@module-federation/bridge-vue3 0.0.0-next-20250704073349 → 0.0.0-next-20250708033956
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 +8 -5
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +10 -0
- package/dist/index.js +151 -147
- package/package.json +4 -4
- package/src/create.ts +24 -6
- package/src/index.ts +1 -1
- package/src/remoteApp.tsx +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# @module-federation/bridge-vue3
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20250708033956
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- eb0d1dc: refactor(vue3-bridge): rename createRemoteComponent as createRemoteAppComponent
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- @module-federation/bridge-shared@0.0.0-next-20250704073349
|
|
11
|
+
- @module-federation/runtime@0.0.0-next-20250708033956
|
|
12
|
+
- @module-federation/sdk@0.0.0-next-20250708033956
|
|
13
|
+
- @module-federation/bridge-shared@0.0.0-next-20250708033956
|
|
11
14
|
|
|
12
15
|
## 0.16.0
|
|
13
16
|
|
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
|
|
2
|
-
})`,{filename,importModuleDynamically:(_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER=(_vm_constants=vm.constants)==null?void 0:_vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER)!=null?_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER:importNodeModule});script.runInThisContext()(scriptContext.exports,scriptContext.module,eval("require"),urlDirname,filename);const exportedInterface=scriptContext.module.exports||scriptContext.exports;if(attrs&&exportedInterface&&attrs.globalName){const n=exportedInterface[attrs.globalName]||exportedInterface;cb(void 0,n);return}cb(void 0,exportedInterface)}catch(n){cb(n instanceof Error?n:new Error(`Script execution error: ${n}`))}};getFetch().then(async n=>{if((attrs==null?void 0:attrs.type)==="esm"||(attrs==null?void 0:attrs.type)==="module")return loadModule(urlObj.href,{fetch:n,vm:await importNodeModule("vm")}).then(async t=>{await t.evaluate(),cb(void 0,t.namespace)}).catch(t=>{cb(t instanceof Error?t:new Error(`Script execution error: ${t}`))});handleScriptFetch(n,urlObj)}).catch(n=>{cb(n)})}:(n,t,r
|
|
3
|
-
${
|
|
4
|
-
`)};function _extends(){return _extends=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(t[s]=o[s])}return t},_extends.apply(this,arguments)}const runtimeDescMap={[RUNTIME_001]:"Failed to get remoteEntry exports.",[RUNTIME_002]:'The remote entry interface does not contain "init"',[RUNTIME_003]:"Failed to get manifest.",[RUNTIME_004]:"Failed to locate remote.",[RUNTIME_005]:"Invalid loadShareSync function call from bundler runtime",[RUNTIME_006]:"Invalid loadShareSync function call from runtime",[RUNTIME_007]:"Failed to get remote snapshot.",[RUNTIME_008]:"Failed to load script resources."},typeDescMap={[TYPE_001]:"Failed to generate type declaration. Execute the below cmd to reproduce and fix the error."},buildDescMap={[BUILD_001]:"Failed to find expose module.",[BUILD_002]:"PublicPath is required in prod mode."};_extends({},runtimeDescMap,typeDescMap,buildDescMap);const LOG_CATEGORY="[ Federation Runtime ]",logger=createLogger(LOG_CATEGORY);function assert(n,t){n||error(t)}function error(n){throw n instanceof Error?(n.message=`${LOG_CATEGORY}: ${n.message}`,n):new Error(`${LOG_CATEGORY}: ${n}`)}function warn(n){n instanceof Error&&(n.message=`${LOG_CATEGORY}: ${n.message}`),logger.warn(n)}function addUniqueItem(n,t){return n.findIndex(r=>r===t)===-1&&n.push(t),n}function getFMId(n){return"version"in n&&n.version?`${n.name}:${n.version}`:"entry"in n&&n.entry?`${n.name}:${n.entry}`:`${n.name}`}function isRemoteInfoWithEntry(n){return typeof n.entry<"u"}function isPureRemoteEntry(n){return!n.entry.includes(".json")}function isObject(n){return n&&typeof n=="object"}const objectToString=Object.prototype.toString;function isPlainObject(n){return objectToString.call(n)==="[object Object]"}function arrayOptions(n){return Array.isArray(n)?n:[n]}function getRemoteEntryInfoFromSnapshot(n){const t={url:"",type:"global",globalName:""};return isBrowserEnv()||isReactNativeEnv()?"remoteEntry"in n?{url:n.remoteEntry,type:n.remoteEntryType,globalName:n.globalName}:t:"ssrRemoteEntry"in n?{url:n.ssrRemoteEntry||t.url,type:n.ssrRemoteEntryType||t.type,globalName:n.globalName}:t}const processModuleAlias=(n,t)=>{let r;return n.endsWith("/")?r=n.slice(0,-1):r=n,t.startsWith(".")&&(t=t.slice(1)),r=r+t,r},CurrentGlobal=typeof globalThis=="object"?globalThis:window,nativeGlobal=(()=>{try{return document.defaultView}catch{return CurrentGlobal}})(),Global=nativeGlobal;function definePropertyGlobalVal(n,t,r){Object.defineProperty(n,t,{value:r,configurable:!1,writable:!0})}function includeOwnProperty(n,t){return Object.hasOwnProperty.call(n,t)}includeOwnProperty(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__")||definePropertyGlobalVal(CurrentGlobal,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const globalLoading=CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;function setGlobalDefaultVal(n){var t,r,o,s,a,l;includeOwnProperty(n,"__VMOK__")&&!includeOwnProperty(n,"__FEDERATION__")&&definePropertyGlobalVal(n,"__FEDERATION__",n.__VMOK__),includeOwnProperty(n,"__FEDERATION__")||(definePropertyGlobalVal(n,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),definePropertyGlobalVal(n,"__VMOK__",n.__FEDERATION__));var i;(i=(t=n.__FEDERATION__).__GLOBAL_PLUGIN__)!=null||(t.__GLOBAL_PLUGIN__=[]);var c;(c=(r=n.__FEDERATION__).__INSTANCES__)!=null||(r.__INSTANCES__=[]);var u;(u=(o=n.__FEDERATION__).moduleInfo)!=null||(o.moduleInfo={});var h;(h=(s=n.__FEDERATION__).__SHARE__)!=null||(s.__SHARE__={});var d;(d=(a=n.__FEDERATION__).__MANIFEST_LOADING__)!=null||(a.__MANIFEST_LOADING__={});var p;(p=(l=n.__FEDERATION__).__PRELOADED_MAP__)!=null||(l.__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.16.0")}function getInfoWithoutType(n,t){if(typeof t=="string"){if(n[t])return{value:n[t],key:t};{const o=Object.keys(n);for(const s of o){const[a,l]=s.split(":"),i=`${a}:${t}`,c=n[i];if(c)return{value:c,key:i}}return{value:void 0,key:t}}}else throw new Error("key must be string")}const getGlobalSnapshot=()=>nativeGlobal.__FEDERATION__.moduleInfo,getTargetSnapshotInfoByModuleInfo=(n,t)=>{const r=getFMId(n),o=getInfoWithoutType(t,r).value;if(o&&!o.version&&"version"in n&&n.version&&(o.version=n.version),o)return o;if("version"in n&&n.version){const{version:s}=n,a=_object_without_properties_loose(n,["version"]),l=getFMId(a),i=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,l).value;if((i==null?void 0:i.version)===s)return i}},getGlobalSnapshotInfoByModuleInfo=n=>getTargetSnapshotInfoByModuleInfo(n,nativeGlobal.__FEDERATION__.moduleInfo),setGlobalSnapshotInfoByModuleInfo=(n,t)=>{const r=getFMId(n);return nativeGlobal.__FEDERATION__.moduleInfo[r]=t,nativeGlobal.__FEDERATION__.moduleInfo},addGlobalSnapshot=n=>(nativeGlobal.__FEDERATION__.moduleInfo=_extends$1({},nativeGlobal.__FEDERATION__.moduleInfo,n),()=>{const t=Object.keys(n);for(const r of t)delete nativeGlobal.__FEDERATION__.moduleInfo[r]}),getRemoteEntryExports=(n,t)=>{const r=t||`__FEDERATION_${n}:custom__`,o=CurrentGlobal[r];return{remoteEntryKey:r,entryExports:o}},getGlobalHostPlugins=()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__,getPreloaded=n=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(n),setPreloaded=n=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(n,!0),DEFAULT_SCOPE="default",DEFAULT_REMOTE_TYPE="global",buildIdentifier="[0-9A-Za-z-]+",build=`(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`,numericIdentifier="0|[1-9]\\d*",numericIdentifierLoose="[0-9]+",nonNumericIdentifier="\\d*[a-zA-Z-][a-zA-Z0-9-]*",preReleaseIdentifierLoose=`(?:${numericIdentifierLoose}|${nonNumericIdentifier})`,preReleaseLoose=`(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`,preReleaseIdentifier=`(?:${numericIdentifier}|${nonNumericIdentifier})`,preRelease=`(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`,xRangeIdentifier=`${numericIdentifier}|x|X|\\*`,xRangePlain=`[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`,hyphenRange=`^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`,mainVersionLoose=`(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`,loosePlain=`[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`,gtlt="((?:<|>)?=?)",comparatorTrim=`(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`,loneTilde="(?:~>?)",tildeTrim=`(\\s*)${loneTilde}\\s+`,loneCaret="(?:\\^)",caretTrim=`(\\s*)${loneCaret}\\s+`,star="(<|>)?=?\\s*\\*",caret=`^${loneCaret}${xRangePlain}$`,mainVersion=`(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`,fullPlain=`v?${mainVersion}${preRelease}?${build}?`,tilde=`^${loneTilde}${xRangePlain}$`,xRange=`^${gtlt}\\s*${xRangePlain}$`,comparator=`^${gtlt}\\s*(${fullPlain})$|^$`,gte0="^\\s*>=\\s*0.0.0\\s*$";function parseRegex(n){return new RegExp(n)}function isXVersion(n){return!n||n.toLowerCase()==="x"||n==="*"}function pipe(...n){return t=>n.reduce((r,o)=>o(r),t)}function extractComparator(n){return n.match(parseRegex(comparator))}function combineVersion(n,t,r,o){const s=`${n}.${t}.${r}`;return o?`${s}-${o}`:s}function parseHyphen(n){return n.replace(parseRegex(hyphenRange),(t,r,o,s,a,l,i,c,u,h,d,p)=>(isXVersion(o)?r="":isXVersion(s)?r=`>=${o}.0.0`:isXVersion(a)?r=`>=${o}.${s}.0`:r=`>=${r}`,isXVersion(u)?c="":isXVersion(h)?c=`<${Number(u)+1}.0.0-0`:isXVersion(d)?c=`<${u}.${Number(h)+1}.0-0`:p?c=`<=${u}.${h}.${d}-${p}`:c=`<=${c}`,`${r} ${c}`.trim()))}function parseComparatorTrim(n){return n.replace(parseRegex(comparatorTrim),"$1$2$3")}function parseTildeTrim(n){return n.replace(parseRegex(tildeTrim),"$1~")}function parseCaretTrim(n){return n.replace(parseRegex(caretTrim),"$1^")}function parseCarets(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(caret),(r,o,s,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(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(r,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(n){return n.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(r,o,s,a,l,i)=>{const c=isXVersion(s),u=c||isXVersion(a),h=u||isXVersion(l);return o==="="&&h&&(o=""),i="",c?o===">"||o==="<"?"<0.0.0-0":"*":o&&h?(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`:h?`>=${s}.${a}.0${i} <${s}.${Number(a)+1}.0-0`:r})).join(" ")}function parseStar(n){return n.trim().replace(parseRegex(star),"")}function parseGTE0(n){return n.trim().replace(parseRegex(gte0),"")}function compareAtom(n,t){return n=Number(n)||n,t=Number(t)||t,n>t?1:n===t?0:-1}function comparePreRelease(n,t){const{preRelease:r}=n,{preRelease:o}=t;if(r===void 0&&o)return 1;if(r&&o===void 0)return-1;if(r===void 0&&o===void 0)return 0;for(let s=0,a=r.length;s<=a;s++){const l=r[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(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 r=extractComparator(n);if(!r)return!1;const[,o,,s,a,l,i]=r,c={operator:o,version:combineVersion(s,a,l,i),major:s,minor:a,patch:l,preRelease:i==null?void 0:i.split(".")},u=t.split("||");for(const h of u){const d=h.trim();if(!d||d==="*"||d==="x")return!0;try{const p=parseRange(d);if(!p.trim())return!0;const m=p.split(" ").map(y=>parseComparatorString(y)).join(" ");if(!m.trim())return!0;const _=m.split(/\s+/).map(y=>parseGTE0(y)).filter(Boolean);if(_.length===0)continue;let g=!0;for(const y of _){const E=extractComparator(y);if(!E){g=!1;break}const[,I,,S,R,b,v]=E,A={operator:I,version:combineVersion(S,R,b,v),major:S,minor:R,patch:b,preRelease:v==null?void 0:v.split(".")};if(!compare(A,c)){g=!1;break}}if(g)return!0}catch(p){console.error(`[semver] Error processing range part "${d}":`,p);continue}}return!1}function formatShare(n,t,r,o){let s;"get"in n?s=n.get:"lib"in n?s=()=>Promise.resolve(n.lib):s=()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${r}'!`)});var a,l,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:(a=n.version)!=null?a:"0",scope:Array.isArray(n.scope)?n.scope:[(l=n.scope)!=null?l:"default"],strategy:((i=n.strategy)!=null?i:o)||"version-first"})}function formatShareConfigs(n,t){const r=t.shared||{},o=t.name,s=Object.keys(r).reduce((l,i)=>{const c=arrayOptions(r[i]);return l[i]=l[i]||[],c.forEach(u=>{l[i].push(formatShare(u,o,i,t.shareStrategy))}),l},{}),a=_extends$1({},n.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(n,t){const r=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(r(n),`<=${r(t)}`)}const findVersion=(n,t)=>{const r=t||function(o,s){return versionLt(o,s)};return Object.keys(n).reduce((o,s)=>!o||r(o,s)||o==="0"?s:o,0)},isLoaded=n=>!!n.loaded||typeof n.lib=="function",isLoading=n=>!!n.loading;function findSingletonVersionOrderByVersion(n,t,r){const o=n[t][r],s=function(a,l){return!isLoaded(o[a])&&versionLt(a,l)};return findVersion(n[t][r],s)}function findSingletonVersionOrderByLoaded(n,t,r){const o=n[t][r],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(n[t][r],s)}function getFindShareFunction(n){return n==="loaded-first"?findSingletonVersionOrderByLoaded:findSingletonVersionOrderByVersion}function getRegisteredShare(n,t,r,o){if(!n)return;const{shareConfig:s,scope:a=DEFAULT_SCOPE,strategy:l}=r,i=Array.isArray(a)?a:[a];for(const c of i)if(s&&n[c]&&n[c][t]){const{requiredVersion:u}=s,d=getFindShareFunction(l)(n,c,t),p=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(d,u)){const g=`Version ${d} from ${d&&n[c][t][d].from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${u})`;s.strictVersion?error(g):warn(g)}return n[c][t][d]}else{if(u===!1||u==="*"||satisfy(d,u))return n[c][t][d];for(const[g,y]of Object.entries(n[c][t]))if(satisfy(g,u))return y}},m={shareScopeMap:n,scope:c,pkgName:t,version:d,GlobalFederation:Global.__FEDERATION__,resolver:p};return(o.emit(m)||m).resolver()}}function getGlobalShareScope(){return Global.__FEDERATION__.__SHARE__}function getTargetSharedOptions(n){const{pkgName:t,extraOptions:r,shareInfos:o}=n,s=i=>{if(!i)return;const c={};i.forEach(d=>{c[d.version]=d});const h=findVersion(c,function(d,p){return!isLoaded(c[d])&&versionLt(d,p)});return c[h]};var a;const l=(a=r==null?void 0:r.resolver)!=null?a:s;return Object.assign({},l(o[t]),r==null?void 0:r.customShareInfo)}function getBuilderId(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function matchRemoteWithNameAndExpose(n,t){for(const r of n){const o=t.startsWith(r.name);let s=t.replace(r.name,"");if(o){if(s.startsWith("/")){const i=r.name;return s=`.${s}`,{pkgNameOrAlias:i,expose:s,remote:r}}else if(s==="")return{pkgNameOrAlias:r.name,expose:".",remote:r}}const a=r.alias&&t.startsWith(r.alias);let l=r.alias&&t.replace(r.alias,"");if(r.alias&&a){if(l&&l.startsWith("/")){const i=r.alias;return l=`.${l}`,{pkgNameOrAlias:i,expose:l,remote:r}}else if(l==="")return{pkgNameOrAlias:r.alias,expose:".",remote:r}}}}function matchRemote(n,t){for(const r of n)if(t===r.name||r.alias&&t===r.alias)return r}function registerPlugins(n,t){const r=getGlobalHostPlugins();return r.length>0&&r.forEach(o=>{n!=null&&n.find(s=>s.name!==o.name)&&n.push(o)}),n&&n.length>0&&n.forEach(o=>{t.forEach(s=>{s.applyPlugin(o)})}),n}const importCallback=".then(callbacks[0]).catch(callbacks[1])";async function loadEsmEntry({entry:n,remoteEntryExports:t}){return new Promise((r,o)=>{try{t?r(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${n}")${importCallback}`)([r,o]):import(n).then(r).catch(o)}catch(s){o(s)}})}async function loadSystemJsEntry({entry:n,remoteEntryExports:t}){return new Promise((r,o)=>{try{t?r(t):typeof __system_context__>"u"?System.import(n).then(r).catch(o):new Function("callbacks",`System.import("${n}")${importCallback}`)([r,o])}catch(s){o(s)}})}function handleRemoteEntryLoaded(n,t,r){const{remoteEntryKey:o,entryExports:s}=getRemoteEntryExports(n,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:n,remoteEntryUrl:r,remoteEntryKey:o})),s}async function loadEntryScript({name:n,globalName:t,entry:r,loaderHook:o}){const{entryExports:s}=getRemoteEntryExports(n,t);return s||loadScript(r,{attrs:{},createScriptHook:(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(()=>handleRemoteEntryLoaded(n,t,r)).catch(a=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:n,resourceUrl:r})),a})}async function loadEntryDom({remoteInfo:n,remoteEntryExports:t,loaderHook:r}){const{entry:o,entryGlobalName:s,name:a,type:l}=n;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:r})}}async function loadEntryNode({remoteInfo:n,loaderHook:t}){const{entry:r,entryGlobalName:o,name:s,type:a}=n,{entryExports:l}=getRemoteEntryExports(s,o);return l||loadScriptNode(r,{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(()=>handleRemoteEntryLoaded(s,o,r)).catch(i=>{throw i})}function getRemoteEntryUniqueKey(n){const{entry:t,name:r}=n;return composeKeyWithSeparator(r,t)}async function getRemoteEntry({origin:n,remoteEntryExports:t,remoteInfo:r}){const o=getRemoteEntryUniqueKey(r);if(t)return t;if(!globalLoading[o]){const s=n.remoteHandler.hooks.lifecycle.loadEntry,a=n.loaderHook;globalLoading[o]=s.emit({loaderHook:a,remoteInfo:r,remoteEntryExports:t}).then(l=>l||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:r,remoteEntryExports:t,loaderHook:a}):loadEntryNode({remoteInfo:r,loaderHook:a})))}return globalLoading[o]}function getRemoteInfo(n){return _extends$1({},n,{entry:"entry"in n?n.entry:"",type:n.type||DEFAULT_REMOTE_TYPE,entryGlobalName:n.entryGlobalName||n.name,shareScope:n.shareScope||DEFAULT_SCOPE})}let Module=class{async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let t;try{t=await getRemoteEntry({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports})}catch{const o=getRemoteEntryUniqueKey(this.remoteInfo);t=await this.host.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry,origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports,globalLoading,uniqueKey:o})}return assert(t,`remoteEntryExports is undefined
|
|
5
|
-
${safeToString(this.remoteInfo)}`),this.remoteEntryExports=t,this.remoteEntryExports}async get(t,r,o,s){const{loadFactory:a=!0}=o||{loadFactory:!0},l=await this.getEntry();if(!this.inited){const d=this.host.shareScopeMap,p=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];p.length||p.push("default"),p.forEach(E=>{d[E]||(d[E]={})});const m=d[p[0]],_=[],g={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?p:this.remoteInfo.shareScope||"default"};Object.defineProperty(g,"shareScopeMap",{value:d,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:g,initScope:_,remoteInfo:this.remoteInfo,origin:this.host});typeof(l==null?void 0:l.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{hostName:this.host.name,remoteName:this.remoteInfo.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:r,moduleInfo:this.remoteInfo}),i||(i=await l.get(r)),assert(i,`${getFMId(this.remoteInfo)} remote don't export ${r}.`);const c=processModuleAlias(this.remoteInfo.name,r),u=this.wraperFactory(i,c);return a?await u():u}wraperFactory(t,r){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,r),s}:()=>{const s=t();return o(s,r),s}}constructor({remoteInfo:t,host:r}){this.inited=!1,this.lib=void 0,this.remoteInfo=t,this.host=r}};class SyncHook{on(t){typeof t=="function"&&this.listeners.add(t)}once(t){const r=this;this.on(function o(...s){return r.remove(o),t.apply(null,s)})}emit(...t){let r;return this.listeners.size>0&&this.listeners.forEach(o=>{r=o(...t)}),r}remove(t){this.listeners.delete(t)}removeAll(){this.listeners.clear()}constructor(t){this.type="",this.listeners=new Set,t&&(this.type=t)}}class AsyncHook extends SyncHook{emit(...t){let r;const o=Array.from(this.listeners);if(o.length>0){let s=0;const a=l=>l===!1?!1:s<o.length?Promise.resolve(o[s++].apply(null,t)).then(a):l;r=a()}return Promise.resolve(r)}}function checkReturnData(n,t){if(!isObject(t))return!1;if(n!==t){for(const r in n)if(!(r in t))return!1}return!0}class SyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The data for the "${this.type}" hook should be an object.`);for(const r of this.listeners)try{const o=r(t);if(checkReturnData(t,o))t=o;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(o){warn(o),this.onerror(o)}return t}constructor(t){super(),this.onerror=error,this.type=t}}class AsyncWaterfallHook extends SyncHook{emit(t){isObject(t)||error(`The response data for the "${this.type}" hook must be an object.`);const r=Array.from(this.listeners);if(r.length>0){let o=0;const s=l=>(warn(l),this.onerror(l),t),a=l=>{if(checkReturnData(t,l)){if(t=l,o<r.length)try{return Promise.resolve(r[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 r=t.name;assert(r,"A name must be provided by the plugin."),this.registerPlugins[r]||(this.registerPlugins[r]=t,Object.keys(this.lifecycle).forEach(o=>{const s=t[o];s&&this.lifecycle[o].on(s)}))}removePlugin(t){assert(t,"A name is required.");const r=this.registerPlugins[t];assert(r,`The plugin "${t}" is not registered.`),Object.keys(r).forEach(o=>{o!=="name"&&this.lifecycle[o].remove(r[o])})}inherit({lifecycle:t,registerPlugins:r}){Object.keys(t).forEach(o=>{assert(!this.lifecycle[o],`The hook "${o}" has a conflict and cannot be inherited.`),this.lifecycle[o]=t[o]}),Object.keys(r).forEach(o=>{assert(!this.registerPlugins[o],`The plugin "${o}" has a conflict and cannot be inherited.`),this.applyPlugin(r[o])})}constructor(t){this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}}function defaultPreloadArgs(n){return _extends$1({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},n)}function formatPreloadArgs(n,t){return t.map(r=>{const o=matchRemote(n,r.nameOrAlias);return assert(o,`Unable to preload ${r.nameOrAlias} as it is not included in ${!o&&safeToString({remoteInfo:o,remotes:n})}`),{remote:o,preloadConfig:defaultPreloadArgs(r)}})}function normalizePreloadExposes(n){return n?n.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function preloadAssets(n,t,r,o=!0){const{cssAssets:s,jsAssetsWithoutEntry:a,entryAssets:l}=r;if(t.options.inBrowser){if(l.forEach(i=>{const{moduleInfo:c}=i,u=t.moduleCache.get(n.name);getRemoteEntry(u?{origin:t,remoteInfo:c,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:c,remoteEntryExports:void 0})}),o){const i={rel:"preload",as:"style"};s.forEach(c=>{const{link:u,needAttach:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(c=>{const{link:u,needAttach:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});h&&document.head.appendChild(u)})}if(o){const i={rel:"preload",as:"script"};a.forEach(c=>{const{link:u,needAttach:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={fetchpriority:"high",type:(n==null?void 0:n.type)==="module"?"module":"text/javascript"};a.forEach(c=>{const{script:u,needAttach:h}=createScript({url:c,cb:()=>{},attrs:i,createScriptHook:(d,p)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:d,attrs:p});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});h&&document.head.appendChild(u)})}}}function assignRemoteInfo(n,t){const r=getRemoteEntryInfoFromSnapshot(t);r.url||error(`The attribute remoteEntry of ${n.name} must not be undefined.`);let o=getResourceUrl(t,r.url);!isBrowserEnv()&&!o.startsWith("http")&&(o=`https:${o}`),n.type=r.type,n.entryGlobalName=r.globalName,n.entry=o,n.version=t.version,n.buildVersion=t.buildVersion}function snapshotPlugin(){return{name:"snapshot-plugin",async afterResolve(n){const{remote:t,pkgNameOrAlias:r,expose:o,origin:s,remoteInfo:a,id:l}=n;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:i,globalSnapshot:c}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:l});assignRemoteInfo(a,i);const u={remote:t,preloadConfig:{nameOrAlias:r,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},h=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:u,remoteInfo:a,remote:t,remoteSnapshot:i,globalSnapshot:c});return h&&preloadAssets(a,s,h,!1),_extends$1({},n,{remoteSnapshot:i})}return n}}}function splitId(n){const t=n.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function traverseModuleInfo(n,t,r,o,s={},a){const l=getFMId(t),{value:i}=getInfoWithoutType(n,l),c=a||i;if(c&&!isManifestProvider(c)&&(r(c,t,o),c.remotesInfo)){const u=Object.keys(c.remotesInfo);for(const h of u){if(s[h])continue;s[h]=!0;const d=splitId(h),p=c.remotesInfo[h];traverseModuleInfo(n,{name:d.name,version:p.matchedVersion},r,!1,s,void 0)}}}const isExisted=(n,t)=>document.querySelector(`${n}[${n==="link"?"href":"src"}="${t}"]`);function generatePreloadAssets(n,t,r,o,s){const a=[],l=[],i=[],c=new Set,u=new Set,{options:h}=n,{preloadConfig:d}=t,{depsRemote:p}=d;if(traverseModuleInfo(o,r,(y,E,I)=>{let S;if(I)S=d;else if(Array.isArray(p)){const O=p.find(T=>T.nameOrAlias===E.name||T.nameOrAlias===E.alias);if(!O)return;S=defaultPreloadArgs(O)}else if(p===!0)S=d;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(N=>getResourceUrl(y,N));return S.filter?T.filter(S.filter):T}if(b){const O=b.length;for(let T=0;T<O;T++){const N=b[T],w=`${E.name}/${N.moduleName}`;n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:N.moduleName==="."?E.name:w,name:E.name,remoteSnapshot:y,preloadConfig:S,remote:E,origin:n}),!getPreloaded(w)&&(S.resourceCategory==="all"?(a.push(...$(N.assets.css.async)),a.push(...$(N.assets.css.sync)),l.push(...$(N.assets.js.async)),l.push(...$(N.assets.js.sync))):(S.resourceCategory="sync")&&(a.push(...$(N.assets.css.sync)),l.push(...$(N.assets.js.sync))),setPreloaded(w))}}},!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=h.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 _=l.filter(y=>!c.has(y)&&!isExisted("script",y));return{cssAssets:a.filter(y=>!u.has(y)&&!isExisted("link",y)),jsAssetsWithoutEntry:_,entryAssets:i.filter(y=>!isExisted("script",y.url))}}const generatePreloadAssetsPlugin=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(n){const{origin:t,preloadOptions:r,remoteInfo:o,remote:s,globalSnapshot:a,remoteSnapshot:l}=n;return isBrowserEnv()?isRemoteInfoWithEntry(s)&&isPureRemoteEntry(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:o.name,entry:s.entry,type:o.type||"global",entryGlobalName:"",shareScope:""}}]}:(assignRemoteInfo(o,l),generatePreloadAssets(t,r,o,a,l)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(n,t){const r=getGlobalSnapshotInfoByModuleInfo({name:t.name,version:t.options.version}),o=r&&"remotesInfo"in r&&r.remotesInfo&&getInfoWithoutType(r.remotesInfo,n.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:r,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:n.name,version:o.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:getGlobalSnapshot(),remoteSnapshot:getGlobalSnapshotInfoByModuleInfo({name:n.name,version:"version"in n?n.version:void 0})}}class SnapshotHandler{async loadRemoteSnapshotInfo({moduleInfo:t,id:r,expose:o}){const{options:s}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:s,moduleInfo:t});let a=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});a||(a={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:a})),a&&"remotesInfo"in a&&!getInfoWithoutType(a.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(a.remotesInfo=_extends$1({},a==null?void 0:a.remotesInfo,{[t.name]:{matchedVersion:"version"in t?t.version:t.entry}}));const{hostGlobalSnapshot:l,remoteSnapshot:i,globalSnapshot:c}=this.getGlobalRemoteInfo(t),{remoteSnapshot:u,globalSnapshot:h}=await this.hooks.lifecycle.loadSnapshot.emit({options:s,moduleInfo:t,hostGlobalSnapshot:l,remoteSnapshot:i,globalSnapshot:c});let d,p;if(u)if(isManifestProvider(u)){const m=isBrowserEnv()?u.remoteEntry:u.ssrRemoteEntry||u.remoteEntry||"",_=await this.getManifestJson(m,t,{}),g=setGlobalSnapshotInfoByModuleInfo(_extends$1({},t,{entry:m}),_);d=_,p=g}else{const{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:u,from:"global"});d=m,p=h}else if(isRemoteInfoWithEntry(t)){const m=await this.getManifestJson(t.entry,t,{}),_=setGlobalSnapshotInfoByModuleInfo(t,m),{remoteSnapshot:g}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:m,from:"global"});d=g,p=_}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(h)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:r,host:this.HostInstance,options:s,moduleInfo:t,remoteSnapshot:d}),{remoteSnapshot:d,globalSnapshot:p}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,r,o){const s=async()=>{let l=this.manifestCache.get(t);if(l)return l;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});(!i||!(i instanceof Response))&&(i=await fetch(t,{})),l=await i.json()}catch(i){l=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),l||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:r.name,hostName:this.HostInstance.options.name},`${i}`)))}return assert(l.metaData&&l.exposes&&l.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,l),l},a=async()=>{const l=await s(),i=generateSnapshotFromManifest(l,{version:t}),{remoteSnapshot:c}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:r,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,r){const{shareInfos:o,shared:s}=formatShareConfigs(t,r);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:r.name})})}),{shareInfos:o,shared:s}}async loadShare(t,r){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:r,shareInfos:o.options.shared});s!=null&&s.scope&&await Promise.all(s.scope.map(async u=>{await Promise.all(this.initializeSharing(u,{strategy:s.strategy}))}));const 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 h=(async()=>{const d=await i.get();l.lib=d,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=d,p.loaded=!0),d})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:o.options.name,lib:null,loading:h}),h}else{if(r!=null&&r.customShareInfo)return!1;const h=(async()=>{const d=await l.get();l.lib=d,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=d,p.loaded=!0),d})();return this.setShared({pkgName:t,loaded:!1,shared:l,from:o.options.name,lib:null,loading:h}),h}}initializeSharing(t=DEFAULT_SCOPE,r){const{host:o}=this,s=r==null?void 0:r.from,a=r==null?void 0:r.strategy;let l=r==null?void 0:r.initScope;const i=[];if(s!=="build"){const{initTokens:_}=this;l||(l=[]);let g=_[t];if(g||(g=_[t]={from:this.host.name}),l.indexOf(g)>=0)return i;l.push(g)}const c=this.shareScopeMap,u=o.options.name;c[t]||(c[t]={});const h=c[t],d=(_,g)=>{var y;const{version:E,eager:I}=g;h[_]=h[_]||{};const S=h[_],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)},p=_=>_&&_.init&&_.init(c[t],l),m=async _=>{const{module:g}=await o.remoteHandler.getRemoteModuleAndOptions({id:_});if(g.getEntry){let y;try{y=await g.getEntry()}catch(E){y=await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:_,error:E,from:"runtime",lifecycle:"beforeLoadShare",origin:o})}g.inited||(await p(y),g.inited=!0)}};return Object.keys(o.options.shared).forEach(_=>{o.options.shared[_].forEach(y=>{y.scope.includes(t)&&d(_,y)})}),(o.options.shareStrategy==="version-first"||a==="version-first")&&o.options.remotes.forEach(_=>{_.shareScope===t&&i.push(m(_.name))}),i}loadShareSync(t,r){const{host:o}=this,s=getTargetSharedOptions({pkgName:t,extraOptions:r,shareInfos:o.options.shared});s!=null&&s.scope&&s.scope.forEach(i=>{this.initializeSharing(i,{strategy:s.strategy})});const 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=(r==null?void 0:r.from)==="build"?RUNTIME_005:RUNTIME_006;throw new Error(getShortErrorMsg(c,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}return s.lib=i,this.setShared({pkgName:t,loaded:!0,from:o.options.name,lib:s.lib,shared:s}),s.lib}throw new Error(getShortErrorMsg(RUNTIME_006,runtimeDescMap,{hostName:o.options.name,sharedPkgName:t}))}initShareScopeMap(t,r,o={}){const{host:s}=this;this.shareScopeMap[t]=r,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:r,options:s.options,origin:s,scopeName:t,hostShareScopeMap:o.hostShareScopeMap})}setShared({pkgName:t,shared:r,from:o,lib:s,loading:a,loaded:l,get:i}){const{version:c,scope:u="default"}=r,h=_object_without_properties_loose(r,["version","scope"]);(Array.isArray(u)?u:[u]).forEach(p=>{if(this.shareScopeMap[p]||(this.shareScopeMap[p]={}),this.shareScopeMap[p][t]||(this.shareScopeMap[p][t]={}),!this.shareScopeMap[p][t][c]){this.shareScopeMap[p][t][c]=_extends$1({version:c,scope:["default"]},h,{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 r=getGlobalShareScope(),o=t.id||t.name;o&&!r[o]&&(r[o]=this.shareScopeMap)}constructor(t){this.hooks=new PluginSystem({afterResolve:new AsyncWaterfallHook("afterResolve"),beforeLoadShare:new AsyncWaterfallHook("beforeLoadShare"),loadShare:new AsyncHook,resolveShare:new SyncWaterfallHook("resolveShare"),initContainerShareScopeMap:new SyncWaterfallHook("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}}class RemoteHandler{formatAndRegisterRemote(t,r){return(r.remotes||[]).reduce((s,a)=>(this.registerRemote(a,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,r){const{remote:o,expose:s}=r,{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,r){const{host:o}=this;try{const{loadFactory:s=!0}=r||{loadFactory:!0},{module:a,moduleOptions:l,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:c,remote:u,expose:h,id:d,remoteSnapshot:p}=i,m=await a.get(d,h,r,p),_=await this.hooks.lifecycle.onLoad.emit({id:d,pkgNameOrAlias:c,expose:h,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:l,moduleInstance:a,origin:o});return this.setIdToRemoteMap(t,i),typeof _=="function"?_:m}catch(s){const{from:a="runtime"}=r||{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:r}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:t,options:r.options,origin:r});const o=formatPreloadArgs(r.options.remotes,t);await Promise.all(o.map(async s=>{const{remote:a}=s,l=getRemoteInfo(a),{globalSnapshot:i,remoteSnapshot:c}=await r.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:a}),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:r,preloadOptions:s,remote:a,remoteInfo:l,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(l,r,u)}))}registerRemotes(t,r){const{host:o}=this;t.forEach(s=>{this.registerRemote(s,o.options.remotes,{force:r==null?void 0:r.force})})}async getRemoteModuleAndOptions(t){const{host:r}=this,{id:o}=t;let s;try{s=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:r.options,origin:r})}catch(_){if(s=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:r.options,origin:r,from:"runtime",error:_,lifecycle:"beforeRequest"}),!s)throw _}const{id:a}=s,l=matchRemoteWithNameAndExpose(r.options.remotes,a);assert(l,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:r.options.name,requestId:a}));const{remote:i}=l,c=getRemoteInfo(i),u=await r.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:a},l,{options:r.options,origin:r,remoteInfo:c})),{remote:h,expose:d}=u;assert(h&&d,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);let p=r.moduleCache.get(h.name);const m={host:r,remoteInfo:c};return p||(p=new Module(m),r.moduleCache.set(h.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,r,o){const{host:s}=this,a=()=>{if(t.alias){const i=r.find(c=>{var u;return t.alias&&(c.name.startsWith(t.alias)||((u=c.alias)==null?void 0:u.startsWith(t.alias)))});assert(!i,`The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in t&&isBrowserEnv()&&!t.entry.startsWith("http")&&(t.entry=new URL(t.entry,window.location.origin).href),t.shareScope||(t.shareScope=DEFAULT_SCOPE),t.type||(t.type=DEFAULT_REMOTE_TYPE)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:t,origin:s});const l=r.find(i=>i.name===t.name);if(!l)a(),r.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];o!=null&&o.force&&(this.removeRemote(l),a(),r.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s}),warn$1(i.join(" ")))}}removeRemote(t){try{const{host:o}=this,{name:s}=t,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 r;(r=Object.getOwnPropertyDescriptor(CurrentGlobal,c))!=null&&r.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 h=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const d=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===h:m.name===h);if(d!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[d];h=m.options.id||h;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 _[h]),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(d,1)}const{hostGlobalSnapshot:p}=getGlobalRemoteInfo(t,o);if(p){const m=p&&"remotesInfo"in p&&p.remotesInfo&&getInfoWithoutType(p.remotesInfo,t.name).key;m&&(delete p.remotesInfo[m],Global.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Global.__FEDERATION__.__MANIFEST_LOADING__[m])}o.moduleCache.delete(t.name)}}catch(o){logger.log("removeRemote fail: ",o)}}constructor(t){this.hooks=new PluginSystem({beforeRegisterRemote:new SyncWaterfallHook("beforeRegisterRemote"),registerRemote:new SyncWaterfallHook("registerRemote"),beforeRequest:new AsyncWaterfallHook("beforeRequest"),onLoad:new AsyncHook("onLoad"),handlePreloadModule:new SyncHook("handlePreloadModule"),errorLoadRemote:new AsyncHook("errorLoadRemote"),beforePreloadRemote:new AsyncHook("beforePreloadRemote"),generatePreloadAssets:new AsyncHook("generatePreloadAssets"),afterPreloadRemote:new AsyncHook,loadEntry:new AsyncHook}),this.host=t,this.idToRemoteMap={}}}const USE_SNAPSHOT=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;class ModuleFederation{initOptions(t){this.registerPlugins(t.plugins);const r=this.formatOptions(this.options,t);return this.options=r,r}async loadShare(t,r){return this.sharedHandler.loadShare(t,r)}loadShareSync(t,r){return this.sharedHandler.loadShareSync(t,r)}initializeSharing(t=DEFAULT_SCOPE,r){return this.sharedHandler.initializeSharing(t,r)}initRawContainer(t,r,o){const s=getRemoteInfo({name:t,entry:r}),a=new Module({host:this,remoteInfo:s});return a.remoteEntryExports=o,this.moduleCache.set(t,a),a}async loadRemote(t,r){return this.remoteHandler.loadRemote(t,r)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,r,o={}){this.sharedHandler.initShareScopeMap(t,r,o)}formatOptions(t,r){const{shared:o}=formatShareConfigs(t,r),{userOptions:s,options:a}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:r,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(h=>{c.includes(h)||c.push(h)});const u=_extends$1({},t,r,{plugins:c,remotes:l,shared:i});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(t){const r=registerPlugins(t,[this.hooks,this.remoteHandler.hooks,this.sharedHandler.hooks,this.snapshotHandler.hooks,this.loaderHook,this.bridgeHook]);this.options.plugins=this.options.plugins.reduce((o,s)=>(s&&o&&!o.find(a=>a.name===s.name)&&o.push(s),o),r||[])}registerRemotes(t,r){return this.remoteHandler.registerRemotes(t,r)}registerShared(t){this.sharedHandler.registerShared(this.options,_extends$1({},this.options,{shared:t}))}constructor(t){this.hooks=new PluginSystem({beforeInit:new SyncWaterfallHook("beforeInit"),init:new SyncHook,beforeInitContainer:new AsyncWaterfallHook("beforeInitContainer"),initContainer:new AsyncWaterfallHook("initContainer")}),this.version="0.16.0",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const r=USE_SNAPSHOT?[snapshotPlugin(),generatePreloadAssetsPlugin()]:[],o={id:getBuilderId(),name:t.name,plugins:r,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=o,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...o.plugins,...t.plugins||[]]),this.options=this.formatOptions(o,t)}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(ModuleFederation);function createBridgeComponent(n){const t=new Map,r=getInstance();return()=>({__APP_VERSION__:"0.16.0",async render(o){var _,g,y;LoggerInstance.debug("createBridgeComponent render Info",o);const{moduleName:s,dom:a,basename:l,memoryRoute:i,hashRoute:c,...u}=o,h=Vue__namespace.createApp(n.rootComponent,u);t.set(a,h);const d=await((y=(g=(_=r==null?void 0:r.bridgeHook)==null?void 0:_.lifecycle)==null?void 0:g.beforeBridgeRender)==null?void 0:y.emit(o)),p=d&&typeof d=="object"&&(d!=null&&d.extraProps)?d==null?void 0:d.extraProps:{},m=n.appOptions({app:h,basename:l,memoryRoute:i,hashRoute:c,...u,...p});if(m!=null&&m.router){let E,I=m.router.getRoutes();o.memoryRoute?E=VueRouter__namespace.createMemoryHistory(o.basename):o.hashRoute?(E=VueRouter__namespace.createWebHashHistory(),I=I.map(R=>({...R,path:o.basename+R.path}))):E=VueRouter__namespace.createWebHistory(o.basename);const S=VueRouter__namespace.createRouter({...m.router.options,history:E,routes:I});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:S}),i&&await S.push(i.entryPath),h.use(S)}h.mount(a)},destroy(o){LoggerInstance.debug("createBridgeComponent destroy Info",o);const s=t.get(o==null?void 0:o.dom);s==null||s.unmount()}})}function e(){const n=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(n)}const RemoteApp=Vue.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(n){const t=Vue.ref(null),r=Vue.ref(null),o=Vue.ref(""),s=VueRouter.useRoute(),a=getInstance(),l=Vue.useAttrs(),i=async()=>{var p,m,_,g;const u=(p=n.providerInfo)==null?void 0:p.call(n);r.value=u;let h={...l,moduleName:n.moduleName,dom:t.value,basename:n.basename,memoryRoute:n.memoryRoute,hashRoute:n.hashRoute};LoggerInstance.debug("createRemoteComponent LazyComponent render >>>",h);const d=await((g=(_=(m=a==null?void 0:a.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:_.beforeBridgeRender)==null?void 0:g.emit(h))||{};h={...h,...d.extraProps},u.render(h)},c=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&i(),o.value!==""&&o.value!==u&&(LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>",{...n,pathname:s.path}),e()),o.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>",{...n}),c(),(u=r.value)==null||u.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(n.rootAttrs||{},{ref:t}),null)}});function createRemoteComponent(n){return Vue.defineAsyncComponent({__APP_VERSION__:"0.16.0",...n.asyncComponentOptions,loader:async()=>{var c,u;const t=VueRouter.useRoute();let r="/";const o=(u=(c=t==null?void 0:t.matched)==null?void 0:c[0])==null?void 0:u.path;o&&(o.endsWith("/:pathMatch(.*)*")?r=o.replace("/:pathMatch(.*)*",""):r=t.matched[0].path);const s=(n==null?void 0:n.export)||"default";LoggerInstance.debug("createRemoteComponent LazyComponent create >>>",{basename:r,info:n});const a=await n.loader(),l=a&&a[Symbol.for("mf_module_id")],i=a[s];if(LoggerInstance.debug("createRemoteComponent LazyComponent loadRemote info >>>",{moduleName:l,module:a,exportName:s,basename:r,route:t}),s in a&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:l,providerInfo:i,basename:r,rootAttrs:n.rootAttrs})}};throw new Error("module not found")}})}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteComponent=createRemoteComponent;
|
|
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",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)}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 a=s.slice(1);return a.endsWith("/")?a.slice(0,-1):a}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:a={},version:l}=t;let i;const c=()=>"publicPath"in n.metaData?n.metaData.publicPath==="auto"&&l?inferAutoPublicPath(l):n.metaData.publicPath:n.metaData.getPublicPath,u=Object.keys(a);let h={};if(!Object.keys(s).length){var d;h=((d=n.remotes)==null?void 0:d.reduce((b,v)=>{let $;const A=v.federationContainerName;return u.includes(A)?$=a[A]:"version"in v?$=v.version:$=v.entry,b[A]={matchedVersion:$},b},{}))||{}}Object.keys(s).forEach(b=>h[b]={matchedVersion:u.includes(b)?a[b]:s[b]});const{remoteEntry:{path:p,name:m,type:_},types:g,buildInfo:{buildVersion:y},globalName:E,ssrRemoteEntry:I}=n.metaData,{exposes:S}=n;let R={version:l||"",buildVersion:y,globalName:E,remoteEntry:simpleJoinRemoteEntry(p,m),remoteEntryType:_,remoteTypes:simpleJoinRemoteEntry(g.path,g.name),remoteTypesZip:g.zip||"",remoteTypesAPI:g.api||"",remotesInfo:h,shared:n==null?void 0:n.shared.map(b=>({assets:b.assets,sharedName:b.name,version:b.version})),modules:S==null?void 0:S.map(b=>({moduleName:b.name,modulePath:b.path,assets:b.assets}))};if((o=n.metaData)!=null&&o.prefetchInterface){const b=n.metaData.prefetchInterface;R=_extends$2({},R,{prefetchInterface:b})}if((r=n.metaData)!=null&&r.prefetchEntry){const{path:b,name:v,type:$}=n.metaData.prefetchEntry;R=_extends$2({},R,{prefetchEntry:simpleJoinRemoteEntry(b,v),prefetchEntryType:$})}if("publicPath"in n.metaData?i=_extends$2({},R,{publicPath:c(),ssrPublicPath:n.metaData.ssrPublicPath}):i=_extends$2({},R,{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 a=document.getElementsByTagName("script");for(let i=0;i<a.length;i++){const c=a[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 l=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:h=!0}=n;h&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),i&&typeof i=="function")){const h=i(c);if(h instanceof Promise){const d=await h;return u(),d}return u(),h}u()};return t.onerror=l.bind(null,t.onerror),t.onload=l.bind(null,t.onload),s=setTimeout(()=>{l(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 a=0;a<r.length;a++){const l=r[a],i=l.getAttribute("href"),c=l.getAttribute("rel");if(i&&isStaticResourcesEqual(i,n.url)&&c===n.attrs.rel){t=l,o=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",n.url);let a;const l=n.attrs;n.createLinkHook&&(a=n.createLinkHook(n.url,l),a instanceof HTMLLinkElement&&(t=a)),l&&!a&&Object.keys(l).forEach(i=>{t&&!t.getAttribute(i)&&t.setAttribute(i,l[i])})}const s=(a,l)=>{const i=()=>{(l==null?void 0:l.type)==="error"?n!=null&&n.onErrorCallback&&(n==null||n.onErrorCallback(l)):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)}),a)){const c=a(l);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,a)=>{const{script:l,needAttach:i}=createScript({url:n,cb:s,onErrorCallback:a,attrs:_extends$2({fetchpriority:"high"},o),createScriptHook:r,needDeleteScript:!0});i&&document.head.appendChild(l)})}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((a,l)=>o.lifecycle.fetch.emit(a,l))(n,t||{});return!s||!(s instanceof Response)?(typeof fetch>"u"?await loadNodeFetch():fetch)(n,t||{}):s},createScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(url,cb,attrs,loaderHook)=>{if(loaderHook!=null&&loaderHook.createScriptHook){const n=loaderHook.createScriptHook(url);n&&typeof n=="object"&&"url"in n&&(url=n.url)}let urlObj;try{urlObj=new URL(url)}catch(n){console.error("Error constructing URL:",n),cb(new Error(`Invalid URL: ${n}`));return}const getFetch=async()=>loaderHook!=null&&loaderHook.fetch?(n,t)=>lazyLoaderHookFetch(n,t,loaderHook):typeof fetch>"u"?loadNodeFetch():fetch,handleScriptFetch=async(f,urlObj)=>{try{var _vm_constants;const res=await f(urlObj.href),data=await res.text(),[path,vm]=await Promise.all([importNodeModule("path"),importNodeModule("vm")]),scriptContext={exports:{},module:{exports:{}}},urlDirname=urlObj.pathname.split("/").slice(0,-1).join("/"),filename=path.basename(urlObj.pathname);var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;const script=new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}
|
|
2
|
+
})`,{filename,importModuleDynamically:(_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER=(_vm_constants=vm.constants)==null?void 0:_vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER)!=null?_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER:importNodeModule});script.runInThisContext()(scriptContext.exports,scriptContext.module,eval("require"),urlDirname,filename);const exportedInterface=scriptContext.module.exports||scriptContext.exports;if(attrs&&exportedInterface&&attrs.globalName){const n=exportedInterface[attrs.globalName]||exportedInterface;cb(void 0,n);return}cb(void 0,exportedInterface)}catch(n){cb(n instanceof Error?n:new Error(`Script execution error: ${n}`))}};getFetch().then(async n=>{if((attrs==null?void 0:attrs.type)==="esm"||(attrs==null?void 0:attrs.type)==="module")return loadModule(urlObj.href,{fetch:n,vm:await importNodeModule("vm")}).then(async t=>{await t.evaluate(),cb(void 0,t.namespace)}).catch(t=>{cb(t instanceof Error?t:new Error(`Script execution error: ${t}`))});handleScriptFetch(n,urlObj)}).catch(n=>{cb(n)})}:(n,t,o,r)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},loadScriptNode=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(n,t)=>new Promise((o,r)=>{createScriptNode(n,(s,a)=>{if(s)r(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;o(u)}},t.attrs,t.loaderHook)}):(n,t)=>{throw new Error("loadScriptNode is disabled in non-Node.js environment")};async function loadModule(n,t){const{fetch:o,vm:r}=t,a=await(await o(n)).text(),l=new r.SourceTextModule(a,{importModuleDynamically:async(i,c)=>{const u=new URL(i,n).href;return loadModule(u,t)}});return await l.link(async i=>{const c=new URL(i,n).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 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,a;for(a=0;a<r.length;a++)s=r[a],!(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",BUILD_002="BUILD-002",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
|
+
${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.",[BUILD_002]:"PublicPath is required in prod mode."};_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")}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,a,l;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 h;(h=(s=n.__FEDERATION__).__SHARE__)!=null||(s.__SHARE__={});var d;(d=(a=n.__FEDERATION__).__MANIFEST_LOADING__)!=null||(a.__MANIFEST_LOADING__={});var p;(p=(l=n.__FEDERATION__).__PRELOADED_MAP__)!=null||(l.__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.16.0")}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[a,l]=s.split(":"),i=`${a}:${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,a=_object_without_properties_loose(n,["version"]),l=getFMId(a),i=getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo,l).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,a,l,i,c,u,h,d,p)=>(isXVersion(r)?o="":isXVersion(s)?o=`>=${r}.0.0`:isXVersion(a)?o=`>=${r}.${s}.0`:o=`>=${o}`,isXVersion(u)?c="":isXVersion(h)?c=`<${Number(u)+1}.0.0-0`:isXVersion(d)?c=`<${u}.${Number(h)+1}.0-0`:p?c=`<=${u}.${h}.${d}-${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,a,l)=>isXVersion(r)?"":isXVersion(s)?`>=${r}.0.0 <${Number(r)+1}.0.0-0`:isXVersion(a)?r==="0"?`>=${r}.${s}.0 <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.0 <${Number(r)+1}.0.0-0`:l?r==="0"?s==="0"?`>=${r}.${s}.${a}-${l} <${r}.${s}.${Number(a)+1}-0`:`>=${r}.${s}.${a}-${l} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${a}-${l} <${Number(r)+1}.0.0-0`:r==="0"?s==="0"?`>=${r}.${s}.${a} <${r}.${s}.${Number(a)+1}-0`:`>=${r}.${s}.${a} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${a} <${Number(r)+1}.0.0-0`)).join(" ")}function parseTildes(n){return n.trim().split(/\s+/).map(t=>t.replace(parseRegex(tilde),(o,r,s,a,l)=>isXVersion(r)?"":isXVersion(s)?`>=${r}.0.0 <${Number(r)+1}.0.0-0`:isXVersion(a)?`>=${r}.${s}.0 <${r}.${Number(s)+1}.0-0`:l?`>=${r}.${s}.${a}-${l} <${r}.${Number(s)+1}.0-0`:`>=${r}.${s}.${a} <${r}.${Number(s)+1}.0-0`)).join(" ")}function parseXRanges(n){return n.split(/\s+/).map(t=>t.trim().replace(parseRegex(xRange),(o,r,s,a,l,i)=>{const c=isXVersion(s),u=c||isXVersion(a),h=u||isXVersion(l);return r==="="&&h&&(r=""),i="",c?r===">"||r==="<"?"<0.0.0-0":"*":r&&h?(u&&(a=0),l=0,r===">"?(r=">=",u?(s=Number(s)+1,a=0,l=0):(a=Number(a)+1,l=0)):r==="<="&&(r="<",u?s=Number(s)+1:a=Number(a)+1),r==="<"&&(i="-0"),`${r+s}.${a}.${l}${i}`):u?`>=${s}.0.0${i} <${Number(s)+1}.0.0-0`:h?`>=${s}.${a}.0${i} <${s}.${Number(a)+1}.0-0`:o})).join(" ")}function parseStar(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,a=o.length;s<=a;s++){const l=o[s],i=r[s];if(l!==i)return l===void 0&&i===void 0?0:l?i?compareAtom(l,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 o=extractComparator(n);if(!o)return!1;const[,r,,s,a,l,i]=o,c={operator:r,version:combineVersion(s,a,l,i),major:s,minor:a,patch:l,preRelease:i==null?void 0:i.split(".")},u=t.split("||");for(const h of u){const d=h.trim();if(!d||d==="*"||d==="x")return!0;try{const p=parseRange(d);if(!p.trim())return!0;const m=p.split(" ").map(y=>parseComparatorString(y)).join(" ");if(!m.trim())return!0;const _=m.split(/\s+/).map(y=>parseGTE0(y)).filter(Boolean);if(_.length===0)continue;let g=!0;for(const y of _){const E=extractComparator(y);if(!E){g=!1;break}const[,I,,S,R,b,v]=E,$={operator:I,version:combineVersion(S,R,b,v),major:S,minor:R,patch:b,preRelease:v==null?void 0:v.split(".")};if(!compare($,c)){g=!1;break}}if(g)return!0}catch(p){console.error(`[semver] Error processing range part "${d}":`,p);continue}}return!1}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 a,l,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:(a=n.version)!=null?a:"0",scope:Array.isArray(n.scope)?n.scope:[(l=n.scope)!=null?l:"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((l,i)=>{const c=arrayOptions(o[i]);return l[i]=l[i]||[],c.forEach(u=>{l[i].push(formatShare(u,r,i,t.shareStrategy))}),l},{}),a=_extends$1({},n.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(n,t){const o=r=>{if(!Number.isNaN(Number(r))){const a=r.split(".");let l=r;for(let i=0;i<3-a.length;i++)l+=".0";return l}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(a,l){return!isLoaded(r[a])&&versionLt(a,l)};return findVersion(n[t][o],s)}function findSingletonVersionOrderByLoaded(n,t,o){const r=n[t][o],s=function(a,l){const i=c=>isLoaded(c)||isLoading(c);return i(r[l])?i(r[a])?!!versionLt(a,l):!0:i(r[a])?!1:versionLt(a,l)};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:a=DEFAULT_SCOPE,strategy:l}=o,i=Array.isArray(a)?a:[a];for(const c of i)if(s&&n[c]&&n[c][t]){const{requiredVersion:u}=s,d=getFindShareFunction(l)(n,c,t),p=()=>{if(s.singleton){if(typeof u=="string"&&!satisfy(d,u)){const g=`Version ${d} from ${d&&n[c][t][d].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][d]}else{if(u===!1||u==="*"||satisfy(d,u))return n[c][t][d];for(const[g,y]of Object.entries(n[c][t]))if(satisfy(g,u))return y}},m={shareScopeMap:n,scope:c,pkgName:t,version:d,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(d=>{c[d.version]=d});const h=findVersion(c,function(d,p){return!isLoaded(c[d])&&versionLt(d,p)});return c[h]};var a;const l=(a=o==null?void 0:o.resolver)!=null?a:s;return Object.assign({},l(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 a=o.alias&&t.startsWith(o.alias);let l=o.alias&&t.replace(o.alias,"");if(o.alias&&a){if(l&&l.startsWith("/")){const i=o.alias;return l=`.${l}`,{pkgNameOrAlias:i,expose:l,remote:o}}else if(l==="")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}const importCallback=".then(callbacks[0]).catch(callbacks[1])";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}")${importCallback}`)([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}")${importCallback}`)([o,r])}catch(s){r(s)}})}function handleRemoteEntryLoaded(n,t,o){const{remoteEntryKey:r,entryExports:s}=getRemoteEntryExports(n,t);return assert(s,getShortErrorMsg(RUNTIME_001,runtimeDescMap,{remoteName:n,remoteEntryUrl:o,remoteEntryKey: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:(a,l)=>{const i=r.lifecycle.createScript.emit({url:a,attrs:l});if(i&&(i instanceof HTMLScriptElement||"script"in i||"timeout"in i))return i}}).then(()=>handleRemoteEntryLoaded(n,t,o)).catch(a=>{throw assert(void 0,getShortErrorMsg(RUNTIME_008,runtimeDescMap,{remoteName:n,resourceUrl:o})),a})}async function loadEntryDom({remoteInfo:n,remoteEntryExports:t,loaderHook:o}){const{entry:r,entryGlobalName:s,name:a,type:l}=n;switch(l){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:a,loaderHook:o})}}async function loadEntryNode({remoteInfo:n,loaderHook:t}){const{entry:o,entryGlobalName:r,name:s,type:a}=n,{entryExports:l}=getRemoteEntryExports(s,r);return l||loadScriptNode(o,{attrs:{name:s,globalName:r,type:a},loaderHook:{createScriptHook:(i,c={})=>{const u=t.lifecycle.createScript.emit({url:i,attrs:c});if(u&&"url"in u)return u}}}).then(()=>handleRemoteEntryLoaded(s,r,o)).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,a=n.loaderHook;globalLoading[r]=s.emit({loaderHook:a,remoteInfo:o,remoteEntryExports:t}).then(l=>l||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":isBrowserEnv())?loadEntryDom({remoteInfo:o,remoteEntryExports:t,loaderHook:a}):loadEntryNode({remoteInfo:o,loaderHook:a})))}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})}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:a,entryAssets:l}=o;if(t.options.inBrowser){if(l.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:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={rel:"stylesheet",type:"text/css"};s.forEach(c=>{const{link:u,needAttach:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m},needDeleteLink:!1});h&&document.head.appendChild(u)})}if(r){const i={rel:"preload",as:"script"};a.forEach(c=>{const{link:u,needAttach:h}=createLink({url:c,cb:()=>{},attrs:i,createLinkHook:(d,p)=>{const m=t.loaderHook.lifecycle.createLink.emit({url:d,attrs:p});if(m instanceof HTMLLinkElement)return m}});h&&document.head.appendChild(u)})}else{const i={fetchpriority:"high",type:(n==null?void 0:n.type)==="module"?"module":"text/javascript"};a.forEach(c=>{const{script:u,needAttach:h}=createScript({url:c,cb:()=>{},attrs:i,createScriptHook:(d,p)=>{const m=t.loaderHook.lifecycle.createScript.emit({url:d,attrs:p});if(m instanceof HTMLScriptElement)return m},needDeleteScript:!0});h&&document.head.appendChild(u)})}}}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:a=!0}=r||{loadFactory:!0},l=await this.getEntry();if(!this.inited){const d=this.host.shareScopeMap,p=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];p.length||p.push("default"),p.forEach(E=>{d[E]||(d[E]={})});const m=d[p[0]],_=[],g={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?p:this.remoteInfo.shareScope||"default"};Object.defineProperty(g,"shareScopeMap",{value:d,enumerable:!1});const y=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:m,remoteEntryInitOptions:g,initScope:_,remoteInfo:this.remoteInfo,origin:this.host});typeof(l==null?void 0:l.init)>"u"&&error(getShortErrorMsg(RUNTIME_002,runtimeDescMap,{hostName:this.host.name,remoteName:this.remoteInfo.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:o,moduleInfo:this.remoteInfo}),i||(i=await l.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 a?await u():u}wraperFactory(t,o){function r(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 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 a=l=>l===!1?!1:s<r.length?Promise.resolve(r[s++].apply(null,t)).then(a):l;o=a()}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=l=>(warn(l),this.onerror(l),t),a=l=>{if(checkReturnData(t,l)){if(t=l,r<o.length)try{return Promise.resolve(o[r++](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 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 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:a,id:l}=n;if(!isRemoteInfoWithEntry(t)||!isPureRemoteEntry(t)){const{remoteSnapshot:i,globalSnapshot:c}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:l});assignRemoteInfo(a,i);const u={remote:t,preloadConfig:{nameOrAlias:o,exposes:[r],resourceCategory:"sync",share:!1,depsRemote:!1}},h=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:u,remoteInfo:a,remote:t,remoteSnapshot:i,globalSnapshot:c});return h&&preloadAssets(a,s,h,!1),_extends$1({},n,{remoteSnapshot:i})}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={},a){const l=getFMId(t),{value:i}=getInfoWithoutType(n,l),c=a||i;if(c&&!isManifestProvider(c)&&(o(c,t,r),c.remotesInfo)){const u=Object.keys(c.remotesInfo);for(const h of u){if(s[h])continue;s[h]=!0;const d=splitId(h),p=c.remotesInfo[h];traverseModuleInfo(n,{name:d.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 a=[],l=[],i=[],c=new Set,u=new Set,{options:h}=n,{preloadConfig:d}=t,{depsRemote:p}=d;if(traverseModuleInfo(r,o,(y,E,I)=>{let S;if(I)S=d;else if(Array.isArray(p)){const O=p.find(T=>T.nameOrAlias===E.name||T.nameOrAlias===E.alias);if(!O)return;S=defaultPreloadArgs(O)}else if(p===!0)S=d;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 $;b=y==null||($=y.modules)==null?void 0:$.reduce((O,T)=>((v==null?void 0:v.indexOf(T.moduleName))!==-1&&O.push(T),O),[])}function A(O){const T=O.map(N=>getResourceUrl(y,N));return S.filter?T.filter(S.filter):T}if(b){const O=b.length;for(let T=0;T<O;T++){const N=b[T],w=`${E.name}/${N.moduleName}`;n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:N.moduleName==="."?E.name:w,name:E.name,remoteSnapshot:y,preloadConfig:S,remote:E,origin:n}),!getPreloaded(w)&&(S.resourceCategory==="all"?(a.push(...A(N.assets.css.async)),a.push(...A(N.assets.css.sync)),l.push(...A(N.assets.js.async)),l.push(...A(N.assets.js.sync))):(S.resourceCategory="sync")&&(a.push(...A(N.assets.css.sync)),l.push(...A(N.assets.js.sync))),setPreloaded(w))}}},!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=h.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 _=l.filter(y=>!c.has(y)&&!isExisted("script",y));return{cssAssets:a.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:a,remoteSnapshot:l}=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,l),generatePreloadAssets(t,o,r,a,l)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function getGlobalRemoteInfo(n,t){const o=getGlobalSnapshotInfoByModuleInfo({name:t.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 loadRemoteSnapshotInfo({moduleInfo:t,id:o,expose:r}){const{options:s}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:s,moduleInfo:t});let a=getGlobalSnapshotInfoByModuleInfo({name:this.HostInstance.options.name,version:this.HostInstance.options.version});a||(a={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},addGlobalSnapshot({[this.HostInstance.options.name]:a})),a&&"remotesInfo"in a&&!getInfoWithoutType(a.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(a.remotesInfo=_extends$1({},a==null?void 0:a.remotesInfo,{[t.name]:{matchedVersion:"version"in t?t.version:t.entry}}));const{hostGlobalSnapshot:l,remoteSnapshot:i,globalSnapshot:c}=this.getGlobalRemoteInfo(t),{remoteSnapshot:u,globalSnapshot:h}=await this.hooks.lifecycle.loadSnapshot.emit({options:s,moduleInfo:t,hostGlobalSnapshot:l,remoteSnapshot:i,globalSnapshot:c});let d,p;if(u)if(isManifestProvider(u)){const m=isBrowserEnv()?u.remoteEntry:u.ssrRemoteEntry||u.remoteEntry||"",_=await this.getManifestJson(m,t,{}),g=setGlobalSnapshotInfoByModuleInfo(_extends$1({},t,{entry:m}),_);d=_,p=g}else{const{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:u,from:"global"});d=m,p=h}else if(isRemoteInfoWithEntry(t)){const m=await this.getManifestJson(t.entry,t,{}),_=setGlobalSnapshotInfoByModuleInfo(t,m),{remoteSnapshot:g}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:m,from:"global"});d=g,p=_}else error(getShortErrorMsg(RUNTIME_007,runtimeDescMap,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(h)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:o,host:this.HostInstance,options:s,moduleInfo:t,remoteSnapshot:d}),{remoteSnapshot:d,globalSnapshot:p}}getGlobalRemoteInfo(t){return getGlobalRemoteInfo(t,this.HostInstance)}async getManifestJson(t,o,r){const s=async()=>{let l=this.manifestCache.get(t);if(l)return l;try{let i=await this.loaderHook.lifecycle.fetch.emit(t,{});(!i||!(i instanceof Response))&&(i=await fetch(t,{})),l=await i.json()}catch(i){l=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),l||(delete this.manifestLoading[t],error(getShortErrorMsg(RUNTIME_003,runtimeDescMap,{manifestUrl:t,moduleName:o.name,hostName:this.HostInstance.options.name},`${i}`)))}return assert(l.metaData&&l.exposes&&l.shared,`${t} is not a federation manifest`),this.manifestCache.set(t,l),l},a=async()=>{const l=await s(),i=generateSnapshotFromManifest(l,{version:t}),{remoteSnapshot:c}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:o,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,o){const{shareInfos:r,shared:s}=formatShareConfigs(t,o);return Object.keys(r).forEach(l=>{r[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: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 a=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:t,shareInfo:s,shared:r.options.shared,origin:r}),{shareInfo:l}=a;assert(l,`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,l,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 h=(async()=>{const d=await i.get();l.lib=d,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=d,p.loaded=!0),d})();return this.setShared({pkgName:t,loaded:!1,shared:i,from:r.options.name,lib:null,loading:h}),h}else{if(o!=null&&o.customShareInfo)return!1;const h=(async()=>{const d=await l.get();l.lib=d,l.loaded=!0,c(l);const p=getRegisteredShare(this.shareScopeMap,t,l,this.hooks.lifecycle.resolveShare);return p&&(p.lib=d,p.loaded=!0),d})();return this.setShared({pkgName:t,loaded:!1,shared:l,from:r.options.name,lib:null,loading:h}),h}}initializeSharing(t=DEFAULT_SCOPE,o){const{host:r}=this,s=o==null?void 0:o.from,a=o==null?void 0:o.strategy;let l=o==null?void 0:o.initScope;const i=[];if(s!=="build"){const{initTokens:_}=this;l||(l=[]);let g=_[t];if(g||(g=_[t]={from:this.host.name}),l.indexOf(g)>=0)return i;l.push(g)}const c=this.shareScopeMap,u=r.options.name;c[t]||(c[t]={});const h=c[t],d=(_,g)=>{var y;const{version:E,eager:I}=g;h[_]=h[_]||{};const S=h[_],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)},p=_=>_&&_.init&&_.init(c[t],l),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 p(y),g.inited=!0)}};return Object.keys(r.options.shared).forEach(_=>{r.options.shared[_].forEach(y=>{y.scope.includes(t)&&d(_,y)})}),(r.options.shareStrategy==="version-first"||a==="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 a=getRegisteredShare(this.shareScopeMap,t,s,this.hooks.lifecycle.resolveShare),l=i=>{i.useIn||(i.useIn=[]),addUniqueItem(i.useIn,r.options.name)};if(a){if(typeof a.lib=="function")return l(a),a.loaded||(a.loaded=!0,a.from===r.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:r.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=(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:a,loaded:l,get:i}){const{version:c,scope:u="default"}=o,h=_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"]},h,{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 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,a)=>(this.registerRemote(a,s,{force:!1}),s),t.remotes)}setIdToRemoteMap(t,o){const{remote:r,expose:s}=o,{name:a,alias:l}=r;if(this.idToRemoteMap[t]={name:r.name,expose:s},l&&t.startsWith(a)){const i=t.replace(a,l);this.idToRemoteMap[i]={name:r.name,expose:s};return}if(l&&t.startsWith(l)){const i=t.replace(l,a);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:a,moduleOptions:l,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:t}),{pkgNameOrAlias:c,remote:u,expose:h,id:d,remoteSnapshot:p}=i,m=await a.get(d,h,o,p),_=await this.hooks.lifecycle.onLoad.emit({id:d,pkgNameOrAlias:c,expose:h,exposeModule:s?m:void 0,exposeModuleFactory:s?void 0:m,remote:u,options:l,moduleInstance:a,origin:r});return this.setIdToRemoteMap(t,i),typeof _=="function"?_:m}catch(s){const{from:a="runtime"}=o||{from:"runtime"},l=await this.hooks.lifecycle.errorLoadRemote.emit({id:t,error:s,from:a,lifecycle:"onLoad",origin:r});if(!l)throw s;return l}}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:a}=s,l=getRemoteInfo(a),{globalSnapshot:i,remoteSnapshot:c}=await o.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:a}),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:s,remote:a,remoteInfo:l,globalSnapshot:i,remoteSnapshot:c});u&&preloadAssets(l,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:a}=s,l=matchRemoteWithNameAndExpose(o.options.remotes,a);assert(l,getShortErrorMsg(RUNTIME_004,runtimeDescMap,{hostName:o.options.name,requestId:a}));const{remote:i}=l,c=getRemoteInfo(i),u=await o.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({id:a},l,{options:o.options,origin:o,remoteInfo:c})),{remote:h,expose:d}=u;assert(h&&d,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);let p=o.moduleCache.get(h.name);const m={host:o,remoteInfo:c};return p||(p=new Module(m),o.moduleCache.set(h.name,p)),{module:p,moduleOptions:m,remoteMatchInfo:u}}registerRemote(t,o,r){const{host:s}=this,a=()=>{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 l=o.find(i=>i.name===t.name);if(!l)a(),o.push(t),this.hooks.lifecycle.registerRemote.emit({remote:t,origin:s});else{const i=[`The remote "${t.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];r!=null&&r.force&&(this.removeRemote(l),a(),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,a=r.options.remotes.findIndex(i=>i.name===s);a!==-1&&r.options.remotes.splice(a,1);const l=r.moduleCache.get(t.name);if(l){const i=l.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(l.remoteInfo);globalLoading[u]&&delete globalLoading[u],r.snapshotHandler.manifestCache.delete(i.entry);let h=i.buildVersion?composeKeyWithSeparator(i.name,i.buildVersion):i.name;const d=CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(m=>i.buildVersion?m.options.id===h:m.name===h);if(d!==-1){const m=CurrentGlobal.__FEDERATION__.__INSTANCES__[d];h=m.options.id||h;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($=>{const A=v[$];A&&typeof A=="object"&&A.from===i.name&&(A.loaded||A.loading?(A.useIn=A.useIn.filter(O=>O!==i.name),A.useIn.length?g=!1:y.push([E,S,b,$])):y.push([E,S,b,$]))})})})}),g&&(m.shareScopeMap={},delete _[h]),y.forEach(([E,I,S,R])=>{var b,v,$;($=_[E])==null||(v=$[I])==null||(b=v[S])==null||delete b[R]}),CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(d,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={}}}const USE_SNAPSHOT=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;class FederationHost{initOptions(t){this.registerPlugins(t.plugins);const 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}),a=new Module({host:this,remoteInfo:s});return a.remoteEntryExports=r,this.moduleCache.set(t,a),a}async loadRemote(t,o){return this.remoteHandler.loadRemote(t,o)}async preloadRemote(t){return this.remoteHandler.preloadRemote(t)}initShareScopeMap(t,o,r={}){this.sharedHandler.initShareScopeMap(t,o,r)}formatOptions(t,o){const{shared:r}=formatShareConfigs(t,o),{userOptions:s,options:a}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:o,options:t,shareInfo:r}),l=this.remoteHandler.formatAndRegisterRemote(a,s),{shared:i}=this.sharedHandler.registerShared(a,s),c=[...a.plugins];s.plugins&&s.plugins.forEach(h=>{c.includes(h)||c.push(h)});const u=_extends$1({},t,o,{plugins:c,remotes:l,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(a=>a.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.16.0",this.moduleCache=new Map,this.loaderHook=new PluginSystem({getModuleInfo:new SyncHook,createScript:new SyncHook,createLink:new SyncHook,fetch:new AsyncHook,loadEntryError:new AsyncHook,getModuleFactory:new AsyncHook}),this.bridgeHook=new PluginSystem({beforeBridgeRender:new SyncHook,afterBridgeRender:new SyncHook,beforeBridgeDestroy:new SyncHook,afterBridgeDestroy:new SyncHook});const o=USE_SNAPSHOT?[snapshotPlugin(),generatePreloadAssetsPlugin()]:[],r={id:getBuilderId(),name:t.name,plugins:o,remotes:[],shared:{},inBrowser:isBrowserEnv()};this.name=t.name,this.options=r,this.snapshotHandler=new SnapshotHandler(this),this.sharedHandler=new SharedHandler(this),this.remoteHandler=new RemoteHandler(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...r.plugins,...t.plugins||[]]),this.options=this.formatOptions(r,t)}}let FederationInstance=null;function getInstance(){return FederationInstance}setGlobalFederationConstructor(FederationHost);function createBridgeComponent(n){const t=new Map,o=getInstance();return()=>({__APP_VERSION__:"0.16.0",async render(r){var _,g,y;LoggerInstance.debug("createBridgeComponent render Info",r);const{moduleName:s,dom:a,basename:l,memoryRoute:i,hashRoute:c,...u}=r,h=Vue__namespace.createApp(n.rootComponent,u);t.set(a,h);const d=await((y=(g=(_=o==null?void 0:o.bridgeHook)==null?void 0:_.lifecycle)==null?void 0:g.beforeBridgeRender)==null?void 0:y.emit(r)),p=d&&typeof d=="object"&&(d!=null&&d.extraProps)?d==null?void 0:d.extraProps:{},m=n.appOptions({app:h,basename:l,memoryRoute:i,hashRoute:c,...u,...p});if(m!=null&&m.router){let E,I=m.router.getRoutes();r.memoryRoute?E=VueRouter__namespace.createMemoryHistory(r.basename):r.hashRoute?(E=VueRouter__namespace.createWebHashHistory(),I=I.map(R=>({...R,path:r.basename+R.path}))):E=VueRouter__namespace.createWebHistory(r.basename);const S=VueRouter__namespace.createRouter({...m.router.options,history:E,routes:I});LoggerInstance.debug("createBridgeComponent render router info>>>",{moduleName:s,router:S}),i&&await S.push(i.entryPath),h.use(S)}h.mount(a)},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(),a=getInstance(),l=Vue.useAttrs(),i=async()=>{var p,m,_,g;const u=(p=n.providerInfo)==null?void 0:p.call(n);o.value=u;let h={...l,moduleName:n.moduleName,dom:t.value,basename:n.basename,memoryRoute:n.memoryRoute,hashRoute:n.hashRoute};LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",h);const d=await((g=(_=(m=a==null?void 0:a.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:_.beforeBridgeRender)==null?void 0:g.emit(h))||{};h={...h,...d.extraProps},u.render(h)},c=Vue.watch(()=>s==null?void 0:s.path,u=>{u!==s.path&&i(),r.value!==""&&r.value!==u&&(LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...n,pathname:s.path}),e()),r.value=u});return Vue.onMounted(()=>{i()}),Vue.onBeforeUnmount(()=>{var u;LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>",{...n}),c(),(u=o.value)==null||u.destroy({dom:t.value})}),()=>Vue.createVNode("div",Vue.mergeProps(n.rootAttrs||{},{ref:t}),null)}});function createRemoteAppComponent(n){return Vue.defineAsyncComponent({__APP_VERSION__:"0.16.0",...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("createRemoteAppComponent LazyComponent create >>>",{basename:o,info:n});const a=await n.loader(),l=a&&a[Symbol.for("mf_module_id")],i=a[s];if(LoggerInstance.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:l,module:a,exportName:s,basename:o,route:t}),s in a&&typeof i=="function")return{render(){return Vue.h(RemoteApp,{moduleName:l,providerInfo:i,basename:o,rootAttrs:n.rootAttrs})}};throw new Error("module not found")}})}function createRemoteComponent(n){return LoggerInstance.warn("createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!"),createRemoteAppComponent(n)}exports.createBridgeComponent=createBridgeComponent;exports.createRemoteAppComponent=createRemoteAppComponent;exports.createRemoteComponent=createRemoteComponent;
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,16 @@ export declare function createBridgeComponent(bridgeInfo: ProviderFnParams): ()
|
|
|
18
18
|
}): void;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
export declare function createRemoteAppComponent(info: {
|
|
22
|
+
loader: () => Promise<any>;
|
|
23
|
+
export?: string;
|
|
24
|
+
asyncComponentOptions?: Omit<AsyncComponentOptions, 'loader'>;
|
|
25
|
+
rootAttrs?: Record<string, unknown>;
|
|
26
|
+
}): new () => ComponentPublicInstance;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!
|
|
30
|
+
*/
|
|
21
31
|
export declare function createRemoteComponent(info: {
|
|
22
32
|
loader: () => Promise<any>;
|
|
23
33
|
export?: string;
|
package/dist/index.js
CHANGED
|
@@ -1079,6 +1079,137 @@ function getRemoteInfo(n) {
|
|
|
1079
1079
|
shareScope: n.shareScope || DEFAULT_SCOPE
|
|
1080
1080
|
});
|
|
1081
1081
|
}
|
|
1082
|
+
function defaultPreloadArgs(n) {
|
|
1083
|
+
return _extends$1({
|
|
1084
|
+
resourceCategory: "sync",
|
|
1085
|
+
share: !0,
|
|
1086
|
+
depsRemote: !0,
|
|
1087
|
+
prefetchInterface: !1
|
|
1088
|
+
}, n);
|
|
1089
|
+
}
|
|
1090
|
+
function formatPreloadArgs(n, t) {
|
|
1091
|
+
return t.map((o) => {
|
|
1092
|
+
const r = matchRemote(n, o.nameOrAlias);
|
|
1093
|
+
return assert(r, `Unable to preload ${o.nameOrAlias} as it is not included in ${!r && safeToString({
|
|
1094
|
+
remoteInfo: r,
|
|
1095
|
+
remotes: n
|
|
1096
|
+
})}`), {
|
|
1097
|
+
remote: r,
|
|
1098
|
+
preloadConfig: defaultPreloadArgs(o)
|
|
1099
|
+
};
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
function normalizePreloadExposes(n) {
|
|
1103
|
+
return n ? n.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1104
|
+
}
|
|
1105
|
+
function preloadAssets(n, t, o, r = !0) {
|
|
1106
|
+
const { cssAssets: s, jsAssetsWithoutEntry: a, entryAssets: l } = o;
|
|
1107
|
+
if (t.options.inBrowser) {
|
|
1108
|
+
if (l.forEach((i) => {
|
|
1109
|
+
const { moduleInfo: c } = i, u = t.moduleCache.get(n.name);
|
|
1110
|
+
getRemoteEntry(u ? {
|
|
1111
|
+
origin: t,
|
|
1112
|
+
remoteInfo: c,
|
|
1113
|
+
remoteEntryExports: u.remoteEntryExports
|
|
1114
|
+
} : {
|
|
1115
|
+
origin: t,
|
|
1116
|
+
remoteInfo: c,
|
|
1117
|
+
remoteEntryExports: void 0
|
|
1118
|
+
});
|
|
1119
|
+
}), r) {
|
|
1120
|
+
const i = {
|
|
1121
|
+
rel: "preload",
|
|
1122
|
+
as: "style"
|
|
1123
|
+
};
|
|
1124
|
+
s.forEach((c) => {
|
|
1125
|
+
const { link: u, needAttach: p } = createLink({
|
|
1126
|
+
url: c,
|
|
1127
|
+
cb: () => {
|
|
1128
|
+
},
|
|
1129
|
+
attrs: i,
|
|
1130
|
+
createLinkHook: (d, m) => {
|
|
1131
|
+
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1132
|
+
url: d,
|
|
1133
|
+
attrs: m
|
|
1134
|
+
});
|
|
1135
|
+
if (y instanceof HTMLLinkElement)
|
|
1136
|
+
return y;
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
p && document.head.appendChild(u);
|
|
1140
|
+
});
|
|
1141
|
+
} else {
|
|
1142
|
+
const i = {
|
|
1143
|
+
rel: "stylesheet",
|
|
1144
|
+
type: "text/css"
|
|
1145
|
+
};
|
|
1146
|
+
s.forEach((c) => {
|
|
1147
|
+
const { link: u, needAttach: p } = createLink({
|
|
1148
|
+
url: c,
|
|
1149
|
+
cb: () => {
|
|
1150
|
+
},
|
|
1151
|
+
attrs: i,
|
|
1152
|
+
createLinkHook: (d, m) => {
|
|
1153
|
+
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1154
|
+
url: d,
|
|
1155
|
+
attrs: m
|
|
1156
|
+
});
|
|
1157
|
+
if (y instanceof HTMLLinkElement)
|
|
1158
|
+
return y;
|
|
1159
|
+
},
|
|
1160
|
+
needDeleteLink: !1
|
|
1161
|
+
});
|
|
1162
|
+
p && document.head.appendChild(u);
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
if (r) {
|
|
1166
|
+
const i = {
|
|
1167
|
+
rel: "preload",
|
|
1168
|
+
as: "script"
|
|
1169
|
+
};
|
|
1170
|
+
a.forEach((c) => {
|
|
1171
|
+
const { link: u, needAttach: p } = createLink({
|
|
1172
|
+
url: c,
|
|
1173
|
+
cb: () => {
|
|
1174
|
+
},
|
|
1175
|
+
attrs: i,
|
|
1176
|
+
createLinkHook: (d, m) => {
|
|
1177
|
+
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1178
|
+
url: d,
|
|
1179
|
+
attrs: m
|
|
1180
|
+
});
|
|
1181
|
+
if (y instanceof HTMLLinkElement)
|
|
1182
|
+
return y;
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
p && document.head.appendChild(u);
|
|
1186
|
+
});
|
|
1187
|
+
} else {
|
|
1188
|
+
const i = {
|
|
1189
|
+
fetchpriority: "high",
|
|
1190
|
+
type: (n == null ? void 0 : n.type) === "module" ? "module" : "text/javascript"
|
|
1191
|
+
};
|
|
1192
|
+
a.forEach((c) => {
|
|
1193
|
+
const { script: u, needAttach: p } = createScript({
|
|
1194
|
+
url: c,
|
|
1195
|
+
cb: () => {
|
|
1196
|
+
},
|
|
1197
|
+
attrs: i,
|
|
1198
|
+
createScriptHook: (d, m) => {
|
|
1199
|
+
const y = t.loaderHook.lifecycle.createScript.emit({
|
|
1200
|
+
url: d,
|
|
1201
|
+
attrs: m
|
|
1202
|
+
});
|
|
1203
|
+
if (y instanceof HTMLScriptElement)
|
|
1204
|
+
return y;
|
|
1205
|
+
},
|
|
1206
|
+
needDeleteScript: !0
|
|
1207
|
+
});
|
|
1208
|
+
p && document.head.appendChild(u);
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1082
1213
|
let Module = class {
|
|
1083
1214
|
async getEntry() {
|
|
1084
1215
|
if (this.remoteEntryExports)
|
|
@@ -1296,137 +1427,6 @@ class PluginSystem {
|
|
|
1296
1427
|
this.registerPlugins = {}, this.lifecycle = t, this.lifecycleKeys = Object.keys(t);
|
|
1297
1428
|
}
|
|
1298
1429
|
}
|
|
1299
|
-
function defaultPreloadArgs(n) {
|
|
1300
|
-
return _extends$1({
|
|
1301
|
-
resourceCategory: "sync",
|
|
1302
|
-
share: !0,
|
|
1303
|
-
depsRemote: !0,
|
|
1304
|
-
prefetchInterface: !1
|
|
1305
|
-
}, n);
|
|
1306
|
-
}
|
|
1307
|
-
function formatPreloadArgs(n, t) {
|
|
1308
|
-
return t.map((o) => {
|
|
1309
|
-
const r = matchRemote(n, o.nameOrAlias);
|
|
1310
|
-
return assert(r, `Unable to preload ${o.nameOrAlias} as it is not included in ${!r && safeToString({
|
|
1311
|
-
remoteInfo: r,
|
|
1312
|
-
remotes: n
|
|
1313
|
-
})}`), {
|
|
1314
|
-
remote: r,
|
|
1315
|
-
preloadConfig: defaultPreloadArgs(o)
|
|
1316
|
-
};
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
function normalizePreloadExposes(n) {
|
|
1320
|
-
return n ? n.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1321
|
-
}
|
|
1322
|
-
function preloadAssets(n, t, o, r = !0) {
|
|
1323
|
-
const { cssAssets: s, jsAssetsWithoutEntry: a, entryAssets: l } = o;
|
|
1324
|
-
if (t.options.inBrowser) {
|
|
1325
|
-
if (l.forEach((i) => {
|
|
1326
|
-
const { moduleInfo: c } = i, u = t.moduleCache.get(n.name);
|
|
1327
|
-
getRemoteEntry(u ? {
|
|
1328
|
-
origin: t,
|
|
1329
|
-
remoteInfo: c,
|
|
1330
|
-
remoteEntryExports: u.remoteEntryExports
|
|
1331
|
-
} : {
|
|
1332
|
-
origin: t,
|
|
1333
|
-
remoteInfo: c,
|
|
1334
|
-
remoteEntryExports: void 0
|
|
1335
|
-
});
|
|
1336
|
-
}), r) {
|
|
1337
|
-
const i = {
|
|
1338
|
-
rel: "preload",
|
|
1339
|
-
as: "style"
|
|
1340
|
-
};
|
|
1341
|
-
s.forEach((c) => {
|
|
1342
|
-
const { link: u, needAttach: p } = createLink({
|
|
1343
|
-
url: c,
|
|
1344
|
-
cb: () => {
|
|
1345
|
-
},
|
|
1346
|
-
attrs: i,
|
|
1347
|
-
createLinkHook: (d, m) => {
|
|
1348
|
-
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1349
|
-
url: d,
|
|
1350
|
-
attrs: m
|
|
1351
|
-
});
|
|
1352
|
-
if (y instanceof HTMLLinkElement)
|
|
1353
|
-
return y;
|
|
1354
|
-
}
|
|
1355
|
-
});
|
|
1356
|
-
p && document.head.appendChild(u);
|
|
1357
|
-
});
|
|
1358
|
-
} else {
|
|
1359
|
-
const i = {
|
|
1360
|
-
rel: "stylesheet",
|
|
1361
|
-
type: "text/css"
|
|
1362
|
-
};
|
|
1363
|
-
s.forEach((c) => {
|
|
1364
|
-
const { link: u, needAttach: p } = createLink({
|
|
1365
|
-
url: c,
|
|
1366
|
-
cb: () => {
|
|
1367
|
-
},
|
|
1368
|
-
attrs: i,
|
|
1369
|
-
createLinkHook: (d, m) => {
|
|
1370
|
-
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1371
|
-
url: d,
|
|
1372
|
-
attrs: m
|
|
1373
|
-
});
|
|
1374
|
-
if (y instanceof HTMLLinkElement)
|
|
1375
|
-
return y;
|
|
1376
|
-
},
|
|
1377
|
-
needDeleteLink: !1
|
|
1378
|
-
});
|
|
1379
|
-
p && document.head.appendChild(u);
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1382
|
-
if (r) {
|
|
1383
|
-
const i = {
|
|
1384
|
-
rel: "preload",
|
|
1385
|
-
as: "script"
|
|
1386
|
-
};
|
|
1387
|
-
a.forEach((c) => {
|
|
1388
|
-
const { link: u, needAttach: p } = createLink({
|
|
1389
|
-
url: c,
|
|
1390
|
-
cb: () => {
|
|
1391
|
-
},
|
|
1392
|
-
attrs: i,
|
|
1393
|
-
createLinkHook: (d, m) => {
|
|
1394
|
-
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1395
|
-
url: d,
|
|
1396
|
-
attrs: m
|
|
1397
|
-
});
|
|
1398
|
-
if (y instanceof HTMLLinkElement)
|
|
1399
|
-
return y;
|
|
1400
|
-
}
|
|
1401
|
-
});
|
|
1402
|
-
p && document.head.appendChild(u);
|
|
1403
|
-
});
|
|
1404
|
-
} else {
|
|
1405
|
-
const i = {
|
|
1406
|
-
fetchpriority: "high",
|
|
1407
|
-
type: (n == null ? void 0 : n.type) === "module" ? "module" : "text/javascript"
|
|
1408
|
-
};
|
|
1409
|
-
a.forEach((c) => {
|
|
1410
|
-
const { script: u, needAttach: p } = createScript({
|
|
1411
|
-
url: c,
|
|
1412
|
-
cb: () => {
|
|
1413
|
-
},
|
|
1414
|
-
attrs: i,
|
|
1415
|
-
createScriptHook: (d, m) => {
|
|
1416
|
-
const y = t.loaderHook.lifecycle.createScript.emit({
|
|
1417
|
-
url: d,
|
|
1418
|
-
attrs: m
|
|
1419
|
-
});
|
|
1420
|
-
if (y instanceof HTMLScriptElement)
|
|
1421
|
-
return y;
|
|
1422
|
-
},
|
|
1423
|
-
needDeleteScript: !0
|
|
1424
|
-
});
|
|
1425
|
-
p && document.head.appendChild(u);
|
|
1426
|
-
});
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
1430
|
function assignRemoteInfo(n, t) {
|
|
1431
1431
|
const o = getRemoteEntryInfoFromSnapshot(t);
|
|
1432
1432
|
o.url || error(`The attribute remoteEntry of ${n.name} must not be undefined.`);
|
|
@@ -2243,7 +2243,7 @@ class RemoteHandler {
|
|
|
2243
2243
|
}
|
|
2244
2244
|
}
|
|
2245
2245
|
const USE_SNAPSHOT = typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN == "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : !0;
|
|
2246
|
-
class
|
|
2246
|
+
class FederationHost {
|
|
2247
2247
|
initOptions(t) {
|
|
2248
2248
|
this.registerPlugins(t.plugins);
|
|
2249
2249
|
const o = this.formatOptions(this.options, t);
|
|
@@ -2320,11 +2320,6 @@ class ModuleFederation {
|
|
|
2320
2320
|
registerRemotes(t, o) {
|
|
2321
2321
|
return this.remoteHandler.registerRemotes(t, o);
|
|
2322
2322
|
}
|
|
2323
|
-
registerShared(t) {
|
|
2324
|
-
this.sharedHandler.registerShared(this.options, _extends$1({}, this.options, {
|
|
2325
|
-
shared: t
|
|
2326
|
-
}));
|
|
2327
|
-
}
|
|
2328
2323
|
constructor(t) {
|
|
2329
2324
|
this.hooks = new PluginSystem({
|
|
2330
2325
|
beforeInit: new SyncWaterfallHook("beforeInit"),
|
|
@@ -2368,7 +2363,7 @@ let FederationInstance = null;
|
|
|
2368
2363
|
function getInstance() {
|
|
2369
2364
|
return FederationInstance;
|
|
2370
2365
|
}
|
|
2371
|
-
setGlobalFederationConstructor(
|
|
2366
|
+
setGlobalFederationConstructor(FederationHost);
|
|
2372
2367
|
function createBridgeComponent(n) {
|
|
2373
2368
|
const t = /* @__PURE__ */ new Map(), o = getInstance();
|
|
2374
2369
|
return () => ({
|
|
@@ -2446,14 +2441,14 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2446
2441
|
memoryRoute: n.memoryRoute,
|
|
2447
2442
|
hashRoute: n.hashRoute
|
|
2448
2443
|
};
|
|
2449
|
-
LoggerInstance.debug("
|
|
2444
|
+
LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>", p);
|
|
2450
2445
|
const d = await ((E = (g = (y = a == null ? void 0 : a.bridgeHook) == null ? void 0 : y.lifecycle) == null ? void 0 : g.beforeBridgeRender) == null ? void 0 : E.emit(p)) || {};
|
|
2451
2446
|
p = {
|
|
2452
2447
|
...p,
|
|
2453
2448
|
...d.extraProps
|
|
2454
2449
|
}, u.render(p);
|
|
2455
2450
|
}, c = watch(() => s == null ? void 0 : s.path, (u) => {
|
|
2456
|
-
u !== s.path && i(), r.value !== "" && r.value !== u && (LoggerInstance.debug("
|
|
2451
|
+
u !== s.path && i(), r.value !== "" && r.value !== u && (LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>", {
|
|
2457
2452
|
...n,
|
|
2458
2453
|
pathname: s.path
|
|
2459
2454
|
}), e()), r.value = u;
|
|
@@ -2462,7 +2457,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2462
2457
|
i();
|
|
2463
2458
|
}), onBeforeUnmount(() => {
|
|
2464
2459
|
var u;
|
|
2465
|
-
LoggerInstance.debug("
|
|
2460
|
+
LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>", {
|
|
2466
2461
|
...n
|
|
2467
2462
|
}), c(), (u = o.value) == null || u.destroy({
|
|
2468
2463
|
dom: t.value
|
|
@@ -2472,7 +2467,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2472
2467
|
}), null);
|
|
2473
2468
|
}
|
|
2474
2469
|
});
|
|
2475
|
-
function
|
|
2470
|
+
function createRemoteAppComponent(n) {
|
|
2476
2471
|
return defineAsyncComponent({
|
|
2477
2472
|
__APP_VERSION__: "0.16.0",
|
|
2478
2473
|
...n.asyncComponentOptions,
|
|
@@ -2484,13 +2479,16 @@ function createRemoteComponent(n) {
|
|
|
2484
2479
|
const r = (u = (c = t == null ? void 0 : t.matched) == null ? void 0 : c[0]) == null ? void 0 : u.path;
|
|
2485
2480
|
r && (r.endsWith("/:pathMatch(.*)*") ? o = r.replace("/:pathMatch(.*)*", "") : o = t.matched[0].path);
|
|
2486
2481
|
const s = (n == null ? void 0 : n.export) || "default";
|
|
2487
|
-
LoggerInstance.debug(
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2482
|
+
LoggerInstance.debug(
|
|
2483
|
+
"createRemoteAppComponent LazyComponent create >>>",
|
|
2484
|
+
{
|
|
2485
|
+
basename: o,
|
|
2486
|
+
info: n
|
|
2487
|
+
}
|
|
2488
|
+
);
|
|
2491
2489
|
const a = await n.loader(), l = a && a[Symbol.for("mf_module_id")], i = a[s];
|
|
2492
2490
|
if (LoggerInstance.debug(
|
|
2493
|
-
"
|
|
2491
|
+
"createRemoteAppComponent LazyComponent loadRemote info >>>",
|
|
2494
2492
|
{ moduleName: l, module: a, exportName: s, basename: o, route: t }
|
|
2495
2493
|
), s in a && typeof i == "function")
|
|
2496
2494
|
return {
|
|
@@ -2507,7 +2505,13 @@ function createRemoteComponent(n) {
|
|
|
2507
2505
|
}
|
|
2508
2506
|
});
|
|
2509
2507
|
}
|
|
2508
|
+
function createRemoteComponent(n) {
|
|
2509
|
+
return LoggerInstance.warn(
|
|
2510
|
+
"createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!"
|
|
2511
|
+
), createRemoteAppComponent(n);
|
|
2512
|
+
}
|
|
2510
2513
|
export {
|
|
2511
2514
|
createBridgeComponent,
|
|
2515
|
+
createRemoteAppComponent,
|
|
2512
2516
|
createRemoteComponent
|
|
2513
2517
|
};
|
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-20250708033956",
|
|
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-20250708033956",
|
|
36
|
+
"@module-federation/sdk": "0.0.0-next-20250708033956",
|
|
37
|
+
"@module-federation/runtime": "0.0.0-next-20250708033956"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@vitejs/plugin-vue": "^5.0.4",
|
package/src/create.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { LoggerInstance } from './utils.js';
|
|
|
5
5
|
|
|
6
6
|
declare const __APP_VERSION__: string;
|
|
7
7
|
|
|
8
|
-
export function
|
|
8
|
+
export function createRemoteAppComponent(info: {
|
|
9
9
|
loader: () => Promise<any>;
|
|
10
10
|
export?: string;
|
|
11
11
|
asyncComponentOptions?: Omit<AsyncComponentOptions, 'loader'>;
|
|
@@ -29,17 +29,20 @@ export function createRemoteComponent(info: {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const exportName = info?.export || 'default';
|
|
32
|
-
LoggerInstance.debug(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
LoggerInstance.debug(
|
|
33
|
+
`createRemoteAppComponent LazyComponent create >>>`,
|
|
34
|
+
{
|
|
35
|
+
basename,
|
|
36
|
+
info,
|
|
37
|
+
},
|
|
38
|
+
);
|
|
36
39
|
|
|
37
40
|
const module: any = await info.loader();
|
|
38
41
|
const moduleName = module && module[Symbol.for('mf_module_id')];
|
|
39
42
|
const exportFn = module[exportName];
|
|
40
43
|
|
|
41
44
|
LoggerInstance.debug(
|
|
42
|
-
`
|
|
45
|
+
`createRemoteAppComponent LazyComponent loadRemote info >>>`,
|
|
43
46
|
{ moduleName, module, exportName, basename, route },
|
|
44
47
|
);
|
|
45
48
|
|
|
@@ -59,3 +62,18 @@ export function createRemoteComponent(info: {
|
|
|
59
62
|
},
|
|
60
63
|
});
|
|
61
64
|
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!
|
|
68
|
+
*/
|
|
69
|
+
export function createRemoteComponent(info: {
|
|
70
|
+
loader: () => Promise<any>;
|
|
71
|
+
export?: string;
|
|
72
|
+
asyncComponentOptions?: Omit<AsyncComponentOptions, 'loader'>;
|
|
73
|
+
rootAttrs?: Record<string, unknown>;
|
|
74
|
+
}) {
|
|
75
|
+
LoggerInstance.warn(
|
|
76
|
+
'createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!',
|
|
77
|
+
);
|
|
78
|
+
return createRemoteAppComponent(info);
|
|
79
|
+
}
|
package/src/index.ts
CHANGED
package/src/remoteApp.tsx
CHANGED
|
@@ -43,7 +43,7 @@ export default defineComponent({
|
|
|
43
43
|
hashRoute: props.hashRoute,
|
|
44
44
|
};
|
|
45
45
|
LoggerInstance.debug(
|
|
46
|
-
`
|
|
46
|
+
`createRemoteAppComponent LazyComponent render >>>`,
|
|
47
47
|
renderProps,
|
|
48
48
|
);
|
|
49
49
|
|
|
@@ -67,7 +67,7 @@ export default defineComponent({
|
|
|
67
67
|
// dispatchPopstateEnv
|
|
68
68
|
if (pathname.value !== '' && pathname.value !== newPath) {
|
|
69
69
|
LoggerInstance.debug(
|
|
70
|
-
`
|
|
70
|
+
`createRemoteAppComponent dispatchPopstateEnv >>>`,
|
|
71
71
|
{
|
|
72
72
|
...props,
|
|
73
73
|
pathname: route.path,
|
|
@@ -84,9 +84,12 @@ export default defineComponent({
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
onBeforeUnmount(() => {
|
|
87
|
-
LoggerInstance.debug(
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
LoggerInstance.debug(
|
|
88
|
+
`createRemoteAppComponent LazyComponent destroy >>>`,
|
|
89
|
+
{
|
|
90
|
+
...props,
|
|
91
|
+
},
|
|
92
|
+
);
|
|
90
93
|
watchStopHandle();
|
|
91
94
|
|
|
92
95
|
hostInstance?.bridgeHook?.lifecycle?.beforeBridgeDestroy?.emit({
|