@ray-js/api 1.4.0-alpha.0 → 1.4.0-alpha.10

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 (81) hide show
  1. package/@types/P2PKit.d.ts +402 -0
  2. package/@types/all-kits.d.ts +1 -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.d.ts +27 -0
  10. package/lib/P2PKit-2.0.3.js +79 -0
  11. package/lib/PlayNetKit-1.1.3.js +2 -1
  12. package/lib/all-kits.d.ts +1 -0
  13. package/lib/all-kits.js +1 -0
  14. package/lib/cloud/alarm.js +4 -7
  15. package/lib/cloud/core.js +2 -3
  16. package/lib/cloud/device.js +20 -31
  17. package/lib/cloud/interface.d.ts +7 -7
  18. package/lib/cloud/linkage.js +43 -41
  19. package/lib/cloud/statistic.js +21 -33
  20. package/lib/cloud/timer.js +31 -48
  21. package/lib/constants.js +1 -1
  22. package/lib/core/promisify/index.js +5 -9
  23. package/lib/getBoundingClientRect/index.js +16 -17
  24. package/lib/getBoundingClientRect/index.thing.js +16 -17
  25. package/lib/getBoundingClientRect/index.wechat.js +16 -17
  26. package/lib/getCdnUrl/index.d.ts +1 -0
  27. package/lib/getCdnUrl/index.js +4 -0
  28. package/lib/getCdnUrl/index.thing.d.ts +3 -1
  29. package/lib/getCdnUrl/index.thing.js +54 -19
  30. package/lib/getCdnUrl/index.wechat.d.ts +1 -0
  31. package/lib/getCdnUrl/index.wechat.js +4 -0
  32. package/lib/getElementById/index.js +1 -3
  33. package/lib/getElementById/index.thing.js +2 -4
  34. package/lib/getElementById/index.wechat.js +2 -4
  35. package/lib/index.d.ts +1 -1
  36. package/lib/index.js +4 -3
  37. package/lib/lifecycles/offAppEvent/index.js +2 -2
  38. package/lib/lifecycles/offAppHide/index.js +2 -2
  39. package/lib/lifecycles/offAppShow/index.js +2 -2
  40. package/lib/lifecycles/offError/index.js +2 -2
  41. package/lib/lifecycles/offThemeChange/index.js +2 -2
  42. package/lib/lifecycles/offWindowResize/index.js +2 -2
  43. package/lib/lifecycles/onAppEvent/index.js +2 -2
  44. package/lib/lifecycles/onAppHide/index.js +2 -2
  45. package/lib/lifecycles/onAppShow/index.js +2 -2
  46. package/lib/lifecycles/onError/index.js +2 -2
  47. package/lib/lifecycles/onPageNotFound/index.js +2 -2
  48. package/lib/lifecycles/onThemeChange/index.js +2 -2
  49. package/lib/lifecycles/onWindowResize/index.js +2 -2
  50. package/lib/navigateBack/index.js +3 -6
  51. package/lib/navigateTo/index.js +2 -5
  52. package/lib/onNavigationBarBack/index.js +1 -2
  53. package/lib/onNavigationBarBack/index.wechat.js +1 -2
  54. package/lib/panel/devInfo/index.js +84 -121
  55. package/lib/panel/i18n/index.d.ts +1 -1
  56. package/lib/panel/i18n/index.js +180 -262
  57. package/lib/panel/i18n/index.wechat.d.ts +1 -1
  58. package/lib/panel/i18n/index.wechat.js +184 -267
  59. package/lib/panel/normalizeNetwork.d.ts +2 -2
  60. package/lib/panel/normalizeNetwork.js +2 -7
  61. package/lib/panel/publishDps.d.ts +1 -1
  62. package/lib/panel/publishDps.js +13 -18
  63. package/lib/panel/types/devInfo.d.ts +3 -3
  64. package/lib/panel/types/utilities.d.ts +8 -8
  65. package/lib/panel/utils.js +1 -3
  66. package/lib/reLaunch/index.js +2 -5
  67. package/lib/redirectTo/index.js +2 -6
  68. package/lib/requestCloud/index.js +2 -2
  69. package/lib/requestCloud/index.wechat.js +0 -1
  70. package/lib/setNavigationBarBack/index.js +1 -2
  71. package/lib/setNavigationBarBack/index.wechat.js +1 -2
  72. package/lib/setNavigationBarColor/index.js +3 -6
  73. package/lib/setNavigationBarTitle/index.js +5 -6
  74. package/lib/switchTab/index.js +2 -5
  75. package/lib/utils.d.ts +1 -1
  76. package/lib/utils.js +5 -14
  77. package/lib/utils.wechat.d.ts +1 -1
  78. package/lib/utils.wechat.js +9 -21
  79. package/lib/viewAPI.js +13 -12
  80. package/package.json +25 -25
  81. package/LICENSE.md +0 -9
@@ -1,24 +1,20 @@
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/es.promise.js";
4
2
  export function promisify(api) {
5
3
  return function () {
6
- var arg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
- return new Promise(function (resolve, reject) {
8
- var promisifyArg = arg;
4
+ let arg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5
+ return new Promise((resolve, reject) => {
6
+ const promisifyArg = arg;
9
7
  api(_objectSpread(_objectSpread({}, promisifyArg), {}, {
10
- success: function success(res) {
8
+ success: res => {
11
9
  if (promisifyArg && typeof promisifyArg.success === 'function') {
12
10
  promisifyArg.success(res);
13
11
  }
14
-
15
12
  resolve(res);
16
13
  },
17
- fail: function fail(res) {
14
+ fail: res => {
18
15
  if (promisifyArg && typeof promisifyArg.fail === 'function') {
19
16
  promisifyArg.fail(res);
20
17
  }
21
-
22
18
  reject(res);
23
19
  }
24
20
  }));
@@ -1,26 +1,25 @@
1
- import "core-js/modules/es.object.to-string.js";
2
- import "core-js/modules/es.promise.js";
3
-
4
1
  /**
5
2
  * 获取元素的大小及其相对于视口的位置
6
3
  * @param element HTEMLElement | Nodes
7
4
  */
8
5
  export default function getBoundingClientRect(element) {
9
- return new Promise(function (resolve) {
10
- var rect = element.getBoundingClientRect();
11
- var right = rect.right,
12
- left = rect.left,
13
- top = rect.top,
14
- bottom = rect.bottom,
15
- width = rect.width,
16
- height = rect.height;
6
+ return new Promise(resolve => {
7
+ const rect = element.getBoundingClientRect();
8
+ const {
9
+ right,
10
+ left,
11
+ top,
12
+ bottom,
13
+ width,
14
+ height
15
+ } = rect;
17
16
  resolve({
18
- right: right,
19
- left: left,
20
- top: top,
21
- bottom: bottom,
22
- width: width,
23
- height: height
17
+ right,
18
+ left,
19
+ top,
20
+ bottom,
21
+ width,
22
+ height
24
23
  });
25
24
  });
26
25
  }
@@ -1,22 +1,21 @@
1
- import "core-js/modules/es.object.to-string.js";
2
- import "core-js/modules/es.promise.js";
3
- import "core-js/modules/es.regexp.exec.js";
4
1
  export default function getBoundingClientRect(ref) {
5
- return new Promise(function (resolve) {
6
- ref.boundingClientRect(function (rect) {
7
- var right = rect.right,
8
- left = rect.left,
9
- top = rect.top,
10
- bottom = rect.bottom,
11
- width = rect.width,
12
- height = rect.height;
2
+ return new Promise(resolve => {
3
+ ref.boundingClientRect(rect => {
4
+ const {
5
+ right,
6
+ left,
7
+ top,
8
+ bottom,
9
+ width,
10
+ height
11
+ } = rect;
13
12
  resolve({
14
- right: right,
15
- left: left,
16
- top: top,
17
- bottom: bottom,
18
- width: width,
19
- height: height
13
+ right,
14
+ left,
15
+ top,
16
+ bottom,
17
+ width,
18
+ height
20
19
  });
21
20
  }).exec();
22
21
  });
@@ -1,22 +1,21 @@
1
- import "core-js/modules/es.object.to-string.js";
2
- import "core-js/modules/es.promise.js";
3
- import "core-js/modules/es.regexp.exec.js";
4
1
  export default function getBoundingClientRect(ref) {
5
- return new Promise(function (resolve) {
6
- ref.boundingClientRect(function (rect) {
7
- var right = rect.right,
8
- left = rect.left,
9
- top = rect.top,
10
- bottom = rect.bottom,
11
- width = rect.width,
12
- height = rect.height;
2
+ return new Promise(resolve => {
3
+ ref.boundingClientRect(rect => {
4
+ const {
5
+ right,
6
+ left,
7
+ top,
8
+ bottom,
9
+ width,
10
+ height
11
+ } = rect;
13
12
  resolve({
14
- right: right,
15
- left: left,
16
- top: top,
17
- bottom: bottom,
18
- width: width,
19
- height: height
13
+ right,
14
+ left,
15
+ top,
16
+ bottom,
17
+ width,
18
+ height
20
19
  });
21
20
  }).exec();
22
21
  });
@@ -1 +1,2 @@
1
1
  export default function getCdnUrl(path: string): string;
2
+ export declare function getCdnUrlAsync(path: string): Promise<string>;
@@ -1,4 +1,8 @@
1
1
  export default function getCdnUrl(path) {
2
2
  // 暂未实现获取cdn方法,将直接返回path
3
3
  return path;
4
+ }
5
+ export function getCdnUrlAsync(path) {
6
+ // 暂未实现获取cdn方法,将直接返回path
7
+ return Promise.resolve(path);
4
8
  }
@@ -1 +1,3 @@
1
- export default function getCdnUrl(path: string, cdnMap?: Record<string, string>): string;
1
+ export declare function getRegionCode(): Promise<string>;
2
+ export default function getCdnUrl(path: string, cdnMap?: Record<string, string>, region?: string): string;
3
+ export declare function getCdnUrlAsync(path: string, cdnMap?: Record<string, string>, region?: string): Promise<string>;
@@ -1,28 +1,63 @@
1
- export default function getCdnUrl(path, cdnMap) {
1
+ const regionMap = {
2
+ AY: 'images.tuyacn.com',
3
+ AZ: 'usimagesd1448c85ulz2o4.cdn5th.com',
4
+ EU: 'euimagesd2h2yqnfpu4gl5.cdn5th.com',
5
+ IN: 'inimagesd1jqokb9wptk2t.cdn5th.com',
6
+ RU: 'euimagesd2h2yqnfpu4gl5.cdn5th.com',
7
+ WE: 'd2h2yqnfpu4gl5.cdn5th.com',
8
+ UE: 'usimagesd1448c85ulz2o4.cdn5th.com'
9
+ };
10
+ let regionCode = 'EU';
11
+ export function getRegionCode() {
12
+ return new Promise((resolve, reject) => {
13
+ ty.getAppInfo({
14
+ success: function (res) {
15
+ resolve(res.regionCode);
16
+ },
17
+ fail: function (err) {
18
+ reject(err);
19
+ }
20
+ });
21
+ });
22
+ }
23
+ ty.getAppInfo({
24
+ success: function (res) {
25
+ regionCode = res.regionCode;
26
+ }
27
+ });
28
+ export default function getCdnUrl(path, cdnMap, region) {
2
29
  if (!cdnMap) {
3
30
  console.warn('请传入cdnMap');
4
31
  return path;
5
32
  }
6
-
7
- var regionCode = 'EU';
8
- ty.getAppInfo().then(function (res) {
9
- regionCode = res.regionCode;
10
- });
11
- var region = {
12
- AY: 'images.tuyacn.com',
13
- AZ: 'usimagesd1448c85ulz2o4.cdn5th.com',
14
- EU: 'euimagesd2h2yqnfpu4gl5.cdn5th.com',
15
- IN: 'inimagesd1jqokb9wptk2t.cdn5th.com',
16
- RU: 'euimagesd2h2yqnfpu4gl5.cdn5th.com',
17
- WE: 'd2h2yqnfpu4gl5.cdn5th.com',
18
- UE: 'usimagesd1448c85ulz2o4.cdn5th.com'
19
- }[regionCode];
20
- var cdnShortPath = cdnMap[path];
21
-
33
+ const cdnShortPath = cdnMap[path];
34
+ if (!cdnShortPath) {
35
+ console.warn('[App] cdn "' + path + '" is not exist.');
36
+ return path;
37
+ }
38
+ const cdnPath = 'https://' + regionMap[region || regionCode] + '/' + cdnShortPath;
39
+ return cdnPath;
40
+ }
41
+ export async function getCdnUrlAsync(path, cdnMap, region) {
42
+ if (!cdnMap) {
43
+ console.warn('请传入cdnMap');
44
+ return path;
45
+ }
46
+ let _regionCode = 'EU';
47
+ if (region) {
48
+ _regionCode = region;
49
+ } else {
50
+ try {
51
+ _regionCode = await getRegionCode();
52
+ } catch (error) {
53
+ console.warn('[App] getRegionCode error, use default region EU', error);
54
+ }
55
+ }
56
+ const cdnShortPath = cdnMap[path];
22
57
  if (!cdnShortPath) {
23
58
  console.warn('[App] cdn "' + path + '" is not exist.');
24
59
  return path;
25
60
  }
26
-
27
- return 'https://' + region + '/' + cdnShortPath;
61
+ const cdnPath = 'https://' + regionMap[_regionCode] + '/' + cdnShortPath;
62
+ return cdnPath;
28
63
  }
@@ -1 +1,2 @@
1
1
  export default function getCdnUrl(path: string): string;
2
+ export declare function getCdnUrlAsync(path: string): Promise<string>;
@@ -1,4 +1,8 @@
1
1
  export default function getCdnUrl(path) {
2
2
  // 暂未实现获取cdn方法,将直接返回path
3
3
  return path;
4
+ }
5
+ export function getCdnUrlAsync(path) {
6
+ // 暂未实现获取cdn方法,将直接返回path
7
+ return Promise.resolve(path);
4
8
  }
@@ -1,7 +1,5 @@
1
- import "core-js/modules/es.object.to-string.js";
2
- import "core-js/modules/es.promise.js";
3
1
  export default function getElementById(id) {
4
- return new Promise(function (resolve) {
2
+ return new Promise(resolve => {
5
3
  resolve(document.getElementById(id));
6
4
  });
7
5
  }
@@ -1,8 +1,6 @@
1
- import "core-js/modules/es.object.to-string.js";
2
- import "core-js/modules/es.promise.js";
3
1
  export default function getElementById(id) {
4
- return new Promise(function (resolve) {
5
- var nodeRef = ty.createSelectorQuery().select("#".concat(id));
2
+ return new Promise(resolve => {
3
+ const nodeRef = ty.createSelectorQuery().select("#".concat(id));
6
4
  resolve(nodeRef);
7
5
  });
8
6
  }
@@ -1,8 +1,6 @@
1
- import "core-js/modules/es.object.to-string.js";
2
- import "core-js/modules/es.promise.js";
3
1
  export default function getElementById(id) {
4
- return new Promise(function (resolve) {
5
- var nodeRef = wx.createSelectorQuery().select("#".concat(id));
2
+ return new Promise(resolve => {
3
+ const nodeRef = wx.createSelectorQuery().select("#".concat(id));
6
4
  resolve(nodeRef);
7
5
  });
8
6
  }
package/lib/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export { default as showTabBar } from './showTabBar';
20
20
  export { default as switchTab } from './switchTab';
21
21
  export { default as onNavigationBarBack } from './onNavigationBarBack';
22
22
  export { default as setNavigationBarBack } from './setNavigationBarBack';
23
- export { default as getCdnUrl } from './getCdnUrl';
23
+ export { default as getCdnUrl, getCdnUrlAsync } from './getCdnUrl';
24
24
  /**
25
25
  * 提供 glboal-api 将 wx / ty 对象暴露出去,供给业务在Ray为显示导出api时进行快速响应开发。
26
26
  */
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference path="../@types/api.d.ts" />
2
+
2
3
  export * from './constants';
3
4
  export * from './all-kits';
4
5
  export * from './lifecycles';
@@ -20,16 +21,16 @@ export { default as showTabBar } from './showTabBar';
20
21
  export { default as switchTab } from './switchTab';
21
22
  export { default as onNavigationBarBack } from './onNavigationBarBack';
22
23
  export { default as setNavigationBarBack } from './setNavigationBarBack';
23
- export { default as getCdnUrl } from './getCdnUrl';
24
+ export { default as getCdnUrl, getCdnUrlAsync } from './getCdnUrl';
25
+
24
26
  /**
25
27
  * 提供 glboal-api 将 wx / ty 对象暴露出去,供给业务在Ray为显示导出api时进行快速响应开发。
26
28
  */
27
-
28
29
  export { default as globalApi } from './global-api';
29
30
  export * from './cloud';
31
+
30
32
  /**
31
33
  * 0.10.3将一部分未支持的api导入
32
34
  */
33
-
34
35
  export * from './viewAPI';
35
36
  export * from './panel';
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var offAppEvent = function () {
2
+
3
+ const offAppEvent = function () {
3
4
  console.warn('// TODO 暂未实现方法 offAppEvent');
4
5
  };
5
-
6
6
  export default offAppEvent;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var offAppHide = function () {
2
+
3
+ const offAppHide = function () {
3
4
  console.warn('// TODO 暂未实现方法 offAppHide');
4
5
  };
5
-
6
6
  export default offAppHide;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var offAppShow = function () {
2
+
3
+ const offAppShow = function () {
3
4
  console.warn('// TODO 暂未实现方法 offAppShow');
4
5
  };
5
-
6
6
  export default offAppShow;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var offError = function () {
2
+
3
+ const offError = function () {
3
4
  console.warn('// TODO 暂未实现方法 offError');
4
5
  };
5
-
6
6
  export default offError;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var offThemeChange = function () {
2
+
3
+ const offThemeChange = function () {
3
4
  console.warn('// TODO 暂未实现方法 offThemeChange');
4
5
  };
5
-
6
6
  export default offThemeChange;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var offWindowResize = function () {
2
+
3
+ const offWindowResize = function () {
3
4
  console.warn('// TODO 暂未实现方法 offWindowResize');
4
5
  };
5
-
6
6
  export default offWindowResize;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var onAppEvent = function () {
2
+
3
+ const onAppEvent = function () {
3
4
  console.warn('// TODO 暂未实现方法 onAppEvent');
4
5
  };
5
-
6
6
  export default onAppEvent;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var onAppHide = function () {
2
+
3
+ const onAppHide = function () {
3
4
  console.warn('// TODO 暂未实现方法 onAppHide');
4
5
  };
5
-
6
6
  export default onAppHide;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var onAppShow = function () {
2
+
3
+ const onAppShow = function () {
3
4
  console.warn('// TODO 暂未实现方法 onAppShow');
4
5
  };
5
-
6
6
  export default onAppShow;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var onError = function () {
2
+
3
+ const onError = function () {
3
4
  console.warn('// TODO 暂未实现方法 onError');
4
5
  };
5
-
6
6
  export default onError;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var onPageNotFound = function () {
2
+
3
+ const onPageNotFound = function () {
3
4
  console.warn('// TODO 暂未实现方法 onPageNotFound');
4
5
  };
5
-
6
6
  export default onPageNotFound;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var onThemeChange = function () {
2
+
3
+ const onThemeChange = function () {
3
4
  console.warn('// TODO 暂未实现方法 onThemeChange');
4
5
  };
5
-
6
6
  export default onThemeChange;
@@ -1,6 +1,6 @@
1
1
  /// <reference path="../../@types/api.d.ts" />
2
- var onWindowResize = function () {
2
+
3
+ const onWindowResize = function () {
3
4
  console.warn('// TODO 暂未实现方法 onWindowResize');
4
5
  };
5
-
6
6
  export default onWindowResize;
@@ -1,14 +1,11 @@
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 navigateBack = function () {
7
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
3
+ import router from '@ray-js/router';
4
+ const navigateBack = function () {
5
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
8
6
  delta: 1
9
7
  };
10
8
  router.go(options.delta * -1);
11
9
  return Promise.resolve();
12
10
  };
13
-
14
11
  export default navigateBack;
@@ -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 navigateTo = function (options) {
3
+ import router from '@ray-js/router';
4
+ const navigateTo = function (options) {
7
5
  router.push(options.url);
8
6
  return Promise.resolve();
9
7
  };
10
-
11
8
  export default navigateTo;
@@ -1,5 +1,4 @@
1
- var onNavigationBarBack = function () {
1
+ const onNavigationBarBack = function () {
2
2
  console.warn('尚未支持');
3
3
  };
4
-
5
4
  export default onNavigationBarBack;
@@ -1,5 +1,4 @@
1
- var onNavigationBarBack = function () {
1
+ const onNavigationBarBack = function () {
2
2
  console.warn('尚未支持');
3
3
  };
4
-
5
4
  export default onNavigationBarBack;