@module-federation/bridge-react 0.0.0-next-20250223132729 → 0.0.0-next-20250224065053
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 +9 -5
- package/dist/context-CRuF6Lwb.cjs +99 -0
- package/dist/context-xD9r7Htw.js +100 -0
- package/dist/index.cjs.js +89 -75
- package/dist/index.es.js +90 -76
- 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/package.json +4 -4
- package/src/provider/create.tsx +3 -8
- package/src/remote/component.tsx +96 -82
- package/src/remote/create.tsx +1 -1
- package/dist/context-BwD5jfgB.cjs +0 -364
- package/dist/context-BwUPFSB2.js +0 -365
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20250224065053
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [aa6a044]
|
|
8
|
+
- @module-federation/sdk@0.0.0-next-20250224065053
|
|
9
|
+
- @module-federation/bridge-shared@0.0.0-next-20250224065053
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
## 0.9.0
|
|
8
12
|
|
|
9
13
|
### Patch Changes
|
|
10
14
|
|
|
11
|
-
- @module-federation/sdk@0.
|
|
12
|
-
- @module-federation/bridge-shared@0.
|
|
15
|
+
- @module-federation/sdk@0.9.0
|
|
16
|
+
- @module-federation/bridge-shared@0.9.0
|
|
13
17
|
|
|
14
18
|
## 0.8.12
|
|
15
19
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const React = require("react");
|
|
3
|
+
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
4
|
+
const BROWSER_LOG_VALUE = "1";
|
|
5
|
+
function isBrowserEnv() {
|
|
6
|
+
return typeof window !== "undefined";
|
|
7
|
+
}
|
|
8
|
+
function isBrowserDebug() {
|
|
9
|
+
try {
|
|
10
|
+
if (isBrowserEnv() && window.localStorage) {
|
|
11
|
+
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
12
|
+
}
|
|
13
|
+
} catch (error) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
function isDebugMode() {
|
|
19
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
20
|
+
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
21
|
+
}
|
|
22
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return isBrowserDebug();
|
|
26
|
+
}
|
|
27
|
+
let Logger = class Logger2 {
|
|
28
|
+
log(...args) {
|
|
29
|
+
console.log(this.prefix, ...args);
|
|
30
|
+
}
|
|
31
|
+
warn(...args) {
|
|
32
|
+
console.warn(this.prefix, ...args);
|
|
33
|
+
}
|
|
34
|
+
error(...args) {
|
|
35
|
+
console.error(this.prefix, ...args);
|
|
36
|
+
}
|
|
37
|
+
success(...args) {
|
|
38
|
+
console.log(this.prefix, ...args);
|
|
39
|
+
}
|
|
40
|
+
info(...args) {
|
|
41
|
+
console.log(this.prefix, ...args);
|
|
42
|
+
}
|
|
43
|
+
ready(...args) {
|
|
44
|
+
console.log(this.prefix, ...args);
|
|
45
|
+
}
|
|
46
|
+
debug(...args) {
|
|
47
|
+
if (isDebugMode()) {
|
|
48
|
+
console.log(this.prefix, ...args);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
constructor(prefix) {
|
|
52
|
+
this.prefix = prefix;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function createLogger(prefix) {
|
|
56
|
+
return new Logger(prefix);
|
|
57
|
+
}
|
|
58
|
+
const LoggerInstance = createLogger(
|
|
59
|
+
"[ Module Federation Bridge React ]"
|
|
60
|
+
);
|
|
61
|
+
function pathJoin(...args) {
|
|
62
|
+
const res = args.reduce((res2, path) => {
|
|
63
|
+
let nPath = path;
|
|
64
|
+
if (!nPath || typeof nPath !== "string") {
|
|
65
|
+
return res2;
|
|
66
|
+
}
|
|
67
|
+
if (nPath[0] !== "/") {
|
|
68
|
+
nPath = `/${nPath}`;
|
|
69
|
+
}
|
|
70
|
+
const lastIndex = nPath.length - 1;
|
|
71
|
+
if (nPath[lastIndex] === "/") {
|
|
72
|
+
nPath = nPath.substring(0, lastIndex);
|
|
73
|
+
}
|
|
74
|
+
return res2 + nPath;
|
|
75
|
+
}, "");
|
|
76
|
+
return res || "/";
|
|
77
|
+
}
|
|
78
|
+
const getModuleName = (id) => {
|
|
79
|
+
if (!id) {
|
|
80
|
+
return id;
|
|
81
|
+
}
|
|
82
|
+
const idArray = id.split("/");
|
|
83
|
+
if (idArray.length < 2) {
|
|
84
|
+
return id;
|
|
85
|
+
}
|
|
86
|
+
return idArray[0] + "/" + idArray[1];
|
|
87
|
+
};
|
|
88
|
+
const getRootDomDefaultClassName = (moduleName) => {
|
|
89
|
+
if (!moduleName) {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
93
|
+
return `bridge-root-component-${name}`;
|
|
94
|
+
};
|
|
95
|
+
const RouterContext = React.createContext(null);
|
|
96
|
+
exports.LoggerInstance = LoggerInstance;
|
|
97
|
+
exports.RouterContext = RouterContext;
|
|
98
|
+
exports.getRootDomDefaultClassName = getRootDomDefaultClassName;
|
|
99
|
+
exports.pathJoin = pathJoin;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
3
|
+
const BROWSER_LOG_VALUE = "1";
|
|
4
|
+
function isBrowserEnv() {
|
|
5
|
+
return typeof window !== "undefined";
|
|
6
|
+
}
|
|
7
|
+
function isBrowserDebug() {
|
|
8
|
+
try {
|
|
9
|
+
if (isBrowserEnv() && window.localStorage) {
|
|
10
|
+
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
11
|
+
}
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
function isDebugMode() {
|
|
18
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
19
|
+
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
20
|
+
}
|
|
21
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return isBrowserDebug();
|
|
25
|
+
}
|
|
26
|
+
let Logger = class Logger2 {
|
|
27
|
+
log(...args) {
|
|
28
|
+
console.log(this.prefix, ...args);
|
|
29
|
+
}
|
|
30
|
+
warn(...args) {
|
|
31
|
+
console.warn(this.prefix, ...args);
|
|
32
|
+
}
|
|
33
|
+
error(...args) {
|
|
34
|
+
console.error(this.prefix, ...args);
|
|
35
|
+
}
|
|
36
|
+
success(...args) {
|
|
37
|
+
console.log(this.prefix, ...args);
|
|
38
|
+
}
|
|
39
|
+
info(...args) {
|
|
40
|
+
console.log(this.prefix, ...args);
|
|
41
|
+
}
|
|
42
|
+
ready(...args) {
|
|
43
|
+
console.log(this.prefix, ...args);
|
|
44
|
+
}
|
|
45
|
+
debug(...args) {
|
|
46
|
+
if (isDebugMode()) {
|
|
47
|
+
console.log(this.prefix, ...args);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
constructor(prefix) {
|
|
51
|
+
this.prefix = prefix;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function createLogger(prefix) {
|
|
55
|
+
return new Logger(prefix);
|
|
56
|
+
}
|
|
57
|
+
const LoggerInstance = createLogger(
|
|
58
|
+
"[ Module Federation Bridge React ]"
|
|
59
|
+
);
|
|
60
|
+
function pathJoin(...args) {
|
|
61
|
+
const res = args.reduce((res2, path) => {
|
|
62
|
+
let nPath = path;
|
|
63
|
+
if (!nPath || typeof nPath !== "string") {
|
|
64
|
+
return res2;
|
|
65
|
+
}
|
|
66
|
+
if (nPath[0] !== "/") {
|
|
67
|
+
nPath = `/${nPath}`;
|
|
68
|
+
}
|
|
69
|
+
const lastIndex = nPath.length - 1;
|
|
70
|
+
if (nPath[lastIndex] === "/") {
|
|
71
|
+
nPath = nPath.substring(0, lastIndex);
|
|
72
|
+
}
|
|
73
|
+
return res2 + nPath;
|
|
74
|
+
}, "");
|
|
75
|
+
return res || "/";
|
|
76
|
+
}
|
|
77
|
+
const getModuleName = (id) => {
|
|
78
|
+
if (!id) {
|
|
79
|
+
return id;
|
|
80
|
+
}
|
|
81
|
+
const idArray = id.split("/");
|
|
82
|
+
if (idArray.length < 2) {
|
|
83
|
+
return id;
|
|
84
|
+
}
|
|
85
|
+
return idArray[0] + "/" + idArray[1];
|
|
86
|
+
};
|
|
87
|
+
const getRootDomDefaultClassName = (moduleName) => {
|
|
88
|
+
if (!moduleName) {
|
|
89
|
+
return "";
|
|
90
|
+
}
|
|
91
|
+
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
92
|
+
return `bridge-root-component-${name}`;
|
|
93
|
+
};
|
|
94
|
+
const RouterContext = React__default.createContext(null);
|
|
95
|
+
export {
|
|
96
|
+
LoggerInstance as L,
|
|
97
|
+
RouterContext as R,
|
|
98
|
+
getRootDomDefaultClassName as g,
|
|
99
|
+
pathJoin as p
|
|
100
|
+
};
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
-
const context = require("./context-
|
|
4
|
+
const context = require("./context-CRuF6Lwb.cjs");
|
|
5
5
|
const ReactRouterDOM = require("react-router-dom");
|
|
6
6
|
const plugin = require("./plugin.cjs.js");
|
|
7
7
|
const ReactDOM = require("react-dom");
|
|
@@ -123,78 +123,97 @@ function e() {
|
|
|
123
123
|
window.dispatchEvent(t);
|
|
124
124
|
}
|
|
125
125
|
const RemoteAppWrapper = React.forwardRef(function(props, ref) {
|
|
126
|
-
const {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
150
|
-
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
151
|
-
context.LoggerInstance.debug(
|
|
152
|
-
`createRemoteComponent LazyComponent destroy >>>`,
|
|
153
|
-
{ moduleName, basename, dom: renderDom.current }
|
|
154
|
-
);
|
|
155
|
-
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
156
|
-
moduleName,
|
|
157
|
-
dom: renderDom.current,
|
|
158
|
-
basename,
|
|
159
|
-
memoryRoute,
|
|
160
|
-
fallback,
|
|
161
|
-
...resProps
|
|
162
|
-
});
|
|
163
|
-
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
164
|
-
moduleName,
|
|
165
|
-
dom: renderDom.current
|
|
166
|
-
});
|
|
167
|
-
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
|
|
126
|
+
const RemoteApp2 = () => {
|
|
127
|
+
context.LoggerInstance.debug(`RemoteAppWrapper RemoteApp props >>>`, { props });
|
|
128
|
+
const {
|
|
129
|
+
moduleName,
|
|
130
|
+
memoryRoute,
|
|
131
|
+
basename,
|
|
132
|
+
providerInfo,
|
|
133
|
+
className,
|
|
134
|
+
style,
|
|
135
|
+
fallback,
|
|
136
|
+
...resProps
|
|
137
|
+
} = props;
|
|
138
|
+
const instance = plugin.federationRuntime.instance;
|
|
139
|
+
const rootRef = ref && "current" in ref ? ref : React.useRef(null);
|
|
140
|
+
const renderDom = React.useRef(null);
|
|
141
|
+
const providerInfoRef = React.useRef(null);
|
|
142
|
+
context.LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);
|
|
143
|
+
React.useEffect(() => {
|
|
144
|
+
const renderTimeout = setTimeout(() => {
|
|
145
|
+
var _a, _b, _c, _d, _e, _f;
|
|
146
|
+
const providerReturn = providerInfo();
|
|
147
|
+
providerInfoRef.current = providerReturn;
|
|
148
|
+
let renderProps = {
|
|
168
149
|
moduleName,
|
|
169
|
-
dom:
|
|
150
|
+
dom: rootRef.current,
|
|
170
151
|
basename,
|
|
171
152
|
memoryRoute,
|
|
172
153
|
fallback,
|
|
173
154
|
...resProps
|
|
155
|
+
};
|
|
156
|
+
renderDom.current = rootRef.current;
|
|
157
|
+
context.LoggerInstance.debug(
|
|
158
|
+
`createRemoteComponent LazyComponent render >>>`,
|
|
159
|
+
renderProps
|
|
160
|
+
);
|
|
161
|
+
context.LoggerInstance.debug(
|
|
162
|
+
`createRemoteComponent LazyComponent hostInstance >>>`,
|
|
163
|
+
instance
|
|
164
|
+
);
|
|
165
|
+
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(
|
|
166
|
+
renderProps
|
|
167
|
+
)) || {};
|
|
168
|
+
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
169
|
+
providerReturn.render(renderProps);
|
|
170
|
+
(_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);
|
|
171
|
+
});
|
|
172
|
+
return () => {
|
|
173
|
+
clearTimeout(renderTimeout);
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
176
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
177
|
+
context.LoggerInstance.debug(
|
|
178
|
+
`createRemoteComponent LazyComponent destroy >>>`,
|
|
179
|
+
{ moduleName, basename, dom: renderDom.current }
|
|
180
|
+
);
|
|
181
|
+
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
182
|
+
moduleName,
|
|
183
|
+
dom: renderDom.current,
|
|
184
|
+
basename,
|
|
185
|
+
memoryRoute,
|
|
186
|
+
fallback,
|
|
187
|
+
...resProps
|
|
188
|
+
});
|
|
189
|
+
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
190
|
+
moduleName,
|
|
191
|
+
dom: renderDom.current
|
|
192
|
+
});
|
|
193
|
+
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
|
|
194
|
+
moduleName,
|
|
195
|
+
dom: renderDom.current,
|
|
196
|
+
basename,
|
|
197
|
+
memoryRoute,
|
|
198
|
+
fallback,
|
|
199
|
+
...resProps
|
|
200
|
+
});
|
|
201
|
+
}
|
|
174
202
|
});
|
|
203
|
+
};
|
|
204
|
+
}, []);
|
|
205
|
+
const rootComponentClassName = `${context.getRootDomDefaultClassName(moduleName)} ${props == null ? void 0 : props.className}`;
|
|
206
|
+
return /* @__PURE__ */ React.createElement(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
className: rootComponentClassName,
|
|
210
|
+
style: props == null ? void 0 : props.style,
|
|
211
|
+
ref: rootRef
|
|
175
212
|
}
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (!initialized || !providerInfoRef.current)
|
|
181
|
-
return;
|
|
182
|
-
let renderProps = {
|
|
183
|
-
moduleName,
|
|
184
|
-
dom: rootRef.current,
|
|
185
|
-
basename,
|
|
186
|
-
memoryRoute,
|
|
187
|
-
fallback,
|
|
188
|
-
...resProps
|
|
189
|
-
};
|
|
190
|
-
renderDom.current = rootRef.current;
|
|
191
|
-
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)) || {};
|
|
192
|
-
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
193
|
-
providerInfoRef.current.render(renderProps);
|
|
194
|
-
(_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);
|
|
195
|
-
}, [initialized, ...Object.values(props)]);
|
|
196
|
-
const rootComponentClassName = `${context.getRootDomDefaultClassName(moduleName)} ${className || ""}`;
|
|
197
|
-
return /* @__PURE__ */ React.createElement("div", { className: rootComponentClassName, style, ref: rootRef });
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
RemoteApp2["__APP_VERSION__"] = "0.9.0";
|
|
216
|
+
return /* @__PURE__ */ React.createElement(RemoteApp2, null);
|
|
198
217
|
});
|
|
199
218
|
function withRouterData(WrappedComponent) {
|
|
200
219
|
const Component = React.forwardRef(function(props, ref) {
|
|
@@ -317,9 +336,9 @@ function createLazyRemoteComponent(info) {
|
|
|
317
336
|
});
|
|
318
337
|
}
|
|
319
338
|
function createRemoteComponent(info) {
|
|
320
|
-
const LazyComponent = createLazyRemoteComponent(info);
|
|
321
339
|
return React.forwardRef(
|
|
322
340
|
(props, ref) => {
|
|
341
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
323
342
|
return /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: info.fallback }, /* @__PURE__ */ React.createElement(React.Suspense, { fallback: info.loading }, /* @__PURE__ */ React.createElement(LazyComponent, { ...props, ref })));
|
|
324
343
|
}
|
|
325
344
|
);
|
|
@@ -387,13 +406,9 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
387
406
|
bridgeInfo == null ? void 0 : bridgeInfo.render(rootComponentWithErrorBoundary, dom)
|
|
388
407
|
).then((root) => rootMap.set(info.dom, root));
|
|
389
408
|
} else {
|
|
390
|
-
|
|
391
|
-
let root = rootMap.get(info.dom);
|
|
392
|
-
if (!root) {
|
|
393
|
-
root = createRoot(info.dom);
|
|
394
|
-
rootMap.set(info.dom, root);
|
|
395
|
-
}
|
|
409
|
+
const root = createRoot(info.dom);
|
|
396
410
|
root.render(rootComponentWithErrorBoundary);
|
|
411
|
+
rootMap.set(info.dom, root);
|
|
397
412
|
}
|
|
398
413
|
((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
|
|
399
414
|
},
|
|
@@ -401,7 +416,6 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
401
416
|
var _a, _b, _c;
|
|
402
417
|
context.LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
|
|
403
418
|
const root = rootMap.get(info.dom);
|
|
404
|
-
console.log("--------createBridgeComponent destroy Info", info);
|
|
405
419
|
if (root) {
|
|
406
420
|
if ("unmount" in root) {
|
|
407
421
|
root.unmount();
|
|
@@ -410,7 +424,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
410
424
|
}
|
|
411
425
|
rootMap.delete(info.dom);
|
|
412
426
|
}
|
|
413
|
-
(_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.
|
|
427
|
+
(_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.destroyBridge) == null ? void 0 : _c.emit(info);
|
|
414
428
|
}
|
|
415
429
|
};
|
|
416
430
|
};
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import React__default, { createContext, Component, createElement, forwardRef, useRef,
|
|
3
|
-
import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, R as RouterContext } from "./context-
|
|
2
|
+
import React__default, { createContext, Component, createElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
|
|
3
|
+
import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, R as RouterContext } from "./context-xD9r7Htw.js";
|
|
4
4
|
import * as ReactRouterDOM from "react-router-dom";
|
|
5
5
|
import { federationRuntime } from "./plugin.es.js";
|
|
6
6
|
import ReactDOM from "react-dom";
|
|
@@ -104,78 +104,97 @@ function e() {
|
|
|
104
104
|
window.dispatchEvent(t);
|
|
105
105
|
}
|
|
106
106
|
const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
107
|
-
const {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
131
|
-
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
132
|
-
LoggerInstance.debug(
|
|
133
|
-
`createRemoteComponent LazyComponent destroy >>>`,
|
|
134
|
-
{ moduleName, basename, dom: renderDom.current }
|
|
135
|
-
);
|
|
136
|
-
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
137
|
-
moduleName,
|
|
138
|
-
dom: renderDom.current,
|
|
139
|
-
basename,
|
|
140
|
-
memoryRoute,
|
|
141
|
-
fallback,
|
|
142
|
-
...resProps
|
|
143
|
-
});
|
|
144
|
-
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
145
|
-
moduleName,
|
|
146
|
-
dom: renderDom.current
|
|
147
|
-
});
|
|
148
|
-
(_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
|
+
const RemoteApp2 = () => {
|
|
108
|
+
LoggerInstance.debug(`RemoteAppWrapper RemoteApp props >>>`, { props });
|
|
109
|
+
const {
|
|
110
|
+
moduleName,
|
|
111
|
+
memoryRoute,
|
|
112
|
+
basename,
|
|
113
|
+
providerInfo,
|
|
114
|
+
className,
|
|
115
|
+
style,
|
|
116
|
+
fallback,
|
|
117
|
+
...resProps
|
|
118
|
+
} = props;
|
|
119
|
+
const instance = federationRuntime.instance;
|
|
120
|
+
const rootRef = ref && "current" in ref ? ref : useRef(null);
|
|
121
|
+
const renderDom = useRef(null);
|
|
122
|
+
const providerInfoRef = useRef(null);
|
|
123
|
+
LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const renderTimeout = setTimeout(() => {
|
|
126
|
+
var _a, _b, _c, _d, _e, _f;
|
|
127
|
+
const providerReturn = providerInfo();
|
|
128
|
+
providerInfoRef.current = providerReturn;
|
|
129
|
+
let renderProps = {
|
|
149
130
|
moduleName,
|
|
150
|
-
dom:
|
|
131
|
+
dom: rootRef.current,
|
|
151
132
|
basename,
|
|
152
133
|
memoryRoute,
|
|
153
134
|
fallback,
|
|
154
135
|
...resProps
|
|
136
|
+
};
|
|
137
|
+
renderDom.current = rootRef.current;
|
|
138
|
+
LoggerInstance.debug(
|
|
139
|
+
`createRemoteComponent LazyComponent render >>>`,
|
|
140
|
+
renderProps
|
|
141
|
+
);
|
|
142
|
+
LoggerInstance.debug(
|
|
143
|
+
`createRemoteComponent LazyComponent hostInstance >>>`,
|
|
144
|
+
instance
|
|
145
|
+
);
|
|
146
|
+
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(
|
|
147
|
+
renderProps
|
|
148
|
+
)) || {};
|
|
149
|
+
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
150
|
+
providerReturn.render(renderProps);
|
|
151
|
+
(_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);
|
|
152
|
+
});
|
|
153
|
+
return () => {
|
|
154
|
+
clearTimeout(renderTimeout);
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
157
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
158
|
+
LoggerInstance.debug(
|
|
159
|
+
`createRemoteComponent LazyComponent destroy >>>`,
|
|
160
|
+
{ moduleName, basename, dom: renderDom.current }
|
|
161
|
+
);
|
|
162
|
+
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
163
|
+
moduleName,
|
|
164
|
+
dom: renderDom.current,
|
|
165
|
+
basename,
|
|
166
|
+
memoryRoute,
|
|
167
|
+
fallback,
|
|
168
|
+
...resProps
|
|
169
|
+
});
|
|
170
|
+
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
171
|
+
moduleName,
|
|
172
|
+
dom: renderDom.current
|
|
173
|
+
});
|
|
174
|
+
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
|
|
175
|
+
moduleName,
|
|
176
|
+
dom: renderDom.current,
|
|
177
|
+
basename,
|
|
178
|
+
memoryRoute,
|
|
179
|
+
fallback,
|
|
180
|
+
...resProps
|
|
181
|
+
});
|
|
182
|
+
}
|
|
155
183
|
});
|
|
184
|
+
};
|
|
185
|
+
}, []);
|
|
186
|
+
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${props == null ? void 0 : props.className}`;
|
|
187
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
188
|
+
"div",
|
|
189
|
+
{
|
|
190
|
+
className: rootComponentClassName,
|
|
191
|
+
style: props == null ? void 0 : props.style,
|
|
192
|
+
ref: rootRef
|
|
156
193
|
}
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (!initialized || !providerInfoRef.current)
|
|
162
|
-
return;
|
|
163
|
-
let renderProps = {
|
|
164
|
-
moduleName,
|
|
165
|
-
dom: rootRef.current,
|
|
166
|
-
basename,
|
|
167
|
-
memoryRoute,
|
|
168
|
-
fallback,
|
|
169
|
-
...resProps
|
|
170
|
-
};
|
|
171
|
-
renderDom.current = rootRef.current;
|
|
172
|
-
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)) || {};
|
|
173
|
-
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
174
|
-
providerInfoRef.current.render(renderProps);
|
|
175
|
-
(_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);
|
|
176
|
-
}, [initialized, ...Object.values(props)]);
|
|
177
|
-
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${className || ""}`;
|
|
178
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: rootComponentClassName, style, ref: rootRef });
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
RemoteApp2["__APP_VERSION__"] = "0.9.0";
|
|
197
|
+
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);
|
|
179
198
|
});
|
|
180
199
|
function withRouterData(WrappedComponent) {
|
|
181
200
|
const Component2 = forwardRef(function(props, ref) {
|
|
@@ -298,9 +317,9 @@ function createLazyRemoteComponent(info) {
|
|
|
298
317
|
});
|
|
299
318
|
}
|
|
300
319
|
function createRemoteComponent(info) {
|
|
301
|
-
const LazyComponent = createLazyRemoteComponent(info);
|
|
302
320
|
return forwardRef(
|
|
303
321
|
(props, ref) => {
|
|
322
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
304
323
|
return /* @__PURE__ */ React__default.createElement(ErrorBoundary, { FallbackComponent: info.fallback }, /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref })));
|
|
305
324
|
}
|
|
306
325
|
);
|
|
@@ -368,13 +387,9 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
368
387
|
bridgeInfo == null ? void 0 : bridgeInfo.render(rootComponentWithErrorBoundary, dom)
|
|
369
388
|
).then((root) => rootMap.set(info.dom, root));
|
|
370
389
|
} else {
|
|
371
|
-
|
|
372
|
-
let root = rootMap.get(info.dom);
|
|
373
|
-
if (!root) {
|
|
374
|
-
root = createRoot(info.dom);
|
|
375
|
-
rootMap.set(info.dom, root);
|
|
376
|
-
}
|
|
390
|
+
const root = createRoot(info.dom);
|
|
377
391
|
root.render(rootComponentWithErrorBoundary);
|
|
392
|
+
rootMap.set(info.dom, root);
|
|
378
393
|
}
|
|
379
394
|
((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
|
|
380
395
|
},
|
|
@@ -382,7 +397,6 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
382
397
|
var _a, _b, _c;
|
|
383
398
|
LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
|
|
384
399
|
const root = rootMap.get(info.dom);
|
|
385
|
-
console.log("--------createBridgeComponent destroy Info", info);
|
|
386
400
|
if (root) {
|
|
387
401
|
if ("unmount" in root) {
|
|
388
402
|
root.unmount();
|
|
@@ -391,7 +405,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
391
405
|
}
|
|
392
406
|
rootMap.delete(info.dom);
|
|
393
407
|
}
|
|
394
|
-
(_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.
|
|
408
|
+
(_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.destroyBridge) == null ? void 0 : _c.emit(info);
|
|
395
409
|
}
|
|
396
410
|
};
|
|
397
411
|
};
|
package/dist/router-v5.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom$1 = require("react-router-dom/index.js");
|
|
5
|
-
const context = require("./context-
|
|
5
|
+
const context = require("./context-CRuF6Lwb.cjs");
|
|
6
6
|
const ReactRouterDom = require("react-router-dom/index.js");
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
package/dist/router-v5.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom$1 from "react-router-dom/index.js";
|
|
3
|
-
import { R as RouterContext, L as LoggerInstance } from "./context-
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-xD9r7Htw.js";
|
|
4
4
|
export * from "react-router-dom/index.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|