@module-federation/bridge-react 0.0.0-next-20240726084328 → 0.0.0-next-20240731082143
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 +14 -2
- package/dist/index.cjs.js +74 -111
- package/dist/index.d.ts +7 -15
- package/dist/index.es.js +76 -113
- package/package.json +2 -12
- package/src/create.tsx +24 -19
- package/src/provider.tsx +23 -37
- package/src/remote/index.tsx +55 -78
- 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 {
|
|
@@ -11,10 +10,13 @@ import RemoteApp from './remote';
|
|
|
11
10
|
export interface RenderFnParams extends ProviderParams {
|
|
12
11
|
dom?: any;
|
|
13
12
|
}
|
|
13
|
+
|
|
14
14
|
interface RemoteModule {
|
|
15
15
|
provider: () => {
|
|
16
16
|
render: (
|
|
17
|
-
info:
|
|
17
|
+
info: ProviderParams & {
|
|
18
|
+
dom: any;
|
|
19
|
+
},
|
|
18
20
|
) => void;
|
|
19
21
|
destroy: (info: { dom: any }) => void;
|
|
20
22
|
};
|
|
@@ -25,7 +27,6 @@ function createLazyRemoteComponent<T, E extends keyof T>(info: {
|
|
|
25
27
|
loading: React.ReactNode;
|
|
26
28
|
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
27
29
|
export?: E;
|
|
28
|
-
dom?: string;
|
|
29
30
|
}) {
|
|
30
31
|
const exportName = info?.export || 'default';
|
|
31
32
|
return React.lazy(async () => {
|
|
@@ -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
|
);
|
|
@@ -89,25 +89,30 @@ export function createRemoteComponent<T, E extends keyof T>(info: {
|
|
|
89
89
|
loading: React.ReactNode;
|
|
90
90
|
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
91
91
|
export?: E;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
+
: {};
|
|
101
|
+
|
|
102
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
102
103
|
|
|
103
|
-
return
|
|
104
|
-
|
|
104
|
+
return (
|
|
105
|
+
props: {
|
|
106
|
+
basename?: ProviderParams['basename'];
|
|
107
|
+
memoryRoute?: ProviderParams['memoryRoute'];
|
|
108
|
+
} & RawComponentType,
|
|
109
|
+
) => {
|
|
105
110
|
return (
|
|
106
111
|
<ErrorBoundary FallbackComponent={info.fallback}>
|
|
107
112
|
<React.Suspense fallback={info.loading}>
|
|
108
|
-
<LazyComponent {...props}
|
|
113
|
+
<LazyComponent {...props} />
|
|
109
114
|
</React.Suspense>
|
|
110
115
|
</ErrorBoundary>
|
|
111
116
|
);
|
|
112
|
-
}
|
|
117
|
+
};
|
|
113
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,10 +1,11 @@
|
|
|
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';
|
|
5
5
|
import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
|
|
6
6
|
|
|
7
7
|
declare const __APP_VERSION__: string;
|
|
8
|
+
|
|
8
9
|
export interface RenderFnParams extends ProviderParams {
|
|
9
10
|
dom?: any;
|
|
10
11
|
}
|
|
@@ -24,89 +25,69 @@ interface RemoteAppParams {
|
|
|
24
25
|
name: string;
|
|
25
26
|
providerInfo: NonNullable<RemoteModule['provider']>;
|
|
26
27
|
exportName: string | number | symbol;
|
|
27
|
-
dom?: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
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
|
+
});
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
);
|
|
74
|
-
providerReturn.render(renderProps);
|
|
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
|
+
}
|
|
75
72
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
clearTimeout(renderTimeout);
|
|
79
|
-
setTimeout(() => {
|
|
80
|
-
if (providerInfoRef.current?.destroy) {
|
|
81
|
-
LoggerInstance.log(
|
|
82
|
-
`createRemoteComponent LazyComponent destroy >>>`,
|
|
83
|
-
{ name, basename, dom: renderDom.current },
|
|
84
|
-
);
|
|
85
|
-
providerInfoRef.current?.destroy({
|
|
86
|
-
dom: renderDom.current,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
}, []);
|
|
73
|
+
};
|
|
74
|
+
}, []);
|
|
92
75
|
|
|
93
|
-
|
|
94
|
-
}
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
return <div ref={rootRef}></div>;
|
|
78
|
+
};
|
|
95
79
|
|
|
96
|
-
|
|
97
|
-
return <RemoteApp />
|
|
98
|
-
});
|
|
80
|
+
(RemoteApp as any)['__APP_VERSION__'] = __APP_VERSION__;
|
|
99
81
|
|
|
100
82
|
interface ExtraDataProps {
|
|
101
83
|
basename?: string;
|
|
102
84
|
}
|
|
103
85
|
|
|
104
|
-
export function withRouterData<P extends Parameters<typeof
|
|
86
|
+
export function withRouterData<P extends Parameters<typeof RemoteApp>[0]>(
|
|
105
87
|
WrappedComponent: React.ComponentType<P & ExtraDataProps>,
|
|
106
88
|
): React.FC<Omit<P, keyof ExtraDataProps>> {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
let enableDispathPopstate = false
|
|
89
|
+
return (props: any) => {
|
|
90
|
+
let enableDispathPopstate = false;
|
|
110
91
|
let routerContextVal: any;
|
|
111
92
|
try {
|
|
112
93
|
ReactRouterDOM.useLocation();
|
|
@@ -177,12 +158,8 @@ export function withRouterData<P extends Parameters<typeof RemoteAppWrapper>[0]>
|
|
|
177
158
|
}, [location]);
|
|
178
159
|
}
|
|
179
160
|
|
|
180
|
-
return <WrappedComponent {...(props as P)} basename={basename}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return forwardRef(function (props, ref) {
|
|
184
|
-
return <Component {...props} ref={ref} />
|
|
185
|
-
}) as any;
|
|
161
|
+
return <WrappedComponent {...(props as P)} basename={basename} />;
|
|
162
|
+
};
|
|
186
163
|
}
|
|
187
164
|
|
|
188
|
-
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 { }
|