@vtj/parser 0.16.11 → 0.16.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/index.mjs CHANGED
@@ -4,8 +4,8 @@ import pu from "@babel/traverse";
4
4
  import mu from "@babel/generator";
5
5
  import { BlockModel as ue } from "@vtj/core";
6
6
  import { tsFormatter as xu } from "@vtj/coder";
7
- import { NodeTypes as g } from "@vue/compiler-core";
8
- import { upperFirstCamelCase as ee, unBase64 as te, uid as iu } from "@vtj/base";
7
+ import { NodeTypes as x } from "@vue/compiler-core";
8
+ import { upperFirstCamelCase as ee, unBase64 as te, uid as su } from "@vtj/base";
9
9
  import ae from "postcss";
10
10
  import * as ie from "sass";
11
11
  import * as V from "@babel/types";
@@ -13,10 +13,10 @@ import * as V from "@babel/types";
13
13
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
14
14
  * @name @vtj/parser
15
15
  * @author CHC chenhuachun1549@dingtalk.com
16
- * @version 0.16.11
16
+ * @version 0.16.12
17
17
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
18
18
  */
19
- const v0 = "0.16.11";
19
+ const v0 = "0.16.12";
20
20
  function D(e) {
21
21
  const { descriptor: u, errors: t } = ku(e), a = u.template?.content || "", i = (u.scriptSetup || u.script)?.content || "", s = u.styles.map((r) => r.content);
22
22
  return {
@@ -29,7 +29,7 @@ function D(e) {
29
29
  function W(e) {
30
30
  return Yu(e, { sourceType: "module", plugins: ["typescript"] });
31
31
  }
32
- function Y(e, u) {
32
+ function eu(e, u) {
33
33
  return (pu.default || pu)(e, u);
34
34
  }
35
35
  function O(e) {
@@ -46,22 +46,22 @@ function O(e) {
46
46
  return console.error("代码生成错误", u), "";
47
47
  }
48
48
  }
49
- function nu(e) {
49
+ function ou(e) {
50
50
  return !!e && e.type === "JSExpression";
51
51
  }
52
52
  function se(e) {
53
53
  return typeof e == "object" && !!e && e.type === "JSFunction";
54
54
  }
55
- function ou(e) {
56
- return !!nu(e) || !!se(e);
55
+ function du(e) {
56
+ return !!ou(e) || !!se(e);
57
57
  }
58
58
  function re(e) {
59
- return !!e && !nu(e) && typeof e != "string";
59
+ return !!e && !ou(e) && typeof e != "string";
60
60
  }
61
61
  function qu(e, u) {
62
62
  try {
63
63
  const t = W(e);
64
- return Y(t, u), O(t) || "";
64
+ return eu(t, u), O(t) || "";
65
65
  } catch {
66
66
  return "";
67
67
  }
@@ -106,7 +106,7 @@ function ce(e, u) {
106
106
  }
107
107
  function w0(e) {
108
108
  const u = D(e), t = W(u.script), a = {};
109
- return u.styles && (a.css = u.styles[0] || ""), Y(t, {
109
+ return u.styles && (a.css = u.styles[0] || ""), eu(t, {
110
110
  CallExpression(i) {
111
111
  const s = i.node.callee?.name;
112
112
  if (s) {
@@ -133,17 +133,17 @@ function ne(e, u, t, a) {
133
133
  else if (o) {
134
134
  let y = 0, b = !1, S = "";
135
135
  for (let I = a.length - 1; I >= 0; I--) {
136
- const x = a[I];
137
- if (b && x === S)
136
+ const g = a[I];
137
+ if (b && g === S)
138
138
  b = !1, S = "";
139
- else if (!b && (x === "'" || x === '"' || x === "`")) {
140
- b = !0, S = x;
139
+ else if (!b && (g === "'" || g === '"' || g === "`")) {
140
+ b = !0, S = g;
141
141
  continue;
142
142
  }
143
143
  if (!b) {
144
- if (x === ")")
144
+ if (g === ")")
145
145
  y++;
146
- else if (x === "(") {
146
+ else if (g === "(") {
147
147
  if (y === 0) {
148
148
  f = I;
149
149
  break;
@@ -326,7 +326,7 @@ function q(e) {
326
326
  value: /^\{[\w\W]*\}$/.test(e) ? `(${e})` : e
327
327
  };
328
328
  }
329
- function du(e) {
329
+ function fu(e) {
330
330
  return {
331
331
  type: "JSFunction",
332
332
  value: e
@@ -384,7 +384,7 @@ const me = /* @__PURE__ */ new Uint16Array(
384
384
  // prettier-ignore
385
385
  /* @__PURE__ */ "Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map((e) => e.charCodeAt(0))
386
386
  );
387
- var tu;
387
+ var au;
388
388
  const ge = /* @__PURE__ */ new Map([
389
389
  [0, 65533],
390
390
  // C1 Unicode control character reference replacements
@@ -417,7 +417,7 @@ const ge = /* @__PURE__ */ new Map([
417
417
  [159, 376]
418
418
  ]), yu = (
419
419
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, n/no-unsupported-features/es-builtins
420
- (tu = String.fromCodePoint) !== null && tu !== void 0 ? tu : function(e) {
420
+ (au = String.fromCodePoint) !== null && au !== void 0 ? au : function(e) {
421
421
  let u = "";
422
422
  return e > 65535 && (e -= 65536, u += String.fromCharCode(e >>> 10 & 1023 | 55296), e = 56320 | e & 1023), u += String.fromCharCode(e), u;
423
423
  }
@@ -435,14 +435,14 @@ var $;
435
435
  (function(e) {
436
436
  e[e.VALUE_LENGTH = 49152] = "VALUE_LENGTH", e[e.BRANCH_LENGTH = 16256] = "BRANCH_LENGTH", e[e.JUMP_TABLE = 127] = "JUMP_TABLE";
437
437
  })($ || ($ = {}));
438
- function su(e) {
438
+ function ru(e) {
439
439
  return e >= k.ZERO && e <= k.NINE;
440
440
  }
441
441
  function Ie(e) {
442
442
  return e >= k.UPPER_A && e <= k.UPPER_F || e >= k.LOWER_A && e <= k.LOWER_F;
443
443
  }
444
444
  function Ee(e) {
445
- return e >= k.UPPER_A && e <= k.UPPER_Z || e >= k.LOWER_A && e <= k.LOWER_Z || su(e);
445
+ return e >= k.UPPER_A && e <= k.UPPER_Z || e >= k.LOWER_A && e <= k.LOWER_Z || ru(e);
446
446
  }
447
447
  function ve(e) {
448
448
  return e === k.EQUALS || Ee(e);
@@ -519,7 +519,7 @@ class we {
519
519
  const a = t;
520
520
  for (; t < u.length; ) {
521
521
  const i = u.charCodeAt(t);
522
- if (su(i) || Ie(i))
522
+ if (ru(i) || Ie(i))
523
523
  t += 1;
524
524
  else
525
525
  return this.addToNumericResult(u, a, t, 16), this.emitNumericEntity(i, 3);
@@ -539,7 +539,7 @@ class we {
539
539
  const a = t;
540
540
  for (; t < u.length; ) {
541
541
  const i = u.charCodeAt(t);
542
- if (su(i))
542
+ if (ru(i))
543
543
  t += 1;
544
544
  else
545
545
  return this.addToNumericResult(u, a, t, 10), this.emitNumericEntity(i, 2);
@@ -674,7 +674,7 @@ var d;
674
674
  function _(e) {
675
675
  return e === h.Space || e === h.NewLine || e === h.Tab || e === h.FormFeed || e === h.CarriageReturn;
676
676
  }
677
- function Z(e) {
677
+ function Q(e) {
678
678
  return e === h.Slash || e === h.Gt || _(e);
679
679
  }
680
680
  function Te(e) {
@@ -739,7 +739,7 @@ class Ne {
739
739
  const t = this.sequenceIndex === this.currentSequence.length;
740
740
  if (!(t ? (
741
741
  // If we are at the end of the sequence, make sure the tag name has ended
742
- Z(u)
742
+ Q(u)
743
743
  ) : (
744
744
  // Otherwise, do a case-insensitive comparison
745
745
  (u | 32) === this.currentSequence[this.sequenceIndex]
@@ -800,7 +800,7 @@ class Ne {
800
800
  * We allow anything that wouldn't end the tag.
801
801
  */
802
802
  isTagStartChar(u) {
803
- return this.xmlMode ? !Z(u) : Te(u);
803
+ return this.xmlMode ? !Q(u) : Te(u);
804
804
  }
805
805
  startSpecial(u, t) {
806
806
  this.isSpecial = !0, this.currentSequence = u, this.sequenceIndex = t, this.state = d.SpecialStartSequence;
@@ -816,7 +816,7 @@ class Ne {
816
816
  } else u === h.Slash ? this.state = d.BeforeClosingTagName : (this.state = d.Text, this.stateText(u));
817
817
  }
818
818
  stateInTagName(u) {
819
- Z(u) && (this.cbs.onopentagname(this.sectionStart, this.index), this.sectionStart = -1, this.state = d.BeforeAttributeName, this.stateBeforeAttributeName(u));
819
+ Q(u) && (this.cbs.onopentagname(this.sectionStart, this.index), this.sectionStart = -1, this.state = d.BeforeAttributeName, this.stateBeforeAttributeName(u));
820
820
  }
821
821
  stateBeforeClosingTagName(u) {
822
822
  _(u) || (u === h.Gt ? this.state = d.Text : (this.state = this.isTagStartChar(u) ? d.InClosingTagName : d.InSpecialComment, this.sectionStart = this.index));
@@ -834,7 +834,7 @@ class Ne {
834
834
  u === h.Gt ? (this.cbs.onselfclosingtag(this.index), this.state = d.Text, this.sectionStart = this.index + 1, this.isSpecial = !1) : _(u) || (this.state = d.BeforeAttributeName, this.stateBeforeAttributeName(u));
835
835
  }
836
836
  stateInAttributeName(u) {
837
- (u === h.Eq || Z(u)) && (this.cbs.onattribname(this.sectionStart, this.index), this.sectionStart = this.index, this.state = d.AfterAttributeName, this.stateAfterAttributeName(u));
837
+ (u === h.Eq || Q(u)) && (this.cbs.onattribname(this.sectionStart, this.index), this.sectionStart = this.index, this.state = d.AfterAttributeName, this.stateAfterAttributeName(u));
838
838
  }
839
839
  stateAfterAttributeName(u) {
840
840
  u === h.Eq ? this.state = d.BeforeAttributeValue : u === h.Slash || u === h.Gt ? (this.cbs.onattribend(L.NoValue, this.sectionStart), this.sectionStart = -1, this.state = d.BeforeAttributeName, this.stateBeforeAttributeName(u)) : _(u) || (this.cbs.onattribend(L.NoValue, this.sectionStart), this.state = d.InAttributeName, this.sectionStart = this.index);
@@ -1405,7 +1405,7 @@ function je(e, u) {
1405
1405
  emits: [],
1406
1406
  errors: []
1407
1407
  }, i = W(e);
1408
- return Y(i, {
1408
+ return eu(i, {
1409
1409
  ExportDefaultDeclaration(s) {
1410
1410
  const r = s.node.declaration;
1411
1411
  if (r.type !== "CallExpression") return;
@@ -1523,7 +1523,7 @@ function P(e) {
1523
1523
  id: f ? r.replace("watcher_", "") : "",
1524
1524
  name: r,
1525
1525
  watcher: f,
1526
- exp: du(l)
1526
+ exp: fu(l)
1527
1527
  };
1528
1528
  }
1529
1529
  }
@@ -1612,7 +1612,7 @@ function Fe(e) {
1612
1612
  const s = O(
1613
1613
  a.body.body[0].argument.callee.object
1614
1614
  );
1615
- u[i] = du(s);
1615
+ u[i] = fu(s);
1616
1616
  } else
1617
1617
  u[i] = P(a)?.exp;
1618
1618
  } catch (s) {
@@ -1659,7 +1659,7 @@ function Oe(e, u = {}) {
1659
1659
  handler: Tu(n, "handler")
1660
1660
  });
1661
1661
  } else if (a.type === "ObjectMethod" && t.push({
1662
- id: iu(),
1662
+ id: su(),
1663
1663
  source: {
1664
1664
  type: "JSFunction",
1665
1665
  value: `() => { return this.${r}; }`
@@ -1670,7 +1670,7 @@ function Oe(e, u = {}) {
1670
1670
  }), a.type === "ObjectProperty") {
1671
1671
  const n = s.properties;
1672
1672
  t.push({
1673
- id: iu(),
1673
+ id: su(),
1674
1674
  source: {
1675
1675
  type: "JSFunction",
1676
1676
  value: `() => { return this.${r}; }`
@@ -1763,9 +1763,9 @@ function Je(e) {
1763
1763
  }
1764
1764
  return u;
1765
1765
  }
1766
- let ru = [], Q = {}, _u = {}, Bu = {}, Fu = {}, K = "web", $u = [];
1766
+ let cu = [], K = {}, _u = {}, Bu = {}, Fu = {}, Y = "web", $u = [];
1767
1767
  function Xe(e, u, t = "", a) {
1768
- return ru = [], Q = {}, _u = a?.handlers || {}, Fu = a?.styles || {}, K = a?.platform || "web", $u = a?.imports || [], Bu = a?.directives || {}, {
1768
+ return cu = [], K = {}, _u = a?.handlers || {}, Fu = a?.styles || {}, Y = a?.platform || "web", $u = a?.imports || [], Bu = a?.directives || {}, {
1769
1769
  nodes: (Vu({
1770
1770
  id: e,
1771
1771
  filename: u,
@@ -1773,8 +1773,8 @@ function Xe(e, u, t = "", a) {
1773
1773
  isProd: !0,
1774
1774
  slotted: !0
1775
1775
  }).ast?.children || []).map((n) => G(n)).filter((n) => !!n),
1776
- slots: ru,
1777
- context: Q
1776
+ slots: cu,
1777
+ context: K
1778
1778
  };
1779
1779
  }
1780
1780
  function Ze(e) {
@@ -1783,7 +1783,7 @@ function Ze(e) {
1783
1783
  const t = [];
1784
1784
  for (const [a, i] of Object.entries(e.props || {}))
1785
1785
  a === "name" ? u = i : t.push(a);
1786
- ru.push({
1786
+ cu.push({
1787
1787
  name: u,
1788
1788
  params: t
1789
1789
  });
@@ -1792,7 +1792,7 @@ function Ze(e) {
1792
1792
  function Qe(e) {
1793
1793
  const u = {};
1794
1794
  for (const t of e) {
1795
- if (t.type === g.ATTRIBUTE)
1795
+ if (t.type === x.ATTRIBUTE)
1796
1796
  if (t.name === "class") {
1797
1797
  const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, s = a.match(i)?.[0] || "", r = a.split(" ").filter((o) => o !== s), n = Fu[`.${s}`];
1798
1798
  n && (u.style = n), r.length && (u.class = r.join(" "));
@@ -1801,7 +1801,7 @@ function Qe(e) {
1801
1801
  a && (u.style = ju(a));
1802
1802
  } else
1803
1803
  u[t.name] = t.value?.content || "";
1804
- if (t.type === g.DIRECTIVE && t.name === "bind" && (t.exp?.type === g.SIMPLE_EXPRESSION && t.arg?.type === g.SIMPLE_EXPRESSION && (u[t.arg.content] = q(`(${t.exp.content})`)), t.exp?.type === g.COMPOUND_EXPRESSION && t.arg?.type === g.SIMPLE_EXPRESSION))
1804
+ if (t.type === x.DIRECTIVE && t.name === "bind" && (t.exp?.type === x.SIMPLE_EXPRESSION && t.arg?.type === x.SIMPLE_EXPRESSION && (u[t.arg.content] = q(`(${t.exp.content})`)), t.exp?.type === x.COMPOUND_EXPRESSION && t.arg?.type === x.SIMPLE_EXPRESSION))
1805
1805
  if (t.arg.content === "class" && u.class) {
1806
1806
  const a = t.exp.ast.type, i = he(
1807
1807
  u.class,
@@ -1819,13 +1819,13 @@ function Qe(e) {
1819
1819
  function Ke(e, u = {}) {
1820
1820
  const t = {};
1821
1821
  for (const a of e)
1822
- if (a.type === g.DIRECTIVE && a.name === "on" && a.arg?.type === g.SIMPLE_EXPRESSION) {
1822
+ if (a.type === x.DIRECTIVE && a.name === "on" && a.arg?.type === x.SIMPLE_EXPRESSION) {
1823
1823
  const i = a.modifiers.reduce(
1824
1824
  (l, f) => (l[f.content] = !0, l),
1825
1825
  {}
1826
1826
  );
1827
1827
  let s = a.exp?.loc.source || "";
1828
- /\)$/.test(s) && (s = `($event) => { ${s} } `);
1828
+ /\)$/.test(s) && (s = `($event) => { ${s} } `), s || (s = "() => {}");
1829
1829
  const n = new RegExp(`${a.arg.content}_[\\w]{5,}`), o = s.match(n)?.[0] || "", c = u[o];
1830
1830
  if (o && c)
1831
1831
  t[a.arg.content] = {
@@ -1837,16 +1837,16 @@ function Ke(e, u = {}) {
1837
1837
  const l = a.exp?.ast?.type === "AssignmentExpression";
1838
1838
  t[a.arg.content] = {
1839
1839
  name: a.arg.content,
1840
- handler: du(l ? `()=> {${s}}` : `(${s})`),
1840
+ handler: fu(l ? `()=> {${s}}` : `(${s})`),
1841
1841
  modifiers: i
1842
1842
  };
1843
1843
  }
1844
1844
  }
1845
1845
  return t;
1846
1846
  }
1847
- function uu(e, u) {
1847
+ function Z(e, u) {
1848
1848
  const t = [], a = ["if", "for", "model", "show", "bind", "html"];
1849
- if (u && (e.type === g.IF_BRANCH || e.type === g.IF) && u.forEach((i, s) => {
1849
+ if (u && (e.type === x.IF_BRANCH || e.type === x.IF) && u.forEach((i, s) => {
1850
1850
  if (e === i) {
1851
1851
  const r = s === 0 ? "vIf" : i.condition ? "vElseIf" : "vElse", n = i.condition?.loc.source || "";
1852
1852
  t.push({
@@ -1855,20 +1855,20 @@ function uu(e, u) {
1855
1855
  });
1856
1856
  const o = e.children?.[0];
1857
1857
  if (o) {
1858
- const c = uu(o);
1858
+ const c = Z(o);
1859
1859
  t.push(...c);
1860
1860
  }
1861
1861
  }
1862
- }), e.type === g.FOR && t.push({
1862
+ }), e.type === x.FOR && t.push({
1863
1863
  name: "vFor",
1864
1864
  value: q(e.source.loc.source),
1865
1865
  iterator: {
1866
1866
  item: e.valueAlias?.loc.source || "item",
1867
1867
  index: e.keyAlias?.loc.source || "index"
1868
1868
  }
1869
- }), e.type === g.ELEMENT) {
1869
+ }), e.type === x.ELEMENT) {
1870
1870
  const i = e.props.filter(
1871
- (l) => l.type === g.DIRECTIVE
1871
+ (l) => l.type === x.DIRECTIVE
1872
1872
  ), s = i.filter((l) => l.name === "model");
1873
1873
  s.length && s.forEach((l) => {
1874
1874
  t.push({
@@ -1910,18 +1910,18 @@ function uu(e, u) {
1910
1910
  }
1911
1911
  function Ou(e) {
1912
1912
  let u = "";
1913
- if (e.type === g.ELEMENT) {
1913
+ if (e.type === x.ELEMENT) {
1914
1914
  const { props: t = [], tag: a } = e;
1915
1915
  for (const i of t)
1916
1916
  if (i.name === "class") {
1917
1917
  const s = i.value?.content || "", r = new RegExp(`${a}_([\\w]+)`);
1918
1918
  u = s.match(r)?.[1] || "";
1919
- } else if (i.type === g.DIRECTIVE && i.name === "on") {
1919
+ } else if (i.type === x.DIRECTIVE && i.name === "on") {
1920
1920
  const s = i.arg?.loc?.source || "", r = i.exp?.loc?.source || "", n = new RegExp(`${s}_([\\w]+)`);
1921
1921
  u = r.match(n)?.[1] || "";
1922
1922
  }
1923
1923
  }
1924
- return u || iu();
1924
+ return u || su();
1925
1925
  }
1926
1926
  function Ye(e) {
1927
1927
  const u = /\.\/(.+?)\.vue/;
@@ -1938,8 +1938,8 @@ function Ye(e) {
1938
1938
  }
1939
1939
  }
1940
1940
  }
1941
- function cu(e, u) {
1942
- const t = new Set(u?.id ? Q[u.id] : []), a = (e.directives || []).find((r) => r.name === "vFor");
1941
+ function nu(e, u) {
1942
+ const t = new Set(u?.id ? K[u.id] : []), a = (e.directives || []).find((r) => r.name === "vFor");
1943
1943
  let i = new Set(Array.from(t));
1944
1944
  if (a) {
1945
1945
  const { item: r = "item", index: n = "index" } = a.iterator || {};
@@ -1950,98 +1950,107 @@ function cu(e, u) {
1950
1950
  const r = typeof s == "string" ? [] : s.params || [], n = r.length ? r : [`scope_${u?.id}`];
1951
1951
  i = /* @__PURE__ */ new Set([...n, ...Array.from(i)]);
1952
1952
  }
1953
- Q[e.id] = i;
1953
+ K[e.id] = i;
1954
1954
  }
1955
- function au(e, u, t, a) {
1955
+ function iu(e, u, t, a) {
1956
1956
  const i = {
1957
- name: Ru(e.tag, K),
1957
+ name: Ru(e.tag, Y),
1958
1958
  from: Ye(e.tag),
1959
1959
  props: Qe(e.props),
1960
1960
  events: Ke(e.props, _u),
1961
- directives: uu(t || e, a)
1961
+ directives: Z(t || e, a)
1962
1962
  };
1963
- i.id = Ou(e), cu(i, u);
1964
- const s = fu(i, e.children);
1965
- return cu(i, u), Ze(s), s;
1963
+ i.id = Ou(e), nu(i, u);
1964
+ const s = uu(i, e.children);
1965
+ return nu(i, u), Ze(s), s;
1966
1966
  }
1967
1967
  function u0(e, u) {
1968
1968
  return e.map((t) => G(t, u, e));
1969
1969
  }
1970
1970
  function G(e, u, t) {
1971
- if (e.type === g.ELEMENT)
1972
- return au(e, u);
1973
- if (e.type === g.IF)
1971
+ if (e.type === x.ELEMENT)
1972
+ return iu(e, u);
1973
+ if (e.type === x.IF)
1974
1974
  return e0(e);
1975
- if (t && e.type === g.IF_BRANCH) {
1976
- const a = e.children.find((i) => i.type === g.ELEMENT);
1977
- if (a && a.type === g.ELEMENT)
1978
- return au(a, u, e, t);
1975
+ if (t && e.type === x.IF_BRANCH) {
1976
+ const a = e.children.find(
1977
+ (i) => i.type === x.ELEMENT || i.type === x.FOR
1978
+ );
1979
+ if (a) {
1980
+ if (a.type === x.ELEMENT)
1981
+ return iu(a, u, e, t);
1982
+ if (a.type === x.FOR) {
1983
+ const s = { name: "div", directives: Z(e) };
1984
+ return uu(s, e.children || []);
1985
+ }
1986
+ }
1987
+ return "";
1979
1988
  }
1980
- if (e.type === g.FOR) {
1989
+ if (e.type === x.FOR) {
1981
1990
  const a = e.children[0];
1982
- if (e.children.length > 1 || a.type !== g.ELEMENT) {
1983
- const s = { name: "span", directives: uu(e) };
1984
- return fu(s, e.children);
1991
+ if (e.children.length > 1 || a.type !== x.ELEMENT) {
1992
+ const s = { name: "span", directives: Z(e) };
1993
+ return uu(s, e.children);
1985
1994
  } else
1986
- return au(a, u, e);
1995
+ return iu(a, u, e);
1987
1996
  }
1988
- if (e.type === g.TEXT_CALL)
1989
- return e.content.type == g.TEXT ? e.content.content : e.content.type === g.INTERPOLATION ? q(e.content.content.loc.source) : e.content.type === g.COMPOUND_EXPRESSION ? Nu(
1997
+ if (e.type === x.TEXT_CALL)
1998
+ return e.content.type == x.TEXT ? e.content.content : e.content.type === x.INTERPOLATION ? q(e.content.content.loc.source) : e.content.type === x.COMPOUND_EXPRESSION ? Nu(
1990
1999
  e.content.children
1991
2000
  ) : "";
1992
- if (e.type === g.TEXT)
2001
+ if (e.type === x.TEXT)
1993
2002
  return e.content;
1994
- if (e.type === g.INTERPOLATION && (e.content.type === g.SIMPLE_EXPRESSION || e.content.type === g.COMPOUND_EXPRESSION))
2003
+ if (e.type === x.INTERPOLATION && (e.content.type === x.SIMPLE_EXPRESSION || e.content.type === x.COMPOUND_EXPRESSION))
1995
2004
  return q(e.content.loc.source);
1996
- if (e.type === g.COMPOUND_EXPRESSION)
2005
+ if (e.type === x.COMPOUND_EXPRESSION)
1997
2006
  return Nu(
1998
2007
  e.children
1999
2008
  );
2000
- e.type !== g.COMMENT && console.warn("未处理", e.type);
2009
+ e.type !== x.COMMENT && console.warn("未处理", e.type);
2001
2010
  }
2002
2011
  function Nu(e = []) {
2003
2012
  const u = e.filter((a) => typeof a != "string"), t = [];
2004
2013
  for (const a of u)
2005
2014
  t.push({
2006
2015
  name: "span",
2007
- children: a.type === g.TEXT ? a.loc.source : q(a.content?.loc.source)
2016
+ children: a.type === x.TEXT ? a.loc.source : q(a.content?.loc.source)
2008
2017
  });
2009
2018
  return {
2010
2019
  name: "span",
2011
2020
  children: t
2012
2021
  };
2013
2022
  }
2014
- function fu(e, u = []) {
2023
+ function uu(e, u = []) {
2015
2024
  const t = [];
2016
2025
  for (const a of u)
2017
- if (a.type === g.ELEMENT && a.codegenNode?.value?.arguments) {
2026
+ if (a.type === x.ELEMENT && a.codegenNode?.value?.arguments) {
2018
2027
  const i = a.codegenNode.value.arguments[0];
2019
2028
  if (i) {
2020
- const s = Au(i, K);
2029
+ const s = Au(i, Y);
2021
2030
  t.push(...s);
2022
2031
  }
2023
- } else if (a.type === g.ELEMENT && a.tag === "template") {
2032
+ } else if (a.type === x.ELEMENT && a.tag === "template") {
2024
2033
  const i = a.props.find((s) => s.name === "slot");
2025
2034
  for (const s of a.children) {
2026
- const r = s.type === g.TEXT || s.type === g.TEXT_CALL ? {
2035
+ const r = s.type === x.TEXT || s.type === x.TEXT_CALL ? {
2027
2036
  name: "span",
2028
2037
  children: G(s, e)
2029
2038
  } : G(s, e);
2030
2039
  r && (Array.isArray(r) ? r : [r]).forEach((o) => {
2031
- re(o) && i?.type === g.DIRECTIVE && (o.id = Ou(s), o.slot = {
2040
+ re(o) && i?.type === x.DIRECTIVE && (o.id = Ou(s), o.slot = {
2032
2041
  name: i.arg?.content || "default",
2033
2042
  params: i.exp?.identifiers || [],
2034
- scope: i.exp?.type === g.SIMPLE_EXPRESSION ? i.exp.content : ""
2035
- }, cu(o, e)), t.push(o);
2043
+ scope: i.exp?.type === x.SIMPLE_EXPRESSION ? i.exp.content : ""
2044
+ }, nu(o, e)), t.push(o);
2036
2045
  });
2037
2046
  }
2038
- } else if (a.type === g.JS_CALL_EXPRESSION) {
2047
+ } else if (a.type === x.JS_CALL_EXPRESSION) {
2039
2048
  const i = a.arguments?.[0];
2040
2049
  if (i) {
2041
- const s = Au(i, K);
2050
+ const s = Au(i, Y);
2042
2051
  t.push(...s);
2043
2052
  }
2044
- } else if (a.type === g.TEXT_CALL) {
2053
+ } else if (a.type === x.TEXT_CALL) {
2045
2054
  const i = G(a, e);
2046
2055
  i && (Array.isArray(i) ? t.push(...i) : t.push(i));
2047
2056
  } else {
@@ -2050,16 +2059,16 @@ function fu(e, u = []) {
2050
2059
  }
2051
2060
  if (t.length === 1) {
2052
2061
  const a = t[0];
2053
- e.children = typeof a == "string" || nu(a) ? a : [a];
2062
+ e.children = typeof a == "string" || ou(a) ? a : [a];
2054
2063
  } else
2055
2064
  e.children = t.map((a) => typeof a == "string" ? { name: "span", children: a } : a);
2056
2065
  return e;
2057
2066
  }
2058
2067
  function e0(e) {
2059
2068
  const u = e.branches || [], t = u[0], a = t.children || [];
2060
- if (t?.isTemplateIf || a.length > 1 || a[0].type !== g.ELEMENT) {
2061
- const s = { name: "span", directives: uu(t, u) };
2062
- return fu(s, t.children);
2069
+ if (t?.isTemplateIf || a.length > 1 || a[0].type !== x.ELEMENT) {
2070
+ const s = { name: "span", directives: Z(t, u) };
2071
+ return uu(s, t.children);
2063
2072
  } else
2064
2073
  return u0(u);
2065
2074
  }
@@ -2185,17 +2194,17 @@ function r0(e) {
2185
2194
  for (; (c = o.exec(s)) !== null; ) {
2186
2195
  const b = c[0], S = c[1], I = F(S, i);
2187
2196
  if (I !== S) {
2188
- const x = B(s, c.index);
2197
+ const g = B(s, c.index);
2189
2198
  n.push({
2190
2199
  start: c.index,
2191
2200
  end: c.index + b.length,
2192
2201
  original: b,
2193
2202
  replacement: `{{${I}}}`,
2194
- line: x.line,
2195
- column: x.column
2203
+ line: g.line,
2204
+ column: g.column
2196
2205
  }), u.push({
2197
- line: x.line + 1,
2198
- column: x.column,
2206
+ line: g.line + 1,
2207
+ column: g.column,
2199
2208
  original: S.trim(),
2200
2209
  fixed: I.trim(),
2201
2210
  message: "修复插值表达式:添加 state. 前缀"
@@ -2204,42 +2213,42 @@ function r0(e) {
2204
2213
  }
2205
2214
  const l = /:(\w+)="([^"]+)"/g;
2206
2215
  for (; (c = l.exec(s)) !== null; ) {
2207
- const b = c[0], S = c[1], I = c[2], x = F(I, i);
2208
- if (x !== I) {
2216
+ const b = c[0], S = c[1], I = c[2], g = F(I, i);
2217
+ if (g !== I) {
2209
2218
  const w = B(s, c.index);
2210
2219
  n.push({
2211
2220
  start: c.index,
2212
2221
  end: c.index + b.length,
2213
2222
  original: b,
2214
- replacement: `:${S}="${x}"`,
2223
+ replacement: `:${S}="${g}"`,
2215
2224
  line: w.line,
2216
2225
  column: w.column
2217
2226
  }), u.push({
2218
2227
  line: w.line + 1,
2219
2228
  column: w.column,
2220
2229
  original: I,
2221
- fixed: x,
2230
+ fixed: g,
2222
2231
  message: "修复绑定属性:添加 state. 前缀"
2223
2232
  });
2224
2233
  }
2225
2234
  }
2226
2235
  const f = /v-(if|else-if|show)="([^"]+)"/g;
2227
2236
  for (; (c = f.exec(s)) !== null; ) {
2228
- const b = c[0], S = c[1], I = c[2], x = F(I, i);
2229
- if (x !== I) {
2237
+ const b = c[0], S = c[1], I = c[2], g = F(I, i);
2238
+ if (g !== I) {
2230
2239
  const w = B(s, c.index);
2231
2240
  n.push({
2232
2241
  start: c.index,
2233
2242
  end: c.index + b.length,
2234
2243
  original: b,
2235
- replacement: `v-${S}="${x}"`,
2244
+ replacement: `v-${S}="${g}"`,
2236
2245
  line: w.line,
2237
2246
  column: w.column
2238
2247
  }), u.push({
2239
2248
  line: w.line + 1,
2240
2249
  column: w.column,
2241
2250
  original: I,
2242
- fixed: x,
2251
+ fixed: g,
2243
2252
  message: `修复 v-${S} 指令:添加 state. 前缀`
2244
2253
  });
2245
2254
  }
@@ -2248,17 +2257,17 @@ function r0(e) {
2248
2257
  for (; (c = m.exec(s)) !== null; ) {
2249
2258
  const b = c[0], I = c[1].match(/^(.+)\s+in\s+(.+)$/);
2250
2259
  if (I) {
2251
- const [, x, w] = I, R = F(
2260
+ const [, g, w] = I, R = F(
2252
2261
  w,
2253
2262
  i
2254
2263
  );
2255
2264
  if (R !== w) {
2256
- const U = B(s, c.index), eu = `v-for="${x} in ${R}"`;
2265
+ const U = B(s, c.index), tu = `v-for="${g} in ${R}"`;
2257
2266
  n.push({
2258
2267
  start: c.index,
2259
2268
  end: c.index + b.length,
2260
2269
  original: b,
2261
- replacement: eu,
2270
+ replacement: tu,
2262
2271
  line: U.line,
2263
2272
  column: U.column
2264
2273
  }), u.push({
@@ -2275,17 +2284,17 @@ function r0(e) {
2275
2284
  for (; (c = p.exec(s)) !== null; ) {
2276
2285
  const b = c[0], S = c[1], I = F(S, i);
2277
2286
  if (I !== S) {
2278
- const x = B(s, c.index);
2287
+ const g = B(s, c.index);
2279
2288
  n.push({
2280
2289
  start: c.index,
2281
2290
  end: c.index + b.length,
2282
2291
  original: b,
2283
2292
  replacement: `v-model="${I}"`,
2284
- line: x.line,
2285
- column: x.column
2293
+ line: g.line,
2294
+ column: g.column
2286
2295
  }), u.push({
2287
- line: x.line + 1,
2288
- column: x.column,
2296
+ line: g.line + 1,
2297
+ column: g.column,
2289
2298
  original: S,
2290
2299
  fixed: I,
2291
2300
  message: "修复 v-model 指令:添加 state. 前缀"
@@ -2296,17 +2305,17 @@ function r0(e) {
2296
2305
  for (; (c = v.exec(s)) !== null; ) {
2297
2306
  const b = c[0], S = c[1], I = F(S, i);
2298
2307
  if (I !== S) {
2299
- const x = B(s, c.index);
2308
+ const g = B(s, c.index);
2300
2309
  n.push({
2301
2310
  start: c.index,
2302
2311
  end: c.index + b.length,
2303
2312
  original: b,
2304
2313
  replacement: `v-bind="${I}"`,
2305
- line: x.line,
2306
- column: x.column
2314
+ line: g.line,
2315
+ column: g.column
2307
2316
  }), u.push({
2308
- line: x.line + 1,
2309
- column: x.column,
2317
+ line: g.line + 1,
2318
+ column: g.column,
2310
2319
  original: S,
2311
2320
  fixed: I,
2312
2321
  message: "修复 v-bind 指令:添加 state. 前缀"
@@ -2315,29 +2324,29 @@ function r0(e) {
2315
2324
  }
2316
2325
  const A = /v-(text|html)="([^"]+)"/g;
2317
2326
  for (; (c = A.exec(s)) !== null; ) {
2318
- const b = c[0], S = c[1], I = c[2], x = F(I, i);
2319
- if (x !== I) {
2327
+ const b = c[0], S = c[1], I = c[2], g = F(I, i);
2328
+ if (g !== I) {
2320
2329
  const w = B(s, c.index);
2321
2330
  n.push({
2322
2331
  start: c.index,
2323
2332
  end: c.index + b.length,
2324
2333
  original: b,
2325
- replacement: `v-${S}="${x}"`,
2334
+ replacement: `v-${S}="${g}"`,
2326
2335
  line: w.line,
2327
2336
  column: w.column
2328
2337
  }), u.push({
2329
2338
  line: w.line + 1,
2330
2339
  column: w.column,
2331
2340
  original: I,
2332
- fixed: x,
2341
+ fixed: g,
2333
2342
  message: `修复 v-${S} 指令:添加 state. 前缀`
2334
2343
  });
2335
2344
  }
2336
2345
  }
2337
2346
  const y = /(@|v-on:)(\w+)="([^"]+)"/g;
2338
2347
  for (; (c = y.exec(s)) !== null; ) {
2339
- const b = c[0], S = c[1], I = c[2], x = c[3], w = n0(x, i);
2340
- if (w !== x) {
2348
+ const b = c[0], S = c[1], I = c[2], g = c[3], w = n0(g, i);
2349
+ if (w !== g) {
2341
2350
  const R = B(s, c.index);
2342
2351
  n.push({
2343
2352
  start: c.index,
@@ -2349,7 +2358,7 @@ function r0(e) {
2349
2358
  }), u.push({
2350
2359
  line: R.line + 1,
2351
2360
  column: R.column,
2352
- original: x,
2361
+ original: g,
2353
2362
  fixed: w,
2354
2363
  message: "修复事件处理器:添加 state. 前缀"
2355
2364
  });
@@ -2374,7 +2383,7 @@ function c0(e) {
2374
2383
  const u = /* @__PURE__ */ new Set();
2375
2384
  try {
2376
2385
  const t = W(e);
2377
- Y(t, {
2386
+ eu(t, {
2378
2387
  CallExpression(a) {
2379
2388
  if (a.node.callee.type === "Identifier" && a.node.callee.name === "reactive" && a.node.arguments.length > 0 && a.node.arguments[0].type === "ObjectExpression") {
2380
2389
  const i = a.parent;
@@ -2533,11 +2542,11 @@ async function A0(e) {
2533
2542
  state: b,
2534
2543
  watch: S,
2535
2544
  lifeCycles: I,
2536
- computed: x,
2545
+ computed: g,
2537
2546
  methods: w,
2538
2547
  props: R,
2539
2548
  emits: U,
2540
- expose: eu,
2549
+ expose: tu,
2541
2550
  inject: Pu,
2542
2551
  handlers: Uu,
2543
2552
  imports: lu,
@@ -2557,15 +2566,15 @@ async function A0(e) {
2557
2566
  state: b,
2558
2567
  watch: S,
2559
2568
  lifeCycles: I,
2560
- computed: x,
2569
+ computed: g,
2561
2570
  methods: w,
2562
2571
  dataSources: Hu,
2563
2572
  slots: zu,
2564
2573
  emits: U,
2565
- expose: eu,
2574
+ expose: tu,
2566
2575
  nodes: Wu,
2567
2576
  css: A
2568
- }, Xu = Object.keys(x || {}), Zu = [
2577
+ }, Xu = Object.keys(g || {}), Zu = [
2569
2578
  "$el",
2570
2579
  "$emit",
2571
2580
  "$nextTick",
@@ -2593,7 +2602,7 @@ async function A0(e) {
2593
2602
  bu,
2594
2603
  async (z) => {
2595
2604
  await f0(z, async (J) => {
2596
- if (ou(J)) {
2605
+ if (du(J)) {
2597
2606
  const Ku = await xu(J.value);
2598
2607
  J.value = gu(Ku, z.id, hu);
2599
2608
  }
@@ -2607,8 +2616,8 @@ async function A0(e) {
2607
2616
  }
2608
2617
  async function d0(e, u, t) {
2609
2618
  const a = async (p, v) => {
2610
- if (await u(p, v), Array.isArray(p.children))
2611
- for (const A of p.children)
2619
+ if (await u(p, v), Array.isArray(p?.children))
2620
+ for (const A of p?.children || [])
2612
2621
  await a(A, p);
2613
2622
  }, i = async (p) => {
2614
2623
  if (!p || typeof p != "object") return;
@@ -2619,7 +2628,7 @@ async function d0(e, u, t) {
2619
2628
  }
2620
2629
  const v = Object.values(p);
2621
2630
  for (const A of v)
2622
- ou(A) ? await t(A) : await i(A);
2631
+ du(A) ? await t(A) : await i(A);
2623
2632
  }, {
2624
2633
  state: s,
2625
2634
  watch: r,
@@ -2651,7 +2660,7 @@ async function f0(e, u) {
2651
2660
  await u(s), await t(s);
2652
2661
  return;
2653
2662
  }
2654
- if (ou(a)) {
2663
+ if (du(a)) {
2655
2664
  await u(a);
2656
2665
  return;
2657
2666
  }