@empjs/share 3.13.9-beta.2 → 4.0.0-alpha.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.
Files changed (132) hide show
  1. package/README.md +202 -62
  2. package/dist/171.js +2 -0
  3. package/dist/171.js.map +1 -0
  4. package/dist/227.js +2 -0
  5. package/dist/227.js.map +1 -0
  6. package/dist/607.js +2 -0
  7. package/dist/607.js.map +1 -0
  8. package/dist/68.js +2 -0
  9. package/dist/68.js.map +1 -0
  10. package/dist/adapter/index.d.ts +1 -0
  11. package/dist/{adapter.d.cts → adapter/react.d.ts} +3 -8
  12. package/dist/adapter/vue.d.ts +1 -0
  13. package/dist/adapter.d.ts +1 -14
  14. package/dist/adapter.js +2 -1
  15. package/dist/adapter.js.map +1 -1
  16. package/dist/adapterVue.d.ts +1 -0
  17. package/dist/adapterVue.js +1 -0
  18. package/dist/forceRemote.d.ts +2 -19
  19. package/dist/forceRemote.js +2 -1
  20. package/dist/forceRemote.js.map +1 -1
  21. package/dist/framework/react/config.d.ts +1 -0
  22. package/dist/framework/react/index.d.ts +3 -0
  23. package/dist/framework/react/shared.d.ts +2 -0
  24. package/dist/framework/vue/config.d.ts +1 -0
  25. package/dist/framework/vue/index.d.ts +3 -0
  26. package/dist/framework/vue/shared.d.ts +2 -0
  27. package/dist/helper/config.d.ts +3 -0
  28. package/dist/helper/index.d.ts +6 -0
  29. package/dist/helper/moduleFederation.d.ts +6 -0
  30. package/dist/helper/resolvePackageExport.d.ts +1 -0
  31. package/dist/helper/rspack.d.ts +1 -0
  32. package/dist/index.d.ts +3 -9
  33. package/dist/index.js +2 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/library/full.d.ts +7 -0
  36. package/dist/library/sdk.d.ts +2 -0
  37. package/dist/library/sdkPolyfill.d.ts +3 -0
  38. package/dist/library/wSdk.d.ts +2 -0
  39. package/dist/mfRuntime.d.ts +1 -1
  40. package/dist/mfRuntime.js +1 -1
  41. package/dist/plugins/rspack/index.d.ts +11 -0
  42. package/dist/plugins/rspack/plugin.d.ts +7 -0
  43. package/dist/plugins/rspack/runtimePlugin/forceRemote.d.ts +13 -0
  44. package/dist/plugins/rspack/runtimePlugin/registerRemotes.d.ts +3 -0
  45. package/dist/plugins/rspack/share.d.ts +30 -0
  46. package/dist/{types-BGnQUQ0O.d.cts → plugins/rspack/types.d.ts} +14 -17
  47. package/dist/plugins/rspack/utils.d.ts +2 -0
  48. package/dist/react.d.ts +1 -9
  49. package/dist/react.js +2 -1
  50. package/dist/react.js.map +1 -1
  51. package/dist/rspack.d.ts +2 -15
  52. package/dist/rspack.js +2 -1
  53. package/dist/rspack.js.map +1 -1
  54. package/dist/{runtime.d.cts → runtime/index.d.ts} +4 -7
  55. package/dist/runtime/index.pre.version.d.ts +22 -0
  56. package/dist/runtime/plugins.d.ts +2 -0
  57. package/dist/runtime/sdk-prev.d.ts +30 -0
  58. package/dist/runtime/sdk.d.ts +31 -0
  59. package/dist/runtime.d.ts +2 -23
  60. package/dist/runtime.js +2 -1
  61. package/dist/runtime.js.map +1 -1
  62. package/dist/sdk.d.ts +1 -34
  63. package/dist/sdk.js +2 -1
  64. package/dist/sdk.js.map +1 -1
  65. package/dist/types/index.d.ts +26 -0
  66. package/dist/vue.d.ts +1 -9
  67. package/dist/vue.js +2 -1
  68. package/dist/vue.js.map +1 -1
  69. package/output/adapter/index.d.ts +1 -0
  70. package/output/adapter/react.d.ts +9 -0
  71. package/output/adapter/vue.d.ts +1 -0
  72. package/output/framework/react/config.d.ts +1 -0
  73. package/output/framework/react/index.d.ts +3 -0
  74. package/output/framework/react/shared.d.ts +2 -0
  75. package/output/framework/vue/config.d.ts +1 -0
  76. package/output/framework/vue/index.d.ts +3 -0
  77. package/output/framework/vue/shared.d.ts +2 -0
  78. package/output/helper/config.d.ts +3 -0
  79. package/output/helper/index.d.ts +6 -0
  80. package/output/helper/moduleFederation.d.ts +6 -0
  81. package/output/helper/resolvePackageExport.d.ts +1 -0
  82. package/output/helper/rspack.d.ts +1 -0
  83. package/output/index.d.ts +3 -0
  84. package/output/library/full.d.ts +7 -0
  85. package/output/library/sdk.d.ts +2 -0
  86. package/output/library/sdkPolyfill.d.ts +3 -0
  87. package/output/library/wSdk.d.ts +2 -0
  88. package/output/plugins/rspack/index.d.ts +11 -0
  89. package/output/plugins/rspack/plugin.d.ts +7 -0
  90. package/output/plugins/rspack/runtimePlugin/forceRemote.d.ts +13 -0
  91. package/output/plugins/rspack/runtimePlugin/registerRemotes.d.ts +3 -0
  92. package/output/plugins/rspack/share.d.ts +30 -0
  93. package/{dist/types-BGnQUQ0O.d.ts → output/plugins/rspack/types.d.ts} +14 -17
  94. package/output/plugins/rspack/utils.d.ts +2 -0
  95. package/output/runtime/index.d.ts +20 -0
  96. package/output/runtime/index.pre.version.d.ts +22 -0
  97. package/output/runtime/mfRuntime.d.ts +1 -0
  98. package/output/runtime/plugins.d.ts +2 -0
  99. package/output/runtime/sdk-prev.d.ts +30 -0
  100. package/output/runtime/sdk.d.ts +31 -0
  101. package/output/sdk.d.ts +1 -0
  102. package/output/sdk.js +5 -1
  103. package/output/types/index.d.ts +26 -0
  104. package/package.json +42 -91
  105. package/dist/adapter.cjs +0 -1
  106. package/dist/adapter.cjs.map +0 -1
  107. package/dist/forceRemote.cjs +0 -1
  108. package/dist/forceRemote.cjs.map +0 -1
  109. package/dist/forceRemote.d.cts +0 -19
  110. package/dist/index-DaSrQPN9.d.cts +0 -21
  111. package/dist/index-DaSrQPN9.d.ts +0 -21
  112. package/dist/index.cjs +0 -1
  113. package/dist/index.cjs.map +0 -1
  114. package/dist/index.d.cts +0 -9
  115. package/dist/mfRuntime.cjs +0 -1
  116. package/dist/mfRuntime.cjs.map +0 -1
  117. package/dist/mfRuntime.js.map +0 -1
  118. package/dist/react.cjs +0 -1
  119. package/dist/react.cjs.map +0 -1
  120. package/dist/react.d.cts +0 -9
  121. package/dist/rspack.cjs +0 -1
  122. package/dist/rspack.cjs.map +0 -1
  123. package/dist/rspack.d.cts +0 -15
  124. package/dist/runtime.cjs +0 -1
  125. package/dist/runtime.cjs.map +0 -1
  126. package/dist/sdk.cjs +0 -1
  127. package/dist/sdk.cjs.map +0 -1
  128. package/dist/sdk.d.cts +0 -34
  129. package/dist/vue.cjs +0 -1
  130. package/dist/vue.cjs.map +0 -1
  131. package/dist/vue.d.cts +0 -9
  132. /package/dist/{mfRuntime.d.cts → runtime/mfRuntime.d.ts} +0 -0
@@ -1,9 +1,7 @@
1
- import { ModuleFederation } from '@module-federation/runtime';
2
- import { E as EMPShareRuntimeType, I as InitOptionsType, a as EmpRuntimeOptions, L as LoadRemoteType } from './index-DaSrQPN9.cjs';
3
- import '@module-federation/sdk';
4
-
1
+ import type { ModuleFederation } from '@module-federation/runtime';
2
+ import type { EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType } from '../types';
5
3
  type EmpInitOptionsType = Partial<InitOptionsType>;
6
- declare class EMPRuntime {
4
+ export declare class EMPRuntime {
7
5
  libs: EMPShareRuntimeType;
8
6
  initOptions: InitOptionsType;
9
7
  options: EmpRuntimeOptions;
@@ -19,5 +17,4 @@ declare class EMPRuntime {
19
17
  preloadRemote(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>): Promise<void> | undefined;
20
18
  }
21
19
  declare const _default: EMPRuntime;
22
-
23
- export { EMPRuntime, _default as default };
20
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import type { EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType } from '../types';
2
+ type EmpInitOptionsType = Partial<InitOptionsType>;
3
+ export declare class EMPRuntime {
4
+ libs: EMPShareRuntimeType;
5
+ initOptions: InitOptionsType;
6
+ options: EmpRuntimeOptions;
7
+ shareGlobalName: string;
8
+ private isInit;
9
+ constructor(op?: EMPShareRuntimeType);
10
+ /**
11
+ * 实例化 adapter libs
12
+ */
13
+ setup(o?: EMPShareRuntimeType | string): void;
14
+ init(options?: EmpInitOptionsType): void;
15
+ load<T = any>(...args: LoadRemoteType): Promise<T>;
16
+ register: typeof import("@module-federation/runtime").registerRemotes;
17
+ preload: typeof import("@module-federation/runtime").preloadRemote;
18
+ loadShare: typeof import("@module-federation/runtime").loadShare;
19
+ preloadRemote: typeof import("@module-federation/runtime").preloadRemote;
20
+ }
21
+ declare const _default: EMPRuntime;
22
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import type { FederationRuntimePlugin } from '../types';
2
+ export declare const catchErrorNextPlugin: (showLog?: boolean) => FederationRuntimePlugin;
@@ -0,0 +1,30 @@
1
+ import * as mfRuntime from '@module-federation/runtime';
2
+ export declare const getInstance: typeof mfRuntime.getInstance;
3
+ export declare const createInstance: typeof mfRuntime.createInstance;
4
+ export declare const init: typeof mfRuntime.init;
5
+ export declare const registerShared: typeof mfRuntime.registerShared;
6
+ export declare const registerRemotes: typeof mfRuntime.registerRemotes;
7
+ export declare const registerPlugins: typeof mfRuntime.registerPlugins;
8
+ export declare const loadRemote: typeof mfRuntime.loadRemote;
9
+ export declare const preloadRemote: typeof mfRuntime.preloadRemote;
10
+ export declare const loadShare: typeof mfRuntime.loadShare;
11
+ export declare const getReactShare: () => {
12
+ react: {
13
+ lib: () => any;
14
+ version: any;
15
+ scope: any;
16
+ shareConfig: {
17
+ singleton: boolean;
18
+ requiredVersion: string;
19
+ };
20
+ };
21
+ 'react-dom': {
22
+ lib: () => any;
23
+ version: any;
24
+ scope: any;
25
+ shareConfig: {
26
+ singleton: boolean;
27
+ requiredVersion: string;
28
+ };
29
+ };
30
+ };
@@ -0,0 +1,31 @@
1
+ import * as mfRuntime from '@module-federation/runtime';
2
+ declare const getInstance: () => ReturnType<typeof mfRuntime.getInstance>;
3
+ export { getInstance };
4
+ export declare const createInstance: typeof mfRuntime.createInstance;
5
+ export declare const init: typeof mfRuntime.init;
6
+ export declare const registerShared: typeof mfRuntime.registerShared;
7
+ export declare const registerRemotes: typeof mfRuntime.registerRemotes;
8
+ export declare const registerPlugins: typeof mfRuntime.registerPlugins;
9
+ export declare const loadRemote: typeof mfRuntime.loadRemote;
10
+ export declare const preloadRemote: typeof mfRuntime.preloadRemote;
11
+ export declare const loadShare: typeof mfRuntime.loadShare;
12
+ export declare const getReactShare: () => {
13
+ react: {
14
+ lib: () => any;
15
+ version: any;
16
+ scope: any;
17
+ shareConfig: {
18
+ singleton: boolean;
19
+ requiredVersion: string;
20
+ };
21
+ };
22
+ 'react-dom': {
23
+ lib: () => any;
24
+ version: any;
25
+ scope: any;
26
+ shareConfig: {
27
+ singleton: boolean;
28
+ requiredVersion: string;
29
+ };
30
+ };
31
+ };
package/dist/runtime.d.ts CHANGED
@@ -1,23 +1,2 @@
1
- import { ModuleFederation } from '@module-federation/runtime';
2
- import { E as EMPShareRuntimeType, I as InitOptionsType, a as EmpRuntimeOptions, L as LoadRemoteType } from './index-DaSrQPN9.js';
3
- import '@module-federation/sdk';
4
-
5
- type EmpInitOptionsType = Partial<InitOptionsType>;
6
- declare class EMPRuntime {
7
- libs: EMPShareRuntimeType;
8
- initOptions: InitOptionsType;
9
- options: EmpRuntimeOptions;
10
- shareGlobalName: string;
11
- constructor(op?: EMPShareRuntimeType);
12
- mfInstance?: ModuleFederation;
13
- setup(o?: EMPShareRuntimeType | string): void;
14
- init(options?: EmpInitOptionsType): ModuleFederation | undefined;
15
- load<T = any>(...args: LoadRemoteType): Promise<T>;
16
- register(...args: Parameters<NonNullable<typeof this.mfInstance>['registerRemotes']>): void | undefined;
17
- preload(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>): Promise<void> | undefined;
18
- loadShare(...args: Parameters<NonNullable<typeof this.mfInstance>['loadShare']>): Promise<false | (() => unknown)> | undefined;
19
- preloadRemote(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>): Promise<void> | undefined;
20
- }
21
- declare const _default: EMPRuntime;
22
-
23
- export { EMPRuntime, _default as default };
1
+ export {default} from './runtime/index'
2
+ export * from './runtime/index'
package/dist/runtime.js CHANGED
@@ -1 +1,2 @@
1
- function e(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function r(r){if(Array.isArray(r))return e(r)}function n(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}function t(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function a(e,r,n){if(r)t(e.prototype,r);if(n)t(e,n);return e}function i(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function o(){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 u(e){return r(e)||i(e)||f(e)||o()}function l(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function f(r,n){if(!r)return;if(typeof r==="string")return e(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor)t=r.constructor.name;if(t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return e(r,n)}var s=Object.defineProperty;var c=function(e,r,n){return r in e?s(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n};var v=function(e,r,n){return c(e,(typeof r==="undefined"?"undefined":l(r))!="symbol"?r+"":r,n)};function y(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var a=true,i=false,o=undefined;try{for(var u=n[Symbol.iterator](),l;!(a=(l=u.next()).done);a=true){var f=l.value;for(var s in f){var c=f[s],v=e[s];if(Object(c)==c&&Object(v)===v){e[s]=y(v,c);continue}e[s]=f[s]}}}catch(e){i=true;o=e}finally{try{if(!a&&u.return!=null){u.return()}}finally{if(i){throw o}}}return e}var m=!1,d=m?console.log.bind(console,"[EMP Share]"):function(){};var h="EMP_SHARE_RUNTIME";var p=window[h]||{},b=window,w=b||{},g=w.EMPShareGlobalVal;g&&g.runtimeLib&&(p=b[g.runtimeLib]);var S=/*#__PURE__*/function(){"use strict";function e(r){n(this,e);v(this,"libs",p);v(this,"initOptions");v(this,"options",{showLog:!1});v(this,"shareGlobalName",h);v(this,"mfInstance");r&&this.setup(r)}a(e,[{key:"setup",value:function e(e){if(e&&(typeof e=="string"&&(e=window[e]),this.libs=e),!this.libs.MFRuntime||!this.libs.MFSDK)throw new Error("MFRuntime and MFSDK Required!")}},{key:"init",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.mfInstance)return this.mfInstance;var r={name:"empRuntimeProject",remotes:[]};r=y(r,e),this.mfInstance=this.libs.MFRuntime.createInstance(r)}},{key:"load",value:function e(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}var t;var a;return(a=this.mfInstance)===null||a===void 0?void 0:(t=a).loadRemote.apply(t,u(r))}},{key:"register",value:function e(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}var t;var a;return(a=this.mfInstance)===null||a===void 0?void 0:(t=a).registerRemotes.apply(t,u(r))}},{key:"preload",value:function e(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}var t;var a;return(a=this.mfInstance)===null||a===void 0?void 0:(t=a).preloadRemote.apply(t,u(r))}},{key:"loadShare",value:function e(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}var t;var a;return(a=this.mfInstance)===null||a===void 0?void 0:(t=a).loadShare.apply(t,u(r))}},{key:"preloadRemote",value:function e(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}var t;var a;return(a=this.mfInstance)===null||a===void 0?void 0:(t=a).preloadRemote.apply(t,u(r))}}]);return e}(),A=new S;export{S as EMPRuntime,A as default};//# sourceMappingURL=runtime.js.map
1
+ import{deepAssign as e}from"./227.js";import{shareGlobalName as t}from"./607.js";function i(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let n=window[t]||{},r=window,{EMPShareGlobalVal:s}=r||{};s&&s.runtimeLib&&(n=r[s.runtimeLib]);class o{setup(e){if(e&&("string"==typeof e&&(e=window[e]),this.libs=e),!this.libs.MFRuntime||!this.libs.MFSDK)throw Error("MFRuntime and MFSDK Required!")}init(t={}){if(this.mfInstance)return this.mfInstance;let i={name:"empRuntimeProject",remotes:[]};i=e(i,t),this.mfInstance=this.libs.MFRuntime.createInstance(i)}load(...e){var t;return null==(t=this.mfInstance)?void 0:t.loadRemote(...e)}register(...e){var t;return null==(t=this.mfInstance)?void 0:t.registerRemotes(...e)}preload(...e){var t;return null==(t=this.mfInstance)?void 0:t.preloadRemote(...e)}loadShare(...e){var t;return null==(t=this.mfInstance)?void 0:t.loadShare(...e)}preloadRemote(...e){var t;return null==(t=this.mfInstance)?void 0:t.preloadRemote(...e)}constructor(e){i(this,"libs",n),i(this,"initOptions",void 0),i(this,"options",{showLog:!1}),i(this,"shareGlobalName",t),i(this,"mfInstance",void 0),e&&this.setup(e)}}let a=new o;export default a;export{o as EMPRuntime};
2
+ //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/liangxiaoming/Documents/emp/packages/emp-share/dist/runtime.js","../src/helper/index.ts","../src/helper/config.ts","../src/runtime/index.ts"],"names":["b","Object","defineProperty","f","o","e","t","enumerable","configurable","writable","value","n","deepAssign","target","sources","source","k","vs","vt","isDev","log","console","bind","shareGlobalName","globalLib","window","win","EMPShareGlobalVal","runtimeLib","EMPRuntime","op","__publicField","showLog","setup","libs","MFRuntime","MFSDK","Error","init","options","mfInstance","name","remotes","createInstance","load","args","loadRemote","register","registerRemotes","preload","preloadRemote","loadShare","runtime_default"],"mappings":"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","sourcesContent":["var b=Object.defineProperty;var f=(o,e,t)=>e in o?b(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var n=(o,e,t)=>f(o,typeof e!=\"symbol\"?e+\"\":e,t);function a(o,...e){for(let t of e)for(let i in t){let s=t[i],r=o[i];if(Object(s)==s&&Object(r)===r){o[i]=a(r,s);continue}o[i]=t[i]}return o}var h=!1,y=h?console.log.bind(console,\"[EMP Share]\"):()=>{};var p=\"EMP_SHARE_RUNTIME\";var c=window[p]||{},u=window,{EMPShareGlobalVal:l}=u||{};l&&l.runtimeLib&&(c=u[l.runtimeLib]);var m=class{constructor(e){n(this,\"libs\",c);n(this,\"initOptions\");n(this,\"options\",{showLog:!1});n(this,\"shareGlobalName\",p);n(this,\"mfInstance\");e&&this.setup(e)}setup(e){if(e&&(typeof e==\"string\"&&(e=window[e]),this.libs=e),!this.libs.MFRuntime||!this.libs.MFSDK)throw new Error(\"MFRuntime and MFSDK Required!\")}init(e={}){if(this.mfInstance)return this.mfInstance;let t={name:\"empRuntimeProject\",remotes:[]};t=a(t,e),this.mfInstance=this.libs.MFRuntime.createInstance(t)}load(...e){return this.mfInstance?.loadRemote(...e)}register(...e){return this.mfInstance?.registerRemotes(...e)}preload(...e){return this.mfInstance?.preloadRemote(...e)}loadShare(...e){return this.mfInstance?.loadShare(...e)}preloadRemote(...e){return this.mfInstance?.preloadRemote(...e)}},M=new m;export{m as EMPRuntime,M as default};\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'\nexport const shareGlobalVal = 'EMPShareGlobalVal'\nexport const shareForceRemote = 'EMP_FORCE_REMOTES'\n","import type {ModuleFederation} from '@module-federation/runtime'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport type {EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType} from 'src/types'\n\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 constructor(op?: EMPShareRuntimeType) {\n if (op) this.setup(op)\n }\n public mfInstance?: ModuleFederation\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.mfInstance) return this.mfInstance\n let op: InitOptionsType = {\n name: 'empRuntimeProject',\n remotes: [],\n // plugins: [catchErrorNextPlugin(this.options.showLog)],\n }\n op = deepAssign<InitOptionsType>(op, options)\n this.mfInstance = this.libs.MFRuntime.createInstance(op)\n }\n public load<T = any>(...args: LoadRemoteType) {\n return this.mfInstance?.loadRemote<T>(...args) as Promise<T>\n }\n public register(...args: Parameters<NonNullable<typeof this.mfInstance>['registerRemotes']>) {\n return this.mfInstance?.registerRemotes(...args)\n }\n public preload(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>) {\n return this.mfInstance?.preloadRemote(...args)\n }\n public loadShare(...args: Parameters<NonNullable<typeof this.mfInstance>['loadShare']>) {\n return this.mfInstance?.loadShare(...args)\n }\n public preloadRemote(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>) {\n return this.mfInstance?.preloadRemote(...args)\n }\n}\n//\nexport default new EMPRuntime()\n"]}
1
+ {"version":3,"file":"runtime.js","sources":["../src/runtime/index.ts"],"sourcesContent":["import type {ModuleFederation} from '@module-federation/runtime'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport type {EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType} from 'src/types'\n\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 constructor(op?: EMPShareRuntimeType) {\n if (op) this.setup(op)\n }\n public mfInstance?: ModuleFederation\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.mfInstance) return this.mfInstance\n let op: InitOptionsType = {\n name: 'empRuntimeProject',\n remotes: [],\n // plugins: [catchErrorNextPlugin(this.options.showLog)],\n }\n op = deepAssign<InitOptionsType>(op, options)\n this.mfInstance = this.libs.MFRuntime.createInstance(op)\n }\n public load<T = any>(...args: LoadRemoteType) {\n return this.mfInstance?.loadRemote<T>(...args) as Promise<T>\n }\n public register(...args: Parameters<NonNullable<typeof this.mfInstance>['registerRemotes']>) {\n return this.mfInstance?.registerRemotes(...args)\n }\n public preload(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>) {\n return this.mfInstance?.preloadRemote(...args)\n }\n public loadShare(...args: Parameters<NonNullable<typeof this.mfInstance>['loadShare']>) {\n return this.mfInstance?.loadShare(...args)\n }\n public preloadRemote(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>) {\n return this.mfInstance?.preloadRemote(...args)\n }\n}\n//\nexport default new EMPRuntime()\n"],"names":["globalLib","window","shareGlobalName","win","EMPShareGlobalVal","EMPRuntime","o","Error","options","op","deepAssign","args","_this_mfInstance"],"mappings":"qOAMA,IAAIA,EAAYC,MAAM,CAACC,EAAgB,EAAI,CAAC,EAEtCC,EAAWF,OACX,CAACG,kBAAAA,CAAiB,CAAC,CAAGD,GAAO,CAAC,CAChCC,CAAAA,GAAqBA,EAAkB,UAAU,EACnDJ,CAAAA,EAAYG,CAAG,CAACC,EAAkB,UAAU,CAAC,AAAD,CAGvC,OAAMC,EAWJ,MAAMC,CAAgC,CAAE,CAK7C,GAJIA,IACE,AAAa,UAAb,OAAOA,GAAgBA,CAAAA,EAAIL,MAAM,CAACK,EAAE,AAAD,EACvC,IAAI,CAAC,IAAI,CAAGA,GAEV,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAC1C,MAAM,AAAIC,MAAM,gCAEpB,CACO,KAAKC,EAA8B,CAAC,CAAC,CAAE,CAC5C,GAAI,IAAI,CAAC,UAAU,CAAE,OAAO,IAAI,CAAC,UAAU,CAC3C,IAAIC,EAAsB,CACxB,KAAM,oBACN,QAAS,EAAE,AAEb,EACAA,EAAKC,EAA4BD,EAAID,GACrC,IAAI,CAAC,UAAU,CAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAACC,EACvD,CACO,KAAc,GAAGE,CAAoB,CAAE,C,IACrCC,EAAP,OAAO,MAAAA,CAAAA,EAAAA,IAAI,CAAC,UAAU,AAAD,EAAdA,KAAAA,EAAAA,EAAiB,UAAU,IAAOD,EAC3C,CACO,SAAS,GAAGA,CAAwE,CAAE,C,IACpFC,EAAP,OAAO,MAAAA,CAAAA,EAAAA,IAAI,CAAC,UAAU,AAAD,EAAdA,KAAAA,EAAAA,EAAiB,eAAe,IAAID,EAC7C,CACO,QAAQ,GAAGA,CAAsE,CAAE,C,IACjFC,EAAP,OAAO,MAAAA,CAAAA,EAAAA,IAAI,CAAC,UAAU,AAAD,EAAdA,KAAAA,EAAAA,EAAiB,aAAa,IAAID,EAC3C,CACO,UAAU,GAAGA,CAAkE,CAAE,C,IAC/EC,EAAP,OAAO,MAAAA,CAAAA,EAAAA,IAAI,CAAC,UAAU,AAAD,EAAdA,KAAAA,EAAAA,EAAiB,SAAS,IAAID,EACvC,CACO,cAAc,GAAGA,CAAsE,CAAE,C,IACvFC,EAAP,OAAO,MAAAA,CAAAA,EAAAA,IAAI,CAAC,UAAU,AAAD,EAAdA,KAAAA,EAAAA,EAAiB,aAAa,IAAID,EAC3C,CArCA,YAAYF,CAAwB,CAAE,CANtC,OAAO,OAA4BT,GACnC,OAAO,cAAP,QACA,OAAO,UAA6B,CAClC,QAAS,EACX,GACA,OAAO,kBAAkBE,GAIzB,OAAO,aAAP,QAFMO,GAAI,IAAI,CAAC,KAAK,CAACA,EACrB,CAoCF,CAEA,MAAe,IAAIJ,C"}
package/dist/sdk.d.ts CHANGED
@@ -1,34 +1 @@
1
- import * as mfRuntime from '@module-federation/runtime';
2
-
3
- declare const getInstance: () => ReturnType<typeof mfRuntime.getInstance>;
4
-
5
- declare const createInstance: typeof mfRuntime.createInstance;
6
- declare const init: typeof mfRuntime.init;
7
- declare const registerShared: typeof mfRuntime.registerShared;
8
- declare const registerRemotes: typeof mfRuntime.registerRemotes;
9
- declare const registerPlugins: typeof mfRuntime.registerPlugins;
10
- declare const loadRemote: typeof mfRuntime.loadRemote;
11
- declare const preloadRemote: typeof mfRuntime.preloadRemote;
12
- declare const loadShare: typeof mfRuntime.loadShare;
13
- declare const getReactShare: () => {
14
- react: {
15
- lib: () => any;
16
- version: any;
17
- scope: any;
18
- shareConfig: {
19
- singleton: boolean;
20
- requiredVersion: string;
21
- };
22
- };
23
- 'react-dom': {
24
- lib: () => any;
25
- version: any;
26
- scope: any;
27
- shareConfig: {
28
- singleton: boolean;
29
- requiredVersion: string;
30
- };
31
- };
32
- };
33
-
34
- export { createInstance, getInstance, getReactShare, init, loadRemote, loadShare, preloadRemote, registerPlugins, registerRemotes, registerShared };
1
+ export * from './runtime/sdk'
package/dist/sdk.js CHANGED
@@ -1 +1,2 @@
1
- function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(r){if(Array.isArray(r))return e(r)}function t(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function n(){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 o(e){return r(e)||t(e)||i(e)||n()}function a(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function i(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}var s;var l=(typeof window==="undefined"?"undefined":a(window))<"u"?window:void 0,u=l[l.EMPShareGlobalVal.runtimeLib].MFRuntime,c=[],f=function(){var e=u.getInstance();return e&&(e.options.remotes.length>0?c=e.options.remotes:c.length>0&&(e.registerRemotes(c),c=[]),e)},d=function(e){return function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}var a;var i,s;return(s=f())===null||s===void 0?void 0:(i=s[e])===null||i===void 0?void 0:(a=i).call.apply(a,[s].concat(o(t)))}};var m=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return(s=u).createInstance.apply(s,o(r))},p=u.init,g=d("registerShared"),v=d("registerRemotes"),y=d("registerPlugins"),h=d("loadRemote"),b=d("preloadRemote"),S=d("loadShare"),w=function(){var e=l[l.EMPShareGlobalVal.frameworkLib],r=e.React,t=e.ReactDOM,n=e.scope,o=n===void 0?"default":n;return{react:{lib:function(){return r},version:r.version,scope:o,shareConfig:{singleton:!0,requiredVersion:"^".concat(r.version)}},"react-dom":{lib:function(){return t},version:t.version,scope:o,shareConfig:{singleton:!0,requiredVersion:"^".concat(r.version)}}}};export{m as createInstance,f as getInstance,w as getReactShare,p as init,h as loadRemote,S as loadShare,b as preloadRemote,y as registerPlugins,v as registerRemotes,g as registerShared};//# sourceMappingURL=sdk.js.map
1
+ let e="u">typeof window?window:void 0,r=e[e.EMPShareGlobalVal.runtimeLib].MFRuntime,t=[],o=()=>{let e=r.getInstance();return e&&(e.options.remotes.length>0?t=e.options.remotes:t.length>0&&(e.registerRemotes(t),t=[])),e},i=e=>(...r)=>{var t,i;return null==(i=o())||null==(t=i[e])?void 0:t.call(i,...r)},n=(...e)=>r.createInstance(...e),a=r.init,s=i("registerShared"),l=i("registerRemotes"),g=i("registerPlugins"),d=i("loadRemote"),m=i("preloadRemote"),u=i("loadShare"),h=()=>{let{React:r,ReactDOM:t,scope:o="default"}=e[e.EMPShareGlobalVal.frameworkLib];return{react:{lib:()=>r,version:r.version,scope:o,shareConfig:{singleton:!0,requiredVersion:`^${r.version}`}},"react-dom":{lib:()=>t,version:t.version,scope:o,shareConfig:{singleton:!0,requiredVersion:`^${r.version}`}}}};export{n as createInstance,o as getInstance,h as getReactShare,a as init,d as loadRemote,u as loadShare,m as preloadRemote,g as registerPlugins,l as registerRemotes,s as registerShared};
2
+ //# sourceMappingURL=sdk.js.map
package/dist/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/runtime/sdk.ts"],"names":["mf","win","window","EMPShareGlobalVal","runtimeLib","MFRuntime","pendingRemotes","getInstance","inst","options","remotes","length","registerRemotes","call","method","args","createInstance","init","registerShared","registerPlugins","loadRemote","preloadRemote","loadShare","getReactShare","frameworkLib","React","ReactDOM","scope","react","lib","version","shareConfig","singleton","requiredVersion","m","a","d","f","u","g","R","l","p","c"],"mappings":"o4BAqB4EA,EAnB5E,IAAMC,EAAW,CAAA,OAAOC,iCAAP,EAAOA,OAAA,EAAW,IAAcA,OAAS,KAAA,EACpDF,EAAKC,CAAAA,CAAIA,EAAIE,iBAAA,CAAkBC,UAAU,CAAA,CAAEC,SAAA,CAE7CC,EAAwB,EAAC,CAEvBC,EAAc,WAClB,IAAMC,EAAOR,EAAGO,WAAA,GAChB,OAAKC,GACDA,CAAAA,EAAKC,OAAA,CAAQC,OAAA,CAAQC,MAAA,CAAS,EAAGL,EAAiBE,EAAKC,OAAA,CAAQC,OAAA,CAC1DJ,EAAeK,MAAA,CAAS,GAC/BH,CAAAA,EAAKI,eAAA,CAAgBN,GACrBA,EAAiB,EAAC,EAEbE,CAAAA,CACT,EAEMK,EAAWC,SAAAA,UAAoB,sCAAIC,4BAAAA,sBAAiBR,MAAAA,EAAAA,SAAAA,EAAAA,aAAAA,mBAAAA,EAAAA,CAAY,CAAYO,EAAM,UAA9BP,kBAAAA,CAAAA,EAAAA,cAAAA,EAAAA,CAAAA,EAAyC,CAAzCA,OAAkC,EAAGQ,OAGxF,IAAMC,EAAkD,sCAAID,4BAAAA,wBAASf,CAAAA,EAAAA,GAAGgB,cAAA,OAAHhB,EAAkB,EAAGe,KACpFE,EAA8BjB,EAAGiB,IAAA,CACjCC,EAAiBL,EAAsC,kBACvDD,EAAkBC,EAAuC,mBACzDM,EAAkBN,EAAuC,mBACzDO,EAAaP,EAAkC,cAC/CQ,EAAgBR,EAAqC,iBACrDS,EAAYT,EAAiC,aAE7CU,EAAgB,WAC3B,IAA6CtB,EAAAA,CAAAA,CAAIA,EAAIE,iBAAA,CAAkBqB,YAAY,CAAA,CAA5EC,EAAsCxB,EAAtCwB,MAAOC,EAA+BzB,EAA/ByB,SAAUC,EAAqB1B,EAArB0B,MAAAA,EAAAA,WAAQ,UAARA,EACxB,MAAO,CACLC,MAAO,CACLC,IAAK,kBAAMJ,GACXK,QAASL,EAAMK,OAAA,CACfH,MAAAA,EACAI,YAAa,CAACC,UAAW,CAAA,EAAMC,gBAAiB,IAAiB,OAAbR,EAAMK,OAAO,CAAE,CACrE,EACA,YAAa,CACXD,IAAK,kBAAMH,GACXI,QAASJ,EAASI,OAAA,CAClBH,MAAAA,EACAI,YAAa,CAACC,UAAW,CAAA,EAAMC,gBAAiB,IAAiB,OAAbR,EAAMK,OAAO,CAAE,CACrE,CACF,CACF,SAAAI,KAAAlB,cAAA,CAAAmB,KAAA5B,WAAA,CAAA6B,KAAAb,aAAA,CAAAc,KAAApB,IAAA,CAAAqB,KAAAlB,UAAA,CAAAmB,KAAAjB,SAAA,CAAAkB,KAAAnB,aAAA,CAAAoB,KAAAtB,eAAA,CAAAuB,KAAA9B,eAAA,CAAA+B,KAAAzB,cAAA","sourcesContent":["import * as mfRuntime from '@module-federation/runtime'\n\nconst win: any = typeof window !== 'undefined' ? window : undefined\nconst mf = win[win.EMPShareGlobalVal.runtimeLib]['MFRuntime'] as typeof mfRuntime\n\nlet pendingRemotes: any[] = []\n\nconst getInstance = (): ReturnType<typeof mfRuntime.getInstance> => {\n const inst = mf.getInstance()\n if (!inst) return inst\n if (inst.options.remotes.length > 0) pendingRemotes = inst.options.remotes\n else if (pendingRemotes.length > 0) {\n inst.registerRemotes(pendingRemotes)\n pendingRemotes = []\n }\n return inst\n}\n\nconst call = <T>(method: string) => ((...args: any[]) => (getInstance() as any)?.[method]?.(...args)) as T\n\nexport {getInstance}\nexport const createInstance: typeof mfRuntime.createInstance = (...args) => mf.createInstance(...args)\nexport const init: typeof mfRuntime.init = mf.init\nexport const registerShared = call<typeof mfRuntime.registerShared>('registerShared')\nexport const registerRemotes = call<typeof mfRuntime.registerRemotes>('registerRemotes')\nexport const registerPlugins = call<typeof mfRuntime.registerPlugins>('registerPlugins')\nexport const loadRemote = call<typeof mfRuntime.loadRemote>('loadRemote')\nexport const preloadRemote = call<typeof mfRuntime.preloadRemote>('preloadRemote')\nexport const loadShare = call<typeof mfRuntime.loadShare>('loadShare')\n\nexport const getReactShare = () => {\n const {React, ReactDOM, scope = 'default'} = win[win.EMPShareGlobalVal.frameworkLib]\n return {\n react: {\n lib: () => React,\n version: React.version,\n scope,\n shareConfig: {singleton: true, requiredVersion: `^${React.version}`},\n },\n 'react-dom': {\n lib: () => ReactDOM,\n version: ReactDOM.version,\n scope,\n shareConfig: {singleton: true, requiredVersion: `^${React.version}`},\n },\n }\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sources":["../src/runtime/sdk.ts"],"sourcesContent":["import * as mfRuntime from '@module-federation/runtime'\n\nconst win: any = typeof window !== 'undefined' ? window : undefined\nconst mf = win[win.EMPShareGlobalVal.runtimeLib]['MFRuntime'] as typeof mfRuntime\n\nlet pendingRemotes: any[] = []\n\nconst getInstance = (): ReturnType<typeof mfRuntime.getInstance> => {\n const inst = mf.getInstance()\n if (!inst) return inst\n if (inst.options.remotes.length > 0) pendingRemotes = inst.options.remotes\n else if (pendingRemotes.length > 0) {\n inst.registerRemotes(pendingRemotes)\n pendingRemotes = []\n }\n return inst\n}\n\nconst call = <T>(method: string) => ((...args: any[]) => (getInstance() as any)?.[method]?.(...args)) as T\n\nexport {getInstance}\nexport const createInstance: typeof mfRuntime.createInstance = (...args) => mf.createInstance(...args)\nexport const init: typeof mfRuntime.init = mf.init\nexport const registerShared = call<typeof mfRuntime.registerShared>('registerShared')\nexport const registerRemotes = call<typeof mfRuntime.registerRemotes>('registerRemotes')\nexport const registerPlugins = call<typeof mfRuntime.registerPlugins>('registerPlugins')\nexport const loadRemote = call<typeof mfRuntime.loadRemote>('loadRemote')\nexport const preloadRemote = call<typeof mfRuntime.preloadRemote>('preloadRemote')\nexport const loadShare = call<typeof mfRuntime.loadShare>('loadShare')\n\nexport const getReactShare = () => {\n const {React, ReactDOM, scope = 'default'} = win[win.EMPShareGlobalVal.frameworkLib]\n return {\n react: {\n lib: () => React,\n version: React.version,\n scope,\n shareConfig: {singleton: true, requiredVersion: `^${React.version}`},\n },\n 'react-dom': {\n lib: () => ReactDOM,\n version: ReactDOM.version,\n scope,\n shareConfig: {singleton: true, requiredVersion: `^${React.version}`},\n },\n }\n}\n"],"names":["win","window","undefined","mf","pendingRemotes","getInstance","inst","call","method","args","_getInstance_method","_getInstance","createInstance","init","registerShared","registerRemotes","registerPlugins","loadRemote","preloadRemote","loadShare","getReactShare","React","ReactDOM","scope"],"mappings":"AAEA,IAAMA,EAAW,AAAkB,IAAlB,OAAOC,OAAyBA,OAASC,OACpDC,EAAKH,CAAG,CAACA,EAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC,SAAY,CAEzDI,EAAwB,EAAE,CAExBC,EAAc,KAClB,IAAMC,EAAOH,EAAG,WAAW,UACtBG,IACDA,EAAK,OAAO,CAAC,OAAO,CAAC,MAAM,CAAG,EAAGF,EAAiBE,EAAK,OAAO,CAAC,OAAO,CACjEF,EAAe,MAAM,CAAG,IAC/BE,EAAK,eAAe,CAACF,GACrBA,EAAiB,EAAE,GAJHE,CAOpB,EAEMC,EAAO,AAAIC,GAAoB,CAAC,GAAGC,K,IAAgBC,EAACC,E,aAAAA,CAAAA,EAAAA,GAAY,GAAZA,MAADD,CAAAA,EAACC,CAAuB,CAACH,EAAO,AAAD,EAA/BE,KAAAA,EAAAA,EAAAA,IAAAA,CAACC,KAAqCF,E,EAGlFG,EAAkD,CAAC,GAAGH,IAASN,EAAG,cAAc,IAAIM,GACpFI,EAA8BV,EAAG,IAAI,CACrCW,EAAiBP,EAAsC,kBACvDQ,EAAkBR,EAAuC,mBACzDS,EAAkBT,EAAuC,mBACzDU,EAAaV,EAAkC,cAC/CW,EAAgBX,EAAqC,iBACrDY,EAAYZ,EAAiC,aAE7Ca,EAAgB,KAC3B,GAAM,CAACC,MAAAA,CAAK,CAAEC,SAAAA,CAAQ,CAAEC,MAAAA,EAAQ,SAAS,CAAC,CAAGvB,CAAG,CAACA,EAAI,iBAAiB,CAAC,YAAY,CAAC,CACpF,MAAO,CACL,MAAO,CACL,IAAK,IAAMqB,EACX,QAASA,EAAM,OAAO,CACtBE,MAAAA,EACA,YAAa,CAAC,UAAW,GAAM,gBAAiB,CAAC,CAAC,EAAEF,EAAM,OAAO,CAAC,CAAC,CACrE,EACA,YAAa,CACX,IAAK,IAAMC,EACX,QAASA,EAAS,OAAO,CACzBC,MAAAA,EACA,YAAa,CAAC,UAAW,GAAM,gBAAiB,CAAC,CAAC,EAAEF,EAAM,OAAO,CAAC,CAAC,CACrE,CACF,CACF,S"}
@@ -0,0 +1,26 @@
1
+ export type { FederationRuntimePlugin } from '../helper/moduleFederation';
2
+ import type { MFRuntime, MFSDK } from '../helper/moduleFederation';
3
+ export type Override<What, With> = Omit<What, keyof With> & With;
4
+ export type EMPShareRuntimeType = {
5
+ MFRuntime: Required<typeof MFRuntime>;
6
+ MFSDK: Required<typeof MFSDK>;
7
+ };
8
+ export type EMPShareRuntimeAdapterReactType = {
9
+ React?: any;
10
+ ReactDOM?: any;
11
+ createRoot?: any;
12
+ hydrateRoot?: any;
13
+ scope: string;
14
+ };
15
+ export type EMPShareRuntimeAdapterVueType = {
16
+ Vue?: any;
17
+ VueRouter?: any;
18
+ Pinia?: any;
19
+ scope: string;
20
+ };
21
+ export type InitOptionsType = Parameters<typeof MFRuntime.init>[0];
22
+ export type LoadRemoteType = Parameters<typeof MFRuntime.loadRemote>;
23
+ export type FrameworkType = 'react' | 'vue' | 'vue2' | 'angular';
24
+ export type EmpRuntimeOptions = {
25
+ showLog?: boolean;
26
+ };
package/dist/vue.d.ts CHANGED
@@ -1,9 +1 @@
1
- import { I as InitOptionsType } from './index-DaSrQPN9.js';
2
- import '@module-federation/runtime';
3
- import '@module-federation/sdk';
4
-
5
- declare const shared: () => InitOptionsType["shared"];
6
-
7
- declare const external: (o: any, globalVal: string) => any;
8
-
9
- export { external, shared };
1
+ export * from './framework/vue/index'
package/dist/vue.js CHANGED
@@ -1 +1,2 @@
1
- function e(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}function r(r){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};var o=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}o.forEach(function(n){e(r,n,t[n])})}return r}var n=function(e,r){return e=Object.assign(e,{vue:"".concat(r,".Vue"),"vue-router":"".concat(r,".VueRouter")}),e};var t=window,o={},u=t||{},i=u.EMPShareGlobalVal;i&&i.frameworkLib&&(o=t[i.frameworkLib]);var a=r({scope:"default"},o),c=function(){var e=a.Vue,r=a.VueRouter,n=a.scope;return{vue:{lib:function(){return e},version:e.version,scope:n,shareConfig:{singleton:!0,requiredVersion:"^".concat(e.version)}},"vue-router":{lib:function(){return r},version:r.version,scope:n,shareConfig:{singleton:!0,requiredVersion:"^".concat(r.version)}}}};var s=n;export{s as external,c as shared};//# sourceMappingURL=vue.js.map
1
+ import{externalVue as e}from"./68.js";let r=window,n={},{EMPShareGlobalVal:o}=r||{};o&&o.frameworkLib&&(n=r[o.frameworkLib]);let t=function(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(r){var o;o=n[r],r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o})}return e}({scope:"default"},n),i=()=>{let{Vue:e,VueRouter:r,scope:n}=t;return{vue:{lib:()=>e,version:e.version,scope:n,shareConfig:{singleton:!0,requiredVersion:`^${e.version}`}},"vue-router":{lib:()=>r,version:r.version,scope:n,shareConfig:{singleton:!0,requiredVersion:`^${r.version}`}}}},l=e;export{l as external,i as shared};
2
+ //# sourceMappingURL=vue.js.map
package/dist/vue.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/framework/vue/config.ts","../src/framework/vue/shared.ts","../src/framework/vue/index.ts"],"names":["externalVue","o","globalVal","Object","assign","vue","win","window","globalLib","EMPShareGlobalVal","frameworkLib","libs","scope","shared","Vue","VueRouter","lib","version","shareConfig","singleton","requiredVersion","external"],"mappings":"idAAO,IAAMA,EAAc,SAACC,EAAQC,UAClCD,EAAIE,OAAOC,MAAA,CAAOH,EAAG,CACnBI,IAAK,GAAY,OAATH,EAAS,QACjB,aAAc,GAAY,OAATA,EAAS,aAC5B,GACOD,GCAT,IAAMK,EAAWC,OACbC,EAAY,CAAC,EACWF,EAAAA,GAAO,CAAC,EAA7BG,EAAqBH,EAArBG,iBACHA,CAAAA,GAAqBA,EAAkBC,YAAA,EACzCF,CAAAA,EAAYF,CAAAA,CAAIG,EAAkBC,YAAY,CAAA,EAEhD,IAAMC,EAAsC,GAC1CC,MAAO,WACJJ,GAEQK,EAAS,WACpB,IAAOC,EAAyBH,EAAzBG,IAAKC,EAAoBJ,EAApBI,UAAWH,EAASD,EAATC,MACvB,MAAO,CACLP,IAAK,CACHW,IAAK,kBAAMF,GACXG,QAASH,EAAIG,OAAA,CACbL,MAAAA,EACAM,YAAa,CACXC,UAAW,CAAA,EACXC,gBAAiB,IAAe,OAAXN,EAAIG,OAAO,CAClC,CACF,EACA,aAAc,CACZD,IAAK,kBAAMD,GACXE,QAASF,EAAUE,OAAA,CACnBL,MAAAA,EACAM,YAAa,CACXC,UAAW,CAAA,EACXC,gBAAiB,IAAqB,OAAjBL,EAAUE,OAAO,CACxC,CACF,CACF,CACF,EClCA,IAAMI,EAAWrB,SAAAA,KAAAA,QAAAA,CAAAA,KAAAA,MAAAA","sourcesContent":["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 {EMPShareRuntimeAdapterVueType, InitOptionsType} from 'src/types'\n\n// o['vue'] = `EMP_ADAPTER_VUE.Vue`\n// o['vue-router'] = `EMP_ADAPTER_VUE.VueRouter`\n// o['pinia'] = `EMP_ADAPTER_VUE.Pinia`\nconst win: any = window\nlet globalLib = {}\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.frameworkLib) {\n globalLib = win[EMPShareGlobalVal.frameworkLib]\n}\nconst libs: EMPShareRuntimeAdapterVueType = {\n scope: 'default',\n ...globalLib,\n}\nexport const shared = (): InitOptionsType['shared'] => {\n const {Vue, VueRouter, scope} = libs\n return {\n vue: {\n lib: () => Vue,\n version: Vue.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${Vue.version}`,\n },\n },\n 'vue-router': {\n lib: () => VueRouter,\n version: VueRouter.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${VueRouter.version}`,\n },\n },\n }\n}\n","import {externalVue} from './config'\nimport {shared} from './shared'\n\nconst external = externalVue\nexport {shared, external}\n"]}
1
+ {"version":3,"file":"vue.js","sources":["../src/framework/vue/shared.ts","../src/framework/vue/index.ts"],"sourcesContent":["import {EMPShareRuntimeAdapterVueType, InitOptionsType} from 'src/types'\n\n// o['vue'] = `EMP_ADAPTER_VUE.Vue`\n// o['vue-router'] = `EMP_ADAPTER_VUE.VueRouter`\n// o['pinia'] = `EMP_ADAPTER_VUE.Pinia`\nconst win: any = window\nlet globalLib = {}\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.frameworkLib) {\n globalLib = win[EMPShareGlobalVal.frameworkLib]\n}\nconst libs: EMPShareRuntimeAdapterVueType = {\n scope: 'default',\n ...globalLib,\n}\nexport const shared = (): InitOptionsType['shared'] => {\n const {Vue, VueRouter, scope} = libs\n return {\n vue: {\n lib: () => Vue,\n version: Vue.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${Vue.version}`,\n },\n },\n 'vue-router': {\n lib: () => VueRouter,\n version: VueRouter.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${VueRouter.version}`,\n },\n },\n }\n}\n","import {externalVue} from './config'\nimport {shared} from './shared'\n\nconst external = externalVue\nexport {shared, external}\n"],"names":["win","window","globalLib","EMPShareGlobalVal","libs","shared","Vue","VueRouter","scope","external","externalVue"],"mappings":"oDAKA,IAAMA,EAAWC,OACbC,EAAY,CAAC,EACX,CAACC,kBAAAA,CAAiB,CAAC,CAAGH,GAAO,CAAC,CAChCG,CAAAA,GAAqBA,EAAkB,YAAY,EACrDD,CAAAA,EAAYF,CAAG,CAACG,EAAkB,YAAY,CAAC,AAAD,EAEhD,IAAMC,EAAsC,A,iaAAA,CAC1C,MAAO,S,EACJF,GAEQG,EAAS,KACpB,GAAM,CAACC,IAAAA,CAAG,CAAEC,UAAAA,CAAS,CAAEC,MAAAA,CAAK,CAAC,CAAGJ,EAChC,MAAO,CACL,IAAK,CACH,IAAK,IAAME,EACX,QAASA,EAAI,OAAO,CACpBE,MAAAA,EACA,YAAa,CACX,UAAW,GACX,gBAAiB,CAAC,CAAC,EAAEF,EAAI,OAAO,CAAC,CAAC,AACpC,CACF,EACA,aAAc,CACZ,IAAK,IAAMC,EACX,QAASA,EAAU,OAAO,CAC1BC,MAAAA,EACA,YAAa,CACX,UAAW,GACX,gBAAiB,CAAC,CAAC,EAAED,EAAU,OAAO,CAAC,CAAC,AAC1C,CACF,CACF,CACF,EClCME,EAAWC,S"}
@@ -0,0 +1 @@
1
+ export * from './react';
@@ -0,0 +1,9 @@
1
+ import type { EMPShareRuntimeAdapterReactType, InitOptionsType } from '../types';
2
+ export declare class ReactAdapter {
3
+ libs: EMPShareRuntimeAdapterReactType;
4
+ constructor(op?: EMPShareRuntimeAdapterReactType);
5
+ setup(o?: EMPShareRuntimeAdapterReactType | string): void;
6
+ get shared(): InitOptionsType['shared'];
7
+ adapter<P = any>(component: any, scope?: string, React?: any, ReactDOM?: any): P;
8
+ }
9
+ export declare const reactAdapter: ReactAdapter;
@@ -0,0 +1 @@
1
+ export declare const Vue2InVue3Adapter: any;
@@ -0,0 +1 @@
1
+ export declare const externalReact: (o: any, globalVal: string) => any;
@@ -0,0 +1,3 @@
1
+ import { shared } from './shared';
2
+ declare const external: (o: any, globalVal: string) => any;
3
+ export { shared, external };
@@ -0,0 +1,2 @@
1
+ import { InitOptionsType } from '../../types';
2
+ export declare const shared: () => InitOptionsType["shared"];
@@ -0,0 +1 @@
1
+ export declare const externalVue: (o: any, globalVal: string) => any;
@@ -0,0 +1,3 @@
1
+ import { shared } from './shared';
2
+ declare const external: (o: any, globalVal: string) => any;
3
+ export { shared, external };
@@ -0,0 +1,2 @@
1
+ import { InitOptionsType } from '../../types';
2
+ export declare const shared: () => InitOptionsType["shared"];
@@ -0,0 +1,3 @@
1
+ export declare const shareGlobalName = "EMP_SHARE_RUNTIME";
2
+ export declare const shareGlobalVal = "EMPShareGlobalVal";
3
+ export declare const shareForceRemote = "EMP_FORCE_REMOTES";
@@ -0,0 +1,6 @@
1
+ export declare const importJsVm: (content: string) => string;
2
+ export declare function deepAssign<T>(target: any, ...sources: any): T;
3
+ export declare const checkVersion: (version: string) => number;
4
+ export declare const isPromise: (p: any) => any;
5
+ export declare const isDev: boolean;
6
+ export declare const log: (...args: any[]) => void;
@@ -0,0 +1,6 @@
1
+ import * as MFRuntime from '@module-federation/runtime';
2
+ import * as MFSDK from '@module-federation/sdk';
3
+ export { MFRuntime, MFSDK };
4
+ import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
5
+ export type FederationRuntimePlugin = ModuleFederationRuntimePlugin;
6
+ export type { ModuleFederationRuntimePlugin };
@@ -0,0 +1 @@
1
+ export declare function resolvePackageExport(specifier: string): string;
@@ -0,0 +1 @@
1
+ export { ModuleFederationPlugin } from '@module-federation/rspack';
@@ -0,0 +1,3 @@
1
+ import { default as pluginRspackEmpShare } from './plugins/rspack';
2
+ export default pluginRspackEmpShare;
3
+ export * from './plugins/rspack';
@@ -0,0 +1,7 @@
1
+ import 'core-js/stable/global-this';
2
+ import 'core-js/stable/object/entries';
3
+ import { reactAdapter } from '../adapter';
4
+ import { MFRuntime, MFSDK } from '../helper/moduleFederation';
5
+ import { EMPRuntime } from '../runtime';
6
+ declare const runtime: EMPRuntime;
7
+ export { MFRuntime, MFSDK, reactAdapter, runtime };
@@ -0,0 +1,2 @@
1
+ import { MFRuntime, MFSDK } from '../helper/moduleFederation';
2
+ export { MFRuntime, MFSDK };
@@ -0,0 +1,3 @@
1
+ import 'core-js/stable/global-this';
2
+ import 'core-js/stable/object/entries';
3
+ import './sdk';
@@ -0,0 +1,2 @@
1
+ import { MFRuntime, MFSDK } from '../helper/moduleFederation';
2
+ export { MFRuntime, MFSDK };
@@ -0,0 +1,11 @@
1
+ import type { GlobalStore } from '@empjs/cli';
2
+ import type { EMPPluginShareType } from './types';
3
+ export type { EMPPluginShareType };
4
+ export * from '../../framework/react/config';
5
+ export * from '../../framework/vue/config';
6
+ export * from './types';
7
+ export declare const pluginRspackEmpShare: (o?: EMPPluginShareType) => {
8
+ name: string;
9
+ rsConfig(store: GlobalStore): Promise<void>;
10
+ };
11
+ export default pluginRspackEmpShare;
@@ -0,0 +1,7 @@
1
+ import { Compiler } from '@empjs/cli';
2
+ import type { EMPSHARERuntimeOptions } from './types';
3
+ export declare class EmpShareRemoteLibPlugin {
4
+ options: EMPSHARERuntimeOptions;
5
+ constructor(op: EMPSHARERuntimeOptions);
6
+ apply(compiler: Compiler): void;
7
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 运行时插件:根据 window[EMP_FORCE_REMOTES] 配置,在注册 remote 前拦截并改写其 entry/url。
3
+ * 支持两种方式二选一:指定完整 entry 地址,或仅指定 version 做 URL 内版本号替换。
4
+ */
5
+ import { type ModuleFederationRuntimePlugin } from '@module-federation/runtime';
6
+ import { shareForceRemote } from '../../../helper/config';
7
+ import { type ForceRemoteOptions } from '../types';
8
+ declare global {
9
+ interface Window {
10
+ [shareForceRemote]?: ForceRemoteOptions;
11
+ }
12
+ }
13
+ export default function (): ModuleFederationRuntimePlugin;
@@ -0,0 +1,3 @@
1
+ import { type GlobalStore } from '@empjs/cli';
2
+ import { ForceRemoteOptions } from '../types';
3
+ export declare const registerRemotes: (store: GlobalStore, forceRemotes: ForceRemoteOptions) => void;
@@ -0,0 +1,30 @@
1
+ import type { GlobalStore } from '@empjs/cli';
2
+ import type { EMPPluginShareType, frameworkOptions, runtimeLibType } from './types';
3
+ export declare class EmpShare {
4
+ private op;
5
+ private store;
6
+ /**
7
+ * 注入资源
8
+ */
9
+ private injectHtml;
10
+ /**
11
+ * 兼容 shareLib
12
+ */
13
+ private externalsLib;
14
+ constructor(op: EMPPluginShareType, store: GlobalStore);
15
+ setup(): void;
16
+ private injectToHtml;
17
+ private injectFramework;
18
+ private injectFkLibs;
19
+ private injectGlobalVal;
20
+ fk: Required<frameworkOptions>;
21
+ private resetFramework;
22
+ rt: Required<runtimeLibType>;
23
+ private resetRuntime;
24
+ private setExternal;
25
+ private setRuntimeLib;
26
+ private setMfName;
27
+ private setMF;
28
+ private setDtsRuntimePkgs;
29
+ private setShareLib;
30
+ }
@@ -1,7 +1,6 @@
1
- import { ModuleFederationPlugin } from '@empjs/module-federation-rspack';
2
-
3
- type ModuleFederationPluginOptions = ConstructorParameters<typeof ModuleFederationPlugin>[0];
4
- type EMPSHARERuntimeOptions = {
1
+ import type { ModuleFederationPlugin } from '../../helper/rspack';
2
+ export type ModuleFederationPluginOptions = ConstructorParameters<typeof ModuleFederationPlugin>[0];
3
+ export type EMPSHARERuntimeOptions = {
5
4
  /**
6
5
  * 兼容 emp2.0 shareLib 配置
7
6
  */
@@ -36,7 +35,7 @@ type EMPSHARERuntimeOptions = {
36
35
  */
37
36
  frameworkLib?: frameworLibType;
38
37
  };
39
- type runtimeLibType = {
38
+ export type runtimeLibType = {
40
39
  /**
41
40
  * MFRuntime 地址
42
41
  */
@@ -46,11 +45,11 @@ type runtimeLibType = {
46
45
  */
47
46
  global?: string;
48
47
  };
49
- type frameworLibType = string | {
48
+ export type frameworLibType = string | {
50
49
  dev: string;
51
50
  prod: string;
52
51
  };
53
- type frameworkOptions = {
52
+ export type frameworkOptions = {
54
53
  /**
55
54
  * 框架名称
56
55
  */
@@ -81,7 +80,7 @@ type frameworkOptions = {
81
80
  /**
82
81
  * runtime beforeRegisterRemote 收到的 remote 对象结构(与 @module-federation/runtime Remote 兼容)
83
82
  */
84
- type RemoteInfoForForce = {
83
+ export type RemoteInfoForForce = {
85
84
  /** 唯一标识,如 @nova/bigolive-common,用于匹配 forceRemotes key(优先于 name) */
86
85
  alias?: string;
87
86
  /** 占位名,如 $1,可能重名;插件会为占位名生成唯一 name */
@@ -100,12 +99,12 @@ type RemoteInfoForForce = {
100
99
  * 单项配置:仅替换 URL 中 `key@oldVer` 的版本部分
101
100
  * @example "17.0.0"
102
101
  */
103
- type ForceRemoteVersion = string;
102
+ export type ForceRemoteVersion = string;
104
103
  /**
105
104
  * 单项配置:显式指定仅替换版本(与 string 等价,便于扩展)
106
105
  * @example { version: "17.0.0" }
107
106
  */
108
- type ForceRemoteVersionOption = {
107
+ export type ForceRemoteVersionOption = {
109
108
  version: string;
110
109
  };
111
110
  /**
@@ -113,7 +112,7 @@ type ForceRemoteVersionOption = {
113
112
  * 匹配时优先用 alias(唯一标识,如 @nova/bigolive-common),避免 name 为 $1 等占位符导致重名
114
113
  * @example { entry: "https://cdn.example.com/app1.js" }
115
114
  */
116
- type ForceRemoteEntryOption = {
115
+ export type ForceRemoteEntryOption = {
117
116
  entry: string;
118
117
  };
119
118
  /**
@@ -121,13 +120,13 @@ type ForceRemoteEntryOption = {
121
120
  * - string / { version }:对所有 remote 的 entry/url/manifest 中 `key@xxx` 做版本替换
122
121
  * - { entry }:key 为 remote 的 alias(优先)或 name 时,对该 remote 做整入口替换
123
122
  */
124
- type ForceRemoteItem = ForceRemoteVersion | ForceRemoteVersionOption | ForceRemoteEntryOption;
125
- type ForceRemoteOptions = Record<string, ForceRemoteItem>;
126
- type EMPPluginShareType = ModuleFederationPluginOptions & {
123
+ export type ForceRemoteItem = ForceRemoteVersion | ForceRemoteVersionOption | ForceRemoteEntryOption;
124
+ export type ForceRemoteOptions = Record<string, ForceRemoteItem>;
125
+ export type EMPPluginShareType = ModuleFederationPluginOptions & {
127
126
  empRuntime?: EMPSHARERuntimeOptions;
128
127
  forceRemotes?: ForceRemoteOptions;
129
128
  };
130
- type ExternalsItemType = {
129
+ export type ExternalsItemType = {
131
130
  /**
132
131
  * 模块名
133
132
  * @example react-dom
@@ -153,5 +152,3 @@ type ExternalsItemType = {
153
152
  */
154
153
  type?: string;
155
154
  };
156
-
157
- export type { EMPPluginShareType as E, ForceRemoteVersion as F, ModuleFederationPluginOptions as M, RemoteInfoForForce as R, EMPSHARERuntimeOptions as a, frameworkOptions as b, ForceRemoteVersionOption as c, ForceRemoteEntryOption as d, ForceRemoteItem as e, frameworLibType as f, ForceRemoteOptions as g, ExternalsItemType as h, runtimeLibType as r };
@@ -0,0 +1,2 @@
1
+ import type { EMPSHARERuntimeOptions } from './types';
2
+ export declare function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry?: string): string;
@@ -0,0 +1,20 @@
1
+ import type { ModuleFederation } from '@module-federation/runtime';
2
+ import type { EMPShareRuntimeType, EmpRuntimeOptions, InitOptionsType, LoadRemoteType } from '../types';
3
+ type EmpInitOptionsType = Partial<InitOptionsType>;
4
+ export declare class EMPRuntime {
5
+ libs: EMPShareRuntimeType;
6
+ initOptions: InitOptionsType;
7
+ options: EmpRuntimeOptions;
8
+ shareGlobalName: string;
9
+ constructor(op?: EMPShareRuntimeType);
10
+ mfInstance?: ModuleFederation;
11
+ setup(o?: EMPShareRuntimeType | string): void;
12
+ init(options?: EmpInitOptionsType): ModuleFederation | undefined;
13
+ load<T = any>(...args: LoadRemoteType): Promise<T>;
14
+ register(...args: Parameters<NonNullable<typeof this.mfInstance>['registerRemotes']>): void | undefined;
15
+ preload(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>): Promise<void> | undefined;
16
+ loadShare(...args: Parameters<NonNullable<typeof this.mfInstance>['loadShare']>): Promise<false | (() => unknown)> | undefined;
17
+ preloadRemote(...args: Parameters<NonNullable<typeof this.mfInstance>['preloadRemote']>): Promise<void> | undefined;
18
+ }
19
+ declare const _default: EMPRuntime;
20
+ export default _default;