@module-federation/bridge-vue3 0.0.0-next-20250429062839 → 0.0.0-next-20250515032632
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 +6 -4
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +205 -190
- package/package.json +4 -4
- package/src/provider.ts +26 -6
- package/src/remoteApp.tsx +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# @module-federation/bridge-vue3
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20250515032632
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- @module-federation/bridge-shared@0.0.0-next-
|
|
7
|
+
- 677aac9: vue.js has router option added to the vue3-bridge
|
|
8
|
+
- Updated dependencies [677aac9]
|
|
9
|
+
- @module-federation/bridge-shared@0.0.0-next-20250515032632
|
|
10
|
+
- @module-federation/runtime@0.0.0-next-20250515032632
|
|
11
|
+
- @module-federation/sdk@0.0.0-next-20250515032632
|
|
10
12
|
|
|
11
13
|
## 0.13.1
|
|
12
14
|
|
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 o in n)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>n[o]})}}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 o=1;o<arguments.length;o++){var r=arguments[o];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},_extends$2.apply(this,arguments)}const MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",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,o)=>o?t?`${t}${SEPARATOR}${o}`:o:t,""):""},getResourceUrl=(n,t)=>{if("getPublicPath"in n){let o;return n.getPublicPath.startsWith("function")?o=new Function("return "+n.getPublicPath)()():o=new Function(n.getPublicPath)(),`${o}${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 r=(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 r?r.endsWith("/")?`${r}${t}`:`${r}/${t}`:t};function inferAutoPublicPath(n){return n.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(n,t={}){var o,r;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
|
|
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 o in n)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>n[o]})}}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 o=1;o<arguments.length;o++){var r=arguments[o];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},_extends$2.apply(this,arguments)}const MANIFEST_EXT=".json",BROWSER_LOG_KEY="FEDERATION_DEBUG",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,o)=>o?t?`${t}${SEPARATOR}${o}`:o:t,""):""},getResourceUrl=(n,t)=>{if("getPublicPath"in n){let o;return n.getPublicPath.startsWith("function")?o=new Function("return "+n.getPublicPath)()():o=new Function(n.getPublicPath)(),`${o}${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 r=(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 r?r.endsWith("/")?`${r}${t}`:`${r}/${t}`:t};function inferAutoPublicPath(n){return n.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function generateSnapshotFromManifest(n,t={}){var o,r;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 A;const $=v.federationContainerName;return u.includes($)?A=l[$]:"version"in v?A=v.version:A=v.entry,b[$]={matchedVersion:A},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((o=n.metaData)!=null&&o.prefetchInterface){const b=n.metaData.prefetchInterface;S=_extends$2({},S,{prefetchInterface:b})}if((r=n.metaData)!=null&&r.prefetchEntry){const{path:b,name:v,type:A}=n.metaData.prefetchEntry;S=_extends$2({},S,{prefetchEntry:simpleJoinRemoteEntry(b,v),prefetchEntryType:A})}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(o){warn$1(o);return}}function isStaticResourcesEqual(n,t){const o=/^(https?:)?\/\//i,r=n.replace(o,"").replace(/\/$/,""),s=t.replace(o,"").replace(/\/$/,"");return r===s}function createScript(n){let t=null,o=!0,r=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,o=!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&&(r=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.`))},r),{script:t,needAttach:o}}function createLink(n){let t=null,o=!0;const r=document.getElementsByTagName("link");for(let l=0;l<r.length;l++){const a=r[l],i=a.getAttribute("href"),c=a.getAttribute("rel");if(i&&isStaticResourcesEqual(i,n.url)&&c===n.attrs.rel){t=a,o=!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:o}}function loadScript(n,t){const{attrs:o={},createScriptHook:r}=t;return new Promise((s,l)=>{const{script:a,needAttach:i}=createScript({url:n,cb:s,onErrorCallback:l,attrs:_extends$2({fetchpriority:"high"},o),createScriptHook:r,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(o=>o).catch(o=>{throw console.error(`Error importing module ${n}:`,o),o})}const loadNodeFetch=async()=>{const n=await importNodeModule("node-fetch");return n.default||n},lazyLoaderHookFetch=async(n,t,o)=>{const s=await((l,a)=>o.lifecycle.fetch.emit(l,a))(n,t||{});return!s||!(s instanceof Response)?(typeof fetch>"u"?await loadNodeFetch():fetch)(n,t||{}):s};function createScriptNode(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)})}function loadScriptNode(n,t){return new Promise((o,r)=>{createScriptNode(n,(s,l)=>{if(s)r(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;o(u)}},t.attrs,t.loaderHook)})}async function loadModule(n,t){const{fetch:o,vm:r}=t,l=await(await o(n)).text(),a=new r.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 o=1;o<arguments.length;o++){var r=arguments[o];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},_extends$1.apply(this,arguments)}function _object_without_properties_loose(n,t){if(n==null)return{};var o={},r=Object.keys(n),s,l;for(l=0;l<r.length;l++)s=r[l],!(t.indexOf(s)>=0)&&(o[s]=n[s]);return o}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,o,r)=>{const s=[`${[t[n]]} #${n}`];return o&&s.push(`args: ${JSON.stringify(o)}`),s.push(getDocsUrl(n)),r&&s.push(`Original Error Message:
|
|
3
3
|
${r}`),s.join(`
|
|
4
|
-
`)};function _extends(){return _extends=Object.assign||function(t){for(var o=1;o<arguments.length;o++){var r=arguments[o];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},_extends.apply(this,arguments)}const runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot.",[RUNTIME_008]:"Failed to load script resources."},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(o=>o===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")&&n.entry.includes(".js")}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 o;return n.endsWith("/")?o=n.slice(0,-1):o=n,t.startsWith(".")&&(t=t.slice(1)),o=o+t,o},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(n,t,o){Object.defineProperty(n,t,{value:o,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,o,r,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=(o=n.__FEDERATION__).__INSTANCES__)!=null||(o.__INSTANCES__=[]);var u;(u=(r=n.__FEDERATION__).moduleInfo)!=null||(r.moduleInfo={});var d;(d=(s=n.__FEDERATION__).__SHARE__)!=null||(s.__SHARE__={});var p;(p=(l=n.__FEDERATION__).__MANIFEST_LOADING__)!=null||(l.__MANIFEST_LOADING__={});var h;(h=(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 r=Object.keys(n);for(const s of r){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 o=getFMId(n),r=getInfoWithoutType(t,o).value;if(r&&!r.version&&"version"in n&&n.version&&(r.version=n.version),r)return r;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 o=getFMId(n);return nativeGlobal.__FEDERATION__.moduleInfo[o]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=n=>(nativeGlobal.__FEDERATION__.moduleInfo=_extends$1({},nativeGlobal.__FEDERATION__.moduleInfo,n),()=>{const t=Object.keys(n);for(const o of t)delete nativeGlobal.__FEDERATION__.moduleInfo[o]}),getRemoteEntryExports=(n,t)=>{const o=t||`__FEDERATION_${n}:custom__`,r=CurrentGlobal[o];return{remoteEntryKey:o,entryExports:r}},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((o,r)=>r(o),t)}function extractComparator(n){return n.match(parseRegex(comparator))}function combineVersion(n,t,o,r){const s=`${n}.${t}.${o}`;return r?`${s}-${r}`:s}function parseHyphen(n){return n.replace(parseRegex(hyphenRange),(t,o,r,s,l,a,i,c,u,d,p,h)=>(isXVersion(r)?o="":isXVersion(s)?o=`>=${r}.0.0`:isXVersion(l)?o=`>=${r}.${s}.0`:o=`>=${o}`,isXVersion(u)?c="":isXVersion(d)?c=`<${Number(u)+1}.0.0-0`:isXVersion(p)?c=`<${u}.${Number(d)+1}.0-0`:h?c=`<=${u}.${d}.${p}-${h}`:c=`<=${c}`,`${o} ${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),(o,r,s,l,a)=>isXVersion(r)?"":isXVersion(s)?`>=${r}.0.0 <${Number(r)+1}.0.0-0`:isXVersion(l)?r==="0"?`>=${r}.${s}.0 <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.0 <${Number(r)+1}.0.0-0`:a?r==="0"?s==="0"?`>=${r}.${s}.${l}-${a} <${r}.${s}.${Number(l)+1}-0`:`>=${r}.${s}.${l}-${a} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${l}-${a} <${Number(r)+1}.0.0-0`:r==="0"?s==="0"?`>=${r}.${s}.${l} <${r}.${s}.${Number(l)+1}-0`:`>=${r}.${s}.${l} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${l} <${Number(r)+1}.0.0-0`)).join(" ")}function parseTildes(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(o,r,s,l,a)=>isXVersion(r)?"":isXVersion(s)?`>=${r}.0.0 <${Number(r)+1}.0.0-0`:isXVersion(l)?`>=${r}.${s}.0 <${r}.${Number(s)+1}.0-0`:a?`>=${r}.${s}.${l}-${a} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${l} <${r}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(n){return n.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(o,r,s,l,a,i)=>{const c=isXVersion(s),u=c||isXVersion(l),d=u||isXVersion(a);return r==="="&&d&&(r=""),i="",c?r===">"||r==="<"?"<0.0.0-0":"*":r&&d?(u&&(l=0),a=0,r===">"?(r=">=",u?(s=Number(s)+1,l=0,a=0):(l=Number(l)+1,a=0)):r==="<="&&(r="<",u?s=Number(s)+1:l=Number(l)+1),r==="<"&&(i="-0"),`${r+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`:o})).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:o}=n,{preRelease:r}=t;if(o===void 0&&r)return 1;if(o&&r===void 0)return-1;if(o===void 0&&r===void 0)return 0;for(let s=0,l=o.length;s<=l;s++){const a=o[s],i=r[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(h=>parseComparatorString(h)).join(" ").split(/\s+/).map(h=>parseGTE0(h)),l=extractComparator(n);if(!l)return!1;const[,a,,i,c,u,d]=l,p={version:combineVersion(i,c,u,d),major:i,minor:c,patch:u,preRelease:d==null?void 0:d.split(".")};for(const h of s){const m=extractComparator(h);if(!m)return!1;const[,_,,g,y,E,I]=m,S={operator:_,version:combineVersion(g,y,E,I),major:g,minor:y,patch:E,preRelease:I==null?void 0:I.split(".")};if(!compare(S,p))return!1}return!0}function formatShare(n,t,o,r){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 '${o}'!`)});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:r)||"version-first"})}function formatShareConfigs(n,t){const o=t.shared||{},r=t.name,s=Object.keys(o).reduce((a,i)=>{const c=arrayOptions(o[i]);return a[i]=a[i]||[],c.forEach(u=>{a[i].push(formatShare(u,r,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 o=r=>{if(!Number.isNaN(Number(r))){const l=r.split(".");let a=r;for(let i=0;i<3-l.length;i++)a+=".0";return a}return r};return!!satisfy(o(n),`<=${o(t)}`)}const findVersion=(n,t)=>{const o=t||function(r,s){return versionLt(r,s)};return Object.keys(n).reduce((r,s)=>!r||o(r,s)||r==="0"?s:r,0)},isLoaded=n=>!!n.loaded||typeof n.lib=="function",isLoading=n=>!!n.loading;function findSingletonVersionOrderByVersion(n,t,o){const r=n[t][o],s=function(l,a){return!isLoaded(r[l])&&versionLt(l,a)};return findVersion(n[t][o],s)}function findSingletonVersionOrderByLoaded(n,t,o){const r=n[t][o],s=function(l,a){const i=c=>isLoaded(c)||isLoading(c);return i(r[a])?i(r[l])?!!versionLt(l,a):!0:i(r[l])?!1:versionLt(l,a)};return findVersion(n[t][o],s)}function getFindShareFunction(n){return n==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(n,t,o,r){if(!n)return;const{shareConfig:s,scope:l=DEFAULT_SCOPE,strategy:a}=o,i=Array.isArray(l)?l:[l];for(const c of i)if(s&&n[c]&&n[c][t]){const{requiredVersion:u}=s,p=getFindShareFunction(a)(n,c,t),h=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(p,u)){const g=`Version ${p} from ${p&&n[c][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;s.strictVersion?error(g):warn(g)}return n[c][t][p]}else{if(u===!1||u==="*"||satisfy(p,u))return n[c][t][p];for(const[g,y]of Object.entries(n[c][t]))if(satisfy(g,u))return y}},m={shareScopeMap:n,scope:c,pkgName:t,version:p,GlobalFederation:Global.__FEDERATION__,resolver:h};return(r.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(n){const{pkgName:t,extraOptions:o,shareInfos:r}=n,s=i=>{if(!i)return;const c={};i.forEach(p=>{c[p.version]=p});const d=findVersion(c,function(p,h){return!isLoaded(c[p])&&versionLt(p,h)});return c[d]};var l;const a=(l=o==null?void 0:o.resolver)!=null?l:s;return Object.assign({},a(r[t]),o==null?void 0:o.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(n,t){for(const o of n){const r=t.startsWith(o.name);let s=t.replace(o.name,"");if(r){if(s.startsWith("/")){const i=o.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:o}}else if(s==="")return{pkgNameOrAlias:o.name,expose:".",remote:o}}const l=o.alias&&t.startsWith(o.alias);let a=o.alias&&t.replace(o.alias,"");if(o.alias&&l){if(a&&a.startsWith("/")){const i=o.alias;return a=`.${a}`,{pkgNameOrAlias:i,expose:a,remote:o}}else if(a==="")return{pkgNameOrAlias:o.alias,expose:".",remote:o}}}}function matchRemote(n,t){for(const o of n)if(t===o.name||o.alias&&t===o.alias)return o}function registerPlugins(n,t){const o=getGlobalHostPlugins();return o.length>0&&o.forEach(r=>{n!=null&&n.find(s=>s.name!==r.name)&&n.push(r)}),n&&n.length>0&&n.forEach(r=>{t.forEach(s=>{s.applyPlugin(r)})}),n}async function loadEsmEntry({entry:n,remoteEntryExports:t}){return new Promise((o,r)=>{try{t?o(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${n}").then(callbacks[0]).catch(callbacks[1])`)([o,r]):import(n).then(o).catch(r)}catch(s){r(s)}})}async function loadSystemJsEntry({entry:n,remoteEntryExports:t}){return new Promise((o,r)=>{try{t?o(t):typeof __system_context__>"u"?System.import(n).then(o).catch(r):new Function("callbacks",`System.import("${n}").then(callbacks[0]).catch(callbacks[1])`)([o,r])}catch(s){r(s)}})}async function loadEntryScript({name:n,globalName:t,entry:o,loaderHook:r}){const{entryExports:s}=getRemoteEntryExports(n,t);return s||loadScript(o,{attrs:{},createScriptHook:(l,a)=>{const i=r.lifecycle.createScript.emit({url:l,attrs:a});if(i&&(i instanceof HTMLScriptElement||"script"in i||"timeout"in i))return i}}).then(()=>{const{remoteEntryKey:l,entryExports:a}=getRemoteEntryExports(n,t);return assert(a,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:n,remoteEntryUrl:o,remoteEntryKey:l})),a}).catch(l=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:n,resourceUrl:o})),l})}async function loadEntryDom({remoteInfo:n,remoteEntryExports:t,loaderHook:o}){const{entry:r,entryGlobalName:s,name:l,type:a}=n;switch(a){case"esm":case"module":return loadEsmEntry({entry:r,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:r,remoteEntryExports:t});default:return loadEntryScript({entry:r,globalName:s,name:l,loaderHook:o})}}async function loadEntryNode({remoteInfo:n,loaderHook:t}){const{entry:o,entryGlobalName:r,name:s,type:l}=n,{entryExports:a}=getRemoteEntryExports(s,r);return a||loadScriptNode(o,{attrs:{name:s,globalName:r,type:l},loaderHook:{createScriptHook:(i,c={})=>{const u=t.lifecycle.createScript.emit({url:i,attrs:c});if(u&&"url"in u)return u}}}).then(()=>{const{remoteEntryKey:i,entryExports:c}=getRemoteEntryExports(s,r);return assert(c,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:s,remoteEntryUrl:o,remoteEntryKey:i})),c}).catch(i=>{throw i})}function getRemoteEntryUniqueKey(n){const{entry:t,name:o}=n;return composeKeyWithSeparator(o,t)}async function getRemoteEntry({origin:n,remoteEntryExports:t,remoteInfo:o}){const r=getRemoteEntryUniqueKey(o);if(t)return t;if(!globalLoading[r]){const s=n.remoteHandler.hooks.lifecycle.loadEntry,l=n.loaderHook;globalLoading[r]=s.emit({loaderHook:l,remoteInfo:o,remoteEntryExports:t}).then(a=>a||(isBrowserEnv()?loadEntryDom({remoteInfo:o,remoteEntryExports:t,loaderHook:l}):loadEntryNode({remoteInfo:o,loaderHook:l})))}return globalLoading[r]}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 r=getRemoteEntryUniqueKey(this.remoteInfo);t=await this.host.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry,origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports,globalLoading,uniqueKey:r})}return assert(t,`remoteEntryExports is undefined
|
|
5
|
-
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,o,r,s){const{loadFactory:l=!0}=r||{loadFactory:!0},a=await this.getEntry();if(!this.inited){const p=this.host.shareScopeMap,h=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];h.length||h.push("default"),h.forEach(E=>{p[E]||(p[E]={})});const m=p[h[0]],_=[],g={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?h:this.remoteInfo.shareScope||"default"};Object.defineProperty(g,"shareScopeMap",{value:p,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:g,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:o,moduleInfo:this.remoteInfo}),i||(i=await a.get(o)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${o}.`);const c=processModuleAlias(this.remoteInfo.name,o),u=this.wraperFactory(i,c);return l?await u():u}wraperFactory(t,o){function r(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 r(s,o),s}:()=>{const s=t();return r(s,o),s}}constructor({remoteInfo:t,host:o}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=o}};class SyncHook{on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const o=this;this.on(function r(...s){return o.remove(r),t.apply(null,s)})}emit(...t){let o;return this.listeners.size>0&&this.listeners.forEach(r=>{o=r(...t)}),o}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 o;const r=Array.from(this.listeners);if(r.length>0){let s=0;const l=a=>a===!1?!1:s<r.length?Promise.resolve(r[s++].apply(null,t)).then(l):a;o=l()}return Promise.resolve(o)}}function checkReturnData(n,t){if(!isObject(t))return!1;if(n!==t){for(const o in n)if(!(o 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 o of this.listeners)try{const r=o(t);if(checkReturnData(t,r))t=r;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(r){warn(r),this.onerror(r)}return t}constructor(t){super(),this.onerror=error,this.type=t}}class AsyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const o=Array.from(this.listeners);if(o.length>0){let r=0;const s=a=>(warn(a),this.onerror(a),t),l=a=>{if(checkReturnData(t,a)){if(t=a,r<o.length)try{return Promise.resolve(o[r++](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 o=t.name;assert(o,"A name must be provided by the plugin."),this.registerPlugins[o]||(this.registerPlugins[o]=t,Object.keys(this.lifecycle).forEach(r=>{const s=t[r];s&&this.lifecycle[r].on(s)}))}removePlugin(t){assert(t,"A name is required.");const o=this.registerPlugins[t];assert(o,`The plugin "${t}" is not registered.`),Object.keys(o).forEach(r=>{r!=="name"&&this.lifecycle[r].remove(o[r])})}inherit({lifecycle:t,registerPlugins:o}){Object.keys(t).forEach(r=>{assert(!this.lifecycle[r],`The hook "${r}" has a conflict and cannot be inherited.`),this.lifecycle[r]=t[r]}),Object.keys(o).forEach(r=>{assert(!this.registerPlugins[r],`The plugin "${r}" has a conflict and cannot be inherited.`),this.applyPlugin(o[r])})}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(o=>{const r=matchRemote(n,o.nameOrAlias);return assert(r,`Unable to preload ${o.nameOrAlias} as it is not included in ${!r&&safeToString({remoteInfo:r,remotes:n})}`),{remote:r,preloadConfig:defaultPreloadArgs(o)}})}function normalizePreloadExposes(n){return n?n.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(n,t,o,r=!0){const{cssAssets:s,jsAssetsWithoutEntry:l,entryAssets:a}=o;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})}),r){const i={rel:"preload",as:"style"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(p,h)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:h});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:(p,h)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:h});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});d&&document.head.appendChild(u)})}if(r){const i={rel:"preload",as:"script"};l.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(p,h)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:h});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:(p,h)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:p,attrs:h});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});d&&document.head.appendChild(u)})}}}function assignRemoteInfo(n,t){const o=getRemoteEntryInfoFromSnapshot(t);o.url||error(`The attribute remoteEntry of ${n.name} must not be undefined.`);let r=getResourceUrl(t,o.url);!isBrowserEnv()&&!r.startsWith("http")&&(r=`https:${r}`),n.type=o.type,n.entryGlobalName=o.globalName,n.entry=r,n.version=t.version,n.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(n){const{remote:t,pkgNameOrAlias:o,expose:r,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:o,exposes:[r],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,o,r,s={},l){const a=getFMId(t),{value:i}=getInfoWithoutType(n,a),c=l||i;if(c&&!isManifestProvider(c)&&(o(c,t,r),c.remotesInfo)){const u=Object.keys(c.remotesInfo);for(const d of u){if(s[d])continue;s[d]=!0;const p=splitId(d),h=c.remotesInfo[d];traverseModuleInfo(n,{name:p.name,version:h.matchedVersion},o,!1,s,void 0)}}}const isExisted=(n,t)=>document.querySelector(`${n}[${n==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(n,t,o,r,s){const l=[],a=[],i=[],c=new Set,u=new Set,{options:d}=n,{preloadConfig:p}=t,{depsRemote:h}=p;if(traverseModuleInfo(r,o,(y,E,I)=>{let S;if(I)S=p;else if(Array.isArray(h)){const O=h.find(T=>T.nameOrAlias===E.name||T.nameOrAlias===E.alias);if(!O)return;S=defaultPreloadArgs(O)}else if(h===!0)S=p;else return;const R=getResourceUrl(y,getRemoteEntryInfoFromSnapshot(y).url);R&&i.push({name:E.name,moduleInfo:{name:E.name,entry:R,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:R});let b="modules"in y?y.modules:[];const v=normalizePreloadExposes(S.exposes);if(v.length&&"modules"in y){var A;b=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(w=>getResourceUrl(y,w));return S.filter?T.filter(S.filter):T}if(b){const O=b.length;for(let T=0;T<O;T++){const w=b[T],N=`${E.name}/${w.moduleName}`;n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:w.moduleName==="."?E.name:N,name:E.name,remoteSnapshot:y,preloadConfig:S,remote:E,origin:n}),!getPreloaded(N)&&(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(N))}}},!0,{},s),s.shared){const y=(E,I)=>{const S=getRegisteredShare(n.shareScopeMap,I.sharedName,E,n.sharedHandler.hooks.lifecycle.resolveShare);S&&typeof S.lib=="function"&&(I.assets.js.sync.forEach(R=>{c.add(R)}),I.assets.css.sync.forEach(R=>{u.add(R)}))};s.shared.forEach(E=>{var I;const S=(I=d.shared)==null?void 0:I[E.sharedName];if(!S)return;const R=E.version?S.find(v=>v.version===E.version):S;if(!R)return;arrayOptions(R).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:o,remoteInfo:r,remote:s,globalSnapshot:l,remoteSnapshot:a}=n;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:r.name,entry:s.entry,type:r.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(r,a),generatePreloadAssets(t,o,r,l,a)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(n,t){const o=getGlobalSnapshotInfoByModuleInfo({name:t.options.name,version:t.options.version}),r=o&&"remotesInfo"in o&&o.remotesInfo&&getInfoWithoutType(o.remotesInfo,n.name).value;return r&&r.matchedVersion?{hostGlobalSnapshot:o,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:n.name,version:r.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:o}=this.HostInstance,{hostGlobalSnapshot:r,remoteSnapshot:s,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:a,globalSnapshot:i}=await this.hooks.lifecycle.loadSnapshot.emit({options:o,moduleInfo:t,hostGlobalSnapshot:r,remoteSnapshot:s,globalSnapshot:l});return{remoteSnapshot:a,globalSnapshot:i}}async loadRemoteSnapshotInfo(t){const{options:o}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:o,moduleInfo:t});let r=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});r||(r={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:r})),r&&"remotesInfo"in r&&!getInfoWithoutType(r.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(r.remotesInfo=_extends$1({},r==null?void 0:r.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:o,moduleInfo:t,hostGlobalSnapshot:s,remoteSnapshot:l,globalSnapshot:a});let u,d;if(i)if(isManifestProvider(i)){const p=isBrowserEnv()?i.remoteEntry:i.ssrRemoteEntry||i.remoteEntry||"",h=await this.getManifestJson(p,t,{}),m=setGlobalSnapshotInfoByModuleInfo(_extends$1({},t,{entry:p}),h);u=h,d=m}else{const{remoteSnapshot:p}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:i,from:"global"});u=p,d=c}else if(isRemoteInfoWithEntry(t)){const p=await this.getManifestJson(t.entry,t,{}),h=setGlobalSnapshotInfoByModuleInfo(t,p),{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:p,from:"global"});u=m,d=h}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(c)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({options:o,moduleInfo:t,remoteSnapshot:u}),{remoteSnapshot:u,globalSnapshot:d}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,o,r){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:o.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:o,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,o){const{shareInfos:r,shared:s}=formatShareConfigs(t,o);return Object.keys(r).forEach(a=>{r[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:o.name})})}),{shareInfos:r,shared:s}}async loadShare(t,o){const{host:r}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:r.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const l=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:r.options.shared,origin:r}),{shareInfo:a}=l;assert(a,`Cannot find ${t} Share in the ${r.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare),c=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,r.options.name)};if(i&&i.lib)return c(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),c(i),u}else if(i){const d=(async()=>{const p=await i.get();a.lib=p,a.loaded=!0,c(a);const h=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare);return h&&(h.lib=p,h.loaded=!0),p})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:r.options.name,lib:null,loading:d}),d}else{if(o!=null&&o.customShareInfo)return!1;const d=(async()=>{const p=await a.get();a.lib=p,a.loaded=!0,c(a);const h=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare);return h&&(h.lib=p,h.loaded=!0),p})();return this.setShared({pkgName:t,loaded:!1,shared:a,from:r.options.name,lib:null,loading:d}),d}}initializeSharing(t=DEFAULT_SCOPE,o){const{host:r}=this,s=o==null?void 0:o.from,l=o==null?void 0:o.strategy;let a=o==null?void 0:o.initScope;const i=[];if(s!=="build"){const{initTokens:_}=this;a||(a=[]);let g=_[t];if(g||(g=_[t]={from:this.host.name}),a.indexOf(g)>=0)return i;a.push(g)}const c=this.shareScopeMap,u=r.options.name;c[t]||(c[t]={});const d=c[t],p=(_,g)=>{var y;const{version:E,eager:I}=g;d[_]=d[_]||{};const S=d[_],R=S[E],b=!!(R&&(R.eager||(y=R.shareConfig)!=null&&y.eager));(!R||R.strategy!=="loaded-first"&&!R.loaded&&(!I!=!b?I:u>R.from))&&(S[E]=g)},h=_=>_&&_.init&&_.init(c[t],a),m=async _=>{const{module:g}=await r.remoteHandler.getRemoteModuleAndOptions({id:_});if(g.getEntry){let y;try{y=await g.getEntry()}catch(E){y=await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:_,error:E,from:"runtime",lifecycle:"beforeLoadShare",origin:r})}g.inited||(await h(y),g.inited=!0)}};return Object.keys(r.options.shared).forEach(_=>{r.options.shared[_].forEach(y=>{y.scope.includes(t)&&p(_,y)})}),(r.options.shareStrategy==="version-first"||l==="version-first")&&r.options.remotes.forEach(_=>{_.shareScope===t&&i.push(m(_.name))}),i}loadShareSync(t,o){const{host:r}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:r.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,r.options.name)};if(l){if(typeof l.lib=="function")return a(l),l.loaded||(l.loaded=!0,l.from===r.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:r.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=(o==null?void 0:o.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(c,runtimeDescMap,{hostName:r.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:r.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:r.options.name,sharedPkgName:t}))}initShareScopeMap(t,o,r={}){const{host:s}=this;this.shareScopeMap[t]=o,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:o,options:s.options,origin:s,scopeName:t,hostShareScopeMap:r.hostShareScopeMap})}setShared({pkgName:t,shared:o,from:r,lib:s,loading:l,loaded:a,get:i}){const{version:c,scope:u="default"}=o,d=_object_without_properties_loose(o,["version","scope"]);(Array.isArray(u)?u:[u]).forEach(h=>{if(this.shareScopeMap[h]||(this.shareScopeMap[h]={}),this.shareScopeMap[h][t]||(this.shareScopeMap[h][t]={}),!this.shareScopeMap[h][t][c]){this.shareScopeMap[h][t][c]=_extends$1({version:c,scope:["default"]},d,{lib:s,loaded:a,loading:l}),i&&(this.shareScopeMap[h][t][c].get=i);return}const m=this.shareScopeMap[h][t][c];l&&!m.loading&&(m.loading=l)})}_setGlobalShareScopeMap(t){const o=getGlobalShareScope(),r=t.id||t.name;r&&!o[r]&&(o[r]=this.shareScopeMap)}constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}}class RemoteHandler{formatAndRegisterRemote(t,o){return(o.remotes||[]).reduce((s,l)=>(this.registerRemote(l,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,o){const{remote:r,expose:s}=o,{name:l,alias:a}=r;if(this.idToRemoteMap[t]={name:r.name,expose:s},a&&t.startsWith(l)){const i=t.replace(l,a);this.idToRemoteMap[i]={name:r.name,expose:s};return}if(a&&t.startsWith(a)){const i=t.replace(a,l);this.idToRemoteMap[i]={name:r.name,expose:s}}}async loadRemote(t,o){const{host:r}=this;try{const{loadFactory:s=!0}=o||{loadFactory:!0},{module:l,moduleOptions:a,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:c,remote:u,expose:d,id:p,remoteSnapshot:h}=i,m=await l.get(p,d,o,h),_=await this.hooks.lifecycle.onLoad.emit({id:p,pkgNameOrAlias:c,expose:d,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:a,moduleInstance:l,origin:r});return this.setIdToRemoteMap(t,i),typeof _=="function"?_:m}catch(s){const{from:l="runtime"}=o||{from:"runtime"},a=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:l,lifecycle:"onLoad",origin:r});if(!a)throw s;return a}}async preloadRemote(t){const{host:o}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:o.options,origin:o});const r=formatPreloadArgs(o.options.remotes,t);await Promise.all(r.map(async s=>{const{remote:l}=s,a=getRemoteInfo(l),{globalSnapshot:i,remoteSnapshot:c}=await o.snapshotHandler.loadRemoteSnapshotInfo(l),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:s,remote:l,remoteInfo:a,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(a,o,u)}))}registerRemotes(t,o){const{host:r}=this;t.forEach(s=>{this.registerRemote(s,r.options.remotes,{force:o==null?void 0:o.force})})}async getRemoteModuleAndOptions(t){const{host:o}=this,{id:r}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:r,options:o.options,origin:o})}catch(_){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:r,options:o.options,origin:o,from:"runtime",error:_,lifecycle:"beforeRequest"}),!s)throw _}const{id:l}=s,a=matchRemoteWithNameAndExpose(o.options.remotes,l);assert(a,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:o.options.name,requestId:l}));const{remote:i}=a,c=getRemoteInfo(i),u=await o.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:l},a,{options:o.options,origin:o,remoteInfo:c})),{remote:d,expose:p}=u;assert(d&&p,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);let h=o.moduleCache.get(d.name);const m={host:o,remoteInfo:c};return h||(h=new Module(m),o.moduleCache.set(d.name,h)),{module:h,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,o,r){const{host:s}=this,l=()=>{if(t.alias){const i=o.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=o.find(i=>i.name===t.name);if(!a)l(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];r!=null&&r.force&&(this.removeRemote(a),l(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){try{const{host:r}=this,{name:s}=t,l=r.options.remotes.findIndex(i=>i.name===s);l!==-1&&r.options.remotes.splice(l,1);const a=r.moduleCache.get(t.name);if(a){const i=a.remoteInfo,c=i.entryGlobalName;if(CurrentGlobal[c]){var o;(o=Object.getOwnPropertyDescriptor(CurrentGlobal,c))!=null&&o.configurable?delete CurrentGlobal[c]:CurrentGlobal[c]=void 0}const u=getRemoteEntryUniqueKey(a.remoteInfo);globalLoading[u]&&delete globalLoading[u],r.snapshotHandler.manifestCache.delete(i.entry);let d=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const p=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===d:m.name===d);if(p!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[p];d=m.options.id||d;const _=getGlobalShareScope();let g=!0;const y=[];Object.keys(_).forEach(E=>{const I=_[E];I&&Object.keys(I).forEach(S=>{const R=I[S];R&&Object.keys(R).forEach(b=>{const v=R[b];v&&Object.keys(v).forEach(A=>{const $=v[A];$&&typeof $=="object"&&$.from===i.name&&($.loaded||$.loading?($.useIn=$.useIn.filter(O=>O!==i.name),$.useIn.length?g=!1:y.push([E,S,b,A])):y.push([E,S,b,A]))})})})}),g&&(m.shareScopeMap={},delete _[d]),y.forEach(([E,I,S,R])=>{var b,v,A;(A=_[E])==null||(v=A[I])==null||(b=v[S])==null||delete b[R]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p,1)}const{hostGlobalSnapshot:h}=getGlobalRemoteInfo(t,r);if(h){const m=h&&"remotesInfo"in h&&h.remotesInfo&&getInfoWithoutType(h.remotesInfo,t.name).key;m&&(delete h.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}r.moduleCache.delete(t.name)}}catch(r){logger.log("removeRemote fail: ",r)}}constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}}class FederationHost{initOptions(t){this.registerPlugins(t.plugins);const o=this.formatOptions(this.options,t);return this.options=o,o}async loadShare(t,o){return this.sharedHandler.loadShare(t,o)}loadShareSync(t,o){return this.sharedHandler.loadShareSync(t,o)}initializeSharing(t=DEFAULT_SCOPE,o){return this.sharedHandler.initializeSharing(t,o)}initRawContainer(t,o,r){const s=getRemoteInfo({name:t,entry:o}),l=new Module({host:this,remoteInfo:s});return l.remoteEntryExports=r,this.moduleCache.set(t,l),l}async loadRemote(t,o){return this.remoteHandler.loadRemote(t,o)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,o,r={}){this.sharedHandler.initShareScopeMap(t,o,r)}formatOptions(t,o){const{shared:r}=formatShareConfigs(t,o),{userOptions:s,options:l}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:o,options:t,shareInfo:r}),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,o,{plugins:c,remotes:a,shared:i});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const o=registerPlugins(t,[this.hooks,this.remoteHandler.hooks,this.sharedHandler.hooks,this.snapshotHandler.hooks,this.loaderHook,this.bridgeHook]);this.options.plugins=this.options.plugins.reduce((r,s)=>(s&&r&&!r.find(l=>l.name===s.name)&&r.push(s),r),o||[])}registerRemotes(t,o){return this.remoteHandler.registerRemotes(t,o)}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 o={id:getBuilderId(),name:t.name,plugins:[snapshotPlugin(),generatePreloadAssetsPlugin()],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,o=getInstance();return()=>({__APP_VERSION__:"0.13.1",async render(r){var m,_,g;LoggerInstance.debug("createBridgeComponent render Info",r);const{moduleName:s,dom:l,basename:a,memoryRoute:i,...c}=r,u=Vue__namespace.createApp(n.rootComponent,c);t.set(l,u);const d=await((g=(_=(m=o==null?void 0:o.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:_.beforeBridgeRender)==null?void 0:g.emit(r)),p=d&&typeof d=="object"&&(d!=null&&d.extraProps)?d==null?void 0:d.extraProps:{},h=n.appOptions({app:u,basename:a,memoryRoute:i,...c,...p});if(h!=null&&h.router){const y=r.memoryRoute?VueRouter__namespace.createMemoryHistory(r.basename):VueRouter__namespace.createWebHistory(r.basename),E=VueRouter__namespace.createRouter({...h.router.options,history:y,routes:h.router.getRoutes()});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:E}),i&&await E.push(i.entryPath),u.use(E)}u.mount(l)},destroy(r){LoggerInstance.debug("createBridgeComponent destroy Info",r);const s=t.get(r==null?void 0:r.dom);s==null||s.unmount()}})}function e(){const n=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(n)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(n){const t=Vue.ref(null),o=Vue.ref(null),r=Vue.ref(""),s=VueRouter.useRoute(),l=getInstance(),a=Vue.useAttrs(),i=async()=>{var h,m,_,g;const u=(h=n.providerInfo)==null?void 0:h.call(n);o.value=u;let d={...a,moduleName:n.moduleName,dom:t.value,basename:n.basename,memoryRoute:n.memoryRoute};LoggerInstance.debug("createRemoteComponent LazyComponent render >>>",d);const p=await((g=(_=(m=l==null?void 0:l.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:_.beforeBridgeRender)==null?void 0:g.emit(d))||{};d={...d,...p.extraProps},u.render(d)},c=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&i(),r.value!==""&&r.value!==u&&(LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>",{...n,pathname:s.path}),e()),r.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>",{...n}),c(),(u=o.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 o="/";const r=(u=(c=t==null?void 0:t.matched)==null?void 0:c[0])==null?void 0:u.path;r&&(r.endsWith("/:pathMatch(.*)*")?o=r.replace("/:pathMatch(.*)*",""):o=t.matched[0].path);const s=(n==null?void 0:n.export)||"default";LoggerInstance.debug("createRemoteComponent LazyComponent create >>>",{basename:o,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:o,route:t}),s in l&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:a,providerInfo:i,basename:o,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 o=1;o<arguments.length;o++){var r=arguments[o];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},_extends.apply(this,arguments)}const runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot.",[RUNTIME_008]:"Failed to load script resources."},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(o=>o===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")&&n.entry.includes(".js")}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 o;return n.endsWith("/")?o=n.slice(0,-1):o=n,t.startsWith(".")&&(t=t.slice(1)),o=o+t,o},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(n,t,o){Object.defineProperty(n,t,{value:o,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,o,r,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=(o=n.__FEDERATION__).__INSTANCES__)!=null||(o.__INSTANCES__=[]);var u;(u=(r=n.__FEDERATION__).moduleInfo)!=null||(r.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 r=Object.keys(n);for(const s of r){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 o=getFMId(n),r=getInfoWithoutType(t,o).value;if(r&&!r.version&&"version"in n&&n.version&&(r.version=n.version),r)return r;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 o=getFMId(n);return nativeGlobal.__FEDERATION__.moduleInfo[o]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=n=>(nativeGlobal.__FEDERATION__.moduleInfo=_extends$1({},nativeGlobal.__FEDERATION__.moduleInfo,n),()=>{const t=Object.keys(n);for(const o of t)delete nativeGlobal.__FEDERATION__.moduleInfo[o]}),getRemoteEntryExports=(n,t)=>{const o=t||`__FEDERATION_${n}:custom__`,r=CurrentGlobal[o];return{remoteEntryKey:o,entryExports:r}},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((o,r)=>r(o),t)}function extractComparator(n){return n.match(parseRegex(comparator))}function combineVersion(n,t,o,r){const s=`${n}.${t}.${o}`;return r?`${s}-${r}`:s}function parseHyphen(n){return n.replace(parseRegex(hyphenRange),(t,o,r,s,l,a,i,c,u,d,h,p)=>(isXVersion(r)?o="":isXVersion(s)?o=`>=${r}.0.0`:isXVersion(l)?o=`>=${r}.${s}.0`:o=`>=${o}`,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}`,`${o} ${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),(o,r,s,l,a)=>isXVersion(r)?"":isXVersion(s)?`>=${r}.0.0 <${Number(r)+1}.0.0-0`:isXVersion(l)?r==="0"?`>=${r}.${s}.0 <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.0 <${Number(r)+1}.0.0-0`:a?r==="0"?s==="0"?`>=${r}.${s}.${l}-${a} <${r}.${s}.${Number(l)+1}-0`:`>=${r}.${s}.${l}-${a} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${l}-${a} <${Number(r)+1}.0.0-0`:r==="0"?s==="0"?`>=${r}.${s}.${l} <${r}.${s}.${Number(l)+1}-0`:`>=${r}.${s}.${l} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${l} <${Number(r)+1}.0.0-0`)).join(" ")}function parseTildes(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(o,r,s,l,a)=>isXVersion(r)?"":isXVersion(s)?`>=${r}.0.0 <${Number(r)+1}.0.0-0`:isXVersion(l)?`>=${r}.${s}.0 <${r}.${Number(s)+1}.0-0`:a?`>=${r}.${s}.${l}-${a} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${l} <${r}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(n){return n.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(o,r,s,l,a,i)=>{const c=isXVersion(s),u=c||isXVersion(l),d=u||isXVersion(a);return r==="="&&d&&(r=""),i="",c?r===">"||r==="<"?"<0.0.0-0":"*":r&&d?(u&&(l=0),a=0,r===">"?(r=">=",u?(s=Number(s)+1,l=0,a=0):(l=Number(l)+1,a=0)):r==="<="&&(r="<",u?s=Number(s)+1:l=Number(l)+1),r==="<"&&(i="-0"),`${r+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`:o})).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:o}=n,{preRelease:r}=t;if(o===void 0&&r)return 1;if(o&&r===void 0)return-1;if(o===void 0&&r===void 0)return 0;for(let s=0,l=o.length;s<=l;s++){const a=o[s],i=r[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,o,r){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 '${o}'!`)});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:r)||"version-first"})}function formatShareConfigs(n,t){const o=t.shared||{},r=t.name,s=Object.keys(o).reduce((a,i)=>{const c=arrayOptions(o[i]);return a[i]=a[i]||[],c.forEach(u=>{a[i].push(formatShare(u,r,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 o=r=>{if(!Number.isNaN(Number(r))){const l=r.split(".");let a=r;for(let i=0;i<3-l.length;i++)a+=".0";return a}return r};return!!satisfy(o(n),`<=${o(t)}`)}const findVersion=(n,t)=>{const o=t||function(r,s){return versionLt(r,s)};return Object.keys(n).reduce((r,s)=>!r||o(r,s)||r==="0"?s:r,0)},isLoaded=n=>!!n.loaded||typeof n.lib=="function",isLoading=n=>!!n.loading;function findSingletonVersionOrderByVersion(n,t,o){const r=n[t][o],s=function(l,a){return!isLoaded(r[l])&&versionLt(l,a)};return findVersion(n[t][o],s)}function findSingletonVersionOrderByLoaded(n,t,o){const r=n[t][o],s=function(l,a){const i=c=>isLoaded(c)||isLoading(c);return i(r[a])?i(r[l])?!!versionLt(l,a):!0:i(r[l])?!1:versionLt(l,a)};return findVersion(n[t][o],s)}function getFindShareFunction(n){return n==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(n,t,o,r){if(!n)return;const{shareConfig:s,scope:l=DEFAULT_SCOPE,strategy:a}=o,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 ${o.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(r.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(n){const{pkgName:t,extraOptions:o,shareInfos:r}=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=o==null?void 0:o.resolver)!=null?l:s;return Object.assign({},a(r[t]),o==null?void 0:o.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(n,t){for(const o of n){const r=t.startsWith(o.name);let s=t.replace(o.name,"");if(r){if(s.startsWith("/")){const i=o.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:o}}else if(s==="")return{pkgNameOrAlias:o.name,expose:".",remote:o}}const l=o.alias&&t.startsWith(o.alias);let a=o.alias&&t.replace(o.alias,"");if(o.alias&&l){if(a&&a.startsWith("/")){const i=o.alias;return a=`.${a}`,{pkgNameOrAlias:i,expose:a,remote:o}}else if(a==="")return{pkgNameOrAlias:o.alias,expose:".",remote:o}}}}function matchRemote(n,t){for(const o of n)if(t===o.name||o.alias&&t===o.alias)return o}function registerPlugins(n,t){const o=getGlobalHostPlugins();return o.length>0&&o.forEach(r=>{n!=null&&n.find(s=>s.name!==r.name)&&n.push(r)}),n&&n.length>0&&n.forEach(r=>{t.forEach(s=>{s.applyPlugin(r)})}),n}async function loadEsmEntry({entry:n,remoteEntryExports:t}){return new Promise((o,r)=>{try{t?o(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${n}").then(callbacks[0]).catch(callbacks[1])`)([o,r]):import(n).then(o).catch(r)}catch(s){r(s)}})}async function loadSystemJsEntry({entry:n,remoteEntryExports:t}){return new Promise((o,r)=>{try{t?o(t):typeof __system_context__>"u"?System.import(n).then(o).catch(r):new Function("callbacks",`System.import("${n}").then(callbacks[0]).catch(callbacks[1])`)([o,r])}catch(s){r(s)}})}async function loadEntryScript({name:n,globalName:t,entry:o,loaderHook:r}){const{entryExports:s}=getRemoteEntryExports(n,t);return s||loadScript(o,{attrs:{},createScriptHook:(l,a)=>{const i=r.lifecycle.createScript.emit({url:l,attrs:a});if(i&&(i instanceof HTMLScriptElement||"script"in i||"timeout"in i))return i}}).then(()=>{const{remoteEntryKey:l,entryExports:a}=getRemoteEntryExports(n,t);return assert(a,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:n,remoteEntryUrl:o,remoteEntryKey:l})),a}).catch(l=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:n,resourceUrl:o})),l})}async function loadEntryDom({remoteInfo:n,remoteEntryExports:t,loaderHook:o}){const{entry:r,entryGlobalName:s,name:l,type:a}=n;switch(a){case"esm":case"module":return loadEsmEntry({entry:r,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:r,remoteEntryExports:t});default:return loadEntryScript({entry:r,globalName:s,name:l,loaderHook:o})}}async function loadEntryNode({remoteInfo:n,loaderHook:t}){const{entry:o,entryGlobalName:r,name:s,type:l}=n,{entryExports:a}=getRemoteEntryExports(s,r);return a||loadScriptNode(o,{attrs:{name:s,globalName:r,type:l},loaderHook:{createScriptHook:(i,c={})=>{const u=t.lifecycle.createScript.emit({url:i,attrs:c});if(u&&"url"in u)return u}}}).then(()=>{const{remoteEntryKey:i,entryExports:c}=getRemoteEntryExports(s,r);return assert(c,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:s,remoteEntryUrl:o,remoteEntryKey:i})),c}).catch(i=>{throw i})}function getRemoteEntryUniqueKey(n){const{entry:t,name:o}=n;return composeKeyWithSeparator(o,t)}async function getRemoteEntry({origin:n,remoteEntryExports:t,remoteInfo:o}){const r=getRemoteEntryUniqueKey(o);if(t)return t;if(!globalLoading[r]){const s=n.remoteHandler.hooks.lifecycle.loadEntry,l=n.loaderHook;globalLoading[r]=s.emit({loaderHook:l,remoteInfo:o,remoteEntryExports:t}).then(a=>a||(isBrowserEnv()?loadEntryDom({remoteInfo:o,remoteEntryExports:t,loaderHook:l}):loadEntryNode({remoteInfo:o,loaderHook:l})))}return globalLoading[r]}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 r=getRemoteEntryUniqueKey(this.remoteInfo);t=await this.host.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry,origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports,globalLoading,uniqueKey:r})}return assert(t,`remoteEntryExports is undefined
|
|
5
|
+
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,o,r,s){const{loadFactory:l=!0}=r||{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:o,moduleInfo:this.remoteInfo}),i||(i=await a.get(o)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${o}.`);const c=processModuleAlias(this.remoteInfo.name,o),u=this.wraperFactory(i,c);return l?await u():u}wraperFactory(t,o){function r(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 r(s,o),s}:()=>{const s=t();return r(s,o),s}}constructor({remoteInfo:t,host:o}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=o}};class SyncHook{on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const o=this;this.on(function r(...s){return o.remove(r),t.apply(null,s)})}emit(...t){let o;return this.listeners.size>0&&this.listeners.forEach(r=>{o=r(...t)}),o}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 o;const r=Array.from(this.listeners);if(r.length>0){let s=0;const l=a=>a===!1?!1:s<r.length?Promise.resolve(r[s++].apply(null,t)).then(l):a;o=l()}return Promise.resolve(o)}}function checkReturnData(n,t){if(!isObject(t))return!1;if(n!==t){for(const o in n)if(!(o 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 o of this.listeners)try{const r=o(t);if(checkReturnData(t,r))t=r;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(r){warn(r),this.onerror(r)}return t}constructor(t){super(),this.onerror=error,this.type=t}}class AsyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const o=Array.from(this.listeners);if(o.length>0){let r=0;const s=a=>(warn(a),this.onerror(a),t),l=a=>{if(checkReturnData(t,a)){if(t=a,r<o.length)try{return Promise.resolve(o[r++](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 o=t.name;assert(o,"A name must be provided by the plugin."),this.registerPlugins[o]||(this.registerPlugins[o]=t,Object.keys(this.lifecycle).forEach(r=>{const s=t[r];s&&this.lifecycle[r].on(s)}))}removePlugin(t){assert(t,"A name is required.");const o=this.registerPlugins[t];assert(o,`The plugin "${t}" is not registered.`),Object.keys(o).forEach(r=>{r!=="name"&&this.lifecycle[r].remove(o[r])})}inherit({lifecycle:t,registerPlugins:o}){Object.keys(t).forEach(r=>{assert(!this.lifecycle[r],`The hook "${r}" has a conflict and cannot be inherited.`),this.lifecycle[r]=t[r]}),Object.keys(o).forEach(r=>{assert(!this.registerPlugins[r],`The plugin "${r}" has a conflict and cannot be inherited.`),this.applyPlugin(o[r])})}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(o=>{const r=matchRemote(n,o.nameOrAlias);return assert(r,`Unable to preload ${o.nameOrAlias} as it is not included in ${!r&&safeToString({remoteInfo:r,remotes:n})}`),{remote:r,preloadConfig:defaultPreloadArgs(o)}})}function normalizePreloadExposes(n){return n?n.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(n,t,o,r=!0){const{cssAssets:s,jsAssetsWithoutEntry:l,entryAssets:a}=o;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})}),r){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(r){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 o=getRemoteEntryInfoFromSnapshot(t);o.url||error(`The attribute remoteEntry of ${n.name} must not be undefined.`);let r=getResourceUrl(t,o.url);!isBrowserEnv()&&!r.startsWith("http")&&(r=`https:${r}`),n.type=o.type,n.entryGlobalName=o.globalName,n.entry=r,n.version=t.version,n.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(n){const{remote:t,pkgNameOrAlias:o,expose:r,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:o,exposes:[r],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,o,r,s={},l){const a=getFMId(t),{value:i}=getInfoWithoutType(n,a),c=l||i;if(c&&!isManifestProvider(c)&&(o(c,t,r),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},o,!1,s,void 0)}}}const isExisted=(n,t)=>document.querySelector(`${n}[${n==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(n,t,o,r,s){const l=[],a=[],i=[],c=new Set,u=new Set,{options:d}=n,{preloadConfig:h}=t,{depsRemote:p}=h;if(traverseModuleInfo(r,o,(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 A;b=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(w=>getResourceUrl(y,w));return R.filter?T.filter(R.filter):T}if(b){const O=b.length;for(let T=0;T<O;T++){const w=b[T],N=`${g.name}/${w.moduleName}`;n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:w.moduleName==="."?g.name:N,name:g.name,remoteSnapshot:y,preloadConfig:R,remote:g,origin:n}),!getPreloaded(N)&&(R.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))):(R.resourceCategory="sync")&&(l.push(...$(w.assets.css.sync)),a.push(...$(w.assets.js.sync))),setPreloaded(N))}}},!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:o,remoteInfo:r,remote:s,globalSnapshot:l,remoteSnapshot:a}=n;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:r.name,entry:s.entry,type:r.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(r,a),generatePreloadAssets(t,o,r,l,a)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(n,t){const o=getGlobalSnapshotInfoByModuleInfo({name:t.options.name,version:t.options.version}),r=o&&"remotesInfo"in o&&o.remotesInfo&&getInfoWithoutType(o.remotesInfo,n.name).value;return r&&r.matchedVersion?{hostGlobalSnapshot:o,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:n.name,version:r.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:o}=this.HostInstance,{hostGlobalSnapshot:r,remoteSnapshot:s,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:a,globalSnapshot:i}=await this.hooks.lifecycle.loadSnapshot.emit({options:o,moduleInfo:t,hostGlobalSnapshot:r,remoteSnapshot:s,globalSnapshot:l});return{remoteSnapshot:a,globalSnapshot:i}}async loadRemoteSnapshotInfo(t){const{options:o}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:o,moduleInfo:t});let r=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});r||(r={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:r})),r&&"remotesInfo"in r&&!getInfoWithoutType(r.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(r.remotesInfo=_extends$1({},r==null?void 0:r.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:o,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:o,moduleInfo:t,remoteSnapshot:u}),{remoteSnapshot:u,globalSnapshot:d}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,o,r){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:o.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:o,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,o){const{shareInfos:r,shared:s}=formatShareConfigs(t,o);return Object.keys(r).forEach(a=>{r[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:o.name})})}),{shareInfos:r,shared:s}}async loadShare(t,o){const{host:r}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:r.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const l=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:r.options.shared,origin:r}),{shareInfo:a}=l;assert(a,`Cannot find ${t} Share in the ${r.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,a,this.hooks.lifecycle.resolveShare),c=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,r.options.name)};if(i&&i.lib)return c(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),c(i),u}else if(i){const 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:r.options.name,lib:null,loading:d}),d}else{if(o!=null&&o.customShareInfo)return!1;const d=(async()=>{const h=await a.get();a.lib=h,a.loaded=!0,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:r.options.name,lib:null,loading:d}),d}}initializeSharing(t=DEFAULT_SCOPE,o){const{host:r}=this,s=o==null?void 0:o.from,l=o==null?void 0:o.strategy;let a=o==null?void 0:o.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=r.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 r.remoteHandler.getRemoteModuleAndOptions({id:_});if(E.getEntry){let y;try{y=await E.getEntry()}catch(g){y=await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:_,error:g,from:"runtime",lifecycle:"beforeLoadShare",origin:r})}E.inited||(await p(y),E.inited=!0)}};return Object.keys(r.options.shared).forEach(_=>{r.options.shared[_].forEach(y=>{y.scope.includes(t)&&h(_,y)})}),(r.options.shareStrategy==="version-first"||l==="version-first")&&r.options.remotes.forEach(_=>{_.shareScope===t&&i.push(m(_.name))}),i}loadShareSync(t,o){const{host:r}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:o,shareInfos:r.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,r.options.name)};if(l){if(typeof l.lib=="function")return a(l),l.loaded||(l.loaded=!0,l.from===r.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:r.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=(o==null?void 0:o.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(c,runtimeDescMap,{hostName:r.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:r.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:r.options.name,sharedPkgName:t}))}initShareScopeMap(t,o,r={}){const{host:s}=this;this.shareScopeMap[t]=o,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:o,options:s.options,origin:s,scopeName:t,hostShareScopeMap:r.hostShareScopeMap})}setShared({pkgName:t,shared:o,from:r,lib:s,loading:l,loaded:a,get:i}){const{version:c,scope:u="default"}=o,d=_object_without_properties_loose(o,["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 o=getGlobalShareScope(),r=t.id||t.name;r&&!o[r]&&(o[r]=this.shareScopeMap)}constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}}class RemoteHandler{formatAndRegisterRemote(t,o){return(o.remotes||[]).reduce((s,l)=>(this.registerRemote(l,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,o){const{remote:r,expose:s}=o,{name:l,alias:a}=r;if(this.idToRemoteMap[t]={name:r.name,expose:s},a&&t.startsWith(l)){const i=t.replace(l,a);this.idToRemoteMap[i]={name:r.name,expose:s};return}if(a&&t.startsWith(a)){const i=t.replace(a,l);this.idToRemoteMap[i]={name:r.name,expose:s}}}async loadRemote(t,o){const{host:r}=this;try{const{loadFactory:s=!0}=o||{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,o,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:r});return this.setIdToRemoteMap(t,i),typeof _=="function"?_:m}catch(s){const{from:l="runtime"}=o||{from:"runtime"},a=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:l,lifecycle:"onLoad",origin:r});if(!a)throw s;return a}}async preloadRemote(t){const{host:o}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:o.options,origin:o});const r=formatPreloadArgs(o.options.remotes,t);await Promise.all(r.map(async s=>{const{remote:l}=s,a=getRemoteInfo(l),{globalSnapshot:i,remoteSnapshot:c}=await o.snapshotHandler.loadRemoteSnapshotInfo(l),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:s,remote:l,remoteInfo:a,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(a,o,u)}))}registerRemotes(t,o){const{host:r}=this;t.forEach(s=>{this.registerRemote(s,r.options.remotes,{force:o==null?void 0:o.force})})}async getRemoteModuleAndOptions(t){const{host:o}=this,{id:r}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:r,options:o.options,origin:o})}catch(_){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:r,options:o.options,origin:o,from:"runtime",error:_,lifecycle:"beforeRequest"}),!s)throw _}const{id:l}=s,a=matchRemoteWithNameAndExpose(o.options.remotes,l);assert(a,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:o.options.name,requestId:l}));const{remote:i}=a,c=getRemoteInfo(i),u=await o.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:l},a,{options:o.options,origin:o,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=o.moduleCache.get(d.name);const m={host:o,remoteInfo:c};return p||(p=new Module(m),o.moduleCache.set(d.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,o,r){const{host:s}=this,l=()=>{if(t.alias){const i=o.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=o.find(i=>i.name===t.name);if(!a)l(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];r!=null&&r.force&&(this.removeRemote(a),l(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){try{const{host:r}=this,{name:s}=t,l=r.options.remotes.findIndex(i=>i.name===s);l!==-1&&r.options.remotes.splice(l,1);const a=r.moduleCache.get(t.name);if(a){const i=a.remoteInfo,c=i.entryGlobalName;if(CurrentGlobal[c]){var o;(o=Object.getOwnPropertyDescriptor(CurrentGlobal,c))!=null&&o.configurable?delete CurrentGlobal[c]:CurrentGlobal[c]=void 0}const u=getRemoteEntryUniqueKey(a.remoteInfo);globalLoading[u]&&delete globalLoading[u],r.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(A=>{const $=v[A];$&&typeof $=="object"&&$.from===i.name&&($.loaded||$.loading?($.useIn=$.useIn.filter(O=>O!==i.name),$.useIn.length?E=!1:y.push([g,R,b,A])):y.push([g,R,b,A]))})})})}),E&&(m.shareScopeMap={},delete _[d]),y.forEach(([g,I,R,S])=>{var b,v,A;(A=_[g])==null||(v=A[I])==null||(b=v[R])==null||delete b[S]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(h,1)}const{hostGlobalSnapshot:p}=getGlobalRemoteInfo(t,r);if(p){const m=p&&"remotesInfo"in p&&p.remotesInfo&&getInfoWithoutType(p.remotesInfo,t.name).key;m&&(delete p.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}r.moduleCache.delete(t.name)}}catch(r){logger.log("removeRemote fail: ",r)}}constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}}class FederationHost{initOptions(t){this.registerPlugins(t.plugins);const o=this.formatOptions(this.options,t);return this.options=o,o}async loadShare(t,o){return this.sharedHandler.loadShare(t,o)}loadShareSync(t,o){return this.sharedHandler.loadShareSync(t,o)}initializeSharing(t=DEFAULT_SCOPE,o){return this.sharedHandler.initializeSharing(t,o)}initRawContainer(t,o,r){const s=getRemoteInfo({name:t,entry:o}),l=new Module({host:this,remoteInfo:s});return l.remoteEntryExports=r,this.moduleCache.set(t,l),l}async loadRemote(t,o){return this.remoteHandler.loadRemote(t,o)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,o,r={}){this.sharedHandler.initShareScopeMap(t,o,r)}formatOptions(t,o){const{shared:r}=formatShareConfigs(t,o),{userOptions:s,options:l}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:o,options:t,shareInfo:r}),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,o,{plugins:c,remotes:a,shared:i});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const o=registerPlugins(t,[this.hooks,this.remoteHandler.hooks,this.sharedHandler.hooks,this.snapshotHandler.hooks,this.loaderHook,this.bridgeHook]);this.options.plugins=this.options.plugins.reduce((r,s)=>(s&&r&&!r.find(l=>l.name===s.name)&&r.push(s),r),o||[])}registerRemotes(t,o){return this.remoteHandler.registerRemotes(t,o)}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 o={id:getBuilderId(),name:t.name,plugins:[snapshotPlugin(),generatePreloadAssetsPlugin()],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,o=getInstance();return()=>({__APP_VERSION__:"0.13.1",async render(r){var _,E,y;LoggerInstance.debug("createBridgeComponent render Info",r);const{moduleName:s,dom:l,basename:a,memoryRoute:i,hashRoute:c,...u}=r,d=Vue__namespace.createApp(n.rootComponent,u);t.set(l,d);const h=await((y=(E=(_=o==null?void 0:o.bridgeHook)==null?void 0:_.lifecycle)==null?void 0:E.beforeBridgeRender)==null?void 0:y.emit(r)),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();r.memoryRoute?g=VueRouter__namespace.createMemoryHistory(r.basename):r.hashRoute?(g=VueRouter__namespace.createWebHashHistory(),I=I.map(S=>({...S,path:r.basename+S.path}))):g=VueRouter__namespace.createWebHistory(r.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(r){LoggerInstance.debug("createBridgeComponent destroy Info",r);const s=t.get(r==null?void 0:r.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),o=Vue.ref(null),r=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);o.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(),r.value!==""&&r.value!==u&&(LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>",{...n,pathname:s.path}),e()),r.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>",{...n}),c(),(u=o.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 o="/";const r=(u=(c=t==null?void 0:t.matched)==null?void 0:c[0])==null?void 0:u.path;r&&(r.endsWith("/:pathMatch(.*)*")?o=r.replace("/:pathMatch(.*)*",""):o=t.matched[0].path);const s=(n==null?void 0:n.export)||"default";LoggerInstance.debug("createRemoteComponent LazyComponent create >>>",{basename:o,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:o,route:t}),s in l&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:a,providerInfo:i,basename:o,rootAttrs:n.rootAttrs})}};throw new Error("module not found")}})}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteComponent=createRemoteComponent;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -74,8 +74,8 @@ function generateSnapshotFromManifest(n, t = {}) {
|
|
|
74
74
|
const c = () => "publicPath" in n.metaData ? n.metaData.publicPath === "auto" && a ? inferAutoPublicPath(a) : n.metaData.publicPath : n.metaData.getPublicPath, u = Object.keys(l);
|
|
75
75
|
let d = {};
|
|
76
76
|
if (!Object.keys(s).length) {
|
|
77
|
-
var
|
|
78
|
-
d = ((
|
|
77
|
+
var p;
|
|
78
|
+
d = ((p = n.remotes) == null ? void 0 : p.reduce((R, $) => {
|
|
79
79
|
let T;
|
|
80
80
|
const A = $.federationContainerName;
|
|
81
81
|
return u.includes(A) ? T = l[A] : "version" in $ ? T = $.version : T = $.entry, R[A] = {
|
|
@@ -87,23 +87,23 @@ function generateSnapshotFromManifest(n, t = {}) {
|
|
|
87
87
|
// overrides will override dependencies
|
|
88
88
|
matchedVersion: u.includes(R) ? l[R] : s[R]
|
|
89
89
|
});
|
|
90
|
-
const { remoteEntry: { path:
|
|
91
|
-
let
|
|
90
|
+
const { remoteEntry: { path: m, name: y, type: g }, types: b, buildInfo: { buildVersion: _ }, globalName: E, ssrRemoteEntry: v } = n.metaData, { exposes: S } = n;
|
|
91
|
+
let I = {
|
|
92
92
|
version: a || "",
|
|
93
93
|
buildVersion: _,
|
|
94
|
-
globalName:
|
|
95
|
-
remoteEntry: simpleJoinRemoteEntry(
|
|
94
|
+
globalName: E,
|
|
95
|
+
remoteEntry: simpleJoinRemoteEntry(m, y),
|
|
96
96
|
remoteEntryType: g,
|
|
97
|
-
remoteTypes: simpleJoinRemoteEntry(
|
|
98
|
-
remoteTypesZip:
|
|
99
|
-
remoteTypesAPI:
|
|
97
|
+
remoteTypes: simpleJoinRemoteEntry(b.path, b.name),
|
|
98
|
+
remoteTypesZip: b.zip || "",
|
|
99
|
+
remoteTypesAPI: b.api || "",
|
|
100
100
|
remotesInfo: d,
|
|
101
101
|
shared: n == null ? void 0 : n.shared.map((R) => ({
|
|
102
102
|
assets: R.assets,
|
|
103
103
|
sharedName: R.name,
|
|
104
104
|
version: R.version
|
|
105
105
|
})),
|
|
106
|
-
modules:
|
|
106
|
+
modules: S == null ? void 0 : S.map((R) => ({
|
|
107
107
|
moduleName: R.name,
|
|
108
108
|
modulePath: R.path,
|
|
109
109
|
assets: R.assets
|
|
@@ -111,21 +111,21 @@ function generateSnapshotFromManifest(n, t = {}) {
|
|
|
111
111
|
};
|
|
112
112
|
if ((o = n.metaData) != null && o.prefetchInterface) {
|
|
113
113
|
const R = n.metaData.prefetchInterface;
|
|
114
|
-
|
|
114
|
+
I = _extends$2({}, I, {
|
|
115
115
|
prefetchInterface: R
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
if ((r = n.metaData) != null && r.prefetchEntry) {
|
|
119
119
|
const { path: R, name: $, type: T } = n.metaData.prefetchEntry;
|
|
120
|
-
|
|
120
|
+
I = _extends$2({}, I, {
|
|
121
121
|
prefetchEntry: simpleJoinRemoteEntry(R, $),
|
|
122
122
|
prefetchEntryType: T
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
if ("publicPath" in n.metaData ? i = _extends$2({},
|
|
125
|
+
if ("publicPath" in n.metaData ? i = _extends$2({}, I, {
|
|
126
126
|
publicPath: c(),
|
|
127
127
|
ssrPublicPath: n.metaData.ssrPublicPath
|
|
128
|
-
}) : i = _extends$2({},
|
|
128
|
+
}) : i = _extends$2({}, I, {
|
|
129
129
|
getPublicPath: c()
|
|
130
130
|
}), v) {
|
|
131
131
|
const R = simpleJoinRemoteEntry(v.path, v.name);
|
|
@@ -209,8 +209,8 @@ function createScript(n) {
|
|
|
209
209
|
}), i && typeof i == "function")) {
|
|
210
210
|
const d = i(c);
|
|
211
211
|
if (d instanceof Promise) {
|
|
212
|
-
const
|
|
213
|
-
return u(),
|
|
212
|
+
const p = await d;
|
|
213
|
+
return u(), p;
|
|
214
214
|
}
|
|
215
215
|
return u(), d;
|
|
216
216
|
}
|
|
@@ -513,10 +513,10 @@ function setGlobalDefaultVal(n) {
|
|
|
513
513
|
(u = (r = n.__FEDERATION__).moduleInfo) != null || (r.moduleInfo = {});
|
|
514
514
|
var d;
|
|
515
515
|
(d = (s = n.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
516
|
-
var m;
|
|
517
|
-
(m = (l = n.__FEDERATION__).__MANIFEST_LOADING__) != null || (l.__MANIFEST_LOADING__ = {});
|
|
518
516
|
var p;
|
|
519
|
-
(p = (
|
|
517
|
+
(p = (l = n.__FEDERATION__).__MANIFEST_LOADING__) != null || (l.__MANIFEST_LOADING__ = {});
|
|
518
|
+
var m;
|
|
519
|
+
(m = (a = n.__FEDERATION__).__PRELOADED_MAP__) != null || (a.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
520
520
|
}
|
|
521
521
|
setGlobalDefaultVal(CurrentGlobal);
|
|
522
522
|
setGlobalDefaultVal(nativeGlobal);
|
|
@@ -590,7 +590,7 @@ function combineVersion(n, t, o, r) {
|
|
|
590
590
|
return r ? `${s}-${r}` : s;
|
|
591
591
|
}
|
|
592
592
|
function parseHyphen(n) {
|
|
593
|
-
return n.replace(parseRegex(hyphenRange), (t, o, r, s, l, a, i, c, u, d,
|
|
593
|
+
return n.replace(parseRegex(hyphenRange), (t, o, r, s, l, a, i, c, u, d, p, m) => (isXVersion(r) ? o = "" : isXVersion(s) ? o = `>=${r}.0.0` : isXVersion(l) ? o = `>=${r}.${s}.0` : o = `>=${o}`, isXVersion(u) ? c = "" : isXVersion(d) ? c = `<${Number(u) + 1}.0.0-0` : isXVersion(p) ? c = `<${u}.${Number(d) + 1}.0-0` : m ? c = `<=${u}.${d}.${p}-${m}` : c = `<=${c}`, `${o} ${c}`.trim()));
|
|
594
594
|
}
|
|
595
595
|
function parseComparatorTrim(n) {
|
|
596
596
|
return n.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -703,29 +703,29 @@ function parseRange(n) {
|
|
|
703
703
|
function satisfy(n, t) {
|
|
704
704
|
if (!n)
|
|
705
705
|
return !1;
|
|
706
|
-
const s = parseRange(t).split(" ").map((
|
|
706
|
+
const s = parseRange(t).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)), l = extractComparator(n);
|
|
707
707
|
if (!l)
|
|
708
708
|
return !1;
|
|
709
|
-
const [, a, , i, c, u, d] = l,
|
|
709
|
+
const [, a, , i, c, u, d] = l, p = {
|
|
710
710
|
version: combineVersion(i, c, u, d),
|
|
711
711
|
major: i,
|
|
712
712
|
minor: c,
|
|
713
713
|
patch: u,
|
|
714
714
|
preRelease: d == null ? void 0 : d.split(".")
|
|
715
715
|
};
|
|
716
|
-
for (const
|
|
717
|
-
const y = extractComparator(
|
|
716
|
+
for (const m of s) {
|
|
717
|
+
const y = extractComparator(m);
|
|
718
718
|
if (!y)
|
|
719
719
|
return !1;
|
|
720
|
-
const [, g, ,
|
|
720
|
+
const [, g, , b, _, E, v] = y, S = {
|
|
721
721
|
operator: g,
|
|
722
|
-
version: combineVersion(
|
|
723
|
-
major:
|
|
722
|
+
version: combineVersion(b, _, E, v),
|
|
723
|
+
major: b,
|
|
724
724
|
minor: _,
|
|
725
|
-
patch:
|
|
725
|
+
patch: E,
|
|
726
726
|
preRelease: v == null ? void 0 : v.split(".")
|
|
727
727
|
};
|
|
728
|
-
if (!compare(
|
|
728
|
+
if (!compare(S, p))
|
|
729
729
|
return !1;
|
|
730
730
|
}
|
|
731
731
|
return !0;
|
|
@@ -816,27 +816,27 @@ function getRegisteredShare(n, t, o, r) {
|
|
|
816
816
|
];
|
|
817
817
|
for (const c of i)
|
|
818
818
|
if (s && n[c] && n[c][t]) {
|
|
819
|
-
const { requiredVersion: u } = s,
|
|
819
|
+
const { requiredVersion: u } = s, p = getFindShareFunction(a)(n, c, t), m = () => {
|
|
820
820
|
if (s.singleton) {
|
|
821
|
-
if (typeof u == "string" && !satisfy(
|
|
822
|
-
const
|
|
823
|
-
s.strictVersion ? error(
|
|
821
|
+
if (typeof u == "string" && !satisfy(p, u)) {
|
|
822
|
+
const b = `Version ${p} from ${p && n[c][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;
|
|
823
|
+
s.strictVersion ? error(b) : warn(b);
|
|
824
824
|
}
|
|
825
|
-
return n[c][t][
|
|
825
|
+
return n[c][t][p];
|
|
826
826
|
} else {
|
|
827
|
-
if (u === !1 || u === "*" || satisfy(
|
|
828
|
-
return n[c][t][
|
|
829
|
-
for (const [
|
|
830
|
-
if (satisfy(
|
|
827
|
+
if (u === !1 || u === "*" || satisfy(p, u))
|
|
828
|
+
return n[c][t][p];
|
|
829
|
+
for (const [b, _] of Object.entries(n[c][t]))
|
|
830
|
+
if (satisfy(b, u))
|
|
831
831
|
return _;
|
|
832
832
|
}
|
|
833
833
|
}, y = {
|
|
834
834
|
shareScopeMap: n,
|
|
835
835
|
scope: c,
|
|
836
836
|
pkgName: t,
|
|
837
|
-
version:
|
|
837
|
+
version: p,
|
|
838
838
|
GlobalFederation: Global.__FEDERATION__,
|
|
839
|
-
resolver:
|
|
839
|
+
resolver: m
|
|
840
840
|
};
|
|
841
841
|
return (r.emit(y) || y).resolver();
|
|
842
842
|
}
|
|
@@ -849,11 +849,11 @@ function getTargetSharedOptions(n) {
|
|
|
849
849
|
if (!i)
|
|
850
850
|
return;
|
|
851
851
|
const c = {};
|
|
852
|
-
i.forEach((
|
|
853
|
-
c[
|
|
852
|
+
i.forEach((p) => {
|
|
853
|
+
c[p.version] = p;
|
|
854
854
|
});
|
|
855
|
-
const d = findVersion(c, function(
|
|
856
|
-
return !isLoaded(c[
|
|
855
|
+
const d = findVersion(c, function(p, m) {
|
|
856
|
+
return !isLoaded(c[p]) && versionLt(p, m);
|
|
857
857
|
});
|
|
858
858
|
return c[d];
|
|
859
859
|
};
|
|
@@ -1087,25 +1087,25 @@ let Module = class {
|
|
|
1087
1087
|
loadFactory: !0
|
|
1088
1088
|
}, a = await this.getEntry();
|
|
1089
1089
|
if (!this.inited) {
|
|
1090
|
-
const
|
|
1090
|
+
const p = this.host.shareScopeMap, m = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [
|
|
1091
1091
|
this.remoteInfo.shareScope
|
|
1092
1092
|
];
|
|
1093
|
-
|
|
1094
|
-
|
|
1093
|
+
m.length || m.push("default"), m.forEach((E) => {
|
|
1094
|
+
p[E] || (p[E] = {});
|
|
1095
1095
|
});
|
|
1096
|
-
const y = m[
|
|
1096
|
+
const y = p[m[0]], g = [], b = {
|
|
1097
1097
|
version: this.remoteInfo.version || "",
|
|
1098
|
-
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ?
|
|
1098
|
+
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? m : this.remoteInfo.shareScope || "default"
|
|
1099
1099
|
};
|
|
1100
|
-
Object.defineProperty(
|
|
1101
|
-
value:
|
|
1100
|
+
Object.defineProperty(b, "shareScopeMap", {
|
|
1101
|
+
value: p,
|
|
1102
1102
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1103
1103
|
enumerable: !1
|
|
1104
1104
|
});
|
|
1105
1105
|
const _ = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1106
1106
|
shareScope: y,
|
|
1107
1107
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1108
|
-
remoteEntryInitOptions:
|
|
1108
|
+
remoteEntryInitOptions: b,
|
|
1109
1109
|
initScope: g,
|
|
1110
1110
|
remoteInfo: this.remoteInfo,
|
|
1111
1111
|
origin: this.host
|
|
@@ -1320,10 +1320,10 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1320
1320
|
cb: () => {
|
|
1321
1321
|
},
|
|
1322
1322
|
attrs: i,
|
|
1323
|
-
createLinkHook: (
|
|
1323
|
+
createLinkHook: (p, m) => {
|
|
1324
1324
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1325
|
-
url:
|
|
1326
|
-
attrs:
|
|
1325
|
+
url: p,
|
|
1326
|
+
attrs: m
|
|
1327
1327
|
});
|
|
1328
1328
|
if (y instanceof HTMLLinkElement)
|
|
1329
1329
|
return y;
|
|
@@ -1342,10 +1342,10 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1342
1342
|
cb: () => {
|
|
1343
1343
|
},
|
|
1344
1344
|
attrs: i,
|
|
1345
|
-
createLinkHook: (
|
|
1345
|
+
createLinkHook: (p, m) => {
|
|
1346
1346
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1347
|
-
url:
|
|
1348
|
-
attrs:
|
|
1347
|
+
url: p,
|
|
1348
|
+
attrs: m
|
|
1349
1349
|
});
|
|
1350
1350
|
if (y instanceof HTMLLinkElement)
|
|
1351
1351
|
return y;
|
|
@@ -1366,10 +1366,10 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1366
1366
|
cb: () => {
|
|
1367
1367
|
},
|
|
1368
1368
|
attrs: i,
|
|
1369
|
-
createLinkHook: (
|
|
1369
|
+
createLinkHook: (p, m) => {
|
|
1370
1370
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1371
|
-
url:
|
|
1372
|
-
attrs:
|
|
1371
|
+
url: p,
|
|
1372
|
+
attrs: m
|
|
1373
1373
|
});
|
|
1374
1374
|
if (y instanceof HTMLLinkElement)
|
|
1375
1375
|
return y;
|
|
@@ -1388,10 +1388,10 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1388
1388
|
cb: () => {
|
|
1389
1389
|
},
|
|
1390
1390
|
attrs: i,
|
|
1391
|
-
createScriptHook: (
|
|
1391
|
+
createScriptHook: (p, m) => {
|
|
1392
1392
|
const y = t.loaderHook.lifecycle.createScript.emit({
|
|
1393
|
-
url:
|
|
1394
|
-
attrs:
|
|
1393
|
+
url: p,
|
|
1394
|
+
attrs: m
|
|
1395
1395
|
});
|
|
1396
1396
|
if (y instanceof HTMLScriptElement)
|
|
1397
1397
|
return y;
|
|
@@ -1465,86 +1465,86 @@ function traverseModuleInfo(n, t, o, r, s = {}, l) {
|
|
|
1465
1465
|
if (s[d])
|
|
1466
1466
|
continue;
|
|
1467
1467
|
s[d] = !0;
|
|
1468
|
-
const
|
|
1468
|
+
const p = splitId(d), m = c.remotesInfo[d];
|
|
1469
1469
|
traverseModuleInfo(n, {
|
|
1470
|
-
name:
|
|
1471
|
-
version:
|
|
1470
|
+
name: p.name,
|
|
1471
|
+
version: m.matchedVersion
|
|
1472
1472
|
}, o, !1, s, void 0);
|
|
1473
1473
|
}
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
1476
|
const isExisted = (n, t) => document.querySelector(`${n}[${n === "link" ? "href" : "src"}="${t}"]`);
|
|
1477
1477
|
function generatePreloadAssets(n, t, o, r, s) {
|
|
1478
|
-
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = n, { preloadConfig:
|
|
1479
|
-
if (traverseModuleInfo(r, o, (_,
|
|
1480
|
-
let
|
|
1478
|
+
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = n, { preloadConfig: p } = t, { depsRemote: m } = p;
|
|
1479
|
+
if (traverseModuleInfo(r, o, (_, E, v) => {
|
|
1480
|
+
let S;
|
|
1481
1481
|
if (v)
|
|
1482
|
-
|
|
1483
|
-
else if (Array.isArray(
|
|
1484
|
-
const O =
|
|
1482
|
+
S = p;
|
|
1483
|
+
else if (Array.isArray(m)) {
|
|
1484
|
+
const O = m.find((w) => w.nameOrAlias === E.name || w.nameOrAlias === E.alias);
|
|
1485
1485
|
if (!O)
|
|
1486
1486
|
return;
|
|
1487
|
-
|
|
1488
|
-
} else if (
|
|
1489
|
-
|
|
1487
|
+
S = defaultPreloadArgs(O);
|
|
1488
|
+
} else if (m === !0)
|
|
1489
|
+
S = p;
|
|
1490
1490
|
else
|
|
1491
1491
|
return;
|
|
1492
|
-
const
|
|
1493
|
-
|
|
1494
|
-
name:
|
|
1492
|
+
const I = getResourceUrl(_, getRemoteEntryInfoFromSnapshot(_).url);
|
|
1493
|
+
I && i.push({
|
|
1494
|
+
name: E.name,
|
|
1495
1495
|
moduleInfo: {
|
|
1496
|
-
name:
|
|
1497
|
-
entry:
|
|
1496
|
+
name: E.name,
|
|
1497
|
+
entry: I,
|
|
1498
1498
|
type: "remoteEntryType" in _ ? _.remoteEntryType : "global",
|
|
1499
|
-
entryGlobalName: "globalName" in _ ? _.globalName :
|
|
1499
|
+
entryGlobalName: "globalName" in _ ? _.globalName : E.name,
|
|
1500
1500
|
shareScope: "",
|
|
1501
1501
|
version: "version" in _ ? _.version : void 0
|
|
1502
1502
|
},
|
|
1503
|
-
url:
|
|
1503
|
+
url: I
|
|
1504
1504
|
});
|
|
1505
1505
|
let R = "modules" in _ ? _.modules : [];
|
|
1506
|
-
const $ = normalizePreloadExposes(
|
|
1506
|
+
const $ = normalizePreloadExposes(S.exposes);
|
|
1507
1507
|
if ($.length && "modules" in _) {
|
|
1508
1508
|
var T;
|
|
1509
1509
|
R = _ == null || (T = _.modules) == null ? void 0 : T.reduce((O, w) => (($ == null ? void 0 : $.indexOf(w.moduleName)) !== -1 && O.push(w), O), []);
|
|
1510
1510
|
}
|
|
1511
1511
|
function A(O) {
|
|
1512
1512
|
const w = O.map((M) => getResourceUrl(_, M));
|
|
1513
|
-
return
|
|
1513
|
+
return S.filter ? w.filter(S.filter) : w;
|
|
1514
1514
|
}
|
|
1515
1515
|
if (R) {
|
|
1516
1516
|
const O = R.length;
|
|
1517
1517
|
for (let w = 0; w < O; w++) {
|
|
1518
|
-
const M = R[w], N = `${
|
|
1518
|
+
const M = R[w], N = `${E.name}/${M.moduleName}`;
|
|
1519
1519
|
n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1520
|
-
id: M.moduleName === "." ?
|
|
1521
|
-
name:
|
|
1520
|
+
id: M.moduleName === "." ? E.name : N,
|
|
1521
|
+
name: E.name,
|
|
1522
1522
|
remoteSnapshot: _,
|
|
1523
|
-
preloadConfig:
|
|
1524
|
-
remote:
|
|
1523
|
+
preloadConfig: S,
|
|
1524
|
+
remote: E,
|
|
1525
1525
|
origin: n
|
|
1526
|
-
}), !getPreloaded(N) && (
|
|
1526
|
+
}), !getPreloaded(N) && (S.resourceCategory === "all" ? (l.push(...A(M.assets.css.async)), l.push(...A(M.assets.css.sync)), a.push(...A(M.assets.js.async)), a.push(...A(M.assets.js.sync))) : (S.resourceCategory = "sync") && (l.push(...A(M.assets.css.sync)), a.push(...A(M.assets.js.sync))), setPreloaded(N));
|
|
1527
1527
|
}
|
|
1528
1528
|
}
|
|
1529
1529
|
}, !0, {}, s), s.shared) {
|
|
1530
|
-
const _ = (
|
|
1531
|
-
const
|
|
1532
|
-
|
|
1533
|
-
c.add(
|
|
1534
|
-
}), v.assets.css.sync.forEach((
|
|
1535
|
-
u.add(
|
|
1530
|
+
const _ = (E, v) => {
|
|
1531
|
+
const S = getRegisteredShare(n.shareScopeMap, v.sharedName, E, n.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1532
|
+
S && typeof S.lib == "function" && (v.assets.js.sync.forEach((I) => {
|
|
1533
|
+
c.add(I);
|
|
1534
|
+
}), v.assets.css.sync.forEach((I) => {
|
|
1535
|
+
u.add(I);
|
|
1536
1536
|
}));
|
|
1537
1537
|
};
|
|
1538
|
-
s.shared.forEach((
|
|
1538
|
+
s.shared.forEach((E) => {
|
|
1539
1539
|
var v;
|
|
1540
|
-
const
|
|
1541
|
-
if (!I)
|
|
1542
|
-
return;
|
|
1543
|
-
const S = b.version ? I.find(($) => $.version === b.version) : I;
|
|
1540
|
+
const S = (v = d.shared) == null ? void 0 : v[E.sharedName];
|
|
1544
1541
|
if (!S)
|
|
1545
1542
|
return;
|
|
1546
|
-
|
|
1547
|
-
|
|
1543
|
+
const I = E.version ? S.find(($) => $.version === E.version) : S;
|
|
1544
|
+
if (!I)
|
|
1545
|
+
return;
|
|
1546
|
+
arrayOptions(I).forEach(($) => {
|
|
1547
|
+
_($, E);
|
|
1548
1548
|
});
|
|
1549
1549
|
});
|
|
1550
1550
|
}
|
|
@@ -1651,29 +1651,29 @@ class SnapshotHandler {
|
|
|
1651
1651
|
let u, d;
|
|
1652
1652
|
if (i)
|
|
1653
1653
|
if (isManifestProvider(i)) {
|
|
1654
|
-
const
|
|
1654
|
+
const p = isBrowserEnv() ? i.remoteEntry : i.ssrRemoteEntry || i.remoteEntry || "", m = await this.getManifestJson(p, t, {}), y = setGlobalSnapshotInfoByModuleInfo(_extends$1({}, t, {
|
|
1655
1655
|
// The global remote may be overridden
|
|
1656
1656
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1657
|
-
entry:
|
|
1658
|
-
}),
|
|
1659
|
-
u =
|
|
1657
|
+
entry: p
|
|
1658
|
+
}), m);
|
|
1659
|
+
u = m, d = y;
|
|
1660
1660
|
} else {
|
|
1661
|
-
const { remoteSnapshot:
|
|
1661
|
+
const { remoteSnapshot: p } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1662
1662
|
options: this.HostInstance.options,
|
|
1663
1663
|
moduleInfo: t,
|
|
1664
1664
|
remoteSnapshot: i,
|
|
1665
1665
|
from: "global"
|
|
1666
1666
|
});
|
|
1667
|
-
u =
|
|
1667
|
+
u = p, d = c;
|
|
1668
1668
|
}
|
|
1669
1669
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1670
|
-
const
|
|
1670
|
+
const p = await this.getManifestJson(t.entry, t, {}), m = setGlobalSnapshotInfoByModuleInfo(t, p), { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1671
1671
|
options: this.HostInstance.options,
|
|
1672
1672
|
moduleInfo: t,
|
|
1673
|
-
remoteSnapshot:
|
|
1673
|
+
remoteSnapshot: p,
|
|
1674
1674
|
from: "global"
|
|
1675
1675
|
});
|
|
1676
|
-
u = y, d =
|
|
1676
|
+
u = y, d = m;
|
|
1677
1677
|
} else
|
|
1678
1678
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1679
1679
|
hostName: t.name,
|
|
@@ -1786,10 +1786,10 @@ class SharedHandler {
|
|
|
1786
1786
|
return i.loaded = !0, i.lib || (i.lib = u), c(i), u;
|
|
1787
1787
|
} else if (i) {
|
|
1788
1788
|
const d = (async () => {
|
|
1789
|
-
const
|
|
1790
|
-
a.lib =
|
|
1791
|
-
const
|
|
1792
|
-
return
|
|
1789
|
+
const p = await i.get();
|
|
1790
|
+
a.lib = p, a.loaded = !0, c(a);
|
|
1791
|
+
const m = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare);
|
|
1792
|
+
return m && (m.lib = p, m.loaded = !0), p;
|
|
1793
1793
|
})();
|
|
1794
1794
|
return this.setShared({
|
|
1795
1795
|
pkgName: t,
|
|
@@ -1803,10 +1803,10 @@ class SharedHandler {
|
|
|
1803
1803
|
if (o != null && o.customShareInfo)
|
|
1804
1804
|
return !1;
|
|
1805
1805
|
const d = (async () => {
|
|
1806
|
-
const
|
|
1807
|
-
a.lib =
|
|
1808
|
-
const
|
|
1809
|
-
return
|
|
1806
|
+
const p = await a.get();
|
|
1807
|
+
a.lib = p, a.loaded = !0, c(a);
|
|
1808
|
+
const m = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare);
|
|
1809
|
+
return m && (m.lib = p, m.loaded = !0), p;
|
|
1810
1810
|
})();
|
|
1811
1811
|
return this.setShared({
|
|
1812
1812
|
pkgName: t,
|
|
@@ -1831,43 +1831,43 @@ class SharedHandler {
|
|
|
1831
1831
|
if (s !== "build") {
|
|
1832
1832
|
const { initTokens: g } = this;
|
|
1833
1833
|
a || (a = []);
|
|
1834
|
-
let
|
|
1835
|
-
if (
|
|
1834
|
+
let b = g[t];
|
|
1835
|
+
if (b || (b = g[t] = {
|
|
1836
1836
|
from: this.host.name
|
|
1837
|
-
}), a.indexOf(
|
|
1838
|
-
a.push(
|
|
1837
|
+
}), a.indexOf(b) >= 0) return i;
|
|
1838
|
+
a.push(b);
|
|
1839
1839
|
}
|
|
1840
1840
|
const c = this.shareScopeMap, u = r.options.name;
|
|
1841
1841
|
c[t] || (c[t] = {});
|
|
1842
|
-
const d = c[t],
|
|
1842
|
+
const d = c[t], p = (g, b) => {
|
|
1843
1843
|
var _;
|
|
1844
|
-
const { version:
|
|
1844
|
+
const { version: E, eager: v } = b;
|
|
1845
1845
|
d[g] = d[g] || {};
|
|
1846
|
-
const
|
|
1847
|
-
(!
|
|
1848
|
-
},
|
|
1849
|
-
const { module:
|
|
1846
|
+
const S = d[g], I = S[E], R = !!(I && (I.eager || (_ = I.shareConfig) != null && _.eager));
|
|
1847
|
+
(!I || I.strategy !== "loaded-first" && !I.loaded && (!v != !R ? v : u > I.from)) && (S[E] = b);
|
|
1848
|
+
}, m = (g) => g && g.init && g.init(c[t], a), y = async (g) => {
|
|
1849
|
+
const { module: b } = await r.remoteHandler.getRemoteModuleAndOptions({
|
|
1850
1850
|
id: g
|
|
1851
1851
|
});
|
|
1852
|
-
if (
|
|
1852
|
+
if (b.getEntry) {
|
|
1853
1853
|
let _;
|
|
1854
1854
|
try {
|
|
1855
|
-
_ = await
|
|
1856
|
-
} catch (
|
|
1855
|
+
_ = await b.getEntry();
|
|
1856
|
+
} catch (E) {
|
|
1857
1857
|
_ = await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1858
1858
|
id: g,
|
|
1859
|
-
error:
|
|
1859
|
+
error: E,
|
|
1860
1860
|
from: "runtime",
|
|
1861
1861
|
lifecycle: "beforeLoadShare",
|
|
1862
1862
|
origin: r
|
|
1863
1863
|
});
|
|
1864
1864
|
}
|
|
1865
|
-
|
|
1865
|
+
b.inited || (await m(_), b.inited = !0);
|
|
1866
1866
|
}
|
|
1867
1867
|
};
|
|
1868
1868
|
return Object.keys(r.options.shared).forEach((g) => {
|
|
1869
1869
|
r.options.shared[g].forEach((_) => {
|
|
1870
|
-
_.scope.includes(t) &&
|
|
1870
|
+
_.scope.includes(t) && p(g, _);
|
|
1871
1871
|
});
|
|
1872
1872
|
}), (r.options.shareStrategy === "version-first" || l === "version-first") && r.options.remotes.forEach((g) => {
|
|
1873
1873
|
g.shareScope === t && i.push(y(g.name));
|
|
@@ -1947,9 +1947,9 @@ class SharedHandler {
|
|
|
1947
1947
|
]);
|
|
1948
1948
|
(Array.isArray(u) ? u : [
|
|
1949
1949
|
u
|
|
1950
|
-
]).forEach((
|
|
1951
|
-
if (this.shareScopeMap[
|
|
1952
|
-
this.shareScopeMap[
|
|
1950
|
+
]).forEach((m) => {
|
|
1951
|
+
if (this.shareScopeMap[m] || (this.shareScopeMap[m] = {}), this.shareScopeMap[m][t] || (this.shareScopeMap[m][t] = {}), !this.shareScopeMap[m][t][c]) {
|
|
1952
|
+
this.shareScopeMap[m][t][c] = _extends$1({
|
|
1953
1953
|
version: c,
|
|
1954
1954
|
scope: [
|
|
1955
1955
|
"default"
|
|
@@ -1958,10 +1958,10 @@ class SharedHandler {
|
|
|
1958
1958
|
lib: s,
|
|
1959
1959
|
loaded: a,
|
|
1960
1960
|
loading: l
|
|
1961
|
-
}), i && (this.shareScopeMap[
|
|
1961
|
+
}), i && (this.shareScopeMap[m][t][c].get = i);
|
|
1962
1962
|
return;
|
|
1963
1963
|
}
|
|
1964
|
-
const y = this.shareScopeMap[
|
|
1964
|
+
const y = this.shareScopeMap[m][t][c];
|
|
1965
1965
|
l && !y.loading && (y.loading = l);
|
|
1966
1966
|
});
|
|
1967
1967
|
}
|
|
@@ -2017,8 +2017,8 @@ class RemoteHandler {
|
|
|
2017
2017
|
loadFactory: !0
|
|
2018
2018
|
}, { module: l, moduleOptions: a, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2019
2019
|
id: t
|
|
2020
|
-
}), { pkgNameOrAlias: c, remote: u, expose: d, id:
|
|
2021
|
-
id:
|
|
2020
|
+
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await l.get(p, d, o, m), g = await this.hooks.lifecycle.onLoad.emit({
|
|
2021
|
+
id: p,
|
|
2022
2022
|
pkgNameOrAlias: c,
|
|
2023
2023
|
expose: d,
|
|
2024
2024
|
exposeModule: s ? y : void 0,
|
|
@@ -2104,15 +2104,15 @@ class RemoteHandler {
|
|
|
2104
2104
|
options: o.options,
|
|
2105
2105
|
origin: o,
|
|
2106
2106
|
remoteInfo: c
|
|
2107
|
-
})), { remote: d, expose:
|
|
2108
|
-
assert(d &&
|
|
2109
|
-
let
|
|
2107
|
+
})), { remote: d, expose: p } = u;
|
|
2108
|
+
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);
|
|
2109
|
+
let m = o.moduleCache.get(d.name);
|
|
2110
2110
|
const y = {
|
|
2111
2111
|
host: o,
|
|
2112
2112
|
remoteInfo: c
|
|
2113
2113
|
};
|
|
2114
|
-
return
|
|
2115
|
-
module:
|
|
2114
|
+
return m || (m = new Module(y), o.moduleCache.set(d.name, m)), {
|
|
2115
|
+
module: m,
|
|
2116
2116
|
moduleOptions: y,
|
|
2117
2117
|
remoteMatchInfo: u
|
|
2118
2118
|
};
|
|
@@ -2163,44 +2163,44 @@ class RemoteHandler {
|
|
|
2163
2163
|
const u = getRemoteEntryUniqueKey(a.remoteInfo);
|
|
2164
2164
|
globalLoading[u] && delete globalLoading[u], r.snapshotHandler.manifestCache.delete(i.entry);
|
|
2165
2165
|
let d = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2166
|
-
const
|
|
2167
|
-
if (
|
|
2168
|
-
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[
|
|
2166
|
+
const p = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === d : y.name === d);
|
|
2167
|
+
if (p !== -1) {
|
|
2168
|
+
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[p];
|
|
2169
2169
|
d = y.options.id || d;
|
|
2170
2170
|
const g = getGlobalShareScope();
|
|
2171
|
-
let
|
|
2171
|
+
let b = !0;
|
|
2172
2172
|
const _ = [];
|
|
2173
|
-
Object.keys(g).forEach((
|
|
2174
|
-
const v = g[
|
|
2175
|
-
v && Object.keys(v).forEach((
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2178
|
-
const $ =
|
|
2173
|
+
Object.keys(g).forEach((E) => {
|
|
2174
|
+
const v = g[E];
|
|
2175
|
+
v && Object.keys(v).forEach((S) => {
|
|
2176
|
+
const I = v[S];
|
|
2177
|
+
I && Object.keys(I).forEach((R) => {
|
|
2178
|
+
const $ = I[R];
|
|
2179
2179
|
$ && Object.keys($).forEach((T) => {
|
|
2180
2180
|
const A = $[T];
|
|
2181
|
-
A && typeof A == "object" && A.from === i.name && (A.loaded || A.loading ? (A.useIn = A.useIn.filter((O) => O !== i.name), A.useIn.length ?
|
|
2182
|
-
|
|
2183
|
-
|
|
2181
|
+
A && typeof A == "object" && A.from === i.name && (A.loaded || A.loading ? (A.useIn = A.useIn.filter((O) => O !== i.name), A.useIn.length ? b = !1 : _.push([
|
|
2182
|
+
E,
|
|
2183
|
+
S,
|
|
2184
2184
|
R,
|
|
2185
2185
|
T
|
|
2186
2186
|
])) : _.push([
|
|
2187
|
-
|
|
2188
|
-
|
|
2187
|
+
E,
|
|
2188
|
+
S,
|
|
2189
2189
|
R,
|
|
2190
2190
|
T
|
|
2191
2191
|
]));
|
|
2192
2192
|
});
|
|
2193
2193
|
});
|
|
2194
2194
|
});
|
|
2195
|
-
}),
|
|
2195
|
+
}), b && (y.shareScopeMap = {}, delete g[d]), _.forEach(([E, v, S, I]) => {
|
|
2196
2196
|
var R, $, T;
|
|
2197
|
-
(T = g[
|
|
2198
|
-
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(
|
|
2197
|
+
(T = g[E]) == null || ($ = T[v]) == null || (R = $[S]) == null || delete R[I];
|
|
2198
|
+
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p, 1);
|
|
2199
2199
|
}
|
|
2200
|
-
const { hostGlobalSnapshot:
|
|
2201
|
-
if (
|
|
2202
|
-
const y =
|
|
2203
|
-
y && (delete
|
|
2200
|
+
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, r);
|
|
2201
|
+
if (m) {
|
|
2202
|
+
const y = m && "remotesInfo" in m && m.remotesInfo && getInfoWithoutType(m.remotesInfo, t.name).key;
|
|
2203
|
+
y && (delete m.remotesInfo[y], Global.__FEDERATION__.__MANIFEST_LOADING__[y] && delete Global.__FEDERATION__.__MANIFEST_LOADING__[y]);
|
|
2204
2204
|
}
|
|
2205
2205
|
r.moduleCache.delete(t.name);
|
|
2206
2206
|
}
|
|
@@ -2350,29 +2350,42 @@ function createBridgeComponent(n) {
|
|
|
2350
2350
|
return () => ({
|
|
2351
2351
|
__APP_VERSION__: "0.13.1",
|
|
2352
2352
|
async render(r) {
|
|
2353
|
-
var
|
|
2353
|
+
var g, b, _;
|
|
2354
2354
|
LoggerInstance.debug("createBridgeComponent render Info", r);
|
|
2355
|
-
const {
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2355
|
+
const {
|
|
2356
|
+
moduleName: s,
|
|
2357
|
+
dom: l,
|
|
2358
|
+
basename: a,
|
|
2359
|
+
memoryRoute: i,
|
|
2360
|
+
hashRoute: c,
|
|
2361
|
+
...u
|
|
2362
|
+
} = r, d = Vue.createApp(n.rootComponent, u);
|
|
2363
|
+
t.set(l, d);
|
|
2364
|
+
const p = await ((_ = (b = (g = o == null ? void 0 : o.bridgeHook) == null ? void 0 : g.lifecycle) == null ? void 0 : b.beforeBridgeRender) == null ? void 0 : _.emit(r)), m = p && typeof p == "object" && (p != null && p.extraProps) ? p == null ? void 0 : p.extraProps : {}, y = n.appOptions({
|
|
2365
|
+
app: d,
|
|
2359
2366
|
basename: a,
|
|
2360
2367
|
memoryRoute: i,
|
|
2361
|
-
|
|
2368
|
+
hashRoute: c,
|
|
2369
|
+
...u,
|
|
2362
2370
|
...m
|
|
2363
2371
|
});
|
|
2364
|
-
if (
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2372
|
+
if (y != null && y.router) {
|
|
2373
|
+
let E, v = y.router.getRoutes();
|
|
2374
|
+
r.memoryRoute ? E = VueRouter.createMemoryHistory(r.basename) : r.hashRoute ? (E = VueRouter.createWebHashHistory(), v = v.map((I) => ({
|
|
2375
|
+
...I,
|
|
2376
|
+
path: r.basename + I.path
|
|
2377
|
+
}))) : E = VueRouter.createWebHistory(r.basename);
|
|
2378
|
+
const S = VueRouter.createRouter({
|
|
2379
|
+
...y.router.options,
|
|
2380
|
+
history: E,
|
|
2381
|
+
routes: v
|
|
2369
2382
|
});
|
|
2370
2383
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
2371
2384
|
moduleName: s,
|
|
2372
|
-
router:
|
|
2373
|
-
}), i && await
|
|
2385
|
+
router: S
|
|
2386
|
+
}), i && await S.push(i.entryPath), d.use(S);
|
|
2374
2387
|
}
|
|
2375
|
-
|
|
2388
|
+
d.mount(l);
|
|
2376
2389
|
},
|
|
2377
2390
|
destroy(r) {
|
|
2378
2391
|
LoggerInstance.debug("createBridgeComponent destroy Info", r);
|
|
@@ -2391,27 +2404,29 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2391
2404
|
moduleName: String,
|
|
2392
2405
|
basename: String,
|
|
2393
2406
|
memoryRoute: Object,
|
|
2407
|
+
hashRoute: Boolean,
|
|
2394
2408
|
providerInfo: Function,
|
|
2395
2409
|
rootAttrs: Object
|
|
2396
2410
|
},
|
|
2397
2411
|
inheritAttrs: !1,
|
|
2398
2412
|
setup(n) {
|
|
2399
2413
|
const t = ref(null), o = ref(null), r = ref(""), s = useRoute(), l = getInstance(), a = useAttrs(), i = async () => {
|
|
2400
|
-
var
|
|
2401
|
-
const u = (
|
|
2414
|
+
var m, y, g, b;
|
|
2415
|
+
const u = (m = n.providerInfo) == null ? void 0 : m.call(n);
|
|
2402
2416
|
o.value = u;
|
|
2403
2417
|
let d = {
|
|
2404
2418
|
...a,
|
|
2405
2419
|
moduleName: n.moduleName,
|
|
2406
2420
|
dom: t.value,
|
|
2407
2421
|
basename: n.basename,
|
|
2408
|
-
memoryRoute: n.memoryRoute
|
|
2422
|
+
memoryRoute: n.memoryRoute,
|
|
2423
|
+
hashRoute: n.hashRoute
|
|
2409
2424
|
};
|
|
2410
2425
|
LoggerInstance.debug("createRemoteComponent LazyComponent render >>>", d);
|
|
2411
|
-
const
|
|
2426
|
+
const p = await ((b = (g = (y = l == null ? void 0 : l.bridgeHook) == null ? void 0 : y.lifecycle) == null ? void 0 : g.beforeBridgeRender) == null ? void 0 : b.emit(d)) || {};
|
|
2412
2427
|
d = {
|
|
2413
2428
|
...d,
|
|
2414
|
-
...
|
|
2429
|
+
...p.extraProps
|
|
2415
2430
|
}, u.render(d);
|
|
2416
2431
|
}, c = watch(() => s == null ? void 0 : s.path, (u) => {
|
|
2417
2432
|
u !== s.path && i(), r.value !== "" && r.value !== u && (LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>", {
|
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-20250515032632",
|
|
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-20250515032632",
|
|
36
|
+
"@module-federation/sdk": "0.0.0-next-20250515032632",
|
|
37
|
+
"@module-federation/runtime": "0.0.0-next-20250515032632"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@vitejs/plugin-vue": "^5.0.4",
|
package/src/provider.ts
CHANGED
|
@@ -28,7 +28,14 @@ export function createBridgeComponent(bridgeInfo: ProviderFnParams) {
|
|
|
28
28
|
__APP_VERSION__,
|
|
29
29
|
async render(info: RenderFnParams) {
|
|
30
30
|
LoggerInstance.debug(`createBridgeComponent render Info`, info);
|
|
31
|
-
const {
|
|
31
|
+
const {
|
|
32
|
+
moduleName,
|
|
33
|
+
dom,
|
|
34
|
+
basename,
|
|
35
|
+
memoryRoute,
|
|
36
|
+
hashRoute,
|
|
37
|
+
...propsInfo
|
|
38
|
+
} = info;
|
|
32
39
|
const app = Vue.createApp(bridgeInfo.rootComponent, propsInfo);
|
|
33
40
|
rootMap.set(dom, app);
|
|
34
41
|
|
|
@@ -46,19 +53,32 @@ export function createBridgeComponent(bridgeInfo: ProviderFnParams) {
|
|
|
46
53
|
app,
|
|
47
54
|
basename,
|
|
48
55
|
memoryRoute,
|
|
56
|
+
hashRoute,
|
|
49
57
|
...propsInfo,
|
|
50
58
|
...extraProps,
|
|
51
59
|
});
|
|
52
|
-
|
|
53
60
|
if (bridgeOptions?.router) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
let history;
|
|
62
|
+
let routes = bridgeOptions.router.getRoutes();
|
|
63
|
+
|
|
64
|
+
if (info.memoryRoute) {
|
|
65
|
+
history = VueRouter.createMemoryHistory(info.basename);
|
|
66
|
+
} else if (info.hashRoute) {
|
|
67
|
+
history = VueRouter.createWebHashHistory();
|
|
68
|
+
routes = routes.map((route) => {
|
|
69
|
+
return {
|
|
70
|
+
...route,
|
|
71
|
+
path: info.basename + route.path,
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
history = VueRouter.createWebHistory(info.basename);
|
|
76
|
+
}
|
|
57
77
|
|
|
58
78
|
const router = VueRouter.createRouter({
|
|
59
79
|
...bridgeOptions.router.options,
|
|
60
80
|
history,
|
|
61
|
-
routes
|
|
81
|
+
routes,
|
|
62
82
|
});
|
|
63
83
|
|
|
64
84
|
LoggerInstance.debug(`createBridgeComponent render router info>>>`, {
|
package/src/remoteApp.tsx
CHANGED
|
@@ -17,6 +17,7 @@ export default defineComponent({
|
|
|
17
17
|
moduleName: String,
|
|
18
18
|
basename: String,
|
|
19
19
|
memoryRoute: Object,
|
|
20
|
+
hashRoute: Boolean,
|
|
20
21
|
providerInfo: Function,
|
|
21
22
|
rootAttrs: Object,
|
|
22
23
|
},
|
|
@@ -39,6 +40,7 @@ export default defineComponent({
|
|
|
39
40
|
dom: rootRef.value,
|
|
40
41
|
basename: props.basename,
|
|
41
42
|
memoryRoute: props.memoryRoute,
|
|
43
|
+
hashRoute: props.hashRoute,
|
|
42
44
|
};
|
|
43
45
|
LoggerInstance.debug(
|
|
44
46
|
`createRemoteComponent LazyComponent render >>>`,
|
|
@@ -92,6 +94,7 @@ export default defineComponent({
|
|
|
92
94
|
dom: rootRef.value,
|
|
93
95
|
basename: props.basename,
|
|
94
96
|
memoryRoute: props.memoryRoute,
|
|
97
|
+
hashRoute: props.hashRoute,
|
|
95
98
|
});
|
|
96
99
|
|
|
97
100
|
(providerInfoRef.value as any)?.destroy({ dom: rootRef.value });
|
|
@@ -100,6 +103,7 @@ export default defineComponent({
|
|
|
100
103
|
dom: rootRef.value,
|
|
101
104
|
basename: props.basename,
|
|
102
105
|
memoryRoute: props.memoryRoute,
|
|
106
|
+
hashRoute: props.hashRoute,
|
|
103
107
|
});
|
|
104
108
|
});
|
|
105
109
|
|