@module-federation/bridge-vue3 0.0.0-refactor-manifest-20251017070814 → 0.0.0-refactor-manifest-20251111024434
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 +38 -5
- package/dist/index.cjs +6 -3
- package/dist/index.js +204 -177
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
# @module-federation/bridge-vue3
|
|
2
2
|
|
|
3
|
-
## 0.0.0-refactor-manifest-
|
|
3
|
+
## 0.0.0-refactor-manifest-20251111024434
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Updated dependencies [
|
|
8
|
-
- @module-federation/sdk@0.0.0-refactor-manifest-
|
|
9
|
-
- @module-federation/runtime@0.0.0-refactor-manifest-
|
|
10
|
-
- @module-federation/bridge-shared@0.0.0-refactor-manifest-
|
|
7
|
+
- Updated dependencies [567aa11]
|
|
8
|
+
- @module-federation/sdk@0.0.0-refactor-manifest-20251111024434
|
|
9
|
+
- @module-federation/runtime@0.0.0-refactor-manifest-20251111024434
|
|
10
|
+
- @module-federation/bridge-shared@0.0.0-refactor-manifest-20251111024434
|
|
11
|
+
|
|
12
|
+
## 0.21.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- @module-federation/runtime@0.21.3
|
|
17
|
+
- @module-federation/sdk@0.21.3
|
|
18
|
+
- @module-federation/bridge-shared@0.21.3
|
|
19
|
+
|
|
20
|
+
## 0.21.2
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- @module-federation/runtime@0.21.2
|
|
25
|
+
- @module-federation/sdk@0.21.2
|
|
26
|
+
- @module-federation/bridge-shared@0.21.2
|
|
27
|
+
|
|
28
|
+
## 0.21.1
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- @module-federation/runtime@0.21.1
|
|
33
|
+
- @module-federation/sdk@0.21.1
|
|
34
|
+
- @module-federation/bridge-shared@0.21.1
|
|
35
|
+
|
|
36
|
+
## 0.21.0
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [d1e90a4]
|
|
41
|
+
- @module-federation/sdk@0.21.0
|
|
42
|
+
- @module-federation/runtime@0.21.0
|
|
43
|
+
- @module-federation/bridge-shared@0.21.0
|
|
11
44
|
|
|
12
45
|
## 0.20.0
|
|
13
46
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vue=require("vue"),VueRouter=require("vue-router");function _interopNamespaceDefault(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>r[o]})}}return t.default=r,Object.freeze(t)}const Vue__namespace=_interopNamespaceDefault(Vue),VueRouter__namespace=_interopNamespaceDefault(VueRouter),MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",SEPARATOR=":";function isBrowserEnv(){return typeof window<"u"&&typeof window.document<"u"}function isReactNativeEnv(){return typeof navigator<"u"&&(navigator==null?void 0:navigator.product)==="ReactNative"}function isBrowserDebug(){try{if(isBrowserEnv()&&window.localStorage)return!!localStorage.getItem(BROWSER_LOG_KEY)}catch{return!1}return!1}function isDebugMode(){return typeof process<"u"&&process.env&&process.env.FEDERATION_DEBUG?!!process.env.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&FEDERATION_DEBUG?!0:isBrowserDebug()}const LOG_CATEGORY$1="[ Federation Runtime ]",composeKeyWithSeparator=function(...r){return r.length?r.reduce((t,o)=>o?t?`${t}${SEPARATOR}${o}`:o:t,""):""},getResourceUrl=(r,t)=>{if("getPublicPath"in r){let o;return r.getPublicPath.startsWith("function")?o=new Function("return "+r.getPublicPath)()():o=new Function(r.getPublicPath)(),`${o}${t}`}else return"publicPath"in r?!isBrowserEnv()&&!isReactNativeEnv()&&"ssrPublicPath"in r?`${r.ssrPublicPath}${t}`:`${r.publicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",r,t),"")},warn$1=r=>{console.warn(`${LOG_CATEGORY$1}: ${r}`)};function safeToString(r){try{return JSON.stringify(r,null,2)}catch{return""}}const simpleJoinRemoteEntry=(r,t)=>{if(!r)return t;const n=(s=>{if(s===".")return"";if(s.startsWith("./"))return s.replace("./","");if(s.startsWith("/")){const a=s.slice(1);return a.endsWith("/")?a.slice(0,-1):a}return s})(r);return n?n.endsWith("/")?`${n}${t}`:`${n}/${t}`:t};function inferAutoPublicPath(r){return r.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(r,t={}){var S,_,T;const{remotes:o={},overrides:n={},version:s}=t;let a;const c=()=>"publicPath"in r.metaData?r.metaData.publicPath==="auto"&&s?inferAutoPublicPath(s):r.metaData.publicPath:r.metaData.getPublicPath,i=Object.keys(n);let l={};Object.keys(o).length||(l=((S=r.remotes)==null?void 0:S.reduce((R,I)=>{let A;const w=I.federationContainerName;return i.includes(w)?A=n[w]:"version"in I?A=I.version:A=I.entry,R[w]={matchedVersion:A},R},{}))||{}),Object.keys(o).forEach(R=>l[R]={matchedVersion:i.includes(R)?n[R]:o[R]});const{remoteEntry:{path:u,name:h,type:p},types:d={path:"",name:"",zip:"",api:""},buildInfo:{buildVersion:m},globalName:y,ssrRemoteEntry:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vue=require("vue"),VueRouter=require("vue-router");function _interopNamespaceDefault(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>r[o]})}}return t.default=r,Object.freeze(t)}const Vue__namespace=_interopNamespaceDefault(Vue),VueRouter__namespace=_interopNamespaceDefault(VueRouter),MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",SEPARATOR=":";function isBrowserEnv(){return typeof window<"u"&&typeof window.document<"u"}function isReactNativeEnv(){return typeof navigator<"u"&&(navigator==null?void 0:navigator.product)==="ReactNative"}function isBrowserDebug(){try{if(isBrowserEnv()&&window.localStorage)return!!localStorage.getItem(BROWSER_LOG_KEY)}catch{return!1}return!1}function isDebugMode(){return typeof process<"u"&&process.env&&process.env.FEDERATION_DEBUG?!!process.env.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&FEDERATION_DEBUG?!0:isBrowserDebug()}const LOG_CATEGORY$1="[ Federation Runtime ]",composeKeyWithSeparator=function(...r){return r.length?r.reduce((t,o)=>o?t?`${t}${SEPARATOR}${o}`:o:t,""):""},getResourceUrl=(r,t)=>{if("getPublicPath"in r){let o;return r.getPublicPath.startsWith("function")?o=new Function("return "+r.getPublicPath)()():o=new Function(r.getPublicPath)(),`${o}${t}`}else return"publicPath"in r?!isBrowserEnv()&&!isReactNativeEnv()&&"ssrPublicPath"in r?`${r.ssrPublicPath}${t}`:`${r.publicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",r,t),"")},warn$1=r=>{console.warn(`${LOG_CATEGORY$1}: ${r}`)};function safeToString(r){try{return JSON.stringify(r,null,2)}catch{return""}}const simpleJoinRemoteEntry=(r,t)=>{if(!r)return t;const n=(s=>{if(s===".")return"";if(s.startsWith("./"))return s.replace("./","");if(s.startsWith("/")){const a=s.slice(1);return a.endsWith("/")?a.slice(0,-1):a}return s})(r);return n?n.endsWith("/")?`${n}${t}`:`${n}/${t}`:t};function inferAutoPublicPath(r){return r.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(r,t={}){var S,_,T;const{remotes:o={},overrides:n={},version:s}=t;let a;const c=()=>"publicPath"in r.metaData?r.metaData.publicPath==="auto"&&s?inferAutoPublicPath(s):r.metaData.publicPath:r.metaData.getPublicPath,i=Object.keys(n);let l={};Object.keys(o).length||(l=((S=r.remotes)==null?void 0:S.reduce((R,I)=>{let A;const w=I.federationContainerName;return i.includes(w)?A=n[w]:"version"in I?A=I.version:A=I.entry,R[w]={matchedVersion:A},R},{}))||{}),Object.keys(o).forEach(R=>l[R]={matchedVersion:i.includes(R)?n[R]:o[R]});const{remoteEntry:{path:u,name:h,type:p},types:d={path:"",name:"",zip:"",api:""},buildInfo:{buildVersion:m},globalName:y,ssrRemoteEntry:E}=r.metaData,{exposes:g}=r;let b={version:s||"",buildVersion:m,globalName:y,remoteEntry:simpleJoinRemoteEntry(u,h),remoteEntryType:p,remoteTypes:simpleJoinRemoteEntry(d.path,d.name),remoteTypesZip:d.zip||"",remoteTypesAPI:d.api||"",remotesInfo:l,shared:r==null?void 0:r.shared.map(R=>({assets:R.assets,sharedName:R.name,version:R.version})),modules:g==null?void 0:g.map(R=>({moduleName:R.name,modulePath:R.path,assets:R.assets}))};if((_=r.metaData)!=null&&_.prefetchInterface){const R=r.metaData.prefetchInterface;b={...b,prefetchInterface:R}}if((T=r.metaData)!=null&&T.prefetchEntry){const{path:R,name:I,type:A}=r.metaData.prefetchEntry;b={...b,prefetchEntry:simpleJoinRemoteEntry(R,I),prefetchEntryType:A}}if("publicPath"in r.metaData?a={...b,publicPath:c(),ssrPublicPath:r.metaData.ssrPublicPath}:a={...b,getPublicPath:c()},E){const R=simpleJoinRemoteEntry(E.path,E.name);a.ssrRemoteEntry=R,a.ssrRemoteEntryType=E.type||"commonjs-module"}return a}function isManifestProvider(r){return!!("remoteEntry"in r&&r.remoteEntry.includes(MANIFEST_EXT))}const PREFIX="[ Module Federation ]",DEFAULT_DELEGATE=console,LOGGER_STACK_SKIP_TOKENS=["logger.ts","logger.js","captureStackTrace","Logger.emit","Logger.log","Logger.info","Logger.warn","Logger.error","Logger.debug"];function captureStackTrace(){try{const r=new Error().stack;if(!r)return;const[,...t]=r.split(`
|
|
2
|
+
`),o=t.filter(s=>!LOGGER_STACK_SKIP_TOKENS.some(a=>s.includes(a)));return o.length?`Stack trace:
|
|
3
|
+
${o.slice(0,5).join(`
|
|
4
|
+
`)}`:void 0}catch{return}}class Logger{constructor(t,o=DEFAULT_DELEGATE){this.prefix=t,this.delegate=o??DEFAULT_DELEGATE}setPrefix(t){this.prefix=t}setDelegate(t){this.delegate=t??DEFAULT_DELEGATE}emit(t,o){const n=this.delegate,a=isDebugMode()?captureStackTrace():void 0,c=a?[...o,a]:o,i=(()=>{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 l of i){const u=n[l];if(typeof u=="function"){u.call(n,this.prefix,...c);return}}for(const l of i){const u=DEFAULT_DELEGATE[l];if(typeof u=="function"){u.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(o){warn$1(o);return}}function isStaticResourcesEqual(r,t){const o=/^(https?:)?\/\//i,n=r.replace(o,"").replace(/\/$/,""),s=t.replace(o,"").replace(/\/$/,"");return n===s}function createScript(r){let t=null,o=!0,n=2e4,s;const a=document.getElementsByTagName("script");for(let i=0;i<a.length;i++){const l=a[i],u=l.getAttribute("src");if(u&&isStaticResourcesEqual(u,r.url)){t=l,o=!1;break}}if(!t){const i=r.attrs;t=document.createElement("script"),t.type=(i==null?void 0:i.type)==="module"?"module":"text/javascript";let l;r.createScriptHook&&(l=r.createScriptHook(r.url,r.attrs),l instanceof HTMLScriptElement?t=l:typeof l=="object"&&("script"in l&&l.script&&(t=l.script),"timeout"in l&&l.timeout&&(n=l.timeout))),t.src||(t.src=r.url),i&&!l&&Object.keys(i).forEach(u=>{t&&(u==="async"||u==="defer"?t[u]=i[u]:t.getAttribute(u)||t.setAttribute(u,i[u]))})}const c=async(i,l)=>{clearTimeout(s);const u=()=>{(l==null?void 0:l.type)==="error"?r!=null&&r.onErrorCallback&&(r==null||r.onErrorCallback(l)):r!=null&&r.cb&&(r==null||r.cb())};if(t&&(t.onerror=null,t.onload=null,safeWrapper(()=>{const{needDeleteScript:h=!0}=r;h&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),i&&typeof i=="function")){const h=i(l);if(h instanceof Promise){const p=await h;return u(),p}return u(),h}u()};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.`))},n),{script:t,needAttach:o}}function createLink(r){let t=null,o=!0;const n=document.getElementsByTagName("link");for(let a=0;a<n.length;a++){const c=n[a],i=c.getAttribute("href"),l=c.getAttribute("rel");if(i&&isStaticResourcesEqual(i,r.url)&&l===r.attrs.rel){t=c,o=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",r.url);let a;const c=r.attrs;r.createLinkHook&&(a=r.createLinkHook(r.url,c),a instanceof HTMLLinkElement&&(t=a)),c&&!a&&Object.keys(c).forEach(i=>{t&&!t.getAttribute(i)&&t.setAttribute(i,c[i])})}const s=(a,c)=>{const i=()=>{(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:l=!0}=r;l&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),a)){const l=a(c);return i(),l}i()};return t.onerror=s.bind(null,t.onerror),t.onload=s.bind(null,t.onload),{link:t,needAttach:o}}function loadScript(r,t){const{attrs:o={},createScriptHook:n}=t;return new Promise((s,a)=>{const{script:c,needAttach:i}=createScript({url:r,cb:s,onErrorCallback:a,attrs:{fetchpriority:"high",...o},createScriptHook:n,needDeleteScript:!0});i&&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 o=new Function("name","return import(name)")(r).then(n=>n).catch(n=>{throw console.error(`Error importing module ${r}:`,n),sdkImportCache.delete(r),n});return sdkImportCache.set(r,o),o}const loadNodeFetch=async()=>{const r=await importNodeModule("node-fetch");return r.default||r},lazyLoaderHookFetch=async(r,t,o)=>{const s=await((a,c)=>o.lifecycle.fetch.emit(a,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}
|
|
2
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,o,n)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},loadScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(r,t)=>new Promise((o,n)=>{createScriptNode(r,(s,a)=>{var c,i;if(s)n(s);else{const l=((c=t==null?void 0:t.attrs)==null?void 0:c.globalName)||`__FEDERATION_${(i=t==null?void 0:t.attrs)==null?void 0:i.name}:custom__`,u=globalThis[l]=a;o(u)}},t.attrs,t.loaderHook)}):(r,t)=>{throw new Error("loadScriptNode is disabled in non-Node.js environment")},esmModuleCache=new Map;async function loadModule(r,t){if(esmModuleCache.has(r))return esmModuleCache.get(r);const{fetch:o,vm:n}=t,a=await(await o(r)).text(),c=new n.SourceTextModule(a,{importModuleDynamically:async(i,l)=>{const u=new URL(i,r).href;return loadModule(u,t)}});return esmModuleCache.set(r,c),await c.link(async i=>{const l=new URL(i,r).href;return await loadModule(l,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}`,getShortErrorMsg=(r,t,o,n)=>{const s=[`${[t[r]]} #${r}`];return o&&s.push(`args: ${JSON.stringify(o)}`),s.push(getDocsUrl(r)),n&&s.push(`Original Error Message:
|
|
3
6
|
${n}`),s.join(`
|
|
4
|
-
`)},runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot.",[RUNTIME_008]:"Failed to load script resources.",[RUNTIME_009]:"Please call createInstance first."},LOG_CATEGORY="[ Federation Runtime ]",logger=createLogger(LOG_CATEGORY);function assert(r,t){r||error(t)}function error(r){throw r instanceof Error?(r.message.startsWith(LOG_CATEGORY)||(r.message=`${LOG_CATEGORY}: ${r.message}`),r):new Error(`${LOG_CATEGORY}: ${r}`)}function warn(r){r instanceof Error&&(r.message.startsWith(LOG_CATEGORY)||(r.message=`${LOG_CATEGORY}: ${r.message}`)),logger.warn(r)}function addUniqueItem(r,t){return r.findIndex(o=>o===t)===-1&&r.push(t),r}function getFMId(r){return"version"in r&&r.version?`${r.name}:${r.version}`:"entry"in r&&r.entry?`${r.name}:${r.entry}`:`${r.name}`}function isRemoteInfoWithEntry(r){return typeof r.entry<"u"}function isPureRemoteEntry(r){return!r.entry.includes(".json")}function isObject(r){return r&&typeof r=="object"}const objectToString=Object.prototype.toString;function isPlainObject(r){return objectToString.call(r)==="[object Object]"}function arrayOptions(r){return Array.isArray(r)?r:[r]}function getRemoteEntryInfoFromSnapshot(r){const t={url:"",type:"global",globalName:""};return isBrowserEnv()||isReactNativeEnv()?"remoteEntry"in r?{url:r.remoteEntry,type:r.remoteEntryType,globalName:r.globalName}:t:"ssrRemoteEntry"in r?{url:r.ssrRemoteEntry||t.url,type:r.ssrRemoteEntryType||t.type,globalName:r.globalName}:t}const processModuleAlias=(r,t)=>{let o;return r.endsWith("/")?o=r.slice(0,-1):o=r,t.startsWith(".")&&(t=t.slice(1)),o=o+t,o},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(r,t,o){Object.defineProperty(r,t,{value:o,configurable:!1,writable:!0})}function includeOwnProperty(r,t){return Object.hasOwnProperty.call(r,t)}includeOwnProperty(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(r){var t,o,n,s,a,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__=[]),(o=r.__FEDERATION__).__INSTANCES__??(o.__INSTANCES__=[]),(n=r.__FEDERATION__).moduleInfo??(n.moduleInfo={}),(s=r.__FEDERATION__).__SHARE__??(s.__SHARE__={}),(a=r.__FEDERATION__).__MANIFEST_LOADING__??(a.__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-refactor-manifest-20251017070814")}function getInfoWithoutType(r,t){if(typeof t=="string"){if(r[t])return{value:r[t],key:t};{const n=Object.keys(r);for(const s of n){const[a,c]=s.split(":"),i=`${a}:${t}`,l=r[i];if(l)return{value:l,key:i}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(r,t)=>{const o=getFMId(r),n=getInfoWithoutType(t,o).value;if(n&&!n.version&&"version"in r&&r.version&&(n.version=r.version),n)return n;if("version"in r&&r.version){const{version:s,...a}=r,c=getFMId(a),i=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,c).value;if((i==null?void 0:i.version)===s)return i}},getGlobalSnapshotInfoByModuleInfo=r=>getTargetSnapshotInfoByModuleInfo(r,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(r,t)=>{const o=getFMId(r);return nativeGlobal.__FEDERATION__.moduleInfo[o]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=r=>(nativeGlobal.__FEDERATION__.moduleInfo={...nativeGlobal.__FEDERATION__.moduleInfo,...r},()=>{const t=Object.keys(r);for(const o of t)delete nativeGlobal.__FEDERATION__.moduleInfo[o]}),getRemoteEntryExports=(r,t)=>{const o=t||`__FEDERATION_${r}:custom__`,n=CurrentGlobal[o];return{remoteEntryKey:o,entryExports:n}},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=r=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(r),setPreloaded=r=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(r,!0),DEFAULT_SCOPE="default",DEFAULT_REMOTE_TYPE="global",buildIdentifier="[0-9A-Za-z-]+",build=`(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`,numericIdentifier="0|[1-9]\\d*",numericIdentifierLoose="[0-9]+",nonNumericIdentifier="\\d*[a-zA-Z-][a-zA-Z0-9-]*",preReleaseIdentifierLoose=`(?:${numericIdentifierLoose}|${nonNumericIdentifier})`,preReleaseLoose=`(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`,preReleaseIdentifier=`(?:${numericIdentifier}|${nonNumericIdentifier})`,preRelease=`(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`,xRangeIdentifier=`${numericIdentifier}|x|X|\\*`,xRangePlain=`[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`,hyphenRange=`^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`,mainVersionLoose=`(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`,loosePlain=`[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`,gtlt="((?:<|>)?=?)",comparatorTrim=`(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`,loneTilde="(?:~>?)",tildeTrim=`(\\s*)${loneTilde}\\s+`,loneCaret="(?:\\^)",caretTrim=`(\\s*)${loneCaret}\\s+`,star="(<|>)?=?\\s*\\*",caret=`^${loneCaret}${xRangePlain}$`,mainVersion=`(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`,fullPlain=`v?${mainVersion}${preRelease}?${build}?`,tilde=`^${loneTilde}${xRangePlain}$`,xRange=`^${gtlt}\\s*${xRangePlain}$`,comparator=`^${gtlt}\\s*(${fullPlain})$|^$`,gte0="^\\s*>=\\s*0.0.0\\s*$";function parseRegex(r){return new RegExp(r)}function isXVersion(r){return!r||r.toLowerCase()==="x"||r==="*"}function pipe(...r){return t=>r.reduce((o,n)=>n(o),t)}function extractComparator(r){return r.match(parseRegex(comparator))}function combineVersion(r,t,o,n){const s=`${r}.${t}.${o}`;return n?`${s}-${n}`:s}function parseHyphen(r){return r.replace(parseRegex(hyphenRange),(t,o,n,s,a,c,i,l,u,h,p,d)=>(isXVersion(n)?o="":isXVersion(s)?o=`>=${n}.0.0`:isXVersion(a)?o=`>=${n}.${s}.0`:o=`>=${o}`,isXVersion(u)?l="":isXVersion(h)?l=`<${Number(u)+1}.0.0-0`:isXVersion(p)?l=`<${u}.${Number(h)+1}.0-0`:d?l=`<=${u}.${h}.${p}-${d}`:l=`<=${l}`,`${o} ${l}`.trim()))}function parseComparatorTrim(r){return r.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(r){return r.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(r){return r.replace(parseRegex(caretTrim),"$1^")}function parseCarets(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(caret),(o,n,s,a,c)=>isXVersion(n)?"":isXVersion(s)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:isXVersion(a)?n==="0"?`>=${n}.${s}.0 <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.0 <${Number(n)+1}.0.0-0`:c?n==="0"?s==="0"?`>=${n}.${s}.${a}-${c} <${n}.${s}.${Number(a)+1}-0`:`>=${n}.${s}.${a}-${c} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a}-${c} <${Number(n)+1}.0.0-0`:n==="0"?s==="0"?`>=${n}.${s}.${a} <${n}.${s}.${Number(a)+1}-0`:`>=${n}.${s}.${a} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a} <${Number(n)+1}.0.0-0`)).join(" ")}function parseTildes(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(o,n,s,a,c)=>isXVersion(n)?"":isXVersion(s)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:isXVersion(a)?`>=${n}.${s}.0 <${n}.${Number(s)+1}.0-0`:c?`>=${n}.${s}.${a}-${c} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a} <${n}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(r){return r.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(o,n,s,a,c,i)=>{const l=isXVersion(s),u=l||isXVersion(a),h=u||isXVersion(c);return n==="="&&h&&(n=""),i="",l?n===">"||n==="<"?"<0.0.0-0":"*":n&&h?(u&&(a=0),c=0,n===">"?(n=">=",u?(s=Number(s)+1,a=0,c=0):(a=Number(a)+1,c=0)):n==="<="&&(n="<",u?s=Number(s)+1:a=Number(a)+1),n==="<"&&(i="-0"),`${n+s}.${a}.${c}${i}`):u?`>=${s}.0.0${i} <${Number(s)+1}.0.0-0`:h?`>=${s}.${a}.0${i} <${s}.${Number(a)+1}.0-0`:o})).join(" ")}function parseStar(r){return r.trim().replace(parseRegex(star),"")}function parseGTE0(r){return r.trim().replace(parseRegex(gte0),"")}function compareAtom(r,t){return r=Number(r)||r,t=Number(t)||t,r>t?1:r===t?0:-1}function comparePreRelease(r,t){const{preRelease:o}=r,{preRelease:n}=t;if(o===void 0&&n)return 1;if(o&&n===void 0)return-1;if(o===void 0&&n===void 0)return 0;for(let s=0,a=o.length;s<=a;s++){const c=o[s],i=n[s];if(c!==i)return c===void 0&&i===void 0?0:c?i?compareAtom(c,i):-1:1}return 0}function compareVersion(r,t){return compareAtom(r.major,t.major)||compareAtom(r.minor,t.minor)||compareAtom(r.patch,t.patch)||comparePreRelease(r,t)}function eq(r,t){return r.version===t.version}function compare(r,t){switch(r.operator){case"":case"=":return eq(r,t);case">":return compareVersion(r,t)<0;case">=":return eq(r,t)||compareVersion(r,t)<0;case"<":return compareVersion(r,t)>0;case"<=":return eq(r,t)||compareVersion(r,t)>0;case void 0:return!0;default:return!1}}function parseComparatorString(r){return pipe(parseCarets,parseTildes,parseXRanges,parseStar)(r)}function parseRange(r){return pipe(parseHyphen,parseComparatorTrim,parseTildeTrim,parseCaretTrim)(r.trim()).split(/\s+/).join(" ")}function satisfy(r,t){if(!r)return!1;const o=extractComparator(r);if(!o)return!1;const[,n,,s,a,c,i]=o,l={operator:n,version:combineVersion(s,a,c,i),major:s,minor:a,patch:c,preRelease:i==null?void 0:i.split(".")},u=t.split("||");for(const h of u){const p=h.trim();if(!p||p==="*"||p==="x")return!0;try{const d=parseRange(p);if(!d.trim())return!0;const m=d.split(" ").map(E=>parseComparatorString(E)).join(" ");if(!m.trim())return!0;const y=m.split(/\s+/).map(E=>parseGTE0(E)).filter(Boolean);if(y.length===0)continue;let g=!0;for(const E of y){const b=extractComparator(E);if(!b){g=!1;break}const[,S,,_,T,R,I]=b,A={operator:S,version:combineVersion(_,T,R,I),major:_,minor:T,patch:R,preRelease:I==null?void 0:I.split(".")};if(!compare(A,l)){g=!1;break}}if(g)return!0}catch(d){console.error(`[semver] Error processing range part "${p}":`,d);continue}}return!1}function formatShare(r,t,o,n){let s;return"get"in r?s=r.get:"lib"in r?s=()=>Promise.resolve(r.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${o}'!`)}),{deps:[],useIn:[],from:t,loading:null,...r,shareConfig:{requiredVersion:`^${r.version}`,singleton:!1,eager:!1,strictVersion:!1,...r.shareConfig},get:s,loaded:r!=null&&r.loaded||"lib"in r?!0:void 0,version:r.version??"0",scope:Array.isArray(r.scope)?r.scope:[r.scope??"default"],strategy:(r.strategy??n)||"version-first"}}function formatShareConfigs(r,t){const o=t.shared||{},n=t.name,s=Object.keys(o).reduce((c,i)=>{const l=arrayOptions(o[i]);return c[i]=c[i]||[],l.forEach(u=>{c[i].push(formatShare(u,n,i,t.shareStrategy))}),c},{}),a={...r.shared};return Object.keys(s).forEach(c=>{a[c]?s[c].forEach(i=>{a[c].find(u=>u.version===i.version)||a[c].push(i)}):a[c]=s[c]}),{shared:a,shareInfos:s}}function versionLt(r,t){const o=n=>{if(!Number.isNaN(Number(n))){const a=n.split(".");let c=n;for(let i=0;i<3-a.length;i++)c+=".0";return c}return n};return!!satisfy(o(r),`<=${o(t)}`)}const findVersion=(r,t)=>{const o=t||function(n,s){return versionLt(n,s)};return Object.keys(r).reduce((n,s)=>!n||o(n,s)||n==="0"?s:n,0)},isLoaded=r=>!!r.loaded||typeof r.lib=="function",isLoading=r=>!!r.loading;function findSingletonVersionOrderByVersion(r,t,o){const n=r[t][o],s=function(a,c){return!isLoaded(n[a])&&versionLt(a,c)};return findVersion(r[t][o],s)}function findSingletonVersionOrderByLoaded(r,t,o){const n=r[t][o],s=function(a,c){const i=l=>isLoaded(l)||isLoading(l);return i(n[c])?i(n[a])?!!versionLt(a,c):!0:i(n[a])?!1:versionLt(a,c)};return findVersion(r[t][o],s)}function getFindShareFunction(r){return r==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(r,t,o,n){if(!r)return;const{shareConfig:s,scope:a=DEFAULT_SCOPE,strategy:c}=o,i=Array.isArray(a)?a:[a];for(const l of i)if(s&&r[l]&&r[l][t]){const{requiredVersion:u}=s,p=getFindShareFunction(c)(r,l,t),d=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(p,u)){const g=`Version ${p} from ${p&&r[l][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;s.strictVersion?error(g):warn(g)}return r[l][t][p]}else{if(u===!1||u==="*"||satisfy(p,u))return r[l][t][p];for(const[g,E]of Object.entries(r[l][t]))if(satisfy(g,u))return E}},m={shareScopeMap:r,scope:l,pkgName:t,version:p,GlobalFederation:Global.__FEDERATION__,resolver:d};return(n.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(r){const{pkgName:t,extraOptions:o,shareInfos:n}=r,s=c=>{if(!c)return;const i={};c.forEach(h=>{i[h.version]=h});const u=findVersion(i,function(h,p){return!isLoaded(i[h])&&versionLt(h,p)});return i[u]},a=(o==null?void 0:o.resolver)??s;return Object.assign({},a(n[t]),o==null?void 0:o.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(r,t){for(const o of r){const n=t.startsWith(o.name);let s=t.replace(o.name,"");if(n){if(s.startsWith("/")){const i=o.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:o}}else if(s==="")return{pkgNameOrAlias:o.name,expose:".",remote:o}}const a=o.alias&&t.startsWith(o.alias);let c=o.alias&&t.replace(o.alias,"");if(o.alias&&a){if(c&&c.startsWith("/")){const i=o.alias;return c=`.${c}`,{pkgNameOrAlias:i,expose:c,remote:o}}else if(c==="")return{pkgNameOrAlias:o.alias,expose:".",remote:o}}}}function matchRemote(r,t){for(const o of r)if(t===o.name||o.alias&&t===o.alias)return o}function registerPlugins(r,t){const o=getGlobalHostPlugins(),n=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return o.length>0&&o.forEach(s=>{r!=null&&r.find(a=>a.name!==s.name)&&r.push(s)}),r&&r.length>0&&r.forEach(s=>{n.forEach(a=>{a.applyPlugin(s,t)})}),r}const importCallback=".then(callbacks[0]).catch(callbacks[1])";async function loadEsmEntry({entry:r,remoteEntryExports:t}){return new Promise((o,n)=>{try{t?o(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${r}")${importCallback}`)([o,n]):import(r).then(o).catch(n)}catch(s){n(s)}})}async function loadSystemJsEntry({entry:r,remoteEntryExports:t}){return new Promise((o,n)=>{try{t?o(t):typeof __system_context__>"u"?System.import(r).then(o).catch(n):new Function("callbacks",`System.import("${r}")${importCallback}`)([o,n])}catch(s){n(s)}})}function handleRemoteEntryLoaded(r,t,o){const{remoteEntryKey:n,entryExports:s}=getRemoteEntryExports(r,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:r,remoteEntryUrl:o,remoteEntryKey:n})),s}async function loadEntryScript({name:r,globalName:t,entry:o,loaderHook:n,getEntryUrl:s}){const{entryExports:a}=getRemoteEntryExports(r,t);if(a)return a;const c=s?s(o):o;return loadScript(c,{attrs:{},createScriptHook:(i,l)=>{const u=n.lifecycle.createScript.emit({url:i,attrs:l});if(u&&(u instanceof HTMLScriptElement||"script"in u||"timeout"in u))return u}}).then(()=>handleRemoteEntryLoaded(r,t,o)).catch(i=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:r,resourceUrl:o})),i})}async function loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:o,getEntryUrl:n}){const{entry:s,entryGlobalName:a,name:c,type:i}=r;switch(i){case"esm":case"module":return loadEsmEntry({entry:s,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:s,remoteEntryExports:t});default:return loadEntryScript({entry:s,globalName:a,name:c,loaderHook:o,getEntryUrl:n})}}async function loadEntryNode({remoteInfo:r,loaderHook:t}){const{entry:o,entryGlobalName:n,name:s,type:a}=r,{entryExports:c}=getRemoteEntryExports(s,n);return c||loadScriptNode(o,{attrs:{name:s,globalName:n,type:a},loaderHook:{createScriptHook:(i,l={})=>{const u=t.lifecycle.createScript.emit({url:i,attrs:l});if(u&&"url"in u)return u}}}).then(()=>handleRemoteEntryLoaded(s,n,o)).catch(i=>{throw i})}function getRemoteEntryUniqueKey(r){const{entry:t,name:o}=r;return composeKeyWithSeparator(o,t)}async function getRemoteEntry(r){const{origin:t,remoteEntryExports:o,remoteInfo:n,getEntryUrl:s,_inErrorHandling:a=!1}=r,c=getRemoteEntryUniqueKey(n);if(o)return o;if(!globalLoading[c]){const i=t.remoteHandler.hooks.lifecycle.loadEntry,l=t.loaderHook;globalLoading[c]=i.emit({loaderHook:l,remoteInfo:n,remoteEntryExports:o}).then(u=>u||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:n,remoteEntryExports:o,loaderHook:l,getEntryUrl:s}):loadEntryNode({remoteInfo:n,loaderHook:l}))).catch(async u=>{const h=getRemoteEntryUniqueKey(n);if(u instanceof Error&&u.message.includes(RUNTIME_008)&&!a){const d=y=>getRemoteEntry({...y,_inErrorHandling:!0}),m=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:d,origin:t,remoteInfo:n,remoteEntryExports:o,globalLoading,uniqueKey:h});if(m)return m}throw u})}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(o=>{const n=matchRemote(r,o.nameOrAlias);return assert(n,`Unable to preload ${o.nameOrAlias} as it is not included in ${!n&&safeToString({remoteInfo:n,remotes:r})}`),{remote:n,preloadConfig:defaultPreloadArgs(o)}})}function normalizePreloadExposes(r){return r?r.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(r,t,o,n=!0){const{cssAssets:s,jsAssetsWithoutEntry:a,entryAssets:c}=o;if(t.options.inBrowser){if(c.forEach(i=>{const{moduleInfo:l}=i,u=t.moduleCache.get(r.name);getRemoteEntry(u?{origin:t,remoteInfo:l,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:l,remoteEntryExports:void 0})}),n){const i={rel:"preload",as:"style"};s.forEach(l=>{const{link:u,needAttach:h}=createLink({url:l,cb:()=>{},attrs:i,createLinkHook:(p,d)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:d});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(l=>{const{link:u,needAttach:h}=createLink({url:l,cb:()=>{},attrs:i,createLinkHook:(p,d)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:d});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});h&&document.head.appendChild(u)})}if(n){const i={rel:"preload",as:"script"};a.forEach(l=>{const{link:u,needAttach:h}=createLink({url:l,cb:()=>{},attrs:i,createLinkHook:(p,d)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:d});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={fetchpriority:"high",type:(r==null?void 0:r.type)==="module"?"module":"text/javascript"};a.forEach(l=>{const{script:u,needAttach:h}=createScript({url:l,cb:()=>{},attrs:i,createScriptHook:(p,d)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:p,attrs:d});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});h&&document.head.appendChild(u)})}}}class Module{constructor({remoteInfo:t,host:o}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=o}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let t;return t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports}),assert(t,`remoteEntryExports is undefined
|
|
5
|
-
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,o,n,s){const{loadFactory:a=!0}=n||{loadFactory:!0},c=await this.getEntry();if(!this.inited){const p=this.host.shareScopeMap,d=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];d.length||d.push("default"),d.forEach(b=>{p[b]||(p[b]={})});const m=p[d[0]],y=[],g={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?d:this.remoteInfo.shareScope||"default"};Object.defineProperty(g,"shareScopeMap",{value:p,enumerable:!1});const E=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:g,initScope:y,remoteInfo:this.remoteInfo,origin:this.host});typeof(c==null?void 0:c.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await c.init(E.shareScope,E.initScope,E.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...E,id:t,remoteSnapshot:s,remoteEntryExports:c})}this.lib=c,this.inited=!0;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:c,expose:o,moduleInfo:this.remoteInfo}),i||(i=await c.get(o)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${o}.`);const l=processModuleAlias(this.remoteInfo.name,o),u=this.wraperFactory(i,l);return a?await u():u}wraperFactory(t,o){function n(s,a){s&&typeof s=="object"&&Object.isExtensible(s)&&!Object.getOwnPropertyDescriptor(s,Symbol.for("mf_module_id"))&&Object.defineProperty(s,Symbol.for("mf_module_id"),{value:a,enumerable:!1})}return t instanceof Promise?async()=>{const s=await t();return n(s,o),s}:()=>{const s=t();return n(s,o),s}}}class SyncHook{constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const o=this;this.on(function n(...s){return o.remove(n),t.apply(null,s)})}emit(...t){let o;return this.listeners.size>0&&this.listeners.forEach(n=>{o=n(...t)}),o}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}}class AsyncHook extends SyncHook{emit(...t){let o;const n=Array.from(this.listeners);if(n.length>0){let s=0;const a=c=>c===!1?!1:s<n.length?Promise.resolve(n[s++].apply(null,t)).then(a):c;o=a()}return Promise.resolve(o)}}function checkReturnData(r,t){if(!isObject(t))return!1;if(r!==t){for(const o in r)if(!(o in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{constructor(t){super(),this.onerror=error,this.type=t}emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const o of this.listeners)try{const n=o(t);if(checkReturnData(t,n))t=n;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(n){warn(n),this.onerror(n)}return t}}class AsyncWaterfallHook extends SyncHook{constructor(t){super(),this.onerror=error,this.type=t}emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const o=Array.from(this.listeners);if(o.length>0){let n=0;const s=c=>(warn(c),this.onerror(c),t),a=c=>{if(checkReturnData(t,c)){if(t=c,n<o.length)try{return Promise.resolve(o[n++](t)).then(a,s)}catch(i){return s(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return t};return Promise.resolve(a(t))}return Promise.resolve(t)}}class PluginSystem{constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}applyPlugin(t,o){var s;assert(isPlainObject(t),"Plugin configuration is invalid.");const n=t.name;assert(n,"A name must be provided by the plugin."),this.registerPlugins[n]||(this.registerPlugins[n]=t,(s=t.apply)==null||s.call(t,o),Object.keys(this.lifecycle).forEach(a=>{const c=t[a];c&&this.lifecycle[a].on(c)}))}removePlugin(t){assert(t,"A name is required.");const o=this.registerPlugins[t];assert(o,`The plugin "${t}" is not registered.`),Object.keys(o).forEach(n=>{n!=="name"&&this.lifecycle[n].remove(o[n])})}}function assignRemoteInfo(r,t){const o=getRemoteEntryInfoFromSnapshot(t);o.url||error(`The attribute remoteEntry of ${r.name} must not be undefined.`);let n=getResourceUrl(t,o.url);!isBrowserEnv()&&!n.startsWith("http")&&(n=`https:${n}`),r.type=o.type,r.entryGlobalName=o.globalName,r.entry=n,r.version=t.version,r.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(r){const{remote:t,pkgNameOrAlias:o,expose:n,origin:s,remoteInfo:a,id:c}=r;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:i,globalSnapshot:l}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:c});assignRemoteInfo(a,i);const u={remote:t,preloadConfig:{nameOrAlias:o,exposes:[n],resourceCategory:"sync",share:!1,depsRemote:!1}},h=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:u,remoteInfo:a,remote:t,remoteSnapshot:i,globalSnapshot:l});return h&&preloadAssets(a,s,h,!1),{...r,remoteSnapshot:i}}return r}}}function splitId(r){const t=r.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function traverseModuleInfo(r,t,o,n,s={},a){const c=getFMId(t),{value:i}=getInfoWithoutType(r,c),l=a||i;if(l&&!isManifestProvider(l)&&(o(l,t,n),l.remotesInfo)){const u=Object.keys(l.remotesInfo);for(const h of u){if(s[h])continue;s[h]=!0;const p=splitId(h),d=l.remotesInfo[h];traverseModuleInfo(r,{name:p.name,version:d.matchedVersion},o,!1,s,void 0)}}}const isExisted=(r,t)=>document.querySelector(`${r}[${r==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(r,t,o,n,s){const a=[],c=[],i=[],l=new Set,u=new Set,{options:h}=r,{preloadConfig:p}=t,{depsRemote:d}=p;if(traverseModuleInfo(n,o,(E,b,S)=>{var w;let _;if(S)_=p;else if(Array.isArray(d)){const N=d.find($=>$.nameOrAlias===b.name||$.nameOrAlias===b.alias);if(!N)return;_=defaultPreloadArgs(N)}else if(d===!0)_=p;else return;const T=getResourceUrl(E,getRemoteEntryInfoFromSnapshot(E).url);T&&i.push({name:b.name,moduleInfo:{name:b.name,entry:T,type:"remoteEntryType"in E?E.remoteEntryType:"global",entryGlobalName:"globalName"in E?E.globalName:b.name,shareScope:"",version:"version"in E?E.version:void 0},url:T});let R="modules"in E?E.modules:[];const I=normalizePreloadExposes(_.exposes);I.length&&"modules"in E&&(R=(w=E==null?void 0:E.modules)==null?void 0:w.reduce((N,$)=>((I==null?void 0:I.indexOf($.moduleName))!==-1&&N.push($),N),[]));function A(N){const $=N.map(P=>getResourceUrl(E,P));return _.filter?$.filter(_.filter):$}if(R){const N=R.length;for(let $=0;$<N;$++){const P=R[$],M=`${b.name}/${P.moduleName}`;r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:P.moduleName==="."?b.name:M,name:b.name,remoteSnapshot:E,preloadConfig:_,remote:b,origin:r}),!getPreloaded(M)&&(_.resourceCategory==="all"?(a.push(...A(P.assets.css.async)),a.push(...A(P.assets.css.sync)),c.push(...A(P.assets.js.async)),c.push(...A(P.assets.js.sync))):(_.resourceCategory="sync")&&(a.push(...A(P.assets.css.sync)),c.push(...A(P.assets.js.sync))),setPreloaded(M))}}},!0,{},s),s.shared&&s.shared.length>0){const E=(b,S)=>{const _=getRegisteredShare(r.shareScopeMap,S.sharedName,b,r.sharedHandler.hooks.lifecycle.resolveShare);_&&typeof _.lib=="function"&&(S.assets.js.sync.forEach(T=>{l.add(T)}),S.assets.css.sync.forEach(T=>{u.add(T)}))};s.shared.forEach(b=>{var R;const S=(R=h.shared)==null?void 0:R[b.sharedName];if(!S)return;const _=b.version?S.find(I=>I.version===b.version):S;if(!_)return;arrayOptions(_).forEach(I=>{E(I,b)})})}const y=c.filter(E=>!l.has(E)&&!isExisted("script",E));return{cssAssets:a.filter(E=>!u.has(E)&&!isExisted("link",E)),jsAssetsWithoutEntry:y,entryAssets:i.filter(E=>!isExisted("script",E.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(r){const{origin:t,preloadOptions:o,remoteInfo:n,remote:s,globalSnapshot:a,remoteSnapshot:c}=r;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:n.name,entry:s.entry,type:n.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(n,c),generatePreloadAssets(t,o,n,a,c)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(r,t){const o=getGlobalSnapshotInfoByModuleInfo({name:t.name,version:t.options.version}),n=o&&"remotesInfo"in o&&o.remotesInfo&&getInfoWithoutType(o.remotesInfo,r.name).value;return n&&n.matchedVersion?{hostGlobalSnapshot:o,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:n.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:"version"in r?r.version:void 0})}}class SnapshotHandler{constructor(t){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new PluginSystem({beforeLoadRemoteSnapshot:new AsyncHook("beforeLoadRemoteSnapshot"),loadSnapshot:new AsyncWaterfallHook("loadGlobalSnapshot"),loadRemoteSnapshot:new AsyncWaterfallHook("loadRemoteSnapshot"),afterLoadSnapshot:new AsyncWaterfallHook("afterLoadSnapshot")}),this.manifestLoading=Global.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=t,this.loaderHook=t.loaderHook}async loadRemoteSnapshotInfo({moduleInfo:t,id:o,expose:n}){const{options:s}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:s,moduleInfo:t});let a=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});a||(a={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:a})),a&&"remotesInfo"in a&&!getInfoWithoutType(a.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(a.remotesInfo={...a==null?void 0:a.remotesInfo,[t.name]:{matchedVersion:"version"in t?t.version:t.entry}});const{hostGlobalSnapshot:c,remoteSnapshot:i,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:u,globalSnapshot:h}=await this.hooks.lifecycle.loadSnapshot.emit({options:s,moduleInfo:t,hostGlobalSnapshot:c,remoteSnapshot:i,globalSnapshot:l});let p,d;if(u)if(isManifestProvider(u)){const m=isBrowserEnv()?u.remoteEntry:u.ssrRemoteEntry||u.remoteEntry||"",y=await this.getManifestJson(m,t,{}),g=setGlobalSnapshotInfoByModuleInfo({...t,entry:m},y);p=y,d=g}else{const{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:u,from:"global"});p=m,d=h}else if(isRemoteInfoWithEntry(t)){const m=await this.getManifestJson(t.entry,t,{}),y=setGlobalSnapshotInfoByModuleInfo(t,m),{remoteSnapshot:g}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:m,from:"global"});p=g,d=y}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(h)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:o,host:this.HostInstance,options:s,moduleInfo:t,remoteSnapshot:p}),{remoteSnapshot:p,globalSnapshot:d}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,o,n){const s=async()=>{let c=this.manifestCache.get(t);if(c)return c;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});(!i||!(i instanceof Response))&&(i=await fetch(t,{})),c=await i.json()}catch(i){c=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),c||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:o.name,hostName:this.HostInstance.options.name},`${i}`)))}return assert(c.metaData&&c.exposes&&c.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,c),c},a=async()=>{const c=await s(),i=generateSnapshotFromManifest(c,{version:t}),{remoteSnapshot:l}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:o,manifestJson:c,remoteSnapshot:i,manifestUrl:t,from:"manifest"});return l};return this.manifestLoading[t]||(this.manifestLoading[t]=a().then(c=>c)),this.manifestLoading[t]}}class SharedHandler{constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}registerShared(t,o){const{shareInfos:n,shared:s}=formatShareConfigs(t,o);return Object.keys(n).forEach(c=>{n[c].forEach(l=>{!getRegisteredShare(this.shareScopeMap,c,l,this.hooks.lifecycle.resolveShare)&&l&&l.lib&&this.setShared({pkgName:c,lib:l.lib,get:l.get,loaded:!0,shared:l,from:o.name})})}),{shareInfos:n,shared:s}}async loadShare(t,o){const{host:n}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:n.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const a=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:n.options.shared,origin:n}),{shareInfo:c}=a;assert(c,`Cannot find ${t} Share in the ${n.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,c,this.hooks.lifecycle.resolveShare),l=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,n.options.name)};if(i&&i.lib)return l(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),l(i),u}else if(i){const h=(async()=>{const p=await i.get();return l(i),i.loaded=!0,i.lib=p,p})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:n.options.name,lib:null,loading:h}),h}else{if(o!=null&&o.customShareInfo)return!1;const h=(async()=>{const p=await c.get();c.lib=p,c.loaded=!0,l(c);const d=getRegisteredShare(this.shareScopeMap,t,c,this.hooks.lifecycle.resolveShare);return d&&(d.lib=p,d.loaded=!0,d.from=c.from),p})();return this.setShared({pkgName:t,loaded:!1,shared:c,from:n.options.name,lib:null,loading:h}),h}}initializeSharing(t=DEFAULT_SCOPE,o){const{host:n}=this,s=o==null?void 0:o.from,a=o==null?void 0:o.strategy;let c=o==null?void 0:o.initScope;const i=[];if(s!=="build"){const{initTokens:y}=this;c||(c=[]);let g=y[t];if(g||(g=y[t]={from:this.host.name}),c.indexOf(g)>=0)return i;c.push(g)}const l=this.shareScopeMap,u=n.options.name;l[t]||(l[t]={});const h=l[t],p=(y,g)=>{var R;const{version:E,eager:b}=g;h[y]=h[y]||{};const S=h[y],_=S[E],T=!!(_&&(_.eager||(R=_.shareConfig)!=null&&R.eager));(!_||_.strategy!=="loaded-first"&&!_.loaded&&(!b!=!T?b:u>_.from))&&(S[E]=g)},d=y=>y&&y.init&&y.init(l[t],c),m=async y=>{const{module:g}=await n.remoteHandler.getRemoteModuleAndOptions({id:y});if(g.getEntry){let E;try{E=await g.getEntry()}catch(b){E=await n.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:y,error:b,from:"runtime",lifecycle:"beforeLoadShare",origin:n})}g.inited||(await d(E),g.inited=!0)}};return Object.keys(n.options.shared).forEach(y=>{n.options.shared[y].forEach(E=>{E.scope.includes(t)&&p(y,E)})}),(n.options.shareStrategy==="version-first"||a==="version-first")&&n.options.remotes.forEach(y=>{y.shareScope===t&&i.push(m(y.name))}),i}loadShareSync(t,o){const{host:n}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:n.options.shared});s!=null&&s.scope&&s.scope.forEach(i=>{this.initializeSharing(i,{strategy:s.strategy})});const a=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),c=i=>{i.useIn||(i.useIn=[]),addUniqueItem(i.useIn,n.options.name)};if(a){if(typeof a.lib=="function")return c(a),a.loaded||(a.loaded=!0,a.from===n.options.name&&(s.loaded=!0)),a.lib;if(typeof a.get=="function"){const i=a.get();if(!(i instanceof Promise))return c(a),this.setShared({pkgName:t,loaded:!0,from:n.options.name,lib:i,shared:a}),i}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const i=s.get();if(i instanceof Promise){const l=(o==null?void 0:o.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(l,runtimeDescMap,{hostName:n.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:n.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:n.options.name,sharedPkgName:t}))}initShareScopeMap(t,o,n={}){const{host:s}=this;this.shareScopeMap[t]=o,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:o,options:s.options,origin:s,scopeName:t,hostShareScopeMap:n.hostShareScopeMap})}setShared({pkgName:t,shared:o,from:n,lib:s,loading:a,loaded:c,get:i}){const{version:l,scope:u="default",...h}=o;(Array.isArray(u)?u:[u]).forEach(d=>{if(this.shareScopeMap[d]||(this.shareScopeMap[d]={}),this.shareScopeMap[d][t]||(this.shareScopeMap[d][t]={}),!this.shareScopeMap[d][t][l]){this.shareScopeMap[d][t][l]={version:l,scope:["default"],...h,lib:s,loaded:c,loading:a},i&&(this.shareScopeMap[d][t][l].get=i);return}const m=this.shareScopeMap[d][t][l];a&&!m.loading&&(m.loading=a),c&&!m.loaded&&(m.loaded=c),n&&m.from!==n&&(m.from=n)})}_setGlobalShareScopeMap(t){const o=getGlobalShareScope(),n=t.id||t.name;n&&!o[n]&&(o[n]=this.shareScopeMap)}}class RemoteHandler{constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}formatAndRegisterRemote(t,o){return(o.remotes||[]).reduce((s,a)=>(this.registerRemote(a,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,o){const{remote:n,expose:s}=o,{name:a,alias:c}=n;if(this.idToRemoteMap[t]={name:n.name,expose:s},c&&t.startsWith(a)){const i=t.replace(a,c);this.idToRemoteMap[i]={name:n.name,expose:s};return}if(c&&t.startsWith(c)){const i=t.replace(c,a);this.idToRemoteMap[i]={name:n.name,expose:s}}}async loadRemote(t,o){const{host:n}=this;try{const{loadFactory:s=!0}=o||{loadFactory:!0},{module:a,moduleOptions:c,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:l,remote:u,expose:h,id:p,remoteSnapshot:d}=i,m=await a.get(p,h,o,d),y=await this.hooks.lifecycle.onLoad.emit({id:p,pkgNameOrAlias:l,expose:h,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:c,moduleInstance:a,origin:n});return this.setIdToRemoteMap(t,i),typeof y=="function"?y:m}catch(s){const{from:a="runtime"}=o||{from:"runtime"},c=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:a,lifecycle:"onLoad",origin:n});if(!c)throw s;return c}}async preloadRemote(t){const{host:o}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:o.options,origin:o});const n=formatPreloadArgs(o.options.remotes,t);await Promise.all(n.map(async s=>{const{remote:a}=s,c=getRemoteInfo(a),{globalSnapshot:i,remoteSnapshot:l}=await o.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:a}),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:s,remote:a,remoteInfo:c,globalSnapshot:i,remoteSnapshot:l});u&&preloadAssets(c,o,u)}))}registerRemotes(t,o){const{host:n}=this;t.forEach(s=>{this.registerRemote(s,n.options.remotes,{force:o==null?void 0:o.force})})}async getRemoteModuleAndOptions(t){const{host:o}=this,{id:n}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:n,options:o.options,origin:o})}catch(y){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:n,options:o.options,origin:o,from:"runtime",error:y,lifecycle:"beforeRequest"}),!s)throw y}const{id:a}=s,c=matchRemoteWithNameAndExpose(o.options.remotes,a);assert(c,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:o.options.name,requestId:a}));const{remote:i}=c,l=getRemoteInfo(i),u=await o.sharedHandler.hooks.lifecycle.afterResolve.emit({id:a,...c,options:o.options,origin:o,remoteInfo:l}),{remote:h,expose:p}=u;assert(h&&p,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);let d=o.moduleCache.get(h.name);const m={host:o,remoteInfo:l};return d||(d=new Module(m),o.moduleCache.set(h.name,d)),{module:d,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,o,n){const{host:s}=this,a=()=>{if(t.alias){const i=o.find(l=>{var u;return t.alias&&(l.name.startsWith(t.alias)||((u=l.alias)==null?void 0:u.startsWith(t.alias)))});assert(!i,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const c=o.find(i=>i.name===t.name);if(!c)a(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];n!=null&&n.force&&(this.removeRemote(c),a(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){var o;try{const{host:n}=this,{name:s}=t,a=n.options.remotes.findIndex(i=>i.name===s);a!==-1&&n.options.remotes.splice(a,1);const c=n.moduleCache.get(t.name);if(c){const i=c.remoteInfo,l=i.entryGlobalName;CurrentGlobal[l]&&((o=Object.getOwnPropertyDescriptor(CurrentGlobal,l))!=null&&o.configurable?delete CurrentGlobal[l]:CurrentGlobal[l]=void 0);const u=getRemoteEntryUniqueKey(c.remoteInfo);globalLoading[u]&&delete globalLoading[u],n.snapshotHandler.manifestCache.delete(i.entry);let h=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const p=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===h:m.name===h);if(p!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[p];h=m.options.id||h;const y=getGlobalShareScope();let g=!0;const E=[];Object.keys(y).forEach(b=>{const S=y[b];S&&Object.keys(S).forEach(_=>{const T=S[_];T&&Object.keys(T).forEach(R=>{const I=T[R];I&&Object.keys(I).forEach(A=>{const w=I[A];w&&typeof w=="object"&&w.from===i.name&&(w.loaded||w.loading?(w.useIn=w.useIn.filter(N=>N!==i.name),w.useIn.length?g=!1:E.push([b,_,R,A])):E.push([b,_,R,A]))})})})}),g&&(m.shareScopeMap={},delete y[h]),E.forEach(([b,S,_,T])=>{var R,I,A;(A=(I=(R=y[b])==null?void 0:R[S])==null?void 0:I[_])==null||delete A[T]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p,1)}const{hostGlobalSnapshot:d}=getGlobalRemoteInfo(t,n);if(d){const m=d&&"remotesInfo"in d&&d.remotesInfo&&getInfoWithoutType(d.remotesInfo,t.name).key;m&&(delete d.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}n.moduleCache.delete(t.name)}}catch(n){logger.log("removeRemote fail: ",n)}}}const USE_SNAPSHOT=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;class ModuleFederation{constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.0.0-refactor-manifest-20251017070814",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const o=USE_SNAPSHOT?[snapshotPlugin(),generatePreloadAssetsPlugin()]:[],n={id:getBuilderId(),name:t.name,plugins:o,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=n,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...n.plugins,...t.plugins||[]]),this.options=this.formatOptions(n,t)}initOptions(t){this.registerPlugins(t.plugins);const o=this.formatOptions(this.options,t);return this.options=o,o}async loadShare(t,o){return this.sharedHandler.loadShare(t,o)}loadShareSync(t,o){return this.sharedHandler.loadShareSync(t,o)}initializeSharing(t=DEFAULT_SCOPE,o){return this.sharedHandler.initializeSharing(t,o)}initRawContainer(t,o,n){const s=getRemoteInfo({name:t,entry:o}),a=new Module({host:this,remoteInfo:s});return a.remoteEntryExports=n,this.moduleCache.set(t,a),a}async loadRemote(t,o){return this.remoteHandler.loadRemote(t,o)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,o,n={}){this.sharedHandler.initShareScopeMap(t,o,n)}formatOptions(t,o){const{shared:n}=formatShareConfigs(t,o),{userOptions:s,options:a}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:o,options:t,shareInfo:n}),c=this.remoteHandler.formatAndRegisterRemote(a,s),{shared:i}=this.sharedHandler.registerShared(a,s),l=[...a.plugins];s.plugins&&s.plugins.forEach(h=>{l.includes(h)||l.push(h)});const u={...t,...o,plugins:l,remotes:c,shared:i};return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const o=registerPlugins(t,this);this.options.plugins=this.options.plugins.reduce((n,s)=>(s&&n&&!n.find(a=>a.name===s.name)&&n.push(s),n),o||[])}registerRemotes(t,o){return this.remoteHandler.registerRemotes(t,o)}registerShared(t){this.sharedHandler.registerShared(this.options,{...this.options,shared:t})}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(ModuleFederation);function addBasenameToNestedRoutes(r,t){return r.map(o=>{const n={...o,path:t+o.path};return o.children&&o.children.length>0&&(n.children=addBasenameToNestedRoutes(o.children,t)),n})}function processRoutes(r){const{router:t,basename:o,memoryRoute:n,hashRoute:s}=r,a=t.getRoutes().sort((d,m)=>d.path.split("/").filter(y=>y).length-m.path.split("/").filter(y=>y).length),c=new Map,i=new Set;a.forEach(d=>{c.set(d.path,d)});const l=(d,m)=>`${d}/${m}`.replace(/\/+/g,"/").replace(/\/$/,"")||"/",u=(d,m="")=>{if(!d.children||d.children.length===0)return d;for(let y=0;y<d.children.length;y++){const g=d.children[y],E=l(m,g.path),b=c.get(E);if(b&&!i.has(b)){const S={...b,path:g.path};d.children[y]=S,i.add(b),u(S,E)}}return d};let h=[];for(const d of a)if(!i.has(d)){const m=u(d,d.path);i.add(d),h.push(m)}let p;return n?p=VueRouter__namespace.createMemoryHistory(o):s?(p=VueRouter__namespace.createWebHashHistory(),o&&(h=addBasenameToNestedRoutes(h,o))):p=VueRouter__namespace.createWebHistory(o),{history:p,routes:h}}function createBridgeComponent(r){const t=new Map,o=getInstance();return()=>({__APP_VERSION__:"0.0.0-refactor-manifest-20251017070814",async render(n){var y,g,E;LoggerInstance.debug("createBridgeComponent render Info",n);const{moduleName:s,dom:a,basename:c,memoryRoute:i,hashRoute:l,...u}=n,h=Vue__namespace.createApp(r.rootComponent,u);t.set(a,h);const p=await((E=(g=(y=o==null?void 0:o.bridgeHook)==null?void 0:y.lifecycle)==null?void 0:g.beforeBridgeRender)==null?void 0:E.emit(n)),d=p&&typeof p=="object"&&(p!=null&&p.extraProps)?p==null?void 0:p.extraProps:{},m=r.appOptions({app:h,basename:c,memoryRoute:i,hashRoute:l,...u,...d});if(m!=null&&m.router){const{history:b,routes:S}=processRoutes({router:m.router,basename:n.basename,memoryRoute:n.memoryRoute,hashRoute:n.hashRoute}),_=VueRouter__namespace.createRouter({...m.router.options,history:b,routes:S});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:_}),i&&await _.push(i.entryPath),h.use(_)}h.mount(a)},destroy(n){LoggerInstance.debug("createBridgeComponent destroy Info",n);const s=t.get(n==null?void 0:n.dom);s==null||s.unmount()}})}function e(){const r=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(r)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(r){const t=Vue.ref(null),o=Vue.ref(null),n=Vue.ref(""),s=VueRouter.useRoute(),a=getInstance(),c=Vue.useAttrs(),i=async()=>{var d,m,y,g;const u=(d=r.providerInfo)==null?void 0:d.call(r);o.value=u;let h={...c,moduleName:r.moduleName,dom:t.value,basename:r.basename,memoryRoute:r.memoryRoute,hashRoute:r.hashRoute};LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",h);const p=await((g=(y=(m=a==null?void 0:a.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:y.beforeBridgeRender)==null?void 0:g.emit(h))||{};h={...h,...p.extraProps},u.render(h)},l=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&i(),n.value!==""&&n.value!==u&&(LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...r,pathname:s.path}),e()),n.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>",{...r}),l(),(u=o.value)==null||u.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(r.rootAttrs||{},{ref:t}),null)}});function createRemoteAppComponent(r){return Vue.defineAsyncComponent({__APP_VERSION__:"0.0.0-refactor-manifest-20251017070814",...r.asyncComponentOptions,loader:async()=>{var l,u;const t=VueRouter.useRoute();let o="/";const n=(u=(l=t==null?void 0:t.matched)==null?void 0:l[0])==null?void 0:u.path;n&&(n.endsWith("/:pathMatch(.*)*")?o=n.replace("/:pathMatch(.*)*",""):o=t.matched[0].path);const s=(r==null?void 0:r.export)||"default";LoggerInstance.debug("createRemoteAppComponent LazyComponent create >>>",{basename:o,info:r});const a=await r.loader(),c=a&&a[Symbol.for("mf_module_id")],i=a[s];if(LoggerInstance.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:c,module:a,exportName:s,basename:o,route:t}),s in a&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:c,providerInfo:i,basename:o,rootAttrs:r.rootAttrs})}};throw new Error("module not found")}})}function createRemoteComponent(r){return LoggerInstance.warn("createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!"),createRemoteAppComponent(r)}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteAppComponent=createRemoteAppComponent;exports.createRemoteComponent=createRemoteComponent;
|
|
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(o=>o===t)===-1&&r.push(t),r}function getFMId(r){return"version"in r&&r.version?`${r.name}:${r.version}`:"entry"in r&&r.entry?`${r.name}:${r.entry}`:`${r.name}`}function isRemoteInfoWithEntry(r){return typeof r.entry<"u"}function isPureRemoteEntry(r){return!r.entry.includes(".json")}function isObject(r){return r&&typeof r=="object"}const objectToString=Object.prototype.toString;function isPlainObject(r){return objectToString.call(r)==="[object Object]"}function arrayOptions(r){return Array.isArray(r)?r:[r]}function getRemoteEntryInfoFromSnapshot(r){const t={url:"",type:"global",globalName:""};return isBrowserEnv()||isReactNativeEnv()?"remoteEntry"in r?{url:r.remoteEntry,type:r.remoteEntryType,globalName:r.globalName}:t:"ssrRemoteEntry"in r?{url:r.ssrRemoteEntry||t.url,type:r.ssrRemoteEntryType||t.type,globalName:r.globalName}:t}const processModuleAlias=(r,t)=>{let o;return r.endsWith("/")?o=r.slice(0,-1):o=r,t.startsWith(".")&&(t=t.slice(1)),o=o+t,o},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(r,t,o){Object.defineProperty(r,t,{value:o,configurable:!1,writable:!0})}function includeOwnProperty(r,t){return Object.hasOwnProperty.call(r,t)}includeOwnProperty(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(r){var t,o,n,s,a,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__=[]),(o=r.__FEDERATION__).__INSTANCES__??(o.__INSTANCES__=[]),(n=r.__FEDERATION__).moduleInfo??(n.moduleInfo={}),(s=r.__FEDERATION__).__SHARE__??(s.__SHARE__={}),(a=r.__FEDERATION__).__MANIFEST_LOADING__??(a.__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-refactor-manifest-20251111024434")}function getInfoWithoutType(r,t){if(typeof t=="string"){if(r[t])return{value:r[t],key:t};{const n=Object.keys(r);for(const s of n){const[a,c]=s.split(":"),i=`${a}:${t}`,l=r[i];if(l)return{value:l,key:i}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(r,t)=>{const o=getFMId(r),n=getInfoWithoutType(t,o).value;if(n&&!n.version&&"version"in r&&r.version&&(n.version=r.version),n)return n;if("version"in r&&r.version){const{version:s,...a}=r,c=getFMId(a),i=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,c).value;if((i==null?void 0:i.version)===s)return i}},getGlobalSnapshotInfoByModuleInfo=r=>getTargetSnapshotInfoByModuleInfo(r,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(r,t)=>{const o=getFMId(r);return nativeGlobal.__FEDERATION__.moduleInfo[o]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=r=>(nativeGlobal.__FEDERATION__.moduleInfo={...nativeGlobal.__FEDERATION__.moduleInfo,...r},()=>{const t=Object.keys(r);for(const o of t)delete nativeGlobal.__FEDERATION__.moduleInfo[o]}),getRemoteEntryExports=(r,t)=>{const o=t||`__FEDERATION_${r}:custom__`,n=CurrentGlobal[o];return{remoteEntryKey:o,entryExports:n}},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=r=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(r),setPreloaded=r=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(r,!0),DEFAULT_SCOPE="default",DEFAULT_REMOTE_TYPE="global",buildIdentifier="[0-9A-Za-z-]+",build=`(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`,numericIdentifier="0|[1-9]\\d*",numericIdentifierLoose="[0-9]+",nonNumericIdentifier="\\d*[a-zA-Z-][a-zA-Z0-9-]*",preReleaseIdentifierLoose=`(?:${numericIdentifierLoose}|${nonNumericIdentifier})`,preReleaseLoose=`(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`,preReleaseIdentifier=`(?:${numericIdentifier}|${nonNumericIdentifier})`,preRelease=`(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`,xRangeIdentifier=`${numericIdentifier}|x|X|\\*`,xRangePlain=`[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`,hyphenRange=`^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`,mainVersionLoose=`(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`,loosePlain=`[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`,gtlt="((?:<|>)?=?)",comparatorTrim=`(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`,loneTilde="(?:~>?)",tildeTrim=`(\\s*)${loneTilde}\\s+`,loneCaret="(?:\\^)",caretTrim=`(\\s*)${loneCaret}\\s+`,star="(<|>)?=?\\s*\\*",caret=`^${loneCaret}${xRangePlain}$`,mainVersion=`(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`,fullPlain=`v?${mainVersion}${preRelease}?${build}?`,tilde=`^${loneTilde}${xRangePlain}$`,xRange=`^${gtlt}\\s*${xRangePlain}$`,comparator=`^${gtlt}\\s*(${fullPlain})$|^$`,gte0="^\\s*>=\\s*0.0.0\\s*$";function parseRegex(r){return new RegExp(r)}function isXVersion(r){return!r||r.toLowerCase()==="x"||r==="*"}function pipe(...r){return t=>r.reduce((o,n)=>n(o),t)}function extractComparator(r){return r.match(parseRegex(comparator))}function combineVersion(r,t,o,n){const s=`${r}.${t}.${o}`;return n?`${s}-${n}`:s}function parseHyphen(r){return r.replace(parseRegex(hyphenRange),(t,o,n,s,a,c,i,l,u,h,p,d)=>(isXVersion(n)?o="":isXVersion(s)?o=`>=${n}.0.0`:isXVersion(a)?o=`>=${n}.${s}.0`:o=`>=${o}`,isXVersion(u)?l="":isXVersion(h)?l=`<${Number(u)+1}.0.0-0`:isXVersion(p)?l=`<${u}.${Number(h)+1}.0-0`:d?l=`<=${u}.${h}.${p}-${d}`:l=`<=${l}`,`${o} ${l}`.trim()))}function parseComparatorTrim(r){return r.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(r){return r.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(r){return r.replace(parseRegex(caretTrim),"$1^")}function parseCarets(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(caret),(o,n,s,a,c)=>isXVersion(n)?"":isXVersion(s)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:isXVersion(a)?n==="0"?`>=${n}.${s}.0 <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.0 <${Number(n)+1}.0.0-0`:c?n==="0"?s==="0"?`>=${n}.${s}.${a}-${c} <${n}.${s}.${Number(a)+1}-0`:`>=${n}.${s}.${a}-${c} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a}-${c} <${Number(n)+1}.0.0-0`:n==="0"?s==="0"?`>=${n}.${s}.${a} <${n}.${s}.${Number(a)+1}-0`:`>=${n}.${s}.${a} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a} <${Number(n)+1}.0.0-0`)).join(" ")}function parseTildes(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(o,n,s,a,c)=>isXVersion(n)?"":isXVersion(s)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:isXVersion(a)?`>=${n}.${s}.0 <${n}.${Number(s)+1}.0-0`:c?`>=${n}.${s}.${a}-${c} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a} <${n}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(r){return r.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(o,n,s,a,c,i)=>{const l=isXVersion(s),u=l||isXVersion(a),h=u||isXVersion(c);return n==="="&&h&&(n=""),i="",l?n===">"||n==="<"?"<0.0.0-0":"*":n&&h?(u&&(a=0),c=0,n===">"?(n=">=",u?(s=Number(s)+1,a=0,c=0):(a=Number(a)+1,c=0)):n==="<="&&(n="<",u?s=Number(s)+1:a=Number(a)+1),n==="<"&&(i="-0"),`${n+s}.${a}.${c}${i}`):u?`>=${s}.0.0${i} <${Number(s)+1}.0.0-0`:h?`>=${s}.${a}.0${i} <${s}.${Number(a)+1}.0-0`:o})).join(" ")}function parseStar(r){return r.trim().replace(parseRegex(star),"")}function parseGTE0(r){return r.trim().replace(parseRegex(gte0),"")}function compareAtom(r,t){return r=Number(r)||r,t=Number(t)||t,r>t?1:r===t?0:-1}function comparePreRelease(r,t){const{preRelease:o}=r,{preRelease:n}=t;if(o===void 0&&n)return 1;if(o&&n===void 0)return-1;if(o===void 0&&n===void 0)return 0;for(let s=0,a=o.length;s<=a;s++){const c=o[s],i=n[s];if(c!==i)return c===void 0&&i===void 0?0:c?i?compareAtom(c,i):-1:1}return 0}function compareVersion(r,t){return compareAtom(r.major,t.major)||compareAtom(r.minor,t.minor)||compareAtom(r.patch,t.patch)||comparePreRelease(r,t)}function eq(r,t){return r.version===t.version}function compare(r,t){switch(r.operator){case"":case"=":return eq(r,t);case">":return compareVersion(r,t)<0;case">=":return eq(r,t)||compareVersion(r,t)<0;case"<":return compareVersion(r,t)>0;case"<=":return eq(r,t)||compareVersion(r,t)>0;case void 0:return!0;default:return!1}}function parseComparatorString(r){return pipe(parseCarets,parseTildes,parseXRanges,parseStar)(r)}function parseRange(r){return pipe(parseHyphen,parseComparatorTrim,parseTildeTrim,parseCaretTrim)(r.trim()).split(/\s+/).join(" ")}function satisfy(r,t){if(!r)return!1;const o=extractComparator(r);if(!o)return!1;const[,n,,s,a,c,i]=o,l={operator:n,version:combineVersion(s,a,c,i),major:s,minor:a,patch:c,preRelease:i==null?void 0:i.split(".")},u=t.split("||");for(const h of u){const p=h.trim();if(!p||p==="*"||p==="x")return!0;try{const d=parseRange(p);if(!d.trim())return!0;const m=d.split(" ").map(g=>parseComparatorString(g)).join(" ");if(!m.trim())return!0;const y=m.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[,S,,_,T,R,I]=b,A={operator:S,version:combineVersion(_,T,R,I),major:_,minor:T,patch:R,preRelease:I==null?void 0:I.split(".")};if(!compare(A,l)){E=!1;break}}if(E)return!0}catch(d){console.error(`[semver] Error processing range part "${p}":`,d);continue}}return!1}function formatShare(r,t,o,n){let s;return"get"in r?s=r.get:"lib"in r?s=()=>Promise.resolve(r.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${o}'!`)}),{deps:[],useIn:[],from:t,loading:null,...r,shareConfig:{requiredVersion:`^${r.version}`,singleton:!1,eager:!1,strictVersion:!1,...r.shareConfig},get:s,loaded:r!=null&&r.loaded||"lib"in r?!0:void 0,version:r.version??"0",scope:Array.isArray(r.scope)?r.scope:[r.scope??"default"],strategy:(r.strategy??n)||"version-first"}}function formatShareConfigs(r,t){const o=t.shared||{},n=t.name,s=Object.keys(o).reduce((c,i)=>{const l=arrayOptions(o[i]);return c[i]=c[i]||[],l.forEach(u=>{c[i].push(formatShare(u,n,i,t.shareStrategy))}),c},{}),a={...r.shared};return Object.keys(s).forEach(c=>{a[c]?s[c].forEach(i=>{a[c].find(u=>u.version===i.version)||a[c].push(i)}):a[c]=s[c]}),{shared:a,shareInfos:s}}function versionLt(r,t){const o=n=>{if(!Number.isNaN(Number(n))){const a=n.split(".");let c=n;for(let i=0;i<3-a.length;i++)c+=".0";return c}return n};return!!satisfy(o(r),`<=${o(t)}`)}const findVersion=(r,t)=>{const o=t||function(n,s){return versionLt(n,s)};return Object.keys(r).reduce((n,s)=>!n||o(n,s)||n==="0"?s:n,0)},isLoaded=r=>!!r.loaded||typeof r.lib=="function",isLoading=r=>!!r.loading;function findSingletonVersionOrderByVersion(r,t,o){const n=r[t][o],s=function(a,c){return!isLoaded(n[a])&&versionLt(a,c)};return findVersion(r[t][o],s)}function findSingletonVersionOrderByLoaded(r,t,o){const n=r[t][o],s=function(a,c){const i=l=>isLoaded(l)||isLoading(l);return i(n[c])?i(n[a])?!!versionLt(a,c):!0:i(n[a])?!1:versionLt(a,c)};return findVersion(r[t][o],s)}function getFindShareFunction(r){return r==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(r,t,o,n){if(!r)return;const{shareConfig:s,scope:a=DEFAULT_SCOPE,strategy:c}=o,i=Array.isArray(a)?a:[a];for(const l of i)if(s&&r[l]&&r[l][t]){const{requiredVersion:u}=s,p=getFindShareFunction(c)(r,l,t),d=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(p,u)){const E=`Version ${p} from ${p&&r[l][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;s.strictVersion?error(E):warn(E)}return r[l][t][p]}else{if(u===!1||u==="*"||satisfy(p,u))return r[l][t][p];for(const[E,g]of Object.entries(r[l][t]))if(satisfy(E,u))return g}},m={shareScopeMap:r,scope:l,pkgName:t,version:p,GlobalFederation:Global.__FEDERATION__,resolver:d};return(n.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(r){const{pkgName:t,extraOptions:o,shareInfos:n}=r,s=c=>{if(!c)return;const i={};c.forEach(h=>{i[h.version]=h});const u=findVersion(i,function(h,p){return!isLoaded(i[h])&&versionLt(h,p)});return i[u]},a=(o==null?void 0:o.resolver)??s;return Object.assign({},a(n[t]),o==null?void 0:o.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(r,t){for(const o of r){const n=t.startsWith(o.name);let s=t.replace(o.name,"");if(n){if(s.startsWith("/")){const i=o.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:o}}else if(s==="")return{pkgNameOrAlias:o.name,expose:".",remote:o}}const a=o.alias&&t.startsWith(o.alias);let c=o.alias&&t.replace(o.alias,"");if(o.alias&&a){if(c&&c.startsWith("/")){const i=o.alias;return c=`.${c}`,{pkgNameOrAlias:i,expose:c,remote:o}}else if(c==="")return{pkgNameOrAlias:o.alias,expose:".",remote:o}}}}function matchRemote(r,t){for(const o of r)if(t===o.name||o.alias&&t===o.alias)return o}function registerPlugins(r,t){const o=getGlobalHostPlugins(),n=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return o.length>0&&o.forEach(s=>{r!=null&&r.find(a=>a.name!==s.name)&&r.push(s)}),r&&r.length>0&&r.forEach(s=>{n.forEach(a=>{a.applyPlugin(s,t)})}),r}const importCallback=".then(callbacks[0]).catch(callbacks[1])";async function loadEsmEntry({entry:r,remoteEntryExports:t}){return new Promise((o,n)=>{try{t?o(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${r}")${importCallback}`)([o,n]):import(r).then(o).catch(n)}catch(s){n(s)}})}async function loadSystemJsEntry({entry:r,remoteEntryExports:t}){return new Promise((o,n)=>{try{t?o(t):typeof __system_context__>"u"?System.import(r).then(o).catch(n):new Function("callbacks",`System.import("${r}")${importCallback}`)([o,n])}catch(s){n(s)}})}function handleRemoteEntryLoaded(r,t,o){const{remoteEntryKey:n,entryExports:s}=getRemoteEntryExports(r,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:r,remoteEntryUrl:o,remoteEntryKey:n})),s}async function loadEntryScript({name:r,globalName:t,entry:o,loaderHook:n,getEntryUrl:s}){const{entryExports:a}=getRemoteEntryExports(r,t);if(a)return a;const c=s?s(o):o;return loadScript(c,{attrs:{},createScriptHook:(i,l)=>{const u=n.lifecycle.createScript.emit({url:i,attrs:l});if(u&&(u instanceof HTMLScriptElement||"script"in u||"timeout"in u))return u}}).then(()=>handleRemoteEntryLoaded(r,t,o)).catch(i=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:r,resourceUrl:o})),i})}async function loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:o,getEntryUrl:n}){const{entry:s,entryGlobalName:a,name:c,type:i}=r;switch(i){case"esm":case"module":return loadEsmEntry({entry:s,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:s,remoteEntryExports:t});default:return loadEntryScript({entry:s,globalName:a,name:c,loaderHook:o,getEntryUrl:n})}}async function loadEntryNode({remoteInfo:r,loaderHook:t}){const{entry:o,entryGlobalName:n,name:s,type:a}=r,{entryExports:c}=getRemoteEntryExports(s,n);return c||loadScriptNode(o,{attrs:{name:s,globalName:n,type:a},loaderHook:{createScriptHook:(i,l={})=>{const u=t.lifecycle.createScript.emit({url:i,attrs:l});if(u&&"url"in u)return u}}}).then(()=>handleRemoteEntryLoaded(s,n,o)).catch(i=>{throw i})}function getRemoteEntryUniqueKey(r){const{entry:t,name:o}=r;return composeKeyWithSeparator(o,t)}async function getRemoteEntry(r){const{origin:t,remoteEntryExports:o,remoteInfo:n,getEntryUrl:s,_inErrorHandling:a=!1}=r,c=getRemoteEntryUniqueKey(n);if(o)return o;if(!globalLoading[c]){const i=t.remoteHandler.hooks.lifecycle.loadEntry,l=t.loaderHook;globalLoading[c]=i.emit({loaderHook:l,remoteInfo:n,remoteEntryExports:o}).then(u=>u||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:n,remoteEntryExports:o,loaderHook:l,getEntryUrl:s}):loadEntryNode({remoteInfo:n,loaderHook:l}))).catch(async u=>{const h=getRemoteEntryUniqueKey(n);if(u instanceof Error&&u.message.includes(RUNTIME_008)&&!a){const d=y=>getRemoteEntry({...y,_inErrorHandling:!0}),m=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:d,origin:t,remoteInfo:n,remoteEntryExports:o,globalLoading,uniqueKey:h});if(m)return m}throw u})}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(o=>{const n=matchRemote(r,o.nameOrAlias);return assert(n,`Unable to preload ${o.nameOrAlias} as it is not included in ${!n&&safeToString({remoteInfo:n,remotes:r})}`),{remote:n,preloadConfig:defaultPreloadArgs(o)}})}function normalizePreloadExposes(r){return r?r.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(r,t,o,n=!0){const{cssAssets:s,jsAssetsWithoutEntry:a,entryAssets:c}=o;if(t.options.inBrowser){if(c.forEach(i=>{const{moduleInfo:l}=i,u=t.moduleCache.get(r.name);getRemoteEntry(u?{origin:t,remoteInfo:l,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:l,remoteEntryExports:void 0})}),n){const i={rel:"preload",as:"style"};s.forEach(l=>{const{link:u,needAttach:h}=createLink({url:l,cb:()=>{},attrs:i,createLinkHook:(p,d)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:d});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(l=>{const{link:u,needAttach:h}=createLink({url:l,cb:()=>{},attrs:i,createLinkHook:(p,d)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:d});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});h&&document.head.appendChild(u)})}if(n){const i={rel:"preload",as:"script"};a.forEach(l=>{const{link:u,needAttach:h}=createLink({url:l,cb:()=>{},attrs:i,createLinkHook:(p,d)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:d});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={fetchpriority:"high",type:(r==null?void 0:r.type)==="module"?"module":"text/javascript"};a.forEach(l=>{const{script:u,needAttach:h}=createScript({url:l,cb:()=>{},attrs:i,createScriptHook:(p,d)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:p,attrs:d});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});h&&document.head.appendChild(u)})}}}class Module{constructor({remoteInfo:t,host:o}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=o}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let t;return t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports}),assert(t,`remoteEntryExports is undefined
|
|
8
|
+
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,o,n,s){const{loadFactory:a=!0}=n||{loadFactory:!0},c=await this.getEntry();if(!this.inited){const p=this.host.shareScopeMap,d=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];d.length||d.push("default"),d.forEach(b=>{p[b]||(p[b]={})});const m=p[d[0]],y=[],E={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?d:this.remoteInfo.shareScope||"default"};Object.defineProperty(E,"shareScopeMap",{value:p,enumerable:!1});const g=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:E,initScope:y,remoteInfo:this.remoteInfo,origin:this.host});typeof(c==null?void 0:c.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await c.init(g.shareScope,g.initScope,g.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...g,id:t,remoteSnapshot:s,remoteEntryExports:c})}this.lib=c,this.inited=!0;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:c,expose:o,moduleInfo:this.remoteInfo}),i||(i=await c.get(o)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${o}.`);const l=processModuleAlias(this.remoteInfo.name,o),u=this.wraperFactory(i,l);return a?await u():u}wraperFactory(t,o){function n(s,a){s&&typeof s=="object"&&Object.isExtensible(s)&&!Object.getOwnPropertyDescriptor(s,Symbol.for("mf_module_id"))&&Object.defineProperty(s,Symbol.for("mf_module_id"),{value:a,enumerable:!1})}return t instanceof Promise?async()=>{const s=await t();return n(s,o),s}:()=>{const s=t();return n(s,o),s}}}class SyncHook{constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const o=this;this.on(function n(...s){return o.remove(n),t.apply(null,s)})}emit(...t){let o;return this.listeners.size>0&&this.listeners.forEach(n=>{o=n(...t)}),o}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}}class AsyncHook extends SyncHook{emit(...t){let o;const n=Array.from(this.listeners);if(n.length>0){let s=0;const a=c=>c===!1?!1:s<n.length?Promise.resolve(n[s++].apply(null,t)).then(a):c;o=a()}return Promise.resolve(o)}}function checkReturnData(r,t){if(!isObject(t))return!1;if(r!==t){for(const o in r)if(!(o in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{constructor(t){super(),this.onerror=error,this.type=t}emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const o of this.listeners)try{const n=o(t);if(checkReturnData(t,n))t=n;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(n){warn(n),this.onerror(n)}return t}}class AsyncWaterfallHook extends SyncHook{constructor(t){super(),this.onerror=error,this.type=t}emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const o=Array.from(this.listeners);if(o.length>0){let n=0;const s=c=>(warn(c),this.onerror(c),t),a=c=>{if(checkReturnData(t,c)){if(t=c,n<o.length)try{return Promise.resolve(o[n++](t)).then(a,s)}catch(i){return s(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return t};return Promise.resolve(a(t))}return Promise.resolve(t)}}class PluginSystem{constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}applyPlugin(t,o){var s;assert(isPlainObject(t),"Plugin configuration is invalid.");const n=t.name;assert(n,"A name must be provided by the plugin."),this.registerPlugins[n]||(this.registerPlugins[n]=t,(s=t.apply)==null||s.call(t,o),Object.keys(this.lifecycle).forEach(a=>{const c=t[a];c&&this.lifecycle[a].on(c)}))}removePlugin(t){assert(t,"A name is required.");const o=this.registerPlugins[t];assert(o,`The plugin "${t}" is not registered.`),Object.keys(o).forEach(n=>{n!=="name"&&this.lifecycle[n].remove(o[n])})}}function assignRemoteInfo(r,t){const o=getRemoteEntryInfoFromSnapshot(t);o.url||error(`The attribute remoteEntry of ${r.name} must not be undefined.`);let n=getResourceUrl(t,o.url);!isBrowserEnv()&&!n.startsWith("http")&&(n=`https:${n}`),r.type=o.type,r.entryGlobalName=o.globalName,r.entry=n,r.version=t.version,r.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(r){const{remote:t,pkgNameOrAlias:o,expose:n,origin:s,remoteInfo:a,id:c}=r;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:i,globalSnapshot:l}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:c});assignRemoteInfo(a,i);const u={remote:t,preloadConfig:{nameOrAlias:o,exposes:[n],resourceCategory:"sync",share:!1,depsRemote:!1}},h=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:u,remoteInfo:a,remote:t,remoteSnapshot:i,globalSnapshot:l});return h&&preloadAssets(a,s,h,!1),{...r,remoteSnapshot:i}}return r}}}function splitId(r){const t=r.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function traverseModuleInfo(r,t,o,n,s={},a){const c=getFMId(t),{value:i}=getInfoWithoutType(r,c),l=a||i;if(l&&!isManifestProvider(l)&&(o(l,t,n),l.remotesInfo)){const u=Object.keys(l.remotesInfo);for(const h of u){if(s[h])continue;s[h]=!0;const p=splitId(h),d=l.remotesInfo[h];traverseModuleInfo(r,{name:p.name,version:d.matchedVersion},o,!1,s,void 0)}}}const isExisted=(r,t)=>document.querySelector(`${r}[${r==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(r,t,o,n,s){const a=[],c=[],i=[],l=new Set,u=new Set,{options:h}=r,{preloadConfig:p}=t,{depsRemote:d}=p;if(traverseModuleInfo(n,o,(g,b,S)=>{var w;let _;if(S)_=p;else if(Array.isArray(d)){const N=d.find($=>$.nameOrAlias===b.name||$.nameOrAlias===b.alias);if(!N)return;_=defaultPreloadArgs(N)}else if(d===!0)_=p;else return;const T=getResourceUrl(g,getRemoteEntryInfoFromSnapshot(g).url);T&&i.push({name:b.name,moduleInfo:{name:b.name,entry:T,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:T});let R="modules"in g?g.modules:[];const I=normalizePreloadExposes(_.exposes);I.length&&"modules"in g&&(R=(w=g==null?void 0:g.modules)==null?void 0:w.reduce((N,$)=>((I==null?void 0:I.indexOf($.moduleName))!==-1&&N.push($),N),[]));function A(N){const $=N.map(P=>getResourceUrl(g,P));return _.filter?$.filter(_.filter):$}if(R){const N=R.length;for(let $=0;$<N;$++){const P=R[$],M=`${b.name}/${P.moduleName}`;r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:P.moduleName==="."?b.name:M,name:b.name,remoteSnapshot:g,preloadConfig:_,remote:b,origin:r}),!getPreloaded(M)&&(_.resourceCategory==="all"?(a.push(...A(P.assets.css.async)),a.push(...A(P.assets.css.sync)),c.push(...A(P.assets.js.async)),c.push(...A(P.assets.js.sync))):(_.resourceCategory="sync")&&(a.push(...A(P.assets.css.sync)),c.push(...A(P.assets.js.sync))),setPreloaded(M))}}},!0,{},s),s.shared&&s.shared.length>0){const g=(b,S)=>{const _=getRegisteredShare(r.shareScopeMap,S.sharedName,b,r.sharedHandler.hooks.lifecycle.resolveShare);_&&typeof _.lib=="function"&&(S.assets.js.sync.forEach(T=>{l.add(T)}),S.assets.css.sync.forEach(T=>{u.add(T)}))};s.shared.forEach(b=>{var R;const S=(R=h.shared)==null?void 0:R[b.sharedName];if(!S)return;const _=b.version?S.find(I=>I.version===b.version):S;if(!_)return;arrayOptions(_).forEach(I=>{g(I,b)})})}const y=c.filter(g=>!l.has(g)&&!isExisted("script",g));return{cssAssets:a.filter(g=>!u.has(g)&&!isExisted("link",g)),jsAssetsWithoutEntry:y,entryAssets:i.filter(g=>!isExisted("script",g.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(r){const{origin:t,preloadOptions:o,remoteInfo:n,remote:s,globalSnapshot:a,remoteSnapshot:c}=r;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:n.name,entry:s.entry,type:n.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(n,c),generatePreloadAssets(t,o,n,a,c)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(r,t){const o=getGlobalSnapshotInfoByModuleInfo({name:t.name,version:t.options.version}),n=o&&"remotesInfo"in o&&o.remotesInfo&&getInfoWithoutType(o.remotesInfo,r.name).value;return n&&n.matchedVersion?{hostGlobalSnapshot:o,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:n.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:"version"in r?r.version:void 0})}}class SnapshotHandler{constructor(t){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new PluginSystem({beforeLoadRemoteSnapshot:new AsyncHook("beforeLoadRemoteSnapshot"),loadSnapshot:new AsyncWaterfallHook("loadGlobalSnapshot"),loadRemoteSnapshot:new AsyncWaterfallHook("loadRemoteSnapshot"),afterLoadSnapshot:new AsyncWaterfallHook("afterLoadSnapshot")}),this.manifestLoading=Global.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=t,this.loaderHook=t.loaderHook}async loadRemoteSnapshotInfo({moduleInfo:t,id:o,expose:n}){const{options:s}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:s,moduleInfo:t});let a=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});a||(a={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:a})),a&&"remotesInfo"in a&&!getInfoWithoutType(a.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(a.remotesInfo={...a==null?void 0:a.remotesInfo,[t.name]:{matchedVersion:"version"in t?t.version:t.entry}});const{hostGlobalSnapshot:c,remoteSnapshot:i,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:u,globalSnapshot:h}=await this.hooks.lifecycle.loadSnapshot.emit({options:s,moduleInfo:t,hostGlobalSnapshot:c,remoteSnapshot:i,globalSnapshot:l});let p,d;if(u)if(isManifestProvider(u)){const m=isBrowserEnv()?u.remoteEntry:u.ssrRemoteEntry||u.remoteEntry||"",y=await this.getManifestJson(m,t,{}),E=setGlobalSnapshotInfoByModuleInfo({...t,entry:m},y);p=y,d=E}else{const{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:u,from:"global"});p=m,d=h}else if(isRemoteInfoWithEntry(t)){const m=await this.getManifestJson(t.entry,t,{}),y=setGlobalSnapshotInfoByModuleInfo(t,m),{remoteSnapshot:E}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:m,from:"global"});p=E,d=y}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(h)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:o,host:this.HostInstance,options:s,moduleInfo:t,remoteSnapshot:p}),{remoteSnapshot:p,globalSnapshot:d}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,o,n){const s=async()=>{let c=this.manifestCache.get(t);if(c)return c;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});(!i||!(i instanceof Response))&&(i=await fetch(t,{})),c=await i.json()}catch(i){c=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),c||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:o.name,hostName:this.HostInstance.options.name},`${i}`)))}return assert(c.metaData&&c.exposes&&c.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,c),c},a=async()=>{const c=await s(),i=generateSnapshotFromManifest(c,{version:t}),{remoteSnapshot:l}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:o,manifestJson:c,remoteSnapshot:i,manifestUrl:t,from:"manifest"});return l};return this.manifestLoading[t]||(this.manifestLoading[t]=a().then(c=>c)),this.manifestLoading[t]}}class SharedHandler{constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}registerShared(t,o){const{shareInfos:n,shared:s}=formatShareConfigs(t,o);return Object.keys(n).forEach(c=>{n[c].forEach(l=>{l.scope.forEach(u=>{var p;((p=this.shareScopeMap[u])==null?void 0:p[c])||this.setShared({pkgName:c,lib:l.lib,get:l.get,loaded:l.loaded||!!l.lib,shared:l,from:o.name})})})}),{shareInfos:n,shared:s}}async loadShare(t,o){const{host:n}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:n.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const a=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:n.options.shared,origin:n}),{shareInfo:c}=a;assert(c,`Cannot find ${t} Share in the ${n.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,c,this.hooks.lifecycle.resolveShare),l=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,n.options.name)};if(i&&i.lib)return l(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),l(i),u}else if(i){const h=(async()=>{const p=await i.get();return l(i),i.loaded=!0,i.lib=p,p})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:n.options.name,lib:null,loading:h}),h}else{if(o!=null&&o.customShareInfo)return!1;const h=(async()=>{const p=await c.get();c.lib=p,c.loaded=!0,l(c);const d=getRegisteredShare(this.shareScopeMap,t,c,this.hooks.lifecycle.resolveShare);return d&&(d.lib=p,d.loaded=!0,d.from=c.from),p})();return this.setShared({pkgName:t,loaded:!1,shared:c,from:n.options.name,lib:null,loading:h}),h}}initializeSharing(t=DEFAULT_SCOPE,o){const{host:n}=this,s=o==null?void 0:o.from,a=o==null?void 0:o.strategy;let c=o==null?void 0:o.initScope;const i=[];if(s!=="build"){const{initTokens:y}=this;c||(c=[]);let E=y[t];if(E||(E=y[t]={from:this.host.name}),c.indexOf(E)>=0)return i;c.push(E)}const l=this.shareScopeMap,u=n.options.name;l[t]||(l[t]={});const h=l[t],p=(y,E)=>{var R;const{version:g,eager:b}=E;h[y]=h[y]||{};const S=h[y],_=S[g],T=!!(_&&(_.eager||(R=_.shareConfig)!=null&&R.eager));(!_||_.strategy!=="loaded-first"&&!_.loaded&&(!b!=!T?b:u>_.from))&&(S[g]=E)},d=y=>y&&y.init&&y.init(l[t],c),m=async y=>{const{module:E}=await n.remoteHandler.getRemoteModuleAndOptions({id:y});if(E.getEntry){let g;try{g=await E.getEntry()}catch(b){g=await n.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:y,error:b,from:"runtime",lifecycle:"beforeLoadShare",origin:n})}E.inited||(await d(g),E.inited=!0)}};return Object.keys(n.options.shared).forEach(y=>{n.options.shared[y].forEach(g=>{g.scope.includes(t)&&p(y,g)})}),(n.options.shareStrategy==="version-first"||a==="version-first")&&n.options.remotes.forEach(y=>{y.shareScope===t&&i.push(m(y.name))}),i}loadShareSync(t,o){const{host:n}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:n.options.shared});s!=null&&s.scope&&s.scope.forEach(i=>{this.initializeSharing(i,{strategy:s.strategy})});const a=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),c=i=>{i.useIn||(i.useIn=[]),addUniqueItem(i.useIn,n.options.name)};if(a){if(typeof a.lib=="function")return c(a),a.loaded||(a.loaded=!0,a.from===n.options.name&&(s.loaded=!0)),a.lib;if(typeof a.get=="function"){const i=a.get();if(!(i instanceof Promise))return c(a),this.setShared({pkgName:t,loaded:!0,from:n.options.name,lib:i,shared:a}),i}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const i=s.get();if(i instanceof Promise){const l=(o==null?void 0:o.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(l,runtimeDescMap,{hostName:n.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:n.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:n.options.name,sharedPkgName:t}))}initShareScopeMap(t,o,n={}){const{host:s}=this;this.shareScopeMap[t]=o,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:o,options:s.options,origin:s,scopeName:t,hostShareScopeMap:n.hostShareScopeMap})}setShared({pkgName:t,shared:o,from:n,lib:s,loading:a,loaded:c,get:i}){const{version:l,scope:u="default",...h}=o;(Array.isArray(u)?u:[u]).forEach(d=>{if(this.shareScopeMap[d]||(this.shareScopeMap[d]={}),this.shareScopeMap[d][t]||(this.shareScopeMap[d][t]={}),!this.shareScopeMap[d][t][l]){this.shareScopeMap[d][t][l]={version:l,scope:[d],...h,lib:s,loaded:c,loading:a},i&&(this.shareScopeMap[d][t][l].get=i);return}const m=this.shareScopeMap[d][t][l];a&&!m.loading&&(m.loading=a),c&&!m.loaded&&(m.loaded=c),n&&m.from!==n&&(m.from=n)})}_setGlobalShareScopeMap(t){const o=getGlobalShareScope(),n=t.id||t.name;n&&!o[n]&&(o[n]=this.shareScopeMap)}}class RemoteHandler{constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}formatAndRegisterRemote(t,o){return(o.remotes||[]).reduce((s,a)=>(this.registerRemote(a,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,o){const{remote:n,expose:s}=o,{name:a,alias:c}=n;if(this.idToRemoteMap[t]={name:n.name,expose:s},c&&t.startsWith(a)){const i=t.replace(a,c);this.idToRemoteMap[i]={name:n.name,expose:s};return}if(c&&t.startsWith(c)){const i=t.replace(c,a);this.idToRemoteMap[i]={name:n.name,expose:s}}}async loadRemote(t,o){const{host:n}=this;try{const{loadFactory:s=!0}=o||{loadFactory:!0},{module:a,moduleOptions:c,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:l,remote:u,expose:h,id:p,remoteSnapshot:d}=i,m=await a.get(p,h,o,d),y=await this.hooks.lifecycle.onLoad.emit({id:p,pkgNameOrAlias:l,expose:h,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:c,moduleInstance:a,origin:n});return this.setIdToRemoteMap(t,i),typeof y=="function"?y:m}catch(s){const{from:a="runtime"}=o||{from:"runtime"},c=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:a,lifecycle:"onLoad",origin:n});if(!c)throw s;return c}}async preloadRemote(t){const{host:o}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:o.options,origin:o});const n=formatPreloadArgs(o.options.remotes,t);await Promise.all(n.map(async s=>{const{remote:a}=s,c=getRemoteInfo(a),{globalSnapshot:i,remoteSnapshot:l}=await o.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:a}),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:s,remote:a,remoteInfo:c,globalSnapshot:i,remoteSnapshot:l});u&&preloadAssets(c,o,u)}))}registerRemotes(t,o){const{host:n}=this;t.forEach(s=>{this.registerRemote(s,n.options.remotes,{force:o==null?void 0:o.force})})}async getRemoteModuleAndOptions(t){const{host:o}=this,{id:n}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:n,options:o.options,origin:o})}catch(y){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:n,options:o.options,origin:o,from:"runtime",error:y,lifecycle:"beforeRequest"}),!s)throw y}const{id:a}=s,c=matchRemoteWithNameAndExpose(o.options.remotes,a);assert(c,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:o.options.name,requestId:a}));const{remote:i}=c,l=getRemoteInfo(i),u=await o.sharedHandler.hooks.lifecycle.afterResolve.emit({id:a,...c,options:o.options,origin:o,remoteInfo:l}),{remote:h,expose:p}=u;assert(h&&p,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);let d=o.moduleCache.get(h.name);const m={host:o,remoteInfo:l};return d||(d=new Module(m),o.moduleCache.set(h.name,d)),{module:d,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,o,n){const{host:s}=this,a=()=>{if(t.alias){const i=o.find(l=>{var u;return t.alias&&(l.name.startsWith(t.alias)||((u=l.alias)==null?void 0:u.startsWith(t.alias)))});assert(!i,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const c=o.find(i=>i.name===t.name);if(!c)a(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];n!=null&&n.force&&(this.removeRemote(c),a(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){var o;try{const{host:n}=this,{name:s}=t,a=n.options.remotes.findIndex(i=>i.name===s);a!==-1&&n.options.remotes.splice(a,1);const c=n.moduleCache.get(t.name);if(c){const i=c.remoteInfo,l=i.entryGlobalName;CurrentGlobal[l]&&((o=Object.getOwnPropertyDescriptor(CurrentGlobal,l))!=null&&o.configurable?delete CurrentGlobal[l]:CurrentGlobal[l]=void 0);const u=getRemoteEntryUniqueKey(c.remoteInfo);globalLoading[u]&&delete globalLoading[u],n.snapshotHandler.manifestCache.delete(i.entry);let h=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const p=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===h:m.name===h);if(p!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[p];h=m.options.id||h;const y=getGlobalShareScope();let E=!0;const g=[];Object.keys(y).forEach(b=>{const S=y[b];S&&Object.keys(S).forEach(_=>{const T=S[_];T&&Object.keys(T).forEach(R=>{const I=T[R];I&&Object.keys(I).forEach(A=>{const w=I[A];w&&typeof w=="object"&&w.from===i.name&&(w.loaded||w.loading?(w.useIn=w.useIn.filter(N=>N!==i.name),w.useIn.length?E=!1:g.push([b,_,R,A])):g.push([b,_,R,A]))})})})}),E&&(m.shareScopeMap={},delete y[h]),g.forEach(([b,S,_,T])=>{var R,I,A;(A=(I=(R=y[b])==null?void 0:R[S])==null?void 0:I[_])==null||delete A[T]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p,1)}const{hostGlobalSnapshot:d}=getGlobalRemoteInfo(t,n);if(d){const m=d&&"remotesInfo"in d&&d.remotesInfo&&getInfoWithoutType(d.remotesInfo,t.name).key;m&&(delete d.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}n.moduleCache.delete(t.name)}}catch(n){logger.log("removeRemote fail: ",n)}}}const USE_SNAPSHOT=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;class ModuleFederation{constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.0.0-refactor-manifest-20251111024434",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const o=USE_SNAPSHOT?[snapshotPlugin(),generatePreloadAssetsPlugin()]:[],n={id:getBuilderId(),name:t.name,plugins:o,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=n,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...n.plugins,...t.plugins||[]]),this.options=this.formatOptions(n,t)}initOptions(t){this.registerPlugins(t.plugins);const o=this.formatOptions(this.options,t);return this.options=o,o}async loadShare(t,o){return this.sharedHandler.loadShare(t,o)}loadShareSync(t,o){return this.sharedHandler.loadShareSync(t,o)}initializeSharing(t=DEFAULT_SCOPE,o){return this.sharedHandler.initializeSharing(t,o)}initRawContainer(t,o,n){const s=getRemoteInfo({name:t,entry:o}),a=new Module({host:this,remoteInfo:s});return a.remoteEntryExports=n,this.moduleCache.set(t,a),a}async loadRemote(t,o){return this.remoteHandler.loadRemote(t,o)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,o,n={}){this.sharedHandler.initShareScopeMap(t,o,n)}formatOptions(t,o){const{shared:n}=formatShareConfigs(t,o),{userOptions:s,options:a}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:o,options:t,shareInfo:n}),c=this.remoteHandler.formatAndRegisterRemote(a,s),{shared:i}=this.sharedHandler.registerShared(a,s),l=[...a.plugins];s.plugins&&s.plugins.forEach(h=>{l.includes(h)||l.push(h)});const u={...t,...o,plugins:l,remotes:c,shared:i};return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const o=registerPlugins(t,this);this.options.plugins=this.options.plugins.reduce((n,s)=>(s&&n&&!n.find(a=>a.name===s.name)&&n.push(s),n),o||[])}registerRemotes(t,o){return this.remoteHandler.registerRemotes(t,o)}registerShared(t){this.sharedHandler.registerShared(this.options,{...this.options,shared:t})}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(ModuleFederation);function addBasenameToNestedRoutes(r,t){return r.map(o=>{const n={...o,path:t+o.path};return o.children&&o.children.length>0&&(n.children=addBasenameToNestedRoutes(o.children,t)),n})}function processRoutes(r){const{router:t,basename:o,memoryRoute:n,hashRoute:s}=r,a=t.getRoutes().sort((d,m)=>d.path.split("/").filter(y=>y).length-m.path.split("/").filter(y=>y).length),c=new Map,i=new Set;a.forEach(d=>{c.set(d.path,d)});const l=(d,m)=>`${d}/${m}`.replace(/\/+/g,"/").replace(/\/$/,"")||"/",u=(d,m="")=>{if(!d.children||d.children.length===0)return d;for(let y=0;y<d.children.length;y++){const E=d.children[y],g=l(m,E.path),b=c.get(g);if(b&&!i.has(b)){const S={...b,path:E.path};d.children[y]=S,i.add(b),u(S,g)}}return d};let h=[];for(const d of a)if(!i.has(d)){const m=u(d,d.path);i.add(d),h.push(m)}let p;return n?p=VueRouter__namespace.createMemoryHistory(o):s?(p=VueRouter__namespace.createWebHashHistory(),o&&(h=addBasenameToNestedRoutes(h,o))):p=VueRouter__namespace.createWebHistory(o),{history:p,routes:h}}function createBridgeComponent(r){const t=new Map,o=getInstance();return()=>({__APP_VERSION__:"0.0.0-refactor-manifest-20251111024434",async render(n){var y,E,g;LoggerInstance.debug("createBridgeComponent render Info",n);const{moduleName:s,dom:a,basename:c,memoryRoute:i,hashRoute:l,...u}=n,h=Vue__namespace.createApp(r.rootComponent,u);t.set(a,h);const p=await((g=(E=(y=o==null?void 0:o.bridgeHook)==null?void 0:y.lifecycle)==null?void 0:E.beforeBridgeRender)==null?void 0:g.emit(n)),d=p&&typeof p=="object"&&(p!=null&&p.extraProps)?p==null?void 0:p.extraProps:{},m=r.appOptions({app:h,basename:c,memoryRoute:i,hashRoute:l,...u,...d});if(m!=null&&m.router){const{history:b,routes:S}=processRoutes({router:m.router,basename:n.basename,memoryRoute:n.memoryRoute,hashRoute:n.hashRoute}),_=VueRouter__namespace.createRouter({...m.router.options,history:b,routes:S});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:_}),i&&await _.push(i.entryPath),h.use(_)}h.mount(a)},destroy(n){LoggerInstance.debug("createBridgeComponent destroy Info",n);const s=t.get(n==null?void 0:n.dom);s==null||s.unmount()}})}function e(){const r=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(r)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(r){const t=Vue.ref(null),o=Vue.ref(null),n=Vue.ref(""),s=VueRouter.useRoute(),a=getInstance(),c=Vue.useAttrs(),i=async()=>{var d,m,y,E;const u=(d=r.providerInfo)==null?void 0:d.call(r);o.value=u;let h={...c,moduleName:r.moduleName,dom:t.value,basename:r.basename,memoryRoute:r.memoryRoute,hashRoute:r.hashRoute};LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",h);const p=await((E=(y=(m=a==null?void 0:a.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:y.beforeBridgeRender)==null?void 0:E.emit(h))||{};h={...h,...p.extraProps},u.render(h)},l=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&i(),n.value!==""&&n.value!==u&&(LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...r,pathname:s.path}),e()),n.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>",{...r}),l(),(u=o.value)==null||u.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(r.rootAttrs||{},{ref:t}),null)}});function createRemoteAppComponent(r){return Vue.defineAsyncComponent({__APP_VERSION__:"0.0.0-refactor-manifest-20251111024434",...r.asyncComponentOptions,loader:async()=>{var l,u;const t=VueRouter.useRoute();let o="/";const n=(u=(l=t==null?void 0:t.matched)==null?void 0:l[0])==null?void 0:u.path;n&&(n.endsWith("/:pathMatch(.*)*")?o=n.replace("/:pathMatch(.*)*",""):o=t.matched[0].path);const s=(r==null?void 0:r.export)||"default";LoggerInstance.debug("createRemoteAppComponent LazyComponent create >>>",{basename:o,info:r});const a=await r.loader(),c=a&&a[Symbol.for("mf_module_id")],i=a[s];if(LoggerInstance.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:c,module:a,exportName:s,basename:o,route:t}),s in a&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:c,providerInfo:i,basename:o,rootAttrs:r.rootAttrs})}};throw new Error("module not found")}})}function createRemoteComponent(r){return LoggerInstance.warn("createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!"),createRemoteAppComponent(r)}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteAppComponent=createRemoteAppComponent;exports.createRemoteComponent=createRemoteComponent;
|
package/dist/index.js
CHANGED
|
@@ -58,26 +58,26 @@ function inferAutoPublicPath(r) {
|
|
|
58
58
|
return r.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
59
59
|
}
|
|
60
60
|
function generateSnapshotFromManifest(r, t = {}) {
|
|
61
|
-
var I, S,
|
|
61
|
+
var I, S, A;
|
|
62
62
|
const { remotes: o = {}, overrides: n = {}, version: s } = t;
|
|
63
63
|
let a;
|
|
64
64
|
const c = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" && s ? inferAutoPublicPath(s) : r.metaData.publicPath : r.metaData.getPublicPath, i = Object.keys(n);
|
|
65
65
|
let l = {};
|
|
66
|
-
Object.keys(o).length || (l = ((I = r.remotes) == null ? void 0 : I.reduce((_,
|
|
66
|
+
Object.keys(o).length || (l = ((I = r.remotes) == null ? void 0 : I.reduce((_, T) => {
|
|
67
67
|
let w;
|
|
68
|
-
const $ =
|
|
69
|
-
return i.includes($) ? w = n[$] : "version" in
|
|
68
|
+
const $ = T.federationContainerName;
|
|
69
|
+
return i.includes($) ? w = n[$] : "version" in T ? w = T.version : w = T.entry, _[$] = {
|
|
70
70
|
matchedVersion: w
|
|
71
71
|
}, _;
|
|
72
72
|
}, {})) || {}), Object.keys(o).forEach((_) => l[_] = {
|
|
73
73
|
// overrides will override dependencies
|
|
74
74
|
matchedVersion: i.includes(_) ? n[_] : o[_]
|
|
75
75
|
});
|
|
76
|
-
const { remoteEntry: { path: u, name: p, type: m }, types: d = { path: "", name: "", zip: "", api: "" }, buildInfo: { buildVersion: y }, globalName:
|
|
77
|
-
let
|
|
76
|
+
const { remoteEntry: { path: u, name: p, type: m }, types: d = { path: "", name: "", zip: "", api: "" }, buildInfo: { buildVersion: y }, globalName: g, ssrRemoteEntry: b } = r.metaData, { exposes: E } = r;
|
|
77
|
+
let R = {
|
|
78
78
|
version: s || "",
|
|
79
79
|
buildVersion: y,
|
|
80
|
-
globalName:
|
|
80
|
+
globalName: g,
|
|
81
81
|
remoteEntry: simpleJoinRemoteEntry(u, p),
|
|
82
82
|
remoteEntryType: m,
|
|
83
83
|
remoteTypes: simpleJoinRemoteEntry(d.path, d.name),
|
|
@@ -89,7 +89,7 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
89
89
|
sharedName: _.name,
|
|
90
90
|
version: _.version
|
|
91
91
|
})),
|
|
92
|
-
modules:
|
|
92
|
+
modules: E == null ? void 0 : E.map((_) => ({
|
|
93
93
|
moduleName: _.name,
|
|
94
94
|
modulePath: _.path,
|
|
95
95
|
assets: _.assets
|
|
@@ -97,36 +97,60 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
97
97
|
};
|
|
98
98
|
if ((S = r.metaData) != null && S.prefetchInterface) {
|
|
99
99
|
const _ = r.metaData.prefetchInterface;
|
|
100
|
-
|
|
101
|
-
...
|
|
100
|
+
R = {
|
|
101
|
+
...R,
|
|
102
102
|
prefetchInterface: _
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
if ((
|
|
106
|
-
const { path: _, name:
|
|
107
|
-
|
|
108
|
-
...
|
|
109
|
-
prefetchEntry: simpleJoinRemoteEntry(_,
|
|
105
|
+
if ((A = r.metaData) != null && A.prefetchEntry) {
|
|
106
|
+
const { path: _, name: T, type: w } = r.metaData.prefetchEntry;
|
|
107
|
+
R = {
|
|
108
|
+
...R,
|
|
109
|
+
prefetchEntry: simpleJoinRemoteEntry(_, T),
|
|
110
110
|
prefetchEntryType: w
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
if ("publicPath" in r.metaData ? a = {
|
|
114
|
-
...
|
|
114
|
+
...R,
|
|
115
115
|
publicPath: c(),
|
|
116
116
|
ssrPublicPath: r.metaData.ssrPublicPath
|
|
117
117
|
} : a = {
|
|
118
|
-
...
|
|
118
|
+
...R,
|
|
119
119
|
getPublicPath: c()
|
|
120
|
-
},
|
|
121
|
-
const _ = simpleJoinRemoteEntry(
|
|
122
|
-
a.ssrRemoteEntry = _, a.ssrRemoteEntryType =
|
|
120
|
+
}, b) {
|
|
121
|
+
const _ = simpleJoinRemoteEntry(b.path, b.name);
|
|
122
|
+
a.ssrRemoteEntry = _, a.ssrRemoteEntryType = b.type || "commonjs-module";
|
|
123
123
|
}
|
|
124
124
|
return a;
|
|
125
125
|
}
|
|
126
126
|
function isManifestProvider(r) {
|
|
127
127
|
return !!("remoteEntry" in r && r.remoteEntry.includes(MANIFEST_EXT));
|
|
128
128
|
}
|
|
129
|
-
const PREFIX = "[ Module Federation ]", DEFAULT_DELEGATE = console
|
|
129
|
+
const PREFIX = "[ Module Federation ]", DEFAULT_DELEGATE = console, LOGGER_STACK_SKIP_TOKENS = [
|
|
130
|
+
"logger.ts",
|
|
131
|
+
"logger.js",
|
|
132
|
+
"captureStackTrace",
|
|
133
|
+
"Logger.emit",
|
|
134
|
+
"Logger.log",
|
|
135
|
+
"Logger.info",
|
|
136
|
+
"Logger.warn",
|
|
137
|
+
"Logger.error",
|
|
138
|
+
"Logger.debug"
|
|
139
|
+
];
|
|
140
|
+
function captureStackTrace() {
|
|
141
|
+
try {
|
|
142
|
+
const r = new Error().stack;
|
|
143
|
+
if (!r)
|
|
144
|
+
return;
|
|
145
|
+
const [, ...t] = r.split(`
|
|
146
|
+
`), o = t.filter((s) => !LOGGER_STACK_SKIP_TOKENS.some((a) => s.includes(a)));
|
|
147
|
+
return o.length ? `Stack trace:
|
|
148
|
+
${o.slice(0, 5).join(`
|
|
149
|
+
`)}` : void 0;
|
|
150
|
+
} catch {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
130
154
|
class Logger {
|
|
131
155
|
constructor(t, o = DEFAULT_DELEGATE) {
|
|
132
156
|
this.prefix = t, this.delegate = o ?? DEFAULT_DELEGATE;
|
|
@@ -138,7 +162,7 @@ class Logger {
|
|
|
138
162
|
this.delegate = t ?? DEFAULT_DELEGATE;
|
|
139
163
|
}
|
|
140
164
|
emit(t, o) {
|
|
141
|
-
const n = this.delegate,
|
|
165
|
+
const n = this.delegate, a = isDebugMode() ? captureStackTrace() : void 0, c = a ? [...o, a] : o, i = (() => {
|
|
142
166
|
switch (t) {
|
|
143
167
|
case "log":
|
|
144
168
|
return ["log", "info"];
|
|
@@ -153,17 +177,17 @@ class Logger {
|
|
|
153
177
|
return ["debug", "log"];
|
|
154
178
|
}
|
|
155
179
|
})();
|
|
156
|
-
for (const
|
|
157
|
-
const
|
|
158
|
-
if (typeof
|
|
159
|
-
|
|
180
|
+
for (const l of i) {
|
|
181
|
+
const u = n[l];
|
|
182
|
+
if (typeof u == "function") {
|
|
183
|
+
u.call(n, this.prefix, ...c);
|
|
160
184
|
return;
|
|
161
185
|
}
|
|
162
186
|
}
|
|
163
|
-
for (const
|
|
164
|
-
const
|
|
165
|
-
if (typeof
|
|
166
|
-
|
|
187
|
+
for (const l of i) {
|
|
188
|
+
const u = DEFAULT_DELEGATE[l];
|
|
189
|
+
if (typeof u == "function") {
|
|
190
|
+
u.call(DEFAULT_DELEGATE, this.prefix, ...c);
|
|
167
191
|
return;
|
|
168
192
|
}
|
|
169
193
|
}
|
|
@@ -502,7 +526,7 @@ function setGlobalDefaultVal(r) {
|
|
|
502
526
|
setGlobalDefaultVal(CurrentGlobal);
|
|
503
527
|
setGlobalDefaultVal(nativeGlobal);
|
|
504
528
|
function setGlobalFederationConstructor(r, t = isDebugMode()) {
|
|
505
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-refactor-manifest-
|
|
529
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-refactor-manifest-20251111024434");
|
|
506
530
|
}
|
|
507
531
|
function getInfoWithoutType(r, t) {
|
|
508
532
|
if (typeof t == "string") {
|
|
@@ -705,33 +729,33 @@ function satisfy(r, t) {
|
|
|
705
729
|
const d = parseRange(m);
|
|
706
730
|
if (!d.trim())
|
|
707
731
|
return !0;
|
|
708
|
-
const y = d.split(" ").map((
|
|
732
|
+
const y = d.split(" ").map((E) => parseComparatorString(E)).join(" ");
|
|
709
733
|
if (!y.trim())
|
|
710
734
|
return !0;
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
735
|
+
const g = y.split(/\s+/).map((E) => parseGTE0(E)).filter(Boolean);
|
|
736
|
+
if (g.length === 0)
|
|
713
737
|
continue;
|
|
714
|
-
let
|
|
715
|
-
for (const
|
|
716
|
-
const
|
|
717
|
-
if (!
|
|
718
|
-
|
|
738
|
+
let b = !0;
|
|
739
|
+
for (const E of g) {
|
|
740
|
+
const R = extractComparator(E);
|
|
741
|
+
if (!R) {
|
|
742
|
+
b = !1;
|
|
719
743
|
break;
|
|
720
744
|
}
|
|
721
|
-
const [, I, , S,
|
|
745
|
+
const [, I, , S, A, _, T] = R, w = {
|
|
722
746
|
operator: I,
|
|
723
|
-
version: combineVersion(S,
|
|
747
|
+
version: combineVersion(S, A, _, T),
|
|
724
748
|
major: S,
|
|
725
|
-
minor:
|
|
749
|
+
minor: A,
|
|
726
750
|
patch: _,
|
|
727
|
-
preRelease:
|
|
751
|
+
preRelease: T == null ? void 0 : T.split(".")
|
|
728
752
|
};
|
|
729
753
|
if (!compare(w, l)) {
|
|
730
|
-
|
|
754
|
+
b = !1;
|
|
731
755
|
break;
|
|
732
756
|
}
|
|
733
757
|
}
|
|
734
|
-
if (
|
|
758
|
+
if (b)
|
|
735
759
|
return !0;
|
|
736
760
|
} catch (d) {
|
|
737
761
|
console.error(`[semver] Error processing range part "${m}":`, d);
|
|
@@ -823,16 +847,16 @@ function getRegisteredShare(r, t, o, n) {
|
|
|
823
847
|
const { requiredVersion: u } = s, m = getFindShareFunction(c)(r, l, t), d = () => {
|
|
824
848
|
if (s.singleton) {
|
|
825
849
|
if (typeof u == "string" && !satisfy(m, u)) {
|
|
826
|
-
const
|
|
827
|
-
s.strictVersion ? error(
|
|
850
|
+
const b = `Version ${m} from ${m && r[l][t][m].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;
|
|
851
|
+
s.strictVersion ? error(b) : warn(b);
|
|
828
852
|
}
|
|
829
853
|
return r[l][t][m];
|
|
830
854
|
} else {
|
|
831
855
|
if (u === !1 || u === "*" || satisfy(m, u))
|
|
832
856
|
return r[l][t][m];
|
|
833
|
-
for (const [
|
|
834
|
-
if (satisfy(
|
|
835
|
-
return
|
|
857
|
+
for (const [b, E] of Object.entries(r[l][t]))
|
|
858
|
+
if (satisfy(b, u))
|
|
859
|
+
return E;
|
|
836
860
|
}
|
|
837
861
|
}, y = {
|
|
838
862
|
shareScopeMap: r,
|
|
@@ -1037,7 +1061,7 @@ async function getRemoteEntry(r) {
|
|
|
1037
1061
|
}) : loadEntryNode({ remoteInfo: n, loaderHook: l }))).catch(async (u) => {
|
|
1038
1062
|
const p = getRemoteEntryUniqueKey(n);
|
|
1039
1063
|
if (u instanceof Error && u.message.includes(RUNTIME_008) && !a) {
|
|
1040
|
-
const d = (
|
|
1064
|
+
const d = (g) => getRemoteEntry({ ...g, _inErrorHandling: !0 }), y = await t.loaderHook.lifecycle.loadEntryError.emit({
|
|
1041
1065
|
getRemoteEntry: d,
|
|
1042
1066
|
origin: t,
|
|
1043
1067
|
remoteInfo: n,
|
|
@@ -1214,23 +1238,23 @@ class Module {
|
|
|
1214
1238
|
const { loadFactory: a = !0 } = n || { loadFactory: !0 }, c = await this.getEntry();
|
|
1215
1239
|
if (!this.inited) {
|
|
1216
1240
|
const m = this.host.shareScopeMap, d = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [this.remoteInfo.shareScope];
|
|
1217
|
-
d.length || d.push("default"), d.forEach((
|
|
1218
|
-
m[
|
|
1241
|
+
d.length || d.push("default"), d.forEach((R) => {
|
|
1242
|
+
m[R] || (m[R] = {});
|
|
1219
1243
|
});
|
|
1220
|
-
const y = m[d[0]],
|
|
1244
|
+
const y = m[d[0]], g = [], b = {
|
|
1221
1245
|
version: this.remoteInfo.version || "",
|
|
1222
1246
|
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? d : this.remoteInfo.shareScope || "default"
|
|
1223
1247
|
};
|
|
1224
|
-
Object.defineProperty(
|
|
1248
|
+
Object.defineProperty(b, "shareScopeMap", {
|
|
1225
1249
|
value: m,
|
|
1226
1250
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1227
1251
|
enumerable: !1
|
|
1228
1252
|
});
|
|
1229
|
-
const
|
|
1253
|
+
const E = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1230
1254
|
shareScope: y,
|
|
1231
1255
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1232
|
-
remoteEntryInitOptions:
|
|
1233
|
-
initScope:
|
|
1256
|
+
remoteEntryInitOptions: b,
|
|
1257
|
+
initScope: g,
|
|
1234
1258
|
remoteInfo: this.remoteInfo,
|
|
1235
1259
|
origin: this.host
|
|
1236
1260
|
});
|
|
@@ -1239,8 +1263,8 @@ class Module {
|
|
|
1239
1263
|
remoteName: this.remoteInfo.name,
|
|
1240
1264
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1241
1265
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1242
|
-
})), await c.init(
|
|
1243
|
-
...
|
|
1266
|
+
})), await c.init(E.shareScope, E.initScope, E.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit({
|
|
1267
|
+
...E,
|
|
1244
1268
|
id: t,
|
|
1245
1269
|
remoteSnapshot: s,
|
|
1246
1270
|
remoteEntryExports: c
|
|
@@ -1463,81 +1487,81 @@ function traverseModuleInfo(r, t, o, n, s = {}, a) {
|
|
|
1463
1487
|
const isExisted = (r, t) => document.querySelector(`${r}[${r === "link" ? "href" : "src"}="${t}"]`);
|
|
1464
1488
|
function generatePreloadAssets(r, t, o, n, s) {
|
|
1465
1489
|
const a = [], c = [], i = [], l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: p } = r, { preloadConfig: m } = t, { depsRemote: d } = m;
|
|
1466
|
-
if (traverseModuleInfo(n, o, (
|
|
1490
|
+
if (traverseModuleInfo(n, o, (E, R, I) => {
|
|
1467
1491
|
var $;
|
|
1468
1492
|
let S;
|
|
1469
1493
|
if (I)
|
|
1470
1494
|
S = m;
|
|
1471
1495
|
else if (Array.isArray(d)) {
|
|
1472
|
-
const
|
|
1473
|
-
if (!
|
|
1496
|
+
const P = d.find((N) => N.nameOrAlias === R.name || N.nameOrAlias === R.alias);
|
|
1497
|
+
if (!P)
|
|
1474
1498
|
return;
|
|
1475
|
-
S = defaultPreloadArgs(
|
|
1499
|
+
S = defaultPreloadArgs(P);
|
|
1476
1500
|
} else if (d === !0)
|
|
1477
1501
|
S = m;
|
|
1478
1502
|
else
|
|
1479
1503
|
return;
|
|
1480
|
-
const
|
|
1481
|
-
|
|
1482
|
-
name:
|
|
1504
|
+
const A = getResourceUrl(E, getRemoteEntryInfoFromSnapshot(E).url);
|
|
1505
|
+
A && i.push({
|
|
1506
|
+
name: R.name,
|
|
1483
1507
|
moduleInfo: {
|
|
1484
|
-
name:
|
|
1485
|
-
entry:
|
|
1486
|
-
type: "remoteEntryType" in
|
|
1487
|
-
entryGlobalName: "globalName" in
|
|
1508
|
+
name: R.name,
|
|
1509
|
+
entry: A,
|
|
1510
|
+
type: "remoteEntryType" in E ? E.remoteEntryType : "global",
|
|
1511
|
+
entryGlobalName: "globalName" in E ? E.globalName : R.name,
|
|
1488
1512
|
shareScope: "",
|
|
1489
|
-
version: "version" in
|
|
1513
|
+
version: "version" in E ? E.version : void 0
|
|
1490
1514
|
},
|
|
1491
|
-
url:
|
|
1515
|
+
url: A
|
|
1492
1516
|
});
|
|
1493
|
-
let _ = "modules" in
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
function w(
|
|
1497
|
-
const N =
|
|
1517
|
+
let _ = "modules" in E ? E.modules : [];
|
|
1518
|
+
const T = normalizePreloadExposes(S.exposes);
|
|
1519
|
+
T.length && "modules" in E && (_ = ($ = E == null ? void 0 : E.modules) == null ? void 0 : $.reduce((P, N) => ((T == null ? void 0 : T.indexOf(N.moduleName)) !== -1 && P.push(N), P), []));
|
|
1520
|
+
function w(P) {
|
|
1521
|
+
const N = P.map((M) => getResourceUrl(E, M));
|
|
1498
1522
|
return S.filter ? N.filter(S.filter) : N;
|
|
1499
1523
|
}
|
|
1500
1524
|
if (_) {
|
|
1501
|
-
const
|
|
1502
|
-
for (let N = 0; N <
|
|
1503
|
-
const
|
|
1525
|
+
const P = _.length;
|
|
1526
|
+
for (let N = 0; N < P; N++) {
|
|
1527
|
+
const M = _[N], L = `${R.name}/${M.moduleName}`;
|
|
1504
1528
|
r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1505
|
-
id:
|
|
1506
|
-
name:
|
|
1507
|
-
remoteSnapshot:
|
|
1529
|
+
id: M.moduleName === "." ? R.name : L,
|
|
1530
|
+
name: R.name,
|
|
1531
|
+
remoteSnapshot: E,
|
|
1508
1532
|
preloadConfig: S,
|
|
1509
|
-
remote:
|
|
1533
|
+
remote: R,
|
|
1510
1534
|
origin: r
|
|
1511
|
-
}), !getPreloaded(L) && (S.resourceCategory === "all" ? (a.push(...w(
|
|
1535
|
+
}), !getPreloaded(L) && (S.resourceCategory === "all" ? (a.push(...w(M.assets.css.async)), a.push(...w(M.assets.css.sync)), c.push(...w(M.assets.js.async)), c.push(...w(M.assets.js.sync))) : (S.resourceCategory = "sync") && (a.push(...w(M.assets.css.sync)), c.push(...w(M.assets.js.sync))), setPreloaded(L));
|
|
1512
1536
|
}
|
|
1513
1537
|
}
|
|
1514
1538
|
}, !0, {}, s), s.shared && s.shared.length > 0) {
|
|
1515
|
-
const
|
|
1516
|
-
const S = getRegisteredShare(r.shareScopeMap, I.sharedName,
|
|
1517
|
-
S && typeof S.lib == "function" && (I.assets.js.sync.forEach((
|
|
1518
|
-
l.add(
|
|
1519
|
-
}), I.assets.css.sync.forEach((
|
|
1520
|
-
u.add(
|
|
1539
|
+
const E = (R, I) => {
|
|
1540
|
+
const S = getRegisteredShare(r.shareScopeMap, I.sharedName, R, r.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1541
|
+
S && typeof S.lib == "function" && (I.assets.js.sync.forEach((A) => {
|
|
1542
|
+
l.add(A);
|
|
1543
|
+
}), I.assets.css.sync.forEach((A) => {
|
|
1544
|
+
u.add(A);
|
|
1521
1545
|
}));
|
|
1522
1546
|
};
|
|
1523
|
-
s.shared.forEach((
|
|
1547
|
+
s.shared.forEach((R) => {
|
|
1524
1548
|
var _;
|
|
1525
|
-
const I = (_ = p.shared) == null ? void 0 : _[
|
|
1549
|
+
const I = (_ = p.shared) == null ? void 0 : _[R.sharedName];
|
|
1526
1550
|
if (!I)
|
|
1527
1551
|
return;
|
|
1528
|
-
const S =
|
|
1552
|
+
const S = R.version ? I.find((T) => T.version === R.version) : I;
|
|
1529
1553
|
if (!S)
|
|
1530
1554
|
return;
|
|
1531
|
-
arrayOptions(S).forEach((
|
|
1532
|
-
|
|
1555
|
+
arrayOptions(S).forEach((T) => {
|
|
1556
|
+
E(T, R);
|
|
1533
1557
|
});
|
|
1534
1558
|
});
|
|
1535
1559
|
}
|
|
1536
|
-
const
|
|
1560
|
+
const g = c.filter((E) => !l.has(E) && !isExisted("script", E));
|
|
1537
1561
|
return {
|
|
1538
|
-
cssAssets: a.filter((
|
|
1539
|
-
jsAssetsWithoutEntry:
|
|
1540
|
-
entryAssets: i.filter((
|
|
1562
|
+
cssAssets: a.filter((E) => !u.has(E) && !isExisted("link", E)),
|
|
1563
|
+
jsAssetsWithoutEntry: g,
|
|
1564
|
+
entryAssets: i.filter((E) => !isExisted("script", E.url))
|
|
1541
1565
|
};
|
|
1542
1566
|
}
|
|
1543
1567
|
const generatePreloadAssetsPlugin = function() {
|
|
@@ -1632,13 +1656,13 @@ class SnapshotHandler {
|
|
|
1632
1656
|
let m, d;
|
|
1633
1657
|
if (u)
|
|
1634
1658
|
if (isManifestProvider(u)) {
|
|
1635
|
-
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "",
|
|
1659
|
+
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "", g = await this.getManifestJson(y, t, {}), b = setGlobalSnapshotInfoByModuleInfo({
|
|
1636
1660
|
...t,
|
|
1637
1661
|
// The global remote may be overridden
|
|
1638
1662
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1639
1663
|
entry: y
|
|
1640
|
-
},
|
|
1641
|
-
m =
|
|
1664
|
+
}, g);
|
|
1665
|
+
m = g, d = b;
|
|
1642
1666
|
} else {
|
|
1643
1667
|
const { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1644
1668
|
options: this.HostInstance.options,
|
|
@@ -1649,13 +1673,13 @@ class SnapshotHandler {
|
|
|
1649
1673
|
m = y, d = p;
|
|
1650
1674
|
}
|
|
1651
1675
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1652
|
-
const y = await this.getManifestJson(t.entry, t, {}),
|
|
1676
|
+
const y = await this.getManifestJson(t.entry, t, {}), g = setGlobalSnapshotInfoByModuleInfo(t, y), { remoteSnapshot: b } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1653
1677
|
options: this.HostInstance.options,
|
|
1654
1678
|
moduleInfo: t,
|
|
1655
1679
|
remoteSnapshot: y,
|
|
1656
1680
|
from: "global"
|
|
1657
1681
|
});
|
|
1658
|
-
m =
|
|
1682
|
+
m = b, d = g;
|
|
1659
1683
|
} else
|
|
1660
1684
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1661
1685
|
hostName: t.name,
|
|
@@ -1731,13 +1755,16 @@ class SharedHandler {
|
|
|
1731
1755
|
const { shareInfos: n, shared: s } = formatShareConfigs(t, o);
|
|
1732
1756
|
return Object.keys(n).forEach((c) => {
|
|
1733
1757
|
n[c].forEach((l) => {
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1758
|
+
l.scope.forEach((u) => {
|
|
1759
|
+
var m;
|
|
1760
|
+
((m = this.shareScopeMap[u]) == null ? void 0 : m[c]) || this.setShared({
|
|
1761
|
+
pkgName: c,
|
|
1762
|
+
lib: l.lib,
|
|
1763
|
+
get: l.get,
|
|
1764
|
+
loaded: l.loaded || !!l.lib,
|
|
1765
|
+
shared: l,
|
|
1766
|
+
from: o.name
|
|
1767
|
+
});
|
|
1741
1768
|
});
|
|
1742
1769
|
});
|
|
1743
1770
|
}), {
|
|
@@ -1814,47 +1841,47 @@ class SharedHandler {
|
|
|
1814
1841
|
let c = o == null ? void 0 : o.initScope;
|
|
1815
1842
|
const i = [];
|
|
1816
1843
|
if (s !== "build") {
|
|
1817
|
-
const { initTokens:
|
|
1844
|
+
const { initTokens: g } = this;
|
|
1818
1845
|
c || (c = []);
|
|
1819
|
-
let
|
|
1820
|
-
if (
|
|
1846
|
+
let b = g[t];
|
|
1847
|
+
if (b || (b = g[t] = { from: this.host.name }), c.indexOf(b) >= 0)
|
|
1821
1848
|
return i;
|
|
1822
|
-
c.push(
|
|
1849
|
+
c.push(b);
|
|
1823
1850
|
}
|
|
1824
1851
|
const l = this.shareScopeMap, u = n.options.name;
|
|
1825
1852
|
l[t] || (l[t] = {});
|
|
1826
|
-
const p = l[t], m = (
|
|
1853
|
+
const p = l[t], m = (g, b) => {
|
|
1827
1854
|
var _;
|
|
1828
|
-
const { version:
|
|
1829
|
-
p[
|
|
1830
|
-
const I = p[
|
|
1831
|
-
(!S || S.strategy !== "loaded-first" && !S.loaded && (!
|
|
1832
|
-
}, d = (
|
|
1833
|
-
const { module:
|
|
1834
|
-
id:
|
|
1855
|
+
const { version: E, eager: R } = b;
|
|
1856
|
+
p[g] = p[g] || {};
|
|
1857
|
+
const I = p[g], S = I[E], A = !!(S && (S.eager || (_ = S.shareConfig) != null && _.eager));
|
|
1858
|
+
(!S || S.strategy !== "loaded-first" && !S.loaded && (!R != !A ? R : u > S.from)) && (I[E] = b);
|
|
1859
|
+
}, d = (g) => g && g.init && g.init(l[t], c), y = async (g) => {
|
|
1860
|
+
const { module: b } = await n.remoteHandler.getRemoteModuleAndOptions({
|
|
1861
|
+
id: g
|
|
1835
1862
|
});
|
|
1836
|
-
if (
|
|
1837
|
-
let
|
|
1863
|
+
if (b.getEntry) {
|
|
1864
|
+
let E;
|
|
1838
1865
|
try {
|
|
1839
|
-
|
|
1840
|
-
} catch (
|
|
1841
|
-
|
|
1842
|
-
id:
|
|
1843
|
-
error:
|
|
1866
|
+
E = await b.getEntry();
|
|
1867
|
+
} catch (R) {
|
|
1868
|
+
E = await n.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1869
|
+
id: g,
|
|
1870
|
+
error: R,
|
|
1844
1871
|
from: "runtime",
|
|
1845
1872
|
lifecycle: "beforeLoadShare",
|
|
1846
1873
|
origin: n
|
|
1847
1874
|
});
|
|
1848
1875
|
}
|
|
1849
|
-
|
|
1876
|
+
b.inited || (await d(E), b.inited = !0);
|
|
1850
1877
|
}
|
|
1851
1878
|
};
|
|
1852
|
-
return Object.keys(n.options.shared).forEach((
|
|
1853
|
-
n.options.shared[
|
|
1854
|
-
|
|
1879
|
+
return Object.keys(n.options.shared).forEach((g) => {
|
|
1880
|
+
n.options.shared[g].forEach((E) => {
|
|
1881
|
+
E.scope.includes(t) && m(g, E);
|
|
1855
1882
|
});
|
|
1856
|
-
}), (n.options.shareStrategy === "version-first" || a === "version-first") && n.options.remotes.forEach((
|
|
1857
|
-
|
|
1883
|
+
}), (n.options.shareStrategy === "version-first" || a === "version-first") && n.options.remotes.forEach((g) => {
|
|
1884
|
+
g.shareScope === t && i.push(y(g.name));
|
|
1858
1885
|
}), i;
|
|
1859
1886
|
}
|
|
1860
1887
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
@@ -1928,7 +1955,7 @@ class SharedHandler {
|
|
|
1928
1955
|
if (this.shareScopeMap[d] || (this.shareScopeMap[d] = {}), this.shareScopeMap[d][t] || (this.shareScopeMap[d][t] = {}), !this.shareScopeMap[d][t][l]) {
|
|
1929
1956
|
this.shareScopeMap[d][t][l] = {
|
|
1930
1957
|
version: l,
|
|
1931
|
-
scope: [
|
|
1958
|
+
scope: [d],
|
|
1932
1959
|
...p,
|
|
1933
1960
|
lib: s,
|
|
1934
1961
|
loaded: c,
|
|
@@ -1985,7 +2012,7 @@ class RemoteHandler {
|
|
|
1985
2012
|
loadFactory: !0
|
|
1986
2013
|
}, { module: a, moduleOptions: c, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
1987
2014
|
id: t
|
|
1988
|
-
}), { pkgNameOrAlias: l, remote: u, expose: p, id: m, remoteSnapshot: d } = i, y = await a.get(m, p, o, d),
|
|
2015
|
+
}), { pkgNameOrAlias: l, remote: u, expose: p, id: m, remoteSnapshot: d } = i, y = await a.get(m, p, o, d), g = await this.hooks.lifecycle.onLoad.emit({
|
|
1989
2016
|
id: m,
|
|
1990
2017
|
pkgNameOrAlias: l,
|
|
1991
2018
|
expose: p,
|
|
@@ -1996,7 +2023,7 @@ class RemoteHandler {
|
|
|
1996
2023
|
moduleInstance: a,
|
|
1997
2024
|
origin: n
|
|
1998
2025
|
});
|
|
1999
|
-
return this.setIdToRemoteMap(t, i), typeof
|
|
2026
|
+
return this.setIdToRemoteMap(t, i), typeof g == "function" ? g : y;
|
|
2000
2027
|
} catch (s) {
|
|
2001
2028
|
const { from: a = "runtime" } = o || { from: "runtime" }, c = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2002
2029
|
id: t,
|
|
@@ -2050,16 +2077,16 @@ class RemoteHandler {
|
|
|
2050
2077
|
options: o.options,
|
|
2051
2078
|
origin: o
|
|
2052
2079
|
});
|
|
2053
|
-
} catch (
|
|
2080
|
+
} catch (g) {
|
|
2054
2081
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2055
2082
|
id: n,
|
|
2056
2083
|
options: o.options,
|
|
2057
2084
|
origin: o,
|
|
2058
2085
|
from: "runtime",
|
|
2059
|
-
error:
|
|
2086
|
+
error: g,
|
|
2060
2087
|
lifecycle: "beforeRequest"
|
|
2061
2088
|
}), !s)
|
|
2062
|
-
throw
|
|
2089
|
+
throw g;
|
|
2063
2090
|
}
|
|
2064
2091
|
const { id: a } = s, c = matchRemoteWithNameAndExpose(o.options.remotes, a);
|
|
2065
2092
|
assert(c, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
@@ -2124,24 +2151,24 @@ class RemoteHandler {
|
|
|
2124
2151
|
if (m !== -1) {
|
|
2125
2152
|
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[m];
|
|
2126
2153
|
p = y.options.id || p;
|
|
2127
|
-
const
|
|
2128
|
-
let
|
|
2129
|
-
const
|
|
2130
|
-
Object.keys(
|
|
2131
|
-
const I =
|
|
2154
|
+
const g = getGlobalShareScope();
|
|
2155
|
+
let b = !0;
|
|
2156
|
+
const E = [];
|
|
2157
|
+
Object.keys(g).forEach((R) => {
|
|
2158
|
+
const I = g[R];
|
|
2132
2159
|
I && Object.keys(I).forEach((S) => {
|
|
2133
|
-
const
|
|
2134
|
-
|
|
2135
|
-
const
|
|
2136
|
-
|
|
2137
|
-
const $ =
|
|
2138
|
-
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((
|
|
2139
|
-
|
|
2160
|
+
const A = I[S];
|
|
2161
|
+
A && Object.keys(A).forEach((_) => {
|
|
2162
|
+
const T = A[_];
|
|
2163
|
+
T && Object.keys(T).forEach((w) => {
|
|
2164
|
+
const $ = T[w];
|
|
2165
|
+
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((P) => P !== i.name), $.useIn.length ? b = !1 : E.push([
|
|
2166
|
+
R,
|
|
2140
2167
|
S,
|
|
2141
2168
|
_,
|
|
2142
2169
|
w
|
|
2143
|
-
])) :
|
|
2144
|
-
|
|
2170
|
+
])) : E.push([
|
|
2171
|
+
R,
|
|
2145
2172
|
S,
|
|
2146
2173
|
_,
|
|
2147
2174
|
w
|
|
@@ -2149,9 +2176,9 @@ class RemoteHandler {
|
|
|
2149
2176
|
});
|
|
2150
2177
|
});
|
|
2151
2178
|
});
|
|
2152
|
-
}),
|
|
2153
|
-
var _,
|
|
2154
|
-
(w = (
|
|
2179
|
+
}), b && (y.shareScopeMap = {}, delete g[p]), E.forEach(([R, I, S, A]) => {
|
|
2180
|
+
var _, T, w;
|
|
2181
|
+
(w = (T = (_ = g[R]) == null ? void 0 : _[I]) == null ? void 0 : T[S]) == null || delete w[A];
|
|
2155
2182
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(m, 1);
|
|
2156
2183
|
}
|
|
2157
2184
|
const { hostGlobalSnapshot: d } = getGlobalRemoteInfo(t, n);
|
|
@@ -2176,7 +2203,7 @@ class ModuleFederation {
|
|
|
2176
2203
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2177
2204
|
// maybe will change, temporarily for internal use only
|
|
2178
2205
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2179
|
-
}), this.version = "0.0.0-refactor-manifest-
|
|
2206
|
+
}), this.version = "0.0.0-refactor-manifest-20251111024434", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2180
2207
|
// FIXME: may not be suitable , not open to the public yet
|
|
2181
2208
|
getModuleInfo: new SyncHook(),
|
|
2182
2209
|
createScript: new SyncHook(),
|
|
@@ -2292,7 +2319,7 @@ function addBasenameToNestedRoutes(r, t) {
|
|
|
2292
2319
|
}
|
|
2293
2320
|
function processRoutes(r) {
|
|
2294
2321
|
const { router: t, basename: o, memoryRoute: n, hashRoute: s } = r, a = t.getRoutes().sort(
|
|
2295
|
-
(d, y) => d.path.split("/").filter((
|
|
2322
|
+
(d, y) => d.path.split("/").filter((g) => g).length - y.path.split("/").filter((g) => g).length
|
|
2296
2323
|
), c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
2297
2324
|
a.forEach((d) => {
|
|
2298
2325
|
c.set(d.path, d);
|
|
@@ -2300,15 +2327,15 @@ function processRoutes(r) {
|
|
|
2300
2327
|
const l = (d, y) => `${d}/${y}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/", u = (d, y = "") => {
|
|
2301
2328
|
if (!d.children || d.children.length === 0)
|
|
2302
2329
|
return d;
|
|
2303
|
-
for (let
|
|
2304
|
-
const
|
|
2305
|
-
if (
|
|
2330
|
+
for (let g = 0; g < d.children.length; g++) {
|
|
2331
|
+
const b = d.children[g], E = l(y, b.path), R = c.get(E);
|
|
2332
|
+
if (R && !i.has(R)) {
|
|
2306
2333
|
const I = {
|
|
2307
|
-
...
|
|
2308
|
-
path:
|
|
2334
|
+
...R,
|
|
2335
|
+
path: b.path
|
|
2309
2336
|
// Keep the original relative path from static route
|
|
2310
2337
|
};
|
|
2311
|
-
d.children[
|
|
2338
|
+
d.children[g] = I, i.add(R), u(I, E);
|
|
2312
2339
|
}
|
|
2313
2340
|
}
|
|
2314
2341
|
return d;
|
|
@@ -2328,9 +2355,9 @@ function processRoutes(r) {
|
|
|
2328
2355
|
function createBridgeComponent(r) {
|
|
2329
2356
|
const t = /* @__PURE__ */ new Map(), o = getInstance();
|
|
2330
2357
|
return () => ({
|
|
2331
|
-
__APP_VERSION__: "0.0.0-refactor-manifest-
|
|
2358
|
+
__APP_VERSION__: "0.0.0-refactor-manifest-20251111024434",
|
|
2332
2359
|
async render(n) {
|
|
2333
|
-
var
|
|
2360
|
+
var g, b, E;
|
|
2334
2361
|
LoggerInstance.debug("createBridgeComponent render Info", n);
|
|
2335
2362
|
const {
|
|
2336
2363
|
moduleName: s,
|
|
@@ -2341,7 +2368,7 @@ function createBridgeComponent(r) {
|
|
|
2341
2368
|
...u
|
|
2342
2369
|
} = n, p = Vue.createApp(r.rootComponent, u);
|
|
2343
2370
|
t.set(a, p);
|
|
2344
|
-
const m = await ((
|
|
2371
|
+
const m = await ((E = (b = (g = o == null ? void 0 : o.bridgeHook) == null ? void 0 : g.lifecycle) == null ? void 0 : b.beforeBridgeRender) == null ? void 0 : E.emit(n)), d = m && typeof m == "object" && (m != null && m.extraProps) ? m == null ? void 0 : m.extraProps : {}, y = r.appOptions({
|
|
2345
2372
|
app: p,
|
|
2346
2373
|
basename: c,
|
|
2347
2374
|
memoryRoute: i,
|
|
@@ -2350,14 +2377,14 @@ function createBridgeComponent(r) {
|
|
|
2350
2377
|
...d
|
|
2351
2378
|
});
|
|
2352
2379
|
if (y != null && y.router) {
|
|
2353
|
-
const { history:
|
|
2380
|
+
const { history: R, routes: I } = processRoutes({
|
|
2354
2381
|
router: y.router,
|
|
2355
2382
|
basename: n.basename,
|
|
2356
2383
|
memoryRoute: n.memoryRoute,
|
|
2357
2384
|
hashRoute: n.hashRoute
|
|
2358
2385
|
}), S = VueRouter.createRouter({
|
|
2359
2386
|
...y.router.options,
|
|
2360
|
-
history:
|
|
2387
|
+
history: R,
|
|
2361
2388
|
routes: I
|
|
2362
2389
|
});
|
|
2363
2390
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
@@ -2391,7 +2418,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2391
2418
|
inheritAttrs: !1,
|
|
2392
2419
|
setup(r) {
|
|
2393
2420
|
const t = ref(null), o = ref(null), n = ref(""), s = useRoute(), a = getInstance(), c = useAttrs(), i = async () => {
|
|
2394
|
-
var d, y,
|
|
2421
|
+
var d, y, g, b;
|
|
2395
2422
|
const u = (d = r.providerInfo) == null ? void 0 : d.call(r);
|
|
2396
2423
|
o.value = u;
|
|
2397
2424
|
let p = {
|
|
@@ -2403,7 +2430,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2403
2430
|
hashRoute: r.hashRoute
|
|
2404
2431
|
};
|
|
2405
2432
|
LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>", p);
|
|
2406
|
-
const m = await ((
|
|
2433
|
+
const m = await ((b = (g = (y = a == null ? void 0 : a.bridgeHook) == null ? void 0 : y.lifecycle) == null ? void 0 : g.beforeBridgeRender) == null ? void 0 : b.emit(p)) || {};
|
|
2407
2434
|
p = {
|
|
2408
2435
|
...p,
|
|
2409
2436
|
...m.extraProps
|
|
@@ -2430,7 +2457,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2430
2457
|
});
|
|
2431
2458
|
function createRemoteAppComponent(r) {
|
|
2432
2459
|
return defineAsyncComponent({
|
|
2433
|
-
__APP_VERSION__: "0.0.0-refactor-manifest-
|
|
2460
|
+
__APP_VERSION__: "0.0.0-refactor-manifest-20251111024434",
|
|
2434
2461
|
...r.asyncComponentOptions,
|
|
2435
2462
|
//@ts-ignore
|
|
2436
2463
|
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-refactor-manifest-
|
|
10
|
+
"version": "0.0.0-refactor-manifest-20251111024434",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"vue-router": "=4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@module-federation/bridge-shared": "0.0.0-refactor-manifest-
|
|
36
|
-
"@module-federation/runtime": "0.0.0-refactor-manifest-
|
|
37
|
-
"@module-federation/sdk": "0.0.0-refactor-manifest-
|
|
35
|
+
"@module-federation/bridge-shared": "0.0.0-refactor-manifest-20251111024434",
|
|
36
|
+
"@module-federation/runtime": "0.0.0-refactor-manifest-20251111024434",
|
|
37
|
+
"@module-federation/sdk": "0.0.0-refactor-manifest-20251111024434"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^18.3.11",
|
|
41
41
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
42
42
|
"@vitejs/plugin-vue-jsx": "^4.0.0",
|
|
43
43
|
"typescript": "^5.2.2",
|
|
44
|
-
"vite": "^5.4.
|
|
44
|
+
"vite": "^5.4.21",
|
|
45
45
|
"vite-plugin-dts": "^4.3.0",
|
|
46
46
|
"vue": "^3.4.21",
|
|
47
47
|
"vue-router": "4.4.5",
|