@shjjs/visual-ui 1.0.36 → 1.0.37
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/core/earth/main.vue.d.ts +2 -2
- package/es/commons/core/useChart.mjs +257 -73
- package/es/components/chart/commons/components/common-chart/index.vue.mjs +213 -30
- package/es/components/chart/commons/components/common-chart-map/index.vue.mjs +210 -27
- package/es/components/chart/commons/hooks/useChart.mjs +261 -77
- package/es/components/chart/src/map/bmap-basic/index.vue.d.ts +8 -8
- package/es/components/chart/src/map/bmap-heatmap/index.vue.d.ts +6 -2
- package/es/components/chart-other-candlestick-basic/index.vue.mjs +212 -29
- package/es/components/chart-other-candlestick-demo/index.vue.mjs +213 -30
- package/es/components/chart-other-candlestick-shanghai/index.vue.mjs +214 -31
- package/es/components/chart-other-circular-graph/index.vue.mjs +214 -31
- package/es/components/chart-other-force/index.vue.mjs +212 -29
- package/es/components/chart-other-force2/index.vue.mjs +212 -29
- package/es/components/chart-other-funnel/index.vue.mjs +214 -31
- package/es/components/chart-other-funnel-contrast/index.vue.mjs +214 -31
- package/es/components/chart-other-funnel-split/index.vue.mjs +214 -31
- package/es/components/chart-other-funnel2/index.vue.mjs +214 -31
- package/es/components/chart-other-gauge/index.vue.mjs +214 -31
- package/es/components/chart-other-gauge-grade/index.vue.mjs +214 -31
- package/es/components/chart-other-gauge-stage/index.vue.mjs +214 -31
- package/es/components/chart-other-graph-basic/index.vue.mjs +214 -31
- package/es/components/chart-other-graph-basic2/index.vue.mjs +214 -31
- package/es/components/chart-other-graph-calendar/index.vue.mjs +214 -31
- package/es/components/chart-other-grid-percentage/index.vue.mjs +218 -35
- package/es/components/chart-other-heatmap/index.vue.mjs +212 -29
- package/es/components/chart-other-label-gauge/index.vue.mjs +216 -33
- package/es/components/chart-other-liquidfill/index.vue.mjs +214 -31
- package/es/components/chart-other-parallel-basic/index.vue.mjs +214 -31
- package/es/components/chart-other-parallel-mul/index.vue.mjs +211 -28
- package/es/components/chart-other-radar/index.vue.mjs +224 -41
- package/es/components/chart-other-radar-stack/index.vue.mjs +211 -28
- package/es/components/chart-other-sunburst-basic/index.vue.mjs +212 -29
- package/es/components/chart-other-sunburst-basic2/index.vue.mjs +212 -29
- package/es/components/chart-other-sunburst-basic3/index.vue.mjs +212 -29
- package/es/components/chart-other-sunburst-basic4/index.vue.mjs +212 -29
- package/es/components/chart-other-sunburst-book/index.vue.mjs +212 -29
- package/es/components/chart-other-sunburst-flavors/index.vue.mjs +214 -31
- package/es/components/chart-other-sunburst-radius/index.vue.mjs +212 -29
- package/es/components/chart-other-theme-river/index.vue.mjs +216 -33
- package/es/components/chart-other-tree/index.vue.mjs +214 -31
- package/es/components/chart-other-tree-line/index.vue.mjs +214 -31
- package/es/components/chart-other-treemap/index.vue.mjs +214 -31
- package/es/components/chart-other-treemap-basic/index.vue.mjs +214 -31
- package/es/components/chart-other-word-cloud/index.vue.mjs +216 -33
- package/es/components/commons-echarts/compileAndRunEcharts.mjs +219 -35
- package/es/components/commons-loop-iterator/index.vue.mjs +1 -1
- package/es/components/commons-loop-iterator/index.vue2.mjs +218 -35
- package/es/components/commons-product-model/index.vue.mjs +2 -2
- package/es/components/commons-product-model/index.vue2.mjs +246 -62
- package/es/components/commons-three-loader/index.vue.mjs +2 -2
- package/es/components/commons-three-loader/index.vue2.mjs +257 -73
- package/es/components/commons-three-loader3/index.vue.mjs +2 -2
- package/es/components/commons-three-loader3/index.vue2.mjs +301 -117
- package/es/components/commons-weather/index.vue.mjs +1 -1
- package/es/components/commons-weather/index.vue2.mjs +233 -48
- package/es/components/commons-weather-dynamic/index.vue.mjs +2 -2
- package/es/components/commons-weather-dynamic/index.vue2.mjs +236 -52
- package/es/components/interaction/button/index.vue.mjs +2 -2
- package/es/components/interaction/button/index.vue2.mjs +252 -68
- package/es/components/interaction/date-picker/components/common-date-picker/index.vue.mjs +1 -1
- package/es/components/interaction/date-picker/components/common-date-picker/index.vue2.mjs +324 -140
- package/es/components/interaction/tabs/index.vue.mjs +223 -39
- package/es/components/interaction/tabs-icon/index.vue.mjs +225 -41
- package/es/components/interaction-input/index.vue.mjs +1 -1
- package/es/components/interaction-input/index.vue2.mjs +244 -61
- package/es/components/interaction-select/index.vue.mjs +1 -1
- package/es/components/interaction-select/index.vue2.mjs +269 -86
- package/es/components/interaction-slider/index.vue.mjs +2 -2
- package/es/components/interaction-slider/index.vue2.mjs +248 -65
- package/es/components/interaction-switch/index.vue.mjs +1 -1
- package/es/components/interaction-switch/index.vue2.mjs +217 -33
- package/es/components/interaction-tabs/index.vue.mjs +1 -1
- package/es/components/interaction-tabs/index.vue2.mjs +221 -37
- package/es/components/interaction-tabs2/index.vue.mjs +2 -2
- package/es/components/interaction-tabs2/index.vue2.mjs +219 -35
- package/es/components/map-earth-basic/index.d.ts +2 -2
- package/es/components/map-earth-basic/index.vue.d.ts +2 -2
- package/es/components/map-earth-basic/index.vue.mjs +286 -103
- package/es/components/map-earth-cool-tech/index.d.ts +2 -2
- package/es/components/map-earth-cool-tech/index.vue.d.ts +4 -6
- package/es/components/map-earth-cool-tech/index.vue.mjs +286 -103
- package/es/components/map-earth-fly-line/index.d.ts +2 -2
- package/es/components/map-earth-fly-line/index.vue.d.ts +2 -2
- package/es/components/map-earth-fly-line/index.vue.mjs +286 -103
- package/es/components/map-earth-hacker/index.d.ts +2 -2
- package/es/components/map-earth-hacker/index.vue.d.ts +2 -2
- package/es/components/map-earth-hacker/index.vue.mjs +286 -103
- package/es/components/map-earth-particle/index.d.ts +2 -2
- package/es/components/map-earth-particle/index.vue.d.ts +2 -2
- package/es/components/map-earth-particle/index.vue.mjs +286 -103
- package/es/components/media-audio/index.vue.mjs +2 -2
- package/es/components/media-audio/index.vue2.mjs +220 -36
- package/es/components/media-audio-dynamic/index.vue.mjs +1 -1
- package/es/components/media-audio-dynamic/index.vue2.mjs +226 -43
- package/es/components/media-flv/index.vue.mjs +219 -35
- package/es/components/media-iframe/index.vue.mjs +2 -2
- package/es/components/media-iframe/index.vue2.mjs +199 -15
- package/es/components/media-iframe-dynamic/index.vue.mjs +2 -2
- package/es/components/media-iframe-dynamic/index.vue2.mjs +219 -36
- package/es/components/media-image-dynamic/index.vue.mjs +1 -1
- package/es/components/media-image-dynamic/index.vue2.mjs +207 -24
- package/es/components/media-m3u8/index.vue.mjs +221 -37
- package/es/components/media-m3u8-dynamic/index.vue.mjs +228 -45
- package/es/components/media-video/index.vue.mjs +1 -1
- package/es/components/media-video/index.vue2.mjs +216 -31
- package/es/components/media-video-dynamic/index.vue.mjs +1 -1
- package/es/components/media-video-dynamic/index.vue2.mjs +223 -40
- package/es/components/scene-amap2d/index.vue.mjs +2 -2
- package/es/components/scene-amap2d/index.vue2.mjs +376 -192
- package/es/components/scene-amap3d/index.vue.mjs +2 -2
- package/es/components/scene-amap3d/index.vue2.mjs +414 -231
- package/es/components/scene-default/index.vue.mjs +2 -2
- package/es/components/scene-default/index.vue2.mjs +201 -16
- package/es/components/scene-map3d/index.vue.mjs +2 -2
- package/es/components/scene-map3d/index.vue2.mjs +289 -106
- package/es/components/scene-ue-iframe/index.vue.mjs +1 -1
- package/es/components/scene-ue-iframe/index.vue2.mjs +212 -27
- package/es/components/scene-ue-shj/index.vue.mjs +2 -2
- package/es/components/scene-ue-shj/index.vue2.mjs +200 -15
- package/es/components/scene-unity-iframe/index.vue.mjs +1 -1
- package/es/components/scene-unity-iframe/index.vue2.mjs +204 -19
- package/es/components/scene-unity-webgl/index.vue.mjs +2 -2
- package/es/components/scene-unity-webgl/index.vue2.mjs +204 -19
- package/es/components/scene-vr/index.vue.mjs +2 -2
- package/es/components/scene-vr/index.vue2.mjs +307 -123
- package/es/components/text/list/index.vue.mjs +240 -56
- package/es/components/text-count-down/index.vue.mjs +2 -2
- package/es/components/text-count-down/index.vue2.mjs +245 -60
- package/es/components/text-over-number/index.vue.mjs +2 -2
- package/es/components/text-over-number/index.vue2.mjs +243 -60
- package/es/components/text-real-time/index.vue.mjs +1 -1
- package/es/components/text-real-time/index.vue2.mjs +212 -28
- package/es/components/text-row-scroll/index.vue.mjs +2 -2
- package/es/components/text-row-scroll/index.vue2.mjs +289 -106
- package/es/components/text-table-basic/index.vue.mjs +2 -2
- package/es/components/text-table-basic/index.vue2.mjs +286 -103
- package/es/components/text-table-scroll/index.vue.mjs +1 -1
- package/es/components/text-table-scroll/index.vue2.mjs +291 -108
- package/es/components/text-text-dynamic/index.vue.mjs +2 -2
- package/es/components/text-text-dynamic/index.vue2.mjs +218 -35
- package/es/index.d.ts +1 -0
- package/es/index.mjs +375 -361
- package/es/plugins/datasource/index.mjs +217 -0
- package/es/plugins/datasource/sources/api.mjs +32 -0
- package/es/plugins/datasource/sources/static.mjs +17 -0
- package/es/plugins/datasource/sources/storage.mjs +28 -0
- package/es/plugins/datasource/sources/url.mjs +17 -0
- package/es/plugins/datasource/sources/variable.mjs +17 -0
- package/es/plugins/datasource/sources/ws.mjs +139 -0
- package/es/plugins/datasource/utils/axios.mjs +134 -0
- package/es/plugins/datasource/utils/request.mjs +5 -0
- package/es/plugins/datasource/utils/utils.mjs +229 -0
- package/es/plugins/datasource/utils/wsManager.mjs +78 -0
- package/es/plugins/event/actions/fullScreenAction.mjs +8 -0
- package/es/plugins/event/actions/invokeAction.mjs +11 -0
- package/es/plugins/event/actions/linkAction.mjs +8 -0
- package/es/plugins/event/actions/moveAction.mjs +15 -0
- package/es/plugins/event/actions/refreshVariableAction.mjs +18 -0
- package/es/plugins/event/actions/rotateAction.mjs +19 -0
- package/es/plugins/event/actions/scaleAction.mjs +24 -0
- package/es/plugins/event/actions/sendApiAction.mjs +16 -0
- package/es/plugins/event/actions/ueCommonsWebscoketAction.mjs +31 -0
- package/es/plugins/event/actions/ueShjExecMethodAction.mjs +31 -0
- package/es/plugins/event/actions/unityIframeExecMethodAction.mjs +28 -0
- package/es/plugins/event/actions/unityWebglExecMethodAction.mjs +28 -0
- package/es/plugins/event/actions/updatePageAction.mjs +6 -0
- package/es/plugins/event/actions/updateVariableAction.mjs +25 -0
- package/es/plugins/event/actions/updateWidgetAction.mjs +14 -0
- package/es/plugins/event/actions/vrSceneMethodAction.mjs +12 -0
- package/es/plugins/event/index.mjs +161 -0
- package/es/plugins/event/utils/utils.mjs +50 -0
- package/es/plugins/utils/componentRefs.mjs +37 -0
- package/es/plugins/utils/getNextElement.mjs +12 -0
- package/es/widgets.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var U = (w, t, a) => t in w ? A(w, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : w[t] = a;
|
|
3
|
+
var I = (w, t, a) => U(w, typeof t != "symbol" ? t + "" : t, a);
|
|
4
|
+
import { isArray as F, isString as b, cloneDeep as P } from "lodash";
|
|
5
|
+
import { parseStaticData as j } from "./sources/static.mjs";
|
|
6
|
+
import { parseUrlData as E } from "./sources/url.mjs";
|
|
7
|
+
import { parseVariableData as M } from "./sources/variable.mjs";
|
|
8
|
+
import { parseAPIPort as W } from "./sources/api.mjs";
|
|
9
|
+
import { parseWebSocket as $ } from "./sources/ws.mjs";
|
|
10
|
+
import { DataSourceUtils as T } from "./utils/utils.mjs";
|
|
11
|
+
import { parseStorage as N } from "./sources/storage.mjs";
|
|
12
|
+
import { wsManager as X } from "./utils/wsManager.mjs";
|
|
13
|
+
const D = class D {
|
|
14
|
+
static addParser(t, a) {
|
|
15
|
+
this.parsers.add({ type: t, parser: a });
|
|
16
|
+
}
|
|
17
|
+
static getParser(t) {
|
|
18
|
+
const a = Array.from(this.parsers).find((e) => e.type === t);
|
|
19
|
+
return a == null ? void 0 : a.parser;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 解析数据源
|
|
23
|
+
* @param sources 数据源
|
|
24
|
+
* @param callback 回调函数
|
|
25
|
+
* @param tId 组件id
|
|
26
|
+
* @param isStore 是否存储
|
|
27
|
+
* @param noUseMapping 是否不使用映射
|
|
28
|
+
* @param isInterval 是否开启定时任务
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
static parse({ sources: t, callback: a, tId: e, isStore: s = !1, noUseMapping: i = !1, isInterval: n = !0 }) {
|
|
32
|
+
return a ?? (a = () => {
|
|
33
|
+
}), t && F(t) && t.length > 0 && t[0] ? new Promise((p, o) => {
|
|
34
|
+
T.cleanupPreviousWebSockets(this.wsInstances, t.map((r) => r.id), e);
|
|
35
|
+
const h = /* @__PURE__ */ new Set(), l = this.wsInstances.get(e) || /* @__PURE__ */ new Set();
|
|
36
|
+
t.forEach((r) => {
|
|
37
|
+
var u;
|
|
38
|
+
if (n) {
|
|
39
|
+
const { source: f } = r;
|
|
40
|
+
if (!f) {
|
|
41
|
+
a([]), p([]);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const m = `${e}-${r.id}`, d = this.datasourceTimer.findIndex((S) => S.id === m);
|
|
45
|
+
if (d !== -1 && (clearInterval(this.datasourceTimer[d].timer), this.datasourceTimer.splice(d, 1)), f.isAutoUpdate) {
|
|
46
|
+
const S = setInterval(() => {
|
|
47
|
+
var g;
|
|
48
|
+
(g = this.task(r, s, i, e, (c) => {
|
|
49
|
+
a(c);
|
|
50
|
+
})) == null || g.then((c) => {
|
|
51
|
+
p(c);
|
|
52
|
+
});
|
|
53
|
+
}, f.autoUpdateTime * 1e3);
|
|
54
|
+
this.datasourceTimer.push({ id: m, timer: S });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (r.source.type !== "ws") {
|
|
58
|
+
(u = this.task(r, s, i, e, (f) => a(f))) == null || u.then((f) => p(f));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (T.hasValidWebSocket(this.wsInstances, e, r.id))
|
|
62
|
+
l.forEach((f) => {
|
|
63
|
+
f.getId() === r.id && h.add(f);
|
|
64
|
+
});
|
|
65
|
+
else {
|
|
66
|
+
const f = $(r, r.id, i, e, (m) => {
|
|
67
|
+
p(m), a({ data: [{ data: m.finalUserData.data }] }), this.taskStorage(t, m.finalUserData.data);
|
|
68
|
+
});
|
|
69
|
+
h.add(f);
|
|
70
|
+
}
|
|
71
|
+
}), h.size > 0 && this.wsInstances.set(e, h);
|
|
72
|
+
}) : (a([]), Promise.resolve([]));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 执行数据源任务
|
|
76
|
+
* @param sources 数据源
|
|
77
|
+
* @param isStore 是否存储
|
|
78
|
+
* @param noUseMapping 是否不使用映射
|
|
79
|
+
* @param tId 组件id
|
|
80
|
+
* @param callback 回调函数
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
static task(t, a = !1, e = !1, s, i = () => {
|
|
84
|
+
}) {
|
|
85
|
+
return t ? new Promise((n, p) => {
|
|
86
|
+
let o = null;
|
|
87
|
+
const { source: h } = t, l = this.getParser(h.type);
|
|
88
|
+
l && (o = l(t, t.id, e)), o.then((r) => {
|
|
89
|
+
n(r), e && (this.taskStorage(t, r.noMappingData), i(r.noMappingData)), e || (this.taskStorage(t, r.finalKeyData), i(r.finalKeyData));
|
|
90
|
+
});
|
|
91
|
+
}) : (i([]), Promise.resolve([]));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 过滤数据
|
|
95
|
+
* @param filter 过滤器
|
|
96
|
+
* @param data 数据
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
static filterData(t, a) {
|
|
100
|
+
return new Promise((e, s) => {
|
|
101
|
+
if (b(t)) {
|
|
102
|
+
try {
|
|
103
|
+
const i = T.getVariableData();
|
|
104
|
+
let n = `
|
|
105
|
+
${t}
|
|
106
|
+
|
|
107
|
+
// 在这里调用 filter 函数,并传递 data 参数
|
|
108
|
+
return filter(data);
|
|
109
|
+
`;
|
|
110
|
+
n = n.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, ""), n = T.replaceStringVariables(n, i);
|
|
111
|
+
const p = new Function("data", n);
|
|
112
|
+
e(p(a));
|
|
113
|
+
} catch {
|
|
114
|
+
e(a);
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
e(a);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 处理数据
|
|
123
|
+
* @param filter 过滤器
|
|
124
|
+
* @param data 数据
|
|
125
|
+
* @param mappings 映射
|
|
126
|
+
* @param id 组件id
|
|
127
|
+
* @param dynamicMapping 是否动态映射
|
|
128
|
+
* @param noUseMapping 是否不使用映射
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
static processData(t, a, e, s, i, n, p) {
|
|
132
|
+
return new Promise(function(o) {
|
|
133
|
+
const h = P({ id: s, data: a });
|
|
134
|
+
D.filterData(t, a).then((l) => {
|
|
135
|
+
const r = P({ id: s, data: l });
|
|
136
|
+
if (n)
|
|
137
|
+
o({
|
|
138
|
+
id: s,
|
|
139
|
+
finalKeyData: [],
|
|
140
|
+
finalUserData: { id: s, data: l },
|
|
141
|
+
filteredData: r,
|
|
142
|
+
rawData: h,
|
|
143
|
+
noMappingData: l
|
|
144
|
+
});
|
|
145
|
+
else {
|
|
146
|
+
let u = [];
|
|
147
|
+
F(l) && (u = l.map((d, S) => {
|
|
148
|
+
const g = {};
|
|
149
|
+
if (i && i && S === 0) {
|
|
150
|
+
const c = [];
|
|
151
|
+
for (const y in d) {
|
|
152
|
+
const k = e.find((K) => K.name === y);
|
|
153
|
+
k ? c.push({ alias: k.alias, name: y, type: "any", label: y, mapping: k.mapping, status: !0 }) : c.push({ alias: y, name: y, type: "any", label: y, mapping: y, status: !0 });
|
|
154
|
+
}
|
|
155
|
+
e.splice(0, e.length), e.push(...c);
|
|
156
|
+
}
|
|
157
|
+
return e.forEach((c) => {
|
|
158
|
+
try {
|
|
159
|
+
c.alias ? g[c.alias] = d[c.mapping] : g[c.name] = d[c.mapping];
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
162
|
+
}), p && (g.userdata = d), g;
|
|
163
|
+
}));
|
|
164
|
+
const f = P({ id: s, data: u }), m = P({ id: s, data: D.parseMappedData(u, e, s) });
|
|
165
|
+
o({
|
|
166
|
+
id: s,
|
|
167
|
+
finalKeyData: u.length === 0 ? { id: s, data: l } : m,
|
|
168
|
+
finalUserData: u.length === 0 ? { id: s, data: l } : f,
|
|
169
|
+
filteredData: r,
|
|
170
|
+
rawData: h,
|
|
171
|
+
noMappingData: []
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 解析数据为Key、Data格式
|
|
179
|
+
* @param data 数据
|
|
180
|
+
* @param mappings 映射
|
|
181
|
+
* @param id 组件id
|
|
182
|
+
* @returns
|
|
183
|
+
*/
|
|
184
|
+
static parseMappedData(t, a, e) {
|
|
185
|
+
return t.reduce(
|
|
186
|
+
(s, i) => {
|
|
187
|
+
let n = "系列一";
|
|
188
|
+
a && a.find((o) => o.name === "series") && (n = i[a.find((o) => o.name === "series").name], delete i[a.find((o) => o.name === "series").name]);
|
|
189
|
+
const p = s.find((o) => o.key === n);
|
|
190
|
+
return p ? p.data.push(i) : s.push({ key: n, data: [i] }), s;
|
|
191
|
+
},
|
|
192
|
+
[]
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 处理数据存储
|
|
197
|
+
* @param sources 数据源
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
200
|
+
static taskStorage(t, a) {
|
|
201
|
+
const { source: e } = t;
|
|
202
|
+
e.storage && e.storage.setField && e.storage.setType !== 0 && (e.storage.setType === 1 && localStorage.setItem("Local_" + e.storage.setField, JSON.stringify(a)), e.storage.setType === 2 && sessionStorage.setItem("Session_" + e.storage.setField, JSON.stringify(a)));
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
I(D, "wsInstances", /* @__PURE__ */ new Map()), I(D, "datasourceTimer", []), I(D, "parsers", /* @__PURE__ */ new Set([
|
|
206
|
+
{ type: "url", parser: E },
|
|
207
|
+
{ type: "static", parser: j },
|
|
208
|
+
{ type: "variable", parser: M },
|
|
209
|
+
{ type: "api", parser: W },
|
|
210
|
+
{ type: "storage", parser: N }
|
|
211
|
+
]));
|
|
212
|
+
let x = D;
|
|
213
|
+
export {
|
|
214
|
+
T as DataSourceUtils,
|
|
215
|
+
x as SHJDatasourceV2,
|
|
216
|
+
X as wsManager
|
|
217
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SHJDatasourceV2 as U } from "../index.mjs";
|
|
2
|
+
import { httpRequest as p } from "../utils/request.mjs";
|
|
3
|
+
import { DataSourceUtils as t } from "../utils/utils.mjs";
|
|
4
|
+
const q = (f, e, y) => new Promise(function(r, j) {
|
|
5
|
+
const { api: n } = f.source;
|
|
6
|
+
try {
|
|
7
|
+
if (n) {
|
|
8
|
+
let { isHeaders: m, isBody: h, headers: c, contentType: u, url: a, postParam: o } = n;
|
|
9
|
+
const E = t.getEnvironments(), l = t.getVariableData(), i = (P) => {
|
|
10
|
+
P.then((D) => {
|
|
11
|
+
if (D.status === 200) {
|
|
12
|
+
const { filter: V, mapping: g, isUserdata: T } = f.source;
|
|
13
|
+
U.processData(V, D.data, g, e, f.source.dynamicMapping, y, T).then((b) => {
|
|
14
|
+
b && r(b);
|
|
15
|
+
}).catch(() => r(t.noneData(e)));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
r(t.noneData(e));
|
|
19
|
+
}).catch(() => {
|
|
20
|
+
r(t.noneData(e));
|
|
21
|
+
});
|
|
22
|
+
}, s = t.replaceEnvVariables(a, E);
|
|
23
|
+
a = t.replaceURLVariables(a, l), h && (o = t.replaceObjectVariables(o, l)), m && (c = t.replaceObjectVariables(c, l)), n.type === "GET" && i(p.get(s + a, { headers: c })), n.type === "POST" && i(p.post(s + a, o, { headers: c }, u)), n.type === "PUT" && i(p.put(s + a, o, { headers: c }, u)), n.type === "DELETE" && i(p.delete(s + a, { headers: c }));
|
|
24
|
+
} else
|
|
25
|
+
r(t.noneData(e));
|
|
26
|
+
} catch {
|
|
27
|
+
r(t.noneData(e));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export {
|
|
31
|
+
q as parseAPIPort
|
|
32
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SHJDatasourceV2 as s } from "../index.mjs";
|
|
2
|
+
import { DataSourceUtils as t } from "../utils/utils.mjs";
|
|
3
|
+
const u = (a, e, c) => new Promise(function(r, p) {
|
|
4
|
+
if (a.source.static !== void 0) {
|
|
5
|
+
const i = t.getVariableData(), n = t.replaceObjectVariables(a.source.static, i);
|
|
6
|
+
s.processData(a.source.filter, n, a.source.mapping, e, a.source.dynamicMapping, c, a.source.isUserdata).then((o) => {
|
|
7
|
+
r(o);
|
|
8
|
+
}).catch(() => {
|
|
9
|
+
r(t.noneData(e));
|
|
10
|
+
});
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
r(t.noneData(e));
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
u as parseStaticData
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SHJDatasourceV2 as m } from "../index.mjs";
|
|
2
|
+
import { DataSourceUtils as n } from "../utils/utils.mjs";
|
|
3
|
+
const l = (e, t, c) => new Promise(function(a, u) {
|
|
4
|
+
if (!e.source.storage) {
|
|
5
|
+
a(n.noneData(t));
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const { getType: o, getField: r } = e.source.storage;
|
|
9
|
+
if (o === 0) {
|
|
10
|
+
a(n.noneData(t));
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!r) {
|
|
14
|
+
a(n.noneData(t));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let s = null;
|
|
18
|
+
o === 1 && (s = localStorage.getItem("Local_" + r)), o === 2 && (s = sessionStorage.getItem("Session_" + r));
|
|
19
|
+
const { filter: i, mapping: g, isUserdata: p } = e.source;
|
|
20
|
+
m.processData(i, s, g, t, e.source.dynamicMapping, c, p).then((f) => {
|
|
21
|
+
a(f);
|
|
22
|
+
}).catch(() => {
|
|
23
|
+
a(n.noneData(t));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
l as parseStorage
|
|
28
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SHJDatasourceV2 as i } from "../index.mjs";
|
|
2
|
+
import { DataSourceUtils as n } from "../utils/utils.mjs";
|
|
3
|
+
const f = (a, t, c) => new Promise(function(r, m) {
|
|
4
|
+
const o = new URLSearchParams(window.location.search), e = Object.fromEntries(o.entries());
|
|
5
|
+
if (Object.keys(e).length > 0) {
|
|
6
|
+
i.processData(a.source.filter, e, a.source.mapping, t, a.source.dynamicMapping, c, a.source.isUserdata).then((s) => {
|
|
7
|
+
r(s);
|
|
8
|
+
}).catch(() => {
|
|
9
|
+
r(n.noneData(t));
|
|
10
|
+
});
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
r(n.noneData(t));
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
f as parseUrlData
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SHJDatasourceV2 as c } from "../index.mjs";
|
|
2
|
+
import { DataSourceUtils as n } from "../utils/utils.mjs";
|
|
3
|
+
const m = (a, r, o) => new Promise(function(e, s) {
|
|
4
|
+
const i = n.getVariableData().find((t) => t.id === a.source.variableId || t.name === a.source.variableId);
|
|
5
|
+
if (!i) {
|
|
6
|
+
e(n.noneData(r));
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
c.processData(a.source.filter, i._value, a.source.mapping, r, a.source.dynamicMapping, o, a.source.isUserdata).then((t) => {
|
|
10
|
+
e(t);
|
|
11
|
+
}).catch(() => {
|
|
12
|
+
e(n.noneData(r));
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
m as parseVariableData
|
|
17
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var g = (c, t, e) => t in c ? p(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
|
+
var d = (c, t, e) => g(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { SHJDatasourceV2 as f } from "../index.mjs";
|
|
5
|
+
import { wsManager as u } from "../utils/wsManager.mjs";
|
|
6
|
+
import { DataSourceUtils as l } from "../utils/utils.mjs";
|
|
7
|
+
class w {
|
|
8
|
+
constructor(t, e, s, i, n, o) {
|
|
9
|
+
d(this, "ws", null);
|
|
10
|
+
d(this, "reconnectAttempts", 0);
|
|
11
|
+
d(this, "timeoutTimer");
|
|
12
|
+
d(this, "isDisconnecting", !1);
|
|
13
|
+
d(this, "config");
|
|
14
|
+
this.source = t, this.id = e, this.noUseMapping = s, this.tId = i, this.onData = n, this.onEvent = o;
|
|
15
|
+
const { websocket: r } = t.source;
|
|
16
|
+
if (!r) {
|
|
17
|
+
n == null || n(l.noneData(e)), this.config = {
|
|
18
|
+
url: "",
|
|
19
|
+
reconnect: !1,
|
|
20
|
+
timeout: 3e4
|
|
21
|
+
};
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.config = r, this.connect();
|
|
25
|
+
}
|
|
26
|
+
// 新增:获取连接ID
|
|
27
|
+
getId() {
|
|
28
|
+
return this.id;
|
|
29
|
+
}
|
|
30
|
+
// 新增:检查连接是否有效
|
|
31
|
+
isConnected() {
|
|
32
|
+
return this.ws !== null && this.ws.readyState === WebSocket.OPEN;
|
|
33
|
+
}
|
|
34
|
+
processProtocols() {
|
|
35
|
+
const { protocols: t = "" } = this.config;
|
|
36
|
+
return t ? Array.isArray(t) ? t : t.split(/\s*,\s*/) : [];
|
|
37
|
+
}
|
|
38
|
+
injectHeadersToUrl(t) {
|
|
39
|
+
try {
|
|
40
|
+
const e = new URL(t);
|
|
41
|
+
return Object.entries(this.config.headers || {}).forEach(([s, i]) => {
|
|
42
|
+
e.searchParams.append(s, i);
|
|
43
|
+
}), e.toString();
|
|
44
|
+
} catch {
|
|
45
|
+
return t;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
connect() {
|
|
49
|
+
var r, h;
|
|
50
|
+
if (this.isDisconnecting) return;
|
|
51
|
+
const {
|
|
52
|
+
url: t,
|
|
53
|
+
isHeaders: e = !1,
|
|
54
|
+
binaryType: s = "blob",
|
|
55
|
+
timeout: i = 3e4
|
|
56
|
+
} = this.config, n = e ? this.injectHeadersToUrl(t) : t, o = this.processProtocols();
|
|
57
|
+
u.closeByComponentIds(this.tId);
|
|
58
|
+
try {
|
|
59
|
+
this.ws = o.length > 0 ? new WebSocket(n, o) : new WebSocket(n), this.ws && (u.add(this.ws, this.tId), this.ws.binaryType = s, this.timeoutTimer = setTimeout(() => {
|
|
60
|
+
var a, m;
|
|
61
|
+
((a = this.ws) == null ? void 0 : a.readyState) === WebSocket.CONNECTING && (this.ws.close(), (m = this.onEvent) == null || m.call(this, "error", "Connection timeout"), this.handleClose({ code: 4001, reason: "Timeout" }));
|
|
62
|
+
}, i), this.ws.onopen = this.handleOpen.bind(this), this.ws.onmessage = this.handleMessage.bind(this), this.ws.onerror = this.handleError.bind(this), this.ws.onclose = this.handleClose.bind(this), (r = this.onEvent) == null || r.call(this, "connecting"));
|
|
63
|
+
} catch (a) {
|
|
64
|
+
(h = this.onEvent) == null || h.call(this, "error", a), this.scheduleReconnect();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
handleOpen() {
|
|
68
|
+
var s, i, n, o;
|
|
69
|
+
this.timeoutTimer && clearTimeout(this.timeoutTimer), (s = this.onEvent) == null || s.call(this, "connected"), this.reconnectAttempts = 0;
|
|
70
|
+
const { message: t, isMessage: e } = this.config;
|
|
71
|
+
if (t && e)
|
|
72
|
+
try {
|
|
73
|
+
const r = l.getVariableData(), h = typeof t == "string" ? l.replaceStringVariables(t, r) : l.replaceObjectVariables(t, r), a = typeof h == "string" ? h : JSON.stringify(h);
|
|
74
|
+
(i = this.ws) == null || i.send(a), (n = this.onEvent) == null || n.call(this, "messageSent", a);
|
|
75
|
+
} catch {
|
|
76
|
+
(o = this.onEvent) == null || o.call(this, "error", "Failed to send initial message");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async handleMessage(t) {
|
|
80
|
+
var e, s, i, n;
|
|
81
|
+
try {
|
|
82
|
+
let o = t.data;
|
|
83
|
+
if (typeof o == "string")
|
|
84
|
+
try {
|
|
85
|
+
o = JSON.parse(o);
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
const r = await f.processData(
|
|
89
|
+
this.source.source.filter,
|
|
90
|
+
o,
|
|
91
|
+
this.source.source.mapping,
|
|
92
|
+
this.id,
|
|
93
|
+
this.source.source.dynamicMapping,
|
|
94
|
+
this.noUseMapping,
|
|
95
|
+
this.source.source.isUserdata
|
|
96
|
+
);
|
|
97
|
+
(e = this.onData) == null || e.call(this, r), (s = this.onEvent) == null || s.call(this, "data", r);
|
|
98
|
+
} catch {
|
|
99
|
+
(i = this.onEvent) == null || i.call(this, "error", "Data processing failed"), (n = this.onData) == null || n.call(this, l.noneData(this.id));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
handleError(t) {
|
|
103
|
+
var e, s, i;
|
|
104
|
+
(e = this.onEvent) == null || e.call(this, "error", t), ((s = this.ws) == null ? void 0 : s.readyState) !== WebSocket.OPEN && ((i = this.onData) == null || i.call(this, l.noneData(this.id)));
|
|
105
|
+
}
|
|
106
|
+
handleClose(t) {
|
|
107
|
+
var e, s;
|
|
108
|
+
this.timeoutTimer && clearTimeout(this.timeoutTimer), (e = this.onEvent) == null || e.call(this, "disconnected", { code: t.code, reason: t.reason }), this.shouldReconnect(t) ? this.scheduleReconnect() : (s = this.onData) == null || s.call(this, l.noneData(this.id));
|
|
109
|
+
}
|
|
110
|
+
shouldReconnect(t) {
|
|
111
|
+
const { reconnect: e = !1, maxReconnectAttempts: s = 10 } = this.config;
|
|
112
|
+
return !this.isDisconnecting && e && this.reconnectAttempts < s && t.code !== 1e3 && t.code !== 4001;
|
|
113
|
+
}
|
|
114
|
+
scheduleReconnect() {
|
|
115
|
+
var s;
|
|
116
|
+
if (this.isDisconnecting) return;
|
|
117
|
+
const { reconnectInterval: t = 5e3 } = this.config;
|
|
118
|
+
this.reconnectAttempts++;
|
|
119
|
+
const e = t * Math.pow(2, this.reconnectAttempts - 1);
|
|
120
|
+
(s = this.onEvent) == null || s.call(this, "reconnecting", { attempt: this.reconnectAttempts, delay: e }), setTimeout(() => this.connect(), Math.min(e, 3e4));
|
|
121
|
+
}
|
|
122
|
+
send(t) {
|
|
123
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN)
|
|
124
|
+
throw new Error("WebSocket 未连接");
|
|
125
|
+
const e = typeof t == "string" ? t : JSON.stringify(t);
|
|
126
|
+
this.ws.send(e);
|
|
127
|
+
}
|
|
128
|
+
disconnect() {
|
|
129
|
+
this.isDisconnecting = !0, this.ws && (this.ws.close(1e3, "Manual close"), this.timeoutTimer && clearTimeout(this.timeoutTimer), u.closeByComponentIds(this.tId));
|
|
130
|
+
}
|
|
131
|
+
getWebSocket() {
|
|
132
|
+
return this.ws;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const T = (c, t, e, s, i, n) => new w(c, t, e, s, i, n);
|
|
136
|
+
export {
|
|
137
|
+
w as WebSocketInstance,
|
|
138
|
+
T as parseWebSocket
|
|
139
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var u = (i, t, e) => t in i ? l(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var f = (i, t, e) => u(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import d from "axios";
|
|
5
|
+
import { merge as p } from "lodash";
|
|
6
|
+
class T {
|
|
7
|
+
constructor() {
|
|
8
|
+
f(this, "instance");
|
|
9
|
+
this.instance = d.create();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* GET 请求
|
|
13
|
+
* @param url
|
|
14
|
+
* @param config
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
get(t, e) {
|
|
18
|
+
return this.instance.get(t, e);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* POST 请求
|
|
22
|
+
* @param url 请求的URL
|
|
23
|
+
* @param data 发送的数据
|
|
24
|
+
* @param contentType 数据的内容类型
|
|
25
|
+
* @param config 额外的Axios配置
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
post(t, e, a, o = "application/json; charset=UTF-8") {
|
|
29
|
+
const s = {
|
|
30
|
+
headers: {
|
|
31
|
+
"Content-Type": "application/json; charset=UTF-8"
|
|
32
|
+
/* Json */
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
if (o === "multipart/form-data") {
|
|
36
|
+
s.headers = {};
|
|
37
|
+
const n = new FormData();
|
|
38
|
+
for (const r in e)
|
|
39
|
+
n.append(r, e[r]);
|
|
40
|
+
e = n;
|
|
41
|
+
} else o === "application/x-www-form-urlencoded; charset=UTF-8" && (s.headers["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8", s.transformRequest = [(n) => {
|
|
42
|
+
const r = new URLSearchParams();
|
|
43
|
+
for (const c in n)
|
|
44
|
+
r.append(c, n[c]);
|
|
45
|
+
return r.toString();
|
|
46
|
+
}]);
|
|
47
|
+
return this.instance.post(t, e, p({}, s, a));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* PUT 请求
|
|
51
|
+
* @param url
|
|
52
|
+
* @param data
|
|
53
|
+
* @param config
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
put(t, e, a, o = "application/x-www-form-urlencoded; charset=UTF-8") {
|
|
57
|
+
const s = {
|
|
58
|
+
headers: {
|
|
59
|
+
"Content-Type": o
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
if (o === "multipart/form-data") {
|
|
63
|
+
s.headers = {};
|
|
64
|
+
const n = new FormData();
|
|
65
|
+
for (const r in e)
|
|
66
|
+
n.append(r, e[r]);
|
|
67
|
+
e = n;
|
|
68
|
+
} else o === "application/x-www-form-urlencoded; charset=UTF-8" && (s.headers["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8", s.transformRequest = [(n) => {
|
|
69
|
+
const r = new URLSearchParams();
|
|
70
|
+
for (const c in n)
|
|
71
|
+
r.append(c, n[c]);
|
|
72
|
+
return r.toString();
|
|
73
|
+
}]);
|
|
74
|
+
return this.instance.put(t, e, p({}, s, a));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* DELETE 请求
|
|
78
|
+
* @param url
|
|
79
|
+
* @param config
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
delete(t, e) {
|
|
83
|
+
const a = {
|
|
84
|
+
headers: {
|
|
85
|
+
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
|
86
|
+
/* UrlEncoded */
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return this.instance.delete(t, p({}, a, e));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 文件上传
|
|
93
|
+
* @param url
|
|
94
|
+
* @param params
|
|
95
|
+
* @param config
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
upload(t, e, a) {
|
|
99
|
+
const o = {
|
|
100
|
+
headers: {
|
|
101
|
+
"Content-Type": "multipart/form-data"
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return this.instance.post(t, e, a || o);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* blob文件下载
|
|
108
|
+
* @param url
|
|
109
|
+
* @param params
|
|
110
|
+
* @param config
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
download(t, e, a) {
|
|
114
|
+
const o = {
|
|
115
|
+
responseType: "blob",
|
|
116
|
+
headers: {
|
|
117
|
+
"Content-Type": "application/json"
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return this.instance.post(t, e, a || o);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Custom 请求
|
|
124
|
+
* @param url
|
|
125
|
+
* @param config
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
custom(t, e) {
|
|
129
|
+
return this.instance.get(t, e);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
T as HttpRequest
|
|
134
|
+
};
|