@vtj/core 0.17.8 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { uid as m, timestamp as G, isString as N, uuid as R, cloneDeep as T, upperFirstCamelCase as D, delay as O, merge as I, toArray as j, mitt as F } from "@vtj/base";
1
+ import { uid as m, timestamp as G, isString as N, uuid as R, cloneDeep as T, upperFirstCamelCase as k, delay as O, merge as I, toArray as j, mitt as F } 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.17.8
6
+ * @version 0.18.0
7
7
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
8
8
  */
9
- const z = "0.17.8", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", q = [H, L], Q = {
9
+ const z = "0.18.0", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", q = [H, L], Q = {
10
10
  vue: "Vue",
11
11
  "vue-router": "VueRouter"
12
12
  }, X = {
@@ -95,8 +95,8 @@ class C {
95
95
  }
96
96
  static toDsl(e) {
97
97
  return Object.entries(e).reduce((t, [i, s]) => {
98
- const { handler: a, modifiers: r } = s;
99
- return t[i] = { name: i, handler: a, modifiers: r }, t;
98
+ const { handler: a, modifiers: o } = s;
99
+ return t[i] = { name: i, handler: a, modifiers: o }, t;
100
100
  }, {});
101
101
  }
102
102
  static parse(e = {}) {
@@ -106,7 +106,7 @@ class C {
106
106
  );
107
107
  }
108
108
  }
109
- class v {
109
+ class E {
110
110
  constructor(e) {
111
111
  this.schema = e, this.id = e.id || m(), this.update(e);
112
112
  }
@@ -136,22 +136,22 @@ class v {
136
136
  iterator;
137
137
  update(e) {
138
138
  Object.assign(this.schema, e);
139
- const { name: t, arg: i, modifiers: s, value: a, iterator: r } = this.schema;
140
- this.name = t, this.arg = i, this.modifiers = s, this.value = a, this.iterator = r;
139
+ const { name: t, arg: i, modifiers: s, value: a, iterator: o } = this.schema;
140
+ this.name = t, this.arg = i, this.modifiers = s, this.value = a, this.iterator = o;
141
141
  }
142
142
  static parse(e = []) {
143
- return e.map((t) => new v(t));
143
+ return e.map((t) => new E(t));
144
144
  }
145
145
  static toDsl(e = []) {
146
146
  return e.map((t) => {
147
- const { name: i, arg: s, modifiers: a, value: r, iterator: o, id: h } = t;
147
+ const { name: i, arg: s, modifiers: a, value: o, iterator: r, id: h } = t;
148
148
  return {
149
149
  id: h,
150
150
  name: i,
151
151
  arg: s,
152
152
  modifiers: a,
153
- value: r,
154
- iterator: o
153
+ value: o,
154
+ iterator: r
155
155
  };
156
156
  });
157
157
  }
@@ -225,12 +225,12 @@ class _ {
225
225
  invisible: i = !1,
226
226
  locked: s = !1,
227
227
  children: a = [],
228
- slot: r,
229
- props: o = {},
228
+ slot: o,
229
+ props: r = {},
230
230
  events: h = {},
231
231
  directives: p = []
232
232
  } = e;
233
- this.invisible = i, this.locked = s, this.setChildren(a, !0), this.setSlot(r, !0), this.props = A.parse(o), this.events = C.parse(h), this.directives = v.parse(p), t || n.emit(c, this);
233
+ this.invisible = i, this.locked = s, this.setChildren(a, !0), this.setSlot(o, !0), this.props = A.parse(r), this.events = C.parse(h), this.directives = E.parse(p), t || n.emit(c, this);
234
234
  }
235
235
  /**
236
236
  * 设置子节点
@@ -300,7 +300,7 @@ class _ {
300
300
  * @param silent
301
301
  */
302
302
  setDirective(e, t = !1) {
303
- const i = e instanceof v ? e : new v(e), s = this.directives.findIndex((a) => a.id === e.id);
303
+ const i = e instanceof E ? e : new E(e), s = this.directives.findIndex((a) => a.id === e.id);
304
304
  s >= 0 ? this.directives.splice(s, 1, i) : this.directives.push(i), t || n.emit(c, this);
305
305
  }
306
306
  /**
@@ -323,7 +323,7 @@ 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 a = i.findIndex((r) => r === e);
326
+ const a = i.findIndex((o) => o === e);
327
327
  e.parent = null, i.splice(a, 1), t || n.emit(c, this);
328
328
  }
329
329
  /**
@@ -395,22 +395,22 @@ class _ {
395
395
  from: i,
396
396
  invisible: s,
397
397
  locked: a,
398
- slot: r,
399
- children: o,
398
+ slot: o,
399
+ children: r,
400
400
  props: h,
401
401
  directives: p,
402
402
  events: P
403
- } = this, E = Array.isArray(o) ? o.map((U) => U.toDsl()) : o;
403
+ } = this, v = Array.isArray(r) ? r.map((U) => U.toDsl()) : r;
404
404
  return {
405
405
  id: e,
406
406
  name: t,
407
407
  from: i,
408
408
  invisible: s,
409
409
  locked: a,
410
- slot: r,
411
- children: E,
410
+ slot: o,
411
+ children: v,
412
412
  props: A.toDsl(h),
413
- directives: v.toDsl(p),
413
+ directives: E.toDsl(p),
414
414
  events: C.toDsl(P)
415
415
  };
416
416
  }
@@ -457,17 +457,23 @@ 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 l = "EVENT_BLOCK_CHANGE";
460
+ const d = "EVENT_BLOCK_CHANGE";
461
461
  class u {
462
462
  __VTJ_BLOCK__ = !0;
463
463
  id;
464
464
  name = "";
465
+ apiMode = "options";
465
466
  inject = [];
466
467
  state = {};
468
+ refs = {};
469
+ reactives = {};
467
470
  lifeCycles = {};
468
471
  methods = {};
469
472
  computed = {};
470
473
  watch = [];
474
+ composables = [];
475
+ setup = void 0;
476
+ provide = {};
471
477
  css = "";
472
478
  props = [];
473
479
  emits = [];
@@ -480,12 +486,18 @@ class u {
480
486
  static normalAttrs = [
481
487
  "name",
482
488
  "locked",
489
+ "apiMode",
483
490
  "inject",
484
491
  "state",
492
+ "refs",
493
+ "reactives",
485
494
  "lifeCycles",
486
495
  "methods",
487
496
  "computed",
488
497
  "watch",
498
+ "composables",
499
+ "setup",
500
+ "provide",
489
501
  "css",
490
502
  "props",
491
503
  "emits",
@@ -501,10 +513,10 @@ class u {
501
513
  update(e, t = !1) {
502
514
  for (const s of u.normalAttrs) {
503
515
  const a = e[s];
504
- a !== void 0 && (this[s] = a);
516
+ (a !== void 0 || s === "setup") && (this[s] = a);
505
517
  }
506
518
  const { nodes: i = [] } = e;
507
- i.length ? this.nodes = i.map((s) => new _(s)) : this.nodes = [], t || n.emit(l, this);
519
+ i.length ? this.nodes = i.map((s) => new _(s)) : this.nodes = [], t || n.emit(d, this);
508
520
  }
509
521
  /**
510
522
  * 获取DSL
@@ -514,13 +526,13 @@ class u {
514
526
  const { __VTJ_BLOCK__: t, id: i, nodes: s } = this;
515
527
  return {
516
528
  ...u.normalAttrs.reduce(
517
- (r, o) => (r[o] = this[o], r),
529
+ (o, r) => (o[r] = this[r], o),
518
530
  {}
519
531
  ),
520
532
  __VTJ_BLOCK__: t,
521
533
  __VERSION__: e || G().toString(),
522
534
  id: i,
523
- nodes: s.map((r) => r.toDsl())
535
+ nodes: s.map((o) => o.toDsl())
524
536
  };
525
537
  }
526
538
  /**
@@ -529,6 +541,9 @@ class u {
529
541
  dispose() {
530
542
  this.nodes.map((e) => e.dispose(!0)), this.nodes = [], this.disposed = !0;
531
543
  }
544
+ isExistName(e) {
545
+ return e in this.refs || e in this.reactives || e in this.computed || e in this.methods;
546
+ }
532
547
  /**
533
548
  * 设置通用函数属性
534
549
  * @param type
@@ -537,7 +552,7 @@ class u {
537
552
  * @param silent
538
553
  */
539
554
  setFunction(e, t, i, s = !1) {
540
- this[e][t] = i, s || n.emit(l, this);
555
+ this[e][t] = i, s || n.emit(d, this);
541
556
  }
542
557
  /**
543
558
  * 删除通用函数属性
@@ -546,7 +561,10 @@ class u {
546
561
  * @param silent
547
562
  */
548
563
  removeFunction(e, t, i = !1) {
549
- delete this[e][t], i || n.emit(l, this);
564
+ delete this[e][t], i || n.emit(d, this);
565
+ }
566
+ setComputed(e, t, i = !1) {
567
+ t ? this.computed[e] = t : delete this.computed[e], i || n.emit(d, this);
550
568
  }
551
569
  /**
552
570
  * 设置状态
@@ -555,7 +573,7 @@ class u {
555
573
  * @param silent
556
574
  */
557
575
  setState(e, t, i = !1) {
558
- this.state[e] = t, i || n.emit(l, this);
576
+ this.state[e] = t, i || n.emit(d, this);
559
577
  }
560
578
  /**
561
579
  * 删除状态
@@ -563,7 +581,7 @@ class u {
563
581
  * @param silent
564
582
  */
565
583
  removeState(e, t = !1) {
566
- delete this.state[e], t || n.emit(l, this);
584
+ delete this.state[e], t || n.emit(d, this);
567
585
  }
568
586
  /**
569
587
  * 更新CSS
@@ -571,7 +589,7 @@ class u {
571
589
  * @param silent
572
590
  */
573
591
  setCss(e, t = !1) {
574
- this.css = e, t || n.emit(l, this);
592
+ this.css = e, t || n.emit(d, this);
575
593
  }
576
594
  /**
577
595
  * 新增或更新 watch
@@ -583,7 +601,7 @@ class u {
583
601
  const i = this.watch.findIndex(
584
602
  (s) => s.id && s.id === e.id || s === e
585
603
  );
586
- i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || n.emit(l, this);
604
+ i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || n.emit(d, this);
587
605
  }
588
606
  /**
589
607
  * 删除 watch
@@ -594,7 +612,7 @@ class u {
594
612
  const i = this.watch.findIndex(
595
613
  (s) => s.id && s.id === e.id || s === e
596
614
  );
597
- i > -1 && (this.watch.splice(i, 1), t || n.emit(l, this));
615
+ i > -1 && (this.watch.splice(i, 1), t || n.emit(d, this));
598
616
  }
599
617
  /**
600
618
  * 定义属性参数
@@ -605,7 +623,7 @@ class u {
605
623
  const i = this.props.findIndex(
606
624
  (s) => typeof s == "string" ? s === e.name : s.name === e.name
607
625
  );
608
- i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || n.emit(l, this);
626
+ i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || n.emit(d, this);
609
627
  }
610
628
  /**
611
629
  * 删除属性
@@ -616,7 +634,7 @@ class u {
616
634
  const i = this.props.findIndex(
617
635
  (s) => typeof s == "string" ? s === e.name : s.name === e.name
618
636
  );
619
- i > -1 && (this.props.splice(i, 1), t || n.emit(l, this));
637
+ i > -1 && (this.props.splice(i, 1), t || n.emit(d, this));
620
638
  }
621
639
  /**
622
640
  * 设置事件
@@ -627,7 +645,7 @@ class u {
627
645
  const i = N(e) ? { name: e, params: [] } : e, s = this.emits.findIndex(
628
646
  (a) => a === i.name || a.name === i.name
629
647
  );
630
- s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(l, this);
648
+ s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(d, this);
631
649
  }
632
650
  /**
633
651
  * 删除事件
@@ -638,10 +656,10 @@ class u {
638
656
  const i = this.emits.findIndex(
639
657
  (s) => N(s) ? s === e : s.name === e
640
658
  );
641
- i > -1 && (this.emits.splice(i, 1), t || n.emit(l, this));
659
+ i > -1 && (this.emits.splice(i, 1), t || n.emit(d, this));
642
660
  }
643
661
  setExpose(e, t = !1) {
644
- this.expose = e, t || n.emit(l, this);
662
+ this.expose = e, t || n.emit(d, this);
645
663
  }
646
664
  /**
647
665
  * 设置插槽
@@ -652,7 +670,7 @@ class u {
652
670
  const i = N(e) ? { name: e, params: [] } : e, s = this.slots.findIndex(
653
671
  (a) => a === i.name || a.name === i.name
654
672
  );
655
- s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(l, this);
673
+ s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(d, this);
656
674
  }
657
675
  /**
658
676
  * 删除插槽
@@ -663,7 +681,7 @@ class u {
663
681
  const i = this.slots.findIndex(
664
682
  (s) => N(s) ? s === e : s.name === e
665
683
  );
666
- i > -1 && (this.slots.splice(i, 1), t || n.emit(l, this));
684
+ i > -1 && (this.slots.splice(i, 1), t || n.emit(d, this));
667
685
  }
668
686
  /**
669
687
  * 设置注入
@@ -672,7 +690,7 @@ class u {
672
690
  */
673
691
  setInject(e, t = !1) {
674
692
  const i = this.inject.findIndex((s) => s.name === e.name);
675
- i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || n.emit(l, this);
693
+ i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || n.emit(d, this);
676
694
  }
677
695
  /**
678
696
  * 删除注入
@@ -681,7 +699,7 @@ class u {
681
699
  */
682
700
  removeInject(e, t = !1) {
683
701
  const i = this.inject.findIndex((s) => s.name === e.name);
684
- i > -1 && (this.inject.splice(i, 1), t || n.emit(l, this));
702
+ i > -1 && (this.inject.splice(i, 1), t || n.emit(d, this));
685
703
  }
686
704
  /**
687
705
  * 设置数据源
@@ -689,7 +707,7 @@ class u {
689
707
  * @param silent
690
708
  */
691
709
  setDataSource(e, t = !1) {
692
- this.dataSources[e.name] = e, t || n.emit(l, this);
710
+ this.dataSources[e.name] = e, t || n.emit(d, this);
693
711
  }
694
712
  /**
695
713
  * 删除数据源
@@ -697,20 +715,105 @@ class u {
697
715
  * @param silent
698
716
  */
699
717
  removeDataSource(e, t = !1) {
700
- delete this.dataSources[e], t || n.emit(l, this);
718
+ delete this.dataSources[e], t || n.emit(d, this);
719
+ }
720
+ /**
721
+ * 设置 API 风格
722
+ * @param mode
723
+ * @param silent
724
+ */
725
+ setApiMode(e, t = !1) {
726
+ this.apiMode = e, t || n.emit(d, this);
727
+ }
728
+ /**
729
+ * 设置 ref 声明
730
+ * @param name
731
+ * @param value
732
+ * @param silent
733
+ */
734
+ setRef(e, t, i = !1) {
735
+ this.refs[e] = t, i || n.emit(d, this);
736
+ }
737
+ /**
738
+ * 删除 ref 声明
739
+ * @param name
740
+ * @param silent
741
+ */
742
+ removeRef(e, t = !1) {
743
+ delete this.refs[e], t || n.emit(d, this);
744
+ }
745
+ /**
746
+ * 设置 reactive 声明
747
+ * @param name
748
+ * @param value
749
+ * @param silent
750
+ */
751
+ setReactive(e, t, i = !1) {
752
+ this.reactives[e] = t, i || n.emit(d, this);
753
+ }
754
+ /**
755
+ * 删除 reactive 声明
756
+ * @param name
757
+ * @param silent
758
+ */
759
+ removeReactive(e, t = !1) {
760
+ delete this.reactives[e], t || n.emit(d, this);
761
+ }
762
+ /**
763
+ * 设置组合函数调用
764
+ * @param composable
765
+ * @param silent
766
+ */
767
+ setComposable(e, t = !1) {
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 || n.emit(d, this);
770
+ }
771
+ /**
772
+ * 删除组合函数调用
773
+ * @param name
774
+ * @param silent
775
+ */
776
+ removeComposable(e, t = !1) {
777
+ const i = this.composables.findIndex((s) => s.name === e);
778
+ i > -1 && (this.composables.splice(i, 1), t || n.emit(d, this));
779
+ }
780
+ /**
781
+ * 设置 provide
782
+ * @param key
783
+ * @param value
784
+ * @param silent
785
+ */
786
+ setProvide(e, t, i = !1) {
787
+ this.provide[e] = t, i || n.emit(d, this);
788
+ }
789
+ /**
790
+ * 删除 provide
791
+ * @param key
792
+ * @param silent
793
+ */
794
+ removeProvide(e, t = !1) {
795
+ delete this.provide[e], t || n.emit(d, this);
796
+ }
797
+ /**
798
+ * 设置 setup 初始化代码
799
+ * @param code
800
+ * @param silent
801
+ */
802
+ setSetup(e, t = !1) {
803
+ this.setup = e, t || n.emit(d, this);
701
804
  }
702
805
  insertAfter(e, t, i = !1) {
703
806
  e.parent = null;
704
807
  const s = this.nodes.indexOf(t);
705
- this.nodes.splice(s + 1, 0, e), i || n.emit(l, this);
808
+ this.nodes.splice(s + 1, 0, e), i || n.emit(d, this);
706
809
  }
707
810
  insertBefore(e, t, i = !1) {
708
811
  e.parent = null;
709
812
  const s = this.nodes.indexOf(t);
710
- this.nodes.splice(s, 0, e), i || n.emit(l, this);
813
+ this.nodes.splice(s, 0, e), i || n.emit(d, this);
711
814
  }
712
815
  appendNode(e, t = !1) {
713
- e.parent = null, this.nodes.push(e), t || n.emit(l, this);
816
+ e.parent = null, this.nodes.push(e), t || n.emit(d, this);
714
817
  }
715
818
  /**
716
819
  * 添加节点
@@ -724,7 +827,7 @@ class u {
724
827
  }
725
828
  __removeNode(e, t = !1) {
726
829
  const i = this.nodes.findIndex((s) => s.id === e.id);
727
- i > -1 && (this.nodes.splice(i, 1), t || n.emit(l, this));
830
+ i > -1 && (this.nodes.splice(i, 1), t || n.emit(d, this));
728
831
  }
729
832
  /**
730
833
  * 删除节点
@@ -754,7 +857,7 @@ class u {
754
857
  e.movePrev(t);
755
858
  else {
756
859
  const i = this.nodes, s = i.indexOf(e);
757
- s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || n.emit(l, this));
860
+ s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || n.emit(d, this));
758
861
  }
759
862
  }
760
863
  /**
@@ -767,7 +870,7 @@ class u {
767
870
  e.moveNext(t);
768
871
  else {
769
872
  const i = this.nodes, s = i.indexOf(e);
770
- s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || n.emit(l, this));
873
+ s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || n.emit(d, this));
771
874
  }
772
875
  }
773
876
  /**
@@ -784,13 +887,13 @@ class u {
784
887
  this.locked = !0;
785
888
  for (const t of this.nodes)
786
889
  t.lock(!0);
787
- e || n.emit(l, this);
890
+ e || n.emit(d, this);
788
891
  }
789
892
  unlock(e = !1) {
790
893
  this.locked = !1;
791
894
  for (const t of this.nodes)
792
895
  t.unlock(!0);
793
- e || n.emit(l, this);
896
+ e || n.emit(d, this);
794
897
  }
795
898
  isChild(e) {
796
899
  let t = !1;
@@ -803,8 +906,8 @@ class u {
803
906
  return t;
804
907
  }
805
908
  }
806
- const d = "EVENT_PROJECT_CHANGE", b = "EVENT_PROJECT_ACTIVED", B = "EVENT_PROJECT_DEPS_CHANGE", g = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", V = "EVENT_PROJECT_APIS_CHANGE", w = "EVENT_PROJECT_META_CHANGE", $ = "EVENT_PROJECT_PUBLISH", M = "EVENT_PROJECT_FILE_PUBLISH", K = "EVENT_PROJECT_GEN_SOURCE";
807
- class k {
909
+ const l = "EVENT_PROJECT_CHANGE", D = "EVENT_PROJECT_ACTIVED", B = "EVENT_PROJECT_DEPS_CHANGE", g = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", V = "EVENT_PROJECT_APIS_CHANGE", w = "EVENT_PROJECT_META_CHANGE", M = "EVENT_PROJECT_PUBLISH", $ = "EVENT_PROJECT_FILE_PUBLISH", K = "EVENT_PROJECT_GEN_SOURCE";
910
+ class b {
808
911
  id = "";
809
912
  locked = "";
810
913
  platform = "web";
@@ -852,11 +955,11 @@ class k {
852
955
  this.id = t || m(), this.__UID__ = i || R(!0), this.update(e, !0);
853
956
  }
854
957
  update(e, t = !1) {
855
- for (const i of k.attrs) {
958
+ for (const i of b.attrs) {
856
959
  const s = e[i];
857
960
  s && (this[i] = s);
858
961
  }
859
- t || n.emit(d, {
962
+ t || n.emit(l, {
860
963
  model: this,
861
964
  type: "update",
862
965
  data: e
@@ -870,7 +973,7 @@ class k {
870
973
  delete t.dsl, t.children && t.children.length && this.cleanPagesDsl(t.children);
871
974
  }
872
975
  toDsl(e) {
873
- const { id: t } = this, i = k.attrs.reduce(
976
+ const { id: t } = this, i = b.attrs.reduce(
874
977
  (s, a) => (s[a] = this[a], s),
875
978
  {}
876
979
  );
@@ -892,7 +995,7 @@ class k {
892
995
  * @param silent
893
996
  */
894
997
  active(e, t = !1) {
895
- this.currentFile = e, t || n.emit(b, {
998
+ this.currentFile = e, t || n.emit(D, {
896
999
  model: this,
897
1000
  type: "update",
898
1001
  data: e
@@ -903,7 +1006,7 @@ class k {
903
1006
  * @param silent
904
1007
  */
905
1008
  deactivate(e = !1) {
906
- this.currentFile = null, e || n.emit(b, {
1009
+ this.currentFile = null, e || n.emit(D, {
907
1010
  model: this,
908
1011
  type: "update",
909
1012
  data: null
@@ -915,18 +1018,18 @@ class k {
915
1018
  * @param silent
916
1019
  */
917
1020
  setDeps(e, t = !1) {
918
- const i = this.dependencies, s = i.findIndex((r) => r.package === e.package);
1021
+ const i = this.dependencies, s = i.findIndex((o) => o.package === e.package);
919
1022
  let a;
920
1023
  if (s > -1 ? (a = "update", i.splice(s, 1, {
921
1024
  ...i[s],
922
1025
  ...e
923
1026
  })) : (a = "create", i.push(e)), !t) {
924
- const r = {
1027
+ const o = {
925
1028
  model: this,
926
1029
  type: a,
927
1030
  data: e
928
1031
  };
929
- n.emit(B, r), n.emit(d, r);
1032
+ n.emit(B, o), n.emit(l, o);
930
1033
  }
931
1034
  }
932
1035
  /**
@@ -942,7 +1045,7 @@ class k {
942
1045
  type: "delete",
943
1046
  data: e
944
1047
  };
945
- n.emit(B, a), n.emit(d, a);
1048
+ n.emit(B, a), n.emit(l, a);
946
1049
  }
947
1050
  }
948
1051
  /**
@@ -956,9 +1059,9 @@ class k {
956
1059
  if (a.id === i)
957
1060
  return a;
958
1061
  if (a.children && a.children.length) {
959
- const r = t(i, a.children);
960
- if (r)
961
- return r;
1062
+ const o = t(i, a.children);
1063
+ if (o)
1064
+ return o;
962
1065
  }
963
1066
  }
964
1067
  };
@@ -989,7 +1092,8 @@ class k {
989
1092
  async createPage(e, t, i = !1) {
990
1093
  if (e.id = e.raw ? e.name : e.id || m(), e.type = "page", e.dir ? e.children = [] : e.dsl = e.dsl || new u({
991
1094
  id: e.id,
992
- name: D(e.name)
1095
+ name: k(e.name),
1096
+ apiMode: "composition"
993
1097
  }).toDsl(), t) {
994
1098
  const s = this.getPage(t);
995
1099
  s ? s.children ? s.children.push(e) : s.children = [e] : console.warn(`not found PageFile for id: ${t} `);
@@ -1001,7 +1105,7 @@ class k {
1001
1105
  type: "create",
1002
1106
  data: e
1003
1107
  };
1004
- n.emit(g, s), n.emit(d, s);
1108
+ n.emit(g, s), n.emit(l, s);
1005
1109
  }
1006
1110
  return !this.currentFile && !e.dir && (this.active(e, !0), await O(1e3), this.active(e, i)), e;
1007
1111
  }
@@ -1018,19 +1122,19 @@ class k {
1018
1122
  type: "update",
1019
1123
  data: e
1020
1124
  };
1021
- n.emit(g, s), n.emit(d, s);
1125
+ n.emit(g, s), n.emit(l, s);
1022
1126
  }
1023
1127
  return i;
1024
1128
  }
1025
1129
  findParent(e) {
1026
1130
  const t = (i, s = [], a) => {
1027
- for (const r of s) {
1028
- if (r.id === i)
1131
+ for (const o of s) {
1132
+ if (o.id === i)
1029
1133
  return a;
1030
- if (r.children && r.children.length) {
1031
- const o = t(i, r.children, r);
1032
- if (o)
1033
- return o;
1134
+ if (o.children && o.children.length) {
1135
+ const r = t(i, o.children, o);
1136
+ if (r)
1137
+ return r;
1034
1138
  }
1035
1139
  }
1036
1140
  };
@@ -1039,16 +1143,16 @@ class k {
1039
1143
  movePageTo(e, t, i = !1) {
1040
1144
  const s = t ? this.getPage(t) : null, a = this.getPage(e);
1041
1145
  if (!a) return !1;
1042
- const r = this.findParent(e);
1043
- if (r ? r.children = r.children?.filter(
1044
- (o) => o.id !== e
1045
- ) : this.pages = this.pages.filter((o) => o.id !== e), s ? (s.dir || s.layout) && (s.children ? s.children.push(a) : s.children = [a]) : this.pages.push(a), !i) {
1046
- const o = {
1146
+ const o = this.findParent(e);
1147
+ if (o ? o.children = o.children?.filter(
1148
+ (r) => r.id !== e
1149
+ ) : this.pages = this.pages.filter((r) => r.id !== e), s ? (s.dir || s.layout) && (s.children ? s.children.push(a) : s.children = [a]) : this.pages.push(a), !i) {
1150
+ const r = {
1047
1151
  model: this,
1048
1152
  type: "update",
1049
1153
  data: a
1050
1154
  };
1051
- n.emit(g, o), n.emit(d, o);
1155
+ n.emit(g, r), n.emit(l, r);
1052
1156
  }
1053
1157
  return !0;
1054
1158
  }
@@ -1063,12 +1167,13 @@ class k {
1063
1167
  * @param silent
1064
1168
  */
1065
1169
  clonePage(e, t, i = !1) {
1066
- const s = m(), a = `${e.name}Copy`, r = `${e.title}_副本`, o = new u({
1170
+ const s = m(), a = `${e.name}Copy`, o = `${e.title}_副本`, r = new u({
1067
1171
  id: s,
1068
- name: a
1069
- }).toDsl(), h = I({}, e, { id: s, name: a, title: r, dsl: o }), p = t ? this.getPage(t)?.children || [] : this.pages, P = p.findIndex((E) => E.id === e.id);
1172
+ name: a,
1173
+ apiMode: "composition"
1174
+ }).toDsl(), h = I({}, e, { id: s, name: a, title: o, dsl: r }), p = t ? this.getPage(t)?.children || [] : this.pages, P = p.findIndex((v) => v.id === e.id);
1070
1175
  if (p.splice(P + 1, 0, h), !i) {
1071
- const E = {
1176
+ const v = {
1072
1177
  model: this,
1073
1178
  type: "clone",
1074
1179
  data: {
@@ -1076,30 +1181,30 @@ class k {
1076
1181
  target: h
1077
1182
  }
1078
1183
  };
1079
- n.emit(g, E), n.emit(d, E);
1184
+ n.emit(g, v), n.emit(l, v);
1080
1185
  }
1081
1186
  }
1082
1187
  async saveToBlock(e, t = !1) {
1083
1188
  this.active(e, t), await O(1e3);
1084
- const i = m(), s = e.name, a = e.title, r = new u({
1189
+ const i = m(), s = e.name, a = e.title, o = new u({
1085
1190
  ...e.dsl,
1086
1191
  id: i,
1087
1192
  name: s
1088
- }).toDsl(), o = I({}, e, {
1193
+ }).toDsl(), r = I({}, e, {
1089
1194
  id: i,
1090
1195
  name: s,
1091
1196
  title: a,
1092
- dsl: r,
1197
+ dsl: o,
1093
1198
  type: "block",
1094
1199
  fromType: "Schema"
1095
1200
  });
1096
- if (this.blocks.push(o), !t) {
1201
+ if (this.blocks.push(r), !t) {
1097
1202
  const h = {
1098
1203
  model: this,
1099
1204
  type: "create",
1100
- data: o
1205
+ data: r
1101
1206
  };
1102
- n.emit(y, h), n.emit(d, h);
1207
+ n.emit(y, h), n.emit(l, h);
1103
1208
  }
1104
1209
  }
1105
1210
  /**
@@ -1108,13 +1213,13 @@ class k {
1108
1213
  * @param silent
1109
1214
  */
1110
1215
  removePage(e, t = !1) {
1111
- const i = this.getPage(e), s = (a, r) => {
1112
- const o = r.findIndex((h) => h.id === a);
1113
- if (o >= 0) {
1114
- r.splice(o, 1);
1216
+ const i = this.getPage(e), s = (a, o) => {
1217
+ const r = o.findIndex((h) => h.id === a);
1218
+ if (r >= 0) {
1219
+ o.splice(r, 1);
1115
1220
  return;
1116
1221
  }
1117
- for (const h of r)
1222
+ for (const h of o)
1118
1223
  h.children && h.children.length && s(a, h.children);
1119
1224
  };
1120
1225
  if (s(e, this.pages), e === this.homepage && (this.homepage = ""), this.currentFile?.id === e && this.deactivate(t), !t) {
@@ -1123,7 +1228,7 @@ class k {
1123
1228
  type: "delete",
1124
1229
  data: i
1125
1230
  };
1126
- n.emit(g, a), n.emit(d, a);
1231
+ n.emit(g, a), n.emit(l, a);
1127
1232
  }
1128
1233
  }
1129
1234
  /**
@@ -1143,16 +1248,16 @@ class k {
1143
1248
  * @param silent
1144
1249
  */
1145
1250
  async createBlock(e, t = !1) {
1146
- const i = e.id || m(), s = D(e.name);
1147
- e.id = i, e.type = "block", e.fromType = e.fromType || "Schema", e.dsl = new u({ id: i, name: s }).toDsl(), this.blocks.push(e);
1251
+ const i = e.id || m(), s = k(e.name);
1252
+ e.id = i, e.type = "block", e.fromType = e.fromType || "Schema", e.dsl = new u({ id: i, name: s, apiMode: "composition" }).toDsl(), this.blocks.push(e);
1148
1253
  const a = e.fromType || "Schema";
1149
1254
  if (!t) {
1150
- const r = {
1255
+ const o = {
1151
1256
  model: this,
1152
1257
  type: "create",
1153
1258
  data: e
1154
1259
  };
1155
- n.emit(y, r), n.emit(d, r);
1260
+ n.emit(y, o), n.emit(l, o);
1156
1261
  }
1157
1262
  return !this.currentFile && a === "Schema" && (this.active(e, !0), await O(1e3), this.active(e, t)), e;
1158
1263
  }
@@ -1169,25 +1274,26 @@ class k {
1169
1274
  type: "update",
1170
1275
  data: e
1171
1276
  };
1172
- n.emit(y, s), n.emit(d, s);
1277
+ n.emit(y, s), n.emit(l, s);
1173
1278
  }
1174
1279
  return i;
1175
1280
  }
1176
1281
  cloneBlock(e, t = !1) {
1177
- const i = m(), s = `${e.name}Copy`, a = `${e.title}_副本`, r = new u({
1282
+ const i = m(), s = `${e.name}Copy`, a = `${e.title}_副本`, o = new u({
1178
1283
  id: i,
1179
- name: s
1180
- }).toDsl(), o = I({}, e, { id: i, name: s, title: a, dsl: r }), h = this.blocks.findIndex((p) => p.id === e.id);
1181
- if (this.blocks.splice(h + 1, 0, o), !t) {
1284
+ name: s,
1285
+ apiMode: "composition"
1286
+ }).toDsl(), r = I({}, e, { id: i, name: s, title: a, dsl: o }), h = this.blocks.findIndex((p) => p.id === e.id);
1287
+ if (this.blocks.splice(h + 1, 0, r), !t) {
1182
1288
  const p = {
1183
1289
  model: this,
1184
1290
  type: "clone",
1185
1291
  data: {
1186
1292
  source: e,
1187
- target: o
1293
+ target: r
1188
1294
  }
1189
1295
  };
1190
- n.emit(y, p), n.emit(d, p);
1296
+ n.emit(y, p), n.emit(l, p);
1191
1297
  }
1192
1298
  }
1193
1299
  /**
@@ -1196,14 +1302,14 @@ class k {
1196
1302
  * @param silent
1197
1303
  */
1198
1304
  removeBlock(e, t = !1) {
1199
- const i = this.getBlock(e), s = this.blocks, a = s.findIndex((r) => r.id === e);
1305
+ const i = this.getBlock(e), s = this.blocks, a = s.findIndex((o) => o.id === e);
1200
1306
  if (a > -1 ? (s.splice(a, 1), this.currentFile?.id === e && this.deactivate(t)) : console.warn(`not found PageFile for id: ${e} `), !t) {
1201
- const r = {
1307
+ const o = {
1202
1308
  model: this,
1203
1309
  type: "delete",
1204
1310
  data: i
1205
1311
  };
1206
- n.emit(y, r), n.emit(d, r);
1312
+ n.emit(y, o), n.emit(l, o);
1207
1313
  }
1208
1314
  }
1209
1315
  /**
@@ -1240,7 +1346,7 @@ class k {
1240
1346
  type: s,
1241
1347
  data: e
1242
1348
  };
1243
- n.emit(V, a), n.emit(d, a);
1349
+ n.emit(V, a), n.emit(l, a);
1244
1350
  }
1245
1351
  return i || e;
1246
1352
  }
@@ -1253,7 +1359,7 @@ class k {
1253
1359
  type: "create",
1254
1360
  data: e
1255
1361
  };
1256
- n.emit(V, i), n.emit(d, i);
1362
+ n.emit(V, i), n.emit(l, i);
1257
1363
  }
1258
1364
  }
1259
1365
  /**
@@ -1269,7 +1375,7 @@ class k {
1269
1375
  type: "delete",
1270
1376
  data: e
1271
1377
  };
1272
- n.emit(V, s), n.emit(d, s);
1378
+ n.emit(V, s), n.emit(l, s);
1273
1379
  }
1274
1380
  }
1275
1381
  existApiName(e, t = []) {
@@ -1286,7 +1392,7 @@ class k {
1286
1392
  type: s,
1287
1393
  data: e
1288
1394
  };
1289
- n.emit(w, a), n.emit(d, a);
1395
+ n.emit(w, a), n.emit(l, a);
1290
1396
  }
1291
1397
  }
1292
1398
  removeMeta(e, t = !1) {
@@ -1297,7 +1403,7 @@ class k {
1297
1403
  type: "delete",
1298
1404
  data: e
1299
1405
  };
1300
- n.emit(w, s), n.emit(d, s);
1406
+ n.emit(w, s), n.emit(l, s);
1301
1407
  }
1302
1408
  }
1303
1409
  existMetaCode(e, t = []) {
@@ -1310,7 +1416,7 @@ class k {
1310
1416
  type: "update",
1311
1417
  data: e
1312
1418
  };
1313
- n.emit(d, i);
1419
+ n.emit(l, i);
1314
1420
  }
1315
1421
  }
1316
1422
  setConfig(e, t = !1) {
@@ -1320,7 +1426,7 @@ class k {
1320
1426
  type: "update",
1321
1427
  data: e
1322
1428
  };
1323
- n.emit(d, i);
1429
+ n.emit(l, i);
1324
1430
  }
1325
1431
  }
1326
1432
  setUniConfig(e, t, i = !1) {
@@ -1330,7 +1436,7 @@ class k {
1330
1436
  type: "update",
1331
1437
  data: this.uniConfig
1332
1438
  };
1333
- n.emit(d, s);
1439
+ n.emit(l, s);
1334
1440
  }
1335
1441
  }
1336
1442
  setGloblas(e, t, i = !1) {
@@ -1340,7 +1446,7 @@ class k {
1340
1446
  type: "update",
1341
1447
  data: this.globals
1342
1448
  };
1343
- n.emit(d, s);
1449
+ n.emit(l, s);
1344
1450
  }
1345
1451
  }
1346
1452
  setI18n(e, t = !1) {
@@ -1350,7 +1456,7 @@ class k {
1350
1456
  type: "update",
1351
1457
  data: this.i18n
1352
1458
  };
1353
- n.emit(d, i);
1459
+ n.emit(l, i);
1354
1460
  }
1355
1461
  }
1356
1462
  setEnv(e, t = !1) {
@@ -1360,7 +1466,7 @@ class k {
1360
1466
  type: "update",
1361
1467
  data: this.env
1362
1468
  };
1363
- n.emit(d, i);
1469
+ n.emit(l, i);
1364
1470
  }
1365
1471
  }
1366
1472
  publish(e) {
@@ -1369,7 +1475,7 @@ class k {
1369
1475
  type: "publish",
1370
1476
  data: e || this
1371
1477
  };
1372
- e ? n.emit(M, t) : n.emit($, t);
1478
+ e ? n.emit($, t) : n.emit(M, t);
1373
1479
  }
1374
1480
  genSource() {
1375
1481
  const e = {
@@ -1386,7 +1492,7 @@ class k {
1386
1492
  type: "update",
1387
1493
  data: e
1388
1494
  };
1389
- n.emit(d, t);
1495
+ n.emit(l, t);
1390
1496
  }
1391
1497
  unlock(e) {
1392
1498
  if (e !== this.locked)
@@ -1397,16 +1503,16 @@ class k {
1397
1503
  type: "update",
1398
1504
  data: null
1399
1505
  };
1400
- n.emit(d, t);
1506
+ n.emit(l, t);
1401
1507
  }
1402
1508
  getPageRoutes(e, t) {
1403
- const i = this.platform === "uniapp", s = e || (i ? "pages" : "page"), a = this.getPages(), r = t || "";
1404
- return a.map((o) => ({
1405
- id: o.id,
1406
- path: `${r}/${s}/${o.id}`,
1407
- name: o.name,
1408
- title: o.title,
1409
- meta: o.meta
1509
+ const i = this.platform === "uniapp", s = e || (i ? "pages" : "page"), a = this.getPages(), o = t || "";
1510
+ return a.map((r) => ({
1511
+ id: r.id,
1512
+ path: `${o}/${s}/${r.id}`,
1513
+ name: r.name,
1514
+ title: r.title,
1515
+ meta: r.meta
1410
1516
  }));
1411
1517
  }
1412
1518
  }
@@ -1453,13 +1559,13 @@ class se {
1453
1559
  dsl: T(e)
1454
1560
  };
1455
1561
  this.items.unshift(a);
1456
- const r = this.items.filter((o) => !o.remark);
1457
- if (r.length > s) {
1458
- const o = r.splice(s).map((h) => h.id);
1459
- this.items = this.items.filter((h) => !o.includes(h.id)), i || n.emit(x, {
1562
+ const o = this.items.filter((r) => !r.remark);
1563
+ if (o.length > s) {
1564
+ const r = o.splice(s).map((h) => h.id);
1565
+ this.items = this.items.filter((h) => !r.includes(h.id)), i || n.emit(x, {
1460
1566
  model: this,
1461
1567
  type: "delete",
1462
- data: o
1568
+ data: r
1463
1569
  });
1464
1570
  }
1465
1571
  this.index = -1, i || n.emit(x, {
@@ -1490,7 +1596,7 @@ class se {
1490
1596
  remove(e, t = !1) {
1491
1597
  const i = j(e);
1492
1598
  for (const s of i) {
1493
- const a = this.items.findIndex((r) => r.id === s);
1599
+ const a = this.items.findIndex((o) => o.id === s);
1494
1600
  a > -1 ? (this.items.splice(a, 1), a === this.index ? this.index = -1 : this.index >= this.items.length && (this.index = this.items.length - 1)) : console.warn(`not found HistoryItem for id: ${e} `);
1495
1601
  }
1496
1602
  t || n.emit(x, {
@@ -1546,14 +1652,14 @@ function ne(f) {
1546
1652
  function ae(f) {
1547
1653
  return f instanceof _;
1548
1654
  }
1549
- function re(f) {
1655
+ function oe(f) {
1550
1656
  return !!f.__VTJ_BLOCK__;
1551
1657
  }
1552
1658
  function J(f) {
1553
1659
  const e = T(f);
1554
1660
  return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) => J(t))), e;
1555
1661
  }
1556
- function oe(f) {
1662
+ function re(f) {
1557
1663
  const e = f.fromType || "Schema";
1558
1664
  return e === "Schema" ? {
1559
1665
  type: "Schema",
@@ -1577,33 +1683,33 @@ export {
1577
1683
  L as BUILT_IN_VUE_ROUTER,
1578
1684
  ie as Base,
1579
1685
  u as BlockModel,
1580
- v as DirectiveModel,
1581
- l as EVENT_BLOCK_CHANGE,
1686
+ E as DirectiveModel,
1687
+ d as EVENT_BLOCK_CHANGE,
1582
1688
  x as EVENT_HISTORY_CHANGE,
1583
1689
  S as EVENT_HISTORY_LOAD,
1584
1690
  c as EVENT_NODE_CHANGE,
1585
- b as EVENT_PROJECT_ACTIVED,
1691
+ D as EVENT_PROJECT_ACTIVED,
1586
1692
  V as EVENT_PROJECT_APIS_CHANGE,
1587
1693
  y as EVENT_PROJECT_BLOCKS_CHANGE,
1588
- d as EVENT_PROJECT_CHANGE,
1694
+ l as EVENT_PROJECT_CHANGE,
1589
1695
  B as EVENT_PROJECT_DEPS_CHANGE,
1590
- M as EVENT_PROJECT_FILE_PUBLISH,
1696
+ $ as EVENT_PROJECT_FILE_PUBLISH,
1591
1697
  K as EVENT_PROJECT_GEN_SOURCE,
1592
1698
  w as EVENT_PROJECT_META_CHANGE,
1593
1699
  g as EVENT_PROJECT_PAGES_CHANGE,
1594
- $ as EVENT_PROJECT_PUBLISH,
1700
+ M as EVENT_PROJECT_PUBLISH,
1595
1701
  C as EventModel,
1596
1702
  se as HistoryModel,
1597
1703
  ee as I18N_LOCALES,
1598
1704
  _ as NodeModel,
1599
- k as ProjectModel,
1705
+ b as ProjectModel,
1600
1706
  A as PropModel,
1601
1707
  te as Service,
1602
1708
  z as VTJ_CORE_VERSION,
1603
1709
  J as cloneDsl,
1604
- oe as createNodeFrom,
1710
+ re as createNodeFrom,
1605
1711
  n as emitter,
1606
1712
  ne as isBlock,
1607
- re as isBlockSchema,
1713
+ oe as isBlockSchema,
1608
1714
  ae as isNode
1609
1715
  };