@modern-js/runtime 2.68.8 → 2.68.10
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.
|
@@ -105,7 +105,10 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
105
105
|
if (!finalRouteConfig.routes && !createRoutes) {
|
|
106
106
|
return App;
|
|
107
107
|
}
|
|
108
|
-
const selectBasePath = (pathname) =>
|
|
108
|
+
const selectBasePath = (pathname) => {
|
|
109
|
+
const match = serverBase.find((baseUrl) => isSegmentPrefix(pathname, baseUrl));
|
|
110
|
+
return match || "/";
|
|
111
|
+
};
|
|
109
112
|
const RouterWrapper = (props) => {
|
|
110
113
|
const { router, routes } = useRouterCreation({
|
|
111
114
|
...props,
|
|
@@ -152,6 +155,16 @@ const safeUse = (promise) => {
|
|
|
152
155
|
}
|
|
153
156
|
return null;
|
|
154
157
|
};
|
|
158
|
+
function normalizeBase(b) {
|
|
159
|
+
if (b.length > 1 && b.endsWith("/"))
|
|
160
|
+
return b.slice(0, -1);
|
|
161
|
+
return b || "/";
|
|
162
|
+
}
|
|
163
|
+
function isSegmentPrefix(pathname, base) {
|
|
164
|
+
const b = normalizeBase(base);
|
|
165
|
+
const p = pathname || "/";
|
|
166
|
+
return p === b || p.startsWith(`${b}/`);
|
|
167
|
+
}
|
|
155
168
|
function useRouterCreation(props, options) {
|
|
156
169
|
const { api, createRoutes, supportHtml5History, selectBasePath, basename } = options;
|
|
157
170
|
const runtimeContext = (0, import_react.useContext)(import_core.RuntimeReactContext);
|
|
@@ -73,9 +73,10 @@ var routerPlugin = function() {
|
|
|
73
73
|
return App;
|
|
74
74
|
}
|
|
75
75
|
var selectBasePath = function(pathname) {
|
|
76
|
-
|
|
77
|
-
return pathname
|
|
78
|
-
})
|
|
76
|
+
var match = serverBase.find(function(baseUrl) {
|
|
77
|
+
return isSegmentPrefix(pathname, baseUrl);
|
|
78
|
+
});
|
|
79
|
+
return match || "/";
|
|
79
80
|
};
|
|
80
81
|
var RouterWrapper = function(props) {
|
|
81
82
|
var _useRouterCreation = useRouterCreation(_object_spread_props(_object_spread({}, props), {
|
|
@@ -126,6 +127,16 @@ var safeUse = function(promise) {
|
|
|
126
127
|
}
|
|
127
128
|
return null;
|
|
128
129
|
};
|
|
130
|
+
function normalizeBase(b) {
|
|
131
|
+
if (b.length > 1 && b.endsWith("/"))
|
|
132
|
+
return b.slice(0, -1);
|
|
133
|
+
return b || "/";
|
|
134
|
+
}
|
|
135
|
+
function isSegmentPrefix(pathname, base) {
|
|
136
|
+
var b = normalizeBase(base);
|
|
137
|
+
var p = pathname || "/";
|
|
138
|
+
return p === b || p.startsWith("".concat(b, "/"));
|
|
139
|
+
}
|
|
129
140
|
function useRouterCreation(props, options) {
|
|
130
141
|
var api = options.api, createRoutes = options.createRoutes, supportHtml5History = options.supportHtml5History, selectBasePath = options.selectBasePath, basename = options.basename;
|
|
131
142
|
var runtimeContext = useContext(RuntimeReactContext);
|
|
@@ -69,7 +69,10 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
69
69
|
if (!finalRouteConfig.routes && !createRoutes) {
|
|
70
70
|
return App;
|
|
71
71
|
}
|
|
72
|
-
const selectBasePath = (pathname) =>
|
|
72
|
+
const selectBasePath = (pathname) => {
|
|
73
|
+
const match = serverBase.find((baseUrl) => isSegmentPrefix(pathname, baseUrl));
|
|
74
|
+
return match || "/";
|
|
75
|
+
};
|
|
73
76
|
const RouterWrapper = (props) => {
|
|
74
77
|
const { router, routes } = useRouterCreation({
|
|
75
78
|
...props,
|
|
@@ -116,6 +119,16 @@ const safeUse = (promise) => {
|
|
|
116
119
|
}
|
|
117
120
|
return null;
|
|
118
121
|
};
|
|
122
|
+
function normalizeBase(b) {
|
|
123
|
+
if (b.length > 1 && b.endsWith("/"))
|
|
124
|
+
return b.slice(0, -1);
|
|
125
|
+
return b || "/";
|
|
126
|
+
}
|
|
127
|
+
function isSegmentPrefix(pathname, base) {
|
|
128
|
+
const b = normalizeBase(base);
|
|
129
|
+
const p = pathname || "/";
|
|
130
|
+
return p === b || p.startsWith(`${b}/`);
|
|
131
|
+
}
|
|
119
132
|
function useRouterCreation(props, options) {
|
|
120
133
|
const { api, createRoutes, supportHtml5History, selectBasePath, basename } = options;
|
|
121
134
|
const runtimeContext = useContext(RuntimeReactContext);
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.68.
|
|
18
|
+
"version": "2.68.10",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -219,13 +219,13 @@
|
|
|
219
219
|
"react-is": "^18",
|
|
220
220
|
"react-side-effect": "^2.1.2",
|
|
221
221
|
"styled-components": "^5.3.1",
|
|
222
|
-
"@modern-js/plugin": "2.68.
|
|
223
|
-
"@modern-js/plugin-data-loader": "2.68.
|
|
224
|
-
"@modern-js/
|
|
225
|
-
"@modern-js/
|
|
226
|
-
"@modern-js/runtime-utils": "2.68.
|
|
227
|
-
"@modern-js/
|
|
228
|
-
"@modern-js/
|
|
222
|
+
"@modern-js/plugin": "2.68.10",
|
|
223
|
+
"@modern-js/plugin-data-loader": "2.68.10",
|
|
224
|
+
"@modern-js/render": "2.68.10",
|
|
225
|
+
"@modern-js/plugin-v2": "2.68.10",
|
|
226
|
+
"@modern-js/runtime-utils": "2.68.10",
|
|
227
|
+
"@modern-js/utils": "2.68.10",
|
|
228
|
+
"@modern-js/types": "2.68.10"
|
|
229
229
|
},
|
|
230
230
|
"peerDependencies": {
|
|
231
231
|
"react": ">=17",
|
|
@@ -249,10 +249,10 @@
|
|
|
249
249
|
"ts-node": "^10.9.1",
|
|
250
250
|
"typescript": "^5",
|
|
251
251
|
"webpack": "^5.101.0",
|
|
252
|
-
"@modern-js/app-tools": "2.68.
|
|
252
|
+
"@modern-js/app-tools": "2.68.10",
|
|
253
253
|
"@scripts/build": "2.66.0",
|
|
254
254
|
"@scripts/jest-config": "2.66.0",
|
|
255
|
-
"@modern-js/core": "2.68.
|
|
255
|
+
"@modern-js/core": "2.68.10"
|
|
256
256
|
},
|
|
257
257
|
"sideEffects": false,
|
|
258
258
|
"publishConfig": {
|