@vtj/parser 0.16.26 → 0.16.28
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 +13 -13
- package/dist/index.mjs +212 -193
- package/package.json +3 -3
- package/types/version.d.ts +2 -2
- package/types/vue/replacer.d.ts +12 -0
package/dist/index.mjs
CHANGED
|
@@ -13,10 +13,10 @@ import * as V from "@babel/types";
|
|
|
13
13
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
14
14
|
* @name @vtj/parser
|
|
15
15
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
16
|
-
* @version 0.16.
|
|
16
|
+
* @version 0.16.28
|
|
17
17
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
18
18
|
*/
|
|
19
|
-
const T0 = "0.16.
|
|
19
|
+
const T0 = "0.16.28";
|
|
20
20
|
function D(e) {
|
|
21
21
|
const { descriptor: u, errors: t } = Vu(e), a = u.template?.content || "", i = (u.scriptSetup || u.script)?.content || "", s = u.styles.map((r) => r.content);
|
|
22
22
|
return {
|
|
@@ -71,9 +71,9 @@ function oe(e, u) {
|
|
|
71
71
|
try {
|
|
72
72
|
const { descriptor: a, errors: i } = Vu(e);
|
|
73
73
|
if (i && i.length > 0 && i.forEach((r) => {
|
|
74
|
-
const n = r.message || String(r),
|
|
75
|
-
|
|
76
|
-
`Vue SFC 错误: ${n} (位置: ${
|
|
74
|
+
const n = r.message || String(r), o = r.loc;
|
|
75
|
+
o && o.start ? t.push(
|
|
76
|
+
`Vue SFC 错误: ${n} (位置: ${o.start.line}:${o.start.column})`
|
|
77
77
|
) : t.push(`Vue SFC 错误: ${n}`);
|
|
78
78
|
}), a.template)
|
|
79
79
|
try {
|
|
@@ -84,10 +84,10 @@ function oe(e, u) {
|
|
|
84
84
|
isProd: !1
|
|
85
85
|
});
|
|
86
86
|
r.errors && r.errors.length > 0 && r.errors.forEach((n) => {
|
|
87
|
-
const
|
|
87
|
+
const o = typeof n == "string" ? n : n.message, c = typeof n == "string" ? null : n.loc;
|
|
88
88
|
c && c.start ? t.push(
|
|
89
|
-
`模板编译错误: ${
|
|
90
|
-
) : t.push(`模板编译错误: ${
|
|
89
|
+
`模板编译错误: ${o} (位置: ${c.start.line}:${c.start.column})`
|
|
90
|
+
) : t.push(`模板编译错误: ${o}`);
|
|
91
91
|
});
|
|
92
92
|
} catch (r) {
|
|
93
93
|
t.push(`模板编译错误: ${r.message}`);
|
|
@@ -125,12 +125,12 @@ function de(e, u, t, a) {
|
|
|
125
125
|
const s = e.slice(u + t.length);
|
|
126
126
|
if (s.trim().startsWith("=>"))
|
|
127
127
|
return !0;
|
|
128
|
-
const n = a.endsWith("(") || a.match(/\(\s*$/),
|
|
129
|
-
if (n ||
|
|
128
|
+
const n = a.endsWith("(") || a.match(/\(\s*$/), o = a.endsWith(",") || a.match(/,\s*$/);
|
|
129
|
+
if (n || o) {
|
|
130
130
|
let l = -1, m = "";
|
|
131
131
|
if (n)
|
|
132
132
|
l = a.length - 1;
|
|
133
|
-
else if (
|
|
133
|
+
else if (o) {
|
|
134
134
|
let y = 0, b = !1, S = "";
|
|
135
135
|
for (let I = a.length - 1; I >= 0; I--) {
|
|
136
136
|
const g = a[I];
|
|
@@ -153,6 +153,8 @@ function de(e, u, t, a) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
+
if (o && l < 0)
|
|
157
|
+
return !1;
|
|
156
158
|
if (l >= 0) {
|
|
157
159
|
let y = l - 1;
|
|
158
160
|
for (; y >= 0 && /\s/.test(a.charAt(y)); )
|
|
@@ -200,6 +202,23 @@ function gu(e, u, t) {
|
|
|
200
202
|
if (a < 0) return !1;
|
|
201
203
|
const i = e[a];
|
|
202
204
|
if (i !== "{" && i !== "," || i === "{" && a > 0 && e[a - 1] === "$") return !1;
|
|
205
|
+
if (i === ",") {
|
|
206
|
+
let n = 0, o = a - 1;
|
|
207
|
+
for (; o >= 0; ) {
|
|
208
|
+
const c = e[o];
|
|
209
|
+
if (c === "}") n++;
|
|
210
|
+
else if (c === "{") {
|
|
211
|
+
if (n === 0) break;
|
|
212
|
+
n--;
|
|
213
|
+
} else if (c === "]" || c === ")")
|
|
214
|
+
n++;
|
|
215
|
+
else if (c === "[" || c === "(") {
|
|
216
|
+
if (n === 0) return !1;
|
|
217
|
+
n--;
|
|
218
|
+
}
|
|
219
|
+
o--;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
203
222
|
let s = u + t.length;
|
|
204
223
|
for (; s < e.length && /\s/.test(e[s]); ) s++;
|
|
205
224
|
if (s >= e.length) return !1;
|
|
@@ -220,13 +239,13 @@ function B(e, u, t) {
|
|
|
220
239
|
// 正则表达式括号深度(用于处理字符类)
|
|
221
240
|
}, r = /[a-zA-Z0-9_$@-]/;
|
|
222
241
|
function n(c) {
|
|
223
|
-
for (let
|
|
224
|
-
const l = c[
|
|
242
|
+
for (let d = 0; d < c.length; d++) {
|
|
243
|
+
const l = c[d];
|
|
225
244
|
if (!s.inString && !s.inRegex) {
|
|
226
245
|
if (l === "'" || l === '"' || l === "`")
|
|
227
246
|
s.inString = !0, s.quoteChar = l;
|
|
228
247
|
else if (l === "/") {
|
|
229
|
-
let m =
|
|
248
|
+
let m = d - 1;
|
|
230
249
|
for (; m >= 0 && /\s/.test(c[m]); )
|
|
231
250
|
m--;
|
|
232
251
|
if (m < 0)
|
|
@@ -275,10 +294,10 @@ function B(e, u, t) {
|
|
|
275
294
|
s.inRegex = !0, s.regexDepth = 0;
|
|
276
295
|
}
|
|
277
296
|
}
|
|
278
|
-
} else s.inString ? l === s.quoteChar ? s.quoteChar === "`" && s.inTemplateExpr > 0 || (s.inString = !1, s.quoteChar = "", s.inTemplateExpr = 0) : s.quoteChar === "`" && (l === "$" &&
|
|
297
|
+
} else s.inString ? l === s.quoteChar ? s.quoteChar === "`" && s.inTemplateExpr > 0 || (s.inString = !1, s.quoteChar = "", s.inTemplateExpr = 0) : s.quoteChar === "`" && (l === "$" && d + 1 < c.length && c[d + 1] === "{" ? (s.inTemplateExpr++, d++) : l === "}" && s.inTemplateExpr > 0 && s.inTemplateExpr--) : s.inRegex && (l === "[" ? s.regexDepth++ : l === "]" && s.regexDepth > 0 ? s.regexDepth-- : l === "/" && s.regexDepth === 0 && (d === 0 || c[d - 1] !== "\\") && (s.inRegex = !1, s.regexDepth = 0));
|
|
279
298
|
}
|
|
280
299
|
}
|
|
281
|
-
function
|
|
300
|
+
function o(c) {
|
|
282
301
|
if (s.inRegex || s.inString && s.inTemplateExpr === 0 && !e.slice(0, c).match(/new\s+RegExp\s*\([^)]*$/))
|
|
283
302
|
return !1;
|
|
284
303
|
if (c >= 3 && e.slice(c - 3, c) === "..." && (c >= 4 ? e.charAt(c - 4) : "") !== ".")
|
|
@@ -290,8 +309,8 @@ function B(e, u, t) {
|
|
|
290
309
|
}
|
|
291
310
|
return !1;
|
|
292
311
|
}
|
|
293
|
-
const
|
|
294
|
-
if (r.test(
|
|
312
|
+
const d = c > 0 ? e.charAt(c - 1) : "", l = c + u.length < e.length ? e.charAt(c + u.length) : "";
|
|
313
|
+
if (r.test(d) || r.test(l))
|
|
295
314
|
return !1;
|
|
296
315
|
const m = e.slice(0, c);
|
|
297
316
|
return m.match(/(const|let|var|function)\s+$/) ? !1 : m.match(/\{\s*$/) && !/\$\{\s*$/.test(m) ? !!(c > 0 && e.charAt(c - 1) === "[" || gu(e, c, u)) : de(
|
|
@@ -304,8 +323,8 @@ function B(e, u, t) {
|
|
|
304
323
|
for (; i < e.length; ) {
|
|
305
324
|
const c = e.indexOf(u, i);
|
|
306
325
|
if (c === -1) break;
|
|
307
|
-
const
|
|
308
|
-
a.push(
|
|
326
|
+
const d = e.slice(i, c);
|
|
327
|
+
a.push(d), n(d), i = c, o(i) ? gu(e, i, u) ? a.push(u + ": " + t) : a.push(t) : a.push(u), i += u.length;
|
|
309
328
|
}
|
|
310
329
|
return i < e.length && a.push(e.slice(i)), a.join("");
|
|
311
330
|
}
|
|
@@ -316,22 +335,22 @@ function yu(e, u, t) {
|
|
|
316
335
|
libs: s = {},
|
|
317
336
|
members: r = [],
|
|
318
337
|
props: n = [],
|
|
319
|
-
platform:
|
|
338
|
+
platform: o
|
|
320
339
|
} = t || {}, c = Array.from(a[u || ""] || /* @__PURE__ */ new Set());
|
|
321
340
|
if (c)
|
|
322
|
-
for (const
|
|
323
|
-
e = B(e,
|
|
324
|
-
for (const
|
|
325
|
-
e = B(e,
|
|
326
|
-
for (const
|
|
327
|
-
e = B(e,
|
|
328
|
-
for (const [
|
|
329
|
-
e = B(e,
|
|
330
|
-
for (const
|
|
331
|
-
e = B(e,
|
|
332
|
-
if (
|
|
333
|
-
const
|
|
334
|
-
e = e.replace(
|
|
341
|
+
for (const d of c)
|
|
342
|
+
e = B(e, d, `this.context.${d}`);
|
|
343
|
+
for (const d of i)
|
|
344
|
+
e = B(e, d, `this.${d}.value`), e = B(e, `this.${d}`, `this.${d}.value`), e = B(e, `this.${d}.value.value`, `this.${d}.value`);
|
|
345
|
+
for (const d of n)
|
|
346
|
+
e = B(e, d, `this.props.${d}`), e = B(e, `this.${d}`, `this.props.${d}`);
|
|
347
|
+
for (const [d, l] of Object.entries(s))
|
|
348
|
+
e = B(e, d, `this.$libs.${l}.${d}`), e = B(e, `this.${d}`, `this.$libs.${l}.${d}`);
|
|
349
|
+
for (const d of r)
|
|
350
|
+
e = B(e, d, `this.${d}`);
|
|
351
|
+
if (o === "uniapp") {
|
|
352
|
+
const d = /\suni\./g;
|
|
353
|
+
e = e.replace(d, "this.$libs.UniH5.uni.");
|
|
335
354
|
}
|
|
336
355
|
return e = e.replace(/_ctx\./g, "this."), e = e.replace(/this\.this\./g, "this."), e;
|
|
337
356
|
}
|
|
@@ -663,18 +682,18 @@ function Ne(e, u, t, a) {
|
|
|
663
682
|
if (i === 0)
|
|
664
683
|
return s !== 0 && a === s ? t : -1;
|
|
665
684
|
if (s) {
|
|
666
|
-
const
|
|
667
|
-
return
|
|
685
|
+
const o = a - s;
|
|
686
|
+
return o < 0 || o >= i ? -1 : e[t + o] - 1;
|
|
668
687
|
}
|
|
669
688
|
let r = t, n = r + i - 1;
|
|
670
689
|
for (; r <= n; ) {
|
|
671
|
-
const
|
|
690
|
+
const o = r + n >>> 1, c = e[o];
|
|
672
691
|
if (c < a)
|
|
673
|
-
r =
|
|
692
|
+
r = o + 1;
|
|
674
693
|
else if (c > a)
|
|
675
|
-
n =
|
|
694
|
+
n = o - 1;
|
|
676
695
|
else
|
|
677
|
-
return e[
|
|
696
|
+
return e[o + i];
|
|
678
697
|
}
|
|
679
698
|
return -1;
|
|
680
699
|
}
|
|
@@ -682,10 +701,10 @@ var h;
|
|
|
682
701
|
(function(e) {
|
|
683
702
|
e[e.Tab = 9] = "Tab", e[e.NewLine = 10] = "NewLine", e[e.FormFeed = 12] = "FormFeed", e[e.CarriageReturn = 13] = "CarriageReturn", e[e.Space = 32] = "Space", e[e.ExclamationMark = 33] = "ExclamationMark", e[e.Number = 35] = "Number", e[e.Amp = 38] = "Amp", e[e.SingleQuote = 39] = "SingleQuote", e[e.DoubleQuote = 34] = "DoubleQuote", e[e.Dash = 45] = "Dash", e[e.Slash = 47] = "Slash", e[e.Zero = 48] = "Zero", e[e.Nine = 57] = "Nine", e[e.Semi = 59] = "Semi", e[e.Lt = 60] = "Lt", e[e.Eq = 61] = "Eq", e[e.Gt = 62] = "Gt", e[e.Questionmark = 63] = "Questionmark", e[e.UpperA = 65] = "UpperA", e[e.LowerA = 97] = "LowerA", e[e.UpperF = 70] = "UpperF", e[e.LowerF = 102] = "LowerF", e[e.UpperZ = 90] = "UpperZ", e[e.LowerZ = 122] = "LowerZ", e[e.LowerX = 120] = "LowerX", e[e.OpeningSquareBracket = 91] = "OpeningSquareBracket";
|
|
684
703
|
})(h || (h = {}));
|
|
685
|
-
var
|
|
704
|
+
var f;
|
|
686
705
|
(function(e) {
|
|
687
706
|
e[e.Text = 1] = "Text", e[e.BeforeTagName = 2] = "BeforeTagName", e[e.InTagName = 3] = "InTagName", e[e.InSelfClosingTag = 4] = "InSelfClosingTag", e[e.BeforeClosingTagName = 5] = "BeforeClosingTagName", e[e.InClosingTagName = 6] = "InClosingTagName", e[e.AfterClosingTagName = 7] = "AfterClosingTagName", e[e.BeforeAttributeName = 8] = "BeforeAttributeName", e[e.InAttributeName = 9] = "InAttributeName", e[e.AfterAttributeName = 10] = "AfterAttributeName", e[e.BeforeAttributeValue = 11] = "BeforeAttributeValue", e[e.InAttributeValueDq = 12] = "InAttributeValueDq", e[e.InAttributeValueSq = 13] = "InAttributeValueSq", e[e.InAttributeValueNq = 14] = "InAttributeValueNq", e[e.BeforeDeclaration = 15] = "BeforeDeclaration", e[e.InDeclaration = 16] = "InDeclaration", e[e.InProcessingInstruction = 17] = "InProcessingInstruction", e[e.BeforeComment = 18] = "BeforeComment", e[e.CDATASequence = 19] = "CDATASequence", e[e.InSpecialComment = 20] = "InSpecialComment", e[e.InCommentLike = 21] = "InCommentLike", e[e.BeforeSpecialS = 22] = "BeforeSpecialS", e[e.BeforeSpecialT = 23] = "BeforeSpecialT", e[e.SpecialStartSequence = 24] = "SpecialStartSequence", e[e.InSpecialTag = 25] = "InSpecialTag", e[e.InEntity = 26] = "InEntity";
|
|
688
|
-
})(
|
|
707
|
+
})(f || (f = {}));
|
|
689
708
|
function F(e) {
|
|
690
709
|
return e === h.Space || e === h.NewLine || e === h.Tab || e === h.FormFeed || e === h.CarriageReturn;
|
|
691
710
|
}
|
|
@@ -730,10 +749,10 @@ const T = {
|
|
|
730
749
|
};
|
|
731
750
|
class Ve {
|
|
732
751
|
constructor({ xmlMode: u = !1, decodeEntities: t = !0 }, a) {
|
|
733
|
-
this.cbs = a, this.state =
|
|
752
|
+
this.cbs = a, this.state = f.Text, this.buffer = "", this.sectionStart = 0, this.index = 0, this.entityStart = 0, this.baseState = f.Text, this.isSpecial = !1, this.running = !0, this.offset = 0, this.currentSequence = void 0, this.sequenceIndex = 0, this.xmlMode = u, this.decodeEntities = t, this.entityDecoder = new Te(u ? ye : ge, (i, s) => this.emitCodePoint(i, s));
|
|
734
753
|
}
|
|
735
754
|
reset() {
|
|
736
|
-
this.state =
|
|
755
|
+
this.state = f.Text, this.buffer = "", this.sectionStart = 0, this.index = 0, this.baseState = f.Text, this.currentSequence = void 0, this.running = !0, this.offset = 0;
|
|
737
756
|
}
|
|
738
757
|
write(u) {
|
|
739
758
|
this.offset += this.buffer.length, this.buffer = u, this.parse();
|
|
@@ -748,7 +767,7 @@ class Ve {
|
|
|
748
767
|
this.running = !0, this.index < this.buffer.length + this.offset && this.parse();
|
|
749
768
|
}
|
|
750
769
|
stateText(u) {
|
|
751
|
-
u === h.Lt || !this.decodeEntities && this.fastForwardTo(h.Lt) ? (this.index > this.sectionStart && this.cbs.ontext(this.sectionStart, this.index), this.state =
|
|
770
|
+
u === h.Lt || !this.decodeEntities && this.fastForwardTo(h.Lt) ? (this.index > this.sectionStart && this.cbs.ontext(this.sectionStart, this.index), this.state = f.BeforeTagName, this.sectionStart = this.index) : this.decodeEntities && u === h.Amp && this.startEntity();
|
|
752
771
|
}
|
|
753
772
|
stateSpecialStartSequence(u) {
|
|
754
773
|
const t = this.sequenceIndex === this.currentSequence.length;
|
|
@@ -764,7 +783,7 @@ class Ve {
|
|
|
764
783
|
this.sequenceIndex++;
|
|
765
784
|
return;
|
|
766
785
|
}
|
|
767
|
-
this.sequenceIndex = 0, this.state =
|
|
786
|
+
this.sequenceIndex = 0, this.state = f.InTagName, this.stateInTagName(u);
|
|
768
787
|
}
|
|
769
788
|
/** Look for an end tag. For <title> tags, also decode entities. */
|
|
770
789
|
stateInSpecialTag(u) {
|
|
@@ -783,7 +802,7 @@ class Ve {
|
|
|
783
802
|
(u | 32) === this.currentSequence[this.sequenceIndex] ? this.sequenceIndex += 1 : this.sequenceIndex === 0 ? this.currentSequence === T.TitleEnd ? this.decodeEntities && u === h.Amp && this.startEntity() : this.fastForwardTo(h.Lt) && (this.sequenceIndex = 1) : this.sequenceIndex = +(u === h.Lt);
|
|
784
803
|
}
|
|
785
804
|
stateCDATASequence(u) {
|
|
786
|
-
u === T.Cdata[this.sequenceIndex] ? ++this.sequenceIndex === T.Cdata.length && (this.state =
|
|
805
|
+
u === T.Cdata[this.sequenceIndex] ? ++this.sequenceIndex === T.Cdata.length && (this.state = f.InCommentLike, this.currentSequence = T.CdataEnd, this.sequenceIndex = 0, this.sectionStart = this.index + 1) : (this.sequenceIndex = 0, this.state = f.InDeclaration, this.stateInDeclaration(u));
|
|
787
806
|
}
|
|
788
807
|
/**
|
|
789
808
|
* When we wait for one specific character, we can speed things up
|
|
@@ -806,7 +825,7 @@ class Ve {
|
|
|
806
825
|
* - All characters but the start character of the sequence can be skipped.
|
|
807
826
|
*/
|
|
808
827
|
stateInCommentLike(u) {
|
|
809
|
-
u === this.currentSequence[this.sequenceIndex] ? ++this.sequenceIndex === this.currentSequence.length && (this.currentSequence === T.CdataEnd ? this.cbs.oncdata(this.sectionStart, this.index, 2) : this.cbs.oncomment(this.sectionStart, this.index, 2), this.sequenceIndex = 0, this.sectionStart = this.index + 1, this.state =
|
|
828
|
+
u === this.currentSequence[this.sequenceIndex] ? ++this.sequenceIndex === this.currentSequence.length && (this.currentSequence === T.CdataEnd ? this.cbs.oncdata(this.sectionStart, this.index, 2) : this.cbs.oncomment(this.sectionStart, this.index, 2), this.sequenceIndex = 0, this.sectionStart = this.index + 1, this.state = f.Text) : this.sequenceIndex === 0 ? this.fastForwardTo(this.currentSequence[0]) && (this.sequenceIndex = 1) : u !== this.currentSequence[this.sequenceIndex - 1] && (this.sequenceIndex = 0);
|
|
810
829
|
}
|
|
811
830
|
/**
|
|
812
831
|
* HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
|
|
@@ -818,47 +837,47 @@ class Ve {
|
|
|
818
837
|
return this.xmlMode ? !Q(u) : ke(u);
|
|
819
838
|
}
|
|
820
839
|
startSpecial(u, t) {
|
|
821
|
-
this.isSpecial = !0, this.currentSequence = u, this.sequenceIndex = t, this.state =
|
|
840
|
+
this.isSpecial = !0, this.currentSequence = u, this.sequenceIndex = t, this.state = f.SpecialStartSequence;
|
|
822
841
|
}
|
|
823
842
|
stateBeforeTagName(u) {
|
|
824
843
|
if (u === h.ExclamationMark)
|
|
825
|
-
this.state =
|
|
844
|
+
this.state = f.BeforeDeclaration, this.sectionStart = this.index + 1;
|
|
826
845
|
else if (u === h.Questionmark)
|
|
827
|
-
this.state =
|
|
846
|
+
this.state = f.InProcessingInstruction, this.sectionStart = this.index + 1;
|
|
828
847
|
else if (this.isTagStartChar(u)) {
|
|
829
848
|
const t = u | 32;
|
|
830
|
-
this.sectionStart = this.index, this.xmlMode ? this.state =
|
|
831
|
-
} else u === h.Slash ? this.state =
|
|
849
|
+
this.sectionStart = this.index, this.xmlMode ? this.state = f.InTagName : t === T.ScriptEnd[2] ? this.state = f.BeforeSpecialS : t === T.TitleEnd[2] || t === T.XmpEnd[2] ? this.state = f.BeforeSpecialT : this.state = f.InTagName;
|
|
850
|
+
} else u === h.Slash ? this.state = f.BeforeClosingTagName : (this.state = f.Text, this.stateText(u));
|
|
832
851
|
}
|
|
833
852
|
stateInTagName(u) {
|
|
834
|
-
Q(u) && (this.cbs.onopentagname(this.sectionStart, this.index), this.sectionStart = -1, this.state =
|
|
853
|
+
Q(u) && (this.cbs.onopentagname(this.sectionStart, this.index), this.sectionStart = -1, this.state = f.BeforeAttributeName, this.stateBeforeAttributeName(u));
|
|
835
854
|
}
|
|
836
855
|
stateBeforeClosingTagName(u) {
|
|
837
|
-
F(u) || (u === h.Gt ? this.state =
|
|
856
|
+
F(u) || (u === h.Gt ? this.state = f.Text : (this.state = this.isTagStartChar(u) ? f.InClosingTagName : f.InSpecialComment, this.sectionStart = this.index));
|
|
838
857
|
}
|
|
839
858
|
stateInClosingTagName(u) {
|
|
840
|
-
(u === h.Gt || F(u)) && (this.cbs.onclosetag(this.sectionStart, this.index), this.sectionStart = -1, this.state =
|
|
859
|
+
(u === h.Gt || F(u)) && (this.cbs.onclosetag(this.sectionStart, this.index), this.sectionStart = -1, this.state = f.AfterClosingTagName, this.stateAfterClosingTagName(u));
|
|
841
860
|
}
|
|
842
861
|
stateAfterClosingTagName(u) {
|
|
843
|
-
(u === h.Gt || this.fastForwardTo(h.Gt)) && (this.state =
|
|
862
|
+
(u === h.Gt || this.fastForwardTo(h.Gt)) && (this.state = f.Text, this.sectionStart = this.index + 1);
|
|
844
863
|
}
|
|
845
864
|
stateBeforeAttributeName(u) {
|
|
846
|
-
u === h.Gt ? (this.cbs.onopentagend(this.index), this.isSpecial ? (this.state =
|
|
865
|
+
u === h.Gt ? (this.cbs.onopentagend(this.index), this.isSpecial ? (this.state = f.InSpecialTag, this.sequenceIndex = 0) : this.state = f.Text, this.sectionStart = this.index + 1) : u === h.Slash ? this.state = f.InSelfClosingTag : F(u) || (this.state = f.InAttributeName, this.sectionStart = this.index);
|
|
847
866
|
}
|
|
848
867
|
stateInSelfClosingTag(u) {
|
|
849
|
-
u === h.Gt ? (this.cbs.onselfclosingtag(this.index), this.state =
|
|
868
|
+
u === h.Gt ? (this.cbs.onselfclosingtag(this.index), this.state = f.Text, this.sectionStart = this.index + 1, this.isSpecial = !1) : F(u) || (this.state = f.BeforeAttributeName, this.stateBeforeAttributeName(u));
|
|
850
869
|
}
|
|
851
870
|
stateInAttributeName(u) {
|
|
852
|
-
(u === h.Eq || Q(u)) && (this.cbs.onattribname(this.sectionStart, this.index), this.sectionStart = this.index, this.state =
|
|
871
|
+
(u === h.Eq || Q(u)) && (this.cbs.onattribname(this.sectionStart, this.index), this.sectionStart = this.index, this.state = f.AfterAttributeName, this.stateAfterAttributeName(u));
|
|
853
872
|
}
|
|
854
873
|
stateAfterAttributeName(u) {
|
|
855
|
-
u === h.Eq ? this.state =
|
|
874
|
+
u === h.Eq ? this.state = f.BeforeAttributeValue : u === h.Slash || u === h.Gt ? (this.cbs.onattribend(L.NoValue, this.sectionStart), this.sectionStart = -1, this.state = f.BeforeAttributeName, this.stateBeforeAttributeName(u)) : F(u) || (this.cbs.onattribend(L.NoValue, this.sectionStart), this.state = f.InAttributeName, this.sectionStart = this.index);
|
|
856
875
|
}
|
|
857
876
|
stateBeforeAttributeValue(u) {
|
|
858
|
-
u === h.DoubleQuote ? (this.state =
|
|
877
|
+
u === h.DoubleQuote ? (this.state = f.InAttributeValueDq, this.sectionStart = this.index + 1) : u === h.SingleQuote ? (this.state = f.InAttributeValueSq, this.sectionStart = this.index + 1) : F(u) || (this.sectionStart = this.index, this.state = f.InAttributeValueNq, this.stateInAttributeValueNoQuotes(u));
|
|
859
878
|
}
|
|
860
879
|
handleInAttributeValue(u, t) {
|
|
861
|
-
u === t || !this.decodeEntities && this.fastForwardTo(t) ? (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = -1, this.cbs.onattribend(t === h.DoubleQuote ? L.Double : L.Single, this.index + 1), this.state =
|
|
880
|
+
u === t || !this.decodeEntities && this.fastForwardTo(t) ? (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = -1, this.cbs.onattribend(t === h.DoubleQuote ? L.Double : L.Single, this.index + 1), this.state = f.BeforeAttributeName) : this.decodeEntities && u === h.Amp && this.startEntity();
|
|
862
881
|
}
|
|
863
882
|
stateInAttributeValueDoubleQuotes(u) {
|
|
864
883
|
this.handleInAttributeValue(u, h.DoubleQuote);
|
|
@@ -867,26 +886,26 @@ class Ve {
|
|
|
867
886
|
this.handleInAttributeValue(u, h.SingleQuote);
|
|
868
887
|
}
|
|
869
888
|
stateInAttributeValueNoQuotes(u) {
|
|
870
|
-
F(u) || u === h.Gt ? (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = -1, this.cbs.onattribend(L.Unquoted, this.index), this.state =
|
|
889
|
+
F(u) || u === h.Gt ? (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = -1, this.cbs.onattribend(L.Unquoted, this.index), this.state = f.BeforeAttributeName, this.stateBeforeAttributeName(u)) : this.decodeEntities && u === h.Amp && this.startEntity();
|
|
871
890
|
}
|
|
872
891
|
stateBeforeDeclaration(u) {
|
|
873
|
-
u === h.OpeningSquareBracket ? (this.state =
|
|
892
|
+
u === h.OpeningSquareBracket ? (this.state = f.CDATASequence, this.sequenceIndex = 0) : this.state = u === h.Dash ? f.BeforeComment : f.InDeclaration;
|
|
874
893
|
}
|
|
875
894
|
stateInDeclaration(u) {
|
|
876
|
-
(u === h.Gt || this.fastForwardTo(h.Gt)) && (this.cbs.ondeclaration(this.sectionStart, this.index), this.state =
|
|
895
|
+
(u === h.Gt || this.fastForwardTo(h.Gt)) && (this.cbs.ondeclaration(this.sectionStart, this.index), this.state = f.Text, this.sectionStart = this.index + 1);
|
|
877
896
|
}
|
|
878
897
|
stateInProcessingInstruction(u) {
|
|
879
|
-
(u === h.Gt || this.fastForwardTo(h.Gt)) && (this.cbs.onprocessinginstruction(this.sectionStart, this.index), this.state =
|
|
898
|
+
(u === h.Gt || this.fastForwardTo(h.Gt)) && (this.cbs.onprocessinginstruction(this.sectionStart, this.index), this.state = f.Text, this.sectionStart = this.index + 1);
|
|
880
899
|
}
|
|
881
900
|
stateBeforeComment(u) {
|
|
882
|
-
u === h.Dash ? (this.state =
|
|
901
|
+
u === h.Dash ? (this.state = f.InCommentLike, this.currentSequence = T.CommentEnd, this.sequenceIndex = 2, this.sectionStart = this.index + 1) : this.state = f.InDeclaration;
|
|
883
902
|
}
|
|
884
903
|
stateInSpecialComment(u) {
|
|
885
|
-
(u === h.Gt || this.fastForwardTo(h.Gt)) && (this.cbs.oncomment(this.sectionStart, this.index, 0), this.state =
|
|
904
|
+
(u === h.Gt || this.fastForwardTo(h.Gt)) && (this.cbs.oncomment(this.sectionStart, this.index, 0), this.state = f.Text, this.sectionStart = this.index + 1);
|
|
886
905
|
}
|
|
887
906
|
stateBeforeSpecialS(u) {
|
|
888
907
|
const t = u | 32;
|
|
889
|
-
t === T.ScriptEnd[3] ? this.startSpecial(T.ScriptEnd, 4) : t === T.StyleEnd[3] ? this.startSpecial(T.StyleEnd, 4) : (this.state =
|
|
908
|
+
t === T.ScriptEnd[3] ? this.startSpecial(T.ScriptEnd, 4) : t === T.StyleEnd[3] ? this.startSpecial(T.StyleEnd, 4) : (this.state = f.InTagName, this.stateInTagName(u));
|
|
890
909
|
}
|
|
891
910
|
stateBeforeSpecialT(u) {
|
|
892
911
|
switch (u | 32) {
|
|
@@ -903,11 +922,11 @@ class Ve {
|
|
|
903
922
|
break;
|
|
904
923
|
}
|
|
905
924
|
default:
|
|
906
|
-
this.state =
|
|
925
|
+
this.state = f.InTagName, this.stateInTagName(u);
|
|
907
926
|
}
|
|
908
927
|
}
|
|
909
928
|
startEntity() {
|
|
910
|
-
this.baseState = this.state, this.state =
|
|
929
|
+
this.baseState = this.state, this.state = f.InEntity, this.entityStart = this.index, this.entityDecoder.startEntity(this.xmlMode ? C.Strict : this.baseState === f.Text || this.baseState === f.InSpecialTag ? C.Legacy : C.Attribute);
|
|
911
930
|
}
|
|
912
931
|
stateInEntity() {
|
|
913
932
|
const u = this.entityDecoder.write(this.buffer, this.index - this.offset);
|
|
@@ -917,7 +936,7 @@ class Ve {
|
|
|
917
936
|
* Remove data that has already been consumed from the buffer.
|
|
918
937
|
*/
|
|
919
938
|
cleanup() {
|
|
920
|
-
this.running && this.sectionStart !== this.index && (this.state ===
|
|
939
|
+
this.running && this.sectionStart !== this.index && (this.state === f.Text || this.state === f.InSpecialTag && this.sequenceIndex === 0 ? (this.cbs.ontext(this.sectionStart, this.index), this.sectionStart = this.index) : (this.state === f.InAttributeValueDq || this.state === f.InAttributeValueSq || this.state === f.InAttributeValueNq) && (this.cbs.onattribdata(this.sectionStart, this.index), this.sectionStart = this.index));
|
|
921
940
|
}
|
|
922
941
|
shouldContinue() {
|
|
923
942
|
return this.index < this.buffer.length + this.offset && this.running;
|
|
@@ -931,107 +950,107 @@ class Ve {
|
|
|
931
950
|
for (; this.shouldContinue(); ) {
|
|
932
951
|
const u = this.buffer.charCodeAt(this.index - this.offset);
|
|
933
952
|
switch (this.state) {
|
|
934
|
-
case
|
|
953
|
+
case f.Text: {
|
|
935
954
|
this.stateText(u);
|
|
936
955
|
break;
|
|
937
956
|
}
|
|
938
|
-
case
|
|
957
|
+
case f.SpecialStartSequence: {
|
|
939
958
|
this.stateSpecialStartSequence(u);
|
|
940
959
|
break;
|
|
941
960
|
}
|
|
942
|
-
case
|
|
961
|
+
case f.InSpecialTag: {
|
|
943
962
|
this.stateInSpecialTag(u);
|
|
944
963
|
break;
|
|
945
964
|
}
|
|
946
|
-
case
|
|
965
|
+
case f.CDATASequence: {
|
|
947
966
|
this.stateCDATASequence(u);
|
|
948
967
|
break;
|
|
949
968
|
}
|
|
950
|
-
case
|
|
969
|
+
case f.InAttributeValueDq: {
|
|
951
970
|
this.stateInAttributeValueDoubleQuotes(u);
|
|
952
971
|
break;
|
|
953
972
|
}
|
|
954
|
-
case
|
|
973
|
+
case f.InAttributeName: {
|
|
955
974
|
this.stateInAttributeName(u);
|
|
956
975
|
break;
|
|
957
976
|
}
|
|
958
|
-
case
|
|
977
|
+
case f.InCommentLike: {
|
|
959
978
|
this.stateInCommentLike(u);
|
|
960
979
|
break;
|
|
961
980
|
}
|
|
962
|
-
case
|
|
981
|
+
case f.InSpecialComment: {
|
|
963
982
|
this.stateInSpecialComment(u);
|
|
964
983
|
break;
|
|
965
984
|
}
|
|
966
|
-
case
|
|
985
|
+
case f.BeforeAttributeName: {
|
|
967
986
|
this.stateBeforeAttributeName(u);
|
|
968
987
|
break;
|
|
969
988
|
}
|
|
970
|
-
case
|
|
989
|
+
case f.InTagName: {
|
|
971
990
|
this.stateInTagName(u);
|
|
972
991
|
break;
|
|
973
992
|
}
|
|
974
|
-
case
|
|
993
|
+
case f.InClosingTagName: {
|
|
975
994
|
this.stateInClosingTagName(u);
|
|
976
995
|
break;
|
|
977
996
|
}
|
|
978
|
-
case
|
|
997
|
+
case f.BeforeTagName: {
|
|
979
998
|
this.stateBeforeTagName(u);
|
|
980
999
|
break;
|
|
981
1000
|
}
|
|
982
|
-
case
|
|
1001
|
+
case f.AfterAttributeName: {
|
|
983
1002
|
this.stateAfterAttributeName(u);
|
|
984
1003
|
break;
|
|
985
1004
|
}
|
|
986
|
-
case
|
|
1005
|
+
case f.InAttributeValueSq: {
|
|
987
1006
|
this.stateInAttributeValueSingleQuotes(u);
|
|
988
1007
|
break;
|
|
989
1008
|
}
|
|
990
|
-
case
|
|
1009
|
+
case f.BeforeAttributeValue: {
|
|
991
1010
|
this.stateBeforeAttributeValue(u);
|
|
992
1011
|
break;
|
|
993
1012
|
}
|
|
994
|
-
case
|
|
1013
|
+
case f.BeforeClosingTagName: {
|
|
995
1014
|
this.stateBeforeClosingTagName(u);
|
|
996
1015
|
break;
|
|
997
1016
|
}
|
|
998
|
-
case
|
|
1017
|
+
case f.AfterClosingTagName: {
|
|
999
1018
|
this.stateAfterClosingTagName(u);
|
|
1000
1019
|
break;
|
|
1001
1020
|
}
|
|
1002
|
-
case
|
|
1021
|
+
case f.BeforeSpecialS: {
|
|
1003
1022
|
this.stateBeforeSpecialS(u);
|
|
1004
1023
|
break;
|
|
1005
1024
|
}
|
|
1006
|
-
case
|
|
1025
|
+
case f.BeforeSpecialT: {
|
|
1007
1026
|
this.stateBeforeSpecialT(u);
|
|
1008
1027
|
break;
|
|
1009
1028
|
}
|
|
1010
|
-
case
|
|
1029
|
+
case f.InAttributeValueNq: {
|
|
1011
1030
|
this.stateInAttributeValueNoQuotes(u);
|
|
1012
1031
|
break;
|
|
1013
1032
|
}
|
|
1014
|
-
case
|
|
1033
|
+
case f.InSelfClosingTag: {
|
|
1015
1034
|
this.stateInSelfClosingTag(u);
|
|
1016
1035
|
break;
|
|
1017
1036
|
}
|
|
1018
|
-
case
|
|
1037
|
+
case f.InDeclaration: {
|
|
1019
1038
|
this.stateInDeclaration(u);
|
|
1020
1039
|
break;
|
|
1021
1040
|
}
|
|
1022
|
-
case
|
|
1041
|
+
case f.BeforeDeclaration: {
|
|
1023
1042
|
this.stateBeforeDeclaration(u);
|
|
1024
1043
|
break;
|
|
1025
1044
|
}
|
|
1026
|
-
case
|
|
1045
|
+
case f.BeforeComment: {
|
|
1027
1046
|
this.stateBeforeComment(u);
|
|
1028
1047
|
break;
|
|
1029
1048
|
}
|
|
1030
|
-
case
|
|
1049
|
+
case f.InProcessingInstruction: {
|
|
1031
1050
|
this.stateInProcessingInstruction(u);
|
|
1032
1051
|
break;
|
|
1033
1052
|
}
|
|
1034
|
-
case
|
|
1053
|
+
case f.InEntity: {
|
|
1035
1054
|
this.stateInEntity();
|
|
1036
1055
|
break;
|
|
1037
1056
|
}
|
|
@@ -1041,15 +1060,15 @@ class Ve {
|
|
|
1041
1060
|
this.cleanup();
|
|
1042
1061
|
}
|
|
1043
1062
|
finish() {
|
|
1044
|
-
this.state ===
|
|
1063
|
+
this.state === f.InEntity && (this.entityDecoder.end(), this.state = this.baseState), this.handleTrailingData(), this.cbs.onend();
|
|
1045
1064
|
}
|
|
1046
1065
|
/** Handle any trailing data. */
|
|
1047
1066
|
handleTrailingData() {
|
|
1048
1067
|
const u = this.buffer.length + this.offset;
|
|
1049
|
-
this.sectionStart >= u || (this.state ===
|
|
1068
|
+
this.sectionStart >= u || (this.state === f.InCommentLike ? this.currentSequence === T.CdataEnd ? this.cbs.oncdata(this.sectionStart, u, 0) : this.cbs.oncomment(this.sectionStart, u, 0) : this.state === f.InTagName || this.state === f.BeforeAttributeName || this.state === f.BeforeAttributeValue || this.state === f.AfterAttributeName || this.state === f.InAttributeName || this.state === f.InAttributeValueSq || this.state === f.InAttributeValueDq || this.state === f.InAttributeValueNq || this.state === f.InClosingTagName || this.cbs.ontext(this.sectionStart, u));
|
|
1050
1069
|
}
|
|
1051
1070
|
emitCodePoint(u, t) {
|
|
1052
|
-
this.baseState !==
|
|
1071
|
+
this.baseState !== f.Text && this.baseState !== f.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));
|
|
1053
1072
|
}
|
|
1054
1073
|
}
|
|
1055
1074
|
const G = /* @__PURE__ */ new Set([
|
|
@@ -1141,8 +1160,8 @@ const G = /* @__PURE__ */ new Set([
|
|
|
1141
1160
|
]), je = /\s|\//;
|
|
1142
1161
|
class De {
|
|
1143
1162
|
constructor(u, t = {}) {
|
|
1144
|
-
var a, i, s, r, n,
|
|
1145
|
-
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 = (s = t.recognizeSelfClosing) !== null && s !== void 0 ? s : !this.htmlMode, this.tokenizer = new ((r = t.Tokenizer) !== null && r !== void 0 ? r : Ve)(this.options, this), this.foreignContext = [!this.htmlMode], (
|
|
1163
|
+
var a, i, s, r, n, o;
|
|
1164
|
+
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 = (s = t.recognizeSelfClosing) !== null && s !== void 0 ? s : !this.htmlMode, this.tokenizer = new ((r = t.Tokenizer) !== null && r !== void 0 ? r : Ve)(this.options, this), this.foreignContext = [!this.htmlMode], (o = (n = this.cbs).onparserinit) === null || o === void 0 || o.call(n, this);
|
|
1146
1165
|
}
|
|
1147
1166
|
// Tokenizer event handlers
|
|
1148
1167
|
/** @internal */
|
|
@@ -1190,11 +1209,11 @@ class De {
|
|
|
1190
1209
|
}
|
|
1191
1210
|
/** @internal */
|
|
1192
1211
|
onclosetag(u, t) {
|
|
1193
|
-
var a, i, s, r, n,
|
|
1212
|
+
var a, i, s, r, n, o, c, d;
|
|
1194
1213
|
this.endIndex = t;
|
|
1195
1214
|
let l = this.getSlice(u, t);
|
|
1196
1215
|
if (this.lowerCaseTagNames && (l = l.toLowerCase()), this.htmlMode && (wu.has(l) || Au.has(l)) && this.foreignContext.shift(), this.isVoidElement(l))
|
|
1197
|
-
this.htmlMode && l === "br" && ((r = (s = this.cbs).onopentagname) === null || r === void 0 || r.call(s, "br"), (
|
|
1216
|
+
this.htmlMode && l === "br" && ((r = (s = this.cbs).onopentagname) === null || r === void 0 || r.call(s, "br"), (o = (n = this.cbs).onopentag) === null || o === void 0 || o.call(n, "br", {}, !0), (d = (c = this.cbs).onclosetag) === null || d === void 0 || d.call(c, "br", !1));
|
|
1198
1217
|
else {
|
|
1199
1218
|
const m = this.stack.indexOf(l);
|
|
1200
1219
|
if (m !== -1)
|
|
@@ -1266,10 +1285,10 @@ class De {
|
|
|
1266
1285
|
}
|
|
1267
1286
|
/** @internal */
|
|
1268
1287
|
oncdata(u, t, a) {
|
|
1269
|
-
var i, s, r, n,
|
|
1288
|
+
var i, s, r, n, o, c, d, l, m, p;
|
|
1270
1289
|
this.endIndex = t;
|
|
1271
1290
|
const v = this.getSlice(u, t - a);
|
|
1272
|
-
!this.htmlMode || this.options.recognizeCDATA ? ((s = (i = this.cbs).oncdatastart) === null || s === void 0 || s.call(i), (n = (r = this.cbs).ontext) === null || n === void 0 || n.call(r, v), (c = (
|
|
1291
|
+
!this.htmlMode || this.options.recognizeCDATA ? ((s = (i = this.cbs).oncdatastart) === null || s === void 0 || s.call(i), (n = (r = this.cbs).ontext) === null || n === void 0 || n.call(r, v), (c = (o = this.cbs).oncdataend) === null || c === void 0 || c.call(o)) : ((l = (d = this.cbs).oncomment) === null || l === void 0 || l.call(d, `[CDATA[${v}]]`), (p = (m = this.cbs).oncommentend) === null || p === void 0 || p.call(m)), this.startIndex = t + 1;
|
|
1273
1292
|
}
|
|
1274
1293
|
/** @internal */
|
|
1275
1294
|
onend() {
|
|
@@ -1372,23 +1391,23 @@ function Tu(e, u = "web") {
|
|
|
1372
1391
|
let i = "";
|
|
1373
1392
|
const s = new De(
|
|
1374
1393
|
{
|
|
1375
|
-
onopentag: (r, n,
|
|
1394
|
+
onopentag: (r, n, o) => {
|
|
1376
1395
|
const c = a[a.length - 1];
|
|
1377
1396
|
i.trim() && (Array.isArray(c.children) ? c.children.push({
|
|
1378
1397
|
name: "span",
|
|
1379
1398
|
children: i.trim()
|
|
1380
1399
|
}) : c.children = i.trim(), i = "");
|
|
1381
|
-
const
|
|
1400
|
+
const d = Object.entries(n || {}).reduce(
|
|
1382
1401
|
(m, p) => {
|
|
1383
1402
|
let [v = "", A = ""] = p;
|
|
1384
1403
|
return v && (m[v] = A), m;
|
|
1385
1404
|
},
|
|
1386
1405
|
{}
|
|
1387
1406
|
);
|
|
1388
|
-
|
|
1407
|
+
d.style && (d.style = Du(d.style));
|
|
1389
1408
|
const l = {
|
|
1390
1409
|
name: ju(r, u),
|
|
1391
|
-
props:
|
|
1410
|
+
props: d
|
|
1392
1411
|
};
|
|
1393
1412
|
Array.isArray(c.children) ? c.children.push(l) : c.children ? c.children = [
|
|
1394
1413
|
{
|
|
@@ -1396,7 +1415,7 @@ function Tu(e, u = "web") {
|
|
|
1396
1415
|
children: c.children
|
|
1397
1416
|
},
|
|
1398
1417
|
l
|
|
1399
|
-
] : c.children = [l],
|
|
1418
|
+
] : c.children = [l], o || a.push(l);
|
|
1400
1419
|
},
|
|
1401
1420
|
ontext: (r) => {
|
|
1402
1421
|
const n = r.trim();
|
|
@@ -1426,15 +1445,15 @@ function Ce(e, u) {
|
|
|
1426
1445
|
if (r.type !== "CallExpression") return;
|
|
1427
1446
|
const n = r.arguments[0];
|
|
1428
1447
|
if (n?.type !== "ObjectExpression") return;
|
|
1429
|
-
const
|
|
1448
|
+
const o = n.properties.filter(
|
|
1430
1449
|
(l) => l.type === "ObjectProperty"
|
|
1431
1450
|
), c = n.properties.filter(
|
|
1432
1451
|
(l) => l.type == "ObjectMethod"
|
|
1433
|
-
),
|
|
1452
|
+
), d = o.find(
|
|
1434
1453
|
(l) => l.key.name === "computed"
|
|
1435
1454
|
);
|
|
1436
|
-
|
|
1437
|
-
for (const l of
|
|
1455
|
+
d && (a.computed = Cu(d.value), a.watchers = Me(d.value));
|
|
1456
|
+
for (const l of o)
|
|
1438
1457
|
switch (l.key.name) {
|
|
1439
1458
|
case "name":
|
|
1440
1459
|
a.name = l.value.value;
|
|
@@ -1488,13 +1507,13 @@ function Le(e) {
|
|
|
1488
1507
|
const n = s[2] === "@element-plus/icons-vue" ? "@vtj/icons" : s[2];
|
|
1489
1508
|
i.push({
|
|
1490
1509
|
from: n,
|
|
1491
|
-
imports: s[1].split(",").map((
|
|
1510
|
+
imports: s[1].split(",").map((o) => o.trim())
|
|
1492
1511
|
});
|
|
1493
1512
|
}
|
|
1494
1513
|
for (; (s = t.exec(r)) !== null; ) {
|
|
1495
|
-
const n = s[1],
|
|
1514
|
+
const n = s[1], o = s[2];
|
|
1496
1515
|
n && !a.test(n) && i.push({
|
|
1497
|
-
from:
|
|
1516
|
+
from: o,
|
|
1498
1517
|
imports: n
|
|
1499
1518
|
});
|
|
1500
1519
|
}
|
|
@@ -1523,22 +1542,22 @@ function Be(e) {
|
|
|
1523
1542
|
return t;
|
|
1524
1543
|
}
|
|
1525
1544
|
function U(e) {
|
|
1526
|
-
const { key: u, async: t, params: a, body: i } = e, s = a?.map((r) => r.type === "ObjectPattern" ? `{${r.properties.map((
|
|
1545
|
+
const { key: u, async: t, params: a, body: i } = e, s = a?.map((r) => r.type === "ObjectPattern" ? `{${r.properties.map((o) => o.key?.name || o.name).join(",")}}` : r.type === "AssignmentPattern" ? r.left.name + "=" + (r.right?.extra?.raw || "null") : r.name).join(", ");
|
|
1527
1546
|
if (u.type === "Identifier") {
|
|
1528
1547
|
const r = u.name;
|
|
1529
1548
|
let n = "{}";
|
|
1530
1549
|
i && (n = P(i) || "{}");
|
|
1531
|
-
const
|
|
1532
|
-
if (
|
|
1533
|
-
let p = P(
|
|
1550
|
+
const o = e.value;
|
|
1551
|
+
if (o && o.type === "CallExpression") {
|
|
1552
|
+
let p = P(o) || "";
|
|
1534
1553
|
p = p.replace("function () {", "() => {"), n = `{ return (${p})}`;
|
|
1535
1554
|
}
|
|
1536
|
-
const
|
|
1555
|
+
const d = `${t ? "async " : ""}(${s}) => ${n}`, l = r.startsWith("watcher_");
|
|
1537
1556
|
return {
|
|
1538
1557
|
id: l ? r.replace("watcher_", "") : "",
|
|
1539
1558
|
name: r,
|
|
1540
1559
|
watcher: l,
|
|
1541
|
-
exp: fu(
|
|
1560
|
+
exp: fu(d)
|
|
1542
1561
|
};
|
|
1543
1562
|
}
|
|
1544
1563
|
}
|
|
@@ -1555,7 +1574,7 @@ function Fe(e, u) {
|
|
|
1555
1574
|
if (!e) return {};
|
|
1556
1575
|
const t = {}, a = /apis\[\'([\w]*)\'\]/, i = /\.then\(([\w\W]*)\)/;
|
|
1557
1576
|
for (const s of e.properties) {
|
|
1558
|
-
const r = U(s), n = s.body.body?.[0],
|
|
1577
|
+
const r = U(s), n = s.body.body?.[0], o = (n?.leadingComments?.[0].value || "").trim(), c = xe(o);
|
|
1559
1578
|
if (r && r.exp.value.includes("this.provider.apis")) {
|
|
1560
1579
|
const l = (r.exp.value.match(a) || [])[1];
|
|
1561
1580
|
if (!l) continue;
|
|
@@ -1583,7 +1602,7 @@ function Fe(e, u) {
|
|
|
1583
1602
|
};
|
|
1584
1603
|
}
|
|
1585
1604
|
if (r && r.exp.value.includes("this.provider.createMock")) {
|
|
1586
|
-
const
|
|
1605
|
+
const d = n?.declarations?.[0]?.init?.arguments?.[0], l = r.exp.value.match(i)?.[1];
|
|
1587
1606
|
t[r.name] = {
|
|
1588
1607
|
ref: "",
|
|
1589
1608
|
name: r.name,
|
|
@@ -1603,7 +1622,7 @@ function Fe(e, u) {
|
|
|
1603
1622
|
},
|
|
1604
1623
|
mockTemplate: c?.mockTemplate || {
|
|
1605
1624
|
type: "JSFunction",
|
|
1606
|
-
value:
|
|
1625
|
+
value: d ? P(d) : ""
|
|
1607
1626
|
}
|
|
1608
1627
|
};
|
|
1609
1628
|
}
|
|
@@ -1752,11 +1771,11 @@ function We(e) {
|
|
|
1752
1771
|
function ze(e) {
|
|
1753
1772
|
let u = [];
|
|
1754
1773
|
return e.type === "ObjectExpression" && (u = e.properties?.map((t) => {
|
|
1755
|
-
const { key: a, value: i } = t, s = i.properties, r = a.name, n = Lu(s, "from"),
|
|
1774
|
+
const { key: a, value: i } = t, s = i.properties, r = a.name, n = Lu(s, "from"), o = _u(s);
|
|
1756
1775
|
return {
|
|
1757
1776
|
name: r,
|
|
1758
1777
|
from: n || r,
|
|
1759
|
-
default:
|
|
1778
|
+
default: o
|
|
1760
1779
|
};
|
|
1761
1780
|
})), u;
|
|
1762
1781
|
}
|
|
@@ -1809,7 +1828,7 @@ function Ye(e) {
|
|
|
1809
1828
|
for (const t of e) {
|
|
1810
1829
|
if (t.type === x.ATTRIBUTE)
|
|
1811
1830
|
if (t.name === "class") {
|
|
1812
|
-
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, s = a.match(i)?.[0] || "", r = a.split(" ").filter((
|
|
1831
|
+
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, s = a.match(i)?.[0] || "", r = a.split(" ").filter((o) => o !== s), n = $u[`.${s}`];
|
|
1813
1832
|
n && (u.style = n), r.length && (u.class = r.join(" "));
|
|
1814
1833
|
} else if (t.name === "style") {
|
|
1815
1834
|
const a = t.value?.content || "";
|
|
@@ -1842,23 +1861,23 @@ function e0(e, u = {}) {
|
|
|
1842
1861
|
for (const a of e)
|
|
1843
1862
|
if (a.type === x.DIRECTIVE && a.name === "on" && a.arg?.type === x.SIMPLE_EXPRESSION) {
|
|
1844
1863
|
const i = a.modifiers.reduce(
|
|
1845
|
-
(
|
|
1864
|
+
(c, d) => (d.content && (c[d.content] = !0), c),
|
|
1846
1865
|
{}
|
|
1847
1866
|
);
|
|
1848
1867
|
let s = a.exp?.loc.source || "";
|
|
1849
|
-
|
|
1850
|
-
const
|
|
1851
|
-
if (
|
|
1868
|
+
s || (s = "() => {}");
|
|
1869
|
+
const r = new RegExp(`${a.arg.content}_[\\w]{5,}`), n = s.match(r)?.[0] || "", o = u[n];
|
|
1870
|
+
if (n && o)
|
|
1852
1871
|
t[a.arg.content] = {
|
|
1853
1872
|
name: a.arg.content,
|
|
1854
|
-
handler:
|
|
1873
|
+
handler: o,
|
|
1855
1874
|
modifiers: i
|
|
1856
1875
|
};
|
|
1857
1876
|
else {
|
|
1858
|
-
const
|
|
1877
|
+
const c = a.exp?.ast?.type === "CallExpression";
|
|
1859
1878
|
t[a.arg.content] = {
|
|
1860
1879
|
name: a.arg.content,
|
|
1861
|
-
handler:
|
|
1880
|
+
handler: c ? q(s) : fu(s),
|
|
1862
1881
|
modifiers: i
|
|
1863
1882
|
};
|
|
1864
1883
|
}
|
|
@@ -1874,9 +1893,9 @@ function Z(e, u) {
|
|
|
1874
1893
|
name: r,
|
|
1875
1894
|
value: r === "vElse" ? !0 : q(n)
|
|
1876
1895
|
});
|
|
1877
|
-
const
|
|
1878
|
-
if (
|
|
1879
|
-
const c = Z(
|
|
1896
|
+
const o = e.children?.[0];
|
|
1897
|
+
if (o) {
|
|
1898
|
+
const c = Z(o);
|
|
1880
1899
|
t.push(...c);
|
|
1881
1900
|
}
|
|
1882
1901
|
}
|
|
@@ -1889,39 +1908,39 @@ function Z(e, u) {
|
|
|
1889
1908
|
}
|
|
1890
1909
|
}), e.type === x.ELEMENT) {
|
|
1891
1910
|
const i = e.props.filter(
|
|
1892
|
-
(
|
|
1893
|
-
), s = i.filter((
|
|
1894
|
-
s.length && s.forEach((
|
|
1911
|
+
(d) => d.type === x.DIRECTIVE
|
|
1912
|
+
), s = i.filter((d) => d.name === "model");
|
|
1913
|
+
s.length && s.forEach((d) => {
|
|
1895
1914
|
t.push({
|
|
1896
1915
|
name: "vModel",
|
|
1897
|
-
arg:
|
|
1898
|
-
value: q(
|
|
1916
|
+
arg: d.arg?.content,
|
|
1917
|
+
value: q(d.exp?.loc.source || "")
|
|
1899
1918
|
});
|
|
1900
1919
|
});
|
|
1901
|
-
const r = i.find((
|
|
1920
|
+
const r = i.find((d) => d.name === "show");
|
|
1902
1921
|
r && t.push({
|
|
1903
1922
|
name: "vShow",
|
|
1904
1923
|
value: q(r.exp?.loc.source || "")
|
|
1905
1924
|
});
|
|
1906
|
-
const n = i.find((
|
|
1925
|
+
const n = i.find((d) => d.name === "bind" && !d.arg);
|
|
1907
1926
|
n && t.push({
|
|
1908
1927
|
name: "vBind",
|
|
1909
1928
|
value: q(n.exp?.loc.source || "")
|
|
1910
1929
|
});
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1930
|
+
const o = i.find((d) => d.name === "html");
|
|
1931
|
+
o && t.push({
|
|
1913
1932
|
name: "vHtml",
|
|
1914
|
-
value: q(
|
|
1933
|
+
value: q(o.exp?.loc.source || "")
|
|
1915
1934
|
});
|
|
1916
|
-
const c = i.filter((
|
|
1917
|
-
for (const
|
|
1918
|
-
const l = (
|
|
1935
|
+
const c = i.filter((d) => !a.includes(d.name));
|
|
1936
|
+
for (const d of c) {
|
|
1937
|
+
const l = (d.modifiers || []).reduce(
|
|
1919
1938
|
(v, A) => (v[A.content] = !0, v),
|
|
1920
1939
|
{}
|
|
1921
|
-
), m =
|
|
1940
|
+
), m = d.arg?.content || void 0, p = Fu[d.name];
|
|
1922
1941
|
p && t.push({
|
|
1923
1942
|
name: p,
|
|
1924
|
-
value: q(
|
|
1943
|
+
value: q(d.exp?.loc.source || ""),
|
|
1925
1944
|
arg: m,
|
|
1926
1945
|
modifiers: l
|
|
1927
1946
|
});
|
|
@@ -1985,7 +2004,7 @@ function iu(e, u, t, a) {
|
|
|
1985
2004
|
const s = uu(i, e.children);
|
|
1986
2005
|
return nu(i, u), Ke(s), s;
|
|
1987
2006
|
}
|
|
1988
|
-
function a0(e, u) {
|
|
2007
|
+
function a0(e = [], u) {
|
|
1989
2008
|
return e.map((t) => W(t, u, e));
|
|
1990
2009
|
}
|
|
1991
2010
|
function W(e, u, t) {
|
|
@@ -2057,12 +2076,12 @@ function uu(e, u = []) {
|
|
|
2057
2076
|
name: "span",
|
|
2058
2077
|
children: W(s, e)
|
|
2059
2078
|
} : W(s, e);
|
|
2060
|
-
r && (Array.isArray(r) ? r : [r]).forEach((
|
|
2061
|
-
ne(
|
|
2079
|
+
r && (Array.isArray(r) ? r : [r]).forEach((o) => {
|
|
2080
|
+
ne(o) && i?.type === x.DIRECTIVE && (o.id = Mu(s), o.slot = {
|
|
2062
2081
|
name: i.arg?.content || "default",
|
|
2063
2082
|
params: i.exp?.identifiers || [],
|
|
2064
2083
|
scope: i.exp?.type === x.SIMPLE_EXPRESSION ? i.exp.content : ""
|
|
2065
|
-
}, nu(
|
|
2084
|
+
}, nu(o, e)), t.push(o);
|
|
2066
2085
|
});
|
|
2067
2086
|
}
|
|
2068
2087
|
} else if (a.type === x.JS_CALL_EXPRESSION) {
|
|
@@ -2091,7 +2110,7 @@ function i0(e) {
|
|
|
2091
2110
|
const s = { name: "span", directives: Z(t, u) };
|
|
2092
2111
|
return uu(s, t.children);
|
|
2093
2112
|
} else
|
|
2094
|
-
return a0(u);
|
|
2113
|
+
return a0(u)?.[0];
|
|
2095
2114
|
}
|
|
2096
2115
|
function s0(e) {
|
|
2097
2116
|
const u = [], t = {}, a = [];
|
|
@@ -2099,10 +2118,10 @@ function s0(e) {
|
|
|
2099
2118
|
const i = re.compileString(e, { charset: !1 })?.css || "", s = se.parse(i), r = /^.[\w]+_[\w]{5,}/;
|
|
2100
2119
|
for (const n of s.nodes)
|
|
2101
2120
|
if (n.type === "rule") {
|
|
2102
|
-
const
|
|
2121
|
+
const o = {};
|
|
2103
2122
|
r.test(n.selector) ? (n.nodes.forEach((c) => {
|
|
2104
|
-
c.type === "decl" && (
|
|
2105
|
-
}), t[n.selector] =
|
|
2123
|
+
c.type === "decl" && (o[c.prop] = c.value);
|
|
2124
|
+
}), t[n.selector] = o) : a.push(n.toString());
|
|
2106
2125
|
} else
|
|
2107
2126
|
a.push(n.toString());
|
|
2108
2127
|
} catch (i) {
|
|
@@ -2210,9 +2229,9 @@ function o0(e) {
|
|
|
2210
2229
|
};
|
|
2211
2230
|
const i = d0(a.script), s = a.template;
|
|
2212
2231
|
let r = s;
|
|
2213
|
-
const n = [],
|
|
2232
|
+
const n = [], o = /\{\{([^}]+)\}\}/g;
|
|
2214
2233
|
let c;
|
|
2215
|
-
for (; (c =
|
|
2234
|
+
for (; (c = o.exec(s)) !== null; ) {
|
|
2216
2235
|
const b = c[0], S = c[1], I = O(S, i);
|
|
2217
2236
|
if (I !== S) {
|
|
2218
2237
|
const g = $(s, c.index);
|
|
@@ -2232,8 +2251,8 @@ function o0(e) {
|
|
|
2232
2251
|
});
|
|
2233
2252
|
}
|
|
2234
2253
|
}
|
|
2235
|
-
const
|
|
2236
|
-
for (; (c =
|
|
2254
|
+
const d = /:(\w+)="([^"]+)"/g;
|
|
2255
|
+
for (; (c = d.exec(s)) !== null; ) {
|
|
2237
2256
|
const b = c[0], S = c[1], I = c[2], g = O(I, i);
|
|
2238
2257
|
if (g !== I) {
|
|
2239
2258
|
const w = $(s, c.index);
|
|
@@ -2464,31 +2483,31 @@ class l0 {
|
|
|
2464
2483
|
a.script = Ru(a.script, {
|
|
2465
2484
|
ImportDeclaration(r) {
|
|
2466
2485
|
if (r.node.source.value === "@vtj/icons") {
|
|
2467
|
-
const n = r.node.specifiers,
|
|
2486
|
+
const n = r.node.specifiers, o = [];
|
|
2468
2487
|
let c = !1;
|
|
2469
|
-
for (const
|
|
2470
|
-
const l =
|
|
2471
|
-
l === j && (c = !0), t.includes(l) ||
|
|
2472
|
-
V.importSpecifier(
|
|
2488
|
+
for (const d of n) {
|
|
2489
|
+
const l = d.imported?.name;
|
|
2490
|
+
l === j && (c = !0), t.includes(l) || o.push(
|
|
2491
|
+
V.importSpecifier(d.local, d.imported)
|
|
2473
2492
|
);
|
|
2474
2493
|
}
|
|
2475
|
-
c ||
|
|
2494
|
+
c || o.push(
|
|
2476
2495
|
V.importSpecifier(
|
|
2477
2496
|
V.identifier(j),
|
|
2478
2497
|
V.identifier(j)
|
|
2479
2498
|
)
|
|
2480
|
-
), r.node.specifiers =
|
|
2499
|
+
), r.node.specifiers = o;
|
|
2481
2500
|
}
|
|
2482
2501
|
},
|
|
2483
2502
|
ObjectMethod(r) {
|
|
2484
2503
|
if (r.node.key.name === "setup") {
|
|
2485
2504
|
const n = r.node.body.body;
|
|
2486
|
-
for (const
|
|
2487
|
-
if (V.isReturnStatement(
|
|
2488
|
-
const c =
|
|
2489
|
-
|
|
2490
|
-
(
|
|
2491
|
-
),
|
|
2505
|
+
for (const o of n)
|
|
2506
|
+
if (V.isReturnStatement(o) && V.isObjectExpression(o.argument)) {
|
|
2507
|
+
const c = o.argument.properties || [];
|
|
2508
|
+
o.argument.properties = c.filter(
|
|
2509
|
+
(d) => !t.includes(d.key.name)
|
|
2510
|
+
), o.argument.properties.push(
|
|
2492
2511
|
V.objectProperty(
|
|
2493
2512
|
V.identifier(j),
|
|
2494
2513
|
V.identifier(j),
|
|
@@ -2502,7 +2521,7 @@ class l0 {
|
|
|
2502
2521
|
ObjectProperty(r) {
|
|
2503
2522
|
if (V.isIdentifier(r.node.value) && t.includes(r.node.value.name) && (r.node.value = V.identifier(j)), V.isArrayExpression(r.node.value)) {
|
|
2504
2523
|
const n = r.node.value.elements;
|
|
2505
|
-
r.node.value.elements = n.map((
|
|
2524
|
+
r.node.value.elements = n.map((o) => V.isIdentifier(o) && t.includes(o.name) ? V.identifier(j) : o);
|
|
2506
2525
|
}
|
|
2507
2526
|
},
|
|
2508
2527
|
AssignmentExpression(r) {
|
|
@@ -2513,8 +2532,8 @@ class l0 {
|
|
|
2513
2532
|
if (s)
|
|
2514
2533
|
for (const r of s) {
|
|
2515
2534
|
let n = r;
|
|
2516
|
-
for (const
|
|
2517
|
-
n = n.replace(new RegExp(
|
|
2535
|
+
for (const o of t)
|
|
2536
|
+
n = n.replace(new RegExp(o, "g"), j);
|
|
2518
2537
|
a.template = a.template.replace(r, n);
|
|
2519
2538
|
}
|
|
2520
2539
|
for (const r of t)
|
|
@@ -2547,11 +2566,11 @@ async function k0(e) {
|
|
|
2547
2566
|
const { id: u, name: t, source: a, project: i } = e, s = oe(a, t);
|
|
2548
2567
|
if (s)
|
|
2549
2568
|
return Promise.reject(s);
|
|
2550
|
-
const { dependencies: r = [], platform: n = "web" } = i || {},
|
|
2569
|
+
const { dependencies: r = [], platform: n = "web" } = i || {}, o = new n0(), c = new l0(), d = o.validate(a);
|
|
2551
2570
|
let l = [];
|
|
2552
|
-
if (!
|
|
2553
|
-
return l =
|
|
2554
|
-
const m = c.fixBasedOnValidation(a,
|
|
2571
|
+
if (!d.valid)
|
|
2572
|
+
return l = d.errors, Promise.reject(l);
|
|
2573
|
+
const m = c.fixBasedOnValidation(a, d), p = D(m), {
|
|
2555
2574
|
styles: v,
|
|
2556
2575
|
css: A,
|
|
2557
2576
|
errors: y
|
|
@@ -2657,9 +2676,9 @@ async function b0(e, u, t) {
|
|
|
2657
2676
|
state: s,
|
|
2658
2677
|
watch: r,
|
|
2659
2678
|
computed: n,
|
|
2660
|
-
props:
|
|
2679
|
+
props: o,
|
|
2661
2680
|
dataSources: c,
|
|
2662
|
-
methods:
|
|
2681
|
+
methods: d,
|
|
2663
2682
|
lifeCycles: l,
|
|
2664
2683
|
inject: m
|
|
2665
2684
|
} = e;
|
|
@@ -2667,9 +2686,9 @@ async function b0(e, u, t) {
|
|
|
2667
2686
|
state: s,
|
|
2668
2687
|
watch: r,
|
|
2669
2688
|
computed: n,
|
|
2670
|
-
props:
|
|
2689
|
+
props: o,
|
|
2671
2690
|
dataSources: c,
|
|
2672
|
-
methods:
|
|
2691
|
+
methods: d,
|
|
2673
2692
|
lifeCycles: l,
|
|
2674
2693
|
inject: m
|
|
2675
2694
|
}), Array.isArray(e.nodes))
|