@micro-zoe/micro-app 0.8.9 → 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.9';
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
@@ -3755,6 +3764,7 @@ class MicroApp extends EventCenterForBaseApp {
3755
3764
  options.preFetchApps && preFetch(options.preFetchApps);
3756
3765
  // load global assets when browser is idle
3757
3766
  options.globalAssets && getGlobalAssets(options.globalAssets);
3767
+ isFunction(options.excludeAssetFilter) && (this.excludeAssetFilter = options.excludeAssetFilter);
3758
3768
  if (isPlainObject(options.plugins)) {
3759
3769
  const modules = options.plugins.modules;
3760
3770
  if (isPlainObject(modules)) {