@xaendar/compiler 0.7.16 → 0.7.18
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/xaendar-compiler.es.js +19 -11
- package/package.json +3 -3
|
@@ -514,9 +514,16 @@ function generateElement(node, parentNode, index, compilerContext, anchor) {
|
|
|
514
514
|
const nodeName = getElementIdentifier(node, parentNode, index);
|
|
515
515
|
const tagName = node.tagName;
|
|
516
516
|
const retval = {
|
|
517
|
-
code: [
|
|
517
|
+
code: [],
|
|
518
518
|
functionsToProcess: /* @__PURE__ */ new Map()
|
|
519
519
|
};
|
|
520
|
+
switch (tagName) {
|
|
521
|
+
case "svg":
|
|
522
|
+
retval.code.push("context.createElement = createSVGElement");
|
|
523
|
+
break;
|
|
524
|
+
case "math": retval.code.push("context.createElement = createMATHMLElement");
|
|
525
|
+
}
|
|
526
|
+
retval.code.push(`const ${nodeName} = _renderElement(${parentNode}, context, ${anchor}, '${tagName}',`);
|
|
520
527
|
attributes.length ? retval.code.push(...indent([
|
|
521
528
|
"[",
|
|
522
529
|
...indent(attributes),
|
|
@@ -527,6 +534,10 @@ function generateElement(node, parentNode, index, compilerContext, anchor) {
|
|
|
527
534
|
...indent(events),
|
|
528
535
|
"]"
|
|
529
536
|
]), ");") : retval.code[retval.code.length - 1] = `${retval.code[retval.code.length - 1]} []);`;
|
|
537
|
+
switch (tagName) {
|
|
538
|
+
case "svg":
|
|
539
|
+
case "math": retval.code.push("context.createElement = createElement");
|
|
540
|
+
}
|
|
530
541
|
if (node.children.length) {
|
|
531
542
|
retval.functionsToProcess.set(`${nodeName}Children`, {
|
|
532
543
|
fn: {
|
|
@@ -861,16 +872,13 @@ var Generator = class {
|
|
|
861
872
|
renderFunctions.push(...indent(["return context;"]), "}");
|
|
862
873
|
for (const [key, fnData] of this._nodeToProcess.entries()) {
|
|
863
874
|
const { node, parentNode, context, precode, anchor } = fnData.fn;
|
|
864
|
-
renderFunctions.push(`\n${key}(${fnData.args?.join(", ")}) {`, ...indent([
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
}).flat(),
|
|
872
|
-
fnData.fn.isForBody ? "return { context, update };" : "return context;"
|
|
873
|
-
]), "}");
|
|
875
|
+
renderFunctions.push(`\n${key}(${fnData.args?.join(", ")}) {`, ...indent(["const context = new Context(this, parentContext);"]));
|
|
876
|
+
if (precode) renderFunctions.push(indent(precode));
|
|
877
|
+
renderFunctions.push(...indent([...node.children.map((child, i) => {
|
|
878
|
+
const { code, functionsToProcess } = this._processNode(child, parentNode, i.toString(), context, anchor ?? null);
|
|
879
|
+
functionsToProcess?.forEach((value, key) => this._nodeToProcess.set(key, value));
|
|
880
|
+
return code;
|
|
881
|
+
}).flat(), fnData.fn.isForBody ? "return { context, update };" : "return context;"]), "}");
|
|
874
882
|
}
|
|
875
883
|
return renderFunctions.join("\n");
|
|
876
884
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaendar/compiler",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.18",
|
|
4
4
|
"description": "A library for transpiling Xaendar Templates into JavaScript code",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@xaendar/common": "0.7.
|
|
20
|
-
"@xaendar/types": "0.7.
|
|
19
|
+
"@xaendar/common": "0.7.18",
|
|
20
|
+
"@xaendar/types": "0.7.18",
|
|
21
21
|
"typescript": "^6.0.3"
|
|
22
22
|
}
|
|
23
23
|
}
|