@module-federation/bridge-react 0.12.0 → 0.13.1
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 +23 -0
- package/dist/bridge-base-0CS6p-6-.js +199 -0
- package/dist/bridge-base-DIOcSEVT.cjs +214 -0
- package/dist/index.cjs.js +51 -206
- package/dist/index.d.ts +35 -17
- package/dist/index.es.js +44 -199
- package/dist/router-v5.cjs.js +3 -3
- package/dist/router-v5.es.js +1 -1
- package/dist/router-v6.cjs.js +5 -5
- package/dist/router-v6.es.js +1 -1
- package/dist/router.cjs.js +5 -5
- package/dist/router.es.js +1 -1
- package/dist/v18.cjs.js +15 -0
- package/dist/v18.d.ts +105 -0
- package/dist/v18.es.js +15 -0
- package/dist/v19.cjs.js +15 -0
- package/dist/v19.d.ts +106 -0
- package/dist/v19.es.js +15 -0
- package/package.json +15 -5
- package/src/index.ts +8 -2
- package/src/provider/{create.tsx → versions/bridge-base.tsx} +32 -18
- package/src/provider/versions/legacy.ts +86 -0
- package/src/provider/versions/v18.ts +47 -0
- package/src/provider/versions/v19.ts +48 -0
- package/src/remote/create.tsx +4 -2
- package/src/types.ts +19 -0
- package/src/utils/index.ts +0 -20
- package/src/v18.ts +9 -0
- package/src/v19.ts +9 -0
- package/vite.config.ts +3 -2
- package/src/provider/compat.ts +0 -60
- package/dist/{context-C79iMWYD.cjs → index-BYDWxFmi.cjs} +1 -1
- package/dist/{context-Dbqf0szX.js → index-BlBMQSoq.js} +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,104 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import React__default, {
|
|
4
|
-
import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin
|
|
1
|
+
import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-0CS6p-6-.js";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
import React__default, { forwardRef, useRef, useState, useEffect, useContext } from "react";
|
|
4
|
+
import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin } from "./index-BlBMQSoq.js";
|
|
5
5
|
import * as ReactRouterDOM from "react-router-dom";
|
|
6
6
|
import { federationRuntime } from "./plugin.es.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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];
|
|
7
|
+
function createReact16Or17Root(container) {
|
|
8
|
+
return {
|
|
9
|
+
render(children) {
|
|
10
|
+
const reactVersion = ReactDOM.version || "";
|
|
11
|
+
const isReact18 = reactVersion.startsWith("18");
|
|
12
|
+
const isReact19 = reactVersion.startsWith("19");
|
|
13
|
+
if (isReact19) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`React 19 detected in legacy mode. This is not supported. Please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v19'`
|
|
16
|
+
);
|
|
33
17
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
18
|
+
if (isReact18) {
|
|
19
|
+
console.warn(
|
|
20
|
+
`[Bridge-React] React 18 detected in legacy mode. For better compatibility, please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v18'`
|
|
21
|
+
);
|
|
87
22
|
}
|
|
23
|
+
ReactDOM.render(children, container);
|
|
24
|
+
},
|
|
25
|
+
unmount() {
|
|
26
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
88
27
|
}
|
|
89
|
-
|
|
90
|
-
value: {
|
|
91
|
-
didCatch,
|
|
92
|
-
error,
|
|
93
|
-
resetErrorBoundary: this.resetErrorBoundary
|
|
94
|
-
}
|
|
95
|
-
}, childToRender);
|
|
96
|
-
}
|
|
28
|
+
};
|
|
97
29
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
30
|
+
function createBridgeComponent(bridgeInfo) {
|
|
31
|
+
const fullBridgeInfo = {
|
|
32
|
+
createRoot: createReact16Or17Root,
|
|
33
|
+
...bridgeInfo
|
|
34
|
+
};
|
|
35
|
+
return createBaseBridgeComponent(fullBridgeInfo);
|
|
102
36
|
}
|
|
103
37
|
function e() {
|
|
104
38
|
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
@@ -127,8 +61,8 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
127
61
|
providerInfoRef.current = providerReturn;
|
|
128
62
|
setInitialized(true);
|
|
129
63
|
return () => {
|
|
130
|
-
var
|
|
131
|
-
if ((
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
65
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
132
66
|
LoggerInstance.debug(
|
|
133
67
|
`createRemoteComponent LazyComponent destroy >>>`,
|
|
134
68
|
{ moduleName, basename, dom: renderDom.current }
|
|
@@ -157,7 +91,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
157
91
|
};
|
|
158
92
|
}, [moduleName]);
|
|
159
93
|
useEffect(() => {
|
|
160
|
-
var
|
|
94
|
+
var _a, _b, _c, _d, _e, _f;
|
|
161
95
|
if (!initialized || !providerInfoRef.current) return;
|
|
162
96
|
let renderProps = {
|
|
163
97
|
moduleName,
|
|
@@ -168,7 +102,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
168
102
|
...resProps
|
|
169
103
|
};
|
|
170
104
|
renderDom.current = rootRef.current;
|
|
171
|
-
const beforeBridgeRenderRes = ((_c = (_b = (
|
|
105
|
+
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
106
|
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
173
107
|
providerInfoRef.current.render(renderProps);
|
|
174
108
|
(_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 +111,8 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
177
111
|
return /* @__PURE__ */ React__default.createElement("div", { className: rootComponentClassName, style, ref: rootRef });
|
|
178
112
|
});
|
|
179
113
|
function withRouterData(WrappedComponent) {
|
|
180
|
-
const
|
|
181
|
-
var
|
|
114
|
+
const Component = forwardRef(function(props, ref) {
|
|
115
|
+
var _a;
|
|
182
116
|
if (props == null ? void 0 : props.basename) {
|
|
183
117
|
return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
|
|
184
118
|
}
|
|
@@ -211,7 +145,7 @@ function withRouterData(WrappedComponent) {
|
|
|
211
145
|
const match = useRouteMatch == null ? void 0 : useRouteMatch();
|
|
212
146
|
if (useHistory) {
|
|
213
147
|
const history = useHistory == null ? void 0 : useHistory();
|
|
214
|
-
basename = (
|
|
148
|
+
basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: "/" });
|
|
215
149
|
}
|
|
216
150
|
if (match) {
|
|
217
151
|
basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
|
|
@@ -244,7 +178,7 @@ function withRouterData(WrappedComponent) {
|
|
|
244
178
|
return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename, ref });
|
|
245
179
|
});
|
|
246
180
|
return forwardRef(function(props, ref) {
|
|
247
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
181
|
+
return /* @__PURE__ */ React__default.createElement(Component, { ...props, ref });
|
|
248
182
|
});
|
|
249
183
|
}
|
|
250
184
|
const RemoteApp = withRouterData(RemoteAppWrapper);
|
|
@@ -299,103 +233,14 @@ function createLazyRemoteComponent(info) {
|
|
|
299
233
|
function createRemoteComponent(info) {
|
|
300
234
|
const LazyComponent = createLazyRemoteComponent(info);
|
|
301
235
|
return forwardRef((props, ref) => {
|
|
302
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
function createRoot(container, options) {
|
|
307
|
-
if (isReact18) {
|
|
308
|
-
return ReactDOM.createRoot(container, options);
|
|
309
|
-
}
|
|
310
|
-
return {
|
|
311
|
-
render(children) {
|
|
312
|
-
ReactDOM.render(children, container);
|
|
313
|
-
},
|
|
314
|
-
unmount() {
|
|
315
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
function createBridgeComponent({
|
|
320
|
-
createRoot: createRoot$1 = createRoot,
|
|
321
|
-
...bridgeInfo
|
|
322
|
-
}) {
|
|
323
|
-
return () => {
|
|
324
|
-
const rootMap = /* @__PURE__ */ new Map();
|
|
325
|
-
const instance = federationRuntime.instance;
|
|
326
|
-
LoggerInstance.debug(
|
|
327
|
-
`createBridgeComponent instance from props >>>`,
|
|
328
|
-
instance
|
|
329
|
-
);
|
|
330
|
-
const RawComponent = (info) => {
|
|
331
|
-
const { appInfo, propsInfo, ...restProps } = info;
|
|
332
|
-
const { moduleName, memoryRoute, basename = "/" } = appInfo;
|
|
333
|
-
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { moduleName, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(
|
|
334
|
-
bridgeInfo.rootComponent,
|
|
335
|
-
{
|
|
336
|
-
...propsInfo,
|
|
337
|
-
basename,
|
|
338
|
-
...restProps
|
|
339
|
-
}
|
|
340
|
-
));
|
|
341
|
-
};
|
|
342
|
-
return {
|
|
343
|
-
async render(info) {
|
|
344
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
345
|
-
LoggerInstance.debug(`createBridgeComponent render Info`, info);
|
|
346
|
-
const {
|
|
347
|
-
moduleName,
|
|
348
|
-
dom,
|
|
349
|
-
basename,
|
|
350
|
-
memoryRoute,
|
|
351
|
-
fallback,
|
|
352
|
-
...propsInfo
|
|
353
|
-
} = 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,
|
|
357
|
-
{
|
|
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
|
-
}
|
|
379
|
-
}
|
|
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)) || {};
|
|
236
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
237
|
+
ErrorBoundary,
|
|
238
|
+
{
|
|
239
|
+
FallbackComponent: info.fallback
|
|
381
240
|
},
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
|
|
386
|
-
const root = rootMap.get(dom);
|
|
387
|
-
if (root) {
|
|
388
|
-
if ("unmount" in root) {
|
|
389
|
-
root.unmount();
|
|
390
|
-
} else {
|
|
391
|
-
ReactDOM.unmountComponentAtNode(root);
|
|
392
|
-
}
|
|
393
|
-
rootMap.delete(dom);
|
|
394
|
-
}
|
|
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);
|
|
396
|
-
}
|
|
397
|
-
};
|
|
398
|
-
};
|
|
241
|
+
/* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref }))
|
|
242
|
+
);
|
|
243
|
+
});
|
|
399
244
|
}
|
|
400
245
|
export {
|
|
401
246
|
createBridgeComponent,
|
package/dist/router-v5.cjs.js
CHANGED
|
@@ -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
|
|
5
|
+
const index = require("./index-BYDWxFmi.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" } });
|
|
@@ -23,8 +23,8 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
const ReactRouterDom__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDom$1);
|
|
24
24
|
function WraperRouter(props) {
|
|
25
25
|
const { basename, ...propsRes } = props;
|
|
26
|
-
const routerContextProps = React.useContext(
|
|
27
|
-
|
|
26
|
+
const routerContextProps = React.useContext(index.RouterContext) || {};
|
|
27
|
+
index.LoggerInstance.debug(`WraperRouter info >>>`, {
|
|
28
28
|
...routerContextProps,
|
|
29
29
|
routerContextProps,
|
|
30
30
|
WraperRouterProps: props
|
package/dist/router-v5.es.js
CHANGED
|
@@ -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 "./
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./index-BlBMQSoq.js";
|
|
4
4
|
export * from "react-router-dom/index.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
package/dist/router-v6.cjs.js
CHANGED
|
@@ -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
|
|
5
|
+
const index = require("./index-BYDWxFmi.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" } });
|
|
@@ -23,8 +23,8 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
const ReactRouterDom__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDom$1);
|
|
24
24
|
function WraperRouter(props) {
|
|
25
25
|
const { basename, ...propsRes } = props;
|
|
26
|
-
const routerContextProps = React.useContext(
|
|
27
|
-
|
|
26
|
+
const routerContextProps = React.useContext(index.RouterContext) || {};
|
|
27
|
+
index.LoggerInstance.debug(`WraperRouter info >>>`, {
|
|
28
28
|
...routerContextProps,
|
|
29
29
|
routerContextProps,
|
|
30
30
|
WraperRouterProps: props
|
|
@@ -48,9 +48,9 @@ function WraperRouter(props) {
|
|
|
48
48
|
}
|
|
49
49
|
function WraperRouterProvider(props) {
|
|
50
50
|
const { router, ...propsRes } = props;
|
|
51
|
-
const routerContextProps = React.useContext(
|
|
51
|
+
const routerContextProps = React.useContext(index.RouterContext) || {};
|
|
52
52
|
const routers = router.routes;
|
|
53
|
-
|
|
53
|
+
index.LoggerInstance.debug(`WraperRouterProvider info >>>`, {
|
|
54
54
|
...routerContextProps,
|
|
55
55
|
routerContextProps,
|
|
56
56
|
WraperRouterProviderProps: props,
|
package/dist/router-v6.es.js
CHANGED
|
@@ -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 "./
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./index-BlBMQSoq.js";
|
|
4
4
|
export * from "react-router-dom/dist/index.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
package/dist/router.cjs.js
CHANGED
|
@@ -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
|
|
5
|
+
const index = require("./index-BYDWxFmi.cjs");
|
|
6
6
|
function _interopNamespaceDefault(e) {
|
|
7
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
8
|
if (e) {
|
|
@@ -22,8 +22,8 @@ function _interopNamespaceDefault(e) {
|
|
|
22
22
|
const ReactRouterDom__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDom);
|
|
23
23
|
function WrapperRouter(props) {
|
|
24
24
|
const { basename, ...propsRes } = props;
|
|
25
|
-
const routerContextProps = React.useContext(
|
|
26
|
-
|
|
25
|
+
const routerContextProps = React.useContext(index.RouterContext) || {};
|
|
26
|
+
index.LoggerInstance.debug(`WrapperRouter info >>>`, {
|
|
27
27
|
...routerContextProps,
|
|
28
28
|
routerContextProps,
|
|
29
29
|
WrapperRouterProps: props
|
|
@@ -47,9 +47,9 @@ function WrapperRouter(props) {
|
|
|
47
47
|
}
|
|
48
48
|
function WrapperRouterProvider(props) {
|
|
49
49
|
const { router, ...propsRes } = props;
|
|
50
|
-
const routerContextProps = React.useContext(
|
|
50
|
+
const routerContextProps = React.useContext(index.RouterContext) || {};
|
|
51
51
|
const routers = router.routes;
|
|
52
|
-
|
|
52
|
+
index.LoggerInstance.debug(`WrapperRouterProvider info >>>`, {
|
|
53
53
|
...routerContextProps,
|
|
54
54
|
routerContextProps,
|
|
55
55
|
WrapperRouterProviderProps: props,
|
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 "./
|
|
4
|
+
import { R as RouterContext, L as LoggerInstance } from "./index-BlBMQSoq.js";
|
|
5
5
|
function WrapperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
|
7
7
|
const routerContextProps = useContext(RouterContext) || {};
|
package/dist/v18.cjs.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const client = require("react-dom/client");
|
|
4
|
+
const bridgeBase = require("./bridge-base-DIOcSEVT.cjs");
|
|
5
|
+
function createReact18Root(container, options) {
|
|
6
|
+
return client.createRoot(container, options);
|
|
7
|
+
}
|
|
8
|
+
function createBridgeComponent(bridgeInfo) {
|
|
9
|
+
const fullBridgeInfo = {
|
|
10
|
+
createRoot: createReact18Root,
|
|
11
|
+
...bridgeInfo
|
|
12
|
+
};
|
|
13
|
+
return bridgeBase.createBaseBridgeComponent(fullBridgeInfo);
|
|
14
|
+
}
|
|
15
|
+
exports.createBridgeComponent = createBridgeComponent;
|
package/dist/v18.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import * as React_2 from 'react';
|
|
3
|
+
|
|
4
|
+
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
5
|
+
render(info: RenderParams): Promise<void>;
|
|
6
|
+
destroy(info: DestroyParams): void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export declare interface CreateRootOptions {
|
|
10
|
+
identifierPrefix?: string;
|
|
11
|
+
onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Options for creating a React root
|
|
16
|
+
*/
|
|
17
|
+
declare interface CreateRootOptions_2 {
|
|
18
|
+
identifierPrefix?: string;
|
|
19
|
+
onRecoverableError?: (error: unknown) => void;
|
|
20
|
+
transitionCallbacks?: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Parameters for the destroy function
|
|
25
|
+
*/
|
|
26
|
+
export declare interface DestroyParams {
|
|
27
|
+
moduleName: string;
|
|
28
|
+
dom: HTMLElement;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Parameters for the provider function
|
|
33
|
+
*/
|
|
34
|
+
export declare interface ProviderFnParams<T> {
|
|
35
|
+
rootComponent: React_2.ComponentType<T>;
|
|
36
|
+
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
|
|
37
|
+
createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions_2) => Root_2;
|
|
38
|
+
/**
|
|
39
|
+
* Default options to pass to createRoot for React 18 and 19
|
|
40
|
+
* These options will be used when creating a root unless overridden by rootOptions in render params
|
|
41
|
+
* @example
|
|
42
|
+
* {
|
|
43
|
+
* identifierPrefix: 'app-',
|
|
44
|
+
* onRecoverableError: (err) => console.error(err)
|
|
45
|
+
* }
|
|
46
|
+
*/
|
|
47
|
+
defaultRootOptions?: CreateRootOptions_2;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Parameters for the provider function
|
|
52
|
+
*/
|
|
53
|
+
export declare interface ProviderParams {
|
|
54
|
+
moduleName?: string;
|
|
55
|
+
basename?: string;
|
|
56
|
+
memoryRoute?: {
|
|
57
|
+
entryPath: string;
|
|
58
|
+
initialState?: Record<string, unknown>;
|
|
59
|
+
};
|
|
60
|
+
style?: React_2.CSSProperties;
|
|
61
|
+
className?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Parameters for the render function
|
|
66
|
+
*/
|
|
67
|
+
export declare interface RenderParams {
|
|
68
|
+
moduleName?: string;
|
|
69
|
+
basename?: string;
|
|
70
|
+
memoryRoute?: {
|
|
71
|
+
entryPath: string;
|
|
72
|
+
initialState?: Record<string, unknown>;
|
|
73
|
+
};
|
|
74
|
+
dom: HTMLElement;
|
|
75
|
+
/**
|
|
76
|
+
* Options to pass to createRoot for React 18 and 19
|
|
77
|
+
* @example
|
|
78
|
+
* {
|
|
79
|
+
* identifierPrefix: 'app-',
|
|
80
|
+
* onRecoverableError: (err) => console.error(err)
|
|
81
|
+
* }
|
|
82
|
+
*/
|
|
83
|
+
rootOptions?: CreateRootOptions_2;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare interface Root {
|
|
88
|
+
render(children: default_2.ReactNode): void;
|
|
89
|
+
unmount(): void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Interface for a React root object
|
|
94
|
+
*/
|
|
95
|
+
declare interface Root_2 {
|
|
96
|
+
render(children: React_2.ReactNode): void;
|
|
97
|
+
unmount(): void;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Type for a root element, which can be either an HTMLElement or a React root
|
|
102
|
+
*/
|
|
103
|
+
export declare type RootType = HTMLElement | Root_2;
|
|
104
|
+
|
|
105
|
+
export { }
|
package/dist/v18.es.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRoot } from "react-dom/client";
|
|
2
|
+
import { c as createBaseBridgeComponent } from "./bridge-base-0CS6p-6-.js";
|
|
3
|
+
function createReact18Root(container, options) {
|
|
4
|
+
return createRoot(container, options);
|
|
5
|
+
}
|
|
6
|
+
function createBridgeComponent(bridgeInfo) {
|
|
7
|
+
const fullBridgeInfo = {
|
|
8
|
+
createRoot: createReact18Root,
|
|
9
|
+
...bridgeInfo
|
|
10
|
+
};
|
|
11
|
+
return createBaseBridgeComponent(fullBridgeInfo);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
createBridgeComponent
|
|
15
|
+
};
|
package/dist/v19.cjs.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const client = require("react-dom/client");
|
|
4
|
+
const bridgeBase = require("./bridge-base-DIOcSEVT.cjs");
|
|
5
|
+
function createReact19Root(container, options) {
|
|
6
|
+
return client.createRoot(container, options);
|
|
7
|
+
}
|
|
8
|
+
function createBridgeComponent(bridgeInfo) {
|
|
9
|
+
const fullBridgeInfo = {
|
|
10
|
+
createRoot: createReact19Root,
|
|
11
|
+
...bridgeInfo
|
|
12
|
+
};
|
|
13
|
+
return bridgeBase.createBaseBridgeComponent(fullBridgeInfo);
|
|
14
|
+
}
|
|
15
|
+
exports.createBridgeComponent = createBridgeComponent;
|
package/dist/v19.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import * as React_2 from 'react';
|
|
3
|
+
|
|
4
|
+
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
5
|
+
render(info: RenderParams): Promise<void>;
|
|
6
|
+
destroy(info: DestroyParams): void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export declare interface CreateRootOptions {
|
|
10
|
+
identifierPrefix?: string;
|
|
11
|
+
onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
|
|
12
|
+
transitionCallbacks?: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Options for creating a React root
|
|
17
|
+
*/
|
|
18
|
+
declare interface CreateRootOptions_2 {
|
|
19
|
+
identifierPrefix?: string;
|
|
20
|
+
onRecoverableError?: (error: unknown) => void;
|
|
21
|
+
transitionCallbacks?: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Parameters for the destroy function
|
|
26
|
+
*/
|
|
27
|
+
export declare interface DestroyParams {
|
|
28
|
+
moduleName: string;
|
|
29
|
+
dom: HTMLElement;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Parameters for the provider function
|
|
34
|
+
*/
|
|
35
|
+
export declare interface ProviderFnParams<T> {
|
|
36
|
+
rootComponent: React_2.ComponentType<T>;
|
|
37
|
+
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
|
|
38
|
+
createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions_2) => Root_2;
|
|
39
|
+
/**
|
|
40
|
+
* Default options to pass to createRoot for React 18 and 19
|
|
41
|
+
* These options will be used when creating a root unless overridden by rootOptions in render params
|
|
42
|
+
* @example
|
|
43
|
+
* {
|
|
44
|
+
* identifierPrefix: 'app-',
|
|
45
|
+
* onRecoverableError: (err) => console.error(err)
|
|
46
|
+
* }
|
|
47
|
+
*/
|
|
48
|
+
defaultRootOptions?: CreateRootOptions_2;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Parameters for the provider function
|
|
53
|
+
*/
|
|
54
|
+
export declare interface ProviderParams {
|
|
55
|
+
moduleName?: string;
|
|
56
|
+
basename?: string;
|
|
57
|
+
memoryRoute?: {
|
|
58
|
+
entryPath: string;
|
|
59
|
+
initialState?: Record<string, unknown>;
|
|
60
|
+
};
|
|
61
|
+
style?: React_2.CSSProperties;
|
|
62
|
+
className?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Parameters for the render function
|
|
67
|
+
*/
|
|
68
|
+
export declare interface RenderParams {
|
|
69
|
+
moduleName?: string;
|
|
70
|
+
basename?: string;
|
|
71
|
+
memoryRoute?: {
|
|
72
|
+
entryPath: string;
|
|
73
|
+
initialState?: Record<string, unknown>;
|
|
74
|
+
};
|
|
75
|
+
dom: HTMLElement;
|
|
76
|
+
/**
|
|
77
|
+
* Options to pass to createRoot for React 18 and 19
|
|
78
|
+
* @example
|
|
79
|
+
* {
|
|
80
|
+
* identifierPrefix: 'app-',
|
|
81
|
+
* onRecoverableError: (err) => console.error(err)
|
|
82
|
+
* }
|
|
83
|
+
*/
|
|
84
|
+
rootOptions?: CreateRootOptions_2;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare interface Root {
|
|
89
|
+
render(children: default_2.ReactNode): void;
|
|
90
|
+
unmount(): void;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Interface for a React root object
|
|
95
|
+
*/
|
|
96
|
+
declare interface Root_2 {
|
|
97
|
+
render(children: React_2.ReactNode): void;
|
|
98
|
+
unmount(): void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Type for a root element, which can be either an HTMLElement or a React root
|
|
103
|
+
*/
|
|
104
|
+
export declare type RootType = HTMLElement | Root_2;
|
|
105
|
+
|
|
106
|
+
export { }
|