@adaas/are-html 0.0.22 → 0.0.24

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 (191) hide show
  1. package/dist/browser/index.d.mts +194 -10
  2. package/dist/browser/index.mjs +696 -245
  3. package/dist/browser/index.mjs.map +1 -1
  4. package/dist/node/{AreBinding.attribute-doUvtOjc.d.mts → AreBinding.attribute-BWzEIw6H.d.mts} +45 -0
  5. package/dist/node/{AreBinding.attribute-Bm5LlOyE.d.ts → AreBinding.attribute-GpT-5Qmf.d.ts} +45 -0
  6. package/dist/node/attributes/AreBinding.attribute.d.mts +1 -1
  7. package/dist/node/attributes/AreBinding.attribute.d.ts +1 -1
  8. package/dist/node/attributes/AreDirective.attribute.d.mts +1 -1
  9. package/dist/node/attributes/AreDirective.attribute.d.ts +1 -1
  10. package/dist/node/attributes/AreEvent.attribute.d.mts +1 -1
  11. package/dist/node/attributes/AreEvent.attribute.d.ts +1 -1
  12. package/dist/node/attributes/AreStatic.attribute.d.mts +1 -1
  13. package/dist/node/attributes/AreStatic.attribute.d.ts +1 -1
  14. package/dist/node/directives/AreDirectiveFor.directive.d.mts +18 -1
  15. package/dist/node/directives/AreDirectiveFor.directive.d.ts +18 -1
  16. package/dist/node/directives/AreDirectiveFor.directive.js +57 -9
  17. package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
  18. package/dist/node/directives/AreDirectiveFor.directive.mjs +57 -9
  19. package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
  20. package/dist/node/directives/AreDirectiveIf.directive.d.mts +18 -2
  21. package/dist/node/directives/AreDirectiveIf.directive.d.ts +18 -2
  22. package/dist/node/directives/AreDirectiveIf.directive.js +29 -6
  23. package/dist/node/directives/AreDirectiveIf.directive.js.map +1 -1
  24. package/dist/node/directives/AreDirectiveIf.directive.mjs +29 -6
  25. package/dist/node/directives/AreDirectiveIf.directive.mjs.map +1 -1
  26. package/dist/node/directives/AreDirectiveShow.directive.d.mts +1 -1
  27. package/dist/node/directives/AreDirectiveShow.directive.d.ts +1 -1
  28. package/dist/node/engine/AreHTML.compiler.d.mts +4 -2
  29. package/dist/node/engine/AreHTML.compiler.d.ts +4 -2
  30. package/dist/node/engine/AreHTML.compiler.js +11 -4
  31. package/dist/node/engine/AreHTML.compiler.js.map +1 -1
  32. package/dist/node/engine/AreHTML.compiler.mjs +11 -4
  33. package/dist/node/engine/AreHTML.compiler.mjs.map +1 -1
  34. package/dist/node/engine/AreHTML.constants.d.mts +33 -1
  35. package/dist/node/engine/AreHTML.constants.d.ts +33 -1
  36. package/dist/node/engine/AreHTML.constants.js +166 -0
  37. package/dist/node/engine/AreHTML.constants.js.map +1 -1
  38. package/dist/node/engine/AreHTML.constants.mjs +165 -1
  39. package/dist/node/engine/AreHTML.constants.mjs.map +1 -1
  40. package/dist/node/engine/AreHTML.context.d.mts +66 -0
  41. package/dist/node/engine/AreHTML.context.d.ts +66 -0
  42. package/dist/node/engine/AreHTML.context.js +98 -0
  43. package/dist/node/engine/AreHTML.context.js.map +1 -1
  44. package/dist/node/engine/AreHTML.context.mjs +98 -0
  45. package/dist/node/engine/AreHTML.context.mjs.map +1 -1
  46. package/dist/node/engine/AreHTML.interpreter.d.mts +3 -0
  47. package/dist/node/engine/AreHTML.interpreter.d.ts +3 -0
  48. package/dist/node/engine/AreHTML.interpreter.js +66 -10
  49. package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
  50. package/dist/node/engine/AreHTML.interpreter.mjs +66 -10
  51. package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
  52. package/dist/node/engine/AreHTML.lifecycle.d.mts +1 -8
  53. package/dist/node/engine/AreHTML.lifecycle.d.ts +1 -8
  54. package/dist/node/engine/AreHTML.lifecycle.js +29 -44
  55. package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
  56. package/dist/node/engine/AreHTML.lifecycle.mjs +29 -44
  57. package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
  58. package/dist/node/engine/AreHTML.tokenizer.d.mts +1 -1
  59. package/dist/node/engine/AreHTML.tokenizer.d.ts +1 -1
  60. package/dist/node/engine/AreHTML.tokenizer.js +7 -1
  61. package/dist/node/engine/AreHTML.tokenizer.js.map +1 -1
  62. package/dist/node/engine/AreHTML.tokenizer.mjs +7 -1
  63. package/dist/node/engine/AreHTML.tokenizer.mjs.map +1 -1
  64. package/dist/node/engine/AreHTML.transformer.d.mts +1 -1
  65. package/dist/node/engine/AreHTML.transformer.d.ts +1 -1
  66. package/dist/node/index.d.mts +4 -3
  67. package/dist/node/index.d.ts +4 -3
  68. package/dist/node/index.js +7 -0
  69. package/dist/node/index.mjs +1 -0
  70. package/dist/node/instructions/AddStaticHTML.instruction.d.mts +8 -0
  71. package/dist/node/instructions/AddStaticHTML.instruction.d.ts +8 -0
  72. package/dist/node/instructions/AddStaticHTML.instruction.js +31 -0
  73. package/dist/node/instructions/AddStaticHTML.instruction.js.map +1 -0
  74. package/dist/node/instructions/AddStaticHTML.instruction.mjs +24 -0
  75. package/dist/node/instructions/AddStaticHTML.instruction.mjs.map +1 -0
  76. package/dist/node/instructions/AreHTML.instructions.constants.d.mts +1 -0
  77. package/dist/node/instructions/AreHTML.instructions.constants.d.ts +1 -0
  78. package/dist/node/instructions/AreHTML.instructions.constants.js +1 -0
  79. package/dist/node/instructions/AreHTML.instructions.constants.js.map +1 -1
  80. package/dist/node/instructions/AreHTML.instructions.constants.mjs +1 -0
  81. package/dist/node/instructions/AreHTML.instructions.constants.mjs.map +1 -1
  82. package/dist/node/instructions/AreHTML.instructions.types.d.mts +9 -1
  83. package/dist/node/instructions/AreHTML.instructions.types.d.ts +9 -1
  84. package/dist/node/lib/AreDirective/AreDirective.component.d.mts +1 -1
  85. package/dist/node/lib/AreDirective/AreDirective.component.d.ts +1 -1
  86. package/dist/node/lib/AreDirective/AreDirective.types.d.mts +1 -1
  87. package/dist/node/lib/AreDirective/AreDirective.types.d.ts +1 -1
  88. package/dist/node/lib/AreHTML/AreHTML.tokenizer.d.mts +1 -1
  89. package/dist/node/lib/AreHTML/AreHTML.tokenizer.d.ts +1 -1
  90. package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.d.mts +1 -1
  91. package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.d.ts +1 -1
  92. package/dist/node/lib/AreHTMLNode/AreHTMLNode.d.mts +1 -1
  93. package/dist/node/lib/AreHTMLNode/AreHTMLNode.d.ts +1 -1
  94. package/dist/node/lib/AreHTMLNode/AreHTMLNode.js +51 -0
  95. package/dist/node/lib/AreHTMLNode/AreHTMLNode.js.map +1 -1
  96. package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs +51 -0
  97. package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs.map +1 -1
  98. package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
  99. package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
  100. package/dist/node/nodes/AreComment.d.mts +1 -1
  101. package/dist/node/nodes/AreComment.d.ts +1 -1
  102. package/dist/node/nodes/AreComponent.d.mts +1 -1
  103. package/dist/node/nodes/AreComponent.d.ts +1 -1
  104. package/dist/node/nodes/AreInterpolation.d.mts +1 -1
  105. package/dist/node/nodes/AreInterpolation.d.ts +1 -1
  106. package/dist/node/nodes/AreRoot.d.mts +1 -1
  107. package/dist/node/nodes/AreRoot.d.ts +1 -1
  108. package/dist/node/nodes/AreText.d.mts +1 -1
  109. package/dist/node/nodes/AreText.d.ts +1 -1
  110. package/examples/dashboard/concept.ts +1 -1
  111. package/examples/dashboard/dist/index.html +1 -1
  112. package/examples/dashboard/dist/{mqh9ryml-xat335.js → mqiw5sqa-ypckmj.js} +403 -57
  113. package/examples/for-perf/dist/index.html +1 -1
  114. package/examples/for-perf/dist/{mqh9ryfo-6a8d0o.js → mqp8i2py-vltsx0.js} +3030 -2474
  115. package/examples/lazy-loading/README.md +76 -0
  116. package/examples/lazy-loading/concept.ts +55 -0
  117. package/examples/lazy-loading/containers/UI.container.ts +215 -0
  118. package/examples/lazy-loading/dist/app.js +3803 -0
  119. package/examples/{for-perf/dist/mqh9ryfq-4pf5cv.js → lazy-loading/dist/chunks/chunk-6K72IBO4.js} +2708 -5476
  120. package/examples/lazy-loading/dist/index.html +36 -0
  121. package/examples/lazy-loading/dist/lazy/about-page.js +59 -0
  122. package/examples/lazy-loading/dist/lazy/reports-page.js +65 -0
  123. package/examples/lazy-loading/dist/lazy/settings-page.js +54 -0
  124. package/examples/lazy-loading/public/index.html +36 -0
  125. package/examples/lazy-loading/src/components/AppShell.component.ts +44 -0
  126. package/examples/lazy-loading/src/components/HomePage.component.ts +59 -0
  127. package/examples/lazy-loading/src/components/LazyOutlet.component.ts +108 -0
  128. package/examples/lazy-loading/src/components/NavBar.component.ts +98 -0
  129. package/examples/lazy-loading/src/concept.ts +116 -0
  130. package/examples/lazy-loading/src/lazy/AboutPage.component.ts +54 -0
  131. package/examples/lazy-loading/src/lazy/ReportsPage.component.ts +56 -0
  132. package/examples/lazy-loading/src/lazy/SettingsPage.component.ts +45 -0
  133. package/examples/lazy-loading/src/runtime/ComponentManifest.fragment.ts +61 -0
  134. package/examples/lazy-loading/src/runtime/LazyComponentResolver.fragment.ts +77 -0
  135. package/examples/os-desktop/README.md +91 -0
  136. package/examples/os-desktop/concept.ts +54 -0
  137. package/examples/os-desktop/containers/OS.container.ts +198 -0
  138. package/examples/os-desktop/containers/apps/AppBackend.ts +29 -0
  139. package/examples/os-desktop/containers/apps/GanttApp.backend.ts +56 -0
  140. package/examples/os-desktop/containers/apps/MarketingApp.backend.ts +68 -0
  141. package/examples/os-desktop/dist/app.js +4410 -0
  142. package/examples/os-desktop/dist/apps/gantt/app.js +271 -0
  143. package/examples/os-desktop/dist/apps/marketing/app.js +346 -0
  144. package/examples/{for-perf/dist/mqh9ryde-m243t8.js → os-desktop/dist/chunks/chunk-6K72IBO4.js} +2708 -5476
  145. package/examples/os-desktop/dist/chunks/chunk-EIIGUL6N.js +30 -0
  146. package/examples/os-desktop/dist/chunks/chunk-WOH7L5UR.js +30 -0
  147. package/examples/os-desktop/dist/index.html +33 -0
  148. package/examples/os-desktop/public/index.html +33 -0
  149. package/examples/os-desktop/src/apps/gantt/GanttApp.component.ts +41 -0
  150. package/examples/os-desktop/src/apps/gantt/GanttChart.component.ts +126 -0
  151. package/examples/os-desktop/src/apps/gantt/GanttStore.ts +47 -0
  152. package/examples/os-desktop/src/apps/gantt/GanttToolbar.component.ts +73 -0
  153. package/examples/os-desktop/src/apps/gantt/index.ts +13 -0
  154. package/examples/os-desktop/src/apps/marketing/MarketingApp.component.ts +53 -0
  155. package/examples/os-desktop/src/apps/marketing/MarketingStore.ts +34 -0
  156. package/examples/os-desktop/src/apps/marketing/PostEditor.component.ts +153 -0
  157. package/examples/os-desktop/src/apps/marketing/PostPreview.component.ts +110 -0
  158. package/examples/os-desktop/src/apps/marketing/index.ts +16 -0
  159. package/examples/os-desktop/src/concept.ts +126 -0
  160. package/examples/os-desktop/src/os/AppStage.component.ts +112 -0
  161. package/examples/os-desktop/src/os/AppWindow.component.ts +102 -0
  162. package/examples/os-desktop/src/os/Desktop.component.ts +106 -0
  163. package/examples/os-desktop/src/os/Dock.component.ts +174 -0
  164. package/examples/os-desktop/src/os/Hud.component.ts +83 -0
  165. package/examples/os-desktop/src/os/Launchpad.component.ts +191 -0
  166. package/examples/os-desktop/src/os/MenuBar.component.ts +156 -0
  167. package/examples/os-desktop/src/runtime/AppComponentResolver.fragment.ts +121 -0
  168. package/examples/os-desktop/src/runtime/AppRegistry.fragment.ts +104 -0
  169. package/examples/os-desktop/src/signals/MouseState.signal.ts +34 -0
  170. package/examples/os-desktop/src/signals/OSRoute.signal.ts +37 -0
  171. package/examples/os-desktop/src/signals/SelectionState.signal.ts +34 -0
  172. package/examples/signal-routing/dist/index.html +1 -1
  173. package/examples/signal-routing/dist/{mqh9ryc9-dkcbkx.js → mqp8hgce-4d6rh0.js} +3196 -2640
  174. package/package.json +13 -9
  175. package/src/directives/AreDirectiveFor.directive.ts +99 -16
  176. package/src/directives/AreDirectiveIf.directive.ts +33 -4
  177. package/src/engine/AreHTML.compiler.ts +25 -2
  178. package/src/engine/AreHTML.constants.ts +142 -0
  179. package/src/engine/AreHTML.context.ts +112 -0
  180. package/src/engine/AreHTML.interpreter.ts +114 -13
  181. package/src/engine/AreHTML.lifecycle.ts +81 -74
  182. package/src/engine/AreHTML.tokenizer.ts +30 -1
  183. package/src/index.ts +1 -0
  184. package/src/instructions/AddStaticHTML.instruction.ts +23 -0
  185. package/src/instructions/AreHTML.instructions.constants.ts +1 -0
  186. package/src/instructions/AreHTML.instructions.types.ts +9 -0
  187. package/src/lib/AreHTMLNode/AreHTMLNode.ts +74 -0
  188. package/src/lib/AreRoot/AreRoot.component.ts +3 -3
  189. package/tests/PropPropagation.test.ts +181 -0
  190. package/tests/StaticIsland.test.ts +115 -0
  191. package/tests/jest.setup.ts +11 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/directives/AreDirectiveIf.directive.ts"],"names":[],"mappings":";;;;;;;;;AAkCO,IAAM,cAAA,GAAN,cAA6B,YAAA,CAAa;AAAA,EAI7C,UACwB,SAAA,EACD,KAAA,EAEC,KAAA,EACA,KAAA,EACA,WACjB,IAAA,EACL;AACE,IAAA,MAAA,CAAO,MAAM,CAAA,+BAAA,EAAkC,SAAA,CAAU,MAAM,KAAA,CAAM,QAAA,EAAU,CAAA,CAAA,CAAG,CAAA;AAElF,IAAA,MAAM,OAAO,SAAA,CAAU,KAAA;AAKvB,IAAA,MAAM,UAAA,GAAa,KAAK,cAAA,EAAe;AAEvC,IAAA,MAAM,MAAA,GAAS,WAAW,UAAA,CAAW,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,UAAU,IAAI,CAAA;AAExE,IAAA,IAAI,MAAA,EAAQ;AACR,MAAA,UAAA,CAAW,KAAA,CAAM,WAAW,MAAM,CAAA;AAClC,MAAA,IAAA,CAAK,KAAA,CAAM,SAAS,MAAM,CAAA;AAAA,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A,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,cAAA,CAAA","file":"AreDirectiveIf.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 { AreScene, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AddCommentInstruction } from \"@adaas/are-html/instructions/AddComment.instruction\";\nimport { AreDirectiveContext } from \"@adaas/are-html/directive/AreDirective.context\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\n\n\n\n/**\n * `$if` directive — conditionally renders a node based on an expression.\n *\n * ⚠️ Known limitation: do NOT use `$if` and `$for` on the SAME element.\n * Doing so produces duplicated DOM on toggle because the two directives\n * share an owner node and clone its scope independently. Wrap one in a\n * parent element instead, e.g.:\n *\n * <div $if=\"visible\">\n * <li $for=\"item in items\">{{item.name}}</li>\n * </div>\n *\n * or\n *\n * <ul $for=\"item in items\">\n * <li $if=\"item.visible\">{{item.name}}</li>\n * </ul>\n */\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'Built-in $if directive. Conditionally renders a subtree based on a store expression. Replaces the target element with a stable comment anchor when the condition is false and restores the fully rendered subtree when it becomes true, preventing any leaking of the host element between states.'\n})\n@AreDirective.Priority(2)\nexport class AreDirectiveIf 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\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 logger.debug(`[Transform] directive $IF for <${attribute.owner.aseid.toString()}>`)\n\n const node = attribute.owner;\n\n /**\n * We have to keep this node as a group node, and copy all data into the child node that would be actual node. \n */\n const ifTemplate = node.cloneWithScope();\n\n const ifAttr = ifTemplate.attributes.find(d => d.name === attribute.name);\n\n if (ifAttr) {\n ifTemplate.scope.deregister(ifAttr);\n node.scope.register(ifAttr);\n }\n\n node.init();\n\n node.addChild(ifTemplate);\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 = ifTemplate.scope.resolveFlat(AreDirectiveContext);\n\n // if (!directiveContext) {\n // directiveContext = new AreDirectiveContext(ifTemplate.aseid);\n // ifTemplate.scope.register(directiveContext);\n // }\n\n ifTemplate.scene.deactivate();\n\n attribute.template = ifTemplate;\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 @A_Inject(AreSyntax) syntax: AreSyntax,\n\n @A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,\n ...args: any[]\n ): void {\n /**\n * 1. Extract the value from the store based on the attribute content\n * (which is the path to the value in the store)\n */\n attribute.value = syntax.evaluate(attribute.content, store, {\n ...(directiveContext?.scope || {}),\n });\n\n /**\n * 2. If the value is falsy, remove the node from the scene by planning a RemoveElement instruction.\n * If the value is truthy, ensure the node is in the scene by planning an AddElement instruction if it's not already planned.\n */\n const hostInstruction = scene.host!;\n const commentIdentifier = ` --- if: ${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 if (attribute.value)\n attribute.template!.scene.activate();\n else\n attribute.template!.scene.deactivate();\n }\n\n\n\n @AreDirective.Update\n update(\n @A_Inject(A_Caller) attribute: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreSyntax) syntax: AreSyntax,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ): void {\n /**\n * 1. Extract the value from the store based on the attribute content\n * (which is the path to the value in the store)\n */\n const previous = !!attribute.value;\n const next = !!syntax.evaluate(attribute.content, store);\n attribute.value = next;\n\n // Skip when truthiness has not changed — avoids redundant mount/unmount.\n if (previous === next) return;\n\n if (next) {\n attribute.template!.scene.activate();\n attribute.template!.mount();\n } else {\n attribute.template!.unmount();\n attribute.template!.scene.deactivate();\n }\n }\n\n}"]}
1
+ {"version":3,"sources":["../../../src/directives/AreDirectiveIf.directive.ts"],"names":[],"mappings":";;;;;;;;;AAkCO,IAAM,cAAA,GAAN,cAA6B,YAAA,CAAa;AAAA,EAI7C,UACwB,SAAA,EACD,KAAA,EAEC,KAAA,EACA,KAAA,EACA,WACjB,IAAA,EACL;AACE,IAAA,MAAA,CAAO,MAAM,CAAA,+BAAA,EAAkC,SAAA,CAAU,MAAM,KAAA,CAAM,QAAA,EAAU,CAAA,CAAA,CAAG,CAAA;AAElF,IAAA,MAAM,OAAO,SAAA,CAAU,KAAA;AAKvB,IAAA,MAAM,UAAA,GAAa,KAAK,cAAA,EAAe;AAEvC,IAAA,MAAM,MAAA,GAAS,WAAW,UAAA,CAAW,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,UAAU,IAAI,CAAA;AAExE,IAAA,IAAI,MAAA,EAAQ;AACR,MAAA,UAAA,CAAW,KAAA,CAAM,WAAW,MAAM,CAAA;AAClC,MAAA,IAAA,CAAK,KAAA,CAAM,SAAS,MAAM,CAAA;AAAA,IAC9B;AAEA,IAAA,IAAA,CAAK,IAAA,EAAK;AAEV,IAAA,IAAA,CAAK,SAAS,UAAU,CAAA;AAYxB,IAAA,UAAA,CAAW,MAAM,UAAA,EAA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A,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,OAAO,CAAA,CAAA;AAAA,EAChB,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,mBAAmB,CAAA;AAAA,CAAA,EA7FxB,cAAA,CAuFT,SAAA,EAAA,QAAA,EAAA,CAAA,CAAA;AAvFS,cAAA,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,cAAA,CAAA","file":"AreDirectiveIf.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 { AreScene, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AddCommentInstruction } from \"@adaas/are-html/instructions/AddComment.instruction\";\nimport { AreDirectiveContext } from \"@adaas/are-html/directive/AreDirective.context\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\n\n\n\n/**\n * `$if` directive — conditionally renders a node based on an expression.\n *\n * ⚠️ Known limitation: do NOT use `$if` and `$for` on the SAME element.\n * Doing so produces duplicated DOM on toggle because the two directives\n * share an owner node and clone its scope independently. Wrap one in a\n * parent element instead, e.g.:\n *\n * <div $if=\"visible\">\n * <li $for=\"item in items\">{{item.name}}</li>\n * </div>\n *\n * or\n *\n * <ul $for=\"item in items\">\n * <li $if=\"item.visible\">{{item.name}}</li>\n * </ul>\n */\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'Built-in $if directive. Conditionally renders a subtree based on a store expression. Replaces the target element with a stable comment anchor when the condition is false and restores the fully rendered subtree when it becomes true, preventing any leaking of the host element between states.'\n})\n@AreDirective.Priority(2)\nexport class AreDirectiveIf 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\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 logger.debug(`[Transform] directive $IF for <${attribute.owner.aseid.toString()}>`)\n\n const node = attribute.owner;\n\n /**\n * We have to keep this node as a group node, and copy all data into the child node that would be actual node. \n */\n const ifTemplate = node.cloneWithScope();\n\n const ifAttr = ifTemplate.attributes.find(d => d.name === attribute.name);\n\n if (ifAttr) {\n ifTemplate.scope.deregister(ifAttr);\n node.scope.register(ifAttr);\n }\n\n node.init();\n\n node.addChild(ifTemplate);\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 = ifTemplate.scope.resolveFlat(AreDirectiveContext);\n\n // if (!directiveContext) {\n // directiveContext = new AreDirectiveContext(ifTemplate.aseid);\n // ifTemplate.scope.register(directiveContext);\n // }\n\n ifTemplate.scene.deactivate();\n\n attribute.template = ifTemplate;\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 @A_Inject(AreSyntax) syntax: AreSyntax,\n\n @A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,\n ...args: any[]\n ): void {\n /**\n * 1. Extract the value from the store based on the attribute content\n * (which is the path to the value in the store)\n */\n attribute.value = this.evaluateCondition(syntax, attribute, store, directiveContext);\n\n /**\n * 2. If the value is falsy, remove the node from the scene by planning a RemoveElement instruction.\n * If the value is truthy, ensure the node is in the scene by planning an AddElement instruction if it's not already planned.\n */\n const hostInstruction = scene.host!;\n const commentIdentifier = ` --- if: ${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 if (attribute.value)\n attribute.template!.scene.activate();\n else\n attribute.template!.scene.deactivate();\n }\n\n\n\n @AreDirective.Update\n update(\n @A_Inject(A_Caller) attribute: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(AreSyntax) syntax: AreSyntax,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,\n ...args: any[]\n ): void {\n /**\n * 1. Extract the value from the store based on the attribute content\n * (which is the path to the value in the store)\n */\n const previous = !!attribute.value;\n const next = this.evaluateCondition(syntax, attribute, store, directiveContext);\n attribute.value = next;\n\n // Skip when truthiness has not changed — avoids redundant mount/unmount.\n if (previous === next) return;\n\n if (next) {\n attribute.template!.scene.activate();\n attribute.template!.mount();\n } else {\n attribute.template!.unmount();\n attribute.template!.scene.deactivate();\n }\n }\n\n /**\n * Evaluates the `$if` condition defensively.\n *\n * A condition can reference data that is momentarily unavailable — most\n * commonly a nested `$if` (e.g. `$if=\"selected.fields.length\"`) living\n * inside a parent `$if=\"selected\"` whose object has just become `null`.\n * Because the nested directive is still subscribed to the store, its\n * update fires on that same change and the raw expression would throw\n * `Cannot read properties of null`, crashing the whole update pipeline.\n *\n * Treating an evaluation error as `false` is the correct contract for a\n * conditional: if the condition cannot be resolved, the subtree simply\n * stays hidden until the referenced data is present again (at which point\n * the parent `$if` re-activates and re-evaluates this one).\n */\n private evaluateCondition(\n syntax: AreSyntax,\n attribute: AreDirectiveAttribute,\n store: AreStore,\n directiveContext?: AreDirectiveContext,\n ): boolean {\n try {\n return !!syntax.evaluate(attribute.content, store, {\n ...(directiveContext?.scope || {}),\n });\n } catch {\n return false;\n }\n }\n\n}"]}
@@ -1,5 +1,5 @@
1
1
  import { A_Logger } from '@adaas/a-utils/a-logger';
2
- import { a as AreDirective, b as AreDirectiveAttribute } from '../AreBinding.attribute-doUvtOjc.mjs';
2
+ import { a as AreDirective, b as AreDirectiveAttribute } from '../AreBinding.attribute-BWzEIw6H.mjs';
3
3
  import { AreStore, AreScene, AreSyntax } from '@adaas/are';
4
4
  import { AreDirectiveContext } from '../lib/AreDirective/AreDirective.context.mjs';
5
5
  import '@adaas/a-concept';
@@ -1,5 +1,5 @@
1
1
  import { A_Logger } from '@adaas/a-utils/a-logger';
2
- import { a as AreDirective, b as AreDirectiveAttribute } from '../AreBinding.attribute-Bm5LlOyE.js';
2
+ import { a as AreDirective, b as AreDirectiveAttribute } from '../AreBinding.attribute-GpT-5Qmf.js';
3
3
  import { AreStore, AreScene, AreSyntax } from '@adaas/are';
4
4
  import { AreDirectiveContext } from '../lib/AreDirective/AreDirective.context.js';
5
5
  import '@adaas/a-concept';
@@ -1,10 +1,12 @@
1
1
  import { A_Feature } from '@adaas/a-concept';
2
2
  import { A_Logger } from '@adaas/a-utils/a-logger';
3
3
  import { AreCompiler, AreScene, AreStore, AreSyntax } from '@adaas/are';
4
- import { e as AreHTMLNode, f as AreStaticAttribute, b as AreDirectiveAttribute, c as AreEventAttribute, A as AreBindingAttribute } from '../AreBinding.attribute-doUvtOjc.mjs';
4
+ import { e as AreHTMLNode, f as AreStaticAttribute, b as AreDirectiveAttribute, c as AreEventAttribute, A as AreBindingAttribute } from '../AreBinding.attribute-BWzEIw6H.mjs';
5
5
  import { AreInterpolation } from '../nodes/AreInterpolation.mjs';
6
6
  import { AreText } from '../nodes/AreText.mjs';
7
+ import { AreDirectiveContext } from '../lib/AreDirective/AreDirective.context.mjs';
7
8
  import '../lib/AreStyle/AreStyle.context.mjs';
9
+ import '@adaas/a-utils/a-execution';
8
10
 
9
11
  declare class AreHTMLCompiler extends AreCompiler {
10
12
  /**
@@ -28,7 +30,7 @@ declare class AreHTMLCompiler extends AreCompiler {
28
30
  compileStaticAttribute(attribute: AreStaticAttribute, scene: AreScene, ...args: any[]): void;
29
31
  compileDirectiveAttribute(directive: AreDirectiveAttribute, store: AreStore, feature: A_Feature, logger?: A_Logger, ...args: any[]): void;
30
32
  compileEventAttribute(attribute: AreEventAttribute, scene: AreScene, ...args: any[]): void;
31
- compileBindingAttribute(attribute: AreBindingAttribute, scene: AreScene, parentStore: AreStore, store: AreStore, syntax: AreSyntax, ...args: any[]): void;
33
+ compileBindingAttribute(attribute: AreBindingAttribute, scene: AreScene, parentStore: AreStore, store: AreStore, syntax: AreSyntax, directiveContext?: AreDirectiveContext, ...args: any[]): void;
32
34
  }
33
35
 
34
36
  export { AreHTMLCompiler };
@@ -1,10 +1,12 @@
1
1
  import { A_Feature } from '@adaas/a-concept';
2
2
  import { A_Logger } from '@adaas/a-utils/a-logger';
3
3
  import { AreCompiler, AreScene, AreStore, AreSyntax } from '@adaas/are';
4
- import { e as AreHTMLNode, f as AreStaticAttribute, b as AreDirectiveAttribute, c as AreEventAttribute, A as AreBindingAttribute } from '../AreBinding.attribute-Bm5LlOyE.js';
4
+ import { e as AreHTMLNode, f as AreStaticAttribute, b as AreDirectiveAttribute, c as AreEventAttribute, A as AreBindingAttribute } from '../AreBinding.attribute-GpT-5Qmf.js';
5
5
  import { AreInterpolation } from '../nodes/AreInterpolation.js';
6
6
  import { AreText } from '../nodes/AreText.js';
7
+ import { AreDirectiveContext } from '../lib/AreDirective/AreDirective.context.js';
7
8
  import '../lib/AreStyle/AreStyle.context.js';
9
+ import '@adaas/a-utils/a-execution';
8
10
 
9
11
  declare class AreHTMLCompiler extends AreCompiler {
10
12
  /**
@@ -28,7 +30,7 @@ declare class AreHTMLCompiler extends AreCompiler {
28
30
  compileStaticAttribute(attribute: AreStaticAttribute, scene: AreScene, ...args: any[]): void;
29
31
  compileDirectiveAttribute(directive: AreDirectiveAttribute, store: AreStore, feature: A_Feature, logger?: A_Logger, ...args: any[]): void;
30
32
  compileEventAttribute(attribute: AreEventAttribute, scene: AreScene, ...args: any[]): void;
31
- compileBindingAttribute(attribute: AreBindingAttribute, scene: AreScene, parentStore: AreStore, store: AreStore, syntax: AreSyntax, ...args: any[]): void;
33
+ compileBindingAttribute(attribute: AreBindingAttribute, scene: AreScene, parentStore: AreStore, store: AreStore, syntax: AreSyntax, directiveContext?: AreDirectiveContext, ...args: any[]): void;
32
34
  }
33
35
 
34
36
  export { AreHTMLCompiler };
@@ -15,7 +15,9 @@ var AddAttribute_instruction = require('@adaas/are-html/instructions/AddAttribut
15
15
  var AddText_instruction = require('@adaas/are-html/instructions/AddText.instruction');
16
16
  var AddListener_instruction = require('@adaas/are-html/instructions/AddListener.instruction');
17
17
  var AddStyle_instruction = require('@adaas/are-html/instructions/AddStyle.instruction');
18
+ var AddStaticHTML_instruction = require('@adaas/are-html/instructions/AddStaticHTML.instruction');
18
19
  var node = require('@adaas/are-html/node');
20
+ var AreDirective_context = require('@adaas/are-html/directive/AreDirective.context');
19
21
 
20
22
  var __defProp = Object.defineProperty;
21
23
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -31,6 +33,9 @@ var __decorateParam = (index, decorator) => (target, key) => decorator(target, k
31
33
  exports.AreHTMLCompiler = class AreHTMLCompiler extends are.AreCompiler {
32
34
  compileHTMLNode(node, scene, logger, ...args) {
33
35
  super.compile(node, scene, logger, ...args);
36
+ if (node.isStaticIsland && scene.host) {
37
+ scene.plan(new AddStaticHTML_instruction.AddStaticHTMLInstruction(scene.host, { html: node.staticInnerHTML }));
38
+ }
34
39
  if (node.styles?.styles) {
35
40
  const host = scene.host;
36
41
  if (host) {
@@ -88,7 +93,7 @@ exports.AreHTMLCompiler = class AreHTMLCompiler extends are.AreCompiler {
88
93
  handler: attribute.content
89
94
  }));
90
95
  }
91
- compileBindingAttribute(attribute, scene, parentStore, store, syntax, ...args) {
96
+ compileBindingAttribute(attribute, scene, parentStore, store, syntax, directiveContext, ...args) {
92
97
  if (!scene.host)
93
98
  throw new are.AreCompilerError({
94
99
  title: "Scene Host Not Found",
@@ -124,11 +129,12 @@ exports.AreHTMLCompiler = class AreHTMLCompiler extends are.AreCompiler {
124
129
  }
125
130
  return value;
126
131
  };
132
+ const directiveScope = () => directiveContext?.scope ?? {};
127
133
  const watcher = {
128
134
  update: () => {
129
135
  try {
130
136
  parentStore.watch(watcher);
131
- const next = coerce(syntax.evaluate(attribute.content, parentStore));
137
+ const next = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));
132
138
  parentStore.unwatch(watcher);
133
139
  store.set(propName, next);
134
140
  } catch (e) {
@@ -137,7 +143,7 @@ exports.AreHTMLCompiler = class AreHTMLCompiler extends are.AreCompiler {
137
143
  }
138
144
  };
139
145
  parentStore.watch(watcher);
140
- const initial = coerce(syntax.evaluate(attribute.content, parentStore));
146
+ const initial = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));
141
147
  parentStore.unwatch(watcher);
142
148
  store.set(propName, initial);
143
149
  return;
@@ -193,7 +199,8 @@ __decorateClass([
193
199
  __decorateParam(2, aConcept.A_Dependency.Parent()),
194
200
  __decorateParam(2, aConcept.A_Inject(are.AreStore)),
195
201
  __decorateParam(3, aConcept.A_Inject(are.AreStore)),
196
- __decorateParam(4, aConcept.A_Inject(are.AreSyntax))
202
+ __decorateParam(4, aConcept.A_Inject(are.AreSyntax)),
203
+ __decorateParam(5, aConcept.A_Inject(AreDirective_context.AreDirectiveContext))
197
204
  ], exports.AreHTMLCompiler.prototype, "compileBindingAttribute", 1);
198
205
  exports.AreHTMLCompiler = __decorateClass([
199
206
  core.A_Frame.Define({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":["AreHTMLCompiler","AreCompiler","AddStyleInstruction","AddTextInstruction","AreCompilerError","AddAttributeInstruction","AreDirectiveFeatures","A_FormatterHelper","AddListenerInstruction","AreHTMLNode","A_Caller","AreScene","A_Logger","AreInterpolation","AreStore","AreText","AreStaticAttribute","AreDirectiveAttribute","A_Feature","AreEventAttribute","AreBindingAttribute","AreSyntax","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBaA,uBAAA,GAAN,8BAA8BC,eAAA,CAAY;AAAA,EAS7C,eAAA,CACwB,IAAA,EACA,KAAA,EACA,MAAA,EAAA,GACjB,IAAA,EACC;AACJ,IAAA,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,GAAG,IAAI,CAAA;AAE1C,IAAA,IAAI,IAAA,CAAK,QAAQ,MAAA,EAAQ;AACrB,MAAA,MAAM,OAAO,KAAA,CAAM,IAAA;AACnB,MAAA,IAAI,IAAA,EAAM;AACN,QAAA,KAAA,CAAM,IAAA,CAAK,IAAIC,wCAAA,CAAoB,IAAA,EAAM,EAAE,QAAQ,IAAA,CAAK,MAAA,CAAO,MAAA,EAAQ,CAAC,CAAA;AAAA,MAC5E;AAAA,IACJ;AAAA,EACJ;AAAA,EAeA,oBAAA,CACwB,aAAA,EACA,KAAA,EAEA,KAAA,EACA,WACjB,IAAA,EACL;AAeE,IAAA,KAAA,CAAM,IAAA,CAAK,IAAIC,sCAAA,CAAmB,EAAE,OAAA,EAAS,cAAc,OAAA,EAAS,QAAA,EAAU,IAAA,EAAM,CAAC,CAAA;AAAA,EACzF;AAAA,EAMA,WAAA,CACwB,IAAA,EACA,KAAA,EACA,MAAA,EAAA,GACjB,IAAA,EACL;AACE,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,CAAA,oCAAA,EAAuC,IAAA,CAAK,KAAA,CAAM,UAAU,CAAA,iBAAA,EAAoB,IAAA,CAAK,OAAO,CAAA,CAAA,CAAG,CAAA;AACrH,IAAA,IAAI,KAAA,CAAM,IAAA;AACN,MAAA,KAAA,CAAM,MAAA,CAAO,MAAM,IAAI,CAAA;AAE3B,IAAA,KAAA,CAAM,IAAA,CAAK,IAAIA,sC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A,EAAa;AAAA,GAChB;AAAA,CAAA,EACYtB,uBAAA,CAAA","file":"AreHTML.compiler.js","sourcesContent":["import { A_Caller, A_Dependency, A_Feature, A_FormatterHelper, A_Inject } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AddAttributeInstruction} from \"@adaas/are-html/instructions/AddAttribute.instruction\";\nimport { AddTextInstruction} from \"@adaas/are-html/instructions/AddText.instruction\";\nimport { AddListenerInstruction} from \"@adaas/are-html/instructions/AddListener.instruction\";\nimport { AddStyleInstruction } from \"@adaas/are-html/instructions/AddStyle.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\n\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific compiler for A-Concept Rendering Engine (ARE) components, extending the base AreCompiler to handle HTML templates, styles, and rendering logic tailored for web environments.'\n})\nexport class AreHTMLCompiler extends AreCompiler {\n\n /**\n * Extends the base compile for all AreHTMLNode instances (elements, components, root nodes).\n * After the standard element/attribute/children instructions are emitted, checks whether\n * the node has a registered AreStyle and plans an AddStyleInstruction so the interpreter\n * can inject the CSS into the document head during mount.\n */\n @AreCompiler.Compile(AreHTMLNode)\n compileHTMLNode(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n super.compile(node, scene, logger, ...args);\n\n if (node.styles?.styles) {\n const host = scene.host;\n if (host) {\n scene.plan(new AddStyleInstruction(host, { styles: node.styles.styles }));\n }\n }\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Interpolation Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n /**\n * Default compile method for interpolations, which can be overridden by specific implementations if needed.\n * \n * @param interpolation \n * @param scope \n * @param scene \n * @param store \n * @param feature \n */\n @AreCompiler.Compile(AreInterpolation)\n compileInterpolation(\n @A_Inject(A_Caller) interpolation: AreInterpolation,\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n // if (scene.host)\n // console.log('Scene Host: ', scene.host);\n\n // let content = '';\n\n // logger?.debug('green', `AreHTMLCompiler: compile interpolation <${interpolation.aseid.toString()}> with key: \"${interpolation.content}\"`, store.get(interpolation.content));\n\n // try {\n // content = AreCommonHelper.evaluate(interpolation.content, store);\n\n // } catch (error) {\n // content = ''\n // }\n\n scene.plan(new AddTextInstruction({ content: interpolation.content, evaluate: true }));\n }\n\n // -----------------------------------------------------------------------------------------\n // ------------------------------Are-Text Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n @AreCompiler.Compile(AreText)\n compileText(\n @A_Inject(A_Caller) text: AreText,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.debug('cyan', `AreHTMLCompiler: compile text node <${text.aseid.toString()}> with content: \"${text.content}\"`);\n if (scene.host)\n scene.unPlan(scene.host);\n\n scene.plan(new AddTextInstruction({ content: text.content }));\n\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Attribute Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n\n @AreCompiler.Compile(AreStaticAttribute)\n compileStaticAttribute(\n @A_Inject(A_Caller) attribute: AreStaticAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n const content = attribute.content;\n\n /**\n * If the attribute value contains {{ }} interpolations, transform them into\n * a JS string-concatenation expression so the interpreter can evaluate them.\n * e.g. \"color:{{expr}}\" → '\"color:\"+(expr)+\"\"'\n */\n if (content.includes('{{')) {\n const transformed = '\"' + content.replace(/\\{\\{([^}]+)\\}\\}/g, '\"+($1)+\"') + '\"';\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: transformed,\n evaluate: true,\n }));\n return;\n }\n\n /**\n * Default case: regular static attribute rendered as-is.\n */\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content\n }));\n }\n\n @AreCompiler.Compile(AreDirectiveAttribute)\n compileDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n store.watch(directive);\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.Compile, 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 store.unwatch(directive);\n }\n\n\n @AreCompiler.Compile(AreEventAttribute)\n compileEventAttribute(\n @A_Inject(A_Caller) attribute: AreEventAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n /**\n * 2. In case the attribute is an event listener, then \n * we should simply add a callback handler that will be used to proxy an event \n * into the ComponentNode component. \n *[!] In this case AreAttribute is AreEventAttribute that has prepared callback function to be used \n * in the event listener. It is important to store callback function once \n * to prevent duplicated functions in case of multiple compilations during development.\n */\n scene.plan(new AddListenerInstruction(scene.host, {\n name: attribute.name,\n handler: attribute.content\n }));\n }\n\n\n @AreCompiler.Compile(AreBindingAttribute)\n compileBindingAttribute(\n @A_Inject(A_Caller) attribute: AreBindingAttribute,\n @A_Inject(AreScene) scene: AreScene,\n @A_Dependency.Parent()\n @A_Inject(AreStore) parentStore: AreStore,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreSyntax) syntax: AreSyntax,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n\n const node = attribute.owner;\n const props = node.component?.props;\n\n // Component prop names are typically declared in camelCase, while template\n // markup uses kebab-case. Try both forms when matching.\n let propName: string | undefined;\n if (props) {\n if (props[attribute.name]) {\n propName = attribute.name;\n } else {\n const camel = A_FormatterHelper.toCamelCase(attribute.name);\n if (props[camel]) propName = camel;\n }\n }\n\n /**\n * 1. Component prop binding — evaluate against the parent store and\n * keep the child store reactive to upstream changes.\n */\n if (propName && props) {\n const propDefinition = props[propName];\n\n const coerce = (raw: any): any => {\n let value = raw;\n if (propDefinition.type) {\n switch (propDefinition.type) {\n case 'string': value = value === undefined || value === null ? '' : String(value); break;\n case 'number': value = Number(value); break;\n case 'boolean': value = Boolean(value); break;\n }\n }\n return value;\n };\n\n // The watcher entity below is registered against parentStore so that\n // updates to the bound expression in the parent flow into the child store.\n const watcher = {\n update: () => {\n try {\n parentStore.watch(watcher);\n const next = coerce(syntax.evaluate(attribute.content, parentStore));\n parentStore.unwatch(watcher);\n store.set(propName!, next);\n } catch (e) {\n parentStore.unwatch(watcher);\n }\n }\n };\n\n // Initial read with watch active so dependencies are recorded.\n parentStore.watch(watcher);\n const initial = coerce(syntax.evaluate(attribute.content, parentStore));\n parentStore.unwatch(watcher);\n\n store.set(propName, initial);\n return;\n }\n\n /**\n * 2. Default attribute binding — evaluated reactively against the local store.\n */\n const instruction = new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content,\n evaluate: true\n })\n\n scene.plan(instruction);\n }\n\n\n}"]}
1
+ {"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":["AreHTMLCompiler","AreCompiler","AddStaticHTMLInstruction","AddStyleInstruction","AddTextInstruction","AreCompilerError","AddAttributeInstruction","AreDirectiveFeatures","A_FormatterHelper","AddListenerInstruction","AreHTMLNode","A_Caller","AreScene","A_Logger","AreInterpolation","AreStore","AreText","AreStaticAttribute","AreDirectiveAttribute","A_Feature","AreEventAttribute","AreBindingAttribute","AreSyntax","AreDirectiveContext","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BaA,uBAAA,GAAN,8BAA8BC,eAAA,CAAY;AAAA,EAS7C,eAAA,CACwB,IAAA,EACA,KAAA,EACA,MAAA,EAAA,GACjB,IAAA,EACC;AACJ,IAAA,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,GAAG,IAAI,CAAA;AAU1C,IAAA,IAAI,IAAA,CAAK,cAAA,IAAkB,KAAA,CAAM,IAAA,EAAM;AACnC,MAAA,KAAA,CAAM,IAAA,CAAK,IAAIC,kDAAA,CAAyB,KAAA,CAAM,IAAA,EAAM,EAAE,IAAA,EAAM,IAAA,CAAK,eAAA,EAAkB,CAAC,CAAA;AAAA,IACxF;AAEA,IAAA,IAAI,IAAA,CAAK,QAAQ,MAAA,EAAQ;AACrB,MAAA,MAAM,O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AAqB,CAAA;AAAA,EAErC,qCAASP,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASI,YAAQ,CAAA,CAAA;AAAA,EACjB,qCAASI,kBAAS,CAAA,CAAA;AAAA,EAClB,qCAASN,gBAAQ,CAAA;AAAA,CAAA,EA5Ibb,uBAAA,CAwIT,SAAA,EAAA,2BAAA,EAAA,CAAA,CAAA;AA0BA,eAAA,CAAA;AAAA,EADCC,eAAA,CAAY,QAAQmB,oCAAiB,CAAA;AAAA,EAEjC,qCAAST,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,YAAQ,CAAA;AAAA,CAAA,EApKbZ,uBAAA,CAkKT,SAAA,EAAA,uBAAA,EAAA,CAAA,CAAA;AA2BA,eAAA,CAAA;AAAA,EADCC,eAAA,CAAY,QAAQoB,wCAAmB,CAAA;AAAA,EAEnC,qCAASV,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,YAAQ,CAAA,CAAA;AAAA,EACjB,yCAAa,MAAA,EAAO,CAAA;AAAA,EACpB,qCAASG,YAAQ,CAAA,CAAA;AAAA,EACjB,qCAASA,YAAQ,CAAA,CAAA;AAAA,EACjB,qCAASO,aAAS,CAAA,CAAA;AAAA,EAClB,qCAASC,wCAAmB,CAAA;AAAA,CAAA,EApMxBvB,uBAAA,CA6LT,SAAA,EAAA,yBAAA,EAAA,CAAA,CAAA;AA7LSA,uBAAA,GAAN,eAAA,CAAA;AAAA,EAJNwB,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYxB,uBAAA,CAAA","file":"AreHTML.compiler.js","sourcesContent":["import { A_Caller, A_Dependency, A_Feature, A_FormatterHelper, A_Inject } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AddAttributeInstruction} from \"@adaas/are-html/instructions/AddAttribute.instruction\";\nimport { AddTextInstruction} from \"@adaas/are-html/instructions/AddText.instruction\";\nimport { AddListenerInstruction} from \"@adaas/are-html/instructions/AddListener.instruction\";\nimport { AddStyleInstruction } from \"@adaas/are-html/instructions/AddStyle.instruction\";\nimport { AddStaticHTMLInstruction } from \"@adaas/are-html/instructions/AddStaticHTML.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\nimport { AreDirectiveContext } from \"@adaas/are-html/directive/AreDirective.context\";\n\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific compiler for A-Concept Rendering Engine (ARE) components, extending the base AreCompiler to handle HTML templates, styles, and rendering logic tailored for web environments.'\n})\nexport class AreHTMLCompiler extends AreCompiler {\n\n /**\n * Extends the base compile for all AreHTMLNode instances (elements, components, root nodes).\n * After the standard element/attribute/children instructions are emitted, checks whether\n * the node has a registered AreStyle and plans an AddStyleInstruction so the interpreter\n * can inject the CSS into the document head during mount.\n */\n @AreCompiler.Compile(AreHTMLNode)\n compileHTMLNode(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n super.compile(node, scene, logger, ...args);\n\n /**\n * Static-island materialisation. When the tokenizer flagged this node as\n * a static island its inner subtree was never exploded into child nodes,\n * so there is nothing for the base compiler to walk. Emit a single\n * AddStaticHTML instruction carrying the captured inner markup; the\n * interpreter injects it onto the host element in one pass (and decodes\n * HTML entities for free).\n */\n if (node.isStaticIsland && scene.host) {\n scene.plan(new AddStaticHTMLInstruction(scene.host, { html: node.staticInnerHTML! }));\n }\n\n if (node.styles?.styles) {\n const host = scene.host;\n if (host) {\n scene.plan(new AddStyleInstruction(host, { styles: node.styles.styles }));\n }\n }\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Interpolation Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n /**\n * Default compile method for interpolations, which can be overridden by specific implementations if needed.\n * \n * @param interpolation \n * @param scope \n * @param scene \n * @param store \n * @param feature \n */\n @AreCompiler.Compile(AreInterpolation)\n compileInterpolation(\n @A_Inject(A_Caller) interpolation: AreInterpolation,\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n // if (scene.host)\n // console.log('Scene Host: ', scene.host);\n\n // let content = '';\n\n // logger?.debug('green', `AreHTMLCompiler: compile interpolation <${interpolation.aseid.toString()}> with key: \"${interpolation.content}\"`, store.get(interpolation.content));\n\n // try {\n // content = AreCommonHelper.evaluate(interpolation.content, store);\n\n // } catch (error) {\n // content = ''\n // }\n\n scene.plan(new AddTextInstruction({ content: interpolation.content, evaluate: true }));\n }\n\n // -----------------------------------------------------------------------------------------\n // ------------------------------Are-Text Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n @AreCompiler.Compile(AreText)\n compileText(\n @A_Inject(A_Caller) text: AreText,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.debug('cyan', `AreHTMLCompiler: compile text node <${text.aseid.toString()}> with content: \"${text.content}\"`);\n if (scene.host)\n scene.unPlan(scene.host);\n\n scene.plan(new AddTextInstruction({ content: text.content }));\n\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Attribute Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n\n @AreCompiler.Compile(AreStaticAttribute)\n compileStaticAttribute(\n @A_Inject(A_Caller) attribute: AreStaticAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n const content = attribute.content;\n\n /**\n * If the attribute value contains {{ }} interpolations, transform them into\n * a JS string-concatenation expression so the interpreter can evaluate them.\n * e.g. \"color:{{expr}}\" → '\"color:\"+(expr)+\"\"'\n */\n if (content.includes('{{')) {\n const transformed = '\"' + content.replace(/\\{\\{([^}]+)\\}\\}/g, '\"+($1)+\"') + '\"';\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: transformed,\n evaluate: true,\n }));\n return;\n }\n\n /**\n * Default case: regular static attribute rendered as-is.\n */\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content\n }));\n }\n\n @AreCompiler.Compile(AreDirectiveAttribute)\n compileDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n store.watch(directive);\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.Compile, 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 store.unwatch(directive);\n }\n\n\n @AreCompiler.Compile(AreEventAttribute)\n compileEventAttribute(\n @A_Inject(A_Caller) attribute: AreEventAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n /**\n * 2. In case the attribute is an event listener, then \n * we should simply add a callback handler that will be used to proxy an event \n * into the ComponentNode component. \n *[!] In this case AreAttribute is AreEventAttribute that has prepared callback function to be used \n * in the event listener. It is important to store callback function once \n * to prevent duplicated functions in case of multiple compilations during development.\n */\n scene.plan(new AddListenerInstruction(scene.host, {\n name: attribute.name,\n handler: attribute.content\n }));\n }\n\n\n @AreCompiler.Compile(AreBindingAttribute)\n compileBindingAttribute(\n @A_Inject(A_Caller) attribute: AreBindingAttribute,\n @A_Inject(AreScene) scene: AreScene,\n @A_Dependency.Parent()\n @A_Inject(AreStore) parentStore: AreStore,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreSyntax) syntax: AreSyntax,\n @A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n\n const node = attribute.owner;\n const props = node.component?.props;\n\n // Component prop names are typically declared in camelCase, while template\n // markup uses kebab-case. Try both forms when matching.\n let propName: string | undefined;\n if (props) {\n if (props[attribute.name]) {\n propName = attribute.name;\n } else {\n const camel = A_FormatterHelper.toCamelCase(attribute.name);\n if (props[camel]) propName = camel;\n }\n }\n\n /**\n * 1. Component prop binding — evaluate against the parent store and\n * keep the child store reactive to upstream changes.\n */\n if (propName && props) {\n const propDefinition = props[propName];\n\n const coerce = (raw: any): any => {\n let value = raw;\n if (propDefinition.type) {\n switch (propDefinition.type) {\n case 'string': value = value === undefined || value === null ? '' : String(value); break;\n case 'number': value = Number(value); break;\n case 'boolean': value = Boolean(value); break;\n }\n }\n return value;\n };\n\n // Item-scoped variables from an enclosing directive (the `item`/`index`\n // of a `$for`, or any scope a `$if` merged in) so a prop binding like\n // `:title=\"item.name\"` resolves the loop variable — checked BEFORE the\n // store, exactly like plain attribute bindings do in the interpreter.\n // Read `.scope` lazily inside each evaluation so keyed `$for` updates\n // that reassign the context's scope are always reflected.\n const directiveScope = () => directiveContext?.scope ?? {};\n\n // The watcher entity below is registered against parentStore so that\n // updates to the bound expression in the parent flow into the child store.\n const watcher = {\n update: () => {\n try {\n parentStore.watch(watcher);\n const next = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));\n parentStore.unwatch(watcher);\n store.set(propName!, next);\n } catch (e) {\n parentStore.unwatch(watcher);\n }\n }\n };\n\n // Initial read with watch active so dependencies are recorded.\n parentStore.watch(watcher);\n const initial = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));\n parentStore.unwatch(watcher);\n\n store.set(propName, initial);\n return;\n }\n\n /**\n * 2. Default attribute binding — evaluated reactively against the local store.\n */\n const instruction = new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content,\n evaluate: true\n })\n\n scene.plan(instruction);\n }\n\n\n}"]}
@@ -14,11 +14,16 @@ import { AddAttributeInstruction } from '@adaas/are-html/instructions/AddAttribu
14
14
  import { AddTextInstruction } from '@adaas/are-html/instructions/AddText.instruction';
15
15
  import { AddListenerInstruction } from '@adaas/are-html/instructions/AddListener.instruction';
16
16
  import { AddStyleInstruction } from '@adaas/are-html/instructions/AddStyle.instruction';
17
+ import { AddStaticHTMLInstruction } from '@adaas/are-html/instructions/AddStaticHTML.instruction';
17
18
  import { AreHTMLNode } from '@adaas/are-html/node';
19
+ import { AreDirectiveContext } from '@adaas/are-html/directive/AreDirective.context';
18
20
 
19
21
  let AreHTMLCompiler = class extends AreCompiler {
20
22
  compileHTMLNode(node, scene, logger, ...args) {
21
23
  super.compile(node, scene, logger, ...args);
24
+ if (node.isStaticIsland && scene.host) {
25
+ scene.plan(new AddStaticHTMLInstruction(scene.host, { html: node.staticInnerHTML }));
26
+ }
22
27
  if (node.styles?.styles) {
23
28
  const host = scene.host;
24
29
  if (host) {
@@ -76,7 +81,7 @@ let AreHTMLCompiler = class extends AreCompiler {
76
81
  handler: attribute.content
77
82
  }));
78
83
  }
79
- compileBindingAttribute(attribute, scene, parentStore, store, syntax, ...args) {
84
+ compileBindingAttribute(attribute, scene, parentStore, store, syntax, directiveContext, ...args) {
80
85
  if (!scene.host)
81
86
  throw new AreCompilerError({
82
87
  title: "Scene Host Not Found",
@@ -112,11 +117,12 @@ let AreHTMLCompiler = class extends AreCompiler {
112
117
  }
113
118
  return value;
114
119
  };
120
+ const directiveScope = () => directiveContext?.scope ?? {};
115
121
  const watcher = {
116
122
  update: () => {
117
123
  try {
118
124
  parentStore.watch(watcher);
119
- const next = coerce(syntax.evaluate(attribute.content, parentStore));
125
+ const next = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));
120
126
  parentStore.unwatch(watcher);
121
127
  store.set(propName, next);
122
128
  } catch (e) {
@@ -125,7 +131,7 @@ let AreHTMLCompiler = class extends AreCompiler {
125
131
  }
126
132
  };
127
133
  parentStore.watch(watcher);
128
- const initial = coerce(syntax.evaluate(attribute.content, parentStore));
134
+ const initial = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));
129
135
  parentStore.unwatch(watcher);
130
136
  store.set(propName, initial);
131
137
  return;
@@ -181,7 +187,8 @@ __decorateClass([
181
187
  __decorateParam(2, A_Dependency.Parent()),
182
188
  __decorateParam(2, A_Inject(AreStore)),
183
189
  __decorateParam(3, A_Inject(AreStore)),
184
- __decorateParam(4, A_Inject(AreSyntax))
190
+ __decorateParam(4, A_Inject(AreSyntax)),
191
+ __decorateParam(5, A_Inject(AreDirectiveContext))
185
192
  ], AreHTMLCompiler.prototype, "compileBindingAttribute", 1);
186
193
  AreHTMLCompiler = __decorateClass([
187
194
  A_Frame.Define({
@@ -1 +1 @@
1
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/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AddAttributeInstruction} from \"@adaas/are-html/instructions/AddAttribute.instruction\";\nimport { AddTextInstruction} from \"@adaas/are-html/instructions/AddText.instruction\";\nimport { AddListenerInstruction} from \"@adaas/are-html/instructions/AddListener.instruction\";\nimport { AddStyleInstruction } from \"@adaas/are-html/instructions/AddStyle.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\n\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific compiler for A-Concept Rendering Engine (ARE) components, extending the base AreCompiler to handle HTML templates, styles, and rendering logic tailored for web environments.'\n})\nexport class AreHTMLCompiler extends AreCompiler {\n\n /**\n * Extends the base compile for all AreHTMLNode instances (elements, components, root nodes).\n * After the standard element/attribute/children instructions are emitted, checks whether\n * the node has a registered AreStyle and plans an AddStyleInstruction so the interpreter\n * can inject the CSS into the document head during mount.\n */\n @AreCompiler.Compile(AreHTMLNode)\n compileHTMLNode(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n super.compile(node, scene, logger, ...args);\n\n if (node.styles?.styles) {\n const host = scene.host;\n if (host) {\n scene.plan(new AddStyleInstruction(host, { styles: node.styles.styles }));\n }\n }\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Interpolation Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n /**\n * Default compile method for interpolations, which can be overridden by specific implementations if needed.\n * \n * @param interpolation \n * @param scope \n * @param scene \n * @param store \n * @param feature \n */\n @AreCompiler.Compile(AreInterpolation)\n compileInterpolation(\n @A_Inject(A_Caller) interpolation: AreInterpolation,\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n // if (scene.host)\n // console.log('Scene Host: ', scene.host);\n\n // let content = '';\n\n // logger?.debug('green', `AreHTMLCompiler: compile interpolation <${interpolation.aseid.toString()}> with key: \"${interpolation.content}\"`, store.get(interpolation.content));\n\n // try {\n // content = AreCommonHelper.evaluate(interpolation.content, store);\n\n // } catch (error) {\n // content = ''\n // }\n\n scene.plan(new AddTextInstruction({ content: interpolation.content, evaluate: true }));\n }\n\n // -----------------------------------------------------------------------------------------\n // ------------------------------Are-Text Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n @AreCompiler.Compile(AreText)\n compileText(\n @A_Inject(A_Caller) text: AreText,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.debug('cyan', `AreHTMLCompiler: compile text node <${text.aseid.toString()}> with content: \"${text.content}\"`);\n if (scene.host)\n scene.unPlan(scene.host);\n\n scene.plan(new AddTextInstruction({ content: text.content }));\n\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Attribute Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n\n @AreCompiler.Compile(AreStaticAttribute)\n compileStaticAttribute(\n @A_Inject(A_Caller) attribute: AreStaticAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n const content = attribute.content;\n\n /**\n * If the attribute value contains {{ }} interpolations, transform them into\n * a JS string-concatenation expression so the interpreter can evaluate them.\n * e.g. \"color:{{expr}}\" → '\"color:\"+(expr)+\"\"'\n */\n if (content.includes('{{')) {\n const transformed = '\"' + content.replace(/\\{\\{([^}]+)\\}\\}/g, '\"+($1)+\"') + '\"';\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: transformed,\n evaluate: true,\n }));\n return;\n }\n\n /**\n * Default case: regular static attribute rendered as-is.\n */\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content\n }));\n }\n\n @AreCompiler.Compile(AreDirectiveAttribute)\n compileDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n store.watch(directive);\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.Compile, 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 store.unwatch(directive);\n }\n\n\n @AreCompiler.Compile(AreEventAttribute)\n compileEventAttribute(\n @A_Inject(A_Caller) attribute: AreEventAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n /**\n * 2. In case the attribute is an event listener, then \n * we should simply add a callback handler that will be used to proxy an event \n * into the ComponentNode component. \n *[!] In this case AreAttribute is AreEventAttribute that has prepared callback function to be used \n * in the event listener. It is important to store callback function once \n * to prevent duplicated functions in case of multiple compilations during development.\n */\n scene.plan(new AddListenerInstruction(scene.host, {\n name: attribute.name,\n handler: attribute.content\n }));\n }\n\n\n @AreCompiler.Compile(AreBindingAttribute)\n compileBindingAttribute(\n @A_Inject(A_Caller) attribute: AreBindingAttribute,\n @A_Inject(AreScene) scene: AreScene,\n @A_Dependency.Parent()\n @A_Inject(AreStore) parentStore: AreStore,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreSyntax) syntax: AreSyntax,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n\n const node = attribute.owner;\n const props = node.component?.props;\n\n // Component prop names are typically declared in camelCase, while template\n // markup uses kebab-case. Try both forms when matching.\n let propName: string | undefined;\n if (props) {\n if (props[attribute.name]) {\n propName = attribute.name;\n } else {\n const camel = A_FormatterHelper.toCamelCase(attribute.name);\n if (props[camel]) propName = camel;\n }\n }\n\n /**\n * 1. Component prop binding — evaluate against the parent store and\n * keep the child store reactive to upstream changes.\n */\n if (propName && props) {\n const propDefinition = props[propName];\n\n const coerce = (raw: any): any => {\n let value = raw;\n if (propDefinition.type) {\n switch (propDefinition.type) {\n case 'string': value = value === undefined || value === null ? '' : String(value); break;\n case 'number': value = Number(value); break;\n case 'boolean': value = Boolean(value); break;\n }\n }\n return value;\n };\n\n // The watcher entity below is registered against parentStore so that\n // updates to the bound expression in the parent flow into the child store.\n const watcher = {\n update: () => {\n try {\n parentStore.watch(watcher);\n const next = coerce(syntax.evaluate(attribute.content, parentStore));\n parentStore.unwatch(watcher);\n store.set(propName!, next);\n } catch (e) {\n parentStore.unwatch(watcher);\n }\n }\n };\n\n // Initial read with watch active so dependencies are recorded.\n parentStore.watch(watcher);\n const initial = coerce(syntax.evaluate(attribute.content, parentStore));\n parentStore.unwatch(watcher);\n\n store.set(propName, initial);\n return;\n }\n\n /**\n * 2. Default attribute binding — evaluated reactively against the local store.\n */\n const instruction = new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content,\n evaluate: true\n })\n\n scene.plan(instruction);\n }\n\n\n}"]}
1
+ {"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BO,IAAM,eAAA,GAAN,cAA8B,WAAA,CAAY;AAAA,EAS7C,eAAA,CACwB,IAAA,EACA,KAAA,EACA,MAAA,EAAA,GACjB,IAAA,EACC;AACJ,IAAA,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,GAAG,IAAI,CAAA;AAU1C,IAAA,IAAI,IAAA,CAAK,cAAA,IAAkB,KAAA,CAAM,IAAA,EAAM;AACnC,MAAA,KAAA,CAAM,IAAA,CAAK,IAAI,wBAAA,CAAyB,KAAA,CAAM,IAAA,EAAM,EAAE,IAAA,EAAM,IAAA,CAAK,eAAA,EAAkB,CAAC,CAAA;AAAA,IACxF;AAEA,IAAA,IAAI,IAAA,CAAK,QAAQ,MAAA,EAAQ;AACrB,MAAA,MAAM,OAAO,KAAA,CAAM,IAAA;AACnB,MAAA,IAAI,IAAA,EAAM;AACN,QAAA,KAAA,CAAM,IAAA,CAAK,IAAI,mBAAA,CAAoB,IAAA,EAAM,EAAE,QAAQ,IAAA,CAAK,MAAA,CAAO,MAAA,EAAQ,CAAC,CAAA;AAAA,MAC5E;AAAA,IACJ;AAAA,EACJ;AAAA,EAeA,oBAAA,CACwB,aAAA,EACA,KAAA,EAEA,KAAA,EACA,WACjB,IAAA,EACL;AAeE,IAAA,KAAA,CAAM,IAAA,CAAK,IAAI,kBAAA,CAAmB,EAAE,OAAA,EAAS,cAAc,OAAA,EAAS,QAAA,EAAU,IAAA,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AA;AAAA,EADC,WAAA,CAAY,QAAQ,mBAAmB,CAAA;AAAA,EAEnC,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,gCAAa,MAAA,EAAO,CAAA;AAAA,EACpB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,mBAAmB,CAAA;AAAA,CAAA,EApMxB,eAAA,CA6LT,SAAA,EAAA,yBAAA,EAAA,CAAA,CAAA;AA7LS,eAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,eAAA,CAAA","file":"AreHTML.compiler.mjs","sourcesContent":["import { A_Caller, A_Dependency, A_Feature, A_FormatterHelper, A_Inject } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AddAttributeInstruction} from \"@adaas/are-html/instructions/AddAttribute.instruction\";\nimport { AddTextInstruction} from \"@adaas/are-html/instructions/AddText.instruction\";\nimport { AddListenerInstruction} from \"@adaas/are-html/instructions/AddListener.instruction\";\nimport { AddStyleInstruction } from \"@adaas/are-html/instructions/AddStyle.instruction\";\nimport { AddStaticHTMLInstruction } from \"@adaas/are-html/instructions/AddStaticHTML.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\nimport { AreDirectiveContext } from \"@adaas/are-html/directive/AreDirective.context\";\n\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific compiler for A-Concept Rendering Engine (ARE) components, extending the base AreCompiler to handle HTML templates, styles, and rendering logic tailored for web environments.'\n})\nexport class AreHTMLCompiler extends AreCompiler {\n\n /**\n * Extends the base compile for all AreHTMLNode instances (elements, components, root nodes).\n * After the standard element/attribute/children instructions are emitted, checks whether\n * the node has a registered AreStyle and plans an AddStyleInstruction so the interpreter\n * can inject the CSS into the document head during mount.\n */\n @AreCompiler.Compile(AreHTMLNode)\n compileHTMLNode(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n super.compile(node, scene, logger, ...args);\n\n /**\n * Static-island materialisation. When the tokenizer flagged this node as\n * a static island its inner subtree was never exploded into child nodes,\n * so there is nothing for the base compiler to walk. Emit a single\n * AddStaticHTML instruction carrying the captured inner markup; the\n * interpreter injects it onto the host element in one pass (and decodes\n * HTML entities for free).\n */\n if (node.isStaticIsland && scene.host) {\n scene.plan(new AddStaticHTMLInstruction(scene.host, { html: node.staticInnerHTML! }));\n }\n\n if (node.styles?.styles) {\n const host = scene.host;\n if (host) {\n scene.plan(new AddStyleInstruction(host, { styles: node.styles.styles }));\n }\n }\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Interpolation Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n /**\n * Default compile method for interpolations, which can be overridden by specific implementations if needed.\n * \n * @param interpolation \n * @param scope \n * @param scene \n * @param store \n * @param feature \n */\n @AreCompiler.Compile(AreInterpolation)\n compileInterpolation(\n @A_Inject(A_Caller) interpolation: AreInterpolation,\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n // if (scene.host)\n // console.log('Scene Host: ', scene.host);\n\n // let content = '';\n\n // logger?.debug('green', `AreHTMLCompiler: compile interpolation <${interpolation.aseid.toString()}> with key: \"${interpolation.content}\"`, store.get(interpolation.content));\n\n // try {\n // content = AreCommonHelper.evaluate(interpolation.content, store);\n\n // } catch (error) {\n // content = ''\n // }\n\n scene.plan(new AddTextInstruction({ content: interpolation.content, evaluate: true }));\n }\n\n // -----------------------------------------------------------------------------------------\n // ------------------------------Are-Text Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n @AreCompiler.Compile(AreText)\n compileText(\n @A_Inject(A_Caller) text: AreText,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.debug('cyan', `AreHTMLCompiler: compile text node <${text.aseid.toString()}> with content: \"${text.content}\"`);\n if (scene.host)\n scene.unPlan(scene.host);\n\n scene.plan(new AddTextInstruction({ content: text.content }));\n\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Attribute Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n\n @AreCompiler.Compile(AreStaticAttribute)\n compileStaticAttribute(\n @A_Inject(A_Caller) attribute: AreStaticAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n const content = attribute.content;\n\n /**\n * If the attribute value contains {{ }} interpolations, transform them into\n * a JS string-concatenation expression so the interpreter can evaluate them.\n * e.g. \"color:{{expr}}\" → '\"color:\"+(expr)+\"\"'\n */\n if (content.includes('{{')) {\n const transformed = '\"' + content.replace(/\\{\\{([^}]+)\\}\\}/g, '\"+($1)+\"') + '\"';\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: transformed,\n evaluate: true,\n }));\n return;\n }\n\n /**\n * Default case: regular static attribute rendered as-is.\n */\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content\n }));\n }\n\n @AreCompiler.Compile(AreDirectiveAttribute)\n compileDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n store.watch(directive);\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.Compile, 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 store.unwatch(directive);\n }\n\n\n @AreCompiler.Compile(AreEventAttribute)\n compileEventAttribute(\n @A_Inject(A_Caller) attribute: AreEventAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n /**\n * 2. In case the attribute is an event listener, then \n * we should simply add a callback handler that will be used to proxy an event \n * into the ComponentNode component. \n *[!] In this case AreAttribute is AreEventAttribute that has prepared callback function to be used \n * in the event listener. It is important to store callback function once \n * to prevent duplicated functions in case of multiple compilations during development.\n */\n scene.plan(new AddListenerInstruction(scene.host, {\n name: attribute.name,\n handler: attribute.content\n }));\n }\n\n\n @AreCompiler.Compile(AreBindingAttribute)\n compileBindingAttribute(\n @A_Inject(A_Caller) attribute: AreBindingAttribute,\n @A_Inject(AreScene) scene: AreScene,\n @A_Dependency.Parent()\n @A_Inject(AreStore) parentStore: AreStore,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreSyntax) syntax: AreSyntax,\n @A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n\n const node = attribute.owner;\n const props = node.component?.props;\n\n // Component prop names are typically declared in camelCase, while template\n // markup uses kebab-case. Try both forms when matching.\n let propName: string | undefined;\n if (props) {\n if (props[attribute.name]) {\n propName = attribute.name;\n } else {\n const camel = A_FormatterHelper.toCamelCase(attribute.name);\n if (props[camel]) propName = camel;\n }\n }\n\n /**\n * 1. Component prop binding — evaluate against the parent store and\n * keep the child store reactive to upstream changes.\n */\n if (propName && props) {\n const propDefinition = props[propName];\n\n const coerce = (raw: any): any => {\n let value = raw;\n if (propDefinition.type) {\n switch (propDefinition.type) {\n case 'string': value = value === undefined || value === null ? '' : String(value); break;\n case 'number': value = Number(value); break;\n case 'boolean': value = Boolean(value); break;\n }\n }\n return value;\n };\n\n // Item-scoped variables from an enclosing directive (the `item`/`index`\n // of a `$for`, or any scope a `$if` merged in) so a prop binding like\n // `:title=\"item.name\"` resolves the loop variable — checked BEFORE the\n // store, exactly like plain attribute bindings do in the interpreter.\n // Read `.scope` lazily inside each evaluation so keyed `$for` updates\n // that reassign the context's scope are always reflected.\n const directiveScope = () => directiveContext?.scope ?? {};\n\n // The watcher entity below is registered against parentStore so that\n // updates to the bound expression in the parent flow into the child store.\n const watcher = {\n update: () => {\n try {\n parentStore.watch(watcher);\n const next = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));\n parentStore.unwatch(watcher);\n store.set(propName!, next);\n } catch (e) {\n parentStore.unwatch(watcher);\n }\n }\n };\n\n // Initial read with watch active so dependencies are recorded.\n parentStore.watch(watcher);\n const initial = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));\n parentStore.unwatch(watcher);\n\n store.set(propName, initial);\n return;\n }\n\n /**\n * 2. Default attribute binding — evaluated reactively against the local store.\n */\n const instruction = new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content,\n evaluate: true\n })\n\n scene.plan(instruction);\n }\n\n\n}"]}
@@ -66,5 +66,37 @@ declare const LISTENER_OPTION_MODIFIERS: Set<string>;
66
66
  * Avoids "undefined"/"null"/"[object Object]" leaks into the DOM.
67
67
  */
68
68
  declare function toDOMString(value: any): string;
69
+ /**
70
+ * Standard HTML element names that are safe to materialise wholesale via
71
+ * `innerHTML` / a cached `<template>` clone.
72
+ *
73
+ * The set is intentionally an allow-list of plain HTML flow/phrasing/table/list
74
+ * /form-display tags. Anything NOT in this set — custom elements, registered
75
+ * ARE components (resolved by PascalCase tag), and SVG/MathML elements — is
76
+ * excluded so those subtrees keep flowing through the normal per-node pipeline
77
+ * (SVG needs createElementNS; components need their own lifecycle).
78
+ */
79
+ declare const STANDARD_HTML_TAGS: Set<string>;
80
+ /**
81
+ * Detects whether an inner-markup string is a fully *static island* — i.e. it
82
+ * contains no ARE-reactive constructs and therefore can be rendered in one shot
83
+ * (browser-parsed `innerHTML` / cached `<template>` clone) instead of being
84
+ * exploded into one AreNode per element/text/interpolation.
85
+ *
86
+ * A subtree is static iff it contains:
87
+ * 1. no `{{ }}` interpolations, and
88
+ * 2. no dynamic attributes (`$`-directive / `:`-binding / `@`-event), and
89
+ * 3. only standard HTML tags (no custom elements, ARE components or SVG).
90
+ *
91
+ * The scanner is quote-aware so a `:` / `@` / `$` inside an attribute *value*
92
+ * (e.g. `href="http://…"`, `style="color:red"`) is never mistaken for a
93
+ * dynamic-attribute prefix. The detector is deliberately conservative: any
94
+ * ambiguity resolves to `false` (skip the optimisation, keep the safe path).
95
+ *
96
+ * NOTE: pure-text content (no tags at all) is also considered static — this is
97
+ * what lets `&nbsp;`, `&amp;`, `&#160;` and friends decode correctly, since the
98
+ * browser HTML parser handles entities that hand-built text nodes do not.
99
+ */
100
+ declare function isStaticMarkup(inner: string): boolean;
69
101
 
70
- export { BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, SVG_ATTRIBUTE_NS, SVG_NAMESPACE, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
102
+ export { BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, STANDARD_HTML_TAGS, SVG_ATTRIBUTE_NS, SVG_NAMESPACE, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isStaticMarkup, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
@@ -66,5 +66,37 @@ declare const LISTENER_OPTION_MODIFIERS: Set<string>;
66
66
  * Avoids "undefined"/"null"/"[object Object]" leaks into the DOM.
67
67
  */
68
68
  declare function toDOMString(value: any): string;
69
+ /**
70
+ * Standard HTML element names that are safe to materialise wholesale via
71
+ * `innerHTML` / a cached `<template>` clone.
72
+ *
73
+ * The set is intentionally an allow-list of plain HTML flow/phrasing/table/list
74
+ * /form-display tags. Anything NOT in this set — custom elements, registered
75
+ * ARE components (resolved by PascalCase tag), and SVG/MathML elements — is
76
+ * excluded so those subtrees keep flowing through the normal per-node pipeline
77
+ * (SVG needs createElementNS; components need their own lifecycle).
78
+ */
79
+ declare const STANDARD_HTML_TAGS: Set<string>;
80
+ /**
81
+ * Detects whether an inner-markup string is a fully *static island* — i.e. it
82
+ * contains no ARE-reactive constructs and therefore can be rendered in one shot
83
+ * (browser-parsed `innerHTML` / cached `<template>` clone) instead of being
84
+ * exploded into one AreNode per element/text/interpolation.
85
+ *
86
+ * A subtree is static iff it contains:
87
+ * 1. no `{{ }}` interpolations, and
88
+ * 2. no dynamic attributes (`$`-directive / `:`-binding / `@`-event), and
89
+ * 3. only standard HTML tags (no custom elements, ARE components or SVG).
90
+ *
91
+ * The scanner is quote-aware so a `:` / `@` / `$` inside an attribute *value*
92
+ * (e.g. `href="http://…"`, `style="color:red"`) is never mistaken for a
93
+ * dynamic-attribute prefix. The detector is deliberately conservative: any
94
+ * ambiguity resolves to `false` (skip the optimisation, keep the safe path).
95
+ *
96
+ * NOTE: pure-text content (no tags at all) is also considered static — this is
97
+ * what lets `&nbsp;`, `&amp;`, `&#160;` and friends decode correctly, since the
98
+ * browser HTML parser handles entities that hand-built text nodes do not.
99
+ */
100
+ declare function isStaticMarkup(inner: string): boolean;
69
101
 
70
- export { BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, SVG_ATTRIBUTE_NS, SVG_NAMESPACE, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
102
+ export { BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, STANDARD_HTML_TAGS, SVG_ATTRIBUTE_NS, SVG_NAMESPACE, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isStaticMarkup, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };