@xaendar/compiler 0.6.16 → 0.6.17
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 +13 -7
- package/package.json +3 -3
|
@@ -1612,8 +1612,8 @@ function parseImplicitAliases(source, baseOffset, out) {
|
|
|
1612
1612
|
const eqIndex = trimmed.indexOf("=");
|
|
1613
1613
|
if (eqIndex === -1) throw new Error(`[Parser] Invalid alias declaration '${trimmed}'. Expected '$implicit = alias'.`);
|
|
1614
1614
|
cursor += entry.length + 1;
|
|
1615
|
-
const
|
|
1616
|
-
const
|
|
1615
|
+
const alias = trimmed.slice(0, eqIndex).trim();
|
|
1616
|
+
const implicit = trimmed.slice(eqIndex + 1).trim();
|
|
1617
1617
|
const isImplicitVariable = (value) => IMPLICIT_VARIABLES.has(value);
|
|
1618
1618
|
if (!isImplicitVariable(implicit)) throw new Error(`[Parser] '${implicit}' is not a known implicit variable. Known variables: ${[...IMPLICIT_VARIABLES].join(", ")}.`);
|
|
1619
1619
|
cursor += entry.length + 1;
|
|
@@ -1670,7 +1670,7 @@ function splitForSections(source) {
|
|
|
1670
1670
|
}
|
|
1671
1671
|
current += char;
|
|
1672
1672
|
}
|
|
1673
|
-
if (current.trim().length
|
|
1673
|
+
if (current.trim().length) sections.push(current);
|
|
1674
1674
|
return sections;
|
|
1675
1675
|
}
|
|
1676
1676
|
/**
|
|
@@ -2315,7 +2315,13 @@ function processFor(node, nodeName, parentNode, compilerContext) {
|
|
|
2315
2315
|
], compilerContext);
|
|
2316
2316
|
const forKey = getBlockIdentifier(parentNode, nodeName, "for");
|
|
2317
2317
|
functionsToProcess.set(forKey, {
|
|
2318
|
-
code: [`const { ${node.itemAlias}, ${indexName}, ${firstName}, ${lastName}, ${evenName}, ${oddName} } = _iterationVariables(${itemsName}, ${counterName}
|
|
2318
|
+
code: [`const { ${node.itemAlias}, ${indexName}, ${firstName}, ${lastName}, ${evenName}, ${oddName} } = _iterationVariables(${itemsName}, ${counterName}, '${node.itemAlias}', {
|
|
2319
|
+
$index: '${indexName}',
|
|
2320
|
+
$first: '${firstName}',
|
|
2321
|
+
$last: '${lastName}',
|
|
2322
|
+
$even: '${evenName}',
|
|
2323
|
+
$odd: '${oddName}'
|
|
2324
|
+
});`, ...node.children.flatMap((child, i) => processNode(child, `${nodeName}_${i}`, parentNode, forContext))],
|
|
2319
2325
|
args: [
|
|
2320
2326
|
parentNode,
|
|
2321
2327
|
"parentContext",
|
|
@@ -2484,13 +2490,13 @@ var nodeToProcess = /* @__PURE__ */ new Map();
|
|
|
2484
2490
|
function generateRenderFunction(ast, cssVariableName) {
|
|
2485
2491
|
nodeToProcess.clear();
|
|
2486
2492
|
const compilerContext = new CompilerContext();
|
|
2487
|
-
const renderFunctions = ["_render() {", ...indent([`const ${ROOT_NODE} = this._root;`, "const context = new Context(this)"])];
|
|
2493
|
+
const renderFunctions = ["_render() {", ...indent([`const ${ROOT_NODE} = this._root;`, "const context = new Context(this);"])];
|
|
2488
2494
|
if (cssVariableName) renderFunctions.push(indent(`${ROOT_NODE}.adoptedStyleSheets = [${cssVariableName}];`));
|
|
2489
2495
|
renderFunctions.push(...indent([...ast.map((node, i) => [...processNode(node, i.toString(), ROOT_NODE, compilerContext)]).flat(), "return context;"]), "}");
|
|
2490
2496
|
while (nodeToProcess.size) {
|
|
2491
2497
|
const [key, fnData] = nodeToProcess.entries().next().value;
|
|
2492
|
-
renderFunctions.push(
|
|
2493
|
-
"const context = new Context(this, parentContext)",
|
|
2498
|
+
renderFunctions.push(`\n${key}(${fnData.args.join(", ")}) {`, ...indent([
|
|
2499
|
+
"const context = new Context(this, parentContext);",
|
|
2494
2500
|
...fnData.fn(...fnData.args),
|
|
2495
2501
|
"return context"
|
|
2496
2502
|
]), "}");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaendar/compiler",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.17",
|
|
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.6.
|
|
20
|
-
"@xaendar/types": "0.6.
|
|
19
|
+
"@xaendar/common": "0.6.17",
|
|
20
|
+
"@xaendar/types": "0.6.17",
|
|
21
21
|
"typescript": "^6.0.3"
|
|
22
22
|
}
|
|
23
23
|
}
|