@module-federation/bridge-react 0.0.0-next-20250410121036 → 0.0.0-next-20250411200445

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +4 -8
  2. package/dist/index.cjs.js +136 -64
  3. package/dist/index.d.ts +1 -24
  4. package/dist/index.es.js +139 -67
  5. package/dist/router-v5.cjs.js +1 -1
  6. package/dist/router-v5.es.js +1 -1
  7. package/dist/router-v6.cjs.js +1 -1
  8. package/dist/router-v6.es.js +1 -1
  9. package/dist/router.cjs.js +1 -1
  10. package/dist/router.es.js +1 -1
  11. package/package.json +4 -19
  12. package/src/index.ts +0 -6
  13. package/src/provider/compat.ts +60 -0
  14. package/src/provider/create.tsx +20 -73
  15. package/src/remote/create.tsx +2 -4
  16. package/src/types.ts +0 -19
  17. package/src/utils/index.ts +20 -0
  18. package/vite.config.ts +0 -54
  19. package/dist/internal/bridge-base-CW88-1Be.es.js +0 -103
  20. package/dist/internal/bridge-base-DBiwuddQ.cjs.js +0 -119
  21. package/dist/internal/react-error-boundary.esm-CMdlkNPP.es.js +0 -99
  22. package/dist/internal/react-error-boundary.esm-D8nxmvmv.cjs.js +0 -98
  23. package/dist/legacy.cjs.js +0 -4
  24. package/dist/legacy.d.ts +0 -104
  25. package/dist/legacy.es.js +0 -4
  26. package/dist/v16.cjs.js +0 -22
  27. package/dist/v16.d.ts +0 -104
  28. package/dist/v16.es.js +0 -22
  29. package/dist/v18.cjs.js +0 -15
  30. package/dist/v18.d.ts +0 -105
  31. package/dist/v18.es.js +0 -15
  32. package/dist/v19.cjs.js +0 -15
  33. package/dist/v19.d.ts +0 -106
  34. package/dist/v19.es.js +0 -15
  35. package/src/legacy.ts +0 -13
  36. package/src/provider/versions/bridge-base.tsx +0 -122
  37. package/src/provider/versions/legacy.ts +0 -42
  38. package/src/provider/versions/v18.ts +0 -47
  39. package/src/provider/versions/v19.ts +0 -48
  40. package/src/v18.ts +0 -9
  41. package/src/v19.ts +0 -9
  42. /package/dist/{internal/context.cjs.js → context-C79iMWYD.cjs} +0 -0
  43. /package/dist/{internal/context.es.js → context-Dbqf0szX.js} +0 -0
@@ -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 "./internal/context.es.js";
3
+ import { R as RouterContext, L as LoggerInstance } from "./context-Dbqf0szX.js";
4
4
  export * from "react-router-dom/index.js";
5
5
  function WraperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
@@ -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/dist/index.js");
5
- const context = require("./internal/context.cjs.js");
5
+ const context = require("./context-C79iMWYD.cjs");
6
6
  const ReactRouterDom = require("react-router-dom/dist/index.js");
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -1,6 +1,6 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom$1 from "react-router-dom/dist/index.js";
3
- import { R as RouterContext, L as LoggerInstance } from "./internal/context.es.js";
3
+ import { R as RouterContext, L as LoggerInstance } from "./context-Dbqf0szX.js";
4
4
  export * from "react-router-dom/dist/index.js";
5
5
  function WraperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom = require("react-router-dom/");
5
- const context = require("./internal/context.cjs.js");
5
+ const context = require("./context-C79iMWYD.cjs");
6
6
  function _interopNamespaceDefault(e) {
7
7
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
8
  if (e) {
package/dist/router.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom from "react-router-dom/";
3
3
  export * from "react-router-dom/";
4
- import { R as RouterContext, L as LoggerInstance } from "./internal/context.es.js";
4
+ import { R as RouterContext, L as LoggerInstance } from "./context-Dbqf0szX.js";
5
5
  function WrapperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
7
7
  const routerContextProps = useContext(RouterContext) || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "0.0.0-next-20250410121036",
3
+ "version": "0.0.0-next-20250411200445",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,21 +21,6 @@
21
21
  "import": "./dist/index.es.js",
22
22
  "require": "./dist/index.cjs.js"
23
23
  },
24
- "./legacy": {
25
- "types": "./dist/legacy.d.ts",
26
- "import": "./dist/legacy.es.js",
27
- "require": "./dist/legacy.cjs.js"
28
- },
29
- "./v18": {
30
- "types": "./dist/v18.d.ts",
31
- "import": "./dist/v18.es.js",
32
- "require": "./dist/v18.cjs.js"
33
- },
34
- "./v19": {
35
- "types": "./dist/v19.d.ts",
36
- "import": "./dist/v19.es.js",
37
- "require": "./dist/v19.cjs.js"
38
- },
39
24
  "./router": {
40
25
  "types": "./dist/router.d.ts",
41
26
  "import": "./dist/router.es.js",
@@ -60,8 +45,8 @@
60
45
  },
61
46
  "dependencies": {
62
47
  "react-error-boundary": "^4.1.2",
63
- "@module-federation/bridge-shared": "0.0.0-next-20250410121036",
64
- "@module-federation/sdk": "0.0.0-next-20250410121036"
48
+ "@module-federation/bridge-shared": "0.0.0-next-20250411200445",
49
+ "@module-federation/sdk": "0.0.0-next-20250411200445"
65
50
  },
66
51
  "peerDependencies": {
67
52
  "react": ">=16.9.0",
@@ -82,7 +67,7 @@
82
67
  "typescript": "^5.2.2",
83
68
  "vite": "^5.4.12",
84
69
  "vite-plugin-dts": "^4.3.0",
85
- "@module-federation/runtime": "0.0.0-next-20250410121036"
70
+ "@module-federation/runtime": "0.0.0-next-20250411200445"
86
71
  },
87
72
  "scripts": {
88
73
  "dev": "vite",
package/src/index.ts CHANGED
@@ -6,9 +6,3 @@ export type {
6
6
  DestroyParams,
7
7
  RenderParams,
8
8
  } from './types';
9
-
10
- // 注意:对于特定React版本的支持,请使用以下导入路径:
11
- // - React 16/17: import { createBridgeComponent } from '@module-federation/bridge-react/legacy'
12
- // - React 18: import { createBridgeComponent } from '@module-federation/bridge-react/v18'
13
- // - React 19: import { createBridgeComponent } from '@module-federation/bridge-react/v19'
14
- // export * from './legacy';
@@ -0,0 +1,60 @@
1
+ import ReactDOM from 'react-dom';
2
+ import { CreateRootOptions, Root } from '../types';
3
+
4
+ // ReactDOM.version is only available in React 16.13.0 and later
5
+ const isReact18 = ReactDOM.version?.startsWith('18');
6
+
7
+ /**
8
+ * Creates a root for a container element compatible with both React 16 and 18
9
+ */
10
+ export function createRoot(
11
+ container: Element | DocumentFragment,
12
+ options?: CreateRootOptions,
13
+ ): Root {
14
+ if (isReact18) {
15
+ // For React 18, use the new createRoot API
16
+ // @ts-ignore - Types will be available in React 18
17
+ return (ReactDOM as any).createRoot(container, options);
18
+ }
19
+
20
+ // For React 16/17, simulate the new root API using render/unmountComponentAtNode
21
+ return {
22
+ render(children: React.ReactNode) {
23
+ ReactDOM.render(children, container);
24
+ },
25
+ unmount() {
26
+ ReactDOM.unmountComponentAtNode(container);
27
+ },
28
+ };
29
+ }
30
+
31
+ /**
32
+ * Hydrates a container compatible with both React 16 and 18
33
+ */
34
+ export function hydrateRoot(
35
+ container: Element | DocumentFragment,
36
+ initialChildren: React.ReactNode,
37
+ options?: CreateRootOptions,
38
+ ): Root {
39
+ if (isReact18) {
40
+ // For React 18, use the new hydrateRoot API
41
+ // @ts-ignore - Types will be available in React 18
42
+ return (ReactDOM as any).hydrateRoot(container, initialChildren, options);
43
+ }
44
+
45
+ // For React 16/17, simulate the new root API using hydrate/unmountComponentAtNode
46
+ return {
47
+ render(children: React.ReactNode) {
48
+ // For the initial render, use hydrate
49
+ if (children === initialChildren) {
50
+ ReactDOM.hydrate(children, container);
51
+ } else {
52
+ // For subsequent renders, use regular render
53
+ ReactDOM.render(children, container);
54
+ }
55
+ },
56
+ unmount() {
57
+ ReactDOM.unmountComponentAtNode(container);
58
+ },
59
+ };
60
+ }
@@ -6,63 +6,15 @@ import type {
6
6
  RootType,
7
7
  DestroyParams,
8
8
  RenderParams,
9
- CreateRootOptions,
10
9
  } from '../types';
11
- import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
10
+ import { ErrorBoundary } from 'react-error-boundary';
12
11
  import { RouterContext } from './context';
13
12
  import { LoggerInstance } from '../utils';
14
13
  import { federationRuntime } from './plugin';
14
+ import { createRoot as defaultCreateRoot } from './compat';
15
15
 
16
- /**
17
- * Default createRoot function that automatically detects React version and uses the appropriate API(only support React 16/17, 18)
18
- *
19
- * Note: Users can also directly import version-specific bridge components:
20
- * - import { createBridgeComponent } from '@module-federation/bridge-react/legacy'
21
- * - import { createBridgeComponent } from '@module-federation/bridge-react/v18'
22
- * - import { createBridgeComponent } from '@module-federation/bridge-react/v19'
23
- */
24
- function defaultCreateRoot(
25
- container: Element | DocumentFragment,
26
- options?: CreateRootOptions,
27
- ): {
28
- render(children: React.ReactNode): void;
29
- unmount(): void;
30
- } {
31
- const reactVersion = ReactDOM.version || '';
32
- const isReact18 = reactVersion.startsWith('18');
33
-
34
- // For React 18, use createRoot API
35
- if (isReact18) {
36
- try {
37
- // @ts-ignore - Types will be available in React 18
38
- return (ReactDOM as any).createRoot(container, options);
39
- } catch (e) {
40
- console.warn(
41
- 'Failed to use React 18 createRoot API, falling back to legacy API',
42
- e,
43
- );
44
- }
45
- }
46
-
47
- // For React 16/17, use legacy API
48
- return {
49
- render(children: React.ReactNode) {
50
- // @ts-ignore - React 17's render method is deprecated but still functional
51
- ReactDOM.render(children, container);
52
- },
53
- unmount() {
54
- ReactDOM.unmountComponentAtNode(container as Element);
55
- },
56
- };
57
- }
58
-
59
- /**
60
- * Creates a bridge component factory that automatically detects and uses
61
- * the appropriate React version (16/17, 18, or 19)
62
- */
63
16
  export function createBridgeComponent<T>({
64
17
  createRoot = defaultCreateRoot,
65
- defaultRootOptions,
66
18
  ...bridgeInfo
67
19
  }: ProviderFnParams<T>) {
68
20
  return () => {
@@ -96,23 +48,14 @@ export function createBridgeComponent<T>({
96
48
  basename,
97
49
  memoryRoute,
98
50
  fallback,
99
- rootOptions,
100
51
  ...propsInfo
101
52
  } = info;
102
53
 
103
- // Merge default root options with render-specific root options
104
- const mergedRootOptions: CreateRootOptions | undefined = {
105
- ...defaultRootOptions,
106
- ...(rootOptions as CreateRootOptions),
107
- };
108
-
109
54
  const beforeBridgeRenderRes =
110
55
  instance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(info) || {};
111
56
 
112
57
  const rootComponentWithErrorBoundary = (
113
- <ErrorBoundary
114
- FallbackComponent={fallback as React.ComponentType<FallbackProps>}
115
- >
58
+ <ErrorBoundary FallbackComponent={fallback}>
116
59
  <RawComponent
117
60
  appInfo={{
118
61
  moduleName,
@@ -120,25 +63,29 @@ export function createBridgeComponent<T>({
120
63
  memoryRoute,
121
64
  }}
122
65
  propsInfo={
123
- {
124
- ...propsInfo,
125
- ...(beforeBridgeRenderRes as any)?.extraProps,
126
- } as T
66
+ { ...propsInfo, ...beforeBridgeRenderRes?.extraProps } as T
127
67
  }
128
68
  />
129
69
  </ErrorBoundary>
130
70
  );
131
71
 
132
- let root = rootMap.get(dom);
133
- // Do not call createRoot multiple times
134
- if (!root) {
135
- root = createRoot(dom, mergedRootOptions);
136
- rootMap.set(dom, root);
137
- }
72
+ if (bridgeInfo.render) {
73
+ await Promise.resolve(
74
+ bridgeInfo.render(rootComponentWithErrorBoundary, dom),
75
+ ).then((root: RootType) => rootMap.set(dom, root));
76
+ } else {
77
+ let root = rootMap.get(dom);
78
+ // do not call createRoot multiple times
79
+ if (!root) {
80
+ root = createRoot(dom);
81
+ rootMap.set(dom, root);
82
+ }
138
83
 
139
- if ('render' in root) {
140
- root.render(rootComponentWithErrorBoundary);
84
+ if ('render' in root) {
85
+ root.render(rootComponentWithErrorBoundary);
86
+ }
141
87
  }
88
+
142
89
  instance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(info) || {};
143
90
  },
144
91
 
@@ -150,7 +97,7 @@ export function createBridgeComponent<T>({
150
97
  if ('unmount' in root) {
151
98
  root.unmount();
152
99
  } else {
153
- ReactDOM.unmountComponentAtNode(dom as HTMLElement);
100
+ ReactDOM.unmountComponentAtNode(root as HTMLElement);
154
101
  }
155
102
  rootMap.delete(dom);
156
103
  }
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef } from 'react';
2
- import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
2
+ import { ErrorBoundary } from 'react-error-boundary';
3
3
  import { LoggerInstance } from '../utils';
4
4
  import RemoteApp from './component';
5
5
  import {
@@ -77,9 +77,7 @@ export function createRemoteComponent<
77
77
  const LazyComponent = createLazyRemoteComponent(info);
78
78
  return forwardRef<HTMLDivElement, RemoteComponentProps>((props, ref) => {
79
79
  return (
80
- <ErrorBoundary
81
- FallbackComponent={info.fallback as React.ComponentType<FallbackProps>}
82
- >
80
+ <ErrorBoundary FallbackComponent={info.fallback}>
83
81
  <React.Suspense fallback={info.loading}>
84
82
  <LazyComponent {...props} ref={ref} />
85
83
  </React.Suspense>
package/src/types.ts CHANGED
@@ -34,15 +34,6 @@ export interface RenderParams {
34
34
  initialState?: Record<string, unknown>;
35
35
  };
36
36
  dom: HTMLElement;
37
- /**
38
- * Options to pass to createRoot for React 18 and 19
39
- * @example
40
- * {
41
- * identifierPrefix: 'app-',
42
- * onRecoverableError: (err) => console.error(err)
43
- * }
44
- */
45
- rootOptions?: CreateRootOptions;
46
37
  [key: string]: unknown;
47
38
  }
48
39
 
@@ -90,16 +81,6 @@ export interface ProviderFnParams<T> {
90
81
  container: Element | DocumentFragment,
91
82
  options?: CreateRootOptions,
92
83
  ) => Root;
93
- /**
94
- * Default options to pass to createRoot for React 18 and 19
95
- * These options will be used when creating a root unless overridden by rootOptions in render params
96
- * @example
97
- * {
98
- * identifierPrefix: 'app-',
99
- * onRecoverableError: (err) => console.error(err)
100
- * }
101
- */
102
- defaultRootOptions?: CreateRootOptions;
103
84
  }
104
85
 
105
86
  /**
@@ -1,9 +1,29 @@
1
+ import React from 'react';
1
2
  import { createLogger } from '@module-federation/sdk';
2
3
 
3
4
  export const LoggerInstance = createLogger(
4
5
  '[ Module Federation Bridge React ]',
5
6
  );
6
7
 
8
+ type typeReact = typeof React;
9
+
10
+ export function atLeastReact18(React: typeReact) {
11
+ if (
12
+ React &&
13
+ typeof React.version === 'string' &&
14
+ React.version.indexOf('.') >= 0
15
+ ) {
16
+ const majorVersionString = React.version.split('.')[0];
17
+ try {
18
+ return Number(majorVersionString) >= 18;
19
+ } catch (err) {
20
+ return false;
21
+ }
22
+ } else {
23
+ return false;
24
+ }
25
+ }
26
+
7
27
  export function pathJoin(...args: string[]) {
8
28
  const res = args.reduce((res, path: string) => {
9
29
  let nPath = path;
package/vite.config.ts CHANGED
@@ -4,53 +4,17 @@ import path from 'path';
4
4
  import dts from 'vite-plugin-dts';
5
5
  // import react from '@vitejs/plugin-react';
6
6
  import packageJson from './package.json';
7
- import fs from 'fs';
8
7
 
9
8
  const perDepsKeys = Object.keys(packageJson.peerDependencies);
10
9
 
11
10
  export default defineConfig({
12
11
  plugins: [
13
- // 添加我们的自定义插件
14
12
  dts({
15
13
  rollupTypes: true,
16
14
  bundledPackages: [
17
15
  '@module-federation/bridge-shared',
18
16
  'react-error-boundary',
19
17
  ],
20
- // 自定义类型声明文件的输出路径
21
- afterBuild: () => {
22
- // 确保provider目录存在
23
- if (!fs.existsSync('dist/provider')) {
24
- fs.mkdirSync('dist/provider', { recursive: true });
25
- }
26
-
27
- // 复制src/provider/versions中的类型声明文件到dist/provider目录
28
- const srcDir = path.resolve(__dirname, 'dist/provider/versions');
29
- const destDir = path.resolve(__dirname, 'dist/provider');
30
-
31
- if (fs.existsSync(srcDir)) {
32
- // 读取srcDir中的所有文件
33
- const files = fs.readdirSync(srcDir);
34
-
35
- // 复制每个v*.d.ts文件到destDir
36
- files.forEach((file) => {
37
- if (file.match(/^v\d+\.d\.ts$/)) {
38
- const srcFile = path.join(srcDir, file);
39
- const destFile = path.join(destDir, file);
40
-
41
- // 读取源文件内容
42
- const content = fs.readFileSync(srcFile, 'utf8');
43
-
44
- // 写入目标文件
45
- fs.writeFileSync(destFile, content);
46
-
47
- console.log(`Copied ${srcFile} to ${destFile}`);
48
- }
49
- });
50
- } else {
51
- console.warn(`Source directory ${srcDir} does not exist.`);
52
- }
53
- },
54
18
  }),
55
19
  ],
56
20
  build: {
@@ -61,10 +25,6 @@ export default defineConfig({
61
25
  router: path.resolve(__dirname, 'src/router/default.tsx'),
62
26
  'router-v5': path.resolve(__dirname, 'src/router/v5.tsx'),
63
27
  'router-v6': path.resolve(__dirname, 'src/router/v6.tsx'),
64
- v16: path.resolve(__dirname, 'src/legacy.ts'),
65
- legacy: path.resolve(__dirname, 'src/legacy.ts'),
66
- v18: path.resolve(__dirname, 'src/v18.ts'),
67
- v19: path.resolve(__dirname, 'src/v19.ts'),
68
28
  },
69
29
  formats: ['cjs', 'es'],
70
30
  fileName: (format, entryName) => `${entryName}.${format}.js`,
@@ -79,20 +39,6 @@ export default defineConfig({
79
39
  'react-router-dom/index.js',
80
40
  'react-router-dom/dist/index.js',
81
41
  ],
82
- output: {
83
- // 将共享chunk文件放在internal目录下,并使用更清晰的命名
84
- chunkFileNames: (chunkInfo) => {
85
- // 根据chunk的名称或内容确定一个更有意义的名称
86
- const name = chunkInfo.name;
87
- if (name.includes('context')) {
88
- return 'internal/context.[format].js';
89
- }
90
- if (name.includes('version-specific')) {
91
- return 'internal/version-specific.[format].js';
92
- }
93
- return 'internal/[name]-[hash].[format].js';
94
- },
95
- },
96
42
  plugins: [
97
43
  {
98
44
  name: 'modify-output-plugin',
@@ -1,103 +0,0 @@
1
- import * as React from "react";
2
- import { E as ErrorBoundary } from "./react-error-boundary.esm-CMdlkNPP.es.js";
3
- import { L as LoggerInstance, R as RouterContext } from "./context.es.js";
4
- import { federationRuntime } from "../plugin.es.js";
5
- function createBaseBridgeComponent({
6
- createRoot,
7
- defaultRootOptions,
8
- ...bridgeInfo
9
- }) {
10
- return () => {
11
- const rootMap = /* @__PURE__ */ new Map();
12
- const instance = federationRuntime.instance;
13
- LoggerInstance.debug(
14
- `createBridgeComponent instance from props >>>`,
15
- instance
16
- );
17
- const RawComponent = (info) => {
18
- const { appInfo, propsInfo, ...restProps } = info;
19
- const { moduleName, memoryRoute, basename = "/" } = appInfo;
20
- return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { moduleName, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(
21
- bridgeInfo.rootComponent,
22
- {
23
- ...propsInfo,
24
- basename,
25
- ...restProps
26
- }
27
- ));
28
- };
29
- return {
30
- async render(info) {
31
- var _a, _b, _c, _d, _e, _f;
32
- LoggerInstance.debug(`createBridgeComponent render Info`, info);
33
- const {
34
- moduleName,
35
- dom,
36
- basename,
37
- memoryRoute,
38
- fallback,
39
- rootOptions,
40
- ...propsInfo
41
- } = info;
42
- const mergedRootOptions = {
43
- ...defaultRootOptions,
44
- ...rootOptions
45
- };
46
- 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)) || {};
47
- const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(
48
- ErrorBoundary,
49
- {
50
- FallbackComponent: fallback
51
- },
52
- /* @__PURE__ */ React.createElement(
53
- RawComponent,
54
- {
55
- appInfo: {
56
- moduleName,
57
- basename,
58
- memoryRoute
59
- },
60
- propsInfo: {
61
- ...propsInfo,
62
- ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
63
- }
64
- }
65
- )
66
- );
67
- if (bridgeInfo.render) {
68
- await Promise.resolve(
69
- bridgeInfo.render(rootComponentWithErrorBoundary, dom)
70
- ).then((root) => rootMap.set(dom, root));
71
- } else {
72
- let root = rootMap.get(dom);
73
- if (!root && createRoot) {
74
- root = createRoot(dom, mergedRootOptions);
75
- rootMap.set(dom, root);
76
- }
77
- if (root && "render" in root) {
78
- root.render(rootComponentWithErrorBoundary);
79
- }
80
- }
81
- ((_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)) || {};
82
- },
83
- destroy(info) {
84
- var _a, _b, _c;
85
- const { dom } = info;
86
- LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
87
- const root = rootMap.get(dom);
88
- if (root) {
89
- if ("unmount" in root) {
90
- root.unmount();
91
- } else {
92
- console.warn("Root does not have unmount method");
93
- }
94
- rootMap.delete(dom);
95
- }
96
- (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
97
- }
98
- };
99
- };
100
- }
101
- export {
102
- createBaseBridgeComponent as c
103
- };