@module-federation/bridge-vue3 2.2.2 → 2.2.3
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 +9 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +22 -13
- package/package.json +7 -7
- package/src/create.ts +6 -2
- package/src/routeUtils.ts +28 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @module-federation/bridge-vue3
|
|
2
2
|
|
|
3
|
+
## 2.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7489d7c: fix(bridge-vue3): pass hashRoute and memoryRoute to RemoteApp, fix path and redirect prefixing in addBasenameToNestedRoutes
|
|
8
|
+
- @module-federation/runtime@2.2.3
|
|
9
|
+
- @module-federation/sdk@2.2.3
|
|
10
|
+
- @module-federation/bridge-shared@2.2.3
|
|
11
|
+
|
|
3
12
|
## 2.2.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -4,5 +4,5 @@ ${r.slice(0,5).join(`
|
|
|
4
4
|
`)}`:void 0}catch{return}}var tt=class{constructor(e,t=X){this.prefix=e,this.delegate=t??X}setPrefix(e){this.prefix=e}setDelegate(e){this.delegate=e??X}emit(e,t){const r=this.delegate,n=we()?Jt():void 0,o=n?[...t,n]:t,s=(()=>{switch(e){case"log":return["log","info"];case"info":return["info","log"];case"warn":return["warn","info","log"];case"error":return["error","warn","log"];default:return["debug","log"]}})();for(const i of s){const a=r[i];if(typeof a=="function"){a.call(r,this.prefix,...o);return}}for(const i of s){const a=X[i];if(typeof a=="function"){a.call(X,this.prefix,...o);return}}}log(...e){this.emit("log",e)}warn(...e){this.emit("warn",e)}error(...e){this.emit("error",e)}success(...e){this.emit("info",e)}info(...e){this.emit("info",e)}ready(...e){this.emit("info",e)}debug(...e){we()&&this.emit("debug",e)}};function rt(e){return new tt(e)}function Xt(e){const t=new tt(e);return Object.defineProperty(t,"__mf_infrastructure_logger__",{value:!0,enumerable:!1,configurable:!1}),t}Xt(Kt);async function nt(e,t){try{return await e()}catch(r){Ze(r);return}}function Ie(e,t){const r=/^(https?:)?\/\//i;return e.replace(r,"").replace(/\/$/,"")===t.replace(r,"").replace(/\/$/,"")}function ot(e){let t=null,r=!0,n=2e4,o;const s=document.getElementsByTagName("script");for(let c=0;c<s.length;c++){const f=s[c],h=f.getAttribute("src");if(h&&Ie(h,e.url)){t=f,r=!1;break}}if(!t){const c=e.attrs;t=document.createElement("script"),t.type=(c==null?void 0:c.type)==="module"?"module":"text/javascript";let f;e.createScriptHook&&(f=e.createScriptHook(e.url,e.attrs),f instanceof HTMLScriptElement?t=f:typeof f=="object"&&("script"in f&&f.script&&(t=f.script),"timeout"in f&&f.timeout&&(n=f.timeout))),t.src||(t.src=e.url),c&&!f&&Object.keys(c).forEach(h=>{t&&(h==="async"||h==="defer"?t[h]=c[h]:t.getAttribute(h)||t.setAttribute(h,c[h]))})}let i=null;const a=typeof window<"u"?c=>{if(c.filename&&Ie(c.filename,e.url)){const f=new Error(`ScriptExecutionError: Script "${e.url}" loaded but threw a runtime error during execution: ${c.message} (${c.filename}:${c.lineno}:${c.colno})`);f.name="ScriptExecutionError",i=f}}:null;a&&window.addEventListener("error",a);const l=async(c,f)=>{clearTimeout(o),a&&window.removeEventListener("error",a);const h=()=>{if((f==null?void 0:f.type)==="error"){const u=new Error(`ScriptNetworkError: Failed to load script "${e.url}" - the script URL is unreachable or the server returned an error (network failure, 404, CORS, etc.)`);u.name="ScriptNetworkError",e!=null&&e.onErrorCallback&&(e==null||e.onErrorCallback(u))}else i?e!=null&&e.onErrorCallback&&(e==null||e.onErrorCallback(i)):e!=null&&e.cb&&(e==null||e.cb())};if(t&&(t.onerror=null,t.onload=null,nt(()=>{const{needDeleteScript:u=!0}=e;u&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),c&&typeof c=="function")){const u=c(f);if(u instanceof Promise){const d=await u;return h(),d}return h(),u}h()};return t.onerror=l.bind(null,t.onerror),t.onload=l.bind(null,t.onload),o=setTimeout(()=>{l(null,new Error(`Remote script "${e.url}" time-outed.`))},n),{script:t,needAttach:r}}function Ee(e){let t=null,r=!0;const n=document.getElementsByTagName("link");for(let s=0;s<n.length;s++){const i=n[s],a=i.getAttribute("href"),l=i.getAttribute("rel");if(a&&Ie(a,e.url)&&l===e.attrs.rel){t=i,r=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",e.url);let s;const i=e.attrs;e.createLinkHook&&(s=e.createLinkHook(e.url,i),s instanceof HTMLLinkElement&&(t=s)),i&&!s&&Object.keys(i).forEach(a=>{t&&!t.getAttribute(a)&&t.setAttribute(a,i[a])})}const o=(s,i)=>{const a=()=>{(i==null?void 0:i.type)==="error"?e!=null&&e.onErrorCallback&&(e==null||e.onErrorCallback(i)):e!=null&&e.cb&&(e==null||e.cb())};if(t&&(t.onerror=null,t.onload=null,nt(()=>{const{needDeleteLink:l=!0}=e;l&&t!=null&&t.parentNode&&t.parentNode.removeChild(t)}),s)){const l=s(i);return a(),l}a()};return t.onerror=o.bind(null,t.onerror),t.onload=o.bind(null,t.onload),{link:t,needAttach:r}}function Yt(e,t){const{attrs:r={},createScriptHook:n}=t;return new Promise((o,s)=>{const{script:i,needAttach:a}=ot({url:e,cb:o,onErrorCallback:s,attrs:{fetchpriority:"high",...r},createScriptHook:n,needDeleteScript:!0});a&&document.head.appendChild(i)})}const se=new Map;function B(e){if(!e)throw new Error("import specifier is required");if(se.has(e))return se.get(e);const t=new Function("name","return import(name)")(e).then(r=>r).catch(r=>{throw console.error(`Error importing module ${e}:`,r),se.delete(e),r});return se.set(e,t),t}const st=async()=>{const e=await B("node-fetch");return e.default||e},Zt=async(e,t,r)=>{const o=await((s,i)=>r.lifecycle.fetch.emit(s,i))(e,t||{});return!o||!(o instanceof Response)?(typeof fetch>"u"?await st():fetch)(e,t||{}):o},Qt=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(e,t,r,n)=>{if(n!=null&&n.createScriptHook){const a=n.createScriptHook(e);a&&typeof a=="object"&&"url"in a&&(e=a.url)}let o;try{o=new URL(e)}catch(a){console.error("Error constructing URL:",a),t(new Error(`Invalid URL: ${a}`));return}const s=async()=>n!=null&&n.fetch?(a,l)=>Zt(a,l,n):typeof fetch>"u"?st():fetch,i=async(a,l)=>{var c;try{const h=await(await a(l.href)).text(),[u,d]=await Promise.all([B("path"),B("vm")]),m={exports:{},module:{exports:{}}},y=l.pathname.split("/").slice(0,-1).join("/"),g=u.basename(l.pathname),p=new d.Script(`(function(exports, module, require, __dirname, __filename) {${h}
|
|
5
5
|
})`,{filename:g,importModuleDynamically:((c=d.constants)==null?void 0:c.USE_MAIN_CONTEXT_DEFAULT_LOADER)??B});let E;E=(await B("node:module")).createRequire(l.protocol==="file:"||l.protocol==="node:"?l.href:u.join(process.cwd(),"__mf_require_base__.js")),p.runInThisContext()(m.exports,m.module,E,y,g);const b=m.module.exports||m.exports;if(r&&b&&r.globalName){t(void 0,b[r.globalName]||b);return}t(void 0,b)}catch(f){t(f instanceof Error?f:new Error(`Script execution error: ${f}`))}};s().then(async a=>{if((r==null?void 0:r.type)==="esm"||(r==null?void 0:r.type)==="module")return Te(o.href,{fetch:a,vm:await B("vm")}).then(async l=>{await l.evaluate(),t(void 0,l.namespace)}).catch(l=>{t(l instanceof Error?l:new Error(`Script execution error: ${l}`))});i(a,o)}).catch(a=>{t(a)})}:(e,t,r,n)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},er=typeof ENV_TARGET>"u"||ENV_TARGET!=="web"?(e,t)=>new Promise((r,n)=>{Qt(e,(o,s)=>{var i,a;if(o)n(o);else{const l=((i=t==null?void 0:t.attrs)==null?void 0:i.globalName)||`__FEDERATION_${(a=t==null?void 0:t.attrs)==null?void 0:a.name}:custom__`;r(globalThis[l]=s)}},t.attrs,t.loaderHook)}):(e,t)=>{throw new Error("loadScriptNode is disabled in non-Node.js environment")},_e=new Map;async function Te(e,t){if(_e.has(e))return _e.get(e);const{fetch:r,vm:n}=t,o=await(await r(e)).text(),s=new n.SourceTextModule(o,{importModuleDynamically:async(i,a)=>{const l=new URL(i,e).href;return Te(l,t)}});return _e.set(e,s),await s.link(async i=>{const a=new URL(i,e).href;return await Te(a,t)}),s}const D=rt("[ Module Federation Bridge Vue3 ]"),tr=e=>`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${e.split("-")[0].toLowerCase()}#${e.toLowerCase()}`,it=(e,t,r,n)=>{const o=[`${[t[e]]} #${e}`];return r&&o.push(`args: ${JSON.stringify(r)}`),o.push(tr(e)),n&&o.push(`Original Error Message:
|
|
6
6
|
${n}`),o.join(`
|
|
7
|
-
`)};function rr(e,t,r,n,o,s){return n(it(e,t,r,o))}const G="[ Federation Runtime ]",ve=rt(G);function k(e,t,r,n,o){e||S(t)}function S(e,t,r,n,o){if(t!==void 0)return rr(e,t,r??{},i=>{throw new Error(`${G}: ${i}`)},n);const s=e;throw s instanceof Error?(s.message.startsWith(G)||(s.message=`${G}: ${s.message}`),s):new Error(`${G}: ${s}`)}function Le(e){e instanceof Error&&(e.message.startsWith(G)||(e.message=`${G}: ${e.message}`)),ve.warn(e)}function nr(e,t){return e.findIndex(r=>r===t)===-1&&e.push(t),e}function Q(e){return"version"in e&&e.version?`${e.name}:${e.version}`:"entry"in e&&e.entry?`${e.name}:${e.entry}`:`${e.name}`}function Me(e){return typeof e.entry<"u"}function at(e){return!e.entry.includes(".json")}function Ce(e){return e&&typeof e=="object"}const or=Object.prototype.toString;function sr(e){return or.call(e)==="[object Object]"}function ct(e){return Array.isArray(e)?e:[e]}function lt(e){const t={url:"",type:"global",globalName:""};return H||Xe()||!("ssrRemoteEntry"in e)?"remoteEntry"in e?{url:e.remoteEntry,type:e.remoteEntryType,globalName:e.globalName}:t:"ssrRemoteEntry"in e?{url:e.ssrRemoteEntry||t.url,type:e.ssrRemoteEntryType||t.type,globalName:e.globalName}:t}const ir=(e,t)=>{let r;return e.endsWith("/")?r=e.slice(0,-1):r=e,t.startsWith(".")&&(t=t.slice(1)),r=r+t,r},I=typeof globalThis=="object"?globalThis:window,O=(()=>{try{return document.defaultView}catch{return I}})(),ee=O;function le(e,t,r){Object.defineProperty(e,t,{value:r,configurable:!1,writable:!0})}function ue(e,t){return Object.hasOwnProperty.call(e,t)}ue(I,"__GLOBAL_LOADING_REMOTE_ENTRY__")||le(I,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const W=I.__GLOBAL_LOADING_REMOTE_ENTRY__;function ut(e){var t,r,n,o,s,i;ue(e,"__VMOK__")&&!ue(e,"__FEDERATION__")&&le(e,"__FEDERATION__",e.__VMOK__),ue(e,"__FEDERATION__")||(le(e,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),le(e,"__VMOK__",e.__FEDERATION__)),(t=e.__FEDERATION__).__GLOBAL_PLUGIN__??(t.__GLOBAL_PLUGIN__=[]),(r=e.__FEDERATION__).__INSTANCES__??(r.__INSTANCES__=[]),(n=e.__FEDERATION__).moduleInfo??(n.moduleInfo={}),(o=e.__FEDERATION__).__SHARE__??(o.__SHARE__={}),(s=e.__FEDERATION__).__MANIFEST_LOADING__??(s.__MANIFEST_LOADING__={}),(i=e.__FEDERATION__).__PRELOADED_MAP__??(i.__PRELOADED_MAP__=new Map)}ut(I);ut(O);function ar(e,t=we()){t&&(I.__FEDERATION__.__DEBUG_CONSTRUCTOR__=e,I.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="2.2.2")}function K(e,t){if(typeof t=="string"){if(e[t])return{value:e[t],key:t};{const r=Object.keys(e);for(const n of r){const[o,s]=n.split(":"),i=`${o}:${t}`,a=e[i];if(a)return{value:a,key:i}}return{value:void 0,key:t}}}else S(`getInfoWithoutType: "key" must be a string, got ${typeof t} (${JSON.stringify(t)}).`)}const xe=()=>O.__FEDERATION__.moduleInfo,cr=(e,t)=>{const r=K(t,Q(e)).value;if(r&&!r.version&&"version"in e&&e.version&&(r.version=e.version),r)return r;if("version"in e&&e.version){const{version:n,...o}=e,s=Q(o),i=K(O.__FEDERATION__.moduleInfo,s).value;if((i==null?void 0:i.version)===n)return i}},fe=e=>cr(e,O.__FEDERATION__.moduleInfo),Ue=(e,t)=>{const r=Q(e);return O.__FEDERATION__.moduleInfo[r]=t,O.__FEDERATION__.moduleInfo},lr=e=>(O.__FEDERATION__.moduleInfo={...O.__FEDERATION__.moduleInfo,...e},()=>{const t=Object.keys(e);for(const r of t)delete O.__FEDERATION__.moduleInfo[r]}),De=(e,t)=>{const r=t||`__FEDERATION_${e}:custom__`;return{remoteEntryKey:r,entryExports:I[r]}},ur=()=>O.__FEDERATION__.__GLOBAL_PLUGIN__,fr=e=>I.__FEDERATION__.__PRELOADED_MAP__.get(e),hr=e=>I.__FEDERATION__.__PRELOADED_MAP__.set(e,!0),Ve="[0-9A-Za-z-]+",Fe=`(?:\\+(${Ve}(?:\\.${Ve})*))`,Z="0|[1-9]\\d*",he="[0-9]+",ft="\\d*[a-zA-Z-][a-zA-Z0-9-]*",Be=`(?:${he}|${ft})`,dr=`(?:-?(${Be}(?:\\.${Be})*))`,We=`(?:${Z}|${ft})`,ht=`(?:-(${We}(?:\\.${We})*))`,be=`${Z}|x|X|\\*`,z=`[v=\\s]*(${be})(?:\\.(${be})(?:\\.(${be})(?:${ht})?${Fe}?)?)?`,mr=`^\\s*(${z})\\s+-\\s+(${z})\\s*$`,pr=`[v=\\s]*${`(${he})\\.(${he})\\.(${he})`}${dr}?${Fe}?`,He="((?:<|>)?=?)",yr=`(\\s*)${He}\\s*(${pr}|${z})`,dt="(?:~>?)",gr=`(\\s*)${dt}\\s+`,mt="(?:\\^)",Er=`(\\s*)${mt}\\s+`,_r="(<|>)?=?\\s*\\*",br=`^${mt}${z}$`,Rr=`v?${`(${Z})\\.(${Z})\\.(${Z})`}${ht}?${Fe}?`,Sr=`^${dt}${z}$`,$r=`^${He}\\s*${z}$`,wr=`^${He}\\s*(${Rr})$|^$`,Nr="^\\s*>=\\s*0.0.0\\s*$";function C(e){return new RegExp(e)}function T(e){return!e||e.toLowerCase()==="x"||e==="*"}function pt(...e){return t=>e.reduce((r,n)=>n(r),t)}function je(e){return e.match(C(wr))}function qe(e,t,r,n){const o=`${e}.${t}.${r}`;return n?`${o}-${n}`:o}function Ir(e){return e.replace(C(mr),(t,r,n,o,s,i,a,l,c,f,h,u)=>(T(n)?r="":T(o)?r=`>=${n}.0.0`:T(s)?r=`>=${n}.${o}.0`:r=`>=${r}`,T(c)?l="":T(f)?l=`<${Number(c)+1}.0.0-0`:T(h)?l=`<${c}.${Number(f)+1}.0-0`:u?l=`<=${c}.${f}.${h}-${u}`:l=`<=${l}`,`${r} ${l}`.trim()))}function Tr(e){return e.replace(C(yr),"$1$2$3")}function vr(e){return e.replace(C(gr),"$1~")}function Ar(e){return e.replace(C(Er),"$1^")}function Pr(e){return e.trim().split(/\s+/).map(t=>t.replace(C(br),(r,n,o,s,i)=>T(n)?"":T(o)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:T(s)?n==="0"?`>=${n}.${o}.0 <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.0 <${Number(n)+1}.0.0-0`:i?n==="0"?o==="0"?`>=${n}.${o}.${s}-${i} <${n}.${o}.${Number(s)+1}-0`:`>=${n}.${o}.${s}-${i} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${s}-${i} <${Number(n)+1}.0.0-0`:n==="0"?o==="0"?`>=${n}.${o}.${s} <${n}.${o}.${Number(s)+1}-0`:`>=${n}.${o}.${s} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${s} <${Number(n)+1}.0.0-0`)).join(" ")}function kr(e){return e.trim().split(/\s+/).map(t=>t.replace(C(Sr),(r,n,o,s,i)=>T(n)?"":T(o)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:T(s)?`>=${n}.${o}.0 <${n}.${Number(o)+1}.0-0`:i?`>=${n}.${o}.${s}-${i} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${s} <${n}.${Number(o)+1}.0-0`)).join(" ")}function Or(e){return e.split(/\s+/).map(t=>t.trim().replace(C($r),(r,n,o,s,i,a)=>{const l=T(o),c=l||T(s),f=c||T(i);return n==="="&&f&&(n=""),a="",l?n===">"||n==="<"?"<0.0.0-0":"*":n&&f?(c&&(s=0),i=0,n===">"?(n=">=",c?(o=Number(o)+1,s=0,i=0):(s=Number(s)+1,i=0)):n==="<="&&(n="<",c?o=Number(o)+1:s=Number(s)+1),n==="<"&&(a="-0"),`${n+o}.${s}.${i}${a}`):c?`>=${o}.0.0${a} <${Number(o)+1}.0.0-0`:f?`>=${o}.${s}.0${a} <${o}.${Number(s)+1}.0-0`:r})).join(" ")}function Lr(e){return e.trim().replace(C(_r),"")}function Mr(e){return e.trim().replace(C(Nr),"")}function de(e,t){return e=Number(e)||e,t=Number(t)||t,e>t?1:e===t?0:-1}function Cr(e,t){const{preRelease:r}=e,{preRelease:n}=t;if(r===void 0&&n)return 1;if(r&&n===void 0)return-1;if(r===void 0&&n===void 0)return 0;for(let o=0,s=r.length;o<=s;o++){const i=r[o],a=n[o];if(i!==a)return i===void 0&&a===void 0?0:i?a?de(i,a):-1:1}return 0}function ie(e,t){return de(e.major,t.major)||de(e.minor,t.minor)||de(e.patch,t.patch)||Cr(e,t)}function Re(e,t){return e.version===t.version}function Dr(e,t){switch(e.operator){case"":case"=":return Re(e,t);case">":return ie(e,t)<0;case">=":return Re(e,t)||ie(e,t)<0;case"<":return ie(e,t)>0;case"<=":return Re(e,t)||ie(e,t)>0;case void 0:return!0;default:return!1}}function Fr(e){return pt(Pr,kr,Or,Lr)(e)}function Hr(e){return pt(Ir,Tr,vr,Ar)(e.trim()).split(/\s+/).join(" ")}function Y(e,t){if(!e)return!1;const r=je(e);if(!r)return!1;const[,n,,o,s,i,a]=r,l={operator:n,version:qe(o,s,i,a),major:o,minor:s,patch:i,preRelease:a==null?void 0:a.split(".")},c=t.split("||");for(const f of c){const h=f.trim();if(!h||h==="*"||h==="x")return!0;try{const u=Hr(h);if(!u.trim())return!0;const d=u.split(" ").map(g=>Fr(g)).join(" ");if(!d.trim())return!0;const m=d.split(/\s+/).map(g=>Mr(g)).filter(Boolean);if(m.length===0)continue;let y=!0;for(const g of m){const p=je(g);if(!p){y=!1;break}const[,E,,b,N,_,$]=p;if(!Dr({operator:E,version:qe(b,N,_,$),major:b,minor:N,patch:_,preRelease:$==null?void 0:$.split(".")},l)){y=!1;break}}if(y)return!0}catch(u){console.error(`[semver] Error processing range part "${h}":`,u);continue}}return!1}const ne="default",yt="global";function Gr(e,t,r,n){var s,i;let o;return"get"in e?o=e.get:"lib"in e?o=()=>Promise.resolve(e.lib):o=()=>Promise.resolve(()=>{S(`Cannot get shared "${r}" from "${t}": neither "get" nor "lib" is provided in the share config.`)}),(s=e.shareConfig)!=null&&s.eager&&((i=e.treeShaking)!=null&&i.mode)&&S(`Invalid shared config for "${r}" from "${t}": cannot use both "eager: true" and "treeShaking.mode" simultaneously. Choose one strategy.`),{deps:[],useIn:[],from:t,loading:null,...e,shareConfig:{requiredVersion:`^${e.version}`,singleton:!1,eager:!1,strictVersion:!1,...e.shareConfig},get:o,loaded:e!=null&&e.loaded||"lib"in e?!0:void 0,version:e.version??"0",scope:Array.isArray(e.scope)?e.scope:[e.scope??"default"],strategy:(e.strategy??n)||"version-first",treeShaking:e.treeShaking?{...e.treeShaking,mode:e.treeShaking.mode??"server-calc",status:e.treeShaking.status??$e.UNKNOWN,useIn:[]}:void 0}}function gt(e,t){const r=t.shared||{},n=t.name,o=Object.keys(r).reduce((i,a)=>{const l=ct(r[a]);return i[a]=i[a]||[],l.forEach(c=>{i[a].push(Gr(c,n,a,t.shareStrategy))}),i},{}),s={...e.shared};return Object.keys(o).forEach(i=>{s[i]?o[i].forEach(a=>{s[i].find(l=>l.version===a.version)||s[i].push(a)}):s[i]=o[i]}),{allShareInfos:s,newShareInfos:o}}function te(e,t){if(!e)return!1;const{status:r,mode:n}=e;return r===$e.NO_USE?!1:r===$e.CALCULATED?!0:n==="runtime-infer"?t?Ur(e,t):!0:!1}function x(e,t){const r=n=>{if(!Number.isNaN(Number(n))){const o=n.split(".");let s=n;for(let i=0;i<3-o.length;i++)s+=".0";return s}return n};return!!Y(r(e),`<=${r(t)}`)}const re=(e,t)=>{const r=t||function(n,o){return x(n,o)};return Object.keys(e).reduce((n,o)=>!n||r(n,o)||n==="0"?o:n,0)},pe=e=>!!e.loaded||typeof e.lib=="function",xr=e=>!!e.loading,Ur=(e,t)=>{if(!e||!t)return!1;const{usedExports:r}=e;return r?!!t.every(n=>r.includes(n)):!1};function Vr(e,t,r,n){const o=e[t][r];let s="",i=te(n);const a=function(l,c){return i?o[l].treeShaking?o[c].treeShaking?!pe(o[l].treeShaking)&&x(l,c):!1:!0:!pe(o[l])&&x(l,c)};if(i){if(s=re(e[t][r],a),s)return{version:s,useTreesShaking:i};i=!1}return{version:re(e[t][r],a),useTreesShaking:i}}const U=e=>pe(e)||xr(e);function Br(e,t,r,n){const o=e[t][r];let s="",i=te(n);const a=function(l,c){if(i){if(!o[l].treeShaking)return!0;if(!o[c].treeShaking)return!1;if(U(o[c].treeShaking))return U(o[l].treeShaking)?!!x(l,c):!0;if(U(o[l].treeShaking))return!1}return U(o[c])?U(o[l])?!!x(l,c):!0:U(o[l])?!1:x(l,c)};if(i){if(s=re(e[t][r],a),s)return{version:s,useTreesShaking:i};i=!1}return{version:re(e[t][r],a),useTreesShaking:i}}function Wr(e){return e==="loaded-first"?Br:Vr}function me(e,t,r,n){if(!e)return;const{shareConfig:o,scope:s=ne,strategy:i,treeShaking:a}=r,l=Array.isArray(s)?s:[s];for(const c of l)if(o&&e[c]&&e[c][t]){const{requiredVersion:f}=o,{version:h,useTreesShaking:u}=Wr(i)(e,c,t,a),d=()=>{const y=e[c][t][h];if(o.singleton){if(typeof f=="string"&&!Y(h,f)){const g=`Version ${h} from ${h&&y.from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${f})`;o.strictVersion?S(g):Le(g)}return{shared:y,useTreesShaking:u}}else{if(f===!1||f==="*")return{shared:y,useTreesShaking:u};if(Y(h,f))return{shared:y,useTreesShaking:u};const g=te(a);if(g){for(const[p,E]of Object.entries(e[c][t]))if(te(E.treeShaking,a==null?void 0:a.usedExports)&&Y(p,f))return{shared:E,useTreesShaking:g}}for(const[p,E]of Object.entries(e[c][t]))if(Y(p,f))return{shared:E,useTreesShaking:!1}}},m={shareScopeMap:e,scope:c,pkgName:t,version:h,GlobalFederation:ee.__FEDERATION__,shareInfo:r,resolver:d};return(n.emit(m)||m).resolver()}}function Et(){return ee.__FEDERATION__.__SHARE__}function Ke(e){const{pkgName:t,extraOptions:r,shareInfos:n}=e,o=l=>{if(!l)return;const c={};return l.forEach(h=>{c[h.version]=h}),c[re(c,function(h,u){return!pe(c[h])&&x(h,u)})]},s=(r==null?void 0:r.resolver)??o,i=l=>l!==null&&typeof l=="object"&&!Array.isArray(l),a=(...l)=>{const c={};for(const f of l)if(f)for(const[h,u]of Object.entries(f)){const d=c[h];i(d)&&i(u)?c[h]=a(d,u):u!==void 0&&(c[h]=u)}return c};return a(s(n[t]),r==null?void 0:r.customShareInfo)}const V=(e,t)=>{e.useIn||(e.useIn=[]),nr(e.useIn,t)};function ae(e,t){return t&&e.treeShaking?e.treeShaking:e}function jr(e,t){for(const r of e){const n=t.startsWith(r.name);let o=t.replace(r.name,"");if(n){if(o.startsWith("/")){const a=r.name;return o=`.${o}`,{pkgNameOrAlias:a,expose:o,remote:r}}else if(o==="")return{pkgNameOrAlias:r.name,expose:".",remote:r}}const s=r.alias&&t.startsWith(r.alias);let i=r.alias&&t.replace(r.alias,"");if(r.alias&&s){if(i&&i.startsWith("/")){const a=r.alias;return i=`.${i}`,{pkgNameOrAlias:a,expose:i,remote:r}}else if(i==="")return{pkgNameOrAlias:r.alias,expose:".",remote:r}}}}function qr(e,t){for(const r of e)if(t===r.name||r.alias&&t===r.alias)return r}const _t="RUNTIME-001",bt="RUNTIME-002",Rt="RUNTIME-003",St="RUNTIME-004",$t="RUNTIME-005",Ae="RUNTIME-006",wt="RUNTIME-007",Ge="RUNTIME-008",Kr="RUNTIME-009",Nt="RUNTIME-010",It="RUNTIME-011",L={[_t]:"Failed to get remoteEntry exports.",[bt]:'The remote entry interface does not contain "init"',[Rt]:"Failed to get manifest.",[St]:"Failed to locate remote.",[$t]:"Invalid loadShareSync function call from bundler runtime",[Ae]:"Invalid loadShareSync function call from runtime",[wt]:"Failed to get remote snapshot.",[Ge]:"Failed to load script resources.",[Kr]:"Please call createInstance first.",[Nt]:'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.',[It]:"The remoteEntry URL is missing from the remote snapshot."};({...L});const Tt=".then(callbacks[0]).catch(callbacks[1])";async function zr({entry:e,remoteEntryExports:t}){return new Promise((r,n)=>{try{t?r(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${e}")${Tt}`)([r,n]):import(e).then(r).catch(n)}catch(o){S(`Failed to load ESM entry from "${e}". ${o instanceof Error?o.message:String(o)}`)}})}async function Jr({entry:e,remoteEntryExports:t}){return new Promise((r,n)=>{try{t?r(t):typeof __system_context__>"u"?System.import(e).then(r).catch(n):new Function("callbacks",`System.import("${e}")${Tt}`)([r,n])}catch(o){S(`Failed to load SystemJS entry from "${e}". ${o instanceof Error?o.message:String(o)}`)}})}function vt(e,t,r){const{remoteEntryKey:n,entryExports:o}=De(e,t);return o||S(_t,L,{remoteName:e,remoteEntryUrl:r,remoteEntryKey:n}),o}async function Xr({name:e,globalName:t,entry:r,loaderHook:n,getEntryUrl:o}){const{entryExports:s}=De(e,t);if(s)return s;const i=o?o(r):r;return Yt(i,{attrs:{},createScriptHook:(a,l)=>{const c=n.lifecycle.createScript.emit({url:a,attrs:l});if(c&&(c instanceof HTMLScriptElement||"script"in c||"timeout"in c))return c}}).then(()=>vt(e,t,r),a=>{const l=a instanceof Error?a.message:String(a);S(Ge,L,{remoteName:e,resourceUrl:i},l)})}async function Yr({remoteInfo:e,remoteEntryExports:t,loaderHook:r,getEntryUrl:n}){const{entry:o,entryGlobalName:s,name:i,type:a}=e;switch(a){case"esm":case"module":return zr({entry:o,remoteEntryExports:t});case"system":return Jr({entry:o,remoteEntryExports:t});default:return Xr({entry:o,globalName:s,name:i,loaderHook:r,getEntryUrl:n})}}async function Zr({remoteInfo:e,loaderHook:t}){const{entry:r,entryGlobalName:n,name:o,type:s}=e,{entryExports:i}=De(o,n);return i||er(r,{attrs:{name:o,globalName:n,type:s},loaderHook:{createScriptHook:(a,l={})=>{const c=t.lifecycle.createScript.emit({url:a,attrs:l});if(c&&"url"in c)return c}}}).then(()=>vt(o,n,r)).catch(a=>{S(`Failed to load Node.js entry for remote "${o}" from "${r}". ${a instanceof Error?a.message:String(a)}`)})}function Pe(e){const{entry:t,name:r}=e;return Ye(r,t)}async function ye(e){const{origin:t,remoteEntryExports:r,remoteInfo:n,getEntryUrl:o,_inErrorHandling:s=!1}=e,i=Pe(n);if(r)return r;if(!W[i]){const a=t.remoteHandler.hooks.lifecycle.loadEntry,l=t.loaderHook;W[i]=a.emit({loaderHook:l,remoteInfo:n,remoteEntryExports:r}).then(c=>c||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":H)?Yr({remoteInfo:n,remoteEntryExports:r,loaderHook:l,getEntryUrl:o}):Zr({remoteInfo:n,loaderHook:l}))).catch(async c=>{const f=Pe(n),h=c instanceof Error&&c.message.includes("ScriptExecutionError");if(c instanceof Error&&c.message.includes(Ge)&&!h&&!s){const u=m=>ye({...m,_inErrorHandling:!0}),d=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:u,origin:t,remoteInfo:n,remoteEntryExports:r,globalLoading:W,uniqueKey:f});if(d)return d}throw c})}return W[i]}function ke(e){return{...e,entry:"entry"in e?e.entry:"",type:e.type||yt,entryGlobalName:e.entryGlobalName||e.name,shareScope:e.shareScope||ne}}function Qr(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function en(e,t){const r=ur(),n=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return r.length>0&&r.forEach(o=>{e!=null&&e.find(s=>s.name!==o.name)&&e.push(o)}),e&&e.length>0&&e.forEach(o=>{n.forEach(s=>{s.applyPlugin(o,t)})}),e}function tn(e){return{name:e.name,alias:e.alias,entry:"entry"in e?e.entry:void 0,version:"version"in e?e.version:void 0,type:e.type,entryGlobalName:e.entryGlobalName,shareScope:e.shareScope}}function J(e){var r,n,o,s,i,a;const t={};for(const[l,c]of Object.entries(e.shared)){const f=c[0];f&&(t[l]={version:f.version,singleton:(r=f.shareConfig)==null?void 0:r.singleton,requiredVersion:((n=f.shareConfig)==null?void 0:n.requiredVersion)===!1?!1:(o=f.shareConfig)==null?void 0:o.requiredVersion,eager:f.eager,strictVersion:(s=f.shareConfig)==null?void 0:s.strictVersion})}return{project:{name:e.name,mfRole:((i=e.remotes)==null?void 0:i.length)>0?"host":"unknown"},mfConfig:{name:e.name,remotes:((a=e.remotes)==null?void 0:a.map(tn))??[],shared:t}}}function At(e){return{resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1,...e}}function rn(e,t){return t.map(r=>{const n=qr(e,r.nameOrAlias);return k(n,`Unable to preload ${r.nameOrAlias} as it is not included in ${!n&&Qe({remoteInfo:n,remotes:e})}`),{remote:n,preloadConfig:At(r)}})}function nn(e){return e?e.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function Pt(e,t,r,n=!0){const{cssAssets:o,jsAssetsWithoutEntry:s,entryAssets:i}=r;if(t.options.inBrowser){if(i.forEach(a=>{const{moduleInfo:l}=a,c=t.moduleCache.get(e.name);ye(c?{origin:t,remoteInfo:l,remoteEntryExports:c.remoteEntryExports}:{origin:t,remoteInfo:l,remoteEntryExports:void 0})}),n){const a={rel:"preload",as:"style"};o.forEach(l=>{const{link:c,needAttach:f}=Ee({url:l,cb:()=>{},attrs:a,createLinkHook:(h,u)=>{const d=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:u});if(d instanceof HTMLLinkElement)return d}});f&&document.head.appendChild(c)})}else{const a={rel:"stylesheet",type:"text/css"};o.forEach(l=>{const{link:c,needAttach:f}=Ee({url:l,cb:()=>{},attrs:a,createLinkHook:(h,u)=>{const d=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:u});if(d instanceof HTMLLinkElement)return d},needDeleteLink:!1});f&&document.head.appendChild(c)})}if(n){const a={rel:"preload",as:"script"};s.forEach(l=>{const{link:c,needAttach:f}=Ee({url:l,cb:()=>{},attrs:a,createLinkHook:(h,u)=>{const d=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:u});if(d instanceof HTMLLinkElement)return d}});f&&document.head.appendChild(c)})}else{const a={fetchpriority:"high",type:(e==null?void 0:e.type)==="module"?"module":"text/javascript"};s.forEach(l=>{const{script:c,needAttach:f}=ot({url:l,cb:()=>{},attrs:a,createScriptHook:(h,u)=>{const d=t.loaderHook.lifecycle.createScript.emit({url:h,attrs:u});if(d instanceof HTMLScriptElement)return d},needDeleteScript:!0});f&&document.head.appendChild(c)})}}}function on(e,t,r){const n=t,o=Array.isArray(e.shareScope)?e.shareScope:[e.shareScope];o.length||o.push("default"),o.forEach(i=>{n[i]||(n[i]={})});const s={version:e.version||"",shareScopeKeys:Array.isArray(e.shareScope)?o:e.shareScope||"default"};return Object.defineProperty(s,"shareScopeMap",{value:n,enumerable:!1}),{remoteEntryInitOptions:s,shareScope:n[o[0]],initScope:r??[]}}var kt=class{constructor({remoteInfo:e,host:t}){this.inited=!1,this.initing=!1,this.lib=void 0,this.remoteInfo=e,this.host=t}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;const e=await ye({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports});return k(e,`remoteEntryExports is undefined
|
|
8
|
-
${Qe(this.remoteInfo)}`),this.remoteEntryExports=e,this.remoteEntryExports}async init(e,t,r){const n=await this.getEntry();if(this.inited)return n;if(this.initPromise)return await this.initPromise,n;this.initing=!0,this.initPromise=(async()=>{const{remoteEntryInitOptions:o,shareScope:s,initScope:i}=on(this.remoteInfo,this.host.shareScopeMap,r),a=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:s,remoteEntryInitOptions:o,initScope:i,remoteInfo:this.remoteInfo,origin:this.host});typeof(n==null?void 0:n.init)>"u"&&S(bt,L,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName},void 0,J(this.host.options)),await n.init(a.shareScope,a.initScope,a.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...a,id:e,remoteSnapshot:t,remoteEntryExports:n}),this.inited=!0})();try{await this.initPromise}finally{this.initing=!1,this.initPromise=void 0}return n}async get(e,t,r,n){const{loadFactory:o=!0}=r||{loadFactory:!0},s=await this.init(e,n);this.lib=s;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:s,expose:t,moduleInfo:this.remoteInfo}),i||(i=await s.get(t)),k(i,`${Q(this.remoteInfo)} remote don't export ${t}.`);const a=ir(this.remoteInfo.name,t),l=this.wraperFactory(i,a);return o?await l():l}wraperFactory(e,t){function r(n,o){n&&typeof n=="object"&&Object.isExtensible(n)&&!Object.getOwnPropertyDescriptor(n,Symbol.for("mf_module_id"))&&Object.defineProperty(n,Symbol.for("mf_module_id"),{value:o,enumerable:!1})}return e instanceof Promise?async()=>{const n=await e();return r(n,t),n}:()=>{const n=e();return r(n,t),n}}},A=class{constructor(e){this.type="",this.listeners=new Set,e&&(this.type=e)}on(e){typeof e=="function"&&this.listeners.add(e)}once(e){const t=this;this.on(function r(...n){return t.remove(r),e.apply(null,n)})}emit(...e){let t;return this.listeners.size>0&&this.listeners.forEach(r=>{t=r(...e)}),t}remove(e){this.listeners.delete(e)}removeAll(){this.listeners.clear()}},P=class extends A{emit(...e){let t;const r=Array.from(this.listeners);if(r.length>0){let n=0;const o=s=>s===!1?!1:n<r.length?Promise.resolve(r[n++].apply(null,e)).then(o):s;t=o()}return Promise.resolve(t)}};function Ot(e,t){if(!Ce(t))return!1;if(e!==t){for(const r in e)if(!(r in t))return!1}return!0}var j=class extends A{constructor(e){super(),this.onerror=S,this.type=e}emit(e){Ce(e)||S(`The data for the "${this.type}" hook should be an object.`);for(const t of this.listeners)try{const r=t(e);if(Ot(e,r))e=r;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(r){Le(r),this.onerror(r)}return e}},F=class extends A{constructor(e){super(),this.onerror=S,this.type=e}emit(e){Ce(e)||S(`The response data for the "${this.type}" hook must be an object.`);const t=Array.from(this.listeners);if(t.length>0){let r=0;const n=s=>(Le(s),this.onerror(s),e),o=s=>{if(Ot(e,s)){if(e=s,r<t.length)try{return Promise.resolve(t[r++](e)).then(o,n)}catch(i){return n(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return e};return Promise.resolve(o(e))}return Promise.resolve(e)}},q=class{constructor(e){this.registerPlugins={},this.lifecycle=e,this.lifecycleKeys=Object.keys(e)}applyPlugin(e,t){var n;k(sr(e),"Plugin configuration is invalid.");const r=e.name;k(r,"A name must be provided by the plugin."),this.registerPlugins[r]||(this.registerPlugins[r]=e,(n=e.apply)==null||n.call(e,t),Object.keys(this.lifecycle).forEach(o=>{const s=e[o];s&&this.lifecycle[o].on(s)}))}removePlugin(e){k(e,"A name is required.");const t=this.registerPlugins[e];k(t,`The plugin "${e}" is not registered.`),Object.keys(t).forEach(r=>{r!=="name"&&this.lifecycle[r].remove(t[r])})}};function Lt(e,t){const r=lt(t);r.url||S(It,L,{remoteName:e.name});let n=Ne(t,r.url);!H&&!n.startsWith("http")&&(n=`https:${n}`),e.type=r.type,e.entryGlobalName=r.globalName,e.entry=n,e.version=t.version,e.buildVersion=t.buildVersion}function sn(){return{name:"snapshot-plugin",async afterResolve(e){const{remote:t,pkgNameOrAlias:r,expose:n,origin:o,remoteInfo:s,id:i}=e;if(!Me(t)||!at(t)){const{remoteSnapshot:a,globalSnapshot:l}=await o.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:i});Lt(s,a);const c={remote:t,preloadConfig:{nameOrAlias:r,exposes:[n],resourceCategory:"sync",share:!1,depsRemote:!1}},f=await o.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:c,remoteInfo:s,remote:t,remoteSnapshot:a,globalSnapshot:l});return f&&Pt(s,o,f,!1),{...e,remoteSnapshot:a}}return e}}}function an(e){const t=e.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 Mt(e,t,r,n,o={},s){const{value:i}=K(e,Q(t)),a=s||i;if(a&&!et(a)&&(r(a,t,n),a.remotesInfo)){const l=Object.keys(a.remotesInfo);for(const c of l){if(o[c])continue;o[c]=!0;const f=an(c),h=a.remotesInfo[c];Mt(e,{name:f.name,version:h.matchedVersion},r,!1,o,void 0)}}}const Se=(e,t)=>document.querySelector(`${e}[${e==="link"?"href":"src"}="${t}"]`);function cn(e,t,r,n,o){const s=[],i=[],a=[],l=new Set,c=new Set,{options:f}=e,{preloadConfig:h}=t,{depsRemote:u}=h;if(Mt(n,r,(m,y,g)=>{var $;let p;if(g)p=h;else if(Array.isArray(u)){const R=u.find(w=>w.nameOrAlias===y.name||w.nameOrAlias===y.alias);if(!R)return;p=At(R)}else if(u===!0)p=h;else return;const E=Ne(m,lt(m).url);E&&a.push({name:y.name,moduleInfo:{name:y.name,entry:E,type:"remoteEntryType"in m?m.remoteEntryType:"global",entryGlobalName:"globalName"in m?m.globalName:y.name,shareScope:"",version:"version"in m?m.version:void 0},url:E});let b="modules"in m?m.modules:[];const N=nn(p.exposes);N.length&&"modules"in m&&(b=($=m==null?void 0:m.modules)==null?void 0:$.reduce((R,w)=>((N==null?void 0:N.indexOf(w.moduleName))!==-1&&R.push(w),R),[]));function _(R){const w=R.map(M=>Ne(m,M));return p.filter?w.filter(p.filter):w}if(b){const R=b.length;for(let w=0;w<R;w++){const M=b[w],ge=`${y.name}/${M.moduleName}`;e.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:M.moduleName==="."?y.name:ge,name:y.name,remoteSnapshot:m,preloadConfig:p,remote:y,origin:e}),!fr(ge)&&(p.resourceCategory==="all"?(s.push(..._(M.assets.css.async)),s.push(..._(M.assets.css.sync)),i.push(..._(M.assets.js.async)),i.push(..._(M.assets.js.sync))):p.resourceCategory==="sync"&&(s.push(..._(M.assets.css.sync)),i.push(..._(M.assets.js.sync))),hr(ge))}}},!0,{},o),o.shared&&o.shared.length>0){const m=(y,g)=>{const{shared:p}=me(e.shareScopeMap,g.sharedName,y,e.sharedHandler.hooks.lifecycle.resolveShare)||{};p&&typeof p.lib=="function"&&(g.assets.js.sync.forEach(E=>{l.add(E)}),g.assets.css.sync.forEach(E=>{c.add(E)}))};o.shared.forEach(y=>{var E;const g=(E=f.shared)==null?void 0:E[y.sharedName];if(!g)return;const p=y.version?g.find(b=>b.version===y.version):g;p&&ct(p).forEach(b=>{m(b,y)})})}const d=i.filter(m=>!l.has(m)&&!Se("script",m));return{cssAssets:s.filter(m=>!c.has(m)&&!Se("link",m)),jsAssetsWithoutEntry:d,entryAssets:a.filter(m=>!Se("script",m.url))}}const ln=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(e){const{origin:t,preloadOptions:r,remoteInfo:n,remote:o,globalSnapshot:s,remoteSnapshot:i}=e;return H?Me(o)&&at(o)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:o.name,url:o.entry,moduleInfo:{name:n.name,entry:o.entry,type:n.type||"global",entryGlobalName:"",shareScope:""}}]}:(Lt(n,i),cn(t,r,n,s,i)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function Ct(e,t){const r=fe({name:t.name,version:t.options.version}),n=r&&"remotesInfo"in r&&r.remotesInfo&&K(r.remotesInfo,e.name).value;return n&&n.matchedVersion?{hostGlobalSnapshot:r,globalSnapshot:xe(),remoteSnapshot:fe({name:e.name,version:n.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:xe(),remoteSnapshot:fe({name:e.name,version:"version"in e?e.version:void 0})}}var un=class{constructor(e){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new q({beforeLoadRemoteSnapshot:new P("beforeLoadRemoteSnapshot"),loadSnapshot:new F("loadGlobalSnapshot"),loadRemoteSnapshot:new F("loadRemoteSnapshot"),afterLoadSnapshot:new F("afterLoadSnapshot")}),this.manifestLoading=ee.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=e,this.loaderHook=e.loaderHook}async loadRemoteSnapshotInfo({moduleInfo:e,id:t,expose:r}){const{options:n}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:n,moduleInfo:e});let o=fe({name:this.HostInstance.options.name,version:this.HostInstance.options.version});o||(o={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},lr({[this.HostInstance.options.name]:o})),o&&"remotesInfo"in o&&!K(o.remotesInfo,e.name).value&&("version"in e||"entry"in e)&&(o.remotesInfo={...o==null?void 0:o.remotesInfo,[e.name]:{matchedVersion:"version"in e?e.version:e.entry}});const{hostGlobalSnapshot:s,remoteSnapshot:i,globalSnapshot:a}=this.getGlobalRemoteInfo(e),{remoteSnapshot:l,globalSnapshot:c}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:e,hostGlobalSnapshot:s,remoteSnapshot:i,globalSnapshot:a});let f,h;if(l)if(et(l)){const u=H?l.remoteEntry:l.ssrRemoteEntry||l.remoteEntry||"",d=await this.getManifestJson(u,e,{}),m=Ue({...e,entry:u},d);f=d,h=m}else{const{remoteSnapshot:u}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:l,from:"global"});f=u,h=c}else if(Me(e)){const u=await this.getManifestJson(e.entry,e,{}),d=Ue(e,u),{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:u,from:"global"});f=m,h=d}else S(wt,L,{remoteName:e.name,remoteVersion:e.version,hostName:this.HostInstance.options.name,globalSnapshot:JSON.stringify(c)},void 0,J(this.HostInstance.options));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:t,host:this.HostInstance,options:n,moduleInfo:e,remoteSnapshot:f}),{remoteSnapshot:f,globalSnapshot:h}}getGlobalRemoteInfo(e){return Ct(e,this.HostInstance)}async getManifestJson(e,t,r){const n=async()=>{let s=this.manifestCache.get(e);if(s)return s;try{let i=await this.loaderHook.lifecycle.fetch.emit(e,{});(!i||!(i instanceof Response))&&(i=await fetch(e,{})),s=await i.json()}catch(i){s=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:e,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),s||(delete this.manifestLoading[e],S(Rt,L,{manifestUrl:e,moduleName:t.name,hostName:this.HostInstance.options.name},`${i}`,J(this.HostInstance.options)))}return k(s.metaData&&s.exposes&&s.shared,`"${e}" is not a valid federation manifest for remote "${t.name}". Missing required fields: ${[!s.metaData&&"metaData",!s.exposes&&"exposes",!s.shared&&"shared"].filter(Boolean).join(", ")}.`),this.manifestCache.set(e,s),s},o=async()=>{const s=await n(),i=qt(s,{version:e}),{remoteSnapshot:a}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,manifestJson:s,remoteSnapshot:i,manifestUrl:e,from:"manifest"});return a};return this.manifestLoading[e]||(this.manifestLoading[e]=o().then(s=>s)),this.manifestLoading[e]}},fn=class{constructor(e){this.hooks=new q({beforeRegisterShare:new j("beforeRegisterShare"),afterResolve:new F("afterResolve"),beforeLoadShare:new F("beforeLoadShare"),loadShare:new P,resolveShare:new j("resolveShare"),initContainerShareScopeMap:new j("initContainerShareScopeMap")}),this.host=e,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(e.options)}registerShared(e,t){const{newShareInfos:r,allShareInfos:n}=gt(e,t);return Object.keys(r).forEach(o=>{r[o].forEach(s=>{s.scope.forEach(i=>{var a;this.hooks.lifecycle.beforeRegisterShare.emit({origin:this.host,pkgName:o,shared:s}),(a=this.shareScopeMap[i])!=null&&a[o]||this.setShared({pkgName:o,lib:s.lib,get:s.get,loaded:s.loaded||!!s.lib,shared:s,from:t.name})})})}),{newShareInfos:r,allShareInfos:n}}async loadShare(e,t){const{host:r}=this,n=Ke({pkgName:e,extraOptions:t,shareInfos:r.options.shared});n!=null&&n.scope&&await Promise.all(n.scope.map(async a=>{await Promise.all(this.initializeSharing(a,{strategy:n.strategy}))}));const{shareInfo:o}=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:e,shareInfo:n,shared:r.options.shared,origin:r});k(o,`Cannot find shared "${e}" in host "${r.options.name}". Ensure the shared config for "${e}" is declared in the federation plugin options and the host has been initialized before loading shares.`);const{shared:s,useTreesShaking:i}=me(this.shareScopeMap,e,o,this.hooks.lifecycle.resolveShare)||{};if(s){const a=ae(s,i);if(a.lib)return V(a,r.options.name),a.lib;if(a.loading&&!a.loaded){const l=await a.loading;return a.loaded=!0,a.lib||(a.lib=l),V(a,r.options.name),l}else{const c=(async()=>{const f=await a.get();return V(a,r.options.name),a.loaded=!0,a.lib=f,f})();return this.setShared({pkgName:e,loaded:!1,shared:s,from:r.options.name,lib:null,loading:c,treeShaking:i?a:void 0}),c}}else{if(t!=null&&t.customShareInfo)return!1;const a=te(o.treeShaking),l=ae(o,a),f=(async()=>{const h=await l.get();l.lib=h,l.loaded=!0,V(l,r.options.name);const{shared:u,useTreesShaking:d}=me(this.shareScopeMap,e,o,this.hooks.lifecycle.resolveShare)||{};if(u){const m=ae(u,d);m.lib=h,m.loaded=!0,u.from=o.from}return h})();return this.setShared({pkgName:e,loaded:!1,shared:o,from:r.options.name,lib:null,loading:f,treeShaking:a?l:void 0}),f}}initializeSharing(e=ne,t){const{host:r}=this,n=t==null?void 0:t.from,o=t==null?void 0:t.strategy;let s=t==null?void 0:t.initScope;const i=[];if(n!=="build"){const{initTokens:u}=this;s||(s=[]);let d=u[e];if(d||(d=u[e]={from:this.host.name}),s.indexOf(d)>=0)return i;s.push(d)}const a=this.shareScopeMap,l=r.options.name;a[e]||(a[e]={});const c=a[e],f=(u,d)=>{var b;const{version:m,eager:y}=d;c[u]=c[u]||{};const g=c[u],p=g[m]&&ae(g[m]),E=!!(p&&("eager"in p&&p.eager||"shareConfig"in p&&((b=p.shareConfig)!=null&&b.eager)));(!p||p.strategy!=="loaded-first"&&!p.loaded&&(!y!=!E?y:l>g[m].from))&&(g[m]=d)},h=async u=>{const{module:d}=await r.remoteHandler.getRemoteModuleAndOptions({id:u});let m;try{m=await d.getEntry()}catch(y){if(m=await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:u,error:y,from:"runtime",lifecycle:"beforeLoadShare",origin:r}),!m)return}finally{m!=null&&m.init&&!d.initing&&(d.remoteEntryExports=m,await d.init(void 0,void 0,s))}};return Object.keys(r.options.shared).forEach(u=>{r.options.shared[u].forEach(d=>{d.scope.includes(e)&&f(u,d)})}),(r.options.shareStrategy==="version-first"||o==="version-first")&&r.options.remotes.forEach(u=>{u.shareScope===e&&i.push(h(u.name))}),i}loadShareSync(e,t){const{host:r}=this,n=Ke({pkgName:e,extraOptions:t,shareInfos:r.options.shared});n!=null&&n.scope&&n.scope.forEach(i=>{this.initializeSharing(i,{strategy:n.strategy})});const{shared:o,useTreesShaking:s}=me(this.shareScopeMap,e,n,this.hooks.lifecycle.resolveShare)||{};if(o){if(typeof o.lib=="function")return V(o,r.options.name),o.loaded||(o.loaded=!0,o.from===r.options.name&&(n.loaded=!0)),o.lib;if(typeof o.get=="function"){const i=o.get();if(!(i instanceof Promise))return V(o,r.options.name),this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:i,shared:o}),i}}if(n.lib)return n.loaded||(n.loaded=!0),n.lib;if(n.get){const i=n.get();return i instanceof Promise&&S((t==null?void 0:t.from)==="build"?$t:Ae,L,{hostName:r.options.name,sharedPkgName:e},void 0,J(r.options)),n.lib=i,this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:n.lib,shared:n}),n.lib}S(Ae,L,{hostName:r.options.name,sharedPkgName:e},void 0,J(r.options))}initShareScopeMap(e,t,r={}){const{host:n}=this;this.shareScopeMap[e]=t,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:t,options:n.options,origin:n,scopeName:e,hostShareScopeMap:r.hostShareScopeMap})}setShared({pkgName:e,shared:t,from:r,lib:n,loading:o,loaded:s,get:i,treeShaking:a}){const{version:l,scope:c="default",...f}=t,h=Array.isArray(c)?c:[c],u=d=>{const m=(g,p,E)=>{E&&!g[p]&&(g[p]=E)},y=a?d.treeShaking:d;m(y,"loaded",s),m(y,"loading",o),m(y,"get",i)};h.forEach(d=>{this.shareScopeMap[d]||(this.shareScopeMap[d]={}),this.shareScopeMap[d][e]||(this.shareScopeMap[d][e]={}),this.shareScopeMap[d][e][l]||(this.shareScopeMap[d][e][l]={version:l,scope:[d],...f,lib:n});const m=this.shareScopeMap[d][e][l];u(m),r&&m.from!==r&&(m.from=r)})}_setGlobalShareScopeMap(e){const t=Et(),r=e.id||e.name;r&&!t[r]&&(t[r]=this.shareScopeMap)}},hn=class{constructor(e){this.hooks=new q({beforeRegisterRemote:new j("beforeRegisterRemote"),registerRemote:new j("registerRemote"),beforeRequest:new F("beforeRequest"),onLoad:new P("onLoad"),handlePreloadModule:new A("handlePreloadModule"),errorLoadRemote:new P("errorLoadRemote"),beforePreloadRemote:new P("beforePreloadRemote"),generatePreloadAssets:new P("generatePreloadAssets"),afterPreloadRemote:new P,loadEntry:new P}),this.host=e,this.idToRemoteMap={}}formatAndRegisterRemote(e,t){return(t.remotes||[]).reduce((r,n)=>(this.registerRemote(n,r,{force:!1}),r),e.remotes)}setIdToRemoteMap(e,t){const{remote:r,expose:n}=t,{name:o,alias:s}=r;if(this.idToRemoteMap[e]={name:r.name,expose:n},s&&e.startsWith(o)){const i=e.replace(o,s);this.idToRemoteMap[i]={name:r.name,expose:n};return}if(s&&e.startsWith(s)){const i=e.replace(s,o);this.idToRemoteMap[i]={name:r.name,expose:n}}}async loadRemote(e,t){const{host:r}=this;try{const{loadFactory:n=!0}=t||{loadFactory:!0},{module:o,moduleOptions:s,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:e}),{pkgNameOrAlias:a,remote:l,expose:c,id:f,remoteSnapshot:h}=i,u=await o.get(f,c,t,h),d=await this.hooks.lifecycle.onLoad.emit({id:f,pkgNameOrAlias:a,expose:c,exposeModule:n?u:void 0,exposeModuleFactory:n?void 0:u,remote:l,options:s,moduleInstance:o,origin:r});return this.setIdToRemoteMap(e,i),typeof d=="function"?d:u}catch(n){const{from:o="runtime"}=t||{from:"runtime"},s=await this.hooks.lifecycle.errorLoadRemote.emit({id:e,error:n,from:o,lifecycle:"onLoad",origin:r});if(!s)throw n;return s}}async preloadRemote(e){const{host:t}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:e,options:t.options,origin:t});const r=rn(t.options.remotes,e);await Promise.all(r.map(async n=>{const{remote:o}=n,s=ke(o),{globalSnapshot:i,remoteSnapshot:a}=await t.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:o}),l=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:t,preloadOptions:n,remote:o,remoteInfo:s,globalSnapshot:i,remoteSnapshot:a});l&&Pt(s,t,l)}))}registerRemotes(e,t){const{host:r}=this;e.forEach(n=>{this.registerRemote(n,r.options.remotes,{force:t==null?void 0:t.force})})}async getRemoteModuleAndOptions(e){const{host:t}=this,{id:r}=e;let n;try{n=await this.hooks.lifecycle.beforeRequest.emit({id:r,options:t.options,origin:t})}catch(d){if(n=await this.hooks.lifecycle.errorLoadRemote.emit({id:r,options:t.options,origin:t,from:"runtime",error:d,lifecycle:"beforeRequest"}),!n)throw d}const{id:o}=n,s=jr(t.options.remotes,o);s||S(St,L,{hostName:t.options.name,requestId:o},void 0,J(t.options));const{remote:i}=s,a=ke(i),l=await t.sharedHandler.hooks.lifecycle.afterResolve.emit({id:o,...s,options:t.options,origin:t,remoteInfo:a}),{remote:c,expose:f}=l;k(c&&f,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${o}.`);let h=t.moduleCache.get(c.name);const u={host:t,remoteInfo:a};return h||(h=new kt(u),t.moduleCache.set(c.name,h)),{module:h,moduleOptions:u,remoteMatchInfo:l}}registerRemote(e,t,r){const{host:n}=this,o=()=>{if(e.alias){const i=t.find(a=>{var l;return e.alias&&(a.name.startsWith(e.alias)||((l=a.alias)==null?void 0:l.startsWith(e.alias)))});k(!i,`The alias ${e.alias} of remote ${e.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in e&&H&&typeof window<"u"&&!e.entry.startsWith("http")&&(e.entry=new URL(e.entry,window.location.origin).href),e.shareScope||(e.shareScope=ne),e.type||(e.type=yt)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:e,origin:n});const s=t.find(i=>i.name===e.name);if(!s)o(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:n});else{const i=[`The remote "${e.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];r!=null&&r.force&&(this.removeRemote(s),o(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:n}),Ze(i.join(" ")))}}removeRemote(e){var t;try{const{host:r}=this,{name:n}=e,o=r.options.remotes.findIndex(i=>i.name===n);o!==-1&&r.options.remotes.splice(o,1);const s=r.moduleCache.get(e.name);if(s){const i=s.remoteInfo,a=i.entryGlobalName;I[a]&&((t=Object.getOwnPropertyDescriptor(I,a))!=null&&t.configurable?delete I[a]:I[a]=void 0);const l=Pe(s.remoteInfo);W[l]&&delete W[l],r.snapshotHandler.manifestCache.delete(i.entry);let c=i.buildVersion?Ye(i.name,i.buildVersion):i.name;const f=I.__FEDERATION__.__INSTANCES__.findIndex(u=>i.buildVersion?u.options.id===c:u.name===c);if(f!==-1){const u=I.__FEDERATION__.__INSTANCES__[f];c=u.options.id||c;const d=Et();let m=!0;const y=[];Object.keys(d).forEach(g=>{const p=d[g];p&&Object.keys(p).forEach(E=>{const b=p[E];b&&Object.keys(b).forEach(N=>{const _=b[N];_&&Object.keys(_).forEach($=>{const R=_[$];R&&typeof R=="object"&&R.from===i.name&&(R.loaded||R.loading?(R.useIn=R.useIn.filter(w=>w!==i.name),R.useIn.length?m=!1:y.push([g,E,N,$])):y.push([g,E,N,$]))})})})}),m&&(u.shareScopeMap={},delete d[c]),y.forEach(([g,p,E,b])=>{var N,_,$;($=(_=(N=d[g])==null?void 0:N[p])==null?void 0:_[E])==null||delete $[b]}),I.__FEDERATION__.__INSTANCES__.splice(f,1)}const{hostGlobalSnapshot:h}=Ct(e,r);if(h){const u=h&&"remotesInfo"in h&&h.remotesInfo&&K(h.remotesInfo,e.name).key;u&&(delete h.remotesInfo[u],ee.__FEDERATION__.__MANIFEST_LOADING__[u]&&delete ee.__FEDERATION__.__MANIFEST_LOADING__[u])}r.moduleCache.delete(e.name)}}catch(r){ve.error(`removeRemote failed: ${r instanceof Error?r.message:String(r)}`)}}};const dn=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;var mn=class{constructor(e){this.hooks=new q({beforeInit:new j("beforeInit"),init:new A,beforeInitContainer:new F("beforeInitContainer"),initContainer:new F("initContainer")}),this.version="2.2.2",this.moduleCache=new Map,this.loaderHook=new q({getModuleInfo:new A,createScript:new A,createLink:new A,fetch:new P,loadEntryError:new P,getModuleFactory:new P}),this.bridgeHook=new q({beforeBridgeRender:new A,afterBridgeRender:new A,beforeBridgeDestroy:new A,afterBridgeDestroy:new A});const t=dn?[sn(),ln()]:[],r={id:Qr(),name:e.name,plugins:t,remotes:[],shared:{},inBrowser:H};this.name=e.name,this.options=r,this.snapshotHandler=new un(this),this.sharedHandler=new fn(this),this.remoteHandler=new hn(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...r.plugins,...e.plugins||[]]),this.options=this.formatOptions(r,e)}initOptions(e){e.name&&e.name!==this.options.name&&S(it(Nt,L)),this.registerPlugins(e.plugins);const t=this.formatOptions(this.options,e);return this.options=t,t}async loadShare(e,t){return this.sharedHandler.loadShare(e,t)}loadShareSync(e,t){return this.sharedHandler.loadShareSync(e,t)}initializeSharing(e=ne,t){return this.sharedHandler.initializeSharing(e,t)}initRawContainer(e,t,r){const n=ke({name:e,entry:t}),o=new kt({host:this,remoteInfo:n});return o.remoteEntryExports=r,this.moduleCache.set(e,o),o}async loadRemote(e,t){return this.remoteHandler.loadRemote(e,t)}async preloadRemote(e){return this.remoteHandler.preloadRemote(e)}initShareScopeMap(e,t,r={}){this.sharedHandler.initShareScopeMap(e,t,r)}formatOptions(e,t){const{allShareInfos:r}=gt(e,t),{userOptions:n,options:o}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:t,options:e,shareInfo:r}),s=this.remoteHandler.formatAndRegisterRemote(o,n),{allShareInfos:i}=this.sharedHandler.registerShared(o,n),a=[...o.plugins];n.plugins&&n.plugins.forEach(c=>{a.includes(c)||a.push(c)});const l={...e,...t,plugins:a,remotes:s,shared:i};return this.hooks.lifecycle.init.emit({origin:this,options:l}),l}registerPlugins(e){const t=en(e,this);this.options.plugins=this.options.plugins.reduce((r,n)=>(n&&r&&!r.find(o=>o.name===n.name)&&r.push(n),r),t||[])}registerRemotes(e,t){return this.remoteHandler.registerRemotes(e,t)}registerShared(e){this.sharedHandler.registerShared(this.options,{...this.options,shared:e})}};let pn=null;function Dt(){return pn}ar(mn);function Ft(e,t){return e.map(r=>{const n={...r,path:t+r.path};return r.children&&r.children.length>0&&(n.children=Ft(r.children,t)),n})}function yn(e){const{router:t,basename:r,memoryRoute:n,hashRoute:o}=e,s=t.getRoutes().sort((u,d)=>u.path.split("/").filter(m=>m).length-d.path.split("/").filter(m=>m).length),i=new Map,a=new Set;s.forEach(u=>{i.set(u.path,u)});const l=(u,d)=>`${u}/${d}`.replace(/\/+/g,"/").replace(/\/$/,"")||"/",c=(u,d="")=>{if(!u.children||u.children.length===0)return u;for(let m=0;m<u.children.length;m++){const y=u.children[m],g=l(d,y.path),p=i.get(g);if(p&&!a.has(p)){const E={...p,path:y.path};u.children[m]=E,a.add(p),c(E,g)}}return u};let f=[];for(const u of s)if(!a.has(u)){const d=c(u,u.path);a.add(u),f.push(d)}let h;return n?h=ce.createMemoryHistory(r):o?(h=ce.createWebHashHistory(),r&&(f=Ft(f,r))):h=ce.createWebHistory(r),{history:h,routes:f}}function gn(e){const t=new Map,r=Dt();return()=>({__APP_VERSION__:"2.2.2",async render(n){var m,y,g;D.debug("createBridgeComponent render Info",n);const{moduleName:o,dom:s,basename:i,memoryRoute:a,hashRoute:l,...c}=n,f=Gt.createApp(e.rootComponent,c);t.set(s,f);const h=await((g=(y=(m=r==null?void 0:r.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:y.beforeBridgeRender)==null?void 0:g.emit(n)),u=h&&typeof h=="object"&&(h!=null&&h.extraProps)?h==null?void 0:h.extraProps:{},d=e.appOptions({app:f,basename:i,memoryRoute:a,hashRoute:l,...c,...u});if(d!=null&&d.router){const{history:p,routes:E}=yn({router:d.router,basename:n.basename,memoryRoute:n.memoryRoute,hashRoute:n.hashRoute}),b=ce.createRouter({...d.router.options,history:p,routes:E});D.debug("createBridgeComponent render router info>>>",{moduleName:o,router:b}),a&&await b.push(a.entryPath),f.use(b)}f.mount(s)},destroy(n){D.debug("createBridgeComponent destroy Info",n);const o=t.get(n==null?void 0:n.dom);o==null||o.unmount()}})}function En(){const e=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(e)}const _n=v.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(e){const t=v.ref(null),r=v.ref(null),n=v.ref(""),o=Oe.useRoute(),s=Dt(),i=v.useAttrs(),a=async()=>{var u,d,m,y;const c=(u=e.providerInfo)==null?void 0:u.call(e);r.value=c;let f={...i,moduleName:e.moduleName,dom:t.value,basename:e.basename,memoryRoute:e.memoryRoute,hashRoute:e.hashRoute};D.debug("createRemoteAppComponent LazyComponent render >>>",f);const h=await((y=(m=(d=s==null?void 0:s.bridgeHook)==null?void 0:d.lifecycle)==null?void 0:m.beforeBridgeRender)==null?void 0:y.emit(f))||{};f={...f,...h.extraProps},c.render(f)},l=v.watch(()=>o==null?void 0:o.path,c=>{c!==o.path&&a(),n.value!==""&&n.value!==c&&(D.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...e,pathname:o.path}),En()),n.value=c});return v.onMounted(()=>{a()}),v.onBeforeUnmount(()=>{var c;D.debug("createRemoteAppComponent LazyComponent destroy >>>",{...e}),l(),(c=r.value)==null||c.destroy({dom:t.value})}),()=>v.createVNode("div",v.mergeProps(e.rootAttrs||{},{ref:t}),null)}});function Ht(e){return v.defineAsyncComponent({__APP_VERSION__:"2.2.2",...e.asyncComponentOptions,loader:async()=>{var l,c;const t=Oe.useRoute();let r="/";const n=(c=(l=t==null?void 0:t.matched)==null?void 0:l[0])==null?void 0:c.path;n&&(n.endsWith("/:pathMatch(.*)*")?r=n.replace("/:pathMatch(.*)*",""):r=t.matched[0].path);const o=(e==null?void 0:e.export)||"default";D.debug("createRemoteAppComponent LazyComponent create >>>",{basename:r,info:e});const s=await e.loader(),i=s&&s[Symbol.for("mf_module_id")],a=s[o];if(D.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:i,module:s,exportName:o,basename:r,route:t}),o in s&&typeof a=="function")return{render(){return v.h(_n,{moduleName:i,providerInfo:a,basename:r,rootAttrs:e.rootAttrs})}};throw new Error("module not found")}})}function bn(e){return D.warn("createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!"),Ht(e)}exports.createBridgeComponent=gn;exports.createRemoteAppComponent=Ht;exports.createRemoteComponent=bn;
|
|
7
|
+
`)};function rr(e,t,r,n,o,s){return n(it(e,t,r,o))}const G="[ Federation Runtime ]",ve=rt(G);function k(e,t,r,n,o){e||S(t)}function S(e,t,r,n,o){if(t!==void 0)return rr(e,t,r??{},i=>{throw new Error(`${G}: ${i}`)},n);const s=e;throw s instanceof Error?(s.message.startsWith(G)||(s.message=`${G}: ${s.message}`),s):new Error(`${G}: ${s}`)}function Le(e){e instanceof Error&&(e.message.startsWith(G)||(e.message=`${G}: ${e.message}`)),ve.warn(e)}function nr(e,t){return e.findIndex(r=>r===t)===-1&&e.push(t),e}function Q(e){return"version"in e&&e.version?`${e.name}:${e.version}`:"entry"in e&&e.entry?`${e.name}:${e.entry}`:`${e.name}`}function Me(e){return typeof e.entry<"u"}function at(e){return!e.entry.includes(".json")}function Ce(e){return e&&typeof e=="object"}const or=Object.prototype.toString;function sr(e){return or.call(e)==="[object Object]"}function ct(e){return Array.isArray(e)?e:[e]}function lt(e){const t={url:"",type:"global",globalName:""};return H||Xe()||!("ssrRemoteEntry"in e)?"remoteEntry"in e?{url:e.remoteEntry,type:e.remoteEntryType,globalName:e.globalName}:t:"ssrRemoteEntry"in e?{url:e.ssrRemoteEntry||t.url,type:e.ssrRemoteEntryType||t.type,globalName:e.globalName}:t}const ir=(e,t)=>{let r;return e.endsWith("/")?r=e.slice(0,-1):r=e,t.startsWith(".")&&(t=t.slice(1)),r=r+t,r},I=typeof globalThis=="object"?globalThis:window,O=(()=>{try{return document.defaultView}catch{return I}})(),ee=O;function le(e,t,r){Object.defineProperty(e,t,{value:r,configurable:!1,writable:!0})}function ue(e,t){return Object.hasOwnProperty.call(e,t)}ue(I,"__GLOBAL_LOADING_REMOTE_ENTRY__")||le(I,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});const W=I.__GLOBAL_LOADING_REMOTE_ENTRY__;function ut(e){var t,r,n,o,s,i;ue(e,"__VMOK__")&&!ue(e,"__FEDERATION__")&&le(e,"__FEDERATION__",e.__VMOK__),ue(e,"__FEDERATION__")||(le(e,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),le(e,"__VMOK__",e.__FEDERATION__)),(t=e.__FEDERATION__).__GLOBAL_PLUGIN__??(t.__GLOBAL_PLUGIN__=[]),(r=e.__FEDERATION__).__INSTANCES__??(r.__INSTANCES__=[]),(n=e.__FEDERATION__).moduleInfo??(n.moduleInfo={}),(o=e.__FEDERATION__).__SHARE__??(o.__SHARE__={}),(s=e.__FEDERATION__).__MANIFEST_LOADING__??(s.__MANIFEST_LOADING__={}),(i=e.__FEDERATION__).__PRELOADED_MAP__??(i.__PRELOADED_MAP__=new Map)}ut(I);ut(O);function ar(e,t=we()){t&&(I.__FEDERATION__.__DEBUG_CONSTRUCTOR__=e,I.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="2.2.3")}function K(e,t){if(typeof t=="string"){if(e[t])return{value:e[t],key:t};{const r=Object.keys(e);for(const n of r){const[o,s]=n.split(":"),i=`${o}:${t}`,a=e[i];if(a)return{value:a,key:i}}return{value:void 0,key:t}}}else S(`getInfoWithoutType: "key" must be a string, got ${typeof t} (${JSON.stringify(t)}).`)}const xe=()=>O.__FEDERATION__.moduleInfo,cr=(e,t)=>{const r=K(t,Q(e)).value;if(r&&!r.version&&"version"in e&&e.version&&(r.version=e.version),r)return r;if("version"in e&&e.version){const{version:n,...o}=e,s=Q(o),i=K(O.__FEDERATION__.moduleInfo,s).value;if((i==null?void 0:i.version)===n)return i}},fe=e=>cr(e,O.__FEDERATION__.moduleInfo),Ue=(e,t)=>{const r=Q(e);return O.__FEDERATION__.moduleInfo[r]=t,O.__FEDERATION__.moduleInfo},lr=e=>(O.__FEDERATION__.moduleInfo={...O.__FEDERATION__.moduleInfo,...e},()=>{const t=Object.keys(e);for(const r of t)delete O.__FEDERATION__.moduleInfo[r]}),De=(e,t)=>{const r=t||`__FEDERATION_${e}:custom__`;return{remoteEntryKey:r,entryExports:I[r]}},ur=()=>O.__FEDERATION__.__GLOBAL_PLUGIN__,fr=e=>I.__FEDERATION__.__PRELOADED_MAP__.get(e),hr=e=>I.__FEDERATION__.__PRELOADED_MAP__.set(e,!0),Ve="[0-9A-Za-z-]+",Fe=`(?:\\+(${Ve}(?:\\.${Ve})*))`,Z="0|[1-9]\\d*",he="[0-9]+",ft="\\d*[a-zA-Z-][a-zA-Z0-9-]*",Be=`(?:${he}|${ft})`,dr=`(?:-?(${Be}(?:\\.${Be})*))`,We=`(?:${Z}|${ft})`,ht=`(?:-(${We}(?:\\.${We})*))`,be=`${Z}|x|X|\\*`,z=`[v=\\s]*(${be})(?:\\.(${be})(?:\\.(${be})(?:${ht})?${Fe}?)?)?`,mr=`^\\s*(${z})\\s+-\\s+(${z})\\s*$`,pr=`[v=\\s]*${`(${he})\\.(${he})\\.(${he})`}${dr}?${Fe}?`,He="((?:<|>)?=?)",yr=`(\\s*)${He}\\s*(${pr}|${z})`,dt="(?:~>?)",gr=`(\\s*)${dt}\\s+`,mt="(?:\\^)",Er=`(\\s*)${mt}\\s+`,_r="(<|>)?=?\\s*\\*",br=`^${mt}${z}$`,Rr=`v?${`(${Z})\\.(${Z})\\.(${Z})`}${ht}?${Fe}?`,Sr=`^${dt}${z}$`,$r=`^${He}\\s*${z}$`,wr=`^${He}\\s*(${Rr})$|^$`,Nr="^\\s*>=\\s*0.0.0\\s*$";function C(e){return new RegExp(e)}function T(e){return!e||e.toLowerCase()==="x"||e==="*"}function pt(...e){return t=>e.reduce((r,n)=>n(r),t)}function je(e){return e.match(C(wr))}function qe(e,t,r,n){const o=`${e}.${t}.${r}`;return n?`${o}-${n}`:o}function Ir(e){return e.replace(C(mr),(t,r,n,o,s,i,a,l,c,f,h,u)=>(T(n)?r="":T(o)?r=`>=${n}.0.0`:T(s)?r=`>=${n}.${o}.0`:r=`>=${r}`,T(c)?l="":T(f)?l=`<${Number(c)+1}.0.0-0`:T(h)?l=`<${c}.${Number(f)+1}.0-0`:u?l=`<=${c}.${f}.${h}-${u}`:l=`<=${l}`,`${r} ${l}`.trim()))}function Tr(e){return e.replace(C(yr),"$1$2$3")}function vr(e){return e.replace(C(gr),"$1~")}function Ar(e){return e.replace(C(Er),"$1^")}function Pr(e){return e.trim().split(/\s+/).map(t=>t.replace(C(br),(r,n,o,s,i)=>T(n)?"":T(o)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:T(s)?n==="0"?`>=${n}.${o}.0 <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.0 <${Number(n)+1}.0.0-0`:i?n==="0"?o==="0"?`>=${n}.${o}.${s}-${i} <${n}.${o}.${Number(s)+1}-0`:`>=${n}.${o}.${s}-${i} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${s}-${i} <${Number(n)+1}.0.0-0`:n==="0"?o==="0"?`>=${n}.${o}.${s} <${n}.${o}.${Number(s)+1}-0`:`>=${n}.${o}.${s} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${s} <${Number(n)+1}.0.0-0`)).join(" ")}function kr(e){return e.trim().split(/\s+/).map(t=>t.replace(C(Sr),(r,n,o,s,i)=>T(n)?"":T(o)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:T(s)?`>=${n}.${o}.0 <${n}.${Number(o)+1}.0-0`:i?`>=${n}.${o}.${s}-${i} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${s} <${n}.${Number(o)+1}.0-0`)).join(" ")}function Or(e){return e.split(/\s+/).map(t=>t.trim().replace(C($r),(r,n,o,s,i,a)=>{const l=T(o),c=l||T(s),f=c||T(i);return n==="="&&f&&(n=""),a="",l?n===">"||n==="<"?"<0.0.0-0":"*":n&&f?(c&&(s=0),i=0,n===">"?(n=">=",c?(o=Number(o)+1,s=0,i=0):(s=Number(s)+1,i=0)):n==="<="&&(n="<",c?o=Number(o)+1:s=Number(s)+1),n==="<"&&(a="-0"),`${n+o}.${s}.${i}${a}`):c?`>=${o}.0.0${a} <${Number(o)+1}.0.0-0`:f?`>=${o}.${s}.0${a} <${o}.${Number(s)+1}.0-0`:r})).join(" ")}function Lr(e){return e.trim().replace(C(_r),"")}function Mr(e){return e.trim().replace(C(Nr),"")}function de(e,t){return e=Number(e)||e,t=Number(t)||t,e>t?1:e===t?0:-1}function Cr(e,t){const{preRelease:r}=e,{preRelease:n}=t;if(r===void 0&&n)return 1;if(r&&n===void 0)return-1;if(r===void 0&&n===void 0)return 0;for(let o=0,s=r.length;o<=s;o++){const i=r[o],a=n[o];if(i!==a)return i===void 0&&a===void 0?0:i?a?de(i,a):-1:1}return 0}function ie(e,t){return de(e.major,t.major)||de(e.minor,t.minor)||de(e.patch,t.patch)||Cr(e,t)}function Re(e,t){return e.version===t.version}function Dr(e,t){switch(e.operator){case"":case"=":return Re(e,t);case">":return ie(e,t)<0;case">=":return Re(e,t)||ie(e,t)<0;case"<":return ie(e,t)>0;case"<=":return Re(e,t)||ie(e,t)>0;case void 0:return!0;default:return!1}}function Fr(e){return pt(Pr,kr,Or,Lr)(e)}function Hr(e){return pt(Ir,Tr,vr,Ar)(e.trim()).split(/\s+/).join(" ")}function Y(e,t){if(!e)return!1;const r=je(e);if(!r)return!1;const[,n,,o,s,i,a]=r,l={operator:n,version:qe(o,s,i,a),major:o,minor:s,patch:i,preRelease:a==null?void 0:a.split(".")},c=t.split("||");for(const f of c){const h=f.trim();if(!h||h==="*"||h==="x")return!0;try{const u=Hr(h);if(!u.trim())return!0;const d=u.split(" ").map(g=>Fr(g)).join(" ");if(!d.trim())return!0;const m=d.split(/\s+/).map(g=>Mr(g)).filter(Boolean);if(m.length===0)continue;let y=!0;for(const g of m){const p=je(g);if(!p){y=!1;break}const[,E,,b,N,_,$]=p;if(!Dr({operator:E,version:qe(b,N,_,$),major:b,minor:N,patch:_,preRelease:$==null?void 0:$.split(".")},l)){y=!1;break}}if(y)return!0}catch(u){console.error(`[semver] Error processing range part "${h}":`,u);continue}}return!1}const ne="default",yt="global";function Gr(e,t,r,n){var s,i;let o;return"get"in e?o=e.get:"lib"in e?o=()=>Promise.resolve(e.lib):o=()=>Promise.resolve(()=>{S(`Cannot get shared "${r}" from "${t}": neither "get" nor "lib" is provided in the share config.`)}),(s=e.shareConfig)!=null&&s.eager&&((i=e.treeShaking)!=null&&i.mode)&&S(`Invalid shared config for "${r}" from "${t}": cannot use both "eager: true" and "treeShaking.mode" simultaneously. Choose one strategy.`),{deps:[],useIn:[],from:t,loading:null,...e,shareConfig:{requiredVersion:`^${e.version}`,singleton:!1,eager:!1,strictVersion:!1,...e.shareConfig},get:o,loaded:e!=null&&e.loaded||"lib"in e?!0:void 0,version:e.version??"0",scope:Array.isArray(e.scope)?e.scope:[e.scope??"default"],strategy:(e.strategy??n)||"version-first",treeShaking:e.treeShaking?{...e.treeShaking,mode:e.treeShaking.mode??"server-calc",status:e.treeShaking.status??$e.UNKNOWN,useIn:[]}:void 0}}function gt(e,t){const r=t.shared||{},n=t.name,o=Object.keys(r).reduce((i,a)=>{const l=ct(r[a]);return i[a]=i[a]||[],l.forEach(c=>{i[a].push(Gr(c,n,a,t.shareStrategy))}),i},{}),s={...e.shared};return Object.keys(o).forEach(i=>{s[i]?o[i].forEach(a=>{s[i].find(l=>l.version===a.version)||s[i].push(a)}):s[i]=o[i]}),{allShareInfos:s,newShareInfos:o}}function te(e,t){if(!e)return!1;const{status:r,mode:n}=e;return r===$e.NO_USE?!1:r===$e.CALCULATED?!0:n==="runtime-infer"?t?Ur(e,t):!0:!1}function x(e,t){const r=n=>{if(!Number.isNaN(Number(n))){const o=n.split(".");let s=n;for(let i=0;i<3-o.length;i++)s+=".0";return s}return n};return!!Y(r(e),`<=${r(t)}`)}const re=(e,t)=>{const r=t||function(n,o){return x(n,o)};return Object.keys(e).reduce((n,o)=>!n||r(n,o)||n==="0"?o:n,0)},pe=e=>!!e.loaded||typeof e.lib=="function",xr=e=>!!e.loading,Ur=(e,t)=>{if(!e||!t)return!1;const{usedExports:r}=e;return r?!!t.every(n=>r.includes(n)):!1};function Vr(e,t,r,n){const o=e[t][r];let s="",i=te(n);const a=function(l,c){return i?o[l].treeShaking?o[c].treeShaking?!pe(o[l].treeShaking)&&x(l,c):!1:!0:!pe(o[l])&&x(l,c)};if(i){if(s=re(e[t][r],a),s)return{version:s,useTreesShaking:i};i=!1}return{version:re(e[t][r],a),useTreesShaking:i}}const U=e=>pe(e)||xr(e);function Br(e,t,r,n){const o=e[t][r];let s="",i=te(n);const a=function(l,c){if(i){if(!o[l].treeShaking)return!0;if(!o[c].treeShaking)return!1;if(U(o[c].treeShaking))return U(o[l].treeShaking)?!!x(l,c):!0;if(U(o[l].treeShaking))return!1}return U(o[c])?U(o[l])?!!x(l,c):!0:U(o[l])?!1:x(l,c)};if(i){if(s=re(e[t][r],a),s)return{version:s,useTreesShaking:i};i=!1}return{version:re(e[t][r],a),useTreesShaking:i}}function Wr(e){return e==="loaded-first"?Br:Vr}function me(e,t,r,n){if(!e)return;const{shareConfig:o,scope:s=ne,strategy:i,treeShaking:a}=r,l=Array.isArray(s)?s:[s];for(const c of l)if(o&&e[c]&&e[c][t]){const{requiredVersion:f}=o,{version:h,useTreesShaking:u}=Wr(i)(e,c,t,a),d=()=>{const y=e[c][t][h];if(o.singleton){if(typeof f=="string"&&!Y(h,f)){const g=`Version ${h} from ${h&&y.from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${f})`;o.strictVersion?S(g):Le(g)}return{shared:y,useTreesShaking:u}}else{if(f===!1||f==="*")return{shared:y,useTreesShaking:u};if(Y(h,f))return{shared:y,useTreesShaking:u};const g=te(a);if(g){for(const[p,E]of Object.entries(e[c][t]))if(te(E.treeShaking,a==null?void 0:a.usedExports)&&Y(p,f))return{shared:E,useTreesShaking:g}}for(const[p,E]of Object.entries(e[c][t]))if(Y(p,f))return{shared:E,useTreesShaking:!1}}},m={shareScopeMap:e,scope:c,pkgName:t,version:h,GlobalFederation:ee.__FEDERATION__,shareInfo:r,resolver:d};return(n.emit(m)||m).resolver()}}function Et(){return ee.__FEDERATION__.__SHARE__}function Ke(e){const{pkgName:t,extraOptions:r,shareInfos:n}=e,o=l=>{if(!l)return;const c={};return l.forEach(h=>{c[h.version]=h}),c[re(c,function(h,u){return!pe(c[h])&&x(h,u)})]},s=(r==null?void 0:r.resolver)??o,i=l=>l!==null&&typeof l=="object"&&!Array.isArray(l),a=(...l)=>{const c={};for(const f of l)if(f)for(const[h,u]of Object.entries(f)){const d=c[h];i(d)&&i(u)?c[h]=a(d,u):u!==void 0&&(c[h]=u)}return c};return a(s(n[t]),r==null?void 0:r.customShareInfo)}const V=(e,t)=>{e.useIn||(e.useIn=[]),nr(e.useIn,t)};function ae(e,t){return t&&e.treeShaking?e.treeShaking:e}function jr(e,t){for(const r of e){const n=t.startsWith(r.name);let o=t.replace(r.name,"");if(n){if(o.startsWith("/")){const a=r.name;return o=`.${o}`,{pkgNameOrAlias:a,expose:o,remote:r}}else if(o==="")return{pkgNameOrAlias:r.name,expose:".",remote:r}}const s=r.alias&&t.startsWith(r.alias);let i=r.alias&&t.replace(r.alias,"");if(r.alias&&s){if(i&&i.startsWith("/")){const a=r.alias;return i=`.${i}`,{pkgNameOrAlias:a,expose:i,remote:r}}else if(i==="")return{pkgNameOrAlias:r.alias,expose:".",remote:r}}}}function qr(e,t){for(const r of e)if(t===r.name||r.alias&&t===r.alias)return r}const _t="RUNTIME-001",bt="RUNTIME-002",Rt="RUNTIME-003",St="RUNTIME-004",$t="RUNTIME-005",Ae="RUNTIME-006",wt="RUNTIME-007",Ge="RUNTIME-008",Kr="RUNTIME-009",Nt="RUNTIME-010",It="RUNTIME-011",L={[_t]:"Failed to get remoteEntry exports.",[bt]:'The remote entry interface does not contain "init"',[Rt]:"Failed to get manifest.",[St]:"Failed to locate remote.",[$t]:"Invalid loadShareSync function call from bundler runtime",[Ae]:"Invalid loadShareSync function call from runtime",[wt]:"Failed to get remote snapshot.",[Ge]:"Failed to load script resources.",[Kr]:"Please call createInstance first.",[Nt]:'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.',[It]:"The remoteEntry URL is missing from the remote snapshot."};({...L});const Tt=".then(callbacks[0]).catch(callbacks[1])";async function zr({entry:e,remoteEntryExports:t}){return new Promise((r,n)=>{try{t?r(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${e}")${Tt}`)([r,n]):import(e).then(r).catch(n)}catch(o){S(`Failed to load ESM entry from "${e}". ${o instanceof Error?o.message:String(o)}`)}})}async function Jr({entry:e,remoteEntryExports:t}){return new Promise((r,n)=>{try{t?r(t):typeof __system_context__>"u"?System.import(e).then(r).catch(n):new Function("callbacks",`System.import("${e}")${Tt}`)([r,n])}catch(o){S(`Failed to load SystemJS entry from "${e}". ${o instanceof Error?o.message:String(o)}`)}})}function vt(e,t,r){const{remoteEntryKey:n,entryExports:o}=De(e,t);return o||S(_t,L,{remoteName:e,remoteEntryUrl:r,remoteEntryKey:n}),o}async function Xr({name:e,globalName:t,entry:r,loaderHook:n,getEntryUrl:o}){const{entryExports:s}=De(e,t);if(s)return s;const i=o?o(r):r;return Yt(i,{attrs:{},createScriptHook:(a,l)=>{const c=n.lifecycle.createScript.emit({url:a,attrs:l});if(c&&(c instanceof HTMLScriptElement||"script"in c||"timeout"in c))return c}}).then(()=>vt(e,t,r),a=>{const l=a instanceof Error?a.message:String(a);S(Ge,L,{remoteName:e,resourceUrl:i},l)})}async function Yr({remoteInfo:e,remoteEntryExports:t,loaderHook:r,getEntryUrl:n}){const{entry:o,entryGlobalName:s,name:i,type:a}=e;switch(a){case"esm":case"module":return zr({entry:o,remoteEntryExports:t});case"system":return Jr({entry:o,remoteEntryExports:t});default:return Xr({entry:o,globalName:s,name:i,loaderHook:r,getEntryUrl:n})}}async function Zr({remoteInfo:e,loaderHook:t}){const{entry:r,entryGlobalName:n,name:o,type:s}=e,{entryExports:i}=De(o,n);return i||er(r,{attrs:{name:o,globalName:n,type:s},loaderHook:{createScriptHook:(a,l={})=>{const c=t.lifecycle.createScript.emit({url:a,attrs:l});if(c&&"url"in c)return c}}}).then(()=>vt(o,n,r)).catch(a=>{S(`Failed to load Node.js entry for remote "${o}" from "${r}". ${a instanceof Error?a.message:String(a)}`)})}function Pe(e){const{entry:t,name:r}=e;return Ye(r,t)}async function ye(e){const{origin:t,remoteEntryExports:r,remoteInfo:n,getEntryUrl:o,_inErrorHandling:s=!1}=e,i=Pe(n);if(r)return r;if(!W[i]){const a=t.remoteHandler.hooks.lifecycle.loadEntry,l=t.loaderHook;W[i]=a.emit({loaderHook:l,remoteInfo:n,remoteEntryExports:r}).then(c=>c||((typeof ENV_TARGET<"u"?ENV_TARGET==="web":H)?Yr({remoteInfo:n,remoteEntryExports:r,loaderHook:l,getEntryUrl:o}):Zr({remoteInfo:n,loaderHook:l}))).catch(async c=>{const f=Pe(n),h=c instanceof Error&&c.message.includes("ScriptExecutionError");if(c instanceof Error&&c.message.includes(Ge)&&!h&&!s){const u=m=>ye({...m,_inErrorHandling:!0}),d=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:u,origin:t,remoteInfo:n,remoteEntryExports:r,globalLoading:W,uniqueKey:f});if(d)return d}throw c})}return W[i]}function ke(e){return{...e,entry:"entry"in e?e.entry:"",type:e.type||yt,entryGlobalName:e.entryGlobalName||e.name,shareScope:e.shareScope||ne}}function Qr(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function en(e,t){const r=ur(),n=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return r.length>0&&r.forEach(o=>{e!=null&&e.find(s=>s.name!==o.name)&&e.push(o)}),e&&e.length>0&&e.forEach(o=>{n.forEach(s=>{s.applyPlugin(o,t)})}),e}function tn(e){return{name:e.name,alias:e.alias,entry:"entry"in e?e.entry:void 0,version:"version"in e?e.version:void 0,type:e.type,entryGlobalName:e.entryGlobalName,shareScope:e.shareScope}}function J(e){var r,n,o,s,i,a;const t={};for(const[l,c]of Object.entries(e.shared)){const f=c[0];f&&(t[l]={version:f.version,singleton:(r=f.shareConfig)==null?void 0:r.singleton,requiredVersion:((n=f.shareConfig)==null?void 0:n.requiredVersion)===!1?!1:(o=f.shareConfig)==null?void 0:o.requiredVersion,eager:f.eager,strictVersion:(s=f.shareConfig)==null?void 0:s.strictVersion})}return{project:{name:e.name,mfRole:((i=e.remotes)==null?void 0:i.length)>0?"host":"unknown"},mfConfig:{name:e.name,remotes:((a=e.remotes)==null?void 0:a.map(tn))??[],shared:t}}}function At(e){return{resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1,...e}}function rn(e,t){return t.map(r=>{const n=qr(e,r.nameOrAlias);return k(n,`Unable to preload ${r.nameOrAlias} as it is not included in ${!n&&Qe({remoteInfo:n,remotes:e})}`),{remote:n,preloadConfig:At(r)}})}function nn(e){return e?e.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function Pt(e,t,r,n=!0){const{cssAssets:o,jsAssetsWithoutEntry:s,entryAssets:i}=r;if(t.options.inBrowser){if(i.forEach(a=>{const{moduleInfo:l}=a,c=t.moduleCache.get(e.name);ye(c?{origin:t,remoteInfo:l,remoteEntryExports:c.remoteEntryExports}:{origin:t,remoteInfo:l,remoteEntryExports:void 0})}),n){const a={rel:"preload",as:"style"};o.forEach(l=>{const{link:c,needAttach:f}=Ee({url:l,cb:()=>{},attrs:a,createLinkHook:(h,u)=>{const d=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:u});if(d instanceof HTMLLinkElement)return d}});f&&document.head.appendChild(c)})}else{const a={rel:"stylesheet",type:"text/css"};o.forEach(l=>{const{link:c,needAttach:f}=Ee({url:l,cb:()=>{},attrs:a,createLinkHook:(h,u)=>{const d=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:u});if(d instanceof HTMLLinkElement)return d},needDeleteLink:!1});f&&document.head.appendChild(c)})}if(n){const a={rel:"preload",as:"script"};s.forEach(l=>{const{link:c,needAttach:f}=Ee({url:l,cb:()=>{},attrs:a,createLinkHook:(h,u)=>{const d=t.loaderHook.lifecycle.createLink.emit({url:h,attrs:u});if(d instanceof HTMLLinkElement)return d}});f&&document.head.appendChild(c)})}else{const a={fetchpriority:"high",type:(e==null?void 0:e.type)==="module"?"module":"text/javascript"};s.forEach(l=>{const{script:c,needAttach:f}=ot({url:l,cb:()=>{},attrs:a,createScriptHook:(h,u)=>{const d=t.loaderHook.lifecycle.createScript.emit({url:h,attrs:u});if(d instanceof HTMLScriptElement)return d},needDeleteScript:!0});f&&document.head.appendChild(c)})}}}function on(e,t,r){const n=t,o=Array.isArray(e.shareScope)?e.shareScope:[e.shareScope];o.length||o.push("default"),o.forEach(i=>{n[i]||(n[i]={})});const s={version:e.version||"",shareScopeKeys:Array.isArray(e.shareScope)?o:e.shareScope||"default"};return Object.defineProperty(s,"shareScopeMap",{value:n,enumerable:!1}),{remoteEntryInitOptions:s,shareScope:n[o[0]],initScope:r??[]}}var kt=class{constructor({remoteInfo:e,host:t}){this.inited=!1,this.initing=!1,this.lib=void 0,this.remoteInfo=e,this.host=t}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;const e=await ye({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports});return k(e,`remoteEntryExports is undefined
|
|
8
|
+
${Qe(this.remoteInfo)}`),this.remoteEntryExports=e,this.remoteEntryExports}async init(e,t,r){const n=await this.getEntry();if(this.inited)return n;if(this.initPromise)return await this.initPromise,n;this.initing=!0,this.initPromise=(async()=>{const{remoteEntryInitOptions:o,shareScope:s,initScope:i}=on(this.remoteInfo,this.host.shareScopeMap,r),a=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:s,remoteEntryInitOptions:o,initScope:i,remoteInfo:this.remoteInfo,origin:this.host});typeof(n==null?void 0:n.init)>"u"&&S(bt,L,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName},void 0,J(this.host.options)),await n.init(a.shareScope,a.initScope,a.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...a,id:e,remoteSnapshot:t,remoteEntryExports:n}),this.inited=!0})();try{await this.initPromise}finally{this.initing=!1,this.initPromise=void 0}return n}async get(e,t,r,n){const{loadFactory:o=!0}=r||{loadFactory:!0},s=await this.init(e,n);this.lib=s;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:s,expose:t,moduleInfo:this.remoteInfo}),i||(i=await s.get(t)),k(i,`${Q(this.remoteInfo)} remote don't export ${t}.`);const a=ir(this.remoteInfo.name,t),l=this.wraperFactory(i,a);return o?await l():l}wraperFactory(e,t){function r(n,o){n&&typeof n=="object"&&Object.isExtensible(n)&&!Object.getOwnPropertyDescriptor(n,Symbol.for("mf_module_id"))&&Object.defineProperty(n,Symbol.for("mf_module_id"),{value:o,enumerable:!1})}return e instanceof Promise?async()=>{const n=await e();return r(n,t),n}:()=>{const n=e();return r(n,t),n}}},A=class{constructor(e){this.type="",this.listeners=new Set,e&&(this.type=e)}on(e){typeof e=="function"&&this.listeners.add(e)}once(e){const t=this;this.on(function r(...n){return t.remove(r),e.apply(null,n)})}emit(...e){let t;return this.listeners.size>0&&this.listeners.forEach(r=>{t=r(...e)}),t}remove(e){this.listeners.delete(e)}removeAll(){this.listeners.clear()}},P=class extends A{emit(...e){let t;const r=Array.from(this.listeners);if(r.length>0){let n=0;const o=s=>s===!1?!1:n<r.length?Promise.resolve(r[n++].apply(null,e)).then(o):s;t=o()}return Promise.resolve(t)}};function Ot(e,t){if(!Ce(t))return!1;if(e!==t){for(const r in e)if(!(r in t))return!1}return!0}var j=class extends A{constructor(e){super(),this.onerror=S,this.type=e}emit(e){Ce(e)||S(`The data for the "${this.type}" hook should be an object.`);for(const t of this.listeners)try{const r=t(e);if(Ot(e,r))e=r;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(r){Le(r),this.onerror(r)}return e}},F=class extends A{constructor(e){super(),this.onerror=S,this.type=e}emit(e){Ce(e)||S(`The response data for the "${this.type}" hook must be an object.`);const t=Array.from(this.listeners);if(t.length>0){let r=0;const n=s=>(Le(s),this.onerror(s),e),o=s=>{if(Ot(e,s)){if(e=s,r<t.length)try{return Promise.resolve(t[r++](e)).then(o,n)}catch(i){return n(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return e};return Promise.resolve(o(e))}return Promise.resolve(e)}},q=class{constructor(e){this.registerPlugins={},this.lifecycle=e,this.lifecycleKeys=Object.keys(e)}applyPlugin(e,t){var n;k(sr(e),"Plugin configuration is invalid.");const r=e.name;k(r,"A name must be provided by the plugin."),this.registerPlugins[r]||(this.registerPlugins[r]=e,(n=e.apply)==null||n.call(e,t),Object.keys(this.lifecycle).forEach(o=>{const s=e[o];s&&this.lifecycle[o].on(s)}))}removePlugin(e){k(e,"A name is required.");const t=this.registerPlugins[e];k(t,`The plugin "${e}" is not registered.`),Object.keys(t).forEach(r=>{r!=="name"&&this.lifecycle[r].remove(t[r])})}};function Lt(e,t){const r=lt(t);r.url||S(It,L,{remoteName:e.name});let n=Ne(t,r.url);!H&&!n.startsWith("http")&&(n=`https:${n}`),e.type=r.type,e.entryGlobalName=r.globalName,e.entry=n,e.version=t.version,e.buildVersion=t.buildVersion}function sn(){return{name:"snapshot-plugin",async afterResolve(e){const{remote:t,pkgNameOrAlias:r,expose:n,origin:o,remoteInfo:s,id:i}=e;if(!Me(t)||!at(t)){const{remoteSnapshot:a,globalSnapshot:l}=await o.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:i});Lt(s,a);const c={remote:t,preloadConfig:{nameOrAlias:r,exposes:[n],resourceCategory:"sync",share:!1,depsRemote:!1}},f=await o.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:c,remoteInfo:s,remote:t,remoteSnapshot:a,globalSnapshot:l});return f&&Pt(s,o,f,!1),{...e,remoteSnapshot:a}}return e}}}function an(e){const t=e.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 Mt(e,t,r,n,o={},s){const{value:i}=K(e,Q(t)),a=s||i;if(a&&!et(a)&&(r(a,t,n),a.remotesInfo)){const l=Object.keys(a.remotesInfo);for(const c of l){if(o[c])continue;o[c]=!0;const f=an(c),h=a.remotesInfo[c];Mt(e,{name:f.name,version:h.matchedVersion},r,!1,o,void 0)}}}const Se=(e,t)=>document.querySelector(`${e}[${e==="link"?"href":"src"}="${t}"]`);function cn(e,t,r,n,o){const s=[],i=[],a=[],l=new Set,c=new Set,{options:f}=e,{preloadConfig:h}=t,{depsRemote:u}=h;if(Mt(n,r,(m,y,g)=>{var $;let p;if(g)p=h;else if(Array.isArray(u)){const R=u.find(w=>w.nameOrAlias===y.name||w.nameOrAlias===y.alias);if(!R)return;p=At(R)}else if(u===!0)p=h;else return;const E=Ne(m,lt(m).url);E&&a.push({name:y.name,moduleInfo:{name:y.name,entry:E,type:"remoteEntryType"in m?m.remoteEntryType:"global",entryGlobalName:"globalName"in m?m.globalName:y.name,shareScope:"",version:"version"in m?m.version:void 0},url:E});let b="modules"in m?m.modules:[];const N=nn(p.exposes);N.length&&"modules"in m&&(b=($=m==null?void 0:m.modules)==null?void 0:$.reduce((R,w)=>((N==null?void 0:N.indexOf(w.moduleName))!==-1&&R.push(w),R),[]));function _(R){const w=R.map(M=>Ne(m,M));return p.filter?w.filter(p.filter):w}if(b){const R=b.length;for(let w=0;w<R;w++){const M=b[w],ge=`${y.name}/${M.moduleName}`;e.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:M.moduleName==="."?y.name:ge,name:y.name,remoteSnapshot:m,preloadConfig:p,remote:y,origin:e}),!fr(ge)&&(p.resourceCategory==="all"?(s.push(..._(M.assets.css.async)),s.push(..._(M.assets.css.sync)),i.push(..._(M.assets.js.async)),i.push(..._(M.assets.js.sync))):p.resourceCategory==="sync"&&(s.push(..._(M.assets.css.sync)),i.push(..._(M.assets.js.sync))),hr(ge))}}},!0,{},o),o.shared&&o.shared.length>0){const m=(y,g)=>{const{shared:p}=me(e.shareScopeMap,g.sharedName,y,e.sharedHandler.hooks.lifecycle.resolveShare)||{};p&&typeof p.lib=="function"&&(g.assets.js.sync.forEach(E=>{l.add(E)}),g.assets.css.sync.forEach(E=>{c.add(E)}))};o.shared.forEach(y=>{var E;const g=(E=f.shared)==null?void 0:E[y.sharedName];if(!g)return;const p=y.version?g.find(b=>b.version===y.version):g;p&&ct(p).forEach(b=>{m(b,y)})})}const d=i.filter(m=>!l.has(m)&&!Se("script",m));return{cssAssets:s.filter(m=>!c.has(m)&&!Se("link",m)),jsAssetsWithoutEntry:d,entryAssets:a.filter(m=>!Se("script",m.url))}}const ln=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(e){const{origin:t,preloadOptions:r,remoteInfo:n,remote:o,globalSnapshot:s,remoteSnapshot:i}=e;return H?Me(o)&&at(o)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:o.name,url:o.entry,moduleInfo:{name:n.name,entry:o.entry,type:n.type||"global",entryGlobalName:"",shareScope:""}}]}:(Lt(n,i),cn(t,r,n,s,i)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function Ct(e,t){const r=fe({name:t.name,version:t.options.version}),n=r&&"remotesInfo"in r&&r.remotesInfo&&K(r.remotesInfo,e.name).value;return n&&n.matchedVersion?{hostGlobalSnapshot:r,globalSnapshot:xe(),remoteSnapshot:fe({name:e.name,version:n.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:xe(),remoteSnapshot:fe({name:e.name,version:"version"in e?e.version:void 0})}}var un=class{constructor(e){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new q({beforeLoadRemoteSnapshot:new P("beforeLoadRemoteSnapshot"),loadSnapshot:new F("loadGlobalSnapshot"),loadRemoteSnapshot:new F("loadRemoteSnapshot"),afterLoadSnapshot:new F("afterLoadSnapshot")}),this.manifestLoading=ee.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=e,this.loaderHook=e.loaderHook}async loadRemoteSnapshotInfo({moduleInfo:e,id:t,expose:r}){const{options:n}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:n,moduleInfo:e});let o=fe({name:this.HostInstance.options.name,version:this.HostInstance.options.version});o||(o={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},lr({[this.HostInstance.options.name]:o})),o&&"remotesInfo"in o&&!K(o.remotesInfo,e.name).value&&("version"in e||"entry"in e)&&(o.remotesInfo={...o==null?void 0:o.remotesInfo,[e.name]:{matchedVersion:"version"in e?e.version:e.entry}});const{hostGlobalSnapshot:s,remoteSnapshot:i,globalSnapshot:a}=this.getGlobalRemoteInfo(e),{remoteSnapshot:l,globalSnapshot:c}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:e,hostGlobalSnapshot:s,remoteSnapshot:i,globalSnapshot:a});let f,h;if(l)if(et(l)){const u=H?l.remoteEntry:l.ssrRemoteEntry||l.remoteEntry||"",d=await this.getManifestJson(u,e,{}),m=Ue({...e,entry:u},d);f=d,h=m}else{const{remoteSnapshot:u}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:l,from:"global"});f=u,h=c}else if(Me(e)){const u=await this.getManifestJson(e.entry,e,{}),d=Ue(e,u),{remoteSnapshot:m}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:u,from:"global"});f=m,h=d}else S(wt,L,{remoteName:e.name,remoteVersion:e.version,hostName:this.HostInstance.options.name,globalSnapshot:JSON.stringify(c)},void 0,J(this.HostInstance.options));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:t,host:this.HostInstance,options:n,moduleInfo:e,remoteSnapshot:f}),{remoteSnapshot:f,globalSnapshot:h}}getGlobalRemoteInfo(e){return Ct(e,this.HostInstance)}async getManifestJson(e,t,r){const n=async()=>{let s=this.manifestCache.get(e);if(s)return s;try{let i=await this.loaderHook.lifecycle.fetch.emit(e,{});(!i||!(i instanceof Response))&&(i=await fetch(e,{})),s=await i.json()}catch(i){s=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:e,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),s||(delete this.manifestLoading[e],S(Rt,L,{manifestUrl:e,moduleName:t.name,hostName:this.HostInstance.options.name},`${i}`,J(this.HostInstance.options)))}return k(s.metaData&&s.exposes&&s.shared,`"${e}" is not a valid federation manifest for remote "${t.name}". Missing required fields: ${[!s.metaData&&"metaData",!s.exposes&&"exposes",!s.shared&&"shared"].filter(Boolean).join(", ")}.`),this.manifestCache.set(e,s),s},o=async()=>{const s=await n(),i=qt(s,{version:e}),{remoteSnapshot:a}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,manifestJson:s,remoteSnapshot:i,manifestUrl:e,from:"manifest"});return a};return this.manifestLoading[e]||(this.manifestLoading[e]=o().then(s=>s)),this.manifestLoading[e]}},fn=class{constructor(e){this.hooks=new q({beforeRegisterShare:new j("beforeRegisterShare"),afterResolve:new F("afterResolve"),beforeLoadShare:new F("beforeLoadShare"),loadShare:new P,resolveShare:new j("resolveShare"),initContainerShareScopeMap:new j("initContainerShareScopeMap")}),this.host=e,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(e.options)}registerShared(e,t){const{newShareInfos:r,allShareInfos:n}=gt(e,t);return Object.keys(r).forEach(o=>{r[o].forEach(s=>{s.scope.forEach(i=>{var a;this.hooks.lifecycle.beforeRegisterShare.emit({origin:this.host,pkgName:o,shared:s}),(a=this.shareScopeMap[i])!=null&&a[o]||this.setShared({pkgName:o,lib:s.lib,get:s.get,loaded:s.loaded||!!s.lib,shared:s,from:t.name})})})}),{newShareInfos:r,allShareInfos:n}}async loadShare(e,t){const{host:r}=this,n=Ke({pkgName:e,extraOptions:t,shareInfos:r.options.shared});n!=null&&n.scope&&await Promise.all(n.scope.map(async a=>{await Promise.all(this.initializeSharing(a,{strategy:n.strategy}))}));const{shareInfo:o}=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:e,shareInfo:n,shared:r.options.shared,origin:r});k(o,`Cannot find shared "${e}" in host "${r.options.name}". Ensure the shared config for "${e}" is declared in the federation plugin options and the host has been initialized before loading shares.`);const{shared:s,useTreesShaking:i}=me(this.shareScopeMap,e,o,this.hooks.lifecycle.resolveShare)||{};if(s){const a=ae(s,i);if(a.lib)return V(a,r.options.name),a.lib;if(a.loading&&!a.loaded){const l=await a.loading;return a.loaded=!0,a.lib||(a.lib=l),V(a,r.options.name),l}else{const c=(async()=>{const f=await a.get();return V(a,r.options.name),a.loaded=!0,a.lib=f,f})();return this.setShared({pkgName:e,loaded:!1,shared:s,from:r.options.name,lib:null,loading:c,treeShaking:i?a:void 0}),c}}else{if(t!=null&&t.customShareInfo)return!1;const a=te(o.treeShaking),l=ae(o,a),f=(async()=>{const h=await l.get();l.lib=h,l.loaded=!0,V(l,r.options.name);const{shared:u,useTreesShaking:d}=me(this.shareScopeMap,e,o,this.hooks.lifecycle.resolveShare)||{};if(u){const m=ae(u,d);m.lib=h,m.loaded=!0,u.from=o.from}return h})();return this.setShared({pkgName:e,loaded:!1,shared:o,from:r.options.name,lib:null,loading:f,treeShaking:a?l:void 0}),f}}initializeSharing(e=ne,t){const{host:r}=this,n=t==null?void 0:t.from,o=t==null?void 0:t.strategy;let s=t==null?void 0:t.initScope;const i=[];if(n!=="build"){const{initTokens:u}=this;s||(s=[]);let d=u[e];if(d||(d=u[e]={from:this.host.name}),s.indexOf(d)>=0)return i;s.push(d)}const a=this.shareScopeMap,l=r.options.name;a[e]||(a[e]={});const c=a[e],f=(u,d)=>{var b;const{version:m,eager:y}=d;c[u]=c[u]||{};const g=c[u],p=g[m]&&ae(g[m]),E=!!(p&&("eager"in p&&p.eager||"shareConfig"in p&&((b=p.shareConfig)!=null&&b.eager)));(!p||p.strategy!=="loaded-first"&&!p.loaded&&(!y!=!E?y:l>g[m].from))&&(g[m]=d)},h=async u=>{const{module:d}=await r.remoteHandler.getRemoteModuleAndOptions({id:u});let m;try{m=await d.getEntry()}catch(y){if(m=await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:u,error:y,from:"runtime",lifecycle:"beforeLoadShare",origin:r}),!m)return}finally{m!=null&&m.init&&!d.initing&&(d.remoteEntryExports=m,await d.init(void 0,void 0,s))}};return Object.keys(r.options.shared).forEach(u=>{r.options.shared[u].forEach(d=>{d.scope.includes(e)&&f(u,d)})}),(r.options.shareStrategy==="version-first"||o==="version-first")&&r.options.remotes.forEach(u=>{u.shareScope===e&&i.push(h(u.name))}),i}loadShareSync(e,t){const{host:r}=this,n=Ke({pkgName:e,extraOptions:t,shareInfos:r.options.shared});n!=null&&n.scope&&n.scope.forEach(i=>{this.initializeSharing(i,{strategy:n.strategy})});const{shared:o,useTreesShaking:s}=me(this.shareScopeMap,e,n,this.hooks.lifecycle.resolveShare)||{};if(o){if(typeof o.lib=="function")return V(o,r.options.name),o.loaded||(o.loaded=!0,o.from===r.options.name&&(n.loaded=!0)),o.lib;if(typeof o.get=="function"){const i=o.get();if(!(i instanceof Promise))return V(o,r.options.name),this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:i,shared:o}),i}}if(n.lib)return n.loaded||(n.loaded=!0),n.lib;if(n.get){const i=n.get();return i instanceof Promise&&S((t==null?void 0:t.from)==="build"?$t:Ae,L,{hostName:r.options.name,sharedPkgName:e},void 0,J(r.options)),n.lib=i,this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:n.lib,shared:n}),n.lib}S(Ae,L,{hostName:r.options.name,sharedPkgName:e},void 0,J(r.options))}initShareScopeMap(e,t,r={}){const{host:n}=this;this.shareScopeMap[e]=t,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:t,options:n.options,origin:n,scopeName:e,hostShareScopeMap:r.hostShareScopeMap})}setShared({pkgName:e,shared:t,from:r,lib:n,loading:o,loaded:s,get:i,treeShaking:a}){const{version:l,scope:c="default",...f}=t,h=Array.isArray(c)?c:[c],u=d=>{const m=(g,p,E)=>{E&&!g[p]&&(g[p]=E)},y=a?d.treeShaking:d;m(y,"loaded",s),m(y,"loading",o),m(y,"get",i)};h.forEach(d=>{this.shareScopeMap[d]||(this.shareScopeMap[d]={}),this.shareScopeMap[d][e]||(this.shareScopeMap[d][e]={}),this.shareScopeMap[d][e][l]||(this.shareScopeMap[d][e][l]={version:l,scope:[d],...f,lib:n});const m=this.shareScopeMap[d][e][l];u(m),r&&m.from!==r&&(m.from=r)})}_setGlobalShareScopeMap(e){const t=Et(),r=e.id||e.name;r&&!t[r]&&(t[r]=this.shareScopeMap)}},hn=class{constructor(e){this.hooks=new q({beforeRegisterRemote:new j("beforeRegisterRemote"),registerRemote:new j("registerRemote"),beforeRequest:new F("beforeRequest"),onLoad:new P("onLoad"),handlePreloadModule:new A("handlePreloadModule"),errorLoadRemote:new P("errorLoadRemote"),beforePreloadRemote:new P("beforePreloadRemote"),generatePreloadAssets:new P("generatePreloadAssets"),afterPreloadRemote:new P,loadEntry:new P}),this.host=e,this.idToRemoteMap={}}formatAndRegisterRemote(e,t){return(t.remotes||[]).reduce((r,n)=>(this.registerRemote(n,r,{force:!1}),r),e.remotes)}setIdToRemoteMap(e,t){const{remote:r,expose:n}=t,{name:o,alias:s}=r;if(this.idToRemoteMap[e]={name:r.name,expose:n},s&&e.startsWith(o)){const i=e.replace(o,s);this.idToRemoteMap[i]={name:r.name,expose:n};return}if(s&&e.startsWith(s)){const i=e.replace(s,o);this.idToRemoteMap[i]={name:r.name,expose:n}}}async loadRemote(e,t){const{host:r}=this;try{const{loadFactory:n=!0}=t||{loadFactory:!0},{module:o,moduleOptions:s,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:e}),{pkgNameOrAlias:a,remote:l,expose:c,id:f,remoteSnapshot:h}=i,u=await o.get(f,c,t,h),d=await this.hooks.lifecycle.onLoad.emit({id:f,pkgNameOrAlias:a,expose:c,exposeModule:n?u:void 0,exposeModuleFactory:n?void 0:u,remote:l,options:s,moduleInstance:o,origin:r});return this.setIdToRemoteMap(e,i),typeof d=="function"?d:u}catch(n){const{from:o="runtime"}=t||{from:"runtime"},s=await this.hooks.lifecycle.errorLoadRemote.emit({id:e,error:n,from:o,lifecycle:"onLoad",origin:r});if(!s)throw n;return s}}async preloadRemote(e){const{host:t}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:e,options:t.options,origin:t});const r=rn(t.options.remotes,e);await Promise.all(r.map(async n=>{const{remote:o}=n,s=ke(o),{globalSnapshot:i,remoteSnapshot:a}=await t.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:o}),l=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:t,preloadOptions:n,remote:o,remoteInfo:s,globalSnapshot:i,remoteSnapshot:a});l&&Pt(s,t,l)}))}registerRemotes(e,t){const{host:r}=this;e.forEach(n=>{this.registerRemote(n,r.options.remotes,{force:t==null?void 0:t.force})})}async getRemoteModuleAndOptions(e){const{host:t}=this,{id:r}=e;let n;try{n=await this.hooks.lifecycle.beforeRequest.emit({id:r,options:t.options,origin:t})}catch(d){if(n=await this.hooks.lifecycle.errorLoadRemote.emit({id:r,options:t.options,origin:t,from:"runtime",error:d,lifecycle:"beforeRequest"}),!n)throw d}const{id:o}=n,s=jr(t.options.remotes,o);s||S(St,L,{hostName:t.options.name,requestId:o},void 0,J(t.options));const{remote:i}=s,a=ke(i),l=await t.sharedHandler.hooks.lifecycle.afterResolve.emit({id:o,...s,options:t.options,origin:t,remoteInfo:a}),{remote:c,expose:f}=l;k(c&&f,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${o}.`);let h=t.moduleCache.get(c.name);const u={host:t,remoteInfo:a};return h||(h=new kt(u),t.moduleCache.set(c.name,h)),{module:h,moduleOptions:u,remoteMatchInfo:l}}registerRemote(e,t,r){const{host:n}=this,o=()=>{if(e.alias){const i=t.find(a=>{var l;return e.alias&&(a.name.startsWith(e.alias)||((l=a.alias)==null?void 0:l.startsWith(e.alias)))});k(!i,`The alias ${e.alias} of remote ${e.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in e&&H&&typeof window<"u"&&!e.entry.startsWith("http")&&(e.entry=new URL(e.entry,window.location.origin).href),e.shareScope||(e.shareScope=ne),e.type||(e.type=yt)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:e,origin:n});const s=t.find(i=>i.name===e.name);if(!s)o(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:n});else{const i=[`The remote "${e.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];r!=null&&r.force&&(this.removeRemote(s),o(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:n}),Ze(i.join(" ")))}}removeRemote(e){var t;try{const{host:r}=this,{name:n}=e,o=r.options.remotes.findIndex(i=>i.name===n);o!==-1&&r.options.remotes.splice(o,1);const s=r.moduleCache.get(e.name);if(s){const i=s.remoteInfo,a=i.entryGlobalName;I[a]&&((t=Object.getOwnPropertyDescriptor(I,a))!=null&&t.configurable?delete I[a]:I[a]=void 0);const l=Pe(s.remoteInfo);W[l]&&delete W[l],r.snapshotHandler.manifestCache.delete(i.entry);let c=i.buildVersion?Ye(i.name,i.buildVersion):i.name;const f=I.__FEDERATION__.__INSTANCES__.findIndex(u=>i.buildVersion?u.options.id===c:u.name===c);if(f!==-1){const u=I.__FEDERATION__.__INSTANCES__[f];c=u.options.id||c;const d=Et();let m=!0;const y=[];Object.keys(d).forEach(g=>{const p=d[g];p&&Object.keys(p).forEach(E=>{const b=p[E];b&&Object.keys(b).forEach(N=>{const _=b[N];_&&Object.keys(_).forEach($=>{const R=_[$];R&&typeof R=="object"&&R.from===i.name&&(R.loaded||R.loading?(R.useIn=R.useIn.filter(w=>w!==i.name),R.useIn.length?m=!1:y.push([g,E,N,$])):y.push([g,E,N,$]))})})})}),m&&(u.shareScopeMap={},delete d[c]),y.forEach(([g,p,E,b])=>{var N,_,$;($=(_=(N=d[g])==null?void 0:N[p])==null?void 0:_[E])==null||delete $[b]}),I.__FEDERATION__.__INSTANCES__.splice(f,1)}const{hostGlobalSnapshot:h}=Ct(e,r);if(h){const u=h&&"remotesInfo"in h&&h.remotesInfo&&K(h.remotesInfo,e.name).key;u&&(delete h.remotesInfo[u],ee.__FEDERATION__.__MANIFEST_LOADING__[u]&&delete ee.__FEDERATION__.__MANIFEST_LOADING__[u])}r.moduleCache.delete(e.name)}}catch(r){ve.error(`removeRemote failed: ${r instanceof Error?r.message:String(r)}`)}}};const dn=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0;var mn=class{constructor(e){this.hooks=new q({beforeInit:new j("beforeInit"),init:new A,beforeInitContainer:new F("beforeInitContainer"),initContainer:new F("initContainer")}),this.version="2.2.3",this.moduleCache=new Map,this.loaderHook=new q({getModuleInfo:new A,createScript:new A,createLink:new A,fetch:new P,loadEntryError:new P,getModuleFactory:new P}),this.bridgeHook=new q({beforeBridgeRender:new A,afterBridgeRender:new A,beforeBridgeDestroy:new A,afterBridgeDestroy:new A});const t=dn?[sn(),ln()]:[],r={id:Qr(),name:e.name,plugins:t,remotes:[],shared:{},inBrowser:H};this.name=e.name,this.options=r,this.snapshotHandler=new un(this),this.sharedHandler=new fn(this),this.remoteHandler=new hn(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...r.plugins,...e.plugins||[]]),this.options=this.formatOptions(r,e)}initOptions(e){e.name&&e.name!==this.options.name&&S(it(Nt,L)),this.registerPlugins(e.plugins);const t=this.formatOptions(this.options,e);return this.options=t,t}async loadShare(e,t){return this.sharedHandler.loadShare(e,t)}loadShareSync(e,t){return this.sharedHandler.loadShareSync(e,t)}initializeSharing(e=ne,t){return this.sharedHandler.initializeSharing(e,t)}initRawContainer(e,t,r){const n=ke({name:e,entry:t}),o=new kt({host:this,remoteInfo:n});return o.remoteEntryExports=r,this.moduleCache.set(e,o),o}async loadRemote(e,t){return this.remoteHandler.loadRemote(e,t)}async preloadRemote(e){return this.remoteHandler.preloadRemote(e)}initShareScopeMap(e,t,r={}){this.sharedHandler.initShareScopeMap(e,t,r)}formatOptions(e,t){const{allShareInfos:r}=gt(e,t),{userOptions:n,options:o}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:t,options:e,shareInfo:r}),s=this.remoteHandler.formatAndRegisterRemote(o,n),{allShareInfos:i}=this.sharedHandler.registerShared(o,n),a=[...o.plugins];n.plugins&&n.plugins.forEach(c=>{a.includes(c)||a.push(c)});const l={...e,...t,plugins:a,remotes:s,shared:i};return this.hooks.lifecycle.init.emit({origin:this,options:l}),l}registerPlugins(e){const t=en(e,this);this.options.plugins=this.options.plugins.reduce((r,n)=>(n&&r&&!r.find(o=>o.name===n.name)&&r.push(n),r),t||[])}registerRemotes(e,t){return this.remoteHandler.registerRemotes(e,t)}registerShared(e){this.sharedHandler.registerShared(this.options,{...this.options,shared:e})}};let pn=null;function Dt(){return pn}ar(mn);function Ft(e,t){const r=n=>{const o=n.length>1&&n.endsWith("/"),s=`${t}/${n}`.replace(/\/+/g,"/").replace(/\/$/,"")||"/";return o?`${s}/`:s};return e.map(n=>{const o={...n,path:r(n.path)};return typeof n.redirect=="string"?o.redirect=r(n.redirect):n.redirect&&typeof n.redirect=="object"&&"path"in n.redirect&&typeof n.redirect.path=="string"&&(o.redirect={...n.redirect,path:r(n.redirect.path)}),n.children&&n.children.length>0&&(o.children=Ft(n.children,t)),o})}function yn(e){const{router:t,basename:r,memoryRoute:n,hashRoute:o}=e,s=t.getRoutes().sort((u,d)=>u.path.split("/").filter(m=>m).length-d.path.split("/").filter(m=>m).length),i=new Map,a=new Set;s.forEach(u=>{i.set(u.path,u)});const l=(u,d)=>`${u}/${d}`.replace(/\/+/g,"/").replace(/\/$/,"")||"/",c=(u,d="")=>{if(!u.children||u.children.length===0)return u;for(let m=0;m<u.children.length;m++){const y=u.children[m],g=l(d,y.path),p=i.get(g);if(p&&!a.has(p)){const E={...p,path:y.path};u.children[m]=E,a.add(p),c(E,g)}}return u};let f=[];for(const u of s)if(!a.has(u)){const d=c(u,u.path);a.add(u),f.push(d)}let h;return n?h=ce.createMemoryHistory(r):o?(h=ce.createWebHashHistory(),r&&(f=Ft(f,r))):h=ce.createWebHistory(r),{history:h,routes:f}}function gn(e){const t=new Map,r=Dt();return()=>({__APP_VERSION__:"2.2.3",async render(n){var m,y,g;D.debug("createBridgeComponent render Info",n);const{moduleName:o,dom:s,basename:i,memoryRoute:a,hashRoute:l,...c}=n,f=Gt.createApp(e.rootComponent,c);t.set(s,f);const h=await((g=(y=(m=r==null?void 0:r.bridgeHook)==null?void 0:m.lifecycle)==null?void 0:y.beforeBridgeRender)==null?void 0:g.emit(n)),u=h&&typeof h=="object"&&(h!=null&&h.extraProps)?h==null?void 0:h.extraProps:{},d=e.appOptions({app:f,basename:i,memoryRoute:a,hashRoute:l,...c,...u});if(d!=null&&d.router){const{history:p,routes:E}=yn({router:d.router,basename:n.basename,memoryRoute:n.memoryRoute,hashRoute:n.hashRoute}),b=ce.createRouter({...d.router.options,history:p,routes:E});D.debug("createBridgeComponent render router info>>>",{moduleName:o,router:b}),a&&await b.push(a.entryPath),f.use(b)}f.mount(s)},destroy(n){D.debug("createBridgeComponent destroy Info",n);const o=t.get(n==null?void 0:n.dom);o==null||o.unmount()}})}function En(){const e=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(e)}const _n=v.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,hashRoute:Boolean,providerInfo:Function,rootAttrs:Object},inheritAttrs:!1,setup(e){const t=v.ref(null),r=v.ref(null),n=v.ref(""),o=Oe.useRoute(),s=Dt(),i=v.useAttrs(),a=async()=>{var u,d,m,y;const c=(u=e.providerInfo)==null?void 0:u.call(e);r.value=c;let f={...i,moduleName:e.moduleName,dom:t.value,basename:e.basename,memoryRoute:e.memoryRoute,hashRoute:e.hashRoute};D.debug("createRemoteAppComponent LazyComponent render >>>",f);const h=await((y=(m=(d=s==null?void 0:s.bridgeHook)==null?void 0:d.lifecycle)==null?void 0:m.beforeBridgeRender)==null?void 0:y.emit(f))||{};f={...f,...h.extraProps},c.render(f)},l=v.watch(()=>o==null?void 0:o.path,c=>{c!==o.path&&a(),n.value!==""&&n.value!==c&&(D.debug("createRemoteAppComponent dispatchPopstateEnv >>>",{...e,pathname:o.path}),En()),n.value=c});return v.onMounted(()=>{a()}),v.onBeforeUnmount(()=>{var c;D.debug("createRemoteAppComponent LazyComponent destroy >>>",{...e}),l(),(c=r.value)==null||c.destroy({dom:t.value})}),()=>v.createVNode("div",v.mergeProps(e.rootAttrs||{},{ref:t}),null)}});function Ht(e){return v.defineAsyncComponent({__APP_VERSION__:"2.2.3",...e.asyncComponentOptions,loader:async()=>{var l,c;const t=Oe.useRoute();let r="/";const n=(c=(l=t==null?void 0:t.matched)==null?void 0:l[0])==null?void 0:c.path;n&&(n.endsWith("/:pathMatch(.*)*")?r=n.replace("/:pathMatch(.*)*",""):r=t.matched[0].path);const o=(e==null?void 0:e.export)||"default";D.debug("createRemoteAppComponent LazyComponent create >>>",{basename:r,info:e});const s=await e.loader(),i=s&&s[Symbol.for("mf_module_id")],a=s[o];if(D.debug("createRemoteAppComponent LazyComponent loadRemote info >>>",{moduleName:i,module:s,exportName:o,basename:r,route:t}),o in s&&typeof a=="function")return{render(){return v.h(_n,{moduleName:i,providerInfo:a,basename:r,rootAttrs:e.rootAttrs,memoryRoute:e.memoryRoute,hashRoute:e.hashRoute})}};throw new Error("module not found")}})}function bn(e){return D.warn("createRemoteComponent is deprecated, please use createRemoteAppComponent instead!"),Ht(e)}exports.createBridgeComponent=gn;exports.createRemoteAppComponent=Ht;exports.createRemoteComponent=bn;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,10 +23,14 @@ export declare function createRemoteAppComponent(info: {
|
|
|
23
23
|
export?: string;
|
|
24
24
|
asyncComponentOptions?: Omit<AsyncComponentOptions, 'loader'>;
|
|
25
25
|
rootAttrs?: Record<string, unknown>;
|
|
26
|
+
memoryRoute?: {
|
|
27
|
+
entryPath: string;
|
|
28
|
+
};
|
|
29
|
+
hashRoute?: boolean;
|
|
26
30
|
}): new () => ComponentPublicInstance;
|
|
27
31
|
|
|
28
32
|
/**
|
|
29
|
-
* @deprecated
|
|
33
|
+
* @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
|
|
30
34
|
*/
|
|
31
35
|
export declare function createRemoteComponent(info: {
|
|
32
36
|
loader: () => Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -536,7 +536,7 @@ function lt(e) {
|
|
|
536
536
|
lt(I);
|
|
537
537
|
lt(k);
|
|
538
538
|
function mr(e, t = we()) {
|
|
539
|
-
t && (I.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = e, I.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.2.
|
|
539
|
+
t && (I.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = e, I.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.2.3");
|
|
540
540
|
}
|
|
541
541
|
function q(e, t) {
|
|
542
542
|
if (typeof t == "string") {
|
|
@@ -2273,7 +2273,7 @@ var Rn = class {
|
|
|
2273
2273
|
init: new v(),
|
|
2274
2274
|
beforeInitContainer: new D("beforeInitContainer"),
|
|
2275
2275
|
initContainer: new D("initContainer")
|
|
2276
|
-
}), this.version = "2.2.
|
|
2276
|
+
}), this.version = "2.2.3", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new j({
|
|
2277
2277
|
getModuleInfo: new v(),
|
|
2278
2278
|
createScript: new v(),
|
|
2279
2279
|
createLink: new v(),
|
|
@@ -2371,15 +2371,22 @@ function Ct() {
|
|
|
2371
2371
|
}
|
|
2372
2372
|
mr(Rn);
|
|
2373
2373
|
function Dt(e, t) {
|
|
2374
|
-
|
|
2375
|
-
const n = {
|
|
2376
|
-
|
|
2377
|
-
|
|
2374
|
+
const r = (n) => {
|
|
2375
|
+
const o = n.length > 1 && n.endsWith("/"), s = `${t}/${n}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/";
|
|
2376
|
+
return o ? `${s}/` : s;
|
|
2377
|
+
};
|
|
2378
|
+
return e.map((n) => {
|
|
2379
|
+
const o = {
|
|
2380
|
+
...n,
|
|
2381
|
+
path: r(n.path)
|
|
2378
2382
|
};
|
|
2379
|
-
return r.
|
|
2380
|
-
|
|
2383
|
+
return typeof n.redirect == "string" ? o.redirect = r(n.redirect) : n.redirect && typeof n.redirect == "object" && "path" in n.redirect && typeof n.redirect.path == "string" && (o.redirect = {
|
|
2384
|
+
...n.redirect,
|
|
2385
|
+
path: r(n.redirect.path)
|
|
2386
|
+
}), n.children && n.children.length > 0 && (o.children = Dt(
|
|
2387
|
+
n.children,
|
|
2381
2388
|
t
|
|
2382
|
-
)),
|
|
2389
|
+
)), o;
|
|
2383
2390
|
});
|
|
2384
2391
|
}
|
|
2385
2392
|
function $n(e) {
|
|
@@ -2420,7 +2427,7 @@ function $n(e) {
|
|
|
2420
2427
|
function An(e) {
|
|
2421
2428
|
const t = /* @__PURE__ */ new Map(), r = Ct();
|
|
2422
2429
|
return () => ({
|
|
2423
|
-
__APP_VERSION__: "2.2.
|
|
2430
|
+
__APP_VERSION__: "2.2.3",
|
|
2424
2431
|
async render(n) {
|
|
2425
2432
|
var m, y, E;
|
|
2426
2433
|
C.debug("createBridgeComponent render Info", n);
|
|
@@ -2522,7 +2529,7 @@ const Nn = /* @__PURE__ */ Ht({
|
|
|
2522
2529
|
});
|
|
2523
2530
|
function In(e) {
|
|
2524
2531
|
return jt({
|
|
2525
|
-
__APP_VERSION__: "2.2.
|
|
2532
|
+
__APP_VERSION__: "2.2.3",
|
|
2526
2533
|
...e.asyncComponentOptions,
|
|
2527
2534
|
//@ts-ignore
|
|
2528
2535
|
loader: async () => {
|
|
@@ -2550,7 +2557,9 @@ function In(e) {
|
|
|
2550
2557
|
moduleName: i,
|
|
2551
2558
|
providerInfo: a,
|
|
2552
2559
|
basename: r,
|
|
2553
|
-
rootAttrs: e.rootAttrs
|
|
2560
|
+
rootAttrs: e.rootAttrs,
|
|
2561
|
+
memoryRoute: e.memoryRoute,
|
|
2562
|
+
hashRoute: e.hashRoute
|
|
2554
2563
|
});
|
|
2555
2564
|
}
|
|
2556
2565
|
};
|
|
@@ -2560,7 +2569,7 @@ function In(e) {
|
|
|
2560
2569
|
}
|
|
2561
2570
|
function Pn(e) {
|
|
2562
2571
|
return C.warn(
|
|
2563
|
-
"
|
|
2572
|
+
"createRemoteComponent is deprecated, please use createRemoteAppComponent instead!"
|
|
2564
2573
|
), In(e);
|
|
2565
2574
|
}
|
|
2566
2575
|
export {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "git+https://github.com/module-federation/core.git",
|
|
8
8
|
"directory": "packages/bridge/vue3-bridge"
|
|
9
9
|
},
|
|
10
|
-
"version": "2.2.
|
|
10
|
+
"version": "2.2.3",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"vue-router": "=4"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@module-federation/
|
|
35
|
-
"@module-federation/
|
|
36
|
-
"@module-federation/runtime": "2.2.
|
|
34
|
+
"@module-federation/bridge-shared": "2.2.3",
|
|
35
|
+
"@module-federation/sdk": "2.2.3",
|
|
36
|
+
"@module-federation/runtime": "2.2.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/react": "^18.3.11",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"@vitejs/plugin-vue-jsx": "^4.0.0",
|
|
42
42
|
"typescript": "^5.2.2",
|
|
43
43
|
"vite": "^5.4.21",
|
|
44
|
-
"vite-plugin-dts": "^4.
|
|
45
|
-
"vue": "^3.
|
|
44
|
+
"vite-plugin-dts": "^4.5.4",
|
|
45
|
+
"vue": "^3.5.30",
|
|
46
46
|
"vue-router": "4.4.5",
|
|
47
|
-
"vue-tsc": "^2.
|
|
47
|
+
"vue-tsc": "^2.2.12"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"dev": "vite",
|
package/src/create.ts
CHANGED
|
@@ -10,6 +10,8 @@ export function createRemoteAppComponent(info: {
|
|
|
10
10
|
export?: string;
|
|
11
11
|
asyncComponentOptions?: Omit<AsyncComponentOptions, 'loader'>;
|
|
12
12
|
rootAttrs?: Record<string, unknown>;
|
|
13
|
+
memoryRoute?: { entryPath: string };
|
|
14
|
+
hashRoute?: boolean;
|
|
13
15
|
}) {
|
|
14
16
|
return defineAsyncComponent({
|
|
15
17
|
__APP_VERSION__,
|
|
@@ -54,6 +56,8 @@ export function createRemoteAppComponent(info: {
|
|
|
54
56
|
providerInfo: exportFn,
|
|
55
57
|
basename,
|
|
56
58
|
rootAttrs: info.rootAttrs,
|
|
59
|
+
memoryRoute: info.memoryRoute,
|
|
60
|
+
hashRoute: info.hashRoute,
|
|
57
61
|
});
|
|
58
62
|
},
|
|
59
63
|
};
|
|
@@ -64,7 +68,7 @@ export function createRemoteAppComponent(info: {
|
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
|
-
* @deprecated
|
|
71
|
+
* @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
|
|
68
72
|
*/
|
|
69
73
|
export function createRemoteComponent(info: {
|
|
70
74
|
loader: () => Promise<any>;
|
|
@@ -73,7 +77,7 @@ export function createRemoteComponent(info: {
|
|
|
73
77
|
rootAttrs?: Record<string, unknown>;
|
|
74
78
|
}) {
|
|
75
79
|
LoggerInstance.warn(
|
|
76
|
-
'
|
|
80
|
+
'createRemoteComponent is deprecated, please use createRemoteAppComponent instead!',
|
|
77
81
|
);
|
|
78
82
|
return createRemoteAppComponent(info);
|
|
79
83
|
}
|
package/src/routeUtils.ts
CHANGED
|
@@ -23,12 +23,39 @@ function addBasenameToNestedRoutes(
|
|
|
23
23
|
routes: VueRouter.RouteRecordNormalized[],
|
|
24
24
|
basename: string,
|
|
25
25
|
): VueRouter.RouteRecordNormalized[] {
|
|
26
|
+
/**
|
|
27
|
+
* Join two path segments, collapse multiple slashes, and optionally
|
|
28
|
+
* preserve a trailing slash that was present in the original value.
|
|
29
|
+
* A bare '/' root is never considered an intentional trailing slash.
|
|
30
|
+
*/
|
|
31
|
+
const prefixPath = (original: string): string => {
|
|
32
|
+
const hasTrailingSlash = original.length > 1 && original.endsWith('/');
|
|
33
|
+
const normalized =
|
|
34
|
+
`${basename}/${original}`.replace(/\/+/g, '/').replace(/\/$/, '') || '/';
|
|
35
|
+
return hasTrailingSlash ? `${normalized}/` : normalized;
|
|
36
|
+
};
|
|
37
|
+
|
|
26
38
|
return routes.map((route) => {
|
|
27
39
|
const updatedRoute: VueRouter.RouteRecordNormalized = {
|
|
28
40
|
...route,
|
|
29
|
-
path:
|
|
41
|
+
path: prefixPath(route.path),
|
|
30
42
|
};
|
|
31
43
|
|
|
44
|
+
// Prefix string redirects with basename
|
|
45
|
+
if (typeof route.redirect === 'string') {
|
|
46
|
+
updatedRoute.redirect = prefixPath(route.redirect);
|
|
47
|
+
} else if (
|
|
48
|
+
route.redirect &&
|
|
49
|
+
typeof route.redirect === 'object' &&
|
|
50
|
+
'path' in route.redirect &&
|
|
51
|
+
typeof route.redirect.path === 'string'
|
|
52
|
+
) {
|
|
53
|
+
updatedRoute.redirect = {
|
|
54
|
+
...route.redirect,
|
|
55
|
+
path: prefixPath(route.redirect.path),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
32
59
|
// Recursively process child routes
|
|
33
60
|
if (route.children && route.children.length > 0) {
|
|
34
61
|
updatedRoute.children = addBasenameToNestedRoutes(
|