@vtj/parser 0.13.16 → 0.13.17
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 +10 -10
- package/dist/index.mjs +230 -222
- package/package.json +6 -6
- package/types/version.d.ts +2 -2
package/dist/index.mjs
CHANGED
@@ -13,11 +13,11 @@ 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.17
|
17
17
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
18
18
|
*/
|
19
|
-
const p0 = "0.13.
|
20
|
-
function
|
19
|
+
const p0 = "0.13.17";
|
20
|
+
function R(e) {
|
21
21
|
const { descriptor: u } = Ju(e), t = u.template?.content || "", a = (u.scriptSetup || u.script)?.content || "", i = u.styles.map((c) => c.content);
|
22
22
|
return {
|
23
23
|
template: t,
|
@@ -66,7 +66,7 @@ function ku(e, u) {
|
|
66
66
|
}
|
67
67
|
}
|
68
68
|
function m0(e) {
|
69
|
-
const u =
|
69
|
+
const u = R(e), t = z(u.script), a = {};
|
70
70
|
return u.styles && (a.css = u.styles[0] || ""), K(t, {
|
71
71
|
CallExpression(i) {
|
72
72
|
const c = i.node.callee?.name;
|
@@ -82,8 +82,8 @@ function m0(e) {
|
|
82
82
|
}
|
83
83
|
function W(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 = W(e,
|
101
|
-
for (const
|
102
|
-
e = W(e,
|
103
|
-
for (const [
|
104
|
-
e = W(e,
|
105
|
-
for (const
|
106
|
-
e = W(e,
|
107
|
-
if (
|
108
|
-
const
|
109
|
-
e = e.replace(
|
99
|
+
for (const r of d)
|
100
|
+
e = W(e, r, `this.context.${r}`);
|
101
|
+
for (const r of i)
|
102
|
+
e = W(e, r, `this.${r}.value`);
|
103
|
+
for (const [r, b] of Object.entries(c))
|
104
|
+
e = W(e, r, `this.$libs.${b}.${r}`), e = W(e, `this.${r}`, `this.$libs.${b}.${r}`);
|
105
|
+
for (const r of s)
|
106
|
+
e = W(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
|
}
|
@@ -241,13 +241,13 @@ var v;
|
|
241
241
|
(function(e) {
|
242
242
|
e[e.EntityStart = 0] = "EntityStart", e[e.NumericStart = 1] = "NumericStart", e[e.NumericDecimal = 2] = "NumericDecimal", e[e.NumericHex = 3] = "NumericHex", e[e.NamedEntity = 4] = "NamedEntity";
|
243
243
|
})(v || (v = {}));
|
244
|
-
var
|
244
|
+
var D;
|
245
245
|
(function(e) {
|
246
246
|
e[e.Legacy = 0] = "Legacy", e[e.Strict = 1] = "Strict", e[e.Attribute = 2] = "Attribute";
|
247
|
-
})(
|
247
|
+
})(D || (D = {}));
|
248
248
|
class ge {
|
249
249
|
constructor(u, t, a) {
|
250
|
-
this.decodeTree = u, this.emitCodePoint = t, this.errors = a, this.state = v.EntityStart, this.consumed = 1, this.result = 0, this.treeIndex = 0, this.excess = 1, this.decodeMode =
|
250
|
+
this.decodeTree = u, this.emitCodePoint = t, this.errors = a, this.state = v.EntityStart, this.consumed = 1, this.result = 0, this.treeIndex = 0, this.excess = 1, this.decodeMode = D.Strict;
|
251
251
|
}
|
252
252
|
/** Resets the instance to make it reusable. */
|
253
253
|
startEntity(u) {
|
@@ -355,7 +355,7 @@ class ge {
|
|
355
355
|
return (a = this.errors) === null || a === void 0 || a.absenceOfDigitsInNumericCharacterReference(this.consumed), 0;
|
356
356
|
if (u === A.SEMI)
|
357
357
|
this.consumed += 1;
|
358
|
-
else if (this.decodeMode ===
|
358
|
+
else if (this.decodeMode === D.Strict)
|
359
359
|
return 0;
|
360
360
|
return this.emitCodePoint(be(this.result), this.consumed), this.errors && (u !== A.SEMI && this.errors.missingSemicolonAfterCharacterReference(), this.errors.validateNumericCharacterReference(this.result)), this.consumed;
|
361
361
|
}
|
@@ -375,13 +375,13 @@ class ge {
|
|
375
375
|
const s = u.charCodeAt(t);
|
376
376
|
if (this.treeIndex = ye(a, i, this.treeIndex + Math.max(1, c), s), this.treeIndex < 0)
|
377
377
|
return this.result === 0 || // If we are parsing an attribute
|
378
|
-
this.decodeMode ===
|
378
|
+
this.decodeMode === D.Attribute && // We shouldn't have consumed any characters after the entity,
|
379
379
|
(c === 0 || // And there should be no invalid characters.
|
380
380
|
xe(s)) ? 0 : this.emitNotTerminatedNamedEntity();
|
381
381
|
if (i = a[this.treeIndex], c = (i & F.VALUE_LENGTH) >> 14, c !== 0) {
|
382
382
|
if (s === A.SEMI)
|
383
383
|
return this.emitNamedEntityData(this.treeIndex, c, this.consumed + this.excess);
|
384
|
-
this.decodeMode !==
|
384
|
+
this.decodeMode !== D.Strict && (this.result = this.treeIndex, this.consumed += this.excess, this.excess = 0);
|
385
385
|
}
|
386
386
|
}
|
387
387
|
return -1;
|
@@ -420,7 +420,7 @@ class ge {
|
|
420
420
|
var u;
|
421
421
|
switch (this.state) {
|
422
422
|
case v.NamedEntity:
|
423
|
-
return this.result !== 0 && (this.decodeMode !==
|
423
|
+
return this.result !== 0 && (this.decodeMode !== D.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
|
424
424
|
// Otherwise, emit a numeric entity if we have one.
|
425
425
|
case v.NumericDecimal:
|
426
426
|
return this.emitNumericEntity(0, 2);
|
@@ -441,13 +441,13 @@ function ye(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
|
}
|
@@ -470,10 +470,10 @@ function X(e) {
|
|
470
470
|
function Se(e) {
|
471
471
|
return e >= l.LowerA && e <= l.LowerZ || e >= l.UpperA && e <= l.UpperZ;
|
472
472
|
}
|
473
|
-
var
|
473
|
+
var L;
|
474
474
|
(function(e) {
|
475
475
|
e[e.NoValue = 0] = "NoValue", e[e.Unquoted = 1] = "Unquoted", e[e.Single = 2] = "Single", e[e.Double = 3] = "Double";
|
476
|
-
})(
|
476
|
+
})(L || (L = {}));
|
477
477
|
const w = {
|
478
478
|
Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
|
479
479
|
// CDATA[
|
@@ -627,13 +627,13 @@ class Ie {
|
|
627
627
|
(u === l.Eq || X(u)) && (this.cbs.onattribname(this.sectionStart, this.index), this.sectionStart = this.index, this.state = o.AfterAttributeName, this.stateAfterAttributeName(u));
|
628
628
|
}
|
629
629
|
stateAfterAttributeName(u) {
|
630
|
-
u === l.Eq ? this.state = o.BeforeAttributeValue : u === l.Slash || u === l.Gt ? (this.cbs.onattribend(
|
630
|
+
u === l.Eq ? this.state = o.BeforeAttributeValue : u === l.Slash || u === l.Gt ? (this.cbs.onattribend(L.NoValue, this.sectionStart), this.sectionStart = -1, this.state = o.BeforeAttributeName, this.stateBeforeAttributeName(u)) : _(u) || (this.cbs.onattribend(L.NoValue, this.sectionStart), this.state = o.InAttributeName, this.sectionStart = this.index);
|
631
631
|
}
|
632
632
|
stateBeforeAttributeValue(u) {
|
633
633
|
u === l.DoubleQuote ? (this.state = o.InAttributeValueDq, this.sectionStart = this.index + 1) : u === l.SingleQuote ? (this.state = o.InAttributeValueSq, this.sectionStart = this.index + 1) : _(u) || (this.sectionStart = this.index, this.state = o.InAttributeValueNq, this.stateInAttributeValueNoQuotes(u));
|
634
634
|
}
|
635
635
|
handleInAttributeValue(u, t) {
|
636
|
-
u === t || !this.decodeEntities && this.fastForwardTo(t) ? (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = -1, this.cbs.onattribend(t === l.DoubleQuote ?
|
636
|
+
u === t || !this.decodeEntities && this.fastForwardTo(t) ? (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = -1, this.cbs.onattribend(t === l.DoubleQuote ? L.Double : L.Single, this.index + 1), this.state = o.BeforeAttributeName) : this.decodeEntities && u === l.Amp && this.startEntity();
|
637
637
|
}
|
638
638
|
stateInAttributeValueDoubleQuotes(u) {
|
639
639
|
this.handleInAttributeValue(u, l.DoubleQuote);
|
@@ -642,7 +642,7 @@ class Ie {
|
|
642
642
|
this.handleInAttributeValue(u, l.SingleQuote);
|
643
643
|
}
|
644
644
|
stateInAttributeValueNoQuotes(u) {
|
645
|
-
_(u) || u === l.Gt ? (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = -1, this.cbs.onattribend(
|
645
|
+
_(u) || u === l.Gt ? (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = -1, this.cbs.onattribend(L.Unquoted, this.index), this.state = o.BeforeAttributeName, this.stateBeforeAttributeName(u)) : this.decodeEntities && u === l.Amp && this.startEntity();
|
646
646
|
}
|
647
647
|
stateBeforeDeclaration(u) {
|
648
648
|
u === l.OpeningSquareBracket ? (this.state = o.CDATASequence, this.sequenceIndex = 0) : this.state = u === l.Dash ? o.BeforeComment : o.InDeclaration;
|
@@ -682,7 +682,7 @@ class Ie {
|
|
682
682
|
}
|
683
683
|
}
|
684
684
|
startEntity() {
|
685
|
-
this.baseState = this.state, this.state = o.InEntity, this.entityStart = this.index, this.entityDecoder.startEntity(this.xmlMode ?
|
685
|
+
this.baseState = this.state, this.state = o.InEntity, this.entityStart = this.index, this.entityDecoder.startEntity(this.xmlMode ? D.Strict : this.baseState === o.Text || this.baseState === o.InSpecialTag ? D.Legacy : D.Attribute);
|
686
686
|
}
|
687
687
|
stateInEntity() {
|
688
688
|
const u = this.entityDecoder.write(this.buffer, this.index - this.offset);
|
@@ -916,8 +916,8 @@ const $ = /* @__PURE__ */ new Set([
|
|
916
916
|
]), ve = /\s|\//;
|
917
917
|
class Ae {
|
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 : Ie)(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 : Ie)(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 Ae {
|
|
950
950
|
const s = this.htmlMode && Ee.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 Ae {
|
|
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)
|
@@ -1007,7 +1007,7 @@ class Ae {
|
|
1007
1007
|
/** @internal */
|
1008
1008
|
onattribend(u, t) {
|
1009
1009
|
var a, i;
|
1010
|
-
this.endIndex = t, (i = (a = this.cbs).onattribute) === null || i === void 0 || i.call(a, this.attribname, this.attribvalue, u ===
|
1010
|
+
this.endIndex = t, (i = (a = this.cbs).onattribute) === null || i === void 0 || i.call(a, this.attribname, this.attribvalue, u === L.Double ? '"' : u === L.Single ? "'" : u === L.NoValue ? void 0 : null), this.attribs && !Object.prototype.hasOwnProperty.call(this.attribs, this.attribname) && (this.attribs[this.attribname] = this.attribvalue), this.attribvalue = "";
|
1011
1011
|
}
|
1012
1012
|
getInstructionName(u) {
|
1013
1013
|
const t = u.search(ve);
|
@@ -1036,15 +1036,15 @@ class Ae {
|
|
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 Ae(
|
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 Te(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"
|
@@ -1233,19 +1233,19 @@ function Te(e, u) {
|
|
1233
1233
|
a.inject = Me(f.value);
|
1234
1234
|
break;
|
1235
1235
|
}
|
1236
|
-
for (const f of
|
1236
|
+
for (const f of r)
|
1237
1237
|
switch (f.key.name) {
|
1238
1238
|
case "setup":
|
1239
1239
|
a.state = Ve(f.body);
|
1240
1240
|
break;
|
1241
1241
|
}
|
1242
|
-
a.lifeCycles = _e(
|
1242
|
+
a.lifeCycles = _e(r);
|
1243
1243
|
},
|
1244
1244
|
CallExpression(c) {
|
1245
1245
|
const s = Fe(c.node);
|
1246
1246
|
if (s.length)
|
1247
|
-
for (let
|
1248
|
-
a.emits?.find((
|
1247
|
+
for (let n of s)
|
1248
|
+
a.emits?.find((r) => r.name === n.name) || a.emits?.push(n);
|
1249
1249
|
}
|
1250
1250
|
}), a;
|
1251
1251
|
}
|
@@ -1254,17 +1254,17 @@ function Ne(e) {
|
|
1254
1254
|
let c;
|
1255
1255
|
const s = e.replace(/\n/g, " ");
|
1256
1256
|
for (; (c = u.exec(s)) !== null; ) {
|
1257
|
-
const
|
1257
|
+
const n = c[2] === "@element-plus/icons-vue" ? "@vtj/icons" : c[2];
|
1258
1258
|
i.push({
|
1259
|
-
from:
|
1259
|
+
from: n,
|
1260
1260
|
imports: c[1].split(",").map((d) => d.trim())
|
1261
1261
|
});
|
1262
1262
|
}
|
1263
1263
|
for (; (c = t.exec(s)) !== null; ) {
|
1264
|
-
const
|
1265
|
-
|
1264
|
+
const n = c[1], d = c[2];
|
1265
|
+
n && !a.test(n) && i.push({
|
1266
1266
|
from: d,
|
1267
|
-
imports:
|
1267
|
+
imports: n
|
1268
1268
|
});
|
1269
1269
|
}
|
1270
1270
|
return i;
|
@@ -1295,14 +1295,14 @@ function P(e) {
|
|
1295
1295
|
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(", ");
|
1296
1296
|
if (u.type === "Identifier") {
|
1297
1297
|
const s = u.name;
|
1298
|
-
let
|
1299
|
-
i && (
|
1298
|
+
let n = "{}";
|
1299
|
+
i && (n = M(i) || "{}");
|
1300
1300
|
const d = e.value;
|
1301
1301
|
if (d && d.type === "CallExpression") {
|
1302
1302
|
let x = M(d) || "";
|
1303
|
-
x = x.replace("function () {", "() => {"),
|
1303
|
+
x = x.replace("function () {", "() => {"), n = `{ return (${x})}`;
|
1304
1304
|
}
|
1305
|
-
const b = `${t ? "async " : ""}(${c}) => ${
|
1305
|
+
const b = `${t ? "async " : ""}(${c}) => ${n}`, f = s.startsWith("watcher_");
|
1306
1306
|
return {
|
1307
1307
|
id: f ? s.replace("watcher_", "") : "",
|
1308
1308
|
name: s,
|
@@ -1324,7 +1324,7 @@ function qe(e, u) {
|
|
1324
1324
|
if (!e) return {};
|
1325
1325
|
const t = {}, a = /apis\[\'([\w]*)\'\]/, i = /\.then\(([\w\W]*)\)/;
|
1326
1326
|
for (const c of e.properties) {
|
1327
|
-
const s = P(c),
|
1327
|
+
const s = P(c), n = c.body.body?.[0], d = (n?.leadingComments?.[0].value || "").trim(), r = oe(d);
|
1328
1328
|
if (s && s.exp.value.includes("this.provider.apis")) {
|
1329
1329
|
const f = (s.exp.value.match(a) || [])[1];
|
1330
1330
|
if (!f) continue;
|
@@ -1334,7 +1334,7 @@ function qe(e, u) {
|
|
1334
1334
|
t[s.name] = {
|
1335
1335
|
ref: f,
|
1336
1336
|
name: I.name,
|
1337
|
-
test:
|
1337
|
+
test: r?.test || {
|
1338
1338
|
type: "JSFunction",
|
1339
1339
|
value: `() => this.runApi({
|
1340
1340
|
/* 在这里可输入接口参数 */
|
@@ -1352,25 +1352,25 @@ function qe(e, u) {
|
|
1352
1352
|
};
|
1353
1353
|
}
|
1354
1354
|
if (s && s.exp.value.includes("this.provider.createMock")) {
|
1355
|
-
const b =
|
1355
|
+
const b = n?.declarations?.[0]?.init?.arguments?.[0], f = s.exp.value.match(i)?.[1];
|
1356
1356
|
t[s.name] = {
|
1357
1357
|
ref: "",
|
1358
1358
|
name: s.name,
|
1359
|
-
test:
|
1359
|
+
test: r?.test || {
|
1360
1360
|
type: "JSFunction",
|
1361
1361
|
value: `() => this.runApi({
|
1362
1362
|
/* 在这里可输入接口参数 */
|
1363
1363
|
})`
|
1364
1364
|
},
|
1365
1365
|
type: "mock",
|
1366
|
-
label:
|
1367
|
-
transform:
|
1366
|
+
label: r?.label || "",
|
1367
|
+
transform: r?.transform || {
|
1368
1368
|
type: "JSFunction",
|
1369
1369
|
value: f || `(res) => {
|
1370
1370
|
return res;
|
1371
1371
|
}`
|
1372
1372
|
},
|
1373
|
-
mockTemplate:
|
1373
|
+
mockTemplate: r?.mockTemplate || {
|
1374
1374
|
type: "JSFunction",
|
1375
1375
|
value: b ? M(b) : ""
|
1376
1376
|
}
|
@@ -1434,13 +1434,13 @@ function Le(e, u = {}) {
|
|
1434
1434
|
for (const a of e.properties) {
|
1435
1435
|
const { key: i, value: c } = a, s = i.value || i.name || "";
|
1436
1436
|
if (u[s]) {
|
1437
|
-
const
|
1437
|
+
const n = c.properties;
|
1438
1438
|
t.push({
|
1439
1439
|
id: s.replace("watcher_", ""),
|
1440
1440
|
source: u[s],
|
1441
|
-
deep: J(
|
1442
|
-
immediate: J(
|
1443
|
-
handler: Tu(
|
1441
|
+
deep: J(n, "deep"),
|
1442
|
+
immediate: J(n, "immediate"),
|
1443
|
+
handler: Tu(n, "handler")
|
1444
1444
|
});
|
1445
1445
|
} else if (a.type === "ObjectMethod" && t.push({
|
1446
1446
|
id: iu(),
|
@@ -1452,16 +1452,16 @@ function Le(e, u = {}) {
|
|
1452
1452
|
immediate: !1,
|
1453
1453
|
handler: P(a)?.exp
|
1454
1454
|
}), a.type === "ObjectProperty") {
|
1455
|
-
const
|
1455
|
+
const n = c.properties;
|
1456
1456
|
t.push({
|
1457
1457
|
id: iu(),
|
1458
1458
|
source: {
|
1459
1459
|
type: "JSFunction",
|
1460
1460
|
value: `() => { return this.${s}; }`
|
1461
1461
|
},
|
1462
|
-
deep: J(
|
1463
|
-
immediate: J(
|
1464
|
-
handler: Tu(
|
1462
|
+
deep: J(n, "deep"),
|
1463
|
+
immediate: J(n, "immediate"),
|
1464
|
+
handler: Tu(n, "handler")
|
1465
1465
|
});
|
1466
1466
|
}
|
1467
1467
|
}
|
@@ -1521,10 +1521,10 @@ function Fe(e) {
|
|
1521
1521
|
function Me(e) {
|
1522
1522
|
let u = [];
|
1523
1523
|
return e.type === "ObjectExpression" && (u = e.properties.map((t) => {
|
1524
|
-
const { key: a, value: i } = t, c = i.properties, s = a.name,
|
1524
|
+
const { key: a, value: i } = t, c = i.properties, s = a.name, n = Ru(c, "from"), d = Du(c);
|
1525
1525
|
return {
|
1526
1526
|
name: s,
|
1527
|
-
from:
|
1527
|
+
from: n || s,
|
1528
1528
|
default: d
|
1529
1529
|
};
|
1530
1530
|
})), u;
|
@@ -1541,7 +1541,7 @@ function Oe(e, u, t = "", a) {
|
|
1541
1541
|
source: t,
|
1542
1542
|
isProd: !0,
|
1543
1543
|
slotted: !0
|
1544
|
-
}).ast?.children || []).map((
|
1544
|
+
}).ast?.children || []).map((n) => U(n)).filter((n) => !!n),
|
1545
1545
|
slots: su,
|
1546
1546
|
context: Q
|
1547
1547
|
};
|
@@ -1563,8 +1563,8 @@ function Ue(e) {
|
|
1563
1563
|
for (const t of e) {
|
1564
1564
|
if (t.type === h.ATTRIBUTE)
|
1565
1565
|
if (t.name === "class") {
|
1566
|
-
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((d) => d !== c),
|
1567
|
-
|
1566
|
+
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((d) => d !== c), n = _u[`.${c}`];
|
1567
|
+
n && (u.style = n), s.length && (u.class = s.join(" "));
|
1568
1568
|
} else if (t.name === "style") {
|
1569
1569
|
const a = t.value?.content || "";
|
1570
1570
|
a && (u.style = qu(a));
|
@@ -1595,11 +1595,11 @@ function He(e, u = {}) {
|
|
1595
1595
|
);
|
1596
1596
|
let c = a.exp?.loc.source || "";
|
1597
1597
|
/\)$/.test(c) && (c = `($event) => { ${c} } `);
|
1598
|
-
const
|
1599
|
-
if (d &&
|
1598
|
+
const n = new RegExp(`${a.arg.content}_[\\w]{5,}`), d = c.match(n)?.[0] || "", r = u[d];
|
1599
|
+
if (d && r)
|
1600
1600
|
t[a.arg.content] = {
|
1601
1601
|
name: a.arg.content,
|
1602
|
-
handler:
|
1602
|
+
handler: r,
|
1603
1603
|
modifiers: i
|
1604
1604
|
};
|
1605
1605
|
else {
|
@@ -1622,9 +1622,9 @@ function Y(e, u) {
|
|
1622
1622
|
name: c,
|
1623
1623
|
value: c === "vElse" ? !0 : k(s)
|
1624
1624
|
});
|
1625
|
-
const
|
1626
|
-
if (
|
1627
|
-
const d = Y(
|
1625
|
+
const n = e.children?.[0];
|
1626
|
+
if (n) {
|
1627
|
+
const d = Y(n);
|
1628
1628
|
t.push(...d);
|
1629
1629
|
}
|
1630
1630
|
}
|
@@ -1656,10 +1656,10 @@ function Y(e, u) {
|
|
1656
1656
|
name: "vBind",
|
1657
1657
|
value: k(s.exp?.loc.source || "")
|
1658
1658
|
});
|
1659
|
-
const
|
1660
|
-
|
1659
|
+
const n = a.find((d) => d.name === "html");
|
1660
|
+
n && t.push({
|
1661
1661
|
name: "vHtml",
|
1662
|
-
value: k(
|
1662
|
+
value: k(n.exp?.loc.source || "")
|
1663
1663
|
});
|
1664
1664
|
}
|
1665
1665
|
return t;
|
@@ -1673,8 +1673,8 @@ function Cu(e) {
|
|
1673
1673
|
const c = i.value?.content || "", s = new RegExp(`${a}_([\\w]+)`);
|
1674
1674
|
u = c.match(s)?.[1] || "";
|
1675
1675
|
} else if (i.type === h.DIRECTIVE && i.name === "on") {
|
1676
|
-
const c = i.arg?.loc?.source || "", s = i.exp?.loc?.source || "",
|
1677
|
-
u = s.match(
|
1676
|
+
const c = i.arg?.loc?.source || "", s = i.exp?.loc?.source || "", n = new RegExp(`${c}_([\\w]+)`);
|
1677
|
+
u = s.match(n)?.[1] || "";
|
1678
1678
|
}
|
1679
1679
|
}
|
1680
1680
|
return u || iu();
|
@@ -1698,13 +1698,13 @@ function nu(e, u) {
|
|
1698
1698
|
const t = new Set(u?.id ? Q[u.id] : []), a = (e.directives || []).find((s) => s.name === "vFor");
|
1699
1699
|
let i = new Set(Array.from(t));
|
1700
1700
|
if (a) {
|
1701
|
-
const { item: s = "item", index:
|
1702
|
-
i = /* @__PURE__ */ new Set([s,
|
1701
|
+
const { item: s = "item", index: n = "index" } = a.iterator || {};
|
1702
|
+
i = /* @__PURE__ */ new Set([s, n, ...Array.from(i)]);
|
1703
1703
|
}
|
1704
1704
|
const c = e.slot;
|
1705
1705
|
if (c) {
|
1706
|
-
const s = typeof c == "string" ? [] : c.params || [],
|
1707
|
-
i = /* @__PURE__ */ new Set([...
|
1706
|
+
const s = typeof c == "string" ? [] : c.params || [], n = s.length ? s : [`scope_${u?.id}`];
|
1707
|
+
i = /* @__PURE__ */ new Set([...n, ...Array.from(i)]);
|
1708
1708
|
}
|
1709
1709
|
Q[e.id] = i;
|
1710
1710
|
}
|
@@ -1823,14 +1823,14 @@ function ze(e) {
|
|
1823
1823
|
const u = [], t = {}, a = [];
|
1824
1824
|
try {
|
1825
1825
|
const i = ue.compileString(e, { charset: !1 })?.css || "", c = Yu.parse(i), s = /^.[\w]+_[\w]{5,}/;
|
1826
|
-
for (const
|
1827
|
-
if (
|
1826
|
+
for (const n of c.nodes)
|
1827
|
+
if (n.type === "rule") {
|
1828
1828
|
const d = {};
|
1829
|
-
s.test(
|
1830
|
-
|
1831
|
-
}), t[
|
1829
|
+
s.test(n.selector) ? (n.nodes.forEach((r) => {
|
1830
|
+
r.type === "decl" && (d[r.prop] = r.value);
|
1831
|
+
}), t[n.selector] = d) : a.push(n.toString());
|
1832
1832
|
} else
|
1833
|
-
a.push(
|
1833
|
+
a.push(n.toString());
|
1834
1834
|
} catch (i) {
|
1835
1835
|
u.push(`css解析出错了,错误信息:[ ${i.message} ]
|
1836
1836
|
`);
|
@@ -1846,7 +1846,7 @@ const Fu = "arrow-double-left, arrow-double-right, contact, notes, records, cash
|
|
1846
1846
|
", "
|
1847
1847
|
), Xe = "AddLocation, Aim, AlarmClock, Apple, ArrowDownBold, ArrowDown, ArrowLeftBold, ArrowLeft, ArrowRightBold, ArrowRight, ArrowUpBold, ArrowUp, Avatar, Back, Baseball, Basketball, BellFilled, Bell, Bicycle, BottomLeft, BottomRight, Bottom, Bowl, Box, Briefcase, BrushFilled, Brush, Burger, Calendar, CameraFilled, Camera, CaretBottom, CaretLeft, CaretRight, CaretTop, Cellphone, ChatDotRound, ChatDotSquare, ChatLineRound, ChatLineSquare, ChatRound, ChatSquare, Check, Checked, Cherry, Chicken, ChromeFilled, CircleCheckFilled, CircleCheck, CircleCloseFilled, CircleClose, CirclePlusFilled, CirclePlus, Clock, CloseBold, Close, Cloudy, CoffeeCup, Coffee, Coin, ColdDrink, CollectionTag, Collection, Comment, Compass, Connection, Coordinate, CopyDocument, Cpu, CreditCard, Crop, DArrowLeft, DArrowRight, DCaret, DataAnalysis, DataBoard, DataLine, DeleteFilled, DeleteLocation, Delete, Dessert, Discount, DishDot, Dish, DocumentAdd, DocumentChecked, DocumentCopy, DocumentDelete, DocumentRemove, Document, Download, Drizzling, EditPen, Edit, ElemeFilled, Eleme, ElementPlus, Expand, Failed, Female, Files, Film, Filter, Finished, FirstAidKit, Flag, Fold, FolderAdd, FolderChecked, FolderDelete, FolderOpened, FolderRemove, Folder, Food, Football, ForkSpoon, Fries, FullScreen, GobletFull, GobletSquareFull, GobletSquare, Goblet, GoldMedal, GoodsFilled, Goods, Grape, Grid, Guide, Handbag, Headset, HelpFilled, Help, Hide, Histogram, HomeFilled, HotWater, House, IceCreamRound, IceCreamSquare, IceCream, IceDrink, IceTea, InfoFilled, Iphone, Key, KnifeFork, Lightning, Link, List, Loading, LocationFilled, LocationInformation, Location, Lock, Lollipop, MagicStick, Magnet, Male, Management, MapLocation, Medal, Memo, Menu, MessageBox, Message, Mic, Microphone, MilkTea, Minus, Money, Monitor, MoonNight, Moon, MoreFilled, More, MostlyCloudy, Mouse, Mug, MuteNotification, Mute, NoSmoking, Notebook, Notification, Odometer, OfficeBuilding, Open, Operation, Opportunity, Orange, Paperclip, PartlyCloudy, Pear, PhoneFilled, Phone, PictureFilled, PictureRounded, Picture, PieChart, Place, Platform, Plus, Pointer, Position, Postcard, Pouring, Present, PriceTag, Printer, Promotion, QuartzWatch, QuestionFilled, Rank, ReadingLamp, Reading, RefreshLeft, RefreshRight, Refresh, Refrigerator, RemoveFilled, Remove, Right, ScaleToOriginal, School, Scissor, Search, Select, Sell, SemiSelect, Service, SetUp, Setting, Share, Ship, Shop, ShoppingBag, ShoppingCartFull, ShoppingCart, ShoppingTrolley, Smoking, Soccer, SoldOut, SortDown, SortUp, Sort, Stamp, StarFilled, Star, Stopwatch, SuccessFilled, Sugar, SuitcaseLine, Suitcase, Sunny, Sunrise, Sunset, SwitchButton, SwitchFilled, Switch, TakeawayBox, Ticket, Tickets, Timer, ToiletPaper, Tools, TopLeft, TopRight, Top, TrendCharts, TrophyBase, Trophy, TurnOff, Umbrella, Unlock, UploadFilled, Upload, UserFilled, User, Van, VideoCameraFilled, VideoCamera, VideoPause, VideoPlay, View, WalletFilled, Wallet, WarnTriangleFilled, WarningFilled, Warning, Watch, Watermelon, WindPower, ZoomIn, ZoomOut, VtjIconChatRecord, VtjIconNewChat, VtjIconAi, VtjIconUniapp, VtjIconWindowMax, VtjIconWindowMin, VtjIconWindowClose, VtjIconWindowNormal, VtjIconWindowDown, VtjIconWindowUp, VtjIconNpSave, VtjIconNpFile, VtjIconNpEdit, VtjIconNpShare, VtjIconNpSearch, VtjIconNpExport, VtjIconNpImport, VtjIconNpList, VtjIconNpPrint, VtjIconNpCancel, VtjIconNpConfirm, VtjIconNpReset, VtjIconNpReturnAll, VtjIconNpReturn, VtjIconNpRemove, VtjIconNpRemoveRow, VtjIconNpDelete, VtjIconNpExit, VtjIconNpRefresh, VtjIconNpAdd, VtjIconNpSelect, VtjIconNpAddRow, VtjIconNpExtend, VtjIconNpClose, VtjIconNpSubmit, VtjIconDeps, VtjIconBack, VtjIconHome, VtjIconApi, VtjIconExport, VtjIconImport, VtjIconGreater, VtjIconSmaller, VtjIconCheck, VtjIconSwitch, VtjIconCopy, VtjIconLock, VtjIconUnlock, VtjIconLayers, VtjIconConsole, VtjIconTeam, VtjIconPublish, VtjIconPreview, VtjIconSave, VtjIconPc, VtjIconPhone, VtjIconPad, VtjIconRedo, VtjIconRefresh, VtjIconUndo, VtjIconCategory, VtjIconProject, VtjIconNotice, VtjIconFav, VtjIconBug, VtjIconFile, VtjIconFolder, VtjIconUpload, VtjIconDownload, VtjIconUser, VtjIconSetting, VtjIconArrowRight, VtjIconArrowLeft, VtjIconArrowDown, VtjIconArrowUp, VtjIconShare, VtjIconData, VtjIconTemplate, VtjIconExitFullscreen, VtjIconFullscreen, VtjIconEdit, VtjIconRemove, VtjIconJs, VtjIconDatabase, VtjIconInfo, VtjIconPlus, VtjIconMinus, VtjIconHelp, VtjIconVars, VtjIconOutline, VtjIconVisible, VtjIconInvisible, VtjIconDocument, VtjIconHistory, VtjIconFixed, VtjIconUnfixed, VtjIconSearch, VtjIconMore, VtjIconClose, VtjIconComponents, VtjIconBlock".split(
|
1848
1848
|
", "
|
1849
|
-
), Qe = "user",
|
1849
|
+
), Qe = "user", j = "User";
|
1850
1850
|
class Ze {
|
1851
1851
|
validate(u) {
|
1852
1852
|
const t = {
|
@@ -1861,7 +1861,7 @@ class Ze {
|
|
1861
1861
|
}
|
1862
1862
|
isCompleteSFC(u) {
|
1863
1863
|
try {
|
1864
|
-
const t =
|
1864
|
+
const t = R(u);
|
1865
1865
|
return !!(t.template && t.script && t.styles);
|
1866
1866
|
} catch {
|
1867
1867
|
return !1;
|
@@ -1870,7 +1870,7 @@ class Ze {
|
|
1870
1870
|
checkSyntax(u) {
|
1871
1871
|
let t = "";
|
1872
1872
|
try {
|
1873
|
-
const a =
|
1873
|
+
const a = R(u);
|
1874
1874
|
z(a.script);
|
1875
1875
|
} catch (a) {
|
1876
1876
|
a instanceof SyntaxError && (t = a.message);
|
@@ -1878,7 +1878,7 @@ class Ze {
|
|
1878
1878
|
return t;
|
1879
1879
|
}
|
1880
1880
|
checkSetup(u) {
|
1881
|
-
const t =
|
1881
|
+
const t = R(u);
|
1882
1882
|
let a = 0;
|
1883
1883
|
return ku(t.script, {
|
1884
1884
|
ObjectMethod(i) {
|
@@ -1889,10 +1889,10 @@ class Ze {
|
|
1889
1889
|
}), a === 3;
|
1890
1890
|
}
|
1891
1891
|
findVantIcons(u) {
|
1892
|
-
const t =
|
1892
|
+
const t = R(u), a = /<(?:VanIcon|van-icon)\b[^>]*>/g, i = t.template.match(a) || [], c = [];
|
1893
1893
|
return i.forEach((s) => {
|
1894
|
-
const
|
1895
|
-
|
1894
|
+
const n = s.match(/\bname="([^"]+)"/);
|
1895
|
+
n && c.push(n[1]);
|
1896
1896
|
}), [...new Set(c)];
|
1897
1897
|
}
|
1898
1898
|
checkVantIcons(u) {
|
@@ -1902,7 +1902,7 @@ class Ze {
|
|
1902
1902
|
return a;
|
1903
1903
|
}
|
1904
1904
|
findVtjIcons(u) {
|
1905
|
-
const t =
|
1905
|
+
const t = R(u), a = /import\s*{([^}]+)}\s*from\s*['"]\@vtj\/icons['"]/, i = t.script.match(a);
|
1906
1906
|
return !i || !i[1] ? [] : i[1].split(",").map((c) => c.trim()).filter(Boolean);
|
1907
1907
|
}
|
1908
1908
|
checkVtjIcons(u) {
|
@@ -1926,7 +1926,7 @@ class Ze {
|
|
1926
1926
|
function Ke(e) {
|
1927
1927
|
const u = [];
|
1928
1928
|
let t = e;
|
1929
|
-
const a =
|
1929
|
+
const a = R(e);
|
1930
1930
|
if (!a.template || !a.script)
|
1931
1931
|
return {
|
1932
1932
|
fixed: !1,
|
@@ -1936,15 +1936,15 @@ function Ke(e) {
|
|
1936
1936
|
};
|
1937
1937
|
const i = Ye(a.script), c = a.template;
|
1938
1938
|
let s = c;
|
1939
|
-
const
|
1940
|
-
let
|
1941
|
-
for (; (
|
1942
|
-
const m =
|
1939
|
+
const n = [], d = /\{\{([^}]+)\}\}/g;
|
1940
|
+
let r;
|
1941
|
+
for (; (r = d.exec(c)) !== null; ) {
|
1942
|
+
const m = r[0], y = r[1], g = C(y, i);
|
1943
1943
|
if (g !== y) {
|
1944
|
-
const p = B(c,
|
1945
|
-
|
1946
|
-
start:
|
1947
|
-
end:
|
1944
|
+
const p = B(c, r.index);
|
1945
|
+
n.push({
|
1946
|
+
start: r.index,
|
1947
|
+
end: r.index + m.length,
|
1948
1948
|
original: m,
|
1949
1949
|
replacement: `{{${g}}}`,
|
1950
1950
|
line: p.line,
|
@@ -1959,13 +1959,13 @@ function Ke(e) {
|
|
1959
1959
|
}
|
1960
1960
|
}
|
1961
1961
|
const b = /:(\w+)="([^"]+)"/g;
|
1962
|
-
for (; (
|
1963
|
-
const m =
|
1962
|
+
for (; (r = b.exec(c)) !== null; ) {
|
1963
|
+
const m = r[0], y = r[1], g = r[2], p = C(g, i);
|
1964
1964
|
if (p !== g) {
|
1965
|
-
const E = B(c,
|
1966
|
-
|
1967
|
-
start:
|
1968
|
-
end:
|
1965
|
+
const E = B(c, r.index);
|
1966
|
+
n.push({
|
1967
|
+
start: r.index,
|
1968
|
+
end: r.index + m.length,
|
1969
1969
|
original: m,
|
1970
1970
|
replacement: `:${y}="${p}"`,
|
1971
1971
|
line: E.line,
|
@@ -1980,13 +1980,13 @@ function Ke(e) {
|
|
1980
1980
|
}
|
1981
1981
|
}
|
1982
1982
|
const f = /v-(if|else-if|show)="([^"]+)"/g;
|
1983
|
-
for (; (
|
1984
|
-
const m =
|
1983
|
+
for (; (r = f.exec(c)) !== null; ) {
|
1984
|
+
const m = r[0], y = r[1], g = r[2], p = C(g, i);
|
1985
1985
|
if (p !== g) {
|
1986
|
-
const E = B(c,
|
1987
|
-
|
1988
|
-
start:
|
1989
|
-
end:
|
1986
|
+
const E = B(c, r.index);
|
1987
|
+
n.push({
|
1988
|
+
start: r.index,
|
1989
|
+
end: r.index + m.length,
|
1990
1990
|
original: m,
|
1991
1991
|
replacement: `v-${y}="${p}"`,
|
1992
1992
|
line: E.line,
|
@@ -2001,18 +2001,18 @@ function Ke(e) {
|
|
2001
2001
|
}
|
2002
2002
|
}
|
2003
2003
|
const I = /v-for="([^"]+)"/g;
|
2004
|
-
for (; (
|
2005
|
-
const m =
|
2004
|
+
for (; (r = I.exec(c)) !== null; ) {
|
2005
|
+
const m = r[0], g = r[1].match(/^(.+)\s+in\s+(.+)$/);
|
2006
2006
|
if (g) {
|
2007
2007
|
const [, p, E] = g, q = C(
|
2008
2008
|
E,
|
2009
2009
|
i
|
2010
2010
|
);
|
2011
2011
|
if (q !== E) {
|
2012
|
-
const O = B(c,
|
2013
|
-
|
2014
|
-
start:
|
2015
|
-
end:
|
2012
|
+
const O = B(c, r.index), eu = `v-for="${p} in ${q}"`;
|
2013
|
+
n.push({
|
2014
|
+
start: r.index,
|
2015
|
+
end: r.index + m.length,
|
2016
2016
|
original: m,
|
2017
2017
|
replacement: eu,
|
2018
2018
|
line: O.line,
|
@@ -2028,13 +2028,13 @@ function Ke(e) {
|
|
2028
2028
|
}
|
2029
2029
|
}
|
2030
2030
|
const x = /v-model="([^"]+)"/g;
|
2031
|
-
for (; (
|
2032
|
-
const m =
|
2031
|
+
for (; (r = x.exec(c)) !== null; ) {
|
2032
|
+
const m = r[0], y = r[1], g = C(y, i);
|
2033
2033
|
if (g !== y) {
|
2034
|
-
const p = B(c,
|
2035
|
-
|
2036
|
-
start:
|
2037
|
-
end:
|
2034
|
+
const p = B(c, r.index);
|
2035
|
+
n.push({
|
2036
|
+
start: r.index,
|
2037
|
+
end: r.index + m.length,
|
2038
2038
|
original: m,
|
2039
2039
|
replacement: `v-model="${g}"`,
|
2040
2040
|
line: p.line,
|
@@ -2049,13 +2049,13 @@ function Ke(e) {
|
|
2049
2049
|
}
|
2050
2050
|
}
|
2051
2051
|
const N = /v-bind="([^"]+)"/g;
|
2052
|
-
for (; (
|
2053
|
-
const m =
|
2052
|
+
for (; (r = N.exec(c)) !== null; ) {
|
2053
|
+
const m = r[0], y = r[1], g = C(y, i);
|
2054
2054
|
if (g !== y) {
|
2055
|
-
const p = B(c,
|
2056
|
-
|
2057
|
-
start:
|
2058
|
-
end:
|
2055
|
+
const p = B(c, r.index);
|
2056
|
+
n.push({
|
2057
|
+
start: r.index,
|
2058
|
+
end: r.index + m.length,
|
2059
2059
|
original: m,
|
2060
2060
|
replacement: `v-bind="${g}"`,
|
2061
2061
|
line: p.line,
|
@@ -2070,13 +2070,13 @@ function Ke(e) {
|
|
2070
2070
|
}
|
2071
2071
|
}
|
2072
2072
|
const V = /v-(text|html)="([^"]+)"/g;
|
2073
|
-
for (; (
|
2074
|
-
const m =
|
2073
|
+
for (; (r = V.exec(c)) !== null; ) {
|
2074
|
+
const m = r[0], y = r[1], g = r[2], p = C(g, i);
|
2075
2075
|
if (p !== g) {
|
2076
|
-
const E = B(c,
|
2077
|
-
|
2078
|
-
start:
|
2079
|
-
end:
|
2076
|
+
const E = B(c, r.index);
|
2077
|
+
n.push({
|
2078
|
+
start: r.index,
|
2079
|
+
end: r.index + m.length,
|
2080
2080
|
original: m,
|
2081
2081
|
replacement: `v-${y}="${p}"`,
|
2082
2082
|
line: E.line,
|
@@ -2091,13 +2091,13 @@ function Ke(e) {
|
|
2091
2091
|
}
|
2092
2092
|
}
|
2093
2093
|
const uu = /(@|v-on:)(\w+)="([^"]+)"/g;
|
2094
|
-
for (; (
|
2095
|
-
const m =
|
2094
|
+
for (; (r = uu.exec(c)) !== null; ) {
|
2095
|
+
const m = r[0], y = r[1], g = r[2], p = r[3], E = u0(p, i);
|
2096
2096
|
if (E !== p) {
|
2097
|
-
const q = B(c,
|
2098
|
-
|
2099
|
-
start:
|
2100
|
-
end:
|
2097
|
+
const q = B(c, r.index);
|
2098
|
+
n.push({
|
2099
|
+
start: r.index,
|
2100
|
+
end: r.index + m.length,
|
2101
2101
|
original: m,
|
2102
2102
|
replacement: `${y}${g}="${E}"`,
|
2103
2103
|
line: q.line,
|
@@ -2111,16 +2111,16 @@ function Ke(e) {
|
|
2111
2111
|
});
|
2112
2112
|
}
|
2113
2113
|
}
|
2114
|
-
if (
|
2114
|
+
if (n.sort((m, y) => y.start - m.start), n.forEach((m) => {
|
2115
2115
|
s = s.substring(0, m.start) + m.replacement + s.substring(m.end);
|
2116
|
-
}),
|
2116
|
+
}), n.length > 0) {
|
2117
2117
|
const m = e.indexOf("<template>"), y = e.lastIndexOf("</template>") + 11;
|
2118
2118
|
t = e.substring(0, m) + `<template>
|
2119
2119
|
` + s + `
|
2120
2120
|
</template>` + e.substring(y);
|
2121
2121
|
}
|
2122
2122
|
return {
|
2123
|
-
fixed:
|
2123
|
+
fixed: n.length > 0,
|
2124
2124
|
originalCode: e,
|
2125
2125
|
fixedCode: t,
|
2126
2126
|
changes: u
|
@@ -2162,7 +2162,7 @@ function u0(e, u) {
|
|
2162
2162
|
`(\\+\\+|--)?(?<![\\w.])${a}(?![\\w])`,
|
2163
2163
|
"g"
|
2164
2164
|
);
|
2165
|
-
t.includes(`state.${a}`) || (t = t.replace(i, `state.${a}$1`), t = t.replace(c, (s,
|
2165
|
+
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));
|
2166
2166
|
}), C(t, u);
|
2167
2167
|
}
|
2168
2168
|
function B(e, u) {
|
@@ -2179,45 +2179,45 @@ class e0 {
|
|
2179
2179
|
return t.illegalVantIcons.length && (a = this.fixVantIcons(a)), t.illegalVtjIcons.length && (a = this.fixVtjIcons(a, t.illegalVtjIcons)), Ke(a).fixedCode;
|
2180
2180
|
}
|
2181
2181
|
fixVantIcons(u) {
|
2182
|
-
const t =
|
2182
|
+
const t = R(u), a = t.template.replace(
|
2183
2183
|
/<(?:VanIcon|van-icon)\s+[^>]*name="([^"]+)"[^>]*>/g,
|
2184
2184
|
(i, c) => Fu.includes(c) ? i : i.replace(c, Qe)
|
2185
2185
|
);
|
2186
2186
|
return this.reconstructSFC(t, a, t.script);
|
2187
2187
|
}
|
2188
2188
|
fixVtjIcons(u, t = []) {
|
2189
|
-
const a =
|
2189
|
+
const a = R(u);
|
2190
2190
|
a.script = ku(a.script, {
|
2191
|
-
ImportDeclaration(
|
2192
|
-
if (
|
2193
|
-
const
|
2191
|
+
ImportDeclaration(s) {
|
2192
|
+
if (s.node.source.value === "@vtj/icons") {
|
2193
|
+
const n = s.node.specifiers, d = [];
|
2194
2194
|
let r = !1;
|
2195
|
-
for (const
|
2196
|
-
const
|
2197
|
-
|
2198
|
-
T.importSpecifier(
|
2195
|
+
for (const b of n) {
|
2196
|
+
const f = b.imported?.name;
|
2197
|
+
f === j && (r = !0), t.includes(f) || d.push(
|
2198
|
+
T.importSpecifier(b.local, b.imported)
|
2199
2199
|
);
|
2200
2200
|
}
|
2201
|
-
r ||
|
2201
|
+
r || d.push(
|
2202
2202
|
T.importSpecifier(
|
2203
|
-
T.identifier(
|
2204
|
-
T.identifier(
|
2203
|
+
T.identifier(j),
|
2204
|
+
T.identifier(j)
|
2205
2205
|
)
|
2206
|
-
),
|
2206
|
+
), s.node.specifiers = d;
|
2207
2207
|
}
|
2208
2208
|
},
|
2209
|
-
ObjectMethod(
|
2210
|
-
if (
|
2211
|
-
const
|
2212
|
-
for (const
|
2213
|
-
if (T.isReturnStatement(
|
2214
|
-
const r =
|
2215
|
-
|
2216
|
-
(
|
2217
|
-
),
|
2209
|
+
ObjectMethod(s) {
|
2210
|
+
if (s.node.key.name === "setup") {
|
2211
|
+
const n = s.node.body.body;
|
2212
|
+
for (const d of n)
|
2213
|
+
if (T.isReturnStatement(d) && T.isObjectExpression(d.argument)) {
|
2214
|
+
const r = d.argument.properties || [];
|
2215
|
+
d.argument.properties = r.filter(
|
2216
|
+
(b) => !t.includes(b.key.name)
|
2217
|
+
), d.argument.properties.push(
|
2218
2218
|
T.objectProperty(
|
2219
|
-
T.identifier(
|
2220
|
-
T.identifier(
|
2219
|
+
T.identifier(j),
|
2220
|
+
T.identifier(j),
|
2221
2221
|
!1,
|
2222
2222
|
!0
|
2223
2223
|
)
|
@@ -2225,20 +2225,28 @@ class e0 {
|
|
2225
2225
|
}
|
2226
2226
|
}
|
2227
2227
|
},
|
2228
|
-
ObjectProperty(
|
2229
|
-
if (T.isIdentifier(
|
2230
|
-
const
|
2231
|
-
|
2228
|
+
ObjectProperty(s) {
|
2229
|
+
if (T.isIdentifier(s.node.value) && t.includes(s.node.value.name) && (s.node.value = T.identifier(j)), T.isArrayExpression(s.node.value)) {
|
2230
|
+
const n = s.node.value.elements;
|
2231
|
+
s.node.value.elements = n.map((d) => T.isIdentifier(d) && t.includes(d.name) ? T.identifier(j) : d);
|
2232
2232
|
}
|
2233
2233
|
},
|
2234
|
-
AssignmentExpression(
|
2235
|
-
T.isIdentifier(
|
2234
|
+
AssignmentExpression(s) {
|
2235
|
+
T.isIdentifier(s.node.right) && t.includes(s.node.right.name) && (s.node.right = T.identifier(j));
|
2236
2236
|
}
|
2237
2237
|
});
|
2238
|
-
|
2238
|
+
const i = /:icon\s*=\s*["']([^"']+)["']/g, c = a.template.match(i);
|
2239
|
+
if (c)
|
2240
|
+
for (const s of c) {
|
2241
|
+
let n = s;
|
2242
|
+
for (const d of t)
|
2243
|
+
n = n.replace(new RegExp(d, "g"), j);
|
2244
|
+
a.template = a.template.replace(s, n);
|
2245
|
+
}
|
2246
|
+
for (const s of t)
|
2239
2247
|
a.template = a.template.replace(
|
2240
|
-
new RegExp(`:icon="${
|
2241
|
-
`:icon="${
|
2248
|
+
new RegExp(`:icon="${s}"`, "g"),
|
2249
|
+
`:icon="${j}"`
|
2242
2250
|
);
|
2243
2251
|
return this.reconstructSFC(a, a.template, a.script);
|
2244
2252
|
}
|
@@ -2262,11 +2270,11 @@ ${a}
|
|
2262
2270
|
}
|
2263
2271
|
}
|
2264
2272
|
async function x0(e) {
|
2265
|
-
const { id: u, name: t, source: a, project: i } = e, { dependencies: c = [], platform: s = "web" } = i || {},
|
2273
|
+
const { id: u, name: t, source: a, project: i } = e, { dependencies: c = [], platform: s = "web" } = i || {}, n = new Ze(), d = new e0(), r = n.validate(a);
|
2266
2274
|
let b = [];
|
2267
|
-
if (!
|
2268
|
-
return b =
|
2269
|
-
const f = d.fixBasedOnValidation(a,
|
2275
|
+
if (!r.valid)
|
2276
|
+
return b = r.errors, Promise.reject(b);
|
2277
|
+
const f = d.fixBasedOnValidation(a, r), I = R(f), {
|
2270
2278
|
styles: x,
|
2271
2279
|
css: N,
|
2272
2280
|
errors: V
|
@@ -2364,9 +2372,9 @@ async function t0(e, u, t) {
|
|
2364
2372
|
}, {
|
2365
2373
|
state: c,
|
2366
2374
|
watch: s,
|
2367
|
-
computed:
|
2375
|
+
computed: n,
|
2368
2376
|
props: d,
|
2369
|
-
dataSources:
|
2377
|
+
dataSources: r,
|
2370
2378
|
methods: b,
|
2371
2379
|
lifeCycles: f,
|
2372
2380
|
inject: I
|
@@ -2374,9 +2382,9 @@ async function t0(e, u, t) {
|
|
2374
2382
|
if (await i({
|
2375
2383
|
state: c,
|
2376
2384
|
watch: s,
|
2377
|
-
computed:
|
2385
|
+
computed: n,
|
2378
2386
|
props: d,
|
2379
|
-
dataSources:
|
2387
|
+
dataSources: r,
|
2380
2388
|
methods: b,
|
2381
2389
|
lifeCycles: f,
|
2382
2390
|
inject: I
|
@@ -2410,8 +2418,8 @@ function i0(e = [], u = []) {
|
|
2410
2418
|
for (const { from: i, imports: c } of e)
|
2411
2419
|
if (Array.isArray(c))
|
2412
2420
|
c.forEach((s) => {
|
2413
|
-
const
|
2414
|
-
|
2421
|
+
const n = a[i];
|
2422
|
+
n && (t[s] = n);
|
2415
2423
|
});
|
2416
2424
|
else {
|
2417
2425
|
const s = a[i];
|