@empjs/share 3.2.0 → 3.3.1-beta.1
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/adapter.cjs +1 -1
- package/dist/adapter.cjs.map +1 -1
- package/dist/adapter.d.cts +8 -3
- package/dist/adapter.d.ts +8 -3
- package/dist/adapter.js +1 -1
- package/dist/adapter.js.map +1 -1
- package/dist/{index-CLt6ciOL.d.cts → index-DU656k6V.d.cts} +4 -4
- package/dist/{index-CLt6ciOL.d.ts → index-DU656k6V.d.ts} +4 -4
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.cjs.map +1 -1
- package/dist/rspack.js +2 -2
- package/dist/rspack.js.map +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +6 -5
- package/dist/runtime.d.ts +6 -5
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/output/full.d.ts +9 -8
- package/output/full.js +1 -1
- package/output/full.js.map +1 -1
- package/output/sdk.js +1 -1
- package/output/sdk.js.map +1 -1
- package/output/sdkPolyfill.js +1 -1
- package/output/sdkPolyfill.js.map +1 -1
- package/package.json +21 -36
package/dist/rspack.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{ModuleFederationPlugin as
|
|
2
|
-
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:i}=e,{runtimeLib:
|
|
1
|
+
import{ModuleFederationPlugin as E}from"@module-federation/enhanced/rspack";var h="EMP_SHARE_RUNTIME";var b=r=>`data:text/javascript,${r}`;var R=!1,k=R?console.log.bind(console,"[EMP Share]"):()=>{};var d=r=>{let e=[`import '${r}'`].join(`
|
|
2
|
+
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:i}=e,{runtimeLib:s}=this.options;if(!s){let o=d("@empjs/share/library");new i.EntryPlugin(e.context,o,{name:void 0}).apply(e)}}};function y(r,e){return typeof r=="string"?`${r}/runtime${e==="development"?".development":""}.umd.js`:typeof r=="object"?e==="development"?r.dev:r.prod:""}var g=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,i){this.op=e||{},this.store=i}setup(){this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:i}=this;i.length>0&&e.injectTags(i,"EMPShare")}injectFramework(){if(!this.op.empRuntime||!this.op.empRuntime.frameworkLib)return;let{store:e,injectHtml:i}=this,{frameworkLib:s}=this.op.empRuntime;if(s){let o=y(s,e.mode);i.push({attributes:{src:o},tagName:"script"})}}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:i}=this;e.framework=Object.hasOwn(e,"framework")?e.framework:"react",e.runtimeGlobal=e.runtimeGlobal||h,e.frameworkGlobal=e.frameworkGlobal||(e.shareLib?"window":""),e.injectGlobalValToHtml!==!1&&i.push({tagName:"script",innerHTML:`EMPShareGlobalVal={frameworkLib:'${e.frameworkGlobal}',runtimeLib:'${e.runtimeGlobal}',framework:'${e.framework}'}`})}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:i}=this,{empRuntime:s}=this.op,{framework:o,shareLib:n,runtimeGlobal:t,frameworkGlobal:a}=s,f={"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"},p={};for(let[m,u]of Object.entries(f))p[m]=`${t}.${u}`;if(o==="react"&&!n&&a){let m={react:"React","react-dom":"ReactDOM"};for(let[u,j]of Object.entries(m))p[u]=`${a}.${j}`}n&&i.map(m=>{m.type==="js"&&m.module&&m.global&&(p[m.module]=`${a}.${m.global}`)}),s.setExternals&&s.setExternals(p),e.chain.merge({externals:p})}setRuntimeLib(){if(!this.op.empRuntime)return;let{runtimeLib:e,shareLib:i}=this.op.empRuntime,{store:s,injectHtml:o}=this,{empRuntime:n}=this.op;e?e==="useFrameworkLib"&&!i||o.push({tagName:"script",pos:"head",attributes:{src:e}}):s.chain.plugin("plugin-emp-share-framework").use(l,[n])}setMF(){let e=this.op,{store:i}=this;if(e.name){let s=i.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);s.empRuntime&&delete s.empRuntime,i.chain.plugin("plugin-emp-share").use(E,[s])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:i,injectHtml:s}=this;if(e&&typeof e=="object"){for(let[o,n]of Object.entries(e)){let t={};if(t.module=o,typeof n=="string"){let a=n.match(g)||[];a.length>0?(t.global=a[1],t.entry=a[2],t.type="js",i.push(t),t={}):(t.global="",t.entry=n,t.type="js",i.push(t),t={})}else Array.isArray(n)?n.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))t.entry=a,t.type="css";else{let p=a.match(g)||[];p.length>0?(t.global=p[1],t.entry=p[2],t.type="js"):(t.global="",t.entry=a,t.type="js")}i.push(t),t={}}):typeof n=="object"&&n.entry&&(t.entry=n.entry,t.global=n.global,t.type=n.type,i.push(t),t={})}i.map(o=>{o.type==="js"?s.push({attributes:{src:o.entry},tagName:"script"}):o.type==="css"&&s.push({attributes:{href:o.entry,rel:"stylesheet"},tagName:"link"})})}}};var S=(r={})=>({name:"@empjs/share",async rsConfig(e){r.manifest===!0?r.manifest={fileName:"emp.json"}:typeof r.manifest=="object"&&(r.manifest=e.deepAssign({fileName:"emp.json"},r.manifest)),new c(r,e).setup()}}),$=S;export{$ as default,S as pluginRspackEmpShare};
|
|
3
3
|
//# sourceMappingURL=rspack.js.map
|
package/dist/rspack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/rspack/share.ts","../src/helper/config.ts","../src/helper/index.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/index.ts"],"sourcesContent":["import type {GlobalStore} from '@empjs/cli'\nimport {ModuleFederationPlugin} from '@module-federation/enhanced/rspack'\nimport {shareGlobalName} from 'src/helper/config'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {EMPPluginShareType, ExternalsItemType, ModuleFederationPluginOptions} from './types'\nimport {getRuntimeLib} from './utils'\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.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.op.empRuntime || !this.op.empRuntime.frameworkLib) return\n const {store, injectHtml} = this\n const {frameworkLib} = this.op.empRuntime\n if (frameworkLib) {\n const url = getRuntimeLib(frameworkLib, store.mode)\n 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 empRuntime.framework = Object.hasOwn(empRuntime, 'framework') ? empRuntime.framework : 'react'\n empRuntime.runtimeGlobal = empRuntime.runtimeGlobal || shareGlobalName\n empRuntime.frameworkGlobal = empRuntime.frameworkGlobal || (empRuntime.shareLib ? 'window' : '')\n\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal={frameworkLib:'${empRuntime.frameworkGlobal}',runtimeLib:'${empRuntime.runtimeGlobal}',framework:'${empRuntime.framework}'}`,\n })\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {framework, shareLib, runtimeGlobal, frameworkGlobal} = empRuntime\n const externalRuntime = {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${runtimeGlobal}.${value}`\n }\n if (framework === 'react' && !shareLib && frameworkGlobal) {\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${frameworkGlobal}.${value}`\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${frameworkGlobal}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals)\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 {runtimeLib, shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!runtimeLib) {\n // 内置 runtimeLib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (runtimeLib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: runtimeLib}})\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 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 shareGlobalName = 'EMP_SHARE_RUNTIME'\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","import type {Compiler} from '@rspack/core'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\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 {runtimeLib} = this.options\n if (!runtimeLib) {\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string) {\n if (typeof host === 'string') return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\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 {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n"],"mappings":"AACA,OAAQ,0BAAAA,MAA6B,qCCD9B,IAAMC,EAAkB,oBCAxB,IAAMC,EAAcC,GAAoB,wBAAwBA,CAAO,GCG9E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,CAAC,CAEL,CAAC,CACH,CACF,CACF,EKtNO,IAAMS,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAChB,IAAIC,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ","names":["ModuleFederationPlugin","shareGlobalName","importJsVm","content","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","runtimeLib","entry","getRuntimeLib","host","mode","exp","EmpShare","op","store","injectHtml","frameworkLib","url","getRuntimeLib","empRuntime","shareGlobalName","externalsLib","framework","shareLib","runtimeGlobal","frameworkGlobal","externalRuntime","externals","key","value","externalReact","v","runtimeLib","EmpShareRemoteLibPlugin","o","ModuleFederationPlugin","k","externalsItem","cb","vo","pluginRspackEmpShare","o","store","EmpShare","rspack_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugins/rspack/share.ts","../src/helper/config.ts","../src/helper/index.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/index.ts"],"sourcesContent":["import type {GlobalStore} from '@empjs/cli'\nimport {ModuleFederationPlugin} from '@module-federation/enhanced/rspack'\nimport {shareGlobalName} from 'src/helper/config'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {EMPPluginShareType, ExternalsItemType, ModuleFederationPluginOptions} from './types'\nimport {getRuntimeLib} from './utils'\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.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.op.empRuntime || !this.op.empRuntime.frameworkLib) return\n const {store, injectHtml} = this\n const {frameworkLib} = this.op.empRuntime\n if (frameworkLib) {\n const url = getRuntimeLib(frameworkLib, store.mode)\n 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 empRuntime.framework = Object.hasOwn(empRuntime, 'framework') ? empRuntime.framework : 'react'\n empRuntime.runtimeGlobal = empRuntime.runtimeGlobal || shareGlobalName\n empRuntime.frameworkGlobal = empRuntime.frameworkGlobal || (empRuntime.shareLib ? 'window' : '')\n\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal={frameworkLib:'${empRuntime.frameworkGlobal}',runtimeLib:'${empRuntime.runtimeGlobal}',framework:'${empRuntime.framework}'}`,\n })\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {framework, shareLib, runtimeGlobal, frameworkGlobal} = empRuntime\n const externalRuntime = {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${runtimeGlobal}.${value}`\n }\n if (framework === 'react' && !shareLib && frameworkGlobal) {\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${frameworkGlobal}.${value}`\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${frameworkGlobal}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals)\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 {runtimeLib, shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!runtimeLib) {\n // 内置 runtimeLib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (runtimeLib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: runtimeLib}})\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 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 shareGlobalName = 'EMP_SHARE_RUNTIME'\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","import type {Compiler} from '@rspack/core'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\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 {runtimeLib} = this.options\n if (!runtimeLib) {\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string) {\n if (typeof host === 'string') return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\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 {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\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 //\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n"],"mappings":"AACA,OAAQ,0BAAAA,MAA6B,qCCD9B,IAAMC,EAAkB,oBCAxB,IAAMC,EAAcC,GAAoB,wBAAwBA,CAAO,GAqBvE,IAAMC,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECnB7E,IAAME,EAAuBC,GAAO,CAClC,IAAMC,EAAU,CAAC,WAAWD,CAAG,GAAG,EAAE,KAAK;AAAA,CAAI,EAC7C,OAAOE,EAAWD,CAAO,CAC3B,EACaE,EAAN,KAA8B,CACnC,QACA,YAAYC,EAA4B,CACtC,KAAK,QAAUA,CACjB,CACA,MAAMC,EAAoB,CACxB,GAAM,CAAC,QAAAC,CAAO,EAAID,EACZ,CAAC,WAAAE,CAAU,EAAI,KAAK,QAC1B,GAAI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EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ","names":["ModuleFederationPlugin","shareGlobalName","importJsVm","content","isDev","log","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","runtimeLib","entry","getRuntimeLib","host","mode","exp","EmpShare","op","store","injectHtml","frameworkLib","url","getRuntimeLib","empRuntime","shareGlobalName","externalsLib","framework","shareLib","runtimeGlobal","frameworkGlobal","externalRuntime","externals","key","value","externalReact","v","runtimeLib","EmpShareRemoteLibPlugin","o","ModuleFederationPlugin","k","externalsItem","cb","vo","pluginRspackEmpShare","o","store","EmpShare","rspack_default"]}
|
package/dist/runtime.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var r=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var y=(e,i)=>{for(var t in i)r(e,t,{get:i[t],enumerable:!0})},d=(e,i,t,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of h(i))!R.call(e,o)&&o!==t&&r(e,o,{get:()=>i[o],enumerable:!(s=b(i,o))||s.enumerable});return e};var T=e=>d(r({},"__esModule",{value:!0}),e);var E={};y(E,{EMPRuntime:()=>n,default:()=>M});module.exports=T(E);function l(e,...i){for(let t of i)for(let s in t){let o=t[s],p=e[s];if(Object(o)==o&&Object(p)===p){e[s]=l(p,o);continue}e[s]=t[s]}return e}var f=!1,S=f?console.log.bind(console,"[EMP Share]"):()=>{};var a="EMP_SHARE_RUNTIME";var c=window[a]||{},u=window,{EMPShareGlobalVal:m}=u||{};m&&m.runtimeLib&&(c=u[m.runtimeLib]);var n=class{libs=c;initOptions;options={showLog:!1};shareGlobalName=a;isInit=!1;constructor(i){i&&this.setup(i)}setup(i){if(i&&(typeof i=="string"&&(i=window[i]),this.libs=i),!this.libs.MFRuntime||!this.libs.MFSDK)throw new Error("MFRuntime and MFSDK Required!")}init(i={}){if(this.isInit)return;let t={name:"empRuntimeProject",remotes:[]};t=l(t,i),this.libs.MFRuntime.init(t),this.isInit=!0}load(...i){return this.libs.MFRuntime.loadRemote(...i)}register=this.libs?.MFRuntime.registerRemotes;preload=this.libs?.MFRuntime.preloadRemote;loadShare=this.libs?.MFRuntime.loadShare;preloadRemote=this.libs?.MFRuntime.preloadRemote},M=new n;0&&(module.exports={EMPRuntime});
|
|
2
2
|
//# sourceMappingURL=runtime.cjs.map
|
package/dist/runtime.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/index.ts","../src/helper/index.ts","../src/helper/config.ts"],"sourcesContent":["import {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport type {EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType} from 'src/types'\ntype EmpInitOptionsType = Partial<InitOptionsType>\nlet globalLib = window[shareGlobalName] || {}\n// 根据 injectGlobalValToHtml 提前把库赋值到 EMPRuntime\nconst win: any = window\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.runtimeLib) {\n globalLib = win[EMPShareGlobalVal.runtimeLib]\n}\n\nexport class EMPRuntime {\n public libs: EMPShareRuntimeType = globalLib\n public initOptions!: InitOptionsType\n public options: EmpRuntimeOptions = {\n showLog: false,\n }\n public shareGlobalName = shareGlobalName\n private isInit = false\n constructor(op?: EMPShareRuntimeType) {\n if (op) this.setup(op)\n }\n /**\n * 实例化 adapter libs\n */\n public setup(o?: EMPShareRuntimeType | string) {\n if (o) {\n if (typeof o === 'string') o = window[o]\n this.libs = o as any\n }\n if (!this.libs.MFRuntime || !this.libs.MFSDK) {\n throw new Error('MFRuntime and MFSDK Required!')\n }\n }\n public init(options: EmpInitOptionsType = {}) {\n if (this.isInit) return\n let op: InitOptionsType = {\n name: 'empRuntimeProject',\n remotes: [],\n // plugins: [catchErrorNextPlugin(this.options.showLog)],\n }\n op = deepAssign<InitOptionsType>(op, options)\n this.libs.MFRuntime.init(op)\n this.isInit = true\n }\n public load<T = any>(...args: LoadRemoteType) {\n return this.libs.MFRuntime.loadRemote<T>(...args) as Promise<T>\n }\n public register = this.libs?.MFRuntime.registerRemotes\n public preload = this.libs?.MFRuntime.preloadRemote\n public loadShare = this.libs?.MFRuntime.loadShare\n}\n//\nexport default new EMPRuntime()\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","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GCEO,SAASK,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,
|
|
1
|
+
{"version":3,"sources":["../src/runtime/index.ts","../src/helper/index.ts","../src/helper/config.ts"],"sourcesContent":["import {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport type {EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType} from 'src/types'\ntype EmpInitOptionsType = Partial<InitOptionsType>\nlet globalLib = window[shareGlobalName] || {}\n// 根据 injectGlobalValToHtml 提前把库赋值到 EMPRuntime\nconst win: any = window\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.runtimeLib) {\n globalLib = win[EMPShareGlobalVal.runtimeLib]\n}\n\nexport class EMPRuntime {\n public libs: EMPShareRuntimeType = globalLib\n public initOptions!: InitOptionsType\n public options: EmpRuntimeOptions = {\n showLog: false,\n }\n public shareGlobalName = shareGlobalName\n private isInit = false\n constructor(op?: EMPShareRuntimeType) {\n if (op) this.setup(op)\n }\n /**\n * 实例化 adapter libs\n */\n public setup(o?: EMPShareRuntimeType | string) {\n if (o) {\n if (typeof o === 'string') o = window[o]\n this.libs = o as any\n }\n if (!this.libs.MFRuntime || !this.libs.MFSDK) {\n throw new Error('MFRuntime and MFSDK Required!')\n }\n }\n public init(options: EmpInitOptionsType = {}) {\n if (this.isInit) return\n let op: InitOptionsType = {\n name: 'empRuntimeProject',\n remotes: [],\n // plugins: [catchErrorNextPlugin(this.options.showLog)],\n }\n op = deepAssign<InitOptionsType>(op, options)\n this.libs.MFRuntime.init(op)\n this.isInit = true\n }\n public load<T = any>(...args: LoadRemoteType) {\n return this.libs.MFRuntime.loadRemote<T>(...args) as Promise<T>\n }\n public register = this.libs?.MFRuntime.registerRemotes\n public preload = this.libs?.MFRuntime.preloadRemote\n public loadShare = this.libs?.MFRuntime.loadShare\n public preloadRemote = this.libs?.MFRuntime.preloadRemote\n}\n//\nexport default new EMPRuntime()\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"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GCEO,SAASK,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,oBFI/B,IAAIC,EAAY,OAAOC,CAAe,GAAK,CAAC,EAEtCC,EAAW,OACX,CAAC,kBAAAC,CAAiB,EAAID,GAAO,CAAC,EAChCC,GAAqBA,EAAkB,aACzCH,EAAYE,EAAIC,EAAkB,UAAU,GAGvC,IAAMC,EAAN,KAAiB,CACf,KAA4BJ,EAC5B,YACA,QAA6B,CAClC,QAAS,EACX,EACO,gBAAkBC,EACjB,OAAS,GACjB,YAAYI,EAA0B,CAChCA,GAAI,KAAK,MAAMA,CAAE,CACvB,CAIO,MAAMC,EAAkC,CAK7C,GAJIA,IACE,OAAOA,GAAM,WAAUA,EAAI,OAAOA,CAAC,GACvC,KAAK,KAAOA,GAEV,CAAC,KAAK,KAAK,WAAa,CAAC,KAAK,KAAK,MACrC,MAAM,IAAI,MAAM,+BAA+B,CAEnD,CACO,KAAKC,EAA8B,CAAC,EAAG,CAC5C,GAAI,KAAK,OAAQ,OACjB,IAAIF,EAAsB,CACxB,KAAM,oBACN,QAAS,CAAC,CAEZ,EACAA,EAAKG,EAA4BH,EAAIE,CAAO,EAC5C,KAAK,KAAK,UAAU,KAAKF,CAAE,EAC3B,KAAK,OAAS,EAChB,CACO,QAAiBI,EAAsB,CAC5C,OAAO,KAAK,KAAK,UAAU,WAAc,GAAGA,CAAI,CAClD,CACO,SAAW,KAAK,MAAM,UAAU,gBAChC,QAAU,KAAK,MAAM,UAAU,cAC/B,UAAY,KAAK,MAAM,UAAU,UACjC,cAAgB,KAAK,MAAM,UAAU,aAC9C,EAEOC,EAAQ,IAAIN","names":["runtime_exports","__export","EMPRuntime","runtime_default","__toCommonJS","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","globalLib","shareGlobalName","win","EMPShareGlobalVal","EMPRuntime","op","o","options","deepAssign","args","runtime_default"]}
|
package/dist/runtime.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { E as EMPShareRuntimeType, I as InitOptionsType, a as EmpRuntimeOptions, L as LoadRemoteType } from './index-
|
|
1
|
+
import * as _module_federation_enhanced_runtime from '@module-federation/enhanced/runtime';
|
|
2
|
+
import { E as EMPShareRuntimeType, I as InitOptionsType, a as EmpRuntimeOptions, L as LoadRemoteType } from './index-DU656k6V.cjs';
|
|
3
3
|
import '@module-federation/sdk';
|
|
4
4
|
|
|
5
5
|
type EmpInitOptionsType = Partial<InitOptionsType>;
|
|
@@ -16,9 +16,10 @@ declare class EMPRuntime {
|
|
|
16
16
|
setup(o?: EMPShareRuntimeType | string): void;
|
|
17
17
|
init(options?: EmpInitOptionsType): void;
|
|
18
18
|
load<T = any>(...args: LoadRemoteType): Promise<T>;
|
|
19
|
-
register: typeof
|
|
20
|
-
preload: typeof
|
|
21
|
-
loadShare: typeof
|
|
19
|
+
register: typeof _module_federation_enhanced_runtime.registerRemotes;
|
|
20
|
+
preload: typeof _module_federation_enhanced_runtime.preloadRemote;
|
|
21
|
+
loadShare: typeof _module_federation_enhanced_runtime.loadShare;
|
|
22
|
+
preloadRemote: typeof _module_federation_enhanced_runtime.preloadRemote;
|
|
22
23
|
}
|
|
23
24
|
declare const _default: EMPRuntime;
|
|
24
25
|
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { E as EMPShareRuntimeType, I as InitOptionsType, a as EmpRuntimeOptions, L as LoadRemoteType } from './index-
|
|
1
|
+
import * as _module_federation_enhanced_runtime from '@module-federation/enhanced/runtime';
|
|
2
|
+
import { E as EMPShareRuntimeType, I as InitOptionsType, a as EmpRuntimeOptions, L as LoadRemoteType } from './index-DU656k6V.js';
|
|
3
3
|
import '@module-federation/sdk';
|
|
4
4
|
|
|
5
5
|
type EmpInitOptionsType = Partial<InitOptionsType>;
|
|
@@ -16,9 +16,10 @@ declare class EMPRuntime {
|
|
|
16
16
|
setup(o?: EMPShareRuntimeType | string): void;
|
|
17
17
|
init(options?: EmpInitOptionsType): void;
|
|
18
18
|
load<T = any>(...args: LoadRemoteType): Promise<T>;
|
|
19
|
-
register: typeof
|
|
20
|
-
preload: typeof
|
|
21
|
-
loadShare: typeof
|
|
19
|
+
register: typeof _module_federation_enhanced_runtime.registerRemotes;
|
|
20
|
+
preload: typeof _module_federation_enhanced_runtime.preloadRemote;
|
|
21
|
+
loadShare: typeof _module_federation_enhanced_runtime.loadShare;
|
|
22
|
+
preloadRemote: typeof _module_federation_enhanced_runtime.preloadRemote;
|
|
22
23
|
}
|
|
23
24
|
declare const _default: EMPRuntime;
|
|
24
25
|
|
package/dist/runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function p(
|
|
1
|
+
function p(t,...i){for(let e of i)for(let o in e){let s=e[o],n=t[o];if(Object(s)==s&&Object(n)===n){t[o]=p(n,s);continue}t[o]=e[o]}return t}var u=!1,b=u?console.log.bind(console,"[EMP Share]"):()=>{};var r="EMP_SHARE_RUNTIME";var m=window[r]||{},c=window,{EMPShareGlobalVal:l}=c||{};l&&l.runtimeLib&&(m=c[l.runtimeLib]);var a=class{libs=m;initOptions;options={showLog:!1};shareGlobalName=r;isInit=!1;constructor(i){i&&this.setup(i)}setup(i){if(i&&(typeof i=="string"&&(i=window[i]),this.libs=i),!this.libs.MFRuntime||!this.libs.MFSDK)throw new Error("MFRuntime and MFSDK Required!")}init(i={}){if(this.isInit)return;let e={name:"empRuntimeProject",remotes:[]};e=p(e,i),this.libs.MFRuntime.init(e),this.isInit=!0}load(...i){return this.libs.MFRuntime.loadRemote(...i)}register=this.libs?.MFRuntime.registerRemotes;preload=this.libs?.MFRuntime.preloadRemote;loadShare=this.libs?.MFRuntime.loadShare;preloadRemote=this.libs?.MFRuntime.preloadRemote},T=new a;export{a as EMPRuntime,T as default};
|
|
2
2
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helper/index.ts","../src/helper/config.ts","../src/runtime/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","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","import {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport type {EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType} from 'src/types'\ntype EmpInitOptionsType = Partial<InitOptionsType>\nlet globalLib = window[shareGlobalName] || {}\n// 根据 injectGlobalValToHtml 提前把库赋值到 EMPRuntime\nconst win: any = window\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.runtimeLib) {\n globalLib = win[EMPShareGlobalVal.runtimeLib]\n}\n\nexport class EMPRuntime {\n public libs: EMPShareRuntimeType = globalLib\n public initOptions!: InitOptionsType\n public options: EmpRuntimeOptions = {\n showLog: false,\n }\n public shareGlobalName = shareGlobalName\n private isInit = false\n constructor(op?: EMPShareRuntimeType) {\n if (op) this.setup(op)\n }\n /**\n * 实例化 adapter libs\n */\n public setup(o?: EMPShareRuntimeType | string) {\n if (o) {\n if (typeof o === 'string') o = window[o]\n this.libs = o as any\n }\n if (!this.libs.MFRuntime || !this.libs.MFSDK) {\n throw new Error('MFRuntime and MFSDK Required!')\n }\n }\n public init(options: EmpInitOptionsType = {}) {\n if (this.isInit) return\n let op: InitOptionsType = {\n name: 'empRuntimeProject',\n remotes: [],\n // plugins: [catchErrorNextPlugin(this.options.showLog)],\n }\n op = deepAssign<InitOptionsType>(op, options)\n this.libs.MFRuntime.init(op)\n this.isInit = true\n }\n public load<T = any>(...args: LoadRemoteType) {\n return this.libs.MFRuntime.loadRemote<T>(...args) as Promise<T>\n }\n public register = this.libs?.MFRuntime.registerRemotes\n public preload = this.libs?.MFRuntime.preloadRemote\n public loadShare = this.libs?.MFRuntime.loadShare\n}\n//\nexport default new EMPRuntime()\n"],"mappings":"AAEO,SAASA,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,
|
|
1
|
+
{"version":3,"sources":["../src/helper/index.ts","../src/helper/config.ts","../src/runtime/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","import {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport type {EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType} from 'src/types'\ntype EmpInitOptionsType = Partial<InitOptionsType>\nlet globalLib = window[shareGlobalName] || {}\n// 根据 injectGlobalValToHtml 提前把库赋值到 EMPRuntime\nconst win: any = window\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.runtimeLib) {\n globalLib = win[EMPShareGlobalVal.runtimeLib]\n}\n\nexport class EMPRuntime {\n public libs: EMPShareRuntimeType = globalLib\n public initOptions!: InitOptionsType\n public options: EmpRuntimeOptions = {\n showLog: false,\n }\n public shareGlobalName = shareGlobalName\n private isInit = false\n constructor(op?: EMPShareRuntimeType) {\n if (op) this.setup(op)\n }\n /**\n * 实例化 adapter libs\n */\n public setup(o?: EMPShareRuntimeType | string) {\n if (o) {\n if (typeof o === 'string') o = window[o]\n this.libs = o as any\n }\n if (!this.libs.MFRuntime || !this.libs.MFSDK) {\n throw new Error('MFRuntime and MFSDK Required!')\n }\n }\n public init(options: EmpInitOptionsType = {}) {\n if (this.isInit) return\n let op: InitOptionsType = {\n name: 'empRuntimeProject',\n remotes: [],\n // plugins: [catchErrorNextPlugin(this.options.showLog)],\n }\n op = deepAssign<InitOptionsType>(op, options)\n this.libs.MFRuntime.init(op)\n this.isInit = true\n }\n public load<T = any>(...args: LoadRemoteType) {\n return this.libs.MFRuntime.loadRemote<T>(...args) as Promise<T>\n }\n public register = this.libs?.MFRuntime.registerRemotes\n public preload = this.libs?.MFRuntime.preloadRemote\n public loadShare = this.libs?.MFRuntime.loadShare\n public preloadRemote = this.libs?.MFRuntime.preloadRemote\n}\n//\nexport default new EMPRuntime()\n"],"mappings":"AAEO,SAASA,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,oBCI/B,IAAIC,EAAY,OAAOC,CAAe,GAAK,CAAC,EAEtCC,EAAW,OACX,CAAC,kBAAAC,CAAiB,EAAID,GAAO,CAAC,EAChCC,GAAqBA,EAAkB,aACzCH,EAAYE,EAAIC,EAAkB,UAAU,GAGvC,IAAMC,EAAN,KAAiB,CACf,KAA4BJ,EAC5B,YACA,QAA6B,CAClC,QAAS,EACX,EACO,gBAAkBC,EACjB,OAAS,GACjB,YAAYI,EAA0B,CAChCA,GAAI,KAAK,MAAMA,CAAE,CACvB,CAIO,MAAMC,EAAkC,CAK7C,GAJIA,IACE,OAAOA,GAAM,WAAUA,EAAI,OAAOA,CAAC,GACvC,KAAK,KAAOA,GAEV,CAAC,KAAK,KAAK,WAAa,CAAC,KAAK,KAAK,MACrC,MAAM,IAAI,MAAM,+BAA+B,CAEnD,CACO,KAAKC,EAA8B,CAAC,EAAG,CAC5C,GAAI,KAAK,OAAQ,OACjB,IAAIF,EAAsB,CACxB,KAAM,oBACN,QAAS,CAAC,CAEZ,EACAA,EAAKG,EAA4BH,EAAIE,CAAO,EAC5C,KAAK,KAAK,UAAU,KAAKF,CAAE,EAC3B,KAAK,OAAS,EAChB,CACO,QAAiBI,EAAsB,CAC5C,OAAO,KAAK,KAAK,UAAU,WAAc,GAAGA,CAAI,CAClD,CACO,SAAW,KAAK,MAAM,UAAU,gBAChC,QAAU,KAAK,MAAM,UAAU,cAC/B,UAAY,KAAK,MAAM,UAAU,UACjC,cAAgB,KAAK,MAAM,UAAU,aAC9C,EAEOC,EAAQ,IAAIN","names":["deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","globalLib","shareGlobalName","win","EMPShareGlobalVal","EMPRuntime","op","o","options","deepAssign","args","runtime_default"]}
|
package/output/full.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import MFSDK__default from '@module-federation/sdk';
|
|
2
2
|
import * as MFSDK from '@module-federation/sdk';
|
|
3
3
|
export { MFSDK };
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
4
|
+
import * as _module_federation_enhanced_runtime from '@module-federation/enhanced/runtime';
|
|
5
|
+
import _module_federation_enhanced_runtime__default from '@module-federation/enhanced/runtime';
|
|
6
6
|
import * as moduleFederationRuntime from '@empjs/module-federation-runtime';
|
|
7
7
|
export { moduleFederationRuntime as MFRuntime };
|
|
8
8
|
|
|
9
9
|
type EMPShareRuntimeType = {
|
|
10
|
-
MFRuntime: Required<typeof
|
|
10
|
+
MFRuntime: Required<typeof _module_federation_enhanced_runtime__default>;
|
|
11
11
|
MFSDK: Required<typeof MFSDK__default>;
|
|
12
12
|
};
|
|
13
13
|
type EMPShareRuntimeAdapterReactType = {
|
|
@@ -17,8 +17,8 @@ type EMPShareRuntimeAdapterReactType = {
|
|
|
17
17
|
hydrateRoot?: any;
|
|
18
18
|
scope: string;
|
|
19
19
|
};
|
|
20
|
-
type InitOptionsType = Parameters<typeof
|
|
21
|
-
type LoadRemoteType = Parameters<typeof
|
|
20
|
+
type InitOptionsType = Parameters<typeof _module_federation_enhanced_runtime__default.init>[0];
|
|
21
|
+
type LoadRemoteType = Parameters<typeof _module_federation_enhanced_runtime__default.loadRemote>;
|
|
22
22
|
type EmpRuntimeOptions = {
|
|
23
23
|
showLog?: boolean;
|
|
24
24
|
};
|
|
@@ -46,9 +46,10 @@ declare class EMPRuntime {
|
|
|
46
46
|
setup(o?: EMPShareRuntimeType | string): void;
|
|
47
47
|
init(options?: EmpInitOptionsType): void;
|
|
48
48
|
load<T = any>(...args: LoadRemoteType): Promise<T>;
|
|
49
|
-
register: typeof
|
|
50
|
-
preload: typeof
|
|
51
|
-
loadShare: typeof
|
|
49
|
+
register: typeof _module_federation_enhanced_runtime.registerRemotes;
|
|
50
|
+
preload: typeof _module_federation_enhanced_runtime.preloadRemote;
|
|
51
|
+
loadShare: typeof _module_federation_enhanced_runtime.loadShare;
|
|
52
|
+
preloadRemote: typeof _module_federation_enhanced_runtime.preloadRemote;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
declare const runtime: EMPRuntime;
|