@module-federation/bridge-react 0.0.0-feat-support-bridge-react-router-v7-20251015102312

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 (100) hide show
  1. package/CHANGELOG.md +670 -0
  2. package/LICENSE +21 -0
  3. package/README.md +131 -0
  4. package/__tests__/bridge.spec.tsx +160 -0
  5. package/__tests__/createLazyComponent.spec.tsx +209 -0
  6. package/__tests__/prefetch.spec.ts +156 -0
  7. package/__tests__/router.spec.tsx +82 -0
  8. package/__tests__/setupTests.ts +8 -0
  9. package/__tests__/util.ts +36 -0
  10. package/dist/bridge-base-29j7dZKh.mjs +201 -0
  11. package/dist/bridge-base-CTNdBioh.js +216 -0
  12. package/dist/data-fetch-server-middleware.cjs.js +163 -0
  13. package/dist/data-fetch-server-middleware.d.ts +15 -0
  14. package/dist/data-fetch-server-middleware.es.js +164 -0
  15. package/dist/data-fetch-utils.cjs.js +24 -0
  16. package/dist/data-fetch-utils.d.ts +81 -0
  17. package/dist/data-fetch-utils.es.js +26 -0
  18. package/dist/index-Dm-M9ouh.mjs +46 -0
  19. package/dist/index-DqCpgmgH.js +45 -0
  20. package/dist/index.cjs.js +293 -0
  21. package/dist/index.d.ts +274 -0
  22. package/dist/index.es.js +276 -0
  23. package/dist/index.esm-CzoIcLts.js +459 -0
  24. package/dist/index.esm-JLwyxgUK.mjs +460 -0
  25. package/dist/lazy-load-component-plugin-B4fdMQTL.js +521 -0
  26. package/dist/lazy-load-component-plugin-ijw36GA0.mjs +522 -0
  27. package/dist/lazy-load-component-plugin.cjs.js +6 -0
  28. package/dist/lazy-load-component-plugin.d.ts +16 -0
  29. package/dist/lazy-load-component-plugin.es.js +6 -0
  30. package/dist/lazy-utils.cjs.js +24 -0
  31. package/dist/lazy-utils.d.ts +149 -0
  32. package/dist/lazy-utils.es.js +24 -0
  33. package/dist/plugin.cjs.js +14 -0
  34. package/dist/plugin.d.ts +22 -0
  35. package/dist/plugin.es.js +14 -0
  36. package/dist/prefetch-Bgm31z9s.js +1272 -0
  37. package/dist/prefetch-DjeoxOeZ.mjs +1273 -0
  38. package/dist/router-v5.cjs.js +55 -0
  39. package/dist/router-v5.d.ts +18 -0
  40. package/dist/router-v5.es.js +32 -0
  41. package/dist/router-v6.cjs.js +84 -0
  42. package/dist/router-v6.d.ts +20 -0
  43. package/dist/router-v6.es.js +61 -0
  44. package/dist/router-v7.cjs.js +83 -0
  45. package/dist/router-v7.d.ts +20 -0
  46. package/dist/router-v7.es.js +61 -0
  47. package/dist/router.cjs.js +82 -0
  48. package/dist/router.d.ts +20 -0
  49. package/dist/router.es.js +60 -0
  50. package/dist/utils-0HFFqmd4.js +2015 -0
  51. package/dist/utils-BTpxHmva.mjs +2016 -0
  52. package/dist/v18.cjs.js +15 -0
  53. package/dist/v18.d.ts +114 -0
  54. package/dist/v18.es.js +15 -0
  55. package/dist/v19.cjs.js +15 -0
  56. package/dist/v19.d.ts +115 -0
  57. package/dist/v19.es.js +15 -0
  58. package/jest.config.ts +21 -0
  59. package/package.json +144 -0
  60. package/project.json +23 -0
  61. package/src/index.ts +45 -0
  62. package/src/lazy/AwaitDataFetch.tsx +215 -0
  63. package/src/lazy/constant.ts +30 -0
  64. package/src/lazy/createLazyComponent.tsx +411 -0
  65. package/src/lazy/data-fetch/cache.ts +291 -0
  66. package/src/lazy/data-fetch/call-data-fetch.ts +13 -0
  67. package/src/lazy/data-fetch/data-fetch-server-middleware.ts +196 -0
  68. package/src/lazy/data-fetch/index.ts +16 -0
  69. package/src/lazy/data-fetch/inject-data-fetch.ts +109 -0
  70. package/src/lazy/data-fetch/prefetch.ts +112 -0
  71. package/src/lazy/data-fetch/runtime-plugin.ts +115 -0
  72. package/src/lazy/index.ts +35 -0
  73. package/src/lazy/logger.ts +6 -0
  74. package/src/lazy/types.ts +75 -0
  75. package/src/lazy/utils.ts +372 -0
  76. package/src/lazy/wrapNoSSR.tsx +10 -0
  77. package/src/modern-app-env.d.ts +2 -0
  78. package/src/plugins/lazy-load-component-plugin.spec.ts +21 -0
  79. package/src/plugins/lazy-load-component-plugin.ts +57 -0
  80. package/src/provider/context.tsx +4 -0
  81. package/src/provider/plugin.ts +22 -0
  82. package/src/provider/versions/bridge-base.tsx +127 -0
  83. package/src/provider/versions/legacy.ts +87 -0
  84. package/src/provider/versions/v18.ts +47 -0
  85. package/src/provider/versions/v19.ts +48 -0
  86. package/src/remote/component.tsx +211 -0
  87. package/src/remote/create.tsx +103 -0
  88. package/src/router/default.tsx +73 -0
  89. package/src/router/v5.tsx +43 -0
  90. package/src/router/v6.tsx +74 -0
  91. package/src/router/v7.tsx +75 -0
  92. package/src/types.ts +147 -0
  93. package/src/utils/index.ts +44 -0
  94. package/src/v18.ts +9 -0
  95. package/src/v19.ts +9 -0
  96. package/tsconfig.json +42 -0
  97. package/tsconfig.node.json +11 -0
  98. package/tsconfig.spec.json +26 -0
  99. package/vite.config.ts +106 -0
  100. package/vitest.config.ts +27 -0
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const bridgeBase = require("./bridge-base-CTNdBioh.js");
4
+ const ReactDOM = require("react-dom");
5
+ const index = require("./index-DqCpgmgH.js");
6
+ const React = require("react");
7
+ const ReactRouterDOM = require("react-router-dom");
8
+ const plugin = require("./plugin.cjs.js");
9
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-B4fdMQTL.js");
10
+ const lazyUtils = require("./utils-0HFFqmd4.js");
11
+ const dataFetchUtils = require("./data-fetch-utils.cjs.js");
12
+ const prefetch = require("./prefetch-Bgm31z9s.js");
13
+ function _interopNamespaceDefault(e2) {
14
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
15
+ if (e2) {
16
+ for (const k in e2) {
17
+ if (k !== "default") {
18
+ const d = Object.getOwnPropertyDescriptor(e2, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: () => e2[k]
22
+ });
23
+ }
24
+ }
25
+ }
26
+ n.default = e2;
27
+ return Object.freeze(n);
28
+ }
29
+ const ReactRouterDOM__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDOM);
30
+ function createReact16Or17Root(container) {
31
+ return {
32
+ render(children) {
33
+ const reactVersion = ReactDOM.version || "";
34
+ const isReact18 = reactVersion.startsWith("18");
35
+ const isReact19 = reactVersion.startsWith("19");
36
+ if (isReact19) {
37
+ throw new Error(
38
+ `React 19 detected in legacy mode. This is not supported. Please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v19'`
39
+ );
40
+ }
41
+ if (isReact18) {
42
+ index.LoggerInstance.warn(
43
+ `[Bridge-React] React 18 detected in legacy mode. For better compatibility, please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v18'`
44
+ );
45
+ }
46
+ ReactDOM.render(children, container);
47
+ },
48
+ unmount() {
49
+ ReactDOM.unmountComponentAtNode(container);
50
+ }
51
+ };
52
+ }
53
+ function createBridgeComponent(bridgeInfo) {
54
+ const fullBridgeInfo = {
55
+ createRoot: createReact16Or17Root,
56
+ ...bridgeInfo
57
+ };
58
+ return bridgeBase.createBaseBridgeComponent(fullBridgeInfo);
59
+ }
60
+ function e() {
61
+ const t = new PopStateEvent("popstate", { state: window.history.state });
62
+ window.dispatchEvent(t);
63
+ }
64
+ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
65
+ const {
66
+ moduleName,
67
+ memoryRoute,
68
+ basename,
69
+ providerInfo,
70
+ className,
71
+ style,
72
+ fallback,
73
+ loading,
74
+ ...resProps
75
+ } = props;
76
+ const instance = plugin.federationRuntime.instance;
77
+ const rootRef = ref && "current" in ref ? ref : React.useRef(null);
78
+ const renderDom = React.useRef(null);
79
+ const providerInfoRef = React.useRef(null);
80
+ const [initialized, setInitialized] = React.useState(false);
81
+ index.LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);
82
+ React.useEffect(() => {
83
+ if (initialized) return;
84
+ const providerReturn = providerInfo();
85
+ providerInfoRef.current = providerReturn;
86
+ setInitialized(true);
87
+ return () => {
88
+ var _a, _b, _c, _d, _e, _f, _g, _h;
89
+ if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
90
+ index.LoggerInstance.debug(
91
+ `createRemoteAppComponent LazyComponent destroy >>>`,
92
+ { moduleName, basename, dom: renderDom.current }
93
+ );
94
+ (_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
95
+ moduleName,
96
+ dom: renderDom.current,
97
+ basename,
98
+ memoryRoute,
99
+ fallback,
100
+ ...resProps
101
+ });
102
+ (_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
103
+ moduleName,
104
+ dom: renderDom.current
105
+ });
106
+ (_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
107
+ moduleName,
108
+ dom: renderDom.current,
109
+ basename,
110
+ memoryRoute,
111
+ fallback,
112
+ ...resProps
113
+ });
114
+ }
115
+ };
116
+ }, [moduleName]);
117
+ React.useEffect(() => {
118
+ var _a, _b, _c, _d, _e, _f;
119
+ if (!initialized || !providerInfoRef.current) return;
120
+ let renderProps = {
121
+ moduleName,
122
+ dom: rootRef.current,
123
+ basename,
124
+ memoryRoute,
125
+ fallback,
126
+ ...resProps
127
+ };
128
+ renderDom.current = rootRef.current;
129
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
130
+ renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
131
+ providerInfoRef.current.render(renderProps);
132
+ (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps);
133
+ }, [initialized, ...Object.values(props)]);
134
+ const rootComponentClassName = `${index.getRootDomDefaultClassName(moduleName)} ${className || ""}`;
135
+ return /* @__PURE__ */ React.createElement("div", { className: rootComponentClassName, style, ref: rootRef }, loading);
136
+ });
137
+ function withRouterData(WrappedComponent) {
138
+ const Component = React.forwardRef(function(props, ref) {
139
+ var _a;
140
+ if (props == null ? void 0 : props.basename) {
141
+ return /* @__PURE__ */ React.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
142
+ }
143
+ let enableDispathPopstate = false;
144
+ let routerContextVal;
145
+ try {
146
+ ReactRouterDOM__namespace.useLocation();
147
+ enableDispathPopstate = true;
148
+ } catch {
149
+ enableDispathPopstate = false;
150
+ }
151
+ let basename = "/";
152
+ if (!props.basename && enableDispathPopstate) {
153
+ const ReactRouterDOMAny = ReactRouterDOM__namespace;
154
+ const useRouteMatch = ReactRouterDOMAny["useRouteMatch"];
155
+ const useHistory = ReactRouterDOMAny["useHistory"];
156
+ const useHref = ReactRouterDOMAny["useHref"];
157
+ const UNSAFE_RouteContext = ReactRouterDOMAny["UNSAFE_RouteContext"];
158
+ if (UNSAFE_RouteContext) {
159
+ if (useHref) {
160
+ basename = useHref == null ? void 0 : useHref("/");
161
+ }
162
+ routerContextVal = React.useContext(UNSAFE_RouteContext);
163
+ if (routerContextVal && routerContextVal.matches && routerContextVal.matches.length > 0) {
164
+ const matchIndex = routerContextVal.matches.length - 1;
165
+ const pathnameBase = routerContextVal.matches[matchIndex].pathnameBase;
166
+ basename = index.pathJoin(basename, pathnameBase || "/");
167
+ }
168
+ } else {
169
+ const match = useRouteMatch == null ? void 0 : useRouteMatch();
170
+ if (useHistory) {
171
+ const history = useHistory == null ? void 0 : useHistory();
172
+ basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: "/" });
173
+ }
174
+ if (match) {
175
+ basename = index.pathJoin(basename, (match == null ? void 0 : match.path) || "/");
176
+ }
177
+ }
178
+ }
179
+ index.LoggerInstance.debug(`createRemoteAppComponent withRouterData >>>`, {
180
+ ...props,
181
+ basename,
182
+ routerContextVal,
183
+ enableDispathPopstate
184
+ });
185
+ if (enableDispathPopstate) {
186
+ const location = ReactRouterDOM__namespace.useLocation();
187
+ const [pathname, setPathname] = React.useState(location.pathname);
188
+ React.useEffect(() => {
189
+ if (pathname !== "" && pathname !== location.pathname) {
190
+ index.LoggerInstance.debug(
191
+ `createRemoteAppComponent dispatchPopstateEnv >>>`,
192
+ {
193
+ name: props.name,
194
+ pathname: location.pathname
195
+ }
196
+ );
197
+ e();
198
+ }
199
+ setPathname(location.pathname);
200
+ }, [location]);
201
+ }
202
+ return /* @__PURE__ */ React.createElement(WrappedComponent, { ...props, basename, ref });
203
+ });
204
+ return React.forwardRef(function(props, ref) {
205
+ return /* @__PURE__ */ React.createElement(Component, { ...props, ref });
206
+ });
207
+ }
208
+ const RemoteApp = withRouterData(RemoteAppWrapper);
209
+ function createLazyRemoteComponent(info) {
210
+ const exportName = (info == null ? void 0 : info.export) || "default";
211
+ return React.lazy(async () => {
212
+ index.LoggerInstance.debug(`createRemoteAppComponent LazyComponent create >>>`, {
213
+ lazyComponent: info.loader,
214
+ exportName
215
+ });
216
+ try {
217
+ const m = await info.loader();
218
+ const moduleName = m && m[Symbol.for("mf_module_id")];
219
+ index.LoggerInstance.debug(
220
+ `createRemoteAppComponent LazyComponent loadRemote info >>>`,
221
+ { name: moduleName, module: m, exportName }
222
+ );
223
+ const exportFn = m[exportName];
224
+ if (exportName in m && typeof exportFn === "function") {
225
+ const RemoteAppComponent = React.forwardRef((props, ref) => {
226
+ return /* @__PURE__ */ React.createElement(
227
+ RemoteApp,
228
+ {
229
+ moduleName,
230
+ providerInfo: exportFn,
231
+ exportName: info.export || "default",
232
+ fallback: info.fallback,
233
+ loading: info.loading,
234
+ ref,
235
+ ...props
236
+ }
237
+ );
238
+ });
239
+ return {
240
+ default: RemoteAppComponent
241
+ };
242
+ } else {
243
+ index.LoggerInstance.debug(
244
+ `createRemoteAppComponent LazyComponent module not found >>>`,
245
+ { name: moduleName, module: m, exportName }
246
+ );
247
+ throw Error(
248
+ `Make sure that ${moduleName} has the correct export when export is ${String(
249
+ exportName
250
+ )}`
251
+ );
252
+ }
253
+ } catch (error) {
254
+ throw error;
255
+ }
256
+ });
257
+ }
258
+ function createRemoteAppComponent(info) {
259
+ const LazyComponent = createLazyRemoteComponent(info);
260
+ return React.forwardRef((props, ref) => {
261
+ return /* @__PURE__ */ React.createElement(
262
+ bridgeBase.ErrorBoundary,
263
+ {
264
+ FallbackComponent: info.fallback
265
+ },
266
+ /* @__PURE__ */ React.createElement(React.Suspense, { fallback: info.loading }, /* @__PURE__ */ React.createElement(LazyComponent, { ...props, ref }))
267
+ );
268
+ });
269
+ }
270
+ function createRemoteComponent(info) {
271
+ index.LoggerInstance.warn(
272
+ `createRemoteComponent is deprecated, please use createRemoteAppComponent instead!`
273
+ );
274
+ return createRemoteAppComponent(info);
275
+ }
276
+ exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
277
+ exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
278
+ exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
279
+ exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
280
+ exports.CacheSize = lazyUtils.CacheSize;
281
+ exports.CacheTime = lazyUtils.CacheTime;
282
+ exports.ERROR_TYPE = lazyUtils.ERROR_TYPE;
283
+ exports.cache = lazyUtils.cache;
284
+ exports.clearStore = lazyUtils.clearStore;
285
+ exports.configureCache = lazyUtils.configureCache;
286
+ exports.generateKey = lazyUtils.generateKey;
287
+ exports.revalidateTag = lazyUtils.revalidateTag;
288
+ exports.setSSREnv = lazyUtils.setSSREnv;
289
+ exports.callDataFetch = dataFetchUtils.callDataFetch;
290
+ exports.prefetch = prefetch.prefetch;
291
+ exports.createBridgeComponent = createBridgeComponent;
292
+ exports.createRemoteAppComponent = createRemoteAppComponent;
293
+ exports.createRemoteComponent = createRemoteComponent;
@@ -0,0 +1,274 @@
1
+ import { default as default_2 } from 'react';
2
+ import { getInstance } from '@module-federation/runtime';
3
+ import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
4
+ import * as React_2 from 'react';
5
+ import { ReactNode } from 'react';
6
+
7
+ export declare const autoFetchDataPlugin: () => ModuleFederationRuntimePlugin;
8
+
9
+ export declare function cache<T>(fn: DataFetch<T>, options?: CacheOptions): DataFetch<T>;
10
+
11
+ declare interface CacheConfig {
12
+ maxSize?: number;
13
+ unstable_shouldDisable?: ({ request, }: {
14
+ request: Request;
15
+ }) => boolean | Promise<boolean>;
16
+ }
17
+
18
+ declare interface CacheOptions {
19
+ tag?: string | string[];
20
+ maxAge?: number;
21
+ revalidate?: number;
22
+ getKey?: <Args extends any[]>(...args: Args) => string;
23
+ onCache?: (info: CacheStatsInfo) => boolean;
24
+ }
25
+
26
+ export declare const CacheSize: {
27
+ readonly KB: 1024;
28
+ readonly MB: number;
29
+ readonly GB: number;
30
+ };
31
+
32
+ export declare interface CacheStatsInfo {
33
+ status: CacheStatus;
34
+ key: string | symbol;
35
+ params: DataFetchParams;
36
+ result: any;
37
+ }
38
+
39
+ export declare type CacheStatus = 'hit' | 'stale' | 'miss';
40
+
41
+ export declare const CacheTime: {
42
+ readonly SECOND: 1000;
43
+ readonly MINUTE: number;
44
+ readonly HOUR: number;
45
+ readonly DAY: number;
46
+ readonly WEEK: number;
47
+ readonly MONTH: number;
48
+ };
49
+
50
+ export declare function callDataFetch(): Promise<void>;
51
+
52
+ export declare function clearStore(): void;
53
+
54
+ export declare function collectSSRAssets(options: CollectSSRAssetsOptions): default_2.ReactNode[];
55
+
56
+ export declare type CollectSSRAssetsOptions = {
57
+ id: string;
58
+ instance: ReturnType<typeof getInstance>;
59
+ injectScript?: boolean;
60
+ injectLink?: boolean;
61
+ };
62
+
63
+ export declare function configureCache(config: CacheConfig): void;
64
+
65
+ export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
66
+ render(info: RenderParams): Promise<void>;
67
+ destroy(info: DestroyParams): void;
68
+ };
69
+
70
+ 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;
71
+
72
+ export declare type CreateLazyComponentOptions<T, E extends keyof T> = {
73
+ loader: () => Promise<T>;
74
+ instance: ReturnType<typeof getInstance>;
75
+ loading: default_2.ReactNode;
76
+ delayLoading?: number;
77
+ fallback: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
78
+ export?: E;
79
+ dataFetchParams?: DataFetchParams;
80
+ noSSR?: boolean;
81
+ injectScript?: boolean;
82
+ injectLink?: boolean;
83
+ };
84
+
85
+ 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>>;
86
+
87
+ /**
88
+ * @deprecated createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!
89
+ */
90
+ 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>>;
91
+
92
+ export declare interface CreateRootOptions {
93
+ identifierPrefix?: string;
94
+ onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
95
+ }
96
+
97
+ /**
98
+ * Options for creating a React root
99
+ */
100
+ declare interface CreateRootOptions_2 {
101
+ identifierPrefix?: string;
102
+ onRecoverableError?: (error: unknown) => void;
103
+ transitionCallbacks?: unknown;
104
+ }
105
+
106
+ declare type DataFetch<T> = (params: DataFetchParams) => Promise<T>;
107
+
108
+ export declare type DataFetchParams = {
109
+ isDowngrade: boolean;
110
+ _id?: string;
111
+ } & Record<string, unknown>;
112
+
113
+ /**
114
+ * Parameters for the destroy function
115
+ */
116
+ export declare interface DestroyParams {
117
+ moduleName: string;
118
+ dom: HTMLElement;
119
+ }
120
+
121
+ export declare const ERROR_TYPE: {
122
+ DATA_FETCH: number;
123
+ LOAD_REMOTE: number;
124
+ UNKNOWN: number;
125
+ };
126
+
127
+ declare type ErrorInfo = {
128
+ error: Error;
129
+ errorType: number;
130
+ dataFetchMapKey?: string;
131
+ };
132
+
133
+ export declare function generateKey(dataFetchOptions: DataFetchParams): string;
134
+
135
+ export declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
136
+
137
+ declare type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
138
+
139
+ export declare type NoSSRRemoteInfo = {
140
+ name: string;
141
+ version: string;
142
+ ssrPublicPath: string;
143
+ ssrRemoteEntry: string;
144
+ globalName: string;
145
+ };
146
+
147
+ export declare function prefetch(options: PrefetchOptions): Promise<void>;
148
+
149
+ declare type PrefetchOptions = {
150
+ id: string;
151
+ instance: ReturnType<typeof getInstance>;
152
+ dataFetchParams?: DataFetchParams;
153
+ preloadComponentResource?: boolean;
154
+ };
155
+
156
+ /**
157
+ * Parameters for the provider function
158
+ */
159
+ export declare interface ProviderFnParams<T> {
160
+ rootComponent: React_2.ComponentType<T>;
161
+ render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
162
+ createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions_2) => Root_2;
163
+ /**
164
+ * Default options to pass to createRoot for React 18 and 19
165
+ * These options will be used when creating a root unless overridden by rootOptions in render params
166
+ * @example
167
+ * {
168
+ * identifierPrefix: 'app-',
169
+ * onRecoverableError: (err) => console.error(err)
170
+ * }
171
+ */
172
+ defaultRootOptions?: CreateRootOptions_2;
173
+ }
174
+
175
+ /**
176
+ * Parameters for the provider function
177
+ */
178
+ export declare interface ProviderParams {
179
+ moduleName?: string;
180
+ basename?: string;
181
+ memoryRoute?: {
182
+ entryPath: string;
183
+ initialState?: Record<string, unknown>;
184
+ };
185
+ style?: React_2.CSSProperties;
186
+ className?: string;
187
+ }
188
+
189
+ declare type ReactKey = {
190
+ key?: default_2.Key | null;
191
+ };
192
+
193
+ /**
194
+ * Parameters for the remote component loader
195
+ */
196
+ declare interface RemoteComponentParams<T = Record<string, unknown>, E extends keyof T = keyof T> {
197
+ loader: () => Promise<T>;
198
+ loading: React_2.ReactNode;
199
+ fallback: React_2.ComponentType<{
200
+ error: Error;
201
+ }>;
202
+ export?: E;
203
+ props?: T;
204
+ }
205
+
206
+ /**
207
+ * Parameters for the remote component
208
+ */
209
+ declare interface RemoteComponentProps<T = Record<string, unknown>> {
210
+ props?: T;
211
+ fallback?: React_2.ComponentType<{
212
+ error: Error;
213
+ }>;
214
+ loading?: React_2.ReactNode;
215
+ [key: string]: unknown;
216
+ }
217
+
218
+ /**
219
+ * Parameters for the render function
220
+ */
221
+ export declare interface RenderParams {
222
+ moduleName?: string;
223
+ basename?: string;
224
+ memoryRoute?: {
225
+ entryPath: string;
226
+ initialState?: Record<string, unknown>;
227
+ };
228
+ dom: HTMLElement;
229
+ /**
230
+ * Options to pass to createRoot for React 18 and 19
231
+ * @example
232
+ * {
233
+ * identifierPrefix: 'app-',
234
+ * onRecoverableError: (err) => console.error(err)
235
+ * }
236
+ */
237
+ rootOptions?: CreateRootOptions_2;
238
+ [key: string]: unknown;
239
+ }
240
+
241
+ export declare function revalidateTag(tag: string): void;
242
+
243
+ export declare interface Root {
244
+ render(children: React.ReactNode): void;
245
+ unmount(): void;
246
+ }
247
+
248
+ /**
249
+ * Interface for a React root object
250
+ */
251
+ declare interface Root_2 {
252
+ render(children: React_2.ReactNode): void;
253
+ unmount(): void;
254
+ }
255
+
256
+ /**
257
+ * Type for a root element, which can be either an HTMLElement or a React root
258
+ */
259
+ export declare type RootType = HTMLElement | Root_2;
260
+
261
+ export declare function setSSREnv({ fetchServerQuery, }: {
262
+ fetchServerQuery?: Record<string, unknown>;
263
+ }): void;
264
+
265
+ export { }
266
+
267
+
268
+ declare module '@module-federation/runtime-core' {
269
+ interface ModuleFederation {
270
+ createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
271
+ prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
272
+ collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
273
+ }
274
+ }