@module-federation/bridge-vue3 0.0.0-next-20250526062606 → 0.0.0-next-20250527065931
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -5
- package/dist/index.cjs +3 -3
- package/dist/index.js +107 -114
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
# @module-federation/bridge-vue3
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20250527065931
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @module-federation/runtime@0.0.0-next-20250527065931
|
|
8
|
+
- @module-federation/sdk@0.0.0-next-20250527065931
|
|
9
|
+
- @module-federation/bridge-shared@0.0.0-next-20250527065931
|
|
10
|
+
|
|
11
|
+
## 0.14.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
6
14
|
|
|
7
15
|
- 677aac9: vue.js has router option added to the vue3-bridge
|
|
8
16
|
- Updated dependencies [82b8cac]
|
|
9
|
-
- Updated dependencies [494ce80]
|
|
10
17
|
- Updated dependencies [677aac9]
|
|
11
|
-
- @module-federation/sdk@0.
|
|
12
|
-
- @module-federation/bridge-shared@0.
|
|
13
|
-
- @module-federation/runtime@0.
|
|
18
|
+
- @module-federation/sdk@0.14.0
|
|
19
|
+
- @module-federation/bridge-shared@0.14.0
|
|
20
|
+
- @module-federation/runtime@0.14.0
|
|
14
21
|
|
|
15
22
|
## 0.13.1
|
|
16
23
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vue=require("vue"),VueRouter=require("vue-router");function _interopNamespaceDefault(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>n[r]})}}return t.default=n,Object.freeze(t)}const Vue__namespace=_interopNamespaceDefault(Vue),VueRouter__namespace=_interopNamespaceDefault(VueRouter);function _extends$2(){return _extends$2=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s])}return t},_extends$2.apply(this,arguments)}const MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",BROWSER_LOG_VALUE="1",SEPARATOR=":";function isBrowserEnv(){return typeof window<"u"&&typeof window.document<"u"}function isReactNativeEnv(){var n;return typeof navigator<"u"&&((n=navigator)==null?void 0:n.product)==="ReactNative"}function isBrowserDebug(){try{if(isBrowserEnv()&&window.localStorage)return localStorage.getItem(BROWSER_LOG_KEY)===BROWSER_LOG_VALUE}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(...n){return n.length?n.reduce((t,r)=>r?t?`${t}${SEPARATOR}${r}`:r:t,""):""},getResourceUrl=(n,t)=>{if("getPublicPath"in n){let r;return n.getPublicPath.startsWith("function")?r=new Function("return "+n.getPublicPath)()():r=new Function(n.getPublicPath)(),`${r}${t}`}else return"publicPath"in n?!isBrowserEnv()&&!isReactNativeEnv()&&"ssrPublicPath"in n?`${n.ssrPublicPath}${t}`:`${n.publicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",n,t),"")},warn$1=n=>{console.warn(`${LOG_CATEGORY$1}: ${n}`)};function safeToString(n){try{return JSON.stringify(n,null,2)}catch{return""}}const simpleJoinRemoteEntry=(n,t)=>{if(!n)return t;const o=(s=>{if(s===".")return"";if(s.startsWith("./"))return s.replace("./","");if(s.startsWith("/")){const l=s.slice(1);return l.endsWith("/")?l.slice(0,-1):l}return s})(n);return o?o.endsWith("/")?`${o}${t}`:`${o}/${t}`:t};function inferAutoPublicPath(n){return n.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(n,t={}){var r,o;const{remotes:s={},overrides:l={},version:a}=t;let i;const c=()=>"publicPath"in n.metaData?n.metaData.publicPath==="auto"&&a?inferAutoPublicPath(a):n.metaData.publicPath:n.metaData.getPublicPath,u=Object.keys(l);let d={};if(!Object.keys(s).length){var h;d=((h=n.remotes)==null?void 0:h.reduce((
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vue=require("vue"),VueRouter=require("vue-router");function _interopNamespaceDefault(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>n[r]})}}return t.default=n,Object.freeze(t)}const Vue__namespace=_interopNamespaceDefault(Vue),VueRouter__namespace=_interopNamespaceDefault(VueRouter);function _extends$2(){return _extends$2=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s])}return t},_extends$2.apply(this,arguments)}const MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",BROWSER_LOG_VALUE="1",SEPARATOR=":";function isBrowserEnv(){return typeof window<"u"&&typeof window.document<"u"}function isReactNativeEnv(){var n;return typeof navigator<"u"&&((n=navigator)==null?void 0:n.product)==="ReactNative"}function isBrowserDebug(){try{if(isBrowserEnv()&&window.localStorage)return localStorage.getItem(BROWSER_LOG_KEY)===BROWSER_LOG_VALUE}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(...n){return n.length?n.reduce((t,r)=>r?t?`${t}${SEPARATOR}${r}`:r:t,""):""},getResourceUrl=(n,t)=>{if("getPublicPath"in n){let r;return n.getPublicPath.startsWith("function")?r=new Function("return "+n.getPublicPath)()():r=new Function(n.getPublicPath)(),`${r}${t}`}else return"publicPath"in n?!isBrowserEnv()&&!isReactNativeEnv()&&"ssrPublicPath"in n?`${n.ssrPublicPath}${t}`:`${n.publicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",n,t),"")},warn$1=n=>{console.warn(`${LOG_CATEGORY$1}: ${n}`)};function safeToString(n){try{return JSON.stringify(n,null,2)}catch{return""}}const simpleJoinRemoteEntry=(n,t)=>{if(!n)return t;const o=(s=>{if(s===".")return"";if(s.startsWith("./"))return s.replace("./","");if(s.startsWith("/")){const l=s.slice(1);return l.endsWith("/")?l.slice(0,-1):l}return s})(n);return o?o.endsWith("/")?`${o}${t}`:`${o}/${t}`:t};function inferAutoPublicPath(n){return n.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(n,t={}){var r,o;const{remotes:s={},overrides:l={},version:a}=t;let i;const c=()=>"publicPath"in n.metaData?n.metaData.publicPath==="auto"&&a?inferAutoPublicPath(a):n.metaData.publicPath:n.metaData.getPublicPath,u=Object.keys(l);let d={};if(!Object.keys(s).length){var h;d=((h=n.remotes)==null?void 0:h.reduce((b,v)=>{let $;const A=v.federationContainerName;return u.includes(A)?$=l[A]:"version"in v?$=v.version:$=v.entry,b[A]={matchedVersion:$},b},{}))||{}}Object.keys(s).forEach(b=>d[b]={matchedVersion:u.includes(b)?l[b]:s[b]});const{remoteEntry:{path:p,name:m,type:_},types:E,buildInfo:{buildVersion:y},globalName:g,ssrRemoteEntry:I}=n.metaData,{exposes:R}=n;let S={version:a||"",buildVersion:y,globalName:g,remoteEntry:simpleJoinRemoteEntry(p,m),remoteEntryType:_,remoteTypes:simpleJoinRemoteEntry(E.path,E.name),remoteTypesZip:E.zip||"",remoteTypesAPI:E.api||"",remotesInfo:d,shared:n==null?void 0:n.shared.map(b=>({assets:b.assets,sharedName:b.name,version:b.version})),modules:R==null?void 0:R.map(b=>({moduleName:b.name,modulePath:b.path,assets:b.assets}))};if((r=n.metaData)!=null&&r.prefetchInterface){const b=n.metaData.prefetchInterface;S=_extends$2({},S,{prefetchInterface:b})}if((o=n.metaData)!=null&&o.prefetchEntry){const{path:b,name:v,type:$}=n.metaData.prefetchEntry;S=_extends$2({},S,{prefetchEntry:simpleJoinRemoteEntry(b,v),prefetchEntryType:$})}if("publicPath"in n.metaData?i=_extends$2({},S,{publicPath:c(),ssrPublicPath:n.metaData.ssrPublicPath}):i=_extends$2({},S,{getPublicPath:c()}),I){const b=simpleJoinRemoteEntry(I.path,I.name);i.ssrRemoteEntry=b,i.ssrRemoteEntryType=I.type||"commonjs-module"}return i}function isManifestProvider(n){return!!("remoteEntry"in n&&n.remoteEntry.includes(MANIFEST_EXT))}let Logger=class{setPrefix(t){this.prefix=t}log(...t){console.log(this.prefix,...t)}warn(...t){console.log(this.prefix,...t)}error(...t){console.log(this.prefix,...t)}success(...t){console.log(this.prefix,...t)}info(...t){console.log(this.prefix,...t)}ready(...t){console.log(this.prefix,...t)}debug(...t){isDebugMode()&&console.log(this.prefix,...t)}constructor(t){this.prefix=t}};function createLogger(n){return new Logger(n)}async function safeWrapper(n,t){try{return await n()}catch(r){warn$1(r);return}}function isStaticResourcesEqual(n,t){const r=/^(https?:)?\/\//i,o=n.replace(r,"").replace(/\/$/,""),s=t.replace(r,"").replace(/\/$/,"");return o===s}function createScript(n){let t=null,r=!0,o=2e4,s;const l=document.getElementsByTagName("script");for(let i=0;i<l.length;i++){const c=l[i],u=c.getAttribute("src");if(u&&isStaticResourcesEqual(u,n.url)){t=c,r=!1;break}}if(!t){const i=n.attrs;t=document.createElement("script"),t.type=(i==null?void 0:i.type)==="module"?"module":"text/javascript";let c;n.createScriptHook&&(c=n.createScriptHook(n.url,n.attrs),c instanceof HTMLScriptElement?t=c:typeof c=="object"&&("script"in c&&c.script&&(t=c.script),"timeout"in c&&c.timeout&&(o=c.timeout))),t.src||(t.src=n.url),i&&!c&&Object.keys(i).forEach(u=>{t&&(u==="async"||u==="defer"?t[u]=i[u]:t.getAttribute(u)||t.setAttribute(u,i[u]))})}const a=async(i,c)=>{clearTimeout(s);const u=()=>{(c==null?void 0:c.type)==="error"?n!=null&&n.onErrorCallback&&(n==null||n.onErrorCallback(c)):n!=null&&n.cb&&(n==null||n.cb())};if(t&&(t.onerror=null,t.onload=null,safeWrapper(()=>{const{needDeleteScript:d=!0}=n;d&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),i&&typeof i=="function")){const d=i(c);if(d instanceof Promise){const h=await d;return u(),h}return u(),d}u()};return t.onerror=a.bind(null,t.onerror),t.onload=a.bind(null,t.onload),s=setTimeout(()=>{a(null,new Error(`Remote script "${n.url}" time-outed.`))},o),{script:t,needAttach:r}}function createLink(n){let t=null,r=!0;const o=document.getElementsByTagName("link");for(let l=0;l<o.length;l++){const a=o[l],i=a.getAttribute("href"),c=a.getAttribute("rel");if(i&&isStaticResourcesEqual(i,n.url)&&c===n.attrs.rel){t=a,r=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",n.url);let l;const a=n.attrs;n.createLinkHook&&(l=n.createLinkHook(n.url,a),l instanceof HTMLLinkElement&&(t=l)),a&&!l&&Object.keys(a).forEach(i=>{t&&!t.getAttribute(i)&&t.setAttribute(i,a[i])})}const s=(l,a)=>{const i=()=>{(a==null?void 0:a.type)==="error"?n!=null&&n.onErrorCallback&&(n==null||n.onErrorCallback(a)):n!=null&&n.cb&&(n==null||n.cb())};if(t&&(t.onerror=null,t.onload=null,safeWrapper(()=>{const{needDeleteLink:c=!0}=n;c&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),l)){const c=l(a);return i(),c}i()};return t.onerror=s.bind(null,t.onerror),t.onload=s.bind(null,t.onload),{link:t,needAttach:r}}function loadScript(n,t){const{attrs:r={},createScriptHook:o}=t;return new Promise((s,l)=>{const{script:a,needAttach:i}=createScript({url:n,cb:s,onErrorCallback:l,attrs:_extends$2({fetchpriority:"high"},r),createScriptHook:o,needDeleteScript:!0});i&&document.head.appendChild(a)})}function importNodeModule(n){if(!n)throw new Error("import specifier is required");return new Function("name","return import(name)")(n).then(r=>r).catch(r=>{throw console.error(`Error importing module ${n}:`,r),r})}const loadNodeFetch=async()=>{const n=await importNodeModule("node-fetch");return n.default||n},lazyLoaderHookFetch=async(n,t,r)=>{const s=await((l,a)=>r.lifecycle.fetch.emit(l,a))(n,t||{});return!s||!(s instanceof Response)?(typeof fetch>"u"?await loadNodeFetch():fetch)(n,t||{}):s},createScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(url,cb,attrs,loaderHook)=>{if(loaderHook!=null&&loaderHook.createScriptHook){const n=loaderHook.createScriptHook(url);n&&typeof n=="object"&&"url"in n&&(url=n.url)}let urlObj;try{urlObj=new URL(url)}catch(n){console.error("Error constructing URL:",n),cb(new Error(`Invalid URL: ${n}`));return}const getFetch=async()=>loaderHook!=null&&loaderHook.fetch?(n,t)=>lazyLoaderHookFetch(n,t,loaderHook):typeof fetch>"u"?loadNodeFetch():fetch,handleScriptFetch=async(f,urlObj)=>{try{var _vm_constants;const res=await f(urlObj.href),data=await res.text(),[path,vm]=await Promise.all([importNodeModule("path"),importNodeModule("vm")]),scriptContext={exports:{},module:{exports:{}}},urlDirname=urlObj.pathname.split("/").slice(0,-1).join("/"),filename=path.basename(urlObj.pathname);var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;const script=new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}
|
|
2
2
|
})`,{filename,importModuleDynamically:(_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER=(_vm_constants=vm.constants)==null?void 0:_vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER)!=null?_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER:importNodeModule});script.runInThisContext()(scriptContext.exports,scriptContext.module,eval("require"),urlDirname,filename);const exportedInterface=scriptContext.module.exports||scriptContext.exports;if(attrs&&exportedInterface&&attrs.globalName){const n=exportedInterface[attrs.globalName]||exportedInterface;cb(void 0,n);return}cb(void 0,exportedInterface)}catch(n){cb(n instanceof Error?n:new Error(`Script execution error: ${n}`))}};getFetch().then(async n=>{if((attrs==null?void 0:attrs.type)==="esm"||(attrs==null?void 0:attrs.type)==="module")return loadModule(urlObj.href,{fetch:n,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(n,urlObj)}).catch(n=>{cb(n)})}:(n,t,r,o)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},loadScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(n,t)=>new Promise((r,o)=>{createScriptNode(n,(s,l)=>{if(s)o(s);else{var a,i;const c=(t==null||(a=t.attrs)==null?void 0:a.globalName)||`__FEDERATION_${t==null||(i=t.attrs)==null?void 0:i.name}:custom__`,u=globalThis[c]=l;r(u)}},t.attrs,t.loaderHook)}):(n,t)=>{throw new Error("loadScriptNode is disabled in non-Node.js environment")};async function loadModule(n,t){const{fetch:r,vm:o}=t,l=await(await r(n)).text(),a=new o.SourceTextModule(l,{importModuleDynamically:async(i,c)=>{const u=new URL(i,n).href;return loadModule(u,t)}});return await a.link(async i=>{const c=new URL(i,n).href;return await loadModule(c,t)}),a}const LoggerInstance=createLogger("[ Module Federation Bridge Vue3 ]");function _extends$1(){return _extends$1=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s])}return t},_extends$1.apply(this,arguments)}function _object_without_properties_loose(n,t){if(n==null)return{};var r={},o=Object.keys(n),s,l;for(l=0;l<o.length;l++)s=o[l],!(t.indexOf(s)>=0)&&(r[s]=n[s]);return r}const RUNTIME_001="RUNTIME-001",RUNTIME_002="RUNTIME-002",RUNTIME_003="RUNTIME-003",RUNTIME_004="RUNTIME-004",RUNTIME_005="RUNTIME-005",RUNTIME_006="RUNTIME-006",RUNTIME_007="RUNTIME-007",RUNTIME_008="RUNTIME-008",TYPE_001="TYPE-001",BUILD_001="BUILD-001",getDocsUrl=n=>`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${n.split("-")[0].toLowerCase()}/${n}`,getShortErrorMsg=(n,t,r,o)=>{const s=[`${[t[n]]} #${n}`];return r&&s.push(`args: ${JSON.stringify(r)}`),s.push(getDocsUrl(n)),o&&s.push(`Original Error Message:
|
|
3
3
|
${o}`),s.join(`
|
|
4
|
-
`)};function _extends(){return _extends=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s])}return t},_extends.apply(this,arguments)}const runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot.",[RUNTIME_008]:"Failed to load script resources."},typeDescMap={[TYPE_001]:"Failed to generate type declaration. Execute the below cmd to reproduce and fix the error."},buildDescMap={[BUILD_001]:"Failed to find expose module."};_extends({},runtimeDescMap,typeDescMap,buildDescMap);const LOG_CATEGORY="[ Federation Runtime ]",logger=createLogger(LOG_CATEGORY);function assert(n,t){n||error(t)}function error(n){throw n instanceof Error?(n.message=`${LOG_CATEGORY}: ${n.message}`,n):new Error(`${LOG_CATEGORY}: ${n}`)}function warn(n){n instanceof Error&&(n.message=`${LOG_CATEGORY}: ${n.message}`),logger.warn(n)}function addUniqueItem(n,t){return n.findIndex(r=>r===t)===-1&&n.push(t),n}function getFMId(n){return"version"in n&&n.version?`${n.name}:${n.version}`:"entry"in n&&n.entry?`${n.name}:${n.entry}`:`${n.name}`}function isRemoteInfoWithEntry(n){return typeof n.entry<"u"}function isPureRemoteEntry(n){return!n.entry.includes(".json")}function isObject(n){return n&&typeof n=="object"}const objectToString=Object.prototype.toString;function isPlainObject(n){return objectToString.call(n)==="[object Object]"}function arrayOptions(n){return Array.isArray(n)?n:[n]}function getRemoteEntryInfoFromSnapshot(n){const t={url:"",type:"global",globalName:""};return isBrowserEnv()||isReactNativeEnv()?"remoteEntry"in n?{url:n.remoteEntry,type:n.remoteEntryType,globalName:n.globalName}:t:"ssrRemoteEntry"in n?{url:n.ssrRemoteEntry||t.url,type:n.ssrRemoteEntryType||t.type,globalName:n.globalName}:t}const processModuleAlias=(n,t)=>{let r;return n.endsWith("/")?r=n.slice(0,-1):r=n,t.startsWith(".")&&(t=t.slice(1)),r=r+t,r},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(n,t,r){Object.defineProperty(n,t,{value:r,configurable:!1,writable:!0})}function includeOwnProperty(n,t){return Object.hasOwnProperty.call(n,t)}includeOwnProperty(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(n){var t,r,o,s,l,a;includeOwnProperty(n,"__VMOK__")&&!includeOwnProperty(n,"__FEDERATION__")&&definePropertyGlobalVal(n,"__FEDERATION__",n.__VMOK__),includeOwnProperty(n,"__FEDERATION__")||(definePropertyGlobalVal(n,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),definePropertyGlobalVal(n,"__VMOK__",n.__FEDERATION__));var i;(i=(t=n.__FEDERATION__).__GLOBAL_PLUGIN__)!=null||(t.__GLOBAL_PLUGIN__=[]);var c;(c=(r=n.__FEDERATION__).__INSTANCES__)!=null||(r.__INSTANCES__=[]);var u;(u=(o=n.__FEDERATION__).moduleInfo)!=null||(o.moduleInfo={});var d;(d=(s=n.__FEDERATION__).__SHARE__)!=null||(s.__SHARE__={});var h;(h=(l=n.__FEDERATION__).__MANIFEST_LOADING__)!=null||(l.__MANIFEST_LOADING__={});var p;(p=(a=n.__FEDERATION__).__PRELOADED_MAP__)!=null||(a.__PRELOADED_MAP__=new Map)}setGlobalDefaultVal(CurrentGlobal);setGlobalDefaultVal(nativeGlobal);function setGlobalFederationConstructor(n,t=isDebugMode()){t&&(CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__=n,CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="0.13.1")}function getInfoWithoutType(n,t){if(typeof t=="string"){if(n[t])return{value:n[t],key:t};{const o=Object.keys(n);for(const s of o){const[l,a]=s.split(":"),i=`${l}:${t}`,c=n[i];if(c)return{value:c,key:i}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(n,t)=>{const r=getFMId(n),o=getInfoWithoutType(t,r).value;if(o&&!o.version&&"version"in n&&n.version&&(o.version=n.version),o)return o;if("version"in n&&n.version){const{version:s}=n,l=_object_without_properties_loose(n,["version"]),a=getFMId(l),i=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,a).value;if((i==null?void 0:i.version)===s)return i}},getGlobalSnapshotInfoByModuleInfo=n=>getTargetSnapshotInfoByModuleInfo(n,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(n,t)=>{const r=getFMId(n);return nativeGlobal.__FEDERATION__.moduleInfo[r]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=n=>(nativeGlobal.__FEDERATION__.moduleInfo=_extends$1({},nativeGlobal.__FEDERATION__.moduleInfo,n),()=>{const t=Object.keys(n);for(const r of t)delete nativeGlobal.__FEDERATION__.moduleInfo[r]}),getRemoteEntryExports=(n,t)=>{const r=t||`__FEDERATION_${n}:custom__`,o=CurrentGlobal[r];return{remoteEntryKey:r,entryExports:o}},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=n=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(n),setPreloaded=n=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(n,!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(n){return new RegExp(n)}function isXVersion(n){return!n||n.toLowerCase()==="x"||n==="*"}function pipe(...n){return t=>n.reduce((r,o)=>o(r),t)}function extractComparator(n){return n.match(parseRegex(comparator))}function combineVersion(n,t,r,o){const s=`${n}.${t}.${r}`;return o?`${s}-${o}`:s}function parseHyphen(n){return n.replace(parseRegex(hyphenRange),(t,r,o,s,l,a,i,c,u,d,h,p)=>(isXVersion(o)?r="":isXVersion(s)?r=`>=${o}.0.0`:isXVersion(l)?r=`>=${o}.${s}.0`:r=`>=${r}`,isXVersion(u)?c="":isXVersion(d)?c=`<${Number(u)+1}.0.0-0`:isXVersion(h)?c=`<${u}.${Number(d)+1}.0-0`:p?c=`<=${u}.${d}.${h}-${p}`:c=`<=${c}`,`${r} ${c}`.trim()))}function parseComparatorTrim(n){return n.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(n){return n.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(n){return n.replace(parseRegex(caretTrim),"$1^")}function parseCarets(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(caret),(r,o,s,l,a)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(l)?o==="0"?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.0 <${Number(o)+1}.0.0-0`:a?o==="0"?s==="0"?`>=${o}.${s}.${l}-${a} <${o}.${s}.${Number(l)+1}-0`:`>=${o}.${s}.${l}-${a} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${l}-${a} <${Number(o)+1}.0.0-0`:o==="0"?s==="0"?`>=${o}.${s}.${l} <${o}.${s}.${Number(l)+1}-0`:`>=${o}.${s}.${l} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${l} <${Number(o)+1}.0.0-0`)).join(" ")}function parseTildes(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(r,o,s,l,a)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(l)?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:a?`>=${o}.${s}.${l}-${a} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${l} <${o}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(n){return n.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(r,o,s,l,a,i)=>{const c=isXVersion(s),u=c||isXVersion(l),d=u||isXVersion(a);return o==="="&&d&&(o=""),i="",c?o===">"||o==="<"?"<0.0.0-0":"*":o&&d?(u&&(l=0),a=0,o===">"?(o=">=",u?(s=Number(s)+1,l=0,a=0):(l=Number(l)+1,a=0)):o==="<="&&(o="<",u?s=Number(s)+1:l=Number(l)+1),o==="<"&&(i="-0"),`${o+s}.${l}.${a}${i}`):u?`>=${s}.0.0${i} <${Number(s)+1}.0.0-0`:d?`>=${s}.${l}.0${i} <${s}.${Number(l)+1}.0-0`:r})).join(" ")}function parseStar(n){return n.trim().replace(parseRegex(star),"")}function parseGTE0(n){return n.trim().replace(parseRegex(gte0),"")}function compareAtom(n,t){return n=Number(n)||n,t=Number(t)||t,n>t?1:n===t?0:-1}function comparePreRelease(n,t){const{preRelease:r}=n,{preRelease:o}=t;if(r===void 0&&o)return 1;if(r&&o===void 0)return-1;if(r===void 0&&o===void 0)return 0;for(let s=0,l=r.length;s<=l;s++){const a=r[s],i=o[s];if(a!==i)return a===void 0&&i===void 0?0:a?i?compareAtom(a,i):-1:1}return 0}function compareVersion(n,t){return compareAtom(n.major,t.major)||compareAtom(n.minor,t.minor)||compareAtom(n.patch,t.patch)||comparePreRelease(n,t)}function eq(n,t){return n.version===t.version}function compare(n,t){switch(n.operator){case"":case"=":return eq(n,t);case">":return compareVersion(n,t)<0;case">=":return eq(n,t)||compareVersion(n,t)<0;case"<":return compareVersion(n,t)>0;case"<=":return eq(n,t)||compareVersion(n,t)>0;case void 0:return!0;default:return!1}}function parseComparatorString(n){return pipe(parseCarets,parseTildes,parseXRanges,parseStar)(n)}function parseRange(n){return pipe(parseHyphen,parseComparatorTrim,parseTildeTrim,parseCaretTrim)(n.trim()).split(/\s+/).join(" ")}function satisfy(n,t){if(!n)return!1;const s=parseRange(t).split(" ").map(p=>parseComparatorString(p)).join(" ").split(/\s+/).map(p=>parseGTE0(p)),l=extractComparator(n);if(!l)return!1;const[,a,,i,c,u,d]=l,h={version:combineVersion(i,c,u,d),major:i,minor:c,patch:u,preRelease:d==null?void 0:d.split(".")};for(const p of s){const m=extractComparator(p);if(!m)return!1;const[,_,,b,y,E,I]=m,R={operator:_,version:combineVersion(b,y,E,I),major:b,minor:y,patch:E,preRelease:I==null?void 0:I.split(".")};if(!compare(R,h))return!1}return!0}function formatShare(n,t,r,o){let s;"get"in n?s=n.get:"lib"in n?s=()=>Promise.resolve(n.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${r}'!`)});var l,a,i;return _extends$1({deps:[],useIn:[],from:t,loading:null},n,{shareConfig:_extends$1({requiredVersion:`^${n.version}`,singleton:!1,eager:!1,strictVersion:!1},n.shareConfig),get:s,loaded:n!=null&&n.loaded||"lib"in n?!0:void 0,version:(l=n.version)!=null?l:"0",scope:Array.isArray(n.scope)?n.scope:[(a=n.scope)!=null?a:"default"],strategy:((i=n.strategy)!=null?i:o)||"version-first"})}function formatShareConfigs(n,t){const r=t.shared||{},o=t.name,s=Object.keys(r).reduce((a,i)=>{const c=arrayOptions(r[i]);return a[i]=a[i]||[],c.forEach(u=>{a[i].push(formatShare(u,o,i,t.shareStrategy))}),a},{}),l=_extends$1({},n.shared);return Object.keys(s).forEach(a=>{l[a]?s[a].forEach(i=>{l[a].find(u=>u.version===i.version)||l[a].push(i)}):l[a]=s[a]}),{shared:l,shareInfos:s}}function versionLt(n,t){const r=o=>{if(!Number.isNaN(Number(o))){const l=o.split(".");let a=o;for(let i=0;i<3-l.length;i++)a+=".0";return a}return o};return!!satisfy(r(n),`<=${r(t)}`)}const findVersion=(n,t)=>{const r=t||function(o,s){return versionLt(o,s)};return Object.keys(n).reduce((o,s)=>!o||r(o,s)||o==="0"?s:o,0)},isLoaded=n=>!!n.loaded||typeof n.lib=="function",isLoading=n=>!!n.loading;function findSingletonVersionOrderByVersion(n,t,r){const o=n[t][r],s=function(l,a){return!isLoaded(o[l])&&versionLt(l,a)};return findVersion(n[t][r],s)}function findSingletonVersionOrderByLoaded(n,t,r){const o=n[t][r],s=function(l,a){const i=c=>isLoaded(c)||isLoading(c);return i(o[a])?i(o[l])?!!versionLt(l,a):!0:i(o[l])?!1:versionLt(l,a)};return findVersion(n[t][r],s)}function getFindShareFunction(n){return n==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(n,t,r,o){if(!n)return;const{shareConfig:s,scope:l=DEFAULT_SCOPE,strategy:a}=r,i=Array.isArray(l)?l:[l];for(const c of i)if(s&&n[c]&&n[c][t]){const{requiredVersion:u}=s,h=getFindShareFunction(a)(n,c,t),p=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(h,u)){const b=`Version ${h} from ${h&&n[c][t][h].from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${u})`;s.strictVersion?error(b):warn(b)}return n[c][t][h]}else{if(u===!1||u==="*"||satisfy(h,u))return n[c][t][h];for(const[b,y]of Object.entries(n[c][t]))if(satisfy(b,u))return y}},m={shareScopeMap:n,scope:c,pkgName:t,version:h,GlobalFederation:Global.__FEDERATION__,resolver:p};return(o.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(n){const{pkgName:t,extraOptions:r,shareInfos:o}=n,s=i=>{if(!i)return;const c={};i.forEach(h=>{c[h.version]=h});const d=findVersion(c,function(h,p){return!isLoaded(c[h])&&versionLt(h,p)});return c[d]};var l;const a=(l=r==null?void 0:r.resolver)!=null?l:s;return Object.assign({},a(o[t]),r==null?void 0:r.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(n,t){for(const r of n){const o=t.startsWith(r.name);let s=t.replace(r.name,"");if(o){if(s.startsWith("/")){const i=r.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:r}}else if(s==="")return{pkgNameOrAlias:r.name,expose:".",remote:r}}const l=r.alias&&t.startsWith(r.alias);let a=r.alias&&t.replace(r.alias,"");if(r.alias&&l){if(a&&a.startsWith("/")){const i=r.alias;return a=`.${a}`,{pkgNameOrAlias:i,expose:a,remote:r}}else if(a==="")return{pkgNameOrAlias:r.alias,expose:".",remote:r}}}}function matchRemote(n,t){for(const r of n)if(t===r.name||r.alias&&t===r.alias)return r}function registerPlugins(n,t){const r=getGlobalHostPlugins();return r.length>0&&r.forEach(o=>{n!=null&&n.find(s=>s.name!==o.name)&&n.push(o)}),n&&n.length>0&&n.forEach(o=>{t.forEach(s=>{s.applyPlugin(o)})}),n}const importCallback=".then(callbacks[0]).catch(callbacks[1])";async function loadEsmEntry({entry:n,remoteEntryExports:t}){return new Promise((r,o)=>{try{t?r(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${n}")${importCallback}`)([r,o]):import(n).then(r).catch(o)}catch(s){o(s)}})}async function loadSystemJsEntry({entry:n,remoteEntryExports:t}){return new Promise((r,o)=>{try{t?r(t):typeof __system_context__>"u"?System.import(n).then(r).catch(o):new Function("callbacks",`System.import("${n}")${importCallback}`)([r,o])}catch(s){o(s)}})}function handleRemoteEntryLoaded(n,t,r){const{remoteEntryKey:o,entryExports:s}=getRemoteEntryExports(n,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:n,remoteEntryUrl:r,remoteEntryKey:o})),s}async function loadEntryScript({name:n,globalName:t,entry:r,loaderHook:o}){const{entryExports:s}=getRemoteEntryExports(n,t);return s||loadScript(r,{attrs:{},createScriptHook:(l,a)=>{const i=o.lifecycle.createScript.emit({url:l,attrs:a});if(i&&(i instanceof HTMLScriptElement||"script"in i||"timeout"in i))return i}}).then(()=>handleRemoteEntryLoaded(n,t,r)).catch(l=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:n,resourceUrl:r})),l})}async function loadEntryDom({remoteInfo:n,remoteEntryExports:t,loaderHook:r}){const{entry:o,entryGlobalName:s,name:l,type:a}=n;switch(a){case"esm":case"module":return loadEsmEntry({entry:o,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:o,remoteEntryExports:t});default:return loadEntryScript({entry:o,globalName:s,name:l,loaderHook:r})}}async function loadEntryNode({remoteInfo:n,loaderHook:t}){const{entry:r,entryGlobalName:o,name:s,type:l}=n,{entryExports:a}=getRemoteEntryExports(s,o);return a||loadScriptNode(r,{attrs:{name:s,globalName:o,type:l},loaderHook:{createScriptHook:(i,c={})=>{const u=t.lifecycle.createScript.emit({url:i,attrs:c});if(u&&"url"in u)return u}}}).then(()=>handleRemoteEntryLoaded(s,o,r)).catch(i=>{throw i})}function getRemoteEntryUniqueKey(n){const{entry:t,name:r}=n;return composeKeyWithSeparator(r,t)}async function getRemoteEntry({origin:n,remoteEntryExports:t,remoteInfo:r}){const o=getRemoteEntryUniqueKey(r);if(t)return t;if(!globalLoading[o]){const s=n.remoteHandler.hooks.lifecycle.loadEntry,l=n.loaderHook;globalLoading[o]=s.emit({loaderHook:l,remoteInfo:r,remoteEntryExports:t}).then(a=>a||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:l}):loadEntryNode({remoteInfo:r,loaderHook:l})))}return globalLoading[o]}function getRemoteInfo(n){return _extends$1({},n,{entry:"entry"in n?n.entry:"",type:n.type||DEFAULT_REMOTE_TYPE,entryGlobalName:n.entryGlobalName||n.name,shareScope:n.shareScope||DEFAULT_SCOPE})}let Module=class{async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let t;try{t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports})}catch{const o=getRemoteEntryUniqueKey(this.remoteInfo);t=await this.host.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry,origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports,globalLoading,uniqueKey:o})}return assert(t,`remoteEntryExports is undefined
|
|
5
|
-
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,r,o,s){const{loadFactory:l=!0}=o||{loadFactory:!0},a=await this.getEntry();if(!this.inited){const h=this.host.shareScopeMap,p=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];p.length||p.push("default"),p.forEach(E=>{h[E]||(h[E]={})});const m=h[p[0]],_=[],b={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?p:this.remoteInfo.shareScope||"default"};Object.defineProperty(b,"shareScopeMap",{value:h,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:b,initScope:_,remoteInfo:this.remoteInfo,origin:this.host});typeof(a==null?void 0:a.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{remoteName:name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await a.init(y.shareScope,y.initScope,y.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit(_extends$1({},y,{id:t,remoteSnapshot:s,remoteEntryExports:a}))}this.lib=a,this.inited=!0;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:a,expose:r,moduleInfo:this.remoteInfo}),i||(i=await a.get(r)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${r}.`);const c=processModuleAlias(this.remoteInfo.name,r),u=this.wraperFactory(i,c);return l?await u():u}wraperFactory(t,r){function o(s,l){s&&typeof s=="object"&&Object.isExtensible(s)&&!Object.getOwnPropertyDescriptor(s,Symbol.for("mf_module_id"))&&Object.defineProperty(s,Symbol.for("mf_module_id"),{value:l,enumerable:!1})}return t instanceof Promise?async()=>{const s=await t();return o(s,r),s}:()=>{const s=t();return o(s,r),s}}constructor({remoteInfo:t,host:r}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=r}};class SyncHook{on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const r=this;this.on(function o(...s){return r.remove(o),t.apply(null,s)})}emit(...t){let r;return this.listeners.size>0&&this.listeners.forEach(o=>{r=o(...t)}),r}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}}class AsyncHook extends SyncHook{emit(...t){let r;const o=Array.from(this.listeners);if(o.length>0){let s=0;const l=a=>a===!1?!1:s<o.length?Promise.resolve(o[s++].apply(null,t)).then(l):a;r=l()}return Promise.resolve(r)}}function checkReturnData(n,t){if(!isObject(t))return!1;if(n!==t){for(const r in n)if(!(r in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const r of this.listeners)try{const o=r(t);if(checkReturnData(t,o))t=o;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(o){warn(o),this.onerror(o)}return t}constructor(t){super(),this.onerror=error,this.type=t}}class AsyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const r=Array.from(this.listeners);if(r.length>0){let o=0;const s=a=>(warn(a),this.onerror(a),t),l=a=>{if(checkReturnData(t,a)){if(t=a,o<r.length)try{return Promise.resolve(r[o++](t)).then(l,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(l(t))}return Promise.resolve(t)}constructor(t){super(),this.onerror=error,this.type=t}}class PluginSystem{applyPlugin(t){assert(isPlainObject(t),"Plugin configuration is invalid.");const r=t.name;assert(r,"A name must be provided by the plugin."),this.registerPlugins[r]||(this.registerPlugins[r]=t,Object.keys(this.lifecycle).forEach(o=>{const s=t[o];s&&this.lifecycle[o].on(s)}))}removePlugin(t){assert(t,"A name is required.");const r=this.registerPlugins[t];assert(r,`The plugin "${t}" is not registered.`),Object.keys(r).forEach(o=>{o!=="name"&&this.lifecycle[o].remove(r[o])})}inherit({lifecycle:t,registerPlugins:r}){Object.keys(t).forEach(o=>{assert(!this.lifecycle[o],`The hook "${o}" has a conflict and cannot be inherited.`),this.lifecycle[o]=t[o]}),Object.keys(r).forEach(o=>{assert(!this.registerPlugins[o],`The plugin "${o}" has a conflict and cannot be inherited.`),this.applyPlugin(r[o])})}constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}}function defaultPreloadArgs(n){return _extends$1({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},n)}function formatPreloadArgs(n,t){return t.map(r=>{const o=matchRemote(n,r.nameOrAlias);return assert(o,`Unable to preload ${r.nameOrAlias} as it is not included in ${!o&&safeToString({remoteInfo:o,remotes:n})}`),{remote:o,preloadConfig:defaultPreloadArgs(r)}})}function normalizePreloadExposes(n){return n?n.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(n,t,r,o=!0){const{cssAssets:s,jsAssetsWithoutEntry:l,entryAssets:a}=r;if(t.options.inBrowser){if(a.forEach(i=>{const{moduleInfo:c}=i,u=t.moduleCache.get(n.name);getRemoteEntry(u?{origin:t,remoteInfo:c,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:c,remoteEntryExports:void 0})}),o){const i={rel:"preload",as:"style"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m}});d&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});d&&document.head.appendChild(u)})}if(o){const i={rel:"preload",as:"script"};l.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m}});d&&document.head.appendChild(u)})}else{const i={fetchpriority:"high",type:(n==null?void 0:n.type)==="module"?"module":"text/javascript"};l.forEach(c=>{const{script:u,needAttach:d}=createScript({url:c,cb:()=>{},attrs:i,createScriptHook:(h,p)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:h,attrs:p});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});d&&document.head.appendChild(u)})}}}function assignRemoteInfo(n,t){const r=getRemoteEntryInfoFromSnapshot(t);r.url||error(`The attribute remoteEntry of ${n.name} must not be undefined.`);let o=getResourceUrl(t,r.url);!isBrowserEnv()&&!o.startsWith("http")&&(o=`https:${o}`),n.type=r.type,n.entryGlobalName=r.globalName,n.entry=o,n.version=t.version,n.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(n){const{remote:t,pkgNameOrAlias:r,expose:o,origin:s,remoteInfo:l}=n;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:a,globalSnapshot:i}=await s.snapshotHandler.loadRemoteSnapshotInfo(t);assignRemoteInfo(l,a);const c={remote:t,preloadConfig:{nameOrAlias:r,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},u=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:c,remoteInfo:l,remote:t,remoteSnapshot:a,globalSnapshot:i});return u&&preloadAssets(l,s,u,!1),_extends$1({},n,{remoteSnapshot:a})}return n}}}function splitId(n){const t=n.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(n,t,r,o,s={},l){const a=getFMId(t),{value:i}=getInfoWithoutType(n,a),c=l||i;if(c&&!isManifestProvider(c)&&(r(c,t,o),c.remotesInfo)){const u=Object.keys(c.remotesInfo);for(const d of u){if(s[d])continue;s[d]=!0;const h=splitId(d),p=c.remotesInfo[d];traverseModuleInfo(n,{name:h.name,version:p.matchedVersion},r,!1,s,void 0)}}}const isExisted=(n,t)=>document.querySelector(`${n}[${n==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(n,t,r,o,s){const l=[],a=[],i=[],c=new Set,u=new Set,{options:d}=n,{preloadConfig:h}=t,{depsRemote:p}=h;if(traverseModuleInfo(o,r,(y,E,I)=>{let R;if(I)R=h;else if(Array.isArray(p)){const O=p.find(T=>T.nameOrAlias===E.name||T.nameOrAlias===E.alias);if(!O)return;R=defaultPreloadArgs(O)}else if(p===!0)R=h;else return;const S=getResourceUrl(y,getRemoteEntryInfoFromSnapshot(y).url);S&&i.push({name:E.name,moduleInfo:{name:E.name,entry:S,type:"remoteEntryType"in y?y.remoteEntryType:"global",entryGlobalName:"globalName"in y?y.globalName:E.name,shareScope:"",version:"version"in y?y.version:void 0},url:S});let g="modules"in y?y.modules:[];const v=normalizePreloadExposes(R.exposes);if(v.length&&"modules"in y){var A;g=y==null||(A=y.modules)==null?void 0:A.reduce((O,T)=>((v==null?void 0:v.indexOf(T.moduleName))!==-1&&O.push(T),O),[])}function $(O){const T=O.map(N=>getResourceUrl(y,N));return R.filter?T.filter(R.filter):T}if(g){const O=g.length;for(let T=0;T<O;T++){const N=g[T],w=`${E.name}/${N.moduleName}`;n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:N.moduleName==="."?E.name:w,name:E.name,remoteSnapshot:y,preloadConfig:R,remote:E,origin:n}),!getPreloaded(w)&&(R.resourceCategory==="all"?(l.push(...$(N.assets.css.async)),l.push(...$(N.assets.css.sync)),a.push(...$(N.assets.js.async)),a.push(...$(N.assets.js.sync))):(R.resourceCategory="sync")&&(l.push(...$(N.assets.css.sync)),a.push(...$(N.assets.js.sync))),setPreloaded(w))}}},!0,{},s),s.shared){const y=(E,I)=>{const R=getRegisteredShare(n.shareScopeMap,I.sharedName,E,n.sharedHandler.hooks.lifecycle.resolveShare);R&&typeof R.lib=="function"&&(I.assets.js.sync.forEach(S=>{c.add(S)}),I.assets.css.sync.forEach(S=>{u.add(S)}))};s.shared.forEach(E=>{var I;const R=(I=d.shared)==null?void 0:I[E.sharedName];if(!R)return;const S=E.version?R.find(v=>v.version===E.version):R;if(!S)return;arrayOptions(S).forEach(v=>{y(v,E)})})}const _=a.filter(y=>!c.has(y)&&!isExisted("script",y));return{cssAssets:l.filter(y=>!u.has(y)&&!isExisted("link",y)),jsAssetsWithoutEntry:_,entryAssets:i.filter(y=>!isExisted("script",y.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(n){const{origin:t,preloadOptions:r,remoteInfo:o,remote:s,globalSnapshot:l,remoteSnapshot:a}=n;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:o.name,entry:s.entry,type:o.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(o,a),generatePreloadAssets(t,r,o,l,a)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(n,t){const r=getGlobalSnapshotInfoByModuleInfo({name:t.options.name,version:t.options.version}),o=r&&"remotesInfo"in r&&r.remotesInfo&&getInfoWithoutType(r.remotesInfo,n.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:r,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:n.name,version:o.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:n.name,version:"version"in n?n.version:void 0})}}class SnapshotHandler{async loadSnapshot(t){const{options:r}=this.HostInstance,{hostGlobalSnapshot:o,remoteSnapshot:s,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:a,globalSnapshot:i}=await this.hooks.lifecycle.loadSnapshot.emit({options:r,moduleInfo:t,hostGlobalSnapshot:o,remoteSnapshot:s,globalSnapshot:l});return{remoteSnapshot:a,globalSnapshot:i}}async loadRemoteSnapshotInfo(t){const{options:r}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:r,moduleInfo:t});let o=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});o||(o={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:o})),o&&"remotesInfo"in o&&!getInfoWithoutType(o.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(o.remotesInfo=_extends$1({},o==null?void 0:o.remotesInfo,{[t.name]:{matchedVersion:"version"in t?t.version:t.entry}}));const{hostGlobalSnapshot:s,remoteSnapshot:l,globalSnapshot:a}=this.getGlobalRemoteInfo(t),{remoteSnapshot:i,globalSnapshot:c}=await this.hooks.lifecycle.loadSnapshot.emit({options:r,moduleInfo:t,hostGlobalSnapshot:s,remoteSnapshot:l,globalSnapshot:a});let u,d;if(i)if(isManifestProvider(i)){const h=isBrowserEnv()?i.remoteEntry:i.ssrRemoteEntry||i.remoteEntry||"",p=await this.getManifestJson(h,t,{}),m=setGlobalSnapshotInfoByModuleInfo(_extends$1({},t,{entry:h}),p);u=p,d=m}else{const{remoteSnapshot:h}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:i,from:"global"});u=h,d=c}else if(isRemoteInfoWithEntry(t)){const h=await this.getManifestJson(t.entry,t,{}),p=setGlobalSnapshotInfoByModuleInfo(t,h),{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:h,from:"global"});u=m,d=p}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(c)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({options:r,moduleInfo:t,remoteSnapshot:u}),{remoteSnapshot:u,globalSnapshot:d}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,r,o){const s=async()=>{let a=this.manifestCache.get(t);if(a)return a;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});(!i||!(i instanceof Response))&&(i=await fetch(t,{})),a=await i.json()}catch(i){a=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),a||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:r.name,hostName:this.HostInstance.options.name},`${i}`)))}return assert(a.metaData&&a.exposes&&a.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,a),a},l=async()=>{const a=await s(),i=generateSnapshotFromManifest(a,{version:t}),{remoteSnapshot:c}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:r,manifestJson:a,remoteSnapshot:i,manifestUrl:t,from:"manifest"});return c};return this.manifestLoading[t]||(this.manifestLoading[t]=l().then(a=>a)),this.manifestLoading[t]}constructor(t){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new PluginSystem({beforeLoadRemoteSnapshot:new AsyncHook("beforeLoadRemoteSnapshot"),loadSnapshot:new AsyncWaterfallHook("loadGlobalSnapshot"),loadRemoteSnapshot:new AsyncWaterfallHook("loadRemoteSnapshot"),afterLoadSnapshot:new AsyncWaterfallHook("afterLoadSnapshot")}),this.manifestLoading=Global.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=t,this.loaderHook=t.loaderHook}}class SharedHandler{registerShared(t,r){const{shareInfos:o,shared:s}=formatShareConfigs(t,r);return Object.keys(o).forEach(a=>{o[a].forEach(c=>{!getRegisteredShare(this.shareScopeMap,a,c,this.hooks.lifecycle.resolveShare)&&c&&c.lib&&this.setShared({pkgName:a,lib:c.lib,get:c.get,loaded:!0,shared:c,from:r.name})})}),{shareInfos:o,shared:s}}async loadShare(t,r){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:r,shareInfos:o.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const l=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:o.options.shared,origin:o}),{shareInfo:a}=l;assert(a,`Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare),c=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,o.options.name)};if(i&&i.lib)return c(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),c(i),u}else if(i){const d=(async()=>{const h=await i.get();a.lib=h,a.loaded=!0,c(a);const p=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0),h})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:o.options.name,lib:null,loading:d}),d}else{if(r!=null&&r.customShareInfo)return!1;const d=(async()=>{const h=await a.get();a.lib=h,a.loaded=!0,c(a);const p=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0),h})();return this.setShared({pkgName:t,loaded:!1,shared:a,from:o.options.name,lib:null,loading:d}),d}}initializeSharing(t=DEFAULT_SCOPE,r){const{host:o}=this,s=r==null?void 0:r.from,l=r==null?void 0:r.strategy;let a=r==null?void 0:r.initScope;const i=[];if(s!=="build"){const{initTokens:_}=this;a||(a=[]);let b=_[t];if(b||(b=_[t]={from:this.host.name}),a.indexOf(b)>=0)return i;a.push(b)}const c=this.shareScopeMap,u=o.options.name;c[t]||(c[t]={});const d=c[t],h=(_,b)=>{var y;const{version:E,eager:I}=b;d[_]=d[_]||{};const R=d[_],S=R[E],g=!!(S&&(S.eager||(y=S.shareConfig)!=null&&y.eager));(!S||S.strategy!=="loaded-first"&&!S.loaded&&(!I!=!g?I:u>S.from))&&(R[E]=b)},p=_=>_&&_.init&&_.init(c[t],a),m=async _=>{const{module:b}=await o.remoteHandler.getRemoteModuleAndOptions({id:_});if(b.getEntry){let y;try{y=await b.getEntry()}catch(E){y=await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:_,error:E,from:"runtime",lifecycle:"beforeLoadShare",origin:o})}b.inited||(await p(y),b.inited=!0)}};return Object.keys(o.options.shared).forEach(_=>{o.options.shared[_].forEach(y=>{y.scope.includes(t)&&h(_,y)})}),(o.options.shareStrategy==="version-first"||l==="version-first")&&o.options.remotes.forEach(_=>{_.shareScope===t&&i.push(m(_.name))}),i}loadShareSync(t,r){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:r,shareInfos:o.options.shared});s!=null&&s.scope&&s.scope.forEach(i=>{this.initializeSharing(i,{strategy:s.strategy})});const l=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),a=i=>{i.useIn||(i.useIn=[]),addUniqueItem(i.useIn,o.options.name)};if(l){if(typeof l.lib=="function")return a(l),l.loaded||(l.loaded=!0,l.from===o.options.name&&(s.loaded=!0)),l.lib;if(typeof l.get=="function"){const i=l.get();if(!(i instanceof Promise))return a(l),this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:i,shared:l}),i}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const i=s.get();if(i instanceof Promise){const c=(r==null?void 0:r.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(c,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}initShareScopeMap(t,r,o={}){const{host:s}=this;this.shareScopeMap[t]=r,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:r,options:s.options,origin:s,scopeName:t,hostShareScopeMap:o.hostShareScopeMap})}setShared({pkgName:t,shared:r,from:o,lib:s,loading:l,loaded:a,get:i}){const{version:c,scope:u="default"}=r,d=_object_without_properties_loose(r,["version","scope"]);(Array.isArray(u)?u:[u]).forEach(p=>{if(this.shareScopeMap[p]||(this.shareScopeMap[p]={}),this.shareScopeMap[p][t]||(this.shareScopeMap[p][t]={}),!this.shareScopeMap[p][t][c]){this.shareScopeMap[p][t][c]=_extends$1({version:c,scope:["default"]},d,{lib:s,loaded:a,loading:l}),i&&(this.shareScopeMap[p][t][c].get=i);return}const m=this.shareScopeMap[p][t][c];l&&!m.loading&&(m.loading=l)})}_setGlobalShareScopeMap(t){const r=getGlobalShareScope(),o=t.id||t.name;o&&!r[o]&&(r[o]=this.shareScopeMap)}constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}}class RemoteHandler{formatAndRegisterRemote(t,r){return(r.remotes||[]).reduce((s,l)=>(this.registerRemote(l,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,r){const{remote:o,expose:s}=r,{name:l,alias:a}=o;if(this.idToRemoteMap[t]={name:o.name,expose:s},a&&t.startsWith(l)){const i=t.replace(l,a);this.idToRemoteMap[i]={name:o.name,expose:s};return}if(a&&t.startsWith(a)){const i=t.replace(a,l);this.idToRemoteMap[i]={name:o.name,expose:s}}}async loadRemote(t,r){const{host:o}=this;try{const{loadFactory:s=!0}=r||{loadFactory:!0},{module:l,moduleOptions:a,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:c,remote:u,expose:d,id:h,remoteSnapshot:p}=i,m=await l.get(h,d,r,p),_=await this.hooks.lifecycle.onLoad.emit({id:h,pkgNameOrAlias:c,expose:d,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:a,moduleInstance:l,origin:o});return this.setIdToRemoteMap(t,i),typeof _=="function"?_:m}catch(s){const{from:l="runtime"}=r||{from:"runtime"},a=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:l,lifecycle:"onLoad",origin:o});if(!a)throw s;return a}}async preloadRemote(t){const{host:r}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:r.options,origin:r});const o=formatPreloadArgs(r.options.remotes,t);await Promise.all(o.map(async s=>{const{remote:l}=s,a=getRemoteInfo(l),{globalSnapshot:i,remoteSnapshot:c}=await r.snapshotHandler.loadRemoteSnapshotInfo(l),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:r,preloadOptions:s,remote:l,remoteInfo:a,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(a,r,u)}))}registerRemotes(t,r){const{host:o}=this;t.forEach(s=>{this.registerRemote(s,o.options.remotes,{force:r==null?void 0:r.force})})}async getRemoteModuleAndOptions(t){const{host:r}=this,{id:o}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:r.options,origin:r})}catch(_){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:r.options,origin:r,from:"runtime",error:_,lifecycle:"beforeRequest"}),!s)throw _}const{id:l}=s,a=matchRemoteWithNameAndExpose(r.options.remotes,l);assert(a,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:r.options.name,requestId:l}));const{remote:i}=a,c=getRemoteInfo(i),u=await r.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:l},a,{options:r.options,origin:r,remoteInfo:c})),{remote:d,expose:h}=u;assert(d&&h,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);let p=r.moduleCache.get(d.name);const m={host:r,remoteInfo:c};return p||(p=new Module(m),r.moduleCache.set(d.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,r,o){const{host:s}=this,l=()=>{if(t.alias){const i=r.find(c=>{var u;return t.alias&&(c.name.startsWith(t.alias)||((u=c.alias)==null?void 0:u.startsWith(t.alias)))});assert(!i,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const a=r.find(i=>i.name===t.name);if(!a)l(),r.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."];o!=null&&o.force&&(this.removeRemote(a),l(),r.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){try{const{host:o}=this,{name:s}=t,l=o.options.remotes.findIndex(i=>i.name===s);l!==-1&&o.options.remotes.splice(l,1);const a=o.moduleCache.get(t.name);if(a){const i=a.remoteInfo,c=i.entryGlobalName;if(CurrentGlobal[c]){var r;(r=Object.getOwnPropertyDescriptor(CurrentGlobal,c))!=null&&r.configurable?delete CurrentGlobal[c]:CurrentGlobal[c]=void 0}const u=getRemoteEntryUniqueKey(a.remoteInfo);globalLoading[u]&&delete globalLoading[u],o.snapshotHandler.manifestCache.delete(i.entry);let d=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const h=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===d:m.name===d);if(h!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[h];d=m.options.id||d;const _=getGlobalShareScope();let b=!0;const y=[];Object.keys(_).forEach(E=>{const I=_[E];I&&Object.keys(I).forEach(R=>{const S=I[R];S&&Object.keys(S).forEach(g=>{const v=S[g];v&&Object.keys(v).forEach(A=>{const $=v[A];$&&typeof $=="object"&&$.from===i.name&&($.loaded||$.loading?($.useIn=$.useIn.filter(O=>O!==i.name),$.useIn.length?b=!1:y.push([E,R,g,A])):y.push([E,R,g,A]))})})})}),b&&(m.shareScopeMap={},delete _[d]),y.forEach(([E,I,R,S])=>{var g,v,A;(A=_[E])==null||(v=A[I])==null||(g=v[R])==null||delete g[S]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(h,1)}const{hostGlobalSnapshot:p}=getGlobalRemoteInfo(t,o);if(p){const m=p&&"remotesInfo"in p&&p.remotesInfo&&getInfoWithoutType(p.remotesInfo,t.name).key;m&&(delete p.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}o.moduleCache.delete(t.name)}}catch(o){logger.log("removeRemote fail: ",o)}}constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}}const USE_SNAPSHOT=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;class FederationHost{initOptions(t){this.registerPlugins(t.plugins);const r=this.formatOptions(this.options,t);return this.options=r,r}async loadShare(t,r){return this.sharedHandler.loadShare(t,r)}loadShareSync(t,r){return this.sharedHandler.loadShareSync(t,r)}initializeSharing(t=DEFAULT_SCOPE,r){return this.sharedHandler.initializeSharing(t,r)}initRawContainer(t,r,o){const s=getRemoteInfo({name:t,entry:r}),l=new Module({host:this,remoteInfo:s});return l.remoteEntryExports=o,this.moduleCache.set(t,l),l}async loadRemote(t,r){return this.remoteHandler.loadRemote(t,r)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,r,o={}){this.sharedHandler.initShareScopeMap(t,r,o)}formatOptions(t,r){const{shared:o}=formatShareConfigs(t,r),{userOptions:s,options:l}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:r,options:t,shareInfo:o}),a=this.remoteHandler.formatAndRegisterRemote(l,s),{shared:i}=this.sharedHandler.registerShared(l,s),c=[...l.plugins];s.plugins&&s.plugins.forEach(d=>{c.includes(d)||c.push(d)});const u=_extends$1({},t,r,{plugins:c,remotes:a,shared:i});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const r=registerPlugins(t,[this.hooks,this.remoteHandler.hooks,this.sharedHandler.hooks,this.snapshotHandler.hooks,this.loaderHook,this.bridgeHook]);this.options.plugins=this.options.plugins.reduce((o,s)=>(s&&o&&!o.find(l=>l.name===s.name)&&o.push(s),o),r||[])}registerRemotes(t,r){return this.remoteHandler.registerRemotes(t,r)}constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.13.1",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 r=USE_SNAPSHOT?[snapshotPlugin(),generatePreloadAssetsPlugin()]:[],o={id:getBuilderId(),name:t.name,plugins:r,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=o,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...o.plugins,...t.plugins||[]]),this.options=this.formatOptions(o,t)}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(FederationHost);function createBridgeComponent(n){const t=new Map,r=getInstance();return()=>({__APP_VERSION__:"0.13.1",async render(o){var _,b,y;LoggerInstance.debug("createBridgeComponent render Info",o);const{moduleName:s,dom:l,basename:a,memoryRoute:i,hashRoute:c,...u}=o,d=Vue__namespace.createApp(n.rootComponent,u);t.set(l,d);const h=await((y=(b=(_=r==null?void 0:r.bridgeHook)==null?void 0:_.lifecycle)==null?void 0:b.beforeBridgeRender)==null?void 0:y.emit(o)),p=h&&typeof h=="object"&&(h!=null&&h.extraProps)?h==null?void 0:h.extraProps:{},m=n.appOptions({app:d,basename:a,memoryRoute:i,hashRoute:c,...u,...p});if(m!=null&&m.router){let E,I=m.router.getRoutes();o.memoryRoute?E=VueRouter__namespace.createMemoryHistory(o.basename):o.hashRoute?(E=VueRouter__namespace.createWebHashHistory(),I=I.map(S=>({...S,path:o.basename+S.path}))):E=VueRouter__namespace.createWebHistory(o.basename);const R=VueRouter__namespace.createRouter({...m.router.options,history:E,routes:I});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:R}),i&&await R.push(i.entryPath),d.use(R)}d.mount(l)},destroy(o){LoggerInstance.debug("createBridgeComponent destroy Info",o);const s=t.get(o==null?void 0:o.dom);s==null||s.unmount()}})}function e(){const n=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(n)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(n){const t=Vue.ref(null),r=Vue.ref(null),o=Vue.ref(""),s=VueRouter.useRoute(),l=getInstance(),a=Vue.useAttrs(),i=async()=>{var p,m,_,b;const u=(p=n.providerInfo)==null?void 0:p.call(n);r.value=u;let d={...a,moduleName:n.moduleName,dom:t.value,basename:n.basename,memoryRoute:n.memoryRoute,hashRoute:n.hashRoute};LoggerInstance.debug("createRemoteComponent LazyComponent render >>>",d);const h=await((b=(_=(m=l==null?void 0:l.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:_.beforeBridgeRender)==null?void 0:b.emit(d))||{};d={...d,...h.extraProps},u.render(d)},c=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&i(),o.value!==""&&o.value!==u&&(LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>",{...n,pathname:s.path}),e()),o.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>",{...n}),c(),(u=r.value)==null||u.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(n.rootAttrs||{},{ref:t}),null)}});function createRemoteComponent(n){return Vue.defineAsyncComponent({__APP_VERSION__:"0.13.1",...n.asyncComponentOptions,loader:async()=>{var c,u;const t=VueRouter.useRoute();let r="/";const o=(u=(c=t==null?void 0:t.matched)==null?void 0:c[0])==null?void 0:u.path;o&&(o.endsWith("/:pathMatch(.*)*")?r=o.replace("/:pathMatch(.*)*",""):r=t.matched[0].path);const s=(n==null?void 0:n.export)||"default";LoggerInstance.debug("createRemoteComponent LazyComponent create >>>",{basename:r,info:n});const l=await n.loader(),a=l&&l[Symbol.for("mf_module_id")],i=l[s];if(LoggerInstance.debug("createRemoteComponent LazyComponent loadRemote info >>>",{moduleName:a,module:l,exportName:s,basename:r,route:t}),s in l&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:a,providerInfo:i,basename:r,rootAttrs:n.rootAttrs})}};throw new Error("module not found")}})}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteComponent=createRemoteComponent;
|
|
4
|
+
`)};function _extends(){return _extends=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s])}return t},_extends.apply(this,arguments)}const runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot.",[RUNTIME_008]:"Failed to load script resources."},typeDescMap={[TYPE_001]:"Failed to generate type declaration. Execute the below cmd to reproduce and fix the error."},buildDescMap={[BUILD_001]:"Failed to find expose module."};_extends({},runtimeDescMap,typeDescMap,buildDescMap);const LOG_CATEGORY="[ Federation Runtime ]",logger=createLogger(LOG_CATEGORY);function assert(n,t){n||error(t)}function error(n){throw n instanceof Error?(n.message=`${LOG_CATEGORY}: ${n.message}`,n):new Error(`${LOG_CATEGORY}: ${n}`)}function warn(n){n instanceof Error&&(n.message=`${LOG_CATEGORY}: ${n.message}`),logger.warn(n)}function addUniqueItem(n,t){return n.findIndex(r=>r===t)===-1&&n.push(t),n}function getFMId(n){return"version"in n&&n.version?`${n.name}:${n.version}`:"entry"in n&&n.entry?`${n.name}:${n.entry}`:`${n.name}`}function isRemoteInfoWithEntry(n){return typeof n.entry<"u"}function isPureRemoteEntry(n){return!n.entry.includes(".json")}function isObject(n){return n&&typeof n=="object"}const objectToString=Object.prototype.toString;function isPlainObject(n){return objectToString.call(n)==="[object Object]"}function arrayOptions(n){return Array.isArray(n)?n:[n]}function getRemoteEntryInfoFromSnapshot(n){const t={url:"",type:"global",globalName:""};return isBrowserEnv()||isReactNativeEnv()?"remoteEntry"in n?{url:n.remoteEntry,type:n.remoteEntryType,globalName:n.globalName}:t:"ssrRemoteEntry"in n?{url:n.ssrRemoteEntry||t.url,type:n.ssrRemoteEntryType||t.type,globalName:n.globalName}:t}const processModuleAlias=(n,t)=>{let r;return n.endsWith("/")?r=n.slice(0,-1):r=n,t.startsWith(".")&&(t=t.slice(1)),r=r+t,r},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(n,t,r){Object.defineProperty(n,t,{value:r,configurable:!1,writable:!0})}function includeOwnProperty(n,t){return Object.hasOwnProperty.call(n,t)}includeOwnProperty(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(n){var t,r,o,s,l,a;includeOwnProperty(n,"__VMOK__")&&!includeOwnProperty(n,"__FEDERATION__")&&definePropertyGlobalVal(n,"__FEDERATION__",n.__VMOK__),includeOwnProperty(n,"__FEDERATION__")||(definePropertyGlobalVal(n,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),definePropertyGlobalVal(n,"__VMOK__",n.__FEDERATION__));var i;(i=(t=n.__FEDERATION__).__GLOBAL_PLUGIN__)!=null||(t.__GLOBAL_PLUGIN__=[]);var c;(c=(r=n.__FEDERATION__).__INSTANCES__)!=null||(r.__INSTANCES__=[]);var u;(u=(o=n.__FEDERATION__).moduleInfo)!=null||(o.moduleInfo={});var d;(d=(s=n.__FEDERATION__).__SHARE__)!=null||(s.__SHARE__={});var h;(h=(l=n.__FEDERATION__).__MANIFEST_LOADING__)!=null||(l.__MANIFEST_LOADING__={});var p;(p=(a=n.__FEDERATION__).__PRELOADED_MAP__)!=null||(a.__PRELOADED_MAP__=new Map)}setGlobalDefaultVal(CurrentGlobal);setGlobalDefaultVal(nativeGlobal);function setGlobalFederationConstructor(n,t=isDebugMode()){t&&(CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__=n,CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="0.14.0")}function getInfoWithoutType(n,t){if(typeof t=="string"){if(n[t])return{value:n[t],key:t};{const o=Object.keys(n);for(const s of o){const[l,a]=s.split(":"),i=`${l}:${t}`,c=n[i];if(c)return{value:c,key:i}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(n,t)=>{const r=getFMId(n),o=getInfoWithoutType(t,r).value;if(o&&!o.version&&"version"in n&&n.version&&(o.version=n.version),o)return o;if("version"in n&&n.version){const{version:s}=n,l=_object_without_properties_loose(n,["version"]),a=getFMId(l),i=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,a).value;if((i==null?void 0:i.version)===s)return i}},getGlobalSnapshotInfoByModuleInfo=n=>getTargetSnapshotInfoByModuleInfo(n,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(n,t)=>{const r=getFMId(n);return nativeGlobal.__FEDERATION__.moduleInfo[r]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=n=>(nativeGlobal.__FEDERATION__.moduleInfo=_extends$1({},nativeGlobal.__FEDERATION__.moduleInfo,n),()=>{const t=Object.keys(n);for(const r of t)delete nativeGlobal.__FEDERATION__.moduleInfo[r]}),getRemoteEntryExports=(n,t)=>{const r=t||`__FEDERATION_${n}:custom__`,o=CurrentGlobal[r];return{remoteEntryKey:r,entryExports:o}},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=n=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(n),setPreloaded=n=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(n,!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(n){return new RegExp(n)}function isXVersion(n){return!n||n.toLowerCase()==="x"||n==="*"}function pipe(...n){return t=>n.reduce((r,o)=>o(r),t)}function extractComparator(n){return n.match(parseRegex(comparator))}function combineVersion(n,t,r,o){const s=`${n}.${t}.${r}`;return o?`${s}-${o}`:s}function parseHyphen(n){return n.replace(parseRegex(hyphenRange),(t,r,o,s,l,a,i,c,u,d,h,p)=>(isXVersion(o)?r="":isXVersion(s)?r=`>=${o}.0.0`:isXVersion(l)?r=`>=${o}.${s}.0`:r=`>=${r}`,isXVersion(u)?c="":isXVersion(d)?c=`<${Number(u)+1}.0.0-0`:isXVersion(h)?c=`<${u}.${Number(d)+1}.0-0`:p?c=`<=${u}.${d}.${h}-${p}`:c=`<=${c}`,`${r} ${c}`.trim()))}function parseComparatorTrim(n){return n.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(n){return n.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(n){return n.replace(parseRegex(caretTrim),"$1^")}function parseCarets(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(caret),(r,o,s,l,a)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(l)?o==="0"?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.0 <${Number(o)+1}.0.0-0`:a?o==="0"?s==="0"?`>=${o}.${s}.${l}-${a} <${o}.${s}.${Number(l)+1}-0`:`>=${o}.${s}.${l}-${a} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${l}-${a} <${Number(o)+1}.0.0-0`:o==="0"?s==="0"?`>=${o}.${s}.${l} <${o}.${s}.${Number(l)+1}-0`:`>=${o}.${s}.${l} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${l} <${Number(o)+1}.0.0-0`)).join(" ")}function parseTildes(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(r,o,s,l,a)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(l)?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:a?`>=${o}.${s}.${l}-${a} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${l} <${o}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(n){return n.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(r,o,s,l,a,i)=>{const c=isXVersion(s),u=c||isXVersion(l),d=u||isXVersion(a);return o==="="&&d&&(o=""),i="",c?o===">"||o==="<"?"<0.0.0-0":"*":o&&d?(u&&(l=0),a=0,o===">"?(o=">=",u?(s=Number(s)+1,l=0,a=0):(l=Number(l)+1,a=0)):o==="<="&&(o="<",u?s=Number(s)+1:l=Number(l)+1),o==="<"&&(i="-0"),`${o+s}.${l}.${a}${i}`):u?`>=${s}.0.0${i} <${Number(s)+1}.0.0-0`:d?`>=${s}.${l}.0${i} <${s}.${Number(l)+1}.0-0`:r})).join(" ")}function parseStar(n){return n.trim().replace(parseRegex(star),"")}function parseGTE0(n){return n.trim().replace(parseRegex(gte0),"")}function compareAtom(n,t){return n=Number(n)||n,t=Number(t)||t,n>t?1:n===t?0:-1}function comparePreRelease(n,t){const{preRelease:r}=n,{preRelease:o}=t;if(r===void 0&&o)return 1;if(r&&o===void 0)return-1;if(r===void 0&&o===void 0)return 0;for(let s=0,l=r.length;s<=l;s++){const a=r[s],i=o[s];if(a!==i)return a===void 0&&i===void 0?0:a?i?compareAtom(a,i):-1:1}return 0}function compareVersion(n,t){return compareAtom(n.major,t.major)||compareAtom(n.minor,t.minor)||compareAtom(n.patch,t.patch)||comparePreRelease(n,t)}function eq(n,t){return n.version===t.version}function compare(n,t){switch(n.operator){case"":case"=":return eq(n,t);case">":return compareVersion(n,t)<0;case">=":return eq(n,t)||compareVersion(n,t)<0;case"<":return compareVersion(n,t)>0;case"<=":return eq(n,t)||compareVersion(n,t)>0;case void 0:return!0;default:return!1}}function parseComparatorString(n){return pipe(parseCarets,parseTildes,parseXRanges,parseStar)(n)}function parseRange(n){return pipe(parseHyphen,parseComparatorTrim,parseTildeTrim,parseCaretTrim)(n.trim()).split(/\s+/).join(" ")}function satisfy(n,t){if(!n)return!1;const s=parseRange(t).split(" ").map(p=>parseComparatorString(p)).join(" ").split(/\s+/).map(p=>parseGTE0(p)),l=extractComparator(n);if(!l)return!1;const[,a,,i,c,u,d]=l,h={version:combineVersion(i,c,u,d),major:i,minor:c,patch:u,preRelease:d==null?void 0:d.split(".")};for(const p of s){const m=extractComparator(p);if(!m)return!1;const[,_,,E,y,g,I]=m,R={operator:_,version:combineVersion(E,y,g,I),major:E,minor:y,patch:g,preRelease:I==null?void 0:I.split(".")};if(!compare(R,h))return!1}return!0}function formatShare(n,t,r,o){let s;"get"in n?s=n.get:"lib"in n?s=()=>Promise.resolve(n.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${r}'!`)});var l,a,i;return _extends$1({deps:[],useIn:[],from:t,loading:null},n,{shareConfig:_extends$1({requiredVersion:`^${n.version}`,singleton:!1,eager:!1,strictVersion:!1},n.shareConfig),get:s,loaded:n!=null&&n.loaded||"lib"in n?!0:void 0,version:(l=n.version)!=null?l:"0",scope:Array.isArray(n.scope)?n.scope:[(a=n.scope)!=null?a:"default"],strategy:((i=n.strategy)!=null?i:o)||"version-first"})}function formatShareConfigs(n,t){const r=t.shared||{},o=t.name,s=Object.keys(r).reduce((a,i)=>{const c=arrayOptions(r[i]);return a[i]=a[i]||[],c.forEach(u=>{a[i].push(formatShare(u,o,i,t.shareStrategy))}),a},{}),l=_extends$1({},n.shared);return Object.keys(s).forEach(a=>{l[a]?s[a].forEach(i=>{l[a].find(u=>u.version===i.version)||l[a].push(i)}):l[a]=s[a]}),{shared:l,shareInfos:s}}function versionLt(n,t){const r=o=>{if(!Number.isNaN(Number(o))){const l=o.split(".");let a=o;for(let i=0;i<3-l.length;i++)a+=".0";return a}return o};return!!satisfy(r(n),`<=${r(t)}`)}const findVersion=(n,t)=>{const r=t||function(o,s){return versionLt(o,s)};return Object.keys(n).reduce((o,s)=>!o||r(o,s)||o==="0"?s:o,0)},isLoaded=n=>!!n.loaded||typeof n.lib=="function",isLoading=n=>!!n.loading;function findSingletonVersionOrderByVersion(n,t,r){const o=n[t][r],s=function(l,a){return!isLoaded(o[l])&&versionLt(l,a)};return findVersion(n[t][r],s)}function findSingletonVersionOrderByLoaded(n,t,r){const o=n[t][r],s=function(l,a){const i=c=>isLoaded(c)||isLoading(c);return i(o[a])?i(o[l])?!!versionLt(l,a):!0:i(o[l])?!1:versionLt(l,a)};return findVersion(n[t][r],s)}function getFindShareFunction(n){return n==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(n,t,r,o){if(!n)return;const{shareConfig:s,scope:l=DEFAULT_SCOPE,strategy:a}=r,i=Array.isArray(l)?l:[l];for(const c of i)if(s&&n[c]&&n[c][t]){const{requiredVersion:u}=s,h=getFindShareFunction(a)(n,c,t),p=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(h,u)){const E=`Version ${h} from ${h&&n[c][t][h].from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${u})`;s.strictVersion?error(E):warn(E)}return n[c][t][h]}else{if(u===!1||u==="*"||satisfy(h,u))return n[c][t][h];for(const[E,y]of Object.entries(n[c][t]))if(satisfy(E,u))return y}},m={shareScopeMap:n,scope:c,pkgName:t,version:h,GlobalFederation:Global.__FEDERATION__,resolver:p};return(o.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(n){const{pkgName:t,extraOptions:r,shareInfos:o}=n,s=i=>{if(!i)return;const c={};i.forEach(h=>{c[h.version]=h});const d=findVersion(c,function(h,p){return!isLoaded(c[h])&&versionLt(h,p)});return c[d]};var l;const a=(l=r==null?void 0:r.resolver)!=null?l:s;return Object.assign({},a(o[t]),r==null?void 0:r.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(n,t){for(const r of n){const o=t.startsWith(r.name);let s=t.replace(r.name,"");if(o){if(s.startsWith("/")){const i=r.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:r}}else if(s==="")return{pkgNameOrAlias:r.name,expose:".",remote:r}}const l=r.alias&&t.startsWith(r.alias);let a=r.alias&&t.replace(r.alias,"");if(r.alias&&l){if(a&&a.startsWith("/")){const i=r.alias;return a=`.${a}`,{pkgNameOrAlias:i,expose:a,remote:r}}else if(a==="")return{pkgNameOrAlias:r.alias,expose:".",remote:r}}}}function matchRemote(n,t){for(const r of n)if(t===r.name||r.alias&&t===r.alias)return r}function registerPlugins(n,t){const r=getGlobalHostPlugins();return r.length>0&&r.forEach(o=>{n!=null&&n.find(s=>s.name!==o.name)&&n.push(o)}),n&&n.length>0&&n.forEach(o=>{t.forEach(s=>{s.applyPlugin(o)})}),n}const importCallback=".then(callbacks[0]).catch(callbacks[1])";async function loadEsmEntry({entry:n,remoteEntryExports:t}){return new Promise((r,o)=>{try{t?r(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${n}")${importCallback}`)([r,o]):import(n).then(r).catch(o)}catch(s){o(s)}})}async function loadSystemJsEntry({entry:n,remoteEntryExports:t}){return new Promise((r,o)=>{try{t?r(t):typeof __system_context__>"u"?System.import(n).then(r).catch(o):new Function("callbacks",`System.import("${n}")${importCallback}`)([r,o])}catch(s){o(s)}})}function handleRemoteEntryLoaded(n,t,r){const{remoteEntryKey:o,entryExports:s}=getRemoteEntryExports(n,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:n,remoteEntryUrl:r,remoteEntryKey:o})),s}async function loadEntryScript({name:n,globalName:t,entry:r,loaderHook:o}){const{entryExports:s}=getRemoteEntryExports(n,t);return s||loadScript(r,{attrs:{},createScriptHook:(l,a)=>{const i=o.lifecycle.createScript.emit({url:l,attrs:a});if(i&&(i instanceof HTMLScriptElement||"script"in i||"timeout"in i))return i}}).then(()=>handleRemoteEntryLoaded(n,t,r)).catch(l=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:n,resourceUrl:r})),l})}async function loadEntryDom({remoteInfo:n,remoteEntryExports:t,loaderHook:r}){const{entry:o,entryGlobalName:s,name:l,type:a}=n;switch(a){case"esm":case"module":return loadEsmEntry({entry:o,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:o,remoteEntryExports:t});default:return loadEntryScript({entry:o,globalName:s,name:l,loaderHook:r})}}async function loadEntryNode({remoteInfo:n,loaderHook:t}){const{entry:r,entryGlobalName:o,name:s,type:l}=n,{entryExports:a}=getRemoteEntryExports(s,o);return a||loadScriptNode(r,{attrs:{name:s,globalName:o,type:l},loaderHook:{createScriptHook:(i,c={})=>{const u=t.lifecycle.createScript.emit({url:i,attrs:c});if(u&&"url"in u)return u}}}).then(()=>handleRemoteEntryLoaded(s,o,r)).catch(i=>{throw i})}function getRemoteEntryUniqueKey(n){const{entry:t,name:r}=n;return composeKeyWithSeparator(r,t)}async function getRemoteEntry({origin:n,remoteEntryExports:t,remoteInfo:r}){const o=getRemoteEntryUniqueKey(r);if(t)return t;if(!globalLoading[o]){const s=n.remoteHandler.hooks.lifecycle.loadEntry,l=n.loaderHook;globalLoading[o]=s.emit({loaderHook:l,remoteInfo:r,remoteEntryExports:t}).then(a=>a||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:l}):loadEntryNode({remoteInfo:r,loaderHook:l})))}return globalLoading[o]}function getRemoteInfo(n){return _extends$1({},n,{entry:"entry"in n?n.entry:"",type:n.type||DEFAULT_REMOTE_TYPE,entryGlobalName:n.entryGlobalName||n.name,shareScope:n.shareScope||DEFAULT_SCOPE})}let Module=class{async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let t;try{t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports})}catch{const o=getRemoteEntryUniqueKey(this.remoteInfo);t=await this.host.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry,origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports,globalLoading,uniqueKey:o})}return assert(t,`remoteEntryExports is undefined
|
|
5
|
+
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,r,o,s){const{loadFactory:l=!0}=o||{loadFactory:!0},a=await this.getEntry();if(!this.inited){const h=this.host.shareScopeMap,p=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];p.length||p.push("default"),p.forEach(g=>{h[g]||(h[g]={})});const m=h[p[0]],_=[],E={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?p:this.remoteInfo.shareScope||"default"};Object.defineProperty(E,"shareScopeMap",{value:h,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:E,initScope:_,remoteInfo:this.remoteInfo,origin:this.host});typeof(a==null?void 0:a.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{remoteName:name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await a.init(y.shareScope,y.initScope,y.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit(_extends$1({},y,{id:t,remoteSnapshot:s,remoteEntryExports:a}))}this.lib=a,this.inited=!0;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:a,expose:r,moduleInfo:this.remoteInfo}),i||(i=await a.get(r)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${r}.`);const c=processModuleAlias(this.remoteInfo.name,r),u=this.wraperFactory(i,c);return l?await u():u}wraperFactory(t,r){function o(s,l){s&&typeof s=="object"&&Object.isExtensible(s)&&!Object.getOwnPropertyDescriptor(s,Symbol.for("mf_module_id"))&&Object.defineProperty(s,Symbol.for("mf_module_id"),{value:l,enumerable:!1})}return t instanceof Promise?async()=>{const s=await t();return o(s,r),s}:()=>{const s=t();return o(s,r),s}}constructor({remoteInfo:t,host:r}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=r}};class SyncHook{on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const r=this;this.on(function o(...s){return r.remove(o),t.apply(null,s)})}emit(...t){let r;return this.listeners.size>0&&this.listeners.forEach(o=>{r=o(...t)}),r}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}}class AsyncHook extends SyncHook{emit(...t){let r;const o=Array.from(this.listeners);if(o.length>0){let s=0;const l=a=>a===!1?!1:s<o.length?Promise.resolve(o[s++].apply(null,t)).then(l):a;r=l()}return Promise.resolve(r)}}function checkReturnData(n,t){if(!isObject(t))return!1;if(n!==t){for(const r in n)if(!(r in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const r of this.listeners)try{const o=r(t);if(checkReturnData(t,o))t=o;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(o){warn(o),this.onerror(o)}return t}constructor(t){super(),this.onerror=error,this.type=t}}class AsyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const r=Array.from(this.listeners);if(r.length>0){let o=0;const s=a=>(warn(a),this.onerror(a),t),l=a=>{if(checkReturnData(t,a)){if(t=a,o<r.length)try{return Promise.resolve(r[o++](t)).then(l,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(l(t))}return Promise.resolve(t)}constructor(t){super(),this.onerror=error,this.type=t}}class PluginSystem{applyPlugin(t){assert(isPlainObject(t),"Plugin configuration is invalid.");const r=t.name;assert(r,"A name must be provided by the plugin."),this.registerPlugins[r]||(this.registerPlugins[r]=t,Object.keys(this.lifecycle).forEach(o=>{const s=t[o];s&&this.lifecycle[o].on(s)}))}removePlugin(t){assert(t,"A name is required.");const r=this.registerPlugins[t];assert(r,`The plugin "${t}" is not registered.`),Object.keys(r).forEach(o=>{o!=="name"&&this.lifecycle[o].remove(r[o])})}inherit({lifecycle:t,registerPlugins:r}){Object.keys(t).forEach(o=>{assert(!this.lifecycle[o],`The hook "${o}" has a conflict and cannot be inherited.`),this.lifecycle[o]=t[o]}),Object.keys(r).forEach(o=>{assert(!this.registerPlugins[o],`The plugin "${o}" has a conflict and cannot be inherited.`),this.applyPlugin(r[o])})}constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}}function defaultPreloadArgs(n){return _extends$1({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},n)}function formatPreloadArgs(n,t){return t.map(r=>{const o=matchRemote(n,r.nameOrAlias);return assert(o,`Unable to preload ${r.nameOrAlias} as it is not included in ${!o&&safeToString({remoteInfo:o,remotes:n})}`),{remote:o,preloadConfig:defaultPreloadArgs(r)}})}function normalizePreloadExposes(n){return n?n.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(n,t,r,o=!0){const{cssAssets:s,jsAssetsWithoutEntry:l,entryAssets:a}=r;if(t.options.inBrowser){if(a.forEach(i=>{const{moduleInfo:c}=i,u=t.moduleCache.get(n.name);getRemoteEntry(u?{origin:t,remoteInfo:c,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:c,remoteEntryExports:void 0})}),o){const i={rel:"preload",as:"style"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m}});d&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});d&&document.head.appendChild(u)})}if(o){const i={rel:"preload",as:"script"};l.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m}});d&&document.head.appendChild(u)})}else{const i={fetchpriority:"high",type:(n==null?void 0:n.type)==="module"?"module":"text/javascript"};l.forEach(c=>{const{script:u,needAttach:d}=createScript({url:c,cb:()=>{},attrs:i,createScriptHook:(h,p)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:h,attrs:p});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});d&&document.head.appendChild(u)})}}}function assignRemoteInfo(n,t){const r=getRemoteEntryInfoFromSnapshot(t);r.url||error(`The attribute remoteEntry of ${n.name} must not be undefined.`);let o=getResourceUrl(t,r.url);!isBrowserEnv()&&!o.startsWith("http")&&(o=`https:${o}`),n.type=r.type,n.entryGlobalName=r.globalName,n.entry=o,n.version=t.version,n.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(n){const{remote:t,pkgNameOrAlias:r,expose:o,origin:s,remoteInfo:l}=n;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:a,globalSnapshot:i}=await s.snapshotHandler.loadRemoteSnapshotInfo(t);assignRemoteInfo(l,a);const c={remote:t,preloadConfig:{nameOrAlias:r,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},u=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:c,remoteInfo:l,remote:t,remoteSnapshot:a,globalSnapshot:i});return u&&preloadAssets(l,s,u,!1),_extends$1({},n,{remoteSnapshot:a})}return n}}}function splitId(n){const t=n.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(n,t,r,o,s={},l){const a=getFMId(t),{value:i}=getInfoWithoutType(n,a),c=l||i;if(c&&!isManifestProvider(c)&&(r(c,t,o),c.remotesInfo)){const u=Object.keys(c.remotesInfo);for(const d of u){if(s[d])continue;s[d]=!0;const h=splitId(d),p=c.remotesInfo[d];traverseModuleInfo(n,{name:h.name,version:p.matchedVersion},r,!1,s,void 0)}}}const isExisted=(n,t)=>document.querySelector(`${n}[${n==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(n,t,r,o,s){const l=[],a=[],i=[],c=new Set,u=new Set,{options:d}=n,{preloadConfig:h}=t,{depsRemote:p}=h;if(traverseModuleInfo(o,r,(y,g,I)=>{let R;if(I)R=h;else if(Array.isArray(p)){const O=p.find(T=>T.nameOrAlias===g.name||T.nameOrAlias===g.alias);if(!O)return;R=defaultPreloadArgs(O)}else if(p===!0)R=h;else return;const S=getResourceUrl(y,getRemoteEntryInfoFromSnapshot(y).url);S&&i.push({name:g.name,moduleInfo:{name:g.name,entry:S,type:"remoteEntryType"in y?y.remoteEntryType:"global",entryGlobalName:"globalName"in y?y.globalName:g.name,shareScope:"",version:"version"in y?y.version:void 0},url:S});let b="modules"in y?y.modules:[];const v=normalizePreloadExposes(R.exposes);if(v.length&&"modules"in y){var $;b=y==null||($=y.modules)==null?void 0:$.reduce((O,T)=>((v==null?void 0:v.indexOf(T.moduleName))!==-1&&O.push(T),O),[])}function A(O){const T=O.map(N=>getResourceUrl(y,N));return R.filter?T.filter(R.filter):T}if(b){const O=b.length;for(let T=0;T<O;T++){const N=b[T],w=`${g.name}/${N.moduleName}`;n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:N.moduleName==="."?g.name:w,name:g.name,remoteSnapshot:y,preloadConfig:R,remote:g,origin:n}),!getPreloaded(w)&&(R.resourceCategory==="all"?(l.push(...A(N.assets.css.async)),l.push(...A(N.assets.css.sync)),a.push(...A(N.assets.js.async)),a.push(...A(N.assets.js.sync))):(R.resourceCategory="sync")&&(l.push(...A(N.assets.css.sync)),a.push(...A(N.assets.js.sync))),setPreloaded(w))}}},!0,{},s),s.shared){const y=(g,I)=>{const R=getRegisteredShare(n.shareScopeMap,I.sharedName,g,n.sharedHandler.hooks.lifecycle.resolveShare);R&&typeof R.lib=="function"&&(I.assets.js.sync.forEach(S=>{c.add(S)}),I.assets.css.sync.forEach(S=>{u.add(S)}))};s.shared.forEach(g=>{var I;const R=(I=d.shared)==null?void 0:I[g.sharedName];if(!R)return;const S=g.version?R.find(v=>v.version===g.version):R;if(!S)return;arrayOptions(S).forEach(v=>{y(v,g)})})}const _=a.filter(y=>!c.has(y)&&!isExisted("script",y));return{cssAssets:l.filter(y=>!u.has(y)&&!isExisted("link",y)),jsAssetsWithoutEntry:_,entryAssets:i.filter(y=>!isExisted("script",y.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(n){const{origin:t,preloadOptions:r,remoteInfo:o,remote:s,globalSnapshot:l,remoteSnapshot:a}=n;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:o.name,entry:s.entry,type:o.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(o,a),generatePreloadAssets(t,r,o,l,a)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(n,t){const r=getGlobalSnapshotInfoByModuleInfo({name:t.options.name,version:t.options.version}),o=r&&"remotesInfo"in r&&r.remotesInfo&&getInfoWithoutType(r.remotesInfo,n.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:r,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:n.name,version:o.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:n.name,version:"version"in n?n.version:void 0})}}class SnapshotHandler{async loadSnapshot(t){const{options:r}=this.HostInstance,{hostGlobalSnapshot:o,remoteSnapshot:s,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:a,globalSnapshot:i}=await this.hooks.lifecycle.loadSnapshot.emit({options:r,moduleInfo:t,hostGlobalSnapshot:o,remoteSnapshot:s,globalSnapshot:l});return{remoteSnapshot:a,globalSnapshot:i}}async loadRemoteSnapshotInfo(t){const{options:r}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:r,moduleInfo:t});let o=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});o||(o={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:o})),o&&"remotesInfo"in o&&!getInfoWithoutType(o.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(o.remotesInfo=_extends$1({},o==null?void 0:o.remotesInfo,{[t.name]:{matchedVersion:"version"in t?t.version:t.entry}}));const{hostGlobalSnapshot:s,remoteSnapshot:l,globalSnapshot:a}=this.getGlobalRemoteInfo(t),{remoteSnapshot:i,globalSnapshot:c}=await this.hooks.lifecycle.loadSnapshot.emit({options:r,moduleInfo:t,hostGlobalSnapshot:s,remoteSnapshot:l,globalSnapshot:a});let u,d;if(i)if(isManifestProvider(i)){const h=isBrowserEnv()?i.remoteEntry:i.ssrRemoteEntry||i.remoteEntry||"",p=await this.getManifestJson(h,t,{}),m=setGlobalSnapshotInfoByModuleInfo(_extends$1({},t,{entry:h}),p);u=p,d=m}else{const{remoteSnapshot:h}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:i,from:"global"});u=h,d=c}else if(isRemoteInfoWithEntry(t)){const h=await this.getManifestJson(t.entry,t,{}),p=setGlobalSnapshotInfoByModuleInfo(t,h),{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:h,from:"global"});u=m,d=p}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(c)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({options:r,moduleInfo:t,remoteSnapshot:u}),{remoteSnapshot:u,globalSnapshot:d}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,r,o){const s=async()=>{let a=this.manifestCache.get(t);if(a)return a;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});(!i||!(i instanceof Response))&&(i=await fetch(t,{})),a=await i.json()}catch(i){a=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),a||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:r.name,hostName:this.HostInstance.options.name},`${i}`)))}return assert(a.metaData&&a.exposes&&a.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,a),a},l=async()=>{const a=await s(),i=generateSnapshotFromManifest(a,{version:t}),{remoteSnapshot:c}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:r,manifestJson:a,remoteSnapshot:i,manifestUrl:t,from:"manifest"});return c};return this.manifestLoading[t]||(this.manifestLoading[t]=l().then(a=>a)),this.manifestLoading[t]}constructor(t){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new PluginSystem({beforeLoadRemoteSnapshot:new AsyncHook("beforeLoadRemoteSnapshot"),loadSnapshot:new AsyncWaterfallHook("loadGlobalSnapshot"),loadRemoteSnapshot:new AsyncWaterfallHook("loadRemoteSnapshot"),afterLoadSnapshot:new AsyncWaterfallHook("afterLoadSnapshot")}),this.manifestLoading=Global.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=t,this.loaderHook=t.loaderHook}}class SharedHandler{registerShared(t,r){const{shareInfos:o,shared:s}=formatShareConfigs(t,r);return Object.keys(o).forEach(a=>{o[a].forEach(c=>{!getRegisteredShare(this.shareScopeMap,a,c,this.hooks.lifecycle.resolveShare)&&c&&c.lib&&this.setShared({pkgName:a,lib:c.lib,get:c.get,loaded:!0,shared:c,from:r.name})})}),{shareInfos:o,shared:s}}async loadShare(t,r){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:r,shareInfos:o.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const l=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:o.options.shared,origin:o}),{shareInfo:a}=l;assert(a,`Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare),c=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,o.options.name)};if(i&&i.lib)return c(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),c(i),u}else if(i){const d=(async()=>{const h=await i.get();a.lib=h,a.loaded=!0,c(a);const p=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0),h})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:o.options.name,lib:null,loading:d}),d}else{if(r!=null&&r.customShareInfo)return!1;const d=(async()=>{const h=await a.get();a.lib=h,a.loaded=!0,c(a);const p=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0),h})();return this.setShared({pkgName:t,loaded:!1,shared:a,from:o.options.name,lib:null,loading:d}),d}}initializeSharing(t=DEFAULT_SCOPE,r){const{host:o}=this,s=r==null?void 0:r.from,l=r==null?void 0:r.strategy;let a=r==null?void 0:r.initScope;const i=[];if(s!=="build"){const{initTokens:_}=this;a||(a=[]);let E=_[t];if(E||(E=_[t]={from:this.host.name}),a.indexOf(E)>=0)return i;a.push(E)}const c=this.shareScopeMap,u=o.options.name;c[t]||(c[t]={});const d=c[t],h=(_,E)=>{var y;const{version:g,eager:I}=E;d[_]=d[_]||{};const R=d[_],S=R[g],b=!!(S&&(S.eager||(y=S.shareConfig)!=null&&y.eager));(!S||S.strategy!=="loaded-first"&&!S.loaded&&(!I!=!b?I:u>S.from))&&(R[g]=E)},p=_=>_&&_.init&&_.init(c[t],a),m=async _=>{const{module:E}=await o.remoteHandler.getRemoteModuleAndOptions({id:_});if(E.getEntry){let y;try{y=await E.getEntry()}catch(g){y=await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:_,error:g,from:"runtime",lifecycle:"beforeLoadShare",origin:o})}E.inited||(await p(y),E.inited=!0)}};return Object.keys(o.options.shared).forEach(_=>{o.options.shared[_].forEach(y=>{y.scope.includes(t)&&h(_,y)})}),(o.options.shareStrategy==="version-first"||l==="version-first")&&o.options.remotes.forEach(_=>{_.shareScope===t&&i.push(m(_.name))}),i}loadShareSync(t,r){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:r,shareInfos:o.options.shared});s!=null&&s.scope&&s.scope.forEach(i=>{this.initializeSharing(i,{strategy:s.strategy})});const l=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),a=i=>{i.useIn||(i.useIn=[]),addUniqueItem(i.useIn,o.options.name)};if(l){if(typeof l.lib=="function")return a(l),l.loaded||(l.loaded=!0,l.from===o.options.name&&(s.loaded=!0)),l.lib;if(typeof l.get=="function"){const i=l.get();if(!(i instanceof Promise))return a(l),this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:i,shared:l}),i}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const i=s.get();if(i instanceof Promise){const c=(r==null?void 0:r.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(c,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}initShareScopeMap(t,r,o={}){const{host:s}=this;this.shareScopeMap[t]=r,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:r,options:s.options,origin:s,scopeName:t,hostShareScopeMap:o.hostShareScopeMap})}setShared({pkgName:t,shared:r,from:o,lib:s,loading:l,loaded:a,get:i}){const{version:c,scope:u="default"}=r,d=_object_without_properties_loose(r,["version","scope"]);(Array.isArray(u)?u:[u]).forEach(p=>{if(this.shareScopeMap[p]||(this.shareScopeMap[p]={}),this.shareScopeMap[p][t]||(this.shareScopeMap[p][t]={}),!this.shareScopeMap[p][t][c]){this.shareScopeMap[p][t][c]=_extends$1({version:c,scope:["default"]},d,{lib:s,loaded:a,loading:l}),i&&(this.shareScopeMap[p][t][c].get=i);return}const m=this.shareScopeMap[p][t][c];l&&!m.loading&&(m.loading=l)})}_setGlobalShareScopeMap(t){const r=getGlobalShareScope(),o=t.id||t.name;o&&!r[o]&&(r[o]=this.shareScopeMap)}constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}}class RemoteHandler{formatAndRegisterRemote(t,r){return(r.remotes||[]).reduce((s,l)=>(this.registerRemote(l,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,r){const{remote:o,expose:s}=r,{name:l,alias:a}=o;if(this.idToRemoteMap[t]={name:o.name,expose:s},a&&t.startsWith(l)){const i=t.replace(l,a);this.idToRemoteMap[i]={name:o.name,expose:s};return}if(a&&t.startsWith(a)){const i=t.replace(a,l);this.idToRemoteMap[i]={name:o.name,expose:s}}}async loadRemote(t,r){const{host:o}=this;try{const{loadFactory:s=!0}=r||{loadFactory:!0},{module:l,moduleOptions:a,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:c,remote:u,expose:d,id:h,remoteSnapshot:p}=i,m=await l.get(h,d,r,p),_=await this.hooks.lifecycle.onLoad.emit({id:h,pkgNameOrAlias:c,expose:d,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:a,moduleInstance:l,origin:o});return this.setIdToRemoteMap(t,i),typeof _=="function"?_:m}catch(s){const{from:l="runtime"}=r||{from:"runtime"},a=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:l,lifecycle:"onLoad",origin:o});if(!a)throw s;return a}}async preloadRemote(t){const{host:r}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:r.options,origin:r});const o=formatPreloadArgs(r.options.remotes,t);await Promise.all(o.map(async s=>{const{remote:l}=s,a=getRemoteInfo(l),{globalSnapshot:i,remoteSnapshot:c}=await r.snapshotHandler.loadRemoteSnapshotInfo(l),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:r,preloadOptions:s,remote:l,remoteInfo:a,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(a,r,u)}))}registerRemotes(t,r){const{host:o}=this;t.forEach(s=>{this.registerRemote(s,o.options.remotes,{force:r==null?void 0:r.force})})}async getRemoteModuleAndOptions(t){const{host:r}=this,{id:o}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:r.options,origin:r})}catch(_){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:r.options,origin:r,from:"runtime",error:_,lifecycle:"beforeRequest"}),!s)throw _}const{id:l}=s,a=matchRemoteWithNameAndExpose(r.options.remotes,l);assert(a,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:r.options.name,requestId:l}));const{remote:i}=a,c=getRemoteInfo(i),u=await r.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:l},a,{options:r.options,origin:r,remoteInfo:c})),{remote:d,expose:h}=u;assert(d&&h,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);let p=r.moduleCache.get(d.name);const m={host:r,remoteInfo:c};return p||(p=new Module(m),r.moduleCache.set(d.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,r,o){const{host:s}=this,l=()=>{if(t.alias){const i=r.find(c=>{var u;return t.alias&&(c.name.startsWith(t.alias)||((u=c.alias)==null?void 0:u.startsWith(t.alias)))});assert(!i,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const a=r.find(i=>i.name===t.name);if(!a)l(),r.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."];o!=null&&o.force&&(this.removeRemote(a),l(),r.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){try{const{host:o}=this,{name:s}=t,l=o.options.remotes.findIndex(i=>i.name===s);l!==-1&&o.options.remotes.splice(l,1);const a=o.moduleCache.get(t.name);if(a){const i=a.remoteInfo,c=i.entryGlobalName;if(CurrentGlobal[c]){var r;(r=Object.getOwnPropertyDescriptor(CurrentGlobal,c))!=null&&r.configurable?delete CurrentGlobal[c]:CurrentGlobal[c]=void 0}const u=getRemoteEntryUniqueKey(a.remoteInfo);globalLoading[u]&&delete globalLoading[u],o.snapshotHandler.manifestCache.delete(i.entry);let d=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const h=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===d:m.name===d);if(h!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[h];d=m.options.id||d;const _=getGlobalShareScope();let E=!0;const y=[];Object.keys(_).forEach(g=>{const I=_[g];I&&Object.keys(I).forEach(R=>{const S=I[R];S&&Object.keys(S).forEach(b=>{const v=S[b];v&&Object.keys(v).forEach($=>{const A=v[$];A&&typeof A=="object"&&A.from===i.name&&(A.loaded||A.loading?(A.useIn=A.useIn.filter(O=>O!==i.name),A.useIn.length?E=!1:y.push([g,R,b,$])):y.push([g,R,b,$]))})})})}),E&&(m.shareScopeMap={},delete _[d]),y.forEach(([g,I,R,S])=>{var b,v,$;($=_[g])==null||(v=$[I])==null||(b=v[R])==null||delete b[S]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(h,1)}const{hostGlobalSnapshot:p}=getGlobalRemoteInfo(t,o);if(p){const m=p&&"remotesInfo"in p&&p.remotesInfo&&getInfoWithoutType(p.remotesInfo,t.name).key;m&&(delete p.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}o.moduleCache.delete(t.name)}}catch(o){logger.log("removeRemote fail: ",o)}}constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}}const USE_SNAPSHOT=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;class FederationHost{initOptions(t){this.registerPlugins(t.plugins);const r=this.formatOptions(this.options,t);return this.options=r,r}async loadShare(t,r){return this.sharedHandler.loadShare(t,r)}loadShareSync(t,r){return this.sharedHandler.loadShareSync(t,r)}initializeSharing(t=DEFAULT_SCOPE,r){return this.sharedHandler.initializeSharing(t,r)}initRawContainer(t,r,o){const s=getRemoteInfo({name:t,entry:r}),l=new Module({host:this,remoteInfo:s});return l.remoteEntryExports=o,this.moduleCache.set(t,l),l}async loadRemote(t,r){return this.remoteHandler.loadRemote(t,r)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,r,o={}){this.sharedHandler.initShareScopeMap(t,r,o)}formatOptions(t,r){const{shared:o}=formatShareConfigs(t,r),{userOptions:s,options:l}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:r,options:t,shareInfo:o}),a=this.remoteHandler.formatAndRegisterRemote(l,s),{shared:i}=this.sharedHandler.registerShared(l,s),c=[...l.plugins];s.plugins&&s.plugins.forEach(d=>{c.includes(d)||c.push(d)});const u=_extends$1({},t,r,{plugins:c,remotes:a,shared:i});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const r=registerPlugins(t,[this.hooks,this.remoteHandler.hooks,this.sharedHandler.hooks,this.snapshotHandler.hooks,this.loaderHook,this.bridgeHook]);this.options.plugins=this.options.plugins.reduce((o,s)=>(s&&o&&!o.find(l=>l.name===s.name)&&o.push(s),o),r||[])}registerRemotes(t,r){return this.remoteHandler.registerRemotes(t,r)}constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.14.0",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const r=USE_SNAPSHOT?[snapshotPlugin(),generatePreloadAssetsPlugin()]:[],o={id:getBuilderId(),name:t.name,plugins:r,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=o,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...o.plugins,...t.plugins||[]]),this.options=this.formatOptions(o,t)}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(FederationHost);function createBridgeComponent(n){const t=new Map,r=getInstance();return()=>({__APP_VERSION__:"0.14.0",async render(o){var _,E,y;LoggerInstance.debug("createBridgeComponent render Info",o);const{moduleName:s,dom:l,basename:a,memoryRoute:i,hashRoute:c,...u}=o,d=Vue__namespace.createApp(n.rootComponent,u);t.set(l,d);const h=await((y=(E=(_=r==null?void 0:r.bridgeHook)==null?void 0:_.lifecycle)==null?void 0:E.beforeBridgeRender)==null?void 0:y.emit(o)),p=h&&typeof h=="object"&&(h!=null&&h.extraProps)?h==null?void 0:h.extraProps:{},m=n.appOptions({app:d,basename:a,memoryRoute:i,hashRoute:c,...u,...p});if(m!=null&&m.router){let g,I=m.router.getRoutes();o.memoryRoute?g=VueRouter__namespace.createMemoryHistory(o.basename):o.hashRoute?(g=VueRouter__namespace.createWebHashHistory(),I=I.map(S=>({...S,path:o.basename+S.path}))):g=VueRouter__namespace.createWebHistory(o.basename);const R=VueRouter__namespace.createRouter({...m.router.options,history:g,routes:I});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:R}),i&&await R.push(i.entryPath),d.use(R)}d.mount(l)},destroy(o){LoggerInstance.debug("createBridgeComponent destroy Info",o);const s=t.get(o==null?void 0:o.dom);s==null||s.unmount()}})}function e(){const n=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(n)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(n){const t=Vue.ref(null),r=Vue.ref(null),o=Vue.ref(""),s=VueRouter.useRoute(),l=getInstance(),a=Vue.useAttrs(),i=async()=>{var p,m,_,E;const u=(p=n.providerInfo)==null?void 0:p.call(n);r.value=u;let d={...a,moduleName:n.moduleName,dom:t.value,basename:n.basename,memoryRoute:n.memoryRoute,hashRoute:n.hashRoute};LoggerInstance.debug("createRemoteComponent LazyComponent render >>>",d);const h=await((E=(_=(m=l==null?void 0:l.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:_.beforeBridgeRender)==null?void 0:E.emit(d))||{};d={...d,...h.extraProps},u.render(d)},c=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&i(),o.value!==""&&o.value!==u&&(LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>",{...n,pathname:s.path}),e()),o.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>",{...n}),c(),(u=r.value)==null||u.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(n.rootAttrs||{},{ref:t}),null)}});function createRemoteComponent(n){return Vue.defineAsyncComponent({__APP_VERSION__:"0.14.0",...n.asyncComponentOptions,loader:async()=>{var c,u;const t=VueRouter.useRoute();let r="/";const o=(u=(c=t==null?void 0:t.matched)==null?void 0:c[0])==null?void 0:u.path;o&&(o.endsWith("/:pathMatch(.*)*")?r=o.replace("/:pathMatch(.*)*",""):r=t.matched[0].path);const s=(n==null?void 0:n.export)||"default";LoggerInstance.debug("createRemoteComponent LazyComponent create >>>",{basename:r,info:n});const l=await n.loader(),a=l&&l[Symbol.for("mf_module_id")],i=l[s];if(LoggerInstance.debug("createRemoteComponent LazyComponent loadRemote info >>>",{moduleName:a,module:l,exportName:s,basename:r,route:t}),s in l&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:a,providerInfo:i,basename:r,rootAttrs:n.rootAttrs})}};throw new Error("module not found")}})}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteComponent=createRemoteComponent;
|
package/dist/index.js
CHANGED
|
@@ -75,58 +75,51 @@ function generateSnapshotFromManifest(n, t = {}) {
|
|
|
75
75
|
let d = {};
|
|
76
76
|
if (!Object.keys(s).length) {
|
|
77
77
|
var p;
|
|
78
|
-
d = ((p = n.remotes) == null ? void 0 : p.reduce((
|
|
79
|
-
let
|
|
80
|
-
const
|
|
81
|
-
return u.includes(
|
|
82
|
-
matchedVersion:
|
|
83
|
-
},
|
|
78
|
+
d = ((p = n.remotes) == null ? void 0 : p.reduce((R, A) => {
|
|
79
|
+
let T;
|
|
80
|
+
const $ = A.federationContainerName;
|
|
81
|
+
return u.includes($) ? T = l[$] : "version" in A ? T = A.version : T = A.entry, R[$] = {
|
|
82
|
+
matchedVersion: T
|
|
83
|
+
}, R;
|
|
84
84
|
}, {})) || {};
|
|
85
85
|
}
|
|
86
|
-
Object.keys(s).forEach((
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// overrides will override dependencies
|
|
90
|
-
matchedVersion: u.includes(g) ? l[g] : s[g]
|
|
91
|
-
} : typeof s[g] == "object" ? _extends$2({}, s[g], {
|
|
92
|
-
matchedVersion: u.includes(g) ? l[g] : ((A = s[g]) == null ? void 0 : A.version) || (($ = s[g]) == null ? void 0 : $.entry)
|
|
93
|
-
}) : {
|
|
94
|
-
matchedVersion: "*"
|
|
95
|
-
};
|
|
86
|
+
Object.keys(s).forEach((R) => d[R] = {
|
|
87
|
+
// overrides will override dependencies
|
|
88
|
+
matchedVersion: u.includes(R) ? l[R] : s[R]
|
|
96
89
|
});
|
|
97
|
-
const { remoteEntry: { path: m, name: y, type: E }, types:
|
|
90
|
+
const { remoteEntry: { path: m, name: y, type: E }, types: b, buildInfo: { buildVersion: _ }, globalName: g, ssrRemoteEntry: v } = n.metaData, { exposes: S } = n;
|
|
98
91
|
let I = {
|
|
99
92
|
version: a || "",
|
|
100
93
|
buildVersion: _,
|
|
101
|
-
globalName:
|
|
94
|
+
globalName: g,
|
|
102
95
|
remoteEntry: simpleJoinRemoteEntry(m, y),
|
|
103
96
|
remoteEntryType: E,
|
|
104
|
-
remoteTypes: simpleJoinRemoteEntry(
|
|
105
|
-
remoteTypesZip:
|
|
106
|
-
remoteTypesAPI:
|
|
97
|
+
remoteTypes: simpleJoinRemoteEntry(b.path, b.name),
|
|
98
|
+
remoteTypesZip: b.zip || "",
|
|
99
|
+
remoteTypesAPI: b.api || "",
|
|
107
100
|
remotesInfo: d,
|
|
108
|
-
shared: n == null ? void 0 : n.shared.map((
|
|
109
|
-
assets:
|
|
110
|
-
sharedName:
|
|
111
|
-
version:
|
|
101
|
+
shared: n == null ? void 0 : n.shared.map((R) => ({
|
|
102
|
+
assets: R.assets,
|
|
103
|
+
sharedName: R.name,
|
|
104
|
+
version: R.version
|
|
112
105
|
})),
|
|
113
|
-
modules: S == null ? void 0 : S.map((
|
|
114
|
-
moduleName:
|
|
115
|
-
modulePath:
|
|
116
|
-
assets:
|
|
106
|
+
modules: S == null ? void 0 : S.map((R) => ({
|
|
107
|
+
moduleName: R.name,
|
|
108
|
+
modulePath: R.path,
|
|
109
|
+
assets: R.assets
|
|
117
110
|
}))
|
|
118
111
|
};
|
|
119
112
|
if ((r = n.metaData) != null && r.prefetchInterface) {
|
|
120
|
-
const
|
|
113
|
+
const R = n.metaData.prefetchInterface;
|
|
121
114
|
I = _extends$2({}, I, {
|
|
122
|
-
prefetchInterface:
|
|
115
|
+
prefetchInterface: R
|
|
123
116
|
});
|
|
124
117
|
}
|
|
125
118
|
if ((o = n.metaData) != null && o.prefetchEntry) {
|
|
126
|
-
const { path:
|
|
119
|
+
const { path: R, name: A, type: T } = n.metaData.prefetchEntry;
|
|
127
120
|
I = _extends$2({}, I, {
|
|
128
|
-
prefetchEntry: simpleJoinRemoteEntry(
|
|
129
|
-
prefetchEntryType:
|
|
121
|
+
prefetchEntry: simpleJoinRemoteEntry(R, A),
|
|
122
|
+
prefetchEntryType: T
|
|
130
123
|
});
|
|
131
124
|
}
|
|
132
125
|
if ("publicPath" in n.metaData ? i = _extends$2({}, I, {
|
|
@@ -135,8 +128,8 @@ function generateSnapshotFromManifest(n, t = {}) {
|
|
|
135
128
|
}) : i = _extends$2({}, I, {
|
|
136
129
|
getPublicPath: c()
|
|
137
130
|
}), v) {
|
|
138
|
-
const
|
|
139
|
-
i.ssrRemoteEntry =
|
|
131
|
+
const R = simpleJoinRemoteEntry(v.path, v.name);
|
|
132
|
+
i.ssrRemoteEntry = R, i.ssrRemoteEntryType = v.type || "commonjs-module";
|
|
140
133
|
}
|
|
141
134
|
return i;
|
|
142
135
|
}
|
|
@@ -528,7 +521,7 @@ function setGlobalDefaultVal(n) {
|
|
|
528
521
|
setGlobalDefaultVal(CurrentGlobal);
|
|
529
522
|
setGlobalDefaultVal(nativeGlobal);
|
|
530
523
|
function setGlobalFederationConstructor(n, t = isDebugMode()) {
|
|
531
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = n, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
524
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = n, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.14.0");
|
|
532
525
|
}
|
|
533
526
|
function getInfoWithoutType(n, t) {
|
|
534
527
|
if (typeof t == "string") {
|
|
@@ -724,12 +717,12 @@ function satisfy(n, t) {
|
|
|
724
717
|
const y = extractComparator(m);
|
|
725
718
|
if (!y)
|
|
726
719
|
return !1;
|
|
727
|
-
const [, E, ,
|
|
720
|
+
const [, E, , b, _, g, v] = y, S = {
|
|
728
721
|
operator: E,
|
|
729
|
-
version: combineVersion(
|
|
730
|
-
major:
|
|
722
|
+
version: combineVersion(b, _, g, v),
|
|
723
|
+
major: b,
|
|
731
724
|
minor: _,
|
|
732
|
-
patch:
|
|
725
|
+
patch: g,
|
|
733
726
|
preRelease: v == null ? void 0 : v.split(".")
|
|
734
727
|
};
|
|
735
728
|
if (!compare(S, p))
|
|
@@ -826,15 +819,15 @@ function getRegisteredShare(n, t, r, o) {
|
|
|
826
819
|
const { requiredVersion: u } = s, p = getFindShareFunction(a)(n, c, t), m = () => {
|
|
827
820
|
if (s.singleton) {
|
|
828
821
|
if (typeof u == "string" && !satisfy(p, u)) {
|
|
829
|
-
const
|
|
830
|
-
s.strictVersion ? error(
|
|
822
|
+
const b = `Version ${p} from ${p && n[c][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${u})`;
|
|
823
|
+
s.strictVersion ? error(b) : warn(b);
|
|
831
824
|
}
|
|
832
825
|
return n[c][t][p];
|
|
833
826
|
} else {
|
|
834
827
|
if (u === !1 || u === "*" || satisfy(p, u))
|
|
835
828
|
return n[c][t][p];
|
|
836
|
-
for (const [
|
|
837
|
-
if (satisfy(
|
|
829
|
+
for (const [b, _] of Object.entries(n[c][t]))
|
|
830
|
+
if (satisfy(b, u))
|
|
838
831
|
return _;
|
|
839
832
|
}
|
|
840
833
|
}, y = {
|
|
@@ -1092,14 +1085,14 @@ let Module = class {
|
|
|
1092
1085
|
const p = this.host.shareScopeMap, m = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [
|
|
1093
1086
|
this.remoteInfo.shareScope
|
|
1094
1087
|
];
|
|
1095
|
-
m.length || m.push("default"), m.forEach((
|
|
1096
|
-
p[
|
|
1088
|
+
m.length || m.push("default"), m.forEach((g) => {
|
|
1089
|
+
p[g] || (p[g] = {});
|
|
1097
1090
|
});
|
|
1098
|
-
const y = p[m[0]], E = [],
|
|
1091
|
+
const y = p[m[0]], E = [], b = {
|
|
1099
1092
|
version: this.remoteInfo.version || "",
|
|
1100
1093
|
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? m : this.remoteInfo.shareScope || "default"
|
|
1101
1094
|
};
|
|
1102
|
-
Object.defineProperty(
|
|
1095
|
+
Object.defineProperty(b, "shareScopeMap", {
|
|
1103
1096
|
value: p,
|
|
1104
1097
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1105
1098
|
enumerable: !1
|
|
@@ -1107,7 +1100,7 @@ let Module = class {
|
|
|
1107
1100
|
const _ = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1108
1101
|
shareScope: y,
|
|
1109
1102
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1110
|
-
remoteEntryInitOptions:
|
|
1103
|
+
remoteEntryInitOptions: b,
|
|
1111
1104
|
initScope: E,
|
|
1112
1105
|
remoteInfo: this.remoteInfo,
|
|
1113
1106
|
origin: this.host
|
|
@@ -1478,12 +1471,12 @@ function traverseModuleInfo(n, t, r, o, s = {}, l) {
|
|
|
1478
1471
|
const isExisted = (n, t) => document.querySelector(`${n}[${n === "link" ? "href" : "src"}="${t}"]`);
|
|
1479
1472
|
function generatePreloadAssets(n, t, r, o, s) {
|
|
1480
1473
|
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = n, { preloadConfig: p } = t, { depsRemote: m } = p;
|
|
1481
|
-
if (traverseModuleInfo(o, r, (_,
|
|
1474
|
+
if (traverseModuleInfo(o, r, (_, g, v) => {
|
|
1482
1475
|
let S;
|
|
1483
1476
|
if (v)
|
|
1484
1477
|
S = p;
|
|
1485
1478
|
else if (Array.isArray(m)) {
|
|
1486
|
-
const N = m.find((O) => O.nameOrAlias ===
|
|
1479
|
+
const N = m.find((O) => O.nameOrAlias === g.name || O.nameOrAlias === g.alias);
|
|
1487
1480
|
if (!N)
|
|
1488
1481
|
return;
|
|
1489
1482
|
S = defaultPreloadArgs(N);
|
|
@@ -1493,60 +1486,60 @@ function generatePreloadAssets(n, t, r, o, s) {
|
|
|
1493
1486
|
return;
|
|
1494
1487
|
const I = getResourceUrl(_, getRemoteEntryInfoFromSnapshot(_).url);
|
|
1495
1488
|
I && i.push({
|
|
1496
|
-
name:
|
|
1489
|
+
name: g.name,
|
|
1497
1490
|
moduleInfo: {
|
|
1498
|
-
name:
|
|
1491
|
+
name: g.name,
|
|
1499
1492
|
entry: I,
|
|
1500
1493
|
type: "remoteEntryType" in _ ? _.remoteEntryType : "global",
|
|
1501
|
-
entryGlobalName: "globalName" in _ ? _.globalName :
|
|
1494
|
+
entryGlobalName: "globalName" in _ ? _.globalName : g.name,
|
|
1502
1495
|
shareScope: "",
|
|
1503
1496
|
version: "version" in _ ? _.version : void 0
|
|
1504
1497
|
},
|
|
1505
1498
|
url: I
|
|
1506
1499
|
});
|
|
1507
|
-
let
|
|
1500
|
+
let R = "modules" in _ ? _.modules : [];
|
|
1508
1501
|
const A = normalizePreloadExposes(S.exposes);
|
|
1509
1502
|
if (A.length && "modules" in _) {
|
|
1510
|
-
var
|
|
1511
|
-
|
|
1503
|
+
var T;
|
|
1504
|
+
R = _ == null || (T = _.modules) == null ? void 0 : T.reduce((N, O) => ((A == null ? void 0 : A.indexOf(O.moduleName)) !== -1 && N.push(O), N), []);
|
|
1512
1505
|
}
|
|
1513
|
-
function
|
|
1506
|
+
function $(N) {
|
|
1514
1507
|
const O = N.map((w) => getResourceUrl(_, w));
|
|
1515
1508
|
return S.filter ? O.filter(S.filter) : O;
|
|
1516
1509
|
}
|
|
1517
|
-
if (
|
|
1518
|
-
const N =
|
|
1510
|
+
if (R) {
|
|
1511
|
+
const N = R.length;
|
|
1519
1512
|
for (let O = 0; O < N; O++) {
|
|
1520
|
-
const w =
|
|
1513
|
+
const w = R[O], P = `${g.name}/${w.moduleName}`;
|
|
1521
1514
|
n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1522
|
-
id: w.moduleName === "." ?
|
|
1523
|
-
name:
|
|
1515
|
+
id: w.moduleName === "." ? g.name : P,
|
|
1516
|
+
name: g.name,
|
|
1524
1517
|
remoteSnapshot: _,
|
|
1525
1518
|
preloadConfig: S,
|
|
1526
|
-
remote:
|
|
1519
|
+
remote: g,
|
|
1527
1520
|
origin: n
|
|
1528
|
-
}), !getPreloaded(P) && (S.resourceCategory === "all" ? (l.push(
|
|
1521
|
+
}), !getPreloaded(P) && (S.resourceCategory === "all" ? (l.push(...$(w.assets.css.async)), l.push(...$(w.assets.css.sync)), a.push(...$(w.assets.js.async)), a.push(...$(w.assets.js.sync))) : (S.resourceCategory = "sync") && (l.push(...$(w.assets.css.sync)), a.push(...$(w.assets.js.sync))), setPreloaded(P));
|
|
1529
1522
|
}
|
|
1530
1523
|
}
|
|
1531
1524
|
}, !0, {}, s), s.shared) {
|
|
1532
|
-
const _ = (
|
|
1533
|
-
const S = getRegisteredShare(n.shareScopeMap, v.sharedName,
|
|
1525
|
+
const _ = (g, v) => {
|
|
1526
|
+
const S = getRegisteredShare(n.shareScopeMap, v.sharedName, g, n.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1534
1527
|
S && typeof S.lib == "function" && (v.assets.js.sync.forEach((I) => {
|
|
1535
1528
|
c.add(I);
|
|
1536
1529
|
}), v.assets.css.sync.forEach((I) => {
|
|
1537
1530
|
u.add(I);
|
|
1538
1531
|
}));
|
|
1539
1532
|
};
|
|
1540
|
-
s.shared.forEach((
|
|
1533
|
+
s.shared.forEach((g) => {
|
|
1541
1534
|
var v;
|
|
1542
|
-
const S = (v = d.shared) == null ? void 0 : v[
|
|
1535
|
+
const S = (v = d.shared) == null ? void 0 : v[g.sharedName];
|
|
1543
1536
|
if (!S)
|
|
1544
1537
|
return;
|
|
1545
|
-
const I =
|
|
1538
|
+
const I = g.version ? S.find((A) => A.version === g.version) : S;
|
|
1546
1539
|
if (!I)
|
|
1547
1540
|
return;
|
|
1548
1541
|
arrayOptions(I).forEach((A) => {
|
|
1549
|
-
_(A,
|
|
1542
|
+
_(A, g);
|
|
1550
1543
|
});
|
|
1551
1544
|
});
|
|
1552
1545
|
}
|
|
@@ -1833,38 +1826,38 @@ class SharedHandler {
|
|
|
1833
1826
|
if (s !== "build") {
|
|
1834
1827
|
const { initTokens: E } = this;
|
|
1835
1828
|
a || (a = []);
|
|
1836
|
-
let
|
|
1837
|
-
if (
|
|
1829
|
+
let b = E[t];
|
|
1830
|
+
if (b || (b = E[t] = {
|
|
1838
1831
|
from: this.host.name
|
|
1839
|
-
}), a.indexOf(
|
|
1840
|
-
a.push(
|
|
1832
|
+
}), a.indexOf(b) >= 0) return i;
|
|
1833
|
+
a.push(b);
|
|
1841
1834
|
}
|
|
1842
1835
|
const c = this.shareScopeMap, u = o.options.name;
|
|
1843
1836
|
c[t] || (c[t] = {});
|
|
1844
|
-
const d = c[t], p = (E,
|
|
1837
|
+
const d = c[t], p = (E, b) => {
|
|
1845
1838
|
var _;
|
|
1846
|
-
const { version:
|
|
1839
|
+
const { version: g, eager: v } = b;
|
|
1847
1840
|
d[E] = d[E] || {};
|
|
1848
|
-
const S = d[E], I = S[
|
|
1849
|
-
(!I || I.strategy !== "loaded-first" && !I.loaded && (!v != !
|
|
1841
|
+
const S = d[E], I = S[g], R = !!(I && (I.eager || (_ = I.shareConfig) != null && _.eager));
|
|
1842
|
+
(!I || I.strategy !== "loaded-first" && !I.loaded && (!v != !R ? v : u > I.from)) && (S[g] = b);
|
|
1850
1843
|
}, m = (E) => E && E.init && E.init(c[t], a), y = async (E) => {
|
|
1851
|
-
const { module:
|
|
1844
|
+
const { module: b } = await o.remoteHandler.getRemoteModuleAndOptions({
|
|
1852
1845
|
id: E
|
|
1853
1846
|
});
|
|
1854
|
-
if (
|
|
1847
|
+
if (b.getEntry) {
|
|
1855
1848
|
let _;
|
|
1856
1849
|
try {
|
|
1857
|
-
_ = await
|
|
1858
|
-
} catch (
|
|
1850
|
+
_ = await b.getEntry();
|
|
1851
|
+
} catch (g) {
|
|
1859
1852
|
_ = await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1860
1853
|
id: E,
|
|
1861
|
-
error:
|
|
1854
|
+
error: g,
|
|
1862
1855
|
from: "runtime",
|
|
1863
1856
|
lifecycle: "beforeLoadShare",
|
|
1864
1857
|
origin: o
|
|
1865
1858
|
});
|
|
1866
1859
|
}
|
|
1867
|
-
|
|
1860
|
+
b.inited || (await m(_), b.inited = !0);
|
|
1868
1861
|
}
|
|
1869
1862
|
};
|
|
1870
1863
|
return Object.keys(o.options.shared).forEach((E) => {
|
|
@@ -2170,33 +2163,33 @@ class RemoteHandler {
|
|
|
2170
2163
|
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[p];
|
|
2171
2164
|
d = y.options.id || d;
|
|
2172
2165
|
const E = getGlobalShareScope();
|
|
2173
|
-
let
|
|
2166
|
+
let b = !0;
|
|
2174
2167
|
const _ = [];
|
|
2175
|
-
Object.keys(E).forEach((
|
|
2176
|
-
const v = E[
|
|
2168
|
+
Object.keys(E).forEach((g) => {
|
|
2169
|
+
const v = E[g];
|
|
2177
2170
|
v && Object.keys(v).forEach((S) => {
|
|
2178
2171
|
const I = v[S];
|
|
2179
|
-
I && Object.keys(I).forEach((
|
|
2180
|
-
const A = I[
|
|
2181
|
-
A && Object.keys(A).forEach((
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
b,
|
|
2185
|
-
S,
|
|
2172
|
+
I && Object.keys(I).forEach((R) => {
|
|
2173
|
+
const A = I[R];
|
|
2174
|
+
A && Object.keys(A).forEach((T) => {
|
|
2175
|
+
const $ = A[T];
|
|
2176
|
+
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((N) => N !== i.name), $.useIn.length ? b = !1 : _.push([
|
|
2186
2177
|
g,
|
|
2187
|
-
$
|
|
2188
|
-
])) : _.push([
|
|
2189
|
-
b,
|
|
2190
2178
|
S,
|
|
2179
|
+
R,
|
|
2180
|
+
T
|
|
2181
|
+
])) : _.push([
|
|
2191
2182
|
g,
|
|
2192
|
-
|
|
2183
|
+
S,
|
|
2184
|
+
R,
|
|
2185
|
+
T
|
|
2193
2186
|
]));
|
|
2194
2187
|
});
|
|
2195
2188
|
});
|
|
2196
2189
|
});
|
|
2197
|
-
}),
|
|
2198
|
-
var
|
|
2199
|
-
(
|
|
2190
|
+
}), b && (y.shareScopeMap = {}, delete E[d]), _.forEach(([g, v, S, I]) => {
|
|
2191
|
+
var R, A, T;
|
|
2192
|
+
(T = E[g]) == null || (A = T[v]) == null || (R = A[S]) == null || delete R[I];
|
|
2200
2193
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p, 1);
|
|
2201
2194
|
}
|
|
2202
2195
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, o);
|
|
@@ -2312,7 +2305,7 @@ class FederationHost {
|
|
|
2312
2305
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2313
2306
|
// maybe will change, temporarily for internal use only
|
|
2314
2307
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2315
|
-
}), this.version = "0.
|
|
2308
|
+
}), this.version = "0.14.0", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2316
2309
|
// FIXME: may not be suitable , not open to the public yet
|
|
2317
2310
|
getModuleInfo: new SyncHook(),
|
|
2318
2311
|
createScript: new SyncHook(),
|
|
@@ -2351,9 +2344,9 @@ setGlobalFederationConstructor(FederationHost);
|
|
|
2351
2344
|
function createBridgeComponent(n) {
|
|
2352
2345
|
const t = /* @__PURE__ */ new Map(), r = getInstance();
|
|
2353
2346
|
return () => ({
|
|
2354
|
-
__APP_VERSION__: "0.
|
|
2347
|
+
__APP_VERSION__: "0.14.0",
|
|
2355
2348
|
async render(o) {
|
|
2356
|
-
var E,
|
|
2349
|
+
var E, b, _;
|
|
2357
2350
|
LoggerInstance.debug("createBridgeComponent render Info", o);
|
|
2358
2351
|
const {
|
|
2359
2352
|
moduleName: s,
|
|
@@ -2364,7 +2357,7 @@ function createBridgeComponent(n) {
|
|
|
2364
2357
|
...u
|
|
2365
2358
|
} = o, d = Vue.createApp(n.rootComponent, u);
|
|
2366
2359
|
t.set(l, d);
|
|
2367
|
-
const p = await ((_ = (
|
|
2360
|
+
const p = await ((_ = (b = (E = r == null ? void 0 : r.bridgeHook) == null ? void 0 : E.lifecycle) == null ? void 0 : b.beforeBridgeRender) == null ? void 0 : _.emit(o)), m = p && typeof p == "object" && (p != null && p.extraProps) ? p == null ? void 0 : p.extraProps : {}, y = n.appOptions({
|
|
2368
2361
|
app: d,
|
|
2369
2362
|
basename: a,
|
|
2370
2363
|
memoryRoute: i,
|
|
@@ -2373,14 +2366,14 @@ function createBridgeComponent(n) {
|
|
|
2373
2366
|
...m
|
|
2374
2367
|
});
|
|
2375
2368
|
if (y != null && y.router) {
|
|
2376
|
-
let
|
|
2377
|
-
o.memoryRoute ?
|
|
2369
|
+
let g, v = y.router.getRoutes();
|
|
2370
|
+
o.memoryRoute ? g = VueRouter.createMemoryHistory(o.basename) : o.hashRoute ? (g = VueRouter.createWebHashHistory(), v = v.map((I) => ({
|
|
2378
2371
|
...I,
|
|
2379
2372
|
path: o.basename + I.path
|
|
2380
|
-
}))) :
|
|
2373
|
+
}))) : g = VueRouter.createWebHistory(o.basename);
|
|
2381
2374
|
const S = VueRouter.createRouter({
|
|
2382
2375
|
...y.router.options,
|
|
2383
|
-
history:
|
|
2376
|
+
history: g,
|
|
2384
2377
|
routes: v
|
|
2385
2378
|
});
|
|
2386
2379
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
@@ -2414,7 +2407,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2414
2407
|
inheritAttrs: !1,
|
|
2415
2408
|
setup(n) {
|
|
2416
2409
|
const t = ref(null), r = ref(null), o = ref(""), s = useRoute(), l = getInstance(), a = useAttrs(), i = async () => {
|
|
2417
|
-
var m, y, E,
|
|
2410
|
+
var m, y, E, b;
|
|
2418
2411
|
const u = (m = n.providerInfo) == null ? void 0 : m.call(n);
|
|
2419
2412
|
r.value = u;
|
|
2420
2413
|
let d = {
|
|
@@ -2426,7 +2419,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2426
2419
|
hashRoute: n.hashRoute
|
|
2427
2420
|
};
|
|
2428
2421
|
LoggerInstance.debug("createRemoteComponent LazyComponent render >>>", d);
|
|
2429
|
-
const p = await ((
|
|
2422
|
+
const p = await ((b = (E = (y = l == null ? void 0 : l.bridgeHook) == null ? void 0 : y.lifecycle) == null ? void 0 : E.beforeBridgeRender) == null ? void 0 : b.emit(d)) || {};
|
|
2430
2423
|
d = {
|
|
2431
2424
|
...d,
|
|
2432
2425
|
...p.extraProps
|
|
@@ -2453,7 +2446,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2453
2446
|
});
|
|
2454
2447
|
function createRemoteComponent(n) {
|
|
2455
2448
|
return defineAsyncComponent({
|
|
2456
|
-
__APP_VERSION__: "0.
|
|
2449
|
+
__APP_VERSION__: "0.14.0",
|
|
2457
2450
|
...n.asyncComponentOptions,
|
|
2458
2451
|
//@ts-ignore
|
|
2459
2452
|
loader: async () => {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "https://github.com/module-federation/core",
|
|
8
8
|
"directory": "packages/vue3-bridge"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.0.0-next-
|
|
10
|
+
"version": "0.0.0-next-20250527065931",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"vue-router": "=4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@module-federation/bridge-shared": "0.0.0-next-
|
|
36
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
37
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
35
|
+
"@module-federation/bridge-shared": "0.0.0-next-20250527065931",
|
|
36
|
+
"@module-federation/sdk": "0.0.0-next-20250527065931",
|
|
37
|
+
"@module-federation/runtime": "0.0.0-next-20250527065931"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@vitejs/plugin-vue": "^5.0.4",
|