@vtj/coder 0.17.8 → 0.18.1

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.mjs CHANGED
@@ -1,25 +1,25 @@
1
- import { mitt as K, base64 as ee, dedupArray as C, toArray as te, kebabCase as B, camelCase as b, isPlainObject as se, template as J, cloneDeep as ne } from "@vtj/base";
2
- import { format as F } from "prettier/standalone";
3
- import * as re from "prettier/plugins/html";
4
- import * as U from "prettier/plugins/babel";
5
- import * as M from "prettier/plugins/postcss";
6
- import * as V from "prettier/plugins/estree";
1
+ import { mitt as ye, base64 as Se, dedupArray as B, toArray as je, kebabCase as F, camelCase as A, isPlainObject as ke, isString as we, template as W, cloneDeep as Ie } from "@vtj/base";
2
+ import { format as H } from "prettier/standalone";
3
+ import * as Oe from "prettier/plugins/html";
4
+ import * as Q from "prettier/plugins/babel";
5
+ import * as X from "prettier/plugins/postcss";
6
+ import * as Y 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.17.8
11
+ * @version 0.18.1
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const Je = "0.17.8";
14
+ const Tt = "0.18.1";
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.17.8
19
+ * @version 0.18.1
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
- const ie = [
22
+ const Ce = [
23
23
  "slot",
24
24
  "template",
25
25
  "component",
@@ -32,8 +32,8 @@ const ie = [
32
32
  "span",
33
33
  "a"
34
34
  ];
35
- K();
36
- const T = {
35
+ ye();
36
+ const V = {
37
37
  arrowParens: "always",
38
38
  bracketSpacing: !0,
39
39
  bracketSameLine: !0,
@@ -51,63 +51,64 @@ const T = {
51
51
  tabWidth: 2,
52
52
  trailingComma: "none",
53
53
  useTabs: !1,
54
- vueIndentScriptAndStyle: !0
54
+ vueIndentScriptAndStyle: !0,
55
+ removeBlankLines: !0
55
56
  };
56
- async function H(t, e) {
57
- return e ? t : await F(t, {
57
+ async function K(t, e) {
58
+ return e ? t : await H(t, {
58
59
  parser: "vue",
59
- ...T,
60
- plugins: [re, U, V, M]
60
+ ...V,
61
+ plugins: [Oe, Q, Y, X]
61
62
  });
62
63
  }
63
- async function oe(t, e) {
64
+ async function xe(t, e) {
64
65
  if (e) return t;
65
66
  try {
66
- return (await F(t, {
67
+ return (await H(t, {
67
68
  parser: "babel-ts",
68
- ...T,
69
- plugins: [U, V]
69
+ ...V,
70
+ plugins: [Q, Y]
70
71
  })).replace(/;\n$/gi, "");
71
- } catch (n) {
72
- return console.warn(n), t;
72
+ } catch (s) {
73
+ return console.warn(s), t;
73
74
  }
74
75
  }
75
- async function W(t, e) {
76
- return e ? t : F(t, {
76
+ async function G(t, e) {
77
+ return e ? t : H(t, {
77
78
  parser: "scss",
78
- ...T,
79
- plugins: [M]
79
+ ...V,
80
+ plugins: [X]
80
81
  });
81
82
  }
82
- function w(t) {
83
+ function T(t) {
83
84
  return t && t.type === "JSExpression";
84
85
  }
85
- function A(t) {
86
+ function R(t) {
86
87
  return typeof t == "object" && t && t.type === "JSFunction";
87
88
  }
88
- function j(t) {
89
- return w(t) || A(t);
89
+ function S(t) {
90
+ return T(t) || R(t);
90
91
  }
91
- function q(t) {
92
+ function ee(t) {
92
93
  return t.replace(new RegExp("this.", "g"), "");
93
94
  }
94
- function D(t) {
95
+ function J(t) {
95
96
  return t.replace(/this\.context\??\./g, "");
96
97
  }
97
- function m(t, e = !0, n = !0, s = [], i = !0) {
98
+ function _(t, e = !0, s = !0, n = [], o = !0) {
98
99
  let r = t;
99
- return j(t) ? (r = t.value.trim().replace(/;$/, ""), i && (r = r.replace(/\"/g, "'"))) : r = e ? JSON.stringify(r) : t, r = x(r, s), n ? q(D(r)) : D(r);
100
+ return S(t) ? (r = t.value.trim().replace(/;$/, ""), o && (r = r.replace(/\"/g, "'"))) : r = e ? JSON.stringify(r) : t, r = M(r, n), s ? ee(J(r)) : J(r);
100
101
  }
101
- function x(t = "", e = []) {
102
- let n = t;
103
- for (const s of e)
104
- n = n.replace(
105
- new RegExp(`this.${s}.value`, "g"),
106
- `this.${s}`
102
+ function M(t = "", e = []) {
103
+ let s = t;
104
+ for (const n of e)
105
+ s = s.replace(
106
+ new RegExp(`this.${n}.value`, "g"),
107
+ `this.${n}`
107
108
  );
108
- return n;
109
+ return s;
109
110
  }
110
- function Q(t) {
111
+ function te(t) {
111
112
  let e = t.trim().replace(/;$/, "");
112
113
  if (e = /^\((\(|async|function)/.test(e) ? e.substring(1, e.length - 1) : e, e.startsWith("{")) return e;
113
114
  if (e.startsWith("async function"))
@@ -115,36 +116,36 @@ function Q(t) {
115
116
  else if (e.startsWith("function"))
116
117
  e = e.replace(/^function/, "");
117
118
  else {
118
- const i = /^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/, r = e.match(i);
119
+ const o = /^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/, r = e.match(o);
119
120
  r && r[2] && (r[2].startsWith("{") || (e = e.replace(r[2], `{ return ${r[2]} }`))), e = e.replace("=>", "");
120
121
  }
121
122
  return e;
122
123
  }
123
- function ce(t = {}) {
124
- return Object.entries(t).map(([e, n]) => `"${e}": ${m(n)}`);
124
+ function Ae(t = {}) {
125
+ return Object.entries(t).map(([e, s]) => `"${e}": ${_(s)}`);
125
126
  }
126
- function G(t = {}, e = !1) {
127
- const n = Object.keys(t);
128
- return e ? n.map((s) => "." + s) : n;
127
+ function se(t = {}, e = !1) {
128
+ const s = Object.keys(t);
129
+ return e ? s.map((n) => "." + n) : s;
129
130
  }
130
- function ae(t) {
131
+ function Pe(t) {
131
132
  let e = "";
132
- for (var n in t)
133
- if (t.hasOwnProperty(n)) {
134
- var s = t[n];
135
- e += n + ": " + s + ";";
133
+ for (var s in t)
134
+ if (t.hasOwnProperty(s)) {
135
+ var n = t[s];
136
+ e += s + ": " + n + ";";
136
137
  }
137
138
  return e;
138
139
  }
139
- function le(t = [], e = []) {
140
- return t.filter((n) => !e.includes(n));
140
+ function Ee(t = [], e = []) {
141
+ return t.filter((s) => !e.includes(s));
141
142
  }
142
- function L(t) {
143
- return ee(JSON.stringify(t));
143
+ function z(t) {
144
+ return Se(JSON.stringify(t));
144
145
  }
145
- class ue {
146
- constructor(e, n) {
147
- this.dsl = e, this.dependencies = n, this.libraryRegex = this.collectLibrary(), this.walk(e), this.walkNodes(e), this.members = this.getLibraryMember();
146
+ class Ne {
147
+ constructor(e, s) {
148
+ this.dsl = e, this.dependencies = s, this.collectEasycom(), this.libraryRegex = this.collectLibrary(), this.walk(e), this.walkNodes(e), this.members = this.getLibraryMember();
148
149
  }
149
150
  /**
150
151
  * { 'element-plus': ['ElButton', 'ElInput' ...] }
@@ -155,7 +156,13 @@ class ue {
155
156
  members = [];
156
157
  urlSchemas = {};
157
158
  blockPlugins = {};
159
+ /** 配置了 easycom 的依赖包名集合,出码时不需要 import */
160
+ easycomPackages = /* @__PURE__ */ new Set();
158
161
  libraryRegex = [];
162
+ collectEasycom() {
163
+ for (const e of this.dependencies)
164
+ e.easycom?.key && e.easycom?.value && e.package && this.easycomPackages.add(e.package);
165
+ }
159
166
  collectLibrary() {
160
167
  return this.dependencies.filter((e) => !!e.library).map((e) => new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`, "g"));
161
168
  }
@@ -165,18 +172,18 @@ class ue {
165
172
  * @returns ex: { name: 'ElButton', path: 'this.$libs.ElementPlus.', library: 'ElementPlus' }
166
173
  */
167
174
  collectImport(e) {
168
- const n = e.split(".");
169
- if (n.length === 4) {
170
- const s = n.pop(), i = n.join(".") + ".", r = n.pop();
171
- if (s && r) {
172
- const o = this.dependencies.find(
175
+ const s = e.split(".");
176
+ if (s.length === 4) {
177
+ const n = s.pop(), o = s.join(".") + ".", r = s.pop();
178
+ if (n && r) {
179
+ const c = this.dependencies.find(
173
180
  (a) => a.library === r
174
181
  )?.package;
175
- o && (this.imports[o] || (this.imports[o] = /* @__PURE__ */ new Set())).add(s);
182
+ c && !this.easycomPackages.has(c) && (this.imports[c] || (this.imports[c] = /* @__PURE__ */ new Set())).add(n);
176
183
  }
177
184
  return {
178
- name: s,
179
- path: i,
185
+ name: n,
186
+ path: o,
180
187
  library: r
181
188
  };
182
189
  }
@@ -184,58 +191,58 @@ class ue {
184
191
  }
185
192
  // 代码中包含依赖库的引用,需要从代码中移除
186
193
  replaceLibraryPath(e) {
187
- const { libraryRegex: n } = this;
188
- let s = e.value;
189
- for (const i of n) {
190
- const r = e.value?.match(i) || [];
191
- for (const o of r) {
192
- const a = this.collectImport(o);
194
+ const { libraryRegex: s } = this;
195
+ let n = e.value;
196
+ for (const o of s) {
197
+ const r = e.value?.match(o) || [];
198
+ for (const c of r) {
199
+ const a = this.collectImport(c);
193
200
  if (a) {
194
- const h = a.path.replace(/\$/g, "\\$");
195
- s = s.replace(new RegExp(h, "g"), "");
201
+ const l = a.path.replace(/\$/g, "\\$");
202
+ n = n.replace(new RegExp(l, "g"), "");
196
203
  }
197
204
  }
198
205
  }
199
- return s;
206
+ return n;
200
207
  }
201
208
  walk(e) {
202
- const n = (s) => {
203
- if (!s || typeof s != "object") return;
204
- if (Array.isArray(s)) {
205
- for (let r of s)
206
- n(r);
209
+ const s = (n) => {
210
+ if (!n || typeof n != "object") return;
211
+ if (Array.isArray(n)) {
212
+ for (let r of n)
213
+ s(r);
207
214
  return;
208
215
  }
209
- const i = Object.values(s);
210
- for (const r of i)
211
- j(r) ? r.value = this.replaceLibraryPath(r) : n(r);
216
+ const o = Object.values(n);
217
+ for (const r of o)
218
+ S(r) ? r.value = this.replaceLibraryPath(r) : s(r);
212
219
  };
213
- n(e);
220
+ s(e);
214
221
  }
215
222
  getLibraryMember(e = []) {
216
- let n = [...e];
217
- const s = { ...this.imports };
218
- delete s["uni-h5"], delete s["@dcloudio/uni-h5"], delete s["uni-ui"], delete s["@dcloudio/uni-ui"];
219
- for (const i of Object.values(s))
220
- n = n.concat(Array.from(i));
221
- return C(n);
223
+ let s = [...e];
224
+ const n = { ...this.imports };
225
+ delete n["uni-h5"], delete n["@dcloudio/uni-h5"], delete n["uni-ui"], delete n["@dcloudio/uni-ui"];
226
+ for (const o of Object.values(n))
227
+ s = s.concat(Array.from(o));
228
+ return B(s);
222
229
  }
223
- collectContext(e, n) {
224
- const s = new Set(n?.id ? this.context[n.id] : []), i = (e.directives || []).find((a) => a.name === "vFor");
225
- let r = new Set(Array.from(s));
226
- if (i) {
227
- const { item: a = "item", index: h = "index" } = i.iterator || {};
228
- r = /* @__PURE__ */ new Set([a, h, ...Array.from(r)]);
229
- }
230
- const o = e.slot;
230
+ collectContext(e, s) {
231
+ const n = new Set(s?.id ? this.context[s.id] : []), o = (e.directives || []).find((a) => a.name === "vFor");
232
+ let r = new Set(Array.from(n));
231
233
  if (o) {
232
- const a = typeof o == "string" ? [] : o.params || [], h = a.length ? a : [`scope_${n?.id}`];
233
- r = /* @__PURE__ */ new Set([...h, ...Array.from(r)]);
234
+ const { item: a = "item", index: l = "index" } = o.iterator || {};
235
+ r = /* @__PURE__ */ new Set([a, l, ...Array.from(r)]);
236
+ }
237
+ const c = e.slot;
238
+ if (c) {
239
+ const a = typeof c == "string" ? [] : c.params || [], l = a.length ? a : [`scope_${s?.id}`];
240
+ r = /* @__PURE__ */ new Set([...l, ...Array.from(r)]);
234
241
  }
235
242
  this.context[e.id] = r;
236
243
  }
237
244
  collectStyle(e) {
238
- e.id && e.props?.style && Object.keys(e.props.style).length && !j(e.props.style) && (this.style[`.${e.name}_${e.id}`] = e.props.style);
245
+ e.id && e.props?.style && Object.keys(e.props.style).length && !S(e.props.style) && (this.style[`.${e.name}_${e.id}`] = e.props.style);
239
246
  }
240
247
  collectUrlSchema(e) {
241
248
  typeof e.from == "object" && e.from.type === "UrlSchema" && (this.urlSchemas[e.name] = e.from);
@@ -244,76 +251,76 @@ class ue {
244
251
  typeof e.from == "object" && e.from.type === "Plugin" && (this.blockPlugins[e.name] = e.from);
245
252
  }
246
253
  walkNodes(e) {
247
- const n = (s, i) => {
248
- this.collectContext(s, i), this.collectStyle(s), this.collectUrlSchema(s), this.collectBlockPlugin(s), Array.isArray(s.children) && s.children.forEach((r) => n(r, s));
254
+ const s = (n, o) => {
255
+ this.collectContext(n, o), this.collectStyle(n), this.collectUrlSchema(n), this.collectBlockPlugin(n), Array.isArray(n.children) && n.children.forEach((r) => s(r, n));
249
256
  };
250
- Array.isArray(e.nodes) && e.nodes.forEach((s) => n(s));
257
+ Array.isArray(e.nodes) && e.nodes.forEach((n) => s(n));
251
258
  }
252
259
  }
253
- function pe(t = {}) {
254
- return Object.entries(t).map(([e, n]) => {
255
- const s = m(n, !1, !0, [], !1);
256
- return `${e}:${s}`;
260
+ function Be(t = {}) {
261
+ return Object.entries(t).map(([e, s]) => {
262
+ const n = _(s, !1, !0, [], !1);
263
+ return `${e}:${n}`;
257
264
  });
258
265
  }
259
- function fe(t = []) {
266
+ function Te(t = []) {
260
267
  return t.map((e) => `${e.name}: {
261
268
  from: '${e.from || e.name}',
262
- default: ${m(e.default, !0, !1, [], !1)}
269
+ default: ${_(e.default, !0, !1, [], !1)}
263
270
  }`);
264
271
  }
265
- function me(t = []) {
266
- const e = (n) => n ? `[${te(n).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
267
- return t.map((n) => typeof n == "string" ? `${n}: {}` : (j(n.default) && !n.default.value && (n.default.value = "undefined"), `${n.name}: {
268
- type:${e(n.type)},
269
- required: ${m(!!n.required, !0, !1, [], !1)},
270
- default: ${n.default ? m(n.default, !0, !1, [], !1) : "undefined"}
272
+ function ne(t = []) {
273
+ const e = (s) => s ? `[${je(s).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
274
+ return t.map((s) => typeof s == "string" ? `${s}: {}` : (S(s.default) && !s.default.value && (s.default.value = "undefined"), `${s.name}: {
275
+ type:${e(s.type)},
276
+ required: ${_(!!s.required, !0, !1, [], !1)},
277
+ default: ${s.default ? _(s.default, !0, !1, [], !1) : "undefined"}
271
278
  }`));
272
279
  }
273
- function he(t = []) {
280
+ function re(t = []) {
274
281
  return t.map((e) => `'${typeof e == "string" ? e : e.name}'`);
275
282
  }
276
- function N(t = {}, e = []) {
277
- return Object.entries(t).map(([n, s]) => {
278
- let i = Q(
279
- m(s, !1, !1, [], !1)
283
+ function U(t = {}, e = []) {
284
+ return Object.entries(t).map(([s, n]) => {
285
+ let o = te(
286
+ _(n, !1, !1, [], !1)
280
287
  );
281
- return i = x(i, e)?.trim(), i.startsWith("async") ? `async ${n}${i.replace(/^async/, "")}` : i.startsWith("(") || i.startsWith("{") ? `${n}${i}` : null;
282
- }).filter((n) => !!n);
288
+ return o = M(o, e)?.trim(), o.startsWith("async") ? `async ${s}${o.replace(/^async/, "")}` : o.startsWith("(") || o.startsWith("{") ? `${s}${o}` : null;
289
+ }).filter((s) => !!s);
283
290
  }
284
- function de(t = [], e = []) {
285
- const n = t.reduce(
286
- (r, o) => (o.id && A(o.source) && (r[`watcher_${o.id}`] = o.source), r),
291
+ function Me(t = [], e = []) {
292
+ const s = t.reduce(
293
+ (r, c) => (c.id && R(c.source) && (r[`watcher_${c.id}`] = c.source), r),
287
294
  {}
288
- ), s = N(n, e), i = t.map((r) => r.handler && r.handler.value ? `watcher_${r.id}: {
295
+ ), n = U(s, e), o = t.map((r) => r.handler && r.handler.value ? `watcher_${r.id}: {
289
296
  deep: ${r.deep},
290
297
  immediate:${r.immediate},
291
- handler${Q(r.handler.value)}
298
+ handler${te(r.handler.value)}
292
299
  }` : null).filter((r) => !!r);
293
300
  return {
294
- computed: s,
295
- watches: i
301
+ computed: n,
302
+ watches: o
296
303
  };
297
304
  }
298
- function ge(t = {}) {
305
+ function Re(t = {}) {
299
306
  return Object.values(t).map((e) => {
300
307
  if (e.type === "mock") {
301
- const n = A(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
308
+ const s = R(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
302
309
  return `async ${e.name}(...args) {
303
- // DataSource: ${L(e)}
304
- const mock = this.provider.createMock(${n});
310
+ // DataSource: ${z(e)}
311
+ const mock = this.provider.createMock(${s});
305
312
  return await mock.apply(this, args);
306
313
  }`;
307
314
  } else {
308
- const n = A(e.transform) && e.transform.value || "(res) => res";
315
+ const s = R(e.transform) && e.transform.value || "(res) => res";
309
316
  return `async ${e.name}(...args) {
310
- // DataSource: ${L(e)}
311
- return await this.provider.apis['${e.ref}'].apply(this, args).then(${n});
317
+ // DataSource: ${z(e)}
318
+ return await this.provider.apis['${e.ref}'].apply(this, args).then(${s});
312
319
  }`;
313
320
  }
314
321
  });
315
322
  }
316
- const ye = [
323
+ const De = [
317
324
  "img",
318
325
  "input",
319
326
  "br",
@@ -328,7 +335,7 @@ const ye = [
328
335
  "source",
329
336
  "track",
330
337
  "wbr"
331
- ], R = [
338
+ ], Z = [
332
339
  "vIf",
333
340
  "vElseIf",
334
341
  "vElse",
@@ -338,341 +345,1099 @@ const ye = [
338
345
  "vBind",
339
346
  "vHtml"
340
347
  ];
341
- function Z(t, e, n = [], s = {}, i) {
348
+ function q(t, e, s = [], n = {}, o) {
342
349
  const r = [];
343
- let o = {}, a = [];
344
- const h = [];
350
+ let c = {}, a = [];
351
+ const l = [];
345
352
  let p = [];
346
- return $e(t).forEach((c) => {
347
- const y = [];
348
- for (const f of c.children) {
349
- let { id: d, name: v, invisible: $, from: g } = f;
350
- if ($)
353
+ return Le(t).forEach((i) => {
354
+ const u = [];
355
+ for (const v of i.children) {
356
+ let { id: b, name: k, invisible: g, from: m } = v;
357
+ if (g)
351
358
  continue;
352
- const O = be(v, e, g);
353
- O && a.push(O), z(g) && p.push({ id: g.id, name: v });
354
- const { props: E, events: P } = xe(
355
- f,
356
- d,
357
- f.props,
358
- f.events,
359
- s,
360
- n
361
- ), k = Ce(
362
- f.directives,
363
- n,
364
- h
365
- ).join(" "), S = f.children ? Ee(
366
- f.children,
359
+ const h = Fe(k, e, m);
360
+ h && a.push(h), oe(m) && p.push({ id: m.id, name: k });
361
+ const { props: y, events: $ } = qe(
362
+ v,
363
+ b,
364
+ v.props,
365
+ v.events,
367
366
  n,
368
- e,
367
+ s
368
+ ), w = Ge(
369
+ v.directives,
370
+ s,
371
+ l
372
+ ).join(" "), I = v.children ? Qe(
373
+ v.children,
369
374
  s,
370
- f
375
+ e,
376
+ n,
377
+ v
371
378
  ) : "";
372
- let _ = "";
373
- typeof S == "string" ? _ = S : (_ = (S?.nodes || []).join(`
374
- `), Object.assign(o, S?.methods || {}), a = a.concat(S?.components || []), p = p.concat(S?.importBlocks || []));
375
- const I = ["@dcloudio/uni-h5", "@dcloudio/uni-ui"].includes(
376
- g || e.get(v)?.package
377
- ) ? B(v) : X(g) || Y(g) ? "component" : v;
378
- y.push(
379
- ye.includes(I) ? `<${I} ${k} ${E} ${P} />` : `<${I} ${k} ${E} ${P}>${_ ? `
380
- ` + _.trim() : ""}</${I}>`
379
+ let C = "";
380
+ typeof I == "string" ? C = I : (C = (I?.nodes || []).join(`
381
+ `), Object.assign(c, I?.methods || {}), a = a.concat(I?.components || []), p = p.concat(I?.importBlocks || []));
382
+ const N = ["@dcloudio/uni-h5", "@dcloudio/uni-ui"].includes(
383
+ m || e.get(k)?.package
384
+ ) ? F(k) : ce(m) || ae(m) ? "component" : k;
385
+ u.push(
386
+ De.includes(N) ? `<${N} ${w} ${y} ${$} />` : `<${N} ${w} ${y} ${$}>${C ? `
387
+ ` + C.trim() : ""}</${N}>`
381
388
  );
382
389
  }
383
- const l = Pe(c.slot, y.join(`
384
- `), i?.id);
385
- r.push(l);
390
+ const f = Xe(i.slot, u.join(`
391
+ `), o?.id);
392
+ r.push(f);
386
393
  }), {
387
394
  nodes: r,
388
- methods: o,
389
- directives: ve(h),
390
- components: C(a),
391
- importBlocks: C(p, "id")
395
+ methods: c,
396
+ directives: Ue(l),
397
+ components: B(a),
398
+ importBlocks: B(p, "id")
392
399
  };
393
400
  }
394
- function ve(t) {
395
- return C(t).map((e) => `${e.startsWith("v") ? e.substring(1) : e}:${e}`);
401
+ function Ue(t) {
402
+ return B(t).map((e) => `${e.startsWith("v") ? e.substring(1) : e}:${e}`);
396
403
  }
397
- function $e(t = []) {
404
+ function Le(t = []) {
398
405
  const e = /* @__PURE__ */ new Map();
399
- for (const n of t) {
400
- const s = typeof n.slot == "string" ? n.slot : n.slot?.name, i = e.get(s);
401
- i ? i.children.push(n) : e.set(s, { slot: n.slot, children: [n] });
406
+ for (const s of t) {
407
+ const n = typeof s.slot == "string" ? s.slot : s.slot?.name, o = e.get(n);
408
+ o ? o.children.push(s) : e.set(n, { slot: s.slot, children: [s] });
402
409
  }
403
410
  return e;
404
411
  }
405
- function be(t, e, n) {
406
- if (ie.includes(t)) return null;
407
- const s = e.get(t);
408
- if (s && s.alias) {
409
- const i = s.parent ? `${s.parent}.${s.alias}` : s.alias;
410
- return `${t}: ${i}`;
412
+ function Fe(t, e, s) {
413
+ if (Ce.includes(t)) return null;
414
+ const n = e.get(t);
415
+ if (n && n.alias) {
416
+ const o = n.parent ? `${n.parent}.${n.alias}` : n.alias;
417
+ return `${t}: ${o}`;
411
418
  }
412
- return z(n) || s ? t : null;
419
+ return oe(s) || n ? t : null;
413
420
  }
414
- function z(t) {
421
+ function oe(t) {
415
422
  return !!t && typeof t == "object" && t.type === "Schema";
416
423
  }
417
- function X(t) {
424
+ function ce(t) {
418
425
  return typeof t == "object" && t.type === "UrlSchema";
419
426
  }
420
- function Y(t) {
427
+ function ae(t) {
421
428
  return typeof t == "object" && t.type === "Plugin";
422
429
  }
423
- function je(t, e, n = []) {
424
- return t === "style" ? j(e) ? `:style="${m({
430
+ function Je(t, e, s = []) {
431
+ return t === "style" ? S(e) ? `:style="${_({
425
432
  ...e,
426
- value: x(e.value, n)
427
- })}"` : "" : t === "__class" && j(e) ? `:class="${m({
433
+ value: M(e.value, s)
434
+ })}"` : "" : t === "__class" && S(e) ? `:class="${_({
428
435
  ...e,
429
- value: x(e.value, n)
430
- })}"` : typeof e == "string" ? `${t}="${e}"` : j(e) ? `:${t}="${m({
436
+ value: M(e.value, s)
437
+ })}"` : typeof e == "string" ? `${t}="${e}"` : S(e) ? `:${t}="${_({
431
438
  ...e,
432
- value: x(e.value, n)
433
- })}"` : se(e) ? `:${t}='{${ce(
439
+ value: M(e.value, s)
440
+ })}"` : ke(e) ? `:${t}='{${Ae(
434
441
  e
435
442
  ).join(", ")}}'` : `:${t}='${JSON.stringify(e)}'`;
436
443
  }
437
- function Se(t, e = {}, n = []) {
444
+ function We(t, e = {}, s = []) {
438
445
  if (!!Object.keys(e.style || {}).length) {
439
446
  const r = `${t.name}_${t.id}`;
440
- 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
+ e.class ? typeof e.class == "string" ? e.class = [e.class, r].join(" ") : (e.__class = e.class, e.class = r) : e.class = r, S(e.style) || delete e.style;
441
448
  }
442
- const i = t.from;
443
- return (X(i) || Y(i)) && (e.is = {
449
+ const o = t.from;
450
+ return (ce(o) || ae(o)) && (e.is = {
444
451
  type: "JSExpression",
445
452
  value: t.name
446
- }), Object.entries(e).map(([r, o]) => je(r, o, n));
453
+ }), Object.entries(e).map(([r, c]) => Je(r, c, s));
447
454
  }
448
- function ke(t, e, n) {
449
- const s = G(e.modifiers, !0);
450
- return `@${t}${s.join("")}="${n}"`;
455
+ function He(t, e, s) {
456
+ const n = se(e.modifiers, !0);
457
+ return `@${t}${n.join("")}="${s}"`;
451
458
  }
452
- function we(t, e = {}, n = {}) {
453
- const s = {};
459
+ function Ve(t, e = {}, s = {}) {
460
+ const n = {};
454
461
  return {
455
- binders: Object.entries(e).map(([r, o]) => {
456
- const a = q(D(o.handler.value)).replace(
462
+ binders: Object.entries(e).map(([r, c]) => {
463
+ const a = ee(J(c.handler.value)).replace(
457
464
  /\"/g,
458
465
  "'"
459
466
  );
460
- return ke(r, o, a);
467
+ return He(r, c, a);
461
468
  }),
462
- handlers: s
469
+ handlers: n
463
470
  };
464
471
  }
465
- function xe(t, e, n = {}, s = {}, i = {}, r) {
466
- const { binders: o, handlers: a } = we(e, s, i);
472
+ function qe(t, e, s = {}, n = {}, o = {}, r) {
473
+ const { binders: c, handlers: a } = Ve(e, n, o);
467
474
  return {
468
- props: Se(t, n, r).join(" "),
475
+ props: We(t, s, r).join(" "),
469
476
  handlers: a,
470
- binders: o,
471
- events: o.join(" ")
477
+ binders: c,
478
+ events: c.join(" ")
472
479
  };
473
480
  }
474
- function Ce(t = [], e = [], n = []) {
475
- const s = [], {
476
- vIf: i,
481
+ function Ge(t = [], e = [], s = []) {
482
+ const n = [], {
483
+ vIf: o,
477
484
  vElse: r,
478
- vElseIf: o,
485
+ vElseIf: c,
479
486
  vShow: a,
480
- vModels: h,
487
+ vModels: l,
481
488
  vFor: p,
482
- vBind: u,
483
- vHtml: c,
484
- customDirectives: y
485
- } = Oe(t);
486
- if (i && s.push(`v-if="${m(i.value, !0, !0, e)}"`), o && s.push(
487
- `v-else-if="${m(o.value, !0, !0, e)}"`
488
- ), r && s.push("v-else"), a && s.push(
489
- `v-show="${m(a.value, !0, !0, e)}"`
490
- ), u && s.push(
491
- `v-bind="${m(u.value, !0, !0, e)}"`
492
- ), h.forEach((l) => {
493
- const f = G(l.modifiers, !0), d = l.arg ? w(l.arg) ? `:[${m(l.arg, !0, !0, e)}]` : `:${l.arg}` : "";
494
- s.push(
495
- `v-model${d}${f}="${m(l.value, !0, !0, e)}"`
489
+ vBind: d,
490
+ vHtml: i,
491
+ customDirectives: u
492
+ } = ze(t);
493
+ if (o && n.push(`v-if="${_(o.value, !0, !0, e)}"`), c && n.push(
494
+ `v-else-if="${_(c.value, !0, !0, e)}"`
495
+ ), r && n.push("v-else"), a && n.push(
496
+ `v-show="${_(a.value, !0, !0, e)}"`
497
+ ), d && n.push(
498
+ `v-bind="${_(d.value, !0, !0, e)}"`
499
+ ), l.forEach((f) => {
500
+ const v = se(f.modifiers, !0), b = f.arg ? T(f.arg) ? `:[${_(f.arg, !0, !0, e)}]` : `:${f.arg}` : "";
501
+ n.push(
502
+ `v-model${b}${v}="${_(f.value, !0, !0, e)}"`
496
503
  );
497
504
  }), p) {
498
- const { item: l, index: f } = { item: "item", index: "index", ...p.iterator };
499
- s.push(
500
- `v-for="(${l}, ${f}) in ${m(p.value, !0, !0, e)}"`
505
+ const { item: f, index: v } = { item: "item", index: "index", ...p.iterator };
506
+ n.push(
507
+ `v-for="(${f}, ${v}) in ${_(p.value, !0, !0, e)}"`
501
508
  );
502
509
  }
503
- return c && s.push(
504
- `v-html="${m(c.value, !0, !0, e)}"`
505
- ), y && y.length && y.forEach((l) => {
506
- if (!l.name) return;
507
- let f = "", d = "";
508
- w(l.name) ? (d = m(l.name, !0, !0, e), n.push(d)) : d = l.name;
509
- const v = d?.startsWith("v") ? B(d) : B("v-" + d);
510
- if (f += v, l.arg && (w(l.arg) ? f += `:[${m(l.name, !0, !0, e)}]` : f += `:${l.arg}`), l.modifiers) {
511
- const $ = Object.keys(l.modifiers);
512
- $.length && (f += $.map((g) => "." + g));
510
+ return i && n.push(
511
+ `v-html="${_(i.value, !0, !0, e)}"`
512
+ ), u && u.length && u.forEach((f) => {
513
+ if (!f.name) return;
514
+ let v = "", b = "";
515
+ T(f.name) ? (b = _(f.name, !0, !0, e), s.push(b)) : b = f.name;
516
+ const k = b?.startsWith("v") ? F(b) : F("v-" + b);
517
+ if (v += k, f.arg && (T(f.arg) ? v += `:[${_(f.name, !0, !0, e)}]` : v += `:${f.arg}`), f.modifiers) {
518
+ const g = Object.keys(f.modifiers);
519
+ g.length && (v += g.map((m) => "." + m));
513
520
  }
514
- l.value ? s.push(
515
- `${f}="${m(l.value, !0, !0, e)}"`
516
- ) : s.push(f);
517
- }), s;
521
+ f.value ? n.push(
522
+ `${v}="${_(f.value, !0, !0, e)}"`
523
+ ) : n.push(v);
524
+ }), n;
518
525
  }
519
- function Oe(t = []) {
526
+ function ze(t = []) {
520
527
  const e = t.filter(
521
- (c) => R.includes(c.name)
522
- ), n = t.filter(
523
- (c) => !R.includes(c.name)
524
- ), s = e.find(
525
- (c) => b(c.name) === "vIf"
526
- ), i = e.find(
527
- (c) => b(c.name) === "vElseIf"
528
- ), r = e.find(
529
- (c) => b(c.name) === "vElse"
528
+ (i) => Z.includes(i.name)
529
+ ), s = t.filter(
530
+ (i) => !Z.includes(i.name)
531
+ ), n = e.find(
532
+ (i) => A(i.name) === "vIf"
530
533
  ), o = e.find(
531
- (c) => b(c.name) === "vFor"
534
+ (i) => A(i.name) === "vElseIf"
535
+ ), r = e.find(
536
+ (i) => A(i.name) === "vElse"
537
+ ), c = e.find(
538
+ (i) => A(i.name) === "vFor"
532
539
  ), a = e.find(
533
- (c) => b(c.name) === "vShow"
534
- ), h = e.find(
535
- (c) => b(c.name) === "vBind"
540
+ (i) => A(i.name) === "vShow"
541
+ ), l = e.find(
542
+ (i) => A(i.name) === "vBind"
536
543
  ), p = e.find(
537
- (c) => b(c.name) === "vHtml"
538
- ), u = e.filter(
539
- (c) => b(c.name) === "vModel"
544
+ (i) => A(i.name) === "vHtml"
545
+ ), d = e.filter(
546
+ (i) => A(i.name) === "vModel"
540
547
  );
541
548
  return {
542
- vIf: s,
543
- vElseIf: i,
549
+ vIf: n,
550
+ vElseIf: o,
544
551
  vElse: r,
545
- vFor: o,
552
+ vFor: c,
546
553
  vShow: a,
547
- vModels: u,
548
- vBind: h,
554
+ vModels: d,
555
+ vBind: l,
549
556
  vHtml: p,
550
- customDirectives: n
557
+ customDirectives: s
551
558
  };
552
559
  }
553
- function Ee(t, e, n, s, i) {
554
- return typeof t == "string" ? t : w(t) ? `{{ ${m(t, !1, !0, e)} }}` : Array.isArray(t) ? Z(t, n, e, s, i) : "";
560
+ function Ze(t) {
561
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
562
+ }
563
+ function Qe(t, e, s, n, o) {
564
+ return typeof t == "string" ? Ze(t) : T(t) ? `{{ ${_(t, !1, !0, e)} }}` : Array.isArray(t) ? q(t, s, e, n, o) : "";
555
565
  }
556
- function Pe(t, e, n) {
566
+ function Xe(t, e, s) {
557
567
  if (!t) return e;
558
- const s = typeof t == "string" ? { name: t, params: [], scope: "" } : { params: [], scope: "", ...t };
559
- return `<template ${`#${s.name}="${s.scope ? s.scope : s.params?.length > 0 ? `{${s.params?.join(",")}}` : `scope_${n}`}"`}>
568
+ const n = typeof t == "string" ? { name: t, params: [], scope: "" } : { params: [], scope: "", ...t };
569
+ return `<template ${`#${n.name}="${n.scope ? n.scope : n.params?.length > 0 ? `{${n.params?.join(",")}}` : `scope_${s}`}"`}>
560
570
  ${e}
561
571
  </template>`;
562
572
  }
563
- function _e(t, e = [], n = [], s = {}, i = "web") {
564
- const r = [
573
+ function Ye(t, e = [], s = [], n = {}, o = "web", r = /* @__PURE__ */ new Set()) {
574
+ const c = [
565
575
  "@dcloudio/uni-h5",
566
576
  "uni-h5",
567
577
  "@dcloudio/uni-ui",
568
578
  "uni-ui"
569
- ], o = {
579
+ ], a = {
570
580
  vue: ["defineComponent", "reactive"]
571
- }, a = [];
572
- for (const p of e) {
573
- const u = t.get(p.split(":")[0]);
574
- if (u && u.package) {
575
- const c = o[u.package] ?? (o[u.package] = []), y = u.parent || (u.alias || "").split(".")[0] || u.name;
576
- c.push(y), i === "uniapp" && r.includes(u.package) && a.push(y);
581
+ }, l = [];
582
+ for (const d of e) {
583
+ const i = t.get(d.split(":")[0]);
584
+ if (i && i.package) {
585
+ if (r.has(i.package)) continue;
586
+ const u = a[i.package] ?? (a[i.package] = []), f = i.parent || (i.alias || "").split(".")[0] || i.name;
587
+ u.push(f), o === "uniapp" && c.includes(i.package) && l.push(f);
577
588
  }
578
589
  }
579
- for (const [p, u] of Object.entries(s))
580
- (o[p] ?? (o[p] = [])).push(...Array.from(u)), i === "uniapp" && r.includes(p) && a.push(...Array.from(u));
590
+ for (const [d, i] of Object.entries(n))
591
+ (a[d] ?? (a[d] = [])).push(...Array.from(i)), o === "uniapp" && c.includes(d) && l.push(...Array.from(i));
581
592
  return {
582
- imports: Object.entries(o).filter(([p, u]) => i === "uniapp" ? !r.includes(p) && !!u.length : !!u.length).map(([p, u]) => `import { ${C(u).join(
593
+ imports: Object.entries(a).filter(([d, i]) => o === "uniapp" ? !c.includes(d) && !!i.length : !!i.length).map(([d, i]) => `import { ${B(i).join(
583
594
  ","
584
- )}} from '${p}';`).concat(n),
585
- uniComponents: a
595
+ )}} from '${d}';`).concat(s),
596
+ uniComponents: l
586
597
  };
587
598
  }
588
- function Ie(t = {}) {
599
+ function ie(t = {}) {
589
600
  const e = [];
590
- for (const [n, s] of Object.entries(t))
601
+ for (const [s, n] of Object.entries(t))
591
602
  e.push(`
592
- ${n} {
593
- ${ae(s)}
603
+ ${s} {
604
+ ${Pe(n)}
594
605
  }
595
606
  `);
596
607
  return e.join(`
597
608
  `);
598
609
  }
599
- function Ne(t = {}) {
610
+ function le(t = {}) {
600
611
  const e = [];
601
- return Object.entries(t).forEach(([n, s]) => {
612
+ return Object.entries(t).forEach(([s, n]) => {
602
613
  e.push(
603
- `const ${n} = provider.defineUrlSchemaComponent('${s.url}');`
614
+ `const ${s} = provider.defineUrlSchemaComponent('${n.url}');`
604
615
  );
605
616
  }), e;
606
617
  }
607
- function Ae(t = {}) {
618
+ function ue(t = {}) {
608
619
  const e = [];
609
- return Object.entries(t).forEach(([n, s]) => {
620
+ return Object.entries(t).forEach(([s, n]) => {
610
621
  e.push(
611
- `const ${n} = provider.definePluginComponent(${JSON.stringify(s)});`
622
+ `const ${s} = provider.definePluginComponent(${JSON.stringify(n)});`
612
623
  );
613
624
  }), e;
614
625
  }
615
- function Be(t, e, n = "web") {
616
- const { dsl: s } = t, i = Object.keys(s.computed || {}), r = N(s.lifeCycles, i), o = N(s.computed, i), a = de(s.watch, i), h = ge(s.dataSources), { methods: p, nodes: u, components: c, importBlocks: y, directives: l } = Z(
617
- s.nodes || [],
626
+ function Ke(t, e, s = "web") {
627
+ const { dsl: n } = t, o = Object.keys(n.computed || {}), r = U(n.lifeCycles, o), c = U(n.computed, o), a = Me(n.watch, o), l = Re(n.dataSources), { methods: p, nodes: d, components: i, importBlocks: u, directives: f } = q(
628
+ n.nodes || [],
618
629
  e,
619
- i,
630
+ o,
620
631
  t.context
621
- ), f = [...o, ...a.computed], d = N(
632
+ ), v = [...c, ...a.computed], b = U(
622
633
  {
623
634
  ...p,
624
- ...s.methods || {}
635
+ ...n.methods || {}
625
636
  },
626
- i
627
- ), v = y.map((k) => `import ${k.name} from './${k.id}.vue';`);
628
- let { imports: $, uniComponents: g } = _e(
637
+ o
638
+ ), k = u.map((w) => `import ${w.name} from './${w.id}.vue';`);
639
+ let { imports: g, uniComponents: m } = Ye(
629
640
  e,
630
- c,
631
- v,
641
+ i,
642
+ k,
632
643
  t.imports,
633
- n
644
+ s,
645
+ t.easycomPackages
634
646
  );
635
- const O = Object.keys({
647
+ const h = Object.keys({
636
648
  ...t.urlSchemas,
637
649
  ...t.blockPlugins
638
- }), E = Ne(t.urlSchemas), P = Ae(t.blockPlugins);
650
+ }), y = le(t.urlSchemas), $ = ue(t.blockPlugins);
639
651
  return {
640
- id: s.id,
641
- version: s.__VERSION__,
642
- name: s.name,
643
- state: pe(s.state).join(","),
644
- inject: fe(s.inject).join(","),
645
- props: me(s.props).join(","),
646
- emits: he(s.emits).join(","),
647
- expose: s.expose && s.expose.length ? JSON.stringify(s.expose || []) : "",
652
+ id: n.id,
653
+ version: n.__VERSION__,
654
+ name: n.name,
655
+ state: Be(n.state).join(","),
656
+ inject: Te(n.inject).join(","),
657
+ props: ne(n.props).join(","),
658
+ emits: re(n.emits).join(","),
659
+ expose: n.expose && n.expose.length ? JSON.stringify(n.expose || []) : "",
648
660
  watch: a.watches.join(","),
649
661
  lifeCycles: r.join(","),
650
- computed: f.join(","),
651
- methods: [...h, ...d].join(","),
662
+ computed: v.join(","),
663
+ methods: [...l, ...b].join(","),
652
664
  imports: `
653
- ` + $.join(`
665
+ ` + g.join(`
654
666
  `),
655
- components: le(c, g).join(","),
656
- directives: l.join(","),
667
+ components: Ee(i, m).join(","),
668
+ directives: f.join(","),
657
669
  returns: t.members.join(","),
658
- template: u.join(`
670
+ template: d.join(`
671
+ `),
672
+ css: n.css || "",
673
+ style: ie(t.style),
674
+ urlSchemas: y.join(`
675
+ `),
676
+ blockPlugins: $.join(`
677
+ `),
678
+ asyncComponents: h.join(","),
679
+ uniComponents: m,
680
+ renderer: s === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer"
681
+ };
682
+ }
683
+ const E = {
684
+ state: {
685
+ composable: null,
686
+ from: "self",
687
+ declare: null,
688
+ replace: "__state"
689
+ },
690
+ $uni: {
691
+ composable: null,
692
+ from: "self",
693
+ declare: null,
694
+ replace: "uni"
695
+ },
696
+ $getApp: {
697
+ composable: null,
698
+ from: "self",
699
+ declare: null,
700
+ replace: "getApp"
701
+ },
702
+ // ---- Vue 原生 ----
703
+ $emit: {
704
+ composable: null,
705
+ from: "vue",
706
+ declare: null,
707
+ replace: "__emit"
708
+ },
709
+ $props: {
710
+ composable: null,
711
+ from: "vue",
712
+ declare: null,
713
+ replace: "__props"
714
+ },
715
+ $attrs: {
716
+ composable: "useAttrs",
717
+ from: "vue",
718
+ declare: "const __attrs = useAttrs();",
719
+ replace: "__attrs"
720
+ },
721
+ $slots: {
722
+ composable: "useSlots",
723
+ from: "vue",
724
+ declare: "const __slots = useSlots();",
725
+ replace: "__slots"
726
+ },
727
+ $nextTick: {
728
+ composable: "nextTick",
729
+ from: "vue",
730
+ declare: null,
731
+ replace: "nextTick"
732
+ },
733
+ $watch: {
734
+ composable: "watch",
735
+ from: "vue",
736
+ declare: null,
737
+ replace: "watch"
738
+ },
739
+ $refs: {
740
+ composable: "getCurrentInstance",
741
+ from: "vue",
742
+ declare: "const __instance = getCurrentInstance();",
743
+ replace: "__instance.proxy.$refs"
744
+ },
745
+ $el: {
746
+ composable: "getCurrentInstance",
747
+ from: "vue",
748
+ declare: "const __instance = getCurrentInstance();",
749
+ replace: "__instance.proxy.$el"
750
+ },
751
+ $root: {
752
+ composable: "getCurrentInstance",
753
+ from: "vue",
754
+ declare: "const __instance = getCurrentInstance();",
755
+ replace: "__instance.proxy.$root"
756
+ },
757
+ $parent: {
758
+ composable: "getCurrentInstance",
759
+ from: "vue",
760
+ declare: "const __instance = getCurrentInstance();",
761
+ replace: "__instance.proxy.$parent"
762
+ },
763
+ $options: {
764
+ composable: "getCurrentInstance",
765
+ from: "vue",
766
+ declare: "const __instance = getCurrentInstance();",
767
+ replace: "__instance.proxy.$options"
768
+ },
769
+ $forceUpdate: {
770
+ composable: "getCurrentInstance",
771
+ from: "vue",
772
+ declare: "const __instance = getCurrentInstance();",
773
+ replace: "__instance.proxy.$forceUpdate"
774
+ },
775
+ // ---- vue-router ----
776
+ $router: {
777
+ composable: "useRouter",
778
+ from: "vue-router",
779
+ declare: "const __router = useRouter();",
780
+ replace: "__router"
781
+ },
782
+ $route: {
783
+ composable: "useRoute",
784
+ from: "vue-router",
785
+ declare: "const __route = useRoute();",
786
+ replace: "__route"
787
+ },
788
+ // ---- vue-i18n ----
789
+ $i18n: {
790
+ composable: "useI18n",
791
+ from: "vue-i18n",
792
+ declare: "const __i18n = useI18n();",
793
+ replace: "__i18n"
794
+ },
795
+ $t: {
796
+ composable: "useI18n",
797
+ from: "vue-i18n",
798
+ declare: "const __i18n = useI18n();",
799
+ replace: "__i18n.t"
800
+ },
801
+ $n: {
802
+ composable: "useI18n",
803
+ from: "vue-i18n",
804
+ declare: "const __i18n = useI18n();",
805
+ replace: "__i18n.n"
806
+ },
807
+ $d: {
808
+ composable: "useI18n",
809
+ from: "vue-i18n",
810
+ declare: "const __i18n = useI18n();",
811
+ replace: "__i18n.d"
812
+ },
813
+ $rt: {
814
+ composable: "useI18n",
815
+ from: "vue-i18n",
816
+ declare: "const __i18n = useI18n();",
817
+ replace: "__i18n.rt"
818
+ },
819
+ $te: {
820
+ composable: "useI18n",
821
+ from: "vue-i18n",
822
+ declare: "const __i18n = useI18n();",
823
+ replace: "__i18n.te"
824
+ },
825
+ $tm: {
826
+ composable: "useI18n",
827
+ from: "vue-i18n",
828
+ declare: "const __i18n = useI18n();",
829
+ replace: "__i18n.tm"
830
+ },
831
+ // ---- @vtj/renderer ----
832
+ // 注:from 使用特殊标记 '__renderer__',运行时会与 useProvider 合并到同一条 import 语句
833
+ $provider: {
834
+ composable: "useStore",
835
+ from: "__renderer__",
836
+ declare: null,
837
+ replace: "__provider"
838
+ },
839
+ $store: {
840
+ composable: "useStore",
841
+ from: "__renderer__",
842
+ declare: "const __store = useStore();",
843
+ replace: "__store"
844
+ },
845
+ $pinia: {
846
+ composable: "usePinia",
847
+ from: "__renderer__",
848
+ declare: "const __pinia = usePinia();",
849
+ replace: "__pinia"
850
+ },
851
+ $request: {
852
+ composable: "useRequest",
853
+ from: "__renderer__",
854
+ declare: "const __request = useRequest();",
855
+ replace: "__request"
856
+ },
857
+ $libs: {
858
+ composable: "useLibs",
859
+ from: "__renderer__",
860
+ declare: "const __libs = useLibs();",
861
+ replace: "__libs"
862
+ },
863
+ $access: {
864
+ composable: "useAccess",
865
+ from: "__renderer__",
866
+ declare: "const __access = useAccess();",
867
+ replace: "__access"
868
+ },
869
+ $apis: {
870
+ composable: "useApis",
871
+ from: "__renderer__",
872
+ declare: "const __apis = useApis();",
873
+ replace: "__apis"
874
+ }
875
+ }, pe = {
876
+ "element-plus": {
877
+ $loading: {
878
+ composable: "ElLoading",
879
+ from: "element-plus",
880
+ declare: null,
881
+ replace: "ElLoading.service"
882
+ },
883
+ $message: {
884
+ composable: "ElMessage",
885
+ from: "element-plus",
886
+ declare: null,
887
+ replace: "ElMessage"
888
+ },
889
+ $notify: {
890
+ composable: "ElNotification",
891
+ from: "element-plus",
892
+ declare: null,
893
+ replace: "ElNotification"
894
+ },
895
+ $messageBox: {
896
+ composable: "ElMessageBox",
897
+ from: "element-plus",
898
+ declare: null,
899
+ replace: "ElMessageBox"
900
+ },
901
+ $msgbox: {
902
+ composable: "ElMessageBox",
903
+ from: "element-plus",
904
+ declare: null,
905
+ replace: "ElMessageBox"
906
+ },
907
+ $confirm: {
908
+ composable: "ElMessageBox",
909
+ from: "element-plus",
910
+ declare: null,
911
+ replace: "ElMessageBox.confirm"
912
+ },
913
+ $prompt: {
914
+ composable: "ElMessageBox",
915
+ from: "element-plus",
916
+ declare: null,
917
+ replace: "ElMessageBox.prompt"
918
+ }
919
+ },
920
+ "ant-design-vue": {
921
+ $confirm: {
922
+ composable: "Modal",
923
+ from: "ant-design-vue",
924
+ declare: null,
925
+ replace: "Modal.confirm"
926
+ },
927
+ $message: {
928
+ composable: "message",
929
+ from: "ant-design-vue",
930
+ declare: null,
931
+ replace: "message"
932
+ },
933
+ $notification: {
934
+ composable: "notification",
935
+ from: "ant-design-vue",
936
+ declare: null,
937
+ replace: "notification"
938
+ },
939
+ $info: {
940
+ composable: "message",
941
+ from: "ant-design-vue",
942
+ declare: null,
943
+ replace: "message.info"
944
+ },
945
+ $success: {
946
+ composable: "message",
947
+ from: "ant-design-vue",
948
+ declare: null,
949
+ replace: "message.success"
950
+ },
951
+ $warning: {
952
+ composable: "message",
953
+ from: "ant-design-vue",
954
+ declare: null,
955
+ replace: "message.warning"
956
+ },
957
+ $error: {
958
+ composable: "message",
959
+ from: "ant-design-vue",
960
+ declare: null,
961
+ replace: "message.error"
962
+ }
963
+ }
964
+ }, et = Object.keys(pe);
965
+ function tt(t) {
966
+ for (const [, e] of t)
967
+ if (et.includes(e.package))
968
+ return e.package;
969
+ return null;
970
+ }
971
+ function st(t) {
972
+ const e = t ? pe[t] ?? {} : {};
973
+ return { ...E, ...e };
974
+ }
975
+ function nt(t, e = E) {
976
+ const s = /* @__PURE__ */ new Set(), n = /this\.\$(\w+)\b/g, o = (r) => {
977
+ if (r && typeof r == "object") {
978
+ if (Array.isArray(r)) {
979
+ for (const c of r) o(c);
980
+ return;
981
+ }
982
+ if (S(r) && r.value) {
983
+ let c;
984
+ for (n.lastIndex = 0; (c = n.exec(r.value)) !== null; ) {
985
+ const a = "$" + c[1];
986
+ a in e && s.add(a);
987
+ }
988
+ return;
989
+ }
990
+ for (const c of Object.values(r))
991
+ o(c);
992
+ }
993
+ };
994
+ return o(t.refs), o(t.reactives), o(t.state), o(t.computed), o(t.methods), o(t.watch), o(t.lifeCycles), o(t.inject), o(t.composables), o(t.provide), o(t.dataSources), o(t.setup), o(t.nodes), s;
995
+ }
996
+ function rt(t, e = E) {
997
+ const s = [];
998
+ for (const n of t) {
999
+ const o = e[n];
1000
+ o && o.declare && !s.includes(o.declare) && s.push(o.declare);
1001
+ }
1002
+ return s;
1003
+ }
1004
+ function ot(t, e = E) {
1005
+ const s = {};
1006
+ for (const n of t) {
1007
+ const o = e[n];
1008
+ if (o && o.composable) {
1009
+ const r = s[o.from] ?? (s[o.from] = []);
1010
+ r.includes(o.composable) || r.push(o.composable);
1011
+ }
1012
+ }
1013
+ return s;
1014
+ }
1015
+ function ct(t, e = E) {
1016
+ const s = new Set(Object.keys(t.refs ?? {})), n = new Set(Object.keys(t.reactives ?? {})), r = Object.keys(t.state ?? {}).length > 0;
1017
+ r && n.add("__state");
1018
+ const c = new Set(Object.keys(t.computed ?? {})), a = new Set(Object.keys(t.methods ?? {})), l = /* @__PURE__ */ new Set();
1019
+ for (const u of t.props ?? [])
1020
+ we(u) ? l.add(u) : l.add(u.name);
1021
+ const p = /* @__PURE__ */ new Set();
1022
+ for (const u of t.composables ?? [])
1023
+ if (u.destructure && u.destructure.length > 0)
1024
+ for (const f of u.destructure) p.add(f);
1025
+ else u.name && p.add(u.name);
1026
+ const d = /* @__PURE__ */ new Set();
1027
+ for (const u of t.inject ?? [])
1028
+ u.name && d.add(u.name);
1029
+ const i = /* @__PURE__ */ new Set();
1030
+ for (const [, u] of Object.entries(t.dataSources ?? {}))
1031
+ u.name && i.add(u.name);
1032
+ return {
1033
+ refs: s,
1034
+ reactives: n,
1035
+ computed: c,
1036
+ methods: a,
1037
+ props: l,
1038
+ composables: p,
1039
+ injects: d,
1040
+ dataSources: i,
1041
+ hasState: r,
1042
+ effectiveApiMap: e
1043
+ };
1044
+ }
1045
+ function j(t, e, s = "script") {
1046
+ if (!t) return t;
1047
+ let n = t;
1048
+ for (const [o, r] of Object.entries(e.effectiveApiMap)) {
1049
+ const c = o.replace(/\$/g, "\\$"), a = new RegExp(`this\\.${c}\\b`, "g");
1050
+ n = n.replace(a, r.replace);
1051
+ }
1052
+ return n = n.replace(
1053
+ /this\.([A-Za-z_$][\w$]*)\.value\b/g,
1054
+ (o, r) => e.refs.has(r) || e.computed.has(r) ? s === "script" ? `${r}.value` : r : o
1055
+ ), n = n.replace(/this\.([A-Za-z_$][\w$]*)/g, (o, 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 : o), n;
1056
+ }
1057
+ function P(t) {
1058
+ let e = t.trim().replace(/;$/, "");
1059
+ return /^\((\(|async|function)/.test(e) && (e = e.substring(1, e.length - 1).trim()), e;
1060
+ }
1061
+ function at(t = {}, e) {
1062
+ return Object.entries(t).map(([s, n]) => {
1063
+ let o;
1064
+ return S(n) ? o = j(n.value || "undefined", e, "script") : o = JSON.stringify(n), `const ${s} = ref(${o});`;
1065
+ });
1066
+ }
1067
+ function it(t = {}, e) {
1068
+ return Object.entries(t).map(([s, n]) => {
1069
+ let o;
1070
+ return S(n) ? o = j(n.value || "{}", e, "script") : o = JSON.stringify(n ?? {}), `const ${s} = reactive(${o});`;
1071
+ });
1072
+ }
1073
+ function lt(t = {}, e) {
1074
+ const s = Object.entries(t);
1075
+ return s.length === 0 ? "" : `const __state = reactive({ ${s.map(([o, r]) => {
1076
+ let c;
1077
+ return S(r) ? c = j(r.value || "undefined", e, "script") : c = JSON.stringify(r), `${o}: ${c}`;
1078
+ }).join(", ")} });`;
1079
+ }
1080
+ function ut(t = [], e) {
1081
+ const s = [], n = {}, o = /* @__PURE__ */ new Set();
1082
+ for (const r of t) {
1083
+ if (!r || !r.composable) continue;
1084
+ let c = "";
1085
+ if (S(r.composable) ? c = r.composable.value || "" : typeof r.composable == "string" && (c = r.composable), !c || c === "useProvider") continue;
1086
+ if (r.name) {
1087
+ if (o.has(r.name)) continue;
1088
+ o.add(r.name);
1089
+ }
1090
+ const l = (r.args ?? []).map((p) => S(p) ? j(p.value || "", e, "script") : JSON.stringify(p)).join(", ");
1091
+ r.destructure && r.destructure.length > 0 ? s.push(
1092
+ `const { ${r.destructure.join(", ")} } = ${c}(${l});`
1093
+ ) : r.name ? s.push(`const ${r.name} = ${c}(${l});`) : s.push(`${c}(${l});`);
1094
+ }
1095
+ return { statements: s, imports: n };
1096
+ }
1097
+ function pt(t = [], e) {
1098
+ return t.map((s) => {
1099
+ const n = S(s.from) ? j(
1100
+ s.from.value || `'${s.name}'`,
1101
+ e,
1102
+ "script"
1103
+ ) : `'${s.from || s.name}'`;
1104
+ let o = "undefined";
1105
+ return s.default !== void 0 && s.default !== null && (S(s.default) ? o = j(
1106
+ s.default.value || "undefined",
1107
+ e,
1108
+ "script"
1109
+ ) : o = JSON.stringify(s.default)), `const ${s.name} = inject(${n}, ${o});`;
1110
+ });
1111
+ }
1112
+ function ft(t = {}, e) {
1113
+ return Object.entries(t).map(([s, n]) => {
1114
+ if (!n || !n.value) return null;
1115
+ const o = j(n.value, e, "script"), r = P(o);
1116
+ return `const ${s} = computed(${r});`;
1117
+ }).filter((s) => !!s);
1118
+ }
1119
+ function mt(t = {}, e) {
1120
+ return Object.entries(t).map(([s, n]) => {
1121
+ if (!n || !n.value) return null;
1122
+ const o = j(n.value, e, "script"), r = P(o);
1123
+ return `const ${s} = ${r};`;
1124
+ }).filter((s) => !!s);
1125
+ }
1126
+ function dt(t = {}, e) {
1127
+ return Object.values(t).map((s) => {
1128
+ if (!s || !s.name) return null;
1129
+ if (s.type === "mock") {
1130
+ const n = s.mockTemplate && s.mockTemplate.value ? s.mockTemplate.value : "(params) => ({})", o = e ? j(n, e, "script") : n;
1131
+ return `const ${s.name} = async (...args) => {
1132
+ const mock = __provider.createMock(${o});
1133
+ return await mock.apply(null, args);
1134
+ };`;
1135
+ } else {
1136
+ const n = s.transform && s.transform.value ? s.transform.value : "(res) => res", o = e ? j(n, e, "script") : n;
1137
+ return `const ${s.name} = async (...args) => {
1138
+ return await __provider.apis['${s.ref}'].apply(null, args).then(${o});
1139
+ };`;
1140
+ }
1141
+ }).filter((s) => !!s);
1142
+ }
1143
+ function ht(t = [], e) {
1144
+ return t.map((s) => {
1145
+ if (!s || !s.handler || !s.handler.value) return null;
1146
+ const n = s.source && s.source.value ? j(s.source.value, e, "script") : "() => null", o = P(n), r = j(
1147
+ s.handler.value,
1148
+ e,
1149
+ "script"
1150
+ ), c = P(r), a = [];
1151
+ s.deep && a.push("deep: true"), s.immediate && a.push("immediate: true"), s.flush && a.push(`flush: '${s.flush}'`);
1152
+ const l = a.length > 0 ? `, { ${a.join(", ")} }` : "";
1153
+ return `watch(${o}, ${c}${l});`;
1154
+ }).filter((s) => !!s);
1155
+ }
1156
+ function gt(t = {}, e) {
1157
+ return Object.entries(t).map(([s, n]) => {
1158
+ let o;
1159
+ if (R(n)) {
1160
+ const r = j(
1161
+ n.value || "",
1162
+ e,
1163
+ "script"
1164
+ );
1165
+ o = P(r);
1166
+ } else S(n) ? o = j(n.value || "undefined", e, "script") : o = JSON.stringify(n);
1167
+ return `provide('${s}', ${o});`;
1168
+ });
1169
+ }
1170
+ function fe(t) {
1171
+ let e = t.trim().replace(/;$/, "");
1172
+ /^\((\(|async|function)/.test(e) && (e = e.substring(1, e.length - 1).trim());
1173
+ const s = e.match(/^(?:async\s+)?\([^)]*\)\s*=>\s*([\s\S]+)$/);
1174
+ if (s) {
1175
+ let o = s[1].trim();
1176
+ return o.startsWith("{") && o.endsWith("}") ? o = o.slice(1, -1).trim() : o = o.replace(/;$/, "") + ";", o;
1177
+ }
1178
+ const n = e.match(
1179
+ /^(?:async\s+)?function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*)\}$/
1180
+ );
1181
+ return n ? n[1].trim() : e;
1182
+ }
1183
+ function vt(t, e) {
1184
+ if (!t || !t.value) return "";
1185
+ const s = j(t.value, e, "script");
1186
+ return fe(s);
1187
+ }
1188
+ function $t(t = {}, e) {
1189
+ const s = [];
1190
+ for (const n of ["beforeCreate", "created"]) {
1191
+ const o = t[n];
1192
+ if (o && o.value) {
1193
+ const r = j(o.value, e, "script"), c = fe(r);
1194
+ c && s.push(`// ${n}
1195
+ ${c}`);
1196
+ }
1197
+ }
1198
+ return s.join(`
1199
+ `);
1200
+ }
1201
+ const bt = {
1202
+ beforeMount: "onBeforeMount",
1203
+ mounted: "onMounted",
1204
+ beforeUpdate: "onBeforeUpdate",
1205
+ updated: "onUpdated",
1206
+ beforeUnmount: "onBeforeUnmount",
1207
+ unmounted: "onUnmounted",
1208
+ errorCaptured: "onErrorCaptured",
1209
+ renderTracked: "onRenderTracked",
1210
+ renderTriggered: "onRenderTriggered",
1211
+ activated: "onActivated",
1212
+ deactivated: "onDeactivated"
1213
+ }, _t = /* @__PURE__ */ new Set([
1214
+ "onBeforeMount",
1215
+ "onMounted",
1216
+ "onBeforeUpdate",
1217
+ "onUpdated",
1218
+ "onBeforeUnmount",
1219
+ "onUnmounted",
1220
+ "onErrorCaptured",
1221
+ "onRenderTracked",
1222
+ "onRenderTriggered",
1223
+ "onActivated",
1224
+ "onDeactivated"
1225
+ ]), yt = /* @__PURE__ */ new Set([
1226
+ "onLoad",
1227
+ "onShow",
1228
+ "onReady",
1229
+ "onHide",
1230
+ "onUnload",
1231
+ "onResize",
1232
+ "onPullDownRefresh",
1233
+ "onReachBottom",
1234
+ "onTabItemTap",
1235
+ "onShareAppMessage",
1236
+ "onPageScroll",
1237
+ "onNavigationBarButtonTap",
1238
+ "onBackPress",
1239
+ "onNavigationBarSearchInputChanged",
1240
+ "onNavigationBarSearchInputConfirmed",
1241
+ "onNavigationBarSearchInputClicked",
1242
+ "onShareTimeline",
1243
+ "onAddToFavorites"
1244
+ ]);
1245
+ function St(t = {}, e) {
1246
+ const s = [], n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
1247
+ for (const [r, c] of Object.entries(t)) {
1248
+ if (!c || !c.value || r === "created" || r === "beforeCreate") continue;
1249
+ const a = bt[r] || r;
1250
+ if (_t.has(a)) {
1251
+ const l = j(c.value, e, "script"), p = P(l);
1252
+ s.push(`${a}(${p});`), n.add(a);
1253
+ } else if (yt.has(a)) {
1254
+ const l = j(c.value, e, "script"), p = P(l);
1255
+ s.push(`${a}(${p});`), o.add(a);
1256
+ }
1257
+ }
1258
+ return { statements: s, usedHooks: n, usedUniHooks: o };
1259
+ }
1260
+ function jt(t) {
1261
+ const {
1262
+ componentMap: e,
1263
+ components: s,
1264
+ importBlocks: n,
1265
+ collectImports: o,
1266
+ platform: r,
1267
+ vueImports: c,
1268
+ composableImports: a,
1269
+ globalApiImports: l,
1270
+ uniHookImports: p,
1271
+ easycomPackages: d
1272
+ } = t, i = [
1273
+ "@dcloudio/uni-h5",
1274
+ "uni-h5",
1275
+ "@dcloudio/uni-ui",
1276
+ "uni-ui"
1277
+ ], u = {
1278
+ vue: [...c]
1279
+ }, f = [], v = [], b = {};
1280
+ for (const g of s) {
1281
+ const m = g.split(":")[0], h = e.get(m);
1282
+ if (!h || !h.package || h.parent || d.has(h.package)) continue;
1283
+ const y = u[h.package] ?? (u[h.package] = []), $ = (h.alias || "").split(".")[0] || h.name, w = m, I = $ !== w ? `${$} as ${w}` : $;
1284
+ y.push(I), b[$] = w, r === "uniapp" && i.includes(h.package) && f.push($);
1285
+ }
1286
+ for (const g of s) {
1287
+ const m = g.split(":")[0], h = e.get(m);
1288
+ if (!h || !h.package || !h.parent || d.has(h.package)) continue;
1289
+ const y = h.parent, $ = b[y] ?? y, w = h.alias || "";
1290
+ v.push(
1291
+ `const ${m} = ${$}.${w};`
1292
+ ), b[y] || ((u[h.package] ?? (u[h.package] = [])).push(y), b[y] = y);
1293
+ }
1294
+ for (const [g, m] of Object.entries(o))
1295
+ (u[g] ?? (u[g] = [])).push(...Array.from(m)), r === "uniapp" && i.includes(g) && f.push(...Array.from(m));
1296
+ for (const [g, m] of Object.entries(a))
1297
+ (u[g] ?? (u[g] = [])).push(...m);
1298
+ for (const [g, m] of Object.entries(l))
1299
+ (u[g] ?? (u[g] = [])).push(...m);
1300
+ return r === "uniapp" && p.length > 0 && (u["@dcloudio/uni-app"] ?? (u["@dcloudio/uni-app"] = [])).push(...p), { imports: Object.entries(u).filter(([g, m]) => r === "uniapp" ? !i.includes(g) && !!m.length : !!m.length).map(([g, m]) => `import { ${B(m).join(
1301
+ ","
1302
+ )}} from '${g}';`).concat(n), uniComponents: f, componentDeclarations: v };
1303
+ }
1304
+ function kt(t, e = E, s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set()) {
1305
+ const o = Object.entries(e), r = (c) => {
1306
+ if (c == null || typeof c != "object") return c;
1307
+ if (Array.isArray(c))
1308
+ return c.map(r);
1309
+ if (S(c) && typeof c.value == "string") {
1310
+ let l = c.value;
1311
+ for (const [p, d] of o) {
1312
+ const i = p.replace(/\$/g, "\\$"), u = new RegExp(`this\\.${i}\\b`, "g");
1313
+ l = l.replace(u, d.replace);
1314
+ }
1315
+ return l = l.replace(/this\.([A-Za-z_$][\w$]*)\.value\b/g, (p, d) => s.has(d) || n.has(d) ? d : p), { ...c, value: l };
1316
+ }
1317
+ const a = {};
1318
+ for (const [l, p] of Object.entries(c))
1319
+ a[l] = r(p);
1320
+ return a;
1321
+ };
1322
+ return t.map(r);
1323
+ }
1324
+ function wt(t, e, s = [], n = {}, o, r = E, c = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set()) {
1325
+ const l = kt(
1326
+ t,
1327
+ r,
1328
+ c,
1329
+ a
1330
+ );
1331
+ return q(
1332
+ l,
1333
+ e,
1334
+ s,
1335
+ n,
1336
+ o
1337
+ );
1338
+ }
1339
+ function It(t, e, s = "web") {
1340
+ const { dsl: n } = t, o = tt(e), r = st(o), c = ct(n, r), a = nt(n, r), l = rt(a, r), p = ot(a, r), d = p.__renderer__ || [];
1341
+ delete p.__renderer__;
1342
+ const i = wt(
1343
+ n.nodes || [],
1344
+ e,
1345
+ Object.keys(n.computed || {}),
1346
+ t.context,
1347
+ void 0,
1348
+ r,
1349
+ c.refs,
1350
+ c.computed
1351
+ ), u = i.importBlocks.map(
1352
+ (O) => `import ${O.name} from './${O.id}.vue';`
1353
+ ), f = at(n.refs || {}, c), v = it(n.reactives || {}, c), b = lt(n.state || {}, c), k = ft(n.computed || {}, c), g = {
1354
+ ...i.methods || {},
1355
+ ...n.methods || {}
1356
+ }, m = mt(g, c), h = dt(n.dataSources || {}, c), y = ht(n.watch || [], c), $ = pt(n.inject || [], c), w = gt(n.provide || {}, c), I = ut(
1357
+ n.composables || [],
1358
+ c
1359
+ ), C = /* @__PURE__ */ new Set();
1360
+ for (const O of n.composables || [])
1361
+ if (O.destructure && O.destructure.length > 0)
1362
+ for (const D of O.destructure) C.add(D);
1363
+ else O.name && C.add(O.name);
1364
+ const N = l.filter((O) => {
1365
+ const D = O.match(/^const\s+(\w+)\s*=/);
1366
+ return !(D && C.has(D[1]));
1367
+ }), L = St(n.lifeCycles || {}, c), me = $t(
1368
+ n.lifeCycles || {},
1369
+ c
1370
+ ), de = vt(n.setup, c), x = /* @__PURE__ */ new Set();
1371
+ f.length > 0 && x.add("ref"), (v.length > 0 || b) && x.add("reactive"), k.length > 0 && x.add("computed"), y.length > 0 && x.add("watch"), $.length > 0 && x.add("inject"), w.length > 0 && x.add("provide");
1372
+ for (const O of L.usedHooks) x.add(O);
1373
+ const he = s === "uniapp" ? Array.from(L.usedUniHooks) : [], { imports: ge, uniComponents: ve, componentDeclarations: $e } = jt({
1374
+ componentMap: e,
1375
+ components: i.components,
1376
+ importBlocks: u,
1377
+ collectImports: t.imports,
1378
+ platform: s,
1379
+ vueImports: Array.from(x),
1380
+ composableImports: I.imports,
1381
+ globalApiImports: p,
1382
+ uniHookImports: he,
1383
+ easycomPackages: t.easycomPackages
1384
+ }), be = le(t.urlSchemas), _e = ue(t.blockPlugins);
1385
+ return {
1386
+ id: n.id,
1387
+ version: n.__VERSION__,
1388
+ name: n.name,
1389
+ imports: `
1390
+ ` + ge.join(`
1391
+ `),
1392
+ props: ne(n.props).join(","),
1393
+ emits: re(n.emits).join(","),
1394
+ needsProps: a.has("$props"),
1395
+ needsEmit: a.has("$emit"),
1396
+ expose: n.expose && n.expose.length ? `{ ${n.expose.join(", ")} }` : "",
1397
+ globalApiDeclares: N.join(`
1398
+ `),
1399
+ injects: $.join(`
1400
+ `),
1401
+ composables: I.statements.join(`
1402
+ `),
1403
+ state: b,
1404
+ refs: f.join(`
1405
+ `),
1406
+ reactives: v.join(`
1407
+ `),
1408
+ computed: k.join(`
1409
+ `),
1410
+ methods: m.join(`
659
1411
  `),
660
- css: s.css || "",
661
- style: Ie(t.style),
662
- urlSchemas: E.join(`
1412
+ dataSources: h.join(`
663
1413
  `),
664
- blockPlugins: P.join(`
1414
+ watch: y.join(`
665
1415
  `),
666
- asyncComponents: O.join(","),
667
- uniComponents: g,
668
- renderer: n === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer"
1416
+ provide: w.join(`
1417
+ `),
1418
+ createdStatements: me,
1419
+ setupStatements: de,
1420
+ lifeCycles: L.statements.join(`
1421
+ `),
1422
+ template: i.nodes.join(`
1423
+ `),
1424
+ css: n.css || "",
1425
+ style: ie(t.style),
1426
+ urlSchemas: be.join(`
1427
+ `),
1428
+ blockPlugins: _e.join(`
1429
+ `),
1430
+ uniComponents: ve,
1431
+ renderer: s === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer",
1432
+ rendererImports: ["useProvider", ...d].join(", "),
1433
+ componentDeclarations: $e.join(`
1434
+ `)
669
1435
  };
670
1436
  }
671
- const De = `
1437
+ const Ot = `
672
1438
  // @ts-nocheck
673
-
674
- <%= imports %>
675
1439
  import { useProvider } from '<%= renderer %>';
1440
+ <%= imports %>
676
1441
  export default defineComponent({
677
1442
  name: '<%= name %>',
678
1443
  <% if(inject) { %> inject: { <%= inject %>}, <% } %>
@@ -701,48 +1466,83 @@ export default defineComponent({
701
1466
  <% if(methods) { %> methods: { <%= methods %> }, <% } %>
702
1467
  <% if(watch) { %> watch: { <%= watch %> }, <% } %> <%= lifeCycles %>
703
1468
  });
704
- `.replace(/(\n|\r|\t)/g, ""), Fe = `
1469
+ `, Ct = `
705
1470
  <template>
706
1471
  <%= template %>
707
1472
  </template>
708
- <script lang="<%= scriptLang %>">
1473
+ <script lang="<%= scriptLang %>"<% if(scriptSetup) { %> setup<% } %>>
709
1474
  <%= script %>
710
1475
  <\/script>
711
1476
  <style lang="<%= styleLang %>" scoped>
712
1477
  <%= css %>
713
1478
  <%= style %>
714
1479
  </style>
715
- `, Te = J(De), We = J(Fe);
716
- async function Ue(t, e = /* @__PURE__ */ new Map(), n = [], s = "web", i) {
717
- const r = t, o = typeof r.dsl == "object" && arguments.length === 1 ? r : {
1480
+ `, xt = `// @ts-nocheck
1481
+ import { <%= rendererImports %> } from '<%= renderer %>';<%= imports %>
1482
+ <% if(componentDeclarations) { %><%= componentDeclarations %><% } %>
1483
+ <% if(props) { %>const __props = defineProps({ <%= props %> });<% } else if(needsProps) { %>const __props = defineProps();<% } %>
1484
+ <% if(emits) { %>const __emit = defineEmits([<%= emits %>]);<% } else if(needsEmit) { %>const __emit = defineEmits();<% } %>
1485
+ const __provider = useProvider({ id: '<%= id %>', version: '<%= version %>' });
1486
+ <%= urlSchemas %>
1487
+ <%= blockPlugins %>
1488
+ <%= globalApiDeclares %>
1489
+ <%= injects %>
1490
+ <%= composables %>
1491
+ <%= createdStatements %>
1492
+ <%= state %>
1493
+ <%= refs %>
1494
+ <%= reactives %>
1495
+ <%= computed %>
1496
+ <%= methods %>
1497
+ <%= setupStatements %>
1498
+ <%= dataSources %>
1499
+ <%= watch %>
1500
+ <%= provide %>
1501
+ <%= lifeCycles %>
1502
+ <% if(expose) { %>defineExpose(<%= expose %>);<% } %>
1503
+ `, At = W(Ot), Pt = W(xt), Et = W(Ct);
1504
+ async function Mt(t, e = /* @__PURE__ */ new Map(), s = [], n = "web", o) {
1505
+ const r = t, c = typeof r.dsl == "object" && arguments.length === 1 ? r : {
718
1506
  dsl: t,
719
1507
  componentMap: e,
720
- dependencies: n,
721
- platform: s,
722
- formatterDisabled: i
1508
+ dependencies: s,
1509
+ platform: n,
1510
+ formatterDisabled: o
723
1511
  }, {
724
1512
  dsl: a,
725
- componentMap: h = /* @__PURE__ */ new Map(),
1513
+ componentMap: l = /* @__PURE__ */ new Map(),
726
1514
  dependencies: p = [],
727
- platform: u = "web",
728
- formatterDisabled: c = !1,
729
- ts: y = !0,
730
- scss: l = !1
731
- } = o, f = new ue(ne(a), p), d = Be(f, h, u), v = Te(d), $ = We({
732
- template: d.template || `
1515
+ platform: d = "web",
1516
+ formatterDisabled: i = !1,
1517
+ ts: u = !0,
1518
+ scss: f = !1
1519
+ } = c, v = new Ne(Ie(a), p), b = a.apiMode === "composition";
1520
+ let k, g, m, h;
1521
+ if (b) {
1522
+ const $ = It(v, l, d);
1523
+ h = Pt($), k = $.template || `
733
1524
  <!--组件模版内容-->
734
- `,
735
- css: await W(d.css, c) || `
1525
+ `, g = $.css, m = $.style;
1526
+ } else {
1527
+ const $ = Ke(v, l, d);
1528
+ h = At($), k = $.template || `
1529
+ <!--组件模版内容-->
1530
+ `, g = $.css, m = $.style;
1531
+ }
1532
+ const y = Et({
1533
+ template: k,
1534
+ css: await G(g, i) || `
736
1535
  /* 组件样式内容 */
737
1536
  `,
738
- script: await oe(v, c),
739
- style: await W(d.style, c),
740
- scriptLang: y ? "ts" : "js",
741
- styleLang: l ? "scss" : "css"
1537
+ script: await xe(h, i),
1538
+ style: await G(m, i),
1539
+ scriptLang: u ? "ts" : "js",
1540
+ styleLang: f ? "scss" : "css",
1541
+ scriptSetup: b
742
1542
  });
743
- return await H($, c).catch((g) => (g.content = $, Promise.reject(g)));
1543
+ return await K(y, i).catch(($) => ($.content = y, Promise.reject($)));
744
1544
  }
745
- async function Me(t) {
1545
+ async function Rt(t) {
746
1546
  const e = `
747
1547
  <template>
748
1548
  <div>
@@ -755,13 +1555,18 @@ async function Me(t) {
755
1555
  <style scoped lang="scss">
756
1556
  </style>
757
1557
  `;
758
- return await H(e);
1558
+ return await K(e);
759
1559
  }
760
1560
  export {
761
- Je as VTJ_CODER_VERSION,
762
- Me as createEmptyPage,
763
- W as cssFormatter,
764
- Ue as generator,
765
- oe as tsFormatter,
766
- H as vueFormatter
1561
+ E as GLOBAL_API_MAP,
1562
+ pe as UI_GLOBAL_API_MAPS,
1563
+ et as UI_PACKAGES,
1564
+ Tt as VTJ_CODER_VERSION,
1565
+ st as buildEffectiveApiMap,
1566
+ Rt as createEmptyPage,
1567
+ G as cssFormatter,
1568
+ tt as detectUIPackage,
1569
+ Mt as generator,
1570
+ xe as tsFormatter,
1571
+ K as vueFormatter
767
1572
  };