@epilot/zenith-runtime
v0.3.2
Published
The runtime behind @epilot/zenith-react: one Griffel engine, one renderer instance, one insertion anchor, the Base UI primitives and the core token sheet, shared across every co-resident copy
Maintainers
Keywords
Readme
@epilot/zenith-runtime
The runtime behind @epilot/zenith-react: styling and stylesheet coordination,
and, since DECISIONS.md D13, the Base UI primitives and the core token sheet
the component package would otherwise bundle into every application.
The runtime owns the Griffel renderer, deterministic class salt, insertion
anchor, and document-scoped stylesheet coordination. /v1 also exports one
namespace per Base UI family Zenith wraps (dialog, switch, alertDialog, …;
BASE_UI_FAMILIES is the index) and tokenSheets, the core sheets by structure
hash (getTokenSheet, ensureTokenSheet). Token values stay with the React
package; the runtime serves the compiled sheet for the hash a package asks for.
A hash means "this structure, latest values": a token value change keeps the hash
and scripts/emit-shared.ts rewrites the current sheet's archived module in place.
The sheets are an append-only archive (src/v1/sheets/): a structure change (a token
added, removed or renamed) adds a sheet and nothing removes one, so a runtime released
with it keeps serving the previous hash, as emitted, for the applications still
compiled against it. A hash leaves the served set only through
src/v1/token-sheets.retired.ts, by hand. The runtime also corrects what applications bring
themselves: the ensureSheet it exports replaces the coloured text (light steps 11 and a11) and the
solid-fill colours (steps 9 to 10, indicator, track, solid, solid-hover, contrast, on-solid) of
the core and palette sheets, derived per block by scripts/emit-shared.ts into src/v1/token-corrections.generated.ts, in the CSS an
application passes for those hashes with the latest build's values, so a contrast fix reaches
deployed applications without a rebuild; the archive and every other token or block are never changed. src/v1/abi.test.ts pins every served
family, every member and every archived hash: a release cannot drop or rename one
without that pin changing in the same change.
React is a peer: the served primitives render on the consumer's React, and on
nothing else. A host that serves the runtime through its import map and builds
that artefact itself (a wrapper around @epilot/zenith-runtime/v1) marks
react and react-dom as external, so the runtime runs on the page's single
React, the import map's copy, never a bundled one, and takes react/jsx-runtime
from that same React version (#116). A runtime bundled with a React of its own
makes every served primitive's hooks run on a React that is not rendering, which
surfaces as a minified useMemo of null; a react/jsx-runtime of another React
version creates elements the page's React rejects as not valid children. The
runtime says so instead of crashing: assertCompatibility takes the
application's react, @epilot/zenith-react passes its own before any component
renders, and either mismatch stops the application at startup with a message
naming this rule. The SystemJS bundle registers react and react-dom as its
only dependencies and inlines a JSX runtime shim over the host's createElement
(src/system/jsx-runtime.ts), so the same artefact serves React 18 and React 19
hosts.
Most applications should not import this package directly: install
@epilot/zenith-react, whose caret range on this package (for example ^0.2.0)
lets the bundler resolve a compatible runtime; a consumer that bundles the
runtime keeps only the families it renders. A portal may externalize
@epilot/zenith-runtime/v1 only after the host serves a runtime inside that
range. When what the runtime serves changes, the
runtime is released and deployed by the host before any application that needs
it (D13, "Release and deploy order").
bun run build # emits the class salt and src/v1/shared.generated.ts, then the npm dist
bun run build:system # dist/bundle.js, the artefact an import map points at
bun run testWhat root-config serves. One file per runtime release, dist/bundle.js or
the host's own wrapper around @epilot/zenith-runtime/v1 built as above, at an
immutable, versioned URL under the one key:
{ "@epilot/zenith-runtime/v1": "<base>/bundle.js" }Applications externalize that key alone. The per-family entries of runtime
0.2.0-next.4 (/v1/core.js, /v1/<family>.js) are not served any more;
DECISIONS.md D13 ("the per-family split is reverted for 0.2.0") records why
and the split configuration to revisit.
@base-ui/react is an exact devDependency, vendored into the dist like Griffel:
the served primitives are part of the /v1 ABI. A Base UI major bump is a new
versioned path, never a change to /v1.
bun scripts/bench/shared-primitives.mjs (repository root) measures what the
served primitives and sheet change for an application and for this bundle.
