@vtj/renderer 0.12.19 → 0.12.21

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,16 +1,16 @@
1
- import { Base as Te, BUILT_IN_COMPONENTS as De, ProjectModel as N, HistoryModel as pe } from "@vtj/core";
2
- import { isUrl as xe, url as b, dedupArray as Oe, isString as j, isFunction as K, logger as C, storage as L, cookie as q, toArray as re, unRSA as ie, delay as fe, createRequest as de, jsonp as he, merge as Ne, pathToRegexp as Be, pathToRegexpMatch as Ue, formDataToJson as Le, cloneDeep as oe, camelCase as E, upperFirst as qe, pick as Je, request as z, loadScript as ae, Storage as Ke, mapToObject as Z } from "@vtj/utils";
1
+ import { Base as xe, BUILT_IN_COMPONENTS as Oe, ProjectModel as N, HistoryModel as pe } from "@vtj/core";
2
+ import { isUrl as Ne, url as C, dedupArray as Be, isString as E, isFunction as V, logger as k, storage as J, cookie as K, toArray as re, unRSA as ie, delay as fe, createRequest as de, jsonp as he, merge as Ue, pathToRegexp as Le, pathToRegexpMatch as qe, formDataToJson as Je, cloneDeep as oe, camelCase as j, upperFirst as Ke, pick as ze, request as W, loadScript as ae, Storage as Ve, mapToObject as te } from "@vtj/utils";
3
3
  import * as B from "vue";
4
- import { inject as me, defineComponent as ve, h as V, ref as W, defineAsyncComponent as ce, watchEffect as ze } from "vue";
4
+ import { inject as me, defineComponent as ve, h as G, ref as Y, defineAsyncComponent as ce, watchEffect as We } from "vue";
5
5
  import { useRoute as ge } from "vue-router";
6
6
  /**!
7
7
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
8
8
  * @name @vtj/renderer
9
9
  * @author CHC chenhuachun1549@dingtalk.com
10
- * @version 0.12.19
10
+ * @version 0.12.21
11
11
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
12
12
  */
13
- const A = "0.12.19";
13
+ const A = "0.12.21";
14
14
  var y = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(y || {});
15
15
  const le = [
16
16
  "$el",
@@ -24,7 +24,7 @@ const le = [
24
24
  "$props",
25
25
  "$options",
26
26
  "$forceUpdate"
27
- ], Xt = [
27
+ ], Zt = [
28
28
  "beforeCreate",
29
29
  "created",
30
30
  "beforeMount",
@@ -38,7 +38,7 @@ const le = [
38
38
  "renderTriggered",
39
39
  "activated",
40
40
  "deactivated"
41
- ], Ve = [
41
+ ], Ge = [
42
42
  "vIf",
43
43
  "vElseIf",
44
44
  "vElse",
@@ -47,7 +47,7 @@ const le = [
47
47
  "vFor",
48
48
  "vBind",
49
49
  "vHtml"
50
- ], We = {
50
+ ], Ye = {
51
51
  String,
52
52
  Number,
53
53
  Boolean,
@@ -55,59 +55,66 @@ const le = [
55
55
  Object,
56
56
  Function,
57
57
  Date
58
- }, I = "VtjPage", O = "VtjHomepage", Ge = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot".split(
58
+ }, I = "VtjPage", O = "VtjHomepage", Qe = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot".split(
59
59
  ","
60
- ), Ye = "component,slot".split(",");
60
+ ), Xe = "component,slot".split(",");
61
61
  function D(n, e) {
62
- return n.map((t) => xe(t) || t.startsWith("/") ? t : `${e}${t}`);
62
+ return n.map((t) => Ne(t) || t.startsWith("/") ? t : `${e}${t}`);
63
63
  }
64
- function ee(n) {
64
+ function U(n) {
65
65
  return /\.css$/.test(n);
66
66
  }
67
- function te(n) {
67
+ function L(n) {
68
68
  return /\.js$/.test(n);
69
69
  }
70
- function Qe(n) {
70
+ function Ze(n) {
71
71
  return /\.json$/.test(n);
72
72
  }
73
- function Zt(n) {
73
+ function es(n) {
74
74
  return n.map(
75
- (e) => `<script src="${b.append(e, { v: A })}"><\/script>`
75
+ (e) => `<script src="${C.append(e, { v: A })}"><\/script>`
76
76
  ).join("");
77
77
  }
78
- function es(n = []) {
78
+ function ts(n = []) {
79
79
  return n.map(
80
- (e) => `<link rel="stylesheet" href="${b.append(e, { v: A })}" />`
80
+ (e) => `<link rel="stylesheet" href="${C.append(e, { v: A })}" />`
81
81
  ).join("");
82
82
  }
83
- function Xe(n, e = !1) {
83
+ function et(n, e = !1) {
84
84
  return e && n.endsWith(".prod.js") ? n.replace(".prod.js", ".js") : n;
85
85
  }
86
- function Ze(n, e, t = !1) {
86
+ function tt(n, e, t = !1) {
87
87
  const s = n.filter((m) => !!m.enabled), r = [], i = [], a = [], o = [], c = {}, l = {}, u = [], p = {};
88
88
  return s.forEach(
89
- ({ urls: m, assetsUrl: f, library: d, assetsLibrary: h, localeLibrary: _ }) => {
89
+ ({ urls: m, assetsUrl: d, library: f, assetsLibrary: h, localeLibrary: _ }) => {
90
90
  m?.forEach((v) => {
91
- te(v) && r.push(Xe(v, t)), ee(v) && i.push(v);
92
- }), d && (o.push(d), c[d] = D(m || [], e), _ && (l[d] = _)), f && a.push(f), h && u.push(h), d && h && (p[h] = d);
91
+ L(v) && r.push(et(v, t)), U(v) && i.push(v);
92
+ }), f && (o.push(f), c[f] = D(m || [], e), _ && (l[f] = _)), d && a.push(d), h && u.push(h), f && h && (p[h] = f);
93
93
  }
94
94
  ), {
95
95
  scripts: D(r, e),
96
96
  css: D(i, e),
97
97
  materials: D(a, e),
98
98
  libraryExports: o,
99
- materialExports: Oe(u),
99
+ materialExports: Be(u),
100
100
  materialMapLibrary: p,
101
101
  libraryMap: c,
102
102
  libraryLocaleMap: l
103
103
  };
104
104
  }
105
- function et(n, e) {
105
+ function st(n, e) {
106
106
  const { name: t, parent: s, alias: r } = n;
107
107
  return s ? e[s]?.[r || t] : e[r || t];
108
108
  }
109
+ function nt(n = []) {
110
+ const e = n.filter((s) => U(s)), t = n.filter((s) => L(s));
111
+ return {
112
+ css: e,
113
+ js: t
114
+ };
115
+ }
109
116
  function ye(n) {
110
- return j(n) ? n : JSON.stringify(n);
117
+ return E(n) ? n : JSON.stringify(n);
111
118
  }
112
119
  function _e(n, e, t) {
113
120
  const s = n.CSSStyleSheet;
@@ -124,11 +131,11 @@ function _e(n, e, t) {
124
131
  i ? i.innerHTML = t : (i = r.createElement("style"), i.id = e, i.innerHTML = t, r.head.appendChild(i));
125
132
  }
126
133
  }
127
- async function tt(n, e) {
134
+ async function rt(n, e) {
128
135
  const t = await window.fetch(e).then((s) => s.text()).catch(() => "");
129
136
  t && _e(window, n, t);
130
137
  }
131
- function st(n, e = window) {
138
+ function we(n, e = window) {
132
139
  const t = e.document, s = e.document.head;
133
140
  for (const r of n)
134
141
  if (!t.getElementById(r)) {
@@ -136,7 +143,7 @@ function st(n, e = window) {
136
143
  a.rel = "stylesheet", a.id = r, a.href = r, s.appendChild(a);
137
144
  }
138
145
  }
139
- async function nt(n, e, t = window) {
146
+ async function Se(n, e, t = window) {
140
147
  const s = t.document, r = t.document.head;
141
148
  let i = t[e];
142
149
  return i ? i.default || i : new Promise((a, o) => {
@@ -150,14 +157,14 @@ async function nt(n, e, t = window) {
150
157
  }
151
158
  });
152
159
  }
153
- function rt(n) {
154
- return K(n) || K(n?.install);
155
- }
156
160
  function it(n) {
157
- return Ye.includes(n);
161
+ return V(n) || V(n?.install);
158
162
  }
159
163
  function ot(n) {
160
- return Ge.includes(n);
164
+ return Xe.includes(n);
165
+ }
166
+ function at(n) {
167
+ return Qe.includes(n);
161
168
  }
162
169
  function M(n = window) {
163
170
  const e = window?.Mock;
@@ -166,7 +173,7 @@ function M(n = window) {
166
173
  if (t && window)
167
174
  return window.Mock = t, t;
168
175
  }
169
- function ts(n, e, t) {
176
+ function ss(n, e, t) {
170
177
  Object.assign(e.meta, t.meta);
171
178
  const s = n?._container;
172
179
  t?.type === "page" && s.classList.add("is-page"), t?.pure && s.classList.add("is-pure");
@@ -181,13 +188,13 @@ function H(n, e, t = !1, s = !1) {
181
188
  const a = `with(${t ? "{}" : "$scope || {}"}) { ${i} }`;
182
189
  return new Function("$scope", a)(e);
183
190
  } catch (r) {
184
- if (C.error("parseExpression.error", r, n, e?.__self ?? e), s)
191
+ if (k.error("parseExpression.error", r, n, e?.__self ?? e), s)
185
192
  throw r;
186
193
  }
187
194
  }
188
- function G(n, e, t = !1, s = !1) {
195
+ function Q(n, e, t = !1, s = !1) {
189
196
  const r = H(n, e, t, s);
190
- if (typeof r != "function" && (C.error(
197
+ if (typeof r != "function" && (k.error(
191
198
  "parseFunction.error",
192
199
  "not a function",
193
200
  n,
@@ -202,13 +209,13 @@ function w(n) {
202
209
  function T(n) {
203
210
  return typeof n == "object" && n && n.type === "JSFunction";
204
211
  }
205
- function at(n) {
212
+ function ct(n) {
206
213
  return w(n) || T(n);
207
214
  }
208
- function ss(n) {
209
- return at(n) ? n.value : JSON.stringify(n);
215
+ function ns(n) {
216
+ return ct(n) ? n.value : JSON.stringify(n);
210
217
  }
211
- const ct = {
218
+ const lt = {
212
219
  session: !1,
213
220
  authKey: "Authorization",
214
221
  storageKey: "ACCESS_STORAGE",
@@ -221,14 +228,14 @@ const ct = {
221
228
  noPermissionMessage: "无权限访问该页面",
222
229
  appName: "",
223
230
  statusKey: "code"
224
- }, we = Symbol("access");
225
- class Se {
231
+ }, $e = Symbol("access");
232
+ class je {
226
233
  options;
227
234
  data = null;
228
235
  mode = y.Raw;
229
236
  interceptResponse = !0;
230
237
  constructor(e) {
231
- this.options = Object.assign({}, ct, e), this.loadData();
238
+ this.options = Object.assign({}, lt, e), this.loadData();
232
239
  }
233
240
  enableIntercept() {
234
241
  this.interceptResponse = !0;
@@ -242,17 +249,17 @@ class Se {
242
249
  }
243
250
  login(e) {
244
251
  const { storageKey: t, storagePrefix: s, session: r, authKey: i } = this.options;
245
- this.setData(e), this.data && (L.save(t, e, {
252
+ this.setData(e), this.data && (J.save(t, e, {
246
253
  type: "local",
247
254
  prefix: s
248
- }), r && q.set(i, this.data.token));
255
+ }), r && K.set(i, this.data.token));
249
256
  }
250
257
  clear() {
251
258
  const { storageKey: e, storagePrefix: t, session: s, authKey: r } = this.options;
252
- this.data = null, L.remove(e, {
259
+ this.data = null, J.remove(e, {
253
260
  type: "local",
254
261
  prefix: t
255
- }), s && q.remove(r);
262
+ }), s && K.remove(r);
256
263
  }
257
264
  logout() {
258
265
  this.clear(), this.toLogin();
@@ -272,7 +279,7 @@ class Se {
272
279
  return re(e).some((i) => s[i] || s[t + "." + i]);
273
280
  }
274
281
  install(e) {
275
- e.config.globalProperties.$access = this, e.provide(we, this);
282
+ e.config.globalProperties.$access = this, e.provide($e, this);
276
283
  }
277
284
  isAuthPath(e) {
278
285
  const { auth: t, isAuth: s } = this.options;
@@ -312,7 +319,7 @@ class Se {
312
319
  this.data = e;
313
320
  }
314
321
  loadData() {
315
- const { storageKey: e, storagePrefix: t } = this.options, s = L.get(e, {
322
+ const { storageKey: e, storagePrefix: t } = this.options, s = J.get(e, {
316
323
  type: "local",
317
324
  prefix: t
318
325
  });
@@ -320,7 +327,7 @@ class Se {
320
327
  }
321
328
  isLogined() {
322
329
  const { session: e, authKey: t } = this.options;
323
- return e && t ? !!q.get(t) : !!this.getToken();
330
+ return e && t ? !!K.get(t) : !!this.getToken();
324
331
  }
325
332
  hasRoutePermission(e) {
326
333
  if (e.name === I) {
@@ -340,7 +347,7 @@ class Se {
340
347
  return t();
341
348
  {
342
349
  const { noPermissionMessage: s = "无权限访问", unauthorized: r = !1 } = this.options;
343
- return await this.showTip(s), K(r) ? (r(), t(!1)) : j(r) ? t(r) : t(!1);
350
+ return await this.showTip(s), V(r) ? (r(), t(!1)) : E(r) ? t(r) : t(!1);
344
351
  }
345
352
  }
346
353
  t(!1), this.toLogin();
@@ -375,10 +382,10 @@ class Se {
375
382
  );
376
383
  }
377
384
  }
378
- function lt() {
379
- return me(we, null);
385
+ function ut() {
386
+ return me($e, null);
380
387
  }
381
- function ns(n = {}) {
388
+ function rs(n = {}) {
382
389
  const {
383
390
  notify: e,
384
391
  loading: t,
@@ -415,13 +422,13 @@ function ns(n = {}) {
415
422
  loading: t,
416
423
  useTitle: a,
417
424
  startupComponent: r,
418
- access: i ? new Se({ alert: o, ...i }) : void 0
425
+ access: i ? new je({ alert: o, ...i }) : void 0
419
426
  };
420
427
  }
421
- function rs(n = {}) {
422
- return new Se(n);
428
+ function is(n = {}) {
429
+ return new je(n);
423
430
  }
424
- function ut(n, e) {
431
+ function pt(n, e) {
425
432
  const { jsonp: t, request: s } = e;
426
433
  if (n.method === "jsonp")
427
434
  return (r = {}) => t(n.url, {
@@ -437,10 +444,10 @@ function ut(n, e) {
437
444
  headers: r
438
445
  }
439
446
  };
440
- return (a, o) => (delete i.data, s.send(Ne(i, o || {}, { data: a })));
447
+ return (a, o) => (delete i.data, s.send(Ue(i, o || {}, { data: a })));
441
448
  }
442
449
  }
443
- function pt(n, e) {
450
+ function ft(n, e) {
444
451
  const { metaQuery: t } = e;
445
452
  if (!t) return;
446
453
  const { code: s, queryCode: r } = n;
@@ -452,47 +459,47 @@ function pt(n, e) {
452
459
  return t(s, r, i, a);
453
460
  };
454
461
  }
455
- function ft(n = [], e = [], t) {
462
+ function dt(n = [], e = [], t) {
456
463
  const s = {};
457
464
  for (const r of n)
458
- s[r.id] = ut(r, t);
459
- for (const r of e)
460
465
  s[r.id] = pt(r, t);
466
+ for (const r of e)
467
+ s[r.id] = ft(r, t);
461
468
  return s;
462
469
  }
463
- async function dt(n = [], e = window) {
470
+ async function ht(n = [], e = window) {
464
471
  const t = M(e);
465
- t && ($e(e), n.forEach((s) => mt(t, s)));
472
+ t && (Ee(e), n.forEach((s) => vt(t, s)));
466
473
  }
467
- function ht(n, e = window) {
468
- const t = T(n.mockTemplate) && n.mockTemplate.value ? G(n.mockTemplate, {}, !0) : void 0, s = M(e);
474
+ function mt(n, e = window) {
475
+ const t = T(n.mockTemplate) && n.mockTemplate.value ? Q(n.mockTemplate, {}, !0) : void 0, s = M(e);
469
476
  return async (...r) => {
470
477
  let i = {};
471
478
  if (t)
472
479
  try {
473
480
  i = await t.apply(t, r);
474
481
  } catch (a) {
475
- C.warn("模拟数据模版异常", a);
482
+ k.warn("模拟数据模版异常", a);
476
483
  }
477
484
  return s?.mock(i);
478
485
  };
479
486
  }
480
- function mt(n, e) {
487
+ function vt(n, e) {
481
488
  if (!e.mock) return;
482
489
  const { url: t, mockTemplate: s } = e;
483
490
  if (t && s) {
484
- const r = Be(`${t}(.*)`), i = Ue(t, { decode: decodeURIComponent }), a = H(s, {}, !0);
491
+ const r = Le(`${t}(.*)`), i = qe(t, { decode: decodeURIComponent }), a = H(s, {}, !0);
485
492
  n.mock(r, (o) => {
486
- const c = b.parse(o.url) || {}, l = o.body instanceof FormData ? Le(o.body) : o.body, u = i(o.url)?.params;
493
+ const c = C.parse(o.url) || {}, l = o.body instanceof FormData ? Je(o.body) : o.body, u = i(o.url)?.params;
487
494
  return Object.assign(o, { data: l, params: c, query: u }), n.mock(a(o));
488
495
  });
489
496
  }
490
497
  }
491
- function $e(n = window) {
498
+ function Ee(n = window) {
492
499
  const e = M(n);
493
500
  e && (e._mocked = {});
494
501
  }
495
- class vt {
502
+ class gt {
496
503
  __id = null;
497
504
  __mode;
498
505
  __instance = null;
@@ -551,9 +558,9 @@ class vt {
551
558
  if (e)
552
559
  if (this.__mode === y.Runtime) {
553
560
  const { id: t, type: s } = e, r = t ? this.__transform[t] ?? e.value : e.value;
554
- return G({ type: s, value: r }, this);
561
+ return Q({ type: s, value: r }, this);
555
562
  } else
556
- return G(e, this);
563
+ return Q(e, this);
557
564
  }
558
565
  __parseExpression(e) {
559
566
  if (e)
@@ -591,7 +598,7 @@ class vt {
591
598
  return s.context.__proto__ = this.context, s.__proto__ = this, s;
592
599
  }
593
600
  }
594
- function Y(n) {
601
+ function X(n) {
595
602
  const {
596
603
  Vue: e = B,
597
604
  mode: t = y.Runtime,
@@ -603,56 +610,59 @@ function Y(n) {
603
610
  $components: s,
604
611
  $libs: r,
605
612
  $apis: i
606
- }, l = new vt({
613
+ }, l = new gt({
607
614
  mode: t,
608
615
  dsl: o.value,
609
616
  attrs: c
610
617
  }), u = e.defineComponent({
611
618
  name: o.value.name,
612
619
  props: {
613
- ...yt(o.value.props ?? [], l)
620
+ ..._t(o.value.props ?? [], l)
614
621
  },
615
622
  setup(p) {
616
623
  l.$props = p, l.props = p, o.value.id && _e(
617
624
  n.window || window,
618
625
  o.value.id,
619
626
  o.value.css || ""
620
- ), l.state = _t(e, o.value.state ?? {}, l);
621
- const m = wt(e, o.value.computed ?? {}, l), f = St(o.value.methods ?? {}, l), d = $t(e, o.value.inject, l), h = Et(
627
+ ), l.state = wt(e, o.value.state ?? {}, l);
628
+ const m = St(e, o.value.computed ?? {}, l), d = $t(o.value.methods ?? {}, l), f = jt(e, o.value.inject, l);
629
+ for (const [v, P] of Object.entries(f || {}))
630
+ f[v] = e.inject(v, P);
631
+ const h = Et(
622
632
  o.value.dataSources || {},
623
633
  l
624
634
  ), _ = {
625
- ...d,
626
- ...m,
627
635
  ...f,
636
+ ...m,
637
+ ...d,
628
638
  ...h
629
639
  };
630
- return l.setup(_, e), jt(e, o.value.watch ?? [], l), {
640
+ return l.setup(_, e), Pt(e, o.value.watch ?? [], l), {
631
641
  vtj: l
632
642
  };
633
643
  },
634
- emits: gt(o.value.emits),
644
+ emits: yt(o.value.emits),
635
645
  expose: ["vtj"],
636
646
  render() {
637
647
  if (!o.value.nodes) return null;
638
648
  const p = o.value.nodes || [];
639
- return p.length === 1 ? k(p[0], l, e, a, p) : p.map(
640
- (m) => k(m, l, e, a, p)
649
+ return p.length === 1 ? F(p[0], l, e, a, p) : p.map(
650
+ (m) => F(m, l, e, a, p)
641
651
  );
642
652
  },
643
- ...Pt(o.value.lifeCycles ?? {}, l)
653
+ ...Rt(o.value.lifeCycles ?? {}, l)
644
654
  });
645
655
  return {
646
656
  renderer: e.markRaw(u),
647
657
  context: l
648
658
  };
649
659
  }
650
- function gt(n = []) {
651
- return n.map((e) => j(e) ? e : e.name);
660
+ function yt(n = []) {
661
+ return n.map((e) => E(e) ? e : e.name);
652
662
  }
653
- function yt(n = [], e) {
654
- const t = (s) => s ? (Array.isArray(s) ? s : [s]).map((i) => We[i]) : void 0;
655
- return n.map((s) => j(s) ? {
663
+ function _t(n = [], e) {
664
+ const t = (s) => s ? (Array.isArray(s) ? s : [s]).map((i) => Ye[i]) : void 0;
665
+ return n.map((s) => E(s) ? {
656
666
  name: s
657
667
  } : {
658
668
  name: s.name,
@@ -668,7 +678,7 @@ function yt(n = [], e) {
668
678
  {}
669
679
  );
670
680
  }
671
- function _t(n, e, t) {
681
+ function wt(n, e, t) {
672
682
  return n.reactive(
673
683
  Object.keys(e || {}).reduce(
674
684
  (s, r) => {
@@ -679,19 +689,19 @@ function _t(n, e, t) {
679
689
  )
680
690
  );
681
691
  }
682
- function wt(n, e, t) {
692
+ function St(n, e, t) {
683
693
  return Object.entries(e ?? {}).reduce(
684
694
  (s, [r, i]) => (s[r] = n.computed(t.__parseFunction(i)), s),
685
695
  {}
686
696
  );
687
697
  }
688
- function St(n, e) {
698
+ function $t(n, e) {
689
699
  return Object.entries(n ?? {}).reduce(
690
700
  (t, [s, r]) => (t[s] = e.__parseFunction(r), t),
691
701
  {}
692
702
  );
693
703
  }
694
- function $t(n, e = [], t) {
704
+ function jt(n, e = [], t) {
695
705
  return e.reduce(
696
706
  (s, r) => {
697
707
  const { name: i, from: a } = r || {};
@@ -707,7 +717,7 @@ function Et(n, e) {
707
717
  (t, s) => {
708
718
  const r = n[s];
709
719
  if (r.type === "mock")
710
- t[s] = ht(r);
720
+ t[s] = mt(r);
711
721
  else if (r.ref) {
712
722
  const i = e.$apis[r.ref], a = T(r.transform) ? r.transform.value ? e.__parseFunction(r.transform) : void 0 : r.transform;
713
723
  t[s] = async (...o) => {
@@ -720,7 +730,7 @@ function Et(n, e) {
720
730
  {}
721
731
  );
722
732
  }
723
- function jt(n, e = [], t) {
733
+ function Pt(n, e = [], t) {
724
734
  e.forEach((s) => {
725
735
  n.watch(
726
736
  t.__parseExpression(s.source),
@@ -732,55 +742,55 @@ function jt(n, e = [], t) {
732
742
  );
733
743
  });
734
744
  }
735
- function Pt(n, e) {
745
+ function Rt(n, e) {
736
746
  return Object.entries(n ?? {}).reduce(
737
747
  (t, [s, r]) => (t[s] = e.__parseFunction(r), t),
738
748
  {}
739
749
  );
740
750
  }
741
- let J = [], R = {};
742
- const Rt = (n) => n;
743
- async function Ee(n, e = window) {
744
- const { urls: t = [], library: s } = n, r = t.filter((o) => te(o));
751
+ let z = [], b = {};
752
+ const bt = (n) => n;
753
+ async function Pe(n, e = window) {
754
+ const { urls: t = [], library: s } = n, r = t.filter((o) => L(o));
745
755
  if (r.length === 0 || !s) return null;
746
- const i = t.filter((o) => ee(o));
747
- return i.length && st(i, e), await nt(r, s, e).catch(
756
+ const i = t.filter((o) => U(o));
757
+ return i.length && we(i, e), await Se(r, s, e).catch(
748
758
  (o) => (console.warn("loadScriptUrl error", r, s, o), null)
749
759
  );
750
760
  }
751
- function Q(n) {
761
+ function Z(n) {
752
762
  const { getDsl: e, getDslByUrl: t, options: s } = n;
753
- return s.window && (J.forEach((r) => {
763
+ return s.window && (z.forEach((r) => {
754
764
  delete s.window[r];
755
- }), J = []), (r, i, a = B) => {
765
+ }), z = []), (r, i, a = B) => {
756
766
  if (!i || typeof i == "string") return r;
757
767
  if (i.type === "Schema" && i.id)
758
768
  return a.defineAsyncComponent(async () => {
759
- const o = R[i.id] || await e(i.id);
760
- return o && (o.name = r, R[i.id] = o), o ? Y({
769
+ const o = b[i.id] || await e(i.id);
770
+ return o && (o.name = r, b[i.id] = o), o ? X({
761
771
  ...s,
762
772
  Vue: a,
763
773
  dsl: oe(o),
764
774
  mode: y.Runtime,
765
- loader: Q(n)
775
+ loader: Z(n)
766
776
  }).renderer : null;
767
777
  });
768
778
  if (i.type === "UrlSchema" && i.url)
769
779
  return a.defineAsyncComponent(async () => {
770
- const o = R[i.url] || await t(i.url);
771
- return o && (o.name = r, R[i.url] = o), o ? Y({
780
+ const o = b[i.url] || await t(i.url);
781
+ return o && (o.name = r, b[i.url] = o), o ? X({
772
782
  ...s,
773
783
  Vue: a,
774
784
  dsl: oe(o),
775
785
  mode: y.Runtime,
776
- loader: Q(n)
786
+ loader: Z(n)
777
787
  }).renderer : null;
778
788
  });
779
789
  if (i.type === "Plugin") {
780
- let o = i.library ? R[i.library] : null;
781
- return o || (i.library && J.push(i.library), o = R[i.library || Symbol()] = a.defineAsyncComponent(
790
+ let o = i.library ? b[i.library] : null;
791
+ return o || (i.library && z.push(i.library), o = b[i.library || Symbol()] = a.defineAsyncComponent(
782
792
  async () => {
783
- const c = await Ee(i, s.window);
793
+ const c = await Pe(i, s.window);
784
794
  return c || (console.warn("getPlugin result is null", i), null);
785
795
  }
786
796
  ), o);
@@ -788,46 +798,46 @@ function Q(n) {
788
798
  return r;
789
799
  };
790
800
  }
791
- function is() {
792
- R = {};
801
+ function os() {
802
+ b = {};
793
803
  }
794
- function k(n, e, t = B, s = Rt, r = [], i = !1) {
804
+ function F(n, e, t = B, s = bt, r = [], i = !1) {
795
805
  if (!n || !n.name || n.invisible) return null;
796
- const a = t.getCurrentInstance()?.appContext, { id: o = null, directives: c = [] } = n, { vIf: l, vElseIf: u, vElse: p, vFor: m, vShow: f, vModels: d, vBind: h, vHtml: _, others: v } = je(c);
806
+ const a = t.getCurrentInstance()?.appContext, { id: o = null, directives: c = [] } = n, { vIf: l, vElseIf: u, vElse: p, vFor: m, vShow: d, vModels: f, vBind: h, vHtml: _, others: v } = Re(c);
797
807
  if (!i && (u || p))
798
808
  return null;
799
- if (l && !Ct(l, e))
800
- return It(n, e, t, s, r);
801
- const F = (S) => {
802
- const Ae = S.$components, Ie = (() => {
809
+ if (l && !kt(l, e))
810
+ return Mt(n, e, t, s, r);
811
+ const P = (S) => {
812
+ const Me = S.$components, He = (() => {
803
813
  if (n.name === "component")
804
- return kt(S, n.props?.is);
814
+ return Ft(S, n.props?.is);
805
815
  if (n.name === "slot") return n.name;
806
816
  const $ = s(n.name, n.from, t);
807
- return j($) ? it($) || ot($) ? $ : Ae[$] ?? a?.app?.component($) ?? $ : $;
808
- })(), P = Ft(o, n.props ?? {}, S), Me = At(t, n.events ?? {}, S);
817
+ return E($) ? ot($) || at($) ? $ : Me[$] ?? a?.app?.component($) ?? $ : $;
818
+ })(), R = At(o, n.props ?? {}, S), Te = It(t, n.events ?? {}, S);
809
819
  if (n.name === "slot")
810
- return Mt(t, n, P, S, s);
811
- h && Object.assign(P, S.__parseExpression(h.value)), f && (P.style = Object.assign(
812
- P.style ?? {},
813
- Tt(f, S)
814
- )), _ && Object.assign(P, Dt(_, S)), d.forEach(($) => {
815
- Object.assign(P, xt(t, $, S));
820
+ return Ht(t, n, R, S, s);
821
+ h && Object.assign(R, S.__parseExpression(h.value)), d && (R.style = Object.assign(
822
+ R.style ?? {},
823
+ Dt(d, S)
824
+ )), _ && Object.assign(R, xt(_, S)), f.forEach(($) => {
825
+ Object.assign(R, Ot(t, $, S));
816
826
  });
817
- const He = Ot(
827
+ const De = Nt(
818
828
  t,
819
829
  n.children ?? [],
820
830
  S,
821
831
  s,
822
832
  n
823
833
  );
824
- let U = t.createVNode(Ie, { ...P, ...Me }, He);
825
- const ne = a ? bt(a, v, S) : [];
826
- return ne.length && (U = t.withDirectives(U, ne)), U;
834
+ let q = t.createVNode(He, { ...R, ...Te }, De);
835
+ const ne = a ? Ct(a, v, S) : [];
836
+ return ne.length && (q = t.withDirectives(q, ne)), q;
827
837
  };
828
- return m ? Ut(m, F, e) : F(e);
838
+ return m ? Lt(m, P, e) : P(e);
829
839
  }
830
- function bt(n, e, t) {
840
+ function Ct(n, e, t) {
831
841
  const s = n.app;
832
842
  return e.map((r) => {
833
843
  const i = typeof r.name == "string" ? s.directive(r.name) : t.__parseExpression(r.name);
@@ -836,13 +846,13 @@ function bt(n, e, t) {
836
846
  return r.value && a.push(t.__parseExpression(r.value)), r.arg && a.push(r.arg), r.modifiers && a.push(r.modifiers), a;
837
847
  }).filter((r) => !!r);
838
848
  }
839
- function je(n = []) {
840
- const e = n.find((u) => E(u.name) === "vIf"), t = n.find(
841
- (u) => E(u.name) === "vElseIf"
842
- ), s = n.find((u) => E(u.name) === "vElse"), r = n.find((u) => E(u.name) === "vFor"), i = n.find((u) => E(u.name) === "vShow"), a = n.find((u) => E(u.name) === "vBind"), o = n.find((u) => E(u.name) === "vHtml"), c = n.filter(
843
- (u) => E(u.name) === "vModel"
849
+ function Re(n = []) {
850
+ const e = n.find((u) => j(u.name) === "vIf"), t = n.find(
851
+ (u) => j(u.name) === "vElseIf"
852
+ ), s = n.find((u) => j(u.name) === "vElse"), r = n.find((u) => j(u.name) === "vFor"), i = n.find((u) => j(u.name) === "vShow"), a = n.find((u) => j(u.name) === "vBind"), o = n.find((u) => j(u.name) === "vHtml"), c = n.filter(
853
+ (u) => j(u.name) === "vModel"
844
854
  ), l = n.filter(
845
- (u) => !Ve.includes(E(u.name))
855
+ (u) => !Ge.includes(j(u.name))
846
856
  );
847
857
  return {
848
858
  vIf: e,
@@ -856,26 +866,26 @@ function je(n = []) {
856
866
  vHtml: o
857
867
  };
858
868
  }
859
- function Ct(n, e) {
869
+ function kt(n, e) {
860
870
  return !!e.__parseExpression(n.value);
861
871
  }
862
- function kt(n, e) {
872
+ function Ft(n, e) {
863
873
  return e ? w(e) ? n.__parseExpression(e) : e : "div";
864
874
  }
865
- function Ft(n, e, t) {
866
- const s = X(e, t);
875
+ function At(n, e, t) {
876
+ const s = ee(e, t);
867
877
  return s.ref = t.__ref(n, s.ref), s;
868
878
  }
869
- function X(n, e) {
870
- return w(n) ? e.__parseExpression(n) : T(n) ? e.__parseFunction(n) : Array.isArray(n) ? n.map((t) => X(t, e)) : typeof n == "object" ? Object.keys(n || {}).reduce(
879
+ function ee(n, e) {
880
+ return w(n) ? e.__parseExpression(n) : T(n) ? e.__parseFunction(n) : Array.isArray(n) ? n.map((t) => ee(t, e)) : typeof n == "object" ? Object.keys(n || {}).reduce(
871
881
  (t, s) => {
872
882
  let r = n[s];
873
- return t[s] = X(r, e), t;
883
+ return t[s] = ee(r, e), t;
874
884
  },
875
885
  {}
876
886
  ) : n;
877
887
  }
878
- function At(n, e, t) {
888
+ function It(n, e, t) {
879
889
  const s = ["passive", "capture", "once"], r = {
880
890
  capture: "Capture",
881
891
  once: "Once",
@@ -883,62 +893,62 @@ function At(n, e, t) {
883
893
  };
884
894
  return Object.keys(e || {}).reduce(
885
895
  (i, a) => {
886
- const o = e[a], c = Pe(o.modifiers), l = c.find((m) => s.includes(m)), u = "on" + qe(a) + (l && r[l] || ""), p = t.__parseFunction(o.handler);
896
+ const o = e[a], c = be(o.modifiers), l = c.find((m) => s.includes(m)), u = "on" + Ke(a) + (l && r[l] || ""), p = t.__parseFunction(o.handler);
887
897
  return p && (i[u] = n.withModifiers(p, c)), i;
888
898
  },
889
899
  {}
890
900
  );
891
901
  }
892
- function It(n, e, t, s, r = []) {
902
+ function Mt(n, e, t, s, r = []) {
893
903
  let i = r.findIndex((a) => a.id === n.id);
894
904
  for (let a = ++i; a < r.length; a++) {
895
- const { directives: o = [] } = r[a], { vElseIf: c, vElse: l } = je(o);
905
+ const { directives: o = [] } = r[a], { vElseIf: c, vElse: l } = Re(o);
896
906
  if (c) {
897
907
  if (e.__parseExpression(c.value))
898
- return k(r[a], e, t, s, r, !0);
908
+ return F(r[a], e, t, s, r, !0);
899
909
  continue;
900
910
  }
901
911
  if (l)
902
- return k(r[a], e, t, s, r, !0);
912
+ return F(r[a], e, t, s, r, !0);
903
913
  }
904
914
  return null;
905
915
  }
906
- function Pe(n = {}, e = !1) {
916
+ function be(n = {}, e = !1) {
907
917
  const t = Object.keys(n);
908
918
  return e ? t.map((s) => "." + s) : t;
909
919
  }
910
- function Mt(n, e, t, s, r) {
911
- const { children: i } = e, a = Ht(e, s), o = s.$slots?.[a.name];
912
- return o ? o(t) : i ? j(i) ? n.createTextVNode(i) : w(i) ? n.createTextVNode(
920
+ function Ht(n, e, t, s, r) {
921
+ const { children: i } = e, a = Tt(e, s), o = s.$slots?.[a.name];
922
+ return o ? o(t) : i ? E(i) ? n.createTextVNode(i) : w(i) ? n.createTextVNode(
913
923
  ye(s.__parseExpression(i))
914
924
  ) : Array.isArray(i) ? i.map(
915
- (c) => k(c, s, n, r, i)
925
+ (c) => F(c, s, n, r, i)
916
926
  ) : null : null;
917
927
  }
918
- function Ht(n, e) {
928
+ function Tt(n, e) {
919
929
  const { props: t } = n, s = t?.name || "default";
920
930
  return {
921
931
  name: w(s) ? e.__parseExpression(s) : s,
922
932
  params: []
923
933
  };
924
934
  }
925
- function Tt(n, e) {
935
+ function Dt(n, e) {
926
936
  return e.__parseExpression(n.value) ? {} : {
927
937
  display: "none"
928
938
  };
929
939
  }
930
- function Dt(n, e) {
940
+ function xt(n, e) {
931
941
  return {
932
942
  innerHTML: e.__parseExpression(n.value) || ""
933
943
  };
934
944
  }
935
- function xt(n, e, t) {
945
+ function Ot(n, e, t) {
936
946
  const s = {
937
947
  type: "JSFunction",
938
948
  value: e.value?.value ? `(v) => {
939
949
  ${e.value.value} = v;
940
950
  }` : "(v) => {}"
941
- }, r = t.__parseFunction(s), i = Pe(
951
+ }, r = t.__parseFunction(s), i = be(
942
952
  w(e.modifiers) ? t.__parseExpression(e.modifiers) : e.modifiers
943
953
  ), a = w(e.arg) ? t.__parseExpression(e.arg) : e.arg || "modelValue";
944
954
  return {
@@ -946,28 +956,28 @@ function xt(n, e, t) {
946
956
  [`onUpdate:${a}`]: i.length && r ? n.withModifiers(r, i) : r
947
957
  };
948
958
  }
949
- function Ot(n, e, t, s, r) {
959
+ function Nt(n, e, t, s, r) {
950
960
  if (!e) return null;
951
- if (j(e))
961
+ if (E(e))
952
962
  return { default: () => e };
953
963
  if (w(e))
954
964
  return {
955
965
  default: () => ye(t.__parseExpression(e))
956
966
  };
957
967
  if (Array.isArray(e) && e.length > 0) {
958
- const i = Nt(e), a = (o) => !o || !r ? {} : r?.id && Object.keys(o).length ? {
968
+ const i = Bt(e), a = (o) => !o || !r ? {} : r?.id && Object.keys(o).length ? {
959
969
  [`scope_${r.id}`]: o
960
970
  } : {};
961
971
  return Object.entries(i).reduce((o, [c, { nodes: l, params: u }]) => (o[c] = (p) => {
962
- const m = u.length ? Je(p ?? {}, u) : a(p);
972
+ const m = u.length ? ze(p ?? {}, u) : a(p);
963
973
  return l.map(
964
- (f) => k(f, t.__clone(m), n, s, l)
974
+ (d) => F(d, t.__clone(m), n, s, l)
965
975
  );
966
976
  }, o), {});
967
977
  }
968
978
  return null;
969
979
  }
970
- function Nt(n) {
980
+ function Bt(n) {
971
981
  const e = {
972
982
  default: {
973
983
  params: [],
@@ -975,7 +985,7 @@ function Nt(n) {
975
985
  }
976
986
  };
977
987
  for (const t of n) {
978
- const s = Bt(t.slot), r = s.name;
988
+ const s = Ut(t.slot), r = s.name;
979
989
  e[r] ? (e[r].nodes.push(t), e[r].params = e[r].params.concat(s.params)) : e[r] = {
980
990
  nodes: [t],
981
991
  params: s.params
@@ -983,10 +993,10 @@ function Nt(n) {
983
993
  }
984
994
  return e;
985
995
  }
986
- function Bt(n = "default") {
987
- return j(n) ? { name: n, params: [] } : { params: [], ...n };
996
+ function Ut(n = "default") {
997
+ return E(n) ? { name: n, params: [] } : { params: [], ...n };
988
998
  }
989
- function Ut(n, e, t) {
999
+ function Lt(n, e, t) {
990
1000
  const { value: s, iterator: r } = n, { item: i = "item", index: a = "index" } = r || {};
991
1001
  let o = t.__parseExpression(s) || [];
992
1002
  return Number.isInteger(o) && (o = new Array(o).fill(!0).map((c, l) => l + 1)), Array.isArray(o) ? o.map((c, l) => e(t.__clone({ [i]: c, [a]: l }))) : (console.warn("[vForRender]:", `${s?.value} is not a Arrary`), []);
@@ -994,7 +1004,7 @@ function Ut(n, e, t) {
994
1004
  const ue = ve({
995
1005
  name: "VtjPageContainer",
996
1006
  async setup() {
997
- const n = be(), e = ge(), t = e.params.id, s = t ? n.getPage(t) : n.getHomepage(), r = s ? await n.getRenderComponent(s.id) : null, i = W(Symbol());
1007
+ const n = ke(), e = ge(), t = e.params.id, s = t ? n.getPage(t) : n.getHomepage(), r = s ? await n.getRenderComponent(s.id) : null, i = Y(Symbol());
998
1008
  if (s) {
999
1009
  Object.assign(e.meta, s.meta || {}, { cache: s.cache });
1000
1010
  const { useTitle: a } = n?.adapter;
@@ -1012,19 +1022,24 @@ const ue = ve({
1012
1022
  },
1013
1023
  render() {
1014
1024
  const { component: n, query: e, sid: t } = this;
1015
- return n ? V(n, { ...e, key: t }) : V("div", "页面不存在");
1025
+ return n ? G(n, { ...e, key: t }) : G("div", "页面不存在");
1016
1026
  },
1017
1027
  activated() {
1018
1028
  this.meta.cache === !1 && (this.sid = Symbol());
1019
1029
  }
1020
- }), Lt = ve({
1030
+ }), qt = ve({
1021
1031
  name: "VtjStartupContainer",
1022
1032
  render() {
1023
- return V("div", "page not found!");
1024
- }
1025
- }), Re = Symbol("Provider");
1026
- var qt = /* @__PURE__ */ ((n) => (n.Production = "production", n.Development = "development", n))(qt || {});
1027
- class Jt extends Te {
1033
+ return G("div", "page not found!");
1034
+ }
1035
+ }), Ce = Symbol("Provider");
1036
+ var Jt = /* @__PURE__ */ ((n) => (n.Production = "production", n.Development = "development", n))(Jt || {});
1037
+ class Kt extends xe {
1038
+ // DSL缓存
1039
+ /**
1040
+ * 创建Provider实例
1041
+ * @param options 配置选项
1042
+ */
1028
1043
  constructor(e) {
1029
1044
  super(), this.options = e;
1030
1045
  const {
@@ -1042,23 +1057,37 @@ class Jt extends Te {
1042
1057
  /* Development */
1043
1058
  } = e;
1044
1059
  this.mode = s, this.modules = l, this.service = t, this.router = u, this.materialPath = p, this.nodeEnv = m, r && (this.dependencies = r), i && (this.materials = i), Object.assign(this.globals, c), Object.assign(this.adapter, o);
1045
- const { access: f, request: d } = this.adapter;
1046
- f && f.connect({ mode: s, router: u, request: d }), a && s !== y.Design ? this.load(a) : this.project = a;
1060
+ const { access: d, request: f } = this.adapter;
1061
+ d && d.connect({ mode: s, router: u, request: f }), a && s !== y.Design ? this.load(a) : this.project = a;
1047
1062
  }
1048
1063
  mode;
1064
+ // 当前运行模式(设计/源码/预览等)
1049
1065
  globals = {};
1066
+ // 全局变量
1050
1067
  modules = {};
1051
- adapter = { request: z, jsonp: he };
1068
+ // 异步模块加载器
1069
+ adapter = { request: W, jsonp: he };
1070
+ // 适配器接口
1052
1071
  apis = {};
1072
+ // API集合
1053
1073
  dependencies = {};
1074
+ // 依赖项
1054
1075
  materials = {};
1076
+ // 物料资源
1055
1077
  library = {};
1078
+ // 第三方库
1056
1079
  service;
1080
+ // 核心服务
1057
1081
  project = null;
1082
+ // 当前项目配置
1058
1083
  components = {};
1084
+ // 组件集合
1059
1085
  nodeEnv = "development";
1086
+ // 运行环境
1060
1087
  router = null;
1088
+ // 路由实例
1061
1089
  materialPath = "./";
1090
+ // 物料路径
1062
1091
  urlDslCaches = {};
1063
1092
  createMock(e) {
1064
1093
  return async (...t) => {
@@ -1067,17 +1096,26 @@ class Jt extends Te {
1067
1096
  try {
1068
1097
  s = await e.apply(e, t);
1069
1098
  } catch (i) {
1070
- C.warn("模拟数据模版异常", i);
1099
+ k.warn("模拟数据模版异常", i);
1071
1100
  }
1072
1101
  return M()?.mock(s);
1073
1102
  };
1074
1103
  }
1104
+ /**
1105
+ * 加载项目配置并初始化
1106
+ * 1. 从模块或服务加载项目配置
1107
+ * 2. 根据运行模式加载依赖或资源
1108
+ * 3. 初始化Mock数据
1109
+ * 4. 创建API接口
1110
+ * 5. 初始化路由(非uniapp平台)
1111
+ * @param project 项目配置
1112
+ */
1075
1113
  async load(e) {
1076
1114
  const t = this.modules[`.vtj/projects/${e.id}.json`] || this.modules[`/src/.vtj/projects/${e.id}.json`];
1077
1115
  if (this.project = t ? await t() : await this.service.init(e), !this.project)
1078
1116
  throw new Error("project is null");
1079
1117
  const { apis: s = [], meta: r = [] } = this.project, i = window;
1080
- i && (i.CKEDITOR_VERSION = void 0), this.mode === y.Raw ? await this.loadDependencies(i) : await this.loadAssets(i), this.initMock(i), this.apis = ft(s, r, this.adapter), $e(i), dt(s, i), e.platform !== "uniapp" && this.initRouter(), this.triggerReady();
1118
+ i && (i.CKEDITOR_VERSION = void 0), this.mode === y.Raw ? await this.loadDependencies(i) : await this.loadAssets(i), this.initMock(i), this.apis = dt(s, r, this.adapter), Ee(i), ht(s, i), e.platform !== "uniapp" && this.initRouter(), this.triggerReady();
1081
1119
  }
1082
1120
  initMock(e) {
1083
1121
  const t = M(e);
@@ -1097,39 +1135,39 @@ class Jt extends Te {
1097
1135
  materials: u,
1098
1136
  materialExports: p,
1099
1137
  materialMapLibrary: m
1100
- } = Ze(
1138
+ } = tt(
1101
1139
  t,
1102
1140
  a,
1103
1141
  o === "development"
1104
1142
  /* Development */
1105
1143
  );
1106
- for (const f of c) {
1107
- const d = s[f], h = e[f];
1144
+ for (const d of c) {
1145
+ const f = s[d], h = e[d];
1108
1146
  if (h)
1109
- r[f] = h;
1110
- else if (d)
1111
- e[f] = r[f] = await d();
1147
+ r[d] = h;
1148
+ else if (f)
1149
+ e[d] = r[d] = await f();
1112
1150
  else {
1113
- const _ = l[f] || [];
1151
+ const _ = l[d] || [];
1114
1152
  for (const v of _)
1115
- ee(v) && await tt(f, b.append(v, { v: A })), te(v) && await ae(b.append(v, { v: A }));
1116
- r[f] = e[f];
1153
+ U(v) && await rt(d, C.append(v, { v: A })), L(v) && await ae(C.append(v, { v: A }));
1154
+ r[d] = e[d];
1117
1155
  }
1118
1156
  }
1119
1157
  if (o === "development") {
1120
- for (const d of u)
1121
- await ae(b.append(d, { v: A }));
1122
- const f = this.materials || {};
1123
- for (const d of p) {
1124
- const h = e[m[d]], _ = De[d];
1158
+ for (const f of u)
1159
+ await ae(C.append(f, { v: A }));
1160
+ const d = this.materials || {};
1161
+ for (const f of p) {
1162
+ const h = e[m[f]], _ = Oe[f];
1125
1163
  if (_)
1126
1164
  h && _.forEach((v) => {
1127
1165
  i[v] = h[v];
1128
1166
  });
1129
1167
  else {
1130
- const v = f[d] ? (await f[d]()).default : e[d];
1131
- v && h && (v.components || []).forEach((F) => {
1132
- i[F.name] = et(F, h);
1168
+ const v = d[f] ? (await d[f]()).default : e[f];
1169
+ v && h && (v.components || []).forEach((P) => {
1170
+ i[P.name] = st(P, h);
1133
1171
  });
1134
1172
  }
1135
1173
  }
@@ -1149,16 +1187,26 @@ class Jt extends Te {
1149
1187
  }, p = {
1150
1188
  path: l,
1151
1189
  name: O,
1152
- component: t?.homepage ? ue : r.startupComponent || Lt,
1190
+ component: t?.homepage ? ue : r.startupComponent || qt,
1153
1191
  meta: c
1154
1192
  };
1155
1193
  e.hasRoute(I) && e.removeRoute(I), e.hasRoute(O) && e.removeRoute(O), a ? (e.addRoute(a, u), e.addRoute(a, p)) : (e.addRoute(u), e.addRoute(p));
1156
1194
  }
1195
+ /**
1196
+ * Vue 插件安装方法
1197
+ * 1. 安装所有第三方库插件
1198
+ * 2. 执行自定义安装函数(如果提供)
1199
+ * 3. 安装访问适配器
1200
+ * 4. 提供全局 Provider 实例
1201
+ * 5. 设计模式下设置错误处理器
1202
+ * 6. 执行增强函数(如果提供)
1203
+ * @param app Vue 应用实例
1204
+ */
1157
1205
  install(e) {
1158
1206
  const t = e.config.globalProperties.installed || {};
1159
1207
  for (const [s, r] of Object.entries(this.library))
1160
- !t[s] && rt(r) && (e.use(r), t[s] = !0);
1161
- this.options.install && e.use(this.options.install), this.adapter.access && e.use(this.adapter.access), e.provide(Re, this), e.config.globalProperties.$provider = this, e.config.globalProperties.installed = t, this.mode === y.Design && (e.config.errorHandler = (s, r, i) => {
1208
+ !t[s] && it(r) && (e.use(r), t[s] = !0);
1209
+ this.options.install && e.use(this.options.install), this.adapter.access && e.use(this.adapter.access), e.provide(Ce, this), e.config.globalProperties.$provider = this, e.config.globalProperties.installed = t, this.mode === y.Design && (e.config.errorHandler = (s, r, i) => {
1162
1210
  const a = r?.$options.name, o = typeof s == "string" ? s : s?.message || s?.msg || "未知错误", c = `[ ${a} ] ${o} ${i}`;
1163
1211
  console.error(
1164
1212
  "[VTJ Error]:",
@@ -1169,7 +1217,7 @@ class Jt extends Te {
1169
1217
  },
1170
1218
  s?.stack
1171
1219
  ), this.adapter.notify && this.adapter.notify(c, "组件渲染错误", "error");
1172
- });
1220
+ }), this.options.enhance && e.use(this.options.enhance, this);
1173
1221
  }
1174
1222
  getFile(e) {
1175
1223
  const { blocks: t = [] } = this.project || {};
@@ -1208,6 +1256,15 @@ class Jt extends Te {
1208
1256
  }
1209
1257
  }).then((s) => s.data).catch(() => null) : null);
1210
1258
  }
1259
+ /**
1260
+ * 创建 DSL 渲染器
1261
+ * 1. 合并默认选项和自定义选项
1262
+ * 2. 创建 DSL 加载器
1263
+ * 3. 返回渲染器实例
1264
+ * @param dsl 区块 DSL 配置
1265
+ * @param opts 渲染选项
1266
+ * @returns 渲染器实例
1267
+ */
1211
1268
  createDslRenderer(e, t = {}) {
1212
1269
  const { library: s, components: r, mode: i, apis: a } = this, o = {
1213
1270
  mode: i,
@@ -1217,47 +1274,73 @@ class Jt extends Te {
1217
1274
  apis: a,
1218
1275
  window,
1219
1276
  ...t
1220
- }, c = Q({
1277
+ }, c = Z({
1221
1278
  getDsl: async (l) => await this.getDsl(l) || null,
1222
1279
  getDslByUrl: async (l) => await this.getDslByUrl(l) || null,
1223
1280
  options: o
1224
1281
  });
1225
- return Y({
1282
+ return X({
1226
1283
  ...o,
1227
1284
  dsl: e,
1228
1285
  loader: c
1229
1286
  });
1230
1287
  }
1288
+ /**
1289
+ * 获取渲染组件
1290
+ * 1. 根据ID查找文件(页面或区块)
1291
+ * 2. 如果找到文件且提供了output回调,则调用它
1292
+ * 3. 尝试从模块缓存加载原始Vue组件
1293
+ * 4. 如果找不到原始组件,则获取DSL并创建渲染器
1294
+ * @param id 文件ID
1295
+ * @param output 找到文件时的回调函数
1296
+ * @returns Promise<Vue组件>
1297
+ */
1231
1298
  async getRenderComponent(e, t) {
1232
1299
  const s = this.getFile(e);
1233
1300
  if (!s)
1234
- return C.warn(`Can not find file: ${e}`), null;
1301
+ return k.warn(`Can not find file: ${e}`), null;
1235
1302
  t && t(s);
1236
1303
  const r = `.vtj/vue/${e}.vue`, i = this.modules[r] || this.modules[`/src/pages/${e}.vue`];
1237
1304
  if (i)
1238
1305
  return (await i())?.default;
1239
1306
  const a = await this.getDsl(s.id);
1240
- return a ? this.createDslRenderer(a).renderer : (C.warn(`Can not find dsl: ${e}`), null);
1241
- }
1307
+ return a ? this.createDslRenderer(a).renderer : (k.warn(`Can not find dsl: ${e}`), null);
1308
+ }
1309
+ /**
1310
+ * 定义基于URL的异步组件
1311
+ * 1. 根据URL获取DSL配置
1312
+ * 2. 如果获取成功,设置组件名称
1313
+ * 3. 创建并返回DSL渲染器
1314
+ * @param url DSL配置URL
1315
+ * @param name 可选的自定义组件名称
1316
+ * @returns Vue异步组件
1317
+ */
1242
1318
  defineUrlSchemaComponent(e, t) {
1243
1319
  return ce(async () => {
1244
1320
  const s = await this.getDslByUrl(e);
1245
1321
  return s ? (s.name = t || s.name, this.createDslRenderer(s).renderer) : null;
1246
1322
  });
1247
1323
  }
1324
+ /**
1325
+ * 定义基于插件的异步组件
1326
+ * 1. 根据插件来源获取插件实例
1327
+ * 2. 返回插件组件
1328
+ * @param from 插件来源配置
1329
+ * @returns Vue异步组件
1330
+ */
1248
1331
  definePluginComponent(e) {
1249
- return ce(async () => await Ee(e, window));
1332
+ return ce(async () => await Pe(e, window));
1250
1333
  }
1251
1334
  }
1252
- function os(n) {
1253
- const e = new Jt(n);
1335
+ function as(n) {
1336
+ const e = new Kt(n);
1254
1337
  return {
1255
1338
  provider: e,
1256
1339
  onReady: (s) => e.ready(s)
1257
1340
  };
1258
1341
  }
1259
- function be(n = {}) {
1260
- const e = me(Re, null);
1342
+ function ke(n = {}) {
1343
+ const e = me(Ce, null);
1261
1344
  if (!e)
1262
1345
  throw new Error("Can not find provider");
1263
1346
  if (e.nodeEnv === "development") {
@@ -1273,13 +1356,21 @@ function be(n = {}) {
1273
1356
  }
1274
1357
  return e;
1275
1358
  }
1276
- const Ce = {
1359
+ async function cs(n, e = "") {
1360
+ const { name: t, urls: s = [] } = n || {}, r = s.map((o) => e + o), { css: i, js: a } = nt(r);
1361
+ if (i.length && we(i), a.length)
1362
+ return await Se(a, t).catch(
1363
+ () => {
1364
+ }
1365
+ );
1366
+ }
1367
+ const Fe = {
1277
1368
  type: "json",
1278
1369
  validSuccess: !0,
1279
1370
  originResponse: !1,
1280
1371
  failMessage: !0,
1281
1372
  validate: (n) => n.data?.code === 0
1282
- }, Kt = (n, e = "/__vtj__/api/:type.json") => (t, s, r) => n.send({
1373
+ }, zt = (n, e = "/__vtj__/api/:type.json") => (t, s, r) => n.send({
1283
1374
  url: e,
1284
1375
  method: "post",
1285
1376
  params: { type: t },
@@ -1288,8 +1379,8 @@ const Ce = {
1288
1379
  type: t,
1289
1380
  data: s
1290
1381
  },
1291
- settings: Ce
1292
- }), zt = (n, e = "/__vtj__/api/uploader.json") => async (t, s) => await n.send({
1382
+ settings: Fe
1383
+ }), Vt = (n, e = "/__vtj__/api/uploader.json") => async (t, s) => await n.send({
1293
1384
  url: e,
1294
1385
  method: "post",
1295
1386
  data: {
@@ -1297,11 +1388,11 @@ const Ce = {
1297
1388
  projectId: s
1298
1389
  },
1299
1390
  settings: {
1300
- ...Ce,
1391
+ ...Fe,
1301
1392
  type: "data"
1302
1393
  }
1303
1394
  }).then((r) => r && r[0] ? r[0] : null).catch(() => null);
1304
- function as(n) {
1395
+ function ls(n) {
1305
1396
  return de({
1306
1397
  settings: {
1307
1398
  type: "json",
@@ -1316,8 +1407,8 @@ function as(n) {
1316
1407
  });
1317
1408
  }
1318
1409
  class se {
1319
- constructor(e = z) {
1320
- this.req = e, this.api = Kt(e), this.uploader = zt(e);
1410
+ constructor(e = W) {
1411
+ this.req = e, this.api = zt(e), this.uploader = Vt(e);
1321
1412
  }
1322
1413
  api;
1323
1414
  pluginCaches = {};
@@ -1401,10 +1492,10 @@ class se {
1401
1492
  return await this.api("clearStaticFiles", e).catch(() => "");
1402
1493
  }
1403
1494
  async getPluginMaterial(e) {
1404
- const { urls: t = [] } = e, s = t.filter((i) => Qe(i))[0];
1495
+ const { urls: t = [] } = e, s = t.filter((i) => Ze(i))[0];
1405
1496
  if (!s) return null;
1406
1497
  const r = this.pluginCaches[s];
1407
- return r || (this.pluginCaches[s] = z.send({
1498
+ return r || (this.pluginCaches[s] = W.send({
1408
1499
  url: s,
1409
1500
  method: "get",
1410
1501
  settings: {
@@ -1417,12 +1508,12 @@ class se {
1417
1508
  return console.log("BaseService.genSource", e), "";
1418
1509
  }
1419
1510
  }
1420
- const g = new Ke({
1511
+ const g = new Ve({
1421
1512
  type: "local",
1422
1513
  expired: 0,
1423
1514
  prefix: "__VTJ_"
1424
1515
  });
1425
- class cs extends se {
1516
+ class us extends se {
1426
1517
  init(e) {
1427
1518
  const t = new N(e), s = g.get(`project_${t.id}`), r = Object.assign(t.toDsl(), s || {});
1428
1519
  return g.save(`project_${t.id}`, r), Promise.resolve(r);
@@ -1432,7 +1523,7 @@ class cs extends se {
1432
1523
  return g.save(`project_${t.id}`, t.toDsl()), Promise.resolve(!0);
1433
1524
  }
1434
1525
  saveMaterials(e, t) {
1435
- return g.save(`materials_${e.id}`, Z(t)), Promise.resolve(!0);
1526
+ return g.save(`materials_${e.id}`, te(t)), Promise.resolve(!0);
1436
1527
  }
1437
1528
  saveFile(e) {
1438
1529
  return g.save(`file_${e.id}`, e), Promise.resolve(!0);
@@ -1472,7 +1563,7 @@ class cs extends se {
1472
1563
  }), Promise.resolve(!0);
1473
1564
  }
1474
1565
  }
1475
- class Vt extends se {
1566
+ class Wt extends se {
1476
1567
  projects = {};
1477
1568
  materials = {};
1478
1569
  files = {};
@@ -1487,7 +1578,7 @@ class Vt extends se {
1487
1578
  return this.projects[t.id] = t.toDsl(), Promise.resolve(!0);
1488
1579
  }
1489
1580
  saveMaterials(e, t) {
1490
- return e.id && (this.materials[e.id] = Z(t)), Promise.resolve(!0);
1581
+ return e.id && (this.materials[e.id] = te(t)), Promise.resolve(!0);
1491
1582
  }
1492
1583
  saveFile(e) {
1493
1584
  return this.files[e.id] = e, Promise.resolve(!0);
@@ -1530,10 +1621,10 @@ class Vt extends se {
1530
1621
  }
1531
1622
  }
1532
1623
  let x = null;
1533
- function ls() {
1534
- return x || (x = new Vt(), x);
1624
+ function ps() {
1625
+ return x || (x = new Wt(), x);
1535
1626
  }
1536
- class us extends se {
1627
+ class fs extends se {
1537
1628
  getFileCaches = {};
1538
1629
  async getExtension() {
1539
1630
  return await this.api("getExtension", {}).catch(() => {
@@ -1550,7 +1641,7 @@ class us extends se {
1550
1641
  async saveMaterials(e, t) {
1551
1642
  return !!await this.api("saveMaterials", {
1552
1643
  project: e,
1553
- materials: Z(t)
1644
+ materials: te(t)
1554
1645
  }).catch(() => !1);
1555
1646
  }
1556
1647
  async saveFile(e) {
@@ -1590,7 +1681,7 @@ class us extends se {
1590
1681
  );
1591
1682
  }
1592
1683
  }
1593
- function ke(n, e, t = []) {
1684
+ function Ae(n, e, t = []) {
1594
1685
  return t.map((s) => {
1595
1686
  const { id: r, title: i, icon: a, children: o, hidden: c } = s;
1596
1687
  return {
@@ -1599,39 +1690,39 @@ function ke(n, e, t = []) {
1599
1690
  icon: a,
1600
1691
  hidden: c,
1601
1692
  url: `${n}/${e}/${r}`,
1602
- children: o && o.length ? ke(n, e, o) : void 0
1693
+ children: o && o.length ? Ae(n, e, o) : void 0
1603
1694
  };
1604
1695
  });
1605
1696
  }
1606
- function Fe(n, e) {
1697
+ function Ie(n, e) {
1607
1698
  if (!e) return n;
1608
1699
  let t = [];
1609
1700
  for (const s of n)
1610
1701
  if (s.children && s.children.length) {
1611
- const r = Fe(s.children, e);
1702
+ const r = Ie(s.children, e);
1612
1703
  r.length && (s.children = r, t.push(s));
1613
1704
  } else
1614
1705
  e.can(s.id.toString()) && t.push(s);
1615
1706
  return t;
1616
1707
  }
1617
- function ps(n) {
1708
+ function ds(n) {
1618
1709
  const {
1619
1710
  menuPathPrefix: e = "",
1620
1711
  pageRouteName: t = "page",
1621
1712
  disableMenusFilter: s = !1
1622
- } = n || {}, r = be(), i = ge(), a = lt(), o = W(!1), c = W(!1), l = r.project;
1623
- ze(() => {
1624
- const { name: m, params: f, meta: d } = i;
1713
+ } = n || {}, r = ke(), i = ge(), a = ut(), o = Y(!1), c = Y(!1), l = r.project;
1714
+ We(() => {
1715
+ const { name: m, params: d, meta: f } = i;
1625
1716
  if (m === I) {
1626
- const h = r.getPage(f.id);
1717
+ const h = r.getPage(d.id);
1627
1718
  o.value = !h?.mask, c.value = !!h?.pure;
1628
1719
  } else if (m === O) {
1629
1720
  const h = r.getHomepage();
1630
1721
  o.value = !h?.mask, c.value = !!h?.pure;
1631
1722
  } else
1632
- o.value = !d.mask, c.value = !!d.pure;
1723
+ o.value = !f.mask, c.value = !!f.pure;
1633
1724
  });
1634
- const u = ke(
1725
+ const u = Ae(
1635
1726
  e,
1636
1727
  t,
1637
1728
  l?.pages
@@ -1641,77 +1732,79 @@ function ps(n) {
1641
1732
  logo: p?.logo,
1642
1733
  themeSwitchable: p?.themeSwitchable,
1643
1734
  title: p?.title || l?.description || l?.name || "VTJ App",
1644
- menus: s ? u : Fe(u, a),
1735
+ menus: s ? u : Ie(u, a),
1645
1736
  pure: c
1646
1737
  };
1647
1738
  }
1648
1739
  export {
1649
- we as ACCESS_KEY,
1650
- Se as Access,
1651
- Ye as BUILD_IN_TAGS,
1652
- Ve as BUILT_IN_DIRECTIVES,
1740
+ $e as ACCESS_KEY,
1741
+ je as Access,
1742
+ Xe as BUILD_IN_TAGS,
1743
+ Ge as BUILT_IN_DIRECTIVES,
1653
1744
  se as BaseService,
1654
1745
  le as CONTEXT_HOST,
1655
- vt as Context,
1746
+ gt as Context,
1656
1747
  y as ContextMode,
1657
- We as DATA_TYPES,
1748
+ Ye as DATA_TYPES,
1658
1749
  O as HOMEPAGE_ROUTE_NAME,
1659
- Ge as HTML_TAGS,
1660
- ss as JSCodeToString,
1661
- Xt as LIFE_CYCLES_LIST,
1662
- us as LocalService,
1663
- Vt as MemoryService,
1664
- qt as NodeEnv,
1750
+ Qe as HTML_TAGS,
1751
+ ns as JSCodeToString,
1752
+ Zt as LIFE_CYCLES_LIST,
1753
+ fs as LocalService,
1754
+ Wt as MemoryService,
1755
+ Jt as NodeEnv,
1665
1756
  I as PAGE_ROUTE_NAME,
1666
- Jt as Provider,
1667
- cs as StorageService,
1757
+ Kt as Provider,
1758
+ us as StorageService,
1668
1759
  A as VTJ_RENDERER_VERSION,
1669
1760
  _e as adoptedStyleSheets,
1670
- is as clearLoaderCache,
1671
- rs as createAccess,
1672
- ns as createAdapter,
1673
- Zt as createAssetScripts,
1674
- es as createAssetsCss,
1761
+ os as clearLoaderCache,
1762
+ is as createAccess,
1763
+ rs as createAdapter,
1764
+ es as createAssetScripts,
1765
+ ts as createAssetsCss,
1675
1766
  Et as createDataSources,
1676
- Q as createLoader,
1677
- ls as createMemoryService,
1678
- pt as createMetaApi,
1679
- ht as createMock,
1680
- os as createProvider,
1681
- Y as createRenderer,
1682
- ut as createSchemaApi,
1683
- ft as createSchemaApis,
1684
- as as createServiceRequest,
1685
- Rt as defaultLoader,
1767
+ Z as createLoader,
1768
+ ps as createMemoryService,
1769
+ ft as createMetaApi,
1770
+ mt as createMock,
1771
+ as as createProvider,
1772
+ X as createRenderer,
1773
+ pt as createSchemaApi,
1774
+ dt as createSchemaApis,
1775
+ ls as createServiceRequest,
1776
+ bt as defaultLoader,
1686
1777
  D as fillBasePath,
1687
1778
  M as getMock,
1688
- Pe as getModifiers,
1689
- Ee as getPlugin,
1690
- et as getRawComponent,
1691
- it as isBuiltInTag,
1692
- ee as isCSSUrl,
1693
- at as isJSCode,
1779
+ be as getModifiers,
1780
+ Pe as getPlugin,
1781
+ st as getRawComponent,
1782
+ ot as isBuiltInTag,
1783
+ U as isCSSUrl,
1784
+ ct as isJSCode,
1694
1785
  w as isJSExpression,
1695
1786
  T as isJSFunction,
1696
- Qe as isJSON,
1697
- te as isJSUrl,
1698
- ot as isNativeTag,
1699
- rt as isVuePlugin,
1700
- tt as loadCss,
1701
- st as loadCssUrl,
1702
- nt as loadScriptUrl,
1703
- mt as mockApi,
1704
- dt as mockApis,
1705
- $e as mockCleanup,
1706
- k as nodeRender,
1707
- Ze as parseDeps,
1787
+ Ze as isJSON,
1788
+ L as isJSUrl,
1789
+ at as isNativeTag,
1790
+ it as isVuePlugin,
1791
+ rt as loadCss,
1792
+ we as loadCssUrl,
1793
+ cs as loadEnhance,
1794
+ Se as loadScriptUrl,
1795
+ vt as mockApi,
1796
+ ht as mockApis,
1797
+ Ee as mockCleanup,
1798
+ F as nodeRender,
1799
+ tt as parseDeps,
1708
1800
  H as parseExpression,
1709
- G as parseFunction,
1710
- Re as providerKey,
1711
- Xe as removeProdFlag,
1712
- ts as setupPageSetting,
1801
+ Q as parseFunction,
1802
+ nt as parseUrls,
1803
+ Ce as providerKey,
1804
+ et as removeProdFlag,
1805
+ ss as setupPageSetting,
1713
1806
  ye as toString,
1714
- lt as useAccess,
1715
- ps as useMask,
1716
- be as useProvider
1807
+ ut as useAccess,
1808
+ ds as useMask,
1809
+ ke as useProvider
1717
1810
  };