@empjs/share 3.11.3 → 3.11.5
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/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.cjs.map +1 -1
- package/dist/rspack.d.cts +27 -1
- package/dist/rspack.d.ts +27 -1
- package/dist/rspack.js.map +1 -1
- package/output/sdk.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var M=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},P=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of E(e))!S.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=x(e,n))||r.enumerable});return i};var v=i=>P(u({},"__esModule",{value:!0}),i);var w={};M(w,{default:()=>
|
|
2
|
-
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=O("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function g(i,e,t="runtime"){return typeof i=="string"?t==="runtime"?`${i}/runtime${e==="development"?".development":""}.umd.js`:`${i}/${t}.${e}.umd.js`:typeof i=="object"?e==="development"?i.dev:i.prod:""}var j=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=g(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let o={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(o.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(o)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=f(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||y,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:n}=r,o=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},s={};for(let[a,m]of Object.entries(o))s[a]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!n&&this.fk.global){let a=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,R]of Object.entries(m))s[p]=`${this.fk.global}.${R}`;[17,18,19].includes(a)&&(s["react-dom/client"]=this.fk.global,s["react/jsx-runtime"]=this.fk.global,s["react/jsx-dev-runtime"]=this.fk.global)}n&&t.map(a=>{a.type==="js"&&a.module&&a.global&&(s[a.module]=`${this.fk.global}.${a.global}`)}),r.setExternals&&r.setExternals(s,this.fk.global,this.rt.global),e.chain.merge({externals:s})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:n}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[n])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(h.ModuleFederationPlugin,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[n,o]of Object.entries(e)){let s={};if(s.module=n,typeof o=="string"){let a=o.match(j)||[];a.length>0?(s.global=a[1],s.entry=a[2],s.type="js",t.push(s),s={}):(s.global="",s.entry=o,s.type="js",t.push(s),s={})}else Array.isArray(o)?o.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))s.entry=a,s.type="css";else{let p=a.match(j)||[];p.length>0?(s.global=p[1],s.entry=p[2],s.type="js"):(s.global="",s.entry=a,s.type="js")}t.push(s),s={}}):typeof o=="object"&&o.entry&&(s.entry=o.entry,s.global=o.global,s.type=o.type,t.push(s),s={})}t.map(n=>{n.type==="js"?r.push({attributes:{src:n.entry},tagName:"script"}):n.type==="css"&&r.push({attributes:{href:n.entry,rel:"stylesheet"},tagName:"link"})})}}};var H=(i,e)=>(i=Object.assign(i,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),i);var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var M=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},P=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of E(e))!S.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=x(e,n))||r.enumerable});return i};var v=i=>P(u({},"__esModule",{value:!0}),i);var w={};M(w,{default:()=>N,externalReact:()=>H,externalVue:()=>T,pluginRspackEmpShare:()=>d});module.exports=v(w);var b=i=>`data:text/javascript,${i}`;function f(i,...e){for(let t of e)for(let r in t){let n=t[r],o=i[r];if(Object(n)==n&&Object(o)===o){i[r]=f(o,n);continue}i[r]=t[r]}return i}var L=!1,G=L?console.log.bind(console,"[EMP Share]"):()=>{};var y="EMP_SHARE_RUNTIME";var h=require("@module-federation/rspack");var O=i=>{let e=[`import '${i}'`].join(`
|
|
2
|
+
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=O("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function g(i,e,t="runtime"){return typeof i=="string"?t==="runtime"?`${i}/runtime${e==="development"?".development":""}.umd.js`:`${i}/${t}.${e}.umd.js`:typeof i=="object"?e==="development"?i.dev:i.prod:""}var j=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=g(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let o={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(o.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(o)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=f(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||y,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:n}=r,o=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},s={};for(let[a,m]of Object.entries(o))s[a]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!n&&this.fk.global){let a=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,R]of Object.entries(m))s[p]=`${this.fk.global}.${R}`;[17,18,19].includes(a)&&(s["react-dom/client"]=this.fk.global,s["react/jsx-runtime"]=this.fk.global,s["react/jsx-dev-runtime"]=this.fk.global)}n&&t.map(a=>{a.type==="js"&&a.module&&a.global&&(s[a.module]=`${this.fk.global}.${a.global}`)}),r.setExternals&&r.setExternals(s,this.fk.global,this.rt.global),e.chain.merge({externals:s})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:n}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[n])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(h.ModuleFederationPlugin,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[n,o]of Object.entries(e)){let s={};if(s.module=n,typeof o=="string"){let a=o.match(j)||[];a.length>0?(s.global=a[1],s.entry=a[2],s.type="js",t.push(s),s={}):(s.global="",s.entry=o,s.type="js",t.push(s),s={})}else Array.isArray(o)?o.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))s.entry=a,s.type="css";else{let p=a.match(j)||[];p.length>0?(s.global=p[1],s.entry=p[2],s.type="js"):(s.global="",s.entry=a,s.type="js")}t.push(s),s={}}):typeof o=="object"&&o.entry&&(s.entry=o.entry,s.global=o.global,s.type=o.type,t.push(s),s={})}t.map(n=>{n.type==="js"?r.push({attributes:{src:n.entry},tagName:"script"}):n.type==="css"&&r.push({attributes:{href:n.entry,rel:"stylesheet"},tagName:"link"})})}}};var H=(i,e)=>(i=Object.assign(i,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),i);var T=(i,e)=>(i=Object.assign(i,{vue:`${e}.Vue`,"vue-router":`${e}.VueRouter`}),i);var d=(i={})=>({name:"@empjs/share",async rsConfig(e){i.manifest===!0?i.manifest={fileName:"emp.json"}:typeof i.manifest=="object"&&(i.manifest=e.deepAssign({fileName:"emp.json"},i.manifest)),new c(i,e).setup()}}),k=d;var N=k;0&&(module.exports={externalReact,externalVue,pluginRspackEmpShare});
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts"],"sourcesContent":["import {default as pluginRspackEmpShare} from 'src/plugins/rspack'\nexport default pluginRspackEmpShare\nexport * from 'src/plugins/rspack'\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/rspack'\n","import {Compiler} from '@empjs/cli'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC,CAAE,GAAKA,GAAM,OAAOC,CAAE,IAAMA,EAAI,CACzCL,EAAOG,CAAC,EAAIJ,EAAWM,EAAID,CAAE,EAC7B,QACF,CACAJ,EAAOG,CAAC,EAAID,EAAOC,CAAC,CACtB,CAEF,OAAOH,CACT,CAMO,IAAMM,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECtBtE,IAAME,EAAkB,oBCA/B,IAAAC,EAAqC,qCCIrC,IAAMC,EAAuBC,GAAO,CAClC,IAAMC,EAAU,CAAC,WAAWD,CAAG,GAAG,EAAE,KAAK;AAAA,CAAI,EAC7C,OAAOE,EAAWD,CAAO,CAC3B,EAEaE,EAAN,KAA8B,CACnC,QACA,YAAYC,EAA4B,CACtC,KAAK,QAAUA,CACjB,CACA,MAAMC,EAAoB,CACxB,GAAM,CAAC,QAAAC,CAAO,EAAID,EACZE,EAAQR,EAAqB,sBAAsB,EACzD,IAAIO,EAAQ,YAAYD,EAAS,QAASE,EAA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/BA,EAAgB,CAAC,EAErB,CAEAZ,EAAa,IAAIQ,GAAK,CAChBA,EAAE,OAAS,KACbrB,EAAW,KAAK,CACd,WAAY,CACV,IAAKqB,EAAE,KACT,EACA,QAAS,QACX,CAAC,EACQA,EAAE,OAAS,OACpBrB,EAAW,KAAK,CACd,WAAY,CACV,KAAMqB,EAAE,MACR,IAAK,YACP,EACA,QAAS,MACX,CAAC,CAEL,CAAC,CACH,CACF,CACF,ECxTO,IAAMO,EAAgB,CAACC,EAAQC,KACpCD,EAAI,OAAO,OAAOA,EAAG,CACnB,MAAO,GAAGC,CAAS,SACnB,YAAa,GAAGA,CAAS,YACzB,mBAAoBA,EACpB,oBAAqBA,EACrB,wBAAyBA,EACzB,mBAAoB,GAAGA,CAAS,iBAClC,CAAC,EACMD,GCTF,IAAME,EAAc,CAACC,EAAQC,KAClCD,EAAI,OAAO,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GCGF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ,ETxBf,IAAOK,EAAQC","names":["src_exports","__export","src_default","externalReact","externalVue","pluginRspackEmpShare","__toCommonJS","importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","import_rspack","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default","src_default","rspack_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts"],"sourcesContent":["import {default as pluginRspackEmpShare} from 'src/plugins/rspack'\nexport default pluginRspackEmpShare\nexport * from 'src/plugins/rspack'\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/rspack'\n","import {Compiler} from '@empjs/cli'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\nexport type {EMPPluginShareType}\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\nexport * from './types'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAA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AAc,CAACC,EAAQC,KAClCD,EAAI,OAAO,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GCIF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ,ETzBf,IAAOK,EAAQC","names":["src_exports","__export","src_default","externalReact","externalVue","pluginRspackEmpShare","__toCommonJS","importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","import_rspack","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default","src_default","rspack_default"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pluginRspackEmpShare from './rspack.cjs';
|
|
2
|
-
export { externalReact, externalVue } from './rspack.cjs';
|
|
2
|
+
export { EMPPluginShareType, EMPSHARERuntimeOptions, ExternalsItemType, ModuleFederationPluginOptions, externalReact, externalVue, frameworLibType, frameworkOptions, runtimeLibType } from './rspack.cjs';
|
|
3
3
|
import '@empjs/cli';
|
|
4
4
|
import '@module-federation/rspack';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pluginRspackEmpShare from './rspack.js';
|
|
2
|
-
export { externalReact, externalVue } from './rspack.js';
|
|
2
|
+
export { EMPPluginShareType, EMPSHARERuntimeOptions, ExternalsItemType, ModuleFederationPluginOptions, externalReact, externalVue, frameworLibType, frameworkOptions, runtimeLibType } from './rspack.js';
|
|
3
3
|
import '@empjs/cli';
|
|
4
4
|
import '@module-federation/rspack';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
var f=s=>`data:text/javascript,${s}`;function u(s,...e){for(let t of e)for(let r in t){let a=t[r],n=s[r];if(Object(a)==a&&Object(n)===n){s[r]=u(n,a);continue}s[r]=t[r]}return s}var k=!1,E=k?console.log.bind(console,"[EMP Share]"):()=>{};var h="EMP_SHARE_RUNTIME";import{ModuleFederationPlugin as b}from"@module-federation/rspack";var R=s=>{let e=[`import '${s}'`].join(`
|
|
2
|
-
`);return f(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=R("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function y(s,e,t="runtime"){return typeof s=="string"?t==="runtime"?`${s}/runtime${e==="development"?".development":""}.umd.js`:`${s}/${t}.${e}.umd.js`:typeof s=="object"?e==="development"?s.dev:s.prod:""}var g=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=y(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let n={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(n.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(n)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=u(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||h,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:a}=r,n=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},i={};for(let[o,m]of Object.entries(n))i[o]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!a&&this.fk.global){let o=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,d]of Object.entries(m))i[p]=`${this.fk.global}.${d}`;[17,18,19].includes(o)&&(i["react-dom/client"]=this.fk.global,i["react/jsx-runtime"]=this.fk.global,i["react/jsx-dev-runtime"]=this.fk.global)}a&&t.map(o=>{o.type==="js"&&o.module&&o.global&&(i[o.module]=`${this.fk.global}.${o.global}`)}),r.setExternals&&r.setExternals(i,this.fk.global,this.rt.global),e.chain.merge({externals:i})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:a}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[a])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(b,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[a,n]of Object.entries(e)){let i={};if(i.module=a,typeof n=="string"){let o=n.match(g)||[];o.length>0?(i.global=o[1],i.entry=o[2],i.type="js",t.push(i),i={}):(i.global="",i.entry=n,i.type="js",t.push(i),i={})}else Array.isArray(n)?n.map(o=>{if(!o)return;if(o.split("?")[0].endsWith(".css"))i.entry=o,i.type="css";else{let p=o.match(g)||[];p.length>0?(i.global=p[1],i.entry=p[2],i.type="js"):(i.global="",i.entry=o,i.type="js")}t.push(i),i={}}):typeof n=="object"&&n.entry&&(i.entry=n.entry,i.global=n.global,i.type=n.type,t.push(i),i={})}t.map(a=>{a.type==="js"?r.push({attributes:{src:a.entry},tagName:"script"}):a.type==="css"&&r.push({attributes:{href:a.entry,rel:"stylesheet"},tagName:"link"})})}}};var A=(s,e)=>(s=Object.assign(s,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),s);var V=(s,e)=>(s=Object.assign(s,{vue:`${e}.Vue`,"vue-router":`${e}.VueRouter`}),s);var x=(s={})=>({name:"@empjs/share",async rsConfig(e){s.manifest===!0?s.manifest={fileName:"emp.json"}:typeof s.manifest=="object"&&(s.manifest=e.deepAssign({fileName:"emp.json"},s.manifest)),new c(s,e).setup()}}),j=x;var
|
|
2
|
+
`);return f(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=R("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function y(s,e,t="runtime"){return typeof s=="string"?t==="runtime"?`${s}/runtime${e==="development"?".development":""}.umd.js`:`${s}/${t}.${e}.umd.js`:typeof s=="object"?e==="development"?s.dev:s.prod:""}var g=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=y(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let n={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(n.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(n)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=u(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||h,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:a}=r,n=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},i={};for(let[o,m]of Object.entries(n))i[o]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!a&&this.fk.global){let o=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,d]of Object.entries(m))i[p]=`${this.fk.global}.${d}`;[17,18,19].includes(o)&&(i["react-dom/client"]=this.fk.global,i["react/jsx-runtime"]=this.fk.global,i["react/jsx-dev-runtime"]=this.fk.global)}a&&t.map(o=>{o.type==="js"&&o.module&&o.global&&(i[o.module]=`${this.fk.global}.${o.global}`)}),r.setExternals&&r.setExternals(i,this.fk.global,this.rt.global),e.chain.merge({externals:i})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:a}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[a])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(b,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[a,n]of Object.entries(e)){let i={};if(i.module=a,typeof n=="string"){let o=n.match(g)||[];o.length>0?(i.global=o[1],i.entry=o[2],i.type="js",t.push(i),i={}):(i.global="",i.entry=n,i.type="js",t.push(i),i={})}else Array.isArray(n)?n.map(o=>{if(!o)return;if(o.split("?")[0].endsWith(".css"))i.entry=o,i.type="css";else{let p=o.match(g)||[];p.length>0?(i.global=p[1],i.entry=p[2],i.type="js"):(i.global="",i.entry=o,i.type="js")}t.push(i),i={}}):typeof n=="object"&&n.entry&&(i.entry=n.entry,i.global=n.global,i.type=n.type,t.push(i),i={})}t.map(a=>{a.type==="js"?r.push({attributes:{src:a.entry},tagName:"script"}):a.type==="css"&&r.push({attributes:{href:a.entry,rel:"stylesheet"},tagName:"link"})})}}};var A=(s,e)=>(s=Object.assign(s,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),s);var V=(s,e)=>(s=Object.assign(s,{vue:`${e}.Vue`,"vue-router":`${e}.VueRouter`}),s);var x=(s={})=>({name:"@empjs/share",async rsConfig(e){s.manifest===!0?s.manifest={fileName:"emp.json"}:typeof s.manifest=="object"&&(s.manifest=e.deepAssign({fileName:"emp.json"},s.manifest)),new c(s,e).setup()}}),j=x;var K=j;export{K as default,A as externalReact,V as externalVue,x as pluginRspackEmpShare};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts","../src/index.ts"],"sourcesContent":["export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/rspack'\n","import {Compiler} from '@empjs/cli'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n","import {default as pluginRspackEmpShare} from 'src/plugins/rspack'\nexport default pluginRspackEmpShare\nexport * from 'src/plugins/rspack'\n"],"mappings":"AAAO,IAAMA,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC,CAAE,GAAKA,GAAM,OAAOC,CAAE,IAAMA,EAAI,CACzCL,EAAOG,CAAC,EAAIJ,EAAWM,EAAID,CAAE,EAC7B,Q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AASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ,ECxBf,IAAOK,EAAQC","names":["importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","ModuleFederationPlugin","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","ModuleFederationPlugin","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default","src_default","rspack_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts","../src/index.ts"],"sourcesContent":["export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/rspack'\n","import {Compiler} from '@empjs/cli'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\nexport type {EMPPluginShareType}\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\nexport * from './types'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n","import {default as pluginRspackEmpShare} from 'src/plugins/rspack'\nexport default pluginRspackEmpShare\nexport * from 'src/plugins/rspack'\n"],"mappings":"AAAO,IAAMA,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC,CAAE,GAAKA,GAAM,OAAOC,CAAE,IAAMA,EAAI,CACzCL,EAAOG,CAAC,EAAIJ,EAAWM,EAAID,CAAE,EAC7B,QACF,CACAJ,EAAOG,CAAC,EAAID,EAAOC,CAAC,CACtB,CAEF,OAAOH,CACT,CAMO,IAAMM,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECtBtE,IAAME,EAAkB,oBCA/B,OAAQ,0BAAAC,MAA6B,4BCIrC,IAAMC,EAAuBC,GAAO,CAClC,IAAMC,EAAU,CAAC,WAAWD,CAAG,GAAG,EAAE,KAAK;AAAA,CAAI,EAC7C,OAAOE,EAAWD,CAAO,CAC3B,EAEaE,EAAN,KAA8B,CACnC,QACA,YAAYC,EAA4B,CACtC,KAAK,QAAUA,CACjB,CACA,MAAMC,EAAoB,CACxB,GAAM,CAAC,QAAAC,CAAO,EAAID,EACZE,EAAQR,EAAqB,sBAAsB,EACzD,IAAIO,EAAQ,YAAYD,EAAS,QAASE,EAAO,CAC/C,KAAM,MACR,CAAC,EAAE,MAAMF,CAAQ,CACnB,CACF,ECpBO,SAASG,EAAcC,EAA8CC,EAAcC,EAAQ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V,IAAKqB,EAAE,KACT,EACA,QAAS,QACX,CAAC,EACQA,EAAE,OAAS,OACpBrB,EAAW,KAAK,CACd,WAAY,CACV,KAAMqB,EAAE,MACR,IAAK,YACP,EACA,QAAS,MACX,CAAC,CAEL,CAAC,CACH,CACF,CACF,ECxTO,IAAMQ,EAAgB,CAACC,EAAQC,KACpCD,EAAI,OAAO,OAAOA,EAAG,CACnB,MAAO,GAAGC,CAAS,SACnB,YAAa,GAAGA,CAAS,YACzB,mBAAoBA,EACpB,oBAAqBA,EACrB,wBAAyBA,EACzB,mBAAoB,GAAGA,CAAS,iBAClC,CAAC,EACMD,GCTF,IAAME,EAAc,CAACC,EAAQC,KAClCD,EAAI,OAAO,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GCIF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ,ECzBf,IAAOK,EAAQC","names":["importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","ModuleFederationPlugin","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","ModuleFederationPlugin","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default","src_default","rspack_default"]}
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var S=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},M=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of x(e))!E.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=R(e,n))||r.enumerable});return i};var P=i=>M(u({},"__esModule",{value:!0}),i);var
|
|
2
|
-
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=L("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function g(i,e,t="runtime"){return typeof i=="string"?t==="runtime"?`${i}/runtime${e==="development"?".development":""}.umd.js`:`${i}/${t}.${e}.umd.js`:typeof i=="object"?e==="development"?i.dev:i.prod:""}var j=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=g(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let o={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(o.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(o)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=f(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||y,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:n}=r,o=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},s={};for(let[a,m]of Object.entries(o))s[a]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!n&&this.fk.global){let a=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,k]of Object.entries(m))s[p]=`${this.fk.global}.${k}`;[17,18,19].includes(a)&&(s["react-dom/client"]=this.fk.global,s["react/jsx-runtime"]=this.fk.global,s["react/jsx-dev-runtime"]=this.fk.global)}n&&t.map(a=>{a.type==="js"&&a.module&&a.global&&(s[a.module]=`${this.fk.global}.${a.global}`)}),r.setExternals&&r.setExternals(s,this.fk.global,this.rt.global),e.chain.merge({externals:s})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:n}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[n])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(h.ModuleFederationPlugin,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[n,o]of Object.entries(e)){let s={};if(s.module=n,typeof o=="string"){let a=o.match(j)||[];a.length>0?(s.global=a[1],s.entry=a[2],s.type="js",t.push(s),s={}):(s.global="",s.entry=o,s.type="js",t.push(s),s={})}else Array.isArray(o)?o.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))s.entry=a,s.type="css";else{let p=a.match(j)||[];p.length>0?(s.global=p[1],s.entry=p[2],s.type="js"):(s.global="",s.entry=a,s.type="js")}t.push(s),s={}}):typeof o=="object"&&o.entry&&(s.entry=o.entry,s.global=o.global,s.type=o.type,t.push(s),s={})}t.map(n=>{n.type==="js"?r.push({attributes:{src:n.entry},tagName:"script"}):n.type==="css"&&r.push({attributes:{href:n.entry,rel:"stylesheet"},tagName:"link"})})}}};var O=(i,e)=>(i=Object.assign(i,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),i);var H=(i,e)=>(i=Object.assign(i,{vue:`${e}.Vue`,"vue-router":`${e}.VueRouter`}),i);var d=(i={})=>({name:"@empjs/share",async rsConfig(e){i.manifest===!0?i.manifest={fileName:"emp.json"}:typeof i.manifest=="object"&&(i.manifest=e.deepAssign({fileName:"emp.json"},i.manifest)),new c(i,e).setup()}}),
|
|
1
|
+
"use strict";var u=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var S=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},M=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of x(e))!E.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=R(e,n))||r.enumerable});return i};var P=i=>M(u({},"__esModule",{value:!0}),i);var N={};S(N,{default:()=>T,externalReact:()=>O,externalVue:()=>H,pluginRspackEmpShare:()=>d});module.exports=P(N);var b=i=>`data:text/javascript,${i}`;function f(i,...e){for(let t of e)for(let r in t){let n=t[r],o=i[r];if(Object(n)==n&&Object(o)===o){i[r]=f(o,n);continue}i[r]=t[r]}return i}var v=!1,$=v?console.log.bind(console,"[EMP Share]"):()=>{};var y="EMP_SHARE_RUNTIME";var h=require("@module-federation/rspack");var L=i=>{let e=[`import '${i}'`].join(`
|
|
2
|
+
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=L("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function g(i,e,t="runtime"){return typeof i=="string"?t==="runtime"?`${i}/runtime${e==="development"?".development":""}.umd.js`:`${i}/${t}.${e}.umd.js`:typeof i=="object"?e==="development"?i.dev:i.prod:""}var j=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=g(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let o={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(o.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(o)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=f(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||y,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:n}=r,o=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},s={};for(let[a,m]of Object.entries(o))s[a]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!n&&this.fk.global){let a=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,k]of Object.entries(m))s[p]=`${this.fk.global}.${k}`;[17,18,19].includes(a)&&(s["react-dom/client"]=this.fk.global,s["react/jsx-runtime"]=this.fk.global,s["react/jsx-dev-runtime"]=this.fk.global)}n&&t.map(a=>{a.type==="js"&&a.module&&a.global&&(s[a.module]=`${this.fk.global}.${a.global}`)}),r.setExternals&&r.setExternals(s,this.fk.global,this.rt.global),e.chain.merge({externals:s})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:n}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[n])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(h.ModuleFederationPlugin,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[n,o]of Object.entries(e)){let s={};if(s.module=n,typeof o=="string"){let a=o.match(j)||[];a.length>0?(s.global=a[1],s.entry=a[2],s.type="js",t.push(s),s={}):(s.global="",s.entry=o,s.type="js",t.push(s),s={})}else Array.isArray(o)?o.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))s.entry=a,s.type="css";else{let p=a.match(j)||[];p.length>0?(s.global=p[1],s.entry=p[2],s.type="js"):(s.global="",s.entry=a,s.type="js")}t.push(s),s={}}):typeof o=="object"&&o.entry&&(s.entry=o.entry,s.global=o.global,s.type=o.type,t.push(s),s={})}t.map(n=>{n.type==="js"?r.push({attributes:{src:n.entry},tagName:"script"}):n.type==="css"&&r.push({attributes:{href:n.entry,rel:"stylesheet"},tagName:"link"})})}}};var O=(i,e)=>(i=Object.assign(i,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),i);var H=(i,e)=>(i=Object.assign(i,{vue:`${e}.Vue`,"vue-router":`${e}.VueRouter`}),i);var d=(i={})=>({name:"@empjs/share",async rsConfig(e){i.manifest===!0?i.manifest={fileName:"emp.json"}:typeof i.manifest=="object"&&(i.manifest=e.deepAssign({fileName:"emp.json"},i.manifest)),new c(i,e).setup()}}),T=d;0&&(module.exports={externalReact,externalVue,pluginRspackEmpShare});
|
|
3
3
|
//# sourceMappingURL=rspack.cjs.map
|
package/dist/rspack.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/rspack/index.ts","../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts"],"sourcesContent":["import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/rspack'\n","import {Compiler} from '@empjs/cli'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.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MACX,CAAC,CAEL,CAAC,CACH,CACF,CACF,ECxTO,IAAMO,EAAgB,CAACC,EAAQC,KACpCD,EAAI,OAAO,OAAOA,EAAG,CACnB,MAAO,GAAGC,CAAS,SACnB,YAAa,GAAGA,CAAS,YACzB,mBAAoBA,EACpB,oBAAqBA,EACrB,wBAAyBA,EACzB,mBAAoB,GAAGA,CAAS,iBAClC,CAAC,EACMD,GCTF,IAAME,EAAc,CAACC,EAAQC,KAClCD,EAAI,OAAO,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GRGF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ","names":["rspack_exports","__export","rspack_default","externalReact","externalVue","pluginRspackEmpShare","__toCommonJS","importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","import_rspack","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugins/rspack/index.ts","../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts"],"sourcesContent":["import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\nexport type {EMPPluginShareType}\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\nexport * from './types'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/rspack'\n","import {Compiler} from '@empjs/cli'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC,CAAE,GAAKA,GAAM,OAAOC,CAAE,IAAMA,EAAI,CACzCL,EAAOG,CAAC,EAAIJ,EAAWM,EAAID,CAAE,EAC7B,QACF,CACAJ,EAAOG,CAAC,EAAID,EAAOC,CAAC,CACtB,CAEF,OAAOH,CACT,CAMO,IAAMM,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECtBtE,IAA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AAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ","names":["rspack_exports","__export","rspack_default","externalReact","externalVue","pluginRspackEmpShare","__toCommonJS","importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","import_rspack","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default"]}
|
package/dist/rspack.d.cts
CHANGED
|
@@ -82,6 +82,32 @@ type frameworkOptions = {
|
|
|
82
82
|
type EMPPluginShareType = ModuleFederationPluginOptions & {
|
|
83
83
|
empRuntime?: EMPSHARERuntimeOptions;
|
|
84
84
|
};
|
|
85
|
+
type ExternalsItemType = {
|
|
86
|
+
/**
|
|
87
|
+
* 模块名
|
|
88
|
+
* @example react-dom
|
|
89
|
+
*/
|
|
90
|
+
module?: string;
|
|
91
|
+
/**
|
|
92
|
+
* 全局变量
|
|
93
|
+
* @example ReactDom
|
|
94
|
+
*/
|
|
95
|
+
global?: string;
|
|
96
|
+
/**
|
|
97
|
+
* 入口地址
|
|
98
|
+
* 不填则可以通过 emp-config 里的 html.files.js[url] 传入合并后的请求
|
|
99
|
+
* 如 http://...?react&react-dom&react-router&mobx
|
|
100
|
+
* @example http://
|
|
101
|
+
*/
|
|
102
|
+
entry?: string;
|
|
103
|
+
/**
|
|
104
|
+
* 类型入口
|
|
105
|
+
* @default js
|
|
106
|
+
* @enum js | css
|
|
107
|
+
* @example css
|
|
108
|
+
*/
|
|
109
|
+
type?: string;
|
|
110
|
+
};
|
|
85
111
|
|
|
86
112
|
declare const externalReact: (o: any, globalVal: string) => any;
|
|
87
113
|
|
|
@@ -92,4 +118,4 @@ declare const pluginRspackEmpShare: (o?: EMPPluginShareType) => {
|
|
|
92
118
|
rsConfig(store: GlobalStore): Promise<void>;
|
|
93
119
|
};
|
|
94
120
|
|
|
95
|
-
export { pluginRspackEmpShare as default, externalReact, externalVue, pluginRspackEmpShare };
|
|
121
|
+
export { type EMPPluginShareType, type EMPSHARERuntimeOptions, type ExternalsItemType, type ModuleFederationPluginOptions, pluginRspackEmpShare as default, externalReact, externalVue, type frameworLibType, type frameworkOptions, pluginRspackEmpShare, type runtimeLibType };
|
package/dist/rspack.d.ts
CHANGED
|
@@ -82,6 +82,32 @@ type frameworkOptions = {
|
|
|
82
82
|
type EMPPluginShareType = ModuleFederationPluginOptions & {
|
|
83
83
|
empRuntime?: EMPSHARERuntimeOptions;
|
|
84
84
|
};
|
|
85
|
+
type ExternalsItemType = {
|
|
86
|
+
/**
|
|
87
|
+
* 模块名
|
|
88
|
+
* @example react-dom
|
|
89
|
+
*/
|
|
90
|
+
module?: string;
|
|
91
|
+
/**
|
|
92
|
+
* 全局变量
|
|
93
|
+
* @example ReactDom
|
|
94
|
+
*/
|
|
95
|
+
global?: string;
|
|
96
|
+
/**
|
|
97
|
+
* 入口地址
|
|
98
|
+
* 不填则可以通过 emp-config 里的 html.files.js[url] 传入合并后的请求
|
|
99
|
+
* 如 http://...?react&react-dom&react-router&mobx
|
|
100
|
+
* @example http://
|
|
101
|
+
*/
|
|
102
|
+
entry?: string;
|
|
103
|
+
/**
|
|
104
|
+
* 类型入口
|
|
105
|
+
* @default js
|
|
106
|
+
* @enum js | css
|
|
107
|
+
* @example css
|
|
108
|
+
*/
|
|
109
|
+
type?: string;
|
|
110
|
+
};
|
|
85
111
|
|
|
86
112
|
declare const externalReact: (o: any, globalVal: string) => any;
|
|
87
113
|
|
|
@@ -92,4 +118,4 @@ declare const pluginRspackEmpShare: (o?: EMPPluginShareType) => {
|
|
|
92
118
|
rsConfig(store: GlobalStore): Promise<void>;
|
|
93
119
|
};
|
|
94
120
|
|
|
95
|
-
export { pluginRspackEmpShare as default, externalReact, externalVue, pluginRspackEmpShare };
|
|
121
|
+
export { type EMPPluginShareType, type EMPSHARERuntimeOptions, type ExternalsItemType, type ModuleFederationPluginOptions, pluginRspackEmpShare as default, externalReact, externalVue, type frameworLibType, type frameworkOptions, pluginRspackEmpShare, type runtimeLibType };
|
package/dist/rspack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts"],"sourcesContent":["export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/rspack'\n","import {Compiler} from '@empjs/cli'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n"],"mappings":"AAAO,IAAMA,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC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Ac,GAAGA,CAAS,YAC5B,CAAC,EACMD,GCGF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ","names":["importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","ModuleFederationPlugin","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","ModuleFederationPlugin","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts"],"sourcesContent":["export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/rspack'\n","import {Compiler} from '@empjs/cli'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\nexport type {EMPPluginShareType}\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\nexport * from './types'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n"],"mappings":"AAAO,IAAMA,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC,CAAE,GAAKA,GAAM,OAAOC,CAAE,IAAMA,EAAI,CACzCL,EAAOG,CAAC,EAAIJ,EAAWM,EAAID,CAAE,EAC7B,QACF,CACAJ,EAAOG,CAAC,EAAID,EAAOC,CAAC,CACtB,CAEF,OAAOH,CACT,CAMO,IAAMM,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECtBtE,IAAME,EAAkB,oBCA/B,OAAQ,0BAAAC,MAA6B,4BCIrC,IAAMC,EAAuBC,GAAO,CAClC,IAAMC,EAAU,CAAC,WAAWD,CAAG,GAAG,EAAE,KAAK;AAAA,CAAI,EAC7C,OAAOE,EAAWD,CAAO,CAC3B,EAEaE,EAAN,KAA8B,CACnC,QACA,YAAYC,EAA4B,CACtC,KAAK,QAAUA,CACjB,CACA,MAAMC,EAAoB,CACxB,GAAM,CAAC,QAAAC,CAAO,EAAID,EACZE,EAAQR,EAAqB,sBAAsB,EACzD,IAAIO,EAAQ,YAAYD,EAAS,QAASE,EAAO,CAC/C,KAAM,MACR,CAAC,EAAE,MAAMF,CAAQ,CACnB,CACF,ECpBO,SAASG,EAAcC,EAA8CC,EAAcC,EAAQ,UAAW,CAC3G,OAA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T,EACA,QAAS,QACX,CAAC,EACQA,EAAE,OAAS,OACpBrB,EAAW,KAAK,CACd,WAAY,CACV,KAAMqB,EAAE,MACR,IAAK,YACP,EACA,QAAS,MACX,CAAC,CAEL,CAAC,CACH,CACF,CACF,ECxTO,IAAMQ,EAAgB,CAACC,EAAQC,KACpCD,EAAI,OAAO,OAAOA,EAAG,CACnB,MAAO,GAAGC,CAAS,SACnB,YAAa,GAAGA,CAAS,YACzB,mBAAoBA,EACpB,oBAAqBA,EACrB,wBAAyBA,EACzB,mBAAoB,GAAGA,CAAS,iBAClC,CAAC,EACMD,GCTF,IAAME,EAAc,CAACC,EAAQC,KAClCD,EAAI,OAAO,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GCIF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ","names":["importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","ModuleFederationPlugin","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","ModuleFederationPlugin","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default"]}
|
package/output/sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function _assert_this_initialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function asyncGeneratorStep(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function _async_to_generator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){asyncGeneratorStep(a,r,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,r,o,i,c,"throw",e)}i(void 0)})}}function _call_super(e,t,n){return t=_get_prototype_of(t),_possible_constructor_return(e,_is_native_reflect_construct()?Reflect.construct(t,n||[],_get_prototype_of(e).constructor):t.apply(e,n))}function _class_call_check(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _create_class(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _get_prototype_of(e){return _get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_get_prototype_of(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_set_prototype_of(e,t)}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_define_property(e,t,n[t])})}return e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function _object_without_properties(e,t){if(null==e)return{};var n,r,o=_object_without_properties_loose(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function _object_without_properties_loose(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}function _possible_constructor_return(e,t){return!t||"object"!==_type_of(t)&&"function"!=typeof t?_assert_this_initialized(e):t}function _set_prototype_of(e,t){return _set_prototype_of=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},_set_prototype_of(e,t)}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_array(e){return _array_with_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_array_like_to_array(e,t):void 0}}function _is_native_reflect_construct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_is_native_reflect_construct=function(){return!!e})()}function _ts_generator(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}var EMP_SHARE_RUNTIME=function(exports){"use strict";var sr=Object.defineProperty,pt=function(e,t){for(var n in t)sr(e,n,{get:t[n],enumerable:!0})},ht={};pt(ht,{Module:function(){return te},ModuleFederation:function(){return q},createInstance:function(){return or},getInstance:function(){return Jn},getRemoteEntry:function(){return ee},getRemoteInfo:function(){return fe},init:function(){return Bn},loadRemote:function(){return Wn},loadScript:function(){return z},loadScriptNode:function(){return X},loadShare:function(){return Kn},loadShareSync:function(){return qn},preloadRemote:function(){return zn},registerGlobalPlugins:function(){return Gt},registerPlugins:function(){return Yn},registerRemotes:function(){return Xn},registerShared:function(){return Zn}});var We={},_obj,_obj1;pt(We,{BROWSER_LOG_KEY:function(){return mt},ENCODE_NAME_PREFIX:function(){return lr},EncodedNameTransformMap:function(){return pe},FederationModuleManifest:function(){return ir},MANIFEST_EXT:function(){return Ce},MFModuleType:function(){return ar},MFPrefetchCommon:function(){return fr},MODULE_DEVTOOL_IDENTIFIER:function(){return cr},ManifestFileName:function(){return ke},NameTransformMap:function(){return v},NameTransformSymbol:function(){return I},SEPARATOR:function(){return Ge},StatsFileName:function(){return xe},TEMP_DIR:function(){return ur},assert:function(){return Rr},bindLoggerToCompiler:function(){return wr},composeKeyWithSeparator:function(){return _e},containerPlugin:function(){return dr},containerReferencePlugin:function(){return hr},createInfrastructureLogger:function(){return Rt},createLink:function(){return ie},createLogger:function(){return Re},createModuleFederationConfig:function(){return vr},createScript:function(){return Se},createScriptNode:function(){return It},decodeName:function(){return Er},encodeName:function(){return Ue},error:function(){return Et},generateExposeFilename:function(){return gr},generateShareFilename:function(){return br},generateSnapshotFromManifest:function(){return Ve},getManifestFileName:function(){return $r},getProcessEnv:function(){return yt},getResourceUrl:function(){return se},inferAutoPublicPath:function(){return gt},infrastructureLogger:function(){return Ar},isBrowserEnv:function(){return x},isDebugMode:function(){return oe},isManifestProvider:function(){return be},isReactNativeEnv:function(){return ye},isRequiredVersion:function(){return Ir},isStaticResourcesEqual:function(){return Be},loadScript:function(){return z},loadScriptNode:function(){return X},logger:function(){return Or},moduleFederationPlugin:function(){return pr},normalizeOptions:function(){return Mr},parseEntry:function(){return _r},safeToString:function(){return ge},safeWrapper:function(){return je},sharePlugin:function(){return mr},simpleJoinRemoteEntry:function(){return W},warn:function(){return Ee}});var ir="federation-manifest.json",Ce=".json",mt="FEDERATION_DEBUG",I={AT:"@",HYPHEN:"-",SLASH:"/"},v=(_obj={},_define_property(_obj,I.AT,"scope_"),_define_property(_obj,I.HYPHEN,"_"),_define_property(_obj,I.SLASH,"__"),_obj),pe=(_obj1={},_define_property(_obj1,v[I.AT],I.AT),_define_property(_obj1,v[I.HYPHEN],I.HYPHEN),_define_property(_obj1,v[I.SLASH],I.SLASH),_obj1),Ge=":",ke="mf-manifest.json",xe="mf-stats.json",ar={NPM:"npm",APP:"app"},cr="__MF_DEVTOOLS_MODULE_INFO__",lr="ENCODE_NAME_PREFIX",ur=".federation",fr={identifier:"MFDataPrefetch",globalKey:"__PREFETCH__",library:"mf-data-prefetch",exportsKey:"__PREFETCH_EXPORTS__",fileName:"bootstrap.js"},dr=Object.freeze({__proto__:null}),hr=Object.freeze({__proto__:null}),pr=Object.freeze({__proto__:null}),mr=Object.freeze({__proto__:null});function x(){return("undefined"==typeof window?"undefined":_type_of(window))<"u"&&_type_of(window.document)<"u"}function ye(){var e;return("undefined"==typeof navigator?"undefined":_type_of(navigator))<"u"&&"ReactNative"===(null===(e=navigator)||void 0===e?void 0:e.product)}function yr(){try{if(x()&&window.localStorage)return!!localStorage.getItem(mt)}catch(e){return!1}return!1}function oe(){return("undefined"==typeof process?"undefined":_type_of(process))<"u"&&process.env,yr()}var yt=function(){return("undefined"==typeof process?"undefined":_type_of(process))<"u"&&process.env?process.env:{}},_t="[ Federation Runtime ]",_r=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ge,r=e.split(n),o="development"===yt().NODE_ENV&&t,a=function(e){return e.startsWith("http")||e.includes(Ce)};if(r.length>=2){var i=_to_array(r),c=i[0],s=i.slice(1);e.startsWith(n)&&(c=r.slice(0,2).join(n),s=[o||r.slice(2).join(n)]);var u=o||s.join(n);return a(u)?{name:c,entry:u}:{name:c,version:u||"*"}}if(1===r.length){var l=_sliced_to_array(r,1)[0];return o&&a(o)?{name:l,entry:o}:{name:l,version:o||"*"}}throw"Invalid entry value: ".concat(e)},_e=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.length?t.reduce(function(e,t){return t?e?"".concat(e).concat(Ge).concat(t):t:e},""):""},Ue=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{var r=n?".js":"";return"".concat(t).concat(e.replace(new RegExp("".concat(I.AT),"g"),v[I.AT]).replace(new RegExp("".concat(I.HYPHEN),"g"),v[I.HYPHEN]).replace(new RegExp("".concat(I.SLASH),"g"),v[I.SLASH])).concat(r)}catch(e){throw e}},Er=function(e,t,n){try{var r=e;if(t){if(!r.startsWith(t))return r;r=r.replace(new RegExp(t,"g"),"")}return r=r.replace(new RegExp("".concat(v[I.AT]),"g"),pe[v[I.AT]]).replace(new RegExp("".concat(v[I.SLASH]),"g"),pe[v[I.SLASH]]).replace(new RegExp("".concat(v[I.HYPHEN]),"g"),pe[v[I.HYPHEN]]),n&&(r=r.replace(".js","")),r}catch(e){throw e}},gr=function(e,t){if(!e)return"";var n=e;return"."===n&&(n="default_export"),n.startsWith("./")&&(n=n.replace("./","")),Ue(n,"__federation_expose_",t)},br=function(e,t){return e?Ue(e,"__federation_shared_",t):""},se=function(e,t){var n;return"getPublicPath"in e?(n=e.getPublicPath.startsWith("function")?new Function("return "+e.getPublicPath)()():new Function(e.getPublicPath)(),"".concat(n).concat(t)):"publicPath"in e?x()||ye()||!("ssrPublicPath"in e)?"".concat(e.publicPath).concat(t):"".concat(e.ssrPublicPath).concat(t):(console.warn("Cannot get resource URL. If in debug mode, please ignore.",e,t),"")},Rr=function(e,t){e||Et(t)},Et=function(e){throw new Error("".concat(_t,": ").concat(e))},Ee=function(e){console.warn("".concat(_t,": ").concat(e))};function ge(e){try{return JSON.stringify(e,null,2)}catch(e){return""}}var Sr=/^([\d^=v<>~]|[*xX]$)/;function Ir(e){return Sr.test(e)}var W=function(e,t){if(!e)return t;var n=function(e){if("."===e)return"";if(e.startsWith("./"))return e.replace("./","");if(e.startsWith("/")){var t=e.slice(1);return t.endsWith("/")?t.slice(0,-1):t}return e}(e);return n?n.endsWith("/")?"".concat(n).concat(t):"".concat(n,"/").concat(t):t};function gt(e){return e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function Ve(e){var t,n,r,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=a.remotes,c=void 0===i?{}:i,s=a.overrides,u=void 0===s?{}:s,l=a.version,f=function(){return"publicPath"in e.metaData?"auto"===e.metaData.publicPath&&l?gt(l):e.metaData.publicPath:e.metaData.getPublicPath},_=Object.keys(u),p={};Object.keys(c).length||(p=(null===(t=e.remotes)||void 0===t?void 0:t.reduce(function(e,t){var n,r=t.federationContainerName;return n=_.includes(r)?u[r]:"version"in t?t.version:t.entry,e[r]={matchedVersion:n},e},{}))||{}),Object.keys(c).forEach(function(e){return p[e]={matchedVersion:_.includes(e)?u[e]:c[e]}});var h=e.metaData,d=h.remoteEntry,m=d.path,y=d.name,v=d.type,g=h.types,b=void 0===g?{path:"",name:"",zip:"",api:""}:g,E=h.buildInfo.buildVersion,S=h.globalName,I=h.ssrRemoteEntry,N=e.exposes,w={version:l||"",buildVersion:E,globalName:S,remoteEntry:W(m,y),remoteEntryType:v,remoteTypes:W(b.path,b.name),remoteTypesZip:b.zip||"",remoteTypesAPI:b.api||"",remotesInfo:p,shared:null==e?void 0:e.shared.map(function(e){return{assets:e.assets,sharedName:e.name,version:e.version}}),modules:null==N?void 0:N.map(function(e){return{moduleName:e.name,modulePath:e.path,assets:e.assets}})};if(null===(n=e.metaData)||void 0===n?void 0:n.prefetchInterface){var R=e.metaData.prefetchInterface;w=_object_spread_props(_object_spread({},w),{prefetchInterface:R})}if(null===(r=e.metaData)||void 0===r?void 0:r.prefetchEntry){var A=e.metaData.prefetchEntry,k=A.path,O=A.name,j=A.type;w=_object_spread_props(_object_spread({},w),{prefetchEntry:W(k,O),prefetchEntryType:j})}if(o="publicPath"in e.metaData?_object_spread_props(_object_spread({},w),{publicPath:f(),ssrPublicPath:e.metaData.ssrPublicPath}):_object_spread_props(_object_spread({},w),{getPublicPath:f()}),I){var T=W(I.path,I.name);o.ssrRemoteEntry=T,o.ssrRemoteEntryType=I.type||"commonjs-module"}return o}function be(e){return!(!("remoteEntry"in e)||!e.remoteEntry.includes(Ce))}function $r(e){if(!e)return{statsFileName:xe,manifestFileName:ke};var t,n="boolean"==typeof e?"":e.filePath||"",r="boolean"==typeof e?"":e.fileName||"",o=".json",a=r?(t=r).endsWith(o)?t:"".concat(t).concat(o):ke,i=r?function(e,t){return e.replace(o,"".concat(t).concat(o))}(a,"-stats"):xe;return{statsFileName:W(n,i),manifestFileName:W(n,a)}}var bt="[ Module Federation ]",re=console,Nr=["logger.ts","logger.js","captureStackTrace","Logger.emit","Logger.log","Logger.info","Logger.warn","Logger.error","Logger.debug"];function Tr(){try{var e=(new Error).stack;if(!e)return;var t=_to_array(e.split("\n")).slice(1).filter(function(e){return!Nr.some(function(t){return e.includes(t)})});return t.length?"Stack trace:\n".concat(t.slice(0,5).join("\n")):void 0}catch(e){return}}var me=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:re;_class_call_check(this,e),this.prefix=t,this.delegate=null!=n?n:re}return _create_class(e,[{key:"setPrefix",value:function(e){this.prefix=e}},{key:"setDelegate",value:function(e){this.delegate=null!=e?e:re}},{key:"emit",value:function(e,t){var n=this.delegate,r=oe()?Tr():void 0,o=r?_to_consumable_array(t).concat([r]):t,a=function(){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"]}}(),i=!0,c=!1,s=void 0;try{for(var u,l=a[Symbol.iterator]();!(i=(u=l.next()).done);i=!0){var f,_=n[u.value];if("function"==typeof _)return void(f=_).call.apply(f,[n,this.prefix].concat(_to_consumable_array(o)))}}catch(e){c=!0,s=e}finally{try{i||null==l.return||l.return()}finally{if(c)throw s}}var p=!0,h=!1,d=void 0;try{for(var m,y=a[Symbol.iterator]();!(p=(m=y.next()).done);p=!0){var v,g=m.value,b=re[g];if("function"==typeof b)return void(v=b).call.apply(v,[re,this.prefix].concat(_to_consumable_array(o)))}}catch(e){h=!0,d=e}finally{try{p||null==y.return||y.return()}finally{if(h)throw d}}}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.emit("log",t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.emit("warn",t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.emit("error",t)}},{key:"success",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.emit("info",t)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.emit("info",t)}},{key:"ready",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.emit("info",t)}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];oe()&&this.emit("debug",t)}}]),e}();function Re(e){return new me(e)}function Rt(e){var t=new me(e);return Object.defineProperty(t,"__mf_infrastructure_logger__",{value:!0,enumerable:!1,configurable:!1}),t}function wr(e,t,n){if(e.__mf_infrastructure_logger__&&(null==t?void 0:t.getInfrastructureLogger))try{var r=t.getInfrastructureLogger(n);r&&"object"==(void 0===r?"undefined":_type_of(r))&&("function"==typeof r.log||"function"==typeof r.info||"function"==typeof r.warn||"function"==typeof r.error)&&e.setDelegate(r)}catch(t){e.setDelegate(void 0)}}var Or=Re(bt),Ar=Rt(bt);function je(e,t){return _async_to_generator(function(){var n;return _ts_generator(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e()];case 1:return[2,r.sent()];case 2:return n=r.sent(),!t&&Ee(n),[2];case 3:return[2]}})})()}function Be(e,t){var n=/^(https?:)?\/\//i;return e.replace(n,"").replace(/\/$/,"")===t.replace(n,"").replace(/\/$/,"")}function Se(e){for(var t,n=null,r=!0,o=2e4,a=document.getElementsByTagName("script"),i=0;i<a.length;i++){var c=a[i],s=c.getAttribute("src");if(s&&Be(s,e.url)){n=c,r=!1;break}}if(!n){var u,l=e.attrs;(n=document.createElement("script")).type="module"===(null==l?void 0:l.type)?"module":"text/javascript",e.createScriptHook&&(_instanceof(u=e.createScriptHook(e.url,e.attrs),HTMLScriptElement)?n=u:"object"==(void 0===u?"undefined":_type_of(u))&&("script"in u&&u.script&&(n=u.script),"timeout"in u&&u.timeout&&(o=u.timeout))),n.src||(n.src=e.url),l&&!u&&Object.keys(l).forEach(function(e){n&&("async"===e||"defer"===e?n[e]=l[e]:n.getAttribute(e)||n.setAttribute(e,l[e]))})}var f=function(r,o){return _async_to_generator(function(){var a,i,c;return _ts_generator(this,function(s){switch(s.label){case 0:return clearTimeout(t),a=function(){"error"===(null==o?void 0:o.type)?(null==e?void 0:e.onErrorCallback)&&(null==e||e.onErrorCallback(o)):(null==e?void 0:e.cb)&&(null==e||e.cb())},n&&(n.onerror=null,n.onload=null,je(function(){var t=e.needDeleteScript;(void 0===t||t)&&(null==n?void 0:n.parentNode)&&n.parentNode.removeChild(n)}),r&&"function"==typeof r)?_instanceof(i=r(o),Promise)?[4,i]:[3,2]:[3,3];case 1:return c=s.sent(),[2,(a(),c)];case 2:return[2,(a(),i)];case 3:return a(),[2]}})})()};return n.onerror=f.bind(null,n.onerror),n.onload=f.bind(null,n.onload),t=setTimeout(function(){f(null,new Error('Remote script "'.concat(e.url,'" time-outed.')))},o),{script:n,needAttach:r}}function ie(e){for(var t=null,n=!0,r=document.getElementsByTagName("link"),o=0;o<r.length;o++){var a=r[o],i=a.getAttribute("href"),c=a.getAttribute("rel");if(i&&Be(i,e.url)&&c===e.attrs.rel){t=a,n=!1;break}}if(!t){(t=document.createElement("link")).setAttribute("href",e.url);var s,u=e.attrs;e.createLinkHook&&(_instanceof(s=e.createLinkHook(e.url,u),HTMLLinkElement)&&(t=s)),u&&!s&&Object.keys(u).forEach(function(e){t&&!t.getAttribute(e)&&t.setAttribute(e,u[e])})}var l=function(n,r){var o=function(){"error"===(null==r?void 0:r.type)?(null==e?void 0:e.onErrorCallback)&&(null==e||e.onErrorCallback(r)):(null==e?void 0:e.cb)&&(null==e||e.cb())};if(t&&(t.onerror=null,t.onload=null,je(function(){var n=e.needDeleteLink;(void 0===n||n)&&(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}),n)){var a=n(r);return o(),a}o()};return t.onerror=l.bind(null,t.onerror),t.onload=l.bind(null,t.onload),{link:t,needAttach:n}}function z(e,t){var n=t.attrs,r=void 0===n?{}:n,o=t.createScriptHook;return new Promise(function(t,n){var a=Se({url:e,cb:t,onErrorCallback:n,attrs:_object_spread({fetchpriority:"high"},r),createScriptHook:o,needDeleteScript:!0}),i=a.script;a.needAttach&&document.head.appendChild(i)})}var he=new Map;function ne(e){if(!e)throw new Error("import specifier is required");if(he.has(e))return he.get(e);var t=new Function("name","return import(name)")(e).then(function(e){return e}).catch(function(t){throw console.error("Error importing module ".concat(e,":"),t),he.delete(e),t});return he.set(e,t),t}var St=function(){return _async_to_generator(function(){var e;return _ts_generator(this,function(t){switch(t.label){case 0:return[4,ne("node-fetch")];case 1:return[2,(e=t.sent()).default||e]}})})()},Pr=function(e,t,n){return _async_to_generator(function(){var r,o,a;return _ts_generator(this,function(i){switch(i.label){case 0:return[4,(c=e,s=t||{},n.lifecycle.fetch.emit(c,s))];case 1:return(r=i.sent())&&_instanceof(r,Response)?[3,5]:("undefined"==typeof fetch?"undefined":_type_of(fetch))>"u"?[4,St()]:[3,3];case 2:return a=i.sent(),[3,4];case 3:a=fetch,i.label=4;case 4:return o=a(e,t||{}),[3,6];case 5:o=r,i.label=6;case 6:return[2,o]}var c,s})})()},It=("undefined"==typeof ENV_TARGET?"undefined":_type_of(ENV_TARGET))>"u"||"web"!==ENV_TARGET?function(url,cb,attrs,loaderHook){if(null==loaderHook?void 0:loaderHook.createScriptHook){var _$t=loaderHook.createScriptHook(url);_$t&&"object"==(void 0===_$t?"undefined":_type_of(_$t))&&"url"in _$t&&(url=_$t.url)}var urlObj;try{urlObj=new URL(url)}catch(e){return console.error("Error constructing URL:",e),void cb(new Error("Invalid URL: ".concat(e)))}var getFetch=function(){return _async_to_generator(function(){return _ts_generator(this,function(e){return[2,(null==loaderHook?void 0:loaderHook.fetch)?function(e,t){return Pr(e,t,loaderHook)}:("undefined"==typeof fetch?"undefined":_type_of(fetch))>"u"?St():fetch]})})()},handleScriptFetch=function(f,urlObj){return _async_to_generator(function(){var _vm_constants,_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER,res,data,_ref,path,vm,scriptContext,urlDirname,filename,script,exportedInterface,_$t,t;return _ts_generator(this,function(_state){switch(_state.label){case 0:return _state.trys.push([0,4,,5]),[4,f(urlObj.href)];case 1:return res=_state.sent(),[4,res.text()];case 2:return data=_state.sent(),[4,Promise.all([ne("path"),ne("vm")])];case 3:return _ref=_sliced_to_array.apply(void 0,[_state.sent(),2]),path=_ref[0],vm=_ref[1],scriptContext={exports:{},module:{exports:{}}},urlDirname=urlObj.pathname.split("/").slice(0,-1).join("/"),filename=path.basename(urlObj.pathname),script=new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data,"\n})"),{filename:filename,importModuleDynamically:null!==(_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER=null===(_vm_constants=vm.constants)||void 0===_vm_constants?void 0:_vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER)&&void 0!==_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER?_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER:ne}),script.runInThisContext()(scriptContext.exports,scriptContext.module,eval("require"),urlDirname,filename),exportedInterface=scriptContext.module.exports||scriptContext.exports,attrs&&exportedInterface&&attrs.globalName?(_$t=exportedInterface[attrs.globalName]||exportedInterface,cb(void 0,_$t),[2]):(cb(void 0,exportedInterface),[3,5]);case 4:return t=_state.sent(),cb(_instanceof(t,Error)?t:new Error("Script execution error: ".concat(t))),[3,5];case 5:return[2]}})})()};getFetch().then(function(e){return _async_to_generator(function(){var t,n;return _ts_generator(this,function(r){switch(r.label){case 0:return"esm"!==(null==attrs?void 0:attrs.type)&&"module"!==(null==attrs?void 0:attrs.type)?[3,2]:(t=[urlObj.href],n={fetch:e},[4,ne("vm")]);case 1:return[2,He.apply(void 0,t.concat([(n.vm=r.sent(),n)])).then(function(e){return _async_to_generator(function(){return _ts_generator(this,function(t){switch(t.label){case 0:return[4,e.evaluate()];case 1:return t.sent(),cb(void 0,e.namespace),[2]}})})()}).catch(function(e){cb(_instanceof(e,Error)?e:new Error("Script execution error: ".concat(e)))})];case 2:return handleScriptFetch(e,urlObj),[2]}})})()}).catch(function(e){cb(e)})}:function(e,t,n,r){t(new Error("createScriptNode is disabled in non-Node.js environment"))},X=("undefined"==typeof ENV_TARGET?"undefined":_type_of(ENV_TARGET))>"u"||"web"!==ENV_TARGET?function(e,t){return new Promise(function(n,r){It(e,function(e,o){if(e)r(e);else{var a,i,c=(null==t||null===(a=t.attrs)||void 0===a?void 0:a.globalName)||"__FEDERATION_".concat(null==t||null===(i=t.attrs)||void 0===i?void 0:i.name,":custom__"),s=globalThis[c]=o;n(s)}},t.attrs,t.loaderHook)})}:function(e,t){throw new Error("loadScriptNode is disabled in non-Node.js environment")},De=new Map;function He(e,t){return _async_to_generator(function(){var n,r,o,a;return _ts_generator(this,function(i){switch(i.label){case 0:return De.has(e)?[2,De.get(e)]:(n=t.fetch,r=t.vm,[4,n(e)]);case 1:return[4,i.sent().text()];case 2:return o=i.sent(),a=new r.SourceTextModule(o,{importModuleDynamically:function(n,r){return _async_to_generator(function(){return _ts_generator(this,function(r){return[2,He(new URL(n,e).href,t)]})})()}}),De.set(e,a),[4,a.link(function(n){return _async_to_generator(function(){return _ts_generator(this,function(r){switch(r.label){case 0:return[4,He(new URL(n,e).href,t)];case 1:return[2,r.sent()]}})})()})];case 3:return[2,(i.sent(),a)]}})})()}function Mr(e,t,n){return function(r){if(!1===r)return!1;if((void 0===r?"undefined":_type_of(r))>"u")return!!e&&t;if(!0===r)return t;if(r&&"object"==(void 0===r?"undefined":_type_of(r)))return _object_spread({},t,r);throw new Error("Unexpected type for `".concat(n,"`, expect boolean/undefined/object, got: ").concat(void 0===r?"undefined":_type_of(r)))}}var vr=function(e){return e},_obj2,Ke="RUNTIME-001",qe="RUNTIME-002",ze="RUNTIME-003",Xe="RUNTIME-004",Ye="RUNTIME-005",Ie="RUNTIME-006",Je="RUNTIME-007",$e="RUNTIME-008",j="RUNTIME-009",kr=function(e){return"View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/".concat(e.split("-")[0].toLowerCase(),"/").concat(e)},A=function(e,t,n,r){var o=["".concat([t[e]]," #").concat(e)];return n&&o.push("args: ".concat(JSON.stringify(n))),o.push(kr(e)),r&&o.push("Original Error Message:\n ".concat(r)),o.join("\n")},w=(_obj2={},_define_property(_obj2,Ke,"Failed to get remoteEntry exports."),_define_property(_obj2,qe,'The remote entry interface does not contain "init"'),_define_property(_obj2,ze,"Failed to get manifest."),_define_property(_obj2,Xe,"Failed to locate remote."),_define_property(_obj2,Ye,"Invalid loadShareSync function call from bundler runtime"),_define_property(_obj2,Ie,"Invalid loadShareSync function call from runtime"),_define_property(_obj2,Je,"Failed to get remote snapshot."),_define_property(_obj2,$e,"Failed to load script resources."),_define_property(_obj2,j,"Please call createInstance first."),_obj2),J="[ Federation Runtime ]",tt=Re(J);function $(e,t){e||G(t)}function G(e){throw _instanceof(e,Error)?(e.message.startsWith(J)||(e.message="".concat(J,": ").concat(e.message)),e):new Error("".concat(J,": ").concat(e))}function Le(e){_instanceof(e,Error)&&(e.message.startsWith(J)||(e.message="".concat(J,": ").concat(e.message))),tt.warn(e)}function $t(e,t){return-1===e.findIndex(function(e){return e===t})&&e.push(t),e}function ce(e){return"version"in e&&e.version?"".concat(e.name,":").concat(e.version):"entry"in e&&e.entry?"".concat(e.name,":").concat(e.entry):"".concat(e.name)}function it(e){return _type_of(e.entry)<"u"}function Lt(e){return!e.entry.includes(".json")}function at(e){return e&&"object"==(void 0===e?"undefined":_type_of(e))}var Cr=Object.prototype.toString;function Gr(e){return"[object Object]"===Cr.call(e)}function Ft(e){return Array.isArray(e)?e:[e]}function Dt(e){var t={url:"",type:"global",globalName:""};return x()||ye()?"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}var Ur=function(e,t){var n;return n=e.endsWith("/")?e.slice(0,-1):e,t.startsWith(".")&&(t=t.slice(1)),n+=t},N="object"==("undefined"==typeof globalThis?"undefined":_type_of(globalThis))?globalThis:window,D=function(){try{return document.defaultView}catch(e){return N}}(),le=D;function Te(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!1,writable:!0})}function we(e,t){return Object.hasOwnProperty.call(e,t)}we(N,"__GLOBAL_LOADING_REMOTE_ENTRY__")||Te(N,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});var Y=N.__GLOBAL_LOADING_REMOTE_ENTRY__;function kt(e){var t,n,r,o,a,i,c,s,u,l,f,_;we(e,"__VMOK__")&&!we(e,"__FEDERATION__")&&Te(e,"__FEDERATION__",e.__VMOK__),we(e,"__FEDERATION__")||(Te(e,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),Te(e,"__VMOK__",e.__FEDERATION__)),null!==(c=(t=e.__FEDERATION__).__GLOBAL_PLUGIN__)&&void 0!==c||(t.__GLOBAL_PLUGIN__=[]),null!==(s=(n=e.__FEDERATION__).__INSTANCES__)&&void 0!==s||(n.__INSTANCES__=[]),null!==(u=(r=e.__FEDERATION__).moduleInfo)&&void 0!==u||(r.moduleInfo={}),null!==(l=(o=e.__FEDERATION__).__SHARE__)&&void 0!==l||(o.__SHARE__={}),null!==(f=(a=e.__FEDERATION__).__MANIFEST_LOADING__)&&void 0!==f||(a.__MANIFEST_LOADING__={}),null!==(_=(i=e.__FEDERATION__).__PRELOADED_MAP__)&&void 0!==_||(i.__PRELOADED_MAP__=new Map)}function xt(e){N.__FEDERATION__.__INSTANCES__.push(e)}function Ht(){return N.__FEDERATION__.__DEBUG_CONSTRUCTOR__}function Ct(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:oe())&&(N.__FEDERATION__.__DEBUG_CONSTRUCTOR__=e,N.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="0.21.4")}function Z(e,t){if("string"==typeof t){if(e[t])return{value:e[t],key:t};var n=Object.keys(e),r=!0,o=!1,a=void 0;try{for(var i,c=n[Symbol.iterator]();!(r=(i=c.next()).done);r=!0){var s=_sliced_to_array(i.value.split(":"),2),u=s[0],l=(s[1],"".concat(u,":").concat(t)),f=e[l];if(f)return{value:f,key:l}}}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return{value:void 0,key:t}}throw new Error("key must be string")}kt(N),kt(D);var Nt=function(){return D.__FEDERATION__.moduleInfo},Vr=function(e,t){var n=Z(t,ce(e)).value;if(n&&!n.version&&"version"in e&&e.version&&(n.version=e.version),n)return n;if("version"in e&&e.version){var r=e.version,o=ce(_object_without_properties(e,["version"])),a=Z(D.__FEDERATION__.moduleInfo,o).value;if((null==a?void 0:a.version)===r)return a}},Oe=function(e){return Vr(e,D.__FEDERATION__.moduleInfo)},Tt=function(e,t){var n=ce(e);return D.__FEDERATION__.moduleInfo[n]=t,D.__FEDERATION__.moduleInfo},jr=function(e){return D.__FEDERATION__.moduleInfo=_object_spread({},D.__FEDERATION__.moduleInfo,e),function(){var t=Object.keys(e),n=!0,r=!1,o=void 0;try{for(var a,i=t[Symbol.iterator]();!(n=(a=i.next()).done);n=!0){var c=a.value;delete D.__FEDERATION__.moduleInfo[c]}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}}},ct=function(e,t){var n=t||"__FEDERATION_".concat(e,":custom__");return{remoteEntryKey:n,entryExports:N[n]}},Gt=function(e){var t=D.__FEDERATION__.__GLOBAL_PLUGIN__;e.forEach(function(e){-1===t.findIndex(function(t){return t.name===e.name})?t.push(e):Le("The plugin ".concat(e.name," has been registered."))})},Br=function(){return D.__FEDERATION__.__GLOBAL_PLUGIN__},Wr=function(e){return N.__FEDERATION__.__PRELOADED_MAP__.get(e)},Kr=function(e){return N.__FEDERATION__.__PRELOADED_MAP__.set(e,!0)},de="default",Ut="global",wt="[0-9A-Za-z-]+",lt="(?:\\+(".concat(wt,"(?:\\.").concat(wt,")*))"),ae="0|[1-9]\\d*",Ae="[0-9]+",Vt="\\d*[a-zA-Z-][a-zA-Z0-9-]*",Ot="(?:".concat(Ae,"|").concat(Vt,")"),qr="(?:-?(".concat(Ot,"(?:\\.").concat(Ot,")*))"),At="(?:".concat(ae,"|").concat(Vt,")"),jt="(?:-(".concat(At,"(?:\\.").concat(At,")*))"),Ze="".concat(ae,"|x|X|\\*"),Q="[v=\\s]*(".concat(Ze,")(?:\\.(").concat(Ze,")(?:\\.(").concat(Ze,")(?:").concat(jt,")?").concat(lt,"?)?)?"),zr="^\\s*(".concat(Q,")\\s+-\\s+(").concat(Q,")\\s*$"),Xr="(".concat(Ae,")\\.(").concat(Ae,")\\.(").concat(Ae,")"),Yr="[v=\\s]*".concat(Xr).concat(qr,"?").concat(lt,"?"),ut="((?:<|>)?=?)",Jr="(\\s*)".concat(ut,"\\s*(").concat(Yr,"|").concat(Q,")"),Bt="(?:~>?)",Zr="(\\s*)".concat(Bt,"\\s+"),Wt="(?:\\^)",Qr="(\\s*)".concat(Wt,"\\s+"),en="(<|>)?=?\\s*\\*",tn="^".concat(Wt).concat(Q,"$"),rn="(".concat(ae,")\\.(").concat(ae,")\\.(").concat(ae,")"),nn="v?".concat(rn).concat(jt,"?").concat(lt,"?"),on="^".concat(Bt).concat(Q,"$"),sn="^".concat(ut,"\\s*").concat(Q,"$"),an="^".concat(ut,"\\s*(").concat(nn,")$|^$"),cn="^\\s*>=\\s*0.0.0\\s*$";function U(e){return new RegExp(e)}function P(e){return!e||"x"===e.toLowerCase()||"*"===e}function Kt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return t.reduce(function(e,t){return t(e)},e)}}function Pt(e){return e.match(U(an))}function Mt(e,t,n,r){var o="".concat(e,".").concat(t,".").concat(n);return r?"".concat(o,"-").concat(r):o}function ln(e){return e.replace(U(zr),function(e,t,n,r,o,a,i,c,s,u,l,f){return t=P(n)?"":P(r)?">=".concat(n,".0.0"):P(o)?">=".concat(n,".").concat(r,".0"):">=".concat(t),c=P(s)?"":P(u)?"<".concat(Number(s)+1,".0.0-0"):P(l)?"<".concat(s,".").concat(Number(u)+1,".0-0"):f?"<=".concat(s,".").concat(u,".").concat(l,"-").concat(f):"<=".concat(c),"".concat(t," ").concat(c).trim()})}function un(e){return e.replace(U(Jr),"$1$2$3")}function fn(e){return e.replace(U(Zr),"$1~")}function dn(e){return e.replace(U(Qr),"$1^")}function hn(e){return e.trim().split(/\s+/).map(function(e){return e.replace(U(tn),function(e,t,n,r,o){return P(t)?"":P(n)?">=".concat(t,".0.0 <").concat(Number(t)+1,".0.0-0"):P(r)?"0"===t?">=".concat(t,".").concat(n,".0 <").concat(t,".").concat(Number(n)+1,".0-0"):">=".concat(t,".").concat(n,".0 <").concat(Number(t)+1,".0.0-0"):o?"0"===t?"0"===n?">=".concat(t,".").concat(n,".").concat(r,"-").concat(o," <").concat(t,".").concat(n,".").concat(Number(r)+1,"-0"):">=".concat(t,".").concat(n,".").concat(r,"-").concat(o," <").concat(t,".").concat(Number(n)+1,".0-0"):">=".concat(t,".").concat(n,".").concat(r,"-").concat(o," <").concat(Number(t)+1,".0.0-0"):"0"===t?"0"===n?">=".concat(t,".").concat(n,".").concat(r," <").concat(t,".").concat(n,".").concat(Number(r)+1,"-0"):">=".concat(t,".").concat(n,".").concat(r," <").concat(t,".").concat(Number(n)+1,".0-0"):">=".concat(t,".").concat(n,".").concat(r," <").concat(Number(t)+1,".0.0-0")})}).join(" ")}function pn(e){return e.trim().split(/\s+/).map(function(e){return e.replace(U(on),function(e,t,n,r,o){return P(t)?"":P(n)?">=".concat(t,".0.0 <").concat(Number(t)+1,".0.0-0"):P(r)?">=".concat(t,".").concat(n,".0 <").concat(t,".").concat(Number(n)+1,".0-0"):o?">=".concat(t,".").concat(n,".").concat(r,"-").concat(o," <").concat(t,".").concat(Number(n)+1,".0-0"):">=".concat(t,".").concat(n,".").concat(r," <").concat(t,".").concat(Number(n)+1,".0-0")})}).join(" ")}function mn(e){return e.split(/\s+/).map(function(e){return e.trim().replace(U(sn),function(e,t,n,r,o,a){var i=P(n),c=i||P(r),s=c||P(o);return"="===t&&s&&(t=""),a="",i?">"===t||"<"===t?"<0.0.0-0":"*":t&&s?(c&&(r=0),o=0,">"===t?(t=">=",c?(n=Number(n)+1,r=0,o=0):(r=Number(r)+1,o=0)):"<="===t&&(t="<",c?n=Number(n)+1:r=Number(r)+1),"<"===t&&(a="-0"),"".concat(t+n,".").concat(r,".").concat(o).concat(a)):c?">=".concat(n,".0.0").concat(a," <").concat(Number(n)+1,".0.0-0"):s?">=".concat(n,".").concat(r,".0").concat(a," <").concat(n,".").concat(Number(r)+1,".0-0"):e})}).join(" ")}function yn(e){return e.trim().replace(U(en),"")}function _n(e){return e.trim().replace(U(cn),"")}function Pe(e,t){return(e=Number(e)||e)>(t=Number(t)||t)?1:e===t?0:-1}function En(e,t){var n=e.preRelease,r=t.preRelease;if(void 0===n&&r)return 1;if(n&&void 0===r)return-1;if(void 0===n&&void 0===r)return 0;for(var o=0,a=n.length;o<=a;o++){var i=n[o],c=r[o];if(i!==c)return void 0===i&&void 0===c?0:i?c?Pe(i,c):-1:1}return 0}function Ne(e,t){return Pe(e.major,t.major)||Pe(e.minor,t.minor)||Pe(e.patch,t.patch)||En(e,t)}function Qe(e,t){return e.version===t.version}function gn(e,t){switch(e.operator){case"":case"=":return Qe(e,t);case">":return Ne(e,t)<0;case">=":return Qe(e,t)||Ne(e,t)<0;case"<":return Ne(e,t)>0;case"<=":return Qe(e,t)||Ne(e,t)>0;case void 0:return!0;default:return!1}}function bn(e){return Kt(hn,pn,mn,yn)(e)}function Rn(e){return Kt(ln,un,fn,dn)(e.trim()).split(/\s+/).join(" ")}function Me(e,t){if(!e)return!1;var n=Pt(e);if(!n)return!1;var r=_sliced_to_array(n,7),o=r[1],a=r[3],i=r[4],c=r[5],s=r[6],u={operator:o,version:Mt(a,i,c,s),major:a,minor:i,patch:c,preRelease:null==s?void 0:s.split(".")},l=t.split("||"),f=!0,_=!1,p=void 0;try{for(var h,d=l[Symbol.iterator]();!(f=(h=d.next()).done);f=!0){var m=h.value.trim();if(!m||"*"===m||"x"===m)return!0;try{var y=Rn(m);if(!y.trim())return!0;var v=y.split(" ").map(function(e){return bn(e)}).join(" ");if(!v.trim())return!0;var g=v.split(/\s+/).map(function(e){return _n(e)}).filter(Boolean);if(0===g.length)continue;var b=!0,E=!0,S=!1,I=void 0;try{for(var N,w=g[Symbol.iterator]();!(E=(N=w.next()).done);E=!0){var R=Pt(N.value);if(!R){b=!1;break}var A=_sliced_to_array(R,7),k=A[1],O=A[3],j=A[4],T=A[5],P=A[6];if(!gn({operator:k,version:Mt(O,j,T,P),major:O,minor:j,patch:T,preRelease:null==P?void 0:P.split(".")},u)){b=!1;break}}}catch(e){S=!0,I=e}finally{try{E||null==w.return||w.return()}finally{if(S)throw I}}if(b)return!0}catch(e){console.error('[semver] Error processing range part "'.concat(m,'":'),e);continue}}}catch(e){_=!0,p=e}finally{try{f||null==d.return||d.return()}finally{if(_)throw p}}return!1}function Sn(e,t,n,r){var o,a,i,c;return o="get"in e?e.get:"lib"in e?function(){return Promise.resolve(e.lib)}:function(){return Promise.resolve(function(){throw new Error("Can not get shared '".concat(n,"'!"))})},_object_spread_props(_object_spread({deps:[],useIn:[],from:t,loading:null},e),{shareConfig:_object_spread({requiredVersion:"^".concat(e.version),singleton:!1,eager:!1,strictVersion:!1},e.shareConfig),get:o,loaded:!(!(null==e?void 0:e.loaded)&&!("lib"in e))||void 0,version:null!==(a=e.version)&&void 0!==a?a:"0",scope:Array.isArray(e.scope)?e.scope:[null!==(i=e.scope)&&void 0!==i?i:"default"],strategy:(null!==(c=e.strategy)&&void 0!==c?c:r)||"version-first"})}function qt(e,t){var n=t.shared||{},r=t.name,o=Object.keys(n).reduce(function(e,o){var a=Ft(n[o]);return e[o]=e[o]||[],a.forEach(function(n){e[o].push(Sn(n,r,o,t.shareStrategy))}),e},{}),a=_object_spread({},e.shared);return Object.keys(o).forEach(function(e){a[e]?o[e].forEach(function(t){a[e].find(function(e){return e.version===t.version})||a[e].push(t)}):a[e]=o[e]}),{shared:a,shareInfos:o}}function ue(e,t){var n=function(e){if(!Number.isNaN(Number(e))){for(var t=e.split("."),n=e,r=0;r<3-t.length;r++)n+=".0";return n}return e};return!!Me(n(e),"<=".concat(n(t)))}var ft=function(e,t){var n=t||function(e,t){return ue(e,t)};return Object.keys(e).reduce(function(e,t){return!e||n(e,t)||"0"===e?t:e},0)},dt=function(e){return!!e.loaded||"function"==typeof e.lib},In=function(e){return!!e.loading};function $n(e,t,n){var r=e[t][n];return ft(e[t][n],function(e,t){return!dt(r[e])&&ue(e,t)})}function Nn(e,t,n){var r=e[t][n];return ft(e[t][n],function(e,t){var n=function(e){return dt(e)||In(e)};return n(r[t])?!n(r[e])||!!ue(e,t):!n(r[e])&&ue(e,t)})}function Tn(e){return"loaded-first"===e?Nn:$n}function ve(e,t,n,r){if(e){var o=n.shareConfig,a=n.scope,i=void 0===a?de:a,c=n.strategy,s=Array.isArray(i)?i:[i],u=!0,l=!1,f=void 0;try{for(var _,p=function(){var a=_.value;if(o&&e[a]&&e[a][t]){var i=o.requiredVersion,s=Tn(c)(e,a,t),u={shareScopeMap:e,scope:a,pkgName:t,version:s,GlobalFederation:le.__FEDERATION__,resolver:function(){if(o.singleton){if("string"==typeof i&&!Me(s,i)){var r="Version ".concat(s," from ").concat(s&&e[a][t][s].from," of shared singleton module ").concat(t," does not satisfy the requirement of ").concat(n.from," which needs ").concat(i,")");o.strictVersion?G(r):Le(r)}return e[a][t][s]}if(!1===i||"*"===i||Me(s,i))return e[a][t][s];var c=!0,u=!1,l=void 0;try{for(var f,_=Object.entries(e[a][t])[Symbol.iterator]();!(c=(f=_.next()).done);c=!0){var p=_sliced_to_array(f.value,2),h=p[0],d=p[1];if(Me(h,i))return d}}catch(e){u=!0,l=e}finally{try{c||null==_.return||_.return()}finally{if(u)throw l}}}};return{v:(r.emit(u)||u).resolver()}}},h=s[Symbol.iterator]();!(u=(_=h.next()).done);u=!0){var d=p();if("object"===_type_of(d))return d.v}}catch(e){l=!0,f=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw f}}}}function zt(){return le.__FEDERATION__.__SHARE__}function vt(e){var t,n=e.pkgName,r=e.extraOptions,o=e.shareInfos,a=null!==(t=null==r?void 0:r.resolver)&&void 0!==t?t:function(e){if(e){var t={};e.forEach(function(e){t[e.version]=e});var n=ft(t,function(e,n){return!dt(t[e])&&ue(e,n)});return t[n]}};return Object.assign({},a(o[n]),null==r?void 0:r.customShareInfo)}function wn(){return("undefined"==typeof FEDERATION_BUILD_IDENTIFIER?"undefined":_type_of(FEDERATION_BUILD_IDENTIFIER))<"u"?FEDERATION_BUILD_IDENTIFIER:""}function On(e,t){var n=!0,r=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done);n=!0){var c=a.value,s=t.startsWith(c.name),u=t.replace(c.name,"");if(s){if(u.startsWith("/"))return{pkgNameOrAlias:c.name,expose:u=".".concat(u),remote:c};if(""===u)return{pkgNameOrAlias:c.name,expose:".",remote:c}}var l=c.alias&&t.startsWith(c.alias),f=c.alias&&t.replace(c.alias,"");if(c.alias&&l){if(f&&f.startsWith("/"))return{pkgNameOrAlias:c.alias,expose:f=".".concat(f),remote:c};if(""===f)return{pkgNameOrAlias:c.alias,expose:".",remote:c}}}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}}function An(e,t){var n=!0,r=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done);n=!0){var c=a.value;if(t===c.name||c.alias&&t===c.alias)return c}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}}function Pn(e,t){var n=Br(),r=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return n.length>0&&n.forEach(function(t){(null==e?void 0:e.find(function(e){return e.name!==t.name}))&&e.push(t)}),e&&e.length>0&&e.forEach(function(e){r.forEach(function(n){n.applyPlugin(e,t)})}),e}var Xt=".then(callbacks[0]).catch(callbacks[1])";function Mn(e){return _async_to_generator(function(e){var t,n;return _ts_generator(this,function(r){return t=e.entry,n=e.remoteEntryExports,[2,new Promise(function(e,r){try{n?e(n):new Function("callbacks",'import("'.concat(t,'")').concat(Xt))([e,r])}catch(e){r(e)}})]})}).apply(this,arguments)}function vn(e){return _async_to_generator(function(e){var t,n;return _ts_generator(this,function(r){return t=e.entry,n=e.remoteEntryExports,[2,new Promise(function(e,r){try{n?e(n):("undefined"==typeof __system_context__?"undefined":_type_of(__system_context__))>"u"?System.import(t).then(e).catch(r):new Function("callbacks",'System.import("'.concat(t,'")').concat(Xt))([e,r])}catch(e){r(e)}})]})}).apply(this,arguments)}function Yt(e,t,n){var r=ct(e,t),o=r.remoteEntryKey,a=r.entryExports;return $(a,A(Ke,w,{remoteName:e,remoteEntryUrl:n,remoteEntryKey:o})),a}function Ln(e){return _async_to_generator(function(e){var t,n,r,o,a,i,c;return _ts_generator(this,function(s){return t=e.name,n=e.globalName,r=e.entry,o=e.loaderHook,a=e.getEntryUrl,i=ct(t,n),(c=i.entryExports)?[2,c]:[2,z(a?a(r):r,{attrs:{},createScriptHook:function(e,t){var n=o.lifecycle.createScript.emit({url:e,attrs:t});if(n&&(_instanceof(n,HTMLScriptElement)||"script"in n||"timeout"in n))return n}}).then(function(){return Yt(t,n,r)}).catch(function(e){throw $(void 0,A($e,w,{remoteName:t,resourceUrl:r})),e})]})}).apply(this,arguments)}function Fn(e){return _async_to_generator(function(e){var t,n,r,o,a,i,c;return _ts_generator(this,function(s){switch(t=e.remoteInfo,n=e.remoteEntryExports,r=e.loaderHook,o=e.getEntryUrl,a=t.entry,i=t.entryGlobalName,c=t.name,t.type){case"esm":case"module":return[2,Mn({entry:a,remoteEntryExports:n})];case"system":return[2,vn({entry:a,remoteEntryExports:n})];default:return[2,Ln({entry:a,globalName:i,name:c,loaderHook:r,getEntryUrl:o})]}return[2]})}).apply(this,arguments)}function Dn(e){return _async_to_generator(function(e){var t,n,r,o,a,i,c;return _ts_generator(this,function(s){return t=e.remoteInfo,n=e.loaderHook,r=t.entry,o=t.entryGlobalName,a=t.name,i=t.type,c=ct(a,o),[2,c.entryExports||X(r,{attrs:{name:a,globalName:o,type:i},loaderHook:{createScriptHook:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.lifecycle.createScript.emit({url:e,attrs:t});if(r&&"url"in r)return r}}}).then(function(){return Yt(a,o,r)}).catch(function(e){throw e})]})}).apply(this,arguments)}function rt(e){var t=e.entry,n=e.name;return _e(n,t)}function ee(e){return _async_to_generator(function(){var t,n,r,o,a,i,c,s,u;return _ts_generator(this,function(l){return t=e.origin,n=e.remoteEntryExports,r=e.remoteInfo,o=e.getEntryUrl,a=e._inErrorHandling,i=void 0!==a&&a,c=rt(r),n?[2,n]:(Y[c]||(s=t.remoteHandler.hooks.lifecycle.loadEntry,u=t.loaderHook,Y[c]=s.emit({loaderHook:u,remoteInfo:r,remoteEntryExports:n}).then(function(e){return e||((("undefined"==typeof ENV_TARGET?"undefined":_type_of(ENV_TARGET))<"u"?"web"===ENV_TARGET:x())?Fn({remoteInfo:r,remoteEntryExports:n,loaderHook:u,getEntryUrl:o}):Dn({remoteInfo:r,loaderHook:u}))}).catch(function(e){return _async_to_generator(function(){var o,a,c;return _ts_generator(this,function(s){switch(s.label){case 0:return o=rt(r),_instanceof(e,Error)&&e.message.includes($e)&&!i?(a=function(e){return ee(_object_spread_props(_object_spread({},e),{_inErrorHandling:!0}))},[4,t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:a,origin:t,remoteInfo:r,remoteEntryExports:n,globalLoading:Y,uniqueKey:o})]):[3,2];case 1:if(c=s.sent())return[2,c];s.label=2;case 2:throw e}})})()})),[2,Y[c]])})})()}function fe(e){return _object_spread_props(_object_spread({},e),{entry:"entry"in e?e.entry:"",type:e.type||Ut,entryGlobalName:e.entryGlobalName||e.name,shareScope:e.shareScope||de})}function Jt(e){return _object_spread({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},e)}function kn(e,t){return t.map(function(t){var n=An(e,t.nameOrAlias);return $(n,"Unable to preload ".concat(t.nameOrAlias," as it is not included in ").concat(!n&&ge({remoteInfo:n,remotes:e}))),{remote:n,preloadConfig:Jt(t)}})}function xn(e){return e?e.map(function(e){return"."===e?e:e.startsWith("./")?e.replace("./",""):e}):[]}function Zt(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=n.cssAssets,a=n.jsAssetsWithoutEntry,i=n.entryAssets;if(t.options.inBrowser){if(i.forEach(function(n){var r=n.moduleInfo,o=t.moduleCache.get(e.name);ee(o?{origin:t,remoteInfo:r,remoteEntryExports:o.remoteEntryExports}:{origin:t,remoteInfo:r,remoteEntryExports:void 0})}),r){var c={rel:"preload",as:"style"};o.forEach(function(e){var n=ie({url:e,cb:function(){},attrs:c,createLinkHook:function(e,n){var r=t.loaderHook.lifecycle.createLink.emit({url:e,attrs:n});if(_instanceof(r,HTMLLinkElement))return r}}),r=n.link;n.needAttach&&document.head.appendChild(r)})}else{var s={rel:"stylesheet",type:"text/css"};o.forEach(function(e){var n=ie({url:e,cb:function(){},attrs:s,createLinkHook:function(e,n){var r=t.loaderHook.lifecycle.createLink.emit({url:e,attrs:n});if(_instanceof(r,HTMLLinkElement))return r},needDeleteLink:!1}),r=n.link;n.needAttach&&document.head.appendChild(r)})}if(r){var u={rel:"preload",as:"script"};a.forEach(function(e){var n=ie({url:e,cb:function(){},attrs:u,createLinkHook:function(e,n){var r=t.loaderHook.lifecycle.createLink.emit({url:e,attrs:n});if(_instanceof(r,HTMLLinkElement))return r}}),r=n.link;n.needAttach&&document.head.appendChild(r)})}else{var l={fetchpriority:"high",type:"module"===(null==e?void 0:e.type)?"module":"text/javascript"};a.forEach(function(e){var n=Se({url:e,cb:function(){},attrs:l,createScriptHook:function(e,n){var r=t.loaderHook.lifecycle.createScript.emit({url:e,attrs:n});if(_instanceof(r,HTMLScriptElement))return r},needDeleteScript:!0}),r=n.script;n.needAttach&&document.head.appendChild(r)})}}}var te=function(){function e(t){var n=t.remoteInfo,r=t.host;_class_call_check(this,e),this.inited=!1,this.lib=void 0,this.remoteInfo=n,this.host=r}return _create_class(e,[{key:"getEntry",value:function(){return _async_to_generator(function(){var e;return _ts_generator(this,function(t){switch(t.label){case 0:return this.remoteEntryExports?[2,this.remoteEntryExports]:[4,ee({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports})];case 1:return[2,(e=t.sent(),$(e,"remoteEntryExports is undefined \n ".concat(ge(this.remoteInfo))),this.remoteEntryExports=e,this.remoteEntryExports)]}})}).call(this)}},{key:"get",value:function(e,t,n,r){return _async_to_generator(function(){var o,a,i,c,s,u,l,f,_,p,h,d,m;return _ts_generator(this,function(y){switch(y.label){case 0:return o=(n||{loadFactory:!0}).loadFactory,a=void 0===o||o,[4,this.getEntry()];case 1:return i=y.sent(),this.inited?[3,5]:(c=this.host.shareScopeMap,(s=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope]).length||s.push("default"),s.forEach(function(e){c[e]||(c[e]={})}),u=c[s[0]],l=[],f={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?s:this.remoteInfo.shareScope||"default"},Object.defineProperty(f,"shareScopeMap",{value:c,enumerable:!1}),[4,this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:u,remoteEntryInitOptions:f,initScope:l,remoteInfo:this.remoteInfo,origin:this.host})]);case 2:return _=y.sent(),_type_of(null==i?void 0:i.init)>"u"&&G(A(qe,w,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),[4,i.init(_.shareScope,_.initScope,_.remoteEntryInitOptions)];case 3:return y.sent(),[4,this.host.hooks.lifecycle.initContainer.emit(_object_spread_props(_object_spread({},_),{id:e,remoteSnapshot:r,remoteEntryExports:i}))];case 4:y.sent(),y.label=5;case 5:return this.lib=i,this.inited=!0,[4,this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:i,expose:t,moduleInfo:this.remoteInfo})];case 6:return p=y.sent(),p?[3,8]:[4,i.get(t)];case 7:p=y.sent(),y.label=8;case 8:return $(p,"".concat(ce(this.remoteInfo)," remote don't export ").concat(t,".")),h=Ur(this.remoteInfo.name,t),d=this.wraperFactory(p,h),a?[4,d()]:[3,10];case 9:return m=y.sent(),[3,11];case 10:m=d,y.label=11;case 11:return[2,m]}})}).call(this)}},{key:"wraperFactory",value:function(e,t){function n(e,t){e&&"object"==(void 0===e?"undefined":_type_of(e))&&Object.isExtensible(e)&&!Object.getOwnPropertyDescriptor(e,Symbol.for("mf_module_id"))&&Object.defineProperty(e,Symbol.for("mf_module_id"),{value:t,enumerable:!1})}return _instanceof(e,Promise)?function(){return _async_to_generator(function(){var r;return _ts_generator(this,function(o){switch(o.label){case 0:return[4,e()];case 1:return[2,(n(r=o.sent(),t),r)]}})})()}:function(){var r=e();return n(r,t),r}}}]),e}(),M=function(){function e(t){_class_call_check(this,e),this.type="",this.listeners=new Set,t&&(this.type=t)}return _create_class(e,[{key:"on",value:function(e){"function"==typeof e&&this.listeners.add(e)}},{key:"once",value:function(e){var t=this;this.on(function n(){for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return t.remove(n),e.apply(null,o)})}},{key:"emit",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r;return this.listeners.size>0&&this.listeners.forEach(function(e){r=e.apply(void 0,_to_consumable_array(t))}),r}},{key:"remove",value:function(e){this.listeners.delete(e)}},{key:"removeAll",value:function(){this.listeners.clear()}}]),e}(),L=function(e){function t(){return _class_call_check(this,t),_call_super(this,t,arguments)}return _inherits(t,e),_create_class(t,[{key:"emit",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=Array.from(this.listeners);if(o.length>0){var a=0,i=function(e){return!1!==e&&(a<o.length?Promise.resolve(o[a++].apply(null,t)).then(i):e)};r=i()}return Promise.resolve(r)}}]),t}(M);function Qt(e,t){if(!at(t))return!1;if(e!==t)for(var n in e)if(!(n in t))return!1;return!0}var K=function(e){function t(e){var n;return _class_call_check(this,t),(n=_call_super(this,t)).onerror=G,n.type=e,n}return _inherits(t,e),_create_class(t,[{key:"emit",value:function(e){at(e)||G('The data for the "'.concat(this.type,'" hook should be an object.'));var t=!0,n=!1,r=void 0;try{for(var o,a=this.listeners[Symbol.iterator]();!(t=(o=a.next()).done);t=!0){var i=o.value;try{var c=i(e);if(!Qt(e,c)){this.onerror('A plugin returned an unacceptable value for the "'.concat(this.type,'" type.'));break}e=c}catch(e){Le(e),this.onerror(e)}}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}return e}}]),t}(M),C=function(e){function t(e){var n;return _class_call_check(this,t),(n=_call_super(this,t)).onerror=G,n.type=e,n}return _inherits(t,e),_create_class(t,[{key:"emit",value:function(e){var t=this;at(e)||G('The response data for the "'.concat(this.type,'" hook must be an object.'));var n=Array.from(this.listeners);if(n.length>0){var r=0,o=function(n){return Le(n),t.onerror(n),e},a=function(i){if(Qt(e,i)){if(e=i,r<n.length)try{return Promise.resolve(n[r++](e)).then(a,o)}catch(e){return o(e)}}else t.onerror('A plugin returned an incorrect value for the "'.concat(t.type,'" type.'));return e};return Promise.resolve(a(e))}return Promise.resolve(e)}}]),t}(M),B=function(){function e(t){_class_call_check(this,e),this.registerPlugins={},this.lifecycle=t,this.lifecycleKeys=Object.keys(t)}return _create_class(e,[{key:"applyPlugin",value:function(e,t){var n,r=this;$(Gr(e),"Plugin configuration is invalid.");var o=e.name;$(o,"A name must be provided by the plugin."),this.registerPlugins[o]||(this.registerPlugins[o]=e,null===(n=e.apply)||void 0===n||n.call(e,t),Object.keys(this.lifecycle).forEach(function(t){var n=e[t];n&&r.lifecycle[t].on(n)}))}},{key:"removePlugin",value:function(e){var t=this;$(e,"A name is required.");var n=this.registerPlugins[e];$(n,'The plugin "'.concat(e,'" is not registered.')),Object.keys(n).forEach(function(e){"name"!==e&&t.lifecycle[e].remove(n[e])})}}]),e}();function er(e,t){var n=Dt(t);n.url||G("The attribute remoteEntry of ".concat(e.name," must not be undefined."));var r=se(t,n.url);!x()&&!r.startsWith("http")&&(r="https:".concat(r)),e.type=n.type,e.entryGlobalName=n.globalName,e.entry=r,e.version=t.version,e.buildVersion=t.buildVersion}function Hn(){return{name:"snapshot-plugin",afterResolve:function(e){return _async_to_generator(function(){var t,n,r,o,a,i,c,s,u,l,f;return _ts_generator(this,function(_){switch(_.label){case 0:return t=e.remote,n=e.pkgNameOrAlias,r=e.expose,o=e.origin,a=e.remoteInfo,i=e.id,it(t)&&Lt(t)?[3,3]:[4,o.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:i})];case 1:return c=_.sent(),s=c.remoteSnapshot,u=c.globalSnapshot,er(a,s),l={remote:t,preloadConfig:{nameOrAlias:n,exposes:[r],resourceCategory:"sync",share:!1,depsRemote:!1}},[4,o.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:l,remoteInfo:a,remote:t,remoteSnapshot:s,globalSnapshot:u})];case 2:return[2,((f=_.sent())&&Zt(a,o,f,!1),_object_spread_props(_object_spread({},e),{remoteSnapshot:s}))];case 3:return[2,e]}})})()}}}function Cn(e){var t=e.split(":");return 1===t.length?{name:t[0],version:void 0}:2===t.length?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function tr(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=arguments.length>5?arguments[5]:void 0,i=Z(e,ce(t)).value,c=a||i;if(c&&!be(c)&&(n(c,t,r),c.remotesInfo)){var s=Object.keys(c.remotesInfo),u=!0,l=!1,f=void 0;try{for(var _,p=s[Symbol.iterator]();!(u=(_=p.next()).done);u=!0){var h=_.value;if(!o[h]){o[h]=!0;var d=Cn(h),m=c.remotesInfo[h];tr(e,{name:d.name,version:m.matchedVersion},n,!1,o,void 0)}}}catch(e){l=!0,f=e}finally{try{u||null==p.return||p.return()}finally{if(l)throw f}}}}var et=function(e,t){return document.querySelector("".concat(e,"[").concat("link"===e?"href":"src",'="').concat(t,'"]'))};function Gn(e,t,n,r,o){var a=[],i=[],c=[],s=new Set,u=new Set,l=e.options,f=t.preloadConfig,_=f.depsRemote;if(tr(r,n,function(t,n,r){var o,s,u=function(e){var n=e.map(function(e){return se(t,e)});return s.filter?n.filter(s.filter):n};if(r)s=f;else if(Array.isArray(_)){var l=_.find(function(e){return e.nameOrAlias===n.name||e.nameOrAlias===n.alias});if(!l)return;s=Jt(l)}else{if(!0!==_)return;s=f}var p=se(t,Dt(t).url);p&&c.push({name:n.name,moduleInfo:{name:n.name,entry:p,type:"remoteEntryType"in t?t.remoteEntryType:"global",entryGlobalName:"globalName"in t?t.globalName:n.name,shareScope:"",version:"version"in t?t.version:void 0},url:p});var h="modules"in t?t.modules:[],d=xn(s.exposes);if(d.length&&"modules"in t&&(h=null==t||null===(o=t.modules)||void 0===o?void 0:o.reduce(function(e,t){return-1!==(null==d?void 0:d.indexOf(t.moduleName))&&e.push(t),e},[])),h)for(var m=h.length,y=0;y<m;y++){var v,g,b,E,S,I,N=h[y],w="".concat(n.name,"/").concat(N.moduleName);e.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:"."===N.moduleName?n.name:w,name:n.name,remoteSnapshot:t,preloadConfig:s,remote:n,origin:e}),!Wr(w)&&("all"===s.resourceCategory?((v=a).push.apply(v,_to_consumable_array(u(N.assets.css.async))),(g=a).push.apply(g,_to_consumable_array(u(N.assets.css.sync))),(b=i).push.apply(b,_to_consumable_array(u(N.assets.js.async))),(E=i).push.apply(E,_to_consumable_array(u(N.assets.js.sync)))):(s.resourceCategory="sync")&&((S=a).push.apply(S,_to_consumable_array(u(N.assets.css.sync))),(I=i).push.apply(I,_to_consumable_array(u(N.assets.js.sync)))),Kr(w))}},!0,{},o),o.shared&&o.shared.length>0){o.shared.forEach(function(t){var n,r=null===(n=l.shared)||void 0===n?void 0:n[t.sharedName];if(r){var o=t.version?r.find(function(e){return e.version===t.version}):r;o&&Ft(o).forEach(function(n){!function(t,n){var r=ve(e.shareScopeMap,n.sharedName,t,e.sharedHandler.hooks.lifecycle.resolveShare);r&&"function"==typeof r.lib&&(n.assets.js.sync.forEach(function(e){s.add(e)}),n.assets.css.sync.forEach(function(e){u.add(e)}))}(n,t)})}})}var p=i.filter(function(e){return!s.has(e)&&!et("script",e)});return{cssAssets:a.filter(function(e){return!u.has(e)&&!et("link",e)}),jsAssetsWithoutEntry:p,entryAssets:c.filter(function(e){return!et("script",e.url)})}}var Un=function(){return{name:"generate-preload-assets-plugin",generatePreloadAssets:function(e){return _async_to_generator(function(){var t,n,r,o,a,i;return _ts_generator(this,function(c){return t=e.origin,n=e.preloadOptions,r=e.remoteInfo,o=e.remote,a=e.globalSnapshot,i=e.remoteSnapshot,[2,x()?it(o)&&Lt(o)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:o.name,url:o.entry,moduleInfo:{name:r.name,entry:o.entry,type:r.type||"global",entryGlobalName:"",shareScope:""}}]}:(er(r,i),Gn(t,n,r,a,i)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}]})})()}}};function rr(e,t){var n=Oe({name:t.name,version:t.options.version}),r=n&&"remotesInfo"in n&&n.remotesInfo&&Z(n.remotesInfo,e.name).value;return r&&r.matchedVersion?{hostGlobalSnapshot:n,globalSnapshot:Nt(),remoteSnapshot:Oe({name:e.name,version:r.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:Nt(),remoteSnapshot:Oe({name:e.name,version:"version"in e?e.version:void 0})}}var nt=function(){function e(t){_class_call_check(this,e),this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new B({beforeLoadRemoteSnapshot:new L("beforeLoadRemoteSnapshot"),loadSnapshot:new C("loadGlobalSnapshot"),loadRemoteSnapshot:new C("loadRemoteSnapshot"),afterLoadSnapshot:new C("afterLoadSnapshot")}),this.manifestLoading=le.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=t,this.loaderHook=t.loaderHook}return _create_class(e,[{key:"loadRemoteSnapshotInfo",value:function(e){return _async_to_generator(function(e){var t,n,r,o,a,i,c,s,u,l,f,_,p,h,d,m,y,v,g,b,E,S,I;return _ts_generator(this,function(N){switch(N.label){case 0:return t=e.moduleInfo,n=e.id,e.expose,r=this.HostInstance,o=r.options,[4,this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:o,moduleInfo:t})];case 1:return N.sent(),(a=Oe({name:this.HostInstance.options.name,version:this.HostInstance.options.version}))||(a={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},jr(_define_property({},this.HostInstance.options.name,a))),a&&"remotesInfo"in a&&!Z(a.remotesInfo,t.name).value&&("version"in t||"entry"in t)&&(a.remotesInfo=_object_spread_props(_object_spread({},null==a?void 0:a.remotesInfo),_define_property({},t.name,{matchedVersion:"version"in t?t.version:t.entry}))),i=this.getGlobalRemoteInfo(t),c=i.hostGlobalSnapshot,s=i.remoteSnapshot,u=i.globalSnapshot,[4,this.hooks.lifecycle.loadSnapshot.emit({options:o,moduleInfo:t,hostGlobalSnapshot:c,remoteSnapshot:s,globalSnapshot:u})];case 2:return l=N.sent(),f=l.remoteSnapshot,_=l.globalSnapshot,f?be(f)?(d=x()?f.remoteEntry:f.ssrRemoteEntry||f.remoteEntry||"",[4,this.getManifestJson(d,t,{})]):[3,4]:[3,7];case 3:return m=N.sent(),y=Tt(_object_spread_props(_object_spread({},t),{entry:d}),m),p=m,h=y,[3,6];case 4:return[4,this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:f,from:"global"})];case 5:v=N.sent(),g=v.remoteSnapshot,p=g,h=_,N.label=6;case 6:return[3,11];case 7:return it(t)?[4,this.getManifestJson(t.entry,t,{})]:[3,10];case 8:return b=N.sent(),E=Tt(t,b),[4,this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,remoteSnapshot:b,from:"global"})];case 9:return S=N.sent(),I=S.remoteSnapshot,p=I,h=E,[3,11];case 10:G(A(Je,w,{hostName:t.name,hostVersion:t.version,globalSnapshot:JSON.stringify(_)})),N.label=11;case 11:return[4,this.hooks.lifecycle.afterLoadSnapshot.emit({id:n,host:this.HostInstance,options:o,moduleInfo:t,remoteSnapshot:p})];case 12:return[2,(N.sent(),{remoteSnapshot:p,globalSnapshot:h})]}})}).apply(this,arguments)}},{key:"getGlobalRemoteInfo",value:function(e){return rr(e,this.HostInstance)}},{key:"getManifestJson",value:function(e,t,n){return _async_to_generator(function(){var n,r,o;return _ts_generator(this,function(a){return n=this,r=function(){return _async_to_generator(function(){var n,r,o;return _ts_generator(this,function(a){switch(a.label){case 0:if(n=this.manifestCache.get(e))return[2,n];a.label=1;case 1:return a.trys.push([1,6,,8]),[4,this.loaderHook.lifecycle.fetch.emit(e,{})];case 2:return r=a.sent(),!r||!_instanceof(r,Response)?[4,fetch(e,{})]:[3,4];case 3:r=a.sent(),a.label=4;case 4:return[4,r.json()];case 5:return n=a.sent(),[3,8];case 6:return o=a.sent(),[4,this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:e,error:o,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance})];case 7:return(n=a.sent())||(delete this.manifestLoading[e],G(A(ze,w,{manifestUrl:e,moduleName:t.name,hostName:this.HostInstance.options.name},"".concat(o)))),[3,8];case 8:return[2,($(n.metaData&&n.exposes&&n.shared,"".concat(e," is not a federation manifest")),this.manifestCache.set(e,n),n)]}})}).call(n)},o=function(){return _async_to_generator(function(){var n,o,a;return _ts_generator(this,function(i){switch(i.label){case 0:return[4,r()];case 1:return n=i.sent(),o=Ve(n,{version:e}),[4,this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,manifestJson:n,remoteSnapshot:o,manifestUrl:e,from:"manifest"})];case 2:return a=i.sent(),[2,a.remoteSnapshot]}})}).call(n)},[2,(this.manifestLoading[e]||(this.manifestLoading[e]=o().then(function(e){return e})),this.manifestLoading[e])]})}).call(this)}}]),e}(),ot=function(){function e(t){_class_call_check(this,e),this.hooks=new B({afterResolve:new C("afterResolve"),beforeLoadShare:new C("beforeLoadShare"),loadShare:new L,resolveShare:new K("resolveShare"),initContainerShareScopeMap:new K("initContainerShareScopeMap")}),this.host=t,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(t.options)}return _create_class(e,[{key:"registerShared",value:function(e,t){var n=this,r=qt(e,t),o=r.shareInfos,a=r.shared;return Object.keys(o).forEach(function(e){o[e].forEach(function(r){r.scope.forEach(function(o){var a;(null===(a=n.shareScopeMap[o])||void 0===a?void 0:a[e])||n.setShared({pkgName:e,lib:r.lib,get:r.get,loaded:r.loaded||!!r.lib,shared:r,from:t.name})})})}),{shareInfos:o,shared:a}}},{key:"loadShare",value:function(e,t){return _async_to_generator(function(){var n,r,o,a,i,c,s,u,l,f;return _ts_generator(this,function(_){switch(_.label){case 0:return n=this,r=this.host,o=vt({pkgName:e,extraOptions:t,shareInfos:r.options.shared}),(null==o?void 0:o.scope)?[4,Promise.all(o.scope.map(function(e){return _async_to_generator(function(){return _ts_generator(this,function(t){switch(t.label){case 0:return[4,Promise.all(this.initializeSharing(e,{strategy:o.strategy}))];case 1:return t.sent(),[2]}})}).call(n)}))]:[3,2];case 1:_.sent(),_.label=2;case 2:return[4,this.hooks.lifecycle.beforeLoadShare.emit({pkgName:e,shareInfo:o,shared:r.options.shared,origin:r})];case 3:return a=_.sent(),$(i=a.shareInfo,"Cannot find ".concat(e," Share in the ").concat(r.options.name,". Please ensure that the ").concat(e," Share parameters have been injected")),c=ve(this.shareScopeMap,e,i,this.hooks.lifecycle.resolveShare),s=function(e){e.useIn||(e.useIn=[]),$t(e.useIn,r.options.name)},c&&c.lib?[2,(s(c),c.lib)]:c&&c.loading&&!c.loaded?[4,c.loading]:[3,5];case 4:return u=_.sent(),[2,(c.loaded=!0,c.lib||(c.lib=u),s(c),u)];case 5:return c?(l=_async_to_generator(function(){var e;return _ts_generator(this,function(t){switch(t.label){case 0:return[4,c.get()];case 1:return e=t.sent(),[2,(s(c),c.loaded=!0,c.lib=e,e)]}})})(),[2,(this.setShared({pkgName:e,loaded:!1,shared:c,from:r.options.name,lib:null,loading:l}),l)]):(null==t?void 0:t.customShareInfo)?[2,!1]:(f=_async_to_generator(function(){var t,n;return _ts_generator(this,function(r){switch(r.label){case 0:return[4,i.get()];case 1:return t=r.sent(),i.lib=t,i.loaded=!0,s(i),[2,((n=ve(this.shareScopeMap,e,i,this.hooks.lifecycle.resolveShare))&&(n.lib=t,n.loaded=!0,n.from=i.from),t)]}})}).call(n),[2,(this.setShared({pkgName:e,loaded:!1,shared:i,from:r.options.name,lib:null,loading:f}),f)]);case 6:return[2]}})}).call(this)}},{key:"initializeSharing",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:de,t=arguments.length>1?arguments[1]:void 0,n=this.host,r=null==t?void 0:t.from,o=null==t?void 0:t.strategy,a=null==t?void 0:t.initScope,i=[];if("build"!==r){var c=this.initTokens;a||(a=[]);var s=c[e];if(s||(s=c[e]={from:this.host.name}),a.indexOf(s)>=0)return i;a.push(s)}var u=this.shareScopeMap,l=n.options.name;u[e]||(u[e]={});var f=u[e],_=function(t){return t&&t.init&&t.init(u[e],a)};return Object.keys(n.options.shared).forEach(function(t){n.options.shared[t].forEach(function(n){n.scope.includes(e)&&function(e,t){var n,r=t.version,o=t.eager;f[e]=f[e]||{};var a=f[e],i=a[r],c=!(!i||!i.eager&&!(null===(n=i.shareConfig)||void 0===n?void 0:n.eager));(!i||"loaded-first"!==i.strategy&&!i.loaded&&(!o!=!c?o:l>i.from))&&(a[r]=t)}(t,n)})}),("version-first"===n.options.shareStrategy||"version-first"===o)&&n.options.remotes.forEach(function(t){t.shareScope===e&&i.push(function(e){return _async_to_generator(function(){var t,r,o,a;return _ts_generator(this,function(i){switch(i.label){case 0:return[4,n.remoteHandler.getRemoteModuleAndOptions({id:e})];case 1:if(t=i.sent(),!(r=t.module).getEntry)return[3,9];i.label=2;case 2:return i.trys.push([2,4,,6]),[4,r.getEntry()];case 3:return o=i.sent(),[3,6];case 4:return a=i.sent(),[4,n.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:e,error:a,from:"runtime",lifecycle:"beforeLoadShare",origin:n})];case 5:return o=i.sent(),[3,6];case 6:return r.inited?[3,8]:[4,_(o)];case 7:i.sent(),r.inited=!0,i.label=8;case 8:i.label=9;case 9:return[2]}})})()}(t.name))}),i}},{key:"loadShareSync",value:function(e,t){var n=this,r=this.host,o=vt({pkgName:e,extraOptions:t,shareInfos:r.options.shared});(null==o?void 0:o.scope)&&o.scope.forEach(function(e){n.initializeSharing(e,{strategy:o.strategy})});var a=ve(this.shareScopeMap,e,o,this.hooks.lifecycle.resolveShare),i=function(e){e.useIn||(e.useIn=[]),$t(e.useIn,r.options.name)};if(a){if("function"==typeof a.lib)return i(a),a.loaded||(a.loaded=!0,a.from===r.options.name&&(o.loaded=!0)),a.lib;if("function"==typeof a.get){var c=a.get();if(!_instanceof(c,Promise))return i(a),this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:c,shared:a}),c}}if(o.lib)return o.loaded||(o.loaded=!0),o.lib;if(o.get){var s=o.get();if(_instanceof(s,Promise)){var u="build"===(null==t?void 0:t.from)?Ye:Ie;throw new Error(A(u,w,{hostName:r.options.name,sharedPkgName:e}))}return o.lib=s,this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:o.lib,shared:o}),o.lib}throw new Error(A(Ie,w,{hostName:r.options.name,sharedPkgName:e}))}},{key:"initShareScopeMap",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.host;this.shareScopeMap[e]=t,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:t,options:r.options,origin:r,scopeName:e,hostShareScopeMap:n.hostShareScopeMap})}},{key:"setShared",value:function(e){var t=this,n=e.pkgName,r=e.shared,o=e.from,a=e.lib,i=e.loading,c=e.loaded,s=e.get,u=r.version,l=r.scope,f=void 0===l?"default":l,_=_object_without_properties(r,["version","scope"]);(Array.isArray(f)?f:[f]).forEach(function(e){if(t.shareScopeMap[e]||(t.shareScopeMap[e]={}),t.shareScopeMap[e][n]||(t.shareScopeMap[e][n]={}),!t.shareScopeMap[e][n][u])return t.shareScopeMap[e][n][u]=_object_spread_props(_object_spread({version:u,scope:[e]},_),{lib:a,loaded:c,loading:i}),void(s&&(t.shareScopeMap[e][n][u].get=s));var r=t.shareScopeMap[e][n][u];i&&!r.loading&&(r.loading=i),c&&!r.loaded&&(r.loaded=c),o&&r.from!==o&&(r.from=o)})}},{key:"_setGlobalShareScopeMap",value:function(e){var t=zt(),n=e.id||e.name;n&&!t[n]&&(t[n]=this.shareScopeMap)}}]),e}(),st=function(){function e(t){_class_call_check(this,e),this.hooks=new B({beforeRegisterRemote:new K("beforeRegisterRemote"),registerRemote:new K("registerRemote"),beforeRequest:new C("beforeRequest"),onLoad:new L("onLoad"),handlePreloadModule:new M("handlePreloadModule"),errorLoadRemote:new L("errorLoadRemote"),beforePreloadRemote:new L("beforePreloadRemote"),generatePreloadAssets:new L("generatePreloadAssets"),afterPreloadRemote:new L,loadEntry:new L}),this.host=t,this.idToRemoteMap={}}return _create_class(e,[{key:"formatAndRegisterRemote",value:function(e,t){var n=this;return(t.remotes||[]).reduce(function(e,t){return n.registerRemote(t,e,{force:!1}),e},e.remotes)}},{key:"setIdToRemoteMap",value:function(e,t){var n=t.remote,r=t.expose,o=n.name,a=n.alias;if(this.idToRemoteMap[e]={name:n.name,expose:r},a&&e.startsWith(o)){var i=e.replace(o,a);this.idToRemoteMap[i]={name:n.name,expose:r}}else if(a&&e.startsWith(a)){var c=e.replace(a,o);this.idToRemoteMap[c]={name:n.name,expose:r}}}},{key:"loadRemote",value:function(e,t){return _async_to_generator(function(){var n,r,o,a,i,c,s,u,l,f,_,p,h,d,m,y,v,g;return _ts_generator(this,function(b){switch(b.label){case 0:n=this.host,b.label=1;case 1:return b.trys.push([1,5,,7]),r=(t||{loadFactory:!0}).loadFactory,o=void 0===r||r,[4,this.getRemoteModuleAndOptions({id:e})];case 2:return a=b.sent(),i=a.module,c=a.moduleOptions,s=a.remoteMatchInfo,u=s.pkgNameOrAlias,l=s.remote,f=s.expose,_=s.id,p=s.remoteSnapshot,[4,i.get(_,f,t,p)];case 3:return h=b.sent(),[4,this.hooks.lifecycle.onLoad.emit({id:_,pkgNameOrAlias:u,expose:f,exposeModule:o?h:void 0,exposeModuleFactory:o?void 0:h,remote:l,options:c,moduleInstance:i,origin:n})];case 4:return d=b.sent(),[2,(this.setIdToRemoteMap(e,s),"function"==typeof d?d:h)];case 5:return m=b.sent(),y=(t||{from:"runtime"}).from,v=void 0===y?"runtime":y,[4,this.hooks.lifecycle.errorLoadRemote.emit({id:e,error:m,from:v,lifecycle:"onLoad",origin:n})];case 6:if(!(g=b.sent()))throw m;return[2,g];case 7:return[2]}})}).call(this)}},{key:"preloadRemote",value:function(e){return _async_to_generator(function(){var t,n,r;return _ts_generator(this,function(o){switch(o.label){case 0:return t=this,n=this.host,[4,this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:e,options:n.options,origin:n})];case 1:return o.sent(),r=kn(n.options.remotes,e),[4,Promise.all(r.map(function(e){return _async_to_generator(function(){var t,r,o,a,i,c;return _ts_generator(this,function(s){switch(s.label){case 0:return t=e.remote,r=fe(t),[4,n.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t})];case 1:return o=s.sent(),a=o.globalSnapshot,i=o.remoteSnapshot,[4,this.hooks.lifecycle.generatePreloadAssets.emit({origin:n,preloadOptions:e,remote:t,remoteInfo:r,globalSnapshot:a,remoteSnapshot:i})];case 2:return(c=s.sent())&&Zt(r,n,c),[2]}})}).call(t)}))];case 2:return o.sent(),[2]}})}).call(this)}},{key:"registerRemotes",value:function(e,t){var n=this,r=this.host;e.forEach(function(e){n.registerRemote(e,r.options.remotes,{force:null==t?void 0:t.force})})}},{key:"getRemoteModuleAndOptions",value:function(e){return _async_to_generator(function(){var t,n,r,o,a,i,c,s,u,l,f,_,p;return _ts_generator(this,function(h){switch(h.label){case 0:t=this.host,n=e.id,h.label=1;case 1:return h.trys.push([1,3,,5]),[4,this.hooks.lifecycle.beforeRequest.emit({id:n,options:t.options,origin:t})];case 2:return r=h.sent(),[3,5];case 3:return o=h.sent(),[4,this.hooks.lifecycle.errorLoadRemote.emit({id:n,options:t.options,origin:t,from:"runtime",error:o,lifecycle:"beforeRequest"})];case 4:if(!(r=h.sent()))throw o;return[3,5];case 5:return a=r.id,$(i=On(t.options.remotes,a),A(Xe,w,{hostName:t.options.name,requestId:a})),c=i.remote,s=fe(c),[4,t.sharedHandler.hooks.lifecycle.afterResolve.emit(_object_spread_props(_object_spread({id:a},i),{options:t.options,origin:t,remoteInfo:s}))];case 6:return u=h.sent(),l=u.remote,f=u.expose,$(l&&f,"The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ".concat(a,".")),_=t.moduleCache.get(l.name),p={host:t,remoteInfo:s},[2,(_||(_=new te(p),t.moduleCache.set(l.name,_)),{module:_,moduleOptions:p,remoteMatchInfo:u})]}})}).call(this)}},{key:"registerRemote",value:function(e,t,n){var r=this.host,o=function(){if(e.alias){var n=t.find(function(t){var n;return e.alias&&(t.name.startsWith(e.alias)||(null===(n=t.alias)||void 0===n?void 0:n.startsWith(e.alias)))});$(!n,"The alias ".concat(e.alias," of remote ").concat(e.name," is not allowed to be the prefix of ").concat(n&&n.name," name or alias"))}"entry"in e&&x()&&!e.entry.startsWith("http")&&(e.entry=new URL(e.entry,window.location.origin).href),e.shareScope||(e.shareScope=de),e.type||(e.type=Ut)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:e,origin:r});var a=t.find(function(t){return t.name===e.name});if(a){var i=['The remote "'.concat(e.name,'" is already registered.'),"Please note that overriding it may cause unexpected errors."];(null==n?void 0:n.force)&&(this.removeRemote(a),o(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:r}),Ee(i.join(" ")))}else o(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:r})}},{key:"removeRemote",value:function(e){try{var t=this.host,n=e.name,r=t.options.remotes.findIndex(function(e){return e.name===n});-1!==r&&t.options.remotes.splice(r,1);var o=t.moduleCache.get(e.name);if(o){var a,i=o.remoteInfo,c=i.entryGlobalName;N[c]&&((null===(a=Object.getOwnPropertyDescriptor(N,c))||void 0===a?void 0:a.configurable)?delete N[c]:N[c]=void 0);var s=rt(o.remoteInfo);Y[s]&&delete Y[s],t.snapshotHandler.manifestCache.delete(i.entry);var u=i.buildVersion?_e(i.name,i.buildVersion):i.name,l=N.__FEDERATION__.__INSTANCES__.findIndex(function(e){return i.buildVersion?e.options.id===u:e.name===u});if(-1!==l){var f=N.__FEDERATION__.__INSTANCES__[l];u=f.options.id||u;var _=zt(),p=!0,h=[];Object.keys(_).forEach(function(e){var t=_[e];t&&Object.keys(t).forEach(function(n){var r=t[n];r&&Object.keys(r).forEach(function(t){var o=r[t];o&&Object.keys(o).forEach(function(r){var a=o[r];a&&"object"==(void 0===a?"undefined":_type_of(a))&&a.from===i.name&&(a.loaded||a.loading?(a.useIn=a.useIn.filter(function(e){return e!==i.name}),a.useIn.length?p=!1:h.push([e,n,t,r])):h.push([e,n,t,r]))})})})}),p&&(f.shareScopeMap={},delete _[u]),h.forEach(function(e){var t,n,r,o=_sliced_to_array(e,4),a=o[0],i=o[1],c=o[2],s=o[3];null===(r=_[a])||void 0===r||(null===(n=r[i])||void 0===n||(null===(t=n[c])||void 0===t||delete t[s]))}),N.__FEDERATION__.__INSTANCES__.splice(l,1)}var d=rr(e,t).hostGlobalSnapshot;if(d){var m=d&&"remotesInfo"in d&&d.remotesInfo&&Z(d.remotesInfo,e.name).key;m&&(delete d.remotesInfo[m],le.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete le.__FEDERATION__.__MANIFEST_LOADING__[m])}t.moduleCache.delete(e.name)}}catch(e){tt.log("removeRemote fail: ",e)}}}]),e}(),Vn="boolean"!=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN||!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN,q=function(){function e(t){_class_call_check(this,e),this.hooks=new B({beforeInit:new K("beforeInit"),init:new M,beforeInitContainer:new C("beforeInitContainer"),initContainer:new C("initContainer")}),this.version="0.21.4",this.moduleCache=new Map,this.loaderHook=new B({getModuleInfo:new M,createScript:new M,createLink:new M,fetch:new L,loadEntryError:new L,getModuleFactory:new L}),this.bridgeHook=new B({beforeBridgeRender:new M,afterBridgeRender:new M,beforeBridgeDestroy:new M,afterBridgeDestroy:new M});var n=Vn?[Hn(),Un()]:[],r={id:wn(),name:t.name,plugins:n,remotes:[],shared:{},inBrowser:x()};this.name=t.name,this.options=r,this.snapshotHandler=new nt(this),this.sharedHandler=new ot(this),this.remoteHandler=new st(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins(_to_consumable_array(r.plugins).concat(_to_consumable_array(t.plugins||[]))),this.options=this.formatOptions(r,t)}return _create_class(e,[{key:"initOptions",value:function(e){this.registerPlugins(e.plugins);var t=this.formatOptions(this.options,e);return this.options=t,t}},{key:"loadShare",value:function(e,t){return _async_to_generator(function(){return _ts_generator(this,function(n){return[2,this.sharedHandler.loadShare(e,t)]})}).call(this)}},{key:"loadShareSync",value:function(e,t){return this.sharedHandler.loadShareSync(e,t)}},{key:"initializeSharing",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:de,t=arguments.length>1?arguments[1]:void 0;return this.sharedHandler.initializeSharing(e,t)}},{key:"initRawContainer",value:function(e,t,n){var r=fe({name:e,entry:t}),o=new te({host:this,remoteInfo:r});return o.remoteEntryExports=n,this.moduleCache.set(e,o),o}},{key:"loadRemote",value:function(e,t){return _async_to_generator(function(){return _ts_generator(this,function(n){return[2,this.remoteHandler.loadRemote(e,t)]})}).call(this)}},{key:"preloadRemote",value:function(e){return _async_to_generator(function(){return _ts_generator(this,function(t){return[2,this.remoteHandler.preloadRemote(e)]})}).call(this)}},{key:"initShareScopeMap",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.sharedHandler.initShareScopeMap(e,t,n)}},{key:"formatOptions",value:function(e,t){var n=qt(e,t).shared,r=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:t,options:e,shareInfo:n}),o=r.userOptions,a=r.options,i=this.remoteHandler.formatAndRegisterRemote(a,o),c=this.sharedHandler.registerShared(a,o).shared,s=_to_consumable_array(a.plugins);o.plugins&&o.plugins.forEach(function(e){s.includes(e)||s.push(e)});var u=_object_spread_props(_object_spread({},e,t),{plugins:s,remotes:i,shared:c});return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}},{key:"registerPlugins",value:function(e){var t=Pn(e,this);this.options.plugins=this.options.plugins.reduce(function(e,t){return t&&e&&!e.find(function(e){return e.name===t.name})&&e.push(t),e},t||[])}},{key:"registerRemotes",value:function(e,t){return this.remoteHandler.registerRemotes(e,t)}},{key:"registerShared",value:function(e){this.sharedHandler.registerShared(this.options,_object_spread_props(_object_spread({},this.options),{shared:e}))}}]),e}();function jn(){return("undefined"==typeof FEDERATION_BUILD_IDENTIFIER?"undefined":_type_of(FEDERATION_BUILD_IDENTIFIER))<"u"?FEDERATION_BUILD_IDENTIFIER:""}function nr(e,t){var n=jn();return N.__FEDERATION__.__INSTANCES__.find(function(r){return!!(n&&r.options.id===n||r.options.name===e&&!r.options.version&&!t||r.options.name===e&&t&&r.options.version===t)})}function or(e){var t=new(Ht()||q)(e);return xt(t),t}var R=null;function Bn(e){var t=nr(e.name,e.version);return t?(t.initOptions(e),R||(R=t),t):R=or(e)}function Wn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $(R,A(j,w)),R.loadRemote.apply(R,t)}function Kn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $(R,A(j,w)),R.loadShare.apply(R,t)}function qn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $(R,A(j,w)),R.loadShareSync.apply(R,t)}function zn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $(R,A(j,w)),R.preloadRemote.apply(R,t)}function Xn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $(R,A(j,w)),R.registerRemotes.apply(R,t)}function Yn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $(R,A(j,w)),R.registerPlugins.apply(R,t)}function Jn(){return R}function Zn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $(R,A(j,w)),R.registerShared.apply(R,t)}return Ct(q),exports.MFRuntime=ht,exports.MFSDK=We,exports}({});
|
|
1
|
+
var EMP_SHARE_RUNTIME=function(exports){"use strict";var bt=Object.defineProperty,pr=Object.defineProperties,mr=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,Rt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,gt=(e,t,r)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,R=(e,t)=>{for(var r in t||(t={}))Rt.call(t,r)&>(e,r,t[r]);if(ye)for(var r of ye(t))St.call(t,r)&>(e,r,t[r]);return e},M=(e,t)=>pr(e,mr(t)),xe=(e,t)=>{var r={};for(var o in e)Rt.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&ye)for(var o of ye(e))t.indexOf(o)<0&&St.call(e,o)&&(r[o]=e[o]);return r},It=(e,t)=>{for(var r in t)bt(e,r,{get:t[r],enumerable:!0})},Et={};It(Et,{Module:()=>oe,ModuleFederation:()=>Y,createInstance:()=>hr,getInstance:()=>ao,getRemoteEntry:()=>ne,getRemoteInfo:()=>pe,init:()=>eo,loadRemote:()=>to,loadScript:()=>J,loadScriptNode:()=>Z,loadShare:()=>ro,loadShareSync:()=>no,preloadRemote:()=>oo,registerGlobalPlugins:()=>Xt,registerPlugins:()=>io,registerRemotes:()=>so,registerShared:()=>co});var Ye={};It(Ye,{BROWSER_LOG_KEY:()=>$t,ENCODE_NAME_PREFIX:()=>gr,EncodedNameTransformMap:()=>Ee,FederationModuleManifest:()=>yr,MANIFEST_EXT:()=>Be,MFModuleType:()=>_r,MFPrefetchCommon:()=>Rr,MODULE_DEVTOOL_IDENTIFIER:()=>Er,ManifestFileName:()=>Ue,NameTransformMap:()=>k,NameTransformSymbol:()=>w,SEPARATOR:()=>We,StatsFileName:()=>je,TEMP_DIR:()=>br,assert:()=>Mr,bindLoggerToCompiler:()=>Hr,composeKeyWithSeparator:()=>Re,containerPlugin:()=>Sr,containerReferencePlugin:()=>Ir,createInfrastructureLogger:()=>Ot,createLink:()=>le,createLogger:()=>Ne,createModuleFederationConfig:()=>jr,createScript:()=>Te,createScriptNode:()=>Lt,decodeName:()=>Ar,encodeName:()=>Ke,error:()=>wt,generateExposeFilename:()=>Pr,generateShareFilename:()=>Or,generateSnapshotFromManifest:()=>qe,getManifestFileName:()=>vr,getProcessEnv:()=>Nt,getResourceUrl:()=>ce,inferAutoPublicPath:()=>At,infrastructureLogger:()=>xr,isBrowserEnv:()=>U,isDebugMode:()=>ae,isManifestProvider:()=>$e,isReactNativeEnv:()=>be,isRequiredVersion:()=>Fr,isStaticResourcesEqual:()=>Xe,loadScript:()=>J,loadScriptNode:()=>Z,logger:()=>Cr,moduleFederationPlugin:()=>$r,normalizeOptions:()=>Ur,parseEntry:()=>wr,safeToString:()=>Ie,safeWrapper:()=>ze,sharePlugin:()=>Nr,simpleJoinRemoteEntry:()=>z,warn:()=>Se});var yr="federation-manifest.json",Be=".json",$t="FEDERATION_DEBUG",w={AT:"@",HYPHEN:"-",SLASH:"/"},k={[w.AT]:"scope_",[w.HYPHEN]:"_",[w.SLASH]:"__"},Ee={[k[w.AT]]:w.AT,[k[w.HYPHEN]]:w.HYPHEN,[k[w.SLASH]]:w.SLASH},We=":",Ue="mf-manifest.json",je="mf-stats.json",_r={NPM:"npm",APP:"app"},Er="__MF_DEVTOOLS_MODULE_INFO__",gr="ENCODE_NAME_PREFIX",br=".federation",Rr={identifier:"MFDataPrefetch",globalKey:"__PREFETCH__",library:"mf-data-prefetch",exportsKey:"__PREFETCH_EXPORTS__",fileName:"bootstrap.js"},Sr=Object.freeze({__proto__:null}),Ir=Object.freeze({__proto__:null}),$r=Object.freeze({__proto__:null}),Nr=Object.freeze({__proto__:null});function U(){return"undefined"!=typeof window&&void 0!==window.document}function be(){return"undefined"!=typeof navigator&&"ReactNative"===(null==navigator?void 0:navigator.product)}function Tr(){try{if(U()&&window.localStorage)return!!localStorage.getItem($t)}catch(e){return!1}return!1}function ae(){return"undefined"!=typeof process&&process.env,Tr()}var Nt=function(){return"undefined"!=typeof process&&process.env?process.env:{}},Tt="[ Federation Runtime ]",wr=(e,t,r=We)=>{let o=e.split(r),n="development"===Nt().NODE_ENV&&t,i=e=>e.startsWith("http")||e.includes(Be);if(o.length>=2){let[t,...a]=o;e.startsWith(r)&&(t=o.slice(0,2).join(r),a=[n||o.slice(2).join(r)]);let s=n||a.join(r);return i(s)?{name:t,entry:s}:{name:t,version:s||"*"}}if(1===o.length){let[e]=o;return n&&i(n)?{name:e,entry:n}:{name:e,version:n||"*"}}throw`Invalid entry value: ${e}`},Re=function(...e){return e.length?e.reduce((e,t)=>t?e?`${e}${We}${t}`:t:e,""):""},Ke=function(e,t="",r=!1){try{let o=r?".js":"";return`${t}${e.replace(new RegExp(`${w.AT}`,"g"),k[w.AT]).replace(new RegExp(`${w.HYPHEN}`,"g"),k[w.HYPHEN]).replace(new RegExp(`${w.SLASH}`,"g"),k[w.SLASH])}${o}`}catch(e){throw e}},Ar=function(e,t,r){try{let o=e;if(t){if(!o.startsWith(t))return o;o=o.replace(new RegExp(t,"g"),"")}return o=o.replace(new RegExp(`${k[w.AT]}`,"g"),Ee[k[w.AT]]).replace(new RegExp(`${k[w.SLASH]}`,"g"),Ee[k[w.SLASH]]).replace(new RegExp(`${k[w.HYPHEN]}`,"g"),Ee[k[w.HYPHEN]]),r&&(o=o.replace(".js","")),o}catch(e){throw e}},Pr=(e,t)=>{if(!e)return"";let r=e;return"."===r&&(r="default_export"),r.startsWith("./")&&(r=r.replace("./","")),Ke(r,"__federation_expose_",t)},Or=(e,t)=>e?Ke(e,"__federation_shared_",t):"",ce=(e,t)=>{if("getPublicPath"in e){let r;return r=e.getPublicPath.startsWith("function")?new Function("return "+e.getPublicPath)()():new Function(e.getPublicPath)(),`${r}${t}`}return"publicPath"in e?U()||be()||!("ssrPublicPath"in e)?`${e.publicPath}${t}`:`${e.ssrPublicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",e,t),"")},Mr=(e,t)=>{e||wt(t)},wt=e=>{throw new Error(`${Tt}: ${e}`)},Se=e=>{console.warn(`${Tt}: ${e}`)};function Ie(e){try{return JSON.stringify(e,null,2)}catch(e){return""}}var Lr=/^([\d^=v<>~]|[*xX]$)/;function Fr(e){return Lr.test(e)}var z=(e,t)=>{if(!e)return t;let r=(e=>{if("."===e)return"";if(e.startsWith("./"))return e.replace("./","");if(e.startsWith("/")){let t=e.slice(1);return t.endsWith("/")?t.slice(0,-1):t}return e})(e);return r?r.endsWith("/")?`${r}${t}`:`${r}/${t}`:t};function At(e){return e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function qe(e,t={}){var r,o,n;let i,{remotes:a={},overrides:s={},version:l}=t,c=()=>"publicPath"in e.metaData?"auto"===e.metaData.publicPath&&l?At(l):e.metaData.publicPath:e.metaData.getPublicPath,u=Object.keys(s),m={};Object.keys(a).length||(m=(null==(r=e.remotes)?void 0:r.reduce((e,t)=>{let r,o=t.federationContainerName;return r=u.includes(o)?s[o]:"version"in t?t.version:t.entry,e[o]={matchedVersion:r},e},{}))||{}),Object.keys(a).forEach(e=>m[e]={matchedVersion:u.includes(e)?s[e]:a[e]});let{remoteEntry:{path:h,name:f,type:p},types:d={path:"",name:"",zip:"",api:""},buildInfo:{buildVersion:y},globalName:_,ssrRemoteEntry:g}=e.metaData,{exposes:E}=e,b={version:l||"",buildVersion:y,globalName:_,remoteEntry:z(h,f),remoteEntryType:p,remoteTypes:z(d.path,d.name),remoteTypesZip:d.zip||"",remoteTypesAPI:d.api||"",remotesInfo:m,shared:null==e?void 0:e.shared.map(e=>({assets:e.assets,sharedName:e.name,version:e.version})),modules:null==E?void 0:E.map(e=>({moduleName:e.name,modulePath:e.path,assets:e.assets}))};if(null!=(o=e.metaData)&&o.prefetchInterface){let t=e.metaData.prefetchInterface;b=M(R({},b),{prefetchInterface:t})}if(null!=(n=e.metaData)&&n.prefetchEntry){let{path:t,name:r,type:o}=e.metaData.prefetchEntry;b=M(R({},b),{prefetchEntry:z(t,r),prefetchEntryType:o})}if(i="publicPath"in e.metaData?M(R({},b),{publicPath:c(),ssrPublicPath:e.metaData.ssrPublicPath}):M(R({},b),{getPublicPath:c()}),g){let e=z(g.path,g.name);i.ssrRemoteEntry=e,i.ssrRemoteEntryType=g.type||"commonjs-module"}return i}function $e(e){return!(!("remoteEntry"in e)||!e.remoteEntry.includes(Be))}function vr(e){if(!e)return{statsFileName:je,manifestFileName:Ue};let t="boolean"==typeof e?"":e.filePath||"",r="boolean"==typeof e?"":e.fileName||"",o=".json",n=r?(a=r).endsWith(o)?a:`${a}${o}`:Ue,i=r?((e,t)=>e.replace(o,`${t}${o}`))(n,"-stats"):je;var a;return{statsFileName:z(t,i),manifestFileName:z(t,n)}}var Pt="[ Module Federation ]",se=console,Dr=["logger.ts","logger.js","captureStackTrace","Logger.emit","Logger.log","Logger.info","Logger.warn","Logger.error","Logger.debug"];function kr(){try{let e=(new Error).stack;if(!e)return;let[,...t]=e.split("\n"),r=t.filter(e=>!Dr.some(t=>e.includes(t)));return r.length?`Stack trace:\n${r.slice(0,5).join("\n")}`:void 0}catch(e){return}}var ge=class{constructor(e,t=se){this.prefix=e,this.delegate=null!=t?t:se}setPrefix(e){this.prefix=e}setDelegate(e){this.delegate=null!=e?e:se}emit(e,t){let r=this.delegate,o=ae()?kr():void 0,n=o?[...t,o]:t,i=(()=>{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(let e of i){let t=r[e];if("function"==typeof t)return void t.call(r,this.prefix,...n)}for(let e of i){let t=se[e];if("function"==typeof t)return void t.call(se,this.prefix,...n)}}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){ae()&&this.emit("debug",e)}};function Ne(e){return new ge(e)}function Ot(e){let t=new ge(e);return Object.defineProperty(t,"__mf_infrastructure_logger__",{value:!0,enumerable:!1,configurable:!1}),t}function Hr(e,t,r){if(e.__mf_infrastructure_logger__&&null!=t&&t.getInfrastructureLogger)try{let o=t.getInfrastructureLogger(r);o&&"object"==typeof o&&("function"==typeof o.log||"function"==typeof o.info||"function"==typeof o.warn||"function"==typeof o.error)&&e.setDelegate(o)}catch(t){e.setDelegate(void 0)}}var Cr=Ne(Pt),xr=Ot(Pt);async function ze(e,t){try{return await e()}catch(e){return void(!t&&Se(e))}}function Xe(e,t){let r=/^(https?:)?\/\//i;return e.replace(r,"").replace(/\/$/,"")===t.replace(r,"").replace(/\/$/,"")}function Te(e){let t,r=null,o=!0,n=2e4,i=document.getElementsByTagName("script");for(let t=0;t<i.length;t++){let n=i[t],a=n.getAttribute("src");if(a&&Xe(a,e.url)){r=n,o=!1;break}}if(!r){let t,o=e.attrs;r=document.createElement("script"),r.type="module"===(null==o?void 0:o.type)?"module":"text/javascript",e.createScriptHook&&(t=e.createScriptHook(e.url,e.attrs),t instanceof HTMLScriptElement?r=t:"object"==typeof t&&("script"in t&&t.script&&(r=t.script),"timeout"in t&&t.timeout&&(n=t.timeout))),r.src||(r.src=e.url),o&&!t&&Object.keys(o).forEach(e=>{r&&("async"===e||"defer"===e?r[e]=o[e]:r.getAttribute(e)||r.setAttribute(e,o[e]))})}let a=async(o,n)=>{clearTimeout(t);let i=()=>{"error"===(null==n?void 0:n.type)?null!=e&&e.onErrorCallback&&(null==e||e.onErrorCallback(n)):null!=e&&e.cb&&(null==e||e.cb())};if(r&&(r.onerror=null,r.onload=null,ze(()=>{let{needDeleteScript:t=!0}=e;t&&null!=r&&r.parentNode&&r.parentNode.removeChild(r)}),o&&"function"==typeof o)){let e=o(n);if(e instanceof Promise){let t=await e;return i(),t}return i(),e}i()};return r.onerror=a.bind(null,r.onerror),r.onload=a.bind(null,r.onload),t=setTimeout(()=>{a(null,new Error(`Remote script "${e.url}" time-outed.`))},n),{script:r,needAttach:o}}function le(e){let t=null,r=!0,o=document.getElementsByTagName("link");for(let n=0;n<o.length;n++){let i=o[n],a=i.getAttribute("href"),s=i.getAttribute("rel");if(a&&Xe(a,e.url)&&s===e.attrs.rel){t=i,r=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",e.url);let r,o=e.attrs;e.createLinkHook&&(r=e.createLinkHook(e.url,o),r instanceof HTMLLinkElement&&(t=r)),o&&!r&&Object.keys(o).forEach(e=>{t&&!t.getAttribute(e)&&t.setAttribute(e,o[e])})}let n=(r,o)=>{let n=()=>{"error"===(null==o?void 0:o.type)?null!=e&&e.onErrorCallback&&(null==e||e.onErrorCallback(o)):null!=e&&e.cb&&(null==e||e.cb())};if(t&&(t.onerror=null,t.onload=null,ze(()=>{let{needDeleteLink:r=!0}=e;r&&null!=t&&t.parentNode&&t.parentNode.removeChild(t)}),r)){let e=r(o);return n(),e}n()};return t.onerror=n.bind(null,t.onerror),t.onload=n.bind(null,t.onload),{link:t,needAttach:r}}function J(e,t){let{attrs:r={},createScriptHook:o}=t;return new Promise((t,n)=>{let{script:i,needAttach:a}=Te({url:e,cb:t,onErrorCallback:n,attrs:R({fetchpriority:"high"},r),createScriptHook:o,needDeleteScript:!0});a&&document.head.appendChild(i)})}var _e=new Map;function ie(e){if(!e)throw new Error("import specifier is required");if(_e.has(e))return _e.get(e);let t=new Function("name","return import(name)")(e).then(e=>e).catch(t=>{throw console.error(`Error importing module ${e}:`,t),_e.delete(e),t});return _e.set(e,t),t}var Mt=async()=>{let e=await ie("node-fetch");return e.default||e},Gr=async(e,t,r)=>{let o=await(n=e,i=t||{},r.lifecycle.fetch.emit(n,i));var n,i;return o&&o instanceof Response?o:("undefined"==typeof fetch?await Mt():fetch)(e,t||{})},Lt="undefined"==typeof ENV_TARGET||"web"!==ENV_TARGET?(url,cb,attrs,loaderHook)=>{if(null!=loaderHook&&loaderHook.createScriptHook){let e=loaderHook.createScriptHook(url);e&&"object"==typeof e&&"url"in e&&(url=e.url)}let urlObj;try{urlObj=new URL(url)}catch(e){return console.error("Error constructing URL:",e),void cb(new Error(`Invalid URL: ${e}`))}let getFetch=async()=>null!=loaderHook&&loaderHook.fetch?(e,t)=>Gr(e,t,loaderHook):"undefined"==typeof fetch?Mt():fetch,handleScriptFetch=async(f,urlObj)=>{var t,e;try{let res=await f(urlObj.href),data=await res.text(),[path,vm]=await Promise.all([ie("path"),ie("vm")]),scriptContext={exports:{},module:{exports:{}}},urlDirname=urlObj.pathname.split("/").slice(0,-1).join("/"),filename=path.basename(urlObj.pathname),script=new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`,{filename:filename,importModuleDynamically:null!=(e=null==(t=vm.constants)?void 0:t.USE_MAIN_CONTEXT_DEFAULT_LOADER)?e:ie});script.runInThisContext()(scriptContext.exports,scriptContext.module,eval("require"),urlDirname,filename);let exportedInterface=scriptContext.module.exports||scriptContext.exports;if(attrs&&exportedInterface&&attrs.globalName){let e=exportedInterface[attrs.globalName]||exportedInterface;return void cb(void 0,e)}cb(void 0,exportedInterface)}catch(e){cb(e instanceof Error?e:new Error(`Script execution error: ${e}`))}};getFetch().then(async e=>{if("esm"===(null==attrs?void 0:attrs.type)||"module"===(null==attrs?void 0:attrs.type))return Ve(urlObj.href,{fetch:e,vm:await ie("vm")}).then(async e=>{await e.evaluate(),cb(void 0,e.namespace)}).catch(e=>{cb(e instanceof Error?e:new Error(`Script execution error: ${e}`))});handleScriptFetch(e,urlObj)}).catch(e=>{cb(e)})}:(e,t,r,o)=>{t(new Error("createScriptNode is disabled in non-Node.js environment"))},Z="undefined"==typeof ENV_TARGET||"web"!==ENV_TARGET?(e,t)=>new Promise((r,o)=>{Lt(e,(e,n)=>{var i,a;if(e)o(e);else{let e=(null==(i=null==t?void 0:t.attrs)?void 0:i.globalName)||`__FEDERATION_${null==(a=null==t?void 0:t.attrs)?void 0:a.name}:custom__`,o=globalThis[e]=n;r(o)}},t.attrs,t.loaderHook)}):(e,t)=>{throw new Error("loadScriptNode is disabled in non-Node.js environment")},Ge=new Map;async function Ve(e,t){if(Ge.has(e))return Ge.get(e);let{fetch:r,vm:o}=t,n=await(await r(e)).text(),i=new o.SourceTextModule(n,{importModuleDynamically:async(r,o)=>Ve(new URL(r,e).href,t)});return Ge.set(e,i),await i.link(async r=>{let o=new URL(r,e).href;return await Ve(o,t)}),i}function Ur(e,t,r){return function(o){if(!1===o)return!1;if(void 0===o)return!!e&&t;if(!0===o)return t;if(o&&"object"==typeof o)return R(R({},t),o);throw new Error(`Unexpected type for \`${r}\`, expect boolean/undefined/object, got: ${typeof o}`)}}var jr=e=>e,Je="RUNTIME-001",Ze="RUNTIME-002",Qe="RUNTIME-003",et="RUNTIME-004",tt="RUNTIME-005",we="RUNTIME-006",rt="RUNTIME-007",Ae="RUNTIME-008",K="RUNTIME-009",Vr="TYPE-001",Br="BUILD-001",Wr="BUILD-002",Kr=e=>`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${e.split("-")[0].toLowerCase()}/${e}`,L=(e,t,r,o)=>{let n=[`${[t[e]]} #${e}`];return r&&n.push(`args: ${JSON.stringify(r)}`),n.push(Kr(e)),o&&n.push(`Original Error Message:\n ${o}`),n.join("\n")},O={[Je]:"Failed to get remoteEntry exports.",[Ze]:'The remote entry interface does not contain "init"',[Qe]:"Failed to get manifest.",[et]:"Failed to locate remote.",[tt]:"Invalid loadShareSync function call from bundler runtime",[we]:"Invalid loadShareSync function call from runtime",[rt]:"Failed to get remote snapshot.",[Ae]:"Failed to load script resources.",[K]:"Please call createInstance first."},qr={[Vr]:"Failed to generate type declaration. Execute the below cmd to reproduce and fix the error."},zr={[Br]:"Failed to find expose module.",[Wr]:"PublicPath is required in prod mode."};R(R(R({},O),qr),zr);var ee="[ Federation Runtime ]",it=Ne(ee);function A(e,t){e||B(t)}function B(e){throw e instanceof Error?(e.message.startsWith(ee)||(e.message=`${ee}: ${e.message}`),e):new Error(`${ee}: ${e}`)}function He(e){e instanceof Error&&(e.message.startsWith(ee)||(e.message=`${ee}: ${e.message}`)),it.warn(e)}function Ft(e,t){return-1===e.findIndex(e=>e===t)&&e.push(t),e}function fe(e){return"version"in e&&e.version?`${e.name}:${e.version}`:"entry"in e&&e.entry?`${e.name}:${e.entry}`:`${e.name}`}function ft(e){return void 0!==e.entry}function jt(e){return!e.entry.includes(".json")}function dt(e){return e&&"object"==typeof e}var Xr=Object.prototype.toString;function Yr(e){return"[object Object]"===Xr.call(e)}function Vt(e){return Array.isArray(e)?e:[e]}function Bt(e){let t={url:"",type:"global",globalName:""};return U()||be()?"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}var Jr=(e,t)=>{let r;return r=e.endsWith("/")?e.slice(0,-1):e,t.startsWith(".")&&(t=t.slice(1)),r+=t,r},P="object"==typeof globalThis?globalThis:window,x=(()=>{try{return document.defaultView}catch(e){return P}})(),de=x;function Oe(e,t,r){Object.defineProperty(e,t,{value:r,configurable:!1,writable:!0})}function Me(e,t){return Object.hasOwnProperty.call(e,t)}Me(P,"__GLOBAL_LOADING_REMOTE_ENTRY__")||Oe(P,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});var Q=P.__GLOBAL_LOADING_REMOTE_ENTRY__;function Wt(e){var t,r,o,n,i,a;Me(e,"__VMOK__")&&!Me(e,"__FEDERATION__")&&Oe(e,"__FEDERATION__",e.__VMOK__),Me(e,"__FEDERATION__")||(Oe(e,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),Oe(e,"__VMOK__",e.__FEDERATION__)),null!=(t=e.__FEDERATION__).__GLOBAL_PLUGIN__||(t.__GLOBAL_PLUGIN__=[]),null!=(r=e.__FEDERATION__).__INSTANCES__||(r.__INSTANCES__=[]),null!=(o=e.__FEDERATION__).moduleInfo||(o.moduleInfo={}),null!=(n=e.__FEDERATION__).__SHARE__||(n.__SHARE__={}),null!=(i=e.__FEDERATION__).__MANIFEST_LOADING__||(i.__MANIFEST_LOADING__={}),null!=(a=e.__FEDERATION__).__PRELOADED_MAP__||(a.__PRELOADED_MAP__=new Map)}function Kt(e){P.__FEDERATION__.__INSTANCES__.push(e)}function qt(){return P.__FEDERATION__.__DEBUG_CONSTRUCTOR__}function zt(e,t=ae()){t&&(P.__FEDERATION__.__DEBUG_CONSTRUCTOR__=e,P.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="0.21.4")}function te(e,t){if("string"==typeof t){if(e[t])return{value:e[t],key:t};{let r=Object.keys(e);for(let o of r){let[r,n]=o.split(":"),i=`${r}:${t}`,a=e[i];if(a)return{value:a,key:i}}return{value:void 0,key:t}}}throw new Error("key must be string")}Wt(P),Wt(x);var vt=()=>x.__FEDERATION__.moduleInfo,Zr=(e,t)=>{let r=te(t,fe(e)).value;if(r&&!r.version&&"version"in e&&e.version&&(r.version=e.version),r)return r;if("version"in e&&e.version){let t=e,{version:r}=t,o=fe(xe(t,["version"])),n=te(x.__FEDERATION__.moduleInfo,o).value;if((null==n?void 0:n.version)===r)return n}},Le=e=>Zr(e,x.__FEDERATION__.moduleInfo),Dt=(e,t)=>{let r=fe(e);return x.__FEDERATION__.moduleInfo[r]=t,x.__FEDERATION__.moduleInfo},Qr=e=>(x.__FEDERATION__.moduleInfo=R(R({},x.__FEDERATION__.moduleInfo),e),()=>{let t=Object.keys(e);for(let e of t)delete x.__FEDERATION__.moduleInfo[e]}),ht=(e,t)=>{let r=t||`__FEDERATION_${e}:custom__`;return{remoteEntryKey:r,entryExports:P[r]}},Xt=e=>{let{__GLOBAL_PLUGIN__:t}=x.__FEDERATION__;e.forEach(e=>{-1===t.findIndex(t=>t.name===e.name)?t.push(e):He(`The plugin ${e.name} has been registered.`)})},en=()=>x.__FEDERATION__.__GLOBAL_PLUGIN__,tn=e=>P.__FEDERATION__.__PRELOADED_MAP__.get(e),rn=e=>P.__FEDERATION__.__PRELOADED_MAP__.set(e,!0),me="default",Yt="global",kt="[0-9A-Za-z-]+",pt=`(?:\\+(${kt}(?:\\.${kt})*))`,ue="0|[1-9]\\d*",Fe="[0-9]+",Jt="\\d*[a-zA-Z-][a-zA-Z0-9-]*",Ht=`(?:${Fe}|${Jt})`,nn=`(?:-?(${Ht}(?:\\.${Ht})*))`,Ct=`(?:${ue}|${Jt})`,Zt=`(?:-(${Ct}(?:\\.${Ct})*))`,nt=`${ue}|x|X|\\*`,re=`[v=\\s]*(${nt})(?:\\.(${nt})(?:\\.(${nt})(?:${Zt})?${pt}?)?)?`,on=`^\\s*(${re})\\s+-\\s+(${re})\\s*$`,sn=`(${Fe})\\.(${Fe})\\.(${Fe})`,an=`[v=\\s]*${sn}${nn}?${pt}?`,mt="((?:<|>)?=?)",cn=`(\\s*)${mt}\\s*(${an}|${re})`,Qt="(?:~>?)",ln=`(\\s*)${Qt}\\s+`,er="(?:\\^)",un=`(\\s*)${er}\\s+`,fn="(<|>)?=?\\s*\\*",dn=`^${er}${re}$`,hn=`(${ue})\\.(${ue})\\.(${ue})`,pn=`v?${hn}${Zt}?${pt}?`,mn=`^${Qt}${re}$`,yn=`^${mt}\\s*${re}$`,_n=`^${mt}\\s*(${pn})$|^$`,En="^\\s*>=\\s*0.0.0\\s*$";function W(e){return new RegExp(e)}function v(e){return!e||"x"===e.toLowerCase()||"*"===e}function tr(...e){return t=>e.reduce((e,t)=>t(e),t)}function xt(e){return e.match(W(_n))}function Gt(e,t,r,o){let n=`${e}.${t}.${r}`;return o?`${n}-${o}`:n}function gn(e){return e.replace(W(on),(e,t,r,o,n,i,a,s,l,c,u,m)=>`${t=v(r)?"":v(o)?`>=${r}.0.0`:v(n)?`>=${r}.${o}.0`:`>=${t}`} ${s=v(l)?"":v(c)?`<${Number(l)+1}.0.0-0`:v(u)?`<${l}.${Number(c)+1}.0-0`:m?`<=${l}.${c}.${u}-${m}`:`<=${s}`}`.trim())}function bn(e){return e.replace(W(cn),"$1$2$3")}function Rn(e){return e.replace(W(ln),"$1~")}function Sn(e){return e.replace(W(un),"$1^")}function In(e){return e.trim().split(/\s+/).map(e=>e.replace(W(dn),(e,t,r,o,n)=>v(t)?"":v(r)?`>=${t}.0.0 <${Number(t)+1}.0.0-0`:v(o)?"0"===t?`>=${t}.${r}.0 <${t}.${Number(r)+1}.0-0`:`>=${t}.${r}.0 <${Number(t)+1}.0.0-0`:n?"0"===t?"0"===r?`>=${t}.${r}.${o}-${n} <${t}.${r}.${Number(o)+1}-0`:`>=${t}.${r}.${o}-${n} <${t}.${Number(r)+1}.0-0`:`>=${t}.${r}.${o}-${n} <${Number(t)+1}.0.0-0`:"0"===t?"0"===r?`>=${t}.${r}.${o} <${t}.${r}.${Number(o)+1}-0`:`>=${t}.${r}.${o} <${t}.${Number(r)+1}.0-0`:`>=${t}.${r}.${o} <${Number(t)+1}.0.0-0`)).join(" ")}function $n(e){return e.trim().split(/\s+/).map(e=>e.replace(W(mn),(e,t,r,o,n)=>v(t)?"":v(r)?`>=${t}.0.0 <${Number(t)+1}.0.0-0`:v(o)?`>=${t}.${r}.0 <${t}.${Number(r)+1}.0-0`:n?`>=${t}.${r}.${o}-${n} <${t}.${Number(r)+1}.0-0`:`>=${t}.${r}.${o} <${t}.${Number(r)+1}.0-0`)).join(" ")}function Nn(e){return e.split(/\s+/).map(e=>e.trim().replace(W(yn),(e,t,r,o,n,i)=>{let a=v(r),s=a||v(o),l=s||v(n);return"="===t&&l&&(t=""),i="",a?">"===t||"<"===t?"<0.0.0-0":"*":t&&l?(s&&(o=0),n=0,">"===t?(t=">=",s?(r=Number(r)+1,o=0,n=0):(o=Number(o)+1,n=0)):"<="===t&&(t="<",s?r=Number(r)+1:o=Number(o)+1),"<"===t&&(i="-0"),`${t+r}.${o}.${n}${i}`):s?`>=${r}.0.0${i} <${Number(r)+1}.0.0-0`:l?`>=${r}.${o}.0${i} <${r}.${Number(o)+1}.0-0`:e})).join(" ")}function Tn(e){return e.trim().replace(W(fn),"")}function wn(e){return e.trim().replace(W(En),"")}function ve(e,t){return(e=Number(e)||e)>(t=Number(t)||t)?1:e===t?0:-1}function An(e,t){let{preRelease:r}=e,{preRelease:o}=t;if(void 0===r&&o)return 1;if(r&&void 0===o)return-1;if(void 0===r&&void 0===o)return 0;for(let e=0,t=r.length;e<=t;e++){let t=r[e],n=o[e];if(t!==n)return void 0===t&&void 0===n?0:t?n?ve(t,n):-1:1}return 0}function Pe(e,t){return ve(e.major,t.major)||ve(e.minor,t.minor)||ve(e.patch,t.patch)||An(e,t)}function ot(e,t){return e.version===t.version}function Pn(e,t){switch(e.operator){case"":case"=":return ot(e,t);case">":return Pe(e,t)<0;case">=":return ot(e,t)||Pe(e,t)<0;case"<":return Pe(e,t)>0;case"<=":return ot(e,t)||Pe(e,t)>0;case void 0:return!0;default:return!1}}function On(e){return tr(In,$n,Nn,Tn)(e)}function Mn(e){return tr(gn,bn,Rn,Sn)(e.trim()).split(/\s+/).join(" ")}function De(e,t){if(!e)return!1;let r=xt(e);if(!r)return!1;let[,o,,n,i,a,s]=r,l={operator:o,version:Gt(n,i,a,s),major:n,minor:i,patch:a,preRelease:null==s?void 0:s.split(".")},c=t.split("||");for(let e of c){let t=e.trim();if(!t||"*"===t||"x"===t)return!0;try{let e=Mn(t);if(!e.trim())return!0;let r=e.split(" ").map(e=>On(e)).join(" ");if(!r.trim())return!0;let o=r.split(/\s+/).map(e=>wn(e)).filter(Boolean);if(0===o.length)continue;let n=!0;for(let e of o){let t=xt(e);if(!t){n=!1;break}let[,r,,o,i,a,s]=t;if(!Pn({operator:r,version:Gt(o,i,a,s),major:o,minor:i,patch:a,preRelease:null==s?void 0:s.split(".")},l)){n=!1;break}}if(n)return!0}catch(e){console.error(`[semver] Error processing range part "${t}":`,e);continue}}return!1}function Ln(e,t,r,o){var n,i,a;let s;return s="get"in e?e.get:"lib"in e?()=>Promise.resolve(e.lib):()=>Promise.resolve(()=>{throw new Error(`Can not get shared '${r}'!`)}),M(R({deps:[],useIn:[],from:t,loading:null},e),{shareConfig:R({requiredVersion:`^${e.version}`,singleton:!1,eager:!1,strictVersion:!1},e.shareConfig),get:s,loaded:!!(null!=e&&e.loaded||"lib"in e)||void 0,version:null!=(n=e.version)?n:"0",scope:Array.isArray(e.scope)?e.scope:[null!=(i=e.scope)?i:"default"],strategy:(null!=(a=e.strategy)?a:o)||"version-first"})}function rr(e,t){let r=t.shared||{},o=t.name,n=Object.keys(r).reduce((e,n)=>{let i=Vt(r[n]);return e[n]=e[n]||[],i.forEach(r=>{e[n].push(Ln(r,o,n,t.shareStrategy))}),e},{}),i=R({},e.shared);return Object.keys(n).forEach(e=>{i[e]?n[e].forEach(t=>{i[e].find(e=>e.version===t.version)||i[e].push(t)}):i[e]=n[e]}),{shared:i,shareInfos:n}}function he(e,t){let r=e=>{if(!Number.isNaN(Number(e))){let t=e.split("."),r=e;for(let e=0;e<3-t.length;e++)r+=".0";return r}return e};return!!De(r(e),`<=${r(t)}`)}var yt=(e,t)=>{let r=t||function(e,t){return he(e,t)};return Object.keys(e).reduce((e,t)=>!e||r(e,t)||"0"===e?t:e,0)},_t=e=>!!e.loaded||"function"==typeof e.lib,Fn=e=>!!e.loading;function vn(e,t,r){let o=e[t][r];return yt(e[t][r],function(e,t){return!_t(o[e])&&he(e,t)})}function Dn(e,t,r){let o=e[t][r];return yt(e[t][r],function(e,t){let r=e=>_t(e)||Fn(e);return r(o[t])?!r(o[e])||!!he(e,t):!r(o[e])&&he(e,t)})}function kn(e){return"loaded-first"===e?Dn:vn}function ke(e,t,r,o){if(!e)return;let{shareConfig:n,scope:i=me,strategy:a}=r,s=Array.isArray(i)?i:[i];for(let i of s)if(n&&e[i]&&e[i][t]){let{requiredVersion:s}=n,l=kn(a)(e,i,t),c=()=>{if(n.singleton){if("string"==typeof s&&!De(l,s)){let o=`Version ${l} from ${l&&e[i][t][l].from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${s})`;n.strictVersion?B(o):He(o)}return e[i][t][l]}if(!1===s||"*"===s||De(l,s))return e[i][t][l];for(let[r,o]of Object.entries(e[i][t]))if(De(r,s))return o},u={shareScopeMap:e,scope:i,pkgName:t,version:l,GlobalFederation:de.__FEDERATION__,resolver:c};return(o.emit(u)||u).resolver()}}function nr(){return de.__FEDERATION__.__SHARE__}function Ut(e){var t;let{pkgName:r,extraOptions:o,shareInfos:n}=e,i=null!=(t=null==o?void 0:o.resolver)?t:e=>{if(!e)return;let t={};e.forEach(e=>{t[e.version]=e});let r=yt(t,function(e,r){return!_t(t[e])&&he(e,r)});return t[r]};return Object.assign({},i(n[r]),null==o?void 0:o.customShareInfo)}function Hn(){return"undefined"!=typeof FEDERATION_BUILD_IDENTIFIER?FEDERATION_BUILD_IDENTIFIER:""}function Cn(e,t){for(let r of e){let e=t.startsWith(r.name),o=t.replace(r.name,"");if(e){if(o.startsWith("/")){return o=`.${o}`,{pkgNameOrAlias:r.name,expose:o,remote:r}}if(""===o)return{pkgNameOrAlias:r.name,expose:".",remote:r}}let n=r.alias&&t.startsWith(r.alias),i=r.alias&&t.replace(r.alias,"");if(r.alias&&n){if(i&&i.startsWith("/")){return i=`.${i}`,{pkgNameOrAlias:r.alias,expose:i,remote:r}}if(""===i)return{pkgNameOrAlias:r.alias,expose:".",remote:r}}}}function xn(e,t){for(let r of e)if(t===r.name||r.alias&&t===r.alias)return r}function Gn(e,t){let r=en(),o=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return r.length>0&&r.forEach(t=>{null!=e&&e.find(e=>e.name!==t.name)&&e.push(t)}),e&&e.length>0&&e.forEach(e=>{o.forEach(r=>{r.applyPlugin(e,t)})}),e}var or=".then(callbacks[0]).catch(callbacks[1])";async function Un({entry:e,remoteEntryExports:t}){return new Promise((r,o)=>{try{t?r(t):new Function("callbacks",`import("${e}")${or}`)([r,o])}catch(e){o(e)}})}async function jn({entry:e,remoteEntryExports:t}){return new Promise((r,o)=>{try{t?r(t):"undefined"==typeof __system_context__?System.import(e).then(r).catch(o):new Function("callbacks",`System.import("${e}")${or}`)([r,o])}catch(e){o(e)}})}function sr(e,t,r){let{remoteEntryKey:o,entryExports:n}=ht(e,t);return A(n,L(Je,O,{remoteName:e,remoteEntryUrl:r,remoteEntryKey:o})),n}async function Vn({name:e,globalName:t,entry:r,loaderHook:o,getEntryUrl:n}){let{entryExports:i}=ht(e,t);return i||J(n?n(r):r,{attrs:{},createScriptHook:(e,t)=>{let r=o.lifecycle.createScript.emit({url:e,attrs:t});if(r&&(r instanceof HTMLScriptElement||"script"in r||"timeout"in r))return r}}).then(()=>sr(e,t,r)).catch(t=>{throw A(void 0,L(Ae,O,{remoteName:e,resourceUrl:r})),t})}async function Bn({remoteInfo:e,remoteEntryExports:t,loaderHook:r,getEntryUrl:o}){let{entry:n,entryGlobalName:i,name:a,type:s}=e;switch(s){case"esm":case"module":return Un({entry:n,remoteEntryExports:t});case"system":return jn({entry:n,remoteEntryExports:t});default:return Vn({entry:n,globalName:i,name:a,loaderHook:r,getEntryUrl:o})}}async function Wn({remoteInfo:e,loaderHook:t}){let{entry:r,entryGlobalName:o,name:n,type:i}=e,{entryExports:a}=ht(n,o);return a||Z(r,{attrs:{name:n,globalName:o,type:i},loaderHook:{createScriptHook:(e,r={})=>{let o=t.lifecycle.createScript.emit({url:e,attrs:r});if(o&&"url"in o)return o}}}).then(()=>sr(n,o,r)).catch(e=>{throw e})}function at(e){let{entry:t,name:r}=e;return Re(r,t)}async function ne(e){let{origin:t,remoteEntryExports:r,remoteInfo:o,getEntryUrl:n,_inErrorHandling:i=!1}=e,a=at(o);if(r)return r;if(!Q[a]){let e=t.remoteHandler.hooks.lifecycle.loadEntry,s=t.loaderHook;Q[a]=e.emit({loaderHook:s,remoteInfo:o,remoteEntryExports:r}).then(e=>e||(("undefined"!=typeof ENV_TARGET?"web"===ENV_TARGET:U())?Bn({remoteInfo:o,remoteEntryExports:r,loaderHook:s,getEntryUrl:n}):Wn({remoteInfo:o,loaderHook:s}))).catch(async e=>{let n=at(o);if(e instanceof Error&&e.message.includes(Ae)&&!i){let e=e=>ne(M(R({},e),{_inErrorHandling:!0})),i=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:e,origin:t,remoteInfo:o,remoteEntryExports:r,globalLoading:Q,uniqueKey:n});if(i)return i}throw e})}return Q[a]}function pe(e){return M(R({},e),{entry:"entry"in e?e.entry:"",type:e.type||Yt,entryGlobalName:e.entryGlobalName||e.name,shareScope:e.shareScope||me})}function ir(e){return R({resourceCategory:"sync",share:!0,depsRemote:!0,prefetchInterface:!1},e)}function Kn(e,t){return t.map(t=>{let r=xn(e,t.nameOrAlias);return A(r,`Unable to preload ${t.nameOrAlias} as it is not included in ${!r&&Ie({remoteInfo:r,remotes:e})}`),{remote:r,preloadConfig:ir(t)}})}function qn(e){return e?e.map(e=>"."===e?e:e.startsWith("./")?e.replace("./",""):e):[]}function ar(e,t,r,o=!0){let{cssAssets:n,jsAssetsWithoutEntry:i,entryAssets:a}=r;if(t.options.inBrowser){if(a.forEach(r=>{let{moduleInfo:o}=r,n=t.moduleCache.get(e.name);ne(n?{origin:t,remoteInfo:o,remoteEntryExports:n.remoteEntryExports}:{origin:t,remoteInfo:o,remoteEntryExports:void 0})}),o){let e={rel:"preload",as:"style"};n.forEach(r=>{let{link:o,needAttach:n}=le({url:r,cb:()=>{},attrs:e,createLinkHook:(e,r)=>{let o=t.loaderHook.lifecycle.createLink.emit({url:e,attrs:r});if(o instanceof HTMLLinkElement)return o}});n&&document.head.appendChild(o)})}else{let e={rel:"stylesheet",type:"text/css"};n.forEach(r=>{let{link:o,needAttach:n}=le({url:r,cb:()=>{},attrs:e,createLinkHook:(e,r)=>{let o=t.loaderHook.lifecycle.createLink.emit({url:e,attrs:r});if(o instanceof HTMLLinkElement)return o},needDeleteLink:!1});n&&document.head.appendChild(o)})}if(o){let e={rel:"preload",as:"script"};i.forEach(r=>{let{link:o,needAttach:n}=le({url:r,cb:()=>{},attrs:e,createLinkHook:(e,r)=>{let o=t.loaderHook.lifecycle.createLink.emit({url:e,attrs:r});if(o instanceof HTMLLinkElement)return o}});n&&document.head.appendChild(o)})}else{let r={fetchpriority:"high",type:"module"===(null==e?void 0:e.type)?"module":"text/javascript"};i.forEach(e=>{let{script:o,needAttach:n}=Te({url:e,cb:()=>{},attrs:r,createScriptHook:(e,r)=>{let o=t.loaderHook.lifecycle.createScript.emit({url:e,attrs:r});if(o instanceof HTMLScriptElement)return o},needDeleteScript:!0});n&&document.head.appendChild(o)})}}}var oe=class{constructor({remoteInfo:e,host:t}){this.inited=!1,this.lib=void 0,this.remoteInfo=e,this.host=t}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;let e;return e=await ne({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports}),A(e,`remoteEntryExports is undefined \n ${Ie(this.remoteInfo)}`),this.remoteEntryExports=e,this.remoteEntryExports}async get(e,t,r,o){let n,{loadFactory:i=!0}=r||{loadFactory:!0},a=await this.getEntry();if(!this.inited){let t=this.host.shareScopeMap,r=Array.isArray(this.remoteInfo.shareScope)?this.remoteInfo.shareScope:[this.remoteInfo.shareScope];r.length||r.push("default"),r.forEach(e=>{t[e]||(t[e]={})});let n=t[r[0]],i=[],s={version:this.remoteInfo.version||"",shareScopeKeys:Array.isArray(this.remoteInfo.shareScope)?r:this.remoteInfo.shareScope||"default"};Object.defineProperty(s,"shareScopeMap",{value:t,enumerable:!1});let l=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:n,remoteEntryInitOptions:s,initScope:i,remoteInfo:this.remoteInfo,origin:this.host});void 0===(null==a?void 0:a.init)&&B(L(Ze,O,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName})),await a.init(l.shareScope,l.initScope,l.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit(M(R({},l),{id:e,remoteSnapshot:o,remoteEntryExports:a}))}this.lib=a,this.inited=!0,n=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:a,expose:t,moduleInfo:this.remoteInfo}),n||(n=await a.get(t)),A(n,`${fe(this.remoteInfo)} remote don't export ${t}.`);let s=Jr(this.remoteInfo.name,t),l=this.wraperFactory(n,s);return i?await l():l}wraperFactory(e,t){function r(e,t){e&&"object"==typeof e&&Object.isExtensible(e)&&!Object.getOwnPropertyDescriptor(e,Symbol.for("mf_module_id"))&&Object.defineProperty(e,Symbol.for("mf_module_id"),{value:t,enumerable:!1})}return e instanceof Promise?async()=>{let o=await e();return r(o,t),o}:()=>{let o=e();return r(o,t),o}}},D=class{constructor(e){this.type="",this.listeners=new Set,e&&(this.type=e)}on(e){"function"==typeof e&&this.listeners.add(e)}once(e){let t=this;this.on(function r(...o){return t.remove(r),e.apply(null,o)})}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()}},H=class extends D{emit(...e){let t,r=Array.from(this.listeners);if(r.length>0){let o=0,n=t=>!1!==t&&(o<r.length?Promise.resolve(r[o++].apply(null,e)).then(n):t);t=n()}return Promise.resolve(t)}};function cr(e,t){if(!dt(t))return!1;if(e!==t)for(let r in e)if(!(r in t))return!1;return!0}var X=class extends D{constructor(e){super(),this.onerror=B,this.type=e}emit(e){dt(e)||B(`The data for the "${this.type}" hook should be an object.`);for(let t of this.listeners)try{let r=t(e);if(!cr(e,r)){this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}e=r}catch(e){He(e),this.onerror(e)}return e}},V=class extends D{constructor(e){super(),this.onerror=B,this.type=e}emit(e){dt(e)||B(`The response data for the "${this.type}" hook must be an object.`);let t=Array.from(this.listeners);if(t.length>0){let r=0,o=t=>(He(t),this.onerror(t),e),n=i=>{if(cr(e,i)){if(e=i,r<t.length)try{return Promise.resolve(t[r++](e)).then(n,o)}catch(e){return o(e)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return e};return Promise.resolve(n(e))}return Promise.resolve(e)}},q=class{constructor(e){this.registerPlugins={},this.lifecycle=e,this.lifecycleKeys=Object.keys(e)}applyPlugin(e,t){var r;A(Yr(e),"Plugin configuration is invalid.");let o=e.name;A(o,"A name must be provided by the plugin."),this.registerPlugins[o]||(this.registerPlugins[o]=e,null==(r=e.apply)||r.call(e,t),Object.keys(this.lifecycle).forEach(t=>{let r=e[t];r&&this.lifecycle[t].on(r)}))}removePlugin(e){A(e,"A name is required.");let t=this.registerPlugins[e];A(t,`The plugin "${e}" is not registered.`),Object.keys(t).forEach(e=>{"name"!==e&&this.lifecycle[e].remove(t[e])})}};function lr(e,t){let r=Bt(t);r.url||B(`The attribute remoteEntry of ${e.name} must not be undefined.`);let o=ce(t,r.url);!U()&&!o.startsWith("http")&&(o=`https:${o}`),e.type=r.type,e.entryGlobalName=r.globalName,e.entry=o,e.version=t.version,e.buildVersion=t.buildVersion}function zn(){return{name:"snapshot-plugin",async afterResolve(e){let{remote:t,pkgNameOrAlias:r,expose:o,origin:n,remoteInfo:i,id:a}=e;if(!ft(t)||!jt(t)){let{remoteSnapshot:s,globalSnapshot:l}=await n.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:a});lr(i,s);let c={remote:t,preloadConfig:{nameOrAlias:r,exposes:[o],resourceCategory:"sync",share:!1,depsRemote:!1}},u=await n.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:n,preloadOptions:c,remoteInfo:i,remote:t,remoteSnapshot:s,globalSnapshot:l});return u&&ar(i,n,u,!1),M(R({},e),{remoteSnapshot:s})}return e}}}function Xn(e){let t=e.split(":");return 1===t.length?{name:t[0],version:void 0}:2===t.length?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function ur(e,t,r,o,n={},i){let a=fe(t),{value:s}=te(e,a),l=i||s;if(l&&!$e(l)&&(r(l,t,o),l.remotesInfo)){let t=Object.keys(l.remotesInfo);for(let o of t){if(n[o])continue;n[o]=!0;let t=Xn(o),i=l.remotesInfo[o];ur(e,{name:t.name,version:i.matchedVersion},r,!1,n,void 0)}}}var st=(e,t)=>document.querySelector(`${e}[${"link"===e?"href":"src"}="${t}"]`);function Yn(e,t,r,o,n){let i=[],a=[],s=[],l=new Set,c=new Set,{options:u}=e,{preloadConfig:m}=t,{depsRemote:h}=m;if(ur(o,r,(t,r,o)=>{var n;let l;if(o)l=m;else if(Array.isArray(h)){let e=h.find(e=>e.nameOrAlias===r.name||e.nameOrAlias===r.alias);if(!e)return;l=ir(e)}else{if(!0!==h)return;l=m}let c=ce(t,Bt(t).url);c&&s.push({name:r.name,moduleInfo:{name:r.name,entry:c,type:"remoteEntryType"in t?t.remoteEntryType:"global",entryGlobalName:"globalName"in t?t.globalName:r.name,shareScope:"",version:"version"in t?t.version:void 0},url:c});let u="modules"in t?t.modules:[],f=qn(l.exposes);function p(e){let r=e.map(e=>ce(t,e));return l.filter?r.filter(l.filter):r}if(f.length&&"modules"in t&&(u=null==(n=null==t?void 0:t.modules)?void 0:n.reduce((e,t)=>(-1!==(null==f?void 0:f.indexOf(t.moduleName))&&e.push(t),e),[])),u){let o=u.length;for(let n=0;n<o;n++){let o=u[n],s=`${r.name}/${o.moduleName}`;e.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:"."===o.moduleName?r.name:s,name:r.name,remoteSnapshot:t,preloadConfig:l,remote:r,origin:e}),!tn(s)&&("all"===l.resourceCategory?(i.push(...p(o.assets.css.async)),i.push(...p(o.assets.css.sync)),a.push(...p(o.assets.js.async)),a.push(...p(o.assets.js.sync))):(l.resourceCategory="sync")&&(i.push(...p(o.assets.css.sync)),a.push(...p(o.assets.js.sync))),rn(s))}}},!0,{},n),n.shared&&n.shared.length>0){let t=(t,r)=>{let o=ke(e.shareScopeMap,r.sharedName,t,e.sharedHandler.hooks.lifecycle.resolveShare);o&&"function"==typeof o.lib&&(r.assets.js.sync.forEach(e=>{l.add(e)}),r.assets.css.sync.forEach(e=>{c.add(e)}))};n.shared.forEach(e=>{var r;let o=null==(r=u.shared)?void 0:r[e.sharedName];if(!o)return;let n=e.version?o.find(t=>t.version===e.version):o;n&&Vt(n).forEach(r=>{t(r,e)})})}let f=a.filter(e=>!l.has(e)&&!st("script",e));return{cssAssets:i.filter(e=>!c.has(e)&&!st("link",e)),jsAssetsWithoutEntry:f,entryAssets:s.filter(e=>!st("script",e.url))}}var Jn=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(e){let{origin:t,preloadOptions:r,remoteInfo:o,remote:n,globalSnapshot:i,remoteSnapshot:a}=e;return U()?ft(n)&&jt(n)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:n.name,url:n.entry,moduleInfo:{name:o.name,entry:n.entry,type:o.type||"global",entryGlobalName:"",shareScope:""}}]}:(lr(o,a),Yn(t,r,o,i,a)):{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[]}}}};function fr(e,t){let r=Le({name:t.name,version:t.options.version}),o=r&&"remotesInfo"in r&&r.remotesInfo&&te(r.remotesInfo,e.name).value;return o&&o.matchedVersion?{hostGlobalSnapshot:r,globalSnapshot:vt(),remoteSnapshot:Le({name:e.name,version:o.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:vt(),remoteSnapshot:Le({name:e.name,version:"version"in e?e.version:void 0})}}var ct=class{constructor(e){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new q({beforeLoadRemoteSnapshot:new H("beforeLoadRemoteSnapshot"),loadSnapshot:new V("loadGlobalSnapshot"),loadRemoteSnapshot:new V("loadRemoteSnapshot"),afterLoadSnapshot:new V("afterLoadSnapshot")}),this.manifestLoading=de.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=e,this.loaderHook=e.loaderHook}async loadRemoteSnapshotInfo({moduleInfo:e,id:t,expose:r}){let{options:o}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:o,moduleInfo:e});let n=Le({name:this.HostInstance.options.name,version:this.HostInstance.options.version});n||(n={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},Qr({[this.HostInstance.options.name]:n})),n&&"remotesInfo"in n&&!te(n.remotesInfo,e.name).value&&("version"in e||"entry"in e)&&(n.remotesInfo=M(R({},null==n?void 0:n.remotesInfo),{[e.name]:{matchedVersion:"version"in e?e.version:e.entry}}));let i,a,{hostGlobalSnapshot:s,remoteSnapshot:l,globalSnapshot:c}=this.getGlobalRemoteInfo(e),{remoteSnapshot:u,globalSnapshot:m}=await this.hooks.lifecycle.loadSnapshot.emit({options:o,moduleInfo:e,hostGlobalSnapshot:s,remoteSnapshot:l,globalSnapshot:c});if(u)if($e(u)){let t=U()?u.remoteEntry:u.ssrRemoteEntry||u.remoteEntry||"",r=await this.getManifestJson(t,e,{});i=r,a=Dt(M(R({},e),{entry:t}),r)}else{let{remoteSnapshot:t}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:u,from:"global"});i=t,a=m}else if(ft(e)){let t=await this.getManifestJson(e.entry,e,{}),r=Dt(e,t),{remoteSnapshot:o}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:t,from:"global"});i=o,a=r}else B(L(rt,O,{hostName:e.name,hostVersion:e.version,globalSnapshot:JSON.stringify(m)}));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:t,host:this.HostInstance,options:o,moduleInfo:e,remoteSnapshot:i}),{remoteSnapshot:i,globalSnapshot:a}}getGlobalRemoteInfo(e){return fr(e,this.HostInstance)}async getManifestJson(e,t,r){let o=async()=>{let r=this.manifestCache.get(e);if(r)return r;try{let t=await this.loaderHook.lifecycle.fetch.emit(e,{});(!t||!(t instanceof Response))&&(t=await fetch(e,{})),r=await t.json()}catch(o){r=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:e,error:o,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),r||(delete this.manifestLoading[e],B(L(Qe,O,{manifestUrl:e,moduleName:t.name,hostName:this.HostInstance.options.name},`${o}`)))}return A(r.metaData&&r.exposes&&r.shared,`${e} is not a federation manifest`),this.manifestCache.set(e,r),r};return this.manifestLoading[e]||(this.manifestLoading[e]=(async()=>{let r=await o(),n=qe(r,{version:e}),{remoteSnapshot:i}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,manifestJson:r,remoteSnapshot:n,manifestUrl:e,from:"manifest"});return i})().then(e=>e)),this.manifestLoading[e]}},lt=class{constructor(e){this.hooks=new q({afterResolve:new V("afterResolve"),beforeLoadShare:new V("beforeLoadShare"),loadShare:new H,resolveShare:new X("resolveShare"),initContainerShareScopeMap:new X("initContainerShareScopeMap")}),this.host=e,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(e.options)}registerShared(e,t){let{shareInfos:r,shared:o}=rr(e,t);return Object.keys(r).forEach(e=>{r[e].forEach(r=>{r.scope.forEach(o=>{var n;(null==(n=this.shareScopeMap[o])?void 0:n[e])||this.setShared({pkgName:e,lib:r.lib,get:r.get,loaded:r.loaded||!!r.lib,shared:r,from:t.name})})})}),{shareInfos:r,shared:o}}async loadShare(e,t){let{host:r}=this,o=Ut({pkgName:e,extraOptions:t,shareInfos:r.options.shared});null!=o&&o.scope&&await Promise.all(o.scope.map(async e=>{await Promise.all(this.initializeSharing(e,{strategy:o.strategy}))}));let n=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:e,shareInfo:o,shared:r.options.shared,origin:r}),{shareInfo:i}=n;A(i,`Cannot find ${e} Share in the ${r.options.name}. Please ensure that the ${e} Share parameters have been injected`);let a=ke(this.shareScopeMap,e,i,this.hooks.lifecycle.resolveShare),s=e=>{e.useIn||(e.useIn=[]),Ft(e.useIn,r.options.name)};if(a&&a.lib)return s(a),a.lib;if(a&&a.loading&&!a.loaded){let e=await a.loading;return a.loaded=!0,a.lib||(a.lib=e),s(a),e}if(a){let t=(async()=>{let e=await a.get();return s(a),a.loaded=!0,a.lib=e,e})();return this.setShared({pkgName:e,loaded:!1,shared:a,from:r.options.name,lib:null,loading:t}),t}{if(null!=t&&t.customShareInfo)return!1;let o=(async()=>{let t=await i.get();i.lib=t,i.loaded=!0,s(i);let r=ke(this.shareScopeMap,e,i,this.hooks.lifecycle.resolveShare);return r&&(r.lib=t,r.loaded=!0,r.from=i.from),t})();return this.setShared({pkgName:e,loaded:!1,shared:i,from:r.options.name,lib:null,loading:o}),o}}initializeSharing(e=me,t){let{host:r}=this,o=null==t?void 0:t.from,n=null==t?void 0:t.strategy,i=null==t?void 0:t.initScope,a=[];if("build"!==o){let{initTokens:t}=this;i||(i=[]);let r=t[e];if(r||(r=t[e]={from:this.host.name}),i.indexOf(r)>=0)return a;i.push(r)}let s=this.shareScopeMap,l=r.options.name;s[e]||(s[e]={});let c=s[e],u=async t=>{let{module:o}=await r.remoteHandler.getRemoteModuleAndOptions({id:t});if(o.getEntry){let n;try{n=await o.getEntry()}catch(e){n=await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:t,error:e,from:"runtime",lifecycle:"beforeLoadShare",origin:r})}o.inited||(await(t=>t&&t.init&&t.init(s[e],i))(n),o.inited=!0)}};return Object.keys(r.options.shared).forEach(t=>{r.options.shared[t].forEach(r=>{r.scope.includes(e)&&((e,t)=>{var r;let{version:o,eager:n}=t;c[e]=c[e]||{};let i=c[e],a=i[o],s=!(!a||!(a.eager||null!=(r=a.shareConfig)&&r.eager));(!a||"loaded-first"!==a.strategy&&!a.loaded&&(!n!=!s?n:l>a.from))&&(i[o]=t)})(t,r)})}),("version-first"===r.options.shareStrategy||"version-first"===n)&&r.options.remotes.forEach(t=>{t.shareScope===e&&a.push(u(t.name))}),a}loadShareSync(e,t){let{host:r}=this,o=Ut({pkgName:e,extraOptions:t,shareInfos:r.options.shared});null!=o&&o.scope&&o.scope.forEach(e=>{this.initializeSharing(e,{strategy:o.strategy})});let n=ke(this.shareScopeMap,e,o,this.hooks.lifecycle.resolveShare),i=e=>{e.useIn||(e.useIn=[]),Ft(e.useIn,r.options.name)};if(n){if("function"==typeof n.lib)return i(n),n.loaded||(n.loaded=!0,n.from===r.options.name&&(o.loaded=!0)),n.lib;if("function"==typeof n.get){let t=n.get();if(!(t instanceof Promise))return i(n),this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:t,shared:n}),t}}if(o.lib)return o.loaded||(o.loaded=!0),o.lib;if(o.get){let n=o.get();if(n instanceof Promise){let o="build"===(null==t?void 0:t.from)?tt:we;throw new Error(L(o,O,{hostName:r.options.name,sharedPkgName:e}))}return o.lib=n,this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:o.lib,shared:o}),o.lib}throw new Error(L(we,O,{hostName:r.options.name,sharedPkgName:e}))}initShareScopeMap(e,t,r={}){let{host:o}=this;this.shareScopeMap[e]=t,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:t,options:o.options,origin:o,scopeName:e,hostShareScopeMap:r.hostShareScopeMap})}setShared({pkgName:e,shared:t,from:r,lib:o,loading:n,loaded:i,get:a}){let s=t,{version:l,scope:c="default"}=s,u=xe(s,["version","scope"]);(Array.isArray(c)?c:[c]).forEach(t=>{if(this.shareScopeMap[t]||(this.shareScopeMap[t]={}),this.shareScopeMap[t][e]||(this.shareScopeMap[t][e]={}),!this.shareScopeMap[t][e][l])return this.shareScopeMap[t][e][l]=M(R({version:l,scope:[t]},u),{lib:o,loaded:i,loading:n}),void(a&&(this.shareScopeMap[t][e][l].get=a));let s=this.shareScopeMap[t][e][l];n&&!s.loading&&(s.loading=n),i&&!s.loaded&&(s.loaded=i),r&&s.from!==r&&(s.from=r)})}_setGlobalShareScopeMap(e){let t=nr(),r=e.id||e.name;r&&!t[r]&&(t[r]=this.shareScopeMap)}},ut=class{constructor(e){this.hooks=new q({beforeRegisterRemote:new X("beforeRegisterRemote"),registerRemote:new X("registerRemote"),beforeRequest:new V("beforeRequest"),onLoad:new H("onLoad"),handlePreloadModule:new D("handlePreloadModule"),errorLoadRemote:new H("errorLoadRemote"),beforePreloadRemote:new H("beforePreloadRemote"),generatePreloadAssets:new H("generatePreloadAssets"),afterPreloadRemote:new H,loadEntry:new H}),this.host=e,this.idToRemoteMap={}}formatAndRegisterRemote(e,t){return(t.remotes||[]).reduce((e,t)=>(this.registerRemote(t,e,{force:!1}),e),e.remotes)}setIdToRemoteMap(e,t){let{remote:r,expose:o}=t,{name:n,alias:i}=r;if(this.idToRemoteMap[e]={name:r.name,expose:o},i&&e.startsWith(n)){let t=e.replace(n,i);return void(this.idToRemoteMap[t]={name:r.name,expose:o})}if(i&&e.startsWith(i)){let t=e.replace(i,n);this.idToRemoteMap[t]={name:r.name,expose:o}}}async loadRemote(e,t){let{host:r}=this;try{let{loadFactory:o=!0}=t||{loadFactory:!0},{module:n,moduleOptions:i,remoteMatchInfo:a}=await this.getRemoteModuleAndOptions({id:e}),{pkgNameOrAlias:s,remote:l,expose:c,id:u,remoteSnapshot:m}=a,h=await n.get(u,c,t,m),f=await this.hooks.lifecycle.onLoad.emit({id:u,pkgNameOrAlias:s,expose:c,exposeModule:o?h:void 0,exposeModuleFactory:o?void 0:h,remote:l,options:i,moduleInstance:n,origin:r});return this.setIdToRemoteMap(e,a),"function"==typeof f?f:h}catch(o){let{from:n="runtime"}=t||{from:"runtime"},i=await this.hooks.lifecycle.errorLoadRemote.emit({id:e,error:o,from:n,lifecycle:"onLoad",origin:r});if(!i)throw o;return i}}async preloadRemote(e){let{host:t}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:e,options:t.options,origin:t});let r=Kn(t.options.remotes,e);await Promise.all(r.map(async e=>{let{remote:r}=e,o=pe(r),{globalSnapshot:n,remoteSnapshot:i}=await t.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:r}),a=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:t,preloadOptions:e,remote:r,remoteInfo:o,globalSnapshot:n,remoteSnapshot:i});a&&ar(o,t,a)}))}registerRemotes(e,t){let{host:r}=this;e.forEach(e=>{this.registerRemote(e,r.options.remotes,{force:null==t?void 0:t.force})})}async getRemoteModuleAndOptions(e){let t,{host:r}=this,{id:o}=e;try{t=await this.hooks.lifecycle.beforeRequest.emit({id:o,options:r.options,origin:r})}catch(e){if(t=await this.hooks.lifecycle.errorLoadRemote.emit({id:o,options:r.options,origin:r,from:"runtime",error:e,lifecycle:"beforeRequest"}),!t)throw e}let{id:n}=t,i=Cn(r.options.remotes,n);A(i,L(et,O,{hostName:r.options.name,requestId:n}));let{remote:a}=i,s=pe(a),l=await r.sharedHandler.hooks.lifecycle.afterResolve.emit(M(R({id:n},i),{options:r.options,origin:r,remoteInfo:s})),{remote:c,expose:u}=l;A(c&&u,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${n}.`);let m=r.moduleCache.get(c.name),h={host:r,remoteInfo:s};return m||(m=new oe(h),r.moduleCache.set(c.name,m)),{module:m,moduleOptions:h,remoteMatchInfo:l}}registerRemote(e,t,r){let{host:o}=this,n=()=>{if(e.alias){let r=t.find(t=>{var r;return e.alias&&(t.name.startsWith(e.alias)||(null==(r=t.alias)?void 0:r.startsWith(e.alias)))});A(!r,`The alias ${e.alias} of remote ${e.name} is not allowed to be the prefix of ${r&&r.name} name or alias`)}"entry"in e&&U()&&!e.entry.startsWith("http")&&(e.entry=new URL(e.entry,window.location.origin).href),e.shareScope||(e.shareScope=me),e.type||(e.type=Yt)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:e,origin:o});let i=t.find(t=>t.name===e.name);if(i){let a=[`The remote "${e.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];null!=r&&r.force&&(this.removeRemote(i),n(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:o}),Se(a.join(" ")))}else n(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:o})}removeRemote(e){var t;try{let{host:r}=this,{name:o}=e,n=r.options.remotes.findIndex(e=>e.name===o);-1!==n&&r.options.remotes.splice(n,1);let i=r.moduleCache.get(e.name);if(i){let o=i.remoteInfo,n=o.entryGlobalName;P[n]&&(null!=(t=Object.getOwnPropertyDescriptor(P,n))&&t.configurable?delete P[n]:P[n]=void 0);let a=at(i.remoteInfo);Q[a]&&delete Q[a],r.snapshotHandler.manifestCache.delete(o.entry);let s=o.buildVersion?Re(o.name,o.buildVersion):o.name,l=P.__FEDERATION__.__INSTANCES__.findIndex(e=>o.buildVersion?e.options.id===s:e.name===s);if(-1!==l){let e=P.__FEDERATION__.__INSTANCES__[l];s=e.options.id||s;let t=nr(),r=!0,n=[];Object.keys(t).forEach(e=>{let i=t[e];i&&Object.keys(i).forEach(t=>{let a=i[t];a&&Object.keys(a).forEach(i=>{let s=a[i];s&&Object.keys(s).forEach(a=>{let l=s[a];l&&"object"==typeof l&&l.from===o.name&&(l.loaded||l.loading?(l.useIn=l.useIn.filter(e=>e!==o.name),l.useIn.length?r=!1:n.push([e,t,i,a])):n.push([e,t,i,a]))})})})}),r&&(e.shareScopeMap={},delete t[s]),n.forEach(([e,r,o,n])=>{var i,a,s;null==(s=null==(a=null==(i=t[e])?void 0:i[r])?void 0:a[o])||delete s[n]}),P.__FEDERATION__.__INSTANCES__.splice(l,1)}let{hostGlobalSnapshot:c}=fr(e,r);if(c){let t=c&&"remotesInfo"in c&&c.remotesInfo&&te(c.remotesInfo,e.name).key;t&&(delete c.remotesInfo[t],de.__FEDERATION__.__MANIFEST_LOADING__[t]&&delete de.__FEDERATION__.__MANIFEST_LOADING__[t])}r.moduleCache.delete(e.name)}}catch(e){it.log("removeRemote fail: ",e)}}},Zn="boolean"!=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN||!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN,Y=class{constructor(e){this.hooks=new q({beforeInit:new X("beforeInit"),init:new D,beforeInitContainer:new V("beforeInitContainer"),initContainer:new V("initContainer")}),this.version="0.21.4",this.moduleCache=new Map,this.loaderHook=new q({getModuleInfo:new D,createScript:new D,createLink:new D,fetch:new H,loadEntryError:new H,getModuleFactory:new H}),this.bridgeHook=new q({beforeBridgeRender:new D,afterBridgeRender:new D,beforeBridgeDestroy:new D,afterBridgeDestroy:new D});let t=Zn?[zn(),Jn()]:[],r={id:Hn(),name:e.name,plugins:t,remotes:[],shared:{},inBrowser:U()};this.name=e.name,this.options=r,this.snapshotHandler=new ct(this),this.sharedHandler=new lt(this),this.remoteHandler=new ut(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...r.plugins,...e.plugins||[]]),this.options=this.formatOptions(r,e)}initOptions(e){this.registerPlugins(e.plugins);let 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=me,t){return this.sharedHandler.initializeSharing(e,t)}initRawContainer(e,t,r){let o=pe({name:e,entry:t}),n=new oe({host:this,remoteInfo:o});return n.remoteEntryExports=r,this.moduleCache.set(e,n),n}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){let{shared:r}=rr(e,t),{userOptions:o,options:n}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:t,options:e,shareInfo:r}),i=this.remoteHandler.formatAndRegisterRemote(n,o),{shared:a}=this.sharedHandler.registerShared(n,o),s=[...n.plugins];o.plugins&&o.plugins.forEach(e=>{s.includes(e)||s.push(e)});let l=M(R(R({},e),t),{plugins:s,remotes:i,shared:a});return this.hooks.lifecycle.init.emit({origin:this,options:l}),l}registerPlugins(e){let t=Gn(e,this);this.options.plugins=this.options.plugins.reduce((e,t)=>(t&&e&&!e.find(e=>e.name===t.name)&&e.push(t),e),t||[])}registerRemotes(e,t){return this.remoteHandler.registerRemotes(e,t)}registerShared(e){this.sharedHandler.registerShared(this.options,M(R({},this.options),{shared:e}))}};function Qn(){return"undefined"!=typeof FEDERATION_BUILD_IDENTIFIER?FEDERATION_BUILD_IDENTIFIER:""}function dr(e,t){let r=Qn();return P.__FEDERATION__.__INSTANCES__.find(o=>!!(r&&o.options.id===r||o.options.name===e&&!o.options.version&&!t||o.options.name===e&&t&&o.options.version===t))}function hr(e){let t=new(qt()||Y)(e);return Kt(t),t}var I=null;function eo(e){let t=dr(e.name,e.version);return t?(t.initOptions(e),I||(I=t),t):I=hr(e)}function to(...e){return A(I,L(K,O)),I.loadRemote.apply(I,e)}function ro(...e){return A(I,L(K,O)),I.loadShare.apply(I,e)}function no(...e){return A(I,L(K,O)),I.loadShareSync.apply(I,e)}function oo(...e){return A(I,L(K,O)),I.preloadRemote.apply(I,e)}function so(...e){return A(I,L(K,O)),I.registerRemotes.apply(I,e)}function io(...e){return A(I,L(K,O)),I.registerPlugins.apply(I,e)}function ao(){return I}function co(...e){return A(I,L(K,O)),I.registerShared.apply(I,e)}return zt(Y),exports.MFRuntime=Et,exports.MFSDK=Ye,exports}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/share",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.5",
|
|
4
4
|
"description": "emp share and runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
},
|
|
151
151
|
"devDependencies": {
|
|
152
152
|
"@swc/core": "^1.15.1",
|
|
153
|
-
"@empjs/cli": "3.10.
|
|
153
|
+
"@empjs/cli": "3.10.8"
|
|
154
154
|
},
|
|
155
155
|
"scripts": {
|
|
156
156
|
"dev": "pnpm --filter @empjs/share run /^dev:.*/",
|