@module-federation/bridge-react 0.0.0-next-20240818132231 → 0.0.0-next-20240819022441
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 +2 -10
- package/__tests__/bridge.spec.tsx +3 -37
- package/dist/index.cjs.js +92 -126
- package/dist/index.d.ts +7 -10
- package/dist/index.es.js +94 -128
- package/dist/router.cjs.js +12 -8
- package/dist/router.es.js +12 -8
- package/package.json +2 -12
- package/src/create.tsx +25 -32
- package/src/provider.tsx +33 -50
- package/src/remote/index.tsx +56 -92
- package/src/router.tsx +10 -8
- package/vite.config.ts +0 -29
- package/dist/router-v5.cjs.js +0 -48
- package/dist/router-v5.d.ts +0 -6
- package/dist/router-v5.es.js +0 -31
- package/dist/router-v6.cjs.js +0 -57
- package/dist/router-v6.d.ts +0 -9
- package/dist/router-v6.es.js +0 -34
- package/src/router-v5.tsx +0 -39
- package/src/router-v6.tsx +0 -42
package/src/remote/index.tsx
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useContext,
|
|
3
|
-
useEffect,
|
|
4
|
-
useRef,
|
|
5
|
-
useState,
|
|
6
|
-
forwardRef,
|
|
7
|
-
} from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
8
2
|
import * as ReactRouterDOM from 'react-router-dom';
|
|
9
3
|
import type { ProviderParams } from '@module-federation/bridge-shared';
|
|
10
4
|
import { LoggerInstance, pathJoin } from '../utils';
|
|
11
5
|
import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
|
|
12
|
-
import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
|
|
13
6
|
|
|
14
7
|
declare const __APP_VERSION__: string;
|
|
8
|
+
|
|
15
9
|
export interface RenderFnParams extends ProviderParams {
|
|
16
10
|
dom?: any;
|
|
17
|
-
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
18
11
|
}
|
|
19
12
|
|
|
20
13
|
interface RemoteModule {
|
|
@@ -29,96 +22,71 @@ interface RemoteModule {
|
|
|
29
22
|
}
|
|
30
23
|
|
|
31
24
|
interface RemoteAppParams {
|
|
32
|
-
|
|
25
|
+
name: string;
|
|
33
26
|
providerInfo: NonNullable<RemoteModule['provider']>;
|
|
34
27
|
exportName: string | number | symbol;
|
|
35
|
-
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
36
28
|
}
|
|
37
29
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
providerReturn.render(renderProps);
|
|
30
|
+
const RemoteApp = ({
|
|
31
|
+
name,
|
|
32
|
+
memoryRoute,
|
|
33
|
+
basename,
|
|
34
|
+
providerInfo,
|
|
35
|
+
...resProps
|
|
36
|
+
}: RemoteAppParams & ProviderParams) => {
|
|
37
|
+
const rootRef = useRef(null);
|
|
38
|
+
const renderDom = useRef(null);
|
|
39
|
+
const providerInfoRef = useRef<any>(null);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const renderTimeout = setTimeout(() => {
|
|
43
|
+
const providerReturn = providerInfo();
|
|
44
|
+
providerInfoRef.current = providerReturn;
|
|
45
|
+
const renderProps = {
|
|
46
|
+
name,
|
|
47
|
+
dom: rootRef.current,
|
|
48
|
+
basename,
|
|
49
|
+
memoryRoute,
|
|
50
|
+
...resProps,
|
|
51
|
+
};
|
|
52
|
+
renderDom.current = rootRef.current;
|
|
53
|
+
LoggerInstance.log(
|
|
54
|
+
`createRemoteComponent LazyComponent render >>>`,
|
|
55
|
+
renderProps,
|
|
56
|
+
);
|
|
57
|
+
providerReturn.render(renderProps);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return () => {
|
|
61
|
+
clearTimeout(renderTimeout);
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
if (providerInfoRef.current?.destroy) {
|
|
64
|
+
LoggerInstance.log(
|
|
65
|
+
`createRemoteComponent LazyComponent destroy >>>`,
|
|
66
|
+
{ name, basename, dom: renderDom.current },
|
|
67
|
+
);
|
|
68
|
+
providerInfoRef.current?.destroy({
|
|
69
|
+
dom: renderDom.current,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
81
72
|
});
|
|
73
|
+
};
|
|
74
|
+
}, []);
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (providerInfoRef.current?.destroy) {
|
|
87
|
-
LoggerInstance.log(
|
|
88
|
-
`createRemoteComponent LazyComponent destroy >>>`,
|
|
89
|
-
{ moduleName, basename, dom: renderDom.current },
|
|
90
|
-
);
|
|
91
|
-
providerInfoRef.current?.destroy({
|
|
92
|
-
dom: renderDom.current,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
}, []);
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<div
|
|
101
|
-
className={props?.className}
|
|
102
|
-
style={props?.style}
|
|
103
|
-
ref={rootRef}
|
|
104
|
-
></div>
|
|
105
|
-
);
|
|
106
|
-
};
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
return <div ref={rootRef}></div>;
|
|
78
|
+
};
|
|
107
79
|
|
|
108
|
-
|
|
109
|
-
return <RemoteApp />;
|
|
110
|
-
});
|
|
80
|
+
(RemoteApp as any)['__APP_VERSION__'] = __APP_VERSION__;
|
|
111
81
|
|
|
112
82
|
interface ExtraDataProps {
|
|
113
83
|
basename?: string;
|
|
114
84
|
}
|
|
115
85
|
|
|
116
|
-
export function withRouterData<
|
|
117
|
-
P extends Parameters<typeof RemoteAppWrapper>[0],
|
|
118
|
-
>(
|
|
86
|
+
export function withRouterData<P extends Parameters<typeof RemoteApp>[0]>(
|
|
119
87
|
WrappedComponent: React.ComponentType<P & ExtraDataProps>,
|
|
120
88
|
): React.FC<Omit<P, keyof ExtraDataProps>> {
|
|
121
|
-
|
|
89
|
+
return (props: any) => {
|
|
122
90
|
let enableDispathPopstate = false;
|
|
123
91
|
let routerContextVal: any;
|
|
124
92
|
try {
|
|
@@ -190,12 +158,8 @@ export function withRouterData<
|
|
|
190
158
|
}, [location]);
|
|
191
159
|
}
|
|
192
160
|
|
|
193
|
-
return <WrappedComponent {...(props as P)} basename={basename}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return forwardRef(function (props, ref) {
|
|
197
|
-
return <Component {...props} ref={ref} />;
|
|
198
|
-
}) as any;
|
|
161
|
+
return <WrappedComponent {...(props as P)} basename={basename} />;
|
|
162
|
+
};
|
|
199
163
|
}
|
|
200
164
|
|
|
201
|
-
export default withRouterData(
|
|
165
|
+
export default withRouterData(RemoteApp);
|
package/src/router.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import * as ReactRouterDom from 'react-router-dom/';
|
|
|
4
4
|
import { RouterContext } from './context';
|
|
5
5
|
import { LoggerInstance } from './utils';
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function WraperRouter(
|
|
8
8
|
props:
|
|
9
9
|
| Parameters<typeof ReactRouterDom.BrowserRouter>[0]
|
|
10
10
|
| Parameters<typeof ReactRouterDom.MemoryRouter>[0],
|
|
@@ -12,11 +12,12 @@ function WrapperRouter(
|
|
|
12
12
|
const { basename, ...propsRes } = props;
|
|
13
13
|
const routerContextProps = useContext(RouterContext) || {};
|
|
14
14
|
|
|
15
|
-
LoggerInstance.log(`
|
|
15
|
+
LoggerInstance.log(`WraperRouter info >>>`, {
|
|
16
16
|
...routerContextProps,
|
|
17
17
|
routerContextProps,
|
|
18
|
-
|
|
18
|
+
WraperRouterProps: props,
|
|
19
19
|
});
|
|
20
|
+
if (!routerContextProps) return <ReactRouterDom.BrowserRouter {...props} />;
|
|
20
21
|
|
|
21
22
|
if (routerContextProps?.memoryRoute) {
|
|
22
23
|
return (
|
|
@@ -34,16 +35,16 @@ function WrapperRouter(
|
|
|
34
35
|
);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
function
|
|
38
|
+
function WraperRouterProvider(
|
|
38
39
|
props: Parameters<typeof ReactRouterDom.RouterProvider>[0],
|
|
39
40
|
) {
|
|
40
41
|
const { router, ...propsRes } = props;
|
|
41
42
|
const routerContextProps = useContext(RouterContext) || {};
|
|
42
43
|
const routers = router.routes;
|
|
43
|
-
LoggerInstance.log(`
|
|
44
|
+
LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
44
45
|
...routerContextProps,
|
|
45
46
|
routerContextProps,
|
|
46
|
-
|
|
47
|
+
WraperRouterProviderProps: props,
|
|
47
48
|
router,
|
|
48
49
|
});
|
|
49
50
|
const RouterProvider = (ReactRouterDom as any)['Router' + 'Provider'];
|
|
@@ -51,6 +52,7 @@ function WrapperRouterProvider(
|
|
|
51
52
|
const createBrowserRouter = (ReactRouterDom as any)[
|
|
52
53
|
'create' + 'BrowserRouter'
|
|
53
54
|
];
|
|
55
|
+
if (!routerContextProps) return <RouterProvider {...props} />;
|
|
54
56
|
|
|
55
57
|
if (routerContextProps.memoryRoute) {
|
|
56
58
|
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
@@ -69,5 +71,5 @@ function WrapperRouterProvider(
|
|
|
69
71
|
|
|
70
72
|
export * from 'react-router-dom/';
|
|
71
73
|
|
|
72
|
-
export {
|
|
73
|
-
export {
|
|
74
|
+
export { WraperRouter as BrowserRouter };
|
|
75
|
+
export { WraperRouterProvider as RouterProvider };
|
package/vite.config.ts
CHANGED
|
@@ -22,8 +22,6 @@ export default defineConfig({
|
|
|
22
22
|
entry: {
|
|
23
23
|
index: path.resolve(__dirname, 'src/index.ts'),
|
|
24
24
|
router: path.resolve(__dirname, 'src/router.tsx'),
|
|
25
|
-
'router-v5': path.resolve(__dirname, 'src/router-v5.tsx'),
|
|
26
|
-
'router-v6': path.resolve(__dirname, 'src/router-v6.tsx'),
|
|
27
25
|
},
|
|
28
26
|
formats: ['cjs', 'es'],
|
|
29
27
|
fileName: (format, entryName) => `${entryName}.${format}.js`,
|
|
@@ -34,34 +32,7 @@ export default defineConfig({
|
|
|
34
32
|
'@remix-run/router',
|
|
35
33
|
'react-router',
|
|
36
34
|
'react-router-dom/',
|
|
37
|
-
'react-router-dom/index.js',
|
|
38
|
-
'react-router-dom/dist/index.js',
|
|
39
35
|
],
|
|
40
|
-
// plugins: [
|
|
41
|
-
// {
|
|
42
|
-
// name: 'modify-output-plugin',
|
|
43
|
-
// generateBundle(options, bundle) {
|
|
44
|
-
// for (const fileName in bundle) {
|
|
45
|
-
// const chunk = bundle[fileName];
|
|
46
|
-
// if (fileName.includes('router-v6') && chunk.type === 'chunk') {
|
|
47
|
-
// chunk.code = chunk.code.replace(
|
|
48
|
-
// // Match 'react-router-dom/' followed by single quotes, double quotes, or backticks, replacing only 'react-router-dom/' to react-router-v6 dist file structure
|
|
49
|
-
// /react-router-dom\/(?=[\'\"\`])/g,
|
|
50
|
-
// 'react-router-dom/dist/index.js',
|
|
51
|
-
// );
|
|
52
|
-
// }
|
|
53
|
-
|
|
54
|
-
// if (fileName.includes('router-v5') && chunk.type === 'chunk') {
|
|
55
|
-
// chunk.code = chunk.code.replace(
|
|
56
|
-
// // Match 'react-router-dom/' followed by single quotes, double quotes, or backticks, replacing only 'react-router-dom/' to react-router-v5 dist file structure
|
|
57
|
-
// /react-router-dom\/(?=[\'\"\`])/g,
|
|
58
|
-
// 'react-router-dom/index.js',
|
|
59
|
-
// );
|
|
60
|
-
// }
|
|
61
|
-
// }
|
|
62
|
-
// },
|
|
63
|
-
// },
|
|
64
|
-
// ],
|
|
65
36
|
},
|
|
66
37
|
minify: false,
|
|
67
38
|
},
|
package/dist/router-v5.cjs.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
const ReactRouterDom = require("react-router-dom/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
|
-
exports.BrowserRouter = WraperRouter;
|
package/dist/router-v5.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
export { }
|
package/dist/router-v5.es.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React__default, { useContext } from "react";
|
|
2
|
-
import * as ReactRouterDom from "react-router-dom/index.js";
|
|
3
|
-
import { R as RouterContext, L as LoggerInstance } from "./context-Bw2PEwa6.js";
|
|
4
|
-
function WraperRouter(props) {
|
|
5
|
-
const { basename, ...propsRes } = props;
|
|
6
|
-
const routerContextProps = useContext(RouterContext) || {};
|
|
7
|
-
LoggerInstance.log(`WraperRouter info >>>`, {
|
|
8
|
-
...routerContextProps,
|
|
9
|
-
routerContextProps,
|
|
10
|
-
WraperRouterProps: props
|
|
11
|
-
});
|
|
12
|
-
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
13
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
14
|
-
ReactRouterDom.MemoryRouter,
|
|
15
|
-
{
|
|
16
|
-
...props,
|
|
17
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
22
|
-
ReactRouterDom.BrowserRouter,
|
|
23
|
-
{
|
|
24
|
-
...propsRes,
|
|
25
|
-
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
WraperRouter as BrowserRouter
|
|
31
|
-
};
|
package/dist/router-v6.cjs.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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 WraperRouterProvider(props) {
|
|
24
|
-
const { router, ...propsRes } = props;
|
|
25
|
-
const routerContextProps = React.useContext(context.RouterContext) || {};
|
|
26
|
-
const routers = router.routes;
|
|
27
|
-
context.LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
28
|
-
...routerContextProps,
|
|
29
|
-
routerContextProps,
|
|
30
|
-
WraperRouterProviderProps: props,
|
|
31
|
-
router
|
|
32
|
-
});
|
|
33
|
-
const RouterProvider = ReactRouterDom__namespace["RouterProvider"];
|
|
34
|
-
const createMemoryRouter = ReactRouterDom__namespace["createMemoryRouter"];
|
|
35
|
-
const createBrowserRouter = ReactRouterDom__namespace["createBrowserRouter"];
|
|
36
|
-
if (routerContextProps.memoryRoute) {
|
|
37
|
-
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
38
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
39
|
-
});
|
|
40
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
41
|
-
} else {
|
|
42
|
-
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
43
|
-
basename: routerContextProps.basename,
|
|
44
|
-
future: router.future,
|
|
45
|
-
window: router.window
|
|
46
|
-
});
|
|
47
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.RouterProvider = WraperRouterProvider;
|
|
51
|
-
Object.keys(ReactRouterDom).forEach((k) => {
|
|
52
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
53
|
-
Object.defineProperty(exports, k, {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
get: () => ReactRouterDom[k]
|
|
56
|
-
});
|
|
57
|
-
});
|
package/dist/router-v6.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { default as default_2 } from 'react';
|
|
2
|
-
import * as ReactRouterDom from 'react-router-dom/dist/index.js';
|
|
3
|
-
|
|
4
|
-
export declare function RouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): default_2.JSX.Element;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export * from "react-router-dom/dist/index.js";
|
|
8
|
-
|
|
9
|
-
export { }
|
package/dist/router-v6.es.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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 WraperRouterProvider(props) {
|
|
6
|
-
const { router, ...propsRes } = props;
|
|
7
|
-
const routerContextProps = useContext(RouterContext) || {};
|
|
8
|
-
const routers = router.routes;
|
|
9
|
-
LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
10
|
-
...routerContextProps,
|
|
11
|
-
routerContextProps,
|
|
12
|
-
WraperRouterProviderProps: props,
|
|
13
|
-
router
|
|
14
|
-
});
|
|
15
|
-
const RouterProvider = ReactRouterDom["RouterProvider"];
|
|
16
|
-
const createMemoryRouter = ReactRouterDom["createMemoryRouter"];
|
|
17
|
-
const createBrowserRouter = ReactRouterDom["createBrowserRouter"];
|
|
18
|
-
if (routerContextProps.memoryRoute) {
|
|
19
|
-
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
20
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
21
|
-
});
|
|
22
|
-
return /* @__PURE__ */ React__default.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
23
|
-
} else {
|
|
24
|
-
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
25
|
-
basename: routerContextProps.basename,
|
|
26
|
-
future: router.future,
|
|
27
|
-
window: router.window
|
|
28
|
-
});
|
|
29
|
-
return /* @__PURE__ */ React__default.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
WraperRouterProvider as RouterProvider
|
|
34
|
-
};
|
package/src/router-v5.tsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
// The upper alias react-router-dom$ into this file avoids the loop
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import * as ReactRouterDom from 'react-router-dom/index.js';
|
|
5
|
-
|
|
6
|
-
import { RouterContext } from './context';
|
|
7
|
-
import { LoggerInstance } from './utils';
|
|
8
|
-
|
|
9
|
-
function WraperRouter(
|
|
10
|
-
props:
|
|
11
|
-
| Parameters<typeof ReactRouterDom.BrowserRouter>[0]
|
|
12
|
-
| Parameters<typeof ReactRouterDom.MemoryRouter>[0],
|
|
13
|
-
) {
|
|
14
|
-
const { basename, ...propsRes } = props;
|
|
15
|
-
const routerContextProps = useContext(RouterContext) || {};
|
|
16
|
-
|
|
17
|
-
LoggerInstance.log(`WraperRouter info >>>`, {
|
|
18
|
-
...routerContextProps,
|
|
19
|
-
routerContextProps,
|
|
20
|
-
WraperRouterProps: props,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (routerContextProps?.memoryRoute) {
|
|
24
|
-
return (
|
|
25
|
-
<ReactRouterDom.MemoryRouter
|
|
26
|
-
{...props}
|
|
27
|
-
initialEntries={[routerContextProps?.memoryRoute.entryPath]}
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
return (
|
|
32
|
-
<ReactRouterDom.BrowserRouter
|
|
33
|
-
{...propsRes}
|
|
34
|
-
basename={routerContextProps?.basename || basename}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { WraperRouter as BrowserRouter };
|
package/src/router-v6.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
// The upper alias react-router-dom$ into this file avoids the loop
|
|
3
|
-
import * as ReactRouterDom from 'react-router-dom/dist/index.js';
|
|
4
|
-
|
|
5
|
-
import { RouterContext } from './context';
|
|
6
|
-
import { LoggerInstance } from './utils';
|
|
7
|
-
|
|
8
|
-
function WraperRouterProvider(
|
|
9
|
-
props: Parameters<typeof ReactRouterDom.RouterProvider>[0],
|
|
10
|
-
) {
|
|
11
|
-
const { router, ...propsRes } = props;
|
|
12
|
-
const routerContextProps = useContext(RouterContext) || {};
|
|
13
|
-
const routers = router.routes;
|
|
14
|
-
LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
15
|
-
...routerContextProps,
|
|
16
|
-
routerContextProps,
|
|
17
|
-
WraperRouterProviderProps: props,
|
|
18
|
-
router,
|
|
19
|
-
});
|
|
20
|
-
const RouterProvider = (ReactRouterDom as any)['Router' + 'Provider'];
|
|
21
|
-
const createMemoryRouter = (ReactRouterDom as any)['create' + 'MemoryRouter'];
|
|
22
|
-
const createBrowserRouter = (ReactRouterDom as any)[
|
|
23
|
-
'create' + 'BrowserRouter'
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
if (routerContextProps.memoryRoute) {
|
|
27
|
-
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
28
|
-
initialEntries: [routerContextProps?.memoryRoute.entryPath],
|
|
29
|
-
});
|
|
30
|
-
return <RouterProvider router={MemeoryRouterInstance} />;
|
|
31
|
-
} else {
|
|
32
|
-
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
33
|
-
basename: routerContextProps.basename,
|
|
34
|
-
future: router.future,
|
|
35
|
-
window: router.window,
|
|
36
|
-
});
|
|
37
|
-
return <RouterProvider {...propsRes} router={BrowserRouterInstance} />;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export * from 'react-router-dom/dist/index.js';
|
|
42
|
-
export { WraperRouterProvider as RouterProvider };
|