@adaas/are-html 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.conf/tsconfig.base.json +87 -0
- package/.conf/tsconfig.browser.json +34 -0
- package/.conf/tsconfig.node.json +35 -0
- package/.nvmrc +1 -0
- package/LICENSE +13 -0
- package/README.md +678 -0
- package/dist/browser/index.d.mts +521 -0
- package/dist/browser/index.mjs +1782 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/node/AreBinding.attribute-C6JasbJL.d.ts +110 -0
- package/dist/node/AreBinding.attribute-C6qrxN8K.d.mts +110 -0
- package/dist/node/attributes/AreBinding.attribute.d.mts +4 -0
- package/dist/node/attributes/AreBinding.attribute.d.ts +4 -0
- package/dist/node/attributes/AreBinding.attribute.js +15 -0
- package/dist/node/attributes/AreBinding.attribute.js.map +1 -0
- package/dist/node/attributes/AreBinding.attribute.mjs +14 -0
- package/dist/node/attributes/AreBinding.attribute.mjs.map +1 -0
- package/dist/node/attributes/AreDirective.attribute.d.mts +4 -0
- package/dist/node/attributes/AreDirective.attribute.d.ts +4 -0
- package/dist/node/attributes/AreDirective.attribute.js +20 -0
- package/dist/node/attributes/AreDirective.attribute.js.map +1 -0
- package/dist/node/attributes/AreDirective.attribute.mjs +19 -0
- package/dist/node/attributes/AreDirective.attribute.mjs.map +1 -0
- package/dist/node/attributes/AreEvent.attribute.d.mts +4 -0
- package/dist/node/attributes/AreEvent.attribute.d.ts +4 -0
- package/dist/node/attributes/AreEvent.attribute.js +10 -0
- package/dist/node/attributes/AreEvent.attribute.js.map +1 -0
- package/dist/node/attributes/AreEvent.attribute.mjs +9 -0
- package/dist/node/attributes/AreEvent.attribute.mjs.map +1 -0
- package/dist/node/attributes/AreStatic.attribute.d.mts +4 -0
- package/dist/node/attributes/AreStatic.attribute.d.ts +4 -0
- package/dist/node/attributes/AreStatic.attribute.js +10 -0
- package/dist/node/attributes/AreStatic.attribute.js.map +1 -0
- package/dist/node/attributes/AreStatic.attribute.mjs +9 -0
- package/dist/node/attributes/AreStatic.attribute.mjs.map +1 -0
- package/dist/node/chunk-EQQGB2QZ.mjs +15 -0
- package/dist/node/chunk-EQQGB2QZ.mjs.map +1 -0
- package/dist/node/directives/AreComponent.directive.d.mts +2 -0
- package/dist/node/directives/AreComponent.directive.d.ts +2 -0
- package/dist/node/directives/AreComponent.directive.js +4 -0
- package/dist/node/directives/AreComponent.directive.js.map +1 -0
- package/dist/node/directives/AreComponent.directive.mjs +3 -0
- package/dist/node/directives/AreComponent.directive.mjs.map +1 -0
- package/dist/node/directives/AreDirectiveFor.directive.d.mts +41 -0
- package/dist/node/directives/AreDirectiveFor.directive.d.ts +41 -0
- package/dist/node/directives/AreDirectiveFor.directive.js +206 -0
- package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -0
- package/dist/node/directives/AreDirectiveFor.directive.mjs +196 -0
- package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -0
- package/dist/node/directives/AreDirectiveIf.directive.d.mts +15 -0
- package/dist/node/directives/AreDirectiveIf.directive.d.ts +15 -0
- package/dist/node/directives/AreDirectiveIf.directive.js +91 -0
- package/dist/node/directives/AreDirectiveIf.directive.js.map +1 -0
- package/dist/node/directives/AreDirectiveIf.directive.mjs +81 -0
- package/dist/node/directives/AreDirectiveIf.directive.mjs.map +1 -0
- package/dist/node/engine/AreHTML.compiler.d.mts +27 -0
- package/dist/node/engine/AreHTML.compiler.d.ts +27 -0
- package/dist/node/engine/AreHTML.compiler.js +150 -0
- package/dist/node/engine/AreHTML.compiler.js.map +1 -0
- package/dist/node/engine/AreHTML.compiler.mjs +140 -0
- package/dist/node/engine/AreHTML.compiler.mjs.map +1 -0
- package/dist/node/engine/AreHTML.constants.d.mts +2 -0
- package/dist/node/engine/AreHTML.constants.d.ts +2 -0
- package/dist/node/engine/AreHTML.constants.js +4 -0
- package/dist/node/engine/AreHTML.constants.js.map +1 -0
- package/dist/node/engine/AreHTML.constants.mjs +3 -0
- package/dist/node/engine/AreHTML.constants.mjs.map +1 -0
- package/dist/node/engine/AreHTML.context.d.mts +108 -0
- package/dist/node/engine/AreHTML.context.d.ts +108 -0
- package/dist/node/engine/AreHTML.context.js +155 -0
- package/dist/node/engine/AreHTML.context.js.map +1 -0
- package/dist/node/engine/AreHTML.context.mjs +154 -0
- package/dist/node/engine/AreHTML.context.mjs.map +1 -0
- package/dist/node/engine/AreHTML.engine.d.mts +21 -0
- package/dist/node/engine/AreHTML.engine.d.ts +21 -0
- package/dist/node/engine/AreHTML.engine.js +191 -0
- package/dist/node/engine/AreHTML.engine.js.map +1 -0
- package/dist/node/engine/AreHTML.engine.mjs +181 -0
- package/dist/node/engine/AreHTML.engine.mjs.map +1 -0
- package/dist/node/engine/AreHTML.interpreter.d.mts +28 -0
- package/dist/node/engine/AreHTML.interpreter.d.ts +28 -0
- package/dist/node/engine/AreHTML.interpreter.js +340 -0
- package/dist/node/engine/AreHTML.interpreter.js.map +1 -0
- package/dist/node/engine/AreHTML.interpreter.mjs +330 -0
- package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -0
- package/dist/node/engine/AreHTML.lifecycle.d.mts +17 -0
- package/dist/node/engine/AreHTML.lifecycle.d.ts +17 -0
- package/dist/node/engine/AreHTML.lifecycle.js +91 -0
- package/dist/node/engine/AreHTML.lifecycle.js.map +1 -0
- package/dist/node/engine/AreHTML.lifecycle.mjs +79 -0
- package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -0
- package/dist/node/engine/AreHTML.tokenizer.d.mts +13 -0
- package/dist/node/engine/AreHTML.tokenizer.d.ts +13 -0
- package/dist/node/engine/AreHTML.tokenizer.js +83 -0
- package/dist/node/engine/AreHTML.tokenizer.js.map +1 -0
- package/dist/node/engine/AreHTML.tokenizer.mjs +71 -0
- package/dist/node/engine/AreHTML.tokenizer.mjs.map +1 -0
- package/dist/node/engine/AreHTML.transformer.d.mts +11 -0
- package/dist/node/engine/AreHTML.transformer.d.ts +11 -0
- package/dist/node/engine/AreHTML.transformer.js +44 -0
- package/dist/node/engine/AreHTML.transformer.js.map +1 -0
- package/dist/node/engine/AreHTML.transformer.mjs +32 -0
- package/dist/node/engine/AreHTML.transformer.mjs.map +1 -0
- package/dist/node/engine/AreHTML.types.d.mts +6 -0
- package/dist/node/engine/AreHTML.types.d.ts +6 -0
- package/dist/node/engine/AreHTML.types.js +4 -0
- package/dist/node/engine/AreHTML.types.js.map +1 -0
- package/dist/node/engine/AreHTML.types.mjs +3 -0
- package/dist/node/engine/AreHTML.types.mjs.map +1 -0
- package/dist/node/index.d.mts +39 -0
- package/dist/node/index.d.ts +39 -0
- package/dist/node/index.js +294 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/index.mjs +43 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/instructions/AddAttribute.instruction.d.mts +9 -0
- package/dist/node/instructions/AddAttribute.instruction.d.ts +9 -0
- package/dist/node/instructions/AddAttribute.instruction.js +32 -0
- package/dist/node/instructions/AddAttribute.instruction.js.map +1 -0
- package/dist/node/instructions/AddAttribute.instruction.mjs +25 -0
- package/dist/node/instructions/AddAttribute.instruction.mjs.map +1 -0
- package/dist/node/instructions/AddComment.instruction.d.mts +9 -0
- package/dist/node/instructions/AddComment.instruction.d.ts +9 -0
- package/dist/node/instructions/AddComment.instruction.js +35 -0
- package/dist/node/instructions/AddComment.instruction.js.map +1 -0
- package/dist/node/instructions/AddComment.instruction.mjs +28 -0
- package/dist/node/instructions/AddComment.instruction.mjs.map +1 -0
- package/dist/node/instructions/AddElement.instruction.d.mts +8 -0
- package/dist/node/instructions/AddElement.instruction.d.ts +8 -0
- package/dist/node/instructions/AddElement.instruction.js +32 -0
- package/dist/node/instructions/AddElement.instruction.js.map +1 -0
- package/dist/node/instructions/AddElement.instruction.mjs +25 -0
- package/dist/node/instructions/AddElement.instruction.mjs.map +1 -0
- package/dist/node/instructions/AddInterpolation.instruction.d.mts +8 -0
- package/dist/node/instructions/AddInterpolation.instruction.d.ts +8 -0
- package/dist/node/instructions/AddInterpolation.instruction.js +32 -0
- package/dist/node/instructions/AddInterpolation.instruction.js.map +1 -0
- package/dist/node/instructions/AddInterpolation.instruction.mjs +25 -0
- package/dist/node/instructions/AddInterpolation.instruction.mjs.map +1 -0
- package/dist/node/instructions/AddListener.instruction.d.mts +8 -0
- package/dist/node/instructions/AddListener.instruction.d.ts +8 -0
- package/dist/node/instructions/AddListener.instruction.js +32 -0
- package/dist/node/instructions/AddListener.instruction.js.map +1 -0
- package/dist/node/instructions/AddListener.instruction.mjs +25 -0
- package/dist/node/instructions/AddListener.instruction.mjs.map +1 -0
- package/dist/node/instructions/AddStyle.instruction.d.mts +8 -0
- package/dist/node/instructions/AddStyle.instruction.d.ts +8 -0
- package/dist/node/instructions/AddStyle.instruction.js +32 -0
- package/dist/node/instructions/AddStyle.instruction.js.map +1 -0
- package/dist/node/instructions/AddStyle.instruction.mjs +25 -0
- package/dist/node/instructions/AddStyle.instruction.mjs.map +1 -0
- package/dist/node/instructions/AddText.instruction.d.mts +8 -0
- package/dist/node/instructions/AddText.instruction.d.ts +8 -0
- package/dist/node/instructions/AddText.instruction.js +32 -0
- package/dist/node/instructions/AddText.instruction.js.map +1 -0
- package/dist/node/instructions/AddText.instruction.mjs +25 -0
- package/dist/node/instructions/AddText.instruction.mjs.map +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.d.mts +11 -0
- package/dist/node/instructions/AreHTML.instructions.constants.d.ts +11 -0
- package/dist/node/instructions/AreHTML.instructions.constants.js +15 -0
- package/dist/node/instructions/AreHTML.instructions.constants.js.map +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.mjs +15 -0
- package/dist/node/instructions/AreHTML.instructions.constants.mjs.map +1 -0
- package/dist/node/instructions/AreHTML.instructions.types.d.mts +46 -0
- package/dist/node/instructions/AreHTML.instructions.types.d.ts +46 -0
- package/dist/node/instructions/AreHTML.instructions.types.js +4 -0
- package/dist/node/instructions/AreHTML.instructions.types.js.map +1 -0
- package/dist/node/instructions/AreHTML.instructions.types.mjs +3 -0
- package/dist/node/instructions/AreHTML.instructions.types.mjs.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.component.d.mts +4 -0
- package/dist/node/lib/AreDirective/AreDirective.component.d.ts +4 -0
- package/dist/node/lib/AreDirective/AreDirective.component.js +117 -0
- package/dist/node/lib/AreDirective/AreDirective.component.js.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.component.mjs +107 -0
- package/dist/node/lib/AreDirective/AreDirective.component.mjs.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.constants.d.mts +16 -0
- package/dist/node/lib/AreDirective/AreDirective.constants.d.ts +16 -0
- package/dist/node/lib/AreDirective/AreDirective.constants.js +20 -0
- package/dist/node/lib/AreDirective/AreDirective.constants.js.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.constants.mjs +20 -0
- package/dist/node/lib/AreDirective/AreDirective.constants.mjs.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.context.d.mts +9 -0
- package/dist/node/lib/AreDirective/AreDirective.context.d.ts +9 -0
- package/dist/node/lib/AreDirective/AreDirective.context.js +14 -0
- package/dist/node/lib/AreDirective/AreDirective.context.js.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.context.mjs +13 -0
- package/dist/node/lib/AreDirective/AreDirective.context.mjs.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.meta.d.mts +7 -0
- package/dist/node/lib/AreDirective/AreDirective.meta.d.ts +7 -0
- package/dist/node/lib/AreDirective/AreDirective.meta.js +14 -0
- package/dist/node/lib/AreDirective/AreDirective.meta.js.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.meta.mjs +13 -0
- package/dist/node/lib/AreDirective/AreDirective.meta.mjs.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.types.d.mts +17 -0
- package/dist/node/lib/AreDirective/AreDirective.types.d.ts +17 -0
- package/dist/node/lib/AreDirective/AreDirective.types.js +4 -0
- package/dist/node/lib/AreDirective/AreDirective.types.js.map +1 -0
- package/dist/node/lib/AreDirective/AreDirective.types.mjs +3 -0
- package/dist/node/lib/AreDirective/AreDirective.types.mjs.map +1 -0
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.d.mts +13 -0
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.d.ts +13 -0
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.js +82 -0
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.js.map +1 -0
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.mjs +70 -0
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.mjs.map +1 -0
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.d.mts +4 -0
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.d.ts +4 -0
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.js +13 -0
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.js.map +1 -0
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.mjs +12 -0
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.mjs.map +1 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.d.mts +4 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.d.ts +4 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.js +82 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.js.map +1 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs +75 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs.map +1 -0
- package/dist/node/lib/AreRoot/AreRoot.component.d.mts +13 -0
- package/dist/node/lib/AreRoot/AreRoot.component.d.ts +13 -0
- package/dist/node/lib/AreRoot/AreRoot.component.js +117 -0
- package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -0
- package/dist/node/lib/AreRoot/AreRoot.component.mjs +107 -0
- package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -0
- package/dist/node/lib/AreStyle/AreStyle.context.d.mts +8 -0
- package/dist/node/lib/AreStyle/AreStyle.context.d.ts +8 -0
- package/dist/node/lib/AreStyle/AreStyle.context.js +16 -0
- package/dist/node/lib/AreStyle/AreStyle.context.js.map +1 -0
- package/dist/node/lib/AreStyle/AreStyle.context.mjs +15 -0
- package/dist/node/lib/AreStyle/AreStyle.context.mjs.map +1 -0
- package/dist/node/lib/AreStyle/AreStyle.types.d.mts +2 -0
- package/dist/node/lib/AreStyle/AreStyle.types.d.ts +2 -0
- package/dist/node/lib/AreStyle/AreStyle.types.js +4 -0
- package/dist/node/lib/AreStyle/AreStyle.types.js.map +1 -0
- package/dist/node/lib/AreStyle/AreStyle.types.mjs +3 -0
- package/dist/node/lib/AreStyle/AreStyle.types.mjs.map +1 -0
- package/dist/node/lib/AreWatcher/AreWatcher.component.d.mts +18 -0
- package/dist/node/lib/AreWatcher/AreWatcher.component.d.ts +18 -0
- package/dist/node/lib/AreWatcher/AreWatcher.component.js +78 -0
- package/dist/node/lib/AreWatcher/AreWatcher.component.js.map +1 -0
- package/dist/node/lib/AreWatcher/AreWatcher.component.mjs +71 -0
- package/dist/node/lib/AreWatcher/AreWatcher.component.mjs.map +1 -0
- package/dist/node/nodes/AreComment.d.mts +10 -0
- package/dist/node/nodes/AreComment.d.ts +10 -0
- package/dist/node/nodes/AreComment.js +19 -0
- package/dist/node/nodes/AreComment.js.map +1 -0
- package/dist/node/nodes/AreComment.mjs +18 -0
- package/dist/node/nodes/AreComment.mjs.map +1 -0
- package/dist/node/nodes/AreComponent.d.mts +17 -0
- package/dist/node/nodes/AreComponent.d.ts +17 -0
- package/dist/node/nodes/AreComponent.js +35 -0
- package/dist/node/nodes/AreComponent.js.map +1 -0
- package/dist/node/nodes/AreComponent.mjs +28 -0
- package/dist/node/nodes/AreComponent.mjs.map +1 -0
- package/dist/node/nodes/AreInterpolation.d.mts +10 -0
- package/dist/node/nodes/AreInterpolation.d.ts +10 -0
- package/dist/node/nodes/AreInterpolation.js +19 -0
- package/dist/node/nodes/AreInterpolation.js.map +1 -0
- package/dist/node/nodes/AreInterpolation.mjs +18 -0
- package/dist/node/nodes/AreInterpolation.mjs.map +1 -0
- package/dist/node/nodes/AreRoot.d.mts +21 -0
- package/dist/node/nodes/AreRoot.d.ts +21 -0
- package/dist/node/nodes/AreRoot.js +41 -0
- package/dist/node/nodes/AreRoot.js.map +1 -0
- package/dist/node/nodes/AreRoot.mjs +34 -0
- package/dist/node/nodes/AreRoot.mjs.map +1 -0
- package/dist/node/nodes/AreText.d.mts +10 -0
- package/dist/node/nodes/AreText.d.ts +10 -0
- package/dist/node/nodes/AreText.js +19 -0
- package/dist/node/nodes/AreText.js.map +1 -0
- package/dist/node/nodes/AreText.mjs +18 -0
- package/dist/node/nodes/AreText.mjs.map +1 -0
- package/dist/node/signals/AreRoute.signal.d.mts +12 -0
- package/dist/node/signals/AreRoute.signal.d.ts +12 -0
- package/dist/node/signals/AreRoute.signal.js +25 -0
- package/dist/node/signals/AreRoute.signal.js.map +1 -0
- package/dist/node/signals/AreRoute.signal.mjs +24 -0
- package/dist/node/signals/AreRoute.signal.mjs.map +1 -0
- package/docs/a-logo-docs.png +0 -0
- package/examples/dashboard/concept.ts +60 -0
- package/examples/dashboard/containers/UI.container.ts +233 -0
- package/examples/dashboard/dist/index.html +22 -0
- package/examples/dashboard/dist/mnzfypsd-6zjt7w.js +11454 -0
- package/examples/dashboard/dist/styles.css +792 -0
- package/examples/dashboard/public/index.html +22 -0
- package/examples/dashboard/public/styles.css +792 -0
- package/examples/dashboard/src/components/DashboardApp.component.ts +31 -0
- package/examples/dashboard/src/components/DashboardHeader.component.ts +40 -0
- package/examples/dashboard/src/components/DashboardLogo.component.ts +29 -0
- package/examples/dashboard/src/components/DashboardMain.component.ts +57 -0
- package/examples/dashboard/src/components/DashboardMenu.component.ts +94 -0
- package/examples/dashboard/src/components/DashboardNav.component.ts +28 -0
- package/examples/dashboard/src/components/DashboardNavItem.component.ts +32 -0
- package/examples/dashboard/src/components/DashboardSidebar.component.ts +43 -0
- package/examples/dashboard/src/components/DashboardStatCard.component.ts +71 -0
- package/examples/dashboard/src/components/DashboardStats.component.ts +28 -0
- package/examples/dashboard/src/components/DashboardTable.component.ts +138 -0
- package/examples/dashboard/src/components/DashboardUserCard.component.ts +39 -0
- package/examples/dashboard/src/concept.ts +93 -0
- package/examples/jumpstart/concept.ts +60 -0
- package/examples/jumpstart/containers/UI.container.ts +233 -0
- package/examples/jumpstart/dist/index.html +104 -0
- package/examples/jumpstart/dist/mnpl1g4i-nobz9g.js +10882 -0
- package/examples/jumpstart/dist/static/css/main.css +40 -0
- package/examples/jumpstart/dist/static/img/test.png +0 -0
- package/examples/jumpstart/public/index.html +104 -0
- package/examples/jumpstart/public/static/css/main.css +40 -0
- package/examples/jumpstart/public/static/img/test.png +0 -0
- package/examples/jumpstart/src/components/A-Btn.component.ts +150 -0
- package/examples/jumpstart/src/components/A-Input.component.ts +78 -0
- package/examples/jumpstart/src/components/A-Navigation.component.ts +167 -0
- package/examples/jumpstart/src/components/List.component.ts +138 -0
- package/examples/jumpstart/src/components/PromptTextArea.component.ts +359 -0
- package/examples/jumpstart/src/components/SignInComponent.component.ts +127 -0
- package/examples/jumpstart/src/concept.ts +105 -0
- package/jest.config.ts +61 -0
- package/package.json +110 -0
- package/src/attributes/AreBinding.attribute.ts +19 -0
- package/src/attributes/AreDirective.attribute.ts +26 -0
- package/src/attributes/AreEvent.attribute.ts +5 -0
- package/src/attributes/AreStatic.attribute.ts +6 -0
- package/src/directives/AreComponent.directive.ts +0 -0
- package/src/directives/AreDirectiveFor.directive.ts +322 -0
- package/src/directives/AreDirectiveIf.directive.ts +130 -0
- package/src/engine/AreHTML.compiler.ts +226 -0
- package/src/engine/AreHTML.constants.ts +2 -0
- package/src/engine/AreHTML.context.ts +196 -0
- package/src/engine/AreHTML.engine.ts +210 -0
- package/src/engine/AreHTML.interpreter.ts +466 -0
- package/src/engine/AreHTML.lifecycle.ts +96 -0
- package/src/engine/AreHTML.tokenizer.ts +90 -0
- package/src/engine/AreHTML.transformer.ts +37 -0
- package/src/engine/AreHTML.types.ts +6 -0
- package/src/index.ts +80 -0
- package/src/instructions/AddAttribute.instruction.ts +25 -0
- package/src/instructions/AddComment.instruction.ts +27 -0
- package/src/instructions/AddElement.instruction.ts +22 -0
- package/src/instructions/AddInterpolation.instruction.ts +24 -0
- package/src/instructions/AddListener.instruction.ts +24 -0
- package/src/instructions/AddStyle.instruction.ts +24 -0
- package/src/instructions/AddText.instruction.ts +21 -0
- package/src/instructions/AreHTML.instructions.constants.ts +11 -0
- package/src/instructions/AreHTML.instructions.types.ts +51 -0
- package/src/lib/AreDirective/AreDirective.component.ts +124 -0
- package/src/lib/AreDirective/AreDirective.constants.ts +16 -0
- package/src/lib/AreDirective/AreDirective.context.ts +16 -0
- package/src/lib/AreDirective/AreDirective.meta.ts +9 -0
- package/src/lib/AreDirective/AreDirective.types.ts +14 -0
- package/src/lib/AreHTML/AreHTML.tokenizer.ts +86 -0
- package/src/lib/AreHTMLAttribute/AreHTML.attribute.ts +13 -0
- package/src/lib/AreHTMLNode/AreHTMLNode.ts +84 -0
- package/src/lib/AreRoot/AreRoot.component.ts +134 -0
- package/src/lib/AreStyle/AreStyle.context.ts +20 -0
- package/src/lib/AreStyle/AreStyle.types.ts +0 -0
- package/src/lib/AreWatcher/AreWatcher.component.ts +84 -0
- package/src/nodes/AreComment.ts +17 -0
- package/src/nodes/AreComponent.ts +25 -0
- package/src/nodes/AreInterpolation.ts +16 -0
- package/src/nodes/AreRoot.ts +29 -0
- package/src/nodes/AreText.ts +17 -0
- package/src/signals/AreRoute.signal.ts +27 -0
- package/tests/AreTokenizer.test.ts +260 -0
- package/tests/jest.setup.ts +30 -0
- package/tsconfig.json +60 -0
- package/tslint.json +98 -0
- package/tsup.config.ts +108 -0
|
@@ -0,0 +1,1782 @@
|
|
|
1
|
+
import { AreStore, AreScene, AreSyntax, AreCompiler, AreInterpreter, AreInstructionDefaultNames, AreNodeFeatures, AreContext, AreLifecycle, AreSignalsContext, AreAttributeFeatures, Are, AreNode, AreAttribute, AreCompilerError, AreMutation, AreDeclaration, AreSignal, AreInterpreterError, AreTokenizer, AreTransformer, AreEngine, AreRoute as AreRoute$1, AreSignals, AreEvent } from '@adaas/are';
|
|
2
|
+
import { A_Inject, A_Caller, A_Feature, A_Meta, A_Scope, A_Dependency, A_Component, A_Context, A_ComponentMeta, A_FormatterHelper, A_Fragment } from '@adaas/a-concept';
|
|
3
|
+
import { A_Logger } from '@adaas/a-utils/a-logger';
|
|
4
|
+
import { A_Frame } from '@adaas/a-frame';
|
|
5
|
+
import { A_ExecutionContext } from '@adaas/a-utils/a-execution';
|
|
6
|
+
import { A_Route } from '@adaas/a-utils/a-route';
|
|
7
|
+
import { A_ServiceFeatures } from '@adaas/a-utils/a-service';
|
|
8
|
+
import { A_SignalVector } from '@adaas/a-utils/a-signal';
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
13
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
14
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
15
|
+
if (decorator = decorators[i])
|
|
16
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
17
|
+
if (kind && result) __defProp(target, key, result);
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
21
|
+
var AreHTMLAttribute = class extends AreAttribute {
|
|
22
|
+
get owner() {
|
|
23
|
+
return this.scope.issuer();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/attributes/AreBinding.attribute.ts
|
|
28
|
+
var AreBindingAttribute = class extends AreHTMLAttribute {
|
|
29
|
+
// get value(): string {
|
|
30
|
+
// const [firstPart, ...pathPart] = this.content.split('.');
|
|
31
|
+
// const primaryObject = this.owner.store.get(firstPart);
|
|
32
|
+
// return AreCommonHelper.extractPropertyByPath(primaryObject, pathPart.join('.')) as string;
|
|
33
|
+
// }
|
|
34
|
+
};
|
|
35
|
+
var AreDirectiveAttribute = class extends AreHTMLAttribute {
|
|
36
|
+
/**
|
|
37
|
+
* Returns a custom directive component associated with this attribute, if available.
|
|
38
|
+
*
|
|
39
|
+
* The method uses the attribute's name to resolve the corresponding directive component from the scope. It constructs the expected directive name by converting the attribute name to PascalCase and prefixing it with "AreDirective". If a matching directive component is found in the scope, it is returned; otherwise, the method returns undefined.
|
|
40
|
+
*/
|
|
41
|
+
get component() {
|
|
42
|
+
const component = this.scope.resolve(`AreDirective${A_FormatterHelper.toPascalCase(this.name)}`);
|
|
43
|
+
return component;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/attributes/AreEvent.attribute.ts
|
|
48
|
+
var AreEventAttribute = class extends AreHTMLAttribute {
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// src/attributes/AreStatic.attribute.ts
|
|
52
|
+
var AreStaticAttribute = class extends AreHTMLAttribute {
|
|
53
|
+
};
|
|
54
|
+
var AreDirectiveMeta = class extends A_ComponentMeta {
|
|
55
|
+
constructor() {
|
|
56
|
+
super(...arguments);
|
|
57
|
+
this.priority = 0;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/lib/AreDirective/AreDirective.constants.ts
|
|
62
|
+
var AreDirectiveFeatures = {
|
|
63
|
+
/**
|
|
64
|
+
* Feature that should transform the tree based on the directive attribute. This method is called during the transformation phase of the ARE component and should perform any necessary transformations on the AreNode tree based on the directive's content and context. This can include tasks such as adding or removing nodes, modifying node properties, or restructuring the tree to ensure that the directive is applied correctly during rendering.
|
|
65
|
+
*/
|
|
66
|
+
Transform: "_AreDirective_Transform",
|
|
67
|
+
/**
|
|
68
|
+
* Feature that should convert a directiveAttribute definition into a set of SceneInstructions to be rendered correctly
|
|
69
|
+
*/
|
|
70
|
+
Compile: "_AreDirective_Compile",
|
|
71
|
+
/**
|
|
72
|
+
* Feature that should update the directiveAttribute based on the changes in the store or other dependencies.
|
|
73
|
+
*/
|
|
74
|
+
Update: "_AreDirective_Update"
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/lib/AreDirective/AreDirective.component.ts
|
|
78
|
+
var AreDirective = class extends A_Component {
|
|
79
|
+
//==================================================================================
|
|
80
|
+
//======================== LIFECYCLE DECORATORS ====================================
|
|
81
|
+
//==================================================================================
|
|
82
|
+
/**
|
|
83
|
+
* Allows to define a compilation order for directives, which is necessary when we have multiple directives on the same node and we want to control the order of their compilation and application. The directive with the highest priority will be compiled and applied first, and the directive with the lowest priority will be compiled and applied last. This is important because some directives may depend on the output of other directives, so we need to ensure that they are compiled and applied in the correct order to avoid errors and ensure the expected behavior.
|
|
84
|
+
*
|
|
85
|
+
* @param priority
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
static Priority(priority) {
|
|
89
|
+
return function(target) {
|
|
90
|
+
const meta = A_Context.meta(target);
|
|
91
|
+
meta.priority = priority;
|
|
92
|
+
return target;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Allows to define a custom method for transforming the AreNode tree based on the directive attribute. This method is called during the transformation phase of the ARE component and should perform any necessary transformations on the AreNode tree based on the directive's content and context. This can include tasks such as adding or removing nodes, modifying node properties, or restructuring the tree to ensure that the directive is applied correctly during rendering.
|
|
97
|
+
*/
|
|
98
|
+
static get Transform() {
|
|
99
|
+
return (target, propertyKey, descriptor) => {
|
|
100
|
+
return A_Feature.Extend({
|
|
101
|
+
name: AreDirectiveFeatures.Transform,
|
|
102
|
+
scope: [target.constructor]
|
|
103
|
+
})(target, propertyKey, descriptor);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Allows to define a custom method for compiling a directive attribute into a set of SceneInstructions.
|
|
108
|
+
* Can be used at any component to extend this logic not only for a AreDirective inherited.
|
|
109
|
+
*/
|
|
110
|
+
static get Compile() {
|
|
111
|
+
return (target, propertyKey, descriptor) => {
|
|
112
|
+
return A_Feature.Extend({
|
|
113
|
+
name: AreDirectiveFeatures.Compile,
|
|
114
|
+
scope: [target.constructor]
|
|
115
|
+
})(target, propertyKey, descriptor);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Allows to define a custom method for updating a directive attribute based on changes in the store or other dependencies.
|
|
120
|
+
* Can be used at any component to extend this logic not only for a AreDirective inherited.
|
|
121
|
+
*/
|
|
122
|
+
static get Update() {
|
|
123
|
+
return (target, propertyKey, descriptor) => {
|
|
124
|
+
return A_Feature.Extend({
|
|
125
|
+
name: AreDirectiveFeatures.Update,
|
|
126
|
+
scope: [target.constructor]
|
|
127
|
+
})(target, propertyKey, descriptor);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Default transform method for directives, which can be overridden by specific directive implementations. This method is called during the transformation phase of the ARE component and should perform any necessary transformations on the AreNode tree based on the directive's content and context. This can include tasks such as adding or removing nodes, modifying node properties, or restructuring the tree to ensure that the directive is applied correctly during rendering.
|
|
132
|
+
*
|
|
133
|
+
* @param attribute - The directive attribute to transform, which contains all the information about the directive as defined in the template (e.g. name, raw content, evaluated value, etc.)
|
|
134
|
+
* @param args - Additional arguments that may be required for the transformation process.
|
|
135
|
+
*/
|
|
136
|
+
transform(attribute, ...args) {
|
|
137
|
+
const logger = A_Context.scope(this).resolve(A_Logger);
|
|
138
|
+
if (logger) {
|
|
139
|
+
logger.warning(`No transforming logic defined for directive: ${attribute.name} with content: ${attribute.content}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
compile(attribute, ...args) {
|
|
143
|
+
const logger = A_Context.scope(this).resolve(A_Logger);
|
|
144
|
+
if (logger) {
|
|
145
|
+
logger.warning(`No compiling logic defined for directive: ${attribute.name} with content: ${attribute.content}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
update(attribute, ...args) {
|
|
149
|
+
const logger = A_Context.scope(this).resolve(A_Logger);
|
|
150
|
+
if (logger) {
|
|
151
|
+
logger.warning(`No update logic defined for directive: ${attribute.name} with content: ${attribute.content}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
__decorateClass([
|
|
156
|
+
__decorateParam(0, A_Inject(A_Caller))
|
|
157
|
+
], AreDirective.prototype, "transform", 1);
|
|
158
|
+
__decorateClass([
|
|
159
|
+
A_Feature.Extend({
|
|
160
|
+
name: AreDirectiveFeatures.Compile,
|
|
161
|
+
scope: [AreDirective]
|
|
162
|
+
}),
|
|
163
|
+
__decorateParam(0, A_Inject(A_Caller))
|
|
164
|
+
], AreDirective.prototype, "compile", 1);
|
|
165
|
+
__decorateClass([
|
|
166
|
+
A_Feature.Extend({
|
|
167
|
+
name: AreDirectiveFeatures.Update,
|
|
168
|
+
scope: [AreDirective]
|
|
169
|
+
}),
|
|
170
|
+
__decorateParam(0, A_Inject(A_Caller))
|
|
171
|
+
], AreDirective.prototype, "update", 1);
|
|
172
|
+
AreDirective = __decorateClass([
|
|
173
|
+
A_Meta.Define(AreDirectiveMeta)
|
|
174
|
+
], AreDirective);
|
|
175
|
+
|
|
176
|
+
// src/instructions/AreHTML.instructions.constants.ts
|
|
177
|
+
var AreHTMLInstructions = {
|
|
178
|
+
AddElement: "_AreHTML_AddElement",
|
|
179
|
+
AddText: "_AreHTML_AddText",
|
|
180
|
+
AddAttribute: "_AreHTML_AddAttribute",
|
|
181
|
+
AddStyle: "_AreHTML_AddStyle",
|
|
182
|
+
AddListener: "_AreHTML_AddListener",
|
|
183
|
+
AddInterpolation: "_AreHTML_AddInterpolation",
|
|
184
|
+
AddComment: "_AreHTML_AddComment"
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// src/instructions/AddComment.instruction.ts
|
|
188
|
+
var AddCommentInstruction = class extends AreDeclaration {
|
|
189
|
+
get content() {
|
|
190
|
+
return this.payload.content;
|
|
191
|
+
}
|
|
192
|
+
constructor(props) {
|
|
193
|
+
if ("aseid" in props) {
|
|
194
|
+
super(props);
|
|
195
|
+
} else {
|
|
196
|
+
super(AreHTMLInstructions.AddComment, props);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
AddCommentInstruction = __decorateClass([
|
|
201
|
+
A_Frame.Component({
|
|
202
|
+
namespace: "A-ARE",
|
|
203
|
+
name: "AddCommentInstruction",
|
|
204
|
+
description: "Appends a comment node to an element. Apply creates the comment node; revert removes it. Content can be a static string or a dynamic getter for interpolations."
|
|
205
|
+
})
|
|
206
|
+
], AddCommentInstruction);
|
|
207
|
+
var AreDirectiveContext = class extends A_ExecutionContext {
|
|
208
|
+
constructor(aseid) {
|
|
209
|
+
super(aseid.toString());
|
|
210
|
+
this.scope = {};
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// src/directives/AreDirectiveFor.directive.ts
|
|
215
|
+
var AreDirectiveFor = class extends AreDirective {
|
|
216
|
+
transform(attribute, scope, store, scene, logger, ...args) {
|
|
217
|
+
logger.debug(`[Transform] directive $FOR for <${attribute.owner.aseid.toString()}>`);
|
|
218
|
+
const node = attribute.owner;
|
|
219
|
+
const forTemplate = node.cloneWithScope();
|
|
220
|
+
const forAttr = forTemplate.attributes.find((d) => d.name === attribute.name);
|
|
221
|
+
if (forAttr) {
|
|
222
|
+
forTemplate.scope.deregister(forAttr);
|
|
223
|
+
node.scope.register(forAttr);
|
|
224
|
+
}
|
|
225
|
+
node.init();
|
|
226
|
+
attribute.template = forTemplate;
|
|
227
|
+
const { key, index, arrayExpr } = this.parseExpression(attribute.content);
|
|
228
|
+
const array = this.resolveArray(store, arrayExpr, attribute.content);
|
|
229
|
+
attribute.value = array;
|
|
230
|
+
console.log('Initial array for "for" directive:', scene);
|
|
231
|
+
for (let i = 0; i < array.length; i++) {
|
|
232
|
+
this.spawnItemNode(attribute.template, attribute.owner, key, index, array[i], i);
|
|
233
|
+
}
|
|
234
|
+
console.log('Template for "for" directive:', forTemplate);
|
|
235
|
+
}
|
|
236
|
+
compile(attribute, store, scene, ...args) {
|
|
237
|
+
const hostInstruction = scene.host;
|
|
238
|
+
const commentIdentifier = ` --- for: ${attribute.template.id} --- `;
|
|
239
|
+
const declaration = new AddCommentInstruction({ content: commentIdentifier });
|
|
240
|
+
scene.setHost(declaration);
|
|
241
|
+
scene.planBefore(declaration, hostInstruction);
|
|
242
|
+
scene.unPlan(hostInstruction);
|
|
243
|
+
}
|
|
244
|
+
update(attribute, store, scene, ...args) {
|
|
245
|
+
const { key, index, arrayExpr } = this.parseExpression(attribute.content);
|
|
246
|
+
const newArray = this.resolveArray(store, arrayExpr, attribute.content);
|
|
247
|
+
const owner = attribute.owner;
|
|
248
|
+
const currentChildren = [...owner.children];
|
|
249
|
+
attribute.value = newArray;
|
|
250
|
+
const newLen = newArray.length;
|
|
251
|
+
const newItemSet = new Set(newArray);
|
|
252
|
+
const keptChildren = [];
|
|
253
|
+
const removedChildren = [];
|
|
254
|
+
for (const child of currentChildren) {
|
|
255
|
+
const ctx = child.scope.resolveFlat(AreDirectiveContext);
|
|
256
|
+
if (ctx && newItemSet.has(ctx.scope[key])) {
|
|
257
|
+
keptChildren.push(child);
|
|
258
|
+
} else {
|
|
259
|
+
removedChildren.push(child);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
for (const child of removedChildren) {
|
|
263
|
+
child.unmount();
|
|
264
|
+
owner.removeChild(child);
|
|
265
|
+
}
|
|
266
|
+
for (let i = 0; i < keptChildren.length; i++) {
|
|
267
|
+
let directiveContext = keptChildren[i].scope.resolveFlat(AreDirectiveContext);
|
|
268
|
+
if (!directiveContext) {
|
|
269
|
+
directiveContext = new AreDirectiveContext(keptChildren[i].aseid);
|
|
270
|
+
keptChildren[i].scope.register(directiveContext);
|
|
271
|
+
}
|
|
272
|
+
directiveContext.scope = {
|
|
273
|
+
...directiveContext.scope,
|
|
274
|
+
[key]: newArray[i],
|
|
275
|
+
[index || "index"]: i
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
for (let i = keptChildren.length; i < newLen; i++) {
|
|
279
|
+
const itemNode = this.spawnItemNode(attribute.template, owner, key, index, newArray[i], i);
|
|
280
|
+
itemNode.transform();
|
|
281
|
+
itemNode.compile();
|
|
282
|
+
itemNode.mount();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
286
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
287
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
288
|
+
/**
|
|
289
|
+
* Parses the $for expression string into its constituent parts.
|
|
290
|
+
*
|
|
291
|
+
* Supported formats:
|
|
292
|
+
* item in items
|
|
293
|
+
* item, index in items
|
|
294
|
+
* (item, index) in items
|
|
295
|
+
* item in filter(items)
|
|
296
|
+
* item, index in filter(items, 'active')
|
|
297
|
+
*/
|
|
298
|
+
parseExpression(content) {
|
|
299
|
+
const inIndex = content.lastIndexOf(" in ");
|
|
300
|
+
const keyAndIndex = content.slice(0, inIndex).trim().replace(/^\(|\)$/g, "");
|
|
301
|
+
const arrayExpr = content.slice(inIndex + 4).trim();
|
|
302
|
+
const keyParts = keyAndIndex.split(",").map((p) => p.trim());
|
|
303
|
+
return {
|
|
304
|
+
key: keyParts[0],
|
|
305
|
+
index: keyParts[1] || void 0,
|
|
306
|
+
arrayExpr
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Resolves the array expression against the store.
|
|
311
|
+
* Supports both plain key lookups and function-call expressions:
|
|
312
|
+
* items → store.get('items')
|
|
313
|
+
* filter(items) → store.get('filter')(store.get('items'))
|
|
314
|
+
*/
|
|
315
|
+
resolveArray(store, arrayExpr, fullContent) {
|
|
316
|
+
let result;
|
|
317
|
+
const callMatch = arrayExpr.match(/^([^(]+)\((.+)\)$/);
|
|
318
|
+
if (callMatch) {
|
|
319
|
+
const fnName = callMatch[1].trim();
|
|
320
|
+
const fn = store.get(fnName);
|
|
321
|
+
if (typeof fn !== "function")
|
|
322
|
+
throw new AreCompilerError({
|
|
323
|
+
title: 'Invalid "for" Directive Function',
|
|
324
|
+
description: `The expression "${fnName}" in the "for" directive does not resolve to a function in the store. Received: ${typeof fn}`
|
|
325
|
+
});
|
|
326
|
+
const rawArgs = callMatch[2].split(",").map((a) => a.trim());
|
|
327
|
+
const resolvedArgs = rawArgs.map((arg) => {
|
|
328
|
+
if (arg.startsWith("'") && arg.endsWith("'")) return arg.slice(1, -1);
|
|
329
|
+
if (arg.startsWith('"') && arg.endsWith('"')) return arg.slice(1, -1);
|
|
330
|
+
if (!isNaN(Number(arg))) return Number(arg);
|
|
331
|
+
return store.get(arg);
|
|
332
|
+
});
|
|
333
|
+
result = fn(...resolvedArgs);
|
|
334
|
+
} else {
|
|
335
|
+
result = store.get(arrayExpr);
|
|
336
|
+
}
|
|
337
|
+
if (!Array.isArray(result))
|
|
338
|
+
throw new AreCompilerError({
|
|
339
|
+
title: 'Invalid "for" Directive Value',
|
|
340
|
+
description: `The "for" directive expects an array but got ${typeof result}. Expression: "${fullContent}". Received: ${JSON.stringify(result)}`
|
|
341
|
+
});
|
|
342
|
+
return result;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Creates a single item node from the template, registers it as a child of
|
|
346
|
+
* the owner, initialises it, injects item-scoped store values, and activates
|
|
347
|
+
* its scene so the mount/compile cycle will include it.
|
|
348
|
+
*
|
|
349
|
+
* NOTE: This method does NOT call compile() or mount() — the caller is
|
|
350
|
+
* responsible for doing so when the main lifecycle cycle won't cover it
|
|
351
|
+
* (i.e. during update, but not during the initial compile phase).
|
|
352
|
+
*/
|
|
353
|
+
spawnItemNode(template, owner, key, index, item, i) {
|
|
354
|
+
const itemNode = template.clone();
|
|
355
|
+
owner.addChild(itemNode);
|
|
356
|
+
const queue = [itemNode];
|
|
357
|
+
while (queue.length > 0) {
|
|
358
|
+
const current = queue.shift();
|
|
359
|
+
current.init();
|
|
360
|
+
queue.push(...current.children);
|
|
361
|
+
}
|
|
362
|
+
let directiveContext = itemNode.scope.resolveFlat(AreDirectiveContext);
|
|
363
|
+
if (!directiveContext) {
|
|
364
|
+
directiveContext = new AreDirectiveContext(itemNode.aseid);
|
|
365
|
+
itemNode.scope.register(directiveContext);
|
|
366
|
+
}
|
|
367
|
+
directiveContext.scope = {
|
|
368
|
+
...directiveContext.scope,
|
|
369
|
+
[key]: item,
|
|
370
|
+
[index || "index"]: i
|
|
371
|
+
};
|
|
372
|
+
itemNode.scene.activate();
|
|
373
|
+
return itemNode;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
__decorateClass([
|
|
377
|
+
AreDirective.Transform,
|
|
378
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
379
|
+
__decorateParam(1, A_Inject(A_Scope)),
|
|
380
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
381
|
+
__decorateParam(3, A_Inject(AreScene)),
|
|
382
|
+
__decorateParam(4, A_Inject(A_Logger))
|
|
383
|
+
], AreDirectiveFor.prototype, "transform", 1);
|
|
384
|
+
__decorateClass([
|
|
385
|
+
AreDirective.Compile,
|
|
386
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
387
|
+
__decorateParam(1, A_Inject(AreStore)),
|
|
388
|
+
__decorateParam(2, A_Inject(AreScene))
|
|
389
|
+
], AreDirectiveFor.prototype, "compile", 1);
|
|
390
|
+
__decorateClass([
|
|
391
|
+
AreDirective.Update,
|
|
392
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
393
|
+
__decorateParam(1, A_Inject(AreStore)),
|
|
394
|
+
__decorateParam(2, A_Inject(AreScene))
|
|
395
|
+
], AreDirectiveFor.prototype, "update", 1);
|
|
396
|
+
AreDirectiveFor = __decorateClass([
|
|
397
|
+
AreDirective.Priority(1)
|
|
398
|
+
], AreDirectiveFor);
|
|
399
|
+
var AreDirectiveIf = class extends AreDirective {
|
|
400
|
+
transform(attribute, scope, store, scene, logger, ...args) {
|
|
401
|
+
logger.debug(`[Transform] directive $IF for <${attribute.owner.aseid.toString()}>`);
|
|
402
|
+
const node = attribute.owner;
|
|
403
|
+
const ifTemplate = node.cloneWithScope();
|
|
404
|
+
const ifAttr = ifTemplate.attributes.find((d) => d.name === attribute.name);
|
|
405
|
+
if (ifAttr) {
|
|
406
|
+
ifTemplate.scope.deregister(ifAttr);
|
|
407
|
+
node.scope.register(ifAttr);
|
|
408
|
+
}
|
|
409
|
+
node.init();
|
|
410
|
+
node.addChild(ifTemplate);
|
|
411
|
+
ifTemplate.scene.deactivate();
|
|
412
|
+
attribute.template = ifTemplate;
|
|
413
|
+
}
|
|
414
|
+
compile(attribute, store, scene, syntax, directiveContext, ...args) {
|
|
415
|
+
console.log('Compiling directive "if" with attribute content:', attribute);
|
|
416
|
+
attribute.value = syntax.evaluate(attribute.content, store, {
|
|
417
|
+
...directiveContext?.scope || {}
|
|
418
|
+
});
|
|
419
|
+
const hostInstruction = scene.host;
|
|
420
|
+
const commentIdentifier = ` --- if: ${attribute.template.id} --- `;
|
|
421
|
+
const declaration = new AddCommentInstruction({ content: commentIdentifier });
|
|
422
|
+
scene.setHost(declaration);
|
|
423
|
+
scene.planBefore(declaration, hostInstruction);
|
|
424
|
+
scene.unPlan(hostInstruction);
|
|
425
|
+
if (attribute.value)
|
|
426
|
+
attribute.template.scene.activate();
|
|
427
|
+
else
|
|
428
|
+
attribute.template.scene.deactivate();
|
|
429
|
+
}
|
|
430
|
+
update(attribute, store, scope, syntax, scene, ...args) {
|
|
431
|
+
attribute.value = syntax.evaluate(attribute.content, store);
|
|
432
|
+
if (attribute.value) {
|
|
433
|
+
attribute.template.scene.activate();
|
|
434
|
+
attribute.template.mount();
|
|
435
|
+
} else {
|
|
436
|
+
attribute.template.unmount();
|
|
437
|
+
attribute.template.scene.deactivate();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
__decorateClass([
|
|
442
|
+
AreDirective.Transform,
|
|
443
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
444
|
+
__decorateParam(1, A_Inject(A_Scope)),
|
|
445
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
446
|
+
__decorateParam(3, A_Inject(AreScene)),
|
|
447
|
+
__decorateParam(4, A_Inject(A_Logger))
|
|
448
|
+
], AreDirectiveIf.prototype, "transform", 1);
|
|
449
|
+
__decorateClass([
|
|
450
|
+
AreDirective.Compile,
|
|
451
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
452
|
+
__decorateParam(1, A_Inject(AreStore)),
|
|
453
|
+
__decorateParam(2, A_Inject(AreScene)),
|
|
454
|
+
__decorateParam(3, A_Inject(AreSyntax)),
|
|
455
|
+
__decorateParam(4, A_Inject(AreDirectiveContext))
|
|
456
|
+
], AreDirectiveIf.prototype, "compile", 1);
|
|
457
|
+
__decorateClass([
|
|
458
|
+
AreDirective.Update,
|
|
459
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
460
|
+
__decorateParam(1, A_Inject(AreStore)),
|
|
461
|
+
__decorateParam(2, A_Inject(A_Scope)),
|
|
462
|
+
__decorateParam(3, A_Inject(AreSyntax)),
|
|
463
|
+
__decorateParam(4, A_Inject(AreScene))
|
|
464
|
+
], AreDirectiveIf.prototype, "update", 1);
|
|
465
|
+
AreDirectiveIf = __decorateClass([
|
|
466
|
+
AreDirective.Priority(2)
|
|
467
|
+
], AreDirectiveIf);
|
|
468
|
+
var AddAttributeInstruction = class extends AreMutation {
|
|
469
|
+
constructor(parent, props) {
|
|
470
|
+
if ("aseid" in props) {
|
|
471
|
+
super(props);
|
|
472
|
+
} else {
|
|
473
|
+
super(AreHTMLInstructions.AddAttribute, parent, props);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
AddAttributeInstruction = __decorateClass([
|
|
478
|
+
A_Frame.Component({
|
|
479
|
+
namespace: "A-ARE",
|
|
480
|
+
name: "AddAttributeInstruction",
|
|
481
|
+
description: "Sets an attribute on an HTML element. Apply calls setAttribute; revert calls removeAttribute."
|
|
482
|
+
})
|
|
483
|
+
], AddAttributeInstruction);
|
|
484
|
+
var AddElementInstruction = class extends AreDeclaration {
|
|
485
|
+
constructor(props) {
|
|
486
|
+
if ("aseid" in props) {
|
|
487
|
+
super(props);
|
|
488
|
+
} else {
|
|
489
|
+
super(AreHTMLInstructions.AddElement, props);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
AddElementInstruction = __decorateClass([
|
|
494
|
+
A_Frame.Component({
|
|
495
|
+
namespace: "A-ARE",
|
|
496
|
+
name: "AddElementInstruction",
|
|
497
|
+
description: "Creates a new HTML element in the DOM. Apply creates the element; revert removes it."
|
|
498
|
+
})
|
|
499
|
+
], AddElementInstruction);
|
|
500
|
+
var AddInterpolationInstruction = class extends AreMutation {
|
|
501
|
+
constructor(parent, props) {
|
|
502
|
+
if ("aseid" in props) {
|
|
503
|
+
super(props);
|
|
504
|
+
} else {
|
|
505
|
+
super(AreHTMLInstructions.AddInterpolation, parent, props);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
AddInterpolationInstruction = __decorateClass([
|
|
510
|
+
A_Frame.Component({
|
|
511
|
+
namespace: "A-ARE",
|
|
512
|
+
name: "AddInterpolationInstruction",
|
|
513
|
+
description: "Appends a reactive text node whose content is resolved dynamically from the store. Apply creates the text node with the getter; revert removes it."
|
|
514
|
+
})
|
|
515
|
+
], AddInterpolationInstruction);
|
|
516
|
+
var AddListenerInstruction = class extends AreMutation {
|
|
517
|
+
constructor(parent, props) {
|
|
518
|
+
if ("aseid" in props) {
|
|
519
|
+
super(props);
|
|
520
|
+
} else {
|
|
521
|
+
super(AreHTMLInstructions.AddListener, parent, props);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
AddListenerInstruction = __decorateClass([
|
|
526
|
+
A_Frame.Component({
|
|
527
|
+
namespace: "A-ARE",
|
|
528
|
+
name: "AddListenerInstruction",
|
|
529
|
+
description: "Attaches a DOM event listener to an element. Apply calls addEventListener; revert calls removeEventListener."
|
|
530
|
+
})
|
|
531
|
+
], AddListenerInstruction);
|
|
532
|
+
var AddStyleInstruction = class extends AreMutation {
|
|
533
|
+
constructor(parent, props) {
|
|
534
|
+
if ("aseid" in props) {
|
|
535
|
+
super(props);
|
|
536
|
+
} else {
|
|
537
|
+
super(AreHTMLInstructions.AddStyle, parent, props);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
AddStyleInstruction = __decorateClass([
|
|
542
|
+
A_Frame.Component({
|
|
543
|
+
namespace: "A-ARE",
|
|
544
|
+
name: "AddStyleInstruction",
|
|
545
|
+
description: "Sets an inline CSS style property on an element. Apply sets the property; revert removes it."
|
|
546
|
+
})
|
|
547
|
+
], AddStyleInstruction);
|
|
548
|
+
var AddTextInstruction = class extends AreDeclaration {
|
|
549
|
+
constructor(props) {
|
|
550
|
+
if ("aseid" in props) {
|
|
551
|
+
super(props);
|
|
552
|
+
} else {
|
|
553
|
+
super(AreHTMLInstructions.AddText, props);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
AddTextInstruction = __decorateClass([
|
|
558
|
+
A_Frame.Component({
|
|
559
|
+
namespace: "A-ARE",
|
|
560
|
+
name: "AddTextInstruction",
|
|
561
|
+
description: "Appends a text node to an element. Apply creates the text node; revert removes it. Content can be a static string or a dynamic getter for interpolations."
|
|
562
|
+
})
|
|
563
|
+
], AddTextInstruction);
|
|
564
|
+
var AreStyle = class extends A_Fragment {
|
|
565
|
+
constructor(styles, aseid) {
|
|
566
|
+
super({
|
|
567
|
+
name: aseid ? aseid.toString() : "default-style"
|
|
568
|
+
});
|
|
569
|
+
this.styles = styles;
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
// src/lib/AreHTMLNode/AreHTMLNode.ts
|
|
574
|
+
var AreHTMLNode = class extends AreNode {
|
|
575
|
+
/**
|
|
576
|
+
* Actual node type.
|
|
577
|
+
* By default it's a tag name
|
|
578
|
+
*/
|
|
579
|
+
get tag() {
|
|
580
|
+
return this.aseid.entity;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* The static attributes defined for the node, which are typically used to represent static properties or characteristics of the node that do not change based on the context or state. These attributes are usually defined in the template and are not reactive.
|
|
584
|
+
*
|
|
585
|
+
* Example: For a node defined as `<div class="static-class">`, the static attribute would be `class="static-class"`.
|
|
586
|
+
*/
|
|
587
|
+
get staticAttributes() {
|
|
588
|
+
return this.scope.resolveFlatAll(AreStaticAttribute);
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* The binding attributes defined for the node, which are typically used to represent dynamic properties or characteristics of the node that can change based on the context or state. These attributes are usually defined in the template with a specific syntax (e.g., `:prop="value"` or `v-bind:prop="value"`) and are reactive, meaning that they will update automatically when the underlying data changes.
|
|
592
|
+
*
|
|
593
|
+
* Example: For a node defined as `<div :class="dynamicClass">`, the binding attribute would be `:class="dynamicClass"`.
|
|
594
|
+
*/
|
|
595
|
+
get bindings() {
|
|
596
|
+
return this.scope.resolveFlatAll(AreBindingAttribute);
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* The directive attributes defined for the node, which are typically used to represent special instructions or behaviors that should be applied to the node. These attributes are usually defined in the template with a specific syntax (e.g., `v-if="condition"` or `v-for="item in list"`) and are processed by the rendering engine to apply the corresponding logic or behavior to the node.
|
|
600
|
+
*
|
|
601
|
+
* Example: For a node defined as `<div v-if="isVisible">`, the directive attribute would be `v-if="isVisible"`.
|
|
602
|
+
*/
|
|
603
|
+
get directives() {
|
|
604
|
+
const directives = this.scope.resolveFlatAll(AreDirectiveAttribute);
|
|
605
|
+
return directives.filter((d) => d.component).sort((a, b) => {
|
|
606
|
+
const aMeta = A_Context.meta(a.component);
|
|
607
|
+
const bMeta = A_Context.meta(b.component);
|
|
608
|
+
const aPriority = aMeta.priority ?? 0;
|
|
609
|
+
const bPriority = bMeta.priority ?? 0;
|
|
610
|
+
return bPriority - aPriority;
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* The event attributes defined for the node, which are typically used to represent event listeners or handlers that should be attached to the node. These attributes are usually defined in the template with a specific syntax (e.g., `@click="handleClick"` or `v-on:click="handleClick"`) and are processed by the rendering engine to attach the corresponding event listeners to the node.
|
|
615
|
+
*
|
|
616
|
+
* Example: For a node defined as `<button @click="handleClick">`, the event attribute would be `@click="handleClick"`.
|
|
617
|
+
*/
|
|
618
|
+
get events() {
|
|
619
|
+
return this.scope.resolveFlatAll(AreEventAttribute);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* The styles defined for the node, which can include inline styles or styles defined in a separate stylesheet that are applied to the node. These styles can be used to control the visual appearance of the node and can be defined using standard CSS syntax.
|
|
623
|
+
*/
|
|
624
|
+
get styles() {
|
|
625
|
+
return this.scope.resolveFlat(AreStyle);
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
AreHTMLNode = __decorateClass([
|
|
629
|
+
A_Frame.Entity({
|
|
630
|
+
namespace: "A-ARE",
|
|
631
|
+
name: "AreHTMLNode",
|
|
632
|
+
description: "AreHTMLNode represents a node in the HTML structure. It extends the base AreNode and includes properties and methods specific to HTML nodes, such as handling attributes, directives, events, and styles."
|
|
633
|
+
})
|
|
634
|
+
], AreHTMLNode);
|
|
635
|
+
|
|
636
|
+
// src/nodes/AreComment.ts
|
|
637
|
+
var AreComment = class extends AreHTMLNode {
|
|
638
|
+
fromNew(newEntity) {
|
|
639
|
+
super.fromNew({
|
|
640
|
+
...newEntity,
|
|
641
|
+
payload: {
|
|
642
|
+
...newEntity.payload || {},
|
|
643
|
+
entity: "are-comment"
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
var AreComponentNode = class extends AreHTMLNode {
|
|
649
|
+
/**
|
|
650
|
+
* A custom component associated with this node, which can be used to provide custom logic and behavior for the node. This component is typically defined in the context and can be resolved based on the node's type or other identifying information. The component can include its own template, markup, styles, and features that are specific to the functionality it provides.
|
|
651
|
+
*
|
|
652
|
+
* Example: If the node type is "custom-component", the corresponding component would be resolved from the context and can be used to provide custom rendering and behavior for nodes of that type.
|
|
653
|
+
*
|
|
654
|
+
* [!] Note: The component is optional and may not be defined for all nodes. If no component is associated with the node, it will be treated as a standard HTML element or a basic node without custom logic.
|
|
655
|
+
*/
|
|
656
|
+
get component() {
|
|
657
|
+
return this.scope.resolve(A_FormatterHelper.toPascalCase(this.aseid.entity));
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
AreComponentNode = __decorateClass([
|
|
661
|
+
A_Frame.Entity({
|
|
662
|
+
namespace: "A-ARE",
|
|
663
|
+
name: "AreComponentNode",
|
|
664
|
+
description: "AreComponentNode represents a node in the scene graph that corresponds to a component. It extends the base AreNode and includes additional properties and methods specific to component nodes, such as handling attributes, bindings, directives, events, styles, and interpolations associated with the component."
|
|
665
|
+
})
|
|
666
|
+
], AreComponentNode);
|
|
667
|
+
|
|
668
|
+
// src/nodes/AreInterpolation.ts
|
|
669
|
+
var AreInterpolation = class extends AreHTMLNode {
|
|
670
|
+
fromNew(newEntity) {
|
|
671
|
+
super.fromNew({
|
|
672
|
+
...newEntity,
|
|
673
|
+
payload: {
|
|
674
|
+
...newEntity.payload || {},
|
|
675
|
+
entity: "are-interpolation"
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
var AreRootNode = class extends AreHTMLNode {
|
|
681
|
+
/**
|
|
682
|
+
* For the root node, we can default to a generic container element like <div> since it serves as the root of the component tree and does not correspond to a specific HTML tag defined in the markup. The actual content and structure of the root node will be determined by the child nodes and components that are rendered within it, allowing for flexibility in how the root node is used and what it contains.
|
|
683
|
+
*/
|
|
684
|
+
get tag() {
|
|
685
|
+
return "div";
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* A custom component associated with this node, which can be used to provide custom logic and behavior for the node. This component is typically defined in the context and can be resolved based on the node's type or other identifying information. The component can include its own template, markup, styles, and features that are specific to the functionality it provides.
|
|
689
|
+
*
|
|
690
|
+
* Example: If the node type is "custom-component", the corresponding component would be resolved from the context and can be used to provide custom rendering and behavior for nodes of that type.
|
|
691
|
+
*
|
|
692
|
+
* [!] Note: The component is optional and may not be defined for all nodes. If no component is associated with the node, it will be treated as a standard HTML element or a basic node without custom logic.
|
|
693
|
+
*/
|
|
694
|
+
get component() {
|
|
695
|
+
return this.scope.resolve(A_FormatterHelper.toPascalCase(this.aseid.entity));
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
AreRootNode = __decorateClass([
|
|
699
|
+
A_Frame.Entity({
|
|
700
|
+
namespace: "A-ARE",
|
|
701
|
+
name: "AreRootNode",
|
|
702
|
+
description: "AreRootNode represents the root node in the scene graph. It extends the base AreHTMLNode and includes additional properties and methods specific to the root node, such as handling the root element and its associated component."
|
|
703
|
+
})
|
|
704
|
+
], AreRootNode);
|
|
705
|
+
|
|
706
|
+
// src/nodes/AreText.ts
|
|
707
|
+
var AreText = class extends AreHTMLNode {
|
|
708
|
+
fromNew(newEntity) {
|
|
709
|
+
super.fromNew({
|
|
710
|
+
...newEntity,
|
|
711
|
+
payload: {
|
|
712
|
+
...newEntity.payload || {},
|
|
713
|
+
entity: "are-text"
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
var AreRoute = class _AreRoute extends AreSignal {
|
|
719
|
+
constructor(path) {
|
|
720
|
+
super({
|
|
721
|
+
data: new A_Route(path)
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
get route() {
|
|
725
|
+
return this.data;
|
|
726
|
+
}
|
|
727
|
+
static default() {
|
|
728
|
+
return new _AreRoute(document.location.pathname || "/");
|
|
729
|
+
}
|
|
730
|
+
compare(other) {
|
|
731
|
+
return this.route.toRegExp().test(other.data.toString());
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
var AreHTMLEngineContext = class extends AreContext {
|
|
735
|
+
constructor(props) {
|
|
736
|
+
super(props.container?.body.innerHTML || props.source || "");
|
|
737
|
+
/**
|
|
738
|
+
* Index structure mapping:
|
|
739
|
+
*
|
|
740
|
+
* Node -> Group ID -> Element
|
|
741
|
+
* -----------------------------------------------------------------------------------
|
|
742
|
+
* | - Attribute | group: string | Node
|
|
743
|
+
* | - Directive (e.g. for) | | Node
|
|
744
|
+
*/
|
|
745
|
+
this.index = {
|
|
746
|
+
/**
|
|
747
|
+
* 1 AreNode = 1 Dom Node
|
|
748
|
+
*
|
|
749
|
+
* uses ASEID
|
|
750
|
+
*/
|
|
751
|
+
nodeToHostElements: /* @__PURE__ */ new Map(),
|
|
752
|
+
/**
|
|
753
|
+
* 1 Group Instruction = MANY Dom Nodes (e.g. for loop)
|
|
754
|
+
*
|
|
755
|
+
* uses ASEID
|
|
756
|
+
*/
|
|
757
|
+
groupToElements: /* @__PURE__ */ new Map(),
|
|
758
|
+
/**
|
|
759
|
+
* 1 Dom Node = 1 Instruction
|
|
760
|
+
*
|
|
761
|
+
* uses ASEID
|
|
762
|
+
*/
|
|
763
|
+
elementToInstruction: /* @__PURE__ */ new WeakMap(),
|
|
764
|
+
/**
|
|
765
|
+
* 1 Instruction = 1 Dom Node (for CreateElement instructions, for example)
|
|
766
|
+
*
|
|
767
|
+
* uses ASEID
|
|
768
|
+
*/
|
|
769
|
+
instructionToElement: /* @__PURE__ */ new Map(),
|
|
770
|
+
/**
|
|
771
|
+
* Event listeners attached to elements, used for proper cleanup when reverting instructions. Maps a DOM element to a map of event names and their corresponding listeners, allowing the engine to track which listeners are attached to which elements and remove them when necessary (e.g., when an instruction is reverted).
|
|
772
|
+
*/
|
|
773
|
+
elementListeners: /* @__PURE__ */ new WeakMap()
|
|
774
|
+
};
|
|
775
|
+
this._container = props.container;
|
|
776
|
+
}
|
|
777
|
+
get container() {
|
|
778
|
+
return this._container;
|
|
779
|
+
}
|
|
780
|
+
getNodeElement(node) {
|
|
781
|
+
if (typeof node === "string") {
|
|
782
|
+
return this.index.nodeToHostElements.get(node);
|
|
783
|
+
} else {
|
|
784
|
+
return this.index.nodeToHostElements.get(node.aseid.toString());
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Associates a DOM element with a given instruction and its owner node. This method updates the context's index to map the instruction's ASEID to the provided DOM element, and also maps the element back to the instruction's ASEID for reverse lookup. If the instruction has an owner node, it also maps the node's ASEID to the element. Additionally, if the instruction belongs to a group, it adds the element to the set of elements associated with that group. This indexing allows the engine to efficiently manage and update DOM elements based on instructions and their corresponding nodes, enabling dynamic rendering and interaction in response to application state changes.
|
|
789
|
+
*
|
|
790
|
+
* @param instruction
|
|
791
|
+
* @param element
|
|
792
|
+
*/
|
|
793
|
+
setInstructionElement(instruction, element) {
|
|
794
|
+
const node = instruction.owner;
|
|
795
|
+
this.index.instructionToElement.set(instruction.aseid.toString(), element);
|
|
796
|
+
this.index.elementToInstruction.set(element, instruction.aseid.toString());
|
|
797
|
+
if (node) {
|
|
798
|
+
this.index.nodeToHostElements.set(node.aseid.toString(), element);
|
|
799
|
+
}
|
|
800
|
+
if (instruction.group) {
|
|
801
|
+
const groupId = instruction.group;
|
|
802
|
+
if (!this.index.groupToElements.has(groupId)) {
|
|
803
|
+
this.index.groupToElements.set(groupId, /* @__PURE__ */ new Set());
|
|
804
|
+
}
|
|
805
|
+
this.index.groupToElements.get(groupId).add(element);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
getElementByInstruction(instruction) {
|
|
809
|
+
if (typeof instruction === "string") {
|
|
810
|
+
return this.index.instructionToElement.get(instruction);
|
|
811
|
+
} else {
|
|
812
|
+
return this.index.instructionToElement.get(instruction.aseid.toString());
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Removes the association between a given instruction and its corresponding DOM element. This method looks up the instruction's ASEID to find the associated DOM element, and if found, it deletes the mapping from both instructionToElement and elementToInstruction. If the instruction has an owner node, it also removes the mapping from nodeToHostElements. Additionally, if the instruction belongs to a group, it removes the element from the set of elements associated with that group, and if the group has no more elements, it deletes the group from the index. This cleanup is essential for maintaining an accurate and efficient mapping of instructions to DOM elements, especially when instructions are reverted or when nodes are removed from the DOM.
|
|
817
|
+
*
|
|
818
|
+
* @param instruction
|
|
819
|
+
*/
|
|
820
|
+
removeInstructionElement(instruction) {
|
|
821
|
+
const element = this.index.instructionToElement.get(instruction.aseid.toString());
|
|
822
|
+
if (element) {
|
|
823
|
+
this.index.instructionToElement.delete(instruction.aseid.toString());
|
|
824
|
+
this.index.elementToInstruction.delete(element);
|
|
825
|
+
const node = instruction.owner;
|
|
826
|
+
if (node) {
|
|
827
|
+
this.index.nodeToHostElements.delete(node.aseid.toString());
|
|
828
|
+
}
|
|
829
|
+
if (instruction.group) {
|
|
830
|
+
const groupId = instruction.group;
|
|
831
|
+
const groupElements = this.index.groupToElements.get(groupId);
|
|
832
|
+
if (groupElements) {
|
|
833
|
+
groupElements.delete(element);
|
|
834
|
+
if (groupElements.size === 0) {
|
|
835
|
+
this.index.groupToElements.delete(groupId);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
getElementsByGroup(instruction) {
|
|
842
|
+
if (typeof instruction === "string") {
|
|
843
|
+
return this.index.groupToElements.get(instruction);
|
|
844
|
+
} else {
|
|
845
|
+
return this.index.groupToElements.get(instruction.aseid.toString());
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Adds an event listener to a specific DOM element and keeps track of it in the context's index for proper cleanup later. This method takes a DOM element, an event name, and a listener function or object, and stores this information in the elementListeners map. This allows the engine to efficiently manage event listeners attached to dynamically created elements, ensuring that they can be removed when the associated instructions are reverted or when nodes are removed from the DOM, preventing memory leaks and unintended behavior.
|
|
850
|
+
*
|
|
851
|
+
* @param element
|
|
852
|
+
* @param eventName
|
|
853
|
+
* @param listener
|
|
854
|
+
*/
|
|
855
|
+
addListener(element, eventName, listener) {
|
|
856
|
+
if (!this.index.elementListeners.has(element)) {
|
|
857
|
+
this.index.elementListeners.set(element, /* @__PURE__ */ new Map());
|
|
858
|
+
}
|
|
859
|
+
this.index.elementListeners.get(element).set(eventName, listener);
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Retrieves the event listener associated with a specific DOM element and event name from the context's index. This method looks up the element in the elementListeners map and then retrieves the listener for the specified event name. If no listener is found for the given element and event, it returns undefined. This allows the engine to efficiently access and manage event listeners that have been attached to dynamically created elements, enabling proper cleanup when instructions are reverted or when nodes are removed from the DOM.
|
|
863
|
+
*
|
|
864
|
+
* @param element
|
|
865
|
+
* @param eventName
|
|
866
|
+
* @returns
|
|
867
|
+
*/
|
|
868
|
+
getListener(element, eventName) {
|
|
869
|
+
return this.index.elementListeners.get(element)?.get(eventName);
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Removes an event listener from a specific DOM element and updates the context's index accordingly. This method looks up the element in the elementListeners map and deletes the listener for the specified event name. This is typically called when an instruction is reverted or when a node is removed from the DOM, ensuring that any attached event listeners are properly cleaned up to prevent memory leaks and unintended behavior.
|
|
873
|
+
*
|
|
874
|
+
* @param element
|
|
875
|
+
* @param eventName
|
|
876
|
+
*/
|
|
877
|
+
removeListener(element, eventName) {
|
|
878
|
+
this.index.elementListeners.get(element)?.delete(eventName);
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
var AreHTMLCompiler = class extends AreCompiler {
|
|
882
|
+
compileInterpolation(interpolation, scene, store, logger, ...args) {
|
|
883
|
+
scene.plan(new AddTextInstruction({ content: interpolation.content, evaluate: true }));
|
|
884
|
+
}
|
|
885
|
+
compileText(text, scene, logger, ...args) {
|
|
886
|
+
logger?.debug("cyan", `AreHTMLCompiler: compile text node <${text.aseid.toString()}> with content: "${text.content}"`);
|
|
887
|
+
if (scene.host)
|
|
888
|
+
scene.unPlan(scene.host);
|
|
889
|
+
scene.plan(new AddTextInstruction({ content: text.content }));
|
|
890
|
+
}
|
|
891
|
+
compileStaticAttribute(attribute, scene, ...args) {
|
|
892
|
+
if (!scene.host)
|
|
893
|
+
throw new AreCompilerError({
|
|
894
|
+
title: "Scene Host Not Found",
|
|
895
|
+
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.`
|
|
896
|
+
});
|
|
897
|
+
scene.plan(new AddAttributeInstruction(scene.host, {
|
|
898
|
+
name: attribute.name,
|
|
899
|
+
content: attribute.content
|
|
900
|
+
}));
|
|
901
|
+
}
|
|
902
|
+
compileDirectiveAttribute(directive, store, feature, logger, ...args) {
|
|
903
|
+
store.watch(directive);
|
|
904
|
+
if (directive.component) {
|
|
905
|
+
feature.chain(directive.component, AreDirectiveFeatures.Compile, directive.owner.scope);
|
|
906
|
+
} else {
|
|
907
|
+
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.`);
|
|
908
|
+
}
|
|
909
|
+
store.unwatch(directive);
|
|
910
|
+
}
|
|
911
|
+
compileEventAttribute(attribute, scene, ...args) {
|
|
912
|
+
if (!scene.host)
|
|
913
|
+
throw new AreCompilerError({
|
|
914
|
+
title: "Scene Host Not Found",
|
|
915
|
+
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.`
|
|
916
|
+
});
|
|
917
|
+
scene.plan(new AddListenerInstruction(scene.host, {
|
|
918
|
+
name: attribute.name,
|
|
919
|
+
handler: attribute.content
|
|
920
|
+
}));
|
|
921
|
+
}
|
|
922
|
+
compileBindingAttribute(attribute, scene, parentStore, store, ...args) {
|
|
923
|
+
if (!scene.host)
|
|
924
|
+
throw new AreCompilerError({
|
|
925
|
+
title: "Scene Host Not Found",
|
|
926
|
+
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.`
|
|
927
|
+
});
|
|
928
|
+
const node = attribute.owner;
|
|
929
|
+
if (node.component && node.component.props[attribute.name]) {
|
|
930
|
+
const propDefinition = node.component.props[attribute.name];
|
|
931
|
+
let value = parentStore.get(attribute.content);
|
|
932
|
+
if (propDefinition.type) {
|
|
933
|
+
switch (propDefinition.type) {
|
|
934
|
+
case "string":
|
|
935
|
+
value = String(value);
|
|
936
|
+
break;
|
|
937
|
+
case "number":
|
|
938
|
+
value = Number(value);
|
|
939
|
+
break;
|
|
940
|
+
case "boolean":
|
|
941
|
+
value = Boolean(value);
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
store.set(attribute.name, value);
|
|
946
|
+
} else {
|
|
947
|
+
const instruction = new AddAttributeInstruction(scene.host, {
|
|
948
|
+
name: attribute.name,
|
|
949
|
+
content: attribute.content,
|
|
950
|
+
evaluate: true
|
|
951
|
+
});
|
|
952
|
+
scene.plan(instruction);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
__decorateClass([
|
|
957
|
+
AreCompiler.Compile(AreInterpolation),
|
|
958
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
959
|
+
__decorateParam(1, A_Inject(AreScene)),
|
|
960
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
961
|
+
__decorateParam(3, A_Inject(A_Logger))
|
|
962
|
+
], AreHTMLCompiler.prototype, "compileInterpolation", 1);
|
|
963
|
+
__decorateClass([
|
|
964
|
+
AreCompiler.Compile(AreText),
|
|
965
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
966
|
+
__decorateParam(1, A_Inject(AreScene)),
|
|
967
|
+
__decorateParam(2, A_Inject(A_Logger))
|
|
968
|
+
], AreHTMLCompiler.prototype, "compileText", 1);
|
|
969
|
+
__decorateClass([
|
|
970
|
+
AreCompiler.Compile(AreStaticAttribute),
|
|
971
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
972
|
+
__decorateParam(1, A_Inject(AreScene))
|
|
973
|
+
], AreHTMLCompiler.prototype, "compileStaticAttribute", 1);
|
|
974
|
+
__decorateClass([
|
|
975
|
+
AreCompiler.Compile(AreDirectiveAttribute),
|
|
976
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
977
|
+
__decorateParam(1, A_Inject(AreStore)),
|
|
978
|
+
__decorateParam(2, A_Inject(A_Feature)),
|
|
979
|
+
__decorateParam(3, A_Inject(A_Logger))
|
|
980
|
+
], AreHTMLCompiler.prototype, "compileDirectiveAttribute", 1);
|
|
981
|
+
__decorateClass([
|
|
982
|
+
AreCompiler.Compile(AreEventAttribute),
|
|
983
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
984
|
+
__decorateParam(1, A_Inject(AreScene))
|
|
985
|
+
], AreHTMLCompiler.prototype, "compileEventAttribute", 1);
|
|
986
|
+
__decorateClass([
|
|
987
|
+
AreCompiler.Compile(AreBindingAttribute),
|
|
988
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
989
|
+
__decorateParam(1, A_Inject(AreScene)),
|
|
990
|
+
__decorateParam(2, A_Dependency.Parent()),
|
|
991
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
992
|
+
__decorateParam(3, A_Inject(AreStore))
|
|
993
|
+
], AreHTMLCompiler.prototype, "compileBindingAttribute", 1);
|
|
994
|
+
AreHTMLCompiler = __decorateClass([
|
|
995
|
+
A_Frame.Component({
|
|
996
|
+
namespace: "A-ARE",
|
|
997
|
+
name: "AreHTMLCompiler",
|
|
998
|
+
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."
|
|
999
|
+
})
|
|
1000
|
+
], AreHTMLCompiler);
|
|
1001
|
+
var AreHTMLInterpreter = class extends AreInterpreter {
|
|
1002
|
+
addElement(declaration, context, logger) {
|
|
1003
|
+
try {
|
|
1004
|
+
const node = declaration.owner;
|
|
1005
|
+
let currentNode = node;
|
|
1006
|
+
let parent = node.parent;
|
|
1007
|
+
while (parent) {
|
|
1008
|
+
if (context.getNodeElement(parent)) {
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
currentNode = parent;
|
|
1012
|
+
parent = parent.parent;
|
|
1013
|
+
}
|
|
1014
|
+
const tag = node.tag;
|
|
1015
|
+
if (parent) {
|
|
1016
|
+
const mountPoint = context.getNodeElement(parent);
|
|
1017
|
+
if (!mountPoint) {
|
|
1018
|
+
throw new AreInterpreterError({
|
|
1019
|
+
title: "Mount Point Not Found",
|
|
1020
|
+
description: `Could not find a mount point for the node with id "${node.id}". Ensure that the parent node is rendered before its children, or that a valid root element with the corresponding id exists in the DOM.`
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
const element = context.container.createElement(tag);
|
|
1024
|
+
if (mountPoint.nodeType === Node.ELEMENT_NODE) {
|
|
1025
|
+
mountPoint.appendChild(element);
|
|
1026
|
+
} else {
|
|
1027
|
+
mountPoint.parentNode?.insertBefore(element, mountPoint);
|
|
1028
|
+
}
|
|
1029
|
+
context.setInstructionElement(declaration, element);
|
|
1030
|
+
} else {
|
|
1031
|
+
const mountPoint = context.container.getElementById(node.id);
|
|
1032
|
+
if (!mountPoint) {
|
|
1033
|
+
throw new AreInterpreterError({
|
|
1034
|
+
title: "Mount Point Not Found",
|
|
1035
|
+
description: `Could not find a mount point for the node with id "${node.id}". Ensure that the parent node is rendered before its children, or that a valid root element with the corresponding id exists in the DOM.`
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
const element = context.container.createElement(tag);
|
|
1039
|
+
element.setAttribute("data-aseid", node.aseid.toString());
|
|
1040
|
+
mountPoint.parentNode?.replaceChild(element, mountPoint);
|
|
1041
|
+
context.setInstructionElement(declaration, element);
|
|
1042
|
+
}
|
|
1043
|
+
logger?.debug("green", `Element ${node.aseid.toString()} added to Context:`);
|
|
1044
|
+
} catch (error) {
|
|
1045
|
+
logger?.error(error);
|
|
1046
|
+
throw error;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
removeElement(declaration, context) {
|
|
1050
|
+
const element = context.getElementByInstruction(declaration);
|
|
1051
|
+
if (element && element.parentNode) {
|
|
1052
|
+
element.parentNode.removeChild(element);
|
|
1053
|
+
}
|
|
1054
|
+
context.removeInstructionElement(declaration);
|
|
1055
|
+
}
|
|
1056
|
+
addAttribute(mutation, context, store, syntax, directiveContext, logger) {
|
|
1057
|
+
const element = context.getElementByInstruction(mutation.parent);
|
|
1058
|
+
if (!element) {
|
|
1059
|
+
throw new AreInterpreterError({
|
|
1060
|
+
title: "Element Not Found",
|
|
1061
|
+
description: `Could not find a DOM element associated with the instruction ASEID "${mutation.parent}". Ensure that the parent instruction is properly rendered and associated with a DOM element before applying attribute mutations.`
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
const { name, content, evaluate } = mutation.payload;
|
|
1065
|
+
const value = evaluate ? syntax.evaluate(content, store, {
|
|
1066
|
+
...directiveContext?.scope || {}
|
|
1067
|
+
}) : content;
|
|
1068
|
+
if (mutation.cache === void 0) {
|
|
1069
|
+
const existingValue = element.getAttribute(name);
|
|
1070
|
+
const result = existingValue ? `${existingValue} ${value}` : value;
|
|
1071
|
+
element.setAttribute(name, result);
|
|
1072
|
+
mutation.cache = value;
|
|
1073
|
+
} else {
|
|
1074
|
+
const existingValue = element.getAttribute(name);
|
|
1075
|
+
const existingParts = existingValue ? existingValue.split(/\s+/).filter(Boolean) : [];
|
|
1076
|
+
const oldParts = new Set(mutation.cache.split(/\s+/).filter(Boolean));
|
|
1077
|
+
const newParts = value ? value.split(/\s+/).filter(Boolean) : [];
|
|
1078
|
+
const result = [...existingParts.filter((part) => !oldParts.has(part)), ...newParts].join(" ");
|
|
1079
|
+
element.setAttribute(name, result);
|
|
1080
|
+
mutation.cache = value;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
removeAttribute(mutation, context) {
|
|
1084
|
+
try {
|
|
1085
|
+
const element = context.getElementByInstruction(mutation.parent);
|
|
1086
|
+
if (!element) return;
|
|
1087
|
+
const { name } = mutation.payload;
|
|
1088
|
+
if (name && element.nodeType === Node.ELEMENT_NODE) {
|
|
1089
|
+
element?.removeAttribute(name);
|
|
1090
|
+
}
|
|
1091
|
+
} catch (error) {
|
|
1092
|
+
console.log("Error removing attribute:", error);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
addEventListener(mutation, context, store, syntax, directiveContext, logger) {
|
|
1096
|
+
const element = context.getElementByInstruction(mutation.parent);
|
|
1097
|
+
if (!element) {
|
|
1098
|
+
throw new AreInterpreterError({
|
|
1099
|
+
title: "Element Not Found",
|
|
1100
|
+
description: `Could not find a DOM element associated with the instruction ASEID "${mutation.parent}". Ensure that the parent instruction is properly rendered and associated with a DOM element before adding event listeners.`
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
const handlers = syntax.extractEmitHandlers(mutation.payload.handler);
|
|
1104
|
+
const handlerScope = {};
|
|
1105
|
+
for (const handler of handlers) {
|
|
1106
|
+
const handlerFn = (...args) => {
|
|
1107
|
+
const event = new AreEvent(handler);
|
|
1108
|
+
event.set("args", args);
|
|
1109
|
+
event.set("element", element);
|
|
1110
|
+
event.set("instruction", mutation);
|
|
1111
|
+
mutation.owner.emit(event);
|
|
1112
|
+
};
|
|
1113
|
+
handlerScope[`$${handler}`] = handlerFn;
|
|
1114
|
+
}
|
|
1115
|
+
const callback = (e) => {
|
|
1116
|
+
context.startPerformance("Click");
|
|
1117
|
+
const result = syntax.evaluate(mutation.payload.handler, store, {
|
|
1118
|
+
...handlerScope,
|
|
1119
|
+
...directiveContext?.scope || {}
|
|
1120
|
+
});
|
|
1121
|
+
if (typeof result === "function") result(e);
|
|
1122
|
+
};
|
|
1123
|
+
if (callback) {
|
|
1124
|
+
element.addEventListener(mutation.payload.name, callback);
|
|
1125
|
+
context.addListener(element, mutation.payload.name, callback);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
removeEventListener(mutation, context) {
|
|
1129
|
+
const element = context.getElementByInstruction(mutation.parent);
|
|
1130
|
+
if (!element) return;
|
|
1131
|
+
const { name } = mutation.payload;
|
|
1132
|
+
const listener = context.getListener(element, name);
|
|
1133
|
+
if (listener) {
|
|
1134
|
+
element.removeEventListener(name, listener);
|
|
1135
|
+
context.removeListener(element, name);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
addText(declaration, context, store, syntax, directiveContext, logger) {
|
|
1139
|
+
const node = declaration.owner.parent;
|
|
1140
|
+
const { content, evaluate } = declaration.payload;
|
|
1141
|
+
const value = evaluate ? syntax.evaluate(content, store, {
|
|
1142
|
+
...directiveContext?.scope || {}
|
|
1143
|
+
}) : content;
|
|
1144
|
+
if (!node) {
|
|
1145
|
+
const textNode = context.container.createTextNode(value);
|
|
1146
|
+
context.container.body.appendChild(textNode);
|
|
1147
|
+
context.setInstructionElement(declaration, textNode);
|
|
1148
|
+
} else {
|
|
1149
|
+
const element = context.getNodeElement(node);
|
|
1150
|
+
if (!element) {
|
|
1151
|
+
throw new AreInterpreterError({
|
|
1152
|
+
title: "Element Not Found",
|
|
1153
|
+
description: `Could not find a DOM element associated with the instruction ASEID "${declaration.owner.parent.aseid}". Ensure that the parent instruction is properly rendered and associated with a DOM element before applying attribute mutations.`
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
const existingNode = context.getElementByInstruction(declaration);
|
|
1157
|
+
if (existingNode) {
|
|
1158
|
+
existingNode.textContent = value;
|
|
1159
|
+
} else {
|
|
1160
|
+
const textNode = context.container.createTextNode(value);
|
|
1161
|
+
element.appendChild(textNode);
|
|
1162
|
+
context.setInstructionElement(declaration, textNode);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
logger?.debug("green", `Text ${node?.aseid.toString()} added to Context:`);
|
|
1166
|
+
}
|
|
1167
|
+
removeText(declaration, context) {
|
|
1168
|
+
const element = context.getElementByInstruction(declaration);
|
|
1169
|
+
if (!element) return;
|
|
1170
|
+
element.parentNode?.removeChild(element);
|
|
1171
|
+
context.removeInstructionElement(declaration);
|
|
1172
|
+
}
|
|
1173
|
+
addComment(declaration, context, store, syntax, directiveContext, logger) {
|
|
1174
|
+
const node = declaration.owner.parent;
|
|
1175
|
+
const { content, evaluate } = declaration.payload;
|
|
1176
|
+
const value = evaluate ? syntax.evaluate(content, store, {
|
|
1177
|
+
...directiveContext?.scope || {}
|
|
1178
|
+
}) : content;
|
|
1179
|
+
if (!node) {
|
|
1180
|
+
const commentNode = context.container.createComment(value);
|
|
1181
|
+
context.container.body.appendChild(commentNode);
|
|
1182
|
+
context.setInstructionElement(declaration, commentNode);
|
|
1183
|
+
} else {
|
|
1184
|
+
const element = context.getNodeElement(node);
|
|
1185
|
+
if (!element) {
|
|
1186
|
+
throw new AreInterpreterError({
|
|
1187
|
+
title: "Element Not Found",
|
|
1188
|
+
description: `Could not find a DOM element associated with the instruction ASEID "${declaration.owner.parent.aseid}". Ensure that the parent instruction is properly rendered and associated with a DOM element before applying attribute mutations.`
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
const existingNode = context.getElementByInstruction(declaration);
|
|
1192
|
+
if (existingNode) {
|
|
1193
|
+
existingNode.textContent = value;
|
|
1194
|
+
} else {
|
|
1195
|
+
const commentNode = context.container.createComment(value);
|
|
1196
|
+
element.appendChild(commentNode);
|
|
1197
|
+
context.setInstructionElement(declaration, commentNode);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
logger?.debug("green", `Comment ${node?.aseid.toString()} added to Context:`);
|
|
1201
|
+
}
|
|
1202
|
+
removeComment(declaration, context) {
|
|
1203
|
+
const element = context.getElementByInstruction(declaration);
|
|
1204
|
+
if (!element) return;
|
|
1205
|
+
element.parentNode?.removeChild(element);
|
|
1206
|
+
context.removeInstructionElement(declaration);
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
__decorateClass([
|
|
1210
|
+
A_Frame.Method({
|
|
1211
|
+
description: "Create an HTML element based on the provided declaration instruction. Handles both root-level mounting and child element creation based on the structural parent hierarchy."
|
|
1212
|
+
}),
|
|
1213
|
+
AreInterpreter.Apply(AreInstructionDefaultNames.Default),
|
|
1214
|
+
AreInterpreter.Apply(AreHTMLInstructions.AddElement),
|
|
1215
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1216
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext)),
|
|
1217
|
+
__decorateParam(2, A_Inject(A_Logger))
|
|
1218
|
+
], AreHTMLInterpreter.prototype, "addElement", 1);
|
|
1219
|
+
__decorateClass([
|
|
1220
|
+
A_Frame.Method({
|
|
1221
|
+
description: "Remove an HTML element that was created by a CreateElement declaration. Cleans up the DOM and the context index."
|
|
1222
|
+
}),
|
|
1223
|
+
AreInterpreter.Revert(AreInstructionDefaultNames.Default),
|
|
1224
|
+
AreInterpreter.Revert(AreHTMLInstructions.AddElement),
|
|
1225
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1226
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext))
|
|
1227
|
+
], AreHTMLInterpreter.prototype, "removeElement", 1);
|
|
1228
|
+
__decorateClass([
|
|
1229
|
+
A_Frame.Method({
|
|
1230
|
+
description: "Add an attribute to an HTML element based on the provided mutation instruction."
|
|
1231
|
+
}),
|
|
1232
|
+
AreInterpreter.Apply(AreHTMLInstructions.AddAttribute),
|
|
1233
|
+
AreInterpreter.Update(AreHTMLInstructions.AddAttribute),
|
|
1234
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1235
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext)),
|
|
1236
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
1237
|
+
__decorateParam(3, A_Inject(AreSyntax)),
|
|
1238
|
+
__decorateParam(4, A_Inject(AreDirectiveContext)),
|
|
1239
|
+
__decorateParam(5, A_Inject(A_Logger))
|
|
1240
|
+
], AreHTMLInterpreter.prototype, "addAttribute", 1);
|
|
1241
|
+
__decorateClass([
|
|
1242
|
+
A_Frame.Method({
|
|
1243
|
+
description: "Remove an attribute from an HTML element based on the provided mutation instruction."
|
|
1244
|
+
}),
|
|
1245
|
+
AreInterpreter.Revert(AreHTMLInstructions.AddAttribute),
|
|
1246
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1247
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext))
|
|
1248
|
+
], AreHTMLInterpreter.prototype, "removeAttribute", 1);
|
|
1249
|
+
__decorateClass([
|
|
1250
|
+
A_Frame.Method({
|
|
1251
|
+
description: "Add an event listener to an HTML element based on the provided mutation instruction."
|
|
1252
|
+
}),
|
|
1253
|
+
AreInterpreter.Apply(AreHTMLInstructions.AddListener),
|
|
1254
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1255
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext)),
|
|
1256
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
1257
|
+
__decorateParam(3, A_Inject(AreSyntax)),
|
|
1258
|
+
__decorateParam(4, A_Inject(AreDirectiveContext)),
|
|
1259
|
+
__decorateParam(5, A_Inject(A_Logger))
|
|
1260
|
+
], AreHTMLInterpreter.prototype, "addEventListener", 1);
|
|
1261
|
+
__decorateClass([
|
|
1262
|
+
A_Frame.Method({
|
|
1263
|
+
description: "Remove an event listener from an HTML element based on the provided mutation instruction."
|
|
1264
|
+
}),
|
|
1265
|
+
AreInterpreter.Revert(AreHTMLInstructions.AddListener),
|
|
1266
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1267
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext))
|
|
1268
|
+
], AreHTMLInterpreter.prototype, "removeEventListener", 1);
|
|
1269
|
+
__decorateClass([
|
|
1270
|
+
A_Frame.Method({
|
|
1271
|
+
description: "Add text content to an HTML element based on the provided declaration instruction."
|
|
1272
|
+
}),
|
|
1273
|
+
AreInterpreter.Apply(AreHTMLInstructions.AddText),
|
|
1274
|
+
AreInterpreter.Update(AreHTMLInstructions.AddText),
|
|
1275
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1276
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext)),
|
|
1277
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
1278
|
+
__decorateParam(3, A_Inject(AreSyntax)),
|
|
1279
|
+
__decorateParam(4, A_Inject(AreDirectiveContext)),
|
|
1280
|
+
__decorateParam(5, A_Inject(A_Logger))
|
|
1281
|
+
], AreHTMLInterpreter.prototype, "addText", 1);
|
|
1282
|
+
__decorateClass([
|
|
1283
|
+
A_Frame.Method({
|
|
1284
|
+
description: "Remove text content from an HTML element based on the provided declaration instruction."
|
|
1285
|
+
}),
|
|
1286
|
+
AreInterpreter.Revert(AreHTMLInstructions.AddText),
|
|
1287
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1288
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext))
|
|
1289
|
+
], AreHTMLInterpreter.prototype, "removeText", 1);
|
|
1290
|
+
__decorateClass([
|
|
1291
|
+
A_Frame.Method({
|
|
1292
|
+
description: "Add a comment node to the DOM based on the provided declaration instruction."
|
|
1293
|
+
}),
|
|
1294
|
+
AreInterpreter.Apply(AreHTMLInstructions.AddComment),
|
|
1295
|
+
AreInterpreter.Update(AreHTMLInstructions.AddComment),
|
|
1296
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1297
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext)),
|
|
1298
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
1299
|
+
__decorateParam(3, A_Inject(AreSyntax)),
|
|
1300
|
+
__decorateParam(4, A_Inject(AreDirectiveContext)),
|
|
1301
|
+
__decorateParam(5, A_Inject(A_Logger))
|
|
1302
|
+
], AreHTMLInterpreter.prototype, "addComment", 1);
|
|
1303
|
+
__decorateClass([
|
|
1304
|
+
A_Frame.Method({
|
|
1305
|
+
description: "Remove a comment node from the DOM based on the provided declaration instruction."
|
|
1306
|
+
}),
|
|
1307
|
+
AreInterpreter.Revert(AreHTMLInstructions.AddComment),
|
|
1308
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1309
|
+
__decorateParam(1, A_Inject(AreHTMLEngineContext))
|
|
1310
|
+
], AreHTMLInterpreter.prototype, "removeComment", 1);
|
|
1311
|
+
AreHTMLInterpreter = __decorateClass([
|
|
1312
|
+
A_Frame.Component({
|
|
1313
|
+
namespace: "A-ARE",
|
|
1314
|
+
name: "AreHTMLInterpreter",
|
|
1315
|
+
description: "AreHTMLInterpreter is a component that serves as a host for rendering AreNodes into HTML. It provides the necessary context and environment for AreNodes to be rendered and interact with the DOM."
|
|
1316
|
+
})
|
|
1317
|
+
], AreHTMLInterpreter);
|
|
1318
|
+
var AreHTMLTokenizer = class extends AreTokenizer {
|
|
1319
|
+
constructor() {
|
|
1320
|
+
super(...arguments);
|
|
1321
|
+
this.ATTR_PATTERN = /([$:@]?[\w-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>/"'=]+)))?/g;
|
|
1322
|
+
}
|
|
1323
|
+
tokenize(node, context, logger) {
|
|
1324
|
+
super.tokenize(node, context, logger);
|
|
1325
|
+
context.startPerformance("attributeExtraction");
|
|
1326
|
+
const attributes = this.extractAttributes(node.markup);
|
|
1327
|
+
for (const attr of attributes) {
|
|
1328
|
+
node.scope.register(attr);
|
|
1329
|
+
}
|
|
1330
|
+
context.endPerformance("attributeExtraction");
|
|
1331
|
+
}
|
|
1332
|
+
extractAttributes(markup) {
|
|
1333
|
+
const withoutTag = markup.replace(/^<[a-zA-Z][a-zA-Z0-9-]*\s*/, "");
|
|
1334
|
+
let inSingle = false;
|
|
1335
|
+
let inDouble = false;
|
|
1336
|
+
let endIdx = withoutTag.length;
|
|
1337
|
+
for (let i = 0; i < withoutTag.length; i++) {
|
|
1338
|
+
const ch = withoutTag[i];
|
|
1339
|
+
if (ch === '"' && !inSingle) inDouble = !inDouble;
|
|
1340
|
+
else if (ch === "'" && !inDouble) inSingle = !inSingle;
|
|
1341
|
+
else if (ch === ">" && !inSingle && !inDouble) {
|
|
1342
|
+
endIdx = i;
|
|
1343
|
+
break;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
const attrString = withoutTag.slice(0, endIdx).replace(/\s*\/?\s*$/, "").trim();
|
|
1347
|
+
const results = [];
|
|
1348
|
+
for (const match of attrString.matchAll(this.ATTR_PATTERN)) {
|
|
1349
|
+
const raw = match[0];
|
|
1350
|
+
const full = match[1];
|
|
1351
|
+
if (!full) continue;
|
|
1352
|
+
const value = match[2] ?? match[3] ?? match[4] ?? "true";
|
|
1353
|
+
const prefix = full[0];
|
|
1354
|
+
const isSpecial = prefix === ":" || prefix === "@" || prefix === "$";
|
|
1355
|
+
const name = isSpecial ? full.slice(1) : full;
|
|
1356
|
+
const meta = { name, content: value, raw, prefix: isSpecial ? prefix : "" };
|
|
1357
|
+
if (prefix === ":") results.push(new AreBindingAttribute(meta));
|
|
1358
|
+
else if (prefix === "@") results.push(new AreEventAttribute(meta));
|
|
1359
|
+
else if (prefix === "$") results.push(new AreDirectiveAttribute(meta));
|
|
1360
|
+
else results.push(new AreStaticAttribute(meta));
|
|
1361
|
+
}
|
|
1362
|
+
return results;
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
__decorateClass([
|
|
1366
|
+
A_Feature.Extend({
|
|
1367
|
+
name: AreNodeFeatures.onTokenize,
|
|
1368
|
+
scope: [AreComponentNode, AreRootNode]
|
|
1369
|
+
}),
|
|
1370
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1371
|
+
__decorateParam(1, A_Inject(AreContext)),
|
|
1372
|
+
__decorateParam(2, A_Inject(A_Logger))
|
|
1373
|
+
], AreHTMLTokenizer.prototype, "tokenize", 1);
|
|
1374
|
+
var AreHTMLLifecycle = class extends AreLifecycle {
|
|
1375
|
+
initComponent(node, scope, context, logger, ...args) {
|
|
1376
|
+
super.init(node, scope, context, logger, ...args);
|
|
1377
|
+
}
|
|
1378
|
+
initRoot(node, scope, context, signalsContext, logger, ...args) {
|
|
1379
|
+
signalsContext?.subscribe(node);
|
|
1380
|
+
super.init(node, scope, context, logger, ...args);
|
|
1381
|
+
}
|
|
1382
|
+
initText(node, scope, context, logger, ...args) {
|
|
1383
|
+
const scene = new AreScene(node.aseid);
|
|
1384
|
+
scope.register(scene);
|
|
1385
|
+
}
|
|
1386
|
+
initInterpolation(node, scope, context, logger, ...args) {
|
|
1387
|
+
const scene = new AreScene(node.aseid);
|
|
1388
|
+
scope.register(scene);
|
|
1389
|
+
}
|
|
1390
|
+
updateDirectiveAttribute(directive, scope, feature, logger, ...args) {
|
|
1391
|
+
if (directive.component) {
|
|
1392
|
+
feature.chain(directive.component, AreDirectiveFeatures.Update, directive.owner.scope);
|
|
1393
|
+
} else {
|
|
1394
|
+
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.`);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
__decorateClass([
|
|
1399
|
+
AreLifecycle.Init(AreComponentNode),
|
|
1400
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1401
|
+
__decorateParam(1, A_Inject(A_Scope)),
|
|
1402
|
+
__decorateParam(2, A_Inject(AreHTMLEngineContext)),
|
|
1403
|
+
__decorateParam(3, A_Inject(A_Logger))
|
|
1404
|
+
], AreHTMLLifecycle.prototype, "initComponent", 1);
|
|
1405
|
+
__decorateClass([
|
|
1406
|
+
AreLifecycle.Init(AreRootNode),
|
|
1407
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1408
|
+
__decorateParam(1, A_Inject(A_Scope)),
|
|
1409
|
+
__decorateParam(2, A_Inject(AreHTMLEngineContext)),
|
|
1410
|
+
__decorateParam(3, A_Inject(AreSignalsContext)),
|
|
1411
|
+
__decorateParam(4, A_Inject(A_Logger))
|
|
1412
|
+
], AreHTMLLifecycle.prototype, "initRoot", 1);
|
|
1413
|
+
__decorateClass([
|
|
1414
|
+
AreLifecycle.Init(AreText),
|
|
1415
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1416
|
+
__decorateParam(1, A_Inject(A_Scope)),
|
|
1417
|
+
__decorateParam(2, A_Inject(AreHTMLEngineContext)),
|
|
1418
|
+
__decorateParam(3, A_Inject(A_Logger))
|
|
1419
|
+
], AreHTMLLifecycle.prototype, "initText", 1);
|
|
1420
|
+
__decorateClass([
|
|
1421
|
+
AreLifecycle.Init(AreInterpolation),
|
|
1422
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1423
|
+
__decorateParam(1, A_Inject(A_Scope)),
|
|
1424
|
+
__decorateParam(2, A_Inject(AreHTMLEngineContext)),
|
|
1425
|
+
__decorateParam(3, A_Inject(A_Logger))
|
|
1426
|
+
], AreHTMLLifecycle.prototype, "initInterpolation", 1);
|
|
1427
|
+
__decorateClass([
|
|
1428
|
+
A_Feature.Extend({
|
|
1429
|
+
name: AreAttributeFeatures.Update,
|
|
1430
|
+
scope: [AreDirectiveAttribute]
|
|
1431
|
+
}),
|
|
1432
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1433
|
+
__decorateParam(1, A_Inject(A_Scope)),
|
|
1434
|
+
__decorateParam(2, A_Inject(A_Feature)),
|
|
1435
|
+
__decorateParam(3, A_Inject(A_Logger))
|
|
1436
|
+
], AreHTMLLifecycle.prototype, "updateDirectiveAttribute", 1);
|
|
1437
|
+
var AreHTMLTransformer = class extends AreTransformer {
|
|
1438
|
+
transformDirectiveAttribute(directive, store, feature, logger, ...args) {
|
|
1439
|
+
store.watch(directive);
|
|
1440
|
+
if (directive.component) {
|
|
1441
|
+
feature.chain(directive.component, AreDirectiveFeatures.Transform, directive.owner.scope);
|
|
1442
|
+
} else {
|
|
1443
|
+
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.`);
|
|
1444
|
+
}
|
|
1445
|
+
store.unwatch(directive);
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
__decorateClass([
|
|
1449
|
+
A_Feature.Extend({
|
|
1450
|
+
name: AreAttributeFeatures.Transform,
|
|
1451
|
+
scope: [AreDirectiveAttribute]
|
|
1452
|
+
}),
|
|
1453
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1454
|
+
__decorateParam(1, A_Inject(AreStore)),
|
|
1455
|
+
__decorateParam(2, A_Inject(A_Feature)),
|
|
1456
|
+
__decorateParam(3, A_Inject(A_Logger))
|
|
1457
|
+
], AreHTMLTransformer.prototype, "transformDirectiveAttribute", 1);
|
|
1458
|
+
|
|
1459
|
+
// src/engine/AreHTML.engine.ts
|
|
1460
|
+
var AreHTMLEngine = class extends AreEngine {
|
|
1461
|
+
get DefaultSyntax() {
|
|
1462
|
+
return new AreSyntax({
|
|
1463
|
+
trimWhitespace: true,
|
|
1464
|
+
strictMode: true,
|
|
1465
|
+
rules: [
|
|
1466
|
+
// HTML comments
|
|
1467
|
+
{
|
|
1468
|
+
opening: "<!--",
|
|
1469
|
+
closing: "-->",
|
|
1470
|
+
component: AreComment,
|
|
1471
|
+
priority: 10,
|
|
1472
|
+
nested: false,
|
|
1473
|
+
extract: (raw) => ({ content: raw.slice(4, -3).trim() })
|
|
1474
|
+
},
|
|
1475
|
+
// interpolations
|
|
1476
|
+
{
|
|
1477
|
+
opening: "{{",
|
|
1478
|
+
closing: "}}",
|
|
1479
|
+
component: AreInterpolation,
|
|
1480
|
+
priority: 9,
|
|
1481
|
+
nested: false,
|
|
1482
|
+
extract: (_, match) => ({ key: match.content })
|
|
1483
|
+
},
|
|
1484
|
+
// are-root — matched before generic elements, produces AreRootNode
|
|
1485
|
+
{
|
|
1486
|
+
matcher: this.rootElementMatcher.bind(this),
|
|
1487
|
+
component: AreRootNode,
|
|
1488
|
+
priority: 5
|
|
1489
|
+
},
|
|
1490
|
+
// generic HTML elements
|
|
1491
|
+
{
|
|
1492
|
+
matcher: this.htmlElementMatcher.bind(this),
|
|
1493
|
+
component: AreComponentNode,
|
|
1494
|
+
priority: 4
|
|
1495
|
+
},
|
|
1496
|
+
// plain text fallback
|
|
1497
|
+
{
|
|
1498
|
+
component: AreText,
|
|
1499
|
+
priority: 0
|
|
1500
|
+
}
|
|
1501
|
+
]
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
async init(scope) {
|
|
1505
|
+
this.package(scope, {
|
|
1506
|
+
context: new AreHTMLEngineContext({}),
|
|
1507
|
+
syntax: this.DefaultSyntax,
|
|
1508
|
+
compiler: AreHTMLCompiler,
|
|
1509
|
+
interpreter: AreHTMLInterpreter,
|
|
1510
|
+
tokenizer: AreHTMLTokenizer,
|
|
1511
|
+
lifecycle: AreHTMLLifecycle,
|
|
1512
|
+
transformer: AreHTMLTransformer
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
rootElementMatcher(source, from, to, build) {
|
|
1516
|
+
const rootTag = "are-root";
|
|
1517
|
+
const tagStart = source.indexOf("<", from);
|
|
1518
|
+
if (tagStart === -1 || tagStart >= to) return null;
|
|
1519
|
+
const tagNameMatch = source.slice(tagStart).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);
|
|
1520
|
+
if (!tagNameMatch || tagNameMatch[1].toLowerCase() !== rootTag) return null;
|
|
1521
|
+
return this.htmlElementMatcher(source, from, to, build);
|
|
1522
|
+
}
|
|
1523
|
+
htmlElementMatcher(source, from, to, build) {
|
|
1524
|
+
let index = from;
|
|
1525
|
+
while (index < to) {
|
|
1526
|
+
const tagStart = source.indexOf("<", index);
|
|
1527
|
+
if (tagStart === -1 || tagStart >= to) return null;
|
|
1528
|
+
if (source.startsWith("<!--", tagStart)) {
|
|
1529
|
+
index = tagStart + 1;
|
|
1530
|
+
continue;
|
|
1531
|
+
}
|
|
1532
|
+
if (source[tagStart + 1] === "/") {
|
|
1533
|
+
index = tagStart + 1;
|
|
1534
|
+
continue;
|
|
1535
|
+
}
|
|
1536
|
+
if (source[tagStart + 1] === "!" || source[tagStart + 1] === "?") {
|
|
1537
|
+
index = tagStart + 1;
|
|
1538
|
+
continue;
|
|
1539
|
+
}
|
|
1540
|
+
const tagNameMatch = source.slice(tagStart).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);
|
|
1541
|
+
if (!tagNameMatch) {
|
|
1542
|
+
index = tagStart + 1;
|
|
1543
|
+
continue;
|
|
1544
|
+
}
|
|
1545
|
+
const tagName = tagNameMatch[1];
|
|
1546
|
+
const openingTagEnd = AreHTMLEngine.findTagClose(source, tagStart);
|
|
1547
|
+
if (openingTagEnd === -1) return null;
|
|
1548
|
+
const openingTagStr = source.slice(tagStart, openingTagEnd + 1);
|
|
1549
|
+
const idMatch = openingTagStr.match(/\bid=["']([^"']*)["']/);
|
|
1550
|
+
const id = idMatch ? idMatch[1] : void 0;
|
|
1551
|
+
if (source[openingTagEnd - 1] === "/") {
|
|
1552
|
+
const raw = source.slice(tagStart, openingTagEnd + 1);
|
|
1553
|
+
const content2 = source.slice(tagStart + tagNameMatch[0].length, openingTagEnd - 1);
|
|
1554
|
+
const match2 = build(raw, content2, tagStart, "/>");
|
|
1555
|
+
match2.payload = { entity: tagName, selfClose: true, id };
|
|
1556
|
+
return match2;
|
|
1557
|
+
}
|
|
1558
|
+
const closingTag = `</${tagName}>`;
|
|
1559
|
+
let level = 0;
|
|
1560
|
+
let searchIndex = openingTagEnd + 1;
|
|
1561
|
+
let closingStart = -1;
|
|
1562
|
+
while (searchIndex < to) {
|
|
1563
|
+
const nextOpen = source.indexOf(`<${tagName}`, searchIndex);
|
|
1564
|
+
const nextClose = source.indexOf(closingTag, searchIndex);
|
|
1565
|
+
if (nextClose === -1) break;
|
|
1566
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
1567
|
+
const charAfter = source[nextOpen + tagName.length + 1];
|
|
1568
|
+
if (charAfter === " " || charAfter === ">" || charAfter === "/") {
|
|
1569
|
+
level++;
|
|
1570
|
+
searchIndex = nextOpen + tagName.length + 1;
|
|
1571
|
+
continue;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
if (level === 0) {
|
|
1575
|
+
closingStart = nextClose;
|
|
1576
|
+
break;
|
|
1577
|
+
}
|
|
1578
|
+
level--;
|
|
1579
|
+
searchIndex = nextClose + closingTag.length;
|
|
1580
|
+
}
|
|
1581
|
+
if (closingStart === -1) return null;
|
|
1582
|
+
const fullTag = source.slice(tagStart, closingStart + closingTag.length);
|
|
1583
|
+
const content = source.slice(openingTagEnd + 1, closingStart);
|
|
1584
|
+
const match = build(fullTag, content, tagStart, closingTag);
|
|
1585
|
+
match.payload = { entity: tagName, selfClose: false, id };
|
|
1586
|
+
return match;
|
|
1587
|
+
}
|
|
1588
|
+
return null;
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Find the index of the closing `>` of an opening tag, skipping over
|
|
1592
|
+
* `>` characters that appear inside quoted attribute values.
|
|
1593
|
+
*/
|
|
1594
|
+
static findTagClose(source, from) {
|
|
1595
|
+
let inSingle = false;
|
|
1596
|
+
let inDouble = false;
|
|
1597
|
+
for (let i = from; i < source.length; i++) {
|
|
1598
|
+
const ch = source[i];
|
|
1599
|
+
if (ch === '"' && !inSingle) inDouble = !inDouble;
|
|
1600
|
+
else if (ch === "'" && !inDouble) inSingle = !inSingle;
|
|
1601
|
+
else if (ch === ">" && !inSingle && !inDouble) return i;
|
|
1602
|
+
}
|
|
1603
|
+
return -1;
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
__decorateClass([
|
|
1607
|
+
A_Feature.Extend({
|
|
1608
|
+
name: A_ServiceFeatures.onBeforeLoad,
|
|
1609
|
+
before: /.*/
|
|
1610
|
+
}),
|
|
1611
|
+
__decorateParam(0, A_Inject(A_Scope))
|
|
1612
|
+
], AreHTMLEngine.prototype, "init", 1);
|
|
1613
|
+
AreHTMLEngine = __decorateClass([
|
|
1614
|
+
A_Frame.Component({
|
|
1615
|
+
namespace: "A-ARE",
|
|
1616
|
+
name: "AreHTMLEngine",
|
|
1617
|
+
description: "HTML Rendering Engine for A-Concept Rendering Engine (ARE), responsible for processing and rendering HTML templates within the ARE framework."
|
|
1618
|
+
})
|
|
1619
|
+
], AreHTMLEngine);
|
|
1620
|
+
var AreRoot = class extends Are {
|
|
1621
|
+
constructor() {
|
|
1622
|
+
super(...arguments);
|
|
1623
|
+
this.props = {
|
|
1624
|
+
default: {
|
|
1625
|
+
type: "string",
|
|
1626
|
+
default: ""
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
async template(root, logger, signalsContext) {
|
|
1631
|
+
const rootId = root.id;
|
|
1632
|
+
if (signalsContext && !signalsContext.hasRoot(rootId)) {
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
const currentRoute = AreRoute$1.default();
|
|
1636
|
+
let componentName;
|
|
1637
|
+
if (currentRoute) {
|
|
1638
|
+
const initialVector = new A_SignalVector([currentRoute]);
|
|
1639
|
+
let renderTarget = signalsContext?.findComponentByVector(rootId, initialVector);
|
|
1640
|
+
if (!renderTarget) {
|
|
1641
|
+
const signalsMeta = A_Context.meta(AreSignals);
|
|
1642
|
+
renderTarget = signalsMeta?.findComponentByVector(initialVector);
|
|
1643
|
+
}
|
|
1644
|
+
if (renderTarget?.name) {
|
|
1645
|
+
componentName = A_FormatterHelper.toKebabCase(renderTarget.name);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
if (!componentName) {
|
|
1649
|
+
const defaultAttr = root.attributes.find((attr) => attr.name === "default");
|
|
1650
|
+
componentName = defaultAttr?.content;
|
|
1651
|
+
}
|
|
1652
|
+
if (!componentName) {
|
|
1653
|
+
logger.warning('AreRoot: No component found for initial render. Please ensure a route condition or "default" attribute is set.');
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
root.setContent(`<${componentName}></${componentName}>`);
|
|
1657
|
+
}
|
|
1658
|
+
async onSignal(root, vector, store, logger, signalsContext) {
|
|
1659
|
+
console.log("Received signal vector in AreRoot:", root, vector);
|
|
1660
|
+
const rootId = root.id;
|
|
1661
|
+
if (signalsContext && !signalsContext.hasRoot(rootId)) {
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1664
|
+
let renderTarget = signalsContext?.findComponentByVector(rootId, vector);
|
|
1665
|
+
if (!renderTarget) {
|
|
1666
|
+
const signalsMeta = A_Context.meta(AreSignals);
|
|
1667
|
+
renderTarget = signalsMeta?.findComponentByVector(vector);
|
|
1668
|
+
}
|
|
1669
|
+
const componentName = renderTarget?.name ? A_FormatterHelper.toKebabCase(renderTarget.name) : store.get("default");
|
|
1670
|
+
if (!componentName) {
|
|
1671
|
+
logger.warning("No component found for rendering in AreRoot. Please ensure that the signal vector matches at least one component or that a default component name is provided in the store.");
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
root.setContent(`<${componentName}></${componentName}>`);
|
|
1675
|
+
for (let i = 0; i < root.children.length; i++) {
|
|
1676
|
+
const child = root.children[i];
|
|
1677
|
+
child.unmount();
|
|
1678
|
+
child.destroy();
|
|
1679
|
+
root.removeChild(child);
|
|
1680
|
+
}
|
|
1681
|
+
root.tokenize();
|
|
1682
|
+
for (let i = 0; i < root.children.length; i++) {
|
|
1683
|
+
const child = root.children[i];
|
|
1684
|
+
child.init();
|
|
1685
|
+
const res = child.load();
|
|
1686
|
+
if (res instanceof Promise) {
|
|
1687
|
+
await res;
|
|
1688
|
+
}
|
|
1689
|
+
child.transform();
|
|
1690
|
+
child.compile();
|
|
1691
|
+
child.mount();
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
__decorateClass([
|
|
1696
|
+
Are.Template,
|
|
1697
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1698
|
+
__decorateParam(1, A_Inject(A_Logger)),
|
|
1699
|
+
__decorateParam(2, A_Inject(AreSignalsContext))
|
|
1700
|
+
], AreRoot.prototype, "template", 1);
|
|
1701
|
+
__decorateClass([
|
|
1702
|
+
Are.Signal,
|
|
1703
|
+
__decorateParam(0, A_Inject(A_Caller)),
|
|
1704
|
+
__decorateParam(1, A_Inject(A_SignalVector)),
|
|
1705
|
+
__decorateParam(2, A_Inject(AreStore)),
|
|
1706
|
+
__decorateParam(3, A_Inject(A_Logger)),
|
|
1707
|
+
__decorateParam(4, A_Inject(AreSignalsContext))
|
|
1708
|
+
], AreRoot.prototype, "onSignal", 1);
|
|
1709
|
+
AreRoot = __decorateClass([
|
|
1710
|
+
A_Frame.Component({
|
|
1711
|
+
namespace: "A-ARE",
|
|
1712
|
+
name: "AreRoot",
|
|
1713
|
+
description: "The AreRoot component serves as the foundational entry point for the A-Concept Rendering Engine (ARE). It is responsible for initializing the rendering process, managing the root node of the component tree, and handling signal-based rendering logic. The AreRoot component processes incoming signals to determine which child components to render, allowing for dynamic and responsive UI updates based on application state and user interactions."
|
|
1714
|
+
})
|
|
1715
|
+
], AreRoot);
|
|
1716
|
+
var AreWatcher = class extends A_Component {
|
|
1717
|
+
constructor() {
|
|
1718
|
+
super();
|
|
1719
|
+
this.handlers = /* @__PURE__ */ new Set();
|
|
1720
|
+
this.current = new URL(window.location.href);
|
|
1721
|
+
// ── Listeners ─────────────────────────────────────────────────────────────
|
|
1722
|
+
this.onPopState = () => {
|
|
1723
|
+
this.notify();
|
|
1724
|
+
};
|
|
1725
|
+
this.onHashChange = () => {
|
|
1726
|
+
this.notify();
|
|
1727
|
+
};
|
|
1728
|
+
this.onURLChange = () => {
|
|
1729
|
+
this.notify();
|
|
1730
|
+
};
|
|
1731
|
+
this.patchHistory();
|
|
1732
|
+
this.attachListeners();
|
|
1733
|
+
}
|
|
1734
|
+
// ── Public ────────────────────────────────────────────────────────────────
|
|
1735
|
+
onChange(handler) {
|
|
1736
|
+
this.handlers.add(handler);
|
|
1737
|
+
return () => this.handlers.delete(handler);
|
|
1738
|
+
}
|
|
1739
|
+
get url() {
|
|
1740
|
+
return this.current;
|
|
1741
|
+
}
|
|
1742
|
+
destroy() {
|
|
1743
|
+
window.removeEventListener("popstate", this.onPopState);
|
|
1744
|
+
window.removeEventListener("hashchange", this.onHashChange);
|
|
1745
|
+
window.removeEventListener("urlchange", this.onURLChange);
|
|
1746
|
+
this.handlers.clear();
|
|
1747
|
+
}
|
|
1748
|
+
attachListeners() {
|
|
1749
|
+
window.addEventListener("popstate", this.onPopState);
|
|
1750
|
+
window.addEventListener("hashchange", this.onHashChange);
|
|
1751
|
+
window.addEventListener("urlchange", this.onURLChange);
|
|
1752
|
+
}
|
|
1753
|
+
// ── Patch pushState / replaceState ────────────────────────────────────────
|
|
1754
|
+
patchHistory() {
|
|
1755
|
+
const patch = (original) => function(...args) {
|
|
1756
|
+
original.apply(this, args);
|
|
1757
|
+
window.dispatchEvent(new Event("urlchange"));
|
|
1758
|
+
};
|
|
1759
|
+
history.pushState = patch(history.pushState);
|
|
1760
|
+
history.replaceState = patch(history.replaceState);
|
|
1761
|
+
}
|
|
1762
|
+
// ── Notify ────────────────────────────────────────────────────────────────
|
|
1763
|
+
notify() {
|
|
1764
|
+
const next = new URL(window.location.href);
|
|
1765
|
+
if (next.href === this.current.href) return;
|
|
1766
|
+
this.current = next;
|
|
1767
|
+
for (const handler of this.handlers) {
|
|
1768
|
+
handler(this.current);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
};
|
|
1772
|
+
AreWatcher = __decorateClass([
|
|
1773
|
+
A_Frame.Component({
|
|
1774
|
+
namespace: "A-ARE",
|
|
1775
|
+
name: "AreWatcher",
|
|
1776
|
+
description: "AreWatcher is a component that observes browser navigation events (history pushState, replaceState, and popstate) and notifies registered handlers when the URL changes, enabling client-side routing and reactive route-based rendering within the ARE framework."
|
|
1777
|
+
})
|
|
1778
|
+
], AreWatcher);
|
|
1779
|
+
|
|
1780
|
+
export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreStaticAttribute, AreStyle, AreText, AreWatcher };
|
|
1781
|
+
//# sourceMappingURL=index.mjs.map
|
|
1782
|
+
//# sourceMappingURL=index.mjs.map
|