@module-federation/bridge-vue3 0.0.0-next-20240903075658 → 0.0.0-next-20240904030559

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/CHANGELOG.md CHANGED
@@ -1,14 +1,10 @@
1
1
  # @module-federation/bridge-vue3
2
2
 
3
- ## 0.0.0-next-20240903075658
3
+ ## 0.0.0-next-20240904030559
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 3082116: feat: support module isolated reported
8
- - Updated dependencies [3082116]
9
- - Updated dependencies [813680f]
10
- - @module-federation/runtime@0.0.0-next-20240903075658
11
- - @module-federation/bridge-shared@0.0.0-next-20240903075658
7
+ - @module-federation/bridge-shared@0.0.0-next-20240904030559
12
8
 
13
9
  ## 0.6.0
14
10
 
package/dist/index.cjs.js CHANGED
@@ -1,59 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vue=require("vue"),VueRouter=require("vue-router");function _interopNamespaceDefault(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Vue__namespace=_interopNamespaceDefault(Vue),VueRouter__namespace=_interopNamespaceDefault(VueRouter);var a=Object.defineProperty,c=(t,e,n)=>e in t?a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,i=(t,e,n)=>(c(t,typeof e!="symbol"?e+"":e,n),n);class g{constructor(e){i(this,"name"),i(this,"isDebugEnabled"),i(this,"color"),this.name=e,this.isDebugEnabled=!1,this.color=this.stringToColor(e),typeof window<"u"&&typeof localStorage<"u"&&(this.isDebugEnabled=localStorage.getItem("debug")==="true"),typeof process<"u"&&process.env&&(this.isDebugEnabled=process.env.DEBUG==="true")}log(...e){var n,o;if(this.isDebugEnabled){const r=`color: ${this.color}; font-weight: bold`,s=`%c[${this.name}]`,u=((o=(n=new Error().stack)==null?void 0:n.split(`
2
- `)[2])==null?void 0:o.trim())||"Stack information not available";typeof console<"u"&&console.debug&&console.debug(s,r,...e,`
3
- (${u})`)}}stringToColor(e){let n=0;for(let r=0;r<e.length;r++)n=e.charCodeAt(r)+((n<<5)-n);let o="#";for(let r=0;r<3;r++){const s=n>>r*8&255;o+=("00"+s.toString(16)).substr(-2)}return o}}function f(){const t=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(t)}const LoggerInstance=new g("vue3-bridge");function createBridgeComponent(t){const e=new Map;return()=>({__APP_VERSION__:"0.6.0",render(n){var l;LoggerInstance.log("createBridgeComponent render Info",n);const o=Vue__namespace.createApp(t.rootComponent);e.set(n.dom,o),(l=t==null?void 0:t.renderLifecycle)==null||l.call(t,n);const r=t.appOptions({basename:n.basename,memoryRoute:n.memoryRoute}),s=n.memoryRoute?VueRouter__namespace.createMemoryHistory(n.basename):VueRouter__namespace.createWebHistory(n.basename),u=VueRouter__namespace.createRouter({...r.router.options,history:s,routes:r.router.getRoutes()});LoggerInstance.log("createBridgeComponent render router info>>>",{name:n.moduleName,router:u}),n.memoryRoute?u.push(n.memoryRoute.entryPath).then(()=>{o.use(u),o.mount(n.dom)}):(o.use(u),o.mount(n.dom))},destroy(n){var r;LoggerInstance.log("createBridgeComponent destroy Info",n);const o=e.get(n==null?void 0:n.dom);(r=t==null?void 0:t.destroyLifecycle)==null||r.call(t,n),o==null||o.unmount()}})}const MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",BROWSER_LOG_VALUE="1",SEPARATOR=":";function isBrowserEnv(){return typeof window<"u"}function isDebugMode(){return typeof process<"u"&&process.env&&process.env.FEDERATION_DEBUG?!!process.env.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&!!FEDERATION_DEBUG}const DEBUG_LOG="[ FEDERATION DEBUG ]";function safeGetLocalStorageItem(){try{if(typeof window<"u"&&window.localStorage)return localStorage.getItem(BROWSER_LOG_KEY)===BROWSER_LOG_VALUE}catch{return typeof document<"u"}return!1}let Logger=class{info(e,n){if(this.enable){const o=safeToString(n)||"";isBrowserEnv()?console.info(`%c ${this.identifier}: ${e} ${o}`,"color:#3300CC"):console.info("\x1B[34m%s",`${this.identifier}: ${e} ${o?`
4
- ${o}`:""}`)}}logOriginalInfo(...e){this.enable&&(isBrowserEnv()?(console.info(`%c ${this.identifier}: OriginalInfo`,"color:#3300CC"),console.log(...e)):(console.info(`%c ${this.identifier}: OriginalInfo`,"color:#3300CC"),console.log(...e)))}constructor(e){this.enable=!1,this.identifier=e||DEBUG_LOG,isBrowserEnv()&&safeGetLocalStorageItem()?this.enable=!0:isDebugMode()&&(this.enable=!0)}};const LOG_CATEGORY$1="[ Federation Runtime ]";new Logger;const composeKeyWithSeparator=function(...t){return t.length?t.reduce((e,n)=>n?e?`${e}${SEPARATOR}${n}`:n:e,""):""},getResourceUrl=(t,e)=>{if("getPublicPath"in t){let n;return t.getPublicPath.startsWith("function")?n=new Function("return "+t.getPublicPath)()():n=new Function(t.getPublicPath)(),`${n}${e}`}else return"publicPath"in t?`${t.publicPath}${e}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",t,e),"")},warn$1=t=>{console.warn(`${LOG_CATEGORY$1}: ${t}`)};function safeToString(t){try{return JSON.stringify(t,null,2)}catch{return""}}function _extends$9(){return _extends$9=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},_extends$9.apply(this,arguments)}const simpleJoinRemoteEntry=(t,e)=>{if(!t)return e;const o=(r=>{if(r===".")return"";if(r.startsWith("./"))return r.replace("./","");if(r.startsWith("/")){const s=r.slice(1);return s.endsWith("/")?s.slice(0,-1):s}return r})(t);return o?o.endsWith("/")?`${o}${e}`:`${o}/${e}`:e};function inferAutoPublicPath(t){return t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(t,e={}){var n,o;const{remotes:r={},overrides:s={},version:u}=e;let l;const d=()=>"publicPath"in t.metaData?t.metaData.publicPath==="auto"&&u?inferAutoPublicPath(u):t.metaData.publicPath:t.metaData.getPublicPath,h=Object.keys(s);let p={};if(!Object.keys(r).length){var m;p=((m=t.remotes)==null?void 0:m.reduce((S,T)=>{let w;const A=T.federationContainerName;return h.includes(A)?w=s[A]:"version"in T?w=T.version:w=T.entry,S[A]={matchedVersion:w},S},{}))||{}}Object.keys(r).forEach(S=>p[S]={matchedVersion:h.includes(S)?s[S]:r[S]});const{remoteEntry:{path:_,name:y,type:E},types:R,buildInfo:{buildVersion:b},globalName:v,ssrRemoteEntry:O}=t.metaData,{exposes:I}=t;let $={version:u||"",buildVersion:b,globalName:v,remoteEntry:simpleJoinRemoteEntry(_,y),remoteEntryType:E,remoteTypes:simpleJoinRemoteEntry(R.path,R.name),remoteTypesZip:R.zip||"",remoteTypesAPI:R.api||"",remotesInfo:p,shared:t==null?void 0:t.shared.map(S=>({assets:S.assets,sharedName:S.name,version:S.version})),modules:I==null?void 0:I.map(S=>({moduleName:S.name,modulePath:S.path,assets:S.assets}))};if((n=t.metaData)!=null&&n.prefetchInterface){const S=t.metaData.prefetchInterface;$=_extends$9({},$,{prefetchInterface:S})}if((o=t.metaData)!=null&&o.prefetchEntry){const{path:S,name:T,type:w}=t.metaData.prefetchEntry;$=_extends$9({},$,{prefetchEntry:simpleJoinRemoteEntry(S,T),prefetchEntryType:w})}if("publicPath"in t.metaData?l=_extends$9({},$,{publicPath:d()}):l=_extends$9({},$,{getPublicPath:d()}),O){const S=simpleJoinRemoteEntry(O.path,O.name);l.ssrRemoteEntry=S,l.ssrRemoteEntryType="commonjs-module"}return l}function isManifestProvider(t){return!!("remoteEntry"in t&&t.remoteEntry.includes(MANIFEST_EXT))}async function safeWrapper(t,e){try{return await t()}catch(n){warn$1(n);return}}function isStaticResourcesEqual(t,e){const n=/^(https?:)?\/\//i,o=t.replace(n,"").replace(/\/$/,""),r=e.replace(n,"").replace(/\/$/,"");return o===r}function createScript(t){let e=null,n=!0,o=2e4,r;const s=document.getElementsByTagName("script");for(let l=0;l<s.length;l++){const d=s[l],h=d.getAttribute("src");if(h&&isStaticResourcesEqual(h,t.url)){e=d,n=!1;break}}if(!e){e=document.createElement("script"),e.type="text/javascript",e.src=t.url;let l;t.createScriptHook&&(l=t.createScriptHook(t.url,t.attrs),l instanceof HTMLScriptElement?e=l:typeof l=="object"&&("script"in l&&l.script&&(e=l.script),"timeout"in l&&l.timeout&&(o=l.timeout)));const d=t.attrs;d&&!l&&Object.keys(d).forEach(h=>{e&&(h==="async"||h==="defer"?e[h]=d[h]:e.getAttribute(h)||e.setAttribute(h,d[h]))})}const u=(l,d)=>{var h;if(clearTimeout(r),e&&(e.onerror=null,e.onload=null,safeWrapper(()=>{const{needDeleteScript:m=!0}=t;m&&e!=null&&e.parentNode&&e.parentNode.removeChild(e)}),l)){var p;const m=l(d);return t==null||(p=t.cb)==null||p.call(t),m}t==null||(h=t.cb)==null||h.call(t)};return e.onerror=u.bind(null,e.onerror),e.onload=u.bind(null,e.onload),r=setTimeout(()=>{u(null,new Error(`Remote script "${t.url}" time-outed.`))},o),{script:e,needAttach:n}}function createLink(t){let e=null,n=!0;const o=document.getElementsByTagName("link");for(let s=0;s<o.length;s++){const u=o[s],l=u.getAttribute("href"),d=u.getAttribute("ref");if(l&&isStaticResourcesEqual(l,t.url)&&d===t.attrs.ref){e=u,n=!1;break}}if(!e){e=document.createElement("link"),e.setAttribute("href",t.url);let s;const u=t.attrs;t.createLinkHook&&(s=t.createLinkHook(t.url,u),s instanceof HTMLLinkElement&&(e=s)),u&&!s&&Object.keys(u).forEach(l=>{e&&!e.getAttribute(l)&&e.setAttribute(l,u[l])})}const r=(s,u)=>{if(e&&(e.onerror=null,e.onload=null,safeWrapper(()=>{const{needDeleteLink:l=!0}=t;l&&e!=null&&e.parentNode&&e.parentNode.removeChild(e)}),s)){const l=s(u);return t.cb(),l}t.cb()};return e.onerror=r.bind(null,e.onerror),e.onload=r.bind(null,e.onload),{link:e,needAttach:n}}function loadScript(t,e){const{attrs:n={},createScriptHook:o}=e;return new Promise((r,s)=>{const{script:u,needAttach:l}=createScript({url:t,cb:r,attrs:_extends$9({fetchpriority:"high"},n),createScriptHook:o,needDeleteScript:!0});l&&document.head.appendChild(u)})}function importNodeModule(t){if(!t)throw new Error("import specifier is required");return new Function("name","return import(name)")(t).then(n=>n).catch(n=>{throw console.error(`Error importing module ${t}:`,n),n})}const loadNodeFetch=async()=>{const t=await importNodeModule("node-fetch");return t.default||t},lazyLoaderHookFetch=async(t,e)=>{const n=__webpack_require__.federation.instance.loaderHook,r=await((s,u)=>n.lifecycle.fetch.emit(s,u))(t,e||{});return!r||!(r instanceof Response)?(typeof fetch>"u"?await loadNodeFetch():fetch)(t,e||{}):r};function createScriptNode(url,cb,attrs,createScriptHook){if(createScriptHook){const t=createScriptHook(url);t&&typeof t=="object"&&"url"in t&&(url=t.url)}let urlObj;try{urlObj=new URL(url)}catch(t){console.error("Error constructing URL:",t),cb(new Error(`Invalid URL: ${t}`));return}const getFetch=async()=>{if(typeof __webpack_require__<"u")try{if(__webpack_require__.federation.instance.loaderHook.lifecycle.fetch)return lazyLoaderHookFetch}catch(t){console.warn("federation.instance.loaderHook.lifecycle.fetch failed:",t)}return typeof fetch>"u"?loadNodeFetch():fetch},handleScriptFetch=async(f,urlObj)=>{try{var _vm_constants;const res=await f(urlObj.href),data=await res.text(),[path,vm]=await Promise.all([importNodeModule("path"),importNodeModule("vm")]),scriptContext={exports:{},module:{exports:{}}},urlDirname=urlObj.pathname.split("/").slice(0,-1).join("/"),filename=path.basename(urlObj.pathname);var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;const script=new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}
5
- })`,{filename,importModuleDynamically:(_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER=(_vm_constants=vm.constants)==null?void 0:_vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER)!=null?_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER:importNodeModule});script.runInThisContext()(scriptContext.exports,scriptContext.module,eval("require"),urlDirname,filename);const exportedInterface=scriptContext.module.exports||scriptContext.exports;if(attrs&&exportedInterface&&attrs.globalName){const t=exportedInterface[attrs.globalName]||exportedInterface;cb(void 0,t);return}cb(void 0,exportedInterface)}catch(t){cb(t instanceof Error?t:new Error(`Script execution error: ${t}`))}};getFetch().then(t=>handleScriptFetch(t,urlObj)).catch(t=>{cb(t)})}function loadScriptNode(t,e){return new Promise((n,o)=>{createScriptNode(t,(r,s)=>{if(r)o(r);else{var u,l;const d=(e==null||(u=e.attrs)==null?void 0:u.globalName)||`__FEDERATION_${e==null||(l=e.attrs)==null?void 0:l.name}:custom__`,h=globalThis[d]=s;n(h)}},e.attrs,e.createScriptHook)})}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}const LOG_CATEGORY="[ Federation Runtime ]";function assert(t,e){t||error(e)}function error(t){throw t instanceof Error?(t.message=`${LOG_CATEGORY}: ${t.message}`,t):new Error(`${LOG_CATEGORY}: ${t}`)}function warn(t){t instanceof Error?(t.message=`${LOG_CATEGORY}: ${t.message}`,console.warn(t)):console.warn(`${LOG_CATEGORY}: ${t}`)}function addUniqueItem(t,e){return t.findIndex(n=>n===e)===-1&&t.push(e),t}function getFMId(t){return"version"in t&&t.version?`${t.name}:${t.version}`:"entry"in t&&t.entry?`${t.name}:${t.entry}`:`${t.name}`}function isRemoteInfoWithEntry(t){return typeof t.entry<"u"}function isPureRemoteEntry(t){return!t.entry.includes(".json")&&t.entry.includes(".js")}function isObject(t){return t&&typeof t=="object"}const objectToString=Object.prototype.toString;function isPlainObject(t){return objectToString.call(t)==="[object Object]"}function arrayOptions(t){return Array.isArray(t)?t:[t]}function getRemoteEntryInfoFromSnapshot(t){const e={url:"",type:"global",globalName:""};return isBrowserEnv()?"remoteEntry"in t?{url:t.remoteEntry,type:t.remoteEntryType,globalName:t.globalName}:e:"ssrRemoteEntry"in t?{url:t.ssrRemoteEntry||e.url,type:t.ssrRemoteEntryType||e.type,globalName:t.globalName}:e}const processModuleAlias=(t,e)=>{let n;return t.endsWith("/")?n=t.slice(0,-1):n=t,e.startsWith(".")&&(e=e.slice(1)),n=n+e,n};function _extends$1$1(){return _extends$1$1=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$1$1.apply(this,arguments)}function _object_without_properties_loose$1(t,e){if(t==null)return{};var n={},o=Object.keys(t),r,s;for(s=0;s<o.length;s++)r=o[s],!(e.indexOf(r)>=0)&&(n[r]=t[r]);return n}const nativeGlobal=(()=>{try{return new Function("return this")()}catch{return globalThis}})(),Global=nativeGlobal;function definePropertyGlobalVal(t,e,n){Object.defineProperty(t,e,{value:n,configurable:!1,writable:!0})}function includeOwnProperty(t,e){return Object.hasOwnProperty.call(t,e)}includeOwnProperty(globalThis,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(globalThis,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(t){var e,n,o,r,s,u;includeOwnProperty(t,"__VMOK__")&&!includeOwnProperty(t,"__FEDERATION__")&&definePropertyGlobalVal(t,"__FEDERATION__",t.__VMOK__),includeOwnProperty(t,"__FEDERATION__")||(definePropertyGlobalVal(t,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),definePropertyGlobalVal(t,"__VMOK__",t.__FEDERATION__));var l;(l=(e=t.__FEDERATION__).__GLOBAL_PLUGIN__)!=null||(e.__GLOBAL_PLUGIN__=[]);var d;(d=(n=t.__FEDERATION__).__INSTANCES__)!=null||(n.__INSTANCES__=[]);var h;(h=(o=t.__FEDERATION__).moduleInfo)!=null||(o.moduleInfo={});var p;(p=(r=t.__FEDERATION__).__SHARE__)!=null||(r.__SHARE__={});var m;(m=(s=t.__FEDERATION__).__MANIFEST_LOADING__)!=null||(s.__MANIFEST_LOADING__={});var _;(_=(u=t.__FEDERATION__).__PRELOADED_MAP__)!=null||(u.__PRELOADED_MAP__=new Map)}setGlobalDefaultVal(globalThis);setGlobalDefaultVal(nativeGlobal);function resetFederationGlobalInfo(){globalThis.__FEDERATION__.__GLOBAL_PLUGIN__=[],globalThis.__FEDERATION__.__INSTANCES__=[],globalThis.__FEDERATION__.moduleInfo={},globalThis.__FEDERATION__.__SHARE__={},globalThis.__FEDERATION__.__MANIFEST_LOADING__={}}function getGlobalFederationInstance(t,e){const n=getBuilderId();return globalThis.__FEDERATION__.__INSTANCES__.find(o=>!!(n&&o.options.id===getBuilderId()||o.options.name===t&&!o.options.version&&!e||o.options.name===t&&e&&o.options.version===e))}function setGlobalFederationInstance(t){globalThis.__FEDERATION__.__INSTANCES__.push(t)}function getGlobalFederationConstructor(){return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__}function setGlobalFederationConstructor(t,e=isDebugMode()){e&&(globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__=t,globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="0.6.0")}function getInfoWithoutType(t,e){if(typeof e=="string"){if(t[e])return{value:t[e],key:e};{const o=Object.keys(t);for(const r of o){const[s,u]=r.split(":"),l=`${s}:${e}`,d=t[l];if(d)return{value:d,key:l}}return{value:void 0,key:e}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(t,e)=>{const n=getFMId(t),o=getInfoWithoutType(e,n).value;if(o&&!o.version&&"version"in t&&t.version&&(o.version=t.version),o)return o;if("version"in t&&t.version){const{version:r}=t,s=_object_without_properties_loose$1(t,["version"]),u=getFMId(s),l=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,u).value;if((l==null?void 0:l.version)===r)return l}},getGlobalSnapshotInfoByModuleInfo=t=>getTargetSnapshotInfoByModuleInfo(t,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(t,e)=>{const n=getFMId(t);return nativeGlobal.__FEDERATION__.moduleInfo[n]=e,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=t=>(nativeGlobal.__FEDERATION__.moduleInfo=_extends$1$1({},nativeGlobal.__FEDERATION__.moduleInfo,t),()=>{const e=Object.keys(t);for(const n of e)delete nativeGlobal.__FEDERATION__.moduleInfo[n]}),getRemoteEntryExports=(t,e)=>{const n=e||`__FEDERATION_${t}:custom__`,o=globalThis[n];return{remoteEntryKey:n,entryExports:o}},registerGlobalPlugins=t=>{const{__GLOBAL_PLUGIN__:e}=nativeGlobal.__FEDERATION__;t.forEach(n=>{e.findIndex(o=>o.name===n.name)===-1?e.push(n):warn(`The plugin ${n.name} has been registered.`)})},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=t=>globalThis.__FEDERATION__.__PRELOADED_MAP__.get(t),setPreloaded=t=>globalThis.__FEDERATION__.__PRELOADED_MAP__.set(t,!0);function registerPlugins(t,e){const n=getGlobalHostPlugins();return n.length>0&&n.forEach(o=>{t!=null&&t.find(r=>r.name!==o.name)&&t.push(o)}),t&&t.length>0&&t.forEach(o=>{e.forEach(r=>{r.applyPlugin(o)})}),t}const DEFAULT_SCOPE="default",DEFAULT_REMOTE_TYPE="global";class SyncHook{on(e){typeof e=="function"&&this.listeners.add(e)}once(e){const n=this;this.on(function o(...r){return n.remove(o),e.apply(null,r)})}emit(...e){let n;return this.listeners.size>0&&this.listeners.forEach(o=>{n=o(...e)}),n}remove(e){this.listeners.delete(e)}removeAll(){this.listeners.clear()}constructor(e){this.type="",this.listeners=new Set,e&&(this.type=e)}}class AsyncHook extends SyncHook{emit(...e){let n;const o=Array.from(this.listeners);if(o.length>0){let r=0;const s=u=>u===!1?!1:r<o.length?Promise.resolve(o[r++].apply(null,e)).then(s):u;n=s()}return Promise.resolve(n)}}function checkReturnData(t,e){if(!isObject(e))return!1;if(t!==e){for(const n in t)if(!(n in e))return!1}return!0}class SyncWaterfallHook extends SyncHook{emit(e){isObject(e)||error(`The data for the "${this.type}" hook should be an object.`);for(const n of this.listeners)try{const o=n(e);if(checkReturnData(e,o))e=o;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(o){warn(o),this.onerror(o)}return e}constructor(e){super(),this.onerror=error,this.type=e}}class AsyncWaterfallHook extends SyncHook{emit(e){isObject(e)||error(`The response data for the "${this.type}" hook must be an object.`);const n=Array.from(this.listeners);if(n.length>0){let o=0;const r=u=>(warn(u),this.onerror(u),e),s=u=>{if(checkReturnData(e,u)){if(e=u,o<n.length)try{return Promise.resolve(n[o++](e)).then(s,r)}catch(l){return r(l)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return e};return Promise.resolve(s(e))}return Promise.resolve(e)}constructor(e){super(),this.onerror=error,this.type=e}}class PluginSystem{applyPlugin(e){assert(isPlainObject(e),"Plugin configuration is invalid.");const n=e.name;assert(n,"A name must be provided by the plugin."),this.registerPlugins[n]||(this.registerPlugins[n]=e,Object.keys(this.lifecycle).forEach(o=>{const r=e[o];r&&this.lifecycle[o].on(r)}))}removePlugin(e){assert(e,"A name is required.");const n=this.registerPlugins[e];assert(n,`The plugin "${e}" is not registered.`),Object.keys(n).forEach(o=>{o!=="name"&&this.lifecycle[o].remove(n[o])})}inherit({lifecycle:e,registerPlugins:n}){Object.keys(e).forEach(o=>{assert(!this.lifecycle[o],`The hook "${o}" has a conflict and cannot be inherited.`),this.lifecycle[o]=e[o]}),Object.keys(n).forEach(o=>{assert(!this.registerPlugins[o],`The plugin "${o}" has a conflict and cannot be inherited.`),this.applyPlugin(n[o])})}constructor(e){this.registerPlugins={},this.lifecycle=e,this.lifecycleKeys=Object.keys(e)}}const buildIdentifier="[0-9A-Za-z-]+",build=`(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`,numericIdentifier="0|[1-9]\\d*",numericIdentifierLoose="[0-9]+",nonNumericIdentifier="\\d*[a-zA-Z-][a-zA-Z0-9-]*",preReleaseIdentifierLoose=`(?:${numericIdentifierLoose}|${nonNumericIdentifier})`,preReleaseLoose=`(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`,preReleaseIdentifier=`(?:${numericIdentifier}|${nonNumericIdentifier})`,preRelease=`(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`,xRangeIdentifier=`${numericIdentifier}|x|X|\\*`,xRangePlain=`[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`,hyphenRange=`^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`,mainVersionLoose=`(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`,loosePlain=`[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`,gtlt="((?:<|>)?=?)",comparatorTrim=`(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`,loneTilde="(?:~>?)",tildeTrim=`(\\s*)${loneTilde}\\s+`,loneCaret="(?:\\^)",caretTrim=`(\\s*)${loneCaret}\\s+`,star="(<|>)?=?\\s*\\*",caret=`^${loneCaret}${xRangePlain}$`,mainVersion=`(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`,fullPlain=`v?${mainVersion}${preRelease}?${build}?`,tilde=`^${loneTilde}${xRangePlain}$`,xRange=`^${gtlt}\\s*${xRangePlain}$`,comparator=`^${gtlt}\\s*(${fullPlain})$|^$`,gte0="^\\s*>=\\s*0.0.0\\s*$";function parseRegex(t){return new RegExp(t)}function isXVersion(t){return!t||t.toLowerCase()==="x"||t==="*"}function pipe(...t){return e=>t.reduce((n,o)=>o(n),e)}function extractComparator(t){return t.match(parseRegex(comparator))}function combineVersion(t,e,n,o){const r=`${t}.${e}.${n}`;return o?`${r}-${o}`:r}function parseHyphen(t){return t.replace(parseRegex(hyphenRange),(e,n,o,r,s,u,l,d,h,p,m,_)=>(isXVersion(o)?n="":isXVersion(r)?n=`>=${o}.0.0`:isXVersion(s)?n=`>=${o}.${r}.0`:n=`>=${n}`,isXVersion(h)?d="":isXVersion(p)?d=`<${Number(h)+1}.0.0-0`:isXVersion(m)?d=`<${h}.${Number(p)+1}.0-0`:_?d=`<=${h}.${p}.${m}-${_}`:d=`<=${d}`,`${n} ${d}`.trim()))}function parseComparatorTrim(t){return t.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(t){return t.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(t){return t.replace(parseRegex(caretTrim),"$1^")}function parseCarets(t){return t.trim().split(/\s+/).map(e=>e.replace(parseRegex(caret),(n,o,r,s,u)=>isXVersion(o)?"":isXVersion(r)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(s)?o==="0"?`>=${o}.${r}.0 <${o}.${Number(r)+1}.0-0`:`>=${o}.${r}.0 <${Number(o)+1}.0.0-0`:u?o==="0"?r==="0"?`>=${o}.${r}.${s}-${u} <${o}.${r}.${Number(s)+1}-0`:`>=${o}.${r}.${s}-${u} <${o}.${Number(r)+1}.0-0`:`>=${o}.${r}.${s}-${u} <${Number(o)+1}.0.0-0`:o==="0"?r==="0"?`>=${o}.${r}.${s} <${o}.${r}.${Number(s)+1}-0`:`>=${o}.${r}.${s} <${o}.${Number(r)+1}.0-0`:`>=${o}.${r}.${s} <${Number(o)+1}.0.0-0`)).join(" ")}function parseTildes(t){return t.trim().split(/\s+/).map(e=>e.replace(parseRegex(tilde),(n,o,r,s,u)=>isXVersion(o)?"":isXVersion(r)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(s)?`>=${o}.${r}.0 <${o}.${Number(r)+1}.0-0`:u?`>=${o}.${r}.${s}-${u} <${o}.${Number(r)+1}.0-0`:`>=${o}.${r}.${s} <${o}.${Number(r)+1}.0-0`)).join(" ")}function parseXRanges(t){return t.split(/\s+/).map(e=>e.trim().replace(parseRegex(xRange),(n,o,r,s,u,l)=>{const d=isXVersion(r),h=d||isXVersion(s),p=h||isXVersion(u);return o==="="&&p&&(o=""),l="",d?o===">"||o==="<"?"<0.0.0-0":"*":o&&p?(h&&(s=0),u=0,o===">"?(o=">=",h?(r=Number(r)+1,s=0,u=0):(s=Number(s)+1,u=0)):o==="<="&&(o="<",h?r=Number(r)+1:s=Number(s)+1),o==="<"&&(l="-0"),`${o+r}.${s}.${u}${l}`):h?`>=${r}.0.0${l} <${Number(r)+1}.0.0-0`:p?`>=${r}.${s}.0${l} <${r}.${Number(s)+1}.0-0`:n})).join(" ")}function parseStar(t){return t.trim().replace(parseRegex(star),"")}function parseGTE0(t){return t.trim().replace(parseRegex(gte0),"")}function compareAtom(t,e){return t=Number(t)||t,e=Number(e)||e,t>e?1:t===e?0:-1}function comparePreRelease(t,e){const{preRelease:n}=t,{preRelease:o}=e;if(n===void 0&&o)return 1;if(n&&o===void 0)return-1;if(n===void 0&&o===void 0)return 0;for(let r=0,s=n.length;r<=s;r++){const u=n[r],l=o[r];if(u!==l)return u===void 0&&l===void 0?0:u?l?compareAtom(u,l):-1:1}return 0}function compareVersion(t,e){return compareAtom(t.major,e.major)||compareAtom(t.minor,e.minor)||compareAtom(t.patch,e.patch)||comparePreRelease(t,e)}function eq(t,e){return t.version===e.version}function compare(t,e){switch(t.operator){case"":case"=":return eq(t,e);case">":return compareVersion(t,e)<0;case">=":return eq(t,e)||compareVersion(t,e)<0;case"<":return compareVersion(t,e)>0;case"<=":return eq(t,e)||compareVersion(t,e)>0;case void 0:return!0;default:return!1}}function parseComparatorString(t){return pipe(parseCarets,parseTildes,parseXRanges,parseStar)(t)}function parseRange(t){return pipe(parseHyphen,parseComparatorTrim,parseTildeTrim,parseCaretTrim)(t.trim()).split(/\s+/).join(" ")}function satisfy(t,e){if(!t)return!1;const r=parseRange(e).split(" ").map(_=>parseComparatorString(_)).join(" ").split(/\s+/).map(_=>parseGTE0(_)),s=extractComparator(t);if(!s)return!1;const[,u,,l,d,h,p]=s,m={operator:u,version:combineVersion(l,d,h,p),major:l,minor:d,patch:h,preRelease:p==null?void 0:p.split(".")};for(const _ of r){const y=extractComparator(_);if(!y)return!1;const[,E,,R,b,v,O]=y,I={operator:E,version:combineVersion(R,b,v,O),major:R,minor:b,patch:v,preRelease:O==null?void 0:O.split(".")};if(!compare(I,m))return!1}return!0}function _extends$8(){return _extends$8=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$8.apply(this,arguments)}function formatShare(t,e,n,o){let r;"get"in t?r=t.get:"lib"in t?r=()=>Promise.resolve(t.lib):r=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${n}'!`)}),t.strategy&&warn('"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"');var s,u,l;return _extends$8({deps:[],useIn:[],from:e,loading:null},t,{shareConfig:_extends$8({requiredVersion:`^${t.version}`,singleton:!1,eager:!1,strictVersion:!1},t.shareConfig),get:r,loaded:t!=null&&t.loaded||"lib"in t?!0:void 0,version:(s=t.version)!=null?s:"0",scope:Array.isArray(t.scope)?t.scope:[(u=t.scope)!=null?u:"default"],strategy:((l=t.strategy)!=null?l:o)||"version-first"})}function formatShareConfigs(t,e){const n=e.shared||{},o=e.name,r=Object.keys(n).reduce((u,l)=>{const d=arrayOptions(n[l]);return u[l]=u[l]||[],d.forEach(h=>{u[l].push(formatShare(h,o,l,e.shareStrategy))}),u},{}),s=_extends$8({},t.shared);return Object.keys(r).forEach(u=>{s[u]?r[u].forEach(l=>{s[u].find(h=>h.version===l.version)||s[u].push(l)}):s[u]=r[u]}),{shared:s,shareInfos:r}}function versionLt(t,e){const n=o=>{if(!Number.isNaN(Number(o))){const s=o.split(".");let u=o;for(let l=0;l<3-s.length;l++)u+=".0";return u}return o};return!!satisfy(n(t),`<=${n(e)}`)}const findVersion=(t,e)=>{const n=e||function(o,r){return versionLt(o,r)};return Object.keys(t).reduce((o,r)=>!o||n(o,r)||o==="0"?r:o,0)},isLoaded=t=>!!t.loaded||typeof t.lib=="function";function findSingletonVersionOrderByVersion(t,e,n){const o=t[e][n],r=function(s,u){return!isLoaded(o[s])&&versionLt(s,u)};return findVersion(t[e][n],r)}function findSingletonVersionOrderByLoaded(t,e,n){const o=t[e][n],r=function(s,u){return isLoaded(o[u])?isLoaded(o[s])?!!versionLt(s,u):!0:isLoaded(o[s])?!1:versionLt(s,u)};return findVersion(t[e][n],r)}function getFindShareFunction(t){return t==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(t,e,n,o){if(!t)return;const{shareConfig:r,scope:s=DEFAULT_SCOPE,strategy:u}=n,l=Array.isArray(s)?s:[s];for(const d of l)if(r&&t[d]&&t[d][e]){const{requiredVersion:h}=r,m=getFindShareFunction(u)(t,d,e),_=()=>{if(r.singleton){if(typeof h=="string"&&!satisfy(m,h)){const R=`Version ${m} from ${m&&t[d][e][m].from} of shared singleton module ${e} does not satisfy the requirement of ${n.from} which needs ${h})`;r.strictVersion?error(R):warn(R)}return t[d][e][m]}else{if(h===!1||h==="*"||satisfy(m,h))return t[d][e][m];for(const[R,b]of Object.entries(t[d][e]))if(satisfy(R,h))return b}},y={shareScopeMap:t,scope:d,pkgName:e,version:m,GlobalFederation:Global.__FEDERATION__,resolver:_};return(o.emit(y)||y).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(t){const{pkgName:e,extraOptions:n,shareInfos:o}=t,r=l=>{if(!l)return;const d={};l.forEach(m=>{d[m.version]=m});const p=findVersion(d,function(m,_){return!isLoaded(d[m])&&versionLt(m,_)});return d[p]};var s;const u=(s=n==null?void 0:n.resolver)!=null?s:r;return Object.assign({},u(o[e]),n==null?void 0:n.customShareInfo)}function matchRemoteWithNameAndExpose(t,e){for(const n of t){const o=e.startsWith(n.name);let r=e.replace(n.name,"");if(o){if(r.startsWith("/")){const l=n.name;return r=`.${r}`,{pkgNameOrAlias:l,expose:r,remote:n}}else if(r==="")return{pkgNameOrAlias:n.name,expose:".",remote:n}}const s=n.alias&&e.startsWith(n.alias);let u=n.alias&&e.replace(n.alias,"");if(n.alias&&s){if(u&&u.startsWith("/")){const l=n.alias;return u=`.${u}`,{pkgNameOrAlias:l,expose:u,remote:n}}else if(u==="")return{pkgNameOrAlias:n.alias,expose:".",remote:n}}}}function matchRemote(t,e){for(const n of t)if(e===n.name||n.alias&&e===n.alias)return n}function _extends$7(){return _extends$7=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$7.apply(this,arguments)}async function loadEsmEntry({entry:t,remoteEntryExports:e}){return new Promise((n,o)=>{try{e?n(e):new Function("callbacks",`import("${t}").then(callbacks[0]).catch(callbacks[1])`)([n,o])}catch(r){o(r)}})}async function loadSystemJsEntry({entry:t,remoteEntryExports:e}){return new Promise((n,o)=>{try{e?n(e):new Function("callbacks",`System.import("${t}").then(callbacks[0]).catch(callbacks[1])`)([n,o])}catch(r){o(r)}})}async function loadEntryScript({name:t,globalName:e,entry:n,createScriptHook:o}){const{entryExports:r}=getRemoteEntryExports(t,e);return r||loadScript(n,{attrs:{},createScriptHook:(s,u)=>{const l=o.emit({url:s,attrs:u});if(l&&(l instanceof HTMLScriptElement||"script"in l||"timeout"in l))return l}}).then(()=>{const{remoteEntryKey:s,entryExports:u}=getRemoteEntryExports(t,e);return assert(u,`
6
- Unable to use the ${t}'s '${n}' URL with ${s}'s globalName to get remoteEntry exports.
7
- Possible reasons could be:
8
-
9
- 1. '${n}' is not the correct URL, or the remoteEntry resource or name is incorrect.
10
-
11
- 2. ${s} cannot be used to get remoteEntry exports in the window object.
12
- `),u}).catch(s=>{throw s})}async function loadEntryDom({remoteInfo:t,remoteEntryExports:e,createScriptHook:n}){const{entry:o,entryGlobalName:r,name:s,type:u}=t;switch(u){case"esm":case"module":return loadEsmEntry({entry:o,remoteEntryExports:e});case"system":return loadSystemJsEntry({entry:o,remoteEntryExports:e});default:return loadEntryScript({entry:o,globalName:r,name:s,createScriptHook:n})}}async function loadEntryNode({remoteInfo:t,createScriptHook:e}){const{entry:n,entryGlobalName:o,name:r}=t,{entryExports:s}=getRemoteEntryExports(r,o);return s||loadScriptNode(n,{attrs:{name:r,globalName:o},createScriptHook:(u,l)=>{const d=e.emit({url:u,attrs:l});if(d&&"url"in d)return d}}).then(()=>{const{remoteEntryKey:u,entryExports:l}=getRemoteEntryExports(r,o);return assert(l,`
13
- Unable to use the ${r}'s '${n}' URL with ${u}'s globalName to get remoteEntry exports.
14
- Possible reasons could be:
15
-
16
- 1. '${n}' is not the correct URL, or the remoteEntry resource or name is incorrect.
17
-
18
- 2. ${u} cannot be used to get remoteEntry exports in the window object.
19
- `),l}).catch(u=>{throw u})}function getRemoteEntryUniqueKey(t){const{entry:e,name:n}=t;return composeKeyWithSeparator(n,e)}async function getRemoteEntry({origin:t,remoteEntryExports:e,remoteInfo:n}){const o=getRemoteEntryUniqueKey(n);if(e)return e;if(!globalLoading[o]){const r=t.remoteHandler.hooks.lifecycle.loadEntry;if(r.listeners.size)globalLoading[o]=r.emit({createScriptHook:t.loaderHook.lifecycle.createScript,remoteInfo:n,remoteEntryExports:e}).then(s=>s||void 0);else{const s=t.loaderHook.lifecycle.createScript;isBrowserEnv()?globalLoading[o]=loadEntryDom({remoteInfo:n,remoteEntryExports:e,createScriptHook:s}):globalLoading[o]=loadEntryNode({remoteInfo:n,createScriptHook:s})}}return globalLoading[o]}function getRemoteInfo(t){return _extends$7({},t,{entry:"entry"in t?t.entry:"",type:t.type||DEFAULT_REMOTE_TYPE,entryGlobalName:t.entryGlobalName||t.name,shareScope:t.shareScope||DEFAULT_SCOPE})}function _extends$6(){return _extends$6=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$6.apply(this,arguments)}let Module=class{async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;const e=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports});return assert(e,`remoteEntryExports is undefined
20
- ${safeToString(this.remoteInfo)}`),this.remoteEntryExports=e,this.remoteEntryExports}async get(e,n,o){const{loadFactory:r=!0}=o||{loadFactory:!0},s=await this.getEntry();if(!this.inited){const p=this.host.shareScopeMap,m=this.remoteInfo.shareScope||"default";p[m]||(p[m]={});const _=p[m],y=[],E={version:this.remoteInfo.version||""};Object.defineProperty(E,"shareScopeMap",{value:p,enumerable:!1});const R=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:_,remoteEntryInitOptions:E,initScope:y,remoteInfo:this.remoteInfo,origin:this.host});typeof(s==null?void 0:s.init)>"u"&&console.error('The remote entry interface does not contain "init"',`
21
- `,"Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]",`
22
- `,"Ensure that window[nameOfRemote] is returning a {get,init} object."),await s.init(R.shareScope,R.initScope,R.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit(_extends$6({},R,{remoteEntryExports:s}))}this.lib=s,this.inited=!0;const u=await s.get(n);assert(u,`${getFMId(this.remoteInfo)} remote don't export ${n}.`);const l=processModuleAlias(this.remoteInfo.name,n),d=this.wraperFactory(u,l);return r?await d():d}wraperFactory(e,n){function o(r,s){r&&typeof r=="object"&&Object.isExtensible(r)&&!Object.getOwnPropertyDescriptor(r,Symbol.for("mf_module_id"))&&Object.defineProperty(r,Symbol.for("mf_module_id"),{value:s,enumerable:!1})}return e instanceof Promise?async()=>{const r=await e();return o(r,n),r}:()=>{const r=e();return o(r,n),r}}constructor({remoteInfo:e,host:n}){this.inited=!1,this.lib=void 0,this.remoteInfo=e,this.host=n}};function _extends$5(){return _extends$5=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$5.apply(this,arguments)}function defaultPreloadArgs(t){return _extends$5({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},t)}function formatPreloadArgs(t,e){return e.map(n=>{const o=matchRemote(t,n.nameOrAlias);return assert(o,`Unable to preload ${n.nameOrAlias} as it is not included in ${!o&&safeToString({remoteInfo:o,remotes:t})}`),{remote:o,preloadConfig:defaultPreloadArgs(n)}})}function normalizePreloadExposes(t){return t?t.map(e=>e==="."?e:e.startsWith("./")?e.replace("./",""):e):[]}function preloadAssets(t,e,n,o=!0){const{cssAssets:r,jsAssetsWithoutEntry:s,entryAssets:u}=n;if(e.options.inBrowser){if(u.forEach(l=>{const{moduleInfo:d}=l,h=e.moduleCache.get(t.name);getRemoteEntry(h?{origin:e,remoteInfo:d,remoteEntryExports:h.remoteEntryExports}:{origin:e,remoteInfo:d,remoteEntryExports:void 0})}),o){const l={rel:"preload",as:"style",crossorigin:"anonymous"};r.forEach(d=>{const{link:h,needAttach:p}=createLink({url:d,cb:()=>{},attrs:l,createLinkHook:(m,_)=>{const y=e.loaderHook.lifecycle.createLink.emit({url:m,attrs:_});if(y instanceof HTMLLinkElement)return y}});p&&document.head.appendChild(h)})}else{const l={rel:"stylesheet",type:"text/css"};r.forEach(d=>{const{link:h,needAttach:p}=createLink({url:d,cb:()=>{},attrs:l,createLinkHook:(m,_)=>{const y=e.loaderHook.lifecycle.createLink.emit({url:m,attrs:_});if(y instanceof HTMLLinkElement)return y},needDeleteLink:!1});p&&document.head.appendChild(h)})}if(o){const l={rel:"preload",as:"script",crossorigin:"anonymous"};s.forEach(d=>{const{link:h,needAttach:p}=createLink({url:d,cb:()=>{},attrs:l,createLinkHook:(m,_)=>{const y=e.loaderHook.lifecycle.createLink.emit({url:m,attrs:_});if(y instanceof HTMLLinkElement)return y}});p&&document.head.appendChild(h)})}else{const l={fetchpriority:"high",type:(t==null?void 0:t.type)==="module"?"module":"text/javascript"};s.forEach(d=>{const{script:h,needAttach:p}=createScript({url:d,cb:()=>{},attrs:l,createScriptHook:(m,_)=>{const y=e.loaderHook.lifecycle.createScript.emit({url:m,attrs:_});if(y instanceof HTMLScriptElement)return y},needDeleteScript:!0});p&&document.head.appendChild(h)})}}}function _extends$4(){return _extends$4=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$4.apply(this,arguments)}function assignRemoteInfo(t,e){const n=getRemoteEntryInfoFromSnapshot(e);n.url||error(`The attribute remoteEntry of ${t.name} must not be undefined.`);let o=getResourceUrl(e,n.url);!isBrowserEnv()&&!o.startsWith("http")&&(o=`https:${o}`),t.type=n.type,t.entryGlobalName=n.globalName,t.entry=o,t.version=e.version,t.buildVersion=e.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(t){const{remote:e,pkgNameOrAlias:n,expose:o,origin:r,remoteInfo:s}=t;if(!isRemoteInfoWithEntry(e)||!isPureRemoteEntry(e)){const{remoteSnapshot:u,globalSnapshot:l}=await r.snapshotHandler.loadRemoteSnapshotInfo(e);assignRemoteInfo(s,u);const d={remote:e,preloadConfig:{nameOrAlias:n,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},h=await r.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:r,preloadOptions:d,remoteInfo:s,remote:e,remoteSnapshot:u,globalSnapshot:l});return h&&preloadAssets(s,r,h,!1),_extends$4({},t,{remoteSnapshot:u})}return t}}}function splitId(t){const e=t.split(":");return e.length===1?{name:e[0],version:void 0}:e.length===2?{name:e[0],version:e[1]}:{name:e[1],version:e[2]}}function traverseModuleInfo(t,e,n,o,r={},s){const u=getFMId(e),{value:l}=getInfoWithoutType(t,u),d=s||l;if(d&&!isManifestProvider(d)&&(n(d,e,o),d.remotesInfo)){const h=Object.keys(d.remotesInfo);for(const p of h){if(r[p])continue;r[p]=!0;const m=splitId(p),_=d.remotesInfo[p];traverseModuleInfo(t,{name:m.name,version:_.matchedVersion},n,!1,r,void 0)}}}function generatePreloadAssets(t,e,n,o,r){const s=[],u=[],l=[],d=new Set,h=new Set,{options:p}=t,{preloadConfig:m}=e,{depsRemote:_}=m;if(traverseModuleInfo(o,n,(b,v,O)=>{let I;if(O)I=m;else if(Array.isArray(_)){const L=_.find(P=>P.nameOrAlias===v.name||P.nameOrAlias===v.alias);if(!L)return;I=defaultPreloadArgs(L)}else if(_===!0)I=m;else return;const $=getResourceUrl(b,getRemoteEntryInfoFromSnapshot(b).url);$&&l.push({name:v.name,moduleInfo:{name:v.name,entry:$,type:"remoteEntryType"in b?b.remoteEntryType:"global",entryGlobalName:"globalName"in b?b.globalName:v.name,shareScope:"",version:"version"in b?b.version:void 0},url:$});let S="modules"in b?b.modules:[];const T=normalizePreloadExposes(I.exposes);if(T.length&&"modules"in b){var w;S=b==null||(w=b.modules)==null?void 0:w.reduce((L,P)=>((T==null?void 0:T.indexOf(P.moduleName))!==-1&&L.push(P),L),[])}function A(L){const P=L.map(N=>getResourceUrl(b,N));return I.filter?P.filter(I.filter):P}if(S){const L=S.length;for(let P=0;P<L;P++){const N=S[P],x=`${v.name}/${N.moduleName}`;t.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:N.moduleName==="."?v.name:x,name:v.name,remoteSnapshot:b,preloadConfig:I,remote:v,origin:t}),!getPreloaded(x)&&(I.resourceCategory==="all"?(s.push(...A(N.assets.css.async)),s.push(...A(N.assets.css.sync)),u.push(...A(N.assets.js.async)),u.push(...A(N.assets.js.sync))):(I.resourceCategory="sync")&&(s.push(...A(N.assets.css.sync)),u.push(...A(N.assets.js.sync))),setPreloaded(x))}}},!0,{},r),r.shared){const b=(v,O)=>{const I=getRegisteredShare(t.shareScopeMap,O.sharedName,v,t.sharedHandler.hooks.lifecycle.resolveShare);I&&typeof I.lib=="function"&&(O.assets.js.sync.forEach($=>{d.add($)}),O.assets.css.sync.forEach($=>{h.add($)}))};r.shared.forEach(v=>{var O;const I=(O=p.shared)==null?void 0:O[v.sharedName];if(!I)return;const $=v.version?I.find(T=>T.version===v.version):I;if(!$)return;arrayOptions($).forEach(T=>{b(T,v)})})}const E=u.filter(b=>!d.has(b));return{cssAssets:s.filter(b=>!h.has(b)),jsAssetsWithoutEntry:E,entryAssets:l}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(t){const{origin:e,preloadOptions:n,remoteInfo:o,remote:r,globalSnapshot:s,remoteSnapshot:u}=t;return isRemoteInfoWithEntry(r)&&isPureRemoteEntry(r)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:r.name,url:r.entry,moduleInfo:{name:o.name,entry:r.entry,type:"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(o,u),generatePreloadAssets(e,n,o,s,u))}}};function _extends$3(){return _extends$3=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$3.apply(this,arguments)}function getGlobalRemoteInfo(t,e){const n=getGlobalSnapshotInfoByModuleInfo({name:e.options.name,version:e.options.version}),o=n&&"remotesInfo"in n&&n.remotesInfo&&getInfoWithoutType(n.remotesInfo,t.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:n,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:t.name,version:o.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:t.name,version:"version"in t?t.version:void 0})}}class SnapshotHandler{async loadSnapshot(e){const{options:n}=this.HostInstance,{hostGlobalSnapshot:o,remoteSnapshot:r,globalSnapshot:s}=this.getGlobalRemoteInfo(e),{remoteSnapshot:u,globalSnapshot:l}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:e,hostGlobalSnapshot:o,remoteSnapshot:r,globalSnapshot:s});return{remoteSnapshot:u,globalSnapshot:l}}async loadRemoteSnapshotInfo(e){const{options:n}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:n,moduleInfo:e});let o=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});o||(o={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:o})),o&&"remotesInfo"in o&&!getInfoWithoutType(o.remotesInfo,e.name).value&&("version"in e||"entry"in e)&&(o.remotesInfo=_extends$3({},o==null?void 0:o.remotesInfo,{[e.name]:{matchedVersion:"version"in e?e.version:e.entry}}));const{hostGlobalSnapshot:r,remoteSnapshot:s,globalSnapshot:u}=this.getGlobalRemoteInfo(e),{remoteSnapshot:l,globalSnapshot:d}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:e,hostGlobalSnapshot:r,remoteSnapshot:s,globalSnapshot:u});let h,p;if(l)if(isManifestProvider(l)){const m=isBrowserEnv()?l.remoteEntry:l.ssrRemoteEntry||l.remoteEntry||"",_=await this.getManifestJson(m,e,{}),y=setGlobalSnapshotInfoByModuleInfo(_extends$3({},e,{entry:m}),_);h=_,p=y}else{const{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:l,from:"global"});h=m,p=d}else if(isRemoteInfoWithEntry(e)){const m=await this.getManifestJson(e.entry,e,{}),_=setGlobalSnapshotInfoByModuleInfo(e,m),{remoteSnapshot:y}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:m,from:"global"});h=y,p=_}else error(`
23
- Cannot get remoteSnapshot with the name: '${e.name}', version: '${e.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:
24
-
25
- 1. The Deploy platform did not deliver the correct data. You can use __FEDERATION__.moduleInfo to check the remoteInfo.
26
-
27
- 2. The remote '${e.name}' version '${e.version}' is not released.
28
-
29
- The transformed module info: ${JSON.stringify(d)}
30
- `);return await this.hooks.lifecycle.afterLoadSnapshot.emit({options:n,moduleInfo:e,remoteSnapshot:h}),{remoteSnapshot:h,globalSnapshot:p}}getGlobalRemoteInfo(e){return getGlobalRemoteInfo(e,this.HostInstance)}async getManifestJson(e,n,o){const r=async()=>{let u=this.manifestCache.get(e);if(u)return u;try{let l=await this.loaderHook.lifecycle.fetch.emit(e,{});return(!l||!(l instanceof Response))&&(l=await fetch(e,{})),u=await l.json(),assert(u.metaData&&u.exposes&&u.shared,`${e} is not a federation manifest`),this.manifestCache.set(e,u),u}catch(l){delete this.manifestLoading[e],error(`Failed to get manifestJson for ${n.name}. The manifest URL is ${e}. Please ensure that the manifestUrl is accessible.
31
-
32
- Error message:
33
-
34
- ${l}`)}},s=async()=>{const u=await r(),l=generateSnapshotFromManifest(u,{version:e}),{remoteSnapshot:d}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:n,manifestJson:u,remoteSnapshot:l,manifestUrl:e,from:"manifest"});return d};return this.manifestLoading[e]||(this.manifestLoading[e]=s().then(u=>u)),this.manifestLoading[e]}constructor(e){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new PluginSystem({beforeLoadRemoteSnapshot:new AsyncHook("beforeLoadRemoteSnapshot"),loadSnapshot:new AsyncWaterfallHook("loadGlobalSnapshot"),loadRemoteSnapshot:new AsyncWaterfallHook("loadRemoteSnapshot"),afterLoadSnapshot:new AsyncWaterfallHook("afterLoadSnapshot")}),this.manifestLoading=Global.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=e,this.loaderHook=e.loaderHook}}function _extends$2(){return _extends$2=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$2.apply(this,arguments)}function _object_without_properties_loose(t,e){if(t==null)return{};var n={},o=Object.keys(t),r,s;for(s=0;s<o.length;s++)r=o[s],!(e.indexOf(r)>=0)&&(n[r]=t[r]);return n}class SharedHandler{registerShared(e,n){const{shareInfos:o,shared:r}=formatShareConfigs(e,n);return Object.keys(o).forEach(u=>{o[u].forEach(d=>{!getRegisteredShare(this.shareScopeMap,u,d,this.hooks.lifecycle.resolveShare)&&d&&d.lib&&this.setShared({pkgName:u,lib:d.lib,get:d.get,loaded:!0,shared:d,from:n.name})})}),{shareInfos:o,shared:r}}async loadShare(e,n){const{host:o}=this,r=getTargetSharedOptions({pkgName:e,extraOptions:n,shareInfos:o.options.shared});r!=null&&r.scope&&await Promise.all(r.scope.map(async h=>{await Promise.all(this.initializeSharing(h,{strategy:r.strategy}))}));const s=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:e,shareInfo:r,shared:o.options.shared,origin:o}),{shareInfo:u}=s;assert(u,`Cannot find ${e} Share in the ${o.options.name}. Please ensure that the ${e} Share parameters have been injected`);const l=getRegisteredShare(this.shareScopeMap,e,u,this.hooks.lifecycle.resolveShare),d=h=>{h.useIn||(h.useIn=[]),addUniqueItem(h.useIn,o.options.name)};if(l&&l.lib)return d(l),l.lib;if(l&&l.loading&&!l.loaded){const h=await l.loading;return l.loaded=!0,l.lib||(l.lib=h),d(l),h}else if(l){const p=(async()=>{const m=await l.get();u.lib=m,u.loaded=!0,d(u);const _=getRegisteredShare(this.shareScopeMap,e,u,this.hooks.lifecycle.resolveShare);return _&&(_.lib=m,_.loaded=!0),m})();return this.setShared({pkgName:e,loaded:!1,shared:l,from:o.options.name,lib:null,loading:p}),p}else{if(n!=null&&n.customShareInfo)return!1;const p=(async()=>{const m=await u.get();u.lib=m,u.loaded=!0,d(u);const _=getRegisteredShare(this.shareScopeMap,e,u,this.hooks.lifecycle.resolveShare);return _&&(_.lib=m,_.loaded=!0),m})();return this.setShared({pkgName:e,loaded:!1,shared:u,from:o.options.name,lib:null,loading:p}),p}}initializeSharing(e=DEFAULT_SCOPE,n){const{host:o}=this,r=n==null?void 0:n.from,s=n==null?void 0:n.strategy;let u=n==null?void 0:n.initScope;const l=[];if(r!=="build"){const{initTokens:E}=this;u||(u=[]);let R=E[e];if(R||(R=E[e]={from:this.host.name}),u.indexOf(R)>=0)return l;u.push(R)}const d=this.shareScopeMap,h=o.options.name;d[e]||(d[e]={});const p=d[e],m=(E,R)=>{var b;const{version:v,eager:O}=R;p[E]=p[E]||{};const I=p[E],$=I[v],S=!!($&&($.eager||(b=$.shareConfig)!=null&&b.eager));(!$||$.strategy!=="loaded-first"&&!$.loaded&&(!O!=!S?O:h>$.from))&&(I[v]=R)},_=E=>E&&E.init&&E.init(d[e],u),y=async E=>{const{module:R}=await o.remoteHandler.getRemoteModuleAndOptions({id:E});if(R.getEntry){const b=await R.getEntry();R.inited||(await _(b),R.inited=!0)}};return Object.keys(o.options.shared).forEach(E=>{o.options.shared[E].forEach(b=>{b.scope.includes(e)&&m(E,b)})}),(o.options.shareStrategy==="version-first"||s==="version-first")&&o.options.remotes.forEach(E=>{E.shareScope===e&&l.push(y(E.name))}),l}loadShareSync(e,n){const{host:o}=this,r=getTargetSharedOptions({pkgName:e,extraOptions:n,shareInfos:o.options.shared});r!=null&&r.scope&&r.scope.forEach(l=>{this.initializeSharing(l,{strategy:r.strategy})});const s=getRegisteredShare(this.shareScopeMap,e,r,this.hooks.lifecycle.resolveShare),u=l=>{l.useIn||(l.useIn=[]),addUniqueItem(l.useIn,o.options.name)};if(s){if(typeof s.lib=="function")return u(s),s.loaded||(s.loaded=!0,s.from===o.options.name&&(r.loaded=!0)),s.lib;if(typeof s.get=="function"){const l=s.get();if(!(l instanceof Promise))return u(s),this.setShared({pkgName:e,loaded:!0,from:o.options.name,lib:l,shared:s}),l}}if(r.lib)return r.loaded||(r.loaded=!0),r.lib;if(r.get){const l=r.get();if(l instanceof Promise)throw new Error(`
35
- The loadShareSync function was unable to load ${e}. The ${e} could not be found in ${o.options.name}.
36
- Possible reasons for failure:
37
-
38
- 1. The ${e} share was registered with the 'get' attribute, but loadShare was not used beforehand.
39
-
40
- 2. The ${e} share was not registered with the 'lib' attribute.
41
-
42
- `);return r.lib=l,this.setShared({pkgName:e,loaded:!0,from:o.options.name,lib:r.lib,shared:r}),r.lib}throw new Error(`
43
- The loadShareSync function was unable to load ${e}. The ${e} could not be found in ${o.options.name}.
44
- Possible reasons for failure:
45
-
46
- 1. The ${e} share was registered with the 'get' attribute, but loadShare was not used beforehand.
47
-
48
- 2. The ${e} share was not registered with the 'lib' attribute.
49
-
50
- `)}initShareScopeMap(e,n,o={}){const{host:r}=this;this.shareScopeMap[e]=n,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:n,options:r.options,origin:r,scopeName:e,hostShareScopeMap:o.hostShareScopeMap})}setShared({pkgName:e,shared:n,from:o,lib:r,loading:s,loaded:u,get:l}){const{version:d,scope:h="default"}=n,p=_object_without_properties_loose(n,["version","scope"]);(Array.isArray(h)?h:[h]).forEach(_=>{this.shareScopeMap[_]||(this.shareScopeMap[_]={}),this.shareScopeMap[_][e]||(this.shareScopeMap[_][e]={}),!this.shareScopeMap[_][e][d]&&(this.shareScopeMap[_][e][d]=_extends$2({version:d,scope:["default"]},p,{lib:r,loaded:u,loading:s}),l&&(this.shareScopeMap[_][e][d].get=l))})}_setGlobalShareScopeMap(e){const n=getGlobalShareScope(),o=e.id||e.name;o&&!n[o]&&(n[o]=this.shareScopeMap)}constructor(e){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=e,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(e.options)}}function _extends$1(){return _extends$1=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends$1.apply(this,arguments)}class RemoteHandler{formatAndRegisterRemote(e,n){return(n.remotes||[]).reduce((r,s)=>(this.registerRemote(s,r,{force:!1}),r),e.remotes)}setIdToRemoteMap(e,n){const{remote:o,expose:r}=n,{name:s,alias:u}=o;if(this.idToRemoteMap[e]={name:o.name,expose:r},u&&e.startsWith(s)){const l=e.replace(s,u);this.idToRemoteMap[l]={name:o.name,expose:r};return}if(u&&e.startsWith(u)){const l=e.replace(u,s);this.idToRemoteMap[l]={name:o.name,expose:r}}}async loadRemote(e,n){const{host:o}=this;try{const{loadFactory:r=!0}=n||{loadFactory:!0},{module:s,moduleOptions:u,remoteMatchInfo:l}=await this.getRemoteModuleAndOptions({id:e}),{pkgNameOrAlias:d,remote:h,expose:p,id:m}=l,_=await s.get(m,p,n),y=await this.hooks.lifecycle.onLoad.emit({id:m,pkgNameOrAlias:d,expose:p,exposeModule:r?_:void 0,exposeModuleFactory:r?void 0:_,remote:h,options:u,moduleInstance:s,origin:o});return this.setIdToRemoteMap(e,l),typeof y=="function"?y:_}catch(r){const{from:s="runtime"}=n||{from:"runtime"},u=await this.hooks.lifecycle.errorLoadRemote.emit({id:e,error:r,from:s,lifecycle:"onLoad",origin:o});if(!u)throw r;return u}}async preloadRemote(e){const{host:n}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:e,options:n.options,origin:n});const o=formatPreloadArgs(n.options.remotes,e);await Promise.all(o.map(async r=>{const{remote:s}=r,u=getRemoteInfo(s),{globalSnapshot:l,remoteSnapshot:d}=await n.snapshotHandler.loadRemoteSnapshotInfo(s),h=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:n,preloadOptions:r,remote:s,remoteInfo:u,globalSnapshot:l,remoteSnapshot:d});h&&preloadAssets(u,n,h)}))}registerRemotes(e,n){const{host:o}=this;e.forEach(r=>{this.registerRemote(r,o.options.remotes,{force:n==null?void 0:n.force})})}async getRemoteModuleAndOptions(e){const{host:n}=this,{id:o}=e;let r;try{r=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:n.options,origin:n})}catch(E){if(r=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:n.options,origin:n,from:"runtime",error:E,lifecycle:"beforeRequest"}),!r)throw E}const{id:s}=r,u=matchRemoteWithNameAndExpose(n.options.remotes,s);assert(u,`
51
- Unable to locate ${s} in ${n.options.name}. Potential reasons for failure include:
52
-
53
- 1. ${s} was not included in the 'remotes' parameter of ${n.options.name||"the host"}.
54
-
55
- 2. ${s} could not be found in the 'remotes' of ${n.options.name} with either 'name' or 'alias' attributes.
56
- 3. ${s} is not online, injected, or loaded.
57
- 4. ${s} cannot be accessed on the expected.
58
- 5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${s}.
59
- `);const{remote:l}=u,d=getRemoteInfo(l),h=await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:s},u,{options:n.options,origin:n,remoteInfo:d})),{remote:p,expose:m}=h;assert(p&&m,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${s}.`);let _=n.moduleCache.get(p.name);const y={host:n,remoteInfo:d};return _||(_=new Module(y),n.moduleCache.set(p.name,_)),{module:_,moduleOptions:y,remoteMatchInfo:h}}registerRemote(e,n,o){const{host:r}=this,s=()=>{if(e.alias){const l=n.find(d=>{var h;return e.alias&&(d.name.startsWith(e.alias)||((h=d.alias)==null?void 0:h.startsWith(e.alias)))});assert(!l,`The alias ${e.alias} of remote ${e.name} is not allowed to be the prefix of ${l&&l.name} name or alias`)}"entry"in e&&isBrowserEnv()&&!e.entry.startsWith("http")&&(e.entry=new URL(e.entry,window.location.origin).href),e.shareScope||(e.shareScope=DEFAULT_SCOPE),e.type||(e.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:e,origin:r});const u=n.find(l=>l.name===e.name);if(!u)s(),n.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:r});else{const l=[`The remote "${e.name}" is already registered.`,o!=null&&o.force?"Hope you have known that OVERRIDE it may have some unexpected errors":'If you want to merge the remote, you can set "force: true".'];o!=null&&o.force&&(this.removeRemote(u),s(),n.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:r})),warn$1(l.join(" "))}}removeRemote(e){try{const{host:o}=this,{name:r}=e,s=o.options.remotes.findIndex(l=>l.name===r);s!==-1&&o.options.remotes.splice(s,1);const u=o.moduleCache.get(e.name);if(u){const l=u.remoteInfo,d=l.entryGlobalName;if(globalThis[d]){var n;(n=Object.getOwnPropertyDescriptor(globalThis,d))!=null&&n.configurable?delete globalThis[d]:globalThis[d]=void 0}const h=getRemoteEntryUniqueKey(u.remoteInfo);globalLoading[h]&&delete globalLoading[h],o.snapshotHandler.manifestCache.delete(l.entry);let p=l.buildVersion?composeKeyWithSeparator(l.name,l.buildVersion):l.name;const m=globalThis.__FEDERATION__.__INSTANCES__.findIndex(y=>l.buildVersion?y.options.id===p:y.name===p);if(m!==-1){const y=globalThis.__FEDERATION__.__INSTANCES__[m];p=y.options.id||p;const E=getGlobalShareScope();let R=!0;const b=[];Object.keys(E).forEach(v=>{const O=E[v];O&&Object.keys(O).forEach(I=>{const $=O[I];$&&Object.keys($).forEach(S=>{const T=$[S];T&&Object.keys(T).forEach(w=>{const A=T[w];A&&typeof A=="object"&&A.from===l.name&&(A.loaded||A.loading?(A.useIn=A.useIn.filter(L=>L!==l.name),A.useIn.length?R=!1:b.push([v,I,S,w])):b.push([v,I,S,w]))})})})}),R&&(y.shareScopeMap={},delete E[p]),b.forEach(([v,O,I,$])=>{var S,T,w;(w=E[v])==null||(T=w[O])==null||(S=T[I])==null||delete S[$]}),globalThis.__FEDERATION__.__INSTANCES__.splice(m,1)}const{hostGlobalSnapshot:_}=getGlobalRemoteInfo(e,o);if(_){const y=_&&"remotesInfo"in _&&_.remotesInfo&&getInfoWithoutType(_.remotesInfo,e.name).key;y&&(delete _.remotesInfo[y],Global.__FEDERATION__.__MANIFEST_LOADING__[y]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[y])}o.moduleCache.delete(e.name)}}catch(o){console.log("removeRemote fail: ",o)}}constructor(e){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=e,this.idToRemoteMap={}}}function _extends(){return _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends.apply(this,arguments)}class FederationHost{initOptions(e){this.registerPlugins(e.plugins);const n=this.formatOptions(this.options,e);return this.options=n,n}async loadShare(e,n){return this.sharedHandler.loadShare(e,n)}loadShareSync(e,n){return this.sharedHandler.loadShareSync(e,n)}initializeSharing(e=DEFAULT_SCOPE,n){return this.sharedHandler.initializeSharing(e,n)}initRawContainer(e,n,o){const r=getRemoteInfo({name:e,entry:n}),s=new Module({host:this,remoteInfo:r});return s.remoteEntryExports=o,this.moduleCache.set(e,s),s}async loadRemote(e,n){return this.remoteHandler.loadRemote(e,n)}async preloadRemote(e){return this.remoteHandler.preloadRemote(e)}initShareScopeMap(e,n,o={}){this.sharedHandler.initShareScopeMap(e,n,o)}formatOptions(e,n){const{shared:o}=formatShareConfigs(e,n),{userOptions:r,options:s}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:n,options:e,shareInfo:o}),u=this.remoteHandler.formatAndRegisterRemote(s,r),{shared:l}=this.sharedHandler.registerShared(s,r),d=[...s.plugins];r.plugins&&r.plugins.forEach(p=>{d.includes(p)||d.push(p)});const h=_extends({},e,n,{plugins:d,remotes:u,shared:l});return this.hooks.lifecycle.init.emit({origin:this,options:h}),h}registerPlugins(e){const n=registerPlugins(e,[this.hooks,this.remoteHandler.hooks,this.sharedHandler.hooks,this.snapshotHandler.hooks,this.loaderHook]);this.options.plugins=this.options.plugins.reduce((o,r)=>(r&&o&&!o.find(s=>s.name===r.name)&&o.push(r),o),n||[])}registerRemotes(e,n){return this.remoteHandler.registerRemotes(e,n)}constructor(e){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.6.0",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook});const n={id:getBuilderId(),name:e.name,plugins:[snapshotPlugin(),generatePreloadAssetsPlugin()],remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=e.name,this.options=n,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...n.plugins,...e.plugins||[]]),this.options=this.formatOptions(n,e)}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(FederationHost);var pluginHelper$1=Object.freeze({__proto__:null,SyncHook,AsyncHook,SyncWaterfallHook,AsyncWaterfallHook,PluginSystem});const ShareUtils={getRegisteredShare,getGlobalShareScope},GlobalUtils={Global,nativeGlobal,resetFederationGlobalInfo,getGlobalFederationInstance,setGlobalFederationInstance,getGlobalFederationConstructor,setGlobalFederationConstructor,getInfoWithoutType,getGlobalSnapshot,getTargetSnapshotInfoByModuleInfo,getGlobalSnapshotInfoByModuleInfo,setGlobalSnapshotInfoByModuleInfo,addGlobalSnapshot,getRemoteEntryExports,registerGlobalPlugins,getGlobalHostPlugins,getPreloaded,setPreloaded,registerPlugins,pluginHelper:pluginHelper$1};var helpers={global:GlobalUtils,share:ShareUtils};const registerPlugin=helpers.global.registerPlugins,pluginHelper=helpers.global.pluginHelper,host=getInstance(),pluginSystem=new pluginHelper.PluginSystem({bridgeRender:new pluginHelper.SyncHook,bridgeDestroy:new pluginHelper.SyncHook});registerPlugin(host.options.plugins,[pluginSystem]);const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,providerInfo:Function},setup(t){const e=Vue.ref(null),n=Vue.ref(null),o=Vue.ref(""),r=VueRouter.useRoute(),s=()=>{var h;const l=(h=t.providerInfo)==null?void 0:h.call(t);n.value=l;const d={name:t.moduleName,dom:e.value,basename:t.basename,memoryRoute:t.memoryRoute};LoggerInstance.log("createRemoteComponent LazyComponent render >>>",d),pluginSystem.lifecycle.bridgeRender.emit({...d}),l.render(d)},u=Vue.watch(()=>r.path,l=>{l!==r.path&&s(),o.value!==""&&o.value!==l&&(LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>",{...t,pathname:r.path}),f()),o.value=l});return Vue.onMounted(()=>{s()}),Vue.onBeforeUnmount(()=>{var l;LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>",{...t}),u(),pluginSystem.lifecycle.bridgeDestroy.emit({name:t.moduleName,dom:e.value,basename:t.basename,memoryRoute:t.memoryRoute}),(l=n.value)==null||l.destroy({dom:e.value})}),()=>Vue.createVNode("div",{ref:e},null)}});function createRemoteComponent(t){return Vue.defineAsyncComponent({__APP_VERSION__:"0.6.0",loader:async()=>{var d;const e=VueRouter.useRoute();let n="/";const o=(d=e.matched[0])==null?void 0:d.path;o&&(o.endsWith("/:pathMatch(.*)*")?n=o.replace("/:pathMatch(.*)*",""):n=e.matched[0].path);const r=(t==null?void 0:t.export)||"default";LoggerInstance.log("createRemoteComponent LazyComponent create >>>",{basename:n,info:t});const s=await t.loader(),u=s&&s[Symbol.for("mf_module_id")],l=s[r];if(LoggerInstance.log("createRemoteComponent LazyComponent loadRemote info >>>",{name:u,module:s,exportName:r,basename:n,route:e}),r in s&&typeof l=="function")return{render(){return Vue.h(RemoteApp,{moduleName:u,...t,providerInfo:l,basename:n})}};throw new Error("module not found")},loadingComponent:{template:"<div>Loading...</div>"},errorComponent:{template:"<div>Error loading component</div>"},delay:200,timeout:3e3})}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteComponent=createRemoteComponent;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),p=require("vue-router");function b(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(o,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return o.default=t,Object.freeze(o)}const h=b(s),d=b(p);var y=Object.defineProperty,v=(t,o,e)=>o in t?y(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,i=(t,o,e)=>(v(t,typeof o!="symbol"?o+"":o,e),e);class f{constructor(o){i(this,"name"),i(this,"isDebugEnabled"),i(this,"color"),this.name=o,this.isDebugEnabled=!1,this.color=this.stringToColor(o),typeof window<"u"&&typeof localStorage<"u"&&(this.isDebugEnabled=localStorage.getItem("debug")==="true"),typeof process<"u"&&process.env&&(this.isDebugEnabled=process.env.DEBUG==="true")}log(...o){var e,n;if(this.isDebugEnabled){const r=`color: ${this.color}; font-weight: bold`,a=`%c[${this.name}]`,u=((n=(e=new Error().stack)==null?void 0:e.split(`
2
+ `)[2])==null?void 0:n.trim())||"Stack information not available";typeof console<"u"&&console.debug&&console.debug(a,r,...o,`
3
+ (${u})`)}}stringToColor(o){let e=0;for(let r=0;r<o.length;r++)e=o.charCodeAt(r)+((e<<5)-e);let n="#";for(let r=0;r<3;r++){const a=e>>r*8&255;n+=("00"+a.toString(16)).substr(-2)}return n}}function R(){const t=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(t)}const c=new f("vue3-bridge");function C(t){const o=new Map;return()=>({__APP_VERSION__:"0.6.0",render(e){c.log("createBridgeComponent render Info",e);const n=h.createApp(t.rootComponent);o.set(e.dom,n);const r=t.appOptions({basename:e.basename,memoryRoute:e.memoryRoute}),a=e.memoryRoute?d.createMemoryHistory(e.basename):d.createWebHistory(e.basename),u=d.createRouter({...r.router.options,history:a,routes:r.router.getRoutes()});c.log("createBridgeComponent render router info>>>",{name:e.moduleName,router:u}),e.memoryRoute?u.push(e.memoryRoute.entryPath).then(()=>{n.use(u),n.mount(e.dom)}):(n.use(u),n.mount(e.dom))},destroy(e){c.log("createBridgeComponent destroy Info",e);const n=o.get(e==null?void 0:e.dom);n==null||n.unmount()}})}const _=s.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,providerInfo:Function},setup(t){const o=s.ref(null),e=s.ref(null),n=s.ref(""),r=p.useRoute(),a=()=>{var g;const m=(g=t.providerInfo)==null?void 0:g.call(t);e.value=m;const l={name:t.moduleName,dom:o.value,basename:t.basename,memoryRoute:t.memoryRoute};c.log("createRemoteComponent LazyComponent render >>>",l),m.render(l)},u=s.watch(()=>r.path,m=>{m!==r.path&&a(),n.value!==""&&n.value!==m&&(c.log("createRemoteComponent dispatchPopstateEnv >>>",{...t,pathname:r.path}),R()),n.value=m});return s.onMounted(()=>{a()}),s.onBeforeUnmount(()=>{var m;c.log("createRemoteComponent LazyComponent destroy >>>",{...t}),u(),(m=e.value)==null||m.destroy({dom:o.value})}),()=>s.createVNode("div",{ref:o},null)}});function w(t){return s.defineAsyncComponent({__APP_VERSION__:"0.6.0",loader:async()=>{var l;const o=p.useRoute();let e="/";const n=(l=o.matched[0])==null?void 0:l.path;n&&(n.endsWith("/:pathMatch(.*)*")?e=n.replace("/:pathMatch(.*)*",""):e=o.matched[0].path);const r=(t==null?void 0:t.export)||"default";c.log("createRemoteComponent LazyComponent create >>>",{basename:e,info:t});const a=await t.loader(),u=a&&a[Symbol.for("mf_module_id")],m=a[r];if(c.log("createRemoteComponent LazyComponent loadRemote info >>>",{name:u,module:a,exportName:r,basename:e,route:o}),r in a&&typeof m=="function")return{render(){return s.h(_,{moduleName:u,...t,providerInfo:m,basename:e})}};throw new Error("module not found")},loadingComponent:{template:"<div>Loading...</div>"},errorComponent:{template:"<div>Error loading component</div>"},delay:200,timeout:3e3})}exports.createBridgeComponent=C;exports.createRemoteComponent=w;