@module-federation/runtime 0.8.5 → 0.8.7
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/core.cjs.d.ts +2 -0
- package/dist/core.cjs.js +15 -0
- package/dist/core.esm.d.ts +2 -0
- package/dist/core.esm.mjs +3 -0
- package/dist/helpers.cjs.js +7 -27
- package/dist/helpers.esm.mjs +7 -27
- package/dist/index.cjs.js +34 -2086
- package/dist/index.esm.mjs +4 -2072
- package/dist/polyfills.cjs.js +0 -14
- package/dist/polyfills.esm.mjs +1 -14
- package/dist/src/core.d.ts +3 -114
- package/dist/src/embedded.d.ts +49 -49
- package/dist/src/helpers.d.ts +23 -29
- package/dist/src/index.d.ts +3 -9
- package/dist/src/types.d.ts +1 -1
- package/dist/src/utils.d.ts +3 -0
- package/dist/types.cjs.js +10 -0
- package/dist/types.esm.mjs +1 -1
- package/dist/utils.cjs.js +26 -0
- package/dist/utils.esm.mjs +24 -0
- package/package.json +12 -3
- package/dist/share.cjs.js +0 -937
- package/dist/share.esm.mjs +0 -896
- package/dist/src/constant.d.ts +0 -2
- package/dist/src/global.d.ts +0 -43
- package/dist/src/module/index.d.ts +0 -21
- package/dist/src/plugins/generate-preload-assets.d.ts +0 -8
- package/dist/src/plugins/snapshot/SnapshotHandler.d.ts +0 -58
- package/dist/src/plugins/snapshot/index.d.ts +0 -5
- package/dist/src/remote/index.d.ts +0 -109
- package/dist/src/shared/index.d.ts +0 -66
- package/dist/src/type/config.d.ts +0 -112
- package/dist/src/type/index.d.ts +0 -3
- package/dist/src/type/plugin.d.ts +0 -34
- package/dist/src/type/preload.d.ts +0 -26
- package/dist/src/utils/env.d.ts +0 -3
- package/dist/src/utils/hooks/asyncHook.d.ts +0 -6
- package/dist/src/utils/hooks/asyncWaterfallHooks.d.ts +0 -10
- package/dist/src/utils/hooks/index.d.ts +0 -6
- package/dist/src/utils/hooks/pluginSystem.d.ts +0 -15
- package/dist/src/utils/hooks/syncHook.d.ts +0 -12
- package/dist/src/utils/hooks/syncWaterfallHook.d.ts +0 -9
- package/dist/src/utils/index.d.ts +0 -6
- package/dist/src/utils/load.d.ts +0 -9
- package/dist/src/utils/logger.d.ts +0 -6
- package/dist/src/utils/manifest.d.ts +0 -7
- package/dist/src/utils/plugin.d.ts +0 -4
- package/dist/src/utils/preload.d.ts +0 -6
- package/dist/src/utils/semver/compare.d.ts +0 -9
- package/dist/src/utils/semver/constants.d.ts +0 -10
- package/dist/src/utils/semver/index.d.ts +0 -2
- package/dist/src/utils/semver/parser.d.ts +0 -9
- package/dist/src/utils/semver/utils.d.ts +0 -11
- package/dist/src/utils/share.d.ts +0 -27
- package/dist/src/utils/tool.d.ts +0 -18
package/dist/src/constant.d.ts
DELETED
package/dist/src/global.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { FederationHost } from './core';
|
|
2
|
-
import { RemoteEntryExports, GlobalShareScopeMap, Remote, Optional } from './type';
|
|
3
|
-
import { GlobalModuleInfo, ModuleInfo } from '@module-federation/sdk';
|
|
4
|
-
import { FederationRuntimePlugin } from './type/plugin';
|
|
5
|
-
export interface Federation {
|
|
6
|
-
__GLOBAL_PLUGIN__: Array<FederationRuntimePlugin>;
|
|
7
|
-
__DEBUG_CONSTRUCTOR_VERSION__?: string;
|
|
8
|
-
moduleInfo: GlobalModuleInfo;
|
|
9
|
-
__DEBUG_CONSTRUCTOR__?: typeof FederationHost;
|
|
10
|
-
__INSTANCES__: Array<FederationHost>;
|
|
11
|
-
__SHARE__: GlobalShareScopeMap;
|
|
12
|
-
__MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;
|
|
13
|
-
__PRELOADED_MAP__: Map<string, boolean>;
|
|
14
|
-
}
|
|
15
|
-
export declare const CurrentGlobal: typeof globalThis;
|
|
16
|
-
export declare const nativeGlobal: typeof global;
|
|
17
|
-
export declare const Global: typeof globalThis;
|
|
18
|
-
declare global {
|
|
19
|
-
var __FEDERATION__: Federation, __VMOK__: Federation, __GLOBAL_LOADING_REMOTE_ENTRY__: Record<string, undefined | Promise<RemoteEntryExports | void>>;
|
|
20
|
-
}
|
|
21
|
-
export declare const globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
|
|
22
|
-
export declare function resetFederationGlobalInfo(): void;
|
|
23
|
-
export declare function getGlobalFederationInstance(name: string, version: string | undefined): FederationHost | undefined;
|
|
24
|
-
export declare function setGlobalFederationInstance(FederationInstance: FederationHost): void;
|
|
25
|
-
export declare function getGlobalFederationConstructor(): typeof FederationHost | undefined;
|
|
26
|
-
export declare function setGlobalFederationConstructor(FederationConstructor: typeof FederationHost | undefined, isDebug?: boolean): void;
|
|
27
|
-
export declare function getInfoWithoutType<T extends object>(target: T, key: keyof T): {
|
|
28
|
-
value: T[keyof T] | undefined;
|
|
29
|
-
key: string;
|
|
30
|
-
};
|
|
31
|
-
export declare const getGlobalSnapshot: () => GlobalModuleInfo;
|
|
32
|
-
export declare const getTargetSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, "alias">, snapshot: GlobalModuleInfo) => GlobalModuleInfo[string] | undefined;
|
|
33
|
-
export declare const getGlobalSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, "alias">) => GlobalModuleInfo[string] | undefined;
|
|
34
|
-
export declare const setGlobalSnapshotInfoByModuleInfo: (remoteInfo: Remote, moduleDetailInfo: GlobalModuleInfo[string]) => GlobalModuleInfo;
|
|
35
|
-
export declare const addGlobalSnapshot: (moduleInfos: GlobalModuleInfo) => (() => void);
|
|
36
|
-
export declare const getRemoteEntryExports: (name: string, globalName: string | undefined) => {
|
|
37
|
-
remoteEntryKey: string;
|
|
38
|
-
entryExports: RemoteEntryExports | undefined;
|
|
39
|
-
};
|
|
40
|
-
export declare const registerGlobalPlugins: (plugins: Array<FederationRuntimePlugin>) => void;
|
|
41
|
-
export declare const getGlobalHostPlugins: () => Array<FederationRuntimePlugin>;
|
|
42
|
-
export declare const getPreloaded: (id: string) => boolean | undefined;
|
|
43
|
-
export declare const setPreloaded: (id: string) => Map<string, boolean>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { FederationHost } from '../core';
|
|
3
|
-
import { RemoteEntryExports, RemoteInfo } from '../type';
|
|
4
|
-
export type ModuleOptions = ConstructorParameters<typeof Module>[0];
|
|
5
|
-
declare class Module {
|
|
6
|
-
remoteInfo: RemoteInfo;
|
|
7
|
-
inited: boolean;
|
|
8
|
-
remoteEntryExports?: RemoteEntryExports;
|
|
9
|
-
lib: RemoteEntryExports | undefined;
|
|
10
|
-
host: FederationHost;
|
|
11
|
-
constructor({ remoteInfo, host, }: {
|
|
12
|
-
remoteInfo: RemoteInfo;
|
|
13
|
-
host: FederationHost;
|
|
14
|
-
});
|
|
15
|
-
getEntry(): Promise<RemoteEntryExports>;
|
|
16
|
-
get(id: string, expose: string, options?: {
|
|
17
|
-
loadFactory?: boolean;
|
|
18
|
-
}, remoteSnapshot?: ModuleInfo): Promise<any>;
|
|
19
|
-
private wraperFactory;
|
|
20
|
-
}
|
|
21
|
-
export { Module };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { GlobalModuleInfo, ModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { FederationRuntimePlugin, PreloadAssets, PreloadOptions, RemoteInfoOptionalVersion } from '../type';
|
|
3
|
-
import { FederationHost } from '../core';
|
|
4
|
-
declare global {
|
|
5
|
-
var __INIT_VMOK_DEPLOY_GLOBAL_DATA__: boolean | undefined;
|
|
6
|
-
}
|
|
7
|
-
export declare function generatePreloadAssets(origin: FederationHost, preloadOptions: PreloadOptions[number], remote: RemoteInfoOptionalVersion, globalSnapshot: GlobalModuleInfo, remoteSnapshot: ModuleInfo): PreloadAssets;
|
|
8
|
-
export declare const generatePreloadAssetsPlugin: () => FederationRuntimePlugin;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { GlobalModuleInfo, Manifest, ModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { Options, Remote } from '../../type';
|
|
3
|
-
import { getGlobalSnapshot } from '../../global';
|
|
4
|
-
import { PluginSystem, AsyncHook, AsyncWaterfallHook } from '../../utils/hooks';
|
|
5
|
-
import { FederationHost } from '../../core';
|
|
6
|
-
export declare function getGlobalRemoteInfo(moduleInfo: Remote, origin: FederationHost): {
|
|
7
|
-
hostGlobalSnapshot: ModuleInfo | undefined;
|
|
8
|
-
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
|
|
9
|
-
remoteSnapshot: GlobalModuleInfo[string] | undefined;
|
|
10
|
-
};
|
|
11
|
-
export declare class SnapshotHandler {
|
|
12
|
-
loadingHostSnapshot: Promise<GlobalModuleInfo | void> | null;
|
|
13
|
-
HostInstance: FederationHost;
|
|
14
|
-
manifestCache: Map<string, Manifest>;
|
|
15
|
-
hooks: PluginSystem<{
|
|
16
|
-
beforeLoadRemoteSnapshot: AsyncHook<[{
|
|
17
|
-
options: Options;
|
|
18
|
-
moduleInfo: Remote;
|
|
19
|
-
}], void>;
|
|
20
|
-
loadSnapshot: AsyncWaterfallHook<{
|
|
21
|
-
options: Options;
|
|
22
|
-
moduleInfo: Remote;
|
|
23
|
-
hostGlobalSnapshot: GlobalModuleInfo[string] | undefined;
|
|
24
|
-
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
|
|
25
|
-
remoteSnapshot?: GlobalModuleInfo[string] | undefined;
|
|
26
|
-
}>;
|
|
27
|
-
loadRemoteSnapshot: AsyncWaterfallHook<{
|
|
28
|
-
options: Options;
|
|
29
|
-
moduleInfo: Remote;
|
|
30
|
-
manifestJson?: Manifest;
|
|
31
|
-
manifestUrl?: string;
|
|
32
|
-
remoteSnapshot: ModuleInfo;
|
|
33
|
-
from: "global" | "manifest";
|
|
34
|
-
}>;
|
|
35
|
-
afterLoadSnapshot: AsyncWaterfallHook<{
|
|
36
|
-
options: Options;
|
|
37
|
-
moduleInfo: Remote;
|
|
38
|
-
remoteSnapshot: ModuleInfo;
|
|
39
|
-
}>;
|
|
40
|
-
}>;
|
|
41
|
-
loaderHook: FederationHost['loaderHook'];
|
|
42
|
-
manifestLoading: Record<string, Promise<ModuleInfo>>;
|
|
43
|
-
constructor(HostInstance: FederationHost);
|
|
44
|
-
loadSnapshot(moduleInfo: Remote): Promise<{
|
|
45
|
-
remoteSnapshot: GlobalModuleInfo[string] | undefined;
|
|
46
|
-
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
|
|
47
|
-
}>;
|
|
48
|
-
loadRemoteSnapshotInfo(moduleInfo: Remote): Promise<{
|
|
49
|
-
remoteSnapshot: ModuleInfo;
|
|
50
|
-
globalSnapshot: GlobalModuleInfo;
|
|
51
|
-
}> | never;
|
|
52
|
-
getGlobalRemoteInfo(moduleInfo: Remote): {
|
|
53
|
-
hostGlobalSnapshot: ModuleInfo | undefined;
|
|
54
|
-
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
|
|
55
|
-
remoteSnapshot: GlobalModuleInfo[string] | undefined;
|
|
56
|
-
};
|
|
57
|
-
private getManifestJson;
|
|
58
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { FederationRuntimePlugin } from '../../type/plugin';
|
|
3
|
-
import { RemoteInfo } from '../../type';
|
|
4
|
-
export declare function assignRemoteInfo(remoteInfo: RemoteInfo, remoteSnapshot: ModuleInfo): void;
|
|
5
|
-
export declare function snapshotPlugin(): FederationRuntimePlugin;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, RemoteEntryExports, CallFrom } from '../type';
|
|
3
|
-
import { FederationHost } from '../core';
|
|
4
|
-
import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncHook, SyncWaterfallHook } from '../utils/hooks';
|
|
5
|
-
import { Module, ModuleOptions } from '../module';
|
|
6
|
-
export interface LoadRemoteMatch {
|
|
7
|
-
id: string;
|
|
8
|
-
pkgNameOrAlias: string;
|
|
9
|
-
expose: string;
|
|
10
|
-
remote: Remote;
|
|
11
|
-
options: Options;
|
|
12
|
-
origin: FederationHost;
|
|
13
|
-
remoteInfo: RemoteInfo;
|
|
14
|
-
remoteSnapshot?: ModuleInfo;
|
|
15
|
-
}
|
|
16
|
-
export declare class RemoteHandler {
|
|
17
|
-
host: FederationHost;
|
|
18
|
-
idToRemoteMap: Record<string, {
|
|
19
|
-
name: string;
|
|
20
|
-
expose: string;
|
|
21
|
-
}>;
|
|
22
|
-
hooks: PluginSystem<{
|
|
23
|
-
beforeRegisterRemote: SyncWaterfallHook<{
|
|
24
|
-
remote: Remote;
|
|
25
|
-
origin: FederationHost;
|
|
26
|
-
}>;
|
|
27
|
-
registerRemote: SyncWaterfallHook<{
|
|
28
|
-
remote: Remote;
|
|
29
|
-
origin: FederationHost;
|
|
30
|
-
}>;
|
|
31
|
-
beforeRequest: AsyncWaterfallHook<{
|
|
32
|
-
id: string;
|
|
33
|
-
options: Options;
|
|
34
|
-
origin: FederationHost;
|
|
35
|
-
}>;
|
|
36
|
-
onLoad: AsyncHook<[{
|
|
37
|
-
id: string;
|
|
38
|
-
expose: string;
|
|
39
|
-
pkgNameOrAlias: string;
|
|
40
|
-
remote: Remote;
|
|
41
|
-
options: ModuleOptions;
|
|
42
|
-
origin: FederationHost;
|
|
43
|
-
exposeModule: any;
|
|
44
|
-
exposeModuleFactory: any;
|
|
45
|
-
moduleInstance: Module;
|
|
46
|
-
}], void>;
|
|
47
|
-
handlePreloadModule: SyncHook<[{
|
|
48
|
-
id: string;
|
|
49
|
-
name: string;
|
|
50
|
-
remote: Remote;
|
|
51
|
-
remoteSnapshot: ModuleInfo;
|
|
52
|
-
preloadConfig: PreloadRemoteArgs;
|
|
53
|
-
origin: FederationHost;
|
|
54
|
-
}], void>;
|
|
55
|
-
errorLoadRemote: AsyncHook<[{
|
|
56
|
-
id: string;
|
|
57
|
-
error: unknown;
|
|
58
|
-
options?: any;
|
|
59
|
-
from: CallFrom;
|
|
60
|
-
lifecycle: "onLoad" | "beforeRequest" | "beforeLoadShare";
|
|
61
|
-
origin: FederationHost;
|
|
62
|
-
}], unknown>;
|
|
63
|
-
beforePreloadRemote: AsyncHook<[{
|
|
64
|
-
preloadOps: Array<PreloadRemoteArgs>;
|
|
65
|
-
options: Options;
|
|
66
|
-
origin: FederationHost;
|
|
67
|
-
}], false | void | Promise<false | void>>;
|
|
68
|
-
generatePreloadAssets: AsyncHook<[{
|
|
69
|
-
origin: FederationHost;
|
|
70
|
-
preloadOptions: PreloadOptions[number];
|
|
71
|
-
remote: Remote;
|
|
72
|
-
remoteInfo: RemoteInfo;
|
|
73
|
-
remoteSnapshot: ModuleInfo;
|
|
74
|
-
globalSnapshot: GlobalModuleInfo;
|
|
75
|
-
}], Promise<PreloadAssets>>;
|
|
76
|
-
afterPreloadRemote: AsyncHook<{
|
|
77
|
-
preloadOps: Array<PreloadRemoteArgs>;
|
|
78
|
-
options: Options;
|
|
79
|
-
origin: FederationHost;
|
|
80
|
-
}, false | void | Promise<false | void>>;
|
|
81
|
-
loadEntry: AsyncHook<[{
|
|
82
|
-
loaderHook: FederationHost["loaderHook"];
|
|
83
|
-
remoteInfo: RemoteInfo;
|
|
84
|
-
remoteEntryExports?: RemoteEntryExports;
|
|
85
|
-
}], Promise<RemoteEntryExports>>;
|
|
86
|
-
}>;
|
|
87
|
-
constructor(host: FederationHost);
|
|
88
|
-
formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions): Remote[];
|
|
89
|
-
setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch): void;
|
|
90
|
-
loadRemote<T>(id: string, options?: {
|
|
91
|
-
loadFactory?: boolean;
|
|
92
|
-
from: CallFrom;
|
|
93
|
-
}): Promise<T | null>;
|
|
94
|
-
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
|
|
95
|
-
registerRemotes(remotes: Remote[], options?: {
|
|
96
|
-
force?: boolean;
|
|
97
|
-
}): void;
|
|
98
|
-
getRemoteModuleAndOptions(options: {
|
|
99
|
-
id: string;
|
|
100
|
-
}): Promise<{
|
|
101
|
-
module: Module;
|
|
102
|
-
moduleOptions: ModuleOptions;
|
|
103
|
-
remoteMatchInfo: LoadRemoteMatch;
|
|
104
|
-
}>;
|
|
105
|
-
registerRemote(remote: Remote, targetRemotes: Remote[], options?: {
|
|
106
|
-
force?: boolean;
|
|
107
|
-
}): void;
|
|
108
|
-
private removeRemote;
|
|
109
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Federation } from '../global';
|
|
2
|
-
import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions, ShareStrategy, InitScope, InitTokens, CallFrom } from '../type';
|
|
3
|
-
import { FederationHost } from '../core';
|
|
4
|
-
import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncWaterfallHook } from '../utils/hooks';
|
|
5
|
-
import { LoadRemoteMatch } from '../remote';
|
|
6
|
-
export declare class SharedHandler {
|
|
7
|
-
host: FederationHost;
|
|
8
|
-
shareScopeMap: ShareScopeMap;
|
|
9
|
-
hooks: PluginSystem<{
|
|
10
|
-
afterResolve: AsyncWaterfallHook<LoadRemoteMatch>;
|
|
11
|
-
beforeLoadShare: AsyncWaterfallHook<{
|
|
12
|
-
pkgName: string;
|
|
13
|
-
shareInfo?: Shared;
|
|
14
|
-
shared: Options["shared"];
|
|
15
|
-
origin: FederationHost;
|
|
16
|
-
}>;
|
|
17
|
-
loadShare: AsyncHook<[FederationHost, string, ShareInfos], false | void | Promise<false | void>>;
|
|
18
|
-
resolveShare: SyncWaterfallHook<{
|
|
19
|
-
shareScopeMap: ShareScopeMap;
|
|
20
|
-
scope: string;
|
|
21
|
-
pkgName: string;
|
|
22
|
-
version: string;
|
|
23
|
-
GlobalFederation: Federation;
|
|
24
|
-
resolver: () => Shared | undefined;
|
|
25
|
-
}>;
|
|
26
|
-
initContainerShareScopeMap: SyncWaterfallHook<{
|
|
27
|
-
shareScope: ShareScopeMap[string];
|
|
28
|
-
options: Options;
|
|
29
|
-
origin: FederationHost;
|
|
30
|
-
scopeName: string;
|
|
31
|
-
hostShareScopeMap?: ShareScopeMap;
|
|
32
|
-
}>;
|
|
33
|
-
}>;
|
|
34
|
-
initTokens: InitTokens;
|
|
35
|
-
constructor(host: FederationHost);
|
|
36
|
-
registerShared(globalOptions: Options, userOptions: UserOptions): {
|
|
37
|
-
shareInfos: ShareInfos;
|
|
38
|
-
shared: {
|
|
39
|
-
[x: string]: Shared[];
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
loadShare<T>(pkgName: string, extraOptions?: {
|
|
43
|
-
customShareInfo?: Partial<Shared>;
|
|
44
|
-
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
45
|
-
}): Promise<false | (() => T | undefined)>;
|
|
46
|
-
/**
|
|
47
|
-
* This function initializes the sharing sequence (executed only once per share scope).
|
|
48
|
-
* It accepts one argument, the name of the share scope.
|
|
49
|
-
* If the share scope does not exist, it creates one.
|
|
50
|
-
*/
|
|
51
|
-
initializeSharing(shareScopeName?: string, extraOptions?: {
|
|
52
|
-
initScope?: InitScope;
|
|
53
|
-
from?: CallFrom;
|
|
54
|
-
strategy?: ShareStrategy;
|
|
55
|
-
}): Array<Promise<void>>;
|
|
56
|
-
loadShareSync<T>(pkgName: string, extraOptions?: {
|
|
57
|
-
from?: 'build' | 'runtime';
|
|
58
|
-
customShareInfo?: Partial<Shared>;
|
|
59
|
-
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
60
|
-
}): () => T | never;
|
|
61
|
-
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
|
|
62
|
-
hostShareScopeMap?: ShareScopeMap;
|
|
63
|
-
}): void;
|
|
64
|
-
private setShared;
|
|
65
|
-
private _setGlobalShareScopeMap;
|
|
66
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { RemoteWithEntry, RemoteWithVersion, Module, RemoteEntryType } from '@module-federation/sdk';
|
|
2
|
-
import { FederationRuntimePlugin } from './plugin';
|
|
3
|
-
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
|
|
4
|
-
export type PartialOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
5
|
-
[P in K]-?: T[P];
|
|
6
|
-
};
|
|
7
|
-
export interface RemoteInfoCommon {
|
|
8
|
-
alias?: string;
|
|
9
|
-
shareScope?: string;
|
|
10
|
-
type?: RemoteEntryType;
|
|
11
|
-
entryGlobalName?: string;
|
|
12
|
-
}
|
|
13
|
-
export type RemoteInfoOptionalVersion = {
|
|
14
|
-
name: string;
|
|
15
|
-
version?: string;
|
|
16
|
-
} & RemoteInfoCommon;
|
|
17
|
-
export type Remote = (RemoteWithEntry | RemoteWithVersion) & RemoteInfoCommon;
|
|
18
|
-
export type LoadShareExtraOptions = {
|
|
19
|
-
customShareInfo?: Partial<Shared>;
|
|
20
|
-
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
21
|
-
};
|
|
22
|
-
export interface RemoteInfo {
|
|
23
|
-
name: string;
|
|
24
|
-
version?: string;
|
|
25
|
-
buildVersion?: string;
|
|
26
|
-
entry: string;
|
|
27
|
-
type: RemoteEntryType;
|
|
28
|
-
entryGlobalName: string;
|
|
29
|
-
shareScope: string;
|
|
30
|
-
}
|
|
31
|
-
export type HostInfo = Pick<Options, 'name' | 'version' | 'remotes' | 'version'>;
|
|
32
|
-
export interface SharedConfig {
|
|
33
|
-
singleton?: boolean;
|
|
34
|
-
requiredVersion: false | string;
|
|
35
|
-
eager?: boolean;
|
|
36
|
-
strictVersion?: boolean;
|
|
37
|
-
}
|
|
38
|
-
type SharedBaseArgs = {
|
|
39
|
-
version?: string;
|
|
40
|
-
shareConfig?: SharedConfig;
|
|
41
|
-
scope?: string | Array<string>;
|
|
42
|
-
deps?: Array<string>;
|
|
43
|
-
strategy?: 'version-first' | 'loaded-first';
|
|
44
|
-
loaded?: boolean;
|
|
45
|
-
};
|
|
46
|
-
export type SharedGetter = (() => () => Module) | (() => Promise<() => Module>);
|
|
47
|
-
export type ShareArgs = (SharedBaseArgs & {
|
|
48
|
-
get: SharedGetter;
|
|
49
|
-
}) | (SharedBaseArgs & {
|
|
50
|
-
lib: () => Module;
|
|
51
|
-
}) | SharedBaseArgs;
|
|
52
|
-
export type ShareStrategy = 'version-first' | 'loaded-first';
|
|
53
|
-
export type Shared = {
|
|
54
|
-
version: string;
|
|
55
|
-
get: SharedGetter;
|
|
56
|
-
shareConfig: SharedConfig;
|
|
57
|
-
scope: Array<string>;
|
|
58
|
-
useIn: Array<string>;
|
|
59
|
-
from: string;
|
|
60
|
-
deps: Array<string>;
|
|
61
|
-
lib?: () => Module;
|
|
62
|
-
loaded?: boolean;
|
|
63
|
-
loading?: null | Promise<any>;
|
|
64
|
-
eager?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated set in initOptions.shareStrategy instead
|
|
67
|
-
*/
|
|
68
|
-
strategy: ShareStrategy;
|
|
69
|
-
};
|
|
70
|
-
export type ShareScopeMap = {
|
|
71
|
-
[scope: string]: {
|
|
72
|
-
[pkgName: string]: {
|
|
73
|
-
[sharedVersion: string]: Shared;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
export type GlobalShareScopeMap = {
|
|
78
|
-
[instanceName: string]: ShareScopeMap;
|
|
79
|
-
};
|
|
80
|
-
export type ShareInfos = {
|
|
81
|
-
[pkgName: string]: Shared[];
|
|
82
|
-
};
|
|
83
|
-
export interface Options {
|
|
84
|
-
id?: string;
|
|
85
|
-
name: string;
|
|
86
|
-
version?: string;
|
|
87
|
-
remotes: Array<Remote>;
|
|
88
|
-
shared: ShareInfos;
|
|
89
|
-
plugins: Array<FederationRuntimePlugin>;
|
|
90
|
-
inBrowser: boolean;
|
|
91
|
-
shareStrategy?: ShareStrategy;
|
|
92
|
-
}
|
|
93
|
-
export type UserOptions = Omit<Optional<Options, 'plugins'>, 'shared' | 'inBrowser'> & {
|
|
94
|
-
shared?: {
|
|
95
|
-
[pkgName: string]: ShareArgs | ShareArgs[];
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
export type LoadModuleOptions = {
|
|
99
|
-
version?: string;
|
|
100
|
-
};
|
|
101
|
-
export type RemoteEntryInitOptions = {
|
|
102
|
-
version: string;
|
|
103
|
-
shareScopeMap: ShareScopeMap;
|
|
104
|
-
};
|
|
105
|
-
export type InitTokens = Record<string, Record<string, any>>;
|
|
106
|
-
export type InitScope = InitTokens[];
|
|
107
|
-
export type CallFrom = 'build' | 'runtime';
|
|
108
|
-
export type RemoteEntryExports = {
|
|
109
|
-
get: (id: string) => () => Promise<Module>;
|
|
110
|
-
init: (shareScope: ShareScopeMap[string], initScope?: InitScope, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void | Promise<void>;
|
|
111
|
-
};
|
|
112
|
-
export {};
|
package/dist/src/type/index.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { FederationHost } from '../core';
|
|
2
|
-
import { Module } from '../module';
|
|
3
|
-
import { SnapshotHandler } from '../plugins/snapshot/SnapshotHandler';
|
|
4
|
-
import { SharedHandler } from '../shared';
|
|
5
|
-
import { RemoteHandler } from '../remote';
|
|
6
|
-
type CoreLifeCycle = FederationHost['hooks']['lifecycle'];
|
|
7
|
-
type CoreLifeCyclePartial = Partial<{
|
|
8
|
-
[k in keyof CoreLifeCycle]: Parameters<CoreLifeCycle[k]['on']>[0];
|
|
9
|
-
}>;
|
|
10
|
-
type SnapshotLifeCycle = SnapshotHandler['hooks']['lifecycle'];
|
|
11
|
-
type SnapshotLifeCycleCyclePartial = Partial<{
|
|
12
|
-
[k in keyof SnapshotLifeCycle]: Parameters<SnapshotLifeCycle[k]['on']>[0];
|
|
13
|
-
}>;
|
|
14
|
-
type ModuleLifeCycle = Module['host']['loaderHook']['lifecycle'];
|
|
15
|
-
type ModuleLifeCycleCyclePartial = Partial<{
|
|
16
|
-
[k in keyof ModuleLifeCycle]: Parameters<ModuleLifeCycle[k]['on']>[0];
|
|
17
|
-
}>;
|
|
18
|
-
type ModuleBridgeLifeCycle = Module['host']['bridgeHook']['lifecycle'];
|
|
19
|
-
type ModuleBridgeLifeCycleCyclePartial = Partial<{
|
|
20
|
-
[k in keyof ModuleBridgeLifeCycle]: Parameters<ModuleBridgeLifeCycle[k]['on']>[0];
|
|
21
|
-
}>;
|
|
22
|
-
type SharedLifeCycle = SharedHandler['hooks']['lifecycle'];
|
|
23
|
-
type SharedLifeCycleCyclePartial = Partial<{
|
|
24
|
-
[k in keyof SharedLifeCycle]: Parameters<SharedLifeCycle[k]['on']>[0];
|
|
25
|
-
}>;
|
|
26
|
-
type RemoteLifeCycle = RemoteHandler['hooks']['lifecycle'];
|
|
27
|
-
type RemoteLifeCycleCyclePartial = Partial<{
|
|
28
|
-
[k in keyof RemoteLifeCycle]: Parameters<RemoteLifeCycle[k]['on']>[0];
|
|
29
|
-
}>;
|
|
30
|
-
export type FederationRuntimePlugin = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & ModuleBridgeLifeCycleCyclePartial & {
|
|
31
|
-
name: string;
|
|
32
|
-
version?: string;
|
|
33
|
-
};
|
|
34
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Remote, RemoteInfo } from './config';
|
|
2
|
-
export type depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;
|
|
3
|
-
export interface PreloadRemoteArgs {
|
|
4
|
-
nameOrAlias: string;
|
|
5
|
-
exposes?: Array<string>;
|
|
6
|
-
resourceCategory?: 'all' | 'sync';
|
|
7
|
-
share?: boolean;
|
|
8
|
-
depsRemote?: boolean | Array<depsPreloadArg>;
|
|
9
|
-
filter?: (assetUrl: string) => boolean;
|
|
10
|
-
prefetchInterface?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export type PreloadConfig = PreloadRemoteArgs;
|
|
13
|
-
export type PreloadOptions = Array<{
|
|
14
|
-
remote: Remote;
|
|
15
|
-
preloadConfig: PreloadConfig;
|
|
16
|
-
}>;
|
|
17
|
-
export type EntryAssets = {
|
|
18
|
-
name: string;
|
|
19
|
-
url: string;
|
|
20
|
-
moduleInfo: RemoteInfo;
|
|
21
|
-
};
|
|
22
|
-
export interface PreloadAssets {
|
|
23
|
-
cssAssets: Array<string>;
|
|
24
|
-
jsAssetsWithoutEntry: Array<string>;
|
|
25
|
-
entryAssets: Array<EntryAssets>;
|
|
26
|
-
}
|
package/dist/src/utils/env.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ArgsType, SyncHook } from './syncHook';
|
|
2
|
-
type CallbackReturnType = void | false | Promise<void | false>;
|
|
3
|
-
export declare class AsyncHook<T, ExternalEmitReturnType = CallbackReturnType> extends SyncHook<T, ExternalEmitReturnType> {
|
|
4
|
-
emit(...data: ArgsType<T>): Promise<void | false | ExternalEmitReturnType>;
|
|
5
|
-
}
|
|
6
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SyncHook } from './syncHook';
|
|
2
|
-
type CallbackReturnType<T> = T | Promise<T>;
|
|
3
|
-
export declare class AsyncWaterfallHook<T extends Record<string, any>> extends SyncHook<[
|
|
4
|
-
T
|
|
5
|
-
], CallbackReturnType<T>> {
|
|
6
|
-
onerror: (errMsg: string | Error | unknown) => void;
|
|
7
|
-
constructor(type: string);
|
|
8
|
-
emit(data: T): Promise<T>;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { SyncHook } from './syncHook';
|
|
2
|
-
export { AsyncHook } from './asyncHook';
|
|
3
|
-
export { SyncWaterfallHook } from './syncWaterfallHook';
|
|
4
|
-
export { AsyncWaterfallHook } from './asyncWaterfallHooks';
|
|
5
|
-
export { PluginSystem } from './pluginSystem';
|
|
6
|
-
export type { Plugin } from './pluginSystem';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type Plugin<T extends Record<string, any>> = {
|
|
2
|
-
[k in keyof T]?: Parameters<T[k]['on']>[0];
|
|
3
|
-
} & {
|
|
4
|
-
name: string;
|
|
5
|
-
version?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare class PluginSystem<T extends Record<string, any>> {
|
|
8
|
-
lifecycle: T;
|
|
9
|
-
lifecycleKeys: Array<keyof T>;
|
|
10
|
-
registerPlugins: Record<string, Plugin<T>>;
|
|
11
|
-
constructor(lifecycle: T);
|
|
12
|
-
applyPlugin(plugin: Plugin<T>): void;
|
|
13
|
-
removePlugin(pluginName: string): void;
|
|
14
|
-
inherit<T extends PluginSystem<any>>({ lifecycle, registerPlugins, }: T): void;
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type Callback<T, K> = (...args: ArgsType<T>) => K;
|
|
2
|
-
export type ArgsType<T> = T extends Array<any> ? T : Array<any>;
|
|
3
|
-
export declare class SyncHook<T, K> {
|
|
4
|
-
type: string;
|
|
5
|
-
listeners: Set<Callback<T, K>>;
|
|
6
|
-
constructor(type?: string);
|
|
7
|
-
on(fn: Callback<T, K>): void;
|
|
8
|
-
once(fn: Callback<T, K>): void;
|
|
9
|
-
emit(...data: ArgsType<T>): void | K | Promise<any>;
|
|
10
|
-
remove(fn: Callback<T, K>): void;
|
|
11
|
-
removeAll(): void;
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SyncHook } from './syncHook';
|
|
2
|
-
export declare function checkReturnData(originalData: any, returnedData: any): boolean;
|
|
3
|
-
export declare class SyncWaterfallHook<T extends Record<string, any>> extends SyncHook<[
|
|
4
|
-
T
|
|
5
|
-
], T> {
|
|
6
|
-
onerror: (errMsg: string | Error | unknown) => void;
|
|
7
|
-
constructor(type: string);
|
|
8
|
-
emit(data: T): T;
|
|
9
|
-
}
|
package/dist/src/utils/load.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FederationHost } from '../core';
|
|
2
|
-
import { Remote, RemoteEntryExports, RemoteInfo } from '../type';
|
|
3
|
-
export declare function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string;
|
|
4
|
-
export declare function getRemoteEntry({ origin, remoteEntryExports, remoteInfo, }: {
|
|
5
|
-
origin: FederationHost;
|
|
6
|
-
remoteInfo: RemoteInfo;
|
|
7
|
-
remoteEntryExports?: RemoteEntryExports | undefined;
|
|
8
|
-
}): Promise<RemoteEntryExports | false | void>;
|
|
9
|
-
export declare function getRemoteInfo(remote: Remote): RemoteInfo;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
declare const logger: import("@module-federation/sdk").Logger;
|
|
2
|
-
export declare function assert(condition: any, msg: string): asserts condition;
|
|
3
|
-
export declare function error(msg: string | Error | unknown): never;
|
|
4
|
-
export declare function warn(msg: Parameters<typeof console.warn>[0]): void;
|
|
5
|
-
export declare function log(...args: unknown[]): void;
|
|
6
|
-
export { logger };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Remote } from '../type';
|
|
2
|
-
export declare function matchRemoteWithNameAndExpose(remotes: Array<Remote>, id: string): {
|
|
3
|
-
pkgNameOrAlias: string;
|
|
4
|
-
expose: string;
|
|
5
|
-
remote: Remote;
|
|
6
|
-
} | undefined;
|
|
7
|
-
export declare function matchRemote(remotes: Array<Remote>, nameOrAlias: string): Remote | undefined;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { FederationHost } from '../core';
|
|
2
|
-
import { UserOptions } from '../type';
|
|
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'] | Module['host']['bridgeHook']>): import("../type").FederationRuntimePlugin[] | undefined;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PreloadAssets, PreloadConfig, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, depsPreloadArg } from '../type';
|
|
2
|
-
import { FederationHost } from '../core';
|
|
3
|
-
export declare function defaultPreloadArgs(preloadConfig: PreloadRemoteArgs | depsPreloadArg): PreloadConfig;
|
|
4
|
-
export declare function formatPreloadArgs(remotes: Array<Remote>, preloadArgs: Array<PreloadRemoteArgs>): PreloadOptions;
|
|
5
|
-
export declare function normalizePreloadExposes(exposes?: string[]): string[];
|
|
6
|
-
export declare function preloadAssets(remoteInfo: RemoteInfo, host: FederationHost, assets: PreloadAssets, useLinkPreload?: boolean): void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const hyphenRange = "^\\s*([v=\\s]*(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*))*)))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?)?)?)\\s+-\\s+([v=\\s]*(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*))*)))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?)?)?)\\s*$";
|
|
2
|
-
export declare const comparatorTrim = "(\\s*)((?:<|>)?=?)\\s*([v=\\s]*([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-?((?:[0-9]+|\\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\\.(?:[0-9]+|\\d*[a-zA-Z-][a-zA-Z0-9-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?|[v=\\s]*(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*))*)))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?)?)?)";
|
|
3
|
-
export declare const tildeTrim = "(\\s*)(?:~>?)\\s+";
|
|
4
|
-
export declare const caretTrim = "(\\s*)(?:\\^)\\s+";
|
|
5
|
-
export declare const star = "(<|>)?=?\\s*\\*";
|
|
6
|
-
export declare const caret = "^(?:\\^)[v=\\s]*(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*))*)))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?)?)?$";
|
|
7
|
-
export declare const tilde = "^(?:~>?)[v=\\s]*(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*))*)))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?)?)?$";
|
|
8
|
-
export declare const xRange = "^((?:<|>)?=?)\\s*[v=\\s]*(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:\\.(0|[1-9]\\d*|x|X|\\*)(?:(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*))*)))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?)?)?$";
|
|
9
|
-
export declare const comparator = "^((?:<|>)?=?)\\s*(v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][a-zA-Z0-9-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?)$|^$";
|
|
10
|
-
export declare const gte0 = "^\\s*>=\\s*0.0.0\\s*$";
|