@almadar/core 10.28.0 → 10.29.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.
package/dist/index.js CHANGED
@@ -437,7 +437,7 @@ function isBinding(value) {
437
437
  function isSExprCall(value) {
438
438
  return isSExpr(value);
439
439
  }
440
- var CORE_BINDINGS = ["entity", "payload", "state", "now", "config", "computed", "trait", "user"];
440
+ var CORE_BINDINGS = ["entity", "payload", "state", "now", "config", "computed", "trait", "user", "callsitePayload"];
441
441
  function parseBinding(binding) {
442
442
  if (!binding.startsWith("@")) {
443
443
  return null;
@@ -521,7 +521,8 @@ var StateSchema = z.object({
521
521
  var PayloadFieldSchema = z.object({
522
522
  name: z.string().min(1),
523
523
  type: z.string().min(1),
524
- required: z.boolean().optional()
524
+ required: z.boolean().optional(),
525
+ properties: z.lazy(() => z.array(PayloadFieldSchema)).optional()
525
526
  });
526
527
  var EventSchema = z.object({
527
528
  key: z.string().min(1, "Event key is required"),
@@ -571,14 +572,45 @@ var TraitConfigSchema = z.record(TraitConfigValueSchema);
571
572
  function isCallSiteConfigDeclaration(entry) {
572
573
  return typeof entry === "object" && entry !== null && !Array.isArray(entry) && "type" in entry && typeof entry.type === "string" && "default" in entry;
573
574
  }
575
+ var CONFIG_DECLARATION_META_KEYS = ["label", "description", "tier", "synonyms", "values"];
576
+ function isConfigFieldSchema(entry) {
577
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return false;
578
+ if (!("type" in entry) || typeof entry.type !== "string") return false;
579
+ return "default" in entry || CONFIG_DECLARATION_META_KEYS.some((k) => k in entry);
580
+ }
581
+ function normalizeCallSiteConfigToValues(config) {
582
+ if (config === void 0) {
583
+ return void 0;
584
+ }
585
+ const out = {};
586
+ let hasAny = false;
587
+ for (const [key, entry] of Object.entries(config)) {
588
+ const value = isConfigFieldSchema(entry) ? entry.default : entry;
589
+ if (value !== void 0) {
590
+ out[key] = value;
591
+ hasAny = true;
592
+ }
593
+ }
594
+ return hasAny ? out : void 0;
595
+ }
596
+ var ConfigFieldItemsDeclarationSchema = z.lazy(
597
+ () => z.object({
598
+ type: z.string().optional(),
599
+ properties: z.record(TraitEntityFieldSchema).optional(),
600
+ items: ConfigFieldItemsDeclarationSchema.optional()
601
+ })
602
+ );
574
603
  var ConfigFieldDeclarationSchema = z.object({
575
604
  type: z.string(),
576
605
  default: TraitConfigValueSchema.optional(),
606
+ required: z.boolean().optional(),
577
607
  label: z.string().optional(),
578
608
  description: z.string().optional(),
579
609
  tier: z.string().optional(),
580
610
  values: z.array(z.string()).optional(),
581
- synonyms: z.string().optional()
611
+ synonyms: z.string().optional(),
612
+ items: ConfigFieldItemsDeclarationSchema.optional(),
613
+ properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional()
582
614
  });
583
615
  var DeclaredTraitConfigSchema = z.record(
584
616
  ConfigFieldDeclarationSchema
@@ -615,7 +647,9 @@ var TraitEntityFieldSchema = z.object({
615
647
  ]),
616
648
  required: z.boolean().optional(),
617
649
  default: z.unknown().optional(),
618
- values: z.array(z.string()).optional()
650
+ values: z.array(z.string()).optional(),
651
+ items: ConfigFieldItemsDeclarationSchema.optional(),
652
+ properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional()
619
653
  });
620
654
  var TraitDataEntitySchema = z.object({
621
655
  name: z.string().min(1),
@@ -654,19 +688,37 @@ var EventPayloadFieldSchema = z.object({
654
688
  type: z.string().min(1),
655
689
  required: z.boolean().optional(),
656
690
  description: z.string().optional(),
657
- entityType: z.string().optional()
691
+ entityType: z.string().optional(),
692
+ properties: z.lazy(() => z.array(EventPayloadFieldSchema)).optional()
658
693
  });
694
+ var CONFIG_REF_EVENT_PATTERN = /^@config\.[A-Za-z_][A-Za-z0-9_]*$/;
695
+ function configRefEventKnob(event) {
696
+ return CONFIG_REF_EVENT_PATTERN.test(event) ? event.slice("@config.".length) : void 0;
697
+ }
698
+ function resolveConfigRefEventName(event, declaredConfig, effectiveConfig) {
699
+ const knob = configRefEventKnob(event);
700
+ if (knob === void 0) return { ok: false, error: "unknown-knob" };
701
+ const field = declaredConfig?.[knob];
702
+ if (field === void 0) return { ok: false, error: "unknown-knob" };
703
+ if (field.type !== "string") return { ok: false, error: "not-string" };
704
+ if (field.default === void 0) return { ok: false, error: "no-default" };
705
+ const value = effectiveConfig[knob];
706
+ if (typeof value !== "string") return { ok: false, error: "not-string" };
707
+ return { ok: true, value };
708
+ }
659
709
  var TraitEventContractSchema = z.object({
660
710
  /**
661
711
  * Event name. Mirrors the Rust validator's `is_valid_event_identifier`:
662
712
  * starts with a letter, then any letters / digits / underscores. Both
663
713
  * UPPER_SNAKE_CASE and PascalCase shapes are valid identifiers in the
664
714
  * post-Phase 2.5 nominal-event type system (events declared via
665
- * `type X = Event<T>`).
715
+ * `type X = Event<T>`). A pre-resolution `@config.<knob>` reference
716
+ * (Option B) is also legal — inline/resolve substitutes it with the
717
+ * knob's effective literal before codegen/runtime consume it.
666
718
  */
667
719
  event: z.string().min(1).regex(
668
- /^[A-Za-z][A-Za-z0-9_]*$/,
669
- "Event name must start with a letter and contain only letters, digits, and underscores"
720
+ /^([A-Za-z][A-Za-z0-9_]*|@config\.[A-Za-z_][A-Za-z0-9_]*)$/,
721
+ "Event name must start with a letter and contain only letters, digits, and underscores, or be a `@config.<knob>` reference"
670
722
  ),
671
723
  description: z.string().optional(),
672
724
  synonyms: z.string().optional(),
@@ -1608,6 +1660,11 @@ var BINDING_DOCS = {
1608
1660
  description: "Authenticated user / agent context for ownership and role-based gating",
1609
1661
  examples: ["@user.id", "@user.role"],
1610
1662
  requiresPath: true
1663
+ },
1664
+ callsitePayload: {
1665
+ description: "Call-site-captured event payload \u2014 emitted by the compiler's inline-trait hoisting when an extracted render block captured @payload; resolved at the composing effect by the runtime BindingResolver",
1666
+ examples: ["@callsitePayload.error", "@callsitePayload.row"],
1667
+ requiresPath: true
1611
1668
  }
1612
1669
  };
1613
1670
  var BINDING_CONTEXT_RULES = {
@@ -1616,8 +1673,8 @@ var BINDING_CONTEXT_RULES = {
1616
1673
  description: `Guards can access entity fields, event payload, current state, time, the call-site trait config (@config.X), and the authenticated user context (@user.id, @user.role) for ownership / role gates. Config access lets atoms write mode-aware guards \u2014 e.g. std-modal's OPEN can require @payload.row only when @config.mode equals "edit", letting create-mode legitimately fire OPEN with no row. Like effects, @config.X is substituted at molecule/organism inline time with the literal call-site value; at atom-scope validate, @config is allowed-but-unresolved.`
1617
1674
  },
1618
1675
  effect: {
1619
- allowed: ["entity", "payload", "state", "now", "trait", "config", "user"],
1620
- description: "Effects can access and modify entity fields, use payload data, embed another trait's live frame via @trait.X inside render-ui children, read trait config values (@config.X) for atoms parameterized by their call-site, and read the authenticated user context (@user.id, @user.role). At molecule/organism inline time, @config.X is substituted with the literal value from the call-site config block; at atom-scope validate, @config is allowed-but-unresolved."
1676
+ allowed: ["entity", "payload", "state", "now", "trait", "config", "user", "callsitePayload"],
1677
+ description: "Effects can access and modify entity fields, use payload data, embed another trait's live frame via @trait.X inside render-ui children, read trait config values (@config.X) for atoms parameterized by their call-site, and read the authenticated user context (@user.id, @user.role). At molecule/organism inline time, @config.X is substituted with the literal value from the call-site config block; at atom-scope validate, @config is allowed-but-unresolved. @callsitePayload.X is the call-site-captured event payload emitted by the compiler's inline-trait hoisting (a hoisted render block that captured @payload); it is resolved at the composing effect by the runtime BindingResolver."
1621
1678
  },
1622
1679
  tick: {
1623
1680
  allowed: ["entity", "state", "now", "config", "user"],
@@ -1730,7 +1787,7 @@ function getInteractionModelForDomain(domain) {
1730
1787
  // src/patterns/patterns-registry.json
1731
1788
  var patterns_registry_default = {
1732
1789
  version: "1.0.0",
1733
- exportedAt: "2026-07-09T14:00:32.936Z",
1790
+ exportedAt: "2026-07-13T15:27:57.365Z",
1734
1791
  patterns: {
1735
1792
  "entity-table": {
1736
1793
  type: "entity-table",
@@ -12079,6 +12136,144 @@ var patterns_registry_default = {
12079
12136
  ],
12080
12137
  typicalSize: "medium",
12081
12138
  propsSchema: {
12139
+ className: {
12140
+ types: [
12141
+ "string"
12142
+ ],
12143
+ description: "Additional CSS classes"
12144
+ },
12145
+ placeholder: {
12146
+ types: [
12147
+ "string"
12148
+ ],
12149
+ description: "Placeholder text"
12150
+ },
12151
+ value: {
12152
+ types: [
12153
+ "string",
12154
+ "number"
12155
+ ],
12156
+ description: "Current value"
12157
+ },
12158
+ disabled: {
12159
+ types: [
12160
+ "boolean"
12161
+ ],
12162
+ description: "Whether input is disabled"
12163
+ },
12164
+ action: {
12165
+ types: [
12166
+ "string"
12167
+ ],
12168
+ description: "Declarative event name for trait dispatch",
12169
+ kind: "event"
12170
+ },
12171
+ inputType: {
12172
+ types: [
12173
+ "string"
12174
+ ],
12175
+ description: "Input type - supports 'select' and 'textarea' in addition to standard types",
12176
+ enumValues: [
12177
+ "text",
12178
+ "email",
12179
+ "password",
12180
+ "number",
12181
+ "tel",
12182
+ "url",
12183
+ "search",
12184
+ "date",
12185
+ "datetime-local",
12186
+ "time",
12187
+ "checkbox",
12188
+ "select",
12189
+ "textarea"
12190
+ ]
12191
+ },
12192
+ label: {
12193
+ types: [
12194
+ "string"
12195
+ ],
12196
+ description: "label prop"
12197
+ },
12198
+ helperText: {
12199
+ types: [
12200
+ "string"
12201
+ ],
12202
+ description: "helperText prop"
12203
+ },
12204
+ error: {
12205
+ types: [
12206
+ "string"
12207
+ ],
12208
+ description: "error prop"
12209
+ },
12210
+ leftIcon: {
12211
+ types: [
12212
+ "icon",
12213
+ "string"
12214
+ ],
12215
+ description: "leftIcon prop"
12216
+ },
12217
+ rightIcon: {
12218
+ types: [
12219
+ "icon",
12220
+ "string"
12221
+ ],
12222
+ description: "rightIcon prop"
12223
+ },
12224
+ clearable: {
12225
+ types: [
12226
+ "boolean"
12227
+ ],
12228
+ description: "Show clear button when input has value"
12229
+ },
12230
+ onClear: {
12231
+ types: [
12232
+ "function",
12233
+ "string"
12234
+ ],
12235
+ description: "Callback or declarative event key when clear button is clicked"
12236
+ },
12237
+ options: {
12238
+ types: [
12239
+ "array"
12240
+ ],
12241
+ description: "Options for select type",
12242
+ items: {
12243
+ types: [
12244
+ "object"
12245
+ ],
12246
+ properties: {
12247
+ value: {
12248
+ types: [
12249
+ "string"
12250
+ ]
12251
+ },
12252
+ label: {
12253
+ types: [
12254
+ "string"
12255
+ ]
12256
+ }
12257
+ },
12258
+ required: [
12259
+ "value",
12260
+ "label"
12261
+ ]
12262
+ }
12263
+ },
12264
+ rows: {
12265
+ types: [
12266
+ "number"
12267
+ ],
12268
+ description: "Rows for textarea type"
12269
+ },
12270
+ onChange: {
12271
+ types: [
12272
+ "function",
12273
+ "string"
12274
+ ],
12275
+ description: "onChange handler or declarative event key for trait dispatch"
12276
+ },
12082
12277
  leftAddon: {
12083
12278
  types: [
12084
12279
  "node",
@@ -12092,12 +12287,6 @@ var patterns_registry_default = {
12092
12287
  "icon"
12093
12288
  ],
12094
12289
  description: "Right addon (icon, button, or text)"
12095
- },
12096
- className: {
12097
- types: [
12098
- "string"
12099
- ],
12100
- description: "Additional CSS classes"
12101
12290
  }
12102
12291
  }
12103
12292
  },
@@ -36622,7 +36811,159 @@ var patterns_registry_default = {
36622
36811
  "v stack"
36623
36812
  ],
36624
36813
  typicalSize: "small",
36625
- propsSchema: {}
36814
+ propsSchema: {
36815
+ gap: {
36816
+ types: [
36817
+ "string"
36818
+ ],
36819
+ description: "Gap between children",
36820
+ enumValues: [
36821
+ "none",
36822
+ "xs",
36823
+ "sm",
36824
+ "md",
36825
+ "lg",
36826
+ "xl",
36827
+ "2xl"
36828
+ ],
36829
+ default: "md"
36830
+ },
36831
+ align: {
36832
+ types: [
36833
+ "string"
36834
+ ],
36835
+ description: "Align items on the cross axis",
36836
+ enumValues: [
36837
+ "start",
36838
+ "center",
36839
+ "end",
36840
+ "stretch",
36841
+ "baseline"
36842
+ ],
36843
+ default: "stretch"
36844
+ },
36845
+ justify: {
36846
+ types: [
36847
+ "string"
36848
+ ],
36849
+ description: "Justify items on the main axis",
36850
+ enumValues: [
36851
+ "start",
36852
+ "center",
36853
+ "end",
36854
+ "between",
36855
+ "around",
36856
+ "evenly"
36857
+ ],
36858
+ default: "start"
36859
+ },
36860
+ wrap: {
36861
+ types: [
36862
+ "boolean"
36863
+ ],
36864
+ description: "Allow items to wrap",
36865
+ default: false
36866
+ },
36867
+ reverse: {
36868
+ types: [
36869
+ "boolean"
36870
+ ],
36871
+ description: "Reverse the order of children",
36872
+ default: false
36873
+ },
36874
+ flex: {
36875
+ types: [
36876
+ "boolean"
36877
+ ],
36878
+ description: "Fill available space (flex: 1)",
36879
+ default: false
36880
+ },
36881
+ className: {
36882
+ types: [
36883
+ "string"
36884
+ ],
36885
+ description: "Custom class name"
36886
+ },
36887
+ style: {
36888
+ types: [
36889
+ "object"
36890
+ ],
36891
+ description: "Inline styles"
36892
+ },
36893
+ children: {
36894
+ types: [
36895
+ "node"
36896
+ ],
36897
+ description: "Children elements"
36898
+ },
36899
+ as: {
36900
+ types: [
36901
+ "component"
36902
+ ],
36903
+ description: "HTML element to render as"
36904
+ },
36905
+ onClick: {
36906
+ types: [
36907
+ "function"
36908
+ ],
36909
+ description: "Click handler",
36910
+ kind: "callback",
36911
+ callbackArgs: [
36912
+ {
36913
+ name: "e",
36914
+ type: "object"
36915
+ }
36916
+ ],
36917
+ nonEmittable: true
36918
+ },
36919
+ onKeyDown: {
36920
+ types: [
36921
+ "function"
36922
+ ],
36923
+ description: "Keyboard handler",
36924
+ kind: "callback",
36925
+ callbackArgs: [
36926
+ {
36927
+ name: "e",
36928
+ type: "object"
36929
+ }
36930
+ ],
36931
+ nonEmittable: true
36932
+ },
36933
+ role: {
36934
+ types: [
36935
+ "string"
36936
+ ],
36937
+ description: "Role for accessibility"
36938
+ },
36939
+ tabIndex: {
36940
+ types: [
36941
+ "number"
36942
+ ],
36943
+ description: "Tab index for focus management"
36944
+ },
36945
+ action: {
36946
+ types: [
36947
+ "string"
36948
+ ],
36949
+ description: "Declarative event name \u2014 emits UI:{action} via eventBus on click",
36950
+ kind: "event"
36951
+ },
36952
+ actionPayload: {
36953
+ types: [
36954
+ "object"
36955
+ ],
36956
+ description: "Payload to include with the action event",
36957
+ freeform: true
36958
+ },
36959
+ responsive: {
36960
+ types: [
36961
+ "boolean"
36962
+ ],
36963
+ description: "When true, horizontal stacks flip to vertical below the md breakpoint (768px)",
36964
+ default: false
36965
+ }
36966
+ }
36626
36967
  },
36627
36968
  hstack: {
36628
36969
  type: "hstack",
@@ -36635,7 +36976,159 @@ var patterns_registry_default = {
36635
36976
  "h stack"
36636
36977
  ],
36637
36978
  typicalSize: "small",
36638
- propsSchema: {}
36979
+ propsSchema: {
36980
+ gap: {
36981
+ types: [
36982
+ "string"
36983
+ ],
36984
+ description: "Gap between children",
36985
+ enumValues: [
36986
+ "none",
36987
+ "xs",
36988
+ "sm",
36989
+ "md",
36990
+ "lg",
36991
+ "xl",
36992
+ "2xl"
36993
+ ],
36994
+ default: "md"
36995
+ },
36996
+ align: {
36997
+ types: [
36998
+ "string"
36999
+ ],
37000
+ description: "Align items on the cross axis",
37001
+ enumValues: [
37002
+ "start",
37003
+ "center",
37004
+ "end",
37005
+ "stretch",
37006
+ "baseline"
37007
+ ],
37008
+ default: "stretch"
37009
+ },
37010
+ justify: {
37011
+ types: [
37012
+ "string"
37013
+ ],
37014
+ description: "Justify items on the main axis",
37015
+ enumValues: [
37016
+ "start",
37017
+ "center",
37018
+ "end",
37019
+ "between",
37020
+ "around",
37021
+ "evenly"
37022
+ ],
37023
+ default: "start"
37024
+ },
37025
+ wrap: {
37026
+ types: [
37027
+ "boolean"
37028
+ ],
37029
+ description: "Allow items to wrap",
37030
+ default: false
37031
+ },
37032
+ reverse: {
37033
+ types: [
37034
+ "boolean"
37035
+ ],
37036
+ description: "Reverse the order of children",
37037
+ default: false
37038
+ },
37039
+ flex: {
37040
+ types: [
37041
+ "boolean"
37042
+ ],
37043
+ description: "Fill available space (flex: 1)",
37044
+ default: false
37045
+ },
37046
+ className: {
37047
+ types: [
37048
+ "string"
37049
+ ],
37050
+ description: "Custom class name"
37051
+ },
37052
+ style: {
37053
+ types: [
37054
+ "object"
37055
+ ],
37056
+ description: "Inline styles"
37057
+ },
37058
+ children: {
37059
+ types: [
37060
+ "node"
37061
+ ],
37062
+ description: "Children elements"
37063
+ },
37064
+ as: {
37065
+ types: [
37066
+ "component"
37067
+ ],
37068
+ description: "HTML element to render as"
37069
+ },
37070
+ onClick: {
37071
+ types: [
37072
+ "function"
37073
+ ],
37074
+ description: "Click handler",
37075
+ kind: "callback",
37076
+ callbackArgs: [
37077
+ {
37078
+ name: "e",
37079
+ type: "object"
37080
+ }
37081
+ ],
37082
+ nonEmittable: true
37083
+ },
37084
+ onKeyDown: {
37085
+ types: [
37086
+ "function"
37087
+ ],
37088
+ description: "Keyboard handler",
37089
+ kind: "callback",
37090
+ callbackArgs: [
37091
+ {
37092
+ name: "e",
37093
+ type: "object"
37094
+ }
37095
+ ],
37096
+ nonEmittable: true
37097
+ },
37098
+ role: {
37099
+ types: [
37100
+ "string"
37101
+ ],
37102
+ description: "Role for accessibility"
37103
+ },
37104
+ tabIndex: {
37105
+ types: [
37106
+ "number"
37107
+ ],
37108
+ description: "Tab index for focus management"
37109
+ },
37110
+ action: {
37111
+ types: [
37112
+ "string"
37113
+ ],
37114
+ description: "Declarative event name \u2014 emits UI:{action} via eventBus on click",
37115
+ kind: "event"
37116
+ },
37117
+ actionPayload: {
37118
+ types: [
37119
+ "object"
37120
+ ],
37121
+ description: "Payload to include with the action event",
37122
+ freeform: true
37123
+ },
37124
+ responsive: {
37125
+ types: [
37126
+ "boolean"
37127
+ ],
37128
+ description: "When true, horizontal stacks flip to vertical below the md breakpoint (768px)",
37129
+ default: false
37130
+ }
37131
+ }
36639
37132
  },
36640
37133
  "form-layout": {
36641
37134
  type: "form-layout",
@@ -40114,13 +40607,13 @@ var patterns_registry_default = {
40114
40607
  types: [
40115
40608
  "number"
40116
40609
  ],
40117
- description: "Draw width in px (2D) / world units (3D); omitted \u2192 resolved source width."
40610
+ description: "Draw width in world units (fractions of `projector.tileWidth`); omitted \u2192 resolved source width in px."
40118
40611
  },
40119
40612
  height: {
40120
40613
  types: [
40121
40614
  "number"
40122
40615
  ],
40123
- description: "Draw height in px (2D) / world units (3D); omitted \u2192 resolved source height."
40616
+ description: "Draw height in world units (fractions of `projector.tileWidth`); omitted \u2192 resolved source height in px."
40124
40617
  },
40125
40618
  frame: {
40126
40619
  types: [
@@ -40128,6 +40621,12 @@ var patterns_registry_default = {
40128
40621
  ],
40129
40622
  description: "Explicit atlas sub-rect override (px); omitted \u2192 resolved from `asset.atlas`/`asset.sprite`."
40130
40623
  },
40624
+ animation: {
40625
+ types: [
40626
+ "string"
40627
+ ],
40628
+ description: "Named GLB animation clip to play (3D backend only; the 2D painter animates via `frame`). Matched case-insensitively against the model's clips."
40629
+ },
40131
40630
  flipX: {
40132
40631
  types: [
40133
40632
  "boolean"
@@ -40605,6 +41104,11 @@ var patterns_registry_default = {
40605
41104
  "object"
40606
41105
  ]
40607
41106
  },
41107
+ animation: {
41108
+ types: [
41109
+ "string"
41110
+ ]
41111
+ },
40608
41112
  flipX: {
40609
41113
  types: [
40610
41114
  "boolean"
@@ -41731,7 +42235,7 @@ var integrators_registry_default = {
41731
42235
  // src/patterns/component-mapping.json
41732
42236
  var component_mapping_default = {
41733
42237
  version: "1.0.0",
41734
- exportedAt: "2026-07-09T14:00:32.936Z",
42238
+ exportedAt: "2026-07-13T15:27:57.365Z",
41735
42239
  mappings: {
41736
42240
  "page-header": {
41737
42241
  component: "PageHeader",
@@ -43086,7 +43590,7 @@ var component_mapping_default = {
43086
43590
  // src/patterns/event-contracts.json
43087
43591
  var event_contracts_default = {
43088
43592
  version: "1.0.0",
43089
- exportedAt: "2026-07-09T14:00:32.936Z",
43593
+ exportedAt: "2026-07-13T15:27:57.365Z",
43090
43594
  contracts: {
43091
43595
  form: {
43092
43596
  emits: [
@@ -45587,6 +46091,109 @@ function getTrait(ir, traitName) {
45587
46091
  return ir.traits.get(traitName);
45588
46092
  }
45589
46093
 
46094
+ // src/embedded-trait-config.ts
46095
+ var TRAIT_BINDING_PREFIX = "@trait.";
46096
+ var CONFIG_FORWARD_RE = /^@config\.([A-Za-z_][A-Za-z0-9_]*)$/;
46097
+ function collectTraitRefsFromValue(value, into) {
46098
+ if (value === null || value === void 0) return;
46099
+ if (typeof value === "string") {
46100
+ if (value.startsWith(TRAIT_BINDING_PREFIX)) {
46101
+ const rest = value.slice(TRAIT_BINDING_PREFIX.length);
46102
+ const dot = rest.indexOf(".");
46103
+ const traitName = dot === -1 ? rest : rest.slice(0, dot);
46104
+ if (traitName.length > 0) into.add(traitName);
46105
+ }
46106
+ return;
46107
+ }
46108
+ if (Array.isArray(value)) {
46109
+ for (const item of value) collectTraitRefsFromValue(item, into);
46110
+ return;
46111
+ }
46112
+ if (typeof value === "object") {
46113
+ for (const v of Object.values(value)) {
46114
+ collectTraitRefsFromValue(v, into);
46115
+ }
46116
+ }
46117
+ }
46118
+ function targetTraitOf(traitRef) {
46119
+ if (!traitRef || typeof traitRef !== "object") return void 0;
46120
+ const resolved = traitRef._resolved;
46121
+ return resolved && typeof resolved === "object" ? resolved : traitRef;
46122
+ }
46123
+ function collectEmbeddedTraitReferrers(schema) {
46124
+ const out = /* @__PURE__ */ new Map();
46125
+ if (!schema?.orbitals) return out;
46126
+ for (const orbital of schema.orbitals) {
46127
+ const traits = orbital.traits;
46128
+ if (!Array.isArray(traits)) continue;
46129
+ for (const traitRef of traits) {
46130
+ const target = targetTraitOf(traitRef);
46131
+ if (!target) continue;
46132
+ const referrerName = target.name;
46133
+ if (typeof referrerName !== "string" || referrerName.length === 0) continue;
46134
+ const refs = /* @__PURE__ */ new Set();
46135
+ if (target.config) collectTraitRefsFromValue(target.config, refs);
46136
+ const stateMachine = target.stateMachine;
46137
+ if (stateMachine) collectTraitRefsFromValue(stateMachine, refs);
46138
+ if (refs.size === 0) continue;
46139
+ for (const child of refs) {
46140
+ if (child === referrerName) continue;
46141
+ if (!out.has(child)) out.set(child, referrerName);
46142
+ }
46143
+ }
46144
+ }
46145
+ return out;
46146
+ }
46147
+ function buildResolvedTraitConfigs(schema) {
46148
+ const rawByName = {};
46149
+ if (!schema?.orbitals) return {};
46150
+ for (const orbital of schema.orbitals) {
46151
+ const traitRefs = orbital.traits;
46152
+ if (!traitRefs) continue;
46153
+ for (const t of traitRefs) {
46154
+ if (typeof t === "string") continue;
46155
+ const name = t.name ?? t.ref;
46156
+ const config = t.config;
46157
+ if (typeof name === "string" && config !== void 0) {
46158
+ rawByName[name] = { ...t, config };
46159
+ }
46160
+ }
46161
+ }
46162
+ const referrerByChild = collectEmbeddedTraitReferrers(schema);
46163
+ const resolved = /* @__PURE__ */ new Map();
46164
+ const resolving = /* @__PURE__ */ new Set();
46165
+ function resolveConfig(name) {
46166
+ const cached = resolved.get(name);
46167
+ if (cached) return cached;
46168
+ const raw = rawByName[name]?.config;
46169
+ const base = normalizeCallSiteConfigToValues(raw);
46170
+ if (!base) return void 0;
46171
+ if (resolving.has(name)) return base;
46172
+ resolving.add(name);
46173
+ const out = { ...base };
46174
+ const referrer = referrerByChild.get(name);
46175
+ if (referrer && referrer !== name) {
46176
+ const referrerConfig = resolveConfig(referrer);
46177
+ for (const [key, value] of Object.entries(out)) {
46178
+ if (typeof value !== "string") continue;
46179
+ const match = CONFIG_FORWARD_RE.exec(value);
46180
+ if (!match) continue;
46181
+ const forwarded = referrerConfig?.[match[1]];
46182
+ if (forwarded !== void 0) out[key] = forwarded;
46183
+ }
46184
+ }
46185
+ resolving.delete(name);
46186
+ resolved.set(name, out);
46187
+ return out;
46188
+ }
46189
+ const map = {};
46190
+ for (const name of Object.keys(rawByName)) {
46191
+ const cfg = resolveConfig(name);
46192
+ if (cfg !== void 0) map[name] = cfg;
46193
+ }
46194
+ return map;
46195
+ }
46196
+
45590
46197
  // src/diff.ts
45591
46198
  function diffSchemas(before, after) {
45592
46199
  const changes = [];
@@ -47697,6 +48304,6 @@ function mergeEntityFrame(current, orderedWrites) {
47697
48304
  return next;
47698
48305
  }
47699
48306
 
47700
- export { AGENT_DOMAIN_CATEGORIES, ALLOWED_CUSTOM_COMPONENTS, ANIMATION_NAMES, ASSET_ASPECTS, ASSET_DIMENSIONS, AgentDomainCategorySchema, AnimationDefSchema, AnimationNameSchema, AssetAspectSchema, AssetCatalogEntrySchema, AssetCatalogSchema, AssetDimensionSchema, AssetSchema, BINDING_CONTEXT_RULES, BINDING_DOCS, BINDING_ROOTS, BindingSchema, CAMERA_MODES, COMPONENT_MAPPING, CORE_BINDINGS, CameraModeSchema, CameraSchema, ColorSliceSchema, ColorTokensSchema, ComputedEventContractSchema, ComputedEventListenerSchema, ConfigFieldDeclarationSchema, ConfigProvenanceRecordSchema, CustomPatternDefinitionSchema, CustomPatternMapSchema, DEFAULT_INTERACTION_MODELS, DeclaredTraitConfigSchema, DensitySliceSchema, DensityTokensSchema, DesignPreferencesSchema, DesignTokensSchema, DomainCategorySchema, DomainContextSchema, DomainVocabularySchema, ENTITY_ROLES, EVENT_CONTRACTS, EffectSchema, ElevationSliceSchema, ElevationTokensSchema, EntityCallSchema, EntityFieldContractSchema, EntityFieldSchema, EntityPersistenceSchema, EntityRefSchema, EntityRefStringSchema, EntityRoleSchema, EntitySchema, EntitySemanticRoleSchema, EventListenerSchema, EventPayloadFieldSchema, EventSchema, EventScopeSchema, EventSemanticRoleSchema, EventSourceSchema, ExpressionSchema, FieldFormatSchema, FieldSchema, FieldTypeSchema, GameSubCategorySchema, GeometrySliceSchema, GeometryTokensSchema, GuardSchema, INTEGRATORS_REGISTRY, IconFamilySchema, IconographySliceSchema, IconographyTokensSchema, IllustrationSliceSchema, IllustrationStyleSchema, IllustrationTokensSchema, InteractionModelSchema, KNOWN_VALIDATION_ERROR_CODES, ListenSourceSchema, McpServiceDefSchema, MotionDurationKeySchema, MotionDurationPaletteSchema, MotionEasingKeySchema, MotionEasingPaletteSchema, MotionIntentMapSchema, MotionIntentSchema, MotionSliceSchema, MotionTokensSchema, NodeClassificationSchema, OrbitalConfigSchema, OrbitalDefinitionSchema, OrbitalEntitySchema, OrbitalPageSchema, OrbitalPageStrictSchema, OrbitalSchemaSchema, OrbitalTraitRefSchema, OrbitalUnitSchema, OrbitalSchema as OrbitalZodSchema, PATTERN_REGISTRY, PATTERN_TYPES, PageRefObjectSchema, PageRefSchema, PageRefStringSchema, PageSchema, PageTraitRefSchema, PatternTypeSchema, PayloadFieldSchema, RelatedLinkSchema, RelationConfigSchema, RequiredFieldSchema, RestAuthConfigSchema, RestServiceDefSchema, SERVICE_TYPES, SExprAtomSchema, SExprSchema, SPRITE_DIRECTIONS, ScenePosSchema, SchemaMetadataSchema, SemanticAssetRefSchema, ServiceDefinitionSchema, ServiceRefObjectSchema, ServiceRefSchema, ServiceRefStringSchema, ServiceTypeSchema, SkinSpecSchema, SocketEventsSchema, SocketServiceDefSchema, SpacingScaleSchema, SpriteDirectionSchema, SpriteSheetAtlasSchema, StateMachineSchema, StateSchema, StateSemanticRoleSchema, SubTextureSchema, SuggestedGuardSchema, TextureAtlasSchema, ThemeDefinitionSchema, ThemeRefSchema, ThemeRefStringSchema, ThemeTokensSchema, ThemeVariantSchema, TilesheetSchema, TraitCategorySchema, TraitConfigSchema, TraitConfigValueSchema, TraitDataEntitySchema, TraitEntityFieldSchema, TraitEventContractSchema, TraitEventListenerSchema, TraitFieldRefSchema, TraitRefSchema, TraitReferenceSchema, TraitSchema, TraitTickSchema, TransitionSchema, TypeIntentMapSchema, TypeIntentSchema, TypeScaleEntrySchema, TypeScaleSchema, TypeScaleTokensSchema, TypeSizeKeySchema, TypeSliceSchema, TypeSlotSchema, TypeWeightSchema, UISlotSchema, UI_SLOTS, UXHintsSchema, UseDeclarationSchema, UserPersonaSchema, VISUAL_STYLES, ViewTypeSchema, VisualStyleSchema, answerToMutations, answersToMutations, applyEventWiring, applyFactoryCallPlanMutation, applyRenderOverlay, atomic, buildEdgeCoveringWalk, buildGuardPayloads, buildRecommendationContext, buildReplayPaths, buildStateGraph, callService, categorizeRemovals, classifyWorkflow, clearSchemaCache, collectBindings, collectReachableStates, component_mapping_default as componentMapping, composeBehaviors, constTruth, createAssetKey, createEmptyResolvedPage, createEmptyResolvedTrait, createLazyService, createResolvedField, createTypedEventBus, deref, deriveCollection, deriveInputType, despawn, detectLayoutStrategy, detectPageContentReduction, diffFactoryCalls, diffOrbitalSchemas, diffSchemaSemantics, diffSchemas, doEffects, emit, event_contracts_default as eventContracts, extractPayloadFieldRef, findCompatiblePatterns, findService, fingerprintNode, formatRecommendationsForPrompt, generatePatternDescription, generateQuestions, getAllPatternTypes, getArgs, getBindingExamples, getComponentForPattern, getDefaultAnimationsForRole, getEmittedEvents, getEntity, getEntityCardinality, getInteractionModelForDomain, getOperator, getOrbAllowedPatterns, getOrbAllowedPatternsCompact, getOrbAllowedPatternsFiltered, getOrbAllowedPatternsSlim, getPage, getPages, getPatternActionsRef, getPatternDefinition, getPatternMetadata, getPatternPropsCompact, getPatternsGroupedByCategory, getRemovals, getSchemaCacheStats, getServiceNames, getTrait, getTraitConfig, getTraitName, hasService, hasSignificantPageReduction, inferTsType, insertChildAtPath, integrators_registry_default as integratorsRegistry, isBinding, isCallSiteConfigDeclaration, isCircuitEvent, isDestructiveChange, isDrawHostPattern, isDrawablePattern, isEffect, isEntityAwarePattern, isEntityCall, isEntityReference, isEntityReferenceAny, isEventPayloadValue, isFieldValue, isImportedTraitRef, isInlineTrait, isJsonArray, isJsonObject, isJsonPrimitive, isKnownValidationErrorCode, isMcpService, isOrbitalDefinition, isPageReference, isPageReferenceObject, isPageReferenceString, isPlanSnapshot, isResolvedIR, isRestService, isRuntimeEntity, isSExpr, isSExprAtom, isSExprCall, isSExprEffect, isServiceReference, isServiceReferenceObject, isSessionHistoryEntry, isSocketService, isThemeReference, isTraitFieldRef, isValidBinding, isValidPatternType, mergeEntityFrame, navigate, navigatePatternPath, normalizeTraitRef, notify, parseAssetKey, parseBinding, parseEntityRef, parseImportedTraitRef, parseOrbitalSchema, parsePageRef, parseServiceRef, patterns_registry_default as patternsRegistry, persist, persistenceModeAllowsOverrides, recommendPatterns, ref, registry, removeChildAtPath, renderUI, replaceChildAtPath, requiresConfirmation, safeParseOrbitalSchema, schemaToIR, set, setPropAtPath, sexpr, spawn, summarizeOrbital, summarizeSchema, swap, toBindingRoot, translateOverlaysToParams, validateAssetAnimations, validateBindingInContext, walkSExpr, walkStatePairs, watch, widenTier };
48307
+ export { AGENT_DOMAIN_CATEGORIES, ALLOWED_CUSTOM_COMPONENTS, ANIMATION_NAMES, ASSET_ASPECTS, ASSET_DIMENSIONS, AgentDomainCategorySchema, AnimationDefSchema, AnimationNameSchema, AssetAspectSchema, AssetCatalogEntrySchema, AssetCatalogSchema, AssetDimensionSchema, AssetSchema, BINDING_CONTEXT_RULES, BINDING_DOCS, BINDING_ROOTS, BindingSchema, CAMERA_MODES, COMPONENT_MAPPING, CONFIG_REF_EVENT_PATTERN, CORE_BINDINGS, CameraModeSchema, CameraSchema, ColorSliceSchema, ColorTokensSchema, ComputedEventContractSchema, ComputedEventListenerSchema, ConfigFieldDeclarationSchema, ConfigProvenanceRecordSchema, CustomPatternDefinitionSchema, CustomPatternMapSchema, DEFAULT_INTERACTION_MODELS, DeclaredTraitConfigSchema, DensitySliceSchema, DensityTokensSchema, DesignPreferencesSchema, DesignTokensSchema, DomainCategorySchema, DomainContextSchema, DomainVocabularySchema, ENTITY_ROLES, EVENT_CONTRACTS, EffectSchema, ElevationSliceSchema, ElevationTokensSchema, EntityCallSchema, EntityFieldContractSchema, EntityFieldSchema, EntityPersistenceSchema, EntityRefSchema, EntityRefStringSchema, EntityRoleSchema, EntitySchema, EntitySemanticRoleSchema, EventListenerSchema, EventPayloadFieldSchema, EventSchema, EventScopeSchema, EventSemanticRoleSchema, EventSourceSchema, ExpressionSchema, FieldFormatSchema, FieldSchema, FieldTypeSchema, GameSubCategorySchema, GeometrySliceSchema, GeometryTokensSchema, GuardSchema, INTEGRATORS_REGISTRY, IconFamilySchema, IconographySliceSchema, IconographyTokensSchema, IllustrationSliceSchema, IllustrationStyleSchema, IllustrationTokensSchema, InteractionModelSchema, KNOWN_VALIDATION_ERROR_CODES, ListenSourceSchema, McpServiceDefSchema, MotionDurationKeySchema, MotionDurationPaletteSchema, MotionEasingKeySchema, MotionEasingPaletteSchema, MotionIntentMapSchema, MotionIntentSchema, MotionSliceSchema, MotionTokensSchema, NodeClassificationSchema, OrbitalConfigSchema, OrbitalDefinitionSchema, OrbitalEntitySchema, OrbitalPageSchema, OrbitalPageStrictSchema, OrbitalSchemaSchema, OrbitalTraitRefSchema, OrbitalUnitSchema, OrbitalSchema as OrbitalZodSchema, PATTERN_REGISTRY, PATTERN_TYPES, PageRefObjectSchema, PageRefSchema, PageRefStringSchema, PageSchema, PageTraitRefSchema, PatternTypeSchema, PayloadFieldSchema, RelatedLinkSchema, RelationConfigSchema, RequiredFieldSchema, RestAuthConfigSchema, RestServiceDefSchema, SERVICE_TYPES, SExprAtomSchema, SExprSchema, SPRITE_DIRECTIONS, ScenePosSchema, SchemaMetadataSchema, SemanticAssetRefSchema, ServiceDefinitionSchema, ServiceRefObjectSchema, ServiceRefSchema, ServiceRefStringSchema, ServiceTypeSchema, SkinSpecSchema, SocketEventsSchema, SocketServiceDefSchema, SpacingScaleSchema, SpriteDirectionSchema, SpriteSheetAtlasSchema, StateMachineSchema, StateSchema, StateSemanticRoleSchema, SubTextureSchema, SuggestedGuardSchema, TextureAtlasSchema, ThemeDefinitionSchema, ThemeRefSchema, ThemeRefStringSchema, ThemeTokensSchema, ThemeVariantSchema, TilesheetSchema, TraitCategorySchema, TraitConfigSchema, TraitConfigValueSchema, TraitDataEntitySchema, TraitEntityFieldSchema, TraitEventContractSchema, TraitEventListenerSchema, TraitFieldRefSchema, TraitRefSchema, TraitReferenceSchema, TraitSchema, TraitTickSchema, TransitionSchema, TypeIntentMapSchema, TypeIntentSchema, TypeScaleEntrySchema, TypeScaleSchema, TypeScaleTokensSchema, TypeSizeKeySchema, TypeSliceSchema, TypeSlotSchema, TypeWeightSchema, UISlotSchema, UI_SLOTS, UXHintsSchema, UseDeclarationSchema, UserPersonaSchema, VISUAL_STYLES, ViewTypeSchema, VisualStyleSchema, answerToMutations, answersToMutations, applyEventWiring, applyFactoryCallPlanMutation, applyRenderOverlay, atomic, buildEdgeCoveringWalk, buildGuardPayloads, buildRecommendationContext, buildReplayPaths, buildResolvedTraitConfigs, buildStateGraph, callService, categorizeRemovals, classifyWorkflow, clearSchemaCache, collectBindings, collectEmbeddedTraitReferrers, collectReachableStates, component_mapping_default as componentMapping, composeBehaviors, configRefEventKnob, constTruth, createAssetKey, createEmptyResolvedPage, createEmptyResolvedTrait, createLazyService, createResolvedField, createTypedEventBus, deref, deriveCollection, deriveInputType, despawn, detectLayoutStrategy, detectPageContentReduction, diffFactoryCalls, diffOrbitalSchemas, diffSchemaSemantics, diffSchemas, doEffects, emit, event_contracts_default as eventContracts, extractPayloadFieldRef, findCompatiblePatterns, findService, fingerprintNode, formatRecommendationsForPrompt, generatePatternDescription, generateQuestions, getAllPatternTypes, getArgs, getBindingExamples, getComponentForPattern, getDefaultAnimationsForRole, getEmittedEvents, getEntity, getEntityCardinality, getInteractionModelForDomain, getOperator, getOrbAllowedPatterns, getOrbAllowedPatternsCompact, getOrbAllowedPatternsFiltered, getOrbAllowedPatternsSlim, getPage, getPages, getPatternActionsRef, getPatternDefinition, getPatternMetadata, getPatternPropsCompact, getPatternsGroupedByCategory, getRemovals, getSchemaCacheStats, getServiceNames, getTrait, getTraitConfig, getTraitName, hasService, hasSignificantPageReduction, inferTsType, insertChildAtPath, integrators_registry_default as integratorsRegistry, isBinding, isCallSiteConfigDeclaration, isCircuitEvent, isDestructiveChange, isDrawHostPattern, isDrawablePattern, isEffect, isEntityAwarePattern, isEntityCall, isEntityReference, isEntityReferenceAny, isEventPayloadValue, isFieldValue, isImportedTraitRef, isInlineTrait, isJsonArray, isJsonObject, isJsonPrimitive, isKnownValidationErrorCode, isMcpService, isOrbitalDefinition, isPageReference, isPageReferenceObject, isPageReferenceString, isPlanSnapshot, isResolvedIR, isRestService, isRuntimeEntity, isSExpr, isSExprAtom, isSExprCall, isSExprEffect, isServiceReference, isServiceReferenceObject, isSessionHistoryEntry, isSocketService, isThemeReference, isTraitFieldRef, isValidBinding, isValidPatternType, mergeEntityFrame, navigate, navigatePatternPath, normalizeCallSiteConfigToValues, normalizeTraitRef, notify, parseAssetKey, parseBinding, parseEntityRef, parseImportedTraitRef, parseOrbitalSchema, parsePageRef, parseServiceRef, patterns_registry_default as patternsRegistry, persist, persistenceModeAllowsOverrides, recommendPatterns, ref, registry, removeChildAtPath, renderUI, replaceChildAtPath, requiresConfirmation, resolveConfigRefEventName, safeParseOrbitalSchema, schemaToIR, set, setPropAtPath, sexpr, spawn, summarizeOrbital, summarizeSchema, swap, toBindingRoot, translateOverlaysToParams, validateAssetAnimations, validateBindingInContext, walkSExpr, walkStatePairs, watch, widenTier };
47701
48308
  //# sourceMappingURL=index.js.map
47702
48309
  //# sourceMappingURL=index.js.map