@shjjs/visual-ui 1.0.28 → 1.0.30

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.
@@ -29,23 +29,23 @@ const y = class y {
29
29
  */
30
30
  static parse({ sources: t, callback: a, tId: e, isStore: s = !1, noUseMapping: i = !1, isInterval: n = !0 }) {
31
31
  return a ?? (a = () => {
32
- }), t && k(t) && t.length > 0 ? new Promise((p, o) => {
32
+ }), t && k(t) && t.length > 0 && t[0] ? new Promise((p, o) => {
33
33
  P.cleanupPreviousWebSockets(this.wsInstances, t.map((r) => r.id), e);
34
- const f = /* @__PURE__ */ new Set(), h = this.wsInstances.get(e) || /* @__PURE__ */ new Set();
34
+ const f = /* @__PURE__ */ new Set(), m = this.wsInstances.get(e) || /* @__PURE__ */ new Set();
35
35
  t.forEach((r) => {
36
36
  var w;
37
37
  if (n) {
38
- const { source: c } = r, d = `${e}-${r.id}`, D = this.datasourceTimer.findIndex((m) => m.id === d);
38
+ const { source: c } = r, u = `${e}-${r.id}`, D = this.datasourceTimer.findIndex((h) => h.id === u);
39
39
  if (D !== -1 && (clearInterval(this.datasourceTimer[D].timer), this.datasourceTimer.splice(D, 1)), c.isAutoUpdate) {
40
- const m = setInterval(() => {
40
+ const h = setInterval(() => {
41
41
  var l;
42
- (l = this.task(r, s, i, e, (u) => {
43
- a(u);
44
- })) == null || l.then((u) => {
45
- p(u);
42
+ (l = this.task(r, s, i, e, (d) => {
43
+ a(d);
44
+ })) == null || l.then((d) => {
45
+ p(d);
46
46
  });
47
47
  }, c.autoUpdateTime * 1e3);
48
- this.datasourceTimer.push({ id: d, timer: m });
48
+ this.datasourceTimer.push({ id: u, timer: h });
49
49
  }
50
50
  }
51
51
  if (r.source.type !== "ws") {
@@ -53,12 +53,12 @@ const y = class y {
53
53
  return;
54
54
  }
55
55
  if (P.hasValidWebSocket(this.wsInstances, e, r.id))
56
- h.forEach((c) => {
56
+ m.forEach((c) => {
57
57
  c.getId() === r.id && f.add(c);
58
58
  });
59
59
  else {
60
- const c = $(r, r.id, i, e, (d) => {
61
- p(d), a({ data: [{ data: d.finalUserData.data }] }), this.taskStorage(t, d.rawData.data);
60
+ const c = $(r, r.id, i, e, (u) => {
61
+ p(u), a({ data: [{ data: u.finalUserData.data }] }), this.taskStorage(t, u.rawData.data);
62
62
  });
63
63
  f.add(c);
64
64
  }
@@ -78,8 +78,8 @@ const y = class y {
78
78
  }) {
79
79
  return t ? new Promise((n, p) => {
80
80
  let o = null;
81
- const { source: f } = t, h = this.getParser(f.type);
82
- h && (o = h(t, t.id, e)), o.then((r) => {
81
+ const { source: f } = t, m = this.getParser(f.type);
82
+ m && (o = m(t, t.id, e)), o.then((r) => {
83
83
  i(e ? r.noMappingData : r.finalKeyData), this.taskStorage(t, r.rawData.data), n(r);
84
84
  });
85
85
  }) : (i([]), Promise.resolve([]));
@@ -126,38 +126,38 @@ const y = class y {
126
126
  return new Promise(function(p) {
127
127
  const o = I({ id: s, data: a });
128
128
  y.filterData(t, a).then((f) => {
129
- const h = I({ id: s, data: f });
129
+ const m = I({ id: s, data: f });
130
130
  if (n)
131
131
  p({
132
132
  id: s,
133
133
  finalKeyData: [],
134
134
  finalUserData: { id: s, data: f },
135
- filteredData: h,
135
+ filteredData: m,
136
136
  rawData: o,
137
137
  noMappingData: f
138
138
  });
139
139
  else {
140
140
  let r = [];
141
- k(f) && (r = f.map((d, D) => {
142
- const m = {};
141
+ k(f) && (r = f.map((u, D) => {
142
+ const h = {};
143
143
  if (i && i && D === 0) {
144
144
  const l = [];
145
- for (const u in d) {
146
- const T = e.find((b) => b.name === u);
147
- T ? l.push({ alias: T.alias, name: u, type: "any", label: u, mapping: T.mapping, status: !0 }) : l.push({ alias: u, name: u, type: "any", label: u, mapping: u, status: !0 });
145
+ for (const d in u) {
146
+ const T = e.find((b) => b.name === d);
147
+ T ? l.push({ alias: T.alias, name: d, type: "any", label: d, mapping: T.mapping, status: !0 }) : l.push({ alias: d, name: d, type: "any", label: d, mapping: d, status: !0 });
148
148
  }
149
149
  e.splice(0, e.length), e.push(...l);
150
150
  }
151
151
  return e.forEach((l) => {
152
- l.alias ? m[l.alias] = d[l.mapping] : m[l.name] = d[l.mapping];
153
- }), m;
152
+ l.alias ? h[l.alias] = u[l.mapping] : h[l.name] = u[l.mapping];
153
+ }), h.userdata = u, h;
154
154
  }));
155
155
  const w = I({ id: s, data: r }), c = I({ id: s, data: y.parseMappedData(r, e, s) });
156
156
  p({
157
157
  id: s,
158
158
  finalKeyData: r.length === 0 ? { id: s, data: f } : c,
159
159
  finalUserData: r.length === 0 ? { id: s, data: f } : w,
160
- filteredData: h,
160
+ filteredData: m,
161
161
  rawData: o,
162
162
  noMappingData: []
163
163
  });
@@ -90,7 +90,7 @@ export declare class DataSourceUtils {
90
90
  static getNestedValue(obj: any, path: string): any;
91
91
  /**
92
92
  * 从路径字符串中提取变量名
93
- * @param path 路径字符串,例如 "test[0].aa" 或 "test.aa[1]"
93
+ * @param path 路径字符串,例如 "测试.test" 或 "333[0].aa"
94
94
  * @returns 提取出的变量名
95
95
  */
96
96
  static extractVariableName(path: string): string;
@@ -174,11 +174,11 @@ class o {
174
174
  }
175
175
  /**
176
176
  * 从路径字符串中提取变量名
177
- * @param path 路径字符串,例如 "test[0].aa" 或 "test.aa[1]"
177
+ * @param path 路径字符串,例如 "测试.test" 或 "333[0].aa"
178
178
  * @returns 提取出的变量名
179
179
  */
180
180
  static extractVariableName(e) {
181
- const n = e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);
181
+ const n = e.match(/^([\u4e00-\u9fa5a-zA-Z0-9_][\u4e00-\u9fa5a-zA-Z0-9_]*)/);
182
182
  return n ? n[1] : "";
183
183
  }
184
184
  }
@@ -1,22 +1,23 @@
1
- var m = Object.defineProperty;
2
- var f = (a, e, t) => e in a ? m(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var d = (a, e, t) => f(a, typeof e != "symbol" ? e + "" : e, t);
4
- import { cloneDeep as l } from "lodash";
5
- import { executeLinkAction as y } from "./actions/linkAction.mjs";
6
- import { executeMoveAction as A } from "./actions/moveAction.mjs";
1
+ var d = Object.defineProperty;
2
+ var f = (s, e, t) => e in s ? d(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var m = (s, e, t) => f(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { cloneDeep as y } from "lodash";
5
+ import { executeLinkAction as A } from "./actions/linkAction.mjs";
6
+ import { executeMoveAction as g } from "./actions/moveAction.mjs";
7
7
  import { executeSendApiAction as h } from "./actions/sendApiAction.mjs";
8
8
  import { executeScaleAction as x } from "./actions/scaleAction.mjs";
9
- import { executeRotateAction as g } from "./actions/rotateAction.mjs";
10
- import { executeUpdatePageAction as E } from "./actions/updatePageAction.mjs";
11
- import { executeInvokeAction as S } from "./actions/invokeAction.mjs";
12
- import { executeFullScreenAction as b } from "./actions/fullScreenAction.mjs";
9
+ import { executeRotateAction as S } from "./actions/rotateAction.mjs";
10
+ import { executeUpdatePageAction as b } from "./actions/updatePageAction.mjs";
11
+ import { executeInvokeAction as E } from "./actions/invokeAction.mjs";
12
+ import { executeFullScreenAction as V } from "./actions/fullScreenAction.mjs";
13
13
  import { executeUpdateVariableAction as w } from "./actions/updateVariableAction.mjs";
14
14
  import { executeUpdateWidgetAction as M } from "./actions/updateWidgetAction.mjs";
15
15
  import { executeUeCommonsWebscoketAction as U } from "./actions/ueCommonsWebscoketAction.mjs";
16
16
  import { executeUeShjExecMethodAction as k } from "./actions/ueShjExecMethodAction.mjs";
17
17
  import { executeUnityWebglExecMethodAction as C } from "./actions/unityWebglExecMethodAction.mjs";
18
- import { executeUnityIframeExecMethodAction as N } from "./actions/unityIframeExecMethodAction.mjs";
19
- import { executeVrSceneMethodAction as V } from "./actions/vrSceneMethodAction.mjs";
18
+ import { executeUnityIframeExecMethodAction as D } from "./actions/unityIframeExecMethodAction.mjs";
19
+ import { executeVrSceneMethodAction as N } from "./actions/vrSceneMethodAction.mjs";
20
+ import { DataSourceUtils as l } from "../datasource/utils/utils.mjs";
20
21
  class W {
21
22
  /**
22
23
  * 添加事件解析器
@@ -24,8 +25,8 @@ class W {
24
25
  * @param parser 事件解析器
25
26
  */
26
27
  static addAction(e, t) {
27
- const o = Array.from(this.actions).find((r) => r.type === e);
28
- o && this.actions.delete(o), this.actions.add({ type: e, parser: t });
28
+ const i = Array.from(this.actions).find((r) => r.type === e);
29
+ i && this.actions.delete(i), this.actions.add({ type: e, parser: t });
29
30
  }
30
31
  /**
31
32
  * 获取事件解析器
@@ -33,7 +34,7 @@ class W {
33
34
  * @returns 事件解析器
34
35
  */
35
36
  static getAction(e) {
36
- const t = Array.from(this.actions).find((o) => o.type === e);
37
+ const t = Array.from(this.actions).find((i) => i.type === e);
37
38
  return t == null ? void 0 : t.parser;
38
39
  }
39
40
  /**
@@ -42,22 +43,22 @@ class W {
42
43
  * @param type 事件类型
43
44
  * @param params 参数
44
45
  */
45
- static parseEvents(e, t, o) {
46
- e != null && e.length && e.forEach((r, p) => {
46
+ static parseEvents(e, t, i) {
47
+ e != null && e.length && e.forEach((r, c) => {
47
48
  r.eventType === t && setTimeout(() => {
48
49
  const u = new CustomEvent("event-params-log", {
49
50
  detail: {
50
51
  eventId: r.id,
51
- params: o
52
+ params: i
52
53
  }
53
54
  });
54
55
  window.dispatchEvent(u);
55
- const s = this.filterEvent(r, o);
56
- if (!this.conditionLogic(r, s) || !r.actions)
56
+ const p = this.filterEvent(r, i);
57
+ if (!this.conditionLogic(r, p) || !r.actions)
57
58
  return;
58
59
  const n = this.getAction(r.actions);
59
- n && n(r, s);
60
- }, r.delay + p * 10);
60
+ n && n(r, p);
61
+ }, r.delay + c * 10);
61
62
  });
62
63
  }
63
64
  /**
@@ -67,19 +68,20 @@ class W {
67
68
  * @returns 过滤后的参数
68
69
  */
69
70
  static filterEvent(e, t) {
70
- let o = l(t);
71
+ let i = y(t);
71
72
  if (e.filterCode)
72
73
  try {
73
- const r = `
74
+ const r = l.getVariableData();
75
+ let c = `
74
76
  ${e.filterCode}
75
77
 
76
78
  // 在这里调用 filter 函数,并传递 data 参数
77
79
  return filter(data);
78
80
  `;
79
- o = new Function("data", r)(t);
81
+ c = c.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, ""), c = l.replaceStringVariables(c, r), i = new Function("data", c)(t);
80
82
  } catch {
81
83
  }
82
- return o;
84
+ return i;
83
85
  }
84
86
  /**
85
87
  * 条件逻辑判断
@@ -88,68 +90,69 @@ class W {
88
90
  * @returns 是否通过
89
91
  */
90
92
  static conditionLogic(e, t) {
91
- var u, s;
92
- if (!((s = (u = e.condition) == null ? void 0 : u.list) != null && s.length))
93
+ var u, p;
94
+ if (!((p = (u = e.condition) == null ? void 0 : u.list) != null && p.length))
93
95
  return !0;
94
- const o = (n) => {
96
+ const i = (n) => {
95
97
  if (n.type === "field") {
96
98
  if (!n.conditionName) return !1;
97
- const i = t[n.conditionName];
98
- if (i === void 0) return !1;
99
- const c = n.conditionValue;
99
+ const a = t[n.conditionName];
100
+ if (a === void 0) return !1;
101
+ const o = n.conditionValue;
100
102
  switch (n.conditionExpression) {
101
103
  case "eq":
102
- return i.toString() === (c || "").toString();
104
+ return a.toString() === (o || "").toString();
103
105
  case "neq":
104
- return i !== c;
106
+ return a !== o;
105
107
  case "lt":
106
- return i < Number(c);
108
+ return a < Number(o);
107
109
  case "gt":
108
- return i > Number(c);
110
+ return a > Number(o);
109
111
  case "lte":
110
- return i <= Number(c);
112
+ return a <= Number(o);
111
113
  case "gte":
112
- return i >= Number(c);
114
+ return a >= Number(o);
113
115
  case "includes":
114
- return i.includes(c);
116
+ return a.includes(o);
115
117
  case "noincludes":
116
- return !i.includes(c);
118
+ return !a.includes(o);
117
119
  default:
118
120
  return !1;
119
121
  }
120
122
  }
121
123
  if (n.type === "custom")
122
124
  try {
123
- const i = `
125
+ const a = l.getVariableData();
126
+ let o = `
124
127
  ${n.customValue}
125
128
  return condition(data);
126
129
  `;
127
- return new Function("data", i)(t);
130
+ return o = o.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, ""), o = l.replaceStringVariables(o, a), new Function("data", o)(t);
128
131
  } catch {
129
132
  return !1;
130
133
  }
131
134
  return !1;
132
- }, r = e.condition.list.map(o);
135
+ }, r = e.condition.list.map(i);
133
136
  return e.condition.type === "and" ? r.every(Boolean) : r.some(Boolean);
134
137
  }
135
138
  }
136
139
  /** 事件动作 */
137
- d(W, "actions", /* @__PURE__ */ new Set([
138
- { type: "link", parser: y },
140
+ m(W, "actions", /* @__PURE__ */ new Set([
141
+ { type: "link", parser: A },
139
142
  { type: "sendApi", parser: h },
140
- { type: "move", parser: A },
143
+ { type: "move", parser: g },
141
144
  { type: "scale", parser: x },
142
- { type: "rotate", parser: g },
143
- { type: "updatePage", parser: E },
144
- { type: "invoke", parser: S },
145
- { type: "fullscreen", parser: b },
145
+ { type: "rotate", parser: S },
146
+ { type: "updatePage", parser: b },
147
+ { type: "invoke", parser: E },
148
+ { type: "fullscreen", parser: V },
146
149
  { type: "updateVariable", parser: w },
147
150
  { type: "updateWidget", parser: M },
148
151
  { type: "ueCommonsWebscoket", parser: U },
149
152
  { type: "ueShjExecMethod", parser: k },
150
153
  { type: "unityWebglExecMethod", parser: C },
151
- { type: "unityIframeExecMethod", parser: N },
152
- { type: "vrSceneMethod", parser: V }
154
+ { type: "unityIframeExecMethod", parser: D },
155
+ { type: "vrSceneMethod", parser: N }
153
156
  ]));
154
157
  export {
155
158
  W as SHJParseEvent
@@ -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 p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-1495d842"]]);
4
+ const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-1a9e6290"]]);
5
5
  export {
6
6
  p as default
7
7
  };