@zephytiju/prism-composition-model
v1.1.0
Published
Runtime-neutral Prism Operating System and UI-page composition types, canonicalization, validation, migrations, and fixtures.
Readme
PrismCompositionModel
@zephytiju/prism-composition-model is the runtime-neutral source of truth for Prism Operating System and UI-page documents. It publishes pure TypeScript types, deterministic canonical JSON and SHA-256 digests, validators, layout-variant materialization, versioned migrations, and conformance fixtures.
The package contains no transport, persistence, foundation client, UI state, service wire model, or runtime variant resolver.
Contract
- Operating Systems pin ordered immutable UI-page revisions.
- UI-page revisions pin exact layout-template releases and exact Blueprint component versions.
layoutConfigis the runtime authority for an instance.appliedLayoutVariantis optional authoring provenance and is retained only while its exact component release, binding fingerprint, key, and digest match the materialized layout.- Manual edits and component-version changes clear preset provenance and therefore represent
Customwithout changing component configuration, bindings, placement, peers, or the page template.
import { applyLayoutVariant, canonicalDigest } from "@zephytiju/prism-composition-model";
const layoutConfigDigest = await canonicalDigest(layoutConfig);
const updated = await applyLayoutVariant(instance, {
componentRelease: instance.componentRelease,
bindingFingerprint: instance.bindingFingerprint,
key: "dense",
layoutConfig,
layoutConfigDigest,
});Run npm run verify to build, execute conformance vectors, and verify the publishable package contents.
Selected split allocation (1.1)
LayoutNode.splitAllocation is optional page state for an exact template-declared
resizable split: { version: 1, shares: [{ childId, units }] }. Every immediate
child occurs once, in child order, with positive integer units totaling 1,000,000.
Omission preserves legacy documents, template releases and canonical digests.
canonicalSplitAllocation validates unknown JSON; splitAllocationFromWeights
uses largest remainder with child-order ties and rejects zero-unit results.
canonicalizeSplitAllocations and validateUIPageRevision(page, templateDefinition)
require the exact template policy for any explicit allocation. The model does not
resolve or publish templates. Services remain responsible for exact-reference,
whole-page, authorization and concurrency checks.
editSplitLayout(tree, splitId, templateDefinition, edit, innerExtentPx) performs
atomic resize, keyboard resize, add, empty-child removal and reorder operations.
The available extent excludes external panels, gaps and dividers. Keep the old
tree for undo; persist only the resulting canonical page tree. resolveSplitPixels
applies the template axis and size bounds without changing saved shares and returns
fallback when the viewport cannot fit them. Tabs, collapse and responsive adapters
retain the saved allocation and resolve it again on restoration.
The ./fixtures subpath includes splitAllocationVectors for service and Build
conformance. New writes require compatible Composition, SDK, Build Service and
Builder readers; old strict readers must reject unsupported fields without stripping them.
