@shjjs/visual-ui 1.0.33 → 1.0.34
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/useChart.mjs +1 -1
- package/es/commons/plugins/datasource/index.d.ts +73 -73
- package/es/commons/plugins/datasource/index.mjs +214 -214
- package/es/commons/plugins/datasource/sources/api.d.ts +1 -1
- package/es/commons/plugins/datasource/sources/api.mjs +32 -32
- package/es/commons/plugins/datasource/sources/static.d.ts +1 -1
- package/es/commons/plugins/datasource/sources/static.mjs +17 -17
- package/es/commons/plugins/datasource/sources/storage.d.ts +1 -1
- package/es/commons/plugins/datasource/sources/storage.mjs +28 -28
- package/es/commons/plugins/datasource/sources/url.d.ts +1 -1
- package/es/commons/plugins/datasource/sources/url.mjs +17 -17
- package/es/commons/plugins/datasource/sources/variable.d.ts +1 -1
- package/es/commons/plugins/datasource/sources/variable.mjs +17 -17
- package/es/commons/plugins/datasource/sources/ws.d.ts +32 -32
- package/es/commons/plugins/datasource/sources/ws.mjs +139 -139
- package/es/commons/plugins/datasource/utils/axios.d.ts +70 -70
- package/es/commons/plugins/datasource/utils/axios.mjs +134 -134
- package/es/commons/plugins/datasource/utils/request.d.ts +3 -3
- package/es/commons/plugins/datasource/utils/request.mjs +5 -5
- package/es/commons/plugins/datasource/utils/utils.d.ts +115 -115
- package/es/commons/plugins/datasource/utils/utils.mjs +229 -229
- package/es/commons/plugins/datasource/utils/wsManager.d.ts +16 -16
- package/es/commons/plugins/datasource/utils/wsManager.mjs +78 -78
- package/es/commons/plugins/event/actions/fullScreenAction.d.ts +8 -8
- package/es/commons/plugins/event/actions/fullScreenAction.mjs +8 -8
- package/es/commons/plugins/event/actions/invokeAction.d.ts +8 -8
- package/es/commons/plugins/event/actions/invokeAction.mjs +11 -11
- package/es/commons/plugins/event/actions/linkAction.d.ts +8 -8
- package/es/commons/plugins/event/actions/linkAction.mjs +8 -8
- package/es/commons/plugins/event/actions/moveAction.d.ts +8 -8
- package/es/commons/plugins/event/actions/moveAction.mjs +15 -15
- package/es/commons/plugins/event/actions/refreshVariableAction.d.ts +7 -7
- package/es/commons/plugins/event/actions/refreshVariableAction.mjs +18 -18
- package/es/commons/plugins/event/actions/rotateAction.d.ts +8 -8
- package/es/commons/plugins/event/actions/rotateAction.mjs +19 -19
- package/es/commons/plugins/event/actions/scaleAction.d.ts +8 -8
- package/es/commons/plugins/event/actions/scaleAction.mjs +24 -24
- package/es/commons/plugins/event/actions/sendApiAction.d.ts +8 -8
- package/es/commons/plugins/event/actions/sendApiAction.mjs +16 -16
- package/es/commons/plugins/event/actions/ueCommonsWebscoketAction.d.ts +7 -7
- package/es/commons/plugins/event/actions/ueCommonsWebscoketAction.mjs +31 -31
- package/es/commons/plugins/event/actions/ueShjExecMethodAction.d.ts +7 -7
- package/es/commons/plugins/event/actions/ueShjExecMethodAction.mjs +31 -31
- package/es/commons/plugins/event/actions/unityIframeExecMethodAction.d.ts +7 -7
- package/es/commons/plugins/event/actions/unityIframeExecMethodAction.mjs +28 -28
- package/es/commons/plugins/event/actions/unityWebglExecMethodAction.d.ts +7 -7
- package/es/commons/plugins/event/actions/unityWebglExecMethodAction.mjs +28 -28
- package/es/commons/plugins/event/actions/updatePageAction.d.ts +8 -8
- package/es/commons/plugins/event/actions/updatePageAction.mjs +6 -6
- package/es/commons/plugins/event/actions/updateVariableAction.d.ts +7 -7
- package/es/commons/plugins/event/actions/updateVariableAction.mjs +25 -25
- package/es/commons/plugins/event/actions/updateWidgetAction.d.ts +7 -7
- package/es/commons/plugins/event/actions/updateWidgetAction.mjs +14 -14
- package/es/commons/plugins/event/actions/vrSceneMethodAction.d.ts +7 -7
- package/es/commons/plugins/event/actions/vrSceneMethodAction.mjs +12 -12
- package/es/commons/plugins/event/index.d.ts +206 -206
- package/es/commons/plugins/event/index.mjs +161 -161
- package/es/commons/plugins/event/utils/utils.d.ts +22 -22
- package/es/commons/plugins/event/utils/utils.mjs +50 -50
- package/es/commons/utils/componentRefs.d.ts +28 -28
- package/es/commons/utils/componentRefs.mjs +37 -37
- package/es/commons/utils/getNextElement.d.ts +7 -7
- package/es/commons/utils/getNextElement.mjs +12 -12
- package/es/components/chart/commons/components/common-chart/index.vue.mjs +10 -11
- package/es/components/chart/commons/components/common-chart-map/index.vue.mjs +6 -7
- package/es/components/chart/commons/hooks/useChart.mjs +1 -1
- package/es/components/chart-other-candlestick-basic/index.vue.mjs +7 -8
- package/es/components/chart-other-candlestick-demo/index.vue.mjs +16 -17
- package/es/components/chart-other-candlestick-shanghai/index.vue.mjs +14 -15
- package/es/components/chart-other-circular-graph/index.vue.mjs +16 -17
- package/es/components/chart-other-force/index.vue.mjs +19 -20
- package/es/components/chart-other-force2/index.vue.mjs +19 -20
- package/es/components/chart-other-funnel/index.vue.mjs +16 -17
- package/es/components/chart-other-funnel-contrast/index.vue.mjs +16 -17
- package/es/components/chart-other-funnel-split/index.vue.mjs +16 -17
- package/es/components/chart-other-funnel2/index.vue.mjs +16 -17
- package/es/components/chart-other-gauge/index.vue.mjs +21 -22
- package/es/components/chart-other-gauge-grade/index.vue.mjs +20 -21
- package/es/components/chart-other-gauge-stage/index.vue.mjs +21 -22
- package/es/components/chart-other-graph-basic/index.vue.mjs +8 -9
- package/es/components/chart-other-graph-basic2/index.vue.mjs +8 -9
- package/es/components/chart-other-graph-calendar/index.vue.mjs +7 -8
- package/es/components/chart-other-grid-percentage/index.vue.mjs +3 -4
- package/es/components/chart-other-heatmap/index.vue.mjs +19 -20
- package/es/components/chart-other-label-gauge/index.vue.mjs +9 -10
- package/es/components/chart-other-liquidfill/index.vue.mjs +11 -12
- package/es/components/chart-other-parallel-basic/index.vue.mjs +15 -16
- package/es/components/chart-other-parallel-mul/index.vue.mjs +6 -7
- package/es/components/chart-other-radar/index.vue.mjs +20 -21
- package/es/components/chart-other-radar-stack/index.vue.mjs +6 -7
- package/es/components/chart-other-sunburst-basic/index.vue.mjs +12 -13
- package/es/components/chart-other-sunburst-basic2/index.vue.mjs +12 -13
- package/es/components/chart-other-sunburst-basic3/index.vue.mjs +12 -13
- package/es/components/chart-other-sunburst-basic4/index.vue.mjs +12 -13
- package/es/components/chart-other-sunburst-book/index.vue.mjs +7 -8
- package/es/components/chart-other-sunburst-flavors/index.vue.mjs +16 -17
- package/es/components/chart-other-sunburst-radius/index.vue.mjs +18 -19
- package/es/components/chart-other-theme-river/index.vue.mjs +3 -4
- package/es/components/chart-other-tree/index.vue.mjs +8 -9
- package/es/components/chart-other-tree-line/index.vue.mjs +7 -8
- package/es/components/chart-other-treemap/index.vue.mjs +9 -10
- package/es/components/chart-other-treemap-basic/index.vue.mjs +14 -15
- package/es/components/chart-other-word-cloud/index.vue.mjs +11 -12
- package/es/components/commons-echarts/compileAndRunEcharts.mjs +8 -9
- package/es/components/commons-loop-iterator/index.vue.mjs +2 -2
- package/es/components/commons-loop-iterator/index.vue2.mjs +3 -4
- package/es/components/commons-product-model/index.vue.mjs +2 -2
- package/es/components/commons-product-model/index.vue2.mjs +1 -1
- package/es/components/commons-three-loader/index.vue.mjs +1 -1
- package/es/components/commons-three-loader/index.vue2.mjs +1 -1
- package/es/components/commons-three-loader3/index.vue.mjs +1 -1
- package/es/components/commons-three-loader3/index.vue2.mjs +1 -1
- package/es/components/commons-weather/index.vue.mjs +2 -2
- package/es/components/commons-weather/index.vue2.mjs +1 -1
- package/es/components/commons-weather-dynamic/index.vue.mjs +1 -1
- package/es/components/commons-weather-dynamic/index.vue2.mjs +3 -4
- package/es/components/interaction/button/index.vue.mjs +2 -2
- package/es/components/interaction/button/index.vue2.mjs +65 -65
- package/es/components/interaction/date-picker/components/common-date-picker/index.vue.mjs +2 -2
- package/es/components/interaction/date-picker/components/common-date-picker/index.vue2.mjs +64 -65
- package/es/components/interaction/tabs/index.vue.mjs +11 -12
- package/es/components/interaction/tabs-icon/index.vue.mjs +6 -7
- package/es/components/interaction-input/index.vue.mjs +1 -1
- package/es/components/interaction-input/index.vue2.mjs +3 -4
- package/es/components/interaction-select/index.vue.mjs +1 -1
- package/es/components/interaction-select/index.vue2.mjs +6 -7
- package/es/components/interaction-slider/index.vue.mjs +2 -2
- package/es/components/interaction-slider/index.vue2.mjs +34 -35
- package/es/components/interaction-switch/index.vue.mjs +2 -2
- package/es/components/interaction-switch/index.vue2.mjs +20 -20
- package/es/components/interaction-tabs/index.vue.mjs +2 -2
- package/es/components/interaction-tabs/index.vue2.mjs +1 -1
- package/es/components/interaction-tabs2/index.vue.mjs +2 -2
- package/es/components/interaction-tabs2/index.vue2.mjs +1 -1
- package/es/components/map-earth-basic/index.vue.d.ts +0 -2
- package/es/components/map-earth-basic/index.vue.mjs +14 -15
- package/es/components/map-earth-cool-tech/index.vue.mjs +14 -15
- package/es/components/map-earth-fly-line/index.vue.d.ts +0 -4
- package/es/components/map-earth-fly-line/index.vue.mjs +8 -9
- package/es/components/map-earth-hacker/index.vue.d.ts +2 -4
- package/es/components/map-earth-hacker/index.vue.mjs +19 -20
- package/es/components/map-earth-particle/index.vue.d.ts +0 -4
- package/es/components/map-earth-particle/index.vue.mjs +14 -15
- package/es/components/media-audio/index.vue.mjs +2 -2
- package/es/components/media-audio/index.vue2.mjs +5 -5
- package/es/components/media-audio-dynamic/index.vue.mjs +1 -1
- package/es/components/media-audio-dynamic/index.vue2.mjs +4 -5
- package/es/components/media-flv/index.vue.mjs +1 -1
- package/es/components/media-iframe/index.vue.mjs +2 -2
- package/es/components/media-iframe/index.vue2.mjs +1 -1
- package/es/components/media-image-dynamic/index.vue.mjs +2 -2
- package/es/components/media-image-dynamic/index.vue2.mjs +6 -7
- package/es/components/media-m3u8/index.vue.mjs +1 -1
- package/es/components/media-m3u8-dynamic/index.vue.mjs +3 -4
- package/es/components/media-video/index.vue.mjs +2 -2
- package/es/components/media-video/index.vue2.mjs +1 -1
- package/es/components/media-video-dynamic/index.vue.mjs +2 -2
- package/es/components/media-video-dynamic/index.vue2.mjs +3 -4
- package/es/components/scene-amap2d/index.vue.mjs +1 -1
- package/es/components/scene-amap2d/index.vue2.mjs +13 -14
- package/es/components/scene-amap3d/index.vue.mjs +2 -2
- package/es/components/scene-amap3d/index.vue2.mjs +4 -5
- package/es/components/scene-default/index.vue.mjs +2 -2
- package/es/components/scene-default/index.vue2.mjs +1 -1
- package/es/components/scene-map3d/index.vue.mjs +2 -2
- package/es/components/scene-map3d/index.vue2.mjs +19 -20
- package/es/components/scene-ue-iframe/index.vue.mjs +2 -2
- package/es/components/scene-ue-iframe/index.vue2.mjs +1 -1
- package/es/components/scene-ue-shj/index.vue.mjs +2 -2
- package/es/components/scene-ue-shj/index.vue2.mjs +1 -1
- package/es/components/scene-unity-iframe/index.vue.mjs +2 -2
- package/es/components/scene-unity-iframe/index.vue2.mjs +1 -1
- package/es/components/scene-unity-webgl/index.vue.mjs +1 -1
- package/es/components/scene-unity-webgl/index.vue2.mjs +1 -1
- package/es/components/scene-vr/index.vue.mjs +2 -2
- package/es/components/scene-vr/index.vue2.mjs +3 -3
- package/es/components/text/list/index.vue.mjs +10 -11
- package/es/components/text-count-down/index.vue.mjs +1 -1
- package/es/components/text-count-down/index.vue2.mjs +1 -1
- package/es/components/text-over-number/index.vue.mjs +1 -1
- package/es/components/text-over-number/index.vue2.mjs +15 -16
- package/es/components/text-real-time/index.vue.mjs +1 -1
- package/es/components/text-real-time/index.vue2.mjs +2 -2
- package/es/components/text-row-scroll/index.vue.mjs +2 -2
- package/es/components/text-row-scroll/index.vue2.mjs +30 -31
- package/es/components/text-table-basic/index.vue.mjs +1 -1
- package/es/components/text-table-basic/index.vue2.mjs +43 -44
- package/es/components/text-table-scroll/index.vue.mjs +2 -2
- package/es/components/text-table-scroll/index.vue2.mjs +58 -59
- package/es/components/text-text-dynamic/index.vue.mjs +1 -1
- package/es/components/text-text-dynamic/index.vue2.mjs +16 -17
- package/es/env.d.ts +0 -1
- package/es/index.d.ts +0 -7
- package/es/index.mjs +359 -373
- package/es/widgets.css +1 -1
- package/package.json +1 -1
|
@@ -1,229 +1,229 @@
|
|
|
1
|
-
import { isArray as g, isObject as b } from "lodash";
|
|
2
|
-
class o {
|
|
3
|
-
/**
|
|
4
|
-
* 替换URL中的变量
|
|
5
|
-
* @param url URL
|
|
6
|
-
* @param variableData 变量数据
|
|
7
|
-
* @returns 解析后的URL
|
|
8
|
-
*/
|
|
9
|
-
static replaceURLVariables(t, n) {
|
|
10
|
-
try {
|
|
11
|
-
const a = t.match(/\${(.*?)}/g);
|
|
12
|
-
if (a)
|
|
13
|
-
for (let e = 0; e < a.length; e++) {
|
|
14
|
-
const r = a[e].substring(2, a[e].length - 1), i = o.extractVariableName(r), s = n.find((l) => l.name === i);
|
|
15
|
-
if (!s)
|
|
16
|
-
continue;
|
|
17
|
-
const c = o.getNestedValue(s._value, r.substring(i.length));
|
|
18
|
-
t = t.replaceAll(a[e], c);
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
} catch {
|
|
22
|
-
return t;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 替换对象中的变量
|
|
27
|
-
* @param obj 对象
|
|
28
|
-
* @param variableData 变量数据
|
|
29
|
-
* @returns 解析后的对象
|
|
30
|
-
*/
|
|
31
|
-
static replaceObjectVariables(t, n) {
|
|
32
|
-
try {
|
|
33
|
-
let a = JSON.stringify(t);
|
|
34
|
-
const e = a.match(/\$g{(.*?)}/g);
|
|
35
|
-
if (e) {
|
|
36
|
-
for (let r = 0; r < e.length; r++) {
|
|
37
|
-
const i = e[r].substring(3, e[r].length - 1), s = this.extractVariableName(i), c = n.find((u) => u.name === s);
|
|
38
|
-
if (!c)
|
|
39
|
-
continue;
|
|
40
|
-
const l = this.getNestedValue(c._value, i.substring(s.length));
|
|
41
|
-
a = a.replaceAll(e[r], l);
|
|
42
|
-
}
|
|
43
|
-
return JSON.parse(a);
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
} catch {
|
|
47
|
-
return t;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* 替换字符串中的变量
|
|
52
|
-
* @param str 字符串
|
|
53
|
-
* @param variableData 变量数据
|
|
54
|
-
* @returns 解析后的字符串
|
|
55
|
-
*/
|
|
56
|
-
static replaceStringVariables(t, n) {
|
|
57
|
-
try {
|
|
58
|
-
const a = t.match(/\$g{(.*?)}/g);
|
|
59
|
-
if (a)
|
|
60
|
-
for (let e = 0; e < a.length; e++) {
|
|
61
|
-
const r = a[e].substring(3, a[e].length - 1), i = this.extractVariableName(r), s = n.find((l) => l.name === i);
|
|
62
|
-
if (!s)
|
|
63
|
-
continue;
|
|
64
|
-
const c = this.getNestedValue(s._value, r.substring(i.length));
|
|
65
|
-
t = t.replaceAll(a[e], c);
|
|
66
|
-
}
|
|
67
|
-
return t;
|
|
68
|
-
} catch {
|
|
69
|
-
return t;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* 获取URL中的变量名
|
|
74
|
-
* @param url URL
|
|
75
|
-
* @returns 变量名
|
|
76
|
-
*/
|
|
77
|
-
static getURLVariableNames(t) {
|
|
78
|
-
const n = [], a = t.match(/\${(.*?)}/g);
|
|
79
|
-
if (a)
|
|
80
|
-
for (let e = 0; e < a.length; e++) {
|
|
81
|
-
const r = a[e].substring(2, a[e].length - 1), i = o.extractVariableName(r);
|
|
82
|
-
n.push(i);
|
|
83
|
-
}
|
|
84
|
-
return n;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* 获取对象中的变量名
|
|
88
|
-
* @param obj 对象
|
|
89
|
-
* @returns 变量名
|
|
90
|
-
*/
|
|
91
|
-
static getObjectVariableNames(t) {
|
|
92
|
-
const n = [], e = JSON.stringify(t).match(/\$g{(.*?)}/g);
|
|
93
|
-
if (e)
|
|
94
|
-
for (let r = 0; r < e.length; r++) {
|
|
95
|
-
const i = e[r].substring(3, e[r].length - 1), s = this.extractVariableName(i);
|
|
96
|
-
n.push(s);
|
|
97
|
-
}
|
|
98
|
-
return n;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 获取字符串中的变量名
|
|
102
|
-
* @param str 字符串
|
|
103
|
-
* @returns 变量名
|
|
104
|
-
*/
|
|
105
|
-
static getStringVariableNames(t) {
|
|
106
|
-
const n = [], a = t.match(/\$g{(.*?)}/g);
|
|
107
|
-
if (a)
|
|
108
|
-
for (let e = 0; e < a.length; e++) {
|
|
109
|
-
const r = a[e].substring(3, a[e].length - 1), i = this.extractVariableName(r);
|
|
110
|
-
n.push(i);
|
|
111
|
-
}
|
|
112
|
-
return n;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* 解析环境变量
|
|
116
|
-
* @param url URL
|
|
117
|
-
* @param environments 环境变量
|
|
118
|
-
* @returns 解析后的环境变量
|
|
119
|
-
*/
|
|
120
|
-
static replaceEnvVariables(t, n) {
|
|
121
|
-
try {
|
|
122
|
-
let a = "";
|
|
123
|
-
if (!t.includes("http") && n) {
|
|
124
|
-
const e = n.filter((r) => r.selected);
|
|
125
|
-
e && g(e) && e.length > 0 && (a = e[0].envBaseUrl || "");
|
|
126
|
-
}
|
|
127
|
-
return a;
|
|
128
|
-
} catch {
|
|
129
|
-
return "";
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* 返回空数据
|
|
134
|
-
* @param id 数据源 ID
|
|
135
|
-
* @returns 空数据
|
|
136
|
-
*/
|
|
137
|
-
static noneData(t) {
|
|
138
|
-
return {
|
|
139
|
-
id: t,
|
|
140
|
-
finalKeyData: [],
|
|
141
|
-
finalUserData: { id: t, data: [] },
|
|
142
|
-
filteredData: [],
|
|
143
|
-
rawData: [],
|
|
144
|
-
noMappingData: []
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* 获取环境变量
|
|
149
|
-
* @returns 环境变量
|
|
150
|
-
*/
|
|
151
|
-
static getEnvironments() {
|
|
152
|
-
let t = sessionStorage.getItem("currentApiEnvironments");
|
|
153
|
-
return t && (t = JSON.parse(t)), t;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* 设置环境变量
|
|
157
|
-
* @param environments 环境变量
|
|
158
|
-
*/
|
|
159
|
-
static setEnvironments(t) {
|
|
160
|
-
sessionStorage.setItem("currentApiEnvironments", JSON.stringify(t));
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* 获取变量数据
|
|
164
|
-
* @returns 变量数据
|
|
165
|
-
*/
|
|
166
|
-
static getVariableData() {
|
|
167
|
-
let t = sessionStorage.getItem("currentVariableData");
|
|
168
|
-
return t && (t = JSON.parse(t)), t;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* 设置变量数据
|
|
172
|
-
* @param variableData 变量数据
|
|
173
|
-
*/
|
|
174
|
-
static setVariableData(t) {
|
|
175
|
-
sessionStorage.setItem("currentVariableData", JSON.stringify(t));
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* 检查 WebSocket 是否已存在且有效
|
|
179
|
-
* @param wsInstances WebSocket 实例
|
|
180
|
-
* @param tId WebSocket 实例的 ID
|
|
181
|
-
* @param sourceId WebSocket 实例的源 ID
|
|
182
|
-
* @returns 是否有效
|
|
183
|
-
*/
|
|
184
|
-
static hasValidWebSocket(t, n, a) {
|
|
185
|
-
const e = t.get(n);
|
|
186
|
-
if (!e) return !1;
|
|
187
|
-
for (const r of e)
|
|
188
|
-
if (r.getId() === a && r.isConnected())
|
|
189
|
-
return !0;
|
|
190
|
-
return !1;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* 只在必要时清理 WebSocket 连接
|
|
194
|
-
* @param wsInstances WebSocket 实例
|
|
195
|
-
* @param sourceIds 源 ID
|
|
196
|
-
* @param tId WebSocket 实例的 ID
|
|
197
|
-
*/
|
|
198
|
-
static cleanupPreviousWebSockets(t, n, a) {
|
|
199
|
-
const e = t.get(a);
|
|
200
|
-
e && (e.forEach((r) => {
|
|
201
|
-
n.includes(r.getId()) || (r.disconnect(), e.delete(r));
|
|
202
|
-
}), e.size === 0 && t.delete(a));
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* 使用 Function 构造函数获取对象中的嵌套值(更简洁但安全性较低)
|
|
206
|
-
* @param obj 源对象
|
|
207
|
-
* @param path 路径字符串,例如 ".a[0].value"
|
|
208
|
-
* @returns 获取到的值,如果路径不存在则返回 undefined
|
|
209
|
-
*/
|
|
210
|
-
static getNestedValue(t, n) {
|
|
211
|
-
try {
|
|
212
|
-
return n ? new Function("obj", `return obj${n}`)(t) : b(t) || g(t) ? JSON.stringify(t) : t;
|
|
213
|
-
} catch {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* 从路径字符串中提取变量名
|
|
219
|
-
* @param path 路径字符串,例如 "测试.test" 或 "333[0].aa"
|
|
220
|
-
* @returns 提取出的变量名
|
|
221
|
-
*/
|
|
222
|
-
static extractVariableName(t) {
|
|
223
|
-
const n = t.match(/^([\u4e00-\u9fa5a-zA-Z0-9_][\u4e00-\u9fa5a-zA-Z0-9_]*)/);
|
|
224
|
-
return n ? n[1] : "";
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
export {
|
|
228
|
-
o as DataSourceUtils
|
|
229
|
-
};
|
|
1
|
+
import { isArray as g, isObject as b } from "lodash";
|
|
2
|
+
class o {
|
|
3
|
+
/**
|
|
4
|
+
* 替换URL中的变量
|
|
5
|
+
* @param url URL
|
|
6
|
+
* @param variableData 变量数据
|
|
7
|
+
* @returns 解析后的URL
|
|
8
|
+
*/
|
|
9
|
+
static replaceURLVariables(t, n) {
|
|
10
|
+
try {
|
|
11
|
+
const a = t.match(/\${(.*?)}/g);
|
|
12
|
+
if (a)
|
|
13
|
+
for (let e = 0; e < a.length; e++) {
|
|
14
|
+
const r = a[e].substring(2, a[e].length - 1), i = o.extractVariableName(r), s = n.find((l) => l.name === i);
|
|
15
|
+
if (!s)
|
|
16
|
+
continue;
|
|
17
|
+
const c = o.getNestedValue(s._value, r.substring(i.length));
|
|
18
|
+
t = t.replaceAll(a[e], c);
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
} catch {
|
|
22
|
+
return t;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 替换对象中的变量
|
|
27
|
+
* @param obj 对象
|
|
28
|
+
* @param variableData 变量数据
|
|
29
|
+
* @returns 解析后的对象
|
|
30
|
+
*/
|
|
31
|
+
static replaceObjectVariables(t, n) {
|
|
32
|
+
try {
|
|
33
|
+
let a = JSON.stringify(t);
|
|
34
|
+
const e = a.match(/\$g{(.*?)}/g);
|
|
35
|
+
if (e) {
|
|
36
|
+
for (let r = 0; r < e.length; r++) {
|
|
37
|
+
const i = e[r].substring(3, e[r].length - 1), s = this.extractVariableName(i), c = n.find((u) => u.name === s);
|
|
38
|
+
if (!c)
|
|
39
|
+
continue;
|
|
40
|
+
const l = this.getNestedValue(c._value, i.substring(s.length));
|
|
41
|
+
a = a.replaceAll(e[r], l);
|
|
42
|
+
}
|
|
43
|
+
return JSON.parse(a);
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
} catch {
|
|
47
|
+
return t;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 替换字符串中的变量
|
|
52
|
+
* @param str 字符串
|
|
53
|
+
* @param variableData 变量数据
|
|
54
|
+
* @returns 解析后的字符串
|
|
55
|
+
*/
|
|
56
|
+
static replaceStringVariables(t, n) {
|
|
57
|
+
try {
|
|
58
|
+
const a = t.match(/\$g{(.*?)}/g);
|
|
59
|
+
if (a)
|
|
60
|
+
for (let e = 0; e < a.length; e++) {
|
|
61
|
+
const r = a[e].substring(3, a[e].length - 1), i = this.extractVariableName(r), s = n.find((l) => l.name === i);
|
|
62
|
+
if (!s)
|
|
63
|
+
continue;
|
|
64
|
+
const c = this.getNestedValue(s._value, r.substring(i.length));
|
|
65
|
+
t = t.replaceAll(a[e], c);
|
|
66
|
+
}
|
|
67
|
+
return t;
|
|
68
|
+
} catch {
|
|
69
|
+
return t;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 获取URL中的变量名
|
|
74
|
+
* @param url URL
|
|
75
|
+
* @returns 变量名
|
|
76
|
+
*/
|
|
77
|
+
static getURLVariableNames(t) {
|
|
78
|
+
const n = [], a = t.match(/\${(.*?)}/g);
|
|
79
|
+
if (a)
|
|
80
|
+
for (let e = 0; e < a.length; e++) {
|
|
81
|
+
const r = a[e].substring(2, a[e].length - 1), i = o.extractVariableName(r);
|
|
82
|
+
n.push(i);
|
|
83
|
+
}
|
|
84
|
+
return n;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 获取对象中的变量名
|
|
88
|
+
* @param obj 对象
|
|
89
|
+
* @returns 变量名
|
|
90
|
+
*/
|
|
91
|
+
static getObjectVariableNames(t) {
|
|
92
|
+
const n = [], e = JSON.stringify(t).match(/\$g{(.*?)}/g);
|
|
93
|
+
if (e)
|
|
94
|
+
for (let r = 0; r < e.length; r++) {
|
|
95
|
+
const i = e[r].substring(3, e[r].length - 1), s = this.extractVariableName(i);
|
|
96
|
+
n.push(s);
|
|
97
|
+
}
|
|
98
|
+
return n;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 获取字符串中的变量名
|
|
102
|
+
* @param str 字符串
|
|
103
|
+
* @returns 变量名
|
|
104
|
+
*/
|
|
105
|
+
static getStringVariableNames(t) {
|
|
106
|
+
const n = [], a = t.match(/\$g{(.*?)}/g);
|
|
107
|
+
if (a)
|
|
108
|
+
for (let e = 0; e < a.length; e++) {
|
|
109
|
+
const r = a[e].substring(3, a[e].length - 1), i = this.extractVariableName(r);
|
|
110
|
+
n.push(i);
|
|
111
|
+
}
|
|
112
|
+
return n;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 解析环境变量
|
|
116
|
+
* @param url URL
|
|
117
|
+
* @param environments 环境变量
|
|
118
|
+
* @returns 解析后的环境变量
|
|
119
|
+
*/
|
|
120
|
+
static replaceEnvVariables(t, n) {
|
|
121
|
+
try {
|
|
122
|
+
let a = "";
|
|
123
|
+
if (!t.includes("http") && n) {
|
|
124
|
+
const e = n.filter((r) => r.selected);
|
|
125
|
+
e && g(e) && e.length > 0 && (a = e[0].envBaseUrl || "");
|
|
126
|
+
}
|
|
127
|
+
return a;
|
|
128
|
+
} catch {
|
|
129
|
+
return "";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 返回空数据
|
|
134
|
+
* @param id 数据源 ID
|
|
135
|
+
* @returns 空数据
|
|
136
|
+
*/
|
|
137
|
+
static noneData(t) {
|
|
138
|
+
return {
|
|
139
|
+
id: t,
|
|
140
|
+
finalKeyData: [],
|
|
141
|
+
finalUserData: { id: t, data: [] },
|
|
142
|
+
filteredData: [],
|
|
143
|
+
rawData: [],
|
|
144
|
+
noMappingData: []
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 获取环境变量
|
|
149
|
+
* @returns 环境变量
|
|
150
|
+
*/
|
|
151
|
+
static getEnvironments() {
|
|
152
|
+
let t = sessionStorage.getItem("currentApiEnvironments");
|
|
153
|
+
return t && (t = JSON.parse(t)), t;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 设置环境变量
|
|
157
|
+
* @param environments 环境变量
|
|
158
|
+
*/
|
|
159
|
+
static setEnvironments(t) {
|
|
160
|
+
sessionStorage.setItem("currentApiEnvironments", JSON.stringify(t));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 获取变量数据
|
|
164
|
+
* @returns 变量数据
|
|
165
|
+
*/
|
|
166
|
+
static getVariableData() {
|
|
167
|
+
let t = sessionStorage.getItem("currentVariableData");
|
|
168
|
+
return t && (t = JSON.parse(t)), t;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 设置变量数据
|
|
172
|
+
* @param variableData 变量数据
|
|
173
|
+
*/
|
|
174
|
+
static setVariableData(t) {
|
|
175
|
+
sessionStorage.setItem("currentVariableData", JSON.stringify(t));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 检查 WebSocket 是否已存在且有效
|
|
179
|
+
* @param wsInstances WebSocket 实例
|
|
180
|
+
* @param tId WebSocket 实例的 ID
|
|
181
|
+
* @param sourceId WebSocket 实例的源 ID
|
|
182
|
+
* @returns 是否有效
|
|
183
|
+
*/
|
|
184
|
+
static hasValidWebSocket(t, n, a) {
|
|
185
|
+
const e = t.get(n);
|
|
186
|
+
if (!e) return !1;
|
|
187
|
+
for (const r of e)
|
|
188
|
+
if (r.getId() === a && r.isConnected())
|
|
189
|
+
return !0;
|
|
190
|
+
return !1;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 只在必要时清理 WebSocket 连接
|
|
194
|
+
* @param wsInstances WebSocket 实例
|
|
195
|
+
* @param sourceIds 源 ID
|
|
196
|
+
* @param tId WebSocket 实例的 ID
|
|
197
|
+
*/
|
|
198
|
+
static cleanupPreviousWebSockets(t, n, a) {
|
|
199
|
+
const e = t.get(a);
|
|
200
|
+
e && (e.forEach((r) => {
|
|
201
|
+
n.includes(r.getId()) || (r.disconnect(), e.delete(r));
|
|
202
|
+
}), e.size === 0 && t.delete(a));
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 使用 Function 构造函数获取对象中的嵌套值(更简洁但安全性较低)
|
|
206
|
+
* @param obj 源对象
|
|
207
|
+
* @param path 路径字符串,例如 ".a[0].value"
|
|
208
|
+
* @returns 获取到的值,如果路径不存在则返回 undefined
|
|
209
|
+
*/
|
|
210
|
+
static getNestedValue(t, n) {
|
|
211
|
+
try {
|
|
212
|
+
return n ? new Function("obj", `return obj${n}`)(t) : b(t) || g(t) ? JSON.stringify(t) : t;
|
|
213
|
+
} catch {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* 从路径字符串中提取变量名
|
|
219
|
+
* @param path 路径字符串,例如 "测试.test" 或 "333[0].aa"
|
|
220
|
+
* @returns 提取出的变量名
|
|
221
|
+
*/
|
|
222
|
+
static extractVariableName(t) {
|
|
223
|
+
const n = t.match(/^([\u4e00-\u9fa5a-zA-Z0-9_][\u4e00-\u9fa5a-zA-Z0-9_]*)/);
|
|
224
|
+
return n ? n[1] : "";
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
export {
|
|
228
|
+
o as DataSourceUtils
|
|
229
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
declare class WebSocketManager {
|
|
2
|
-
private static instance;
|
|
3
|
-
private connections;
|
|
4
|
-
static getInstance(): WebSocketManager;
|
|
5
|
-
add(ws: WebSocket, componentId: string): void;
|
|
6
|
-
closeByComponentIds(componentIds: string | string[]): void;
|
|
7
|
-
private removeAllListeners;
|
|
8
|
-
closeAll(): void;
|
|
9
|
-
private setupAutoRemove;
|
|
10
|
-
getConnectionsInfo(): {
|
|
11
|
-
componentId: string;
|
|
12
|
-
readyState: number;
|
|
13
|
-
}[];
|
|
14
|
-
}
|
|
15
|
-
export declare const wsManager: WebSocketManager;
|
|
16
|
-
export {};
|
|
1
|
+
declare class WebSocketManager {
|
|
2
|
+
private static instance;
|
|
3
|
+
private connections;
|
|
4
|
+
static getInstance(): WebSocketManager;
|
|
5
|
+
add(ws: WebSocket, componentId: string): void;
|
|
6
|
+
closeByComponentIds(componentIds: string | string[]): void;
|
|
7
|
+
private removeAllListeners;
|
|
8
|
+
closeAll(): void;
|
|
9
|
+
private setupAutoRemove;
|
|
10
|
+
getConnectionsInfo(): {
|
|
11
|
+
componentId: string;
|
|
12
|
+
readyState: number;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
export declare const wsManager: WebSocketManager;
|
|
16
|
+
export {};
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
var d = Object.defineProperty;
|
|
2
|
-
var h = (s, e, o) => e in s ? d(s, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : s[e] = o;
|
|
3
|
-
var r = (s, e, o) => h(s, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
-
const n = class n {
|
|
5
|
-
constructor() {
|
|
6
|
-
r(this, "connections", /* @__PURE__ */ new Set());
|
|
7
|
-
}
|
|
8
|
-
// 单例模式
|
|
9
|
-
static getInstance() {
|
|
10
|
-
return n.instance || (n.instance = new n()), n.instance;
|
|
11
|
-
}
|
|
12
|
-
// 添加 WebSocket 连接
|
|
13
|
-
add(e, o) {
|
|
14
|
-
Array.from(this.connections).filter((t) => t.componentId === o).forEach((t) => {
|
|
15
|
-
if (this.removeAllListeners(t.ws), t.ws.readyState !== WebSocket.CLOSED)
|
|
16
|
-
try {
|
|
17
|
-
t.ws.close(1e3, `Replacing connection for component ${o}`);
|
|
18
|
-
} catch {
|
|
19
|
-
}
|
|
20
|
-
this.connections.delete(t);
|
|
21
|
-
});
|
|
22
|
-
const c = { ws: e, componentId: o };
|
|
23
|
-
this.connections.add(c), this.setupAutoRemove(e, c);
|
|
24
|
-
}
|
|
25
|
-
// 改进点:更彻底的连接关闭 + 内存泄漏防护
|
|
26
|
-
closeByComponentIds(e) {
|
|
27
|
-
const o = Array.isArray(e) ? e : [e], i = new Set(o);
|
|
28
|
-
Array.from(this.connections).filter(
|
|
29
|
-
(t) => i.has(t.componentId) && t.ws.readyState !== WebSocket.CLOSED
|
|
30
|
-
).forEach((t) => {
|
|
31
|
-
this.removeAllListeners(t.ws);
|
|
32
|
-
try {
|
|
33
|
-
t.ws.close(1e3, `Component ${t.componentId} unmounted`);
|
|
34
|
-
} catch {
|
|
35
|
-
}
|
|
36
|
-
this.connections.delete(t);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
// 辅助方法:清理事件监听器
|
|
40
|
-
removeAllListeners(e) {
|
|
41
|
-
const o = () => {
|
|
42
|
-
};
|
|
43
|
-
e.onopen = o, e.onmessage = o, e.onerror = o, e.onclose = o, "removeAllListeners" in e && e.removeAllListeners();
|
|
44
|
-
}
|
|
45
|
-
// 关闭所有连接
|
|
46
|
-
closeAll() {
|
|
47
|
-
this.connections.forEach((e) => {
|
|
48
|
-
if (e.ws.readyState === WebSocket.OPEN || e.ws.readyState === WebSocket.CONNECTING)
|
|
49
|
-
try {
|
|
50
|
-
e.ws.close(1e3, "All connections closed");
|
|
51
|
-
} catch {
|
|
52
|
-
}
|
|
53
|
-
}), this.connections.clear();
|
|
54
|
-
}
|
|
55
|
-
// 自动移除已关闭的连接
|
|
56
|
-
setupAutoRemove(e, o) {
|
|
57
|
-
const i = e.close.bind(e);
|
|
58
|
-
e.close = (c, t) => {
|
|
59
|
-
this.connections.delete(o), i(c, t);
|
|
60
|
-
}, e.onclose = () => {
|
|
61
|
-
this.connections.delete(o);
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
// 用于调试的方法
|
|
65
|
-
getConnectionsInfo() {
|
|
66
|
-
return Array.from(this.connections).map((e) => ({
|
|
67
|
-
componentId: e.componentId,
|
|
68
|
-
readyState: e.ws.readyState
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
// eslint-disable-next-line no-use-before-define
|
|
73
|
-
r(n, "instance");
|
|
74
|
-
let a = n;
|
|
75
|
-
const A = a.getInstance();
|
|
76
|
-
export {
|
|
77
|
-
A as wsManager
|
|
78
|
-
};
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var h = (s, e, o) => e in s ? d(s, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : s[e] = o;
|
|
3
|
+
var r = (s, e, o) => h(s, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
const n = class n {
|
|
5
|
+
constructor() {
|
|
6
|
+
r(this, "connections", /* @__PURE__ */ new Set());
|
|
7
|
+
}
|
|
8
|
+
// 单例模式
|
|
9
|
+
static getInstance() {
|
|
10
|
+
return n.instance || (n.instance = new n()), n.instance;
|
|
11
|
+
}
|
|
12
|
+
// 添加 WebSocket 连接
|
|
13
|
+
add(e, o) {
|
|
14
|
+
Array.from(this.connections).filter((t) => t.componentId === o).forEach((t) => {
|
|
15
|
+
if (this.removeAllListeners(t.ws), t.ws.readyState !== WebSocket.CLOSED)
|
|
16
|
+
try {
|
|
17
|
+
t.ws.close(1e3, `Replacing connection for component ${o}`);
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
this.connections.delete(t);
|
|
21
|
+
});
|
|
22
|
+
const c = { ws: e, componentId: o };
|
|
23
|
+
this.connections.add(c), this.setupAutoRemove(e, c);
|
|
24
|
+
}
|
|
25
|
+
// 改进点:更彻底的连接关闭 + 内存泄漏防护
|
|
26
|
+
closeByComponentIds(e) {
|
|
27
|
+
const o = Array.isArray(e) ? e : [e], i = new Set(o);
|
|
28
|
+
Array.from(this.connections).filter(
|
|
29
|
+
(t) => i.has(t.componentId) && t.ws.readyState !== WebSocket.CLOSED
|
|
30
|
+
).forEach((t) => {
|
|
31
|
+
this.removeAllListeners(t.ws);
|
|
32
|
+
try {
|
|
33
|
+
t.ws.close(1e3, `Component ${t.componentId} unmounted`);
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
this.connections.delete(t);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// 辅助方法:清理事件监听器
|
|
40
|
+
removeAllListeners(e) {
|
|
41
|
+
const o = () => {
|
|
42
|
+
};
|
|
43
|
+
e.onopen = o, e.onmessage = o, e.onerror = o, e.onclose = o, "removeAllListeners" in e && e.removeAllListeners();
|
|
44
|
+
}
|
|
45
|
+
// 关闭所有连接
|
|
46
|
+
closeAll() {
|
|
47
|
+
this.connections.forEach((e) => {
|
|
48
|
+
if (e.ws.readyState === WebSocket.OPEN || e.ws.readyState === WebSocket.CONNECTING)
|
|
49
|
+
try {
|
|
50
|
+
e.ws.close(1e3, "All connections closed");
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}), this.connections.clear();
|
|
54
|
+
}
|
|
55
|
+
// 自动移除已关闭的连接
|
|
56
|
+
setupAutoRemove(e, o) {
|
|
57
|
+
const i = e.close.bind(e);
|
|
58
|
+
e.close = (c, t) => {
|
|
59
|
+
this.connections.delete(o), i(c, t);
|
|
60
|
+
}, e.onclose = () => {
|
|
61
|
+
this.connections.delete(o);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// 用于调试的方法
|
|
65
|
+
getConnectionsInfo() {
|
|
66
|
+
return Array.from(this.connections).map((e) => ({
|
|
67
|
+
componentId: e.componentId,
|
|
68
|
+
readyState: e.ws.readyState
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
// eslint-disable-next-line no-use-before-define
|
|
73
|
+
r(n, "instance");
|
|
74
|
+
let a = n;
|
|
75
|
+
const A = a.getInstance();
|
|
76
|
+
export {
|
|
77
|
+
A as wsManager
|
|
78
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IEvent } from '..';
|
|
2
|
-
/**
|
|
3
|
-
* 执行全屏行为
|
|
4
|
-
* @param event 事件
|
|
5
|
-
* @param params 参数
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare const executeFullScreenAction: (event: IEvent, params: any) => void;
|
|
1
|
+
import { IEvent } from '..';
|
|
2
|
+
/**
|
|
3
|
+
* 执行全屏行为
|
|
4
|
+
* @param event 事件
|
|
5
|
+
* @param params 参数
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const executeFullScreenAction: (event: IEvent, params: any) => void;
|