@hylid/call 4.0.8-alpha.1 → 4.0.9
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/lib/index.d.ts +4 -0
- package/lib/index.js +9 -1
- package/lib/mpWebCall.js +3 -0
- package/lib/webCall.js +1 -0
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ import { webCall, webCallAsync } from './webCall';
|
|
|
6
6
|
import { notFound } from './notFound';
|
|
7
7
|
import { Config } from './types';
|
|
8
8
|
export declare function call<T extends keyof MPApi>(name: T | ({} & string), options?: PickMPArgs<T> | Common | Callback<PickMpReturns<T>>, config?: Config): any;
|
|
9
|
+
export declare function callAsync<T = any>(apiName: string, options?: AsyncCallback<T> & any, config?: {
|
|
10
|
+
timeout: number;
|
|
11
|
+
isSync?: boolean;
|
|
12
|
+
}): Promise<any>;
|
|
9
13
|
export declare function createWebviewSrc(url: string): string;
|
|
10
14
|
export { WebViewBridge } from './webviewBridge';
|
|
11
15
|
export { mpCall, mpWebCall, webCall, notFound, mpWebCallAsync, webCallAsync };
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
var _a;
|
|
1
|
+
var _a, _b;
|
|
2
2
|
import { platform, PLATFORM } from '@hylid/env';
|
|
3
3
|
import { mpCall } from "./mpCall";
|
|
4
4
|
import { mpWebCall, mpWebCallAsync } from "./mpWebCall";
|
|
5
5
|
import { webCall, webCallAsync } from "./webCall";
|
|
6
6
|
import { notFound } from "./notFound";
|
|
7
7
|
var callMap = (_a = {}, _a[PLATFORM.MP] = mpCall, _a[PLATFORM.MPWEB] = mpWebCall, _a[PLATFORM.WEB] = webCall, _a);
|
|
8
|
+
var callMapAsync = (_b = {}, _b[PLATFORM.MPWEB] = mpWebCallAsync, _b[PLATFORM.WEB] = webCallAsync, _b);
|
|
8
9
|
export function call(name, options, config) {
|
|
9
10
|
if (platform) {
|
|
10
11
|
return callMap[platform](name, options, config);
|
|
@@ -12,6 +13,13 @@ export function call(name, options, config) {
|
|
|
12
13
|
return notFound(options, config);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
16
|
+
export function callAsync(apiName, options, config) {
|
|
17
|
+
if (platform) {
|
|
18
|
+
return callMapAsync[platform](apiName, options, config);
|
|
19
|
+
} else {
|
|
20
|
+
return Promise.reject(notFound(options, config));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
15
23
|
export function createWebviewSrc(url) {
|
|
16
24
|
var app = my.getSystemInfoSync().app;
|
|
17
25
|
var hashIndex = url.indexOf('#');
|
package/lib/mpWebCall.js
CHANGED
|
@@ -56,6 +56,9 @@ mpWebOnMessage(function (msg) {
|
|
|
56
56
|
delete callMap[serialId];
|
|
57
57
|
});
|
|
58
58
|
export function mpWebCall(api, options, config) {
|
|
59
|
+
config = __assign({
|
|
60
|
+
timeout: 20000
|
|
61
|
+
}, config);
|
|
59
62
|
var random = Math.floor(Math.random() * 1000000);
|
|
60
63
|
var serialId = api + '_' + random;
|
|
61
64
|
// 只调用,没有参数,不需要接收 jsapi 执行结果
|
package/lib/webCall.js
CHANGED
|
@@ -14,6 +14,7 @@ export function webCall(apiName, options, config) {
|
|
|
14
14
|
success = _a.success,
|
|
15
15
|
fail = _a.fail,
|
|
16
16
|
complete = _a.complete;
|
|
17
|
+
// 兼容 worldfirst 安卓端报错,后续客户端统一字段后删除
|
|
17
18
|
if (res.error || res.errorCode) {
|
|
18
19
|
fail === null || fail === void 0 ? void 0 : fail(res);
|
|
19
20
|
} else {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hylid/call",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.9",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
7
7
|
],
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@hylid/env": "^4.0.
|
|
10
|
-
"@hylid/types": "^4.0.
|
|
9
|
+
"@hylid/env": "^4.0.9",
|
|
10
|
+
"@hylid/types": "^4.0.9"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|