@ray-js/api 1.3.21 → 1.3.23

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 (76) hide show
  1. package/@types/api-extend.d.ts +9 -0
  2. package/LICENSE.md +9 -0
  3. package/lib/BaseKit-3.3.10.js +85 -83
  4. package/lib/BizKit-3.2.7.js +48 -47
  5. package/lib/DeviceKit-3.3.1.js +194 -193
  6. package/lib/HomeKit-3.1.4.js +2 -1
  7. package/lib/MapKit-3.0.7.js +4 -2
  8. package/lib/MiniKit-3.1.0.js +65 -64
  9. package/lib/P2PKit-2.0.3.js +4 -2
  10. package/lib/PlayNetKit-1.1.3.js +2 -1
  11. package/lib/cloud/alarm.js +6 -9
  12. package/lib/cloud/core.js +3 -4
  13. package/lib/cloud/device.js +25 -36
  14. package/lib/cloud/interface.d.ts +7 -7
  15. package/lib/cloud/linkage.js +51 -49
  16. package/lib/cloud/statistic.js +30 -42
  17. package/lib/cloud/timer.js +45 -62
  18. package/lib/constants.js +1 -1
  19. package/lib/core/promisify/index.js +5 -9
  20. package/lib/getBoundingClientRect/index.js +16 -17
  21. package/lib/getBoundingClientRect/index.thing.js +16 -17
  22. package/lib/getBoundingClientRect/index.wechat.js +16 -17
  23. package/lib/getCdnUrl/index.js +0 -2
  24. package/lib/getCdnUrl/index.thing.js +30 -85
  25. package/lib/getCdnUrl/index.wechat.js +0 -2
  26. package/lib/getElementById/index.js +1 -3
  27. package/lib/getElementById/index.thing.js +2 -4
  28. package/lib/getElementById/index.wechat.js +2 -4
  29. package/lib/hideTabBar/index.d.ts +7 -1
  30. package/lib/index.js +3 -2
  31. package/lib/lifecycles/offAppEvent/index.js +2 -2
  32. package/lib/lifecycles/offAppHide/index.js +2 -2
  33. package/lib/lifecycles/offAppShow/index.js +2 -2
  34. package/lib/lifecycles/offError/index.js +2 -2
  35. package/lib/lifecycles/offThemeChange/index.js +2 -2
  36. package/lib/lifecycles/offWindowResize/index.js +2 -2
  37. package/lib/lifecycles/onAppEvent/index.js +2 -2
  38. package/lib/lifecycles/onAppHide/index.js +2 -2
  39. package/lib/lifecycles/onAppShow/index.js +2 -2
  40. package/lib/lifecycles/onError/index.js +2 -2
  41. package/lib/lifecycles/onPageNotFound/index.js +2 -2
  42. package/lib/lifecycles/onThemeChange/index.js +2 -2
  43. package/lib/lifecycles/onWindowResize/index.js +2 -2
  44. package/lib/navigateBack/index.js +3 -6
  45. package/lib/navigateTo/index.js +2 -5
  46. package/lib/onNavigationBarBack/index.js +1 -2
  47. package/lib/onNavigationBarBack/index.wechat.js +1 -2
  48. package/lib/panel/devInfo/index.js +84 -121
  49. package/lib/panel/i18n/index.d.ts +1 -1
  50. package/lib/panel/i18n/index.js +180 -263
  51. package/lib/panel/i18n/index.wechat.d.ts +1 -1
  52. package/lib/panel/i18n/index.wechat.js +184 -268
  53. package/lib/panel/normalizeNetwork.d.ts +2 -2
  54. package/lib/panel/normalizeNetwork.js +2 -7
  55. package/lib/panel/publishDps.d.ts +1 -1
  56. package/lib/panel/publishDps.js +14 -19
  57. package/lib/panel/types/devInfo.d.ts +3 -3
  58. package/lib/panel/types/utilities.d.ts +8 -8
  59. package/lib/panel/utils.js +1 -3
  60. package/lib/reLaunch/index.js +2 -5
  61. package/lib/redirectTo/index.js +2 -7
  62. package/lib/requestCloud/index.js +2 -2
  63. package/lib/requestCloud/index.wechat.js +0 -1
  64. package/lib/setNavigationBarBack/index.js +1 -2
  65. package/lib/setNavigationBarBack/index.wechat.js +1 -2
  66. package/lib/setNavigationBarColor/index.js +3 -6
  67. package/lib/setNavigationBarTitle/index.js +5 -6
  68. package/lib/showTabBar/index.d.ts +7 -1
  69. package/lib/switchTab/index.js +2 -5
  70. package/lib/utils.d.ts +1 -1
  71. package/lib/utils.js +9 -18
  72. package/lib/utils.wechat.d.ts +1 -1
  73. package/lib/utils.wechat.js +14 -26
  74. package/lib/viewAPI.d.ts +1 -0
  75. package/lib/viewAPI.js +14 -12
  76. package/package.json +5 -5
@@ -1,295 +1,211 @@
1
- import _typeof from "@babel/runtime/helpers/esm/typeof";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import "core-js/modules/es.object.keys.js";
5
- import "core-js/modules/es.object.assign.js";
6
- import "core-js/modules/es.array.map.js";
7
- import "core-js/modules/es.regexp.exec.js";
8
- import "core-js/modules/es.regexp.test.js";
9
- import "core-js/modules/es.array.last-index-of.js";
10
- import "core-js/modules/es.string.replace.js";
11
- import "core-js/modules/es.regexp.constructor.js";
12
- import "core-js/modules/es.regexp.dot-all.js";
13
- import "core-js/modules/es.regexp.sticky.js";
14
- import "core-js/modules/es.regexp.to-string.js";
15
- import "core-js/modules/es.array.concat.js";
16
- import "core-js/modules/es.parse-float.js";
17
1
  import { requestCloud, getSystemInfoSync, THING } from '../..';
18
- import { getBitValue } from '../utils'; // 微信小程序暂时只支持本地多语言
2
+ import { getBitValue } from '../utils';
19
3
 
20
- var I18n = {
21
- t: function t(key) {
22
- return key;
23
- }
4
+ // 微信小程序暂时只支持本地多语言
5
+ const I18n = {
6
+ t: key => key
24
7
  };
25
-
26
- var I18N = /*#__PURE__*/function () {
27
- function I18N(props) {
28
- _classCallCheck(this, I18N);
29
-
8
+ export default class I18N {
9
+ constructor(props) {
30
10
  this.strings = this.mergeLanguage(props, {});
31
11
  this.defaultLang = this.strings.en ? 'en' : Object.keys(this.strings)[0];
32
12
  this.setLanguage(this.defaultLang);
33
- var langKey = getSystemInfoSync().language;
13
+ const langKey = getSystemInfoSync().language;
34
14
  this.setLanguage(langKey);
35
15
  }
36
-
37
- _createClass(I18N, [{
38
- key: "forceUpdateNetworkLang",
39
- value: function forceUpdateNetworkLang(productId) {
40
- var _this = this;
41
-
42
- requestCloud({
43
- api: "".concat(THING, ".m.i18n.get"),
44
- version: '1.0',
45
- data: {
46
- productId: productId,
47
- moduleName: 'h5',
48
- endId: 2,
49
- osId: 0
50
- },
51
- // @ts-ignore
52
- success: function success(data) {
53
- if (data) {
54
- _this.strings = _this.mergeLanguage(_this.strings, data);
55
-
56
- _this.buildLanguage(_this.__language);
57
- }
16
+ forceUpdateNetworkLang(productId) {
17
+ requestCloud({
18
+ api: `${THING}.m.i18n.get`,
19
+ version: '1.0',
20
+ data: {
21
+ productId,
22
+ moduleName: 'h5',
23
+ endId: 2,
24
+ osId: 0
25
+ },
26
+ // @ts-ignore
27
+ success: data => {
28
+ if (data) {
29
+ this.strings = this.mergeLanguage(this.strings, data);
30
+ this.buildLanguage(this.__language);
58
31
  }
59
- });
60
- }
61
- }, {
62
- key: "mergeLanguage",
63
- value: function mergeLanguage(L1, L2) {
64
- if (typeof L1 === 'undefined' && typeof L2 === 'undefined') return {};
65
- if (typeof L1 === 'undefined') return L2;
66
- if (typeof L2 === 'undefined') return L1;
67
- var L0 = Object.assign({}, L1);
68
- Object.keys(L2).map(function (k) {
69
- if (typeof L0[k] !== 'undefined') {
70
- Object.assign(L0[k], L2[k]);
71
- } else {
72
- L0[k] = Object.assign({}, L2[k]);
73
- }
74
-
75
- return null;
76
- });
77
- return L0;
78
- }
79
- }, {
80
- key: "isZh",
81
- value: function isZh(language) {
82
- /**
83
- * ios 的中文简体固定为 zh-Hans,
84
- * 但安卓的中文简体可能有一大堆排列组件 = =,如 zh_CN、zh_cn、zh_Hans_CH、zh_hans_cn 等等;
85
- */
86
-
87
- /**
88
- * 如果匹配到位中文简体地区,
89
- * 则将中文 zh 相关的 values 都写入到 this.strings 下,保证兜底本地 zh 相关的能取到,
90
- * 再将当前地区 key 相关的 values 都写入到 this.strings 下,优先级最高;
91
- */
92
- if (typeof language === 'string' && /^zh-hans$|^zh_hans$|^zh_cn$|^zh-cn$|^zh_hans_\w+|^zh-hans-\w+/.test(language.toLowerCase())) {
93
- return true;
94
32
  }
95
-
96
- return false;
97
- }
98
- }, {
99
- key: "setLanguage",
100
- value: function setLanguage(language) {
101
- this.__language = language;
102
-
103
- if (this.isZh(language)) {
104
- this.buildLanguage('zh');
105
- this.buildLanguage(language);
33
+ });
34
+ }
35
+ mergeLanguage(L1, L2) {
36
+ if (typeof L1 === 'undefined' && typeof L2 === 'undefined') return {};
37
+ if (typeof L1 === 'undefined') return L2;
38
+ if (typeof L2 === 'undefined') return L1;
39
+ const L0 = Object.assign({}, L1);
40
+ Object.keys(L2).map(k => {
41
+ if (typeof L0[k] !== 'undefined') {
42
+ Object.assign(L0[k], L2[k]);
106
43
  } else {
107
- this.buildLanguage(this.__language);
108
- }
109
- }
110
- }, {
111
- key: "buildLanguage",
112
- value: function buildLanguage(language) {
113
- var _this2 = this;
114
-
115
- if (this.strings[language]) {
116
- var localizedStrings = this.strings[language];
117
- Object.keys(localizedStrings).map(function (key) {
118
- // eslint-disable-next-line no-prototype-builtins
119
- if (localizedStrings.hasOwnProperty(key)) {
120
- _this2[key] = localizedStrings[key];
121
- }
122
-
123
- return null;
124
- });
125
- }
126
- }
127
- }, {
128
- key: "_getBestMatchingLanguage",
129
- value: function _getBestMatchingLanguage(language, props) {
130
- if (props[language]) return language;
131
- var idx = language.lastIndexOf('-');
132
-
133
- if (idx >= 0) {
134
- var lang = language.substring(0, idx);
135
- return this._getBestMatchingLanguage(lang, props);
136
- }
137
-
138
- var underlineIdx = language.lastIndexOf('_');
139
-
140
- if (underlineIdx >= 0) {
141
- var _lang = language.substring(0, underlineIdx);
142
-
143
- return this._getBestMatchingLanguage(_lang, props);
144
- }
145
-
146
- return this.defaultLang;
147
- } // Format the passed string replacing the numbered placeholders
148
- // i.e. I'd like some {0} and {1}, or just {0}
149
- // Use example:
150
- // strings.formatString(strings.question, strings.bread, strings.butter)
151
-
152
- }, {
153
- key: "formatString",
154
- value: function formatString(str) {
155
- var res = str;
156
-
157
- for (var i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
158
- res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
44
+ L0[k] = Object.assign({}, L2[k]);
159
45
  }
46
+ return null;
47
+ });
48
+ return L0;
49
+ }
50
+ isZh(language) {
51
+ /**
52
+ * ios 的中文简体固定为 zh-Hans,
53
+ * 但安卓的中文简体可能有一大堆排列组件 = =,如 zh_CN、zh_cn、zh_Hans_CH、zh_hans_cn 等等;
54
+ */
160
55
 
161
- return res;
56
+ /**
57
+ * 如果匹配到位中文简体地区,
58
+ * 则将中文 zh 相关的 values 都写入到 this.strings 下,保证兜底本地 zh 相关的能取到,
59
+ * 再将当前地区 key 相关的 values 都写入到 this.strings 下,优先级最高;
60
+ */
61
+ if (typeof language === 'string' && /^zh-hans$|^zh_hans$|^zh_cn$|^zh-cn$|^zh_hans_\w+|^zh-hans-\w+/.test(language.toLowerCase())) {
62
+ return true;
162
63
  }
163
- }, {
164
- key: "formatValue",
165
- value: function formatValue(key) {
166
- var res = typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
167
-
168
- for (var i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
169
- res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
170
- }
171
-
172
- return res;
64
+ return false;
65
+ }
66
+ setLanguage(language) {
67
+ this.__language = language;
68
+ if (this.isZh(language)) {
69
+ this.buildLanguage('zh');
70
+ this.buildLanguage(language);
71
+ } else {
72
+ this.buildLanguage(this.__language);
173
73
  }
174
- }, {
175
- key: "_replaceAll",
176
- value: function _replaceAll(find, replace, str) {
177
- // eslint-disable-next-line no-useless-escape, no-param-reassign
178
- find = find.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
179
- if (!str) return '';
180
- return str.replace(new RegExp(find, 'g'), replace);
74
+ }
75
+ buildLanguage(language) {
76
+ if (this.strings[language]) {
77
+ const localizedStrings = this.strings[language];
78
+ Object.keys(localizedStrings).map(key => {
79
+ // eslint-disable-next-line no-prototype-builtins
80
+ if (localizedStrings.hasOwnProperty(key)) {
81
+ this[key] = localizedStrings[key];
82
+ }
83
+ return null;
84
+ });
181
85
  }
182
- }, {
183
- key: "getDpLang",
184
- value: function getDpLang(code, value) {
185
- var key;
186
-
187
- if (typeof value === 'undefined') {
188
- key = "dp_".concat(code).toLowerCase();
189
- } else if (typeof value === 'boolean') {
190
- var valStr = value ? 'on' : 'off';
191
- key = "dp_".concat(code, "_").concat(valStr).toLowerCase();
192
- } else {
193
- key = "dp_".concat(code, "_").concat(value).toLowerCase();
194
- }
195
-
196
- return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
86
+ }
87
+ _getBestMatchingLanguage(language, props) {
88
+ if (props[language]) return language;
89
+ const idx = language.lastIndexOf('-');
90
+ if (idx >= 0) {
91
+ const lang = language.substring(0, idx);
92
+ return this._getBestMatchingLanguage(lang, props);
197
93
  }
198
- }, {
199
- key: "getDpName",
200
- value: function getDpName(code, defaultName) {
201
- var key = "dp_".concat(code).toLowerCase();
202
- return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
94
+ const underlineIdx = language.lastIndexOf('_');
95
+ if (underlineIdx >= 0) {
96
+ const lang = language.substring(0, underlineIdx);
97
+ return this._getBestMatchingLanguage(lang, props);
203
98
  }
204
- }, {
205
- key: "getDpsLang",
206
- value: function getDpsLang(key) {
207
- var _this3 = this;
208
-
209
- var strs = {};
210
-
211
- if (_typeof(key) === 'object') {
212
- if (typeof key.strKey === 'string') {
213
- strs = I18n.t(key.strKey) !== key.strKey ? I18n.t(key.strKey) : typeof this[key.strKey] !== 'undefined' ? this[key.strKey] : I18n.t(key.strKey);
214
- } else {
215
- Object.keys(key).map(function (i) {
216
- strs[key[i]] = I18n.t(key[i]) !== key[i] ? I18n.t(key[i]) : typeof _this3[key[i]] !== 'undefined' ? _this3[key[i]] : I18n.t(key[i]);
217
- return null;
218
- });
219
- }
220
- } else {
221
- strs = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
222
- }
99
+ return this.defaultLang;
100
+ }
223
101
 
224
- return strs;
102
+ // Format the passed string replacing the numbered placeholders
103
+ // i.e. I'd like some {0} and {1}, or just {0}
104
+ // Use example:
105
+ // strings.formatString(strings.question, strings.bread, strings.butter)
106
+ formatString(str) {
107
+ let res = str;
108
+ for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
109
+ res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
225
110
  }
226
- }, {
227
- key: "getLang",
228
- value: function getLang(key, defaultString) {
229
- return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : typeof defaultString !== 'undefined' ? defaultString : I18n.t(key);
111
+ return res;
112
+ }
113
+ formatValue(key) {
114
+ let res = typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
115
+ for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
116
+ res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
230
117
  }
231
- /**
232
- * 获取picker标题
233
- * @param {*} dpCode
234
- */
235
-
236
- }, {
237
- key: "getRangeStrings",
238
- value: function getRangeStrings(dpCode, schema) {
239
- var _this4 = this;
240
-
241
- var result = {};
242
- if (typeof schema === 'undefined') return result;
243
- var lists = schema.range;
244
- lists.map(function (v) {
245
- var key = "dp_".concat(dpCode, "_").concat(v).toLowerCase();
246
- result[v] = I18n.t(key) !== key ? I18n.t(key) : typeof _this4[key] !== 'undefined' ? _this4[key] : I18n.t(key);
247
- return null;
248
- });
249
- return result;
118
+ return res;
119
+ }
120
+ _replaceAll(find, replace, str) {
121
+ // eslint-disable-next-line no-useless-escape, no-param-reassign
122
+ find = find.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
123
+ if (!str) return '';
124
+ return str.replace(new RegExp(find, 'g'), replace);
125
+ }
126
+ getDpLang(code, value) {
127
+ let key;
128
+ if (typeof value === 'undefined') {
129
+ key = `dp_${code}`.toLowerCase();
130
+ } else if (typeof value === 'boolean') {
131
+ const valStr = value ? 'on' : 'off';
132
+ key = `dp_${code}_${valStr}`.toLowerCase();
133
+ } else {
134
+ key = `dp_${code}_${value}`.toLowerCase();
250
135
  }
251
- /**
252
- * 开关倒计时转换为文案 time => 设备将在xxx后 关闭/开启
253
- * 精确到分钟
254
- * @param {*} t 倒计时剩余()
255
- * @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
256
- */
257
-
258
- }, {
259
- key: "parseCountdown",
260
- value: function parseCountdown(t, power) {
261
- var h = parseFloat("".concat(t / 3600));
262
- var m = parseFloat("".concat(t / 60 - h * 60));
263
- var tHour = I18n.t('t_hour') !== 't_hour' ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
264
- var tMinute = I18n.t('t_minute') !== 't_minute' ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
265
- var time = h >= 1.0 ? "".concat(Math.round(h)).concat(tHour) : "".concat(Math.round(m)).concat(tMinute);
266
- var key = "countdown_".concat(power ? 'on' : 'off');
267
- var str = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
268
- return this.formatString(str, time);
136
+ return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
137
+ }
138
+ getDpName(code, defaultName) {
139
+ const key = `dp_${code}`.toLowerCase();
140
+ return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
141
+ }
142
+ getDpsLang(key) {
143
+ let strs = {};
144
+ if (typeof key === 'object') {
145
+ if (typeof key.strKey === 'string') {
146
+ strs = I18n.t(key.strKey) !== key.strKey ? I18n.t(key.strKey) : typeof this[key.strKey] !== 'undefined' ? this[key.strKey] : I18n.t(key.strKey);
147
+ } else {
148
+ Object.keys(key).map(i => {
149
+ strs[key[i]] = I18n.t(key[i]) !== key[i] ? I18n.t(key[i]) : typeof this[key[i]] !== 'undefined' ? this[key[i]] : I18n.t(key[i]);
150
+ return null;
151
+ });
152
+ }
153
+ } else {
154
+ strs = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
269
155
  }
270
- }, {
271
- key: "getFaultStrings",
272
- value: function getFaultStrings(schema, faultCode, faultValue) {
273
- var onlyPrior = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
274
- if (!faultValue) return '';
275
- var label = schema.label;
276
- var labels = [];
156
+ return strs;
157
+ }
158
+ getLang(key, defaultString) {
159
+ return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : typeof defaultString !== 'undefined' ? defaultString : I18n.t(key);
160
+ }
277
161
 
278
- for (var i = 0; i < label.length; i++) {
279
- var value = label[i];
280
- var isExist = getBitValue(faultValue, i);
162
+ /**
163
+ * 获取picker标题
164
+ * @param {*} dpCode
165
+ */
166
+ getRangeStrings(dpCode, schema) {
167
+ const result = {};
168
+ if (typeof schema === 'undefined') return result;
169
+ const lists = schema.range;
170
+ lists.map(v => {
171
+ const key = `dp_${dpCode}_${v}`.toLowerCase();
172
+ result[v] = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
173
+ return null;
174
+ });
175
+ return result;
176
+ }
281
177
 
282
- if (isExist) {
283
- labels.push(this.getDpLang(faultCode, value));
284
- if (onlyPrior) break;
285
- }
178
+ /**
179
+ * 开关倒计时转换为文案 time => 设备将在xxx后 关闭/开启
180
+ * 精确到分钟
181
+ * @param {*} t 倒计时剩余(秒)
182
+ * @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
183
+ */
184
+ parseCountdown(t, power) {
185
+ const h = parseFloat(`${t / 3600}`);
186
+ const m = parseFloat(`${t / 60 - h * 60}`);
187
+ const tHour = I18n.t('t_hour') !== 't_hour' ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
188
+ const tMinute = I18n.t('t_minute') !== 't_minute' ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
189
+ const time = h >= 1.0 ? `${Math.round(h)}${tHour}` : `${Math.round(m)}${tMinute}`;
190
+ const key = `countdown_${power ? 'on' : 'off'}`;
191
+ const str = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
192
+ return this.formatString(str, time);
193
+ }
194
+ getFaultStrings(schema, faultCode, faultValue) {
195
+ let onlyPrior = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
196
+ if (!faultValue) return '';
197
+ const {
198
+ label
199
+ } = schema;
200
+ const labels = [];
201
+ for (let i = 0; i < label.length; i++) {
202
+ const value = label[i];
203
+ const isExist = getBitValue(faultValue, i);
204
+ if (isExist) {
205
+ labels.push(this.getDpLang(faultCode, value));
206
+ if (onlyPrior) break;
286
207
  }
287
-
288
- return onlyPrior ? labels[0] : labels.join(', ');
289
208
  }
290
- }]);
291
-
292
- return I18N;
293
- }();
294
-
295
- export { I18N as default };
209
+ return onlyPrior ? labels[0] : labels.join(', ');
210
+ }
211
+ }
@@ -1,7 +1,7 @@
1
1
  import { getNetworkType, onNetworkStatusChange } from '../..';
2
2
  import { GetTTTSuccessData, GetTTTEventListenerParams, NetworkState } from './types';
3
- declare type GetNetworkResult = GetTTTSuccessData<typeof getNetworkType>;
4
- declare type NetworkStatusChangeParam = GetTTTEventListenerParams<typeof onNetworkStatusChange>;
3
+ type GetNetworkResult = GetTTTSuccessData<typeof getNetworkType>;
4
+ type NetworkStatusChangeParam = GetTTTEventListenerParams<typeof onNetworkStatusChange>;
5
5
  /**
6
6
  * 规范统一处理 network 返回值
7
7
  *
@@ -1,5 +1,4 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
-
3
2
  /**
4
3
  * 规范统一处理 network 返回值
5
4
  *
@@ -11,15 +10,11 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
11
10
  */
12
11
  export function normalizeNetwork(network, data) {
13
12
  var _result$networkType;
14
-
15
- var result = _objectSpread(_objectSpread({}, network), data);
16
-
17
- var networkType = result === null || result === void 0 ? void 0 : (_result$networkType = result.networkType) === null || _result$networkType === void 0 ? void 0 : _result$networkType.toUpperCase();
13
+ const result = _objectSpread(_objectSpread({}, network), data);
14
+ const networkType = result === null || result === void 0 ? void 0 : (_result$networkType = result.networkType) === null || _result$networkType === void 0 ? void 0 : _result$networkType.toUpperCase();
18
15
  result.networkType = networkType;
19
-
20
16
  if (typeof result.isConnected === 'undefined') {
21
17
  result.isConnected = networkType !== 'NONE';
22
18
  }
23
-
24
19
  return result;
25
20
  }
@@ -1,6 +1,6 @@
1
1
  import { publishDpsBase } from '../..';
2
2
  import { GetTTTAllParams, DpState } from './types';
3
- declare type PublishDpsOptions = Omit<GetTTTAllParams<typeof publishDpsBase>, 'deviceId' | 'dps'>;
3
+ type PublishDpsOptions = Omit<GetTTTAllParams<typeof publishDpsBase>, 'deviceId' | 'dps'>;
4
4
  /**
5
5
  * 下发 DP 点控制设备
6
6
  *
@@ -1,15 +1,12 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import "core-js/modules/es.object.to-string.js";
3
- import "core-js/modules/web.dom-collections.for-each.js";
4
- import "core-js/modules/es.object.keys.js";
5
- import "core-js/modules/es.promise.js";
6
2
  import { publishDpsBase } from '../..';
7
3
  import { getDevInfo } from './devInfo';
8
- var DEFAULT_OPTIONS = {
4
+ const DEFAULT_OPTIONS = {
9
5
  mode: 2,
10
6
  options: {},
11
7
  pipelines: []
12
8
  };
9
+
13
10
  /**
14
11
  * 下发 DP 点控制设备
15
12
  *
@@ -21,32 +18,32 @@ var DEFAULT_OPTIONS = {
21
18
  * publishDps({ switch: false });
22
19
  * publishDps({ '1': false })
23
20
  */
24
-
25
21
  export function sendDps(data) {
26
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
27
- var devInfo = getDevInfo();
28
- var dps = {};
29
- var codeIds = (devInfo === null || devInfo === void 0 ? void 0 : devInfo.codeIds) || {};
30
- Object.keys(data).forEach(function (code) {
22
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
23
+ const devInfo = getDevInfo();
24
+ const dps = {};
25
+ const codeIds = (devInfo === null || devInfo === void 0 ? void 0 : devInfo.codeIds) || {};
26
+ Object.keys(data).forEach(code => {
31
27
  if (codeIds[code] !== undefined) {
32
- dps["".concat(codeIds[code])] = data[code];
28
+ dps[`${codeIds[code]}`] = data[code];
33
29
  } else {
34
30
  dps[code] = data[code];
35
31
  }
36
32
  });
37
- return new Promise(function (resolve, reject) {
33
+ return new Promise((resolve, reject) => {
38
34
  publishDpsBase(_objectSpread({
39
35
  deviceId: devInfo.devId,
40
- dps: dps,
41
- success: function success(ret) {
36
+ dps,
37
+ success: ret => {
42
38
  resolve(ret);
43
39
  },
44
- fail: function fail(err) {
40
+ fail: err => {
45
41
  reject(err);
46
42
  }
47
43
  }, options));
48
44
  });
49
45
  }
46
+
50
47
  /**
51
48
  * 兼容新旧 publishDps,可以使用原有小程序提供的调用方式,也可以使用 SDK 提供的调用方式。
52
49
  * @param data ty.device.publishDps的参数 或 当前要下发的 DP 数据,同时支持 key 为 dp code 或 dp id
@@ -57,10 +54,8 @@ export function sendDps(data) {
57
54
  * publishDps({ switch: false });
58
55
  * publishDps({ '1': false })
59
56
  */
60
-
61
57
  export function publishDps(data) {
62
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
63
-
58
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
64
59
  if (data.deviceId && data.dps) {
65
60
  publishDpsBase(_objectSpread(_objectSpread({}, data), options));
66
61
  } else {
@@ -1,5 +1,5 @@
1
- export declare type DpValue = boolean | number | string;
2
- export declare type DpState = Record<string, DpValue>;
1
+ export type DpValue = boolean | number | string;
2
+ export type DpState = Record<string, DpValue>;
3
3
  export interface DpSchema {
4
4
  attr: number;
5
5
  canTrigger: boolean;
@@ -85,7 +85,7 @@ interface PanelConfig {
85
85
  /**
86
86
  * 设备信息
87
87
  */
88
- export declare type DevInfo = Omit<ty.device.DeviceInfo, 'schema' | 'panelConfig'> & {
88
+ export type DevInfo = Omit<ty.device.DeviceInfo, 'schema' | 'panelConfig'> & {
89
89
  /**
90
90
  * dp id 与 dp code 的映射
91
91
  */
@@ -1,9 +1,9 @@
1
- declare type AnyFn = (...args: any) => any;
2
- export declare type GetTTTAllParams<Fn extends AnyFn> = Parameters<Fn>['0'];
3
- export declare type GetTTTParams<Fn extends AnyFn> = Omit<GetTTTAllParams<Fn>, 'complete' | 'success' | 'fail'>;
4
- export declare type GetTTTSuccessData<Fn extends AnyFn, TTTParams extends AnyFn = GetTTTAllParams<Fn>['success']> = Parameters<TTTParams>['0'];
5
- export declare type GetTTTFailData<Fn extends AnyFn, TTTParams extends AnyFn = GetTTTAllParams<Fn>['failed']> = Parameters<TTTParams>['0'];
6
- export declare type GetTTTEventListener<Fn extends AnyFn> = GetTTTAllParams<Fn>;
7
- export declare type GetTTTEventListenerParams<Fn extends AnyFn, TTTEventListener extends AnyFn = GetTTTEventListener<Fn>> = Parameters<TTTEventListener>['0'];
8
- export declare type PromisifyTTT<Fn extends AnyFn> = (params: GetTTTParams<Fn>) => Promise<GetTTTSuccessData<Fn>>;
1
+ type AnyFn = (...args: any) => any;
2
+ export type GetTTTAllParams<Fn extends AnyFn> = Parameters<Fn>['0'];
3
+ export type GetTTTParams<Fn extends AnyFn> = Omit<GetTTTAllParams<Fn>, 'complete' | 'success' | 'fail'>;
4
+ export type GetTTTSuccessData<Fn extends AnyFn, TTTParams extends AnyFn = GetTTTAllParams<Fn>['success']> = Parameters<TTTParams>['0'];
5
+ export type GetTTTFailData<Fn extends AnyFn, TTTParams extends AnyFn = GetTTTAllParams<Fn>['failed']> = Parameters<TTTParams>['0'];
6
+ export type GetTTTEventListener<Fn extends AnyFn> = GetTTTAllParams<Fn>;
7
+ export type GetTTTEventListenerParams<Fn extends AnyFn, TTTEventListener extends AnyFn = GetTTTEventListener<Fn>> = Parameters<TTTEventListener>['0'];
8
+ export type PromisifyTTT<Fn extends AnyFn> = (params: GetTTTParams<Fn>) => Promise<GetTTTSuccessData<Fn>>;
9
9
  export {};
@@ -12,6 +12,4 @@
12
12
  * @param {Number} idx, idx is reverse, and it begins 0
13
13
  * @returns {Number} a num
14
14
  */
15
- export var getBitValue = function (num, idx) {
16
- return (num & 1 << idx) >> idx;
17
- };
15
+ export const getBitValue = (num, idx) => (num & 1 << idx) >> idx;
@@ -1,11 +1,8 @@
1
- import "core-js/modules/es.object.to-string.js";
2
- import "core-js/modules/es.promise.js";
3
1
  /// <reference path="../../@types/api.d.ts" />
4
- import router from '@ray-js/router';
5
2
 
6
- var reLaunch = function (options) {
3
+ import router from '@ray-js/router';
4
+ const reLaunch = function (options) {
7
5
  router.reload(options.url);
8
6
  return Promise.resolve();
9
7
  };
10
-
11
8
  export default reLaunch;