@vtj/parser 0.12.10 → 0.12.11

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
@@ -11,10 +11,10 @@ import Pu from "postcss";
11
11
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
12
12
  * @name @vtj/parser
13
13
  * @author CHC chenhuachun1549@dingtalk.com
14
- * @version 0.12.10
14
+ * @version 0.12.11
15
15
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
16
16
  */
17
- const J0 = "0.12.10";
17
+ const X0 = "0.12.11";
18
18
  function ru(e) {
19
19
  const { descriptor: u } = Lu(e), t = u.template?.content || "", a = (u.scriptSetup || u.script)?.content || "", i = u.styles.map((c) => c.content);
20
20
  return {
@@ -55,7 +55,7 @@ function G(e) {
55
55
  function Uu(e) {
56
56
  return !!e && !H(e) && typeof e != "string";
57
57
  }
58
- function X0(e) {
58
+ function z0(e) {
59
59
  const u = ru(e), t = nu(u.script), a = {};
60
60
  return u.styles && (a.css = u.styles[0] || ""), du(t, {
61
61
  CallExpression(i) {
@@ -72,9 +72,9 @@ function X0(e) {
72
72
  }
73
73
  function O(e, u, t) {
74
74
  const a = new RegExp(`${u}`, "g"), i = /(\@\_|\$|\.|\,|\w)$/, c = /^\w/, s = new RegExp(`^this.${u}$`, "g");
75
- return e.replace(a, (d, f, h) => {
76
- const b = h.substring(0, f), S = h.substring(f + u.length);
77
- return i.test(b.trim()) || c.test(S.trim()) ? d : t;
75
+ return e.replace(a, (n, f, h) => {
76
+ const b = h.substring(0, f), E = h.substring(f + u.length);
77
+ return i.test(b.trim()) || c.test(E.trim()) ? n : t;
78
78
  }).replace(s, t);
79
79
  }
80
80
  function K(e, u, t) {
@@ -83,10 +83,10 @@ function K(e, u, t) {
83
83
  computed: i = [],
84
84
  libs: c = {},
85
85
  members: s = [],
86
- platform: n
87
- } = t || {}, d = Array.from(a[u || ""] || /* @__PURE__ */ new Set());
88
- if (d)
89
- for (const f of d)
86
+ platform: d
87
+ } = t || {}, n = Array.from(a[u || ""] || /* @__PURE__ */ new Set());
88
+ if (n)
89
+ for (const f of n)
90
90
  e = O(e, f, `this.context.${f}`);
91
91
  for (const f of i)
92
92
  e = O(e, f, `this.${f}.value`);
@@ -94,13 +94,13 @@ function K(e, u, t) {
94
94
  e = O(e, f, `this.$libs.${h}.${f}`);
95
95
  for (const f of s)
96
96
  e = O(e, f, `this.${f}`);
97
- if (n === "uniapp") {
97
+ if (d === "uniapp") {
98
98
  const f = /\buni\./g;
99
99
  e = e.replace(f, "this.$libs.UniH5.uni.");
100
100
  }
101
101
  return e = e.replace(/_ctx\./g, "this."), e;
102
102
  }
103
- function w(e) {
103
+ function v(e) {
104
104
  return {
105
105
  type: "JSExpression",
106
106
  value: /^\{[\w\W]*\}$/.test(e) ? `(${e})` : e
@@ -424,18 +424,18 @@ function a0(e, u, t, a) {
424
424
  if (i === 0)
425
425
  return c !== 0 && a === c ? t : -1;
426
426
  if (c) {
427
- const d = a - c;
428
- return d < 0 || d >= i ? -1 : e[t + d] - 1;
427
+ const n = a - c;
428
+ return n < 0 || n >= i ? -1 : e[t + n] - 1;
429
429
  }
430
- let s = t, n = s + i - 1;
431
- for (; s <= n; ) {
432
- const d = s + n >>> 1, f = e[d];
430
+ let s = t, d = s + i - 1;
431
+ for (; s <= d; ) {
432
+ const n = s + d >>> 1, f = e[n];
433
433
  if (f < a)
434
- s = d + 1;
434
+ s = n + 1;
435
435
  else if (f > a)
436
- n = d - 1;
436
+ d = n - 1;
437
437
  else
438
- return e[d + i];
438
+ return e[n + i];
439
439
  }
440
440
  return -1;
441
441
  }
@@ -902,8 +902,8 @@ const k = /* @__PURE__ */ new Set([
902
902
  ]), n0 = /\s|\//;
903
903
  class d0 {
904
904
  constructor(u, t = {}) {
905
- var a, i, c, s, n, d;
906
- this.options = t, this.startIndex = 0, this.endIndex = 0, this.openTagStart = 0, this.tagname = "", this.attribname = "", this.attribvalue = "", this.attribs = null, this.stack = [], this.buffers = [], this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1, this.cbs = u ?? {}, this.htmlMode = !this.options.xmlMode, this.lowerCaseTagNames = (a = t.lowerCaseTags) !== null && a !== void 0 ? a : this.htmlMode, this.lowerCaseAttributeNames = (i = t.lowerCaseAttributeNames) !== null && i !== void 0 ? i : this.htmlMode, this.recognizeSelfClosing = (c = t.recognizeSelfClosing) !== null && c !== void 0 ? c : !this.htmlMode, this.tokenizer = new ((s = t.Tokenizer) !== null && s !== void 0 ? s : c0)(this.options, this), this.foreignContext = [!this.htmlMode], (d = (n = this.cbs).onparserinit) === null || d === void 0 || d.call(n, this);
905
+ var a, i, c, s, d, n;
906
+ this.options = t, this.startIndex = 0, this.endIndex = 0, this.openTagStart = 0, this.tagname = "", this.attribname = "", this.attribvalue = "", this.attribs = null, this.stack = [], this.buffers = [], this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1, this.cbs = u ?? {}, this.htmlMode = !this.options.xmlMode, this.lowerCaseTagNames = (a = t.lowerCaseTags) !== null && a !== void 0 ? a : this.htmlMode, this.lowerCaseAttributeNames = (i = t.lowerCaseAttributeNames) !== null && i !== void 0 ? i : this.htmlMode, this.recognizeSelfClosing = (c = t.recognizeSelfClosing) !== null && c !== void 0 ? c : !this.htmlMode, this.tokenizer = new ((s = t.Tokenizer) !== null && s !== void 0 ? s : c0)(this.options, this), this.foreignContext = [!this.htmlMode], (n = (d = this.cbs).onparserinit) === null || n === void 0 || n.call(d, this);
907
907
  }
908
908
  // Tokenizer event handlers
909
909
  /** @internal */
@@ -936,8 +936,8 @@ class d0 {
936
936
  const s = this.htmlMode && s0.get(u);
937
937
  if (s)
938
938
  for (; this.stack.length > 0 && s.has(this.stack[0]); ) {
939
- const n = this.stack.shift();
940
- (a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t, n, !0);
939
+ const d = this.stack.shift();
940
+ (a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t, d, !0);
941
941
  }
942
942
  this.isVoidElement(u) || (this.stack.unshift(u), this.htmlMode && (au.has(u) ? this.foreignContext.unshift(!0) : iu.has(u) && this.foreignContext.unshift(!1))), (c = (i = this.cbs).onopentagname) === null || c === void 0 || c.call(i, u), this.cbs.onopentag && (this.attribs = {});
943
943
  }
@@ -951,17 +951,17 @@ class d0 {
951
951
  }
952
952
  /** @internal */
953
953
  onclosetag(u, t) {
954
- var a, i, c, s, n, d, f, h;
954
+ var a, i, c, s, d, n, f, h;
955
955
  this.endIndex = t;
956
956
  let b = this.getSlice(u, t);
957
957
  if (this.lowerCaseTagNames && (b = b.toLowerCase()), this.htmlMode && (au.has(b) || iu.has(b)) && this.foreignContext.shift(), this.isVoidElement(b))
958
- this.htmlMode && b === "br" && ((s = (c = this.cbs).onopentagname) === null || s === void 0 || s.call(c, "br"), (d = (n = this.cbs).onopentag) === null || d === void 0 || d.call(n, "br", {}, !0), (h = (f = this.cbs).onclosetag) === null || h === void 0 || h.call(f, "br", !1));
958
+ this.htmlMode && b === "br" && ((s = (c = this.cbs).onopentagname) === null || s === void 0 || s.call(c, "br"), (n = (d = this.cbs).onopentag) === null || n === void 0 || n.call(d, "br", {}, !0), (h = (f = this.cbs).onclosetag) === null || h === void 0 || h.call(f, "br", !1));
959
959
  else {
960
- const S = this.stack.indexOf(b);
961
- if (S !== -1)
962
- for (let m = 0; m <= S; m++) {
963
- const E = this.stack.shift();
964
- (i = (a = this.cbs).onclosetag) === null || i === void 0 || i.call(a, E, m !== S);
960
+ const E = this.stack.indexOf(b);
961
+ if (E !== -1)
962
+ for (let m = 0; m <= E; m++) {
963
+ const S = this.stack.shift();
964
+ (i = (a = this.cbs).onclosetag) === null || i === void 0 || i.call(a, S, m !== E);
965
965
  }
966
966
  else this.htmlMode && b === "p" && (this.emitOpenTag("p"), this.closeCurrentTag(!0));
967
967
  }
@@ -1022,15 +1022,15 @@ class d0 {
1022
1022
  }
1023
1023
  /** @internal */
1024
1024
  oncomment(u, t, a) {
1025
- var i, c, s, n;
1026
- this.endIndex = t, (c = (i = this.cbs).oncomment) === null || c === void 0 || c.call(i, this.getSlice(u, t - a)), (n = (s = this.cbs).oncommentend) === null || n === void 0 || n.call(s), this.startIndex = t + 1;
1025
+ var i, c, s, d;
1026
+ this.endIndex = t, (c = (i = this.cbs).oncomment) === null || c === void 0 || c.call(i, this.getSlice(u, t - a)), (d = (s = this.cbs).oncommentend) === null || d === void 0 || d.call(s), this.startIndex = t + 1;
1027
1027
  }
1028
1028
  /** @internal */
1029
1029
  oncdata(u, t, a) {
1030
- var i, c, s, n, d, f, h, b, S, m;
1030
+ var i, c, s, d, n, f, h, b, E, m;
1031
1031
  this.endIndex = t;
1032
- const E = this.getSlice(u, t - a);
1033
- !this.htmlMode || this.options.recognizeCDATA ? ((c = (i = this.cbs).oncdatastart) === null || c === void 0 || c.call(i), (n = (s = this.cbs).ontext) === null || n === void 0 || n.call(s, E), (f = (d = this.cbs).oncdataend) === null || f === void 0 || f.call(d)) : ((b = (h = this.cbs).oncomment) === null || b === void 0 || b.call(h, `[CDATA[${E}]]`), (m = (S = this.cbs).oncommentend) === null || m === void 0 || m.call(S)), this.startIndex = t + 1;
1032
+ const S = this.getSlice(u, t - a);
1033
+ !this.htmlMode || this.options.recognizeCDATA ? ((c = (i = this.cbs).oncdatastart) === null || c === void 0 || c.call(i), (d = (s = this.cbs).ontext) === null || d === void 0 || d.call(s, S), (f = (n = this.cbs).oncdataend) === null || f === void 0 || f.call(n)) : ((b = (h = this.cbs).oncomment) === null || b === void 0 || b.call(h, `[CDATA[${S}]]`), (m = (E = this.cbs).oncommentend) === null || m === void 0 || m.call(E)), this.startIndex = t + 1;
1034
1034
  }
1035
1035
  /** @internal */
1036
1036
  onend() {
@@ -1133,16 +1133,16 @@ function cu(e) {
1133
1133
  let a = "";
1134
1134
  const i = new d0(
1135
1135
  {
1136
- onopentag: (c, s, n) => {
1137
- const d = t[t.length - 1];
1138
- a.trim() && (Array.isArray(d.children) ? d.children.push({
1136
+ onopentag: (c, s, d) => {
1137
+ const n = t[t.length - 1];
1138
+ a.trim() && (Array.isArray(n.children) ? n.children.push({
1139
1139
  name: "text",
1140
1140
  children: a.trim()
1141
- }) : d.children = a.trim(), a = "");
1141
+ }) : n.children = a.trim(), a = "");
1142
1142
  const f = Object.entries(s || {}).reduce(
1143
- (b, S) => {
1144
- let [m = "", E = ""] = S;
1145
- return m = m.replace(/\\\"/g, ""), E = E.replace(/\\\"/g, ""), m && (b[m] = E), b;
1143
+ (b, E) => {
1144
+ let [m = "", S = ""] = E;
1145
+ return m = m.replace(/\\\"/g, ""), S = S.replace(/\\\"/g, ""), m && (b[m] = S), b;
1146
1146
  },
1147
1147
  {}
1148
1148
  );
@@ -1151,13 +1151,13 @@ function cu(e) {
1151
1151
  name: c,
1152
1152
  props: f
1153
1153
  };
1154
- Array.isArray(d.children) ? d.children.push(h) : d.children ? d.children = [
1154
+ Array.isArray(n.children) ? n.children.push(h) : n.children ? n.children = [
1155
1155
  {
1156
1156
  name: "span",
1157
- children: d.children
1157
+ children: n.children
1158
1158
  },
1159
1159
  h
1160
- ] : d.children = [h], n || t.push(h);
1160
+ ] : n.children = [h], d || t.push(h);
1161
1161
  },
1162
1162
  ontext: (c) => {
1163
1163
  const s = c.trim();
@@ -1184,7 +1184,7 @@ function f0(e, u, t = "", a) {
1184
1184
  source: t,
1185
1185
  isProd: !0,
1186
1186
  slotted: !0
1187
- }).ast?.children || []).map((n) => D(n)).filter((n) => !!n),
1187
+ }).ast?.children || []).map((d) => _(d)).filter((d) => !!d),
1188
1188
  slots: j,
1189
1189
  context: P
1190
1190
  };
@@ -1206,23 +1206,23 @@ function b0(e) {
1206
1206
  for (const t of e) {
1207
1207
  if (t.type === l.ATTRIBUTE)
1208
1208
  if (t.name === "class") {
1209
- const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((d) => d !== c), n = bu[`.${c}`];
1210
- n && (u.style = n), s.length && (u.class = s.join(" "));
1209
+ const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((n) => n !== c), d = bu[`.${c}`];
1210
+ d && (u.style = d), s.length && (u.class = s.join(" "));
1211
1211
  } else if (t.name === "style") {
1212
1212
  const a = t.value?.content || "";
1213
1213
  a && (u.style = fu(a));
1214
1214
  } else
1215
1215
  u[t.name] = t.value?.content || "";
1216
- if (t.type === l.DIRECTIVE && t.name === "bind" && (t.exp?.type === l.SIMPLE_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION && (u[t.arg.content] = w(`(${t.exp.content})`)), t.exp?.type === l.COMPOUND_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION))
1216
+ if (t.type === l.DIRECTIVE && t.name === "bind" && (t.exp?.type === l.SIMPLE_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION && (u[t.arg.content] = v(`(${t.exp.content})`)), t.exp?.type === l.COMPOUND_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION))
1217
1217
  if (t.arg.content === "class" && u.class) {
1218
1218
  const a = t.exp.ast.type, i = Xu(
1219
1219
  u.class,
1220
1220
  t.exp.loc.source,
1221
1221
  a
1222
1222
  );
1223
- i && (u[t.arg.content] = w(i));
1223
+ i && (u[t.arg.content] = v(i));
1224
1224
  } else
1225
- u[t.arg.content] = w(
1225
+ u[t.arg.content] = v(
1226
1226
  `(${t.exp.loc.source})`
1227
1227
  );
1228
1228
  }
@@ -1238,8 +1238,8 @@ function l0(e, u = {}) {
1238
1238
  );
1239
1239
  let c = a.exp?.loc.source || "";
1240
1240
  /\)$/.test(c) && (c = `($event) => { ${c} } `);
1241
- const n = new RegExp(`${a.arg.content}_[\\w]{5,}`), d = c.match(n)?.[0] || "", f = u[d];
1242
- if (d && f)
1241
+ const d = new RegExp(`${a.arg.content}_[\\w]{5,}`), n = c.match(d)?.[0] || "", f = u[n];
1242
+ if (n && f)
1243
1243
  t[a.arg.content] = {
1244
1244
  name: a.arg.content,
1245
1245
  handler: f,
@@ -1256,60 +1256,61 @@ function l0(e, u = {}) {
1256
1256
  }
1257
1257
  return t;
1258
1258
  }
1259
- function h0(e) {
1260
- const u = [];
1261
- if (e.type === l.IF) {
1262
- const t = e.codegenNode?.test;
1263
- t && u.push({
1264
- name: "vIf",
1265
- value: w(t.loc.source)
1266
- });
1267
- }
1268
- if (e.type === l.FOR && u.push({
1259
+ function h0(e, u) {
1260
+ const t = [];
1261
+ if (u && e.type === l.IF_BRANCH && u.forEach((a, i) => {
1262
+ if (e === a) {
1263
+ const c = i === 0 ? "vIf" : a.condition ? "vElseIf" : "vElse", s = a.condition?.loc.source || "";
1264
+ t.push({
1265
+ name: c,
1266
+ value: c === "vElse" ? !0 : v(s)
1267
+ });
1268
+ }
1269
+ }), e.type === l.FOR && t.push({
1269
1270
  name: "vFor",
1270
- value: w(e.source.loc.source),
1271
+ value: v(e.source.loc.source),
1271
1272
  iterator: {
1272
1273
  item: e.valueAlias?.loc.source || "item",
1273
1274
  index: e.keyAlias?.loc.source || "index"
1274
1275
  }
1275
1276
  }), e.type === l.ELEMENT) {
1276
- const t = e.props.filter(
1277
+ const a = e.props.filter(
1277
1278
  (n) => n.type === l.DIRECTIVE
1278
- ), a = t.filter((n) => n.name === "model");
1279
- a.length && a.forEach((n) => {
1280
- u.push({
1279
+ ), i = a.filter((n) => n.name === "model");
1280
+ i.length && i.forEach((n) => {
1281
+ t.push({
1281
1282
  name: "vModel",
1282
1283
  arg: n.arg?.content,
1283
- value: w(n.exp?.loc.source || "")
1284
+ value: v(n.exp?.loc.source || "")
1284
1285
  });
1285
1286
  });
1286
- const i = t.find((n) => n.name === "show");
1287
- i && u.push({
1287
+ const c = a.find((n) => n.name === "show");
1288
+ c && t.push({
1288
1289
  name: "vShow",
1289
- value: w(i.exp?.loc.source || "")
1290
+ value: v(c.exp?.loc.source || "")
1290
1291
  });
1291
- const c = t.find((n) => n.name === "bind" && !n.arg);
1292
- c && u.push({
1292
+ const s = a.find((n) => n.name === "bind" && !n.arg);
1293
+ s && t.push({
1293
1294
  name: "vBind",
1294
- value: w(c.exp?.loc.source || "")
1295
+ value: v(s.exp?.loc.source || "")
1295
1296
  });
1296
- const s = t.find((n) => n.name === "html");
1297
- s && u.push({
1297
+ const d = a.find((n) => n.name === "html");
1298
+ d && t.push({
1298
1299
  name: "vHtml",
1299
- value: w(s.exp?.loc.source || "")
1300
+ value: v(d.exp?.loc.source || "")
1300
1301
  });
1301
1302
  }
1302
- return u;
1303
+ return t;
1303
1304
  }
1304
1305
  function hu(e) {
1305
1306
  let u = "";
1306
1307
  const { name: t, props: a, events: i = {} } = e, c = a?.class || "";
1307
1308
  if (typeof c == "string") {
1308
- const s = new RegExp(`${t}_([\\w]+)`), n = c.match(s);
1309
- n && n[1] && (u = n[1]);
1309
+ const s = new RegExp(`${t}_([\\w]+)`), d = c.match(s);
1310
+ d && d[1] && (u = d[1]);
1310
1311
  }
1311
- for (const { name: s, handler: n } of Object.values(i)) {
1312
- const d = new RegExp(`${s}_([\\w]+)`), f = n.value.match(d);
1312
+ for (const { name: s, handler: d } of Object.values(i)) {
1313
+ const n = new RegExp(`${s}_([\\w]+)`), f = d.value.match(n);
1313
1314
  f && f[1] && (u = f[1]);
1314
1315
  }
1315
1316
  return u || Vu();
@@ -1318,57 +1319,62 @@ function F(e, u) {
1318
1319
  const t = new Set(u?.id ? P[u.id] : []), a = (e.directives || []).find((s) => s.name === "vFor");
1319
1320
  let i = new Set(Array.from(t));
1320
1321
  if (a) {
1321
- const { item: s = "item", index: n = "index" } = a.iterator || {};
1322
- i = /* @__PURE__ */ new Set([s, n, ...Array.from(i)]);
1322
+ const { item: s = "item", index: d = "index" } = a.iterator || {};
1323
+ i = /* @__PURE__ */ new Set([s, d, ...Array.from(i)]);
1323
1324
  }
1324
1325
  const c = e.slot;
1325
1326
  if (c) {
1326
- const s = typeof c == "string" ? [] : c.params || [], n = s.length ? s : [`scope_${u?.id}`];
1327
- i = /* @__PURE__ */ new Set([...n, ...Array.from(i)]);
1327
+ const s = typeof c == "string" ? [] : c.params || [], d = s.length ? s : [`scope_${u?.id}`];
1328
+ i = /* @__PURE__ */ new Set([...d, ...Array.from(i)]);
1328
1329
  }
1329
1330
  P[e.id] = i;
1330
1331
  }
1331
- function U(e, u, t) {
1332
- const a = {
1332
+ function U(e, u, t, a) {
1333
+ const i = {
1333
1334
  name: Cu(e.tag, lu),
1334
1335
  props: b0(e.props),
1335
1336
  events: l0(e.props, ou),
1336
- directives: h0(t || e)
1337
+ directives: h0(t || e, a)
1337
1338
  };
1338
- a.id = hu(a), F(a, u);
1339
- const i = m0(a, e.children);
1340
- return F(a, u), o0(i), i;
1339
+ i.id = hu(i), F(i, u);
1340
+ const c = x0(i, e.children);
1341
+ return F(i, u), o0(c), c;
1342
+ }
1343
+ function p0(e, u) {
1344
+ return e.map((t) => _(t, u, e));
1341
1345
  }
1342
- function D(e, u) {
1346
+ function _(e, u, t) {
1343
1347
  if (e.type === l.ELEMENT)
1344
1348
  return U(e, u);
1345
- if (e.type === l.IF) {
1346
- const t = e.branches[0].children[0];
1347
- if (t && t.type === l.ELEMENT)
1348
- return U(t, u, e);
1349
+ if (!t && e.type === l.IF)
1350
+ return p0(e.branches);
1351
+ if (t && e.type === l.IF_BRANCH) {
1352
+ const a = e.children[0];
1353
+ if (a && a.type === l.ELEMENT)
1354
+ return U(a, u, e, t);
1349
1355
  }
1350
1356
  if (e.type === l.FOR) {
1351
- const t = e.children[0];
1352
- if (t.type === l.ELEMENT)
1353
- return U(t, u, e);
1357
+ const a = e.children[0];
1358
+ if (a.type === l.ELEMENT)
1359
+ return U(a, u, e);
1354
1360
  }
1355
- return e.type === l.TEXT_CALL ? e.content.type == l.TEXT ? e.content.content : e.content.type === l.INTERPOLATION ? w(e.content.content.loc.source) : "" : e.type === l.TEXT ? e.content : e.type === l.INTERPOLATION && (e.content.type === l.SIMPLE_EXPRESSION || e.content.type === l.COMPOUND_EXPRESSION) ? w(e.content.loc.source) : e.type === l.COMPOUND_EXPRESSION ? p0(
1361
+ return e.type === l.TEXT_CALL ? e.content.type == l.TEXT ? e.content.content : e.content.type === l.INTERPOLATION ? v(e.content.content.loc.source) : "" : e.type === l.TEXT ? e.content : e.type === l.INTERPOLATION && (e.content.type === l.SIMPLE_EXPRESSION || e.content.type === l.COMPOUND_EXPRESSION) ? v(e.content.loc.source) : e.type === l.COMPOUND_EXPRESSION ? m0(
1356
1362
  e.children
1357
1363
  ) : (e.type === l.COMMENT || console.warn("未处理", e.type), null);
1358
1364
  }
1359
- function p0(e = []) {
1365
+ function m0(e = []) {
1360
1366
  const u = e.filter((a) => typeof a != "string"), t = [];
1361
1367
  for (const a of u)
1362
1368
  t.push({
1363
1369
  name: "span",
1364
- children: a.type === l.TEXT ? a.loc.source : w(a.content?.loc.source)
1370
+ children: a.type === l.TEXT ? a.loc.source : v(a.content?.loc.source)
1365
1371
  });
1366
1372
  return {
1367
1373
  name: "span",
1368
1374
  children: t
1369
1375
  };
1370
1376
  }
1371
- function m0(e, u = []) {
1377
+ function x0(e, u = []) {
1372
1378
  const t = [];
1373
1379
  for (const a of u)
1374
1380
  if (a.type === l.ELEMENT && a.codegenNode?.value?.arguments) {
@@ -1382,12 +1388,14 @@ function m0(e, u = []) {
1382
1388
  for (const c of a.children) {
1383
1389
  const s = c.type === l.TEXT || c.type === l.TEXT_CALL ? {
1384
1390
  name: "span",
1385
- children: D(c, e)
1386
- } : D(c, e);
1387
- s && (Uu(s) && i?.type === l.DIRECTIVE && (s.id = hu(s), s.slot = {
1388
- name: i.arg?.content || "default",
1389
- params: i.exp?.identifiers || []
1390
- }, F(s, e)), t.push(s));
1391
+ children: _(c, e)
1392
+ } : _(c, e);
1393
+ s && (Array.isArray(s) ? s : [s]).forEach((n) => {
1394
+ Uu(n) && i?.type === l.DIRECTIVE && (n.id = hu(n), n.slot = {
1395
+ name: i.arg?.content || "default",
1396
+ params: i.exp?.identifiers || []
1397
+ }, F(n, e)), t.push(n);
1398
+ });
1391
1399
  }
1392
1400
  } else if (a.type === l.JS_CALL_EXPRESSION) {
1393
1401
  const i = a.arguments?.[0];
@@ -1396,11 +1404,11 @@ function m0(e, u = []) {
1396
1404
  t.push(...c);
1397
1405
  }
1398
1406
  } else if (a.type === l.TEXT_CALL) {
1399
- const i = D(a, e);
1400
- i && t.push(i);
1407
+ const i = _(a, e);
1408
+ i && (Array.isArray(i) ? t.push(...i) : t.push(i));
1401
1409
  } else {
1402
- const i = D(a, e);
1403
- i && t.push(i);
1410
+ const i = _(a, e);
1411
+ i && (Array.isArray(i) ? t.push(...i) : t.push(i));
1404
1412
  }
1405
1413
  if (t.length === 1) {
1406
1414
  const a = t[0];
@@ -1409,9 +1417,9 @@ function m0(e, u = []) {
1409
1417
  e.children = t.map((a) => typeof a == "string" ? { name: "span", children: a } : a);
1410
1418
  return e;
1411
1419
  }
1412
- function x0(e, u) {
1420
+ function g0(e, u) {
1413
1421
  const a = {
1414
- imports: g0(e),
1422
+ imports: y0(e),
1415
1423
  emits: [],
1416
1424
  errors: []
1417
1425
  }, i = nu(e);
@@ -1419,38 +1427,38 @@ function x0(e, u) {
1419
1427
  ExportDefaultDeclaration(c) {
1420
1428
  const s = c.node.declaration;
1421
1429
  if (s.type !== "CallExpression") return;
1422
- const n = s.arguments[0];
1423
- if (n?.type !== "ObjectExpression") return;
1424
- const d = n.properties.filter(
1430
+ const d = s.arguments[0];
1431
+ if (d?.type !== "ObjectExpression") return;
1432
+ const n = d.properties.filter(
1425
1433
  (b) => b.type === "ObjectProperty"
1426
- ), f = n.properties.filter(
1434
+ ), f = d.properties.filter(
1427
1435
  (b) => b.type == "ObjectMethod"
1428
- ), h = d.find(
1436
+ ), h = n.find(
1429
1437
  (b) => b.key.name === "computed"
1430
1438
  );
1431
- h && (a.computed = pu(h.value), a.watchers = A0(h.value));
1432
- for (const b of d)
1439
+ h && (a.computed = pu(h.value), a.watchers = T0(h.value));
1440
+ for (const b of n)
1433
1441
  switch (b.key.name) {
1434
1442
  case "name":
1435
1443
  a.name = b.value.value;
1436
1444
  break;
1437
1445
  case "methods":
1438
- a.handlers = v0(b.value), a.methods = w0(b.value), a.dataSources = E0(
1446
+ a.handlers = A0(b.value), a.methods = w0(b.value), a.dataSources = v0(
1439
1447
  b.value,
1440
1448
  u
1441
1449
  );
1442
1450
  break;
1443
1451
  case "watch":
1444
- a.watch = T0(
1452
+ a.watch = I0(
1445
1453
  b.value,
1446
1454
  a.watchers
1447
1455
  );
1448
1456
  break;
1449
1457
  case "props":
1450
- a.props = q0(b.value);
1458
+ a.props = k0(b.value);
1451
1459
  break;
1452
1460
  case "inject":
1453
- a.inject = _0(b.value);
1461
+ a.inject = L0(b.value);
1454
1462
  break;
1455
1463
  }
1456
1464
  for (const b of f)
@@ -1459,17 +1467,17 @@ function x0(e, u) {
1459
1467
  a.state = S0(b.body);
1460
1468
  break;
1461
1469
  }
1462
- a.lifeCycles = I0(f);
1470
+ a.lifeCycles = N0(f);
1463
1471
  },
1464
1472
  CallExpression(c) {
1465
- const s = k0(c.node);
1473
+ const s = _0(c.node);
1466
1474
  if (s.length)
1467
- for (let n of s)
1468
- a.emits?.find((f) => f.name === n.name) || a.emits?.push(n);
1475
+ for (let d of s)
1476
+ a.emits?.find((f) => f.name === d.name) || a.emits?.push(d);
1469
1477
  }
1470
1478
  }), a;
1471
1479
  }
1472
- function g0(e) {
1480
+ function y0(e) {
1473
1481
  const u = /import\s+{(.+?)}\s+from\s+['"](.+?)['"]/g, t = [];
1474
1482
  let a;
1475
1483
  for (; (a = u.exec(e)) !== null; ) {
@@ -1481,7 +1489,7 @@ function g0(e) {
1481
1489
  }
1482
1490
  return t;
1483
1491
  }
1484
- function y0(e) {
1492
+ function E0(e) {
1485
1493
  for (const u of e.body)
1486
1494
  if (u.type === "VariableDeclaration" && u.kind == "const") {
1487
1495
  const { id: t, init: a } = u.declarations[0];
@@ -1491,22 +1499,22 @@ function y0(e) {
1491
1499
  return null;
1492
1500
  }
1493
1501
  function S0(e) {
1494
- const u = y0(e);
1502
+ const u = E0(e);
1495
1503
  if (!u) return {};
1496
1504
  const t = {};
1497
1505
  for (const a of u.properties) {
1498
1506
  const { key: i, value: c } = a;
1499
1507
  if (i.type === "Identifier") {
1500
1508
  const s = R(c);
1501
- t[i.name] = w(s);
1509
+ t[i.name] = v(s);
1502
1510
  }
1503
1511
  }
1504
1512
  return t;
1505
1513
  }
1506
1514
  function q(e) {
1507
- const { key: u, async: t, params: a, body: i } = e, c = a.map((s) => s.type === "ObjectPattern" ? `{${s.properties.map((d) => d.key?.name || d.name).join(",")}}` : s.name).join(", ");
1515
+ const { key: u, async: t, params: a, body: i } = e, c = a.map((s) => s.type === "ObjectPattern" ? `{${s.properties.map((n) => n.key?.name || n.name).join(",")}}` : s.name).join(", ");
1508
1516
  if (u.type === "Identifier") {
1509
- const s = u.name, n = R(i), f = `${t ? "async " : ""}(${c}) => ${n}`, h = s.startsWith("watcher_");
1517
+ const s = u.name, d = R(i), f = `${t ? "async " : ""}(${c}) => ${d}`, h = s.startsWith("watcher_");
1510
1518
  return {
1511
1519
  name: s,
1512
1520
  watcher: h,
@@ -1523,19 +1531,19 @@ function pu(e) {
1523
1531
  }
1524
1532
  return u;
1525
1533
  }
1526
- function E0(e, u) {
1534
+ function v0(e, u) {
1527
1535
  if (!e) return {};
1528
1536
  const t = {}, a = /apis\[\'([\w]*)\'\]/, i = /\.then\(([\w\W]*)\)/;
1529
1537
  for (const c of e.properties) {
1530
1538
  const s = q(c);
1531
1539
  if (s && s.exp.value.includes("provider.apis")) {
1532
- const d = (s.exp.value.match(a) || [])[1];
1533
- if (!d) continue;
1534
- const f = L0(u, d);
1540
+ const n = (s.exp.value.match(a) || [])[1];
1541
+ if (!n) continue;
1542
+ const f = D0(u, n);
1535
1543
  if (!f) continue;
1536
1544
  const h = s.exp.value.match(i)?.[1];
1537
1545
  t[s.name] = {
1538
- ref: d,
1546
+ ref: n,
1539
1547
  name: f.name,
1540
1548
  test: {
1541
1549
  type: "JSFunction",
@@ -1563,7 +1571,7 @@ function w0(e) {
1563
1571
  t.test(i) || (a[i] = u[i]);
1564
1572
  return a;
1565
1573
  }
1566
- function v0(e) {
1574
+ function A0(e) {
1567
1575
  if (!e) return {};
1568
1576
  const u = {}, t = /\_([\w]{5,})$/;
1569
1577
  for (const a of e.properties) {
@@ -1583,7 +1591,7 @@ function v0(e) {
1583
1591
  }
1584
1592
  return u;
1585
1593
  }
1586
- function A0(e) {
1594
+ function T0(e) {
1587
1595
  if (!e) return {};
1588
1596
  const u = {};
1589
1597
  for (const t of e.properties) {
@@ -1607,17 +1615,17 @@ function su(e, u) {
1607
1615
  if (t)
1608
1616
  return q(t)?.exp;
1609
1617
  }
1610
- function T0(e, u = {}) {
1618
+ function I0(e, u = {}) {
1611
1619
  const t = [];
1612
1620
  for (const a of e.properties) {
1613
1621
  const { key: i, value: c } = a, s = i.value || i.name || "";
1614
1622
  if (u[s]) {
1615
- const n = c.properties;
1623
+ const d = c.properties;
1616
1624
  t.push({
1617
1625
  source: u[s],
1618
- deep: B(n, "deep"),
1619
- immediate: B(n, "immediate"),
1620
- handler: su(n, "handler")
1626
+ deep: B(d, "deep"),
1627
+ immediate: B(d, "immediate"),
1628
+ handler: su(d, "handler")
1621
1629
  });
1622
1630
  } else if (a.type === "ObjectMethod" && t.push({
1623
1631
  // todo: 处理上下文
@@ -1629,22 +1637,22 @@ function T0(e, u = {}) {
1629
1637
  immediate: !1,
1630
1638
  handler: q(a)?.exp
1631
1639
  }), a.type === "ObjectProperty") {
1632
- const n = c.properties;
1640
+ const d = c.properties;
1633
1641
  t.push({
1634
1642
  // todo: 处理上下文
1635
1643
  source: {
1636
1644
  type: "JSFunction",
1637
1645
  value: `this.${s}`
1638
1646
  },
1639
- deep: B(n, "deep"),
1640
- immediate: B(n, "immediate"),
1641
- handler: su(n, "handler")
1647
+ deep: B(d, "deep"),
1648
+ immediate: B(d, "immediate"),
1649
+ handler: su(d, "handler")
1642
1650
  });
1643
1651
  }
1644
1652
  }
1645
1653
  return t;
1646
1654
  }
1647
- function I0(e) {
1655
+ function N0(e) {
1648
1656
  const u = {};
1649
1657
  for (const t of e) {
1650
1658
  const a = t.key.name;
@@ -1655,7 +1663,7 @@ function I0(e) {
1655
1663
  }
1656
1664
  return u;
1657
1665
  }
1658
- function N0(e) {
1666
+ function q0(e) {
1659
1667
  const u = e.find(
1660
1668
  (t) => t.key?.name === "type"
1661
1669
  );
@@ -1667,9 +1675,9 @@ function xu(e) {
1667
1675
  (t) => t.key?.name === "default"
1668
1676
  );
1669
1677
  if (u)
1670
- return w(R(u.value));
1678
+ return v(R(u.value));
1671
1679
  }
1672
- function q0(e) {
1680
+ function k0(e) {
1673
1681
  if (!e) return [];
1674
1682
  let u = [];
1675
1683
  return e.type === "ArrayExpression" ? u = e.elements.map((t) => t.value) : e.type === "ObjectExpression" && (u = e.properties.map((t) => {
@@ -1677,12 +1685,12 @@ function q0(e) {
1677
1685
  return {
1678
1686
  name: a.name,
1679
1687
  required: B(c, "required"),
1680
- type: N0(c),
1688
+ type: q0(c),
1681
1689
  default: xu(c)
1682
1690
  };
1683
1691
  })), u;
1684
1692
  }
1685
- function k0(e) {
1693
+ function _0(e) {
1686
1694
  const u = [];
1687
1695
  if (e.callee.type === "MemberExpression" && e.callee.property?.name === "$emit") {
1688
1696
  const [a, ...i] = (e.arguments || []).map(
@@ -1695,30 +1703,30 @@ function k0(e) {
1695
1703
  }
1696
1704
  return u;
1697
1705
  }
1698
- function _0(e) {
1706
+ function L0(e) {
1699
1707
  let u = [];
1700
1708
  return e.type === "ObjectExpression" && (u = e.properties.map((t) => {
1701
- const { key: a, value: i } = t, c = i.properties, s = a.name, n = mu(c, "from"), d = xu(c);
1709
+ const { key: a, value: i } = t, c = i.properties, s = a.name, d = mu(c, "from"), n = xu(c);
1702
1710
  return {
1703
1711
  name: s,
1704
- from: n || s,
1705
- default: d
1712
+ from: d || s,
1713
+ default: n
1706
1714
  };
1707
1715
  })), u;
1708
1716
  }
1709
- function L0(e, u) {
1717
+ function D0(e, u) {
1710
1718
  return (e.apis || []).find((t) => t.id === u);
1711
1719
  }
1712
- function D0(e) {
1720
+ function B0(e) {
1713
1721
  const u = [], t = {}, a = [];
1714
1722
  try {
1715
1723
  const i = Pu.parse(e), c = /^.[\w]+_[\w]{5,}/;
1716
1724
  for (const s of i.nodes)
1717
1725
  if (s.type === "rule") {
1718
- const n = {};
1719
- c.test(s.selector) ? (s.nodes.forEach((d) => {
1720
- d.type === "decl" && (n[d.prop] = d.value);
1721
- }), t[s.selector] = n) : a.push(s.toString());
1726
+ const d = {};
1727
+ c.test(s.selector) ? (s.nodes.forEach((n) => {
1728
+ n.type === "decl" && (d[n.prop] = n.value);
1729
+ }), t[s.selector] = d) : a.push(s.toString());
1722
1730
  }
1723
1731
  } catch (i) {
1724
1732
  u.push(`css解析出错了,错误信息:[ ${i.message} ]
@@ -1731,47 +1739,47 @@ function D0(e) {
1731
1739
  `)
1732
1740
  };
1733
1741
  }
1734
- async function z0(e) {
1735
- const { id: u, name: t, source: a, project: i } = e, { dependencies: c = [], platform: s = "web" } = i || {}, n = Ju(a);
1736
- if (n.length)
1737
- return Promise.reject(n);
1738
- const d = ru(a), {
1742
+ async function W0(e) {
1743
+ const { id: u, name: t, source: a, project: i } = e, { dependencies: c = [], platform: s = "web" } = i || {}, d = Ju(a);
1744
+ if (d.length)
1745
+ return Promise.reject(d);
1746
+ const n = ru(a), {
1739
1747
  styles: f,
1740
1748
  css: h,
1741
1749
  errors: b
1742
- } = D0(d.styles.join(`
1750
+ } = B0(n.styles.join(`
1743
1751
  `)), {
1744
- state: S,
1752
+ state: E,
1745
1753
  watch: m,
1746
- lifeCycles: E,
1747
- computed: v,
1754
+ lifeCycles: S,
1755
+ computed: w,
1748
1756
  methods: J,
1749
1757
  props: gu,
1750
1758
  emits: yu,
1751
- inject: Su,
1752
- handlers: Eu,
1753
- imports: wu,
1754
- dataSources: vu
1755
- } = x0(d.script, i), { nodes: Au, slots: Tu, context: Iu } = f0(u, t, d.template, {
1759
+ inject: Eu,
1760
+ handlers: Su,
1761
+ imports: vu,
1762
+ dataSources: wu
1763
+ } = g0(n.script, i), { nodes: Au, slots: Tu, context: Iu } = f0(u, t, n.template, {
1756
1764
  platform: s,
1757
- handlers: Eu,
1765
+ handlers: Su,
1758
1766
  styles: f
1759
1767
  }), X = {
1760
1768
  id: u,
1761
1769
  name: t,
1762
- inject: Su,
1770
+ inject: Eu,
1763
1771
  props: gu,
1764
- state: S,
1772
+ state: E,
1765
1773
  watch: m,
1766
- lifeCycles: E,
1767
- computed: v,
1774
+ lifeCycles: S,
1775
+ computed: w,
1768
1776
  methods: J,
1769
- dataSources: vu,
1777
+ dataSources: wu,
1770
1778
  slots: Tu,
1771
1779
  emits: yu,
1772
1780
  nodes: Au,
1773
1781
  css: h
1774
- }, Nu = Object.keys(v || {}), qu = [
1782
+ }, Nu = Object.keys(w || {}), qu = [
1775
1783
  "$el",
1776
1784
  "$emit",
1777
1785
  "$nextTick",
@@ -1788,68 +1796,68 @@ async function z0(e) {
1788
1796
  "$props",
1789
1797
  "props",
1790
1798
  ...Object.keys(J || {})
1791
- ], { libs: ku } = O0(wu, c), z = {
1799
+ ], { libs: ku } = V0(vu, c), z = {
1792
1800
  platform: s,
1793
1801
  context: Iu,
1794
1802
  computed: Nu,
1795
1803
  libs: ku,
1796
1804
  members: qu
1797
1805
  };
1798
- return await B0(
1806
+ return await R0(
1799
1807
  X,
1800
- async (_) => {
1801
- await R0(_, async (L) => {
1802
- if (G(L)) {
1803
- const _u = await Z(L.value);
1804
- L.value = K(_u, _.id, z);
1808
+ async (L) => {
1809
+ await O0(L, async (D) => {
1810
+ if (G(D)) {
1811
+ const _u = await Z(D.value);
1812
+ D.value = K(_u, L.id, z);
1805
1813
  }
1806
1814
  });
1807
1815
  },
1808
- async (_) => {
1809
- const L = await Z(_.value);
1810
- _.value = K(L, "", z);
1816
+ async (L) => {
1817
+ const D = await Z(L.value);
1818
+ L.value = K(D, "", z);
1811
1819
  }
1812
- ), n.push(...b), n.length ? Promise.reject(n) : new Ru(X).toDsl();
1820
+ ), d.push(...b), d.length ? Promise.reject(d) : new Ru(X).toDsl();
1813
1821
  }
1814
- async function B0(e, u, t) {
1815
- const a = async (m, E) => {
1816
- if (await u(m, E), Array.isArray(m.children))
1817
- for (const v of m.children)
1818
- await a(v, m);
1822
+ async function R0(e, u, t) {
1823
+ const a = async (m, S) => {
1824
+ if (await u(m, S), Array.isArray(m.children))
1825
+ for (const w of m.children)
1826
+ await a(w, m);
1819
1827
  }, i = async (m) => {
1820
1828
  if (!m || typeof m != "object") return;
1821
1829
  if (Array.isArray(m)) {
1822
- for (let v of m)
1823
- await i(v);
1830
+ for (let w of m)
1831
+ await i(w);
1824
1832
  return;
1825
1833
  }
1826
- const E = Object.values(m);
1827
- for (const v of E)
1828
- G(v) ? await t(v) : await i(v);
1834
+ const S = Object.values(m);
1835
+ for (const w of S)
1836
+ G(w) ? await t(w) : await i(w);
1829
1837
  }, {
1830
1838
  state: c,
1831
1839
  watch: s,
1832
- computed: n,
1833
- props: d,
1840
+ computed: d,
1841
+ props: n,
1834
1842
  dataSources: f,
1835
1843
  methods: h,
1836
1844
  lifeCycles: b,
1837
- inject: S
1845
+ inject: E
1838
1846
  } = e;
1839
1847
  if (await i({
1840
1848
  state: c,
1841
1849
  watch: s,
1842
- computed: n,
1843
- props: d,
1850
+ computed: d,
1851
+ props: n,
1844
1852
  dataSources: f,
1845
1853
  methods: h,
1846
1854
  lifeCycles: b,
1847
- inject: S
1855
+ inject: E
1848
1856
  }), Array.isArray(e.nodes))
1849
1857
  for (const m of e.nodes)
1850
1858
  await a(m);
1851
1859
  }
1852
- async function R0(e, u) {
1860
+ async function O0(e, u) {
1853
1861
  const t = async (a) => {
1854
1862
  if (!a || typeof a != "object") return;
1855
1863
  if (Array.isArray(a)) {
@@ -1867,25 +1875,25 @@ async function R0(e, u) {
1867
1875
  };
1868
1876
  await t(e);
1869
1877
  }
1870
- function O0(e = [], u = []) {
1878
+ function V0(e = [], u = []) {
1871
1879
  const t = {}, a = u.reduce(
1872
1880
  (i, c) => (i[c.package] = c.library, i),
1873
1881
  {}
1874
1882
  );
1875
1883
  for (const { from: i, imports: c } of e)
1876
1884
  c.forEach((s) => {
1877
- const n = a[i];
1878
- n && (t[s] = n);
1885
+ const d = a[i];
1886
+ d && (t[s] = d);
1879
1887
  });
1880
1888
  return {
1881
1889
  libs: t
1882
1890
  };
1883
1891
  }
1884
1892
  export {
1885
- J0 as VTJ_PARSER_VERSION,
1893
+ X0 as VTJ_PARSER_VERSION,
1886
1894
  cu as htmlToNodes,
1887
- X0 as parseUniApp,
1888
- z0 as parseVue,
1895
+ z0 as parseUniApp,
1896
+ W0 as parseVue,
1889
1897
  K as patchCode,
1890
1898
  O as replacer
1891
1899
  };