@remix-run/router 0.0.0-experimental-dc307bdd5 → 0.0.0-experimental-d7bf770a8
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 +2 -14
- package/dist/index.d.ts +1 -1
- package/dist/router.cjs.js +13 -13
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -2
- package/dist/router.js +13 -13
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +13 -13
- 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 +1 -1
- package/index.ts +1 -1
- package/package.json +1 -1
- package/router.ts +19 -16
- package/utils.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
-
## 1.19.0
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [REMOVE] Export DataWithResponseInit for Remix usage ([#11859](https://github.com/remix-run/react-router/pull/11859))
|
|
8
|
-
|
|
9
|
-
## 1.19.0-pre.0
|
|
3
|
+
## 1.19.0
|
|
10
4
|
|
|
11
5
|
### Minor Changes
|
|
12
6
|
|
|
7
|
+
- Add a new `replace(url, init?)` alternative to `redirect(url, init?)` that performs a `history.replaceState` instead of a `history.pushState` on client-side navigation redirects ([#11811](https://github.com/remix-run/react-router/pull/11811))
|
|
13
8
|
- Add a new `unstable_data()` API for usage with Remix Single Fetch ([#11836](https://github.com/remix-run/react-router/pull/11836))
|
|
14
|
-
|
|
15
9
|
- This API is not intended for direct usage in React Router SPA applications
|
|
16
10
|
- It is primarily intended for usage with `createStaticHandler.query()` to allow loaders/actions to return arbitrary data + `status`/`headers` without forcing the serialization of data into a `Response` instance
|
|
17
11
|
- This allows for more advanced serialization tactics via `unstable_dataStrategy` such as serializing via `turbo-stream` in Remix Single Fetch
|
|
18
12
|
- ⚠️ This removes the `status` field from `HandlerResult`
|
|
19
13
|
- If you need to return a specific `status` from `unstable_dataStrategy` you should instead do so via `unstable_data()`
|
|
20
14
|
|
|
21
|
-
- Add a new `replace(url, init?)` alternative to `redirect(url, init?)` that performs a `history.replaceState` instead of a `history.pushState` on client-side navigation redirects ([#11811](https://github.com/remix-run/react-router/pull/11811))
|
|
22
|
-
|
|
23
15
|
### Patch Changes
|
|
24
16
|
|
|
25
17
|
- Fix internal cleanup of interrupted fetchers to avoid invalid revalidations on navigations ([#11839](https://github.com/remix-run/react-router/pull/11839))
|
|
26
|
-
|
|
27
18
|
- When a `fetcher.load` is interrupted by an `action` submission, we track it internally and force revalidation once the `action` completes
|
|
28
19
|
- We previously only cleared out this internal tracking info on a successful _navigation_ submission
|
|
29
20
|
- Therefore, if the `fetcher.load` was interrupted by a `fetcher.submit`, then we wouldn't remove it from this internal tracking info on successful load (incorrectly)
|
|
30
21
|
- And then on the next navigation it's presence in the internal tracking would automatically trigger execution of the `fetcher.load` again, ignoring any `shouldRevalidate` logic
|
|
31
22
|
- This fix cleans up the internal tracking so it applies to both navigation submission and fetcher submissions
|
|
32
|
-
|
|
33
23
|
- Fix initial hydration behavior when using `future.v7_partialHydration` along with `unstable_patchRoutesOnMiss` ([#11838](https://github.com/remix-run/react-router/pull/11838))
|
|
34
|
-
|
|
35
24
|
- During initial hydration, `router.state.matches` will now include any partial matches so that we can render ancestor `HydrateFallback` components
|
|
36
25
|
|
|
37
26
|
## 1.18.0
|
|
@@ -39,7 +28,6 @@
|
|
|
39
28
|
### Minor Changes
|
|
40
29
|
|
|
41
30
|
- Stabilize `future.unstable_skipActionErrorRevalidation` as `future.v7_skipActionErrorRevalidation` ([#11769](https://github.com/remix-run/react-router/pull/11769))
|
|
42
|
-
|
|
43
31
|
- When this flag is enabled, actions will not automatically trigger a revalidation if they return/throw a `Response` with a `4xx`/`5xx` status code
|
|
44
32
|
- You may still opt-into revalidation via `shouldRevalidate`
|
|
45
33
|
- This also changes `shouldRevalidate`'s `unstable_actionStatus` parameter to `actionStatus`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, DataStrategyFunction as unstable_DataStrategyFunction, DataStrategyFunctionArgs as unstable_DataStrategyFunctionArgs, DataStrategyMatch as unstable_DataStrategyMatch, ErrorResponse, FormEncType, FormMethod, HandlerResult as unstable_HandlerResult, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params,
|
|
1
|
+
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, DataStrategyFunction as unstable_DataStrategyFunction, DataStrategyFunctionArgs as unstable_DataStrategyFunctionArgs, DataStrategyMatch as unstable_DataStrategyMatch, ErrorResponse, FormEncType, FormMethod, HandlerResult as unstable_HandlerResult, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, AgnosticPatchRoutesOnNavigationFunction as unstable_AgnosticPatchRoutesOnNavigationFunction, PathMatch, PathParam, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, UIMatch, V7_FormMethod, DataWithResponseInit as UNSAFE_DataWithResponseInit, } from "./utils";
|
|
2
2
|
export { AbortedDeferredError, data as unstable_data, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, replace, resolvePath, resolveTo, stripBasename, } from "./utils";
|
|
3
3
|
export type { BrowserHistory, BrowserHistoryOptions, HashHistory, HashHistoryOptions, History, InitialEntry, Location, MemoryHistory, MemoryHistoryOptions, Path, To, } from "./history";
|
|
4
4
|
export { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath, } from "./history";
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-d7bf770a8
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1713,7 +1713,7 @@ function createRouter(init) {
|
|
|
1713
1713
|
let inFlightDataRoutes;
|
|
1714
1714
|
let basename = init.basename || "/";
|
|
1715
1715
|
let dataStrategyImpl = init.unstable_dataStrategy || defaultDataStrategy;
|
|
1716
|
-
let
|
|
1716
|
+
let patchRoutesOnNavigationImpl = init.unstable_patchRoutesOnNavigation;
|
|
1717
1717
|
|
|
1718
1718
|
// Config driven behavior flags
|
|
1719
1719
|
let future = _extends({
|
|
@@ -1747,7 +1747,7 @@ function createRouter(init) {
|
|
|
1747
1747
|
let initialScrollRestored = init.hydrationData != null;
|
|
1748
1748
|
let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
|
|
1749
1749
|
let initialErrors = null;
|
|
1750
|
-
if (initialMatches == null && !
|
|
1750
|
+
if (initialMatches == null && !patchRoutesOnNavigationImpl) {
|
|
1751
1751
|
// If we do not match a user-provided-route, fall back to the root
|
|
1752
1752
|
// to allow the error boundary to take over
|
|
1753
1753
|
let error = getInternalRouterError(404, {
|
|
@@ -1763,7 +1763,7 @@ function createRouter(init) {
|
|
|
1763
1763
|
};
|
|
1764
1764
|
}
|
|
1765
1765
|
|
|
1766
|
-
// In SPA apps, if the user provided a
|
|
1766
|
+
// In SPA apps, if the user provided a patchRoutesOnNavigation implementation and
|
|
1767
1767
|
// our initial match is a splat route, clear them out so we run through lazy
|
|
1768
1768
|
// discovery on hydration in case there's a more accurate lazy route match.
|
|
1769
1769
|
// In SSR apps (with `hydrationData`), we expect that the server will send
|
|
@@ -1781,7 +1781,7 @@ function createRouter(init) {
|
|
|
1781
1781
|
initialMatches = [];
|
|
1782
1782
|
|
|
1783
1783
|
// If partial hydration and fog of war is enabled, we will be running
|
|
1784
|
-
// `
|
|
1784
|
+
// `patchRoutesOnNavigation` during hydration so include any partial matches as
|
|
1785
1785
|
// the initial matches so we can properly render `HydrateFallback`'s
|
|
1786
1786
|
if (future.v7_partialHydration) {
|
|
1787
1787
|
let fogOfWar = checkFogOfWar(null, dataRoutes, init.history.location.pathname);
|
|
@@ -1920,7 +1920,7 @@ function createRouter(init) {
|
|
|
1920
1920
|
// we don't need to update UI state if they change
|
|
1921
1921
|
let blockerFunctions = new Map();
|
|
1922
1922
|
|
|
1923
|
-
// Map of pending
|
|
1923
|
+
// Map of pending patchRoutesOnNavigation() promises (keyed by path/matches) so
|
|
1924
1924
|
// that we only kick them off once for a given combo
|
|
1925
1925
|
let pendingPatchRoutes = new Map();
|
|
1926
1926
|
|
|
@@ -3544,7 +3544,7 @@ function createRouter(init) {
|
|
|
3544
3544
|
return null;
|
|
3545
3545
|
}
|
|
3546
3546
|
function checkFogOfWar(matches, routesToUse, pathname) {
|
|
3547
|
-
if (
|
|
3547
|
+
if (patchRoutesOnNavigationImpl) {
|
|
3548
3548
|
// Don't bother re-calling patchRouteOnMiss for a path we've already
|
|
3549
3549
|
// processed. the last execution would have patched the route tree
|
|
3550
3550
|
// accordingly so `matches` here are already accurate.
|
|
@@ -3564,7 +3564,7 @@ function createRouter(init) {
|
|
|
3564
3564
|
if (Object.keys(matches[0].params).length > 0) {
|
|
3565
3565
|
// If we matched a dynamic param or a splat, it might only be because
|
|
3566
3566
|
// we haven't yet discovered other routes that would match with a
|
|
3567
|
-
// higher score. Call
|
|
3567
|
+
// higher score. Call patchRoutesOnNavigation just to be sure
|
|
3568
3568
|
let partialMatches = matchRoutesImpl(routesToUse, pathname, basename, true);
|
|
3569
3569
|
return {
|
|
3570
3570
|
active: true,
|
|
@@ -3584,7 +3584,7 @@ function createRouter(init) {
|
|
|
3584
3584
|
let isNonHMR = inFlightDataRoutes == null;
|
|
3585
3585
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3586
3586
|
try {
|
|
3587
|
-
await loadLazyRouteChildren(
|
|
3587
|
+
await loadLazyRouteChildren(patchRoutesOnNavigationImpl, pathname, partialMatches, routesToUse, manifest, mapRouteProperties, pendingPatchRoutes, signal);
|
|
3588
3588
|
} catch (e) {
|
|
3589
3589
|
return {
|
|
3590
3590
|
type: "error",
|
|
@@ -4504,15 +4504,15 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
4504
4504
|
}
|
|
4505
4505
|
|
|
4506
4506
|
/**
|
|
4507
|
-
* Idempotent utility to execute
|
|
4507
|
+
* Idempotent utility to execute patchRoutesOnNavigation() to lazily load route
|
|
4508
4508
|
* definitions and update the routes/routeManifest
|
|
4509
4509
|
*/
|
|
4510
|
-
async function loadLazyRouteChildren(
|
|
4510
|
+
async function loadLazyRouteChildren(patchRoutesOnNavigationImpl, path, matches, routes, manifest, mapRouteProperties, pendingRouteChildren, signal) {
|
|
4511
4511
|
let key = [path, ...matches.map(m => m.route.id)].join("-");
|
|
4512
4512
|
try {
|
|
4513
4513
|
let pending = pendingRouteChildren.get(key);
|
|
4514
4514
|
if (!pending) {
|
|
4515
|
-
pending =
|
|
4515
|
+
pending = patchRoutesOnNavigationImpl({
|
|
4516
4516
|
path,
|
|
4517
4517
|
matches,
|
|
4518
4518
|
patch: (routeId, children) => {
|
|
@@ -5119,7 +5119,7 @@ function getInternalRouterError(status, _temp5) {
|
|
|
5119
5119
|
if (status === 400) {
|
|
5120
5120
|
statusText = "Bad Request";
|
|
5121
5121
|
if (type === "route-discovery") {
|
|
5122
|
-
errorMessage = "Unable to match URL \"" + pathname + "\" - the `
|
|
5122
|
+
errorMessage = "Unable to match URL \"" + pathname + "\" - the `unstable_patchRoutesOnNavigation()` " + ("function threw the following error:\n" + message);
|
|
5123
5123
|
} else if (method && pathname && routeId) {
|
|
5124
5124
|
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.";
|
|
5125
5125
|
} else if (type === "defer-action") {
|