@vtj/parser 0.12.14 → 0.12.16
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 +270 -268
- package/package.json +4 -4
- package/types/version.d.ts +2 -2
- package/types/vue/html.d.ts +2 -2
package/dist/index.mjs
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
import { parse as
|
2
|
-
import { parse as
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import { BlockModel as
|
6
|
-
import { tsFormatter as
|
1
|
+
import { parse as Du, compileTemplate as Bu } from "@vue/compiler-sfc";
|
2
|
+
import { parse as Ru } from "@babel/parser";
|
3
|
+
import Q from "@babel/traverse";
|
4
|
+
import Z from "@babel/generator";
|
5
|
+
import { BlockModel as Ou } from "@vtj/core";
|
6
|
+
import { tsFormatter as K } from "@vtj/coder";
|
7
7
|
import { NodeTypes as l } from "@vue/compiler-core";
|
8
|
-
import { upperFirstCamelCase as
|
8
|
+
import { upperFirstCamelCase as Vu, uid as Mu } from "@vtj/base";
|
9
9
|
import Pu from "postcss";
|
10
10
|
/**!
|
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.16
|
15
15
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
16
16
|
*/
|
17
|
-
const X0 = "0.12.
|
18
|
-
function
|
19
|
-
const { descriptor: u } =
|
17
|
+
const X0 = "0.12.16";
|
18
|
+
function nu(e) {
|
19
|
+
const { descriptor: u } = Du(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
23
|
styles: i
|
24
24
|
};
|
25
25
|
}
|
26
|
-
function
|
27
|
-
return
|
26
|
+
function du(e) {
|
27
|
+
return Ru(e, { sourceType: "module", plugins: ["typescript"] });
|
28
28
|
}
|
29
|
-
function
|
30
|
-
return (
|
29
|
+
function fu(e, u) {
|
30
|
+
return (Q.default || Q)(e, u);
|
31
31
|
}
|
32
32
|
function R(e) {
|
33
33
|
try {
|
34
|
-
return (
|
34
|
+
return (Z.default || Z)(e, {
|
35
35
|
comments: !1,
|
36
36
|
concise: !0,
|
37
37
|
retainLines: !1,
|
@@ -43,21 +43,21 @@ function R(e) {
|
|
43
43
|
return console.error("代码生成错误", u), "";
|
44
44
|
}
|
45
45
|
}
|
46
|
-
function
|
46
|
+
function G(e) {
|
47
47
|
return e && e.type === "JSExpression";
|
48
48
|
}
|
49
|
-
function
|
49
|
+
function Uu(e) {
|
50
50
|
return typeof e == "object" && e && e.type === "JSFunction";
|
51
51
|
}
|
52
|
-
function
|
53
|
-
return
|
52
|
+
function C(e) {
|
53
|
+
return G(e) || Uu(e);
|
54
54
|
}
|
55
|
-
function
|
56
|
-
return !!e && !
|
55
|
+
function $u(e) {
|
56
|
+
return !!e && !G(e) && typeof e != "string";
|
57
57
|
}
|
58
58
|
function z0(e) {
|
59
|
-
const u =
|
60
|
-
return u.styles && (a.css = u.styles[0] || ""),
|
59
|
+
const u = nu(e), t = du(u.script), a = {};
|
60
|
+
return u.styles && (a.css = u.styles[0] || ""), fu(t, {
|
61
61
|
CallExpression(i) {
|
62
62
|
const c = i.node.callee?.name;
|
63
63
|
if (c) {
|
@@ -72,21 +72,21 @@ function z0(e) {
|
|
72
72
|
}
|
73
73
|
function O(e, u, t) {
|
74
74
|
const a = new RegExp(`${u}`, "g"), i = /(\@\_|\$|\.|\,|\w)$/, c = /^\w/, s = new RegExp(`^this.${u}$`, "g");
|
75
|
-
return e.replace(a, (
|
75
|
+
return e.replace(a, (d, f, h) => {
|
76
76
|
const b = h.substring(0, f), E = h.substring(f + u.length);
|
77
|
-
return i.test(b.trim()) || c.test(E.trim()) ?
|
77
|
+
return i.test(b.trim()) || c.test(E.trim()) ? d : t;
|
78
78
|
}).replace(s, t);
|
79
79
|
}
|
80
|
-
function
|
80
|
+
function Y(e, u, t) {
|
81
81
|
const {
|
82
82
|
context: a = {},
|
83
83
|
computed: i = [],
|
84
84
|
libs: c = {},
|
85
85
|
members: s = [],
|
86
|
-
platform:
|
87
|
-
} = t || {},
|
88
|
-
if (
|
89
|
-
for (const f of
|
86
|
+
platform: n
|
87
|
+
} = t || {}, d = Array.from(a[u || ""] || /* @__PURE__ */ new Set());
|
88
|
+
if (d)
|
89
|
+
for (const f of d)
|
90
90
|
e = O(e, f, `this.context.${f}`);
|
91
91
|
for (const f of i)
|
92
92
|
e = O(e, f, `this.${f}.value`);
|
@@ -94,25 +94,25 @@ function K(e, u, t) {
|
|
94
94
|
e = O(e, f, `this.$libs.${h}.${f}`);
|
95
95
|
for (const f of s)
|
96
96
|
e = O(e, f, `this.${f}`);
|
97
|
-
if (
|
97
|
+
if (n === "uniapp") {
|
98
98
|
const f = /\buni\./g;
|
99
99
|
e = e.replace(f, "this.$libs.UniH5.uni.");
|
100
100
|
}
|
101
101
|
return e = e.replace(/_ctx\./g, "this."), e;
|
102
102
|
}
|
103
|
-
function
|
103
|
+
function S(e) {
|
104
104
|
return {
|
105
105
|
type: "JSExpression",
|
106
106
|
value: /^\{[\w\W]*\}$/.test(e) ? `(${e})` : e
|
107
107
|
};
|
108
108
|
}
|
109
|
-
function
|
109
|
+
function J(e) {
|
110
110
|
return {
|
111
111
|
type: "JSFunction",
|
112
112
|
value: e
|
113
113
|
};
|
114
114
|
}
|
115
|
-
const
|
115
|
+
const ju = [
|
116
116
|
"beforeCreate",
|
117
117
|
"created",
|
118
118
|
"beforeMount",
|
@@ -126,18 +126,18 @@ const $u = [
|
|
126
126
|
"renderTriggered",
|
127
127
|
"activated",
|
128
128
|
"deactivated"
|
129
|
-
],
|
129
|
+
], Fu = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot".split(
|
130
130
|
","
|
131
|
-
),
|
131
|
+
), Hu = "component,slot,template".split(","), Gu = "view,swiper,progress,icon,text,button,checkbox,editor,form,input,label,picker,radio,slider,switch,textarea,audio,camera,image,video,map,canvas".split(
|
132
132
|
","
|
133
133
|
);
|
134
|
-
function Gu(e, u = "web") {
|
135
|
-
return u === "uniapp" && Hu.includes(e);
|
136
|
-
}
|
137
134
|
function Cu(e, u = "web") {
|
138
|
-
return
|
135
|
+
return u === "uniapp" && Gu.includes(e);
|
139
136
|
}
|
140
|
-
function
|
137
|
+
function ou(e, u = "web") {
|
138
|
+
return (Fu.includes(e) || Hu.includes(e)) && !Cu(e, u) ? e : Vu(e);
|
139
|
+
}
|
140
|
+
function bu(e) {
|
141
141
|
return e.replace(/\s+/g, " ").split(";").reduce((t, a) => {
|
142
142
|
const [i, c] = a.split(":").map((s) => s.trim());
|
143
143
|
return i && c && (t[i] = c), t;
|
@@ -160,7 +160,7 @@ const zu = /* @__PURE__ */ new Uint16Array(
|
|
160
160
|
// prettier-ignore
|
161
161
|
/* @__PURE__ */ "Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map((e) => e.charCodeAt(0))
|
162
162
|
);
|
163
|
-
var
|
163
|
+
var U;
|
164
164
|
const Qu = /* @__PURE__ */ new Map([
|
165
165
|
[0, 65533],
|
166
166
|
// C1 Unicode control character reference replacements
|
@@ -191,9 +191,9 @@ const Qu = /* @__PURE__ */ new Map([
|
|
191
191
|
[156, 339],
|
192
192
|
[158, 382],
|
193
193
|
[159, 376]
|
194
|
-
]),
|
194
|
+
]), uu = (
|
195
195
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, n/no-unsupported-features/es-builtins
|
196
|
-
(
|
196
|
+
(U = String.fromCodePoint) !== null && U !== void 0 ? U : function(e) {
|
197
197
|
let u = "";
|
198
198
|
return e > 65535 && (e -= 65536, u += String.fromCharCode(e >>> 10 & 1023 | 55296), e = 56320 | e & 1023), u += String.fromCharCode(e), u;
|
199
199
|
}
|
@@ -211,14 +211,14 @@ var N;
|
|
211
211
|
(function(e) {
|
212
212
|
e[e.VALUE_LENGTH = 49152] = "VALUE_LENGTH", e[e.BRANCH_LENGTH = 16256] = "BRANCH_LENGTH", e[e.JUMP_TABLE = 127] = "JUMP_TABLE";
|
213
213
|
})(N || (N = {}));
|
214
|
-
function
|
214
|
+
function j(e) {
|
215
215
|
return e >= y.ZERO && e <= y.NINE;
|
216
216
|
}
|
217
217
|
function Yu(e) {
|
218
218
|
return e >= y.UPPER_A && e <= y.UPPER_F || e >= y.LOWER_A && e <= y.LOWER_F;
|
219
219
|
}
|
220
220
|
function u0(e) {
|
221
|
-
return e >= y.UPPER_A && e <= y.UPPER_Z || e >= y.LOWER_A && e <= y.LOWER_Z ||
|
221
|
+
return e >= y.UPPER_A && e <= y.UPPER_Z || e >= y.LOWER_A && e <= y.LOWER_Z || j(e);
|
222
222
|
}
|
223
223
|
function e0(e) {
|
224
224
|
return e === y.EQUALS || u0(e);
|
@@ -295,7 +295,7 @@ class t0 {
|
|
295
295
|
const a = t;
|
296
296
|
for (; t < u.length; ) {
|
297
297
|
const i = u.charCodeAt(t);
|
298
|
-
if (
|
298
|
+
if (j(i) || Yu(i))
|
299
299
|
t += 1;
|
300
300
|
else
|
301
301
|
return this.addToNumericResult(u, a, t, 16), this.emitNumericEntity(i, 3);
|
@@ -315,7 +315,7 @@ class t0 {
|
|
315
315
|
const a = t;
|
316
316
|
for (; t < u.length; ) {
|
317
317
|
const i = u.charCodeAt(t);
|
318
|
-
if (
|
318
|
+
if (j(i))
|
319
319
|
t += 1;
|
320
320
|
else
|
321
321
|
return this.addToNumericResult(u, a, t, 10), this.emitNumericEntity(i, 2);
|
@@ -424,18 +424,18 @@ function a0(e, u, t, a) {
|
|
424
424
|
if (i === 0)
|
425
425
|
return c !== 0 && a === c ? t : -1;
|
426
426
|
if (c) {
|
427
|
-
const
|
428
|
-
return
|
427
|
+
const d = a - c;
|
428
|
+
return d < 0 || d >= i ? -1 : e[t + d] - 1;
|
429
429
|
}
|
430
|
-
let s = t,
|
431
|
-
for (; s <=
|
432
|
-
const
|
430
|
+
let s = t, n = s + i - 1;
|
431
|
+
for (; s <= n; ) {
|
432
|
+
const d = s + n >>> 1, f = e[d];
|
433
433
|
if (f < a)
|
434
|
-
s =
|
434
|
+
s = d + 1;
|
435
435
|
else if (f > a)
|
436
|
-
|
436
|
+
n = d - 1;
|
437
437
|
else
|
438
|
-
return e[
|
438
|
+
return e[d + i];
|
439
439
|
}
|
440
440
|
return -1;
|
441
441
|
}
|
@@ -821,7 +821,7 @@ const k = /* @__PURE__ */ new Set([
|
|
821
821
|
"button",
|
822
822
|
"datalist",
|
823
823
|
"textarea"
|
824
|
-
]), p = /* @__PURE__ */ new Set(["p"]),
|
824
|
+
]), p = /* @__PURE__ */ new Set(["p"]), eu = /* @__PURE__ */ new Set(["thead", "tbody"]), tu = /* @__PURE__ */ new Set(["dd", "dt"]), au = /* @__PURE__ */ new Set(["rt", "rp"]), s0 = /* @__PURE__ */ new Map([
|
825
825
|
["tr", /* @__PURE__ */ new Set(["tr", "th", "td"])],
|
826
826
|
["th", /* @__PURE__ */ new Set(["th"])],
|
827
827
|
["td", /* @__PURE__ */ new Set(["thead", "th", "td"])],
|
@@ -842,8 +842,8 @@ const k = /* @__PURE__ */ new Set([
|
|
842
842
|
["textarea", k],
|
843
843
|
["option", /* @__PURE__ */ new Set(["option"])],
|
844
844
|
["optgroup", /* @__PURE__ */ new Set(["optgroup", "option"])],
|
845
|
-
["dd",
|
846
|
-
["dt",
|
845
|
+
["dd", tu],
|
846
|
+
["dt", tu],
|
847
847
|
["address", p],
|
848
848
|
["article", p],
|
849
849
|
["aside", p],
|
@@ -865,10 +865,10 @@ const k = /* @__PURE__ */ new Set([
|
|
865
865
|
["section", p],
|
866
866
|
["table", p],
|
867
867
|
["ul", p],
|
868
|
-
["rt",
|
869
|
-
["rp",
|
870
|
-
["tbody",
|
871
|
-
["tfoot",
|
868
|
+
["rt", au],
|
869
|
+
["rp", au],
|
870
|
+
["tbody", eu],
|
871
|
+
["tfoot", eu]
|
872
872
|
]), r0 = /* @__PURE__ */ new Set([
|
873
873
|
"area",
|
874
874
|
"base",
|
@@ -889,7 +889,7 @@ const k = /* @__PURE__ */ new Set([
|
|
889
889
|
"source",
|
890
890
|
"track",
|
891
891
|
"wbr"
|
892
|
-
]),
|
892
|
+
]), iu = /* @__PURE__ */ new Set(["math", "svg"]), cu = /* @__PURE__ */ new Set([
|
893
893
|
"mi",
|
894
894
|
"mo",
|
895
895
|
"mn",
|
@@ -902,8 +902,8 @@ const k = /* @__PURE__ */ new Set([
|
|
902
902
|
]), n0 = /\s|\//;
|
903
903
|
class d0 {
|
904
904
|
constructor(u, t = {}) {
|
905
|
-
var a, i, c, s,
|
906
|
-
this.options = t, this.startIndex = 0, this.endIndex = 0, this.openTagStart = 0, this.tagname = "", this.attribname = "", this.attribvalue = "", this.attribs = null, this.stack = [], this.buffers = [], this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1, this.cbs = u ?? {}, this.htmlMode = !this.options.xmlMode, this.lowerCaseTagNames = (a = t.lowerCaseTags) !== null && a !== void 0 ? a : this.htmlMode, this.lowerCaseAttributeNames = (i = t.lowerCaseAttributeNames) !== null && i !== void 0 ? i : this.htmlMode, this.recognizeSelfClosing = (c = t.recognizeSelfClosing) !== null && c !== void 0 ? c : !this.htmlMode, this.tokenizer = new ((s = t.Tokenizer) !== null && s !== void 0 ? s : c0)(this.options, this), this.foreignContext = [!this.htmlMode], (
|
905
|
+
var a, i, c, s, n, d;
|
906
|
+
this.options = t, this.startIndex = 0, this.endIndex = 0, this.openTagStart = 0, this.tagname = "", this.attribname = "", this.attribvalue = "", this.attribs = null, this.stack = [], this.buffers = [], this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1, this.cbs = u ?? {}, this.htmlMode = !this.options.xmlMode, this.lowerCaseTagNames = (a = t.lowerCaseTags) !== null && a !== void 0 ? a : this.htmlMode, this.lowerCaseAttributeNames = (i = t.lowerCaseAttributeNames) !== null && i !== void 0 ? i : this.htmlMode, this.recognizeSelfClosing = (c = t.recognizeSelfClosing) !== null && c !== void 0 ? c : !this.htmlMode, this.tokenizer = new ((s = t.Tokenizer) !== null && s !== void 0 ? s : c0)(this.options, this), this.foreignContext = [!this.htmlMode], (d = (n = this.cbs).onparserinit) === null || d === void 0 || d.call(n, this);
|
907
907
|
}
|
908
908
|
// Tokenizer event handlers
|
909
909
|
/** @internal */
|
@@ -915,7 +915,7 @@ class d0 {
|
|
915
915
|
/** @internal */
|
916
916
|
ontextentity(u, t) {
|
917
917
|
var a, i;
|
918
|
-
this.endIndex = t - 1, (i = (a = this.cbs).ontext) === null || i === void 0 || i.call(a,
|
918
|
+
this.endIndex = t - 1, (i = (a = this.cbs).ontext) === null || i === void 0 || i.call(a, uu(u)), this.startIndex = t;
|
919
919
|
}
|
920
920
|
/**
|
921
921
|
* Checks if the current tag is a void element. Override this if you want
|
@@ -936,10 +936,10 @@ class d0 {
|
|
936
936
|
const s = this.htmlMode && s0.get(u);
|
937
937
|
if (s)
|
938
938
|
for (; this.stack.length > 0 && s.has(this.stack[0]); ) {
|
939
|
-
const
|
940
|
-
(a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t,
|
939
|
+
const n = this.stack.shift();
|
940
|
+
(a = (t = this.cbs).onclosetag) === null || a === void 0 || a.call(t, n, !0);
|
941
941
|
}
|
942
|
-
this.isVoidElement(u) || (this.stack.unshift(u), this.htmlMode && (
|
942
|
+
this.isVoidElement(u) || (this.stack.unshift(u), this.htmlMode && (iu.has(u) ? this.foreignContext.unshift(!0) : cu.has(u) && this.foreignContext.unshift(!1))), (c = (i = this.cbs).onopentagname) === null || c === void 0 || c.call(i, u), this.cbs.onopentag && (this.attribs = {});
|
943
943
|
}
|
944
944
|
endOpenTag(u) {
|
945
945
|
var t, a;
|
@@ -951,17 +951,17 @@ class d0 {
|
|
951
951
|
}
|
952
952
|
/** @internal */
|
953
953
|
onclosetag(u, t) {
|
954
|
-
var a, i, c, s,
|
954
|
+
var a, i, c, s, n, d, f, h;
|
955
955
|
this.endIndex = t;
|
956
956
|
let b = this.getSlice(u, t);
|
957
|
-
if (this.lowerCaseTagNames && (b = b.toLowerCase()), this.htmlMode && (
|
958
|
-
this.htmlMode && b === "br" && ((s = (c = this.cbs).onopentagname) === null || s === void 0 || s.call(c, "br"), (
|
957
|
+
if (this.lowerCaseTagNames && (b = b.toLowerCase()), this.htmlMode && (iu.has(b) || cu.has(b)) && this.foreignContext.shift(), this.isVoidElement(b))
|
958
|
+
this.htmlMode && b === "br" && ((s = (c = this.cbs).onopentagname) === null || s === void 0 || s.call(c, "br"), (d = (n = this.cbs).onopentag) === null || d === void 0 || d.call(n, "br", {}, !0), (h = (f = this.cbs).onclosetag) === null || h === void 0 || h.call(f, "br", !1));
|
959
959
|
else {
|
960
960
|
const E = this.stack.indexOf(b);
|
961
961
|
if (E !== -1)
|
962
962
|
for (let m = 0; m <= E; m++) {
|
963
|
-
const
|
964
|
-
(i = (a = this.cbs).onclosetag) === null || i === void 0 || i.call(a,
|
963
|
+
const v = this.stack.shift();
|
964
|
+
(i = (a = this.cbs).onclosetag) === null || i === void 0 || i.call(a, v, m !== E);
|
965
965
|
}
|
966
966
|
else this.htmlMode && b === "p" && (this.emitOpenTag("p"), this.closeCurrentTag(!0));
|
967
967
|
}
|
@@ -988,7 +988,7 @@ class d0 {
|
|
988
988
|
}
|
989
989
|
/** @internal */
|
990
990
|
onattribentity(u) {
|
991
|
-
this.attribvalue +=
|
991
|
+
this.attribvalue += uu(u);
|
992
992
|
}
|
993
993
|
/** @internal */
|
994
994
|
onattribend(u, t) {
|
@@ -1022,15 +1022,15 @@ class d0 {
|
|
1022
1022
|
}
|
1023
1023
|
/** @internal */
|
1024
1024
|
oncomment(u, t, a) {
|
1025
|
-
var i, c, s,
|
1026
|
-
this.endIndex = t, (c = (i = this.cbs).oncomment) === null || c === void 0 || c.call(i, this.getSlice(u, t - a)), (
|
1025
|
+
var i, c, s, n;
|
1026
|
+
this.endIndex = t, (c = (i = this.cbs).oncomment) === null || c === void 0 || c.call(i, this.getSlice(u, t - a)), (n = (s = this.cbs).oncommentend) === null || n === void 0 || n.call(s), this.startIndex = t + 1;
|
1027
1027
|
}
|
1028
1028
|
/** @internal */
|
1029
1029
|
oncdata(u, t, a) {
|
1030
|
-
var i, c, s,
|
1030
|
+
var i, c, s, n, d, f, h, b, E, m;
|
1031
1031
|
this.endIndex = t;
|
1032
|
-
const
|
1033
|
-
!this.htmlMode || this.options.recognizeCDATA ? ((c = (i = this.cbs).oncdatastart) === null || c === void 0 || c.call(i), (
|
1032
|
+
const v = this.getSlice(u, t - a);
|
1033
|
+
!this.htmlMode || this.options.recognizeCDATA ? ((c = (i = this.cbs).oncdatastart) === null || c === void 0 || c.call(i), (n = (s = this.cbs).ontext) === null || n === void 0 || n.call(s, v), (f = (d = this.cbs).oncdataend) === null || f === void 0 || f.call(d)) : ((b = (h = this.cbs).oncomment) === null || b === void 0 || b.call(h, `[CDATA[${v}]]`), (m = (E = this.cbs).oncommentend) === null || m === void 0 || m.call(E)), this.startIndex = t + 1;
|
1034
1034
|
}
|
1035
1035
|
/** @internal */
|
1036
1036
|
onend() {
|
@@ -1128,65 +1128,65 @@ class d0 {
|
|
1128
1128
|
this.end(u);
|
1129
1129
|
}
|
1130
1130
|
}
|
1131
|
-
function
|
1132
|
-
const
|
1133
|
-
let
|
1134
|
-
const
|
1131
|
+
function su(e, u = "web") {
|
1132
|
+
const t = { name: "", children: [] }, a = [t];
|
1133
|
+
let i = "";
|
1134
|
+
const c = new d0(
|
1135
1135
|
{
|
1136
|
-
onopentag: (
|
1137
|
-
const
|
1138
|
-
|
1139
|
-
name: "
|
1140
|
-
children:
|
1141
|
-
}) :
|
1142
|
-
const
|
1143
|
-
(
|
1144
|
-
let [
|
1145
|
-
return
|
1136
|
+
onopentag: (s, n, d) => {
|
1137
|
+
const f = a[a.length - 1];
|
1138
|
+
i.trim() && (Array.isArray(f.children) ? f.children.push({
|
1139
|
+
name: "span",
|
1140
|
+
children: i.trim()
|
1141
|
+
}) : f.children = i.trim(), i = "");
|
1142
|
+
const h = Object.entries(n || {}).reduce(
|
1143
|
+
(E, m) => {
|
1144
|
+
let [v = "", w = ""] = m;
|
1145
|
+
return v && (E[v] = w), E;
|
1146
1146
|
},
|
1147
1147
|
{}
|
1148
1148
|
);
|
1149
|
-
|
1150
|
-
const
|
1151
|
-
name:
|
1152
|
-
props:
|
1149
|
+
h.style && (h.style = bu(h.style));
|
1150
|
+
const b = {
|
1151
|
+
name: ou(s, u),
|
1152
|
+
props: h
|
1153
1153
|
};
|
1154
|
-
Array.isArray(
|
1154
|
+
Array.isArray(f.children) ? f.children.push(b) : f.children ? f.children = [
|
1155
1155
|
{
|
1156
1156
|
name: "span",
|
1157
|
-
children:
|
1157
|
+
children: f.children
|
1158
1158
|
},
|
1159
|
-
|
1160
|
-
] :
|
1159
|
+
b
|
1160
|
+
] : f.children = [b], d || a.push(b);
|
1161
1161
|
},
|
1162
|
-
ontext: (
|
1163
|
-
const
|
1164
|
-
|
1162
|
+
ontext: (s) => {
|
1163
|
+
const n = s.trim();
|
1164
|
+
n && n !== '"' && (i += n);
|
1165
1165
|
},
|
1166
1166
|
onclosetag: () => {
|
1167
|
-
const
|
1168
|
-
|
1167
|
+
const s = a.pop();
|
1168
|
+
i.trim() && (Array.isArray(s?.children) ? s.children.push({
|
1169
1169
|
name: "span",
|
1170
|
-
children:
|
1171
|
-
}) :
|
1170
|
+
children: i.trim()
|
1171
|
+
}) : s && (s.children = i.trim()), i = "");
|
1172
1172
|
}
|
1173
1173
|
},
|
1174
1174
|
{ decodeEntities: !0 }
|
1175
1175
|
);
|
1176
|
-
return
|
1176
|
+
return c.write(e.replace(/\\"/g, '"')), c.end(), t.children || [];
|
1177
1177
|
}
|
1178
|
-
let
|
1178
|
+
let F = [], M = {}, lu = {}, hu = {}, P = "web";
|
1179
1179
|
function f0(e, u, t = "", a) {
|
1180
|
-
return
|
1181
|
-
nodes: (
|
1180
|
+
return F = [], M = {}, lu = a?.handlers || {}, hu = a?.styles || {}, P = a?.platform || "web", {
|
1181
|
+
nodes: (Bu({
|
1182
1182
|
id: e,
|
1183
1183
|
filename: u,
|
1184
1184
|
source: t,
|
1185
1185
|
isProd: !0,
|
1186
1186
|
slotted: !0
|
1187
|
-
}).ast?.children || []).map((
|
1188
|
-
slots:
|
1189
|
-
context:
|
1187
|
+
}).ast?.children || []).map((n) => _(n)).filter((n) => !!n),
|
1188
|
+
slots: F,
|
1189
|
+
context: M
|
1190
1190
|
};
|
1191
1191
|
}
|
1192
1192
|
function o0(e) {
|
@@ -1195,7 +1195,7 @@ function o0(e) {
|
|
1195
1195
|
const t = [];
|
1196
1196
|
for (const [a, i] of Object.entries(e.props || {}))
|
1197
1197
|
a === "name" ? u = i : t.push(a);
|
1198
|
-
|
1198
|
+
F.push({
|
1199
1199
|
name: u,
|
1200
1200
|
params: t
|
1201
1201
|
});
|
@@ -1206,23 +1206,23 @@ function b0(e) {
|
|
1206
1206
|
for (const t of e) {
|
1207
1207
|
if (t.type === l.ATTRIBUTE)
|
1208
1208
|
if (t.name === "class") {
|
1209
|
-
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((
|
1210
|
-
|
1209
|
+
const a = t.value?.content || "", i = /[\w]+_[\w]{5,}/, c = a.match(i)?.[0] || "", s = a.split(" ").filter((d) => d !== c), n = hu[`.${c}`];
|
1210
|
+
n && (u.style = n), s.length && (u.class = s.join(" "));
|
1211
1211
|
} else if (t.name === "style") {
|
1212
1212
|
const a = t.value?.content || "";
|
1213
|
-
a && (u.style =
|
1213
|
+
a && (u.style = bu(a));
|
1214
1214
|
} else
|
1215
1215
|
u[t.name] = t.value?.content || "";
|
1216
|
-
if (t.type === l.DIRECTIVE && t.name === "bind" && (t.exp?.type === l.SIMPLE_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION && (u[t.arg.content] =
|
1216
|
+
if (t.type === l.DIRECTIVE && t.name === "bind" && (t.exp?.type === l.SIMPLE_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION && (u[t.arg.content] = S(`(${t.exp.content})`)), t.exp?.type === l.COMPOUND_EXPRESSION && t.arg?.type === l.SIMPLE_EXPRESSION))
|
1217
1217
|
if (t.arg.content === "class" && u.class) {
|
1218
1218
|
const a = t.exp.ast.type, i = Xu(
|
1219
1219
|
u.class,
|
1220
1220
|
t.exp.loc.source,
|
1221
1221
|
a
|
1222
1222
|
);
|
1223
|
-
i && (u[t.arg.content] =
|
1223
|
+
i && (u[t.arg.content] = S(i));
|
1224
1224
|
} else
|
1225
|
-
u[t.arg.content] =
|
1225
|
+
u[t.arg.content] = S(
|
1226
1226
|
`(${t.exp.loc.source})`
|
1227
1227
|
);
|
1228
1228
|
}
|
@@ -1238,8 +1238,8 @@ function l0(e, u = {}) {
|
|
1238
1238
|
);
|
1239
1239
|
let c = a.exp?.loc.source || "";
|
1240
1240
|
/\)$/.test(c) && (c = `($event) => { ${c} } `);
|
1241
|
-
const
|
1242
|
-
if (
|
1241
|
+
const n = new RegExp(`${a.arg.content}_[\\w]{5,}`), d = c.match(n)?.[0] || "", f = u[d];
|
1242
|
+
if (d && f)
|
1243
1243
|
t[a.arg.content] = {
|
1244
1244
|
name: a.arg.content,
|
1245
1245
|
handler: f,
|
@@ -1249,7 +1249,7 @@ function l0(e, u = {}) {
|
|
1249
1249
|
const h = a.exp?.ast?.type === "AssignmentExpression";
|
1250
1250
|
t[a.arg.content] = {
|
1251
1251
|
name: a.arg.content,
|
1252
|
-
handler:
|
1252
|
+
handler: J(h ? `()=> {${c}}` : `(${c})`),
|
1253
1253
|
modifiers: i
|
1254
1254
|
};
|
1255
1255
|
}
|
@@ -1263,102 +1263,102 @@ function h0(e, u) {
|
|
1263
1263
|
const c = i === 0 ? "vIf" : a.condition ? "vElseIf" : "vElse", s = a.condition?.loc.source || "";
|
1264
1264
|
t.push({
|
1265
1265
|
name: c,
|
1266
|
-
value: c === "vElse" ? !0 :
|
1266
|
+
value: c === "vElse" ? !0 : S(s)
|
1267
1267
|
});
|
1268
1268
|
}
|
1269
1269
|
}), e.type === l.FOR && t.push({
|
1270
1270
|
name: "vFor",
|
1271
|
-
value:
|
1271
|
+
value: S(e.source.loc.source),
|
1272
1272
|
iterator: {
|
1273
1273
|
item: e.valueAlias?.loc.source || "item",
|
1274
1274
|
index: e.keyAlias?.loc.source || "index"
|
1275
1275
|
}
|
1276
1276
|
}), e.type === l.ELEMENT) {
|
1277
1277
|
const a = e.props.filter(
|
1278
|
-
(
|
1279
|
-
), i = a.filter((
|
1280
|
-
i.length && i.forEach((
|
1278
|
+
(d) => d.type === l.DIRECTIVE
|
1279
|
+
), i = a.filter((d) => d.name === "model");
|
1280
|
+
i.length && i.forEach((d) => {
|
1281
1281
|
t.push({
|
1282
1282
|
name: "vModel",
|
1283
|
-
arg:
|
1284
|
-
value:
|
1283
|
+
arg: d.arg?.content,
|
1284
|
+
value: S(d.exp?.loc.source || "")
|
1285
1285
|
});
|
1286
1286
|
});
|
1287
|
-
const c = a.find((
|
1287
|
+
const c = a.find((d) => d.name === "show");
|
1288
1288
|
c && t.push({
|
1289
1289
|
name: "vShow",
|
1290
|
-
value:
|
1290
|
+
value: S(c.exp?.loc.source || "")
|
1291
1291
|
});
|
1292
|
-
const s = a.find((
|
1292
|
+
const s = a.find((d) => d.name === "bind" && !d.arg);
|
1293
1293
|
s && t.push({
|
1294
1294
|
name: "vBind",
|
1295
|
-
value:
|
1295
|
+
value: S(s.exp?.loc.source || "")
|
1296
1296
|
});
|
1297
|
-
const
|
1298
|
-
|
1297
|
+
const n = a.find((d) => d.name === "html");
|
1298
|
+
n && t.push({
|
1299
1299
|
name: "vHtml",
|
1300
|
-
value:
|
1300
|
+
value: S(n.exp?.loc.source || "")
|
1301
1301
|
});
|
1302
1302
|
}
|
1303
1303
|
return t;
|
1304
1304
|
}
|
1305
|
-
function
|
1305
|
+
function pu(e) {
|
1306
1306
|
let u = "";
|
1307
1307
|
const { name: t, props: a, events: i = {} } = e, c = a?.class || "";
|
1308
1308
|
if (typeof c == "string") {
|
1309
|
-
const s = new RegExp(`${t}_([\\w]+)`),
|
1310
|
-
|
1309
|
+
const s = new RegExp(`${t}_([\\w]+)`), n = c.match(s);
|
1310
|
+
n && n[1] && (u = n[1]);
|
1311
1311
|
}
|
1312
|
-
for (const { name: s, handler:
|
1313
|
-
const
|
1312
|
+
for (const { name: s, handler: n } of Object.values(i)) {
|
1313
|
+
const d = new RegExp(`${s}_([\\w]+)`), f = n.value.match(d);
|
1314
1314
|
f && f[1] && (u = f[1]);
|
1315
1315
|
}
|
1316
|
-
return u ||
|
1316
|
+
return u || Mu();
|
1317
1317
|
}
|
1318
|
-
function
|
1319
|
-
const t = new Set(u?.id ?
|
1318
|
+
function H(e, u) {
|
1319
|
+
const t = new Set(u?.id ? M[u.id] : []), a = (e.directives || []).find((s) => s.name === "vFor");
|
1320
1320
|
let i = new Set(Array.from(t));
|
1321
1321
|
if (a) {
|
1322
|
-
const { item: s = "item", index:
|
1323
|
-
i = /* @__PURE__ */ new Set([s,
|
1322
|
+
const { item: s = "item", index: n = "index" } = a.iterator || {};
|
1323
|
+
i = /* @__PURE__ */ new Set([s, n, ...Array.from(i)]);
|
1324
1324
|
}
|
1325
1325
|
const c = e.slot;
|
1326
1326
|
if (c) {
|
1327
|
-
const s = typeof c == "string" ? [] : c.params || [],
|
1328
|
-
i = /* @__PURE__ */ new Set([...
|
1327
|
+
const s = typeof c == "string" ? [] : c.params || [], n = s.length ? s : [`scope_${u?.id}`];
|
1328
|
+
i = /* @__PURE__ */ new Set([...n, ...Array.from(i)]);
|
1329
1329
|
}
|
1330
|
-
|
1330
|
+
M[e.id] = i;
|
1331
1331
|
}
|
1332
|
-
function
|
1332
|
+
function $(e, u, t, a) {
|
1333
1333
|
const i = {
|
1334
|
-
name:
|
1334
|
+
name: ou(e.tag, P),
|
1335
1335
|
props: b0(e.props),
|
1336
|
-
events: l0(e.props,
|
1336
|
+
events: l0(e.props, lu),
|
1337
1337
|
directives: h0(t || e, a)
|
1338
1338
|
};
|
1339
|
-
i.id =
|
1339
|
+
i.id = pu(i), H(i, u);
|
1340
1340
|
const c = x0(i, e.children);
|
1341
|
-
return
|
1341
|
+
return H(i, u), o0(c), c;
|
1342
1342
|
}
|
1343
1343
|
function p0(e, u) {
|
1344
1344
|
return e.map((t) => _(t, u, e));
|
1345
1345
|
}
|
1346
1346
|
function _(e, u, t) {
|
1347
1347
|
if (e.type === l.ELEMENT)
|
1348
|
-
return
|
1348
|
+
return $(e, u);
|
1349
1349
|
if (!t && e.type === l.IF)
|
1350
1350
|
return p0(e.branches);
|
1351
1351
|
if (t && e.type === l.IF_BRANCH) {
|
1352
|
-
const a = e.children
|
1352
|
+
const a = e.children.find((i) => i.type === l.ELEMENT);
|
1353
1353
|
if (a && a.type === l.ELEMENT)
|
1354
|
-
return
|
1354
|
+
return $(a, u, e, t);
|
1355
1355
|
}
|
1356
1356
|
if (e.type === l.FOR) {
|
1357
1357
|
const a = e.children[0];
|
1358
1358
|
if (a.type === l.ELEMENT)
|
1359
|
-
return
|
1359
|
+
return $(a, u, e);
|
1360
1360
|
}
|
1361
|
-
return e.type === l.TEXT_CALL ? e.content.type == l.TEXT ? e.content.content : e.content.type === l.INTERPOLATION ?
|
1361
|
+
return e.type === l.TEXT_CALL ? e.content.type == l.TEXT ? e.content.content : e.content.type === l.INTERPOLATION ? S(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) ? S(e.content.loc.source) : e.type === l.COMPOUND_EXPRESSION ? m0(
|
1362
1362
|
e.children
|
1363
1363
|
) : (e.type === l.COMMENT || console.warn("未处理", e.type), null);
|
1364
1364
|
}
|
@@ -1367,7 +1367,7 @@ function m0(e = []) {
|
|
1367
1367
|
for (const a of u)
|
1368
1368
|
t.push({
|
1369
1369
|
name: "span",
|
1370
|
-
children: a.type === l.TEXT ? a.loc.source :
|
1370
|
+
children: a.type === l.TEXT ? a.loc.source : S(a.content?.loc.source)
|
1371
1371
|
});
|
1372
1372
|
return {
|
1373
1373
|
name: "span",
|
@@ -1380,7 +1380,7 @@ function x0(e, u = []) {
|
|
1380
1380
|
if (a.type === l.ELEMENT && a.codegenNode?.value?.arguments) {
|
1381
1381
|
const i = a.codegenNode.value.arguments[0];
|
1382
1382
|
if (i) {
|
1383
|
-
const c =
|
1383
|
+
const c = su(i, P);
|
1384
1384
|
t.push(...c);
|
1385
1385
|
}
|
1386
1386
|
} else if (a.type === l.ELEMENT && a.tag === "template") {
|
@@ -1390,17 +1390,17 @@ function x0(e, u = []) {
|
|
1390
1390
|
name: "span",
|
1391
1391
|
children: _(c, e)
|
1392
1392
|
} : _(c, e);
|
1393
|
-
s && (Array.isArray(s) ? s : [s]).forEach((
|
1394
|
-
|
1393
|
+
s && (Array.isArray(s) ? s : [s]).forEach((d) => {
|
1394
|
+
$u(d) && i?.type === l.DIRECTIVE && (d.id = pu(d), d.slot = {
|
1395
1395
|
name: i.arg?.content || "default",
|
1396
1396
|
params: i.exp?.identifiers || []
|
1397
|
-
},
|
1397
|
+
}, H(d, e)), t.push(d);
|
1398
1398
|
});
|
1399
1399
|
}
|
1400
1400
|
} else if (a.type === l.JS_CALL_EXPRESSION) {
|
1401
1401
|
const i = a.arguments?.[0];
|
1402
1402
|
if (i) {
|
1403
|
-
const c =
|
1403
|
+
const c = su(i, P);
|
1404
1404
|
t.push(...c);
|
1405
1405
|
}
|
1406
1406
|
} else if (a.type === l.TEXT_CALL) {
|
@@ -1412,7 +1412,7 @@ function x0(e, u = []) {
|
|
1412
1412
|
}
|
1413
1413
|
if (t.length === 1) {
|
1414
1414
|
const a = t[0];
|
1415
|
-
e.children = typeof a == "string" ||
|
1415
|
+
e.children = typeof a == "string" || G(a) ? a : [a];
|
1416
1416
|
} else
|
1417
1417
|
e.children = t.map((a) => typeof a == "string" ? { name: "span", children: a } : a);
|
1418
1418
|
return e;
|
@@ -1422,22 +1422,22 @@ function g0(e, u) {
|
|
1422
1422
|
imports: y0(e),
|
1423
1423
|
emits: [],
|
1424
1424
|
errors: []
|
1425
|
-
}, i =
|
1426
|
-
return
|
1425
|
+
}, i = du(e);
|
1426
|
+
return fu(i, {
|
1427
1427
|
ExportDefaultDeclaration(c) {
|
1428
1428
|
const s = c.node.declaration;
|
1429
1429
|
if (s.type !== "CallExpression") return;
|
1430
|
-
const
|
1431
|
-
if (
|
1432
|
-
const
|
1430
|
+
const n = s.arguments[0];
|
1431
|
+
if (n?.type !== "ObjectExpression") return;
|
1432
|
+
const d = n.properties.filter(
|
1433
1433
|
(b) => b.type === "ObjectProperty"
|
1434
|
-
), f =
|
1434
|
+
), f = n.properties.filter(
|
1435
1435
|
(b) => b.type == "ObjectMethod"
|
1436
|
-
), h =
|
1436
|
+
), h = d.find(
|
1437
1437
|
(b) => b.key.name === "computed"
|
1438
1438
|
);
|
1439
|
-
h && (a.computed =
|
1440
|
-
for (const b of
|
1439
|
+
h && (a.computed = mu(h.value), a.watchers = T0(h.value));
|
1440
|
+
for (const b of d)
|
1441
1441
|
switch (b.key.name) {
|
1442
1442
|
case "name":
|
1443
1443
|
a.name = b.value.value;
|
@@ -1472,8 +1472,8 @@ function g0(e, u) {
|
|
1472
1472
|
CallExpression(c) {
|
1473
1473
|
const s = _0(c.node);
|
1474
1474
|
if (s.length)
|
1475
|
-
for (let
|
1476
|
-
a.emits?.find((f) => f.name ===
|
1475
|
+
for (let n of s)
|
1476
|
+
a.emits?.find((f) => f.name === n.name) || a.emits?.push(n);
|
1477
1477
|
}
|
1478
1478
|
}), a;
|
1479
1479
|
}
|
@@ -1507,23 +1507,25 @@ function S0(e) {
|
|
1507
1507
|
const { key: i, value: c } = a;
|
1508
1508
|
if (i.type === "Identifier") {
|
1509
1509
|
const s = R(c);
|
1510
|
-
t[i.name] =
|
1510
|
+
t[i.name] = S(s);
|
1511
1511
|
}
|
1512
1512
|
}
|
1513
1513
|
return t;
|
1514
1514
|
}
|
1515
1515
|
function q(e) {
|
1516
|
-
const { key: u, async: t, params: a, body: i } = e
|
1516
|
+
const { key: u, async: t, params: a, body: i } = e;
|
1517
|
+
console.log("getFunction--", e, u, t, a, i);
|
1518
|
+
const c = a.map((s) => s.type === "ObjectPattern" ? `{${s.properties.map((d) => d.key?.name || d.name).join(",")}}` : s.name).join(", ");
|
1517
1519
|
if (u.type === "Identifier") {
|
1518
|
-
const s = u.name,
|
1520
|
+
const s = u.name, n = R(i), f = `${t ? "async " : ""}(${c}) => ${n}`, h = s.startsWith("watcher_");
|
1519
1521
|
return {
|
1520
1522
|
name: s,
|
1521
1523
|
watcher: h,
|
1522
|
-
exp:
|
1524
|
+
exp: J(f)
|
1523
1525
|
};
|
1524
1526
|
}
|
1525
1527
|
}
|
1526
|
-
function
|
1528
|
+
function mu(e) {
|
1527
1529
|
if (!e) return {};
|
1528
1530
|
const u = {};
|
1529
1531
|
for (const t of e.properties) {
|
@@ -1538,13 +1540,13 @@ function v0(e, u) {
|
|
1538
1540
|
for (const c of e.properties) {
|
1539
1541
|
const s = q(c);
|
1540
1542
|
if (s && s.exp.value.includes("provider.apis")) {
|
1541
|
-
const
|
1542
|
-
if (!
|
1543
|
-
const f = D0(u,
|
1543
|
+
const d = (s.exp.value.match(a) || [])[1];
|
1544
|
+
if (!d) continue;
|
1545
|
+
const f = D0(u, d);
|
1544
1546
|
if (!f) continue;
|
1545
1547
|
const h = s.exp.value.match(i)?.[1];
|
1546
1548
|
t[s.name] = {
|
1547
|
-
ref:
|
1549
|
+
ref: d,
|
1548
1550
|
name: f.name,
|
1549
1551
|
test: {
|
1550
1552
|
type: "JSFunction",
|
@@ -1567,7 +1569,7 @@ function v0(e, u) {
|
|
1567
1569
|
return t;
|
1568
1570
|
}
|
1569
1571
|
function w0(e) {
|
1570
|
-
const u =
|
1572
|
+
const u = mu(e), t = /\_([\w]{5,})$/, a = {};
|
1571
1573
|
for (const i of Object.keys(u))
|
1572
1574
|
t.test(i) || (a[i] = u[i]);
|
1573
1575
|
return a;
|
@@ -1583,7 +1585,7 @@ function A0(e) {
|
|
1583
1585
|
const c = R(
|
1584
1586
|
a.body.body[0].argument.callee.object
|
1585
1587
|
);
|
1586
|
-
u[i] =
|
1588
|
+
u[i] = J(c);
|
1587
1589
|
} else
|
1588
1590
|
u[i] = q(a)?.exp;
|
1589
1591
|
} catch (c) {
|
@@ -1602,14 +1604,14 @@ function T0(e) {
|
|
1602
1604
|
return u;
|
1603
1605
|
}
|
1604
1606
|
function B(e, u) {
|
1605
|
-
return !!
|
1607
|
+
return !!xu(e, u);
|
1606
1608
|
}
|
1607
|
-
function
|
1609
|
+
function xu(e, u) {
|
1608
1610
|
return e.find(
|
1609
1611
|
(a) => a.key?.name === u
|
1610
1612
|
)?.value?.value;
|
1611
1613
|
}
|
1612
|
-
function
|
1614
|
+
function ru(e, u) {
|
1613
1615
|
const t = e.find(
|
1614
1616
|
(a) => a.key?.name === u
|
1615
1617
|
);
|
@@ -1621,12 +1623,12 @@ function I0(e, u = {}) {
|
|
1621
1623
|
for (const a of e.properties) {
|
1622
1624
|
const { key: i, value: c } = a, s = i.value || i.name || "";
|
1623
1625
|
if (u[s]) {
|
1624
|
-
const
|
1626
|
+
const n = c.properties;
|
1625
1627
|
t.push({
|
1626
1628
|
source: u[s],
|
1627
|
-
deep: B(
|
1628
|
-
immediate: B(
|
1629
|
-
handler:
|
1629
|
+
deep: B(n, "deep"),
|
1630
|
+
immediate: B(n, "immediate"),
|
1631
|
+
handler: ru(n, "handler")
|
1630
1632
|
});
|
1631
1633
|
} else if (a.type === "ObjectMethod" && t.push({
|
1632
1634
|
// todo: 处理上下文
|
@@ -1638,16 +1640,16 @@ function I0(e, u = {}) {
|
|
1638
1640
|
immediate: !1,
|
1639
1641
|
handler: q(a)?.exp
|
1640
1642
|
}), a.type === "ObjectProperty") {
|
1641
|
-
const
|
1643
|
+
const n = c.properties;
|
1642
1644
|
t.push({
|
1643
1645
|
// todo: 处理上下文
|
1644
1646
|
source: {
|
1645
1647
|
type: "JSFunction",
|
1646
1648
|
value: `this.${s}`
|
1647
1649
|
},
|
1648
|
-
deep: B(
|
1649
|
-
immediate: B(
|
1650
|
-
handler:
|
1650
|
+
deep: B(n, "deep"),
|
1651
|
+
immediate: B(n, "immediate"),
|
1652
|
+
handler: ru(n, "handler")
|
1651
1653
|
});
|
1652
1654
|
}
|
1653
1655
|
}
|
@@ -1657,7 +1659,7 @@ function N0(e) {
|
|
1657
1659
|
const u = {};
|
1658
1660
|
for (const t of e) {
|
1659
1661
|
const a = t.key.name;
|
1660
|
-
if (
|
1662
|
+
if (ju.includes(a)) {
|
1661
1663
|
const i = q(t);
|
1662
1664
|
i && (u[i.name] = i.exp);
|
1663
1665
|
}
|
@@ -1671,12 +1673,12 @@ function q0(e) {
|
|
1671
1673
|
if (u)
|
1672
1674
|
return u.value.type === "ArrayExpression" ? u.value.elements.map((t) => t.name) : u.value.name;
|
1673
1675
|
}
|
1674
|
-
function
|
1676
|
+
function gu(e) {
|
1675
1677
|
const u = e.find(
|
1676
1678
|
(t) => t.key?.name === "default"
|
1677
1679
|
);
|
1678
1680
|
if (u)
|
1679
|
-
return
|
1681
|
+
return S(R(u.value));
|
1680
1682
|
}
|
1681
1683
|
function k0(e) {
|
1682
1684
|
if (!e) return [];
|
@@ -1687,7 +1689,7 @@ function k0(e) {
|
|
1687
1689
|
name: a.name,
|
1688
1690
|
required: B(c, "required"),
|
1689
1691
|
type: q0(c),
|
1690
|
-
default:
|
1692
|
+
default: gu(c)
|
1691
1693
|
};
|
1692
1694
|
})), u;
|
1693
1695
|
}
|
@@ -1707,11 +1709,11 @@ function _0(e) {
|
|
1707
1709
|
function L0(e) {
|
1708
1710
|
let u = [];
|
1709
1711
|
return e.type === "ObjectExpression" && (u = e.properties.map((t) => {
|
1710
|
-
const { key: a, value: i } = t, c = i.properties, s = a.name,
|
1712
|
+
const { key: a, value: i } = t, c = i.properties, s = a.name, n = xu(c, "from"), d = gu(c);
|
1711
1713
|
return {
|
1712
1714
|
name: s,
|
1713
|
-
from:
|
1714
|
-
default:
|
1715
|
+
from: n || s,
|
1716
|
+
default: d
|
1715
1717
|
};
|
1716
1718
|
})), u;
|
1717
1719
|
}
|
@@ -1724,10 +1726,10 @@ function B0(e) {
|
|
1724
1726
|
const i = Pu.parse(e), c = /^.[\w]+_[\w]{5,}/;
|
1725
1727
|
for (const s of i.nodes)
|
1726
1728
|
if (s.type === "rule") {
|
1727
|
-
const
|
1728
|
-
c.test(s.selector) ? (s.nodes.forEach((
|
1729
|
-
|
1730
|
-
}), t[s.selector] =
|
1729
|
+
const n = {};
|
1730
|
+
c.test(s.selector) ? (s.nodes.forEach((d) => {
|
1731
|
+
d.type === "decl" && (n[d.prop] = d.value);
|
1732
|
+
}), t[s.selector] = n) : a.push(s.toString());
|
1731
1733
|
}
|
1732
1734
|
} catch (i) {
|
1733
1735
|
u.push(`css解析出错了,错误信息:[ ${i.message} ]
|
@@ -1741,46 +1743,46 @@ function B0(e) {
|
|
1741
1743
|
};
|
1742
1744
|
}
|
1743
1745
|
async function W0(e) {
|
1744
|
-
const { id: u, name: t, source: a, project: i } = e, { dependencies: c = [], platform: s = "web" } = i || {},
|
1745
|
-
if (
|
1746
|
-
return Promise.reject(
|
1747
|
-
const
|
1746
|
+
const { id: u, name: t, source: a, project: i } = e, { dependencies: c = [], platform: s = "web" } = i || {}, n = Ju(a);
|
1747
|
+
if (n.length)
|
1748
|
+
return Promise.reject(n);
|
1749
|
+
const d = nu(a), {
|
1748
1750
|
styles: f,
|
1749
1751
|
css: h,
|
1750
1752
|
errors: b
|
1751
|
-
} = B0(
|
1753
|
+
} = B0(d.styles.join(`
|
1752
1754
|
`)), {
|
1753
1755
|
state: E,
|
1754
1756
|
watch: m,
|
1755
|
-
lifeCycles:
|
1757
|
+
lifeCycles: v,
|
1756
1758
|
computed: w,
|
1757
|
-
methods:
|
1758
|
-
props:
|
1759
|
-
emits:
|
1760
|
-
inject:
|
1761
|
-
handlers:
|
1762
|
-
imports:
|
1763
|
-
dataSources:
|
1764
|
-
} = g0(
|
1759
|
+
methods: X,
|
1760
|
+
props: yu,
|
1761
|
+
emits: Eu,
|
1762
|
+
inject: Su,
|
1763
|
+
handlers: vu,
|
1764
|
+
imports: wu,
|
1765
|
+
dataSources: Au
|
1766
|
+
} = g0(d.script, i), { nodes: Tu, slots: Iu, context: Nu } = f0(u, t, d.template, {
|
1765
1767
|
platform: s,
|
1766
|
-
handlers:
|
1768
|
+
handlers: vu,
|
1767
1769
|
styles: f
|
1768
|
-
}),
|
1770
|
+
}), z = {
|
1769
1771
|
id: u,
|
1770
1772
|
name: t,
|
1771
|
-
inject:
|
1772
|
-
props:
|
1773
|
+
inject: Su,
|
1774
|
+
props: yu,
|
1773
1775
|
state: E,
|
1774
1776
|
watch: m,
|
1775
|
-
lifeCycles:
|
1777
|
+
lifeCycles: v,
|
1776
1778
|
computed: w,
|
1777
|
-
methods:
|
1778
|
-
dataSources:
|
1779
|
-
slots:
|
1780
|
-
emits:
|
1781
|
-
nodes:
|
1779
|
+
methods: X,
|
1780
|
+
dataSources: Au,
|
1781
|
+
slots: Iu,
|
1782
|
+
emits: Eu,
|
1783
|
+
nodes: Tu,
|
1782
1784
|
css: h
|
1783
|
-
},
|
1785
|
+
}, qu = Object.keys(w || {}), ku = [
|
1784
1786
|
"$el",
|
1785
1787
|
"$emit",
|
1786
1788
|
"$nextTick",
|
@@ -1796,33 +1798,33 @@ async function W0(e) {
|
|
1796
1798
|
"state",
|
1797
1799
|
"$props",
|
1798
1800
|
"props",
|
1799
|
-
...Object.keys(
|
1800
|
-
], { libs:
|
1801
|
+
...Object.keys(X || {})
|
1802
|
+
], { libs: _u } = V0(wu, c), W = {
|
1801
1803
|
platform: s,
|
1802
|
-
context:
|
1803
|
-
computed:
|
1804
|
-
libs:
|
1805
|
-
members:
|
1804
|
+
context: Nu,
|
1805
|
+
computed: qu,
|
1806
|
+
libs: _u,
|
1807
|
+
members: ku
|
1806
1808
|
};
|
1807
1809
|
return await R0(
|
1808
|
-
|
1810
|
+
z,
|
1809
1811
|
async (L) => {
|
1810
1812
|
await O0(L, async (D) => {
|
1811
|
-
if (
|
1812
|
-
const
|
1813
|
-
D.value =
|
1813
|
+
if (C(D)) {
|
1814
|
+
const Lu = await K(D.value);
|
1815
|
+
D.value = Y(Lu, L.id, W);
|
1814
1816
|
}
|
1815
1817
|
});
|
1816
1818
|
},
|
1817
1819
|
async (L) => {
|
1818
|
-
const D = await
|
1819
|
-
L.value =
|
1820
|
+
const D = await K(L.value);
|
1821
|
+
L.value = Y(D, "", W);
|
1820
1822
|
}
|
1821
|
-
),
|
1823
|
+
), n.push(...b), n.length ? Promise.reject(n) : new Ou(z).toDsl();
|
1822
1824
|
}
|
1823
1825
|
async function R0(e, u, t) {
|
1824
|
-
const a = async (m,
|
1825
|
-
if (await u(m,
|
1826
|
+
const a = async (m, v) => {
|
1827
|
+
if (await u(m, v), Array.isArray(m.children))
|
1826
1828
|
for (const w of m.children)
|
1827
1829
|
await a(w, m);
|
1828
1830
|
}, i = async (m) => {
|
@@ -1832,14 +1834,14 @@ async function R0(e, u, t) {
|
|
1832
1834
|
await i(w);
|
1833
1835
|
return;
|
1834
1836
|
}
|
1835
|
-
const
|
1836
|
-
for (const w of
|
1837
|
-
|
1837
|
+
const v = Object.values(m);
|
1838
|
+
for (const w of v)
|
1839
|
+
C(w) ? await t(w) : await i(w);
|
1838
1840
|
}, {
|
1839
1841
|
state: c,
|
1840
1842
|
watch: s,
|
1841
|
-
computed:
|
1842
|
-
props:
|
1843
|
+
computed: n,
|
1844
|
+
props: d,
|
1843
1845
|
dataSources: f,
|
1844
1846
|
methods: h,
|
1845
1847
|
lifeCycles: b,
|
@@ -1848,8 +1850,8 @@ async function R0(e, u, t) {
|
|
1848
1850
|
if (await i({
|
1849
1851
|
state: c,
|
1850
1852
|
watch: s,
|
1851
|
-
computed:
|
1852
|
-
props:
|
1853
|
+
computed: n,
|
1854
|
+
props: d,
|
1853
1855
|
dataSources: f,
|
1854
1856
|
methods: h,
|
1855
1857
|
lifeCycles: b,
|
@@ -1866,7 +1868,7 @@ async function O0(e, u) {
|
|
1866
1868
|
await u(c), await t(c);
|
1867
1869
|
return;
|
1868
1870
|
}
|
1869
|
-
if (
|
1871
|
+
if (C(a)) {
|
1870
1872
|
await u(a);
|
1871
1873
|
return;
|
1872
1874
|
}
|
@@ -1883,8 +1885,8 @@ function V0(e = [], u = []) {
|
|
1883
1885
|
);
|
1884
1886
|
for (const { from: i, imports: c } of e)
|
1885
1887
|
c.forEach((s) => {
|
1886
|
-
const
|
1887
|
-
|
1888
|
+
const n = a[i];
|
1889
|
+
n && (t[s] = n);
|
1888
1890
|
});
|
1889
1891
|
return {
|
1890
1892
|
libs: t
|
@@ -1892,9 +1894,9 @@ function V0(e = [], u = []) {
|
|
1892
1894
|
}
|
1893
1895
|
export {
|
1894
1896
|
X0 as VTJ_PARSER_VERSION,
|
1895
|
-
|
1897
|
+
su as htmlToNodes,
|
1896
1898
|
z0 as parseUniApp,
|
1897
1899
|
W0 as parseVue,
|
1898
|
-
|
1900
|
+
Y as patchCode,
|
1899
1901
|
O as replacer
|
1900
1902
|
};
|