@module-federation/bridge-react 0.0.0-next-20250926024003 → 0.0.0-perf-devtools-20260107043700
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 +81 -3
- package/__tests__/bridge.spec.tsx +37 -14
- package/dist/base.cjs.js +29 -0
- package/dist/base.d.ts +311 -0
- package/dist/base.es.js +30 -0
- package/dist/{bridge-base-BwHtOqw_.mjs → bridge-base-CPSTBjEp.mjs} +30 -18
- package/dist/{bridge-base-Ds850AOx.js → bridge-base-RStDxH71.js} +30 -18
- package/dist/createHelpers-B_L612IN.js +190 -0
- package/dist/createHelpers-Ui5pt7je.mjs +191 -0
- package/dist/data-fetch-server-middleware.cjs.js +2 -2
- package/dist/data-fetch-server-middleware.es.js +2 -2
- package/dist/data-fetch-utils.cjs.js +2 -2
- package/dist/data-fetch-utils.es.js +8 -8
- package/dist/{index-eN2xRRXs.js → index-DRSBaSu3.js} +1 -1
- package/dist/{index-rAO0Wr0M.mjs → index-DyQNwY2M.mjs} +1 -1
- package/dist/index.cjs.js +11 -179
- package/dist/index.d.ts +31 -6
- package/dist/index.es.js +19 -186
- package/dist/{index.esm-Ju4RY-yW.js → index.esm-BWaKho-8.js} +108 -46
- package/dist/{index.esm-CtI0uQUR.mjs → index.esm-CPwSeCvw.mjs} +113 -51
- package/dist/{lazy-load-component-plugin-D6tEPyvX.mjs → lazy-load-component-plugin-CNyT62wB.mjs} +2 -2
- package/dist/{lazy-load-component-plugin-CWNzJM0v.js → lazy-load-component-plugin-Dr5VV1mu.js} +2 -2
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/lazy-utils.cjs.js +2 -2
- package/dist/lazy-utils.es.js +4 -4
- package/dist/{prefetch-hTVJ80G6.js → prefetch-J3x-_5zT.js} +43 -141
- package/dist/{prefetch-DCF_oa3O.mjs → prefetch-lrSPKiuu.mjs} +43 -141
- 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-v7.cjs.js +83 -0
- package/dist/router-v7.d.ts +20 -0
- package/dist/router-v7.es.js +61 -0
- package/dist/router.cjs.js +1 -1
- package/dist/router.es.js +1 -1
- package/dist/{utils-VSOJTX_o.mjs → utils-dUgb9Jkm.mjs} +7 -7
- package/dist/{utils-vIpCrZmn.js → utils-tM9yE73c.js} +1 -1
- 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 +54 -10
- package/src/base.ts +50 -0
- package/src/index.ts +6 -1
- package/src/provider/versions/bridge-base.tsx +45 -17
- package/src/provider/versions/legacy.ts +2 -1
- package/src/remote/RemoteAppWrapper.tsx +108 -0
- package/src/remote/base-component/component.tsx +2 -0
- package/src/remote/base-component/create.tsx +23 -0
- package/src/remote/base-component/index.tsx +10 -0
- package/src/remote/createHelpers.tsx +130 -0
- package/src/remote/{component.tsx → router-component/component.tsx} +3 -110
- package/src/remote/router-component/create.tsx +23 -0
- package/src/remote/router-component/index.tsx +10 -0
- package/src/router/v7.tsx +75 -0
- package/vite.config.ts +25 -0
- package/src/remote/create.tsx +0 -103
package/dist/index.cjs.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const createHelpers = require("./createHelpers-B_L612IN.js");
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-Dr5VV1mu.js");
|
|
5
5
|
const React = require("react");
|
|
6
|
-
const index = require("./index-eN2xRRXs.js");
|
|
7
6
|
const ReactRouterDOM = require("react-router-dom");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const lazyUtils = require("./utils-vIpCrZmn.js");
|
|
7
|
+
const index = require("./index-DRSBaSu3.js");
|
|
8
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
11
9
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
12
|
-
const prefetch = require("./prefetch-
|
|
10
|
+
const prefetch = require("./prefetch-J3x-_5zT.js");
|
|
13
11
|
function _interopNamespaceDefault(e2) {
|
|
14
12
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
15
13
|
if (e2) {
|
|
@@ -27,113 +25,10 @@ function _interopNamespaceDefault(e2) {
|
|
|
27
25
|
return Object.freeze(n);
|
|
28
26
|
}
|
|
29
27
|
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
|
-
console.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
28
|
function e() {
|
|
61
29
|
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
62
30
|
window.dispatchEvent(t);
|
|
63
31
|
}
|
|
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
32
|
function withRouterData(WrappedComponent) {
|
|
138
33
|
const Component = React.forwardRef(function(props, ref) {
|
|
139
34
|
var _a;
|
|
@@ -205,74 +100,12 @@ function withRouterData(WrappedComponent) {
|
|
|
205
100
|
return /* @__PURE__ */ React.createElement(Component, { ...props, ref });
|
|
206
101
|
});
|
|
207
102
|
}
|
|
208
|
-
const RemoteApp = withRouterData(RemoteAppWrapper);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
}
|
|
103
|
+
const RemoteApp = withRouterData(createHelpers.RemoteAppWrapper);
|
|
104
|
+
const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(RemoteApp);
|
|
105
|
+
const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
|
|
106
|
+
createRemoteAppComponent
|
|
107
|
+
);
|
|
108
|
+
exports.createBridgeComponent = createHelpers.createBridgeComponent;
|
|
276
109
|
exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
|
|
277
110
|
exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
|
|
278
111
|
exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
|
|
@@ -288,6 +121,5 @@ exports.revalidateTag = lazyUtils.revalidateTag;
|
|
|
288
121
|
exports.setSSREnv = lazyUtils.setSSREnv;
|
|
289
122
|
exports.callDataFetch = dataFetchUtils.callDataFetch;
|
|
290
123
|
exports.prefetch = prefetch.prefetch;
|
|
291
|
-
exports.createBridgeComponent = createBridgeComponent;
|
|
292
124
|
exports.createRemoteAppComponent = createRemoteAppComponent;
|
|
293
125
|
exports.createRemoteComponent = createRemoteComponent;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
2
3
|
import { getInstance } from '@module-federation/runtime';
|
|
3
4
|
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
|
|
4
5
|
import * as React_2 from 'react';
|
|
5
6
|
import { ReactNode } from 'react';
|
|
7
|
+
import { RefAttributes } from 'react';
|
|
6
8
|
|
|
7
9
|
export declare const autoFetchDataPlugin: () => ModuleFederationRuntimePlugin;
|
|
8
10
|
|
|
@@ -82,12 +84,12 @@ export declare type CreateLazyComponentOptions<T, E extends keyof T> = {
|
|
|
82
84
|
injectLink?: boolean;
|
|
83
85
|
};
|
|
84
86
|
|
|
85
|
-
export declare
|
|
87
|
+
export declare const createRemoteAppComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & RefAttributes<HTMLDivElement>>;
|
|
86
88
|
|
|
87
89
|
/**
|
|
88
|
-
* @deprecated
|
|
90
|
+
* @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
|
|
89
91
|
*/
|
|
90
|
-
export declare
|
|
92
|
+
export declare const createRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => any;
|
|
91
93
|
|
|
92
94
|
export declare interface CreateRootOptions {
|
|
93
95
|
identifierPrefix?: string;
|
|
@@ -134,7 +136,7 @@ export declare function generateKey(dataFetchOptions: DataFetchParams): string;
|
|
|
134
136
|
|
|
135
137
|
export declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
|
|
136
138
|
|
|
137
|
-
declare type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
139
|
+
export declare type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
138
140
|
|
|
139
141
|
export declare type NoSSRRemoteInfo = {
|
|
140
142
|
name: string;
|
|
@@ -193,7 +195,7 @@ declare type ReactKey = {
|
|
|
193
195
|
/**
|
|
194
196
|
* Parameters for the remote component loader
|
|
195
197
|
*/
|
|
196
|
-
declare interface RemoteComponentParams<T = Record<string, unknown>, E extends keyof T = keyof T> {
|
|
198
|
+
export declare interface RemoteComponentParams<T = Record<string, unknown>, E extends keyof T = keyof T> {
|
|
197
199
|
loader: () => Promise<T>;
|
|
198
200
|
loading: React_2.ReactNode;
|
|
199
201
|
fallback: React_2.ComponentType<{
|
|
@@ -206,7 +208,7 @@ declare interface RemoteComponentParams<T = Record<string, unknown>, E extends k
|
|
|
206
208
|
/**
|
|
207
209
|
* Parameters for the remote component
|
|
208
210
|
*/
|
|
209
|
-
declare interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
211
|
+
export declare interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
210
212
|
props?: T;
|
|
211
213
|
fallback?: React_2.ComponentType<{
|
|
212
214
|
error: Error;
|
|
@@ -215,6 +217,29 @@ declare interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
|
215
217
|
[key: string]: unknown;
|
|
216
218
|
}
|
|
217
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Interface for a remote module provider
|
|
222
|
+
*/
|
|
223
|
+
export declare interface RemoteModule {
|
|
224
|
+
provider: () => {
|
|
225
|
+
render: (info: RenderFnParams) => void;
|
|
226
|
+
destroy: (info: {
|
|
227
|
+
dom: any;
|
|
228
|
+
}) => void;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Parameters for the render function, extending ProviderParams
|
|
234
|
+
*/
|
|
235
|
+
export declare interface RenderFnParams extends ProviderParams {
|
|
236
|
+
dom: HTMLElement;
|
|
237
|
+
fallback?: React_2.ComponentType<{
|
|
238
|
+
error: Error;
|
|
239
|
+
}>;
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
}
|
|
242
|
+
|
|
218
243
|
/**
|
|
219
244
|
* Parameters for the render function
|
|
220
245
|
*/
|
package/dist/index.es.js
CHANGED
|
@@ -1,120 +1,16 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { R as RemoteAppWrapper, c as createDeprecatedRemoteComponentFactory, a as createRemoteAppComponentFactory } from "./createHelpers-Ui5pt7je.mjs";
|
|
2
|
+
import { b } from "./createHelpers-Ui5pt7je.mjs";
|
|
3
|
+
import { b as b2, a, c, l } from "./lazy-load-component-plugin-CNyT62wB.mjs";
|
|
4
|
+
import React__default, { forwardRef, useContext, useState, useEffect } from "react";
|
|
5
5
|
import * as ReactRouterDOM from "react-router-dom";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { C, b as b2, E, e, h, c as c2, d, r, s } from "./utils-VSOJTX_o.mjs";
|
|
6
|
+
import { p as pathJoin, L as LoggerInstance } from "./index-DyQNwY2M.mjs";
|
|
7
|
+
import { C, a as a2, E, b as b3, d, c as c2, g, r, s } from "./utils-dUgb9Jkm.mjs";
|
|
9
8
|
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
10
|
-
import { p } from "./prefetch-
|
|
11
|
-
function
|
|
12
|
-
return {
|
|
13
|
-
render(children) {
|
|
14
|
-
const reactVersion = ReactDOM.version || "";
|
|
15
|
-
const isReact18 = reactVersion.startsWith("18");
|
|
16
|
-
const isReact19 = reactVersion.startsWith("19");
|
|
17
|
-
if (isReact19) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
`React 19 detected in legacy mode. This is not supported. Please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v19'`
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
if (isReact18) {
|
|
23
|
-
console.warn(
|
|
24
|
-
`[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'`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
ReactDOM.render(children, container);
|
|
28
|
-
},
|
|
29
|
-
unmount() {
|
|
30
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function createBridgeComponent(bridgeInfo) {
|
|
35
|
-
const fullBridgeInfo = {
|
|
36
|
-
createRoot: createReact16Or17Root,
|
|
37
|
-
...bridgeInfo
|
|
38
|
-
};
|
|
39
|
-
return createBaseBridgeComponent(fullBridgeInfo);
|
|
40
|
-
}
|
|
41
|
-
function e2() {
|
|
9
|
+
import { p } from "./prefetch-lrSPKiuu.mjs";
|
|
10
|
+
function e() {
|
|
42
11
|
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
43
12
|
window.dispatchEvent(t);
|
|
44
13
|
}
|
|
45
|
-
const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
46
|
-
const {
|
|
47
|
-
moduleName,
|
|
48
|
-
memoryRoute,
|
|
49
|
-
basename,
|
|
50
|
-
providerInfo,
|
|
51
|
-
className,
|
|
52
|
-
style,
|
|
53
|
-
fallback,
|
|
54
|
-
loading,
|
|
55
|
-
...resProps
|
|
56
|
-
} = props;
|
|
57
|
-
const instance = federationRuntime.instance;
|
|
58
|
-
const rootRef = ref && "current" in ref ? ref : useRef(null);
|
|
59
|
-
const renderDom = useRef(null);
|
|
60
|
-
const providerInfoRef = useRef(null);
|
|
61
|
-
const [initialized, setInitialized] = useState(false);
|
|
62
|
-
LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (initialized) return;
|
|
65
|
-
const providerReturn = providerInfo();
|
|
66
|
-
providerInfoRef.current = providerReturn;
|
|
67
|
-
setInitialized(true);
|
|
68
|
-
return () => {
|
|
69
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
70
|
-
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
71
|
-
LoggerInstance.debug(
|
|
72
|
-
`createRemoteAppComponent LazyComponent destroy >>>`,
|
|
73
|
-
{ moduleName, basename, dom: renderDom.current }
|
|
74
|
-
);
|
|
75
|
-
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
76
|
-
moduleName,
|
|
77
|
-
dom: renderDom.current,
|
|
78
|
-
basename,
|
|
79
|
-
memoryRoute,
|
|
80
|
-
fallback,
|
|
81
|
-
...resProps
|
|
82
|
-
});
|
|
83
|
-
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
84
|
-
moduleName,
|
|
85
|
-
dom: renderDom.current
|
|
86
|
-
});
|
|
87
|
-
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
|
|
88
|
-
moduleName,
|
|
89
|
-
dom: renderDom.current,
|
|
90
|
-
basename,
|
|
91
|
-
memoryRoute,
|
|
92
|
-
fallback,
|
|
93
|
-
...resProps
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}, [moduleName]);
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
var _a, _b, _c, _d, _e, _f;
|
|
100
|
-
if (!initialized || !providerInfoRef.current) return;
|
|
101
|
-
let renderProps = {
|
|
102
|
-
moduleName,
|
|
103
|
-
dom: rootRef.current,
|
|
104
|
-
basename,
|
|
105
|
-
memoryRoute,
|
|
106
|
-
fallback,
|
|
107
|
-
...resProps
|
|
108
|
-
};
|
|
109
|
-
renderDom.current = rootRef.current;
|
|
110
|
-
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)) || {};
|
|
111
|
-
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
112
|
-
providerInfoRef.current.render(renderProps);
|
|
113
|
-
(_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);
|
|
114
|
-
}, [initialized, ...Object.values(props)]);
|
|
115
|
-
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${className || ""}`;
|
|
116
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: rootComponentClassName, style, ref: rootRef }, loading);
|
|
117
|
-
});
|
|
118
14
|
function withRouterData(WrappedComponent) {
|
|
119
15
|
const Component = forwardRef(function(props, ref) {
|
|
120
16
|
var _a;
|
|
@@ -175,7 +71,7 @@ function withRouterData(WrappedComponent) {
|
|
|
175
71
|
pathname: location.pathname
|
|
176
72
|
}
|
|
177
73
|
);
|
|
178
|
-
|
|
74
|
+
e();
|
|
179
75
|
}
|
|
180
76
|
setPathname(location.pathname);
|
|
181
77
|
}, [location]);
|
|
@@ -187,88 +83,25 @@ function withRouterData(WrappedComponent) {
|
|
|
187
83
|
});
|
|
188
84
|
}
|
|
189
85
|
const RemoteApp = withRouterData(RemoteAppWrapper);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
lazyComponent: info.loader,
|
|
195
|
-
exportName
|
|
196
|
-
});
|
|
197
|
-
try {
|
|
198
|
-
const m = await info.loader();
|
|
199
|
-
const moduleName = m && m[Symbol.for("mf_module_id")];
|
|
200
|
-
LoggerInstance.debug(
|
|
201
|
-
`createRemoteAppComponent LazyComponent loadRemote info >>>`,
|
|
202
|
-
{ name: moduleName, module: m, exportName }
|
|
203
|
-
);
|
|
204
|
-
const exportFn = m[exportName];
|
|
205
|
-
if (exportName in m && typeof exportFn === "function") {
|
|
206
|
-
const RemoteAppComponent = forwardRef((props, ref) => {
|
|
207
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
208
|
-
RemoteApp,
|
|
209
|
-
{
|
|
210
|
-
moduleName,
|
|
211
|
-
providerInfo: exportFn,
|
|
212
|
-
exportName: info.export || "default",
|
|
213
|
-
fallback: info.fallback,
|
|
214
|
-
loading: info.loading,
|
|
215
|
-
ref,
|
|
216
|
-
...props
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
});
|
|
220
|
-
return {
|
|
221
|
-
default: RemoteAppComponent
|
|
222
|
-
};
|
|
223
|
-
} else {
|
|
224
|
-
LoggerInstance.debug(
|
|
225
|
-
`createRemoteAppComponent LazyComponent module not found >>>`,
|
|
226
|
-
{ name: moduleName, module: m, exportName }
|
|
227
|
-
);
|
|
228
|
-
throw Error(
|
|
229
|
-
`Make sure that ${moduleName} has the correct export when export is ${String(
|
|
230
|
-
exportName
|
|
231
|
-
)}`
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
} catch (error) {
|
|
235
|
-
throw error;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
function createRemoteAppComponent(info) {
|
|
240
|
-
const LazyComponent = createLazyRemoteComponent(info);
|
|
241
|
-
return forwardRef((props, ref) => {
|
|
242
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
243
|
-
ErrorBoundary,
|
|
244
|
-
{
|
|
245
|
-
FallbackComponent: info.fallback
|
|
246
|
-
},
|
|
247
|
-
/* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref }))
|
|
248
|
-
);
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
function createRemoteComponent(info) {
|
|
252
|
-
LoggerInstance.warn(
|
|
253
|
-
`createRemoteComponent is deprecated, please use createRemoteAppComponent instead!`
|
|
254
|
-
);
|
|
255
|
-
return createRemoteAppComponent(info);
|
|
256
|
-
}
|
|
86
|
+
const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteApp);
|
|
87
|
+
const createRemoteComponent = createDeprecatedRemoteComponentFactory(
|
|
88
|
+
createRemoteAppComponent
|
|
89
|
+
);
|
|
257
90
|
export {
|
|
258
91
|
C as CacheSize,
|
|
259
|
-
|
|
92
|
+
a2 as CacheTime,
|
|
260
93
|
E as ERROR_TYPE,
|
|
261
|
-
|
|
262
|
-
|
|
94
|
+
b2 as autoFetchDataPlugin,
|
|
95
|
+
b3 as cache,
|
|
263
96
|
callDataFetch,
|
|
264
|
-
|
|
97
|
+
d as clearStore,
|
|
265
98
|
a as collectSSRAssets,
|
|
266
99
|
c2 as configureCache,
|
|
267
|
-
createBridgeComponent,
|
|
100
|
+
b as createBridgeComponent,
|
|
268
101
|
c as createLazyComponent,
|
|
269
102
|
createRemoteAppComponent,
|
|
270
103
|
createRemoteComponent,
|
|
271
|
-
|
|
104
|
+
g as generateKey,
|
|
272
105
|
l as lazyLoadComponentPlugin,
|
|
273
106
|
p as prefetch,
|
|
274
107
|
r as revalidateTag,
|