@remix-run/router 1.12.0 → 1.13.0
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 +13 -0
- package/dist/index.d.ts +2 -2
- package/dist/router.cjs.js +14 -7
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +13 -7
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +14 -7
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/index.ts +2 -1
- package/package.json +1 -1
- package/router.ts +9 -2
- package/utils.ts +12 -1
package/dist/utils.d.ts
CHANGED
|
@@ -261,7 +261,7 @@ type _PathParam<Path extends string> = Path extends `${infer L}/${infer R}` ? _P
|
|
|
261
261
|
* "/:a/:b" -> "a" | "b"
|
|
262
262
|
* "/:a/b/:c/*" -> "a" | "c" | "*"
|
|
263
263
|
*/
|
|
264
|
-
type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
|
|
264
|
+
export type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
|
|
265
265
|
export type ParamParseKey<Segment extends string> = [
|
|
266
266
|
PathParam<Segment>
|
|
267
267
|
] extends [never] ? string : PathParam<Segment>;
|
|
@@ -399,6 +399,7 @@ export declare function resolvePath(to: To, fromPathname?: string): Path;
|
|
|
399
399
|
* </Route>
|
|
400
400
|
*/
|
|
401
401
|
export declare function getPathContributingMatches<T extends AgnosticRouteMatch = AgnosticRouteMatch>(matches: T[]): T[];
|
|
402
|
+
export declare function getResolveToMatches<T extends AgnosticRouteMatch = AgnosticRouteMatch>(matches: T[]): string[];
|
|
402
403
|
/**
|
|
403
404
|
* @private
|
|
404
405
|
*/
|
package/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type {
|
|
|
20
20
|
ParamParseKey,
|
|
21
21
|
Params,
|
|
22
22
|
PathMatch,
|
|
23
|
+
PathParam,
|
|
23
24
|
PathPattern,
|
|
24
25
|
RedirectFunction,
|
|
25
26
|
ShouldRevalidateFunction,
|
|
@@ -86,7 +87,7 @@ export {
|
|
|
86
87
|
ErrorResponseImpl as UNSAFE_ErrorResponseImpl,
|
|
87
88
|
convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes,
|
|
88
89
|
convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch,
|
|
89
|
-
|
|
90
|
+
getResolveToMatches as UNSAFE_getResolveToMatches,
|
|
90
91
|
} from "./utils";
|
|
91
92
|
|
|
92
93
|
export {
|
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
convertRouteMatchToUiMatch,
|
|
41
41
|
convertRoutesToDataRoutes,
|
|
42
42
|
getPathContributingMatches,
|
|
43
|
+
getResolveToMatches,
|
|
43
44
|
immutableRouteKeys,
|
|
44
45
|
isRouteErrorResponse,
|
|
45
46
|
joinPaths,
|
|
@@ -1632,6 +1633,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
1632
1633
|
isRevalidationRequired,
|
|
1633
1634
|
cancelledDeferredRoutes,
|
|
1634
1635
|
cancelledFetcherLoads,
|
|
1636
|
+
deletedFetchers,
|
|
1635
1637
|
fetchLoadMatches,
|
|
1636
1638
|
fetchRedirectIds,
|
|
1637
1639
|
routesToUse,
|
|
@@ -2005,6 +2007,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
2005
2007
|
isRevalidationRequired,
|
|
2006
2008
|
cancelledDeferredRoutes,
|
|
2007
2009
|
cancelledFetcherLoads,
|
|
2010
|
+
deletedFetchers,
|
|
2008
2011
|
fetchLoadMatches,
|
|
2009
2012
|
fetchRedirectIds,
|
|
2010
2013
|
routesToUse,
|
|
@@ -3338,7 +3341,7 @@ function normalizeTo(
|
|
|
3338
3341
|
// Resolve the relative path
|
|
3339
3342
|
let path = resolveTo(
|
|
3340
3343
|
to ? to : ".",
|
|
3341
|
-
|
|
3344
|
+
getResolveToMatches(contextualMatches),
|
|
3342
3345
|
stripBasename(location.pathname, basename) || location.pathname,
|
|
3343
3346
|
relative === "path"
|
|
3344
3347
|
);
|
|
@@ -3549,6 +3552,7 @@ function getMatchesToLoad(
|
|
|
3549
3552
|
isRevalidationRequired: boolean,
|
|
3550
3553
|
cancelledDeferredRoutes: string[],
|
|
3551
3554
|
cancelledFetcherLoads: string[],
|
|
3555
|
+
deletedFetchers: Set<string>,
|
|
3552
3556
|
fetchLoadMatches: Map<string, FetchLoadMatch>,
|
|
3553
3557
|
fetchRedirectIds: Set<string>,
|
|
3554
3558
|
routesToUse: AgnosticDataRouteObject[],
|
|
@@ -3616,7 +3620,10 @@ function getMatchesToLoad(
|
|
|
3616
3620
|
let revalidatingFetchers: RevalidatingFetcher[] = [];
|
|
3617
3621
|
fetchLoadMatches.forEach((f, key) => {
|
|
3618
3622
|
// Don't revalidate if fetcher won't be present in the subsequent render
|
|
3619
|
-
if (
|
|
3623
|
+
if (
|
|
3624
|
+
!matches.some((m) => m.route.id === f.routeId) ||
|
|
3625
|
+
deletedFetchers.has(key)
|
|
3626
|
+
) {
|
|
3620
3627
|
return;
|
|
3621
3628
|
}
|
|
3622
3629
|
|
package/utils.ts
CHANGED
|
@@ -349,7 +349,7 @@ type _PathParam<Path extends string> =
|
|
|
349
349
|
* "/:a/:b" -> "a" | "b"
|
|
350
350
|
* "/:a/b/:c/*" -> "a" | "c" | "*"
|
|
351
351
|
*/
|
|
352
|
-
type PathParam<Path extends string> =
|
|
352
|
+
export type PathParam<Path extends string> =
|
|
353
353
|
// check if path is just a wildcard
|
|
354
354
|
Path extends "*" | "/*"
|
|
355
355
|
? "*"
|
|
@@ -1145,6 +1145,17 @@ export function getPathContributingMatches<
|
|
|
1145
1145
|
);
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
|
+
// Return the array of pathnames for the current route matches - used to
|
|
1149
|
+
// generate the routePathnames input for resolveTo()
|
|
1150
|
+
export function getResolveToMatches<
|
|
1151
|
+
T extends AgnosticRouteMatch = AgnosticRouteMatch
|
|
1152
|
+
>(matches: T[]) {
|
|
1153
|
+
// Use the full pathname for the leaf match so we include splat values for "." links
|
|
1154
|
+
return getPathContributingMatches(matches).map((match, idx) =>
|
|
1155
|
+
idx === matches.length - 1 ? match.pathname : match.pathnameBase
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1148
1159
|
/**
|
|
1149
1160
|
* @private
|
|
1150
1161
|
*/
|