@hylid/call 4.0.6 → 4.0.8-alpha.1
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/mpWebCall.js +10 -0
- package/lib/types.d.ts +1 -1
- package/lib/utils.d.ts +4 -0
- package/lib/utils.js +6 -0
- package/lib/webCall.js +1 -1
- package/package.json +3 -3
package/lib/mpWebCall.js
CHANGED
|
@@ -9,6 +9,7 @@ var __assign = this && this.__assign || function () {
|
|
|
9
9
|
return __assign.apply(this, arguments);
|
|
10
10
|
};
|
|
11
11
|
import { mpWebOnMessage, mpWebPostMessage } from "./mpWebBridge";
|
|
12
|
+
import { createError } from "./utils";
|
|
12
13
|
import { alipayJSBridge } from "./webCall";
|
|
13
14
|
// 关联 postMessage 和 onMessage,根据 serialId 执行回调
|
|
14
15
|
var callMap = {};
|
|
@@ -71,6 +72,15 @@ export function mpWebCall(api, options, config) {
|
|
|
71
72
|
isSync: config === null || config === void 0 ? void 0 : config.isSync
|
|
72
73
|
};
|
|
73
74
|
mpWebPostMessage(message);
|
|
75
|
+
// 设置 jsapi 通信超时时间
|
|
76
|
+
var _options = options;
|
|
77
|
+
if ((config === null || config === void 0 ? void 0 : config.timeout) && (_options === null || _options === void 0 ? void 0 : _options.fail)) {
|
|
78
|
+
setTimeout(function () {
|
|
79
|
+
if (!callMap[serialId]) return;
|
|
80
|
+
delete callMap[serialId];
|
|
81
|
+
_options.fail(createError('TIMEOUT'));
|
|
82
|
+
}, config.timeout);
|
|
83
|
+
}
|
|
74
84
|
}
|
|
75
85
|
function broadcastGlobalData(key, result) {
|
|
76
86
|
var message = {
|
package/lib/types.d.ts
CHANGED
package/lib/utils.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ declare const ERROR: {
|
|
|
20
20
|
code: number;
|
|
21
21
|
message: (name: string) => string;
|
|
22
22
|
};
|
|
23
|
+
TIMEOUT: {
|
|
24
|
+
code: number;
|
|
25
|
+
message: (name: string) => string;
|
|
26
|
+
};
|
|
23
27
|
};
|
|
24
28
|
export declare const createError: (type: keyof typeof ERROR, name?: string) => {
|
|
25
29
|
errorCode: number;
|
package/lib/utils.js
CHANGED
|
@@ -28,6 +28,12 @@ var ERROR = {
|
|
|
28
28
|
message: function message(name) {
|
|
29
29
|
return "".concat(name, " exec fail, params error");
|
|
30
30
|
}
|
|
31
|
+
},
|
|
32
|
+
TIMEOUT: {
|
|
33
|
+
code: -6,
|
|
34
|
+
message: function message(name) {
|
|
35
|
+
return "".concat(name, " exec fail, timeout");
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
};
|
|
33
39
|
export var createError = function createError(type, name) {
|
package/lib/webCall.js
CHANGED
|
@@ -14,7 +14,7 @@ export function webCall(apiName, options, config) {
|
|
|
14
14
|
success = _a.success,
|
|
15
15
|
fail = _a.fail,
|
|
16
16
|
complete = _a.complete;
|
|
17
|
-
if (res.error) {
|
|
17
|
+
if (res.error || res.errorCode) {
|
|
18
18
|
fail === null || fail === void 0 ? void 0 : fail(res);
|
|
19
19
|
} else {
|
|
20
20
|
success === null || success === void 0 ? void 0 : success(res);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hylid/call",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.8-alpha.1",
|
|
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.8-alpha.1",
|
|
10
|
+
"@hylid/types": "^4.0.8-alpha.1"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|