@adaas/are-html 0.0.20 → 0.0.22

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.
Files changed (109) hide show
  1. package/.conf/tsconfig.base.json +1 -0
  2. package/.conf/tsconfig.browser.json +1 -0
  3. package/.conf/tsconfig.node.json +1 -0
  4. package/dist/browser/index.d.mts +206 -7
  5. package/dist/browser/index.mjs +527 -65
  6. package/dist/browser/index.mjs.map +1 -1
  7. package/dist/node/directives/AreDirectiveFor.directive.d.mts +44 -1
  8. package/dist/node/directives/AreDirectiveFor.directive.d.ts +44 -1
  9. package/dist/node/directives/AreDirectiveFor.directive.js +102 -6
  10. package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
  11. package/dist/node/directives/AreDirectiveFor.directive.mjs +102 -6
  12. package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
  13. package/dist/node/directives/AreDirectiveShow.directive.d.mts +32 -0
  14. package/dist/node/directives/AreDirectiveShow.directive.d.ts +32 -0
  15. package/dist/node/directives/AreDirectiveShow.directive.js +81 -0
  16. package/dist/node/directives/AreDirectiveShow.directive.js.map +1 -0
  17. package/dist/node/directives/AreDirectiveShow.directive.mjs +71 -0
  18. package/dist/node/directives/AreDirectiveShow.directive.mjs.map +1 -0
  19. package/dist/node/engine/AreHTML.engine.d.mts +2 -1
  20. package/dist/node/engine/AreHTML.engine.d.ts +2 -1
  21. package/dist/node/engine/AreHTML.engine.js +8 -2
  22. package/dist/node/engine/AreHTML.engine.js.map +1 -1
  23. package/dist/node/engine/AreHTML.engine.mjs +8 -2
  24. package/dist/node/engine/AreHTML.engine.mjs.map +1 -1
  25. package/dist/node/engine/AreHTML.interpreter.d.mts +3 -0
  26. package/dist/node/engine/AreHTML.interpreter.d.ts +3 -0
  27. package/dist/node/engine/AreHTML.interpreter.js +29 -0
  28. package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
  29. package/dist/node/engine/AreHTML.interpreter.mjs +29 -0
  30. package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
  31. package/dist/node/engine/AreHTML.lifecycle.d.mts +8 -1
  32. package/dist/node/engine/AreHTML.lifecycle.d.ts +8 -1
  33. package/dist/node/engine/AreHTML.lifecycle.js +46 -3
  34. package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
  35. package/dist/node/engine/AreHTML.lifecycle.mjs +46 -3
  36. package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
  37. package/dist/node/helpers/AreScheduler.helper.d.mts +39 -0
  38. package/dist/node/helpers/AreScheduler.helper.d.ts +39 -0
  39. package/dist/node/helpers/AreScheduler.helper.js +40 -0
  40. package/dist/node/helpers/AreScheduler.helper.js.map +1 -0
  41. package/dist/node/helpers/AreScheduler.helper.mjs +40 -0
  42. package/dist/node/helpers/AreScheduler.helper.mjs.map +1 -0
  43. package/dist/node/index.d.mts +4 -1
  44. package/dist/node/index.d.ts +4 -1
  45. package/dist/node/index.js +21 -0
  46. package/dist/node/index.mjs +3 -0
  47. package/dist/node/instructions/AreHTML.instructions.constants.d.mts +1 -0
  48. package/dist/node/instructions/AreHTML.instructions.constants.d.ts +1 -0
  49. package/dist/node/instructions/AreHTML.instructions.constants.js +2 -1
  50. package/dist/node/instructions/AreHTML.instructions.constants.js.map +1 -1
  51. package/dist/node/instructions/AreHTML.instructions.constants.mjs +2 -1
  52. package/dist/node/instructions/AreHTML.instructions.constants.mjs.map +1 -1
  53. package/dist/node/instructions/AreHTML.instructions.types.d.mts +9 -1
  54. package/dist/node/instructions/AreHTML.instructions.types.d.ts +9 -1
  55. package/dist/node/instructions/HideElement.instruction.d.mts +13 -0
  56. package/dist/node/instructions/HideElement.instruction.d.ts +13 -0
  57. package/dist/node/instructions/HideElement.instruction.js +31 -0
  58. package/dist/node/instructions/HideElement.instruction.js.map +1 -0
  59. package/dist/node/instructions/HideElement.instruction.mjs +24 -0
  60. package/dist/node/instructions/HideElement.instruction.mjs.map +1 -0
  61. package/dist/node/lib/AreRoot/AreRoot.component.d.mts +57 -3
  62. package/dist/node/lib/AreRoot/AreRoot.component.d.ts +57 -3
  63. package/dist/node/lib/AreRoot/AreRoot.component.js +138 -49
  64. package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
  65. package/dist/node/lib/AreRoot/AreRoot.component.mjs +140 -51
  66. package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
  67. package/dist/node/lib/AreRoot/AreRootCache.context.d.mts +58 -0
  68. package/dist/node/lib/AreRoot/AreRootCache.context.d.ts +58 -0
  69. package/dist/node/lib/AreRoot/AreRootCache.context.js +106 -0
  70. package/dist/node/lib/AreRoot/AreRootCache.context.js.map +1 -0
  71. package/dist/node/lib/AreRoot/AreRootCache.context.mjs +99 -0
  72. package/dist/node/lib/AreRoot/AreRootCache.context.mjs.map +1 -0
  73. package/examples/dashboard/dist/index.html +1 -1
  74. package/examples/dashboard/dist/{mq19zxz4-mnlgmd.js → mqh9ryml-xat335.js} +1922 -1316
  75. package/examples/dashboard/src/concept.ts +3 -2
  76. package/examples/for-perf/concept.ts +45 -0
  77. package/examples/for-perf/containers/UI.container.ts +161 -0
  78. package/examples/for-perf/dist/index.html +270 -0
  79. package/examples/for-perf/dist/mqh9ryde-m243t8.js +15223 -0
  80. package/examples/for-perf/dist/mqh9ryfo-6a8d0o.js +15223 -0
  81. package/examples/for-perf/dist/mqh9ryfq-4pf5cv.js +15223 -0
  82. package/examples/for-perf/public/index.html +270 -0
  83. package/examples/for-perf/src/components/PerfApp.component.ts +37 -0
  84. package/examples/for-perf/src/components/PerfControls.component.ts +34 -0
  85. package/examples/for-perf/src/components/PerfGrid.component.ts +225 -0
  86. package/examples/for-perf/src/components/PerfHeader.component.ts +34 -0
  87. package/examples/for-perf/src/components/PerfStats.component.ts +43 -0
  88. package/examples/for-perf/src/concept.ts +94 -0
  89. package/examples/jumpstart/dist/index.html +1 -1
  90. package/examples/jumpstart/dist/{mq1a0fv0-ccgtz6.js → mq7mgf58-vbf07e.js} +895 -521
  91. package/examples/signal-routing/dist/index.html +1 -1
  92. package/examples/signal-routing/dist/{mq1bzrik-4lec86.js → mqh9ryc9-dkcbkx.js} +2024 -1300
  93. package/examples/signal-routing/src/components/SettingsPage.component.ts +39 -0
  94. package/examples/signal-routing/src/concept.ts +2 -0
  95. package/jest.config.ts +1 -0
  96. package/package.json +10 -9
  97. package/src/directives/AreDirectiveFor.directive.ts +185 -12
  98. package/src/directives/AreDirectiveShow.directive.ts +127 -0
  99. package/src/engine/AreHTML.engine.ts +11 -1
  100. package/src/engine/AreHTML.interpreter.ts +50 -0
  101. package/src/engine/AreHTML.lifecycle.ts +83 -6
  102. package/src/helpers/AreScheduler.helper.ts +61 -0
  103. package/src/index.ts +3 -0
  104. package/src/instructions/AreHTML.instructions.constants.ts +1 -0
  105. package/src/instructions/AreHTML.instructions.types.ts +9 -0
  106. package/src/instructions/HideElement.instruction.ts +29 -0
  107. package/src/lib/AreRoot/AreRoot.component.ts +205 -72
  108. package/src/lib/AreRoot/AreRootCache.context.ts +133 -0
  109. package/tsconfig.json +1 -0
@@ -6,6 +6,7 @@ var aLogger = require('@adaas/a-utils/a-logger');
6
6
  var aSignal = require('@adaas/a-utils/a-signal');
7
7
  var are = require('@adaas/are');
8
8
  var AreRoute_signal = require('@adaas/are-html/signals/AreRoute.signal');
9
+ var AreRootCache_context = require('./AreRootCache.context');
9
10
 
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -19,7 +20,7 @@ var __decorateClass = (decorators, target, key, kind) => {
19
20
  };
20
21
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
21
22
  exports.AreRoot = class AreRoot extends are.Are {
22
- async template(root, logger, signalsContext) {
23
+ async template(root, logger, signalsContext, signalState) {
23
24
  const rootId = root.id;
24
25
  if (signalsContext && !signalsContext.hasRoot(rootId)) {
25
26
  if (!root.content?.trim()) {
@@ -31,26 +32,9 @@ exports.AreRoot = class AreRoot extends are.Are {
31
32
  }
32
33
  return;
33
34
  }
34
- const currentRoute = AreRoute_signal.AreRoute.default();
35
- let componentName;
36
- if (currentRoute) {
37
- const initialVector = new aSignal.A_SignalVector([currentRoute]);
38
- let renderTarget = signalsContext?.findComponentByVector(rootId, initialVector);
39
- if (!renderTarget) {
40
- const signalsMeta = aConcept.A_Context.meta(are.AreSignals);
41
- const pool = signalsContext?.getComponentById(rootId);
42
- const metaTarget = signalsMeta?.findComponentByVector(
43
- initialVector,
44
- pool?.length ? pool : void 0
45
- );
46
- if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {
47
- renderTarget = metaTarget;
48
- }
49
- }
50
- if (renderTarget?.name) {
51
- componentName = aConcept.A_FormatterHelper.toKebabCase(renderTarget.name);
52
- }
53
- }
35
+ const initialVector = this.buildInitialVector(signalState);
36
+ const renderTarget = this.matchComponent(rootId, initialVector, signalsContext);
37
+ let componentName = renderTarget?.name ? aConcept.A_FormatterHelper.toKebabCase(renderTarget.name) : void 0;
54
38
  if (!componentName) {
55
39
  if (root.content?.trim()) {
56
40
  return;
@@ -72,32 +56,17 @@ exports.AreRoot = class AreRoot extends are.Are {
72
56
  }
73
57
  root.setContent(`<${componentName}></${componentName}>`);
74
58
  }
75
- async onSignal(root, vector, logger, signalsContext) {
59
+ async onSignal(root, vector, logger, signalsContext, cache) {
76
60
  const rootId = root.id;
77
61
  if (signalsContext && !signalsContext.hasRoot(rootId)) {
78
62
  return;
79
63
  }
80
- let renderTarget = signalsContext?.findComponentByVector(rootId, vector);
81
- if (!renderTarget) {
82
- const signalsMeta = aConcept.A_Context.meta(are.AreSignals);
83
- const pool = signalsContext?.getComponentById(rootId);
84
- const metaTarget = signalsMeta?.findComponentByVector(
85
- vector,
86
- pool?.length ? pool : void 0
87
- );
88
- if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {
89
- renderTarget = metaTarget;
90
- }
91
- }
64
+ const renderTarget = this.matchComponent(rootId, vector, signalsContext);
92
65
  const def = signalsContext?.getDefault(rootId);
93
66
  const componentName = renderTarget?.name ? aConcept.A_FormatterHelper.toKebabCase(renderTarget.name) : def?.name ? aConcept.A_FormatterHelper.toKebabCase(def.name) : void 0;
94
67
  if (!componentName) {
95
- for (let i = 0; i < root.children.length; i++) {
96
- const child = root.children[i];
97
- signalsContext?.unsubscribe(child);
98
- child.unmount();
99
- child.destroy();
100
- root.removeChild(child);
68
+ for (const child of [...root.children]) {
69
+ this.stashChild(root, child, signalsContext, cache);
101
70
  }
102
71
  root.setContent("");
103
72
  return;
@@ -106,13 +75,14 @@ exports.AreRoot = class AreRoot extends are.Are {
106
75
  if (currentChild?.type === componentName) {
107
76
  return;
108
77
  }
78
+ for (const child of [...root.children]) {
79
+ this.stashChild(root, child, signalsContext, cache);
80
+ }
109
81
  root.setContent(`<${componentName}></${componentName}>`);
110
- for (let i = 0; i < root.children.length; i++) {
111
- const child = root.children[i];
112
- signalsContext?.unsubscribe(child);
113
- child.unmount();
114
- child.destroy();
115
- root.removeChild(child);
82
+ const cached = cache?.take(root.id, componentName);
83
+ if (cached) {
84
+ this.restoreChild(root, cached, signalsContext);
85
+ return;
116
86
  }
117
87
  root.tokenize();
118
88
  for (let i = 0; i < root.children.length; i++) {
@@ -124,22 +94,141 @@ exports.AreRoot = class AreRoot extends are.Are {
124
94
  }
125
95
  child.transform();
126
96
  child.compile();
127
- child.mount();
97
+ await child.mount();
98
+ }
99
+ }
100
+ /**
101
+ * Resolves the component a vector should render for the given root, mirroring
102
+ * the priority used everywhere in the routing system:
103
+ * 1. Root-specific conditions registered on AreSignalsContext.
104
+ * 2. The global AreSignalsMeta map, restricted to this outlet's pool.
105
+ *
106
+ * Passing the pool *into* the meta lookup is critical: without it, the first
107
+ * globally matching component wins and may belong to a different outlet
108
+ * (e.g. AisRequirementsPanel for the meta-outlet matching
109
+ * AisEditorCursorScope) — the pool check would then reject it and the outlet
110
+ * would fall back to its default, hiding a valid in-pool match (e.g.
111
+ * AisDiagramTab matching AisSetPrimaryDisplay).
112
+ *
113
+ * Returns `undefined` when nothing matches — callers decide whether to use a
114
+ * configured default, body content, or clear the outlet.
115
+ */
116
+ matchComponent(rootId, vector, signalsContext) {
117
+ if (!vector) return void 0;
118
+ let renderTarget = signalsContext?.findComponentByVector(rootId, vector);
119
+ if (!renderTarget) {
120
+ const signalsMeta = aConcept.A_Context.meta(are.AreSignals);
121
+ const pool = signalsContext?.getComponentById(rootId);
122
+ const metaTarget = signalsMeta?.findComponentByVector(
123
+ vector,
124
+ pool?.length ? pool : void 0,
125
+ rootId
126
+ );
127
+ if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {
128
+ renderTarget = metaTarget;
129
+ }
130
+ }
131
+ return renderTarget;
132
+ }
133
+ /**
134
+ * Builds the vector used for the INITIAL render. It is seeded from the
135
+ * accumulated signal state (every signal dispatched on the bus so far) so a
136
+ * freshly-mounted outlet reflects the live application state immediately,
137
+ * not just on the next signal tick. The current URL route is appended when
138
+ * no AreRoute is already present in the state, so route-driven outlets still
139
+ * resolve on the very first paint (before AreRouteWatcher has dispatched).
140
+ */
141
+ buildInitialVector(signalState) {
142
+ const signals = [];
143
+ if (signalState) {
144
+ for (const signal of signalState.toVector()) {
145
+ if (signal) signals.push(signal);
146
+ }
147
+ }
148
+ if (!signals.some((signal) => signal instanceof AreRoute_signal.AreRoute)) {
149
+ try {
150
+ const currentRoute = AreRoute_signal.AreRoute.default();
151
+ if (currentRoute) signals.push(currentRoute);
152
+ } catch {
153
+ }
154
+ }
155
+ return new aSignal.A_SignalVector(signals);
156
+ }
157
+ /**
158
+ * Detach a displayed child subtree from the outlet and stash it in the cache
159
+ * for fast re-injection later. The subtree is unmounted (its scene plan is
160
+ * preserved) and deregistered from the root scope, but NOT destroyed. The
161
+ * nodes that were subscribed to the signal bus are unsubscribed while cached
162
+ * so the detached DOM never reacts to signals, and recorded so they can be
163
+ * re-subscribed verbatim on restore.
164
+ *
165
+ * When no cache is available, or the LRU evicts an entry, the affected
166
+ * subtree is fully destroyed.
167
+ */
168
+ stashChild(root, child, signalsContext, cache) {
169
+ const tag = child.type;
170
+ child.unmount();
171
+ const subscribers = signalsContext ? this.collectSubscribers(child, signalsContext) : [];
172
+ for (const node of subscribers) {
173
+ signalsContext?.unsubscribe(node);
174
+ }
175
+ root.removeChild(child);
176
+ if (!cache) {
177
+ void child.destroy();
178
+ return;
179
+ }
180
+ const evicted = cache.put(root.id, tag, { node: child, subscribers });
181
+ for (const entry of evicted) {
182
+ void entry.node.destroy();
183
+ }
184
+ }
185
+ /**
186
+ * Re-attach a cached subtree to the outlet and re-mount it from its preserved
187
+ * scene plan, re-subscribing exactly the nodes that were subscribed before it
188
+ * was cached.
189
+ */
190
+ restoreChild(root, entry, signalsContext) {
191
+ const child = entry.node;
192
+ root.addChild(child);
193
+ for (const node of entry.subscribers) {
194
+ signalsContext?.subscribe(node);
195
+ }
196
+ child.mount();
197
+ }
198
+ /**
199
+ * Walk a subtree and collect the nodes currently registered as signal
200
+ * subscribers. Mirrors the subscription performed at init time in
201
+ * AreHTMLLifecycle (component nodes and root nodes) without depending on the
202
+ * concrete node classes — it simply intersects the subtree with the live
203
+ * subscriber registry.
204
+ */
205
+ collectSubscribers(node, signalsContext) {
206
+ const result = [];
207
+ const queue = [node];
208
+ while (queue.length > 0) {
209
+ const current = queue.shift();
210
+ if (signalsContext.subscribers.has(current)) {
211
+ result.push(current);
212
+ }
213
+ queue.push(...current.children);
128
214
  }
215
+ return result;
129
216
  }
130
217
  };
131
218
  __decorateClass([
132
219
  are.Are.Template,
133
220
  __decorateParam(0, aConcept.A_Inject(aConcept.A_Caller)),
134
221
  __decorateParam(1, aConcept.A_Inject(aLogger.A_Logger)),
135
- __decorateParam(2, aConcept.A_Inject(are.AreSignalsContext))
222
+ __decorateParam(2, aConcept.A_Inject(are.AreSignalsContext)),
223
+ __decorateParam(3, aConcept.A_Inject(aSignal.A_SignalState))
136
224
  ], exports.AreRoot.prototype, "template", 1);
137
225
  __decorateClass([
138
226
  are.Are.Signal,
139
227
  __decorateParam(0, aConcept.A_Inject(aConcept.A_Caller)),
140
228
  __decorateParam(1, aConcept.A_Inject(aSignal.A_SignalVector)),
141
229
  __decorateParam(2, aConcept.A_Inject(aLogger.A_Logger)),
142
- __decorateParam(3, aConcept.A_Inject(are.AreSignalsContext))
230
+ __decorateParam(3, aConcept.A_Inject(are.AreSignalsContext)),
231
+ __decorateParam(4, aConcept.A_Inject(AreRootCache_context.AreRootCache))
143
232
  ], exports.AreRoot.prototype, "onSignal", 1);
144
233
  exports.AreRoot = __decorateClass([
145
234
  core.A_Frame.Define({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":["AreRoot","Are","AreRoute","A_SignalVector","A_Context","AreSignals","A_FormatterHelper","A_Caller","A_Logger","AreSignalsContext","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;AAYaA,eAAA,GAAN,sBAAsBC,OAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,cAAA,EAC/B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAIpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,EAAS,IAAA,EAAK,EAAG;AAEvB,QAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,EAAQ,KAAA,CAAM,4BAA4B,CAAA;AACpE,QAAA,MAAM,gBAAA,GAAmB,eAAe,CAAC,CAAA;AACzC,QAAA,IAAI,gBAAA,EAAkB;AAClB,UAAA,IAAA,CAAK,UAAA,CAAW,CAAA,CAAA,EAAI,gBAAgB,CAAA,GAAA,EAAM,gBAAgB,CAAA,CAAA,CAAG,CAAA;AAAA,QACjE;AAAA,MACJ;AAEA,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,YAAA,GAAeC,yBAAS,OAAA,EAAQ;AAEtC,IAAA,IAAI,aAAA;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AA,CAAS,QAAQ,CAAA,EAAA,EAAK;AAC3C,MAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,QAAA,CAAS,CAAC,CAAA;AAC7B,MAAA,KAAA,CAAM,IAAA,EAAK;AAEX,MAAA,MAAM,GAAA,GAAM,MAAM,IAAA,EAAK;AACvB,MAAA,IAAI,eAAe,OAAA,EAAS;AACxB,QAAA,MAAM,GAAA;AAAA,MACV;AACA,MAAA,KAAA,CAAM,SAAA,EAAU;AAEhB,MAAA,KAAA,CAAM,OAAA,EAAQ;AACd,MAAA,KAAA,CAAM,KAAA,EAAM;AAAA,IAChB;AAAA,EACJ;AACJ;AAvLU,eAAA,CAAA;AAAA,EADLL,OAAA,CAAI,QAAA;AAAA,EAEA,qCAASM,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA;AAAA,CAAA,EANtBT,eAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAwFA,eAAA,CAAA;AAAA,EADLC,OAAA,CAAI,MAAA;AAAA,EAEA,qCAASM,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASJ,sBAAc,CAAA,CAAA;AAAA,EACvB,qCAASK,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA;AAAA,CAAA,EA/FtBT,eAAA,CA2FH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AA3FGA,eAAA,GAAN,eAAA,CAAA;AAAA,EAJNU,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYV,eAAA,CAAA","file":"AreRoot.component.js","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext } from \"@adaas/are\";\nimport { AreRoute } from \"@adaas/are-html/signals/AreRoute.signal\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'The AreRoot component serves as the foundational entry point for the A-Concept Rendering Engine (ARE). It is responsible for initializing the rendering process, managing the root node of the component tree, and handling signal-based rendering logic. The AreRoot component processes incoming signals to determine which child components to render, allowing for dynamic and responsive UI updates based on application state and user interactions.'\n})\nexport class AreRoot extends Are {\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — but still honour body content or\n // a 'default' attribute if one is present on the markup.\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n if (!root.content?.trim()) {\n // Fallback: legacy default= attribute\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n const defaultComponent = defaultMatch?.[1];\n if (defaultComponent) {\n root.setContent(`<${defaultComponent}></${defaultComponent}>`);\n }\n }\n // Body content (or none) — tokenizer picks it up without intervention\n return;\n }\n\n const currentRoute = AreRoute.default();\n\n let componentName: string | undefined;\n\n if (currentRoute) {\n const initialVector = new A_SignalVector([currentRoute]);\n\n // 1. Lookup via AreSignalsContext (per root-id conditions)\n let renderTarget = signalsContext?.findComponentByVector(rootId, initialVector);\n\n // 2. Fall back to global AreSignalsMeta, pool-filtered.\n // IMPORTANT: pass the pool *into* the lookup so it can skip over\n // out-of-pool matches (e.g. a meta-outlet component whose condition\n // also matches the same vector) and find the highest-priority match\n // that this outlet can actually render. Filtering only after the\n // fact would mask valid in-pool matches and surface the outlet's\n // default instead.\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n const pool = signalsContext?.getComponentById(rootId);\n const metaTarget = signalsMeta?.findComponentByVector(\n initialVector,\n pool?.length ? pool : undefined,\n );\n if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {\n renderTarget = metaTarget;\n }\n }\n\n if (renderTarget?.name) {\n componentName = A_FormatterHelper.toKebabCase(renderTarget.name);\n }\n }\n\n // 3. Fall back to body content (the nodes already placed inside the\n // <are-root> tag act as the default). No setContent() call needed —\n // the tokenizer will process root.content as-is.\n if (!componentName) {\n if (root.content?.trim()) {\n return;\n }\n }\n // 3.5. Fall back to AreSignalsContext default component for this root.\n if (!componentName) {\n const defaultComp = signalsContext?.getDefault(rootId);\n if (defaultComp?.name) {\n componentName = A_FormatterHelper.toKebabCase(defaultComp.name);\n }\n }\n // 4. Last resort: legacy default= attribute on the markup.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a \"default\" attribute.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n const rootId = root.id;\n\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // 1. Try root-specific lookup via AreSignalsContext (keyed by the are-root's id attribute)\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Fall back to global AreSignalsMeta lookup, restricted to this\n // outlet's pool. Passing the pool *into* the lookup is critical:\n // without it, the first globally matching component wins and may\n // belong to a different outlet (e.g. AisRequirementsPanel for the\n // meta-outlet matching AisEditorCursorScope) — the pool check then\n // rejects it and the outlet falls back to default, hiding a valid\n // in-pool match (e.g. AisDiagramTab matching AisSetPrimaryDisplay).\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n const pool = signalsContext?.getComponentById(rootId);\n const metaTarget = signalsMeta?.findComponentByVector(\n vector,\n pool?.length ? pool : undefined,\n );\n if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {\n renderTarget = metaTarget;\n }\n }\n\n const def = signalsContext?.getDefault(rootId);\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : def?.name\n ? A_FormatterHelper.toKebabCase(def.name)\n : undefined;\n\n // No matching condition for this signal vector and no default — clear the outlet.\n if (!componentName) {\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n signalsContext?.unsubscribe(child);\n child.unmount();\n child.destroy();\n root.removeChild(child);\n }\n root.setContent('');\n return;\n }\n\n // Guard: if the outlet already shows the same component, do nothing.\n // Prevents infinite remount loops when a non-routing signal carries a\n // stale routing signal in the accumulated A_SignalState vector.\n // node.type is the kebab-case tag name — the most direct and reliable\n // identifier (no constructor-name resolution, no proxy wrapping issues).\n const currentChild = root.children[0] as AreNode | undefined;\n if (currentChild?.type === componentName) {\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n // Unsubscribe old children BEFORE destroying them.\n // Without this, AreSignals.handleSignalVector keeps iterating stale\n // (scope-less) nodes on every subsequent signal and throws an error.\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n signalsContext?.unsubscribe(child);\n child.unmount();\n child.destroy();\n root.removeChild(child);\n }\n\n\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n child.mount();\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":["AreRoot","Are","A_FormatterHelper","A_Context","AreSignals","AreRoute","A_SignalVector","A_Caller","A_Logger","AreSignalsContext","A_SignalState","AreRootCache","A_Frame"],"mappings":";;;;;;;;;;;;;;;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,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYZ,eAAA,CAAA","file":"AreRoot.component.js","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, A_TYPES__Ctor } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Signal, A_SignalState, A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext } from \"@adaas/are\";\nimport { AreRoute } from \"@adaas/are-html/signals/AreRoute.signal\";\nimport { AreRootCache, AreRootCacheEntry } from \"./AreRootCache.context\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'The AreRoot component serves as the foundational entry point for the A-Concept Rendering Engine (ARE). It is responsible for initializing the rendering process, managing the root node of the component tree, and handling signal-based rendering logic. The AreRoot component processes incoming signals to determine which child components to render, allowing for dynamic and responsive UI updates based on application state and user interactions.'\n})\nexport class AreRoot extends Are {\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_SignalState) signalState?: A_SignalState,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — but still honour body content or\n // a 'default' attribute if one is present on the markup.\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n if (!root.content?.trim()) {\n // Fallback: legacy default= attribute\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n const defaultComponent = defaultMatch?.[1];\n if (defaultComponent) {\n root.setContent(`<${defaultComponent}></${defaultComponent}>`);\n }\n }\n // Body content (or none) — tokenizer picks it up without intervention\n return;\n }\n\n // Select from the ACCUMULATED signal state (every signal dispatched so\n // far), not just the current URL route. Outlets keyed on domain signals\n // (e.g. a primary-display selector) must reflect the live vector the\n // moment they mount — even when they mount AFTER the routing signal was\n // dispatched (a nested outlet inside a just-rendered parent). Using the\n // same vector + lookup as onSignal keeps initial render and subsequent\n // updates consistent.\n const initialVector = this.buildInitialVector(signalState);\n const renderTarget = this.matchComponent(rootId, initialVector, signalsContext);\n\n let componentName: string | undefined = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : undefined;\n\n // 3. Fall back to body content (the nodes already placed inside the\n // <are-root> tag act as the default). No setContent() call needed —\n // the tokenizer will process root.content as-is.\n if (!componentName) {\n if (root.content?.trim()) {\n return;\n }\n }\n // 3.5. Fall back to AreSignalsContext default component for this root.\n if (!componentName) {\n const defaultComp = signalsContext?.getDefault(rootId);\n if (defaultComp?.name) {\n componentName = A_FormatterHelper.toKebabCase(defaultComp.name);\n }\n }\n // 4. Last resort: legacy default= attribute on the markup.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a \"default\" attribute.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(AreRootCache) cache?: AreRootCache,\n ) {\n const rootId = root.id;\n\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // Resolve the target component for the incoming vector using the SAME\n // lookup the initial template render uses (root-id conditions first,\n // then the global pool-filtered meta map).\n const renderTarget = this.matchComponent(rootId, vector, signalsContext);\n\n const def = signalsContext?.getDefault(rootId);\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : def?.name\n ? A_FormatterHelper.toKebabCase(def.name)\n : undefined;\n\n // No matching condition for this signal vector and no default — clear the outlet.\n if (!componentName) {\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n root.setContent('');\n return;\n }\n\n // Guard: if the outlet already shows the same component, do nothing.\n // Prevents infinite remount loops when a non-routing signal carries a\n // stale routing signal in the accumulated A_SignalState vector.\n // node.type is the kebab-case tag name — the most direct and reliable\n // identifier (no constructor-name resolution, no proxy wrapping issues).\n const currentChild = root.children[0] as AreNode | undefined;\n if (currentChild?.type === componentName) {\n return;\n }\n\n // Stash the currently displayed children so routing back to them can be\n // re-injected instantly from the cache (they are unmounted + detached but\n // NOT destroyed). Falls back to full teardown when no cache is available.\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n // Fast path: a previously rendered subtree for this component is cached —\n // re-attach it and re-mount from the preserved scene plan, skipping the\n // expensive tokenize/init/load/transform/compile pipeline.\n const cached = cache?.take(root.id, componentName);\n if (cached) {\n this.restoreChild(root, cached, signalsContext);\n return;\n }\n\n // Slow path: build the component subtree from scratch.\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n // The HTML engine time-slices large initial mounts; await so a heavy\n // routed component renders in yielding chunks instead of freezing the\n // main thread on first entry. Small subtrees resolve synchronously.\n await child.mount();\n }\n }\n\n /**\n * Resolves the component a vector should render for the given root, mirroring\n * the priority used everywhere in the routing system:\n * 1. Root-specific conditions registered on AreSignalsContext.\n * 2. The global AreSignalsMeta map, restricted to this outlet's pool.\n *\n * Passing the pool *into* the meta lookup is critical: without it, the first\n * globally matching component wins and may belong to a different outlet\n * (e.g. AisRequirementsPanel for the meta-outlet matching\n * AisEditorCursorScope) — the pool check would then reject it and the outlet\n * would fall back to its default, hiding a valid in-pool match (e.g.\n * AisDiagramTab matching AisSetPrimaryDisplay).\n *\n * Returns `undefined` when nothing matches — callers decide whether to use a\n * configured default, body content, or clear the outlet.\n */\n protected matchComponent(\n rootId: string,\n vector: A_SignalVector | undefined,\n signalsContext?: AreSignalsContext,\n ): A_TYPES__Ctor<Are> | undefined {\n if (!vector) return undefined;\n\n // 1. Root-specific conditions.\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Global pool-filtered meta map.\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n const pool = signalsContext?.getComponentById(rootId);\n const metaTarget = signalsMeta?.findComponentByVector(\n vector,\n pool?.length ? pool : undefined,\n rootId,\n );\n if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {\n renderTarget = metaTarget;\n }\n }\n\n return renderTarget as A_TYPES__Ctor<Are> | undefined;\n }\n\n /**\n * Builds the vector used for the INITIAL render. It is seeded from the\n * accumulated signal state (every signal dispatched on the bus so far) so a\n * freshly-mounted outlet reflects the live application state immediately,\n * not just on the next signal tick. The current URL route is appended when\n * no AreRoute is already present in the state, so route-driven outlets still\n * resolve on the very first paint (before AreRouteWatcher has dispatched).\n */\n protected buildInitialVector(signalState?: A_SignalState): A_SignalVector {\n const signals: A_Signal[] = [];\n\n if (signalState) {\n for (const signal of signalState.toVector()) {\n if (signal) signals.push(signal);\n }\n }\n\n if (!signals.some(signal => signal instanceof AreRoute)) {\n try {\n const currentRoute = AreRoute.default();\n if (currentRoute) signals.push(currentRoute);\n } catch {\n // Non-browser environment (no document) — route is simply absent.\n }\n }\n\n return new A_SignalVector(signals);\n }\n\n /**\n * Detach a displayed child subtree from the outlet and stash it in the cache\n * for fast re-injection later. The subtree is unmounted (its scene plan is\n * preserved) and deregistered from the root scope, but NOT destroyed. The\n * nodes that were subscribed to the signal bus are unsubscribed while cached\n * so the detached DOM never reacts to signals, and recorded so they can be\n * re-subscribed verbatim on restore.\n *\n * When no cache is available, or the LRU evicts an entry, the affected\n * subtree is fully destroyed.\n */\n protected stashChild(\n root: AreNode,\n child: AreNode,\n signalsContext: AreSignalsContext | undefined,\n cache: AreRootCache | undefined,\n ): void {\n const tag = child.type;\n\n child.unmount();\n\n // Collect exactly the nodes that are currently subscribed within this\n // subtree, then unsubscribe them. Without this, AreSignals keeps\n // delivering vectors to a detached subtree that would update reverted\n // DOM (unmount does not deactivate the scene).\n const subscribers = signalsContext\n ? this.collectSubscribers(child, signalsContext)\n : [];\n for (const node of subscribers) {\n signalsContext?.unsubscribe(node);\n }\n\n // Deregister from the root scope (the \"deregister node from parent\").\n root.removeChild(child);\n\n if (!cache) {\n void child.destroy();\n return;\n }\n\n const evicted = cache.put(root.id, tag, { node: child, subscribers });\n for (const entry of evicted) {\n // Evicted entries are already unmounted + unsubscribed + detached.\n void entry.node.destroy();\n }\n }\n\n /**\n * Re-attach a cached subtree to the outlet and re-mount it from its preserved\n * scene plan, re-subscribing exactly the nodes that were subscribed before it\n * was cached.\n */\n protected restoreChild(\n root: AreNode,\n entry: AreRootCacheEntry,\n signalsContext: AreSignalsContext | undefined,\n ): void {\n const child = entry.node;\n\n root.addChild(child);\n\n for (const node of entry.subscribers) {\n signalsContext?.subscribe(node);\n }\n\n child.mount();\n }\n\n /**\n * Walk a subtree and collect the nodes currently registered as signal\n * subscribers. Mirrors the subscription performed at init time in\n * AreHTMLLifecycle (component nodes and root nodes) without depending on the\n * concrete node classes — it simply intersects the subtree with the live\n * subscriber registry.\n */\n protected collectSubscribers(\n node: AreNode,\n signalsContext: AreSignalsContext,\n ): AreNode[] {\n const result: AreNode[] = [];\n const queue: AreNode[] = [node];\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (signalsContext.subscribers.has(current)) {\n result.push(current);\n }\n queue.push(...current.children);\n }\n return result;\n }\n}\n"]}
@@ -1,13 +1,14 @@
1
1
  import { __decorateClass, __decorateParam } from '../../chunk-EQQGB2QZ.mjs';
2
- import { A_Inject, A_Caller, A_Context, A_FormatterHelper } from '@adaas/a-concept';
2
+ import { A_Inject, A_Caller, A_FormatterHelper, A_Context } from '@adaas/a-concept';
3
3
  import { A_Frame } from '@adaas/a-frame/core';
4
4
  import { A_Logger } from '@adaas/a-utils/a-logger';
5
- import { A_SignalVector } from '@adaas/a-utils/a-signal';
5
+ import { A_SignalState, A_SignalVector } from '@adaas/a-utils/a-signal';
6
6
  import { Are, AreSignalsContext, AreSignals } from '@adaas/are';
7
7
  import { AreRoute } from '@adaas/are-html/signals/AreRoute.signal';
8
+ import { AreRootCache } from './AreRootCache.context';
8
9
 
9
10
  let AreRoot = class extends Are {
10
- async template(root, logger, signalsContext) {
11
+ async template(root, logger, signalsContext, signalState) {
11
12
  const rootId = root.id;
12
13
  if (signalsContext && !signalsContext.hasRoot(rootId)) {
13
14
  if (!root.content?.trim()) {
@@ -19,26 +20,9 @@ let AreRoot = class extends Are {
19
20
  }
20
21
  return;
21
22
  }
22
- const currentRoute = AreRoute.default();
23
- let componentName;
24
- if (currentRoute) {
25
- const initialVector = new A_SignalVector([currentRoute]);
26
- let renderTarget = signalsContext?.findComponentByVector(rootId, initialVector);
27
- if (!renderTarget) {
28
- const signalsMeta = A_Context.meta(AreSignals);
29
- const pool = signalsContext?.getComponentById(rootId);
30
- const metaTarget = signalsMeta?.findComponentByVector(
31
- initialVector,
32
- pool?.length ? pool : void 0
33
- );
34
- if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {
35
- renderTarget = metaTarget;
36
- }
37
- }
38
- if (renderTarget?.name) {
39
- componentName = A_FormatterHelper.toKebabCase(renderTarget.name);
40
- }
41
- }
23
+ const initialVector = this.buildInitialVector(signalState);
24
+ const renderTarget = this.matchComponent(rootId, initialVector, signalsContext);
25
+ let componentName = renderTarget?.name ? A_FormatterHelper.toKebabCase(renderTarget.name) : void 0;
42
26
  if (!componentName) {
43
27
  if (root.content?.trim()) {
44
28
  return;
@@ -60,32 +44,17 @@ let AreRoot = class extends Are {
60
44
  }
61
45
  root.setContent(`<${componentName}></${componentName}>`);
62
46
  }
63
- async onSignal(root, vector, logger, signalsContext) {
47
+ async onSignal(root, vector, logger, signalsContext, cache) {
64
48
  const rootId = root.id;
65
49
  if (signalsContext && !signalsContext.hasRoot(rootId)) {
66
50
  return;
67
51
  }
68
- let renderTarget = signalsContext?.findComponentByVector(rootId, vector);
69
- if (!renderTarget) {
70
- const signalsMeta = A_Context.meta(AreSignals);
71
- const pool = signalsContext?.getComponentById(rootId);
72
- const metaTarget = signalsMeta?.findComponentByVector(
73
- vector,
74
- pool?.length ? pool : void 0
75
- );
76
- if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {
77
- renderTarget = metaTarget;
78
- }
79
- }
52
+ const renderTarget = this.matchComponent(rootId, vector, signalsContext);
80
53
  const def = signalsContext?.getDefault(rootId);
81
54
  const componentName = renderTarget?.name ? A_FormatterHelper.toKebabCase(renderTarget.name) : def?.name ? A_FormatterHelper.toKebabCase(def.name) : void 0;
82
55
  if (!componentName) {
83
- for (let i = 0; i < root.children.length; i++) {
84
- const child = root.children[i];
85
- signalsContext?.unsubscribe(child);
86
- child.unmount();
87
- child.destroy();
88
- root.removeChild(child);
56
+ for (const child of [...root.children]) {
57
+ this.stashChild(root, child, signalsContext, cache);
89
58
  }
90
59
  root.setContent("");
91
60
  return;
@@ -94,13 +63,14 @@ let AreRoot = class extends Are {
94
63
  if (currentChild?.type === componentName) {
95
64
  return;
96
65
  }
66
+ for (const child of [...root.children]) {
67
+ this.stashChild(root, child, signalsContext, cache);
68
+ }
97
69
  root.setContent(`<${componentName}></${componentName}>`);
98
- for (let i = 0; i < root.children.length; i++) {
99
- const child = root.children[i];
100
- signalsContext?.unsubscribe(child);
101
- child.unmount();
102
- child.destroy();
103
- root.removeChild(child);
70
+ const cached = cache?.take(root.id, componentName);
71
+ if (cached) {
72
+ this.restoreChild(root, cached, signalsContext);
73
+ return;
104
74
  }
105
75
  root.tokenize();
106
76
  for (let i = 0; i < root.children.length; i++) {
@@ -112,22 +82,141 @@ let AreRoot = class extends Are {
112
82
  }
113
83
  child.transform();
114
84
  child.compile();
115
- child.mount();
85
+ await child.mount();
86
+ }
87
+ }
88
+ /**
89
+ * Resolves the component a vector should render for the given root, mirroring
90
+ * the priority used everywhere in the routing system:
91
+ * 1. Root-specific conditions registered on AreSignalsContext.
92
+ * 2. The global AreSignalsMeta map, restricted to this outlet's pool.
93
+ *
94
+ * Passing the pool *into* the meta lookup is critical: without it, the first
95
+ * globally matching component wins and may belong to a different outlet
96
+ * (e.g. AisRequirementsPanel for the meta-outlet matching
97
+ * AisEditorCursorScope) — the pool check would then reject it and the outlet
98
+ * would fall back to its default, hiding a valid in-pool match (e.g.
99
+ * AisDiagramTab matching AisSetPrimaryDisplay).
100
+ *
101
+ * Returns `undefined` when nothing matches — callers decide whether to use a
102
+ * configured default, body content, or clear the outlet.
103
+ */
104
+ matchComponent(rootId, vector, signalsContext) {
105
+ if (!vector) return void 0;
106
+ let renderTarget = signalsContext?.findComponentByVector(rootId, vector);
107
+ if (!renderTarget) {
108
+ const signalsMeta = A_Context.meta(AreSignals);
109
+ const pool = signalsContext?.getComponentById(rootId);
110
+ const metaTarget = signalsMeta?.findComponentByVector(
111
+ vector,
112
+ pool?.length ? pool : void 0,
113
+ rootId
114
+ );
115
+ if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {
116
+ renderTarget = metaTarget;
117
+ }
118
+ }
119
+ return renderTarget;
120
+ }
121
+ /**
122
+ * Builds the vector used for the INITIAL render. It is seeded from the
123
+ * accumulated signal state (every signal dispatched on the bus so far) so a
124
+ * freshly-mounted outlet reflects the live application state immediately,
125
+ * not just on the next signal tick. The current URL route is appended when
126
+ * no AreRoute is already present in the state, so route-driven outlets still
127
+ * resolve on the very first paint (before AreRouteWatcher has dispatched).
128
+ */
129
+ buildInitialVector(signalState) {
130
+ const signals = [];
131
+ if (signalState) {
132
+ for (const signal of signalState.toVector()) {
133
+ if (signal) signals.push(signal);
134
+ }
135
+ }
136
+ if (!signals.some((signal) => signal instanceof AreRoute)) {
137
+ try {
138
+ const currentRoute = AreRoute.default();
139
+ if (currentRoute) signals.push(currentRoute);
140
+ } catch {
141
+ }
142
+ }
143
+ return new A_SignalVector(signals);
144
+ }
145
+ /**
146
+ * Detach a displayed child subtree from the outlet and stash it in the cache
147
+ * for fast re-injection later. The subtree is unmounted (its scene plan is
148
+ * preserved) and deregistered from the root scope, but NOT destroyed. The
149
+ * nodes that were subscribed to the signal bus are unsubscribed while cached
150
+ * so the detached DOM never reacts to signals, and recorded so they can be
151
+ * re-subscribed verbatim on restore.
152
+ *
153
+ * When no cache is available, or the LRU evicts an entry, the affected
154
+ * subtree is fully destroyed.
155
+ */
156
+ stashChild(root, child, signalsContext, cache) {
157
+ const tag = child.type;
158
+ child.unmount();
159
+ const subscribers = signalsContext ? this.collectSubscribers(child, signalsContext) : [];
160
+ for (const node of subscribers) {
161
+ signalsContext?.unsubscribe(node);
162
+ }
163
+ root.removeChild(child);
164
+ if (!cache) {
165
+ void child.destroy();
166
+ return;
167
+ }
168
+ const evicted = cache.put(root.id, tag, { node: child, subscribers });
169
+ for (const entry of evicted) {
170
+ void entry.node.destroy();
171
+ }
172
+ }
173
+ /**
174
+ * Re-attach a cached subtree to the outlet and re-mount it from its preserved
175
+ * scene plan, re-subscribing exactly the nodes that were subscribed before it
176
+ * was cached.
177
+ */
178
+ restoreChild(root, entry, signalsContext) {
179
+ const child = entry.node;
180
+ root.addChild(child);
181
+ for (const node of entry.subscribers) {
182
+ signalsContext?.subscribe(node);
183
+ }
184
+ child.mount();
185
+ }
186
+ /**
187
+ * Walk a subtree and collect the nodes currently registered as signal
188
+ * subscribers. Mirrors the subscription performed at init time in
189
+ * AreHTMLLifecycle (component nodes and root nodes) without depending on the
190
+ * concrete node classes — it simply intersects the subtree with the live
191
+ * subscriber registry.
192
+ */
193
+ collectSubscribers(node, signalsContext) {
194
+ const result = [];
195
+ const queue = [node];
196
+ while (queue.length > 0) {
197
+ const current = queue.shift();
198
+ if (signalsContext.subscribers.has(current)) {
199
+ result.push(current);
200
+ }
201
+ queue.push(...current.children);
116
202
  }
203
+ return result;
117
204
  }
118
205
  };
119
206
  __decorateClass([
120
207
  Are.Template,
121
208
  __decorateParam(0, A_Inject(A_Caller)),
122
209
  __decorateParam(1, A_Inject(A_Logger)),
123
- __decorateParam(2, A_Inject(AreSignalsContext))
210
+ __decorateParam(2, A_Inject(AreSignalsContext)),
211
+ __decorateParam(3, A_Inject(A_SignalState))
124
212
  ], AreRoot.prototype, "template", 1);
125
213
  __decorateClass([
126
214
  Are.Signal,
127
215
  __decorateParam(0, A_Inject(A_Caller)),
128
216
  __decorateParam(1, A_Inject(A_SignalVector)),
129
217
  __decorateParam(2, A_Inject(A_Logger)),
130
- __decorateParam(3, A_Inject(AreSignalsContext))
218
+ __decorateParam(3, A_Inject(AreSignalsContext)),
219
+ __decorateParam(4, A_Inject(AreRootCache))
131
220
  ], AreRoot.prototype, "onSignal", 1);
132
221
  AreRoot = __decorateClass([
133
222
  A_Frame.Define({