@goldfishjs/core
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -0,1 +1,3 @@ | ||
import _observable from "@goldfishjs/reactive-connect/lib/decorators/observable"; | ||
import _state from "@goldfishjs/reactive-connect/lib/decorators/state"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
@@ -19,3 +21,14 @@ import _asyncForEach from "@goldfishjs/utils/lib/asyncForEach"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _typeof from "@babel/runtime/helpers/typeof"; | ||
var __decorate = this && this.__decorate || function (decorators, target, key, desc) { | ||
var c = arguments.length, | ||
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, | ||
d; | ||
if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) { | ||
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
} | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) { | ||
@@ -76,2 +89,11 @@ function adopt(value) { | ||
_this.pluginHub = new _PluginHub(); | ||
/** | ||
* The error in Promise will not be catch by Alipay, | ||
* so we should do it by ourself. | ||
* | ||
* @type {*} | ||
* @memberof AppStore | ||
*/ | ||
_this.globalErrorInPromise = null; | ||
return _this; | ||
@@ -129,3 +151,9 @@ } | ||
this.pluginHub.init(); | ||
this.pluginHub.init()["catch"](function (e) { | ||
// The Alipay does not catch the exception in Promise, | ||
// so print the error here for debug. | ||
console.error(e); | ||
_this2.globalErrorInPromise = e; | ||
throw e; | ||
}); | ||
} | ||
@@ -453,2 +481,5 @@ /** | ||
export { AppStore as default }; | ||
__decorate([_state], AppStore.prototype, "globalErrorInPromise", void 0); | ||
AppStore = __decorate([_observable], AppStore); | ||
export default AppStore; |
@@ -53,3 +53,3 @@ import _createMiniApp from "@goldfishjs/reactive-connect/lib/createMiniApp"; | ||
_regeneratorRuntime.mark(function _callee() { | ||
var store; | ||
var store, app; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -61,27 +61,40 @@ while (1) { | ||
store.isInitLoading = true; | ||
store.updatePages(options); | ||
_context.next = 5; | ||
store.updatePages(options); // Call onError when there is uncaught error in Promise. | ||
app = getApp(); | ||
store.watch(function () { | ||
return store.globalErrorInPromise; | ||
}, function (error) { | ||
var onError = app.onError; | ||
if (error && onError) { | ||
onError(error); | ||
} | ||
}, { | ||
immediate: true | ||
}); | ||
_context.next = 7; | ||
return store.waitForReady(); | ||
case 5: | ||
case 7: | ||
store.initFeedback(); | ||
_context.prev = 6; | ||
_context.next = 9; | ||
_context.prev = 8; | ||
_context.next = 11; | ||
return store.fetchInitData(); | ||
case 9: | ||
_context.next = 14; | ||
case 11: | ||
_context.next = 16; | ||
break; | ||
case 11: | ||
_context.prev = 11; | ||
_context.t0 = _context["catch"](6); | ||
case 13: | ||
_context.prev = 13; | ||
_context.t0 = _context["catch"](8); | ||
throw _context.t0; | ||
case 14: | ||
_context.prev = 14; | ||
case 16: | ||
_context.prev = 16; | ||
store.isInitLoading = false; | ||
return _context.finish(14); | ||
return _context.finish(16); | ||
case 17: | ||
case 19: | ||
case "end": | ||
@@ -91,3 +104,3 @@ return _context.stop(); | ||
} | ||
}, _callee, this, [[6, 11, 14, 17]]); | ||
}, _callee, this, [[8, 13, 16, 19]]); | ||
})); | ||
@@ -94,0 +107,0 @@ }); |
{ | ||
"name": "@goldfishjs/core", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "goldfish", | ||
@@ -19,5 +19,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@goldfishjs/plugins": "^0.0.15", | ||
"@goldfishjs/reactive-connect": "^0.0.15", | ||
"@goldfishjs/utils": "^0.0.15", | ||
"@goldfishjs/plugins": "^0.0.16", | ||
"@goldfishjs/reactive-connect": "^0.0.16", | ||
"@goldfishjs/utils": "^0.0.16", | ||
"mini-types": "^0.1.0" | ||
@@ -24,0 +24,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
import { AppStore as BaseAppStore } from '@goldfishjs/reactive-connect'; | ||
import { AppStore as BaseAppStore, observable, state } from '@goldfishjs/reactive-connect'; | ||
import { | ||
@@ -25,2 +25,3 @@ PluginHub, | ||
*/ | ||
@observable | ||
export default class AppStore extends BaseAppStore { | ||
@@ -48,2 +49,12 @@ /** | ||
/** | ||
* The error in Promise will not be catch by Alipay, | ||
* so we should do it by ourself. | ||
* | ||
* @type {*} | ||
* @memberof AppStore | ||
*/ | ||
@state | ||
public globalErrorInPromise: any = null; | ||
/** | ||
* Set the config immediately after the AppStore is created. | ||
@@ -91,3 +102,9 @@ * | ||
// Initialize all plugins. | ||
this.pluginHub.init(); | ||
this.pluginHub.init().catch((e) => { | ||
// The Alipay does not catch the exception in Promise, | ||
// so print the error here for debug. | ||
console.error(e); | ||
this.globalErrorInPromise = e; | ||
throw e; | ||
}); | ||
} | ||
@@ -94,0 +111,0 @@ |
@@ -30,2 +30,18 @@ import { createMiniApp, AppOptions, AppInstance, attachLogic } from '@goldfishjs/reactive-connect'; | ||
store.updatePages(options); | ||
// Call onError when there is uncaught error in Promise. | ||
const app = getApp(); | ||
store.watch( | ||
() => store.globalErrorInPromise, | ||
(error) => { | ||
const onError = (app as any).onError; | ||
if (error && onError) { | ||
onError(error); | ||
} | ||
}, | ||
{ | ||
immediate: true, | ||
}, | ||
); | ||
await store.waitForReady(); | ||
@@ -32,0 +48,0 @@ store.initFeedback(); |
@@ -26,2 +26,10 @@ /// <reference types="mini-types" /> | ||
/** | ||
* The error in Promise will not be catch by Alipay, | ||
* so we should do it by ourself. | ||
* | ||
* @type {*} | ||
* @memberof AppStore | ||
*/ | ||
globalErrorInPromise: any; | ||
/** | ||
* Set the config immediately after the AppStore is created. | ||
@@ -28,0 +36,0 @@ * |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51724
1504
+ Added@goldfishjs/bridge@0.0.16(transitive)
+ Added@goldfishjs/plugins@0.0.16(transitive)
+ Added@goldfishjs/reactive@0.0.16(transitive)
+ Added@goldfishjs/reactive-connect@0.0.16(transitive)
+ Added@goldfishjs/requester@0.0.16(transitive)
+ Added@goldfishjs/route@0.0.16(transitive)
+ Added@goldfishjs/utils@0.0.16(transitive)
- Removed@goldfishjs/bridge@0.0.15(transitive)
- Removed@goldfishjs/plugins@0.0.15(transitive)
- Removed@goldfishjs/reactive@0.0.15(transitive)
- Removed@goldfishjs/reactive-connect@0.0.15(transitive)
- Removed@goldfishjs/requester@0.0.15(transitive)
- Removed@goldfishjs/route@0.0.15(transitive)
- Removed@goldfishjs/utils@0.0.15(transitive)
Updated@goldfishjs/plugins@^0.0.16
Updated@goldfishjs/utils@^0.0.16