@xaendar/compiler 0.7.22 → 0.7.23
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 +11 -14
- package/package.json +3 -3
|
@@ -891,7 +891,7 @@ var Generator = class {
|
|
|
891
891
|
generatedCode.push(...indent(["return context;"]), "}");
|
|
892
892
|
for (const [key, fnData] of this._nodeToProcess.entries()) {
|
|
893
893
|
const { node, parentNode, context, precode, anchor } = fnData.fn;
|
|
894
|
-
generatedCode.push(`\n${key}
|
|
894
|
+
generatedCode.push(`\n${key}(${fnData.args?.join(", ")}) {`, ...indent(["const context = new Context(this, parentContext);"]));
|
|
895
895
|
if (precode) generatedCode.push(indent(precode));
|
|
896
896
|
generatedCode.push(...indent([...node.children.map((child, i) => {
|
|
897
897
|
const result = this._processNode(child, parentNode, i.toString(), context, anchor ?? null);
|
|
@@ -2921,16 +2921,13 @@ function typeCheckElement(node, parentNode, index, context) {
|
|
|
2921
2921
|
} else return `${resolvedParameter}`;
|
|
2922
2922
|
}).join(", ");
|
|
2923
2923
|
const beginning = parsedEventParameter ? "($event)" : "()";
|
|
2924
|
-
retVal.code.push(`const ${nodeName}_${name} = ${beginning} => root.${handler}(${mappedParameters})
|
|
2925
|
-
});
|
|
2926
|
-
if (node.children.length) retVal.functionsToProcess.set(`${nodeName}Children`, {
|
|
2927
|
-
fn: {
|
|
2928
|
-
node,
|
|
2929
|
-
parentNode,
|
|
2930
|
-
context
|
|
2931
|
-
},
|
|
2932
|
-
args: [nodeName]
|
|
2924
|
+
retVal.code.push(`const ${nodeName}_${name} = ${beginning} => root.${handler}(${mappedParameters});`);
|
|
2933
2925
|
});
|
|
2926
|
+
if (node.children.length) retVal.functionsToProcess.set(`${nodeName}Children`, { fn: {
|
|
2927
|
+
node,
|
|
2928
|
+
parentNode,
|
|
2929
|
+
context
|
|
2930
|
+
} });
|
|
2934
2931
|
return retVal;
|
|
2935
2932
|
}
|
|
2936
2933
|
//#endregion
|
|
@@ -2966,11 +2963,11 @@ function typeCheckFor(node, parentNode, index, compilerContext) {
|
|
|
2966
2963
|
},
|
|
2967
2964
|
args: [`${itemsName}: typeof ${iterableExpr}`, `${counterName}: number`]
|
|
2968
2965
|
});
|
|
2969
|
-
retVal.code.push(`const ${forKey}_${itemsName} = ${iterableExpr}
|
|
2966
|
+
retVal.code.push(`const ${forKey}_${itemsName} = ${iterableExpr};`);
|
|
2970
2967
|
retVal.code.push(`const ${forKey}_${node.itemAlias} = ${resolveExpression(node.trackExpression, forContext, {
|
|
2971
2968
|
skipResolution: true,
|
|
2972
2969
|
resolver: `${iterableExpr}`
|
|
2973
|
-
})}
|
|
2970
|
+
})};`);
|
|
2974
2971
|
return retVal;
|
|
2975
2972
|
}
|
|
2976
2973
|
/**
|
|
@@ -3054,7 +3051,7 @@ function typeCheckSwitch(node, parentNode, index, compilerContext) {
|
|
|
3054
3051
|
//#endregion
|
|
3055
3052
|
//#region ../packages/compiler/src/type-checker/states/type-check-text-and-interpolation.state.ts
|
|
3056
3053
|
function typeCheckTextAndInterpolation(node, parentNode, index, compilerContext) {
|
|
3057
|
-
return { code: [`const ${getTextIdentifier("text", parentNode.identifier, index)} = ${node.type === ASTNodeType.Text ? node.value : resolveExpression(node.expression, compilerContext, { resolver: "root" })};`] };
|
|
3054
|
+
return { code: [`const ${getTextIdentifier("text", parentNode.identifier, index)} = ${node.type === ASTNodeType.Text ? `'${node.value}'` : resolveExpression(node.expression, compilerContext, { resolver: "root" })};`] };
|
|
3058
3055
|
}
|
|
3059
3056
|
//#endregion
|
|
3060
3057
|
//#region ../packages/compiler/src/type-checker/type-checker.ts
|
|
@@ -3091,7 +3088,7 @@ var TypeChecker = class {
|
|
|
3091
3088
|
generatedCode.push("}");
|
|
3092
3089
|
for (const [key, fnData] of this._nodeToProcess.entries()) {
|
|
3093
3090
|
const { node, parentNode, precode, context } = fnData.fn;
|
|
3094
|
-
generatedCode.push(`\nfunction ${key}
|
|
3091
|
+
generatedCode.push(`\nfunction ${key}(${fnData.args?.join(", ") ?? ""}): void {`);
|
|
3095
3092
|
if (precode) generatedCode.push(indent(precode));
|
|
3096
3093
|
generatedCode.push(...indent([...node.children.map((child, i) => {
|
|
3097
3094
|
const result = this._processNode(child, parentNode, i.toString(), context);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaendar/compiler",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.23",
|
|
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.23",
|
|
20
|
+
"@xaendar/types": "0.7.23",
|
|
21
21
|
"typescript": "^6.0.3"
|
|
22
22
|
}
|
|
23
23
|
}
|