@shjjs/visual-ui 3.0.5 → 3.0.8

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.
@@ -1,21 +1,21 @@
1
- var y = Object.defineProperty;
2
- var w = (u, t, e) => t in u ? y(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
3
- var h = (u, t, e) => w(u, typeof t != "symbol" ? t + "" : t, e);
4
- import { cloneDeep as x, isString as k } from "lodash";
5
- import { parseStaticData as C } from "./sources/static.mjs";
6
- import { parseUrlData as M } from "./sources/url.mjs";
7
- import { parseVariableData as v } from "./sources/variable.mjs";
8
- import { parseAPIPort as A } from "./sources/api.mjs";
9
- import { DataSourceUtils as E } from "./utils/utils.mjs";
10
- import { parseStorage as U } from "./sources/storage.mjs";
11
- import { parseMqttData as B } from "./sources/mqtt.mjs";
12
- import { parseWebSocketData as T } from "./sources/websocket.mjs";
13
- import { MqttConnectionPoolManager as m } from "./utils/mqttConnectionPool.mjs";
1
+ var w = Object.defineProperty;
2
+ var x = (p, t, e) => t in p ? w(p, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[t] = e;
3
+ var f = (p, t, e) => x(p, typeof t != "symbol" ? t + "" : t, e);
4
+ import { cloneDeep as k, isString as C } from "lodash";
5
+ import { parseStaticData as M } from "./sources/static.mjs";
6
+ import { parseUrlData as v } from "./sources/url.mjs";
7
+ import { parseVariableData as A } from "./sources/variable.mjs";
8
+ import { parseAPIPort as E } from "./sources/api.mjs";
9
+ import { DataSourceUtils as U } from "./utils/utils.mjs";
10
+ import { parseStorage as B } from "./sources/storage.mjs";
11
+ import { parseMqttData as T } from "./sources/mqtt.mjs";
12
+ import { parseWebSocketData as W } from "./sources/websocket.mjs";
13
+ import { MqttConnectionPoolManager as d } from "./utils/mqttConnectionPool.mjs";
14
14
  import { WebSocketConnectionPoolManager as S } from "./utils/websocketConnectionPool.mjs";
15
- import { mappingData as W } from "./utils/mappingData.mjs";
16
- import { groupData as q } from "./utils/groupData.mjs";
17
- import { storageData as g } from "./utils/storageData.mjs";
18
- const c = class c {
15
+ import { mappingData as q } from "./utils/mappingData.mjs";
16
+ import { groupData as K } from "./utils/groupData.mjs";
17
+ import { storageData as m } from "./utils/storageData.mjs";
18
+ const l = class l {
19
19
  /**
20
20
  * 添加数据源解析器
21
21
  * @param type - 数据源类型
@@ -44,21 +44,21 @@ const c = class c {
44
44
  */
45
45
  static parse({
46
46
  sources: t,
47
- callback: e = (o) => o || [],
47
+ callback: e = (i) => i || [],
48
48
  noUseMapping: a = !1,
49
49
  isInterval: r = !0,
50
- isEditor: i = !1
50
+ isEditor: o = !1
51
51
  }) {
52
52
  try {
53
53
  if (t.length <= 0)
54
54
  throw new Error("未找到数据源");
55
- t.forEach((o) => {
55
+ t.forEach((i) => {
56
56
  this.handleDataSourceExecution(
57
- o,
57
+ i,
58
58
  e,
59
59
  a,
60
60
  r,
61
- i
61
+ o
62
62
  );
63
63
  });
64
64
  } catch {
@@ -68,27 +68,27 @@ const c = class c {
68
68
  /**
69
69
  * 处理数据源执行逻辑,根据pid确定执行顺序
70
70
  */
71
- static handleDataSourceExecution(t, e, a, r, i) {
72
- if (i) {
71
+ static handleDataSourceExecution(t, e, a, r, o) {
72
+ if (o) {
73
73
  this.executeDataSource(
74
74
  t,
75
75
  e,
76
76
  a,
77
77
  r,
78
- i
78
+ o
79
79
  );
80
80
  return;
81
81
  }
82
- const { id: o, pid: n } = t;
83
- if (this.initializeDataSourceState(o), this.checkAndExecuteWaitingChildren(o), n && n.toString() !== "-1") {
82
+ const { id: i, pid: n } = t;
83
+ if (this.initializeDataSourceState(i), this.checkAndExecuteWaitingChildren(i), n && n.toString() !== "-1") {
84
84
  const s = this.dataSourceStatePool.get(n);
85
85
  if (!s) {
86
- this.waitingPool.set(o, {
86
+ this.waitingPool.set(i, {
87
87
  item: t,
88
88
  callback: e,
89
89
  noUseMapping: a,
90
90
  isInterval: r,
91
- isEditor: i
91
+ isEditor: o
92
92
  });
93
93
  return;
94
94
  }
@@ -97,20 +97,20 @@ const c = class c {
97
97
  e,
98
98
  a,
99
99
  r,
100
- i
101
- ) : (this.waitingPool.set(o, {
100
+ o
101
+ ) : (this.waitingPool.set(i, {
102
102
  item: t,
103
103
  callback: e,
104
104
  noUseMapping: a,
105
105
  isInterval: r,
106
- isEditor: i
106
+ isEditor: o
107
107
  }), s.callbacks.push(() => {
108
- this.waitingPool.delete(o), this.executeDataSource(
108
+ this.waitingPool.delete(i), this.executeDataSource(
109
109
  t,
110
110
  e,
111
111
  a,
112
112
  r,
113
- i
113
+ o
114
114
  );
115
115
  }));
116
116
  } else
@@ -119,7 +119,7 @@ const c = class c {
119
119
  e,
120
120
  a,
121
121
  r,
122
- i
122
+ o
123
123
  );
124
124
  }
125
125
  /**
@@ -188,27 +188,27 @@ const c = class c {
188
188
  /**
189
189
  * 执行数据源
190
190
  */
191
- static executeDataSource(t, e, a, r, i) {
192
- if (i) {
193
- this.executeTask(t, a, i, (o) => {
194
- e(o);
191
+ static executeDataSource(t, e, a, r, o) {
192
+ if (o) {
193
+ this.executeTask(t, a, o, (i) => {
194
+ e(i);
195
195
  });
196
196
  return;
197
197
  }
198
- this.markDataSourceExecuting(t.id), this.setupInterval(t, r, a, i, e), this.executeTask(t, a, i, (o) => {
199
- e(o), this.markDataSourceCompleted(t.id);
198
+ this.markDataSourceExecuting(t.id), this.setupInterval(t, r, a, o, e), this.executeTask(t, a, o, (i) => {
199
+ e(i), this.markDataSourceCompleted(t.id);
200
200
  });
201
201
  }
202
202
  /**
203
203
  * 设置定时任务
204
204
  */
205
- static setupInterval(t, e, a, r, i) {
205
+ static setupInterval(t, e, a, r, o) {
206
206
  if (!e) return;
207
- const o = this.timerPool.get(t.id);
208
- if (o && (clearInterval(o), this.timerPool.delete(t.id)), t.source.isAutoUpdate) {
207
+ const i = this.timerPool.get(t.id);
208
+ if (i && (clearInterval(i), this.timerPool.delete(t.id)), t.source.isAutoUpdate) {
209
209
  const n = setInterval(() => {
210
210
  this.markDataSourceExecuting(t.id), this.executeTask(t, a, r, (s) => {
211
- i(s), this.markDataSourceCompleted(t.id);
211
+ o(s), this.markDataSourceCompleted(t.id);
212
212
  });
213
213
  }, t.source.autoUpdateTime * 1e3);
214
214
  this.timerPool.set(t.id, n);
@@ -218,14 +218,13 @@ const c = class c {
218
218
  * 执行任务
219
219
  */
220
220
  static executeTask(t, e, a, r) {
221
- const i = t, { source: o } = i, n = this.getParser(o.type);
222
- n && n(i, e, (s) => {
223
- var f;
221
+ const o = t, { source: i } = o, n = this.getParser(i.type);
222
+ n && n(o, e, (s) => {
224
223
  if (a) {
225
224
  r(s);
226
225
  return;
227
226
  }
228
- !e && ((f = i.source.mapping) != null && f.length) ? (g(i.source.storage, s.finalKeyData), r(s.finalKeyData)) : (g(i.source.storage, s.noMappingData), r(s.noMappingData));
227
+ e ? (m(o.source.storage, s.noMappingData), r(s.noMappingData)) : (m(o.source.storage, s.finalKeyData), r(s.finalKeyData));
229
228
  });
230
229
  }
231
230
  /**
@@ -237,30 +236,31 @@ const c = class c {
237
236
  * @returns
238
237
  */
239
238
  static processData(t, e, a, r) {
240
- const { filter: i, mapping: o, dynamicMapping: n, isUserdata: s } = x(t);
241
- return new Promise(function(f) {
242
- const P = e;
243
- c.filterData(i, e).then(
244
- (l) => {
245
- const p = {
239
+ const { filter: o, mapping: i, dynamicMapping: n, isUserdata: s } = k(t);
240
+ return new Promise(function(P) {
241
+ const D = e;
242
+ l.filterData(o, e).then(
243
+ (u) => {
244
+ const h = {
246
245
  id: a,
247
246
  finalKeyData: { id: a, data: null },
248
247
  finalUserData: { id: a, data: null },
249
- filteredData: { id: a, data: l },
250
- rawData: { id: a, data: P },
248
+ filteredData: { id: a, data: u },
249
+ rawData: { id: a, data: D },
251
250
  noMappingData: null
252
251
  };
253
- if (!r && o.length) {
254
- const d = W(
255
- l,
256
- o,
252
+ if (r)
253
+ h.finalUserData.data = u, h.noMappingData = u;
254
+ else {
255
+ const { mappedData: c, finalMapping: y } = q(
256
+ u,
257
+ i,
257
258
  n,
258
259
  s
259
260
  );
260
- p.finalKeyData.data = d.length ? q(d, o) : l, p.finalUserData.data = d.length ? d : l;
261
- } else
262
- p.finalUserData.data = l, p.noMappingData = l;
263
- f(p);
261
+ h.finalKeyData.data = c != null && c.length ? K(c, y) : u, h.finalUserData.data = c != null && c.length ? c : u;
262
+ }
263
+ P(h);
264
264
  }
265
265
  );
266
266
  });
@@ -272,19 +272,19 @@ const c = class c {
272
272
  * @returns
273
273
  */
274
274
  static async filterData(t, e) {
275
- if (!k(t))
275
+ if (!C(t))
276
276
  return e;
277
277
  try {
278
278
  let a = t.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, "");
279
- a = E.replaceStringVariables(a);
279
+ a = U.replaceStringVariables(a);
280
280
  const r = `
281
281
  ${a}
282
282
  if (typeof filter !== 'function') {
283
283
  throw new Error('filter function is not defined in the provided code');
284
284
  }
285
285
  return filter(data);
286
- `, o = new Function("data", r)(e);
287
- return o instanceof Promise ? await o : o;
286
+ `, i = new Function("data", r)(e);
287
+ return i instanceof Promise ? await i : i;
288
288
  } catch {
289
289
  return e;
290
290
  }
@@ -295,10 +295,10 @@ const c = class c {
295
295
  static destroy() {
296
296
  this.timerPool.forEach((t) => {
297
297
  clearInterval(t);
298
- }), this.timerPool.clear(), this.dataSourceStatePool.clear(), this.dataSourceStatePool = /* @__PURE__ */ new Map(), this.waitingPool.clear(), this.waitingPool = /* @__PURE__ */ new Map(), m.closeAllConnections(), S.closeAllConnections();
298
+ }), this.timerPool.clear(), this.dataSourceStatePool.clear(), this.dataSourceStatePool = /* @__PURE__ */ new Map(), this.waitingPool.clear(), this.waitingPool = /* @__PURE__ */ new Map(), d.closeAllConnections(), S.closeAllConnections();
299
299
  }
300
300
  static clearMqttConnectionById(t) {
301
- m.removeConnectionByUUID(t);
301
+ d.removeConnectionByUUID(t);
302
302
  }
303
303
  static clearWebSocketConnectionById(t) {
304
304
  S.removeConnectionByUUID(t);
@@ -307,26 +307,26 @@ const c = class c {
307
307
  /**
308
308
  * 定时器池
309
309
  */
310
- h(c, "timerPool", /* @__PURE__ */ new Map()), /**
310
+ f(l, "timerPool", /* @__PURE__ */ new Map()), /**
311
311
  * 数据源状态池 - 跟踪所有数据源的执行状态
312
312
  */
313
- h(c, "dataSourceStatePool", /* @__PURE__ */ new Map()), /**
313
+ f(l, "dataSourceStatePool", /* @__PURE__ */ new Map()), /**
314
314
  * 等待执行的数据源池 - 存储因依赖关系而等待的数据源
315
315
  */
316
- h(c, "waitingPool", /* @__PURE__ */ new Map()), /**
316
+ f(l, "waitingPool", /* @__PURE__ */ new Map()), /**
317
317
  * 数据源解析器
318
318
  */
319
- h(c, "parsers", /* @__PURE__ */ new Set([
320
- { type: "url", parser: M },
321
- { type: "static", parser: C },
322
- { type: "variable", parser: v },
323
- { type: "api", parser: A },
324
- { type: "storage", parser: U },
325
- { type: "mqtt", parser: B },
326
- { type: "ws", parser: T }
319
+ f(l, "parsers", /* @__PURE__ */ new Set([
320
+ { type: "url", parser: v },
321
+ { type: "static", parser: M },
322
+ { type: "variable", parser: A },
323
+ { type: "api", parser: E },
324
+ { type: "storage", parser: B },
325
+ { type: "mqtt", parser: T },
326
+ { type: "ws", parser: W }
327
327
  ]));
328
- let D = c;
328
+ let g = l;
329
329
  export {
330
- E as DataSourceUtils,
331
- D as SHJDatasourceV2
330
+ U as DataSourceUtils,
331
+ g as SHJDatasourceV2
332
332
  };
@@ -1,23 +1,23 @@
1
1
  import { SHJDatasourceV2 as k } from "../index.mjs";
2
2
  import { httpRequest as o } from "../utils/request.mjs";
3
3
  import { DataSourceUtils as n } from "../utils/utils.mjs";
4
- const L = async (t, P, l) => {
5
- var m;
6
- const e = t == null ? void 0 : t.id, p = (m = t == null ? void 0 : t.source) == null ? void 0 : m.api, a = (c) => {
7
- l(n.noneData(c));
4
+ const L = async (t, P, c) => {
5
+ var d;
6
+ const e = t == null ? void 0 : t.id, l = (d = t == null ? void 0 : t.source) == null ? void 0 : d.api, a = (m) => {
7
+ c(n.noneData(m));
8
8
  };
9
- if (!p || !e)
9
+ if (!l || !e)
10
10
  return a(e || "");
11
11
  const {
12
12
  isHeaders: U,
13
13
  isBody: u,
14
14
  headers: v,
15
- contentType: d,
15
+ contentType: p,
16
16
  url: D,
17
17
  postParam: E,
18
18
  type: y,
19
19
  isUseEnv: T = !0
20
- } = p;
20
+ } = l;
21
21
  try {
22
22
  const S = n.getEnvironments().envBaseUrl ?? "", V = T ? S : "", g = n.replaceStringVariables(D), i = U ? n.replaceObjectVariables(v) : {}, f = u ? n.replaceObjectVariables(E) : {}, s = V + g;
23
23
  if (!s)
@@ -32,7 +32,7 @@ const L = async (t, P, l) => {
32
32
  s,
33
33
  f,
34
34
  { headers: i },
35
- d
35
+ p
36
36
  );
37
37
  break;
38
38
  case "PUT":
@@ -40,7 +40,7 @@ const L = async (t, P, l) => {
40
40
  s,
41
41
  f,
42
42
  { headers: i },
43
- d
43
+ p
44
44
  );
45
45
  break;
46
46
  case "DELETE":
@@ -59,7 +59,7 @@ const L = async (t, P, l) => {
59
59
  e,
60
60
  P
61
61
  );
62
- h ? l(h) : a(e);
62
+ h ? c(h) : a(e);
63
63
  } else
64
64
  a(e);
65
65
  } catch {
@@ -1,31 +1,34 @@
1
1
  import { isArray as c } from "lodash";
2
- const m = (n, s, e, a) => {
3
- if (!c(n))
4
- return n;
2
+ const m = (s, n, r, a) => {
3
+ if (!c(s))
4
+ return s;
5
5
  let l = null;
6
- return l = n.map((r, p) => {
6
+ return l = s.map((e, p) => {
7
7
  const i = {};
8
- return e && p === 0 && (s = f(r, s)), Object.keys(s).forEach((o) => {
9
- const t = s[o];
10
- t.alias ? i[t.alias] = r[t.mapping] : i[t.name] = r[t.mapping];
11
- }), a && (i.userdata = r), i;
12
- }), l;
13
- }, f = (n, s) => {
14
- const e = [];
15
- return n ?? (n = []), Object.keys(n).forEach((a) => {
16
- const l = s.find((r) => r.name === a);
17
- l ? e.push({
8
+ return r && p === 0 && (n = f(e, n)), Object.keys(n).forEach((o) => {
9
+ const t = n[o];
10
+ t.alias ? i[t.alias] = e[t.mapping] : i[t.name] = e[t.mapping];
11
+ }), a && (i.userdata = e), i;
12
+ }), {
13
+ mappedData: l,
14
+ finalMapping: n
15
+ };
16
+ }, f = (s, n) => {
17
+ const r = [];
18
+ return s ?? (s = []), Object.keys(s).forEach((a) => {
19
+ const l = n.find((e) => e.name === a);
20
+ l ? r.push({
18
21
  alias: l.alias,
19
22
  name: a,
20
23
  label: a,
21
24
  mapping: l.mapping
22
- }) : e.push({
25
+ }) : r.push({
23
26
  alias: a,
24
27
  name: a,
25
28
  label: a,
26
29
  mapping: a
27
30
  });
28
- }), e;
31
+ }), r;
29
32
  };
30
33
  export {
31
34
  f as dynamicMappingData,
@@ -1,7 +1,7 @@
1
1
  import o from "./index.vue2.mjs";
2
2
  /* empty css */
3
3
  import t from "../../../../_virtual/_plugin-vue_export-helper.mjs";
4
- const _ = /* @__PURE__ */ t(o, [["__scopeId", "data-v-79619911"]]);
4
+ const r = /* @__PURE__ */ t(o, [["__scopeId", "data-v-dde8cdcf"]]);
5
5
  export {
6
- _ as default
6
+ r as default
7
7
  };
@@ -1,5 +1,5 @@
1
- import { defineComponent as d, onMounted as J, computed as a, shallowRef as b, ref as u, watch as j, createElementBlock as E, openBlock as c, createElementVNode as H, createBlock as V, createCommentVNode as O, unref as P } from "vue";
2
- import { useVueImportMap as x, Sandbox as N, useStore as k } from "@vue/repl";
1
+ import { defineComponent as d, onMounted as J, computed as a, shallowRef as b, ref as u, watch as j, createElementBlock as E, openBlock as c, createElementVNode as H, createBlock as V, createCommentVNode as k, unref as O } from "vue";
2
+ import { useVueImportMap as P, Sandbox as x, useStore as N } from "@vue/repl";
3
3
  import { useWatch as D } from "./hooks/useWatch.mjs";
4
4
  /* empty css */
5
5
  /* empty css */
@@ -171,7 +171,7 @@ const B = { class: "custom-component-render" }, R = { class: "preview-content" }
171
171
  J(() => {
172
172
  window.SHJDatasourceV2 = M, window.SHJParseEvent = T;
173
173
  });
174
- const e = a(() => _(i.option)), { productionMode: p, vueVersion: v, importMap: h } = x(), w = a(() => ({
174
+ const e = a(() => _(i.option)), { productionMode: p, vueVersion: v, importMap: h } = P(), w = a(() => ({
175
175
  script: {
176
176
  inlineTemplate: p.value,
177
177
  isProd: p.value,
@@ -188,7 +188,7 @@ const B = { class: "custom-component-render" }, R = { class: "preview-content" }
188
188
  if (!(l.value === s && o.value)) {
189
189
  l.value = s, t.value = !0;
190
190
  try {
191
- const r = k(
191
+ const r = N(
192
192
  { builtinImportMap: h, vueVersion: v, sfcOptions: w },
193
193
  s
194
194
  );
@@ -265,6 +265,7 @@ const B = { class: "custom-component-render" }, R = { class: "preview-content" }
265
265
  #app {
266
266
  height: 100%;
267
267
  overflow: hidden;
268
+ background-color: transparent !important;
268
269
  }
269
270
  </style>
270
271
  ${g}
@@ -273,12 +274,13 @@ const B = { class: "custom-component-render" }, R = { class: "preview-content" }
273
274
  }));
274
275
  return (s, r) => (c(), E("div", B, [
275
276
  H("div", R, [
276
- !t.value && o.value ? (c(), V(P(N), {
277
+ !t.value && o.value ? (c(), V(O(x), {
277
278
  key: 0,
278
279
  store: o.value,
280
+ theme: "dark",
279
281
  "clear-console": !1,
280
282
  "preview-options": C.value
281
- }, null, 8, ["store", "preview-options"])) : O("", !0)
283
+ }, null, 8, ["store", "preview-options"])) : k("", !0)
282
284
  ])
283
285
  ]));
284
286
  }