@module-federation/bridge-react 0.0.0-next-20240731105745 → 0.0.0-next-20240801085730
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 +2 -4
- package/__tests__/bridge.spec.tsx +4 -75
- package/__tests__/util.ts +0 -18
- package/dist/index.cjs.js +74 -129
- package/dist/index.d.ts +7 -15
- package/dist/index.es.js +76 -131
- package/package.json +2 -12
- package/src/create.tsx +25 -25
- package/src/provider.tsx +23 -45
- package/src/remote/index.tsx +54 -96
- package/src/router.tsx +0 -2
- package/vite.config.ts +0 -4
- package/dist/router-v5.cjs.js +0 -80
- package/dist/router-v5.d.ts +0 -8
- package/dist/router-v5.es.js +0 -63
- package/dist/router-v6.cjs.js +0 -87
- package/dist/router-v6.d.ts +0 -11
- package/dist/router-v6.es.js +0 -64
- package/src/router-v5.tsx +0 -78
- package/src/router-v6.tsx +0 -76
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import React__default, { createContext, Component, createElement, isValidElement,
|
|
3
|
-
import {
|
|
2
|
+
import React__default, { createContext, Component, createElement, isValidElement, useContext, useState, useEffect, useRef, forwardRef } from "react";
|
|
3
|
+
import { p as pathJoin, L as LoggerInstance, f, a as atLeastReact18, R as RouterContext } from "./context-Bw2PEwa6.js";
|
|
4
4
|
import * as ReactRouterDOM from "react-router-dom";
|
|
5
5
|
import ReactDOM from "react-dom";
|
|
6
6
|
const ErrorBoundaryContext = createContext(null);
|
|
@@ -98,79 +98,55 @@ function hasArrayChanged() {
|
|
|
98
98
|
let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
99
99
|
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
101
|
+
const RemoteApp = ({
|
|
102
|
+
name,
|
|
103
|
+
memoryRoute,
|
|
104
|
+
basename,
|
|
105
|
+
providerInfo,
|
|
106
|
+
...resProps
|
|
107
|
+
}) => {
|
|
108
|
+
const rootRef = useRef(null);
|
|
109
|
+
const renderDom = useRef(null);
|
|
110
|
+
const providerInfoRef = useRef(null);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
const renderTimeout = setTimeout(() => {
|
|
113
|
+
const providerReturn = providerInfo();
|
|
114
|
+
providerInfoRef.current = providerReturn;
|
|
115
|
+
const renderProps = {
|
|
116
|
+
name,
|
|
117
|
+
dom: rootRef.current,
|
|
118
|
+
basename,
|
|
119
|
+
memoryRoute,
|
|
120
|
+
...resProps
|
|
121
|
+
};
|
|
122
|
+
renderDom.current = rootRef.current;
|
|
123
|
+
LoggerInstance.log(
|
|
124
|
+
`createRemoteComponent LazyComponent render >>>`,
|
|
125
|
+
renderProps
|
|
126
|
+
);
|
|
127
|
+
providerReturn.render(renderProps);
|
|
128
|
+
});
|
|
129
|
+
return () => {
|
|
130
|
+
clearTimeout(renderTimeout);
|
|
131
|
+
setTimeout(() => {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
134
|
+
LoggerInstance.log(
|
|
135
|
+
`createRemoteComponent LazyComponent destroy >>>`,
|
|
136
|
+
{ name, basename, dom: renderDom.current }
|
|
137
|
+
);
|
|
138
|
+
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
|
|
139
|
+
dom: renderDom.current
|
|
140
|
+
});
|
|
129
141
|
}
|
|
130
|
-
const renderProps = {
|
|
131
|
-
name,
|
|
132
|
-
dom: domElement,
|
|
133
|
-
basename,
|
|
134
|
-
memoryRoute,
|
|
135
|
-
...resProps
|
|
136
|
-
};
|
|
137
|
-
renderDom.current = rootRef.current;
|
|
138
|
-
LoggerInstance.log(
|
|
139
|
-
`createRemoteComponent LazyComponent render >>>`,
|
|
140
|
-
renderProps
|
|
141
|
-
);
|
|
142
|
-
providerReturn.render(renderProps);
|
|
143
142
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
LoggerInstance.log(
|
|
150
|
-
`createRemoteComponent LazyComponent destroy >>>`,
|
|
151
|
-
{ name, basename, dom: renderDom.current }
|
|
152
|
-
);
|
|
153
|
-
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
|
|
154
|
-
dom: renderDom.current
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
}, []);
|
|
160
|
-
return dom ? null : /* @__PURE__ */ React__default.createElement(
|
|
161
|
-
"div",
|
|
162
|
-
{
|
|
163
|
-
className: props == null ? void 0 : props.className,
|
|
164
|
-
style: props == null ? void 0 : props.style,
|
|
165
|
-
ref: rootRef
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
RemoteApp2["__APP_VERSION__"] = "0.3.3";
|
|
170
|
-
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);
|
|
171
|
-
});
|
|
143
|
+
};
|
|
144
|
+
}, []);
|
|
145
|
+
return /* @__PURE__ */ React__default.createElement("div", { ref: rootRef });
|
|
146
|
+
};
|
|
147
|
+
RemoteApp["__APP_VERSION__"] = "0.3.3";
|
|
172
148
|
function withRouterData(WrappedComponent) {
|
|
173
|
-
|
|
149
|
+
return (props) => {
|
|
174
150
|
var _a;
|
|
175
151
|
let enableDispathPopstate = false;
|
|
176
152
|
let routerContextVal;
|
|
@@ -228,13 +204,10 @@ function withRouterData(WrappedComponent) {
|
|
|
228
204
|
setPathname(location.pathname);
|
|
229
205
|
}, [location]);
|
|
230
206
|
}
|
|
231
|
-
return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename
|
|
232
|
-
}
|
|
233
|
-
return forwardRef(function(props, ref) {
|
|
234
|
-
return /* @__PURE__ */ React__default.createElement(Component2, { ...props, ref });
|
|
235
|
-
});
|
|
207
|
+
return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename });
|
|
208
|
+
};
|
|
236
209
|
}
|
|
237
|
-
const RemoteApp = withRouterData(
|
|
210
|
+
const RemoteApp$1 = withRouterData(RemoteApp);
|
|
238
211
|
function createLazyRemoteComponent(info) {
|
|
239
212
|
const exportName = (info == null ? void 0 : info.export) || "default";
|
|
240
213
|
return React__default.lazy(async () => {
|
|
@@ -251,14 +224,13 @@ function createLazyRemoteComponent(info) {
|
|
|
251
224
|
);
|
|
252
225
|
const exportFn = m2[exportName];
|
|
253
226
|
if (exportName in m2 && typeof exportFn === "function") {
|
|
254
|
-
const RemoteAppComponent = forwardRef((props,
|
|
227
|
+
const RemoteAppComponent = forwardRef((props, _ref) => {
|
|
255
228
|
return /* @__PURE__ */ React__default.createElement(
|
|
256
|
-
RemoteApp,
|
|
229
|
+
RemoteApp$1,
|
|
257
230
|
{
|
|
258
231
|
name: moduleName,
|
|
259
232
|
providerInfo: exportFn,
|
|
260
233
|
exportName: info.export || "default",
|
|
261
|
-
ref,
|
|
262
234
|
...props
|
|
263
235
|
}
|
|
264
236
|
);
|
|
@@ -283,10 +255,10 @@ function createLazyRemoteComponent(info) {
|
|
|
283
255
|
});
|
|
284
256
|
}
|
|
285
257
|
function createRemoteComponent(info) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
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
|
|
289
|
-
}
|
|
258
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
259
|
+
return (props) => {
|
|
260
|
+
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 })));
|
|
261
|
+
};
|
|
290
262
|
}
|
|
291
263
|
var client = {};
|
|
292
264
|
var m = ReactDOM;
|
|
@@ -316,59 +288,32 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
316
288
|
return () => {
|
|
317
289
|
const rootMap = /* @__PURE__ */ new Map();
|
|
318
290
|
const RawComponent = (info) => {
|
|
319
|
-
const { appInfo, propsInfo
|
|
291
|
+
const { appInfo, propsInfo } = info;
|
|
320
292
|
const { name, memoryRoute, basename = "/" } = appInfo;
|
|
321
|
-
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(
|
|
322
|
-
bridgeInfo.rootComponent,
|
|
323
|
-
{
|
|
324
|
-
...propsInfo,
|
|
325
|
-
basename,
|
|
326
|
-
...restProps
|
|
327
|
-
}
|
|
328
|
-
));
|
|
293
|
+
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(bridgeInfo.rootComponent, { ...propsInfo, basename }));
|
|
329
294
|
};
|
|
330
295
|
return {
|
|
331
|
-
|
|
296
|
+
render(info) {
|
|
332
297
|
LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
333
298
|
const { name, basename, memoryRoute, ...propsInfo } = info;
|
|
334
299
|
if (atLeastReact18(React)) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
),
|
|
349
|
-
info.dom
|
|
350
|
-
)
|
|
351
|
-
).then((root) => rootMap.set(info.dom, root));
|
|
352
|
-
} else {
|
|
353
|
-
const root = client.createRoot(info.dom);
|
|
354
|
-
root.render(
|
|
355
|
-
/* @__PURE__ */ React.createElement(
|
|
356
|
-
RawComponent,
|
|
357
|
-
{
|
|
358
|
-
propsInfo,
|
|
359
|
-
appInfo: {
|
|
360
|
-
name,
|
|
361
|
-
basename,
|
|
362
|
-
memoryRoute
|
|
363
|
-
}
|
|
300
|
+
const root = client.createRoot(info.dom);
|
|
301
|
+
rootMap.set(info.dom, root);
|
|
302
|
+
root.render(
|
|
303
|
+
/* @__PURE__ */ React.createElement(
|
|
304
|
+
RawComponent,
|
|
305
|
+
{
|
|
306
|
+
propsInfo,
|
|
307
|
+
appInfo: {
|
|
308
|
+
name,
|
|
309
|
+
basename,
|
|
310
|
+
memoryRoute
|
|
364
311
|
}
|
|
365
|
-
|
|
366
|
-
)
|
|
367
|
-
|
|
368
|
-
}
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
);
|
|
369
315
|
} else {
|
|
370
|
-
|
|
371
|
-
renderFunc(
|
|
316
|
+
ReactDOM.render(
|
|
372
317
|
/* @__PURE__ */ React.createElement(
|
|
373
318
|
RawComponent,
|
|
374
319
|
{
|
|
@@ -384,7 +329,7 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
384
329
|
);
|
|
385
330
|
}
|
|
386
331
|
},
|
|
387
|
-
|
|
332
|
+
destroy(info) {
|
|
388
333
|
LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
389
334
|
dom: info.dom
|
|
390
335
|
});
|
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-20240801085730",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,22 +20,12 @@
|
|
|
20
20
|
"import": "./dist/router.es.js",
|
|
21
21
|
"require": "./dist/router.cjs.js"
|
|
22
22
|
},
|
|
23
|
-
"./router-v5": {
|
|
24
|
-
"types": "./dist/router-v5.d.ts",
|
|
25
|
-
"import": "./dist/router-v5.es.js",
|
|
26
|
-
"require": "./dist/router-v5.cjs.js"
|
|
27
|
-
},
|
|
28
|
-
"./router-v6": {
|
|
29
|
-
"types": "./dist/router-v6.d.ts",
|
|
30
|
-
"import": "./dist/router-v6.es.js",
|
|
31
|
-
"require": "./dist/router-v6.cjs.js"
|
|
32
|
-
},
|
|
33
23
|
"./*": "./*"
|
|
34
24
|
},
|
|
35
25
|
"dependencies": {
|
|
36
26
|
"@loadable/component": "^5.16.4",
|
|
37
27
|
"react-error-boundary": "^4.0.13",
|
|
38
|
-
"@module-federation/bridge-shared": "0.0.0-next-
|
|
28
|
+
"@module-federation/bridge-shared": "0.0.0-next-20240801085730"
|
|
39
29
|
},
|
|
40
30
|
"peerDependencies": {
|
|
41
31
|
"react": ">=16.9.0",
|
package/src/create.tsx
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
ForwardRefExoticComponent,
|
|
4
|
-
PropsWithoutRef,
|
|
5
|
-
RefAttributes,
|
|
6
|
-
} from 'react';
|
|
7
2
|
import type { ProviderParams } from '@module-federation/bridge-shared';
|
|
8
3
|
import { LoggerInstance } from './utils';
|
|
9
4
|
import {
|
|
@@ -18,7 +13,11 @@ export interface RenderFnParams extends ProviderParams {
|
|
|
18
13
|
|
|
19
14
|
interface RemoteModule {
|
|
20
15
|
provider: () => {
|
|
21
|
-
render: (
|
|
16
|
+
render: (
|
|
17
|
+
info: ProviderParams & {
|
|
18
|
+
dom: any;
|
|
19
|
+
},
|
|
20
|
+
) => void;
|
|
22
21
|
destroy: (info: { dom: any }) => void;
|
|
23
22
|
};
|
|
24
23
|
}
|
|
@@ -28,7 +27,6 @@ function createLazyRemoteComponent<T, E extends keyof T>(info: {
|
|
|
28
27
|
loading: React.ReactNode;
|
|
29
28
|
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
30
29
|
export?: E;
|
|
31
|
-
dom?: string;
|
|
32
30
|
}) {
|
|
33
31
|
const exportName = info?.export || 'default';
|
|
34
32
|
return React.lazy(async () => {
|
|
@@ -55,13 +53,12 @@ function createLazyRemoteComponent<T, E extends keyof T>(info: {
|
|
|
55
53
|
basename?: ProviderParams['basename'];
|
|
56
54
|
memoryRoute?: ProviderParams['memoryRoute'];
|
|
57
55
|
}
|
|
58
|
-
>((props,
|
|
56
|
+
>((props, _ref) => {
|
|
59
57
|
return (
|
|
60
58
|
<RemoteApp
|
|
61
59
|
name={moduleName}
|
|
62
60
|
providerInfo={exportFn}
|
|
63
61
|
exportName={info.export || 'default'}
|
|
64
|
-
ref={ref}
|
|
65
62
|
{...props}
|
|
66
63
|
/>
|
|
67
64
|
);
|
|
@@ -92,27 +89,30 @@ export function createRemoteComponent<T, E extends keyof T>(info: {
|
|
|
92
89
|
loading: React.ReactNode;
|
|
93
90
|
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
94
91
|
export?: E;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// : {};
|
|
92
|
+
}) {
|
|
93
|
+
type ExportType = T[E] extends (...args: any) => any
|
|
94
|
+
? ReturnType<T[E]>
|
|
95
|
+
: never;
|
|
96
|
+
type RawComponentType = '__BRIDGE_FN__' extends keyof ExportType
|
|
97
|
+
? ExportType['__BRIDGE_FN__'] extends (...args: any) => any
|
|
98
|
+
? Parameters<ExportType['__BRIDGE_FN__']>[0]
|
|
99
|
+
: {}
|
|
100
|
+
: {};
|
|
101
|
+
|
|
102
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
107
103
|
|
|
108
|
-
return
|
|
109
|
-
|
|
104
|
+
return (
|
|
105
|
+
props: {
|
|
106
|
+
basename?: ProviderParams['basename'];
|
|
107
|
+
memoryRoute?: ProviderParams['memoryRoute'];
|
|
108
|
+
} & RawComponentType,
|
|
109
|
+
) => {
|
|
110
110
|
return (
|
|
111
111
|
<ErrorBoundary FallbackComponent={info.fallback}>
|
|
112
112
|
<React.Suspense fallback={info.loading}>
|
|
113
|
-
<LazyComponent {...props}
|
|
113
|
+
<LazyComponent {...props} />
|
|
114
114
|
</React.Suspense>
|
|
115
115
|
</ErrorBoundary>
|
|
116
116
|
);
|
|
117
|
-
}
|
|
117
|
+
};
|
|
118
118
|
}
|
package/src/provider.tsx
CHANGED
|
@@ -9,69 +9,45 @@ import type {
|
|
|
9
9
|
} from '@module-federation/bridge-shared';
|
|
10
10
|
import { LoggerInstance, atLeastReact18 } from './utils';
|
|
11
11
|
|
|
12
|
-
type RootType = HTMLElement | ReactDOMClient.Root;
|
|
13
12
|
type ProviderFnParams<T> = {
|
|
14
13
|
rootComponent: React.ComponentType<T>;
|
|
15
|
-
render?: (
|
|
16
|
-
App: React.ReactElement,
|
|
17
|
-
id?: HTMLElement | string,
|
|
18
|
-
) => RootType | Promise<RootType>;
|
|
19
14
|
};
|
|
20
15
|
|
|
21
16
|
export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
22
17
|
return () => {
|
|
23
|
-
const rootMap = new Map<any,
|
|
18
|
+
const rootMap = new Map<any, ReactDOMClient.Root>();
|
|
19
|
+
|
|
24
20
|
const RawComponent = (info: { propsInfo: T; appInfo: ProviderParams }) => {
|
|
25
|
-
const { appInfo, propsInfo
|
|
21
|
+
const { appInfo, propsInfo } = info;
|
|
26
22
|
const { name, memoryRoute, basename = '/' } = appInfo;
|
|
27
23
|
|
|
28
24
|
return (
|
|
29
25
|
<RouterContext.Provider value={{ name, basename, memoryRoute }}>
|
|
30
|
-
<bridgeInfo.rootComponent
|
|
31
|
-
{...propsInfo}
|
|
32
|
-
basename={basename}
|
|
33
|
-
{...restProps}
|
|
34
|
-
/>
|
|
26
|
+
<bridgeInfo.rootComponent {...propsInfo} basename={basename} />
|
|
35
27
|
</RouterContext.Provider>
|
|
36
28
|
);
|
|
37
29
|
};
|
|
38
30
|
|
|
39
31
|
return {
|
|
40
|
-
|
|
32
|
+
render(info: RenderFnParams & any) {
|
|
41
33
|
LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
42
34
|
const { name, basename, memoryRoute, ...propsInfo } = info;
|
|
35
|
+
|
|
43
36
|
if (atLeastReact18(React)) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
),
|
|
57
|
-
).then((root: RootType) => rootMap.set(info.dom, root));
|
|
58
|
-
} else {
|
|
59
|
-
const root: RootType = ReactDOMClient.createRoot(info.dom);
|
|
60
|
-
root.render(
|
|
61
|
-
<RawComponent
|
|
62
|
-
propsInfo={propsInfo}
|
|
63
|
-
appInfo={{
|
|
64
|
-
name,
|
|
65
|
-
basename,
|
|
66
|
-
memoryRoute,
|
|
67
|
-
}}
|
|
68
|
-
/>,
|
|
69
|
-
);
|
|
70
|
-
rootMap.set(info.dom, root);
|
|
71
|
-
}
|
|
37
|
+
const root = ReactDOMClient.createRoot(info.dom);
|
|
38
|
+
rootMap.set(info.dom, root);
|
|
39
|
+
root.render(
|
|
40
|
+
<RawComponent
|
|
41
|
+
propsInfo={propsInfo}
|
|
42
|
+
appInfo={{
|
|
43
|
+
name,
|
|
44
|
+
basename,
|
|
45
|
+
memoryRoute,
|
|
46
|
+
}}
|
|
47
|
+
/>,
|
|
48
|
+
);
|
|
72
49
|
} else {
|
|
73
|
-
|
|
74
|
-
renderFunc(
|
|
50
|
+
ReactDOM.render(
|
|
75
51
|
<RawComponent
|
|
76
52
|
propsInfo={propsInfo}
|
|
77
53
|
appInfo={{
|
|
@@ -84,13 +60,13 @@ export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
|
84
60
|
);
|
|
85
61
|
}
|
|
86
62
|
},
|
|
87
|
-
|
|
63
|
+
destroy(info: { dom: HTMLElement }) {
|
|
88
64
|
LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
89
65
|
dom: info.dom,
|
|
90
66
|
});
|
|
91
67
|
if (atLeastReact18(React)) {
|
|
92
68
|
const root = rootMap.get(info.dom);
|
|
93
|
-
|
|
69
|
+
root?.unmount();
|
|
94
70
|
} else {
|
|
95
71
|
ReactDOM.unmountComponentAtNode(info.dom);
|
|
96
72
|
}
|
|
@@ -108,3 +84,5 @@ export function ShadowRoot(info: { children: () => JSX.Element }) {
|
|
|
108
84
|
|
|
109
85
|
return <div ref={domRef}>{root && <info.children />}</div>;
|
|
110
86
|
}
|
|
87
|
+
|
|
88
|
+
// function ShadowContent() {}
|