@vtj/parser 0.13.34 → 0.13.36
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.cjs +6 -6
- package/dist/index.mjs +216 -216
- package/package.json +6 -6
- package/types/version.d.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -13,10 +13,10 @@ import * as T from "@babel/types";
|
|
|
13
13
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
14
14
|
* @name @vtj/parser
|
|
15
15
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
16
|
-
* @version 0.13.
|
|
16
|
+
* @version 0.13.36
|
|
17
17
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
18
18
|
*/
|
|
19
|
-
const x0 = "0.13.
|
|
19
|
+
const x0 = "0.13.36";
|
|
20
20
|
function R(e) {
|
|
21
21
|
const { descriptor: u } = zu(e), t = u.template?.content || "", a = (u.scriptSetup || u.script)?.content || "", i = u.styles.map((c) => c.content);
|
|
22
22
|
return {
|
|
@@ -80,10 +80,10 @@ function g0(e) {
|
|
|
80
80
|
}
|
|
81
81
|
}), a;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function P(e, u, t) {
|
|
84
84
|
const a = new RegExp(`${u.replace(/\$/g, "\\$")}`, "g"), i = /(\@|\_|\-|\$|\.|\,|\w|\{\s|\'|\")$/, c = /^[\w\_\-\@\$]/, s = new RegExp(`^this.${u}$`, "g");
|
|
85
|
-
return e.replace(a, (d,
|
|
86
|
-
const f = b.substring(0,
|
|
85
|
+
return e.replace(a, (d, r, b) => {
|
|
86
|
+
const f = b.substring(0, r), I = b.substring(r + u.length);
|
|
87
87
|
return i.test(f) || c.test(I.trim()) ? d : t;
|
|
88
88
|
}).replace(s, t);
|
|
89
89
|
}
|
|
@@ -93,20 +93,20 @@ function gu(e, u, t) {
|
|
|
93
93
|
computed: i = [],
|
|
94
94
|
libs: c = {},
|
|
95
95
|
members: s = [],
|
|
96
|
-
platform:
|
|
96
|
+
platform: n
|
|
97
97
|
} = t || {}, d = Array.from(a[u || ""] || /* @__PURE__ */ new Set());
|
|
98
98
|
if (d)
|
|
99
|
-
for (const
|
|
100
|
-
e =
|
|
101
|
-
for (const
|
|
102
|
-
e =
|
|
103
|
-
for (const [
|
|
104
|
-
e =
|
|
105
|
-
for (const
|
|
106
|
-
e =
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
e = e.replace(
|
|
99
|
+
for (const r of d)
|
|
100
|
+
e = P(e, r, `this.context.${r}`);
|
|
101
|
+
for (const r of i)
|
|
102
|
+
e = P(e, `this.${r}`, `this.${r}.value`), e = P(e, r, `this.${r}.value`), e = P(e, `this.${r}.value.value`, `this.${r}.value`);
|
|
103
|
+
for (const [r, b] of Object.entries(c))
|
|
104
|
+
e = P(e, r, `this.$libs.${b}.${r}`), e = P(e, `this.${r}`, `this.$libs.${b}.${r}`);
|
|
105
|
+
for (const r of s)
|
|
106
|
+
e = P(e, r, `this.${r}`);
|
|
107
|
+
if (n === "uniapp") {
|
|
108
|
+
const r = /\buni\./g;
|
|
109
|
+
e = e.replace(r, "this.$libs.UniH5.uni.");
|
|
110
110
|
}
|
|
111
111
|
return e = e.replace(/_ctx\./g, "this."), e = e.replace(/this\.this\./g, "this."), e;
|
|
112
112
|
}
|
|
@@ -441,13 +441,13 @@ function Se(e, u, t, a) {
|
|
|
441
441
|
const d = a - c;
|
|
442
442
|
return d < 0 || d >= i ? -1 : e[t + d] - 1;
|
|
443
443
|
}
|
|
444
|
-
let s = t,
|
|
445
|
-
for (; s <=
|
|
446
|
-
const d = s +
|
|
447
|
-
if (
|
|
444
|
+
let s = t, n = s + i - 1;
|
|
445
|
+
for (; s <= n; ) {
|
|
446
|
+
const d = s + n >>> 1, r = e[d];
|
|
447
|
+
if (r < a)
|
|
448
448
|
s = d + 1;
|
|
449
|
-
else if (
|
|
450
|
-
|
|
449
|
+
else if (r > a)
|
|
450
|
+
n = d - 1;
|
|
451
451
|
else
|
|
452
452
|
return e[d + i];
|
|
453
453
|
}
|
|
@@ -827,7 +827,7 @@ class Ee {
|
|
|
827
827
|
this.baseState !== o.Text && this.baseState !== o.InSpecialTag ? (this.sectionStart < this.entityStart && this.cbs.onattribdata(this.sectionStart, this.entityStart), this.sectionStart = this.entityStart + t, this.index = this.sectionStart - 1, this.cbs.onattribentity(u)) : (this.sectionStart < this.entityStart && this.cbs.ontext(this.sectionStart, this.entityStart), this.sectionStart = this.entityStart + t, this.index = this.sectionStart - 1, this.cbs.ontextentity(u, this.sectionStart));
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
|
-
const
|
|
830
|
+
const U = /* @__PURE__ */ new Set([
|
|
831
831
|
"input",
|
|
832
832
|
"option",
|
|
833
833
|
"optgroup",
|
|
@@ -848,12 +848,12 @@ const $ = /* @__PURE__ */ new Set([
|
|
|
848
848
|
["h4", S],
|
|
849
849
|
["h5", S],
|
|
850
850
|
["h6", S],
|
|
851
|
-
["select",
|
|
852
|
-
["input",
|
|
853
|
-
["output",
|
|
854
|
-
["button",
|
|
855
|
-
["datalist",
|
|
856
|
-
["textarea",
|
|
851
|
+
["select", U],
|
|
852
|
+
["input", U],
|
|
853
|
+
["output", U],
|
|
854
|
+
["button", U],
|
|
855
|
+
["datalist", U],
|
|
856
|
+
["textarea", U],
|
|
857
857
|
["option", /* @__PURE__ */ new Set(["option"])],
|
|
858
858
|
["optgroup", /* @__PURE__ */ new Set(["optgroup", "option"])],
|
|
859
859
|
["dd", Iu],
|
|
@@ -916,8 +916,8 @@ const $ = /* @__PURE__ */ new Set([
|
|
|
916
916
|
]), Ae = /\s|\//;
|
|
917
917
|
class Te {
|
|
918
918
|
constructor(u, t = {}) {
|
|
919
|
-
var a, i, c, s,
|
|
920
|
-
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 : Ee)(this.options, this), this.foreignContext = [!this.htmlMode], (d = (
|
|
919
|
+
var a, i, c, s, n, d;
|
|
920
|
+
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 : Ee)(this.options, this), this.foreignContext = [!this.htmlMode], (d = (n = this.cbs).onparserinit) === null || d === void 0 || d.call(n, this);
|
|
921
921
|
}
|
|
922
922
|
// Tokenizer event handlers
|
|
923
923
|
/** @internal */
|
|
@@ -950,8 +950,8 @@ class Te {
|
|
|
950
950
|
const s = this.htmlMode && we.get(u);
|
|
951
951
|
if (s)
|
|
952
952
|
for (; this.stack.length > 0 && s.has(this.stack[0]); ) {
|
|
953
|
-
const
|
|
954
|
-
(a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t,
|
|
953
|
+
const n = this.stack.shift();
|
|
954
|
+
(a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t, n, !0);
|
|
955
955
|
}
|
|
956
956
|
this.isVoidElement(u) || (this.stack.unshift(u), this.htmlMode && (wu.has(u) ? this.foreignContext.unshift(!0) : vu.has(u) && this.foreignContext.unshift(!1))), (c = (i = this.cbs).onopentagname) === null || c === void 0 || c.call(i, u), this.cbs.onopentag && (this.attribs = {});
|
|
957
957
|
}
|
|
@@ -965,11 +965,11 @@ class Te {
|
|
|
965
965
|
}
|
|
966
966
|
/** @internal */
|
|
967
967
|
onclosetag(u, t) {
|
|
968
|
-
var a, i, c, s,
|
|
968
|
+
var a, i, c, s, n, d, r, b;
|
|
969
969
|
this.endIndex = t;
|
|
970
970
|
let f = this.getSlice(u, t);
|
|
971
971
|
if (this.lowerCaseTagNames && (f = f.toLowerCase()), this.htmlMode && (wu.has(f) || vu.has(f)) && this.foreignContext.shift(), this.isVoidElement(f))
|
|
972
|
-
this.htmlMode && f === "br" && ((s = (c = this.cbs).onopentagname) === null || s === void 0 || s.call(c, "br"), (d = (
|
|
972
|
+
this.htmlMode && f === "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), (b = (r = this.cbs).onclosetag) === null || b === void 0 || b.call(r, "br", !1));
|
|
973
973
|
else {
|
|
974
974
|
const I = this.stack.indexOf(f);
|
|
975
975
|
if (I !== -1)
|
|
@@ -1036,15 +1036,15 @@ class Te {
|
|
|
1036
1036
|
}
|
|
1037
1037
|
/** @internal */
|
|
1038
1038
|
oncomment(u, t, a) {
|
|
1039
|
-
var i, c, s,
|
|
1040
|
-
this.endIndex = t, (c = (i = this.cbs).oncomment) === null || c === void 0 || c.call(i, this.getSlice(u, t - a)), (
|
|
1039
|
+
var i, c, s, n;
|
|
1040
|
+
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;
|
|
1041
1041
|
}
|
|
1042
1042
|
/** @internal */
|
|
1043
1043
|
oncdata(u, t, a) {
|
|
1044
|
-
var i, c, s,
|
|
1044
|
+
var i, c, s, n, d, r, b, f, I, x;
|
|
1045
1045
|
this.endIndex = t;
|
|
1046
1046
|
const N = this.getSlice(u, t - a);
|
|
1047
|
-
!this.htmlMode || this.options.recognizeCDATA ? ((c = (i = this.cbs).oncdatastart) === null || c === void 0 || c.call(i), (
|
|
1047
|
+
!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, N), (r = (d = this.cbs).oncdataend) === null || r === void 0 || r.call(d)) : ((f = (b = this.cbs).oncomment) === null || f === void 0 || f.call(b, `[CDATA[${N}]]`), (x = (I = this.cbs).oncommentend) === null || x === void 0 || x.call(I)), this.startIndex = t + 1;
|
|
1048
1048
|
}
|
|
1049
1049
|
/** @internal */
|
|
1050
1050
|
onend() {
|
|
@@ -1147,13 +1147,13 @@ function Au(e, u = "web") {
|
|
|
1147
1147
|
let i = "";
|
|
1148
1148
|
const c = new Te(
|
|
1149
1149
|
{
|
|
1150
|
-
onopentag: (s,
|
|
1151
|
-
const
|
|
1152
|
-
i.trim() && (Array.isArray(
|
|
1150
|
+
onopentag: (s, n, d) => {
|
|
1151
|
+
const r = a[a.length - 1];
|
|
1152
|
+
i.trim() && (Array.isArray(r.children) ? r.children.push({
|
|
1153
1153
|
name: "span",
|
|
1154
1154
|
children: i.trim()
|
|
1155
|
-
}) :
|
|
1156
|
-
const b = Object.entries(
|
|
1155
|
+
}) : r.children = i.trim(), i = "");
|
|
1156
|
+
const b = Object.entries(n || {}).reduce(
|
|
1157
1157
|
(I, x) => {
|
|
1158
1158
|
let [N = "", V = ""] = x;
|
|
1159
1159
|
return N && (I[N] = V), I;
|
|
@@ -1165,17 +1165,17 @@ function Au(e, u = "web") {
|
|
|
1165
1165
|
name: Vu(s, u),
|
|
1166
1166
|
props: b
|
|
1167
1167
|
};
|
|
1168
|
-
Array.isArray(
|
|
1168
|
+
Array.isArray(r.children) ? r.children.push(f) : r.children ? r.children = [
|
|
1169
1169
|
{
|
|
1170
1170
|
name: "span",
|
|
1171
|
-
children:
|
|
1171
|
+
children: r.children
|
|
1172
1172
|
},
|
|
1173
1173
|
f
|
|
1174
|
-
] :
|
|
1174
|
+
] : r.children = [f], d || a.push(f);
|
|
1175
1175
|
},
|
|
1176
1176
|
ontext: (s) => {
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1177
|
+
const n = s.trim();
|
|
1178
|
+
n && n !== '"' && (i += n);
|
|
1179
1179
|
},
|
|
1180
1180
|
onclosetag: () => {
|
|
1181
1181
|
const s = a.pop();
|
|
@@ -1199,11 +1199,11 @@ function Ne(e, u) {
|
|
|
1199
1199
|
ExportDefaultDeclaration(c) {
|
|
1200
1200
|
const s = c.node.declaration;
|
|
1201
1201
|
if (s.type !== "CallExpression") return;
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1204
|
-
const d =
|
|
1202
|
+
const n = s.arguments[0];
|
|
1203
|
+
if (n?.type !== "ObjectExpression") return;
|
|
1204
|
+
const d = n.properties.filter(
|
|
1205
1205
|
(f) => f.type === "ObjectProperty"
|
|
1206
|
-
),
|
|
1206
|
+
), r = n.properties.filter(
|
|
1207
1207
|
(f) => f.type == "ObjectMethod"
|
|
1208
1208
|
), b = d.find(
|
|
1209
1209
|
(f) => f.key.name === "computed"
|
|
@@ -1236,19 +1236,19 @@ function Ne(e, u) {
|
|
|
1236
1236
|
a.expose = Oe(f.value);
|
|
1237
1237
|
break;
|
|
1238
1238
|
}
|
|
1239
|
-
for (const f of
|
|
1239
|
+
for (const f of r)
|
|
1240
1240
|
switch (f.key.name) {
|
|
1241
1241
|
case "setup":
|
|
1242
1242
|
a.state = qe(f.body);
|
|
1243
1243
|
break;
|
|
1244
1244
|
}
|
|
1245
|
-
a.lifeCycles = Be(
|
|
1245
|
+
a.lifeCycles = Be(r);
|
|
1246
1246
|
},
|
|
1247
1247
|
CallExpression(c) {
|
|
1248
1248
|
const s = Me(c.node);
|
|
1249
1249
|
if (s.length)
|
|
1250
|
-
for (let
|
|
1251
|
-
a.emits?.find((
|
|
1250
|
+
for (let n of s)
|
|
1251
|
+
a.emits?.find((r) => r.name === n.name) || a.emits?.push(n);
|
|
1252
1252
|
}
|
|
1253
1253
|
}), a;
|
|
1254
1254
|
}
|
|
@@ -1257,17 +1257,17 @@ function ke(e) {
|
|
|
1257
1257
|
let c;
|
|
1258
1258
|
const s = e.replace(/\n/g, " ");
|
|
1259
1259
|
for (; (c = u.exec(s)) !== null; ) {
|
|
1260
|
-
const
|
|
1260
|
+
const n = c[2] === "@element-plus/icons-vue" ? "@vtj/icons" : c[2];
|
|
1261
1261
|
i.push({
|
|
1262
|
-
from:
|
|
1262
|
+
from: n,
|
|
1263
1263
|
imports: c[1].split(",").map((d) => d.trim())
|
|
1264
1264
|
});
|
|
1265
1265
|
}
|
|
1266
1266
|
for (; (c = t.exec(s)) !== null; ) {
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1267
|
+
const n = c[1], d = c[2];
|
|
1268
|
+
n && !a.test(n) && i.push({
|
|
1269
1269
|
from: d,
|
|
1270
|
-
imports:
|
|
1270
|
+
imports: n
|
|
1271
1271
|
});
|
|
1272
1272
|
}
|
|
1273
1273
|
return i;
|
|
@@ -1294,18 +1294,18 @@ function qe(e) {
|
|
|
1294
1294
|
}
|
|
1295
1295
|
return t;
|
|
1296
1296
|
}
|
|
1297
|
-
function
|
|
1297
|
+
function O(e) {
|
|
1298
1298
|
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.type === "AssignmentPattern" ? s.left.name + "=" + (s.right?.extra?.raw || "null") : s.name).join(", ");
|
|
1299
1299
|
if (u.type === "Identifier") {
|
|
1300
1300
|
const s = u.name;
|
|
1301
|
-
let
|
|
1302
|
-
i && (
|
|
1301
|
+
let n = "{}";
|
|
1302
|
+
i && (n = M(i) || "{}");
|
|
1303
1303
|
const d = e.value;
|
|
1304
1304
|
if (d && d.type === "CallExpression") {
|
|
1305
1305
|
let x = M(d) || "";
|
|
1306
|
-
x = x.replace("function () {", "() => {"),
|
|
1306
|
+
x = x.replace("function () {", "() => {"), n = `{ return (${x})}`;
|
|
1307
1307
|
}
|
|
1308
|
-
const b = `${t ? "async " : ""}(${c}) => ${
|
|
1308
|
+
const b = `${t ? "async " : ""}(${c}) => ${n}`, f = s.startsWith("watcher_");
|
|
1309
1309
|
return {
|
|
1310
1310
|
id: f ? s.replace("watcher_", "") : "",
|
|
1311
1311
|
name: s,
|
|
@@ -1318,7 +1318,7 @@ function ju(e) {
|
|
|
1318
1318
|
if (!e) return {};
|
|
1319
1319
|
const u = {};
|
|
1320
1320
|
for (const t of e.properties) {
|
|
1321
|
-
const a =
|
|
1321
|
+
const a = O(t);
|
|
1322
1322
|
a && !a.watcher && !a.exp.value.includes("this.provider.createMock") && !a.exp.value.includes("this.provider.apis") && (u[a.name] = a.exp);
|
|
1323
1323
|
}
|
|
1324
1324
|
return u;
|
|
@@ -1327,7 +1327,7 @@ function je(e, u) {
|
|
|
1327
1327
|
if (!e) return {};
|
|
1328
1328
|
const t = {}, a = /apis\[\'([\w]*)\'\]/, i = /\.then\(([\w\W]*)\)/;
|
|
1329
1329
|
for (const c of e.properties) {
|
|
1330
|
-
const s =
|
|
1330
|
+
const s = O(c), n = c.body.body?.[0], d = (n?.leadingComments?.[0].value || "").trim(), r = de(d);
|
|
1331
1331
|
if (s && s.exp.value.includes("this.provider.apis")) {
|
|
1332
1332
|
const f = (s.exp.value.match(a) || [])[1];
|
|
1333
1333
|
if (!f) continue;
|
|
@@ -1337,7 +1337,7 @@ function je(e, u) {
|
|
|
1337
1337
|
t[s.name] = {
|
|
1338
1338
|
ref: f,
|
|
1339
1339
|
name: I.name,
|
|
1340
|
-
test:
|
|
1340
|
+
test: r?.test || {
|
|
1341
1341
|
type: "JSFunction",
|
|
1342
1342
|
value: `() => this.runApi({
|
|
1343
1343
|
/* 在这里可输入接口参数 */
|
|
@@ -1355,25 +1355,25 @@ function je(e, u) {
|
|
|
1355
1355
|
};
|
|
1356
1356
|
}
|
|
1357
1357
|
if (s && s.exp.value.includes("this.provider.createMock")) {
|
|
1358
|
-
const b =
|
|
1358
|
+
const b = n?.declarations?.[0]?.init?.arguments?.[0], f = s.exp.value.match(i)?.[1];
|
|
1359
1359
|
t[s.name] = {
|
|
1360
1360
|
ref: "",
|
|
1361
1361
|
name: s.name,
|
|
1362
|
-
test:
|
|
1362
|
+
test: r?.test || {
|
|
1363
1363
|
type: "JSFunction",
|
|
1364
1364
|
value: `() => this.runApi({
|
|
1365
1365
|
/* 在这里可输入接口参数 */
|
|
1366
1366
|
})`
|
|
1367
1367
|
},
|
|
1368
1368
|
type: "mock",
|
|
1369
|
-
label:
|
|
1370
|
-
transform:
|
|
1369
|
+
label: r?.label || "",
|
|
1370
|
+
transform: r?.transform || {
|
|
1371
1371
|
type: "JSFunction",
|
|
1372
1372
|
value: f || `(res) => {
|
|
1373
1373
|
return res;
|
|
1374
1374
|
}`
|
|
1375
1375
|
},
|
|
1376
|
-
mockTemplate:
|
|
1376
|
+
mockTemplate: r?.mockTemplate || {
|
|
1377
1377
|
type: "JSFunction",
|
|
1378
1378
|
value: b ? M(b) : ""
|
|
1379
1379
|
}
|
|
@@ -1401,7 +1401,7 @@ function De(e) {
|
|
|
1401
1401
|
);
|
|
1402
1402
|
u[i] = du(c);
|
|
1403
1403
|
} else
|
|
1404
|
-
u[i] =
|
|
1404
|
+
u[i] = O(a)?.exp;
|
|
1405
1405
|
} catch (c) {
|
|
1406
1406
|
console.warn(c);
|
|
1407
1407
|
}
|
|
@@ -1412,7 +1412,7 @@ function Le(e) {
|
|
|
1412
1412
|
if (!e) return {};
|
|
1413
1413
|
const u = {};
|
|
1414
1414
|
for (const t of e.properties) {
|
|
1415
|
-
const a =
|
|
1415
|
+
const a = O(t);
|
|
1416
1416
|
a && a.watcher && (u[a.name] = a.exp);
|
|
1417
1417
|
}
|
|
1418
1418
|
return u;
|
|
@@ -1430,20 +1430,20 @@ function Tu(e, u) {
|
|
|
1430
1430
|
(a) => a.key?.name === u
|
|
1431
1431
|
);
|
|
1432
1432
|
if (t)
|
|
1433
|
-
return
|
|
1433
|
+
return O(t)?.exp;
|
|
1434
1434
|
}
|
|
1435
1435
|
function _e(e, u = {}) {
|
|
1436
1436
|
const t = [];
|
|
1437
1437
|
for (const a of e.properties) {
|
|
1438
1438
|
const { key: i, value: c } = a, s = i.value || i.name || "";
|
|
1439
1439
|
if (u[s]) {
|
|
1440
|
-
const
|
|
1440
|
+
const n = c.properties;
|
|
1441
1441
|
t.push({
|
|
1442
1442
|
id: s.replace("watcher_", ""),
|
|
1443
1443
|
source: u[s],
|
|
1444
|
-
deep: J(
|
|
1445
|
-
immediate: J(
|
|
1446
|
-
handler: Tu(
|
|
1444
|
+
deep: J(n, "deep"),
|
|
1445
|
+
immediate: J(n, "immediate"),
|
|
1446
|
+
handler: Tu(n, "handler")
|
|
1447
1447
|
});
|
|
1448
1448
|
} else if (a.type === "ObjectMethod" && t.push({
|
|
1449
1449
|
id: iu(),
|
|
@@ -1453,18 +1453,18 @@ function _e(e, u = {}) {
|
|
|
1453
1453
|
},
|
|
1454
1454
|
deep: !1,
|
|
1455
1455
|
immediate: !1,
|
|
1456
|
-
handler:
|
|
1456
|
+
handler: O(a)?.exp
|
|
1457
1457
|
}), a.type === "ObjectProperty") {
|
|
1458
|
-
const
|
|
1458
|
+
const n = c.properties;
|
|
1459
1459
|
t.push({
|
|
1460
1460
|
id: iu(),
|
|
1461
1461
|
source: {
|
|
1462
1462
|
type: "JSFunction",
|
|
1463
1463
|
value: `() => { return this.${s}; }`
|
|
1464
1464
|
},
|
|
1465
|
-
deep: J(
|
|
1466
|
-
immediate: J(
|
|
1467
|
-
handler: Tu(
|
|
1465
|
+
deep: J(n, "deep"),
|
|
1466
|
+
immediate: J(n, "immediate"),
|
|
1467
|
+
handler: Tu(n, "handler")
|
|
1468
1468
|
});
|
|
1469
1469
|
}
|
|
1470
1470
|
}
|
|
@@ -1475,7 +1475,7 @@ function Be(e) {
|
|
|
1475
1475
|
for (const t of e) {
|
|
1476
1476
|
const a = t.key.name;
|
|
1477
1477
|
if (ie.includes(a)) {
|
|
1478
|
-
const i =
|
|
1478
|
+
const i = O(t);
|
|
1479
1479
|
i && (u[i.name] = i.exp);
|
|
1480
1480
|
}
|
|
1481
1481
|
}
|
|
@@ -1524,10 +1524,10 @@ function Me(e) {
|
|
|
1524
1524
|
function Pe(e) {
|
|
1525
1525
|
let u = [];
|
|
1526
1526
|
return e.type === "ObjectExpression" && (u = e.properties.map((t) => {
|
|
1527
|
-
const { key: a, value: i } = t, c = i.properties, s = a.name,
|
|
1527
|
+
const { key: a, value: i } = t, c = i.properties, s = a.name, n = Ru(c, "from"), d = Du(c);
|
|
1528
1528
|
return {
|
|
1529
1529
|
name: s,
|
|
1530
|
-
from:
|
|
1530
|
+
from: n || s,
|
|
1531
1531
|
default: d
|
|
1532
1532
|
};
|
|
1533
1533
|
})), u;
|
|
@@ -1547,7 +1547,7 @@ function Ue(e, u, t = "", a) {
|
|
|
1547
1547
|
source: t,
|
|
1548
1548
|
isProd: !0,
|
|
1549
1549
|
slotted: !0
|
|
1550
|
-
}).ast?.children || []).map((
|
|
1550
|
+
}).ast?.children || []).map((n) => H(n)).filter((n) => !!n),
|
|
1551
1551
|
slots: su,
|
|
1552
1552
|
context: Q
|
|
1553
1553
|
};
|
|
@@ -1569,8 +1569,8 @@ function Ge(e) {
|
|
|
1569
1569
|
for (const t of e) {
|
|
1570
1570
|
if (t.type === h.ATTRIBUTE)
|
|
1571
1571
|
if (t.name === "class") {
|
|
1572
|
-
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((d) => d !== c),
|
|
1573
|
-
|
|
1572
|
+
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((d) => d !== c), n = _u[`.${c}`];
|
|
1573
|
+
n && (u.style = n), s.length && (u.class = s.join(" "));
|
|
1574
1574
|
} else if (t.name === "style") {
|
|
1575
1575
|
const a = t.value?.content || "";
|
|
1576
1576
|
a && (u.style = qu(a));
|
|
@@ -1601,11 +1601,11 @@ function We(e, u = {}) {
|
|
|
1601
1601
|
);
|
|
1602
1602
|
let c = a.exp?.loc.source || "";
|
|
1603
1603
|
/\)$/.test(c) && (c = `($event) => { ${c} } `);
|
|
1604
|
-
const
|
|
1605
|
-
if (d &&
|
|
1604
|
+
const n = new RegExp(`${a.arg.content}_[\\w]{5,}`), d = c.match(n)?.[0] || "", r = u[d];
|
|
1605
|
+
if (d && r)
|
|
1606
1606
|
t[a.arg.content] = {
|
|
1607
1607
|
name: a.arg.content,
|
|
1608
|
-
handler:
|
|
1608
|
+
handler: r,
|
|
1609
1609
|
modifiers: i
|
|
1610
1610
|
};
|
|
1611
1611
|
else {
|
|
@@ -1628,9 +1628,9 @@ function Y(e, u) {
|
|
|
1628
1628
|
name: c,
|
|
1629
1629
|
value: c === "vElse" ? !0 : k(s)
|
|
1630
1630
|
});
|
|
1631
|
-
const
|
|
1632
|
-
if (
|
|
1633
|
-
const d = Y(
|
|
1631
|
+
const n = e.children?.[0];
|
|
1632
|
+
if (n) {
|
|
1633
|
+
const d = Y(n);
|
|
1634
1634
|
t.push(...d);
|
|
1635
1635
|
}
|
|
1636
1636
|
}
|
|
@@ -1662,10 +1662,10 @@ function Y(e, u) {
|
|
|
1662
1662
|
name: "vBind",
|
|
1663
1663
|
value: k(s.exp?.loc.source || "")
|
|
1664
1664
|
});
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1665
|
+
const n = a.find((d) => d.name === "html");
|
|
1666
|
+
n && t.push({
|
|
1667
1667
|
name: "vHtml",
|
|
1668
|
-
value: k(
|
|
1668
|
+
value: k(n.exp?.loc.source || "")
|
|
1669
1669
|
});
|
|
1670
1670
|
}
|
|
1671
1671
|
return t;
|
|
@@ -1679,8 +1679,8 @@ function Cu(e) {
|
|
|
1679
1679
|
const c = i.value?.content || "", s = new RegExp(`${a}_([\\w]+)`);
|
|
1680
1680
|
u = c.match(s)?.[1] || "";
|
|
1681
1681
|
} else if (i.type === h.DIRECTIVE && i.name === "on") {
|
|
1682
|
-
const c = i.arg?.loc?.source || "", s = i.exp?.loc?.source || "",
|
|
1683
|
-
u = s.match(
|
|
1682
|
+
const c = i.arg?.loc?.source || "", s = i.exp?.loc?.source || "", n = new RegExp(`${c}_([\\w]+)`);
|
|
1683
|
+
u = s.match(n)?.[1] || "";
|
|
1684
1684
|
}
|
|
1685
1685
|
}
|
|
1686
1686
|
return u || iu();
|
|
@@ -1704,13 +1704,13 @@ function ru(e, u) {
|
|
|
1704
1704
|
const t = new Set(u?.id ? Q[u.id] : []), a = (e.directives || []).find((s) => s.name === "vFor");
|
|
1705
1705
|
let i = new Set(Array.from(t));
|
|
1706
1706
|
if (a) {
|
|
1707
|
-
const { item: s = "item", index:
|
|
1708
|
-
i = /* @__PURE__ */ new Set([s,
|
|
1707
|
+
const { item: s = "item", index: n = "index" } = a.iterator || {};
|
|
1708
|
+
i = /* @__PURE__ */ new Set([s, n, ...Array.from(i)]);
|
|
1709
1709
|
}
|
|
1710
1710
|
const c = e.slot;
|
|
1711
1711
|
if (c) {
|
|
1712
|
-
const s = typeof c == "string" ? [] : c.params || [],
|
|
1713
|
-
i = /* @__PURE__ */ new Set([...
|
|
1712
|
+
const s = typeof c == "string" ? [] : c.params || [], n = s.length ? s : [`scope_${u?.id}`];
|
|
1713
|
+
i = /* @__PURE__ */ new Set([...n, ...Array.from(i)]);
|
|
1714
1714
|
}
|
|
1715
1715
|
Q[e.id] = i;
|
|
1716
1716
|
}
|
|
@@ -1727,9 +1727,9 @@ function au(e, u, t, a) {
|
|
|
1727
1727
|
return ru(i, u), He(c), c;
|
|
1728
1728
|
}
|
|
1729
1729
|
function ze(e, u) {
|
|
1730
|
-
return e.map((t) =>
|
|
1730
|
+
return e.map((t) => H(t, u, e));
|
|
1731
1731
|
}
|
|
1732
|
-
function
|
|
1732
|
+
function H(e, u, t) {
|
|
1733
1733
|
if (e.type === h.ELEMENT)
|
|
1734
1734
|
return au(e, u);
|
|
1735
1735
|
if (e.type === h.IF)
|
|
@@ -1787,8 +1787,8 @@ function fu(e, u = []) {
|
|
|
1787
1787
|
for (const c of a.children) {
|
|
1788
1788
|
const s = c.type === h.TEXT || c.type === h.TEXT_CALL ? {
|
|
1789
1789
|
name: "span",
|
|
1790
|
-
children:
|
|
1791
|
-
} :
|
|
1790
|
+
children: H(c, e)
|
|
1791
|
+
} : H(c, e);
|
|
1792
1792
|
s && (Array.isArray(s) ? s : [s]).forEach((d) => {
|
|
1793
1793
|
ae(d) && i?.type === h.DIRECTIVE && (d.id = Cu(c), d.slot = {
|
|
1794
1794
|
name: i.arg?.content || "default",
|
|
@@ -1804,10 +1804,10 @@ function fu(e, u = []) {
|
|
|
1804
1804
|
t.push(...c);
|
|
1805
1805
|
}
|
|
1806
1806
|
} else if (a.type === h.TEXT_CALL) {
|
|
1807
|
-
const i =
|
|
1807
|
+
const i = H(a, e);
|
|
1808
1808
|
i && (Array.isArray(i) ? t.push(...i) : t.push(i));
|
|
1809
1809
|
} else {
|
|
1810
|
-
const i =
|
|
1810
|
+
const i = H(a, e);
|
|
1811
1811
|
i && (Array.isArray(i) ? t.push(...i) : t.push(i));
|
|
1812
1812
|
}
|
|
1813
1813
|
if (t.length === 1) {
|
|
@@ -1829,14 +1829,14 @@ function Qe(e) {
|
|
|
1829
1829
|
const u = [], t = {}, a = [];
|
|
1830
1830
|
try {
|
|
1831
1831
|
const i = ee.compileString(e, { charset: !1 })?.css || "", c = ue.parse(i), s = /^.[\w]+_[\w]{5,}/;
|
|
1832
|
-
for (const
|
|
1833
|
-
if (
|
|
1832
|
+
for (const n of c.nodes)
|
|
1833
|
+
if (n.type === "rule") {
|
|
1834
1834
|
const d = {};
|
|
1835
|
-
s.test(
|
|
1836
|
-
|
|
1837
|
-
}), t[
|
|
1835
|
+
s.test(n.selector) ? (n.nodes.forEach((r) => {
|
|
1836
|
+
r.type === "decl" && (d[r.prop] = r.value);
|
|
1837
|
+
}), t[n.selector] = d) : a.push(n.toString());
|
|
1838
1838
|
} else
|
|
1839
|
-
a.push(
|
|
1839
|
+
a.push(n.toString());
|
|
1840
1840
|
} catch (i) {
|
|
1841
1841
|
u.push(`css解析出错了,错误信息:[ ${i.message} ]
|
|
1842
1842
|
`);
|
|
@@ -1897,8 +1897,8 @@ class Ye {
|
|
|
1897
1897
|
findVantIcons(u) {
|
|
1898
1898
|
const t = R(u), a = /<(?:VanIcon|van-icon)\b[^>]*>/g, i = t.template.match(a) || [], c = [];
|
|
1899
1899
|
return i.forEach((s) => {
|
|
1900
|
-
const
|
|
1901
|
-
|
|
1900
|
+
const n = s.match(/\bname="([^"]+)"/);
|
|
1901
|
+
n && c.push(n[1]);
|
|
1902
1902
|
}), [...new Set(c)];
|
|
1903
1903
|
}
|
|
1904
1904
|
checkVantIcons(u) {
|
|
@@ -1942,15 +1942,15 @@ function u0(e) {
|
|
|
1942
1942
|
};
|
|
1943
1943
|
const i = e0(a.script), c = a.template;
|
|
1944
1944
|
let s = c;
|
|
1945
|
-
const
|
|
1946
|
-
let
|
|
1947
|
-
for (; (
|
|
1948
|
-
const m =
|
|
1945
|
+
const n = [], d = /\{\{([^}]+)\}\}/g;
|
|
1946
|
+
let r;
|
|
1947
|
+
for (; (r = d.exec(c)) !== null; ) {
|
|
1948
|
+
const m = r[0], y = r[1], g = C(y, i);
|
|
1949
1949
|
if (g !== y) {
|
|
1950
|
-
const p = B(c,
|
|
1951
|
-
|
|
1952
|
-
start:
|
|
1953
|
-
end:
|
|
1950
|
+
const p = B(c, r.index);
|
|
1951
|
+
n.push({
|
|
1952
|
+
start: r.index,
|
|
1953
|
+
end: r.index + m.length,
|
|
1954
1954
|
original: m,
|
|
1955
1955
|
replacement: `{{${g}}}`,
|
|
1956
1956
|
line: p.line,
|
|
@@ -1965,13 +1965,13 @@ function u0(e) {
|
|
|
1965
1965
|
}
|
|
1966
1966
|
}
|
|
1967
1967
|
const b = /:(\w+)="([^"]+)"/g;
|
|
1968
|
-
for (; (
|
|
1969
|
-
const m =
|
|
1968
|
+
for (; (r = b.exec(c)) !== null; ) {
|
|
1969
|
+
const m = r[0], y = r[1], g = r[2], p = C(g, i);
|
|
1970
1970
|
if (p !== g) {
|
|
1971
|
-
const E = B(c,
|
|
1972
|
-
|
|
1973
|
-
start:
|
|
1974
|
-
end:
|
|
1971
|
+
const E = B(c, r.index);
|
|
1972
|
+
n.push({
|
|
1973
|
+
start: r.index,
|
|
1974
|
+
end: r.index + m.length,
|
|
1975
1975
|
original: m,
|
|
1976
1976
|
replacement: `:${y}="${p}"`,
|
|
1977
1977
|
line: E.line,
|
|
@@ -1986,13 +1986,13 @@ function u0(e) {
|
|
|
1986
1986
|
}
|
|
1987
1987
|
}
|
|
1988
1988
|
const f = /v-(if|else-if|show)="([^"]+)"/g;
|
|
1989
|
-
for (; (
|
|
1990
|
-
const m =
|
|
1989
|
+
for (; (r = f.exec(c)) !== null; ) {
|
|
1990
|
+
const m = r[0], y = r[1], g = r[2], p = C(g, i);
|
|
1991
1991
|
if (p !== g) {
|
|
1992
|
-
const E = B(c,
|
|
1993
|
-
|
|
1994
|
-
start:
|
|
1995
|
-
end:
|
|
1992
|
+
const E = B(c, r.index);
|
|
1993
|
+
n.push({
|
|
1994
|
+
start: r.index,
|
|
1995
|
+
end: r.index + m.length,
|
|
1996
1996
|
original: m,
|
|
1997
1997
|
replacement: `v-${y}="${p}"`,
|
|
1998
1998
|
line: E.line,
|
|
@@ -2007,25 +2007,25 @@ function u0(e) {
|
|
|
2007
2007
|
}
|
|
2008
2008
|
}
|
|
2009
2009
|
const I = /v-for="([^"]+)"/g;
|
|
2010
|
-
for (; (
|
|
2011
|
-
const m =
|
|
2010
|
+
for (; (r = I.exec(c)) !== null; ) {
|
|
2011
|
+
const m = r[0], g = r[1].match(/^(.+)\s+in\s+(.+)$/);
|
|
2012
2012
|
if (g) {
|
|
2013
2013
|
const [, p, E] = g, q = C(
|
|
2014
2014
|
E,
|
|
2015
2015
|
i
|
|
2016
2016
|
);
|
|
2017
2017
|
if (q !== E) {
|
|
2018
|
-
const
|
|
2019
|
-
|
|
2020
|
-
start:
|
|
2021
|
-
end:
|
|
2018
|
+
const $ = B(c, r.index), eu = `v-for="${p} in ${q}"`;
|
|
2019
|
+
n.push({
|
|
2020
|
+
start: r.index,
|
|
2021
|
+
end: r.index + m.length,
|
|
2022
2022
|
original: m,
|
|
2023
2023
|
replacement: eu,
|
|
2024
|
-
line:
|
|
2025
|
-
column:
|
|
2024
|
+
line: $.line,
|
|
2025
|
+
column: $.column
|
|
2026
2026
|
}), u.push({
|
|
2027
|
-
line:
|
|
2028
|
-
column:
|
|
2027
|
+
line: $.line + 1,
|
|
2028
|
+
column: $.column,
|
|
2029
2029
|
original: E,
|
|
2030
2030
|
fixed: q,
|
|
2031
2031
|
message: "修复 v-for 指令:添加 state. 前缀"
|
|
@@ -2034,13 +2034,13 @@ function u0(e) {
|
|
|
2034
2034
|
}
|
|
2035
2035
|
}
|
|
2036
2036
|
const x = /v-model="([^"]+)"/g;
|
|
2037
|
-
for (; (
|
|
2038
|
-
const m =
|
|
2037
|
+
for (; (r = x.exec(c)) !== null; ) {
|
|
2038
|
+
const m = r[0], y = r[1], g = C(y, i);
|
|
2039
2039
|
if (g !== y) {
|
|
2040
|
-
const p = B(c,
|
|
2041
|
-
|
|
2042
|
-
start:
|
|
2043
|
-
end:
|
|
2040
|
+
const p = B(c, r.index);
|
|
2041
|
+
n.push({
|
|
2042
|
+
start: r.index,
|
|
2043
|
+
end: r.index + m.length,
|
|
2044
2044
|
original: m,
|
|
2045
2045
|
replacement: `v-model="${g}"`,
|
|
2046
2046
|
line: p.line,
|
|
@@ -2055,13 +2055,13 @@ function u0(e) {
|
|
|
2055
2055
|
}
|
|
2056
2056
|
}
|
|
2057
2057
|
const N = /v-bind="([^"]+)"/g;
|
|
2058
|
-
for (; (
|
|
2059
|
-
const m =
|
|
2058
|
+
for (; (r = N.exec(c)) !== null; ) {
|
|
2059
|
+
const m = r[0], y = r[1], g = C(y, i);
|
|
2060
2060
|
if (g !== y) {
|
|
2061
|
-
const p = B(c,
|
|
2062
|
-
|
|
2063
|
-
start:
|
|
2064
|
-
end:
|
|
2061
|
+
const p = B(c, r.index);
|
|
2062
|
+
n.push({
|
|
2063
|
+
start: r.index,
|
|
2064
|
+
end: r.index + m.length,
|
|
2065
2065
|
original: m,
|
|
2066
2066
|
replacement: `v-bind="${g}"`,
|
|
2067
2067
|
line: p.line,
|
|
@@ -2076,13 +2076,13 @@ function u0(e) {
|
|
|
2076
2076
|
}
|
|
2077
2077
|
}
|
|
2078
2078
|
const V = /v-(text|html)="([^"]+)"/g;
|
|
2079
|
-
for (; (
|
|
2080
|
-
const m =
|
|
2079
|
+
for (; (r = V.exec(c)) !== null; ) {
|
|
2080
|
+
const m = r[0], y = r[1], g = r[2], p = C(g, i);
|
|
2081
2081
|
if (p !== g) {
|
|
2082
|
-
const E = B(c,
|
|
2083
|
-
|
|
2084
|
-
start:
|
|
2085
|
-
end:
|
|
2082
|
+
const E = B(c, r.index);
|
|
2083
|
+
n.push({
|
|
2084
|
+
start: r.index,
|
|
2085
|
+
end: r.index + m.length,
|
|
2086
2086
|
original: m,
|
|
2087
2087
|
replacement: `v-${y}="${p}"`,
|
|
2088
2088
|
line: E.line,
|
|
@@ -2097,13 +2097,13 @@ function u0(e) {
|
|
|
2097
2097
|
}
|
|
2098
2098
|
}
|
|
2099
2099
|
const uu = /(@|v-on:)(\w+)="([^"]+)"/g;
|
|
2100
|
-
for (; (
|
|
2101
|
-
const m =
|
|
2100
|
+
for (; (r = uu.exec(c)) !== null; ) {
|
|
2101
|
+
const m = r[0], y = r[1], g = r[2], p = r[3], E = t0(p, i);
|
|
2102
2102
|
if (E !== p) {
|
|
2103
|
-
const q = B(c,
|
|
2104
|
-
|
|
2105
|
-
start:
|
|
2106
|
-
end:
|
|
2103
|
+
const q = B(c, r.index);
|
|
2104
|
+
n.push({
|
|
2105
|
+
start: r.index,
|
|
2106
|
+
end: r.index + m.length,
|
|
2107
2107
|
original: m,
|
|
2108
2108
|
replacement: `${y}${g}="${E}"`,
|
|
2109
2109
|
line: q.line,
|
|
@@ -2117,16 +2117,16 @@ function u0(e) {
|
|
|
2117
2117
|
});
|
|
2118
2118
|
}
|
|
2119
2119
|
}
|
|
2120
|
-
if (
|
|
2120
|
+
if (n.sort((m, y) => y.start - m.start), n.forEach((m) => {
|
|
2121
2121
|
s = s.substring(0, m.start) + m.replacement + s.substring(m.end);
|
|
2122
|
-
}),
|
|
2122
|
+
}), n.length > 0) {
|
|
2123
2123
|
const m = e.indexOf("<template>"), y = e.lastIndexOf("</template>") + 11;
|
|
2124
2124
|
t = e.substring(0, m) + `<template>
|
|
2125
2125
|
` + s + `
|
|
2126
2126
|
</template>` + e.substring(y);
|
|
2127
2127
|
}
|
|
2128
2128
|
return {
|
|
2129
|
-
fixed:
|
|
2129
|
+
fixed: n.length > 0,
|
|
2130
2130
|
originalCode: e,
|
|
2131
2131
|
fixedCode: t,
|
|
2132
2132
|
changes: u
|
|
@@ -2168,7 +2168,7 @@ function t0(e, u) {
|
|
|
2168
2168
|
`(\\+\\+|--)?(?<![\\w.])${a}(?![\\w])`,
|
|
2169
2169
|
"g"
|
|
2170
2170
|
);
|
|
2171
|
-
t.includes(`state.${a}`) || (t = t.replace(i, `state.${a}$1`), t = t.replace(c, (s,
|
|
2171
|
+
t.includes(`state.${a}`) || (t = t.replace(i, `state.${a}$1`), t = t.replace(c, (s, n) => n ? `${n}state.${a}` : s.includes(a) && !s.includes("state.") ? `state.${a}` : s));
|
|
2172
2172
|
}), C(t, u);
|
|
2173
2173
|
}
|
|
2174
2174
|
function B(e, u) {
|
|
@@ -2196,15 +2196,15 @@ class a0 {
|
|
|
2196
2196
|
a.script = ku(a.script, {
|
|
2197
2197
|
ImportDeclaration(s) {
|
|
2198
2198
|
if (s.node.source.value === "@vtj/icons") {
|
|
2199
|
-
const
|
|
2200
|
-
let
|
|
2201
|
-
for (const b of
|
|
2199
|
+
const n = s.node.specifiers, d = [];
|
|
2200
|
+
let r = !1;
|
|
2201
|
+
for (const b of n) {
|
|
2202
2202
|
const f = b.imported?.name;
|
|
2203
|
-
f === j && (
|
|
2203
|
+
f === j && (r = !0), t.includes(f) || d.push(
|
|
2204
2204
|
T.importSpecifier(b.local, b.imported)
|
|
2205
2205
|
);
|
|
2206
2206
|
}
|
|
2207
|
-
|
|
2207
|
+
r || d.push(
|
|
2208
2208
|
T.importSpecifier(
|
|
2209
2209
|
T.identifier(j),
|
|
2210
2210
|
T.identifier(j)
|
|
@@ -2214,11 +2214,11 @@ class a0 {
|
|
|
2214
2214
|
},
|
|
2215
2215
|
ObjectMethod(s) {
|
|
2216
2216
|
if (s.node.key.name === "setup") {
|
|
2217
|
-
const
|
|
2218
|
-
for (const d of
|
|
2217
|
+
const n = s.node.body.body;
|
|
2218
|
+
for (const d of n)
|
|
2219
2219
|
if (T.isReturnStatement(d) && T.isObjectExpression(d.argument)) {
|
|
2220
|
-
const
|
|
2221
|
-
d.argument.properties =
|
|
2220
|
+
const r = d.argument.properties || [];
|
|
2221
|
+
d.argument.properties = r.filter(
|
|
2222
2222
|
(b) => !t.includes(b.key.name)
|
|
2223
2223
|
), d.argument.properties.push(
|
|
2224
2224
|
T.objectProperty(
|
|
@@ -2233,8 +2233,8 @@ class a0 {
|
|
|
2233
2233
|
},
|
|
2234
2234
|
ObjectProperty(s) {
|
|
2235
2235
|
if (T.isIdentifier(s.node.value) && t.includes(s.node.value.name) && (s.node.value = T.identifier(j)), T.isArrayExpression(s.node.value)) {
|
|
2236
|
-
const
|
|
2237
|
-
s.node.value.elements =
|
|
2236
|
+
const n = s.node.value.elements;
|
|
2237
|
+
s.node.value.elements = n.map((d) => T.isIdentifier(d) && t.includes(d.name) ? T.identifier(j) : d);
|
|
2238
2238
|
}
|
|
2239
2239
|
},
|
|
2240
2240
|
AssignmentExpression(s) {
|
|
@@ -2244,10 +2244,10 @@ class a0 {
|
|
|
2244
2244
|
const i = /:icon\s*=\s*["']([^"']+)["']/g, c = a.template.match(i);
|
|
2245
2245
|
if (c)
|
|
2246
2246
|
for (const s of c) {
|
|
2247
|
-
let
|
|
2247
|
+
let n = s;
|
|
2248
2248
|
for (const d of t)
|
|
2249
|
-
|
|
2250
|
-
a.template = a.template.replace(s,
|
|
2249
|
+
n = n.replace(new RegExp(d, "g"), j);
|
|
2250
|
+
a.template = a.template.replace(s, n);
|
|
2251
2251
|
}
|
|
2252
2252
|
for (const s of t)
|
|
2253
2253
|
a.template = a.template.replace(
|
|
@@ -2276,11 +2276,11 @@ ${a}
|
|
|
2276
2276
|
}
|
|
2277
2277
|
}
|
|
2278
2278
|
async function y0(e) {
|
|
2279
|
-
const { id: u, name: t, source: a, project: i } = e, { dependencies: c = [], platform: s = "web" } = i || {},
|
|
2279
|
+
const { id: u, name: t, source: a, project: i } = e, { dependencies: c = [], platform: s = "web" } = i || {}, n = new Ye(), d = new a0(), r = n.validate(a);
|
|
2280
2280
|
let b = [];
|
|
2281
|
-
if (!
|
|
2282
|
-
return b =
|
|
2283
|
-
const f = d.fixBasedOnValidation(a,
|
|
2281
|
+
if (!r.valid)
|
|
2282
|
+
return b = r.errors, Promise.reject(b);
|
|
2283
|
+
const f = d.fixBasedOnValidation(a, r), I = R(f), {
|
|
2284
2284
|
styles: x,
|
|
2285
2285
|
css: N,
|
|
2286
2286
|
errors: V
|
|
@@ -2296,7 +2296,7 @@ async function y0(e) {
|
|
|
2296
2296
|
methods: p,
|
|
2297
2297
|
props: E,
|
|
2298
2298
|
emits: q,
|
|
2299
|
-
expose:
|
|
2299
|
+
expose: $,
|
|
2300
2300
|
inject: eu,
|
|
2301
2301
|
handlers: Mu,
|
|
2302
2302
|
imports: lu,
|
|
@@ -2319,7 +2319,7 @@ async function y0(e) {
|
|
|
2319
2319
|
dataSources: Pu,
|
|
2320
2320
|
slots: $u,
|
|
2321
2321
|
emits: q,
|
|
2322
|
-
expose:
|
|
2322
|
+
expose: $,
|
|
2323
2323
|
nodes: Ou,
|
|
2324
2324
|
css: N
|
|
2325
2325
|
}, Hu = Object.keys(g || {}), Gu = [
|
|
@@ -2348,17 +2348,17 @@ async function y0(e) {
|
|
|
2348
2348
|
};
|
|
2349
2349
|
return await i0(
|
|
2350
2350
|
bu,
|
|
2351
|
-
async (
|
|
2352
|
-
await c0(
|
|
2353
|
-
if (ou(
|
|
2354
|
-
const Ju = await xu(
|
|
2355
|
-
|
|
2351
|
+
async (G) => {
|
|
2352
|
+
await c0(G, async (W) => {
|
|
2353
|
+
if (ou(W)) {
|
|
2354
|
+
const Ju = await xu(W.value);
|
|
2355
|
+
W.value = gu(Ju, G.id, hu);
|
|
2356
2356
|
}
|
|
2357
2357
|
});
|
|
2358
2358
|
},
|
|
2359
|
-
async (
|
|
2360
|
-
const
|
|
2361
|
-
|
|
2359
|
+
async (G) => {
|
|
2360
|
+
const W = await xu(G.value);
|
|
2361
|
+
G.value = gu(W, "", hu);
|
|
2362
2362
|
}
|
|
2363
2363
|
), new Zu(bu).toDsl();
|
|
2364
2364
|
}
|
|
@@ -2380,9 +2380,9 @@ async function i0(e, u, t) {
|
|
|
2380
2380
|
}, {
|
|
2381
2381
|
state: c,
|
|
2382
2382
|
watch: s,
|
|
2383
|
-
computed:
|
|
2383
|
+
computed: n,
|
|
2384
2384
|
props: d,
|
|
2385
|
-
dataSources:
|
|
2385
|
+
dataSources: r,
|
|
2386
2386
|
methods: b,
|
|
2387
2387
|
lifeCycles: f,
|
|
2388
2388
|
inject: I
|
|
@@ -2390,9 +2390,9 @@ async function i0(e, u, t) {
|
|
|
2390
2390
|
if (await i({
|
|
2391
2391
|
state: c,
|
|
2392
2392
|
watch: s,
|
|
2393
|
-
computed:
|
|
2393
|
+
computed: n,
|
|
2394
2394
|
props: d,
|
|
2395
|
-
dataSources:
|
|
2395
|
+
dataSources: r,
|
|
2396
2396
|
methods: b,
|
|
2397
2397
|
lifeCycles: f,
|
|
2398
2398
|
inject: I
|
|
@@ -2426,8 +2426,8 @@ function s0(e = [], u = []) {
|
|
|
2426
2426
|
for (const { from: i, imports: c } of e)
|
|
2427
2427
|
if (Array.isArray(c))
|
|
2428
2428
|
c.forEach((s) => {
|
|
2429
|
-
const
|
|
2430
|
-
|
|
2429
|
+
const n = a[i];
|
|
2430
|
+
n && (t[s] = n);
|
|
2431
2431
|
});
|
|
2432
2432
|
else {
|
|
2433
2433
|
const s = a[i];
|
|
@@ -2445,5 +2445,5 @@ export {
|
|
|
2445
2445
|
g0 as parseUniApp,
|
|
2446
2446
|
y0 as parseVue,
|
|
2447
2447
|
gu as patchCode,
|
|
2448
|
-
|
|
2448
|
+
P as replacer
|
|
2449
2449
|
};
|