@module-federation/runtime 0.0.0-next-20240829065118 → 0.0.0-next-20240830065016

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/share.esm.js CHANGED
@@ -1,11 +1,15 @@
1
- import { _ as _$1 } from '@swc/helpers/_/_extends';
2
- import { _ } from '@swc/helpers/_/_object_without_properties_loose';
3
- import { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
1
+ import '@module-federation/sdk';
4
2
 
5
3
  function getBuilderId() {
6
4
  //@ts-ignore
7
5
  return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
8
6
  }
7
+ function isDebugMode() {
8
+ return Boolean("");
9
+ }
10
+ function isBrowserEnv() {
11
+ return typeof window !== 'undefined';
12
+ }
9
13
 
10
14
  const LOG_CATEGORY = '[ Federation Runtime ]';
11
15
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@@ -51,6 +55,14 @@ function isRemoteInfoWithEntry(remote) {
51
55
  function isPureRemoteEntry(remote) {
52
56
  return !remote.entry.includes('.json') && remote.entry.includes('.js');
53
57
  }
58
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
59
+ function safeToString(info) {
60
+ try {
61
+ return JSON.stringify(info, null, 2);
62
+ } catch (e) {
63
+ return '';
64
+ }
65
+ }
54
66
  function isObject(val) {
55
67
  return val && typeof val === 'object';
56
68
  }
@@ -87,6 +99,32 @@ function getRemoteEntryInfoFromSnapshot(snapshot) {
87
99
  return defaultRemoteEntryInfo;
88
100
  }
89
101
 
102
+ function _extends$1() {
103
+ _extends$1 = Object.assign || function(target) {
104
+ for(var i = 1; i < arguments.length; i++){
105
+ var source = arguments[i];
106
+ for(var key in source){
107
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
108
+ target[key] = source[key];
109
+ }
110
+ }
111
+ }
112
+ return target;
113
+ };
114
+ return _extends$1.apply(this, arguments);
115
+ }
116
+ function _object_without_properties_loose(source, excluded) {
117
+ if (source == null) return {};
118
+ var target = {};
119
+ var sourceKeys = Object.keys(source);
120
+ var key, i;
121
+ for(i = 0; i < sourceKeys.length; i++){
122
+ key = sourceKeys[i];
123
+ if (excluded.indexOf(key) >= 0) continue;
124
+ target[key] = source[key];
125
+ }
126
+ return target;
127
+ }
90
128
  const nativeGlobal = (()=>{
91
129
  try {
92
130
  return new Function('return this')();
@@ -174,7 +212,7 @@ function getGlobalFederationConstructor() {
174
212
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
175
213
  if (isDebug) {
176
214
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
177
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.0";
215
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.5.1";
178
216
  }
179
217
  }
180
218
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -222,7 +260,7 @@ const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
222
260
  }
223
261
  // If the remote is not included in the hostSnapshot, deploy a micro app snapshot
224
262
  if ('version' in moduleInfo && moduleInfo['version']) {
225
- const { version } = moduleInfo, resModuleInfo = _(moduleInfo, [
263
+ const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
226
264
  "version"
227
265
  ]);
228
266
  const moduleKeyWithoutVersion = getFMId(resModuleInfo);
@@ -240,7 +278,7 @@ const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
240
278
  return nativeGlobal.__FEDERATION__.moduleInfo;
241
279
  };
242
280
  const addGlobalSnapshot = (moduleInfos)=>{
243
- nativeGlobal.__FEDERATION__.moduleInfo = _$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
281
+ nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
244
282
  return ()=>{
245
283
  const keys = Object.keys(moduleInfos);
246
284
  for (const key of keys){
@@ -274,9 +312,216 @@ const getGlobalHostPlugins = ()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
274
312
  const getPreloaded = (id)=>globalThis.__FEDERATION__.__PRELOADED_MAP__.get(id);
275
313
  const setPreloaded = (id)=>globalThis.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
276
314
 
315
+ function registerPlugins(plugins, hookInstances) {
316
+ const globalPlugins = getGlobalHostPlugins();
317
+ // Incorporate global plugins
318
+ if (globalPlugins.length > 0) {
319
+ globalPlugins.forEach((plugin)=>{
320
+ if (plugins == null ? void 0 : plugins.find((item)=>item.name !== plugin.name)) {
321
+ plugins.push(plugin);
322
+ }
323
+ });
324
+ }
325
+ if (plugins && plugins.length > 0) {
326
+ plugins.forEach((plugin)=>{
327
+ hookInstances.forEach((hookInstance)=>{
328
+ hookInstance.applyPlugin(plugin);
329
+ });
330
+ });
331
+ }
332
+ return plugins;
333
+ }
334
+
277
335
  const DEFAULT_SCOPE = 'default';
278
336
  const DEFAULT_REMOTE_TYPE = 'global';
279
337
 
338
+ class SyncHook {
339
+ on(fn) {
340
+ if (typeof fn === 'function') {
341
+ this.listeners.add(fn);
342
+ }
343
+ }
344
+ once(fn) {
345
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
346
+ const self = this;
347
+ this.on(function wrapper(...args) {
348
+ self.remove(wrapper);
349
+ // eslint-disable-next-line prefer-spread
350
+ return fn.apply(null, args);
351
+ });
352
+ }
353
+ emit(...data) {
354
+ let result;
355
+ if (this.listeners.size > 0) {
356
+ // eslint-disable-next-line prefer-spread
357
+ this.listeners.forEach((fn)=>{
358
+ result = fn(...data);
359
+ });
360
+ }
361
+ return result;
362
+ }
363
+ remove(fn) {
364
+ this.listeners.delete(fn);
365
+ }
366
+ removeAll() {
367
+ this.listeners.clear();
368
+ }
369
+ constructor(type){
370
+ this.type = '';
371
+ this.listeners = new Set();
372
+ if (type) {
373
+ this.type = type;
374
+ }
375
+ }
376
+ }
377
+
378
+ class AsyncHook extends SyncHook {
379
+ emit(...data) {
380
+ let result;
381
+ const ls = Array.from(this.listeners);
382
+ if (ls.length > 0) {
383
+ let i = 0;
384
+ const call = (prev)=>{
385
+ if (prev === false) {
386
+ return false; // Abort process
387
+ } else if (i < ls.length) {
388
+ return Promise.resolve(ls[i++].apply(null, data)).then(call);
389
+ } else {
390
+ return prev;
391
+ }
392
+ };
393
+ result = call();
394
+ }
395
+ return Promise.resolve(result);
396
+ }
397
+ }
398
+
399
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
400
+ function checkReturnData(originalData, returnedData) {
401
+ if (!isObject(returnedData)) {
402
+ return false;
403
+ }
404
+ if (originalData !== returnedData) {
405
+ // eslint-disable-next-line no-restricted-syntax
406
+ for(const key in originalData){
407
+ if (!(key in returnedData)) {
408
+ return false;
409
+ }
410
+ }
411
+ }
412
+ return true;
413
+ }
414
+ class SyncWaterfallHook extends SyncHook {
415
+ emit(data) {
416
+ if (!isObject(data)) {
417
+ error(`The data for the "${this.type}" hook should be an object.`);
418
+ }
419
+ for (const fn of this.listeners){
420
+ try {
421
+ const tempData = fn(data);
422
+ if (checkReturnData(data, tempData)) {
423
+ data = tempData;
424
+ } else {
425
+ this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
426
+ break;
427
+ }
428
+ } catch (e) {
429
+ warn(e);
430
+ this.onerror(e);
431
+ }
432
+ }
433
+ return data;
434
+ }
435
+ constructor(type){
436
+ super();
437
+ this.onerror = error;
438
+ this.type = type;
439
+ }
440
+ }
441
+
442
+ class AsyncWaterfallHook extends SyncHook {
443
+ emit(data) {
444
+ if (!isObject(data)) {
445
+ error(`The response data for the "${this.type}" hook must be an object.`);
446
+ }
447
+ const ls = Array.from(this.listeners);
448
+ if (ls.length > 0) {
449
+ let i = 0;
450
+ const processError = (e)=>{
451
+ warn(e);
452
+ this.onerror(e);
453
+ return data;
454
+ };
455
+ const call = (prevData)=>{
456
+ if (checkReturnData(data, prevData)) {
457
+ data = prevData;
458
+ if (i < ls.length) {
459
+ try {
460
+ return Promise.resolve(ls[i++](data)).then(call, processError);
461
+ } catch (e) {
462
+ return processError(e);
463
+ }
464
+ }
465
+ } else {
466
+ this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
467
+ }
468
+ return data;
469
+ };
470
+ return Promise.resolve(call(data));
471
+ }
472
+ return Promise.resolve(data);
473
+ }
474
+ constructor(type){
475
+ super();
476
+ this.onerror = error;
477
+ this.type = type;
478
+ }
479
+ }
480
+
481
+ class PluginSystem {
482
+ applyPlugin(plugin) {
483
+ assert(isPlainObject(plugin), 'Plugin configuration is invalid.');
484
+ // The plugin's name is mandatory and must be unique
485
+ const pluginName = plugin.name;
486
+ assert(pluginName, 'A name must be provided by the plugin.');
487
+ if (!this.registerPlugins[pluginName]) {
488
+ this.registerPlugins[pluginName] = plugin;
489
+ Object.keys(this.lifecycle).forEach((key)=>{
490
+ const pluginLife = plugin[key];
491
+ if (pluginLife) {
492
+ this.lifecycle[key].on(pluginLife);
493
+ }
494
+ });
495
+ }
496
+ }
497
+ removePlugin(pluginName) {
498
+ assert(pluginName, 'A name is required.');
499
+ const plugin = this.registerPlugins[pluginName];
500
+ assert(plugin, `The plugin "${pluginName}" is not registered.`);
501
+ Object.keys(plugin).forEach((key)=>{
502
+ if (key !== 'name') {
503
+ this.lifecycle[key].remove(plugin[key]);
504
+ }
505
+ });
506
+ }
507
+ // eslint-disable-next-line @typescript-eslint/no-shadow
508
+ inherit({ lifecycle, registerPlugins }) {
509
+ Object.keys(lifecycle).forEach((hookName)=>{
510
+ assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
511
+ this.lifecycle[hookName] = lifecycle[hookName];
512
+ });
513
+ Object.keys(registerPlugins).forEach((pluginName)=>{
514
+ assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
515
+ this.applyPlugin(registerPlugins[pluginName]);
516
+ });
517
+ }
518
+ constructor(lifecycle){
519
+ this.registerPlugins = {};
520
+ this.lifecycle = lifecycle;
521
+ this.lifecycleKeys = Object.keys(lifecycle);
522
+ }
523
+ }
524
+
280
525
  // fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
281
526
  // those constants are based on https://www.rubydoc.info/gems/semantic_range/3.0.0/SemanticRange#BUILDIDENTIFIER-constant
282
527
  // Copyright (c)
@@ -633,6 +878,20 @@ function satisfy(version, range) {
633
878
  return true;
634
879
  }
635
880
 
881
+ function _extends() {
882
+ _extends = Object.assign || function(target) {
883
+ for(var i = 1; i < arguments.length; i++){
884
+ var source = arguments[i];
885
+ for(var key in source){
886
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
887
+ target[key] = source[key];
888
+ }
889
+ }
890
+ }
891
+ return target;
892
+ };
893
+ return _extends.apply(this, arguments);
894
+ }
636
895
  function formatShare(shareArgs, from, name, shareStrategy) {
637
896
  let get;
638
897
  if ('get' in shareArgs) {
@@ -649,13 +908,13 @@ function formatShare(shareArgs, from, name, shareStrategy) {
649
908
  warn(`"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"`);
650
909
  }
651
910
  var _shareArgs_version, _shareArgs_scope, _shareArgs_strategy;
652
- return _$1({
911
+ return _extends({
653
912
  deps: [],
654
913
  useIn: [],
655
914
  from,
656
915
  loading: null
657
916
  }, shareArgs, {
658
- shareConfig: _$1({
917
+ shareConfig: _extends({
659
918
  requiredVersion: `^${shareArgs.version}`,
660
919
  singleton: false,
661
920
  eager: false,
@@ -681,7 +940,7 @@ function formatShareConfigs(globalOptions, userOptions) {
681
940
  });
682
941
  return res;
683
942
  }, {});
684
- const shared = _$1({}, globalOptions.shared);
943
+ const shared = _extends({}, globalOptions.shared);
685
944
  Object.keys(shareInfos).forEach((shareKey)=>{
686
945
  if (!shared[shareKey]) {
687
946
  shared[shareKey] = shareInfos[shareKey];
@@ -845,4 +1104,4 @@ function getTargetSharedOptions(options) {
845
1104
  return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
846
1105
  }
847
1106
 
848
- export { getBuilderId as A, setGlobalFederationConstructor as B, getGlobalFederationInstance as C, DEFAULT_REMOTE_TYPE as D, getGlobalFederationConstructor as E, setGlobalFederationInstance as F, Global as G, registerGlobalPlugins as H, nativeGlobal as I, resetFederationGlobalInfo as J, getTargetSnapshotInfoByModuleInfo as K, globalLoading as a, DEFAULT_SCOPE as b, getRemoteEntryExports as c, assert as d, getFMId as e, error as f, getGlobalHostPlugins as g, isPlainObject as h, isObject as i, isRemoteInfoWithEntry as j, isPureRemoteEntry as k, getRemoteEntryInfoFromSnapshot as l, getInfoWithoutType as m, getPreloaded as n, getRegisteredShare as o, arrayOptions as p, getGlobalSnapshotInfoByModuleInfo as q, addGlobalSnapshot as r, setPreloaded as s, setGlobalSnapshotInfoByModuleInfo as t, getGlobalSnapshot as u, formatShareConfigs as v, warn as w, getTargetSharedOptions as x, getGlobalShareScope as y, addUniqueItem as z };
1107
+ export { AsyncHook as A, registerPlugins as B, getBuilderId as C, DEFAULT_REMOTE_TYPE as D, setGlobalFederationConstructor as E, getGlobalFederationInstance as F, Global as G, getGlobalFederationConstructor as H, setGlobalFederationInstance as I, registerGlobalPlugins as J, nativeGlobal as K, resetFederationGlobalInfo as L, getTargetSnapshotInfoByModuleInfo as M, getGlobalHostPlugins as N, PluginSystem as P, SyncWaterfallHook as S, DEFAULT_SCOPE as a, getRemoteEntryExports as b, assert as c, getFMId as d, isPureRemoteEntry as e, getRemoteEntryInfoFromSnapshot as f, globalLoading as g, error as h, isRemoteInfoWithEntry as i, isBrowserEnv as j, getInfoWithoutType as k, getPreloaded as l, setPreloaded as m, getRegisteredShare as n, arrayOptions as o, getGlobalSnapshotInfoByModuleInfo as p, addGlobalSnapshot as q, setGlobalSnapshotInfoByModuleInfo as r, safeToString as s, AsyncWaterfallHook as t, getGlobalSnapshot as u, formatShareConfigs as v, getTargetSharedOptions as w, getGlobalShareScope as x, addUniqueItem as y, SyncHook as z };
@@ -1,5 +1,5 @@
1
1
  import type { CreateScriptHookReturn } from '@module-federation/sdk';
2
- import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions, CallFrom } from './type';
2
+ import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions } from './type';
3
3
  import { Module } from './module';
4
4
  import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';
5
5
  import { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';
@@ -69,15 +69,11 @@ export declare class FederationHost {
69
69
  customShareInfo?: Partial<Shared>;
70
70
  resolver?: (sharedOptions: ShareInfos[string]) => Shared;
71
71
  }): () => T | never;
72
- initializeSharing(shareScopeName?: string, extraOptions?: {
73
- initScope?: InitScope;
74
- from?: CallFrom;
75
- strategy?: Shared['strategy'];
76
- }): Array<Promise<void>>;
72
+ initializeSharing(shareScopeName?: string, strategy?: Shared['strategy']): Array<Promise<void>>;
77
73
  initRawContainer(name: string, url: string, container: RemoteEntryExports): Module;
78
74
  loadRemote<T>(id: string, options?: {
79
75
  loadFactory?: boolean;
80
- from: CallFrom;
76
+ from: 'build' | 'runtime';
81
77
  }): Promise<T | null>;
82
78
  preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
83
79
  initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
@@ -1,5 +1,7 @@
1
1
  import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getInfoWithoutType, getGlobalSnapshot, getTargetSnapshotInfoByModuleInfo, getGlobalSnapshotInfoByModuleInfo, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
2
2
  import { getRegisteredShare, getGlobalShareScope } from './utils/share';
3
+ import * as pluginHelper from './utils/hooks';
4
+ import { registerPlugins } from './utils';
3
5
  interface IShareUtils {
4
6
  getRegisteredShare: typeof getRegisteredShare;
5
7
  getGlobalShareScope: typeof getGlobalShareScope;
@@ -23,6 +25,8 @@ interface IGlobalUtils {
23
25
  getGlobalHostPlugins: typeof getGlobalHostPlugins;
24
26
  getPreloaded: typeof getPreloaded;
25
27
  setPreloaded: typeof setPreloaded;
28
+ registerPlugins: typeof registerPlugins;
29
+ pluginHelper: typeof pluginHelper;
26
30
  }
27
31
  declare const _default: {
28
32
  global: IGlobalUtils;
@@ -32,6 +32,11 @@ export declare class SnapshotHandler {
32
32
  remoteSnapshot: ModuleInfo;
33
33
  from: "global" | "manifest";
34
34
  }>;
35
+ afterLoadSnapshot: AsyncWaterfallHook<{
36
+ options: Options;
37
+ moduleInfo: Remote;
38
+ remoteSnapshot: ModuleInfo;
39
+ }>;
35
40
  }>;
36
41
  loaderHook: FederationHost['loaderHook'];
37
42
  manifestLoading: Record<string, Promise<ModuleInfo>>;
@@ -1,5 +1,5 @@
1
- import { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
2
- import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, RemoteEntryExports, CallFrom } from '../type';
1
+ import type { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
2
+ import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, RemoteEntryExports } from '../type';
3
3
  import { FederationHost } from '../core';
4
4
  import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncHook, SyncWaterfallHook } from '../utils/hooks';
5
5
  import { Module, ModuleOptions } from '../module';
@@ -56,7 +56,7 @@ export declare class RemoteHandler {
56
56
  id: string;
57
57
  error: unknown;
58
58
  options?: any;
59
- from: CallFrom;
59
+ from: "build" | "runtime";
60
60
  lifecycle: "onLoad" | "beforeRequest";
61
61
  origin: FederationHost;
62
62
  }], unknown>;
@@ -89,7 +89,7 @@ export declare class RemoteHandler {
89
89
  setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch): void;
90
90
  loadRemote<T>(id: string, options?: {
91
91
  loadFactory?: boolean;
92
- from: CallFrom;
92
+ from: 'build' | 'runtime';
93
93
  }): Promise<T | null>;
94
94
  preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
95
95
  registerRemotes(remotes: Remote[], options?: {
@@ -1,5 +1,5 @@
1
1
  import { Federation } from '../global';
2
- import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions, ShareStrategy, InitScope, InitTokens, CallFrom } from '../type';
2
+ import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions, ShareStrategy } from '../type';
3
3
  import { FederationHost } from '../core';
4
4
  import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncWaterfallHook } from '../utils/hooks';
5
5
  import { LoadRemoteMatch } from '../remote';
@@ -31,7 +31,6 @@ export declare class SharedHandler {
31
31
  hostShareScopeMap?: ShareScopeMap;
32
32
  }>;
33
33
  }>;
34
- initTokens: InitTokens;
35
34
  constructor(host: FederationHost);
36
35
  registerShared(globalOptions: Options, userOptions: UserOptions): {
37
36
  shareInfos: ShareInfos;
@@ -48,11 +47,7 @@ export declare class SharedHandler {
48
47
  * It accepts one argument, the name of the share scope.
49
48
  * If the share scope does not exist, it creates one.
50
49
  */
51
- initializeSharing(shareScopeName?: string, extraOptions?: {
52
- initScope?: InitScope;
53
- from?: CallFrom;
54
- strategy?: ShareStrategy;
55
- }): Array<Promise<void>>;
50
+ initializeSharing(shareScopeName?: string, strategy?: ShareStrategy): Array<Promise<void>>;
56
51
  loadShareSync<T>(pkgName: string, extraOptions?: {
57
52
  customShareInfo?: Partial<Shared>;
58
53
  resolver?: (sharedOptions: ShareInfos[string]) => Shared;
@@ -102,9 +102,7 @@ export type RemoteEntryInitOptions = {
102
102
  version: string;
103
103
  shareScopeMap: ShareScopeMap;
104
104
  };
105
- export type InitTokens = Record<string, Record<string, any>>;
106
- export type InitScope = InitTokens[];
107
- export type CallFrom = 'build' | 'runtime';
105
+ export type InitScope = Array<Record<string, never>>;
108
106
  export type RemoteEntryExports = {
109
107
  get: (id: string) => () => Promise<Module>;
110
108
  init: (shareScope: ShareScopeMap[string], initScope?: InitScope, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void | Promise<void>;
@@ -1,3 +1,4 @@
1
- export { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
2
1
  export declare function isDevelopmentMode(): boolean;
3
2
  export declare function getBuilderId(): string;
3
+ export declare function isDebugMode(): boolean;
4
+ export declare function isBrowserEnv(): boolean;
@@ -1,4 +1,5 @@
1
1
  import { FederationHost } from '../core';
2
2
  import { UserOptions } from '../type';
3
3
  import { Module } from '../module';
4
- export declare function registerPlugins(plugins: UserOptions['plugins'], hookInstances: Array<FederationHost['hooks'] | FederationHost['snapshotHandler']['hooks'] | FederationHost['sharedHandler']['hooks'] | FederationHost['remoteHandler']['hooks'] | Module['host']['loaderHook']>): import("../type").FederationRuntimePlugin[] | undefined;
4
+ import { PluginSystem } from './hooks';
5
+ export declare function registerPlugins<Y extends Record<string, any>, T extends PluginSystem<Y>>(plugins: UserOptions['plugins'], hookInstances: Array<T | FederationHost['hooks'] | FederationHost['snapshotHandler']['hooks'] | FederationHost['sharedHandler']['hooks'] | FederationHost['remoteHandler']['hooks'] | Module['host']['loaderHook']>): import("../type").FederationRuntimePlugin[] | undefined;
@@ -1,10 +1,11 @@
1
- import { RemoteWithEntry, ModuleInfo, RemoteEntryType } from '@module-federation/sdk';
1
+ import type { RemoteWithEntry, ModuleInfo, RemoteEntryType } from '@module-federation/sdk';
2
2
  import { Remote, RemoteInfoOptionalVersion } from '../type';
3
3
  export declare function addUniqueItem(arr: Array<string>, item: string): Array<string>;
4
4
  export declare function getFMId(remoteInfo: RemoteInfoOptionalVersion | RemoteWithEntry): string;
5
5
  export declare function isRemoteInfoWithEntry(remote: Remote): remote is RemoteWithEntry;
6
6
  export declare function isPureRemoteEntry(remote: RemoteWithEntry): boolean;
7
7
  export declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
8
+ export declare function safeToString(info: any): string;
8
9
  export declare function isObject(val: any): boolean;
9
10
  export declare const objectToString: () => string;
10
11
  export declare function isPlainObject(val: any): val is object;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.0.0-next-20240829065118",
3
+ "version": "0.0.0-next-20240830065016",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -34,11 +34,6 @@
34
34
  "import": "./dist/retry-plugin.esm.js",
35
35
  "require": "./dist/retry-plugin.cjs.js"
36
36
  },
37
- "./embedded": {
38
- "types": "./dist/embedded.cjs.d.ts",
39
- "import": "./dist/embedded.esm.js",
40
- "require": "./dist/embedded.cjs.js"
41
- },
42
37
  "./*": "./*"
43
38
  },
44
39
  "typesVersions": {
@@ -58,6 +53,6 @@
58
53
  }
59
54
  },
60
55
  "dependencies": {
61
- "@module-federation/sdk": "0.0.0-next-20240829065118"
56
+ "@module-federation/sdk": "0.0.0-next-20240830065016"
62
57
  }
63
58
  }
@@ -1 +0,0 @@
1
- export * from "./src/embedded";
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const { FederationHost, registerGlobalPlugins, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerRemotes, registerPlugins, getInstance } = __webpack_require__.federation.runtime;
6
-
7
- exports.FederationHost = FederationHost;
8
- exports.getInstance = getInstance;
9
- exports.getRemoteEntry = getRemoteEntry;
10
- exports.getRemoteInfo = getRemoteInfo;
11
- exports.init = init;
12
- exports.loadRemote = loadRemote;
13
- exports.loadScript = loadScript;
14
- exports.loadScriptNode = loadScriptNode;
15
- exports.loadShare = loadShare;
16
- exports.loadShareSync = loadShareSync;
17
- exports.preloadRemote = preloadRemote;
18
- exports.registerGlobalPlugins = registerGlobalPlugins;
19
- exports.registerPlugins = registerPlugins;
20
- exports.registerRemotes = registerRemotes;
@@ -1,3 +0,0 @@
1
- const { FederationHost, registerGlobalPlugins, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerRemotes, registerPlugins, getInstance } = __webpack_require__.federation.runtime;
2
-
3
- export { FederationHost, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes };
@@ -1,2 +0,0 @@
1
- declare const FederationHost: any, registerGlobalPlugins: any, getRemoteEntry: any, getRemoteInfo: any, loadScript: any, loadScriptNode: any, init: any, loadRemote: any, loadShare: any, loadShareSync: any, preloadRemote: any, registerRemotes: any, registerPlugins: any, getInstance: any;
2
- export { FederationHost, registerGlobalPlugins, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerRemotes, registerPlugins, getInstance, };