@module-federation/retry-plugin 2.0.1 → 2.2.0
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/README.md +44 -60
- package/dist/CHANGELOG.md +17 -1
- package/dist/README.md +44 -60
- package/dist/esm/index.js +282 -341
- package/dist/index.d.ts +641 -20
- package/dist/index.js +288 -371
- package/dist/package.json +8 -1
- package/package.json +10 -3
- package/dist/index.d.mts +0 -110
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,625 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateScriptHookReturn, GlobalModuleInfo, Manifest, Module, ModuleInfo, RemoteEntryType, RemoteWithEntry, RemoteWithVersion, TreeShakingStatus } from "@module-federation/sdk";
|
|
2
2
|
|
|
3
|
+
//#region ../runtime-core/dist/utils/hooks/syncHook.d.ts
|
|
4
|
+
//#region src/utils/hooks/syncHook.d.ts
|
|
5
|
+
type Callback<T, K> = (...args: ArgsType<T>) => K;
|
|
6
|
+
type ArgsType<T> = T extends Array<any> ? T : Array<any>;
|
|
7
|
+
declare class SyncHook<T, K> {
|
|
8
|
+
type: string;
|
|
9
|
+
listeners: Set<Callback<T, K>>;
|
|
10
|
+
constructor(type?: string);
|
|
11
|
+
on(fn: Callback<T, K>): void;
|
|
12
|
+
once(fn: Callback<T, K>): void;
|
|
13
|
+
emit(...data: ArgsType<T>): void | K | Promise<any>;
|
|
14
|
+
remove(fn: Callback<T, K>): void;
|
|
15
|
+
removeAll(): void;
|
|
16
|
+
} //#endregion
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region ../runtime-core/dist/utils/hooks/asyncHook.d.ts
|
|
19
|
+
//#region src/utils/hooks/asyncHook.d.ts
|
|
20
|
+
type CallbackReturnType$1 = void | false | Promise<void | false>;
|
|
21
|
+
declare class AsyncHook<T, ExternalEmitReturnType = CallbackReturnType$1> extends SyncHook<T, ExternalEmitReturnType> {
|
|
22
|
+
emit(...data: ArgsType<T>): Promise<void | false | ExternalEmitReturnType>;
|
|
23
|
+
} //#endregion
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region ../runtime-core/dist/utils/hooks/syncWaterfallHook.d.ts
|
|
26
|
+
//#region src/utils/hooks/syncWaterfallHook.d.ts
|
|
27
|
+
declare class SyncWaterfallHook<T extends Record<string, any>> extends SyncHook<[T], T> {
|
|
28
|
+
onerror: (errMsg: string | Error | unknown) => void;
|
|
29
|
+
constructor(type: string);
|
|
30
|
+
emit(data: T): T;
|
|
31
|
+
} //#endregion
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region ../runtime-core/dist/utils/hooks/asyncWaterfallHooks.d.ts
|
|
34
|
+
//#region src/utils/hooks/asyncWaterfallHooks.d.ts
|
|
35
|
+
type CallbackReturnType<T> = T | Promise<T>;
|
|
36
|
+
declare class AsyncWaterfallHook<T extends Record<string, any>> extends SyncHook<[T], CallbackReturnType<T>> {
|
|
37
|
+
onerror: (errMsg: string | Error | unknown) => void;
|
|
38
|
+
constructor(type: string);
|
|
39
|
+
emit(data: T): Promise<T>;
|
|
40
|
+
} //#endregion
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region ../runtime-core/dist/utils/hooks/pluginSystem.d.ts
|
|
43
|
+
//#region src/utils/hooks/pluginSystem.d.ts
|
|
44
|
+
type Plugin<T extends Record<string, any>> = { [k in keyof T]?: Parameters<T[k]['on']>[0] } & {
|
|
45
|
+
name: string;
|
|
46
|
+
version?: string;
|
|
47
|
+
apply?: (instance: ModuleFederation) => void;
|
|
48
|
+
};
|
|
49
|
+
declare class PluginSystem<T extends Record<string, any>> {
|
|
50
|
+
lifecycle: T;
|
|
51
|
+
lifecycleKeys: Array<keyof T>;
|
|
52
|
+
registerPlugins: Record<string, Plugin<T>>;
|
|
53
|
+
constructor(lifecycle: T);
|
|
54
|
+
applyPlugin(plugin: Plugin<T>, instance: ModuleFederation): void;
|
|
55
|
+
removePlugin(pluginName: string): void;
|
|
56
|
+
} //#endregion
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region ../runtime-core/dist/type/config.d.ts
|
|
59
|
+
//#region src/type/config.d.ts
|
|
60
|
+
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
|
|
61
|
+
interface RemoteInfoCommon {
|
|
62
|
+
alias?: string;
|
|
63
|
+
shareScope?: string | string[];
|
|
64
|
+
type?: RemoteEntryType;
|
|
65
|
+
entryGlobalName?: string;
|
|
66
|
+
}
|
|
67
|
+
type Remote = (RemoteWithEntry | RemoteWithVersion) & RemoteInfoCommon;
|
|
68
|
+
interface RemoteInfo {
|
|
69
|
+
alias?: string;
|
|
70
|
+
name: string;
|
|
71
|
+
version?: string;
|
|
72
|
+
buildVersion?: string;
|
|
73
|
+
entry: string;
|
|
74
|
+
type: RemoteEntryType;
|
|
75
|
+
entryGlobalName: string;
|
|
76
|
+
shareScope: string | string[];
|
|
77
|
+
}
|
|
78
|
+
interface SharedConfig {
|
|
79
|
+
singleton?: boolean;
|
|
80
|
+
requiredVersion: false | string;
|
|
81
|
+
eager?: boolean;
|
|
82
|
+
strictVersion?: boolean;
|
|
83
|
+
layer?: string | null;
|
|
84
|
+
}
|
|
85
|
+
type TreeShakingArgs = {
|
|
86
|
+
usedExports?: string[];
|
|
87
|
+
get?: SharedGetter;
|
|
88
|
+
lib?: () => Module;
|
|
89
|
+
status?: TreeShakingStatus;
|
|
90
|
+
mode?: 'server-calc' | 'runtime-infer';
|
|
91
|
+
loading?: null | Promise<any>;
|
|
92
|
+
loaded?: boolean;
|
|
93
|
+
useIn?: Array<string>;
|
|
94
|
+
};
|
|
95
|
+
type SharedBaseArgs = {
|
|
96
|
+
version?: string;
|
|
97
|
+
shareConfig?: SharedConfig;
|
|
98
|
+
scope?: string | Array<string>;
|
|
99
|
+
deps?: Array<string>;
|
|
100
|
+
strategy?: 'version-first' | 'loaded-first';
|
|
101
|
+
loaded?: boolean;
|
|
102
|
+
treeShaking?: TreeShakingArgs;
|
|
103
|
+
};
|
|
104
|
+
type SharedGetter = (() => () => Module) | (() => Promise<() => Module>);
|
|
105
|
+
type ShareArgs = (SharedBaseArgs & {
|
|
106
|
+
get: SharedGetter;
|
|
107
|
+
}) | (SharedBaseArgs & {
|
|
108
|
+
lib: () => Module;
|
|
109
|
+
}) | SharedBaseArgs;
|
|
110
|
+
type ShareStrategy = 'version-first' | 'loaded-first';
|
|
111
|
+
type Shared = {
|
|
112
|
+
version: string;
|
|
113
|
+
get: SharedGetter;
|
|
114
|
+
shareConfig: SharedConfig;
|
|
115
|
+
scope: Array<string>;
|
|
116
|
+
useIn: Array<string>;
|
|
117
|
+
from: string;
|
|
118
|
+
deps: Array<string>;
|
|
119
|
+
lib?: () => Module;
|
|
120
|
+
loaded?: boolean;
|
|
121
|
+
loading?: null | Promise<any>;
|
|
122
|
+
eager?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated set in initOptions.shareStrategy instead
|
|
125
|
+
*/
|
|
126
|
+
strategy: ShareStrategy;
|
|
127
|
+
treeShaking?: TreeShakingArgs;
|
|
128
|
+
};
|
|
129
|
+
type ShareScopeMap = {
|
|
130
|
+
[scope: string]: {
|
|
131
|
+
[pkgName: string]: {
|
|
132
|
+
[sharedVersion: string]: Shared;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
type GlobalShareScopeMap = {
|
|
137
|
+
[instanceName: string]: ShareScopeMap;
|
|
138
|
+
};
|
|
139
|
+
type ShareInfos = {
|
|
140
|
+
[pkgName: string]: Shared[];
|
|
141
|
+
};
|
|
142
|
+
interface Options {
|
|
143
|
+
id?: string;
|
|
144
|
+
name: string;
|
|
145
|
+
version?: string;
|
|
146
|
+
remotes: Array<Remote>;
|
|
147
|
+
shared: ShareInfos;
|
|
148
|
+
plugins: Array<ModuleFederationRuntimePlugin>;
|
|
149
|
+
inBrowser: boolean;
|
|
150
|
+
shareStrategy?: ShareStrategy;
|
|
151
|
+
}
|
|
152
|
+
type UserOptions = Omit<Optional<Options, 'plugins'>, 'shared' | 'inBrowser'> & {
|
|
153
|
+
shared?: {
|
|
154
|
+
[pkgName: string]: ShareArgs | ShareArgs[];
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
type RemoteEntryInitOptions = {
|
|
158
|
+
version: string;
|
|
159
|
+
shareScopeMap?: ShareScopeMap;
|
|
160
|
+
shareScopeKeys: string | string[];
|
|
161
|
+
};
|
|
162
|
+
type InitTokens = Record<string, Record<string, any>>;
|
|
163
|
+
type InitScope = InitTokens[];
|
|
164
|
+
type CallFrom = 'build' | 'runtime';
|
|
165
|
+
type RemoteEntryExports = {
|
|
166
|
+
get: (id: string) => () => Promise<Module>;
|
|
167
|
+
init: (shareScope: ShareScopeMap[string], initScope?: InitScope, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void | Promise<void>;
|
|
168
|
+
}; //#endregion
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region ../runtime-core/dist/type/preload.d.ts
|
|
171
|
+
//#region src/type/preload.d.ts
|
|
172
|
+
type depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;
|
|
173
|
+
interface PreloadRemoteArgs {
|
|
174
|
+
nameOrAlias: string;
|
|
175
|
+
exposes?: Array<string>;
|
|
176
|
+
resourceCategory?: 'all' | 'sync';
|
|
177
|
+
share?: boolean;
|
|
178
|
+
depsRemote?: boolean | Array<depsPreloadArg>;
|
|
179
|
+
filter?: (assetUrl: string) => boolean;
|
|
180
|
+
prefetchInterface?: boolean;
|
|
181
|
+
}
|
|
182
|
+
type PreloadConfig = PreloadRemoteArgs;
|
|
183
|
+
type PreloadOptions = Array<{
|
|
184
|
+
remote: Remote;
|
|
185
|
+
preloadConfig: PreloadConfig;
|
|
186
|
+
}>;
|
|
187
|
+
type EntryAssets = {
|
|
188
|
+
name: string;
|
|
189
|
+
url: string;
|
|
190
|
+
moduleInfo: RemoteInfo;
|
|
191
|
+
};
|
|
192
|
+
interface PreloadAssets {
|
|
193
|
+
cssAssets: Array<string>;
|
|
194
|
+
jsAssetsWithoutEntry: Array<string>;
|
|
195
|
+
entryAssets: Array<EntryAssets>;
|
|
196
|
+
} //#endregion
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region ../runtime-core/dist/remote/index.d.ts
|
|
199
|
+
//#region src/remote/index.d.ts
|
|
200
|
+
interface LoadRemoteMatch {
|
|
201
|
+
id: string;
|
|
202
|
+
pkgNameOrAlias: string;
|
|
203
|
+
expose: string;
|
|
204
|
+
remote: Remote;
|
|
205
|
+
options: Options;
|
|
206
|
+
origin: ModuleFederation;
|
|
207
|
+
remoteInfo: RemoteInfo;
|
|
208
|
+
remoteSnapshot?: ModuleInfo;
|
|
209
|
+
}
|
|
210
|
+
declare class RemoteHandler {
|
|
211
|
+
host: ModuleFederation;
|
|
212
|
+
idToRemoteMap: Record<string, {
|
|
213
|
+
name: string;
|
|
214
|
+
expose: string;
|
|
215
|
+
}>;
|
|
216
|
+
hooks: PluginSystem<{
|
|
217
|
+
beforeRegisterRemote: SyncWaterfallHook<{
|
|
218
|
+
remote: Remote;
|
|
219
|
+
origin: ModuleFederation;
|
|
220
|
+
}>;
|
|
221
|
+
registerRemote: SyncWaterfallHook<{
|
|
222
|
+
remote: Remote;
|
|
223
|
+
origin: ModuleFederation;
|
|
224
|
+
}>;
|
|
225
|
+
beforeRequest: AsyncWaterfallHook<{
|
|
226
|
+
id: string;
|
|
227
|
+
options: Options;
|
|
228
|
+
origin: ModuleFederation;
|
|
229
|
+
}>;
|
|
230
|
+
onLoad: AsyncHook<[{
|
|
231
|
+
id: string;
|
|
232
|
+
expose: string;
|
|
233
|
+
pkgNameOrAlias: string;
|
|
234
|
+
remote: Remote;
|
|
235
|
+
options: ModuleOptions;
|
|
236
|
+
origin: ModuleFederation;
|
|
237
|
+
exposeModule: any;
|
|
238
|
+
exposeModuleFactory: any;
|
|
239
|
+
moduleInstance: Module$1;
|
|
240
|
+
}], void>;
|
|
241
|
+
handlePreloadModule: SyncHook<[{
|
|
242
|
+
id: string;
|
|
243
|
+
name: string;
|
|
244
|
+
remote: Remote;
|
|
245
|
+
remoteSnapshot: ModuleInfo;
|
|
246
|
+
preloadConfig: PreloadRemoteArgs;
|
|
247
|
+
origin: ModuleFederation;
|
|
248
|
+
}], void>;
|
|
249
|
+
errorLoadRemote: AsyncHook<[{
|
|
250
|
+
id: string;
|
|
251
|
+
error: unknown;
|
|
252
|
+
options?: any;
|
|
253
|
+
from: CallFrom;
|
|
254
|
+
lifecycle: "beforeRequest" | "beforeLoadShare" | "afterResolve" | "onLoad";
|
|
255
|
+
origin: ModuleFederation;
|
|
256
|
+
}], unknown>;
|
|
257
|
+
beforePreloadRemote: AsyncHook<[{
|
|
258
|
+
preloadOps: Array<PreloadRemoteArgs>;
|
|
259
|
+
options: Options;
|
|
260
|
+
origin: ModuleFederation;
|
|
261
|
+
}], false | void | Promise<false | void>>;
|
|
262
|
+
generatePreloadAssets: AsyncHook<[{
|
|
263
|
+
origin: ModuleFederation;
|
|
264
|
+
preloadOptions: PreloadOptions[number];
|
|
265
|
+
remote: Remote;
|
|
266
|
+
remoteInfo: RemoteInfo;
|
|
267
|
+
remoteSnapshot: ModuleInfo;
|
|
268
|
+
globalSnapshot: GlobalModuleInfo;
|
|
269
|
+
}], Promise<PreloadAssets>>;
|
|
270
|
+
afterPreloadRemote: AsyncHook<{
|
|
271
|
+
preloadOps: Array<PreloadRemoteArgs>;
|
|
272
|
+
options: Options;
|
|
273
|
+
origin: ModuleFederation;
|
|
274
|
+
}, false | void | Promise<false | void>>;
|
|
275
|
+
loadEntry: AsyncHook<[{
|
|
276
|
+
loaderHook: ModuleFederation["loaderHook"];
|
|
277
|
+
remoteInfo: RemoteInfo;
|
|
278
|
+
remoteEntryExports?: RemoteEntryExports;
|
|
279
|
+
}], Promise<RemoteEntryExports>>;
|
|
280
|
+
}>;
|
|
281
|
+
constructor(host: ModuleFederation);
|
|
282
|
+
formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions): Remote[];
|
|
283
|
+
setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch): void;
|
|
284
|
+
loadRemote<T>(id: string, options?: {
|
|
285
|
+
loadFactory?: boolean;
|
|
286
|
+
from: CallFrom;
|
|
287
|
+
}): Promise<T | null>;
|
|
288
|
+
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
|
|
289
|
+
registerRemotes(remotes: Remote[], options?: {
|
|
290
|
+
force?: boolean;
|
|
291
|
+
}): void;
|
|
292
|
+
getRemoteModuleAndOptions(options: {
|
|
293
|
+
id: string;
|
|
294
|
+
}): Promise<{
|
|
295
|
+
module: Module$1;
|
|
296
|
+
moduleOptions: ModuleOptions;
|
|
297
|
+
remoteMatchInfo: LoadRemoteMatch;
|
|
298
|
+
}>;
|
|
299
|
+
registerRemote(remote: Remote, targetRemotes: Remote[], options?: {
|
|
300
|
+
force?: boolean;
|
|
301
|
+
}): void;
|
|
302
|
+
private removeRemote;
|
|
303
|
+
} //#endregion
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region ../runtime-core/dist/shared/index.d.ts
|
|
306
|
+
//#region src/shared/index.d.ts
|
|
307
|
+
declare class SharedHandler {
|
|
308
|
+
host: ModuleFederation;
|
|
309
|
+
shareScopeMap: ShareScopeMap;
|
|
310
|
+
hooks: PluginSystem<{
|
|
311
|
+
beforeRegisterShare: SyncWaterfallHook<{
|
|
312
|
+
pkgName: string;
|
|
313
|
+
shared: Shared;
|
|
314
|
+
origin: ModuleFederation;
|
|
315
|
+
}>;
|
|
316
|
+
afterResolve: AsyncWaterfallHook<LoadRemoteMatch>;
|
|
317
|
+
beforeLoadShare: AsyncWaterfallHook<{
|
|
318
|
+
pkgName: string;
|
|
319
|
+
shareInfo?: Shared;
|
|
320
|
+
shared: Options["shared"];
|
|
321
|
+
origin: ModuleFederation;
|
|
322
|
+
}>;
|
|
323
|
+
loadShare: AsyncHook<[ModuleFederation, string, ShareInfos], false | void | Promise<false | void>>;
|
|
324
|
+
resolveShare: SyncWaterfallHook<{
|
|
325
|
+
shareScopeMap: ShareScopeMap;
|
|
326
|
+
scope: string;
|
|
327
|
+
pkgName: string;
|
|
328
|
+
version: string;
|
|
329
|
+
shareInfo: Shared;
|
|
330
|
+
GlobalFederation: Federation;
|
|
331
|
+
resolver: () => {
|
|
332
|
+
shared: Shared;
|
|
333
|
+
useTreesShaking: boolean;
|
|
334
|
+
} | undefined;
|
|
335
|
+
}>;
|
|
336
|
+
initContainerShareScopeMap: SyncWaterfallHook<{
|
|
337
|
+
shareScope: ShareScopeMap[string];
|
|
338
|
+
options: Options;
|
|
339
|
+
origin: ModuleFederation;
|
|
340
|
+
scopeName: string;
|
|
341
|
+
hostShareScopeMap?: ShareScopeMap;
|
|
342
|
+
}>;
|
|
343
|
+
}>;
|
|
344
|
+
initTokens: InitTokens;
|
|
345
|
+
constructor(host: ModuleFederation);
|
|
346
|
+
registerShared(globalOptions: Options, userOptions: UserOptions): {
|
|
347
|
+
newShareInfos: ShareInfos;
|
|
348
|
+
allShareInfos: {
|
|
349
|
+
[pkgName: string]: Shared[];
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
loadShare<T>(pkgName: string, extraOptions?: {
|
|
353
|
+
customShareInfo?: Partial<Shared>;
|
|
354
|
+
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
355
|
+
}): Promise<false | (() => T | undefined)>;
|
|
356
|
+
/**
|
|
357
|
+
* This function initializes the sharing sequence (executed only once per share scope).
|
|
358
|
+
* It accepts one argument, the name of the share scope.
|
|
359
|
+
* If the share scope does not exist, it creates one.
|
|
360
|
+
*/
|
|
361
|
+
initializeSharing(shareScopeName?: string, extraOptions?: {
|
|
362
|
+
initScope?: InitScope;
|
|
363
|
+
from?: CallFrom;
|
|
364
|
+
strategy?: ShareStrategy;
|
|
365
|
+
}): Array<Promise<void>>;
|
|
366
|
+
loadShareSync<T>(pkgName: string, extraOptions?: {
|
|
367
|
+
from?: 'build' | 'runtime';
|
|
368
|
+
customShareInfo?: Partial<Shared>;
|
|
369
|
+
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
370
|
+
}): () => T | never;
|
|
371
|
+
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
|
|
372
|
+
hostShareScopeMap?: ShareScopeMap;
|
|
373
|
+
}): void;
|
|
374
|
+
private setShared;
|
|
375
|
+
private _setGlobalShareScopeMap;
|
|
376
|
+
} //#endregion
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region ../runtime-core/dist/type/plugin.d.ts
|
|
379
|
+
//#region src/type/plugin.d.ts
|
|
380
|
+
type CoreLifeCycle = ModuleFederation['hooks']['lifecycle'];
|
|
381
|
+
type CoreLifeCyclePartial = Partial<{ [k in keyof CoreLifeCycle]: Parameters<CoreLifeCycle[k]['on']>[0] }>;
|
|
382
|
+
type SnapshotLifeCycle = SnapshotHandler['hooks']['lifecycle'];
|
|
383
|
+
type SnapshotLifeCycleCyclePartial = Partial<{ [k in keyof SnapshotLifeCycle]: Parameters<SnapshotLifeCycle[k]['on']>[0] }>;
|
|
384
|
+
type ModuleLifeCycle = Module$1['host']['loaderHook']['lifecycle'];
|
|
385
|
+
type ModuleLifeCycleCyclePartial = Partial<{ [k in keyof ModuleLifeCycle]: Parameters<ModuleLifeCycle[k]['on']>[0] }>;
|
|
386
|
+
type ModuleBridgeLifeCycle = Module$1['host']['bridgeHook']['lifecycle'];
|
|
387
|
+
type ModuleBridgeLifeCycleCyclePartial = Partial<{ [k in keyof ModuleBridgeLifeCycle]: Parameters<ModuleBridgeLifeCycle[k]['on']>[0] }>;
|
|
388
|
+
type SharedLifeCycle = SharedHandler['hooks']['lifecycle'];
|
|
389
|
+
type SharedLifeCycleCyclePartial = Partial<{ [k in keyof SharedLifeCycle]: Parameters<SharedLifeCycle[k]['on']>[0] }>;
|
|
390
|
+
type RemoteLifeCycle = RemoteHandler['hooks']['lifecycle'];
|
|
391
|
+
type RemoteLifeCycleCyclePartial = Partial<{ [k in keyof RemoteLifeCycle]: Parameters<RemoteLifeCycle[k]['on']>[0] }>;
|
|
392
|
+
type ModuleFederationRuntimePlugin = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & ModuleBridgeLifeCycleCyclePartial & {
|
|
393
|
+
name: string;
|
|
394
|
+
version?: string;
|
|
395
|
+
apply?: (instance: ModuleFederation) => void;
|
|
396
|
+
}; //#endregion
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region ../runtime-core/dist/global.d.ts
|
|
399
|
+
//#region src/global.d.ts
|
|
400
|
+
interface Federation {
|
|
401
|
+
__GLOBAL_PLUGIN__: Array<ModuleFederationRuntimePlugin>;
|
|
402
|
+
__DEBUG_CONSTRUCTOR_VERSION__?: string;
|
|
403
|
+
moduleInfo: GlobalModuleInfo;
|
|
404
|
+
__DEBUG_CONSTRUCTOR__?: typeof ModuleFederation;
|
|
405
|
+
__INSTANCES__: Array<ModuleFederation>;
|
|
406
|
+
__SHARE__: GlobalShareScopeMap;
|
|
407
|
+
__MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;
|
|
408
|
+
__PRELOADED_MAP__: Map<string, boolean>;
|
|
409
|
+
}
|
|
410
|
+
declare global {
|
|
411
|
+
var __FEDERATION__: Federation, __VMOK__: Federation, __GLOBAL_LOADING_REMOTE_ENTRY__: Record<string, undefined | Promise<RemoteEntryExports | void>>;
|
|
412
|
+
}
|
|
413
|
+
declare const getGlobalSnapshot: () => GlobalModuleInfo;
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region ../runtime-core/dist/plugins/snapshot/SnapshotHandler.d.ts
|
|
416
|
+
//#region src/plugins/snapshot/SnapshotHandler.d.ts
|
|
417
|
+
declare class SnapshotHandler {
|
|
418
|
+
loadingHostSnapshot: Promise<GlobalModuleInfo | void> | null;
|
|
419
|
+
HostInstance: ModuleFederation;
|
|
420
|
+
manifestCache: Map<string, Manifest>;
|
|
421
|
+
hooks: PluginSystem<{
|
|
422
|
+
beforeLoadRemoteSnapshot: AsyncHook<[{
|
|
423
|
+
options: Options;
|
|
424
|
+
moduleInfo: Remote;
|
|
425
|
+
}], void>;
|
|
426
|
+
loadSnapshot: AsyncWaterfallHook<{
|
|
427
|
+
options: Options;
|
|
428
|
+
moduleInfo: Remote;
|
|
429
|
+
hostGlobalSnapshot: GlobalModuleInfo[string] | undefined;
|
|
430
|
+
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
|
|
431
|
+
remoteSnapshot?: GlobalModuleInfo[string] | undefined;
|
|
432
|
+
}>;
|
|
433
|
+
loadRemoteSnapshot: AsyncWaterfallHook<{
|
|
434
|
+
options: Options;
|
|
435
|
+
moduleInfo: Remote;
|
|
436
|
+
manifestJson?: Manifest;
|
|
437
|
+
manifestUrl?: string;
|
|
438
|
+
remoteSnapshot: ModuleInfo;
|
|
439
|
+
from: "global" | "manifest";
|
|
440
|
+
}>;
|
|
441
|
+
afterLoadSnapshot: AsyncWaterfallHook<{
|
|
442
|
+
id?: string;
|
|
443
|
+
host: ModuleFederation;
|
|
444
|
+
options: Options;
|
|
445
|
+
moduleInfo: Remote;
|
|
446
|
+
remoteSnapshot: ModuleInfo;
|
|
447
|
+
}>;
|
|
448
|
+
}>;
|
|
449
|
+
loaderHook: ModuleFederation['loaderHook'];
|
|
450
|
+
manifestLoading: Record<string, Promise<ModuleInfo>>;
|
|
451
|
+
constructor(HostInstance: ModuleFederation);
|
|
452
|
+
loadRemoteSnapshotInfo({
|
|
453
|
+
moduleInfo,
|
|
454
|
+
id,
|
|
455
|
+
expose
|
|
456
|
+
}: {
|
|
457
|
+
moduleInfo: Remote;
|
|
458
|
+
id?: string;
|
|
459
|
+
expose?: string;
|
|
460
|
+
}): Promise<{
|
|
461
|
+
remoteSnapshot: ModuleInfo;
|
|
462
|
+
globalSnapshot: GlobalModuleInfo;
|
|
463
|
+
}> | never;
|
|
464
|
+
getGlobalRemoteInfo(moduleInfo: Remote): {
|
|
465
|
+
hostGlobalSnapshot: ModuleInfo | undefined;
|
|
466
|
+
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
|
|
467
|
+
remoteSnapshot: GlobalModuleInfo[string] | undefined;
|
|
468
|
+
};
|
|
469
|
+
private getManifestJson;
|
|
470
|
+
} //#endregion
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region ../runtime-core/dist/utils/load.d.ts
|
|
473
|
+
//#region src/utils/load.d.ts
|
|
474
|
+
declare function getRemoteEntry(params: {
|
|
475
|
+
origin: ModuleFederation;
|
|
476
|
+
remoteInfo: RemoteInfo;
|
|
477
|
+
remoteEntryExports?: RemoteEntryExports | undefined;
|
|
478
|
+
getEntryUrl?: (url: string) => string;
|
|
479
|
+
_inErrorHandling?: boolean;
|
|
480
|
+
}): Promise<RemoteEntryExports | false | void>;
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region ../runtime-core/dist/core.d.ts
|
|
483
|
+
//#region src/core.d.ts
|
|
484
|
+
declare class ModuleFederation {
|
|
485
|
+
options: Options;
|
|
486
|
+
hooks: PluginSystem<{
|
|
487
|
+
beforeInit: SyncWaterfallHook<{
|
|
488
|
+
userOptions: UserOptions;
|
|
489
|
+
options: Options;
|
|
490
|
+
origin: ModuleFederation;
|
|
491
|
+
/**
|
|
492
|
+
* @deprecated shareInfo will be removed soon, please use userOptions directly!
|
|
493
|
+
*/
|
|
494
|
+
shareInfo: ShareInfos;
|
|
495
|
+
}>;
|
|
496
|
+
init: SyncHook<[{
|
|
497
|
+
options: Options;
|
|
498
|
+
origin: ModuleFederation;
|
|
499
|
+
}], void>;
|
|
500
|
+
beforeInitContainer: AsyncWaterfallHook<{
|
|
501
|
+
shareScope: ShareScopeMap[string];
|
|
502
|
+
initScope: InitScope;
|
|
503
|
+
remoteEntryInitOptions: RemoteEntryInitOptions;
|
|
504
|
+
remoteInfo: RemoteInfo;
|
|
505
|
+
origin: ModuleFederation;
|
|
506
|
+
}>;
|
|
507
|
+
initContainer: AsyncWaterfallHook<{
|
|
508
|
+
shareScope: ShareScopeMap[string];
|
|
509
|
+
initScope: InitScope;
|
|
510
|
+
remoteEntryInitOptions: RemoteEntryInitOptions;
|
|
511
|
+
remoteInfo: RemoteInfo;
|
|
512
|
+
remoteEntryExports: RemoteEntryExports;
|
|
513
|
+
origin: ModuleFederation;
|
|
514
|
+
id?: string;
|
|
515
|
+
remoteSnapshot?: ModuleInfo;
|
|
516
|
+
}>;
|
|
517
|
+
}>;
|
|
518
|
+
version: string;
|
|
519
|
+
name: string;
|
|
520
|
+
moduleCache: Map<string, Module$1>;
|
|
521
|
+
snapshotHandler: SnapshotHandler;
|
|
522
|
+
sharedHandler: SharedHandler;
|
|
523
|
+
remoteHandler: RemoteHandler;
|
|
524
|
+
shareScopeMap: ShareScopeMap;
|
|
525
|
+
loaderHook: PluginSystem<{
|
|
526
|
+
getModuleInfo: SyncHook<[{
|
|
527
|
+
target: Record<string, any>;
|
|
528
|
+
key: any;
|
|
529
|
+
}], void | {
|
|
530
|
+
value: any | undefined;
|
|
531
|
+
key: string;
|
|
532
|
+
}>;
|
|
533
|
+
createScript: SyncHook<[{
|
|
534
|
+
url: string;
|
|
535
|
+
attrs?: Record<string, any>;
|
|
536
|
+
}], CreateScriptHookReturn>;
|
|
537
|
+
createLink: SyncHook<[{
|
|
538
|
+
url: string;
|
|
539
|
+
attrs?: Record<string, any>;
|
|
540
|
+
}], void | HTMLLinkElement>;
|
|
541
|
+
fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
|
|
542
|
+
loadEntryError: AsyncHook<[{
|
|
543
|
+
getRemoteEntry: typeof getRemoteEntry;
|
|
544
|
+
origin: ModuleFederation;
|
|
545
|
+
remoteInfo: RemoteInfo;
|
|
546
|
+
remoteEntryExports?: RemoteEntryExports | undefined;
|
|
547
|
+
globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
|
|
548
|
+
uniqueKey: string;
|
|
549
|
+
}], Promise<Promise<RemoteEntryExports | undefined> | undefined>>;
|
|
550
|
+
getModuleFactory: AsyncHook<[{
|
|
551
|
+
remoteEntryExports: RemoteEntryExports;
|
|
552
|
+
expose: string;
|
|
553
|
+
moduleInfo: RemoteInfo;
|
|
554
|
+
}], Promise<(() => Promise<Module$1>) | undefined>>;
|
|
555
|
+
}>;
|
|
556
|
+
bridgeHook: PluginSystem<{
|
|
557
|
+
beforeBridgeRender: SyncHook<[Record<string, any>], void | Record<string, any>>;
|
|
558
|
+
afterBridgeRender: SyncHook<[Record<string, any>], void | Record<string, any>>;
|
|
559
|
+
beforeBridgeDestroy: SyncHook<[Record<string, any>], void | Record<string, any>>;
|
|
560
|
+
afterBridgeDestroy: SyncHook<[Record<string, any>], void | Record<string, any>>;
|
|
561
|
+
}>;
|
|
562
|
+
moduleInfo?: GlobalModuleInfo[string];
|
|
563
|
+
constructor(userOptions: UserOptions);
|
|
564
|
+
initOptions(userOptions: UserOptions): Options;
|
|
565
|
+
loadShare<T>(pkgName: string, extraOptions?: {
|
|
566
|
+
customShareInfo?: Partial<Shared>;
|
|
567
|
+
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
568
|
+
}): Promise<false | (() => T | undefined)>;
|
|
569
|
+
loadShareSync<T>(pkgName: string, extraOptions?: {
|
|
570
|
+
customShareInfo?: Partial<Shared>;
|
|
571
|
+
from?: 'build' | 'runtime';
|
|
572
|
+
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
573
|
+
}): () => T | never;
|
|
574
|
+
initializeSharing(shareScopeName?: string, extraOptions?: {
|
|
575
|
+
initScope?: InitScope;
|
|
576
|
+
from?: CallFrom;
|
|
577
|
+
strategy?: Shared['strategy'];
|
|
578
|
+
}): Array<Promise<void>>;
|
|
579
|
+
initRawContainer(name: string, url: string, container: RemoteEntryExports): Module$1;
|
|
580
|
+
loadRemote<T>(id: string, options?: {
|
|
581
|
+
loadFactory?: boolean;
|
|
582
|
+
from: CallFrom;
|
|
583
|
+
}): Promise<T | null>;
|
|
584
|
+
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
|
|
585
|
+
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
|
|
586
|
+
hostShareScopeMap?: ShareScopeMap;
|
|
587
|
+
}): void;
|
|
588
|
+
formatOptions(globalOptions: Options, userOptions: UserOptions): Options;
|
|
589
|
+
registerPlugins(plugins: UserOptions['plugins']): void;
|
|
590
|
+
registerRemotes(remotes: Remote[], options?: {
|
|
591
|
+
force?: boolean;
|
|
592
|
+
}): void;
|
|
593
|
+
registerShared(shared: UserOptions['shared']): void;
|
|
594
|
+
} //#endregion
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region ../runtime-core/dist/module/index.d.ts
|
|
597
|
+
//#region src/module/index.d.ts
|
|
598
|
+
type ModuleOptions = ConstructorParameters<typeof Module$1>[0];
|
|
599
|
+
declare class Module$1 {
|
|
600
|
+
remoteInfo: RemoteInfo;
|
|
601
|
+
inited: boolean;
|
|
602
|
+
initing: boolean;
|
|
603
|
+
initPromise?: Promise<void>;
|
|
604
|
+
remoteEntryExports?: RemoteEntryExports;
|
|
605
|
+
lib: RemoteEntryExports | undefined;
|
|
606
|
+
host: ModuleFederation;
|
|
607
|
+
constructor({
|
|
608
|
+
remoteInfo,
|
|
609
|
+
host
|
|
610
|
+
}: {
|
|
611
|
+
remoteInfo: RemoteInfo;
|
|
612
|
+
host: ModuleFederation;
|
|
613
|
+
});
|
|
614
|
+
getEntry(): Promise<RemoteEntryExports>;
|
|
615
|
+
init(id?: string, remoteSnapshot?: ModuleInfo, rawInitScope?: InitScope): Promise<RemoteEntryExports>;
|
|
616
|
+
get(id: string, expose: string, options?: {
|
|
617
|
+
loadFactory?: boolean;
|
|
618
|
+
}, remoteSnapshot?: ModuleInfo): Promise<any>;
|
|
619
|
+
private wraperFactory;
|
|
620
|
+
} //#endregion
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/types.d.ts
|
|
3
623
|
type CommonRetryOptions = {
|
|
4
624
|
/**
|
|
5
625
|
* retry request options
|
|
@@ -24,9 +644,10 @@ type CommonRetryOptions = {
|
|
|
24
644
|
/**
|
|
25
645
|
* add query parameter
|
|
26
646
|
*/
|
|
27
|
-
addQuery?:
|
|
28
|
-
|
|
29
|
-
|
|
647
|
+
addQuery?: boolean | ((context: {
|
|
648
|
+
times: number;
|
|
649
|
+
originalQuery: string;
|
|
650
|
+
}) => string);
|
|
30
651
|
/**
|
|
31
652
|
* retry domains
|
|
32
653
|
*/
|
|
@@ -41,7 +662,7 @@ type CommonRetryOptions = {
|
|
|
41
662
|
onRetry?: ({
|
|
42
663
|
times,
|
|
43
664
|
domains,
|
|
44
|
-
url
|
|
665
|
+
url
|
|
45
666
|
}: {
|
|
46
667
|
times?: number;
|
|
47
668
|
domains?: string[];
|
|
@@ -54,7 +675,7 @@ type CommonRetryOptions = {
|
|
|
54
675
|
onSuccess?: ({
|
|
55
676
|
domains,
|
|
56
677
|
url,
|
|
57
|
-
tagName
|
|
678
|
+
tagName
|
|
58
679
|
}: {
|
|
59
680
|
domains?: string[];
|
|
60
681
|
url?: string;
|
|
@@ -66,35 +687,34 @@ type CommonRetryOptions = {
|
|
|
66
687
|
onError?: ({
|
|
67
688
|
domains,
|
|
68
689
|
url,
|
|
69
|
-
tagName
|
|
690
|
+
tagName
|
|
70
691
|
}: {
|
|
71
692
|
domains?: string[];
|
|
72
693
|
url?: string;
|
|
73
694
|
tagName?: string;
|
|
74
695
|
}) => void;
|
|
75
696
|
};
|
|
76
|
-
|
|
77
697
|
type FetchRetryOptions = {
|
|
78
698
|
url?: string;
|
|
79
699
|
fetchOptions?: RequestInit;
|
|
80
700
|
} & CommonRetryOptions;
|
|
81
|
-
|
|
82
701
|
type ScriptRetryOptions = {
|
|
83
702
|
retryOptions: CommonRetryOptions;
|
|
84
703
|
retryFn: (...args: any[]) => Promise<any> | (() => Promise<any>);
|
|
85
704
|
beforeExecuteRetry?: (...args: any[]) => void;
|
|
86
705
|
};
|
|
87
|
-
|
|
706
|
+
//#endregion
|
|
707
|
+
//#region src/utils.d.ts
|
|
88
708
|
declare function rewriteWithNextDomain(currentUrl: string, domains?: string[]): string | null;
|
|
89
709
|
declare function appendRetryCountQuery(url: string, retryIndex: number, key?: string): string;
|
|
90
710
|
declare function getRetryUrl(baseUrl: string, opts?: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
711
|
+
domains?: string[];
|
|
712
|
+
addQuery?: boolean | ((context: {
|
|
713
|
+
times: number;
|
|
714
|
+
originalQuery: string;
|
|
715
|
+
}) => string);
|
|
716
|
+
retryIndex?: number;
|
|
717
|
+
queryKey?: string;
|
|
98
718
|
}): string;
|
|
99
719
|
/**
|
|
100
720
|
* Extract domain/host info from a URL and combine it with path/query from another URL
|
|
@@ -104,7 +724,8 @@ declare function getRetryUrl(baseUrl: string, opts?: {
|
|
|
104
724
|
* @returns Combined URL with domain from domainUrl and path/query from pathQueryUrl
|
|
105
725
|
*/
|
|
106
726
|
declare function combineUrlDomainWithPathQuery(domainUrl: string, pathQueryUrl: string): string;
|
|
107
|
-
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/index.d.ts
|
|
108
729
|
declare const RetryPlugin: (params?: CommonRetryOptions) => ModuleFederationRuntimePlugin;
|
|
109
|
-
|
|
110
|
-
export { type CommonRetryOptions, type FetchRetryOptions, RetryPlugin, type ScriptRetryOptions, appendRetryCountQuery, combineUrlDomainWithPathQuery, getRetryUrl, rewriteWithNextDomain };
|
|
730
|
+
//#endregion
|
|
731
|
+
export { type CommonRetryOptions, type FetchRetryOptions, RetryPlugin, type ScriptRetryOptions, appendRetryCountQuery, combineUrlDomainWithPathQuery, getRetryUrl, rewriteWithNextDomain };
|