@xaendar/compiler 0.6.10 → 0.6.12
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 +22 -11
- package/package.json +3 -3
|
@@ -390,23 +390,33 @@ function consumeEvent(cursor, _context) {
|
|
|
390
390
|
let read = true;
|
|
391
391
|
let event = "";
|
|
392
392
|
let retVal;
|
|
393
|
+
let deep = 0;
|
|
393
394
|
cursor.advance();
|
|
394
395
|
while (read) switch (cursor.peek()) {
|
|
395
396
|
case 32:
|
|
396
397
|
case 47:
|
|
397
398
|
case 62:
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
399
|
+
if (deep === 0) {
|
|
400
|
+
retVal = {
|
|
401
|
+
state: LexerState.TAG_BODY,
|
|
402
|
+
tokens: [{
|
|
403
|
+
type: TokenType.EVENT,
|
|
404
|
+
parts: [event]
|
|
405
|
+
}]
|
|
406
|
+
};
|
|
407
|
+
read = false;
|
|
408
|
+
}
|
|
406
409
|
break;
|
|
407
|
-
|
|
410
|
+
case 40:
|
|
411
|
+
deep++;
|
|
412
|
+
break;
|
|
413
|
+
case 41:
|
|
414
|
+
deep--;
|
|
415
|
+
break;
|
|
416
|
+
default: if (deep === 0) {
|
|
408
417
|
cursor.advance();
|
|
409
418
|
event = `${event}${cursor.currentChar.value}`;
|
|
419
|
+
}
|
|
410
420
|
}
|
|
411
421
|
return retVal;
|
|
412
422
|
}
|
|
@@ -1952,7 +1962,7 @@ function processConstDeclaration(node, _nodeName, _parentNode) {
|
|
|
1952
1962
|
function processElement(node, nodeName, parentNode) {
|
|
1953
1963
|
const attributes = mapAttributes(node.attributes);
|
|
1954
1964
|
const events = mapEvents(node.events);
|
|
1955
|
-
const code = [`
|
|
1965
|
+
const code = [`const ${nodeName} = _renderElement(${parentNode}, context, '${node.tagName}',`];
|
|
1956
1966
|
attributes.length ? code.push(...indent([
|
|
1957
1967
|
"[",
|
|
1958
1968
|
...indent(attributes),
|
|
@@ -1963,6 +1973,7 @@ function processElement(node, nodeName, parentNode) {
|
|
|
1963
1973
|
...indent(events),
|
|
1964
1974
|
"]"
|
|
1965
1975
|
]), ")") : code[code.length - 1] = `${code[code.length - 1]} [])`;
|
|
1976
|
+
code.push(...node.children.map((child, i) => processNode(child, i.toString(), nodeName)).flat());
|
|
1966
1977
|
return code;
|
|
1967
1978
|
}
|
|
1968
1979
|
/**
|
|
@@ -2459,7 +2470,7 @@ function processSwitch(node, nodeName, parentNode) {
|
|
|
2459
2470
|
* @returns Array of two generated code lines: the text node creation and the appendChild call.
|
|
2460
2471
|
*/
|
|
2461
2472
|
function processTextAndInterpolation(node, nodeName, parentNode) {
|
|
2462
|
-
return [`${node.type === ASTNodeType.Text ? `
|
|
2473
|
+
return [`${node.type === ASTNodeType.Text ? `_renderLiteralText(${parentNode}, context, '${node.value}')` : `_renderText(${parentNode}, context, '${node.expression.text}')`}`];
|
|
2463
2474
|
}
|
|
2464
2475
|
//#endregion
|
|
2465
2476
|
//#region ../packages/compiler/src/render-generator/render-generator.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaendar/compiler",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
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.12",
|
|
20
|
+
"@xaendar/types": "0.6.12",
|
|
21
21
|
"typescript": "^6.0.3"
|
|
22
22
|
}
|
|
23
23
|
}
|