@shjjs/visual-ui 3.0.2 → 3.0.4
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/es/commons/plugins/datasource/index.mjs +16 -16
- package/es/commons/plugins/datasource/sources/api.mjs +63 -42
- package/es/commons/plugins/datasource/utils/mappingData.mjs +28 -27
- package/es/commons/plugins/datasource/utils/utils.mjs +93 -239
- package/es/components/Scene/components/Map3d/index.vue.mjs +2 -2
- package/es/components/Scene/components/Map3d/index.vue2.mjs +88 -82
- package/es/packages/commons/plugins/datasource/sources/api.d.ts +1 -1
- package/es/packages/commons/plugins/datasource/utils/mappingData.d.ts +6 -0
- package/es/packages/commons/plugins/datasource/utils/utils.d.ts +6 -96
- package/es/packages/components/Scene/components/Map3d/index.vue.d.ts +1 -0
- package/es/widgets.css +1 -1
- package/package.json +1 -1
- package/umd/index.js +421 -421
- package/umd/widgets.css +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
|
-
var w = (
|
|
3
|
-
var h = (
|
|
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
4
|
import { cloneDeep as x, isString as k } from "lodash";
|
|
5
5
|
import { parseStaticData as C } from "./sources/static.mjs";
|
|
6
6
|
import { parseUrlData as M } from "./sources/url.mjs";
|
|
7
7
|
import { parseVariableData as v } from "./sources/variable.mjs";
|
|
8
8
|
import { parseAPIPort as A } from "./sources/api.mjs";
|
|
9
|
-
import { DataSourceUtils as
|
|
10
|
-
import { parseStorage as
|
|
11
|
-
import { parseMqttData as
|
|
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
12
|
import { parseWebSocketData as T } from "./sources/websocket.mjs";
|
|
13
13
|
import { MqttConnectionPoolManager as m } from "./utils/mqttConnectionPool.mjs";
|
|
14
14
|
import { WebSocketConnectionPoolManager as S } from "./utils/websocketConnectionPool.mjs";
|
|
@@ -195,7 +195,7 @@ const c = class c {
|
|
|
195
195
|
});
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
|
-
this.setupInterval(t, r, a, i, e), this.executeTask(t, a, i, (o) => {
|
|
198
|
+
this.markDataSourceExecuting(t.id), this.setupInterval(t, r, a, i, e), this.executeTask(t, a, i, (o) => {
|
|
199
199
|
e(o), this.markDataSourceCompleted(t.id);
|
|
200
200
|
});
|
|
201
201
|
}
|
|
@@ -207,8 +207,8 @@ const c = class c {
|
|
|
207
207
|
const o = this.timerPool.get(t.id);
|
|
208
208
|
if (o && (clearInterval(o), this.timerPool.delete(t.id)), t.source.isAutoUpdate) {
|
|
209
209
|
const n = setInterval(() => {
|
|
210
|
-
this.executeTask(t, a, r, (s) => {
|
|
211
|
-
i(s);
|
|
210
|
+
this.markDataSourceExecuting(t.id), this.executeTask(t, a, r, (s) => {
|
|
211
|
+
i(s), this.markDataSourceCompleted(t.id);
|
|
212
212
|
});
|
|
213
213
|
}, t.source.autoUpdateTime * 1e3);
|
|
214
214
|
this.timerPool.set(t.id, n);
|
|
@@ -242,7 +242,7 @@ const c = class c {
|
|
|
242
242
|
const P = e;
|
|
243
243
|
c.filterData(i, e).then(
|
|
244
244
|
(l) => {
|
|
245
|
-
const
|
|
245
|
+
const p = {
|
|
246
246
|
id: a,
|
|
247
247
|
finalKeyData: { id: a, data: null },
|
|
248
248
|
finalUserData: { id: a, data: null },
|
|
@@ -257,10 +257,10 @@ const c = class c {
|
|
|
257
257
|
n,
|
|
258
258
|
s
|
|
259
259
|
);
|
|
260
|
-
|
|
260
|
+
p.finalKeyData.data = d.length ? q(d, o) : l, p.finalUserData.data = d.length ? d : l;
|
|
261
261
|
} else
|
|
262
|
-
|
|
263
|
-
f(
|
|
262
|
+
p.finalUserData.data = l, p.noMappingData = l;
|
|
263
|
+
f(p);
|
|
264
264
|
}
|
|
265
265
|
);
|
|
266
266
|
});
|
|
@@ -276,7 +276,7 @@ const c = class c {
|
|
|
276
276
|
return e;
|
|
277
277
|
try {
|
|
278
278
|
let a = t.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, "");
|
|
279
|
-
a =
|
|
279
|
+
a = E.replaceStringVariables(a);
|
|
280
280
|
const r = `
|
|
281
281
|
${a}
|
|
282
282
|
if (typeof filter !== 'function') {
|
|
@@ -321,12 +321,12 @@ h(c, "parsers", /* @__PURE__ */ new Set([
|
|
|
321
321
|
{ type: "static", parser: C },
|
|
322
322
|
{ type: "variable", parser: v },
|
|
323
323
|
{ type: "api", parser: A },
|
|
324
|
-
{ type: "storage", parser:
|
|
325
|
-
{ type: "mqtt", parser:
|
|
324
|
+
{ type: "storage", parser: U },
|
|
325
|
+
{ type: "mqtt", parser: B },
|
|
326
326
|
{ type: "ws", parser: T }
|
|
327
327
|
]));
|
|
328
328
|
let D = c;
|
|
329
329
|
export {
|
|
330
|
-
|
|
330
|
+
E as DataSourceUtils,
|
|
331
331
|
D as SHJDatasourceV2
|
|
332
332
|
};
|
|
@@ -1,51 +1,72 @@
|
|
|
1
|
-
import { SHJDatasourceV2 as
|
|
2
|
-
import { httpRequest as
|
|
3
|
-
import { DataSourceUtils as
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
import { SHJDatasourceV2 as k } from "../index.mjs";
|
|
2
|
+
import { httpRequest as o } from "../utils/request.mjs";
|
|
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));
|
|
8
|
+
};
|
|
9
|
+
if (!p || !e)
|
|
10
|
+
return a(e || "");
|
|
11
|
+
const {
|
|
12
|
+
isHeaders: U,
|
|
13
|
+
isBody: u,
|
|
14
|
+
headers: v,
|
|
15
|
+
contentType: d,
|
|
16
|
+
url: D,
|
|
17
|
+
postParam: E,
|
|
18
|
+
type: y,
|
|
19
|
+
isUseEnv: T = !0
|
|
20
|
+
} = p;
|
|
6
21
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
i(t.noneData(e.id));
|
|
23
|
-
}).catch(() => {
|
|
24
|
-
i(t.noneData(e.id));
|
|
25
|
-
});
|
|
26
|
-
}, s = l.envBaseUrl || "";
|
|
27
|
-
a = t.replaceURLVariables(a), a = t.replaceStringVariables(a), c && (o = t.replaceObjectVariables(o)), y && (r = t.replaceObjectVariables(r)), n.type === "GET" && p(f.get(s + a, { headers: r })), n.type === "POST" && p(
|
|
28
|
-
f.post(
|
|
29
|
-
s + a,
|
|
30
|
-
o,
|
|
31
|
-
{ headers: r },
|
|
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
|
+
if (!s)
|
|
24
|
+
return a(e);
|
|
25
|
+
let r;
|
|
26
|
+
switch (y) {
|
|
27
|
+
case "GET":
|
|
28
|
+
r = o.get(s, { headers: i });
|
|
29
|
+
break;
|
|
30
|
+
case "POST":
|
|
31
|
+
r = o.post(
|
|
32
|
+
s,
|
|
33
|
+
f,
|
|
34
|
+
{ headers: i },
|
|
32
35
|
d
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
);
|
|
37
|
+
break;
|
|
38
|
+
case "PUT":
|
|
39
|
+
r = o.put(
|
|
40
|
+
s,
|
|
41
|
+
f,
|
|
42
|
+
{ headers: i },
|
|
39
43
|
d
|
|
40
|
-
)
|
|
41
|
-
|
|
44
|
+
);
|
|
45
|
+
break;
|
|
46
|
+
case "DELETE":
|
|
47
|
+
r = o.delete(s, {
|
|
48
|
+
headers: i
|
|
49
|
+
});
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
return a(e);
|
|
53
|
+
}
|
|
54
|
+
const b = await r;
|
|
55
|
+
if (b.status === 200) {
|
|
56
|
+
const h = await k.processData(
|
|
57
|
+
t.source,
|
|
58
|
+
b.data,
|
|
59
|
+
e,
|
|
60
|
+
P
|
|
61
|
+
);
|
|
62
|
+
h ? l(h) : a(e);
|
|
42
63
|
} else
|
|
43
|
-
|
|
64
|
+
a(e);
|
|
44
65
|
} catch {
|
|
45
|
-
|
|
66
|
+
a(e);
|
|
46
67
|
}
|
|
47
68
|
};
|
|
48
69
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
o as httpRequest,
|
|
71
|
+
L as parseAPIPort
|
|
51
72
|
};
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { isArray as
|
|
2
|
-
const
|
|
3
|
-
if (!
|
|
4
|
-
return
|
|
5
|
-
let
|
|
6
|
-
return
|
|
1
|
+
import { isArray as c } from "lodash";
|
|
2
|
+
const u = (l, n, r, a) => {
|
|
3
|
+
if (!c(l))
|
|
4
|
+
return l;
|
|
5
|
+
let s = null;
|
|
6
|
+
return s = l.map((e, p) => {
|
|
7
7
|
const i = {};
|
|
8
|
-
return
|
|
9
|
-
const t =
|
|
10
|
-
t.alias ? i[t.alias] =
|
|
11
|
-
}),
|
|
12
|
-
}),
|
|
13
|
-
}, f = (
|
|
14
|
-
const
|
|
15
|
-
return Object.keys(
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
alias:
|
|
19
|
-
name:
|
|
20
|
-
label:
|
|
21
|
-
mapping:
|
|
22
|
-
}) :
|
|
23
|
-
alias:
|
|
24
|
-
name:
|
|
25
|
-
label:
|
|
26
|
-
mapping:
|
|
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
|
+
}), s;
|
|
13
|
+
}, f = (l, n) => {
|
|
14
|
+
const r = [];
|
|
15
|
+
return Object.keys(l).forEach((a) => {
|
|
16
|
+
const s = n.find((e) => e.name === a);
|
|
17
|
+
s ? r.push({
|
|
18
|
+
alias: s.alias,
|
|
19
|
+
name: a,
|
|
20
|
+
label: a,
|
|
21
|
+
mapping: s.mapping
|
|
22
|
+
}) : r.push({
|
|
23
|
+
alias: a,
|
|
24
|
+
name: a,
|
|
25
|
+
label: a,
|
|
26
|
+
mapping: a
|
|
27
27
|
});
|
|
28
|
-
}),
|
|
28
|
+
}), r;
|
|
29
29
|
};
|
|
30
30
|
export {
|
|
31
|
-
|
|
31
|
+
f as dynamicMappingData,
|
|
32
|
+
u as mappingData
|
|
32
33
|
};
|
|
@@ -1,283 +1,137 @@
|
|
|
1
1
|
var f = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { cloneDeep as
|
|
5
|
-
import { SHJDatasourceV2 as
|
|
6
|
-
import { storageData as
|
|
2
|
+
var b = (l, a, e) => a in l ? f(l, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[a] = e;
|
|
3
|
+
var d = (l, a, e) => b(l, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
+
import { cloneDeep as g } from "lodash";
|
|
5
|
+
import { SHJDatasourceV2 as u } from "../index.mjs";
|
|
6
|
+
import { storageData as V } from "./storageData.mjs";
|
|
7
7
|
import "../../event/actions/fullScreenAction.mjs";
|
|
8
|
-
import { EventUtils as
|
|
9
|
-
const
|
|
10
|
-
static
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
continue;
|
|
20
|
-
const o = r.getNestedValue(
|
|
21
|
-
n._value,
|
|
22
|
-
i.substring(s.length)
|
|
23
|
-
);
|
|
24
|
-
e = e.replaceAll(a[t], o);
|
|
8
|
+
import { EventUtils as m } from "../../event/utils/utils.mjs";
|
|
9
|
+
const i = class i {
|
|
10
|
+
static executeAllVariable(a) {
|
|
11
|
+
a.forEach((e) => {
|
|
12
|
+
e.sources.isVariable = !0;
|
|
13
|
+
}), i.setVariables(a), a.forEach((e) => {
|
|
14
|
+
u.parse({
|
|
15
|
+
sources: [e.sources],
|
|
16
|
+
noUseMapping: !0,
|
|
17
|
+
callback: (t) => {
|
|
18
|
+
i.setVariableById(e, t, !1);
|
|
25
19
|
}
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return e;
|
|
29
|
-
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
30
22
|
}
|
|
31
|
-
static replaceObjectVariables(
|
|
32
|
-
const
|
|
33
|
-
return JSON.parse(
|
|
23
|
+
static replaceObjectVariables(a) {
|
|
24
|
+
const e = this.replaceStringVariables(JSON.stringify(a));
|
|
25
|
+
return JSON.parse(e);
|
|
34
26
|
}
|
|
35
|
-
static replaceStringVariables(
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
e = e.replaceAll(a[t], o);
|
|
27
|
+
static replaceStringVariables(a) {
|
|
28
|
+
return a.replace(/\$g\{([^}]+)\}/g, (e, t) => {
|
|
29
|
+
const { varName: r, propPath: n } = this.parseVariablePath(t), c = this.getVariables().find((o) => o.name === r);
|
|
30
|
+
if (!c)
|
|
31
|
+
return e;
|
|
32
|
+
let s = c._value;
|
|
33
|
+
try {
|
|
34
|
+
for (const o of n) {
|
|
35
|
+
if (s == null) {
|
|
36
|
+
s = void 0;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
s = s[o];
|
|
50
40
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return e;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
static getURLVariableNames(e) {
|
|
57
|
-
const a = [], t = e.match(/\${(.*?)}/g);
|
|
58
|
-
if (t)
|
|
59
|
-
for (let i = 0; i < t.length; i++) {
|
|
60
|
-
const s = t[i].substring(2, t[i].length - 1), n = r.extractVariableName(s);
|
|
61
|
-
a.push(n);
|
|
41
|
+
} catch {
|
|
42
|
+
return "undefined";
|
|
62
43
|
}
|
|
63
|
-
|
|
44
|
+
return typeof s == "object" ? JSON.stringify(s) : s === void 0 ? "undefined" : String(s);
|
|
45
|
+
});
|
|
64
46
|
}
|
|
65
|
-
static getObjectVariableNames(
|
|
66
|
-
return this.getStringVariableNames(JSON.stringify(
|
|
47
|
+
static getObjectVariableNames(a) {
|
|
48
|
+
return this.getStringVariableNames(JSON.stringify(a));
|
|
67
49
|
}
|
|
68
|
-
static getStringVariableNames(
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
static getStringVariableNames(a) {
|
|
51
|
+
const e = /* @__PURE__ */ new Set(), t = /\$g\{([^}]+)\}/g;
|
|
52
|
+
for (const r of a.matchAll(t)) {
|
|
53
|
+
const n = r[1], { varName: c } = this.parseVariablePath(n);
|
|
54
|
+
c && e.add(c);
|
|
55
|
+
}
|
|
56
|
+
return Array.from(e);
|
|
57
|
+
}
|
|
58
|
+
static parseVariablePath(a) {
|
|
59
|
+
const t = a.replace(/\[/g, ".").replace(/\]/g, "").split("."), r = t[0], n = t.slice(1);
|
|
60
|
+
return { varName: r, propPath: n };
|
|
76
61
|
}
|
|
77
|
-
/**
|
|
78
|
-
* 获取环境变量
|
|
79
|
-
* @returns 环境变量
|
|
80
|
-
*/
|
|
81
62
|
static getEnvironments() {
|
|
82
63
|
return window._apiEnvironment;
|
|
83
64
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const a = e.find((t) => t.selected);
|
|
90
|
-
a && (window._apiEnvironment = {
|
|
91
|
-
envName: a.envName,
|
|
92
|
-
envBaseUrl: a.envBaseUrl
|
|
65
|
+
static setEnvironments(a) {
|
|
66
|
+
const e = a.find((t) => t.selected);
|
|
67
|
+
e && (window._apiEnvironment = {
|
|
68
|
+
envName: e.envName,
|
|
69
|
+
envBaseUrl: e.envBaseUrl
|
|
93
70
|
});
|
|
94
71
|
}
|
|
95
|
-
/**
|
|
96
|
-
* 获取变量数据
|
|
97
|
-
* @returns 变量数据
|
|
98
|
-
*/
|
|
99
72
|
static getVariables() {
|
|
100
73
|
return window._variables || [];
|
|
101
74
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*/
|
|
106
|
-
static setVariables(e) {
|
|
107
|
-
window._variables = h(e), window._variables.forEach((a) => {
|
|
108
|
-
a._callbacks ?? (a._callbacks = /* @__PURE__ */ new Map());
|
|
75
|
+
static setVariables(a) {
|
|
76
|
+
window._variables = g(a), window._variables.forEach((e) => {
|
|
77
|
+
e._callbacks ?? (e._callbacks = /* @__PURE__ */ new Map());
|
|
109
78
|
});
|
|
110
79
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*/
|
|
116
|
-
static getVariableById(e) {
|
|
117
|
-
return window._variables.find((a) => a.id === e);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
121
|
-
* @param name
|
|
122
|
-
* @returns
|
|
123
|
-
*/
|
|
124
|
-
static getVariableByName(e) {
|
|
125
|
-
return window._variables.find((a) => a.name === e);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* @param name
|
|
130
|
-
* @returns
|
|
131
|
-
*/
|
|
132
|
-
static getVariableValueByName(e) {
|
|
133
|
-
const a = window._variables.find((t) => t.name === e);
|
|
134
|
-
return a ? a._value : null;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
*
|
|
138
|
-
* @param name
|
|
139
|
-
* @returns
|
|
140
|
-
*/
|
|
141
|
-
static getVariableInitialStateByName(e) {
|
|
142
|
-
const a = window._variables.find((t) => t.name === e);
|
|
143
|
-
return a ? a._initialState : null;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* 设置变量数据
|
|
147
|
-
* @param id 变量 ID
|
|
148
|
-
* @param variable 变量数据
|
|
149
|
-
*/
|
|
150
|
-
static setVariableById(e, a, t = !0) {
|
|
151
|
-
const i = this.getVariableById(e.id);
|
|
152
|
-
if (i) {
|
|
153
|
-
i._value = a, i._initialState ?? (i._initialState = !0);
|
|
80
|
+
static setVariableById(a, e, t = !0) {
|
|
81
|
+
const r = this.getVariableById(a.id);
|
|
82
|
+
if (r) {
|
|
83
|
+
r._value = e, r._initialState ?? (r._initialState = !0);
|
|
154
84
|
try {
|
|
155
|
-
|
|
85
|
+
V(a.sources.source.storage, e);
|
|
156
86
|
} catch {
|
|
157
87
|
}
|
|
158
|
-
|
|
159
|
-
(
|
|
160
|
-
), t &&
|
|
88
|
+
r._callbacks ?? (r._callbacks = /* @__PURE__ */ new Map()), r._callbacks.forEach(
|
|
89
|
+
(n) => n(a._value)
|
|
90
|
+
), t && m.updateWidgetVariableData(r);
|
|
161
91
|
}
|
|
162
92
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
* @param wsInstances WebSocket 实例
|
|
166
|
-
* @param tId WebSocket 实例的 ID
|
|
167
|
-
* @param sourceId WebSocket 实例的源 ID
|
|
168
|
-
* @returns 是否有效
|
|
169
|
-
*/
|
|
170
|
-
static hasValidWebSocket(e, a, t) {
|
|
171
|
-
const i = e.get(a);
|
|
172
|
-
if (!i) return !1;
|
|
173
|
-
for (const s of i)
|
|
174
|
-
if (s.getId() === t && s.isConnected())
|
|
175
|
-
return !0;
|
|
176
|
-
return !1;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* 只在必要时清理 WebSocket 连接
|
|
180
|
-
* @param wsInstances WebSocket 实例
|
|
181
|
-
* @param sourceIds 源 ID
|
|
182
|
-
* @param tId WebSocket 实例的 ID
|
|
183
|
-
*/
|
|
184
|
-
static cleanupPreviousWebSockets(e, a, t) {
|
|
185
|
-
const i = e.get(t);
|
|
186
|
-
i && (i.forEach((s) => {
|
|
187
|
-
a.includes(s.getId()) || (s.disconnect(), i.delete(s));
|
|
188
|
-
}), i.size === 0 && e.delete(t));
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* 使用 Function 构造函数获取对象中的嵌套值(更简洁但安全性较低)
|
|
192
|
-
* @param obj 源对象
|
|
193
|
-
* @param path 路径字符串,例如 ".a[0].value"
|
|
194
|
-
* @returns 获取到的值,如果路径不存在则返回 undefined
|
|
195
|
-
*/
|
|
196
|
-
static getNestedValue(e, a) {
|
|
197
|
-
try {
|
|
198
|
-
return a ? new Function("obj", `return obj${a}`)(e) : e;
|
|
199
|
-
} catch {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
93
|
+
static getVariableById(a) {
|
|
94
|
+
return window._variables.find((e) => e.id === a);
|
|
202
95
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
* @param path 路径字符串,例如 "测试.test" 或 "333[0].aa"
|
|
206
|
-
* @returns 提取出的变量名
|
|
207
|
-
*/
|
|
208
|
-
static extractVariableName(e) {
|
|
209
|
-
const a = e.match(
|
|
210
|
-
/^([\u4e00-\u9fa5a-zA-Z0-9_][\u4e00-\u9fa5a-zA-Z0-9_]*)/
|
|
211
|
-
);
|
|
212
|
-
return a ? a[1] : "";
|
|
96
|
+
static getVariableByName(a) {
|
|
97
|
+
return window._variables.find((e) => e.name === a);
|
|
213
98
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
* @returns
|
|
218
|
-
*/
|
|
219
|
-
static executeAllVariable(e) {
|
|
220
|
-
e.forEach((a) => {
|
|
221
|
-
a.sources.isVariable = !0;
|
|
222
|
-
}), r.setVariables(e), e.forEach((a) => {
|
|
223
|
-
b.parse({
|
|
224
|
-
sources: [a.sources],
|
|
225
|
-
noUseMapping: !0,
|
|
226
|
-
callback: (t) => {
|
|
227
|
-
r.setVariableById(a, t, !1);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
99
|
+
static getVariableValueByName(a) {
|
|
100
|
+
const e = window._variables.find((t) => t.name === a);
|
|
101
|
+
return e ? e._value : null;
|
|
231
102
|
}
|
|
232
|
-
|
|
233
|
-
* 返回空数据
|
|
234
|
-
* @param id 数据源 ID
|
|
235
|
-
* @returns 空数据
|
|
236
|
-
*/
|
|
237
|
-
static noneData(e) {
|
|
103
|
+
static noneData(a) {
|
|
238
104
|
return {
|
|
239
|
-
id:
|
|
240
|
-
finalKeyData: { id:
|
|
241
|
-
finalUserData: { id:
|
|
105
|
+
id: a,
|
|
106
|
+
finalKeyData: { id: a, data: null },
|
|
107
|
+
finalUserData: { id: a, data: null },
|
|
242
108
|
filteredData: null,
|
|
243
109
|
rawData: null,
|
|
244
110
|
noMappingData: null
|
|
245
111
|
};
|
|
246
112
|
}
|
|
247
113
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
*/
|
|
252
|
-
c(r, "addVariable", (e) => {
|
|
253
|
-
b.parse({
|
|
254
|
-
sources: [e.sources],
|
|
114
|
+
d(i, "addVariable", (a) => {
|
|
115
|
+
u.parse({
|
|
116
|
+
sources: [a.sources],
|
|
255
117
|
noUseMapping: !0,
|
|
256
|
-
callback: (
|
|
257
|
-
|
|
118
|
+
callback: (e) => {
|
|
119
|
+
i.getVariables().push(a), i.setVariableById(a, e, !1);
|
|
258
120
|
}
|
|
259
121
|
});
|
|
260
|
-
}),
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
*/
|
|
264
|
-
c(r, "updateVariable", (e) => {
|
|
265
|
-
b.parse({
|
|
266
|
-
sources: [e.sources],
|
|
122
|
+
}), d(i, "updateVariable", (a) => {
|
|
123
|
+
u.parse({
|
|
124
|
+
sources: [a.sources],
|
|
267
125
|
noUseMapping: !0,
|
|
268
|
-
callback: (
|
|
269
|
-
|
|
126
|
+
callback: (e) => {
|
|
127
|
+
i.setVariableById(a, e, !1);
|
|
270
128
|
}
|
|
271
129
|
});
|
|
272
|
-
}),
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*/
|
|
276
|
-
c(r, "deleteVariableById", (e) => {
|
|
277
|
-
const a = window._variables.findIndex((t) => t.id === e);
|
|
278
|
-
a > -1 && window._variables.splice(a, 1);
|
|
130
|
+
}), d(i, "deleteVariableById", (a) => {
|
|
131
|
+
const e = window._variables.findIndex((t) => t.id === a);
|
|
132
|
+
e > -1 && window._variables.splice(e, 1);
|
|
279
133
|
});
|
|
280
|
-
let
|
|
134
|
+
let p = i;
|
|
281
135
|
export {
|
|
282
|
-
|
|
136
|
+
p as DataSourceUtils
|
|
283
137
|
};
|
|
@@ -2,7 +2,7 @@ import o from "./index.vue2.mjs";
|
|
|
2
2
|
/* empty css */
|
|
3
3
|
/* empty css */
|
|
4
4
|
import t from "../../../../_virtual/_plugin-vue_export-helper.mjs";
|
|
5
|
-
const
|
|
5
|
+
const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-673277b1"]]);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
a as default
|
|
8
8
|
};
|