@yahoo/uds-create-config 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,10 @@ import { componentLayerClass, componentPropClasses, componentRuleClasses, layerC
8
8
  const refOf = (value) => typeof value?.__ref === "string" ? value.__ref : void 0;
9
9
  const layerOf = (element) => {
10
10
  const target = refOf(element);
11
- if (target === void 0) return void 0;
11
+ if (target === void 0) {
12
+ const standing = element?.layer;
13
+ return boundPropOf(element) !== void 0 && typeof standing === "string" ? standing : void 0;
14
+ }
12
15
  const { kind, qualifiedPath } = splitRef(target);
13
16
  return kind === "layer" ? qualifiedPath : void 0;
14
17
  };
@@ -17,6 +20,54 @@ const boundPropOf = (element) => {
17
20
  const marker = element?.$state;
18
21
  return typeof marker === "string" ? marker.replace(/^\//, "") : void 0;
19
22
  };
23
+ /** A stored element as a spec type: an intrinsic tag stays, a ref becomes its key. */
24
+ const typeOfStored = (element) => typeof element === "string" ? element : refOf(element);
25
+ /**
26
+ * The registry key of an element rendered THROUGH a package factory — `motion.create(Box)`, spelled
27
+ * `package:motion/react#motion(component:Box)`.
28
+ *
29
+ * The render wrapped the layer, so the module paints motion's element and the anatomy has to say
30
+ * so, or a cell shows the layer without the transition, the hidden-when-empty collapse, the press
31
+ * scale. The registry emits one entry per pair the anatomies name (see codegen's registry emitter);
32
+ * this is the one spelling both sides use. Not a ref path — the parentheses keep it from parsing as
33
+ * one — since it names a derived thing, not an entity.
34
+ */
35
+ function wrappedElementKey(wrapper, type) {
36
+ return `${wrapper}(${type})`;
37
+ }
38
+ /** The type inside a {@link wrappedElementKey}, or `undefined` for a key that wraps nothing. */
39
+ function unwrapElementKey(key) {
40
+ const open = key.indexOf("(");
41
+ if (open === -1 || !key.endsWith(")")) return void 0;
42
+ return key.slice(open + 1, -1);
43
+ }
44
+ /** The type a node renders as, wrapped when the node names a wrapper. */
45
+ function wrappedTypeOf(node, type) {
46
+ if (type === void 0) return void 0;
47
+ const wrapper = refOf(node.wrapper);
48
+ return wrapper ? wrappedElementKey(wrapper, type) : type;
49
+ }
50
+ /**
51
+ * The element a bound node mounts for one value, when the render wrote its own enumeration.
52
+ *
53
+ * `boundElementType` answers a DOMAIN lookup — the value names an icon, the library resolves it. A
54
+ * dispatch is the other shape: the render listed the alternatives itself (`if (mode === 'link')
55
+ * return <ChipLink/>`), so the map is the render's own words and the `else` is its final return.
56
+ * The map is asked first, the domain second, the fallback last — so an unset prop mounts what the
57
+ * render mounts for one.
58
+ */
59
+ function boundChoice(config, componentPath, element, value) {
60
+ const bound = boundPropOf(element);
61
+ if (bound === void 0) return void 0;
62
+ const { map, else: otherwise } = element;
63
+ if (map && typeof value === "string" && value in map) {
64
+ const chosen = typeOfStored(map[value]);
65
+ if (chosen) return chosen;
66
+ }
67
+ const fromDomain = boundElementType(config, componentPath, bound, value);
68
+ if (fromDomain) return fromDomain;
69
+ return typeOfStored(otherwise);
70
+ }
20
71
  /** The slot PROP a node STANDS FOR — a `Slot`-typed node whose `name` prop says which prop's
21
72
  * instance content splices at its position among the siblings. json-render's own vocabulary (the
22
73
  * `Slot` registry primitive and its `name` prop), so the stored node and the rendered element are
@@ -104,6 +155,7 @@ function entryKeyOf(nodes) {
104
155
  * own layers to whatever that layer is; a bound element has no json-render form (its `type` is a
105
156
  * plain string), so it is reported rather than guessed at. */
106
157
  function typeOf(layers, element) {
158
+ if (boundPropOf(element) !== void 0) return typeOfStored(element.else);
107
159
  const layer = layerOf(element);
108
160
  const target = layer === void 0 ? element : layers[layer];
109
161
  if (typeof target === "string") return target;
@@ -152,7 +204,7 @@ function deriveSpec(config, path) {
152
204
  };
153
205
  continue;
154
206
  }
155
- const type = typeOf(layers, node.element);
207
+ const type = wrappedTypeOf(node, typeOf(layers, node.element));
156
208
  if (!type) return void 0;
157
209
  const layer = layerOf(node.element);
158
210
  const props = {
@@ -163,16 +215,7 @@ function deriveSpec(config, path) {
163
215
  "data-uds-component": path
164
216
  } : {}
165
217
  };
166
- let children = node.children?.length ? [...node.children] : void 0;
167
- if (props.children !== void 0 && children) {
168
- const textKey = `${key}•text`;
169
- elements[textKey] = {
170
- type: "span",
171
- props: { children: props.children }
172
- };
173
- delete props.children;
174
- children = [textKey, ...children];
175
- }
218
+ const children = node.children?.length ? [...node.children] : void 0;
176
219
  elements[key] = {
177
220
  type,
178
221
  ...Object.keys(props).length ? { props } : {},
@@ -564,7 +607,7 @@ function consumedProps(config, path, body) {
564
607
  function computeConsumedProps(config, path, body) {
565
608
  const consumed = new Set(["className", "layerProps"]);
566
609
  const declared = body.props ?? {};
567
- for (const [name, decl] of Object.entries(declared)) if (decl?.type === "variant" || decl?.type === "slot" || decl?.type === "forward" || decl?.type === "composite") consumed.add(name);
610
+ for (const [name, decl] of Object.entries(declared)) if (decl && decl.type !== "styleProperty") consumed.add(name);
568
611
  for (const rule of componentRuleClasses(config, path)) for (const prop of Object.keys(rule.when)) if (declared[prop]) consumed.add(prop);
569
612
  return consumed;
570
613
  }
@@ -658,6 +701,8 @@ function classesFor(config, path, layer, state, extra) {
658
701
  /** Emit one element, expanding it when the config describes what it's made of. Returns the key it
659
702
  * was emitted under. */
660
703
  function place(sink, type, props, children, hint, slots) {
704
+ const target = unwrapElementKey(type);
705
+ if (target !== void 0 && sink.rendered && !sink.rendered.has(type)) return place(sink, target, props, children, hint, slots);
661
706
  if (expandable(sink, type)) return expandInstance(sink, pathOf(type), props, children, hint, slots);
662
707
  let tag = type;
663
708
  let own = props;
@@ -676,6 +721,21 @@ function place(sink, type, props, children, hint, slots) {
676
721
  };
677
722
  return key;
678
723
  }
724
+ /** Whether any node under `key` (itself excluded) binds `prop` as its content. */
725
+ function subtreeBinds(anatomy, key, prop) {
726
+ const seen = /* @__PURE__ */ new Set();
727
+ const visit = (at) => {
728
+ if (seen.has(at)) return false;
729
+ seen.add(at);
730
+ const node = anatomy[at];
731
+ if (!node) return false;
732
+ return [...node.children ?? [], ...Object.values(node.slots ?? {}).flat()].some((child) => {
733
+ const pointer = ((anatomy[child]?.props)?.children)?.$state;
734
+ return typeof pointer === "string" && pointer.replace(/^\//, "") === prop || visit(child);
735
+ });
736
+ };
737
+ return visit(key);
738
+ }
679
739
  /**
680
740
  * Replace one component instance with the tree it is made of.
681
741
  *
@@ -698,6 +758,19 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
698
758
  };
699
759
  const consumed = consumedProps(config, path, body);
700
760
  const { byLayer: targets } = slotTargets(config, path, body);
761
+ const valueRoutes = /* @__PURE__ */ new Map();
762
+ for (const [from, decl] of Object.entries(body.props ?? {})) {
763
+ if (decl?.type !== "forward") continue;
764
+ if (routesContent(config, layers, decl)) continue;
765
+ const target = refOf(decl.target);
766
+ if (!target) continue;
767
+ const routes = valueRoutes.get(pathOf(target)) ?? [];
768
+ routes.push({
769
+ from,
770
+ into: intoName(decl.into)
771
+ });
772
+ valueRoutes.set(pathOf(target), routes);
773
+ }
701
774
  const supplied = {
702
775
  ...body.defaultProps ?? {},
703
776
  ...instanceProps
@@ -723,7 +796,12 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
723
796
  let contentPlaced = false;
724
797
  const routedFroms = /* @__PURE__ */ new Set();
725
798
  for (const target of targets.values()) routedFroms.add(target.from);
726
- const unroutedFills = Object.entries(instanceSlots ?? {}).filter(([from]) => !routedFroms.has(from)).flatMap(([, fills]) => fills);
799
+ const positioned = /* @__PURE__ */ new Set();
800
+ for (const node of Object.values(anatomy)) {
801
+ const prop = slotAnatomyPropOf(node);
802
+ if (prop !== void 0) positioned.add(prop);
803
+ }
804
+ const unroutedFills = Object.entries(instanceSlots ?? {}).filter(([from]) => !routedFroms.has(from) && !positioned.has(from)).flatMap(([, fills]) => fills);
727
805
  const allContent = [...content, ...unroutedFills];
728
806
  const emit = (key, keyHint) => {
729
807
  const node = anatomy[key];
@@ -733,7 +811,8 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
733
811
  const isRoot = key === hostNode;
734
812
  let type = typeOf(layers, node.element);
735
813
  const bound = boundPropOf(node.element);
736
- if (bound) type = boundElementType(config, path, bound, state[bound]);
814
+ if (bound) type = boundChoice(config, path, node.element, state[bound]);
815
+ type = wrappedTypeOf(node, type);
737
816
  if (!type) {
738
817
  sink.unresolved.add(bound ? `component:${path}#${key} (${bound})` : `component:${path}#${key}`);
739
818
  return;
@@ -748,12 +827,13 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
748
827
  return key;
749
828
  }
750
829
  const slot = layer ? targets.get(layer) : void 0;
751
- const slotValue = slot ? instanceProps[slot.from] : void 0;
830
+ const slotValue = slot && !subtreeBinds(anatomy, key, slot.from) ? instanceProps[slot.from] : void 0;
752
831
  const props = layer ? {
753
832
  ...authoredProps(config, node.props),
754
833
  "data-uds-component": path,
755
834
  "data-uds-layer": layer,
756
835
  ...forwarded[layer],
836
+ ...Object.fromEntries((valueRoutes.get(layer) ?? []).filter(({ from }) => state[from] !== void 0).map(({ from, into }) => [into, state[from]])),
757
837
  ...isRoot ? rest : {},
758
838
  ...slot && slotValue !== void 0 ? { [intoName(slot.into)]: slotValue } : {},
759
839
  ...layerProps[layer],
@@ -765,20 +845,32 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
765
845
  } : authoredProps(config, node.props);
766
846
  if (node.text !== void 0) props.children = node.text;
767
847
  const children = [];
848
+ const boundFills = {};
849
+ for (const [name, value] of Object.entries(props)) {
850
+ const bound = boundPropOf(value);
851
+ const fills = bound !== void 0 ? instanceSlots?.[bound] : void 0;
852
+ if (!fills?.length) continue;
853
+ delete props[name];
854
+ if (name === "children") children.push(...fills);
855
+ else boundFills[name] = [...fills];
856
+ }
768
857
  for (const child of node.children ?? []) {
769
858
  const childSlot = slotAnatomyPropOf(anatomy[child]);
770
859
  if (childSlot !== void 0) {
771
- if (childSlot === untargetedSlot && allContent.length > 0) {
772
- children.push(...allContent);
773
- contentPlaced = true;
774
- }
860
+ if (childSlot === untargetedSlot) {
861
+ const fills = instanceSlots?.[childSlot] ?? [];
862
+ if (allContent.length > 0 || fills.length > 0) {
863
+ children.push(...allContent, ...fills);
864
+ contentPlaced = true;
865
+ }
866
+ } else children.push(...instanceSlots?.[childSlot] ?? []);
775
867
  continue;
776
868
  }
777
869
  const placed = emit(child, `${keyHint}•${child}`);
778
870
  if (placed) children.push(placed);
779
871
  }
780
872
  if (isRoot && allContent.length > 0 && !contentPlaced) children.push(...allContent);
781
- const slots = {};
873
+ const slots = { ...boundFills };
782
874
  const routed = slot ? instanceSlots?.[slot.from] : void 0;
783
875
  const overridden = routed?.length && slot && !slot.untargeted ? intoName(slot.into) : void 0;
784
876
  for (const [name, fills] of Object.entries(node.slots ?? {})) {
@@ -787,12 +879,7 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
787
879
  if (placedFills.length) slots[name] = placedFills;
788
880
  }
789
881
  if (overridden && routed) slots[overridden] = [...routed];
790
- if (routed?.length && !overridden) children.push(...routed);
791
- if ((node.text !== void 0 || node.props !== void 0 && "children" in node.props) && props.children !== void 0 && children.length > 0) {
792
- const text = props.children;
793
- delete props.children;
794
- children.unshift(place(nested, "span", { children: text }, [], `${keyHint}•text`));
795
- }
882
+ if (routed?.length && !overridden && !(slot && positioned.has(slot.from))) children.push(...routed);
796
883
  const placed = place(nested, type, props, children, keyHint, Object.keys(slots).length ? slots : void 0);
797
884
  if (visible === void 0) withCondition(nested, placed, { visible: node.visible });
798
885
  return placed;
@@ -824,9 +911,15 @@ function expandSpec(config, spec, options = {}) {
824
911
  unresolved: /* @__PURE__ */ new Set(),
825
912
  expanding: []
826
913
  };
914
+ const emitting = /* @__PURE__ */ new Set();
827
915
  const emit = (key) => {
828
916
  const element = spec.elements[key];
829
917
  if (!element) return void 0;
918
+ if (emitting.has(key)) {
919
+ sink.unresolved.add(key);
920
+ return;
921
+ }
922
+ emitting.add(key);
830
923
  const children = [];
831
924
  for (const child of element.children ?? []) {
832
925
  const placed = emit(child);
@@ -836,6 +929,7 @@ function expandSpec(config, spec, options = {}) {
836
929
  for (const [name, fills] of Object.entries(element.slots ?? {})) slots[name] = fills.map((fill) => emit(fill)).filter((placed) => placed !== void 0);
837
930
  const placed = place(sink, element.type, { ...element.props }, children, key, slots);
838
931
  if (element.visible !== void 0) withCondition(sink, placed, { visible: element.visible });
932
+ emitting.delete(key);
839
933
  return placed;
840
934
  };
841
935
  return {
@@ -857,4 +951,4 @@ function expandComponent(config, path, props = {}, options = {}) {
857
951
  return expandSpec(config, instanceSpec(path, props), options);
858
952
  }
859
953
  //#endregion
860
- export { boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, previewSpec, resolveVisibility, slotAnatomyPropOf, slotTargetsOf, specWithResolvedVisibility, visibilityStateProps, visibilityTerms, withoutTruthyTerm };
954
+ export { boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, previewSpec, resolveVisibility, slotAnatomyPropOf, slotTargetsOf, specWithResolvedVisibility, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
@@ -15,7 +15,7 @@ import { Patch, SerializedConfig } from "./Config.js";
15
15
  * sets this constant to its own older timestamp; the merge ref then carries a registered migration
16
16
  * newer than the constant, and the assertion fails until the author re-mints.
17
17
  */
18
- declare const CURRENT_SCHEMA_VERSION = 20260914155048;
18
+ declare const CURRENT_SCHEMA_VERSION = 20260914181845;
19
19
  /** What the walkers need to see of an envelope — loose on purpose, so a typed `SerializedConfig`
20
20
  * and a raw old-shape record both flow in without casts. */
21
21
  interface VersionStamped {
@@ -13,7 +13,7 @@ import { ConfigFormatError } from "./rejection.js";
13
13
  * sets this constant to its own older timestamp; the merge ref then carries a registered migration
14
14
  * newer than the constant, and the assertion fails until the author re-mints.
15
15
  */
16
- const CURRENT_SCHEMA_VERSION = 20260914155048;
16
+ const CURRENT_SCHEMA_VERSION = 20260914181845;
17
17
  /** The mint that moved `options` into the `settings` kind — restated here, rather than imported
18
18
  * from the migration that owns it, because that migration imports this module. */
19
19
  const SETTINGS_AS_KIND_VERSION = 20260908171448;
@@ -45,7 +45,7 @@ function registerSchemaMigrations(...migrations) {
45
45
  for (const migration of migrations) {
46
46
  if (migration.version !== 1 && !isMintTimestamp(migration.version)) throw new Error(`Schema migration version ${migration.version} is not a mint timestamp — mint one with \`date +%Y%m%d%H%M%S\`, like a supabase migration.`);
47
47
  if (REGISTERED.has(migration.version)) throw new Error(`A schema migration at version ${migration.version} is already registered.`);
48
- if (migration.version > 20260914155048) throw new Error(`Schema migration ${migration.version} is newer than CURRENT_SCHEMA_VERSION (${CURRENT_SCHEMA_VERSION}) — a stale branch merged, or the mint forgot to bump the constant. Re-mint: set CURRENT_SCHEMA_VERSION to the newest migration version.`);
48
+ if (migration.version > 20260914181845) throw new Error(`Schema migration ${migration.version} is newer than CURRENT_SCHEMA_VERSION (${CURRENT_SCHEMA_VERSION}) — a stale branch merged, or the mint forgot to bump the constant. Re-mint: set CURRENT_SCHEMA_VERSION to the newest migration version.`);
49
49
  REGISTERED.set(migration.version, migration);
50
50
  }
51
51
  }
@@ -102,7 +102,7 @@ function pendingFor(version, target, options) {
102
102
  * Already-current input passes through untouched — same reference, so hot paths pay nothing.
103
103
  */
104
104
  function upgradeSerializedConfig(json, options) {
105
- const target = options?.target ?? 20260914155048;
105
+ const target = options?.target ?? 20260914181845;
106
106
  const version = detectedWireVersion(json);
107
107
  if (version > target) throw new SchemaVersionTooNew(version, target);
108
108
  const raw = json;
@@ -160,7 +160,7 @@ function upgradedSources(json, options) {
160
160
  * meaning under the current schema and replay skips it — reported by the caller, not swallowed here.
161
161
  */
162
162
  function upgradePatch(patch, writtenAt, options) {
163
- const target = options?.target ?? 20260914155048;
163
+ const target = options?.target ?? 20260914181845;
164
164
  if (writtenAt > target) throw new SchemaVersionTooNew(writtenAt, target);
165
165
  let current = patch;
166
166
  for (const migration of pendingFor(writtenAt, target, options)) {
@@ -179,7 +179,7 @@ function upgradePatch(patch, writtenAt, options) {
179
179
  * stamp would cause.
180
180
  */
181
181
  function upgradeDraftEntries(draft, options) {
182
- const target = options?.target ?? 20260914155048;
182
+ const target = options?.target ?? 20260914181845;
183
183
  const entries = [];
184
184
  const held = [];
185
185
  const retired = [];
package/dist/index.d.ts CHANGED
@@ -61,6 +61,7 @@ import { RefMember, STYLE_PROP_VALUE_FORMS, STYLE_PROP_VALUE_LEAVES, StylePropLe
61
61
  import { OverrideCondition, Token, TokenBody, defineOverride, overrideCondition, overrideKey, overrideKeyModifiers, overrideModifiers } from "./entities/system/Token.js";
62
62
  import { Tool } from "./entities/system/Tool.js";
63
63
  import { TokenBinding, TokenMatch, matchTokens, searchTokens, tokenBinding } from "./entities/system/token-index.js";
64
+ import { AnatomyIssue, AnatomyIssueKind, AnatomyReport, DiffOptions, RenderedNode, SIZE_TOLERANCE_PX, STYLE_PROPERTIES, anatomyIssueKey, diffRendered, normalizeStyleValue, renderedSignatureOf, snapshotHtml } from "./framework/anatomy-check.js";
64
65
  import { ChangeHook, runChangeHooks } from "./framework/change-hooks.js";
65
66
  import { Change, ChangeTarget, baseOf, changeOf, changeValueAt, changesOf, describeBody, summarizeChanges } from "./framework/changes.js";
66
67
  import { ComponentRuleClass, SplitStyleProps, componentClassBase, componentCompositeClasses, componentLayerClass, componentMotionClasses, componentPropClasses, componentRuleClasses, forceModeAttribute, forceModeAttributeOf, forceModeProp, forceModePropGroup, forceModePropValue, forceModeProps, forceStateAttribute, isForceModeProp, kebabComponent, layerCompositeProps, modifierUtilitiesUsed, motionClassName, ruleCondition, splitStyleProps, stylePropClassBase, stylePropClassName, stylePropClasses, styleRuleMotionClasses } from "./framework/class-names.js";
@@ -75,7 +76,7 @@ import { ForwardClaims, SurfaceCompositeProp, SurfaceProp, SurfacePropKind, Surf
75
76
  import { DanglingLocalRef, UnknownStyleLeaf, danglingLocalRefs, unknownStyleLeaves } from "./framework/ref-integrity.js";
76
77
  import { resolveInputDir, resolveOutDir, resolveRegistryDir } from "./framework/registry-dir.js";
77
78
  import { InferredRename, inferredRenames } from "./framework/rename-inference.js";
78
- import { ComponentSpec, ComponentSpecs, ExpandOptions, ExpansionResult, RenderElement, RenderSpec, SlotTarget, VisibilityOperator, VisibilityTerm, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, previewSpec, resolveVisibility, slotTargetsOf, specWithResolvedVisibility, visibilityStateProps, visibilityTerms, withoutTruthyTerm } from "./framework/render-spec.js";
79
+ import { ComponentSpec, ComponentSpecs, ExpandOptions, ExpansionResult, RenderElement, RenderSpec, SlotTarget, VisibilityOperator, VisibilityTerm, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, previewSpec, resolveVisibility, slotTargetsOf, specWithResolvedVisibility, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey } from "./framework/render-spec.js";
79
80
  import { CURRENT_SCHEMA_VERSION, SchemaMigration, SchemaVersionTooNew, UpgradedDraft, WalkOptions, detectedWireVersion, registerSchemaMigrations, schemaVersionOf, upgradeDraftEntries, upgradePatch, upgradeSerializedConfig } from "./framework/schema-version.js";
80
81
  import { ConfigSession, ConfigSessionOptions, ConfigSink, ConfigSource, DraftSource, RebaseOrigin, SourceChange, memoryConfigSource } from "./framework/session.js";
81
82
  import { SignatureOptions, renderSignature, signatureOf } from "./framework/signature.js";
@@ -87,4 +88,5 @@ import { valueLeavesOf, valueSchemaOf } from "./framework/value-domain.js";
87
88
  import { views } from "./framework/views-facade.js";
88
89
  import { RN_STYLE_KEYS } from "./react-native/style-keys.generated.js";
89
90
  import { namedSlotTargets } from "./spec/empty-node-slots.js";
90
- export { AI_LANES, AiChat, AiFlow, type AiFlowOrigin, AiGeneration, type AiLane, AiMessage, type AiMultiAgentMode, type AnySystemConfig, type AsInput, type AttachedSources, type Authored, type AuthoredComponent, type AuthoredProp, type AuthoredPropBody, type AuthoringSignatureOptions, BUILD_DEFAULTS, type BreakOutcome, type BreakPlan, type BreakPlanInput, type BreakPlanRow, type BreakReach, BuildSection, CANVAS_ROLES, CONFIG_OPERATION_KIND, CSS_DEFAULTS, CSS_PROPERTY_NAMES, CSS_WIDE_KEYWORDS, CURRENT_SCHEMA_VERSION, Canvas, CanvasConfig, CanvasRole, type CanvasRoleName, CanvasSection, type Change, type ChangeHook, type ChangeTarget, type ChildrenPolicy, type Collection, type ColorValue, Component, type ComponentBody, type ComponentBuilder, type ComponentContractOf, type ComponentElementBody, type ComponentModuleSource, type ComponentPropBody, type ComponentPropsOf, type ComponentReference, type ComponentRegistryImport, type ComponentRegistryImportBinding, type ComponentRuleClass, type ComponentSpec, type ComponentSpecs, type ComponentStyleBody, Composite, type ComputedFields, type ComputedInput, type ComputedMap, Config, type ConfigClass, type ConfigEdit, ConfigFormatError, type ConfigInstance, type ConfigIssue, type ConfigIssueCode, type ConfigKind, type ConfigOp, ConfigRejection, ConfigSession, type ConfigSessionOptions, type ConfigSink, type ConfigSource, type CopyPlan, type CopyPlanInput, type CopyPlanRow, type CreateInput, type CssGrammar, type CssPrefix, type CssPropertyEntry, CssSection, DERIVED_MUTATIONS, type DanglingDirective, type DanglingLocalRef, type DanglingRef, type DeclaredRuntimeModule, type DeletePlan, type DeriveMembers, type DerivedColor, type DerivedEntityClass, type DerivedOp, Device, type DraftSource, ENTITY_PATH_MESSAGE, EXPORT_MEMBER, type Edition, type ElementVisibility, type ElementVisibilityInput, Entity, type EntityAddress, type EntityChange, type EntityClass, type EntityKind, type EntityMap, type ExpandOptions, type ExpansionResult, type ExtendedComponentRef, type ExtendedRef, type FieldsSchema, File, Font, FontFile, type ForwardClaims, GROUP, GUIDANCE_LANES, GlobalStyle, type Gradient, type GroupBody, Guidance, type GuidanceLane, type GuidanceScope, type GuidanceSegment, GuidanceStyle, type GuidanceStyleBody, type HasSnapshot, type HydrationOptions, ICON_METADATA_FORMATS, Icon, type IconLibrary, type IconMemberMetadata, type IconMetadataAdapter, type IconMetadataDeclaration, type IconMetadataFile, type IconMetadataFormat, type IdentifiedOp, type InferredRename, type ItemOf, type KindSignature, type KindSlice, LINK_SLUG, LINK_SLUG_MESSAGE, type LayerElement, type LayerMap, type LayerStyleOptions, type LeafAddress, type LinkArrival, type LinkDeclaration, type LinkPaths, type LinkPlan, type LinkPlanInput, LinkedSystem, type LinkedSystemResolver, type LinkedSystemState, type ListOptions, type LiveConfig, type LocalOverlay, MINTED, MODIFIER_CATEGORIES, type MisdeclaredOverlay, Modifier, type ModifierCategory, type ModifierGroupMeta, Motion, NATIVE_ACTIVATIONS, type NativeActivation, NativeModifier, NativeSettings, NativeStyleProperty, NativeToken, Node, type OpHandler, type OpInput, Operation, type OverlayVerb, type OverrideCondition, type OwnedRecords, PLAYGROUND_DEFAULTS, Package, Page, type Patch, type PathOf, type PinDirective, type PinOptions, type PinOptionsField, type Plan, type PlanImpact, type PlanOp, PlaygroundSection, type PreviewMatrix, type ProjectedVisibility, type PropDecl, type PropDeclaration, type PropMap, RN_STYLE_KEYS, ReactNativeSystem, type ReactNativeSystemConfig, type RebaseConflict, type RebaseOrigin, type RebaseResult, type RecordedSource, type RedundantQualifier, type Ref, type RefGraph, type RefGraphEntry, type RefIndex, type RefIndexChange, type RefMember, type RefTarget, type RegisteredComponentContracts, type RegisteredEntities, type RegisteredModifiers, type RegisteredPaths, type RegisteredStyleProps, type RenamePlan, type RenderArgs, type RenderElement, type RenderSpec, type RenderedTarget, type ResolveValueTypeInput, type ResolvedSource, SCRIPT_EXTENSIONS, SERIALIZED_CONFIG_VERSION, STYLE_PROP_VALUE_FORMS, STYLE_PROP_VALUE_LEAVES, type SchemaEntry, type SchemaMigration, SchemaVersionTooNew, type SerializedConfig, type SerializedSourceAnswer, Settings, type SignatureOptions, type SkippedOp, type SlotTarget, Snapshot, type Source, type SourceAnswer, type SourceChange, type SourceMap, type SourceResolution, type SourceResolutionSchemas, type SourceResolver, type SourceRowState, type SourceState, type SourceUnavailable, type SourcesBySlug, type SourcesOf, type SpecNode, type SplitStyleProps, type StampedPatch, type StoredConfig, type StoredPreviewCondition, type StylePropEntry, type StylePropLeaf, type StylePropValue, type StylePropValueCtx, type StylePropValueKind, StyleProperty, type StylePropertyItem, type StyleRuleInput, type StyleValue, type SubEntityClass, type SubPatch, type SurfaceCompositeProp, type SurfaceProp, type SurfacePropKind, type SurfaceScalarProp, type SurfaceSlotProp, type SurfaceStylePropertyProp, type SurfaceVariantProp, System, type SystemConfig, SystemSection, SystemSource, Token, type TokenBinding, type TokenBody, type TokenMatch, Tool, type TraverseOptions, type TreeNode, UNREACHABLE, type UnadoptedDirective, type UnknownStyleLeaf, type UnlinkPlan, type UnlinkPlanInput, type UnreadableBorrow, type UnstatableCondition, type UpgradedDraft, type UserSchemas, VOID_ELEMENTS, type ValueOf, type ValueType, type VariantValueBody, type VariantValues, type VisibilityOperator, type VisibilityTerm, WEB_ACTIVATIONS, type WalkOptions, type WebActivation, addressOf, alpha, applyPathDelta, assetType, authoredBag, authoredValue, authoringSignatures, baseOf, blankComponentBody, borrowedGroup, borrowedItem, boundElementType, brandGroup, buildRefGraph, buildRefIndex, canonicalWhen, changeOf, changeValueAt, changesOf, childrenPolicy, className, classPrefixOf, classifyStylePropValue, collectRefs, componentClassBase, componentCompositeClasses, componentLayerClass, componentModuleFilePaths, componentModuleKey, componentModuleSource, componentMotionClasses, componentPropClasses, componentRegistryImports, componentRuleClasses, componentSpec, createCanvasConfig, createSliceMemo, cssPrefixes, cssPropValue, cssProperty, cssPropertyNames, cssValueIssue, cssVar, cssVarRef, danglingDirectives, danglingLocalRefs, danglingSourcedRefs, darken, declaredField, declaredPropRouting, declaredRuntimeModules, defineComponent, defineConfig, defineDerivedEntity, defineEntity, defineOverride, defineSubEntity, deriveCreateSchema, deriveSpec, deriveUpdateSchema, describeBody, describePatch, detectedWireVersion, editOp, entityRefOf, entryKeyOf, expandComponent, expandSpec, fieldKeys, fontFamilyStack, forceModeAttribute, forceModeAttributeOf, forceModeProp, forceModePropGroup, forceModePropValue, forceModeProps, forceStateAttribute, forwardClaims, forwardedLayers, forwardedNames, forwardsOf, globalStyleName, guidanceReaches, guidanceScopeOf, guidanceTextOf, iconCategories, iconLibraries, iconLibrary, iconMemberMetadata, iconMetadata, iconMetadataDeclaration, iconMetadataFile, iconMetadataFileJsonSchema, iconMetadataFormat, inferredRenames, inputOf, instanceSpec, intoName, isAuthored, isBinaryAsset, isConfigFormatError, isConfigRejection, isCssProperty, isDeclaredElementProp, isDerivedColor, isEntityPath, isExtendedRef, isForceModeProp, isGradient, isGroupBody, isLinkSlug, isMintedRow, isNativeConfig, isPlainObject, isRef, isSystemConfig, kebabComponent, kindOf, kindsOf, layerCompositeProps, layerRef, layerStyles, leafAddresses, leafVerb, leavesOfStylePropValue, lighten, linearGradient, matchEntities, matchTokens, memberFromLeaf, memberLeaves, memberOf, memberRef, memberVariantOptions, memoryConfigSource, misdeclaredOverlays, mix, modeAxes, modifierAxes, modifierAxis, modifierCategory, modifierGroupFields, modifierInvariants, modifierLeaf, modifierUtilitiesUsed, motionClassName, namedFields, namedSlotTargets, nativeTokenValue, negatedCssValue, normalizeName, opOf, opVerb, opacityPercentage, opsForKind, orRef, overlayVerb, overrideCondition, overrideKey, overrideKeyModifiers, overrideModifiers, ownValues, ownerOf, ownsItsValues, packageKey, packageName, partsOf, pathDelta, pathOf, pathSegments, planBreak, planCopy, planLink, planUnlink, previewConditionalProps, previewConditions, previewDefaults, previewMatrix, previewSpec, propOwner, propValueDomain, propValueFromAxis, redundantQualifiers, ref, refGraphOf, refLeaf, refSchema, registerSchemaMigrations, renderDerivedColor, renderGradient, renderSignature, renderStyleValue, renderedElement, renderedTarget, resolutionSchema, resolveComponentProps, resolveFieldValue, resolveIconLibrary, resolveInputDir, resolveOutDir, resolveRegistryDir, resolveTokenValue, resolveTokenValueUnder, resolveValueType, resolveVisibility, resolvedSource, rewriteRefNamespace, rewriteRefSource, rewriteRefs, rnStyleKey, rootLayerOf, routedBag, routedProp, routedPropIn, routesContent, ruleApplies, ruleCondition, runChangeHooks, schemaVersionOf, searchEntities, searchTokens, setAtPath, signatureOf, slotTargetsOf, sniffValueType, sourceEntries, sourceOf, sourceOfGroup, sourceOfItem, sourceRowStates, sourceSlugFor, sourceUnavailable, sourceUnreachable, sourceVarPrefix, specWithResolvedVisibility, splitRef, splitStyleProps, stamp, styleAliasesOf, styleDeclarations, stylePropClassBase, stylePropClassName, stylePropClasses, stylePropEntries, stylePropLeafForToken, stylePropNegates, stylePropTokenGroup, stylePropTokenPath, stylePropTokenValues, stylePropValueFormOf, stylePropValueFromLeaf, stylePropValueLeaves, stylePropValueSchema, stylePropValues, stylePropertiesWriting, stylePropertyAccepts, stylePropertyFor, stylePropertyPathFor, styleRuleMotionClasses, suggestLinkSlug, summarizeChanges, surfaceProp, surfaceProps, toCssPropertyName, tokenBinding, touchedFields, unadoptedDirectives, unknownStyleLeaves, unreadableBorrows, unstatableConditions, updateRefIndex, upgradeDraftEntries, upgradePatch, upgradeSerializedConfig, validateComponentProps, validateSpec, valueAt, valueLeavesOf, valueRef, valueSchemaOf, varPrefixOf, views, visibilityStateProps, visibilityTerms, withoutTruthyTerm };
91
+ import { PreviewElement, graftPreviewElements, isPreviewElement } from "./spec/preview-elements.js";
92
+ export { AI_LANES, AiChat, AiFlow, type AiFlowOrigin, AiGeneration, type AiLane, AiMessage, type AiMultiAgentMode, type AnatomyIssue, type AnatomyIssueKind, type AnatomyReport, type AnySystemConfig, type AsInput, type AttachedSources, type Authored, type AuthoredComponent, type AuthoredProp, type AuthoredPropBody, type AuthoringSignatureOptions, BUILD_DEFAULTS, type BreakOutcome, type BreakPlan, type BreakPlanInput, type BreakPlanRow, type BreakReach, BuildSection, CANVAS_ROLES, CONFIG_OPERATION_KIND, CSS_DEFAULTS, CSS_PROPERTY_NAMES, CSS_WIDE_KEYWORDS, CURRENT_SCHEMA_VERSION, Canvas, CanvasConfig, CanvasRole, type CanvasRoleName, CanvasSection, type Change, type ChangeHook, type ChangeTarget, type ChildrenPolicy, type Collection, type ColorValue, Component, type ComponentBody, type ComponentBuilder, type ComponentContractOf, type ComponentElementBody, type ComponentModuleSource, type ComponentPropBody, type ComponentPropsOf, type ComponentReference, type ComponentRegistryImport, type ComponentRegistryImportBinding, type ComponentRuleClass, type ComponentSpec, type ComponentSpecs, type ComponentStyleBody, Composite, type ComputedFields, type ComputedInput, type ComputedMap, Config, type ConfigClass, type ConfigEdit, ConfigFormatError, type ConfigInstance, type ConfigIssue, type ConfigIssueCode, type ConfigKind, type ConfigOp, ConfigRejection, ConfigSession, type ConfigSessionOptions, type ConfigSink, type ConfigSource, type CopyPlan, type CopyPlanInput, type CopyPlanRow, type CreateInput, type CssGrammar, type CssPrefix, type CssPropertyEntry, CssSection, DERIVED_MUTATIONS, type DanglingDirective, type DanglingLocalRef, type DanglingRef, type DeclaredRuntimeModule, type DeletePlan, type DeriveMembers, type DerivedColor, type DerivedEntityClass, type DerivedOp, Device, type DiffOptions, type DraftSource, ENTITY_PATH_MESSAGE, EXPORT_MEMBER, type Edition, type ElementVisibility, type ElementVisibilityInput, Entity, type EntityAddress, type EntityChange, type EntityClass, type EntityKind, type EntityMap, type ExpandOptions, type ExpansionResult, type ExtendedComponentRef, type ExtendedRef, type FieldsSchema, File, Font, FontFile, type ForwardClaims, GROUP, GUIDANCE_LANES, GlobalStyle, type Gradient, type GroupBody, Guidance, type GuidanceLane, type GuidanceScope, type GuidanceSegment, GuidanceStyle, type GuidanceStyleBody, type HasSnapshot, type HydrationOptions, ICON_METADATA_FORMATS, Icon, type IconLibrary, type IconMemberMetadata, type IconMetadataAdapter, type IconMetadataDeclaration, type IconMetadataFile, type IconMetadataFormat, type IdentifiedOp, type InferredRename, type ItemOf, type KindSignature, type KindSlice, LINK_SLUG, LINK_SLUG_MESSAGE, type LayerElement, type LayerMap, type LayerStyleOptions, type LeafAddress, type LinkArrival, type LinkDeclaration, type LinkPaths, type LinkPlan, type LinkPlanInput, LinkedSystem, type LinkedSystemResolver, type LinkedSystemState, type ListOptions, type LiveConfig, type LocalOverlay, MINTED, MODIFIER_CATEGORIES, type MisdeclaredOverlay, Modifier, type ModifierCategory, type ModifierGroupMeta, Motion, NATIVE_ACTIVATIONS, type NativeActivation, NativeModifier, NativeSettings, NativeStyleProperty, NativeToken, Node, type OpHandler, type OpInput, Operation, type OverlayVerb, type OverrideCondition, type OwnedRecords, PLAYGROUND_DEFAULTS, Package, Page, type Patch, type PathOf, type PinDirective, type PinOptions, type PinOptionsField, type Plan, type PlanImpact, type PlanOp, PlaygroundSection, type PreviewElement, type PreviewMatrix, type ProjectedVisibility, type PropDecl, type PropDeclaration, type PropMap, RN_STYLE_KEYS, ReactNativeSystem, type ReactNativeSystemConfig, type RebaseConflict, type RebaseOrigin, type RebaseResult, type RecordedSource, type RedundantQualifier, type Ref, type RefGraph, type RefGraphEntry, type RefIndex, type RefIndexChange, type RefMember, type RefTarget, type RegisteredComponentContracts, type RegisteredEntities, type RegisteredModifiers, type RegisteredPaths, type RegisteredStyleProps, type RenamePlan, type RenderArgs, type RenderElement, type RenderSpec, type RenderedNode, type RenderedTarget, type ResolveValueTypeInput, type ResolvedSource, SCRIPT_EXTENSIONS, SERIALIZED_CONFIG_VERSION, SIZE_TOLERANCE_PX, STYLE_PROPERTIES, STYLE_PROP_VALUE_FORMS, STYLE_PROP_VALUE_LEAVES, type SchemaEntry, type SchemaMigration, SchemaVersionTooNew, type SerializedConfig, type SerializedSourceAnswer, Settings, type SignatureOptions, type SkippedOp, type SlotTarget, Snapshot, type Source, type SourceAnswer, type SourceChange, type SourceMap, type SourceResolution, type SourceResolutionSchemas, type SourceResolver, type SourceRowState, type SourceState, type SourceUnavailable, type SourcesBySlug, type SourcesOf, type SpecNode, type SplitStyleProps, type StampedPatch, type StoredConfig, type StoredPreviewCondition, type StylePropEntry, type StylePropLeaf, type StylePropValue, type StylePropValueCtx, type StylePropValueKind, StyleProperty, type StylePropertyItem, type StyleRuleInput, type StyleValue, type SubEntityClass, type SubPatch, type SurfaceCompositeProp, type SurfaceProp, type SurfacePropKind, type SurfaceScalarProp, type SurfaceSlotProp, type SurfaceStylePropertyProp, type SurfaceVariantProp, System, type SystemConfig, SystemSection, SystemSource, Token, type TokenBinding, type TokenBody, type TokenMatch, Tool, type TraverseOptions, type TreeNode, UNREACHABLE, type UnadoptedDirective, type UnknownStyleLeaf, type UnlinkPlan, type UnlinkPlanInput, type UnreadableBorrow, type UnstatableCondition, type UpgradedDraft, type UserSchemas, VOID_ELEMENTS, type ValueOf, type ValueType, type VariantValueBody, type VariantValues, type VisibilityOperator, type VisibilityTerm, WEB_ACTIVATIONS, type WalkOptions, type WebActivation, addressOf, alpha, anatomyIssueKey, applyPathDelta, assetType, authoredBag, authoredValue, authoringSignatures, baseOf, blankComponentBody, borrowedGroup, borrowedItem, boundElementType, brandGroup, buildRefGraph, buildRefIndex, canonicalWhen, changeOf, changeValueAt, changesOf, childrenPolicy, className, classPrefixOf, classifyStylePropValue, collectRefs, componentClassBase, componentCompositeClasses, componentLayerClass, componentModuleFilePaths, componentModuleKey, componentModuleSource, componentMotionClasses, componentPropClasses, componentRegistryImports, componentRuleClasses, componentSpec, createCanvasConfig, createSliceMemo, cssPrefixes, cssPropValue, cssProperty, cssPropertyNames, cssValueIssue, cssVar, cssVarRef, danglingDirectives, danglingLocalRefs, danglingSourcedRefs, darken, declaredField, declaredPropRouting, declaredRuntimeModules, defineComponent, defineConfig, defineDerivedEntity, defineEntity, defineOverride, defineSubEntity, deriveCreateSchema, deriveSpec, deriveUpdateSchema, describeBody, describePatch, detectedWireVersion, diffRendered, editOp, entityRefOf, entryKeyOf, expandComponent, expandSpec, fieldKeys, fontFamilyStack, forceModeAttribute, forceModeAttributeOf, forceModeProp, forceModePropGroup, forceModePropValue, forceModeProps, forceStateAttribute, forwardClaims, forwardedLayers, forwardedNames, forwardsOf, globalStyleName, graftPreviewElements, guidanceReaches, guidanceScopeOf, guidanceTextOf, iconCategories, iconLibraries, iconLibrary, iconMemberMetadata, iconMetadata, iconMetadataDeclaration, iconMetadataFile, iconMetadataFileJsonSchema, iconMetadataFormat, inferredRenames, inputOf, instanceSpec, intoName, isAuthored, isBinaryAsset, isConfigFormatError, isConfigRejection, isCssProperty, isDeclaredElementProp, isDerivedColor, isEntityPath, isExtendedRef, isForceModeProp, isGradient, isGroupBody, isLinkSlug, isMintedRow, isNativeConfig, isPlainObject, isPreviewElement, isRef, isSystemConfig, kebabComponent, kindOf, kindsOf, layerCompositeProps, layerRef, layerStyles, leafAddresses, leafVerb, leavesOfStylePropValue, lighten, linearGradient, matchEntities, matchTokens, memberFromLeaf, memberLeaves, memberOf, memberRef, memberVariantOptions, memoryConfigSource, misdeclaredOverlays, mix, modeAxes, modifierAxes, modifierAxis, modifierCategory, modifierGroupFields, modifierInvariants, modifierLeaf, modifierUtilitiesUsed, motionClassName, namedFields, namedSlotTargets, nativeTokenValue, negatedCssValue, normalizeName, normalizeStyleValue, opOf, opVerb, opacityPercentage, opsForKind, orRef, overlayVerb, overrideCondition, overrideKey, overrideKeyModifiers, overrideModifiers, ownValues, ownerOf, ownsItsValues, packageKey, packageName, partsOf, pathDelta, pathOf, pathSegments, planBreak, planCopy, planLink, planUnlink, previewConditionalProps, previewConditions, previewDefaults, previewMatrix, previewSpec, propOwner, propValueDomain, propValueFromAxis, redundantQualifiers, ref, refGraphOf, refLeaf, refSchema, registerSchemaMigrations, renderDerivedColor, renderGradient, renderSignature, renderStyleValue, renderedElement, renderedSignatureOf, renderedTarget, resolutionSchema, resolveComponentProps, resolveFieldValue, resolveIconLibrary, resolveInputDir, resolveOutDir, resolveRegistryDir, resolveTokenValue, resolveTokenValueUnder, resolveValueType, resolveVisibility, resolvedSource, rewriteRefNamespace, rewriteRefSource, rewriteRefs, rnStyleKey, rootLayerOf, routedBag, routedProp, routedPropIn, routesContent, ruleApplies, ruleCondition, runChangeHooks, schemaVersionOf, searchEntities, searchTokens, setAtPath, signatureOf, slotTargetsOf, snapshotHtml, sniffValueType, sourceEntries, sourceOf, sourceOfGroup, sourceOfItem, sourceRowStates, sourceSlugFor, sourceUnavailable, sourceUnreachable, sourceVarPrefix, specWithResolvedVisibility, splitRef, splitStyleProps, stamp, styleAliasesOf, styleDeclarations, stylePropClassBase, stylePropClassName, stylePropClasses, stylePropEntries, stylePropLeafForToken, stylePropNegates, stylePropTokenGroup, stylePropTokenPath, stylePropTokenValues, stylePropValueFormOf, stylePropValueFromLeaf, stylePropValueLeaves, stylePropValueSchema, stylePropValues, stylePropertiesWriting, stylePropertyAccepts, stylePropertyFor, stylePropertyPathFor, styleRuleMotionClasses, suggestLinkSlug, summarizeChanges, surfaceProp, surfaceProps, toCssPropertyName, tokenBinding, touchedFields, unadoptedDirectives, unknownStyleLeaves, unreadableBorrows, unstatableConditions, updateRefIndex, upgradeDraftEntries, upgradePatch, upgradeSerializedConfig, validateComponentProps, validateSpec, valueAt, valueLeavesOf, valueRef, valueSchemaOf, varPrefixOf, views, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
package/dist/index.js CHANGED
@@ -23,9 +23,10 @@ import { STYLE_PROP_VALUE_FORMS, STYLE_PROP_VALUE_LEAVES, StyleProperty, classif
23
23
  import { createSliceMemo } from "./framework/memo.js";
24
24
  import { authoredBag, authoredValue, className, cssPropValue, cssVar, cssVarRef, declaredPropRouting, memberFromLeaf, memberLeaves, negatedCssValue, opacityPercentage, previewConditionalProps, previewConditions, previewDefaults, previewMatrix, propOwner, propValueDomain, propValueFromAxis, renderStyleValue, resolveComponentProps, resolveFieldValue, resolveTokenValue, resolveTokenValueUnder, routedBag, sourceVarPrefix, styleAliasesOf, styleDeclarations, stylePropEntries, stylePropLeafForToken, stylePropNegates, stylePropTokenGroup, stylePropTokenPath, stylePropTokenValues, stylePropValueFromLeaf, stylePropValueLeaves, stylePropValues, stylePropertiesWriting, stylePropertyAccepts, stylePropertyFor, stylePropertyPathFor, validateComponentProps } from "./framework/projections.js";
25
25
  import { forwardClaims, forwardedLayers, intoName, routedProp, routedPropIn, routesContent, surfaceProp, surfaceProps } from "./framework/prop-surface.js";
26
+ import { graftPreviewElements, isPreviewElement } from "./spec/preview-elements.js";
26
27
  import { layerStyles, ruleApplies } from "./framework/layer-styles.js";
27
28
  import { componentClassBase, componentCompositeClasses, componentLayerClass, componentMotionClasses, componentPropClasses, componentRuleClasses, forceModeAttribute, forceModeAttributeOf, forceModeProp, forceModePropGroup, forceModePropValue, forceModeProps, forceStateAttribute, isForceModeProp, kebabComponent, layerCompositeProps, modifierUtilitiesUsed, motionClassName, ruleCondition, splitStyleProps, stylePropClassBase, stylePropClassName, stylePropClasses, styleRuleMotionClasses } from "./framework/class-names.js";
28
- import { boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, previewSpec, resolveVisibility, slotTargetsOf, specWithResolvedVisibility, visibilityStateProps, visibilityTerms, withoutTruthyTerm } from "./framework/render-spec.js";
29
+ import { boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, previewSpec, resolveVisibility, slotTargetsOf, specWithResolvedVisibility, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey } from "./framework/render-spec.js";
29
30
  import { Package } from "./entities/system/Package.js";
30
31
  import { File, SCRIPT_EXTENSIONS, isBinaryAsset } from "./entities/system/File.js";
31
32
  import { Component, blankComponentBody, canonicalWhen, forwardedNames, layerRef, ownValues, ownsItsValues, valueRef } from "./entities/system/Component.js";
@@ -74,6 +75,7 @@ import { assetType, iconCategories, iconLibraries, iconLibrary, isDeclaredElemen
74
75
  import { declaredRuntimeModules } from "./entities/system/runtime-modules.js";
75
76
  import { matchEntities, normalizeName, searchEntities } from "./framework/entity-search.js";
76
77
  import { matchTokens, searchTokens, tokenBinding } from "./entities/system/token-index.js";
78
+ import { SIZE_TOLERANCE_PX, STYLE_PROPERTIES, anatomyIssueKey, diffRendered, normalizeStyleValue, renderedSignatureOf, snapshotHtml } from "./framework/anatomy-check.js";
77
79
  import { runChangeHooks } from "./framework/change-hooks.js";
78
80
  import { baseOf, changeOf, changeValueAt, changesOf, describeBody, summarizeChanges } from "./framework/changes.js";
79
81
  import { DERIVED_MUTATIONS } from "./framework/derived-mutations.js";
@@ -83,4 +85,4 @@ import { ConfigSession, memoryConfigSource } from "./framework/session.js";
83
85
  import { EXPORT_MEMBER, packageKey, packageName } from "./framework/utils/package-path.js";
84
86
  import { validateSpec } from "./framework/validate-spec.js";
85
87
  import { namedSlotTargets } from "./spec/empty-node-slots.js";
86
- export { AI_LANES, AiChat, AiFlow, AiGeneration, AiMessage, BUILD_DEFAULTS, BuildSection, CANVAS_ROLES, CONFIG_OPERATION_KIND, CSS_DEFAULTS, CSS_PROPERTY_NAMES, CSS_WIDE_KEYWORDS, CURRENT_SCHEMA_VERSION, Canvas, CanvasConfig, CanvasRole, CanvasSection, Component, Composite, Config, ConfigFormatError, ConfigRejection, ConfigSession, CssSection, DERIVED_MUTATIONS, Device, ENTITY_PATH_MESSAGE, EXPORT_MEMBER, Entity, File, Font, FontFile, GROUP, GUIDANCE_LANES, GlobalStyle, Guidance, GuidanceStyle, ICON_METADATA_FORMATS, Icon, LINK_SLUG, LINK_SLUG_MESSAGE, LinkedSystem, MINTED, MODIFIER_CATEGORIES, Modifier, Motion, NATIVE_ACTIVATIONS, NativeModifier, NativeSettings, NativeStyleProperty, NativeToken, Node, Operation, PLAYGROUND_DEFAULTS, Package, Page, PlaygroundSection, RN_STYLE_KEYS, ReactNativeSystem, SCRIPT_EXTENSIONS, SERIALIZED_CONFIG_VERSION, STYLE_PROP_VALUE_FORMS, STYLE_PROP_VALUE_LEAVES, SchemaVersionTooNew, Settings, Snapshot, StyleProperty, System, SystemSection, SystemSource, Token, Tool, UNREACHABLE, VOID_ELEMENTS, WEB_ACTIVATIONS, addressOf, alpha, applyPathDelta, assetType, authoredBag, authoredValue, authoringSignatures, baseOf, blankComponentBody, borrowedGroup, borrowedItem, boundElementType, brandGroup, buildRefGraph, buildRefIndex, canonicalWhen, changeOf, changeValueAt, changesOf, childrenPolicy, className, classPrefixOf, classifyStylePropValue, collectRefs, componentClassBase, componentCompositeClasses, componentLayerClass, componentModuleFilePaths, componentModuleKey, componentModuleSource, componentMotionClasses, componentPropClasses, componentRegistryImports, componentRuleClasses, componentSpec, createCanvasConfig, createSliceMemo, cssPrefixes, cssPropValue, cssProperty, cssPropertyNames, cssValueIssue, cssVar, cssVarRef, danglingDirectives, danglingLocalRefs, danglingSourcedRefs, darken, declaredField, declaredPropRouting, declaredRuntimeModules, defineComponent, defineConfig, defineDerivedEntity, defineEntity, defineOverride, defineSubEntity, deriveCreateSchema, deriveSpec, deriveUpdateSchema, describeBody, describePatch, detectedWireVersion, editOp, entityRefOf, entryKeyOf, expandComponent, expandSpec, fieldKeys, fontFamilyStack, forceModeAttribute, forceModeAttributeOf, forceModeProp, forceModePropGroup, forceModePropValue, forceModeProps, forceStateAttribute, forwardClaims, forwardedLayers, forwardedNames, forwardsOf, globalStyleName, guidanceReaches, guidanceScopeOf, guidanceTextOf, iconCategories, iconLibraries, iconLibrary, iconMemberMetadata, iconMetadata, iconMetadataDeclaration, iconMetadataFile, iconMetadataFileJsonSchema, iconMetadataFormat, inferredRenames, inputOf, instanceSpec, intoName, isAuthored, isBinaryAsset, isConfigFormatError, isConfigRejection, isCssProperty, isDeclaredElementProp, isDerivedColor, isEntityPath, isExtendedRef, isForceModeProp, isGradient, isGroupBody, isLinkSlug, isMintedRow, isNativeConfig, isPlainObject, isRef, isSystemConfig, kebabComponent, kindOf, kindsOf, layerCompositeProps, layerRef, layerStyles, leafAddresses, leafVerb, leavesOfStylePropValue, lighten, linearGradient, matchEntities, matchTokens, memberFromLeaf, memberLeaves, memberOf, memberRef, memberVariantOptions, memoryConfigSource, misdeclaredOverlays, mix, modeAxes, modifierAxes, modifierAxis, modifierCategory, modifierGroupFields, modifierInvariants, modifierLeaf, modifierUtilitiesUsed, motionClassName, namedFields, namedSlotTargets, nativeTokenValue, negatedCssValue, normalizeName, opOf, opVerb, opacityPercentage, opsForKind, orRef, overlayVerb, overrideCondition, overrideKey, overrideKeyModifiers, overrideModifiers, ownValues, ownerOf, ownsItsValues, packageKey, packageName, partsOf, pathDelta, pathOf, pathSegments, planBreak, planCopy, planLink, planUnlink, previewConditionalProps, previewConditions, previewDefaults, previewMatrix, previewSpec, propOwner, propValueDomain, propValueFromAxis, redundantQualifiers, ref, refGraphOf, refLeaf, refSchema, registerSchemaMigrations, renderDerivedColor, renderGradient, renderSignature, renderStyleValue, renderedElement, renderedTarget, resolutionSchema, resolveComponentProps, resolveFieldValue, resolveIconLibrary, resolveInputDir, resolveOutDir, resolveRegistryDir, resolveTokenValue, resolveTokenValueUnder, resolveValueType, resolveVisibility, resolvedSource, rewriteRefNamespace, rewriteRefSource, rewriteRefs, rnStyleKey, rootLayerOf, routedBag, routedProp, routedPropIn, routesContent, ruleApplies, ruleCondition, runChangeHooks, schemaVersionOf, searchEntities, searchTokens, setAtPath, signatureOf, slotTargetsOf, sniffValueType, sourceEntries, sourceOf, sourceOfGroup, sourceOfItem, sourceRowStates, sourceSlugFor, sourceUnavailable, sourceUnreachable, sourceVarPrefix, specWithResolvedVisibility, splitRef, splitStyleProps, stamp, styleAliasesOf, styleDeclarations, stylePropClassBase, stylePropClassName, stylePropClasses, stylePropEntries, stylePropLeafForToken, stylePropNegates, stylePropTokenGroup, stylePropTokenPath, stylePropTokenValues, stylePropValueFormOf, stylePropValueFromLeaf, stylePropValueLeaves, stylePropValueSchema, stylePropValues, stylePropertiesWriting, stylePropertyAccepts, stylePropertyFor, stylePropertyPathFor, styleRuleMotionClasses, suggestLinkSlug, summarizeChanges, surfaceProp, surfaceProps, toCssPropertyName, tokenBinding, touchedFields, unadoptedDirectives, unknownStyleLeaves, unreadableBorrows, unstatableConditions, updateRefIndex, upgradeDraftEntries, upgradePatch, upgradeSerializedConfig, validateComponentProps, validateSpec, valueAt, valueLeavesOf, valueRef, valueSchemaOf, varPrefixOf, views, visibilityStateProps, visibilityTerms, withoutTruthyTerm };
88
+ export { AI_LANES, AiChat, AiFlow, AiGeneration, AiMessage, BUILD_DEFAULTS, BuildSection, CANVAS_ROLES, CONFIG_OPERATION_KIND, CSS_DEFAULTS, CSS_PROPERTY_NAMES, CSS_WIDE_KEYWORDS, CURRENT_SCHEMA_VERSION, Canvas, CanvasConfig, CanvasRole, CanvasSection, Component, Composite, Config, ConfigFormatError, ConfigRejection, ConfigSession, CssSection, DERIVED_MUTATIONS, Device, ENTITY_PATH_MESSAGE, EXPORT_MEMBER, Entity, File, Font, FontFile, GROUP, GUIDANCE_LANES, GlobalStyle, Guidance, GuidanceStyle, ICON_METADATA_FORMATS, Icon, LINK_SLUG, LINK_SLUG_MESSAGE, LinkedSystem, MINTED, MODIFIER_CATEGORIES, Modifier, Motion, NATIVE_ACTIVATIONS, NativeModifier, NativeSettings, NativeStyleProperty, NativeToken, Node, Operation, PLAYGROUND_DEFAULTS, Package, Page, PlaygroundSection, RN_STYLE_KEYS, ReactNativeSystem, SCRIPT_EXTENSIONS, SERIALIZED_CONFIG_VERSION, SIZE_TOLERANCE_PX, STYLE_PROPERTIES, STYLE_PROP_VALUE_FORMS, STYLE_PROP_VALUE_LEAVES, SchemaVersionTooNew, Settings, Snapshot, StyleProperty, System, SystemSection, SystemSource, Token, Tool, UNREACHABLE, VOID_ELEMENTS, WEB_ACTIVATIONS, addressOf, alpha, anatomyIssueKey, applyPathDelta, assetType, authoredBag, authoredValue, authoringSignatures, baseOf, blankComponentBody, borrowedGroup, borrowedItem, boundElementType, brandGroup, buildRefGraph, buildRefIndex, canonicalWhen, changeOf, changeValueAt, changesOf, childrenPolicy, className, classPrefixOf, classifyStylePropValue, collectRefs, componentClassBase, componentCompositeClasses, componentLayerClass, componentModuleFilePaths, componentModuleKey, componentModuleSource, componentMotionClasses, componentPropClasses, componentRegistryImports, componentRuleClasses, componentSpec, createCanvasConfig, createSliceMemo, cssPrefixes, cssPropValue, cssProperty, cssPropertyNames, cssValueIssue, cssVar, cssVarRef, danglingDirectives, danglingLocalRefs, danglingSourcedRefs, darken, declaredField, declaredPropRouting, declaredRuntimeModules, defineComponent, defineConfig, defineDerivedEntity, defineEntity, defineOverride, defineSubEntity, deriveCreateSchema, deriveSpec, deriveUpdateSchema, describeBody, describePatch, detectedWireVersion, diffRendered, editOp, entityRefOf, entryKeyOf, expandComponent, expandSpec, fieldKeys, fontFamilyStack, forceModeAttribute, forceModeAttributeOf, forceModeProp, forceModePropGroup, forceModePropValue, forceModeProps, forceStateAttribute, forwardClaims, forwardedLayers, forwardedNames, forwardsOf, globalStyleName, graftPreviewElements, guidanceReaches, guidanceScopeOf, guidanceTextOf, iconCategories, iconLibraries, iconLibrary, iconMemberMetadata, iconMetadata, iconMetadataDeclaration, iconMetadataFile, iconMetadataFileJsonSchema, iconMetadataFormat, inferredRenames, inputOf, instanceSpec, intoName, isAuthored, isBinaryAsset, isConfigFormatError, isConfigRejection, isCssProperty, isDeclaredElementProp, isDerivedColor, isEntityPath, isExtendedRef, isForceModeProp, isGradient, isGroupBody, isLinkSlug, isMintedRow, isNativeConfig, isPlainObject, isPreviewElement, isRef, isSystemConfig, kebabComponent, kindOf, kindsOf, layerCompositeProps, layerRef, layerStyles, leafAddresses, leafVerb, leavesOfStylePropValue, lighten, linearGradient, matchEntities, matchTokens, memberFromLeaf, memberLeaves, memberOf, memberRef, memberVariantOptions, memoryConfigSource, misdeclaredOverlays, mix, modeAxes, modifierAxes, modifierAxis, modifierCategory, modifierGroupFields, modifierInvariants, modifierLeaf, modifierUtilitiesUsed, motionClassName, namedFields, namedSlotTargets, nativeTokenValue, negatedCssValue, normalizeName, normalizeStyleValue, opOf, opVerb, opacityPercentage, opsForKind, orRef, overlayVerb, overrideCondition, overrideKey, overrideKeyModifiers, overrideModifiers, ownValues, ownerOf, ownsItsValues, packageKey, packageName, partsOf, pathDelta, pathOf, pathSegments, planBreak, planCopy, planLink, planUnlink, previewConditionalProps, previewConditions, previewDefaults, previewMatrix, previewSpec, propOwner, propValueDomain, propValueFromAxis, redundantQualifiers, ref, refGraphOf, refLeaf, refSchema, registerSchemaMigrations, renderDerivedColor, renderGradient, renderSignature, renderStyleValue, renderedElement, renderedSignatureOf, renderedTarget, resolutionSchema, resolveComponentProps, resolveFieldValue, resolveIconLibrary, resolveInputDir, resolveOutDir, resolveRegistryDir, resolveTokenValue, resolveTokenValueUnder, resolveValueType, resolveVisibility, resolvedSource, rewriteRefNamespace, rewriteRefSource, rewriteRefs, rnStyleKey, rootLayerOf, routedBag, routedProp, routedPropIn, routesContent, ruleApplies, ruleCondition, runChangeHooks, schemaVersionOf, searchEntities, searchTokens, setAtPath, signatureOf, slotTargetsOf, snapshotHtml, sniffValueType, sourceEntries, sourceOf, sourceOfGroup, sourceOfItem, sourceRowStates, sourceSlugFor, sourceUnavailable, sourceUnreachable, sourceVarPrefix, specWithResolvedVisibility, splitRef, splitStyleProps, stamp, styleAliasesOf, styleDeclarations, stylePropClassBase, stylePropClassName, stylePropClasses, stylePropEntries, stylePropLeafForToken, stylePropNegates, stylePropTokenGroup, stylePropTokenPath, stylePropTokenValues, stylePropValueFormOf, stylePropValueFromLeaf, stylePropValueLeaves, stylePropValueSchema, stylePropValues, stylePropertiesWriting, stylePropertyAccepts, stylePropertyFor, stylePropertyPathFor, styleRuleMotionClasses, suggestLinkSlug, summarizeChanges, surfaceProp, surfaceProps, toCssPropertyName, tokenBinding, touchedFields, unadoptedDirectives, unknownStyleLeaves, unreadableBorrows, unstatableConditions, updateRefIndex, upgradeDraftEntries, upgradePatch, upgradeSerializedConfig, validateComponentProps, validateSpec, valueAt, valueLeavesOf, valueRef, valueSchemaOf, varPrefixOf, views, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
@@ -1147,6 +1147,7 @@ declare function loadV1Artifact(studio: V1Artifact, options?: LoadV1Options): Co
1147
1147
  target: _$zod.ZodType<Ref, unknown, _$zod_v4_core0.$ZodTypeInternals<Ref, unknown>>;
1148
1148
  names: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
1149
1149
  }, _$zod_v4_core0.$strip>>>;
1150
+ exports: _$zod.ZodOptional<SubEntityClass<_$zod.ZodObject<{}, _$zod_v4_core0.$strict>>>;
1150
1151
  }, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "file", Record<never, never>, {
1151
1152
  readonly binary: ({
1152
1153
  path
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The wire shapes the anatomy reader and the anatomy check taught the config, all additive:
3
+ *
4
+ * - An anatomy node's prop-chosen element (`{ "$state": "/<prop>" }`) gains optional `map` (prop
5
+ * value → the element mounted for it), `else` (the element when nothing matches) and `layer` (the
6
+ * layer the chosen element stands in for), so a render that mounts a different component per
7
+ * value of one prop has one root node whose element the prop picks.
8
+ * - An anatomy node gains an optional `wrapper`: a ref to a package factory the element renders
9
+ * through, `{ "__ref": "package:motion/react#motion" }` for a layer written as
10
+ * `motion.create(Box)`, so the node carries the motion props and paints like the module.
11
+ * - A `File` gains an optional `exports` member collection, so an anatomy can name a same-file
12
+ * function component (`file:src/uds/components/pagination.tsx#PaginationProvider`) and the
13
+ * registry can import it from the module the file emits to. A node's props may also hold a list
14
+ * of literals, a motion keyframe track.
15
+ *
16
+ * Nothing stored before this version reshapes. A body without a field means what its absence
17
+ * always meant: a domain lookup, a direct element, a file with no members.
18
+ *
19
+ * Deletable once no stored artifact predates it.
20
+ */
21
+ import type { SchemaMigration } from '../framework/schema-version';
22
+ export declare const ANATOMY_HARNESS_VERSION = 20260914181845;
23
+ export declare const anatomyHarnessMigration: SchemaMigration;
@@ -0,0 +1,10 @@
1
+ //#region src/migrations/20260914181845_anatomy_harness.ts
2
+ const ANATOMY_HARNESS_VERSION = 20260914181845;
3
+ const anatomyHarnessMigration = {
4
+ version: ANATOMY_HARNESS_VERSION,
5
+ up(json) {
6
+ return json;
7
+ }
8
+ };
9
+ //#endregion
10
+ export { ANATOMY_HARNESS_VERSION, anatomyHarnessMigration };
@@ -20,13 +20,12 @@ function assetRegistryEntries({ libraries, components }) {
20
20
  for (const name of group.assetNames) {
21
21
  const member = members[name];
22
22
  if (member === void 0) continue;
23
- const Renderable = makeAssetRenderable(SystemComponent, member, name);
24
23
  const key = group.assetType(name);
25
24
  entries[key] = makeComponentEntry({
26
- component: Renderable,
25
+ component: makeAssetRenderable(void 0, member, name),
27
26
  name: key
28
27
  });
29
- bySlug.set(name, Renderable);
28
+ bySlug.set(name, makeAssetRenderable(SystemComponent, member, name));
30
29
  }
31
30
  assetMembers.set(group.name, bySlug);
32
31
  }
@@ -85,7 +85,7 @@ function specContent({ children, propChildren }) {
85
85
  propChildren,
86
86
  ...childArray.slice(slotAt)
87
87
  ];
88
- return children;
88
+ return propChildren != null ? [propChildren, ...childArray] : children;
89
89
  }
90
90
  if (propChildren != null && childArray.length > 0) return [propChildren, ...childArray];
91
91
  if (childArray.length > 0) return children;
@@ -1,3 +1,4 @@
1
+ import { kindOf } from "../../framework/utils/refs.js";
1
2
  import React from "react";
2
3
  //#region src/renderer/wrappers/inline-styles.tsx
3
4
  const HEX_RE = /^#[0-9a-fA-F]{3,8}$/;
@@ -68,6 +69,7 @@ function wrapInlineStyleProps(reg, config = {}) {
68
69
  const elementType = renderProps.element.type;
69
70
  const rawStyle = props?.style;
70
71
  if (!props || rawStyle == null) return React.createElement(Comp, renderProps);
72
+ if (props["data-uds-layer"] !== void 0) return React.createElement(Comp, renderProps);
71
73
  let style;
72
74
  if (typeof rawStyle === "string") style = parseCssDeclarationString(rawStyle);
73
75
  else if (typeof rawStyle === "object" && !Array.isArray(rawStyle)) style = rawStyle;
@@ -98,8 +100,26 @@ function wrapInlineStyleProps(reg, config = {}) {
98
100
  }
99
101
  });
100
102
  };
101
- for (const [name, Comp] of Object.entries(reg)) wrapped[name] = makeInlineStylePropsWrapper(Comp);
103
+ for (const [name, Comp] of Object.entries(reg)) {
104
+ if (takesNoStyleProps(name)) {
105
+ wrapped[name] = Comp;
106
+ continue;
107
+ }
108
+ wrapped[name] = makeInlineStylePropsWrapper(Comp);
109
+ }
102
110
  return wrapped;
103
111
  }
112
+ /** Whether a registry key names something that cannot resolve a style prop — see the loop above. */
113
+ function takesNoStyleProps(registryKey) {
114
+ if (!registryKey.includes(":")) return false;
115
+ const open = registryKey.indexOf("(");
116
+ const kind = kindOf(open !== -1 && registryKey.endsWith(")") ? registryKey.slice(0, open) : registryKey);
117
+ if (kind !== "package" && kind !== "file") return false;
118
+ if (open !== -1 && registryKey.endsWith(")")) {
119
+ const target = registryKey.slice(open + 1, -1);
120
+ return !(target.includes(":") && kindOf(target) === "component");
121
+ }
122
+ return true;
123
+ }
104
124
  //#endregion
105
125
  export { wrapInlineStyleProps };
@@ -1,10 +1,10 @@
1
1
  import { AcceptsChildNodes, ChildNodesClassification, ClassifyChildNodes, buildAcceptsChildNodes, buildClassifyChildNodes, namedSlotTargets, stripInjectedSlots, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots } from "./empty-node-slots.js";
2
+ import { GraftableElement, GraftableSpec, PreviewElement, PreviewSpecNode, PreviewValue, graftPreviewElements, hasPreviewElementDeep, isPreviewElement, previewElementNodes, previewElementType } from "./preview-elements.js";
2
3
  import { DocumentRename, RewritableSpec, SpecRewrite, rewriteSpecRefs } from "./rewrite-refs.js";
3
4
  import { applyForcedModifiers, collectForcedModifierProps } from "./apply-forced-modifiers.js";
4
5
  import { AssetComponentMap, AssetJsxForm, AssetNodeResolver, assetJsxForm, jsxIdentifier, parseAssetType } from "./asset-jsx.js";
5
6
  import { CollapseTextLabelsResult, CollapsedTextLabel, collapseWrappedTextLabels } from "./collapse-text-labels.js";
6
7
  import { JsxToSpecOptions, UNRESOLVED, hasUnresolvedProps, jsxToSpec, stripUnresolvedProps } from "./jsxToSpec.js";
7
- import { GraftableElement, GraftableSpec, PreviewElement, PreviewSpecNode, PreviewValue, graftPreviewElements, hasPreviewElementDeep, isPreviewElement, previewElementNodes, previewElementType } from "./preview-elements.js";
8
8
  import { SpecToJsxOptions, SpecToJsxResult, specToJsx } from "./specToJsx.js";
9
9
 
10
10
  //#region src/spec/index.d.ts
@@ -4,9 +4,26 @@ import { serializeProps } from "@json-render/codegen";
4
4
  function statePathToExpression(path) {
5
5
  return `state${path.split("/").filter(Boolean).map((s) => `.${s}`).join("")}`;
6
6
  }
7
- function isDynamicValue(value) {
7
+ function isStateValue(value) {
8
8
  return typeof value === "object" && value !== null && "$state" in value && typeof value.$state === "string";
9
9
  }
10
+ /** `{ $cond, $then, $else }` — a value the anatomy chooses by a condition on state. */
11
+ function isConditionalValue(value) {
12
+ return typeof value === "object" && value !== null && "$cond" in value && "$then" in value && "$else" in value && isStateValue(value.$cond);
13
+ }
14
+ /** A `$state` binding or a `$cond` choice — anything written as an expression rather than a literal. */
15
+ function isDynamicValue(value) {
16
+ return isStateValue(value) || isConditionalValue(value);
17
+ }
18
+ /** The test of a `$cond`, as the expression the render would have written. */
19
+ function conditionExpression(condition) {
20
+ const subject = statePathToExpression(condition.$state);
21
+ let test;
22
+ if (condition.eq !== void 0) test = `${subject} === ${JSON.stringify(condition.eq)}`;
23
+ else if (condition.neq !== void 0) test = `${subject} !== ${JSON.stringify(condition.neq)}`;
24
+ else test = subject;
25
+ return condition.not ? `!(${test})` : test;
26
+ }
10
27
  /** All element keys an element's `slots` record pulls in. */
11
28
  function collectSlotKeys(slots) {
12
29
  const keys = /* @__PURE__ */ new Set();
@@ -14,9 +31,16 @@ function collectSlotKeys(slots) {
14
31
  return keys;
15
32
  }
16
33
  function resolveDynamicValue(value) {
17
- if (isDynamicValue(value)) return statePathToExpression(value.$state);
34
+ if (isConditionalValue(value)) return `${conditionExpression(value.$cond)} ? ${armExpression(value.$then)} : ${armExpression(value.$else)}`;
35
+ if (isStateValue(value)) return statePathToExpression(value.$state);
18
36
  return String(value);
19
37
  }
38
+ /** One arm of a written-back choice: a nested choice in parentheses, a binding, or a literal. */
39
+ function armExpression(value) {
40
+ if (isConditionalValue(value)) return `(${resolveDynamicValue(value)})`;
41
+ if (isStateValue(value)) return statePathToExpression(value.$state);
42
+ return JSON.stringify(value);
43
+ }
20
44
  function renderActionBinding(binding) {
21
45
  if (Array.isArray(binding)) return `{() => { ${binding.map((b) => b.action).map((a) => `${a}()`).join("; ")} }}`;
22
46
  return `{${binding.action}}`;