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/utils/index.js CHANGED
@@ -7,11 +7,11 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
7
  export * from "./type";
8
8
  export * from "./getMittMeta";
9
9
  export { default as queryToObject } from "./queryToObject";
10
- /**
11
- * 交换数组元素
12
- * @param arr 数组
13
- * @param index1 元素下标1
14
- * @param index2 元素下标2
10
+ /**
11
+ * 交换数组元素
12
+ * @param arr 数组
13
+ * @param index1 元素下标1
14
+ * @param index2 元素下标2
15
15
  */
16
16
  export function arrayEleSwap(arr, index1, index2) {
17
17
  var temp = arr[index1];
@@ -19,10 +19,10 @@ export function arrayEleSwap(arr, index1, index2) {
19
19
  arr[index2] = temp;
20
20
  }
21
21
 
22
- /**
23
- * 计算鼠标相对事件触发的 currentTarget 元素的相对位置
24
- * @param e
25
- * @returns { x: number; y: number }
22
+ /**
23
+ * 计算鼠标相对事件触发的 currentTarget 元素的相对位置
24
+ * @param e
25
+ * @returns { x: number; y: number }
26
26
  */
27
27
  export function calculateMousePosition(e) {
28
28
  var currentTarget = e.currentTarget;
@@ -33,17 +33,17 @@ export function calculateMousePosition(e) {
33
33
  };
34
34
  }
35
35
 
36
- /**
37
- * 特殊字符转义,防止特殊字符导致json字符串转换成json对象出错
38
- * @param {*} string
39
- * @returns string
36
+ /**
37
+ * 特殊字符转义,防止特殊字符导致json字符串转换成json对象出错
38
+ * @param {*} string
39
+ * @returns string
40
40
  */
41
41
  export var transSpecialChar = function transSpecialChar(string) {
42
42
  return string.replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/ /g, '&nbsp;').replace(/(")+/g, '"').replace(/'/g, '&#39;').replace(/\r/g, '\\r').replace(/\n/g, '\\n').replace(/\t/g, '\\t').replace(/\\/g, '\\\\');
43
43
  };
44
44
 
45
- /**
46
- * 判断电脑是 window 还是 mac
45
+ /**
46
+ * 判断电脑是 window 还是 mac
47
47
  */
48
48
  export function getOS() {
49
49
  var agent = navigator.userAgent.toLowerCase();
@@ -60,12 +60,12 @@ export function getOS() {
60
60
  return 'window';
61
61
  }
62
62
 
63
- /**
64
- * 生成随机字符串
65
- *
66
- * @param {*} length 指定长度
67
- * @param {*} chars 字符集
68
- * @returns
63
+ /**
64
+ * 生成随机字符串
65
+ *
66
+ * @param {*} length 指定长度
67
+ * @param {*} chars 字符集
68
+ * @returns
69
69
  */
70
70
  export function randomString(length) {
71
71
  var chars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
@@ -76,11 +76,11 @@ export function randomString(length) {
76
76
  return result;
77
77
  }
78
78
 
79
- /**
80
- * 生成指定范围的随机数
81
- * @param minNum 最小值
82
- * @param maxNum 最大值
83
- * @returns
79
+ /**
80
+ * 生成指定范围的随机数
81
+ * @param minNum 最小值
82
+ * @param maxNum 最大值
83
+ * @returns
84
84
  */
85
85
  export function randomExtend(minNum, maxNum) {
86
86
  if (maxNum === undefined) {
@@ -89,11 +89,11 @@ export function randomExtend(minNum, maxNum) {
89
89
  return Math.floor(Math.random() * (maxNum - minNum + 1) + minNum);
90
90
  }
91
91
 
92
- /**
93
- * 给 canvas 添加水印
94
- * @param canvas canvas 对象
95
- * @param text 水印字体
96
- * @returns canvas
92
+ /**
93
+ * 给 canvas 添加水印
94
+ * @param canvas canvas 对象
95
+ * @param text 水印字体
96
+ * @returns canvas
97
97
  */
98
98
  export function waterMark(canvas, text) {
99
99
  var ctx = canvas.getContext('2d');
@@ -139,9 +139,9 @@ export function pointValueFormat(expressions, value) {
139
139
  return '-';
140
140
  }
141
141
  }
142
- /**
143
- * 从点位 id 中获取产品编号、设备编号、标识符
144
- * @param {string} pointId - The point ID of the point you want to get the info from.
142
+ /**
143
+ * 从点位 id 中获取产品编号、设备编号、标识符
144
+ * @param {string} pointId - The point ID of the point you want to get the info from.
145
145
  */
146
146
  export function getInfoFromPointId(pointId) {
147
147
  if (!pointId) {
@@ -0,0 +1,59 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
5
+ 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; } } }; }
6
+ 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; } }
7
+ 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; }
8
+ import { unstable_batchedUpdates } from 'react-dom';
9
+ import emitter, { clearPointSnapshots } from "./events";
10
+ /** Bound work per task so large polling responses leave time for interaction. */
11
+ export function createPointDispatcher() {
12
+ var pending = new Map();
13
+ var timer;
14
+ var disposed = false;
15
+ var published = new Set();
16
+ var _flush = function flush() {
17
+ timer = undefined;
18
+ unstable_batchedUpdates(function () {
19
+ var count = 0;
20
+ var _iterator = _createForOfIteratorHelper(pending),
21
+ _step;
22
+ try {
23
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
24
+ var _step$value = _slicedToArray(_step.value, 2),
25
+ event = _step$value[0],
26
+ value = _step$value[1];
27
+ pending.delete(event);
28
+ published.add(event);
29
+ try {
30
+ emitter.emit(event, value);
31
+ } catch (error) {
32
+ // One malformed shape must not strand all remaining point updates.
33
+ console.error('SCADA point update failed', event, error);
34
+ }
35
+ if (++count >= 100) break;
36
+ }
37
+ } catch (err) {
38
+ _iterator.e(err);
39
+ } finally {
40
+ _iterator.f();
41
+ }
42
+ });
43
+ if (pending.size && !disposed) timer = setTimeout(_flush, 0);
44
+ };
45
+ return {
46
+ emit: function emit(event, value) {
47
+ if (disposed) return;
48
+ pending.set(event, value);
49
+ if (timer === undefined) timer = setTimeout(_flush, 0);
50
+ },
51
+ dispose: function dispose() {
52
+ disposed = true;
53
+ if (timer !== undefined) clearTimeout(timer);
54
+ pending.clear();
55
+ clearPointSnapshots(published);
56
+ published.clear();
57
+ }
58
+ };
59
+ }
@@ -5,6 +5,7 @@ import { isNumber } from "./type";
5
5
  */
6
6
  export function formatPointDisplayValue(value, config) {
7
7
  var _config$decimalPlaces;
8
+ if (typeof value === 'number' && !Number.isFinite(value)) return '-';
8
9
  if (typeof value !== 'number' || !(config === null || config === void 0 ? void 0 : config.decimalEnabled)) {
9
10
  return value;
10
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "4.1.7",
3
+ "version": "4.1.8",
4
4
  "scripts": {
5
5
  "start": "cross-env PORT=8000 UMI_ENV=prod umi dev",
6
6
  "prepare:3d": "node scripts/build-scada.mjs studio",