@hylid/call 2.12.0-alpha.41 → 3.0.0-alpha.2
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 +11 -1
- package/lib/webviewBridge.js +18 -13
- package/package.json +3 -3
package/lib/mpWebCall.js
CHANGED
|
@@ -26,8 +26,18 @@ var callbackFn = function callbackFn(res, callback) {
|
|
|
26
26
|
success = _a.success,
|
|
27
27
|
fail = _a.fail,
|
|
28
28
|
complete = _a.complete;
|
|
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
|
+
// 下面兼容老版本
|
|
29
39
|
// @ts-ignore
|
|
30
|
-
if (
|
|
40
|
+
if (res === null || res === void 0 ? void 0 : res.error) {
|
|
31
41
|
fail === null || fail === void 0 ? void 0 : fail(res);
|
|
32
42
|
} else {
|
|
33
43
|
success === null || success === void 0 ? void 0 : success(res);
|
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];
|
|
@@ -179,22 +179,27 @@ var WebViewBridge = /** @class */function () {
|
|
|
179
179
|
type = _a === void 0 ? 'async' : _a;
|
|
180
180
|
return new Promise(function (resolve) {
|
|
181
181
|
var options = __assign(__assign({}, _options), {
|
|
182
|
-
success:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}, res));
|
|
188
|
-
} else {
|
|
189
|
-
resolve(res);
|
|
190
|
-
}
|
|
182
|
+
success: function success(res) {
|
|
183
|
+
resolve({
|
|
184
|
+
_type_: 'success',
|
|
185
|
+
_data_: res
|
|
186
|
+
});
|
|
191
187
|
},
|
|
192
|
-
|
|
188
|
+
fail: function fail(res) {
|
|
189
|
+
resolve({
|
|
190
|
+
_type_: 'fail',
|
|
191
|
+
_data_: res
|
|
192
|
+
});
|
|
193
|
+
}
|
|
193
194
|
});
|
|
194
195
|
// @ts-ignore
|
|
195
196
|
var mpApi = _this.customApi[api] || my[api];
|
|
196
197
|
if (type === 'sync') {
|
|
197
|
-
|
|
198
|
+
var data_1 = mpApi(_options);
|
|
199
|
+
resolve({
|
|
200
|
+
_type_: 'success',
|
|
201
|
+
_data_: data_1
|
|
202
|
+
});
|
|
198
203
|
}
|
|
199
204
|
if (type === 'async') {
|
|
200
205
|
if (!mpApi) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hylid/call",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
7
7
|
],
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@hylid/env": "^
|
|
10
|
-
"@hylid/types": "^
|
|
9
|
+
"@hylid/env": "^3.0.0-alpha.2",
|
|
10
|
+
"@hylid/types": "^3.0.0-alpha.2"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|