@sprig-and-prose/sprig-scene-engine
v0.1.2
Published
Framework-agnostic runtime for compiled scene manifests
Downloads
386
Readme
@sprig-and-prose/sprig-scene-engine
Framework-agnostic runtime for compiled scene manifests. Loads a compiled scene manifest (from @sprig-and-prose/sprig-scenes) and provides common runtime logic: prop initialization with defaults, within reconciliation, and simple helpers to drive a renderer.
Usage
import { createSceneRuntime } from '@sprig-and-prose/sprig-scene-engine';
import type { SceneManifest } from '@sprig-and-prose/sprig-scenes/manifest';
const manifest: SceneManifest = { /* compiled scene JSON */ };
const runtime = createSceneRuntime(manifest, { strict: true });
runtime.getProp('SearchText'); // default ""
runtime.setProp('SearchText', 'foo');
runtime.subscribe((e) => { /* e: RuntimeEvent */ });
runtime.getLayout(); // root layout node
runtime.getNodeModel(node); // NodeModel for heading/section/select/inputv0 support
- Default prop initialization: Each prop gets its manifest
defaultor an inferred value (string →"", integer →0, boolean →false, arrayOf →[], actor ref →null). - Within reconciliation: Props with
within: { prop: "OtherProp" }are reconciled when the referenced options prop or their own value changes. ForarrayOf, selected = selected ∩ options (primitives by strict equality, actor refs by identity key). For scalars, value must be contained in options or is set tonull. EmitsreconciledWithinwhen reconciliation changes a prop. - Node models:
getNodeModel(node)returns a renderer-friendly union:heading,section,select,input, orunknown. Select/input expose aPropBindingwithvalueandset(v).
Not supported yet
- Derived props
- Filters
- Presentations
- Loops
