@remix-run/router 1.17.1 → 1.18.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 +15 -0
- package/dist/index.d.ts +1 -1
- package/dist/router.cjs.js +29 -32
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +1 -1
- package/dist/router.js +29 -33
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +29 -32
- 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 +1 -0
- package/package.json +1 -1
- package/router.ts +32 -30
- package/utils.ts +2 -2
package/dist/utils.d.ts
CHANGED
|
@@ -167,7 +167,7 @@ export interface ShouldRevalidateFunctionArgs {
|
|
|
167
167
|
text?: Submission["text"];
|
|
168
168
|
formData?: Submission["formData"];
|
|
169
169
|
json?: Submission["json"];
|
|
170
|
-
|
|
170
|
+
actionStatus?: number;
|
|
171
171
|
actionResult?: any;
|
|
172
172
|
defaultShouldRevalidate: boolean;
|
|
173
173
|
}
|
|
@@ -393,6 +393,7 @@ export interface PathMatch<ParamKey extends string = string> {
|
|
|
393
393
|
* @see https://reactrouter.com/utils/match-path
|
|
394
394
|
*/
|
|
395
395
|
export declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
|
|
396
|
+
export declare function decodePath(value: string): string;
|
|
396
397
|
/**
|
|
397
398
|
* @private
|
|
398
399
|
*/
|
package/index.ts
CHANGED
|
@@ -92,6 +92,7 @@ export {
|
|
|
92
92
|
ErrorResponseImpl as UNSAFE_ErrorResponseImpl,
|
|
93
93
|
convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes,
|
|
94
94
|
convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch,
|
|
95
|
+
decodePath as UNSAFE_decodePath,
|
|
95
96
|
getResolveToMatches as UNSAFE_getResolveToMatches,
|
|
96
97
|
} from "./utils";
|
|
97
98
|
|
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -372,7 +372,7 @@ export interface FutureConfig {
|
|
|
372
372
|
v7_partialHydration: boolean;
|
|
373
373
|
v7_prependBasename: boolean;
|
|
374
374
|
v7_relativeSplatPath: boolean;
|
|
375
|
-
|
|
375
|
+
v7_skipActionErrorRevalidation: boolean;
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
/**
|
|
@@ -806,7 +806,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
806
806
|
v7_partialHydration: false,
|
|
807
807
|
v7_prependBasename: false,
|
|
808
808
|
v7_relativeSplatPath: false,
|
|
809
|
-
|
|
809
|
+
v7_skipActionErrorRevalidation: false,
|
|
810
810
|
...init.future,
|
|
811
811
|
};
|
|
812
812
|
// Cleanup function for history
|
|
@@ -841,10 +841,13 @@ export function createRouter(init: RouterInit): Router {
|
|
|
841
841
|
initialErrors = { [route.id]: error };
|
|
842
842
|
}
|
|
843
843
|
|
|
844
|
-
//
|
|
845
|
-
// match is a splat route, clear them out so we run through lazy
|
|
846
|
-
// on hydration in case there's a more accurate lazy route match
|
|
847
|
-
|
|
844
|
+
// In SPA apps, if the user provided a patchRoutesOnMiss implementation and
|
|
845
|
+
// our initial match is a splat route, clear them out so we run through lazy
|
|
846
|
+
// discovery on hydration in case there's a more accurate lazy route match.
|
|
847
|
+
// In SSR apps (with `hydrationData`), we expect that the server will send
|
|
848
|
+
// up the proper matched routes so we don't want to run lazy discovery on
|
|
849
|
+
// initial hydration and want to hydrate into the splat route.
|
|
850
|
+
if (initialMatches && patchRoutesOnMissImpl && !init.hydrationData) {
|
|
848
851
|
let fogOfWar = checkFogOfWar(
|
|
849
852
|
initialMatches,
|
|
850
853
|
dataRoutes,
|
|
@@ -1680,14 +1683,14 @@ export function createRouter(init: RouterInit): Router {
|
|
|
1680
1683
|
if (discoverResult.type === "aborted") {
|
|
1681
1684
|
return { shortCircuited: true };
|
|
1682
1685
|
} else if (discoverResult.type === "error") {
|
|
1683
|
-
let {
|
|
1686
|
+
let { boundaryId, error } = handleDiscoverRouteError(
|
|
1684
1687
|
location.pathname,
|
|
1685
1688
|
discoverResult
|
|
1686
1689
|
);
|
|
1687
1690
|
return {
|
|
1688
|
-
matches:
|
|
1691
|
+
matches: discoverResult.partialMatches,
|
|
1689
1692
|
pendingActionResult: [
|
|
1690
|
-
|
|
1693
|
+
boundaryId,
|
|
1691
1694
|
{
|
|
1692
1695
|
type: ResultType.error,
|
|
1693
1696
|
error,
|
|
@@ -1856,15 +1859,15 @@ export function createRouter(init: RouterInit): Router {
|
|
|
1856
1859
|
if (discoverResult.type === "aborted") {
|
|
1857
1860
|
return { shortCircuited: true };
|
|
1858
1861
|
} else if (discoverResult.type === "error") {
|
|
1859
|
-
let {
|
|
1862
|
+
let { boundaryId, error } = handleDiscoverRouteError(
|
|
1860
1863
|
location.pathname,
|
|
1861
1864
|
discoverResult
|
|
1862
1865
|
);
|
|
1863
1866
|
return {
|
|
1864
|
-
matches:
|
|
1867
|
+
matches: discoverResult.partialMatches,
|
|
1865
1868
|
loaderData: {},
|
|
1866
1869
|
errors: {
|
|
1867
|
-
[
|
|
1870
|
+
[boundaryId]: error,
|
|
1868
1871
|
},
|
|
1869
1872
|
};
|
|
1870
1873
|
} else if (!discoverResult.matches) {
|
|
@@ -1891,7 +1894,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
1891
1894
|
activeSubmission,
|
|
1892
1895
|
location,
|
|
1893
1896
|
future.v7_partialHydration && initialHydration === true,
|
|
1894
|
-
future.
|
|
1897
|
+
future.v7_skipActionErrorRevalidation,
|
|
1895
1898
|
isRevalidationRequired,
|
|
1896
1899
|
cancelledDeferredRoutes,
|
|
1897
1900
|
cancelledFetcherLoads,
|
|
@@ -2350,7 +2353,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
2350
2353
|
submission,
|
|
2351
2354
|
nextLocation,
|
|
2352
2355
|
false,
|
|
2353
|
-
future.
|
|
2356
|
+
future.v7_skipActionErrorRevalidation,
|
|
2354
2357
|
isRevalidationRequired,
|
|
2355
2358
|
cancelledDeferredRoutes,
|
|
2356
2359
|
cancelledFetcherLoads,
|
|
@@ -3064,18 +3067,17 @@ export function createRouter(init: RouterInit): Router {
|
|
|
3064
3067
|
pathname: string,
|
|
3065
3068
|
discoverResult: DiscoverRoutesErrorResult
|
|
3066
3069
|
) {
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
}
|
|
3078
|
-
return { notFoundMatches: matches, route, error };
|
|
3070
|
+
return {
|
|
3071
|
+
boundaryId: findNearestBoundary(discoverResult.partialMatches).route.id,
|
|
3072
|
+
error: getInternalRouterError(400, {
|
|
3073
|
+
type: "route-discovery",
|
|
3074
|
+
pathname,
|
|
3075
|
+
message:
|
|
3076
|
+
discoverResult.error != null && "message" in discoverResult.error
|
|
3077
|
+
? discoverResult.error
|
|
3078
|
+
: String(discoverResult.error),
|
|
3079
|
+
}),
|
|
3080
|
+
};
|
|
3079
3081
|
}
|
|
3080
3082
|
|
|
3081
3083
|
function cancelActiveDeferreds(
|
|
@@ -4384,7 +4386,7 @@ function getMatchesToLoad(
|
|
|
4384
4386
|
nextParams: nextRouteMatch.params,
|
|
4385
4387
|
...submission,
|
|
4386
4388
|
actionResult,
|
|
4387
|
-
|
|
4389
|
+
actionStatus,
|
|
4388
4390
|
defaultShouldRevalidate: shouldSkipRevalidation
|
|
4389
4391
|
? false
|
|
4390
4392
|
: // Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate
|
|
@@ -4463,7 +4465,7 @@ function getMatchesToLoad(
|
|
|
4463
4465
|
nextParams: matches[matches.length - 1].params,
|
|
4464
4466
|
...submission,
|
|
4465
4467
|
actionResult,
|
|
4466
|
-
|
|
4468
|
+
actionStatus,
|
|
4467
4469
|
defaultShouldRevalidate: shouldSkipRevalidation
|
|
4468
4470
|
? false
|
|
4469
4471
|
: isRevalidationRequired,
|
|
@@ -5364,8 +5366,8 @@ function getInternalRouterError(
|
|
|
5364
5366
|
statusText = "Bad Request";
|
|
5365
5367
|
if (type === "route-discovery") {
|
|
5366
5368
|
errorMessage =
|
|
5367
|
-
`Unable to match URL "${pathname}" - the \`
|
|
5368
|
-
`
|
|
5369
|
+
`Unable to match URL "${pathname}" - the \`unstable_patchRoutesOnMiss()\` ` +
|
|
5370
|
+
`function threw the following error:\n${message}`;
|
|
5369
5371
|
} else if (method && pathname && routeId) {
|
|
5370
5372
|
errorMessage =
|
|
5371
5373
|
`You made a ${method} request to "${pathname}" but ` +
|
package/utils.ts
CHANGED
|
@@ -210,7 +210,7 @@ export interface ShouldRevalidateFunctionArgs {
|
|
|
210
210
|
text?: Submission["text"];
|
|
211
211
|
formData?: Submission["formData"];
|
|
212
212
|
json?: Submission["json"];
|
|
213
|
-
|
|
213
|
+
actionStatus?: number;
|
|
214
214
|
actionResult?: any;
|
|
215
215
|
defaultShouldRevalidate: boolean;
|
|
216
216
|
}
|
|
@@ -1075,7 +1075,7 @@ function compilePath(
|
|
|
1075
1075
|
return [matcher, params];
|
|
1076
1076
|
}
|
|
1077
1077
|
|
|
1078
|
-
function decodePath(value: string) {
|
|
1078
|
+
export function decodePath(value: string) {
|
|
1079
1079
|
try {
|
|
1080
1080
|
return value
|
|
1081
1081
|
.split("/")
|