@xaendar/compiler 0.3.17 → 0.3.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaendar/compiler",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "description": "A library containing compiler engine",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -16,8 +16,8 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@xaendar/common": "0.3.17",
20
- "@xaendar/types": "0.3.17",
19
+ "@xaendar/common": "0.3.18",
20
+ "@xaendar/types": "0.3.18",
21
21
  "typescript": "^6.0.3"
22
22
  }
23
23
  }
@@ -213,10 +213,10 @@ function m(e, t) {
213
213
  //#endregion
214
214
  //#region ../packages/compiler/src/lexer/states/interpolation-literal.state.ts
215
215
  function h(e, t) {
216
- let i = !0, a = "", o;
216
+ let i = !0, a = "`", o;
217
217
  for (e.advance(); i;) switch (e.peek()) {
218
218
  case 96:
219
- if (e.advance(), e.peek() === 125) {
219
+ if (a = g(e, a), e.peek() === 125) {
220
220
  e.advance();
221
221
  let s = t.history.pop(), c;
222
222
  switch (s) {
@@ -252,7 +252,7 @@ function v(e) {
252
252
  }
253
253
  //#endregion
254
254
  //#region ../packages/compiler/src/lexer/states/interpolation.state.ts
255
- function ee(e, t) {
255
+ function y(e, t) {
256
256
  let r;
257
257
  e.advance(), e.skipSpaces();
258
258
  let i = e.peek();
@@ -263,7 +263,7 @@ function ee(e, t) {
263
263
  }
264
264
  //#endregion
265
265
  //#region ../packages/compiler/src/lexer/states/tag-body.state.ts
266
- function y(e, t) {
266
+ function b(e, t) {
267
267
  let r = !0, i;
268
268
  for (; r;) switch (e.peek()) {
269
269
  case 64:
@@ -282,7 +282,7 @@ function y(e, t) {
282
282
  }
283
283
  //#endregion
284
284
  //#region ../packages/compiler/src/lexer/states/tag-close.state.ts
285
- function te(e, t) {
285
+ function ee(e, t) {
286
286
  let i = !0, a = "", o;
287
287
  for (e.advance(2), e.skipSpaces(); i;) switch (e.peek()) {
288
288
  case 62:
@@ -301,7 +301,7 @@ function te(e, t) {
301
301
  }
302
302
  //#endregion
303
303
  //#region ../packages/compiler/src/lexer/states/tag-open-end.state.ts
304
- function ne(e, t) {
304
+ function te(e, t) {
305
305
  let i;
306
306
  if (e.peek() === 62) e.advance(), i = {
307
307
  state: n.TEXT,
@@ -326,7 +326,7 @@ function ne(e, t) {
326
326
  }
327
327
  //#endregion
328
328
  //#region ../packages/compiler/src/lexer/states/tag-open-name.state.ts
329
- function re(e, t) {
329
+ function ne(e, t) {
330
330
  let i = !0, a = "", o;
331
331
  for (e.advance(), e.skipSpaces(); i;) switch (e.peek()) {
332
332
  case 32:
@@ -346,7 +346,7 @@ function re(e, t) {
346
346
  }
347
347
  //#endregion
348
348
  //#region ../packages/compiler/src/lexer/states/text.state.ts
349
- function b(e, t) {
349
+ function x(e, t) {
350
350
  let i = !0, a = "", o;
351
351
  for (; i;) switch (e.peek()) {
352
352
  case 60:
@@ -381,7 +381,7 @@ function b(e, t) {
381
381
  }
382
382
  //#endregion
383
383
  //#region ../packages/compiler/src/lexer/types/lexer-cursor.model.ts
384
- var ie = class {
384
+ var re = class {
385
385
  input;
386
386
  _currentChar = {
387
387
  code: 0,
@@ -437,32 +437,32 @@ var ie = class {
437
437
  throwEOFError() {
438
438
  throw Error("", { cause: 0 });
439
439
  }
440
- }, ae = class {
440
+ }, ie = class {
441
441
  input;
442
442
  _cursor;
443
443
  _state = n.START;
444
444
  _stack = new e();
445
445
  _tokens = [];
446
446
  _states = {
447
- [n.START]: b,
448
- [n.TEXT]: b,
449
- [n.TAG_OPEN_NAME]: re,
450
- [n.TAG_BODY]: y,
451
- [n.TAG_OPEN_END]: ne,
452
- [n.TAG_CLOSE]: te,
447
+ [n.START]: x,
448
+ [n.TEXT]: x,
449
+ [n.TAG_OPEN_NAME]: ne,
450
+ [n.TAG_BODY]: b,
451
+ [n.TAG_OPEN_END]: te,
452
+ [n.TAG_CLOSE]: ee,
453
453
  [n.ATTRIBUTE]: i,
454
454
  [n.FLOW_CONTROL]: f,
455
455
  [n.FLOW_CONTROL_CONDITION]: d,
456
456
  [n.CASE_FLOW_CONTROL_CONDITION]: s,
457
457
  [n.FLOW_CONTROL_BLOCK]: u,
458
458
  [n.EVENT]: l,
459
- [n.INTERPOLATION]: ee,
459
+ [n.INTERPOLATION]: y,
460
460
  [n.INTERPOLATION_EXPRESSION]: p,
461
461
  [n.INTERPOLATION_LITERAL]: h,
462
462
  [n.CONST_DECLARATION]: c
463
463
  };
464
464
  constructor(e) {
465
- this.input = e, this._cursor = new ie(this.input);
465
+ this.input = e, this._cursor = new re(this.input);
466
466
  }
467
467
  tokenize() {
468
468
  let e = !1;
@@ -478,7 +478,7 @@ var ie = class {
478
478
  }
479
479
  return this._tokens;
480
480
  }
481
- }, oe = class {
481
+ }, ae = class {
482
482
  _tokens;
483
483
  _currentToken = {
484
484
  value: { type: r.EOF },
@@ -507,14 +507,14 @@ var ie = class {
507
507
  peekOneToken(e) {
508
508
  return e < this._tokens.length ? this._tokens[e] : { type: r.EOF };
509
509
  }
510
- }, x = /* @__PURE__ */ function(e) {
510
+ }, S = /* @__PURE__ */ function(e) {
511
511
  return e[e.Element = 0] = "Element", e[e.Text = 1] = "Text", e[e.Interpolation = 2] = "Interpolation", e[e.If = 3] = "If", e[e.Else = 4] = "Else", e[e.ElseIf = 5] = "ElseIf", e[e.For = 6] = "For", e[e.Switch = 7] = "Switch", e[e.Case = 8] = "Case", e[e.ConstDeclaration = 9] = "ConstDeclaration", e;
512
512
  }({});
513
513
  //#endregion
514
514
  //#region ../packages/compiler/src/parser/states/parse-const-declaration.state.ts
515
- function S(e, t, n) {
515
+ function oe(e, t, n) {
516
516
  return e.advance(), {
517
- type: x.ConstDeclaration,
517
+ type: S.ConstDeclaration,
518
518
  varName: n.parts[0],
519
519
  expression: n.parts[1]
520
520
  };
@@ -523,13 +523,13 @@ function S(e, t, n) {
523
523
  //#region ../packages/compiler/src/parser/states/parse-interpolation.state.ts
524
524
  function C(e, t, n) {
525
525
  return e.advance(), {
526
- type: x.Interpolation,
526
+ type: S.Interpolation,
527
527
  expression: n.parts[0]
528
528
  };
529
529
  }
530
530
  //#endregion
531
531
  //#region ../packages/compiler/src/parser/states/parse-attribute.state.ts
532
- function se(e, t, n) {
532
+ function w(e, t, n) {
533
533
  e.advance();
534
534
  let i = n.parts[0];
535
535
  if (!i.includes("=")) return {
@@ -551,7 +551,7 @@ function se(e, t, n) {
551
551
  }
552
552
  //#endregion
553
553
  //#region ../packages/compiler/src/parser/states/parse-event.state.ts
554
- function ce(e, t, n) {
554
+ function se(e, t, n) {
555
555
  e.advance();
556
556
  let r = n.parts[0], [i, a] = r.split("=");
557
557
  if (!i || !a) throw Error(`[Parser] Invalid event format: ${r}`);
@@ -562,57 +562,57 @@ function ce(e, t, n) {
562
562
  }
563
563
  //#endregion
564
564
  //#region ../packages/compiler/src/parser/states/parse-element.state.ts
565
- function le(e, t, n) {
565
+ function ce(e, t, n) {
566
566
  e.advance();
567
567
  let i = n.parts[0], a = [], o = [], s = !0;
568
568
  for (; s;) {
569
569
  let n = e.peek();
570
570
  switch (n.type) {
571
571
  case r.ATTRIBUTE:
572
- a.push(se(e, t, n));
572
+ a.push(w(e, t, n));
573
573
  break;
574
574
  case r.EVENT:
575
- o.push(ce(e, t, n));
575
+ o.push(se(e, t, n));
576
576
  break;
577
577
  default: s = !1;
578
578
  }
579
579
  }
580
580
  if (e.peek().type === r.TAG_OPEN_END && e.advance(), e.peek().type === r.TAG_SELF_CLOSE) return e.advance(), {
581
- type: x.Element,
581
+ type: S.Element,
582
582
  tagName: i,
583
583
  attributes: a,
584
584
  events: o,
585
585
  children: []
586
586
  };
587
587
  let c = [];
588
- for (; !ue(e, i);) {
588
+ for (; !le(e, i);) {
589
589
  let e = t();
590
590
  e && c.push(e);
591
591
  }
592
592
  return e.advance(), {
593
- type: x.Element,
593
+ type: S.Element,
594
594
  tagName: i,
595
595
  attributes: a,
596
596
  events: o,
597
597
  children: c
598
598
  };
599
599
  }
600
- function ue(e, t) {
600
+ function le(e, t) {
601
601
  let n = e.peek();
602
602
  return n.type === r.TAG_CLOSE_NAME && n.parts[0] === t;
603
603
  }
604
604
  //#endregion
605
605
  //#region ../packages/compiler/src/parser/utils/expression-validator.ts
606
- function w(e) {
606
+ function T(e) {
607
607
  let n = t.createSourceFile("expression.ts", `const x = ${e}`, t.ScriptTarget.ESNext, !0).statements[0].declarationList.declarations[0].initializer, r = [];
608
- if (T(n, 10, r), r.length) throw Error(r.reduce((e, t) => `${e}${t.message}\n`, ""));
608
+ if (E(n, 10, r), r.length) throw Error(r.reduce((e, t) => `${e}${t.message}\n`, ""));
609
609
  return { node: n };
610
610
  }
611
- function T(e, n, r) {
612
- if (!E(e)) throw Error(D(e));
613
- if (t.forEachChild(e, (e) => T(e, n, r)), r.length) throw Error(r[0].message);
611
+ function E(e, n, r) {
612
+ if (!D(e)) throw Error(O(e));
613
+ if (t.forEachChild(e, (e) => E(e, n, r)), r.length) throw Error(r[0].message);
614
614
  }
615
- function E(e) {
615
+ function D(e) {
616
616
  switch (e.kind) {
617
617
  case t.SyntaxKind.StringLiteral:
618
618
  case t.SyntaxKind.NumericLiteral:
@@ -673,7 +673,7 @@ function E(e) {
673
673
  default: return !1;
674
674
  }
675
675
  }
676
- function D(e) {
676
+ function O(e) {
677
677
  switch (e.kind) {
678
678
  case t.SyntaxKind.AwaitExpression: return "'await' is not allowed inside template expressions.";
679
679
  case t.SyntaxKind.YieldExpression: return "'yield' is not allowed inside template expressions.";
@@ -681,16 +681,16 @@ function D(e) {
681
681
  case t.SyntaxKind.ArrowFunction:
682
682
  case t.SyntaxKind.FunctionExpression: return "Function expressions are not allowed inside template expressions.";
683
683
  case t.SyntaxKind.TaggedTemplateExpression: return "Tagged template expressions are not allowed inside template expressions.";
684
- case t.SyntaxKind.BinaryExpression: return O(e.operatorToken.kind) ? "Assignments are not allowed inside template expressions. Use @const to declare local template variables instead." : `'${t.SyntaxKind[e.kind]}' is not allowed inside template expressions.`;
684
+ case t.SyntaxKind.BinaryExpression: return k(e.operatorToken.kind) ? "Assignments are not allowed inside template expressions. Use @const to declare local template variables instead." : `'${t.SyntaxKind[e.kind]}' is not allowed inside template expressions.`;
685
685
  default: return `'${t.SyntaxKind[e.kind]}' is not allowed inside template expressions.`;
686
686
  }
687
687
  }
688
- function O(e) {
688
+ function k(e) {
689
689
  return e >= t.SyntaxKind.FirstAssignment && e <= t.SyntaxKind.LastAssignment;
690
690
  }
691
691
  //#endregion
692
692
  //#region ../packages/compiler/src/parser/states/parse-block-children.state.ts
693
- function k(e, t) {
693
+ function A(e, t) {
694
694
  let n = [];
695
695
  for (; e.peek().type !== r.BLOCK_CLOSE;) {
696
696
  let e = t();
@@ -700,30 +700,30 @@ function k(e, t) {
700
700
  }
701
701
  //#endregion
702
702
  //#region ../packages/compiler/src/parser/states/parse-for.state.ts
703
- function A(e, t, n) {
703
+ function j(e, t, n) {
704
704
  e.advance();
705
705
  let i = e.peek();
706
706
  if (i.type !== r.CONDITION) throw Error(`[Parser] Expected CONDITION after FOR, got ${r[i.type]}`);
707
- let a = j(i.parts[0], 0);
707
+ let a = M(i.parts[0], 0);
708
708
  e.advance(2);
709
- let o = k(e, t);
709
+ let o = A(e, t);
710
710
  return {
711
- type: x.For,
711
+ type: S.For,
712
712
  ...a,
713
713
  children: o
714
714
  };
715
715
  }
716
- function j(e, t) {
717
- let n = N(e);
716
+ function M(e, t) {
717
+ let n = P(e);
718
718
  if (n.length < 2) throw Error("[Parser] @for requires at least \"item of iterable; track expr\".");
719
719
  let r = n[0].trim(), i = r.indexOf(" of ");
720
720
  if (i === -1) throw Error("[Parser] @for expression must be in the form \"item of iterable\".");
721
721
  let a = r.slice(0, i).trim(), o = r.slice(i + 4).trim();
722
- if (!P(a)) throw Error(`[Parser] '${a}' is not a valid item alias.`);
723
- let s = w(o), c = n[1].trim();
722
+ if (!F(a)) throw Error(`[Parser] '${a}' is not a valid item alias.`);
723
+ let s = T(o), c = n[1].trim();
724
724
  if (!c.startsWith("track ")) throw Error("[Parser] Second section of @for must start with \"track\".");
725
- let l = c.slice(6).trim(), u = w(l), d = /* @__PURE__ */ new Map();
726
- return n.length >= 3 && n[2] !== void 0 && M(n[2].trim(), t + e.indexOf(n[2]), d), {
725
+ let l = c.slice(6).trim(), u = T(l), d = /* @__PURE__ */ new Map();
726
+ return n.length >= 3 && n[2] !== void 0 && N(n[2].trim(), t + e.indexOf(n[2]), d), {
727
727
  itemAlias: a,
728
728
  iterableExpression: s.node,
729
729
  iterableSource: o,
@@ -732,7 +732,7 @@ function j(e, t) {
732
732
  implicitAliases: d
733
733
  };
734
734
  }
735
- function M(e, t, n) {
735
+ function N(e, t, n) {
736
736
  let r = e.split(","), i = 0, a = new Set([
737
737
  "$index",
738
738
  "$last",
@@ -746,12 +746,12 @@ function M(e, t, n) {
746
746
  i += e.length + 1;
747
747
  let o = t.slice(0, r).trim(), s = t.slice(r + 1).trim();
748
748
  if (!((e) => a.has(e))(o)) throw Error(`[Parser] '${o}' is not a known implicit variable. Known variables: ${[...a].join(", ")}.`);
749
- if (i += e.length + 1, !P(s)) throw Error(`[Parser] '${s}' is not a valid alias identifier.`);
749
+ if (i += e.length + 1, !F(s)) throw Error(`[Parser] '${s}' is not a valid alias identifier.`);
750
750
  if (i += e.length + 1, n.has(o)) throw Error(`[Parser] '${o}' is already aliased in this @for expression.`);
751
751
  n.set(o, s), i += e.length + 1;
752
752
  }
753
753
  }
754
- function N(e) {
754
+ function P(e) {
755
755
  let t = [], n = "", r = 0, i;
756
756
  for (let a = 0; a < e.length; a++) {
757
757
  let o = e[a];
@@ -781,17 +781,17 @@ function N(e) {
781
781
  }
782
782
  return n.trim().length > 0 && t.push(n), t;
783
783
  }
784
- function P(e) {
784
+ function F(e) {
785
785
  if (!e.length) return !1;
786
786
  let n = t.createSourceFile("__id.ts", e, t.ScriptTarget.ESNext, !1).statements[0];
787
787
  return !!n && t.isExpressionStatement(n) && t.isIdentifier(n.expression) && n.expression.text === e;
788
788
  }
789
789
  //#endregion
790
790
  //#region ../packages/compiler/src/parser/states/parse-if.state.ts
791
- function F(e, t, n) {
792
- return I(e, t, n);
793
- }
794
791
  function I(e, t, n) {
792
+ return L(e, t, n);
793
+ }
794
+ function L(e, t, n) {
795
795
  switch (n.type) {
796
796
  case r.IF:
797
797
  case r.ELSE_IF:
@@ -799,26 +799,26 @@ function I(e, t, n) {
799
799
  let i = e.peek();
800
800
  if (i.type !== r.CONDITION) throw Error(`[Parser] Expected CONDITION after ${r[n.type]}, got ${r[i.type]}`);
801
801
  e.advance(2);
802
- let a = i.parts[0], o = w(a), s = k(e, t);
802
+ let a = i.parts[0], o = T(a), s = A(e, t);
803
803
  return {
804
- type: n.type === r.IF ? x.If : x.ElseIf,
804
+ type: n.type === r.IF ? S.If : S.ElseIf,
805
805
  condition: a,
806
806
  conditionNode: o.node,
807
807
  consequent: s,
808
- alternate: I(e, t, e.peek())
808
+ alternate: L(e, t, e.peek())
809
809
  };
810
810
  case r.ELSE:
811
811
  e.advance(2);
812
- let c = k(e, t);
812
+ let c = A(e, t);
813
813
  return {
814
- type: x.Else,
814
+ type: S.Else,
815
815
  consequent: c
816
816
  };
817
817
  }
818
818
  }
819
819
  //#endregion
820
820
  //#region ../packages/compiler/src/parser/states/parse-switch.state.ts
821
- function L(e, t, n) {
821
+ function R(e, t, n) {
822
822
  e.advance();
823
823
  let i = e.peek();
824
824
  if (i.type !== r.CONDITION) throw Error(`[Parser] Expected CONDITION after SWITCH, got ${r[i.type]}`);
@@ -835,50 +835,50 @@ function L(e, t, n) {
835
835
  n.push(t.parts[0]), e.advance();
836
836
  } while (e.peek().type !== r.BLOCK_OPEN);
837
837
  e.advance(), o.push({
838
- type: x.Case,
838
+ type: S.Case,
839
839
  condition: n,
840
- children: k(e, t)
840
+ children: A(e, t)
841
841
  });
842
842
  break;
843
843
  case r.DEFAULT:
844
844
  e.advance(2), o.push({
845
- type: x.Case,
845
+ type: S.Case,
846
846
  condition: null,
847
- children: k(e, t)
847
+ children: A(e, t)
848
848
  });
849
849
  break;
850
850
  }
851
851
  return e.advance(), {
852
- type: x.Switch,
852
+ type: S.Switch,
853
853
  expression: a,
854
854
  cases: o
855
855
  };
856
856
  }
857
857
  //#endregion
858
858
  //#region ../packages/compiler/src/parser/states/parse-text.state.ts
859
- function R(e, t, n) {
859
+ function z(e, t, n) {
860
860
  return e.advance(), {
861
- type: x.Text,
861
+ type: S.Text,
862
862
  value: n.parts[0]
863
863
  };
864
864
  }
865
865
  //#endregion
866
866
  //#region ../packages/compiler/src/parser/parser.ts
867
- var z = class {
867
+ var B = class {
868
868
  tokens;
869
869
  _cursor;
870
870
  _states = {
871
- [r.TEXT]: R,
871
+ [r.TEXT]: z,
872
872
  [r.INTERPOLATION_EXPRESSION]: C,
873
873
  [r.INTERPOLATION_LITERAL]: C,
874
- [r.TAG_OPEN_NAME]: le,
875
- [r.IF]: F,
876
- [r.FOR]: A,
877
- [r.SWITCH]: L,
878
- [r.CONST_DECLARATION]: S
874
+ [r.TAG_OPEN_NAME]: ce,
875
+ [r.IF]: I,
876
+ [r.FOR]: j,
877
+ [r.SWITCH]: R,
878
+ [r.CONST_DECLARATION]: oe
879
879
  };
880
880
  constructor(e) {
881
- this.tokens = e, this._cursor = new oe(this.tokens);
881
+ this.tokens = e, this._cursor = new ae(this.tokens);
882
882
  }
883
883
  parse() {
884
884
  let e = [];
@@ -895,7 +895,7 @@ var z = class {
895
895
  if (!t) throw Error(`[Parser] No transition function for token type ${r[e.type]}`);
896
896
  return t(this._cursor, this.parseNode.bind(this), e);
897
897
  }
898
- }, B = class {
898
+ }, V = class {
899
899
  _identifiers;
900
900
  _parent;
901
901
  constructor(e = [], t) {
@@ -908,7 +908,7 @@ var z = class {
908
908
  getIdentifier(e) {
909
909
  return this._identifiers.includes(e) ? e : this._parent?.getIdentifier(e);
910
910
  }
911
- }, V = new Set(/* @__PURE__ */ "undefined.NaN.Infinity.globalThis.eval.isFinite.isNaN.parseFloat.parseInt.decodeURI.decodeURIComponent.encodeURI.encodeURIComponent.escape.unescape.Object.Function.Boolean.Symbol.Error.AggregateError.EvalError.RangeError.ReferenceError.SyntaxError.TypeError.URIError.SuppressedError.InternalError.Number.BigInt.Math.Date.Temporal.String.RegExp.Array.TypedArray.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Uint16Array.Int32Array.Uint32Array.BigInt64Array.BigUint64Array.Float16Array.Float32Array.Float64Array.Map.Set.WeakMap.WeakSet.ArrayBuffer.SharedArrayBuffer.DataView.Atomics.JSON.WeakRef.FinalizationRegistry.Iterator.AsyncIterator.Promise.GeneratorFunction.AsyncGeneratorFunction.Generator.AsyncGenerator.AsyncFunction.DisposableStack.AsyncDisposableStack.Reflect.Proxy.Intl.WebAssembly.window.document.navigator.location.history.screen.console.performance.crypto.fetch.alert.confirm.prompt.setTimeout.setInterval.clearTimeout.clearInterval.requestAnimationFrame.cancelAnimationFrame.queueMicrotask.structuredClone.URL.URLSearchParams.FormData.Headers.Request.Response.AbortController.AbortSignal.CustomEvent.Event.EventTarget.MutationObserver.IntersectionObserver.ResizeObserver.PerformanceObserver.Worker.SharedWorker.ServiceWorker.Blob.File.FileReader.ReadableStream.WritableStream.TransformStream.TextEncoder.TextDecoder.ImageData.Canvas.Storage.localStorage.sessionStorage.indexedDB.WebSocket.XMLHttpRequest.HTMLElement.HTMLInputElement.HTMLButtonElement.HTMLFormElement.HTMLAnchorElement.HTMLImageElement.HTMLVideoElement.HTMLAudioElement.HTMLCanvasElement.HTMLSelectElement.HTMLTextAreaElement.HTMLDivElement.HTMLSpanElement.HTMLParagraphElement.HTMLHeadingElement.HTMLTableElement.HTMLTableRowElement.HTMLTableCellElement.HTMLUListElement.HTMLOListElement.HTMLLIElement.HTMLLabelElement.HTMLDialogElement.HTMLDetailsElement.HTMLSlotElement.HTMLTemplateElement.SVGElement.SVGSVGElement.Element.Node.NodeList.DocumentFragment.ShadowRoot.Document.Window".split(".")), H = "this._root";
911
+ }, ue = new Set(/* @__PURE__ */ "undefined.NaN.Infinity.globalThis.eval.isFinite.isNaN.parseFloat.parseInt.decodeURI.decodeURIComponent.encodeURI.encodeURIComponent.escape.unescape.Object.Function.Boolean.Symbol.Error.AggregateError.EvalError.RangeError.ReferenceError.SyntaxError.TypeError.URIError.SuppressedError.InternalError.Number.BigInt.Math.Date.Temporal.String.RegExp.Array.TypedArray.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Uint16Array.Int32Array.Uint32Array.BigInt64Array.BigUint64Array.Float16Array.Float32Array.Float64Array.Map.Set.WeakMap.WeakSet.ArrayBuffer.SharedArrayBuffer.DataView.Atomics.JSON.WeakRef.FinalizationRegistry.Iterator.AsyncIterator.Promise.GeneratorFunction.AsyncGeneratorFunction.Generator.AsyncGenerator.AsyncFunction.DisposableStack.AsyncDisposableStack.Reflect.Proxy.Intl.WebAssembly.window.document.navigator.location.history.screen.console.performance.crypto.fetch.alert.confirm.prompt.setTimeout.setInterval.clearTimeout.clearInterval.requestAnimationFrame.cancelAnimationFrame.queueMicrotask.structuredClone.URL.URLSearchParams.FormData.Headers.Request.Response.AbortController.AbortSignal.CustomEvent.Event.EventTarget.MutationObserver.IntersectionObserver.ResizeObserver.PerformanceObserver.Worker.SharedWorker.ServiceWorker.Blob.File.FileReader.ReadableStream.WritableStream.TransformStream.TextEncoder.TextDecoder.ImageData.Canvas.Storage.localStorage.sessionStorage.indexedDB.WebSocket.XMLHttpRequest.HTMLElement.HTMLInputElement.HTMLButtonElement.HTMLFormElement.HTMLAnchorElement.HTMLImageElement.HTMLVideoElement.HTMLAudioElement.HTMLCanvasElement.HTMLSelectElement.HTMLTextAreaElement.HTMLDivElement.HTMLSpanElement.HTMLParagraphElement.HTMLHeadingElement.HTMLTableElement.HTMLTableRowElement.HTMLTableCellElement.HTMLUListElement.HTMLOListElement.HTMLLIElement.HTMLLabelElement.HTMLDialogElement.HTMLDetailsElement.HTMLSlotElement.HTMLTemplateElement.SVGElement.SVGSVGElement.Element.Node.NodeList.DocumentFragment.ShadowRoot.Document.Window".split(".")), H = "this._root";
912
912
  function U(e, t) {
913
913
  return typeof e == "string" ? t.getIdentifier(e) ?? `this.${e}` : W(e, e, t);
914
914
  }
@@ -928,7 +928,7 @@ function G(e, n) {
928
928
  }), r;
929
929
  }
930
930
  function K(e, n) {
931
- return !(t.isPropertyAccessExpression(n) && n.name === e || V.has(e.text));
931
+ return !(t.isPropertyAccessExpression(n) && n.name === e || ue.has(e.text));
932
932
  }
933
933
  function q(...e) {
934
934
  return e.map((e) => ` ${e}`);
@@ -947,10 +947,10 @@ function fe(e, t, n, r) {
947
947
  //#endregion
948
948
  //#region ../packages/compiler/src/render-generator/states/process-element.state.ts
949
949
  function Y(e, t, n, r) {
950
- let i = new B([], r);
950
+ let i = new V([], r);
951
951
  return [
952
952
  `const ${t} = document.createElement("${e.tagName}");`,
953
- ...e.attributes?.map((e) => `${t}.setAttribute('${e.name}', ${typeof e.value == "string" ? e.value : `this.${e.value.expression}`});`) || [],
953
+ ...e.attributes?.map((e) => `${t}.setAttribute('${e.name}', ${typeof e.value == "string" ? e.value : `${U(e.value.expression, r)}`});`) || [],
954
954
  ...e.events?.map((e) => `${t}.addEventListener("${e.name}", ($event) => this.${e.handler}.bind(this));`) || [],
955
955
  `${n}.appendChild(${t});`,
956
956
  ...e.children.map((e, n) => $(e, n.toString(), t, i)).flat()
@@ -959,7 +959,7 @@ function Y(e, t, n, r) {
959
959
  //#endregion
960
960
  //#region ../packages/compiler/src/render-generator/states/process-for.state.ts
961
961
  function pe(e, t, n, r) {
962
- let i = e.iterableSource, a = r.getIdentifier(i) ?? `this.${i}`, o = J(n, t, "items"), s = J(n, t, "i"), c = X(e, "$index"), l = X(e, "$first"), u = X(e, "$last"), d = X(e, "$even"), f = X(e, "$odd"), p = new B([
962
+ let i = e.iterableSource, a = r.getIdentifier(i) ?? `this.${i}`, o = J(n, t, "items"), s = J(n, t, "i"), c = X(e, "$index"), l = X(e, "$first"), u = X(e, "$last"), d = X(e, "$even"), f = X(e, "$odd"), p = new V([
963
963
  e.itemAlias,
964
964
  c,
965
965
  l,
@@ -987,17 +987,17 @@ function X(e, t) {
987
987
  //#endregion
988
988
  //#region ../packages/compiler/src/render-generator/states/process-if.state.ts
989
989
  function me(e, t, n, r) {
990
- let i = new B([], r), a = [
990
+ let i = new V([], r), a = [
991
991
  `if (${U(e.conditionNode, r)}) {`,
992
992
  ...Z(e, t, n, i),
993
993
  "}"
994
994
  ], o = e.alternate;
995
- for (; o?.type === x.ElseIf;) {
996
- let e = new B([], r);
995
+ for (; o?.type === S.ElseIf;) {
996
+ let e = new V([], r);
997
997
  a[a.length - 1] += ` else if (${U(o.conditionNode, r)}) {`, a.push(...Z(o, t, n, e), "}"), o = o.alternate;
998
998
  }
999
999
  if (o) {
1000
- let e = new B([], r);
1000
+ let e = new V([], r);
1001
1001
  a[a.length - 1] += " else {", a.push(...Z(o, t, n, e), "}");
1002
1002
  }
1003
1003
  return a;
@@ -1010,21 +1010,21 @@ function Z(e, t, n, r) {
1010
1010
  function he(e, t, n, r) {
1011
1011
  return [
1012
1012
  `switch (${U(e.expression, r)}) {`,
1013
- ...e.cases.map((e) => [...q(...e.condition ? e.condition.map((e, t, n) => `case ${e}:${t === n.length - 1 ? " {" : ""}`) : ["default: {"], ...e.children.map((e, i) => q(...$(e, `${t}_${i}_${i}`, n, new B([], r)))).flat(), `${q("break;")}`, "}")]).flat(),
1013
+ ...e.cases.map((e) => [...q(...e.condition ? e.condition.map((e, t, n) => `case ${e}:${t === n.length - 1 ? " {" : ""}`) : ["default: {"], ...e.children.map((e, i) => q(...$(e, `${t}_${i}_${i}`, n, new V([], r)))).flat(), `${q("break;")}`, "}")]).flat(),
1014
1014
  "}"
1015
1015
  ];
1016
1016
  }
1017
1017
  //#endregion
1018
1018
  //#region ../packages/compiler/src/render-generator/states/process-text-and-interpolation.state.ts
1019
1019
  function ge(e, t, n, r) {
1020
- return [`const ${t} = document.createTextNode(${e.type === x.Text ? JSON.stringify(e.value) : U(e.expression, r)});`, `${n}.appendChild(${t});`];
1020
+ return [`const ${t} = document.createTextNode(${e.type === S.Text ? JSON.stringify(e.value) : U(e.expression, r)});`, `${n}.appendChild(${t});`];
1021
1021
  }
1022
1022
  //#endregion
1023
1023
  //#region ../packages/compiler/src/render-generator/render-generator.ts
1024
1024
  var Q = /* @__PURE__ */ new Map();
1025
1025
  function _e(e) {
1026
1026
  Q.clear();
1027
- let t = new B(), n = [
1027
+ let t = new V(), n = [
1028
1028
  "_render() {",
1029
1029
  ...q(...e.map((e, n) => [...$(e, n.toString(), H, t), ""]).flat()),
1030
1030
  "}"
@@ -1037,26 +1037,26 @@ function _e(e) {
1037
1037
  }
1038
1038
  function $(e, t, n, r) {
1039
1039
  switch (e.type) {
1040
- case x.Text:
1041
- case x.Interpolation: return ge(e, J(n, t), n, r);
1042
- case x.Element: return Y(e, de(e, n, t), n, r);
1043
- case x.If:
1040
+ case S.Text:
1041
+ case S.Interpolation: return ge(e, J(n, t), n, r);
1042
+ case S.Element: return Y(e, de(e, n, t), n, r);
1043
+ case S.If:
1044
1044
  let i = `control_flow_if_${t}()`;
1045
1045
  return Q.set(i, () => me(e, t, n, r)), [`this.${i};`];
1046
- case x.For:
1046
+ case S.For:
1047
1047
  let a = `control_flow_for_${t}()`;
1048
1048
  return Q.set(a, () => pe(e, t, n, r)), [`this.${a};`];
1049
- case x.Switch:
1049
+ case S.Switch:
1050
1050
  let o = `control_flow_switch_${t}()`;
1051
1051
  return Q.set(o, () => he(e, t, n, r)), [`this.${o};`];
1052
- case x.ConstDeclaration: return fe(e, t, n, r);
1052
+ case S.ConstDeclaration: return fe(e, t, n, r);
1053
1053
  default: return [];
1054
1054
  }
1055
1055
  }
1056
1056
  //#endregion
1057
1057
  //#region ../packages/compiler/src/compile.ts
1058
1058
  function ve(e) {
1059
- return _e(new z(new ae(e).tokenize()).parse());
1059
+ return _e(new B(new ie(e).tokenize()).parse());
1060
1060
  }
1061
1061
  //#endregion
1062
1062
  export { ve as compile };