Implements the ContextPort<T> abstraction described in the
multi-framework research note. The port is the framework-agnostic
contract for "provide a value at a parent and consume it at any
descendant" — every framework adapter (React createContext, Vue
provide/inject, Svelte setContext/getContext, Lit
@lit/context) wires the same shape into its native primitive so
the core renderer dispatch loop never reaches for a framework-
specific API.
For Lit, the port is implemented on top of
@lit/context, which uses the
proposed Context Protocol
— DOM events bubble up from a consumer until a provider catches them
and seeds the consumer with the requested value. The protocol is
synchronous, DOM-scoped, and runs only in the browser.
SSR caveat.@lit/context does NOT server-render. The Lit SSR
package (@lit-labs/ssr) emits Custom Element markup without firing
the consumer-side context request events, so any value provided via
a ContextPort is undefined on the server. Consumers must default
gracefully — the built-in Lit renderers fall back to the default
resolver when the resolver context is unset, matching their browser
behaviour when no consumer wraps the schema element.
Canonical ContextPort compatibility. The canonical
ContextPort interface declared in core/contexts.ts is
deliberately host-agnostic: provide(value, children): unknown and
consume(): T. Lit's @lit/context requires a ReactiveControllerHost
at every call site to register provider / consumer controllers, so
the Lit ports below cannot match the canonical signature directly.
Rather than declaring a parallel local ContextPort<T> (which would
shadow the canonical type), the Lit adapter exports the port objects
with inferred local types and re-exports the canonical
ContextPort so consumers retain a single source of truth for
the type name.
Context ports for the Lit adapter.
Implements the
ContextPort<T>abstraction described in the multi-framework research note. The port is the framework-agnostic contract for "provide a value at a parent and consume it at any descendant" — every framework adapter (ReactcreateContext, Vueprovide/inject, SveltesetContext/getContext, Lit@lit/context) wires the same shape into its native primitive so the core renderer dispatch loop never reaches for a framework- specific API.For Lit, the port is implemented on top of
@lit/context, which uses the proposed Context Protocol — DOM events bubble up from a consumer until a provider catches them and seeds the consumer with the requested value. The protocol is synchronous, DOM-scoped, and runs only in the browser.SSR caveat.
@lit/contextdoes NOT server-render. The Lit SSR package (@lit-labs/ssr) emits Custom Element markup without firing the consumer-side context request events, so any value provided via aContextPortisundefinedon the server. Consumers must default gracefully — the built-in Lit renderers fall back to the default resolver when the resolver context is unset, matching their browser behaviour when no consumer wraps the schema element.Canonical ContextPort compatibility. The canonical ContextPort interface declared in
core/contexts.tsis deliberately host-agnostic:provide(value, children): unknownandconsume(): T. Lit's@lit/contextrequires aReactiveControllerHostat every call site to register provider / consumer controllers, so the Lit ports below cannot match the canonical signature directly. Rather than declaring a parallel localContextPort<T>(which would shadow the canonical type), the Lit adapter exports the port objects with inferred local types and re-exports the canonical ContextPort so consumers retain a single source of truth for the type name.