@almadar/ui 5.9.7 → 5.9.8

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.
@@ -60902,6 +60902,40 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
60902
60902
  };
60903
60903
  }
60904
60904
 
60905
+ // runtime/orbitalsByTrait.ts
60906
+ function buildOrbitalsByTrait(schema, resolvedPages = []) {
60907
+ const map = {};
60908
+ if (!schema?.orbitals) return map;
60909
+ const pagePathToOrbital = {};
60910
+ for (const orb of schema.orbitals) {
60911
+ for (const traitRef of orb.traits ?? []) {
60912
+ let traitName;
60913
+ if (typeof traitRef === "string") {
60914
+ const parts = traitRef.split(".");
60915
+ traitName = parts[parts.length - 1];
60916
+ } else if (typeof traitRef.ref === "string") {
60917
+ const parts = traitRef.ref.split(".");
60918
+ traitName = traitRef.name ?? parts[parts.length - 1];
60919
+ } else if (typeof traitRef.name === "string") {
60920
+ traitName = traitRef.name;
60921
+ }
60922
+ if (traitName) map[traitName] = orb.name;
60923
+ }
60924
+ for (const pg of orb.pages ?? []) {
60925
+ const path = typeof pg === "string" ? pg : pg?.path;
60926
+ if (path) pagePathToOrbital[path] = orb.name;
60927
+ }
60928
+ }
60929
+ for (const page of resolvedPages) {
60930
+ const orbital = page.path ? pagePathToOrbital[page.path] : void 0;
60931
+ if (!orbital) continue;
60932
+ for (const traitName of page.traitNames) {
60933
+ if (traitName && !(traitName in map)) map[traitName] = orbital;
60934
+ }
60935
+ }
60936
+ return map;
60937
+ }
60938
+
60905
60939
  // runtime/OrbPreview.tsx
60906
60940
  init_EntitySchemaContext();
60907
60941
 
@@ -61660,27 +61694,16 @@ function SchemaRunner({ schema, serverUrl, transport, mockData, pageName, onNavi
61660
61694
  if (!orbitals) return [];
61661
61695
  return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
61662
61696
  }, [schema]);
61663
- const orbitalsByTrait = React98.useMemo(() => {
61664
- const map = {};
61665
- const parsed = schema;
61666
- if (!parsed?.orbitals) return map;
61667
- for (const orb of parsed.orbitals) {
61668
- for (const traitRef of orb.traits) {
61669
- let traitName;
61670
- if (typeof traitRef === "string") {
61671
- const parts = traitRef.split(".");
61672
- traitName = parts[parts.length - 1];
61673
- } else if ("ref" in traitRef && typeof traitRef.ref === "string") {
61674
- const parts = traitRef.ref.split(".");
61675
- traitName = traitRef.name ?? parts[parts.length - 1];
61676
- } else if ("name" in traitRef && typeof traitRef.name === "string") {
61677
- traitName = traitRef.name;
61678
- }
61679
- if (traitName) map[traitName] = orb.name;
61680
- }
61681
- }
61682
- return map;
61683
- }, [schema]);
61697
+ const orbitalsByTrait = React98.useMemo(
61698
+ () => buildOrbitalsByTrait(
61699
+ schema,
61700
+ ir ? Array.from(ir.pages.values()).map((p2) => ({
61701
+ path: p2.path,
61702
+ traitNames: p2.traits.map((b) => b.trait.name)
61703
+ })) : []
61704
+ ),
61705
+ [schema, ir]
61706
+ );
61684
61707
  const traitLinkedEntitiesMap = React98.useMemo(() => {
61685
61708
  const map = /* @__PURE__ */ new Map();
61686
61709
  if (ir) {
package/dist/avl/index.js CHANGED
@@ -60853,6 +60853,40 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
60853
60853
  };
60854
60854
  }
60855
60855
 
60856
+ // runtime/orbitalsByTrait.ts
60857
+ function buildOrbitalsByTrait(schema, resolvedPages = []) {
60858
+ const map = {};
60859
+ if (!schema?.orbitals) return map;
60860
+ const pagePathToOrbital = {};
60861
+ for (const orb of schema.orbitals) {
60862
+ for (const traitRef of orb.traits ?? []) {
60863
+ let traitName;
60864
+ if (typeof traitRef === "string") {
60865
+ const parts = traitRef.split(".");
60866
+ traitName = parts[parts.length - 1];
60867
+ } else if (typeof traitRef.ref === "string") {
60868
+ const parts = traitRef.ref.split(".");
60869
+ traitName = traitRef.name ?? parts[parts.length - 1];
60870
+ } else if (typeof traitRef.name === "string") {
60871
+ traitName = traitRef.name;
60872
+ }
60873
+ if (traitName) map[traitName] = orb.name;
60874
+ }
60875
+ for (const pg of orb.pages ?? []) {
60876
+ const path = typeof pg === "string" ? pg : pg?.path;
60877
+ if (path) pagePathToOrbital[path] = orb.name;
60878
+ }
60879
+ }
60880
+ for (const page of resolvedPages) {
60881
+ const orbital = page.path ? pagePathToOrbital[page.path] : void 0;
60882
+ if (!orbital) continue;
60883
+ for (const traitName of page.traitNames) {
60884
+ if (traitName && !(traitName in map)) map[traitName] = orbital;
60885
+ }
60886
+ }
60887
+ return map;
60888
+ }
60889
+
60856
60890
  // runtime/OrbPreview.tsx
60857
60891
  init_EntitySchemaContext();
60858
60892
 
@@ -61611,27 +61645,16 @@ function SchemaRunner({ schema, serverUrl, transport, mockData, pageName, onNavi
61611
61645
  if (!orbitals) return [];
61612
61646
  return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
61613
61647
  }, [schema]);
61614
- const orbitalsByTrait = useMemo(() => {
61615
- const map = {};
61616
- const parsed = schema;
61617
- if (!parsed?.orbitals) return map;
61618
- for (const orb of parsed.orbitals) {
61619
- for (const traitRef of orb.traits) {
61620
- let traitName;
61621
- if (typeof traitRef === "string") {
61622
- const parts = traitRef.split(".");
61623
- traitName = parts[parts.length - 1];
61624
- } else if ("ref" in traitRef && typeof traitRef.ref === "string") {
61625
- const parts = traitRef.ref.split(".");
61626
- traitName = traitRef.name ?? parts[parts.length - 1];
61627
- } else if ("name" in traitRef && typeof traitRef.name === "string") {
61628
- traitName = traitRef.name;
61629
- }
61630
- if (traitName) map[traitName] = orb.name;
61631
- }
61632
- }
61633
- return map;
61634
- }, [schema]);
61648
+ const orbitalsByTrait = useMemo(
61649
+ () => buildOrbitalsByTrait(
61650
+ schema,
61651
+ ir ? Array.from(ir.pages.values()).map((p2) => ({
61652
+ path: p2.path,
61653
+ traitNames: p2.traits.map((b) => b.trait.name)
61654
+ })) : []
61655
+ ),
61656
+ [schema, ir]
61657
+ );
61635
61658
  const traitLinkedEntitiesMap = useMemo(() => {
61636
61659
  const map = /* @__PURE__ */ new Map();
61637
61660
  if (ir) {
@@ -48544,6 +48544,40 @@ function collectEmbeddedTraits(schema) {
48544
48544
  return out;
48545
48545
  }
48546
48546
 
48547
+ // runtime/orbitalsByTrait.ts
48548
+ function buildOrbitalsByTrait(schema, resolvedPages = []) {
48549
+ const map = {};
48550
+ if (!schema?.orbitals) return map;
48551
+ const pagePathToOrbital = {};
48552
+ for (const orb of schema.orbitals) {
48553
+ for (const traitRef of orb.traits ?? []) {
48554
+ let traitName;
48555
+ if (typeof traitRef === "string") {
48556
+ const parts = traitRef.split(".");
48557
+ traitName = parts[parts.length - 1];
48558
+ } else if (typeof traitRef.ref === "string") {
48559
+ const parts = traitRef.ref.split(".");
48560
+ traitName = traitRef.name ?? parts[parts.length - 1];
48561
+ } else if (typeof traitRef.name === "string") {
48562
+ traitName = traitRef.name;
48563
+ }
48564
+ if (traitName) map[traitName] = orb.name;
48565
+ }
48566
+ for (const pg of orb.pages ?? []) {
48567
+ const path = typeof pg === "string" ? pg : pg?.path;
48568
+ if (path) pagePathToOrbital[path] = orb.name;
48569
+ }
48570
+ }
48571
+ for (const page of resolvedPages) {
48572
+ const orbital = page.path ? pagePathToOrbital[page.path] : void 0;
48573
+ if (!orbital) continue;
48574
+ for (const traitName of page.traitNames) {
48575
+ if (traitName && !(traitName in map)) map[traitName] = orbital;
48576
+ }
48577
+ }
48578
+ return map;
48579
+ }
48580
+
48547
48581
  // runtime/OrbPreview.tsx
48548
48582
  init_EntitySchemaContext();
48549
48583
 
@@ -49339,27 +49373,16 @@ function SchemaRunner({ schema, serverUrl, transport, mockData, pageName, onNavi
49339
49373
  if (!orbitals) return [];
49340
49374
  return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
49341
49375
  }, [schema]);
49342
- const orbitalsByTrait = React85.useMemo(() => {
49343
- const map = {};
49344
- const parsed = schema;
49345
- if (!parsed?.orbitals) return map;
49346
- for (const orb of parsed.orbitals) {
49347
- for (const traitRef of orb.traits) {
49348
- let traitName;
49349
- if (typeof traitRef === "string") {
49350
- const parts = traitRef.split(".");
49351
- traitName = parts[parts.length - 1];
49352
- } else if ("ref" in traitRef && typeof traitRef.ref === "string") {
49353
- const parts = traitRef.ref.split(".");
49354
- traitName = traitRef.name ?? parts[parts.length - 1];
49355
- } else if ("name" in traitRef && typeof traitRef.name === "string") {
49356
- traitName = traitRef.name;
49357
- }
49358
- if (traitName) map[traitName] = orb.name;
49359
- }
49360
- }
49361
- return map;
49362
- }, [schema]);
49376
+ const orbitalsByTrait = React85.useMemo(
49377
+ () => buildOrbitalsByTrait(
49378
+ schema,
49379
+ ir ? Array.from(ir.pages.values()).map((p2) => ({
49380
+ path: p2.path,
49381
+ traitNames: p2.traits.map((b) => b.trait.name)
49382
+ })) : []
49383
+ ),
49384
+ [schema, ir]
49385
+ );
49363
49386
  const traitLinkedEntitiesMap = React85.useMemo(() => {
49364
49387
  const map = /* @__PURE__ */ new Map();
49365
49388
  if (ir) {
@@ -48495,6 +48495,40 @@ function collectEmbeddedTraits(schema) {
48495
48495
  return out;
48496
48496
  }
48497
48497
 
48498
+ // runtime/orbitalsByTrait.ts
48499
+ function buildOrbitalsByTrait(schema, resolvedPages = []) {
48500
+ const map = {};
48501
+ if (!schema?.orbitals) return map;
48502
+ const pagePathToOrbital = {};
48503
+ for (const orb of schema.orbitals) {
48504
+ for (const traitRef of orb.traits ?? []) {
48505
+ let traitName;
48506
+ if (typeof traitRef === "string") {
48507
+ const parts = traitRef.split(".");
48508
+ traitName = parts[parts.length - 1];
48509
+ } else if (typeof traitRef.ref === "string") {
48510
+ const parts = traitRef.ref.split(".");
48511
+ traitName = traitRef.name ?? parts[parts.length - 1];
48512
+ } else if (typeof traitRef.name === "string") {
48513
+ traitName = traitRef.name;
48514
+ }
48515
+ if (traitName) map[traitName] = orb.name;
48516
+ }
48517
+ for (const pg of orb.pages ?? []) {
48518
+ const path = typeof pg === "string" ? pg : pg?.path;
48519
+ if (path) pagePathToOrbital[path] = orb.name;
48520
+ }
48521
+ }
48522
+ for (const page of resolvedPages) {
48523
+ const orbital = page.path ? pagePathToOrbital[page.path] : void 0;
48524
+ if (!orbital) continue;
48525
+ for (const traitName of page.traitNames) {
48526
+ if (traitName && !(traitName in map)) map[traitName] = orbital;
48527
+ }
48528
+ }
48529
+ return map;
48530
+ }
48531
+
48498
48532
  // runtime/OrbPreview.tsx
48499
48533
  init_EntitySchemaContext();
48500
48534
 
@@ -49290,27 +49324,16 @@ function SchemaRunner({ schema, serverUrl, transport, mockData, pageName, onNavi
49290
49324
  if (!orbitals) return [];
49291
49325
  return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
49292
49326
  }, [schema]);
49293
- const orbitalsByTrait = useMemo(() => {
49294
- const map = {};
49295
- const parsed = schema;
49296
- if (!parsed?.orbitals) return map;
49297
- for (const orb of parsed.orbitals) {
49298
- for (const traitRef of orb.traits) {
49299
- let traitName;
49300
- if (typeof traitRef === "string") {
49301
- const parts = traitRef.split(".");
49302
- traitName = parts[parts.length - 1];
49303
- } else if ("ref" in traitRef && typeof traitRef.ref === "string") {
49304
- const parts = traitRef.ref.split(".");
49305
- traitName = traitRef.name ?? parts[parts.length - 1];
49306
- } else if ("name" in traitRef && typeof traitRef.name === "string") {
49307
- traitName = traitRef.name;
49308
- }
49309
- if (traitName) map[traitName] = orb.name;
49310
- }
49311
- }
49312
- return map;
49313
- }, [schema]);
49327
+ const orbitalsByTrait = useMemo(
49328
+ () => buildOrbitalsByTrait(
49329
+ schema,
49330
+ ir ? Array.from(ir.pages.values()).map((p2) => ({
49331
+ path: p2.path,
49332
+ traitNames: p2.traits.map((b) => b.trait.name)
49333
+ })) : []
49334
+ ),
49335
+ [schema, ir]
49336
+ );
49314
49337
  const traitLinkedEntitiesMap = useMemo(() => {
49315
49338
  const map = /* @__PURE__ */ new Map();
49316
49339
  if (ir) {
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Build the `trait name → owning orbital` map used to form the qualified
3
+ * `UI:<orbital>.<trait>.<event>` bus keys that trait state machines subscribe
4
+ * to. Pure + dependency-free so it can be unit-tested without a React render.
5
+ *
6
+ * Critically, it backfills from the RESOLVED page bindings, not just the source
7
+ * `schema.orbitals[].traits`. An auto-pulled sibling trait (e.g. an embedded
8
+ * `@trait.X` calendar lifted into the orbital by the compiler's sibling-pull)
9
+ * is absent from the source orbital's `traits[]`, so a source-only map misses
10
+ * it — leaving its self-subscription unregistered and its own fetch-success
11
+ * (e.g. `CalendarEventLoaded`) unheard, so the trait sticks in `loading`. A
12
+ * pulled sibling lands in the same orbital as the page that references it, so
13
+ * we backfill from the resolved page's owning orbital. Source-declared mappings
14
+ * win; the IR only fills gaps.
15
+ */
16
+ export interface OrbitalsByTraitSchema {
17
+ orbitals?: ReadonlyArray<{
18
+ name: string;
19
+ traits?: ReadonlyArray<string | {
20
+ ref?: string;
21
+ name?: string;
22
+ }>;
23
+ pages?: ReadonlyArray<string | {
24
+ path?: string;
25
+ }>;
26
+ }>;
27
+ }
28
+ export interface ResolvedPageTraits {
29
+ /** Page route path, matched against the source orbital's page paths. */
30
+ path?: string;
31
+ /** Resolved trait names mounted on the page (includes pulled siblings). */
32
+ traitNames: readonly string[];
33
+ }
34
+ export declare function buildOrbitalsByTrait(schema: OrbitalsByTraitSchema | undefined, resolvedPages?: ReadonlyArray<ResolvedPageTraits>): Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "5.9.7",
3
+ "version": "5.9.8",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [