@micro-zoe/micro-app 1.0.0-alpha.4 → 1.0.0-alpha.5
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/index.esm.js +15 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.map +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = '1.0.0-alpha.
|
|
1
|
+
const version = '1.0.0-alpha.5';
|
|
2
2
|
// do not use isUndefined
|
|
3
3
|
const isBrowser = typeof window !== 'undefined';
|
|
4
4
|
// do not use isUndefined
|
|
@@ -4425,10 +4425,14 @@ class CreateApp {
|
|
|
4425
4425
|
execScripts(this.source.scripts, this, (isFinished) => {
|
|
4426
4426
|
if (!this.umdMode) {
|
|
4427
4427
|
const { mount, unmount } = this.getUmdLibraryHooks();
|
|
4428
|
+
/**
|
|
4429
|
+
* umdHookUnmount can works in non UMD mode
|
|
4430
|
+
* register with window.unmount
|
|
4431
|
+
*/
|
|
4432
|
+
this.umdHookUnmount = unmount;
|
|
4428
4433
|
// if mount & unmount is function, the sub app is umd mode
|
|
4429
4434
|
if (isFunction(mount) && isFunction(unmount)) {
|
|
4430
4435
|
this.umdHookMount = mount;
|
|
4431
|
-
this.umdHookUnmount = unmount;
|
|
4432
4436
|
this.umdMode = true;
|
|
4433
4437
|
if (this.sandBox)
|
|
4434
4438
|
this.sandBox.proxyWindow.__MICRO_APP_UMD_MODE__ = true;
|
|
@@ -4500,7 +4504,7 @@ class CreateApp {
|
|
|
4500
4504
|
* send an unmount event to the micro app or call umd unmount hook
|
|
4501
4505
|
* before the sandbox is cleared
|
|
4502
4506
|
*/
|
|
4503
|
-
if (this.umdHookUnmount) {
|
|
4507
|
+
if (isFunction(this.umdHookUnmount)) {
|
|
4504
4508
|
try {
|
|
4505
4509
|
umdHookUnmountResult = this.umdHookUnmount();
|
|
4506
4510
|
}
|
|
@@ -4622,13 +4626,18 @@ class CreateApp {
|
|
|
4622
4626
|
}
|
|
4623
4627
|
// get umd library, if it not exist, return empty object
|
|
4624
4628
|
getUmdLibraryHooks() {
|
|
4625
|
-
var _a, _b;
|
|
4629
|
+
var _a, _b, _c, _d;
|
|
4626
4630
|
// after execScripts, the app maybe unmounted
|
|
4627
4631
|
if (appStates.UNMOUNT !== this.state) {
|
|
4628
4632
|
const global = ((_b = (_a = this.sandBox) === null || _a === void 0 ? void 0 : _a.proxyWindow) !== null && _b !== void 0 ? _b : globalEnv.rawWindow);
|
|
4629
4633
|
this.libraryName = getRootContainer(this.container).getAttribute('library') || `micro-app-${this.name}`;
|
|
4630
|
-
|
|
4631
|
-
|
|
4634
|
+
if (isObject(global[this.libraryName])) {
|
|
4635
|
+
return global[this.libraryName];
|
|
4636
|
+
}
|
|
4637
|
+
return {
|
|
4638
|
+
mount: (_c = this.sandBox) === null || _c === void 0 ? void 0 : _c.proxyWindow.mount,
|
|
4639
|
+
unmount: (_d = this.sandBox) === null || _d === void 0 ? void 0 : _d.proxyWindow.unmount,
|
|
4640
|
+
};
|
|
4632
4641
|
}
|
|
4633
4642
|
return {};
|
|
4634
4643
|
}
|