@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
package/CHANGELOG.md CHANGED
@@ -1,17 +1,13 @@
1
1
  # @module-federation/bridge-react
2
2
 
3
- ## 0.0.0-next-20250410121036
4
-
5
- ### Minor Changes
6
-
7
- - d802e00: feat(react-bridge): Add native support for React 19 in bridge-react with enhanced createRoot options
3
+ ## 0.0.0-next-20250411200445
8
4
 
9
5
  ### Patch Changes
10
6
 
11
- - d0a11ff: feat(bridge-react): support react v19 in react compat file.
7
+ - Updated dependencies [6ce82d3]
12
8
  - Updated dependencies [f4fb242]
13
- - @module-federation/sdk@0.0.0-next-20250410121036
14
- - @module-federation/bridge-shared@0.0.0-next-20250410121036
9
+ - @module-federation/sdk@0.0.0-next-20250411200445
10
+ - @module-federation/bridge-shared@0.0.0-next-20250411200445
15
11
 
16
12
  ## 0.11.4
17
13
 
package/dist/index.cjs.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
4
  const React = require("react");
4
- const reactErrorBoundary_esm = require("./internal/react-error-boundary.esm-D8nxmvmv.cjs.js");
5
- const context = require("./internal/context.cjs.js");
5
+ const context = require("./context-C79iMWYD.cjs");
6
6
  const ReactRouterDOM = require("react-router-dom");
7
7
  const plugin = require("./plugin.cjs.js");
8
8
  const ReactDOM = require("react-dom");
@@ -24,6 +24,101 @@ function _interopNamespaceDefault(e2) {
24
24
  }
25
25
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
26
26
  const ReactRouterDOM__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDOM);
27
+ const ErrorBoundaryContext = React.createContext(null);
28
+ const initialState = {
29
+ didCatch: false,
30
+ error: null
31
+ };
32
+ class ErrorBoundary extends React.Component {
33
+ constructor(props) {
34
+ super(props);
35
+ this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
36
+ this.state = initialState;
37
+ }
38
+ static getDerivedStateFromError(error) {
39
+ return {
40
+ didCatch: true,
41
+ error
42
+ };
43
+ }
44
+ resetErrorBoundary() {
45
+ const {
46
+ error
47
+ } = this.state;
48
+ if (error !== null) {
49
+ var _this$props$onReset, _this$props;
50
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
51
+ args[_key] = arguments[_key];
52
+ }
53
+ (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
54
+ args,
55
+ reason: "imperative-api"
56
+ });
57
+ this.setState(initialState);
58
+ }
59
+ }
60
+ componentDidCatch(error, info) {
61
+ var _this$props$onError, _this$props2;
62
+ (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
63
+ }
64
+ componentDidUpdate(prevProps, prevState) {
65
+ const {
66
+ didCatch
67
+ } = this.state;
68
+ const {
69
+ resetKeys
70
+ } = this.props;
71
+ if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
72
+ var _this$props$onReset2, _this$props3;
73
+ (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
74
+ next: resetKeys,
75
+ prev: prevProps.resetKeys,
76
+ reason: "keys"
77
+ });
78
+ this.setState(initialState);
79
+ }
80
+ }
81
+ render() {
82
+ const {
83
+ children,
84
+ fallbackRender,
85
+ FallbackComponent,
86
+ fallback
87
+ } = this.props;
88
+ const {
89
+ didCatch,
90
+ error
91
+ } = this.state;
92
+ let childToRender = children;
93
+ if (didCatch) {
94
+ const props = {
95
+ error,
96
+ resetErrorBoundary: this.resetErrorBoundary
97
+ };
98
+ if (typeof fallbackRender === "function") {
99
+ childToRender = fallbackRender(props);
100
+ } else if (FallbackComponent) {
101
+ childToRender = React.createElement(FallbackComponent, props);
102
+ } else if (fallback !== void 0) {
103
+ childToRender = fallback;
104
+ } else {
105
+ throw error;
106
+ }
107
+ }
108
+ return React.createElement(ErrorBoundaryContext.Provider, {
109
+ value: {
110
+ didCatch,
111
+ error,
112
+ resetErrorBoundary: this.resetErrorBoundary
113
+ }
114
+ }, childToRender);
115
+ }
116
+ }
117
+ function hasArrayChanged() {
118
+ let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
119
+ let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
120
+ return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
121
+ }
27
122
  function e() {
28
123
  const t = new PopStateEvent("popstate", { state: window.history.state });
29
124
  window.dispatchEvent(t);
@@ -51,8 +146,8 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
51
146
  providerInfoRef.current = providerReturn;
52
147
  setInitialized(true);
53
148
  return () => {
54
- var _a, _b, _c, _d, _e, _f, _g, _h;
55
- if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
149
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
150
+ if ((_a2 = providerInfoRef.current) == null ? void 0 : _a2.destroy) {
56
151
  context.LoggerInstance.debug(
57
152
  `createRemoteComponent LazyComponent destroy >>>`,
58
153
  { moduleName, basename, dom: renderDom.current }
@@ -81,7 +176,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
81
176
  };
82
177
  }, [moduleName]);
83
178
  React.useEffect(() => {
84
- var _a, _b, _c, _d, _e, _f;
179
+ var _a2, _b, _c, _d, _e, _f;
85
180
  if (!initialized || !providerInfoRef.current) return;
86
181
  let renderProps = {
87
182
  moduleName,
@@ -92,7 +187,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
92
187
  ...resProps
93
188
  };
94
189
  renderDom.current = rootRef.current;
95
- 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)) || {};
190
+ const beforeBridgeRenderRes = ((_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
96
191
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
97
192
  providerInfoRef.current.render(renderProps);
98
193
  (_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);
@@ -102,7 +197,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
102
197
  });
103
198
  function withRouterData(WrappedComponent) {
104
199
  const Component = React.forwardRef(function(props, ref) {
105
- var _a;
200
+ var _a2;
106
201
  if (props == null ? void 0 : props.basename) {
107
202
  return /* @__PURE__ */ React.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
108
203
  }
@@ -135,7 +230,7 @@ function withRouterData(WrappedComponent) {
135
230
  const match = useRouteMatch == null ? void 0 : useRouteMatch();
136
231
  if (useHistory) {
137
232
  const history = useHistory == null ? void 0 : useHistory();
138
- basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: "/" });
233
+ basename = (_a2 = history == null ? void 0 : history.createHref) == null ? void 0 : _a2.call(history, { pathname: "/" });
139
234
  }
140
235
  if (match) {
141
236
  basename = context.pathJoin(basename, (match == null ? void 0 : match.path) || "/");
@@ -223,27 +318,13 @@ function createLazyRemoteComponent(info) {
223
318
  function createRemoteComponent(info) {
224
319
  const LazyComponent = createLazyRemoteComponent(info);
225
320
  return React.forwardRef((props, ref) => {
226
- return /* @__PURE__ */ React.createElement(
227
- reactErrorBoundary_esm.ErrorBoundary,
228
- {
229
- FallbackComponent: info.fallback
230
- },
231
- /* @__PURE__ */ React.createElement(React.Suspense, { fallback: info.loading }, /* @__PURE__ */ React.createElement(LazyComponent, { ...props, ref }))
232
- );
321
+ return /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: info.fallback }, /* @__PURE__ */ React.createElement(React.Suspense, { fallback: info.loading }, /* @__PURE__ */ React.createElement(LazyComponent, { ...props, ref })));
233
322
  });
234
323
  }
235
- function defaultCreateRoot(container, options) {
236
- const reactVersion = ReactDOM.version || "";
237
- const isReact18 = reactVersion.startsWith("18");
324
+ const isReact18 = (_a = ReactDOM.version) == null ? void 0 : _a.startsWith("18");
325
+ function createRoot(container, options) {
238
326
  if (isReact18) {
239
- try {
240
- return ReactDOM.createRoot(container, options);
241
- } catch (e2) {
242
- console.warn(
243
- "Failed to use React 18 createRoot API, falling back to legacy API",
244
- e2
245
- );
246
- }
327
+ return ReactDOM.createRoot(container, options);
247
328
  }
248
329
  return {
249
330
  render(children) {
@@ -255,8 +336,7 @@ function defaultCreateRoot(container, options) {
255
336
  };
256
337
  }
257
338
  function createBridgeComponent({
258
- createRoot = defaultCreateRoot,
259
- defaultRootOptions,
339
+ createRoot: createRoot$1 = createRoot,
260
340
  ...bridgeInfo
261
341
  }) {
262
342
  return () => {
@@ -280,7 +360,7 @@ function createBridgeComponent({
280
360
  };
281
361
  return {
282
362
  async render(info) {
283
- var _a, _b, _c, _d, _e, _f;
363
+ var _a2, _b, _c, _d, _e, _f;
284
364
  context.LoggerInstance.debug(`createBridgeComponent render Info`, info);
285
365
  const {
286
366
  moduleName,
@@ -288,46 +368,38 @@ function createBridgeComponent({
288
368
  basename,
289
369
  memoryRoute,
290
370
  fallback,
291
- rootOptions,
292
371
  ...propsInfo
293
372
  } = info;
294
- const mergedRootOptions = {
295
- ...defaultRootOptions,
296
- ...rootOptions
297
- };
298
- 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)) || {};
299
- const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(
300
- reactErrorBoundary_esm.ErrorBoundary,
373
+ const beforeBridgeRenderRes = ((_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
374
+ const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(ErrorBoundary, { FallbackComponent: fallback }, /* @__PURE__ */ React__namespace.createElement(
375
+ RawComponent,
301
376
  {
302
- FallbackComponent: fallback
303
- },
304
- /* @__PURE__ */ React__namespace.createElement(
305
- RawComponent,
306
- {
307
- appInfo: {
308
- moduleName,
309
- basename,
310
- memoryRoute
311
- },
312
- propsInfo: {
313
- ...propsInfo,
314
- ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
315
- }
316
- }
317
- )
318
- );
319
- let root = rootMap.get(dom);
320
- if (!root) {
321
- root = createRoot(dom, mergedRootOptions);
322
- rootMap.set(dom, root);
323
- }
324
- if ("render" in root) {
325
- root.render(rootComponentWithErrorBoundary);
377
+ appInfo: {
378
+ moduleName,
379
+ basename,
380
+ memoryRoute
381
+ },
382
+ propsInfo: { ...propsInfo, ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps }
383
+ }
384
+ ));
385
+ if (bridgeInfo.render) {
386
+ await Promise.resolve(
387
+ bridgeInfo.render(rootComponentWithErrorBoundary, dom)
388
+ ).then((root) => rootMap.set(dom, root));
389
+ } else {
390
+ let root = rootMap.get(dom);
391
+ if (!root) {
392
+ root = createRoot$1(dom);
393
+ rootMap.set(dom, root);
394
+ }
395
+ if ("render" in root) {
396
+ root.render(rootComponentWithErrorBoundary);
397
+ }
326
398
  }
327
399
  ((_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)) || {};
328
400
  },
329
401
  destroy(info) {
330
- var _a, _b, _c;
402
+ var _a2, _b, _c;
331
403
  const { dom } = info;
332
404
  context.LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
333
405
  const root = rootMap.get(dom);
@@ -335,11 +407,11 @@ function createBridgeComponent({
335
407
  if ("unmount" in root) {
336
408
  root.unmount();
337
409
  } else {
338
- ReactDOM.unmountComponentAtNode(dom);
410
+ ReactDOM.unmountComponentAtNode(root);
339
411
  }
340
412
  rootMap.delete(dom);
341
413
  }
342
- (_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);
414
+ (_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
343
415
  }
344
416
  };
345
417
  };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,7 @@
1
1
  import { default as default_2 } from 'react';
2
2
  import * as React_2 from 'react';
3
3
 
4
- /**
5
- * Creates a bridge component factory that automatically detects and uses
6
- * the appropriate React version (16/17, 18, or 19)
7
- */
8
- export declare function createBridgeComponent<T>({ createRoot, defaultRootOptions, ...bridgeInfo }: ProviderFnParams<T>): () => {
4
+ export declare function createBridgeComponent<T>({ createRoot, ...bridgeInfo }: ProviderFnParams<T>): () => {
9
5
  render(info: RenderParams): Promise<void>;
10
6
  destroy(info: DestroyParams): void;
11
7
  };
@@ -38,16 +34,6 @@ declare interface ProviderFnParams<T> {
38
34
  rootComponent: React_2.ComponentType<T>;
39
35
  render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
40
36
  createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions) => Root;
41
- /**
42
- * Default options to pass to createRoot for React 18 and 19
43
- * These options will be used when creating a root unless overridden by rootOptions in render params
44
- * @example
45
- * {
46
- * identifierPrefix: 'app-',
47
- * onRecoverableError: (err) => console.error(err)
48
- * }
49
- */
50
- defaultRootOptions?: CreateRootOptions;
51
37
  }
52
38
 
53
39
  /**
@@ -111,15 +97,6 @@ export declare interface RenderParams {
111
97
  initialState?: Record<string, unknown>;
112
98
  };
113
99
  dom: HTMLElement;
114
- /**
115
- * Options to pass to createRoot for React 18 and 19
116
- * @example
117
- * {
118
- * identifierPrefix: 'app-',
119
- * onRecoverableError: (err) => console.error(err)
120
- * }
121
- */
122
- rootOptions?: CreateRootOptions;
123
100
  [key: string]: unknown;
124
101
  }
125
102
 
package/dist/index.es.js CHANGED
@@ -1,10 +1,105 @@
1
+ var _a;
1
2
  import * as React from "react";
2
- import React__default, { forwardRef, useRef, useState, useEffect, useContext } from "react";
3
- import { E as ErrorBoundary } from "./internal/react-error-boundary.esm-CMdlkNPP.es.js";
4
- import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, R as RouterContext } from "./internal/context.es.js";
3
+ import React__default, { createContext, Component, createElement, forwardRef, useRef, useState, useEffect, useContext } from "react";
4
+ import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, R as RouterContext } from "./context-Dbqf0szX.js";
5
5
  import * as ReactRouterDOM from "react-router-dom";
6
6
  import { federationRuntime } from "./plugin.es.js";
7
7
  import ReactDOM from "react-dom";
8
+ const ErrorBoundaryContext = createContext(null);
9
+ const initialState = {
10
+ didCatch: false,
11
+ error: null
12
+ };
13
+ class ErrorBoundary extends Component {
14
+ constructor(props) {
15
+ super(props);
16
+ this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
17
+ this.state = initialState;
18
+ }
19
+ static getDerivedStateFromError(error) {
20
+ return {
21
+ didCatch: true,
22
+ error
23
+ };
24
+ }
25
+ resetErrorBoundary() {
26
+ const {
27
+ error
28
+ } = this.state;
29
+ if (error !== null) {
30
+ var _this$props$onReset, _this$props;
31
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32
+ args[_key] = arguments[_key];
33
+ }
34
+ (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
35
+ args,
36
+ reason: "imperative-api"
37
+ });
38
+ this.setState(initialState);
39
+ }
40
+ }
41
+ componentDidCatch(error, info) {
42
+ var _this$props$onError, _this$props2;
43
+ (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
44
+ }
45
+ componentDidUpdate(prevProps, prevState) {
46
+ const {
47
+ didCatch
48
+ } = this.state;
49
+ const {
50
+ resetKeys
51
+ } = this.props;
52
+ if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
53
+ var _this$props$onReset2, _this$props3;
54
+ (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
55
+ next: resetKeys,
56
+ prev: prevProps.resetKeys,
57
+ reason: "keys"
58
+ });
59
+ this.setState(initialState);
60
+ }
61
+ }
62
+ render() {
63
+ const {
64
+ children,
65
+ fallbackRender,
66
+ FallbackComponent,
67
+ fallback
68
+ } = this.props;
69
+ const {
70
+ didCatch,
71
+ error
72
+ } = this.state;
73
+ let childToRender = children;
74
+ if (didCatch) {
75
+ const props = {
76
+ error,
77
+ resetErrorBoundary: this.resetErrorBoundary
78
+ };
79
+ if (typeof fallbackRender === "function") {
80
+ childToRender = fallbackRender(props);
81
+ } else if (FallbackComponent) {
82
+ childToRender = createElement(FallbackComponent, props);
83
+ } else if (fallback !== void 0) {
84
+ childToRender = fallback;
85
+ } else {
86
+ throw error;
87
+ }
88
+ }
89
+ return createElement(ErrorBoundaryContext.Provider, {
90
+ value: {
91
+ didCatch,
92
+ error,
93
+ resetErrorBoundary: this.resetErrorBoundary
94
+ }
95
+ }, childToRender);
96
+ }
97
+ }
98
+ function hasArrayChanged() {
99
+ let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
100
+ let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
101
+ return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
102
+ }
8
103
  function e() {
9
104
  const t = new PopStateEvent("popstate", { state: window.history.state });
10
105
  window.dispatchEvent(t);
@@ -32,8 +127,8 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
32
127
  providerInfoRef.current = providerReturn;
33
128
  setInitialized(true);
34
129
  return () => {
35
- var _a, _b, _c, _d, _e, _f, _g, _h;
36
- if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
130
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
131
+ if ((_a2 = providerInfoRef.current) == null ? void 0 : _a2.destroy) {
37
132
  LoggerInstance.debug(
38
133
  `createRemoteComponent LazyComponent destroy >>>`,
39
134
  { moduleName, basename, dom: renderDom.current }
@@ -62,7 +157,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
62
157
  };
63
158
  }, [moduleName]);
64
159
  useEffect(() => {
65
- var _a, _b, _c, _d, _e, _f;
160
+ var _a2, _b, _c, _d, _e, _f;
66
161
  if (!initialized || !providerInfoRef.current) return;
67
162
  let renderProps = {
68
163
  moduleName,
@@ -73,7 +168,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
73
168
  ...resProps
74
169
  };
75
170
  renderDom.current = rootRef.current;
76
- 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)) || {};
171
+ const beforeBridgeRenderRes = ((_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
77
172
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
78
173
  providerInfoRef.current.render(renderProps);
79
174
  (_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);
@@ -82,8 +177,8 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
82
177
  return /* @__PURE__ */ React__default.createElement("div", { className: rootComponentClassName, style, ref: rootRef });
83
178
  });
84
179
  function withRouterData(WrappedComponent) {
85
- const Component = forwardRef(function(props, ref) {
86
- var _a;
180
+ const Component2 = forwardRef(function(props, ref) {
181
+ var _a2;
87
182
  if (props == null ? void 0 : props.basename) {
88
183
  return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
89
184
  }
@@ -116,7 +211,7 @@ function withRouterData(WrappedComponent) {
116
211
  const match = useRouteMatch == null ? void 0 : useRouteMatch();
117
212
  if (useHistory) {
118
213
  const history = useHistory == null ? void 0 : useHistory();
119
- basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: "/" });
214
+ basename = (_a2 = history == null ? void 0 : history.createHref) == null ? void 0 : _a2.call(history, { pathname: "/" });
120
215
  }
121
216
  if (match) {
122
217
  basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
@@ -149,7 +244,7 @@ function withRouterData(WrappedComponent) {
149
244
  return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename, ref });
150
245
  });
151
246
  return forwardRef(function(props, ref) {
152
- return /* @__PURE__ */ React__default.createElement(Component, { ...props, ref });
247
+ return /* @__PURE__ */ React__default.createElement(Component2, { ...props, ref });
153
248
  });
154
249
  }
155
250
  const RemoteApp = withRouterData(RemoteAppWrapper);
@@ -204,27 +299,13 @@ function createLazyRemoteComponent(info) {
204
299
  function createRemoteComponent(info) {
205
300
  const LazyComponent = createLazyRemoteComponent(info);
206
301
  return forwardRef((props, ref) => {
207
- return /* @__PURE__ */ React__default.createElement(
208
- ErrorBoundary,
209
- {
210
- FallbackComponent: info.fallback
211
- },
212
- /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref }))
213
- );
302
+ 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 })));
214
303
  });
215
304
  }
216
- function defaultCreateRoot(container, options) {
217
- const reactVersion = ReactDOM.version || "";
218
- const isReact18 = reactVersion.startsWith("18");
305
+ const isReact18 = (_a = ReactDOM.version) == null ? void 0 : _a.startsWith("18");
306
+ function createRoot(container, options) {
219
307
  if (isReact18) {
220
- try {
221
- return ReactDOM.createRoot(container, options);
222
- } catch (e2) {
223
- console.warn(
224
- "Failed to use React 18 createRoot API, falling back to legacy API",
225
- e2
226
- );
227
- }
308
+ return ReactDOM.createRoot(container, options);
228
309
  }
229
310
  return {
230
311
  render(children) {
@@ -236,8 +317,7 @@ function defaultCreateRoot(container, options) {
236
317
  };
237
318
  }
238
319
  function createBridgeComponent({
239
- createRoot = defaultCreateRoot,
240
- defaultRootOptions,
320
+ createRoot: createRoot$1 = createRoot,
241
321
  ...bridgeInfo
242
322
  }) {
243
323
  return () => {
@@ -261,7 +341,7 @@ function createBridgeComponent({
261
341
  };
262
342
  return {
263
343
  async render(info) {
264
- var _a, _b, _c, _d, _e, _f;
344
+ var _a2, _b, _c, _d, _e, _f;
265
345
  LoggerInstance.debug(`createBridgeComponent render Info`, info);
266
346
  const {
267
347
  moduleName,
@@ -269,46 +349,38 @@ function createBridgeComponent({
269
349
  basename,
270
350
  memoryRoute,
271
351
  fallback,
272
- rootOptions,
273
352
  ...propsInfo
274
353
  } = info;
275
- const mergedRootOptions = {
276
- ...defaultRootOptions,
277
- ...rootOptions
278
- };
279
- 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)) || {};
280
- const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(
281
- ErrorBoundary,
354
+ const beforeBridgeRenderRes = ((_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
355
+ const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: fallback }, /* @__PURE__ */ React.createElement(
356
+ RawComponent,
282
357
  {
283
- FallbackComponent: fallback
284
- },
285
- /* @__PURE__ */ React.createElement(
286
- RawComponent,
287
- {
288
- appInfo: {
289
- moduleName,
290
- basename,
291
- memoryRoute
292
- },
293
- propsInfo: {
294
- ...propsInfo,
295
- ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
296
- }
297
- }
298
- )
299
- );
300
- let root = rootMap.get(dom);
301
- if (!root) {
302
- root = createRoot(dom, mergedRootOptions);
303
- rootMap.set(dom, root);
304
- }
305
- if ("render" in root) {
306
- root.render(rootComponentWithErrorBoundary);
358
+ appInfo: {
359
+ moduleName,
360
+ basename,
361
+ memoryRoute
362
+ },
363
+ propsInfo: { ...propsInfo, ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps }
364
+ }
365
+ ));
366
+ if (bridgeInfo.render) {
367
+ await Promise.resolve(
368
+ bridgeInfo.render(rootComponentWithErrorBoundary, dom)
369
+ ).then((root) => rootMap.set(dom, root));
370
+ } else {
371
+ let root = rootMap.get(dom);
372
+ if (!root) {
373
+ root = createRoot$1(dom);
374
+ rootMap.set(dom, root);
375
+ }
376
+ if ("render" in root) {
377
+ root.render(rootComponentWithErrorBoundary);
378
+ }
307
379
  }
308
380
  ((_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)) || {};
309
381
  },
310
382
  destroy(info) {
311
- var _a, _b, _c;
383
+ var _a2, _b, _c;
312
384
  const { dom } = info;
313
385
  LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
314
386
  const root = rootMap.get(dom);
@@ -316,11 +388,11 @@ function createBridgeComponent({
316
388
  if ("unmount" in root) {
317
389
  root.unmount();
318
390
  } else {
319
- ReactDOM.unmountComponentAtNode(dom);
391
+ ReactDOM.unmountComponentAtNode(root);
320
392
  }
321
393
  rootMap.delete(dom);
322
394
  }
323
- (_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);
395
+ (_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
324
396
  }
325
397
  };
326
398
  };
@@ -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("./internal/context.cjs.js");
5
+ const context = require("./context-C79iMWYD.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" } });