@module-federation/bridge-react 0.0.0-next-20250926024003 → 0.0.0-perf-devtools-20260106124142
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-CWNzJM0v.js → lazy-load-component-plugin-BbKBABLx.js} +2 -2
- package/dist/{lazy-load-component-plugin-D6tEPyvX.mjs → lazy-load-component-plugin-CHUcCRrF.mjs} +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-DCF_oa3O.mjs → prefetch-CBBSKet3.mjs} +43 -141
- package/dist/{prefetch-hTVJ80G6.js → prefetch-DcwCyN6i.js} +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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const React = require("react");
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-DRSBaSu3.js");
|
|
4
4
|
const plugin = require("./plugin.cjs.js");
|
|
5
5
|
function _interopNamespaceDefault(e) {
|
|
6
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -138,6 +138,24 @@ function createBaseBridgeComponent({
|
|
|
138
138
|
}
|
|
139
139
|
));
|
|
140
140
|
};
|
|
141
|
+
const DefaultFallback = ({ error }) => /* @__PURE__ */ React__namespace.createElement("div", { role: "alert" }, /* @__PURE__ */ React__namespace.createElement("p", null, "Something went wrong:"), /* @__PURE__ */ React__namespace.createElement("pre", { style: { color: "red" } }, error.message));
|
|
142
|
+
const BridgeWrapper = ({
|
|
143
|
+
basename,
|
|
144
|
+
moduleName,
|
|
145
|
+
memoryRoute,
|
|
146
|
+
propsInfo,
|
|
147
|
+
fallback
|
|
148
|
+
}) => /* @__PURE__ */ React__namespace.createElement(ErrorBoundary, { FallbackComponent: fallback || DefaultFallback }, /* @__PURE__ */ React__namespace.createElement(
|
|
149
|
+
RawComponent,
|
|
150
|
+
{
|
|
151
|
+
appInfo: {
|
|
152
|
+
moduleName,
|
|
153
|
+
basename,
|
|
154
|
+
memoryRoute
|
|
155
|
+
},
|
|
156
|
+
propsInfo
|
|
157
|
+
}
|
|
158
|
+
));
|
|
141
159
|
return {
|
|
142
160
|
async render(info) {
|
|
143
161
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -157,24 +175,18 @@ function createBaseBridgeComponent({
|
|
|
157
175
|
};
|
|
158
176
|
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(info)) || {};
|
|
159
177
|
const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(
|
|
160
|
-
|
|
178
|
+
BridgeWrapper,
|
|
161
179
|
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
memoryRoute
|
|
171
|
-
},
|
|
172
|
-
propsInfo: {
|
|
173
|
-
...propsInfo,
|
|
174
|
-
...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
|
|
175
|
-
}
|
|
180
|
+
basename,
|
|
181
|
+
moduleName,
|
|
182
|
+
memoryRoute,
|
|
183
|
+
fallback,
|
|
184
|
+
propsInfo: {
|
|
185
|
+
...propsInfo,
|
|
186
|
+
basename,
|
|
187
|
+
...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
|
|
176
188
|
}
|
|
177
|
-
|
|
189
|
+
}
|
|
178
190
|
);
|
|
179
191
|
if (bridgeInfo.render) {
|
|
180
192
|
await Promise.resolve(
|
|
@@ -201,7 +213,7 @@ function createBaseBridgeComponent({
|
|
|
201
213
|
if ("unmount" in root) {
|
|
202
214
|
root.unmount();
|
|
203
215
|
} else {
|
|
204
|
-
|
|
216
|
+
index.LoggerInstance.warn("Root does not have unmount method");
|
|
205
217
|
}
|
|
206
218
|
rootMap.delete(dom);
|
|
207
219
|
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const bridgeBase = require("./bridge-base-RStDxH71.js");
|
|
3
|
+
const ReactDOM = require("react-dom");
|
|
4
|
+
const index = require("./index-DRSBaSu3.js");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const plugin = require("./plugin.cjs.js");
|
|
7
|
+
function createReact16Or17Root(container) {
|
|
8
|
+
return {
|
|
9
|
+
render(children) {
|
|
10
|
+
const reactVersion = ReactDOM.version || "";
|
|
11
|
+
const isReact18 = reactVersion.startsWith("18");
|
|
12
|
+
const isReact19 = reactVersion.startsWith("19");
|
|
13
|
+
if (isReact19) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`React 19 detected in legacy mode. This is not supported. Please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v19'`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
if (isReact18) {
|
|
19
|
+
index.LoggerInstance.warn(
|
|
20
|
+
`[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'`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
ReactDOM.render(children, container);
|
|
24
|
+
},
|
|
25
|
+
unmount() {
|
|
26
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function createBridgeComponent(bridgeInfo) {
|
|
31
|
+
const fullBridgeInfo = {
|
|
32
|
+
createRoot: createReact16Or17Root,
|
|
33
|
+
...bridgeInfo
|
|
34
|
+
};
|
|
35
|
+
return bridgeBase.createBaseBridgeComponent(fullBridgeInfo);
|
|
36
|
+
}
|
|
37
|
+
const RemoteAppWrapper = React.forwardRef(function(props, ref) {
|
|
38
|
+
const {
|
|
39
|
+
moduleName,
|
|
40
|
+
memoryRoute,
|
|
41
|
+
basename,
|
|
42
|
+
providerInfo,
|
|
43
|
+
className,
|
|
44
|
+
style,
|
|
45
|
+
fallback,
|
|
46
|
+
loading,
|
|
47
|
+
...resProps
|
|
48
|
+
} = props;
|
|
49
|
+
const instance = plugin.federationRuntime.instance;
|
|
50
|
+
const rootRef = ref && "current" in ref ? ref : React.useRef(null);
|
|
51
|
+
const renderDom = React.useRef(null);
|
|
52
|
+
const providerInfoRef = React.useRef(null);
|
|
53
|
+
const [initialized, setInitialized] = React.useState(false);
|
|
54
|
+
index.LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (initialized) return;
|
|
57
|
+
const providerReturn = providerInfo();
|
|
58
|
+
providerInfoRef.current = providerReturn;
|
|
59
|
+
setInitialized(true);
|
|
60
|
+
return () => {
|
|
61
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
62
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
63
|
+
index.LoggerInstance.debug(
|
|
64
|
+
`createRemoteAppComponent LazyComponent destroy >>>`,
|
|
65
|
+
{ moduleName, basename, dom: renderDom.current }
|
|
66
|
+
);
|
|
67
|
+
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
68
|
+
moduleName,
|
|
69
|
+
dom: renderDom.current,
|
|
70
|
+
basename,
|
|
71
|
+
memoryRoute,
|
|
72
|
+
fallback,
|
|
73
|
+
...resProps
|
|
74
|
+
});
|
|
75
|
+
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
76
|
+
moduleName,
|
|
77
|
+
dom: renderDom.current
|
|
78
|
+
});
|
|
79
|
+
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
|
|
80
|
+
moduleName,
|
|
81
|
+
dom: renderDom.current,
|
|
82
|
+
basename,
|
|
83
|
+
memoryRoute,
|
|
84
|
+
fallback,
|
|
85
|
+
...resProps
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}, [moduleName]);
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
var _a, _b, _c, _d, _e, _f;
|
|
92
|
+
if (!initialized || !providerInfoRef.current) return;
|
|
93
|
+
let renderProps = {
|
|
94
|
+
moduleName,
|
|
95
|
+
dom: rootRef.current,
|
|
96
|
+
basename,
|
|
97
|
+
memoryRoute,
|
|
98
|
+
fallback,
|
|
99
|
+
...resProps
|
|
100
|
+
};
|
|
101
|
+
renderDom.current = rootRef.current;
|
|
102
|
+
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)) || {};
|
|
103
|
+
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
104
|
+
providerInfoRef.current.render(renderProps);
|
|
105
|
+
(_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);
|
|
106
|
+
}, [initialized, ...Object.values(props)]);
|
|
107
|
+
const rootComponentClassName = `${index.getRootDomDefaultClassName(moduleName)} ${className || ""}`;
|
|
108
|
+
return /* @__PURE__ */ React.createElement("div", { className: rootComponentClassName, style, ref: rootRef }, loading);
|
|
109
|
+
});
|
|
110
|
+
function createLazyRemoteComponentFactory(RemoteApp) {
|
|
111
|
+
return function createLazyRemoteComponent(info) {
|
|
112
|
+
const exportName = (info == null ? void 0 : info.export) || "default";
|
|
113
|
+
return React.lazy(async () => {
|
|
114
|
+
index.LoggerInstance.debug(
|
|
115
|
+
`createRemoteAppComponent LazyComponent create >>>`,
|
|
116
|
+
{
|
|
117
|
+
lazyComponent: info.loader,
|
|
118
|
+
exportName
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
try {
|
|
122
|
+
const m = await info.loader();
|
|
123
|
+
const moduleName = m && m[Symbol.for("mf_module_id")];
|
|
124
|
+
index.LoggerInstance.debug(
|
|
125
|
+
`createRemoteAppComponent LazyComponent loadRemote info >>>`,
|
|
126
|
+
{ name: moduleName, module: m, exportName }
|
|
127
|
+
);
|
|
128
|
+
const exportFn = m[exportName];
|
|
129
|
+
if (exportName in m && typeof exportFn === "function") {
|
|
130
|
+
const RemoteAppComponent = React.forwardRef((props, ref) => {
|
|
131
|
+
return /* @__PURE__ */ React.createElement(
|
|
132
|
+
RemoteApp,
|
|
133
|
+
{
|
|
134
|
+
moduleName,
|
|
135
|
+
providerInfo: exportFn,
|
|
136
|
+
exportName: info.export || "default",
|
|
137
|
+
fallback: info.fallback,
|
|
138
|
+
loading: info.loading,
|
|
139
|
+
ref,
|
|
140
|
+
...props
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
default: RemoteAppComponent
|
|
146
|
+
};
|
|
147
|
+
} else {
|
|
148
|
+
index.LoggerInstance.debug(
|
|
149
|
+
`createRemoteAppComponent LazyComponent module not found >>>`,
|
|
150
|
+
{ name: moduleName, module: m, exportName }
|
|
151
|
+
);
|
|
152
|
+
throw Error(
|
|
153
|
+
`Make sure that ${moduleName} has the correct export when export is ${String(
|
|
154
|
+
exportName
|
|
155
|
+
)}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
} catch (error) {
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function createRemoteAppComponentFactory(RemoteApp) {
|
|
165
|
+
const createLazyRemoteComponent = createLazyRemoteComponentFactory(RemoteApp);
|
|
166
|
+
return function createRemoteAppComponent(info) {
|
|
167
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
168
|
+
return React.forwardRef((props, ref) => {
|
|
169
|
+
return /* @__PURE__ */ React.createElement(
|
|
170
|
+
bridgeBase.ErrorBoundary,
|
|
171
|
+
{
|
|
172
|
+
FallbackComponent: info.fallback
|
|
173
|
+
},
|
|
174
|
+
/* @__PURE__ */ React.createElement(React.Suspense, { fallback: info.loading }, /* @__PURE__ */ React.createElement(LazyComponent, { ...props, ref }))
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function createDeprecatedRemoteComponentFactory(createFn) {
|
|
180
|
+
return function createRemoteComponent(info) {
|
|
181
|
+
index.LoggerInstance.warn(
|
|
182
|
+
`createRemoteComponent is deprecated, please use createRemoteAppComponent instead!`
|
|
183
|
+
);
|
|
184
|
+
return createFn(info);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
exports.RemoteAppWrapper = RemoteAppWrapper;
|
|
188
|
+
exports.createBridgeComponent = createBridgeComponent;
|
|
189
|
+
exports.createDeprecatedRemoteComponentFactory = createDeprecatedRemoteComponentFactory;
|
|
190
|
+
exports.createRemoteAppComponentFactory = createRemoteAppComponentFactory;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-CPSTBjEp.mjs";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
import { L as LoggerInstance, g as getRootDomDefaultClassName } from "./index-DyQNwY2M.mjs";
|
|
4
|
+
import React__default, { forwardRef, useRef, useState, useEffect } from "react";
|
|
5
|
+
import { federationRuntime } from "./plugin.es.js";
|
|
6
|
+
function createReact16Or17Root(container) {
|
|
7
|
+
return {
|
|
8
|
+
render(children) {
|
|
9
|
+
const reactVersion = ReactDOM.version || "";
|
|
10
|
+
const isReact18 = reactVersion.startsWith("18");
|
|
11
|
+
const isReact19 = reactVersion.startsWith("19");
|
|
12
|
+
if (isReact19) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`React 19 detected in legacy mode. This is not supported. Please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v19'`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (isReact18) {
|
|
18
|
+
LoggerInstance.warn(
|
|
19
|
+
`[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'`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
ReactDOM.render(children, container);
|
|
23
|
+
},
|
|
24
|
+
unmount() {
|
|
25
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function createBridgeComponent(bridgeInfo) {
|
|
30
|
+
const fullBridgeInfo = {
|
|
31
|
+
createRoot: createReact16Or17Root,
|
|
32
|
+
...bridgeInfo
|
|
33
|
+
};
|
|
34
|
+
return createBaseBridgeComponent(fullBridgeInfo);
|
|
35
|
+
}
|
|
36
|
+
const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
37
|
+
const {
|
|
38
|
+
moduleName,
|
|
39
|
+
memoryRoute,
|
|
40
|
+
basename,
|
|
41
|
+
providerInfo,
|
|
42
|
+
className,
|
|
43
|
+
style,
|
|
44
|
+
fallback,
|
|
45
|
+
loading,
|
|
46
|
+
...resProps
|
|
47
|
+
} = props;
|
|
48
|
+
const instance = federationRuntime.instance;
|
|
49
|
+
const rootRef = ref && "current" in ref ? ref : useRef(null);
|
|
50
|
+
const renderDom = useRef(null);
|
|
51
|
+
const providerInfoRef = useRef(null);
|
|
52
|
+
const [initialized, setInitialized] = useState(false);
|
|
53
|
+
LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (initialized) return;
|
|
56
|
+
const providerReturn = providerInfo();
|
|
57
|
+
providerInfoRef.current = providerReturn;
|
|
58
|
+
setInitialized(true);
|
|
59
|
+
return () => {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
61
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
62
|
+
LoggerInstance.debug(
|
|
63
|
+
`createRemoteAppComponent LazyComponent destroy >>>`,
|
|
64
|
+
{ moduleName, basename, dom: renderDom.current }
|
|
65
|
+
);
|
|
66
|
+
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
67
|
+
moduleName,
|
|
68
|
+
dom: renderDom.current,
|
|
69
|
+
basename,
|
|
70
|
+
memoryRoute,
|
|
71
|
+
fallback,
|
|
72
|
+
...resProps
|
|
73
|
+
});
|
|
74
|
+
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
75
|
+
moduleName,
|
|
76
|
+
dom: renderDom.current
|
|
77
|
+
});
|
|
78
|
+
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
|
|
79
|
+
moduleName,
|
|
80
|
+
dom: renderDom.current,
|
|
81
|
+
basename,
|
|
82
|
+
memoryRoute,
|
|
83
|
+
fallback,
|
|
84
|
+
...resProps
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}, [moduleName]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
var _a, _b, _c, _d, _e, _f;
|
|
91
|
+
if (!initialized || !providerInfoRef.current) return;
|
|
92
|
+
let renderProps = {
|
|
93
|
+
moduleName,
|
|
94
|
+
dom: rootRef.current,
|
|
95
|
+
basename,
|
|
96
|
+
memoryRoute,
|
|
97
|
+
fallback,
|
|
98
|
+
...resProps
|
|
99
|
+
};
|
|
100
|
+
renderDom.current = rootRef.current;
|
|
101
|
+
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)) || {};
|
|
102
|
+
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
103
|
+
providerInfoRef.current.render(renderProps);
|
|
104
|
+
(_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);
|
|
105
|
+
}, [initialized, ...Object.values(props)]);
|
|
106
|
+
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${className || ""}`;
|
|
107
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: rootComponentClassName, style, ref: rootRef }, loading);
|
|
108
|
+
});
|
|
109
|
+
function createLazyRemoteComponentFactory(RemoteApp) {
|
|
110
|
+
return function createLazyRemoteComponent(info) {
|
|
111
|
+
const exportName = (info == null ? void 0 : info.export) || "default";
|
|
112
|
+
return React__default.lazy(async () => {
|
|
113
|
+
LoggerInstance.debug(
|
|
114
|
+
`createRemoteAppComponent LazyComponent create >>>`,
|
|
115
|
+
{
|
|
116
|
+
lazyComponent: info.loader,
|
|
117
|
+
exportName
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
try {
|
|
121
|
+
const m = await info.loader();
|
|
122
|
+
const moduleName = m && m[Symbol.for("mf_module_id")];
|
|
123
|
+
LoggerInstance.debug(
|
|
124
|
+
`createRemoteAppComponent LazyComponent loadRemote info >>>`,
|
|
125
|
+
{ name: moduleName, module: m, exportName }
|
|
126
|
+
);
|
|
127
|
+
const exportFn = m[exportName];
|
|
128
|
+
if (exportName in m && typeof exportFn === "function") {
|
|
129
|
+
const RemoteAppComponent = forwardRef((props, ref) => {
|
|
130
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
131
|
+
RemoteApp,
|
|
132
|
+
{
|
|
133
|
+
moduleName,
|
|
134
|
+
providerInfo: exportFn,
|
|
135
|
+
exportName: info.export || "default",
|
|
136
|
+
fallback: info.fallback,
|
|
137
|
+
loading: info.loading,
|
|
138
|
+
ref,
|
|
139
|
+
...props
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
default: RemoteAppComponent
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
LoggerInstance.debug(
|
|
148
|
+
`createRemoteAppComponent LazyComponent module not found >>>`,
|
|
149
|
+
{ name: moduleName, module: m, exportName }
|
|
150
|
+
);
|
|
151
|
+
throw Error(
|
|
152
|
+
`Make sure that ${moduleName} has the correct export when export is ${String(
|
|
153
|
+
exportName
|
|
154
|
+
)}`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function createRemoteAppComponentFactory(RemoteApp) {
|
|
164
|
+
const createLazyRemoteComponent = createLazyRemoteComponentFactory(RemoteApp);
|
|
165
|
+
return function createRemoteAppComponent(info) {
|
|
166
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
167
|
+
return forwardRef((props, ref) => {
|
|
168
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
169
|
+
ErrorBoundary,
|
|
170
|
+
{
|
|
171
|
+
FallbackComponent: info.fallback
|
|
172
|
+
},
|
|
173
|
+
/* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref }))
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function createDeprecatedRemoteComponentFactory(createFn) {
|
|
179
|
+
return function createRemoteComponent(info) {
|
|
180
|
+
LoggerInstance.warn(
|
|
181
|
+
`createRemoteComponent is deprecated, please use createRemoteAppComponent instead!`
|
|
182
|
+
);
|
|
183
|
+
return createFn(info);
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
RemoteAppWrapper as R,
|
|
188
|
+
createRemoteAppComponentFactory as a,
|
|
189
|
+
createBridgeComponent as b,
|
|
190
|
+
createDeprecatedRemoteComponentFactory as c
|
|
191
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const lazyUtils = require("./utils-
|
|
3
|
-
const index_esm = require("./index.esm-
|
|
2
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
3
|
+
const index_esm = require("./index.esm-BWaKho-8.js");
|
|
4
4
|
function wrapSetTimeout(targetPromise, delay = 2e4, id) {
|
|
5
5
|
if (targetPromise && typeof targetPromise.then === "function") {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DATA_FETCH_QUERY, l as logger,
|
|
2
|
-
import { M as MANIFEST_EXT, S as SEPARATOR } from "./index.esm-
|
|
1
|
+
import { D as DATA_FETCH_QUERY, l as logger, e as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, h as loadDataFetchModule } from "./utils-dUgb9Jkm.mjs";
|
|
2
|
+
import { M as MANIFEST_EXT, S as SEPARATOR } from "./index.esm-CPwSeCvw.mjs";
|
|
3
3
|
function wrapSetTimeout(targetPromise, delay = 2e4, id) {
|
|
4
4
|
if (targetPromise && typeof targetPromise.then === "function") {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const lazyUtils = require("./utils-
|
|
4
|
-
const prefetch = require("./prefetch-
|
|
3
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
4
|
+
const prefetch = require("./prefetch-DcwCyN6i.js");
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { x as DATA_FETCH_FUNCTION } from "./utils-
|
|
2
|
-
import { C,
|
|
3
|
-
import { d as dataFetchFunction } from "./prefetch-
|
|
4
|
-
import { i, p } from "./prefetch-
|
|
1
|
+
import { x as DATA_FETCH_FUNCTION } from "./utils-dUgb9Jkm.mjs";
|
|
2
|
+
import { C, a, b, d, c, g, r } from "./utils-dUgb9Jkm.mjs";
|
|
3
|
+
import { d as dataFetchFunction } from "./prefetch-CBBSKet3.mjs";
|
|
4
|
+
import { i, p } from "./prefetch-CBBSKet3.mjs";
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
|
@@ -14,12 +14,12 @@ async function callDataFetch() {
|
|
|
14
14
|
}
|
|
15
15
|
export {
|
|
16
16
|
C as CacheSize,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
a as CacheTime,
|
|
18
|
+
b as cache,
|
|
19
19
|
callDataFetch,
|
|
20
|
-
|
|
20
|
+
d as clearStore,
|
|
21
21
|
c as configureCache,
|
|
22
|
-
|
|
22
|
+
g as generateKey,
|
|
23
23
|
i as injectDataFetch,
|
|
24
24
|
p as prefetch,
|
|
25
25
|
r as revalidateTag
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const React = require("react");
|
|
3
|
-
const index_esm = require("./index.esm-
|
|
3
|
+
const index_esm = require("./index.esm-BWaKho-8.js");
|
|
4
4
|
const RouterContext = React.createContext(null);
|
|
5
5
|
const LoggerInstance = index_esm.createLogger(
|
|
6
6
|
"[ Module Federation Bridge React ]"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { c as createLogger } from "./index.esm-
|
|
2
|
+
import { c as createLogger } from "./index.esm-CPwSeCvw.mjs";
|
|
3
3
|
const RouterContext = React__default.createContext(null);
|
|
4
4
|
const LoggerInstance = createLogger(
|
|
5
5
|
"[ Module Federation Bridge React ]"
|