@modern-js/plugin-router-v5 2.0.0-beta.6 → 2.0.0-beta.7
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.
@@ -23,7 +23,12 @@ import {
|
|
23
23
|
createBrowserHistory,
|
24
24
|
createHashHistory
|
25
25
|
} from "history";
|
26
|
-
import {
|
26
|
+
import {
|
27
|
+
Router,
|
28
|
+
StaticRouter,
|
29
|
+
useRouteMatch,
|
30
|
+
useLocation
|
31
|
+
} from "react-router-dom";
|
27
32
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
28
33
|
import { RuntimeReactContext, isBrowser } from "@modern-js/runtime";
|
29
34
|
import { renderRoutes, getLocation, urlJoin } from "./utils";
|
@@ -40,6 +45,13 @@ const routerPlugin = ({
|
|
40
45
|
name: "@modern-js/plugin-router",
|
41
46
|
setup: () => {
|
42
47
|
return {
|
48
|
+
init({ context }, next) {
|
49
|
+
context.router = {
|
50
|
+
useRouteMatch,
|
51
|
+
useLocation
|
52
|
+
};
|
53
|
+
return next({ context });
|
54
|
+
},
|
43
55
|
hoc: ({ App }, next) => {
|
44
56
|
const getRouteApp = () => {
|
45
57
|
var _a;
|
@@ -63,6 +63,13 @@ const routerPlugin = ({
|
|
63
63
|
name: "@modern-js/plugin-router",
|
64
64
|
setup: () => {
|
65
65
|
return {
|
66
|
+
init({ context }, next) {
|
67
|
+
context.router = {
|
68
|
+
useRouteMatch: import_react_router_dom.useRouteMatch,
|
69
|
+
useLocation: import_react_router_dom.useLocation
|
70
|
+
};
|
71
|
+
return next({ context });
|
72
|
+
},
|
66
73
|
hoc: ({ App }, next) => {
|
67
74
|
const getRouteApp = () => {
|
68
75
|
var _a;
|
@@ -53,7 +53,7 @@ function _objectSpreadProps(target, source) {
|
|
53
53
|
import { jsx } from "react/jsx-runtime";
|
54
54
|
import { useContext } from "react";
|
55
55
|
import { createBrowserHistory, createHashHistory } from "history";
|
56
|
-
import { Router, StaticRouter } from "react-router-dom";
|
56
|
+
import { Router, StaticRouter, useRouteMatch, useLocation } from "react-router-dom";
|
57
57
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
58
58
|
import { RuntimeReactContext, isBrowser } from "@modern-js/runtime";
|
59
59
|
import { renderRoutes, getLocation, urlJoin } from "./utils";
|
@@ -69,6 +69,16 @@ var routerPlugin = function(param) {
|
|
69
69
|
name: "@modern-js/plugin-router",
|
70
70
|
setup: function() {
|
71
71
|
return {
|
72
|
+
init: function init(param, next) {
|
73
|
+
var context = param.context;
|
74
|
+
context.router = {
|
75
|
+
useRouteMatch: useRouteMatch,
|
76
|
+
useLocation: useLocation
|
77
|
+
};
|
78
|
+
return next({
|
79
|
+
context: context
|
80
|
+
});
|
81
|
+
},
|
72
82
|
hoc: function(param, next) {
|
73
83
|
var App = param.App;
|
74
84
|
var getRouteApp = function() {
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.0.0-beta.
|
14
|
+
"version": "2.0.0-beta.7",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/cli/index.d.ts",
|
17
17
|
"main": "./dist/js/node/cli/index.js",
|
@@ -54,9 +54,9 @@
|
|
54
54
|
"hoist-non-react-statics": "^3.3.2",
|
55
55
|
"@types/history": "^4.7.9",
|
56
56
|
"@types/react-router-dom": "^5.1.8",
|
57
|
-
"@modern-js/plugin": "2.0.0-beta.
|
58
|
-
"@modern-js/utils": "2.0.0-beta.
|
59
|
-
"@modern-js/types": "2.0.0-beta.
|
57
|
+
"@modern-js/plugin": "2.0.0-beta.7",
|
58
|
+
"@modern-js/utils": "2.0.0-beta.7",
|
59
|
+
"@modern-js/types": "2.0.0-beta.7"
|
60
60
|
},
|
61
61
|
"peerDependencies": {
|
62
62
|
"react": ">=17",
|
@@ -75,12 +75,12 @@
|
|
75
75
|
"@testing-library/react": "^13.4.0",
|
76
76
|
"@testing-library/react-hooks": "^8.0.1",
|
77
77
|
"@types/invariant": "^2.2.30",
|
78
|
-
"@modern-js/runtime": "2.0.0-beta.
|
79
|
-
"@modern-js/core": "2.0.0-beta.
|
80
|
-
"@modern-js/utils": "2.0.0-beta.
|
81
|
-
"@scripts/build": "2.0.0-beta.
|
82
|
-
"@modern-js/app-tools": "2.0.0-beta.
|
83
|
-
"@scripts/jest-config": "2.0.0-beta.
|
78
|
+
"@modern-js/runtime": "2.0.0-beta.7",
|
79
|
+
"@modern-js/core": "2.0.0-beta.7",
|
80
|
+
"@modern-js/utils": "2.0.0-beta.7",
|
81
|
+
"@scripts/build": "2.0.0-beta.7",
|
82
|
+
"@modern-js/app-tools": "2.0.0-beta.7",
|
83
|
+
"@scripts/jest-config": "2.0.0-beta.7"
|
84
84
|
},
|
85
85
|
"sideEffects": false,
|
86
86
|
"modernConfig": {},
|