@module-federation/bridge-vue3 0.0.0-next-20241218093627 → 0.0.0-next-20241224035007

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # @module-federation/bridge-vue3
2
2
 
3
- ## 0.0.0-next-20241218093627
3
+ ## 0.0.0-next-20241224035007
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - @module-federation/runtime@0.0.0-next-20241218093627
8
- - @module-federation/sdk@0.0.0-next-20241218093627
9
- - @module-federation/bridge-shared@0.0.0-next-20241218093627
7
+ - 85e7482: fix(bridge-react): change all logs from info to debug in all bridge packages
8
+ - @module-federation/runtime@0.0.0-next-20241224035007
9
+ - @module-federation/sdk@0.0.0-next-20241224035007
10
+ - @module-federation/bridge-shared@0.0.0-next-20241224035007
10
11
 
11
12
  ## 0.8.5
12
13
 
package/dist/index.cjs.js CHANGED
@@ -7,4 +7,4 @@ ${n(_.join(`
7
7
  })`,{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 r=exportedInterface[attrs.globalName]||exportedInterface;cb(void 0,r);return}cb(void 0,exportedInterface)}catch(r){cb(r instanceof Error?r:new Error(`Script execution error: ${r}`))}};getFetch().then(async r=>{if((attrs==null?void 0:attrs.type)==="esm"||(attrs==null?void 0:attrs.type)==="module")return loadModule(urlObj.href,{fetch:r,vm:await importNodeModule("vm")}).then(async t=>{await t.evaluate(),cb(void 0,t.namespace)}).catch(t=>{cb(t instanceof Error?t:new Error(`Script execution error: ${t}`))});handleScriptFetch(r,urlObj)}).catch(r=>{cb(r)})}function loadScriptNode(r,t){return new Promise((n,o)=>{createScriptNode(r,(s,a)=>{if(s)o(s);else{var l,i;const c=(t==null||(l=t.attrs)==null?void 0:l.globalName)||`__FEDERATION_${t==null||(i=t.attrs)==null?void 0:i.name}:custom__`,u=globalThis[c]=a;n(u)}},t.attrs,t.loaderHook)})}async function loadModule(r,t){const{fetch:n,vm:o}=t,a=await(await n(r)).text(),l=new o.SourceTextModule(a,{importModuleDynamically:async(i,c)=>{const u=new URL(i,r).href;return loadModule(u,t)}});return await l.link(async i=>{const c=new URL(i,r).href;return await loadModule(c,t)}),l}const LoggerInstance=createLogger("[ Module Federation Bridge Vue3 ]");function _extends$1(){return _extends$1=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s])}return t},_extends$1.apply(this,arguments)}function _object_without_properties_loose(r,t){if(r==null)return{};var n={},o=Object.keys(r),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(n[s]=r[s]);return n}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}const LOG_CATEGORY="[ Federation Runtime ]",logger=createLogger(LOG_CATEGORY);function assert(r,t){r||error(t)}function error(r){throw r instanceof Error?(r.message=`${LOG_CATEGORY}: ${r.message}`,r):new Error(`${LOG_CATEGORY}: ${r}`)}function warn(r){r instanceof Error&&(r.message=`${LOG_CATEGORY}: ${r.message}`),logger.warn(r)}function addUniqueItem(r,t){return r.findIndex(n=>n===t)===-1&&r.push(t),r}function getFMId(r){return"version"in r&&r.version?`${r.name}:${r.version}`:"entry"in r&&r.entry?`${r.name}:${r.entry}`:`${r.name}`}function isRemoteInfoWithEntry(r){return typeof r.entry<"u"}function isPureRemoteEntry(r){return!r.entry.includes(".json")&&r.entry.includes(".js")}function isObject(r){return r&&typeof r=="object"}const objectToString=Object.prototype.toString;function isPlainObject(r){return objectToString.call(r)==="[object Object]"}function arrayOptions(r){return Array.isArray(r)?r:[r]}function getRemoteEntryInfoFromSnapshot(r){const t={url:"",type:"global",globalName:""};return isBrowserEnv()?"remoteEntry"in r?{url:r.remoteEntry,type:r.remoteEntryType,globalName:r.globalName}:t:"ssrRemoteEntry"in r?{url:r.ssrRemoteEntry||t.url,type:r.ssrRemoteEntryType||t.type,globalName:r.globalName}:t}const processModuleAlias=(r,t)=>{let n;return r.endsWith("/")?n=r.slice(0,-1):n=r,t.startsWith(".")&&(t=t.slice(1)),n=n+t,n},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(r,t,n){Object.defineProperty(r,t,{value:n,configurable:!1,writable:!0})}function includeOwnProperty(r,t){return Object.hasOwnProperty.call(r,t)}includeOwnProperty(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(r){var t,n,o,s,a,l;includeOwnProperty(r,"__VMOK__")&&!includeOwnProperty(r,"__FEDERATION__")&&definePropertyGlobalVal(r,"__FEDERATION__",r.__VMOK__),includeOwnProperty(r,"__FEDERATION__")||(definePropertyGlobalVal(r,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),definePropertyGlobalVal(r,"__VMOK__",r.__FEDERATION__));var i;(i=(t=r.__FEDERATION__).__GLOBAL_PLUGIN__)!=null||(t.__GLOBAL_PLUGIN__=[]);var c;(c=(n=r.__FEDERATION__).__INSTANCES__)!=null||(n.__INSTANCES__=[]);var u;(u=(o=r.__FEDERATION__).moduleInfo)!=null||(o.moduleInfo={});var d;(d=(s=r.__FEDERATION__).__SHARE__)!=null||(s.__SHARE__={});var h;(h=(a=r.__FEDERATION__).__MANIFEST_LOADING__)!=null||(a.__MANIFEST_LOADING__={});var p;(p=(l=r.__FEDERATION__).__PRELOADED_MAP__)!=null||(l.__PRELOADED_MAP__=new Map)}setGlobalDefaultVal(CurrentGlobal);setGlobalDefaultVal(nativeGlobal);function setGlobalFederationConstructor(r,t=isDebugMode()){t&&(CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__=r,CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="0.8.5")}function getInfoWithoutType(r,t){if(typeof t=="string"){if(r[t])return{value:r[t],key:t};{const o=Object.keys(r);for(const s of o){const[a,l]=s.split(":"),i=`${a}:${t}`,c=r[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=(r,t)=>{const n=getFMId(r),o=getInfoWithoutType(t,n).value;if(o&&!o.version&&"version"in r&&r.version&&(o.version=r.version),o)return o;if("version"in r&&r.version){const{version:s}=r,a=_object_without_properties_loose(r,["version"]),l=getFMId(a),i=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,l).value;if((i==null?void 0:i.version)===s)return i}},getGlobalSnapshotInfoByModuleInfo=r=>getTargetSnapshotInfoByModuleInfo(r,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(r,t)=>{const n=getFMId(r);return nativeGlobal.__FEDERATION__.moduleInfo[n]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=r=>(nativeGlobal.__FEDERATION__.moduleInfo=_extends$1({},nativeGlobal.__FEDERATION__.moduleInfo,r),()=>{const t=Object.keys(r);for(const n of t)delete nativeGlobal.__FEDERATION__.moduleInfo[n]}),getRemoteEntryExports=(r,t)=>{const n=t||`__FEDERATION_${r}:custom__`,o=CurrentGlobal[n];return{remoteEntryKey:n,entryExports:o}},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=r=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(r),setPreloaded=r=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(r,!0),DEFAULT_SCOPE="default",DEFAULT_REMOTE_TYPE="global",buildIdentifier="[0-9A-Za-z-]+",build=`(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`,numericIdentifier="0|[1-9]\\d*",numericIdentifierLoose="[0-9]+",nonNumericIdentifier="\\d*[a-zA-Z-][a-zA-Z0-9-]*",preReleaseIdentifierLoose=`(?:${numericIdentifierLoose}|${nonNumericIdentifier})`,preReleaseLoose=`(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`,preReleaseIdentifier=`(?:${numericIdentifier}|${nonNumericIdentifier})`,preRelease=`(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`,xRangeIdentifier=`${numericIdentifier}|x|X|\\*`,xRangePlain=`[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`,hyphenRange=`^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`,mainVersionLoose=`(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`,loosePlain=`[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`,gtlt="((?:<|>)?=?)",comparatorTrim=`(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`,loneTilde="(?:~>?)",tildeTrim=`(\\s*)${loneTilde}\\s+`,loneCaret="(?:\\^)",caretTrim=`(\\s*)${loneCaret}\\s+`,star="(<|>)?=?\\s*\\*",caret=`^${loneCaret}${xRangePlain}$`,mainVersion=`(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`,fullPlain=`v?${mainVersion}${preRelease}?${build}?`,tilde=`^${loneTilde}${xRangePlain}$`,xRange=`^${gtlt}\\s*${xRangePlain}$`,comparator=`^${gtlt}\\s*(${fullPlain})$|^$`,gte0="^\\s*>=\\s*0.0.0\\s*$";function parseRegex(r){return new RegExp(r)}function isXVersion(r){return!r||r.toLowerCase()==="x"||r==="*"}function pipe(...r){return t=>r.reduce((n,o)=>o(n),t)}function extractComparator(r){return r.match(parseRegex(comparator))}function combineVersion(r,t,n,o){const s=`${r}.${t}.${n}`;return o?`${s}-${o}`:s}function parseHyphen(r){return r.replace(parseRegex(hyphenRange),(t,n,o,s,a,l,i,c,u,d,h,p)=>(isXVersion(o)?n="":isXVersion(s)?n=`>=${o}.0.0`:isXVersion(a)?n=`>=${o}.${s}.0`:n=`>=${n}`,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}`,`${n} ${c}`.trim()))}function parseComparatorTrim(r){return r.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(r){return r.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(r){return r.replace(parseRegex(caretTrim),"$1^")}function parseCarets(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(caret),(n,o,s,a,l)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(a)?o==="0"?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.0 <${Number(o)+1}.0.0-0`:l?o==="0"?s==="0"?`>=${o}.${s}.${a}-${l} <${o}.${s}.${Number(a)+1}-0`:`>=${o}.${s}.${a}-${l} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${a}-${l} <${Number(o)+1}.0.0-0`:o==="0"?s==="0"?`>=${o}.${s}.${a} <${o}.${s}.${Number(a)+1}-0`:`>=${o}.${s}.${a} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${a} <${Number(o)+1}.0.0-0`)).join(" ")}function parseTildes(r){return r.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(n,o,s,a,l)=>isXVersion(o)?"":isXVersion(s)?`>=${o}.0.0 <${Number(o)+1}.0.0-0`:isXVersion(a)?`>=${o}.${s}.0 <${o}.${Number(s)+1}.0-0`:l?`>=${o}.${s}.${a}-${l} <${o}.${Number(s)+1}.0-0`:`>=${o}.${s}.${a} <${o}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(r){return r.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(n,o,s,a,l,i)=>{const c=isXVersion(s),u=c||isXVersion(a),d=u||isXVersion(l);return o==="="&&d&&(o=""),i="",c?o===">"||o==="<"?"<0.0.0-0":"*":o&&d?(u&&(a=0),l=0,o===">"?(o=">=",u?(s=Number(s)+1,a=0,l=0):(a=Number(a)+1,l=0)):o==="<="&&(o="<",u?s=Number(s)+1:a=Number(a)+1),o==="<"&&(i="-0"),`${o+s}.${a}.${l}${i}`):u?`>=${s}.0.0${i} <${Number(s)+1}.0.0-0`:d?`>=${s}.${a}.0${i} <${s}.${Number(a)+1}.0-0`:n})).join(" ")}function parseStar(r){return r.trim().replace(parseRegex(star),"")}function parseGTE0(r){return r.trim().replace(parseRegex(gte0),"")}function compareAtom(r,t){return r=Number(r)||r,t=Number(t)||t,r>t?1:r===t?0:-1}function comparePreRelease(r,t){const{preRelease:n}=r,{preRelease:o}=t;if(n===void 0&&o)return 1;if(n&&o===void 0)return-1;if(n===void 0&&o===void 0)return 0;for(let s=0,a=n.length;s<=a;s++){const l=n[s],i=o[s];if(l!==i)return l===void 0&&i===void 0?0:l?i?compareAtom(l,i):-1:1}return 0}function compareVersion(r,t){return compareAtom(r.major,t.major)||compareAtom(r.minor,t.minor)||compareAtom(r.patch,t.patch)||comparePreRelease(r,t)}function eq(r,t){return r.version===t.version}function compare(r,t){switch(r.operator){case"":case"=":return eq(r,t);case">":return compareVersion(r,t)<0;case">=":return eq(r,t)||compareVersion(r,t)<0;case"<":return compareVersion(r,t)>0;case"<=":return eq(r,t)||compareVersion(r,t)>0;case void 0:return!0;default:return!1}}function parseComparatorString(r){return pipe(parseCarets,parseTildes,parseXRanges,parseStar)(r)}function parseRange(r){return pipe(parseHyphen,parseComparatorTrim,parseTildeTrim,parseCaretTrim)(r.trim()).split(/\s+/).join(" ")}function satisfy(r,t){if(!r)return!1;const s=parseRange(t).split(" ").map(p=>parseComparatorString(p)).join(" ").split(/\s+/).map(p=>parseGTE0(p)),a=extractComparator(r);if(!a)return!1;const[,l,,i,c,u,d]=a,h={operator:l,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[,g,,b,y,_,v]=m,S={operator:g,version:combineVersion(b,y,_,v),major:b,minor:y,patch:_,preRelease:v==null?void 0:v.split(".")};if(!compare(S,h))return!1}return!0}function formatShare(r,t,n,o){let s;"get"in r?s=r.get:"lib"in r?s=()=>Promise.resolve(r.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${n}'!`)}),r.strategy&&warn('"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"');var a,l,i;return _extends$1({deps:[],useIn:[],from:t,loading:null},r,{shareConfig:_extends$1({requiredVersion:`^${r.version}`,singleton:!1,eager:!1,strictVersion:!1},r.shareConfig),get:s,loaded:r!=null&&r.loaded||"lib"in r?!0:void 0,version:(a=r.version)!=null?a:"0",scope:Array.isArray(r.scope)?r.scope:[(l=r.scope)!=null?l:"default"],strategy:((i=r.strategy)!=null?i:o)||"version-first"})}function formatShareConfigs(r,t){const n=t.shared||{},o=t.name,s=Object.keys(n).reduce((l,i)=>{const c=arrayOptions(n[i]);return l[i]=l[i]||[],c.forEach(u=>{l[i].push(formatShare(u,o,i,t.shareStrategy))}),l},{}),a=_extends$1({},r.shared);return Object.keys(s).forEach(l=>{a[l]?s[l].forEach(i=>{a[l].find(u=>u.version===i.version)||a[l].push(i)}):a[l]=s[l]}),{shared:a,shareInfos:s}}function versionLt(r,t){const n=o=>{if(!Number.isNaN(Number(o))){const a=o.split(".");let l=o;for(let i=0;i<3-a.length;i++)l+=".0";return l}return o};return!!satisfy(n(r),`<=${n(t)}`)}const findVersion=(r,t)=>{const n=t||function(o,s){return versionLt(o,s)};return Object.keys(r).reduce((o,s)=>!o||n(o,s)||o==="0"?s:o,0)},isLoaded=r=>!!r.loaded||typeof r.lib=="function",isLoading=r=>!!r.loading;function findSingletonVersionOrderByVersion(r,t,n){const o=r[t][n],s=function(a,l){return!isLoaded(o[a])&&versionLt(a,l)};return findVersion(r[t][n],s)}function findSingletonVersionOrderByLoaded(r,t,n){const o=r[t][n],s=function(a,l){const i=c=>isLoaded(c)||isLoading(c);return i(o[l])?i(o[a])?!!versionLt(a,l):!0:i(o[a])?!1:versionLt(a,l)};return findVersion(r[t][n],s)}function getFindShareFunction(r){return r==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(r,t,n,o){if(!r)return;const{shareConfig:s,scope:a=DEFAULT_SCOPE,strategy:l}=n,i=Array.isArray(a)?a:[a];for(const c of i)if(s&&r[c]&&r[c][t]){const{requiredVersion:u}=s,h=getFindShareFunction(l)(r,c,t),p=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(h,u)){const b=`Version ${h} from ${h&&r[c][t][h].from} of shared singleton module ${t} does not satisfy the requirement of ${n.from} which needs ${u})`;s.strictVersion?error(b):warn(b)}return r[c][t][h]}else{if(u===!1||u==="*"||satisfy(h,u))return r[c][t][h];for(const[b,y]of Object.entries(r[c][t]))if(satisfy(b,u))return y}},m={shareScopeMap:r,scope:c,pkgName:t,version:h,GlobalFederation:Global.__FEDERATION__,resolver:p};return(o.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(r){const{pkgName:t,extraOptions:n,shareInfos:o}=r,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 a;const l=(a=n==null?void 0:n.resolver)!=null?a:s;return Object.assign({},l(o[t]),n==null?void 0:n.customShareInfo)}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",TYPE_001="TYPE-001",getDocsUrl=r=>`https://module-federation.io/guide/troubleshooting/${r.split("-")[0].toLowerCase()}/${r}`,getShortErrorMsg=(r,t,n,o)=>{const s=[`${[t[r]]} #${r}`];return n&&s.push(`args: ${JSON.stringify(n)}`),s.push(getDocsUrl(r)),o&&s.push(`Original Error Message:
8
8
  ${o}`),s.join(`
9
9
  `)};function _extends(){return _extends=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s])}return t},_extends.apply(this,arguments)}const runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot."},typeDescMap={[TYPE_001]:"Failed to generate type declaration."};_extends({},runtimeDescMap,typeDescMap);function matchRemoteWithNameAndExpose(r,t){for(const n of r){const o=t.startsWith(n.name);let s=t.replace(n.name,"");if(o){if(s.startsWith("/")){const i=n.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:n}}else if(s==="")return{pkgNameOrAlias:n.name,expose:".",remote:n}}const a=n.alias&&t.startsWith(n.alias);let l=n.alias&&t.replace(n.alias,"");if(n.alias&&a){if(l&&l.startsWith("/")){const i=n.alias;return l=`.${l}`,{pkgNameOrAlias:i,expose:l,remote:n}}else if(l==="")return{pkgNameOrAlias:n.alias,expose:".",remote:n}}}}function matchRemote(r,t){for(const n of r)if(t===n.name||n.alias&&t===n.alias)return n}function registerPlugins$1(r,t){const n=getGlobalHostPlugins();return n.length>0&&n.forEach(o=>{r!=null&&r.find(s=>s.name!==o.name)&&r.push(o)}),r&&r.length>0&&r.forEach(o=>{t.forEach(s=>{s.applyPlugin(o)})}),r}async function loadEsmEntry({entry:r,remoteEntryExports:t}){return new Promise((n,o)=>{try{t?n(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${r}").then(callbacks[0]).catch(callbacks[1])`)([n,o]):import(r).then(n).catch(o)}catch(s){o(s)}})}async function loadSystemJsEntry({entry:r,remoteEntryExports:t}){return new Promise((n,o)=>{try{t?n(t):typeof __system_context__>"u"?System.import(r).then(n).catch(o):new Function("callbacks",`System.import("${r}").then(callbacks[0]).catch(callbacks[1])`)([n,o])}catch(s){o(s)}})}async function loadEntryScript({name:r,globalName:t,entry:n,loaderHook:o}){const{entryExports:s}=getRemoteEntryExports(r,t);return s||loadScript(n,{attrs:{},createScriptHook:(a,l)=>{const i=o.lifecycle.createScript.emit({url:a,attrs:l});if(i&&(i instanceof HTMLScriptElement||"script"in i||"timeout"in i))return i}}).then(()=>{const{remoteEntryKey:a,entryExports:l}=getRemoteEntryExports(r,t);return assert(l,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:r,remoteEntryUrl:n,remoteEntryKey:a})),l}).catch(a=>{throw a})}async function loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:n}){const{entry:o,entryGlobalName:s,name:a,type:l}=r;switch(l){case"esm":case"module":return loadEsmEntry({entry:o,remoteEntryExports:t});case"system":return loadSystemJsEntry({entry:o,remoteEntryExports:t});default:return loadEntryScript({entry:o,globalName:s,name:a,loaderHook:n})}}async function loadEntryNode({remoteInfo:r,loaderHook:t}){const{entry:n,entryGlobalName:o,name:s,type:a}=r,{entryExports:l}=getRemoteEntryExports(s,o);return l||loadScriptNode(n,{attrs:{name:s,globalName:o,type:a},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,o);return assert(c,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:s,remoteEntryUrl:n,remoteEntryKey:i})),c}).catch(i=>{throw i})}function getRemoteEntryUniqueKey(r){const{entry:t,name:n}=r;return composeKeyWithSeparator(n,t)}async function getRemoteEntry({origin:r,remoteEntryExports:t,remoteInfo:n}){const o=getRemoteEntryUniqueKey(n);if(t)return t;if(!globalLoading[o]){const s=r.remoteHandler.hooks.lifecycle.loadEntry,a=r.loaderHook;globalLoading[o]=s.emit({loaderHook:a,remoteInfo:n,remoteEntryExports:t}).then(l=>l||(isBrowserEnv()?loadEntryDom({remoteInfo:n,remoteEntryExports:t,loaderHook:a}):loadEntryNode({remoteInfo:n,loaderHook:a})))}return globalLoading[o]}function getRemoteInfo(r){return _extends$1({},r,{entry:"entry"in r?r.entry:"",type:r.type||DEFAULT_REMOTE_TYPE,entryGlobalName:r.entryGlobalName||r.name,shareScope:r.shareScope||DEFAULT_SCOPE})}let Module=class{async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let t;try{t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports})}catch{const o=getRemoteEntryUniqueKey(this.remoteInfo);t=await this.host.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry,origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports,globalLoading,uniqueKey:o})}return assert(t,`remoteEntryExports is undefined
10
- ${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,n,o,s){const{loadFactory:a=!0}=o||{loadFactory:!0},l=await this.getEntry();if(!this.inited){const h=this.host.shareScopeMap,p=this.remoteInfo.shareScope||"default";h[p]||(h[p]={});const m=h[p],g=[],b={version:this.remoteInfo.version||""};Object.defineProperty(b,"shareScopeMap",{value:h,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:b,initScope:g,remoteInfo:this.remoteInfo,origin:this.host});typeof(l==null?void 0:l.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{remoteName:name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await l.init(y.shareScope,y.initScope,y.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit(_extends$1({},y,{id:t,remoteSnapshot:s,remoteEntryExports:l}))}this.lib=l,this.inited=!0;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:l,expose:n,moduleInfo:this.remoteInfo}),i||(i=await l.get(n)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${n}.`);const c=processModuleAlias(this.remoteInfo.name,n),u=this.wraperFactory(i,c);return a?await u():u}wraperFactory(t,n){function o(s,a){s&&typeof s=="object"&&Object.isExtensible(s)&&!Object.getOwnPropertyDescriptor(s,Symbol.for("mf_module_id"))&&Object.defineProperty(s,Symbol.for("mf_module_id"),{value:a,enumerable:!1})}return t instanceof Promise?async()=>{const s=await t();return o(s,n),s}:()=>{const s=t();return o(s,n),s}}constructor({remoteInfo:t,host:n}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=n}};class SyncHook{on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const n=this;this.on(function o(...s){return n.remove(o),t.apply(null,s)})}emit(...t){let n;return this.listeners.size>0&&this.listeners.forEach(o=>{n=o(...t)}),n}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}}class AsyncHook extends SyncHook{emit(...t){let n;const o=Array.from(this.listeners);if(o.length>0){let s=0;const a=l=>l===!1?!1:s<o.length?Promise.resolve(o[s++].apply(null,t)).then(a):l;n=a()}return Promise.resolve(n)}}function checkReturnData(r,t){if(!isObject(t))return!1;if(r!==t){for(const n in r)if(!(n in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const n of this.listeners)try{const o=n(t);if(checkReturnData(t,o))t=o;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(o){warn(o),this.onerror(o)}return t}constructor(t){super(),this.onerror=error,this.type=t}}class AsyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const n=Array.from(this.listeners);if(n.length>0){let o=0;const s=l=>(warn(l),this.onerror(l),t),a=l=>{if(checkReturnData(t,l)){if(t=l,o<n.length)try{return Promise.resolve(n[o++](t)).then(a,s)}catch(i){return s(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return t};return Promise.resolve(a(t))}return Promise.resolve(t)}constructor(t){super(),this.onerror=error,this.type=t}}class PluginSystem{applyPlugin(t){assert(isPlainObject(t),"Plugin configuration is invalid.");const n=t.name;assert(n,"A name must be provided by the plugin."),this.registerPlugins[n]||(this.registerPlugins[n]=t,Object.keys(this.lifecycle).forEach(o=>{const s=t[o];s&&this.lifecycle[o].on(s)}))}removePlugin(t){assert(t,"A name is required.");const n=this.registerPlugins[t];assert(n,`The plugin "${t}" is not registered.`),Object.keys(n).forEach(o=>{o!=="name"&&this.lifecycle[o].remove(n[o])})}inherit({lifecycle:t,registerPlugins:n}){Object.keys(t).forEach(o=>{assert(!this.lifecycle[o],`The hook "${o}" has a conflict and cannot be inherited.`),this.lifecycle[o]=t[o]}),Object.keys(n).forEach(o=>{assert(!this.registerPlugins[o],`The plugin "${o}" has a conflict and cannot be inherited.`),this.applyPlugin(n[o])})}constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}}function defaultPreloadArgs(r){return _extends$1({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},r)}function formatPreloadArgs(r,t){return t.map(n=>{const o=matchRemote(r,n.nameOrAlias);return assert(o,`Unable to preload ${n.nameOrAlias} as it is not included in ${!o&&safeToString({remoteInfo:o,remotes:r})}`),{remote:o,preloadConfig:defaultPreloadArgs(n)}})}function normalizePreloadExposes(r){return r?r.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(r,t,n,o=!0){const{cssAssets:s,jsAssetsWithoutEntry:a,entryAssets:l}=n;if(t.options.inBrowser){if(l.forEach(i=>{const{moduleInfo:c}=i,u=t.moduleCache.get(r.name);getRemoteEntry(u?{origin:t,remoteInfo:c,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:c,remoteEntryExports:void 0})}),o){const i={rel:"preload",as:"style"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m}});d&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});d&&document.head.appendChild(u)})}if(o){const i={rel:"preload",as:"script"};a.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:(r==null?void 0:r.type)==="module"?"module":"text/javascript"};a.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(r,t){const n=getRemoteEntryInfoFromSnapshot(t);n.url||error(`The attribute remoteEntry of ${r.name} must not be undefined.`);let o=getResourceUrl(t,n.url);!isBrowserEnv()&&!o.startsWith("http")&&(o=`https:${o}`),r.type=n.type,r.entryGlobalName=n.globalName,r.entry=o,r.version=t.version,r.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(r){const{remote:t,pkgNameOrAlias:n,expose:o,origin:s,remoteInfo:a}=r;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:l,globalSnapshot:i}=await s.snapshotHandler.loadRemoteSnapshotInfo(t);assignRemoteInfo(a,l);const c={remote:t,preloadConfig:{nameOrAlias:n,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},u=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:c,remoteInfo:a,remote:t,remoteSnapshot:l,globalSnapshot:i});return u&&preloadAssets(a,s,u,!1),_extends$1({},r,{remoteSnapshot:l})}return r}}}function splitId(r){const t=r.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function traverseModuleInfo(r,t,n,o,s={},a){const l=getFMId(t),{value:i}=getInfoWithoutType(r,l),c=a||i;if(c&&!isManifestProvider(c)&&(n(c,t,o),c.remotesInfo)){const u=Object.keys(c.remotesInfo);for(const d of u){if(s[d])continue;s[d]=!0;const h=splitId(d),p=c.remotesInfo[d];traverseModuleInfo(r,{name:h.name,version:p.matchedVersion},n,!1,s,void 0)}}}function generatePreloadAssets(r,t,n,o,s){const a=[],l=[],i=[],c=new Set,u=new Set,{options:d}=r,{preloadConfig:h}=t,{depsRemote:p}=h;if(traverseModuleInfo(o,n,(y,_,v)=>{let S;if(v)S=h;else if(Array.isArray(p)){const A=p.find(w=>w.nameOrAlias===_.name||w.nameOrAlias===_.alias);if(!A)return;S=defaultPreloadArgs(A)}else if(p===!0)S=h;else return;const R=getResourceUrl(y,getRemoteEntryInfoFromSnapshot(y).url);R&&i.push({name:_.name,moduleInfo:{name:_.name,entry:R,type:"remoteEntryType"in y?y.remoteEntryType:"global",entryGlobalName:"globalName"in y?y.globalName:_.name,shareScope:"",version:"version"in y?y.version:void 0},url:R});let E="modules"in y?y.modules:[];const I=normalizePreloadExposes(S.exposes);if(I.length&&"modules"in y){var O;E=y==null||(O=y.modules)==null?void 0:O.reduce((A,w)=>((I==null?void 0:I.indexOf(w.moduleName))!==-1&&A.push(w),A),[])}function $(A){const w=A.map(P=>getResourceUrl(y,P));return S.filter?w.filter(S.filter):w}if(E){const A=E.length;for(let w=0;w<A;w++){const P=E[w],T=`${_.name}/${P.moduleName}`;r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:P.moduleName==="."?_.name:T,name:_.name,remoteSnapshot:y,preloadConfig:S,remote:_,origin:r}),!getPreloaded(T)&&(S.resourceCategory==="all"?(a.push(...$(P.assets.css.async)),a.push(...$(P.assets.css.sync)),l.push(...$(P.assets.js.async)),l.push(...$(P.assets.js.sync))):(S.resourceCategory="sync")&&(a.push(...$(P.assets.css.sync)),l.push(...$(P.assets.js.sync))),setPreloaded(T))}}},!0,{},s),s.shared){const y=(_,v)=>{const S=getRegisteredShare(r.shareScopeMap,v.sharedName,_,r.sharedHandler.hooks.lifecycle.resolveShare);S&&typeof S.lib=="function"&&(v.assets.js.sync.forEach(R=>{c.add(R)}),v.assets.css.sync.forEach(R=>{u.add(R)}))};s.shared.forEach(_=>{var v;const S=(v=d.shared)==null?void 0:v[_.sharedName];if(!S)return;const R=_.version?S.find(I=>I.version===_.version):S;if(!R)return;arrayOptions(R).forEach(I=>{y(I,_)})})}const g=l.filter(y=>!c.has(y));return{cssAssets:a.filter(y=>!u.has(y)),jsAssetsWithoutEntry:g,entryAssets:i}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(r){const{origin:t,preloadOptions:n,remoteInfo:o,remote:s,globalSnapshot:a,remoteSnapshot:l}=r;return isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:o.name,entry:s.entry,type:o.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(o,l),generatePreloadAssets(t,n,o,a,l))}}};function getGlobalRemoteInfo(r,t){const n=getGlobalSnapshotInfoByModuleInfo({name:t.options.name,version:t.options.version}),o=n&&"remotesInfo"in n&&n.remotesInfo&&getInfoWithoutType(n.remotesInfo,r.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:n,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:o.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:"version"in r?r.version:void 0})}}class SnapshotHandler{async loadSnapshot(t){const{options:n}=this.HostInstance,{hostGlobalSnapshot:o,remoteSnapshot:s,globalSnapshot:a}=this.getGlobalRemoteInfo(t),{remoteSnapshot:l,globalSnapshot:i}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:t,hostGlobalSnapshot:o,remoteSnapshot:s,globalSnapshot:a});return{remoteSnapshot:l,globalSnapshot:i}}async loadRemoteSnapshotInfo(t){const{options:n}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:n,moduleInfo:t});let o=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});o||(o={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:o})),o&&"remotesInfo"in o&&!getInfoWithoutType(o.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(o.remotesInfo=_extends$1({},o==null?void 0:o.remotesInfo,{[t.name]:{matchedVersion:"version"in t?t.version:t.entry}}));const{hostGlobalSnapshot:s,remoteSnapshot:a,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:i,globalSnapshot:c}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:t,hostGlobalSnapshot:s,remoteSnapshot:a,globalSnapshot:l});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:n,moduleInfo:t,remoteSnapshot:u}),{remoteSnapshot:u,globalSnapshot:d}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,n,o){const s=async()=>{let l=this.manifestCache.get(t);if(l)return l;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});return(!i||!(i instanceof Response))&&(i=await fetch(t,{})),l=await i.json(),assert(l.metaData&&l.exposes&&l.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,l),l}catch(i){delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:n.name},`${i}`))}},a=async()=>{const l=await s(),i=generateSnapshotFromManifest(l,{version:t}),{remoteSnapshot:c}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:n,manifestJson:l,remoteSnapshot:i,manifestUrl:t,from:"manifest"});return c};return this.manifestLoading[t]||(this.manifestLoading[t]=a().then(l=>l)),this.manifestLoading[t]}constructor(t){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new PluginSystem({beforeLoadRemoteSnapshot:new AsyncHook("beforeLoadRemoteSnapshot"),loadSnapshot:new AsyncWaterfallHook("loadGlobalSnapshot"),loadRemoteSnapshot:new AsyncWaterfallHook("loadRemoteSnapshot"),afterLoadSnapshot:new AsyncWaterfallHook("afterLoadSnapshot")}),this.manifestLoading=Global.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=t,this.loaderHook=t.loaderHook}}class SharedHandler{registerShared(t,n){const{shareInfos:o,shared:s}=formatShareConfigs(t,n);return Object.keys(o).forEach(l=>{o[l].forEach(c=>{!getRegisteredShare(this.shareScopeMap,l,c,this.hooks.lifecycle.resolveShare)&&c&&c.lib&&this.setShared({pkgName:l,lib:c.lib,get:c.get,loaded:!0,shared:c,from:n.name})})}),{shareInfos:o,shared:s}}async loadShare(t,n){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:o.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const a=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:o.options.shared,origin:o}),{shareInfo:l}=a;assert(l,`Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare),c=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,o.options.name)};if(i&&i.lib)return c(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),c(i),u}else if(i){const d=(async()=>{const h=await i.get();l.lib=h,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0),h})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:o.options.name,lib:null,loading:d}),d}else{if(n!=null&&n.customShareInfo)return!1;const d=(async()=>{const h=await l.get();l.lib=h,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0),h})();return this.setShared({pkgName:t,loaded:!1,shared:l,from:o.options.name,lib:null,loading:d}),d}}initializeSharing(t=DEFAULT_SCOPE,n){const{host:o}=this,s=n==null?void 0:n.from,a=n==null?void 0:n.strategy;let l=n==null?void 0:n.initScope;const i=[];if(s!=="build"){const{initTokens:g}=this;l||(l=[]);let b=g[t];if(b||(b=g[t]={from:this.host.name}),l.indexOf(b)>=0)return i;l.push(b)}const c=this.shareScopeMap,u=o.options.name;c[t]||(c[t]={});const d=c[t],h=(g,b)=>{var y;const{version:_,eager:v}=b;d[g]=d[g]||{};const S=d[g],R=S[_],E=!!(R&&(R.eager||(y=R.shareConfig)!=null&&y.eager));(!R||R.strategy!=="loaded-first"&&!R.loaded&&(!v!=!E?v:u>R.from))&&(S[_]=b)},p=g=>g&&g.init&&g.init(c[t],l),m=async g=>{const{module:b}=await o.remoteHandler.getRemoteModuleAndOptions({id:g});if(b.getEntry){let y;try{y=await b.getEntry()}catch(_){y=await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:g,error:_,from:"runtime",lifecycle:"beforeLoadShare",origin:o})}b.inited||(await p(y),b.inited=!0)}};return Object.keys(o.options.shared).forEach(g=>{o.options.shared[g].forEach(y=>{y.scope.includes(t)&&h(g,y)})}),(o.options.shareStrategy==="version-first"||a==="version-first")&&o.options.remotes.forEach(g=>{g.shareScope===t&&i.push(m(g.name))}),i}loadShareSync(t,n){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:o.options.shared});s!=null&&s.scope&&s.scope.forEach(i=>{this.initializeSharing(i,{strategy:s.strategy})});const a=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),l=i=>{i.useIn||(i.useIn=[]),addUniqueItem(i.useIn,o.options.name)};if(a){if(typeof a.lib=="function")return l(a),a.loaded||(a.loaded=!0,a.from===o.options.name&&(s.loaded=!0)),a.lib;if(typeof a.get=="function"){const i=a.get();if(!(i instanceof Promise))return l(a),this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:i,shared:a}),i}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const i=s.get();if(i instanceof Promise){const c=(n==null?void 0:n.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(c,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}initShareScopeMap(t,n,o={}){const{host:s}=this;this.shareScopeMap[t]=n,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:n,options:s.options,origin:s,scopeName:t,hostShareScopeMap:o.hostShareScopeMap})}setShared({pkgName:t,shared:n,from:o,lib:s,loading:a,loaded:l,get:i}){const{version:c,scope:u="default"}=n,d=_object_without_properties_loose(n,["version","scope"]);(Array.isArray(u)?u:[u]).forEach(p=>{if(this.shareScopeMap[p]||(this.shareScopeMap[p]={}),this.shareScopeMap[p][t]||(this.shareScopeMap[p][t]={}),!this.shareScopeMap[p][t][c]){this.shareScopeMap[p][t][c]=_extends$1({version:c,scope:["default"]},d,{lib:s,loaded:l,loading:a}),i&&(this.shareScopeMap[p][t][c].get=i);return}const m=this.shareScopeMap[p][t][c];a&&!m.loading&&(m.loading=a)})}_setGlobalShareScopeMap(t){const n=getGlobalShareScope(),o=t.id||t.name;o&&!n[o]&&(n[o]=this.shareScopeMap)}constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}}class RemoteHandler{formatAndRegisterRemote(t,n){return(n.remotes||[]).reduce((s,a)=>(this.registerRemote(a,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,n){const{remote:o,expose:s}=n,{name:a,alias:l}=o;if(this.idToRemoteMap[t]={name:o.name,expose:s},l&&t.startsWith(a)){const i=t.replace(a,l);this.idToRemoteMap[i]={name:o.name,expose:s};return}if(l&&t.startsWith(l)){const i=t.replace(l,a);this.idToRemoteMap[i]={name:o.name,expose:s}}}async loadRemote(t,n){const{host:o}=this;try{const{loadFactory:s=!0}=n||{loadFactory:!0},{module:a,moduleOptions:l,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:c,remote:u,expose:d,id:h,remoteSnapshot:p}=i,m=await a.get(h,d,n,p),g=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:l,moduleInstance:a,origin:o});return this.setIdToRemoteMap(t,i),typeof g=="function"?g:m}catch(s){const{from:a="runtime"}=n||{from:"runtime"},l=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:a,lifecycle:"onLoad",origin:o});if(!l)throw s;return l}}async preloadRemote(t){const{host:n}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:n.options,origin:n});const o=formatPreloadArgs(n.options.remotes,t);await Promise.all(o.map(async s=>{const{remote:a}=s,l=getRemoteInfo(a),{globalSnapshot:i,remoteSnapshot:c}=await n.snapshotHandler.loadRemoteSnapshotInfo(a),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:n,preloadOptions:s,remote:a,remoteInfo:l,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(l,n,u)}))}registerRemotes(t,n){const{host:o}=this;t.forEach(s=>{this.registerRemote(s,o.options.remotes,{force:n==null?void 0:n.force})})}async getRemoteModuleAndOptions(t){const{host:n}=this,{id:o}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:n.options,origin:n})}catch(g){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:n.options,origin:n,from:"runtime",error:g,lifecycle:"beforeRequest"}),!s)throw g}const{id:a}=s,l=matchRemoteWithNameAndExpose(n.options.remotes,a);assert(l,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:n.options.name,requestId:a}));const{remote:i}=l,c=getRemoteInfo(i),u=await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:a},l,{options:n.options,origin:n,remoteInfo:c})),{remote: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 ${a}.`);let p=n.moduleCache.get(d.name);const m={host:n,remoteInfo:c};return p||(p=new Module(m),n.moduleCache.set(d.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,n,o){const{host:s}=this,a=()=>{if(t.alias){const i=n.find(c=>{var u;return t.alias&&(c.name.startsWith(t.alias)||((u=c.alias)==null?void 0:u.startsWith(t.alias)))});assert(!i,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const l=n.find(i=>i.name===t.name);if(!l)a(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];o!=null&&o.force&&(this.removeRemote(l),a(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){try{const{host:o}=this,{name:s}=t,a=o.options.remotes.findIndex(i=>i.name===s);a!==-1&&o.options.remotes.splice(a,1);const l=o.moduleCache.get(t.name);if(l){const i=l.remoteInfo,c=i.entryGlobalName;if(CurrentGlobal[c]){var n;(n=Object.getOwnPropertyDescriptor(CurrentGlobal,c))!=null&&n.configurable?delete CurrentGlobal[c]:CurrentGlobal[c]=void 0}const u=getRemoteEntryUniqueKey(l.remoteInfo);globalLoading[u]&&delete globalLoading[u],o.snapshotHandler.manifestCache.delete(i.entry);let d=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const h=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===d:m.name===d);if(h!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[h];d=m.options.id||d;const g=getGlobalShareScope();let b=!0;const y=[];Object.keys(g).forEach(_=>{const v=g[_];v&&Object.keys(v).forEach(S=>{const R=v[S];R&&Object.keys(R).forEach(E=>{const I=R[E];I&&Object.keys(I).forEach(O=>{const $=I[O];$&&typeof $=="object"&&$.from===i.name&&($.loaded||$.loading?($.useIn=$.useIn.filter(A=>A!==i.name),$.useIn.length?b=!1:y.push([_,S,E,O])):y.push([_,S,E,O]))})})})}),b&&(m.shareScopeMap={},delete g[d]),y.forEach(([_,v,S,R])=>{var E,I,O;(O=g[_])==null||(I=O[v])==null||(E=I[S])==null||delete E[R]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(h,1)}const{hostGlobalSnapshot:p}=getGlobalRemoteInfo(t,o);if(p){const m=p&&"remotesInfo"in p&&p.remotesInfo&&getInfoWithoutType(p.remotesInfo,t.name).key;m&&(delete p.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}o.moduleCache.delete(t.name)}}catch(o){logger.log("removeRemote fail: ",o)}}constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}}class FederationHost{initOptions(t){this.registerPlugins(t.plugins);const n=this.formatOptions(this.options,t);return this.options=n,n}async loadShare(t,n){return this.sharedHandler.loadShare(t,n)}loadShareSync(t,n){return this.sharedHandler.loadShareSync(t,n)}initializeSharing(t=DEFAULT_SCOPE,n){return this.sharedHandler.initializeSharing(t,n)}initRawContainer(t,n,o){const s=getRemoteInfo({name:t,entry:n}),a=new Module({host:this,remoteInfo:s});return a.remoteEntryExports=o,this.moduleCache.set(t,a),a}async loadRemote(t,n){return this.remoteHandler.loadRemote(t,n)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,n,o={}){this.sharedHandler.initShareScopeMap(t,n,o)}formatOptions(t,n){const{shared:o}=formatShareConfigs(t,n),{userOptions:s,options:a}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:n,options:t,shareInfo:o}),l=this.remoteHandler.formatAndRegisterRemote(a,s),{shared:i}=this.sharedHandler.registerShared(a,s),c=[...a.plugins];s.plugins&&s.plugins.forEach(d=>{c.includes(d)||c.push(d)});const u=_extends$1({},t,n,{plugins:c,remotes:l,shared:i});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const n=registerPlugins$1(t,[this.hooks,this.remoteHandler.hooks,this.sharedHandler.hooks,this.snapshotHandler.hooks,this.loaderHook,this.bridgeHook]);this.options.plugins=this.options.plugins.reduce((o,s)=>(s&&o&&!o.find(a=>a.name===s.name)&&o.push(s),o),n||[])}registerRemotes(t,n){return this.remoteHandler.registerRemotes(t,n)}constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.8.5",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const n={id:getBuilderId(),name:t.name,plugins:[snapshotPlugin(),generatePreloadAssetsPlugin()],remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=n,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...n.plugins,...t.plugins||[]]),this.options=this.formatOptions(n,t)}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(FederationHost);function createBridgeComponent(r){const t=new Map,n=getInstance();return()=>({__APP_VERSION__:"0.8.5",async render(o){var c,u,d;LoggerInstance.log("createBridgeComponent render Info",o);const s=Vue__namespace.createApp(r.rootComponent);t.set(o.dom,s);const a=await((d=(u=(c=n==null?void 0:n.bridgeHook)==null?void 0:c.lifecycle)==null?void 0:u.beforeBridgeRender)==null?void 0:d.emit(o)),l=a&&typeof a=="object"&&(a!=null&&a.extraProps)?a==null?void 0:a.extraProps:{},i=r.appOptions({app:s,basename:o.basename,memoryRoute:o.memoryRoute,...l});if(i!=null&&i.router){const h=o.memoryRoute?VueRouter__namespace.createMemoryHistory(o.basename):VueRouter__namespace.createWebHistory(o.basename),p=VueRouter__namespace.createRouter({...i.router.options,history:h,routes:i.router.getRoutes()});LoggerInstance.log("createBridgeComponent render router info>>>",{name:o.moduleName,router:p}),o.memoryRoute&&await p.push(o.memoryRoute.entryPath),s.use(p)}s.mount(o.dom)},destroy(o){LoggerInstance.log("createBridgeComponent destroy Info",o);const s=t.get(o==null?void 0:o.dom);s==null||s.unmount()}})}function e(){const r=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(r)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,providerInfo:Function},setup(r){const t=Vue.ref(null),n=Vue.ref(null),o=Vue.ref(""),s=VueRouter.useRoute(),a=()=>{var d;const i=(d=r.providerInfo)==null?void 0:d.call(r);n.value=i;let c={name:r.moduleName,dom:t.value,basename:r.basename,memoryRoute:r.memoryRoute};LoggerInstance.log("createRemoteComponent LazyComponent render >>>",c),c={...c,...{}.extraProps},i.render(c)},l=Vue.watch(()=>s.path,i=>{i!==s.path&&a(),o.value!==""&&o.value!==i&&(LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>",{...r,pathname:s.path}),e()),o.value=i});return Vue.onMounted(()=>{a()}),Vue.onBeforeUnmount(()=>{var i;LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>",{...r}),l(),(i=n.value)==null||i.destroy({dom:t.value})}),()=>Vue.createVNode("div",{ref:t},null)}});function createRemoteComponent(r){return Vue.defineAsyncComponent({__APP_VERSION__:"0.8.5",...r.asyncComponentOptions,loader:async()=>{var c;const t=VueRouter.useRoute();let n="/";const o=(c=t.matched[0])==null?void 0:c.path;o&&(o.endsWith("/:pathMatch(.*)*")?n=o.replace("/:pathMatch(.*)*",""):n=t.matched[0].path);const s=(r==null?void 0:r.export)||"default";LoggerInstance.log("createRemoteComponent LazyComponent create >>>",{basename:n,info:r});const a=await r.loader(),l=a&&a[Symbol.for("mf_module_id")],i=a[s];if(LoggerInstance.log("createRemoteComponent LazyComponent loadRemote info >>>",{name:l,module:a,exportName:s,basename:n,route:t}),s in a&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:l,providerInfo:i,basename:n})}};throw new Error("module not found")}})}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteComponent=createRemoteComponent;
10
+ ${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,n,o,s){const{loadFactory:a=!0}=o||{loadFactory:!0},l=await this.getEntry();if(!this.inited){const h=this.host.shareScopeMap,p=this.remoteInfo.shareScope||"default";h[p]||(h[p]={});const m=h[p],g=[],b={version:this.remoteInfo.version||""};Object.defineProperty(b,"shareScopeMap",{value:h,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:b,initScope:g,remoteInfo:this.remoteInfo,origin:this.host});typeof(l==null?void 0:l.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{remoteName:name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await l.init(y.shareScope,y.initScope,y.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit(_extends$1({},y,{id:t,remoteSnapshot:s,remoteEntryExports:l}))}this.lib=l,this.inited=!0;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:l,expose:n,moduleInfo:this.remoteInfo}),i||(i=await l.get(n)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${n}.`);const c=processModuleAlias(this.remoteInfo.name,n),u=this.wraperFactory(i,c);return a?await u():u}wraperFactory(t,n){function o(s,a){s&&typeof s=="object"&&Object.isExtensible(s)&&!Object.getOwnPropertyDescriptor(s,Symbol.for("mf_module_id"))&&Object.defineProperty(s,Symbol.for("mf_module_id"),{value:a,enumerable:!1})}return t instanceof Promise?async()=>{const s=await t();return o(s,n),s}:()=>{const s=t();return o(s,n),s}}constructor({remoteInfo:t,host:n}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=n}};class SyncHook{on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const n=this;this.on(function o(...s){return n.remove(o),t.apply(null,s)})}emit(...t){let n;return this.listeners.size>0&&this.listeners.forEach(o=>{n=o(...t)}),n}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}}class AsyncHook extends SyncHook{emit(...t){let n;const o=Array.from(this.listeners);if(o.length>0){let s=0;const a=l=>l===!1?!1:s<o.length?Promise.resolve(o[s++].apply(null,t)).then(a):l;n=a()}return Promise.resolve(n)}}function checkReturnData(r,t){if(!isObject(t))return!1;if(r!==t){for(const n in r)if(!(n in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const n of this.listeners)try{const o=n(t);if(checkReturnData(t,o))t=o;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(o){warn(o),this.onerror(o)}return t}constructor(t){super(),this.onerror=error,this.type=t}}class AsyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const n=Array.from(this.listeners);if(n.length>0){let o=0;const s=l=>(warn(l),this.onerror(l),t),a=l=>{if(checkReturnData(t,l)){if(t=l,o<n.length)try{return Promise.resolve(n[o++](t)).then(a,s)}catch(i){return s(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return t};return Promise.resolve(a(t))}return Promise.resolve(t)}constructor(t){super(),this.onerror=error,this.type=t}}class PluginSystem{applyPlugin(t){assert(isPlainObject(t),"Plugin configuration is invalid.");const n=t.name;assert(n,"A name must be provided by the plugin."),this.registerPlugins[n]||(this.registerPlugins[n]=t,Object.keys(this.lifecycle).forEach(o=>{const s=t[o];s&&this.lifecycle[o].on(s)}))}removePlugin(t){assert(t,"A name is required.");const n=this.registerPlugins[t];assert(n,`The plugin "${t}" is not registered.`),Object.keys(n).forEach(o=>{o!=="name"&&this.lifecycle[o].remove(n[o])})}inherit({lifecycle:t,registerPlugins:n}){Object.keys(t).forEach(o=>{assert(!this.lifecycle[o],`The hook "${o}" has a conflict and cannot be inherited.`),this.lifecycle[o]=t[o]}),Object.keys(n).forEach(o=>{assert(!this.registerPlugins[o],`The plugin "${o}" has a conflict and cannot be inherited.`),this.applyPlugin(n[o])})}constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}}function defaultPreloadArgs(r){return _extends$1({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},r)}function formatPreloadArgs(r,t){return t.map(n=>{const o=matchRemote(r,n.nameOrAlias);return assert(o,`Unable to preload ${n.nameOrAlias} as it is not included in ${!o&&safeToString({remoteInfo:o,remotes:r})}`),{remote:o,preloadConfig:defaultPreloadArgs(n)}})}function normalizePreloadExposes(r){return r?r.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(r,t,n,o=!0){const{cssAssets:s,jsAssetsWithoutEntry:a,entryAssets:l}=n;if(t.options.inBrowser){if(l.forEach(i=>{const{moduleInfo:c}=i,u=t.moduleCache.get(r.name);getRemoteEntry(u?{origin:t,remoteInfo:c,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:c,remoteEntryExports:void 0})}),o){const i={rel:"preload",as:"style"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m}});d&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(c=>{const{link:u,needAttach:d}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(h,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:p});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});d&&document.head.appendChild(u)})}if(o){const i={rel:"preload",as:"script"};a.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:(r==null?void 0:r.type)==="module"?"module":"text/javascript"};a.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(r,t){const n=getRemoteEntryInfoFromSnapshot(t);n.url||error(`The attribute remoteEntry of ${r.name} must not be undefined.`);let o=getResourceUrl(t,n.url);!isBrowserEnv()&&!o.startsWith("http")&&(o=`https:${o}`),r.type=n.type,r.entryGlobalName=n.globalName,r.entry=o,r.version=t.version,r.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(r){const{remote:t,pkgNameOrAlias:n,expose:o,origin:s,remoteInfo:a}=r;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:l,globalSnapshot:i}=await s.snapshotHandler.loadRemoteSnapshotInfo(t);assignRemoteInfo(a,l);const c={remote:t,preloadConfig:{nameOrAlias:n,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},u=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:c,remoteInfo:a,remote:t,remoteSnapshot:l,globalSnapshot:i});return u&&preloadAssets(a,s,u,!1),_extends$1({},r,{remoteSnapshot:l})}return r}}}function splitId(r){const t=r.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function traverseModuleInfo(r,t,n,o,s={},a){const l=getFMId(t),{value:i}=getInfoWithoutType(r,l),c=a||i;if(c&&!isManifestProvider(c)&&(n(c,t,o),c.remotesInfo)){const u=Object.keys(c.remotesInfo);for(const d of u){if(s[d])continue;s[d]=!0;const h=splitId(d),p=c.remotesInfo[d];traverseModuleInfo(r,{name:h.name,version:p.matchedVersion},n,!1,s,void 0)}}}function generatePreloadAssets(r,t,n,o,s){const a=[],l=[],i=[],c=new Set,u=new Set,{options:d}=r,{preloadConfig:h}=t,{depsRemote:p}=h;if(traverseModuleInfo(o,n,(y,_,v)=>{let S;if(v)S=h;else if(Array.isArray(p)){const A=p.find(w=>w.nameOrAlias===_.name||w.nameOrAlias===_.alias);if(!A)return;S=defaultPreloadArgs(A)}else if(p===!0)S=h;else return;const R=getResourceUrl(y,getRemoteEntryInfoFromSnapshot(y).url);R&&i.push({name:_.name,moduleInfo:{name:_.name,entry:R,type:"remoteEntryType"in y?y.remoteEntryType:"global",entryGlobalName:"globalName"in y?y.globalName:_.name,shareScope:"",version:"version"in y?y.version:void 0},url:R});let E="modules"in y?y.modules:[];const I=normalizePreloadExposes(S.exposes);if(I.length&&"modules"in y){var O;E=y==null||(O=y.modules)==null?void 0:O.reduce((A,w)=>((I==null?void 0:I.indexOf(w.moduleName))!==-1&&A.push(w),A),[])}function $(A){const w=A.map(P=>getResourceUrl(y,P));return S.filter?w.filter(S.filter):w}if(E){const A=E.length;for(let w=0;w<A;w++){const P=E[w],T=`${_.name}/${P.moduleName}`;r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:P.moduleName==="."?_.name:T,name:_.name,remoteSnapshot:y,preloadConfig:S,remote:_,origin:r}),!getPreloaded(T)&&(S.resourceCategory==="all"?(a.push(...$(P.assets.css.async)),a.push(...$(P.assets.css.sync)),l.push(...$(P.assets.js.async)),l.push(...$(P.assets.js.sync))):(S.resourceCategory="sync")&&(a.push(...$(P.assets.css.sync)),l.push(...$(P.assets.js.sync))),setPreloaded(T))}}},!0,{},s),s.shared){const y=(_,v)=>{const S=getRegisteredShare(r.shareScopeMap,v.sharedName,_,r.sharedHandler.hooks.lifecycle.resolveShare);S&&typeof S.lib=="function"&&(v.assets.js.sync.forEach(R=>{c.add(R)}),v.assets.css.sync.forEach(R=>{u.add(R)}))};s.shared.forEach(_=>{var v;const S=(v=d.shared)==null?void 0:v[_.sharedName];if(!S)return;const R=_.version?S.find(I=>I.version===_.version):S;if(!R)return;arrayOptions(R).forEach(I=>{y(I,_)})})}const g=l.filter(y=>!c.has(y));return{cssAssets:a.filter(y=>!u.has(y)),jsAssetsWithoutEntry:g,entryAssets:i}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(r){const{origin:t,preloadOptions:n,remoteInfo:o,remote:s,globalSnapshot:a,remoteSnapshot:l}=r;return isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:o.name,entry:s.entry,type:o.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(o,l),generatePreloadAssets(t,n,o,a,l))}}};function getGlobalRemoteInfo(r,t){const n=getGlobalSnapshotInfoByModuleInfo({name:t.options.name,version:t.options.version}),o=n&&"remotesInfo"in n&&n.remotesInfo&&getInfoWithoutType(n.remotesInfo,r.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:n,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:o.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:r.name,version:"version"in r?r.version:void 0})}}class SnapshotHandler{async loadSnapshot(t){const{options:n}=this.HostInstance,{hostGlobalSnapshot:o,remoteSnapshot:s,globalSnapshot:a}=this.getGlobalRemoteInfo(t),{remoteSnapshot:l,globalSnapshot:i}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:t,hostGlobalSnapshot:o,remoteSnapshot:s,globalSnapshot:a});return{remoteSnapshot:l,globalSnapshot:i}}async loadRemoteSnapshotInfo(t){const{options:n}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:n,moduleInfo:t});let o=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});o||(o={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:o})),o&&"remotesInfo"in o&&!getInfoWithoutType(o.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(o.remotesInfo=_extends$1({},o==null?void 0:o.remotesInfo,{[t.name]:{matchedVersion:"version"in t?t.version:t.entry}}));const{hostGlobalSnapshot:s,remoteSnapshot:a,globalSnapshot:l}=this.getGlobalRemoteInfo(t),{remoteSnapshot:i,globalSnapshot:c}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:t,hostGlobalSnapshot:s,remoteSnapshot:a,globalSnapshot:l});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:n,moduleInfo:t,remoteSnapshot:u}),{remoteSnapshot:u,globalSnapshot:d}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,n,o){const s=async()=>{let l=this.manifestCache.get(t);if(l)return l;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});return(!i||!(i instanceof Response))&&(i=await fetch(t,{})),l=await i.json(),assert(l.metaData&&l.exposes&&l.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,l),l}catch(i){delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:n.name},`${i}`))}},a=async()=>{const l=await s(),i=generateSnapshotFromManifest(l,{version:t}),{remoteSnapshot:c}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:n,manifestJson:l,remoteSnapshot:i,manifestUrl:t,from:"manifest"});return c};return this.manifestLoading[t]||(this.manifestLoading[t]=a().then(l=>l)),this.manifestLoading[t]}constructor(t){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new PluginSystem({beforeLoadRemoteSnapshot:new AsyncHook("beforeLoadRemoteSnapshot"),loadSnapshot:new AsyncWaterfallHook("loadGlobalSnapshot"),loadRemoteSnapshot:new AsyncWaterfallHook("loadRemoteSnapshot"),afterLoadSnapshot:new AsyncWaterfallHook("afterLoadSnapshot")}),this.manifestLoading=Global.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=t,this.loaderHook=t.loaderHook}}class SharedHandler{registerShared(t,n){const{shareInfos:o,shared:s}=formatShareConfigs(t,n);return Object.keys(o).forEach(l=>{o[l].forEach(c=>{!getRegisteredShare(this.shareScopeMap,l,c,this.hooks.lifecycle.resolveShare)&&c&&c.lib&&this.setShared({pkgName:l,lib:c.lib,get:c.get,loaded:!0,shared:c,from:n.name})})}),{shareInfos:o,shared:s}}async loadShare(t,n){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:o.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const a=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:o.options.shared,origin:o}),{shareInfo:l}=a;assert(l,`Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);const i=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare),c=u=>{u.useIn||(u.useIn=[]),addUniqueItem(u.useIn,o.options.name)};if(i&&i.lib)return c(i),i.lib;if(i&&i.loading&&!i.loaded){const u=await i.loading;return i.loaded=!0,i.lib||(i.lib=u),c(i),u}else if(i){const d=(async()=>{const h=await i.get();l.lib=h,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0),h})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:o.options.name,lib:null,loading:d}),d}else{if(n!=null&&n.customShareInfo)return!1;const d=(async()=>{const h=await l.get();l.lib=h,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=h,p.loaded=!0),h})();return this.setShared({pkgName:t,loaded:!1,shared:l,from:o.options.name,lib:null,loading:d}),d}}initializeSharing(t=DEFAULT_SCOPE,n){const{host:o}=this,s=n==null?void 0:n.from,a=n==null?void 0:n.strategy;let l=n==null?void 0:n.initScope;const i=[];if(s!=="build"){const{initTokens:g}=this;l||(l=[]);let b=g[t];if(b||(b=g[t]={from:this.host.name}),l.indexOf(b)>=0)return i;l.push(b)}const c=this.shareScopeMap,u=o.options.name;c[t]||(c[t]={});const d=c[t],h=(g,b)=>{var y;const{version:_,eager:v}=b;d[g]=d[g]||{};const S=d[g],R=S[_],E=!!(R&&(R.eager||(y=R.shareConfig)!=null&&y.eager));(!R||R.strategy!=="loaded-first"&&!R.loaded&&(!v!=!E?v:u>R.from))&&(S[_]=b)},p=g=>g&&g.init&&g.init(c[t],l),m=async g=>{const{module:b}=await o.remoteHandler.getRemoteModuleAndOptions({id:g});if(b.getEntry){let y;try{y=await b.getEntry()}catch(_){y=await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:g,error:_,from:"runtime",lifecycle:"beforeLoadShare",origin:o})}b.inited||(await p(y),b.inited=!0)}};return Object.keys(o.options.shared).forEach(g=>{o.options.shared[g].forEach(y=>{y.scope.includes(t)&&h(g,y)})}),(o.options.shareStrategy==="version-first"||a==="version-first")&&o.options.remotes.forEach(g=>{g.shareScope===t&&i.push(m(g.name))}),i}loadShareSync(t,n){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:n,shareInfos:o.options.shared});s!=null&&s.scope&&s.scope.forEach(i=>{this.initializeSharing(i,{strategy:s.strategy})});const a=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),l=i=>{i.useIn||(i.useIn=[]),addUniqueItem(i.useIn,o.options.name)};if(a){if(typeof a.lib=="function")return l(a),a.loaded||(a.loaded=!0,a.from===o.options.name&&(s.loaded=!0)),a.lib;if(typeof a.get=="function"){const i=a.get();if(!(i instanceof Promise))return l(a),this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:i,shared:a}),i}}if(s.lib)return s.loaded||(s.loaded=!0),s.lib;if(s.get){const i=s.get();if(i instanceof Promise){const c=(n==null?void 0:n.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(c,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}initShareScopeMap(t,n,o={}){const{host:s}=this;this.shareScopeMap[t]=n,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:n,options:s.options,origin:s,scopeName:t,hostShareScopeMap:o.hostShareScopeMap})}setShared({pkgName:t,shared:n,from:o,lib:s,loading:a,loaded:l,get:i}){const{version:c,scope:u="default"}=n,d=_object_without_properties_loose(n,["version","scope"]);(Array.isArray(u)?u:[u]).forEach(p=>{if(this.shareScopeMap[p]||(this.shareScopeMap[p]={}),this.shareScopeMap[p][t]||(this.shareScopeMap[p][t]={}),!this.shareScopeMap[p][t][c]){this.shareScopeMap[p][t][c]=_extends$1({version:c,scope:["default"]},d,{lib:s,loaded:l,loading:a}),i&&(this.shareScopeMap[p][t][c].get=i);return}const m=this.shareScopeMap[p][t][c];a&&!m.loading&&(m.loading=a)})}_setGlobalShareScopeMap(t){const n=getGlobalShareScope(),o=t.id||t.name;o&&!n[o]&&(n[o]=this.shareScopeMap)}constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}}class RemoteHandler{formatAndRegisterRemote(t,n){return(n.remotes||[]).reduce((s,a)=>(this.registerRemote(a,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,n){const{remote:o,expose:s}=n,{name:a,alias:l}=o;if(this.idToRemoteMap[t]={name:o.name,expose:s},l&&t.startsWith(a)){const i=t.replace(a,l);this.idToRemoteMap[i]={name:o.name,expose:s};return}if(l&&t.startsWith(l)){const i=t.replace(l,a);this.idToRemoteMap[i]={name:o.name,expose:s}}}async loadRemote(t,n){const{host:o}=this;try{const{loadFactory:s=!0}=n||{loadFactory:!0},{module:a,moduleOptions:l,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:c,remote:u,expose:d,id:h,remoteSnapshot:p}=i,m=await a.get(h,d,n,p),g=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:l,moduleInstance:a,origin:o});return this.setIdToRemoteMap(t,i),typeof g=="function"?g:m}catch(s){const{from:a="runtime"}=n||{from:"runtime"},l=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:a,lifecycle:"onLoad",origin:o});if(!l)throw s;return l}}async preloadRemote(t){const{host:n}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:n.options,origin:n});const o=formatPreloadArgs(n.options.remotes,t);await Promise.all(o.map(async s=>{const{remote:a}=s,l=getRemoteInfo(a),{globalSnapshot:i,remoteSnapshot:c}=await n.snapshotHandler.loadRemoteSnapshotInfo(a),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:n,preloadOptions:s,remote:a,remoteInfo:l,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(l,n,u)}))}registerRemotes(t,n){const{host:o}=this;t.forEach(s=>{this.registerRemote(s,o.options.remotes,{force:n==null?void 0:n.force})})}async getRemoteModuleAndOptions(t){const{host:n}=this,{id:o}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:n.options,origin:n})}catch(g){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:n.options,origin:n,from:"runtime",error:g,lifecycle:"beforeRequest"}),!s)throw g}const{id:a}=s,l=matchRemoteWithNameAndExpose(n.options.remotes,a);assert(l,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:n.options.name,requestId:a}));const{remote:i}=l,c=getRemoteInfo(i),u=await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:a},l,{options:n.options,origin:n,remoteInfo:c})),{remote: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 ${a}.`);let p=n.moduleCache.get(d.name);const m={host:n,remoteInfo:c};return p||(p=new Module(m),n.moduleCache.set(d.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,n,o){const{host:s}=this,a=()=>{if(t.alias){const i=n.find(c=>{var u;return t.alias&&(c.name.startsWith(t.alias)||((u=c.alias)==null?void 0:u.startsWith(t.alias)))});assert(!i,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const l=n.find(i=>i.name===t.name);if(!l)a(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];o!=null&&o.force&&(this.removeRemote(l),a(),n.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){try{const{host:o}=this,{name:s}=t,a=o.options.remotes.findIndex(i=>i.name===s);a!==-1&&o.options.remotes.splice(a,1);const l=o.moduleCache.get(t.name);if(l){const i=l.remoteInfo,c=i.entryGlobalName;if(CurrentGlobal[c]){var n;(n=Object.getOwnPropertyDescriptor(CurrentGlobal,c))!=null&&n.configurable?delete CurrentGlobal[c]:CurrentGlobal[c]=void 0}const u=getRemoteEntryUniqueKey(l.remoteInfo);globalLoading[u]&&delete globalLoading[u],o.snapshotHandler.manifestCache.delete(i.entry);let d=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const h=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===d:m.name===d);if(h!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[h];d=m.options.id||d;const g=getGlobalShareScope();let b=!0;const y=[];Object.keys(g).forEach(_=>{const v=g[_];v&&Object.keys(v).forEach(S=>{const R=v[S];R&&Object.keys(R).forEach(E=>{const I=R[E];I&&Object.keys(I).forEach(O=>{const $=I[O];$&&typeof $=="object"&&$.from===i.name&&($.loaded||$.loading?($.useIn=$.useIn.filter(A=>A!==i.name),$.useIn.length?b=!1:y.push([_,S,E,O])):y.push([_,S,E,O]))})})})}),b&&(m.shareScopeMap={},delete g[d]),y.forEach(([_,v,S,R])=>{var E,I,O;(O=g[_])==null||(I=O[v])==null||(E=I[S])==null||delete E[R]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(h,1)}const{hostGlobalSnapshot:p}=getGlobalRemoteInfo(t,o);if(p){const m=p&&"remotesInfo"in p&&p.remotesInfo&&getInfoWithoutType(p.remotesInfo,t.name).key;m&&(delete p.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}o.moduleCache.delete(t.name)}}catch(o){logger.log("removeRemote fail: ",o)}}constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}}class FederationHost{initOptions(t){this.registerPlugins(t.plugins);const n=this.formatOptions(this.options,t);return this.options=n,n}async loadShare(t,n){return this.sharedHandler.loadShare(t,n)}loadShareSync(t,n){return this.sharedHandler.loadShareSync(t,n)}initializeSharing(t=DEFAULT_SCOPE,n){return this.sharedHandler.initializeSharing(t,n)}initRawContainer(t,n,o){const s=getRemoteInfo({name:t,entry:n}),a=new Module({host:this,remoteInfo:s});return a.remoteEntryExports=o,this.moduleCache.set(t,a),a}async loadRemote(t,n){return this.remoteHandler.loadRemote(t,n)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,n,o={}){this.sharedHandler.initShareScopeMap(t,n,o)}formatOptions(t,n){const{shared:o}=formatShareConfigs(t,n),{userOptions:s,options:a}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:n,options:t,shareInfo:o}),l=this.remoteHandler.formatAndRegisterRemote(a,s),{shared:i}=this.sharedHandler.registerShared(a,s),c=[...a.plugins];s.plugins&&s.plugins.forEach(d=>{c.includes(d)||c.push(d)});const u=_extends$1({},t,n,{plugins:c,remotes:l,shared:i});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const n=registerPlugins$1(t,[this.hooks,this.remoteHandler.hooks,this.sharedHandler.hooks,this.snapshotHandler.hooks,this.loaderHook,this.bridgeHook]);this.options.plugins=this.options.plugins.reduce((o,s)=>(s&&o&&!o.find(a=>a.name===s.name)&&o.push(s),o),n||[])}registerRemotes(t,n){return this.remoteHandler.registerRemotes(t,n)}constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.8.5",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const n={id:getBuilderId(),name:t.name,plugins:[snapshotPlugin(),generatePreloadAssetsPlugin()],remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=n,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...n.plugins,...t.plugins||[]]),this.options=this.formatOptions(n,t)}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(FederationHost);function createBridgeComponent(r){const t=new Map,n=getInstance();return()=>({__APP_VERSION__:"0.8.5",async render(o){var c,u,d;LoggerInstance.debug("createBridgeComponent render Info",o);const s=Vue__namespace.createApp(r.rootComponent);t.set(o.dom,s);const a=await((d=(u=(c=n==null?void 0:n.bridgeHook)==null?void 0:c.lifecycle)==null?void 0:u.beforeBridgeRender)==null?void 0:d.emit(o)),l=a&&typeof a=="object"&&(a!=null&&a.extraProps)?a==null?void 0:a.extraProps:{},i=r.appOptions({app:s,basename:o.basename,memoryRoute:o.memoryRoute,...l});if(i!=null&&i.router){const h=o.memoryRoute?VueRouter__namespace.createMemoryHistory(o.basename):VueRouter__namespace.createWebHistory(o.basename),p=VueRouter__namespace.createRouter({...i.router.options,history:h,routes:i.router.getRoutes()});LoggerInstance.log("createBridgeComponent render router info>>>",{name:o.moduleName,router:p}),o.memoryRoute&&await p.push(o.memoryRoute.entryPath),s.use(p)}s.mount(o.dom)},destroy(o){LoggerInstance.debug("createBridgeComponent destroy Info",o);const s=t.get(o==null?void 0:o.dom);s==null||s.unmount()}})}function e(){const r=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(r)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,providerInfo:Function},setup(r){const t=Vue.ref(null),n=Vue.ref(null),o=Vue.ref(""),s=VueRouter.useRoute(),a=()=>{var d;const i=(d=r.providerInfo)==null?void 0:d.call(r);n.value=i;let c={name:r.moduleName,dom:t.value,basename:r.basename,memoryRoute:r.memoryRoute};LoggerInstance.debug("createRemoteComponent LazyComponent render >>>",c),c={...c,...{}.extraProps},i.render(c)},l=Vue.watch(()=>s.path,i=>{i!==s.path&&a(),o.value!==""&&o.value!==i&&(LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>",{...r,pathname:s.path}),e()),o.value=i});return Vue.onMounted(()=>{a()}),Vue.onBeforeUnmount(()=>{var i;LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>",{...r}),l(),(i=n.value)==null||i.destroy({dom:t.value})}),()=>Vue.createVNode("div",{ref:t},null)}});function createRemoteComponent(r){return Vue.defineAsyncComponent({__APP_VERSION__:"0.8.5",...r.asyncComponentOptions,loader:async()=>{var c;const t=VueRouter.useRoute();let n="/";const o=(c=t.matched[0])==null?void 0:c.path;o&&(o.endsWith("/:pathMatch(.*)*")?n=o.replace("/:pathMatch(.*)*",""):n=t.matched[0].path);const s=(r==null?void 0:r.export)||"default";LoggerInstance.debug("createRemoteComponent LazyComponent create >>>",{basename:n,info:r});const a=await r.loader(),l=a&&a[Symbol.for("mf_module_id")],i=a[s];if(LoggerInstance.debug("createRemoteComponent LazyComponent loadRemote info >>>",{name:l,module:a,exportName:s,basename:n,route:t}),s in a&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:l,providerInfo:i,basename:n})}};throw new Error("module not found")}})}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteComponent=createRemoteComponent;
package/dist/index.es.js CHANGED
@@ -2487,7 +2487,7 @@ function createBridgeComponent(r) {
2487
2487
  __APP_VERSION__: "0.8.5",
2488
2488
  async render(o) {
2489
2489
  var c, u, d;
2490
- LoggerInstance.log("createBridgeComponent render Info", o);
2490
+ LoggerInstance.debug("createBridgeComponent render Info", o);
2491
2491
  const s = Vue.createApp(r.rootComponent);
2492
2492
  t.set(o.dom, s);
2493
2493
  const a = await ((d = (u = (c = n == null ? void 0 : n.bridgeHook) == null ? void 0 : c.lifecycle) == null ? void 0 : u.beforeBridgeRender) == null ? void 0 : d.emit(o)), l = a && typeof a == "object" && (a != null && a.extraProps) ? a == null ? void 0 : a.extraProps : {}, i = r.appOptions({
@@ -2510,7 +2510,7 @@ function createBridgeComponent(r) {
2510
2510
  s.mount(o.dom);
2511
2511
  },
2512
2512
  destroy(o) {
2513
- LoggerInstance.log("createBridgeComponent destroy Info", o);
2513
+ LoggerInstance.debug("createBridgeComponent destroy Info", o);
2514
2514
  const s = t.get(o == null ? void 0 : o.dom);
2515
2515
  s == null || s.unmount();
2516
2516
  }
@@ -2539,12 +2539,12 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
2539
2539
  basename: r.basename,
2540
2540
  memoryRoute: r.memoryRoute
2541
2541
  };
2542
- LoggerInstance.log("createRemoteComponent LazyComponent render >>>", c), c = {
2542
+ LoggerInstance.debug("createRemoteComponent LazyComponent render >>>", c), c = {
2543
2543
  ...c,
2544
2544
  ...{}.extraProps
2545
2545
  }, i.render(c);
2546
2546
  }, l = watch(() => s.path, (i) => {
2547
- i !== s.path && a(), o.value !== "" && o.value !== i && (LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>", {
2547
+ i !== s.path && a(), o.value !== "" && o.value !== i && (LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>", {
2548
2548
  ...r,
2549
2549
  pathname: s.path
2550
2550
  }), e()), o.value = i;
@@ -2553,7 +2553,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
2553
2553
  a();
2554
2554
  }), onBeforeUnmount(() => {
2555
2555
  var i;
2556
- LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>", {
2556
+ LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>", {
2557
2557
  ...r
2558
2558
  }), l(), (i = n.value) == null || i.destroy({
2559
2559
  dom: t.value
@@ -2575,12 +2575,12 @@ function createRemoteComponent(r) {
2575
2575
  const o = (c = t.matched[0]) == null ? void 0 : c.path;
2576
2576
  o && (o.endsWith("/:pathMatch(.*)*") ? n = o.replace("/:pathMatch(.*)*", "") : n = t.matched[0].path);
2577
2577
  const s = (r == null ? void 0 : r.export) || "default";
2578
- LoggerInstance.log("createRemoteComponent LazyComponent create >>>", {
2578
+ LoggerInstance.debug("createRemoteComponent LazyComponent create >>>", {
2579
2579
  basename: n,
2580
2580
  info: r
2581
2581
  });
2582
2582
  const a = await r.loader(), l = a && a[Symbol.for("mf_module_id")], i = a[s];
2583
- if (LoggerInstance.log(
2583
+ if (LoggerInstance.debug(
2584
2584
  "createRemoteComponent LazyComponent loadRemote info >>>",
2585
2585
  { name: l, module: a, exportName: s, basename: n, route: t }
2586
2586
  ), s in a && typeof i == "function")
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-20241218093627",
10
+ "version": "0.0.0-next-20241224035007",
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
@@ -32,9 +32,9 @@
32
32
  "vue-router": "=3"
33
33
  },
34
34
  "dependencies": {
35
- "@module-federation/bridge-shared": "0.0.0-next-20241218093627",
36
- "@module-federation/sdk": "0.0.0-next-20241218093627",
37
- "@module-federation/runtime": "0.0.0-next-20241218093627"
35
+ "@module-federation/bridge-shared": "0.0.0-next-20241224035007",
36
+ "@module-federation/sdk": "0.0.0-next-20241224035007",
37
+ "@module-federation/runtime": "0.0.0-next-20241224035007"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@vitejs/plugin-vue": "^5.0.4",
package/src/create.ts CHANGED
@@ -28,7 +28,7 @@ export function createRemoteComponent(info: {
28
28
  }
29
29
 
30
30
  const exportName = info?.export || 'default';
31
- LoggerInstance.log(`createRemoteComponent LazyComponent create >>>`, {
31
+ LoggerInstance.debug(`createRemoteComponent LazyComponent create >>>`, {
32
32
  basename,
33
33
  info,
34
34
  });
@@ -37,7 +37,7 @@ export function createRemoteComponent(info: {
37
37
  const moduleName = module && module[Symbol.for('mf_module_id')];
38
38
  const exportFn = module[exportName];
39
39
 
40
- LoggerInstance.log(
40
+ LoggerInstance.debug(
41
41
  `createRemoteComponent LazyComponent loadRemote info >>>`,
42
42
  { name: moduleName, module, exportName, basename, route },
43
43
  );
package/src/provider.ts CHANGED
@@ -27,7 +27,7 @@ export function createBridgeComponent(bridgeInfo: ProviderFnParams) {
27
27
  return {
28
28
  __APP_VERSION__,
29
29
  async render(info: RenderFnParams) {
30
- LoggerInstance.log(`createBridgeComponent render Info`, info);
30
+ LoggerInstance.debug(`createBridgeComponent render Info`, info);
31
31
  const app = Vue.createApp(bridgeInfo.rootComponent);
32
32
  rootMap.set(info.dom, app);
33
33
 
@@ -75,7 +75,7 @@ export function createBridgeComponent(bridgeInfo: ProviderFnParams) {
75
75
  instance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(info);
76
76
  },
77
77
  destroy(info: { dom: HTMLElement }) {
78
- LoggerInstance.log(`createBridgeComponent destroy Info`, info);
78
+ LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
79
79
  const root = rootMap.get(info?.dom);
80
80
 
81
81
  instance?.bridgeHook?.lifecycle?.beforeBridgeDestroy?.emit(info);
package/src/remoteApp.tsx CHANGED
@@ -29,7 +29,7 @@ export default defineComponent({
29
29
  basename: props.basename,
30
30
  memoryRoute: props.memoryRoute,
31
31
  };
32
- LoggerInstance.log(
32
+ LoggerInstance.debug(
33
33
  `createRemoteComponent LazyComponent render >>>`,
34
34
  renderProps,
35
35
  );
@@ -53,10 +53,13 @@ export default defineComponent({
53
53
 
54
54
  // dispatchPopstateEnv
55
55
  if (pathname.value !== '' && pathname.value !== newPath) {
56
- LoggerInstance.log(`createRemoteComponent dispatchPopstateEnv >>>`, {
57
- ...props,
58
- pathname: route.path,
59
- });
56
+ LoggerInstance.debug(
57
+ `createRemoteComponent dispatchPopstateEnv >>>`,
58
+ {
59
+ ...props,
60
+ pathname: route.path,
61
+ },
62
+ );
60
63
  dispatchPopstateEnv();
61
64
  }
62
65
  pathname.value = newPath;
@@ -68,7 +71,7 @@ export default defineComponent({
68
71
  });
69
72
 
70
73
  onBeforeUnmount(() => {
71
- LoggerInstance.log(`createRemoteComponent LazyComponent destroy >>>`, {
74
+ LoggerInstance.debug(`createRemoteComponent LazyComponent destroy >>>`, {
72
75
  ...props,
73
76
  });
74
77
  watchStopHandle();