@module-federation/bridge-react 0.0.0-next-20250707074728 → 0.0.0-next-20250708033956
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/CHANGELOG.md +8 -4
- package/__tests__/bridge.spec.tsx +7 -7
- package/dist/{bridge-base-P6pEjY1q.js → bridge-base-BoshEggF.mjs} +1 -1
- package/dist/{bridge-base-BBH982Tz.cjs → bridge-base-UGCwcMnG.js} +1 -1
- package/dist/data-fetch-runtime-plugin.cjs.js +73 -0
- package/dist/data-fetch-runtime-plugin.d.ts +6 -0
- package/dist/data-fetch-runtime-plugin.es.js +74 -0
- package/dist/data-fetch-server-middleware.cjs.js +163 -0
- package/dist/data-fetch-server-middleware.d.ts +6 -0
- package/dist/data-fetch-server-middleware.es.js +164 -0
- package/dist/data-fetch-utils.cjs.js +1273 -0
- package/dist/data-fetch-utils.d.ts +77 -0
- package/dist/data-fetch-utils.es.js +1275 -0
- package/dist/index-C0fDZB5b.js +45 -0
- package/dist/index-CqxytsLY.mjs +46 -0
- package/dist/index.cjs.js +461 -9
- package/dist/index.d.ts +143 -0
- package/dist/index.es.js +464 -11
- package/dist/index.esm-BCeUd-x9.mjs +418 -0
- package/dist/index.esm-j_1sIRzg.js +417 -0
- package/dist/inject-data-fetch-CAvi-gSf.js +79 -0
- package/dist/inject-data-fetch-errCdqBS.mjs +80 -0
- package/dist/lazy-utils.cjs.js +24 -0
- package/dist/lazy-utils.d.ts +140 -0
- package/dist/lazy-utils.es.js +24 -0
- package/dist/plugin.d.ts +4 -4
- package/dist/router-v5.cjs.js +1 -1
- package/dist/router-v5.es.js +1 -1
- package/dist/router-v6.cjs.js +1 -1
- package/dist/router-v6.es.js +1 -1
- package/dist/router.cjs.js +1 -1
- package/dist/router.es.js +1 -1
- package/dist/utils-Bk8hGjjF.mjs +2016 -0
- package/dist/utils-iEVlDmyk.js +2015 -0
- package/dist/v18.cjs.js +1 -1
- package/dist/v18.es.js +1 -1
- package/dist/v19.cjs.js +1 -1
- package/dist/v19.es.js +1 -1
- package/package.json +45 -5
- package/src/index.ts +30 -1
- package/src/lazy/AwaitDataFetch.tsx +215 -0
- package/src/lazy/constant.ts +30 -0
- package/src/lazy/createLazyComponent.tsx +404 -0
- package/src/lazy/data-fetch/cache.ts +296 -0
- package/src/lazy/data-fetch/call-data-fetch.ts +13 -0
- package/src/lazy/data-fetch/data-fetch-server-middleware.ts +196 -0
- package/src/lazy/data-fetch/index.ts +15 -0
- package/src/lazy/data-fetch/inject-data-fetch.ts +109 -0
- package/src/lazy/data-fetch/prefetch.ts +102 -0
- package/src/lazy/data-fetch/runtime-plugin.ts +116 -0
- package/src/lazy/index.ts +31 -0
- package/src/lazy/logger.ts +6 -0
- package/src/lazy/types.ts +75 -0
- package/src/lazy/utils.ts +372 -0
- package/src/lazy/wrapNoSSR.tsx +10 -0
- package/src/provider/plugin.ts +4 -4
- package/src/remote/component.tsx +3 -3
- package/src/remote/create.tsx +17 -4
- package/tsconfig.json +1 -1
- package/vite.config.ts +13 -0
- package/dist/index-Cv3p6r66.cjs +0 -235
- package/dist/index-D4yt7Udv.js +0 -236
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,98 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
|
+
import { FederationRuntimePlugin } from '@module-federation/runtime';
|
|
3
|
+
import { getInstance } from '@module-federation/runtime';
|
|
4
|
+
import { JSX as JSX_2 } from 'react';
|
|
5
|
+
import { Key } from 'react';
|
|
2
6
|
import * as React_2 from 'react';
|
|
7
|
+
import { ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
export declare const autoFetchDataPlugin: () => FederationRuntimePlugin;
|
|
10
|
+
|
|
11
|
+
export declare function cache<T>(fn: DataFetch<T>, options?: CacheOptions): DataFetch<T>;
|
|
12
|
+
|
|
13
|
+
declare interface CacheConfig {
|
|
14
|
+
maxSize?: number;
|
|
15
|
+
unstable_shouldDisable?: ({ request, }: {
|
|
16
|
+
request: Request;
|
|
17
|
+
}) => boolean | Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare interface CacheOptions {
|
|
21
|
+
tag?: string | string[];
|
|
22
|
+
maxAge?: number;
|
|
23
|
+
revalidate?: number;
|
|
24
|
+
getKey?: <Args extends any[]>(...args: Args) => string;
|
|
25
|
+
customKey?: <Args extends any[]>(options: {
|
|
26
|
+
params: Args;
|
|
27
|
+
fn: (...args: Args) => any;
|
|
28
|
+
generatedKey: string;
|
|
29
|
+
}) => string | symbol;
|
|
30
|
+
onCache?: (info: CacheStatsInfo) => boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export declare const CacheSize: {
|
|
34
|
+
readonly KB: 1024;
|
|
35
|
+
readonly MB: number;
|
|
36
|
+
readonly GB: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export declare interface CacheStatsInfo {
|
|
40
|
+
status: CacheStatus;
|
|
41
|
+
key: string | symbol;
|
|
42
|
+
params: DataFetchParams;
|
|
43
|
+
result: any;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare type CacheStatus = 'hit' | 'stale' | 'miss';
|
|
47
|
+
|
|
48
|
+
export declare const CacheTime: {
|
|
49
|
+
readonly SECOND: 1000;
|
|
50
|
+
readonly MINUTE: number;
|
|
51
|
+
readonly HOUR: number;
|
|
52
|
+
readonly DAY: number;
|
|
53
|
+
readonly WEEK: number;
|
|
54
|
+
readonly MONTH: number;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export declare function callDataFetch(): Promise<void>;
|
|
58
|
+
|
|
59
|
+
export declare function clearStore(): void;
|
|
60
|
+
|
|
61
|
+
export declare function collectSSRAssets(options: CollectSSRAssetsOptions): default_2.ReactNode[];
|
|
62
|
+
|
|
63
|
+
export declare type CollectSSRAssetsOptions = {
|
|
64
|
+
id: string;
|
|
65
|
+
instance: ReturnType<typeof getInstance>;
|
|
66
|
+
injectScript?: boolean;
|
|
67
|
+
injectLink?: boolean;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export declare function configureCache(config: CacheConfig): void;
|
|
3
71
|
|
|
4
72
|
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
5
73
|
render(info: RenderParams): Promise<void>;
|
|
6
74
|
destroy(info: DestroyParams): void;
|
|
7
75
|
};
|
|
8
76
|
|
|
77
|
+
export declare function createLazyComponent<T, E extends keyof T>(options: CreateLazyComponentOptions<T, E>): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? ReactKey : Parameters<T[E]>[0] & ReactKey : ReactKey) => default_2.JSX.Element;
|
|
78
|
+
|
|
79
|
+
export declare type CreateLazyComponentOptions<T, E extends keyof T> = {
|
|
80
|
+
loader: () => Promise<T>;
|
|
81
|
+
instance: ReturnType<typeof getInstance>;
|
|
82
|
+
loading: default_2.ReactNode;
|
|
83
|
+
delayLoading?: number;
|
|
84
|
+
fallback: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
|
|
85
|
+
export?: E;
|
|
86
|
+
dataFetchParams?: DataFetchParams;
|
|
87
|
+
noSSR?: boolean;
|
|
88
|
+
cacheData?: boolean;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export declare function createRemoteAppComponent<T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>): default_2.ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & default_2.RefAttributes<HTMLDivElement>>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!
|
|
95
|
+
*/
|
|
9
96
|
export declare function createRemoteComponent<T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>): default_2.ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & default_2.RefAttributes<HTMLDivElement>>;
|
|
10
97
|
|
|
11
98
|
export declare interface CreateRootOptions {
|
|
@@ -22,6 +109,13 @@ declare interface CreateRootOptions_2 {
|
|
|
22
109
|
transitionCallbacks?: unknown;
|
|
23
110
|
}
|
|
24
111
|
|
|
112
|
+
declare type DataFetch<T> = (params: DataFetchParams) => Promise<T>;
|
|
113
|
+
|
|
114
|
+
export declare type DataFetchParams = {
|
|
115
|
+
isDowngrade: boolean;
|
|
116
|
+
_id?: string;
|
|
117
|
+
} & Record<string, unknown>;
|
|
118
|
+
|
|
25
119
|
/**
|
|
26
120
|
* Parameters for the destroy function
|
|
27
121
|
*/
|
|
@@ -30,8 +124,39 @@ export declare interface DestroyParams {
|
|
|
30
124
|
dom: HTMLElement;
|
|
31
125
|
}
|
|
32
126
|
|
|
127
|
+
export declare const ERROR_TYPE: {
|
|
128
|
+
DATA_FETCH: number;
|
|
129
|
+
LOAD_REMOTE: number;
|
|
130
|
+
UNKNOWN: number;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
declare type ErrorInfo = {
|
|
134
|
+
error: Error;
|
|
135
|
+
errorType: number;
|
|
136
|
+
dataFetchMapKey?: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export declare function generateKey(dataFetchOptions: DataFetchParams): string;
|
|
140
|
+
|
|
33
141
|
declare type LazyRemoteComponentInfo<T, E extends keyof T> = RemoteComponentParams<T>;
|
|
34
142
|
|
|
143
|
+
export declare type NoSSRRemoteInfo = {
|
|
144
|
+
name: string;
|
|
145
|
+
version: string;
|
|
146
|
+
ssrPublicPath: string;
|
|
147
|
+
ssrRemoteEntry: string;
|
|
148
|
+
globalName: string;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export declare function prefetch(options: PrefetchOptions): Promise<void>;
|
|
152
|
+
|
|
153
|
+
declare type PrefetchOptions = {
|
|
154
|
+
id: string;
|
|
155
|
+
instance: ReturnType<typeof getInstance>;
|
|
156
|
+
dataFetchParams?: DataFetchParams;
|
|
157
|
+
preloadComponentResource?: boolean;
|
|
158
|
+
};
|
|
159
|
+
|
|
35
160
|
/**
|
|
36
161
|
* Parameters for the provider function
|
|
37
162
|
*/
|
|
@@ -65,6 +190,10 @@ export declare interface ProviderParams {
|
|
|
65
190
|
className?: string;
|
|
66
191
|
}
|
|
67
192
|
|
|
193
|
+
declare type ReactKey = {
|
|
194
|
+
key?: default_2.Key | null;
|
|
195
|
+
};
|
|
196
|
+
|
|
68
197
|
/**
|
|
69
198
|
* Parameters for the remote component loader
|
|
70
199
|
*/
|
|
@@ -113,6 +242,8 @@ export declare interface RenderParams {
|
|
|
113
242
|
[key: string]: unknown;
|
|
114
243
|
}
|
|
115
244
|
|
|
245
|
+
export declare function revalidateTag(tag: string): void;
|
|
246
|
+
|
|
116
247
|
export declare interface Root {
|
|
117
248
|
render(children: React.ReactNode): void;
|
|
118
249
|
unmount(): void;
|
|
@@ -131,4 +262,16 @@ declare interface Root_2 {
|
|
|
131
262
|
*/
|
|
132
263
|
export declare type RootType = HTMLElement | Root_2;
|
|
133
264
|
|
|
265
|
+
export declare function setSSREnv({ fetchServerQuery, }: {
|
|
266
|
+
fetchServerQuery?: Record<string, unknown>;
|
|
267
|
+
}): void;
|
|
268
|
+
|
|
269
|
+
export declare function wrapNoSSR<T, E extends keyof T>(createLazyComponentFn: typeof createLazyComponent<T, E>): (options: Omit<CreateLazyComponentOptions<T, E>, "noSSR">) => (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? {
|
|
270
|
+
key?: Key | null;
|
|
271
|
+
} : Parameters<T[E]>[0] & {
|
|
272
|
+
key?: Key | null;
|
|
273
|
+
} : {
|
|
274
|
+
key?: Key | null;
|
|
275
|
+
}) => JSX_2.Element;
|
|
276
|
+
|
|
134
277
|
export { }
|