@modern-js/plugin-router-v5 2.17.1 → 2.18.1
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
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @modern-js/plugin-router-v5
|
2
2
|
|
3
|
+
## 2.18.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- @modern-js/types@2.18.1
|
8
|
+
- @modern-js/utils@2.18.1
|
9
|
+
|
10
|
+
## 2.18.0
|
11
|
+
|
12
|
+
### Patch Changes
|
13
|
+
|
14
|
+
- @modern-js/types@2.18.0
|
15
|
+
- @modern-js/utils@2.18.0
|
16
|
+
|
3
17
|
## 2.17.1
|
4
18
|
|
5
19
|
### Patch Changes
|
@@ -12,7 +12,7 @@ const _history = require("history");
|
|
12
12
|
const _reactrouterdom = require("react-router-dom");
|
13
13
|
const _hoistnonreactstatics = /* @__PURE__ */ _interop_require_default(require("hoist-non-react-statics"));
|
14
14
|
const _runtime = require("@modern-js/runtime");
|
15
|
-
const
|
15
|
+
const _runtimebrowser = require("@modern-js/utils/runtime-browser");
|
16
16
|
const _utils = require("./utils");
|
17
17
|
function _interop_require_default(obj) {
|
18
18
|
return obj && obj.__esModule ? obj : {
|
@@ -63,7 +63,7 @@ const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5His
|
|
63
63
|
const isBrow = (0, _runtime.isBrowser)();
|
64
64
|
const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
|
65
65
|
if (isBrow) {
|
66
|
-
window._SERVER_DATA = (0,
|
66
|
+
window._SERVER_DATA = (0, _runtimebrowser.parsedJSONFromElement)("__MODERN_SERVER_DATA__");
|
67
67
|
}
|
68
68
|
return {
|
69
69
|
name: "@modern-js/plugin-router",
|
package/dist/esm/cli/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
function _define_property(obj, key, value) {
|
2
2
|
if (key in obj) {
|
3
3
|
Object.defineProperty(obj, key, {
|
4
|
-
value,
|
4
|
+
value: value,
|
5
5
|
enumerable: true,
|
6
6
|
configurable: true,
|
7
7
|
writable: true
|
@@ -101,8 +101,8 @@ export default function() {
|
|
101
101
|
throw new Error("should enable runtime.router.mode for entry ".concat(entryName));
|
102
102
|
}
|
103
103
|
return {
|
104
|
-
entrypoint,
|
105
|
-
imports
|
104
|
+
entrypoint: entrypoint,
|
105
|
+
imports: imports
|
106
106
|
};
|
107
107
|
},
|
108
108
|
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
|
@@ -122,15 +122,15 @@ export default function() {
|
|
122
122
|
plugins.push({
|
123
123
|
name: PLUGIN_IDENTIFIER,
|
124
124
|
options: JSON.stringify(_object_spread_props(_object_spread({
|
125
|
-
serverBase
|
125
|
+
serverBase: serverBase
|
126
126
|
}, runtimeConfig.router), {
|
127
127
|
routesConfig: fileSystemRoutes ? "{ ".concat(ROUTES_IDENTIFIER, ", globalApp: App }") : void 0
|
128
128
|
})).replace(/"routesConfig"\s*:\s*"((\S|\s)+)"/g, '"routesConfig": $1,')
|
129
129
|
});
|
130
130
|
}
|
131
131
|
return {
|
132
|
-
entrypoint,
|
133
|
-
plugins
|
132
|
+
entrypoint: entrypoint,
|
133
|
+
plugins: plugins
|
134
134
|
};
|
135
135
|
},
|
136
136
|
addRuntimeExports: function addRuntimeExports() {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
function _define_property(obj, key, value) {
|
2
2
|
if (key in obj) {
|
3
3
|
Object.defineProperty(obj, key, {
|
4
|
-
value,
|
4
|
+
value: value,
|
5
5
|
enumerable: true,
|
6
6
|
configurable: true,
|
7
7
|
writable: true
|
@@ -56,7 +56,7 @@ import { createBrowserHistory, createHashHistory } from "history";
|
|
56
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
|
-
import { parsedJSONFromElement } from "@modern-js/utils/runtime";
|
59
|
+
import { parsedJSONFromElement } from "@modern-js/utils/runtime-browser";
|
60
60
|
import { renderRoutes, getLocation, urlJoin } from "./utils";
|
61
61
|
export var routerPlugin = function(param) {
|
62
62
|
var _param_serverBase = param.serverBase, serverBase = _param_serverBase === void 0 ? [] : _param_serverBase, customHistory = param.history, _param_supportHtml5History = param.supportHtml5History, supportHtml5History = _param_supportHtml5History === void 0 ? true : _param_supportHtml5History, routesConfig = param.routesConfig, createRoutes = param.createRoutes, _param_historyOptions = param.historyOptions, historyOptions = _param_historyOptions === void 0 ? {} : _param_historyOptions;
|
@@ -76,11 +76,11 @@ export var routerPlugin = function(param) {
|
|
76
76
|
init: function init(param2, next) {
|
77
77
|
var context = param2.context;
|
78
78
|
context.router = {
|
79
|
-
useRouteMatch,
|
80
|
-
useLocation
|
79
|
+
useRouteMatch: useRouteMatch,
|
80
|
+
useLocation: useLocation
|
81
81
|
};
|
82
82
|
return next({
|
83
|
-
context
|
83
|
+
context: context
|
84
84
|
});
|
85
85
|
},
|
86
86
|
hoc: function(param2, next) {
|
@@ -93,7 +93,7 @@ export var routerPlugin = function(param) {
|
|
93
93
|
var history = customHistory || (supportHtml5History ? createBrowserHistory(historyOptions) : createHashHistory(historyOptions));
|
94
94
|
return function(props) {
|
95
95
|
return /* @__PURE__ */ _jsx(Router, {
|
96
|
-
history,
|
96
|
+
history: history,
|
97
97
|
children: createRoutes ? /* @__PURE__ */ _jsx(App, _object_spread_props(_object_spread({}, props), {
|
98
98
|
Component: createRoutes()
|
99
99
|
})) : /* @__PURE__ */ _jsx(App, _object_spread_props(_object_spread({}, props), {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
function _define_property(obj, key, value) {
|
2
2
|
if (key in obj) {
|
3
3
|
Object.defineProperty(obj, key, {
|
4
|
-
value,
|
4
|
+
value: value,
|
5
5
|
enumerable: true,
|
6
6
|
configurable: true,
|
7
7
|
writable: true
|
@@ -75,7 +75,7 @@ export function renderRoutes(routesConfig) {
|
|
75
75
|
return /* @__PURE__ */ _jsx(Component, _object_spread({}, props));
|
76
76
|
}
|
77
77
|
return /* @__PURE__ */ _jsx(GlobalLayout, _object_spread({
|
78
|
-
Component
|
78
|
+
Component: Component
|
79
79
|
}, props));
|
80
80
|
};
|
81
81
|
var findMatchedRoute = function(pathname) {
|
@@ -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/utils/runtime";
|
7
|
+
import { parsedJSONFromElement } from "@modern-js/utils/runtime-browser";
|
8
8
|
import { renderRoutes, getLocation, urlJoin } from "./utils";
|
9
9
|
export const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5History = true, routesConfig, createRoutes, historyOptions = {} }) => {
|
10
10
|
const isBrow = isBrowser();
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.18.1",
|
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,8 +59,8 @@
|
|
59
59
|
"history": "^4.7.9",
|
60
60
|
"hoist-non-react-statics": "^3.3.2",
|
61
61
|
"react-router-dom": "^5.3.4",
|
62
|
-
"@modern-js/types": "2.
|
63
|
-
"@modern-js/utils": "2.
|
62
|
+
"@modern-js/types": "2.18.1",
|
63
|
+
"@modern-js/utils": "2.18.1"
|
64
64
|
},
|
65
65
|
"peerDependencies": {
|
66
66
|
"react": ">=17",
|
@@ -78,12 +78,12 @@
|
|
78
78
|
"react-dom": "^18",
|
79
79
|
"ts-jest": "^29.0.4",
|
80
80
|
"typescript": "^4",
|
81
|
-
"@modern-js/app-tools": "2.
|
82
|
-
"@modern-js/core": "2.
|
83
|
-
"@modern-js/runtime": "2.
|
84
|
-
"@modern-js/utils": "2.
|
85
|
-
"@scripts/build": "2.
|
86
|
-
"@scripts/jest-config": "2.
|
81
|
+
"@modern-js/app-tools": "2.18.1",
|
82
|
+
"@modern-js/core": "2.18.1",
|
83
|
+
"@modern-js/runtime": "2.18.1",
|
84
|
+
"@modern-js/utils": "2.18.1",
|
85
|
+
"@scripts/build": "2.18.1",
|
86
|
+
"@scripts/jest-config": "2.18.1"
|
87
87
|
},
|
88
88
|
"sideEffects": false,
|
89
89
|
"modernConfig": {},
|