@modern-js/plugin-router-v5 2.37.1 → 2.37.2-fix.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.
@@ -1,52 +1,41 @@
1
- import React from 'react';
2
- import { History, BrowserHistoryBuildOptions, HashHistoryBuildOptions } from 'history';
3
- import { RouteProps } from 'react-router-dom';
4
- import type { Plugin } from '@modern-js/runtime';
5
- declare global {
6
- interface Window {
7
- _SERVER_DATA?: {
8
- router: {
9
- baseUrl: string;
10
- params: Record<string, string>;
11
- };
12
- };
13
- }
14
- }
1
+ import type { RuntimePluginFuture } from '@modern-js/runtime';
2
+ import { type BrowserHistoryBuildOptions, type HashHistoryBuildOptions, type History } from 'history';
3
+ import type React from 'react';
4
+ import { type RouteProps } from 'react-router-dom';
5
+ import { modifyRoutesHook } from './hooks';
6
+ export type RouterExtendsHooks = {
7
+ modifyRoutes: typeof modifyRoutesHook;
8
+ };
15
9
  export type SingleRouteConfig = RouteProps & {
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;
10
+ redirect?: string;
11
+ routes?: SingleRouteConfig[];
12
+ key?: string;
13
+ /**
14
+ * layout component
15
+ */
16
+ layout?: React.ComponentType;
17
+ /**
18
+ * component would be rendered when route macthed.
19
+ */
20
+ component?: React.ComponentType;
27
21
  };
28
22
  export type HistoryConfig = {
29
- supportHtml5History: true;
30
- historyOptions: BrowserHistoryBuildOptions;
23
+ supportHtml5History: true;
24
+ historyOptions: BrowserHistoryBuildOptions;
31
25
  } | {
32
- supportHtml5History: false;
33
- historyOptions: HashHistoryBuildOptions;
26
+ supportHtml5History: false;
27
+ historyOptions: HashHistoryBuildOptions;
34
28
  };
35
29
  export type RouterConfig = Partial<HistoryConfig> & {
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[];
30
+ mode?: 'react-router-5';
31
+ routesConfig?: {
32
+ globalApp?: React.ComponentType<any>;
33
+ routes?: SingleRouteConfig[];
34
+ };
35
+ createRoutes?: () => React.ComponentType<any> | null;
36
+ history?: History;
37
+ serverBase?: string[];
44
38
  };
45
- export declare const routerPlugin: ({
46
- serverBase,
47
- history: customHistory,
48
- supportHtml5History,
49
- routesConfig,
50
- createRoutes,
51
- historyOptions
52
- }: RouterConfig) => Plugin;
39
+ export declare const routerPlugin: (userConfig?: RouterConfig) => RuntimePluginFuture<{
40
+ extendHooks: RouterExtendsHooks;
41
+ }>;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
- import { RouterConfig } from './plugin';
3
- export declare function renderRoutes(routesConfig?: RouterConfig['routesConfig'], extraProps?: any): JSX.Element | null;
1
+ import React from 'react';
2
+ import type { RouterConfig } from './plugin';
3
+ export declare function renderRoutes(routesConfig?: RouterConfig['routesConfig'], extraProps?: any): React.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.37.1",
18
+ "version": "2.37.2-fix.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",
@@ -60,9 +60,10 @@
60
60
  "hoist-non-react-statics": "^3.3.2",
61
61
  "react-router-dom": "^5.3.4",
62
62
  "@swc/helpers": "0.5.1",
63
- "@modern-js/plugin": "2.37.1",
64
- "@modern-js/types": "2.37.1",
65
- "@modern-js/utils": "2.37.1"
63
+ "@modern-js/plugin": "2.37.2",
64
+ "@modern-js/utils": "2.37.2",
65
+ "@modern-js/runtime-utils": "2.37.2",
66
+ "@modern-js/types": "2.37.2"
66
67
  },
67
68
  "peerDependencies": {
68
69
  "react": ">=17",
@@ -78,19 +79,17 @@
78
79
  "react-dom": "^18",
79
80
  "ts-jest": "^29.1.0",
80
81
  "typescript": "^5",
81
- "@modern-js/app-tools": "2.37.1",
82
- "@modern-js/core": "2.37.1",
83
- "@modern-js/runtime": "2.37.1",
84
- "@modern-js/utils": "2.37.1",
85
- "@modern-js/runtime-utils": "2.37.1",
86
- "@scripts/build": "2.37.1",
87
- "@scripts/jest-config": "2.37.1"
82
+ "@modern-js/app-tools": "2.37.2",
83
+ "@modern-js/runtime": "2.37.2",
84
+ "@scripts/jest-config": "2.37.2",
85
+ "@scripts/build": "2.37.2",
86
+ "@modern-js/utils": "2.37.2",
87
+ "@modern-js/core": "2.37.2"
88
88
  },
89
89
  "sideEffects": false,
90
90
  "publishConfig": {
91
91
  "registry": "https://registry.npmjs.org/",
92
- "access": "public",
93
- "provenance": true
92
+ "access": "public"
94
93
  },
95
94
  "scripts": {
96
95
  "dev": "modern-lib build --watch",