@hylid/call 2.12.0-alpha.40 → 3.0.0-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 CHANGED
@@ -26,13 +26,11 @@ var callbackFn = function callbackFn(res, callback) {
26
26
  success = _a.success,
27
27
  fail = _a.fail,
28
28
  complete = _a.complete;
29
- // @ts-ignore
30
- if (res.error) {
31
- fail === null || fail === void 0 ? void 0 : fail(res);
32
- } else {
33
- success === null || success === void 0 ? void 0 : success(res);
34
- }
35
- complete === null || complete === void 0 ? void 0 : complete(res);
29
+ var data = res.data,
30
+ type = res.type;
31
+ if (type === 'success') success === null || success === void 0 ? void 0 : success(data);
32
+ if (type === 'fail') fail === null || fail === void 0 ? void 0 : fail(data);
33
+ if (type === 'complete') complete === null || complete === void 0 ? void 0 : complete(data);
36
34
  };
37
35
  export var mpWebCall = function () {
38
36
  var callMap = {};
@@ -179,22 +179,33 @@ 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: resolve,
182
+ success: function success(res) {
183
+ resolve({
184
+ type: 'success',
185
+ data: res
186
+ });
187
+ },
183
188
  fail: function fail(res) {
184
- if (!res || !res.error) {
185
- resolve(__assign({
186
- error: "".concat(api, " error")
187
- }, res));
188
- } else {
189
- resolve(res);
190
- }
189
+ resolve({
190
+ type: 'fail',
191
+ data: res
192
+ });
191
193
  },
192
- complete: resolve
194
+ complete: function complete(res) {
195
+ resolve({
196
+ type: 'complete',
197
+ data: res
198
+ });
199
+ }
193
200
  });
194
201
  // @ts-ignore
195
202
  var mpApi = _this.customApi[api] || my[api];
196
203
  if (type === 'sync') {
197
- resolve(mpApi(options));
204
+ var data_1 = mpApi(_options);
205
+ resolve({
206
+ type: 'success',
207
+ data: data_1
208
+ });
198
209
  }
199
210
  if (type === 'async') {
200
211
  if (!mpApi) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@hylid/call",
3
- "version": "2.12.0-alpha.40",
3
+ "version": "3.0.0-alpha.1",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "lib"
7
7
  ],
8
8
  "dependencies": {
9
- "@hylid/env": "^2.12.0-alpha.40",
10
- "@hylid/types": "^2.12.0-alpha.40"
9
+ "@hylid/env": "^3.0.0-alpha.1",
10
+ "@hylid/types": "^3.0.0-alpha.1"
11
11
  },
12
12
  "publishConfig": {
13
13
  "access": "public"