Skip to content
docsv0.1.0

AlpineRuntimeAdapter

The Alpine.js {@see ClientRuntimeAdapterInterface}: marks rendered root elements with `data-milpa-*` attributes an Alpine component picks up, and describes the boot payload / static asset the HTML renderers embed so the browser knows which contracts are live and where to load the runtime script from. Stateless and side-effect-free — every method is a pure projection of its arguments.

AlpineRuntimeAdapter::name()

public function name(): string

The runtime identifier this adapter targets, `"alpine"`.

AlpineRuntimeAdapter::rootAttributes()

public function rootAttributes(Milpa\Live\ValueObjects\ComponentContract $contract, Milpa\Live\ValueObjects\StateSnapshot $state): array

Root-element attributes an HTML renderer merges into a mounted component's wrapper tag so the client runtime can find it and bind to its `$state->componentId`.

Parameters

Parameters of rootAttributes()
NameTypeDescription
$contractMilpa\Live\ValueObjects\ComponentContract
$stateMilpa\Live\ValueObjects\StateSnapshot

AlpineRuntimeAdapter::bootPayload()

public function bootPayload(array $contracts): array

The payload embedded in the page for the client runtime to bootstrap from: this adapter's {@see name()} plus a name/version/design-contract summary of every mounted component contract.

Parameters

Parameters of bootPayload()
NameTypeDescription
$contractsarray

AlpineRuntimeAdapter::assets()

public function assets(): array

Static assets a page rendering this runtime's components must load — currently just the Alpine runtime script.