@vtj/parser 0.12.4 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -6
- package/dist/index.mjs +283 -279
- package/package.json +3 -3
- package/types/version.d.ts +2 -2
package/dist/index.mjs
CHANGED
@@ -11,16 +11,16 @@ import Ru from "postcss";
|
|
11
11
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
12
12
|
* @name @vtj/parser
|
13
13
|
* @author CHC chenhuachun1549@dingtalk.com
|
14
|
-
* @version 0.12.
|
14
|
+
* @version 0.12.5
|
15
15
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
16
16
|
*/
|
17
|
-
const $0 = "0.12.
|
17
|
+
const $0 = "0.12.5";
|
18
18
|
function su(e) {
|
19
|
-
const { descriptor: u } = qu(e), t = u.template?.content || "", a = (u.scriptSetup || u.script)?.content || "",
|
19
|
+
const { descriptor: u } = qu(e), t = u.template?.content || "", a = (u.scriptSetup || u.script)?.content || "", i = u.styles.map((c) => c.content);
|
20
20
|
return {
|
21
21
|
template: t,
|
22
22
|
script: a,
|
23
|
-
styles:
|
23
|
+
styles: i
|
24
24
|
};
|
25
25
|
}
|
26
26
|
function ru(e) {
|
@@ -58,11 +58,11 @@ function Vu(e) {
|
|
58
58
|
function F0(e) {
|
59
59
|
const u = su(e), t = ru(u.script), a = {};
|
60
60
|
return u.styles && (a.css = u.styles[0] || ""), nu(t, {
|
61
|
-
CallExpression(
|
62
|
-
const
|
63
|
-
if (
|
64
|
-
const s = R(
|
65
|
-
s && (a[
|
61
|
+
CallExpression(i) {
|
62
|
+
const c = i.node.callee?.name;
|
63
|
+
if (c) {
|
64
|
+
const s = R(i.node.arguments[0]);
|
65
|
+
s && (a[c] = {
|
66
66
|
type: "JSFunction",
|
67
67
|
value: s
|
68
68
|
});
|
@@ -71,31 +71,31 @@ function F0(e) {
|
|
71
71
|
}), a;
|
72
72
|
}
|
73
73
|
function O(e, u, t) {
|
74
|
-
const a = new RegExp(`${u}`, "g"),
|
75
|
-
return e.replace(a, (
|
76
|
-
const
|
77
|
-
return
|
78
|
-
});
|
74
|
+
const a = new RegExp(`${u}`, "g"), i = /(\@\_|\$|\.|\,|\w)$/, c = /^\w/, s = new RegExp(`^this.${u}$`, "g");
|
75
|
+
return e.replace(a, (d, b, h) => {
|
76
|
+
const o = h.substring(0, b), S = h.substring(b + u.length);
|
77
|
+
return i.test(o.trim()) || c.test(S.trim()) ? d : t;
|
78
|
+
}).replace(s, t);
|
79
79
|
}
|
80
80
|
function Z(e, u, t) {
|
81
81
|
const {
|
82
82
|
context: a = {},
|
83
|
-
computed:
|
84
|
-
libs:
|
83
|
+
computed: i = [],
|
84
|
+
libs: c = {},
|
85
85
|
members: s = []
|
86
86
|
} = t || {}, n = Array.from(a[u || ""] || /* @__PURE__ */ new Set());
|
87
87
|
if (n)
|
88
88
|
for (const d of n)
|
89
89
|
e = O(e, d, `this.context.${d}`);
|
90
|
-
for (const d of
|
90
|
+
for (const d of i)
|
91
91
|
e = O(e, d, `this.${d}.value`);
|
92
|
-
for (const [d, b] of Object.entries(
|
92
|
+
for (const [d, b] of Object.entries(c))
|
93
93
|
e = O(e, d, `this.$libs.${b}.${d}`);
|
94
94
|
for (const d of s)
|
95
95
|
e = O(e, d, `this.${d}`);
|
96
96
|
return e = e.replace(/_ctx\./g, "this."), e;
|
97
97
|
}
|
98
|
-
function
|
98
|
+
function v(e) {
|
99
99
|
return {
|
100
100
|
type: "JSExpression",
|
101
101
|
value: /^\{[\w\W]*\}$/.test(e) ? `(${e})` : e
|
@@ -253,10 +253,10 @@ class Qu {
|
|
253
253
|
stateNumericStart(u, t) {
|
254
254
|
return t >= u.length ? -1 : (u.charCodeAt(t) | Ju) === y.LOWER_X ? (this.state = g.NumericHex, this.consumed += 1, this.stateNumericHex(u, t + 1)) : (this.state = g.NumericDecimal, this.stateNumericDecimal(u, t));
|
255
255
|
}
|
256
|
-
addToNumericResult(u, t, a,
|
256
|
+
addToNumericResult(u, t, a, i) {
|
257
257
|
if (t !== a) {
|
258
|
-
const
|
259
|
-
this.result = this.result * Math.pow(
|
258
|
+
const c = a - t;
|
259
|
+
this.result = this.result * Math.pow(i, c) + Number.parseInt(u.substr(t, c), i), this.consumed += c;
|
260
260
|
}
|
261
261
|
}
|
262
262
|
/**
|
@@ -271,11 +271,11 @@ class Qu {
|
|
271
271
|
stateNumericHex(u, t) {
|
272
272
|
const a = t;
|
273
273
|
for (; t < u.length; ) {
|
274
|
-
const
|
275
|
-
if ($(
|
274
|
+
const i = u.charCodeAt(t);
|
275
|
+
if ($(i) || zu(i))
|
276
276
|
t += 1;
|
277
277
|
else
|
278
|
-
return this.addToNumericResult(u, a, t, 16), this.emitNumericEntity(
|
278
|
+
return this.addToNumericResult(u, a, t, 16), this.emitNumericEntity(i, 3);
|
279
279
|
}
|
280
280
|
return this.addToNumericResult(u, a, t, 16), -1;
|
281
281
|
}
|
@@ -291,11 +291,11 @@ class Qu {
|
|
291
291
|
stateNumericDecimal(u, t) {
|
292
292
|
const a = t;
|
293
293
|
for (; t < u.length; ) {
|
294
|
-
const
|
295
|
-
if ($(
|
294
|
+
const i = u.charCodeAt(t);
|
295
|
+
if ($(i))
|
296
296
|
t += 1;
|
297
297
|
else
|
298
|
-
return this.addToNumericResult(u, a, t, 10), this.emitNumericEntity(
|
298
|
+
return this.addToNumericResult(u, a, t, 10), this.emitNumericEntity(i, 2);
|
299
299
|
}
|
300
300
|
return this.addToNumericResult(u, a, t, 10), -1;
|
301
301
|
}
|
@@ -333,17 +333,17 @@ class Qu {
|
|
333
333
|
*/
|
334
334
|
stateNamedEntity(u, t) {
|
335
335
|
const { decodeTree: a } = this;
|
336
|
-
let
|
336
|
+
let i = a[this.treeIndex], c = (i & N.VALUE_LENGTH) >> 14;
|
337
337
|
for (; t < u.length; t++, this.excess++) {
|
338
338
|
const s = u.charCodeAt(t);
|
339
|
-
if (this.treeIndex = Zu(a,
|
339
|
+
if (this.treeIndex = Zu(a, i, this.treeIndex + Math.max(1, c), s), this.treeIndex < 0)
|
340
340
|
return this.result === 0 || // If we are parsing an attribute
|
341
341
|
this.decodeMode === A.Attribute && // We shouldn't have consumed any characters after the entity,
|
342
|
-
(
|
342
|
+
(c === 0 || // And there should be no invalid characters.
|
343
343
|
Wu(s)) ? 0 : this.emitNotTerminatedNamedEntity();
|
344
|
-
if (
|
344
|
+
if (i = a[this.treeIndex], c = (i & N.VALUE_LENGTH) >> 14, c !== 0) {
|
345
345
|
if (s === y.SEMI)
|
346
|
-
return this.emitNamedEntityData(this.treeIndex,
|
346
|
+
return this.emitNamedEntityData(this.treeIndex, c, this.consumed + this.excess);
|
347
347
|
this.decodeMode !== A.Strict && (this.result = this.treeIndex, this.consumed += this.excess, this.excess = 0);
|
348
348
|
}
|
349
349
|
}
|
@@ -356,8 +356,8 @@ class Qu {
|
|
356
356
|
*/
|
357
357
|
emitNotTerminatedNamedEntity() {
|
358
358
|
var u;
|
359
|
-
const { result: t, decodeTree: a } = this,
|
360
|
-
return this.emitNamedEntityData(t,
|
359
|
+
const { result: t, decodeTree: a } = this, i = (a[t] & N.VALUE_LENGTH) >> 14;
|
360
|
+
return this.emitNamedEntityData(t, i, this.consumed), (u = this.errors) === null || u === void 0 || u.missingSemicolonAfterCharacterReference(), this.consumed;
|
361
361
|
}
|
362
362
|
/**
|
363
363
|
* Emit a named entity.
|
@@ -369,8 +369,8 @@ class Qu {
|
|
369
369
|
* @returns The number of characters consumed.
|
370
370
|
*/
|
371
371
|
emitNamedEntityData(u, t, a) {
|
372
|
-
const { decodeTree:
|
373
|
-
return this.emitCodePoint(t === 1 ?
|
372
|
+
const { decodeTree: i } = this;
|
373
|
+
return this.emitCodePoint(t === 1 ? i[u] & ~N.VALUE_LENGTH : i[u + 1], a), t === 3 && this.emitCodePoint(i[u + 2], a), a;
|
374
374
|
}
|
375
375
|
/**
|
376
376
|
* Signal to the parser that the end of the input was reached.
|
@@ -397,14 +397,14 @@ class Qu {
|
|
397
397
|
}
|
398
398
|
}
|
399
399
|
function Zu(e, u, t, a) {
|
400
|
-
const
|
401
|
-
if (
|
402
|
-
return
|
403
|
-
if (
|
404
|
-
const d = a -
|
405
|
-
return d < 0 || d >=
|
406
|
-
}
|
407
|
-
let s = t, n = s +
|
400
|
+
const i = (u & N.BRANCH_LENGTH) >> 7, c = u & N.JUMP_TABLE;
|
401
|
+
if (i === 0)
|
402
|
+
return c !== 0 && a === c ? t : -1;
|
403
|
+
if (c) {
|
404
|
+
const d = a - c;
|
405
|
+
return d < 0 || d >= i ? -1 : e[t + d] - 1;
|
406
|
+
}
|
407
|
+
let s = t, n = s + i - 1;
|
408
408
|
for (; s <= n; ) {
|
409
409
|
const d = s + n >>> 1, b = e[d];
|
410
410
|
if (b < a)
|
@@ -412,7 +412,7 @@ function Zu(e, u, t, a) {
|
|
412
412
|
else if (b > a)
|
413
413
|
n = d - 1;
|
414
414
|
else
|
415
|
-
return e[d +
|
415
|
+
return e[d + i];
|
416
416
|
}
|
417
417
|
return -1;
|
418
418
|
}
|
@@ -468,7 +468,7 @@ const p = {
|
|
468
468
|
};
|
469
469
|
class Yu {
|
470
470
|
constructor({ xmlMode: u = !1, decodeEntities: t = !0 }, a) {
|
471
|
-
this.cbs = a, this.state = r.Text, this.buffer = "", this.sectionStart = 0, this.index = 0, this.entityStart = 0, this.baseState = r.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 Qu(u ? Hu : ju, (
|
471
|
+
this.cbs = a, this.state = r.Text, this.buffer = "", this.sectionStart = 0, this.index = 0, this.entityStart = 0, this.baseState = r.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 Qu(u ? Hu : ju, (i, c) => this.emitCodePoint(i, c));
|
472
472
|
}
|
473
473
|
reset() {
|
474
474
|
this.state = r.Text, this.buffer = "", this.sectionStart = 0, this.index = 0, this.baseState = r.Text, this.currentSequence = void 0, this.running = !0, this.offset = 0;
|
@@ -798,19 +798,19 @@ const k = /* @__PURE__ */ new Set([
|
|
798
798
|
"button",
|
799
799
|
"datalist",
|
800
800
|
"textarea"
|
801
|
-
]),
|
801
|
+
]), m = /* @__PURE__ */ new Set(["p"]), Y = /* @__PURE__ */ new Set(["thead", "tbody"]), uu = /* @__PURE__ */ new Set(["dd", "dt"]), eu = /* @__PURE__ */ new Set(["rt", "rp"]), u0 = /* @__PURE__ */ new Map([
|
802
802
|
["tr", /* @__PURE__ */ new Set(["tr", "th", "td"])],
|
803
803
|
["th", /* @__PURE__ */ new Set(["th"])],
|
804
804
|
["td", /* @__PURE__ */ new Set(["thead", "th", "td"])],
|
805
805
|
["body", /* @__PURE__ */ new Set(["head", "link", "script"])],
|
806
806
|
["li", /* @__PURE__ */ new Set(["li"])],
|
807
|
-
["p",
|
808
|
-
["h1",
|
809
|
-
["h2",
|
810
|
-
["h3",
|
811
|
-
["h4",
|
812
|
-
["h5",
|
813
|
-
["h6",
|
807
|
+
["p", m],
|
808
|
+
["h1", m],
|
809
|
+
["h2", m],
|
810
|
+
["h3", m],
|
811
|
+
["h4", m],
|
812
|
+
["h5", m],
|
813
|
+
["h6", m],
|
814
814
|
["select", k],
|
815
815
|
["input", k],
|
816
816
|
["output", k],
|
@@ -821,27 +821,27 @@ const k = /* @__PURE__ */ new Set([
|
|
821
821
|
["optgroup", /* @__PURE__ */ new Set(["optgroup", "option"])],
|
822
822
|
["dd", uu],
|
823
823
|
["dt", uu],
|
824
|
-
["address",
|
825
|
-
["article",
|
826
|
-
["aside",
|
827
|
-
["blockquote",
|
828
|
-
["details",
|
829
|
-
["div",
|
830
|
-
["dl",
|
831
|
-
["fieldset",
|
832
|
-
["figcaption",
|
833
|
-
["figure",
|
834
|
-
["footer",
|
835
|
-
["form",
|
836
|
-
["header",
|
837
|
-
["hr",
|
838
|
-
["main",
|
839
|
-
["nav",
|
840
|
-
["ol",
|
841
|
-
["pre",
|
842
|
-
["section",
|
843
|
-
["table",
|
844
|
-
["ul",
|
824
|
+
["address", m],
|
825
|
+
["article", m],
|
826
|
+
["aside", m],
|
827
|
+
["blockquote", m],
|
828
|
+
["details", m],
|
829
|
+
["div", m],
|
830
|
+
["dl", m],
|
831
|
+
["fieldset", m],
|
832
|
+
["figcaption", m],
|
833
|
+
["figure", m],
|
834
|
+
["footer", m],
|
835
|
+
["form", m],
|
836
|
+
["header", m],
|
837
|
+
["hr", m],
|
838
|
+
["main", m],
|
839
|
+
["nav", m],
|
840
|
+
["ol", m],
|
841
|
+
["pre", m],
|
842
|
+
["section", m],
|
843
|
+
["table", m],
|
844
|
+
["ul", m],
|
845
845
|
["rt", eu],
|
846
846
|
["rp", eu],
|
847
847
|
["tbody", Y],
|
@@ -879,20 +879,20 @@ const k = /* @__PURE__ */ new Set([
|
|
879
879
|
]), t0 = /\s|\//;
|
880
880
|
class a0 {
|
881
881
|
constructor(u, t = {}) {
|
882
|
-
var a,
|
883
|
-
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 = (
|
882
|
+
var a, i, c, s, n, d;
|
883
|
+
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 : Yu)(this.options, this), this.foreignContext = [!this.htmlMode], (d = (n = this.cbs).onparserinit) === null || d === void 0 || d.call(n, this);
|
884
884
|
}
|
885
885
|
// Tokenizer event handlers
|
886
886
|
/** @internal */
|
887
887
|
ontext(u, t) {
|
888
|
-
var a,
|
889
|
-
const
|
890
|
-
this.endIndex = t - 1, (
|
888
|
+
var a, i;
|
889
|
+
const c = this.getSlice(u, t);
|
890
|
+
this.endIndex = t - 1, (i = (a = this.cbs).ontext) === null || i === void 0 || i.call(a, c), this.startIndex = t;
|
891
891
|
}
|
892
892
|
/** @internal */
|
893
893
|
ontextentity(u, t) {
|
894
|
-
var a,
|
895
|
-
this.endIndex = t - 1, (
|
894
|
+
var a, i;
|
895
|
+
this.endIndex = t - 1, (i = (a = this.cbs).ontext) === null || i === void 0 || i.call(a, K(u)), this.startIndex = t;
|
896
896
|
}
|
897
897
|
/**
|
898
898
|
* Checks if the current tag is a void element. Override this if you want
|
@@ -908,7 +908,7 @@ class a0 {
|
|
908
908
|
this.lowerCaseTagNames && (a = a.toLowerCase()), this.emitOpenTag(a);
|
909
909
|
}
|
910
910
|
emitOpenTag(u) {
|
911
|
-
var t, a,
|
911
|
+
var t, a, i, c;
|
912
912
|
this.openTagStart = this.startIndex, this.tagname = u;
|
913
913
|
const s = this.htmlMode && u0.get(u);
|
914
914
|
if (s)
|
@@ -916,7 +916,7 @@ class a0 {
|
|
916
916
|
const n = this.stack.shift();
|
917
917
|
(a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t, n, !0);
|
918
918
|
}
|
919
|
-
this.isVoidElement(u) || (this.stack.unshift(u), this.htmlMode && (tu.has(u) ? this.foreignContext.unshift(!0) : au.has(u) && this.foreignContext.unshift(!1))), (
|
919
|
+
this.isVoidElement(u) || (this.stack.unshift(u), this.htmlMode && (tu.has(u) ? this.foreignContext.unshift(!0) : au.has(u) && this.foreignContext.unshift(!1))), (c = (i = this.cbs).onopentagname) === null || c === void 0 || c.call(i, u), this.cbs.onopentag && (this.attribs = {});
|
920
920
|
}
|
921
921
|
endOpenTag(u) {
|
922
922
|
var t, a;
|
@@ -928,17 +928,17 @@ class a0 {
|
|
928
928
|
}
|
929
929
|
/** @internal */
|
930
930
|
onclosetag(u, t) {
|
931
|
-
var a,
|
931
|
+
var a, i, c, s, n, d, b, h;
|
932
932
|
this.endIndex = t;
|
933
933
|
let o = this.getSlice(u, t);
|
934
934
|
if (this.lowerCaseTagNames && (o = o.toLowerCase()), this.htmlMode && (tu.has(o) || au.has(o)) && this.foreignContext.shift(), this.isVoidElement(o))
|
935
|
-
this.htmlMode && o === "br" && ((s = (
|
935
|
+
this.htmlMode && o === "br" && ((s = (c = this.cbs).onopentagname) === null || s === void 0 || s.call(c, "br"), (d = (n = this.cbs).onopentag) === null || d === void 0 || d.call(n, "br", {}, !0), (h = (b = this.cbs).onclosetag) === null || h === void 0 || h.call(b, "br", !1));
|
936
936
|
else {
|
937
937
|
const S = this.stack.indexOf(o);
|
938
938
|
if (S !== -1)
|
939
939
|
for (let x = 0; x <= S; x++) {
|
940
|
-
const
|
941
|
-
(
|
940
|
+
const E = this.stack.shift();
|
941
|
+
(i = (a = this.cbs).onclosetag) === null || i === void 0 || i.call(a, E, x !== S);
|
942
942
|
}
|
943
943
|
else this.htmlMode && o === "p" && (this.emitOpenTag("p"), this.closeCurrentTag(!0));
|
944
944
|
}
|
@@ -950,8 +950,8 @@ class a0 {
|
|
950
950
|
}
|
951
951
|
closeCurrentTag(u) {
|
952
952
|
var t, a;
|
953
|
-
const
|
954
|
-
this.endOpenTag(u), this.stack[0] ===
|
953
|
+
const i = this.tagname;
|
954
|
+
this.endOpenTag(u), this.stack[0] === i && ((a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t, i, !u), this.stack.shift());
|
955
955
|
}
|
956
956
|
/** @internal */
|
957
957
|
onattribname(u, t) {
|
@@ -969,8 +969,8 @@ class a0 {
|
|
969
969
|
}
|
970
970
|
/** @internal */
|
971
971
|
onattribend(u, t) {
|
972
|
-
var a,
|
973
|
-
this.endIndex = t, (
|
972
|
+
var a, i;
|
973
|
+
this.endIndex = t, (i = (a = this.cbs).onattribute) === null || i === void 0 || i.call(a, this.attribname, this.attribvalue, u === T.Double ? '"' : u === T.Single ? "'" : u === T.NoValue ? void 0 : null), this.attribs && !Object.prototype.hasOwnProperty.call(this.attribs, this.attribname) && (this.attribs[this.attribname] = this.attribvalue), this.attribvalue = "";
|
974
974
|
}
|
975
975
|
getInstructionName(u) {
|
976
976
|
const t = u.search(t0);
|
@@ -982,8 +982,8 @@ class a0 {
|
|
982
982
|
this.endIndex = t;
|
983
983
|
const a = this.getSlice(u, t);
|
984
984
|
if (this.cbs.onprocessinginstruction) {
|
985
|
-
const
|
986
|
-
this.cbs.onprocessinginstruction(`!${
|
985
|
+
const i = this.getInstructionName(a);
|
986
|
+
this.cbs.onprocessinginstruction(`!${i}`, `!${a}`);
|
987
987
|
}
|
988
988
|
this.startIndex = t + 1;
|
989
989
|
}
|
@@ -992,22 +992,22 @@ class a0 {
|
|
992
992
|
this.endIndex = t;
|
993
993
|
const a = this.getSlice(u, t);
|
994
994
|
if (this.cbs.onprocessinginstruction) {
|
995
|
-
const
|
996
|
-
this.cbs.onprocessinginstruction(`?${
|
995
|
+
const i = this.getInstructionName(a);
|
996
|
+
this.cbs.onprocessinginstruction(`?${i}`, `?${a}`);
|
997
997
|
}
|
998
998
|
this.startIndex = t + 1;
|
999
999
|
}
|
1000
1000
|
/** @internal */
|
1001
1001
|
oncomment(u, t, a) {
|
1002
|
-
var
|
1003
|
-
this.endIndex = t, (
|
1002
|
+
var i, c, s, n;
|
1003
|
+
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;
|
1004
1004
|
}
|
1005
1005
|
/** @internal */
|
1006
1006
|
oncdata(u, t, a) {
|
1007
|
-
var
|
1007
|
+
var i, c, s, n, d, b, h, o, S, x;
|
1008
1008
|
this.endIndex = t;
|
1009
|
-
const
|
1010
|
-
!this.htmlMode || this.options.recognizeCDATA ? ((
|
1009
|
+
const E = this.getSlice(u, t - a);
|
1010
|
+
!this.htmlMode || this.options.recognizeCDATA ? ((c = (i = this.cbs).oncdatastart) === null || c === void 0 || c.call(i), (n = (s = this.cbs).ontext) === null || n === void 0 || n.call(s, E), (b = (d = this.cbs).oncdataend) === null || b === void 0 || b.call(d)) : ((o = (h = this.cbs).oncomment) === null || o === void 0 || o.call(h, `[CDATA[${E}]]`), (x = (S = this.cbs).oncommentend) === null || x === void 0 || x.call(S)), this.startIndex = t + 1;
|
1011
1011
|
}
|
1012
1012
|
/** @internal */
|
1013
1013
|
onend() {
|
@@ -1023,8 +1023,8 @@ class a0 {
|
|
1023
1023
|
* Resets the parser to a blank state, ready to parse a new HTML document
|
1024
1024
|
*/
|
1025
1025
|
reset() {
|
1026
|
-
var u, t, a,
|
1027
|
-
(t = (u = this.cbs).onreset) === null || t === void 0 || t.call(u), this.tokenizer.reset(), this.tagname = "", this.attribname = "", this.attribs = null, this.stack.length = 0, this.startIndex = 0, this.endIndex = 0, (
|
1026
|
+
var u, t, a, i;
|
1027
|
+
(t = (u = this.cbs).onreset) === null || t === void 0 || t.call(u), this.tokenizer.reset(), this.tagname = "", this.attribname = "", this.attribs = null, this.stack.length = 0, this.startIndex = 0, this.endIndex = 0, (i = (a = this.cbs).onparserinit) === null || i === void 0 || i.call(a, this), this.buffers.length = 0, this.foreignContext.length = 0, this.foreignContext.unshift(!this.htmlMode), this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1;
|
1028
1028
|
}
|
1029
1029
|
/**
|
1030
1030
|
* Resets the parser, then parses a complete document and
|
@@ -1105,49 +1105,53 @@ class a0 {
|
|
1105
1105
|
this.end(u);
|
1106
1106
|
}
|
1107
1107
|
}
|
1108
|
-
function
|
1109
|
-
|
1110
|
-
|
1108
|
+
function iu(e) {
|
1109
|
+
const u = { name: "", children: [] }, t = [u];
|
1110
|
+
let a = "";
|
1111
|
+
const i = new a0(
|
1111
1112
|
{
|
1112
|
-
onopentag: (c,
|
1113
|
-
const
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1113
|
+
onopentag: (c, s, n) => {
|
1114
|
+
const d = t[t.length - 1];
|
1115
|
+
a.trim() && (Array.isArray(d.children) ? d.children.push({
|
1116
|
+
name: "text",
|
1117
|
+
children: a.trim()
|
1118
|
+
}) : d.children = a.trim(), a = "");
|
1119
|
+
const b = Object.entries(s || {}).reduce(
|
1120
|
+
(o, S) => {
|
1121
|
+
let [x = "", E = ""] = S;
|
1122
|
+
return x = x.replace(/\\\"/g, ""), E = E.replace(/\\\"/g, ""), x && (o[x] = E), o;
|
1117
1123
|
},
|
1118
1124
|
{}
|
1119
|
-
),
|
1125
|
+
), h = {
|
1120
1126
|
name: c,
|
1121
|
-
props:
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1127
|
+
props: b
|
1128
|
+
};
|
1129
|
+
Array.isArray(d.children) ? d.children.push(h) : d.children = [
|
1130
|
+
{
|
1131
|
+
name: "span",
|
1132
|
+
children: d.children
|
1133
|
+
},
|
1134
|
+
h
|
1135
|
+
], n || t.push(h);
|
1125
1136
|
},
|
1126
1137
|
ontext: (c) => {
|
1127
|
-
const
|
1128
|
-
|
1129
|
-
const s = t[t.length - 1];
|
1130
|
-
s.children ? (s.children = [
|
1131
|
-
{
|
1132
|
-
name: "span",
|
1133
|
-
children: s.children
|
1134
|
-
}
|
1135
|
-
], s.children.push({
|
1136
|
-
name: "span",
|
1137
|
-
children: i
|
1138
|
-
})) : s.children = i;
|
1139
|
-
}
|
1138
|
+
const s = c.trim();
|
1139
|
+
s && s !== '"' && (a += s);
|
1140
1140
|
},
|
1141
1141
|
onclosetag: () => {
|
1142
|
-
t.pop();
|
1142
|
+
const c = t.pop();
|
1143
|
+
a.trim() && (Array.isArray(c?.children) ? c.children.push({
|
1144
|
+
name: "span",
|
1145
|
+
children: a.trim()
|
1146
|
+
}) : c && (c.children = a.trim()), a = "");
|
1143
1147
|
}
|
1144
1148
|
},
|
1145
|
-
{
|
1149
|
+
{ decodeEntities: !0 }
|
1146
1150
|
);
|
1147
|
-
return
|
1151
|
+
return i.write(e), i.end(), u.children || [];
|
1148
1152
|
}
|
1149
1153
|
let F = [], P = {}, du = {}, fu = {};
|
1150
|
-
function
|
1154
|
+
function i0(e, u, t = "", a) {
|
1151
1155
|
return F = [], P = {}, du = a?.handlers || {}, fu = a?.styles || {}, {
|
1152
1156
|
nodes: (ku({
|
1153
1157
|
id: e,
|
@@ -1160,12 +1164,12 @@ function c0(e, u, t = "", a) {
|
|
1160
1164
|
context: P
|
1161
1165
|
};
|
1162
1166
|
}
|
1163
|
-
function
|
1167
|
+
function c0(e) {
|
1164
1168
|
if (e.name === "slot") {
|
1165
1169
|
let u = "default";
|
1166
1170
|
const t = [];
|
1167
|
-
for (const [a,
|
1168
|
-
a === "name" ? u =
|
1171
|
+
for (const [a, i] of Object.entries(e.props || {}))
|
1172
|
+
a === "name" ? u = i : t.push(a);
|
1169
1173
|
F.push({
|
1170
1174
|
name: u,
|
1171
1175
|
params: t
|
@@ -1174,8 +1178,8 @@ function i0(e) {
|
|
1174
1178
|
}
|
1175
1179
|
function s0(e) {
|
1176
1180
|
return e.replace(/\s+/g, " ").split(";").reduce((t, a) => {
|
1177
|
-
const [
|
1178
|
-
return
|
1181
|
+
const [i, c] = a.split(":").map((s) => s.trim());
|
1182
|
+
return i && c && (t[i] = c), t;
|
1179
1183
|
}, {});
|
1180
1184
|
}
|
1181
1185
|
function r0(e) {
|
@@ -1183,14 +1187,14 @@ function r0(e) {
|
|
1183
1187
|
for (const t of e) {
|
1184
1188
|
if (t.type === l.ATTRIBUTE)
|
1185
1189
|
if (t.name === "class") {
|
1186
|
-
const a = t.value?.content || "",
|
1190
|
+
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((d) => d !== c), n = fu[`.${c}`];
|
1187
1191
|
n && (u.style = n), s.length && (u.class = s.join(" "));
|
1188
1192
|
} else if (t.name === "style") {
|
1189
1193
|
const a = t.value?.content || "";
|
1190
1194
|
a && (u.style = s0(a));
|
1191
1195
|
} else
|
1192
1196
|
u[t.name] = t.value?.content || "";
|
1193
|
-
t.type === l.DIRECTIVE && t.name === "bind" && (t.exp?.type === l.SIMPLE_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION && (u[t.arg.content] =
|
1197
|
+
t.type === l.DIRECTIVE && t.name === "bind" && (t.exp?.type === l.SIMPLE_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION && (u[t.arg.content] = v(`(${t.exp.content})`)), t.exp?.type === l.COMPOUND_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION && (u[t.arg.content] = v(`(${t.exp.loc.source})`)));
|
1194
1198
|
}
|
1195
1199
|
return u;
|
1196
1200
|
}
|
@@ -1198,25 +1202,25 @@ function n0(e, u = {}) {
|
|
1198
1202
|
const t = {};
|
1199
1203
|
for (const a of e)
|
1200
1204
|
if (a.type === l.DIRECTIVE && a.name === "on" && a.arg?.type === l.SIMPLE_EXPRESSION) {
|
1201
|
-
const
|
1202
|
-
(
|
1205
|
+
const i = a.modifiers.reduce(
|
1206
|
+
(h, o) => (h[o.content] = !0, h),
|
1203
1207
|
{}
|
1204
1208
|
);
|
1205
|
-
let
|
1206
|
-
/\)$/.test(
|
1207
|
-
const n = new RegExp(`${a.arg.content}_[\\w]{5,}`), d =
|
1209
|
+
let c = a.exp?.loc.source || "";
|
1210
|
+
/\)$/.test(c) && (c = `($event) => ${c}`);
|
1211
|
+
const n = new RegExp(`${a.arg.content}_[\\w]{5,}`), d = c.match(n)?.[0] || "", b = u[d];
|
1208
1212
|
if (d && b)
|
1209
1213
|
t[a.arg.content] = {
|
1210
1214
|
name: a.arg.content,
|
1211
1215
|
handler: b,
|
1212
|
-
modifiers:
|
1216
|
+
modifiers: i
|
1213
1217
|
};
|
1214
1218
|
else {
|
1215
|
-
const
|
1219
|
+
const h = a.exp?.ast?.type === "AssignmentExpression";
|
1216
1220
|
t[a.arg.content] = {
|
1217
1221
|
name: a.arg.content,
|
1218
|
-
handler: C(
|
1219
|
-
modifiers:
|
1222
|
+
handler: C(h ? `()=> {${c}}` : `(${c})`),
|
1223
|
+
modifiers: i
|
1220
1224
|
};
|
1221
1225
|
}
|
1222
1226
|
}
|
@@ -1228,12 +1232,12 @@ function d0(e) {
|
|
1228
1232
|
const t = e.codegenNode?.test;
|
1229
1233
|
t && u.push({
|
1230
1234
|
name: "vIf",
|
1231
|
-
value:
|
1235
|
+
value: v(t.loc.source)
|
1232
1236
|
});
|
1233
1237
|
}
|
1234
1238
|
if (e.type === l.FOR && u.push({
|
1235
1239
|
name: "vFor",
|
1236
|
-
value:
|
1240
|
+
value: v(e.source.loc.source),
|
1237
1241
|
iterator: {
|
1238
1242
|
item: e.valueAlias?.loc.source || "item",
|
1239
1243
|
index: e.keyAlias?.loc.source || "index"
|
@@ -1246,35 +1250,35 @@ function d0(e) {
|
|
1246
1250
|
u.push({
|
1247
1251
|
name: "vModel",
|
1248
1252
|
arg: n.arg?.content,
|
1249
|
-
value:
|
1253
|
+
value: v(n.exp?.loc.source || "")
|
1250
1254
|
});
|
1251
1255
|
});
|
1252
|
-
const
|
1253
|
-
|
1256
|
+
const i = t.find((n) => n.name === "show");
|
1257
|
+
i && u.push({
|
1254
1258
|
name: "vShow",
|
1255
|
-
value:
|
1259
|
+
value: v(i.exp?.loc.source || "")
|
1256
1260
|
});
|
1257
|
-
const
|
1258
|
-
|
1261
|
+
const c = t.find((n) => n.name === "bind" && !n.arg);
|
1262
|
+
c && u.push({
|
1259
1263
|
name: "vBind",
|
1260
|
-
value:
|
1264
|
+
value: v(c.exp?.loc.source || "")
|
1261
1265
|
});
|
1262
1266
|
const s = t.find((n) => n.name === "html");
|
1263
1267
|
s && u.push({
|
1264
1268
|
name: "vHtml",
|
1265
|
-
value:
|
1269
|
+
value: v(s.exp?.loc.source || "")
|
1266
1270
|
});
|
1267
1271
|
}
|
1268
1272
|
return u;
|
1269
1273
|
}
|
1270
1274
|
function ou(e) {
|
1271
1275
|
let u = "";
|
1272
|
-
const { name: t, props: a, events:
|
1273
|
-
if (typeof
|
1274
|
-
const s = new RegExp(`${t}_([\\w]+)`), n =
|
1276
|
+
const { name: t, props: a, events: i = {} } = e, c = a?.class || "";
|
1277
|
+
if (typeof c == "string") {
|
1278
|
+
const s = new RegExp(`${t}_([\\w]+)`), n = c.match(s);
|
1275
1279
|
n && n[1] && (u = n[1]);
|
1276
1280
|
}
|
1277
|
-
for (const { name: s, handler: n } of Object.values(
|
1281
|
+
for (const { name: s, handler: n } of Object.values(i)) {
|
1278
1282
|
const d = new RegExp(`${s}_([\\w]+)`), b = n.value.match(d);
|
1279
1283
|
b && b[1] && (u = b[1]);
|
1280
1284
|
}
|
@@ -1282,17 +1286,17 @@ function ou(e) {
|
|
1282
1286
|
}
|
1283
1287
|
function j(e, u) {
|
1284
1288
|
const t = new Set(u?.id ? P[u.id] : []), a = (e.directives || []).find((s) => s.name === "vFor");
|
1285
|
-
let
|
1289
|
+
let i = new Set(Array.from(t));
|
1286
1290
|
if (a) {
|
1287
1291
|
const { item: s = "item", index: n = "index" } = a.iterator || {};
|
1288
|
-
|
1292
|
+
i = /* @__PURE__ */ new Set([s, n, ...Array.from(i)]);
|
1289
1293
|
}
|
1290
|
-
const
|
1291
|
-
if (
|
1292
|
-
const s = typeof
|
1293
|
-
|
1294
|
+
const c = e.slot;
|
1295
|
+
if (c) {
|
1296
|
+
const s = typeof c == "string" ? [] : c.params || [], n = s.length ? s : [`scope_${u?.id}`];
|
1297
|
+
i = /* @__PURE__ */ new Set([...n, ...Array.from(i)]);
|
1294
1298
|
}
|
1295
|
-
P[e.id] =
|
1299
|
+
P[e.id] = i;
|
1296
1300
|
}
|
1297
1301
|
function U(e, u, t) {
|
1298
1302
|
const a = {
|
@@ -1302,8 +1306,8 @@ function U(e, u, t) {
|
|
1302
1306
|
directives: d0(t || e)
|
1303
1307
|
};
|
1304
1308
|
a.id = ou(a), j(a, u);
|
1305
|
-
const
|
1306
|
-
return j(a, u),
|
1309
|
+
const i = f0(a, e.children);
|
1310
|
+
return j(a, u), c0(i), i;
|
1307
1311
|
}
|
1308
1312
|
function D(e, u) {
|
1309
1313
|
if (e.type === l.ELEMENT)
|
@@ -1318,41 +1322,41 @@ function D(e, u) {
|
|
1318
1322
|
if (t.type === l.ELEMENT)
|
1319
1323
|
return U(t, u, e);
|
1320
1324
|
}
|
1321
|
-
return e.type === l.TEXT_CALL ? e.content.type == l.TEXT ? e.content.content : e.content.type === l.INTERPOLATION ?
|
1325
|
+
return e.type === l.TEXT_CALL ? e.content.type == l.TEXT ? e.content.content : e.content.type === l.INTERPOLATION ? v(e.content.content.loc.source) : "" : e.type === l.TEXT ? e.content : e.type === l.INTERPOLATION && (e.content.type === l.SIMPLE_EXPRESSION || e.content.type === l.COMPOUND_EXPRESSION) ? v(e.content.loc.source) : (e.type === l.COMPOUND_EXPRESSION && console.warn("未处理节点", e), console.warn("未处理", e.type), null);
|
1322
1326
|
}
|
1323
1327
|
function f0(e, u = []) {
|
1324
1328
|
const t = [];
|
1325
1329
|
for (const a of u)
|
1326
1330
|
if (a.type === l.ELEMENT && a.codegenNode?.value?.arguments) {
|
1327
|
-
const
|
1328
|
-
if (
|
1329
|
-
const
|
1330
|
-
t.push(...
|
1331
|
+
const i = a.codegenNode.value.arguments[0];
|
1332
|
+
if (i) {
|
1333
|
+
const c = iu(i);
|
1334
|
+
t.push(...c);
|
1331
1335
|
}
|
1332
1336
|
} else if (a.type === l.ELEMENT && a.tag === "template") {
|
1333
|
-
const
|
1334
|
-
for (const
|
1335
|
-
const s =
|
1337
|
+
const i = a.props.find((c) => c.name === "slot");
|
1338
|
+
for (const c of a.children) {
|
1339
|
+
const s = c.type === l.TEXT || c.type === l.TEXT_CALL ? {
|
1336
1340
|
name: "span",
|
1337
|
-
children: D(
|
1338
|
-
} : D(
|
1339
|
-
s && (Vu(s) &&
|
1340
|
-
name:
|
1341
|
-
params:
|
1341
|
+
children: D(c, e)
|
1342
|
+
} : D(c, e);
|
1343
|
+
s && (Vu(s) && i?.type === l.DIRECTIVE && (s.id = ou(s), s.slot = {
|
1344
|
+
name: i.arg?.content || "default",
|
1345
|
+
params: i.exp?.identifiers || []
|
1342
1346
|
}, j(s, e)), t.push(s));
|
1343
1347
|
}
|
1344
1348
|
} else if (a.type === l.JS_CALL_EXPRESSION) {
|
1345
|
-
const
|
1346
|
-
if (
|
1347
|
-
const
|
1348
|
-
t.push(...
|
1349
|
+
const i = a.arguments?.[0];
|
1350
|
+
if (i) {
|
1351
|
+
const c = iu(i);
|
1352
|
+
t.push(...c);
|
1349
1353
|
}
|
1350
1354
|
} else if (a.type === l.TEXT_CALL) {
|
1351
|
-
const
|
1352
|
-
|
1355
|
+
const i = D(a, e);
|
1356
|
+
i && t.push(i);
|
1353
1357
|
} else {
|
1354
|
-
const
|
1355
|
-
|
1358
|
+
const i = D(a, e);
|
1359
|
+
i && t.push(i);
|
1356
1360
|
}
|
1357
1361
|
if (t.length === 1) {
|
1358
1362
|
const a = t[0];
|
@@ -1366,10 +1370,10 @@ function o0(e, u) {
|
|
1366
1370
|
imports: b0(e),
|
1367
1371
|
emits: [],
|
1368
1372
|
errors: []
|
1369
|
-
},
|
1370
|
-
return nu(
|
1371
|
-
ExportDefaultDeclaration(
|
1372
|
-
const s =
|
1373
|
+
}, i = ru(e);
|
1374
|
+
return nu(i, {
|
1375
|
+
ExportDefaultDeclaration(c) {
|
1376
|
+
const s = c.node.declaration;
|
1373
1377
|
if (s.type !== "CallExpression") return;
|
1374
1378
|
const n = s.arguments[0];
|
1375
1379
|
if (n?.type !== "ObjectExpression") return;
|
@@ -1377,10 +1381,10 @@ function o0(e, u) {
|
|
1377
1381
|
(o) => o.type === "ObjectProperty"
|
1378
1382
|
), b = n.properties.filter(
|
1379
1383
|
(o) => o.type == "ObjectMethod"
|
1380
|
-
),
|
1384
|
+
), h = d.find(
|
1381
1385
|
(o) => o.key.name === "computed"
|
1382
1386
|
);
|
1383
|
-
|
1387
|
+
h && (a.computed = bu(h.value), a.watchers = g0(h.value));
|
1384
1388
|
for (const o of d)
|
1385
1389
|
switch (o.key.name) {
|
1386
1390
|
case "name":
|
@@ -1413,8 +1417,8 @@ function o0(e, u) {
|
|
1413
1417
|
}
|
1414
1418
|
a.lifeCycles = S0(b);
|
1415
1419
|
},
|
1416
|
-
CallExpression(
|
1417
|
-
const s = w0(
|
1420
|
+
CallExpression(c) {
|
1421
|
+
const s = w0(c.node);
|
1418
1422
|
if (s.length)
|
1419
1423
|
for (let n of s)
|
1420
1424
|
a.emits?.find((b) => b.name === n.name) || a.emits?.push(n);
|
@@ -1425,10 +1429,10 @@ function b0(e) {
|
|
1425
1429
|
const u = /import\s+{(.+?)}\s+from\s+['"](.+?)['"]/g, t = [];
|
1426
1430
|
let a;
|
1427
1431
|
for (; (a = u.exec(e)) !== null; ) {
|
1428
|
-
const
|
1432
|
+
const i = a[2] === "@element-plus/icons-vue" ? "@vtj/icons" : a[2];
|
1429
1433
|
t.push({
|
1430
|
-
from:
|
1431
|
-
imports: a[1].split(",").map((
|
1434
|
+
from: i,
|
1435
|
+
imports: a[1].split(",").map((c) => c.trim())
|
1432
1436
|
});
|
1433
1437
|
}
|
1434
1438
|
return t;
|
@@ -1447,21 +1451,21 @@ function h0(e) {
|
|
1447
1451
|
if (!u) return {};
|
1448
1452
|
const t = {};
|
1449
1453
|
for (const a of u.properties) {
|
1450
|
-
const { key:
|
1451
|
-
if (
|
1452
|
-
const s = R(
|
1453
|
-
t[
|
1454
|
+
const { key: i, value: c } = a;
|
1455
|
+
if (i.type === "Identifier") {
|
1456
|
+
const s = R(c);
|
1457
|
+
t[i.name] = v(s);
|
1454
1458
|
}
|
1455
1459
|
}
|
1456
1460
|
return t;
|
1457
1461
|
}
|
1458
1462
|
function q(e) {
|
1459
|
-
const { key: u, async: t, params: a, body:
|
1463
|
+
const { key: u, async: t, params: a, body: i } = e, c = a.map((s) => s.type === "ObjectPattern" ? `{${s.properties.map((d) => d.key?.name || d.name).join(",")}}` : s.name).join(", ");
|
1460
1464
|
if (u.type === "Identifier") {
|
1461
|
-
const s = u.name, n = R(
|
1465
|
+
const s = u.name, n = R(i), b = `${t ? "async " : ""}(${c}) => ${n}`, h = s.startsWith("watcher_");
|
1462
1466
|
return {
|
1463
1467
|
name: s,
|
1464
|
-
watcher:
|
1468
|
+
watcher: h,
|
1465
1469
|
exp: C(b)
|
1466
1470
|
};
|
1467
1471
|
}
|
@@ -1477,15 +1481,15 @@ function bu(e) {
|
|
1477
1481
|
}
|
1478
1482
|
function m0(e, u) {
|
1479
1483
|
if (!e) return {};
|
1480
|
-
const t = {}, a = /apis\[\'([\w]*)\'\]/,
|
1481
|
-
for (const
|
1482
|
-
const s = q(
|
1484
|
+
const t = {}, a = /apis\[\'([\w]*)\'\]/, i = /\.then\(([\w\W]*)\)/;
|
1485
|
+
for (const c of e.properties) {
|
1486
|
+
const s = q(c);
|
1483
1487
|
if (s && s.exp.value.includes("provider.apis")) {
|
1484
1488
|
const d = (s.exp.value.match(a) || [])[1];
|
1485
1489
|
if (!d) continue;
|
1486
1490
|
const b = T0(u, d);
|
1487
1491
|
if (!b) continue;
|
1488
|
-
const
|
1492
|
+
const h = s.exp.value.match(i)?.[1];
|
1489
1493
|
t[s.name] = {
|
1490
1494
|
ref: d,
|
1491
1495
|
name: b.name,
|
@@ -1499,7 +1503,7 @@ function m0(e, u) {
|
|
1499
1503
|
label: b.label,
|
1500
1504
|
transform: {
|
1501
1505
|
type: "JSFunction",
|
1502
|
-
value:
|
1506
|
+
value: h || `(res) => {
|
1503
1507
|
return res;
|
1504
1508
|
}`
|
1505
1509
|
},
|
@@ -1511,26 +1515,26 @@ function m0(e, u) {
|
|
1511
1515
|
}
|
1512
1516
|
function x0(e) {
|
1513
1517
|
const u = bu(e), t = /\_([\w]{5,})$/, a = {};
|
1514
|
-
for (const
|
1515
|
-
t.test(
|
1518
|
+
for (const i of Object.keys(u))
|
1519
|
+
t.test(i) || (a[i] = u[i]);
|
1516
1520
|
return a;
|
1517
1521
|
}
|
1518
1522
|
function p0(e) {
|
1519
1523
|
if (!e) return {};
|
1520
1524
|
const u = {}, t = /\_([\w]{5,})$/;
|
1521
1525
|
for (const a of e.properties) {
|
1522
|
-
const
|
1523
|
-
if (t.test(
|
1526
|
+
const i = a.key.name;
|
1527
|
+
if (t.test(i))
|
1524
1528
|
try {
|
1525
1529
|
if (a.body.body[0]?.argument) {
|
1526
|
-
const
|
1530
|
+
const c = R(
|
1527
1531
|
a.body.body[0].argument.callee.object
|
1528
1532
|
);
|
1529
|
-
u[
|
1533
|
+
u[i] = C(c);
|
1530
1534
|
} else
|
1531
|
-
u[
|
1532
|
-
} catch (
|
1533
|
-
console.warn(
|
1535
|
+
u[i] = q(a)?.exp;
|
1536
|
+
} catch (c) {
|
1537
|
+
console.warn(c);
|
1534
1538
|
}
|
1535
1539
|
}
|
1536
1540
|
return u;
|
@@ -1552,7 +1556,7 @@ function lu(e, u) {
|
|
1552
1556
|
(a) => a.key?.name === u
|
1553
1557
|
)?.value?.value;
|
1554
1558
|
}
|
1555
|
-
function
|
1559
|
+
function cu(e, u) {
|
1556
1560
|
const t = e.find(
|
1557
1561
|
(a) => a.key?.name === u
|
1558
1562
|
);
|
@@ -1562,14 +1566,14 @@ function iu(e, u) {
|
|
1562
1566
|
function y0(e, u = {}) {
|
1563
1567
|
const t = [];
|
1564
1568
|
for (const a of e.properties) {
|
1565
|
-
const { key:
|
1569
|
+
const { key: i, value: c } = a, s = i.value || i.name || "";
|
1566
1570
|
if (u[s]) {
|
1567
|
-
const n =
|
1571
|
+
const n = c.properties;
|
1568
1572
|
t.push({
|
1569
1573
|
source: u[s],
|
1570
1574
|
deep: B(n, "deep"),
|
1571
1575
|
immediate: B(n, "immediate"),
|
1572
|
-
handler:
|
1576
|
+
handler: cu(n, "handler")
|
1573
1577
|
});
|
1574
1578
|
} else if (a.type === "ObjectMethod" && t.push({
|
1575
1579
|
// todo: 处理上下文
|
@@ -1581,7 +1585,7 @@ function y0(e, u = {}) {
|
|
1581
1585
|
immediate: !1,
|
1582
1586
|
handler: q(a)?.exp
|
1583
1587
|
}), a.type === "ObjectProperty") {
|
1584
|
-
const n =
|
1588
|
+
const n = c.properties;
|
1585
1589
|
t.push({
|
1586
1590
|
// todo: 处理上下文
|
1587
1591
|
source: {
|
@@ -1590,7 +1594,7 @@ function y0(e, u = {}) {
|
|
1590
1594
|
},
|
1591
1595
|
deep: B(n, "deep"),
|
1592
1596
|
immediate: B(n, "immediate"),
|
1593
|
-
handler:
|
1597
|
+
handler: cu(n, "handler")
|
1594
1598
|
});
|
1595
1599
|
}
|
1596
1600
|
}
|
@@ -1601,8 +1605,8 @@ function S0(e) {
|
|
1601
1605
|
for (const t of e) {
|
1602
1606
|
const a = t.key.name;
|
1603
1607
|
if (Pu.includes(a)) {
|
1604
|
-
const
|
1605
|
-
|
1608
|
+
const i = q(t);
|
1609
|
+
i && (u[i.name] = i.exp);
|
1606
1610
|
}
|
1607
1611
|
}
|
1608
1612
|
return u;
|
@@ -1619,30 +1623,30 @@ function hu(e) {
|
|
1619
1623
|
(t) => t.key?.name === "default"
|
1620
1624
|
);
|
1621
1625
|
if (u)
|
1622
|
-
return
|
1626
|
+
return v(R(u.value));
|
1623
1627
|
}
|
1624
1628
|
function v0(e) {
|
1625
1629
|
if (!e) return [];
|
1626
1630
|
let u = [];
|
1627
1631
|
return e.type === "ArrayExpression" ? u = e.elements.map((t) => t.value) : e.type === "ObjectExpression" && (u = e.properties.map((t) => {
|
1628
|
-
const { key: a, value:
|
1632
|
+
const { key: a, value: i } = t, c = i.properties || [];
|
1629
1633
|
return {
|
1630
1634
|
name: a.name,
|
1631
|
-
required: B(
|
1632
|
-
type: E0(
|
1633
|
-
default: hu(
|
1635
|
+
required: B(c, "required"),
|
1636
|
+
type: E0(c),
|
1637
|
+
default: hu(c)
|
1634
1638
|
};
|
1635
1639
|
})), u;
|
1636
1640
|
}
|
1637
1641
|
function w0(e) {
|
1638
1642
|
const u = [];
|
1639
1643
|
if (e.callee.type === "MemberExpression" && e.callee.property?.name === "$emit") {
|
1640
|
-
const [a, ...
|
1641
|
-
(
|
1644
|
+
const [a, ...i] = (e.arguments || []).map(
|
1645
|
+
(c) => c.value || c.name
|
1642
1646
|
);
|
1643
1647
|
a && u.push({
|
1644
1648
|
name: a,
|
1645
|
-
params:
|
1649
|
+
params: i
|
1646
1650
|
});
|
1647
1651
|
}
|
1648
1652
|
return u;
|
@@ -1650,7 +1654,7 @@ function w0(e) {
|
|
1650
1654
|
function A0(e) {
|
1651
1655
|
let u = [];
|
1652
1656
|
return e.type === "ObjectExpression" && (u = e.properties.map((t) => {
|
1653
|
-
const { key: a, value:
|
1657
|
+
const { key: a, value: i } = t, c = i.properties, s = a.name, n = lu(c, "from"), d = hu(c);
|
1654
1658
|
return {
|
1655
1659
|
name: s,
|
1656
1660
|
from: n || s,
|
@@ -1664,16 +1668,16 @@ function T0(e, u) {
|
|
1664
1668
|
function I0(e) {
|
1665
1669
|
const u = [], t = {}, a = [];
|
1666
1670
|
try {
|
1667
|
-
const
|
1668
|
-
for (const s of
|
1671
|
+
const i = Ru.parse(e), c = /^.[\w]+_[\w]{5,}/;
|
1672
|
+
for (const s of i.nodes)
|
1669
1673
|
if (s.type === "rule") {
|
1670
1674
|
const n = {};
|
1671
|
-
|
1675
|
+
c.test(s.selector) ? (s.nodes.forEach((d) => {
|
1672
1676
|
d.type === "decl" && (n[d.prop] = d.value);
|
1673
1677
|
}), t[s.selector] = n) : a.push(s.toString());
|
1674
1678
|
}
|
1675
|
-
} catch (
|
1676
|
-
u.push(`css解析出错了,错误信息:[ ${
|
1679
|
+
} catch (i) {
|
1680
|
+
u.push(`css解析出错了,错误信息:[ ${i.message} ]
|
1677
1681
|
`);
|
1678
1682
|
}
|
1679
1683
|
return {
|
@@ -1684,19 +1688,19 @@ function I0(e) {
|
|
1684
1688
|
};
|
1685
1689
|
}
|
1686
1690
|
async function j0(e) {
|
1687
|
-
const u = [], { id: t, name: a, source:
|
1688
|
-
if (Fu(
|
1691
|
+
const u = [], { id: t, name: a, source: i, project: c } = e;
|
1692
|
+
if (Fu(i))
|
1689
1693
|
return u.push("style的lang不能是scss, 请改为css"), Promise.reject(u);
|
1690
|
-
const { dependencies: s = [] } =
|
1694
|
+
const { dependencies: s = [] } = c || {}, n = su(i), {
|
1691
1695
|
styles: d,
|
1692
1696
|
css: b,
|
1693
|
-
errors:
|
1697
|
+
errors: h
|
1694
1698
|
} = I0(n.styles.join(`
|
1695
1699
|
`)), {
|
1696
1700
|
state: o,
|
1697
1701
|
watch: S,
|
1698
1702
|
lifeCycles: x,
|
1699
|
-
computed:
|
1703
|
+
computed: E,
|
1700
1704
|
methods: w,
|
1701
1705
|
props: mu,
|
1702
1706
|
emits: xu,
|
@@ -1704,7 +1708,7 @@ async function j0(e) {
|
|
1704
1708
|
handlers: gu,
|
1705
1709
|
imports: yu,
|
1706
1710
|
dataSources: Su
|
1707
|
-
} = o0(n.script,
|
1711
|
+
} = o0(n.script, c), { nodes: Eu, slots: vu, context: wu } = i0(t, a, n.template, {
|
1708
1712
|
handlers: gu,
|
1709
1713
|
styles: d
|
1710
1714
|
}), J = {
|
@@ -1715,14 +1719,14 @@ async function j0(e) {
|
|
1715
1719
|
state: o,
|
1716
1720
|
watch: S,
|
1717
1721
|
lifeCycles: x,
|
1718
|
-
computed:
|
1722
|
+
computed: E,
|
1719
1723
|
methods: w,
|
1720
1724
|
dataSources: Su,
|
1721
1725
|
slots: vu,
|
1722
1726
|
emits: xu,
|
1723
1727
|
nodes: Eu,
|
1724
1728
|
css: b
|
1725
|
-
}, Au = Object.keys(
|
1729
|
+
}, Au = Object.keys(E || {}), Tu = [
|
1726
1730
|
"$el",
|
1727
1731
|
"$emit",
|
1728
1732
|
"$nextTick",
|
@@ -1759,40 +1763,40 @@ async function j0(e) {
|
|
1759
1763
|
const L = await Q(_.value);
|
1760
1764
|
_.value = Z(L, "", z);
|
1761
1765
|
}
|
1762
|
-
), u.push(...
|
1766
|
+
), u.push(...h), u.length ? Promise.reject(u) : new Lu(J).toDsl();
|
1763
1767
|
}
|
1764
1768
|
async function N0(e, u, t) {
|
1765
|
-
const a = async (x,
|
1766
|
-
if (await u(x,
|
1769
|
+
const a = async (x, E) => {
|
1770
|
+
if (await u(x, E), Array.isArray(x.children))
|
1767
1771
|
for (const w of x.children)
|
1768
1772
|
await a(w, x);
|
1769
|
-
},
|
1773
|
+
}, i = async (x) => {
|
1770
1774
|
if (!x || typeof x != "object") return;
|
1771
1775
|
if (Array.isArray(x)) {
|
1772
1776
|
for (let w of x)
|
1773
|
-
await
|
1777
|
+
await i(w);
|
1774
1778
|
return;
|
1775
1779
|
}
|
1776
|
-
const
|
1777
|
-
for (const w of
|
1778
|
-
G(w) ? await t(w) : await
|
1780
|
+
const E = Object.values(x);
|
1781
|
+
for (const w of E)
|
1782
|
+
G(w) ? await t(w) : await i(w);
|
1779
1783
|
}, {
|
1780
|
-
state:
|
1784
|
+
state: c,
|
1781
1785
|
watch: s,
|
1782
1786
|
computed: n,
|
1783
1787
|
props: d,
|
1784
1788
|
dataSources: b,
|
1785
|
-
methods:
|
1789
|
+
methods: h,
|
1786
1790
|
lifeCycles: o,
|
1787
1791
|
inject: S
|
1788
1792
|
} = e;
|
1789
|
-
if (await
|
1790
|
-
state:
|
1793
|
+
if (await i({
|
1794
|
+
state: c,
|
1791
1795
|
watch: s,
|
1792
1796
|
computed: n,
|
1793
1797
|
props: d,
|
1794
1798
|
dataSources: b,
|
1795
|
-
methods:
|
1799
|
+
methods: h,
|
1796
1800
|
lifeCycles: o,
|
1797
1801
|
inject: S
|
1798
1802
|
}), Array.isArray(e.nodes))
|
@@ -1803,28 +1807,28 @@ async function q0(e, u) {
|
|
1803
1807
|
const t = async (a) => {
|
1804
1808
|
if (!a || typeof a != "object") return;
|
1805
1809
|
if (Array.isArray(a)) {
|
1806
|
-
for (let
|
1807
|
-
await u(
|
1810
|
+
for (let c of a)
|
1811
|
+
await u(c), await t(c);
|
1808
1812
|
return;
|
1809
1813
|
}
|
1810
1814
|
if (G(a)) {
|
1811
1815
|
await u(a);
|
1812
1816
|
return;
|
1813
1817
|
}
|
1814
|
-
const
|
1815
|
-
for (const
|
1816
|
-
await u(
|
1818
|
+
const i = Object.values(a);
|
1819
|
+
for (const c of i)
|
1820
|
+
await u(c), await t(c);
|
1817
1821
|
};
|
1818
1822
|
await t(e);
|
1819
1823
|
}
|
1820
1824
|
function k0(e = [], u = []) {
|
1821
1825
|
const t = {}, a = u.reduce(
|
1822
|
-
(
|
1826
|
+
(i, c) => (i[c.package] = c.library, i),
|
1823
1827
|
{}
|
1824
1828
|
);
|
1825
|
-
for (const { from:
|
1826
|
-
|
1827
|
-
const n = a[
|
1829
|
+
for (const { from: i, imports: c } of e)
|
1830
|
+
c.forEach((s) => {
|
1831
|
+
const n = a[i];
|
1828
1832
|
n && (t[s] = n);
|
1829
1833
|
});
|
1830
1834
|
return {
|
@@ -1833,7 +1837,7 @@ function k0(e = [], u = []) {
|
|
1833
1837
|
}
|
1834
1838
|
export {
|
1835
1839
|
$0 as VTJ_PARSER_VERSION,
|
1836
|
-
|
1840
|
+
iu as htmlToNodes,
|
1837
1841
|
F0 as parseUniApp,
|
1838
1842
|
j0 as parseVue,
|
1839
1843
|
Z as patchCode,
|