@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.
- package/.conf/tsconfig.base.json +1 -0
- package/.conf/tsconfig.browser.json +1 -0
- package/.conf/tsconfig.node.json +1 -0
- package/dist/browser/index.d.mts +206 -7
- package/dist/browser/index.mjs +527 -65
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.d.mts +44 -1
- package/dist/node/directives/AreDirectiveFor.directive.d.ts +44 -1
- package/dist/node/directives/AreDirectiveFor.directive.js +102 -6
- package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.mjs +102 -6
- package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
- package/dist/node/directives/AreDirectiveShow.directive.d.mts +32 -0
- package/dist/node/directives/AreDirectiveShow.directive.d.ts +32 -0
- package/dist/node/directives/AreDirectiveShow.directive.js +81 -0
- package/dist/node/directives/AreDirectiveShow.directive.js.map +1 -0
- package/dist/node/directives/AreDirectiveShow.directive.mjs +71 -0
- package/dist/node/directives/AreDirectiveShow.directive.mjs.map +1 -0
- package/dist/node/engine/AreHTML.engine.d.mts +2 -1
- package/dist/node/engine/AreHTML.engine.d.ts +2 -1
- package/dist/node/engine/AreHTML.engine.js +8 -2
- package/dist/node/engine/AreHTML.engine.js.map +1 -1
- package/dist/node/engine/AreHTML.engine.mjs +8 -2
- package/dist/node/engine/AreHTML.engine.mjs.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.d.mts +3 -0
- package/dist/node/engine/AreHTML.interpreter.d.ts +3 -0
- package/dist/node/engine/AreHTML.interpreter.js +29 -0
- package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.mjs +29 -0
- package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.d.mts +8 -1
- package/dist/node/engine/AreHTML.lifecycle.d.ts +8 -1
- package/dist/node/engine/AreHTML.lifecycle.js +46 -3
- package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.mjs +46 -3
- package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
- package/dist/node/helpers/AreScheduler.helper.d.mts +39 -0
- package/dist/node/helpers/AreScheduler.helper.d.ts +39 -0
- package/dist/node/helpers/AreScheduler.helper.js +40 -0
- package/dist/node/helpers/AreScheduler.helper.js.map +1 -0
- package/dist/node/helpers/AreScheduler.helper.mjs +40 -0
- package/dist/node/helpers/AreScheduler.helper.mjs.map +1 -0
- package/dist/node/index.d.mts +4 -1
- package/dist/node/index.d.ts +4 -1
- package/dist/node/index.js +21 -0
- package/dist/node/index.mjs +3 -0
- package/dist/node/instructions/AreHTML.instructions.constants.d.mts +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.d.ts +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.js +2 -1
- package/dist/node/instructions/AreHTML.instructions.constants.js.map +1 -1
- package/dist/node/instructions/AreHTML.instructions.constants.mjs +2 -1
- package/dist/node/instructions/AreHTML.instructions.constants.mjs.map +1 -1
- package/dist/node/instructions/AreHTML.instructions.types.d.mts +9 -1
- package/dist/node/instructions/AreHTML.instructions.types.d.ts +9 -1
- package/dist/node/instructions/HideElement.instruction.d.mts +13 -0
- package/dist/node/instructions/HideElement.instruction.d.ts +13 -0
- package/dist/node/instructions/HideElement.instruction.js +31 -0
- package/dist/node/instructions/HideElement.instruction.js.map +1 -0
- package/dist/node/instructions/HideElement.instruction.mjs +24 -0
- package/dist/node/instructions/HideElement.instruction.mjs.map +1 -0
- package/dist/node/lib/AreRoot/AreRoot.component.d.mts +57 -3
- package/dist/node/lib/AreRoot/AreRoot.component.d.ts +57 -3
- package/dist/node/lib/AreRoot/AreRoot.component.js +138 -49
- package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.mjs +140 -51
- package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
- package/dist/node/lib/AreRoot/AreRootCache.context.d.mts +58 -0
- package/dist/node/lib/AreRoot/AreRootCache.context.d.ts +58 -0
- package/dist/node/lib/AreRoot/AreRootCache.context.js +106 -0
- package/dist/node/lib/AreRoot/AreRootCache.context.js.map +1 -0
- package/dist/node/lib/AreRoot/AreRootCache.context.mjs +99 -0
- package/dist/node/lib/AreRoot/AreRootCache.context.mjs.map +1 -0
- package/examples/dashboard/dist/index.html +1 -1
- package/examples/dashboard/dist/{mq19zxz4-mnlgmd.js → mqh9ryml-xat335.js} +1922 -1316
- package/examples/dashboard/src/concept.ts +3 -2
- package/examples/for-perf/concept.ts +45 -0
- package/examples/for-perf/containers/UI.container.ts +161 -0
- package/examples/for-perf/dist/index.html +270 -0
- package/examples/for-perf/dist/mqh9ryde-m243t8.js +15223 -0
- package/examples/for-perf/dist/mqh9ryfo-6a8d0o.js +15223 -0
- package/examples/for-perf/dist/mqh9ryfq-4pf5cv.js +15223 -0
- package/examples/for-perf/public/index.html +270 -0
- package/examples/for-perf/src/components/PerfApp.component.ts +37 -0
- package/examples/for-perf/src/components/PerfControls.component.ts +34 -0
- package/examples/for-perf/src/components/PerfGrid.component.ts +225 -0
- package/examples/for-perf/src/components/PerfHeader.component.ts +34 -0
- package/examples/for-perf/src/components/PerfStats.component.ts +43 -0
- package/examples/for-perf/src/concept.ts +94 -0
- package/examples/jumpstart/dist/index.html +1 -1
- package/examples/jumpstart/dist/{mq1a0fv0-ccgtz6.js → mq7mgf58-vbf07e.js} +895 -521
- package/examples/signal-routing/dist/index.html +1 -1
- package/examples/signal-routing/dist/{mq1bzrik-4lec86.js → mqh9ryc9-dkcbkx.js} +2024 -1300
- package/examples/signal-routing/src/components/SettingsPage.component.ts +39 -0
- package/examples/signal-routing/src/concept.ts +2 -0
- package/jest.config.ts +1 -0
- package/package.json +10 -9
- package/src/directives/AreDirectiveFor.directive.ts +185 -12
- package/src/directives/AreDirectiveShow.directive.ts +127 -0
- package/src/engine/AreHTML.engine.ts +11 -1
- package/src/engine/AreHTML.interpreter.ts +50 -0
- package/src/engine/AreHTML.lifecycle.ts +83 -6
- package/src/helpers/AreScheduler.helper.ts +61 -0
- package/src/index.ts +3 -0
- package/src/instructions/AreHTML.instructions.constants.ts +1 -0
- package/src/instructions/AreHTML.instructions.types.ts +9 -0
- package/src/instructions/HideElement.instruction.ts +29 -0
- package/src/lib/AreRoot/AreRoot.component.ts +205 -72
- package/src/lib/AreRoot/AreRootCache.context.ts +133 -0
- package/tsconfig.json +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":[],"mappings":";;;;;;;;AAYO,IAAM,OAAA,GAAN,cAAsB,GAAA,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,GAAe,SAAS,OAAA,EAAQ;AAEtC,IAAA,IAAI,aAAA;AAEJ,IAAA,IAAI,YAAA,EAAc;AACd,MAAA,MA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,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,EADL,GAAA,CAAI,QAAA;AAAA,EAEA,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA;AAAA,CAAA,EANtB,OAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAwFA,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;AAAA,CAAA,EA/FtB,OAAA,CA2FH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AA3FG,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, } 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":[],"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,IA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AA,GAAmB,CAAC,IAAI,CAAA;AAC9B,IAAA,OAAO,KAAA,CAAM,SAAS,CAAA,EAAG;AACrB,MAAA,MAAM,OAAA,GAAU,MAAM,KAAA,EAAM;AAC5B,MAAA,IAAI,cAAA,CAAe,WAAA,CAAY,GAAA,CAAI,OAAO,CAAA,EAAG;AACzC,QAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AAAA,MACvB;AACA,MAAA,KAAA,CAAM,IAAA,CAAK,GAAG,OAAA,CAAQ,QAAQ,CAAA;AAAA,IAClC;AACA,IAAA,OAAO,MAAA;AAAA,EACX;AACJ;AA3TU,eAAA,CAAA;AAAA,EADL,GAAA,CAAI,QAAA;AAAA,EAEA,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA,CAAA;AAAA,EAC1B,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 // 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"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { A_Fragment } from '@adaas/a-concept';
|
|
2
|
+
import { AreNode } from '@adaas/are';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A single cached, detached component subtree for an are-root outlet.
|
|
6
|
+
*
|
|
7
|
+
* `node` is fully compiled and its scene plan is intact (it was `unmount()`ed,
|
|
8
|
+
* not destroyed), so it can be re-mounted instantly without re-tokenizing,
|
|
9
|
+
* re-loading, transforming or compiling. `subscribers` records the exact set of
|
|
10
|
+
* nodes inside the subtree that were subscribed to the signal bus at the moment
|
|
11
|
+
* of stashing — they are unsubscribed while cached (so the detached DOM never
|
|
12
|
+
* reacts to signals) and re-subscribed verbatim on restore.
|
|
13
|
+
*/
|
|
14
|
+
type AreRootCacheEntry = {
|
|
15
|
+
node: AreNode;
|
|
16
|
+
subscribers: AreNode[];
|
|
17
|
+
};
|
|
18
|
+
declare class AreRootCache extends A_Fragment {
|
|
19
|
+
/**
|
|
20
|
+
* rootId -> (component tag -> cache entry). The inner Map preserves
|
|
21
|
+
* insertion order which is used as the LRU recency order: the first key is
|
|
22
|
+
* the least-recently-used entry, the last key the most-recently-used.
|
|
23
|
+
*/
|
|
24
|
+
protected _cache: Map<string, Map<string, AreRootCacheEntry>>;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum number of cached subtrees kept per root. Older entries beyond this
|
|
27
|
+
* limit are evicted (and returned to the caller so it can destroy them).
|
|
28
|
+
*/
|
|
29
|
+
protected _limit: number;
|
|
30
|
+
constructor(limit?: number);
|
|
31
|
+
/**
|
|
32
|
+
* Maximum number of cached subtrees kept per root.
|
|
33
|
+
*/
|
|
34
|
+
get limit(): number;
|
|
35
|
+
protected bucket(rootId: string): Map<string, AreRootCacheEntry>;
|
|
36
|
+
/**
|
|
37
|
+
* Whether a subtree for the given component tag is currently cached.
|
|
38
|
+
*/
|
|
39
|
+
has(rootId: string, tag: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieve AND remove a cached subtree so it can become live again. Returns
|
|
42
|
+
* `undefined` on a cache miss.
|
|
43
|
+
*/
|
|
44
|
+
take(rootId: string, tag: string): AreRootCacheEntry | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Stash a detached subtree under the given component tag. Returns any entries
|
|
47
|
+
* that were evicted to honour the LRU limit (or replaced for the same tag) so
|
|
48
|
+
* the caller can `destroy()` them.
|
|
49
|
+
*/
|
|
50
|
+
put(rootId: string, tag: string, entry: AreRootCacheEntry): AreRootCacheEntry[];
|
|
51
|
+
/**
|
|
52
|
+
* Remove and return every cached entry for a root (e.g. on teardown) so the
|
|
53
|
+
* caller can destroy them.
|
|
54
|
+
*/
|
|
55
|
+
clear(rootId: string): AreRootCacheEntry[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { AreRootCache, type AreRootCacheEntry };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { A_Fragment } from '@adaas/a-concept';
|
|
2
|
+
import { AreNode } from '@adaas/are';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A single cached, detached component subtree for an are-root outlet.
|
|
6
|
+
*
|
|
7
|
+
* `node` is fully compiled and its scene plan is intact (it was `unmount()`ed,
|
|
8
|
+
* not destroyed), so it can be re-mounted instantly without re-tokenizing,
|
|
9
|
+
* re-loading, transforming or compiling. `subscribers` records the exact set of
|
|
10
|
+
* nodes inside the subtree that were subscribed to the signal bus at the moment
|
|
11
|
+
* of stashing — they are unsubscribed while cached (so the detached DOM never
|
|
12
|
+
* reacts to signals) and re-subscribed verbatim on restore.
|
|
13
|
+
*/
|
|
14
|
+
type AreRootCacheEntry = {
|
|
15
|
+
node: AreNode;
|
|
16
|
+
subscribers: AreNode[];
|
|
17
|
+
};
|
|
18
|
+
declare class AreRootCache extends A_Fragment {
|
|
19
|
+
/**
|
|
20
|
+
* rootId -> (component tag -> cache entry). The inner Map preserves
|
|
21
|
+
* insertion order which is used as the LRU recency order: the first key is
|
|
22
|
+
* the least-recently-used entry, the last key the most-recently-used.
|
|
23
|
+
*/
|
|
24
|
+
protected _cache: Map<string, Map<string, AreRootCacheEntry>>;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum number of cached subtrees kept per root. Older entries beyond this
|
|
27
|
+
* limit are evicted (and returned to the caller so it can destroy them).
|
|
28
|
+
*/
|
|
29
|
+
protected _limit: number;
|
|
30
|
+
constructor(limit?: number);
|
|
31
|
+
/**
|
|
32
|
+
* Maximum number of cached subtrees kept per root.
|
|
33
|
+
*/
|
|
34
|
+
get limit(): number;
|
|
35
|
+
protected bucket(rootId: string): Map<string, AreRootCacheEntry>;
|
|
36
|
+
/**
|
|
37
|
+
* Whether a subtree for the given component tag is currently cached.
|
|
38
|
+
*/
|
|
39
|
+
has(rootId: string, tag: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieve AND remove a cached subtree so it can become live again. Returns
|
|
42
|
+
* `undefined` on a cache miss.
|
|
43
|
+
*/
|
|
44
|
+
take(rootId: string, tag: string): AreRootCacheEntry | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Stash a detached subtree under the given component tag. Returns any entries
|
|
47
|
+
* that were evicted to honour the LRU limit (or replaced for the same tag) so
|
|
48
|
+
* the caller can `destroy()` them.
|
|
49
|
+
*/
|
|
50
|
+
put(rootId: string, tag: string, entry: AreRootCacheEntry): AreRootCacheEntry[];
|
|
51
|
+
/**
|
|
52
|
+
* Remove and return every cached entry for a root (e.g. on teardown) so the
|
|
53
|
+
* caller can destroy them.
|
|
54
|
+
*/
|
|
55
|
+
clear(rootId: string): AreRootCacheEntry[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { AreRootCache, type AreRootCacheEntry };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var aConcept = require('@adaas/a-concept');
|
|
4
|
+
var core = require('@adaas/a-frame/core');
|
|
5
|
+
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
8
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
9
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10
|
+
if (decorator = decorators[i])
|
|
11
|
+
result = (decorator(result)) || result;
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
exports.AreRootCache = class AreRootCache extends aConcept.A_Fragment {
|
|
15
|
+
constructor(limit = 10) {
|
|
16
|
+
super({ name: "AreRootCache" });
|
|
17
|
+
/**
|
|
18
|
+
* rootId -> (component tag -> cache entry). The inner Map preserves
|
|
19
|
+
* insertion order which is used as the LRU recency order: the first key is
|
|
20
|
+
* the least-recently-used entry, the last key the most-recently-used.
|
|
21
|
+
*/
|
|
22
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
23
|
+
this._limit = Math.max(0, Math.floor(limit));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Maximum number of cached subtrees kept per root.
|
|
27
|
+
*/
|
|
28
|
+
get limit() {
|
|
29
|
+
return this._limit;
|
|
30
|
+
}
|
|
31
|
+
bucket(rootId) {
|
|
32
|
+
let bucket = this._cache.get(rootId);
|
|
33
|
+
if (!bucket) {
|
|
34
|
+
bucket = /* @__PURE__ */ new Map();
|
|
35
|
+
this._cache.set(rootId, bucket);
|
|
36
|
+
}
|
|
37
|
+
return bucket;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether a subtree for the given component tag is currently cached.
|
|
41
|
+
*/
|
|
42
|
+
has(rootId, tag) {
|
|
43
|
+
return this.bucket(rootId).has(tag);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve AND remove a cached subtree so it can become live again. Returns
|
|
47
|
+
* `undefined` on a cache miss.
|
|
48
|
+
*/
|
|
49
|
+
take(rootId, tag) {
|
|
50
|
+
const bucket = this.bucket(rootId);
|
|
51
|
+
const entry = bucket.get(tag);
|
|
52
|
+
if (entry) {
|
|
53
|
+
bucket.delete(tag);
|
|
54
|
+
}
|
|
55
|
+
return entry;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Stash a detached subtree under the given component tag. Returns any entries
|
|
59
|
+
* that were evicted to honour the LRU limit (or replaced for the same tag) so
|
|
60
|
+
* the caller can `destroy()` them.
|
|
61
|
+
*/
|
|
62
|
+
put(rootId, tag, entry) {
|
|
63
|
+
const bucket = this.bucket(rootId);
|
|
64
|
+
const evicted = [];
|
|
65
|
+
const existing = bucket.get(tag);
|
|
66
|
+
if (existing) {
|
|
67
|
+
bucket.delete(tag);
|
|
68
|
+
if (existing.node !== entry.node) {
|
|
69
|
+
evicted.push(existing);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
bucket.set(tag, entry);
|
|
73
|
+
while (bucket.size > this._limit) {
|
|
74
|
+
const oldestKey = bucket.keys().next().value;
|
|
75
|
+
if (oldestKey === void 0) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
const oldest = bucket.get(oldestKey);
|
|
79
|
+
bucket.delete(oldestKey);
|
|
80
|
+
evicted.push(oldest);
|
|
81
|
+
}
|
|
82
|
+
return evicted;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Remove and return every cached entry for a root (e.g. on teardown) so the
|
|
86
|
+
* caller can destroy them.
|
|
87
|
+
*/
|
|
88
|
+
clear(rootId) {
|
|
89
|
+
const bucket = this._cache.get(rootId);
|
|
90
|
+
if (!bucket) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const entries = [...bucket.values()];
|
|
94
|
+
bucket.clear();
|
|
95
|
+
this._cache.delete(rootId);
|
|
96
|
+
return entries;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.AreRootCache = __decorateClass([
|
|
100
|
+
core.A_Frame.Define({
|
|
101
|
+
namespace: "a-are-html",
|
|
102
|
+
description: "AreRootCache is a fragment that keeps a small per-root LRU of previously rendered are-root subtrees. When an are-root swaps the component it displays, the outgoing subtree is stashed here (unmounted + detached, but not destroyed) so that routing back to it can re-inject the preserved scene instantly instead of rebuilding from scratch."
|
|
103
|
+
})
|
|
104
|
+
], exports.AreRootCache);
|
|
105
|
+
//# sourceMappingURL=AreRootCache.context.js.map
|
|
106
|
+
//# sourceMappingURL=AreRootCache.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRootCache.context.ts"],"names":["AreRootCache","A_Fragment","A_Frame"],"mappings":";;;;;;;;;;;;;AAyBaA,oBAAA,GA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A,CAAO,OAAO,MAAM,CAAA;AACzB,IAAA,OAAO,OAAA;AAAA,EACX;AACJ;AA3GaD,oBAAA,GAAN,eAAA,CAAA;AAAA,EAJNE,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYF,oBAAA,CAAA","file":"AreRootCache.context.js","sourcesContent":["import { A_Fragment } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode } from \"@adaas/are\";\n\n\n/**\n * A single cached, detached component subtree for an are-root outlet.\n *\n * `node` is fully compiled and its scene plan is intact (it was `unmount()`ed,\n * not destroyed), so it can be re-mounted instantly without re-tokenizing,\n * re-loading, transforming or compiling. `subscribers` records the exact set of\n * nodes inside the subtree that were subscribed to the signal bus at the moment\n * of stashing — they are unsubscribed while cached (so the detached DOM never\n * reacts to signals) and re-subscribed verbatim on restore.\n */\nexport type AreRootCacheEntry = {\n node: AreNode;\n subscribers: AreNode[];\n};\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'AreRootCache is a fragment that keeps a small per-root LRU of previously rendered are-root subtrees. When an are-root swaps the component it displays, the outgoing subtree is stashed here (unmounted + detached, but not destroyed) so that routing back to it can re-inject the preserved scene instantly instead of rebuilding from scratch.'\n})\nexport class AreRootCache extends A_Fragment {\n\n /**\n * rootId -> (component tag -> cache entry). The inner Map preserves\n * insertion order which is used as the LRU recency order: the first key is\n * the least-recently-used entry, the last key the most-recently-used.\n */\n protected _cache: Map<string, Map<string, AreRootCacheEntry>> = new Map();\n\n /**\n * Maximum number of cached subtrees kept per root. Older entries beyond this\n * limit are evicted (and returned to the caller so it can destroy them).\n */\n protected _limit: number;\n\n constructor(limit: number = 10) {\n super({ name: 'AreRootCache' });\n this._limit = Math.max(0, Math.floor(limit));\n }\n\n /**\n * Maximum number of cached subtrees kept per root.\n */\n get limit(): number {\n return this._limit;\n }\n\n protected bucket(rootId: string): Map<string, AreRootCacheEntry> {\n let bucket = this._cache.get(rootId);\n if (!bucket) {\n bucket = new Map();\n this._cache.set(rootId, bucket);\n }\n return bucket;\n }\n\n /**\n * Whether a subtree for the given component tag is currently cached.\n */\n has(rootId: string, tag: string): boolean {\n return this.bucket(rootId).has(tag);\n }\n\n /**\n * Retrieve AND remove a cached subtree so it can become live again. Returns\n * `undefined` on a cache miss.\n */\n take(rootId: string, tag: string): AreRootCacheEntry | undefined {\n const bucket = this.bucket(rootId);\n const entry = bucket.get(tag);\n if (entry) {\n bucket.delete(tag);\n }\n return entry;\n }\n\n /**\n * Stash a detached subtree under the given component tag. Returns any entries\n * that were evicted to honour the LRU limit (or replaced for the same tag) so\n * the caller can `destroy()` them.\n */\n put(rootId: string, tag: string, entry: AreRootCacheEntry): AreRootCacheEntry[] {\n const bucket = this.bucket(rootId);\n const evicted: AreRootCacheEntry[] = [];\n\n // Replace any stale entry for the same tag (should not normally happen,\n // since a displayed tag is never simultaneously cached) and surface it\n // for destruction so it does not leak.\n const existing = bucket.get(tag);\n if (existing) {\n bucket.delete(tag);\n if (existing.node !== entry.node) {\n evicted.push(existing);\n }\n }\n\n // A limit of 0 disables caching: the freshly added entry is evicted\n // immediately so the caller tears it down.\n bucket.set(tag, entry);\n\n while (bucket.size > this._limit) {\n const oldestKey = bucket.keys().next().value as string | undefined;\n if (oldestKey === undefined) {\n break;\n }\n const oldest = bucket.get(oldestKey)!;\n bucket.delete(oldestKey);\n evicted.push(oldest);\n }\n\n return evicted;\n }\n\n /**\n * Remove and return every cached entry for a root (e.g. on teardown) so the\n * caller can destroy them.\n */\n clear(rootId: string): AreRootCacheEntry[] {\n const bucket = this._cache.get(rootId);\n if (!bucket) {\n return [];\n }\n const entries = [...bucket.values()];\n bucket.clear();\n this._cache.delete(rootId);\n return entries;\n }\n}\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { __decorateClass } from '../../chunk-EQQGB2QZ.mjs';
|
|
2
|
+
import { A_Fragment } from '@adaas/a-concept';
|
|
3
|
+
import { A_Frame } from '@adaas/a-frame/core';
|
|
4
|
+
|
|
5
|
+
let AreRootCache = class extends A_Fragment {
|
|
6
|
+
constructor(limit = 10) {
|
|
7
|
+
super({ name: "AreRootCache" });
|
|
8
|
+
/**
|
|
9
|
+
* rootId -> (component tag -> cache entry). The inner Map preserves
|
|
10
|
+
* insertion order which is used as the LRU recency order: the first key is
|
|
11
|
+
* the least-recently-used entry, the last key the most-recently-used.
|
|
12
|
+
*/
|
|
13
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
14
|
+
this._limit = Math.max(0, Math.floor(limit));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of cached subtrees kept per root.
|
|
18
|
+
*/
|
|
19
|
+
get limit() {
|
|
20
|
+
return this._limit;
|
|
21
|
+
}
|
|
22
|
+
bucket(rootId) {
|
|
23
|
+
let bucket = this._cache.get(rootId);
|
|
24
|
+
if (!bucket) {
|
|
25
|
+
bucket = /* @__PURE__ */ new Map();
|
|
26
|
+
this._cache.set(rootId, bucket);
|
|
27
|
+
}
|
|
28
|
+
return bucket;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether a subtree for the given component tag is currently cached.
|
|
32
|
+
*/
|
|
33
|
+
has(rootId, tag) {
|
|
34
|
+
return this.bucket(rootId).has(tag);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve AND remove a cached subtree so it can become live again. Returns
|
|
38
|
+
* `undefined` on a cache miss.
|
|
39
|
+
*/
|
|
40
|
+
take(rootId, tag) {
|
|
41
|
+
const bucket = this.bucket(rootId);
|
|
42
|
+
const entry = bucket.get(tag);
|
|
43
|
+
if (entry) {
|
|
44
|
+
bucket.delete(tag);
|
|
45
|
+
}
|
|
46
|
+
return entry;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Stash a detached subtree under the given component tag. Returns any entries
|
|
50
|
+
* that were evicted to honour the LRU limit (or replaced for the same tag) so
|
|
51
|
+
* the caller can `destroy()` them.
|
|
52
|
+
*/
|
|
53
|
+
put(rootId, tag, entry) {
|
|
54
|
+
const bucket = this.bucket(rootId);
|
|
55
|
+
const evicted = [];
|
|
56
|
+
const existing = bucket.get(tag);
|
|
57
|
+
if (existing) {
|
|
58
|
+
bucket.delete(tag);
|
|
59
|
+
if (existing.node !== entry.node) {
|
|
60
|
+
evicted.push(existing);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
bucket.set(tag, entry);
|
|
64
|
+
while (bucket.size > this._limit) {
|
|
65
|
+
const oldestKey = bucket.keys().next().value;
|
|
66
|
+
if (oldestKey === void 0) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
const oldest = bucket.get(oldestKey);
|
|
70
|
+
bucket.delete(oldestKey);
|
|
71
|
+
evicted.push(oldest);
|
|
72
|
+
}
|
|
73
|
+
return evicted;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Remove and return every cached entry for a root (e.g. on teardown) so the
|
|
77
|
+
* caller can destroy them.
|
|
78
|
+
*/
|
|
79
|
+
clear(rootId) {
|
|
80
|
+
const bucket = this._cache.get(rootId);
|
|
81
|
+
if (!bucket) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
const entries = [...bucket.values()];
|
|
85
|
+
bucket.clear();
|
|
86
|
+
this._cache.delete(rootId);
|
|
87
|
+
return entries;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
AreRootCache = __decorateClass([
|
|
91
|
+
A_Frame.Define({
|
|
92
|
+
namespace: "a-are-html",
|
|
93
|
+
description: "AreRootCache is a fragment that keeps a small per-root LRU of previously rendered are-root subtrees. When an are-root swaps the component it displays, the outgoing subtree is stashed here (unmounted + detached, but not destroyed) so that routing back to it can re-inject the preserved scene instantly instead of rebuilding from scratch."
|
|
94
|
+
})
|
|
95
|
+
], AreRootCache);
|
|
96
|
+
|
|
97
|
+
export { AreRootCache };
|
|
98
|
+
//# sourceMappingURL=AreRootCache.context.mjs.map
|
|
99
|
+
//# sourceMappingURL=AreRootCache.context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRootCache.context.ts"],"names":[],"mappings":";;;;AAyBO,IAAM,YAAA,GAAN,cAA2B,UAAA,CAAW;AAAA,EAezC,WAAA,CAAY,QAAgB,EAAA,EAAI;AAC5B,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,cAAA,EAAgB,CAAA;AATlC;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAU,MAAA,uBAA0D,GAAA,EAAI;AAUpE,IAAA,IAAA,CAAK,SAAS,IAAA,CAAK,GAAA,CAAI,GAAG,IAAA,CAAK,KAAA,CAAM,KAAK,CAAC,CAAA;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,KAAA,GAAgB;AAChB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EAChB;AAAA,EAEU,OAAO,MAAA,EAAgD;AAC7D,IAAA,IAAI,MAAA,GAAS,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,MAAM,CAAA;AACnC,IAAA,IAAI,CAAC,MAAA,EAAQ;AACT,MAAA,MAAA,uBAAa,GAAA,EAAI;AACjB,MAAA,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,MAAA,EAAQ,MAAM,CAAA;AAAA,IAClC;AACA,IAAA,OAAO,MAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,GAAA,CAAI,QAAgB,GAAA,EAAsB;AACtC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,MAAM,CAAA,CAAE,IAAI,GAAG,CAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAA,CAAK,QAAgB,GAAA,EAA4C;AAC7D,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,CAAO,MAAM,CAAA;AACjC,IAAA,M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ACrC,IAAA,IAAI,CAAC,MAAA,EAAQ;AACT,MAAA,OAAO,EAAC;AAAA,IACZ;AACA,IAAA,MAAM,OAAA,GAAU,CAAC,GAAG,MAAA,CAAO,QAAQ,CAAA;AACnC,IAAA,MAAA,CAAO,KAAA,EAAM;AACb,IAAA,IAAA,CAAK,MAAA,CAAO,OAAO,MAAM,CAAA;AACzB,IAAA,OAAO,OAAA;AAAA,EACX;AACJ;AA3Ga,YAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,YAAA,CAAA","file":"AreRootCache.context.mjs","sourcesContent":["import { A_Fragment } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode } from \"@adaas/are\";\n\n\n/**\n * A single cached, detached component subtree for an are-root outlet.\n *\n * `node` is fully compiled and its scene plan is intact (it was `unmount()`ed,\n * not destroyed), so it can be re-mounted instantly without re-tokenizing,\n * re-loading, transforming or compiling. `subscribers` records the exact set of\n * nodes inside the subtree that were subscribed to the signal bus at the moment\n * of stashing — they are unsubscribed while cached (so the detached DOM never\n * reacts to signals) and re-subscribed verbatim on restore.\n */\nexport type AreRootCacheEntry = {\n node: AreNode;\n subscribers: AreNode[];\n};\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'AreRootCache is a fragment that keeps a small per-root LRU of previously rendered are-root subtrees. When an are-root swaps the component it displays, the outgoing subtree is stashed here (unmounted + detached, but not destroyed) so that routing back to it can re-inject the preserved scene instantly instead of rebuilding from scratch.'\n})\nexport class AreRootCache extends A_Fragment {\n\n /**\n * rootId -> (component tag -> cache entry). The inner Map preserves\n * insertion order which is used as the LRU recency order: the first key is\n * the least-recently-used entry, the last key the most-recently-used.\n */\n protected _cache: Map<string, Map<string, AreRootCacheEntry>> = new Map();\n\n /**\n * Maximum number of cached subtrees kept per root. Older entries beyond this\n * limit are evicted (and returned to the caller so it can destroy them).\n */\n protected _limit: number;\n\n constructor(limit: number = 10) {\n super({ name: 'AreRootCache' });\n this._limit = Math.max(0, Math.floor(limit));\n }\n\n /**\n * Maximum number of cached subtrees kept per root.\n */\n get limit(): number {\n return this._limit;\n }\n\n protected bucket(rootId: string): Map<string, AreRootCacheEntry> {\n let bucket = this._cache.get(rootId);\n if (!bucket) {\n bucket = new Map();\n this._cache.set(rootId, bucket);\n }\n return bucket;\n }\n\n /**\n * Whether a subtree for the given component tag is currently cached.\n */\n has(rootId: string, tag: string): boolean {\n return this.bucket(rootId).has(tag);\n }\n\n /**\n * Retrieve AND remove a cached subtree so it can become live again. Returns\n * `undefined` on a cache miss.\n */\n take(rootId: string, tag: string): AreRootCacheEntry | undefined {\n const bucket = this.bucket(rootId);\n const entry = bucket.get(tag);\n if (entry) {\n bucket.delete(tag);\n }\n return entry;\n }\n\n /**\n * Stash a detached subtree under the given component tag. Returns any entries\n * that were evicted to honour the LRU limit (or replaced for the same tag) so\n * the caller can `destroy()` them.\n */\n put(rootId: string, tag: string, entry: AreRootCacheEntry): AreRootCacheEntry[] {\n const bucket = this.bucket(rootId);\n const evicted: AreRootCacheEntry[] = [];\n\n // Replace any stale entry for the same tag (should not normally happen,\n // since a displayed tag is never simultaneously cached) and surface it\n // for destruction so it does not leak.\n const existing = bucket.get(tag);\n if (existing) {\n bucket.delete(tag);\n if (existing.node !== entry.node) {\n evicted.push(existing);\n }\n }\n\n // A limit of 0 disables caching: the freshly added entry is evicted\n // immediately so the caller tears it down.\n bucket.set(tag, entry);\n\n while (bucket.size > this._limit) {\n const oldestKey = bucket.keys().next().value as string | undefined;\n if (oldestKey === undefined) {\n break;\n }\n const oldest = bucket.get(oldestKey)!;\n bucket.delete(oldestKey);\n evicted.push(oldest);\n }\n\n return evicted;\n }\n\n /**\n * Remove and return every cached entry for a root (e.g. on teardown) so the\n * caller can destroy them.\n */\n clear(rootId: string): AreRootCacheEntry[] {\n const bucket = this._cache.get(rootId);\n if (!bucket) {\n return [];\n }\n const entries = [...bucket.values()];\n bucket.clear();\n this._cache.delete(rootId);\n return entries;\n }\n}\n"]}
|