@module-federation/bridge-react 0.0.0-next-20240822090000 → 0.0.0-next-20240822101913
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 +16 -2
- package/__tests__/bridge.spec.tsx +37 -3
- package/dist/index.cjs.js +126 -92
- package/dist/index.d.ts +13 -10
- package/dist/index.es.js +128 -94
- package/dist/router-v5.cjs.js +56 -0
- package/dist/router-v5.d.ts +9 -0
- package/dist/router-v5.es.js +32 -0
- package/dist/router-v6.cjs.js +83 -0
- package/dist/router-v6.d.ts +11 -0
- package/dist/router-v6.es.js +60 -0
- package/dist/router.cjs.js +8 -12
- package/dist/router.es.js +8 -12
- package/package.json +12 -2
- package/src/create.tsx +21 -25
- package/src/provider.tsx +55 -40
- package/src/remote/index.tsx +93 -56
- package/src/router-v5.tsx +44 -0
- package/src/router-v6.tsx +73 -0
- package/src/router.tsx +8 -10
- package/vite.config.ts +29 -0
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import React__default, { createContext, Component, createElement, isValidElement,
|
|
3
|
-
import {
|
|
2
|
+
import React__default, { createContext, Component, createElement, isValidElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
|
|
3
|
+
import { L as LoggerInstance, p as pathJoin, f, a as atLeastReact18, R as RouterContext } from "./context-Bw2PEwa6.js";
|
|
4
4
|
import * as ReactRouterDOM from "react-router-dom";
|
|
5
5
|
import ReactDOM from "react-dom";
|
|
6
6
|
const ErrorBoundaryContext = createContext(null);
|
|
@@ -98,55 +98,71 @@ function hasArrayChanged() {
|
|
|
98
98
|
let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
99
99
|
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
`createRemoteComponent LazyComponent destroy >>>`,
|
|
136
|
-
{ name, basename, dom: renderDom.current }
|
|
137
|
-
);
|
|
138
|
-
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
|
|
139
|
-
dom: renderDom.current
|
|
140
|
-
});
|
|
141
|
-
}
|
|
101
|
+
const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
102
|
+
const RemoteApp2 = () => {
|
|
103
|
+
LoggerInstance.log(`RemoteAppWrapper RemoteApp props >>>`, { props });
|
|
104
|
+
const {
|
|
105
|
+
moduleName,
|
|
106
|
+
memoryRoute,
|
|
107
|
+
basename,
|
|
108
|
+
providerInfo,
|
|
109
|
+
className,
|
|
110
|
+
style,
|
|
111
|
+
fallback,
|
|
112
|
+
...resProps
|
|
113
|
+
} = props;
|
|
114
|
+
const rootRef = ref && "current" in ref ? ref : useRef(null);
|
|
115
|
+
const renderDom = useRef(null);
|
|
116
|
+
const providerInfoRef = useRef(null);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const renderTimeout = setTimeout(() => {
|
|
119
|
+
const providerReturn = providerInfo();
|
|
120
|
+
providerInfoRef.current = providerReturn;
|
|
121
|
+
const renderProps = {
|
|
122
|
+
moduleName,
|
|
123
|
+
dom: rootRef.current,
|
|
124
|
+
basename,
|
|
125
|
+
memoryRoute,
|
|
126
|
+
fallback,
|
|
127
|
+
...resProps
|
|
128
|
+
};
|
|
129
|
+
renderDom.current = rootRef.current;
|
|
130
|
+
LoggerInstance.log(
|
|
131
|
+
`createRemoteComponent LazyComponent render >>>`,
|
|
132
|
+
renderProps
|
|
133
|
+
);
|
|
134
|
+
providerReturn.render(renderProps);
|
|
142
135
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
136
|
+
return () => {
|
|
137
|
+
clearTimeout(renderTimeout);
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
141
|
+
LoggerInstance.log(
|
|
142
|
+
`createRemoteComponent LazyComponent destroy >>>`,
|
|
143
|
+
{ moduleName, basename, dom: renderDom.current }
|
|
144
|
+
);
|
|
145
|
+
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
|
|
146
|
+
dom: renderDom.current
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
}, []);
|
|
152
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
className: props == null ? void 0 : props.className,
|
|
156
|
+
style: props == null ? void 0 : props.style,
|
|
157
|
+
ref: rootRef
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
RemoteApp2["__APP_VERSION__"] = "0.5.1";
|
|
162
|
+
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);
|
|
163
|
+
});
|
|
148
164
|
function withRouterData(WrappedComponent) {
|
|
149
|
-
|
|
165
|
+
const Component2 = forwardRef(function(props, ref) {
|
|
150
166
|
var _a;
|
|
151
167
|
let enableDispathPopstate = false;
|
|
152
168
|
let routerContextVal;
|
|
@@ -204,10 +220,13 @@ function withRouterData(WrappedComponent) {
|
|
|
204
220
|
setPathname(location.pathname);
|
|
205
221
|
}, [location]);
|
|
206
222
|
}
|
|
207
|
-
return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename });
|
|
208
|
-
};
|
|
223
|
+
return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename, ref });
|
|
224
|
+
});
|
|
225
|
+
return forwardRef(function(props, ref) {
|
|
226
|
+
return /* @__PURE__ */ React__default.createElement(Component2, { ...props, ref });
|
|
227
|
+
});
|
|
209
228
|
}
|
|
210
|
-
const RemoteApp
|
|
229
|
+
const RemoteApp = withRouterData(RemoteAppWrapper);
|
|
211
230
|
function createLazyRemoteComponent(info) {
|
|
212
231
|
const exportName = (info == null ? void 0 : info.export) || "default";
|
|
213
232
|
return React__default.lazy(async () => {
|
|
@@ -224,13 +243,15 @@ function createLazyRemoteComponent(info) {
|
|
|
224
243
|
);
|
|
225
244
|
const exportFn = m2[exportName];
|
|
226
245
|
if (exportName in m2 && typeof exportFn === "function") {
|
|
227
|
-
const RemoteAppComponent = forwardRef((props,
|
|
246
|
+
const RemoteAppComponent = forwardRef((props, ref) => {
|
|
228
247
|
return /* @__PURE__ */ React__default.createElement(
|
|
229
|
-
RemoteApp
|
|
248
|
+
RemoteApp,
|
|
230
249
|
{
|
|
231
|
-
|
|
250
|
+
moduleName,
|
|
232
251
|
providerInfo: exportFn,
|
|
233
252
|
exportName: info.export || "default",
|
|
253
|
+
fallback: info.fallback,
|
|
254
|
+
ref,
|
|
234
255
|
...props
|
|
235
256
|
}
|
|
236
257
|
);
|
|
@@ -255,10 +276,12 @@ function createLazyRemoteComponent(info) {
|
|
|
255
276
|
});
|
|
256
277
|
}
|
|
257
278
|
function createRemoteComponent(info) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
279
|
+
return forwardRef(
|
|
280
|
+
(props, ref) => {
|
|
281
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
282
|
+
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 })));
|
|
283
|
+
}
|
|
284
|
+
);
|
|
262
285
|
}
|
|
263
286
|
var client = {};
|
|
264
287
|
var m = ReactDOM;
|
|
@@ -289,55 +312,66 @@ function createBridgeComponent(bridgeInfo) {
|
|
|
289
312
|
return () => {
|
|
290
313
|
const rootMap = /* @__PURE__ */ new Map();
|
|
291
314
|
const RawComponent = (info) => {
|
|
292
|
-
const { appInfo, propsInfo } = info;
|
|
293
|
-
const {
|
|
294
|
-
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: {
|
|
315
|
+
const { appInfo, propsInfo, ...restProps } = info;
|
|
316
|
+
const { moduleName, memoryRoute, basename = "/" } = appInfo;
|
|
317
|
+
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { moduleName, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(
|
|
318
|
+
bridgeInfo.rootComponent,
|
|
319
|
+
{
|
|
320
|
+
...propsInfo,
|
|
321
|
+
basename,
|
|
322
|
+
...restProps
|
|
323
|
+
}
|
|
324
|
+
));
|
|
295
325
|
};
|
|
296
326
|
if (!provider) {
|
|
297
327
|
provider = {
|
|
298
|
-
render(info) {
|
|
328
|
+
async render(info) {
|
|
299
329
|
LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
300
|
-
const {
|
|
330
|
+
const {
|
|
331
|
+
moduleName,
|
|
332
|
+
dom,
|
|
333
|
+
basename,
|
|
334
|
+
memoryRoute,
|
|
335
|
+
fallback,
|
|
336
|
+
...propsInfo
|
|
337
|
+
} = info;
|
|
338
|
+
const rootComponentWithErrorBoundary = (
|
|
339
|
+
// set ErrorBoundary for RawComponent rendering error, usually caused by user app rendering error
|
|
340
|
+
/* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: fallback }, /* @__PURE__ */ React.createElement(
|
|
341
|
+
RawComponent,
|
|
342
|
+
{
|
|
343
|
+
appInfo: {
|
|
344
|
+
moduleName,
|
|
345
|
+
basename,
|
|
346
|
+
memoryRoute
|
|
347
|
+
},
|
|
348
|
+
propsInfo
|
|
349
|
+
}
|
|
350
|
+
))
|
|
351
|
+
);
|
|
301
352
|
if (atLeastReact18(React)) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
basename,
|
|
312
|
-
memoryRoute
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
)
|
|
316
|
-
);
|
|
353
|
+
if (bridgeInfo == null ? void 0 : bridgeInfo.render) {
|
|
354
|
+
Promise.resolve(
|
|
355
|
+
bridgeInfo == null ? void 0 : bridgeInfo.render(rootComponentWithErrorBoundary, dom)
|
|
356
|
+
).then((root) => rootMap.set(info.dom, root));
|
|
357
|
+
} else {
|
|
358
|
+
const root = client.createRoot(info.dom);
|
|
359
|
+
root.render(rootComponentWithErrorBoundary);
|
|
360
|
+
rootMap.set(info.dom, root);
|
|
361
|
+
}
|
|
317
362
|
} else {
|
|
318
|
-
ReactDOM.render
|
|
319
|
-
|
|
320
|
-
RawComponent,
|
|
321
|
-
{
|
|
322
|
-
propsInfo,
|
|
323
|
-
appInfo: {
|
|
324
|
-
name,
|
|
325
|
-
basename,
|
|
326
|
-
memoryRoute
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
),
|
|
330
|
-
info.dom
|
|
331
|
-
);
|
|
363
|
+
const renderFn = (bridgeInfo == null ? void 0 : bridgeInfo.render) || ReactDOM.render;
|
|
364
|
+
renderFn == null ? void 0 : renderFn(rootComponentWithErrorBoundary, info.dom);
|
|
332
365
|
}
|
|
333
366
|
},
|
|
334
|
-
destroy(info) {
|
|
367
|
+
async destroy(info) {
|
|
335
368
|
LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
336
369
|
dom: info.dom
|
|
337
370
|
});
|
|
338
371
|
if (atLeastReact18(React)) {
|
|
339
372
|
const root = rootMap.get(info.dom);
|
|
340
373
|
root == null ? void 0 : root.unmount();
|
|
374
|
+
rootMap.delete(info.dom);
|
|
341
375
|
} else {
|
|
342
376
|
ReactDOM.unmountComponentAtNode(info.dom);
|
|
343
377
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const ReactRouterDom$1 = require("react-router-dom/index.js");
|
|
5
|
+
const context = require("./context--mtFt3tp.cjs");
|
|
6
|
+
const ReactRouterDom = require("react-router-dom/index.js");
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
+
if (e) {
|
|
10
|
+
for (const k in e) {
|
|
11
|
+
if (k !== "default") {
|
|
12
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: () => e[k]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
const ReactRouterDom__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDom$1);
|
|
24
|
+
function WraperRouter(props) {
|
|
25
|
+
const { basename, ...propsRes } = props;
|
|
26
|
+
const routerContextProps = React.useContext(context.RouterContext) || {};
|
|
27
|
+
context.LoggerInstance.log(`WraperRouter info >>>`, {
|
|
28
|
+
...routerContextProps,
|
|
29
|
+
routerContextProps,
|
|
30
|
+
WraperRouterProps: props
|
|
31
|
+
});
|
|
32
|
+
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
33
|
+
return /* @__PURE__ */ React.createElement(
|
|
34
|
+
ReactRouterDom__namespace.MemoryRouter,
|
|
35
|
+
{
|
|
36
|
+
...props,
|
|
37
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ React.createElement(
|
|
42
|
+
ReactRouterDom__namespace.BrowserRouter,
|
|
43
|
+
{
|
|
44
|
+
...propsRes,
|
|
45
|
+
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
exports.BrowserRouter = WraperRouter;
|
|
50
|
+
Object.keys(ReactRouterDom).forEach((k) => {
|
|
51
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
52
|
+
Object.defineProperty(exports, k, {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: () => ReactRouterDom[k]
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import * as ReactRouterDom from 'react-router-dom/index.js';
|
|
3
|
+
|
|
4
|
+
export declare function BrowserRouter(props: Parameters<typeof ReactRouterDom.BrowserRouter>[0] | Parameters<typeof ReactRouterDom.MemoryRouter>[0]): default_2.JSX.Element;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export * from "react-router-dom/";
|
|
8
|
+
|
|
9
|
+
export { }
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React__default, { useContext } from "react";
|
|
2
|
+
import * as ReactRouterDom$1 from "react-router-dom/index.js";
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-Bw2PEwa6.js";
|
|
4
|
+
export * from "react-router-dom/index.js";
|
|
5
|
+
function WraperRouter(props) {
|
|
6
|
+
const { basename, ...propsRes } = props;
|
|
7
|
+
const routerContextProps = useContext(RouterContext) || {};
|
|
8
|
+
LoggerInstance.log(`WraperRouter info >>>`, {
|
|
9
|
+
...routerContextProps,
|
|
10
|
+
routerContextProps,
|
|
11
|
+
WraperRouterProps: props
|
|
12
|
+
});
|
|
13
|
+
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
14
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
15
|
+
ReactRouterDom$1.MemoryRouter,
|
|
16
|
+
{
|
|
17
|
+
...props,
|
|
18
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
23
|
+
ReactRouterDom$1.BrowserRouter,
|
|
24
|
+
{
|
|
25
|
+
...propsRes,
|
|
26
|
+
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
WraperRouter as BrowserRouter
|
|
32
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const ReactRouterDom = require("react-router-dom/dist/index.js");
|
|
5
|
+
const context = require("./context--mtFt3tp.cjs");
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const ReactRouterDom__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDom);
|
|
23
|
+
function WraperRouter(props) {
|
|
24
|
+
const { basename, ...propsRes } = props;
|
|
25
|
+
const routerContextProps = React.useContext(context.RouterContext) || {};
|
|
26
|
+
context.LoggerInstance.log(`WraperRouter info >>>`, {
|
|
27
|
+
...routerContextProps,
|
|
28
|
+
routerContextProps,
|
|
29
|
+
WraperRouterProps: props
|
|
30
|
+
});
|
|
31
|
+
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
32
|
+
return /* @__PURE__ */ React.createElement(
|
|
33
|
+
ReactRouterDom__namespace.MemoryRouter,
|
|
34
|
+
{
|
|
35
|
+
...props,
|
|
36
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ React.createElement(
|
|
41
|
+
ReactRouterDom__namespace.BrowserRouter,
|
|
42
|
+
{
|
|
43
|
+
...propsRes,
|
|
44
|
+
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function WraperRouterProvider(props) {
|
|
49
|
+
const { router, ...propsRes } = props;
|
|
50
|
+
const routerContextProps = React.useContext(context.RouterContext) || {};
|
|
51
|
+
const routers = router.routes;
|
|
52
|
+
context.LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
53
|
+
...routerContextProps,
|
|
54
|
+
routerContextProps,
|
|
55
|
+
WraperRouterProviderProps: props,
|
|
56
|
+
router
|
|
57
|
+
});
|
|
58
|
+
const RouterProvider = ReactRouterDom__namespace["RouterProvider"];
|
|
59
|
+
const createMemoryRouter = ReactRouterDom__namespace["createMemoryRouter"];
|
|
60
|
+
const createBrowserRouter = ReactRouterDom__namespace["createBrowserRouter"];
|
|
61
|
+
if (routerContextProps.memoryRoute) {
|
|
62
|
+
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
63
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
64
|
+
});
|
|
65
|
+
return /* @__PURE__ */ React.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
66
|
+
} else {
|
|
67
|
+
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
68
|
+
basename: routerContextProps.basename,
|
|
69
|
+
future: router.future,
|
|
70
|
+
window: router.window
|
|
71
|
+
});
|
|
72
|
+
return /* @__PURE__ */ React.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.BrowserRouter = WraperRouter;
|
|
76
|
+
exports.RouterProvider = WraperRouterProvider;
|
|
77
|
+
Object.keys(ReactRouterDom).forEach((k) => {
|
|
78
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
79
|
+
Object.defineProperty(exports, k, {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: () => ReactRouterDom[k]
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import * as ReactRouterDom from 'react-router-dom/dist/index.js';
|
|
3
|
+
|
|
4
|
+
export declare function BrowserRouter(props: Parameters<typeof ReactRouterDom.BrowserRouter>[0] | Parameters<typeof ReactRouterDom.MemoryRouter>[0]): default_2.JSX.Element;
|
|
5
|
+
|
|
6
|
+
export declare function RouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): default_2.JSX.Element;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export * from "react-router-dom/dist/index.js";
|
|
10
|
+
|
|
11
|
+
export { }
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React__default, { useContext } from "react";
|
|
2
|
+
import * as ReactRouterDom from "react-router-dom/dist/index.js";
|
|
3
|
+
export * from "react-router-dom/dist/index.js";
|
|
4
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-Bw2PEwa6.js";
|
|
5
|
+
function WraperRouter(props) {
|
|
6
|
+
const { basename, ...propsRes } = props;
|
|
7
|
+
const routerContextProps = useContext(RouterContext) || {};
|
|
8
|
+
LoggerInstance.log(`WraperRouter info >>>`, {
|
|
9
|
+
...routerContextProps,
|
|
10
|
+
routerContextProps,
|
|
11
|
+
WraperRouterProps: props
|
|
12
|
+
});
|
|
13
|
+
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
14
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
15
|
+
ReactRouterDom.MemoryRouter,
|
|
16
|
+
{
|
|
17
|
+
...props,
|
|
18
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
23
|
+
ReactRouterDom.BrowserRouter,
|
|
24
|
+
{
|
|
25
|
+
...propsRes,
|
|
26
|
+
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function WraperRouterProvider(props) {
|
|
31
|
+
const { router, ...propsRes } = props;
|
|
32
|
+
const routerContextProps = useContext(RouterContext) || {};
|
|
33
|
+
const routers = router.routes;
|
|
34
|
+
LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
35
|
+
...routerContextProps,
|
|
36
|
+
routerContextProps,
|
|
37
|
+
WraperRouterProviderProps: props,
|
|
38
|
+
router
|
|
39
|
+
});
|
|
40
|
+
const RouterProvider = ReactRouterDom["RouterProvider"];
|
|
41
|
+
const createMemoryRouter = ReactRouterDom["createMemoryRouter"];
|
|
42
|
+
const createBrowserRouter = ReactRouterDom["createBrowserRouter"];
|
|
43
|
+
if (routerContextProps.memoryRoute) {
|
|
44
|
+
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
45
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
46
|
+
});
|
|
47
|
+
return /* @__PURE__ */ React__default.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
48
|
+
} else {
|
|
49
|
+
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
50
|
+
basename: routerContextProps.basename,
|
|
51
|
+
future: router.future,
|
|
52
|
+
window: router.window
|
|
53
|
+
});
|
|
54
|
+
return /* @__PURE__ */ React__default.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
WraperRouter as BrowserRouter,
|
|
59
|
+
WraperRouterProvider as RouterProvider
|
|
60
|
+
};
|
package/dist/router.cjs.js
CHANGED
|
@@ -20,16 +20,14 @@ function _interopNamespaceDefault(e) {
|
|
|
20
20
|
return Object.freeze(n);
|
|
21
21
|
}
|
|
22
22
|
const ReactRouterDom__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDom);
|
|
23
|
-
function
|
|
23
|
+
function WrapperRouter(props) {
|
|
24
24
|
const { basename, ...propsRes } = props;
|
|
25
25
|
const routerContextProps = React.useContext(context.RouterContext) || {};
|
|
26
|
-
context.LoggerInstance.log(`
|
|
26
|
+
context.LoggerInstance.log(`WrapperRouter info >>>`, {
|
|
27
27
|
...routerContextProps,
|
|
28
28
|
routerContextProps,
|
|
29
|
-
|
|
29
|
+
WrapperRouterProps: props
|
|
30
30
|
});
|
|
31
|
-
if (!routerContextProps)
|
|
32
|
-
return /* @__PURE__ */ React.createElement(ReactRouterDom__namespace.BrowserRouter, { ...props });
|
|
33
31
|
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
34
32
|
return /* @__PURE__ */ React.createElement(
|
|
35
33
|
ReactRouterDom__namespace.MemoryRouter,
|
|
@@ -47,21 +45,19 @@ function WraperRouter(props) {
|
|
|
47
45
|
}
|
|
48
46
|
);
|
|
49
47
|
}
|
|
50
|
-
function
|
|
48
|
+
function WrapperRouterProvider(props) {
|
|
51
49
|
const { router, ...propsRes } = props;
|
|
52
50
|
const routerContextProps = React.useContext(context.RouterContext) || {};
|
|
53
51
|
const routers = router.routes;
|
|
54
|
-
context.LoggerInstance.log(`
|
|
52
|
+
context.LoggerInstance.log(`WrapperRouterProvider info >>>`, {
|
|
55
53
|
...routerContextProps,
|
|
56
54
|
routerContextProps,
|
|
57
|
-
|
|
55
|
+
WrapperRouterProviderProps: props,
|
|
58
56
|
router
|
|
59
57
|
});
|
|
60
58
|
const RouterProvider = ReactRouterDom__namespace["RouterProvider"];
|
|
61
59
|
const createMemoryRouter = ReactRouterDom__namespace["createMemoryRouter"];
|
|
62
60
|
const createBrowserRouter = ReactRouterDom__namespace["createBrowserRouter"];
|
|
63
|
-
if (!routerContextProps)
|
|
64
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { ...props });
|
|
65
61
|
if (routerContextProps.memoryRoute) {
|
|
66
62
|
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
67
63
|
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
@@ -76,8 +72,8 @@ function WraperRouterProvider(props) {
|
|
|
76
72
|
return /* @__PURE__ */ React.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
|
-
exports.BrowserRouter =
|
|
80
|
-
exports.RouterProvider =
|
|
75
|
+
exports.BrowserRouter = WrapperRouter;
|
|
76
|
+
exports.RouterProvider = WrapperRouterProvider;
|
|
81
77
|
Object.keys(ReactRouterDom).forEach((k) => {
|
|
82
78
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
83
79
|
Object.defineProperty(exports, k, {
|
package/dist/router.es.js
CHANGED
|
@@ -2,16 +2,14 @@ import React__default, { useContext } from "react";
|
|
|
2
2
|
import * as ReactRouterDom from "react-router-dom/";
|
|
3
3
|
export * from "react-router-dom/";
|
|
4
4
|
import { R as RouterContext, L as LoggerInstance } from "./context-Bw2PEwa6.js";
|
|
5
|
-
function
|
|
5
|
+
function WrapperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
|
7
7
|
const routerContextProps = useContext(RouterContext) || {};
|
|
8
|
-
LoggerInstance.log(`
|
|
8
|
+
LoggerInstance.log(`WrapperRouter info >>>`, {
|
|
9
9
|
...routerContextProps,
|
|
10
10
|
routerContextProps,
|
|
11
|
-
|
|
11
|
+
WrapperRouterProps: props
|
|
12
12
|
});
|
|
13
|
-
if (!routerContextProps)
|
|
14
|
-
return /* @__PURE__ */ React__default.createElement(ReactRouterDom.BrowserRouter, { ...props });
|
|
15
13
|
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
16
14
|
return /* @__PURE__ */ React__default.createElement(
|
|
17
15
|
ReactRouterDom.MemoryRouter,
|
|
@@ -29,21 +27,19 @@ function WraperRouter(props) {
|
|
|
29
27
|
}
|
|
30
28
|
);
|
|
31
29
|
}
|
|
32
|
-
function
|
|
30
|
+
function WrapperRouterProvider(props) {
|
|
33
31
|
const { router, ...propsRes } = props;
|
|
34
32
|
const routerContextProps = useContext(RouterContext) || {};
|
|
35
33
|
const routers = router.routes;
|
|
36
|
-
LoggerInstance.log(`
|
|
34
|
+
LoggerInstance.log(`WrapperRouterProvider info >>>`, {
|
|
37
35
|
...routerContextProps,
|
|
38
36
|
routerContextProps,
|
|
39
|
-
|
|
37
|
+
WrapperRouterProviderProps: props,
|
|
40
38
|
router
|
|
41
39
|
});
|
|
42
40
|
const RouterProvider = ReactRouterDom["RouterProvider"];
|
|
43
41
|
const createMemoryRouter = ReactRouterDom["createMemoryRouter"];
|
|
44
42
|
const createBrowserRouter = ReactRouterDom["createBrowserRouter"];
|
|
45
|
-
if (!routerContextProps)
|
|
46
|
-
return /* @__PURE__ */ React__default.createElement(RouterProvider, { ...props });
|
|
47
43
|
if (routerContextProps.memoryRoute) {
|
|
48
44
|
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
49
45
|
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
@@ -59,6 +55,6 @@ function WraperRouterProvider(props) {
|
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
WrapperRouter as BrowserRouter,
|
|
59
|
+
WrapperRouterProvider as RouterProvider
|
|
64
60
|
};
|