@module-federation/bridge-vue3 0.19.0 → 0.20.0

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,5 +1,25 @@
1
1
  # @module-federation/bridge-vue3
2
2
 
3
+ ## 0.20.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e89e972]
8
+ - Updated dependencies [37346d4]
9
+ - Updated dependencies [639a83b]
10
+ - @module-federation/runtime@0.20.0
11
+ - @module-federation/sdk@0.20.0
12
+ - @module-federation/bridge-shared@0.20.0
13
+
14
+ ## 0.19.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+ - @module-federation/sdk@0.19.1
20
+ - @module-federation/runtime@0.19.1
21
+ - @module-federation/bridge-shared@0.19.1
22
+
3
23
  ## 0.19.0
4
24
 
5
25
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vue=require("vue"),VueRouter=require("vue-router");function _interopNamespaceDefault(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const n in o)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>o[n]})}}return t.default=o,Object.freeze(t)}const Vue__namespace=_interopNamespaceDefault(Vue),VueRouter__namespace=_interopNamespaceDefault(VueRouter);function _extends$2(){return _extends$2=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},_extends$2.apply(this,arguments)}const MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",SEPARATOR=":";function isBrowserEnv(){return typeof window<"u"&&typeof window.document<"u"}function isReactNativeEnv(){var o;return typeof navigator<"u"&&((o=navigator)==null?void 0:o.product)==="ReactNative"}function isBrowserDebug(){try{if(isBrowserEnv()&&window.localStorage)return!!localStorage.getItem(BROWSER_LOG_KEY)}catch{return!1}return!1}function isDebugMode(){return typeof process<"u"&&process.env&&process.env.FEDERATION_DEBUG?!!process.env.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&FEDERATION_DEBUG?!0:isBrowserDebug()}const LOG_CATEGORY$1="[ Federation Runtime ]",composeKeyWithSeparator=function(...o){return o.length?o.reduce((t,n)=>n?t?`${t}${SEPARATOR}${n}`:n:t,""):""},getResourceUrl=(o,t)=>{if("getPublicPath"in o){let n;return o.getPublicPath.startsWith("function")?n=new Function("return "+o.getPublicPath)()():n=new Function(o.getPublicPath)(),`${n}${t}`}else return"publicPath"in o?!isBrowserEnv()&&!isReactNativeEnv()&&"ssrPublicPath"in o?`${o.ssrPublicPath}${t}`:`${o.publicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",o,t),"")},warn$1=o=>{console.warn(`${LOG_CATEGORY$1}: ${o}`)};function safeToString(o){try{return JSON.stringify(o,null,2)}catch{return""}}const simpleJoinRemoteEntry=(o,t)=>{if(!o)return t;const r=(s=>{if(s===".")return"";if(s.startsWith("./"))return s.replace("./","");if(s.startsWith("/")){const a=s.slice(1);return a.endsWith("/")?a.slice(0,-1):a}return s})(o);return r?r.endsWith("/")?`${r}${t}`:`${r}/${t}`:t};function inferAutoPublicPath(o){return o.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(o,t={}){var n,r;const{remotes:s={},overrides:a={},version:l}=t;let i;const c=()=>"publicPath"in o.metaData?o.metaData.publicPath==="auto"&&l?inferAutoPublicPath(l):o.metaData.publicPath:o.metaData.getPublicPath,u=Object.keys(a);let h={};if(!Object.keys(s).length){var d;h=((d=o.remotes)==null?void 0:d.reduce((b,v)=>{let $;const A=v.federationContainerName;return u.includes(A)?$=a[A]:"version"in v?$=v.version:$=v.entry,b[A]={matchedVersion:$},b},{}))||{}}Object.keys(s).forEach(b=>h[b]={matchedVersion:u.includes(b)?a[b]:s[b]});const{remoteEntry:{path:p,name:m,type:_},types:E,buildInfo:{buildVersion:y},globalName:g,ssrRemoteEntry:I}=o.metaData,{exposes:S}=o;let R={version:l||"",buildVersion:y,globalName:g,remoteEntry:simpleJoinRemoteEntry(p,m),remoteEntryType:_,remoteTypes:simpleJoinRemoteEntry(E.path,E.name),remoteTypesZip:E.zip||"",remoteTypesAPI:E.api||"",remotesInfo:h,shared:o==null?void 0:o.shared.map(b=>({assets:b.assets,sharedName:b.name,version:b.version})),modules:S==null?void 0:S.map(b=>({moduleName:b.name,modulePath:b.path,assets:b.assets}))};if((n=o.metaData)!=null&&n.prefetchInterface){const b=o.metaData.prefetchInterface;R=_extends$2({},R,{prefetchInterface:b})}if((r=o.metaData)!=null&&r.prefetchEntry){const{path:b,name:v,type:$}=o.metaData.prefetchEntry;R=_extends$2({},R,{prefetchEntry:simpleJoinRemoteEntry(b,v),prefetchEntryType:$})}if("publicPath"in o.metaData?i=_extends$2({},R,{publicPath:c(),ssrPublicPath:o.metaData.ssrPublicPath}):i=_extends$2({},R,{getPublicPath:c()}),I){const b=simpleJoinRemoteEntry(I.path,I.name);i.ssrRemoteEntry=b,i.ssrRemoteEntryType=I.type||"commonjs-module"}return i}function isManifestProvider(o){return!!("remoteEntry"in o&&o.remoteEntry.includes(MANIFEST_EXT))}let Logger=class{setPrefix(t){this.prefix=t}log(...t){console.log(this.prefix,...t)}warn(...t){console.log(this.prefix,...t)}error(...t){console.log(this.prefix,...t)}success(...t){console.log(this.prefix,...t)}info(...t){console.log(this.prefix,...t)}ready(...t){console.log(this.prefix,...t)}debug(...t){isDebugMode()&&console.log(this.prefix,...t)}constructor(t){this.prefix=t}};function createLogger(o){return new Logger(o)}async function safeWrapper(o,t){try{return await o()}catch(n){warn$1(n);return}}function isStaticResourcesEqual(o,t){const n=/^(https?:)?\/\//i,r=o.replace(n,"").replace(/\/$/,""),s=t.replace(n,"").replace(/\/$/,"");return r===s}function createScript(o){let t=null,n=!0,r=2e4,s;const a=document.getElementsByTagName("script");for(let i=0;i<a.length;i++){const c=a[i],u=c.getAttribute("src");if(u&&isStaticResourcesEqual(u,o.url)){t=c,n=!1;break}}if(!t){const i=o.attrs;t=document.createElement("script"),t.type=(i==null?void 0:i.type)==="module"?"module":"text/javascript";let c;o.createScriptHook&&(c=o.createScriptHook(o.url,o.attrs),c instanceof HTMLScriptElement?t=c:typeof c=="object"&&("script"in c&&c.script&&(t=c.script),"timeout"in c&&c.timeout&&(r=c.timeout))),t.src||(t.src=o.url),i&&!c&&Object.keys(i).forEach(u=>{t&&(u==="async"||u==="defer"?t[u]=i[u]:t.getAttribute(u)||t.setAttribute(u,i[u]))})}const l=async(i,c)=>{clearTimeout(s);const u=()=>{(c==null?void 0:c.type)==="error"?o!=null&&o.onErrorCallback&&(o==null||o.onErrorCallback(c)):o!=null&&o.cb&&(o==null||o.cb())};if(t&&(t.onerror=null,t.onload=null,safeWrapper(()=>{const{needDeleteScript:h=!0}=o;h&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),i&&typeof i=="function")){const h=i(c);if(h instanceof Promise){const d=await h;return u(),d}return u(),h}u()};return t.onerror=l.bind(null,t.onerror),t.onload=l.bind(null,t.onload),s=setTimeout(()=>{l(null,new Error(`Remote script "${o.url}" time-outed.`))},r),{script:t,needAttach:n}}function createLink(o){let t=null,n=!0;const r=document.getElementsByTagName("link");for(let a=0;a<r.length;a++){const l=r[a],i=l.getAttribute("href"),c=l.getAttribute("rel");if(i&&isStaticResourcesEqual(i,o.url)&&c===o.attrs.rel){t=l,n=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",o.url);let a;const l=o.attrs;o.createLinkHook&&(a=o.createLinkHook(o.url,l),a instanceof HTMLLinkElement&&(t=a)),l&&!a&&Object.keys(l).forEach(i=>{t&&!t.getAttribute(i)&&t.setAttribute(i,l[i])})}const s=(a,l)=>{const i=()=>{(l==null?void 0:l.type)==="error"?o!=null&&o.onErrorCallback&&(o==null||o.onErrorCallback(l)):o!=null&&o.cb&&(o==null||o.cb())};if(t&&(t.onerror=null,t.onload=null,safeWrapper(()=>{const{needDeleteLink:c=!0}=o;c&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),a)){const c=a(l);return i(),c}i()};return t.onerror=s.bind(null,t.onerror),t.onload=s.bind(null,t.onload),{link:t,needAttach:n}}function loadScript(o,t){const{attrs:n={},createScriptHook:r}=t;return new Promise((s,a)=>{const{script:l,needAttach:i}=createScript({url:o,cb:s,onErrorCallback:a,attrs:_extends$2({fetchpriority:"high"},n),createScriptHook:r,needDeleteScript:!0});i&&document.head.appendChild(l)})}const sdkImportCache=new Map;function importNodeModule(o){if(!o)throw new Error("import specifier is required");if(sdkImportCache.has(o))return sdkImportCache.get(o);const n=new Function("name","return import(name)")(o).then(r=>r).catch(r=>{throw console.error(`Error importing module ${o}:`,r),sdkImportCache.delete(o),r});return sdkImportCache.set(o,n),n}const loadNodeFetch=async()=>{const o=await importNodeModule("node-fetch");return o.default||o},lazyLoaderHookFetch=async(o,t,n)=>{const s=await((a,l)=>n.lifecycle.fetch.emit(a,l))(o,t||{});return!s||!(s instanceof Response)?(typeof fetch>"u"?await loadNodeFetch():fetch)(o,t||{}):s},createScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(url,cb,attrs,loaderHook)=>{if(loaderHook!=null&&loaderHook.createScriptHook){const o=loaderHook.createScriptHook(url);o&&typeof o=="object"&&"url"in o&&(url=o.url)}let urlObj;try{urlObj=new URL(url)}catch(o){console.error("Error constructing URL:",o),cb(new Error(`Invalid URL: ${o}`));return}const getFetch=async()=>loaderHook!=null&&loaderHook.fetch?(o,t)=>lazyLoaderHookFetch(o,t,loaderHook):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}
2
- })`,{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 o=exportedInterface[attrs.globalName]||exportedInterface;cb(void 0,o);return}cb(void 0,exportedInterface)}catch(o){cb(o instanceof Error?o:new Error(`Script execution error: ${o}`))}};getFetch().then(async o=>{if((attrs==null?void 0:attrs.type)==="esm"||(attrs==null?void 0:attrs.type)==="module")return loadModule(urlObj.href,{fetch:o,vm:await importNodeModule("vm")}).then(async t=>{await t.evaluate(),cb(void 0,t.namespace)}).catch(t=>{cb(t instanceof Error?t:new Error(`Script execution error: ${t}`))});handleScriptFetch(o,urlObj)}).catch(o=>{cb(o)})}:(o,t,n,r)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},loadScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(o,t)=>new Promise((n,r)=>{createScriptNode(o,(s,a)=>{if(s)r(s);else{var l,i;const c=(t==null||(l=t.attrs)==null?void 0:l.globalName)||`__FEDERATION_${t==null||(i=t.attrs)==null?void 0:i.name}:custom__`,u=globalThis[c]=a;n(u)}},t.attrs,t.loaderHook)}):(o,t)=>{throw new Error("loadScriptNode is disabled in non-Node.js environment")},esmModuleCache=new Map;async function loadModule(o,t){if(esmModuleCache.has(o))return esmModuleCache.get(o);const{fetch:n,vm:r}=t,a=await(await n(o)).text(),l=new r.SourceTextModule(a,{importModuleDynamically:async(i,c)=>{const u=new URL(i,o).href;return loadModule(u,t)}});return esmModuleCache.set(o,l),await l.link(async i=>{const c=new URL(i,o).href;return await loadModule(c,t)}),l}const LoggerInstance=createLogger("[ Module Federation Bridge Vue3 ]");function _extends$1(){return _extends$1=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},_extends$1.apply(this,arguments)}function _object_without_properties_loose(o,t){if(o==null)return{};var n={},r=Object.keys(o),s,a;for(a=0;a<r.length;a++)s=r[a],!(t.indexOf(s)>=0)&&(n[s]=o[s]);return n}const RUNTIME_001="RUNTIME-001",RUNTIME_002="RUNTIME-002",RUNTIME_003="RUNTIME-003",RUNTIME_004="RUNTIME-004",RUNTIME_005="RUNTIME-005",RUNTIME_006="RUNTIME-006",RUNTIME_007="RUNTIME-007",RUNTIME_008="RUNTIME-008",RUNTIME_009="RUNTIME-009",TYPE_001="TYPE-001",BUILD_001="BUILD-001",BUILD_002="BUILD-002",getDocsUrl=o=>`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${o.split("-")[0].toLowerCase()}/${o}`,getShortErrorMsg=(o,t,n,r)=>{const s=[`${[t[o]]} #${o}`];return n&&s.push(`args: ${JSON.stringify(n)}`),s.push(getDocsUrl(o)),r&&s.push(`Original Error Message:
3
- ${r}`),s.join(`
4
- `)};function _extends(){return _extends=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},_extends.apply(this,arguments)}const runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot.",[RUNTIME_008]:"Failed to load script resources.",[RUNTIME_009]:"Please call createInstance first."},typeDescMap={[TYPE_001]:"Failed to generate type declaration. Execute the below cmd to reproduce and fix the error."},buildDescMap={[BUILD_001]:"Failed to find expose module.",[BUILD_002]:"PublicPath is required in prod mode."};_extends({},runtimeDescMap,typeDescMap,buildDescMap);const LOG_CATEGORY="[ Federation Runtime ]",logger=createLogger(LOG_CATEGORY);function assert(o,t){o||error(t)}function error(o){throw o instanceof Error?(o.message.startsWith(LOG_CATEGORY)||(o.message=`${LOG_CATEGORY}: ${o.message}`),o):new Error(`${LOG_CATEGORY}: ${o}`)}function warn(o){o instanceof Error&&(o.message.startsWith(LOG_CATEGORY)||(o.message=`${LOG_CATEGORY}: ${o.message}`)),logger.warn(o)}function addUniqueItem(o,t){return o.findIndex(n=>n===t)===-1&&o.push(t),o}function getFMId(o){return"version"in o&&o.version?`${o.name}:${o.version}`:"entry"in o&&o.entry?`${o.name}:${o.entry}`:`${o.name}`}function isRemoteInfoWithEntry(o){return typeof o.entry<"u"}function isPureRemoteEntry(o){return!o.entry.includes(".json")}function isObject(o){return o&&typeof o=="object"}const objectToString=Object.prototype.toString;function isPlainObject(o){return objectToString.call(o)==="[object Object]"}function arrayOptions(o){return Array.isArray(o)?o:[o]}function getRemoteEntryInfoFromSnapshot(o){const t={url:"",type:"global",globalName:""};return isBrowserEnv()||isReactNativeEnv()?"remoteEntry"in o?{url:o.remoteEntry,type:o.remoteEntryType,globalName:o.globalName}:t:"ssrRemoteEntry"in o?{url:o.ssrRemoteEntry||t.url,type:o.ssrRemoteEntryType||t.type,globalName:o.globalName}:t}const processModuleAlias=(o,t)=>{let n;return o.endsWith("/")?n=o.slice(0,-1):n=o,t.startsWith(".")&&(t=t.slice(1)),n=n+t,n},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(o,t,n){Object.defineProperty(o,t,{value:n,configurable:!1,writable:!0})}function includeOwnProperty(o,t){return Object.hasOwnProperty.call(o,t)}includeOwnProperty(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(o){var t,n,r,s,a,l;includeOwnProperty(o,"__VMOK__")&&!includeOwnProperty(o,"__FEDERATION__")&&definePropertyGlobalVal(o,"__FEDERATION__",o.__VMOK__),includeOwnProperty(o,"__FEDERATION__")||(definePropertyGlobalVal(o,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),definePropertyGlobalVal(o,"__VMOK__",o.__FEDERATION__));var i;(i=(t=o.__FEDERATION__).__GLOBAL_PLUGIN__)!=null||(t.__GLOBAL_PLUGIN__=[]);var c;(c=(n=o.__FEDERATION__).__INSTANCES__)!=null||(n.__INSTANCES__=[]);var u;(u=(r=o.__FEDERATION__).moduleInfo)!=null||(r.moduleInfo={});var h;(h=(s=o.__FEDERATION__).__SHARE__)!=null||(s.__SHARE__={});var d;(d=(a=o.__FEDERATION__).__MANIFEST_LOADING__)!=null||(a.__MANIFEST_LOADING__={});var p;(p=(l=o.__FEDERATION__).__PRELOADED_MAP__)!=null||(l.__PRELOADED_MAP__=new Map)}setGlobalDefaultVal(CurrentGlobal);setGlobalDefaultVal(nativeGlobal);function setGlobalFederationConstructor(o,t=isDebugMode()){t&&(CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__=o,CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="0.19.0")}function getInfoWithoutType(o,t){if(typeof t=="string"){if(o[t])return{value:o[t],key:t};{const r=Object.keys(o);for(const s of r){const[a,l]=s.split(":"),i=`${a}:${t}`,c=o[i];if(c)return{value:c,key:i}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(o,t)=>{const n=getFMId(o),r=getInfoWithoutType(t,n).value;if(r&&!r.version&&"version"in o&&o.version&&(r.version=o.version),r)return r;if("version"in o&&o.version){const{version:s}=o,a=_object_without_properties_loose(o,["version"]),l=getFMId(a),i=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,l).value;if((i==null?void 0:i.version)===s)return i}},getGlobalSnapshotInfoByModuleInfo=o=>getTargetSnapshotInfoByModuleInfo(o,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(o,t)=>{const n=getFMId(o);return nativeGlobal.__FEDERATION__.moduleInfo[n]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=o=>(nativeGlobal.__FEDERATION__.moduleInfo=_extends$1({},nativeGlobal.__FEDERATION__.moduleInfo,o),()=>{const t=Object.keys(o);for(const n of t)delete nativeGlobal.__FEDERATION__.moduleInfo[n]}),getRemoteEntryExports=(o,t)=>{const n=t||`__FEDERATION_${o}:custom__`,r=CurrentGlobal[n];return{remoteEntryKey:n,entryExports:r}},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=o=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(o),setPreloaded=o=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(o,!0),DEFAULT_SCOPE="default",DEFAULT_REMOTE_TYPE="global",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(o){return new RegExp(o)}function isXVersion(o){return!o||o.toLowerCase()==="x"||o==="*"}function pipe(...o){return t=>o.reduce((n,r)=>r(n),t)}function extractComparator(o){return o.match(parseRegex(comparator))}function combineVersion(o,t,n,r){const s=`${o}.${t}.${n}`;return r?`${s}-${r}`:s}function parseHyphen(o){return o.replace(parseRegex(hyphenRange),(t,n,r,s,a,l,i,c,u,h,d,p)=>(isXVersion(r)?n="":isXVersion(s)?n=`>=${r}.0.0`:isXVersion(a)?n=`>=${r}.${s}.0`:n=`>=${n}`,isXVersion(u)?c="":isXVersion(h)?c=`<${Number(u)+1}.0.0-0`:isXVersion(d)?c=`<${u}.${Number(h)+1}.0-0`:p?c=`<=${u}.${h}.${d}-${p}`:c=`<=${c}`,`${n} ${c}`.trim()))}function parseComparatorTrim(o){return o.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(o){return o.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(o){return o.replace(parseRegex(caretTrim),"$1^")}function parseCarets(o){return o.trim().split(/\s+/).map(t=>t.replace(parseRegex(caret),(n,r,s,a,l)=>isXVersion(r)?"":isXVersion(s)?`>=${r}.0.0 <${Number(r)+1}.0.0-0`:isXVersion(a)?r==="0"?`>=${r}.${s}.0 <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.0 <${Number(r)+1}.0.0-0`:l?r==="0"?s==="0"?`>=${r}.${s}.${a}-${l} <${r}.${s}.${Number(a)+1}-0`:`>=${r}.${s}.${a}-${l} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${a}-${l} <${Number(r)+1}.0.0-0`:r==="0"?s==="0"?`>=${r}.${s}.${a} <${r}.${s}.${Number(a)+1}-0`:`>=${r}.${s}.${a} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${a} <${Number(r)+1}.0.0-0`)).join(" ")}function parseTildes(o){return o.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(n,r,s,a,l)=>isXVersion(r)?"":isXVersion(s)?`>=${r}.0.0 <${Number(r)+1}.0.0-0`:isXVersion(a)?`>=${r}.${s}.0 <${r}.${Number(s)+1}.0-0`:l?`>=${r}.${s}.${a}-${l} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${a} <${r}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(o){return o.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(n,r,s,a,l,i)=>{const c=isXVersion(s),u=c||isXVersion(a),h=u||isXVersion(l);return r==="="&&h&&(r=""),i="",c?r===">"||r==="<"?"<0.0.0-0":"*":r&&h?(u&&(a=0),l=0,r===">"?(r=">=",u?(s=Number(s)+1,a=0,l=0):(a=Number(a)+1,l=0)):r==="<="&&(r="<",u?s=Number(s)+1:a=Number(a)+1),r==="<"&&(i="-0"),`${r+s}.${a}.${l}${i}`):u?`>=${s}.0.0${i} <${Number(s)+1}.0.0-0`:h?`>=${s}.${a}.0${i} <${s}.${Number(a)+1}.0-0`:n})).join(" ")}function parseStar(o){return o.trim().replace(parseRegex(star),"")}function parseGTE0(o){return o.trim().replace(parseRegex(gte0),"")}function compareAtom(o,t){return o=Number(o)||o,t=Number(t)||t,o>t?1:o===t?0:-1}function comparePreRelease(o,t){const{preRelease:n}=o,{preRelease:r}=t;if(n===void 0&&r)return 1;if(n&&r===void 0)return-1;if(n===void 0&&r===void 0)return 0;for(let s=0,a=n.length;s<=a;s++){const l=n[s],i=r[s];if(l!==i)return l===void 0&&i===void 0?0:l?i?compareAtom(l,i):-1:1}return 0}function compareVersion(o,t){return compareAtom(o.major,t.major)||compareAtom(o.minor,t.minor)||compareAtom(o.patch,t.patch)||comparePreRelease(o,t)}function eq(o,t){return o.version===t.version}function compare(o,t){switch(o.operator){case"":case"=":return eq(o,t);case">":return compareVersion(o,t)<0;case">=":return eq(o,t)||compareVersion(o,t)<0;case"<":return compareVersion(o,t)>0;case"<=":return eq(o,t)||compareVersion(o,t)>0;case void 0:return!0;default:return!1}}function parseComparatorString(o){return pipe(parseCarets,parseTildes,parseXRanges,parseStar)(o)}function parseRange(o){return pipe(parseHyphen,parseComparatorTrim,parseTildeTrim,parseCaretTrim)(o.trim()).split(/\s+/).join(" ")}function satisfy(o,t){if(!o)return!1;const n=extractComparator(o);if(!n)return!1;const[,r,,s,a,l,i]=n,c={operator:r,version:combineVersion(s,a,l,i),major:s,minor:a,patch:l,preRelease:i==null?void 0:i.split(".")},u=t.split("||");for(const h of u){const d=h.trim();if(!d||d==="*"||d==="x")return!0;try{const p=parseRange(d);if(!p.trim())return!0;const m=p.split(" ").map(y=>parseComparatorString(y)).join(" ");if(!m.trim())return!0;const _=m.split(/\s+/).map(y=>parseGTE0(y)).filter(Boolean);if(_.length===0)continue;let E=!0;for(const y of _){const g=extractComparator(y);if(!g){E=!1;break}const[,I,,S,R,b,v]=g,$={operator:I,version:combineVersion(S,R,b,v),major:S,minor:R,patch:b,preRelease:v==null?void 0:v.split(".")};if(!compare($,c)){E=!1;break}}if(E)return!0}catch(p){console.error(`[semver] Error processing range part "${d}":`,p);continue}}return!1}function formatShare(o,t,n,r){let s;"get"in o?s=o.get:"lib"in o?s=()=>Promise.resolve(o.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${n}'!`)});var a,l,i;return _extends$1({deps:[],useIn:[],from:t,loading:null},o,{shareConfig:_extends$1({requiredVersion:`^${o.version}`,singleton:!1,eager:!1,strictVersion:!1},o.shareConfig),get:s,loaded:o!=null&&o.loaded||"lib"in o?!0:void 0,version:(a=o.version)!=null?a:"0",scope:Array.isArray(o.scope)?o.scope:[(l=o.scope)!=null?l:"default"],strategy:((i=o.strategy)!=null?i:r)||"version-first"})}function formatShareConfigs(o,t){const n=t.shared||{},r=t.name,s=Object.keys(n).reduce((l,i)=>{const c=arrayOptions(n[i]);return l[i]=l[i]||[],c.forEach(u=>{l[i].push(formatShare(u,r,i,t.shareStrategy))}),l},{}),a=_extends$1({},o.shared);return Object.keys(s).forEach(l=>{a[l]?s[l].forEach(i=>{a[l].find(u=>u.version===i.version)||a[l].push(i)}):a[l]=s[l]}),{shared:a,shareInfos:s}}function versionLt(o,t){const n=r=>{if(!Number.isNaN(Number(r))){const a=r.split(".");let l=r;for(let i=0;i<3-a.length;i++)l+=".0";return l}return r};return!!satisfy(n(o),`<=${n(t)}`)}const findVersion=(o,t)=>{const n=t||function(r,s){return versionLt(r,s)};return Object.keys(o).reduce((r,s)=>!r||n(r,s)||r==="0"?s:r,0)},isLoaded=o=>!!o.loaded||typeof o.lib=="function",isLoading=o=>!!o.loading;function findSingletonVersionOrderByVersion(o,t,n){const r=o[t][n],s=function(a,l){return!isLoaded(r[a])&&versionLt(a,l)};return findVersion(o[t][n],s)}function findSingletonVersionOrderByLoaded(o,t,n){const r=o[t][n],s=function(a,l){const i=c=>isLoaded(c)||isLoading(c);return i(r[l])?i(r[a])?!!versionLt(a,l):!0:i(r[a])?!1:versionLt(a,l)};return findVersion(o[t][n],s)}function getFindShareFunction(o){return o==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(o,t,n,r){if(!o)return;const{shareConfig:s,scope:a=DEFAULT_SCOPE,strategy:l}=n,i=Array.isArray(a)?a:[a];for(const c of i)if(s&&o[c]&&o[c][t]){const{requiredVersion:u}=s,d=getFindShareFunction(l)(o,c,t),p=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(d,u)){const E=`Version ${d} from ${d&&o[c][t][d].from} of shared singleton module ${t} does not satisfy the requirement of ${n.from} which needs ${u})`;s.strictVersion?error(E):warn(E)}return o[c][t][d]}else{if(u===!1||u==="*"||satisfy(d,u))return o[c][t][d];for(const[E,y]of Object.entries(o[c][t]))if(satisfy(E,u))return y}},m={shareScopeMap:o,scope:c,pkgName:t,version:d,GlobalFederation:Global.__FEDERATION__,resolver:p};return(r.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(o){const{pkgName:t,extraOptions:n,shareInfos:r}=o,s=i=>{if(!i)return;const c={};i.forEach(d=>{c[d.version]=d});const h=findVersion(c,function(d,p){return!isLoaded(c[d])&&versionLt(d,p)});return c[h]};var a;const l=(a=n==null?void 0:n.resolver)!=null?a:s;return Object.assign({},l(r[t]),n==null?void 0:n.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(o,t){for(const n of o){const r=t.startsWith(n.name);let s=t.replace(n.name,"");if(r){if(s.startsWith("/")){const i=n.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:n}}else if(s==="")return{pkgNameOrAlias:n.name,expose:".",remote:n}}const a=n.alias&&t.startsWith(n.alias);let l=n.alias&&t.replace(n.alias,"");if(n.alias&&a){if(l&&l.startsWith("/")){const i=n.alias;return l=`.${l}`,{pkgNameOrAlias:i,expose:l,remote:n}}else if(l==="")return{pkgNameOrAlias:n.alias,expose:".",remote:n}}}}function matchRemote(o,t){for(const n of o)if(t===n.name||n.alias&&t===n.alias)return n}function registerPlugins(o,t){const n=getGlobalHostPlugins(),r=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return n.length>0&&n.forEach(s=>{o!=null&&o.find(a=>a.name!==s.name)&&o.push(s)}),o&&o.length>0&&o.forEach(s=>{r.forEach(a=>{a.applyPlugin(s,t)})}),o}const importCallback=".then(callbacks[0]).catch(callbacks[1])";async function loadEsmEntry({entry:o,remoteEntryExports:t}){return new Promise((n,r)=>{try{t?n(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${o}")${importCallback}`)([n,r]):import(o).then(n).catch(r)}catch(s){r(s)}})}async function loadSystemJsEntry({entry:o,remoteEntryExports:t}){return new Promise((n,r)=>{try{t?n(t):typeof __system_context__>"u"?System.import(o).then(n).catch(r):new Function("callbacks",`System.import("${o}")${importCallback}`)([n,r])}catch(s){r(s)}})}function handleRemoteEntryLoaded(o,t,n){const{remoteEntryKey:r,entryExports:s}=getRemoteEntryExports(o,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:o,remoteEntryUrl:n,remoteEntryKey:r})),s}async function loadEntryScript({name:o,globalName:t,entry:n,loaderHook:r,getEntryUrl:s}){const{entryExports:a}=getRemoteEntryExports(o,t);if(a)return a;const l=s?s(n):n;return loadScript(l,{attrs:{},createScriptHook:(i,c)=>{const u=r.lifecycle.createScript.emit({url:i,attrs:c});if(u&&(u instanceof HTMLScriptElement||"script"in u||"timeout"in u))return u}}).then(()=>handleRemoteEntryLoaded(o,t,n)).catch(i=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:o,resourceUrl:n})),i})}async function loadEntryDom({remoteInfo:o,remoteEntryExports:t,loaderHook:n,getEntryUrl:r}){const{entry:s,entryGlobalName:a,name:l,type:i}=o;switch(i){case"esm":case"module":return loadEsmEntry({entry:s,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:s,remoteEntryExports:t});default:return loadEntryScript({entry:s,globalName:a,name:l,loaderHook:n,getEntryUrl:r})}}async function loadEntryNode({remoteInfo:o,loaderHook:t}){const{entry:n,entryGlobalName:r,name:s,type:a}=o,{entryExports:l}=getRemoteEntryExports(s,r);return l||loadScriptNode(n,{attrs:{name:s,globalName:r,type:a},loaderHook:{createScriptHook:(i,c={})=>{const u=t.lifecycle.createScript.emit({url:i,attrs:c});if(u&&"url"in u)return u}}}).then(()=>handleRemoteEntryLoaded(s,r,n)).catch(i=>{throw i})}function getRemoteEntryUniqueKey(o){const{entry:t,name:n}=o;return composeKeyWithSeparator(n,t)}async function getRemoteEntry(o){const{origin:t,remoteEntryExports:n,remoteInfo:r,getEntryUrl:s}=o,a=getRemoteEntryUniqueKey(r);if(n)return n;if(!globalLoading[a]){const l=t.remoteHandler.hooks.lifecycle.loadEntry,i=t.loaderHook;globalLoading[a]=l.emit({loaderHook:i,remoteInfo:r,remoteEntryExports:n}).then(c=>c||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:r,remoteEntryExports:n,loaderHook:i,getEntryUrl:s}):loadEntryNode({remoteInfo:r,loaderHook:i})))}return globalLoading[a]}function getRemoteInfo(o){return _extends$1({},o,{entry:"entry"in o?o.entry:"",type:o.type||DEFAULT_REMOTE_TYPE,entryGlobalName:o.entryGlobalName||o.name,shareScope:o.shareScope||DEFAULT_SCOPE})}function defaultPreloadArgs(o){return _extends$1({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},o)}function formatPreloadArgs(o,t){return t.map(n=>{const r=matchRemote(o,n.nameOrAlias);return assert(r,`Unable to preload ${n.nameOrAlias} as it is not included in ${!r&&safeToString({remoteInfo:r,remotes:o})}`),{remote:r,preloadConfig:defaultPreloadArgs(n)}})}function normalizePreloadExposes(o){return o?o.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(o,t,n,r=!0){const{cssAssets:s,jsAssetsWithoutEntry:a,entryAssets:l}=n;if(t.options.inBrowser){if(l.forEach(i=>{const{moduleInfo:c}=i,u=t.moduleCache.get(o.name);getRemoteEntry(u?{origin:t,remoteInfo:c,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:c,remoteEntryExports:void 0})}),r){const i={rel:"preload",as:"style"};s.forEach(c=>{const{link:u,needAttach:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(c=>{const{link:u,needAttach:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});h&&document.head.appendChild(u)})}if(r){const i={rel:"preload",as:"script"};a.forEach(c=>{const{link:u,needAttach:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={fetchpriority:"high",type:(o==null?void 0:o.type)==="module"?"module":"text/javascript"};a.forEach(c=>{const{script:u,needAttach:h}=createScript({url:c,cb:()=>{},attrs:i,createScriptHook:(d,p)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:d,attrs:p});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});h&&document.head.appendChild(u)})}}}let Module=class{async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let t;try{t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports})}catch(n){const r=getRemoteEntryUniqueKey(this.remoteInfo);n instanceof Error&&n.message.includes(RUNTIME_008)&&(t=await this.host.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry,origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports,globalLoading,uniqueKey:r}))}return assert(t,`remoteEntryExports is undefined
5
- ${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,n,r,s){const{loadFactory:a=!0}=r||{loadFactory:!0},l=await this.getEntry();if(!this.inited){const d=this.host.shareScopeMap,p=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];p.length||p.push("default"),p.forEach(g=>{d[g]||(d[g]={})});const m=d[p[0]],_=[],E={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?p:this.remoteInfo.shareScope||"default"};Object.defineProperty(E,"shareScopeMap",{value:d,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:E,initScope:_,remoteInfo:this.remoteInfo,origin:this.host});typeof(l==null?void 0:l.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await l.init(y.shareScope,y.initScope,y.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit(_extends$1({},y,{id:t,remoteSnapshot:s,remoteEntryExports:l}))}this.lib=l,this.inited=!0;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:l,expose:n,moduleInfo:this.remoteInfo}),i||(i=await l.get(n)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${n}.`);const c=processModuleAlias(this.remoteInfo.name,n),u=this.wraperFactory(i,c);return a?await u():u}wraperFactory(t,n){function r(s,a){s&&typeof s=="object"&&Object.isExtensible(s)&&!Object.getOwnPropertyDescriptor(s,Symbol.for("mf_module_id"))&&Object.defineProperty(s,Symbol.for("mf_module_id"),{value:a,enumerable:!1})}return t instanceof Promise?async()=>{const s=await t();return r(s,n),s}:()=>{const s=t();return r(s,n),s}}constructor({remoteInfo:t,host:n}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=n}};class SyncHook{on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const n=this;this.on(function r(...s){return n.remove(r),t.apply(null,s)})}emit(...t){let n;return this.listeners.size>0&&this.listeners.forEach(r=>{n=r(...t)}),n}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}}class AsyncHook extends SyncHook{emit(...t){let n;const r=Array.from(this.listeners);if(r.length>0){let s=0;const a=l=>l===!1?!1:s<r.length?Promise.resolve(r[s++].apply(null,t)).then(a):l;n=a()}return Promise.resolve(n)}}function checkReturnData(o,t){if(!isObject(t))return!1;if(o!==t){for(const n in o)if(!(n in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const n of this.listeners)try{const r=n(t);if(checkReturnData(t,r))t=r;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(r){warn(r),this.onerror(r)}return t}constructor(t){super(),this.onerror=error,this.type=t}}class AsyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const n=Array.from(this.listeners);if(n.length>0){let r=0;const s=l=>(warn(l),this.onerror(l),t),a=l=>{if(checkReturnData(t,l)){if(t=l,r<n.length)try{return Promise.resolve(n[r++](t)).then(a,s)}catch(i){return s(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return t};return Promise.resolve(a(t))}return Promise.resolve(t)}constructor(t){super(),this.onerror=error,this.type=t}}class PluginSystem{applyPlugin(t,n){assert(isPlainObject(t),"Plugin configuration is invalid.");const r=t.name;assert(r,"A name must be provided by the plugin."),this.registerPlugins[r]||(this.registerPlugins[r]=t,t.apply==null||t.apply.call(t,n),Object.keys(this.lifecycle).forEach(s=>{const a=t[s];a&&this.lifecycle[s].on(a)}))}removePlugin(t){assert(t,"A name is required.");const n=this.registerPlugins[t];assert(n,`The plugin "${t}" is not registered.`),Object.keys(n).forEach(r=>{r!=="name"&&this.lifecycle[r].remove(n[r])})}constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}}function assignRemoteInfo(o,t){const n=getRemoteEntryInfoFromSnapshot(t);n.url||error(`The attribute remoteEntry of ${o.name} must not be undefined.`);let r=getResourceUrl(t,n.url);!isBrowserEnv()&&!r.startsWith("http")&&(r=`https:${r}`),o.type=n.type,o.entryGlobalName=n.globalName,o.entry=r,o.version=t.version,o.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(o){const{remote:t,pkgNameOrAlias:n,expose:r,origin:s,remoteInfo:a,id:l}=o;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:i,globalSnapshot:c}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:l});assignRemoteInfo(a,i);const u={remote:t,preloadConfig:{nameOrAlias:n,exposes:[r],resourceCategory:"sync",share:!1,depsRemote:!1}},h=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:u,remoteInfo:a,remote:t,remoteSnapshot:i,globalSnapshot:c});return h&&preloadAssets(a,s,h,!1),_extends$1({},o,{remoteSnapshot:i})}return o}}}function splitId(o){const t=o.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function traverseModuleInfo(o,t,n,r,s={},a){const l=getFMId(t),{value:i}=getInfoWithoutType(o,l),c=a||i;if(c&&!isManifestProvider(c)&&(n(c,t,r),c.remotesInfo)){const u=Object.keys(c.remotesInfo);for(const h of u){if(s[h])continue;s[h]=!0;const d=splitId(h),p=c.remotesInfo[h];traverseModuleInfo(o,{name:d.name,version:p.matchedVersion},n,!1,s,void 0)}}}const isExisted=(o,t)=>document.querySelector(`${o}[${o==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(o,t,n,r,s){const a=[],l=[],i=[],c=new Set,u=new Set,{options:h}=o,{preloadConfig:d}=t,{depsRemote:p}=d;if(traverseModuleInfo(r,n,(y,g,I)=>{let S;if(I)S=d;else if(Array.isArray(p)){const N=p.find(T=>T.nameOrAlias===g.name||T.nameOrAlias===g.alias);if(!N)return;S=defaultPreloadArgs(N)}else if(p===!0)S=d;else return;const R=getResourceUrl(y,getRemoteEntryInfoFromSnapshot(y).url);R&&i.push({name:g.name,moduleInfo:{name:g.name,entry:R,type:"remoteEntryType"in y?y.remoteEntryType:"global",entryGlobalName:"globalName"in y?y.globalName:g.name,shareScope:"",version:"version"in y?y.version:void 0},url:R});let b="modules"in y?y.modules:[];const v=normalizePreloadExposes(S.exposes);if(v.length&&"modules"in y){var $;b=y==null||($=y.modules)==null?void 0:$.reduce((N,T)=>((v==null?void 0:v.indexOf(T.moduleName))!==-1&&N.push(T),N),[])}function A(N){const T=N.map(O=>getResourceUrl(y,O));return S.filter?T.filter(S.filter):T}if(b){const N=b.length;for(let T=0;T<N;T++){const O=b[T],w=`${g.name}/${O.moduleName}`;o.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:O.moduleName==="."?g.name:w,name:g.name,remoteSnapshot:y,preloadConfig:S,remote:g,origin:o}),!getPreloaded(w)&&(S.resourceCategory==="all"?(a.push(...A(O.assets.css.async)),a.push(...A(O.assets.css.sync)),l.push(...A(O.assets.js.async)),l.push(...A(O.assets.js.sync))):(S.resourceCategory="sync")&&(a.push(...A(O.assets.css.sync)),l.push(...A(O.assets.js.sync))),setPreloaded(w))}}},!0,{},s),s.shared&&s.shared.length>0){const y=(g,I)=>{const S=getRegisteredShare(o.shareScopeMap,I.sharedName,g,o.sharedHandler.hooks.lifecycle.resolveShare);S&&typeof S.lib=="function"&&(I.assets.js.sync.forEach(R=>{c.add(R)}),I.assets.css.sync.forEach(R=>{u.add(R)}))};s.shared.forEach(g=>{var I;const S=(I=h.shared)==null?void 0:I[g.sharedName];if(!S)return;const R=g.version?S.find(v=>v.version===g.version):S;if(!R)return;arrayOptions(R).forEach(v=>{y(v,g)})})}const _=l.filter(y=>!c.has(y)&&!isExisted("script",y));return{cssAssets:a.filter(y=>!u.has(y)&&!isExisted("link",y)),jsAssetsWithoutEntry:_,entryAssets:i.filter(y=>!isExisted("script",y.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(o){const{origin:t,preloadOptions:n,remoteInfo:r,remote:s,globalSnapshot:a,remoteSnapshot:l}=o;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:r.name,entry:s.entry,type:r.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(r,l),generatePreloadAssets(t,n,r,a,l)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(o,t){const n=getGlobalSnapshotInfoByModuleInfo({name:t.name,version:t.options.version}),r=n&&"remotesInfo"in n&&n.remotesInfo&&getInfoWithoutType(n.remotesInfo,o.name).value;return r&&r.matchedVersion?{hostGlobalSnapshot:n,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:o.name,version:r.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:o.name,version:"version"in o?o.version:void 0})}}class SnapshotHandler{async loadRemoteSnapshotInfo({moduleInfo:t,id:n,expose:r}){const{options:s}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:s,moduleInfo:t});let a=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});a||(a={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:a})),a&&"remotesInfo"in a&&!getInfoWithoutType(a.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(a.remotesInfo=_extends$1({},a==null?void 0:a.remotesInfo,{[t.name]:{matchedVersion:"version"in t?t.version:t.entry}}));const{hostGlobalSnapshot:l,remoteSnapshot:i,globalSnapshot:c}=this.getGlobalRemoteInfo(t),{remoteSnapshot:u,globalSnapshot:h}=await this.hooks.lifecycle.loadSnapshot.emit({options:s,moduleInfo:t,hostGlobalSnapshot:l,remoteSnapshot:i,globalSnapshot:c});let d,p;if(u)if(isManifestProvider(u)){const m=isBrowserEnv()?u.remoteEntry:u.ssrRemoteEntry||u.remoteEntry||"",_=await this.getManifestJson(m,t,{}),E=setGlobalSnapshotInfoByModuleInfo(_extends$1({},t,{entry:m}),_);d=_,p=E}else{const{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:u,from:"global"});d=m,p=h}else if(isRemoteInfoWithEntry(t)){const m=await this.getManifestJson(t.entry,t,{}),_=setGlobalSnapshotInfoByModuleInfo(t,m),{remoteSnapshot:E}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:m,from:"global"});d=E,p=_}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(h)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:n,host:this.HostInstance,options:s,moduleInfo:t,remoteSnapshot:d}),{remoteSnapshot:d,globalSnapshot:p}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,n,r){const s=async()=>{let l=this.manifestCache.get(t);if(l)return l;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});(!i||!(i instanceof Response))&&(i=await fetch(t,{})),l=await i.json()}catch(i){l=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),l||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:n.name,hostName:this.HostInstance.options.name},`${i}`)))}return assert(l.metaData&&l.exposes&&l.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,l),l},a=async()=>{const l=await s(),i=generateSnapshotFromManifest(l,{version:t}),{remoteSnapshot:c}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:n,manifestJson:l,remoteSnapshot:i,manifestUrl:t,from:"manifest"});return c};return this.manifestLoading[t]||(this.manifestLoading[t]=a().then(l=>l)),this.manifestLoading[t]}constructor(t){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=t,this.loaderHook=t.loaderHook}}class SharedHandler{registerShared(t,n){const{shareInfos:r,shared:s}=formatShareConfigs(t,n);return Object.keys(r).forEach(l=>{r[l].forEach(c=>{!getRegisteredShare(this.shareScopeMap,l,c,this.hooks.lifecycle.resolveShare)&&c&&c.lib&&this.setShared({pkgName:l,lib:c.lib,get:c.get,loaded:!0,shared:c,from:n.name})})}),{shareInfos:r,shared:s}}async loadShare(t,n){const{host:r}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:r.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const a=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:r.options.shared,origin:r}),{shareInfo:l}=a;assert(l,`Cannot find ${t} Share in the ${r.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare),c=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,r.options.name)};if(i&&i.lib)return c(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),c(i),u}else if(i){const h=(async()=>{const d=await i.get();return c(i),i.loaded=!0,i.lib=d,d})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:r.options.name,lib:null,loading:h}),h}else{if(n!=null&&n.customShareInfo)return!1;const h=(async()=>{const d=await l.get();l.lib=d,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=d,p.loaded=!0,p.from=l.from),d})();return this.setShared({pkgName:t,loaded:!1,shared:l,from:r.options.name,lib:null,loading:h}),h}}initializeSharing(t=DEFAULT_SCOPE,n){const{host:r}=this,s=n==null?void 0:n.from,a=n==null?void 0:n.strategy;let l=n==null?void 0:n.initScope;const i=[];if(s!=="build"){const{initTokens:_}=this;l||(l=[]);let E=_[t];if(E||(E=_[t]={from:this.host.name}),l.indexOf(E)>=0)return i;l.push(E)}const c=this.shareScopeMap,u=r.options.name;c[t]||(c[t]={});const h=c[t],d=(_,E)=>{var y;const{version:g,eager:I}=E;h[_]=h[_]||{};const S=h[_],R=S[g],b=!!(R&&(R.eager||(y=R.shareConfig)!=null&&y.eager));(!R||R.strategy!=="loaded-first"&&!R.loaded&&(!I!=!b?I:u>R.from))&&(S[g]=E)},p=_=>_&&_.init&&_.init(c[t],l),m=async _=>{const{module:E}=await r.remoteHandler.getRemoteModuleAndOptions({id:_});if(E.getEntry){let y;try{y=await E.getEntry()}catch(g){y=await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:_,error:g,from:"runtime",lifecycle:"beforeLoadShare",origin:r})}E.inited||(await p(y),E.inited=!0)}};return Object.keys(r.options.shared).forEach(_=>{r.options.shared[_].forEach(y=>{y.scope.includes(t)&&d(_,y)})}),(r.options.shareStrategy==="version-first"||a==="version-first")&&r.options.remotes.forEach(_=>{_.shareScope===t&&i.push(m(_.name))}),i}loadShareSync(t,n){const{host:r}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:r.options.shared});s!=null&&s.scope&&s.scope.forEach(i=>{this.initializeSharing(i,{strategy:s.strategy})});const a=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),l=i=>{i.useIn||(i.useIn=[]),addUniqueItem(i.useIn,r.options.name)};if(a){if(typeof a.lib=="function")return l(a),a.loaded||(a.loaded=!0,a.from===r.options.name&&(s.loaded=!0)),a.lib;if(typeof a.get=="function"){const i=a.get();if(!(i instanceof Promise))return l(a),this.setShared({pkgName:t,loaded:!0,from:r.options.name,lib:i,shared:a}),i}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const i=s.get();if(i instanceof Promise){const c=(n==null?void 0:n.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(c,runtimeDescMap,{hostName:r.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:r.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:r.options.name,sharedPkgName:t}))}initShareScopeMap(t,n,r={}){const{host:s}=this;this.shareScopeMap[t]=n,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:n,options:s.options,origin:s,scopeName:t,hostShareScopeMap:r.hostShareScopeMap})}setShared({pkgName:t,shared:n,from:r,lib:s,loading:a,loaded:l,get:i}){const{version:c,scope:u="default"}=n,h=_object_without_properties_loose(n,["version","scope"]);(Array.isArray(u)?u:[u]).forEach(p=>{if(this.shareScopeMap[p]||(this.shareScopeMap[p]={}),this.shareScopeMap[p][t]||(this.shareScopeMap[p][t]={}),!this.shareScopeMap[p][t][c]){this.shareScopeMap[p][t][c]=_extends$1({version:c,scope:["default"]},h,{lib:s,loaded:l,loading:a}),i&&(this.shareScopeMap[p][t][c].get=i);return}const m=this.shareScopeMap[p][t][c];a&&!m.loading&&(m.loading=a),l&&!m.loaded&&(m.loaded=l),r&&m.from!==r&&(m.from=r)})}_setGlobalShareScopeMap(t){const n=getGlobalShareScope(),r=t.id||t.name;r&&!n[r]&&(n[r]=this.shareScopeMap)}constructor(t){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=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}}class RemoteHandler{formatAndRegisterRemote(t,n){return(n.remotes||[]).reduce((s,a)=>(this.registerRemote(a,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,n){const{remote:r,expose:s}=n,{name:a,alias:l}=r;if(this.idToRemoteMap[t]={name:r.name,expose:s},l&&t.startsWith(a)){const i=t.replace(a,l);this.idToRemoteMap[i]={name:r.name,expose:s};return}if(l&&t.startsWith(l)){const i=t.replace(l,a);this.idToRemoteMap[i]={name:r.name,expose:s}}}async loadRemote(t,n){const{host:r}=this;try{const{loadFactory:s=!0}=n||{loadFactory:!0},{module:a,moduleOptions:l,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:c,remote:u,expose:h,id:d,remoteSnapshot:p}=i,m=await a.get(d,h,n,p),_=await this.hooks.lifecycle.onLoad.emit({id:d,pkgNameOrAlias:c,expose:h,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:l,moduleInstance:a,origin:r});return this.setIdToRemoteMap(t,i),typeof _=="function"?_:m}catch(s){const{from:a="runtime"}=n||{from:"runtime"},l=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:a,lifecycle:"onLoad",origin:r});if(!l)throw s;return l}}async preloadRemote(t){const{host:n}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:n.options,origin:n});const r=formatPreloadArgs(n.options.remotes,t);await Promise.all(r.map(async s=>{const{remote:a}=s,l=getRemoteInfo(a),{globalSnapshot:i,remoteSnapshot:c}=await n.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:a}),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:n,preloadOptions:s,remote:a,remoteInfo:l,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(l,n,u)}))}registerRemotes(t,n){const{host:r}=this;t.forEach(s=>{this.registerRemote(s,r.options.remotes,{force:n==null?void 0:n.force})})}async getRemoteModuleAndOptions(t){const{host:n}=this,{id:r}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:r,options:n.options,origin:n})}catch(_){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:r,options:n.options,origin:n,from:"runtime",error:_,lifecycle:"beforeRequest"}),!s)throw _}const{id:a}=s,l=matchRemoteWithNameAndExpose(n.options.remotes,a);assert(l,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:n.options.name,requestId:a}));const{remote:i}=l,c=getRemoteInfo(i),u=await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:a},l,{options:n.options,origin:n,remoteInfo:c})),{remote:h,expose:d}=u;assert(h&&d,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);let p=n.moduleCache.get(h.name);const m={host:n,remoteInfo:c};return p||(p=new Module(m),n.moduleCache.set(h.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,n,r){const{host:s}=this,a=()=>{if(t.alias){const i=n.find(c=>{var u;return t.alias&&(c.name.startsWith(t.alias)||((u=c.alias)==null?void 0:u.startsWith(t.alias)))});assert(!i,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const l=n.find(i=>i.name===t.name);if(!l)a(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];r!=null&&r.force&&(this.removeRemote(l),a(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){try{const{host:r}=this,{name:s}=t,a=r.options.remotes.findIndex(i=>i.name===s);a!==-1&&r.options.remotes.splice(a,1);const l=r.moduleCache.get(t.name);if(l){const i=l.remoteInfo,c=i.entryGlobalName;if(CurrentGlobal[c]){var n;(n=Object.getOwnPropertyDescriptor(CurrentGlobal,c))!=null&&n.configurable?delete CurrentGlobal[c]:CurrentGlobal[c]=void 0}const u=getRemoteEntryUniqueKey(l.remoteInfo);globalLoading[u]&&delete globalLoading[u],r.snapshotHandler.manifestCache.delete(i.entry);let h=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const d=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===h:m.name===h);if(d!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[d];h=m.options.id||h;const _=getGlobalShareScope();let E=!0;const y=[];Object.keys(_).forEach(g=>{const I=_[g];I&&Object.keys(I).forEach(S=>{const R=I[S];R&&Object.keys(R).forEach(b=>{const v=R[b];v&&Object.keys(v).forEach($=>{const A=v[$];A&&typeof A=="object"&&A.from===i.name&&(A.loaded||A.loading?(A.useIn=A.useIn.filter(N=>N!==i.name),A.useIn.length?E=!1:y.push([g,S,b,$])):y.push([g,S,b,$]))})})})}),E&&(m.shareScopeMap={},delete _[h]),y.forEach(([g,I,S,R])=>{var b,v,$;($=_[g])==null||(v=$[I])==null||(b=v[S])==null||delete b[R]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(d,1)}const{hostGlobalSnapshot:p}=getGlobalRemoteInfo(t,r);if(p){const m=p&&"remotesInfo"in p&&p.remotesInfo&&getInfoWithoutType(p.remotesInfo,t.name).key;m&&(delete p.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}r.moduleCache.delete(t.name)}}catch(r){logger.log("removeRemote fail: ",r)}}constructor(t){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=t,this.idToRemoteMap={}}}const USE_SNAPSHOT=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;class ModuleFederation{initOptions(t){this.registerPlugins(t.plugins);const n=this.formatOptions(this.options,t);return this.options=n,n}async loadShare(t,n){return this.sharedHandler.loadShare(t,n)}loadShareSync(t,n){return this.sharedHandler.loadShareSync(t,n)}initializeSharing(t=DEFAULT_SCOPE,n){return this.sharedHandler.initializeSharing(t,n)}initRawContainer(t,n,r){const s=getRemoteInfo({name:t,entry:n}),a=new Module({host:this,remoteInfo:s});return a.remoteEntryExports=r,this.moduleCache.set(t,a),a}async loadRemote(t,n){return this.remoteHandler.loadRemote(t,n)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,n,r={}){this.sharedHandler.initShareScopeMap(t,n,r)}formatOptions(t,n){const{shared:r}=formatShareConfigs(t,n),{userOptions:s,options:a}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:n,options:t,shareInfo:r}),l=this.remoteHandler.formatAndRegisterRemote(a,s),{shared:i}=this.sharedHandler.registerShared(a,s),c=[...a.plugins];s.plugins&&s.plugins.forEach(h=>{c.includes(h)||c.push(h)});const u=_extends$1({},t,n,{plugins:c,remotes:l,shared:i});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const n=registerPlugins(t,this);this.options.plugins=this.options.plugins.reduce((r,s)=>(s&&r&&!r.find(a=>a.name===s.name)&&r.push(s),r),n||[])}registerRemotes(t,n){return this.remoteHandler.registerRemotes(t,n)}registerShared(t){this.sharedHandler.registerShared(this.options,_extends$1({},this.options,{shared:t}))}constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.19.0",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const n=USE_SNAPSHOT?[snapshotPlugin(),generatePreloadAssetsPlugin()]:[],r={id:getBuilderId(),name:t.name,plugins:n,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=r,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...r.plugins,...t.plugins||[]]),this.options=this.formatOptions(r,t)}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(ModuleFederation);function createBridgeComponent(o){const t=new Map,n=getInstance();return()=>({__APP_VERSION__:"0.19.0",async render(r){var _,E,y;LoggerInstance.debug("createBridgeComponent render Info",r);const{moduleName:s,dom:a,basename:l,memoryRoute:i,hashRoute:c,...u}=r,h=Vue__namespace.createApp(o.rootComponent,u);t.set(a,h);const d=await((y=(E=(_=n==null?void 0:n.bridgeHook)==null?void 0:_.lifecycle)==null?void 0:E.beforeBridgeRender)==null?void 0:y.emit(r)),p=d&&typeof d=="object"&&(d!=null&&d.extraProps)?d==null?void 0:d.extraProps:{},m=o.appOptions({app:h,basename:l,memoryRoute:i,hashRoute:c,...u,...p});if(m!=null&&m.router){let g,I=m.router.getRoutes();r.memoryRoute?g=VueRouter__namespace.createMemoryHistory(r.basename):r.hashRoute?(g=VueRouter__namespace.createWebHashHistory(),I=I.map(R=>({...R,path:r.basename+R.path}))):g=VueRouter__namespace.createWebHistory(r.basename);const S=VueRouter__namespace.createRouter({...m.router.options,history:g,routes:I});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:S}),i&&await S.push(i.entryPath),h.use(S)}h.mount(a)},destroy(r){LoggerInstance.debug("createBridgeComponent destroy Info",r);const s=t.get(r==null?void 0:r.dom);s==null||s.unmount()}})}function e(){const o=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(o)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(o){const t=Vue.ref(null),n=Vue.ref(null),r=Vue.ref(""),s=VueRouter.useRoute(),a=getInstance(),l=Vue.useAttrs(),i=async()=>{var p,m,_,E;const u=(p=o.providerInfo)==null?void 0:p.call(o);n.value=u;let h={...l,moduleName:o.moduleName,dom:t.value,basename:o.basename,memoryRoute:o.memoryRoute,hashRoute:o.hashRoute};LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",h);const d=await((E=(_=(m=a==null?void 0:a.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:_.beforeBridgeRender)==null?void 0:E.emit(h))||{};h={...h,...d.extraProps},u.render(h)},c=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&i(),r.value!==""&&r.value!==u&&(LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...o,pathname:s.path}),e()),r.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>",{...o}),c(),(u=n.value)==null||u.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(o.rootAttrs||{},{ref:t}),null)}});function createRemoteAppComponent(o){return Vue.defineAsyncComponent({__APP_VERSION__:"0.19.0",...o.asyncComponentOptions,loader:async()=>{var c,u;const t=VueRouter.useRoute();let n="/";const r=(u=(c=t==null?void 0:t.matched)==null?void 0:c[0])==null?void 0:u.path;r&&(r.endsWith("/:pathMatch(.*)*")?n=r.replace("/:pathMatch(.*)*",""):n=t.matched[0].path);const s=(o==null?void 0:o.export)||"default";LoggerInstance.debug("createRemoteAppComponent LazyComponent create >>>",{basename:n,info:o});const a=await o.loader(),l=a&&a[Symbol.for("mf_module_id")],i=a[s];if(LoggerInstance.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:l,module:a,exportName:s,basename:n,route:t}),s in a&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:l,providerInfo:i,basename:n,rootAttrs:o.rootAttrs})}};throw new Error("module not found")}})}function createRemoteComponent(o){return LoggerInstance.warn("createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!"),createRemoteAppComponent(o)}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteAppComponent=createRemoteAppComponent;exports.createRemoteComponent=createRemoteComponent;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vue=require("vue"),VueRouter=require("vue-router");function _interopNamespaceDefault(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>r[o]})}}return t.default=r,Object.freeze(t)}const Vue__namespace=_interopNamespaceDefault(Vue),VueRouter__namespace=_interopNamespaceDefault(VueRouter),MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",SEPARATOR=":";function isBrowserEnv(){return typeof window<"u"&&typeof window.document<"u"}function isReactNativeEnv(){return typeof navigator<"u"&&(navigator==null?void 0:navigator.product)==="ReactNative"}function isBrowserDebug(){try{if(isBrowserEnv()&&window.localStorage)return!!localStorage.getItem(BROWSER_LOG_KEY)}catch{return!1}return!1}function isDebugMode(){return typeof process<"u"&&process.env&&process.env.FEDERATION_DEBUG?!!process.env.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&FEDERATION_DEBUG?!0:isBrowserDebug()}const LOG_CATEGORY$1="[ Federation Runtime ]",composeKeyWithSeparator=function(...r){return r.length?r.reduce((t,o)=>o?t?`${t}${SEPARATOR}${o}`:o:t,""):""},getResourceUrl=(r,t)=>{if("getPublicPath"in r){let o;return r.getPublicPath.startsWith("function")?o=new Function("return "+r.getPublicPath)()():o=new Function(r.getPublicPath)(),`${o}${t}`}else return"publicPath"in r?!isBrowserEnv()&&!isReactNativeEnv()&&"ssrPublicPath"in r?`${r.ssrPublicPath}${t}`:`${r.publicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",r,t),"")},warn$1=r=>{console.warn(`${LOG_CATEGORY$1}: ${r}`)};function safeToString(r){try{return JSON.stringify(r,null,2)}catch{return""}}const simpleJoinRemoteEntry=(r,t)=>{if(!r)return t;const n=(s=>{if(s===".")return"";if(s.startsWith("./"))return s.replace("./","");if(s.startsWith("/")){const i=s.slice(1);return i.endsWith("/")?i.slice(0,-1):i}return s})(r);return n?n.endsWith("/")?`${n}${t}`:`${n}/${t}`:t};function inferAutoPublicPath(r){return r.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(r,t={}){var S,R,A;const{remotes:o={},overrides:n={},version:s}=t;let i;const a=()=>"publicPath"in r.metaData?r.metaData.publicPath==="auto"&&s?inferAutoPublicPath(s):r.metaData.publicPath:r.metaData.getPublicPath,c=Object.keys(n);let l={};Object.keys(o).length||(l=((S=r.remotes)==null?void 0:S.reduce((_,I)=>{let T;const w=I.federationContainerName;return c.includes(w)?T=n[w]:"version"in I?T=I.version:T=I.entry,_[w]={matchedVersion:T},_},{}))||{}),Object.keys(o).forEach(_=>l[_]={matchedVersion:c.includes(_)?n[_]:o[_]});const{remoteEntry:{path:u,name:d,type:h},types:p,buildInfo:{buildVersion:m},globalName:E,ssrRemoteEntry:b}=r.metaData,{exposes:y}=r;let g={version:s||"",buildVersion:m,globalName:E,remoteEntry:simpleJoinRemoteEntry(u,d),remoteEntryType:h,remoteTypes:simpleJoinRemoteEntry(p.path,p.name),remoteTypesZip:p.zip||"",remoteTypesAPI:p.api||"",remotesInfo:l,shared:r==null?void 0:r.shared.map(_=>({assets:_.assets,sharedName:_.name,version:_.version})),modules:y==null?void 0:y.map(_=>({moduleName:_.name,modulePath:_.path,assets:_.assets}))};if((R=r.metaData)!=null&&R.prefetchInterface){const _=r.metaData.prefetchInterface;g={...g,prefetchInterface:_}}if((A=r.metaData)!=null&&A.prefetchEntry){const{path:_,name:I,type:T}=r.metaData.prefetchEntry;g={...g,prefetchEntry:simpleJoinRemoteEntry(_,I),prefetchEntryType:T}}if("publicPath"in r.metaData?i={...g,publicPath:a(),ssrPublicPath:r.metaData.ssrPublicPath}:i={...g,getPublicPath:a()},b){const _=simpleJoinRemoteEntry(b.path,b.name);i.ssrRemoteEntry=_,i.ssrRemoteEntryType=b.type||"commonjs-module"}return i}function isManifestProvider(r){return!!("remoteEntry"in r&&r.remoteEntry.includes(MANIFEST_EXT))}const PREFIX="[ Module Federation ]",DEFAULT_DELEGATE=console;class Logger{constructor(t,o=DEFAULT_DELEGATE){this.prefix=t,this.delegate=o??DEFAULT_DELEGATE}setPrefix(t){this.prefix=t}setDelegate(t){this.delegate=t??DEFAULT_DELEGATE}emit(t,o){const n=this.delegate,s=(()=>{switch(t){case"log":return["log","info"];case"info":return["info","log"];case"warn":return["warn","info","log"];case"error":return["error","warn","log"];case"debug":default:return["debug","log"]}})();for(const i of s){const a=n[i];if(typeof a=="function"){a.call(n,this.prefix,...o);return}}for(const i of s){const a=DEFAULT_DELEGATE[i];if(typeof a=="function"){a.call(DEFAULT_DELEGATE,this.prefix,...o);return}}}log(...t){this.emit("log",t)}warn(...t){this.emit("warn",t)}error(...t){this.emit("error",t)}success(...t){this.emit("info",t)}info(...t){this.emit("info",t)}ready(...t){this.emit("info",t)}debug(...t){isDebugMode()&&this.emit("debug",t)}}function createLogger(r){return new Logger(r)}function createInfrastructureLogger(r){const t=new Logger(r);return Object.defineProperty(t,"__mf_infrastructure_logger__",{value:!0,enumerable:!1,configurable:!1}),t}createInfrastructureLogger(PREFIX);async function safeWrapper(r,t){try{return await r()}catch(o){warn$1(o);return}}function isStaticResourcesEqual(r,t){const o=/^(https?:)?\/\//i,n=r.replace(o,"").replace(/\/$/,""),s=t.replace(o,"").replace(/\/$/,"");return n===s}function createScript(r){let t=null,o=!0,n=2e4,s;const i=document.getElementsByTagName("script");for(let c=0;c<i.length;c++){const l=i[c],u=l.getAttribute("src");if(u&&isStaticResourcesEqual(u,r.url)){t=l,o=!1;break}}if(!t){const c=r.attrs;t=document.createElement("script"),t.type=(c==null?void 0:c.type)==="module"?"module":"text/javascript";let l;r.createScriptHook&&(l=r.createScriptHook(r.url,r.attrs),l instanceof HTMLScriptElement?t=l:typeof l=="object"&&("script"in l&&l.script&&(t=l.script),"timeout"in l&&l.timeout&&(n=l.timeout))),t.src||(t.src=r.url),c&&!l&&Object.keys(c).forEach(u=>{t&&(u==="async"||u==="defer"?t[u]=c[u]:t.getAttribute(u)||t.setAttribute(u,c[u]))})}const a=async(c,l)=>{clearTimeout(s);const u=()=>{(l==null?void 0:l.type)==="error"?r!=null&&r.onErrorCallback&&(r==null||r.onErrorCallback(l)):r!=null&&r.cb&&(r==null||r.cb())};if(t&&(t.onerror=null,t.onload=null,safeWrapper(()=>{const{needDeleteScript:d=!0}=r;d&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),c&&typeof c=="function")){const d=c(l);if(d instanceof Promise){const h=await d;return u(),h}return u(),d}u()};return t.onerror=a.bind(null,t.onerror),t.onload=a.bind(null,t.onload),s=setTimeout(()=>{a(null,new Error(`Remote script "${r.url}" time-outed.`))},n),{script:t,needAttach:o}}function createLink(r){let t=null,o=!0;const n=document.getElementsByTagName("link");for(let i=0;i<n.length;i++){const a=n[i],c=a.getAttribute("href"),l=a.getAttribute("rel");if(c&&isStaticResourcesEqual(c,r.url)&&l===r.attrs.rel){t=a,o=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",r.url);let i;const a=r.attrs;r.createLinkHook&&(i=r.createLinkHook(r.url,a),i instanceof HTMLLinkElement&&(t=i)),a&&!i&&Object.keys(a).forEach(c=>{t&&!t.getAttribute(c)&&t.setAttribute(c,a[c])})}const s=(i,a)=>{const c=()=>{(a==null?void 0:a.type)==="error"?r!=null&&r.onErrorCallback&&(r==null||r.onErrorCallback(a)):r!=null&&r.cb&&(r==null||r.cb())};if(t&&(t.onerror=null,t.onload=null,safeWrapper(()=>{const{needDeleteLink:l=!0}=r;l&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),i)){const l=i(a);return c(),l}c()};return t.onerror=s.bind(null,t.onerror),t.onload=s.bind(null,t.onload),{link:t,needAttach:o}}function loadScript(r,t){const{attrs:o={},createScriptHook:n}=t;return new Promise((s,i)=>{const{script:a,needAttach:c}=createScript({url:r,cb:s,onErrorCallback:i,attrs:{fetchpriority:"high",...o},createScriptHook:n,needDeleteScript:!0});c&&document.head.appendChild(a)})}const sdkImportCache=new Map;function importNodeModule(r){if(!r)throw new Error("import specifier is required");if(sdkImportCache.has(r))return sdkImportCache.get(r);const o=new Function("name","return import(name)")(r).then(n=>n).catch(n=>{throw console.error(`Error importing module ${r}:`,n),sdkImportCache.delete(r),n});return sdkImportCache.set(r,o),o}const loadNodeFetch=async()=>{const r=await importNodeModule("node-fetch");return r.default||r},lazyLoaderHookFetch=async(r,t,o)=>{const s=await((i,a)=>o.lifecycle.fetch.emit(i,a))(r,t||{});return!s||!(s instanceof Response)?(typeof fetch>"u"?await loadNodeFetch():fetch)(r,t||{}):s},createScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(url,cb,attrs,loaderHook)=>{if(loaderHook!=null&&loaderHook.createScriptHook){const r=loaderHook.createScriptHook(url);r&&typeof r=="object"&&"url"in r&&(url=r.url)}let urlObj;try{urlObj=new URL(url)}catch(r){console.error("Error constructing URL:",r),cb(new Error(`Invalid URL: ${r}`));return}const getFetch=async()=>loaderHook!=null&&loaderHook.fetch?(r,t)=>lazyLoaderHookFetch(r,t,loaderHook):typeof fetch>"u"?loadNodeFetch():fetch,handleScriptFetch=async(f,urlObj)=>{var r;try{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),script=new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}
2
+ })`,{filename,importModuleDynamically:((r=vm.constants)==null?void 0:r.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(async r=>{if((attrs==null?void 0:attrs.type)==="esm"||(attrs==null?void 0:attrs.type)==="module")return loadModule(urlObj.href,{fetch:r,vm:await importNodeModule("vm")}).then(async t=>{await t.evaluate(),cb(void 0,t.namespace)}).catch(t=>{cb(t instanceof Error?t:new Error(`Script execution error: ${t}`))});handleScriptFetch(r,urlObj)}).catch(r=>{cb(r)})}:(r,t,o,n)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},loadScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(r,t)=>new Promise((o,n)=>{createScriptNode(r,(s,i)=>{var a,c;if(s)n(s);else{const l=((a=t==null?void 0:t.attrs)==null?void 0:a.globalName)||`__FEDERATION_${(c=t==null?void 0:t.attrs)==null?void 0:c.name}:custom__`,u=globalThis[l]=i;o(u)}},t.attrs,t.loaderHook)}):(r,t)=>{throw new Error("loadScriptNode is disabled in non-Node.js environment")},esmModuleCache=new Map;async function loadModule(r,t){if(esmModuleCache.has(r))return esmModuleCache.get(r);const{fetch:o,vm:n}=t,i=await(await o(r)).text(),a=new n.SourceTextModule(i,{importModuleDynamically:async(c,l)=>{const u=new URL(c,r).href;return loadModule(u,t)}});return esmModuleCache.set(r,a),await a.link(async c=>{const l=new URL(c,r).href;return await loadModule(l,t)}),a}const LoggerInstance=createLogger("[ Module Federation Bridge Vue3 ]"),RUNTIME_001="RUNTIME-001",RUNTIME_002="RUNTIME-002",RUNTIME_003="RUNTIME-003",RUNTIME_004="RUNTIME-004",RUNTIME_005="RUNTIME-005",RUNTIME_006="RUNTIME-006",RUNTIME_007="RUNTIME-007",RUNTIME_008="RUNTIME-008",RUNTIME_009="RUNTIME-009",getDocsUrl=r=>`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${r.split("-")[0].toLowerCase()}/${r}`,getShortErrorMsg=(r,t,o,n)=>{const s=[`${[t[r]]} #${r}`];return o&&s.push(`args: ${JSON.stringify(o)}`),s.push(getDocsUrl(r)),n&&s.push(`Original Error Message:
3
+ ${n}`),s.join(`
4
+ `)},runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot.",[RUNTIME_008]:"Failed to load script resources.",[RUNTIME_009]:"Please call createInstance first."},LOG_CATEGORY="[ Federation Runtime ]",logger=createLogger(LOG_CATEGORY);function assert(r,t){r||error(t)}function error(r){throw r instanceof Error?(r.message.startsWith(LOG_CATEGORY)||(r.message=`${LOG_CATEGORY}: ${r.message}`),r):new Error(`${LOG_CATEGORY}: ${r}`)}function warn(r){r instanceof Error&&(r.message.startsWith(LOG_CATEGORY)||(r.message=`${LOG_CATEGORY}: ${r.message}`)),logger.warn(r)}function addUniqueItem(r,t){return r.findIndex(o=>o===t)===-1&&r.push(t),r}function getFMId(r){return"version"in r&&r.version?`${r.name}:${r.version}`:"entry"in r&&r.entry?`${r.name}:${r.entry}`:`${r.name}`}function isRemoteInfoWithEntry(r){return typeof r.entry<"u"}function isPureRemoteEntry(r){return!r.entry.includes(".json")}function isObject(r){return r&&typeof r=="object"}const objectToString=Object.prototype.toString;function isPlainObject(r){return objectToString.call(r)==="[object Object]"}function arrayOptions(r){return Array.isArray(r)?r:[r]}function getRemoteEntryInfoFromSnapshot(r){const t={url:"",type:"global",globalName:""};return isBrowserEnv()||isReactNativeEnv()?"remoteEntry"in r?{url:r.remoteEntry,type:r.remoteEntryType,globalName:r.globalName}:t:"ssrRemoteEntry"in r?{url:r.ssrRemoteEntry||t.url,type:r.ssrRemoteEntryType||t.type,globalName:r.globalName}:t}const processModuleAlias=(r,t)=>{let o;return r.endsWith("/")?o=r.slice(0,-1):o=r,t.startsWith(".")&&(t=t.slice(1)),o=o+t,o},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(r,t,o){Object.defineProperty(r,t,{value:o,configurable:!1,writable:!0})}function includeOwnProperty(r,t){return Object.hasOwnProperty.call(r,t)}includeOwnProperty(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(r){var t,o,n,s,i,a;includeOwnProperty(r,"__VMOK__")&&!includeOwnProperty(r,"__FEDERATION__")&&definePropertyGlobalVal(r,"__FEDERATION__",r.__VMOK__),includeOwnProperty(r,"__FEDERATION__")||(definePropertyGlobalVal(r,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),definePropertyGlobalVal(r,"__VMOK__",r.__FEDERATION__)),(t=r.__FEDERATION__).__GLOBAL_PLUGIN__??(t.__GLOBAL_PLUGIN__=[]),(o=r.__FEDERATION__).__INSTANCES__??(o.__INSTANCES__=[]),(n=r.__FEDERATION__).moduleInfo??(n.moduleInfo={}),(s=r.__FEDERATION__).__SHARE__??(s.__SHARE__={}),(i=r.__FEDERATION__).__MANIFEST_LOADING__??(i.__MANIFEST_LOADING__={}),(a=r.__FEDERATION__).__PRELOADED_MAP__??(a.__PRELOADED_MAP__=new Map)}setGlobalDefaultVal(CurrentGlobal);setGlobalDefaultVal(nativeGlobal);function setGlobalFederationConstructor(r,t=isDebugMode()){t&&(CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__=r,CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="0.20.0")}function getInfoWithoutType(r,t){if(typeof t=="string"){if(r[t])return{value:r[t],key:t};{const n=Object.keys(r);for(const s of n){const[i,a]=s.split(":"),c=`${i}:${t}`,l=r[c];if(l)return{value:l,key:c}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(r,t)=>{const o=getFMId(r),n=getInfoWithoutType(t,o).value;if(n&&!n.version&&"version"in r&&r.version&&(n.version=r.version),n)return n;if("version"in r&&r.version){const{version:s,...i}=r,a=getFMId(i),c=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,a).value;if((c==null?void 0:c.version)===s)return c}},getGlobalSnapshotInfoByModuleInfo=r=>getTargetSnapshotInfoByModuleInfo(r,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(r,t)=>{const o=getFMId(r);return nativeGlobal.__FEDERATION__.moduleInfo[o]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=r=>(nativeGlobal.__FEDERATION__.moduleInfo={...nativeGlobal.__FEDERATION__.moduleInfo,...r},()=>{const t=Object.keys(r);for(const o of t)delete nativeGlobal.__FEDERATION__.moduleInfo[o]}),getRemoteEntryExports=(r,t)=>{const o=t||`__FEDERATION_${r}:custom__`,n=CurrentGlobal[o];return{remoteEntryKey:o,entryExports:n}},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=r=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(r),setPreloaded=r=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(r,!0),DEFAULT_SCOPE="default",DEFAULT_REMOTE_TYPE="global",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(r){return new RegExp(r)}function isXVersion(r){return!r||r.toLowerCase()==="x"||r==="*"}function pipe(...r){return t=>r.reduce((o,n)=>n(o),t)}function extractComparator(r){return r.match(parseRegex(comparator))}function combineVersion(r,t,o,n){const s=`${r}.${t}.${o}`;return n?`${s}-${n}`:s}function parseHyphen(r){return r.replace(parseRegex(hyphenRange),(t,o,n,s,i,a,c,l,u,d,h,p)=>(isXVersion(n)?o="":isXVersion(s)?o=`>=${n}.0.0`:isXVersion(i)?o=`>=${n}.${s}.0`:o=`>=${o}`,isXVersion(u)?l="":isXVersion(d)?l=`<${Number(u)+1}.0.0-0`:isXVersion(h)?l=`<${u}.${Number(d)+1}.0-0`:p?l=`<=${u}.${d}.${h}-${p}`:l=`<=${l}`,`${o} ${l}`.trim()))}function parseComparatorTrim(r){return r.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(r){return r.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(r){return r.replace(parseRegex(caretTrim),"$1^")}function parseCarets(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(caret),(o,n,s,i,a)=>isXVersion(n)?"":isXVersion(s)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:isXVersion(i)?n==="0"?`>=${n}.${s}.0 <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.0 <${Number(n)+1}.0.0-0`:a?n==="0"?s==="0"?`>=${n}.${s}.${i}-${a} <${n}.${s}.${Number(i)+1}-0`:`>=${n}.${s}.${i}-${a} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${i}-${a} <${Number(n)+1}.0.0-0`:n==="0"?s==="0"?`>=${n}.${s}.${i} <${n}.${s}.${Number(i)+1}-0`:`>=${n}.${s}.${i} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${i} <${Number(n)+1}.0.0-0`)).join(" ")}function parseTildes(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(o,n,s,i,a)=>isXVersion(n)?"":isXVersion(s)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:isXVersion(i)?`>=${n}.${s}.0 <${n}.${Number(s)+1}.0-0`:a?`>=${n}.${s}.${i}-${a} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${i} <${n}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(r){return r.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(o,n,s,i,a,c)=>{const l=isXVersion(s),u=l||isXVersion(i),d=u||isXVersion(a);return n==="="&&d&&(n=""),c="",l?n===">"||n==="<"?"<0.0.0-0":"*":n&&d?(u&&(i=0),a=0,n===">"?(n=">=",u?(s=Number(s)+1,i=0,a=0):(i=Number(i)+1,a=0)):n==="<="&&(n="<",u?s=Number(s)+1:i=Number(i)+1),n==="<"&&(c="-0"),`${n+s}.${i}.${a}${c}`):u?`>=${s}.0.0${c} <${Number(s)+1}.0.0-0`:d?`>=${s}.${i}.0${c} <${s}.${Number(i)+1}.0-0`:o})).join(" ")}function parseStar(r){return r.trim().replace(parseRegex(star),"")}function parseGTE0(r){return r.trim().replace(parseRegex(gte0),"")}function compareAtom(r,t){return r=Number(r)||r,t=Number(t)||t,r>t?1:r===t?0:-1}function comparePreRelease(r,t){const{preRelease:o}=r,{preRelease:n}=t;if(o===void 0&&n)return 1;if(o&&n===void 0)return-1;if(o===void 0&&n===void 0)return 0;for(let s=0,i=o.length;s<=i;s++){const a=o[s],c=n[s];if(a!==c)return a===void 0&&c===void 0?0:a?c?compareAtom(a,c):-1:1}return 0}function compareVersion(r,t){return compareAtom(r.major,t.major)||compareAtom(r.minor,t.minor)||compareAtom(r.patch,t.patch)||comparePreRelease(r,t)}function eq(r,t){return r.version===t.version}function compare(r,t){switch(r.operator){case"":case"=":return eq(r,t);case">":return compareVersion(r,t)<0;case">=":return eq(r,t)||compareVersion(r,t)<0;case"<":return compareVersion(r,t)>0;case"<=":return eq(r,t)||compareVersion(r,t)>0;case void 0:return!0;default:return!1}}function parseComparatorString(r){return pipe(parseCarets,parseTildes,parseXRanges,parseStar)(r)}function parseRange(r){return pipe(parseHyphen,parseComparatorTrim,parseTildeTrim,parseCaretTrim)(r.trim()).split(/\s+/).join(" ")}function satisfy(r,t){if(!r)return!1;const o=extractComparator(r);if(!o)return!1;const[,n,,s,i,a,c]=o,l={operator:n,version:combineVersion(s,i,a,c),major:s,minor:i,patch:a,preRelease:c==null?void 0:c.split(".")},u=t.split("||");for(const d of u){const h=d.trim();if(!h||h==="*"||h==="x")return!0;try{const p=parseRange(h);if(!p.trim())return!0;const m=p.split(" ").map(y=>parseComparatorString(y)).join(" ");if(!m.trim())return!0;const E=m.split(/\s+/).map(y=>parseGTE0(y)).filter(Boolean);if(E.length===0)continue;let b=!0;for(const y of E){const g=extractComparator(y);if(!g){b=!1;break}const[,S,,R,A,_,I]=g,T={operator:S,version:combineVersion(R,A,_,I),major:R,minor:A,patch:_,preRelease:I==null?void 0:I.split(".")};if(!compare(T,l)){b=!1;break}}if(b)return!0}catch(p){console.error(`[semver] Error processing range part "${h}":`,p);continue}}return!1}function formatShare(r,t,o,n){let s;return"get"in r?s=r.get:"lib"in r?s=()=>Promise.resolve(r.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${o}'!`)}),{deps:[],useIn:[],from:t,loading:null,...r,shareConfig:{requiredVersion:`^${r.version}`,singleton:!1,eager:!1,strictVersion:!1,...r.shareConfig},get:s,loaded:r!=null&&r.loaded||"lib"in r?!0:void 0,version:r.version??"0",scope:Array.isArray(r.scope)?r.scope:[r.scope??"default"],strategy:(r.strategy??n)||"version-first"}}function formatShareConfigs(r,t){const o=t.shared||{},n=t.name,s=Object.keys(o).reduce((a,c)=>{const l=arrayOptions(o[c]);return a[c]=a[c]||[],l.forEach(u=>{a[c].push(formatShare(u,n,c,t.shareStrategy))}),a},{}),i={...r.shared};return Object.keys(s).forEach(a=>{i[a]?s[a].forEach(c=>{i[a].find(u=>u.version===c.version)||i[a].push(c)}):i[a]=s[a]}),{shared:i,shareInfos:s}}function versionLt(r,t){const o=n=>{if(!Number.isNaN(Number(n))){const i=n.split(".");let a=n;for(let c=0;c<3-i.length;c++)a+=".0";return a}return n};return!!satisfy(o(r),`<=${o(t)}`)}const findVersion=(r,t)=>{const o=t||function(n,s){return versionLt(n,s)};return Object.keys(r).reduce((n,s)=>!n||o(n,s)||n==="0"?s:n,0)},isLoaded=r=>!!r.loaded||typeof r.lib=="function",isLoading=r=>!!r.loading;function findSingletonVersionOrderByVersion(r,t,o){const n=r[t][o],s=function(i,a){return!isLoaded(n[i])&&versionLt(i,a)};return findVersion(r[t][o],s)}function findSingletonVersionOrderByLoaded(r,t,o){const n=r[t][o],s=function(i,a){const c=l=>isLoaded(l)||isLoading(l);return c(n[a])?c(n[i])?!!versionLt(i,a):!0:c(n[i])?!1:versionLt(i,a)};return findVersion(r[t][o],s)}function getFindShareFunction(r){return r==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(r,t,o,n){if(!r)return;const{shareConfig:s,scope:i=DEFAULT_SCOPE,strategy:a}=o,c=Array.isArray(i)?i:[i];for(const l of c)if(s&&r[l]&&r[l][t]){const{requiredVersion:u}=s,h=getFindShareFunction(a)(r,l,t),p=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(h,u)){const b=`Version ${h} from ${h&&r[l][t][h].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;s.strictVersion?error(b):warn(b)}return r[l][t][h]}else{if(u===!1||u==="*"||satisfy(h,u))return r[l][t][h];for(const[b,y]of Object.entries(r[l][t]))if(satisfy(b,u))return y}},m={shareScopeMap:r,scope:l,pkgName:t,version:h,GlobalFederation:Global.__FEDERATION__,resolver:p};return(n.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(r){const{pkgName:t,extraOptions:o,shareInfos:n}=r,s=a=>{if(!a)return;const c={};a.forEach(d=>{c[d.version]=d});const u=findVersion(c,function(d,h){return!isLoaded(c[d])&&versionLt(d,h)});return c[u]},i=(o==null?void 0:o.resolver)??s;return Object.assign({},i(n[t]),o==null?void 0:o.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(r,t){for(const o of r){const n=t.startsWith(o.name);let s=t.replace(o.name,"");if(n){if(s.startsWith("/")){const c=o.name;return s=`.${s}`,{pkgNameOrAlias:c,expose:s,remote:o}}else if(s==="")return{pkgNameOrAlias:o.name,expose:".",remote:o}}const i=o.alias&&t.startsWith(o.alias);let a=o.alias&&t.replace(o.alias,"");if(o.alias&&i){if(a&&a.startsWith("/")){const c=o.alias;return a=`.${a}`,{pkgNameOrAlias:c,expose:a,remote:o}}else if(a==="")return{pkgNameOrAlias:o.alias,expose:".",remote:o}}}}function matchRemote(r,t){for(const o of r)if(t===o.name||o.alias&&t===o.alias)return o}function registerPlugins(r,t){const o=getGlobalHostPlugins(),n=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return o.length>0&&o.forEach(s=>{r!=null&&r.find(i=>i.name!==s.name)&&r.push(s)}),r&&r.length>0&&r.forEach(s=>{n.forEach(i=>{i.applyPlugin(s,t)})}),r}const importCallback=".then(callbacks[0]).catch(callbacks[1])";async function loadEsmEntry({entry:r,remoteEntryExports:t}){return new Promise((o,n)=>{try{t?o(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${r}")${importCallback}`)([o,n]):import(r).then(o).catch(n)}catch(s){n(s)}})}async function loadSystemJsEntry({entry:r,remoteEntryExports:t}){return new Promise((o,n)=>{try{t?o(t):typeof __system_context__>"u"?System.import(r).then(o).catch(n):new Function("callbacks",`System.import("${r}")${importCallback}`)([o,n])}catch(s){n(s)}})}function handleRemoteEntryLoaded(r,t,o){const{remoteEntryKey:n,entryExports:s}=getRemoteEntryExports(r,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:r,remoteEntryUrl:o,remoteEntryKey:n})),s}async function loadEntryScript({name:r,globalName:t,entry:o,loaderHook:n,getEntryUrl:s}){const{entryExports:i}=getRemoteEntryExports(r,t);if(i)return i;const a=s?s(o):o;return loadScript(a,{attrs:{},createScriptHook:(c,l)=>{const u=n.lifecycle.createScript.emit({url:c,attrs:l});if(u&&(u instanceof HTMLScriptElement||"script"in u||"timeout"in u))return u}}).then(()=>handleRemoteEntryLoaded(r,t,o)).catch(c=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:r,resourceUrl:o})),c})}async function loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:o,getEntryUrl:n}){const{entry:s,entryGlobalName:i,name:a,type:c}=r;switch(c){case"esm":case"module":return loadEsmEntry({entry:s,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:s,remoteEntryExports:t});default:return loadEntryScript({entry:s,globalName:i,name:a,loaderHook:o,getEntryUrl:n})}}async function loadEntryNode({remoteInfo:r,loaderHook:t}){const{entry:o,entryGlobalName:n,name:s,type:i}=r,{entryExports:a}=getRemoteEntryExports(s,n);return a||loadScriptNode(o,{attrs:{name:s,globalName:n,type:i},loaderHook:{createScriptHook:(c,l={})=>{const u=t.lifecycle.createScript.emit({url:c,attrs:l});if(u&&"url"in u)return u}}}).then(()=>handleRemoteEntryLoaded(s,n,o)).catch(c=>{throw c})}function getRemoteEntryUniqueKey(r){const{entry:t,name:o}=r;return composeKeyWithSeparator(o,t)}async function getRemoteEntry(r){const{origin:t,remoteEntryExports:o,remoteInfo:n,getEntryUrl:s,_inErrorHandling:i=!1}=r,a=getRemoteEntryUniqueKey(n);if(o)return o;if(!globalLoading[a]){const c=t.remoteHandler.hooks.lifecycle.loadEntry,l=t.loaderHook;globalLoading[a]=c.emit({loaderHook:l,remoteInfo:n,remoteEntryExports:o}).then(u=>u||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:n,remoteEntryExports:o,loaderHook:l,getEntryUrl:s}):loadEntryNode({remoteInfo:n,loaderHook:l}))).catch(async u=>{const d=getRemoteEntryUniqueKey(n);if(u instanceof Error&&u.message.includes(RUNTIME_008)&&!i){const p=E=>getRemoteEntry({...E,_inErrorHandling:!0}),m=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:p,origin:t,remoteInfo:n,remoteEntryExports:o,globalLoading,uniqueKey:d});if(m)return m}throw u})}return globalLoading[a]}function getRemoteInfo(r){return{...r,entry:"entry"in r?r.entry:"",type:r.type||DEFAULT_REMOTE_TYPE,entryGlobalName:r.entryGlobalName||r.name,shareScope:r.shareScope||DEFAULT_SCOPE}}function defaultPreloadArgs(r){return{resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1,...r}}function formatPreloadArgs(r,t){return t.map(o=>{const n=matchRemote(r,o.nameOrAlias);return assert(n,`Unable to preload ${o.nameOrAlias} as it is not included in ${!n&&safeToString({remoteInfo:n,remotes:r})}`),{remote:n,preloadConfig:defaultPreloadArgs(o)}})}function normalizePreloadExposes(r){return r?r.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(r,t,o,n=!0){const{cssAssets:s,jsAssetsWithoutEntry:i,entryAssets:a}=o;if(t.options.inBrowser){if(a.forEach(c=>{const{moduleInfo:l}=c,u=t.moduleCache.get(r.name);getRemoteEntry(u?{origin:t,remoteInfo:l,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:l,remoteEntryExports:void 0})}),n){const c={rel:"preload",as:"style"};s.forEach(l=>{const{link:u,needAttach:d}=createLink({url:l,cb:()=>{},attrs:c,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m}});d&&document.head.appendChild(u)})}else{const c={rel:"stylesheet",type:"text/css"};s.forEach(l=>{const{link:u,needAttach:d}=createLink({url:l,cb:()=>{},attrs:c,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});d&&document.head.appendChild(u)})}if(n){const c={rel:"preload",as:"script"};i.forEach(l=>{const{link:u,needAttach:d}=createLink({url:l,cb:()=>{},attrs:c,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m}});d&&document.head.appendChild(u)})}else{const c={fetchpriority:"high",type:(r==null?void 0:r.type)==="module"?"module":"text/javascript"};i.forEach(l=>{const{script:u,needAttach:d}=createScript({url:l,cb:()=>{},attrs:c,createScriptHook:(h,p)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:h,attrs:p});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});d&&document.head.appendChild(u)})}}}class Module{constructor({remoteInfo:t,host:o}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=o}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let t;return t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports}),assert(t,`remoteEntryExports is undefined
5
+ ${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,o,n,s){const{loadFactory:i=!0}=n||{loadFactory:!0},a=await this.getEntry();if(!this.inited){const h=this.host.shareScopeMap,p=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];p.length||p.push("default"),p.forEach(g=>{h[g]||(h[g]={})});const m=h[p[0]],E=[],b={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?p:this.remoteInfo.shareScope||"default"};Object.defineProperty(b,"shareScopeMap",{value:h,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:b,initScope:E,remoteInfo:this.remoteInfo,origin:this.host});typeof(a==null?void 0:a.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await a.init(y.shareScope,y.initScope,y.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...y,id:t,remoteSnapshot:s,remoteEntryExports:a})}this.lib=a,this.inited=!0;let c;c=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:a,expose:o,moduleInfo:this.remoteInfo}),c||(c=await a.get(o)),assert(c,`${getFMId(this.remoteInfo)} remote don't export ${o}.`);const l=processModuleAlias(this.remoteInfo.name,o),u=this.wraperFactory(c,l);return i?await u():u}wraperFactory(t,o){function n(s,i){s&&typeof s=="object"&&Object.isExtensible(s)&&!Object.getOwnPropertyDescriptor(s,Symbol.for("mf_module_id"))&&Object.defineProperty(s,Symbol.for("mf_module_id"),{value:i,enumerable:!1})}return t instanceof Promise?async()=>{const s=await t();return n(s,o),s}:()=>{const s=t();return n(s,o),s}}}class SyncHook{constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const o=this;this.on(function n(...s){return o.remove(n),t.apply(null,s)})}emit(...t){let o;return this.listeners.size>0&&this.listeners.forEach(n=>{o=n(...t)}),o}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}}class AsyncHook extends SyncHook{emit(...t){let o;const n=Array.from(this.listeners);if(n.length>0){let s=0;const i=a=>a===!1?!1:s<n.length?Promise.resolve(n[s++].apply(null,t)).then(i):a;o=i()}return Promise.resolve(o)}}function checkReturnData(r,t){if(!isObject(t))return!1;if(r!==t){for(const o in r)if(!(o in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{constructor(t){super(),this.onerror=error,this.type=t}emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const o of this.listeners)try{const n=o(t);if(checkReturnData(t,n))t=n;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(n){warn(n),this.onerror(n)}return t}}class AsyncWaterfallHook extends SyncHook{constructor(t){super(),this.onerror=error,this.type=t}emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const o=Array.from(this.listeners);if(o.length>0){let n=0;const s=a=>(warn(a),this.onerror(a),t),i=a=>{if(checkReturnData(t,a)){if(t=a,n<o.length)try{return Promise.resolve(o[n++](t)).then(i,s)}catch(c){return s(c)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return t};return Promise.resolve(i(t))}return Promise.resolve(t)}}class PluginSystem{constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}applyPlugin(t,o){var s;assert(isPlainObject(t),"Plugin configuration is invalid.");const n=t.name;assert(n,"A name must be provided by the plugin."),this.registerPlugins[n]||(this.registerPlugins[n]=t,(s=t.apply)==null||s.call(t,o),Object.keys(this.lifecycle).forEach(i=>{const a=t[i];a&&this.lifecycle[i].on(a)}))}removePlugin(t){assert(t,"A name is required.");const o=this.registerPlugins[t];assert(o,`The plugin "${t}" is not registered.`),Object.keys(o).forEach(n=>{n!=="name"&&this.lifecycle[n].remove(o[n])})}}function assignRemoteInfo(r,t){const o=getRemoteEntryInfoFromSnapshot(t);o.url||error(`The attribute remoteEntry of ${r.name} must not be undefined.`);let n=getResourceUrl(t,o.url);!isBrowserEnv()&&!n.startsWith("http")&&(n=`https:${n}`),r.type=o.type,r.entryGlobalName=o.globalName,r.entry=n,r.version=t.version,r.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(r){const{remote:t,pkgNameOrAlias:o,expose:n,origin:s,remoteInfo:i,id:a}=r;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:c,globalSnapshot:l}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:a});assignRemoteInfo(i,c);const u={remote:t,preloadConfig:{nameOrAlias:o,exposes:[n],resourceCategory:"sync",share:!1,depsRemote:!1}},d=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:u,remoteInfo:i,remote:t,remoteSnapshot:c,globalSnapshot:l});return d&&preloadAssets(i,s,d,!1),{...r,remoteSnapshot:c}}return r}}}function splitId(r){const t=r.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function traverseModuleInfo(r,t,o,n,s={},i){const a=getFMId(t),{value:c}=getInfoWithoutType(r,a),l=i||c;if(l&&!isManifestProvider(l)&&(o(l,t,n),l.remotesInfo)){const u=Object.keys(l.remotesInfo);for(const d of u){if(s[d])continue;s[d]=!0;const h=splitId(d),p=l.remotesInfo[d];traverseModuleInfo(r,{name:h.name,version:p.matchedVersion},o,!1,s,void 0)}}}const isExisted=(r,t)=>document.querySelector(`${r}[${r==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(r,t,o,n,s){const i=[],a=[],c=[],l=new Set,u=new Set,{options:d}=r,{preloadConfig:h}=t,{depsRemote:p}=h;if(traverseModuleInfo(n,o,(y,g,S)=>{var w;let R;if(S)R=h;else if(Array.isArray(p)){const N=p.find($=>$.nameOrAlias===g.name||$.nameOrAlias===g.alias);if(!N)return;R=defaultPreloadArgs(N)}else if(p===!0)R=h;else return;const A=getResourceUrl(y,getRemoteEntryInfoFromSnapshot(y).url);A&&c.push({name:g.name,moduleInfo:{name:g.name,entry:A,type:"remoteEntryType"in y?y.remoteEntryType:"global",entryGlobalName:"globalName"in y?y.globalName:g.name,shareScope:"",version:"version"in y?y.version:void 0},url:A});let _="modules"in y?y.modules:[];const I=normalizePreloadExposes(R.exposes);I.length&&"modules"in y&&(_=(w=y==null?void 0:y.modules)==null?void 0:w.reduce((N,$)=>((I==null?void 0:I.indexOf($.moduleName))!==-1&&N.push($),N),[]));function T(N){const $=N.map(M=>getResourceUrl(y,M));return R.filter?$.filter(R.filter):$}if(_){const N=_.length;for(let $=0;$<N;$++){const M=_[$],P=`${g.name}/${M.moduleName}`;r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:M.moduleName==="."?g.name:P,name:g.name,remoteSnapshot:y,preloadConfig:R,remote:g,origin:r}),!getPreloaded(P)&&(R.resourceCategory==="all"?(i.push(...T(M.assets.css.async)),i.push(...T(M.assets.css.sync)),a.push(...T(M.assets.js.async)),a.push(...T(M.assets.js.sync))):(R.resourceCategory="sync")&&(i.push(...T(M.assets.css.sync)),a.push(...T(M.assets.js.sync))),setPreloaded(P))}}},!0,{},s),s.shared&&s.shared.length>0){const y=(g,S)=>{const R=getRegisteredShare(r.shareScopeMap,S.sharedName,g,r.sharedHandler.hooks.lifecycle.resolveShare);R&&typeof R.lib=="function"&&(S.assets.js.sync.forEach(A=>{l.add(A)}),S.assets.css.sync.forEach(A=>{u.add(A)}))};s.shared.forEach(g=>{var _;const S=(_=d.shared)==null?void 0:_[g.sharedName];if(!S)return;const R=g.version?S.find(I=>I.version===g.version):S;if(!R)return;arrayOptions(R).forEach(I=>{y(I,g)})})}const E=a.filter(y=>!l.has(y)&&!isExisted("script",y));return{cssAssets:i.filter(y=>!u.has(y)&&!isExisted("link",y)),jsAssetsWithoutEntry:E,entryAssets:c.filter(y=>!isExisted("script",y.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(r){const{origin:t,preloadOptions:o,remoteInfo:n,remote:s,globalSnapshot:i,remoteSnapshot:a}=r;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:n.name,entry:s.entry,type:n.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(n,a),generatePreloadAssets(t,o,n,i,a)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(r,t){const o=getGlobalSnapshotInfoByModuleInfo({name:t.name,version:t.options.version}),n=o&&"remotesInfo"in o&&o.remotesInfo&&getInfoWithoutType(o.remotesInfo,r.name).value;return n&&n.matchedVersion?{hostGlobalSnapshot:o,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:n.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:"version"in r?r.version:void 0})}}class SnapshotHandler{constructor(t){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=t,this.loaderHook=t.loaderHook}async loadRemoteSnapshotInfo({moduleInfo:t,id:o,expose:n}){const{options:s}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:s,moduleInfo:t});let i=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});i||(i={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:i})),i&&"remotesInfo"in i&&!getInfoWithoutType(i.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(i.remotesInfo={...i==null?void 0:i.remotesInfo,[t.name]:{matchedVersion:"version"in t?t.version:t.entry}});const{hostGlobalSnapshot:a,remoteSnapshot:c,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:u,globalSnapshot:d}=await this.hooks.lifecycle.loadSnapshot.emit({options:s,moduleInfo:t,hostGlobalSnapshot:a,remoteSnapshot:c,globalSnapshot:l});let h,p;if(u)if(isManifestProvider(u)){const m=isBrowserEnv()?u.remoteEntry:u.ssrRemoteEntry||u.remoteEntry||"",E=await this.getManifestJson(m,t,{}),b=setGlobalSnapshotInfoByModuleInfo({...t,entry:m},E);h=E,p=b}else{const{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:u,from:"global"});h=m,p=d}else if(isRemoteInfoWithEntry(t)){const m=await this.getManifestJson(t.entry,t,{}),E=setGlobalSnapshotInfoByModuleInfo(t,m),{remoteSnapshot:b}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:m,from:"global"});h=b,p=E}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(d)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:o,host:this.HostInstance,options:s,moduleInfo:t,remoteSnapshot:h}),{remoteSnapshot:h,globalSnapshot:p}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,o,n){const s=async()=>{let a=this.manifestCache.get(t);if(a)return a;try{let c=await this.loaderHook.lifecycle.fetch.emit(t,{});(!c||!(c instanceof Response))&&(c=await fetch(t,{})),a=await c.json()}catch(c){a=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:c,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),a||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:o.name,hostName:this.HostInstance.options.name},`${c}`)))}return assert(a.metaData&&a.exposes&&a.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,a),a},i=async()=>{const a=await s(),c=generateSnapshotFromManifest(a,{version:t}),{remoteSnapshot:l}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:o,manifestJson:a,remoteSnapshot:c,manifestUrl:t,from:"manifest"});return l};return this.manifestLoading[t]||(this.manifestLoading[t]=i().then(a=>a)),this.manifestLoading[t]}}class SharedHandler{constructor(t){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=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}registerShared(t,o){const{shareInfos:n,shared:s}=formatShareConfigs(t,o);return Object.keys(n).forEach(a=>{n[a].forEach(l=>{!getRegisteredShare(this.shareScopeMap,a,l,this.hooks.lifecycle.resolveShare)&&l&&l.lib&&this.setShared({pkgName:a,lib:l.lib,get:l.get,loaded:!0,shared:l,from:o.name})})}),{shareInfos:n,shared:s}}async loadShare(t,o){const{host:n}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:n.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const i=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:n.options.shared,origin:n}),{shareInfo:a}=i;assert(a,`Cannot find ${t} Share in the ${n.options.name}. Please ensure that the ${t} Share parameters have been injected`);const c=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare),l=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,n.options.name)};if(c&&c.lib)return l(c),c.lib;if(c&&c.loading&&!c.loaded){const u=await c.loading;return c.loaded=!0,c.lib||(c.lib=u),l(c),u}else if(c){const d=(async()=>{const h=await c.get();return l(c),c.loaded=!0,c.lib=h,h})();return this.setShared({pkgName:t,loaded:!1,shared:c,from:n.options.name,lib:null,loading:d}),d}else{if(o!=null&&o.customShareInfo)return!1;const d=(async()=>{const h=await a.get();a.lib=h,a.loaded=!0,l(a);const p=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0,p.from=a.from),h})();return this.setShared({pkgName:t,loaded:!1,shared:a,from:n.options.name,lib:null,loading:d}),d}}initializeSharing(t=DEFAULT_SCOPE,o){const{host:n}=this,s=o==null?void 0:o.from,i=o==null?void 0:o.strategy;let a=o==null?void 0:o.initScope;const c=[];if(s!=="build"){const{initTokens:E}=this;a||(a=[]);let b=E[t];if(b||(b=E[t]={from:this.host.name}),a.indexOf(b)>=0)return c;a.push(b)}const l=this.shareScopeMap,u=n.options.name;l[t]||(l[t]={});const d=l[t],h=(E,b)=>{var _;const{version:y,eager:g}=b;d[E]=d[E]||{};const S=d[E],R=S[y],A=!!(R&&(R.eager||(_=R.shareConfig)!=null&&_.eager));(!R||R.strategy!=="loaded-first"&&!R.loaded&&(!g!=!A?g:u>R.from))&&(S[y]=b)},p=E=>E&&E.init&&E.init(l[t],a),m=async E=>{const{module:b}=await n.remoteHandler.getRemoteModuleAndOptions({id:E});if(b.getEntry){let y;try{y=await b.getEntry()}catch(g){y=await n.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:E,error:g,from:"runtime",lifecycle:"beforeLoadShare",origin:n})}b.inited||(await p(y),b.inited=!0)}};return Object.keys(n.options.shared).forEach(E=>{n.options.shared[E].forEach(y=>{y.scope.includes(t)&&h(E,y)})}),(n.options.shareStrategy==="version-first"||i==="version-first")&&n.options.remotes.forEach(E=>{E.shareScope===t&&c.push(m(E.name))}),c}loadShareSync(t,o){const{host:n}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:n.options.shared});s!=null&&s.scope&&s.scope.forEach(c=>{this.initializeSharing(c,{strategy:s.strategy})});const i=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),a=c=>{c.useIn||(c.useIn=[]),addUniqueItem(c.useIn,n.options.name)};if(i){if(typeof i.lib=="function")return a(i),i.loaded||(i.loaded=!0,i.from===n.options.name&&(s.loaded=!0)),i.lib;if(typeof i.get=="function"){const c=i.get();if(!(c instanceof Promise))return a(i),this.setShared({pkgName:t,loaded:!0,from:n.options.name,lib:c,shared:i}),c}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const c=s.get();if(c instanceof Promise){const l=(o==null?void 0:o.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(l,runtimeDescMap,{hostName:n.options.name,sharedPkgName:t}))}return s.lib=c,this.setShared({pkgName:t,loaded:!0,from:n.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:n.options.name,sharedPkgName:t}))}initShareScopeMap(t,o,n={}){const{host:s}=this;this.shareScopeMap[t]=o,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:o,options:s.options,origin:s,scopeName:t,hostShareScopeMap:n.hostShareScopeMap})}setShared({pkgName:t,shared:o,from:n,lib:s,loading:i,loaded:a,get:c}){const{version:l,scope:u="default",...d}=o;(Array.isArray(u)?u:[u]).forEach(p=>{if(this.shareScopeMap[p]||(this.shareScopeMap[p]={}),this.shareScopeMap[p][t]||(this.shareScopeMap[p][t]={}),!this.shareScopeMap[p][t][l]){this.shareScopeMap[p][t][l]={version:l,scope:["default"],...d,lib:s,loaded:a,loading:i},c&&(this.shareScopeMap[p][t][l].get=c);return}const m=this.shareScopeMap[p][t][l];i&&!m.loading&&(m.loading=i),a&&!m.loaded&&(m.loaded=a),n&&m.from!==n&&(m.from=n)})}_setGlobalShareScopeMap(t){const o=getGlobalShareScope(),n=t.id||t.name;n&&!o[n]&&(o[n]=this.shareScopeMap)}}class RemoteHandler{constructor(t){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=t,this.idToRemoteMap={}}formatAndRegisterRemote(t,o){return(o.remotes||[]).reduce((s,i)=>(this.registerRemote(i,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,o){const{remote:n,expose:s}=o,{name:i,alias:a}=n;if(this.idToRemoteMap[t]={name:n.name,expose:s},a&&t.startsWith(i)){const c=t.replace(i,a);this.idToRemoteMap[c]={name:n.name,expose:s};return}if(a&&t.startsWith(a)){const c=t.replace(a,i);this.idToRemoteMap[c]={name:n.name,expose:s}}}async loadRemote(t,o){const{host:n}=this;try{const{loadFactory:s=!0}=o||{loadFactory:!0},{module:i,moduleOptions:a,remoteMatchInfo:c}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:l,remote:u,expose:d,id:h,remoteSnapshot:p}=c,m=await i.get(h,d,o,p),E=await this.hooks.lifecycle.onLoad.emit({id:h,pkgNameOrAlias:l,expose:d,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:a,moduleInstance:i,origin:n});return this.setIdToRemoteMap(t,c),typeof E=="function"?E:m}catch(s){const{from:i="runtime"}=o||{from:"runtime"},a=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:i,lifecycle:"onLoad",origin:n});if(!a)throw s;return a}}async preloadRemote(t){const{host:o}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:o.options,origin:o});const n=formatPreloadArgs(o.options.remotes,t);await Promise.all(n.map(async s=>{const{remote:i}=s,a=getRemoteInfo(i),{globalSnapshot:c,remoteSnapshot:l}=await o.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:i}),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:s,remote:i,remoteInfo:a,globalSnapshot:c,remoteSnapshot:l});u&&preloadAssets(a,o,u)}))}registerRemotes(t,o){const{host:n}=this;t.forEach(s=>{this.registerRemote(s,n.options.remotes,{force:o==null?void 0:o.force})})}async getRemoteModuleAndOptions(t){const{host:o}=this,{id:n}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:n,options:o.options,origin:o})}catch(E){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:n,options:o.options,origin:o,from:"runtime",error:E,lifecycle:"beforeRequest"}),!s)throw E}const{id:i}=s,a=matchRemoteWithNameAndExpose(o.options.remotes,i);assert(a,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:o.options.name,requestId:i}));const{remote:c}=a,l=getRemoteInfo(c),u=await o.sharedHandler.hooks.lifecycle.afterResolve.emit({id:i,...a,options:o.options,origin:o,remoteInfo:l}),{remote:d,expose:h}=u;assert(d&&h,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${i}.`);let p=o.moduleCache.get(d.name);const m={host:o,remoteInfo:l};return p||(p=new Module(m),o.moduleCache.set(d.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,o,n){const{host:s}=this,i=()=>{if(t.alias){const c=o.find(l=>{var u;return t.alias&&(l.name.startsWith(t.alias)||((u=l.alias)==null?void 0:u.startsWith(t.alias)))});assert(!c,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${c&&c.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const a=o.find(c=>c.name===t.name);if(!a)i(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const c=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];n!=null&&n.force&&(this.removeRemote(a),i(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(c.join(" ")))}}removeRemote(t){var o;try{const{host:n}=this,{name:s}=t,i=n.options.remotes.findIndex(c=>c.name===s);i!==-1&&n.options.remotes.splice(i,1);const a=n.moduleCache.get(t.name);if(a){const c=a.remoteInfo,l=c.entryGlobalName;CurrentGlobal[l]&&((o=Object.getOwnPropertyDescriptor(CurrentGlobal,l))!=null&&o.configurable?delete CurrentGlobal[l]:CurrentGlobal[l]=void 0);const u=getRemoteEntryUniqueKey(a.remoteInfo);globalLoading[u]&&delete globalLoading[u],n.snapshotHandler.manifestCache.delete(c.entry);let d=c.buildVersion?composeKeyWithSeparator(c.name,c.buildVersion):c.name;const h=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>c.buildVersion?m.options.id===d:m.name===d);if(h!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[h];d=m.options.id||d;const E=getGlobalShareScope();let b=!0;const y=[];Object.keys(E).forEach(g=>{const S=E[g];S&&Object.keys(S).forEach(R=>{const A=S[R];A&&Object.keys(A).forEach(_=>{const I=A[_];I&&Object.keys(I).forEach(T=>{const w=I[T];w&&typeof w=="object"&&w.from===c.name&&(w.loaded||w.loading?(w.useIn=w.useIn.filter(N=>N!==c.name),w.useIn.length?b=!1:y.push([g,R,_,T])):y.push([g,R,_,T]))})})})}),b&&(m.shareScopeMap={},delete E[d]),y.forEach(([g,S,R,A])=>{var _,I,T;(T=(I=(_=E[g])==null?void 0:_[S])==null?void 0:I[R])==null||delete T[A]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(h,1)}const{hostGlobalSnapshot:p}=getGlobalRemoteInfo(t,n);if(p){const m=p&&"remotesInfo"in p&&p.remotesInfo&&getInfoWithoutType(p.remotesInfo,t.name).key;m&&(delete p.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}n.moduleCache.delete(t.name)}}catch(n){logger.log("removeRemote fail: ",n)}}}const USE_SNAPSHOT=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;class ModuleFederation{constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.20.0",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const o=USE_SNAPSHOT?[snapshotPlugin(),generatePreloadAssetsPlugin()]:[],n={id:getBuilderId(),name:t.name,plugins:o,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.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,...t.plugins||[]]),this.options=this.formatOptions(n,t)}initOptions(t){this.registerPlugins(t.plugins);const o=this.formatOptions(this.options,t);return this.options=o,o}async loadShare(t,o){return this.sharedHandler.loadShare(t,o)}loadShareSync(t,o){return this.sharedHandler.loadShareSync(t,o)}initializeSharing(t=DEFAULT_SCOPE,o){return this.sharedHandler.initializeSharing(t,o)}initRawContainer(t,o,n){const s=getRemoteInfo({name:t,entry:o}),i=new Module({host:this,remoteInfo:s});return i.remoteEntryExports=n,this.moduleCache.set(t,i),i}async loadRemote(t,o){return this.remoteHandler.loadRemote(t,o)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,o,n={}){this.sharedHandler.initShareScopeMap(t,o,n)}formatOptions(t,o){const{shared:n}=formatShareConfigs(t,o),{userOptions:s,options:i}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:o,options:t,shareInfo:n}),a=this.remoteHandler.formatAndRegisterRemote(i,s),{shared:c}=this.sharedHandler.registerShared(i,s),l=[...i.plugins];s.plugins&&s.plugins.forEach(d=>{l.includes(d)||l.push(d)});const u={...t,...o,plugins:l,remotes:a,shared:c};return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const o=registerPlugins(t,this);this.options.plugins=this.options.plugins.reduce((n,s)=>(s&&n&&!n.find(i=>i.name===s.name)&&n.push(s),n),o||[])}registerRemotes(t,o){return this.remoteHandler.registerRemotes(t,o)}registerShared(t){this.sharedHandler.registerShared(this.options,{...this.options,shared:t})}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(ModuleFederation);function createBridgeComponent(r){const t=new Map,o=getInstance();return()=>({__APP_VERSION__:"0.20.0",async render(n){var E,b,y;LoggerInstance.debug("createBridgeComponent render Info",n);const{moduleName:s,dom:i,basename:a,memoryRoute:c,hashRoute:l,...u}=n,d=Vue__namespace.createApp(r.rootComponent,u);t.set(i,d);const h=await((y=(b=(E=o==null?void 0:o.bridgeHook)==null?void 0:E.lifecycle)==null?void 0:b.beforeBridgeRender)==null?void 0:y.emit(n)),p=h&&typeof h=="object"&&(h!=null&&h.extraProps)?h==null?void 0:h.extraProps:{},m=r.appOptions({app:d,basename:a,memoryRoute:c,hashRoute:l,...u,...p});if(m!=null&&m.router){let g,S=m.router.getRoutes();n.memoryRoute?g=VueRouter__namespace.createMemoryHistory(n.basename):n.hashRoute?(g=VueRouter__namespace.createWebHashHistory(),S=S.map(A=>({...A,path:n.basename+A.path}))):g=VueRouter__namespace.createWebHistory(n.basename);const R=VueRouter__namespace.createRouter({...m.router.options,history:g,routes:S});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:R}),c&&await R.push(c.entryPath),d.use(R)}d.mount(i)},destroy(n){LoggerInstance.debug("createBridgeComponent destroy Info",n);const s=t.get(n==null?void 0:n.dom);s==null||s.unmount()}})}function e(){const r=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(r)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(r){const t=Vue.ref(null),o=Vue.ref(null),n=Vue.ref(""),s=VueRouter.useRoute(),i=getInstance(),a=Vue.useAttrs(),c=async()=>{var p,m,E,b;const u=(p=r.providerInfo)==null?void 0:p.call(r);o.value=u;let d={...a,moduleName:r.moduleName,dom:t.value,basename:r.basename,memoryRoute:r.memoryRoute,hashRoute:r.hashRoute};LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",d);const h=await((b=(E=(m=i==null?void 0:i.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:E.beforeBridgeRender)==null?void 0:b.emit(d))||{};d={...d,...h.extraProps},u.render(d)},l=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&c(),n.value!==""&&n.value!==u&&(LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...r,pathname:s.path}),e()),n.value=u});return Vue.onMounted(()=>{c()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>",{...r}),l(),(u=o.value)==null||u.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(r.rootAttrs||{},{ref:t}),null)}});function createRemoteAppComponent(r){return Vue.defineAsyncComponent({__APP_VERSION__:"0.20.0",...r.asyncComponentOptions,loader:async()=>{var l,u;const t=VueRouter.useRoute();let o="/";const n=(u=(l=t==null?void 0:t.matched)==null?void 0:l[0])==null?void 0:u.path;n&&(n.endsWith("/:pathMatch(.*)*")?o=n.replace("/:pathMatch(.*)*",""):o=t.matched[0].path);const s=(r==null?void 0:r.export)||"default";LoggerInstance.debug("createRemoteAppComponent LazyComponent create >>>",{basename:o,info:r});const i=await r.loader(),a=i&&i[Symbol.for("mf_module_id")],c=i[s];if(LoggerInstance.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:a,module:i,exportName:s,basename:o,route:t}),s in i&&typeof c=="function")return{render(){return Vue.h(RemoteApp,{moduleName:a,providerInfo:c,basename:o,rootAttrs:r.rootAttrs})}};throw new Error("module not found")}})}function createRemoteComponent(r){return LoggerInstance.warn("createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!"),createRemoteAppComponent(r)}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteAppComponent=createRemoteAppComponent;exports.createRemoteComponent=createRemoteComponent;