@module-federation/bridge-react 0.0.0-next-20240830065016 → 0.0.0-next-20240830100524
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 +3 -3
- package/dist/index.cjs.js +31 -36
- package/dist/index.d.ts +2 -4
- package/dist/index.es.js +31 -36
- package/package.json +3 -3
- package/src/create.tsx +0 -1
- package/src/lifecycle.ts +2 -6
- package/src/provider.tsx +4 -8
- package/src/remote/index.tsx +23 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20240830100524
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- 3082116: feat: support module isolated reported
|
|
8
8
|
- Updated dependencies [3082116]
|
|
9
9
|
- Updated dependencies [b90fa7d]
|
|
10
|
-
- @module-federation/runtime@0.0.0-next-
|
|
11
|
-
- @module-federation/bridge-shared@0.0.0-next-
|
|
10
|
+
- @module-federation/runtime@0.0.0-next-20240830100524
|
|
11
|
+
- @module-federation/bridge-shared@0.0.0-next-20240830100524
|
|
12
12
|
|
|
13
13
|
## 0.5.1
|
|
14
14
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
-
const runtime = require("@module-federation/runtime");
|
|
5
4
|
const context = require("./context--mtFt3tp.cjs");
|
|
6
5
|
const ReactRouterDOM = require("react-router-dom");
|
|
6
|
+
const runtime = require("@module-federation/runtime");
|
|
7
7
|
const ReactDOM = require("react-dom");
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
9
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -1054,12 +1054,8 @@ const registerPlugin = helpers.global.registerPlugins;
|
|
|
1054
1054
|
const pluginHelper = helpers.global.pluginHelper;
|
|
1055
1055
|
const host = runtime.getInstance();
|
|
1056
1056
|
const pluginSystem = new pluginHelper.PluginSystem({
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
beforeBridgeDestroy: new pluginHelper.AsyncWaterfallHook(
|
|
1060
|
-
"beforeBridgeDestroy"
|
|
1061
|
-
),
|
|
1062
|
-
afterBridgeDestroy: new pluginHelper.AsyncWaterfallHook("afterBridgeDestroy")
|
|
1057
|
+
bridgeRender: new pluginHelper.SyncHook(),
|
|
1058
|
+
bridgeDestroy: new pluginHelper.SyncHook()
|
|
1063
1059
|
});
|
|
1064
1060
|
registerPlugin(
|
|
1065
1061
|
host.options.plugins,
|
|
@@ -1081,11 +1077,6 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
|
|
|
1081
1077
|
const rootRef = ref && "current" in ref ? ref : React.useRef(null);
|
|
1082
1078
|
const renderDom = React.useRef(null);
|
|
1083
1079
|
const providerInfoRef = React.useRef(null);
|
|
1084
|
-
React.useEffect(() => {
|
|
1085
|
-
(async () => {
|
|
1086
|
-
await pluginSystem.lifecycle.afterBridgeRender.emit({});
|
|
1087
|
-
})();
|
|
1088
|
-
}, []);
|
|
1089
1080
|
React.useEffect(() => {
|
|
1090
1081
|
const renderTimeout = setTimeout(() => {
|
|
1091
1082
|
const providerReturn = providerInfo();
|
|
@@ -1103,26 +1094,33 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
|
|
|
1103
1094
|
`createRemoteComponent LazyComponent render >>>`,
|
|
1104
1095
|
renderProps
|
|
1105
1096
|
);
|
|
1097
|
+
pluginSystem.lifecycle.bridgeRender.emit({
|
|
1098
|
+
...renderProps
|
|
1099
|
+
});
|
|
1106
1100
|
providerReturn.render(renderProps);
|
|
1107
1101
|
});
|
|
1108
1102
|
return () => {
|
|
1109
|
-
(
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1103
|
+
clearTimeout(renderTimeout);
|
|
1104
|
+
setTimeout(() => {
|
|
1105
|
+
var _a, _b;
|
|
1106
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
1107
|
+
context.LoggerInstance.log(
|
|
1108
|
+
`createRemoteComponent LazyComponent destroy >>>`,
|
|
1109
|
+
{ moduleName, basename, dom: renderDom.current }
|
|
1110
|
+
);
|
|
1111
|
+
pluginSystem.lifecycle.bridgeDestroy.emit({
|
|
1112
|
+
moduleName,
|
|
1113
|
+
dom: renderDom.current,
|
|
1114
|
+
basename,
|
|
1115
|
+
memoryRoute,
|
|
1116
|
+
fallback,
|
|
1117
|
+
...resProps
|
|
1118
|
+
});
|
|
1119
|
+
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
|
|
1120
|
+
dom: renderDom.current
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1126
1124
|
};
|
|
1127
1125
|
}, []);
|
|
1128
1126
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -1212,7 +1210,6 @@ function createLazyRemoteComponent(info) {
|
|
|
1212
1210
|
});
|
|
1213
1211
|
try {
|
|
1214
1212
|
const m2 = await info.loader();
|
|
1215
|
-
await pluginSystem.lifecycle.beforeBridgeRender.emit({});
|
|
1216
1213
|
const moduleName = m2 && m2[Symbol.for("mf_module_id")];
|
|
1217
1214
|
context.LoggerInstance.log(
|
|
1218
1215
|
`createRemoteComponent LazyComponent loadRemote info >>>`,
|
|
@@ -1301,7 +1298,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1301
1298
|
};
|
|
1302
1299
|
return {
|
|
1303
1300
|
async render(info) {
|
|
1304
|
-
var _a
|
|
1301
|
+
var _a;
|
|
1305
1302
|
context.LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
1306
1303
|
const {
|
|
1307
1304
|
moduleName,
|
|
@@ -1325,7 +1322,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1325
1322
|
}
|
|
1326
1323
|
))
|
|
1327
1324
|
);
|
|
1328
|
-
(_a = bridgeInfo == null ? void 0 : bridgeInfo.
|
|
1325
|
+
(_a = bridgeInfo == null ? void 0 : bridgeInfo.renderLifecycle) == null ? void 0 : _a.call(bridgeInfo, info);
|
|
1329
1326
|
if (context.atLeastReact18(React__namespace)) {
|
|
1330
1327
|
if (bridgeInfo == null ? void 0 : bridgeInfo.render) {
|
|
1331
1328
|
Promise.resolve(
|
|
@@ -1340,11 +1337,9 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1340
1337
|
const renderFn = (bridgeInfo == null ? void 0 : bridgeInfo.render) || ReactDOM.render;
|
|
1341
1338
|
renderFn == null ? void 0 : renderFn(rootComponentWithErrorBoundary, info.dom);
|
|
1342
1339
|
}
|
|
1343
|
-
(_b = bridgeInfo == null ? void 0 : bridgeInfo.afterRender) == null ? void 0 : _b.call(bridgeInfo, info);
|
|
1344
1340
|
},
|
|
1345
1341
|
async destroy(info) {
|
|
1346
|
-
var _a
|
|
1347
|
-
(_a = bridgeInfo == null ? void 0 : bridgeInfo.beforeDestroy) == null ? void 0 : _a.call(bridgeInfo, info);
|
|
1342
|
+
var _a;
|
|
1348
1343
|
context.LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
1349
1344
|
dom: info.dom
|
|
1350
1345
|
});
|
|
@@ -1355,7 +1350,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1355
1350
|
} else {
|
|
1356
1351
|
ReactDOM.unmountComponentAtNode(info.dom);
|
|
1357
1352
|
}
|
|
1358
|
-
(
|
|
1353
|
+
(_a = bridgeInfo == null ? void 0 : bridgeInfo.destroyLifecycle) == null ? void 0 : _a.call(bridgeInfo, info);
|
|
1359
1354
|
},
|
|
1360
1355
|
rawComponent: bridgeInfo.rootComponent,
|
|
1361
1356
|
__BRIDGE_FN__: (_args) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -50,10 +50,8 @@ declare type FallbackProps = {
|
|
|
50
50
|
declare type ProviderFnParams<T> = {
|
|
51
51
|
rootComponent: React_2.ComponentType<T>;
|
|
52
52
|
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
beforeDestroy?: (params: DestroyParams) => void;
|
|
56
|
-
afterDestroy?: (params: DestroyParams) => void;
|
|
53
|
+
renderLifecycle?: (params: RenderFnParams) => void;
|
|
54
|
+
destroyLifecycle?: (params: DestroyParams) => void;
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
export declare interface ProviderParams {
|
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React__default, { createContext, Component, createElement, isValidElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
|
|
3
|
-
import { getInstance } from "@module-federation/runtime";
|
|
4
3
|
import { L as LoggerInstance, p as pathJoin, f, a as atLeastReact18, R as RouterContext } from "./context-Bw2PEwa6.js";
|
|
5
4
|
import * as ReactRouterDOM from "react-router-dom";
|
|
5
|
+
import { getInstance } from "@module-federation/runtime";
|
|
6
6
|
import ReactDOM from "react-dom";
|
|
7
7
|
const ErrorBoundaryContext = createContext(null);
|
|
8
8
|
const initialState = {
|
|
@@ -1035,12 +1035,8 @@ const registerPlugin = helpers.global.registerPlugins;
|
|
|
1035
1035
|
const pluginHelper = helpers.global.pluginHelper;
|
|
1036
1036
|
const host = getInstance();
|
|
1037
1037
|
const pluginSystem = new pluginHelper.PluginSystem({
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
beforeBridgeDestroy: new pluginHelper.AsyncWaterfallHook(
|
|
1041
|
-
"beforeBridgeDestroy"
|
|
1042
|
-
),
|
|
1043
|
-
afterBridgeDestroy: new pluginHelper.AsyncWaterfallHook("afterBridgeDestroy")
|
|
1038
|
+
bridgeRender: new pluginHelper.SyncHook(),
|
|
1039
|
+
bridgeDestroy: new pluginHelper.SyncHook()
|
|
1044
1040
|
});
|
|
1045
1041
|
registerPlugin(
|
|
1046
1042
|
host.options.plugins,
|
|
@@ -1062,11 +1058,6 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
1062
1058
|
const rootRef = ref && "current" in ref ? ref : useRef(null);
|
|
1063
1059
|
const renderDom = useRef(null);
|
|
1064
1060
|
const providerInfoRef = useRef(null);
|
|
1065
|
-
useEffect(() => {
|
|
1066
|
-
(async () => {
|
|
1067
|
-
await pluginSystem.lifecycle.afterBridgeRender.emit({});
|
|
1068
|
-
})();
|
|
1069
|
-
}, []);
|
|
1070
1061
|
useEffect(() => {
|
|
1071
1062
|
const renderTimeout = setTimeout(() => {
|
|
1072
1063
|
const providerReturn = providerInfo();
|
|
@@ -1084,26 +1075,33 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
1084
1075
|
`createRemoteComponent LazyComponent render >>>`,
|
|
1085
1076
|
renderProps
|
|
1086
1077
|
);
|
|
1078
|
+
pluginSystem.lifecycle.bridgeRender.emit({
|
|
1079
|
+
...renderProps
|
|
1080
|
+
});
|
|
1087
1081
|
providerReturn.render(renderProps);
|
|
1088
1082
|
});
|
|
1089
1083
|
return () => {
|
|
1090
|
-
(
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1084
|
+
clearTimeout(renderTimeout);
|
|
1085
|
+
setTimeout(() => {
|
|
1086
|
+
var _a, _b;
|
|
1087
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
1088
|
+
LoggerInstance.log(
|
|
1089
|
+
`createRemoteComponent LazyComponent destroy >>>`,
|
|
1090
|
+
{ moduleName, basename, dom: renderDom.current }
|
|
1091
|
+
);
|
|
1092
|
+
pluginSystem.lifecycle.bridgeDestroy.emit({
|
|
1093
|
+
moduleName,
|
|
1094
|
+
dom: renderDom.current,
|
|
1095
|
+
basename,
|
|
1096
|
+
memoryRoute,
|
|
1097
|
+
fallback,
|
|
1098
|
+
...resProps
|
|
1099
|
+
});
|
|
1100
|
+
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
|
|
1101
|
+
dom: renderDom.current
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1107
1105
|
};
|
|
1108
1106
|
}, []);
|
|
1109
1107
|
return /* @__PURE__ */ React__default.createElement(
|
|
@@ -1193,7 +1191,6 @@ function createLazyRemoteComponent(info) {
|
|
|
1193
1191
|
});
|
|
1194
1192
|
try {
|
|
1195
1193
|
const m2 = await info.loader();
|
|
1196
|
-
await pluginSystem.lifecycle.beforeBridgeRender.emit({});
|
|
1197
1194
|
const moduleName = m2 && m2[Symbol.for("mf_module_id")];
|
|
1198
1195
|
LoggerInstance.log(
|
|
1199
1196
|
`createRemoteComponent LazyComponent loadRemote info >>>`,
|
|
@@ -1282,7 +1279,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1282
1279
|
};
|
|
1283
1280
|
return {
|
|
1284
1281
|
async render(info) {
|
|
1285
|
-
var _a
|
|
1282
|
+
var _a;
|
|
1286
1283
|
LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
1287
1284
|
const {
|
|
1288
1285
|
moduleName,
|
|
@@ -1306,7 +1303,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1306
1303
|
}
|
|
1307
1304
|
))
|
|
1308
1305
|
);
|
|
1309
|
-
(_a = bridgeInfo == null ? void 0 : bridgeInfo.
|
|
1306
|
+
(_a = bridgeInfo == null ? void 0 : bridgeInfo.renderLifecycle) == null ? void 0 : _a.call(bridgeInfo, info);
|
|
1310
1307
|
if (atLeastReact18(React)) {
|
|
1311
1308
|
if (bridgeInfo == null ? void 0 : bridgeInfo.render) {
|
|
1312
1309
|
Promise.resolve(
|
|
@@ -1321,11 +1318,9 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1321
1318
|
const renderFn = (bridgeInfo == null ? void 0 : bridgeInfo.render) || ReactDOM.render;
|
|
1322
1319
|
renderFn == null ? void 0 : renderFn(rootComponentWithErrorBoundary, info.dom);
|
|
1323
1320
|
}
|
|
1324
|
-
(_b = bridgeInfo == null ? void 0 : bridgeInfo.afterRender) == null ? void 0 : _b.call(bridgeInfo, info);
|
|
1325
1321
|
},
|
|
1326
1322
|
async destroy(info) {
|
|
1327
|
-
var _a
|
|
1328
|
-
(_a = bridgeInfo == null ? void 0 : bridgeInfo.beforeDestroy) == null ? void 0 : _a.call(bridgeInfo, info);
|
|
1323
|
+
var _a;
|
|
1329
1324
|
LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
1330
1325
|
dom: info.dom
|
|
1331
1326
|
});
|
|
@@ -1336,7 +1331,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
1336
1331
|
} else {
|
|
1337
1332
|
ReactDOM.unmountComponentAtNode(info.dom);
|
|
1338
1333
|
}
|
|
1339
|
-
(
|
|
1334
|
+
(_a = bridgeInfo == null ? void 0 : bridgeInfo.destroyLifecycle) == null ? void 0 : _a.call(bridgeInfo, info);
|
|
1340
1335
|
},
|
|
1341
1336
|
rawComponent: bridgeInfo.rootComponent,
|
|
1342
1337
|
__BRIDGE_FN__: (_args) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-react",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240830100524",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@loadable/component": "^5.16.4",
|
|
37
37
|
"react-error-boundary": "^4.0.13",
|
|
38
|
-
"@module-federation/bridge-shared": "0.0.0-next-
|
|
38
|
+
"@module-federation/bridge-shared": "0.0.0-next-20240830100524"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.9.0",
|
|
42
42
|
"react-dom": ">=16.9.0",
|
|
43
43
|
"react-router-dom": ">=4",
|
|
44
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
44
|
+
"@module-federation/runtime": "0.0.0-next-20240830100524"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@testing-library/react": "15.0.7",
|
package/src/create.tsx
CHANGED
|
@@ -36,7 +36,6 @@ function createLazyRemoteComponent<T, E extends keyof T>(info: {
|
|
|
36
36
|
|
|
37
37
|
try {
|
|
38
38
|
const m = (await info.loader()) as RemoteModule;
|
|
39
|
-
await hook.lifecycle.beforeBridgeRender.emit({});
|
|
40
39
|
// @ts-ignore
|
|
41
40
|
const moduleName = m && m[Symbol.for('mf_module_id')];
|
|
42
41
|
LoggerInstance.log(
|
package/src/lifecycle.ts
CHANGED
|
@@ -5,12 +5,8 @@ const registerPlugin = helper.global.registerPlugins;
|
|
|
5
5
|
const pluginHelper = helper.global.pluginHelper;
|
|
6
6
|
const host = getInstance()!;
|
|
7
7
|
const pluginSystem = new pluginHelper.PluginSystem({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
beforeBridgeDestroy: new pluginHelper.AsyncWaterfallHook(
|
|
11
|
-
'beforeBridgeDestroy',
|
|
12
|
-
),
|
|
13
|
-
afterBridgeDestroy: new pluginHelper.AsyncWaterfallHook('afterBridgeDestroy'),
|
|
8
|
+
bridgeRender: new pluginHelper.SyncHook<[Record<string, any>], void>(),
|
|
9
|
+
bridgeDestroy: new pluginHelper.SyncHook<[Record<string, any>], void>(),
|
|
14
10
|
});
|
|
15
11
|
|
|
16
12
|
registerPlugin<typeof pluginSystem.lifecycle, typeof pluginSystem>(
|
package/src/provider.tsx
CHANGED
|
@@ -22,10 +22,8 @@ type ProviderFnParams<T> = {
|
|
|
22
22
|
App: React.ReactElement,
|
|
23
23
|
id?: HTMLElement | string,
|
|
24
24
|
) => RootType | Promise<RootType>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
beforeDestroy?: (params: DestroyParams) => void;
|
|
28
|
-
afterDestroy?: (params: DestroyParams) => void;
|
|
25
|
+
renderLifecycle?: (params: RenderFnParams) => void;
|
|
26
|
+
destroyLifecycle?: (params: DestroyParams) => void;
|
|
29
27
|
};
|
|
30
28
|
export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
31
29
|
return () => {
|
|
@@ -69,7 +67,7 @@ export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
|
69
67
|
</ErrorBoundary>
|
|
70
68
|
);
|
|
71
69
|
|
|
72
|
-
bridgeInfo?.
|
|
70
|
+
bridgeInfo?.renderLifecycle?.(info);
|
|
73
71
|
if (atLeastReact18(React)) {
|
|
74
72
|
if (bridgeInfo?.render) {
|
|
75
73
|
// in case bridgeInfo?.render is an async function, resolve this to promise
|
|
@@ -86,10 +84,8 @@ export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
|
86
84
|
const renderFn = bridgeInfo?.render || ReactDOM.render;
|
|
87
85
|
renderFn?.(rootComponentWithErrorBoundary, info.dom);
|
|
88
86
|
}
|
|
89
|
-
bridgeInfo?.afterRender?.(info);
|
|
90
87
|
},
|
|
91
88
|
async destroy(info: DestroyParams) {
|
|
92
|
-
bridgeInfo?.beforeDestroy?.(info);
|
|
93
89
|
LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
94
90
|
dom: info.dom,
|
|
95
91
|
});
|
|
@@ -100,7 +96,7 @@ export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
|
100
96
|
} else {
|
|
101
97
|
ReactDOM.unmountComponentAtNode(info.dom);
|
|
102
98
|
}
|
|
103
|
-
bridgeInfo?.
|
|
99
|
+
bridgeInfo?.destroyLifecycle?.(info);
|
|
104
100
|
},
|
|
105
101
|
rawComponent: bridgeInfo.rootComponent,
|
|
106
102
|
__BRIDGE_FN__: (_args: T) => {},
|
package/src/remote/index.tsx
CHANGED
|
@@ -62,11 +62,6 @@ const RemoteAppWrapper = forwardRef(function (
|
|
|
62
62
|
const renderDom: React.MutableRefObject<HTMLElement | null> = useRef(null);
|
|
63
63
|
const providerInfoRef = useRef<any>(null);
|
|
64
64
|
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
(async () => {
|
|
67
|
-
await hook.lifecycle.afterBridgeRender.emit({});
|
|
68
|
-
})();
|
|
69
|
-
}, []);
|
|
70
65
|
useEffect(() => {
|
|
71
66
|
const renderTimeout = setTimeout(() => {
|
|
72
67
|
const providerReturn = providerInfo();
|
|
@@ -85,26 +80,33 @@ const RemoteAppWrapper = forwardRef(function (
|
|
|
85
80
|
`createRemoteComponent LazyComponent render >>>`,
|
|
86
81
|
renderProps,
|
|
87
82
|
);
|
|
83
|
+
hook.lifecycle.bridgeRender.emit({
|
|
84
|
+
...renderProps,
|
|
85
|
+
});
|
|
88
86
|
providerReturn.render(renderProps);
|
|
89
87
|
});
|
|
90
88
|
|
|
91
89
|
return () => {
|
|
92
|
-
(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
clearTimeout(renderTimeout);
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
if (providerInfoRef.current?.destroy) {
|
|
93
|
+
LoggerInstance.log(
|
|
94
|
+
`createRemoteComponent LazyComponent destroy >>>`,
|
|
95
|
+
{ moduleName, basename, dom: renderDom.current },
|
|
96
|
+
);
|
|
97
|
+
hook.lifecycle.bridgeDestroy.emit({
|
|
98
|
+
moduleName,
|
|
99
|
+
dom: renderDom.current,
|
|
100
|
+
basename,
|
|
101
|
+
memoryRoute,
|
|
102
|
+
fallback,
|
|
103
|
+
...resProps,
|
|
104
|
+
});
|
|
105
|
+
providerInfoRef.current?.destroy({
|
|
106
|
+
dom: renderDom.current,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
108
110
|
};
|
|
109
111
|
}, []);
|
|
110
112
|
|