@adaas/are-html 0.0.12 → 0.0.14
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 +19 -4
- package/dist/browser/index.mjs +114 -7
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/{AreBinding.attribute-C6JasbJL.d.ts → AreBinding.attribute-Bm5LlOyE.d.ts} +7 -0
- package/dist/node/{AreBinding.attribute-C6qrxN8K.d.mts → AreBinding.attribute-doUvtOjc.d.mts} +7 -0
- package/dist/node/attributes/AreBinding.attribute.d.mts +1 -1
- package/dist/node/attributes/AreBinding.attribute.d.ts +1 -1
- package/dist/node/attributes/AreDirective.attribute.d.mts +1 -1
- package/dist/node/attributes/AreDirective.attribute.d.ts +1 -1
- package/dist/node/attributes/AreEvent.attribute.d.mts +1 -1
- package/dist/node/attributes/AreEvent.attribute.d.ts +1 -1
- package/dist/node/attributes/AreStatic.attribute.d.mts +1 -1
- package/dist/node/attributes/AreStatic.attribute.d.ts +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.d.mts +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.d.ts +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.mts +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.ts +1 -1
- package/dist/node/engine/AreHTML.compiler.d.mts +8 -1
- package/dist/node/engine/AreHTML.compiler.d.ts +8 -1
- package/dist/node/engine/AreHTML.compiler.js +17 -0
- package/dist/node/engine/AreHTML.compiler.js.map +1 -1
- package/dist/node/engine/AreHTML.compiler.mjs +17 -0
- package/dist/node/engine/AreHTML.compiler.mjs.map +1 -1
- package/dist/node/engine/AreHTML.context.js +2 -2
- package/dist/node/engine/AreHTML.context.js.map +1 -1
- package/dist/node/engine/AreHTML.context.mjs +3 -3
- package/dist/node/engine/AreHTML.context.mjs.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.d.mts +3 -0
- package/dist/node/engine/AreHTML.interpreter.d.ts +3 -0
- package/dist/node/engine/AreHTML.interpreter.js +44 -0
- package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.mjs +44 -0
- package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.d.mts +2 -1
- package/dist/node/engine/AreHTML.lifecycle.d.ts +2 -1
- package/dist/node/engine/AreHTML.lifecycle.js +13 -1
- package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.mjs +13 -1
- package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
- package/dist/node/engine/AreHTML.tokenizer.d.mts +1 -1
- package/dist/node/engine/AreHTML.tokenizer.d.ts +1 -1
- package/dist/node/engine/AreHTML.transformer.d.mts +1 -1
- package/dist/node/engine/AreHTML.transformer.d.ts +1 -1
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/instructions/AreHTML.instructions.types.d.mts +2 -4
- package/dist/node/instructions/AreHTML.instructions.types.d.ts +2 -4
- package/dist/node/lib/AreDirective/AreDirective.component.d.mts +1 -1
- package/dist/node/lib/AreDirective/AreDirective.component.d.ts +1 -1
- package/dist/node/lib/AreDirective/AreDirective.types.d.mts +1 -1
- package/dist/node/lib/AreDirective/AreDirective.types.d.ts +1 -1
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.d.mts +1 -1
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.d.ts +1 -1
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.d.mts +1 -1
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.d.ts +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.d.mts +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.d.ts +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.js +14 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.js.map +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs +14 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs.map +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.js +26 -3
- package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.mjs +26 -3
- package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
- package/dist/node/nodes/AreComment.d.mts +1 -1
- package/dist/node/nodes/AreComment.d.ts +1 -1
- package/dist/node/nodes/AreComponent.d.mts +1 -1
- package/dist/node/nodes/AreComponent.d.ts +1 -1
- package/dist/node/nodes/AreInterpolation.d.mts +1 -1
- package/dist/node/nodes/AreInterpolation.d.ts +1 -1
- package/dist/node/nodes/AreRoot.d.mts +1 -1
- package/dist/node/nodes/AreRoot.d.ts +1 -1
- package/dist/node/nodes/AreText.d.mts +1 -1
- package/dist/node/nodes/AreText.d.ts +1 -1
- package/examples/component-styles/concept.ts +41 -0
- package/examples/component-styles/containers/UI.container.ts +122 -0
- package/examples/component-styles/dist/index.html +25 -0
- package/examples/{jumpstart/dist/mor90p6y-0plg7g.js → component-styles/dist/mpq29j47-owas2v.js} +8326 -5942
- package/examples/component-styles/public/index.html +25 -0
- package/examples/component-styles/src/components/AppPage.component.ts +74 -0
- package/examples/component-styles/src/components/TheAlert.component.ts +81 -0
- package/examples/component-styles/src/components/TheButton.component.ts +71 -0
- package/examples/component-styles/src/components/TheCard.component.ts +64 -0
- package/examples/component-styles/src/concept.ts +70 -0
- package/examples/dashboard/dist/index.html +1 -1
- package/examples/dashboard/dist/{mpmt0gys-1r9rcu.js → mppzjw80-9gwa4h.js} +1223 -863
- package/examples/jumpstart/dist/index.html +1 -1
- package/examples/jumpstart/dist/{mor90p7p-1898bz.js → mppwx932-xbmb0x.js} +4215 -1984
- package/examples/signal-routing/concept.ts +41 -0
- package/examples/signal-routing/containers/UI.container.ts +126 -0
- package/examples/signal-routing/dist/index.html +18 -0
- package/examples/signal-routing/dist/mpq6u1wz-2pkqe2.js +14002 -0
- package/examples/signal-routing/public/index.html +18 -0
- package/examples/signal-routing/src/components/AboutPage.component.ts +74 -0
- package/examples/signal-routing/src/components/AppShell.component.ts +42 -0
- package/examples/signal-routing/src/components/HomePage.component.ts +76 -0
- package/examples/signal-routing/src/components/NavBar.component.ts +104 -0
- package/examples/signal-routing/src/components/SettingsPage.component.ts +98 -0
- package/examples/signal-routing/src/concept.ts +114 -0
- package/package.json +7 -5
- package/src/engine/AreHTML.compiler.ts +24 -7
- package/src/engine/AreHTML.context.ts +6 -4
- package/src/engine/AreHTML.interpreter.ts +54 -0
- package/src/engine/AreHTML.lifecycle.ts +16 -12
- package/src/instructions/AreHTML.instructions.types.ts +2 -4
- package/src/lib/AreHTMLNode/AreHTMLNode.ts +15 -0
- package/src/lib/AreRoot/AreRoot.component.ts +47 -7
|
@@ -70,6 +70,20 @@ exports.AreHTMLNode = class AreHTMLNode extends are.AreNode {
|
|
|
70
70
|
get styles() {
|
|
71
71
|
return this.scope.resolveFlat(AreStyle_context.AreStyle);
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Registers or updates the component-scoped CSS string for this node.
|
|
75
|
+
* Called by the @Are.Styles-decorated method on the associated component.
|
|
76
|
+
* A new AreStyle fragment is registered in scope on first call; subsequent
|
|
77
|
+
* calls update the existing fragment in-place.
|
|
78
|
+
*/
|
|
79
|
+
setStyles(css) {
|
|
80
|
+
const existing = this.scope.resolveFlat(AreStyle_context.AreStyle);
|
|
81
|
+
if (existing) {
|
|
82
|
+
existing.styles = css;
|
|
83
|
+
} else {
|
|
84
|
+
this.scope.register(new AreStyle_context.AreStyle(css, this.aseid.toString()));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
73
87
|
};
|
|
74
88
|
exports.AreHTMLNode = __decorateClass([
|
|
75
89
|
core.A_Frame.Define({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreHTMLNode/AreHTMLNode.ts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I,MAAA,GAA8B;AAC9B,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAkCC,oCAAiB,CAAA;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,MAAA,GAAmB;AACnB,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,WAAA,CAAsBC,yBAAQ,CAAA;AAAA,EACpD;AAEJ;
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreHTMLNode/AreHTMLNode.ts"],"names":["AreHTMLNode","AreNode","AreStaticAttribute","AreBindingAttribute","AreDirectiveAttribute","A_Context","AreEventAttribute","AreStyle","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBaA,mBAAA,GAAN,0BAA0BC,WAAA,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,IAAI,GAAA,GAAc;AACd,IAAA,OAAO,KAAK,KAAA,CAAM,MAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,gBAAA,GAAyC;AACzC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAmCC,sCAAkB,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,QAAA,GAAkC;AAClC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAoCC,wCAAmB,CAAA;AAAA,EAC7E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,UAAA,GAAsC;AAItC,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,KAAA,CAAM,cAAA,CAAsCC,4CAAqB,CAAA;AAOzF,IAAA,OAAO,UAAA,CAAW,OAAO,CAAA,CAAA,KAAK,CAAA,CAAE,SAAS,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM;AACtD,MAAA,MAAM,KAAA,GAAQC,kBAAA,CAAU,IAAA,CAAqC,CAAA,CAAE,SAAU,CAAA;AACzE,MAAA,MAAM,KAAA,GAAQA,kBAAA,CAAU,IAAA,CAAqC,CAAA,CAAE,SAAU,CAAA;AAEzE,MAAA,MAAM,SAAA,GAAY,MAAM,QAAA,IAAY,CAAA;AACpC,MAAA,MAAM,SAAA,GAAY,MAAM,QAAA,IAAY,CAAA;AAEpC,MAAA,OAAO,SAAA,GAAY,SAAA;AAAA,IACvB,CAAC,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,MAAA,GAA8B;AAC9B,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAkCC,oCAAiB,CAAA;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,MAAA,GAAmB;AACnB,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,WAAA,CAAsBC,yBAAQ,CAAA;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,UAAU,GAAA,EAAmB;AACzB,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,KAAA,CAAM,WAAA,CAAsBA,yBAAQ,CAAA;AAC1D,IAAA,IAAI,QAAA,EAAU;AACV,MAAA,QAAA,CAAS,MAAA,GAAS,GAAA;AAAA,IACtB,CAAA,MAAO;AACH,MAAA,IAAA,CAAK,KAAA,CAAM,SAAS,IAAIA,yBAAA,CAAS,KAAK,IAAA,CAAK,KAAA,CAAM,QAAA,EAAU,CAAC,CAAA;AAAA,IAChE;AAAA,EACJ;AAEJ;AAhFaP,mBAAA,GAAN,eAAA,CAAA;AAAA,EAJNQ,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYR,mBAAA,CAAA","file":"AreHTMLNode.js","sourcesContent":["import { A_Context, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode} from \"@adaas/are\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreStyle } from \"@adaas/are-html/style/AreStyle.context\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AreDirectiveMeta } from \"@adaas/are-html/directive/AreDirective.meta\";\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n 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.'\n})\nexport class AreHTMLNode extends AreNode {\n /**\n * Actual node type. \n * By default it's a tag name\n */\n get tag(): string {\n return this.aseid.entity;\n }\n /**\n * 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.\n * \n * Example: For a node defined as `<div class=\"static-class\">`, the static attribute would be `class=\"static-class\"`.\n */\n get staticAttributes(): AreStaticAttribute[] {\n return this.scope.resolveFlatAll<AreStaticAttribute>(AreStaticAttribute);\n }\n /**\n * 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.\n * \n * Example: For a node defined as `<div :class=\"dynamicClass\">`, the binding attribute would be `:class=\"dynamicClass\"`.\n */\n get bindings(): AreBindingAttribute[] {\n return this.scope.resolveFlatAll<AreBindingAttribute>(AreBindingAttribute);\n }\n /**\n * 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.\n * \n * Example: For a node defined as `<div v-if=\"isVisible\">`, the directive attribute would be `v-if=\"isVisible\"`.\n */\n get directives(): AreDirectiveAttribute[] {\n /**\n * 1. get all registered directives for the node\n */\n const directives = this.scope.resolveFlatAll<AreDirectiveAttribute>(AreDirectiveAttribute)!;\n /**\n * 2. Order them in the way that defined in the meta\n * \n * Each meta has a prioprity of order that may impact the way how directives are compiled and rendered. For example, a directive with higher priority may need to be compiled before other directives to ensure that its logic is applied correctly before other directives are processed. By ordering the directives based on their defined priority in the meta, we can ensure that the compilation and rendering process follows the intended logic and behavior as defined by the directive implementations.\n */\n\n return directives.filter(d => d.component).sort((a, b) => {\n const aMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(a.component!);\n const bMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(b.component!);\n\n const aPriority = aMeta.priority ?? 0;\n const bPriority = bMeta.priority ?? 0;\n\n return bPriority - aPriority;\n });\n }\n /**\n * 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.\n * \n * Example: For a node defined as `<button @click=\"handleClick\">`, the event attribute would be `@click=\"handleClick\"`.\n */\n get events(): AreEventAttribute[] {\n return this.scope.resolveFlatAll<AreEventAttribute>(AreEventAttribute)!;\n }\n /**\n * 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.\n */\n get styles(): AreStyle {\n return this.scope.resolveFlat<AreStyle>(AreStyle)!;\n }\n\n /**\n * Registers or updates the component-scoped CSS string for this node.\n * Called by the @Are.Styles-decorated method on the associated component.\n * A new AreStyle fragment is registered in scope on first call; subsequent\n * calls update the existing fragment in-place.\n */\n setStyles(css: string): void {\n const existing = this.scope.resolveFlat<AreStyle>(AreStyle);\n if (existing) {\n existing.styles = css;\n } else {\n this.scope.register(new AreStyle(css, this.aseid.toString()));\n }\n }\n\n}"]}
|
|
@@ -61,6 +61,20 @@ let AreHTMLNode = class extends AreNode {
|
|
|
61
61
|
get styles() {
|
|
62
62
|
return this.scope.resolveFlat(AreStyle);
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Registers or updates the component-scoped CSS string for this node.
|
|
66
|
+
* Called by the @Are.Styles-decorated method on the associated component.
|
|
67
|
+
* A new AreStyle fragment is registered in scope on first call; subsequent
|
|
68
|
+
* calls update the existing fragment in-place.
|
|
69
|
+
*/
|
|
70
|
+
setStyles(css) {
|
|
71
|
+
const existing = this.scope.resolveFlat(AreStyle);
|
|
72
|
+
if (existing) {
|
|
73
|
+
existing.styles = css;
|
|
74
|
+
} else {
|
|
75
|
+
this.scope.register(new AreStyle(css, this.aseid.toString()));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
64
78
|
};
|
|
65
79
|
AreHTMLNode = __decorateClass([
|
|
66
80
|
A_Frame.Define({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreHTMLNode/AreHTMLNode.ts"],"names":[],"mappings":";;;;;;;;;;AAiBO,IAAM,WAAA,GAAN,cAA0B,OAAA,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,IAAI,GAAA,GAAc;AACd,IAAA,OAAO,KAAK,KAAA,CAAM,MAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,gBAAA,GAAyC;AACzC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAmC,kBAAkB,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,QAAA,GAAkC;AAClC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAoC,mBAAmB,CAAA;AAAA,EAC7E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,UAAA,GAAsC;AAItC,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,KAAA,CAAM,cAAA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AA,CAAM,SAAS,IAAI,QAAA,CAAS,KAAK,IAAA,CAAK,KAAA,CAAM,QAAA,EAAU,CAAC,CAAA;AAAA,IAChE;AAAA,EACJ;AAEJ;AAhFa,WAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,WAAA,CAAA","file":"AreHTMLNode.mjs","sourcesContent":["import { A_Context, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode} from \"@adaas/are\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreStyle } from \"@adaas/are-html/style/AreStyle.context\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AreDirectiveMeta } from \"@adaas/are-html/directive/AreDirective.meta\";\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n 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.'\n})\nexport class AreHTMLNode extends AreNode {\n /**\n * Actual node type. \n * By default it's a tag name\n */\n get tag(): string {\n return this.aseid.entity;\n }\n /**\n * 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.\n * \n * Example: For a node defined as `<div class=\"static-class\">`, the static attribute would be `class=\"static-class\"`.\n */\n get staticAttributes(): AreStaticAttribute[] {\n return this.scope.resolveFlatAll<AreStaticAttribute>(AreStaticAttribute);\n }\n /**\n * 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.\n * \n * Example: For a node defined as `<div :class=\"dynamicClass\">`, the binding attribute would be `:class=\"dynamicClass\"`.\n */\n get bindings(): AreBindingAttribute[] {\n return this.scope.resolveFlatAll<AreBindingAttribute>(AreBindingAttribute);\n }\n /**\n * 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.\n * \n * Example: For a node defined as `<div v-if=\"isVisible\">`, the directive attribute would be `v-if=\"isVisible\"`.\n */\n get directives(): AreDirectiveAttribute[] {\n /**\n * 1. get all registered directives for the node\n */\n const directives = this.scope.resolveFlatAll<AreDirectiveAttribute>(AreDirectiveAttribute)!;\n /**\n * 2. Order them in the way that defined in the meta\n * \n * Each meta has a prioprity of order that may impact the way how directives are compiled and rendered. For example, a directive with higher priority may need to be compiled before other directives to ensure that its logic is applied correctly before other directives are processed. By ordering the directives based on their defined priority in the meta, we can ensure that the compilation and rendering process follows the intended logic and behavior as defined by the directive implementations.\n */\n\n return directives.filter(d => d.component).sort((a, b) => {\n const aMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(a.component!);\n const bMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(b.component!);\n\n const aPriority = aMeta.priority ?? 0;\n const bPriority = bMeta.priority ?? 0;\n\n return bPriority - aPriority;\n });\n }\n /**\n * 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.\n * \n * Example: For a node defined as `<button @click=\"handleClick\">`, the event attribute would be `@click=\"handleClick\"`.\n */\n get events(): AreEventAttribute[] {\n return this.scope.resolveFlatAll<AreEventAttribute>(AreEventAttribute)!;\n }\n /**\n * 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.\n */\n get styles(): AreStyle {\n return this.scope.resolveFlat<AreStyle>(AreStyle)!;\n }\n\n /**\n * Registers or updates the component-scoped CSS string for this node.\n * Called by the @Are.Styles-decorated method on the associated component.\n * A new AreStyle fragment is registered in scope on first call; subsequent\n * calls update the existing fragment in-place.\n */\n setStyles(css: string): void {\n const existing = this.scope.resolveFlat<AreStyle>(AreStyle);\n if (existing) {\n existing.styles = css;\n } else {\n this.scope.register(new AreStyle(css, this.aseid.toString()));\n }\n }\n\n}"]}
|
|
@@ -5,6 +5,7 @@ var core = require('@adaas/a-frame/core');
|
|
|
5
5
|
var aLogger = require('@adaas/a-utils/a-logger');
|
|
6
6
|
var aSignal = require('@adaas/a-utils/a-signal');
|
|
7
7
|
var are = require('@adaas/are');
|
|
8
|
+
var AreRoute_signal = require('@adaas/are-html/signals/AreRoute.signal');
|
|
8
9
|
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
10
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -30,9 +31,16 @@ exports.AreRoot = class AreRoot extends are.Are {
|
|
|
30
31
|
async template(root, logger, signalsContext) {
|
|
31
32
|
const rootId = root.id;
|
|
32
33
|
if (signalsContext && !signalsContext.hasRoot(rootId)) {
|
|
34
|
+
if (!root.content?.trim()) {
|
|
35
|
+
const defaultMatch = root.markup?.match(/\bdefault=["']([^"']*)["']/);
|
|
36
|
+
const defaultComponent = defaultMatch?.[1];
|
|
37
|
+
if (defaultComponent) {
|
|
38
|
+
root.setContent(`<${defaultComponent}></${defaultComponent}>`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
33
41
|
return;
|
|
34
42
|
}
|
|
35
|
-
const currentRoute =
|
|
43
|
+
const currentRoute = AreRoute_signal.AreRoute.default();
|
|
36
44
|
let componentName;
|
|
37
45
|
if (currentRoute) {
|
|
38
46
|
const initialVector = new aSignal.A_SignalVector([currentRoute]);
|
|
@@ -45,12 +53,23 @@ exports.AreRoot = class AreRoot extends are.Are {
|
|
|
45
53
|
componentName = aConcept.A_FormatterHelper.toKebabCase(renderTarget.name);
|
|
46
54
|
}
|
|
47
55
|
}
|
|
56
|
+
if (!componentName) {
|
|
57
|
+
if (root.content?.trim()) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!componentName) {
|
|
62
|
+
const defaultComp = signalsContext?.getDefault(rootId);
|
|
63
|
+
if (defaultComp?.name) {
|
|
64
|
+
componentName = aConcept.A_FormatterHelper.toKebabCase(defaultComp.name);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
48
67
|
if (!componentName) {
|
|
49
68
|
const defaultMatch = root.markup?.match(/\bdefault=["']([^"']*)["']/);
|
|
50
69
|
componentName = defaultMatch?.[1];
|
|
51
70
|
}
|
|
52
71
|
if (!componentName) {
|
|
53
|
-
logger.warning('AreRoot: No component found for initial render.
|
|
72
|
+
logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a "default" attribute.');
|
|
54
73
|
return;
|
|
55
74
|
}
|
|
56
75
|
root.setContent(`<${componentName}></${componentName}>`);
|
|
@@ -67,12 +86,16 @@ exports.AreRoot = class AreRoot extends are.Are {
|
|
|
67
86
|
}
|
|
68
87
|
const componentName = renderTarget?.name ? aConcept.A_FormatterHelper.toKebabCase(renderTarget.name) : store.get("default");
|
|
69
88
|
if (!componentName) {
|
|
70
|
-
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const currentChild = root.children[0];
|
|
92
|
+
if (currentChild?.type === componentName) {
|
|
71
93
|
return;
|
|
72
94
|
}
|
|
73
95
|
root.setContent(`<${componentName}></${componentName}>`);
|
|
74
96
|
for (let i = 0; i < root.children.length; i++) {
|
|
75
97
|
const child = root.children[i];
|
|
98
|
+
signalsContext?.unsubscribe(child);
|
|
76
99
|
child.unmount();
|
|
77
100
|
child.destroy();
|
|
78
101
|
root.removeChild(child);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":["AreRoot","Are","AreRoute","A_SignalVector","A_Context","AreSignals","A_FormatterHelper","A_Caller","A_Logger","AreSignalsContext","AreStore","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;AAWaA,eAAA,GAAN,sBAAsBC,OAAA,CAAI;AAAA,EAA1B,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAEH,IAAA,IAAA,CAAA,KAAA,GAA2C;AAAA,MACvC,OAAA,EAAS;AAAA,QACL,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS;AAAA;AACb,KACJ;AAAA,EAAA;AAAA,EAIA,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,cAAA,EAC/B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAGpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,YAAA,GAAeC,aAAS,OAAA,EAAQ;AAEtC,IAAA,IAAI,aAAA;AAEJ,IAAA,IAAI,YAAA,EAAc;AACd,MAAA,MAAM,aAAA,GAAgB,IAAIC,sBAAA,CAAe,CAAC,YAAY,CAAC,CAAA;AAGvD,MAAA,IAAI,YAAA,GAAe,cAAA,EAAgB,qBAAA,CAAsB,MAAA,EAAQ,aAAa,CAAA;AAG9E,MAAA,IAAI,CAAC,YAAA,EAAc;AACf,QAAA,MAAM,WAAA,GAAcC,kBAAA,CAAU,IAAA,CAAqBC,cAAU,CAAA;AAC7D,QAAA,YAAA,GAAe,WAAA,EAAa,sBAAsB,aAAa,CAAA;AAAA,MACnE;AAEA,MAAA,IAAI,cAAc,IAAA,EAAM;AACpB,QAAA,aAAA,GAAgBC,0BAAA,CAAkB,WAAA,CAAY,YAAA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A,EACvB,qCAASO,YAAQ,CAAA,CAAA;AAAA,EACjB,qCAASF,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA;AAAA,CAAA,EApEtBT,eAAA,CA+DH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AA/DGA,eAAA,GAAN,eAAA,CAAA;AAAA,EAJNW,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYX,eAAA,CAAA","file":"AreRoot.component.js","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, ArePropDefinition, AreStore, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext, AreRoute } from \"@adaas/are\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n 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.'\n})\nexport class AreRoot extends Are {\n\n props: Record<string, ArePropDefinition> = {\n default: {\n type: 'string',\n default: '',\n }\n }\n\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — leave the existing template content intact\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n const currentRoute = AreRoute.default();\n\n let componentName: string | undefined;\n\n if (currentRoute) {\n const initialVector = new A_SignalVector([currentRoute]);\n\n // 1. Lookup via AreSignalsContext (per root-id conditions)\n let renderTarget = signalsContext?.findComponentByVector(rootId, initialVector);\n\n // 2. Fall back to global AreSignalsMeta\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n renderTarget = signalsMeta?.findComponentByVector(initialVector);\n }\n\n if (renderTarget?.name) {\n componentName = A_FormatterHelper.toKebabCase(renderTarget.name);\n }\n }\n\n // 3. Fall back to the 'default' attribute on the node directly.\n // Note: root.attributes is NOT populated at this stage because tokenize()\n // runs after template() in the lifecycle. Read from raw markup instead.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Please ensure a route condition or \"default\" attribute is set.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(AreStore) store: AreStore<{ default: string }>,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n const rootId = root.id;\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // 1. Try root-specific lookup via AreSignalsContext (keyed by the are-root's id attribute)\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Fall back to global AreSignalsMeta lookup\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n renderTarget = signalsMeta?.findComponentByVector(vector);\n }\n\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : store.get('default');\n\n if (!componentName) {\n 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.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.unmount();\n child.destroy();\n root.removeChild(child);\n }\n\n\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n child.mount();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":["AreRoot","Are","AreRoute","A_SignalVector","A_Context","AreSignals","A_FormatterHelper","A_Caller","A_Logger","AreSignalsContext","AreStore","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;AAYaA,eAAA,GAAN,sBAAsBC,OAAA,CAAI;AAAA,EAA1B,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAEH,IAAA,IAAA,CAAA,KAAA,GAA2C;AAAA,MACvC,OAAA,EAAS;AAAA,QACL,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS;AAAA;AACb,KACJ;AAAA,EAAA;AAAA,EAIA,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,cAAA,EAC/B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAIpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,EAAS,IAAA,EAAK,EAAG;AAEvB,QAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,EAAQ,KAAA,CAAM,4BAA4B,CAAA;AACpE,QAAA,MAAM,gBAAA,GAAmB,eAAe,CAAC,CAAA;AACzC,QAAA,IAAI,gBAAA,EAAkB;AAClB,UAAA,IAAA,CAAK,UAAA,CAAW,CAAA,CAAA,EAAI,gBAAgB,CAAA,GAAA,EAAM,gBAAgB,CAAA,CAAA,CAAG,CAAA;AAAA,QACjE;AAAA,MACJ;AAEA,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,YAAA,GAAeC,yBAAS,OAAA,EAAQ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AAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYX,eAAA,CAAA","file":"AreRoot.component.js","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, ArePropDefinition, AreStore, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext } from \"@adaas/are\";\nimport { AreRoute } from \"@adaas/are-html/signals/AreRoute.signal\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n 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.'\n})\nexport class AreRoot extends Are {\n\n props: Record<string, ArePropDefinition> = {\n default: {\n type: 'string',\n default: '',\n }\n }\n\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — but still honour body content or\n // a 'default' attribute if one is present on the markup.\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n if (!root.content?.trim()) {\n // Fallback: legacy default= attribute\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n const defaultComponent = defaultMatch?.[1];\n if (defaultComponent) {\n root.setContent(`<${defaultComponent}></${defaultComponent}>`);\n }\n }\n // Body content (or none) — tokenizer picks it up without intervention\n return;\n }\n\n const currentRoute = AreRoute.default();\n\n let componentName: string | undefined;\n\n if (currentRoute) {\n const initialVector = new A_SignalVector([currentRoute]);\n\n // 1. Lookup via AreSignalsContext (per root-id conditions)\n let renderTarget = signalsContext?.findComponentByVector(rootId, initialVector);\n\n // 2. Fall back to global AreSignalsMeta\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n renderTarget = signalsMeta?.findComponentByVector(initialVector);\n }\n\n if (renderTarget?.name) {\n componentName = A_FormatterHelper.toKebabCase(renderTarget.name);\n }\n }\n\n // 3. Fall back to body content (the nodes already placed inside the\n // <are-root> tag act as the default). No setContent() call needed —\n // the tokenizer will process root.content as-is.\n if (!componentName) {\n if (root.content?.trim()) {\n return;\n }\n }\n // 3.5. Fall back to AreSignalsContext default component for this root.\n if (!componentName) {\n const defaultComp = signalsContext?.getDefault(rootId);\n if (defaultComp?.name) {\n componentName = A_FormatterHelper.toKebabCase(defaultComp.name);\n }\n }\n // 4. Last resort: legacy default= attribute on the markup.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a \"default\" attribute.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(AreStore) store: AreStore<{ default: string }>,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n const rootId = root.id;\n\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // 1. Try root-specific lookup via AreSignalsContext (keyed by the are-root's id attribute)\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Fall back to global AreSignalsMeta lookup\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n renderTarget = signalsMeta?.findComponentByVector(vector);\n }\n\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : store.get('default');\n\n // No matching condition for this signal vector (e.g. AreInit before any route).\n // Keep the current outlet content and do nothing.\n if (!componentName) {\n return;\n }\n\n // Guard: if the outlet already shows the same component, do nothing.\n // Prevents infinite remount loops when a non-routing signal carries a\n // stale routing signal in the accumulated A_SignalState vector.\n // node.type is the kebab-case tag name — the most direct and reliable\n // identifier (no constructor-name resolution, no proxy wrapping issues).\n const currentChild = root.children[0] as AreNode | undefined;\n if (currentChild?.type === componentName) {\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n // Unsubscribe old children BEFORE destroying them.\n // Without this, AreSignals.handleSignalVector keeps iterating stale\n // (scope-less) nodes on every subsequent signal and throws an error.\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n signalsContext?.unsubscribe(child);\n child.unmount();\n child.destroy();\n root.removeChild(child);\n }\n\n\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n child.mount();\n }\n }\n}\n"]}
|
|
@@ -3,7 +3,8 @@ import { A_Inject, A_Caller, A_Context, A_FormatterHelper } from '@adaas/a-conce
|
|
|
3
3
|
import { A_Frame } from '@adaas/a-frame/core';
|
|
4
4
|
import { A_Logger } from '@adaas/a-utils/a-logger';
|
|
5
5
|
import { A_SignalVector } from '@adaas/a-utils/a-signal';
|
|
6
|
-
import { Are, AreSignalsContext, AreStore,
|
|
6
|
+
import { Are, AreSignalsContext, AreStore, AreSignals } from '@adaas/are';
|
|
7
|
+
import { AreRoute } from '@adaas/are-html/signals/AreRoute.signal';
|
|
7
8
|
|
|
8
9
|
let AreRoot = class extends Are {
|
|
9
10
|
constructor() {
|
|
@@ -18,6 +19,13 @@ let AreRoot = class extends Are {
|
|
|
18
19
|
async template(root, logger, signalsContext) {
|
|
19
20
|
const rootId = root.id;
|
|
20
21
|
if (signalsContext && !signalsContext.hasRoot(rootId)) {
|
|
22
|
+
if (!root.content?.trim()) {
|
|
23
|
+
const defaultMatch = root.markup?.match(/\bdefault=["']([^"']*)["']/);
|
|
24
|
+
const defaultComponent = defaultMatch?.[1];
|
|
25
|
+
if (defaultComponent) {
|
|
26
|
+
root.setContent(`<${defaultComponent}></${defaultComponent}>`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
21
29
|
return;
|
|
22
30
|
}
|
|
23
31
|
const currentRoute = AreRoute.default();
|
|
@@ -33,12 +41,23 @@ let AreRoot = class extends Are {
|
|
|
33
41
|
componentName = A_FormatterHelper.toKebabCase(renderTarget.name);
|
|
34
42
|
}
|
|
35
43
|
}
|
|
44
|
+
if (!componentName) {
|
|
45
|
+
if (root.content?.trim()) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!componentName) {
|
|
50
|
+
const defaultComp = signalsContext?.getDefault(rootId);
|
|
51
|
+
if (defaultComp?.name) {
|
|
52
|
+
componentName = A_FormatterHelper.toKebabCase(defaultComp.name);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
36
55
|
if (!componentName) {
|
|
37
56
|
const defaultMatch = root.markup?.match(/\bdefault=["']([^"']*)["']/);
|
|
38
57
|
componentName = defaultMatch?.[1];
|
|
39
58
|
}
|
|
40
59
|
if (!componentName) {
|
|
41
|
-
logger.warning('AreRoot: No component found for initial render.
|
|
60
|
+
logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a "default" attribute.');
|
|
42
61
|
return;
|
|
43
62
|
}
|
|
44
63
|
root.setContent(`<${componentName}></${componentName}>`);
|
|
@@ -55,12 +74,16 @@ let AreRoot = class extends Are {
|
|
|
55
74
|
}
|
|
56
75
|
const componentName = renderTarget?.name ? A_FormatterHelper.toKebabCase(renderTarget.name) : store.get("default");
|
|
57
76
|
if (!componentName) {
|
|
58
|
-
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const currentChild = root.children[0];
|
|
80
|
+
if (currentChild?.type === componentName) {
|
|
59
81
|
return;
|
|
60
82
|
}
|
|
61
83
|
root.setContent(`<${componentName}></${componentName}>`);
|
|
62
84
|
for (let i = 0; i < root.children.length; i++) {
|
|
63
85
|
const child = root.children[i];
|
|
86
|
+
signalsContext?.unsubscribe(child);
|
|
64
87
|
child.unmount();
|
|
65
88
|
child.destroy();
|
|
66
89
|
root.removeChild(child);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":[],"mappings":";;;;;;;AAWO,IAAM,OAAA,GAAN,cAAsB,GAAA,CAAI;AAAA,EAA1B,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAEH,IAAA,IAAA,CAAA,KAAA,GAA2C;AAAA,MACvC,OAAA,EAAS;AAAA,QACL,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS;AAAA;AACb,KACJ;AAAA,EAAA;AAAA,EAIA,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,cAAA,EAC/B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAGpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,YAAA,GAAe,SAAS,OAAA,EAAQ;AAEtC,IAAA,IAAI,aAAA;AAEJ,IAAA,IAAI,YAAA,EAAc;AACd,MAAA,MAAM,aAAA,GAAgB,IAAI,cAAA,CAAe,CAAC,YAAY,CAAC,CAAA;AAGvD,MAAA,IAAI,YAAA,GAAe,cAAA,EAAgB,qBAAA,CAAsB,MAAA,EAAQ,aAAa,CAAA;AAG9E,MAAA,IAAI,CAAC,YAAA,EAAc;AACf,QAAA,MAAM,WAAA,GAAc,SAAA,CAAU,IAAA,CAAqB,UAAU,CAAA;AAC7D,QAAA,YAAA,GAAe,WAAA,EAAa,sBAAsB,aAAa,CAAA;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AAI,MAAA;AAAA,EAEA,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,cAAc,CAAA,CAAA;AAAA,EACvB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA;AAAA,CAAA,EApEtB,OAAA,CA+DH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AA/DG,OAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,OAAA,CAAA","file":"AreRoot.component.mjs","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, ArePropDefinition, AreStore, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext, AreRoute } from \"@adaas/are\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n 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.'\n})\nexport class AreRoot extends Are {\n\n props: Record<string, ArePropDefinition> = {\n default: {\n type: 'string',\n default: '',\n }\n }\n\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — leave the existing template content intact\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n const currentRoute = AreRoute.default();\n\n let componentName: string | undefined;\n\n if (currentRoute) {\n const initialVector = new A_SignalVector([currentRoute]);\n\n // 1. Lookup via AreSignalsContext (per root-id conditions)\n let renderTarget = signalsContext?.findComponentByVector(rootId, initialVector);\n\n // 2. Fall back to global AreSignalsMeta\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n renderTarget = signalsMeta?.findComponentByVector(initialVector);\n }\n\n if (renderTarget?.name) {\n componentName = A_FormatterHelper.toKebabCase(renderTarget.name);\n }\n }\n\n // 3. Fall back to the 'default' attribute on the node directly.\n // Note: root.attributes is NOT populated at this stage because tokenize()\n // runs after template() in the lifecycle. Read from raw markup instead.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Please ensure a route condition or \"default\" attribute is set.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(AreStore) store: AreStore<{ default: string }>,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n const rootId = root.id;\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // 1. Try root-specific lookup via AreSignalsContext (keyed by the are-root's id attribute)\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Fall back to global AreSignalsMeta lookup\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n renderTarget = signalsMeta?.findComponentByVector(vector);\n }\n\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : store.get('default');\n\n if (!componentName) {\n 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.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.unmount();\n child.destroy();\n root.removeChild(child);\n }\n\n\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n child.mount();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":[],"mappings":";;;;;;;;AAYO,IAAM,OAAA,GAAN,cAAsB,GAAA,CAAI;AAAA,EAA1B,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAEH,IAAA,IAAA,CAAA,KAAA,GAA2C;AAAA,MACvC,OAAA,EAAS;AAAA,QACL,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS;AAAA;AACb,KACJ;AAAA,EAAA;AAAA,EAIA,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,cAAA,EAC/B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAIpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,EAAS,IAAA,EAAK,EAAG;AAEvB,QAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,EAAQ,KAAA,CAAM,4BAA4B,CAAA;AACpE,QAAA,MAAM,gBAAA,GAAmB,eAAe,CAAC,CAAA;AACzC,QAAA,IAAI,gBAAA,EAAkB;AAClB,UAAA,IAAA,CAAK,UAAA,CAAW,CAAA,CAAA,EAAI,gBAAgB,CAAA,GAAA,EAAM,gBAAgB,CAAA,CAAA,CAAG,CAAA;AAAA,QACjE;AAAA,MACJ;AAEA,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,YAAA,GAAe,SAAS,OAAA,EAAQ;AAEtC,IAAA,IAAI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AAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,OAAA,CAAA","file":"AreRoot.component.mjs","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, ArePropDefinition, AreStore, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext } from \"@adaas/are\";\nimport { AreRoute } from \"@adaas/are-html/signals/AreRoute.signal\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n 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.'\n})\nexport class AreRoot extends Are {\n\n props: Record<string, ArePropDefinition> = {\n default: {\n type: 'string',\n default: '',\n }\n }\n\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — but still honour body content or\n // a 'default' attribute if one is present on the markup.\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n if (!root.content?.trim()) {\n // Fallback: legacy default= attribute\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n const defaultComponent = defaultMatch?.[1];\n if (defaultComponent) {\n root.setContent(`<${defaultComponent}></${defaultComponent}>`);\n }\n }\n // Body content (or none) — tokenizer picks it up without intervention\n return;\n }\n\n const currentRoute = AreRoute.default();\n\n let componentName: string | undefined;\n\n if (currentRoute) {\n const initialVector = new A_SignalVector([currentRoute]);\n\n // 1. Lookup via AreSignalsContext (per root-id conditions)\n let renderTarget = signalsContext?.findComponentByVector(rootId, initialVector);\n\n // 2. Fall back to global AreSignalsMeta\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n renderTarget = signalsMeta?.findComponentByVector(initialVector);\n }\n\n if (renderTarget?.name) {\n componentName = A_FormatterHelper.toKebabCase(renderTarget.name);\n }\n }\n\n // 3. Fall back to body content (the nodes already placed inside the\n // <are-root> tag act as the default). No setContent() call needed —\n // the tokenizer will process root.content as-is.\n if (!componentName) {\n if (root.content?.trim()) {\n return;\n }\n }\n // 3.5. Fall back to AreSignalsContext default component for this root.\n if (!componentName) {\n const defaultComp = signalsContext?.getDefault(rootId);\n if (defaultComp?.name) {\n componentName = A_FormatterHelper.toKebabCase(defaultComp.name);\n }\n }\n // 4. Last resort: legacy default= attribute on the markup.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a \"default\" attribute.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(AreStore) store: AreStore<{ default: string }>,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n ) {\n const rootId = root.id;\n\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // 1. Try root-specific lookup via AreSignalsContext (keyed by the are-root's id attribute)\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Fall back to global AreSignalsMeta lookup\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n renderTarget = signalsMeta?.findComponentByVector(vector);\n }\n\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : store.get('default');\n\n // No matching condition for this signal vector (e.g. AreInit before any route).\n // Keep the current outlet content and do nothing.\n if (!componentName) {\n return;\n }\n\n // Guard: if the outlet already shows the same component, do nothing.\n // Prevents infinite remount loops when a non-routing signal carries a\n // stale routing signal in the accumulated A_SignalState vector.\n // node.type is the kebab-case tag name — the most direct and reliable\n // identifier (no constructor-name resolution, no proxy wrapping issues).\n const currentChild = root.children[0] as AreNode | undefined;\n if (currentChild?.type === componentName) {\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n // Unsubscribe old children BEFORE destroying them.\n // Without this, AreSignals.handleSignalVector keeps iterating stale\n // (scope-less) nodes on every subsequent signal and throws an error.\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n signalsContext?.unsubscribe(child);\n child.unmount();\n child.destroy();\n root.removeChild(child);\n }\n\n\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n child.mount();\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AreNodeNewProps } from '@adaas/are';
|
|
2
|
-
import { e as AreHTMLNode } from '../AreBinding.attribute-
|
|
2
|
+
import { e as AreHTMLNode } from '../AreBinding.attribute-doUvtOjc.mjs';
|
|
3
3
|
import '@adaas/a-concept';
|
|
4
4
|
import '../lib/AreStyle/AreStyle.context.mjs';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AreNodeNewProps } from '@adaas/are';
|
|
2
|
-
import { e as AreHTMLNode } from '../AreBinding.attribute-
|
|
2
|
+
import { e as AreHTMLNode } from '../AreBinding.attribute-Bm5LlOyE.js';
|
|
3
3
|
import '@adaas/a-concept';
|
|
4
4
|
import '../lib/AreStyle/AreStyle.context.js';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AreNodeNewProps } from '@adaas/are';
|
|
2
|
-
import { e as AreHTMLNode } from '../AreBinding.attribute-
|
|
2
|
+
import { e as AreHTMLNode } from '../AreBinding.attribute-doUvtOjc.mjs';
|
|
3
3
|
import '@adaas/a-concept';
|
|
4
4
|
import '../lib/AreStyle/AreStyle.context.mjs';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AreNodeNewProps } from '@adaas/are';
|
|
2
|
-
import { e as AreHTMLNode } from '../AreBinding.attribute-
|
|
2
|
+
import { e as AreHTMLNode } from '../AreBinding.attribute-Bm5LlOyE.js';
|
|
3
3
|
import '@adaas/a-concept';
|
|
4
4
|
import '../lib/AreStyle/AreStyle.context.js';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AreNodeNewProps } from '@adaas/are';
|
|
2
|
-
import { e as AreHTMLNode } from '../AreBinding.attribute-
|
|
2
|
+
import { e as AreHTMLNode } from '../AreBinding.attribute-doUvtOjc.mjs';
|
|
3
3
|
import '@adaas/a-concept';
|
|
4
4
|
import '../lib/AreStyle/AreStyle.context.mjs';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AreNodeNewProps } from '@adaas/are';
|
|
2
|
-
import { e as AreHTMLNode } from '../AreBinding.attribute-
|
|
2
|
+
import { e as AreHTMLNode } from '../AreBinding.attribute-Bm5LlOyE.js';
|
|
3
3
|
import '@adaas/a-concept';
|
|
4
4
|
import '../lib/AreStyle/AreStyle.context.js';
|
|
5
5
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { A_Concept, A_Context } from "@adaas/a-concept";
|
|
2
|
+
import { UIContainer } from "./containers/UI.container";
|
|
3
|
+
import { A_Logger } from "@adaas/a-utils/a-logger";
|
|
4
|
+
import { A_Polyfill } from "@adaas/a-utils/a-polyfill";
|
|
5
|
+
import { A_Config, ENVConfigReader } from "@adaas/a-utils/a-config";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
try {
|
|
10
|
+
const Application = new UIContainer({
|
|
11
|
+
name: 'ARE Component Styles',
|
|
12
|
+
components: [
|
|
13
|
+
A_Polyfill,
|
|
14
|
+
ENVConfigReader,
|
|
15
|
+
A_Logger,
|
|
16
|
+
],
|
|
17
|
+
fragments: [
|
|
18
|
+
new A_Config({
|
|
19
|
+
defaults: {
|
|
20
|
+
PORT: 8083,
|
|
21
|
+
CONFIG_VERBOSE: true,
|
|
22
|
+
DEV_MODE: true,
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const concept = new A_Concept({
|
|
29
|
+
name: 'adaas-are-example-component-styles',
|
|
30
|
+
components: [A_Logger, A_Polyfill, ENVConfigReader],
|
|
31
|
+
containers: [Application],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await concept.load();
|
|
35
|
+
await concept.start();
|
|
36
|
+
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const logger = A_Context.root.resolve<A_Logger>(A_Logger)!;
|
|
39
|
+
logger.error(error);
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { A_Concept, A_IdentityHelper, A_Inject } from "@adaas/a-concept";
|
|
2
|
+
import { A_Config } from "@adaas/a-utils/a-config";
|
|
3
|
+
import { A_Logger } from "@adaas/a-utils/a-logger";
|
|
4
|
+
import { A_Service } from "@adaas/a-utils/a-service";
|
|
5
|
+
import { build } from "esbuild";
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import http from "http";
|
|
8
|
+
import path from "path";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export class UIContainer extends A_Service {
|
|
12
|
+
|
|
13
|
+
protected server!: any;
|
|
14
|
+
|
|
15
|
+
@A_Concept.Build()
|
|
16
|
+
async build(
|
|
17
|
+
@A_Inject(A_Logger) logger: A_Logger,
|
|
18
|
+
@A_Inject(A_Config) config: A_Config
|
|
19
|
+
): Promise<void> {
|
|
20
|
+
logger.log('Building Component Styles example...');
|
|
21
|
+
const entryFile = path.resolve(__dirname, "../src/concept.ts");
|
|
22
|
+
const BundleID = A_IdentityHelper.generateTimeId();
|
|
23
|
+
const outFile = path.resolve(__dirname, `../dist/${BundleID}.js`);
|
|
24
|
+
|
|
25
|
+
if (fs.existsSync(path.resolve(__dirname, "../dist"))) {
|
|
26
|
+
fs.rmSync(path.resolve(__dirname, "../dist"), { recursive: true, force: true });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await build({
|
|
30
|
+
entryPoints: [entryFile],
|
|
31
|
+
outfile: outFile,
|
|
32
|
+
bundle: true,
|
|
33
|
+
minify: false,
|
|
34
|
+
keepNames: true,
|
|
35
|
+
sourcemap: false,
|
|
36
|
+
target: "es2020",
|
|
37
|
+
format: "esm",
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
logger.log('green', 'Bundle built successfully.');
|
|
41
|
+
|
|
42
|
+
let indexHtml = await fs.promises.readFile(
|
|
43
|
+
path.resolve(__dirname, "../public/index.html"), 'utf-8'
|
|
44
|
+
);
|
|
45
|
+
indexHtml = indexHtml.replace('{{BUNDLE_ID}}', BundleID);
|
|
46
|
+
await fs.promises.writeFile(path.resolve(__dirname, "../dist/index.html"), indexHtml);
|
|
47
|
+
|
|
48
|
+
const publicDir = path.resolve(__dirname, "../public");
|
|
49
|
+
const distDir = path.resolve(__dirname, "../dist");
|
|
50
|
+
const copyRecursive = async (src: string, dest: string) => {
|
|
51
|
+
const entries = await fs.promises.readdir(src, { withFileTypes: true });
|
|
52
|
+
await fs.promises.mkdir(dest, { recursive: true });
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
const srcPath = path.join(src, entry.name);
|
|
55
|
+
const destPath = path.join(dest, entry.name);
|
|
56
|
+
if (entry.isDirectory()) {
|
|
57
|
+
await copyRecursive(srcPath, destPath);
|
|
58
|
+
} else if (entry.name !== 'index.html') {
|
|
59
|
+
await fs.promises.copyFile(srcPath, destPath);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
await copyRecursive(publicDir, distDir);
|
|
64
|
+
logger.log('green', 'Static assets copied.');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@A_Concept.Load()
|
|
68
|
+
async preLoadBuild(
|
|
69
|
+
@A_Inject(A_Logger) logger: A_Logger,
|
|
70
|
+
@A_Inject(A_Config) config: A_Config
|
|
71
|
+
) {
|
|
72
|
+
await this.build(logger, config);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@A_Concept.Start()
|
|
76
|
+
async startStaticServer(
|
|
77
|
+
@A_Inject(A_Logger) logger: A_Logger,
|
|
78
|
+
@A_Inject(A_Config) config: A_Config
|
|
79
|
+
) {
|
|
80
|
+
this.server = http.createServer(this.serveStaticFiles.bind(this));
|
|
81
|
+
const PORT = config.get('PORT') || 8083;
|
|
82
|
+
this.server.listen(PORT, () => {
|
|
83
|
+
logger.log('green', `Component Styles example running at http://localhost:${PORT}`);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
protected async serveStaticFiles(
|
|
88
|
+
req: http.IncomingMessage,
|
|
89
|
+
res: http.ServerResponse,
|
|
90
|
+
) {
|
|
91
|
+
const url = req.url || '/';
|
|
92
|
+
let filePath = path.join(__dirname, '../dist', url === '/' ? 'index.html' : url);
|
|
93
|
+
|
|
94
|
+
const logger = this.scope.resolve<A_Logger>(A_Logger)!;
|
|
95
|
+
logger.log('blue', `Serving: ${filePath}`);
|
|
96
|
+
|
|
97
|
+
const mimeTypes: Record<string, string> = {
|
|
98
|
+
'.html': 'text/html',
|
|
99
|
+
'.js': 'text/javascript',
|
|
100
|
+
'.css': 'text/css',
|
|
101
|
+
'.json': 'application/json',
|
|
102
|
+
'.png': 'image/png',
|
|
103
|
+
'.svg': 'image/svg+xml',
|
|
104
|
+
};
|
|
105
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
106
|
+
const contentType = mimeTypes[ext] || 'application/octet-stream';
|
|
107
|
+
|
|
108
|
+
if (!fs.existsSync(filePath)) {
|
|
109
|
+
filePath = path.join(__dirname, '../dist', 'index.html');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fs.readFile(filePath, (err, content) => {
|
|
113
|
+
if (err) {
|
|
114
|
+
res.writeHead(500);
|
|
115
|
+
res.end(`Server Error: ${err.code}`, 'utf-8');
|
|
116
|
+
} else {
|
|
117
|
+
res.writeHead(200, { 'Content-Type': contentType });
|
|
118
|
+
res.end(content, 'utf-8');
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|