@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Stabilize `future.unstable_skipActionErrorRevalidation` as `future.v7_skipActionErrorRevalidation` ([#11769](https://github.com/remix-run/react-router/pull/11769))
|
|
8
|
+
|
|
9
|
+
- When this flag is enabled, actions will not automatically trigger a revalidation if they return/throw a `Response` with a `4xx`/`5xx` status code
|
|
10
|
+
- You may still opt-into revalidation via `shouldRevalidate`
|
|
11
|
+
- This also changes `shouldRevalidate`'s `unstable_actionStatus` parameter to `actionStatus`
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Fix bubbling of errors thrown from `unstable_patchRoutesOnMiss` ([#11786](https://github.com/remix-run/react-router/pull/11786))
|
|
16
|
+
- Fix hydration in SSR apps using `unstable_patchRoutesOnMiss` that matched a splat route on the server ([#11790](https://github.com/remix-run/react-router/pull/11790))
|
|
17
|
+
|
|
3
18
|
## 1.17.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export { Action, createBrowserHistory, createHashHistory, createMemoryHistory, c
|
|
|
5
5
|
export * from "./router";
|
|
6
6
|
/** @internal */
|
|
7
7
|
export type { RouteManifest as UNSAFE_RouteManifest } from "./utils";
|
|
8
|
-
export { DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch, getResolveToMatches as UNSAFE_getResolveToMatches, } from "./utils";
|
|
8
|
+
export { DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch, decodePath as UNSAFE_decodePath, getResolveToMatches as UNSAFE_getResolveToMatches, } from "./utils";
|
|
9
9
|
export { invariant as UNSAFE_invariant, warning as UNSAFE_warning, } from "./history";
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.
|
|
2
|
+
* @remix-run/router v1.18.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1693,7 +1693,7 @@ function createRouter(init) {
|
|
|
1693
1693
|
v7_partialHydration: false,
|
|
1694
1694
|
v7_prependBasename: false,
|
|
1695
1695
|
v7_relativeSplatPath: false,
|
|
1696
|
-
|
|
1696
|
+
v7_skipActionErrorRevalidation: false
|
|
1697
1697
|
}, init.future);
|
|
1698
1698
|
// Cleanup function for history
|
|
1699
1699
|
let unlistenHistory = null;
|
|
@@ -1730,10 +1730,13 @@ function createRouter(init) {
|
|
|
1730
1730
|
};
|
|
1731
1731
|
}
|
|
1732
1732
|
|
|
1733
|
-
//
|
|
1734
|
-
// match is a splat route, clear them out so we run through lazy
|
|
1735
|
-
// on hydration in case there's a more accurate lazy route match
|
|
1736
|
-
|
|
1733
|
+
// In SPA apps, if the user provided a patchRoutesOnMiss implementation and
|
|
1734
|
+
// our initial match is a splat route, clear them out so we run through lazy
|
|
1735
|
+
// discovery on hydration in case there's a more accurate lazy route match.
|
|
1736
|
+
// In SSR apps (with `hydrationData`), we expect that the server will send
|
|
1737
|
+
// up the proper matched routes so we don't want to run lazy discovery on
|
|
1738
|
+
// initial hydration and want to hydrate into the splat route.
|
|
1739
|
+
if (initialMatches && patchRoutesOnMissImpl && !init.hydrationData) {
|
|
1737
1740
|
let fogOfWar = checkFogOfWar(initialMatches, dataRoutes, init.history.location.pathname);
|
|
1738
1741
|
if (fogOfWar.active) {
|
|
1739
1742
|
initialMatches = null;
|
|
@@ -2405,13 +2408,12 @@ function createRouter(init) {
|
|
|
2405
2408
|
};
|
|
2406
2409
|
} else if (discoverResult.type === "error") {
|
|
2407
2410
|
let {
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
route
|
|
2411
|
+
boundaryId,
|
|
2412
|
+
error
|
|
2411
2413
|
} = handleDiscoverRouteError(location.pathname, discoverResult);
|
|
2412
2414
|
return {
|
|
2413
|
-
matches:
|
|
2414
|
-
pendingActionResult: [
|
|
2415
|
+
matches: discoverResult.partialMatches,
|
|
2416
|
+
pendingActionResult: [boundaryId, {
|
|
2415
2417
|
type: ResultType.error,
|
|
2416
2418
|
error
|
|
2417
2419
|
}]
|
|
@@ -2544,15 +2546,14 @@ function createRouter(init) {
|
|
|
2544
2546
|
};
|
|
2545
2547
|
} else if (discoverResult.type === "error") {
|
|
2546
2548
|
let {
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
route
|
|
2549
|
+
boundaryId,
|
|
2550
|
+
error
|
|
2550
2551
|
} = handleDiscoverRouteError(location.pathname, discoverResult);
|
|
2551
2552
|
return {
|
|
2552
|
-
matches:
|
|
2553
|
+
matches: discoverResult.partialMatches,
|
|
2553
2554
|
loaderData: {},
|
|
2554
2555
|
errors: {
|
|
2555
|
-
[
|
|
2556
|
+
[boundaryId]: error
|
|
2556
2557
|
}
|
|
2557
2558
|
};
|
|
2558
2559
|
} else if (!discoverResult.matches) {
|
|
@@ -2573,7 +2574,7 @@ function createRouter(init) {
|
|
|
2573
2574
|
}
|
|
2574
2575
|
}
|
|
2575
2576
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
2576
|
-
let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, future.v7_partialHydration && initialHydration === true, future.
|
|
2577
|
+
let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, future.v7_partialHydration && initialHydration === true, future.v7_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult);
|
|
2577
2578
|
|
|
2578
2579
|
// Cancel pending deferreds for no-longer-matched routes or routes we're
|
|
2579
2580
|
// about to reload. Note that if this is an action reload we would have
|
|
@@ -2908,7 +2909,7 @@ function createRouter(init) {
|
|
|
2908
2909
|
fetchReloadIds.set(key, loadId);
|
|
2909
2910
|
let loadFetcher = getLoadingFetcher(submission, actionResult.data);
|
|
2910
2911
|
state.fetchers.set(key, loadFetcher);
|
|
2911
|
-
let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, false, future.
|
|
2912
|
+
let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, false, future.v7_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, [match.route.id, actionResult]);
|
|
2912
2913
|
|
|
2913
2914
|
// Put all revalidating fetchers into the loading state, except for the
|
|
2914
2915
|
// current fetcher which we want to keep in it's current loading state which
|
|
@@ -3428,18 +3429,13 @@ function createRouter(init) {
|
|
|
3428
3429
|
};
|
|
3429
3430
|
}
|
|
3430
3431
|
function handleDiscoverRouteError(pathname, discoverResult) {
|
|
3431
|
-
let matches = discoverResult.partialMatches;
|
|
3432
|
-
let route = matches[matches.length - 1].route;
|
|
3433
|
-
let error = getInternalRouterError(400, {
|
|
3434
|
-
type: "route-discovery",
|
|
3435
|
-
routeId: route.id,
|
|
3436
|
-
pathname,
|
|
3437
|
-
message: discoverResult.error != null && "message" in discoverResult.error ? discoverResult.error : String(discoverResult.error)
|
|
3438
|
-
});
|
|
3439
3432
|
return {
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3433
|
+
boundaryId: findNearestBoundary(discoverResult.partialMatches).route.id,
|
|
3434
|
+
error: getInternalRouterError(400, {
|
|
3435
|
+
type: "route-discovery",
|
|
3436
|
+
pathname,
|
|
3437
|
+
message: discoverResult.error != null && "message" in discoverResult.error ? discoverResult.error : String(discoverResult.error)
|
|
3438
|
+
})
|
|
3443
3439
|
};
|
|
3444
3440
|
}
|
|
3445
3441
|
function cancelActiveDeferreds(predicate) {
|
|
@@ -4361,7 +4357,7 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
|
|
|
4361
4357
|
nextParams: nextRouteMatch.params
|
|
4362
4358
|
}, submission, {
|
|
4363
4359
|
actionResult,
|
|
4364
|
-
|
|
4360
|
+
actionStatus,
|
|
4365
4361
|
defaultShouldRevalidate: shouldSkipRevalidation ? false :
|
|
4366
4362
|
// Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate
|
|
4367
4363
|
isRevalidationRequired || currentUrl.pathname + currentUrl.search === nextUrl.pathname + nextUrl.search ||
|
|
@@ -4426,7 +4422,7 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
|
|
|
4426
4422
|
nextParams: matches[matches.length - 1].params
|
|
4427
4423
|
}, submission, {
|
|
4428
4424
|
actionResult,
|
|
4429
|
-
|
|
4425
|
+
actionStatus,
|
|
4430
4426
|
defaultShouldRevalidate: shouldSkipRevalidation ? false : isRevalidationRequired
|
|
4431
4427
|
}));
|
|
4432
4428
|
}
|
|
@@ -5072,7 +5068,7 @@ function getInternalRouterError(status, _temp5) {
|
|
|
5072
5068
|
if (status === 400) {
|
|
5073
5069
|
statusText = "Bad Request";
|
|
5074
5070
|
if (type === "route-discovery") {
|
|
5075
|
-
errorMessage = "Unable to match URL \"" + pathname + "\" - the `
|
|
5071
|
+
errorMessage = "Unable to match URL \"" + pathname + "\" - the `unstable_patchRoutesOnMiss()` " + ("function threw the following error:\n" + message);
|
|
5076
5072
|
} else if (method && pathname && routeId) {
|
|
5077
5073
|
errorMessage = "You made a " + method + " request to \"" + pathname + "\" but " + ("did not provide a `loader` for route \"" + routeId + "\", ") + "so there is no way to handle the request.";
|
|
5078
5074
|
} else if (type === "defer-action") {
|
|
@@ -5414,6 +5410,7 @@ exports.UNSAFE_DeferredData = DeferredData;
|
|
|
5414
5410
|
exports.UNSAFE_ErrorResponseImpl = ErrorResponseImpl;
|
|
5415
5411
|
exports.UNSAFE_convertRouteMatchToUiMatch = convertRouteMatchToUiMatch;
|
|
5416
5412
|
exports.UNSAFE_convertRoutesToDataRoutes = convertRoutesToDataRoutes;
|
|
5413
|
+
exports.UNSAFE_decodePath = decodePath;
|
|
5417
5414
|
exports.UNSAFE_getResolveToMatches = getResolveToMatches;
|
|
5418
5415
|
exports.UNSAFE_invariant = invariant;
|
|
5419
5416
|
exports.UNSAFE_warning = warning;
|