@hylid/call 3.0.0-alpha.1 → 3.0.0-alpha.11
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 +17 -5
- package/lib/webviewBridge.js +8 -14
- package/package.json +3 -3
package/lib/mpWebCall.js
CHANGED
|
@@ -26,11 +26,23 @@ var callbackFn = function callbackFn(res, callback) {
|
|
|
26
26
|
success = _a.success,
|
|
27
27
|
fail = _a.fail,
|
|
28
28
|
complete = _a.complete;
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
29
|
+
var _b = res || {},
|
|
30
|
+
_data_ = _b._data_,
|
|
31
|
+
_type_ = _b._type_;
|
|
32
|
+
// 新版本协议
|
|
33
|
+
if (_type_) {
|
|
34
|
+
if (_type_ === 'success') success === null || success === void 0 ? void 0 : success(_data_);
|
|
35
|
+
if (_type_ === 'fail') fail === null || fail === void 0 ? void 0 : fail(_data_);
|
|
36
|
+
return complete === null || complete === void 0 ? void 0 : complete(_data_);
|
|
37
|
+
}
|
|
38
|
+
// 下面兼容老版本
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
if (res === null || res === void 0 ? void 0 : res.error) {
|
|
41
|
+
fail === null || fail === void 0 ? void 0 : fail(res);
|
|
42
|
+
} else {
|
|
43
|
+
success === null || success === void 0 ? void 0 : success(res);
|
|
44
|
+
}
|
|
45
|
+
complete === null || complete === void 0 ? void 0 : complete(res);
|
|
34
46
|
};
|
|
35
47
|
export var mpWebCall = function () {
|
|
36
48
|
var callMap = {};
|
package/lib/webviewBridge.js
CHANGED
|
@@ -144,12 +144,12 @@ var WebViewBridge = /** @class */function () {
|
|
|
144
144
|
type_1 = (config || {}).type;
|
|
145
145
|
if (!(type_1 === 'callback')) return [3 /*break*/, 1];
|
|
146
146
|
// @ts-ignore
|
|
147
|
-
my[api_1](function (
|
|
147
|
+
my[api_1](function (result) {
|
|
148
148
|
_this.webview.postMessage({
|
|
149
149
|
api: api_1,
|
|
150
150
|
serialId: serialId_1,
|
|
151
151
|
type: type_1,
|
|
152
|
-
result:
|
|
152
|
+
result: result
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
return [3 /*break*/, 3];
|
|
@@ -181,20 +181,14 @@ var WebViewBridge = /** @class */function () {
|
|
|
181
181
|
var options = __assign(__assign({}, _options), {
|
|
182
182
|
success: function success(res) {
|
|
183
183
|
resolve({
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
_type_: 'success',
|
|
185
|
+
_data_: res
|
|
186
186
|
});
|
|
187
187
|
},
|
|
188
188
|
fail: function fail(res) {
|
|
189
189
|
resolve({
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
});
|
|
193
|
-
},
|
|
194
|
-
complete: function complete(res) {
|
|
195
|
-
resolve({
|
|
196
|
-
type: 'complete',
|
|
197
|
-
data: res
|
|
190
|
+
_type_: 'fail',
|
|
191
|
+
_data_: res
|
|
198
192
|
});
|
|
199
193
|
}
|
|
200
194
|
});
|
|
@@ -203,8 +197,8 @@ var WebViewBridge = /** @class */function () {
|
|
|
203
197
|
if (type === 'sync') {
|
|
204
198
|
var data_1 = mpApi(_options);
|
|
205
199
|
resolve({
|
|
206
|
-
|
|
207
|
-
|
|
200
|
+
_type_: 'success',
|
|
201
|
+
_data_: data_1
|
|
208
202
|
});
|
|
209
203
|
}
|
|
210
204
|
if (type === 'async') {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hylid/call",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.11",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
7
7
|
],
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@hylid/env": "^3.0.0-alpha.
|
|
10
|
-
"@hylid/types": "^3.0.0-alpha.
|
|
9
|
+
"@hylid/env": "^3.0.0-alpha.11",
|
|
10
|
+
"@hylid/types": "^3.0.0-alpha.11"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|