@adaas/are-html 0.0.2 → 0.0.4
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/README.md +4 -4
- package/dist/browser/index.d.mts +88 -5
- package/dist/browser/index.mjs +542 -176
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/attributes/AreBinding.attribute.js +17 -4
- package/dist/node/attributes/AreBinding.attribute.js.map +1 -1
- package/dist/node/attributes/AreBinding.attribute.mjs +10 -3
- package/dist/node/attributes/AreBinding.attribute.mjs.map +1 -1
- package/dist/node/attributes/AreDirective.attribute.js +17 -4
- package/dist/node/attributes/AreDirective.attribute.js.map +1 -1
- package/dist/node/attributes/AreDirective.attribute.mjs +10 -3
- package/dist/node/attributes/AreDirective.attribute.mjs.map +1 -1
- package/dist/node/attributes/AreEvent.attribute.js +17 -4
- package/dist/node/attributes/AreEvent.attribute.js.map +1 -1
- package/dist/node/attributes/AreEvent.attribute.mjs +10 -3
- package/dist/node/attributes/AreEvent.attribute.mjs.map +1 -1
- package/dist/node/attributes/AreStatic.attribute.js +17 -4
- package/dist/node/attributes/AreStatic.attribute.js.map +1 -1
- package/dist/node/attributes/AreStatic.attribute.mjs +10 -3
- package/dist/node/attributes/AreStatic.attribute.mjs.map +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.d.mts +8 -0
- package/dist/node/directives/AreDirectiveFor.directive.d.ts +8 -0
- package/dist/node/directives/AreDirectiveFor.directive.js +78 -33
- package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.mjs +78 -33
- package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.mts +18 -0
- package/dist/node/directives/AreDirectiveIf.directive.d.ts +18 -0
- package/dist/node/directives/AreDirectiveIf.directive.js +10 -3
- package/dist/node/directives/AreDirectiveIf.directive.js.map +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.mjs +10 -3
- package/dist/node/directives/AreDirectiveIf.directive.mjs.map +1 -1
- package/dist/node/engine/AreHTML.compiler.d.mts +2 -2
- package/dist/node/engine/AreHTML.compiler.d.ts +2 -2
- package/dist/node/engine/AreHTML.compiler.js +57 -29
- package/dist/node/engine/AreHTML.compiler.js.map +1 -1
- package/dist/node/engine/AreHTML.compiler.mjs +58 -30
- package/dist/node/engine/AreHTML.compiler.mjs.map +1 -1
- package/dist/node/engine/AreHTML.constants.d.mts +53 -1
- package/dist/node/engine/AreHTML.constants.d.ts +53 -1
- package/dist/node/engine/AreHTML.constants.js +100 -0
- package/dist/node/engine/AreHTML.constants.js.map +1 -1
- package/dist/node/engine/AreHTML.constants.mjs +93 -0
- package/dist/node/engine/AreHTML.constants.mjs.map +1 -1
- package/dist/node/engine/AreHTML.context.d.mts +6 -2
- package/dist/node/engine/AreHTML.context.d.ts +6 -2
- package/dist/node/engine/AreHTML.context.js +42 -7
- package/dist/node/engine/AreHTML.context.js.map +1 -1
- package/dist/node/engine/AreHTML.context.mjs +35 -6
- package/dist/node/engine/AreHTML.context.mjs.map +1 -1
- package/dist/node/engine/AreHTML.engine.js +10 -7
- package/dist/node/engine/AreHTML.engine.js.map +1 -1
- package/dist/node/engine/AreHTML.engine.mjs +10 -7
- package/dist/node/engine/AreHTML.engine.mjs.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.js +155 -43
- package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.mjs +155 -43
- package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.js +17 -12
- package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.mjs +9 -2
- package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
- package/dist/node/engine/AreHTML.tokenizer.js +14 -9
- package/dist/node/engine/AreHTML.tokenizer.js.map +1 -1
- package/dist/node/engine/AreHTML.tokenizer.mjs +10 -3
- package/dist/node/engine/AreHTML.tokenizer.mjs.map +1 -1
- package/dist/node/engine/AreHTML.transformer.js +13 -8
- package/dist/node/engine/AreHTML.transformer.js.map +1 -1
- package/dist/node/engine/AreHTML.transformer.mjs +9 -2
- package/dist/node/engine/AreHTML.transformer.mjs.map +1 -1
- package/dist/node/index.d.mts +2 -1
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.js +3 -3
- package/dist/node/index.mjs +1 -1
- package/dist/node/instructions/AddAttribute.instruction.js +3 -4
- package/dist/node/instructions/AddAttribute.instruction.js.map +1 -1
- package/dist/node/instructions/AddAttribute.instruction.mjs +3 -4
- package/dist/node/instructions/AddAttribute.instruction.mjs.map +1 -1
- package/dist/node/instructions/AddComment.instruction.js +3 -4
- package/dist/node/instructions/AddComment.instruction.js.map +1 -1
- package/dist/node/instructions/AddComment.instruction.mjs +3 -4
- package/dist/node/instructions/AddComment.instruction.mjs.map +1 -1
- package/dist/node/instructions/AddElement.instruction.js +3 -4
- package/dist/node/instructions/AddElement.instruction.js.map +1 -1
- package/dist/node/instructions/AddElement.instruction.mjs +3 -4
- package/dist/node/instructions/AddElement.instruction.mjs.map +1 -1
- package/dist/node/instructions/AddInterpolation.instruction.js +3 -4
- package/dist/node/instructions/AddInterpolation.instruction.js.map +1 -1
- package/dist/node/instructions/AddInterpolation.instruction.mjs +3 -4
- package/dist/node/instructions/AddInterpolation.instruction.mjs.map +1 -1
- package/dist/node/instructions/AddListener.instruction.js +3 -4
- package/dist/node/instructions/AddListener.instruction.js.map +1 -1
- package/dist/node/instructions/AddListener.instruction.mjs +3 -4
- package/dist/node/instructions/AddListener.instruction.mjs.map +1 -1
- package/dist/node/instructions/AddStyle.instruction.js +3 -4
- package/dist/node/instructions/AddStyle.instruction.js.map +1 -1
- package/dist/node/instructions/AddStyle.instruction.mjs +3 -4
- package/dist/node/instructions/AddStyle.instruction.mjs.map +1 -1
- package/dist/node/instructions/AddText.instruction.js +3 -4
- package/dist/node/instructions/AddText.instruction.js.map +1 -1
- package/dist/node/instructions/AddText.instruction.mjs +3 -4
- package/dist/node/instructions/AddText.instruction.mjs.map +1 -1
- package/dist/node/lib/AreDirective/AreDirective.component.js +5 -0
- package/dist/node/lib/AreDirective/AreDirective.component.js.map +1 -1
- package/dist/node/lib/AreDirective/AreDirective.component.mjs +5 -0
- package/dist/node/lib/AreDirective/AreDirective.component.mjs.map +1 -1
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.js +17 -4
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.js.map +1 -1
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.mjs +10 -3
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.mjs.map +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.js +3 -4
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.js.map +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs +3 -4
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs.map +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.js +3 -4
- package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.mjs +3 -4
- package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
- package/dist/node/lib/{AreWatcher/AreWatcher.component.d.mts → AreRouteWatcher/AreRouteWatcher.component.d.mts} +2 -2
- package/dist/node/lib/{AreWatcher/AreWatcher.component.d.ts → AreRouteWatcher/AreRouteWatcher.component.d.ts} +2 -2
- package/dist/node/lib/{AreWatcher/AreWatcher.component.js → AreRouteWatcher/AreRouteWatcher.component.js} +9 -10
- package/dist/node/lib/AreRouteWatcher/AreRouteWatcher.component.js.map +1 -0
- package/dist/node/lib/{AreWatcher/AreWatcher.component.mjs → AreRouteWatcher/AreRouteWatcher.component.mjs} +10 -11
- package/dist/node/lib/AreRouteWatcher/AreRouteWatcher.component.mjs.map +1 -0
- package/dist/node/lib/AreStyle/AreStyle.context.js +17 -4
- package/dist/node/lib/AreStyle/AreStyle.context.js.map +1 -1
- package/dist/node/lib/AreStyle/AreStyle.context.mjs +10 -3
- package/dist/node/lib/AreStyle/AreStyle.context.mjs.map +1 -1
- package/dist/node/nodes/AreComment.js +17 -4
- package/dist/node/nodes/AreComment.js.map +1 -1
- package/dist/node/nodes/AreComment.mjs +10 -3
- package/dist/node/nodes/AreComment.mjs.map +1 -1
- package/dist/node/nodes/AreComponent.js +3 -4
- package/dist/node/nodes/AreComponent.js.map +1 -1
- package/dist/node/nodes/AreComponent.mjs +3 -4
- package/dist/node/nodes/AreComponent.mjs.map +1 -1
- package/dist/node/nodes/AreInterpolation.js +17 -4
- package/dist/node/nodes/AreInterpolation.js.map +1 -1
- package/dist/node/nodes/AreInterpolation.mjs +10 -3
- package/dist/node/nodes/AreInterpolation.mjs.map +1 -1
- package/dist/node/nodes/AreRoot.js +3 -4
- package/dist/node/nodes/AreRoot.js.map +1 -1
- package/dist/node/nodes/AreRoot.mjs +3 -4
- package/dist/node/nodes/AreRoot.mjs.map +1 -1
- package/dist/node/nodes/AreText.js +17 -4
- package/dist/node/nodes/AreText.js.map +1 -1
- package/dist/node/nodes/AreText.mjs +10 -3
- package/dist/node/nodes/AreText.mjs.map +1 -1
- package/dist/node/signals/AreRoute.signal.js +18 -5
- package/dist/node/signals/AreRoute.signal.js.map +1 -1
- package/dist/node/signals/AreRoute.signal.mjs +10 -3
- package/dist/node/signals/AreRoute.signal.mjs.map +1 -1
- package/docs/SYNTAX.md +714 -0
- package/docs/arehtml.monaco.json +235 -0
- package/docs/arehtml.monaco.ts +119 -0
- package/examples/dashboard/dist/index.html +1 -1
- package/examples/dashboard/dist/mpioi5ab-8c3oa9.js +13674 -0
- package/examples/jumpstart/dist/index.html +1 -1
- package/examples/{dashboard/dist/mnzfypsd-6zjt7w.js → jumpstart/dist/mor90p6y-0plg7g.js} +1869 -1926
- package/examples/jumpstart/dist/{mnpl1g4i-nobz9g.js → mor90p7p-1898bz.js} +2797 -2282
- package/examples/jumpstart/src/components/List.component.ts +14 -13
- package/examples/jumpstart/src/concept.ts +5 -4
- package/jest.config.ts +1 -1
- package/package.json +10 -6
- package/src/attributes/AreBinding.attribute.ts +5 -0
- package/src/attributes/AreDirective.attribute.ts +5 -0
- package/src/attributes/AreEvent.attribute.ts +5 -0
- package/src/attributes/AreStatic.attribute.ts +5 -0
- package/src/directives/AreDirectiveFor.directive.ts +97 -60
- package/src/directives/AreDirectiveIf.directive.ts +37 -15
- package/src/engine/AreHTML.compiler.ts +64 -36
- package/src/engine/AreHTML.constants.ts +144 -0
- package/src/engine/AreHTML.context.ts +33 -4
- package/src/engine/AreHTML.engine.ts +12 -7
- package/src/engine/AreHTML.interpreter.ts +195 -68
- package/src/engine/AreHTML.lifecycle.ts +5 -0
- package/src/engine/AreHTML.tokenizer.ts +6 -1
- package/src/engine/AreHTML.transformer.ts +5 -0
- package/src/index.ts +2 -2
- package/src/instructions/AddAttribute.instruction.ts +3 -4
- package/src/instructions/AddComment.instruction.ts +3 -4
- package/src/instructions/AddElement.instruction.ts +3 -4
- package/src/instructions/AddInterpolation.instruction.ts +3 -4
- package/src/instructions/AddListener.instruction.ts +3 -4
- package/src/instructions/AddStyle.instruction.ts +3 -4
- package/src/instructions/AddText.instruction.ts +3 -4
- package/src/lib/AreDirective/AreDirective.component.ts +5 -0
- package/src/lib/AreHTMLAttribute/AreHTML.attribute.ts +5 -0
- package/src/lib/AreHTMLNode/AreHTMLNode.ts +3 -4
- package/src/lib/AreRoot/AreRoot.component.ts +3 -4
- package/src/lib/{AreWatcher/AreWatcher.component.ts → AreRouteWatcher/AreRouteWatcher.component.ts} +5 -6
- package/src/lib/AreStyle/AreStyle.context.ts +5 -0
- package/src/nodes/AreComment.ts +5 -0
- package/src/nodes/AreComponent.ts +3 -4
- package/src/nodes/AreInterpolation.ts +5 -0
- package/src/nodes/AreRoot.ts +3 -4
- package/src/nodes/AreText.ts +5 -0
- package/src/signals/AreRoute.signal.ts +5 -0
- package/dist/node/lib/AreWatcher/AreWatcher.component.js.map +0 -1
- package/dist/node/lib/AreWatcher/AreWatcher.component.mjs.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var aConcept = require('@adaas/a-concept');
|
|
4
4
|
var aLogger = require('@adaas/a-utils/a-logger');
|
|
5
|
-
var
|
|
5
|
+
var core = require('@adaas/a-frame/core');
|
|
6
6
|
var are = require('@adaas/are');
|
|
7
7
|
var AreDirective_attribute = require('@adaas/are-html/attributes/AreDirective.attribute');
|
|
8
8
|
var AreStatic_attribute = require('@adaas/are-html/attributes/AreStatic.attribute');
|
|
@@ -67,38 +67,66 @@ exports.AreHTMLCompiler = class AreHTMLCompiler extends are.AreCompiler {
|
|
|
67
67
|
handler: attribute.content
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
|
-
compileBindingAttribute(attribute, scene, parentStore, store, ...args) {
|
|
70
|
+
compileBindingAttribute(attribute, scene, parentStore, store, syntax, ...args) {
|
|
71
71
|
if (!scene.host)
|
|
72
72
|
throw new are.AreCompilerError({
|
|
73
73
|
title: "Scene Host Not Found",
|
|
74
74
|
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.`
|
|
75
75
|
});
|
|
76
76
|
const node = attribute.owner;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
case "number":
|
|
86
|
-
value = Number(value);
|
|
87
|
-
break;
|
|
88
|
-
case "boolean":
|
|
89
|
-
value = Boolean(value);
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
77
|
+
const props = node.component?.props;
|
|
78
|
+
let propName;
|
|
79
|
+
if (props) {
|
|
80
|
+
if (props[attribute.name]) {
|
|
81
|
+
propName = attribute.name;
|
|
82
|
+
} else {
|
|
83
|
+
const camel = aConcept.A_FormatterHelper.toCamelCase(attribute.name);
|
|
84
|
+
if (props[camel]) propName = camel;
|
|
92
85
|
}
|
|
93
|
-
store.set(attribute.name, value);
|
|
94
|
-
} else {
|
|
95
|
-
const instruction = new AddAttribute_instruction.AddAttributeInstruction(scene.host, {
|
|
96
|
-
name: attribute.name,
|
|
97
|
-
content: attribute.content,
|
|
98
|
-
evaluate: true
|
|
99
|
-
});
|
|
100
|
-
scene.plan(instruction);
|
|
101
86
|
}
|
|
87
|
+
if (propName && props) {
|
|
88
|
+
const propDefinition = props[propName];
|
|
89
|
+
const coerce = (raw) => {
|
|
90
|
+
let value = raw;
|
|
91
|
+
if (propDefinition.type) {
|
|
92
|
+
switch (propDefinition.type) {
|
|
93
|
+
case "string":
|
|
94
|
+
value = value === void 0 || value === null ? "" : String(value);
|
|
95
|
+
break;
|
|
96
|
+
case "number":
|
|
97
|
+
value = Number(value);
|
|
98
|
+
break;
|
|
99
|
+
case "boolean":
|
|
100
|
+
value = Boolean(value);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
105
|
+
};
|
|
106
|
+
const watcher = {
|
|
107
|
+
update: () => {
|
|
108
|
+
try {
|
|
109
|
+
parentStore.watch(watcher);
|
|
110
|
+
const next = coerce(syntax.evaluate(attribute.content, parentStore));
|
|
111
|
+
parentStore.unwatch(watcher);
|
|
112
|
+
store.set(propName, next);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
parentStore.unwatch(watcher);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
parentStore.watch(watcher);
|
|
119
|
+
const initial = coerce(syntax.evaluate(attribute.content, parentStore));
|
|
120
|
+
parentStore.unwatch(watcher);
|
|
121
|
+
store.set(propName, initial);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const instruction = new AddAttribute_instruction.AddAttributeInstruction(scene.host, {
|
|
125
|
+
name: attribute.name,
|
|
126
|
+
content: attribute.content,
|
|
127
|
+
evaluate: true
|
|
128
|
+
});
|
|
129
|
+
scene.plan(instruction);
|
|
102
130
|
}
|
|
103
131
|
};
|
|
104
132
|
__decorateClass([
|
|
@@ -137,12 +165,12 @@ __decorateClass([
|
|
|
137
165
|
__decorateParam(1, aConcept.A_Inject(are.AreScene)),
|
|
138
166
|
__decorateParam(2, aConcept.A_Dependency.Parent()),
|
|
139
167
|
__decorateParam(2, aConcept.A_Inject(are.AreStore)),
|
|
140
|
-
__decorateParam(3, aConcept.A_Inject(are.AreStore))
|
|
168
|
+
__decorateParam(3, aConcept.A_Inject(are.AreStore)),
|
|
169
|
+
__decorateParam(4, aConcept.A_Inject(are.AreSyntax))
|
|
141
170
|
], exports.AreHTMLCompiler.prototype, "compileBindingAttribute", 1);
|
|
142
171
|
exports.AreHTMLCompiler = __decorateClass([
|
|
143
|
-
|
|
144
|
-
namespace: "
|
|
145
|
-
name: "AreHTMLCompiler",
|
|
172
|
+
core.A_Frame.Define({
|
|
173
|
+
namespace: "a-are-html",
|
|
146
174
|
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."
|
|
147
175
|
})
|
|
148
176
|
], exports.AreHTMLCompiler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":["AreHTMLCompiler","AreCompiler","AddTextInstruction","AreCompilerError","AddAttributeInstruction","AreDirectiveFeatures","A_FormatterHelper","AddListenerInstruction","AreInterpolation","A_Caller","AreScene","AreStore","A_Logger","AreText","AreStaticAttribute","AreDirectiveAttribute","A_Feature","AreEventAttribute","AreBindingAttribute","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBaA,uBAAA,GAAN,8BAA8BC,eAAA,CAAY;AAAA,EAuB7C,oBAAA,CACwB,aAAA,EACA,KAAA,EAEA,KAAA,EACA,WACjB,IAAA,EACL;AAeE,IAAA,KAAA,CAAM,IAAA,CAAK,IAAIC,sCAAA,CAAmB,E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ACN,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYnB,uBAAA,CAAA","file":"AreHTML.compiler.js","sourcesContent":["import { A_Caller, A_Dependency, A_Feature, A_FormatterHelper, A_Inject } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore } 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\";\n\n\n\n\n@A_Frame.Component({\n namespace: 'A-ARE',\n name: 'AreHTMLCompiler',\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 // compile(\n // @A_Inject(A_Caller) node: AreHTMLNode,\n // @A_Inject(AreScene) scene: AreScene,\n // ...args: any[]\n // ): void {\n // super.compile(node, scene, ...args);\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 * Default case when attribute was not able to be identified as a binding, directive, or event, we just want to add it as a regular attribute to the node. This is the most basic case for attributes that don't have any special behavior or processing logic, and it ensures that they are still rendered on the node even if they don't have any dynamic functionality.\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 ...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\n /**\n * 1. If the binding is related to a component prop, then we should set the value to the component props, so it can be used in the component logic and rendering.\n * This is a special case for component props, since they are not regular attributes and have a special meaning and usage in the component. By setting the value directly to the component props, we can ensure that it is properly reactive and can influence the component's behavior and rendering based on its value.\n */\n if (node.component && node.component.props[attribute.name]) {\n const propDefinition = node.component.props[attribute.name];\n let value = parentStore.get(attribute.content);\n\n if (propDefinition.type) {\n switch (propDefinition.type) {\n case 'string':\n value = String(value);\n break;\n case 'number':\n value = Number(value);\n break;\n case 'boolean':\n value = Boolean(value);\n break;\n default:\n break;\n }\n }\n\n store.set(attribute.name, value);\n }\n /**\n * 2. In other cases, we just want to add it as a regular attribute to the node, since it can be used in the template and rendering as a dynamic value that can change based on the store value. By adding it as a regular attribute, we can ensure that it is properly rendered and updated in the DOM based on its value in the store.\n */\n else {\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\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":["AreHTMLCompiler","AreCompiler","AddTextInstruction","AreCompilerError","AddAttributeInstruction","AreDirectiveFeatures","A_FormatterHelper","AddListenerInstruction","AreInterpolation","A_Caller","AreScene","AreStore","A_Logger","AreText","AreStaticAttribute","AreDirectiveAttribute","A_Feature","AreEventAttribute","AreBindingAttribute","AreSyntax","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBaA,uBAAA,GAAN,8BAA8BC,eAAA,CAAY;AAAA,EAuB7C,oBAAA,CACwB,aAAA,EACA,KAAA,EAEA,KAAA,EACA,WACjB,IAAA,EACL;AAeE,IAAA,KAAA,CAAM,IAAA,CAAK,IAAIC,sCAAA,CAAmB,EAAE,OAAA,EAAS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AA,EAAA,CAAA,CAAA;AAoBA,eAAA,CAAA;AAAA,EADCC,eAAA,CAAY,QAAQc,4CAAqB,CAAA;AAAA,EAErC,qCAASN,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASE,YAAQ,CAAA,CAAA;AAAA,EACjB,qCAASK,kBAAS,CAAA,CAAA;AAAA,EAClB,qCAASJ,gBAAQ,CAAA;AAAA,CAAA,EA/FbZ,uBAAA,CA2FT,SAAA,EAAA,2BAAA,EAAA,CAAA,CAAA;AA0BA,eAAA,CAAA;AAAA,EADCC,eAAA,CAAY,QAAQgB,oCAAiB,CAAA;AAAA,EAEjC,qCAASR,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,YAAQ,CAAA;AAAA,CAAA,EAvHbV,uBAAA,CAqHT,SAAA,EAAA,uBAAA,EAAA,CAAA,CAAA;AA2BA,eAAA,CAAA;AAAA,EADCC,eAAA,CAAY,QAAQiB,wCAAmB,CAAA;AAAA,EAEnC,qCAAST,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,YAAQ,CAAA,CAAA;AAAA,EACjB,yCAAa,MAAA,EAAO,CAAA;AAAA,EACpB,qCAASC,YAAQ,CAAA,CAAA;AAAA,EACjB,qCAASA,YAAQ,CAAA,CAAA;AAAA,EACjB,qCAASQ,aAAS,CAAA;AAAA,CAAA,EAtJdnB,uBAAA,CAgJT,SAAA,EAAA,yBAAA,EAAA,CAAA,CAAA;AAhJSA,uBAAA,GAAN,eAAA,CAAA;AAAA,EAJNoB,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYpB,uBAAA,CAAA","file":"AreHTML.compiler.js","sourcesContent":["import { A_Caller, A_Dependency, A_Feature, A_FormatterHelper, A_Inject } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AddAttributeInstruction} from \"@adaas/are-html/instructions/AddAttribute.instruction\";\nimport { AddTextInstruction} from \"@adaas/are-html/instructions/AddText.instruction\";\nimport { AddListenerInstruction} from \"@adaas/are-html/instructions/AddListener.instruction\";\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 // compile(\n // @A_Inject(A_Caller) node: AreHTMLNode,\n // @A_Inject(AreScene) scene: AreScene,\n // ...args: any[]\n // ): void {\n // super.compile(node, scene, ...args);\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 * Default case when attribute was not able to be identified as a binding, directive, or event, we just want to add it as a regular attribute to the node. This is the most basic case for attributes that don't have any special behavior or processing logic, and it ensures that they are still rendered on the node even if they don't have any dynamic functionality.\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,8 +1,8 @@
|
|
|
1
1
|
import { __decorateClass, __decorateParam } from '../chunk-EQQGB2QZ.mjs';
|
|
2
2
|
import { A_Inject, A_Caller, A_Feature, A_Dependency, A_FormatterHelper } from '@adaas/a-concept';
|
|
3
3
|
import { A_Logger } from '@adaas/a-utils/a-logger';
|
|
4
|
-
import { A_Frame } from '@adaas/a-frame';
|
|
5
|
-
import { AreCompiler, AreScene, AreStore, AreCompilerError } from '@adaas/are';
|
|
4
|
+
import { A_Frame } from '@adaas/a-frame/core';
|
|
5
|
+
import { AreCompiler, AreScene, AreStore, AreSyntax, AreCompilerError } from '@adaas/are';
|
|
6
6
|
import { AreDirectiveAttribute } from '@adaas/are-html/attributes/AreDirective.attribute';
|
|
7
7
|
import { AreStaticAttribute } from '@adaas/are-html/attributes/AreStatic.attribute';
|
|
8
8
|
import { AreDirectiveFeatures } from '@adaas/are-html/directive/AreDirective.constants';
|
|
@@ -55,38 +55,66 @@ let AreHTMLCompiler = class extends AreCompiler {
|
|
|
55
55
|
handler: attribute.content
|
|
56
56
|
}));
|
|
57
57
|
}
|
|
58
|
-
compileBindingAttribute(attribute, scene, parentStore, store, ...args) {
|
|
58
|
+
compileBindingAttribute(attribute, scene, parentStore, store, syntax, ...args) {
|
|
59
59
|
if (!scene.host)
|
|
60
60
|
throw new AreCompilerError({
|
|
61
61
|
title: "Scene Host Not Found",
|
|
62
62
|
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.`
|
|
63
63
|
});
|
|
64
64
|
const node = attribute.owner;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
case "number":
|
|
74
|
-
value = Number(value);
|
|
75
|
-
break;
|
|
76
|
-
case "boolean":
|
|
77
|
-
value = Boolean(value);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
65
|
+
const props = node.component?.props;
|
|
66
|
+
let propName;
|
|
67
|
+
if (props) {
|
|
68
|
+
if (props[attribute.name]) {
|
|
69
|
+
propName = attribute.name;
|
|
70
|
+
} else {
|
|
71
|
+
const camel = A_FormatterHelper.toCamelCase(attribute.name);
|
|
72
|
+
if (props[camel]) propName = camel;
|
|
80
73
|
}
|
|
81
|
-
store.set(attribute.name, value);
|
|
82
|
-
} else {
|
|
83
|
-
const instruction = new AddAttributeInstruction(scene.host, {
|
|
84
|
-
name: attribute.name,
|
|
85
|
-
content: attribute.content,
|
|
86
|
-
evaluate: true
|
|
87
|
-
});
|
|
88
|
-
scene.plan(instruction);
|
|
89
74
|
}
|
|
75
|
+
if (propName && props) {
|
|
76
|
+
const propDefinition = props[propName];
|
|
77
|
+
const coerce = (raw) => {
|
|
78
|
+
let value = raw;
|
|
79
|
+
if (propDefinition.type) {
|
|
80
|
+
switch (propDefinition.type) {
|
|
81
|
+
case "string":
|
|
82
|
+
value = value === void 0 || value === null ? "" : String(value);
|
|
83
|
+
break;
|
|
84
|
+
case "number":
|
|
85
|
+
value = Number(value);
|
|
86
|
+
break;
|
|
87
|
+
case "boolean":
|
|
88
|
+
value = Boolean(value);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return value;
|
|
93
|
+
};
|
|
94
|
+
const watcher = {
|
|
95
|
+
update: () => {
|
|
96
|
+
try {
|
|
97
|
+
parentStore.watch(watcher);
|
|
98
|
+
const next = coerce(syntax.evaluate(attribute.content, parentStore));
|
|
99
|
+
parentStore.unwatch(watcher);
|
|
100
|
+
store.set(propName, next);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
parentStore.unwatch(watcher);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
parentStore.watch(watcher);
|
|
107
|
+
const initial = coerce(syntax.evaluate(attribute.content, parentStore));
|
|
108
|
+
parentStore.unwatch(watcher);
|
|
109
|
+
store.set(propName, initial);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const instruction = new AddAttributeInstruction(scene.host, {
|
|
113
|
+
name: attribute.name,
|
|
114
|
+
content: attribute.content,
|
|
115
|
+
evaluate: true
|
|
116
|
+
});
|
|
117
|
+
scene.plan(instruction);
|
|
90
118
|
}
|
|
91
119
|
};
|
|
92
120
|
__decorateClass([
|
|
@@ -125,12 +153,12 @@ __decorateClass([
|
|
|
125
153
|
__decorateParam(1, A_Inject(AreScene)),
|
|
126
154
|
__decorateParam(2, A_Dependency.Parent()),
|
|
127
155
|
__decorateParam(2, A_Inject(AreStore)),
|
|
128
|
-
__decorateParam(3, A_Inject(AreStore))
|
|
156
|
+
__decorateParam(3, A_Inject(AreStore)),
|
|
157
|
+
__decorateParam(4, A_Inject(AreSyntax))
|
|
129
158
|
], AreHTMLCompiler.prototype, "compileBindingAttribute", 1);
|
|
130
159
|
AreHTMLCompiler = __decorateClass([
|
|
131
|
-
A_Frame.
|
|
132
|
-
namespace: "
|
|
133
|
-
name: "AreHTMLCompiler",
|
|
160
|
+
A_Frame.Define({
|
|
161
|
+
namespace: "a-are-html",
|
|
134
162
|
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."
|
|
135
163
|
})
|
|
136
164
|
], AreHTMLCompiler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuBO,IAAM,eAAA,GAAN,cAA8B,WAAA,CAAY;AAAA,EAuB7C,oBAAA,CACwB,aAAA,EACA,KAAA,EAEA,KAAA,EACA,WACjB,IAAA,EACL;AAeE,IAAA,KAAA,CAAM,IAAA,CAAK,IAAI,kBAAA,CAAmB,EAAE,OAAA,EAAS,cAAc,OAAA,EAAS,QAAA,EAAU,IAAA,EAAM,CAAC,CAAA;AAAA,EACzF;AAAA,EAMA,WAAA,CACwB,IAAA,EACA,KAAA,EACA,MAAA,EAAA,GACjB,IAAA,EACL;AACE,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,CAAA,oCAAA,EAAuC,IAAA,CAAK,KAAA,CAAM,UAAU,CAAA,iBAAA,EAAoB,IAAA,CAAK,OAAO,CAAA,CAAA,CAAG,CAAA;AACrH,IAAA,IAAI,KAAA,CAAM,IAAA;AACN,MAAA,KAAA,CAAM,MAAA,CAAO,MAAM,IAAI,CAAA;AAE3B,IAAA,KAAA,CAAM,IAAA,CAAK,IAAI,kBAAA,CAAmB,EAAE,SAAS,IAAA,CAAK,OAAA,EAAS,CAAC,CAAA;AAAA,EAEhE;AAAA,EAOA,sBAAA,CACwB,SAAA,EAC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AAY,QAAQ,iBAAiB,CAAA;AAAA,EAEjC,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EAvHb,eAAA,CAqHT,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;AAAA,CAAA,EArJb,eAAA,CAgJT,SAAA,EAAA,yBAAA,EAAA,CAAA,CAAA;AAhJS,eAAA,GAAN,eAAA,CAAA;AAAA,EALN,QAAQ,SAAA,CAAU;AAAA,IACf,SAAA,EAAW,OAAA;AAAA,IACX,IAAA,EAAM,iBAAA;AAAA,IACN,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\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore } 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\";\n\n\n\n\n@A_Frame.Component({\n namespace: 'A-ARE',\n name: 'AreHTMLCompiler',\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 // compile(\n // @A_Inject(A_Caller) node: AreHTMLNode,\n // @A_Inject(AreScene) scene: AreScene,\n // ...args: any[]\n // ): void {\n // super.compile(node, scene, ...args);\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 * Default case when attribute was not able to be identified as a binding, directive, or event, we just want to add it as a regular attribute to the node. This is the most basic case for attributes that don't have any special behavior or processing logic, and it ensures that they are still rendered on the node even if they don't have any dynamic functionality.\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 ...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\n /**\n * 1. If the binding is related to a component prop, then we should set the value to the component props, so it can be used in the component logic and rendering.\n * This is a special case for component props, since they are not regular attributes and have a special meaning and usage in the component. By setting the value directly to the component props, we can ensure that it is properly reactive and can influence the component's behavior and rendering based on its value.\n */\n if (node.component && node.component.props[attribute.name]) {\n const propDefinition = node.component.props[attribute.name];\n let value = parentStore.get(attribute.content);\n\n if (propDefinition.type) {\n switch (propDefinition.type) {\n case 'string':\n value = String(value);\n break;\n case 'number':\n value = Number(value);\n break;\n case 'boolean':\n value = Boolean(value);\n break;\n default:\n break;\n }\n }\n\n store.set(attribute.name, value);\n }\n /**\n * 2. In other cases, we just want to add it as a regular attribute to the node, since it can be used in the template and rendering as a dynamic value that can change based on the store value. By adding it as a regular attribute, we can ensure that it is properly rendered and updated in the DOM based on its value in the store.\n */\n else {\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\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/engine/AreHTML.compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAsBO,IAAM,eAAA,GAAN,cAA8B,WAAA,CAAY;AAAA,EAuB7C,oBAAA,CACwB,aAAA,EACA,KAAA,EAEA,KAAA,EACA,WACjB,IAAA,EACL;AAeE,IAAA,KAAA,CAAM,IAAA,CAAK,IAAI,kBAAA,CAAmB,EAAE,OAAA,EAAS,cAAc,OAAA,EAAS,QAAA,EAAU,IAAA,EAAM,CAAC,CAAA;AAAA,EACzF;AAAA,EAMA,WAAA,CACwB,IAAA,EACA,KAAA,EACA,MAAA,EAAA,GACjB,IAAA,EACL;AACE,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,CAAA,oCAAA,EAAuC,IAAA,CAAK,KAAA,CAAM,UAAU,CAAA,iBAAA,EAAoB,IAAA,CAAK,OAAO,CAAA,CAAA,CAAG,CAAA;AACrH,IAAA,IAAI,KAAA,CAAM,IAAA;AACN,MAAA,KAAA,CAAM,MAAA,CAAO,MAAM,IAAI,CAAA;AAE3B,IAAA,KAAA,CAAM,IAAA,CAAK,IAAI,kBAAA,CAAmB,EAAE,SAAS,IAAA,CAAK,OAAA,EAAS,CAAC,CAAA;AAAA,EAEhE;AAAA,EAOA,sBAAA,CACwB,SAAA,EACA,KAAA,EAAA,GACjB,IAAA,EACL;AACE,IAAA,IAAI,CAAC,KAAA,CAAM,IAAA;AACP,MAAA,MAAM,IAAI,gBAAA,CAAiB;AAAA,QACvB,KAAA,EAAO,sBAAA;AAAA,QACP,WAAA,EAAa,CAAA,qCAAA,EAAwC,KAAA,CAAM,EAAE,CAAA,0GAAA;AAAA,OAChE,CAAA;AAIL,IAAA,KAAA,CAAM,IAAA,CAAK,IAAI,uBAAA,CAAwB,KAA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JS,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\";\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 // compile(\n // @A_Inject(A_Caller) node: AreHTMLNode,\n // @A_Inject(AreScene) scene: AreScene,\n // ...args: any[]\n // ): void {\n // super.compile(node, scene, ...args);\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 * Default case when attribute was not able to be identified as a binding, directive, or event, we just want to add it as a regular attribute to the node. This is the most basic case for attributes that don't have any special behavior or processing logic, and it ensures that they are still rendered on the node even if they don't have any dynamic functionality.\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,2 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boolean HTML attributes whose presence (regardless of value) implies "true",
|
|
3
|
+
* and whose absence implies "false". Setting these via `setAttribute(name, value)`
|
|
4
|
+
* always renders the attribute, which is wrong for reactive bindings.
|
|
5
|
+
*
|
|
6
|
+
* Reference: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
|
|
7
|
+
*/
|
|
8
|
+
declare const BOOLEAN_ATTRIBUTES: Set<string>;
|
|
9
|
+
declare function isBooleanAttribute(name: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Form-control IDL properties that must be set as a JS property
|
|
12
|
+
* (not just an attribute) so live user input is reflected.
|
|
13
|
+
*
|
|
14
|
+
* `<input value="foo">` only sets the *default* value;
|
|
15
|
+
* `input.value = "foo"` updates the live state.
|
|
16
|
+
*/
|
|
17
|
+
declare const IDL_FORM_PROPERTIES: Record<string, Set<string>>;
|
|
18
|
+
declare function isIDLFormProperty(tagName: string, attrName: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Normalize a `:class` binding value into a single space-separated string.
|
|
21
|
+
* Supports the common shapes:
|
|
22
|
+
* - string → "a b"
|
|
23
|
+
* - array<string | object | falsy> → ["a", { b: true, c: cond }, null]
|
|
24
|
+
* - object<string, boolean> → { a: true, b: false }
|
|
25
|
+
*/
|
|
26
|
+
declare function normalizeClassValue(value: any): string;
|
|
27
|
+
/**
|
|
28
|
+
* Normalize a `:style` binding value into an inline-style string.
|
|
29
|
+
* Supports:
|
|
30
|
+
* - string → "color: red; font-size: 12px"
|
|
31
|
+
* - object<string, string|number> → { color: 'red', fontSize: '12px' }
|
|
32
|
+
* - array<string | object> → ['color: red', { fontSize: '12px' }]
|
|
33
|
+
*/
|
|
34
|
+
declare function normalizeStyleValue(value: any): string;
|
|
35
|
+
/**
|
|
36
|
+
* Parse a DOM event name with modifiers, e.g. "click.stop.prevent" or "keydown.enter".
|
|
37
|
+
* Returns the bare event name plus the modifier set.
|
|
38
|
+
*/
|
|
39
|
+
interface ParsedEventName {
|
|
40
|
+
event: string;
|
|
41
|
+
modifiers: Set<string>;
|
|
42
|
+
}
|
|
43
|
+
declare function parseEventName(raw: string): ParsedEventName;
|
|
44
|
+
/**
|
|
45
|
+
* Known event-listener modifiers that map directly to addEventListener options.
|
|
46
|
+
*/
|
|
47
|
+
declare const LISTENER_OPTION_MODIFIERS: Set<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Coerce a value into a string for DOM consumption.
|
|
50
|
+
* Avoids "undefined"/"null"/"[object Object]" leaks into the DOM.
|
|
51
|
+
*/
|
|
52
|
+
declare function toDOMString(value: any): string;
|
|
1
53
|
|
|
2
|
-
export {
|
|
54
|
+
export { BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, isBooleanAttribute, isIDLFormProperty, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
|
|
@@ -1,2 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boolean HTML attributes whose presence (regardless of value) implies "true",
|
|
3
|
+
* and whose absence implies "false". Setting these via `setAttribute(name, value)`
|
|
4
|
+
* always renders the attribute, which is wrong for reactive bindings.
|
|
5
|
+
*
|
|
6
|
+
* Reference: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
|
|
7
|
+
*/
|
|
8
|
+
declare const BOOLEAN_ATTRIBUTES: Set<string>;
|
|
9
|
+
declare function isBooleanAttribute(name: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Form-control IDL properties that must be set as a JS property
|
|
12
|
+
* (not just an attribute) so live user input is reflected.
|
|
13
|
+
*
|
|
14
|
+
* `<input value="foo">` only sets the *default* value;
|
|
15
|
+
* `input.value = "foo"` updates the live state.
|
|
16
|
+
*/
|
|
17
|
+
declare const IDL_FORM_PROPERTIES: Record<string, Set<string>>;
|
|
18
|
+
declare function isIDLFormProperty(tagName: string, attrName: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Normalize a `:class` binding value into a single space-separated string.
|
|
21
|
+
* Supports the common shapes:
|
|
22
|
+
* - string → "a b"
|
|
23
|
+
* - array<string | object | falsy> → ["a", { b: true, c: cond }, null]
|
|
24
|
+
* - object<string, boolean> → { a: true, b: false }
|
|
25
|
+
*/
|
|
26
|
+
declare function normalizeClassValue(value: any): string;
|
|
27
|
+
/**
|
|
28
|
+
* Normalize a `:style` binding value into an inline-style string.
|
|
29
|
+
* Supports:
|
|
30
|
+
* - string → "color: red; font-size: 12px"
|
|
31
|
+
* - object<string, string|number> → { color: 'red', fontSize: '12px' }
|
|
32
|
+
* - array<string | object> → ['color: red', { fontSize: '12px' }]
|
|
33
|
+
*/
|
|
34
|
+
declare function normalizeStyleValue(value: any): string;
|
|
35
|
+
/**
|
|
36
|
+
* Parse a DOM event name with modifiers, e.g. "click.stop.prevent" or "keydown.enter".
|
|
37
|
+
* Returns the bare event name plus the modifier set.
|
|
38
|
+
*/
|
|
39
|
+
interface ParsedEventName {
|
|
40
|
+
event: string;
|
|
41
|
+
modifiers: Set<string>;
|
|
42
|
+
}
|
|
43
|
+
declare function parseEventName(raw: string): ParsedEventName;
|
|
44
|
+
/**
|
|
45
|
+
* Known event-listener modifiers that map directly to addEventListener options.
|
|
46
|
+
*/
|
|
47
|
+
declare const LISTENER_OPTION_MODIFIERS: Set<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Coerce a value into a string for DOM consumption.
|
|
50
|
+
* Avoids "undefined"/"null"/"[object Object]" leaks into the DOM.
|
|
51
|
+
*/
|
|
52
|
+
declare function toDOMString(value: any): string;
|
|
1
53
|
|
|
2
|
-
export {
|
|
54
|
+
export { BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, isBooleanAttribute, isIDLFormProperty, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
|
|
@@ -1,4 +1,104 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
4
|
+
"allowfullscreen",
|
|
5
|
+
"async",
|
|
6
|
+
"autofocus",
|
|
7
|
+
"autoplay",
|
|
8
|
+
"checked",
|
|
9
|
+
"controls",
|
|
10
|
+
"default",
|
|
11
|
+
"defer",
|
|
12
|
+
"disabled",
|
|
13
|
+
"formnovalidate",
|
|
14
|
+
"hidden",
|
|
15
|
+
"inert",
|
|
16
|
+
"ismap",
|
|
17
|
+
"itemscope",
|
|
18
|
+
"loop",
|
|
19
|
+
"multiple",
|
|
20
|
+
"muted",
|
|
21
|
+
"nomodule",
|
|
22
|
+
"novalidate",
|
|
23
|
+
"open",
|
|
24
|
+
"playsinline",
|
|
25
|
+
"readonly",
|
|
26
|
+
"required",
|
|
27
|
+
"reversed",
|
|
28
|
+
"selected"
|
|
29
|
+
]);
|
|
30
|
+
function isBooleanAttribute(name) {
|
|
31
|
+
return BOOLEAN_ATTRIBUTES.has(name.toLowerCase());
|
|
32
|
+
}
|
|
33
|
+
const IDL_FORM_PROPERTIES = {
|
|
34
|
+
INPUT: /* @__PURE__ */ new Set(["value", "checked", "indeterminate"]),
|
|
35
|
+
TEXTAREA: /* @__PURE__ */ new Set(["value"]),
|
|
36
|
+
SELECT: /* @__PURE__ */ new Set(["value"]),
|
|
37
|
+
OPTION: /* @__PURE__ */ new Set(["selected"])
|
|
38
|
+
};
|
|
39
|
+
function isIDLFormProperty(tagName, attrName) {
|
|
40
|
+
const set = IDL_FORM_PROPERTIES[tagName.toUpperCase()];
|
|
41
|
+
return !!set && set.has(attrName);
|
|
42
|
+
}
|
|
43
|
+
function normalizeClassValue(value) {
|
|
44
|
+
if (value === null || value === void 0 || value === false) return "";
|
|
45
|
+
if (typeof value === "string") return value;
|
|
46
|
+
if (typeof value === "number") return String(value);
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
return value.map(normalizeClassValue).filter(Boolean).join(" ");
|
|
49
|
+
}
|
|
50
|
+
if (typeof value === "object") {
|
|
51
|
+
const parts = [];
|
|
52
|
+
for (const key of Object.keys(value)) {
|
|
53
|
+
if (value[key]) parts.push(key);
|
|
54
|
+
}
|
|
55
|
+
return parts.join(" ");
|
|
56
|
+
}
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
function normalizeStyleValue(value) {
|
|
60
|
+
if (value === null || value === void 0 || value === false) return "";
|
|
61
|
+
if (typeof value === "string") return value;
|
|
62
|
+
if (typeof value === "number") return String(value);
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
return value.map(normalizeStyleValue).filter(Boolean).join("; ");
|
|
65
|
+
}
|
|
66
|
+
if (typeof value === "object") {
|
|
67
|
+
const parts = [];
|
|
68
|
+
for (const key of Object.keys(value)) {
|
|
69
|
+
const v = value[key];
|
|
70
|
+
if (v === null || v === void 0 || v === false) continue;
|
|
71
|
+
const kebab = key.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
72
|
+
parts.push(`${kebab}: ${v}`);
|
|
73
|
+
}
|
|
74
|
+
return parts.join("; ");
|
|
75
|
+
}
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
function parseEventName(raw) {
|
|
79
|
+
const [event, ...modifiers] = raw.split(".");
|
|
80
|
+
return { event, modifiers: new Set(modifiers) };
|
|
81
|
+
}
|
|
82
|
+
const LISTENER_OPTION_MODIFIERS = /* @__PURE__ */ new Set(["capture", "once", "passive"]);
|
|
83
|
+
function toDOMString(value) {
|
|
84
|
+
if (value === null || value === void 0) return "";
|
|
85
|
+
if (typeof value === "string") return value;
|
|
86
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
87
|
+
try {
|
|
88
|
+
return JSON.stringify(value);
|
|
89
|
+
} catch {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.BOOLEAN_ATTRIBUTES = BOOLEAN_ATTRIBUTES;
|
|
95
|
+
exports.IDL_FORM_PROPERTIES = IDL_FORM_PROPERTIES;
|
|
96
|
+
exports.LISTENER_OPTION_MODIFIERS = LISTENER_OPTION_MODIFIERS;
|
|
97
|
+
exports.isBooleanAttribute = isBooleanAttribute;
|
|
98
|
+
exports.isIDLFormProperty = isIDLFormProperty;
|
|
99
|
+
exports.normalizeClassValue = normalizeClassValue;
|
|
100
|
+
exports.normalizeStyleValue = normalizeStyleValue;
|
|
101
|
+
exports.parseEventName = parseEventName;
|
|
102
|
+
exports.toDOMString = toDOMString;
|
|
3
103
|
//# sourceMappingURL=AreHTML.constants.js.map
|
|
4
104
|
//# sourceMappingURL=AreHTML.constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"AreHTML.constants.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/engine/AreHTML.constants.ts"],"names":[],"mappings":";;AAOO,MAAM,kBAAA,uBAAyB,GAAA,CAAY;AAAA,EAC9C,iBAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,gBAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA;AACJ,CAAC;AAEM,SAAS,mBAAmB,IAAA,EAAuB;AACtD,EAAA,OAAO,kBAAA,CAAmB,GAAA,CAAI,IAAA,CAAK,WAAA,EAAa,CAAA;AACpD;AASO,MAAM,mBAAA,GAAmD;AAAA,EAC5D,uBAAO,IAAI,GAAA,CAAI,CAAC,OAAA,EAAS,SAAA,EAAW,eAAe,CAAC,CAAA;AAAA,EACpD,QAAA,kBAAU,IAAI,GAAA,CAAI,CAAC,OAAO,CAAC,CAAA;AAAA,EAC3B,MAAA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AQ,KAAA,KAAU,MAAA,EAAW,OAAO,EAAA;AAClD,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,IAAI,OAAO,UAAU,QAAA,IAAY,OAAO,UAAU,SAAA,EAAW,OAAO,OAAO,KAAK,CAAA;AAChF,EAAA,IAAI;AACA,IAAA,OAAO,IAAA,CAAK,UAAU,KAAK,CAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AACJ,IAAA,OAAO,EAAA;AAAA,EACX;AACJ","file":"AreHTML.constants.js","sourcesContent":["/**\n * Boolean HTML attributes whose presence (regardless of value) implies \"true\",\n * and whose absence implies \"false\". Setting these via `setAttribute(name, value)`\n * always renders the attribute, which is wrong for reactive bindings.\n *\n * Reference: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n */\nexport const BOOLEAN_ATTRIBUTES = new Set<string>([\n 'allowfullscreen',\n 'async',\n 'autofocus',\n 'autoplay',\n 'checked',\n 'controls',\n 'default',\n 'defer',\n 'disabled',\n 'formnovalidate',\n 'hidden',\n 'inert',\n 'ismap',\n 'itemscope',\n 'loop',\n 'multiple',\n 'muted',\n 'nomodule',\n 'novalidate',\n 'open',\n 'playsinline',\n 'readonly',\n 'required',\n 'reversed',\n 'selected',\n]);\n\nexport function isBooleanAttribute(name: string): boolean {\n return BOOLEAN_ATTRIBUTES.has(name.toLowerCase());\n}\n\n/**\n * Form-control IDL properties that must be set as a JS property\n * (not just an attribute) so live user input is reflected.\n *\n * `<input value=\"foo\">` only sets the *default* value;\n * `input.value = \"foo\"` updates the live state.\n */\nexport const IDL_FORM_PROPERTIES: Record<string, Set<string>> = {\n INPUT: new Set(['value', 'checked', 'indeterminate']),\n TEXTAREA: new Set(['value']),\n SELECT: new Set(['value']),\n OPTION: new Set(['selected']),\n};\n\nexport function isIDLFormProperty(tagName: string, attrName: string): boolean {\n const set = IDL_FORM_PROPERTIES[tagName.toUpperCase()];\n return !!set && set.has(attrName);\n}\n\n/**\n * Normalize a `:class` binding value into a single space-separated string.\n * Supports the common shapes:\n * - string → \"a b\"\n * - array<string | object | falsy> → [\"a\", { b: true, c: cond }, null]\n * - object<string, boolean> → { a: true, b: false }\n */\nexport function normalizeClassValue(value: any): string {\n if (value === null || value === undefined || value === false) return '';\n if (typeof value === 'string') return value;\n if (typeof value === 'number') return String(value);\n\n if (Array.isArray(value)) {\n return value.map(normalizeClassValue).filter(Boolean).join(' ');\n }\n if (typeof value === 'object') {\n const parts: string[] = [];\n for (const key of Object.keys(value)) {\n if (value[key]) parts.push(key);\n }\n return parts.join(' ');\n }\n return '';\n}\n\n/**\n * Normalize a `:style` binding value into an inline-style string.\n * Supports:\n * - string → \"color: red; font-size: 12px\"\n * - object<string, string|number> → { color: 'red', fontSize: '12px' }\n * - array<string | object> → ['color: red', { fontSize: '12px' }]\n */\nexport function normalizeStyleValue(value: any): string {\n if (value === null || value === undefined || value === false) return '';\n if (typeof value === 'string') return value;\n if (typeof value === 'number') return String(value);\n\n if (Array.isArray(value)) {\n return value.map(normalizeStyleValue).filter(Boolean).join('; ');\n }\n if (typeof value === 'object') {\n const parts: string[] = [];\n for (const key of Object.keys(value)) {\n const v = value[key];\n if (v === null || v === undefined || v === false) continue;\n const kebab = key.replace(/[A-Z]/g, m => '-' + m.toLowerCase());\n parts.push(`${kebab}: ${v}`);\n }\n return parts.join('; ');\n }\n return '';\n}\n\n/**\n * Parse a DOM event name with modifiers, e.g. \"click.stop.prevent\" or \"keydown.enter\".\n * Returns the bare event name plus the modifier set.\n */\nexport interface ParsedEventName {\n event: string;\n modifiers: Set<string>;\n}\n\nexport function parseEventName(raw: string): ParsedEventName {\n const [event, ...modifiers] = raw.split('.');\n return { event, modifiers: new Set(modifiers) };\n}\n\n/**\n * Known event-listener modifiers that map directly to addEventListener options.\n */\nexport const LISTENER_OPTION_MODIFIERS = new Set(['capture', 'once', 'passive']);\n\n/**\n * Coerce a value into a string for DOM consumption.\n * Avoids \"undefined\"/\"null\"/\"[object Object]\" leaks into the DOM.\n */\nexport function toDOMString(value: any): string {\n if (value === null || value === undefined) return '';\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n try {\n return JSON.stringify(value);\n } catch {\n return '';\n }\n}\n\n\n"]}
|