Skip to content
docsv0.25.1

ClientAssets

The client-side files a rendered view needs the HOST page to load — script and stylesheet URLs a plugin serves from its own routes (greenhouse decisions/0211, "declared views"). A renderer that needs them implements {@see \Milpa\Live\Contracts\Rendering\DeclaresClientAssets}; a compiler collects one of these per rendered node and {@see merge()}s them; the host emits the result ONCE, in declared order. Merging deduplicates by URL and keeps first-seen order, so two components that share a module never make the page load it twice — the value is immutable, every operation returns a new instance.

ClientAssets::__construct()

public function __construct(array $scripts = [], array $styles = []):

Canonical from birth: each list is deduplicated by URL at construction, first-seen order kept.

Parameters

Parameters of __construct()
NameTypeDescription
$scriptslist<string>script URLs, in the order they should load
$styleslist<string>stylesheet URLs, in the order they should apply

ClientAssets::empty()

public static function empty(): self

No assets at all — what a renderer with nothing to declare, or a compile with no declaring renderer, yields.

ClientAssets::with()

public function with(array $scripts = [], array $styles = []): self

A copy with `$scripts` / `$styles` appended — each list deduplicated by URL, first-seen order preserved.

Parameters

Parameters of with()
NameTypeDescription
$scriptslist<string>
$styleslist<string>

ClientAssets::merge()

public function merge(self $other): self

A copy with every URL of `$other` appended, deduplicated by URL, this instance's order first.

Parameters

Parameters of merge()
NameTypeDescription
$otherself

ClientAssets::isEmpty()

public function isEmpty(): bool

True when there is nothing to emit.

ClientAssets::toArray()

public function toArray(): array

The assets as data — `{scripts: [...], styles: [...]}`.