@modern-js/plugin-router-v5 2.40.0 → 2.42.0
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/dist/cjs/runtime/plugin.js +2 -2
- package/dist/esm/runtime/plugin.js +1 -1
- package/dist/esm-node/runtime/plugin.js +1 -1
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/cli/types.d.ts +4 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/runtime/DefaultNotFound.d.ts +1 -1
- package/dist/types/runtime/hooks.d.ts +2 -2
- package/dist/types/runtime/index.d.ts +1 -1
- package/dist/types/runtime/plugin.d.ts +32 -39
- package/dist/types/runtime/utils.d.ts +1 -1
- package/package.json +12 -12
@@ -37,7 +37,7 @@ var import_history = require("history");
|
|
37
37
|
var import_react_router_dom = require("react-router-dom");
|
38
38
|
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
39
39
|
var import_runtime = require("@modern-js/runtime");
|
40
|
-
var
|
40
|
+
var import_parsed = require("@modern-js/runtime-utils/parsed");
|
41
41
|
var import_utils = require("./utils");
|
42
42
|
var import_hooks = require("./hooks");
|
43
43
|
const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5History = true, routesConfig, createRoutes, historyOptions = {} }) => {
|
@@ -46,7 +46,7 @@ const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5His
|
|
46
46
|
const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
|
47
47
|
let routes = [];
|
48
48
|
if (isBrow) {
|
49
|
-
window._SERVER_DATA = (0,
|
49
|
+
window._SERVER_DATA = (0, import_parsed.parsedJSONFromElement)("__MODERN_SERVER_DATA__");
|
50
50
|
}
|
51
51
|
return {
|
52
52
|
name: "@modern-js/plugin-router",
|
@@ -6,7 +6,7 @@ import { createBrowserHistory, createHashHistory } from "history";
|
|
6
6
|
import { Router, StaticRouter, useRouteMatch, useLocation } from "react-router-dom";
|
7
7
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
8
8
|
import { RuntimeReactContext, isBrowser } from "@modern-js/runtime";
|
9
|
-
import { parsedJSONFromElement } from "@modern-js/runtime-utils/
|
9
|
+
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
10
10
|
import { renderRoutes, getLocation, urlJoin } from "./utils";
|
11
11
|
import { modifyRoutesHook } from "./hooks";
|
12
12
|
var routerPlugin = function(param) {
|
@@ -4,7 +4,7 @@ import { createBrowserHistory, createHashHistory } from "history";
|
|
4
4
|
import { Router, StaticRouter, useRouteMatch, useLocation } from "react-router-dom";
|
5
5
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
6
6
|
import { RuntimeReactContext, isBrowser } from "@modern-js/runtime";
|
7
|
-
import { parsedJSONFromElement } from "@modern-js/runtime-utils/
|
7
|
+
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
8
8
|
import { renderRoutes, getLocation, urlJoin } from "./utils";
|
9
9
|
import { modifyRoutesHook } from "./hooks";
|
10
10
|
const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5History = true, routesConfig, createRoutes, historyOptions = {} }) => {
|
package/dist/types/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
export { default } from './runtime';
|
2
|
-
export * from './runtime';
|
2
|
+
export * from './runtime';
|
@@ -1,2 +1,2 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
export declare const DefaultNotFound: () => JSX.Element;
|
2
|
+
export declare const DefaultNotFound: () => JSX.Element;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { RouteProps } from 'react-router-dom';
|
2
2
|
declare const modifyRoutesHook: import("@modern-js/plugin").Waterfall<RouteProps<string, {
|
3
|
-
|
3
|
+
[x: string]: string | undefined;
|
4
4
|
}>[]>;
|
5
|
-
export { modifyRoutesHook };
|
5
|
+
export { modifyRoutesHook };
|
@@ -3,50 +3,43 @@ import { History, BrowserHistoryBuildOptions, HashHistoryBuildOptions } from 'hi
|
|
3
3
|
import { RouteProps } from 'react-router-dom';
|
4
4
|
import type { Plugin } from '@modern-js/runtime';
|
5
5
|
declare global {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
interface Window {
|
7
|
+
_SERVER_DATA?: {
|
8
|
+
router: {
|
9
|
+
baseUrl: string;
|
10
|
+
params: Record<string, string>;
|
11
|
+
};
|
12
|
+
};
|
13
|
+
}
|
14
14
|
}
|
15
15
|
export type SingleRouteConfig = RouteProps & {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
redirect?: string;
|
17
|
+
routes?: SingleRouteConfig[];
|
18
|
+
key?: string;
|
19
|
+
/**
|
20
|
+
* layout component
|
21
|
+
*/
|
22
|
+
layout?: React.ComponentType;
|
23
|
+
/**
|
24
|
+
* component would be rendered when route macthed.
|
25
|
+
*/
|
26
|
+
component?: React.ComponentType;
|
27
27
|
};
|
28
28
|
export type HistoryConfig = {
|
29
|
-
|
30
|
-
|
29
|
+
supportHtml5History: true;
|
30
|
+
historyOptions: BrowserHistoryBuildOptions;
|
31
31
|
} | {
|
32
|
-
|
33
|
-
|
32
|
+
supportHtml5History: false;
|
33
|
+
historyOptions: HashHistoryBuildOptions;
|
34
34
|
};
|
35
35
|
export type RouterConfig = Partial<HistoryConfig> & {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
mode?: 'react-router-5';
|
37
|
+
routesConfig?: {
|
38
|
+
globalApp?: React.ComponentType<any>;
|
39
|
+
routes?: SingleRouteConfig[];
|
40
|
+
};
|
41
|
+
createRoutes?: () => React.ComponentType<any> | null;
|
42
|
+
history?: History;
|
43
|
+
serverBase?: string[];
|
44
44
|
};
|
45
|
-
export declare const routerPlugin: ({
|
46
|
-
serverBase,
|
47
|
-
history: customHistory,
|
48
|
-
supportHtml5History,
|
49
|
-
routesConfig,
|
50
|
-
createRoutes,
|
51
|
-
historyOptions
|
52
|
-
}: RouterConfig) => Plugin;
|
45
|
+
export declare const routerPlugin: ({ serverBase, history: customHistory, supportHtml5History, routesConfig, createRoutes, historyOptions, }: RouterConfig) => Plugin;
|
@@ -3,4 +3,4 @@ import { RouterConfig } from './plugin';
|
|
3
3
|
export declare function renderRoutes(routesConfig?: RouterConfig['routesConfig'], extraProps?: any): JSX.Element | null;
|
4
4
|
export declare function getLocation(serverContext: any): string;
|
5
5
|
export declare const urlJoin: (...parts: string[]) => string;
|
6
|
-
export declare function standardSlash(str: string): string;
|
6
|
+
export declare function standardSlash(str: string): string;
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.42.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
21
21
|
"main": "./dist/cjs/cli/index.js",
|
@@ -59,10 +59,10 @@
|
|
59
59
|
"history": "^4.7.9",
|
60
60
|
"hoist-non-react-statics": "^3.3.2",
|
61
61
|
"react-router-dom": "^5.3.4",
|
62
|
-
"@swc/helpers": "0.5.
|
63
|
-
"@modern-js/
|
64
|
-
"@modern-js/
|
65
|
-
"@modern-js/utils": "2.
|
62
|
+
"@swc/helpers": "0.5.3",
|
63
|
+
"@modern-js/types": "2.42.0",
|
64
|
+
"@modern-js/plugin": "2.42.0",
|
65
|
+
"@modern-js/utils": "2.42.0"
|
66
66
|
},
|
67
67
|
"peerDependencies": {
|
68
68
|
"react": ">=17",
|
@@ -78,13 +78,13 @@
|
|
78
78
|
"react-dom": "^18",
|
79
79
|
"ts-jest": "^29.1.0",
|
80
80
|
"typescript": "^5",
|
81
|
-
"@modern-js/app-tools": "2.
|
82
|
-
"@modern-js/core": "2.
|
83
|
-
"@modern-js/
|
84
|
-
"@modern-js/
|
85
|
-
"@
|
86
|
-
"@scripts/
|
87
|
-
"@
|
81
|
+
"@modern-js/app-tools": "2.42.0",
|
82
|
+
"@modern-js/core": "2.42.0",
|
83
|
+
"@modern-js/utils": "2.42.0",
|
84
|
+
"@modern-js/runtime": "2.42.0",
|
85
|
+
"@scripts/build": "2.42.0",
|
86
|
+
"@scripts/jest-config": "2.42.0",
|
87
|
+
"@modern-js/runtime-utils": "2.42.0"
|
88
88
|
},
|
89
89
|
"sideEffects": false,
|
90
90
|
"publishConfig": {
|