@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.
- package/@types/P2PKit.d.ts +402 -0
- package/@types/all-kits.d.ts +1 -0
- package/lib/BaseKit-3.3.10.js +85 -83
- package/lib/BizKit-3.2.7.js +48 -47
- package/lib/DeviceKit-3.3.1.js +194 -193
- package/lib/HomeKit-3.1.4.js +2 -1
- package/lib/MapKit-3.0.7.js +4 -2
- package/lib/MiniKit-3.1.0.js +65 -64
- package/lib/P2PKit-2.0.3.d.ts +27 -0
- package/lib/P2PKit-2.0.3.js +79 -0
- package/lib/PlayNetKit-1.1.3.js +2 -1
- package/lib/all-kits.d.ts +1 -0
- package/lib/all-kits.js +1 -0
- package/lib/cloud/alarm.js +4 -7
- package/lib/cloud/core.js +2 -3
- package/lib/cloud/device.js +20 -31
- package/lib/cloud/interface.d.ts +7 -7
- package/lib/cloud/linkage.js +43 -41
- package/lib/cloud/statistic.js +21 -33
- package/lib/cloud/timer.js +31 -48
- package/lib/constants.js +1 -1
- package/lib/core/promisify/index.js +5 -9
- package/lib/getBoundingClientRect/index.js +16 -17
- package/lib/getBoundingClientRect/index.thing.js +16 -17
- package/lib/getBoundingClientRect/index.wechat.js +16 -17
- package/lib/getCdnUrl/index.d.ts +1 -0
- package/lib/getCdnUrl/index.js +4 -0
- package/lib/getCdnUrl/index.thing.d.ts +3 -1
- package/lib/getCdnUrl/index.thing.js +54 -19
- package/lib/getCdnUrl/index.wechat.d.ts +1 -0
- package/lib/getCdnUrl/index.wechat.js +4 -0
- package/lib/getElementById/index.js +1 -3
- package/lib/getElementById/index.thing.js +2 -4
- package/lib/getElementById/index.wechat.js +2 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -3
- package/lib/lifecycles/offAppEvent/index.js +2 -2
- package/lib/lifecycles/offAppHide/index.js +2 -2
- package/lib/lifecycles/offAppShow/index.js +2 -2
- package/lib/lifecycles/offError/index.js +2 -2
- package/lib/lifecycles/offThemeChange/index.js +2 -2
- package/lib/lifecycles/offWindowResize/index.js +2 -2
- package/lib/lifecycles/onAppEvent/index.js +2 -2
- package/lib/lifecycles/onAppHide/index.js +2 -2
- package/lib/lifecycles/onAppShow/index.js +2 -2
- package/lib/lifecycles/onError/index.js +2 -2
- package/lib/lifecycles/onPageNotFound/index.js +2 -2
- package/lib/lifecycles/onThemeChange/index.js +2 -2
- package/lib/lifecycles/onWindowResize/index.js +2 -2
- package/lib/navigateBack/index.js +3 -6
- package/lib/navigateTo/index.js +2 -5
- package/lib/onNavigationBarBack/index.js +1 -2
- package/lib/onNavigationBarBack/index.wechat.js +1 -2
- package/lib/panel/devInfo/index.js +84 -121
- package/lib/panel/i18n/index.d.ts +1 -1
- package/lib/panel/i18n/index.js +180 -262
- package/lib/panel/i18n/index.wechat.d.ts +1 -1
- package/lib/panel/i18n/index.wechat.js +184 -267
- package/lib/panel/normalizeNetwork.d.ts +2 -2
- package/lib/panel/normalizeNetwork.js +2 -7
- package/lib/panel/publishDps.d.ts +1 -1
- package/lib/panel/publishDps.js +13 -18
- package/lib/panel/types/devInfo.d.ts +3 -3
- package/lib/panel/types/utilities.d.ts +8 -8
- package/lib/panel/utils.js +1 -3
- package/lib/reLaunch/index.js +2 -5
- package/lib/redirectTo/index.js +2 -6
- package/lib/requestCloud/index.js +2 -2
- package/lib/requestCloud/index.wechat.js +0 -1
- package/lib/setNavigationBarBack/index.js +1 -2
- package/lib/setNavigationBarBack/index.wechat.js +1 -2
- package/lib/setNavigationBarColor/index.js +3 -6
- package/lib/setNavigationBarTitle/index.js +5 -6
- package/lib/switchTab/index.js +2 -5
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +5 -14
- package/lib/utils.wechat.d.ts +1 -1
- package/lib/utils.wechat.js +9 -21
- package/lib/viewAPI.js +13 -12
- package/package.json +25 -25
- 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
|
-
|
7
|
-
return new Promise(
|
8
|
-
|
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:
|
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:
|
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(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
19
|
-
left
|
20
|
-
top
|
21
|
-
bottom
|
22
|
-
width
|
23
|
-
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(
|
6
|
-
ref.boundingClientRect(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
15
|
-
left
|
16
|
-
top
|
17
|
-
bottom
|
18
|
-
width
|
19
|
-
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(
|
6
|
-
ref.boundingClientRect(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
15
|
-
left
|
16
|
-
top
|
17
|
-
bottom
|
18
|
-
width
|
19
|
-
height
|
13
|
+
right,
|
14
|
+
left,
|
15
|
+
top,
|
16
|
+
bottom,
|
17
|
+
width,
|
18
|
+
height
|
20
19
|
});
|
21
20
|
}).exec();
|
22
21
|
});
|
package/lib/getCdnUrl/index.d.ts
CHANGED
package/lib/getCdnUrl/index.js
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
export
|
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
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
61
|
+
const cdnPath = 'https://' + regionMap[_regionCode] + '/' + cdnShortPath;
|
62
|
+
return cdnPath;
|
28
63
|
}
|
@@ -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(
|
5
|
-
|
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(
|
5
|
-
|
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,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
|
-
|
7
|
-
|
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;
|
package/lib/navigateTo/index.js
CHANGED
@@ -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
|
-
|
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;
|