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