@esmx/router 3.0.0-rc.20 → 3.0.0-rc.22
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/router.d.ts +2 -2
- package/dist/router.mjs +3 -3
- package/dist/util.d.ts +3 -3
- package/dist/util.mjs +5 -5
- package/package.json +3 -3
- package/src/router.ts +3 -3
- package/src/util.ts +8 -8
package/dist/router.d.ts
CHANGED
|
@@ -61,14 +61,14 @@ export declare class Router {
|
|
|
61
61
|
/**
|
|
62
62
|
* Check if the route matches the current route
|
|
63
63
|
*
|
|
64
|
-
* @param
|
|
64
|
+
* @param toRoute Target route object to compare
|
|
65
65
|
* @param matchType Match type
|
|
66
66
|
* - 'route': Route-level matching, compare if route configurations are the same
|
|
67
67
|
* - 'exact': Exact matching, compare if paths are completely the same
|
|
68
68
|
* - 'include': Include matching, check if current path contains target path
|
|
69
69
|
* @returns Whether it matches
|
|
70
70
|
*/
|
|
71
|
-
isRouteMatched(
|
|
71
|
+
isRouteMatched(toRoute: Route, matchType?: RouteMatchType): boolean;
|
|
72
72
|
/**
|
|
73
73
|
* Resolve router link configuration and return complete link data
|
|
74
74
|
*
|
package/dist/router.mjs
CHANGED
|
@@ -143,17 +143,17 @@ export class Router {
|
|
|
143
143
|
/**
|
|
144
144
|
* Check if the route matches the current route
|
|
145
145
|
*
|
|
146
|
-
* @param
|
|
146
|
+
* @param toRoute Target route object to compare
|
|
147
147
|
* @param matchType Match type
|
|
148
148
|
* - 'route': Route-level matching, compare if route configurations are the same
|
|
149
149
|
* - 'exact': Exact matching, compare if paths are completely the same
|
|
150
150
|
* - 'include': Include matching, check if current path contains target path
|
|
151
151
|
* @returns Whether it matches
|
|
152
152
|
*/
|
|
153
|
-
isRouteMatched(
|
|
153
|
+
isRouteMatched(toRoute, matchType = "include") {
|
|
154
154
|
const currentRoute = this.transition.route;
|
|
155
155
|
if (!currentRoute) return false;
|
|
156
|
-
return isRouteMatched(currentRoute,
|
|
156
|
+
return isRouteMatched(currentRoute, toRoute, matchType);
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* Resolve router link configuration and return complete link data
|
package/dist/util.d.ts
CHANGED
|
@@ -15,12 +15,12 @@ export declare function isUrlEqual(url1: URL, url2?: URL | null): boolean;
|
|
|
15
15
|
/**
|
|
16
16
|
* Compare if two routes match
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
18
|
+
* @param fromRoute First route object
|
|
19
|
+
* @param toRoute Second route object, may be null
|
|
20
20
|
* @param matchType Match type
|
|
21
21
|
* - 'route': Route-level matching, compare if route configurations are the same
|
|
22
22
|
* - 'exact': Exact matching, compare if full paths are the same
|
|
23
23
|
* - 'include': Include matching, check if route1 path starts with route2 path
|
|
24
24
|
* @returns Whether they match
|
|
25
25
|
*/
|
|
26
|
-
export declare function isRouteMatched(
|
|
26
|
+
export declare function isRouteMatched(fromRoute: Route, toRoute: Route | null, matchType: RouteMatchType): boolean;
|
package/dist/util.mjs
CHANGED
|
@@ -38,15 +38,15 @@ export function isUrlEqual(url1, url2) {
|
|
|
38
38
|
url2.hash = url2.hash;
|
|
39
39
|
return url1.href === url2.href;
|
|
40
40
|
}
|
|
41
|
-
export function isRouteMatched(
|
|
42
|
-
if (!
|
|
41
|
+
export function isRouteMatched(fromRoute, toRoute, matchType) {
|
|
42
|
+
if (!toRoute) return false;
|
|
43
43
|
switch (matchType) {
|
|
44
44
|
case "route":
|
|
45
|
-
return
|
|
45
|
+
return fromRoute.config === toRoute.config;
|
|
46
46
|
case "exact":
|
|
47
|
-
return
|
|
47
|
+
return fromRoute.fullPath === toRoute.fullPath;
|
|
48
48
|
case "include":
|
|
49
|
-
return
|
|
49
|
+
return fromRoute.fullPath.startsWith(toRoute.fullPath);
|
|
50
50
|
default:
|
|
51
51
|
return false;
|
|
52
52
|
}
|
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@biomejs/biome": "1.9.4",
|
|
35
|
-
"@esmx/lint": "3.0.0-rc.
|
|
35
|
+
"@esmx/lint": "3.0.0-rc.22",
|
|
36
36
|
"@types/node": "22.15.18",
|
|
37
37
|
"@vitest/coverage-v8": "3.1.3",
|
|
38
38
|
"happy-dom": "^18.0.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"unbuild": "3.5.0",
|
|
42
42
|
"vitest": "3.1.3"
|
|
43
43
|
},
|
|
44
|
-
"version": "3.0.0-rc.
|
|
44
|
+
"version": "3.0.0-rc.22",
|
|
45
45
|
"type": "module",
|
|
46
46
|
"private": false,
|
|
47
47
|
"exports": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"template",
|
|
61
61
|
"public"
|
|
62
62
|
],
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "a92281dc6cd6ba843dfe54f04e18593c0aa76170"
|
|
64
64
|
}
|
package/src/router.ts
CHANGED
|
@@ -167,7 +167,7 @@ export class Router {
|
|
|
167
167
|
/**
|
|
168
168
|
* Check if the route matches the current route
|
|
169
169
|
*
|
|
170
|
-
* @param
|
|
170
|
+
* @param toRoute Target route object to compare
|
|
171
171
|
* @param matchType Match type
|
|
172
172
|
* - 'route': Route-level matching, compare if route configurations are the same
|
|
173
173
|
* - 'exact': Exact matching, compare if paths are completely the same
|
|
@@ -175,13 +175,13 @@ export class Router {
|
|
|
175
175
|
* @returns Whether it matches
|
|
176
176
|
*/
|
|
177
177
|
public isRouteMatched(
|
|
178
|
-
|
|
178
|
+
toRoute: Route,
|
|
179
179
|
matchType: RouteMatchType = 'include'
|
|
180
180
|
): boolean {
|
|
181
181
|
const currentRoute = this.transition.route;
|
|
182
182
|
if (!currentRoute) return false;
|
|
183
183
|
|
|
184
|
-
return isRouteMatched(currentRoute,
|
|
184
|
+
return isRouteMatched(currentRoute, toRoute, matchType);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
/**
|
package/src/util.ts
CHANGED
|
@@ -82,8 +82,8 @@ export function isUrlEqual(url1: URL, url2?: URL | null): boolean {
|
|
|
82
82
|
/**
|
|
83
83
|
* Compare if two routes match
|
|
84
84
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
85
|
+
* @param fromRoute First route object
|
|
86
|
+
* @param toRoute Second route object, may be null
|
|
87
87
|
* @param matchType Match type
|
|
88
88
|
* - 'route': Route-level matching, compare if route configurations are the same
|
|
89
89
|
* - 'exact': Exact matching, compare if full paths are the same
|
|
@@ -91,24 +91,24 @@ export function isUrlEqual(url1: URL, url2?: URL | null): boolean {
|
|
|
91
91
|
* @returns Whether they match
|
|
92
92
|
*/
|
|
93
93
|
export function isRouteMatched(
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
fromRoute: Route,
|
|
95
|
+
toRoute: Route | null,
|
|
96
96
|
matchType: RouteMatchType
|
|
97
97
|
): boolean {
|
|
98
|
-
if (!
|
|
98
|
+
if (!toRoute) return false;
|
|
99
99
|
|
|
100
100
|
switch (matchType) {
|
|
101
101
|
case 'route':
|
|
102
102
|
// Route-level matching - compare route configurations
|
|
103
|
-
return
|
|
103
|
+
return fromRoute.config === toRoute.config;
|
|
104
104
|
|
|
105
105
|
case 'exact':
|
|
106
106
|
// Exact matching - full paths are identical
|
|
107
|
-
return
|
|
107
|
+
return fromRoute.fullPath === toRoute.fullPath;
|
|
108
108
|
|
|
109
109
|
case 'include':
|
|
110
110
|
// Include matching - route1 path contains route2 path
|
|
111
|
-
return
|
|
111
|
+
return fromRoute.fullPath.startsWith(toRoute.fullPath);
|
|
112
112
|
|
|
113
113
|
default:
|
|
114
114
|
return false;
|