@adaas/are-html 0.0.21 → 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 (55) 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 +45 -2
  5. package/dist/browser/index.mjs +170 -10
  6. package/dist/browser/index.mjs.map +1 -1
  7. package/dist/node/directives/AreDirectiveFor.directive.d.mts +37 -1
  8. package/dist/node/directives/AreDirectiveFor.directive.d.ts +37 -1
  9. package/dist/node/directives/AreDirectiveFor.directive.js +85 -4
  10. package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
  11. package/dist/node/directives/AreDirectiveFor.directive.mjs +85 -4
  12. package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
  13. package/dist/node/engine/AreHTML.lifecycle.d.mts +8 -1
  14. package/dist/node/engine/AreHTML.lifecycle.d.ts +8 -1
  15. package/dist/node/engine/AreHTML.lifecycle.js +46 -3
  16. package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
  17. package/dist/node/engine/AreHTML.lifecycle.mjs +46 -3
  18. package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
  19. package/dist/node/helpers/AreScheduler.helper.d.mts +39 -0
  20. package/dist/node/helpers/AreScheduler.helper.d.ts +39 -0
  21. package/dist/node/helpers/AreScheduler.helper.js +40 -0
  22. package/dist/node/helpers/AreScheduler.helper.js.map +1 -0
  23. package/dist/node/helpers/AreScheduler.helper.mjs +40 -0
  24. package/dist/node/helpers/AreScheduler.helper.mjs.map +1 -0
  25. package/dist/node/lib/AreRoot/AreRoot.component.js +1 -1
  26. package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
  27. package/dist/node/lib/AreRoot/AreRoot.component.mjs +1 -1
  28. package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
  29. package/examples/dashboard/dist/index.html +1 -1
  30. package/examples/dashboard/dist/{mq19zxz4-mnlgmd.js → mqh9ryml-xat335.js} +1922 -1316
  31. package/examples/dashboard/src/concept.ts +3 -2
  32. package/examples/for-perf/concept.ts +45 -0
  33. package/examples/for-perf/containers/UI.container.ts +161 -0
  34. package/examples/for-perf/dist/index.html +270 -0
  35. package/examples/for-perf/dist/mqh9ryde-m243t8.js +15223 -0
  36. package/examples/for-perf/dist/mqh9ryfo-6a8d0o.js +15223 -0
  37. package/examples/for-perf/dist/mqh9ryfq-4pf5cv.js +15223 -0
  38. package/examples/for-perf/public/index.html +270 -0
  39. package/examples/for-perf/src/components/PerfApp.component.ts +37 -0
  40. package/examples/for-perf/src/components/PerfControls.component.ts +34 -0
  41. package/examples/for-perf/src/components/PerfGrid.component.ts +225 -0
  42. package/examples/for-perf/src/components/PerfHeader.component.ts +34 -0
  43. package/examples/for-perf/src/components/PerfStats.component.ts +43 -0
  44. package/examples/for-perf/src/concept.ts +94 -0
  45. package/examples/jumpstart/dist/index.html +1 -1
  46. package/examples/jumpstart/dist/{mq7hqrxy-4kus50.js → mq7mgf58-vbf07e.js} +269 -91
  47. package/examples/signal-routing/dist/index.html +1 -1
  48. package/examples/signal-routing/dist/{mq7k53th-qiwy4x.js → mqh9ryc9-dkcbkx.js} +1726 -1419
  49. package/jest.config.ts +1 -0
  50. package/package.json +10 -9
  51. package/src/directives/AreDirectiveFor.directive.ts +141 -10
  52. package/src/engine/AreHTML.lifecycle.ts +83 -6
  53. package/src/helpers/AreScheduler.helper.ts +61 -0
  54. package/src/lib/AreRoot/AreRoot.component.ts +4 -1
  55. package/tsconfig.json +1 -0
@@ -0,0 +1,40 @@
1
+ import '../chunk-EQQGB2QZ.mjs';
2
+
3
+ class AreSchedulerHelper {
4
+ /**
5
+ * High-resolution wall-clock time in milliseconds. Uses `performance.now()`
6
+ * when available (monotonic, sub-millisecond), falling back to `Date.now()`.
7
+ */
8
+ static now() {
9
+ return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
10
+ }
11
+ /**
12
+ * Schedule `fn` to run on the next macrotask.
13
+ *
14
+ * `MessageChannel` yields a true macrotask without the ~4ms clamp that nested
15
+ * `setTimeout(0)` calls incur, so the browser can paint between chunks with
16
+ * minimal scheduling overhead. Falls back to `setTimeout` in non-DOM
17
+ * environments (e.g. tests / SSR).
18
+ */
19
+ static scheduleMacrotask(fn) {
20
+ if (typeof MessageChannel === "undefined") {
21
+ setTimeout(fn, 0);
22
+ return;
23
+ }
24
+ if (!this._channel) {
25
+ this._channel = new MessageChannel();
26
+ this._channel.port1.onmessage = () => {
27
+ const next = this._queue.shift();
28
+ if (next) next();
29
+ };
30
+ }
31
+ this._queue.push(fn);
32
+ this._channel.port2.postMessage(null);
33
+ }
34
+ }
35
+ /** FIFO queue of callbacks waiting for their posted macrotask to fire. */
36
+ AreSchedulerHelper._queue = [];
37
+
38
+ export { AreSchedulerHelper };
39
+ //# sourceMappingURL=AreScheduler.helper.mjs.map
40
+ //# sourceMappingURL=AreScheduler.helper.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/AreScheduler.helper.ts"],"names":[],"mappings":";;AAaO,MAAM,kBAAA,CAAmB;AAAA;AAAA;AAAA;AAAA;AAAA,EAgB5B,OAAO,GAAA,GAAc;AACjB,IAAA,OAAQ,OAAO,WAAA,KAAgB,WAAA,IAAe,OAAO,WAAA,CAAY,GAAA,KAAQ,UAAA,GACnE,WAAA,CAAY,GAAA,EAAI,GAChB,IAAA,CAAK,GAAA,EAAI;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,OAAO,kBAAkB,EAAA,EAAsB;AAC3C,IAAA,IAAI,OAAO,mBAAmB,WAAA,EAAa;AACvC,MAAA,UAAA,CAAW,IAAI,CAAC,CAAA;AAChB,MAAA;AAAA,IACJ;AAEA,IAAA,IAAI,CAAC,KAAK,QAAA,EAAU;AAChB,MAAA,IAAA,CAAK,QAAA,GAAW,IAAI,cAAA,EAAe;AACnC,MAAA,IAAA,CAAK,QAAA,CAAS,KAAA,CAAM,SAAA,GAAY,MAAM;AAClC,QAAA,MAAM,IAAA,GAAO,IAAA,CAAK,MAAA,CAAO,KAAA,EAAM;AAC/B,QAAA,IAAI,MAAM,IAAA,EAAK;AAAA,MACnB,CAAA;AAAA,IACJ;AAEA,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,EAAE,CAAA;AACnB,IAAA,IAAA,CAAK,QAAA,CAAS,KAAA,CAAM,WAAA,CAAY,IAAI,CAAA;AAAA,EACxC;AACJ;AAAA;AA/Ca,kBAAA,CAUe,SAA4B,EAAC","file":"AreScheduler.helper.mjs","sourcesContent":["/**\n * AreSchedulerHelper\n *\n * Cooperative time-slicing primitives shared by the chunked (async) render\n * paths — the initial whole-page mount walk and the `$for` directive. Both need\n * the SAME two capabilities:\n * 1. a high-resolution clock to measure how long the current chunk has run, and\n * 2. a zero-delay macrotask scheduler to yield to the browser between chunks\n * so it can paint and process input before resuming work.\n *\n * Keeping these in one helper avoids duplicating the `MessageChannel` plumbing\n * across directives/lifecycle and gives a single place to tune the strategy.\n */\nexport class AreSchedulerHelper {\n\n /**\n * Lazily-created `MessageChannel` used to post zero-delay macrotasks.\n * Created on first use so non-DOM environments (tests / SSR) that never\n * schedule a chunk pay nothing.\n */\n private static _channel?: MessageChannel;\n\n /** FIFO queue of callbacks waiting for their posted macrotask to fire. */\n private static readonly _queue: Array<() => void> = [];\n\n /**\n * High-resolution wall-clock time in milliseconds. Uses `performance.now()`\n * when available (monotonic, sub-millisecond), falling back to `Date.now()`.\n */\n static now(): number {\n return (typeof performance !== 'undefined' && typeof performance.now === 'function')\n ? performance.now()\n : Date.now();\n }\n\n /**\n * Schedule `fn` to run on the next macrotask.\n *\n * `MessageChannel` yields a true macrotask without the ~4ms clamp that nested\n * `setTimeout(0)` calls incur, so the browser can paint between chunks with\n * minimal scheduling overhead. Falls back to `setTimeout` in non-DOM\n * environments (e.g. tests / SSR).\n */\n static scheduleMacrotask(fn: () => void): void {\n if (typeof MessageChannel === 'undefined') {\n setTimeout(fn, 0);\n return;\n }\n\n if (!this._channel) {\n this._channel = new MessageChannel();\n this._channel.port1.onmessage = () => {\n const next = this._queue.shift();\n if (next) next();\n };\n }\n\n this._queue.push(fn);\n this._channel.port2.postMessage(null);\n }\n}\n"]}
@@ -94,7 +94,7 @@ exports.AreRoot = class AreRoot extends are.Are {
94
94
  }
95
95
  child.transform();
96
96
  child.compile();
97
- child.mount();
97
+ await child.mount();
98
98
  }
99
99
  }
100
100
  /**
@@ -1 +1 @@
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":";;;;;;;;;;;;;;;;;;;;;AAaaA,eAAA,GAAN,sBAAsBC,OAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,gBACJ,WAAA,EAC3B;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;AASA,IAAA,MAAM,aAAA,GAAgB,I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CAASC,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA,CAAA;AAAA,EAC1B,qCAASC,qBAAa,CAAA;AAAA,CAAA,EAPlBV,eAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAqEA,eAAA,CAAA;AAAA,EADLC,OAAA,CAAI,MAAA;AAAA,EAEA,qCAASM,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASD,sBAAc,CAAA,CAAA;AAAA,EACvB,qCAASE,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA,CAAA;AAAA,EAC1B,qCAASE,iCAAY,CAAA;AAAA,CAAA,EA7EjBX,eAAA,CAwEH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAxEGA,eAAA,GAAN,eAAA,CAAA;AAAA,EAJNY,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,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 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
+ {"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":";;;;;;;;;;;;;;;;;;;;;AAaaA,eAAA,GAAN,sBAAsBC,OAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,gBACJ,WAAA,EAC3B;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;AASA,IAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACzD,IAAA,MAAM,YAAA,GAAe,IAAA,CAAK,cAA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ASC,qBAAa,CAAA;AAAA,CAAA,EAPlBV,eAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAqEA,eAAA,CAAA;AAAA,EADLC,OAAA,CAAI,MAAA;AAAA,EAEA,qCAASM,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASD,sBAAc,CAAA,CAAA;AAAA,EACvB,qCAASE,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA,CAAA;AAAA,EAC1B,qCAASE,iCAAY,CAAA;AAAA,CAAA,EA7EjBX,eAAA,CAwEH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAxEGA,eAAA,GAAN,eAAA,CAAA;AAAA,EAJNY,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,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"]}
@@ -82,7 +82,7 @@ let AreRoot = class extends Are {
82
82
  }
83
83
  child.transform();
84
84
  child.compile();
85
- child.mount();
85
+ await child.mount();
86
86
  }
87
87
  }
88
88
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":[],"mappings":";;;;;;;;;AAaO,IAAM,OAAA,GAAN,cAAsB,GAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,gBACJ,WAAA,EAC3B;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;AASA,IAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACzD,IAAA,MAAM,Y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1B,4BAAS,aAAa,CAAA;AAAA,CAAA,EAPlB,OAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAqEA,eAAA,CAAA;AAAA,EADL,GAAA,CAAI,MAAA;AAAA,EAEA,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,cAAc,CAAA,CAAA;AAAA,EACvB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA,CAAA;AAAA,EAC1B,4BAAS,YAAY,CAAA;AAAA,CAAA,EA7EjB,OAAA,CAwEH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAxEG,OAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,OAAA,CAAA","file":"AreRoot.component.mjs","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 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
+ {"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":[],"mappings":";;;;;;;;;AAaO,IAAM,OAAA,GAAN,cAAsB,GAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,gBACJ,WAAA,EAC3B;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;AASA,IAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACzD,IAAA,MAAM,YAAA,GAAe,IAAA,CAAK,cAAA,CAAe,MAAA,EAAQ,eAAe,cAAc,CAAA;AAE9E,IAAA,IAAI,gBAAoC,YAAA,EAAc,IAAA,GAChD,kBAAkB,WAAA,CAAY,YAAA,CAAa,IAAI,CAAA,GAC/C,MAAA;AAKN,IAAA,IAAI,CAAC,aAAA,EAAe;AAChB,MAAA,IAAI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AAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA,CAAA;AAAA,EAC1B,4BAAS,YAAY,CAAA;AAAA,CAAA,EA7EjB,OAAA,CAwEH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAxEG,OAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,OAAA,CAAA","file":"AreRoot.component.mjs","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"]}
@@ -16,7 +16,7 @@
16
16
  <dashboard-app></dashboard-app>
17
17
  </are-root>
18
18
 
19
- <script type="module" src="./mq19zxz4-mnlgmd.js"></script>
19
+ <script type="module" src="./mqh9ryml-xat335.js"></script>
20
20
  </body>
21
21
 
22
22
  </html>