@module-federation/bridge-vue3 0.0.0-fix-record-set-config-field-20260202094853 → 0.0.0-fix-loop-load-20260203135642
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 +12 -4
- package/dist/index.cjs +3 -3
- package/dist/index.js +8 -7
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# @module-federation/bridge-vue3
|
|
2
2
|
|
|
3
|
-
## 0.0.0-fix-
|
|
3
|
+
## 0.0.0-fix-loop-load-20260203135642
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- @module-federation/runtime@0.0.0-fix-
|
|
8
|
-
- @module-federation/sdk@0.0.0-fix-
|
|
9
|
-
- @module-federation/bridge-shared@0.0.0-fix-
|
|
7
|
+
- @module-federation/runtime@0.0.0-fix-loop-load-20260203135642
|
|
8
|
+
- @module-federation/sdk@0.0.0-fix-loop-load-20260203135642
|
|
9
|
+
- @module-federation/bridge-shared@0.0.0-fix-loop-load-20260203135642
|
|
10
|
+
|
|
11
|
+
## 0.24.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @module-federation/runtime@0.24.0
|
|
16
|
+
- @module-federation/sdk@0.24.0
|
|
17
|
+
- @module-federation/bridge-shared@0.24.0
|
|
10
18
|
|
|
11
19
|
## 0.23.0
|
|
12
20
|
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
`),n=t.filter(s=>!LOGGER_STACK_SKIP_TOKENS.some(i=>s.includes(i)));return n.length?`Stack trace:
|
|
3
3
|
${n.slice(0,5).join(`
|
|
4
4
|
`)}`:void 0}catch{return}}class Logger{constructor(t,n=DEFAULT_DELEGATE){this.prefix=t,this.delegate=n??DEFAULT_DELEGATE}setPrefix(t){this.prefix=t}setDelegate(t){this.delegate=t??DEFAULT_DELEGATE}emit(t,n){const o=this.delegate,i=isDebugMode()?captureStackTrace():void 0,c=i?[...n,i]:n,a=(()=>{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 u of a){const l=o[u];if(typeof l=="function"){l.call(o,this.prefix,...c);return}}for(const u of a){const l=DEFAULT_DELEGATE[u];if(typeof l=="function"){l.call(DEFAULT_DELEGATE,this.prefix,...c);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(n){warn$1(n);return}}function isStaticResourcesEqual(r,t){const n=/^(https?:)?\/\//i,o=r.replace(n,"").replace(/\/$/,""),s=t.replace(n,"").replace(/\/$/,"");return o===s}function createScript(r){let t=null,n=!0,o=2e4,s;const i=document.getElementsByTagName("script");for(let a=0;a<i.length;a++){const u=i[a],l=u.getAttribute("src");if(l&&isStaticResourcesEqual(l,r.url)){t=u,n=!1;break}}if(!t){const a=r.attrs;t=document.createElement("script"),t.type=(a==null?void 0:a.type)==="module"?"module":"text/javascript";let u;r.createScriptHook&&(u=r.createScriptHook(r.url,r.attrs),u instanceof HTMLScriptElement?t=u:typeof u=="object"&&("script"in u&&u.script&&(t=u.script),"timeout"in u&&u.timeout&&(o=u.timeout))),t.src||(t.src=r.url),a&&!u&&Object.keys(a).forEach(l=>{t&&(l==="async"||l==="defer"?t[l]=a[l]:t.getAttribute(l)||t.setAttribute(l,a[l]))})}const c=async(a,u)=>{clearTimeout(s);const l=()=>{(u==null?void 0:u.type)==="error"?r!=null&&r.onErrorCallback&&(r==null||r.onErrorCallback(u)):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)}),a&&typeof a=="function")){const d=a(u);if(d instanceof Promise){const m=await d;return l(),m}return l(),d}l()};return t.onerror=c.bind(null,t.onerror),t.onload=c.bind(null,t.onload),s=setTimeout(()=>{c(null,new Error(`Remote script "${r.url}" time-outed.`))},o),{script:t,needAttach:n}}function createLink(r){let t=null,n=!0;const o=document.getElementsByTagName("link");for(let i=0;i<o.length;i++){const c=o[i],a=c.getAttribute("href"),u=c.getAttribute("rel");if(a&&isStaticResourcesEqual(a,r.url)&&u===r.attrs.rel){t=c,n=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",r.url);let i;const c=r.attrs;r.createLinkHook&&(i=r.createLinkHook(r.url,c),i instanceof HTMLLinkElement&&(t=i)),c&&!i&&Object.keys(c).forEach(a=>{t&&!t.getAttribute(a)&&t.setAttribute(a,c[a])})}const s=(i,c)=>{const a=()=>{(c==null?void 0:c.type)==="error"?r!=null&&r.onErrorCallback&&(r==null||r.onErrorCallback(c)):r!=null&&r.cb&&(r==null||r.cb())};if(t&&(t.onerror=null,t.onload=null,safeWrapper(()=>{const{needDeleteLink:u=!0}=r;u&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),i)){const u=i(c);return a(),u}a()};return t.onerror=s.bind(null,t.onerror),t.onload=s.bind(null,t.onload),{link:t,needAttach:n}}function loadScript(r,t){const{attrs:n={},createScriptHook:o}=t;return new Promise((s,i)=>{const{script:c,needAttach:a}=createScript({url:r,cb:s,onErrorCallback:i,attrs:{fetchpriority:"high",...n},createScriptHook:o,needDeleteScript:!0});a&&document.head.appendChild(c)})}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 n=new Function("name","return import(name)")(r).then(o=>o).catch(o=>{throw console.error(`Error importing module ${r}:`,o),sdkImportCache.delete(r),o});return sdkImportCache.set(r,n),n}const loadNodeFetch=async()=>{const r=await importNodeModule("node-fetch");return r.default||r},lazyLoaderHookFetch=async(r,t,n)=>{const s=await((i,c)=>n.lifecycle.fetch.emit(i,c))(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}
|
|
5
|
-
})`,{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,n,o)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},loadScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(r,t)=>new Promise((n,o)=>{createScriptNode(r,(s,i)=>{var c,a;if(s)o(s);else{const u=((c=t==null?void 0:t.attrs)==null?void 0:c.globalName)||`__FEDERATION_${(a=t==null?void 0:t.attrs)==null?void 0:a.name}:custom__`,l=globalThis[u]=i;n(l)}},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:n,vm:o}=t,i=await(await n(r)).text(),c=new o.SourceTextModule(i,{importModuleDynamically:async(a,u)=>{const l=new URL(a,r).href;return loadModule(l,t)}});return esmModuleCache.set(r,c),await c.link(async a=>{const u=new URL(a,r).href;return await loadModule(u,t)}),c}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()}
|
|
5
|
+
})`,{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,n,o)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},loadScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(r,t)=>new Promise((n,o)=>{createScriptNode(r,(s,i)=>{var c,a;if(s)o(s);else{const u=((c=t==null?void 0:t.attrs)==null?void 0:c.globalName)||`__FEDERATION_${(a=t==null?void 0:t.attrs)==null?void 0:a.name}:custom__`,l=globalThis[u]=i;n(l)}},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:n,vm:o}=t,i=await(await n(r)).text(),c=new o.SourceTextModule(i,{importModuleDynamically:async(a,u)=>{const l=new URL(a,r).href;return loadModule(l,t)}});return esmModuleCache.set(r,c),await c.link(async a=>{const u=new URL(a,r).href;return await loadModule(u,t)}),c}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.toLowerCase()}`,getShortErrorMsg=(r,t,n,o)=>{const s=[`${[t[r]]} #${r}`];return n&&s.push(`args: ${JSON.stringify(n)}`),s.push(getDocsUrl(r)),o&&s.push(`Original Error Message:
|
|
6
6
|
${o}`),s.join(`
|
|
7
|
-
`)},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(n=>n===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()||!("ssrRemoteEntry"in r)?"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 n;return r.endsWith("/")?n=r.slice(0,-1):n=r,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(r,t,n){Object.defineProperty(r,t,{value:n,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,n,o,s,i,c;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__=[]),(n=r.__FEDERATION__).__INSTANCES__??(n.__INSTANCES__=[]),(o=r.__FEDERATION__).moduleInfo??(o.moduleInfo={}),(s=r.__FEDERATION__).__SHARE__??(s.__SHARE__={}),(i=r.__FEDERATION__).__MANIFEST_LOADING__??(i.__MANIFEST_LOADING__={}),(c=r.__FEDERATION__).__PRELOADED_MAP__??(c.__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.0.0-fix-record-set-config-field-20260202094853")}function getInfoWithoutType(r,t){if(typeof t=="string"){if(r[t])return{value:r[t],key:t};{const o=Object.keys(r);for(const s of o){const[i,c]=s.split(":"),a=`${i}:${t}`,u=r[a];if(u)return{value:u,key:a}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(r,t)=>{const n=getFMId(r),o=getInfoWithoutType(t,n).value;if(o&&!o.version&&"version"in r&&r.version&&(o.version=r.version),o)return o;if("version"in r&&r.version){const{version:s,...i}=r,c=getFMId(i),a=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,c).value;if((a==null?void 0:a.version)===s)return a}},getGlobalSnapshotInfoByModuleInfo=r=>getTargetSnapshotInfoByModuleInfo(r,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(r,t)=>{const n=getFMId(r);return nativeGlobal.__FEDERATION__.moduleInfo[n]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=r=>(nativeGlobal.__FEDERATION__.moduleInfo={...nativeGlobal.__FEDERATION__.moduleInfo,...r},()=>{const t=Object.keys(r);for(const n of t)delete nativeGlobal.__FEDERATION__.moduleInfo[n]}),getRemoteEntryExports=(r,t)=>{const n=t||`__FEDERATION_${r}:custom__`,o=CurrentGlobal[n];return{remoteEntryKey:n,entryExports:o}},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((n,o)=>o(n),t)}function extractComparator(r){return r.match(parseRegex(comparator))}function combineVersion(r,t,n,o){const s=`${r}.${t}.${n}`;return o?`${s}-${o}`:s}function parseHyphen(r){return r.replace(parseRegex(hyphenRange),(t,n,o,s,i,c,a,u,l,d,m,h)=>(isXVersion(o)?n="":isXVersion(s)?n=`>=${o}.0.0`:isXVersion(i)?n=`>=${o}.${s}.0`:n=`>=${n}`,isXVersion(l)?u="":isXVersion(d)?u=`<${Number(l)+1}.0.0-0`:isXVersion(m)?u=`<${l}.${Number(d)+1}.0-0`:h?u=`<=${l}.${d}.${m}-${h}`:u=`<=${u}`,`${n} ${u}`.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),(n,o,s,i,c)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(i)?o==="0"?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.0 <${Number(o)+1}.0.0-0`:c?o==="0"?s==="0"?`>=${o}.${s}.${i}-${c} <${o}.${s}.${Number(i)+1}-0`:`>=${o}.${s}.${i}-${c} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${i}-${c} <${Number(o)+1}.0.0-0`:o==="0"?s==="0"?`>=${o}.${s}.${i} <${o}.${s}.${Number(i)+1}-0`:`>=${o}.${s}.${i} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${i} <${Number(o)+1}.0.0-0`)).join(" ")}function parseTildes(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(n,o,s,i,c)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(i)?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:c?`>=${o}.${s}.${i}-${c} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${i} <${o}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(r){return r.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(n,o,s,i,c,a)=>{const u=isXVersion(s),l=u||isXVersion(i),d=l||isXVersion(c);return o==="="&&d&&(o=""),a="",u?o===">"||o==="<"?"<0.0.0-0":"*":o&&d?(l&&(i=0),c=0,o===">"?(o=">=",l?(s=Number(s)+1,i=0,c=0):(i=Number(i)+1,c=0)):o==="<="&&(o="<",l?s=Number(s)+1:i=Number(i)+1),o==="<"&&(a="-0"),`${o+s}.${i}.${c}${a}`):l?`>=${s}.0.0${a} <${Number(s)+1}.0.0-0`:d?`>=${s}.${i}.0${a} <${s}.${Number(i)+1}.0-0`:n})).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:n}=r,{preRelease:o}=t;if(n===void 0&&o)return 1;if(n&&o===void 0)return-1;if(n===void 0&&o===void 0)return 0;for(let s=0,i=n.length;s<=i;s++){const c=n[s],a=o[s];if(c!==a)return c===void 0&&a===void 0?0:c?a?compareAtom(c,a):-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 n=extractComparator(r);if(!n)return!1;const[,o,,s,i,c,a]=n,u={operator:o,version:combineVersion(s,i,c,a),major:s,minor:i,patch:c,preRelease:a==null?void 0:a.split(".")},l=t.split("||");for(const d of l){const m=d.trim();if(!m||m==="*"||m==="x")return!0;try{const h=parseRange(m);if(!h.trim())return!0;const p=h.split(" ").map(g=>parseComparatorString(g)).join(" ");if(!p.trim())return!0;const y=p.split(/\s+/).map(g=>parseGTE0(g)).filter(Boolean);if(y.length===0)continue;let E=!0;for(const g of y){const b=extractComparator(g);if(!b){E=!1;break}const[,R,,_,I,S,T]=b,A={operator:R,version:combineVersion(_,I,S,T),major:_,minor:I,patch:S,preRelease:T==null?void 0:T.split(".")};if(!compare(A,u)){E=!1;break}}if(E)return!0}catch(h){console.error(`[semver] Error processing range part "${m}":`,h);continue}}return!1}function formatShare(r,t,n,o){var i;let s;if("get"in r?s=r.get:"lib"in r?s=()=>Promise.resolve(r.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${n}'!`)}),(i=r.shareConfig)!=null&&i.eager&&r.treeShaking)throw new Error('Can not set "eager:true" and "treeShaking" at the same time!');return{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??o)||"version-first",treeShaking:r.treeShaking?{...r.treeShaking,mode:r.treeShaking.mode??"server-calc",status:r.treeShaking.status??1,useIn:[]}:void 0}}function formatShareConfigs(r,t){const n=t.shared||{},o=t.name,s=Object.keys(n).reduce((c,a)=>{const u=arrayOptions(n[a]);return c[a]=c[a]||[],u.forEach(l=>{c[a].push(formatShare(l,o,a,t.shareStrategy))}),c},{}),i={...r.shared};return Object.keys(s).forEach(c=>{i[c]?s[c].forEach(a=>{i[c].find(l=>l.version===a.version)||i[c].push(a)}):i[c]=s[c]}),{allShareInfos:i,newShareInfos:s}}function shouldUseTreeShaking(r,t){if(!r)return!1;const{status:n,mode:o}=r;return n===0?!1:n===2?!0:o==="runtime-infer"?t?isMatchUsedExports(r,t):!0:!1}function versionLt(r,t){const n=o=>{if(!Number.isNaN(Number(o))){const i=o.split(".");let c=o;for(let a=0;a<3-i.length;a++)c+=".0";return c}return o};return!!satisfy(n(r),`<=${n(t)}`)}const findVersion=(r,t)=>{const n=t||function(o,s){return versionLt(o,s)};return Object.keys(r).reduce((o,s)=>!o||n(o,s)||o==="0"?s:o,0)},isLoaded=r=>!!r.loaded||typeof r.lib=="function",isLoading=r=>!!r.loading,isMatchUsedExports=(r,t)=>{if(!r||!t)return!1;const{usedExports:n}=r;return n?!!t.every(o=>n.includes(o)):!1};function findSingletonVersionOrderByVersion(r,t,n,o){const s=r[t][n];let i="",c=shouldUseTreeShaking(o);const a=function(u,l){return c?s[u].treeShaking?s[l].treeShaking?!isLoaded(s[u].treeShaking)&&versionLt(u,l):!1:!0:!isLoaded(s[u])&&versionLt(u,l)};if(c){if(i=findVersion(r[t][n],a),i)return{version:i,useTreesShaking:c};c=!1}return{version:findVersion(r[t][n],a),useTreesShaking:c}}const isLoadingOrLoaded=r=>isLoaded(r)||isLoading(r);function findSingletonVersionOrderByLoaded(r,t,n,o){const s=r[t][n];let i="",c=shouldUseTreeShaking(o);const a=function(u,l){if(c){if(!s[u].treeShaking)return!0;if(!s[l].treeShaking)return!1;if(isLoadingOrLoaded(s[l].treeShaking))return isLoadingOrLoaded(s[u].treeShaking)?!!versionLt(u,l):!0;if(isLoadingOrLoaded(s[u].treeShaking))return!1}return isLoadingOrLoaded(s[l])?isLoadingOrLoaded(s[u])?!!versionLt(u,l):!0:isLoadingOrLoaded(s[u])?!1:versionLt(u,l)};if(c){if(i=findVersion(r[t][n],a),i)return{version:i,useTreesShaking:c};c=!1}return{version:findVersion(r[t][n],a),useTreesShaking:c}}function getFindShareFunction(r){return r==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(r,t,n,o){if(!r)return;const{shareConfig:s,scope:i=DEFAULT_SCOPE,strategy:c,treeShaking:a}=n,u=Array.isArray(i)?i:[i];for(const l of u)if(s&&r[l]&&r[l][t]){const{requiredVersion:d}=s,m=getFindShareFunction(c),{version:h,useTreesShaking:p}=m(r,l,t,a),y=()=>{const b=r[l][t][h];if(s.singleton){if(typeof d=="string"&&!satisfy(h,d)){const R=`Version ${h} from ${h&&b.from} of shared singleton module ${t} does not satisfy the requirement of ${n.from} which needs ${d})`;s.strictVersion?error(R):warn(R)}return{shared:b,useTreesShaking:p}}else{if(d===!1||d==="*")return{shared:b,useTreesShaking:p};if(satisfy(h,d))return{shared:b,useTreesShaking:p};const R=shouldUseTreeShaking(a);if(R){for(const[_,I]of Object.entries(r[l][t]))if(shouldUseTreeShaking(I.treeShaking,a==null?void 0:a.usedExports)&&satisfy(_,d))return{shared:I,useTreesShaking:R}}for(const[_,I]of Object.entries(r[l][t]))if(satisfy(_,d))return{shared:I,useTreesShaking:!1}}},E={shareScopeMap:r,scope:l,pkgName:t,version:h,GlobalFederation:Global.__FEDERATION__,shareInfo:n,resolver:y};return(o.emit(E)||E).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(r){const{pkgName:t,extraOptions:n,shareInfos:o}=r,s=u=>{if(!u)return;const l={};u.forEach(h=>{l[h.version]=h});const m=findVersion(l,function(h,p){return!isLoaded(l[h])&&versionLt(h,p)});return l[m]},i=(n==null?void 0:n.resolver)??s,c=u=>u!==null&&typeof u=="object"&&!Array.isArray(u),a=(...u)=>{const l={};for(const d of u)if(d)for(const[m,h]of Object.entries(d)){const p=l[m];c(p)&&c(h)?l[m]=a(p,h):h!==void 0&&(l[m]=h)}return l};return a(i(o[t]),n==null?void 0:n.customShareInfo)}const addUseIn=(r,t)=>{r.useIn||(r.useIn=[]),addUniqueItem(r.useIn,t)};function directShare(r,t){return t&&r.treeShaking?r.treeShaking:r}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(r,t){for(const n of r){const o=t.startsWith(n.name);let s=t.replace(n.name,"");if(o){if(s.startsWith("/")){const a=n.name;return s=`.${s}`,{pkgNameOrAlias:a,expose:s,remote:n}}else if(s==="")return{pkgNameOrAlias:n.name,expose:".",remote:n}}const i=n.alias&&t.startsWith(n.alias);let c=n.alias&&t.replace(n.alias,"");if(n.alias&&i){if(c&&c.startsWith("/")){const a=n.alias;return c=`.${c}`,{pkgNameOrAlias:a,expose:c,remote:n}}else if(c==="")return{pkgNameOrAlias:n.alias,expose:".",remote:n}}}}function matchRemote(r,t){for(const n of r)if(t===n.name||n.alias&&t===n.alias)return n}function registerPlugins(r,t){const n=getGlobalHostPlugins(),o=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return n.length>0&&n.forEach(s=>{r!=null&&r.find(i=>i.name!==s.name)&&r.push(s)}),r&&r.length>0&&r.forEach(s=>{o.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((n,o)=>{try{t?n(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${r}")${importCallback}`)([n,o]):import(r).then(n).catch(o)}catch(s){o(s)}})}async function loadSystemJsEntry({entry:r,remoteEntryExports:t}){return new Promise((n,o)=>{try{t?n(t):typeof __system_context__>"u"?System.import(r).then(n).catch(o):new Function("callbacks",`System.import("${r}")${importCallback}`)([n,o])}catch(s){o(s)}})}function handleRemoteEntryLoaded(r,t,n){const{remoteEntryKey:o,entryExports:s}=getRemoteEntryExports(r,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:r,remoteEntryUrl:n,remoteEntryKey:o})),s}async function loadEntryScript({name:r,globalName:t,entry:n,loaderHook:o,getEntryUrl:s}){const{entryExports:i}=getRemoteEntryExports(r,t);if(i)return i;const c=s?s(n):n;return loadScript(c,{attrs:{},createScriptHook:(a,u)=>{const l=o.lifecycle.createScript.emit({url:a,attrs:u});if(l&&(l instanceof HTMLScriptElement||"script"in l||"timeout"in l))return l}}).then(()=>handleRemoteEntryLoaded(r,t,n)).catch(a=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:r,resourceUrl:n})),a})}async function loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:n,getEntryUrl:o}){const{entry:s,entryGlobalName:i,name:c,type:a}=r;switch(a){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:c,loaderHook:n,getEntryUrl:o})}}async function loadEntryNode({remoteInfo:r,loaderHook:t}){const{entry:n,entryGlobalName:o,name:s,type:i}=r,{entryExports:c}=getRemoteEntryExports(s,o);return c||loadScriptNode(n,{attrs:{name:s,globalName:o,type:i},loaderHook:{createScriptHook:(a,u={})=>{const l=t.lifecycle.createScript.emit({url:a,attrs:u});if(l&&"url"in l)return l}}}).then(()=>handleRemoteEntryLoaded(s,o,n)).catch(a=>{throw a})}function getRemoteEntryUniqueKey(r){const{entry:t,name:n}=r;return composeKeyWithSeparator(n,t)}async function getRemoteEntry(r){const{origin:t,remoteEntryExports:n,remoteInfo:o,getEntryUrl:s,_inErrorHandling:i=!1}=r,c=getRemoteEntryUniqueKey(o);if(n)return n;if(!globalLoading[c]){const a=t.remoteHandler.hooks.lifecycle.loadEntry,u=t.loaderHook;globalLoading[c]=a.emit({loaderHook:u,remoteInfo:o,remoteEntryExports:n}).then(l=>l||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:o,remoteEntryExports:n,loaderHook:u,getEntryUrl:s}):loadEntryNode({remoteInfo:o,loaderHook:u}))).catch(async l=>{const d=getRemoteEntryUniqueKey(o);if(l instanceof Error&&l.message.includes(RUNTIME_008)&&!i){const h=y=>getRemoteEntry({...y,_inErrorHandling:!0}),p=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:h,origin:t,remoteInfo:o,remoteEntryExports:n,globalLoading,uniqueKey:d});if(p)return p}throw l})}return globalLoading[c]}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(n=>{const o=matchRemote(r,n.nameOrAlias);return assert(o,`Unable to preload ${n.nameOrAlias} as it is not included in ${!o&&safeToString({remoteInfo:o,remotes:r})}`),{remote:o,preloadConfig:defaultPreloadArgs(n)}})}function normalizePreloadExposes(r){return r?r.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(r,t,n,o=!0){const{cssAssets:s,jsAssetsWithoutEntry:i,entryAssets:c}=n;if(t.options.inBrowser){if(c.forEach(a=>{const{moduleInfo:u}=a,l=t.moduleCache.get(r.name);getRemoteEntry(l?{origin:t,remoteInfo:u,remoteEntryExports:l.remoteEntryExports}:{origin:t,remoteInfo:u,remoteEntryExports:void 0})}),o){const a={rel:"preload",as:"style"};s.forEach(u=>{const{link:l,needAttach:d}=createLink({url:u,cb:()=>{},attrs:a,createLinkHook:(m,h)=>{const p=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:h});if(p instanceof HTMLLinkElement)return p}});d&&document.head.appendChild(l)})}else{const a={rel:"stylesheet",type:"text/css"};s.forEach(u=>{const{link:l,needAttach:d}=createLink({url:u,cb:()=>{},attrs:a,createLinkHook:(m,h)=>{const p=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:h});if(p instanceof HTMLLinkElement)return p},needDeleteLink:!1});d&&document.head.appendChild(l)})}if(o){const a={rel:"preload",as:"script"};i.forEach(u=>{const{link:l,needAttach:d}=createLink({url:u,cb:()=>{},attrs:a,createLinkHook:(m,h)=>{const p=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:h});if(p instanceof HTMLLinkElement)return p}});d&&document.head.appendChild(l)})}else{const a={fetchpriority:"high",type:(r==null?void 0:r.type)==="module"?"module":"text/javascript"};i.forEach(u=>{const{script:l,needAttach:d}=createScript({url:u,cb:()=>{},attrs:a,createScriptHook:(m,h)=>{const p=t.loaderHook.lifecycle.createScript.emit({url:m,attrs:h});if(p instanceof HTMLScriptElement)return p},needDeleteScript:!0});d&&document.head.appendChild(l)})}}}function createRemoteEntryInitOptions(r,t){const n=t,o=Array.isArray(r.shareScope)?r.shareScope:[r.shareScope];o.length||o.push("default"),o.forEach(a=>{n[a]||(n[a]={})});const s={version:r.version||"",shareScopeKeys:Array.isArray(r.shareScope)?o:r.shareScope||"default"};Object.defineProperty(s,"shareScopeMap",{value:n,enumerable:!1});const i=n[o[0]];return{remoteEntryInitOptions:s,shareScope:i,initScope:[]}}class Module{constructor({remoteInfo:t,host:n}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=n}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;const t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports});return assert(t,`remoteEntryExports is undefined
|
|
8
|
-
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async init(t,n){const o=await this.getEntry();if(!this.inited){const{remoteEntryInitOptions:s,shareScope:i,initScope:c}=createRemoteEntryInitOptions(this.remoteInfo,this.host.shareScopeMap),a=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:i,remoteEntryInitOptions:s,initScope:c,remoteInfo:this.remoteInfo,origin:this.host});typeof(o==null?void 0:o.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await o.init(a.shareScope,a.initScope,a.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...a,id:t,remoteSnapshot:n,remoteEntryExports:o}),this.inited=!0}return o}async get(t,n,o,s){const{loadFactory:i=!0}=o||{loadFactory:!0},c=await this.init(t,s);this.lib=c;let a;a=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:c,expose:n,moduleInfo:this.remoteInfo}),a||(a=await c.get(n)),assert(a,`${getFMId(this.remoteInfo)} remote don't export ${n}.`);const u=processModuleAlias(this.remoteInfo.name,n),l=this.wraperFactory(a,u);return i?await l():l}wraperFactory(t,n){function o(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 o(s,n),s}:()=>{const s=t();return o(s,n),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 n=this;this.on(function o(...s){return n.remove(o),t.apply(null,s)})}emit(...t){let n;return this.listeners.size>0&&this.listeners.forEach(o=>{n=o(...t)}),n}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}}class AsyncHook extends SyncHook{emit(...t){let n;const o=Array.from(this.listeners);if(o.length>0){let s=0;const i=c=>c===!1?!1:s<o.length?Promise.resolve(o[s++].apply(null,t)).then(i):c;n=i()}return Promise.resolve(n)}}function checkReturnData(r,t){if(!isObject(t))return!1;if(r!==t){for(const n in r)if(!(n 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 n of this.listeners)try{const o=n(t);if(checkReturnData(t,o))t=o;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(o){warn(o),this.onerror(o)}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 n=Array.from(this.listeners);if(n.length>0){let o=0;const s=c=>(warn(c),this.onerror(c),t),i=c=>{if(checkReturnData(t,c)){if(t=c,o<n.length)try{return Promise.resolve(n[o++](t)).then(i,s)}catch(a){return s(a)}}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,n){var s;assert(isPlainObject(t),"Plugin configuration is invalid.");const o=t.name;assert(o,"A name must be provided by the plugin."),this.registerPlugins[o]||(this.registerPlugins[o]=t,(s=t.apply)==null||s.call(t,n),Object.keys(this.lifecycle).forEach(i=>{const c=t[i];c&&this.lifecycle[i].on(c)}))}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(o=>{o!=="name"&&this.lifecycle[o].remove(n[o])})}}function assignRemoteInfo(r,t){const n=getRemoteEntryInfoFromSnapshot(t);n.url||error(`The attribute remoteEntry of ${r.name} must not be undefined.`);let o=getResourceUrl(t,n.url);!isBrowserEnv()&&!o.startsWith("http")&&(o=`https:${o}`),r.type=n.type,r.entryGlobalName=n.globalName,r.entry=o,r.version=t.version,r.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(r){const{remote:t,pkgNameOrAlias:n,expose:o,origin:s,remoteInfo:i,id:c}=r;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:a,globalSnapshot:u}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:c});assignRemoteInfo(i,a);const l={remote:t,preloadConfig:{nameOrAlias:n,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},d=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:l,remoteInfo:i,remote:t,remoteSnapshot:a,globalSnapshot:u});return d&&preloadAssets(i,s,d,!1),{...r,remoteSnapshot:a}}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,n,o,s={},i){const c=getFMId(t),{value:a}=getInfoWithoutType(r,c),u=i||a;if(u&&!isManifestProvider(u)&&(n(u,t,o),u.remotesInfo)){const l=Object.keys(u.remotesInfo);for(const d of l){if(s[d])continue;s[d]=!0;const m=splitId(d),h=u.remotesInfo[d];traverseModuleInfo(r,{name:m.name,version:h.matchedVersion},n,!1,s,void 0)}}}const isExisted=(r,t)=>document.querySelector(`${r}[${r==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(r,t,n,o,s){const i=[],c=[],a=[],u=new Set,l=new Set,{options:d}=r,{preloadConfig:m}=t,{depsRemote:h}=m;if(traverseModuleInfo(o,n,(g,b,R)=>{var w;let _;if(R)_=m;else if(Array.isArray(h)){const $=h.find(k=>k.nameOrAlias===b.name||k.nameOrAlias===b.alias);if(!$)return;_=defaultPreloadArgs($)}else if(h===!0)_=m;else return;const I=getResourceUrl(g,getRemoteEntryInfoFromSnapshot(g).url);I&&a.push({name:b.name,moduleInfo:{name:b.name,entry:I,type:"remoteEntryType"in g?g.remoteEntryType:"global",entryGlobalName:"globalName"in g?g.globalName:b.name,shareScope:"",version:"version"in g?g.version:void 0},url:I});let S="modules"in g?g.modules:[];const T=normalizePreloadExposes(_.exposes);T.length&&"modules"in g&&(S=(w=g==null?void 0:g.modules)==null?void 0:w.reduce(($,k)=>((T==null?void 0:T.indexOf(k.moduleName))!==-1&&$.push(k),$),[]));function A($){const k=$.map(N=>getResourceUrl(g,N));return _.filter?k.filter(_.filter):k}if(S){const $=S.length;for(let k=0;k<$;k++){const N=S[k],L=`${b.name}/${N.moduleName}`;r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:N.moduleName==="."?b.name:L,name:b.name,remoteSnapshot:g,preloadConfig:_,remote:b,origin:r}),!getPreloaded(L)&&(_.resourceCategory==="all"?(i.push(...A(N.assets.css.async)),i.push(...A(N.assets.css.sync)),c.push(...A(N.assets.js.async)),c.push(...A(N.assets.js.sync))):(_.resourceCategory="sync")&&(i.push(...A(N.assets.css.sync)),c.push(...A(N.assets.js.sync))),setPreloaded(L))}}},!0,{},s),s.shared&&s.shared.length>0){const g=(b,R)=>{const{shared:_}=getRegisteredShare(r.shareScopeMap,R.sharedName,b,r.sharedHandler.hooks.lifecycle.resolveShare)||{};_&&typeof _.lib=="function"&&(R.assets.js.sync.forEach(I=>{u.add(I)}),R.assets.css.sync.forEach(I=>{l.add(I)}))};s.shared.forEach(b=>{var S;const R=(S=d.shared)==null?void 0:S[b.sharedName];if(!R)return;const _=b.version?R.find(T=>T.version===b.version):R;if(!_)return;arrayOptions(_).forEach(T=>{g(T,b)})})}const y=c.filter(g=>!u.has(g)&&!isExisted("script",g));return{cssAssets:i.filter(g=>!l.has(g)&&!isExisted("link",g)),jsAssetsWithoutEntry:y,entryAssets:a.filter(g=>!isExisted("script",g.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(r){const{origin:t,preloadOptions:n,remoteInfo:o,remote:s,globalSnapshot:i,remoteSnapshot:c}=r;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:o.name,entry:s.entry,type:o.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(o,c),generatePreloadAssets(t,n,o,i,c)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(r,t){const n=getGlobalSnapshotInfoByModuleInfo({name:t.name,version:t.options.version}),o=n&&"remotesInfo"in n&&n.remotesInfo&&getInfoWithoutType(n.remotesInfo,r.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:n,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:o.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:n,expose:o}){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:c,remoteSnapshot:a,globalSnapshot:u}=this.getGlobalRemoteInfo(t),{remoteSnapshot:l,globalSnapshot:d}=await this.hooks.lifecycle.loadSnapshot.emit({options:s,moduleInfo:t,hostGlobalSnapshot:c,remoteSnapshot:a,globalSnapshot:u});let m,h;if(l)if(isManifestProvider(l)){const p=isBrowserEnv()?l.remoteEntry:l.ssrRemoteEntry||l.remoteEntry||"",y=await this.getManifestJson(p,t,{}),E=setGlobalSnapshotInfoByModuleInfo({...t,entry:p},y);m=y,h=E}else{const{remoteSnapshot:p}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:l,from:"global"});m=p,h=d}else if(isRemoteInfoWithEntry(t)){const p=await this.getManifestJson(t.entry,t,{}),y=setGlobalSnapshotInfoByModuleInfo(t,p),{remoteSnapshot:E}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:p,from:"global"});m=E,h=y}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(d)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:n,host:this.HostInstance,options:s,moduleInfo:t,remoteSnapshot:m}),{remoteSnapshot:m,globalSnapshot:h}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,n,o){const s=async()=>{let c=this.manifestCache.get(t);if(c)return c;try{let a=await this.loaderHook.lifecycle.fetch.emit(t,{});(!a||!(a instanceof Response))&&(a=await fetch(t,{})),c=await a.json()}catch(a){c=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:a,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),c||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:n.name,hostName:this.HostInstance.options.name},`${a}`)))}return assert(c.metaData&&c.exposes&&c.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,c),c},i=async()=>{const c=await s(),a=generateSnapshotFromManifest(c,{version:t}),{remoteSnapshot:u}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:n,manifestJson:c,remoteSnapshot:a,manifestUrl:t,from:"manifest"});return u};return this.manifestLoading[t]||(this.manifestLoading[t]=i().then(c=>c)),this.manifestLoading[t]}}class SharedHandler{constructor(t){this.hooks=new PluginSystem({beforeRegisterShare:new SyncWaterfallHook("beforeRegisterShare"),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,n){const{newShareInfos:o,allShareInfos:s}=formatShareConfigs(t,n);return Object.keys(o).forEach(c=>{o[c].forEach(u=>{u.scope.forEach(l=>{var m;this.hooks.lifecycle.beforeRegisterShare.emit({origin:this.host,pkgName:c,shared:u}),((m=this.shareScopeMap[l])==null?void 0:m[c])||this.setShared({pkgName:c,lib:u.lib,get:u.get,loaded:u.loaded||!!u.lib,shared:u,from:n.name})})})}),{newShareInfos:o,allShareInfos:s}}async loadShare(t,n){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:o.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async l=>{await Promise.all(this.initializeSharing(l,{strategy:s.strategy}))}));const i=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:o.options.shared,origin:o}),{shareInfo:c}=i;assert(c,`Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);const{shared:a,useTreesShaking:u}=getRegisteredShare(this.shareScopeMap,t,c,this.hooks.lifecycle.resolveShare)||{};if(a){const l=directShare(a,u);if(l.lib)return addUseIn(l,o.options.name),l.lib;if(l.loading&&!l.loaded){const d=await l.loading;return l.loaded=!0,l.lib||(l.lib=d),addUseIn(l,o.options.name),d}else{const m=(async()=>{const h=await l.get();return addUseIn(l,o.options.name),l.loaded=!0,l.lib=h,h})();return this.setShared({pkgName:t,loaded:!1,shared:a,from:o.options.name,lib:null,loading:m,treeShaking:u?l:void 0}),m}}else{if(n!=null&&n.customShareInfo)return!1;const l=shouldUseTreeShaking(c.treeShaking),d=directShare(c,l),h=(async()=>{const p=await d.get();d.lib=p,d.loaded=!0,addUseIn(d,o.options.name);const{shared:y,useTreesShaking:E}=getRegisteredShare(this.shareScopeMap,t,c,this.hooks.lifecycle.resolveShare)||{};if(y){const g=directShare(y,E);g.lib=p,g.loaded=!0,y.from=c.from}return p})();return this.setShared({pkgName:t,loaded:!1,shared:c,from:o.options.name,lib:null,loading:h,treeShaking:l?d:void 0}),h}}initializeSharing(t=DEFAULT_SCOPE,n){const{host:o}=this,s=n==null?void 0:n.from,i=n==null?void 0:n.strategy;let c=n==null?void 0:n.initScope;const a=[];if(s!=="build"){const{initTokens:p}=this;c||(c=[]);let y=p[t];if(y||(y=p[t]={from:this.host.name}),c.indexOf(y)>=0)return a;c.push(y)}const u=this.shareScopeMap,l=o.options.name;u[t]||(u[t]={});const d=u[t],m=(p,y)=>{var I;const{version:E,eager:g}=y;d[p]=d[p]||{};const b=d[p],R=b[E]&&directShare(b[E]),_=!!(R&&("eager"in R&&R.eager||"shareConfig"in R&&((I=R.shareConfig)!=null&&I.eager)));(!R||R.strategy!=="loaded-first"&&!R.loaded&&(!g!=!_?g:l>b[E].from))&&(b[E]=y)},h=async p=>{const{module:y}=await o.remoteHandler.getRemoteModuleAndOptions({id:p});let E;try{E=await y.getEntry()}catch(g){E=await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:p,error:g,from:"runtime",lifecycle:"beforeLoadShare",origin:o})}finally{E!=null&&E.init&&(y.remoteEntryExports=E,await y.init())}};return Object.keys(o.options.shared).forEach(p=>{o.options.shared[p].forEach(E=>{E.scope.includes(t)&&m(p,E)})}),(o.options.shareStrategy==="version-first"||i==="version-first")&&o.options.remotes.forEach(p=>{p.shareScope===t&&a.push(h(p.name))}),a}loadShareSync(t,n){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:o.options.shared});s!=null&&s.scope&&s.scope.forEach(a=>{this.initializeSharing(a,{strategy:s.strategy})});const{shared:i,useTreesShaking:c}=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare)||{};if(i){if(typeof i.lib=="function")return addUseIn(i,o.options.name),i.loaded||(i.loaded=!0,i.from===o.options.name&&(s.loaded=!0)),i.lib;if(typeof i.get=="function"){const a=i.get();if(!(a instanceof Promise))return addUseIn(i,o.options.name),this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:a,shared:i}),a}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const a=s.get();if(a instanceof Promise){const u=(n==null?void 0:n.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(u,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}return s.lib=a,this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}initShareScopeMap(t,n,o={}){const{host:s}=this;this.shareScopeMap[t]=n,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:n,options:s.options,origin:s,scopeName:t,hostShareScopeMap:o.hostShareScopeMap})}setShared({pkgName:t,shared:n,from:o,lib:s,loading:i,loaded:c,get:a,treeShaking:u}){const{version:l,scope:d="default",...m}=n,h=Array.isArray(d)?d:[d],p=y=>{const E=(b,R,_)=>{_&&!b[R]&&(b[R]=_)},g=u?y.treeShaking:y;E(g,"loaded",c),E(g,"loading",i),E(g,"get",a)};h.forEach(y=>{this.shareScopeMap[y]||(this.shareScopeMap[y]={}),this.shareScopeMap[y][t]||(this.shareScopeMap[y][t]={}),this.shareScopeMap[y][t][l]||(this.shareScopeMap[y][t][l]={version:l,scope:[y],...m,lib:s});const E=this.shareScopeMap[y][t][l];p(E),o&&E.from!==o&&(E.from=o)})}_setGlobalShareScopeMap(t){const n=getGlobalShareScope(),o=t.id||t.name;o&&!n[o]&&(n[o]=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,n){return(n.remotes||[]).reduce((s,i)=>(this.registerRemote(i,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,n){const{remote:o,expose:s}=n,{name:i,alias:c}=o;if(this.idToRemoteMap[t]={name:o.name,expose:s},c&&t.startsWith(i)){const a=t.replace(i,c);this.idToRemoteMap[a]={name:o.name,expose:s};return}if(c&&t.startsWith(c)){const a=t.replace(c,i);this.idToRemoteMap[a]={name:o.name,expose:s}}}async loadRemote(t,n){const{host:o}=this;try{const{loadFactory:s=!0}=n||{loadFactory:!0},{module:i,moduleOptions:c,remoteMatchInfo:a}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:u,remote:l,expose:d,id:m,remoteSnapshot:h}=a,p=await i.get(m,d,n,h),y=await this.hooks.lifecycle.onLoad.emit({id:m,pkgNameOrAlias:u,expose:d,exposeModule:s?p:void 0,exposeModuleFactory:s?void 0:p,remote:l,options:c,moduleInstance:i,origin:o});return this.setIdToRemoteMap(t,a),typeof y=="function"?y:p}catch(s){const{from:i="runtime"}=n||{from:"runtime"},c=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:i,lifecycle:"onLoad",origin:o});if(!c)throw s;return c}}async preloadRemote(t){const{host:n}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:n.options,origin:n});const o=formatPreloadArgs(n.options.remotes,t);await Promise.all(o.map(async s=>{const{remote:i}=s,c=getRemoteInfo(i),{globalSnapshot:a,remoteSnapshot:u}=await n.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:i}),l=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:n,preloadOptions:s,remote:i,remoteInfo:c,globalSnapshot:a,remoteSnapshot:u});l&&preloadAssets(c,n,l)}))}registerRemotes(t,n){const{host:o}=this;t.forEach(s=>{this.registerRemote(s,o.options.remotes,{force:n==null?void 0:n.force})})}async getRemoteModuleAndOptions(t){const{host:n}=this,{id:o}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:n.options,origin:n})}catch(y){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:n.options,origin:n,from:"runtime",error:y,lifecycle:"beforeRequest"}),!s)throw y}const{id:i}=s,c=matchRemoteWithNameAndExpose(n.options.remotes,i);assert(c,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:n.options.name,requestId:i}));const{remote:a}=c,u=getRemoteInfo(a),l=await n.sharedHandler.hooks.lifecycle.afterResolve.emit({id:i,...c,options:n.options,origin:n,remoteInfo:u}),{remote:d,expose:m}=l;assert(d&&m,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${i}.`);let h=n.moduleCache.get(d.name);const p={host:n,remoteInfo:u};return h||(h=new Module(p),n.moduleCache.set(d.name,h)),{module:h,moduleOptions:p,remoteMatchInfo:l}}registerRemote(t,n,o){const{host:s}=this,i=()=>{if(t.alias){const a=n.find(u=>{var l;return t.alias&&(u.name.startsWith(t.alias)||((l=u.alias)==null?void 0:l.startsWith(t.alias)))});assert(!a,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${a&&a.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 c=n.find(a=>a.name===t.name);if(!c)i(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const a=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];o!=null&&o.force&&(this.removeRemote(c),i(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(a.join(" ")))}}removeRemote(t){var n;try{const{host:o}=this,{name:s}=t,i=o.options.remotes.findIndex(a=>a.name===s);i!==-1&&o.options.remotes.splice(i,1);const c=o.moduleCache.get(t.name);if(c){const a=c.remoteInfo,u=a.entryGlobalName;CurrentGlobal[u]&&((n=Object.getOwnPropertyDescriptor(CurrentGlobal,u))!=null&&n.configurable?delete CurrentGlobal[u]:CurrentGlobal[u]=void 0);const l=getRemoteEntryUniqueKey(c.remoteInfo);globalLoading[l]&&delete globalLoading[l],o.snapshotHandler.manifestCache.delete(a.entry);let d=a.buildVersion?composeKeyWithSeparator(a.name,a.buildVersion):a.name;const m=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(p=>a.buildVersion?p.options.id===d:p.name===d);if(m!==-1){const p=CurrentGlobal.__FEDERATION__.__INSTANCES__[m];d=p.options.id||d;const y=getGlobalShareScope();let E=!0;const g=[];Object.keys(y).forEach(b=>{const R=y[b];R&&Object.keys(R).forEach(_=>{const I=R[_];I&&Object.keys(I).forEach(S=>{const T=I[S];T&&Object.keys(T).forEach(A=>{const w=T[A];w&&typeof w=="object"&&w.from===a.name&&(w.loaded||w.loading?(w.useIn=w.useIn.filter($=>$!==a.name),w.useIn.length?E=!1:g.push([b,_,S,A])):g.push([b,_,S,A]))})})})}),E&&(p.shareScopeMap={},delete y[d]),g.forEach(([b,R,_,I])=>{var S,T,A;(A=(T=(S=y[b])==null?void 0:S[R])==null?void 0:T[_])==null||delete A[I]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(m,1)}const{hostGlobalSnapshot:h}=getGlobalRemoteInfo(t,o);if(h){const p=h&&"remotesInfo"in h&&h.remotesInfo&&getInfoWithoutType(h.remotesInfo,t.name).key;p&&(delete h.remotesInfo[p],Global.__FEDERATION__.__MANIFEST_LOADING__[p]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[p])}o.moduleCache.delete(t.name)}}catch(o){logger.log("removeRemote fail: ",o)}}}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.0.0-fix-record-set-config-field-20260202094853",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()]:[],o={id:getBuilderId(),name:t.name,plugins:n,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=o,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...o.plugins,...t.plugins||[]]),this.options=this.formatOptions(o,t)}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,o){const s=getRemoteInfo({name:t,entry:n}),i=new Module({host:this,remoteInfo:s});return i.remoteEntryExports=o,this.moduleCache.set(t,i),i}async loadRemote(t,n){return this.remoteHandler.loadRemote(t,n)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,n,o={}){this.sharedHandler.initShareScopeMap(t,n,o)}formatOptions(t,n){const{allShareInfos:o}=formatShareConfigs(t,n),{userOptions:s,options:i}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:n,options:t,shareInfo:o}),c=this.remoteHandler.formatAndRegisterRemote(i,s),{allShareInfos:a}=this.sharedHandler.registerShared(i,s),u=[...i.plugins];s.plugins&&s.plugins.forEach(d=>{u.includes(d)||u.push(d)});const l={...t,...n,plugins:u,remotes:c,shared:a};return this.hooks.lifecycle.init.emit({origin:this,options:l}),l}registerPlugins(t){const n=registerPlugins(t,this);this.options.plugins=this.options.plugins.reduce((o,s)=>(s&&o&&!o.find(i=>i.name===s.name)&&o.push(s),o),n||[])}registerRemotes(t,n){return this.remoteHandler.registerRemotes(t,n)}registerShared(t){this.sharedHandler.registerShared(this.options,{...this.options,shared:t})}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(ModuleFederation);function addBasenameToNestedRoutes(r,t){return r.map(n=>{const o={...n,path:t+n.path};return n.children&&n.children.length>0&&(o.children=addBasenameToNestedRoutes(n.children,t)),o})}function processRoutes(r){const{router:t,basename:n,memoryRoute:o,hashRoute:s}=r,i=t.getRoutes().sort((h,p)=>h.path.split("/").filter(y=>y).length-p.path.split("/").filter(y=>y).length),c=new Map,a=new Set;i.forEach(h=>{c.set(h.path,h)});const u=(h,p)=>`${h}/${p}`.replace(/\/+/g,"/").replace(/\/$/,"")||"/",l=(h,p="")=>{if(!h.children||h.children.length===0)return h;for(let y=0;y<h.children.length;y++){const E=h.children[y],g=u(p,E.path),b=c.get(g);if(b&&!a.has(b)){const R={...b,path:E.path};h.children[y]=R,a.add(b),l(R,g)}}return h};let d=[];for(const h of i)if(!a.has(h)){const p=l(h,h.path);a.add(h),d.push(p)}let m;return o?m=VueRouter__namespace.createMemoryHistory(n):s?(m=VueRouter__namespace.createWebHashHistory(),n&&(d=addBasenameToNestedRoutes(d,n))):m=VueRouter__namespace.createWebHistory(n),{history:m,routes:d}}function createBridgeComponent(r){const t=new Map,n=getInstance();return()=>({__APP_VERSION__:"0.0.0-fix-record-set-config-field-20260202094853",async render(o){var y,E,g;LoggerInstance.debug("createBridgeComponent render Info",o);const{moduleName:s,dom:i,basename:c,memoryRoute:a,hashRoute:u,...l}=o,d=Vue__namespace.createApp(r.rootComponent,l);t.set(i,d);const m=await((g=(E=(y=n==null?void 0:n.bridgeHook)==null?void 0:y.lifecycle)==null?void 0:E.beforeBridgeRender)==null?void 0:g.emit(o)),h=m&&typeof m=="object"&&(m!=null&&m.extraProps)?m==null?void 0:m.extraProps:{},p=r.appOptions({app:d,basename:c,memoryRoute:a,hashRoute:u,...l,...h});if(p!=null&&p.router){const{history:b,routes:R}=processRoutes({router:p.router,basename:o.basename,memoryRoute:o.memoryRoute,hashRoute:o.hashRoute}),_=VueRouter__namespace.createRouter({...p.router.options,history:b,routes:R});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:_}),a&&await _.push(a.entryPath),d.use(_)}d.mount(i)},destroy(o){LoggerInstance.debug("createBridgeComponent destroy Info",o);const s=t.get(o==null?void 0:o.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),n=Vue.ref(null),o=Vue.ref(""),s=VueRouter.useRoute(),i=getInstance(),c=Vue.useAttrs(),a=async()=>{var h,p,y,E;const l=(h=r.providerInfo)==null?void 0:h.call(r);n.value=l;let d={...c,moduleName:r.moduleName,dom:t.value,basename:r.basename,memoryRoute:r.memoryRoute,hashRoute:r.hashRoute};LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",d);const m=await((E=(y=(p=i==null?void 0:i.bridgeHook)==null?void 0:p.lifecycle)==null?void 0:y.beforeBridgeRender)==null?void 0:E.emit(d))||{};d={...d,...m.extraProps},l.render(d)},u=Vue.watch(()=>s==null?void 0:s.path,l=>{l!==s.path&&a(),o.value!==""&&o.value!==l&&(LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...r,pathname:s.path}),e()),o.value=l});return Vue.onMounted(()=>{a()}),Vue.onBeforeUnmount(()=>{var l;LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>",{...r}),u(),(l=n.value)==null||l.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(r.rootAttrs||{},{ref:t}),null)}});function createRemoteAppComponent(r){return Vue.defineAsyncComponent({__APP_VERSION__:"0.0.0-fix-record-set-config-field-20260202094853",...r.asyncComponentOptions,loader:async()=>{var u,l;const t=VueRouter.useRoute();let n="/";const o=(l=(u=t==null?void 0:t.matched)==null?void 0:u[0])==null?void 0:l.path;o&&(o.endsWith("/:pathMatch(.*)*")?n=o.replace("/:pathMatch(.*)*",""):n=t.matched[0].path);const s=(r==null?void 0:r.export)||"default";LoggerInstance.debug("createRemoteAppComponent LazyComponent create >>>",{basename:n,info:r});const i=await r.loader(),c=i&&i[Symbol.for("mf_module_id")],a=i[s];if(LoggerInstance.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:c,module:i,exportName:s,basename:n,route:t}),s in i&&typeof a=="function")return{render(){return Vue.h(RemoteApp,{moduleName:c,providerInfo:a,basename:n,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;
|
|
7
|
+
`)},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(n=>n===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()||!("ssrRemoteEntry"in r)?"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 n;return r.endsWith("/")?n=r.slice(0,-1):n=r,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(r,t,n){Object.defineProperty(r,t,{value:n,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,n,o,s,i,c;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__=[]),(n=r.__FEDERATION__).__INSTANCES__??(n.__INSTANCES__=[]),(o=r.__FEDERATION__).moduleInfo??(o.moduleInfo={}),(s=r.__FEDERATION__).__SHARE__??(s.__SHARE__={}),(i=r.__FEDERATION__).__MANIFEST_LOADING__??(i.__MANIFEST_LOADING__={}),(c=r.__FEDERATION__).__PRELOADED_MAP__??(c.__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.0.0-fix-loop-load-20260203135642")}function getInfoWithoutType(r,t){if(typeof t=="string"){if(r[t])return{value:r[t],key:t};{const o=Object.keys(r);for(const s of o){const[i,c]=s.split(":"),a=`${i}:${t}`,u=r[a];if(u)return{value:u,key:a}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(r,t)=>{const n=getFMId(r),o=getInfoWithoutType(t,n).value;if(o&&!o.version&&"version"in r&&r.version&&(o.version=r.version),o)return o;if("version"in r&&r.version){const{version:s,...i}=r,c=getFMId(i),a=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,c).value;if((a==null?void 0:a.version)===s)return a}},getGlobalSnapshotInfoByModuleInfo=r=>getTargetSnapshotInfoByModuleInfo(r,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(r,t)=>{const n=getFMId(r);return nativeGlobal.__FEDERATION__.moduleInfo[n]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=r=>(nativeGlobal.__FEDERATION__.moduleInfo={...nativeGlobal.__FEDERATION__.moduleInfo,...r},()=>{const t=Object.keys(r);for(const n of t)delete nativeGlobal.__FEDERATION__.moduleInfo[n]}),getRemoteEntryExports=(r,t)=>{const n=t||`__FEDERATION_${r}:custom__`,o=CurrentGlobal[n];return{remoteEntryKey:n,entryExports:o}},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((n,o)=>o(n),t)}function extractComparator(r){return r.match(parseRegex(comparator))}function combineVersion(r,t,n,o){const s=`${r}.${t}.${n}`;return o?`${s}-${o}`:s}function parseHyphen(r){return r.replace(parseRegex(hyphenRange),(t,n,o,s,i,c,a,u,l,d,m,h)=>(isXVersion(o)?n="":isXVersion(s)?n=`>=${o}.0.0`:isXVersion(i)?n=`>=${o}.${s}.0`:n=`>=${n}`,isXVersion(l)?u="":isXVersion(d)?u=`<${Number(l)+1}.0.0-0`:isXVersion(m)?u=`<${l}.${Number(d)+1}.0-0`:h?u=`<=${l}.${d}.${m}-${h}`:u=`<=${u}`,`${n} ${u}`.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),(n,o,s,i,c)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(i)?o==="0"?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.0 <${Number(o)+1}.0.0-0`:c?o==="0"?s==="0"?`>=${o}.${s}.${i}-${c} <${o}.${s}.${Number(i)+1}-0`:`>=${o}.${s}.${i}-${c} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${i}-${c} <${Number(o)+1}.0.0-0`:o==="0"?s==="0"?`>=${o}.${s}.${i} <${o}.${s}.${Number(i)+1}-0`:`>=${o}.${s}.${i} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${i} <${Number(o)+1}.0.0-0`)).join(" ")}function parseTildes(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(n,o,s,i,c)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(i)?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:c?`>=${o}.${s}.${i}-${c} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${i} <${o}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(r){return r.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(n,o,s,i,c,a)=>{const u=isXVersion(s),l=u||isXVersion(i),d=l||isXVersion(c);return o==="="&&d&&(o=""),a="",u?o===">"||o==="<"?"<0.0.0-0":"*":o&&d?(l&&(i=0),c=0,o===">"?(o=">=",l?(s=Number(s)+1,i=0,c=0):(i=Number(i)+1,c=0)):o==="<="&&(o="<",l?s=Number(s)+1:i=Number(i)+1),o==="<"&&(a="-0"),`${o+s}.${i}.${c}${a}`):l?`>=${s}.0.0${a} <${Number(s)+1}.0.0-0`:d?`>=${s}.${i}.0${a} <${s}.${Number(i)+1}.0-0`:n})).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:n}=r,{preRelease:o}=t;if(n===void 0&&o)return 1;if(n&&o===void 0)return-1;if(n===void 0&&o===void 0)return 0;for(let s=0,i=n.length;s<=i;s++){const c=n[s],a=o[s];if(c!==a)return c===void 0&&a===void 0?0:c?a?compareAtom(c,a):-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 n=extractComparator(r);if(!n)return!1;const[,o,,s,i,c,a]=n,u={operator:o,version:combineVersion(s,i,c,a),major:s,minor:i,patch:c,preRelease:a==null?void 0:a.split(".")},l=t.split("||");for(const d of l){const m=d.trim();if(!m||m==="*"||m==="x")return!0;try{const h=parseRange(m);if(!h.trim())return!0;const p=h.split(" ").map(g=>parseComparatorString(g)).join(" ");if(!p.trim())return!0;const y=p.split(/\s+/).map(g=>parseGTE0(g)).filter(Boolean);if(y.length===0)continue;let E=!0;for(const g of y){const b=extractComparator(g);if(!b){E=!1;break}const[,R,,_,I,S,T]=b,A={operator:R,version:combineVersion(_,I,S,T),major:_,minor:I,patch:S,preRelease:T==null?void 0:T.split(".")};if(!compare(A,u)){E=!1;break}}if(E)return!0}catch(h){console.error(`[semver] Error processing range part "${m}":`,h);continue}}return!1}function formatShare(r,t,n,o){var i;let s;if("get"in r?s=r.get:"lib"in r?s=()=>Promise.resolve(r.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${n}'!`)}),(i=r.shareConfig)!=null&&i.eager&&r.treeShaking)throw new Error('Can not set "eager:true" and "treeShaking" at the same time!');return{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??o)||"version-first",treeShaking:r.treeShaking?{...r.treeShaking,mode:r.treeShaking.mode??"server-calc",status:r.treeShaking.status??1,useIn:[]}:void 0}}function formatShareConfigs(r,t){const n=t.shared||{},o=t.name,s=Object.keys(n).reduce((c,a)=>{const u=arrayOptions(n[a]);return c[a]=c[a]||[],u.forEach(l=>{c[a].push(formatShare(l,o,a,t.shareStrategy))}),c},{}),i={...r.shared};return Object.keys(s).forEach(c=>{i[c]?s[c].forEach(a=>{i[c].find(l=>l.version===a.version)||i[c].push(a)}):i[c]=s[c]}),{allShareInfos:i,newShareInfos:s}}function shouldUseTreeShaking(r,t){if(!r)return!1;const{status:n,mode:o}=r;return n===0?!1:n===2?!0:o==="runtime-infer"?t?isMatchUsedExports(r,t):!0:!1}function versionLt(r,t){const n=o=>{if(!Number.isNaN(Number(o))){const i=o.split(".");let c=o;for(let a=0;a<3-i.length;a++)c+=".0";return c}return o};return!!satisfy(n(r),`<=${n(t)}`)}const findVersion=(r,t)=>{const n=t||function(o,s){return versionLt(o,s)};return Object.keys(r).reduce((o,s)=>!o||n(o,s)||o==="0"?s:o,0)},isLoaded=r=>!!r.loaded||typeof r.lib=="function",isLoading=r=>!!r.loading,isMatchUsedExports=(r,t)=>{if(!r||!t)return!1;const{usedExports:n}=r;return n?!!t.every(o=>n.includes(o)):!1};function findSingletonVersionOrderByVersion(r,t,n,o){const s=r[t][n];let i="",c=shouldUseTreeShaking(o);const a=function(u,l){return c?s[u].treeShaking?s[l].treeShaking?!isLoaded(s[u].treeShaking)&&versionLt(u,l):!1:!0:!isLoaded(s[u])&&versionLt(u,l)};if(c){if(i=findVersion(r[t][n],a),i)return{version:i,useTreesShaking:c};c=!1}return{version:findVersion(r[t][n],a),useTreesShaking:c}}const isLoadingOrLoaded=r=>isLoaded(r)||isLoading(r);function findSingletonVersionOrderByLoaded(r,t,n,o){const s=r[t][n];let i="",c=shouldUseTreeShaking(o);const a=function(u,l){if(c){if(!s[u].treeShaking)return!0;if(!s[l].treeShaking)return!1;if(isLoadingOrLoaded(s[l].treeShaking))return isLoadingOrLoaded(s[u].treeShaking)?!!versionLt(u,l):!0;if(isLoadingOrLoaded(s[u].treeShaking))return!1}return isLoadingOrLoaded(s[l])?isLoadingOrLoaded(s[u])?!!versionLt(u,l):!0:isLoadingOrLoaded(s[u])?!1:versionLt(u,l)};if(c){if(i=findVersion(r[t][n],a),i)return{version:i,useTreesShaking:c};c=!1}return{version:findVersion(r[t][n],a),useTreesShaking:c}}function getFindShareFunction(r){return r==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(r,t,n,o){if(!r)return;const{shareConfig:s,scope:i=DEFAULT_SCOPE,strategy:c,treeShaking:a}=n,u=Array.isArray(i)?i:[i];for(const l of u)if(s&&r[l]&&r[l][t]){const{requiredVersion:d}=s,m=getFindShareFunction(c),{version:h,useTreesShaking:p}=m(r,l,t,a),y=()=>{const b=r[l][t][h];if(s.singleton){if(typeof d=="string"&&!satisfy(h,d)){const R=`Version ${h} from ${h&&b.from} of shared singleton module ${t} does not satisfy the requirement of ${n.from} which needs ${d})`;s.strictVersion?error(R):warn(R)}return{shared:b,useTreesShaking:p}}else{if(d===!1||d==="*")return{shared:b,useTreesShaking:p};if(satisfy(h,d))return{shared:b,useTreesShaking:p};const R=shouldUseTreeShaking(a);if(R){for(const[_,I]of Object.entries(r[l][t]))if(shouldUseTreeShaking(I.treeShaking,a==null?void 0:a.usedExports)&&satisfy(_,d))return{shared:I,useTreesShaking:R}}for(const[_,I]of Object.entries(r[l][t]))if(satisfy(_,d))return{shared:I,useTreesShaking:!1}}},E={shareScopeMap:r,scope:l,pkgName:t,version:h,GlobalFederation:Global.__FEDERATION__,shareInfo:n,resolver:y};return(o.emit(E)||E).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(r){const{pkgName:t,extraOptions:n,shareInfos:o}=r,s=u=>{if(!u)return;const l={};u.forEach(h=>{l[h.version]=h});const m=findVersion(l,function(h,p){return!isLoaded(l[h])&&versionLt(h,p)});return l[m]},i=(n==null?void 0:n.resolver)??s,c=u=>u!==null&&typeof u=="object"&&!Array.isArray(u),a=(...u)=>{const l={};for(const d of u)if(d)for(const[m,h]of Object.entries(d)){const p=l[m];c(p)&&c(h)?l[m]=a(p,h):h!==void 0&&(l[m]=h)}return l};return a(i(o[t]),n==null?void 0:n.customShareInfo)}const addUseIn=(r,t)=>{r.useIn||(r.useIn=[]),addUniqueItem(r.useIn,t)};function directShare(r,t){return t&&r.treeShaking?r.treeShaking:r}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(r,t){for(const n of r){const o=t.startsWith(n.name);let s=t.replace(n.name,"");if(o){if(s.startsWith("/")){const a=n.name;return s=`.${s}`,{pkgNameOrAlias:a,expose:s,remote:n}}else if(s==="")return{pkgNameOrAlias:n.name,expose:".",remote:n}}const i=n.alias&&t.startsWith(n.alias);let c=n.alias&&t.replace(n.alias,"");if(n.alias&&i){if(c&&c.startsWith("/")){const a=n.alias;return c=`.${c}`,{pkgNameOrAlias:a,expose:c,remote:n}}else if(c==="")return{pkgNameOrAlias:n.alias,expose:".",remote:n}}}}function matchRemote(r,t){for(const n of r)if(t===n.name||n.alias&&t===n.alias)return n}function registerPlugins(r,t){const n=getGlobalHostPlugins(),o=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return n.length>0&&n.forEach(s=>{r!=null&&r.find(i=>i.name!==s.name)&&r.push(s)}),r&&r.length>0&&r.forEach(s=>{o.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((n,o)=>{try{t?n(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${r}")${importCallback}`)([n,o]):import(r).then(n).catch(o)}catch(s){o(s)}})}async function loadSystemJsEntry({entry:r,remoteEntryExports:t}){return new Promise((n,o)=>{try{t?n(t):typeof __system_context__>"u"?System.import(r).then(n).catch(o):new Function("callbacks",`System.import("${r}")${importCallback}`)([n,o])}catch(s){o(s)}})}function handleRemoteEntryLoaded(r,t,n){const{remoteEntryKey:o,entryExports:s}=getRemoteEntryExports(r,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:r,remoteEntryUrl:n,remoteEntryKey:o})),s}async function loadEntryScript({name:r,globalName:t,entry:n,loaderHook:o,getEntryUrl:s}){const{entryExports:i}=getRemoteEntryExports(r,t);if(i)return i;const c=s?s(n):n;return loadScript(c,{attrs:{},createScriptHook:(a,u)=>{const l=o.lifecycle.createScript.emit({url:a,attrs:u});if(l&&(l instanceof HTMLScriptElement||"script"in l||"timeout"in l))return l}}).then(()=>handleRemoteEntryLoaded(r,t,n)).catch(a=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:r,resourceUrl:n})),a})}async function loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:n,getEntryUrl:o}){const{entry:s,entryGlobalName:i,name:c,type:a}=r;switch(a){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:c,loaderHook:n,getEntryUrl:o})}}async function loadEntryNode({remoteInfo:r,loaderHook:t}){const{entry:n,entryGlobalName:o,name:s,type:i}=r,{entryExports:c}=getRemoteEntryExports(s,o);return c||loadScriptNode(n,{attrs:{name:s,globalName:o,type:i},loaderHook:{createScriptHook:(a,u={})=>{const l=t.lifecycle.createScript.emit({url:a,attrs:u});if(l&&"url"in l)return l}}}).then(()=>handleRemoteEntryLoaded(s,o,n)).catch(a=>{throw a})}function getRemoteEntryUniqueKey(r){const{entry:t,name:n}=r;return composeKeyWithSeparator(n,t)}async function getRemoteEntry(r){const{origin:t,remoteEntryExports:n,remoteInfo:o,getEntryUrl:s,_inErrorHandling:i=!1}=r,c=getRemoteEntryUniqueKey(o);if(n)return n;if(!globalLoading[c]){const a=t.remoteHandler.hooks.lifecycle.loadEntry,u=t.loaderHook;globalLoading[c]=a.emit({loaderHook:u,remoteInfo:o,remoteEntryExports:n}).then(l=>l||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:o,remoteEntryExports:n,loaderHook:u,getEntryUrl:s}):loadEntryNode({remoteInfo:o,loaderHook:u}))).catch(async l=>{const d=getRemoteEntryUniqueKey(o);if(l instanceof Error&&l.message.includes(RUNTIME_008)&&!i){const h=y=>getRemoteEntry({...y,_inErrorHandling:!0}),p=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:h,origin:t,remoteInfo:o,remoteEntryExports:n,globalLoading,uniqueKey:d});if(p)return p}throw l})}return globalLoading[c]}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(n=>{const o=matchRemote(r,n.nameOrAlias);return assert(o,`Unable to preload ${n.nameOrAlias} as it is not included in ${!o&&safeToString({remoteInfo:o,remotes:r})}`),{remote:o,preloadConfig:defaultPreloadArgs(n)}})}function normalizePreloadExposes(r){return r?r.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(r,t,n,o=!0){const{cssAssets:s,jsAssetsWithoutEntry:i,entryAssets:c}=n;if(t.options.inBrowser){if(c.forEach(a=>{const{moduleInfo:u}=a,l=t.moduleCache.get(r.name);getRemoteEntry(l?{origin:t,remoteInfo:u,remoteEntryExports:l.remoteEntryExports}:{origin:t,remoteInfo:u,remoteEntryExports:void 0})}),o){const a={rel:"preload",as:"style"};s.forEach(u=>{const{link:l,needAttach:d}=createLink({url:u,cb:()=>{},attrs:a,createLinkHook:(m,h)=>{const p=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:h});if(p instanceof HTMLLinkElement)return p}});d&&document.head.appendChild(l)})}else{const a={rel:"stylesheet",type:"text/css"};s.forEach(u=>{const{link:l,needAttach:d}=createLink({url:u,cb:()=>{},attrs:a,createLinkHook:(m,h)=>{const p=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:h});if(p instanceof HTMLLinkElement)return p},needDeleteLink:!1});d&&document.head.appendChild(l)})}if(o){const a={rel:"preload",as:"script"};i.forEach(u=>{const{link:l,needAttach:d}=createLink({url:u,cb:()=>{},attrs:a,createLinkHook:(m,h)=>{const p=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:h});if(p instanceof HTMLLinkElement)return p}});d&&document.head.appendChild(l)})}else{const a={fetchpriority:"high",type:(r==null?void 0:r.type)==="module"?"module":"text/javascript"};i.forEach(u=>{const{script:l,needAttach:d}=createScript({url:u,cb:()=>{},attrs:a,createScriptHook:(m,h)=>{const p=t.loaderHook.lifecycle.createScript.emit({url:m,attrs:h});if(p instanceof HTMLScriptElement)return p},needDeleteScript:!0});d&&document.head.appendChild(l)})}}}function createRemoteEntryInitOptions(r,t){const n=t,o=Array.isArray(r.shareScope)?r.shareScope:[r.shareScope];o.length||o.push("default"),o.forEach(a=>{n[a]||(n[a]={})});const s={version:r.version||"",shareScopeKeys:Array.isArray(r.shareScope)?o:r.shareScope||"default"};Object.defineProperty(s,"shareScopeMap",{value:n,enumerable:!1});const i=n[o[0]];return{remoteEntryInitOptions:s,shareScope:i,initScope:[]}}class Module{constructor({remoteInfo:t,host:n}){this.inited=!1,this.initing=!1,this.lib=void 0,this.remoteInfo=t,this.host=n}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;const t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports});return assert(t,`remoteEntryExports is undefined
|
|
8
|
+
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async init(t,n){const o=await this.getEntry();if(!this.inited&&!this.initing){this.initing=!0;const{remoteEntryInitOptions:s,shareScope:i,initScope:c}=createRemoteEntryInitOptions(this.remoteInfo,this.host.shareScopeMap),a=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:i,remoteEntryInitOptions:s,initScope:c,remoteInfo:this.remoteInfo,origin:this.host});typeof(o==null?void 0:o.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await o.init(a.shareScope,a.initScope,a.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...a,id:t,remoteSnapshot:n,remoteEntryExports:o}),this.inited=!0}return o}async get(t,n,o,s){const{loadFactory:i=!0}=o||{loadFactory:!0},c=await this.init(t,s);this.lib=c;let a;a=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:c,expose:n,moduleInfo:this.remoteInfo}),a||(a=await c.get(n)),assert(a,`${getFMId(this.remoteInfo)} remote don't export ${n}.`);const u=processModuleAlias(this.remoteInfo.name,n),l=this.wraperFactory(a,u);return i?await l():l}wraperFactory(t,n){function o(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 o(s,n),s}:()=>{const s=t();return o(s,n),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 n=this;this.on(function o(...s){return n.remove(o),t.apply(null,s)})}emit(...t){let n;return this.listeners.size>0&&this.listeners.forEach(o=>{n=o(...t)}),n}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}}class AsyncHook extends SyncHook{emit(...t){let n;const o=Array.from(this.listeners);if(o.length>0){let s=0;const i=c=>c===!1?!1:s<o.length?Promise.resolve(o[s++].apply(null,t)).then(i):c;n=i()}return Promise.resolve(n)}}function checkReturnData(r,t){if(!isObject(t))return!1;if(r!==t){for(const n in r)if(!(n 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 n of this.listeners)try{const o=n(t);if(checkReturnData(t,o))t=o;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(o){warn(o),this.onerror(o)}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 n=Array.from(this.listeners);if(n.length>0){let o=0;const s=c=>(warn(c),this.onerror(c),t),i=c=>{if(checkReturnData(t,c)){if(t=c,o<n.length)try{return Promise.resolve(n[o++](t)).then(i,s)}catch(a){return s(a)}}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,n){var s;assert(isPlainObject(t),"Plugin configuration is invalid.");const o=t.name;assert(o,"A name must be provided by the plugin."),this.registerPlugins[o]||(this.registerPlugins[o]=t,(s=t.apply)==null||s.call(t,n),Object.keys(this.lifecycle).forEach(i=>{const c=t[i];c&&this.lifecycle[i].on(c)}))}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(o=>{o!=="name"&&this.lifecycle[o].remove(n[o])})}}function assignRemoteInfo(r,t){const n=getRemoteEntryInfoFromSnapshot(t);n.url||error(`The attribute remoteEntry of ${r.name} must not be undefined.`);let o=getResourceUrl(t,n.url);!isBrowserEnv()&&!o.startsWith("http")&&(o=`https:${o}`),r.type=n.type,r.entryGlobalName=n.globalName,r.entry=o,r.version=t.version,r.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(r){const{remote:t,pkgNameOrAlias:n,expose:o,origin:s,remoteInfo:i,id:c}=r;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:a,globalSnapshot:u}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:c});assignRemoteInfo(i,a);const l={remote:t,preloadConfig:{nameOrAlias:n,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},d=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:l,remoteInfo:i,remote:t,remoteSnapshot:a,globalSnapshot:u});return d&&preloadAssets(i,s,d,!1),{...r,remoteSnapshot:a}}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,n,o,s={},i){const c=getFMId(t),{value:a}=getInfoWithoutType(r,c),u=i||a;if(u&&!isManifestProvider(u)&&(n(u,t,o),u.remotesInfo)){const l=Object.keys(u.remotesInfo);for(const d of l){if(s[d])continue;s[d]=!0;const m=splitId(d),h=u.remotesInfo[d];traverseModuleInfo(r,{name:m.name,version:h.matchedVersion},n,!1,s,void 0)}}}const isExisted=(r,t)=>document.querySelector(`${r}[${r==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(r,t,n,o,s){const i=[],c=[],a=[],u=new Set,l=new Set,{options:d}=r,{preloadConfig:m}=t,{depsRemote:h}=m;if(traverseModuleInfo(o,n,(g,b,R)=>{var w;let _;if(R)_=m;else if(Array.isArray(h)){const $=h.find(k=>k.nameOrAlias===b.name||k.nameOrAlias===b.alias);if(!$)return;_=defaultPreloadArgs($)}else if(h===!0)_=m;else return;const I=getResourceUrl(g,getRemoteEntryInfoFromSnapshot(g).url);I&&a.push({name:b.name,moduleInfo:{name:b.name,entry:I,type:"remoteEntryType"in g?g.remoteEntryType:"global",entryGlobalName:"globalName"in g?g.globalName:b.name,shareScope:"",version:"version"in g?g.version:void 0},url:I});let S="modules"in g?g.modules:[];const T=normalizePreloadExposes(_.exposes);T.length&&"modules"in g&&(S=(w=g==null?void 0:g.modules)==null?void 0:w.reduce(($,k)=>((T==null?void 0:T.indexOf(k.moduleName))!==-1&&$.push(k),$),[]));function A($){const k=$.map(N=>getResourceUrl(g,N));return _.filter?k.filter(_.filter):k}if(S){const $=S.length;for(let k=0;k<$;k++){const N=S[k],L=`${b.name}/${N.moduleName}`;r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:N.moduleName==="."?b.name:L,name:b.name,remoteSnapshot:g,preloadConfig:_,remote:b,origin:r}),!getPreloaded(L)&&(_.resourceCategory==="all"?(i.push(...A(N.assets.css.async)),i.push(...A(N.assets.css.sync)),c.push(...A(N.assets.js.async)),c.push(...A(N.assets.js.sync))):(_.resourceCategory="sync")&&(i.push(...A(N.assets.css.sync)),c.push(...A(N.assets.js.sync))),setPreloaded(L))}}},!0,{},s),s.shared&&s.shared.length>0){const g=(b,R)=>{const{shared:_}=getRegisteredShare(r.shareScopeMap,R.sharedName,b,r.sharedHandler.hooks.lifecycle.resolveShare)||{};_&&typeof _.lib=="function"&&(R.assets.js.sync.forEach(I=>{u.add(I)}),R.assets.css.sync.forEach(I=>{l.add(I)}))};s.shared.forEach(b=>{var S;const R=(S=d.shared)==null?void 0:S[b.sharedName];if(!R)return;const _=b.version?R.find(T=>T.version===b.version):R;if(!_)return;arrayOptions(_).forEach(T=>{g(T,b)})})}const y=c.filter(g=>!u.has(g)&&!isExisted("script",g));return{cssAssets:i.filter(g=>!l.has(g)&&!isExisted("link",g)),jsAssetsWithoutEntry:y,entryAssets:a.filter(g=>!isExisted("script",g.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(r){const{origin:t,preloadOptions:n,remoteInfo:o,remote:s,globalSnapshot:i,remoteSnapshot:c}=r;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:o.name,entry:s.entry,type:o.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(o,c),generatePreloadAssets(t,n,o,i,c)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(r,t){const n=getGlobalSnapshotInfoByModuleInfo({name:t.name,version:t.options.version}),o=n&&"remotesInfo"in n&&n.remotesInfo&&getInfoWithoutType(n.remotesInfo,r.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:n,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:o.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:n,expose:o}){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:c,remoteSnapshot:a,globalSnapshot:u}=this.getGlobalRemoteInfo(t),{remoteSnapshot:l,globalSnapshot:d}=await this.hooks.lifecycle.loadSnapshot.emit({options:s,moduleInfo:t,hostGlobalSnapshot:c,remoteSnapshot:a,globalSnapshot:u});let m,h;if(l)if(isManifestProvider(l)){const p=isBrowserEnv()?l.remoteEntry:l.ssrRemoteEntry||l.remoteEntry||"",y=await this.getManifestJson(p,t,{}),E=setGlobalSnapshotInfoByModuleInfo({...t,entry:p},y);m=y,h=E}else{const{remoteSnapshot:p}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:l,from:"global"});m=p,h=d}else if(isRemoteInfoWithEntry(t)){const p=await this.getManifestJson(t.entry,t,{}),y=setGlobalSnapshotInfoByModuleInfo(t,p),{remoteSnapshot:E}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:p,from:"global"});m=E,h=y}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(d)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:n,host:this.HostInstance,options:s,moduleInfo:t,remoteSnapshot:m}),{remoteSnapshot:m,globalSnapshot:h}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,n,o){const s=async()=>{let c=this.manifestCache.get(t);if(c)return c;try{let a=await this.loaderHook.lifecycle.fetch.emit(t,{});(!a||!(a instanceof Response))&&(a=await fetch(t,{})),c=await a.json()}catch(a){c=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:a,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),c||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:n.name,hostName:this.HostInstance.options.name},`${a}`)))}return assert(c.metaData&&c.exposes&&c.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,c),c},i=async()=>{const c=await s(),a=generateSnapshotFromManifest(c,{version:t}),{remoteSnapshot:u}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:n,manifestJson:c,remoteSnapshot:a,manifestUrl:t,from:"manifest"});return u};return this.manifestLoading[t]||(this.manifestLoading[t]=i().then(c=>c)),this.manifestLoading[t]}}class SharedHandler{constructor(t){this.hooks=new PluginSystem({beforeRegisterShare:new SyncWaterfallHook("beforeRegisterShare"),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,n){const{newShareInfos:o,allShareInfos:s}=formatShareConfigs(t,n);return Object.keys(o).forEach(c=>{o[c].forEach(u=>{u.scope.forEach(l=>{var m;this.hooks.lifecycle.beforeRegisterShare.emit({origin:this.host,pkgName:c,shared:u}),((m=this.shareScopeMap[l])==null?void 0:m[c])||this.setShared({pkgName:c,lib:u.lib,get:u.get,loaded:u.loaded||!!u.lib,shared:u,from:n.name})})})}),{newShareInfos:o,allShareInfos:s}}async loadShare(t,n){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:o.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async l=>{await Promise.all(this.initializeSharing(l,{strategy:s.strategy}))}));const i=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:o.options.shared,origin:o}),{shareInfo:c}=i;assert(c,`Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);const{shared:a,useTreesShaking:u}=getRegisteredShare(this.shareScopeMap,t,c,this.hooks.lifecycle.resolveShare)||{};if(a){const l=directShare(a,u);if(l.lib)return addUseIn(l,o.options.name),l.lib;if(l.loading&&!l.loaded){const d=await l.loading;return l.loaded=!0,l.lib||(l.lib=d),addUseIn(l,o.options.name),d}else{const m=(async()=>{const h=await l.get();return addUseIn(l,o.options.name),l.loaded=!0,l.lib=h,h})();return this.setShared({pkgName:t,loaded:!1,shared:a,from:o.options.name,lib:null,loading:m,treeShaking:u?l:void 0}),m}}else{if(n!=null&&n.customShareInfo)return!1;const l=shouldUseTreeShaking(c.treeShaking),d=directShare(c,l),h=(async()=>{const p=await d.get();d.lib=p,d.loaded=!0,addUseIn(d,o.options.name);const{shared:y,useTreesShaking:E}=getRegisteredShare(this.shareScopeMap,t,c,this.hooks.lifecycle.resolveShare)||{};if(y){const g=directShare(y,E);g.lib=p,g.loaded=!0,y.from=c.from}return p})();return this.setShared({pkgName:t,loaded:!1,shared:c,from:o.options.name,lib:null,loading:h,treeShaking:l?d:void 0}),h}}initializeSharing(t=DEFAULT_SCOPE,n){const{host:o}=this,s=n==null?void 0:n.from,i=n==null?void 0:n.strategy;let c=n==null?void 0:n.initScope;const a=[];if(s!=="build"){const{initTokens:p}=this;c||(c=[]);let y=p[t];if(y||(y=p[t]={from:this.host.name}),c.indexOf(y)>=0)return a;c.push(y)}const u=this.shareScopeMap,l=o.options.name;u[t]||(u[t]={});const d=u[t],m=(p,y)=>{var I;const{version:E,eager:g}=y;d[p]=d[p]||{};const b=d[p],R=b[E]&&directShare(b[E]),_=!!(R&&("eager"in R&&R.eager||"shareConfig"in R&&((I=R.shareConfig)!=null&&I.eager)));(!R||R.strategy!=="loaded-first"&&!R.loaded&&(!g!=!_?g:l>b[E].from))&&(b[E]=y)},h=async p=>{const{module:y}=await o.remoteHandler.getRemoteModuleAndOptions({id:p});let E;try{E=await y.getEntry()}catch(g){E=await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:p,error:g,from:"runtime",lifecycle:"beforeLoadShare",origin:o})}finally{E!=null&&E.init&&(y.remoteEntryExports=E,await y.init())}};return Object.keys(o.options.shared).forEach(p=>{o.options.shared[p].forEach(E=>{E.scope.includes(t)&&m(p,E)})}),(o.options.shareStrategy==="version-first"||i==="version-first")&&o.options.remotes.forEach(p=>{p.shareScope===t&&a.push(h(p.name))}),a}loadShareSync(t,n){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:o.options.shared});s!=null&&s.scope&&s.scope.forEach(a=>{this.initializeSharing(a,{strategy:s.strategy})});const{shared:i,useTreesShaking:c}=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare)||{};if(i){if(typeof i.lib=="function")return addUseIn(i,o.options.name),i.loaded||(i.loaded=!0,i.from===o.options.name&&(s.loaded=!0)),i.lib;if(typeof i.get=="function"){const a=i.get();if(!(a instanceof Promise))return addUseIn(i,o.options.name),this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:a,shared:i}),a}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const a=s.get();if(a instanceof Promise){const u=(n==null?void 0:n.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(u,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}return s.lib=a,this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}initShareScopeMap(t,n,o={}){const{host:s}=this;this.shareScopeMap[t]=n,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:n,options:s.options,origin:s,scopeName:t,hostShareScopeMap:o.hostShareScopeMap})}setShared({pkgName:t,shared:n,from:o,lib:s,loading:i,loaded:c,get:a,treeShaking:u}){const{version:l,scope:d="default",...m}=n,h=Array.isArray(d)?d:[d],p=y=>{const E=(b,R,_)=>{_&&!b[R]&&(b[R]=_)},g=u?y.treeShaking:y;E(g,"loaded",c),E(g,"loading",i),E(g,"get",a)};h.forEach(y=>{this.shareScopeMap[y]||(this.shareScopeMap[y]={}),this.shareScopeMap[y][t]||(this.shareScopeMap[y][t]={}),this.shareScopeMap[y][t][l]||(this.shareScopeMap[y][t][l]={version:l,scope:[y],...m,lib:s});const E=this.shareScopeMap[y][t][l];p(E),o&&E.from!==o&&(E.from=o)})}_setGlobalShareScopeMap(t){const n=getGlobalShareScope(),o=t.id||t.name;o&&!n[o]&&(n[o]=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,n){return(n.remotes||[]).reduce((s,i)=>(this.registerRemote(i,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,n){const{remote:o,expose:s}=n,{name:i,alias:c}=o;if(this.idToRemoteMap[t]={name:o.name,expose:s},c&&t.startsWith(i)){const a=t.replace(i,c);this.idToRemoteMap[a]={name:o.name,expose:s};return}if(c&&t.startsWith(c)){const a=t.replace(c,i);this.idToRemoteMap[a]={name:o.name,expose:s}}}async loadRemote(t,n){const{host:o}=this;try{const{loadFactory:s=!0}=n||{loadFactory:!0},{module:i,moduleOptions:c,remoteMatchInfo:a}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:u,remote:l,expose:d,id:m,remoteSnapshot:h}=a,p=await i.get(m,d,n,h),y=await this.hooks.lifecycle.onLoad.emit({id:m,pkgNameOrAlias:u,expose:d,exposeModule:s?p:void 0,exposeModuleFactory:s?void 0:p,remote:l,options:c,moduleInstance:i,origin:o});return this.setIdToRemoteMap(t,a),typeof y=="function"?y:p}catch(s){const{from:i="runtime"}=n||{from:"runtime"},c=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:i,lifecycle:"onLoad",origin:o});if(!c)throw s;return c}}async preloadRemote(t){const{host:n}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:n.options,origin:n});const o=formatPreloadArgs(n.options.remotes,t);await Promise.all(o.map(async s=>{const{remote:i}=s,c=getRemoteInfo(i),{globalSnapshot:a,remoteSnapshot:u}=await n.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:i}),l=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:n,preloadOptions:s,remote:i,remoteInfo:c,globalSnapshot:a,remoteSnapshot:u});l&&preloadAssets(c,n,l)}))}registerRemotes(t,n){const{host:o}=this;t.forEach(s=>{this.registerRemote(s,o.options.remotes,{force:n==null?void 0:n.force})})}async getRemoteModuleAndOptions(t){const{host:n}=this,{id:o}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:n.options,origin:n})}catch(y){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:n.options,origin:n,from:"runtime",error:y,lifecycle:"beforeRequest"}),!s)throw y}const{id:i}=s,c=matchRemoteWithNameAndExpose(n.options.remotes,i);assert(c,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:n.options.name,requestId:i}));const{remote:a}=c,u=getRemoteInfo(a),l=await n.sharedHandler.hooks.lifecycle.afterResolve.emit({id:i,...c,options:n.options,origin:n,remoteInfo:u}),{remote:d,expose:m}=l;assert(d&&m,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${i}.`);let h=n.moduleCache.get(d.name);const p={host:n,remoteInfo:u};return h||(h=new Module(p),n.moduleCache.set(d.name,h)),{module:h,moduleOptions:p,remoteMatchInfo:l}}registerRemote(t,n,o){const{host:s}=this,i=()=>{if(t.alias){const a=n.find(u=>{var l;return t.alias&&(u.name.startsWith(t.alias)||((l=u.alias)==null?void 0:l.startsWith(t.alias)))});assert(!a,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${a&&a.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 c=n.find(a=>a.name===t.name);if(!c)i(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const a=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];o!=null&&o.force&&(this.removeRemote(c),i(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(a.join(" ")))}}removeRemote(t){var n;try{const{host:o}=this,{name:s}=t,i=o.options.remotes.findIndex(a=>a.name===s);i!==-1&&o.options.remotes.splice(i,1);const c=o.moduleCache.get(t.name);if(c){const a=c.remoteInfo,u=a.entryGlobalName;CurrentGlobal[u]&&((n=Object.getOwnPropertyDescriptor(CurrentGlobal,u))!=null&&n.configurable?delete CurrentGlobal[u]:CurrentGlobal[u]=void 0);const l=getRemoteEntryUniqueKey(c.remoteInfo);globalLoading[l]&&delete globalLoading[l],o.snapshotHandler.manifestCache.delete(a.entry);let d=a.buildVersion?composeKeyWithSeparator(a.name,a.buildVersion):a.name;const m=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(p=>a.buildVersion?p.options.id===d:p.name===d);if(m!==-1){const p=CurrentGlobal.__FEDERATION__.__INSTANCES__[m];d=p.options.id||d;const y=getGlobalShareScope();let E=!0;const g=[];Object.keys(y).forEach(b=>{const R=y[b];R&&Object.keys(R).forEach(_=>{const I=R[_];I&&Object.keys(I).forEach(S=>{const T=I[S];T&&Object.keys(T).forEach(A=>{const w=T[A];w&&typeof w=="object"&&w.from===a.name&&(w.loaded||w.loading?(w.useIn=w.useIn.filter($=>$!==a.name),w.useIn.length?E=!1:g.push([b,_,S,A])):g.push([b,_,S,A]))})})})}),E&&(p.shareScopeMap={},delete y[d]),g.forEach(([b,R,_,I])=>{var S,T,A;(A=(T=(S=y[b])==null?void 0:S[R])==null?void 0:T[_])==null||delete A[I]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(m,1)}const{hostGlobalSnapshot:h}=getGlobalRemoteInfo(t,o);if(h){const p=h&&"remotesInfo"in h&&h.remotesInfo&&getInfoWithoutType(h.remotesInfo,t.name).key;p&&(delete h.remotesInfo[p],Global.__FEDERATION__.__MANIFEST_LOADING__[p]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[p])}o.moduleCache.delete(t.name)}}catch(o){logger.log("removeRemote fail: ",o)}}}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.0.0-fix-loop-load-20260203135642",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()]:[],o={id:getBuilderId(),name:t.name,plugins:n,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=o,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...o.plugins,...t.plugins||[]]),this.options=this.formatOptions(o,t)}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,o){const s=getRemoteInfo({name:t,entry:n}),i=new Module({host:this,remoteInfo:s});return i.remoteEntryExports=o,this.moduleCache.set(t,i),i}async loadRemote(t,n){return this.remoteHandler.loadRemote(t,n)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,n,o={}){this.sharedHandler.initShareScopeMap(t,n,o)}formatOptions(t,n){const{allShareInfos:o}=formatShareConfigs(t,n),{userOptions:s,options:i}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:n,options:t,shareInfo:o}),c=this.remoteHandler.formatAndRegisterRemote(i,s),{allShareInfos:a}=this.sharedHandler.registerShared(i,s),u=[...i.plugins];s.plugins&&s.plugins.forEach(d=>{u.includes(d)||u.push(d)});const l={...t,...n,plugins:u,remotes:c,shared:a};return this.hooks.lifecycle.init.emit({origin:this,options:l}),l}registerPlugins(t){const n=registerPlugins(t,this);this.options.plugins=this.options.plugins.reduce((o,s)=>(s&&o&&!o.find(i=>i.name===s.name)&&o.push(s),o),n||[])}registerRemotes(t,n){return this.remoteHandler.registerRemotes(t,n)}registerShared(t){this.sharedHandler.registerShared(this.options,{...this.options,shared:t})}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(ModuleFederation);function addBasenameToNestedRoutes(r,t){return r.map(n=>{const o={...n,path:t+n.path};return n.children&&n.children.length>0&&(o.children=addBasenameToNestedRoutes(n.children,t)),o})}function processRoutes(r){const{router:t,basename:n,memoryRoute:o,hashRoute:s}=r,i=t.getRoutes().sort((h,p)=>h.path.split("/").filter(y=>y).length-p.path.split("/").filter(y=>y).length),c=new Map,a=new Set;i.forEach(h=>{c.set(h.path,h)});const u=(h,p)=>`${h}/${p}`.replace(/\/+/g,"/").replace(/\/$/,"")||"/",l=(h,p="")=>{if(!h.children||h.children.length===0)return h;for(let y=0;y<h.children.length;y++){const E=h.children[y],g=u(p,E.path),b=c.get(g);if(b&&!a.has(b)){const R={...b,path:E.path};h.children[y]=R,a.add(b),l(R,g)}}return h};let d=[];for(const h of i)if(!a.has(h)){const p=l(h,h.path);a.add(h),d.push(p)}let m;return o?m=VueRouter__namespace.createMemoryHistory(n):s?(m=VueRouter__namespace.createWebHashHistory(),n&&(d=addBasenameToNestedRoutes(d,n))):m=VueRouter__namespace.createWebHistory(n),{history:m,routes:d}}function createBridgeComponent(r){const t=new Map,n=getInstance();return()=>({__APP_VERSION__:"0.0.0-fix-loop-load-20260203135642",async render(o){var y,E,g;LoggerInstance.debug("createBridgeComponent render Info",o);const{moduleName:s,dom:i,basename:c,memoryRoute:a,hashRoute:u,...l}=o,d=Vue__namespace.createApp(r.rootComponent,l);t.set(i,d);const m=await((g=(E=(y=n==null?void 0:n.bridgeHook)==null?void 0:y.lifecycle)==null?void 0:E.beforeBridgeRender)==null?void 0:g.emit(o)),h=m&&typeof m=="object"&&(m!=null&&m.extraProps)?m==null?void 0:m.extraProps:{},p=r.appOptions({app:d,basename:c,memoryRoute:a,hashRoute:u,...l,...h});if(p!=null&&p.router){const{history:b,routes:R}=processRoutes({router:p.router,basename:o.basename,memoryRoute:o.memoryRoute,hashRoute:o.hashRoute}),_=VueRouter__namespace.createRouter({...p.router.options,history:b,routes:R});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:_}),a&&await _.push(a.entryPath),d.use(_)}d.mount(i)},destroy(o){LoggerInstance.debug("createBridgeComponent destroy Info",o);const s=t.get(o==null?void 0:o.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),n=Vue.ref(null),o=Vue.ref(""),s=VueRouter.useRoute(),i=getInstance(),c=Vue.useAttrs(),a=async()=>{var h,p,y,E;const l=(h=r.providerInfo)==null?void 0:h.call(r);n.value=l;let d={...c,moduleName:r.moduleName,dom:t.value,basename:r.basename,memoryRoute:r.memoryRoute,hashRoute:r.hashRoute};LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",d);const m=await((E=(y=(p=i==null?void 0:i.bridgeHook)==null?void 0:p.lifecycle)==null?void 0:y.beforeBridgeRender)==null?void 0:E.emit(d))||{};d={...d,...m.extraProps},l.render(d)},u=Vue.watch(()=>s==null?void 0:s.path,l=>{l!==s.path&&a(),o.value!==""&&o.value!==l&&(LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...r,pathname:s.path}),e()),o.value=l});return Vue.onMounted(()=>{a()}),Vue.onBeforeUnmount(()=>{var l;LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>",{...r}),u(),(l=n.value)==null||l.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(r.rootAttrs||{},{ref:t}),null)}});function createRemoteAppComponent(r){return Vue.defineAsyncComponent({__APP_VERSION__:"0.0.0-fix-loop-load-20260203135642",...r.asyncComponentOptions,loader:async()=>{var u,l;const t=VueRouter.useRoute();let n="/";const o=(l=(u=t==null?void 0:t.matched)==null?void 0:u[0])==null?void 0:l.path;o&&(o.endsWith("/:pathMatch(.*)*")?n=o.replace("/:pathMatch(.*)*",""):n=t.matched[0].path);const s=(r==null?void 0:r.export)||"default";LoggerInstance.debug("createRemoteAppComponent LazyComponent create >>>",{basename:n,info:r});const i=await r.loader(),c=i&&i[Symbol.for("mf_module_id")],a=i[s];if(LoggerInstance.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:c,module:i,exportName:s,basename:n,route:t}),s in i&&typeof a=="function")return{render(){return Vue.h(RemoteApp,{moduleName:c,providerInfo:a,basename:n,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;
|
package/dist/index.js
CHANGED
|
@@ -429,7 +429,7 @@ async function loadModule(r, t) {
|
|
|
429
429
|
return await loadModule(u, t);
|
|
430
430
|
}), c;
|
|
431
431
|
}
|
|
432
|
-
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()}
|
|
432
|
+
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.toLowerCase()}`, getShortErrorMsg = (r, t, n, o) => {
|
|
433
433
|
const s = [`${[t[r]]} #${r}`];
|
|
434
434
|
return n && s.push(`args: ${JSON.stringify(n)}`), s.push(getDocsUrl(r)), o && s.push(`Original Error Message:
|
|
435
435
|
${o}`), s.join(`
|
|
@@ -528,7 +528,7 @@ function setGlobalDefaultVal(r) {
|
|
|
528
528
|
setGlobalDefaultVal(CurrentGlobal);
|
|
529
529
|
setGlobalDefaultVal(nativeGlobal);
|
|
530
530
|
function setGlobalFederationConstructor(r, t = isDebugMode()) {
|
|
531
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-fix-
|
|
531
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-fix-loop-load-20260203135642");
|
|
532
532
|
}
|
|
533
533
|
function getInfoWithoutType(r, t) {
|
|
534
534
|
if (typeof t == "string") {
|
|
@@ -1342,7 +1342,7 @@ function createRemoteEntryInitOptions(r, t) {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
class Module {
|
|
1344
1344
|
constructor({ remoteInfo: t, host: n }) {
|
|
1345
|
-
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host = n;
|
|
1345
|
+
this.inited = !1, this.initing = !1, this.lib = void 0, this.remoteInfo = t, this.host = n;
|
|
1346
1346
|
}
|
|
1347
1347
|
async getEntry() {
|
|
1348
1348
|
if (this.remoteEntryExports)
|
|
@@ -1358,7 +1358,8 @@ class Module {
|
|
|
1358
1358
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1359
1359
|
async init(t, n) {
|
|
1360
1360
|
const o = await this.getEntry();
|
|
1361
|
-
if (!this.inited) {
|
|
1361
|
+
if (!this.inited && !this.initing) {
|
|
1362
|
+
this.initing = !0;
|
|
1362
1363
|
const { remoteEntryInitOptions: s, shareScope: i, initScope: c } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap), a = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1363
1364
|
shareScope: i,
|
|
1364
1365
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
@@ -2327,7 +2328,7 @@ class ModuleFederation {
|
|
|
2327
2328
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2328
2329
|
// maybe will change, temporarily for internal use only
|
|
2329
2330
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2330
|
-
}), this.version = "0.0.0-fix-
|
|
2331
|
+
}), this.version = "0.0.0-fix-loop-load-20260203135642", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2331
2332
|
// FIXME: may not be suitable , not open to the public yet
|
|
2332
2333
|
getModuleInfo: new SyncHook(),
|
|
2333
2334
|
createScript: new SyncHook(),
|
|
@@ -2479,7 +2480,7 @@ function processRoutes(r) {
|
|
|
2479
2480
|
function createBridgeComponent(r) {
|
|
2480
2481
|
const t = /* @__PURE__ */ new Map(), n = getInstance();
|
|
2481
2482
|
return () => ({
|
|
2482
|
-
__APP_VERSION__: "0.0.0-fix-
|
|
2483
|
+
__APP_VERSION__: "0.0.0-fix-loop-load-20260203135642",
|
|
2483
2484
|
async render(o) {
|
|
2484
2485
|
var g, b, E;
|
|
2485
2486
|
LoggerInstance.debug("createBridgeComponent render Info", o);
|
|
@@ -2581,7 +2582,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2581
2582
|
});
|
|
2582
2583
|
function createRemoteAppComponent(r) {
|
|
2583
2584
|
return defineAsyncComponent({
|
|
2584
|
-
__APP_VERSION__: "0.0.0-fix-
|
|
2585
|
+
__APP_VERSION__: "0.0.0-fix-loop-load-20260203135642",
|
|
2585
2586
|
...r.asyncComponentOptions,
|
|
2586
2587
|
//@ts-ignore
|
|
2587
2588
|
loader: async () => {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "git+https://github.com/module-federation/core.git",
|
|
8
8
|
"directory": "packages/bridge/vue3-bridge"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.0.0-fix-
|
|
10
|
+
"version": "0.0.0-fix-loop-load-20260203135642",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"vue-router": "=4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@module-federation/
|
|
36
|
-
"@module-federation/
|
|
37
|
-
"@module-federation/
|
|
35
|
+
"@module-federation/sdk": "0.0.0-fix-loop-load-20260203135642",
|
|
36
|
+
"@module-federation/runtime": "0.0.0-fix-loop-load-20260203135642",
|
|
37
|
+
"@module-federation/bridge-shared": "0.0.0-fix-loop-load-20260203135642"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^18.3.11",
|