coolcare-lite-scada-component 4.1.7 → 4.1.8

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/shims.x6.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- // // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
- // import '@antv/x6'
3
- // import '@antv/x6-react-shape'
4
-
5
- // declare module '@antv/x6' {
6
- // interface Cell {
7
- // /** cell 的 tooltip 内容(React 组件) */
8
- // tooltipContent?: React.FunctionComponent<any>;
9
- // /** 是否禁用 resize */
10
- // disableResize?: boolean;
11
- // }
12
- // }
13
-
14
- // declare module '@antv/x6-react-shape' {
15
- // }
1
+ // // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ // import '@antv/x6'
3
+ // import '@antv/x6-react-shape'
4
+
5
+ // declare module '@antv/x6' {
6
+ // interface Cell {
7
+ // /** cell 的 tooltip 内容(React 组件) */
8
+ // tooltipContent?: React.FunctionComponent<any>;
9
+ // /** 是否禁用 resize */
10
+ // disableResize?: boolean;
11
+ // }
12
+ // }
13
+
14
+ // declare module '@antv/x6-react-shape' {
15
+ // }
package/es/typings.d.ts CHANGED
@@ -1,224 +1,224 @@
1
- /* eslint-disable @typescript-eslint/consistent-type-imports */
2
- interface Window {
3
- /** 组态模式:分编辑和查看 */
4
- scadaMode: 'edit' | 'player';
5
- graph: import('@antv/x6').Graph; // https://stackoverflow.com/a/58375303
6
- echarts: any;
7
- /** 开发调试时用的 */
8
- $emitter: import('mitt').Emitter<any>;
9
- }
10
-
11
- declare const REACT_APP_ENV: 'dev' | 'prod' | 'staging' | string;
12
-
13
- /**
14
- * 编辑场景
15
- * * production: 指定单个产品
16
- * * device: 指定单个设备
17
- * * freedom: 自由选择设备,可选择当前账号下有权限的设备。
18
- */
19
- type EditScene = 'product' | 'device' | 'freedom';
20
-
21
- type EditorQuery = { editor?: '2d' | '3d' } & (
22
- | {
23
- scene: 'product';
24
- /** scene = 'production' 时传 产品 id */
25
- productId: string;
26
- /** 产品版本号 */
27
- productVersionId: string;
28
- /** 组态类型:web | app */
29
- scadaType: '0' | '1';
30
- /** 来源 */
31
- from?: string;
32
- /** 公司 id */
33
- companyId: string;
34
- /** 项目 id */
35
- projectId?: string;
36
- }
37
- | {
38
- scene: 'device';
39
- /** 公司 id */
40
- companyId: string;
41
- /** 项目 id */
42
- projectId?: string;
43
- /** scene = 'device' 时传设备 id */
44
- deviceId: string;
45
- /** 组态类型:web | app */
46
- scadaType: '0' | '1';
47
- /** 来源 */
48
- from?: string;
49
- }
50
- | {
51
- scene: 'freedom';
52
- /** 组态 id */
53
- scadaId: string;
54
- /** 组态标题 */
55
- title: string;
56
- /** 来源 */
57
- from?: string;
58
- /** 公司 id */
59
- companyId: string;
60
- /** 项目 id */
61
- projectId?: string;
62
- // 权限
63
- premission?: string;
64
- }
65
- );
66
-
67
- type PlayerQuery =
68
- | {
69
- /** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
70
- env?: 'prod' | 'staging' | 'dev';
71
- /** 请求地址 */
72
- reqUrl?: string;
73
- /** 使用场景 */
74
- scene: 'product';
75
- /** scene = 'production' 时传 产品 id */
76
- productId: string;
77
- /** 产品版本号 */
78
- productVersionId: string;
79
- /** 组态类型:web | app */
80
- scadaType: '0' | '1';
81
- /** 开启 panning 选项来支持拖拽平移 */
82
- panningEnable?: 'true' | 'false';
83
- /** 缩放模式
84
- *
85
- * width: 等比缩放宽度铺满
86
- *
87
- * auto: 默认值,等比的情况下,尽量全屏铺满
88
- */
89
- zoomMode?: 'width' | 'auto';
90
- /** token */
91
- token?: string;
92
- /** 刷新token */
93
- xToken?: string;
94
- /** 公司 id */
95
- companyId: string;
96
- /** 项目 id */
97
- projectId?: string;
98
- }
99
- | {
100
- /** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
101
- env?: 'prod' | 'staging' | 'dev';
102
- /** 请求地址 */
103
- reqUrl?: string;
104
- /** 使用场景 */
105
- scene: 'device';
106
- /** scene = 'device' 时传设备 id */
107
- deviceId: string;
108
- /** 组态类型:web | app */
109
- scadaType: '0' | '1';
110
- /** 开启 panning 选项来支持拖拽平移 */
111
- panningEnable?: 'true' | 'false';
112
- /** 缩放模式
113
- *
114
- * width: 等比缩放宽度铺满
115
- *
116
- * auto: 默认值,等比的情况下,尽量全屏铺满
117
- */
118
- zoomMode?: 'width' | 'auto';
119
- /** token */
120
- token?: string;
121
- /** 刷新token */
122
- xToken?: string;
123
- }
124
- | {
125
- /** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
126
- env?: 'prod' | 'staging' | 'dev';
127
- /** 请求地址 */
128
- reqUrl?: string;
129
- /** 使用场景 */
130
- scene: 'freedom';
131
- /** 组态 id */
132
- scadaId: string;
133
- /** 公司 id */
134
- companyId: string;
135
- /** 开启 panning 选项来支持拖拽平移 */
136
- panningEnable?: 'true' | 'false';
137
- /** 缩放模式
138
- *
139
- * width: 等比缩放宽度铺满
140
- *
141
- * auto: 默认值,等比的情况下,尽量全屏铺满
142
- */
143
- zoomMode?: 'width' | 'auto';
144
- /** token */
145
- token?: string;
146
- /** 刷新token */
147
- xToken?: string;
148
- /** 项目 id */
149
- projectId?: string;
150
- /** 权限 */
151
- premission: string;
152
- };
153
-
154
- type WindowCommunicateMsg =
155
- | {
156
- event: 'product-scada-config-change';
157
- payload: {
158
- /** 组态配置 json 字符串 */
159
- data: string;
160
- productId: number;
161
- productVersionId?: number;
162
- scadaType: GatewayAPI.EProductConfigurationType;
163
- operationUserId?: number;
164
- configHasChanged?: boolean;
165
- configChangeLog?: string;
166
- };
167
- }
168
- | {
169
- // 通知 parent window 刷新当前设备组态
170
- event: 'device-scada-config-change';
171
- payload: {
172
- deviceId: number;
173
- operationUserId?: number;
174
- configHasChanged?: boolean;
175
- configChangeLog?: string;
176
- };
177
- }
178
- | {
179
- // 请求 parent window 发送产品组态配置
180
- event: 'request-product-scada-config';
181
- payload: {
182
- productId: number;
183
- productVersionId: number;
184
- scadaType: GatewayAPI.EProductConfigurationType;
185
- };
186
- }
187
- | {
188
- // parent window 发送产品组态配置到当前 window
189
- event: 'response-product-scada-config';
190
- /** 产品组态配置 */
191
- payload: any;
192
- };
193
-
194
- // #region 为 Object.keys 定义类型 start
195
- type ObjectKeys<T> = T extends Record<string, unknown>
196
- ? (keyof T)[]
197
- : T extends number
198
- ? []
199
- : T extends any[] | string
200
- ? string[]
201
- : never;
202
-
203
- declare const COOLCARE_LITE_SCADA_VERSION: string;
204
-
205
- interface ObjectConstructor {
206
- // eslint-disable-next-line @typescript-eslint/method-signature-style
207
- keys<T>(o: T): ObjectKeys<T>;
208
- }
209
- // #endregion 为 Object.keys 定义类型 end
210
-
211
- type NestedKeyOf<ObjectType extends Record<string, any>> = {
212
- [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends Record<
213
- string,
214
- unknown
215
- >
216
- ? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}`
217
- : `${Key}`;
218
- }[keyof ObjectType & (string | number)];
219
- type RequiredDeep<T> = T extends Record<string, unknown>
220
- ? {
221
- [key in keyof T]-?: RequiredDeep<T[key]>;
222
- }
223
- : T;
224
- type NodeDataPaths<T> = NestedKeyOf<RequiredDeep<T>>;
1
+ /* eslint-disable @typescript-eslint/consistent-type-imports */
2
+ interface Window {
3
+ /** 组态模式:分编辑和查看 */
4
+ scadaMode: 'edit' | 'player';
5
+ graph: import('@antv/x6').Graph; // https://stackoverflow.com/a/58375303
6
+ echarts: any;
7
+ /** 开发调试时用的 */
8
+ $emitter: import('mitt').Emitter<any>;
9
+ }
10
+
11
+ declare const REACT_APP_ENV: 'dev' | 'prod' | 'staging' | string;
12
+
13
+ /**
14
+ * 编辑场景
15
+ * * production: 指定单个产品
16
+ * * device: 指定单个设备
17
+ * * freedom: 自由选择设备,可选择当前账号下有权限的设备。
18
+ */
19
+ type EditScene = 'product' | 'device' | 'freedom';
20
+
21
+ type EditorQuery = { editor?: '2d' | '3d' } & (
22
+ | {
23
+ scene: 'product';
24
+ /** scene = 'production' 时传 产品 id */
25
+ productId: string;
26
+ /** 产品版本号 */
27
+ productVersionId: string;
28
+ /** 组态类型:web | app */
29
+ scadaType: '0' | '1';
30
+ /** 来源 */
31
+ from?: string;
32
+ /** 公司 id */
33
+ companyId: string;
34
+ /** 项目 id */
35
+ projectId?: string;
36
+ }
37
+ | {
38
+ scene: 'device';
39
+ /** 公司 id */
40
+ companyId: string;
41
+ /** 项目 id */
42
+ projectId?: string;
43
+ /** scene = 'device' 时传设备 id */
44
+ deviceId: string;
45
+ /** 组态类型:web | app */
46
+ scadaType: '0' | '1';
47
+ /** 来源 */
48
+ from?: string;
49
+ }
50
+ | {
51
+ scene: 'freedom';
52
+ /** 组态 id */
53
+ scadaId: string;
54
+ /** 组态标题 */
55
+ title: string;
56
+ /** 来源 */
57
+ from?: string;
58
+ /** 公司 id */
59
+ companyId: string;
60
+ /** 项目 id */
61
+ projectId?: string;
62
+ // 权限
63
+ premission?: string;
64
+ }
65
+ );
66
+
67
+ type PlayerQuery =
68
+ | {
69
+ /** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
70
+ env?: 'prod' | 'staging' | 'dev';
71
+ /** 请求地址 */
72
+ reqUrl?: string;
73
+ /** 使用场景 */
74
+ scene: 'product';
75
+ /** scene = 'production' 时传 产品 id */
76
+ productId: string;
77
+ /** 产品版本号 */
78
+ productVersionId: string;
79
+ /** 组态类型:web | app */
80
+ scadaType: '0' | '1';
81
+ /** 开启 panning 选项来支持拖拽平移 */
82
+ panningEnable?: 'true' | 'false';
83
+ /** 缩放模式
84
+ *
85
+ * width: 等比缩放宽度铺满
86
+ *
87
+ * auto: 默认值,等比的情况下,尽量全屏铺满
88
+ */
89
+ zoomMode?: 'width' | 'auto';
90
+ /** token */
91
+ token?: string;
92
+ /** 刷新token */
93
+ xToken?: string;
94
+ /** 公司 id */
95
+ companyId: string;
96
+ /** 项目 id */
97
+ projectId?: string;
98
+ }
99
+ | {
100
+ /** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
101
+ env?: 'prod' | 'staging' | 'dev';
102
+ /** 请求地址 */
103
+ reqUrl?: string;
104
+ /** 使用场景 */
105
+ scene: 'device';
106
+ /** scene = 'device' 时传设备 id */
107
+ deviceId: string;
108
+ /** 组态类型:web | app */
109
+ scadaType: '0' | '1';
110
+ /** 开启 panning 选项来支持拖拽平移 */
111
+ panningEnable?: 'true' | 'false';
112
+ /** 缩放模式
113
+ *
114
+ * width: 等比缩放宽度铺满
115
+ *
116
+ * auto: 默认值,等比的情况下,尽量全屏铺满
117
+ */
118
+ zoomMode?: 'width' | 'auto';
119
+ /** token */
120
+ token?: string;
121
+ /** 刷新token */
122
+ xToken?: string;
123
+ }
124
+ | {
125
+ /** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
126
+ env?: 'prod' | 'staging' | 'dev';
127
+ /** 请求地址 */
128
+ reqUrl?: string;
129
+ /** 使用场景 */
130
+ scene: 'freedom';
131
+ /** 组态 id */
132
+ scadaId: string;
133
+ /** 公司 id */
134
+ companyId: string;
135
+ /** 开启 panning 选项来支持拖拽平移 */
136
+ panningEnable?: 'true' | 'false';
137
+ /** 缩放模式
138
+ *
139
+ * width: 等比缩放宽度铺满
140
+ *
141
+ * auto: 默认值,等比的情况下,尽量全屏铺满
142
+ */
143
+ zoomMode?: 'width' | 'auto';
144
+ /** token */
145
+ token?: string;
146
+ /** 刷新token */
147
+ xToken?: string;
148
+ /** 项目 id */
149
+ projectId?: string;
150
+ /** 权限 */
151
+ premission: string;
152
+ };
153
+
154
+ type WindowCommunicateMsg =
155
+ | {
156
+ event: 'product-scada-config-change';
157
+ payload: {
158
+ /** 组态配置 json 字符串 */
159
+ data: string;
160
+ productId: number;
161
+ productVersionId?: number;
162
+ scadaType: GatewayAPI.EProductConfigurationType;
163
+ operationUserId?: number;
164
+ configHasChanged?: boolean;
165
+ configChangeLog?: string;
166
+ };
167
+ }
168
+ | {
169
+ // 通知 parent window 刷新当前设备组态
170
+ event: 'device-scada-config-change';
171
+ payload: {
172
+ deviceId: number;
173
+ operationUserId?: number;
174
+ configHasChanged?: boolean;
175
+ configChangeLog?: string;
176
+ };
177
+ }
178
+ | {
179
+ // 请求 parent window 发送产品组态配置
180
+ event: 'request-product-scada-config';
181
+ payload: {
182
+ productId: number;
183
+ productVersionId: number;
184
+ scadaType: GatewayAPI.EProductConfigurationType;
185
+ };
186
+ }
187
+ | {
188
+ // parent window 发送产品组态配置到当前 window
189
+ event: 'response-product-scada-config';
190
+ /** 产品组态配置 */
191
+ payload: any;
192
+ };
193
+
194
+ // #region 为 Object.keys 定义类型 start
195
+ type ObjectKeys<T> = T extends Record<string, unknown>
196
+ ? (keyof T)[]
197
+ : T extends number
198
+ ? []
199
+ : T extends any[] | string
200
+ ? string[]
201
+ : never;
202
+
203
+ declare const COOLCARE_LITE_SCADA_VERSION: string;
204
+
205
+ interface ObjectConstructor {
206
+ // eslint-disable-next-line @typescript-eslint/method-signature-style
207
+ keys<T>(o: T): ObjectKeys<T>;
208
+ }
209
+ // #endregion 为 Object.keys 定义类型 end
210
+
211
+ type NestedKeyOf<ObjectType extends Record<string, any>> = {
212
+ [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends Record<
213
+ string,
214
+ unknown
215
+ >
216
+ ? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}`
217
+ : `${Key}`;
218
+ }[keyof ObjectType & (string | number)];
219
+ type RequiredDeep<T> = T extends Record<string, unknown>
220
+ ? {
221
+ [key in keyof T]-?: RequiredDeep<T[key]>;
222
+ }
223
+ : T;
224
+ type NodeDataPaths<T> = NestedKeyOf<RequiredDeep<T>>;
@@ -1,7 +1,7 @@
1
- /**
2
- * 获取元素的指定CSS属性值
3
- * @param ele HTML 元素
4
- * @param propKey 属性名
1
+ /**
2
+ * 获取元素的指定CSS属性值
3
+ * @param ele HTML 元素
4
+ * @param propKey 属性名
5
5
  */
6
6
  export function getCssStyle(ele, propKey) {
7
7
  if (!ele || !propKey) {
@@ -1,10 +1,10 @@
1
1
  var degrees = 180 / Math.PI;
2
2
 
3
- /**
4
- * 将 matrix 分解成 translate scale skew rotate
5
- * https:// github.com/d3/d3-interpolate/blob/main/src/transform/decompose.js#L12-L25
6
- * @param matrix
7
- * @returns
3
+ /**
4
+ * 将 matrix 分解成 translate scale skew rotate
5
+ * https:// github.com/d3/d3-interpolate/blob/main/src/transform/decompose.js#L12-L25
6
+ * @param matrix
7
+ * @returns
8
8
  */
9
9
  export default function decompose(matrix) {
10
10
  var a = matrix.a,
@@ -1,11 +1,46 @@
1
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1
4
  import mitt from 'mitt';
2
5
 
3
- /**
4
- * 事件命令空间
5
- * * 添加原因:如果一个页面有多个组态实例(Play 页面会当成组件使用, 并显示多个),那么事件通信就会乱
6
+ /**
7
+ * 事件命令空间
8
+ * * 添加原因:如果一个页面有多个组态实例(Play 页面会当成组件使用, 并显示多个),那么事件通信就会乱
6
9
  */
7
10
 
8
11
  var emitter = mitt();
12
+
13
+ // X6 mounts React shapes in scheduled tasks. Replay the latest payload to late
14
+ // subscribers (and remounted shapes), instead of waiting for the next poll.
15
+ var pointSnapshots = new Map();
16
+ var on = emitter.on;
17
+ var emit = emitter.emit;
18
+ emitter.on = function (type, handler) {
19
+ on(type, handler);
20
+ if (typeof type === 'string' && pointSnapshots.has(type)) {
21
+ handler(pointSnapshots.get(type));
22
+ }
23
+ };
24
+ emitter.emit = function (type, payload) {
25
+ if (typeof type === 'string' && type.startsWith('point-update-')) {
26
+ pointSnapshots.set(type, payload);
27
+ }
28
+ emit(type, payload);
29
+ };
30
+ export function clearPointSnapshots(events) {
31
+ var _iterator = _createForOfIteratorHelper(events),
32
+ _step;
33
+ try {
34
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
35
+ var event = _step.value;
36
+ pointSnapshots.delete(event);
37
+ }
38
+ } catch (err) {
39
+ _iterator.e(err);
40
+ } finally {
41
+ _iterator.f();
42
+ }
43
+ }
9
44
  if (process.env.NODE_ENV === 'development') {
10
45
  // TODO 把注释加回来
11
46
  window.$emitter = emitter;