@module-federation/bridge-react 0.0.0-next-20250414091720 → 0.0.0-next-20250415111630

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/dist/index.es.js CHANGED
@@ -1,105 +1,10 @@
1
- var _a;
2
1
  import * as React from "react";
3
- import React__default, { createContext, Component, createElement, forwardRef, useRef, useState, useEffect, useContext } from "react";
2
+ import React__default, { forwardRef, useRef, useState, useEffect, useContext } from "react";
3
+ import { E as ErrorBoundary } from "./react-error-boundary.esm-CMdlkNPP.js";
4
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
- }
103
8
  function e() {
104
9
  const t = new PopStateEvent("popstate", { state: window.history.state });
105
10
  window.dispatchEvent(t);
@@ -127,8 +32,8 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
127
32
  providerInfoRef.current = providerReturn;
128
33
  setInitialized(true);
129
34
  return () => {
130
- var _a2, _b, _c, _d, _e, _f, _g, _h;
131
- if ((_a2 = providerInfoRef.current) == null ? void 0 : _a2.destroy) {
35
+ var _a, _b, _c, _d, _e, _f, _g, _h;
36
+ if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
132
37
  LoggerInstance.debug(
133
38
  `createRemoteComponent LazyComponent destroy >>>`,
134
39
  { moduleName, basename, dom: renderDom.current }
@@ -157,7 +62,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
157
62
  };
158
63
  }, [moduleName]);
159
64
  useEffect(() => {
160
- var _a2, _b, _c, _d, _e, _f;
65
+ var _a, _b, _c, _d, _e, _f;
161
66
  if (!initialized || !providerInfoRef.current) return;
162
67
  let renderProps = {
163
68
  moduleName,
@@ -168,7 +73,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
168
73
  ...resProps
169
74
  };
170
75
  renderDom.current = rootRef.current;
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)) || {};
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)) || {};
172
77
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
173
78
  providerInfoRef.current.render(renderProps);
174
79
  (_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);
@@ -177,8 +82,8 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
177
82
  return /* @__PURE__ */ React__default.createElement("div", { className: rootComponentClassName, style, ref: rootRef });
178
83
  });
179
84
  function withRouterData(WrappedComponent) {
180
- const Component2 = forwardRef(function(props, ref) {
181
- var _a2;
85
+ const Component = forwardRef(function(props, ref) {
86
+ var _a;
182
87
  if (props == null ? void 0 : props.basename) {
183
88
  return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
184
89
  }
@@ -211,7 +116,7 @@ function withRouterData(WrappedComponent) {
211
116
  const match = useRouteMatch == null ? void 0 : useRouteMatch();
212
117
  if (useHistory) {
213
118
  const history = useHistory == null ? void 0 : useHistory();
214
- basename = (_a2 = history == null ? void 0 : history.createHref) == null ? void 0 : _a2.call(history, { pathname: "/" });
119
+ basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: "/" });
215
120
  }
216
121
  if (match) {
217
122
  basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
@@ -244,7 +149,7 @@ function withRouterData(WrappedComponent) {
244
149
  return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename, ref });
245
150
  });
246
151
  return forwardRef(function(props, ref) {
247
- return /* @__PURE__ */ React__default.createElement(Component2, { ...props, ref });
152
+ return /* @__PURE__ */ React__default.createElement(Component, { ...props, ref });
248
153
  });
249
154
  }
250
155
  const RemoteApp = withRouterData(RemoteAppWrapper);
@@ -299,13 +204,27 @@ function createLazyRemoteComponent(info) {
299
204
  function createRemoteComponent(info) {
300
205
  const LazyComponent = createLazyRemoteComponent(info);
301
206
  return forwardRef((props, ref) => {
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 })));
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
+ );
303
214
  });
304
215
  }
305
- const isReact18 = (_a = ReactDOM.version) == null ? void 0 : _a.startsWith("18");
306
- function createRoot(container, options) {
216
+ function defaultCreateRoot(container, options) {
217
+ const reactVersion = ReactDOM.version || "";
218
+ const isReact18 = reactVersion.startsWith("18");
307
219
  if (isReact18) {
308
- return ReactDOM.createRoot(container, options);
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
+ }
309
228
  }
310
229
  return {
311
230
  render(children) {
@@ -317,7 +236,8 @@ function createRoot(container, options) {
317
236
  };
318
237
  }
319
238
  function createBridgeComponent({
320
- createRoot: createRoot$1 = createRoot,
239
+ createRoot = defaultCreateRoot,
240
+ defaultRootOptions,
321
241
  ...bridgeInfo
322
242
  }) {
323
243
  return () => {
@@ -341,7 +261,7 @@ function createBridgeComponent({
341
261
  };
342
262
  return {
343
263
  async render(info) {
344
- var _a2, _b, _c, _d, _e, _f;
264
+ var _a, _b, _c, _d, _e, _f;
345
265
  LoggerInstance.debug(`createBridgeComponent render Info`, info);
346
266
  const {
347
267
  moduleName,
@@ -349,38 +269,46 @@ function createBridgeComponent({
349
269
  basename,
350
270
  memoryRoute,
351
271
  fallback,
272
+ rootOptions,
352
273
  ...propsInfo
353
274
  } = info;
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,
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,
357
282
  {
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
- }
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);
379
307
  }
380
308
  ((_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)) || {};
381
309
  },
382
310
  destroy(info) {
383
- var _a2, _b, _c;
311
+ var _a, _b, _c;
384
312
  const { dom } = info;
385
313
  LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
386
314
  const root = rootMap.get(dom);
@@ -388,11 +316,11 @@ function createBridgeComponent({
388
316
  if ("unmount" in root) {
389
317
  root.unmount();
390
318
  } else {
391
- ReactDOM.unmountComponentAtNode(root);
319
+ ReactDOM.unmountComponentAtNode(dom);
392
320
  }
393
321
  rootMap.delete(dom);
394
322
  }
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);
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);
396
324
  }
397
325
  };
398
326
  };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const v16 = require("./v16.cjs.js");
4
+ exports.createBridgeComponent = v16.createBridgeComponent;
@@ -0,0 +1,104 @@
1
+ import * as React_2 from 'react';
2
+
3
+ export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
4
+ render(info: RenderParams): Promise<void>;
5
+ destroy(info: DestroyParams): void;
6
+ };
7
+
8
+ export declare interface CreateRootOptions {
9
+ identifierPrefix?: string;
10
+ onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
11
+ }
12
+
13
+ /**
14
+ * Options for creating a React root
15
+ */
16
+ declare interface CreateRootOptions_2 {
17
+ identifierPrefix?: string;
18
+ onRecoverableError?: (error: unknown) => void;
19
+ transitionCallbacks?: unknown;
20
+ }
21
+
22
+ /**
23
+ * Parameters for the destroy function
24
+ */
25
+ export declare interface DestroyParams {
26
+ moduleName: string;
27
+ dom: HTMLElement;
28
+ }
29
+
30
+ /**
31
+ * Parameters for the provider function
32
+ */
33
+ export declare interface ProviderFnParams<T> {
34
+ rootComponent: React_2.ComponentType<T>;
35
+ render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
36
+ createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions_2) => Root_2;
37
+ /**
38
+ * Default options to pass to createRoot for React 18 and 19
39
+ * These options will be used when creating a root unless overridden by rootOptions in render params
40
+ * @example
41
+ * {
42
+ * identifierPrefix: 'app-',
43
+ * onRecoverableError: (err) => console.error(err)
44
+ * }
45
+ */
46
+ defaultRootOptions?: CreateRootOptions_2;
47
+ }
48
+
49
+ /**
50
+ * Parameters for the provider function
51
+ */
52
+ export declare interface ProviderParams {
53
+ moduleName?: string;
54
+ basename?: string;
55
+ memoryRoute?: {
56
+ entryPath: string;
57
+ initialState?: Record<string, unknown>;
58
+ };
59
+ style?: React_2.CSSProperties;
60
+ className?: string;
61
+ }
62
+
63
+ /**
64
+ * Parameters for the render function
65
+ */
66
+ export declare interface RenderParams {
67
+ moduleName?: string;
68
+ basename?: string;
69
+ memoryRoute?: {
70
+ entryPath: string;
71
+ initialState?: Record<string, unknown>;
72
+ };
73
+ dom: HTMLElement;
74
+ /**
75
+ * Options to pass to createRoot for React 18 and 19
76
+ * @example
77
+ * {
78
+ * identifierPrefix: 'app-',
79
+ * onRecoverableError: (err) => console.error(err)
80
+ * }
81
+ */
82
+ rootOptions?: CreateRootOptions_2;
83
+ [key: string]: unknown;
84
+ }
85
+
86
+ export declare interface Root {
87
+ render(children: React.ReactNode): void;
88
+ unmount(): void;
89
+ }
90
+
91
+ /**
92
+ * Interface for a React root object
93
+ */
94
+ declare interface Root_2 {
95
+ render(children: React_2.ReactNode): void;
96
+ unmount(): void;
97
+ }
98
+
99
+ /**
100
+ * Type for a root element, which can be either an HTMLElement or a React root
101
+ */
102
+ export declare type RootType = HTMLElement | Root_2;
103
+
104
+ export { }
@@ -0,0 +1,4 @@
1
+ import { createBridgeComponent } from "./v16.es.js";
2
+ export {
3
+ createBridgeComponent
4
+ };
@@ -0,0 +1,99 @@
1
+ import { createContext, Component, createElement } from "react";
2
+ const ErrorBoundaryContext = createContext(null);
3
+ const initialState = {
4
+ didCatch: false,
5
+ error: null
6
+ };
7
+ class ErrorBoundary extends Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
11
+ this.state = initialState;
12
+ }
13
+ static getDerivedStateFromError(error) {
14
+ return {
15
+ didCatch: true,
16
+ error
17
+ };
18
+ }
19
+ resetErrorBoundary() {
20
+ const {
21
+ error
22
+ } = this.state;
23
+ if (error !== null) {
24
+ var _this$props$onReset, _this$props;
25
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
+ args[_key] = arguments[_key];
27
+ }
28
+ (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
29
+ args,
30
+ reason: "imperative-api"
31
+ });
32
+ this.setState(initialState);
33
+ }
34
+ }
35
+ componentDidCatch(error, info) {
36
+ var _this$props$onError, _this$props2;
37
+ (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
38
+ }
39
+ componentDidUpdate(prevProps, prevState) {
40
+ const {
41
+ didCatch
42
+ } = this.state;
43
+ const {
44
+ resetKeys
45
+ } = this.props;
46
+ if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
47
+ var _this$props$onReset2, _this$props3;
48
+ (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
49
+ next: resetKeys,
50
+ prev: prevProps.resetKeys,
51
+ reason: "keys"
52
+ });
53
+ this.setState(initialState);
54
+ }
55
+ }
56
+ render() {
57
+ const {
58
+ children,
59
+ fallbackRender,
60
+ FallbackComponent,
61
+ fallback
62
+ } = this.props;
63
+ const {
64
+ didCatch,
65
+ error
66
+ } = this.state;
67
+ let childToRender = children;
68
+ if (didCatch) {
69
+ const props = {
70
+ error,
71
+ resetErrorBoundary: this.resetErrorBoundary
72
+ };
73
+ if (typeof fallbackRender === "function") {
74
+ childToRender = fallbackRender(props);
75
+ } else if (FallbackComponent) {
76
+ childToRender = createElement(FallbackComponent, props);
77
+ } else if (fallback !== void 0) {
78
+ childToRender = fallback;
79
+ } else {
80
+ throw error;
81
+ }
82
+ }
83
+ return createElement(ErrorBoundaryContext.Provider, {
84
+ value: {
85
+ didCatch,
86
+ error,
87
+ resetErrorBoundary: this.resetErrorBoundary
88
+ }
89
+ }, childToRender);
90
+ }
91
+ }
92
+ function hasArrayChanged() {
93
+ let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
94
+ let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
95
+ return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
96
+ }
97
+ export {
98
+ ErrorBoundary as E
99
+ };
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ const React = require("react");
3
+ const ErrorBoundaryContext = React.createContext(null);
4
+ const initialState = {
5
+ didCatch: false,
6
+ error: null
7
+ };
8
+ class ErrorBoundary extends React.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
12
+ this.state = initialState;
13
+ }
14
+ static getDerivedStateFromError(error) {
15
+ return {
16
+ didCatch: true,
17
+ error
18
+ };
19
+ }
20
+ resetErrorBoundary() {
21
+ const {
22
+ error
23
+ } = this.state;
24
+ if (error !== null) {
25
+ var _this$props$onReset, _this$props;
26
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27
+ args[_key] = arguments[_key];
28
+ }
29
+ (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
30
+ args,
31
+ reason: "imperative-api"
32
+ });
33
+ this.setState(initialState);
34
+ }
35
+ }
36
+ componentDidCatch(error, info) {
37
+ var _this$props$onError, _this$props2;
38
+ (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
39
+ }
40
+ componentDidUpdate(prevProps, prevState) {
41
+ const {
42
+ didCatch
43
+ } = this.state;
44
+ const {
45
+ resetKeys
46
+ } = this.props;
47
+ if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
48
+ var _this$props$onReset2, _this$props3;
49
+ (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
50
+ next: resetKeys,
51
+ prev: prevProps.resetKeys,
52
+ reason: "keys"
53
+ });
54
+ this.setState(initialState);
55
+ }
56
+ }
57
+ render() {
58
+ const {
59
+ children,
60
+ fallbackRender,
61
+ FallbackComponent,
62
+ fallback
63
+ } = this.props;
64
+ const {
65
+ didCatch,
66
+ error
67
+ } = this.state;
68
+ let childToRender = children;
69
+ if (didCatch) {
70
+ const props = {
71
+ error,
72
+ resetErrorBoundary: this.resetErrorBoundary
73
+ };
74
+ if (typeof fallbackRender === "function") {
75
+ childToRender = fallbackRender(props);
76
+ } else if (FallbackComponent) {
77
+ childToRender = React.createElement(FallbackComponent, props);
78
+ } else if (fallback !== void 0) {
79
+ childToRender = fallback;
80
+ } else {
81
+ throw error;
82
+ }
83
+ }
84
+ return React.createElement(ErrorBoundaryContext.Provider, {
85
+ value: {
86
+ didCatch,
87
+ error,
88
+ resetErrorBoundary: this.resetErrorBoundary
89
+ }
90
+ }, childToRender);
91
+ }
92
+ }
93
+ function hasArrayChanged() {
94
+ let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
95
+ let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
96
+ return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
97
+ }
98
+ exports.ErrorBoundary = ErrorBoundary;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const bridgeBase = require("./bridge-base-BQcdOEoU.cjs");
4
+ const ReactDOM = require("react-dom");
5
+ function createReact16Or17Root(container) {
6
+ return {
7
+ render(children) {
8
+ ReactDOM.render(children, container);
9
+ },
10
+ unmount() {
11
+ ReactDOM.unmountComponentAtNode(container);
12
+ }
13
+ };
14
+ }
15
+ function createBridgeComponent(bridgeInfo) {
16
+ const fullBridgeInfo = {
17
+ ...bridgeInfo,
18
+ createRoot: createReact16Or17Root
19
+ };
20
+ return bridgeBase.createBaseBridgeComponent(fullBridgeInfo);
21
+ }
22
+ exports.createBridgeComponent = createBridgeComponent;