@adaas/are-html 0.0.23 → 0.0.25
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/dist/browser/index.d.mts +18 -2
- package/dist/browser/index.mjs +35 -10
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.mts +17 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.ts +17 -1
- package/dist/node/directives/AreDirectiveIf.directive.js +29 -6
- package/dist/node/directives/AreDirectiveIf.directive.js.map +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.mjs +29 -6
- package/dist/node/directives/AreDirectiveIf.directive.mjs.map +1 -1
- package/dist/node/engine/AreHTML.compiler.d.mts +3 -1
- package/dist/node/engine/AreHTML.compiler.d.ts +3 -1
- package/dist/node/engine/AreHTML.compiler.js +7 -4
- package/dist/node/engine/AreHTML.compiler.js.map +1 -1
- package/dist/node/engine/AreHTML.compiler.mjs +7 -4
- package/dist/node/engine/AreHTML.compiler.mjs.map +1 -1
- package/examples/for-perf/dist/index.html +1 -1
- package/examples/for-perf/dist/{mqj1mpf2-z4aokv.js → mqp8i2py-vltsx0.js} +2488 -2373
- package/examples/lazy-loading/README.md +76 -0
- package/examples/lazy-loading/concept.ts +55 -0
- package/examples/lazy-loading/containers/UI.container.ts +215 -0
- package/examples/lazy-loading/dist/app.js +3803 -0
- package/examples/{for-perf/dist/mqj1mpff-4fr7mw.js → lazy-loading/dist/chunks/chunk-6K72IBO4.js} +2688 -5897
- package/examples/lazy-loading/dist/index.html +36 -0
- package/examples/lazy-loading/dist/lazy/about-page.js +59 -0
- package/examples/lazy-loading/dist/lazy/reports-page.js +65 -0
- package/examples/lazy-loading/dist/lazy/settings-page.js +54 -0
- package/examples/lazy-loading/public/index.html +36 -0
- package/examples/lazy-loading/src/components/AppShell.component.ts +44 -0
- package/examples/lazy-loading/src/components/HomePage.component.ts +59 -0
- package/examples/lazy-loading/src/components/LazyOutlet.component.ts +108 -0
- package/examples/lazy-loading/src/components/NavBar.component.ts +98 -0
- package/examples/lazy-loading/src/concept.ts +116 -0
- package/examples/lazy-loading/src/lazy/AboutPage.component.ts +54 -0
- package/examples/lazy-loading/src/lazy/ReportsPage.component.ts +56 -0
- package/examples/lazy-loading/src/lazy/SettingsPage.component.ts +45 -0
- package/examples/lazy-loading/src/runtime/ComponentManifest.fragment.ts +61 -0
- package/examples/lazy-loading/src/runtime/LazyComponentResolver.fragment.ts +77 -0
- package/examples/os-desktop/README.md +91 -0
- package/examples/os-desktop/concept.ts +54 -0
- package/examples/os-desktop/containers/OS.container.ts +198 -0
- package/examples/os-desktop/containers/apps/AppBackend.ts +29 -0
- package/examples/os-desktop/containers/apps/GanttApp.backend.ts +56 -0
- package/examples/os-desktop/containers/apps/MarketingApp.backend.ts +68 -0
- package/examples/os-desktop/dist/app.js +4410 -0
- package/examples/os-desktop/dist/apps/gantt/app.js +271 -0
- package/examples/os-desktop/dist/apps/marketing/app.js +346 -0
- package/examples/os-desktop/dist/chunks/chunk-6K72IBO4.js +12455 -0
- package/examples/os-desktop/dist/chunks/chunk-EIIGUL6N.js +30 -0
- package/examples/os-desktop/dist/chunks/chunk-WOH7L5UR.js +30 -0
- package/examples/os-desktop/dist/index.html +33 -0
- package/examples/os-desktop/public/index.html +33 -0
- package/examples/os-desktop/src/apps/gantt/GanttApp.component.ts +41 -0
- package/examples/os-desktop/src/apps/gantt/GanttChart.component.ts +126 -0
- package/examples/os-desktop/src/apps/gantt/GanttStore.ts +47 -0
- package/examples/os-desktop/src/apps/gantt/GanttToolbar.component.ts +73 -0
- package/examples/os-desktop/src/apps/gantt/index.ts +13 -0
- package/examples/os-desktop/src/apps/marketing/MarketingApp.component.ts +53 -0
- package/examples/os-desktop/src/apps/marketing/MarketingStore.ts +34 -0
- package/examples/os-desktop/src/apps/marketing/PostEditor.component.ts +153 -0
- package/examples/os-desktop/src/apps/marketing/PostPreview.component.ts +110 -0
- package/examples/os-desktop/src/apps/marketing/index.ts +16 -0
- package/examples/os-desktop/src/concept.ts +126 -0
- package/examples/os-desktop/src/os/AppStage.component.ts +112 -0
- package/examples/os-desktop/src/os/AppWindow.component.ts +102 -0
- package/examples/os-desktop/src/os/Desktop.component.ts +106 -0
- package/examples/os-desktop/src/os/Dock.component.ts +174 -0
- package/examples/os-desktop/src/os/Hud.component.ts +83 -0
- package/examples/os-desktop/src/os/Launchpad.component.ts +191 -0
- package/examples/os-desktop/src/os/MenuBar.component.ts +156 -0
- package/examples/os-desktop/src/runtime/AppComponentResolver.fragment.ts +121 -0
- package/examples/os-desktop/src/runtime/AppRegistry.fragment.ts +104 -0
- package/examples/os-desktop/src/signals/MouseState.signal.ts +34 -0
- package/examples/os-desktop/src/signals/OSRoute.signal.ts +37 -0
- package/examples/os-desktop/src/signals/SelectionState.signal.ts +34 -0
- package/examples/signal-routing/dist/index.html +1 -1
- package/examples/signal-routing/dist/{mqiwo23h-bhcolu.js → mqp8hgce-4d6rh0.js} +2911 -2708
- package/package.json +11 -7
- package/src/directives/AreDirectiveIf.directive.ts +33 -4
- package/src/engine/AreHTML.compiler.ts +12 -2
- package/tests/PropPropagation.test.ts +181 -0
- package/tests/jest.setup.ts +11 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAyBO,IAAM,eAAA,GAAN,cAA8B,WAAA,CAAY;AAAA,EAS7C,eAAA,CACwB,IAAA,EACA,KAAA,EACA,MAAA,EAAA,GACjB,IAAA,EACC;AACJ,IAAA,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,GAAG,IAAI,CAAA;AAU1C,IAAA,IAAI,IAAA,CAAK,cAAA,IAAkB,KAAA,CAAM,IAAA,EAAM;AACnC,MAAA,KAAA,CAAM,IAAA,CAAK,IAAI,wBAAA,CAAyB,KAAA,CAAM,IAAA,EAAM,EAAE,IAAA,EAAM,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AAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EA5Ib,eAAA,CAwIT,SAAA,EAAA,2BAAA,EAAA,CAAA,CAAA;AA0BA,eAAA,CAAA;AAAA,EADC,WAAA,CAAY,QAAQ,iBAAiB,CAAA;AAAA,EAEjC,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EApKb,eAAA,CAkKT,SAAA,EAAA,uBAAA,EAAA,CAAA,CAAA;AA2BA,eAAA,CAAA;AAAA,EADC,WAAA,CAAY,QAAQ,mBAAmB,CAAA;AAAA,EAEnC,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,gCAAa,MAAA,EAAO,CAAA;AAAA,EACpB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,SAAS,CAAA;AAAA,CAAA,EAnMd,eAAA,CA6LT,SAAA,EAAA,yBAAA,EAAA,CAAA,CAAA;AA7LS,eAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,eAAA,CAAA","file":"AreHTML.compiler.mjs","sourcesContent":["import { A_Caller, A_Dependency, A_Feature, A_FormatterHelper, A_Inject } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AddAttributeInstruction} from \"@adaas/are-html/instructions/AddAttribute.instruction\";\nimport { AddTextInstruction} from \"@adaas/are-html/instructions/AddText.instruction\";\nimport { AddListenerInstruction} from \"@adaas/are-html/instructions/AddListener.instruction\";\nimport { AddStyleInstruction } from \"@adaas/are-html/instructions/AddStyle.instruction\";\nimport { AddStaticHTMLInstruction } from \"@adaas/are-html/instructions/AddStaticHTML.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\n\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific compiler for A-Concept Rendering Engine (ARE) components, extending the base AreCompiler to handle HTML templates, styles, and rendering logic tailored for web environments.'\n})\nexport class AreHTMLCompiler extends AreCompiler {\n\n /**\n * Extends the base compile for all AreHTMLNode instances (elements, components, root nodes).\n * After the standard element/attribute/children instructions are emitted, checks whether\n * the node has a registered AreStyle and plans an AddStyleInstruction so the interpreter\n * can inject the CSS into the document head during mount.\n */\n @AreCompiler.Compile(AreHTMLNode)\n compileHTMLNode(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n super.compile(node, scene, logger, ...args);\n\n /**\n * Static-island materialisation. When the tokenizer flagged this node as\n * a static island its inner subtree was never exploded into child nodes,\n * so there is nothing for the base compiler to walk. Emit a single\n * AddStaticHTML instruction carrying the captured inner markup; the\n * interpreter injects it onto the host element in one pass (and decodes\n * HTML entities for free).\n */\n if (node.isStaticIsland && scene.host) {\n scene.plan(new AddStaticHTMLInstruction(scene.host, { html: node.staticInnerHTML! }));\n }\n\n if (node.styles?.styles) {\n const host = scene.host;\n if (host) {\n scene.plan(new AddStyleInstruction(host, { styles: node.styles.styles }));\n }\n }\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Interpolation Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n /**\n * Default compile method for interpolations, which can be overridden by specific implementations if needed.\n * \n * @param interpolation \n * @param scope \n * @param scene \n * @param store \n * @param feature \n */\n @AreCompiler.Compile(AreInterpolation)\n compileInterpolation(\n @A_Inject(A_Caller) interpolation: AreInterpolation,\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n // if (scene.host)\n // console.log('Scene Host: ', scene.host);\n\n // let content = '';\n\n // logger?.debug('green', `AreHTMLCompiler: compile interpolation <${interpolation.aseid.toString()}> with key: \"${interpolation.content}\"`, store.get(interpolation.content));\n\n // try {\n // content = AreCommonHelper.evaluate(interpolation.content, store);\n\n // } catch (error) {\n // content = ''\n // }\n\n scene.plan(new AddTextInstruction({ content: interpolation.content, evaluate: true }));\n }\n\n // -----------------------------------------------------------------------------------------\n // ------------------------------Are-Text Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n @AreCompiler.Compile(AreText)\n compileText(\n @A_Inject(A_Caller) text: AreText,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.debug('cyan', `AreHTMLCompiler: compile text node <${text.aseid.toString()}> with content: \"${text.content}\"`);\n if (scene.host)\n scene.unPlan(scene.host);\n\n scene.plan(new AddTextInstruction({ content: text.content }));\n\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Attribute Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n\n @AreCompiler.Compile(AreStaticAttribute)\n compileStaticAttribute(\n @A_Inject(A_Caller) attribute: AreStaticAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n const content = attribute.content;\n\n /**\n * If the attribute value contains {{ }} interpolations, transform them into\n * a JS string-concatenation expression so the interpreter can evaluate them.\n * e.g. \"color:{{expr}}\" → '\"color:\"+(expr)+\"\"'\n */\n if (content.includes('{{')) {\n const transformed = '\"' + content.replace(/\\{\\{([^}]+)\\}\\}/g, '\"+($1)+\"') + '\"';\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: transformed,\n evaluate: true,\n }));\n return;\n }\n\n /**\n * Default case: regular static attribute rendered as-is.\n */\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content\n }));\n }\n\n @AreCompiler.Compile(AreDirectiveAttribute)\n compileDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n store.watch(directive);\n\n /**\n * 3. If the attribute is a directive, then we should find a component that is responsible for\n * the directive compiling logic, and call it. \n * In case component is not found we just want to log a warning, \n * since the directive may be handled by some parent component or simply is a mistake in the template.\n */\n if (directive.component) {\n feature.chain(directive.component, AreDirectiveFeatures.Compile, directive.owner.scope);\n } else {\n logger?.warning(`Directive handler component not found for directive: ${directive.name}. Make sure to create a component named \"AreDirective${A_FormatterHelper.toPascalCase(directive.name)}\" to handle this directive.`);\n }\n\n store.unwatch(directive);\n }\n\n\n @AreCompiler.Compile(AreEventAttribute)\n compileEventAttribute(\n @A_Inject(A_Caller) attribute: AreEventAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n /**\n * 2. In case the attribute is an event listener, then \n * we should simply add a callback handler that will be used to proxy an event \n * into the ComponentNode component. \n *[!] In this case AreAttribute is AreEventAttribute that has prepared callback function to be used \n * in the event listener. It is important to store callback function once \n * to prevent duplicated functions in case of multiple compilations during development.\n */\n scene.plan(new AddListenerInstruction(scene.host, {\n name: attribute.name,\n handler: attribute.content\n }));\n }\n\n\n @AreCompiler.Compile(AreBindingAttribute)\n compileBindingAttribute(\n @A_Inject(A_Caller) attribute: AreBindingAttribute,\n @A_Inject(AreScene) scene: AreScene,\n @A_Dependency.Parent()\n @A_Inject(AreStore) parentStore: AreStore,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreSyntax) syntax: AreSyntax,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n\n const node = attribute.owner;\n const props = node.component?.props;\n\n // Component prop names are typically declared in camelCase, while template\n // markup uses kebab-case. Try both forms when matching.\n let propName: string | undefined;\n if (props) {\n if (props[attribute.name]) {\n propName = attribute.name;\n } else {\n const camel = A_FormatterHelper.toCamelCase(attribute.name);\n if (props[camel]) propName = camel;\n }\n }\n\n /**\n * 1. Component prop binding — evaluate against the parent store and\n * keep the child store reactive to upstream changes.\n */\n if (propName && props) {\n const propDefinition = props[propName];\n\n const coerce = (raw: any): any => {\n let value = raw;\n if (propDefinition.type) {\n switch (propDefinition.type) {\n case 'string': value = value === undefined || value === null ? '' : String(value); break;\n case 'number': value = Number(value); break;\n case 'boolean': value = Boolean(value); break;\n }\n }\n return value;\n };\n\n // The watcher entity below is registered against parentStore so that\n // updates to the bound expression in the parent flow into the child store.\n const watcher = {\n update: () => {\n try {\n parentStore.watch(watcher);\n const next = coerce(syntax.evaluate(attribute.content, parentStore));\n parentStore.unwatch(watcher);\n store.set(propName!, next);\n } catch (e) {\n parentStore.unwatch(watcher);\n }\n }\n };\n\n // Initial read with watch active so dependencies are recorded.\n parentStore.watch(watcher);\n const initial = coerce(syntax.evaluate(attribute.content, parentStore));\n parentStore.unwatch(watcher);\n\n store.set(propName, initial);\n return;\n }\n\n /**\n * 2. Default attribute binding — evaluated reactively against the local store.\n */\n const instruction = new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content,\n evaluate: true\n })\n\n scene.plan(instruction);\n }\n\n\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BO,IAAM,eAAA,GAAN,cAA8B,WAAA,CAAY;AAAA,EAS7C,eAAA,CACwB,IAAA,EACA,KAAA,EACA,MAAA,EAAA,GACjB,IAAA,EACC;AACJ,IAAA,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,GAAG,IAAI,CAAA;AAU1C,IAAA,IAAI,IAAA,CAAK,cAAA,IAAkB,KAAA,CAAM,IAAA,EAAM;AACnC,MAAA,KAAA,CAAM,IAAA,CAAK,IAAI,wBAAA,CAAyB,KAAA,CAAM,IAAA,EAAM,EAAE,IAAA,EAAM,IAAA,CAAK,eAAA,EAAkB,CAAC,CAAA;AAAA,IACxF;AAEA,IAAA,IAAI,IAAA,CAAK,QAAQ,MAAA,EAAQ;AACrB,MAAA,MAAM,OAAO,KAAA,CAAM,IAAA;AACnB,MAAA,IAAI,IAAA,EAAM;AACN,QAAA,KAAA,CAAM,IAAA,CAAK,IAAI,mBAAA,CAAoB,IAAA,EAAM,EAAE,QAAQ,IAAA,CAAK,MAAA,CAAO,MAAA,EAAQ,CAAC,CAAA;AAAA,MAC5E;AAAA,IACJ;AAAA,EACJ;AAAA,EAeA,oBAAA,CACwB,aAAA,EACA,KAAA,EAEA,KAAA,EACA,WACjB,IAAA,EACL;AAeE,IAAA,KAAA,CAAM,IAAA,CAA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AAA,EApKb,eAAA,CAkKT,SAAA,EAAA,uBAAA,EAAA,CAAA,CAAA;AA2BA,eAAA,CAAA;AAAA,EADC,WAAA,CAAY,QAAQ,mBAAmB,CAAA;AAAA,EAEnC,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,gCAAa,MAAA,EAAO,CAAA;AAAA,EACpB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,mBAAmB,CAAA;AAAA,CAAA,EApMxB,eAAA,CA6LT,SAAA,EAAA,yBAAA,EAAA,CAAA,CAAA;AA7LS,eAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,eAAA,CAAA","file":"AreHTML.compiler.mjs","sourcesContent":["import { A_Caller, A_Dependency, A_Feature, A_FormatterHelper, A_Inject } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AddAttributeInstruction} from \"@adaas/are-html/instructions/AddAttribute.instruction\";\nimport { AddTextInstruction} from \"@adaas/are-html/instructions/AddText.instruction\";\nimport { AddListenerInstruction} from \"@adaas/are-html/instructions/AddListener.instruction\";\nimport { AddStyleInstruction } from \"@adaas/are-html/instructions/AddStyle.instruction\";\nimport { AddStaticHTMLInstruction } from \"@adaas/are-html/instructions/AddStaticHTML.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\nimport { AreDirectiveContext } from \"@adaas/are-html/directive/AreDirective.context\";\n\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'HTML-specific compiler for A-Concept Rendering Engine (ARE) components, extending the base AreCompiler to handle HTML templates, styles, and rendering logic tailored for web environments.'\n})\nexport class AreHTMLCompiler extends AreCompiler {\n\n /**\n * Extends the base compile for all AreHTMLNode instances (elements, components, root nodes).\n * After the standard element/attribute/children instructions are emitted, checks whether\n * the node has a registered AreStyle and plans an AddStyleInstruction so the interpreter\n * can inject the CSS into the document head during mount.\n */\n @AreCompiler.Compile(AreHTMLNode)\n compileHTMLNode(\n @A_Inject(A_Caller) node: AreHTMLNode,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ): void {\n super.compile(node, scene, logger, ...args);\n\n /**\n * Static-island materialisation. When the tokenizer flagged this node as\n * a static island its inner subtree was never exploded into child nodes,\n * so there is nothing for the base compiler to walk. Emit a single\n * AddStaticHTML instruction carrying the captured inner markup; the\n * interpreter injects it onto the host element in one pass (and decodes\n * HTML entities for free).\n */\n if (node.isStaticIsland && scene.host) {\n scene.plan(new AddStaticHTMLInstruction(scene.host, { html: node.staticInnerHTML! }));\n }\n\n if (node.styles?.styles) {\n const host = scene.host;\n if (host) {\n scene.plan(new AddStyleInstruction(host, { styles: node.styles.styles }));\n }\n }\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Interpolation Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n /**\n * Default compile method for interpolations, which can be overridden by specific implementations if needed.\n * \n * @param interpolation \n * @param scope \n * @param scene \n * @param store \n * @param feature \n */\n @AreCompiler.Compile(AreInterpolation)\n compileInterpolation(\n @A_Inject(A_Caller) interpolation: AreInterpolation,\n @A_Inject(AreScene) scene: AreScene,\n\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n // if (scene.host)\n // console.log('Scene Host: ', scene.host);\n\n // let content = '';\n\n // logger?.debug('green', `AreHTMLCompiler: compile interpolation <${interpolation.aseid.toString()}> with key: \"${interpolation.content}\"`, store.get(interpolation.content));\n\n // try {\n // content = AreCommonHelper.evaluate(interpolation.content, store);\n\n // } catch (error) {\n // content = ''\n // }\n\n scene.plan(new AddTextInstruction({ content: interpolation.content, evaluate: true }));\n }\n\n // -----------------------------------------------------------------------------------------\n // ------------------------------Are-Text Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n @AreCompiler.Compile(AreText)\n compileText(\n @A_Inject(A_Caller) text: AreText,\n @A_Inject(AreScene) scene: AreScene,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.debug('cyan', `AreHTMLCompiler: compile text node <${text.aseid.toString()}> with content: \"${text.content}\"`);\n if (scene.host)\n scene.unPlan(scene.host);\n\n scene.plan(new AddTextInstruction({ content: text.content }));\n\n }\n\n // -----------------------------------------------------------------------------------------\n // -------------------------Are-Attribute Compile Section-----------------------------------\n // -----------------------------------------------------------------------------------------\n\n @AreCompiler.Compile(AreStaticAttribute)\n compileStaticAttribute(\n @A_Inject(A_Caller) attribute: AreStaticAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n const content = attribute.content;\n\n /**\n * If the attribute value contains {{ }} interpolations, transform them into\n * a JS string-concatenation expression so the interpreter can evaluate them.\n * e.g. \"color:{{expr}}\" → '\"color:\"+(expr)+\"\"'\n */\n if (content.includes('{{')) {\n const transformed = '\"' + content.replace(/\\{\\{([^}]+)\\}\\}/g, '\"+($1)+\"') + '\"';\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: transformed,\n evaluate: true,\n }));\n return;\n }\n\n /**\n * Default case: regular static attribute rendered as-is.\n */\n scene.plan(new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content\n }));\n }\n\n @AreCompiler.Compile(AreDirectiveAttribute)\n compileDirectiveAttribute(\n @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(A_Feature) feature: A_Feature,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n store.watch(directive);\n\n /**\n * 3. If the attribute is a directive, then we should find a component that is responsible for\n * the directive compiling logic, and call it. \n * In case component is not found we just want to log a warning, \n * since the directive may be handled by some parent component or simply is a mistake in the template.\n */\n if (directive.component) {\n feature.chain(directive.component, AreDirectiveFeatures.Compile, directive.owner.scope);\n } else {\n logger?.warning(`Directive handler component not found for directive: ${directive.name}. Make sure to create a component named \"AreDirective${A_FormatterHelper.toPascalCase(directive.name)}\" to handle this directive.`);\n }\n\n store.unwatch(directive);\n }\n\n\n @AreCompiler.Compile(AreEventAttribute)\n compileEventAttribute(\n @A_Inject(A_Caller) attribute: AreEventAttribute,\n @A_Inject(AreScene) scene: AreScene,\n ...args: any[]\n ) {\n\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n /**\n * 2. In case the attribute is an event listener, then \n * we should simply add a callback handler that will be used to proxy an event \n * into the ComponentNode component. \n *[!] In this case AreAttribute is AreEventAttribute that has prepared callback function to be used \n * in the event listener. It is important to store callback function once \n * to prevent duplicated functions in case of multiple compilations during development.\n */\n scene.plan(new AddListenerInstruction(scene.host, {\n name: attribute.name,\n handler: attribute.content\n }));\n }\n\n\n @AreCompiler.Compile(AreBindingAttribute)\n compileBindingAttribute(\n @A_Inject(A_Caller) attribute: AreBindingAttribute,\n @A_Inject(AreScene) scene: AreScene,\n @A_Dependency.Parent()\n @A_Inject(AreStore) parentStore: AreStore,\n @A_Inject(AreStore) store: AreStore,\n @A_Inject(AreSyntax) syntax: AreSyntax,\n @A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,\n ...args: any[]\n ) {\n if (!scene.host)\n throw new AreCompilerError({\n title: 'Scene Host Not Found',\n description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n });\n\n\n const node = attribute.owner;\n const props = node.component?.props;\n\n // Component prop names are typically declared in camelCase, while template\n // markup uses kebab-case. Try both forms when matching.\n let propName: string | undefined;\n if (props) {\n if (props[attribute.name]) {\n propName = attribute.name;\n } else {\n const camel = A_FormatterHelper.toCamelCase(attribute.name);\n if (props[camel]) propName = camel;\n }\n }\n\n /**\n * 1. Component prop binding — evaluate against the parent store and\n * keep the child store reactive to upstream changes.\n */\n if (propName && props) {\n const propDefinition = props[propName];\n\n const coerce = (raw: any): any => {\n let value = raw;\n if (propDefinition.type) {\n switch (propDefinition.type) {\n case 'string': value = value === undefined || value === null ? '' : String(value); break;\n case 'number': value = Number(value); break;\n case 'boolean': value = Boolean(value); break;\n }\n }\n return value;\n };\n\n // Item-scoped variables from an enclosing directive (the `item`/`index`\n // of a `$for`, or any scope a `$if` merged in) so a prop binding like\n // `:title=\"item.name\"` resolves the loop variable — checked BEFORE the\n // store, exactly like plain attribute bindings do in the interpreter.\n // Read `.scope` lazily inside each evaluation so keyed `$for` updates\n // that reassign the context's scope are always reflected.\n const directiveScope = () => directiveContext?.scope ?? {};\n\n // The watcher entity below is registered against parentStore so that\n // updates to the bound expression in the parent flow into the child store.\n const watcher = {\n update: () => {\n try {\n parentStore.watch(watcher);\n const next = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));\n parentStore.unwatch(watcher);\n store.set(propName!, next);\n } catch (e) {\n parentStore.unwatch(watcher);\n }\n }\n };\n\n // Initial read with watch active so dependencies are recorded.\n parentStore.watch(watcher);\n const initial = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));\n parentStore.unwatch(watcher);\n\n store.set(propName, initial);\n return;\n }\n\n /**\n * 2. Default attribute binding — evaluated reactively against the local store.\n */\n const instruction = new AddAttributeInstruction(scene.host, {\n name: attribute.name,\n content: attribute.content,\n evaluate: true\n })\n\n scene.plan(instruction);\n }\n\n\n}"]}
|