Runtime model and guarantees
Current runtime model
Section titled “Current runtime model”.css.tsmodules are transformed by Metro- authoring helpers come from
@opsydyn/crumbs-css/style - themed style exports contain token references until runtime resolution
ThemeProvideranduseThemedStylesresolve those tokens against the active theme
Runtime imports
Section titled “Runtime imports”Use @opsydyn/crumbs-css/theme/core for common provider, hook and token-resolution APIs. Its ESM and CommonJS emitted graphs depend externally only on React and exclude Node built-ins, authoring modules, esbuild, integration and CSS conversion code. Use @opsydyn/crumbs-css/theme for token scopes, dependency plans and recipe controls; the existing dist/theme alias shares that compatibility boundary. Use @opsydyn/crumbs-css/tokens for domain-aware token contracts, themes and atomic patches; its ordinary graph is also runtime-safe and contains no authoring/compiler imports. Keep @opsydyn/crumbs-css/tokens/schema and /tokens/optic behind explicit ingress/tooling boundaries because they opt into Effect Schema and Optic. Runtime and tooling JavaScript build separately; declarations share one graph to preserve nominal token compatibility.
Use @opsydyn/crumbs-css/theme/token when a component needs a flat primitive style map with token domains checked against React Native properties. Its createTokenStyles and themeToken authoring types derive value compatibility from createTokenContract; use theme/core for general themed styles, arrays, recipes and related runtime behavior. The new path is opt-in and makes no consumer-bundle or device-performance guarantee.
The root, /style, Metro plugin and transformer remain build-time entrypoints. Installed compiler dependencies are still required for authoring. The playground qualification inspects fresh production source maps for iOS, Android and web in workspace and packed modes; this does not establish device performance or native platform acceptance.
Current guarantees
Section titled “Current guarantees”- React Native focused
- Metro-transform-based
- predictable recipe ordering
- explicit state selection for interactive styles
- stable diagnostic codes for tooling and CI
Resolved output identity
Section titled “Resolved output identity”resolveThemeTokens and resolveThemeStyles treat style exports and themes as
immutable snapshot inputs. Reusing the same object with the same NativeTheme
returns the cached result: static object styles retain their original
reference, tokenized styles retain their resolved reference, and style maps
reuse unchanged entries. Flattened style arrays and recipes retain their
existing semantic output while sharing repeated results.
The cache uses weak keys for both the input object and theme snapshot. A new theme object is a new cache identity, so an update cannot read values from an older snapshot. This is an output identity and allocation guarantee; it does not claim fewer React renders, fewer native frames or a bounded device-memory profile. Treating a style or theme as mutable after resolution is outside the contract.
Planned dependency resolution
Section titled “Planned dependency resolution”Generated native modules carry a versioned dependency plan in their internal
__crumbsModule descriptor. Each immutable path entry names the token variables
used by that style leaf, after native composition and lowering have removed
overridden declarations. Entries are canonical, sorted and frozen.
Pass the plan to createThemeDependencyResolver(styles, dependencyPlan) when
you need selective pure resolution. Each theme transition returns the resolved
value and a receipt with recomputations, notifications and changedTokens.
Only entries whose declared token values or active contract identity changed
are recomputed, and unchanged output references are retained. notifications counts changed output paths as
an invalidation signal for a future subscription layer; it does not measure
React renders or native frames. The style shape must match the emitted paths,
and style modules and themes must be treated as immutable snapshots.
Selective theme subscriptions
Section titled “Selective theme subscriptions”useThemeSelector(selector) reads a selected value from the active
ThemeProvider snapshot. The selector runs against a complete immutable theme
and the hook subscribes with React’s useSyncExternalStore contract. A
provider update publishes one snapshot during the layout commit, so a
consumer never resolves a mixture of old token values and new derived values.
Selectors are compared by reference. Return a primitive or a memoized object
for unchanged input; an inline selector that allocates a new object on every
call will intentionally invalidate on every snapshot read. useThemedStyle
and useThemedStyles provide stable selectors over their style input and keep
the existing weak-cache identity guarantees.
TokenThemeProvider and each TokenThemeScopeProvider own a separate store.
Nested scopes therefore update and notify independently while retaining their
documented token precedence. Consumer unmount releases its subscription, and
the shared-symbol context/store identity survives duplicate package copies and
hot reload. Store tests cover atomic publication, selected-reference
invalidation, nested stores, disposal and context identity; they do not
establish device frame time, native rendering or retained-memory budgets.
Bounded recipe selection
Section titled “Bounded recipe selection”createRecipeResolver precomputes one immutable plan for its recipe: authored
variant order, defaults, compound requirements and the dimensions used by a
canonical selection key. It evaluates selections on demand, so a recipe with
many variant values does not create an eager Cartesian product.
Selection results are retained in a resolver-local least-recently-used cache.
The default cacheSize is 32; 0 disables retention and the accepted maximum
is 1024. Use getCacheStats() to inspect capacity, size, hits, misses,
evictions and disposed. clearCache() releases current entries, while
dispose() releases them permanently and makes later resolver calls fail. A
resolver owns its plan and cache for its lifetime; there is no process-global
strong selection cache. The recipe and its styles must be treated as immutable
snapshots.
Cached and uncached evaluator equivalence
Section titled “Cached and uncached evaluator equivalence”The package tests compare cached theme resolution with an independent uncached oracle over generated literal/token styles and arrays. Repeated calls for the same immutable input and theme retain their documented references. Replacing a theme snapshot or style artifact creates a new cache identity, so a prior resolved value cannot leak into the replacement.
Compiler dependency plans provide the selective invalidation boundary: a token change recomputes and notifies only declared paths, while static and unrelated outputs retain their references. Generated recipe cases compare bounded, zero-capacity and direct uncached resolvers. The plan stores authored variant values and compound matchers linearly; it never eagerly expands the variant Cartesian product.
The suite uses fixed seeds and an independent oracle. It qualifies semantic equivalence, reference identity and invalidation completeness only; it does not measure React renders, Hermes/native frame time, device memory or Android behaviour. Mutating an input after resolution remains outside the snapshot contract.
Native structured values and variant maps
Section titled “Native structured values and variant maps”Legacy token ownership is the exact raw path of key segments. Identical paths can reuse a token name while themes retain independent value maps; different paths that sanitize to that name fail with CRUMBS_CSS_THEME_TOKEN_COLLISION. Registration is atomic and exposed metadata paths are frozen. Theme creation rejects relocated, invalid or unregistered leaves with CRUMBS_CSS_INVALID_THEME_CONTRACT. Registry checks apply within an authoring module instance/compiled graph. Namespace roots by package/design system; distinct cross-package/provider identities and wrong-provider detection remain M3 work. Existing non-colliding names stay unchanged.
Named .css.ts constants preserve finite primitives (including negative zero), undefined fields, dense arrays and plain/null-prototype data records. Ordinary tag-shaped records remain data. Unsupported functions, instances, cycles, accessors, symbols, non-finite values and other unsupported shapes fail with CRUMBS_CSS_UNSUPPORTED_EXPORT and file/export-path context. Default exports are unsupported. Import ordinary constants directly and omit them from style namespaces passed to theme hooks. Shared identity and descriptor/frozen status are outside the data contract. Legacy strings equal to registered style handles remain style references until the native IR provides distinct provenance.
Native token references are exact data DTOs with own enumerable $$type: "crumbs.css.theme-token" and varName fields. Names match --crumbs-[A-Za-z0-9_-]+. Constructors and resolution reject malformed tagged values with CRUMBS_CSS_INVALID_THEME_TOKEN_REFERENCE; the boolean guard returns false without executing reference accessors. Inherited fields, arrays and extra metadata fields are unsupported. JSON-decoded and null-prototype DTOs remain valid. Active theme lookup requires an own token value; missing or inherited values fail with CRUMBS_CSS_MISSING_THEME_TOKEN. Regenerate legacy/extended references when upgrading. These checks do not replace full theme/artifact schema validation.
Runtime resolution preserves supplied transform arrays and their order, native objects such as shadow offsets, scalar siblings and structured-value references. Ordered style arrays replace nested values as whole values. Only top-level token references are resolved; animated nodes are never evaluated by the resolver. Typed view/text/image inputs retain their primitive result types through direct resolvers, hooks, namespace resolution and style arrays.
Compiled styleVariants maps carry internal metadata while preserving their string keys and TypeScript variant keys. Object spread preserves this metadata. Unmarked legacy maps remain compatible when their shape is unambiguous; native structured-value shapes take precedence over ambiguous map shapes. JSON serialization drops map identity, so regenerate compiler artifacts when relying on native-property-like variant names.
The compiler captures static transform arrays and numeric shadowOffset / textShadowOffset before CSS serialization. Both emission modes preserve order and whole-value replacement, including imported bases, primitive helpers, variants and recipes. Transform entries accept one operation: finite numeric perspective/scales, finite numeric or percentage translations, deg/rad rotations/skews, or a 16-number matrix. Empty transforms are retained; offsets require finite numeric width and height.
Other structured authoring shapes, animated nodes and nested tokens fail with CRUMBS_CSS_UNSUPPORTED_STRUCTURED_VALUE even with permissive diagnostics. Direct primitive helpers also exclude animated transform nodes by type. Pass unsupported native values through React Native’s runtime style prop. CSS strings retain the existing converter contract. Regenerate dependent artifacts together after upgrading; compiled-output checks do not establish native rendering or platform-specific shadow behavior. Nested token evaluation remains outside the current resolution contract.
Primitive reference typing
Section titled “Primitive reference typing”Complete view/text/image references retain their primitive types through generic style calls, variant-map entries, theme resolution and hooks. Direct references use the existing authored composition path; nested and repeated references preserve order. Referenced primitives anchor native inline overrides to their property/value sets. Literal-only generic inputs retain NativeStyle; mixed primitive references return a conservative union. No runtime or phantom branding was introduced.
Keep primitive reference annotations when you want their native result types. Widening to NativeStyleRule deliberately selects the legacy contract; generic forwarders can use style<NativeStyleRule>(rule) or the equivalent explicit variant type argument. The default composition reference type is the primitive union; use its second type parameter for target-specific aliases. Direct inline animated values, arbitrary browser class strings and incompatible inline fields remain rejected. Structural typing does not establish provenance; compiler admission remains independent. Recipe inputs are unchanged.
Generic NativeStyle references support direct style(base) and direct variant entries, retaining NativeStyle results. Complete View/Text/Image references retain their separately tested primitive inference. Inline overrides require static authoring values even beside generic references; supported CSS border shorthand remains available. Reference recognition is structural and does not establish runtime provenance or admit arbitrary animated native values into compilation.
Physical border precedence
Section titled “Physical border precedence”Compiled border width/color shorthands expand to physical top/right/bottom/left properties for both tokens and literals, including width/color output from a literal CSS border shorthand. Multi-value literals retain their per-side values. Later broad or side declarations win before class/composition merging; only surviving tokens are resolved. The literal border style field stays global. Typed border fixtures cover direct rules, nested/repeated bases, primitive helpers, variants and recipes in native and web emitters.
Regenerate dependent compiled artifacts together and pass complete styles to React Native; compiled shorthand fields are no longer present. Mixing old shorthand artifacts with new longhands is not qualified. Raw runtime styles retain native behavior. Start/end fields retain the distinct native precedence described below; side-specific compound borders are rejected under the admission rule below. Embedded compound token expressions and unsupported side border-style output retain existing strict diagnostics. No runtime normalization or semantic token validation was added.
Physical radius precedence
Section titled “Physical radius precedence”Compiled borderRadius expands to top-left, top-right, bottom-right and bottom-left corner properties for both tokens and literals before merging. Later broad/corner declarations win across rules, nested/repeated compositions, primitive helpers, variants and recipes. Multi-value literals, percentages and zero retain their values; only surviving tokens are resolved. Independent reference properties cover declaration sequences and compiled compositions in addition to both native and web emitters.
Regenerate dependent artifacts together and pass complete styles to React Native; mixed old shorthand/new corner artifacts remain unqualified. Raw runtime styles keep native behavior. Logical corner fields retain the native precedence described below. Elliptical CSS radii and embedded multi-value token expressions retain existing strict rejection.
Native numeric flex
Section titled “Native numeric flex”Compiled finite numeric flex remains a native field, including negative values and zero. Tokens retain the same field. Later declarations replace only the same property, while explicit grow/shrink/basis siblings survive in either authored order. Yoga determines their combined layout semantics; Crumbs does not expand numeric flex into browser defaults. See React Native flexbox.
Generic inline authoring now matches primitive helpers: flex accepts a number or branded Crumbs token. CSS keyword/multi-part/length/percentage flex forms and nonfinite literals fail strict compilation with CRUMBS_CSS_DROPPED_DECLARATION. Use explicit native grow/shrink/basis properties to migrate CSS shorthand intent. Permissive conversion drops unsupported forms. Token value-domain validation remains future work. Regenerate dependent compiled artifacts together; mixed old/new flex artifacts remain unqualified. Raw runtime styles retain platform behavior, and compiler parity does not establish visual parity between native and web.
Spacing aliases and direction-dependent overlaps
Section titled “Spacing aliases and direction-dependent overlaps”Crumbs ordered authoring normalizes spacing Inline/Block aliases to physical pairs, BlockStart/End to top/bottom, and InlineStart/End to native Start/End fields before merging. Later declarations replace the same canonical field. Raw React Native aliases have fixed native precedence/fallback rules; compiled authoring and raw runtime styles do not promise identical alias winners. Generic inline types and strict compilation reject multi-value CSS alias forms; use separate sides. Regenerate dependent compiled artifacts together and pass complete styles to React Native; mixed old/new alias artifacts remain unqualified.
Logical spacing and border fields stay distinct from physical fields. The installed React Native 0.85.3 Yoga source prefers mapped logical spacing/border widths, while Fabric border colors/radii prefer explicit physical fields. Broad compiled border colors/radii fill physical fields. Top/bottom start/end radius names precede start/start etc.; all eight existing native logical radius fields now pass compiler admission. All surviving tokens require values even when native precedence masks a field. Independent regressions specify compiler preservation and selected source-grounded LTR/RTL precedence cases; they do not establish native rendering, device RTL settings or web visual parity. Crumbs adds no runtime direction mapping or browser writing-mode support. Raw runtime styles retain native alias rules. Side compound borders are rejected under the admission rule below. See React Native layout aliases.
Inset aliases
Section titled “Inset aliases”Compiled inset expands to four physical sides, Inline/Block to physical pairs, BlockStart/End to top/bottom and InlineStart/End to native start/end. Tokens and literals merge on identical fields: later broad/pair/side entries replace only the same canonical field. Negative/zero offsets, percentages and auto remain supported single native values. Native logical fields stay distinct from physical sides; Yoga determines their direction-dependent precedence. Raw React Native aliases retain native priority/fallback rules, which can differ from Crumbs ordered authoring.
Generic inline types now match primitive helpers for single native inset dimensions or branded tokens. Strict compilation rejects unsupported multi-value strings, expressions, units and nonfinite literals with CRUMBS_CSS_DROPPED_DECLARATION; permissive conversion drops them. Use explicit sides for multiple values. Only completely overridden same-field tokens cease to require values; surviving logical fields still resolve even when native precedence masks them. Token value-domain validation remains future work. Regenerate dependent artifacts together; mixed old/new inset artifacts remain unqualified. Raw runtime styles remain unchanged. This targets the supported React Native New Architecture baseline; compiler/source-grounded tests do not establish native layout, device RTL acceptance or web visual parity. No runtime RTL mapping or browser writing-mode support was added. See React Native inset reference.
Side-border admission
Section titled “Side-border admission”Generic inline rules and nested compositions reject physical/Inline/Block side compound borders and their style fields. JavaScript or upstream vanilla-extract rules that bypass these types receive strict CRUMBS_CSS_DROPPED_DECLARATION diagnostics with migration guidance and source/export context. Permissive conversion keeps its existing whole-declaration drop while preserving valid siblings; no width/color partial salvage is promised. Tokens do not make unsupported side styles native properties.
Use explicit side width/color with global borderStyle where the primitive supports it (View/Text). Image helpers keep their narrower native property set. Generic literal broad border remains supported and emits canonical physical widths/colors plus its global style. Replace unsupported declarations before upgrading. Supported output shape and runtime behavior remain unchanged; no per-side style support or RTL mapping was added.
Required coverage and optional native capabilities
Section titled “Required coverage and optional native capabilities”Package tests use durable consumer fixtures for themed styles, variant maps, recipes, web object emission, relative filenames and local theme imports. Tests and benchmarks admit the same required files; missing files/projects and directory impostors fail with the fixture path. An absent app cannot silently remove these checks.
The host Bun harness always measures five runtime operations and two warm compiler fixtures. Its JSON explicitly reports native/device performance as not-run with a reason. Batch-average quantiles are not individual-operation tails; these checks do not measure Hermes, React rendering, frame time or retained memory. Retained iOS simulator functional evidence is separate from these automated gates. Android native acceptance remains deferred and unqualified even when its production JavaScript export succeeds.
What it does not guarantee
Section titled “What it does not guarantee”- browser CSS parity
- global cascade
- selector matching
- CSS-only responsive behavior
- CSS keyframe animations
Recipe ordering guarantee
Section titled “Recipe ordering guarantee”Resolved recipe arrays are ordered like this:
- base
- selected variants in author-defined order
- matching compound variants in array order
Later entries override earlier ones using normal React Native style-array semantics.
Metro configuration and source refresh
Section titled “Metro configuration and source refresh”Native transform cache records include byte receipts for authored inputs, ancestor configuration, extended configuration, installation manifests and logical/canonical resolution paths. A changed receipt rejects the disk-cache record and invalidates the generated importer through the existing Metro bridge. Legacy cache records retain their existing validation. Compiler-only receipts are absent from ordinary theme/token runtime imports.
A fresh compile verifies configuration and input receipts before and after compilation. Newly discovered graphs receive a verification pass; repeated changes reject the transform after three attempts. This is a bounded consistency check, not an atomic filesystem snapshot. Metro source buffers must agree with the saved entry bytes; save the file and retry when a concurrent edit produces a conflict.
Configuration and authored dependency edits can refresh styles. Restart Metro after changing the nearest package identity, replacing the loaded compiler/plugin artifacts, or changing process-owned loader configuration. Installation receipts detect replacement; they do not unload executable modules already held by Node.
No retained esbuild-context cache is enabled in production. The shipping development workflow has bounded iOS simulator and Android emulator Fast Refresh evidence. Local animation state may reset during Fast Refresh; this is not a state-preservation or device-performance guarantee. See the current guarantees matrix for measured scope and failed/incomplete budgets.
Source-current evidence may carry a complete source-content SHA-256 alongside its base revision. Validation checks tracked non-documentation files and newly authored files in the declared source/tool/test roots; stage new files outside those roots before capture. This keeps one code-and-documentation commit verifiable while rejecting code drift. Evidence without this field continues to require the current source commit.
Container-instance selection
Section titled “Container-instance selection”A named one-axis container owner is separate from theme/window conditions and compiler descriptors. Initial/server/hydration selection is unmeasured; native calculated dimensions choose finite lower-inclusive buckets without rounding. Owners retain at most 17 snapshots, publish once per crossing and publish nothing for same-bucket events. Selector notifications use Object.is, with subscriptions detached on final unsubscribe/replacement/unmount. Parent/context/theme renders can still occur.
Nearest matching owners shadow ancestors, including unmeasured instances; siblings do not share state. Equivalent descriptor copies and ESM/CJS package copies share the versioned React context under one physical React installation. No global owner or definition registry exists. Strict replay and committed Suspense reveal reconnect a live owner without resetting its bucket; keyed remounts reset it; retired callbacks ignore payloads. Shared context admission checks writable React ABI data before exposing the context, rejecting incompatible accessors. One handle has one committed provider and must measure one View. Different-bucket reentrant publication fails; sequential feedback remains an application layout constraint.
The container guide explains composition, virtualisation, native portal bridges and evidence limits.
Instance-owned native motion (M11.3)
Section titled “Instance-owned native motion (M11.3)”Immutable pure definitions feed a finite reducer; an instance owner interprets public Animated operations. Opaque run/read/activation tokens retire authority before native stop callbacks can re-enter. The owner acknowledges driver operations before dependent success and attempts every cleanup channel after failures. It reads stopped native presentation through stopAnimation(callback) and never claims partial-channel success.
The Hook commits options and activation in layout effects. Abandoned renders do not publish options. Frames stay in Animated: there is no adapter frame listener, React update, ThemeProvider, global registry or run history. Maximum state is six values and one current run/read cohort; Promise settlement bookkeeping drains at terminals. M11.3’s five-second two-card fixture measures marker pixels and discrete sampled commit counts; those counts are not an instantaneous frame profiler. Exact host, native development, release budgets and physical/reader acceptance remain distinct. See native motion.
Pure authoring algebra (M11.4)
Section titled “Pure authoring algebra (M11.4)”Colour and typography derivations are eager, bounded, frozen plain data. Every ingress validates descriptor fields before reading values; no getter is invoked, operand mutated, registry retained or Hook created. Same-format second-copy descriptors admit by shape, with nominal markers only in types. Native conversions produce strings or numeric text metrics for existing contracts and styles. Mixing is alpha-premultiplied interpolation in an explicit space. Quantisation occurs only on colour emission; typography retains unscaled binary64 metrics after finite float32 admission checks.
Operations are fixed size except named scales, capped at32 steps. Reflection still visits submitted keys before rejecting excess fields. Derive once or memoise design inputs; accessibility font preferences remain native Text ownership. Exact host/packed/native evidence and microbenchmark costs are recorded by the M11.4 assessment, separately from release-policy acceptance.
Explicit runtime factories (M11.5)
Section titled “Explicit runtime factories (M11.5)”A marked factory invocation captures bounded portable data during authoring. The compiler expands genuine native style arguments, verifies static named endpoints and emits fresh frozen argument literals. Each unique invocation reconstructs once per generated-module evaluation; aliases share it and equal separate calls stay distinct. No closure is evaluated or serialised. Native peers are not executed by endpoint verification. Result metadata is opaque, with explicit unresolved factory dependencies instead of inferred component capabilities. Provider requirements belong to the runtime factory: literal wrappers are independent, while themed wrappers always use the existing provider.