@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,210 @@
|
|
|
1
|
+
import { A_Feature, A_Inject, A_Scope } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
3
|
+
import { A_ServiceFeatures } from "@adaas/a-utils/a-service";
|
|
4
|
+
import { AreEngine, AreSyntaxTokenMatch, AreSyntax } from "@adaas/are";
|
|
5
|
+
import { AreHTMLInterpreter } from "@adaas/are-html/interpreter";
|
|
6
|
+
import { AreHTMLEngineContext } from "./AreHTML.context";
|
|
7
|
+
import { AreInterpolation } from "@adaas/are-html/nodes/AreInterpolation";
|
|
8
|
+
import { AreText } from "@adaas/are-html/nodes/AreText";
|
|
9
|
+
import { AreComment } from "@adaas/are-html/nodes/AreComment";
|
|
10
|
+
import { AreComponentNode } from "@adaas/are-html/nodes/AreComponent";
|
|
11
|
+
import { AreHTMLTokenizer } from "@adaas/are-html/tokenizer";
|
|
12
|
+
import { AreRootNode } from "@adaas/are-html/nodes/AreRoot";
|
|
13
|
+
import { AreHTMLLifecycle } from "@adaas/are-html/lifecycle";
|
|
14
|
+
import { AreHTMLTransformer } from "@adaas/are-html/transformer";
|
|
15
|
+
import { AreHTMLCompiler } from "./AreHTML.compiler";
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@A_Frame.Component({
|
|
20
|
+
namespace: 'A-ARE',
|
|
21
|
+
name: 'AreHTMLEngine',
|
|
22
|
+
description: 'HTML Rendering Engine for A-Concept Rendering Engine (ARE), responsible for processing and rendering HTML templates within the ARE framework.'
|
|
23
|
+
})
|
|
24
|
+
export class AreHTMLEngine extends AreEngine {
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
get DefaultSyntax() {
|
|
29
|
+
return new AreSyntax({
|
|
30
|
+
trimWhitespace: true,
|
|
31
|
+
strictMode: true,
|
|
32
|
+
rules: [
|
|
33
|
+
// HTML comments
|
|
34
|
+
{
|
|
35
|
+
opening: '<!--',
|
|
36
|
+
closing: '-->',
|
|
37
|
+
component: AreComment,
|
|
38
|
+
priority: 10,
|
|
39
|
+
nested: false,
|
|
40
|
+
extract: (raw) => ({ content: raw.slice(4, -3).trim() }),
|
|
41
|
+
},
|
|
42
|
+
// interpolations
|
|
43
|
+
{
|
|
44
|
+
opening: '{{',
|
|
45
|
+
closing: '}}',
|
|
46
|
+
component: AreInterpolation,
|
|
47
|
+
priority: 9,
|
|
48
|
+
nested: false,
|
|
49
|
+
extract: (_, match) => ({ key: match.content }),
|
|
50
|
+
},
|
|
51
|
+
// are-root — matched before generic elements, produces AreRootNode
|
|
52
|
+
{
|
|
53
|
+
matcher: this.rootElementMatcher.bind(this),
|
|
54
|
+
component: AreRootNode,
|
|
55
|
+
priority: 5,
|
|
56
|
+
},
|
|
57
|
+
// generic HTML elements
|
|
58
|
+
{
|
|
59
|
+
matcher: this.htmlElementMatcher.bind(this),
|
|
60
|
+
component: AreComponentNode,
|
|
61
|
+
priority: 4,
|
|
62
|
+
},
|
|
63
|
+
// plain text fallback
|
|
64
|
+
{
|
|
65
|
+
component: AreText,
|
|
66
|
+
priority: 0,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Inject AreHTMLSyntax into the container scope before loading
|
|
75
|
+
*
|
|
76
|
+
* @param container
|
|
77
|
+
*/
|
|
78
|
+
@A_Feature.Extend({
|
|
79
|
+
name: A_ServiceFeatures.onBeforeLoad,
|
|
80
|
+
before: /.*/
|
|
81
|
+
})
|
|
82
|
+
async init(
|
|
83
|
+
@A_Inject(A_Scope) scope: A_Scope,
|
|
84
|
+
) {
|
|
85
|
+
this.package(scope, {
|
|
86
|
+
context: new AreHTMLEngineContext({}),
|
|
87
|
+
syntax: this.DefaultSyntax,
|
|
88
|
+
compiler: AreHTMLCompiler,
|
|
89
|
+
interpreter: AreHTMLInterpreter,
|
|
90
|
+
tokenizer: AreHTMLTokenizer,
|
|
91
|
+
lifecycle: AreHTMLLifecycle,
|
|
92
|
+
transformer: AreHTMLTransformer,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
protected rootElementMatcher(
|
|
98
|
+
source: string,
|
|
99
|
+
from: number,
|
|
100
|
+
to: number,
|
|
101
|
+
build: (raw: string, content: string, position: number, closing: string) => AreSyntaxTokenMatch
|
|
102
|
+
): AreSyntaxTokenMatch | null {
|
|
103
|
+
|
|
104
|
+
// const rootTag = this.config.rootTag
|
|
105
|
+
const rootTag = 'are-root';
|
|
106
|
+
|
|
107
|
+
const tagStart = source.indexOf('<', from)
|
|
108
|
+
if (tagStart === -1 || tagStart >= to) return null
|
|
109
|
+
|
|
110
|
+
// only match if the tag name is exactly the configured root tag
|
|
111
|
+
const tagNameMatch = source.slice(tagStart).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/)
|
|
112
|
+
if (!tagNameMatch || tagNameMatch[1].toLowerCase() !== rootTag) return null
|
|
113
|
+
|
|
114
|
+
// delegate the actual matching to the shared HTML element logic
|
|
115
|
+
return this.htmlElementMatcher(source, from, to, build)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
protected htmlElementMatcher(
|
|
119
|
+
source: string,
|
|
120
|
+
from: number,
|
|
121
|
+
to: number,
|
|
122
|
+
build: (raw: string, content: string, position: number, closing: string) => AreSyntaxTokenMatch
|
|
123
|
+
): AreSyntaxTokenMatch | null {
|
|
124
|
+
let index = from
|
|
125
|
+
|
|
126
|
+
while (index < to) {
|
|
127
|
+
const tagStart = source.indexOf('<', index)
|
|
128
|
+
if (tagStart === -1 || tagStart >= to) return null
|
|
129
|
+
|
|
130
|
+
// skip comments, closing tags, doctype, processing instructions
|
|
131
|
+
if (source.startsWith('<!--', tagStart)) { index = tagStart + 1; continue }
|
|
132
|
+
if (source[tagStart + 1] === '/') { index = tagStart + 1; continue }
|
|
133
|
+
if (source[tagStart + 1] === '!' || source[tagStart + 1] === '?') { index = tagStart + 1; continue }
|
|
134
|
+
|
|
135
|
+
const tagNameMatch = source.slice(tagStart).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/)
|
|
136
|
+
if (!tagNameMatch) { index = tagStart + 1; continue }
|
|
137
|
+
|
|
138
|
+
const tagName = tagNameMatch[1]
|
|
139
|
+
const openingTagEnd = AreHTMLEngine.findTagClose(source, tagStart)
|
|
140
|
+
if (openingTagEnd === -1) return null
|
|
141
|
+
|
|
142
|
+
// extract id attribute if present in the opening tag
|
|
143
|
+
const openingTagStr = source.slice(tagStart, openingTagEnd + 1)
|
|
144
|
+
const idMatch = openingTagStr.match(/\bid=["']([^"']*)["']/)
|
|
145
|
+
const id = idMatch ? idMatch[1] : undefined
|
|
146
|
+
|
|
147
|
+
// self-closing: <br/> or <input/>
|
|
148
|
+
if (source[openingTagEnd - 1] === '/') {
|
|
149
|
+
const raw = source.slice(tagStart, openingTagEnd + 1)
|
|
150
|
+
const content = source.slice(tagStart + tagNameMatch[0].length, openingTagEnd - 1)
|
|
151
|
+
const match = build(raw, content, tagStart, '/>')
|
|
152
|
+
match.payload = { entity: tagName, selfClose: true, id }
|
|
153
|
+
return match
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// find matching closing tag respecting nesting
|
|
157
|
+
const closingTag = `</${tagName}>`
|
|
158
|
+
let level = 0
|
|
159
|
+
let searchIndex = openingTagEnd + 1
|
|
160
|
+
let closingStart = -1
|
|
161
|
+
|
|
162
|
+
while (searchIndex < to) {
|
|
163
|
+
const nextOpen = source.indexOf(`<${tagName}`, searchIndex)
|
|
164
|
+
const nextClose = source.indexOf(closingTag, searchIndex)
|
|
165
|
+
if (nextClose === -1) break
|
|
166
|
+
|
|
167
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
168
|
+
const charAfter = source[nextOpen + tagName.length + 1]
|
|
169
|
+
if (charAfter === ' ' || charAfter === '>' || charAfter === '/') {
|
|
170
|
+
level++
|
|
171
|
+
searchIndex = nextOpen + tagName.length + 1
|
|
172
|
+
continue
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (level === 0) { closingStart = nextClose; break }
|
|
177
|
+
level--
|
|
178
|
+
searchIndex = nextClose + closingTag.length
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (closingStart === -1) return null
|
|
182
|
+
|
|
183
|
+
const fullTag = source.slice(tagStart, closingStart + closingTag.length)
|
|
184
|
+
const content = source.slice(openingTagEnd + 1, closingStart)
|
|
185
|
+
const match = build(fullTag, content, tagStart, closingTag)
|
|
186
|
+
match.payload = { entity: tagName, selfClose: false, id }
|
|
187
|
+
return match
|
|
188
|
+
}
|
|
189
|
+
return null
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Find the index of the closing `>` of an opening tag, skipping over
|
|
194
|
+
* `>` characters that appear inside quoted attribute values.
|
|
195
|
+
*/
|
|
196
|
+
private static findTagClose(source: string, from: number): number {
|
|
197
|
+
let inSingle = false
|
|
198
|
+
let inDouble = false
|
|
199
|
+
|
|
200
|
+
for (let i = from; i < source.length; i++) {
|
|
201
|
+
const ch = source[i]
|
|
202
|
+
if (ch === '"' && !inSingle) inDouble = !inDouble
|
|
203
|
+
else if (ch === "'" && !inDouble) inSingle = !inSingle
|
|
204
|
+
else if (ch === '>' && !inSingle && !inDouble) return i
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return -1
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { A_Caller, A_Inject } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
3
|
+
import { A_Logger } from "@adaas/a-utils/a-logger";
|
|
4
|
+
import {
|
|
5
|
+
AreSyntax, AreStore,
|
|
6
|
+
AreEvent,
|
|
7
|
+
AreInstructionDefaultNames,
|
|
8
|
+
AreInterpreterError,
|
|
9
|
+
AreInterpreter
|
|
10
|
+
} from "@adaas/are";
|
|
11
|
+
import { AreHTMLInstructions } from "@adaas/are-html/instructions/AreHTML.instructions.constants";
|
|
12
|
+
import { AddAttributeInstruction } from "@adaas/are-html/instructions/AddAttribute.instruction";
|
|
13
|
+
import { AddCommentInstruction } from "@adaas/are-html/instructions/AddComment.instruction";
|
|
14
|
+
import { AddElementInstruction } from "@adaas/are-html/instructions/AddElement.instruction";
|
|
15
|
+
import { AddListenerInstruction } from "@adaas/are-html/instructions/AddListener.instruction";
|
|
16
|
+
import { AddTextInstruction } from "@adaas/are-html/instructions/AddText.instruction";
|
|
17
|
+
import { AreDirectiveContext } from "@adaas/are-html/directive/AreDirective.context";
|
|
18
|
+
import { AreHTMLNode } from "../lib/AreHTMLNode/AreHTMLNode";
|
|
19
|
+
import { AreHTMLEngineContext } from "./AreHTML.context";
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@A_Frame.Component({
|
|
23
|
+
namespace: 'A-ARE',
|
|
24
|
+
name: 'AreHTMLInterpreter',
|
|
25
|
+
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.'
|
|
26
|
+
})
|
|
27
|
+
export class AreHTMLInterpreter extends AreInterpreter {
|
|
28
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
29
|
+
// ── CreateElement — Apply / Revert ───────────────────────────────────────────
|
|
30
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
31
|
+
@A_Frame.Method({
|
|
32
|
+
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.'
|
|
33
|
+
})
|
|
34
|
+
@AreInterpreter.Apply(AreInstructionDefaultNames.Default)
|
|
35
|
+
@AreInterpreter.Apply(AreHTMLInstructions.AddElement)
|
|
36
|
+
addElement(
|
|
37
|
+
@A_Inject(A_Caller) declaration: AddElementInstruction,
|
|
38
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
39
|
+
@A_Inject(A_Logger) logger?: A_Logger,
|
|
40
|
+
) {
|
|
41
|
+
try {
|
|
42
|
+
const node = declaration.owner as AreHTMLNode;
|
|
43
|
+
|
|
44
|
+
let currentNode: AreHTMLNode | undefined = node;
|
|
45
|
+
let parent: AreHTMLNode | undefined = node.parent as AreHTMLNode | undefined;
|
|
46
|
+
|
|
47
|
+
while (parent) {
|
|
48
|
+
if (context.getNodeElement(parent)) {
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
currentNode = parent;
|
|
52
|
+
parent = parent.parent as AreHTMLNode | undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// Determine the element tag — components render as a wrapper div
|
|
57
|
+
const tag = node.tag;
|
|
58
|
+
|
|
59
|
+
if (parent) {
|
|
60
|
+
|
|
61
|
+
const mountPoint = context.getNodeElement(parent)
|
|
62
|
+
|
|
63
|
+
if (!mountPoint) {
|
|
64
|
+
throw new AreInterpreterError({
|
|
65
|
+
title: 'Mount Point Not Found',
|
|
66
|
+
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.`
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const element = context.container.createElement(tag);
|
|
71
|
+
|
|
72
|
+
if (mountPoint.nodeType === Node.ELEMENT_NODE) {
|
|
73
|
+
// parent is a real element — just append
|
|
74
|
+
mountPoint.appendChild(element);
|
|
75
|
+
} else {
|
|
76
|
+
// parent is an anchor (comment/text node) — insert before it
|
|
77
|
+
// so content always appears before the anchor marker
|
|
78
|
+
mountPoint.parentNode?.insertBefore(element, mountPoint);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
context.setInstructionElement(declaration, element);
|
|
82
|
+
|
|
83
|
+
} else {
|
|
84
|
+
const mountPoint = context.container.getElementById(node.id);
|
|
85
|
+
if (!mountPoint) {
|
|
86
|
+
throw new AreInterpreterError({
|
|
87
|
+
title: 'Mount Point Not Found',
|
|
88
|
+
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.`
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const element = context.container.createElement(tag);
|
|
93
|
+
|
|
94
|
+
element.setAttribute('data-aseid', node.aseid.toString());
|
|
95
|
+
|
|
96
|
+
mountPoint.parentNode?.replaceChild(element, mountPoint);
|
|
97
|
+
|
|
98
|
+
context.setInstructionElement(declaration, element);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Register the element in the context index
|
|
102
|
+
|
|
103
|
+
logger?.debug('green', `Element ${node.aseid.toString()} added to Context:`);
|
|
104
|
+
|
|
105
|
+
} catch (error) {
|
|
106
|
+
logger?.error(error);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@A_Frame.Method({
|
|
113
|
+
description: 'Remove an HTML element that was created by a CreateElement declaration. Cleans up the DOM and the context index.'
|
|
114
|
+
})
|
|
115
|
+
@AreInterpreter.Revert(AreInstructionDefaultNames.Default)
|
|
116
|
+
@AreInterpreter.Revert(AreHTMLInstructions.AddElement)
|
|
117
|
+
removeElement(
|
|
118
|
+
@A_Inject(A_Caller) declaration: AddElementInstruction,
|
|
119
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
120
|
+
) {
|
|
121
|
+
const element = context.getElementByInstruction(declaration);
|
|
122
|
+
|
|
123
|
+
if (element && element.parentNode) {
|
|
124
|
+
element.parentNode.removeChild(element);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
context.removeInstructionElement(declaration);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
132
|
+
// ── AddAttribute — Apply / Revert ────────────────────────────────────────────
|
|
133
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
134
|
+
@A_Frame.Method({
|
|
135
|
+
description: 'Add an attribute to an HTML element based on the provided mutation instruction.'
|
|
136
|
+
})
|
|
137
|
+
@AreInterpreter.Apply(AreHTMLInstructions.AddAttribute)
|
|
138
|
+
@AreInterpreter.Update(AreHTMLInstructions.AddAttribute)
|
|
139
|
+
addAttribute(
|
|
140
|
+
@A_Inject(A_Caller) mutation: AddAttributeInstruction,
|
|
141
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
142
|
+
@A_Inject(AreStore) store: AreStore,
|
|
143
|
+
@A_Inject(AreSyntax) syntax: AreSyntax,
|
|
144
|
+
@A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,
|
|
145
|
+
|
|
146
|
+
@A_Inject(A_Logger) logger?: A_Logger,
|
|
147
|
+
): void {
|
|
148
|
+
const element = context.getElementByInstruction(mutation.parent!);
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if (!element) {
|
|
152
|
+
throw new AreInterpreterError({
|
|
153
|
+
title: 'Element Not Found',
|
|
154
|
+
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.`
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const { name, content, evaluate } = mutation.payload;
|
|
158
|
+
|
|
159
|
+
const value = evaluate ? syntax.evaluate(content, store, {
|
|
160
|
+
...(directiveContext?.scope || {})
|
|
161
|
+
}) : content;
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* First time
|
|
166
|
+
*/
|
|
167
|
+
if (mutation.cache === undefined) {
|
|
168
|
+
|
|
169
|
+
const existingValue = (element as HTMLElement).getAttribute(name);
|
|
170
|
+
|
|
171
|
+
const result = (existingValue ? `${existingValue} ${value}` : value);
|
|
172
|
+
|
|
173
|
+
(element as HTMLElement).setAttribute(name, result);
|
|
174
|
+
|
|
175
|
+
mutation.cache = value;
|
|
176
|
+
|
|
177
|
+
} else {
|
|
178
|
+
|
|
179
|
+
const existingValue = (element as HTMLElement).getAttribute(name);
|
|
180
|
+
|
|
181
|
+
const existingParts = existingValue ? existingValue.split(/\s+/).filter(Boolean) : [];
|
|
182
|
+
const oldParts = new Set((mutation.cache as string).split(/\s+/).filter(Boolean));
|
|
183
|
+
const newParts = value ? value.split(/\s+/).filter(Boolean) : [];
|
|
184
|
+
|
|
185
|
+
const result = [...existingParts.filter(part => !oldParts.has(part)), ...newParts].join(' ');
|
|
186
|
+
|
|
187
|
+
(element as HTMLElement).setAttribute(name, result);
|
|
188
|
+
|
|
189
|
+
mutation.cache = value;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@A_Frame.Method({
|
|
196
|
+
description: 'Remove an attribute from an HTML element based on the provided mutation instruction.'
|
|
197
|
+
})
|
|
198
|
+
@AreInterpreter.Revert(AreHTMLInstructions.AddAttribute)
|
|
199
|
+
removeAttribute(
|
|
200
|
+
@A_Inject(A_Caller) mutation: AddAttributeInstruction,
|
|
201
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
202
|
+
): void {
|
|
203
|
+
try {
|
|
204
|
+
const element = context.getElementByInstruction(mutation.parent!);
|
|
205
|
+
|
|
206
|
+
if (!element) return;
|
|
207
|
+
|
|
208
|
+
const { name } = mutation.payload;
|
|
209
|
+
|
|
210
|
+
if (name && element.nodeType === Node.ELEMENT_NODE) {
|
|
211
|
+
(element as HTMLElement)?.removeAttribute(name);
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
console.log('Error removing attribute:', error);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
221
|
+
// ── addEventListener — Apply / Revert ────────────────────────────────────────
|
|
222
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
223
|
+
|
|
224
|
+
@A_Frame.Method({
|
|
225
|
+
description: 'Add an event listener to an HTML element based on the provided mutation instruction.'
|
|
226
|
+
})
|
|
227
|
+
@AreInterpreter.Apply(AreHTMLInstructions.AddListener)
|
|
228
|
+
addEventListener(
|
|
229
|
+
@A_Inject(A_Caller) mutation: AddListenerInstruction,
|
|
230
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
231
|
+
@A_Inject(AreStore) store: AreStore,
|
|
232
|
+
@A_Inject(AreSyntax) syntax: AreSyntax,
|
|
233
|
+
@A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,
|
|
234
|
+
@A_Inject(A_Logger) logger?: A_Logger,
|
|
235
|
+
) {
|
|
236
|
+
|
|
237
|
+
const element = context.getElementByInstruction(mutation.parent);
|
|
238
|
+
|
|
239
|
+
if (!element) {
|
|
240
|
+
throw new AreInterpreterError({
|
|
241
|
+
title: 'Element Not Found',
|
|
242
|
+
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.`
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* e.g. @click="handleClick"
|
|
248
|
+
*
|
|
249
|
+
* e.g. @click="handleClick($event, element)"
|
|
250
|
+
*
|
|
251
|
+
* e.g. @click="(e)=> user.name ? handleClick(e) : null" (with conditional logic)
|
|
252
|
+
*
|
|
253
|
+
* e.g. @click="(e)=> isValid(user.name) ? handleClick(e) : null" (with conditional logic)
|
|
254
|
+
*
|
|
255
|
+
* e.g. @click="(e)=> isValid(user.name) ? handleClick(e, format(user.name)) : null" (with conditional logic)
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
const handlers = syntax.extractEmitHandlers(mutation.payload.handler);
|
|
260
|
+
const handlerScope = {}
|
|
261
|
+
|
|
262
|
+
for (const handler of handlers) {
|
|
263
|
+
const handlerFn = (...args: any[]) => {
|
|
264
|
+
const event = new AreEvent(handler)
|
|
265
|
+
|
|
266
|
+
event.set('args', args);
|
|
267
|
+
event.set('element', element);
|
|
268
|
+
event.set('instruction', mutation);
|
|
269
|
+
|
|
270
|
+
mutation.owner.emit(event);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
handlerScope[`$${handler}`] = handlerFn;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const callback = (e: Event) => {
|
|
277
|
+
context.startPerformance('Click')
|
|
278
|
+
|
|
279
|
+
const result = syntax.evaluate(mutation.payload.handler, store, {
|
|
280
|
+
...handlerScope,
|
|
281
|
+
...(directiveContext?.scope || {})
|
|
282
|
+
});
|
|
283
|
+
if (typeof result === 'function') result(e);
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
if (callback) {
|
|
288
|
+
element.addEventListener(mutation.payload.name, callback);
|
|
289
|
+
context.addListener(element, mutation.payload.name, callback);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
@A_Frame.Method({
|
|
295
|
+
description: 'Remove an event listener from an HTML element based on the provided mutation instruction.'
|
|
296
|
+
})
|
|
297
|
+
@AreInterpreter.Revert(AreHTMLInstructions.AddListener)
|
|
298
|
+
removeEventListener(
|
|
299
|
+
@A_Inject(A_Caller) mutation: AddListenerInstruction,
|
|
300
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
301
|
+
) {
|
|
302
|
+
const element = context.getElementByInstruction(mutation.parent);
|
|
303
|
+
|
|
304
|
+
if (!element) return;
|
|
305
|
+
|
|
306
|
+
const { name } = mutation.payload;
|
|
307
|
+
|
|
308
|
+
const listener = context.getListener(element, name);
|
|
309
|
+
|
|
310
|
+
if (listener) {
|
|
311
|
+
element.removeEventListener(name, listener);
|
|
312
|
+
context.removeListener(element, name);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
318
|
+
// ── AddText — Apply / Revert ─────────────────────────────────────────────────
|
|
319
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
320
|
+
|
|
321
|
+
@A_Frame.Method({
|
|
322
|
+
description: 'Add text content to an HTML element based on the provided declaration instruction.'
|
|
323
|
+
})
|
|
324
|
+
@AreInterpreter.Apply(AreHTMLInstructions.AddText)
|
|
325
|
+
@AreInterpreter.Update(AreHTMLInstructions.AddText)
|
|
326
|
+
addText(
|
|
327
|
+
@A_Inject(A_Caller) declaration: AddTextInstruction,
|
|
328
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
329
|
+
@A_Inject(AreStore) store: AreStore,
|
|
330
|
+
@A_Inject(AreSyntax) syntax: AreSyntax,
|
|
331
|
+
@A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,
|
|
332
|
+
|
|
333
|
+
@A_Inject(A_Logger) logger?: A_Logger,
|
|
334
|
+
) {
|
|
335
|
+
const node = declaration.owner.parent;
|
|
336
|
+
const { content, evaluate } = declaration.payload;
|
|
337
|
+
|
|
338
|
+
const value = evaluate ? syntax.evaluate(content, store, {
|
|
339
|
+
...(directiveContext?.scope || {})
|
|
340
|
+
}) : content;
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
if (!node) {
|
|
344
|
+
const textNode = context.container.createTextNode(value);
|
|
345
|
+
context.container.body.appendChild(textNode);
|
|
346
|
+
context.setInstructionElement(declaration, textNode);
|
|
347
|
+
|
|
348
|
+
} else {
|
|
349
|
+
const element = context.getNodeElement(node);
|
|
350
|
+
|
|
351
|
+
if (!element) {
|
|
352
|
+
throw new AreInterpreterError({
|
|
353
|
+
title: 'Element Not Found',
|
|
354
|
+
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.`
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const existingNode = context.getElementByInstruction(declaration);
|
|
360
|
+
|
|
361
|
+
if (existingNode) {
|
|
362
|
+
existingNode.textContent = value;
|
|
363
|
+
} else {
|
|
364
|
+
const textNode = context.container.createTextNode(value);
|
|
365
|
+
element.appendChild(textNode);
|
|
366
|
+
|
|
367
|
+
context.setInstructionElement(declaration, textNode);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
logger?.debug('green', `Text ${node?.aseid.toString()} added to Context:`);
|
|
374
|
+
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
@A_Frame.Method({
|
|
379
|
+
description: 'Remove text content from an HTML element based on the provided declaration instruction.'
|
|
380
|
+
})
|
|
381
|
+
@AreInterpreter.Revert(AreHTMLInstructions.AddText)
|
|
382
|
+
removeText(
|
|
383
|
+
@A_Inject(A_Caller) declaration: AddTextInstruction,
|
|
384
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
385
|
+
) {
|
|
386
|
+
const element = context.getElementByInstruction(declaration);
|
|
387
|
+
|
|
388
|
+
if (!element) return;
|
|
389
|
+
|
|
390
|
+
element.parentNode?.removeChild(element);
|
|
391
|
+
context.removeInstructionElement(declaration);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
@A_Frame.Method({
|
|
397
|
+
description: 'Add a comment node to the DOM based on the provided declaration instruction.'
|
|
398
|
+
})
|
|
399
|
+
@AreInterpreter.Apply(AreHTMLInstructions.AddComment)
|
|
400
|
+
@AreInterpreter.Update(AreHTMLInstructions.AddComment)
|
|
401
|
+
addComment(
|
|
402
|
+
@A_Inject(A_Caller) declaration: AddCommentInstruction,
|
|
403
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
404
|
+
@A_Inject(AreStore) store: AreStore,
|
|
405
|
+
@A_Inject(AreSyntax) syntax: AreSyntax,
|
|
406
|
+
@A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,
|
|
407
|
+
|
|
408
|
+
@A_Inject(A_Logger) logger?: A_Logger,
|
|
409
|
+
) {
|
|
410
|
+
const node = declaration.owner.parent;
|
|
411
|
+
const { content, evaluate } = declaration.payload;
|
|
412
|
+
|
|
413
|
+
const value = evaluate ? syntax.evaluate(content, store, {
|
|
414
|
+
...(directiveContext?.scope || {})
|
|
415
|
+
}) : content;
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
if (!node) {
|
|
419
|
+
const commentNode = context.container.createComment(value);
|
|
420
|
+
context.container.body.appendChild(commentNode);
|
|
421
|
+
context.setInstructionElement(declaration, commentNode);
|
|
422
|
+
|
|
423
|
+
} else {
|
|
424
|
+
const element = context.getNodeElement(node);
|
|
425
|
+
|
|
426
|
+
if (!element) {
|
|
427
|
+
throw new AreInterpreterError({
|
|
428
|
+
title: 'Element Not Found',
|
|
429
|
+
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.`
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const existingNode = context.getElementByInstruction(declaration);
|
|
434
|
+
|
|
435
|
+
if (existingNode) {
|
|
436
|
+
existingNode.textContent = value;
|
|
437
|
+
} else {
|
|
438
|
+
const commentNode = context.container.createComment(value);
|
|
439
|
+
element.appendChild(commentNode);
|
|
440
|
+
|
|
441
|
+
context.setInstructionElement(declaration, commentNode);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
logger?.debug('green', `Comment ${node?.aseid.toString()} added to Context:`);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
@A_Frame.Method({
|
|
452
|
+
description: 'Remove a comment node from the DOM based on the provided declaration instruction.'
|
|
453
|
+
})
|
|
454
|
+
@AreInterpreter.Revert(AreHTMLInstructions.AddComment)
|
|
455
|
+
removeComment(
|
|
456
|
+
@A_Inject(A_Caller) declaration: AddCommentInstruction,
|
|
457
|
+
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
458
|
+
) {
|
|
459
|
+
const element = context.getElementByInstruction(declaration);
|
|
460
|
+
|
|
461
|
+
if (!element) return;
|
|
462
|
+
|
|
463
|
+
element.parentNode?.removeChild(element);
|
|
464
|
+
context.removeInstructionElement(declaration);
|
|
465
|
+
}
|
|
466
|
+
}
|