@xfe-repo/web-router 1.2.6 → 1.2.8
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/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -3
- package/dist/index.mjs +5 -4
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -99,6 +99,7 @@ type CreateNavigatorOptions = {
|
|
|
99
99
|
mode: 'static' | 'browser' | 'hash';
|
|
100
100
|
routes: RouteConfig[];
|
|
101
101
|
initPathname?: string;
|
|
102
|
+
basename?: string;
|
|
102
103
|
redirect?: (path: string) => void;
|
|
103
104
|
};
|
|
104
105
|
declare function createNavigator(options: CreateNavigatorOptions): NavigatorType;
|
package/dist/index.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ type CreateNavigatorOptions = {
|
|
|
99
99
|
mode: 'static' | 'browser' | 'hash';
|
|
100
100
|
routes: RouteConfig[];
|
|
101
101
|
initPathname?: string;
|
|
102
|
+
basename?: string;
|
|
102
103
|
redirect?: (path: string) => void;
|
|
103
104
|
};
|
|
104
105
|
declare function createNavigator(options: CreateNavigatorOptions): NavigatorType;
|
package/dist/index.js
CHANGED
|
@@ -379,7 +379,8 @@ var import_react = require("react");
|
|
|
379
379
|
var import_react_router_dom = require("react-router-dom");
|
|
380
380
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
381
381
|
var Link = (0, import_react.memo)(function(props) {
|
|
382
|
-
var
|
|
382
|
+
var originTo = props.to, children = props.children, preload = props.preload, replace = props.replace, className = props.className, target = props.target;
|
|
383
|
+
var to = (0, import_react_router_dom.useHref)(originTo);
|
|
383
384
|
var _navigator2 = (0, import_react.useMemo)(function() {
|
|
384
385
|
return getClientNavigator();
|
|
385
386
|
}, []);
|
|
@@ -507,7 +508,7 @@ var getRoutes = function(config) {
|
|
|
507
508
|
// src/index.ts
|
|
508
509
|
var _navigator;
|
|
509
510
|
function createNavigator(options) {
|
|
510
|
-
var mode = options.mode, _options_initPathname = options.initPathname, initPathname = _options_initPathname === void 0 ? "/" : _options_initPathname, routes = options.routes;
|
|
511
|
+
var mode = options.mode, _options_initPathname = options.initPathname, initPathname = _options_initPathname === void 0 ? "/" : _options_initPathname, routes = options.routes, basename = options.basename;
|
|
511
512
|
var originHistory;
|
|
512
513
|
if (mode === "static") {
|
|
513
514
|
originHistory = (0, import_history.createMemoryHistory)({
|
|
@@ -529,7 +530,7 @@ function createNavigator(options) {
|
|
|
529
530
|
case 0:
|
|
530
531
|
_path_split = _sliced_to_array(path.split("?"), 2), tmp = _path_split[0], originPath = tmp === void 0 ? "" : tmp, tmp1 = _path_split[1], search = tmp1 === void 0 ? "" : tmp1;
|
|
531
532
|
matchPath = originPath.toLowerCase();
|
|
532
|
-
currentRoute = (_this = (0, import_react_router_dom3.matchRoutes)(routes, matchPath)) === null || _this === void 0 ? void 0 : (_ = _this[0]) === null || _ === void 0 ? void 0 : _.route;
|
|
533
|
+
currentRoute = (_this = (0, import_react_router_dom3.matchRoutes)(routes, matchPath, basename)) === null || _this === void 0 ? void 0 : (_ = _this[0]) === null || _ === void 0 ? void 0 : _.route;
|
|
533
534
|
query = query || import_tools.queryString.parse(search, {
|
|
534
535
|
parseBooleans: true,
|
|
535
536
|
parseNumbers: true
|
package/dist/index.mjs
CHANGED
|
@@ -274,10 +274,11 @@ function onHistoryChange(callback) {
|
|
|
274
274
|
export * from "react-router-dom";
|
|
275
275
|
// src/Link.tsx
|
|
276
276
|
import { memo, useMemo } from "react";
|
|
277
|
-
import { Link as OriginalLink } from "react-router-dom";
|
|
277
|
+
import { Link as OriginalLink, useHref } from "react-router-dom";
|
|
278
278
|
import { jsx } from "react/jsx-runtime";
|
|
279
279
|
var Link = memo(function(props) {
|
|
280
|
-
var
|
|
280
|
+
var originTo = props.to, children = props.children, preload = props.preload, replace = props.replace, className = props.className, target = props.target;
|
|
281
|
+
var to = useHref(originTo);
|
|
281
282
|
var _navigator2 = useMemo(function() {
|
|
282
283
|
return getClientNavigator();
|
|
283
284
|
}, []);
|
|
@@ -405,7 +406,7 @@ var getRoutes = function(config) {
|
|
|
405
406
|
// src/index.ts
|
|
406
407
|
var _navigator;
|
|
407
408
|
function createNavigator(options) {
|
|
408
|
-
var mode = options.mode, _options_initPathname = options.initPathname, initPathname = _options_initPathname === void 0 ? "/" : _options_initPathname, routes = options.routes;
|
|
409
|
+
var mode = options.mode, _options_initPathname = options.initPathname, initPathname = _options_initPathname === void 0 ? "/" : _options_initPathname, routes = options.routes, basename = options.basename;
|
|
409
410
|
var originHistory;
|
|
410
411
|
if (mode === "static") {
|
|
411
412
|
originHistory = createMemoryHistory({
|
|
@@ -427,7 +428,7 @@ function createNavigator(options) {
|
|
|
427
428
|
case 0:
|
|
428
429
|
_path_split = _sliced_to_array(path.split("?"), 2), tmp = _path_split[0], originPath = tmp === void 0 ? "" : tmp, tmp1 = _path_split[1], search = tmp1 === void 0 ? "" : tmp1;
|
|
429
430
|
matchPath = originPath.toLowerCase();
|
|
430
|
-
currentRoute = (_matchRoutes = matchRoutes(routes, matchPath)) === null || _matchRoutes === void 0 ? void 0 : (_matchRoutes_ = _matchRoutes[0]) === null || _matchRoutes_ === void 0 ? void 0 : _matchRoutes_.route;
|
|
431
|
+
currentRoute = (_matchRoutes = matchRoutes(routes, matchPath, basename)) === null || _matchRoutes === void 0 ? void 0 : (_matchRoutes_ = _matchRoutes[0]) === null || _matchRoutes_ === void 0 ? void 0 : _matchRoutes_.route;
|
|
431
432
|
query = query || queryString.parse(search, {
|
|
432
433
|
parseBooleans: true,
|
|
433
434
|
parseNumbers: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/web-router",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"@types/loadable__component": "^5.13.9",
|
|
29
29
|
"@types/node": "^20.16.5",
|
|
30
30
|
"@types/react": "^18",
|
|
31
|
+
"@xfe-repo/web-register": "1.3.5",
|
|
31
32
|
"@xfe-repo/typescript-config": "0.0.6",
|
|
32
|
-
"@xfe-repo/eslint-config": "0.0.5"
|
|
33
|
-
"@xfe-repo/web-register": "1.3.5"
|
|
33
|
+
"@xfe-repo/eslint-config": "0.0.5"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@xfe-repo/web-utils": "1.3.
|
|
36
|
+
"@xfe-repo/web-utils": "1.3.11"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"registry": "https://registry.npmjs.org/"
|