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
| Name | Type | Description |
|---|---|---|
| $scripts | list<string> | script URLs, in the order they should load |
| $styles | list<string> | stylesheet URLs, in the order they should apply |
ClientAssets::empty()
public static function empty(): selfNo 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 = []): selfA copy with `$scripts` / `$styles` appended — each list deduplicated by URL, first-seen order preserved.
Parameters
| Name | Type | Description |
|---|---|---|
| $scripts | list<string> | |
| $styles | list<string> |
ClientAssets::merge()
public function merge(self $other): selfA copy with every URL of `$other` appended, deduplicated by URL, this instance's order first.
Parameters
| Name | Type | Description |
|---|---|---|
| $other | self |
ClientAssets::isEmpty()
public function isEmpty(): boolTrue when there is nothing to emit.
ClientAssets::toArray()
public function toArray(): arrayThe assets as data — `{scripts: [...], styles: [...]}`.