@xaendar/compiler 0.6.9 → 0.6.10

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.
@@ -1925,39 +1925,75 @@ var Parser = class {
1925
1925
  }
1926
1926
  };
1927
1927
  //#endregion
1928
- //#region ../packages/compiler/src/render-generator/models/render-context.model.ts
1928
+ //#region ../packages/compiler/src/render-generator/states/process-const-declaration.state.ts
1929
1929
  /**
1930
- * Tracks identifier scope during render code generation.
1931
- * Each `Context` instance represents one lexical scope (e.g. a `@for` loop body)
1932
- * and can be chained to a parent context for outer-scope resolution.
1930
+ * Generates code for a `@const` declaration node.
1931
+ * Emits a `const name = expression;` JavaScript statement.
1932
+ *
1933
+ * @param node The `ConstDeclarationNode` to process.
1934
+ * @param _nodeName Unused node name.
1935
+ * @param _parentNode Unused parent node name.
1936
+ * @returns Array containing the generated const statement string.
1933
1937
  */
1934
- var Context = class {
1935
- _identifiers;
1936
- _parent;
1937
- /**
1938
- * Creates a new scope context.
1939
- *
1940
- * @param _identifiers List of loop variable names declared in this scope.
1941
- * @param _parent Optional parent context representing the enclosing scope.
1942
- */
1943
- constructor(_identifiers = new Array(), _parent) {
1944
- this._identifiers = _identifiers;
1945
- this._parent = _parent;
1946
- }
1947
- addIdentifier(name) {
1948
- if (this.getIdentifier(name)) throw new Error(`Identifier "${name}" is already declared in this scope.`);
1949
- this._identifiers.push(name);
1950
- }
1951
- /**
1952
- * Returns the innermost identifier in the current scope chain, or
1953
- * delegates to the parent context if none is found in this scope.
1954
- *
1955
- * @returns The most recently declared identifier name, or `undefined` if none exists.
1956
- */
1957
- getIdentifier(name) {
1958
- return this._identifiers.includes(name) ? name : this._parent?.getIdentifier(name);
1959
- }
1960
- };
1938
+ function processConstDeclaration(node, _nodeName, _parentNode) {
1939
+ return [`const ${node.varName} = ${node.varName};`];
1940
+ }
1941
+ //#endregion
1942
+ //#region ../packages/compiler/src/render-generator/states/process-element.state.ts
1943
+ /**
1944
+ * Generates code for an HTML element node: creates the DOM element, sets attributes,
1945
+ * attaches event listeners, appends it to the parent, and recursively processes children.
1946
+ *
1947
+ * @param node The `ElementNode` to process.
1948
+ * @param nodeName Variable name to use for the created DOM element.
1949
+ * @param parentNode Variable name of the parent DOM node to append to.
1950
+ * @returns Array of generated code lines.
1951
+ */
1952
+ function processElement(node, nodeName, parentNode) {
1953
+ const attributes = mapAttributes(node.attributes);
1954
+ const events = mapEvents(node.events);
1955
+ const code = [`renderElement(${parentNode}, context, '${node.tagName}',`];
1956
+ attributes.length ? code.push(...indent([
1957
+ "[",
1958
+ ...indent(attributes),
1959
+ "],"
1960
+ ])) : code[code.length - 1] = `${code[code.length - 1]} [],`;
1961
+ events.length ? code.push(...indent([
1962
+ "[",
1963
+ ...indent(events),
1964
+ "]"
1965
+ ]), ")") : code[code.length - 1] = `${code[code.length - 1]} [])`;
1966
+ return code;
1967
+ }
1968
+ /**
1969
+ * Generates code that assigns attributes to a DOM element.
1970
+ *
1971
+ * Static (string) attribute values are set once via a direct `setAttribute` call,
1972
+ * while dynamic attribute values are wrapped in an `effect` so the attribute is
1973
+ * re-evaluated and updated whenever its underlying signal dependencies change.
1974
+ * The disposer returned by the `effect` is registered in `unwatchFns` for cleanup.
1975
+ *
1976
+ * @param attributes The attribute nodes to map onto the element.
1977
+ * @returns Array of generated code lines, one per attribute.
1978
+ */
1979
+ function mapAttributes(attributes) {
1980
+ return attributes?.map(({ name, value }) => {
1981
+ const isLiteral = typeof value === "string";
1982
+ return `{ name: '${name}', value: '${isLiteral ? value : value.expression.text}', literal: ${isLiteral} },`;
1983
+ });
1984
+ }
1985
+ /**
1986
+ * Generates code that attaches event listeners to a DOM element.
1987
+ *
1988
+ * For each event node an `addEventListener` call is emitted, binding the event
1989
+ * to the component instance handler and exposing the native event as `$event`.
1990
+ *
1991
+ * @param events The event nodes to bind to the element.
1992
+ * @returns Array of generated code lines, one per event listener.
1993
+ */
1994
+ function mapEvents(events) {
1995
+ return events?.map((event) => `{ name: '${event.name}', handler: '${event.handler}' }`);
1996
+ }
1961
1997
  //#endregion
1962
1998
  //#region ../packages/compiler/src/render-generator/utils/render-generator.utils.ts
1963
1999
  /**
@@ -2169,8 +2205,8 @@ var ROOT_NODE = "root";
2169
2205
  * // typeof id !== 'boolean' || pippo instanceof HTMLElement
2170
2206
  * // → typeof this.id !== 'boolean' || this.pippo instanceof HTMLElement
2171
2207
  */
2172
- function resolveExpression(expression, context) {
2173
- return emitNode(expression, expression, context);
2208
+ function resolveExpression(expression) {
2209
+ return emitNode(expression, expression);
2174
2210
  }
2175
2211
  /**
2176
2212
  * Emits the resolved text for a node.
@@ -2181,14 +2217,13 @@ function resolveExpression(expression, context) {
2181
2217
  * - If the node is a resolvable Identifier, emits the resolved name.
2182
2218
  * - Otherwise recurses into children and concatenates their output.
2183
2219
  */
2184
- function emitNode(node, parent, context) {
2185
- if (ts.isIdentifier(node) && needsResolution(node, parent)) return context.getIdentifier(node.text) ?? `this.${node.text}`;
2220
+ function emitNode(node, parent) {
2186
2221
  if (!containsResolvableIdentifier(node, parent)) return node.getText();
2187
2222
  const sourceText = node.getSourceFile().text;
2188
2223
  let result = "";
2189
2224
  let lastEnd = node.getStart();
2190
2225
  ts.forEachChild(node, (child) => {
2191
- result = `${result}${sourceText.slice(lastEnd, child.getStart())}${emitNode(child, node, context)}`;
2226
+ result = `${result}${sourceText.slice(lastEnd, child.getStart())}${emitNode(child, node)}`;
2192
2227
  lastEnd = child.getEnd();
2193
2228
  });
2194
2229
  return `${result}${sourceText.slice(lastEnd, node.getEnd())}`;
@@ -2233,86 +2268,6 @@ function getBlockIdentifier(parentNode, index, prefix) {
2233
2268
  return (parentNode !== "root" ? `${parentNode}_${prefix}${index}` : `${prefix}${index}`).replace(/-/g, "_");
2234
2269
  }
2235
2270
  //#endregion
2236
- //#region ../packages/compiler/src/render-generator/states/process-const-declaration.state.ts
2237
- /**
2238
- * Generates code for a `@const` declaration node.
2239
- * Emits a `const name = expression;` JavaScript statement.
2240
- *
2241
- * @param node The `ConstDeclarationNode` to process.
2242
- * @param _nodeName Unused node name.
2243
- * @param _parentNode Unused parent node name.
2244
- * @param _context Unused render context.
2245
- * @returns Array containing the generated const statement string.
2246
- */
2247
- function processConstDeclaration(node, _nodeName, _parentNode, context) {
2248
- context.addIdentifier(node.varName);
2249
- return [`const ${node.varName} = ${resolveExpression(node.expression, context)};`];
2250
- }
2251
- //#endregion
2252
- //#region ../packages/compiler/src/render-generator/states/process-element.state.ts
2253
- /**
2254
- * Generates code for an HTML element node: creates the DOM element, sets attributes,
2255
- * attaches event listeners, appends it to the parent, and recursively processes children.
2256
- *
2257
- * @param node The `ElementNode` to process.
2258
- * @param nodeName Variable name to use for the created DOM element.
2259
- * @param parentNode Variable name of the parent DOM node to append to.
2260
- * @param context Current render scope context.
2261
- * @returns Array of generated code lines.
2262
- */
2263
- function processElement(node, nodeName, parentNode, context) {
2264
- const childrenContext = new Context([], context);
2265
- return [
2266
- `const ${nodeName} = document.createElement("${node.tagName}");`,
2267
- ...mapAttributes(node.attributes, nodeName, context),
2268
- ...mapEvents(node.events, nodeName),
2269
- `${parentNode}.appendChild(${nodeName});`,
2270
- `unwatchFns.push(() => ${parentNode}.removeChild(${nodeName}));`,
2271
- ...node.children.map((child, i) => processNode(child, i.toString(), nodeName, childrenContext)).flat()
2272
- ];
2273
- }
2274
- /**
2275
- * Generates code that assigns attributes to a DOM element.
2276
- *
2277
- * Static (string) attribute values are set once via a direct `setAttribute` call,
2278
- * while dynamic attribute values are wrapped in an `effect` so the attribute is
2279
- * re-evaluated and updated whenever its underlying signal dependencies change.
2280
- * The disposer returned by the `effect` is registered in `unwatchFns` for cleanup.
2281
- *
2282
- * @param attributes The attribute nodes to map onto the element.
2283
- * @param nodeName Variable name of the DOM element receiving the attributes.
2284
- * @param context Current render scope context, used to resolve dynamic expressions.
2285
- * @returns Array of generated code lines, one per attribute.
2286
- */
2287
- function mapAttributes(attributes, nodeName, context) {
2288
- const literalsAttributes = new Array();
2289
- const bindingsAttributes = new Array();
2290
- attributes?.forEach(({ name, value }) => typeof value === "string" ? literalsAttributes.push({
2291
- name,
2292
- value
2293
- }) : bindingsAttributes.push({
2294
- name,
2295
- value
2296
- }));
2297
- const mappedAttributes = literalsAttributes.map((attr) => `${nodeName}.setAttribute("${attr.name}", "${attr.value}");`);
2298
- const mappedBindingAttributes = bindingsAttributes.map((attr) => `effect(() => ${nodeName}.setAttribute("${attr.name}", ${resolveExpression(attr.value.expression, context)})),`);
2299
- if (mappedBindingAttributes.length) mappedAttributes.push(`unwatchFns.push(`, ...indent(mappedBindingAttributes), `);`);
2300
- return mappedAttributes;
2301
- }
2302
- /**
2303
- * Generates code that attaches event listeners to a DOM element.
2304
- *
2305
- * For each event node an `addEventListener` call is emitted, binding the event
2306
- * to the component instance handler and exposing the native event as `$event`.
2307
- *
2308
- * @param events The event nodes to bind to the element.
2309
- * @param nodeName Variable name of the DOM element receiving the listeners.
2310
- * @returns Array of generated code lines, one per event listener.
2311
- */
2312
- function mapEvents(events, nodeName) {
2313
- return events?.map((event) => `${nodeName}.addEventListener("${event.name}", ($event) => this.${event.handler});`) ?? [];
2314
- }
2315
- //#endregion
2316
2271
  //#region ../packages/compiler/src/render-generator/states/process-for.state.ts
2317
2272
  /**
2318
2273
  * Generates code for a `@for` iteration node.
@@ -2342,14 +2297,12 @@ function mapEvents(events, nodeName) {
2342
2297
  * @param nodeName - Base variable name prefix used for child nodes and
2343
2298
  * to produce a unique loop counter identifier.
2344
2299
  * @param parentNode - Variable name of the parent DOM node.
2345
- * @param parentContext - The enclosing scope context.
2346
2300
  * @returns Array of generated code lines.
2347
2301
  */
2348
- function processFor(node, nodeName, parentNode, parentContext) {
2302
+ function processFor(node, nodeName, parentNode) {
2349
2303
  const mainBlock = new Array();
2350
2304
  const functionsToProcess = /* @__PURE__ */ new Map();
2351
2305
  const iterableSource = node.iterableSource;
2352
- const iterableExpr = parentContext.getIdentifier(iterableSource) ?? `this.${iterableSource}`;
2353
2306
  const itemsName = getTextIdentifier(parentNode, nodeName, "items");
2354
2307
  const counterName = getTextIdentifier(parentNode, nodeName, "i");
2355
2308
  const indexName = resolveImplicit(node, "$index");
@@ -2357,24 +2310,17 @@ function processFor(node, nodeName, parentNode, parentContext) {
2357
2310
  const lastName = resolveImplicit(node, "$last");
2358
2311
  const evenName = resolveImplicit(node, "$even");
2359
2312
  const oddName = resolveImplicit(node, "$odd");
2360
- const forContext = new Context([
2361
- node.itemAlias,
2362
- indexName,
2363
- firstName,
2364
- lastName,
2365
- evenName,
2366
- oddName
2367
- ], parentContext);
2368
2313
  const forKey = getBlockIdentifier(parentNode, nodeName, "for");
2369
2314
  functionsToProcess.set(forKey, {
2370
- code: [`const { ${node.itemAlias}, ${indexName}, ${firstName}, ${lastName}, ${evenName}, ${oddName} } = _iterationVariables(${itemsName}, ${counterName});`, ...node.children.flatMap((child, i) => processNode(child, `${nodeName}_${i}`, parentNode, forContext))],
2315
+ code: [`const { ${node.itemAlias}, ${indexName}, ${firstName}, ${lastName}, ${evenName}, ${oddName} } = _iterationVariables(${itemsName}, ${counterName});`, ...node.children.flatMap((child, i) => processNode(child, `${nodeName}_${i}`, parentNode))],
2371
2316
  args: [
2372
2317
  parentNode,
2318
+ "parentContext",
2373
2319
  itemsName,
2374
2320
  counterName
2375
2321
  ]
2376
2322
  });
2377
- mainBlock.push(`_for(${parentNode}, unwatchFns, () => ${iterableExpr}, this.${forKey}.bind(this));`);
2323
+ mainBlock.push(`_for(${parentNode}, context, '${iterableSource}', this.${forKey}.bind(this));`);
2378
2324
  return {
2379
2325
  mainBlock,
2380
2326
  fns: functionsToProcess
@@ -2404,50 +2350,46 @@ function resolveImplicit(node, implicit) {
2404
2350
  * @param node The `IfNode` to process.
2405
2351
  * @param nodeName Base variable name prefix for child nodes.
2406
2352
  * @param parentNode Variable name of the parent DOM node.
2407
- * @param context Current render scope context.
2408
2353
  * @returns Array of generated code lines.
2409
2354
  */
2410
- function processIf(node, nodeName, parentNode, context) {
2411
- const ifContext = new Context([], context);
2355
+ function processIf(node, nodeName, parentNode) {
2412
2356
  const functionsToProcess = /* @__PURE__ */ new Map();
2413
2357
  const mainBlock = new Array();
2414
2358
  const ifKey = getBlockIdentifier(parentNode, nodeName, "if");
2415
2359
  mainBlock.push({
2416
- condition: resolveExpression(node.conditionNode, context),
2360
+ condition: resolveExpression(node.conditionNode),
2417
2361
  block: `this.${ifKey}.bind(this)`
2418
2362
  });
2419
2363
  functionsToProcess.set(ifKey, {
2420
- code: processConsequent(node, nodeName, parentNode, ifContext),
2421
- args: [parentNode]
2364
+ code: processConsequent(node, nodeName, parentNode),
2365
+ args: [parentNode, "parentContext"]
2422
2366
  });
2423
2367
  let alt = node.alternate;
2424
2368
  let index = 0;
2425
2369
  while (alt?.type === ASTNodeType.ElseIf) {
2426
- const elseIfContext = new Context([], context);
2427
2370
  const keyElseIf = getBlockIdentifier(parentNode, `${nodeName}_${index}`, "elseIf");
2428
2371
  const conditionNode = alt.conditionNode;
2429
2372
  mainBlock.push({
2430
- condition: resolveExpression(conditionNode, context),
2373
+ condition: resolveExpression(conditionNode),
2431
2374
  block: `this.${keyElseIf}.bind(this)`
2432
2375
  });
2433
2376
  functionsToProcess.set(keyElseIf, {
2434
- code: processConsequent(alt, nodeName, parentNode, elseIfContext),
2435
- args: [parentNode]
2377
+ code: processConsequent(alt, nodeName, parentNode),
2378
+ args: [parentNode, "parentContext"]
2436
2379
  });
2437
2380
  alt = alt.alternate;
2438
2381
  }
2439
2382
  if (alt) {
2440
- const elseContext = new Context([], context);
2441
2383
  const keyElse = getBlockIdentifier(parentNode, nodeName, "else");
2442
2384
  mainBlock.push({ block: `this.${keyElse}.bind(this)` });
2443
2385
  functionsToProcess.set(keyElse, {
2444
- code: processConsequent(alt, nodeName, parentNode, elseContext),
2445
- args: [parentNode]
2386
+ code: processConsequent(alt, nodeName, parentNode),
2387
+ args: [parentNode, "parentContext"]
2446
2388
  });
2447
2389
  }
2448
2390
  return {
2449
2391
  mainBlock: [
2450
- `_if(${parentNode}, unwatchFns, [`,
2392
+ `_if(${parentNode}, context, [`,
2451
2393
  ...indent(mainBlock.map(({ condition, block }) => {
2452
2394
  return [
2453
2395
  "{",
@@ -2460,8 +2402,8 @@ function processIf(node, nodeName, parentNode, context) {
2460
2402
  fns: functionsToProcess
2461
2403
  };
2462
2404
  }
2463
- function processConsequent(node, nodeName, parentNode, context) {
2464
- return node.consequent.map((child, i) => processNode(child, `${nodeName}_${i}`, parentNode, context)).flat();
2405
+ function processConsequent(node, nodeName, parentNode) {
2406
+ return node.consequent.map((child, i) => processNode(child, `${nodeName}_${i}`, parentNode)).flat();
2465
2407
  }
2466
2408
  //#endregion
2467
2409
  //#region ../packages/compiler/src/render-generator/states/process-switch.state.ts
@@ -2473,18 +2415,16 @@ function processConsequent(node, nodeName, parentNode, context) {
2473
2415
  * @param node The `SwitchNode` to process.
2474
2416
  * @param nodeName Base variable name prefix for child nodes.
2475
2417
  * @param parentNode Variable name of the parent DOM node.
2476
- * @param context Current render scope context.
2477
2418
  * @returns Array of generated code lines.
2478
2419
  */
2479
- function processSwitch(node, nodeName, parentNode, context) {
2420
+ function processSwitch(node, nodeName, parentNode) {
2480
2421
  const functionsToProcess = /* @__PURE__ */ new Map();
2481
2422
  const blocks = new Array();
2482
2423
  node.cases.forEach((caseNode, i) => {
2483
- const caseContext = new Context([], context);
2484
2424
  const caseName = caseNode.condition ? getBlockIdentifier(parentNode, `${nodeName}_${i}`, "case") : getBlockIdentifier(parentNode, nodeName, "default");
2485
2425
  functionsToProcess.set(caseName, {
2486
- code: caseNode.children.map((child, i) => processNode(child, `${nodeName}_${i}_${i}`, parentNode, caseContext)).flat(),
2487
- args: [parentNode]
2426
+ code: caseNode.children.map((child, i) => processNode(child, `${nodeName}_${i}_${i}`, parentNode)).flat(),
2427
+ args: [parentNode, "parentContext"]
2488
2428
  });
2489
2429
  blocks.push({
2490
2430
  condition: caseNode.condition,
@@ -2493,7 +2433,7 @@ function processSwitch(node, nodeName, parentNode, context) {
2493
2433
  });
2494
2434
  return {
2495
2435
  mainBlock: [
2496
- `_switch(${parentNode}, unwatchFns, () => ${resolveExpression(node.expression, context)}, [`,
2436
+ `_switch(${parentNode}, context, () => ${resolveExpression(node.expression)}, [`,
2497
2437
  ...indent(blocks.map(({ condition, block }) => {
2498
2438
  return [
2499
2439
  "{",
@@ -2514,18 +2454,12 @@ function processSwitch(node, nodeName, parentNode, context) {
2514
2454
  * then appends it to the parent DOM node.
2515
2455
  *
2516
2456
  * @param node A `TextNode` or `InterpolationNode` to process.
2517
- * @param nodeName Variable name for the created text node.
2457
+ * @param nodeName - The identifier for the Text Node created
2518
2458
  * @param parentNode Variable name of the parent DOM node.
2519
- * @param _context Unused render context.
2520
2459
  * @returns Array of two generated code lines: the text node creation and the appendChild call.
2521
2460
  */
2522
- function processTextAndInterpolation(node, nodeName, parentNode, context) {
2523
- const textValue = node.type === ASTNodeType.Text ? JSON.stringify(node.value) : resolveExpression(node.expression, context);
2524
- return [
2525
- `const ${nodeName} = document.createTextNode(${textValue});`,
2526
- `${parentNode}.appendChild(${nodeName});`,
2527
- `unwatchFns.push(effect(() => ${nodeName}.textContent = ${textValue}));`
2528
- ];
2461
+ function processTextAndInterpolation(node, nodeName, parentNode) {
2462
+ return [`${node.type === ASTNodeType.Text ? `renderLiteralText(${parentNode}, context, '${node.value}')` : `renderText(${parentNode}, context, '${node.expression.text}')`}`];
2529
2463
  }
2530
2464
  //#endregion
2531
2465
  //#region ../packages/compiler/src/render-generator/render-generator.ts
@@ -2538,20 +2472,15 @@ var nodeToProcess = /* @__PURE__ */ new Map();
2538
2472
  */
2539
2473
  function generateRenderFunction(ast, cssVariableName) {
2540
2474
  nodeToProcess.clear();
2541
- const context = new Context([ROOT_NODE]);
2542
- const renderFunctions = ["_render() {", indent(`const ${ROOT_NODE} = this._root;`)];
2475
+ const renderFunctions = ["_render() {", ...indent([`const ${ROOT_NODE} = this._root;`, "const context = new Context(this)"])];
2543
2476
  if (cssVariableName) renderFunctions.push(indent(`${ROOT_NODE}.adoptedStyleSheets = [${cssVariableName}];`));
2544
- renderFunctions.push(...indent([
2545
- "let unwatchFns = [];",
2546
- ...ast.map((node, i) => [...processNode(node, i.toString(), ROOT_NODE, context)]).flat(),
2547
- "return unwatchFns;"
2548
- ]), "}");
2477
+ renderFunctions.push(...indent([...ast.map((node, i) => [...processNode(node, i.toString(), ROOT_NODE)]).flat(), "return context;"]), "}");
2549
2478
  while (nodeToProcess.size) {
2550
2479
  const [key, fnData] = nodeToProcess.entries().next().value;
2551
2480
  renderFunctions.push(`${key}(${fnData.args.join(", ")}) {`, ...indent([
2552
- "let unwatchFns = [];",
2481
+ "const context = new Context(this, parentContext)",
2553
2482
  ...fnData.fn(...fnData.args),
2554
- "return unwatchFns;"
2483
+ "return context"
2555
2484
  ]), "}");
2556
2485
  nodeToProcess.delete(key);
2557
2486
  }
@@ -2562,33 +2491,33 @@ function generateRenderFunction(ast, cssVariableName) {
2562
2491
  * For flow control nodes no single var is produced; instead multiple children
2563
2492
  * are appended directly inside the control flow block.
2564
2493
  */
2565
- function processNode(node, nodeName, parentNode, context) {
2494
+ function processNode(node, nodeName, parentNode) {
2566
2495
  switch (node.type) {
2567
2496
  case ASTNodeType.Text:
2568
- case ASTNodeType.Interpolation: return processTextAndInterpolation(node, getTextIdentifier(parentNode, nodeName), parentNode, context);
2569
- case ASTNodeType.Element: return processElement(node, getElementIdentifier(node, parentNode, nodeName), parentNode, context);
2497
+ case ASTNodeType.Interpolation: return processTextAndInterpolation(node, getTextIdentifier(parentNode, nodeName), parentNode);
2498
+ case ASTNodeType.Element: return processElement(node, getElementIdentifier(node, parentNode, nodeName), parentNode);
2570
2499
  case ASTNodeType.If:
2571
- const conditionalBlockData = processIf(node, nodeName, parentNode, context);
2500
+ const conditionalBlockData = processIf(node, nodeName, parentNode);
2572
2501
  conditionalBlockData.fns.forEach((fnBody, key) => nodeToProcess.set(key, {
2573
2502
  fn: () => fnBody.code,
2574
2503
  args: fnBody.args
2575
2504
  }));
2576
2505
  return conditionalBlockData.mainBlock;
2577
2506
  case ASTNodeType.For:
2578
- const forBlockData = processFor(node, nodeName, parentNode, context);
2507
+ const forBlockData = processFor(node, nodeName, parentNode);
2579
2508
  forBlockData.fns.forEach((fnBody, key) => nodeToProcess.set(key, {
2580
2509
  fn: () => fnBody.code,
2581
2510
  args: fnBody.args
2582
2511
  }));
2583
2512
  return forBlockData.mainBlock;
2584
2513
  case ASTNodeType.Switch:
2585
- const switchBlockData = processSwitch(node, nodeName, parentNode, context);
2514
+ const switchBlockData = processSwitch(node, nodeName, parentNode);
2586
2515
  switchBlockData.fns.forEach((fnBody, key) => nodeToProcess.set(key, {
2587
2516
  fn: () => fnBody.code,
2588
2517
  args: fnBody.args
2589
2518
  }));
2590
2519
  return switchBlockData.mainBlock;
2591
- case ASTNodeType.ConstDeclaration: return processConstDeclaration(node, nodeName, parentNode, context);
2520
+ case ASTNodeType.ConstDeclaration: return processConstDeclaration(node, nodeName, parentNode);
2592
2521
  default: return [];
2593
2522
  }
2594
2523
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaendar/compiler",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
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.9",
20
- "@xaendar/types": "0.6.9",
19
+ "@xaendar/common": "0.6.10",
20
+ "@xaendar/types": "0.6.10",
21
21
  "typescript": "^6.0.3"
22
22
  }
23
23
  }