@micro-zoe/micro-app 0.8.7 → 0.8.10

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.d.ts CHANGED
@@ -45,6 +45,7 @@ declare module '@micro-zoe/micro-app/micro_app' {
45
45
  plugins?: plugins;
46
46
  fetch?: fetchType;
47
47
  preFetch: typeof preFetch;
48
+ excludeAssetFilter?: (assetUrl: string) => boolean;
48
49
  start(options?: OptionsType): void;
49
50
  }
50
51
  const _default: MicroApp;
package/lib/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = '0.8.7';
1
+ const version = '0.8.10';
2
2
  // do not use isUndefined
3
3
  const isBrowser = typeof window !== 'undefined';
4
4
  // do not use isUndefined
@@ -986,7 +986,11 @@ function handleNewNode(parent, child, app) {
986
986
  dynamicElementInMicroAppMap.set(child, linkReplaceComment);
987
987
  return linkReplaceComment;
988
988
  }
989
- else if (child.hasAttribute('ignore') || checkIgnoreUrl(child.getAttribute('href'), app.name)) {
989
+ else if (child.hasAttribute('ignore') ||
990
+ checkIgnoreUrl(child.getAttribute('href'), app.name) ||
991
+ (child.href &&
992
+ isFunction(microApp.excludeAssetFilter) &&
993
+ microApp.excludeAssetFilter(child.href))) {
990
994
  return child;
991
995
  }
992
996
  const { url, info, replaceComment } = extractLinkFromHtml(child, parent, app, true);
@@ -1004,6 +1008,11 @@ function handleNewNode(parent, child, app) {
1004
1008
  return child;
1005
1009
  }
1006
1010
  else if (child instanceof HTMLScriptElement) {
1011
+ if (child.src &&
1012
+ isFunction(microApp.excludeAssetFilter) &&
1013
+ microApp.excludeAssetFilter(child.src)) {
1014
+ return child;
1015
+ }
1007
1016
  const { replaceComment, url, info } = extractScriptElement(child, parent, app, true) || {};
1008
1017
  if (url && info) {
1009
1018
  if (!info.isExternal) { // inline script
@@ -1525,7 +1534,7 @@ function extractScriptElement(script, parent, app, isDynamic = false) {
1525
1534
  if (script.hasAttribute('exclude') || checkExcludeUrl(src, app.name)) {
1526
1535
  replaceComment = document.createComment('script element with exclude attribute removed by micro-app');
1527
1536
  }
1528
- else if ((script.type && !['text/javascript', 'text/ecmascript', 'application/javascript', 'application/ecmascript', 'module'].includes(script.type)) ||
1537
+ else if ((script.type && !['text/javascript', 'text/ecmascript', 'application/javascript', 'application/ecmascript', 'module', 'systemjs-module', 'systemjs-importmap'].includes(script.type)) ||
1529
1538
  script.hasAttribute('ignore') || checkIgnoreUrl(src, app.name)) {
1530
1539
  return null;
1531
1540
  }
@@ -2581,20 +2590,22 @@ class SandBox {
2581
2590
  }
2582
2591
  }
2583
2592
  }
2584
- stop() {
2593
+ stop(umdMode) {
2585
2594
  if (this.active) {
2586
2595
  this.active = false;
2587
2596
  this.releaseEffect();
2588
2597
  this.microAppWindow.microApp.clearDataListener();
2589
2598
  this.microAppWindow.microApp.clearGlobalDataListener();
2590
- this.injectedKeys.forEach((key) => {
2591
- Reflect.deleteProperty(this.microAppWindow, key);
2592
- });
2593
- this.injectedKeys.clear();
2594
- this.escapeKeys.forEach((key) => {
2595
- Reflect.deleteProperty(globalEnv.rawWindow, key);
2596
- });
2597
- this.escapeKeys.clear();
2599
+ if (!umdMode) {
2600
+ this.injectedKeys.forEach((key) => {
2601
+ Reflect.deleteProperty(this.microAppWindow, key);
2602
+ });
2603
+ this.injectedKeys.clear();
2604
+ this.escapeKeys.forEach((key) => {
2605
+ Reflect.deleteProperty(globalEnv.rawWindow, key);
2606
+ });
2607
+ this.escapeKeys.clear();
2608
+ }
2598
2609
  if (--SandBox.activeCount === 0) {
2599
2610
  releaseEffectDocumentEvent();
2600
2611
  releasePatches();
@@ -3098,7 +3109,7 @@ class CreateApp {
3098
3109
  cloneContainer(this.container, this.source.html, false);
3099
3110
  }
3100
3111
  // this.container maybe contains micro-app element, stop sandbox should exec after cloneContainer
3101
- (_a = this.sandBox) === null || _a === void 0 ? void 0 : _a.stop();
3112
+ (_a = this.sandBox) === null || _a === void 0 ? void 0 : _a.stop(this.umdMode);
3102
3113
  if (!getActiveApps().length) {
3103
3114
  releasePatchSetAttribute();
3104
3115
  }
@@ -3753,6 +3764,7 @@ class MicroApp extends EventCenterForBaseApp {
3753
3764
  options.preFetchApps && preFetch(options.preFetchApps);
3754
3765
  // load global assets when browser is idle
3755
3766
  options.globalAssets && getGlobalAssets(options.globalAssets);
3767
+ isFunction(options.excludeAssetFilter) && (this.excludeAssetFilter = options.excludeAssetFilter);
3756
3768
  if (isPlainObject(options.plugins)) {
3757
3769
  const modules = options.plugins.modules;
3758
3770
  if (isPlainObject(modules)) {