@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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/directives/AreDirectiveFor.directive.ts"],"names":[],"mappings":";;;;;;;;;AAyBO,IAAM,eAAA,GAAN,cAA8B,YAAA,CAAa;AAAA,EAI9C,UACwB,SAAA,EACD,KAAA,EACC,KAAA,EACA,KAAA,EACA,WACjB,IAAA,EACL;AAEE,IAAA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AA,CAAA,EAjGb,eAAA,CA8FT,SAAA,EAAA,QAAA,EAAA,CAAA,CAAA;AA9FS,eAAA,GAAN,eAAA,CAAA;AAAA,EALN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB,CAAA;AAAA,EACA,YAAA,CAAa,SAAS,CAAC;AAAA,CAAA,EACX,eAAA,CAAA","file":"AreDirectiveFor.directive.mjs","sourcesContent":["import { A_Caller, A_Inject, A_Scope } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreCompilerError, AreScene, AreStore } from \"@adaas/are\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AddCommentInstruction } from \"@adaas/are-html/instructions/AddComment.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\nimport { AreDirectiveContext } from \"@adaas/are-html/directive/AreDirective.context\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\n\n\ntype AreForExpression = {\n key: string;\n index: string | undefined;\n arrayExpr: string;\n /** Optional `track <expr>` clause, e.g. `track row.id` */\n trackExpr: string | undefined;\n};\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'Built-in $for directive. Iterates over an array expression resolved from the store and renders a cloned template fragment per item, managing per-item subscopes and comment-node anchors. Supports keyed diffing via an optional track clause to minimise DOM mutations on collection updates.'\n})\n@AreDirective.Priority(1)\nexport class AreDirectiveFor extends AreDirective {\n\n\n @AreDirective.Transform\n transform(\n @A_Inject(A_Caller) attribute: AreDirectiveAttribute,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger: A_Logger,\n ...args: any[]\n ) {\n\n logger.debug(`[Transform] directive $FOR for <${attribute.owner.aseid.toString()}>`)\n\n const node = attribute.owner;\n\n /**\n * Transfer the original node's scope (with all registered attributes and children)\n * to the template clone, and give the owner node a fresh empty scope.\n * This mirrors the $if directive's approach, making the owner a lightweight\n * group container whose sole visible presence is a comment placeholder.\n */\n const forTemplate = node.cloneWithScope();\n\n /**\n * Remove the $for attribute from the template so iterative clones do not\n * re-trigger this directive during their own transform phase.\n * Re-register it on the owner so the reactive compile/update pipeline keeps working.\n */\n const forAttr = forTemplate.attributes.find(d => d.name === attribute.name);\n\n if (forAttr) {\n forTemplate.scope.deregister(forAttr);\n node.scope.register(forAttr);\n }\n\n /**\n * Re-initialize the owner node with its fresh scope so it becomes a valid\n * group container that will own the generated item nodes as children.\n */\n node.init();\n\n /**\n * Store the template for use in compile and update.\n */\n attribute.template = forTemplate;\n\n\n /**\n * Parse the $for expression and evaluate the source array.\n */\n const { key, index, arrayExpr } = this.parseExpression(attribute.content);\n const array = this.resolveArray(store, arrayExpr, attribute.content);\n\n attribute.value = array;\n\n /**\n * For each item in the array, spawn a clone of the template with the\n * item's store values pre-set and its scene activated.\n *\n * The children are added to the owner node before the main compiler's\n * children iteration loop runs, so the main cycle will compile them —\n * no explicit child.compile() call is needed here.\n */\n for (let i = 0; i < array.length; i++) {\n this.spawnItemNode(attribute.template!, attribute.owner, key, index, array[i], i);\n }\n }\n\n\n @AreDirective.Compile\n compile(\n @A_Inject(A_Caller) attribute: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ): void {\n /**\n * Replace the group node's default host declaration with a comment placeholder\n * so the owner element itself does not render as a DOM element — the item nodes\n * render as its children instead.\n */\n const hostInstruction = scene.host!;\n const commentIdentifier = ` --- for: ${attribute.template!.id} --- `;\n const declaration = new AddCommentInstruction({ content: commentIdentifier });\n\n scene.setHost(declaration);\n scene.planBefore(declaration, hostInstruction);\n scene.unPlan(hostInstruction);\n }\n\n\n @AreDirective.Update\n update(\n @A_Inject(A_Caller) attribute: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ): void {\n /**\n * Re-evaluate the source array.\n */\n const { key, index, arrayExpr, trackExpr } = this.parseExpression(attribute.content);\n const newArray = this.resolveArray(store, arrayExpr, attribute.content);\n\n const owner = attribute.owner;\n const currentChildren = [...owner.children] as AreHTMLNode[];\n\n attribute.value = newArray;\n\n /**\n * Is this `$for`'s subtree currently rendered into the DOM?\n *\n * A `$for` can update while its subtree is detached — e.g. it lives\n * inside a `$if` whose condition is currently false (the documented\n * `<div $if><x $for></div>` nesting). The directive still receives the\n * store change and re-diffs, but it must NOT mount/unmount item nodes\n * directly while detached: the `$for` anchor (and its ancestors) are\n * not in the DOM, so the interpreter's mount-point walk would fall\n * through to the nearest *mounted* ancestor (the `$if` comment in the\n * grandparent) and HOIST the items out of their intended container.\n * When the ancestor `$if` later activates, its mount cascade applies\n * the already-compiled item instructions in the correct place.\n *\n * Detached === any ancestor scene is inactive (regular nodes default\n * to an active scene; only structural directives deactivate one).\n */\n const attached = this.isAttached(owner);\n\n const computeKey = this.makeKeyFn(key, index, trackExpr);\n\n // ── 1. Index existing children by stable key ────────────────────────\n const childByKey = new Map<any, AreHTMLNode>();\n const remaining = new Set<AreHTMLNode>();\n\n for (let i = 0; i < currentChildren.length; i++) {\n const child = currentChildren[i];\n const ctx = child.scope.resolveFlat(AreDirectiveContext);\n const k = ctx ? computeKey(ctx.scope[key], ctx.scope[index || 'index']) : Symbol('orphan');\n childByKey.set(k, child);\n remaining.add(child);\n }\n\n // ── 2. Walk desired list; reuse existing or spawn new ───────────────\n const desired: AreHTMLNode[] = [];\n const newOnes: AreHTMLNode[] = [];\n\n for (let i = 0; i < newArray.length; i++) {\n const item = newArray[i];\n const k = computeKey(item, i);\n const existing = childByKey.get(k);\n\n if (existing) {\n remaining.delete(existing);\n\n let directiveContext = existing.scope.resolveFlat(AreDirectiveContext);\n if (!directiveContext) {\n directiveContext = new AreDirectiveContext(existing.aseid);\n existing.scope.register(directiveContext);\n }\n directiveContext.scope = {\n ...directiveContext.scope,\n [key]: item,\n [index || 'index']: i,\n };\n desired.push(existing);\n } else {\n const itemNode = this.spawnItemNode(attribute.template!, owner, key, index, item, i);\n desired.push(itemNode);\n newOnes.push(itemNode);\n }\n }\n\n // ── 3. Unmount + detach removed children ─────────────────────────────\n for (const child of remaining) {\n // Only revert DOM if the subtree is live; a detached subtree's item\n // nodes were never mounted (see `attached` rationale above), so\n // unmounting them is a no-op at best and risks reverting stale state.\n if (attached) child.unmount();\n owner.removeChild(child);\n }\n\n // ── 4. Mount only the new ones (kept children stay where they are). ─\n for (const child of newOnes) {\n child.transform();\n child.compile();\n // While detached, stop after compile: the item's instructions are\n // planned and the ancestor `$if`'s mount cascade will apply them in\n // the correct container once the condition becomes truthy. Mounting\n // here would hoist the item to the nearest mounted ancestor.\n if (attached) child.mount();\n }\n }\n\n\n /**\n * Walks the node's ancestor chain (inclusive) and reports whether the\n * whole path is currently active — i.e. the subtree is actually rendered\n * into the DOM. A single inactive ancestor scene (e.g. a `$if` whose\n * condition is false) means the subtree is detached.\n */\n private isAttached(node: AreHTMLNode): boolean {\n let current: AreHTMLNode | undefined = node;\n while (current) {\n if (current.scene?.isInactive) return false;\n current = current.parent as AreHTMLNode | undefined;\n }\n return true;\n }\n\n\n // ─────────────────────────────────────────────────────────────────────────────\n // ── Helpers ──────────────────────────────────────────────────────────────────\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Build a key-function that derives a stable identity from each item.\n * If the user provided a `track <expr>` clause, evaluate it as a path on\n * the item; otherwise fall back to the item identity (reference equality).\n */\n private makeKeyFn(key: string, index: string | undefined, trackExpr: string | undefined): (item: any, i: number) => any {\n if (!trackExpr) {\n return (item, i) => item ?? i;\n }\n\n // Strip any leading `key.` so users can write `track row.id`.\n const path = trackExpr.startsWith(key + '.') ? trackExpr.slice(key.length + 1) : trackExpr;\n\n return (item, i) => {\n if (item == null) return i;\n if (path === key || path === '$index') return path === '$index' ? i : item;\n\n // dotted path lookup\n const parts = path.split('.');\n let v: any = item;\n for (const p of parts) {\n if (v == null) return i;\n v = v[p];\n }\n return v ?? i;\n };\n }\n\n /**\n * Parses the $for expression string into its constituent parts.\n *\n * Supported formats:\n * item in items\n * item, index in items\n * (item, index) in items\n * item in filter(items)\n * item, index in filter(items, 'active')\n * item in items track item.id\n * (item, i) in items track item.id\n */\n private parseExpression(content: string): AreForExpression {\n // Strip optional `track <expr>` suffix first.\n let trackExpr: string | undefined;\n const trackIdx = content.search(/\\s+track\\s+/);\n let body = content;\n if (trackIdx !== -1) {\n const m = content.slice(trackIdx).match(/\\s+track\\s+(.+)$/);\n if (m) {\n trackExpr = m[1].trim();\n body = content.slice(0, trackIdx).trim();\n }\n }\n\n const inIndex = body.lastIndexOf(' in ');\n const keyAndIndex = body.slice(0, inIndex).trim().replace(/^\\(|\\)$/g, '');\n const arrayExpr = body.slice(inIndex + 4).trim();\n const keyParts = keyAndIndex.split(',').map(p => p.trim());\n\n return {\n key: keyParts[0],\n index: keyParts[1] || undefined,\n arrayExpr,\n trackExpr,\n };\n }\n\n /**\n * Resolves the array expression against the store.\n * Supports both plain key lookups and function-call expressions:\n * items → store.get('items')\n * filter(items) → store.get('filter')(store.get('items'))\n */\n private resolveArray(store: AreStore, arrayExpr: string, fullContent: string): any[] {\n let result: any;\n const callMatch = arrayExpr.match(/^([^(]+)\\((.+)\\)$/);\n\n if (callMatch) {\n const fnName = callMatch[1].trim();\n const fn = store.get(fnName as any);\n\n if (typeof fn !== 'function')\n throw new AreCompilerError({\n title: 'Invalid \"for\" Directive Function',\n description: `The expression \"${fnName}\" in the \"for\" directive does not resolve to a function in the store. Received: ${typeof fn}`,\n });\n\n const rawArgs = callMatch[2].split(',').map(a => a.trim());\n const resolvedArgs = rawArgs.map(arg => {\n if (arg.startsWith(\"'\") && arg.endsWith(\"'\")) return arg.slice(1, -1);\n if (arg.startsWith('\"') && arg.endsWith('\"')) return arg.slice(1, -1);\n if (!isNaN(Number(arg))) return Number(arg);\n // Dotted-path / optional-chain: e.g. `record?.embedding` or `record.data`\n const stripped = arg.replace(/\\?$/, '');\n if (stripped.includes('.')) {\n const parts = stripped.split('.').map(p => p.replace(/\\?$/, ''));\n let val: any = store.get(parts[0] as any);\n for (let j = 1; j < parts.length; j++) {\n if (val == null) return undefined;\n val = val[parts[j]];\n }\n return val ?? undefined;\n }\n return store.get(stripped as any);\n });\n\n result = (fn as Function)(...resolvedArgs);\n } else if (arrayExpr.includes('.')) {\n // dotted-path lookup: e.g. \"list.items\" or \"record?.keywords\"\n // Strip optional-chaining `?` suffix from each segment so that\n // `record?.keywords` resolves the same as `record.keywords`.\n const parts = arrayExpr.split('.').map(p => p.replace(/\\?$/, ''));\n result = store.get(parts[0] as any);\n for (let i = 1; i < parts.length; i++) {\n if (result == null) break;\n result = result[parts[i]];\n }\n } else {\n result = store.get(arrayExpr.replace(/\\?$/, '') as any);\n }\n\n // null / undefined from optional-chaining expressions (e.g. `record?.keywords`)\n // means the source object is not yet loaded — treat as empty array so the\n // directive initialises gracefully and fills in when the store updates.\n if (result == null) return [];\n\n if (!Array.isArray(result))\n throw new AreCompilerError({\n title: 'Invalid \"for\" Directive Value',\n description: `The \"for\" directive expects an array but got ${typeof result}. Expression: \"${fullContent}\". Received: ${JSON.stringify(result)}`,\n });\n\n return result;\n }\n\n /**\n * Creates a single item node from the template, registers it as a child of\n * the owner, initialises it, injects item-scoped store values, and activates\n * its scene so the mount/compile cycle will include it.\n *\n * NOTE: This method does NOT call compile() or mount() — the caller is\n * responsible for doing so when the main lifecycle cycle won't cover it\n * (i.e. during update, but not during the initial compile phase).\n */\n private spawnItemNode(\n template: AreHTMLNode,\n owner: AreHTMLNode,\n key: string,\n index: string | undefined,\n item: any,\n i: number,\n ): AreHTMLNode {\n const itemNode = template.clone() as AreHTMLNode;\n\n owner.addChild(itemNode);\n\n const queue = [itemNode];\n\n while (queue.length > 0) {\n const current = queue.shift()!\n\n current.init();\n\n queue.push(...current.children as AreHTMLNode[]);\n }\n\n /**\n * Resolve or create a directive context for the item node. This is needed to hold the item-specific store values (e.g. the \"item\" and \"index\" in a \"for\" loop) that the template's bindings will reference during compile and update. The context is shared among all clones of the same template, but that's fine because each clone gets its own scope values assigned here.\n */\n let directiveContext = itemNode.scope.resolveFlat(AreDirectiveContext);\n\n if (!directiveContext) {\n directiveContext = new AreDirectiveContext(itemNode.aseid);\n itemNode.scope.register(directiveContext);\n }\n\n directiveContext.scope = {\n ...directiveContext.scope,\n [key]: item,\n [index || 'index']: i,\n }\n\n itemNode.scene.activate();\n\n return itemNode;\n }\n}"]}
1
+ {"version":3,"sources":["../../../src/directives/AreDirectiveFor.directive.ts"],"names":[],"mappings":";;;;;;;;;;AAgCO,IAAM,eAAA,GAAN,cAA8B,YAAA,CAAa;AAAA,EA8B9C,UACwB,SAAA,EACD,KAAA,EACC,KAAA,EACA,KAAA,EACA,WACjB,IAAA,EACL;AAEE,IAAA,MAAA,CAAO,MAAM,CAAA,gCAAA,EAAmC,SAAA,CAAU,MAAM,KAAA,CAAM,QAAA,EAAU,CAAA,CAAA,CAAG,CAAA;AAEnF,IAAA,MAAM,OAAO,SAAA,CAAU,KAAA;AAQvB,IAAA,MAAM,WAAA,GAAc,KAAK,cAAA,EAAe;AAOxC,IAAA,MAAM,OAAA,GAAU,YAAY,UAAA,CAAW,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,UAAU,IAAI,CAAA;AAE1E,IAAA,IAAI,OAAA,EAAS;AACT,MAAA,WAAA,CAAY,KAAA,CAAM,WAAW,OAAO,CAAA;AACpC,MAAA,IAAA,CAAK,KAAA,CAAM,SAAS,OAAO,CAAA;AAAA,IAC/B;AAMA,IAAA,IAAA,CAAK,IAAA,EAAK;AAKV,IAAA,SAAA,CAAU,QAAA,GAAW,WAAA;AAMrB,IAAA,MAAM,EAAE,KAAK,KAAA,EAAO,SAAA,KAAc,IAAA,CAAK,eAAA,CAAgB,UAAU,OAAO,CAAA;AACxE,IAA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B,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EAnCb,eAAA,CA8BT,SAAA,EAAA,WAAA,EAAA,CAAA,CAAA;AAoEA,eAAA,CAAA;AAAA,EADC,YAAA,CAAa,OAAA;AAAA,EAET,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EArGb,eAAA,CAkGT,SAAA,EAAA,SAAA,EAAA,CAAA,CAAA;AAsBA,eAAA,CAAA;AAAA,EADC,YAAA,CAAa,MAAA;AAAA,EAET,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EA3Hb,eAAA,CAwHT,SAAA,EAAA,QAAA,EAAA,CAAA,CAAA;AAxHS,eAAA,GAAN,eAAA,CAAA;AAAA,EALN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB,CAAA;AAAA,EACA,YAAA,CAAa,SAAS,CAAC;AAAA,CAAA,EACX,eAAA,CAAA","file":"AreDirectiveFor.directive.mjs","sourcesContent":["import { A_Caller, A_Inject, A_Scope } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreCompilerError, AreScene, AreStore } from \"@adaas/are\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AddCommentInstruction } from \"@adaas/are-html/instructions/AddComment.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\nimport { AreDirectiveContext } from \"@adaas/are-html/directive/AreDirective.context\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreSchedulerHelper } from \"@adaas/are-html/helpers/AreScheduler.helper\";\n\n\ntype AreForExpression = {\n key: string;\n index: string | undefined;\n arrayExpr: string;\n /** Optional `track <expr>` clause, e.g. `track row.id` */\n trackExpr: string | undefined;\n};\n\n/**\n * Per-`$for` reentrancy state used to serialize chunked (async) renders.\n * Keyed by the directive attribute instance (one per `$for` in the template).\n */\ntype AreForRenderState = { running: boolean; pending: boolean };\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'Built-in $for directive. Iterates over an array expression resolved from the store and renders a cloned template fragment per item, managing per-item subscopes and comment-node anchors. Supports keyed diffing via an optional track clause to minimise DOM mutations on collection updates.'\n})\n@AreDirective.Priority(1)\nexport class AreDirectiveFor extends AreDirective {\n\n /**\n * Lists whose number of NEW item nodes is at or below this threshold render\n * fully synchronously — byte-for-byte the previous behavior. Typical UIs\n * (menus, small tables) are therefore completely unaffected; only genuinely\n * large lists pay the (tiny) scheduling cost to keep the main thread responsive.\n */\n private static readonly SYNC_THRESHOLD = 100;\n\n /**\n * Per-chunk time budget (ms). During a large-list render we mount item nodes\n * until this much time has elapsed, then yield to the browser so it can paint\n * and process input before the next chunk. ~16ms targets one animation frame.\n */\n private static readonly CHUNK_BUDGET_MS = 16;\n\n /**\n * Per-attribute serialization state. A new update() that arrives while a\n * chunked render of the SAME `$for` is still in flight does NOT start a second\n * concurrent pass (which could interleave mutations on the shared children\n * list); instead it marks `pending` and the in-flight run re-runs once more\n * with the latest data when it finishes. This guarantees the children list is\n * only ever mutated by one pass at a time and the final state always reflects\n * the most recent store value.\n */\n private static readonly renderState = new WeakMap<object, AreForRenderState>();\n\n\n @AreDirective.Transform\n transform(\n @A_Inject(A_Caller) attribute: AreDirectiveAttribute,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger: A_Logger,\n ...args: any[]\n ) {\n\n logger.debug(`[Transform] directive $FOR for <${attribute.owner.aseid.toString()}>`)\n\n const node = attribute.owner;\n\n /**\n * Transfer the original node's scope (with all registered attributes and children)\n * to the template clone, and give the owner node a fresh empty scope.\n * This mirrors the $if directive's approach, making the owner a lightweight\n * group container whose sole visible presence is a comment placeholder.\n */\n const forTemplate = node.cloneWithScope();\n\n /**\n * Remove the $for attribute from the template so iterative clones do not\n * re-trigger this directive during their own transform phase.\n * Re-register it on the owner so the reactive compile/update pipeline keeps working.\n */\n const forAttr = forTemplate.attributes.find(d => d.name === attribute.name);\n\n if (forAttr) {\n forTemplate.scope.deregister(forAttr);\n node.scope.register(forAttr);\n }\n\n /**\n * Re-initialize the owner node with its fresh scope so it becomes a valid\n * group container that will own the generated item nodes as children.\n */\n node.init();\n\n /**\n * Store the template for use in compile and update.\n */\n attribute.template = forTemplate;\n\n\n /**\n * Parse the $for expression and evaluate the source array.\n */\n const { key, index, arrayExpr } = this.parseExpression(attribute.content);\n const array = this.resolveArray(store, arrayExpr, attribute.content);\n\n attribute.value = array;\n\n /**\n * For each item in the array, spawn a clone of the template with the\n * item's store values pre-set and its scene activated.\n *\n * The children are added to the owner node before the main compiler's\n * children iteration loop runs, so the main cycle will compile them —\n * no explicit child.compile() call is needed here.\n */\n for (let i = 0; i < array.length; i++) {\n this.spawnItemNode(attribute.template!, attribute.owner, key, index, array[i], i);\n }\n }\n\n\n @AreDirective.Compile\n compile(\n @A_Inject(A_Caller) attribute: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ): void {\n /**\n * Replace the group node's default host declaration with a comment placeholder\n * so the owner element itself does not render as a DOM element — the item nodes\n * render as its children instead.\n */\n const hostInstruction = scene.host!;\n const commentIdentifier = ` --- for: ${attribute.template!.id} --- `;\n const declaration = new AddCommentInstruction({ content: commentIdentifier });\n\n scene.setHost(declaration);\n scene.planBefore(declaration, hostInstruction);\n scene.unPlan(hostInstruction);\n }\n\n\n @AreDirective.Update\n update(\n @A_Inject(A_Caller) attribute: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ): void | Promise<void> {\n /**\n * Serialize chunked renders per `$for`. If a previous large-list render\n * is still streaming item nodes across macrotasks, do NOT start a second\n * concurrent pass — that would interleave two diffs over the same shared\n * children list (and leave half-compiled item nodes that the next diff\n * would wrongly \"reuse\"). Mark a pass as pending instead; the in-flight\n * run re-diffs once more from the latest store value when it completes.\n */\n let state = AreDirectiveFor.renderState.get(attribute);\n if (!state) {\n state = { running: false, pending: false };\n AreDirectiveFor.renderState.set(attribute, state);\n }\n if (state.running) {\n state.pending = true;\n return;\n }\n\n return this.performUpdate(attribute, store, scene, state);\n }\n\n /**\n * Core of the `$for` update: re-diff the source array against the current\n * children, reconcile reused/removed items, then mount the new ones (small\n * lists synchronously, large lists time-sliced). Never called while another\n * pass for the same `$for` is in flight (see `update`).\n */\n private performUpdate(\n attribute: AreDirectiveAttribute,\n store: AreStore,\n scene: AreScene,\n state: AreForRenderState,\n ): void | Promise<void> {\n /**\n * Re-evaluate the source array.\n */\n const { key, index, arrayExpr, trackExpr } = this.parseExpression(attribute.content);\n const newArray = this.resolveArray(store, arrayExpr, attribute.content);\n\n const owner = attribute.owner;\n const currentChildren = [...owner.children] as AreHTMLNode[];\n\n attribute.value = newArray;\n\n /**\n * Is this `$for`'s subtree currently rendered into the DOM?\n *\n * A `$for` can update while its subtree is detached — e.g. it lives\n * inside a `$if` whose condition is currently false (the documented\n * `<div $if><x $for></div>` nesting). The directive still receives the\n * store change and re-diffs, but it must NOT mount/unmount item nodes\n * directly while detached: the `$for` anchor (and its ancestors) are\n * not in the DOM, so the interpreter's mount-point walk would fall\n * through to the nearest *mounted* ancestor (the `$if` comment in the\n * grandparent) and HOIST the items out of their intended container.\n * When the ancestor `$if` later activates, its mount cascade applies\n * the already-compiled item instructions in the correct place.\n *\n * Detached === any ancestor scene is inactive (regular nodes default\n * to an active scene; only structural directives deactivate one).\n */\n const attached = this.isAttached(owner);\n\n const computeKey = this.makeKeyFn(key, index, trackExpr);\n\n // ── 1. Index existing children by stable key ────────────────────────\n const childByKey = new Map<any, AreHTMLNode>();\n const remaining = new Set<AreHTMLNode>();\n\n for (let i = 0; i < currentChildren.length; i++) {\n const child = currentChildren[i];\n const ctx = child.scope.resolveFlat(AreDirectiveContext);\n const k = ctx ? computeKey(ctx.scope[key], ctx.scope[index || 'index']) : Symbol('orphan');\n childByKey.set(k, child);\n remaining.add(child);\n }\n\n // ── 2. Walk desired list; reuse existing or record items to create ──\n // NOTE: new item nodes are NOT spawned here. Spawning (cloneWithScope +\n // subtree init + scene activation) is the dominant cost of a large\n // render, so it is deferred into the time-sliced loop below alongside\n // transform/compile/mount. Existing (keyed) children are reconciled in\n // place synchronously — that is cheap and keeps reused rows stable.\n const toCreate: Array<{ item: any; idx: number }> = [];\n\n for (let i = 0; i < newArray.length; i++) {\n const item = newArray[i];\n const k = computeKey(item, i);\n const existing = childByKey.get(k);\n\n if (existing) {\n remaining.delete(existing);\n\n let directiveContext = existing.scope.resolveFlat(AreDirectiveContext);\n if (!directiveContext) {\n directiveContext = new AreDirectiveContext(existing.aseid);\n existing.scope.register(directiveContext);\n }\n directiveContext.scope = {\n ...directiveContext.scope,\n [key]: item,\n [index || 'index']: i,\n };\n } else {\n toCreate.push({ item, idx: i });\n }\n }\n\n // ── 3. Unmount + detach removed children ─────────────────────────────\n for (const child of remaining) {\n // Only revert DOM if the subtree is live; a detached subtree's item\n // nodes were never mounted (see `attached` rationale above), so\n // unmounting them is a no-op at best and risks reverting stale state.\n if (attached) child.unmount();\n owner.removeChild(child);\n }\n\n // ── 4. Create + mount the new item nodes. ───────────────────────────\n // `spawnItemNode` appends to `owner.children` immediately, so iterating\n // `toCreate` in source order preserves list order (reused children keep\n // their positions, new rows are appended in order) — identical to the\n // previous synchronous behavior.\n const createItem = (desc: { item: any; idx: number }) => {\n const child = this.spawnItemNode(attribute.template!, owner, key, index, desc.item, desc.idx);\n child.transform();\n child.compile();\n // While detached, stop after compile: the item's instructions are\n // planned and the ancestor `$if`'s mount cascade will apply them in\n // the correct container once the condition becomes truthy. Mounting\n // here would hoist the item to the nearest mounted ancestor.\n if (attached) child.mount();\n };\n\n // Small lists → fully synchronous, identical to the previous behavior.\n if (toCreate.length <= AreDirectiveFor.SYNC_THRESHOLD) {\n for (const desc of toCreate) createItem(desc);\n return this.finishUpdate(attribute, store, scene, state);\n }\n\n // Large lists → time-sliced render. Create item nodes until the frame\n // budget elapses, then yield to the browser (zero-delay macrotask) so\n // it can paint and stay responsive instead of blocking for the whole\n // batch. The `state.running` flag (see `update`) prevents any other\n // update() for this `$for` from interleaving while we stream.\n state.running = true;\n let cursor = 0;\n\n const processChunk = (): void | Promise<void> => {\n try {\n const start = AreSchedulerHelper.now();\n while (cursor < toCreate.length) {\n createItem(toCreate[cursor]);\n cursor++;\n if (AreSchedulerHelper.now() - start >= AreDirectiveFor.CHUNK_BUDGET_MS) break;\n }\n } catch (error) {\n // Never leave the `$for` wedged in the running state on failure,\n // or every future update would be silently deferred forever.\n state.running = false;\n state.pending = false;\n throw error;\n }\n\n if (cursor < toCreate.length) {\n return new Promise<void>(resolve => {\n AreSchedulerHelper.scheduleMacrotask(() => resolve(processChunk()));\n });\n }\n\n return this.finishUpdate(attribute, store, scene, state);\n };\n\n return processChunk();\n }\n\n /**\n * Completes an update pass. If another update() arrived while a chunked\n * render was streaming, run exactly one more pass now from the latest store\n * value so the final DOM always reflects the most recent data.\n */\n private finishUpdate(\n attribute: AreDirectiveAttribute,\n store: AreStore,\n scene: AreScene,\n state: AreForRenderState,\n ): void | Promise<void> {\n state.running = false;\n if (state.pending) {\n state.pending = false;\n return this.performUpdate(attribute, store, scene, state);\n }\n }\n\n\n /**\n * Walks the node's ancestor chain (inclusive) and reports whether the\n * whole path is currently active — i.e. the subtree is actually rendered\n * into the DOM. A single inactive ancestor scene (e.g. a `$if` whose\n * condition is false) means the subtree is detached.\n */\n private isAttached(node: AreHTMLNode): boolean {\n let current: AreHTMLNode | undefined = node;\n while (current) {\n if (current.scene?.isInactive) return false;\n current = current.parent as AreHTMLNode | undefined;\n }\n return true;\n }\n\n\n // ─────────────────────────────────────────────────────────────────────────────\n // ── Helpers ──────────────────────────────────────────────────────────────────\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Build a key-function that derives a stable identity from each item.\n * If the user provided a `track <expr>` clause, evaluate it as a path on\n * the item; otherwise fall back to the item identity (reference equality).\n */\n private makeKeyFn(key: string, index: string | undefined, trackExpr: string | undefined): (item: any, i: number) => any {\n if (!trackExpr) {\n return (item, i) => item ?? i;\n }\n\n // Strip any leading `key.` so users can write `track row.id`.\n const path = trackExpr.startsWith(key + '.') ? trackExpr.slice(key.length + 1) : trackExpr;\n\n return (item, i) => {\n if (item == null) return i;\n if (path === key || path === '$index') return path === '$index' ? i : item;\n\n // dotted path lookup\n const parts = path.split('.');\n let v: any = item;\n for (const p of parts) {\n if (v == null) return i;\n v = v[p];\n }\n return v ?? i;\n };\n }\n\n /**\n * Parses the $for expression string into its constituent parts.\n *\n * Supported formats:\n * item in items\n * item, index in items\n * (item, index) in items\n * item in filter(items)\n * item, index in filter(items, 'active')\n * item in items track item.id\n * (item, i) in items track item.id\n */\n private parseExpression(content: string): AreForExpression {\n // Strip optional `track <expr>` suffix first.\n let trackExpr: string | undefined;\n const trackIdx = content.search(/\\s+track\\s+/);\n let body = content;\n if (trackIdx !== -1) {\n const m = content.slice(trackIdx).match(/\\s+track\\s+(.+)$/);\n if (m) {\n trackExpr = m[1].trim();\n body = content.slice(0, trackIdx).trim();\n }\n }\n\n const inIndex = body.lastIndexOf(' in ');\n const keyAndIndex = body.slice(0, inIndex).trim().replace(/^\\(|\\)$/g, '');\n const arrayExpr = body.slice(inIndex + 4).trim();\n const keyParts = keyAndIndex.split(',').map(p => p.trim());\n\n return {\n key: keyParts[0],\n index: keyParts[1] || undefined,\n arrayExpr,\n trackExpr,\n };\n }\n\n /**\n * Resolves the array expression against the store.\n * Supports both plain key lookups and function-call expressions:\n * items → store.get('items')\n * filter(items) → store.get('filter')(store.get('items'))\n */\n private resolveArray(store: AreStore, arrayExpr: string, fullContent: string): any[] {\n let result: any;\n const callMatch = arrayExpr.match(/^([^(]+)\\((.+)\\)$/);\n\n if (callMatch) {\n const fnName = callMatch[1].trim();\n const fn = store.get(fnName as any);\n\n if (typeof fn !== 'function')\n throw new AreCompilerError({\n title: 'Invalid \"for\" Directive Function',\n description: `The expression \"${fnName}\" in the \"for\" directive does not resolve to a function in the store. Received: ${typeof fn}`,\n });\n\n const rawArgs = callMatch[2].split(',').map(a => a.trim());\n const resolvedArgs = rawArgs.map(arg => {\n if (arg.startsWith(\"'\") && arg.endsWith(\"'\")) return arg.slice(1, -1);\n if (arg.startsWith('\"') && arg.endsWith('\"')) return arg.slice(1, -1);\n if (!isNaN(Number(arg))) return Number(arg);\n // Dotted-path / optional-chain: e.g. `record?.embedding` or `record.data`\n const stripped = arg.replace(/\\?$/, '');\n if (stripped.includes('.')) {\n const parts = stripped.split('.').map(p => p.replace(/\\?$/, ''));\n let val: any = store.get(parts[0] as any);\n for (let j = 1; j < parts.length; j++) {\n if (val == null) return undefined;\n val = val[parts[j]];\n }\n return val ?? undefined;\n }\n return store.get(stripped as any);\n });\n\n result = (fn as Function)(...resolvedArgs);\n } else if (arrayExpr.includes('.')) {\n // dotted-path lookup: e.g. \"list.items\" or \"record?.keywords\"\n // Strip optional-chaining `?` suffix from each segment so that\n // `record?.keywords` resolves the same as `record.keywords`.\n const parts = arrayExpr.split('.').map(p => p.replace(/\\?$/, ''));\n result = store.get(parts[0] as any);\n for (let i = 1; i < parts.length; i++) {\n if (result == null) break;\n result = result[parts[i]];\n }\n } else {\n result = store.get(arrayExpr.replace(/\\?$/, '') as any);\n }\n\n // null / undefined from optional-chaining expressions (e.g. `record?.keywords`)\n // means the source object is not yet loaded — treat as empty array so the\n // directive initialises gracefully and fills in when the store updates.\n if (result == null) return [];\n\n if (!Array.isArray(result))\n throw new AreCompilerError({\n title: 'Invalid \"for\" Directive Value',\n description: `The \"for\" directive expects an array but got ${typeof result}. Expression: \"${fullContent}\". Received: ${JSON.stringify(result)}`,\n });\n\n return result;\n }\n\n /**\n * Creates a single item node from the template, registers it as a child of\n * the owner, initialises it, injects item-scoped store values, and activates\n * its scene so the mount/compile cycle will include it.\n *\n * NOTE: This method does NOT call compile() or mount() — the caller is\n * responsible for doing so when the main lifecycle cycle won't cover it\n * (i.e. during update, but not during the initial compile phase).\n */\n private spawnItemNode(\n template: AreHTMLNode,\n owner: AreHTMLNode,\n key: string,\n index: string | undefined,\n item: any,\n i: number,\n ): AreHTMLNode {\n const itemNode = template.clone() as AreHTMLNode;\n\n owner.addChild(itemNode);\n\n const queue = [itemNode];\n\n while (queue.length > 0) {\n const current = queue.shift()!\n\n current.init();\n\n queue.push(...current.children as AreHTMLNode[]);\n }\n\n /**\n * Resolve or create a directive context for the item node. This is needed to hold the item-specific store values (e.g. the \"item\" and \"index\" in a \"for\" loop) that the template's bindings will reference during compile and update. The context is shared among all clones of the same template, but that's fine because each clone gets its own scope values assigned here.\n */\n let directiveContext = itemNode.scope.resolveFlat(AreDirectiveContext);\n\n if (!directiveContext) {\n directiveContext = new AreDirectiveContext(itemNode.aseid);\n itemNode.scope.register(directiveContext);\n }\n\n directiveContext.scope = {\n ...directiveContext.scope,\n [key]: item,\n [index || 'index']: i,\n }\n\n itemNode.scene.activate();\n\n return itemNode;\n }\n}"]}
@@ -7,6 +7,13 @@ import '../lib/AreStyle/AreStyle.context.mjs';
7
7
  import './AreHTML.types.mjs';
8
8
 
9
9
  declare class AreHTMLLifecycle extends AreLifecycle {
10
+ /**
11
+ * Per-chunk time budget (ms) for the time-sliced initial mount walk. While
12
+ * mounting a large subtree we keep applying nodes until this much wall-clock
13
+ * time has elapsed, then yield to the browser so it can paint and process
14
+ * input before the next chunk. ~16ms targets a single animation frame.
15
+ */
16
+ private static readonly MOUNT_BUDGET_MS;
10
17
  initComponent(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, signalsContext?: AreSignalsContext, logger?: A_Logger, ...args: any[]): void;
11
18
  initRoot(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, signalsContext?: AreSignalsContext, logger?: A_Logger, ...args: any[]): void;
12
19
  initText(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, logger?: A_Logger, ...args: any[]): void;
@@ -19,7 +26,7 @@ declare class AreHTMLLifecycle extends AreLifecycle {
19
26
  /**
20
27
  * Node Content
21
28
  */
22
- scene: AreScene, logger?: A_Logger, ...args: any[]): void;
29
+ scene: AreScene, logger?: A_Logger, ...args: any[]): void | Promise<void>;
23
30
  updateDirectiveAttribute(directive: AreDirectiveAttribute, scope: A_Scope, feature: A_Feature, logger?: A_Logger, ...args: any[]): void;
24
31
  }
25
32
 
@@ -7,6 +7,13 @@ import '../lib/AreStyle/AreStyle.context.js';
7
7
  import './AreHTML.types.js';
8
8
 
9
9
  declare class AreHTMLLifecycle extends AreLifecycle {
10
+ /**
11
+ * Per-chunk time budget (ms) for the time-sliced initial mount walk. While
12
+ * mounting a large subtree we keep applying nodes until this much wall-clock
13
+ * time has elapsed, then yield to the browser so it can paint and process
14
+ * input before the next chunk. ~16ms targets a single animation frame.
15
+ */
16
+ private static readonly MOUNT_BUDGET_MS;
10
17
  initComponent(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, signalsContext?: AreSignalsContext, logger?: A_Logger, ...args: any[]): void;
11
18
  initRoot(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, signalsContext?: AreSignalsContext, logger?: A_Logger, ...args: any[]): void;
12
19
  initText(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, logger?: A_Logger, ...args: any[]): void;
@@ -19,7 +26,7 @@ declare class AreHTMLLifecycle extends AreLifecycle {
19
26
  /**
20
27
  * Node Content
21
28
  */
22
- scene: AreScene, logger?: A_Logger, ...args: any[]): void;
29
+ scene: AreScene, logger?: A_Logger, ...args: any[]): void | Promise<void>;
23
30
  updateDirectiveAttribute(directive: AreDirectiveAttribute, scope: A_Scope, feature: A_Feature, logger?: A_Logger, ...args: any[]): void;
24
31
  }
25
32
 
@@ -12,6 +12,7 @@ var AreDirective_constants = require('@adaas/are-html/directive/AreDirective.con
12
12
  var AreHTML_context = require('./AreHTML.context');
13
13
  var AreHTMLNode = require('../lib/AreHTMLNode/AreHTMLNode');
14
14
  var core = require('@adaas/a-frame/core');
15
+ var AreScheduler_helper = require('@adaas/are-html/helpers/AreScheduler.helper');
15
16
 
16
17
  var __defProp = Object.defineProperty;
17
18
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -46,10 +47,45 @@ exports.AreHTMLLifecycle = class AreHTMLLifecycle extends are.AreLifecycle {
46
47
  logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);
47
48
  if (scene.isInactive) return;
48
49
  node.interpret();
49
- for (let i = 0; i < node.children.length; i++) {
50
- const child = node.children[i];
51
- child.mount();
50
+ const stack = [];
51
+ for (let i = node.children.length - 1; i >= 0; i--) {
52
+ stack.push({ node: node.children[i], entered: false });
52
53
  }
54
+ const step = () => {
55
+ const frame = stack[stack.length - 1];
56
+ const current = frame.node;
57
+ if (frame.entered) {
58
+ stack.pop();
59
+ current.call(are.AreNodeFeatures.onAfterMount, current.scope);
60
+ return;
61
+ }
62
+ frame.entered = true;
63
+ current.call(are.AreNodeFeatures.onBeforeMount, current.scope);
64
+ if (!current.scene.isInactive) {
65
+ current.interpret();
66
+ for (let i = current.children.length - 1; i >= 0; i--) {
67
+ stack.push({ node: current.children[i], entered: false });
68
+ }
69
+ }
70
+ };
71
+ const drive = () => {
72
+ const start = AreScheduler_helper.AreSchedulerHelper.now();
73
+ while (stack.length > 0) {
74
+ step();
75
+ if (stack.length > 0 && AreScheduler_helper.AreSchedulerHelper.now() - start >= exports.AreHTMLLifecycle.MOUNT_BUDGET_MS) {
76
+ return new Promise((resolve, reject) => {
77
+ AreScheduler_helper.AreSchedulerHelper.scheduleMacrotask(() => {
78
+ try {
79
+ resolve(drive());
80
+ } catch (error) {
81
+ reject(error);
82
+ }
83
+ });
84
+ });
85
+ }
86
+ }
87
+ };
88
+ return drive();
53
89
  }
54
90
  updateDirectiveAttribute(directive, scope, feature, logger, ...args) {
55
91
  if (directive.component) {
@@ -59,6 +95,13 @@ exports.AreHTMLLifecycle = class AreHTMLLifecycle extends are.AreLifecycle {
59
95
  }
60
96
  }
61
97
  };
98
+ /**
99
+ * Per-chunk time budget (ms) for the time-sliced initial mount walk. While
100
+ * mounting a large subtree we keep applying nodes until this much wall-clock
101
+ * time has elapsed, then yield to the browser so it can paint and process
102
+ * input before the next chunk. ~16ms targets a single animation frame.
103
+ */
104
+ exports.AreHTMLLifecycle.MOUNT_BUDGET_MS = 16;
62
105
  __decorateClass([
63
106
  are.AreLifecycle.Init(AreComponent.AreComponentNode),
64
107
  __decorateParam(0, aConcept.A_Inject(aConcept.A_Caller)),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/engine/AreHTML.lifecycle.ts"],"names":["AreHTMLLifecycle","AreLifecycle","AreScene","AreDirectiveFeatures","A_FormatterHelper","AreComponentNode","A_Caller","A_Scope","AreHTMLEngineContext","AreSignalsContext","A_Logger","AreRootNode","AreText","AreInterpolation","A_Feature","AreNodeFeatures","AreHTMLNode","AreAttributeFeatures","AreDirectiveAttribute","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkBaA,wBAAA,GAAN,+BAA+BC,gBAAA,CAAa;AAAA,EAG/C,cACwB,IAAA,EACD,KAAA,EACa,OAAA,EACH,cAAA,EACT,WACjB,IAAA,EACC;AAEJ,IAAA,IAAI,IAAA,CAAK,SAAA;AACL,MAAA,cAAA,EAAgB,UAAU,IAAI,CAAA;AAElC,IAAA,KAAA,CAAM,KAAK,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,EACpD;AAAA,EAIA,SACwB,IAAA,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BAAA,CAAA","file":"AreHTML.lifecycle.js","sourcesContent":["import { A_Caller, A_Feature, A_FormatterHelper, A_Inject, A_Scope } from \"@adaas/a-concept\";\nimport { AreLifecycle, AreScene, AreAttributeFeatures, AreSignalsContext, AreNodeFeatures, AreFeatures } from \"@adaas/are\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { AreComponentNode } from \"@adaas/are-html/nodes/AreComponent\";\nimport { AreRootNode } from \"@adaas/are-html/nodes/AreRoot\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreHTMLEngineContext } from \"./AreHTML.context\";\nimport { AreHTMLNode } from \"../lib/AreHTMLNode/AreHTMLNode\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific lifecycle handler extending AreLifecycle. Wires DOM-aware init hooks for component nodes, root nodes, interpolations, text nodes, and directive attributes to the ARE rendering pipeline, connecting each entity to its HTML engine context and priming the scene for subsequent compilation and interpretation.'\n})\nexport class AreHTMLLifecycle extends AreLifecycle {\n\n @AreLifecycle.Init(AreComponentNode)\n initComponent(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n\n if (node.component)\n signalsContext?.subscribe(node);\n\n super.init(node, scope, context, logger, ...args);\n }\n\n\n @AreLifecycle.Init(AreRootNode)\n initRoot(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n signalsContext?.subscribe(node);\n super.init(node, scope, context, logger, ...args);\n }\n\n\n @AreLifecycle.Init(AreText)\n initText(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n const scene = new AreScene(node.aseid);\n\n scope.register(scene);\n }\n\n\n @AreLifecycle.Init(AreInterpolation)\n initInterpolation(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n const scene = new AreScene(node.aseid);\n\n scope.register(scene);\n }\n\n @A_Feature.Extend({\n name: AreNodeFeatures.onMount,\n scope: [AreHTMLNode]\n })\n mount(\n /**\n * Node to be mounted\n */\n @A_Inject(A_Caller) node: AreHTMLNode,\n /**\n * Node Content\n */\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n\n logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);\n\n /**\n * Skip mounting nodes whose scene has been deactivated (e.g. $if template nodes\n * when the condition is false). Mirrors the guard in AreLifecycle.mount.\n */\n if (scene.isInactive) return;\n\n /**\n * 1. We should simply run and render node itself.\n */\n node.interpret();\n /**\n * 2. Then go through all children of the node and mount the.\n */\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n child.mount();\n }\n }\n\n @A_Feature.Extend({\n name: AreAttributeFeatures.Update,\n scope: [AreDirectiveAttribute],\n })\n updateDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n /**\n * 3. If the attribute is a directive, then we should find a component that is responsible for\n * the directive compiling logic, and call it. \n * In case component is not found we just want to log a warning, \n * since the directive may be handled by some parent component or simply is a mistake in the template.\n */\n if (directive.component) {\n feature.chain(directive.component, AreDirectiveFeatures.Update, directive.owner.scope);\n } else {\n logger?.warning(`Directive handler component not found for directive: ${directive.name}. Make sure to create a component named \"AreDirective${A_FormatterHelper.toPascalCase(directive.name)}\" to handle this directive.`);\n }\n }\n\n}"]}
1
+ {"version":3,"sources":["../../../src/engine/AreHTML.lifecycle.ts"],"names":["AreHTMLLifecycle","AreLifecycle","AreScene","AreNodeFeatures","AreSchedulerHelper","AreDirectiveFeatures","A_FormatterHelper","AreComponentNode","A_Caller","A_Scope","AreHTMLEngineContext","AreSignalsContext","A_Logger","AreRootNode","AreText","AreInterpolation","A_Feature","AreHTMLNode","AreAttributeFeatures","AreDirectiveAttribute","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBaA,wBAAA,GAAN,+BAA+BC,gBAAA,CAAa;AAAA,EAW/C,cACwB,IAAA,EACD,KAAA,EACa,OAAA,EACH,cAAA,EACT,WACjB,IAAA,EACC;AAEJ,IAAA,IAAI,IAAA,CAAK,SAAA;AACL,MAAA,cAAA,EAAgB,UAAU,IAAI,CAAA;AAElC,IAAA,KAAA,CAAM,KAAK,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,EACpD;AAAA,EAIA,SACwB,IAAA,EACD,KAAA,EACa,OAAA,EACH,cAAA,EACT,WACjB,IAAA,EACC;AACJ,IAAA,cAAA,EAAgB,UAAU,IAAI,CAAA;AAC9B,IAAA,KAAA,CAAM,KAAK,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,GAAG,IA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AA,CAmLT,SAAA,EAAA,0BAAA,EAAA,CAAA,CAAA;AAnLSA,wBAAA,GAAN,eAAA,CAAA;AAAA,EAJNoB,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYpB,wBAAA,CAAA","file":"AreHTML.lifecycle.js","sourcesContent":["import { A_Caller, A_Feature, A_FormatterHelper, A_Inject, A_Scope } from \"@adaas/a-concept\";\nimport { AreLifecycle, AreScene, AreAttributeFeatures, AreSignalsContext, AreNodeFeatures, AreFeatures } from \"@adaas/are\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { AreComponentNode } from \"@adaas/are-html/nodes/AreComponent\";\nimport { AreRootNode } from \"@adaas/are-html/nodes/AreRoot\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreHTMLEngineContext } from \"./AreHTML.context\";\nimport { AreHTMLNode } from \"../lib/AreHTMLNode/AreHTMLNode\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreSchedulerHelper } from \"@adaas/are-html/helpers/AreScheduler.helper\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific lifecycle handler extending AreLifecycle. Wires DOM-aware init hooks for component nodes, root nodes, interpolations, text nodes, and directive attributes to the ARE rendering pipeline, connecting each entity to its HTML engine context and priming the scene for subsequent compilation and interpretation.'\n})\nexport class AreHTMLLifecycle extends AreLifecycle {\n\n /**\n * Per-chunk time budget (ms) for the time-sliced initial mount walk. While\n * mounting a large subtree we keep applying nodes until this much wall-clock\n * time has elapsed, then yield to the browser so it can paint and process\n * input before the next chunk. ~16ms targets a single animation frame.\n */\n private static readonly MOUNT_BUDGET_MS = 16;\n\n @AreLifecycle.Init(AreComponentNode)\n initComponent(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n\n if (node.component)\n signalsContext?.subscribe(node);\n\n super.init(node, scope, context, logger, ...args);\n }\n\n\n @AreLifecycle.Init(AreRootNode)\n initRoot(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n signalsContext?.subscribe(node);\n super.init(node, scope, context, logger, ...args);\n }\n\n\n @AreLifecycle.Init(AreText)\n initText(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n const scene = new AreScene(node.aseid);\n\n scope.register(scene);\n }\n\n\n @AreLifecycle.Init(AreInterpolation)\n initInterpolation(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n const scene = new AreScene(node.aseid);\n\n scope.register(scene);\n }\n\n @A_Feature.Extend({\n name: AreNodeFeatures.onMount,\n scope: [AreHTMLNode]\n })\n mount(\n /**\n * Node to be mounted\n */\n @A_Inject(A_Caller) node: AreHTMLNode,\n /**\n * Node Content\n */\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void | Promise<void> {\n\n logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);\n\n /**\n * Skip mounting nodes whose scene has been deactivated (e.g. $if template nodes\n * when the condition is false). Mirrors the guard in AreLifecycle.mount.\n */\n if (scene.isInactive) return;\n\n /**\n * 1. Render the root of this mount itself.\n */\n node.interpret();\n\n /**\n * 2. Walk the descendant subtree iteratively with an explicit enter/exit\n * stack so we can TIME-SLICE the work. The previous implementation\n * recursed via `child.mount()`, which fires onBeforeMount → onMount\n * (interpret + recurse) → onAfterMount per node and runs the whole tree\n * in one synchronous, un-yielding block. For large initial trees that\n * froze the main thread on first page load.\n *\n * We replicate the exact per-node hook ordering:\n * - enter → onBeforeMount, then (if active) interpret + queue children\n * - exit → onAfterMount (fires AFTER the node's whole subtree, i.e.\n * post-order, matching the recursive `node.mount()` contract)\n *\n * Small trees complete entirely within a single time budget and the\n * handler returns `void` synchronously — a true fast-path with NO\n * behavioural change for typical UIs. Only genuinely large trees exceed\n * the budget, at which point we yield a macrotask (letting the browser\n * paint / stay responsive) and resume the remaining work, returning a\n * Promise that resolves when the whole subtree is mounted.\n */\n interface MountFrame { node: AreHTMLNode; entered: boolean; }\n\n const stack: MountFrame[] = [];\n for (let i = node.children.length - 1; i >= 0; i--) {\n stack.push({ node: node.children[i] as AreHTMLNode, entered: false });\n }\n\n const step = (): void => {\n const frame = stack[stack.length - 1];\n const current = frame.node;\n\n if (frame.entered) {\n // Post-order exit: the whole subtree below `current` is mounted.\n stack.pop();\n current.call(AreNodeFeatures.onAfterMount, current.scope);\n return;\n }\n\n frame.entered = true;\n\n // onBeforeMount always fires (even for inactive nodes), matching the\n // recursive AreNode.mount() semantics.\n current.call(AreNodeFeatures.onBeforeMount, current.scope);\n\n if (!current.scene.isInactive) {\n current.interpret();\n // Push children in reverse so they pop in document order.\n for (let i = current.children.length - 1; i >= 0; i--) {\n stack.push({ node: current.children[i] as AreHTMLNode, entered: false });\n }\n }\n };\n\n const drive = (): void | Promise<void> => {\n const start = AreSchedulerHelper.now();\n while (stack.length > 0) {\n step();\n if (stack.length > 0 && AreSchedulerHelper.now() - start >= AreHTMLLifecycle.MOUNT_BUDGET_MS) {\n // Budget exhausted with work remaining — yield, then resume.\n return new Promise<void>((resolve, reject) => {\n AreSchedulerHelper.scheduleMacrotask(() => {\n try {\n resolve(drive());\n } catch (error) {\n reject(error);\n }\n });\n });\n }\n }\n };\n\n return drive();\n }\n\n\n @A_Feature.Extend({\n name: AreAttributeFeatures.Update,\n scope: [AreDirectiveAttribute],\n })\n updateDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n /**\n * 3. If the attribute is a directive, then we should find a component that is responsible for\n * the directive compiling logic, and call it. \n * In case component is not found we just want to log a warning, \n * since the directive may be handled by some parent component or simply is a mistake in the template.\n */\n if (directive.component) {\n feature.chain(directive.component, AreDirectiveFeatures.Update, directive.owner.scope);\n } else {\n logger?.warning(`Directive handler component not found for directive: ${directive.name}. Make sure to create a component named \"AreDirective${A_FormatterHelper.toPascalCase(directive.name)}\" to handle this directive.`);\n }\n }\n\n}"]}
@@ -11,6 +11,7 @@ import { AreDirectiveFeatures } from '@adaas/are-html/directive/AreDirective.con
11
11
  import { AreHTMLEngineContext } from './AreHTML.context';
12
12
  import { AreHTMLNode } from '../lib/AreHTMLNode/AreHTMLNode';
13
13
  import { A_Frame } from '@adaas/a-frame/core';
14
+ import { AreSchedulerHelper } from '@adaas/are-html/helpers/AreScheduler.helper';
14
15
 
15
16
  let AreHTMLLifecycle = class extends AreLifecycle {
16
17
  initComponent(node, scope, context, signalsContext, logger, ...args) {
@@ -34,10 +35,45 @@ let AreHTMLLifecycle = class extends AreLifecycle {
34
35
  logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);
35
36
  if (scene.isInactive) return;
36
37
  node.interpret();
37
- for (let i = 0; i < node.children.length; i++) {
38
- const child = node.children[i];
39
- child.mount();
38
+ const stack = [];
39
+ for (let i = node.children.length - 1; i >= 0; i--) {
40
+ stack.push({ node: node.children[i], entered: false });
40
41
  }
42
+ const step = () => {
43
+ const frame = stack[stack.length - 1];
44
+ const current = frame.node;
45
+ if (frame.entered) {
46
+ stack.pop();
47
+ current.call(AreNodeFeatures.onAfterMount, current.scope);
48
+ return;
49
+ }
50
+ frame.entered = true;
51
+ current.call(AreNodeFeatures.onBeforeMount, current.scope);
52
+ if (!current.scene.isInactive) {
53
+ current.interpret();
54
+ for (let i = current.children.length - 1; i >= 0; i--) {
55
+ stack.push({ node: current.children[i], entered: false });
56
+ }
57
+ }
58
+ };
59
+ const drive = () => {
60
+ const start = AreSchedulerHelper.now();
61
+ while (stack.length > 0) {
62
+ step();
63
+ if (stack.length > 0 && AreSchedulerHelper.now() - start >= AreHTMLLifecycle.MOUNT_BUDGET_MS) {
64
+ return new Promise((resolve, reject) => {
65
+ AreSchedulerHelper.scheduleMacrotask(() => {
66
+ try {
67
+ resolve(drive());
68
+ } catch (error) {
69
+ reject(error);
70
+ }
71
+ });
72
+ });
73
+ }
74
+ }
75
+ };
76
+ return drive();
41
77
  }
42
78
  updateDirectiveAttribute(directive, scope, feature, logger, ...args) {
43
79
  if (directive.component) {
@@ -47,6 +83,13 @@ let AreHTMLLifecycle = class extends AreLifecycle {
47
83
  }
48
84
  }
49
85
  };
86
+ /**
87
+ * Per-chunk time budget (ms) for the time-sliced initial mount walk. While
88
+ * mounting a large subtree we keep applying nodes until this much wall-clock
89
+ * time has elapsed, then yield to the browser so it can paint and process
90
+ * input before the next chunk. ~16ms targets a single animation frame.
91
+ */
92
+ AreHTMLLifecycle.MOUNT_BUDGET_MS = 16;
50
93
  __decorateClass([
51
94
  AreLifecycle.Init(AreComponentNode),
52
95
  __decorateParam(0, A_Inject(A_Caller)),
@@ -1 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4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,OAAO,CAAA,CAAA;AAAA,EAChB,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EA3Gb,gBAAA,CAuGT,SAAA,EAAA,0BAAA,EAAA,CAAA,CAAA;AAvGS,gBAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,gBAAA,CAAA","file":"AreHTML.lifecycle.mjs","sourcesContent":["import { A_Caller, A_Feature, A_FormatterHelper, A_Inject, A_Scope } from \"@adaas/a-concept\";\nimport { AreLifecycle, AreScene, AreAttributeFeatures, AreSignalsContext, AreNodeFeatures, AreFeatures } from \"@adaas/are\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { AreComponentNode } from \"@adaas/are-html/nodes/AreComponent\";\nimport { AreRootNode } from \"@adaas/are-html/nodes/AreRoot\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreHTMLEngineContext } from \"./AreHTML.context\";\nimport { AreHTMLNode } from \"../lib/AreHTMLNode/AreHTMLNode\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific lifecycle handler extending AreLifecycle. Wires DOM-aware init hooks for component nodes, root nodes, interpolations, text nodes, and directive attributes to the ARE rendering pipeline, connecting each entity to its HTML engine context and priming the scene for subsequent compilation and interpretation.'\n})\nexport class AreHTMLLifecycle extends AreLifecycle {\n\n @AreLifecycle.Init(AreComponentNode)\n initComponent(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n\n if (node.component)\n signalsContext?.subscribe(node);\n\n super.init(node, scope, context, logger, ...args);\n }\n\n\n @AreLifecycle.Init(AreRootNode)\n initRoot(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n signalsContext?.subscribe(node);\n super.init(node, scope, context, logger, ...args);\n }\n\n\n @AreLifecycle.Init(AreText)\n initText(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n const scene = new AreScene(node.aseid);\n\n scope.register(scene);\n }\n\n\n @AreLifecycle.Init(AreInterpolation)\n initInterpolation(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n const scene = new AreScene(node.aseid);\n\n scope.register(scene);\n }\n\n @A_Feature.Extend({\n name: AreNodeFeatures.onMount,\n scope: [AreHTMLNode]\n })\n mount(\n /**\n * Node to be mounted\n */\n @A_Inject(A_Caller) node: AreHTMLNode,\n /**\n * Node Content\n */\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n\n logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);\n\n /**\n * Skip mounting nodes whose scene has been deactivated (e.g. $if template nodes\n * when the condition is false). Mirrors the guard in AreLifecycle.mount.\n */\n if (scene.isInactive) return;\n\n /**\n * 1. We should simply run and render node itself.\n */\n node.interpret();\n /**\n * 2. Then go through all children of the node and mount the.\n */\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n child.mount();\n }\n }\n\n @A_Feature.Extend({\n name: AreAttributeFeatures.Update,\n scope: [AreDirectiveAttribute],\n })\n updateDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n /**\n * 3. If the attribute is a directive, then we should find a component that is responsible for\n * the directive compiling logic, and call it. \n * In case component is not found we just want to log a warning, \n * since the directive may be handled by some parent component or simply is a mistake in the template.\n */\n if (directive.component) {\n feature.chain(directive.component, AreDirectiveFeatures.Update, directive.owner.scope);\n } else {\n logger?.warning(`Directive handler component not found for directive: ${directive.name}. Make sure to create a component named \"AreDirective${A_FormatterHelper.toPascalCase(directive.name)}\" to handle this directive.`);\n }\n }\n\n}"]}
1
+ {"version":3,"sources":["../../../src/engine/AreHTML.lifecycle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBO,IAAM,gBAAA,GAAN,cAA+B,YAAA,CAAa;AAAA,EAW/C,cACwB,IAAA,EACD,KAAA,EACa,OAAA,EACH,cAAA,EACT,WACjB,IAAA,EACC;AAEJ,IAAA,IAAI,IAAA,CAAK,SAAA;AACL,MAAA,cAAA,EAAgB,UAAU,IAAI,CAAA;AAElC,IAAA,KAAA,CAAM,KAAK,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,EACpD;AAAA,EAIA,SACwB,IAAA,EACD,KAAA,EACa,OAAA,EACH,cAAA,EACT,WACjB,IAAA,EACC;AACJ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,EAClB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EAvLb,gBAAA,CAmLT,SAAA,EAAA,0BAAA,EAAA,CAAA,CAAA;AAnLS,gBAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,gBAAA,CAAA","file":"AreHTML.lifecycle.mjs","sourcesContent":["import { A_Caller, A_Feature, A_FormatterHelper, A_Inject, A_Scope } from \"@adaas/a-concept\";\nimport { AreLifecycle, AreScene, AreAttributeFeatures, AreSignalsContext, AreNodeFeatures, AreFeatures } from \"@adaas/are\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { AreComponentNode } from \"@adaas/are-html/nodes/AreComponent\";\nimport { AreRootNode } from \"@adaas/are-html/nodes/AreRoot\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreHTMLEngineContext } from \"./AreHTML.context\";\nimport { AreHTMLNode } from \"../lib/AreHTMLNode/AreHTMLNode\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreSchedulerHelper } from \"@adaas/are-html/helpers/AreScheduler.helper\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific lifecycle handler extending AreLifecycle. Wires DOM-aware init hooks for component nodes, root nodes, interpolations, text nodes, and directive attributes to the ARE rendering pipeline, connecting each entity to its HTML engine context and priming the scene for subsequent compilation and interpretation.'\n})\nexport class AreHTMLLifecycle extends AreLifecycle {\n\n /**\n * Per-chunk time budget (ms) for the time-sliced initial mount walk. While\n * mounting a large subtree we keep applying nodes until this much wall-clock\n * time has elapsed, then yield to the browser so it can paint and process\n * input before the next chunk. ~16ms targets a single animation frame.\n */\n private static readonly MOUNT_BUDGET_MS = 16;\n\n @AreLifecycle.Init(AreComponentNode)\n initComponent(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n\n if (node.component)\n signalsContext?.subscribe(node);\n\n super.init(node, scope, context, logger, ...args);\n }\n\n\n @AreLifecycle.Init(AreRootNode)\n initRoot(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n signalsContext?.subscribe(node);\n super.init(node, scope, context, logger, ...args);\n }\n\n\n @AreLifecycle.Init(AreText)\n initText(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n const scene = new AreScene(node.aseid);\n\n scope.register(scene);\n }\n\n\n @AreLifecycle.Init(AreInterpolation)\n initInterpolation(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n const scene = new AreScene(node.aseid);\n\n scope.register(scene);\n }\n\n @A_Feature.Extend({\n name: AreNodeFeatures.onMount,\n scope: [AreHTMLNode]\n })\n mount(\n /**\n * Node to be mounted\n */\n @A_Inject(A_Caller) node: AreHTMLNode,\n /**\n * Node Content\n */\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void | Promise<void> {\n\n logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);\n\n /**\n * Skip mounting nodes whose scene has been deactivated (e.g. $if template nodes\n * when the condition is false). Mirrors the guard in AreLifecycle.mount.\n */\n if (scene.isInactive) return;\n\n /**\n * 1. Render the root of this mount itself.\n */\n node.interpret();\n\n /**\n * 2. Walk the descendant subtree iteratively with an explicit enter/exit\n * stack so we can TIME-SLICE the work. The previous implementation\n * recursed via `child.mount()`, which fires onBeforeMount → onMount\n * (interpret + recurse) → onAfterMount per node and runs the whole tree\n * in one synchronous, un-yielding block. For large initial trees that\n * froze the main thread on first page load.\n *\n * We replicate the exact per-node hook ordering:\n * - enter → onBeforeMount, then (if active) interpret + queue children\n * - exit → onAfterMount (fires AFTER the node's whole subtree, i.e.\n * post-order, matching the recursive `node.mount()` contract)\n *\n * Small trees complete entirely within a single time budget and the\n * handler returns `void` synchronously — a true fast-path with NO\n * behavioural change for typical UIs. Only genuinely large trees exceed\n * the budget, at which point we yield a macrotask (letting the browser\n * paint / stay responsive) and resume the remaining work, returning a\n * Promise that resolves when the whole subtree is mounted.\n */\n interface MountFrame { node: AreHTMLNode; entered: boolean; }\n\n const stack: MountFrame[] = [];\n for (let i = node.children.length - 1; i >= 0; i--) {\n stack.push({ node: node.children[i] as AreHTMLNode, entered: false });\n }\n\n const step = (): void => {\n const frame = stack[stack.length - 1];\n const current = frame.node;\n\n if (frame.entered) {\n // Post-order exit: the whole subtree below `current` is mounted.\n stack.pop();\n current.call(AreNodeFeatures.onAfterMount, current.scope);\n return;\n }\n\n frame.entered = true;\n\n // onBeforeMount always fires (even for inactive nodes), matching the\n // recursive AreNode.mount() semantics.\n current.call(AreNodeFeatures.onBeforeMount, current.scope);\n\n if (!current.scene.isInactive) {\n current.interpret();\n // Push children in reverse so they pop in document order.\n for (let i = current.children.length - 1; i >= 0; i--) {\n stack.push({ node: current.children[i] as AreHTMLNode, entered: false });\n }\n }\n };\n\n const drive = (): void | Promise<void> => {\n const start = AreSchedulerHelper.now();\n while (stack.length > 0) {\n step();\n if (stack.length > 0 && AreSchedulerHelper.now() - start >= AreHTMLLifecycle.MOUNT_BUDGET_MS) {\n // Budget exhausted with work remaining — yield, then resume.\n return new Promise<void>((resolve, reject) => {\n AreSchedulerHelper.scheduleMacrotask(() => {\n try {\n resolve(drive());\n } catch (error) {\n reject(error);\n }\n });\n });\n }\n }\n };\n\n return drive();\n }\n\n\n @A_Feature.Extend({\n name: AreAttributeFeatures.Update,\n scope: [AreDirectiveAttribute],\n })\n updateDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n /**\n * 3. If the attribute is a directive, then we should find a component that is responsible for\n * the directive compiling logic, and call it. \n * In case component is not found we just want to log a warning, \n * since the directive may be handled by some parent component or simply is a mistake in the template.\n */\n if (directive.component) {\n feature.chain(directive.component, AreDirectiveFeatures.Update, directive.owner.scope);\n } else {\n logger?.warning(`Directive handler component not found for directive: ${directive.name}. Make sure to create a component named \"AreDirective${A_FormatterHelper.toPascalCase(directive.name)}\" to handle this directive.`);\n }\n }\n\n}"]}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * AreSchedulerHelper
3
+ *
4
+ * Cooperative time-slicing primitives shared by the chunked (async) render
5
+ * paths — the initial whole-page mount walk and the `$for` directive. Both need
6
+ * the SAME two capabilities:
7
+ * 1. a high-resolution clock to measure how long the current chunk has run, and
8
+ * 2. a zero-delay macrotask scheduler to yield to the browser between chunks
9
+ * so it can paint and process input before resuming work.
10
+ *
11
+ * Keeping these in one helper avoids duplicating the `MessageChannel` plumbing
12
+ * across directives/lifecycle and gives a single place to tune the strategy.
13
+ */
14
+ declare class AreSchedulerHelper {
15
+ /**
16
+ * Lazily-created `MessageChannel` used to post zero-delay macrotasks.
17
+ * Created on first use so non-DOM environments (tests / SSR) that never
18
+ * schedule a chunk pay nothing.
19
+ */
20
+ private static _channel?;
21
+ /** FIFO queue of callbacks waiting for their posted macrotask to fire. */
22
+ private static readonly _queue;
23
+ /**
24
+ * High-resolution wall-clock time in milliseconds. Uses `performance.now()`
25
+ * when available (monotonic, sub-millisecond), falling back to `Date.now()`.
26
+ */
27
+ static now(): number;
28
+ /**
29
+ * Schedule `fn` to run on the next macrotask.
30
+ *
31
+ * `MessageChannel` yields a true macrotask without the ~4ms clamp that nested
32
+ * `setTimeout(0)` calls incur, so the browser can paint between chunks with
33
+ * minimal scheduling overhead. Falls back to `setTimeout` in non-DOM
34
+ * environments (e.g. tests / SSR).
35
+ */
36
+ static scheduleMacrotask(fn: () => void): void;
37
+ }
38
+
39
+ export { AreSchedulerHelper };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * AreSchedulerHelper
3
+ *
4
+ * Cooperative time-slicing primitives shared by the chunked (async) render
5
+ * paths — the initial whole-page mount walk and the `$for` directive. Both need
6
+ * the SAME two capabilities:
7
+ * 1. a high-resolution clock to measure how long the current chunk has run, and
8
+ * 2. a zero-delay macrotask scheduler to yield to the browser between chunks
9
+ * so it can paint and process input before resuming work.
10
+ *
11
+ * Keeping these in one helper avoids duplicating the `MessageChannel` plumbing
12
+ * across directives/lifecycle and gives a single place to tune the strategy.
13
+ */
14
+ declare class AreSchedulerHelper {
15
+ /**
16
+ * Lazily-created `MessageChannel` used to post zero-delay macrotasks.
17
+ * Created on first use so non-DOM environments (tests / SSR) that never
18
+ * schedule a chunk pay nothing.
19
+ */
20
+ private static _channel?;
21
+ /** FIFO queue of callbacks waiting for their posted macrotask to fire. */
22
+ private static readonly _queue;
23
+ /**
24
+ * High-resolution wall-clock time in milliseconds. Uses `performance.now()`
25
+ * when available (monotonic, sub-millisecond), falling back to `Date.now()`.
26
+ */
27
+ static now(): number;
28
+ /**
29
+ * Schedule `fn` to run on the next macrotask.
30
+ *
31
+ * `MessageChannel` yields a true macrotask without the ~4ms clamp that nested
32
+ * `setTimeout(0)` calls incur, so the browser can paint between chunks with
33
+ * minimal scheduling overhead. Falls back to `setTimeout` in non-DOM
34
+ * environments (e.g. tests / SSR).
35
+ */
36
+ static scheduleMacrotask(fn: () => void): void;
37
+ }
38
+
39
+ export { AreSchedulerHelper };
@@ -0,0 +1,40 @@
1
+ 'use strict';
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
+ exports.AreSchedulerHelper = AreSchedulerHelper;
39
+ //# sourceMappingURL=AreScheduler.helper.js.map
40
+ //# sourceMappingURL=AreScheduler.helper.js.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.js","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"]}