@module-federation/bridge-react 0.0.0-next-20240822035014 → 0.0.0-next-20240822090000
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 +3 -10
- package/__tests__/bridge.spec.tsx +3 -37
- package/dist/index.cjs.js +112 -142
- package/dist/index.d.ts +15 -16
- package/dist/index.es.js +114 -144
- package/dist/router.cjs.js +12 -8
- package/dist/router.es.js +12 -8
- package/package.json +2 -12
- package/src/create.tsx +25 -21
- package/src/provider.tsx +64 -69
- package/src/remote/index.tsx +56 -93
- package/src/router.tsx +10 -8
- package/vite.config.ts +0 -29
- package/dist/router-v5.cjs.js +0 -56
- package/dist/router-v5.d.ts +0 -9
- package/dist/router-v5.es.js +0 -32
- package/dist/router-v6.cjs.js +0 -83
- package/dist/router-v6.d.ts +0 -11
- package/dist/router-v6.es.js +0 -60
- package/src/router-v5.tsx +0 -44
- package/src/router-v6.tsx +0 -73
package/src/provider.tsx
CHANGED
|
@@ -8,91 +8,84 @@ import type {
|
|
|
8
8
|
RenderFnParams,
|
|
9
9
|
} from '@module-federation/bridge-shared';
|
|
10
10
|
import { LoggerInstance, atLeastReact18 } from './utils';
|
|
11
|
-
import { ErrorBoundary } from 'react-error-boundary';
|
|
12
11
|
|
|
13
|
-
type RootType = HTMLElement | ReactDOMClient.Root;
|
|
14
12
|
type ProviderFnParams<T> = {
|
|
15
13
|
rootComponent: React.ComponentType<T>;
|
|
16
|
-
render?: (
|
|
17
|
-
App: React.ReactElement,
|
|
18
|
-
id?: HTMLElement | string,
|
|
19
|
-
) => RootType | Promise<RootType>;
|
|
20
14
|
};
|
|
21
15
|
|
|
16
|
+
interface Provider<T> {
|
|
17
|
+
render(info: any): void;
|
|
18
|
+
destroy(info: { dom: HTMLElement }): void;
|
|
19
|
+
rawComponent: React.ComponentType;
|
|
20
|
+
__BRIDGE_FN__: (_args: T) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
22
23
|
export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
24
|
+
let provider: Provider<T>;
|
|
25
|
+
|
|
23
26
|
return () => {
|
|
24
|
-
const rootMap = new Map<any,
|
|
27
|
+
const rootMap = new Map<any, ReactDOMClient.Root>();
|
|
28
|
+
|
|
25
29
|
const RawComponent = (info: { propsInfo: T; appInfo: ProviderParams }) => {
|
|
26
|
-
const { appInfo, propsInfo
|
|
27
|
-
const {
|
|
30
|
+
const { appInfo, propsInfo } = info;
|
|
31
|
+
const { name, memoryRoute, basename = '/' } = appInfo;
|
|
32
|
+
|
|
28
33
|
return (
|
|
29
|
-
<RouterContext.Provider value={{
|
|
30
|
-
<bridgeInfo.rootComponent
|
|
31
|
-
{...propsInfo}
|
|
32
|
-
basename={basename}
|
|
33
|
-
{...restProps}
|
|
34
|
-
/>
|
|
34
|
+
<RouterContext.Provider value={{ name, basename, memoryRoute }}>
|
|
35
|
+
<bridgeInfo.rootComponent {...propsInfo} basename={basename} />
|
|
35
36
|
</RouterContext.Provider>
|
|
36
37
|
);
|
|
37
38
|
};
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
dom,
|
|
45
|
-
basename,
|
|
46
|
-
memoryRoute,
|
|
47
|
-
fallback,
|
|
48
|
-
...propsInfo
|
|
49
|
-
} = info;
|
|
50
|
-
const rootComponentWithErrorBoundary = (
|
|
51
|
-
// set ErrorBoundary for RawComponent rendering error, usually caused by user app rendering error
|
|
52
|
-
<ErrorBoundary FallbackComponent={fallback}>
|
|
53
|
-
<RawComponent
|
|
54
|
-
appInfo={{
|
|
55
|
-
moduleName,
|
|
56
|
-
basename,
|
|
57
|
-
memoryRoute,
|
|
58
|
-
}}
|
|
59
|
-
propsInfo={propsInfo}
|
|
60
|
-
/>
|
|
61
|
-
</ErrorBoundary>
|
|
62
|
-
);
|
|
40
|
+
if (!provider) {
|
|
41
|
+
provider = {
|
|
42
|
+
render(info: RenderFnParams & any) {
|
|
43
|
+
LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
44
|
+
const { name, basename, memoryRoute, ...propsInfo } = info;
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// in case bridgeInfo?.render is an async function, resolve this to promise
|
|
67
|
-
Promise.resolve(
|
|
68
|
-
bridgeInfo?.render(rootComponentWithErrorBoundary, dom),
|
|
69
|
-
).then((root: RootType) => rootMap.set(info.dom, root));
|
|
70
|
-
} else {
|
|
71
|
-
const root: RootType = ReactDOMClient.createRoot(info.dom);
|
|
72
|
-
root.render(rootComponentWithErrorBoundary);
|
|
46
|
+
if (atLeastReact18(React)) {
|
|
47
|
+
const root = ReactDOMClient.createRoot(info.dom);
|
|
73
48
|
rootMap.set(info.dom, root);
|
|
49
|
+
root.render(
|
|
50
|
+
<RawComponent
|
|
51
|
+
propsInfo={propsInfo}
|
|
52
|
+
appInfo={{
|
|
53
|
+
name,
|
|
54
|
+
basename,
|
|
55
|
+
memoryRoute,
|
|
56
|
+
}}
|
|
57
|
+
/>,
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
ReactDOM.render(
|
|
61
|
+
<RawComponent
|
|
62
|
+
propsInfo={propsInfo}
|
|
63
|
+
appInfo={{
|
|
64
|
+
name,
|
|
65
|
+
basename,
|
|
66
|
+
memoryRoute,
|
|
67
|
+
}}
|
|
68
|
+
/>,
|
|
69
|
+
info.dom,
|
|
70
|
+
);
|
|
74
71
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
rawComponent: bridgeInfo.rootComponent,
|
|
94
|
-
__BRIDGE_FN__: (_args: T) => {},
|
|
95
|
-
};
|
|
72
|
+
},
|
|
73
|
+
destroy(info: { dom: HTMLElement }) {
|
|
74
|
+
LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
75
|
+
dom: info.dom,
|
|
76
|
+
});
|
|
77
|
+
if (atLeastReact18(React)) {
|
|
78
|
+
const root = rootMap.get(info.dom);
|
|
79
|
+
root?.unmount();
|
|
80
|
+
} else {
|
|
81
|
+
ReactDOM.unmountComponentAtNode(info.dom);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
rawComponent: bridgeInfo.rootComponent,
|
|
85
|
+
__BRIDGE_FN__: (_args: T) => {},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return provider;
|
|
96
89
|
};
|
|
97
90
|
}
|
|
98
91
|
|
|
@@ -103,3 +96,5 @@ export function ShadowRoot(info: { children: () => JSX.Element }) {
|
|
|
103
96
|
|
|
104
97
|
return <div ref={domRef}>{root && <info.children />}</div>;
|
|
105
98
|
}
|
|
99
|
+
|
|
100
|
+
// function ShadowContent() {}
|
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,97 +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
|
-
);
|
|
81
|
-
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
|
+
}
|
|
82
72
|
});
|
|
73
|
+
};
|
|
74
|
+
}, []);
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (providerInfoRef.current?.destroy) {
|
|
88
|
-
LoggerInstance.log(
|
|
89
|
-
`createRemoteComponent LazyComponent destroy >>>`,
|
|
90
|
-
{ moduleName, basename, dom: renderDom.current },
|
|
91
|
-
);
|
|
92
|
-
providerInfoRef.current?.destroy({
|
|
93
|
-
dom: renderDom.current,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
}, []);
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<div
|
|
102
|
-
className={props?.className}
|
|
103
|
-
style={props?.style}
|
|
104
|
-
ref={rootRef}
|
|
105
|
-
></div>
|
|
106
|
-
);
|
|
107
|
-
};
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
return <div ref={rootRef}></div>;
|
|
78
|
+
};
|
|
108
79
|
|
|
109
|
-
|
|
110
|
-
return <RemoteApp />;
|
|
111
|
-
});
|
|
80
|
+
(RemoteApp as any)['__APP_VERSION__'] = __APP_VERSION__;
|
|
112
81
|
|
|
113
82
|
interface ExtraDataProps {
|
|
114
83
|
basename?: string;
|
|
115
84
|
}
|
|
116
85
|
|
|
117
|
-
export function withRouterData<
|
|
118
|
-
P extends Parameters<typeof RemoteAppWrapper>[0],
|
|
119
|
-
>(
|
|
86
|
+
export function withRouterData<P extends Parameters<typeof RemoteApp>[0]>(
|
|
120
87
|
WrappedComponent: React.ComponentType<P & ExtraDataProps>,
|
|
121
88
|
): React.FC<Omit<P, keyof ExtraDataProps>> {
|
|
122
|
-
|
|
89
|
+
return (props: any) => {
|
|
123
90
|
let enableDispathPopstate = false;
|
|
124
91
|
let routerContextVal: any;
|
|
125
92
|
try {
|
|
@@ -191,12 +158,8 @@ export function withRouterData<
|
|
|
191
158
|
}, [location]);
|
|
192
159
|
}
|
|
193
160
|
|
|
194
|
-
return <WrappedComponent {...(props as P)} basename={basename}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return forwardRef(function (props, ref) {
|
|
198
|
-
return <Component {...props} ref={ref} />;
|
|
199
|
-
}) as any;
|
|
161
|
+
return <WrappedComponent {...(props as P)} basename={basename} />;
|
|
162
|
+
};
|
|
200
163
|
}
|
|
201
164
|
|
|
202
|
-
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,33 +32,6 @@ 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
|
-
],
|
|
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
35
|
],
|
|
65
36
|
},
|
|
66
37
|
minify: false,
|
package/dist/router-v5.cjs.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
});
|
package/dist/router-v5.d.ts
DELETED
|
@@ -1,9 +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
|
-
|
|
7
|
-
export * from "react-router-dom/";
|
|
8
|
-
|
|
9
|
-
export { }
|
package/dist/router-v5.es.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/router-v6.cjs.js
DELETED
|
@@ -1,83 +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 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
|
-
});
|
package/dist/router-v6.d.ts
DELETED
|
@@ -1,11 +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 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 { }
|