@vtj/core 0.19.22 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +495 -323
- package/package.json +1 -1
- package/types/models/project.d.ts +7 -0
- package/types/protocols/schemas/file.d.ts +8 -0
- package/types/protocols/service.d.ts +1 -1
- package/types/tools/file.d.ts +20 -0
- package/types/tools/index.d.ts +1 -0
- package/types/version.d.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { uid as m, timestamp as
|
|
1
|
+
import { uid as m, timestamp as Z, isString as S, uuid as H, cloneDeep as A, upperFirstCamelCase as y, delay as B, merge as U, toArray as Q, mitt as X, kebabCase as K } from "@vtj/base";
|
|
2
2
|
/**!
|
|
3
3
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
4
4
|
* @name @vtj/core
|
|
5
5
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
6
|
-
* @version 0.
|
|
6
|
+
* @version 0.20.0
|
|
7
7
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const oe = "0.20.0", le = "BuiltIn", z = "VueMaterial", W = "VueRouterMaterial", he = [z, W], de = {
|
|
10
10
|
vue: "Vue",
|
|
11
11
|
"vue-router": "VueRouter"
|
|
12
|
-
},
|
|
13
|
-
[
|
|
12
|
+
}, ce = {
|
|
13
|
+
[z]: [
|
|
14
14
|
"Transition",
|
|
15
15
|
"TransitionGroup",
|
|
16
16
|
"KeepAlive",
|
|
17
17
|
"Teleport",
|
|
18
18
|
"Suspense"
|
|
19
19
|
],
|
|
20
|
-
[
|
|
21
|
-
},
|
|
20
|
+
[W]: ["RouterView", "RouterLink"]
|
|
21
|
+
}, fe = [
|
|
22
22
|
"slot",
|
|
23
23
|
"template",
|
|
24
24
|
"component",
|
|
@@ -30,7 +30,7 @@ const z = "0.19.22", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial",
|
|
|
30
30
|
"h3",
|
|
31
31
|
"span",
|
|
32
32
|
"a"
|
|
33
|
-
],
|
|
33
|
+
], me = [
|
|
34
34
|
{
|
|
35
35
|
label: "简体中文",
|
|
36
36
|
value: "zh-CN"
|
|
@@ -40,9 +40,9 @@ const z = "0.19.22", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial",
|
|
|
40
40
|
value: "en"
|
|
41
41
|
}
|
|
42
42
|
];
|
|
43
|
-
class
|
|
43
|
+
class pe {
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class ue {
|
|
46
46
|
listeners = [];
|
|
47
47
|
isReady = !1;
|
|
48
48
|
triggerReady() {
|
|
@@ -58,7 +58,7 @@ class ie {
|
|
|
58
58
|
this.isReady = !1;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
class
|
|
61
|
+
class w {
|
|
62
62
|
constructor(e, t, i) {
|
|
63
63
|
this.name = e, this.value = t, this.defaultValue = i, this.setValue(t);
|
|
64
64
|
}
|
|
@@ -76,10 +76,10 @@ class A {
|
|
|
76
76
|
return Object.entries(e).reduce((t, [i, s]) => (s.isUnset || (t[i] = s.getValue()), t), {});
|
|
77
77
|
}
|
|
78
78
|
static parse(e = {}) {
|
|
79
|
-
return Object.entries(e).reduce((t, [i, s]) => (t[i] = new
|
|
79
|
+
return Object.entries(e).reduce((t, [i, s]) => (t[i] = new w(i, s), t), {});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
class
|
|
82
|
+
class I {
|
|
83
83
|
constructor(e) {
|
|
84
84
|
this.schema = e;
|
|
85
85
|
const { name: t, handler: i } = this.schema;
|
|
@@ -95,18 +95,18 @@ class C {
|
|
|
95
95
|
}
|
|
96
96
|
static toDsl(e) {
|
|
97
97
|
return Object.entries(e).reduce((t, [i, s]) => {
|
|
98
|
-
const { handler:
|
|
99
|
-
return t[i] = { name: i, handler:
|
|
98
|
+
const { handler: n, modifiers: r } = s;
|
|
99
|
+
return t[i] = { name: i, handler: n, modifiers: r }, t;
|
|
100
100
|
}, {});
|
|
101
101
|
}
|
|
102
102
|
static parse(e = {}) {
|
|
103
103
|
return Object.entries(e).reduce(
|
|
104
|
-
(t, [i, s]) => (t[i] = new
|
|
104
|
+
(t, [i, s]) => (t[i] = new I(s), t),
|
|
105
105
|
{}
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
class
|
|
109
|
+
class g {
|
|
110
110
|
constructor(e) {
|
|
111
111
|
this.schema = e, this.id = e.id || m(), this.update(e);
|
|
112
112
|
}
|
|
@@ -136,32 +136,32 @@ class E {
|
|
|
136
136
|
iterator;
|
|
137
137
|
update(e) {
|
|
138
138
|
Object.assign(this.schema, e);
|
|
139
|
-
const { name: t, arg: i, modifiers: s, value:
|
|
140
|
-
this.name = t, this.arg = i, this.modifiers = s, this.value =
|
|
139
|
+
const { name: t, arg: i, modifiers: s, value: n, iterator: r } = this.schema;
|
|
140
|
+
this.name = t, this.arg = i, this.modifiers = s, this.value = n, this.iterator = r;
|
|
141
141
|
}
|
|
142
142
|
static parse(e = []) {
|
|
143
|
-
return e.map((t) => new
|
|
143
|
+
return e.map((t) => new g(t));
|
|
144
144
|
}
|
|
145
145
|
static toDsl(e = []) {
|
|
146
146
|
return e.map((t) => {
|
|
147
|
-
const { name: i, arg: s, modifiers:
|
|
147
|
+
const { name: i, arg: s, modifiers: n, value: r, iterator: l, id: d } = t;
|
|
148
148
|
return {
|
|
149
|
-
id:
|
|
149
|
+
id: d,
|
|
150
150
|
name: i,
|
|
151
151
|
arg: s,
|
|
152
|
-
modifiers:
|
|
153
|
-
value:
|
|
154
|
-
iterator:
|
|
152
|
+
modifiers: n,
|
|
153
|
+
value: r,
|
|
154
|
+
iterator: l
|
|
155
155
|
};
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
const
|
|
159
|
+
const f = "EVENT_NODE_CHANGE";
|
|
160
160
|
class _ {
|
|
161
161
|
constructor(e, t = null) {
|
|
162
162
|
this.parent = t;
|
|
163
|
-
const { id: i = m(), name: s, from:
|
|
164
|
-
this.id = i, this.name = s, this.from =
|
|
163
|
+
const { id: i = m(), name: s, from: n = "" } = e;
|
|
164
|
+
this.id = i, this.name = s, this.from = n, this.update(e, !0), _.nodes[this.id] = this;
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
167
167
|
* 标记
|
|
@@ -224,13 +224,13 @@ class _ {
|
|
|
224
224
|
const {
|
|
225
225
|
invisible: i = !1,
|
|
226
226
|
locked: s = !1,
|
|
227
|
-
children:
|
|
228
|
-
slot:
|
|
229
|
-
props:
|
|
230
|
-
events:
|
|
231
|
-
directives:
|
|
227
|
+
children: n = [],
|
|
228
|
+
slot: r,
|
|
229
|
+
props: l = {},
|
|
230
|
+
events: d = {},
|
|
231
|
+
directives: P = []
|
|
232
232
|
} = e;
|
|
233
|
-
this.invisible = i, this.locked = s, this.setChildren(
|
|
233
|
+
this.invisible = i, this.locked = s, this.setChildren(n, !0), this.setSlot(r, !0), this.props = w.parse(l), this.events = I.parse(d), this.directives = g.parse(P), t || a.emit(f, this);
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* 设置子节点
|
|
@@ -238,7 +238,7 @@ class _ {
|
|
|
238
238
|
* @param silent
|
|
239
239
|
*/
|
|
240
240
|
setChildren(e = "", t = !1) {
|
|
241
|
-
Array.isArray(e) ? this.children = e.map((i) => new _(i, this)) : this.children = e, t ||
|
|
241
|
+
Array.isArray(e) ? this.children = e.map((i) => new _(i, this)) : this.children = e, t || a.emit(f, this);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* 设置节点放置的插槽
|
|
@@ -246,7 +246,7 @@ class _ {
|
|
|
246
246
|
* @param silent
|
|
247
247
|
*/
|
|
248
248
|
setSlot(e, t = !1) {
|
|
249
|
-
this.slot = typeof e == "string" ? { name: e, params: [] } : e, t ||
|
|
249
|
+
this.slot = typeof e == "string" ? { name: e, params: [] } : e, t || a.emit(f, this);
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
252
|
* 新增或更新属性
|
|
@@ -256,8 +256,8 @@ class _ {
|
|
|
256
256
|
* @param silent
|
|
257
257
|
*/
|
|
258
258
|
setProp(e, t, i, s = !1) {
|
|
259
|
-
const
|
|
260
|
-
|
|
259
|
+
const n = this.props[e];
|
|
260
|
+
n ? n.setValue(t) : this.props[e] = new w(e, t, i), s || a.emit(f, this);
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
263
263
|
* 删除属性
|
|
@@ -265,7 +265,7 @@ class _ {
|
|
|
265
265
|
* @param silent
|
|
266
266
|
*/
|
|
267
267
|
removeProp(e, t = !1) {
|
|
268
|
-
delete this.props[e], t ||
|
|
268
|
+
delete this.props[e], t || a.emit(f, this);
|
|
269
269
|
}
|
|
270
270
|
/**
|
|
271
271
|
* 获取属性值
|
|
@@ -284,7 +284,7 @@ class _ {
|
|
|
284
284
|
*/
|
|
285
285
|
setEvent(e, t = !1) {
|
|
286
286
|
const i = this.events[e.name];
|
|
287
|
-
i ? i.update(e) : this.events[e.name] = new
|
|
287
|
+
i ? i.update(e) : this.events[e.name] = new I(e), t || a.emit(f, this);
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
290
290
|
* 删除事件
|
|
@@ -292,7 +292,7 @@ class _ {
|
|
|
292
292
|
* @param silent
|
|
293
293
|
*/
|
|
294
294
|
removeEvent(e, t = !1) {
|
|
295
|
-
delete this.events[e], t ||
|
|
295
|
+
delete this.events[e], t || a.emit(f, this);
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
298
|
* 新增或更新指令
|
|
@@ -300,8 +300,8 @@ class _ {
|
|
|
300
300
|
* @param silent
|
|
301
301
|
*/
|
|
302
302
|
setDirective(e, t = !1) {
|
|
303
|
-
const i = e instanceof
|
|
304
|
-
s >= 0 ? this.directives.splice(s, 1, i) : this.directives.push(i), t ||
|
|
303
|
+
const i = e instanceof g ? e : new g(e), s = this.directives.findIndex((n) => n.id === e.id);
|
|
304
|
+
s >= 0 ? this.directives.splice(s, 1, i) : this.directives.push(i), t || a.emit(f, this);
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* 删除指令
|
|
@@ -312,7 +312,7 @@ class _ {
|
|
|
312
312
|
const i = this.directives.findIndex(
|
|
313
313
|
(s) => s === e || s.id === e.id
|
|
314
314
|
);
|
|
315
|
-
i >= 0 && this.directives.splice(i, 1), t ||
|
|
315
|
+
i >= 0 && this.directives.splice(i, 1), t || a.emit(f, this);
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
318
318
|
* 删除子节点
|
|
@@ -323,8 +323,8 @@ class _ {
|
|
|
323
323
|
removeChild(e, t = !1) {
|
|
324
324
|
const { children: i, disposed: s } = this;
|
|
325
325
|
if (s || !Array.isArray(i)) return;
|
|
326
|
-
const
|
|
327
|
-
e.parent = null, i.splice(
|
|
326
|
+
const n = i.findIndex((r) => r === e);
|
|
327
|
+
e.parent = null, i.splice(n, 1), t || a.emit(f, this);
|
|
328
328
|
}
|
|
329
329
|
/**
|
|
330
330
|
* 追加子节点
|
|
@@ -334,7 +334,7 @@ class _ {
|
|
|
334
334
|
*/
|
|
335
335
|
appendChild(e, t = !1) {
|
|
336
336
|
const { children: i, disposed: s } = this;
|
|
337
|
-
s || (e.parent = this, Array.isArray(i) ? i.push(e) : this.children = [e], t ||
|
|
337
|
+
s || (e.parent = this, Array.isArray(i) ? i.push(e) : this.children = [e], t || a.emit(f, this));
|
|
338
338
|
}
|
|
339
339
|
/**
|
|
340
340
|
* 在当前节点的后面插入节点
|
|
@@ -348,7 +348,7 @@ class _ {
|
|
|
348
348
|
if (Array.isArray(i)) {
|
|
349
349
|
e.parent = this.parent;
|
|
350
350
|
const s = i.indexOf(this);
|
|
351
|
-
i.splice(s + 1, 0, e), t ||
|
|
351
|
+
i.splice(s + 1, 0, e), t || a.emit(f, this.parent);
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
/**
|
|
@@ -363,7 +363,7 @@ class _ {
|
|
|
363
363
|
if (Array.isArray(i)) {
|
|
364
364
|
e.parent = this.parent;
|
|
365
365
|
const s = i.indexOf(this);
|
|
366
|
-
i.splice(s, 0, e), t ||
|
|
366
|
+
i.splice(s, 0, e), t || a.emit(f, this.parent);
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
movePrev(e = !1) {
|
|
@@ -372,7 +372,7 @@ class _ {
|
|
|
372
372
|
const i = t.children;
|
|
373
373
|
if (Array.isArray(i)) {
|
|
374
374
|
const s = i.indexOf(this);
|
|
375
|
-
s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, this), e ||
|
|
375
|
+
s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, this), e || a.emit(f, t));
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
moveNext(e = !1) {
|
|
@@ -381,7 +381,7 @@ class _ {
|
|
|
381
381
|
const i = t.children;
|
|
382
382
|
if (Array.isArray(i)) {
|
|
383
383
|
const s = i.indexOf(this);
|
|
384
|
-
s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, this), e ||
|
|
384
|
+
s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, this), e || a.emit(f, t));
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
/**
|
|
@@ -394,24 +394,24 @@ class _ {
|
|
|
394
394
|
name: t,
|
|
395
395
|
from: i,
|
|
396
396
|
invisible: s,
|
|
397
|
-
locked:
|
|
398
|
-
slot:
|
|
399
|
-
children:
|
|
400
|
-
props:
|
|
401
|
-
directives:
|
|
402
|
-
events:
|
|
403
|
-
} = this,
|
|
397
|
+
locked: n,
|
|
398
|
+
slot: r,
|
|
399
|
+
children: l,
|
|
400
|
+
props: d,
|
|
401
|
+
directives: P,
|
|
402
|
+
events: u
|
|
403
|
+
} = this, O = Array.isArray(l) ? l.map((R) => R.toDsl()) : l;
|
|
404
404
|
return {
|
|
405
405
|
id: e,
|
|
406
406
|
name: t,
|
|
407
407
|
from: i,
|
|
408
408
|
invisible: s,
|
|
409
|
-
locked:
|
|
410
|
-
slot:
|
|
411
|
-
children:
|
|
412
|
-
props:
|
|
413
|
-
directives:
|
|
414
|
-
events:
|
|
409
|
+
locked: n,
|
|
410
|
+
slot: r,
|
|
411
|
+
children: O,
|
|
412
|
+
props: w.toDsl(d),
|
|
413
|
+
directives: g.toDsl(P),
|
|
414
|
+
events: I.toDsl(u)
|
|
415
415
|
};
|
|
416
416
|
}
|
|
417
417
|
/**
|
|
@@ -421,25 +421,25 @@ class _ {
|
|
|
421
421
|
*/
|
|
422
422
|
dispose(e = !1) {
|
|
423
423
|
const { children: t, disposed: i } = this;
|
|
424
|
-
i || (Array.isArray(t) && t.forEach((s) => s.dispose(!0)), this.parent ? this.parent.removeChild(this, e) : e ||
|
|
424
|
+
i || (Array.isArray(t) && t.forEach((s) => s.dispose(!0)), this.parent ? this.parent.removeChild(this, e) : e || a.emit(f, this), this.parent = null, this.disposed = !0, delete _.nodes[this.id]);
|
|
425
425
|
}
|
|
426
426
|
lock(e = !1) {
|
|
427
427
|
if (this.locked = !0, Array.isArray(this.children))
|
|
428
428
|
for (const t of this.children)
|
|
429
429
|
t.lock(!0);
|
|
430
|
-
e ||
|
|
430
|
+
e || a.emit(f, this);
|
|
431
431
|
}
|
|
432
432
|
unlock(e = !1) {
|
|
433
433
|
if (this.locked = !1, Array.isArray(this.children))
|
|
434
434
|
for (const t of this.children)
|
|
435
435
|
t.unlock(!0);
|
|
436
|
-
e ||
|
|
436
|
+
e || a.emit(f, this);
|
|
437
437
|
}
|
|
438
438
|
setVisible(e, t = !1) {
|
|
439
439
|
if (this.invisible = !e, Array.isArray(this.children))
|
|
440
440
|
for (const i of this.children)
|
|
441
441
|
i.setVisible(e, !0);
|
|
442
|
-
t ||
|
|
442
|
+
t || a.emit(f, this);
|
|
443
443
|
}
|
|
444
444
|
isChild(e) {
|
|
445
445
|
let t = !1;
|
|
@@ -457,8 +457,8 @@ class _ {
|
|
|
457
457
|
return Array.isArray(this.children) ? this.children.findIndex((t) => t === e || t.id === e.id) : -1;
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
const
|
|
461
|
-
class
|
|
460
|
+
const h = "EVENT_BLOCK_CHANGE";
|
|
461
|
+
class v {
|
|
462
462
|
__VTJ_BLOCK__ = !0;
|
|
463
463
|
id;
|
|
464
464
|
name = "";
|
|
@@ -511,12 +511,12 @@ class u {
|
|
|
511
511
|
this.id = t || m(), this.update(e, !0);
|
|
512
512
|
}
|
|
513
513
|
update(e, t = !1) {
|
|
514
|
-
for (const s of
|
|
515
|
-
const
|
|
516
|
-
(
|
|
514
|
+
for (const s of v.normalAttrs) {
|
|
515
|
+
const n = e[s];
|
|
516
|
+
(n !== void 0 || s === "setup") && (this[s] = n);
|
|
517
517
|
}
|
|
518
518
|
const { nodes: i = [] } = e;
|
|
519
|
-
i.length ? this.nodes = i.map((s) => new _(s)) : this.nodes = [], t ||
|
|
519
|
+
i.length ? this.nodes = i.map((s) => new _(s)) : this.nodes = [], t || a.emit(h, this);
|
|
520
520
|
}
|
|
521
521
|
/**
|
|
522
522
|
* 获取DSL
|
|
@@ -525,14 +525,14 @@ class u {
|
|
|
525
525
|
toDsl(e) {
|
|
526
526
|
const { __VTJ_BLOCK__: t, id: i, nodes: s } = this;
|
|
527
527
|
return {
|
|
528
|
-
...
|
|
529
|
-
(
|
|
528
|
+
...v.normalAttrs.reduce(
|
|
529
|
+
(r, l) => (r[l] = this[l], r),
|
|
530
530
|
{}
|
|
531
531
|
),
|
|
532
532
|
__VTJ_BLOCK__: t,
|
|
533
|
-
__VERSION__: e ||
|
|
533
|
+
__VERSION__: e || Z().toString(),
|
|
534
534
|
id: i,
|
|
535
|
-
nodes: s.map((
|
|
535
|
+
nodes: s.map((r) => r.toDsl())
|
|
536
536
|
};
|
|
537
537
|
}
|
|
538
538
|
/**
|
|
@@ -552,7 +552,7 @@ class u {
|
|
|
552
552
|
* @param silent
|
|
553
553
|
*/
|
|
554
554
|
setFunction(e, t, i, s = !1) {
|
|
555
|
-
this[e][t] = i, s ||
|
|
555
|
+
this[e][t] = i, s || a.emit(h, this);
|
|
556
556
|
}
|
|
557
557
|
/**
|
|
558
558
|
* 删除通用函数属性
|
|
@@ -561,10 +561,10 @@ class u {
|
|
|
561
561
|
* @param silent
|
|
562
562
|
*/
|
|
563
563
|
removeFunction(e, t, i = !1) {
|
|
564
|
-
delete this[e][t], i ||
|
|
564
|
+
delete this[e][t], i || a.emit(h, this);
|
|
565
565
|
}
|
|
566
566
|
setComputed(e, t, i = !1) {
|
|
567
|
-
t ? this.computed[e] = t : delete this.computed[e], i ||
|
|
567
|
+
t ? this.computed[e] = t : delete this.computed[e], i || a.emit(h, this);
|
|
568
568
|
}
|
|
569
569
|
/**
|
|
570
570
|
* 设置状态
|
|
@@ -573,7 +573,7 @@ class u {
|
|
|
573
573
|
* @param silent
|
|
574
574
|
*/
|
|
575
575
|
setState(e, t, i = !1) {
|
|
576
|
-
this.state[e] = t, i ||
|
|
576
|
+
this.state[e] = t, i || a.emit(h, this);
|
|
577
577
|
}
|
|
578
578
|
/**
|
|
579
579
|
* 删除状态
|
|
@@ -581,7 +581,7 @@ class u {
|
|
|
581
581
|
* @param silent
|
|
582
582
|
*/
|
|
583
583
|
removeState(e, t = !1) {
|
|
584
|
-
delete this.state[e], t ||
|
|
584
|
+
delete this.state[e], t || a.emit(h, this);
|
|
585
585
|
}
|
|
586
586
|
/**
|
|
587
587
|
* 更新CSS
|
|
@@ -589,7 +589,7 @@ class u {
|
|
|
589
589
|
* @param silent
|
|
590
590
|
*/
|
|
591
591
|
setCss(e, t = !1) {
|
|
592
|
-
this.css = e, t ||
|
|
592
|
+
this.css = e, t || a.emit(h, this);
|
|
593
593
|
}
|
|
594
594
|
/**
|
|
595
595
|
* 新增或更新 watch
|
|
@@ -601,7 +601,7 @@ class u {
|
|
|
601
601
|
const i = this.watch.findIndex(
|
|
602
602
|
(s) => s.id && s.id === e.id || s === e
|
|
603
603
|
);
|
|
604
|
-
i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t ||
|
|
604
|
+
i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || a.emit(h, this);
|
|
605
605
|
}
|
|
606
606
|
/**
|
|
607
607
|
* 删除 watch
|
|
@@ -612,7 +612,7 @@ class u {
|
|
|
612
612
|
const i = this.watch.findIndex(
|
|
613
613
|
(s) => s.id && s.id === e.id || s === e
|
|
614
614
|
);
|
|
615
|
-
i > -1 && (this.watch.splice(i, 1), t ||
|
|
615
|
+
i > -1 && (this.watch.splice(i, 1), t || a.emit(h, this));
|
|
616
616
|
}
|
|
617
617
|
/**
|
|
618
618
|
* 定义属性参数
|
|
@@ -623,7 +623,7 @@ class u {
|
|
|
623
623
|
const i = this.props.findIndex(
|
|
624
624
|
(s) => typeof s == "string" ? s === e.name : s.name === e.name
|
|
625
625
|
);
|
|
626
|
-
i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t ||
|
|
626
|
+
i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || a.emit(h, this);
|
|
627
627
|
}
|
|
628
628
|
/**
|
|
629
629
|
* 删除属性
|
|
@@ -634,7 +634,7 @@ class u {
|
|
|
634
634
|
const i = this.props.findIndex(
|
|
635
635
|
(s) => typeof s == "string" ? s === e.name : s.name === e.name
|
|
636
636
|
);
|
|
637
|
-
i > -1 && (this.props.splice(i, 1), t ||
|
|
637
|
+
i > -1 && (this.props.splice(i, 1), t || a.emit(h, this));
|
|
638
638
|
}
|
|
639
639
|
/**
|
|
640
640
|
* 设置事件
|
|
@@ -642,10 +642,10 @@ class u {
|
|
|
642
642
|
* @param silent
|
|
643
643
|
*/
|
|
644
644
|
setEmit(e, t = !1) {
|
|
645
|
-
const i =
|
|
646
|
-
(
|
|
645
|
+
const i = S(e) ? { name: e, params: [] } : e, s = this.emits.findIndex(
|
|
646
|
+
(n) => n === i.name || n.name === i.name
|
|
647
647
|
);
|
|
648
|
-
s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t ||
|
|
648
|
+
s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || a.emit(h, this);
|
|
649
649
|
}
|
|
650
650
|
/**
|
|
651
651
|
* 删除事件
|
|
@@ -654,12 +654,12 @@ class u {
|
|
|
654
654
|
*/
|
|
655
655
|
removeEmit(e, t = !1) {
|
|
656
656
|
const i = this.emits.findIndex(
|
|
657
|
-
(s) =>
|
|
657
|
+
(s) => S(s) ? s === e : s.name === e
|
|
658
658
|
);
|
|
659
|
-
i > -1 && (this.emits.splice(i, 1), t ||
|
|
659
|
+
i > -1 && (this.emits.splice(i, 1), t || a.emit(h, this));
|
|
660
660
|
}
|
|
661
661
|
setExpose(e, t = !1) {
|
|
662
|
-
this.expose = e, t ||
|
|
662
|
+
this.expose = e, t || a.emit(h, this);
|
|
663
663
|
}
|
|
664
664
|
/**
|
|
665
665
|
* 设置插槽
|
|
@@ -667,10 +667,10 @@ class u {
|
|
|
667
667
|
* @param silent
|
|
668
668
|
*/
|
|
669
669
|
setSlot(e, t = !1) {
|
|
670
|
-
const i =
|
|
671
|
-
(
|
|
670
|
+
const i = S(e) ? { name: e, params: [] } : e, s = this.slots.findIndex(
|
|
671
|
+
(n) => n === i.name || n.name === i.name
|
|
672
672
|
);
|
|
673
|
-
s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t ||
|
|
673
|
+
s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || a.emit(h, this);
|
|
674
674
|
}
|
|
675
675
|
/**
|
|
676
676
|
* 删除插槽
|
|
@@ -679,9 +679,9 @@ class u {
|
|
|
679
679
|
*/
|
|
680
680
|
removeSlot(e, t = !1) {
|
|
681
681
|
const i = this.slots.findIndex(
|
|
682
|
-
(s) =>
|
|
682
|
+
(s) => S(s) ? s === e : s.name === e
|
|
683
683
|
);
|
|
684
|
-
i > -1 && (this.slots.splice(i, 1), t ||
|
|
684
|
+
i > -1 && (this.slots.splice(i, 1), t || a.emit(h, this));
|
|
685
685
|
}
|
|
686
686
|
/**
|
|
687
687
|
* 设置注入
|
|
@@ -690,7 +690,7 @@ class u {
|
|
|
690
690
|
*/
|
|
691
691
|
setInject(e, t = !1) {
|
|
692
692
|
const i = this.inject.findIndex((s) => s.name === e.name);
|
|
693
|
-
i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t ||
|
|
693
|
+
i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || a.emit(h, this);
|
|
694
694
|
}
|
|
695
695
|
/**
|
|
696
696
|
* 删除注入
|
|
@@ -699,7 +699,7 @@ class u {
|
|
|
699
699
|
*/
|
|
700
700
|
removeInject(e, t = !1) {
|
|
701
701
|
const i = this.inject.findIndex((s) => s.name === e.name);
|
|
702
|
-
i > -1 && (this.inject.splice(i, 1), t ||
|
|
702
|
+
i > -1 && (this.inject.splice(i, 1), t || a.emit(h, this));
|
|
703
703
|
}
|
|
704
704
|
/**
|
|
705
705
|
* 设置数据源
|
|
@@ -707,7 +707,7 @@ class u {
|
|
|
707
707
|
* @param silent
|
|
708
708
|
*/
|
|
709
709
|
setDataSource(e, t = !1) {
|
|
710
|
-
this.dataSources[e.name] = e, t ||
|
|
710
|
+
this.dataSources[e.name] = e, t || a.emit(h, this);
|
|
711
711
|
}
|
|
712
712
|
/**
|
|
713
713
|
* 删除数据源
|
|
@@ -715,7 +715,7 @@ class u {
|
|
|
715
715
|
* @param silent
|
|
716
716
|
*/
|
|
717
717
|
removeDataSource(e, t = !1) {
|
|
718
|
-
delete this.dataSources[e], t ||
|
|
718
|
+
delete this.dataSources[e], t || a.emit(h, this);
|
|
719
719
|
}
|
|
720
720
|
/**
|
|
721
721
|
* 设置 API 风格
|
|
@@ -723,7 +723,7 @@ class u {
|
|
|
723
723
|
* @param silent
|
|
724
724
|
*/
|
|
725
725
|
setApiMode(e, t = !1) {
|
|
726
|
-
this.apiMode = e, t ||
|
|
726
|
+
this.apiMode = e, t || a.emit(h, this);
|
|
727
727
|
}
|
|
728
728
|
/**
|
|
729
729
|
* 设置 ref 声明
|
|
@@ -732,7 +732,7 @@ class u {
|
|
|
732
732
|
* @param silent
|
|
733
733
|
*/
|
|
734
734
|
setRef(e, t, i = !1) {
|
|
735
|
-
this.refs[e] = t, i ||
|
|
735
|
+
this.refs[e] = t, i || a.emit(h, this);
|
|
736
736
|
}
|
|
737
737
|
/**
|
|
738
738
|
* 删除 ref 声明
|
|
@@ -740,7 +740,7 @@ class u {
|
|
|
740
740
|
* @param silent
|
|
741
741
|
*/
|
|
742
742
|
removeRef(e, t = !1) {
|
|
743
|
-
delete this.refs[e], t ||
|
|
743
|
+
delete this.refs[e], t || a.emit(h, this);
|
|
744
744
|
}
|
|
745
745
|
/**
|
|
746
746
|
* 设置 reactive 声明
|
|
@@ -749,7 +749,7 @@ class u {
|
|
|
749
749
|
* @param silent
|
|
750
750
|
*/
|
|
751
751
|
setReactive(e, t, i = !1) {
|
|
752
|
-
this.reactives[e] = t, i ||
|
|
752
|
+
this.reactives[e] = t, i || a.emit(h, this);
|
|
753
753
|
}
|
|
754
754
|
/**
|
|
755
755
|
* 删除 reactive 声明
|
|
@@ -757,7 +757,7 @@ class u {
|
|
|
757
757
|
* @param silent
|
|
758
758
|
*/
|
|
759
759
|
removeReactive(e, t = !1) {
|
|
760
|
-
delete this.reactives[e], t ||
|
|
760
|
+
delete this.reactives[e], t || a.emit(h, this);
|
|
761
761
|
}
|
|
762
762
|
/**
|
|
763
763
|
* 设置组合函数调用
|
|
@@ -766,7 +766,7 @@ class u {
|
|
|
766
766
|
*/
|
|
767
767
|
setComposable(e, t = !1) {
|
|
768
768
|
const i = this.composables.findIndex((s) => s.name === e.name);
|
|
769
|
-
i > -1 ? this.composables.splice(i, 1, e) : this.composables.push(e), t ||
|
|
769
|
+
i > -1 ? this.composables.splice(i, 1, e) : this.composables.push(e), t || a.emit(h, this);
|
|
770
770
|
}
|
|
771
771
|
/**
|
|
772
772
|
* 删除组合函数调用
|
|
@@ -775,7 +775,7 @@ class u {
|
|
|
775
775
|
*/
|
|
776
776
|
removeComposable(e, t = !1) {
|
|
777
777
|
const i = this.composables.findIndex((s) => s.name === e);
|
|
778
|
-
i > -1 && (this.composables.splice(i, 1), t ||
|
|
778
|
+
i > -1 && (this.composables.splice(i, 1), t || a.emit(h, this));
|
|
779
779
|
}
|
|
780
780
|
/**
|
|
781
781
|
* 设置 provide
|
|
@@ -784,7 +784,7 @@ class u {
|
|
|
784
784
|
* @param silent
|
|
785
785
|
*/
|
|
786
786
|
setProvide(e, t, i = !1) {
|
|
787
|
-
this.provide[e] = t, i ||
|
|
787
|
+
this.provide[e] = t, i || a.emit(h, this);
|
|
788
788
|
}
|
|
789
789
|
/**
|
|
790
790
|
* 删除 provide
|
|
@@ -792,7 +792,7 @@ class u {
|
|
|
792
792
|
* @param silent
|
|
793
793
|
*/
|
|
794
794
|
removeProvide(e, t = !1) {
|
|
795
|
-
delete this.provide[e], t ||
|
|
795
|
+
delete this.provide[e], t || a.emit(h, this);
|
|
796
796
|
}
|
|
797
797
|
/**
|
|
798
798
|
* 设置 setup 初始化代码
|
|
@@ -800,20 +800,20 @@ class u {
|
|
|
800
800
|
* @param silent
|
|
801
801
|
*/
|
|
802
802
|
setSetup(e, t = !1) {
|
|
803
|
-
this.setup = e, t ||
|
|
803
|
+
this.setup = e, t || a.emit(h, this);
|
|
804
804
|
}
|
|
805
805
|
insertAfter(e, t, i = !1) {
|
|
806
806
|
e.parent = null;
|
|
807
807
|
const s = this.nodes.indexOf(t);
|
|
808
|
-
this.nodes.splice(s + 1, 0, e), i ||
|
|
808
|
+
this.nodes.splice(s + 1, 0, e), i || a.emit(h, this);
|
|
809
809
|
}
|
|
810
810
|
insertBefore(e, t, i = !1) {
|
|
811
811
|
e.parent = null;
|
|
812
812
|
const s = this.nodes.indexOf(t);
|
|
813
|
-
this.nodes.splice(s, 0, e), i ||
|
|
813
|
+
this.nodes.splice(s, 0, e), i || a.emit(h, this);
|
|
814
814
|
}
|
|
815
815
|
appendNode(e, t = !1) {
|
|
816
|
-
e.parent = null, this.nodes.push(e), t ||
|
|
816
|
+
e.parent = null, this.nodes.push(e), t || a.emit(h, this);
|
|
817
817
|
}
|
|
818
818
|
/**
|
|
819
819
|
* 添加节点
|
|
@@ -827,7 +827,7 @@ class u {
|
|
|
827
827
|
}
|
|
828
828
|
__removeNode(e, t = !1) {
|
|
829
829
|
const i = this.nodes.findIndex((s) => s.id === e.id);
|
|
830
|
-
i > -1 && (this.nodes.splice(i, 1), t ||
|
|
830
|
+
i > -1 && (this.nodes.splice(i, 1), t || a.emit(h, this));
|
|
831
831
|
}
|
|
832
832
|
/**
|
|
833
833
|
* 删除节点
|
|
@@ -857,7 +857,7 @@ class u {
|
|
|
857
857
|
e.movePrev(t);
|
|
858
858
|
else {
|
|
859
859
|
const i = this.nodes, s = i.indexOf(e);
|
|
860
|
-
s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t ||
|
|
860
|
+
s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || a.emit(h, this));
|
|
861
861
|
}
|
|
862
862
|
}
|
|
863
863
|
/**
|
|
@@ -870,7 +870,7 @@ class u {
|
|
|
870
870
|
e.moveNext(t);
|
|
871
871
|
else {
|
|
872
872
|
const i = this.nodes, s = i.indexOf(e);
|
|
873
|
-
s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t ||
|
|
873
|
+
s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || a.emit(h, this));
|
|
874
874
|
}
|
|
875
875
|
}
|
|
876
876
|
/**
|
|
@@ -880,20 +880,20 @@ class u {
|
|
|
880
880
|
* @returns
|
|
881
881
|
*/
|
|
882
882
|
cloneNode(e, t = !1) {
|
|
883
|
-
const i =
|
|
883
|
+
const i = Y(e.toDsl()), s = new _(i);
|
|
884
884
|
return this.addNode(s, e, "bottom", t), s;
|
|
885
885
|
}
|
|
886
886
|
lock(e = !1) {
|
|
887
887
|
this.locked = !0;
|
|
888
888
|
for (const t of this.nodes)
|
|
889
889
|
t.lock(!0);
|
|
890
|
-
e ||
|
|
890
|
+
e || a.emit(h, this);
|
|
891
891
|
}
|
|
892
892
|
unlock(e = !1) {
|
|
893
893
|
this.locked = !1;
|
|
894
894
|
for (const t of this.nodes)
|
|
895
895
|
t.unlock(!0);
|
|
896
|
-
e ||
|
|
896
|
+
e || a.emit(h, this);
|
|
897
897
|
}
|
|
898
898
|
isChild(e) {
|
|
899
899
|
let t = !1;
|
|
@@ -906,7 +906,7 @@ class u {
|
|
|
906
906
|
return t;
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
const
|
|
909
|
+
const c = "EVENT_PROJECT_CHANGE", F = "EVENT_PROJECT_ACTIVED", J = "EVENT_PROJECT_DEPS_CHANGE", x = "EVENT_PROJECT_PAGES_CHANGE", C = "EVENT_PROJECT_BLOCKS_CHANGE", k = "EVENT_PROJECT_APIS_CHANGE", G = "EVENT_PROJECT_META_CHANGE", ee = "EVENT_PROJECT_PUBLISH", te = "EVENT_PROJECT_FILE_PUBLISH", ie = "EVENT_PROJECT_GEN_SOURCE";
|
|
910
910
|
class b {
|
|
911
911
|
id = "";
|
|
912
912
|
locked = "";
|
|
@@ -930,7 +930,7 @@ class b {
|
|
|
930
930
|
};
|
|
931
931
|
env = [];
|
|
932
932
|
__BASE_PATH__ = "/";
|
|
933
|
-
__UID__ =
|
|
933
|
+
__UID__ = H(!0);
|
|
934
934
|
static attrs = [
|
|
935
935
|
"locked",
|
|
936
936
|
"platform",
|
|
@@ -952,14 +952,14 @@ class b {
|
|
|
952
952
|
];
|
|
953
953
|
constructor(e) {
|
|
954
954
|
const { id: t, __UID__: i } = e;
|
|
955
|
-
this.id = t || m(), this.__UID__ = i ||
|
|
955
|
+
this.id = t || m(), this.__UID__ = i || H(!0), this.update(e, !0);
|
|
956
956
|
}
|
|
957
957
|
update(e, t = !1) {
|
|
958
958
|
for (const i of b.attrs) {
|
|
959
959
|
const s = e[i];
|
|
960
960
|
s && (this[i] = s);
|
|
961
961
|
}
|
|
962
|
-
t ||
|
|
962
|
+
t || a.emit(c, {
|
|
963
963
|
model: this,
|
|
964
964
|
type: "update",
|
|
965
965
|
data: e
|
|
@@ -974,13 +974,13 @@ class b {
|
|
|
974
974
|
}
|
|
975
975
|
toDsl(e) {
|
|
976
976
|
const { id: t } = this, i = b.attrs.reduce(
|
|
977
|
-
(s,
|
|
977
|
+
(s, n) => (s[n] = this[n], s),
|
|
978
978
|
{}
|
|
979
979
|
);
|
|
980
|
-
return i.pages && (i.pages = i.pages.map((s) =>
|
|
980
|
+
return i.pages && (i.pages = i.pages.map((s) => A({
|
|
981
981
|
...s,
|
|
982
982
|
dsl: void 0
|
|
983
|
-
})), this.cleanPagesDsl(i.pages)), i.blocks && (i.blocks = i.blocks.map((s) =>
|
|
983
|
+
})), this.cleanPagesDsl(i.pages)), i.blocks && (i.blocks = i.blocks.map((s) => A({
|
|
984
984
|
...s,
|
|
985
985
|
dsl: void 0
|
|
986
986
|
}))), {
|
|
@@ -995,7 +995,7 @@ class b {
|
|
|
995
995
|
* @param silent
|
|
996
996
|
*/
|
|
997
997
|
active(e, t = !1) {
|
|
998
|
-
this.currentFile = e, t ||
|
|
998
|
+
this.currentFile = e, t || a.emit(F, {
|
|
999
999
|
model: this,
|
|
1000
1000
|
type: "update",
|
|
1001
1001
|
data: e
|
|
@@ -1006,7 +1006,7 @@ class b {
|
|
|
1006
1006
|
* @param silent
|
|
1007
1007
|
*/
|
|
1008
1008
|
deactivate(e = !1) {
|
|
1009
|
-
this.currentFile = null, e ||
|
|
1009
|
+
this.currentFile = null, e || a.emit(F, {
|
|
1010
1010
|
model: this,
|
|
1011
1011
|
type: "update",
|
|
1012
1012
|
data: null
|
|
@@ -1018,18 +1018,18 @@ class b {
|
|
|
1018
1018
|
* @param silent
|
|
1019
1019
|
*/
|
|
1020
1020
|
setDeps(e, t = !1) {
|
|
1021
|
-
const i = this.dependencies, s = i.findIndex((
|
|
1022
|
-
let
|
|
1023
|
-
if (s > -1 ? (
|
|
1021
|
+
const i = this.dependencies, s = i.findIndex((r) => r.package === e.package);
|
|
1022
|
+
let n;
|
|
1023
|
+
if (s > -1 ? (n = "update", i.splice(s, 1, {
|
|
1024
1024
|
...i[s],
|
|
1025
1025
|
...e
|
|
1026
|
-
})) : (
|
|
1027
|
-
const
|
|
1026
|
+
})) : (n = "create", i.push(e)), !t) {
|
|
1027
|
+
const r = {
|
|
1028
1028
|
model: this,
|
|
1029
|
-
type:
|
|
1029
|
+
type: n,
|
|
1030
1030
|
data: e
|
|
1031
1031
|
};
|
|
1032
|
-
|
|
1032
|
+
a.emit(J, r), a.emit(c, r);
|
|
1033
1033
|
}
|
|
1034
1034
|
}
|
|
1035
1035
|
/**
|
|
@@ -1038,14 +1038,14 @@ class b {
|
|
|
1038
1038
|
* @param silent
|
|
1039
1039
|
*/
|
|
1040
1040
|
removeDeps(e, t = !1) {
|
|
1041
|
-
const i = this.dependencies, s = i.findIndex((
|
|
1041
|
+
const i = this.dependencies, s = i.findIndex((n) => n.package === e.package);
|
|
1042
1042
|
if (s > -1 && i.splice(s, 1), !t) {
|
|
1043
|
-
const
|
|
1043
|
+
const n = {
|
|
1044
1044
|
model: this,
|
|
1045
1045
|
type: "delete",
|
|
1046
1046
|
data: e
|
|
1047
1047
|
};
|
|
1048
|
-
|
|
1048
|
+
a.emit(J, n), a.emit(c, n);
|
|
1049
1049
|
}
|
|
1050
1050
|
}
|
|
1051
1051
|
/**
|
|
@@ -1055,13 +1055,13 @@ class b {
|
|
|
1055
1055
|
*/
|
|
1056
1056
|
getPage(e) {
|
|
1057
1057
|
const t = (i, s = []) => {
|
|
1058
|
-
for (const
|
|
1059
|
-
if (
|
|
1060
|
-
return
|
|
1061
|
-
if (
|
|
1062
|
-
const
|
|
1063
|
-
if (
|
|
1064
|
-
return
|
|
1058
|
+
for (const n of s) {
|
|
1059
|
+
if (n.id === i)
|
|
1060
|
+
return n;
|
|
1061
|
+
if (n.children && n.children.length) {
|
|
1062
|
+
const r = t(i, n.children);
|
|
1063
|
+
if (r)
|
|
1064
|
+
return r;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
};
|
|
@@ -1090,9 +1090,17 @@ class b {
|
|
|
1090
1090
|
* @param silent
|
|
1091
1091
|
*/
|
|
1092
1092
|
async createPage(e, t, i = !1) {
|
|
1093
|
-
if (e.id = e.
|
|
1093
|
+
if (e.id = e.id || m(), e.type = "page", e.name = y(e.name), this.existPageName(e.name))
|
|
1094
|
+
throw new Error(`页面名称【${e.name}】已经存在`);
|
|
1095
|
+
if (e.dir)
|
|
1096
|
+
delete e.filePath, delete e.routePath;
|
|
1097
|
+
else {
|
|
1098
|
+
const s = N(e.name);
|
|
1099
|
+
e.filePath = s, e.routePath = this.platform === "uniapp" ? void 0 : `/page/${s}`;
|
|
1100
|
+
}
|
|
1101
|
+
if (this.validatePagePath(e), e.dir ? e.children = [] : e.dsl = e.dsl || new v({
|
|
1094
1102
|
id: e.id,
|
|
1095
|
-
name:
|
|
1103
|
+
name: y(e.name),
|
|
1096
1104
|
apiMode: "composition"
|
|
1097
1105
|
}).toDsl(), t) {
|
|
1098
1106
|
const s = this.getPage(t);
|
|
@@ -1105,9 +1113,9 @@ class b {
|
|
|
1105
1113
|
type: "create",
|
|
1106
1114
|
data: e
|
|
1107
1115
|
};
|
|
1108
|
-
|
|
1116
|
+
a.emit(x, s), a.emit(c, s);
|
|
1109
1117
|
}
|
|
1110
|
-
return !this.currentFile && !e.dir && (this.active(e, !0), await
|
|
1118
|
+
return !this.currentFile && !e.dir && (this.active(e, !0), await B(1e3), this.active(e, i)), e;
|
|
1111
1119
|
}
|
|
1112
1120
|
/**
|
|
1113
1121
|
* 更新页面
|
|
@@ -1116,48 +1124,60 @@ class b {
|
|
|
1116
1124
|
*/
|
|
1117
1125
|
updatePage(e, t = !1) {
|
|
1118
1126
|
const i = this.getPage(e.id);
|
|
1119
|
-
|
|
1120
|
-
|
|
1127
|
+
let s;
|
|
1128
|
+
if (delete e.dsl, i) {
|
|
1129
|
+
if (s = { ...i }, e.name = y(e.name), this.existPageName(e.name, [e.id]))
|
|
1130
|
+
throw new Error(`页面名称【${e.name}】已经存在`);
|
|
1131
|
+
if (e.name !== i.name && !i.raw) {
|
|
1132
|
+
const n = N(i.name);
|
|
1133
|
+
i.filePath === n && (e.filePath = N(e.name)), this.platform !== "uniapp" && i.routePath === `/page/${n}` && (e.routePath = `/page/${N(e.name)}`);
|
|
1134
|
+
}
|
|
1135
|
+
this.validatePagePath(e, [e.id]), Object.assign(i, e);
|
|
1136
|
+
} else
|
|
1137
|
+
console.warn(`not found PageFile for id: ${e.id} `);
|
|
1138
|
+
if (!t) {
|
|
1139
|
+
const n = {
|
|
1121
1140
|
model: this,
|
|
1122
1141
|
type: "update",
|
|
1123
|
-
data: e
|
|
1142
|
+
data: e,
|
|
1143
|
+
previous: s
|
|
1124
1144
|
};
|
|
1125
|
-
|
|
1145
|
+
a.emit(x, n), a.emit(c, n);
|
|
1126
1146
|
}
|
|
1127
1147
|
return i;
|
|
1128
1148
|
}
|
|
1129
1149
|
findParent(e) {
|
|
1130
|
-
const t = (i, s = [],
|
|
1131
|
-
for (const
|
|
1132
|
-
if (
|
|
1133
|
-
return
|
|
1134
|
-
if (
|
|
1135
|
-
const
|
|
1136
|
-
if (
|
|
1137
|
-
return
|
|
1150
|
+
const t = (i, s = [], n) => {
|
|
1151
|
+
for (const r of s) {
|
|
1152
|
+
if (r.id === i)
|
|
1153
|
+
return n;
|
|
1154
|
+
if (r.children && r.children.length) {
|
|
1155
|
+
const l = t(i, r.children, r);
|
|
1156
|
+
if (l)
|
|
1157
|
+
return l;
|
|
1138
1158
|
}
|
|
1139
1159
|
}
|
|
1140
1160
|
};
|
|
1141
1161
|
return t(e, this.pages);
|
|
1142
1162
|
}
|
|
1143
1163
|
movePageTo(e, t, i = !1) {
|
|
1144
|
-
const s = t ? this.getPage(t) : null,
|
|
1145
|
-
if (!
|
|
1146
|
-
const
|
|
1147
|
-
if (
|
|
1148
|
-
(
|
|
1149
|
-
) : this.pages = this.pages.filter((
|
|
1150
|
-
const
|
|
1164
|
+
const s = t ? this.getPage(t) : null, n = this.getPage(e);
|
|
1165
|
+
if (!n) return !1;
|
|
1166
|
+
const r = this.findParent(e);
|
|
1167
|
+
if (r ? r.children = r.children?.filter(
|
|
1168
|
+
(l) => l.id !== e
|
|
1169
|
+
) : this.pages = this.pages.filter((l) => l.id !== e), s ? (s.dir || s.layout) && (s.children ? s.children.push(n) : s.children = [n]) : this.pages.push(n), !i) {
|
|
1170
|
+
const l = {
|
|
1151
1171
|
model: this,
|
|
1152
1172
|
type: "update",
|
|
1153
|
-
data:
|
|
1173
|
+
data: n
|
|
1154
1174
|
};
|
|
1155
|
-
|
|
1175
|
+
a.emit(x, l), a.emit(c, l);
|
|
1156
1176
|
}
|
|
1157
1177
|
return !0;
|
|
1158
1178
|
}
|
|
1159
1179
|
getPageTree() {
|
|
1160
|
-
const e =
|
|
1180
|
+
const e = A(this.pages);
|
|
1161
1181
|
return this.cleanPagesDsl(e), e;
|
|
1162
1182
|
}
|
|
1163
1183
|
/**
|
|
@@ -1167,44 +1187,58 @@ class b {
|
|
|
1167
1187
|
* @param silent
|
|
1168
1188
|
*/
|
|
1169
1189
|
clonePage(e, t, i = !1) {
|
|
1170
|
-
const s = m(),
|
|
1190
|
+
const s = m(), n = this.createUniquePath(
|
|
1191
|
+
`${e.name}Copy`,
|
|
1192
|
+
(E) => this.existPageName(E)
|
|
1193
|
+
), r = `${e.title}_副本`, l = new v({
|
|
1171
1194
|
id: s,
|
|
1172
|
-
name:
|
|
1195
|
+
name: n,
|
|
1173
1196
|
apiMode: "composition"
|
|
1174
|
-
}).toDsl(),
|
|
1175
|
-
|
|
1176
|
-
|
|
1197
|
+
}).toDsl(), d = N(n), P = this.platform === "uniapp" ? void 0 : `/page/${d}`, u = U({}, e, {
|
|
1198
|
+
id: s,
|
|
1199
|
+
name: n,
|
|
1200
|
+
title: r,
|
|
1201
|
+
filePath: d,
|
|
1202
|
+
routePath: P,
|
|
1203
|
+
dsl: l
|
|
1204
|
+
}), O = t ? this.getPage(t)?.children || [] : this.pages, R = O.findIndex((E) => E.id === e.id);
|
|
1205
|
+
if (O.splice(R + 1, 0, u), !i) {
|
|
1206
|
+
const E = {
|
|
1177
1207
|
model: this,
|
|
1178
1208
|
type: "clone",
|
|
1179
1209
|
data: {
|
|
1180
1210
|
source: e,
|
|
1181
|
-
target:
|
|
1211
|
+
target: u
|
|
1182
1212
|
}
|
|
1183
1213
|
};
|
|
1184
|
-
|
|
1214
|
+
a.emit(x, E), a.emit(c, E);
|
|
1185
1215
|
}
|
|
1186
1216
|
}
|
|
1187
1217
|
async saveToBlock(e, t = !1) {
|
|
1188
|
-
this.active(e, t), await
|
|
1189
|
-
const i = m(), s =
|
|
1218
|
+
this.active(e, t), await B(1e3);
|
|
1219
|
+
const i = m(), s = this.createUniquePath(
|
|
1220
|
+
e.name,
|
|
1221
|
+
(d) => this.existBlockName(d)
|
|
1222
|
+
), n = e.title, r = new v({
|
|
1190
1223
|
...e.dsl,
|
|
1191
1224
|
id: i,
|
|
1192
1225
|
name: s
|
|
1193
|
-
}).toDsl(),
|
|
1226
|
+
}).toDsl(), l = {
|
|
1194
1227
|
id: i,
|
|
1195
1228
|
name: s,
|
|
1196
|
-
title:
|
|
1197
|
-
|
|
1229
|
+
title: n,
|
|
1230
|
+
filePath: s,
|
|
1231
|
+
dsl: r,
|
|
1198
1232
|
type: "block",
|
|
1199
1233
|
fromType: "Schema"
|
|
1200
|
-
}
|
|
1201
|
-
if (this.blocks.push(
|
|
1202
|
-
const
|
|
1234
|
+
};
|
|
1235
|
+
if (this.blocks.push(l), !t) {
|
|
1236
|
+
const d = {
|
|
1203
1237
|
model: this,
|
|
1204
1238
|
type: "create",
|
|
1205
|
-
data:
|
|
1239
|
+
data: l
|
|
1206
1240
|
};
|
|
1207
|
-
|
|
1241
|
+
a.emit(C, d), a.emit(c, d);
|
|
1208
1242
|
}
|
|
1209
1243
|
}
|
|
1210
1244
|
/**
|
|
@@ -1213,22 +1247,22 @@ class b {
|
|
|
1213
1247
|
* @param silent
|
|
1214
1248
|
*/
|
|
1215
1249
|
removePage(e, t = !1) {
|
|
1216
|
-
const i = this.getPage(e), s = (
|
|
1217
|
-
const
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1250
|
+
const i = this.getPage(e), s = (n, r) => {
|
|
1251
|
+
const l = r.findIndex((d) => d.id === n);
|
|
1252
|
+
if (l >= 0) {
|
|
1253
|
+
r.splice(l, 1);
|
|
1220
1254
|
return;
|
|
1221
1255
|
}
|
|
1222
|
-
for (const
|
|
1223
|
-
|
|
1256
|
+
for (const d of r)
|
|
1257
|
+
d.children && d.children.length && s(n, d.children);
|
|
1224
1258
|
};
|
|
1225
1259
|
if (s(e, this.pages), e === this.homepage && (this.homepage = ""), this.currentFile?.id === e && this.deactivate(t), !t) {
|
|
1226
|
-
const
|
|
1260
|
+
const n = {
|
|
1227
1261
|
model: this,
|
|
1228
1262
|
type: "delete",
|
|
1229
1263
|
data: i
|
|
1230
1264
|
};
|
|
1231
|
-
|
|
1265
|
+
a.emit(x, n), a.emit(c, n);
|
|
1232
1266
|
}
|
|
1233
1267
|
}
|
|
1234
1268
|
/**
|
|
@@ -1248,18 +1282,20 @@ class b {
|
|
|
1248
1282
|
* @param silent
|
|
1249
1283
|
*/
|
|
1250
1284
|
async createBlock(e, t = !1) {
|
|
1251
|
-
const i = e.id || m(), s =
|
|
1252
|
-
e.id = i, e.type = "block", e.fromType = e.fromType || "Schema",
|
|
1253
|
-
|
|
1285
|
+
const i = e.id || m(), s = y(e.name);
|
|
1286
|
+
if (e.id = i, e.name = s, e.type = "block", e.fromType = e.fromType || "Schema", this.existBlockName(s))
|
|
1287
|
+
throw new Error(`区块名称【${s}】已经存在`);
|
|
1288
|
+
e.fromType === "Schema" ? e.filePath = s : delete e.filePath, this.validateBlockPath(e), e.dsl = new v({ id: i, name: s, apiMode: "composition" }).toDsl(), this.blocks.push(e);
|
|
1289
|
+
const n = e.fromType || "Schema";
|
|
1254
1290
|
if (!t) {
|
|
1255
|
-
const
|
|
1291
|
+
const r = {
|
|
1256
1292
|
model: this,
|
|
1257
1293
|
type: "create",
|
|
1258
1294
|
data: e
|
|
1259
1295
|
};
|
|
1260
|
-
|
|
1296
|
+
a.emit(C, r), a.emit(c, r);
|
|
1261
1297
|
}
|
|
1262
|
-
return !this.currentFile &&
|
|
1298
|
+
return !this.currentFile && n === "Schema" && (this.active(e, !0), await B(1e3), this.active(e, t)), e;
|
|
1263
1299
|
}
|
|
1264
1300
|
/**
|
|
1265
1301
|
*
|
|
@@ -1268,32 +1304,43 @@ class b {
|
|
|
1268
1304
|
*/
|
|
1269
1305
|
updateBlock(e, t = !1) {
|
|
1270
1306
|
const i = this.getBlock(e.id);
|
|
1271
|
-
|
|
1272
|
-
|
|
1307
|
+
let s;
|
|
1308
|
+
if (i) {
|
|
1309
|
+
if (s = { ...i }, e.name = y(e.name), this.existBlockName(e.name, [e.id]))
|
|
1310
|
+
throw new Error(`区块名称【${e.name}】已经存在`);
|
|
1311
|
+
e.name !== i.name && (i.fromType || "Schema") === "Schema" && i.filePath === i.name && (e.filePath = e.name), this.validateBlockPath(e, [e.id]), Object.assign(i, e), i.dsl && (i.dsl.name = e.name);
|
|
1312
|
+
} else
|
|
1313
|
+
console.warn(`not found PageFile for id: ${e.id} `);
|
|
1314
|
+
if (!t) {
|
|
1315
|
+
const n = {
|
|
1273
1316
|
model: this,
|
|
1274
1317
|
type: "update",
|
|
1275
|
-
data: e
|
|
1318
|
+
data: e,
|
|
1319
|
+
previous: s
|
|
1276
1320
|
};
|
|
1277
|
-
|
|
1321
|
+
a.emit(C, n), a.emit(c, n);
|
|
1278
1322
|
}
|
|
1279
1323
|
return i;
|
|
1280
1324
|
}
|
|
1281
1325
|
cloneBlock(e, t = !1) {
|
|
1282
|
-
const i = m(), s =
|
|
1326
|
+
const i = m(), s = this.createUniquePath(
|
|
1327
|
+
`${e.name}Copy`,
|
|
1328
|
+
(u) => this.existBlockName(u)
|
|
1329
|
+
), n = `${e.title}_副本`, r = new v({
|
|
1283
1330
|
id: i,
|
|
1284
1331
|
name: s,
|
|
1285
1332
|
apiMode: "composition"
|
|
1286
|
-
}).toDsl(),
|
|
1287
|
-
if (this.blocks.splice(
|
|
1288
|
-
const
|
|
1333
|
+
}).toDsl(), d = U({}, e, { id: i, name: s, title: n, filePath: s, dsl: r }), P = this.blocks.findIndex((u) => u.id === e.id);
|
|
1334
|
+
if (this.blocks.splice(P + 1, 0, d), !t) {
|
|
1335
|
+
const u = {
|
|
1289
1336
|
model: this,
|
|
1290
1337
|
type: "clone",
|
|
1291
1338
|
data: {
|
|
1292
1339
|
source: e,
|
|
1293
|
-
target:
|
|
1340
|
+
target: d
|
|
1294
1341
|
}
|
|
1295
1342
|
};
|
|
1296
|
-
|
|
1343
|
+
a.emit(C, u), a.emit(c, u);
|
|
1297
1344
|
}
|
|
1298
1345
|
}
|
|
1299
1346
|
/**
|
|
@@ -1302,14 +1349,14 @@ class b {
|
|
|
1302
1349
|
* @param silent
|
|
1303
1350
|
*/
|
|
1304
1351
|
removeBlock(e, t = !1) {
|
|
1305
|
-
const i = this.getBlock(e), s = this.blocks,
|
|
1306
|
-
if (
|
|
1307
|
-
const
|
|
1352
|
+
const i = this.getBlock(e), s = this.blocks, n = s.findIndex((r) => r.id === e);
|
|
1353
|
+
if (n > -1 ? (s.splice(n, 1), this.currentFile?.id === e && this.deactivate(t)) : console.warn(`not found PageFile for id: ${e} `), !t) {
|
|
1354
|
+
const r = {
|
|
1308
1355
|
model: this,
|
|
1309
1356
|
type: "delete",
|
|
1310
1357
|
data: i
|
|
1311
1358
|
};
|
|
1312
|
-
|
|
1359
|
+
a.emit(C, r), a.emit(c, r);
|
|
1313
1360
|
}
|
|
1314
1361
|
}
|
|
1315
1362
|
/**
|
|
@@ -1319,7 +1366,14 @@ class b {
|
|
|
1319
1366
|
* @returns
|
|
1320
1367
|
*/
|
|
1321
1368
|
existBlockName(e, t = []) {
|
|
1322
|
-
|
|
1369
|
+
const i = e.toLowerCase();
|
|
1370
|
+
return this.blocks.some((s) => s.name.toLowerCase() === i && !t.includes(s.id));
|
|
1371
|
+
}
|
|
1372
|
+
existBlockFilePath(e, t = []) {
|
|
1373
|
+
const i = L(e).toLowerCase();
|
|
1374
|
+
return this.blocks.some(
|
|
1375
|
+
(s) => p(s).toLowerCase() === i && !t.includes(s.id)
|
|
1376
|
+
);
|
|
1323
1377
|
}
|
|
1324
1378
|
/**
|
|
1325
1379
|
* 检测是否存在名称的页面
|
|
@@ -1328,7 +1382,44 @@ class b {
|
|
|
1328
1382
|
* @returns
|
|
1329
1383
|
*/
|
|
1330
1384
|
existPageName(e, t = []) {
|
|
1331
|
-
|
|
1385
|
+
const i = e.toLowerCase(), s = (n) => n.some((r) => r.name.toLowerCase() === i && !t.includes(r.id) ? !0 : r.children?.length ? s(r.children) : !1);
|
|
1386
|
+
return s(this.pages);
|
|
1387
|
+
}
|
|
1388
|
+
existPageFilePath(e, t = []) {
|
|
1389
|
+
const i = L(e).toLowerCase();
|
|
1390
|
+
return this.getPages().some(
|
|
1391
|
+
(s) => p(s).toLowerCase() === i && !t.includes(s.id)
|
|
1392
|
+
);
|
|
1393
|
+
}
|
|
1394
|
+
existRoutePath(e, t = []) {
|
|
1395
|
+
const i = V(e).replace(/:[^/]+/g, ":");
|
|
1396
|
+
return this.getPages().some((s) => $(s).replace(/:[^/]+/g, ":") === i && !t.includes(s.id));
|
|
1397
|
+
}
|
|
1398
|
+
validatePagePath(e, t = []) {
|
|
1399
|
+
const i = p(e);
|
|
1400
|
+
if (!e.dir && !M(i))
|
|
1401
|
+
throw new Error(`页面文件路径【${i}】格式不正确`);
|
|
1402
|
+
if (!ae(e.routePath))
|
|
1403
|
+
throw new Error(`页面路由【${e.routePath}】格式不正确`);
|
|
1404
|
+
if (!e.dir && this.existPageFilePath(p(e), t))
|
|
1405
|
+
throw new Error(`页面文件路径【${p(e)}】已经存在`);
|
|
1406
|
+
const s = $(e);
|
|
1407
|
+
if (!e.dir && this.existRoutePath(s, t))
|
|
1408
|
+
throw new Error(`页面路由【${s}】已经存在`);
|
|
1409
|
+
}
|
|
1410
|
+
validateBlockPath(e, t = []) {
|
|
1411
|
+
const i = p(e);
|
|
1412
|
+
if (!M(i))
|
|
1413
|
+
throw new Error(`区块文件路径【${i}】格式不正确`);
|
|
1414
|
+
if ((e.fromType || this.getBlock(e.id)?.fromType || "Schema") === "Schema" && this.existBlockFilePath(p(e), t))
|
|
1415
|
+
throw new Error(`区块文件路径【${p(e)}】已经存在`);
|
|
1416
|
+
}
|
|
1417
|
+
createUniquePath(e, t) {
|
|
1418
|
+
const i = e;
|
|
1419
|
+
let s = i, n = 2;
|
|
1420
|
+
for (; t(s); )
|
|
1421
|
+
s = `${i}${n++}`;
|
|
1422
|
+
return s;
|
|
1332
1423
|
}
|
|
1333
1424
|
/**
|
|
1334
1425
|
* 新增或更新api
|
|
@@ -1337,16 +1428,16 @@ class b {
|
|
|
1337
1428
|
*/
|
|
1338
1429
|
setApi(e, t = !1) {
|
|
1339
1430
|
const i = this.apis.find(
|
|
1340
|
-
(
|
|
1431
|
+
(n) => n.name === e.name || n.id === e.id
|
|
1341
1432
|
);
|
|
1342
1433
|
let s;
|
|
1343
1434
|
if (i ? (s = "update", Object.assign(i, e)) : (s = "create", e.id = m(), this.apis.push(e)), !t) {
|
|
1344
|
-
const
|
|
1435
|
+
const n = {
|
|
1345
1436
|
model: this,
|
|
1346
1437
|
type: s,
|
|
1347
1438
|
data: e
|
|
1348
1439
|
};
|
|
1349
|
-
|
|
1440
|
+
a.emit(k, n), a.emit(c, n);
|
|
1350
1441
|
}
|
|
1351
1442
|
return i || e;
|
|
1352
1443
|
}
|
|
@@ -1359,7 +1450,7 @@ class b {
|
|
|
1359
1450
|
type: "create",
|
|
1360
1451
|
data: e
|
|
1361
1452
|
};
|
|
1362
|
-
|
|
1453
|
+
a.emit(k, i), a.emit(c, i);
|
|
1363
1454
|
}
|
|
1364
1455
|
}
|
|
1365
1456
|
/**
|
|
@@ -1375,7 +1466,7 @@ class b {
|
|
|
1375
1466
|
type: "delete",
|
|
1376
1467
|
data: e
|
|
1377
1468
|
};
|
|
1378
|
-
|
|
1469
|
+
a.emit(k, s), a.emit(c, s);
|
|
1379
1470
|
}
|
|
1380
1471
|
}
|
|
1381
1472
|
existApiName(e, t = []) {
|
|
@@ -1383,16 +1474,16 @@ class b {
|
|
|
1383
1474
|
}
|
|
1384
1475
|
setMeta(e, t = !1) {
|
|
1385
1476
|
const i = this.meta.find(
|
|
1386
|
-
(
|
|
1477
|
+
(n) => n.code === e.code || n.id === e.id
|
|
1387
1478
|
);
|
|
1388
1479
|
let s;
|
|
1389
1480
|
if (i ? (s = "update", Object.assign(i, e)) : (s = "create", e.id = m(), this.meta.push(e)), !t) {
|
|
1390
|
-
const
|
|
1481
|
+
const n = {
|
|
1391
1482
|
model: this,
|
|
1392
1483
|
type: s,
|
|
1393
1484
|
data: e
|
|
1394
1485
|
};
|
|
1395
|
-
|
|
1486
|
+
a.emit(G, n), a.emit(c, n);
|
|
1396
1487
|
}
|
|
1397
1488
|
}
|
|
1398
1489
|
removeMeta(e, t = !1) {
|
|
@@ -1403,7 +1494,7 @@ class b {
|
|
|
1403
1494
|
type: "delete",
|
|
1404
1495
|
data: e
|
|
1405
1496
|
};
|
|
1406
|
-
|
|
1497
|
+
a.emit(G, s), a.emit(c, s);
|
|
1407
1498
|
}
|
|
1408
1499
|
}
|
|
1409
1500
|
existMetaCode(e, t = []) {
|
|
@@ -1416,7 +1507,7 @@ class b {
|
|
|
1416
1507
|
type: "update",
|
|
1417
1508
|
data: e
|
|
1418
1509
|
};
|
|
1419
|
-
|
|
1510
|
+
a.emit(c, i);
|
|
1420
1511
|
}
|
|
1421
1512
|
}
|
|
1422
1513
|
setConfig(e, t = !1) {
|
|
@@ -1426,7 +1517,7 @@ class b {
|
|
|
1426
1517
|
type: "update",
|
|
1427
1518
|
data: e
|
|
1428
1519
|
};
|
|
1429
|
-
|
|
1520
|
+
a.emit(c, i);
|
|
1430
1521
|
}
|
|
1431
1522
|
}
|
|
1432
1523
|
setUniConfig(e, t, i = !1) {
|
|
@@ -1436,7 +1527,7 @@ class b {
|
|
|
1436
1527
|
type: "update",
|
|
1437
1528
|
data: this.uniConfig
|
|
1438
1529
|
};
|
|
1439
|
-
|
|
1530
|
+
a.emit(c, s);
|
|
1440
1531
|
}
|
|
1441
1532
|
}
|
|
1442
1533
|
setGloblas(e, t, i = !1) {
|
|
@@ -1446,7 +1537,7 @@ class b {
|
|
|
1446
1537
|
type: "update",
|
|
1447
1538
|
data: this.globals
|
|
1448
1539
|
};
|
|
1449
|
-
|
|
1540
|
+
a.emit(c, s);
|
|
1450
1541
|
}
|
|
1451
1542
|
}
|
|
1452
1543
|
setI18n(e, t = !1) {
|
|
@@ -1456,7 +1547,7 @@ class b {
|
|
|
1456
1547
|
type: "update",
|
|
1457
1548
|
data: this.i18n
|
|
1458
1549
|
};
|
|
1459
|
-
|
|
1550
|
+
a.emit(c, i);
|
|
1460
1551
|
}
|
|
1461
1552
|
}
|
|
1462
1553
|
setEnv(e, t = !1) {
|
|
@@ -1466,7 +1557,7 @@ class b {
|
|
|
1466
1557
|
type: "update",
|
|
1467
1558
|
data: this.env
|
|
1468
1559
|
};
|
|
1469
|
-
|
|
1560
|
+
a.emit(c, i);
|
|
1470
1561
|
}
|
|
1471
1562
|
}
|
|
1472
1563
|
publish(e) {
|
|
@@ -1475,7 +1566,7 @@ class b {
|
|
|
1475
1566
|
type: "publish",
|
|
1476
1567
|
data: e || this
|
|
1477
1568
|
};
|
|
1478
|
-
e ?
|
|
1569
|
+
e ? a.emit(te, t) : a.emit(ee, t);
|
|
1479
1570
|
}
|
|
1480
1571
|
genSource() {
|
|
1481
1572
|
const e = {
|
|
@@ -1483,7 +1574,7 @@ class b {
|
|
|
1483
1574
|
type: "gen",
|
|
1484
1575
|
data: null
|
|
1485
1576
|
};
|
|
1486
|
-
|
|
1577
|
+
a.emit(ie, e);
|
|
1487
1578
|
}
|
|
1488
1579
|
lock(e) {
|
|
1489
1580
|
this.locked = e;
|
|
@@ -1492,7 +1583,7 @@ class b {
|
|
|
1492
1583
|
type: "update",
|
|
1493
1584
|
data: e
|
|
1494
1585
|
};
|
|
1495
|
-
|
|
1586
|
+
a.emit(c, t);
|
|
1496
1587
|
}
|
|
1497
1588
|
unlock(e) {
|
|
1498
1589
|
if (e !== this.locked)
|
|
@@ -1503,21 +1594,24 @@ class b {
|
|
|
1503
1594
|
type: "update",
|
|
1504
1595
|
data: null
|
|
1505
1596
|
};
|
|
1506
|
-
|
|
1597
|
+
a.emit(c, t);
|
|
1507
1598
|
}
|
|
1508
1599
|
getPageRoutes(e, t) {
|
|
1509
|
-
const i = this.platform === "uniapp", s = e || (i ? "pages" : "page"),
|
|
1510
|
-
return
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1600
|
+
const i = this.platform === "uniapp", s = e || (i ? "pages" : "page"), n = this.getPages(), r = t || "";
|
|
1601
|
+
return n.map((l) => {
|
|
1602
|
+
const d = i ? `/${ne(l)}` : $(l, `${r}/`, s);
|
|
1603
|
+
return {
|
|
1604
|
+
id: l.id,
|
|
1605
|
+
path: d,
|
|
1606
|
+
name: l.name,
|
|
1607
|
+
title: l.title,
|
|
1608
|
+
meta: l.meta
|
|
1609
|
+
};
|
|
1610
|
+
});
|
|
1517
1611
|
}
|
|
1518
1612
|
}
|
|
1519
|
-
const
|
|
1520
|
-
class
|
|
1613
|
+
const T = "EVENT_HISTORY_CHANGE", D = "EVENT_HISTORY_LOAD";
|
|
1614
|
+
class ve {
|
|
1521
1615
|
options = { max: 50 };
|
|
1522
1616
|
index = -1;
|
|
1523
1617
|
id;
|
|
@@ -1525,8 +1619,8 @@ class se {
|
|
|
1525
1619
|
items;
|
|
1526
1620
|
constructor(e, t = {}) {
|
|
1527
1621
|
Object.assign(this.options, t);
|
|
1528
|
-
const { id: i, type: s = "file", items:
|
|
1529
|
-
this.id = i, this.type = s, this.items =
|
|
1622
|
+
const { id: i, type: s = "file", items: n = [] } = e;
|
|
1623
|
+
this.id = i, this.type = s, this.items = n;
|
|
1530
1624
|
}
|
|
1531
1625
|
toDsl() {
|
|
1532
1626
|
const { id: e, type: t, items: i } = this;
|
|
@@ -1554,26 +1648,26 @@ class se {
|
|
|
1554
1648
|
* @param silent
|
|
1555
1649
|
*/
|
|
1556
1650
|
add(e, t = "", i = !1) {
|
|
1557
|
-
const { max: s } = this.options,
|
|
1651
|
+
const { max: s } = this.options, n = {
|
|
1558
1652
|
id: m(),
|
|
1559
1653
|
label: (/* @__PURE__ */ new Date()).toLocaleString(),
|
|
1560
1654
|
remark: t,
|
|
1561
|
-
dsl:
|
|
1655
|
+
dsl: A(e)
|
|
1562
1656
|
};
|
|
1563
|
-
this.items.unshift(
|
|
1564
|
-
const
|
|
1565
|
-
if (
|
|
1566
|
-
const
|
|
1567
|
-
this.items = this.items.filter((
|
|
1657
|
+
this.items.unshift(n);
|
|
1658
|
+
const r = this.items.filter((l) => !l.remark);
|
|
1659
|
+
if (r.length > s) {
|
|
1660
|
+
const l = r.splice(s).map((d) => d.id);
|
|
1661
|
+
this.items = this.items.filter((d) => !l.includes(d.id)), i || a.emit(T, {
|
|
1568
1662
|
model: this,
|
|
1569
1663
|
type: "delete",
|
|
1570
|
-
data:
|
|
1664
|
+
data: l
|
|
1571
1665
|
});
|
|
1572
1666
|
}
|
|
1573
|
-
this.index = -1, i ||
|
|
1667
|
+
this.index = -1, i || a.emit(T, {
|
|
1574
1668
|
model: this,
|
|
1575
1669
|
type: "create",
|
|
1576
|
-
data:
|
|
1670
|
+
data: n
|
|
1577
1671
|
});
|
|
1578
1672
|
}
|
|
1579
1673
|
/**
|
|
@@ -1584,7 +1678,7 @@ class se {
|
|
|
1584
1678
|
*/
|
|
1585
1679
|
update(e, t = !1) {
|
|
1586
1680
|
const i = this.items.find((s) => s.id === e.id);
|
|
1587
|
-
i && Object.assign(i, e), t ||
|
|
1681
|
+
i && Object.assign(i, e), t || a.emit(T, {
|
|
1588
1682
|
model: this,
|
|
1589
1683
|
type: "update",
|
|
1590
1684
|
data: i
|
|
@@ -1596,12 +1690,12 @@ class se {
|
|
|
1596
1690
|
* @param silent
|
|
1597
1691
|
*/
|
|
1598
1692
|
remove(e, t = !1) {
|
|
1599
|
-
const i =
|
|
1693
|
+
const i = Q(e);
|
|
1600
1694
|
for (const s of i) {
|
|
1601
|
-
const
|
|
1602
|
-
|
|
1695
|
+
const n = this.items.findIndex((r) => r.id === s);
|
|
1696
|
+
n > -1 ? (this.items.splice(n, 1), n === this.index ? this.index = -1 : this.index >= this.items.length && (this.index = this.items.length - 1)) : console.warn(`not found HistoryItem for id: ${e} `);
|
|
1603
1697
|
}
|
|
1604
|
-
t ||
|
|
1698
|
+
t || a.emit(T, {
|
|
1605
1699
|
model: this,
|
|
1606
1700
|
type: "delete",
|
|
1607
1701
|
data: i
|
|
@@ -1612,7 +1706,7 @@ class se {
|
|
|
1612
1706
|
if (t < 0) return;
|
|
1613
1707
|
--this.index;
|
|
1614
1708
|
const s = i[this.index];
|
|
1615
|
-
s && !e &&
|
|
1709
|
+
s && !e && a.emit(D, {
|
|
1616
1710
|
model: this,
|
|
1617
1711
|
type: "load",
|
|
1618
1712
|
data: s
|
|
@@ -1623,7 +1717,7 @@ class se {
|
|
|
1623
1717
|
if (t >= i.length - 1) return;
|
|
1624
1718
|
t < 0 && (this.index = 0), ++this.index;
|
|
1625
1719
|
const s = i[this.index];
|
|
1626
|
-
s && !e &&
|
|
1720
|
+
s && !e && a.emit(D, {
|
|
1627
1721
|
model: this,
|
|
1628
1722
|
type: "load",
|
|
1629
1723
|
data: s
|
|
@@ -1631,7 +1725,7 @@ class se {
|
|
|
1631
1725
|
}
|
|
1632
1726
|
load(e, t = !1) {
|
|
1633
1727
|
const i = this.items.findIndex((s) => s.id === e);
|
|
1634
|
-
i >= 0 && (this.index = i, t ||
|
|
1728
|
+
i >= 0 && (this.index = i, t || a.emit(D, {
|
|
1635
1729
|
model: this,
|
|
1636
1730
|
type: "load",
|
|
1637
1731
|
data: this.items[i]
|
|
@@ -1640,78 +1734,156 @@ class se {
|
|
|
1640
1734
|
clear(e = !1) {
|
|
1641
1735
|
this.index = -1;
|
|
1642
1736
|
const t = this.items.map((i) => i.id);
|
|
1643
|
-
this.items = [], e ||
|
|
1737
|
+
this.items = [], e || a.emit(T, {
|
|
1644
1738
|
model: this,
|
|
1645
1739
|
type: "clear",
|
|
1646
1740
|
data: t
|
|
1647
1741
|
});
|
|
1648
1742
|
}
|
|
1649
1743
|
}
|
|
1650
|
-
const
|
|
1651
|
-
function
|
|
1652
|
-
return
|
|
1744
|
+
const a = X();
|
|
1745
|
+
function Pe(o) {
|
|
1746
|
+
return o instanceof v;
|
|
1653
1747
|
}
|
|
1654
|
-
function
|
|
1655
|
-
return
|
|
1748
|
+
function _e(o) {
|
|
1749
|
+
return o instanceof _;
|
|
1656
1750
|
}
|
|
1657
|
-
function
|
|
1658
|
-
return !!
|
|
1751
|
+
function Ee(o) {
|
|
1752
|
+
return !!o.__VTJ_BLOCK__;
|
|
1659
1753
|
}
|
|
1660
|
-
function
|
|
1661
|
-
const e =
|
|
1662
|
-
return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) =>
|
|
1754
|
+
function Y(o) {
|
|
1755
|
+
const e = A(o);
|
|
1756
|
+
return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) => Y(t))), e;
|
|
1663
1757
|
}
|
|
1664
|
-
function
|
|
1665
|
-
const e =
|
|
1758
|
+
function ge(o) {
|
|
1759
|
+
const e = o.fromType || "Schema";
|
|
1666
1760
|
return e === "Schema" ? {
|
|
1667
1761
|
type: "Schema",
|
|
1668
|
-
id:
|
|
1762
|
+
id: o.id
|
|
1669
1763
|
} : e === "UrlSchema" ? {
|
|
1670
1764
|
type: "UrlSchema",
|
|
1671
|
-
url: (
|
|
1765
|
+
url: (o.urls || "").split(",")[0] || ""
|
|
1672
1766
|
} : e === "Plugin" ? {
|
|
1673
1767
|
type: "Plugin",
|
|
1674
|
-
urls: (
|
|
1675
|
-
library:
|
|
1768
|
+
urls: (o.urls || "").split(","),
|
|
1769
|
+
library: o.library
|
|
1676
1770
|
} : "";
|
|
1677
1771
|
}
|
|
1772
|
+
function L(o) {
|
|
1773
|
+
return (o || "").trim().replace(/\\/g, "/").replace(/^\/+|\/+$/g, "").replace(/\.vue$/i, "");
|
|
1774
|
+
}
|
|
1775
|
+
function V(o) {
|
|
1776
|
+
const e = (o || "").trim().replace(/\\/g, "/");
|
|
1777
|
+
if (!e) return "";
|
|
1778
|
+
const t = `/${e}`.replace(/\/{2,}/g, "/");
|
|
1779
|
+
return t.length > 1 ? t.replace(/\/$/, "") : t;
|
|
1780
|
+
}
|
|
1781
|
+
function p(o) {
|
|
1782
|
+
return L(o.filePath) || o.id;
|
|
1783
|
+
}
|
|
1784
|
+
function N(o) {
|
|
1785
|
+
return K(o);
|
|
1786
|
+
}
|
|
1787
|
+
function j(o, e = "web") {
|
|
1788
|
+
const t = p(o);
|
|
1789
|
+
return o.type === "block" ? `src/components/${t}.vue` : e === "uniapp" ? `src/pages/${t}.vue` : `src/views/${t}.vue`;
|
|
1790
|
+
}
|
|
1791
|
+
function se(o) {
|
|
1792
|
+
return `@/components/${p(o)}.vue`;
|
|
1793
|
+
}
|
|
1794
|
+
function $(o, e = "", t = "page") {
|
|
1795
|
+
const i = V(o.routePath);
|
|
1796
|
+
if (i) return i;
|
|
1797
|
+
if (o.filePath) {
|
|
1798
|
+
const s = p(o).split("/").map((n) => K(n)).join("/");
|
|
1799
|
+
return V(`${e}${t}/${s}`);
|
|
1800
|
+
}
|
|
1801
|
+
return V(`${e}${t}/${o.id}`);
|
|
1802
|
+
}
|
|
1803
|
+
function ne(o) {
|
|
1804
|
+
return `pages/${p(o)}`;
|
|
1805
|
+
}
|
|
1806
|
+
function q(o = []) {
|
|
1807
|
+
const e = [];
|
|
1808
|
+
for (const t of o)
|
|
1809
|
+
t.dir || e.push(t), t.children?.length && e.push(...q(t.children));
|
|
1810
|
+
return e;
|
|
1811
|
+
}
|
|
1812
|
+
function ye(o) {
|
|
1813
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
1814
|
+
for (const n of o.blocks || []) {
|
|
1815
|
+
const r = j(n, o.platform).toLowerCase();
|
|
1816
|
+
e.set(n.id, n), i.set(r, n.id), t.set(se(n).toLowerCase(), n.id);
|
|
1817
|
+
}
|
|
1818
|
+
for (const n of q(o.pages))
|
|
1819
|
+
e.set(n.id, n), s.set(
|
|
1820
|
+
j(n, o.platform).toLowerCase(),
|
|
1821
|
+
n.id
|
|
1822
|
+
);
|
|
1823
|
+
return {
|
|
1824
|
+
byId: e,
|
|
1825
|
+
blockIdByImportPath: t,
|
|
1826
|
+
blockIdBySourcePath: i,
|
|
1827
|
+
pageIdBySourcePath: s
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
function M(o) {
|
|
1831
|
+
if (!o) return !0;
|
|
1832
|
+
const e = o.trim();
|
|
1833
|
+
return !!e && !e.startsWith("/") && !e.endsWith(".vue") && !/[\\?#]/.test(e) && e.split("/").every((t) => /^(?!\.{1,2}$)[A-Za-z0-9_-]+$/.test(t));
|
|
1834
|
+
}
|
|
1835
|
+
function ae(o) {
|
|
1836
|
+
return o ? o.startsWith("/") && !/[?#]/.test(o) : !0;
|
|
1837
|
+
}
|
|
1678
1838
|
export {
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1839
|
+
ce as BUILT_IN_COMPONENTS,
|
|
1840
|
+
de as BUILT_IN_LIBRARAY_MAP,
|
|
1841
|
+
he as BUILT_IN_MATERIALS,
|
|
1842
|
+
le as BUILT_IN_NAME,
|
|
1843
|
+
fe as BUILT_IN_TAGS,
|
|
1844
|
+
z as BUILT_IN_VUE,
|
|
1845
|
+
W as BUILT_IN_VUE_ROUTER,
|
|
1846
|
+
ue as Base,
|
|
1847
|
+
v as BlockModel,
|
|
1848
|
+
g as DirectiveModel,
|
|
1849
|
+
h as EVENT_BLOCK_CHANGE,
|
|
1850
|
+
T as EVENT_HISTORY_CHANGE,
|
|
1851
|
+
D as EVENT_HISTORY_LOAD,
|
|
1852
|
+
f as EVENT_NODE_CHANGE,
|
|
1853
|
+
F as EVENT_PROJECT_ACTIVED,
|
|
1854
|
+
k as EVENT_PROJECT_APIS_CHANGE,
|
|
1855
|
+
C as EVENT_PROJECT_BLOCKS_CHANGE,
|
|
1856
|
+
c as EVENT_PROJECT_CHANGE,
|
|
1857
|
+
J as EVENT_PROJECT_DEPS_CHANGE,
|
|
1858
|
+
te as EVENT_PROJECT_FILE_PUBLISH,
|
|
1859
|
+
ie as EVENT_PROJECT_GEN_SOURCE,
|
|
1860
|
+
G as EVENT_PROJECT_META_CHANGE,
|
|
1861
|
+
x as EVENT_PROJECT_PAGES_CHANGE,
|
|
1862
|
+
ee as EVENT_PROJECT_PUBLISH,
|
|
1863
|
+
I as EventModel,
|
|
1864
|
+
ve as HistoryModel,
|
|
1865
|
+
me as I18N_LOCALES,
|
|
1706
1866
|
_ as NodeModel,
|
|
1707
1867
|
b as ProjectModel,
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1868
|
+
w as PropModel,
|
|
1869
|
+
pe as Service,
|
|
1870
|
+
oe as VTJ_CORE_VERSION,
|
|
1871
|
+
Y as cloneDsl,
|
|
1872
|
+
ge as createNodeFrom,
|
|
1873
|
+
ye as createProjectFileIndex,
|
|
1874
|
+
a as emitter,
|
|
1875
|
+
q as flattenPages,
|
|
1876
|
+
se as getBlockImportPath,
|
|
1877
|
+
p as getFilePath,
|
|
1878
|
+
N as getPageNamePath,
|
|
1879
|
+
$ as getPageRoutePath,
|
|
1880
|
+
j as getSourceFilePath,
|
|
1881
|
+
ne as getUniPagePath,
|
|
1882
|
+
Pe as isBlock,
|
|
1883
|
+
Ee as isBlockSchema,
|
|
1884
|
+
_e as isNode,
|
|
1885
|
+
M as isValidFilePath,
|
|
1886
|
+
ae as isValidRoutePath,
|
|
1887
|
+
L as normalizeFilePath,
|
|
1888
|
+
V as normalizeRoutePath
|
|
1717
1889
|
};
|