shopware-twig-parser 0.3.2 → 0.4.0

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.
@@ -3,7 +3,7 @@ type Tree = {
3
3
  };
4
4
  type TemplateNode = {
5
5
  type: "template";
6
- children: (TwigStatementDirectiveNode | HtmlElementNode | ContentNode | HtmlDoctypeNode | HtmlNamedEntityNode | HtmlNumericEntityNode)[];
6
+ children: (TwigStatementDirectiveNode | HtmlElementNode | ContentNode | HtmlDoctypeNode | HtmlNamedEntityNode | HtmlNumericEntityNode | TwigCommentNode | VueInterpolationNode)[];
7
7
  };
8
8
  type TwigStatementDirectiveNode = {
9
9
  type: "twig_statement_directive";
@@ -11,7 +11,7 @@ type TwigStatementDirectiveNode = {
11
11
  variable?: TwigVariableNode;
12
12
  function?: TwigFunctionNode;
13
13
  condition?: TwigConditionNode;
14
- children?: (TwigStatementDirectiveNode | ContentNode | HtmlElementNode | HtmlDoctypeNode | HtmlNamedEntityNode | HtmlNumericEntityNode)[];
14
+ children?: (TwigStatementDirectiveNode | ContentNode | HtmlElementNode | HtmlDoctypeNode | HtmlNamedEntityNode | HtmlNumericEntityNode | TwigCommentNode | VueInterpolationNode)[];
15
15
  };
16
16
  type TwigConditionNode = {
17
17
  type: "twig_condition";
@@ -46,7 +46,7 @@ type HtmlElementNode = {
46
46
  type: "html_element";
47
47
  name: string;
48
48
  attributes?: HtmlAttributeNode[];
49
- children: (HtmlElementNode | ContentNode | HtmlNamedEntityNode | HtmlNumericEntityNode)[];
49
+ children: (HtmlElementNode | ContentNode | HtmlNamedEntityNode | HtmlNumericEntityNode | TwigCommentNode | VueInterpolationNode | TwigStatementDirectiveNode)[];
50
50
  void?: boolean;
51
51
  };
52
52
  type HtmlDoctypeNode = {
@@ -60,6 +60,14 @@ type HtmlNumericEntityNode = {
60
60
  type: "html_numeric_entity";
61
61
  content: string;
62
62
  };
63
+ type TwigCommentNode = {
64
+ type: "twig_comment";
65
+ content: string;
66
+ };
67
+ type VueInterpolationNode = {
68
+ type: "vue_interpolation";
69
+ expression: string;
70
+ };
63
71
  export declare function parse(content: string): Tree;
64
72
  export {};
65
73
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,KAAK,IAAI,GAAG;IACV,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,CACN,0BAA0B,GAC1B,eAAe,GACf,WAAW,GACX,eAAe,GACf,mBAAmB,GACnB,qBAAqB,CACxB,EAAE,CAAC;CACL,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,0BAA0B,CAAC;IACjC,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,CAAC,EAAE,CACP,0BAA0B,GAC1B,WAAW,GACX,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,qBAAqB,CACxB,EAAE,CAAC;CACL,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,kBAAkB,CAAC;CAChC,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,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IACjC,QAAQ,EAAE,CACN,eAAe,GACf,WAAW,GACX,mBAAmB,GACnB,qBAAqB,GACrB,eAAe,GACf,oBAAoB,GACpB,0BAA0B,CAC7B,EAAE,CAAC;IACJ,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAkFF,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CA6tB3C"}
@@ -9,58 +9,58 @@ const tree_sitter_shopware_twig_1 = __importDefault(require("tree-sitter-shopwar
9
9
  const parser = new tree_sitter_1.default();
10
10
  // @ts-expect-error
11
11
  parser.setLanguage(tree_sitter_shopware_twig_1.default);
12
- function parse(content) {
13
- const tree = parser.parse(content);
14
- function convertNode(node) {
15
- if (node.type === "statement_directive") {
16
- // Check for if_statement
17
- const ifStatement = node.children.find((child) => child.type === "if_statement");
18
- if (ifStatement) {
19
- const conditionalNode = ifStatement.children.find((child) => child.type === "conditional");
20
- const variableNode = ifStatement.children.find((child) => child.type === "variable");
21
- if (conditionalNode && conditionalNode.text === "if" && variableNode) {
22
- return {
23
- type: "if",
24
- expression: variableNode.text,
25
- };
26
- }
27
- }
28
- // Check for tag_statement
29
- const tagStatement = node.children.find((child) => child.type === "tag_statement");
30
- const functionCall = node.children.find((child) => child.type === "function_call");
31
- if (tagStatement) {
32
- const tagNode = tagStatement.children.find((child) => child.type === "tag");
33
- const conditionalNode = tagStatement.children.find((child) => child.type === "conditional");
34
- const variableNode = tagStatement.children.find((child) => child.type === "variable");
35
- if (tagNode && tagNode.text === "block" && variableNode) {
36
- return {
37
- type: "block",
38
- name: variableNode.text,
39
- };
40
- }
41
- else if (tagNode && tagNode.text === "endblock") {
42
- return {
43
- type: "endblock",
44
- };
45
- }
46
- else if (conditionalNode && conditionalNode.text === "endif") {
47
- return {
48
- type: "endif",
49
- };
50
- }
51
- }
52
- else if (functionCall) {
53
- const functionIdentifier = functionCall.children.find((child) => child.type === "function_identifier");
54
- if (functionIdentifier) {
55
- return {
56
- type: "function",
57
- functionName: functionIdentifier.text,
58
- };
59
- }
12
+ function convertStatementDirective(node) {
13
+ if (node.type === "statement_directive") {
14
+ // Check for if_statement
15
+ const ifStatement = node.children.find((child) => child.type === "if_statement");
16
+ if (ifStatement) {
17
+ const conditionalNode = ifStatement.children.find((child) => child.type === "conditional");
18
+ const variableNode = ifStatement.children.find((child) => child.type === "variable");
19
+ if (conditionalNode && conditionalNode.text === "if" && variableNode) {
20
+ return {
21
+ type: "if",
22
+ expression: variableNode.text,
23
+ };
24
+ }
25
+ }
26
+ // Check for tag_statement
27
+ const tagStatement = node.children.find((child) => child.type === "tag_statement");
28
+ const functionCall = node.children.find((child) => child.type === "function_call");
29
+ if (tagStatement) {
30
+ const tagNode = tagStatement.children.find((child) => child.type === "tag");
31
+ const conditionalNode = tagStatement.children.find((child) => child.type === "conditional");
32
+ const variableNode = tagStatement.children.find((child) => child.type === "variable");
33
+ if (tagNode && tagNode.text === "block" && variableNode) {
34
+ return {
35
+ type: "block",
36
+ name: variableNode.text,
37
+ };
38
+ }
39
+ else if (tagNode && tagNode.text === "endblock") {
40
+ return {
41
+ type: "endblock",
42
+ };
43
+ }
44
+ else if (conditionalNode && conditionalNode.text === "endif") {
45
+ return {
46
+ type: "endif",
47
+ };
48
+ }
49
+ }
50
+ else if (functionCall) {
51
+ const functionIdentifier = functionCall.children.find((child) => child.type === "function_identifier");
52
+ if (functionIdentifier) {
53
+ return {
54
+ type: "function",
55
+ functionName: functionIdentifier.text,
56
+ };
60
57
  }
61
58
  }
62
- return null;
63
59
  }
60
+ return null;
61
+ }
62
+ function parse(content) {
63
+ const tree = parser.parse(content);
64
64
  // First pass: convert all nodes to intermediate format
65
65
  const rawNodes = [];
66
66
  // Also collect content nodes
@@ -84,6 +84,182 @@ function parse(content) {
84
84
  }
85
85
  return null;
86
86
  }
87
+ function convertTwigComment(node) {
88
+ if (node.type === "twig_comment") {
89
+ // Extract content between {# and #}
90
+ const text = node.text;
91
+ const content = text.slice(2, -2).trim();
92
+ return {
93
+ type: "twig_comment",
94
+ content,
95
+ };
96
+ }
97
+ return null;
98
+ }
99
+ function convertVueInterpolation(node) {
100
+ if (node.type === "vue_interpolation") {
101
+ // Find the interpolation_content child
102
+ const contentNode = node.children.find((child) => child.type === "interpolation_content");
103
+ return {
104
+ type: "vue_interpolation",
105
+ expression: contentNode ? contentNode.text.trim() : "",
106
+ };
107
+ }
108
+ return null;
109
+ }
110
+ function buildNestedStructureForElement(nodes) {
111
+ const result = [];
112
+ const stack = [];
113
+ for (const node of nodes) {
114
+ if (node.type === "block") {
115
+ const blockNode = {
116
+ type: "twig_statement_directive",
117
+ tag: {
118
+ type: "twig_tag",
119
+ name: "block",
120
+ },
121
+ variable: {
122
+ type: "twig_variable",
123
+ content: node.name,
124
+ },
125
+ children: [],
126
+ };
127
+ if (stack.length > 0) {
128
+ const parent = stack[stack.length - 1];
129
+ if (parent && parent.children) {
130
+ parent.children.push(blockNode);
131
+ }
132
+ }
133
+ else {
134
+ result.push(blockNode);
135
+ }
136
+ stack.push(blockNode);
137
+ }
138
+ else if (node.type === "endblock") {
139
+ stack.pop();
140
+ }
141
+ else if (node.type === "if") {
142
+ const ifNode = {
143
+ type: "twig_statement_directive",
144
+ condition: {
145
+ type: "twig_condition",
146
+ expression: {
147
+ type: "twig_expression",
148
+ content: node.expression,
149
+ },
150
+ },
151
+ children: [],
152
+ };
153
+ if (stack.length > 0) {
154
+ const parent = stack[stack.length - 1];
155
+ if (parent && parent.children) {
156
+ parent.children.push(ifNode);
157
+ }
158
+ }
159
+ else {
160
+ result.push(ifNode);
161
+ }
162
+ stack.push(ifNode);
163
+ }
164
+ else if (node.type === "endif") {
165
+ stack.pop();
166
+ }
167
+ else if (node.type === "function") {
168
+ const functionNode = {
169
+ type: "twig_statement_directive",
170
+ function: {
171
+ type: "twig_function",
172
+ name: node.functionName,
173
+ },
174
+ };
175
+ if (stack.length > 0) {
176
+ const parent = stack[stack.length - 1];
177
+ if (parent && parent.children) {
178
+ parent.children.push(functionNode);
179
+ }
180
+ }
181
+ else {
182
+ result.push(functionNode);
183
+ }
184
+ }
185
+ else if (node.type === "content") {
186
+ const contentNode = {
187
+ type: "content",
188
+ content: node.content,
189
+ };
190
+ if (stack.length > 0) {
191
+ const parent = stack[stack.length - 1];
192
+ if (parent && parent.children) {
193
+ parent.children.push(contentNode);
194
+ }
195
+ }
196
+ else {
197
+ result.push(contentNode);
198
+ }
199
+ }
200
+ else if (node.type === "html_element" && "name" in node) {
201
+ const htmlNode = node;
202
+ if (stack.length > 0) {
203
+ const parent = stack[stack.length - 1];
204
+ if (parent && parent.children) {
205
+ parent.children.push(htmlNode);
206
+ }
207
+ }
208
+ else {
209
+ result.push(htmlNode);
210
+ }
211
+ }
212
+ else if (node.type === "html_named_entity" && "content" in node) {
213
+ const entityNode = node;
214
+ if (stack.length > 0) {
215
+ const parent = stack[stack.length - 1];
216
+ if (parent && parent.children) {
217
+ parent.children.push(entityNode);
218
+ }
219
+ }
220
+ else {
221
+ result.push(entityNode);
222
+ }
223
+ }
224
+ else if (node.type === "html_numeric_entity" && "content" in node) {
225
+ const entityNode = node;
226
+ if (stack.length > 0) {
227
+ const parent = stack[stack.length - 1];
228
+ if (parent && parent.children) {
229
+ parent.children.push(entityNode);
230
+ }
231
+ }
232
+ else {
233
+ result.push(entityNode);
234
+ }
235
+ }
236
+ else if (node.type === "twig_comment" && "content" in node) {
237
+ const commentNode = node;
238
+ if (stack.length > 0) {
239
+ const parent = stack[stack.length - 1];
240
+ if (parent && parent.children) {
241
+ parent.children.push(commentNode);
242
+ }
243
+ }
244
+ else {
245
+ result.push(commentNode);
246
+ }
247
+ }
248
+ else if (node.type === "vue_interpolation" && "expression" in node) {
249
+ const interpolationNode = node;
250
+ if (stack.length > 0) {
251
+ const parent = stack[stack.length - 1];
252
+ if (parent && parent.children) {
253
+ parent.children.push(interpolationNode);
254
+ }
255
+ }
256
+ else {
257
+ result.push(interpolationNode);
258
+ }
259
+ }
260
+ }
261
+ return result;
262
+ }
87
263
  function convertHtmlElement(node) {
88
264
  if (node.type === "html_element") {
89
265
  // Check for self-closing tag first
@@ -151,11 +327,12 @@ function parse(content) {
151
327
  }
152
328
  attributes.push(attribute);
153
329
  }
154
- const elementChildren = [];
330
+ // Collect raw children first (before nesting processing)
331
+ const rawChildren = [];
155
332
  // Process all children that are not start/end tags
156
333
  for (const child of node.children) {
157
334
  if (child.type === "content") {
158
- elementChildren.push({
335
+ rawChildren.push({
159
336
  type: "content",
160
337
  content: child.text,
161
338
  });
@@ -163,16 +340,36 @@ function parse(content) {
163
340
  else if (child.type === "html_element") {
164
341
  const nestedElement = convertHtmlElement(child);
165
342
  if (nestedElement) {
166
- elementChildren.push(nestedElement);
343
+ rawChildren.push(nestedElement);
167
344
  }
168
345
  }
169
346
  else if (child.type === "html_entity") {
170
347
  const entityNode = convertHtmlEntity(child);
171
348
  if (entityNode) {
172
- elementChildren.push(entityNode);
349
+ rawChildren.push(entityNode);
350
+ }
351
+ }
352
+ else if (child.type === "twig_comment") {
353
+ const commentNode = convertTwigComment(child);
354
+ if (commentNode) {
355
+ rawChildren.push(commentNode);
356
+ }
357
+ }
358
+ else if (child.type === "vue_interpolation") {
359
+ const interpolationNode = convertVueInterpolation(child);
360
+ if (interpolationNode) {
361
+ rawChildren.push(interpolationNode);
362
+ }
363
+ }
364
+ else if (child.type === "statement_directive") {
365
+ const converted = convertStatementDirective(child);
366
+ if (converted) {
367
+ rawChildren.push(converted);
173
368
  }
174
369
  }
175
370
  }
371
+ // Apply block nesting within this HTML element's scope
372
+ const elementChildren = buildNestedStructureForElement(rawChildren);
176
373
  const result = {
177
374
  type: "html_element",
178
375
  name: tagName.text,
@@ -212,8 +409,20 @@ function parse(content) {
212
409
  allNodes.push(entityNode);
213
410
  }
214
411
  }
412
+ else if (child.type === "twig_comment") {
413
+ const commentNode = convertTwigComment(child);
414
+ if (commentNode) {
415
+ allNodes.push(commentNode);
416
+ }
417
+ }
418
+ else if (child.type === "vue_interpolation") {
419
+ const interpolationNode = convertVueInterpolation(child);
420
+ if (interpolationNode) {
421
+ allNodes.push(interpolationNode);
422
+ }
423
+ }
215
424
  else {
216
- const converted = convertNode(child);
425
+ const converted = convertStatementDirective(child);
217
426
  if (converted) {
218
427
  rawNodes.push(converted);
219
428
  allNodes.push(converted);
@@ -386,6 +595,34 @@ function parse(content) {
386
595
  result.push(entityNode);
387
596
  }
388
597
  }
598
+ else if (node.type === "twig_comment" && "content" in node) {
599
+ const commentNode = node;
600
+ if (stack.length > 0) {
601
+ // Add to the current parent's children
602
+ const parent = stack[stack.length - 1];
603
+ if (parent && parent.children) {
604
+ parent.children.push(commentNode);
605
+ }
606
+ }
607
+ else {
608
+ // Add to root level
609
+ result.push(commentNode);
610
+ }
611
+ }
612
+ else if (node.type === "vue_interpolation" && "expression" in node) {
613
+ const interpolationNode = node;
614
+ if (stack.length > 0) {
615
+ // Add to the current parent's children
616
+ const parent = stack[stack.length - 1];
617
+ if (parent && parent.children) {
618
+ parent.children.push(interpolationNode);
619
+ }
620
+ }
621
+ else {
622
+ // Add to root level
623
+ result.push(interpolationNode);
624
+ }
625
+ }
389
626
  }
390
627
  return result;
391
628
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../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I,IAAI,EAAE,CAAC;gBACpE,MAAM,UAAU,GAAG,IAA6B,CAAC;gBAEjD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACrB,uCAAuC;oBACvC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;oBACvC,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;wBAC9B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBACnC,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,oBAAoB;oBACpB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,QAAQ,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO;QACL,QAAQ,EAAE;YACR,IAAI,EAAE,UAAU;YAChB,QAAQ;SACT;KACF,CAAC;AACJ,CAAC","sourcesContent":["import Parser from \"tree-sitter\";\nimport ShopwareTwig from \"tree-sitter-shopware-twig\";\n\ntype Tree = {\n rootNode: TemplateNode;\n};\n\ntype TemplateNode = {\n type: \"template\";\n children: (\n | TwigStatementDirectiveNode\n | HtmlElementNode\n | ContentNode\n | HtmlDoctypeNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n )[];\n};\n\ntype TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\";\n tag?: TwigTagNode;\n variable?: TwigVariableNode;\n function?: TwigFunctionNode;\n condition?: TwigConditionNode;\n children?: (\n | TwigStatementDirectiveNode\n | ContentNode\n | HtmlElementNode\n | HtmlDoctypeNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n )[];\n};\n\ntype TwigConditionNode = {\n type: \"twig_condition\";\n expression: TwigExpressionNode;\n};\n\ntype TwigExpressionNode = {\n type: \"twig_expression\";\n content: string;\n};\n\ntype ContentNode = {\n type: \"content\";\n content: string;\n};\n\ntype TwigTagNode = {\n type: \"twig_tag\";\n name: string;\n};\n\ntype TwigVariableNode = {\n type: \"twig_variable\";\n content: string;\n};\n\ntype TwigFunctionNode = {\n type: \"twig_function\";\n name: string;\n};\n\ntype HtmlAttributeNode = {\n type: \"html_attribute\";\n name: string;\n value?: string;\n};\n\ntype HtmlElementNode = {\n type: \"html_element\";\n name: string;\n attributes?: HtmlAttributeNode[];\n children: (\n | HtmlElementNode\n | ContentNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n )[];\n void?: boolean;\n};\n\ntype HtmlDoctypeNode = {\n type: \"doctype\";\n};\n\ntype HtmlNamedEntityNode = {\n type: \"html_named_entity\";\n content: string;\n};\n\ntype HtmlNumericEntityNode = {\n type: \"html_numeric_entity\";\n content: string;\n};\n\nconst parser = new Parser();\n// @ts-expect-error\nparser.setLanguage(ShopwareTwig);\n\nexport function parse(content: string): Tree {\n const tree = parser.parse(content);\n\n function convertNode(node: any): {\n type: \"block\" | \"endblock\" | \"function\" | \"if\" | \"endif\";\n name?: string;\n functionName?: string;\n expression?: string;\n } | null {\n if (node.type === \"statement_directive\") {\n // Check for if_statement\n const ifStatement = node.children.find(\n (child: any) => child.type === \"if_statement\"\n );\n if (ifStatement) {\n const conditionalNode = ifStatement.children.find(\n (child: any) => child.type === \"conditional\"\n );\n const variableNode = ifStatement.children.find(\n (child: any) => child.type === \"variable\"\n );\n\n if (conditionalNode && conditionalNode.text === \"if\" && variableNode) {\n return {\n type: \"if\",\n expression: variableNode.text,\n };\n }\n }\n\n // Check for tag_statement\n const tagStatement = node.children.find(\n (child: any) => child.type === \"tag_statement\"\n );\n const functionCall = node.children.find(\n (child: any) => child.type === \"function_call\"\n );\n\n if (tagStatement) {\n const tagNode = tagStatement.children.find(\n (child: any) => child.type === \"tag\"\n );\n const conditionalNode = tagStatement.children.find(\n (child: any) => child.type === \"conditional\"\n );\n const variableNode = tagStatement.children.find(\n (child: any) => child.type === \"variable\"\n );\n\n if (tagNode && tagNode.text === \"block\" && variableNode) {\n return {\n type: \"block\",\n name: variableNode.text,\n };\n } else if (tagNode && tagNode.text === \"endblock\") {\n return {\n type: \"endblock\",\n };\n } else if (conditionalNode && conditionalNode.text === \"endif\") {\n return {\n type: \"endif\",\n };\n }\n } else if (functionCall) {\n const functionIdentifier = functionCall.children.find(\n (child: any) => child.type === \"function_identifier\"\n );\n\n if (functionIdentifier) {\n return {\n type: \"function\",\n functionName: functionIdentifier.text,\n };\n }\n }\n }\n return null;\n }\n\n // First pass: convert all nodes to intermediate format\n const rawNodes: {\n type: \"block\" | \"endblock\" | \"function\" | \"if\" | \"endif\";\n name?: string;\n functionName?: string;\n expression?: string;\n }[] = [];\n\n // Also collect content nodes\n const allNodes: Array<\n | {\n type:\n | \"block\"\n | \"endblock\"\n | \"function\"\n | \"if\"\n | \"endif\"\n | \"content\"\n | \"html_element\"\n | \"doctype\";\n name?: string;\n functionName?: string;\n expression?: string;\n content?: string;\n }\n | HtmlElementNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n > = [];\n\n function convertHtmlEntity(\n node: any\n ): HtmlNamedEntityNode | HtmlNumericEntityNode | null {\n if (node.type === \"html_entity\") {\n const entityText = node.text;\n\n // Check if it's a numeric entity (starts with &#)\n if (entityText.startsWith(\"&#\")) {\n return {\n type: \"html_numeric_entity\",\n content: entityText,\n };\n } else if (entityText.startsWith(\"&\")) {\n return {\n type: \"html_named_entity\",\n content: entityText,\n };\n }\n }\n return null;\n }\n\n function convertHtmlElement(node: any): HtmlElementNode | null {\n if (node.type === \"html_element\") {\n // Check for self-closing tag first\n const selfClosingTag = node.children.find(\n (child: any) => child.type === \"html_self_closing_tag\"\n );\n\n // Check for void tag\n const voidTag = node.children.find(\n (child: any) => child.type === \"html_void_tag\"\n );\n\n // Find the start tag to get the element name\n const startTag = node.children.find(\n (child: any) => child.type === \"html_start_tag\"\n );\n\n // Use self-closing tag, void tag, or start tag in that order of preference\n const tagToUse = selfClosingTag || voidTag || startTag;\n if (!tagToUse) return null;\n\n let tagName: any;\n if (voidTag) {\n // For void tags, the tag name is nested inside html_start_tag within the void tag\n const voidStartTag = voidTag.children.find(\n (child: any) => child.type === \"html_start_tag\"\n );\n tagName = voidStartTag?.children.find(\n (child: any) => child.type === \"html_tag_name\"\n );\n } else {\n // For regular and self-closing tags, tag name is directly in the tag\n tagName = tagToUse.children.find(\n (child: any) => child.type === \"html_tag_name\"\n );\n }\n if (!tagName) return null;\n\n // Check if this is a void element\n const hasVoidTag = node.children.some(\n (child: any) => child.type === \"html_void_tag\"\n );\n const hasSelfClosingTag = node.children.some(\n (child: any) => child.type === \"html_self_closing_tag\"\n );\n const isVoid = hasVoidTag || hasSelfClosingTag;\n\n // Parse attributes from the tag (either self-closing or start tag)\n const attributes: HtmlAttributeNode[] = [];\n let attributeNodes;\n\n if (voidTag) {\n // For void tags, attributes are in the nested html_start_tag\n const voidStartTag = voidTag.children.find(\n (child: any) => child.type === \"html_start_tag\"\n );\n attributeNodes = voidStartTag\n ? voidStartTag.children.filter(\n (child: any) => child.type === \"html_attribute\"\n )\n : [];\n } else {\n // For regular and self-closing tags, attributes are directly in the tag\n attributeNodes = tagToUse.children.filter(\n (child: any) => child.type === \"html_attribute\"\n );\n }\n\n for (const attrNode of attributeNodes) {\n const nameNode = attrNode.children.find(\n (child: any) => child.type === \"html_attribute_name\"\n );\n if (!nameNode) continue;\n\n const valueNode = attrNode.children.find(\n (child: any) => child.type === \"html_attribute_value\"\n );\n const quotedValueNode = attrNode.children.find(\n (child: any) => child.type === \"html_quoted_attribute_value\"\n );\n\n let value: string | undefined;\n if (quotedValueNode) {\n // For quoted values, find the inner html_attribute_value\n const innerValueNode = quotedValueNode.children.find(\n (child: any) => child.type === \"html_attribute_value\"\n );\n value = innerValueNode ? innerValueNode.text : undefined;\n } else if (valueNode) {\n value = valueNode.text;\n }\n\n const attribute: HtmlAttributeNode = {\n type: \"html_attribute\",\n name: nameNode.text,\n };\n\n // Only include value property if there's actually a value\n if (value !== undefined) {\n attribute.value = value;\n }\n\n attributes.push(attribute);\n }\n\n const elementChildren: (\n | HtmlElementNode\n | ContentNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n )[] = [];\n\n // Process all children that are not start/end tags\n for (const child of node.children) {\n if (child.type === \"content\") {\n elementChildren.push({\n type: \"content\",\n content: child.text,\n });\n } else if (child.type === \"html_element\") {\n const nestedElement = convertHtmlElement(child);\n if (nestedElement) {\n elementChildren.push(nestedElement);\n }\n } else if (child.type === \"html_entity\") {\n const entityNode = convertHtmlEntity(child);\n if (entityNode) {\n elementChildren.push(entityNode);\n }\n }\n }\n\n const result: HtmlElementNode = {\n type: \"html_element\",\n name: tagName.text,\n children: elementChildren,\n };\n\n if (attributes.length > 0) {\n result.attributes = attributes;\n }\n\n if (isVoid) {\n result.void = true;\n }\n\n return result;\n }\n return null;\n }\n\n for (const child of tree.rootNode.children) {\n if (child.type === \"content\") {\n allNodes.push({\n type: \"content\",\n content: child.text,\n });\n } else if (child.type === \"html_element\") {\n const htmlElement = convertHtmlElement(child);\n if (htmlElement) {\n allNodes.push(htmlElement);\n }\n } else if (child.type === \"html_doctype\") {\n allNodes.push({\n type: \"doctype\",\n });\n } else if (child.type === \"html_entity\") {\n const entityNode = convertHtmlEntity(child);\n if (entityNode) {\n allNodes.push(entityNode);\n }\n } else {\n const converted = convertNode(child);\n if (converted) {\n rawNodes.push(converted);\n allNodes.push(converted);\n }\n }\n }\n\n // Second pass: build nested structure using a stack\n function buildNestedStructure(\n nodes: Array<\n | {\n type:\n | \"block\"\n | \"endblock\"\n | \"function\"\n | \"if\"\n | \"endif\"\n | \"content\"\n | \"html_element\"\n | \"doctype\";\n name?: string;\n functionName?: string;\n expression?: string;\n content?: string;\n }\n | HtmlElementNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n >\n ): (\n | TwigStatementDirectiveNode\n | HtmlElementNode\n | ContentNode\n | HtmlDoctypeNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n )[] {\n const result: (\n | TwigStatementDirectiveNode\n | HtmlElementNode\n | ContentNode\n | HtmlDoctypeNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n )[] = [];\n const stack: TwigStatementDirectiveNode[] = [];\n\n for (const node of nodes) {\n if (node.type === \"block\") {\n const blockNode: TwigStatementDirectiveNode = {\n tag: {\n type: \"twig_tag\",\n name: \"block\",\n },\n type: \"twig_statement_directive\",\n variable: {\n type: \"twig_variable\",\n content: node.name!,\n },\n children: [],\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(blockNode);\n }\n } else {\n // Add to root level\n result.push(blockNode);\n }\n\n // Push to stack for nesting\n stack.push(blockNode);\n } else if (node.type === \"endblock\") {\n // Pop from stack when we encounter an endblock\n stack.pop();\n } else if (node.type === \"if\") {\n const ifNode: TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\",\n condition: {\n type: \"twig_condition\",\n expression: {\n type: \"twig_expression\",\n content: node.expression!,\n },\n },\n children: [],\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(ifNode);\n }\n } else {\n // Add to root level\n result.push(ifNode);\n }\n\n // Push to stack for nesting\n stack.push(ifNode);\n } else if (node.type === \"endif\") {\n // Pop from stack when we encounter an endif\n stack.pop();\n } else if (node.type === \"function\") {\n const functionNode: TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\",\n function: {\n type: \"twig_function\",\n name: node.functionName!,\n },\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(functionNode);\n }\n } else {\n // Add to root level\n result.push(functionNode);\n }\n } else if (node.type === \"content\") {\n const contentNode: ContentNode = {\n type: \"content\",\n content: node.content!,\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(contentNode);\n }\n } else {\n // Content at root level - this shouldn't happen in well-formed templates\n // but we'll handle it gracefully\n result.push({\n type: \"twig_statement_directive\",\n children: [contentNode],\n });\n }\n } else if (node.type === \"html_element\" && \"name\" in node) {\n // HTML elements are already processed and can be added directly\n const htmlNode = node as HtmlElementNode;\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(htmlNode);\n }\n } else {\n // Add to root level\n result.push(htmlNode);\n }\n } else if (node.type === \"doctype\") {\n const doctypeNode: HtmlDoctypeNode = {\n type: \"doctype\",\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(doctypeNode);\n }\n } else {\n // Add to root level\n result.push(doctypeNode);\n }\n } else if (node.type === \"html_named_entity\" && \"content\" in node) {\n const entityNode = node as HtmlNamedEntityNode;\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(entityNode);\n }\n } else {\n // Add to root level\n result.push(entityNode);\n }\n } else if (node.type === \"html_numeric_entity\" && \"content\" in node) {\n const entityNode = node as HtmlNumericEntityNode;\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(entityNode);\n }\n } else {\n // Add to root level\n result.push(entityNode);\n }\n }\n }\n\n return result;\n }\n\n const children = buildNestedStructure(allNodes);\n\n return {\n rootNode: {\n type: \"template\",\n children,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAmMA,sBA6tBC;AAh6BD,8DAAiC;AACjC,0FAAqD;AAkHrD,MAAM,MAAM,GAAG,IAAI,qBAAM,EAAE,CAAC;AAC5B,mBAAmB;AACnB,MAAM,CAAC,WAAW,CAAC,mCAAY,CAAC,CAAC;AAEjC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C,IAAI,CAAC,iBAAiB,CAAC,CAAC;gBACjC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,QAAQ,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO;QACL,QAAQ,EAAE;YACR,IAAI,EAAE,UAAU;YAChB,QAAQ;SACT;KACF,CAAC;AACJ,CAAC","sourcesContent":["import Parser from \"tree-sitter\";\nimport ShopwareTwig from \"tree-sitter-shopware-twig\";\n\ntype Tree = {\n rootNode: TemplateNode;\n};\n\ntype TemplateNode = {\n type: \"template\";\n children: (\n | TwigStatementDirectiveNode\n | HtmlElementNode\n | ContentNode\n | HtmlDoctypeNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n )[];\n};\n\ntype TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\";\n tag?: TwigTagNode;\n variable?: TwigVariableNode;\n function?: TwigFunctionNode;\n condition?: TwigConditionNode;\n children?: (\n | TwigStatementDirectiveNode\n | ContentNode\n | HtmlElementNode\n | HtmlDoctypeNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n )[];\n};\n\ntype TwigConditionNode = {\n type: \"twig_condition\";\n expression: TwigExpressionNode;\n};\n\ntype TwigExpressionNode = {\n type: \"twig_expression\";\n content: string;\n};\n\ntype ContentNode = {\n type: \"content\";\n content: string;\n};\n\ntype TwigTagNode = {\n type: \"twig_tag\";\n name: string;\n};\n\ntype TwigVariableNode = {\n type: \"twig_variable\";\n content: string;\n};\n\ntype TwigFunctionNode = {\n type: \"twig_function\";\n name: string;\n};\n\ntype HtmlAttributeNode = {\n type: \"html_attribute\";\n name: string;\n value?: string;\n};\n\ntype HtmlElementNode = {\n type: \"html_element\";\n name: string;\n attributes?: HtmlAttributeNode[];\n children: (\n | HtmlElementNode\n | ContentNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n | TwigStatementDirectiveNode\n )[];\n void?: boolean;\n};\n\ntype HtmlDoctypeNode = {\n type: \"doctype\";\n};\n\ntype HtmlNamedEntityNode = {\n type: \"html_named_entity\";\n content: string;\n};\n\ntype HtmlNumericEntityNode = {\n type: \"html_numeric_entity\";\n content: string;\n};\n\ntype TwigCommentNode = {\n type: \"twig_comment\";\n content: string;\n};\n\ntype VueInterpolationNode = {\n type: \"vue_interpolation\";\n expression: string;\n};\n\nconst parser = new Parser();\n// @ts-expect-error\nparser.setLanguage(ShopwareTwig);\n\nfunction convertStatementDirective(node: any): {\n type: \"block\" | \"endblock\" | \"function\" | \"if\" | \"endif\";\n name?: string;\n functionName?: string;\n expression?: string;\n} | null {\n if (node.type === \"statement_directive\") {\n // Check for if_statement\n const ifStatement = node.children.find(\n (child: any) => child.type === \"if_statement\"\n );\n if (ifStatement) {\n const conditionalNode = ifStatement.children.find(\n (child: any) => child.type === \"conditional\"\n );\n const variableNode = ifStatement.children.find(\n (child: any) => child.type === \"variable\"\n );\n\n if (conditionalNode && conditionalNode.text === \"if\" && variableNode) {\n return {\n type: \"if\",\n expression: variableNode.text,\n };\n }\n }\n\n // Check for tag_statement\n const tagStatement = node.children.find(\n (child: any) => child.type === \"tag_statement\"\n );\n const functionCall = node.children.find(\n (child: any) => child.type === \"function_call\"\n );\n\n if (tagStatement) {\n const tagNode = tagStatement.children.find(\n (child: any) => child.type === \"tag\"\n );\n const conditionalNode = tagStatement.children.find(\n (child: any) => child.type === \"conditional\"\n );\n const variableNode = tagStatement.children.find(\n (child: any) => child.type === \"variable\"\n );\n\n if (tagNode && tagNode.text === \"block\" && variableNode) {\n return {\n type: \"block\",\n name: variableNode.text,\n };\n } else if (tagNode && tagNode.text === \"endblock\") {\n return {\n type: \"endblock\",\n };\n } else if (conditionalNode && conditionalNode.text === \"endif\") {\n return {\n type: \"endif\",\n };\n }\n } else if (functionCall) {\n const functionIdentifier = functionCall.children.find(\n (child: any) => child.type === \"function_identifier\"\n );\n\n if (functionIdentifier) {\n return {\n type: \"function\",\n functionName: functionIdentifier.text,\n };\n }\n }\n }\n return null;\n}\n\nexport function parse(content: string): Tree {\n const tree = parser.parse(content);\n\n // First pass: convert all nodes to intermediate format\n const rawNodes: {\n type: \"block\" | \"endblock\" | \"function\" | \"if\" | \"endif\";\n name?: string;\n functionName?: string;\n expression?: string;\n }[] = [];\n\n // Also collect content nodes\n const allNodes: Array<\n | {\n type:\n | \"block\"\n | \"endblock\"\n | \"function\"\n | \"if\"\n | \"endif\"\n | \"content\"\n | \"html_element\"\n | \"doctype\";\n name?: string;\n functionName?: string;\n expression?: string;\n content?: string;\n }\n | HtmlElementNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n > = [];\n\n function convertHtmlEntity(\n node: any\n ): HtmlNamedEntityNode | HtmlNumericEntityNode | null {\n if (node.type === \"html_entity\") {\n const entityText = node.text;\n\n // Check if it's a numeric entity (starts with &#)\n if (entityText.startsWith(\"&#\")) {\n return {\n type: \"html_numeric_entity\",\n content: entityText,\n };\n } else if (entityText.startsWith(\"&\")) {\n return {\n type: \"html_named_entity\",\n content: entityText,\n };\n }\n }\n return null;\n }\n\n function convertTwigComment(node: any): TwigCommentNode | null {\n if (node.type === \"twig_comment\") {\n // Extract content between {# and #}\n const text = node.text;\n const content = text.slice(2, -2).trim();\n return {\n type: \"twig_comment\",\n content,\n };\n }\n return null;\n }\n\n function convertVueInterpolation(node: any): VueInterpolationNode | null {\n if (node.type === \"vue_interpolation\") {\n // Find the interpolation_content child\n const contentNode = node.children.find(\n (child: any) => child.type === \"interpolation_content\"\n );\n \n return {\n type: \"vue_interpolation\",\n expression: contentNode ? contentNode.text.trim() : \"\",\n };\n }\n return null;\n }\n\n function buildNestedStructureForElement(\n nodes: Array<\n | {\n type:\n | \"block\"\n | \"endblock\"\n | \"function\"\n | \"if\"\n | \"endif\"\n | \"content\"\n | \"html_element\";\n name?: string;\n functionName?: string;\n expression?: string;\n content?: string;\n }\n | HtmlElementNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n >\n ): (\n | HtmlElementNode\n | ContentNode\n | TwigStatementDirectiveNode\n | TwigCommentNode\n | VueInterpolationNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n )[] {\n const result: (\n | HtmlElementNode\n | ContentNode\n | TwigStatementDirectiveNode\n | TwigCommentNode\n | VueInterpolationNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n )[] = [];\n const stack: TwigStatementDirectiveNode[] = [];\n\n for (const node of nodes) {\n if (node.type === \"block\") {\n const blockNode: TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\",\n tag: {\n type: \"twig_tag\",\n name: \"block\",\n },\n variable: {\n type: \"twig_variable\",\n content: node.name!,\n },\n children: [],\n };\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(blockNode);\n }\n } else {\n result.push(blockNode);\n }\n stack.push(blockNode);\n } else if (node.type === \"endblock\") {\n stack.pop();\n } else if (node.type === \"if\") {\n const ifNode: TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\",\n condition: {\n type: \"twig_condition\",\n expression: {\n type: \"twig_expression\",\n content: node.expression!,\n },\n },\n children: [],\n };\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(ifNode);\n }\n } else {\n result.push(ifNode);\n }\n stack.push(ifNode);\n } else if (node.type === \"endif\") {\n stack.pop();\n } else if (node.type === \"function\") {\n const functionNode: TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\",\n function: {\n type: \"twig_function\",\n name: node.functionName!,\n },\n };\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(functionNode);\n }\n } else {\n result.push(functionNode);\n }\n } else if (node.type === \"content\") {\n const contentNode: ContentNode = {\n type: \"content\",\n content: node.content!,\n };\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(contentNode);\n }\n } else {\n result.push(contentNode);\n }\n } else if (node.type === \"html_element\" && \"name\" in node) {\n const htmlNode = node as HtmlElementNode;\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(htmlNode);\n }\n } else {\n result.push(htmlNode);\n }\n } else if (node.type === \"html_named_entity\" && \"content\" in node) {\n const entityNode = node as HtmlNamedEntityNode;\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(entityNode);\n }\n } else {\n result.push(entityNode);\n }\n } else if (node.type === \"html_numeric_entity\" && \"content\" in node) {\n const entityNode = node as HtmlNumericEntityNode;\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(entityNode);\n }\n } else {\n result.push(entityNode);\n }\n } else if (node.type === \"twig_comment\" && \"content\" in node) {\n const commentNode = node as TwigCommentNode;\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(commentNode);\n }\n } else {\n result.push(commentNode);\n }\n } else if (node.type === \"vue_interpolation\" && \"expression\" in node) {\n const interpolationNode = node as VueInterpolationNode;\n\n if (stack.length > 0) {\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(interpolationNode);\n }\n } else {\n result.push(interpolationNode);\n }\n }\n }\n\n return result;\n }\n\n function convertHtmlElement(node: any): HtmlElementNode | null {\n if (node.type === \"html_element\") {\n // Check for self-closing tag first\n const selfClosingTag = node.children.find(\n (child: any) => child.type === \"html_self_closing_tag\"\n );\n\n // Check for void tag\n const voidTag = node.children.find(\n (child: any) => child.type === \"html_void_tag\"\n );\n\n // Find the start tag to get the element name\n const startTag = node.children.find(\n (child: any) => child.type === \"html_start_tag\"\n );\n\n // Use self-closing tag, void tag, or start tag in that order of preference\n const tagToUse = selfClosingTag || voidTag || startTag;\n if (!tagToUse) return null;\n\n let tagName: any;\n if (voidTag) {\n // For void tags, the tag name is nested inside html_start_tag within the void tag\n const voidStartTag = voidTag.children.find(\n (child: any) => child.type === \"html_start_tag\"\n );\n tagName = voidStartTag?.children.find(\n (child: any) => child.type === \"html_tag_name\"\n );\n } else {\n // For regular and self-closing tags, tag name is directly in the tag\n tagName = tagToUse.children.find(\n (child: any) => child.type === \"html_tag_name\"\n );\n }\n if (!tagName) return null;\n\n // Check if this is a void element\n const hasVoidTag = node.children.some(\n (child: any) => child.type === \"html_void_tag\"\n );\n const hasSelfClosingTag = node.children.some(\n (child: any) => child.type === \"html_self_closing_tag\"\n );\n const isVoid = hasVoidTag || hasSelfClosingTag;\n\n // Parse attributes from the tag (either self-closing or start tag)\n const attributes: HtmlAttributeNode[] = [];\n let attributeNodes;\n\n if (voidTag) {\n // For void tags, attributes are in the nested html_start_tag\n const voidStartTag = voidTag.children.find(\n (child: any) => child.type === \"html_start_tag\"\n );\n attributeNodes = voidStartTag\n ? voidStartTag.children.filter(\n (child: any) => child.type === \"html_attribute\"\n )\n : [];\n } else {\n // For regular and self-closing tags, attributes are directly in the tag\n attributeNodes = tagToUse.children.filter(\n (child: any) => child.type === \"html_attribute\"\n );\n }\n\n for (const attrNode of attributeNodes) {\n const nameNode = attrNode.children.find(\n (child: any) => child.type === \"html_attribute_name\"\n );\n if (!nameNode) continue;\n\n const valueNode = attrNode.children.find(\n (child: any) => child.type === \"html_attribute_value\"\n );\n const quotedValueNode = attrNode.children.find(\n (child: any) => child.type === \"html_quoted_attribute_value\"\n );\n\n let value: string | undefined;\n if (quotedValueNode) {\n // For quoted values, find the inner html_attribute_value\n const innerValueNode = quotedValueNode.children.find(\n (child: any) => child.type === \"html_attribute_value\"\n );\n value = innerValueNode ? innerValueNode.text : undefined;\n } else if (valueNode) {\n value = valueNode.text;\n }\n\n const attribute: HtmlAttributeNode = {\n type: \"html_attribute\",\n name: nameNode.text,\n };\n\n // Only include value property if there's actually a value\n if (value !== undefined) {\n attribute.value = value;\n }\n\n attributes.push(attribute);\n }\n\n // Collect raw children first (before nesting processing)\n const rawChildren: Array<\n | {\n type:\n | \"block\"\n | \"endblock\"\n | \"function\"\n | \"if\"\n | \"endif\"\n | \"content\"\n | \"html_element\";\n name?: string;\n functionName?: string;\n expression?: string;\n content?: string;\n }\n | HtmlElementNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n > = [];\n\n // Process all children that are not start/end tags\n for (const child of node.children) {\n if (child.type === \"content\") {\n rawChildren.push({\n type: \"content\",\n content: child.text,\n });\n } else if (child.type === \"html_element\") {\n const nestedElement = convertHtmlElement(child);\n if (nestedElement) {\n rawChildren.push(nestedElement);\n }\n } else if (child.type === \"html_entity\") {\n const entityNode = convertHtmlEntity(child);\n if (entityNode) {\n rawChildren.push(entityNode);\n }\n } else if (child.type === \"twig_comment\") {\n const commentNode = convertTwigComment(child);\n if (commentNode) {\n rawChildren.push(commentNode);\n }\n } else if (child.type === \"vue_interpolation\") {\n const interpolationNode = convertVueInterpolation(child);\n if (interpolationNode) {\n rawChildren.push(interpolationNode);\n }\n } else if (child.type === \"statement_directive\") {\n const converted = convertStatementDirective(child);\n if (converted) {\n rawChildren.push(converted);\n }\n }\n }\n\n // Apply block nesting within this HTML element's scope\n const elementChildren = buildNestedStructureForElement(rawChildren);\n\n const result: HtmlElementNode = {\n type: \"html_element\",\n name: tagName.text,\n children: elementChildren,\n };\n\n if (attributes.length > 0) {\n result.attributes = attributes;\n }\n\n if (isVoid) {\n result.void = true;\n }\n\n return result;\n }\n return null;\n }\n\n for (const child of tree.rootNode.children) {\n if (child.type === \"content\") {\n allNodes.push({\n type: \"content\",\n content: child.text,\n });\n } else if (child.type === \"html_element\") {\n const htmlElement = convertHtmlElement(child);\n if (htmlElement) {\n allNodes.push(htmlElement);\n }\n } else if (child.type === \"html_doctype\") {\n allNodes.push({\n type: \"doctype\",\n });\n } else if (child.type === \"html_entity\") {\n const entityNode = convertHtmlEntity(child);\n if (entityNode) {\n allNodes.push(entityNode);\n }\n } else if (child.type === \"twig_comment\") {\n const commentNode = convertTwigComment(child);\n if (commentNode) {\n allNodes.push(commentNode);\n }\n } else if (child.type === \"vue_interpolation\") {\n const interpolationNode = convertVueInterpolation(child);\n if (interpolationNode) {\n allNodes.push(interpolationNode);\n }\n } else {\n const converted = convertStatementDirective(child);\n if (converted) {\n rawNodes.push(converted);\n allNodes.push(converted);\n }\n }\n }\n\n // Second pass: build nested structure using a stack\n function buildNestedStructure(\n nodes: Array<\n | {\n type:\n | \"block\"\n | \"endblock\"\n | \"function\"\n | \"if\"\n | \"endif\"\n | \"content\"\n | \"html_element\"\n | \"doctype\";\n name?: string;\n functionName?: string;\n expression?: string;\n content?: string;\n }\n | HtmlElementNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n >\n ): (\n | TwigStatementDirectiveNode\n | HtmlElementNode\n | ContentNode\n | HtmlDoctypeNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n )[] {\n const result: (\n | TwigStatementDirectiveNode\n | HtmlElementNode\n | ContentNode\n | HtmlDoctypeNode\n | HtmlNamedEntityNode\n | HtmlNumericEntityNode\n | TwigCommentNode\n | VueInterpolationNode\n )[] = [];\n const stack: TwigStatementDirectiveNode[] = [];\n\n for (const node of nodes) {\n if (node.type === \"block\") {\n const blockNode: TwigStatementDirectiveNode = {\n tag: {\n type: \"twig_tag\",\n name: \"block\",\n },\n type: \"twig_statement_directive\",\n variable: {\n type: \"twig_variable\",\n content: node.name!,\n },\n children: [],\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(blockNode);\n }\n } else {\n // Add to root level\n result.push(blockNode);\n }\n\n // Push to stack for nesting\n stack.push(blockNode);\n } else if (node.type === \"endblock\") {\n // Pop from stack when we encounter an endblock\n stack.pop();\n } else if (node.type === \"if\") {\n const ifNode: TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\",\n condition: {\n type: \"twig_condition\",\n expression: {\n type: \"twig_expression\",\n content: node.expression!,\n },\n },\n children: [],\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(ifNode);\n }\n } else {\n // Add to root level\n result.push(ifNode);\n }\n\n // Push to stack for nesting\n stack.push(ifNode);\n } else if (node.type === \"endif\") {\n // Pop from stack when we encounter an endif\n stack.pop();\n } else if (node.type === \"function\") {\n const functionNode: TwigStatementDirectiveNode = {\n type: \"twig_statement_directive\",\n function: {\n type: \"twig_function\",\n name: node.functionName!,\n },\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(functionNode);\n }\n } else {\n // Add to root level\n result.push(functionNode);\n }\n } else if (node.type === \"content\") {\n const contentNode: ContentNode = {\n type: \"content\",\n content: node.content!,\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(contentNode);\n }\n } else {\n // Content at root level - this shouldn't happen in well-formed templates\n // but we'll handle it gracefully\n result.push({\n type: \"twig_statement_directive\",\n children: [contentNode],\n });\n }\n } else if (node.type === \"html_element\" && \"name\" in node) {\n // HTML elements are already processed and can be added directly\n const htmlNode = node as HtmlElementNode;\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(htmlNode);\n }\n } else {\n // Add to root level\n result.push(htmlNode);\n }\n } else if (node.type === \"doctype\") {\n const doctypeNode: HtmlDoctypeNode = {\n type: \"doctype\",\n };\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(doctypeNode);\n }\n } else {\n // Add to root level\n result.push(doctypeNode);\n }\n } else if (node.type === \"html_named_entity\" && \"content\" in node) {\n const entityNode = node as HtmlNamedEntityNode;\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(entityNode);\n }\n } else {\n // Add to root level\n result.push(entityNode);\n }\n } else if (node.type === \"html_numeric_entity\" && \"content\" in node) {\n const entityNode = node as HtmlNumericEntityNode;\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(entityNode);\n }\n } else {\n // Add to root level\n result.push(entityNode);\n }\n } else if (node.type === \"twig_comment\" && \"content\" in node) {\n const commentNode = node as TwigCommentNode;\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(commentNode);\n }\n } else {\n // Add to root level\n result.push(commentNode);\n }\n } else if (node.type === \"vue_interpolation\" && \"expression\" in node) {\n const interpolationNode = node as VueInterpolationNode;\n\n if (stack.length > 0) {\n // Add to the current parent's children\n const parent = stack[stack.length - 1];\n if (parent && parent.children) {\n parent.children.push(interpolationNode);\n }\n } else {\n // Add to root level\n result.push(interpolationNode);\n }\n }\n }\n\n return result;\n }\n\n const children = buildNestedStructure(allNodes);\n\n return {\n rootNode: {\n type: \"template\",\n children,\n },\n };\n}\n"]}