Skip to content
docsv0.31.1

ComponentAssetOrchestrator

Gathers what the components of one page declared, and emits it once. This is the seam a component previously did not have. Registering a component was always possible; DRESSING one was not, because its stylesheet had to be patched into whichever package happened to render it — so a plugin could contribute markup and behaviour but never a look, and the promise that the component system was extensible by registry was false at exactly that point. Three payloads travel by this one seam — markup's styles, its script, and its words. Splitting them would build the second system this was meant to end: today `milpa/admin` holds one component system's look in a 4,849-line bundle and its words in a 414-string `private const`, and the two have already drifted. The page hands over the contracts it is about to render — the same list {@see \Milpa\Live\Contracts\Client\ClientRuntimeAdapterInterface::bootPayload()} already receives — and gets back one `<style>` and one `<script>`. Emission is keyed by `name@version`, so a component used fifty times costs its stylesheet once: the alternative, per-instance styling, was measured at ~954 bytes an instance in a system that shipped it. Nothing here reaches the filesystem for anything a contract did not name, and nothing is written.

ComponentAssetOrchestrator::__construct()

public function __construct(Milpa\Live\Assets\CssScoper $scoper = new CssScoper(), Milpa\Live\Assets\ComponentMessages $messages = new ComponentMessages(), ?Milpa\Live\Assets\PresentationOverrides $overrides = null):

Parameters

Parameters of __construct()
NameTypeDescription
$scoperMilpa\Live\Assets\CssScoper
$messagesMilpa\Live\Assets\ComponentMessages
$overrides?Milpa\Live\Assets\PresentationOverrides

ComponentAssetOrchestrator::collect()

public function collect(array $contracts, string $locale = Milpa\Live\Assets\ComponentMessages::DEFAULT_LOCALE): Milpa\Live\Assets\PageAssets

Gathers what this page's components declared: read, scoped, deduplicated, ready to embed.

Parameters

Parameters of collect()
NameTypeDescription
$contractsarray<int, ComponentContract>Every contract the page may render.
$localestringThe language this page is being read in.