@shjjs/visual-ui 1.0.35 → 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.
Files changed (215) hide show
  1. package/es/commons/core/earth/main.vue.d.ts +2 -2
  2. package/es/commons/core/useChart.mjs +257 -73
  3. package/es/components/chart/commons/components/common-chart/index.vue.mjs +213 -30
  4. package/es/components/chart/commons/components/common-chart-map/index.vue.mjs +210 -27
  5. package/es/components/chart/commons/hooks/useChart.mjs +261 -77
  6. package/es/components/chart/src/map/bmap-basic/index.vue.d.ts +6 -2
  7. package/es/components/chart/src/map/bmap-heatmap/index.vue.d.ts +6 -2
  8. package/es/components/chart-other-candlestick-basic/index.vue.mjs +212 -29
  9. package/es/components/chart-other-candlestick-demo/index.vue.mjs +213 -30
  10. package/es/components/chart-other-candlestick-shanghai/index.vue.mjs +214 -31
  11. package/es/components/chart-other-circular-graph/index.vue.mjs +214 -31
  12. package/es/components/chart-other-force/index.vue.mjs +212 -29
  13. package/es/components/chart-other-force2/index.vue.mjs +212 -29
  14. package/es/components/chart-other-funnel/index.vue.mjs +214 -31
  15. package/es/components/chart-other-funnel-contrast/index.vue.mjs +214 -31
  16. package/es/components/chart-other-funnel-split/index.vue.mjs +214 -31
  17. package/es/components/chart-other-funnel2/index.vue.mjs +214 -31
  18. package/es/components/chart-other-gauge/index.vue.mjs +214 -31
  19. package/es/components/chart-other-gauge-grade/index.vue.mjs +214 -31
  20. package/es/components/chart-other-gauge-stage/index.vue.mjs +214 -31
  21. package/es/components/chart-other-graph-basic/index.vue.mjs +214 -31
  22. package/es/components/chart-other-graph-basic2/index.vue.mjs +214 -31
  23. package/es/components/chart-other-graph-calendar/index.vue.mjs +214 -31
  24. package/es/components/chart-other-grid-percentage/index.vue.mjs +218 -35
  25. package/es/components/chart-other-heatmap/index.vue.mjs +212 -29
  26. package/es/components/chart-other-label-gauge/index.vue.mjs +216 -33
  27. package/es/components/chart-other-liquidfill/index.vue.mjs +214 -31
  28. package/es/components/chart-other-parallel-basic/index.vue.mjs +214 -31
  29. package/es/components/chart-other-parallel-mul/index.vue.mjs +211 -28
  30. package/es/components/chart-other-radar/index.vue.mjs +224 -41
  31. package/es/components/chart-other-radar-stack/index.vue.mjs +211 -28
  32. package/es/components/chart-other-sunburst-basic/index.vue.mjs +212 -29
  33. package/es/components/chart-other-sunburst-basic2/index.vue.mjs +212 -29
  34. package/es/components/chart-other-sunburst-basic3/index.vue.mjs +212 -29
  35. package/es/components/chart-other-sunburst-basic4/index.vue.mjs +212 -29
  36. package/es/components/chart-other-sunburst-book/index.vue.mjs +212 -29
  37. package/es/components/chart-other-sunburst-flavors/index.vue.mjs +214 -31
  38. package/es/components/chart-other-sunburst-radius/index.vue.mjs +212 -29
  39. package/es/components/chart-other-theme-river/index.vue.mjs +216 -33
  40. package/es/components/chart-other-tree/index.vue.mjs +214 -31
  41. package/es/components/chart-other-tree-line/index.vue.mjs +214 -31
  42. package/es/components/chart-other-treemap/index.vue.mjs +214 -31
  43. package/es/components/chart-other-treemap-basic/index.vue.mjs +214 -31
  44. package/es/components/chart-other-word-cloud/index.vue.mjs +216 -33
  45. package/es/components/commons-echarts/compileAndRunEcharts.mjs +219 -35
  46. package/es/components/commons-loop-iterator/index.vue.mjs +2 -2
  47. package/es/components/commons-loop-iterator/index.vue2.mjs +218 -35
  48. package/es/components/commons-product-model/index.vue.mjs +1 -1
  49. package/es/components/commons-product-model/index.vue2.mjs +246 -62
  50. package/es/components/commons-three-loader/index.vue.mjs +1 -1
  51. package/es/components/commons-three-loader/index.vue2.mjs +257 -73
  52. package/es/components/commons-three-loader3/index.vue.mjs +2 -2
  53. package/es/components/commons-three-loader3/index.vue2.mjs +301 -117
  54. package/es/components/commons-weather/index.vue.mjs +1 -1
  55. package/es/components/commons-weather/index.vue2.mjs +233 -48
  56. package/es/components/commons-weather-dynamic/index.vue.mjs +2 -2
  57. package/es/components/commons-weather-dynamic/index.vue2.mjs +236 -52
  58. package/es/components/index.d.ts +112 -111
  59. package/es/components/index.mjs +362 -360
  60. package/es/components/interaction/button/index.vue.mjs +2 -2
  61. package/es/components/interaction/button/index.vue2.mjs +252 -68
  62. package/es/components/interaction/date-picker/components/common-date-picker/index.vue.mjs +2 -2
  63. package/es/components/interaction/date-picker/components/common-date-picker/index.vue2.mjs +324 -140
  64. package/es/components/interaction/date-picker/src/date-picker/index.d.ts +211 -211
  65. package/es/components/interaction/date-picker/src/date-picker/index.vue.d.ts +211 -211
  66. package/es/components/interaction/date-picker/src/date-picker-range/index.d.ts +211 -211
  67. package/es/components/interaction/date-picker/src/date-picker-range/index.vue.d.ts +211 -211
  68. package/es/components/interaction/tabs/index.vue.mjs +223 -39
  69. package/es/components/interaction/tabs-icon/index.vue.mjs +225 -41
  70. package/es/components/interaction-input/index.vue.mjs +2 -2
  71. package/es/components/interaction-input/index.vue2.mjs +244 -61
  72. package/es/components/interaction-select/index.vue.mjs +1 -1
  73. package/es/components/interaction-select/index.vue2.mjs +269 -86
  74. package/es/components/interaction-slider/index.vue.mjs +2 -2
  75. package/es/components/interaction-slider/index.vue2.mjs +248 -65
  76. package/es/components/interaction-switch/index.vue.mjs +1 -1
  77. package/es/components/interaction-switch/index.vue2.mjs +217 -33
  78. package/es/components/interaction-tabs/index.vue.mjs +2 -2
  79. package/es/components/interaction-tabs/index.vue2.mjs +221 -37
  80. package/es/components/interaction-tabs2/index.vue.mjs +1 -1
  81. package/es/components/interaction-tabs2/index.vue2.mjs +219 -35
  82. package/es/components/map-earth-basic/index.d.ts +2 -2
  83. package/es/components/map-earth-basic/index.vue.d.ts +2 -2
  84. package/es/components/map-earth-basic/index.vue.mjs +286 -103
  85. package/es/components/map-earth-cool-tech/index.d.ts +2 -2
  86. package/es/components/map-earth-cool-tech/index.vue.d.ts +2 -2
  87. package/es/components/map-earth-cool-tech/index.vue.mjs +286 -103
  88. package/es/components/map-earth-fly-line/index.d.ts +2 -2
  89. package/es/components/map-earth-fly-line/index.vue.d.ts +2 -2
  90. package/es/components/map-earth-fly-line/index.vue.mjs +286 -103
  91. package/es/components/map-earth-hacker/index.d.ts +2 -2
  92. package/es/components/map-earth-hacker/index.vue.d.ts +2 -2
  93. package/es/components/map-earth-hacker/index.vue.mjs +286 -103
  94. package/es/components/map-earth-particle/index.d.ts +2 -2
  95. package/es/components/map-earth-particle/index.vue.d.ts +2 -2
  96. package/es/components/map-earth-particle/index.vue.mjs +286 -103
  97. package/es/components/media-audio/index.vue.mjs +2 -2
  98. package/es/components/media-audio/index.vue2.mjs +219 -35
  99. package/es/components/media-audio-dynamic/index.vue.mjs +1 -1
  100. package/es/components/media-audio-dynamic/index.vue2.mjs +233 -50
  101. package/es/components/media-flv/index.vue.mjs +219 -35
  102. package/es/components/media-iframe/index.vue.mjs +2 -2
  103. package/es/components/media-iframe/index.vue2.mjs +199 -15
  104. package/es/components/media-iframe-dynamic/index.d.ts +51 -0
  105. package/es/components/media-iframe-dynamic/index.mjs +7 -0
  106. package/es/components/media-iframe-dynamic/index.vue.d.ts +51 -0
  107. package/es/components/media-iframe-dynamic/index.vue.mjs +7 -0
  108. package/es/components/media-iframe-dynamic/index.vue2.mjs +259 -0
  109. package/es/components/media-image-dynamic/index.vue.mjs +2 -2
  110. package/es/components/media-image-dynamic/index.vue2.mjs +207 -24
  111. package/es/components/media-m3u8/index.vue.mjs +221 -37
  112. package/es/components/media-m3u8-dynamic/index.vue.mjs +228 -45
  113. package/es/components/media-video/index.vue.mjs +2 -2
  114. package/es/components/media-video/index.vue2.mjs +216 -31
  115. package/es/components/media-video-dynamic/index.vue.mjs +2 -2
  116. package/es/components/media-video-dynamic/index.vue2.mjs +223 -40
  117. package/es/components/scene-amap2d/index.vue.mjs +1 -1
  118. package/es/components/scene-amap2d/index.vue2.mjs +376 -192
  119. package/es/components/scene-amap3d/index.vue.mjs +2 -2
  120. package/es/components/scene-amap3d/index.vue2.mjs +414 -231
  121. package/es/components/scene-default/index.vue.mjs +2 -2
  122. package/es/components/scene-default/index.vue2.mjs +201 -16
  123. package/es/components/scene-map3d/index.vue.mjs +2 -2
  124. package/es/components/scene-map3d/index.vue2.mjs +289 -106
  125. package/es/components/scene-ue-iframe/index.vue.mjs +2 -2
  126. package/es/components/scene-ue-iframe/index.vue2.mjs +212 -27
  127. package/es/components/scene-ue-shj/index.vue.mjs +2 -2
  128. package/es/components/scene-ue-shj/index.vue2.mjs +200 -15
  129. package/es/components/scene-unity-iframe/index.vue.mjs +1 -1
  130. package/es/components/scene-unity-iframe/index.vue2.mjs +204 -19
  131. package/es/components/scene-unity-webgl/index.vue.mjs +2 -2
  132. package/es/components/scene-unity-webgl/index.vue2.mjs +204 -19
  133. package/es/components/scene-vr/index.vue.mjs +2 -2
  134. package/es/components/scene-vr/index.vue2.mjs +302 -118
  135. package/es/components/text/list/index.vue.mjs +240 -56
  136. package/es/components/text-count-down/index.vue.mjs +2 -2
  137. package/es/components/text-count-down/index.vue2.mjs +245 -60
  138. package/es/components/text-over-number/index.vue.mjs +2 -2
  139. package/es/components/text-over-number/index.vue2.mjs +243 -60
  140. package/es/components/text-real-time/index.vue.mjs +2 -2
  141. package/es/components/text-real-time/index.vue2.mjs +212 -28
  142. package/es/components/text-row-scroll/index.vue.mjs +1 -1
  143. package/es/components/text-row-scroll/index.vue2.mjs +288 -105
  144. package/es/components/text-table-basic/index.vue.mjs +2 -2
  145. package/es/components/text-table-basic/index.vue2.mjs +286 -103
  146. package/es/components/text-table-scroll/index.vue.mjs +2 -2
  147. package/es/components/text-table-scroll/index.vue2.mjs +291 -108
  148. package/es/components/text-text-dynamic/index.vue.mjs +2 -2
  149. package/es/components/text-text-dynamic/index.vue2.mjs +218 -35
  150. package/es/index.d.ts +1 -0
  151. package/es/index.mjs +386 -370
  152. package/es/{commons/plugins → plugins}/datasource/index.mjs +217 -214
  153. package/es/{commons/plugins → plugins}/datasource/sources/api.mjs +32 -32
  154. package/es/{commons/plugins → plugins}/datasource/sources/static.mjs +17 -17
  155. package/es/{commons/plugins → plugins}/datasource/sources/storage.mjs +28 -28
  156. package/es/{commons/plugins → plugins}/datasource/sources/url.mjs +17 -17
  157. package/es/{commons/plugins → plugins}/datasource/sources/variable.mjs +17 -17
  158. package/es/{commons/plugins → plugins}/datasource/sources/ws.mjs +139 -139
  159. package/es/{commons/plugins → plugins}/datasource/utils/axios.mjs +134 -134
  160. package/es/{commons/plugins → plugins}/datasource/utils/request.mjs +5 -5
  161. package/es/{commons/plugins → plugins}/datasource/utils/utils.mjs +229 -229
  162. package/es/{commons/plugins → plugins}/datasource/utils/wsManager.mjs +78 -78
  163. package/es/{commons/plugins → plugins}/event/actions/fullScreenAction.mjs +8 -8
  164. package/es/{commons/plugins → plugins}/event/actions/invokeAction.mjs +11 -11
  165. package/es/{commons/plugins → plugins}/event/actions/linkAction.mjs +8 -8
  166. package/es/{commons/plugins → plugins}/event/actions/moveAction.mjs +15 -15
  167. package/es/{commons/plugins → plugins}/event/actions/refreshVariableAction.mjs +18 -18
  168. package/es/{commons/plugins → plugins}/event/actions/rotateAction.mjs +19 -19
  169. package/es/{commons/plugins → plugins}/event/actions/scaleAction.mjs +24 -24
  170. package/es/{commons/plugins → plugins}/event/actions/sendApiAction.mjs +16 -16
  171. package/es/{commons/plugins → plugins}/event/actions/ueCommonsWebscoketAction.mjs +31 -31
  172. package/es/{commons/plugins → plugins}/event/actions/ueShjExecMethodAction.mjs +31 -31
  173. package/es/{commons/plugins → plugins}/event/actions/unityIframeExecMethodAction.mjs +28 -28
  174. package/es/{commons/plugins → plugins}/event/actions/unityWebglExecMethodAction.mjs +28 -28
  175. package/es/{commons/plugins → plugins}/event/actions/updatePageAction.mjs +6 -6
  176. package/es/{commons/plugins → plugins}/event/actions/updateVariableAction.mjs +25 -25
  177. package/es/{commons/plugins → plugins}/event/actions/updateWidgetAction.mjs +14 -14
  178. package/es/{commons/plugins → plugins}/event/actions/vrSceneMethodAction.mjs +12 -12
  179. package/es/{commons/plugins → plugins}/event/index.mjs +161 -161
  180. package/es/{commons/plugins → plugins}/event/utils/utils.mjs +50 -50
  181. package/es/{commons → plugins}/utils/componentRefs.mjs +37 -37
  182. package/es/{commons → plugins}/utils/getNextElement.mjs +12 -12
  183. package/es/widgets.css +1 -1
  184. package/package.json +1 -1
  185. package/es/commons/plugins/datasource/index.d.ts +0 -73
  186. package/es/commons/plugins/datasource/sources/api.d.ts +0 -1
  187. package/es/commons/plugins/datasource/sources/static.d.ts +0 -1
  188. package/es/commons/plugins/datasource/sources/storage.d.ts +0 -1
  189. package/es/commons/plugins/datasource/sources/url.d.ts +0 -1
  190. package/es/commons/plugins/datasource/sources/variable.d.ts +0 -1
  191. package/es/commons/plugins/datasource/sources/ws.d.ts +0 -32
  192. package/es/commons/plugins/datasource/utils/axios.d.ts +0 -70
  193. package/es/commons/plugins/datasource/utils/request.d.ts +0 -3
  194. package/es/commons/plugins/datasource/utils/utils.d.ts +0 -115
  195. package/es/commons/plugins/datasource/utils/wsManager.d.ts +0 -16
  196. package/es/commons/plugins/event/actions/fullScreenAction.d.ts +0 -8
  197. package/es/commons/plugins/event/actions/invokeAction.d.ts +0 -8
  198. package/es/commons/plugins/event/actions/linkAction.d.ts +0 -8
  199. package/es/commons/plugins/event/actions/moveAction.d.ts +0 -8
  200. package/es/commons/plugins/event/actions/refreshVariableAction.d.ts +0 -7
  201. package/es/commons/plugins/event/actions/rotateAction.d.ts +0 -8
  202. package/es/commons/plugins/event/actions/scaleAction.d.ts +0 -8
  203. package/es/commons/plugins/event/actions/sendApiAction.d.ts +0 -8
  204. package/es/commons/plugins/event/actions/ueCommonsWebscoketAction.d.ts +0 -7
  205. package/es/commons/plugins/event/actions/ueShjExecMethodAction.d.ts +0 -7
  206. package/es/commons/plugins/event/actions/unityIframeExecMethodAction.d.ts +0 -7
  207. package/es/commons/plugins/event/actions/unityWebglExecMethodAction.d.ts +0 -7
  208. package/es/commons/plugins/event/actions/updatePageAction.d.ts +0 -8
  209. package/es/commons/plugins/event/actions/updateVariableAction.d.ts +0 -7
  210. package/es/commons/plugins/event/actions/updateWidgetAction.d.ts +0 -7
  211. package/es/commons/plugins/event/actions/vrSceneMethodAction.d.ts +0 -7
  212. package/es/commons/plugins/event/index.d.ts +0 -206
  213. package/es/commons/plugins/event/utils/utils.d.ts +0 -22
  214. package/es/commons/utils/componentRefs.d.ts +0 -28
  215. package/es/commons/utils/getNextElement.d.ts +0 -7
@@ -1,214 +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 W } from "./sources/variable.mjs";
8
- import { parseAPIPort as $ } from "./sources/api.mjs";
9
- import { parseWebSocket as M } from "./sources/ws.mjs";
10
- import { DataSourceUtils as T } from "./utils/utils.mjs";
11
- import { parseStorage as N } from "./sources/storage.mjs";
12
- const D = class D {
13
- static addParser(t, a) {
14
- this.parsers.add({ type: t, parser: a });
15
- }
16
- static getParser(t) {
17
- const a = Array.from(this.parsers).find((e) => e.type === t);
18
- return a == null ? void 0 : a.parser;
19
- }
20
- /**
21
- * 解析数据源
22
- * @param sources 数据源
23
- * @param callback 回调函数
24
- * @param tId 组件id
25
- * @param isStore 是否存储
26
- * @param noUseMapping 是否不使用映射
27
- * @param isInterval 是否开启定时任务
28
- * @returns
29
- */
30
- static parse({ sources: t, callback: a, tId: e, isStore: s = !1, noUseMapping: i = !1, isInterval: n = !0 }) {
31
- return a ?? (a = () => {
32
- }), t && F(t) && t.length > 0 && t[0] ? new Promise((p, o) => {
33
- T.cleanupPreviousWebSockets(this.wsInstances, t.map((r) => r.id), e);
34
- const h = /* @__PURE__ */ new Set(), l = this.wsInstances.get(e) || /* @__PURE__ */ new Set();
35
- t.forEach((r) => {
36
- var u;
37
- if (n) {
38
- const { source: f } = r;
39
- if (!f) {
40
- a([]), p([]);
41
- return;
42
- }
43
- const d = `${e}-${r.id}`, m = this.datasourceTimer.findIndex((S) => S.id === d);
44
- if (m !== -1 && (clearInterval(this.datasourceTimer[m].timer), this.datasourceTimer.splice(m, 1)), f.isAutoUpdate) {
45
- const S = setInterval(() => {
46
- var g;
47
- (g = this.task(r, s, i, e, (c) => {
48
- a(c);
49
- })) == null || g.then((c) => {
50
- p(c);
51
- });
52
- }, f.autoUpdateTime * 1e3);
53
- this.datasourceTimer.push({ id: d, timer: S });
54
- }
55
- }
56
- if (r.source.type !== "ws") {
57
- (u = this.task(r, s, i, e, (f) => a(f))) == null || u.then((f) => p(f));
58
- return;
59
- }
60
- if (T.hasValidWebSocket(this.wsInstances, e, r.id))
61
- l.forEach((f) => {
62
- f.getId() === r.id && h.add(f);
63
- });
64
- else {
65
- const f = M(r, r.id, i, e, (d) => {
66
- p(d), a({ data: [{ data: d.finalUserData.data }] }), this.taskStorage(t, d.finalUserData.data);
67
- });
68
- h.add(f);
69
- }
70
- }), h.size > 0 && this.wsInstances.set(e, h);
71
- }) : (a([]), Promise.resolve([]));
72
- }
73
- /**
74
- * 执行数据源任务
75
- * @param sources 数据源
76
- * @param isStore 是否存储
77
- * @param noUseMapping 是否不使用映射
78
- * @param tId 组件id
79
- * @param callback 回调函数
80
- * @returns
81
- */
82
- static task(t, a = !1, e = !1, s, i = () => {
83
- }) {
84
- return t ? new Promise((n, p) => {
85
- let o = null;
86
- const { source: h } = t, l = this.getParser(h.type);
87
- l && (o = l(t, t.id, e)), o.then((r) => {
88
- n(r), e && (this.taskStorage(t, r.noMappingData), i(r.noMappingData)), e || (this.taskStorage(t, r.finalKeyData), i(r.finalKeyData));
89
- });
90
- }) : (i([]), Promise.resolve([]));
91
- }
92
- /**
93
- * 过滤数据
94
- * @param filter 过滤器
95
- * @param data 数据
96
- * @returns
97
- */
98
- static filterData(t, a) {
99
- return new Promise((e, s) => {
100
- if (b(t)) {
101
- try {
102
- const i = T.getVariableData();
103
- let n = `
104
- ${t}
105
-
106
- // 在这里调用 filter 函数,并传递 data 参数
107
- return filter(data);
108
- `;
109
- n = n.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, ""), n = T.replaceStringVariables(n, i);
110
- const p = new Function("data", n);
111
- e(p(a));
112
- } catch {
113
- e(a);
114
- }
115
- return;
116
- }
117
- e(a);
118
- });
119
- }
120
- /**
121
- * 处理数据
122
- * @param filter 过滤器
123
- * @param data 数据
124
- * @param mappings 映射
125
- * @param id 组件id
126
- * @param dynamicMapping 是否动态映射
127
- * @param noUseMapping 是否不使用映射
128
- * @returns
129
- */
130
- static processData(t, a, e, s, i, n, p) {
131
- return new Promise(function(o) {
132
- const h = P({ id: s, data: a });
133
- D.filterData(t, a).then((l) => {
134
- const r = P({ id: s, data: l });
135
- if (n)
136
- o({
137
- id: s,
138
- finalKeyData: [],
139
- finalUserData: { id: s, data: l },
140
- filteredData: r,
141
- rawData: h,
142
- noMappingData: l
143
- });
144
- else {
145
- let u = [];
146
- F(l) && (u = l.map((m, S) => {
147
- const g = {};
148
- if (i && i && S === 0) {
149
- const c = [];
150
- for (const y in m) {
151
- const k = e.find((x) => x.name === y);
152
- 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 });
153
- }
154
- e.splice(0, e.length), e.push(...c);
155
- }
156
- return e.forEach((c) => {
157
- try {
158
- c.alias ? g[c.alias] = m[c.mapping] : g[c.name] = m[c.mapping];
159
- } catch {
160
- }
161
- }), p && (g.userdata = m), g;
162
- }));
163
- const f = P({ id: s, data: u }), d = P({ id: s, data: D.parseMappedData(u, e, s) });
164
- o({
165
- id: s,
166
- finalKeyData: u.length === 0 ? { id: s, data: l } : d,
167
- finalUserData: u.length === 0 ? { id: s, data: l } : f,
168
- filteredData: r,
169
- rawData: h,
170
- noMappingData: []
171
- });
172
- }
173
- });
174
- });
175
- }
176
- /**
177
- * 解析数据为Key、Data格式
178
- * @param data 数据
179
- * @param mappings 映射
180
- * @param id 组件id
181
- * @returns
182
- */
183
- static parseMappedData(t, a, e) {
184
- return t.reduce(
185
- (s, i) => {
186
- let n = "系列一";
187
- 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]);
188
- const p = s.find((o) => o.key === n);
189
- return p ? p.data.push(i) : s.push({ key: n, data: [i] }), s;
190
- },
191
- []
192
- );
193
- }
194
- /**
195
- * 处理数据存储
196
- * @param sources 数据源
197
- * @returns
198
- */
199
- static taskStorage(t, a) {
200
- const { source: e } = t;
201
- 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)));
202
- }
203
- };
204
- I(D, "wsInstances", /* @__PURE__ */ new Map()), I(D, "datasourceTimer", []), I(D, "parsers", /* @__PURE__ */ new Set([
205
- { type: "url", parser: E },
206
- { type: "static", parser: j },
207
- { type: "variable", parser: W },
208
- { type: "api", parser: $ },
209
- { type: "storage", parser: N }
210
- ]));
211
- let K = D;
212
- export {
213
- K as SHJDatasourceV2
214
- };
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
+ };
@@ -1,32 +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
- };
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
+ };
@@ -1,17 +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
- };
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
+ };
@@ -1,28 +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
- };
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
+ };
@@ -1,17 +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
- };
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
+ };