@module-federation/runtime-core 0.0.0-next-20241115035905

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/LICENSE +21 -0
  4. package/dist/index.cjs.d.ts +1 -0
  5. package/dist/index.cjs.js +3010 -0
  6. package/dist/index.esm.d.ts +1 -0
  7. package/dist/index.esm.js +2980 -0
  8. package/dist/package.json +42 -0
  9. package/dist/polyfills.cjs.js +28 -0
  10. package/dist/polyfills.esm.js +25 -0
  11. package/dist/src/constant.d.ts +2 -0
  12. package/dist/src/core.d.ts +105 -0
  13. package/dist/src/global.d.ts +42 -0
  14. package/dist/src/helpers.d.ts +31 -0
  15. package/dist/src/index.d.ts +14 -0
  16. package/dist/src/module/index.d.ts +21 -0
  17. package/dist/src/plugins/generate-preload-assets.d.ts +8 -0
  18. package/dist/src/plugins/snapshot/SnapshotHandler.d.ts +58 -0
  19. package/dist/src/plugins/snapshot/index.d.ts +5 -0
  20. package/dist/src/remote/index.d.ts +109 -0
  21. package/dist/src/shared/index.d.ts +66 -0
  22. package/dist/src/type/config.d.ts +112 -0
  23. package/dist/src/type/index.d.ts +3 -0
  24. package/dist/src/type/plugin.d.ts +34 -0
  25. package/dist/src/type/preload.d.ts +26 -0
  26. package/dist/src/types.d.ts +1 -0
  27. package/dist/src/utils/env.d.ts +3 -0
  28. package/dist/src/utils/hooks/asyncHook.d.ts +6 -0
  29. package/dist/src/utils/hooks/asyncWaterfallHooks.d.ts +10 -0
  30. package/dist/src/utils/hooks/index.d.ts +6 -0
  31. package/dist/src/utils/hooks/pluginSystem.d.ts +15 -0
  32. package/dist/src/utils/hooks/syncHook.d.ts +12 -0
  33. package/dist/src/utils/hooks/syncWaterfallHook.d.ts +9 -0
  34. package/dist/src/utils/index.d.ts +6 -0
  35. package/dist/src/utils/load.d.ts +9 -0
  36. package/dist/src/utils/logger.d.ts +6 -0
  37. package/dist/src/utils/manifest.d.ts +7 -0
  38. package/dist/src/utils/plugin.d.ts +4 -0
  39. package/dist/src/utils/preload.d.ts +6 -0
  40. package/dist/src/utils/semver/compare.d.ts +9 -0
  41. package/dist/src/utils/semver/constants.d.ts +10 -0
  42. package/dist/src/utils/semver/index.d.ts +2 -0
  43. package/dist/src/utils/semver/parser.d.ts +9 -0
  44. package/dist/src/utils/semver/utils.d.ts +11 -0
  45. package/dist/src/utils/share.d.ts +27 -0
  46. package/dist/src/utils/tool.d.ts +18 -0
  47. package/dist/types.cjs.d.ts +1 -0
  48. package/dist/types.cjs.js +2 -0
  49. package/dist/types.esm.d.ts +1 -0
  50. package/dist/types.esm.js +1 -0
  51. package/package.json +42 -0
@@ -0,0 +1,112 @@
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 {};
@@ -0,0 +1,3 @@
1
+ export * from './config';
2
+ export * from './plugin';
3
+ export * from './preload';
@@ -0,0 +1,34 @@
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 {};
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1 @@
1
+ export * from './type';
@@ -0,0 +1,3 @@
1
+ export { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
2
+ export declare function isDevelopmentMode(): boolean;
3
+ export declare function getBuilderId(): string;
@@ -0,0 +1,6 @@
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 {};
@@ -0,0 +1,10 @@
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 {};
@@ -0,0 +1,6 @@
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';
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,12 @@
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
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ export * from './env';
2
+ export * from './tool';
3
+ export * from './manifest';
4
+ export * from './logger';
5
+ export * from './plugin';
6
+ export * from './load';
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,6 @@
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 };
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,9 @@
1
+ export interface CompareAtom {
2
+ operator: string;
3
+ version: string;
4
+ major: string;
5
+ minor: string;
6
+ patch: string;
7
+ preRelease?: string[];
8
+ }
9
+ export declare function compare(rangeAtom: CompareAtom, versionAtom: CompareAtom): boolean;
@@ -0,0 +1,10 @@
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*$";
@@ -0,0 +1,2 @@
1
+ export declare function satisfy(version: string, range: string): boolean;
2
+ export declare function isLegallyVersion(version: string): boolean;
@@ -0,0 +1,9 @@
1
+ export declare function parseHyphen(range: string): string;
2
+ export declare function parseComparatorTrim(range: string): string;
3
+ export declare function parseTildeTrim(range: string): string;
4
+ export declare function parseCaretTrim(range: string): string;
5
+ export declare function parseCarets(range: string): string;
6
+ export declare function parseTildes(range: string): string;
7
+ export declare function parseXRanges(range: string): string;
8
+ export declare function parseStar(range: string): string;
9
+ export declare function parseGTE0(comparatorString: string): string;
@@ -0,0 +1,11 @@
1
+ export declare function parseRegex(source: string): RegExp;
2
+ export declare function isXVersion(version: string): boolean;
3
+ export declare function pipe<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7): (...args: TArgs) => R7;
4
+ export declare function pipe<TArgs extends any[], R1, R2, R3, R4, R5, R6>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6): (...args: TArgs) => R6;
5
+ export declare function pipe<TArgs extends any[], R1, R2, R3, R4, R5>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5): (...args: TArgs) => R5;
6
+ export declare function pipe<TArgs extends any[], R1, R2, R3, R4>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4): (...args: TArgs) => R4;
7
+ export declare function pipe<TArgs extends any[], R1, R2, R3>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3): (...args: TArgs) => R3;
8
+ export declare function pipe<TArgs extends any[], R1, R2>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2): (...args: TArgs) => R2;
9
+ export declare function pipe<TArgs extends any[], R1>(f1: (...args: TArgs) => R1): (...args: TArgs) => R1;
10
+ export declare function extractComparator(comparatorString: string): RegExpMatchArray | null;
11
+ export declare function combineVersion(major: string, minor: string, patch: string, preRelease: string): string;
@@ -0,0 +1,27 @@
1
+ import { Federation } from '../global';
2
+ import { GlobalShareScopeMap, Shared, ShareArgs, ShareInfos, ShareScopeMap, LoadShareExtraOptions, UserOptions, Options, ShareStrategy } from '../type';
3
+ import { SyncWaterfallHook } from './hooks';
4
+ export declare function formatShare(shareArgs: ShareArgs, from: string, name: string, shareStrategy?: ShareStrategy): Shared;
5
+ export declare function formatShareConfigs(globalOptions: Options, userOptions: UserOptions): {
6
+ shared: {
7
+ [x: string]: Shared[];
8
+ };
9
+ shareInfos: ShareInfos;
10
+ };
11
+ export declare function versionLt(a: string, b: string): boolean;
12
+ export declare const findVersion: (shareVersionMap: ShareScopeMap[string][string], cb?: (prev: string, cur: string) => boolean) => string;
13
+ export declare const isLoaded: (shared: Shared) => boolean;
14
+ export declare function getRegisteredShare(localShareScopeMap: ShareScopeMap, pkgName: string, shareInfo: Shared, resolveShare: SyncWaterfallHook<{
15
+ shareScopeMap: ShareScopeMap;
16
+ scope: string;
17
+ pkgName: string;
18
+ version: string;
19
+ GlobalFederation: Federation;
20
+ resolver: () => Shared | undefined;
21
+ }>): Shared | void;
22
+ export declare function getGlobalShareScope(): GlobalShareScopeMap;
23
+ export declare function getTargetSharedOptions(options: {
24
+ pkgName: string;
25
+ extraOptions?: LoadShareExtraOptions;
26
+ shareInfos: ShareInfos;
27
+ }): Shared & Partial<Shared>;
@@ -0,0 +1,18 @@
1
+ import { RemoteWithEntry, ModuleInfo, RemoteEntryType } from '@module-federation/sdk';
2
+ import { Remote, RemoteInfoOptionalVersion } from '../type';
3
+ export declare function addUniqueItem(arr: Array<string>, item: string): Array<string>;
4
+ export declare function getFMId(remoteInfo: RemoteInfoOptionalVersion | RemoteWithEntry): string;
5
+ export declare function isRemoteInfoWithEntry(remote: Remote): remote is RemoteWithEntry;
6
+ export declare function isPureRemoteEntry(remote: RemoteWithEntry): boolean;
7
+ export declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
8
+ export declare function isObject(val: any): boolean;
9
+ export declare const objectToString: () => string;
10
+ export declare function isPlainObject(val: any): val is object;
11
+ export declare function isStaticResourcesEqual(url1: string, url2: string): boolean;
12
+ export declare function arrayOptions<T>(options: T | Array<T>): Array<T>;
13
+ export declare function getRemoteEntryInfoFromSnapshot(snapshot: ModuleInfo): {
14
+ url: string;
15
+ type: RemoteEntryType;
16
+ globalName: string;
17
+ };
18
+ export declare const processModuleAlias: (name: string, subPath: string) => string;
@@ -0,0 +1 @@
1
+ export * from "./src/types";
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1 @@
1
+ export * from "./src/types";
@@ -0,0 +1 @@
1
+
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@module-federation/runtime-core",
3
+ "version": "0.0.0-next-20241115035905",
4
+ "author": "zhouxiao <codingzx@gmail.com>",
5
+ "main": "./dist/index.cjs.js",
6
+ "module": "./dist/index.esm.js",
7
+ "types": "./dist/index.cjs.d.ts",
8
+ "license": "MIT",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "files": [
13
+ "dist/",
14
+ "README.md"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.cjs.d.ts",
19
+ "import": "./dist/index.esm.js",
20
+ "require": "./dist/index.cjs.js"
21
+ },
22
+ "./types": {
23
+ "types": "./dist/types.cjs.d.ts",
24
+ "import": "./dist/types.esm.js",
25
+ "require": "./dist/types.cjs.js"
26
+ }
27
+ },
28
+ "typesVersions": {
29
+ "*": {
30
+ ".": [
31
+ "./dist/index.cjs.d.ts"
32
+ ],
33
+ "types": [
34
+ "./dist/types.cjs.d.ts"
35
+ ]
36
+ }
37
+ },
38
+ "dependencies": {
39
+ "@module-federation/sdk": "0.0.0-next-20241115035905",
40
+ "@module-federation/error-codes": "0.0.0-next-20241115035905"
41
+ }
42
+ }