@module-federation/bridge-react 0.0.0-next-20240723095610 → 0.0.0-next-20240724103050
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 +26 -3
- package/dist/index.cjs.js +75 -101
- package/dist/index.d.ts +6 -16
- package/dist/index.es.js +77 -103
- package/package.json +2 -12
- package/src/create.tsx +22 -22
- package/src/provider.tsx +23 -37
- package/src/remote/index.tsx +56 -67
- package/src/router.tsx +0 -2
- package/vite.config.ts +0 -4
- package/dist/router-v5.cjs.js +0 -80
- package/dist/router-v5.d.ts +0 -8
- package/dist/router-v5.es.js +0 -63
- package/dist/router-v6.cjs.js +0 -87
- package/dist/router-v6.d.ts +0 -11
- package/dist/router-v6.es.js +0 -64
- package/src/router-v5.tsx +0 -78
- package/src/router-v6.tsx +0 -76
package/src/create.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
|
|
3
2
|
import type { ProviderParams } from '@module-federation/bridge-shared';
|
|
4
3
|
import { LoggerInstance } from './utils';
|
|
5
4
|
import {
|
|
@@ -7,9 +6,11 @@ import {
|
|
|
7
6
|
ErrorBoundaryPropsWithComponent,
|
|
8
7
|
} from 'react-error-boundary';
|
|
9
8
|
import RemoteApp from './remote';
|
|
9
|
+
|
|
10
10
|
export interface RenderFnParams extends ProviderParams {
|
|
11
11
|
dom?: any;
|
|
12
12
|
}
|
|
13
|
+
|
|
13
14
|
interface RemoteModule {
|
|
14
15
|
provider: () => {
|
|
15
16
|
render: (
|
|
@@ -52,13 +53,12 @@ function createLazyRemoteComponent<T, E extends keyof T>(info: {
|
|
|
52
53
|
basename?: ProviderParams['basename'];
|
|
53
54
|
memoryRoute?: ProviderParams['memoryRoute'];
|
|
54
55
|
}
|
|
55
|
-
>((props,
|
|
56
|
+
>((props, _ref) => {
|
|
56
57
|
return (
|
|
57
58
|
<RemoteApp
|
|
58
59
|
name={moduleName}
|
|
59
60
|
providerInfo={exportFn}
|
|
60
61
|
exportName={info.export || 'default'}
|
|
61
|
-
ref={ref}
|
|
62
62
|
{...props}
|
|
63
63
|
/>
|
|
64
64
|
);
|
|
@@ -84,35 +84,35 @@ function createLazyRemoteComponent<T, E extends keyof T>(info: {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
type RemoteProps = {
|
|
88
|
-
basename?: ProviderParams['basename'];
|
|
89
|
-
memoryRoute?: ProviderParams['memoryRoute'];
|
|
90
|
-
[key: string]: any;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
87
|
export function createRemoteComponent<T, E extends keyof T>(info: {
|
|
94
88
|
loader: () => Promise<T>;
|
|
95
89
|
loading: React.ReactNode;
|
|
96
90
|
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
97
91
|
export?: E;
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
}) {
|
|
93
|
+
type ExportType = T[E] extends (...args: any) => any
|
|
94
|
+
? ReturnType<T[E]>
|
|
95
|
+
: never;
|
|
96
|
+
type RawComponentType = '__BRIDGE_FN__' extends keyof ExportType
|
|
97
|
+
? ExportType['__BRIDGE_FN__'] extends (...args: any) => any
|
|
98
|
+
? Parameters<ExportType['__BRIDGE_FN__']>[0]
|
|
99
|
+
: {}
|
|
100
|
+
: {};
|
|
107
101
|
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
props: {
|
|
106
|
+
basename?: ProviderParams['basename'];
|
|
107
|
+
memoryRoute?: ProviderParams['memoryRoute'];
|
|
108
|
+
} & RawComponentType,
|
|
109
|
+
) => {
|
|
110
110
|
return (
|
|
111
111
|
<ErrorBoundary FallbackComponent={info.fallback}>
|
|
112
112
|
<React.Suspense fallback={info.loading}>
|
|
113
|
-
<LazyComponent {...props}
|
|
113
|
+
<LazyComponent {...props} />
|
|
114
114
|
</React.Suspense>
|
|
115
115
|
</ErrorBoundary>
|
|
116
116
|
);
|
|
117
|
-
}
|
|
117
|
+
};
|
|
118
118
|
}
|
package/src/provider.tsx
CHANGED
|
@@ -9,61 +9,45 @@ import type {
|
|
|
9
9
|
} from '@module-federation/bridge-shared';
|
|
10
10
|
import { LoggerInstance, atLeastReact18 } from './utils';
|
|
11
11
|
|
|
12
|
-
type RootType = HTMLElement | ReactDOMClient.Root;
|
|
13
12
|
type ProviderFnParams<T> = {
|
|
14
13
|
rootComponent: React.ComponentType<T>;
|
|
15
|
-
render?: (App: React.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
19
17
|
return () => {
|
|
20
|
-
const rootMap = new Map<any,
|
|
18
|
+
const rootMap = new Map<any, ReactDOMClient.Root>();
|
|
19
|
+
|
|
21
20
|
const RawComponent = (info: { propsInfo: T; appInfo: ProviderParams }) => {
|
|
22
|
-
const { appInfo, propsInfo
|
|
21
|
+
const { appInfo, propsInfo } = info;
|
|
23
22
|
const { name, memoryRoute, basename = '/' } = appInfo;
|
|
24
23
|
|
|
25
24
|
return (
|
|
26
25
|
<RouterContext.Provider value={{ name, basename, memoryRoute }}>
|
|
27
|
-
<bridgeInfo.rootComponent {...propsInfo} basename={basename}
|
|
26
|
+
<bridgeInfo.rootComponent {...propsInfo} basename={basename} />
|
|
28
27
|
</RouterContext.Provider>
|
|
29
28
|
);
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
return {
|
|
33
|
-
|
|
32
|
+
render(info: RenderFnParams & any) {
|
|
34
33
|
LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
35
34
|
const { name, basename, memoryRoute, ...propsInfo } = info;
|
|
35
|
+
|
|
36
36
|
if (atLeastReact18(React)) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)).then((root: RootType) => rootMap.set(info.dom, root));
|
|
50
|
-
} else {
|
|
51
|
-
const root: RootType = ReactDOMClient.createRoot(info.dom);
|
|
52
|
-
root.render(
|
|
53
|
-
<RawComponent
|
|
54
|
-
propsInfo={propsInfo}
|
|
55
|
-
appInfo={{
|
|
56
|
-
name,
|
|
57
|
-
basename,
|
|
58
|
-
memoryRoute,
|
|
59
|
-
}}
|
|
60
|
-
/>,
|
|
61
|
-
);
|
|
62
|
-
rootMap.set(info.dom, root);
|
|
63
|
-
}
|
|
37
|
+
const root = ReactDOMClient.createRoot(info.dom);
|
|
38
|
+
rootMap.set(info.dom, root);
|
|
39
|
+
root.render(
|
|
40
|
+
<RawComponent
|
|
41
|
+
propsInfo={propsInfo}
|
|
42
|
+
appInfo={{
|
|
43
|
+
name,
|
|
44
|
+
basename,
|
|
45
|
+
memoryRoute,
|
|
46
|
+
}}
|
|
47
|
+
/>,
|
|
48
|
+
);
|
|
64
49
|
} else {
|
|
65
|
-
|
|
66
|
-
renderFunc(
|
|
50
|
+
ReactDOM.render(
|
|
67
51
|
<RawComponent
|
|
68
52
|
propsInfo={propsInfo}
|
|
69
53
|
appInfo={{
|
|
@@ -76,13 +60,13 @@ export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
|
|
|
76
60
|
);
|
|
77
61
|
}
|
|
78
62
|
},
|
|
79
|
-
|
|
63
|
+
destroy(info: { dom: HTMLElement }) {
|
|
80
64
|
LoggerInstance.log(`createBridgeComponent destroy Info`, {
|
|
81
65
|
dom: info.dom,
|
|
82
66
|
});
|
|
83
67
|
if (atLeastReact18(React)) {
|
|
84
68
|
const root = rootMap.get(info.dom);
|
|
85
|
-
|
|
69
|
+
root?.unmount();
|
|
86
70
|
} else {
|
|
87
71
|
ReactDOM.unmountComponentAtNode(info.dom);
|
|
88
72
|
}
|
|
@@ -100,3 +84,5 @@ export function ShadowRoot(info: { children: () => JSX.Element }) {
|
|
|
100
84
|
|
|
101
85
|
return <div ref={domRef}>{root && <info.children />}</div>;
|
|
102
86
|
}
|
|
87
|
+
|
|
88
|
+
// function ShadowContent() {}
|
package/src/remote/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useRef, useState
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import * as ReactRouterDOM from 'react-router-dom';
|
|
3
3
|
import type { ProviderParams } from '@module-federation/bridge-shared';
|
|
4
4
|
import { LoggerInstance, pathJoin } from '../utils';
|
|
@@ -27,74 +27,67 @@ interface RemoteAppParams {
|
|
|
27
27
|
exportName: string | number | symbol;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
basename,
|
|
52
|
-
memoryRoute,
|
|
53
|
-
...resProps,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
renderDom.current = rootRef.current;
|
|
57
|
-
LoggerInstance.log(
|
|
58
|
-
`createRemoteComponent LazyComponent render >>>`,
|
|
59
|
-
renderProps,
|
|
60
|
-
);
|
|
61
|
-
providerReturn.render(renderProps);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return () => {
|
|
65
|
-
clearTimeout(renderTimeout);
|
|
66
|
-
setTimeout(() => {
|
|
67
|
-
if (providerInfoRef.current?.destroy) {
|
|
68
|
-
LoggerInstance.log(
|
|
69
|
-
`createRemoteComponent LazyComponent destroy >>>`,
|
|
70
|
-
{ name, basename, dom: renderDom.current },
|
|
71
|
-
);
|
|
72
|
-
providerInfoRef.current?.destroy({
|
|
73
|
-
dom: renderDom.current,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
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,
|
|
77
51
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}, []);
|
|
75
|
+
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
return <div ref={rootRef}></div>;
|
|
78
|
+
};
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
return <RemoteApp />
|
|
86
|
-
});
|
|
80
|
+
(RemoteApp as any)['__APP_VERSION__'] = __APP_VERSION__;
|
|
87
81
|
|
|
88
82
|
interface ExtraDataProps {
|
|
89
83
|
basename?: string;
|
|
90
84
|
}
|
|
91
85
|
|
|
92
|
-
export function withRouterData<P extends Parameters<typeof
|
|
86
|
+
export function withRouterData<P extends Parameters<typeof RemoteApp>[0]>(
|
|
93
87
|
WrappedComponent: React.ComponentType<P & ExtraDataProps>,
|
|
94
88
|
): React.FC<Omit<P, keyof ExtraDataProps>> {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
let enableDispathPopstate = false
|
|
89
|
+
return (props: any) => {
|
|
90
|
+
let enableDispathPopstate = false;
|
|
98
91
|
let routerContextVal: any;
|
|
99
92
|
try {
|
|
100
93
|
ReactRouterDOM.useLocation();
|
|
@@ -165,12 +158,8 @@ export function withRouterData<P extends Parameters<typeof RemoteAppWrapper>[0]>
|
|
|
165
158
|
}, [location]);
|
|
166
159
|
}
|
|
167
160
|
|
|
168
|
-
return <WrappedComponent {...(props as P)} basename={basename}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return forwardRef(function (props, ref) {
|
|
172
|
-
return <Component {...props} ref={ref} />
|
|
173
|
-
}) as any;
|
|
161
|
+
return <WrappedComponent {...(props as P)} basename={basename} />;
|
|
162
|
+
};
|
|
174
163
|
}
|
|
175
164
|
|
|
176
|
-
export default withRouterData(
|
|
165
|
+
export default withRouterData(RemoteApp);
|
package/src/router.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
// The upper alias react-router-dom$ into this file avoids the loop
|
|
3
3
|
import * as ReactRouterDom from 'react-router-dom/';
|
|
4
|
-
|
|
5
4
|
import { RouterContext } from './context';
|
|
6
5
|
import { LoggerInstance } from './utils';
|
|
7
6
|
|
|
@@ -53,7 +52,6 @@ function WraperRouterProvider(
|
|
|
53
52
|
const createBrowserRouter = (ReactRouterDom as any)[
|
|
54
53
|
'create' + 'BrowserRouter'
|
|
55
54
|
];
|
|
56
|
-
|
|
57
55
|
if (!routerContextProps) return <RouterProvider {...props} />;
|
|
58
56
|
|
|
59
57
|
if (routerContextProps.memoryRoute) {
|
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,8 +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
35
|
],
|
|
40
36
|
},
|
|
41
37
|
minify: false,
|
package/dist/router-v5.cjs.js
DELETED
|
@@ -1,80 +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)
|
|
32
|
-
return /* @__PURE__ */ React.createElement(ReactRouterDom__namespace.BrowserRouter, { ...props });
|
|
33
|
-
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
34
|
-
return /* @__PURE__ */ React.createElement(
|
|
35
|
-
ReactRouterDom__namespace.MemoryRouter,
|
|
36
|
-
{
|
|
37
|
-
...props,
|
|
38
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return /* @__PURE__ */ React.createElement(
|
|
43
|
-
ReactRouterDom__namespace.BrowserRouter,
|
|
44
|
-
{
|
|
45
|
-
...propsRes,
|
|
46
|
-
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
function WraperRouterProvider(props) {
|
|
51
|
-
const { router, ...propsRes } = props;
|
|
52
|
-
const routerContextProps = React.useContext(context.RouterContext) || {};
|
|
53
|
-
const routers = router.routes;
|
|
54
|
-
context.LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
55
|
-
...routerContextProps,
|
|
56
|
-
routerContextProps,
|
|
57
|
-
WraperRouterProviderProps: props,
|
|
58
|
-
router
|
|
59
|
-
});
|
|
60
|
-
const RouterProvider = ReactRouterDom__namespace["RouterProvider"];
|
|
61
|
-
const createMemoryRouter = ReactRouterDom__namespace["createMemoryRouter"];
|
|
62
|
-
const createBrowserRouter = ReactRouterDom__namespace["createBrowserRouter"];
|
|
63
|
-
if (!routerContextProps)
|
|
64
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { ...props });
|
|
65
|
-
if (routerContextProps.memoryRoute) {
|
|
66
|
-
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
67
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
68
|
-
});
|
|
69
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
70
|
-
} else {
|
|
71
|
-
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
72
|
-
basename: routerContextProps.basename,
|
|
73
|
-
future: router.future,
|
|
74
|
-
window: router.window
|
|
75
|
-
});
|
|
76
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.BrowserRouter = WraperRouter;
|
|
80
|
-
exports.RouterProvider = WraperRouterProvider;
|
package/dist/router-v5.d.ts
DELETED
|
@@ -1,8 +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 declare function RouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): default_2.JSX.Element;
|
|
7
|
-
|
|
8
|
-
export { }
|
package/dist/router-v5.es.js
DELETED
|
@@ -1,63 +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)
|
|
13
|
-
return /* @__PURE__ */ React__default.createElement(ReactRouterDom.BrowserRouter, { ...props });
|
|
14
|
-
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
15
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
16
|
-
ReactRouterDom.MemoryRouter,
|
|
17
|
-
{
|
|
18
|
-
...props,
|
|
19
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
24
|
-
ReactRouterDom.BrowserRouter,
|
|
25
|
-
{
|
|
26
|
-
...propsRes,
|
|
27
|
-
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
function WraperRouterProvider(props) {
|
|
32
|
-
const { router, ...propsRes } = props;
|
|
33
|
-
const routerContextProps = useContext(RouterContext) || {};
|
|
34
|
-
const routers = router.routes;
|
|
35
|
-
LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
36
|
-
...routerContextProps,
|
|
37
|
-
routerContextProps,
|
|
38
|
-
WraperRouterProviderProps: props,
|
|
39
|
-
router
|
|
40
|
-
});
|
|
41
|
-
const RouterProvider = ReactRouterDom["RouterProvider"];
|
|
42
|
-
const createMemoryRouter = ReactRouterDom["createMemoryRouter"];
|
|
43
|
-
const createBrowserRouter = ReactRouterDom["createBrowserRouter"];
|
|
44
|
-
if (!routerContextProps)
|
|
45
|
-
return /* @__PURE__ */ React__default.createElement(RouterProvider, { ...props });
|
|
46
|
-
if (routerContextProps.memoryRoute) {
|
|
47
|
-
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
48
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
49
|
-
});
|
|
50
|
-
return /* @__PURE__ */ React__default.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
51
|
-
} else {
|
|
52
|
-
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
53
|
-
basename: routerContextProps.basename,
|
|
54
|
-
future: router.future,
|
|
55
|
-
window: router.window
|
|
56
|
-
});
|
|
57
|
-
return /* @__PURE__ */ React__default.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export {
|
|
61
|
-
WraperRouter as BrowserRouter,
|
|
62
|
-
WraperRouterProvider as RouterProvider
|
|
63
|
-
};
|
package/dist/router-v6.cjs.js
DELETED
|
@@ -1,87 +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)
|
|
32
|
-
return /* @__PURE__ */ React.createElement(ReactRouterDom__namespace.BrowserRouter, { ...props });
|
|
33
|
-
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
34
|
-
return /* @__PURE__ */ React.createElement(
|
|
35
|
-
ReactRouterDom__namespace.MemoryRouter,
|
|
36
|
-
{
|
|
37
|
-
...props,
|
|
38
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return /* @__PURE__ */ React.createElement(
|
|
43
|
-
ReactRouterDom__namespace.BrowserRouter,
|
|
44
|
-
{
|
|
45
|
-
...propsRes,
|
|
46
|
-
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
function WraperRouterProvider(props) {
|
|
51
|
-
const { router, ...propsRes } = props;
|
|
52
|
-
const routerContextProps = React.useContext(context.RouterContext) || {};
|
|
53
|
-
const routers = router.routes;
|
|
54
|
-
context.LoggerInstance.log(`WraperRouterProvider info >>>`, {
|
|
55
|
-
...routerContextProps,
|
|
56
|
-
routerContextProps,
|
|
57
|
-
WraperRouterProviderProps: props,
|
|
58
|
-
router
|
|
59
|
-
});
|
|
60
|
-
const RouterProvider = ReactRouterDom__namespace["RouterProvider"];
|
|
61
|
-
const createMemoryRouter = ReactRouterDom__namespace["createMemoryRouter"];
|
|
62
|
-
const createBrowserRouter = ReactRouterDom__namespace["createBrowserRouter"];
|
|
63
|
-
if (!routerContextProps)
|
|
64
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { ...props });
|
|
65
|
-
if (routerContextProps.memoryRoute) {
|
|
66
|
-
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
67
|
-
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
68
|
-
});
|
|
69
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
70
|
-
} else {
|
|
71
|
-
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
72
|
-
basename: routerContextProps.basename,
|
|
73
|
-
future: router.future,
|
|
74
|
-
window: router.window
|
|
75
|
-
});
|
|
76
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.BrowserRouter = WraperRouter;
|
|
80
|
-
exports.RouterProvider = WraperRouterProvider;
|
|
81
|
-
Object.keys(ReactRouterDom).forEach((k) => {
|
|
82
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
83
|
-
Object.defineProperty(exports, k, {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
get: () => ReactRouterDom[k]
|
|
86
|
-
});
|
|
87
|
-
});
|
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 { }
|