@vtj/coder 0.19.22 → 0.19.23-alpha.0
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 +57 -57
- package/dist/index.mjs +564 -515
- package/package.json +2 -2
- package/types/generator.d.ts +3 -2
- package/types/parser/composition/index.d.ts +1 -1
- package/types/parser/index.d.ts +1 -1
- package/types/version.d.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { mitt as
|
|
1
|
+
import { mitt as Ie, base64 as Oe, dedupArray as M, toArray as Ce, kebabCase as J, camelCase as E, isPlainObject as xe, isString as Ae, template as q, cloneDeep as Pe } from "@vtj/base";
|
|
2
2
|
import { format as V } from "prettier/standalone";
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
3
|
+
import * as Ee from "prettier/plugins/html";
|
|
4
|
+
import * as Y from "prettier/plugins/babel";
|
|
5
|
+
import * as K from "prettier/plugins/postcss";
|
|
6
|
+
import * as ee from "prettier/plugins/estree";
|
|
7
7
|
/**!
|
|
8
8
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
9
9
|
* @name @vtj/coder
|
|
10
10
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
11
|
-
* @version 0.19.
|
|
11
|
+
* @version 0.19.23-alpha.0
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/
|
|
14
|
-
const
|
|
14
|
+
const Jt = "0.19.23-alpha.0";
|
|
15
15
|
/**!
|
|
16
16
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
17
17
|
* @name @vtj/core
|
|
18
18
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
19
|
-
* @version 0.19.
|
|
19
|
+
* @version 0.19.23-alpha.0
|
|
20
20
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
22
|
+
const Be = [
|
|
23
23
|
"slot",
|
|
24
24
|
"template",
|
|
25
25
|
"component",
|
|
@@ -32,8 +32,45 @@ const Ce = [
|
|
|
32
32
|
"span",
|
|
33
33
|
"a"
|
|
34
34
|
];
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
Ie();
|
|
36
|
+
function Ne(t) {
|
|
37
|
+
return (t || "").trim().replace(/\\/g, "/").replace(/^\/+|\/+$/g, "").replace(/\.vue$/i, "");
|
|
38
|
+
}
|
|
39
|
+
function te(t) {
|
|
40
|
+
return Ne(t.filePath) || t.id;
|
|
41
|
+
}
|
|
42
|
+
function W(t, e = "web") {
|
|
43
|
+
const s = te(t);
|
|
44
|
+
return t.type === "block" ? `src/components/${s}.vue` : e === "uniapp" ? `src/pages/${s}.vue` : `src/views/${s}.vue`;
|
|
45
|
+
}
|
|
46
|
+
function se(t) {
|
|
47
|
+
return `@/components/${te(t)}.vue`;
|
|
48
|
+
}
|
|
49
|
+
function ne(t = []) {
|
|
50
|
+
const e = [];
|
|
51
|
+
for (const s of t)
|
|
52
|
+
s.dir || e.push(s), s.children?.length && e.push(...ne(s.children));
|
|
53
|
+
return e;
|
|
54
|
+
}
|
|
55
|
+
function Me(t) {
|
|
56
|
+
const e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const r of t.blocks || []) {
|
|
58
|
+
const c = W(r, t.platform).toLowerCase();
|
|
59
|
+
e.set(r.id, r), o.set(c, r.id), s.set(se(r).toLowerCase(), r.id);
|
|
60
|
+
}
|
|
61
|
+
for (const r of ne(t.pages))
|
|
62
|
+
e.set(r.id, r), n.set(
|
|
63
|
+
W(r, t.platform).toLowerCase(),
|
|
64
|
+
r.id
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
byId: e,
|
|
68
|
+
blockIdByImportPath: s,
|
|
69
|
+
blockIdBySourcePath: o,
|
|
70
|
+
pageIdBySourcePath: n
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const G = {
|
|
37
74
|
arrowParens: "always",
|
|
38
75
|
bracketSpacing: !0,
|
|
39
76
|
bracketSameLine: !0,
|
|
@@ -54,61 +91,61 @@ const q = {
|
|
|
54
91
|
vueIndentScriptAndStyle: !0,
|
|
55
92
|
removeBlankLines: !0
|
|
56
93
|
};
|
|
57
|
-
async function
|
|
94
|
+
async function re(t, e) {
|
|
58
95
|
return e ? t : await V(t, {
|
|
59
96
|
parser: "vue",
|
|
60
|
-
...
|
|
61
|
-
plugins: [
|
|
97
|
+
...G,
|
|
98
|
+
plugins: [Ee, Y, ee, K]
|
|
62
99
|
});
|
|
63
100
|
}
|
|
64
|
-
async function
|
|
101
|
+
async function Te(t, e) {
|
|
65
102
|
if (e) return t;
|
|
66
103
|
try {
|
|
67
104
|
return (await V(t, {
|
|
68
105
|
parser: "babel-ts",
|
|
69
|
-
...
|
|
70
|
-
plugins: [
|
|
106
|
+
...G,
|
|
107
|
+
plugins: [Y, ee]
|
|
71
108
|
})).replace(/;\n$/gi, "");
|
|
72
109
|
} catch (s) {
|
|
73
110
|
return console.warn(s), t;
|
|
74
111
|
}
|
|
75
112
|
}
|
|
76
|
-
async function
|
|
113
|
+
async function Z(t, e) {
|
|
77
114
|
return e ? t : V(t, {
|
|
78
115
|
parser: "scss",
|
|
79
|
-
...
|
|
80
|
-
plugins: [
|
|
116
|
+
...G,
|
|
117
|
+
plugins: [K]
|
|
81
118
|
});
|
|
82
119
|
}
|
|
83
|
-
function
|
|
120
|
+
function T(t) {
|
|
84
121
|
return t && t.type === "JSExpression";
|
|
85
122
|
}
|
|
86
|
-
function
|
|
123
|
+
function L(t) {
|
|
87
124
|
return typeof t == "object" && t && t.type === "JSFunction";
|
|
88
125
|
}
|
|
89
|
-
function
|
|
90
|
-
return
|
|
126
|
+
function j(t) {
|
|
127
|
+
return T(t) || L(t);
|
|
91
128
|
}
|
|
92
|
-
function
|
|
129
|
+
function oe(t) {
|
|
93
130
|
return t.replace(new RegExp("this.", "g"), "");
|
|
94
131
|
}
|
|
95
|
-
function
|
|
132
|
+
function H(t) {
|
|
96
133
|
return t.replace(/this\.context\??\./g, "");
|
|
97
134
|
}
|
|
98
|
-
function _(t, e = !0, s = !0,
|
|
135
|
+
function _(t, e = !0, s = !0, o = [], n = !0) {
|
|
99
136
|
let r = t;
|
|
100
|
-
return
|
|
137
|
+
return j(t) ? (r = t.value.trim().replace(/;$/, ""), n && (r = r.replace(/\"/g, "'"))) : r = e ? JSON.stringify(r) : t, r = R(r, o), s ? oe(H(r)) : H(r);
|
|
101
138
|
}
|
|
102
|
-
function
|
|
139
|
+
function R(t = "", e = []) {
|
|
103
140
|
let s = t;
|
|
104
|
-
for (const
|
|
141
|
+
for (const o of e)
|
|
105
142
|
s = s.replace(
|
|
106
|
-
new RegExp(`this.${
|
|
107
|
-
`this.${
|
|
143
|
+
new RegExp(`this.${o}.value`, "g"),
|
|
144
|
+
`this.${o}`
|
|
108
145
|
);
|
|
109
146
|
return s;
|
|
110
147
|
}
|
|
111
|
-
function
|
|
148
|
+
function ce(t) {
|
|
112
149
|
let e = t.trim().replace(/;$/, "");
|
|
113
150
|
if (e = /^\((\(|async|function)/.test(e) ? e.substring(1, e.length - 1) : e, e.startsWith("{")) return e;
|
|
114
151
|
if (e.startsWith("async function"))
|
|
@@ -116,34 +153,34 @@ function se(t) {
|
|
|
116
153
|
else if (e.startsWith("function"))
|
|
117
154
|
e = e.replace(/^function/, "");
|
|
118
155
|
else {
|
|
119
|
-
const
|
|
156
|
+
const n = /^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/, r = e.match(n);
|
|
120
157
|
r && r[2] && (r[2].startsWith("{") || (e = e.replace(r[2], `{ return ${r[2]} }`))), e = e.replace("=>", "");
|
|
121
158
|
}
|
|
122
159
|
return e;
|
|
123
160
|
}
|
|
124
|
-
function
|
|
161
|
+
function Re(t = {}) {
|
|
125
162
|
return Object.entries(t).map(([e, s]) => `"${e}": ${_(s)}`);
|
|
126
163
|
}
|
|
127
|
-
function
|
|
164
|
+
function ae(t = {}, e = !1) {
|
|
128
165
|
const s = Object.keys(t);
|
|
129
|
-
return e ? s.map((
|
|
166
|
+
return e ? s.map((o) => "." + o) : s;
|
|
130
167
|
}
|
|
131
|
-
function
|
|
168
|
+
function Le(t) {
|
|
132
169
|
let e = "";
|
|
133
170
|
for (var s in t)
|
|
134
171
|
if (t.hasOwnProperty(s)) {
|
|
135
|
-
var
|
|
136
|
-
e += s + ": " +
|
|
172
|
+
var o = t[s];
|
|
173
|
+
e += s + ": " + o + ";";
|
|
137
174
|
}
|
|
138
175
|
return e;
|
|
139
176
|
}
|
|
140
|
-
function
|
|
177
|
+
function De(t = [], e = []) {
|
|
141
178
|
return t.filter((s) => !e.includes(s));
|
|
142
179
|
}
|
|
143
|
-
function
|
|
144
|
-
return
|
|
180
|
+
function Q(t) {
|
|
181
|
+
return Oe(JSON.stringify(t));
|
|
145
182
|
}
|
|
146
|
-
class
|
|
183
|
+
class Ue {
|
|
147
184
|
constructor(e, s) {
|
|
148
185
|
this.dsl = e, this.dependencies = s, this.collectEasycom(), this.libraryRegex = this.collectLibrary(), this.walk(e), this.walkNodes(e), this.members = this.getLibraryMember();
|
|
149
186
|
}
|
|
@@ -174,16 +211,16 @@ class Ne {
|
|
|
174
211
|
collectImport(e) {
|
|
175
212
|
const s = e.split(".");
|
|
176
213
|
if (s.length === 4) {
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
214
|
+
const o = s.pop(), n = s.join(".") + ".", r = s.pop();
|
|
215
|
+
if (o && r) {
|
|
179
216
|
const c = this.dependencies.find(
|
|
180
217
|
(a) => a.library === r
|
|
181
218
|
)?.package;
|
|
182
|
-
c && !this.easycomPackages.has(c) && (this.imports[c] || (this.imports[c] = /* @__PURE__ */ new Set())).add(
|
|
219
|
+
c && !this.easycomPackages.has(c) && (this.imports[c] || (this.imports[c] = /* @__PURE__ */ new Set())).add(o);
|
|
183
220
|
}
|
|
184
221
|
return {
|
|
185
|
-
name:
|
|
186
|
-
path:
|
|
222
|
+
name: o,
|
|
223
|
+
path: n,
|
|
187
224
|
library: r
|
|
188
225
|
};
|
|
189
226
|
}
|
|
@@ -192,46 +229,46 @@ class Ne {
|
|
|
192
229
|
// 代码中包含依赖库的引用,需要从代码中移除
|
|
193
230
|
replaceLibraryPath(e) {
|
|
194
231
|
const { libraryRegex: s } = this;
|
|
195
|
-
let
|
|
196
|
-
for (const
|
|
197
|
-
const r = e.value?.match(
|
|
232
|
+
let o = e.value;
|
|
233
|
+
for (const n of s) {
|
|
234
|
+
const r = e.value?.match(n) || [];
|
|
198
235
|
for (const c of r) {
|
|
199
236
|
const a = this.collectImport(c);
|
|
200
237
|
if (a) {
|
|
201
238
|
const l = a.path.replace(/\$/g, "\\$");
|
|
202
|
-
|
|
239
|
+
o = o.replace(new RegExp(l, "g"), "");
|
|
203
240
|
}
|
|
204
241
|
}
|
|
205
242
|
}
|
|
206
|
-
return
|
|
243
|
+
return o;
|
|
207
244
|
}
|
|
208
245
|
walk(e) {
|
|
209
|
-
const s = (
|
|
210
|
-
if (!
|
|
211
|
-
if (Array.isArray(
|
|
212
|
-
for (let r of
|
|
246
|
+
const s = (o) => {
|
|
247
|
+
if (!o || typeof o != "object") return;
|
|
248
|
+
if (Array.isArray(o)) {
|
|
249
|
+
for (let r of o)
|
|
213
250
|
s(r);
|
|
214
251
|
return;
|
|
215
252
|
}
|
|
216
|
-
const
|
|
217
|
-
for (const r of
|
|
218
|
-
|
|
253
|
+
const n = Object.values(o);
|
|
254
|
+
for (const r of n)
|
|
255
|
+
j(r) ? r.value = this.replaceLibraryPath(r) : s(r);
|
|
219
256
|
};
|
|
220
257
|
s(e);
|
|
221
258
|
}
|
|
222
259
|
getLibraryMember(e = []) {
|
|
223
260
|
let s = [...e];
|
|
224
|
-
const
|
|
225
|
-
delete
|
|
226
|
-
for (const
|
|
227
|
-
s = s.concat(Array.from(
|
|
261
|
+
const o = { ...this.imports };
|
|
262
|
+
delete o["uni-h5"], delete o["@dcloudio/uni-h5"], delete o["uni-ui"], delete o["@dcloudio/uni-ui"];
|
|
263
|
+
for (const n of Object.values(o))
|
|
264
|
+
s = s.concat(Array.from(n));
|
|
228
265
|
return M(s);
|
|
229
266
|
}
|
|
230
267
|
collectContext(e, s) {
|
|
231
|
-
const
|
|
232
|
-
let r = new Set(Array.from(
|
|
233
|
-
if (
|
|
234
|
-
const { item: a = "item", index: l = "index" } =
|
|
268
|
+
const o = new Set(s?.id ? this.context[s.id] : []), n = (e.directives || []).find((a) => a.name === "vFor");
|
|
269
|
+
let r = new Set(Array.from(o));
|
|
270
|
+
if (n) {
|
|
271
|
+
const { item: a = "item", index: l = "index" } = n.iterator || {};
|
|
235
272
|
r = /* @__PURE__ */ new Set([a, l, ...Array.from(r)]);
|
|
236
273
|
}
|
|
237
274
|
const c = e.slot;
|
|
@@ -242,7 +279,7 @@ class Ne {
|
|
|
242
279
|
this.context[e.id] = r;
|
|
243
280
|
}
|
|
244
281
|
collectStyle(e) {
|
|
245
|
-
e.id && e.props?.style && Object.keys(e.props.style).length && !
|
|
282
|
+
e.id && e.props?.style && Object.keys(e.props.style).length && !j(e.props.style) && (this.style[`.${e.name}_${e.id}`] = e.props.style);
|
|
246
283
|
}
|
|
247
284
|
collectUrlSchema(e) {
|
|
248
285
|
typeof e.from == "object" && e.from.type === "UrlSchema" && (this.urlSchemas[e.name] = e.from);
|
|
@@ -251,76 +288,76 @@ class Ne {
|
|
|
251
288
|
typeof e.from == "object" && e.from.type === "Plugin" && (this.blockPlugins[e.name] = e.from);
|
|
252
289
|
}
|
|
253
290
|
walkNodes(e) {
|
|
254
|
-
const s = (
|
|
255
|
-
this.collectContext(
|
|
291
|
+
const s = (o, n) => {
|
|
292
|
+
this.collectContext(o, n), this.collectStyle(o), this.collectUrlSchema(o), this.collectBlockPlugin(o), Array.isArray(o.children) && o.children.forEach((r) => s(r, o));
|
|
256
293
|
};
|
|
257
|
-
Array.isArray(e.nodes) && e.nodes.forEach((
|
|
294
|
+
Array.isArray(e.nodes) && e.nodes.forEach((o) => s(o));
|
|
258
295
|
}
|
|
259
296
|
}
|
|
260
|
-
function
|
|
297
|
+
function Fe(t = {}) {
|
|
261
298
|
return Object.entries(t).map(([e, s]) => {
|
|
262
|
-
const
|
|
263
|
-
return `${e}:${
|
|
299
|
+
const o = _(s, !1, !0, [], !1);
|
|
300
|
+
return `${e}:${o}`;
|
|
264
301
|
});
|
|
265
302
|
}
|
|
266
|
-
function
|
|
303
|
+
function Je(t = []) {
|
|
267
304
|
return t.map((e) => `${e.name}: {
|
|
268
305
|
from: '${e.from || e.name}',
|
|
269
306
|
default: ${_(e.default, !0, !1, [], !1)}
|
|
270
307
|
}`);
|
|
271
308
|
}
|
|
272
|
-
function
|
|
273
|
-
const e = (s) => s ? `[${
|
|
274
|
-
return t.map((s) => typeof s == "string" ? `${s}: {}` : (
|
|
309
|
+
function ie(t = []) {
|
|
310
|
+
const e = (s) => s ? `[${Ce(s).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
|
|
311
|
+
return t.map((s) => typeof s == "string" ? `${s}: {}` : (j(s.default) && !s.default.value && (s.default.value = "undefined"), `${s.name}: {
|
|
275
312
|
type:${e(s.type)},
|
|
276
313
|
required: ${_(!!s.required, !0, !1, [], !1)},
|
|
277
314
|
default: ${s.default ? _(s.default, !0, !1, [], !1) : "undefined"}
|
|
278
315
|
}`));
|
|
279
316
|
}
|
|
280
|
-
function
|
|
317
|
+
function le(t = []) {
|
|
281
318
|
return t.map((e) => `'${typeof e == "string" ? e : e.name}'`);
|
|
282
319
|
}
|
|
283
320
|
function F(t = {}, e = []) {
|
|
284
|
-
return Object.entries(t).map(([s,
|
|
285
|
-
let
|
|
286
|
-
_(
|
|
321
|
+
return Object.entries(t).map(([s, o]) => {
|
|
322
|
+
let n = ce(
|
|
323
|
+
_(o, !1, !1, [], !1)
|
|
287
324
|
);
|
|
288
|
-
return
|
|
325
|
+
return n = R(n, e)?.trim(), n.startsWith("async") ? `async ${s}${n.replace(/^async/, "")}` : n.startsWith("(") || n.startsWith("{") ? `${s}${n}` : null;
|
|
289
326
|
}).filter((s) => !!s);
|
|
290
327
|
}
|
|
291
|
-
function
|
|
328
|
+
function We(t = [], e = []) {
|
|
292
329
|
const s = t.reduce(
|
|
293
|
-
(r, c) => (c.id &&
|
|
330
|
+
(r, c) => (c.id && L(c.source) && (r[`watcher_${c.id}`] = c.source), r),
|
|
294
331
|
{}
|
|
295
|
-
),
|
|
332
|
+
), o = F(s, e), n = t.map((r) => r.handler && r.handler.value ? `watcher_${r.id}: {
|
|
296
333
|
deep: ${r.deep},
|
|
297
334
|
immediate:${r.immediate},
|
|
298
|
-
handler${
|
|
335
|
+
handler${ce(r.handler.value)}
|
|
299
336
|
}` : null).filter((r) => !!r);
|
|
300
337
|
return {
|
|
301
|
-
computed:
|
|
302
|
-
watches:
|
|
338
|
+
computed: o,
|
|
339
|
+
watches: n
|
|
303
340
|
};
|
|
304
341
|
}
|
|
305
|
-
function
|
|
342
|
+
function He(t = {}) {
|
|
306
343
|
return Object.values(t).map((e) => {
|
|
307
344
|
if (e.type === "mock") {
|
|
308
|
-
const s =
|
|
345
|
+
const s = L(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
|
|
309
346
|
return `async ${e.name}(...args) {
|
|
310
|
-
// DataSource: ${
|
|
347
|
+
// DataSource: ${Q(e)}
|
|
311
348
|
const mock = this.provider.createMock(${s});
|
|
312
349
|
return await mock.apply(this, args);
|
|
313
350
|
}`;
|
|
314
351
|
} else {
|
|
315
|
-
const s =
|
|
352
|
+
const s = L(e.transform) && e.transform.value || "(res) => res";
|
|
316
353
|
return `async ${e.name}(...args) {
|
|
317
|
-
// DataSource: ${
|
|
354
|
+
// DataSource: ${Q(e)}
|
|
318
355
|
return await this.provider.apis['${e.ref}'].apply(this, args).then(${s});
|
|
319
356
|
}`;
|
|
320
357
|
}
|
|
321
358
|
});
|
|
322
359
|
}
|
|
323
|
-
const
|
|
360
|
+
const qe = [
|
|
324
361
|
"img",
|
|
325
362
|
"input",
|
|
326
363
|
"br",
|
|
@@ -335,7 +372,7 @@ const De = [
|
|
|
335
372
|
"source",
|
|
336
373
|
"track",
|
|
337
374
|
"wbr"
|
|
338
|
-
],
|
|
375
|
+
], X = [
|
|
339
376
|
"vIf",
|
|
340
377
|
"vElseIf",
|
|
341
378
|
"vElse",
|
|
@@ -345,238 +382,238 @@ const De = [
|
|
|
345
382
|
"vBind",
|
|
346
383
|
"vHtml"
|
|
347
384
|
];
|
|
348
|
-
function
|
|
385
|
+
function z(t, e, s = [], o = {}, n, r = /* @__PURE__ */ new Set()) {
|
|
349
386
|
const c = [];
|
|
350
387
|
let a = {}, l = [];
|
|
351
|
-
const
|
|
352
|
-
let
|
|
353
|
-
return
|
|
388
|
+
const m = [];
|
|
389
|
+
let p = [];
|
|
390
|
+
return Ge(t).forEach((u) => {
|
|
354
391
|
const f = [];
|
|
355
392
|
for (const g of u.children) {
|
|
356
|
-
let { id:
|
|
357
|
-
if (
|
|
393
|
+
let { id: C, name: h, invisible: $, from: d } = g;
|
|
394
|
+
if ($)
|
|
358
395
|
continue;
|
|
359
|
-
const y =
|
|
360
|
-
y && l.push(y),
|
|
361
|
-
const { props:
|
|
396
|
+
const y = ze(h, e, d);
|
|
397
|
+
y && l.push(y), ue(d) && p.push({ id: d.id, name: h });
|
|
398
|
+
const { props: S, events: w } = Ke(
|
|
362
399
|
g,
|
|
363
|
-
|
|
400
|
+
C,
|
|
364
401
|
g.props,
|
|
365
402
|
g.events,
|
|
366
|
-
|
|
403
|
+
o,
|
|
367
404
|
s
|
|
368
|
-
),
|
|
405
|
+
), I = et(
|
|
369
406
|
g.directives,
|
|
370
407
|
s,
|
|
371
|
-
|
|
372
|
-
).join(" "),
|
|
408
|
+
m
|
|
409
|
+
).join(" "), v = g.children ? nt(
|
|
373
410
|
g.children,
|
|
374
411
|
s,
|
|
375
412
|
e,
|
|
376
|
-
|
|
413
|
+
o,
|
|
377
414
|
g,
|
|
378
415
|
r
|
|
379
416
|
) : "";
|
|
380
|
-
let
|
|
381
|
-
typeof
|
|
382
|
-
`), Object.assign(a,
|
|
383
|
-
const
|
|
417
|
+
let x = "";
|
|
418
|
+
typeof v == "string" ? x = v : (x = (v?.nodes || []).join(`
|
|
419
|
+
`), Object.assign(a, v?.methods || {}), l = l.concat(v?.components || []), p = p.concat(v?.importBlocks || []));
|
|
420
|
+
const D = d || e.get(h)?.package, A = r.has(D) ? J(h) : ["@dcloudio/uni-h5", "@dcloudio/uni-ui"].includes(D) ? J(h) : pe(d) || fe(d) ? "component" : h;
|
|
384
421
|
f.push(
|
|
385
|
-
|
|
386
|
-
` +
|
|
422
|
+
qe.includes(A) ? `<${A} ${I} ${S} ${w} />` : `<${A} ${I} ${S} ${w}>${x ? `
|
|
423
|
+
` + x.trim() : ""}</${A}>`
|
|
387
424
|
);
|
|
388
425
|
}
|
|
389
|
-
const b =
|
|
390
|
-
`),
|
|
426
|
+
const b = rt(u.slot, f.join(`
|
|
427
|
+
`), n?.id);
|
|
391
428
|
c.push(b);
|
|
392
429
|
}), {
|
|
393
430
|
nodes: c,
|
|
394
431
|
methods: a,
|
|
395
|
-
directives:
|
|
432
|
+
directives: Ve(m),
|
|
396
433
|
components: M(l),
|
|
397
|
-
importBlocks: M(
|
|
434
|
+
importBlocks: M(p, "id")
|
|
398
435
|
};
|
|
399
436
|
}
|
|
400
|
-
function
|
|
437
|
+
function Ve(t) {
|
|
401
438
|
return M(t).map((e) => `${e.startsWith("v") ? e.substring(1) : e}:${e}`);
|
|
402
439
|
}
|
|
403
|
-
function
|
|
440
|
+
function Ge(t = []) {
|
|
404
441
|
const e = /* @__PURE__ */ new Map();
|
|
405
442
|
for (const s of t) {
|
|
406
|
-
const
|
|
407
|
-
|
|
443
|
+
const o = typeof s.slot == "string" ? s.slot : s.slot?.name, n = e.get(o);
|
|
444
|
+
n ? n.children.push(s) : e.set(o, { slot: s.slot, children: [s] });
|
|
408
445
|
}
|
|
409
446
|
return e;
|
|
410
447
|
}
|
|
411
|
-
function
|
|
412
|
-
if (
|
|
413
|
-
const
|
|
414
|
-
if (
|
|
415
|
-
const
|
|
416
|
-
return `${t}: ${
|
|
448
|
+
function ze(t, e, s) {
|
|
449
|
+
if (Be.includes(t)) return null;
|
|
450
|
+
const o = e.get(t);
|
|
451
|
+
if (o && o.alias) {
|
|
452
|
+
const n = o.parent ? `${o.parent}.${o.alias}` : o.alias;
|
|
453
|
+
return `${t}: ${n}`;
|
|
417
454
|
}
|
|
418
|
-
return
|
|
455
|
+
return ue(s) || o ? t : null;
|
|
419
456
|
}
|
|
420
|
-
function
|
|
457
|
+
function ue(t) {
|
|
421
458
|
return !!t && typeof t == "object" && t.type === "Schema";
|
|
422
459
|
}
|
|
423
|
-
function
|
|
460
|
+
function pe(t) {
|
|
424
461
|
return typeof t == "object" && t.type === "UrlSchema";
|
|
425
462
|
}
|
|
426
|
-
function
|
|
463
|
+
function fe(t) {
|
|
427
464
|
return typeof t == "object" && t.type === "Plugin";
|
|
428
465
|
}
|
|
429
|
-
function
|
|
430
|
-
return t === "style" ?
|
|
466
|
+
function Ze(t, e, s = []) {
|
|
467
|
+
return t === "style" ? j(e) ? `:style="${_({
|
|
431
468
|
...e,
|
|
432
|
-
value:
|
|
433
|
-
})}"` : "" : t === "__class" &&
|
|
469
|
+
value: R(e.value, s)
|
|
470
|
+
})}"` : "" : t === "__class" && j(e) ? `:class="${_({
|
|
434
471
|
...e,
|
|
435
|
-
value:
|
|
436
|
-
})}"` : typeof e == "string" ? `${t}="${e}"` :
|
|
472
|
+
value: R(e.value, s)
|
|
473
|
+
})}"` : typeof e == "string" ? `${t}="${e}"` : j(e) ? `:${t}="${_({
|
|
437
474
|
...e,
|
|
438
|
-
value:
|
|
439
|
-
})}"` :
|
|
475
|
+
value: R(e.value, s)
|
|
476
|
+
})}"` : xe(e) ? `:${t}='{${Re(
|
|
440
477
|
e
|
|
441
478
|
).join(", ")}}'` : `:${t}='${JSON.stringify(e)}'`;
|
|
442
479
|
}
|
|
443
|
-
function
|
|
480
|
+
function Qe(t, e = {}, s = []) {
|
|
444
481
|
if (!!Object.keys(e.style || {}).length) {
|
|
445
482
|
const r = `${t.name}_${t.id}`;
|
|
446
|
-
e.class ? typeof e.class == "string" ? e.class = [e.class, r].join(" ") : (e.__class = e.class, e.class = r) : e.class = r,
|
|
483
|
+
e.class ? typeof e.class == "string" ? e.class = [e.class, r].join(" ") : (e.__class = e.class, e.class = r) : e.class = r, j(e.style) || delete e.style;
|
|
447
484
|
}
|
|
448
|
-
const
|
|
449
|
-
return (
|
|
485
|
+
const n = t.from;
|
|
486
|
+
return (pe(n) || fe(n)) && (e.is = {
|
|
450
487
|
type: "JSExpression",
|
|
451
488
|
value: t.name
|
|
452
|
-
}), Object.entries(e).map(([r, c]) =>
|
|
489
|
+
}), Object.entries(e).map(([r, c]) => Ze(r, c, s));
|
|
453
490
|
}
|
|
454
|
-
function
|
|
455
|
-
const
|
|
456
|
-
return `@${t}${
|
|
491
|
+
function Xe(t, e, s) {
|
|
492
|
+
const o = ae(e.modifiers, !0);
|
|
493
|
+
return `@${t}${o.join("")}="${s}"`;
|
|
457
494
|
}
|
|
458
|
-
function
|
|
459
|
-
const
|
|
495
|
+
function Ye(t, e = {}, s = {}) {
|
|
496
|
+
const o = {};
|
|
460
497
|
return {
|
|
461
498
|
binders: Object.entries(e).map(([r, c]) => {
|
|
462
|
-
const a =
|
|
499
|
+
const a = oe(H(c.handler.value)).replace(
|
|
463
500
|
/\"/g,
|
|
464
501
|
"'"
|
|
465
502
|
);
|
|
466
|
-
return
|
|
503
|
+
return Xe(r, c, a);
|
|
467
504
|
}),
|
|
468
|
-
handlers:
|
|
505
|
+
handlers: o
|
|
469
506
|
};
|
|
470
507
|
}
|
|
471
|
-
function
|
|
472
|
-
const { binders: c, handlers: a } =
|
|
508
|
+
function Ke(t, e, s = {}, o = {}, n = {}, r) {
|
|
509
|
+
const { binders: c, handlers: a } = Ye(e, o, n);
|
|
473
510
|
return {
|
|
474
|
-
props:
|
|
511
|
+
props: Qe(t, s, r).join(" "),
|
|
475
512
|
handlers: a,
|
|
476
513
|
binders: c,
|
|
477
514
|
events: c.join(" ")
|
|
478
515
|
};
|
|
479
516
|
}
|
|
480
|
-
function
|
|
481
|
-
const
|
|
482
|
-
vIf:
|
|
517
|
+
function et(t = [], e = [], s = []) {
|
|
518
|
+
const o = [], {
|
|
519
|
+
vIf: n,
|
|
483
520
|
vElse: r,
|
|
484
521
|
vElseIf: c,
|
|
485
522
|
vShow: a,
|
|
486
523
|
vModels: l,
|
|
487
|
-
vFor:
|
|
488
|
-
vBind:
|
|
524
|
+
vFor: m,
|
|
525
|
+
vBind: p,
|
|
489
526
|
vHtml: i,
|
|
490
527
|
customDirectives: u
|
|
491
|
-
} =
|
|
492
|
-
if (
|
|
528
|
+
} = tt(t);
|
|
529
|
+
if (n && o.push(`v-if="${_(n.value, !0, !0, e)}"`), c && o.push(
|
|
493
530
|
`v-else-if="${_(c.value, !0, !0, e)}"`
|
|
494
|
-
), r &&
|
|
531
|
+
), r && o.push("v-else"), a && o.push(
|
|
495
532
|
`v-show="${_(a.value, !0, !0, e)}"`
|
|
496
|
-
),
|
|
497
|
-
`v-bind="${_(
|
|
533
|
+
), p && o.push(
|
|
534
|
+
`v-bind="${_(p.value, !0, !0, e)}"`
|
|
498
535
|
), l.forEach((f) => {
|
|
499
|
-
const b =
|
|
500
|
-
|
|
536
|
+
const b = ae(f.modifiers, !0), g = f.arg ? T(f.arg) ? `:[${_(f.arg, !0, !0, e)}]` : `:${f.arg}` : "";
|
|
537
|
+
o.push(
|
|
501
538
|
`v-model${g}${b}="${_(f.value, !0, !0, e)}"`
|
|
502
539
|
);
|
|
503
|
-
}),
|
|
504
|
-
const { item: f, index: b } = { item: "item", index: "index", ...
|
|
505
|
-
|
|
506
|
-
`v-for="(${f}, ${b}) in ${_(
|
|
540
|
+
}), m) {
|
|
541
|
+
const { item: f, index: b } = { item: "item", index: "index", ...m.iterator };
|
|
542
|
+
o.push(
|
|
543
|
+
`v-for="(${f}, ${b}) in ${_(m.value, !0, !0, e)}"`
|
|
507
544
|
);
|
|
508
545
|
}
|
|
509
|
-
return i &&
|
|
546
|
+
return i && o.push(
|
|
510
547
|
`v-html="${_(i.value, !0, !0, e)}"`
|
|
511
548
|
), u && u.length && u.forEach((f) => {
|
|
512
549
|
if (!f.name) return;
|
|
513
550
|
let b = "", g = "";
|
|
514
|
-
|
|
515
|
-
const
|
|
516
|
-
if (b +=
|
|
517
|
-
const
|
|
518
|
-
|
|
551
|
+
T(f.name) ? (g = _(f.name, !0, !0, e), s.push(g)) : g = f.name;
|
|
552
|
+
const C = g?.startsWith("v") ? J(g) : J("v-" + g);
|
|
553
|
+
if (b += C, f.arg && (T(f.arg) ? b += `:[${_(f.name, !0, !0, e)}]` : b += `:${f.arg}`), f.modifiers) {
|
|
554
|
+
const h = Object.keys(f.modifiers);
|
|
555
|
+
h.length && (b += h.map(($) => "." + $));
|
|
519
556
|
}
|
|
520
|
-
f.value ?
|
|
557
|
+
f.value ? o.push(
|
|
521
558
|
`${b}="${_(f.value, !0, !0, e)}"`
|
|
522
|
-
) :
|
|
523
|
-
}),
|
|
559
|
+
) : o.push(b);
|
|
560
|
+
}), o;
|
|
524
561
|
}
|
|
525
|
-
function
|
|
562
|
+
function tt(t = []) {
|
|
526
563
|
const e = t.filter(
|
|
527
|
-
(i) =>
|
|
564
|
+
(i) => X.includes(i.name)
|
|
528
565
|
), s = t.filter(
|
|
529
|
-
(i) => !
|
|
530
|
-
), n = e.find(
|
|
531
|
-
(i) => A(i.name) === "vIf"
|
|
566
|
+
(i) => !X.includes(i.name)
|
|
532
567
|
), o = e.find(
|
|
533
|
-
(i) =>
|
|
568
|
+
(i) => E(i.name) === "vIf"
|
|
569
|
+
), n = e.find(
|
|
570
|
+
(i) => E(i.name) === "vElseIf"
|
|
534
571
|
), r = e.find(
|
|
535
|
-
(i) =>
|
|
572
|
+
(i) => E(i.name) === "vElse"
|
|
536
573
|
), c = e.find(
|
|
537
|
-
(i) =>
|
|
574
|
+
(i) => E(i.name) === "vFor"
|
|
538
575
|
), a = e.find(
|
|
539
|
-
(i) =>
|
|
576
|
+
(i) => E(i.name) === "vShow"
|
|
540
577
|
), l = e.find(
|
|
541
|
-
(i) =>
|
|
542
|
-
),
|
|
543
|
-
(i) =>
|
|
544
|
-
),
|
|
545
|
-
(i) =>
|
|
578
|
+
(i) => E(i.name) === "vBind"
|
|
579
|
+
), m = e.find(
|
|
580
|
+
(i) => E(i.name) === "vHtml"
|
|
581
|
+
), p = e.filter(
|
|
582
|
+
(i) => E(i.name) === "vModel"
|
|
546
583
|
);
|
|
547
584
|
return {
|
|
548
|
-
vIf:
|
|
549
|
-
vElseIf:
|
|
585
|
+
vIf: o,
|
|
586
|
+
vElseIf: n,
|
|
550
587
|
vElse: r,
|
|
551
588
|
vFor: c,
|
|
552
589
|
vShow: a,
|
|
553
|
-
vModels:
|
|
590
|
+
vModels: p,
|
|
554
591
|
vBind: l,
|
|
555
|
-
vHtml:
|
|
592
|
+
vHtml: m,
|
|
556
593
|
customDirectives: s
|
|
557
594
|
};
|
|
558
595
|
}
|
|
559
|
-
function
|
|
596
|
+
function st(t) {
|
|
560
597
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
561
598
|
}
|
|
562
|
-
function
|
|
563
|
-
return typeof t == "string" ?
|
|
599
|
+
function nt(t, e, s, o, n, r = /* @__PURE__ */ new Set()) {
|
|
600
|
+
return typeof t == "string" ? st(t) : T(t) ? `{{ ${_(t, !1, !0, e)} }}` : Array.isArray(t) ? z(
|
|
564
601
|
t,
|
|
565
602
|
s,
|
|
566
603
|
e,
|
|
567
|
-
n,
|
|
568
604
|
o,
|
|
605
|
+
n,
|
|
569
606
|
r
|
|
570
607
|
) : "";
|
|
571
608
|
}
|
|
572
|
-
function
|
|
609
|
+
function rt(t, e, s) {
|
|
573
610
|
if (!t) return e;
|
|
574
|
-
const
|
|
575
|
-
return `<template ${`#${
|
|
611
|
+
const o = typeof t == "string" ? { name: t, params: [], scope: "" } : { params: [], scope: "", ...t };
|
|
612
|
+
return `<template ${`#${o.name}="${o.scope ? o.scope : o.params?.length > 0 ? `{${o.params?.join(",")}}` : `scope_${s}`}"`}>
|
|
576
613
|
${e}
|
|
577
614
|
</template>`;
|
|
578
615
|
}
|
|
579
|
-
function
|
|
616
|
+
function ot(t, e = [], s = [], o = {}, n = "web", r = /* @__PURE__ */ new Set()) {
|
|
580
617
|
const c = [
|
|
581
618
|
"@dcloudio/uni-h5",
|
|
582
619
|
"uni-h5",
|
|
@@ -585,110 +622,113 @@ function Ye(t, e = [], s = [], n = {}, o = "web", r = /* @__PURE__ */ new Set())
|
|
|
585
622
|
], a = {
|
|
586
623
|
vue: ["defineComponent", "reactive"]
|
|
587
624
|
}, l = [];
|
|
588
|
-
for (const
|
|
589
|
-
const i = t.get(
|
|
625
|
+
for (const p of e) {
|
|
626
|
+
const i = t.get(p.split(":")[0]);
|
|
590
627
|
if (i && i.package) {
|
|
591
628
|
if (r.has(i.package)) continue;
|
|
592
629
|
const u = a[i.package] ?? (a[i.package] = []), f = i.parent || (i.alias || "").split(".")[0] || i.name;
|
|
593
|
-
u.push(f),
|
|
630
|
+
u.push(f), n === "uniapp" && c.includes(i.package) && l.push(f);
|
|
594
631
|
}
|
|
595
632
|
}
|
|
596
|
-
for (const [
|
|
597
|
-
(a[
|
|
633
|
+
for (const [p, i] of Object.entries(o))
|
|
634
|
+
(a[p] ?? (a[p] = [])).push(...Array.from(i)), n === "uniapp" && c.includes(p) && l.push(...Array.from(i));
|
|
598
635
|
return {
|
|
599
|
-
imports: Object.entries(a).filter(([
|
|
636
|
+
imports: Object.entries(a).filter(([p, i]) => n === "uniapp" ? !c.includes(p) && !!i.length : !!i.length).map(([p, i]) => `import { ${M(i).join(
|
|
600
637
|
","
|
|
601
|
-
)}} from '${
|
|
638
|
+
)}} from '${p}';`).concat(s),
|
|
602
639
|
uniComponents: l
|
|
603
640
|
};
|
|
604
641
|
}
|
|
605
|
-
function
|
|
642
|
+
function me(t = {}) {
|
|
606
643
|
const e = [];
|
|
607
|
-
for (const [s,
|
|
644
|
+
for (const [s, o] of Object.entries(t))
|
|
608
645
|
e.push(`
|
|
609
646
|
${s} {
|
|
610
|
-
${
|
|
647
|
+
${Le(o)}
|
|
611
648
|
}
|
|
612
649
|
`);
|
|
613
650
|
return e.join(`
|
|
614
651
|
`);
|
|
615
652
|
}
|
|
616
|
-
function
|
|
653
|
+
function de(t = {}) {
|
|
617
654
|
const e = [];
|
|
618
|
-
return Object.entries(t).forEach(([s,
|
|
655
|
+
return Object.entries(t).forEach(([s, o]) => {
|
|
619
656
|
e.push(
|
|
620
|
-
`const ${s} = provider.defineUrlSchemaComponent('${
|
|
657
|
+
`const ${s} = provider.defineUrlSchemaComponent('${o.url}');`
|
|
621
658
|
);
|
|
622
659
|
}), e;
|
|
623
660
|
}
|
|
624
|
-
function
|
|
661
|
+
function he(t = {}) {
|
|
625
662
|
const e = [];
|
|
626
|
-
return Object.entries(t).forEach(([s,
|
|
663
|
+
return Object.entries(t).forEach(([s, o]) => {
|
|
627
664
|
e.push(
|
|
628
|
-
`const ${s} = provider.definePluginComponent(${JSON.stringify(
|
|
665
|
+
`const ${s} = provider.definePluginComponent(${JSON.stringify(o)});`
|
|
629
666
|
);
|
|
630
667
|
}), e;
|
|
631
668
|
}
|
|
632
|
-
function
|
|
633
|
-
const { dsl: n } = t,
|
|
669
|
+
function ct(t, e, s = "web", o) {
|
|
670
|
+
const { dsl: n } = t, r = Object.keys(n.computed || {}), c = F(n.lifeCycles, r), a = F(n.computed, r), l = We(n.watch, r), m = He(n.dataSources), { methods: p, nodes: i, components: u, importBlocks: f, directives: b } = z(
|
|
634
671
|
n.nodes || [],
|
|
635
672
|
e,
|
|
636
|
-
|
|
673
|
+
r,
|
|
637
674
|
t.context,
|
|
638
675
|
void 0,
|
|
639
676
|
t.easycomPackages
|
|
640
|
-
),
|
|
677
|
+
), g = [...a, ...l.computed], C = F(
|
|
641
678
|
{
|
|
642
679
|
...p,
|
|
643
680
|
...n.methods || {}
|
|
644
681
|
},
|
|
645
|
-
|
|
646
|
-
),
|
|
647
|
-
|
|
682
|
+
r
|
|
683
|
+
), h = f.map((I) => {
|
|
684
|
+
const v = o?.(I.id) || `./${I.id}.vue`;
|
|
685
|
+
return `import ${I.name} from '${v}';`;
|
|
686
|
+
});
|
|
687
|
+
let { imports: $, uniComponents: d } = ot(
|
|
648
688
|
e,
|
|
649
|
-
|
|
650
|
-
|
|
689
|
+
u,
|
|
690
|
+
h,
|
|
651
691
|
t.imports,
|
|
652
692
|
s,
|
|
653
693
|
t.easycomPackages
|
|
654
694
|
);
|
|
655
|
-
const
|
|
695
|
+
const y = Object.keys({
|
|
656
696
|
...t.urlSchemas,
|
|
657
697
|
...t.blockPlugins
|
|
658
|
-
}),
|
|
698
|
+
}), S = de(t.urlSchemas), w = he(t.blockPlugins);
|
|
659
699
|
return {
|
|
660
700
|
id: n.id,
|
|
661
701
|
version: n.__VERSION__,
|
|
662
702
|
name: n.name,
|
|
663
|
-
state:
|
|
664
|
-
inject:
|
|
665
|
-
props:
|
|
666
|
-
emits:
|
|
703
|
+
state: Fe(n.state).join(","),
|
|
704
|
+
inject: Je(n.inject).join(","),
|
|
705
|
+
props: ie(n.props).join(","),
|
|
706
|
+
emits: le(n.emits).join(","),
|
|
667
707
|
expose: n.expose && n.expose.length ? JSON.stringify(n.expose || []) : "",
|
|
668
|
-
watch:
|
|
669
|
-
lifeCycles:
|
|
670
|
-
computed:
|
|
671
|
-
methods: [...
|
|
708
|
+
watch: l.watches.join(","),
|
|
709
|
+
lifeCycles: c.join(","),
|
|
710
|
+
computed: g.join(","),
|
|
711
|
+
methods: [...m, ...C].join(","),
|
|
672
712
|
imports: `
|
|
673
|
-
` +
|
|
713
|
+
` + $.join(`
|
|
674
714
|
`),
|
|
675
|
-
components:
|
|
676
|
-
directives:
|
|
715
|
+
components: De(u, d).join(","),
|
|
716
|
+
directives: b.join(","),
|
|
677
717
|
returns: t.members.join(","),
|
|
678
|
-
template:
|
|
718
|
+
template: i.join(`
|
|
679
719
|
`),
|
|
680
720
|
css: n.css || "",
|
|
681
|
-
style:
|
|
682
|
-
urlSchemas:
|
|
721
|
+
style: me(t.style),
|
|
722
|
+
urlSchemas: S.join(`
|
|
683
723
|
`),
|
|
684
|
-
blockPlugins:
|
|
724
|
+
blockPlugins: w.join(`
|
|
685
725
|
`),
|
|
686
|
-
asyncComponents:
|
|
687
|
-
uniComponents:
|
|
726
|
+
asyncComponents: y.join(","),
|
|
727
|
+
uniComponents: d,
|
|
688
728
|
renderer: s === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer"
|
|
689
729
|
};
|
|
690
730
|
}
|
|
691
|
-
const
|
|
731
|
+
const N = {
|
|
692
732
|
state: {
|
|
693
733
|
composable: null,
|
|
694
734
|
from: "self",
|
|
@@ -880,7 +920,7 @@ const E = {
|
|
|
880
920
|
declare: "const __apis = useApis();",
|
|
881
921
|
replace: "__apis"
|
|
882
922
|
}
|
|
883
|
-
},
|
|
923
|
+
}, ge = {
|
|
884
924
|
"element-plus": {
|
|
885
925
|
$loading: {
|
|
886
926
|
composable: "ElLoading",
|
|
@@ -969,244 +1009,244 @@ const E = {
|
|
|
969
1009
|
replace: "message.error"
|
|
970
1010
|
}
|
|
971
1011
|
}
|
|
972
|
-
},
|
|
973
|
-
function
|
|
1012
|
+
}, at = Object.keys(ge);
|
|
1013
|
+
function it(t) {
|
|
974
1014
|
for (const [, e] of t)
|
|
975
|
-
if (
|
|
1015
|
+
if (at.includes(e.package))
|
|
976
1016
|
return e.package;
|
|
977
1017
|
return null;
|
|
978
1018
|
}
|
|
979
|
-
function
|
|
980
|
-
const e = t ?
|
|
981
|
-
return { ...
|
|
1019
|
+
function lt(t) {
|
|
1020
|
+
const e = t ? ge[t] ?? {} : {};
|
|
1021
|
+
return { ...N, ...e };
|
|
982
1022
|
}
|
|
983
|
-
function
|
|
984
|
-
const s = /* @__PURE__ */ new Set(),
|
|
1023
|
+
function ut(t, e = N) {
|
|
1024
|
+
const s = /* @__PURE__ */ new Set(), o = /this\.\$(\w+)\b/g, n = (r) => {
|
|
985
1025
|
if (r && typeof r == "object") {
|
|
986
1026
|
if (Array.isArray(r)) {
|
|
987
|
-
for (const c of r)
|
|
1027
|
+
for (const c of r) n(c);
|
|
988
1028
|
return;
|
|
989
1029
|
}
|
|
990
|
-
if (
|
|
1030
|
+
if (j(r) && r.value) {
|
|
991
1031
|
let c;
|
|
992
|
-
for (
|
|
1032
|
+
for (o.lastIndex = 0; (c = o.exec(r.value)) !== null; ) {
|
|
993
1033
|
const a = "$" + c[1];
|
|
994
1034
|
a in e && s.add(a);
|
|
995
1035
|
}
|
|
996
1036
|
return;
|
|
997
1037
|
}
|
|
998
1038
|
for (const c of Object.values(r))
|
|
999
|
-
|
|
1039
|
+
n(c);
|
|
1000
1040
|
}
|
|
1001
1041
|
};
|
|
1002
|
-
return
|
|
1042
|
+
return n(t.refs), n(t.reactives), n(t.state), n(t.computed), n(t.methods), n(t.watch), n(t.lifeCycles), n(t.inject), n(t.composables), n(t.provide), n(t.dataSources), n(t.setup), n(t.nodes), s;
|
|
1003
1043
|
}
|
|
1004
|
-
function
|
|
1044
|
+
function pt(t, e = N) {
|
|
1005
1045
|
const s = [];
|
|
1006
|
-
for (const
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1046
|
+
for (const o of t) {
|
|
1047
|
+
const n = e[o];
|
|
1048
|
+
n && n.declare && !s.includes(n.declare) && s.push(n.declare);
|
|
1009
1049
|
}
|
|
1010
1050
|
return s;
|
|
1011
1051
|
}
|
|
1012
|
-
function
|
|
1052
|
+
function ft(t, e = N) {
|
|
1013
1053
|
const s = {};
|
|
1014
|
-
for (const
|
|
1015
|
-
const
|
|
1016
|
-
if (
|
|
1017
|
-
const r = s[
|
|
1018
|
-
r.includes(
|
|
1054
|
+
for (const o of t) {
|
|
1055
|
+
const n = e[o];
|
|
1056
|
+
if (n && n.composable) {
|
|
1057
|
+
const r = s[n.from] ?? (s[n.from] = []);
|
|
1058
|
+
r.includes(n.composable) || r.push(n.composable);
|
|
1019
1059
|
}
|
|
1020
1060
|
}
|
|
1021
1061
|
return s;
|
|
1022
1062
|
}
|
|
1023
|
-
function
|
|
1024
|
-
const s = new Set(Object.keys(t.refs ?? {})),
|
|
1025
|
-
r &&
|
|
1063
|
+
function mt(t, e = N) {
|
|
1064
|
+
const s = new Set(Object.keys(t.refs ?? {})), o = new Set(Object.keys(t.reactives ?? {})), r = Object.keys(t.state ?? {}).length > 0;
|
|
1065
|
+
r && o.add("__state");
|
|
1026
1066
|
const c = new Set(Object.keys(t.computed ?? {})), a = new Set(Object.keys(t.methods ?? {})), l = /* @__PURE__ */ new Set();
|
|
1027
1067
|
for (const u of t.props ?? [])
|
|
1028
|
-
|
|
1029
|
-
const
|
|
1068
|
+
Ae(u) ? l.add(u) : l.add(u.name);
|
|
1069
|
+
const m = /* @__PURE__ */ new Set();
|
|
1030
1070
|
for (const u of t.composables ?? [])
|
|
1031
1071
|
if (u.destructure && u.destructure.length > 0)
|
|
1032
|
-
for (const f of u.destructure)
|
|
1033
|
-
else u.name &&
|
|
1034
|
-
const
|
|
1072
|
+
for (const f of u.destructure) m.add(f);
|
|
1073
|
+
else u.name && m.add(u.name);
|
|
1074
|
+
const p = /* @__PURE__ */ new Set();
|
|
1035
1075
|
for (const u of t.inject ?? [])
|
|
1036
|
-
u.name &&
|
|
1076
|
+
u.name && p.add(u.name);
|
|
1037
1077
|
const i = /* @__PURE__ */ new Set();
|
|
1038
1078
|
for (const [, u] of Object.entries(t.dataSources ?? {}))
|
|
1039
1079
|
u.name && i.add(u.name);
|
|
1040
1080
|
return {
|
|
1041
1081
|
refs: s,
|
|
1042
|
-
reactives:
|
|
1082
|
+
reactives: o,
|
|
1043
1083
|
computed: c,
|
|
1044
1084
|
methods: a,
|
|
1045
1085
|
props: l,
|
|
1046
|
-
composables:
|
|
1047
|
-
injects:
|
|
1086
|
+
composables: m,
|
|
1087
|
+
injects: p,
|
|
1048
1088
|
dataSources: i,
|
|
1049
1089
|
hasState: r,
|
|
1050
1090
|
effectiveApiMap: e
|
|
1051
1091
|
};
|
|
1052
1092
|
}
|
|
1053
|
-
function
|
|
1093
|
+
function k(t, e, s = "script") {
|
|
1054
1094
|
if (!t) return t;
|
|
1055
|
-
let
|
|
1056
|
-
for (const [
|
|
1057
|
-
const c =
|
|
1058
|
-
|
|
1095
|
+
let o = t;
|
|
1096
|
+
for (const [n, r] of Object.entries(e.effectiveApiMap)) {
|
|
1097
|
+
const c = n.replace(/\$/g, "\\$"), a = new RegExp(`this\\.${c}\\b`, "g");
|
|
1098
|
+
o = o.replace(a, r.replace);
|
|
1059
1099
|
}
|
|
1060
|
-
return
|
|
1100
|
+
return o = o.replace(
|
|
1061
1101
|
/this\.([A-Za-z_$][\w$]*)\.value\b/g,
|
|
1062
|
-
(
|
|
1063
|
-
),
|
|
1102
|
+
(n, r) => e.refs.has(r) || e.computed.has(r) ? s === "script" ? `${r}.value` : r : n
|
|
1103
|
+
), o = o.replace(/this\.([A-Za-z_$][\w$]*)/g, (n, r) => e.refs.has(r) || e.computed.has(r) ? s === "script" ? `${r}.value` : r : r === "state" ? "__state" : e.reactives.has(r) || e.methods.has(r) || e.composables.has(r) || e.injects.has(r) || e.dataSources.has(r) ? r : e.props.has(r) ? s === "script" ? `__props.${r}` : r : n), o;
|
|
1064
1104
|
}
|
|
1065
|
-
function
|
|
1105
|
+
function B(t) {
|
|
1066
1106
|
let e = t.trim().replace(/;$/, "");
|
|
1067
1107
|
return /^\((\(|async|function)/.test(e) && (e = e.substring(1, e.length - 1).trim()), e;
|
|
1068
1108
|
}
|
|
1069
|
-
function
|
|
1070
|
-
return Object.entries(t).map(([s,
|
|
1071
|
-
let
|
|
1072
|
-
return
|
|
1109
|
+
function dt(t = {}, e) {
|
|
1110
|
+
return Object.entries(t).map(([s, o]) => {
|
|
1111
|
+
let n;
|
|
1112
|
+
return j(o) ? n = k(o.value || "undefined", e, "script") : n = JSON.stringify(o), `const ${s} = ref(${n});`;
|
|
1073
1113
|
});
|
|
1074
1114
|
}
|
|
1075
|
-
function
|
|
1076
|
-
return Object.entries(t).map(([s,
|
|
1077
|
-
let
|
|
1078
|
-
return
|
|
1115
|
+
function ht(t = {}, e) {
|
|
1116
|
+
return Object.entries(t).map(([s, o]) => {
|
|
1117
|
+
let n;
|
|
1118
|
+
return j(o) ? n = k(o.value || "{}", e, "script") : n = JSON.stringify(o ?? {}), `const ${s} = reactive(${n});`;
|
|
1079
1119
|
});
|
|
1080
1120
|
}
|
|
1081
|
-
function
|
|
1121
|
+
function gt(t = {}, e) {
|
|
1082
1122
|
const s = Object.entries(t);
|
|
1083
|
-
return s.length === 0 ? "" : `const __state = reactive({ ${s.map(([
|
|
1123
|
+
return s.length === 0 ? "" : `const __state = reactive({ ${s.map(([n, r]) => {
|
|
1084
1124
|
let c;
|
|
1085
|
-
return
|
|
1125
|
+
return j(r) ? c = k(r.value || "undefined", e, "script") : c = JSON.stringify(r), `${n}: ${c}`;
|
|
1086
1126
|
}).join(", ")} });`;
|
|
1087
1127
|
}
|
|
1088
|
-
function
|
|
1089
|
-
const s = [],
|
|
1128
|
+
function $t(t = [], e) {
|
|
1129
|
+
const s = [], o = {}, n = /* @__PURE__ */ new Set();
|
|
1090
1130
|
for (const r of t) {
|
|
1091
1131
|
if (!r || !r.composable) continue;
|
|
1092
1132
|
let c = "";
|
|
1093
|
-
if (
|
|
1133
|
+
if (j(r.composable) ? c = r.composable.value || "" : typeof r.composable == "string" && (c = r.composable), !c || c === "useProvider") continue;
|
|
1094
1134
|
if (r.name) {
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1135
|
+
if (n.has(r.name)) continue;
|
|
1136
|
+
n.add(r.name);
|
|
1097
1137
|
}
|
|
1098
|
-
const l = (r.args ?? []).map((
|
|
1138
|
+
const l = (r.args ?? []).map((m) => j(m) ? k(m.value || "", e, "script") : JSON.stringify(m)).join(", ");
|
|
1099
1139
|
r.destructure && r.destructure.length > 0 ? s.push(
|
|
1100
1140
|
`const { ${r.destructure.join(", ")} } = ${c}(${l});`
|
|
1101
1141
|
) : r.name ? s.push(`const ${r.name} = ${c}(${l});`) : s.push(`${c}(${l});`);
|
|
1102
1142
|
}
|
|
1103
|
-
return { statements: s, imports:
|
|
1143
|
+
return { statements: s, imports: o };
|
|
1104
1144
|
}
|
|
1105
|
-
function
|
|
1145
|
+
function vt(t = [], e) {
|
|
1106
1146
|
return t.map((s) => {
|
|
1107
|
-
const
|
|
1147
|
+
const o = j(s.from) ? k(
|
|
1108
1148
|
s.from.value || `'${s.name}'`,
|
|
1109
1149
|
e,
|
|
1110
1150
|
"script"
|
|
1111
1151
|
) : `'${s.from || s.name}'`;
|
|
1112
|
-
let
|
|
1113
|
-
return s.default !== void 0 && s.default !== null && (
|
|
1152
|
+
let n = "undefined";
|
|
1153
|
+
return s.default !== void 0 && s.default !== null && (j(s.default) ? n = k(
|
|
1114
1154
|
s.default.value || "undefined",
|
|
1115
1155
|
e,
|
|
1116
1156
|
"script"
|
|
1117
|
-
) :
|
|
1157
|
+
) : n = JSON.stringify(s.default)), `const ${s.name} = inject(${o}, ${n});`;
|
|
1118
1158
|
});
|
|
1119
1159
|
}
|
|
1120
|
-
function
|
|
1121
|
-
return Object.entries(t).map(([s,
|
|
1122
|
-
if (!
|
|
1123
|
-
const
|
|
1160
|
+
function bt(t = {}, e) {
|
|
1161
|
+
return Object.entries(t).map(([s, o]) => {
|
|
1162
|
+
if (!o || !o.value) return null;
|
|
1163
|
+
const n = k(o.value, e, "script"), r = B(n);
|
|
1124
1164
|
return `const ${s} = computed(${r});`;
|
|
1125
1165
|
}).filter((s) => !!s);
|
|
1126
1166
|
}
|
|
1127
|
-
function
|
|
1128
|
-
return Object.entries(t).map(([s,
|
|
1129
|
-
if (!
|
|
1130
|
-
const
|
|
1167
|
+
function _t(t = {}, e) {
|
|
1168
|
+
return Object.entries(t).map(([s, o]) => {
|
|
1169
|
+
if (!o || !o.value) return null;
|
|
1170
|
+
const n = k(o.value, e, "script"), r = B(n);
|
|
1131
1171
|
return `const ${s} = ${r};`;
|
|
1132
1172
|
}).filter((s) => !!s);
|
|
1133
1173
|
}
|
|
1134
|
-
function
|
|
1174
|
+
function yt(t = {}, e) {
|
|
1135
1175
|
return Object.values(t).map((s) => {
|
|
1136
1176
|
if (!s || !s.name) return null;
|
|
1137
1177
|
if (s.type === "mock") {
|
|
1138
|
-
const
|
|
1178
|
+
const o = s.mockTemplate && s.mockTemplate.value ? s.mockTemplate.value : "(params) => ({})", n = e ? k(o, e, "script") : o;
|
|
1139
1179
|
return `const ${s.name} = async (...args) => {
|
|
1140
|
-
const mock = __provider.createMock(${
|
|
1180
|
+
const mock = __provider.createMock(${n});
|
|
1141
1181
|
return await mock.apply(null, args);
|
|
1142
1182
|
};`;
|
|
1143
1183
|
} else {
|
|
1144
|
-
const
|
|
1184
|
+
const o = s.transform && s.transform.value ? s.transform.value : "(res) => res", n = e ? k(o, e, "script") : o;
|
|
1145
1185
|
return `const ${s.name} = async (...args) => {
|
|
1146
|
-
return await __provider.apis['${s.ref}'].apply(null, args).then(${
|
|
1186
|
+
return await __provider.apis['${s.ref}'].apply(null, args).then(${n});
|
|
1147
1187
|
};`;
|
|
1148
1188
|
}
|
|
1149
1189
|
}).filter((s) => !!s);
|
|
1150
1190
|
}
|
|
1151
|
-
function
|
|
1191
|
+
function St(t = [], e) {
|
|
1152
1192
|
return t.map((s) => {
|
|
1153
1193
|
if (!s || !s.handler || !s.handler.value) return null;
|
|
1154
|
-
const
|
|
1194
|
+
const o = s.source && s.source.value ? k(s.source.value, e, "script") : "() => null", n = B(o), r = k(
|
|
1155
1195
|
s.handler.value,
|
|
1156
1196
|
e,
|
|
1157
1197
|
"script"
|
|
1158
|
-
), c =
|
|
1198
|
+
), c = B(r), a = [];
|
|
1159
1199
|
s.deep && a.push("deep: true"), s.immediate && a.push("immediate: true"), s.flush && a.push(`flush: '${s.flush}'`);
|
|
1160
1200
|
const l = a.length > 0 ? `, { ${a.join(", ")} }` : "";
|
|
1161
|
-
return `watch(${
|
|
1201
|
+
return `watch(${n}, ${c}${l});`;
|
|
1162
1202
|
}).filter((s) => !!s);
|
|
1163
1203
|
}
|
|
1164
|
-
function
|
|
1165
|
-
return Object.entries(t).map(([s,
|
|
1166
|
-
let
|
|
1167
|
-
if (
|
|
1168
|
-
const r =
|
|
1169
|
-
|
|
1204
|
+
function jt(t = {}, e) {
|
|
1205
|
+
return Object.entries(t).map(([s, o]) => {
|
|
1206
|
+
let n;
|
|
1207
|
+
if (L(o)) {
|
|
1208
|
+
const r = k(
|
|
1209
|
+
o.value || "",
|
|
1170
1210
|
e,
|
|
1171
1211
|
"script"
|
|
1172
1212
|
);
|
|
1173
|
-
|
|
1174
|
-
} else
|
|
1175
|
-
return `provide('${s}', ${
|
|
1213
|
+
n = B(r);
|
|
1214
|
+
} else j(o) ? n = k(o.value || "undefined", e, "script") : n = JSON.stringify(o);
|
|
1215
|
+
return `provide('${s}', ${n});`;
|
|
1176
1216
|
});
|
|
1177
1217
|
}
|
|
1178
|
-
function
|
|
1218
|
+
function $e(t) {
|
|
1179
1219
|
let e = t.trim().replace(/;$/, "");
|
|
1180
1220
|
/^\((\(|async|function)/.test(e) && (e = e.substring(1, e.length - 1).trim());
|
|
1181
1221
|
const s = e.match(/^(?:async\s+)?\([^)]*\)\s*=>\s*([\s\S]+)$/);
|
|
1182
1222
|
if (s) {
|
|
1183
|
-
let
|
|
1184
|
-
return
|
|
1223
|
+
let n = s[1].trim();
|
|
1224
|
+
return n.startsWith("{") && n.endsWith("}") ? n = n.slice(1, -1).trim() : n = n.replace(/;$/, "") + ";", n;
|
|
1185
1225
|
}
|
|
1186
|
-
const
|
|
1226
|
+
const o = e.match(
|
|
1187
1227
|
/^(?:async\s+)?function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*)\}$/
|
|
1188
1228
|
);
|
|
1189
|
-
return
|
|
1229
|
+
return o ? o[1].trim() : e;
|
|
1190
1230
|
}
|
|
1191
|
-
function
|
|
1231
|
+
function kt(t, e) {
|
|
1192
1232
|
if (!t || !t.value) return "";
|
|
1193
|
-
const s =
|
|
1194
|
-
return
|
|
1233
|
+
const s = k(t.value, e, "script");
|
|
1234
|
+
return $e(s);
|
|
1195
1235
|
}
|
|
1196
|
-
function
|
|
1236
|
+
function wt(t = {}, e) {
|
|
1197
1237
|
const s = [];
|
|
1198
|
-
for (const
|
|
1199
|
-
const
|
|
1200
|
-
if (
|
|
1201
|
-
const r =
|
|
1202
|
-
c && s.push(`// ${
|
|
1238
|
+
for (const o of ["beforeCreate", "created"]) {
|
|
1239
|
+
const n = t[o];
|
|
1240
|
+
if (n && n.value) {
|
|
1241
|
+
const r = k(n.value, e, "script"), c = $e(r);
|
|
1242
|
+
c && s.push(`// ${o}
|
|
1203
1243
|
${c}`);
|
|
1204
1244
|
}
|
|
1205
1245
|
}
|
|
1206
1246
|
return s.join(`
|
|
1207
1247
|
`);
|
|
1208
1248
|
}
|
|
1209
|
-
const
|
|
1249
|
+
const It = {
|
|
1210
1250
|
beforeMount: "onBeforeMount",
|
|
1211
1251
|
mounted: "onMounted",
|
|
1212
1252
|
beforeUpdate: "onBeforeUpdate",
|
|
@@ -1218,7 +1258,7 @@ const bt = {
|
|
|
1218
1258
|
renderTriggered: "onRenderTriggered",
|
|
1219
1259
|
activated: "onActivated",
|
|
1220
1260
|
deactivated: "onDeactivated"
|
|
1221
|
-
},
|
|
1261
|
+
}, Ot = /* @__PURE__ */ new Set([
|
|
1222
1262
|
"onBeforeMount",
|
|
1223
1263
|
"onMounted",
|
|
1224
1264
|
"onBeforeUpdate",
|
|
@@ -1230,7 +1270,7 @@ const bt = {
|
|
|
1230
1270
|
"onRenderTriggered",
|
|
1231
1271
|
"onActivated",
|
|
1232
1272
|
"onDeactivated"
|
|
1233
|
-
]),
|
|
1273
|
+
]), Ct = /* @__PURE__ */ new Set([
|
|
1234
1274
|
"onLoad",
|
|
1235
1275
|
"onShow",
|
|
1236
1276
|
"onReady",
|
|
@@ -1250,33 +1290,33 @@ const bt = {
|
|
|
1250
1290
|
"onShareTimeline",
|
|
1251
1291
|
"onAddToFavorites"
|
|
1252
1292
|
]);
|
|
1253
|
-
function
|
|
1254
|
-
const s = [],
|
|
1293
|
+
function xt(t = {}, e) {
|
|
1294
|
+
const s = [], o = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
1255
1295
|
for (const [r, c] of Object.entries(t)) {
|
|
1256
1296
|
if (!c || !c.value || r === "created" || r === "beforeCreate") continue;
|
|
1257
|
-
const a =
|
|
1258
|
-
if (
|
|
1259
|
-
const l =
|
|
1260
|
-
s.push(`${a}(${
|
|
1261
|
-
} else if (
|
|
1262
|
-
const l =
|
|
1263
|
-
s.push(`${a}(${
|
|
1297
|
+
const a = It[r] || r;
|
|
1298
|
+
if (Ot.has(a)) {
|
|
1299
|
+
const l = k(c.value, e, "script"), m = B(l);
|
|
1300
|
+
s.push(`${a}(${m});`), o.add(a);
|
|
1301
|
+
} else if (Ct.has(a)) {
|
|
1302
|
+
const l = k(c.value, e, "script"), m = B(l);
|
|
1303
|
+
s.push(`${a}(${m});`), n.add(a);
|
|
1264
1304
|
}
|
|
1265
1305
|
}
|
|
1266
|
-
return { statements: s, usedHooks:
|
|
1306
|
+
return { statements: s, usedHooks: o, usedUniHooks: n };
|
|
1267
1307
|
}
|
|
1268
|
-
function
|
|
1308
|
+
function At(t) {
|
|
1269
1309
|
const {
|
|
1270
1310
|
componentMap: e,
|
|
1271
1311
|
components: s,
|
|
1272
|
-
importBlocks:
|
|
1273
|
-
collectImports:
|
|
1312
|
+
importBlocks: o,
|
|
1313
|
+
collectImports: n,
|
|
1274
1314
|
platform: r,
|
|
1275
1315
|
vueImports: c,
|
|
1276
1316
|
composableImports: a,
|
|
1277
1317
|
globalApiImports: l,
|
|
1278
|
-
uniHookImports:
|
|
1279
|
-
easycomPackages:
|
|
1318
|
+
uniHookImports: m,
|
|
1319
|
+
easycomPackages: p
|
|
1280
1320
|
} = t, i = [
|
|
1281
1321
|
"@dcloudio/uni-h5",
|
|
1282
1322
|
"uni-h5",
|
|
@@ -1285,166 +1325,166 @@ function jt(t) {
|
|
|
1285
1325
|
], u = {
|
|
1286
1326
|
vue: [...c]
|
|
1287
1327
|
}, f = [], b = [], g = {};
|
|
1288
|
-
for (const
|
|
1289
|
-
const
|
|
1290
|
-
if (!
|
|
1291
|
-
const y = u[
|
|
1292
|
-
y.push(
|
|
1328
|
+
for (const h of s) {
|
|
1329
|
+
const $ = h.split(":")[0], d = e.get($);
|
|
1330
|
+
if (!d || !d.package || d.parent || p.has(d.package)) continue;
|
|
1331
|
+
const y = u[d.package] ?? (u[d.package] = []), S = (d.alias || "").split(".")[0] || d.name, w = $, I = S !== w ? `${S} as ${w}` : S;
|
|
1332
|
+
y.push(I), g[S] = w, r === "uniapp" && i.includes(d.package) && f.push(S);
|
|
1293
1333
|
}
|
|
1294
|
-
for (const
|
|
1295
|
-
const
|
|
1296
|
-
if (!
|
|
1297
|
-
const y =
|
|
1334
|
+
for (const h of s) {
|
|
1335
|
+
const $ = h.split(":")[0], d = e.get($);
|
|
1336
|
+
if (!d || !d.package || !d.parent || p.has(d.package)) continue;
|
|
1337
|
+
const y = d.parent, S = g[y] ?? y, w = d.alias || "";
|
|
1298
1338
|
b.push(
|
|
1299
|
-
`const ${
|
|
1300
|
-
), g[y] || ((u[
|
|
1339
|
+
`const ${$} = ${S}.${w};`
|
|
1340
|
+
), g[y] || ((u[d.package] ?? (u[d.package] = [])).push(y), g[y] = y);
|
|
1301
1341
|
}
|
|
1302
|
-
for (const [
|
|
1303
|
-
(u[
|
|
1304
|
-
for (const [
|
|
1305
|
-
(u[
|
|
1306
|
-
for (const [
|
|
1307
|
-
(u[
|
|
1308
|
-
return r === "uniapp" &&
|
|
1342
|
+
for (const [h, $] of Object.entries(n))
|
|
1343
|
+
(u[h] ?? (u[h] = [])).push(...Array.from($)), r === "uniapp" && i.includes(h) && f.push(...Array.from($));
|
|
1344
|
+
for (const [h, $] of Object.entries(a))
|
|
1345
|
+
(u[h] ?? (u[h] = [])).push(...$);
|
|
1346
|
+
for (const [h, $] of Object.entries(l))
|
|
1347
|
+
(u[h] ?? (u[h] = [])).push(...$);
|
|
1348
|
+
return r === "uniapp" && m.length > 0 && (u["@dcloudio/uni-app"] ?? (u["@dcloudio/uni-app"] = [])).push(...m), { imports: Object.entries(u).filter(([h, $]) => r === "uniapp" ? !i.includes(h) && !!$.length : !!$.length).map(([h, $]) => `import { ${M($).join(
|
|
1309
1349
|
","
|
|
1310
|
-
)}} from '${
|
|
1350
|
+
)}} from '${h}';`).concat(o), uniComponents: f, componentDeclarations: b };
|
|
1311
1351
|
}
|
|
1312
|
-
function
|
|
1313
|
-
const
|
|
1352
|
+
function Pt(t, e = N, s = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set()) {
|
|
1353
|
+
const n = Object.entries(e), r = (c) => {
|
|
1314
1354
|
if (c == null || typeof c != "object") return c;
|
|
1315
1355
|
if (Array.isArray(c))
|
|
1316
1356
|
return c.map(r);
|
|
1317
|
-
if (
|
|
1357
|
+
if (j(c) && typeof c.value == "string") {
|
|
1318
1358
|
let l = c.value;
|
|
1319
|
-
for (const [
|
|
1320
|
-
const i =
|
|
1321
|
-
l = l.replace(u,
|
|
1359
|
+
for (const [m, p] of n) {
|
|
1360
|
+
const i = m.replace(/\$/g, "\\$"), u = new RegExp(`this\\.${i}\\b`, "g");
|
|
1361
|
+
l = l.replace(u, p.replace);
|
|
1322
1362
|
}
|
|
1323
|
-
return l = l.replace(/this\.([A-Za-z_$][\w$]*)\.value\b/g, (
|
|
1363
|
+
return l = l.replace(/this\.([A-Za-z_$][\w$]*)\.value\b/g, (m, p) => s.has(p) || o.has(p) ? p : m), { ...c, value: l };
|
|
1324
1364
|
}
|
|
1325
1365
|
const a = {};
|
|
1326
|
-
for (const [l,
|
|
1327
|
-
a[l] = r(
|
|
1366
|
+
for (const [l, m] of Object.entries(c))
|
|
1367
|
+
a[l] = r(m);
|
|
1328
1368
|
return a;
|
|
1329
1369
|
};
|
|
1330
1370
|
return t.map(r);
|
|
1331
1371
|
}
|
|
1332
|
-
function
|
|
1333
|
-
const
|
|
1372
|
+
function Et(t, e, s = [], o = {}, n, r = N, c = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set()) {
|
|
1373
|
+
const m = Pt(
|
|
1334
1374
|
t,
|
|
1335
1375
|
r,
|
|
1336
1376
|
c,
|
|
1337
1377
|
a
|
|
1338
1378
|
);
|
|
1339
|
-
return
|
|
1340
|
-
|
|
1379
|
+
return z(
|
|
1380
|
+
m,
|
|
1341
1381
|
e,
|
|
1342
1382
|
s,
|
|
1343
|
-
n,
|
|
1344
1383
|
o,
|
|
1384
|
+
n,
|
|
1345
1385
|
l
|
|
1346
1386
|
);
|
|
1347
1387
|
}
|
|
1348
|
-
function
|
|
1349
|
-
const { dsl: n } = t,
|
|
1388
|
+
function Bt(t, e, s = "web", o) {
|
|
1389
|
+
const { dsl: n } = t, r = it(e), c = lt(r), a = mt(n, c), l = ut(n, c), m = pt(l, c), p = ft(l, c), i = p.__renderer__ || [];
|
|
1350
1390
|
delete p.__renderer__;
|
|
1351
|
-
const
|
|
1391
|
+
const u = Et(
|
|
1352
1392
|
n.nodes || [],
|
|
1353
1393
|
e,
|
|
1354
1394
|
Object.keys(n.computed || {}),
|
|
1355
1395
|
t.context,
|
|
1356
1396
|
void 0,
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1397
|
+
c,
|
|
1398
|
+
a.refs,
|
|
1399
|
+
a.computed,
|
|
1360
1400
|
t.easycomPackages
|
|
1361
|
-
),
|
|
1362
|
-
(
|
|
1363
|
-
),
|
|
1364
|
-
...
|
|
1401
|
+
), f = u.importBlocks.map(
|
|
1402
|
+
(O) => `import ${O.name} from '${o?.(O.id) || `./${O.id}.vue`}';`
|
|
1403
|
+
), b = dt(n.refs || {}, a), g = ht(n.reactives || {}, a), C = gt(n.state || {}, a), h = bt(n.computed || {}, a), $ = {
|
|
1404
|
+
...u.methods || {},
|
|
1365
1405
|
...n.methods || {}
|
|
1366
|
-
},
|
|
1406
|
+
}, d = _t($, a), y = yt(n.dataSources || {}, a), S = St(n.watch || [], a), w = vt(n.inject || [], a), I = jt(n.provide || {}, a), v = $t(
|
|
1367
1407
|
n.composables || [],
|
|
1368
|
-
|
|
1369
|
-
),
|
|
1370
|
-
for (const
|
|
1371
|
-
if (
|
|
1372
|
-
for (const
|
|
1373
|
-
else
|
|
1374
|
-
const
|
|
1375
|
-
const
|
|
1376
|
-
return !(
|
|
1377
|
-
}),
|
|
1408
|
+
a
|
|
1409
|
+
), x = /* @__PURE__ */ new Set();
|
|
1410
|
+
for (const O of n.composables || [])
|
|
1411
|
+
if (O.destructure && O.destructure.length > 0)
|
|
1412
|
+
for (const U of O.destructure) x.add(U);
|
|
1413
|
+
else O.name && x.add(O.name);
|
|
1414
|
+
const D = m.filter((O) => {
|
|
1415
|
+
const U = O.match(/^const\s+(\w+)\s*=/);
|
|
1416
|
+
return !(U && x.has(U[1]));
|
|
1417
|
+
}), A = xt(n.lifeCycles || {}, a), ve = wt(
|
|
1378
1418
|
n.lifeCycles || {},
|
|
1379
|
-
|
|
1380
|
-
),
|
|
1381
|
-
|
|
1382
|
-
for (const
|
|
1383
|
-
const
|
|
1419
|
+
a
|
|
1420
|
+
), be = kt(n.setup, a), P = /* @__PURE__ */ new Set();
|
|
1421
|
+
b.length > 0 && P.add("ref"), (g.length > 0 || C) && P.add("reactive"), h.length > 0 && P.add("computed"), S.length > 0 && P.add("watch"), w.length > 0 && P.add("inject"), I.length > 0 && P.add("provide");
|
|
1422
|
+
for (const O of A.usedHooks) P.add(O);
|
|
1423
|
+
const _e = s === "uniapp" ? Array.from(A.usedUniHooks) : [], { imports: ye, uniComponents: Se, componentDeclarations: je } = At({
|
|
1384
1424
|
componentMap: e,
|
|
1385
|
-
components:
|
|
1386
|
-
importBlocks:
|
|
1425
|
+
components: u.components,
|
|
1426
|
+
importBlocks: f,
|
|
1387
1427
|
collectImports: t.imports,
|
|
1388
1428
|
platform: s,
|
|
1389
|
-
vueImports: Array.from(
|
|
1390
|
-
composableImports:
|
|
1429
|
+
vueImports: Array.from(P),
|
|
1430
|
+
composableImports: v.imports,
|
|
1391
1431
|
globalApiImports: p,
|
|
1392
|
-
uniHookImports:
|
|
1432
|
+
uniHookImports: _e,
|
|
1393
1433
|
easycomPackages: t.easycomPackages
|
|
1394
|
-
}),
|
|
1434
|
+
}), ke = de(t.urlSchemas), we = he(t.blockPlugins);
|
|
1395
1435
|
return {
|
|
1396
1436
|
id: n.id,
|
|
1397
1437
|
version: n.__VERSION__,
|
|
1398
1438
|
name: n.name,
|
|
1399
1439
|
imports: `
|
|
1400
|
-
` +
|
|
1440
|
+
` + ye.join(`
|
|
1401
1441
|
`),
|
|
1402
|
-
props:
|
|
1403
|
-
emits:
|
|
1404
|
-
needsProps:
|
|
1405
|
-
needsEmit:
|
|
1442
|
+
props: ie(n.props).join(","),
|
|
1443
|
+
emits: le(n.emits).join(","),
|
|
1444
|
+
needsProps: l.has("$props"),
|
|
1445
|
+
needsEmit: l.has("$emit"),
|
|
1406
1446
|
expose: n.expose && n.expose.length ? `{ ${n.expose.join(", ")} }` : "",
|
|
1407
|
-
globalApiDeclares:
|
|
1447
|
+
globalApiDeclares: D.join(`
|
|
1408
1448
|
`),
|
|
1409
|
-
injects:
|
|
1449
|
+
injects: w.join(`
|
|
1410
1450
|
`),
|
|
1411
|
-
composables:
|
|
1451
|
+
composables: v.statements.join(`
|
|
1412
1452
|
`),
|
|
1413
|
-
state:
|
|
1414
|
-
refs:
|
|
1453
|
+
state: C,
|
|
1454
|
+
refs: b.join(`
|
|
1415
1455
|
`),
|
|
1416
|
-
reactives:
|
|
1456
|
+
reactives: g.join(`
|
|
1417
1457
|
`),
|
|
1418
|
-
computed:
|
|
1458
|
+
computed: h.join(`
|
|
1419
1459
|
`),
|
|
1420
|
-
methods:
|
|
1460
|
+
methods: d.join(`
|
|
1421
1461
|
`),
|
|
1422
|
-
dataSources:
|
|
1462
|
+
dataSources: y.join(`
|
|
1423
1463
|
`),
|
|
1424
|
-
watch:
|
|
1464
|
+
watch: S.join(`
|
|
1425
1465
|
`),
|
|
1426
|
-
provide:
|
|
1466
|
+
provide: I.join(`
|
|
1427
1467
|
`),
|
|
1428
|
-
createdStatements:
|
|
1429
|
-
setupStatements:
|
|
1430
|
-
lifeCycles:
|
|
1468
|
+
createdStatements: ve,
|
|
1469
|
+
setupStatements: be,
|
|
1470
|
+
lifeCycles: A.statements.join(`
|
|
1431
1471
|
`),
|
|
1432
|
-
template:
|
|
1472
|
+
template: u.nodes.join(`
|
|
1433
1473
|
`),
|
|
1434
1474
|
css: n.css || "",
|
|
1435
|
-
style:
|
|
1436
|
-
urlSchemas:
|
|
1475
|
+
style: me(t.style),
|
|
1476
|
+
urlSchemas: ke.join(`
|
|
1437
1477
|
`),
|
|
1438
|
-
blockPlugins:
|
|
1478
|
+
blockPlugins: we.join(`
|
|
1439
1479
|
`),
|
|
1440
|
-
uniComponents:
|
|
1480
|
+
uniComponents: Se,
|
|
1441
1481
|
renderer: s === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer",
|
|
1442
|
-
rendererImports: ["useProvider", ...
|
|
1443
|
-
componentDeclarations:
|
|
1482
|
+
rendererImports: ["useProvider", ...i].join(", "),
|
|
1483
|
+
componentDeclarations: je.join(`
|
|
1444
1484
|
`)
|
|
1445
1485
|
};
|
|
1446
1486
|
}
|
|
1447
|
-
const
|
|
1487
|
+
const Nt = `
|
|
1448
1488
|
// @ts-nocheck
|
|
1449
1489
|
import { useProvider } from '<%= renderer %>';
|
|
1450
1490
|
<%= imports %>
|
|
@@ -1476,7 +1516,7 @@ export default defineComponent({
|
|
|
1476
1516
|
<% if(methods) { %> methods: { <%= methods %> }, <% } %>
|
|
1477
1517
|
<% if(watch) { %> watch: { <%= watch %> }, <% } %> <%= lifeCycles %>
|
|
1478
1518
|
});
|
|
1479
|
-
`,
|
|
1519
|
+
`, Mt = `
|
|
1480
1520
|
<template>
|
|
1481
1521
|
<%= template %>
|
|
1482
1522
|
</template>
|
|
@@ -1487,7 +1527,7 @@ export default defineComponent({
|
|
|
1487
1527
|
<%= css %>
|
|
1488
1528
|
<%= style %>
|
|
1489
1529
|
</style>
|
|
1490
|
-
`,
|
|
1530
|
+
`, Tt = `// @ts-nocheck
|
|
1491
1531
|
import { <%= rendererImports %> } from '<%= renderer %>';<%= imports %>
|
|
1492
1532
|
<% if(componentDeclarations) { %><%= componentDeclarations %><% } %>
|
|
1493
1533
|
<% if(props) { %>const __props = defineProps({ <%= props %> });<% } else if(needsProps) { %>const __props = defineProps();<% } %>
|
|
@@ -1510,54 +1550,63 @@ const __provider = useProvider({ id: '<%= id %>', version: '<%= version %>' });
|
|
|
1510
1550
|
<%= provide %>
|
|
1511
1551
|
<%= lifeCycles %>
|
|
1512
1552
|
<% if(expose) { %>defineExpose(<%= expose %>);<% } %>
|
|
1513
|
-
`,
|
|
1514
|
-
async function
|
|
1553
|
+
`, Rt = q(Nt), Lt = q(Tt), Dt = q(Mt);
|
|
1554
|
+
async function Wt(t, e = /* @__PURE__ */ new Map(), s = [], o = "web", n) {
|
|
1515
1555
|
const r = t, c = typeof r.dsl == "object" && arguments.length === 1 ? r : {
|
|
1516
1556
|
dsl: t,
|
|
1517
1557
|
componentMap: e,
|
|
1518
1558
|
dependencies: s,
|
|
1519
|
-
platform:
|
|
1520
|
-
formatterDisabled:
|
|
1559
|
+
platform: o,
|
|
1560
|
+
formatterDisabled: n
|
|
1521
1561
|
}, {
|
|
1522
1562
|
dsl: a,
|
|
1523
1563
|
componentMap: l = /* @__PURE__ */ new Map(),
|
|
1524
|
-
dependencies:
|
|
1525
|
-
platform:
|
|
1564
|
+
dependencies: m = [],
|
|
1565
|
+
platform: p = "web",
|
|
1526
1566
|
formatterDisabled: i = !1,
|
|
1527
1567
|
ts: u = !0,
|
|
1528
|
-
scss: f = !1
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1568
|
+
scss: f = !1,
|
|
1569
|
+
project: b
|
|
1570
|
+
} = c, g = b ? Me(b) : null, C = g ? (v) => {
|
|
1571
|
+
const x = g.byId.get(v);
|
|
1572
|
+
return x?.type === "block" ? se(x) : `./${v}.vue`;
|
|
1573
|
+
} : void 0, h = new Ue(Pe(a), m), $ = a.apiMode === "composition";
|
|
1574
|
+
let d, y, S, w;
|
|
1575
|
+
if ($) {
|
|
1576
|
+
const v = Bt(
|
|
1577
|
+
h,
|
|
1578
|
+
l,
|
|
1579
|
+
p,
|
|
1580
|
+
C
|
|
1581
|
+
);
|
|
1582
|
+
w = Lt(v), d = v.template || `
|
|
1534
1583
|
<!--组件模版内容-->
|
|
1535
|
-
`,
|
|
1584
|
+
`, y = v.css, S = v.style;
|
|
1536
1585
|
} else {
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1586
|
+
const v = ct(h, l, p, C);
|
|
1587
|
+
w = Rt(v), d = v.template || `
|
|
1539
1588
|
<!--组件模版内容-->
|
|
1540
|
-
`,
|
|
1589
|
+
`, y = v.css, S = v.style;
|
|
1541
1590
|
}
|
|
1542
|
-
const
|
|
1543
|
-
template:
|
|
1544
|
-
css: await
|
|
1591
|
+
const I = Dt({
|
|
1592
|
+
template: d,
|
|
1593
|
+
css: await Z(y, i) || `
|
|
1545
1594
|
/* 组件样式内容 */
|
|
1546
1595
|
`,
|
|
1547
|
-
script: await
|
|
1548
|
-
style: await
|
|
1596
|
+
script: await Te(w, i),
|
|
1597
|
+
style: await Z(S, i),
|
|
1549
1598
|
scriptLang: u ? "ts" : "js",
|
|
1550
1599
|
styleLang: f ? "scss" : "css",
|
|
1551
|
-
scriptSetup:
|
|
1600
|
+
scriptSetup: $
|
|
1552
1601
|
});
|
|
1553
|
-
return await
|
|
1602
|
+
return await re(I, i).catch((v) => (v.content = I, Promise.reject(v)));
|
|
1554
1603
|
}
|
|
1555
|
-
async function
|
|
1556
|
-
const
|
|
1604
|
+
async function Ht(t, e = "web") {
|
|
1605
|
+
const s = `
|
|
1557
1606
|
<template>
|
|
1558
1607
|
<div>
|
|
1559
1608
|
<h3>源码模式页面</h3>
|
|
1560
|
-
<div
|
|
1609
|
+
<div>文件路径:/${W(t, e)}</div>
|
|
1561
1610
|
</div>
|
|
1562
1611
|
</template>
|
|
1563
1612
|
<script lang="ts" setup>
|
|
@@ -1565,18 +1614,18 @@ async function Rt(t) {
|
|
|
1565
1614
|
<style scoped lang="scss">
|
|
1566
1615
|
</style>
|
|
1567
1616
|
`;
|
|
1568
|
-
return await
|
|
1617
|
+
return await re(s);
|
|
1569
1618
|
}
|
|
1570
1619
|
export {
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1620
|
+
N as GLOBAL_API_MAP,
|
|
1621
|
+
ge as UI_GLOBAL_API_MAPS,
|
|
1622
|
+
at as UI_PACKAGES,
|
|
1623
|
+
Jt as VTJ_CODER_VERSION,
|
|
1624
|
+
lt as buildEffectiveApiMap,
|
|
1625
|
+
Ht as createEmptyPage,
|
|
1626
|
+
Z as cssFormatter,
|
|
1627
|
+
it as detectUIPackage,
|
|
1628
|
+
Wt as generator,
|
|
1629
|
+
Te as tsFormatter,
|
|
1630
|
+
re as vueFormatter
|
|
1582
1631
|
};
|