@vtj/renderer 0.7.34 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,22 +1,22 @@
1
- import { Base as ae, BUILT_IN_COMPONENTS as ce, ProjectModel as x, HistoryModel as W } from "@vtj/core";
2
- import { isUrl as ue, url as P, dedupArray as le, isString as F, isFunction as q, logger as O, createRequest as pe, merge as fe, pathToRegexp as me, pathToRegexpMatch as de, formDataToJson as he, camelCase as E, upperFirst as ve, pick as _e, jsonp as ye, loadScript as J, Request as ge, Storage as we, mapToObject as N } from "@vtj/utils";
1
+ import { Base as pe, BUILT_IN_COMPONENTS as fe, ProjectModel as x, HistoryModel as Z } from "@vtj/core";
2
+ import { isUrl as de, url as F, dedupArray as me, isString as C, isFunction as W, logger as O, createRequest as he, merge as ve, pathToRegexp as ye, pathToRegexpMatch as ge, formDataToJson as _e, camelCase as E, upperFirst as we, pick as Se, jsonp as $e, loadScript as X, Request as je, Storage as Ee, mapToObject as U } from "@vtj/utils";
3
3
  import * as k from "vue";
4
- import { defineComponent as X, h as D, inject as Se, ref as $e, watchEffect as je } from "vue";
5
- import { useRoute as Y } from "vue-router";
6
- import { ElNotification as B, ElLoading as Ee } from "element-plus";
7
- import M from "mockjs";
8
- import { useTitle as be } from "@vueuse/core";
9
- import { XStartup as Pe } from "@vtj/ui";
4
+ import { defineComponent as ee, h as A, inject as Pe, defineAsyncComponent as Y, ref as Fe, watchEffect as Ce } from "vue";
5
+ import { useRoute as te } from "vue-router";
6
+ import { ElNotification as q, ElLoading as be } from "element-plus";
7
+ import D from "mockjs";
8
+ import { useTitle as Re } from "@vueuse/core";
9
+ import { XStartup as Ie } from "@vtj/ui";
10
10
  /**!
11
11
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
12
12
  * @name @vtj/renderer
13
13
  * @author CHC chenhuachun1549@dingtalk.com
14
- * @version 0.7.34
14
+ * @version 0.8.0
15
15
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
16
16
  */
17
- const I = "0.7.34";
18
- var w = /* @__PURE__ */ ((r) => (r.Runtime = "Runtime", r.Design = "Design", r.Raw = "Raw", r.VNode = "VNode", r))(w || {});
19
- const L = [
17
+ const b = "0.8.0";
18
+ var _ = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(_ || {});
19
+ const z = [
20
20
  "$el",
21
21
  "$emit",
22
22
  "$nextTick",
@@ -28,7 +28,7 @@ const L = [
28
28
  "$props",
29
29
  "$options",
30
30
  "$forceUpdate"
31
- ], St = [
31
+ ], Ct = [
32
32
  "beforeCreate",
33
33
  "created",
34
34
  "beforeMount",
@@ -42,7 +42,7 @@ const L = [
42
42
  "renderTriggered",
43
43
  "activated",
44
44
  "deactivated"
45
- ], Fe = ["vIf", "vShow", "vModel", "vFor", "vBind"], Ie = {
45
+ ], He = ["vIf", "vShow", "vModel", "vFor", "vBind"], xe = {
46
46
  String,
47
47
  Number,
48
48
  Boolean,
@@ -51,179 +51,207 @@ const L = [
51
51
  Function,
52
52
  Date
53
53
  };
54
- function H(r, e) {
55
- return r.map((t) => ue(t) ? t : `${e}${t}`);
54
+ function I(n, e) {
55
+ return n.map((t) => de(t) ? t : `${e}${t}`);
56
56
  }
57
- function z(r) {
58
- return /\.css$/.test(r);
57
+ function J(n) {
58
+ return /\.css$/.test(n);
59
59
  }
60
- function G(r) {
61
- return /\.js$/.test(r);
60
+ function V(n) {
61
+ return /\.js$/.test(n);
62
62
  }
63
- function $t(r) {
64
- return r.map(
65
- (e) => `<script src="${P.append(e, { v: I })}"><\/script>`
63
+ function Oe(n) {
64
+ return /\.json$/.test(n);
65
+ }
66
+ function bt(n) {
67
+ return n.map(
68
+ (e) => `<script src="${F.append(e, { v: b })}"><\/script>`
66
69
  ).join("");
67
70
  }
68
- function jt(r = []) {
69
- return r.map(
70
- (e) => `<link rel="stylesheet" href="${P.append(e, { v: I })}" />`
71
+ function Rt(n = []) {
72
+ return n.map(
73
+ (e) => `<link rel="stylesheet" href="${F.append(e, { v: b })}" />`
71
74
  ).join("");
72
75
  }
73
- function Re(r, e) {
74
- const t = r.filter((f) => !!f.enabled), s = [], n = [], o = [], i = [], a = {}, u = [], c = {};
75
- return t.forEach(({ urls: f, assetsUrl: p, library: l, assetsLibrary: v }) => {
76
- f?.forEach((d) => {
77
- G(d) && s.push(d), z(d) && n.push(d);
78
- }), l && (i.push(l), a[l] = H(f || [], e)), p && o.push(p), v && u.push(v), l && v && (c[v] = l);
79
- }), {
80
- scripts: H(s, e),
81
- css: H(n, e),
82
- materials: H(o, e),
76
+ function De(n, e) {
77
+ const t = n.filter((f) => !!f.enabled), r = [], s = [], o = [], i = [], a = {}, l = {}, c = [], d = {};
78
+ return t.forEach(
79
+ ({ urls: f, assetsUrl: p, library: y, assetsLibrary: m, localeLibrary: h }) => {
80
+ f?.forEach((u) => {
81
+ V(u) && r.push(u), J(u) && s.push(u);
82
+ }), y && (i.push(y), a[y] = I(f || [], e), h && (l[y] = h)), p && o.push(p), m && c.push(m), y && m && (d[m] = y);
83
+ }
84
+ ), {
85
+ scripts: I(r, e),
86
+ css: I(s, e),
87
+ materials: I(o, e),
83
88
  libraryExports: i,
84
- materialExports: le(u),
85
- materialMapLibrary: c,
86
- libraryMap: a
89
+ materialExports: me(c),
90
+ materialMapLibrary: d,
91
+ libraryMap: a,
92
+ libraryLocaleMap: l
87
93
  };
88
94
  }
89
- function He(r, e) {
90
- const { name: t, parent: s, alias: n } = r;
91
- return s ? e[s]?.[n || t] : e[n || t];
95
+ function Me(n, e) {
96
+ const { name: t, parent: r, alias: s } = n;
97
+ return r ? e[r]?.[s || t] : e[s || t];
92
98
  }
93
- function Q(r) {
94
- return F(r) ? r : JSON.stringify(r);
99
+ function re(n) {
100
+ return C(n) ? n : JSON.stringify(n);
95
101
  }
96
- function Z(r, e, t) {
97
- const s = r.CSSStyleSheet;
98
- if (s.prototype.replaceSync) {
99
- const n = new s();
100
- n.id = e, n.replaceSync(t);
101
- const o = r.document, i = o.adoptedStyleSheets, a = Array.from(i).filter(
102
- (u) => u.id !== e
102
+ function ne(n, e, t) {
103
+ const r = n.CSSStyleSheet;
104
+ if (r.prototype.replaceSync) {
105
+ const s = new r();
106
+ s.id = e, s.replaceSync(t);
107
+ const o = n.document, i = o.adoptedStyleSheets, a = Array.from(i).filter(
108
+ (l) => l.id !== e
103
109
  );
104
- o.adoptedStyleSheets = [...a, n];
110
+ o.adoptedStyleSheets = [...a, s];
105
111
  } else {
106
- const n = r.document;
107
- let o = n.getElementById(e);
108
- o ? o.innerHTML = t : (o = n.createElement("style"), o.id = e, o.innerHTML = t, n.head.appendChild(o));
112
+ const s = n.document;
113
+ let o = s.getElementById(e);
114
+ o ? o.innerHTML = t : (o = s.createElement("style"), o.id = e, o.innerHTML = t, s.head.appendChild(o));
109
115
  }
110
116
  }
111
- async function Ce(r, e) {
112
- const t = await window.fetch(e).then((s) => s.text()).catch(() => "");
113
- t && Z(window, r, t);
117
+ async function ke(n, e) {
118
+ const t = await window.fetch(e).then((r) => r.text()).catch(() => "");
119
+ t && ne(window, n, t);
120
+ }
121
+ function se(n, e = window) {
122
+ const t = e.document, r = e.document.head;
123
+ for (const s of n)
124
+ if (!t.getElementById(s)) {
125
+ const i = t.createElement("link");
126
+ i.rel = "stylesheet", i.id = s, i.href = s, r.appendChild(i);
127
+ }
128
+ }
129
+ async function Te(n, e, t = window) {
130
+ const r = t.document, s = t.document.head;
131
+ let o = t[e];
132
+ return o ? o.default || o : new Promise((i, a) => {
133
+ for (const l of n) {
134
+ const c = r.createElement("script");
135
+ c.src = l, c.onload = () => {
136
+ o = t[e], o && i(o.default || o);
137
+ }, c.onerror = (d) => {
138
+ a(d);
139
+ }, s.appendChild(c);
140
+ }
141
+ });
114
142
  }
115
- function xe(r) {
116
- return q(r) || q(r?.install);
143
+ function Ae(n) {
144
+ return W(n) || W(n?.install);
117
145
  }
118
- function R(r, e, t = !1, s = !1) {
146
+ function R(n, e, t = !1, r = !1) {
119
147
  try {
120
- const n = ['"use strict";', "var __self = arguments[0];"];
121
- n.push("return ");
122
- let o = (r.value || "").trim();
123
- o = o.replace(/this(\W|$)/g, (a, u) => `__self${u}`), o = n.join(`
148
+ const s = ['"use strict";', "var __self = arguments[0];"];
149
+ s.push("return ");
150
+ let o = (n.value || "").trim();
151
+ o = o.replace(/this(\W|$)/g, (a, l) => `__self${l}`), o = s.join(`
124
152
  `) + o;
125
153
  const i = `with(${t ? "{}" : "$scope || {}"}) { ${o} }`;
126
154
  return new Function("$scope", i)(e);
127
- } catch (n) {
128
- if (O.error("parseExpression.error", n, r, e?.__self ?? e), s)
129
- throw n;
155
+ } catch (s) {
156
+ if (O.error("parseExpression.error", s, n, e?.__self ?? e), r)
157
+ throw s;
130
158
  }
131
159
  }
132
- function U(r, e, t = !1, s = !1) {
133
- const n = R(r, e, t, s);
134
- if (typeof n != "function" && (O.error(
160
+ function G(n, e, t = !1, r = !1) {
161
+ const s = R(n, e, t, r);
162
+ if (typeof s != "function" && (O.error(
135
163
  "parseFunction.error",
136
164
  "not a function",
137
- r,
165
+ n,
138
166
  e?.__self ?? e
139
- ), s))
140
- throw new Error(`"${r.value}" not a function`);
141
- return n;
167
+ ), r))
168
+ throw new Error(`"${n.value}" not a function`);
169
+ return s;
142
170
  }
143
- function g(r) {
144
- return r && r.type === "JSExpression";
171
+ function w(n) {
172
+ return n && n.type === "JSExpression";
145
173
  }
146
- function A(r) {
147
- return typeof r == "object" && r && r.type === "JSFunction";
174
+ function T(n) {
175
+ return typeof n == "object" && n && n.type === "JSFunction";
148
176
  }
149
- function Oe(r) {
150
- return g(r) || A(r);
177
+ function Be(n) {
178
+ return w(n) || T(n);
151
179
  }
152
- function Et(r) {
153
- return Oe(r) ? r.value : JSON.stringify(r);
180
+ function It(n) {
181
+ return Be(n) ? n.value : JSON.stringify(n);
154
182
  }
155
- let b = null;
156
- const Me = pe({
183
+ let P = null;
184
+ const Ne = he({
157
185
  settings: {
158
186
  type: "form",
159
187
  validSuccess: !0,
160
188
  originResponse: !1,
161
189
  loading: !0,
162
- validate: (r) => r.data?.code === 0 || !!r.data?.success,
190
+ validate: (n) => n.data?.code === 0 || !!n.data?.success,
163
191
  failMessage: !0,
164
- showError: (r) => {
165
- B.error({
166
- message: r || "未知错误"
192
+ showError: (n) => {
193
+ q.error({
194
+ message: n || "未知错误"
167
195
  });
168
196
  },
169
197
  showLoading: () => {
170
- b && b.close(), b = Ee.service({
198
+ P && P.close(), P = be.service({
171
199
  lock: !0,
172
200
  text: "Loading",
173
201
  background: "rgba(0, 0, 0, 0.05)"
174
202
  });
175
203
  },
176
204
  hideLoading: () => {
177
- b && (b.close(), b = null);
205
+ P && (P.close(), P = null);
178
206
  }
179
207
  }
180
208
  });
181
- function Te(r, e) {
182
- const { jsonp: t, request: s } = e;
183
- if (r.method === "jsonp")
184
- return (n = {}) => t(r.url, {
185
- ...r.jsonpOptions,
186
- query: n
209
+ function Ue(n, e) {
210
+ const { jsonp: t, request: r } = e;
211
+ if (n.method === "jsonp")
212
+ return (s = {}) => t(n.url, {
213
+ ...n.jsonpOptions,
214
+ query: s
187
215
  });
188
216
  {
189
- const n = r.headers ? R(r.headers, {}, !0) : void 0, o = {
190
- url: r.url,
191
- method: r.method,
217
+ const s = n.headers ? R(n.headers, {}, !0) : void 0, o = {
218
+ url: n.url,
219
+ method: n.method,
192
220
  settings: {
193
- ...r.settings,
194
- headers: n
221
+ ...n.settings,
222
+ headers: s
195
223
  }
196
224
  };
197
- return (i, a) => s.send(fe(o, a || {}, { data: i }));
225
+ return (i, a) => r.send(ve(o, a || {}, { data: i }));
198
226
  }
199
227
  }
200
- function ke(r = [], e) {
201
- return r.reduce(
202
- (t, s) => (t[s.id] = Te(s, e), t),
228
+ function qe(n = [], e) {
229
+ return n.reduce(
230
+ (t, r) => (t[r.id] = Ue(r, e), t),
203
231
  {}
204
232
  );
205
233
  }
206
- function Ae(r = []) {
207
- M.setup({
234
+ function Je(n = []) {
235
+ D.setup({
208
236
  timeout: "50-500"
209
- }), ee(), r.forEach((e) => De(e));
237
+ }), oe(), n.forEach((e) => Ve(e));
210
238
  }
211
- function De(r) {
212
- if (!r.mock)
239
+ function Ve(n) {
240
+ if (!n.mock)
213
241
  return;
214
- const { url: e, mockTemplate: t } = r;
242
+ const { url: e, mockTemplate: t } = n;
215
243
  if (e && t) {
216
- const s = me(`${e}(.*)`), n = de(e, { decode: decodeURIComponent }), o = R(t, {}, !0);
217
- M.mock(s, (i) => {
218
- const a = P.parse(i.url) || {}, u = i.body instanceof FormData ? he(i.body) : i.body, c = n(i.url)?.params;
219
- return Object.assign(i, { data: u, params: a, query: c }), M.mock(o(i));
244
+ const r = ye(`${e}(.*)`), s = ge(e, { decode: decodeURIComponent }), o = R(t, {}, !0);
245
+ D.mock(r, (i) => {
246
+ const a = F.parse(i.url) || {}, l = i.body instanceof FormData ? _e(i.body) : i.body, c = s(i.url)?.params;
247
+ return Object.assign(i, { data: l, params: a, query: c }), D.mock(o(i));
220
248
  });
221
249
  }
222
250
  }
223
- function ee() {
224
- M._mocked = {};
251
+ function oe() {
252
+ D._mocked = {};
225
253
  }
226
- class Ne {
254
+ class Le {
227
255
  __id = null;
228
256
  __mode;
229
257
  __instance = null;
@@ -248,113 +276,113 @@ class Ne {
248
276
  $apis = {};
249
277
  __transform = {};
250
278
  constructor(e) {
251
- const { mode: t, dsl: s, attrs: n } = e;
252
- this.__mode = t, s && (this.__id = s.id || null, this.__transform = s.transform || {}), n && Object.assign(this, n);
279
+ const { mode: t, dsl: r, attrs: s } = e;
280
+ this.__mode = t, r && (this.__id = r.id || null, this.__transform = r.transform || {}), s && Object.assign(this, s);
253
281
  }
254
282
  setup(e, t = k) {
255
- const s = t.getCurrentInstance();
256
- if (!s)
283
+ const r = t.getCurrentInstance();
284
+ if (!r)
257
285
  return;
258
- this.__instance = s.proxy;
259
- const n = s.appContext.config.globalProperties;
260
- Object.assign(this, n), Object.assign(this, e || {}), this.__proxy(), t.onMounted(() => {
286
+ this.__instance = r.proxy;
287
+ const s = r.appContext.config.globalProperties;
288
+ Object.assign(this, s), Object.assign(this, e || {}), this.__proxy(), t.onMounted(() => {
261
289
  this.__proxy();
262
290
  }), t.onUnmounted(() => {
263
291
  this.__cleanup();
264
292
  });
265
293
  }
266
294
  __proxy() {
267
- this.__instance && L.forEach((e) => {
295
+ this.__instance && z.forEach((e) => {
268
296
  this[e] = this.__instance?.[e];
269
297
  });
270
298
  }
271
299
  __cleanup() {
272
- L.forEach((e) => {
300
+ z.forEach((e) => {
273
301
  this[e] = null;
274
302
  });
275
303
  }
276
304
  __parseFunction(e) {
277
305
  if (e)
278
- if (this.__mode === w.Runtime) {
279
- const { id: t, type: s } = e, n = t ? this.__transform[t] ?? e.value : e.value;
280
- return U({ type: s, value: n }, this);
306
+ if (this.__mode === _.Runtime) {
307
+ const { id: t, type: r } = e, s = t ? this.__transform[t] ?? e.value : e.value;
308
+ return G({ type: r, value: s }, this);
281
309
  } else
282
- return U(e, this);
310
+ return G(e, this);
283
311
  }
284
312
  __parseExpression(e) {
285
313
  if (e)
286
- if (this.__mode === w.Runtime) {
287
- const { id: t, type: s } = e, n = t ? this.__transform[t] ?? e.value : e.value;
288
- return R({ type: s, value: n }, this);
314
+ if (this.__mode === _.Runtime) {
315
+ const { id: t, type: r } = e, s = t ? this.__transform[t] ?? e.value : e.value;
316
+ return R({ type: r, value: s }, this);
289
317
  } else
290
318
  return R(e, this);
291
319
  }
292
320
  __ref(e = null, t) {
293
- if (this.__mode !== w.VNode)
294
- return e && e !== this.__id && (this.__contextRefs[e] = this), (s) => {
295
- let n = s?.$vtjEl || s?.$el || s;
296
- if (!n) {
321
+ if (this.__mode !== _.VNode)
322
+ return e && e !== this.__id && (this.__contextRefs[e] = this), (r) => {
323
+ let s = r?.$vtjEl || r?.$el || r;
324
+ if (!s) {
297
325
  typeof t == "string" && (delete this.$refs[t], e && delete this.__refs[e]);
298
326
  return;
299
327
  }
300
- if (n.__vtj__ = e, n.nodeType === 3 && n.nextSibling && (n = n.nextSibling), w.Design === this.__mode && (n.__context__ = this), e && (this.__refs[e] = s), typeof t == "function")
301
- t(s);
328
+ if (s.nodeType === 3 && s.nextSibling && (s = s.nextSibling), s.__vtj__ = e, _.Design === this.__mode && (s.__context__ = this), e && (this.__refs[e] = r), typeof t == "function")
329
+ t(r);
302
330
  else if (t) {
303
331
  const o = this.$refs[t];
304
332
  if (o) {
305
- const i = new Set([].concat(o, s));
333
+ const i = new Set([].concat(o, r));
306
334
  this.$refs[t] = Array.from(i);
307
335
  } else
308
- this.$refs[t] = s;
336
+ this.$refs[t] = r;
309
337
  }
310
- return s;
338
+ return r;
311
339
  };
312
340
  }
313
341
  __clone(e = {}) {
314
- const t = { ...this.context, ...e }, s = {
342
+ const t = { ...this.context, ...e }, r = {
315
343
  ...t,
316
344
  context: t
317
345
  };
318
- return s.context.__proto__ = this.context, s.__proto__ = this, s;
346
+ return r.context.__proto__ = this.context, r.__proto__ = this, r;
319
347
  }
320
348
  }
321
- function te(r) {
349
+ function B(n) {
322
350
  const {
323
351
  Vue: e = k,
324
- mode: t = w.Runtime,
325
- components: s = {},
326
- libs: n = {},
352
+ mode: t = _.Runtime,
353
+ components: r = {},
354
+ libs: s = {},
327
355
  apis: o = {},
328
356
  loader: i
329
- } = r, a = e.computed(() => r.dsl), u = {
330
- $components: s,
331
- $libs: n,
357
+ } = n, a = e.computed(() => n.dsl), l = {
358
+ $components: r,
359
+ $libs: s,
332
360
  $apis: o
333
- }, c = new Ne({
361
+ }, c = new Le({
334
362
  mode: t,
335
363
  dsl: a.value,
336
- attrs: u
337
- }), f = e.defineComponent({
364
+ attrs: l
365
+ }), d = e.defineComponent({
338
366
  name: a.value.name,
339
367
  props: {
340
- ...Be(a.value.props ?? [], c)
368
+ ...Ke(a.value.props ?? [], c)
341
369
  },
342
- setup(p) {
343
- c.$props = p, a.value.id && Z(
344
- r.window || window,
370
+ setup(f) {
371
+ c.$props = f, a.value.id && ne(
372
+ n.window || window,
345
373
  a.value.id,
346
374
  a.value.css || ""
347
- ), c.state = Ve(e, a.value.state ?? {}, c);
348
- const l = qe(e, a.value.computed ?? {}, c), v = Je(a.value.methods ?? {}, c), d = Le(e, a.value.inject, c), y = Ue(
375
+ ), c.state = We(e, a.value.state ?? {}, c);
376
+ const p = Xe(e, a.value.computed ?? {}, c), y = Ye(a.value.methods ?? {}, c), m = ze(e, a.value.inject, c), h = Ge(
349
377
  a.value.dataSources || {},
350
378
  c
351
- ), m = {
352
- ...d,
353
- ...l,
354
- ...v,
355
- ...y
379
+ ), u = {
380
+ ...m,
381
+ ...p,
382
+ ...y,
383
+ ...h
356
384
  };
357
- return c.setup(m, e), Ke(e, a.value.watch ?? [], c), {
385
+ return c.setup(u, e), Qe(e, a.value.watch ?? [], c), {
358
386
  vtj: c
359
387
  };
360
388
  },
@@ -363,288 +391,314 @@ function te(r) {
363
391
  render() {
364
392
  if (!a.value.nodes)
365
393
  return null;
366
- const p = a.value.nodes || [];
367
- return p.length === 1 ? T(p[0], c, e, i) : p.map((l) => T(l, c, e, i));
394
+ const f = a.value.nodes || [];
395
+ return f.length === 1 ? M(f[0], c, e, i) : f.map((p) => M(p, c, e, i));
368
396
  },
369
- ...We(a.value.lifeCycles ?? {}, c)
397
+ ...Ze(a.value.lifeCycles ?? {}, c)
370
398
  });
371
399
  return {
372
- renderer: e.markRaw(f),
400
+ renderer: e.markRaw(d),
373
401
  context: c
374
402
  };
375
403
  }
376
- function Be(r = [], e) {
377
- const t = (s) => s ? (Array.isArray(s) ? s : [s]).map((o) => Ie[o]) : void 0;
378
- return r.map((s) => F(s) ? {
379
- name: s
404
+ function Ke(n = [], e) {
405
+ const t = (r) => r ? (Array.isArray(r) ? r : [r]).map((o) => xe[o]) : void 0;
406
+ return n.map((r) => C(r) ? {
407
+ name: r
380
408
  } : {
381
- name: s.name,
382
- type: s.type,
383
- required: s.required,
384
- default: g(s.default) ? e.__parseExpression(s.default) : s.default
409
+ name: r.name,
410
+ type: r.type,
411
+ required: r.required,
412
+ default: w(r.default) ? e.__parseExpression(r.default) : r.default
385
413
  }).reduce(
386
- (s, n) => (s[n.name] = {
387
- type: t(n.type),
388
- required: n.required,
389
- default: n.default
390
- }, s),
414
+ (r, s) => (r[s.name] = {
415
+ type: t(s.type),
416
+ required: s.required,
417
+ default: s.default
418
+ }, r),
391
419
  {}
392
420
  );
393
421
  }
394
- function Ve(r, e, t) {
395
- return r.reactive(
422
+ function We(n, e, t) {
423
+ return n.reactive(
396
424
  Object.keys(e || {}).reduce(
397
- (s, n) => {
398
- let o = e[n];
399
- return g(o) ? o = t.__parseExpression(o) : A(o) && (o = t.__parseFunction(o)), s[n] = o, s;
425
+ (r, s) => {
426
+ let o = e[s];
427
+ return w(o) ? o = t.__parseExpression(o) : T(o) && (o = t.__parseFunction(o)), r[s] = o, r;
400
428
  },
401
429
  {}
402
430
  )
403
431
  );
404
432
  }
405
- function qe(r, e, t) {
433
+ function Xe(n, e, t) {
406
434
  return Object.entries(e ?? {}).reduce(
407
- (s, [n, o]) => (s[n] = r.computed(t.__parseFunction(o)), s),
435
+ (r, [s, o]) => (r[s] = n.computed(t.__parseFunction(o)), r),
408
436
  {}
409
437
  );
410
438
  }
411
- function Je(r, e) {
412
- return Object.entries(r ?? {}).reduce(
413
- (t, [s, n]) => (t[s] = e.__parseFunction(n), t),
439
+ function Ye(n, e) {
440
+ return Object.entries(n ?? {}).reduce(
441
+ (t, [r, s]) => (t[r] = e.__parseFunction(s), t),
414
442
  {}
415
443
  );
416
444
  }
417
- function Le(r, e = [], t) {
445
+ function ze(n, e = [], t) {
418
446
  return e.reduce(
419
- (s, n) => {
420
- const { name: o, from: i } = n || {};
421
- n.default;
422
- const a = g(i) ? t.__parseExpression(i) || o : i ?? o, u = g(n.default) ? t.__parseExpression(n.default) : n.default ?? null;
423
- return s[o] = r.inject(a, u), s;
447
+ (r, s) => {
448
+ const { name: o, from: i } = s || {};
449
+ s.default;
450
+ const a = w(i) ? t.__parseExpression(i) || o : i ?? o, l = w(s.default) ? t.__parseExpression(s.default) : s.default ?? null;
451
+ return r[o] = n.inject(a, l), r;
424
452
  },
425
453
  {}
426
454
  );
427
455
  }
428
- function Ue(r, e) {
429
- return Object.keys(r).reduce(
430
- (t, s) => {
431
- const n = r[s], o = e.$apis[n.ref], i = A(n.transform) ? n.transform.value ? e.__parseFunction(n.transform) : void 0 : n.transform;
432
- return t[s] = async (...a) => {
433
- const u = await o.apply(e, a);
434
- return i ? i(u) : u;
456
+ function Ge(n, e) {
457
+ return Object.keys(n).reduce(
458
+ (t, r) => {
459
+ const s = n[r], o = e.$apis[s.ref], i = T(s.transform) ? s.transform.value ? e.__parseFunction(s.transform) : void 0 : s.transform;
460
+ return t[r] = async (...a) => {
461
+ const l = await o.apply(e, a);
462
+ return i ? i(l) : l;
435
463
  }, t;
436
464
  },
437
465
  {}
438
466
  );
439
467
  }
440
- function Ke(r, e = [], t) {
441
- e.forEach((s) => {
442
- r.watch(
443
- t.__parseExpression(s.source),
444
- t.__parseFunction(s.handler),
468
+ function Qe(n, e = [], t) {
469
+ e.forEach((r) => {
470
+ n.watch(
471
+ t.__parseExpression(r.source),
472
+ t.__parseFunction(r.handler),
445
473
  {
446
- deep: s.deep,
447
- immediate: s.immediate
474
+ deep: r.deep,
475
+ immediate: r.immediate
448
476
  }
449
477
  );
450
478
  });
451
479
  }
452
- function We(r, e) {
453
- return Object.entries(r ?? {}).reduce(
454
- (t, [s, n]) => (t[s] = e.__parseFunction(n), t),
480
+ function Ze(n, e) {
481
+ return Object.entries(n ?? {}).reduce(
482
+ (t, [r, s]) => (t[r] = e.__parseFunction(s), t),
455
483
  {}
456
484
  );
457
485
  }
458
- const Xe = (r) => r;
459
- function re(r) {
460
- const { getDsl: e, options: t } = r;
461
- return (s, n, o = k) => !n || typeof n == "string" ? s : n.type === "Schema" ? o.defineAsyncComponent(async () => {
462
- const i = await e(n.id);
463
- return i ? te({
464
- ...t,
465
- Vue: o,
466
- dsl: i,
467
- mode: w.Runtime,
468
- loader: re(r)
486
+ const et = (n) => n;
487
+ async function ie(n, e = window) {
488
+ const { urls: t = [], library: r } = n, s = t.filter((l) => V(l));
489
+ if (s.length === 0 || !r)
490
+ return null;
491
+ const o = t.filter((l) => J(l));
492
+ let i;
493
+ const a = await Te(s, r, e).catch(
494
+ () => null
495
+ );
496
+ return a?.plugin && (i = a.plugin), i ? {
497
+ component: i,
498
+ css: o
499
+ } : null;
500
+ }
501
+ function N(n) {
502
+ const { getDsl: e, getDslByUrl: t, options: r } = n;
503
+ return (s, o, i = k) => !o || typeof o == "string" ? s : o.type === "Schema" && o.id ? i.defineAsyncComponent(async () => {
504
+ const a = await e(o.id);
505
+ return a && (a.name = s), a ? B({
506
+ ...r,
507
+ Vue: i,
508
+ dsl: a,
509
+ mode: _.Runtime,
510
+ loader: N(n)
511
+ }).renderer : null;
512
+ }) : o.type === "UrlSchema" && o.url ? i.defineAsyncComponent(async () => {
513
+ const a = await t(o.url);
514
+ return a && (a.name = s), a ? B({
515
+ ...r,
516
+ Vue: i,
517
+ dsl: a,
518
+ mode: _.Runtime,
519
+ loader: N(n)
469
520
  }).renderer : null;
521
+ }) : o.type === "Plugin" ? i.defineAsyncComponent(async () => {
522
+ const a = await ie(o, r.window);
523
+ return a ? (se(a.css), a.component) : null;
470
524
  }) : s;
471
525
  }
472
- function T(r, e, t = k, s = Xe) {
473
- if (!r || !r.name || r.invisible)
526
+ function M(n, e, t = k, r = et) {
527
+ if (!n || !n.name || n.invisible)
474
528
  return null;
475
- const { id: n = null, directives: o = [] } = r, { vIf: i, vFor: a, vShow: u, vModels: c, vBind: f } = Ye(o);
476
- if (i && !ze(i, e))
529
+ const { id: s = null, directives: o = [] } = n, { vIf: i, vFor: a, vShow: l, vModels: c, vBind: d } = tt(o);
530
+ if (i && !rt(i, e))
477
531
  return null;
478
- const p = (l) => {
479
- const v = l.$components, d = (() => {
480
- if (r.name === "component")
481
- return Ge(l, r.props?.is);
482
- if (r.name === "slot")
483
- return r.name;
484
- const _ = s(r.name, r.from, t);
485
- return F(_) ? v[_] ?? _ : _;
486
- })(), y = Qe(n, r.props ?? {}, l), m = Ze(t, r.events ?? {}, l);
487
- if (r.name === "slot")
488
- return et(t, r, y, l);
489
- f && Object.assign(y, l.__parseExpression(f.value)), u && (y.style = Object.assign(
490
- y.style ?? {},
491
- rt(u, l)
492
- )), c.forEach((_) => {
493
- Object.assign(y, st(t, _, l));
532
+ const f = (p) => {
533
+ const y = p.$components, m = (() => {
534
+ if (n.name === "component")
535
+ return nt(p, n.props?.is);
536
+ if (n.name === "slot")
537
+ return n.name;
538
+ const g = r(n.name, n.from, t);
539
+ return C(g) ? y[g] ?? g : g;
540
+ })(), h = st(s, n.props ?? {}, p), u = ot(t, n.events ?? {}, p);
541
+ if (n.name === "slot")
542
+ return it(t, n, h, p);
543
+ d && Object.assign(h, p.__parseExpression(d.value)), l && (h.style = Object.assign(
544
+ h.style ?? {},
545
+ ct(l, p)
546
+ )), c.forEach((g) => {
547
+ Object.assign(h, lt(t, g, p));
494
548
  });
495
- const S = nt(t, r.children ?? [], l, r);
496
- return t.createVNode(d, { ...y, ...m }, S);
549
+ const S = ut(t, n.children ?? [], p, n);
550
+ return t.createVNode(m, { ...h, ...u }, S);
497
551
  };
498
- return a ? at(a, p, e) : p(e);
552
+ return a ? dt(a, f, e) : f(e);
499
553
  }
500
- function Ye(r = []) {
501
- const e = r.find((a) => E(a.name) === "vIf"), t = r.find((a) => E(a.name) === "vFor"), s = r.find((a) => E(a.name) === "vShow"), n = r.find((a) => E(a.name) === "vBind"), o = r.filter((a) => E(a.name) === "vModel"), i = r.filter(
502
- (a) => !Fe.includes(E(a.name))
554
+ function tt(n = []) {
555
+ const e = n.find((a) => E(a.name) === "vIf"), t = n.find((a) => E(a.name) === "vFor"), r = n.find((a) => E(a.name) === "vShow"), s = n.find((a) => E(a.name) === "vBind"), o = n.filter((a) => E(a.name) === "vModel"), i = n.filter(
556
+ (a) => !He.includes(E(a.name))
503
557
  );
504
558
  return {
505
559
  vIf: e,
506
560
  vFor: t,
507
- vShow: s,
561
+ vShow: r,
508
562
  vModels: o,
509
- vBind: n,
563
+ vBind: s,
510
564
  others: i
511
565
  };
512
566
  }
513
- function ze(r, e) {
514
- return !!e.__parseExpression(r.value);
567
+ function rt(n, e) {
568
+ return !!e.__parseExpression(n.value);
515
569
  }
516
- function Ge(r, e) {
517
- return e ? g(e) ? r.__parseExpression(e) : e : "div";
570
+ function nt(n, e) {
571
+ return e ? w(e) ? n.__parseExpression(e) : e : "div";
518
572
  }
519
- function Qe(r, e, t) {
520
- const s = Object.keys(e || {}).reduce(
521
- (n, o) => {
573
+ function st(n, e, t) {
574
+ const r = Object.keys(e || {}).reduce(
575
+ (s, o) => {
522
576
  let i = e[o];
523
- return g(i) ? i = t.__parseExpression(i) : A(i) && (i = t.__parseFunction(i)), n[o] = i, n;
577
+ return w(i) ? i = t.__parseExpression(i) : T(i) && (i = t.__parseFunction(i)), s[o] = i, s;
524
578
  },
525
579
  {}
526
580
  );
527
- return s.ref = t.__ref(r, s.ref), s;
581
+ return r.ref = t.__ref(n, r.ref), r;
528
582
  }
529
- function Ze(r, e, t) {
530
- const s = ["passive", "capture", "once"], n = {
583
+ function ot(n, e, t) {
584
+ const r = ["passive", "capture", "once"], s = {
531
585
  capture: "Capture",
532
586
  once: "Once",
533
587
  passive: "OnceCapture"
534
588
  };
535
589
  return Object.keys(e || {}).reduce(
536
590
  (o, i) => {
537
- const a = e[i], u = se(a.modifiers), c = u.find((l) => s.includes(l)), f = "on" + ve(i) + (c && n[c] || ""), p = t.__parseFunction(a.handler);
538
- return p && (o[f] = r.withModifiers(p, u)), o;
591
+ const a = e[i], l = ae(a.modifiers), c = l.find((p) => r.includes(p)), d = "on" + we(i) + (c && s[c] || ""), f = t.__parseFunction(a.handler);
592
+ return f && (o[d] = n.withModifiers(f, l)), o;
539
593
  },
540
594
  {}
541
595
  );
542
596
  }
543
- function se(r = {}, e = !1) {
544
- const t = Object.keys(r);
545
- return e ? t.map((s) => "." + s) : t;
597
+ function ae(n = {}, e = !1) {
598
+ const t = Object.keys(n);
599
+ return e ? t.map((r) => "." + r) : t;
546
600
  }
547
- function et(r, e, t, s) {
548
- const { children: n } = e, o = tt(e, s), i = s.$slots?.[o.name];
549
- return i ? i(t) : n ? F(n) ? r.createTextVNode(n) : g(n) ? r.createTextVNode(
550
- Q(s.__parseExpression(n))
551
- ) : Array.isArray(n) ? n.map((a) => T(a, s, r)) : null : null;
601
+ function it(n, e, t, r) {
602
+ const { children: s } = e, o = at(e, r), i = r.$slots?.[o.name];
603
+ return i ? i(t) : s ? C(s) ? n.createTextVNode(s) : w(s) ? n.createTextVNode(
604
+ re(r.__parseExpression(s))
605
+ ) : Array.isArray(s) ? s.map((a) => M(a, r, n)) : null : null;
552
606
  }
553
- function tt(r, e) {
554
- const { props: t } = r, s = t?.name || "default";
607
+ function at(n, e) {
608
+ const { props: t } = n, r = t?.name || "default";
555
609
  return {
556
- name: g(s) ? e.__parseExpression(s) : s,
610
+ name: w(r) ? e.__parseExpression(r) : r,
557
611
  params: []
558
612
  };
559
613
  }
560
- function rt(r, e) {
561
- return e.__parseExpression(r.value) ? {} : {
614
+ function ct(n, e) {
615
+ return e.__parseExpression(n.value) ? {} : {
562
616
  display: "none"
563
617
  };
564
618
  }
565
- function st(r, e, t) {
566
- const s = {
619
+ function lt(n, e, t) {
620
+ const r = {
567
621
  type: "JSFunction",
568
622
  value: e.value?.value ? `(v) => {
569
623
  ${e.value.value} = v;
570
624
  }` : "(v) => {}"
571
- }, n = t.__parseFunction(s), o = se(e.modifiers), i = g(e.arg) ? t.__parseExpression(e.arg) : e.arg || "modelValue";
625
+ }, s = t.__parseFunction(r), o = ae(e.modifiers), i = w(e.arg) ? t.__parseExpression(e.arg) : e.arg || "modelValue";
572
626
  return {
573
627
  [i]: t.__parseExpression(e.value),
574
- [`onUpdate:${i}`]: o.length && n ? r.withModifiers(n, o) : n
628
+ [`onUpdate:${i}`]: o.length && s ? n.withModifiers(s, o) : s
575
629
  };
576
630
  }
577
- function nt(r, e, t, s) {
631
+ function ut(n, e, t, r) {
578
632
  if (!e)
579
633
  return null;
580
- if (F(e))
634
+ if (C(e))
581
635
  return { default: () => e };
582
- if (g(e))
636
+ if (w(e))
583
637
  return {
584
- default: () => Q(t.__parseExpression(e))
638
+ default: () => re(t.__parseExpression(e))
585
639
  };
586
640
  if (Array.isArray(e) && e.length > 0) {
587
- const n = ot(e), o = (i) => !i || !s ? {} : s?.id && Object.keys(i).length ? {
588
- [`scope_${s.id}`]: i
641
+ const s = pt(e), o = (i) => !i || !r ? {} : r?.id && Object.keys(i).length ? {
642
+ [`scope_${r.id}`]: i
589
643
  } : {};
590
- return Object.entries(n).reduce((i, [a, { nodes: u, params: c }]) => (i[a] = (f) => {
591
- const p = c.length ? _e(f ?? {}, c) : o(f);
592
- return u.map(
593
- (l) => T(l, t.__clone(p), r)
644
+ return Object.entries(s).reduce((i, [a, { nodes: l, params: c }]) => (i[a] = (d) => {
645
+ const f = c.length ? Se(d ?? {}, c) : o(d);
646
+ return l.map(
647
+ (p) => M(p, t.__clone(f), n)
594
648
  );
595
649
  }, i), {});
596
650
  }
597
651
  return null;
598
652
  }
599
- function ot(r) {
653
+ function pt(n) {
600
654
  const e = {
601
655
  default: {
602
656
  params: [],
603
657
  nodes: []
604
658
  }
605
659
  };
606
- for (const t of r) {
607
- const s = it(t.slot), n = s.name;
608
- e[n] ? (e[n].nodes.push(t), e[n].params = e[n].params.concat(s.params)) : e[n] = {
660
+ for (const t of n) {
661
+ const r = ft(t.slot), s = r.name;
662
+ e[s] ? (e[s].nodes.push(t), e[s].params = e[s].params.concat(r.params)) : e[s] = {
609
663
  nodes: [t],
610
- params: s.params
664
+ params: r.params
611
665
  };
612
666
  }
613
667
  return e;
614
668
  }
615
- function it(r = "default") {
616
- return F(r) ? { name: r, params: [] } : { params: [], ...r };
669
+ function ft(n = "default") {
670
+ return C(n) ? { name: n, params: [] } : { params: [], ...n };
617
671
  }
618
- function at(r, e, t) {
619
- const { value: s, iterator: n } = r, { item: o = "item", index: i = "index" } = n || {};
620
- let a = t.__parseExpression(s) || [];
621
- return Number.isInteger(a) && (a = new Array(a).fill(!0).map((u, c) => c + 1)), Array.isArray(a) ? a.map((u, c) => e(t.__clone({ [o]: u, [i]: c }))) : (console.warn("[vForRender]:", `${s?.value} is not a Arrary`), []);
672
+ function dt(n, e, t) {
673
+ const { value: r, iterator: s } = n, { item: o = "item", index: i = "index" } = s || {};
674
+ let a = t.__parseExpression(r) || [];
675
+ return Number.isInteger(a) && (a = new Array(a).fill(!0).map((l, c) => c + 1)), Array.isArray(a) ? a.map((l, c) => e(t.__clone({ [o]: l, [i]: c }))) : (console.warn("[vForRender]:", `${r?.value} is not a Arrary`), []);
622
676
  }
623
- const K = X({
677
+ const Q = ee({
624
678
  name: "VtjPageContainer",
625
679
  async setup() {
626
- const r = oe(), e = Y(), t = e.params.id, s = t ? r.getPage(t) : r.getHomepage(), n = s ? await r.getRenderComponent(s.id) : null;
627
- return s && be(s.title || "VTJ"), {
628
- provider: r,
629
- component: n,
630
- file: s,
680
+ const n = le(), e = te(), t = e.params.id, r = t ? n.getPage(t) : n.getHomepage(), s = r ? await n.getRenderComponent(r.id) : null;
681
+ return r && Re(r.title || "VTJ"), {
682
+ provider: n,
683
+ component: s,
684
+ file: r,
631
685
  query: e.query
632
686
  };
633
687
  },
634
688
  render() {
635
- return this.component ? D(this.component, this.query) : D("div", "页面不存在");
689
+ return this.component ? A(this.component, this.query) : A("div", "页面不存在");
636
690
  }
637
- }), ct = X({
691
+ }), mt = ee({
638
692
  name: "VtjStartupContainer",
639
693
  render() {
640
- return D(Pe);
694
+ return A(Ie);
641
695
  }
642
- }), ne = Symbol("Provider");
643
- class ut extends ae {
696
+ }), ce = Symbol("Provider");
697
+ class ht extends pe {
644
698
  mode;
645
699
  globals = {};
646
700
  modules = {};
647
- adapter = { request: Me, jsonp: ye };
701
+ adapter = { request: Ne, jsonp: $e };
648
702
  apis = {};
649
703
  dependencies = {};
650
704
  materials = {};
@@ -655,100 +709,101 @@ class ut extends ae {
655
709
  nodeEnv = "development";
656
710
  router = null;
657
711
  materialPath = "./";
712
+ urlDslCaches = {};
658
713
  constructor(e) {
659
714
  super();
660
715
  const {
661
716
  service: t,
662
- mode: s = w.Raw,
663
- dependencies: n,
717
+ mode: r = _.Raw,
718
+ dependencies: s,
664
719
  materials: o,
665
720
  project: i = {},
666
721
  adapter: a = {},
667
- globals: u = {},
722
+ globals: l = {},
668
723
  modules: c = {},
669
- router: f = null,
670
- materialPath: p = "./",
671
- nodeEnv: l = "development"
724
+ router: d = null,
725
+ materialPath: f = "./",
726
+ nodeEnv: p = "development"
672
727
  } = e;
673
- this.mode = s, this.modules = c, this.service = t, this.router = f, this.materialPath = p, this.nodeEnv = l, n && (this.dependencies = n), o && (this.materials = o), Object.assign(this.globals, u), Object.assign(this.adapter, a), s !== w.Design && this.load(i);
728
+ this.mode = r, this.modules = c, this.service = t, this.router = d, this.materialPath = f, this.nodeEnv = p, s && (this.dependencies = s), o && (this.materials = o), Object.assign(this.globals, l), Object.assign(this.adapter, a), r !== _.Design && this.load(i);
674
729
  }
675
730
  async load(e) {
676
731
  const t = this.modules[`.vtj/projects/${e.id}.json`];
677
732
  if (this.project = t ? await t() : await this.service.init(e), !this.project)
678
733
  throw new Error("project is null");
679
- const { dependencies: s = [], apis: n } = this.project, { dependencies: o, library: i, components: a, materialPath: u } = this, {
734
+ const { dependencies: r = [], apis: s } = this.project, { dependencies: o, library: i, components: a, materialPath: l } = this, {
680
735
  libraryExports: c,
681
- libraryMap: f,
682
- materials: p,
683
- materialExports: l,
684
- materialMapLibrary: v
685
- } = Re(s, u), d = window;
686
- d.CKEDITOR_VERSION = void 0;
687
- for (const m of c) {
688
- const S = o[m], _ = d[m];
689
- if (_)
690
- i[m] = _;
736
+ libraryMap: d,
737
+ materials: f,
738
+ materialExports: p,
739
+ materialMapLibrary: y
740
+ } = De(r, l), m = window;
741
+ m.CKEDITOR_VERSION = void 0;
742
+ for (const u of c) {
743
+ const S = o[u], g = m[u];
744
+ if (g)
745
+ i[u] = g;
691
746
  else if (S)
692
- d[m] = i[m] = await S();
747
+ m[u] = i[u] = await S();
693
748
  else {
694
- const $ = f[m] || [];
749
+ const $ = d[u] || [];
695
750
  for (const j of $)
696
- z(j) && await Ce(m, P.append(j, { v: I })), G(j) && await J(P.append(j, { v: I })), i[m] = d[m];
751
+ J(j) && await ke(u, F.append(j, { v: b })), V(j) && await X(F.append(j, { v: b })), i[u] = m[u];
697
752
  }
698
753
  }
699
- for (const m of p)
700
- await J(P.append(m, { v: I }));
701
- const y = this.materials || {};
702
- for (const m of l) {
703
- const S = d[v[m]], _ = ce[m];
704
- if (_)
705
- S && _.forEach(($) => {
754
+ for (const u of f)
755
+ await X(F.append(u, { v: b }));
756
+ const h = this.materials || {};
757
+ for (const u of p) {
758
+ const S = m[y[u]], g = fe[u];
759
+ if (g)
760
+ S && g.forEach(($) => {
706
761
  a[$] = S[$];
707
762
  });
708
763
  else {
709
- const $ = y[m] ? (await y[m]()).default : d[m];
764
+ const $ = h[u] ? (await h[u]()).default : m[u];
710
765
  $ && S && ($.components || []).forEach((j) => {
711
- a[j.name] = He(j, S);
766
+ a[j.name] = Me(j, S);
712
767
  });
713
768
  }
714
769
  }
715
- n && (this.apis = ke(n, this.adapter), ee(), this.project.config?.mock && Ae(n)), this.initRouter(), this.triggerReady();
770
+ s && (this.apis = qe(s, this.adapter), oe(), this.project.config?.mock && Je(s)), this.initRouter(), this.triggerReady();
716
771
  }
717
772
  initRouter() {
718
773
  const { router: e, project: t } = this;
719
774
  e && (e.addRoute({
720
775
  path: "/page/:id",
721
776
  name: "VtjPage",
722
- component: K
777
+ component: Q
723
778
  }), e.addRoute({
724
779
  path: "/",
725
780
  name: "VtjHomepage",
726
- component: t?.homepage ? K : ct
781
+ component: t?.homepage ? Q : mt
727
782
  }));
728
783
  }
729
784
  install(e) {
730
785
  const t = e.config.globalProperties.installed || {};
731
- for (const [s, n] of Object.entries(this.library))
732
- !t[s] && xe(n) && (e.use(n), t[s] = !0);
733
- e.provide(ne, this), e.config.globalProperties.installed = t;
786
+ for (const [r, s] of Object.entries(this.library))
787
+ !t[r] && Ae(s) && (e.use(s), t[r] = !0);
788
+ e.provide(ce, this), e.config.globalProperties.installed = t;
734
789
  }
735
790
  getFile(e) {
736
791
  const { blocks: t = [] } = this.project || {};
737
- return this.getPage(e) || t.find((s) => s.id === e) || null;
792
+ return this.getPage(e) || t.find((r) => r.id === e) || null;
738
793
  }
739
794
  getPage(e) {
740
- const { pages: t = [] } = this.project || {}, s = (n, o = []) => {
795
+ const { pages: t = [] } = this.project || {}, r = (s, o = []) => {
741
796
  for (const i of o) {
742
- if (i.id === n)
797
+ if (i.id === s)
743
798
  return i;
744
799
  if (i.children && i.children.length) {
745
- const a = s(n, i.children);
800
+ const a = r(s, i.children);
746
801
  if (a)
747
802
  return a;
748
803
  }
749
804
  }
750
805
  };
751
- return s(e, t) || null;
806
+ return r(e, t) || null;
752
807
  }
753
808
  getHomepage() {
754
809
  const { homepage: e } = this.project || {};
@@ -758,83 +813,121 @@ class ut extends ae {
758
813
  const t = this.modules[`.vtj/files/${e}.json`];
759
814
  return t ? await t() : this.service.getFile(e).catch(() => null);
760
815
  }
816
+ async getDslByUrl(e) {
817
+ const t = this.urlDslCaches[e];
818
+ return t || (this.urlDslCaches[e] = this.adapter.request.send({
819
+ url: e,
820
+ method: "get",
821
+ settings: {
822
+ validSuccess: !1,
823
+ originResponse: !0
824
+ }
825
+ }).then((r) => r.data).catch(() => null));
826
+ }
827
+ createDslRenderer(e, t = {}) {
828
+ const { library: r, components: s, mode: o, apis: i } = this, a = {
829
+ mode: o,
830
+ Vue: r.Vue,
831
+ components: s,
832
+ libs: r,
833
+ apis: i,
834
+ window,
835
+ ...t
836
+ }, l = N({
837
+ getDsl: async (c) => await this.getDsl(c) || null,
838
+ getDslByUrl: async (c) => await this.getDslByUrl(c) || null,
839
+ options: a
840
+ });
841
+ return B({
842
+ ...a,
843
+ dsl: e,
844
+ loader: l
845
+ });
846
+ }
761
847
  async getRenderComponent(e) {
762
848
  const t = this.getFile(e);
763
849
  if (!t)
764
850
  return O.warn(`Can not find file: ${e}`), null;
765
- const s = `.vtj/vue/${e}.vue`, n = this.modules[s];
766
- if (n)
767
- return (await n())?.default;
851
+ const r = `.vtj/vue/${e}.vue`, s = this.modules[r];
852
+ if (s)
853
+ return (await s())?.default;
768
854
  const o = await this.getDsl(t.id);
769
- if (!o)
770
- return O.warn(`Can not find dsl: ${e}`), null;
771
- const { library: i, components: a, mode: u, apis: c } = this, f = {
772
- mode: u,
773
- Vue: i.Vue,
774
- components: a,
775
- libs: i,
776
- apis: c,
777
- window
778
- }, p = re({
779
- getDsl: async (v) => await this.getDsl(v) || null,
780
- options: f
781
- }), { renderer: l } = te({
782
- ...f,
783
- dsl: o,
784
- loader: p
855
+ return o ? this.createDslRenderer(o).renderer : (O.warn(`Can not find dsl: ${e}`), null);
856
+ }
857
+ defineUrlSchemaComponent(e, t) {
858
+ return Y(async () => {
859
+ const r = await this.getDslByUrl(e);
860
+ return r ? (r.name = t || r.name, this.createDslRenderer(r).renderer) : null;
861
+ });
862
+ }
863
+ definePluginComponent(e) {
864
+ return Y(async () => {
865
+ const t = await ie(e, window);
866
+ return t ? (se(t.css), t.component) : null;
785
867
  });
786
- return l;
787
868
  }
788
869
  }
789
- function bt(r) {
790
- const e = new ut(r);
870
+ function Ht(n) {
871
+ const e = new ht(n);
791
872
  return {
792
873
  provider: e,
793
- onReady: (s) => e.ready(s)
874
+ onReady: (r) => e.ready(r)
794
875
  };
795
876
  }
796
- function oe(r = {}) {
797
- const e = Se(ne);
877
+ function le(n = {}) {
878
+ const e = Pe(ce);
798
879
  if (!e)
799
880
  throw new Error("Can not find provider");
800
- if (e.mode === w.Raw && e.nodeEnv === "development") {
801
- const { id: t, version: s } = r;
802
- t && s && (async () => {
803
- const n = await e.getDsl(t);
804
- n?.__VERSION__ !== s && B.warning({
805
- title: n?.name,
881
+ if (e.mode === _.Raw && e.nodeEnv === "development") {
882
+ const { id: t, version: r } = n;
883
+ t && r && (async () => {
884
+ const s = await e.getDsl(t);
885
+ s?.__VERSION__ !== r && q.warning({
886
+ title: s?.name,
806
887
  message: "当前组件源码版本与运行时版本不一致,请重新发布组件"
807
888
  });
808
889
  })();
809
890
  }
810
891
  return e;
811
892
  }
812
- const lt = new ge({
893
+ const L = new je({
813
894
  settings: {
814
895
  type: "json",
815
896
  validSuccess: !0,
816
897
  originResponse: !1,
817
898
  failMessage: !0,
818
- validate: (r) => r.data?.code === 0,
819
- showError: (r) => {
820
- B.error({
821
- message: r || "未知错误"
899
+ validate: (n) => n.data?.code === 0,
900
+ showError: (n) => {
901
+ q.error({
902
+ message: n || "未知错误"
822
903
  });
823
904
  }
824
905
  }
825
- }), pt = (r = "/vtj/local/repository/${type}.json") => (e, t) => lt.send({
826
- url: r,
906
+ }), vt = (n = "/vtj/local/repository/${type}.json") => (e, t) => L.send({
907
+ url: n,
827
908
  method: "post",
828
909
  query: { type: e },
829
910
  data: {
830
911
  type: e,
831
912
  data: t
832
913
  }
833
- });
834
- class V {
914
+ }), yt = (n = "/vtj/local/repository/uploader.json") => async (e, t) => await L.send({
915
+ url: n,
916
+ method: "post",
917
+ data: {
918
+ files: e,
919
+ projectId: t
920
+ },
921
+ settings: {
922
+ type: "data"
923
+ }
924
+ }).then((r) => r && r[0] ? r[0] : null).catch(() => null);
925
+ class K {
835
926
  api;
927
+ pluginCaches = {};
928
+ uploader;
836
929
  constructor() {
837
- this.api = pt();
930
+ this.api = vt(), this.uploader = yt();
838
931
  }
839
932
  async init(e) {
840
933
  return console.log("BaseService.init", e), {};
@@ -889,78 +982,106 @@ class V {
889
982
  async removeRawPage(e) {
890
983
  return await this.api("removeRawPage", e).catch(() => "");
891
984
  }
985
+ async uploadStaticFile(e, t) {
986
+ return await this.uploader(e, t).catch(() => null);
987
+ }
988
+ async getStaticFiles(e) {
989
+ return await this.api("getStaticFiles", e).catch(() => []);
990
+ }
991
+ async removeStaticFile(e, t) {
992
+ return await this.api("removeStaticFile", { name: e, projectId: t }).catch(
993
+ () => ""
994
+ );
995
+ }
996
+ async clearStaticFiles(e) {
997
+ return await this.api("clearStaticFiles", e).catch(() => "");
998
+ }
999
+ async getPluginMaterial(e) {
1000
+ const { urls: t = [] } = e, r = t.filter((o) => Oe(o))[0];
1001
+ if (!r)
1002
+ return null;
1003
+ const s = this.pluginCaches[r];
1004
+ return s || (this.pluginCaches[r] = L.send({
1005
+ url: r,
1006
+ method: "get",
1007
+ settings: {
1008
+ validSuccess: !1,
1009
+ originResponse: !0
1010
+ }
1011
+ }).then((o) => o.data).catch(() => null));
1012
+ }
892
1013
  }
893
- const h = new we({
1014
+ const v = new Ee({
894
1015
  type: "local",
895
1016
  expired: 0,
896
1017
  prefix: "__VTJ_"
897
1018
  });
898
- class Pt extends V {
1019
+ class xt extends K {
899
1020
  init(e) {
900
- const t = new x(e), s = h.get(`project_${t.id}`), n = Object.assign(t.toDsl(), s || {});
901
- return h.save(`project_${t.id}`, n), Promise.resolve(n);
1021
+ const t = new x(e), r = v.get(`project_${t.id}`), s = Object.assign(t.toDsl(), r || {});
1022
+ return v.save(`project_${t.id}`, s), Promise.resolve(s);
902
1023
  }
903
1024
  saveProject(e) {
904
1025
  const t = new x(e);
905
- return h.save(`project_${t.id}`, t.toDsl()), Promise.resolve(!0);
1026
+ return v.save(`project_${t.id}`, t.toDsl()), Promise.resolve(!0);
906
1027
  }
907
1028
  saveMaterials(e, t) {
908
- return h.save(`materials_${e.id}`, N(t)), Promise.resolve(!0);
1029
+ return v.save(`materials_${e.id}`, U(t)), Promise.resolve(!0);
909
1030
  }
910
1031
  saveFile(e) {
911
- return h.save(`file_${e.id}`, e), Promise.resolve(!0);
1032
+ return v.save(`file_${e.id}`, e), Promise.resolve(!0);
912
1033
  }
913
1034
  getFile(e) {
914
- const t = h.get(`file_${e}`);
1035
+ const t = v.get(`file_${e}`);
915
1036
  return t ? Promise.resolve(t) : Promise.reject(null);
916
1037
  }
917
1038
  removeFile(e) {
918
- return h.remove(`file_${e}`), Promise.resolve(!0);
1039
+ return v.remove(`file_${e}`), Promise.resolve(!0);
919
1040
  }
920
1041
  saveHistory(e) {
921
- return h.save(`history_${e.id}`, e), Promise.resolve(!0);
1042
+ return v.save(`history_${e.id}`, e), Promise.resolve(!0);
922
1043
  }
923
1044
  removeHistory(e) {
924
- const t = h.get(`history_${e}`);
1045
+ const t = v.get(`history_${e}`);
925
1046
  if (t) {
926
- const n = (t.items || []).map((o) => o.id);
927
- this.removeHistoryItem(e, n), h.remove(`history_${e}`);
1047
+ const s = (t.items || []).map((o) => o.id);
1048
+ this.removeHistoryItem(e, s), v.remove(`history_${e}`);
928
1049
  }
929
1050
  return Promise.resolve(!0);
930
1051
  }
931
1052
  getHistory(e) {
932
- const t = h.get(`history_${e}`), s = new W(t || { id: e });
933
- return Promise.resolve(s.toDsl());
1053
+ const t = v.get(`history_${e}`), r = new Z(t || { id: e });
1054
+ return Promise.resolve(r.toDsl());
934
1055
  }
935
1056
  getHistoryItem(e, t) {
936
- const s = h.get(`history_${e}_${t}`);
937
- return Promise.resolve(s);
1057
+ const r = v.get(`history_${e}_${t}`);
1058
+ return Promise.resolve(r);
938
1059
  }
939
1060
  saveHistoryItem(e, t) {
940
- return h.save(`history_${e}_${t.id}`, t), Promise.resolve(!0);
1061
+ return v.save(`history_${e}_${t.id}`, t), Promise.resolve(!0);
941
1062
  }
942
1063
  removeHistoryItem(e, t) {
943
- return t.forEach((s) => {
944
- h.remove(`history_${e}_${s}`);
1064
+ return t.forEach((r) => {
1065
+ v.remove(`history_${e}_${r}`);
945
1066
  }), Promise.resolve(!0);
946
1067
  }
947
1068
  }
948
- class ft extends V {
1069
+ class gt extends K {
949
1070
  projects = {};
950
1071
  materials = {};
951
1072
  files = {};
952
1073
  histories = {};
953
1074
  historyItems = {};
954
1075
  init(e) {
955
- const t = new x(e), s = this.projects[t.id] || {}, n = Object.assign(t.toDsl(), s);
956
- return this.projects[n.id] = n, Promise.resolve(n);
1076
+ const t = new x(e), r = this.projects[t.id] || {}, s = Object.assign(t.toDsl(), r);
1077
+ return this.projects[s.id] = s, Promise.resolve(s);
957
1078
  }
958
1079
  saveProject(e) {
959
1080
  const t = new x(e);
960
1081
  return this.projects[t.id] = t.toDsl(), Promise.resolve(!0);
961
1082
  }
962
1083
  saveMaterials(e, t) {
963
- return e.id && (this.materials[e.id] = N(t)), Promise.resolve(!0);
1084
+ return e.id && (this.materials[e.id] = U(t)), Promise.resolve(!0);
964
1085
  }
965
1086
  saveFile(e) {
966
1087
  return this.files[e.id] = e, Promise.resolve(!0);
@@ -978,35 +1099,36 @@ class ft extends V {
978
1099
  removeHistory(e) {
979
1100
  const t = this.histories[e];
980
1101
  if (t) {
981
- const n = (t.items || []).map((o) => o.id);
982
- this.removeHistoryItem(e, n), delete this.historyItems[e];
1102
+ const s = (t.items || []).map((o) => o.id);
1103
+ this.removeHistoryItem(e, s), delete this.historyItems[e];
983
1104
  }
984
1105
  return Promise.resolve(!0);
985
1106
  }
986
1107
  getHistory(e) {
987
- const t = this.histories[e], s = new W(t || { id: e });
988
- return Promise.resolve(s);
1108
+ const t = this.histories[e], r = new Z(t || { id: e });
1109
+ return Promise.resolve(r);
989
1110
  }
990
1111
  getHistoryItem(e, t) {
991
- const s = `${e}_${t}`, n = this.historyItems[s] || {};
992
- return Promise.resolve(n);
1112
+ const r = `${e}_${t}`, s = this.historyItems[r] || {};
1113
+ return Promise.resolve(s);
993
1114
  }
994
1115
  saveHistoryItem(e, t) {
995
- const s = `${e}_${t.id}`;
996
- return this.historyItems[s] = t, Promise.resolve(!0);
1116
+ const r = `${e}_${t.id}`;
1117
+ return this.historyItems[r] = t, Promise.resolve(!0);
997
1118
  }
998
1119
  removeHistoryItem(e, t) {
999
- return t.forEach((s) => {
1000
- const n = `${e}_${s}`;
1001
- delete this.historyItems[n];
1120
+ return t.forEach((r) => {
1121
+ const s = `${e}_${r}`;
1122
+ delete this.historyItems[s];
1002
1123
  }), Promise.resolve(!0);
1003
1124
  }
1004
1125
  }
1005
- let C = null;
1006
- function Ft() {
1007
- return C || (C = new ft(), C);
1126
+ let H = null;
1127
+ function Ot() {
1128
+ return H || (H = new gt(), H);
1008
1129
  }
1009
- class It extends V {
1130
+ class Dt extends K {
1131
+ getFileCaches = {};
1010
1132
  async init(e) {
1011
1133
  return await this.api("init", e).catch(() => null) || {};
1012
1134
  }
@@ -1016,14 +1138,19 @@ class It extends V {
1016
1138
  async saveMaterials(e, t) {
1017
1139
  return !!await this.api("saveMaterials", {
1018
1140
  project: e,
1019
- materials: N(t)
1141
+ materials: U(t)
1020
1142
  }).catch(() => !1);
1021
1143
  }
1022
1144
  async saveFile(e) {
1023
1145
  return !!await this.api("saveFile", e).catch(() => !1);
1024
1146
  }
1025
1147
  async getFile(e) {
1026
- return await this.api("getFile", e).catch(() => null) || {};
1148
+ const t = this.getFileCaches[e];
1149
+ return t || (this.getFileCaches[e] = this.api("getFile", e).catch(
1150
+ () => null
1151
+ )).finally(() => {
1152
+ delete this.getFileCaches[e];
1153
+ });
1027
1154
  }
1028
1155
  async removeFile(e) {
1029
1156
  return !!await this.api("removeFile", e).catch(() => !1);
@@ -1051,85 +1178,89 @@ class It extends V {
1051
1178
  );
1052
1179
  }
1053
1180
  }
1054
- function ie(r = []) {
1055
- return r.map((e) => {
1056
- const { id: t, title: s, icon: n, children: o, hidden: i } = e;
1181
+ function ue(n = []) {
1182
+ return n.map((e) => {
1183
+ const { id: t, title: r, icon: s, children: o, hidden: i } = e;
1057
1184
  return {
1058
1185
  id: t,
1059
- title: s,
1060
- icon: n,
1186
+ title: r,
1187
+ icon: s,
1061
1188
  hidden: i,
1062
1189
  url: `/page/${t}`,
1063
- children: o && o.length ? ie(o) : void 0
1190
+ children: o && o.length ? ue(o) : void 0
1064
1191
  };
1065
1192
  });
1066
1193
  }
1067
- function Rt() {
1068
- const r = oe(), e = Y(), t = $e(!1), s = r.project;
1069
- je(() => {
1070
- const { name: i, params: a, meta: u } = e;
1194
+ function Mt() {
1195
+ const n = le(), e = te(), t = Fe(!1), r = n.project;
1196
+ Ce(() => {
1197
+ const { name: i, params: a, meta: l } = e;
1071
1198
  if (i === "VtjPage") {
1072
- const c = r.getPage(a.id);
1199
+ const c = n.getPage(a.id);
1073
1200
  t.value = !c?.mask;
1074
1201
  } else if (i === "VtjHomepage") {
1075
- const c = r.getHomepage();
1202
+ const c = n.getHomepage();
1076
1203
  t.value = !c?.mask;
1077
1204
  } else
1078
- t.value = !u.mask;
1205
+ t.value = !l.mask;
1079
1206
  });
1080
- const n = ie(s?.pages), o = s?.config;
1207
+ const s = ue(r?.pages), o = r?.config;
1081
1208
  return {
1082
1209
  disabled: t,
1083
1210
  logo: o?.logo,
1084
1211
  themeSwitchable: o?.themeSwitchable,
1085
- title: o?.title || s?.description || s?.name || "VTJ App",
1086
- menus: n
1212
+ title: o?.title || r?.description || r?.name || "VTJ App",
1213
+ menus: s
1087
1214
  };
1088
1215
  }
1089
1216
  export {
1090
- Fe as BUILT_IN_DIRECTIVES,
1091
- V as BaseService,
1092
- L as CONTEXT_HOST,
1093
- Ne as Context,
1094
- w as ContextMode,
1095
- Ie as DATA_TYPES,
1096
- Et as JSCodeToString,
1097
- St as LIFE_CYCLES_LIST,
1098
- It as LocalService,
1099
- ft as MemoryService,
1100
- ut as Provider,
1101
- Pt as StorageService,
1102
- I as VTJ_RENDERER_VERSION,
1103
- Z as adoptedStyleSheets,
1104
- $t as createAssetScripts,
1105
- jt as createAssetsCss,
1106
- Ue as createDataSources,
1107
- re as createLoader,
1108
- Ft as createMemoryService,
1109
- bt as createProvider,
1110
- te as createRenderer,
1111
- Te as createSchemaApi,
1112
- ke as createSchemaApis,
1113
- Xe as defaultLoader,
1114
- H as fillBasePath,
1115
- se as getModifiers,
1116
- He as getRawComponent,
1117
- z as isCSSUrl,
1118
- Oe as isJSCode,
1119
- g as isJSExpression,
1120
- A as isJSFunction,
1121
- G as isJSUrl,
1122
- xe as isVuePlugin,
1123
- Ce as loadCss,
1124
- De as mockApi,
1125
- Ae as mockApis,
1126
- ee as mockCleanup,
1127
- T as nodeRender,
1128
- Re as parseDeps,
1217
+ He as BUILT_IN_DIRECTIVES,
1218
+ K as BaseService,
1219
+ z as CONTEXT_HOST,
1220
+ Le as Context,
1221
+ _ as ContextMode,
1222
+ xe as DATA_TYPES,
1223
+ It as JSCodeToString,
1224
+ Ct as LIFE_CYCLES_LIST,
1225
+ Dt as LocalService,
1226
+ gt as MemoryService,
1227
+ ht as Provider,
1228
+ xt as StorageService,
1229
+ b as VTJ_RENDERER_VERSION,
1230
+ ne as adoptedStyleSheets,
1231
+ bt as createAssetScripts,
1232
+ Rt as createAssetsCss,
1233
+ Ge as createDataSources,
1234
+ N as createLoader,
1235
+ Ot as createMemoryService,
1236
+ Ht as createProvider,
1237
+ B as createRenderer,
1238
+ Ue as createSchemaApi,
1239
+ qe as createSchemaApis,
1240
+ et as defaultLoader,
1241
+ I as fillBasePath,
1242
+ ae as getModifiers,
1243
+ ie as getPlugin,
1244
+ Me as getRawComponent,
1245
+ J as isCSSUrl,
1246
+ Be as isJSCode,
1247
+ w as isJSExpression,
1248
+ T as isJSFunction,
1249
+ Oe as isJSON,
1250
+ V as isJSUrl,
1251
+ Ae as isVuePlugin,
1252
+ ke as loadCss,
1253
+ se as loadCssUrl,
1254
+ Te as loadScriptUrl,
1255
+ Ve as mockApi,
1256
+ Je as mockApis,
1257
+ oe as mockCleanup,
1258
+ M as nodeRender,
1259
+ De as parseDeps,
1129
1260
  R as parseExpression,
1130
- U as parseFunction,
1131
- ne as providerKey,
1132
- Q as toString,
1133
- Rt as useMask,
1134
- oe as useProvider
1261
+ G as parseFunction,
1262
+ ce as providerKey,
1263
+ re as toString,
1264
+ Mt as useMask,
1265
+ le as useProvider
1135
1266
  };