@vtj/designer 0.8.60 → 0.8.62

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.
@@ -19,7 +19,7 @@ const T = /* @__PURE__ */ p({
19
19
  createTrustedTypesPolicy: void 0,
20
20
  async getWorker(o, a) {
21
21
  let n;
22
- return a === "json" && (n = await import("./json.worker-BhNp9C2F.js")), ["css", "scss", "less"].includes(a) && (n = await import("./css.worker-BG3X4ypZ.js")), ["html", "handlebars", "razor", "vue"].includes(a) && (n = await import("./html.worker-BCBdCLMV.js")), ["typescript", "javascript"].includes(a) && (n = await import("./ts.worker-yjAiJiOi.js")), n = n || await import("./editor.worker-CdJourTJ.js"), new n.default();
22
+ return a === "json" && (n = await import("./json.worker-Bm0JMgNu.js")), ["css", "scss", "less"].includes(a) && (n = await import("./css.worker-DsXsg0f9.js")), ["html", "handlebars", "razor", "vue"].includes(a) && (n = await import("./html.worker-DOZaicN7.js")), ["typescript", "javascript"].includes(a) && (n = await import("./ts.worker-CdTDJbmm.js")), n = n || await import("./editor.worker-C6rtsk95.js"), new n.default();
23
23
  }
24
24
  };
25
25
  const r = d, i = f();
@@ -2,8 +2,7 @@ const W = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NsYXNzIGRje2NvbnN0cnVjdG9yKCl7dGhpc
2
2
  function d(Z) {
3
3
  let l;
4
4
  try {
5
- if (l = G && (window.URL || window.webkitURL).createObjectURL(G), !l)
6
- throw "";
5
+ if (l = G && (window.URL || window.webkitURL).createObjectURL(G), !l) throw "";
7
6
  const b = new Worker(l, {
8
7
  name: Z?.name
9
8
  });
@@ -2,8 +2,7 @@ const c = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NsYXNzIFhye2NvbnN0cnVjdG9yKCl7dGhpc
2
2
  function W(Z) {
3
3
  let l;
4
4
  try {
5
- if (l = d && (window.URL || window.webkitURL).createObjectURL(d), !l)
6
- throw "";
5
+ if (l = d && (window.URL || window.webkitURL).createObjectURL(d), !l) throw "";
7
6
  const b = new Worker(l, {
8
7
  name: Z?.name
9
8
  });
@@ -2,8 +2,7 @@ const d = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NsYXNzIHBze2NvbnN0cnVjdG9yKCl7dGhpc
2
2
  function W(l) {
3
3
  let Z;
4
4
  try {
5
- if (Z = G && (window.URL || window.webkitURL).createObjectURL(G), !Z)
6
- throw "";
5
+ if (Z = G && (window.URL || window.webkitURL).createObjectURL(G), !Z) throw "";
7
6
  const b = new Worker(Z, {
8
7
  name: l?.name
9
8
  });
package/dist/index.mjs CHANGED
@@ -11,10 +11,10 @@ import As from "mockjs";
11
11
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
12
12
  * @name @vtj/designer
13
13
  * @author CHC chenhuachun1549@dingtalk.com
14
- * @version 0.8.60
14
+ * @version 0.8.62
15
15
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
16
16
  */
17
- const js = "0.8.60", Ut = {
17
+ const js = "0.8.62", Ut = {
18
18
  width: 390,
19
19
  height: 844
20
20
  }, qt = {
@@ -176,8 +176,7 @@ function Fs(u) {
176
176
  return o;
177
177
  }
178
178
  function dt(u, e) {
179
- if (!e)
180
- return null;
179
+ if (!e) return null;
181
180
  const { left: t, top: l, width: a, height: r } = u === "dropping" ? Fs(e) : e.rect, s = {
182
181
  left: `${t}px`,
183
182
  top: `${l}px`,
@@ -205,8 +204,7 @@ function ke() {
205
204
  function Ns(u, e) {
206
205
  const t = k(""), { selected: l, isSelectBlock: a } = ke(), r = S(() => l.value?.model.id), s = S(() => {
207
206
  const i = mt(u), g = mt(e), p = [];
208
- if (!i)
209
- return p;
207
+ if (!i) return p;
210
208
  const v = g?.__contextRefs[r.value || ""], b = g === v || a.value ? [] : Object.keys(v?.context || {}).filter(($) => !["context", "ref"].includes($)).map(($) => `this.context.${$}`);
211
209
  b.length && p.push({ title: "上下文", items: b });
212
210
  const c = i.inject.map(($) => `this.${$.name}`);
@@ -232,8 +230,7 @@ function Ns(u, e) {
232
230
  );
233
231
  return O.length && p.push({ title: "refs", items: O }), p;
234
232
  }), o = S(() => {
235
- if (!t.value)
236
- return s.value;
233
+ if (!t.value) return s.value;
237
234
  const i = t.value.toLowerCase(), g = [];
238
235
  return s.value.forEach((p) => {
239
236
  const v = p.items.filter(
@@ -298,8 +295,7 @@ function Ws(u) {
298
295
  value: Array.isArray(t.value.children) ? "" : t.value.children
299
296
  }
300
297
  ] : []), r = S(() => {
301
- if (!t.value)
302
- return [];
298
+ if (!t.value) return [];
303
299
  const v = l.value || e.assets.componentMap.get(t.value.name);
304
300
  return v ? (v.props || []).map((b) => ({
305
301
  ...b,
@@ -404,24 +400,21 @@ function Ms(u) {
404
400
  }
405
401
  );
406
402
  const a = S(() => {
407
- if (ee(t.value))
408
- return [];
403
+ if (ee(t.value)) return [];
409
404
  const o = t.value?.events || {};
410
405
  return Es.map((i) => ({
411
406
  name: i,
412
407
  event: o[i]
413
408
  }));
414
409
  }), r = S(() => {
415
- if (ee(t.value))
416
- return [];
410
+ if (ee(t.value)) return [];
417
411
  const o = t.value?.events || {};
418
412
  return Ps.map((i) => ({
419
413
  name: i,
420
414
  event: o[i]
421
415
  }));
422
416
  }), s = S(() => {
423
- if (!t.value || ee(t.value))
424
- return [];
417
+ if (!t.value || ee(t.value)) return [];
425
418
  const o = t.value.events || {};
426
419
  return (l.value?.events || e.assets.componentMap.get(t.value.name)?.events || []).map((g) => {
427
420
  const p = typeof g == "string" ? g : g.name;
@@ -447,8 +440,7 @@ const Ht = (u, e) => new hn({
447
440
  arg: u
448
441
  });
449
442
  function Us(u) {
450
- if (!u)
451
- return [];
443
+ if (!u) return [];
452
444
  const { props: e = [], events: t = [] } = u;
453
445
  if (e.length && t.length) {
454
446
  const l = t.filter((a) => (typeof a == "string" ? a : a.name).startsWith("update:")).map((a) => a = typeof a == "string" ? a : a.name);
@@ -461,8 +453,7 @@ function qs(u) {
461
453
  const c = u.value?.model || null;
462
454
  return ee(c) ? null : c;
463
455
  }), l = (c) => S(() => t.value && (t.value.directives || []).find((_) => _.name === c) || Ht(c)), a = () => S(() => {
464
- if (!t.value)
465
- return [];
456
+ if (!t.value) return [];
466
457
  const c = e.assets.componentMap.get(t.value.name || "");
467
458
  return (c ? Us(c) : []).map((w) => (t.value?.directives || []).find(
468
459
  (x) => x.name === "vModel" && x.arg == w.name
@@ -498,8 +489,7 @@ function qs(u) {
498
489
  }
499
490
  },
500
491
  onModelChange: (c, _) => {
501
- if (!t.value)
502
- return;
492
+ if (!t.value) return;
503
493
  const w = parseInt(c), x = g.value[w];
504
494
  x && (_ ? (x.value = _, t.value.setDirective(x)) : (x.value = void 0, t.value.removeDirective(x)));
505
495
  }
@@ -1997,13 +1987,11 @@ const Io = { class: "v-context-viewer" }, Bo = /* @__PURE__ */ E({
1997
1987
  },
1998
1988
  setup(u) {
1999
1989
  const e = u, t = S(() => [`is-${e.mode}`]), l = S(() => {
2000
- if (e.mode === "pc")
2001
- return 1;
1990
+ if (e.mode === "pc") return 1;
2002
1991
  const r = e.mode === "mobile" ? Ut : qt, { width: s, height: o } = r, i = s > 0 ? (e.width || 0) / s : 1, g = o > 0 ? (e.height || 0) / o : 1;
2003
1992
  return Math.min(i, g);
2004
1993
  }), a = S(() => {
2005
- if (e.mode === "pc")
2006
- return {};
1994
+ if (e.mode === "pc") return {};
2007
1995
  const r = e.mode === "mobile" ? Ut : qt, { width: s, height: o } = r;
2008
1996
  return {
2009
1997
  width: `${s}px`,
@@ -2239,8 +2227,7 @@ const Io = { class: "v-context-viewer" }, Bo = /* @__PURE__ */ E({
2239
2227
  return ".js,.css,.json";
2240
2228
  }), b = S(() => s.value?.fromType === "Plugin"), c = async (D) => {
2241
2229
  const R = D, P = l.project.value;
2242
- if (!P)
2243
- return !1;
2230
+ if (!P) return !1;
2244
2231
  if (D.id)
2245
2232
  if (!P.existBlockName(R.name, [R.id]))
2246
2233
  P.updateBlock(R);
@@ -2485,16 +2472,14 @@ const Io = { class: "v-context-viewer" }, Bo = /* @__PURE__ */ E({
2485
2472
  __name: "index",
2486
2473
  setup(u) {
2487
2474
  const { engine: e, designer: t, selected: l } = ke(), { current: a } = ie(), r = k([]), s = (D, R) => {
2488
- if (R === "slot")
2489
- return [];
2475
+ if (R === "slot") return [];
2490
2476
  if (ee(D))
2491
2477
  return D.locked ? ["unlock"] : ["lock"];
2492
2478
  const P = D.parent;
2493
2479
  return P && (P.locked || P.invisible) ? [] : a.value?.locked ? [] : D.locked ? ["unlock"] : D.invisible ? ["visible"] : ["lock", "invisible", "copy", "remove"];
2494
2480
  }, o = (D, R) => {
2495
2481
  const P = {};
2496
- if (!D.some((F) => F.slot))
2497
- return i(D);
2482
+ if (!D.some((F) => F.slot)) return i(D);
2498
2483
  for (const F of D) {
2499
2484
  const L = F.slot?.name || "default";
2500
2485
  P[L] || (P[L] = []), P[L].push(F);
@@ -2523,8 +2508,7 @@ const Io = { class: "v-context-viewer" }, Bo = /* @__PURE__ */ E({
2523
2508
  Array.isArray(P.children) && (X.children = o(P.children, P)), R.push(X);
2524
2509
  }), R;
2525
2510
  }, g = () => {
2526
- if (!a.value)
2527
- return [];
2511
+ if (!a.value) return [];
2528
2512
  const { id: D, name: R, nodes: P } = a.value;
2529
2513
  return [
2530
2514
  {
@@ -2753,7 +2737,7 @@ const Io = { class: "v-context-viewer" }, Bo = /* @__PURE__ */ E({
2753
2737
  ]));
2754
2738
  }
2755
2739
  }), le = Gn({
2756
- loader: () => import("./Editor-bVAaI2zL.js"),
2740
+ loader: () => import("./Editor-DjXowHju.js"),
2757
2741
  loadingComponent: E({
2758
2742
  render() {
2759
2743
  return Te("div", "正在拼命加载...");
@@ -4918,8 +4902,7 @@ const Io = { class: "v-context-viewer" }, Bo = /* @__PURE__ */ E({
4918
4902
  }
4919
4903
  }, c = async (w) => {
4920
4904
  const { transform: x, test: C, name: I } = w;
4921
- if (!e.current)
4922
- return !1;
4905
+ if (!e.current) return !1;
4923
4906
  if (!e.item && e.current.dataSources[I])
4924
4907
  return ne(`名称【${I}】已经存在,请更换名称`), !1;
4925
4908
  if (x?.value) {
@@ -4934,8 +4917,7 @@ const Io = { class: "v-context-viewer" }, Bo = /* @__PURE__ */ E({
4934
4917
  w.test = void 0;
4935
4918
  return e.current?.setDataSource(w), !0;
4936
4919
  }, _ = async () => {
4937
- if (!e.context)
4938
- return;
4920
+ if (!e.context) return;
4939
4921
  if (!s.value.ref) {
4940
4922
  ne("请先选择API");
4941
4923
  return;
@@ -8671,11 +8653,9 @@ class bu {
8671
8653
  this.hover.value = null, this.dropping.value = null, this.selected.value = null;
8672
8654
  }
8673
8655
  async getDropSlot(e) {
8674
- if (!e)
8675
- return;
8656
+ if (!e) return;
8676
8657
  const { engine: t } = this, l = t.assets, a = l.componentMap, r = await l.getBlockMaterial(e.from) || a.get(e.name);
8677
- if (!r?.slots)
8678
- return;
8658
+ if (!r?.slots) return;
8679
8659
  const s = (r?.slots || ["default"]).map(
8680
8660
  (i) => typeof i == "string" ? {
8681
8661
  name: i,
@@ -8696,11 +8676,9 @@ class bu {
8696
8676
  async onDrop(e) {
8697
8677
  e.preventDefault();
8698
8678
  const { engine: t, dragging: l, dropping: a, draggingNode: r } = this, s = t.current.value, o = this.getHelper(e);
8699
- if (!s || !l || !a.value || !o)
8700
- return;
8679
+ if (!s || !l || !a.value || !o) return;
8701
8680
  const i = o.model, g = a.value.type;
8702
- if (!await this.allowDrop(i, g))
8703
- return;
8681
+ if (!await this.allowDrop(i, g)) return;
8704
8682
  let p;
8705
8683
  if (r)
8706
8684
  p = r;
@@ -8725,8 +8703,7 @@ class bu {
8725
8703
  }
8726
8704
  async onDragOver(e) {
8727
8705
  const t = this.getHelper(e);
8728
- if (!t)
8729
- return;
8706
+ if (!t) return;
8730
8707
  const { model: l, type: a } = t;
8731
8708
  l && await this.allowDrop(l, a) ? (e.preventDefault(), this.dropping.value = t) : this.dropping.value = null;
8732
8709
  }
@@ -8779,11 +8756,9 @@ class bu {
8779
8756
  }
8780
8757
  getHelper(e) {
8781
8758
  const t = e.composedPath() || [], l = this.findVtjElement(t) || this.document?.body;
8782
- if (!l)
8783
- return null;
8759
+ if (!l) return null;
8784
8760
  const a = this.getNodeByElement(l) || this.engine.current.value;
8785
- if (!a)
8786
- return null;
8761
+ if (!a) return null;
8787
8762
  const r = l.getBoundingClientRect(), s = this.getDropType(r, e.clientX, e.clientY), o = this.getNodePath(t);
8788
8763
  return {
8789
8764
  el: l,
@@ -8823,8 +8798,7 @@ class bu {
8823
8798
  async setHover(e) {
8824
8799
  if (await we(), e) {
8825
8800
  const t = this.getElmenetByModel(e);
8826
- if (!t)
8827
- return;
8801
+ if (!t) return;
8828
8802
  const l = t.getBoundingClientRect(), a = ee(e) ? [] : this.findPathByNode(e);
8829
8803
  this.hover.value = {
8830
8804
  el: t,
@@ -8839,8 +8813,7 @@ class bu {
8839
8813
  async setSelected(e) {
8840
8814
  if (await we(), e) {
8841
8815
  const t = this.getElmenetByModel(e) || this.document?.createElement("span");
8842
- if (!t)
8843
- return;
8816
+ if (!t) return;
8844
8817
  const l = t.getBoundingClientRect(), a = ee(e) ? [] : this.findPathByNode(e);
8845
8818
  this.selected.value = {
8846
8819
  el: t,
@@ -8855,8 +8828,7 @@ class bu {
8855
8828
  async setDropping(e, t = "inner") {
8856
8829
  if (await we(), e) {
8857
8830
  const l = this.getElmenetByModel(e);
8858
- if (!l)
8859
- return;
8831
+ if (!l) return;
8860
8832
  const a = l.getBoundingClientRect(), r = ee(e) ? [] : this.findPathByNode(e);
8861
8833
  this.dropping.value = {
8862
8834
  el: l,
@@ -8870,15 +8842,12 @@ class bu {
8870
8842
  }
8871
8843
  async allowDrop(e, t = "inner") {
8872
8844
  const { dragging: l, engine: a, draggingNode: r } = this, s = a.current.value;
8873
- if (!l || !s)
8874
- return !1;
8875
- if (ee(e))
8876
- return !0;
8845
+ if (!l || !s) return !1;
8846
+ if (ee(e)) return !0;
8877
8847
  if (r && e.id === r.id || r && r.isChild(e))
8878
8848
  return !1;
8879
8849
  const o = a.assets.componentMap, i = t !== "inner" && e.parent || e, g = await a.assets.getBlockMaterial(i.from) || o.get(i.name);
8880
- if (!g)
8881
- return !1;
8850
+ if (!g) return !1;
8882
8851
  const { parentIncludes: p = !0, name: v } = l, { childIncludes: f = !0 } = g, b = p === !0 || Array.isArray(p) && p.includes(i.name), c = f === !0 || Array.isArray(f) && f.includes(v);
8883
8852
  return b && c;
8884
8853
  }
@@ -9165,15 +9134,13 @@ class wu {
9165
9134
  this.groups.value = this.parseGroups(t), this.componentMap = _l(this.components, "name");
9166
9135
  }
9167
9136
  async getBlockMaterial(e, t) {
9168
- if (!e || typeof e == "string")
9169
- return null;
9137
+ if (!e || typeof e == "string") return null;
9170
9138
  let l;
9171
9139
  if (e.type === "Schema" && e.id && (l = this.caches[e.id] || await this.service.getFile(e.id), this.caches[e.id] = l), e.type === "UrlSchema" && e.url && (l = this.caches[e.url] || await this.provider.getDslByUrl(e.url), this.caches[e.url] = l), e.type === "Plugin") {
9172
9140
  const v = await this.service.getPluginMaterial(e);
9173
9141
  return v ? (v.name = t || v.name, v.from = e, this.componentMap.set(v.name, v), v) : null;
9174
9142
  }
9175
- if (!l)
9176
- return null;
9143
+ if (!l) return null;
9177
9144
  l.name = t || l.name;
9178
9145
  const { id: a, name: r, slots: s, props: o, emits: i } = l, g = (v) => {
9179
9146
  const f = Array.isArray(v) ? v : [v];
@@ -9384,8 +9351,7 @@ class sc extends bn {
9384
9351
  }
9385
9352
  async openFile(e) {
9386
9353
  const t = this.project.value, l = this.skeleton?.getRegion("Apps"), a = e || t?.homepage;
9387
- if (!t || !l || !a)
9388
- return;
9354
+ if (!t || !l || !a) return;
9389
9355
  const r = t.getPage(a);
9390
9356
  r && !r.raw && (l.regionRef?.setActive("Pages"), this.simulator.ready(() => {
9391
9357
  t.active(r);
@@ -10121,8 +10087,7 @@ const je = E({
10121
10087
  }, b = (c) => {
10122
10088
  if (a.value) {
10123
10089
  const _ = a.value[0]?.widgetRef;
10124
- if (!_)
10125
- return;
10090
+ if (!_) return;
10126
10091
  switch (c.name) {
10127
10092
  case "home":
10128
10093
  _.refresh();
@@ -2,8 +2,7 @@ const m = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NsYXNzIFBhe2NvbnN0cnVjdG9yKCl7dGhpc
2
2
  function G(l) {
3
3
  let Z;
4
4
  try {
5
- if (Z = d && (window.URL || window.webkitURL).createObjectURL(d), !Z)
6
- throw "";
5
+ if (Z = d && (window.URL || window.webkitURL).createObjectURL(d), !Z) throw "";
7
6
  const b = new Worker(Z, {
8
7
  name: l?.name
9
8
  });
@@ -2,8 +2,7 @@ const G = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NsYXNzIHdOZXtjb25zdHJ1Y3Rvcigpe3Roa
2
2
  function m(l) {
3
3
  let Z;
4
4
  try {
5
- if (Z = W && (window.URL || window.webkitURL).createObjectURL(W), !Z)
6
- throw "";
5
+ if (Z = W && (window.URL || window.webkitURL).createObjectURL(W), !Z) throw "";
7
6
  const b = new Worker(Z, {
8
7
  name: l?.name
9
8
  });
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@vtj/designer",
3
3
  "private": false,
4
- "version": "0.8.60",
4
+ "version": "0.8.62",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "mockjs": "~1.1.0",
8
8
  "monaco-editor": "~0.48.0",
9
- "@vtj/core": "~0.8.60",
10
- "@vtj/icons": "~0.8.60",
11
- "@vtj/renderer": "~0.8.60",
12
- "@vtj/ui": "~0.8.60",
13
- "@vtj/utils": "~0.8.60"
9
+ "@vtj/core": "~0.8.62",
10
+ "@vtj/renderer": "~0.8.62",
11
+ "@vtj/icons": "~0.8.62",
12
+ "@vtj/utils": "~0.8.62",
13
+ "@vtj/ui": "~0.8.62"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/mockjs": "~1.0.10",
17
17
  "vue": "~3.4.15",
18
- "vue-router": "~4.3.0",
19
- "@vtj/cli": "~0.8.14"
18
+ "vue-router": "~4.4.0",
19
+ "@vtj/cli": "~0.8.15"
20
20
  },
21
21
  "files": [
22
22
  "dist",
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/designer
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.8.59
5
+ * @version 0.8.62
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.8.59";
8
+ export declare const version = "0.8.62";