@remix-run/router 1.9.0-pre.1 → 1.9.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 +6 -12
- package/dist/history.d.ts +4 -4
- package/dist/router.cjs.js +12 -11
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +8 -8
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +12 -11
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +1 -1
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +9 -9
- package/history.ts +5 -5
- package/package.json +1 -1
- package/utils.ts +24 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
-
## 1.9.0
|
|
3
|
+
## 1.9.0
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- In order to move towards stricter TypeScript support in the future, we're aiming to replace current usages of `any` with `unknown` on exposed typings for user-provided data. To do this in Remix v2 without introducing breaking changes in React Router v6, we have added generics to a number of shared types. These continue to default to `any` in React Router and are overridden with `unknown` in Remix. In React Router v7 we plan to move these to `unknown` as a breakjing change. ([#10843](https://github.com/remix-run/react-router/pull/10843))
|
|
5
|
+
### Minor Changes
|
|
8
6
|
|
|
7
|
+
- In order to move towards stricter TypeScript support in the future, we're aiming to replace current usages of `any` with `unknown` on exposed typings for user-provided data. To do this in Remix v2 without introducing breaking changes in React Router v6, we have added generics to a number of shared types. These continue to default to `any` in React Router and are overridden with `unknown` in Remix. In React Router v7 we plan to move these to `unknown` as a breaking change. ([#10843](https://github.com/remix-run/react-router/pull/10843))
|
|
9
8
|
- `Location` now accepts a generic for the `location.state` value
|
|
10
9
|
- `ActionFunctionArgs`/`ActionFunction`/`LoaderFunctionArgs`/`LoaderFunction` now accept a generic for the `context` parameter (only used in SSR usages via `createStaticHandler`)
|
|
11
10
|
- The return type of `useMatches` (now exported as `UIMatch`) accepts generics for `match.data` and `match.handle` - both of which were already set to `unknown`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### Minor Changes
|
|
16
|
-
|
|
17
|
-
- Removed internal API only required for the Remix v1 back-compat layer and no longer needed in Remix v2 (`_isFetchActionRedirect`, `_hasFetcherDoneAnything`) ([#10715](https://github.com/remix-run/react-router/pull/10715))
|
|
11
|
+
- Move the `@private` class export `ErrorResponse` to an `UNSAFE_ErrorResponseImpl` export since it is an implementation detail and there should be no construction of `ErrorResponse` instances in userland. This frees us up to export a `type ErrorResponse` which correlates to an instance of the class via `InstanceType`. Userland code should only ever be using `ErrorResponse` as a type and should be type-narrowing via `isRouteErrorResponse`. ([#10811](https://github.com/remix-run/react-router/pull/10811))
|
|
12
|
+
- Export `ShouldRevalidateFunctionArgs` interface ([#10797](https://github.com/remix-run/react-router/pull/10797))
|
|
13
|
+
- Removed private/internal APIs only required for the Remix v1 backwards compatibility layer and no longer needed in Remix v2 (`_isFetchActionRedirect`, `_hasFetcherDoneAnything`) ([#10715](https://github.com/remix-run/react-router/pull/10715))
|
|
18
14
|
|
|
19
15
|
### Patch Changes
|
|
20
16
|
|
|
21
17
|
- Add method/url to error message on aborted `query`/`queryRoute` calls ([#10793](https://github.com/remix-run/react-router/pull/10793))
|
|
22
|
-
- Move the `@private` class export `ErrorResponse` to an `UNSAFE_ErrorResponseImpl` export since it is an implementation detail and there should be no construction of `ErrorResponse` instances in userland. This frees us up to export a `type ErrorResponse` which correlates to an instance of the class via `InstanceType`. Userland code should only ever be using `ErrorResponse` as a type and should be type-narrowing via `isRouteErrorResponse`. ([#10811](https://github.com/remix-run/react-router/pull/10811))
|
|
23
|
-
- Export `ShouldRevalidateFunctionArgs` interface ([#10797](https://github.com/remix-run/react-router/pull/10797))
|
|
24
18
|
- Fix a race-condition with loader/action-thrown errors on `route.lazy` routes ([#10778](https://github.com/remix-run/react-router/pull/10778))
|
|
25
19
|
- Fix type for `actionResult` on the arguments object passed to `shouldRevalidate` ([#10779](https://github.com/remix-run/react-router/pull/10779))
|
|
26
20
|
|
package/dist/history.d.ts
CHANGED
|
@@ -43,11 +43,11 @@ export interface Path {
|
|
|
43
43
|
* An entry in a history stack. A location contains information about the
|
|
44
44
|
* URL path, as well as possibly some arbitrary state and a key.
|
|
45
45
|
*/
|
|
46
|
-
export interface Location<
|
|
46
|
+
export interface Location<State = any> extends Path {
|
|
47
47
|
/**
|
|
48
48
|
* A value of arbitrary data associated with this location.
|
|
49
49
|
*/
|
|
50
|
-
state:
|
|
50
|
+
state: State;
|
|
51
51
|
/**
|
|
52
52
|
* A unique string associated with this location. May be used to safely store
|
|
53
53
|
* and retrieve data in some other storage API, like `localStorage`.
|
|
@@ -81,8 +81,8 @@ export interface Listener {
|
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Describes a location that is the destination of some navigation, either via
|
|
84
|
-
* `history.push` or `history.replace`.
|
|
85
|
-
* URL path.
|
|
84
|
+
* `history.push` or `history.replace`. This may be either a URL or the pieces
|
|
85
|
+
* of a URL path.
|
|
86
86
|
*/
|
|
87
87
|
export type To = string | Partial<Path>;
|
|
88
88
|
/**
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.9.0
|
|
2
|
+
* @remix-run/router v1.9.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -59,8 +59,8 @@ let Action = /*#__PURE__*/function (Action) {
|
|
|
59
59
|
*/
|
|
60
60
|
/**
|
|
61
61
|
* Describes a location that is the destination of some navigation, either via
|
|
62
|
-
* `history.push` or `history.replace`.
|
|
63
|
-
* URL path.
|
|
62
|
+
* `history.push` or `history.replace`. This may be either a URL or the pieces
|
|
63
|
+
* of a URL path.
|
|
64
64
|
*/
|
|
65
65
|
/**
|
|
66
66
|
* A history is an interface to the navigation stack. The history serves as the
|
|
@@ -322,7 +322,7 @@ function warning(cond, message) {
|
|
|
322
322
|
try {
|
|
323
323
|
// Welcome to debugging history!
|
|
324
324
|
//
|
|
325
|
-
// This error is thrown as a convenience so you can more easily
|
|
325
|
+
// This error is thrown as a convenience, so you can more easily
|
|
326
326
|
// find the source for a warning that appears in the console by
|
|
327
327
|
// enabling "pause on exceptions" in your JavaScript debugger.
|
|
328
328
|
throw new Error(message);
|
|
@@ -604,6 +604,7 @@ let ResultType = /*#__PURE__*/function (ResultType) {
|
|
|
604
604
|
|
|
605
605
|
// TODO: (v7) Change the defaults from any to unknown in and remove Remix wrappers:
|
|
606
606
|
// ActionFunction, ActionFunctionArgs, LoaderFunction, LoaderFunctionArgs
|
|
607
|
+
// Also, make them a type alias instead of an interface
|
|
607
608
|
/**
|
|
608
609
|
* Arguments passed to loader functions
|
|
609
610
|
*/
|
|
@@ -687,7 +688,7 @@ const immutableRouteKeys = new Set(["lazy", "caseSensitive", "path", "id", "inde
|
|
|
687
688
|
*/
|
|
688
689
|
|
|
689
690
|
// Attempt to parse the given string segment. If it fails, then just return the
|
|
690
|
-
// plain string type as a default fallback. Otherwise return the union of the
|
|
691
|
+
// plain string type as a default fallback. Otherwise, return the union of the
|
|
691
692
|
// parsed string literals that were referenced as dynamic segments in the route.
|
|
692
693
|
/**
|
|
693
694
|
* The parameters that were parsed from the URL path.
|
|
@@ -699,7 +700,7 @@ function isIndexRoute(route) {
|
|
|
699
700
|
return route.index === true;
|
|
700
701
|
}
|
|
701
702
|
|
|
702
|
-
// Walk the route tree generating unique IDs where necessary so we are working
|
|
703
|
+
// Walk the route tree generating unique IDs where necessary, so we are working
|
|
703
704
|
// solely with AgnosticDataRouteObject's within the Router
|
|
704
705
|
function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath, manifest) {
|
|
705
706
|
if (parentPath === void 0) {
|
|
@@ -800,7 +801,7 @@ function flattenRoutes(routes, branches, parentsMeta, parentPath) {
|
|
|
800
801
|
let path = joinPaths([parentPath, meta.relativePath]);
|
|
801
802
|
let routesMeta = parentsMeta.concat(meta);
|
|
802
803
|
|
|
803
|
-
// Add the children before adding this route to the array so we traverse the
|
|
804
|
+
// Add the children before adding this route to the array, so we traverse the
|
|
804
805
|
// route tree depth-first and child routes appear before their parents in
|
|
805
806
|
// the "flattened" version.
|
|
806
807
|
if (route.children && route.children.length > 0) {
|
|
@@ -868,15 +869,15 @@ function explodeOptionalSegments(path) {
|
|
|
868
869
|
let result = [];
|
|
869
870
|
|
|
870
871
|
// All child paths with the prefix. Do this for all children before the
|
|
871
|
-
// optional version for all children so we get consistent ordering where the
|
|
872
|
+
// optional version for all children, so we get consistent ordering where the
|
|
872
873
|
// parent optional aspect is preferred as required. Otherwise, we can get
|
|
873
874
|
// child sections interspersed where deeper optional segments are higher than
|
|
874
|
-
// parent optional segments, where for example, /:two would
|
|
875
|
+
// parent optional segments, where for example, /:two would explode _earlier_
|
|
875
876
|
// then /:one. By always including the parent as required _for all children_
|
|
876
877
|
// first, we avoid this issue
|
|
877
878
|
result.push(...restExploded.map(subpath => subpath === "" ? required : [required, subpath].join("/")));
|
|
878
879
|
|
|
879
|
-
// Then if this is an optional value, add all child versions without
|
|
880
|
+
// Then, if this is an optional value, add all child versions without
|
|
880
881
|
if (isOptional) {
|
|
881
882
|
result.push(...restExploded);
|
|
882
883
|
}
|
|
@@ -1064,7 +1065,7 @@ function compilePath(path, caseSensitive, end) {
|
|
|
1064
1065
|
regexpSource += "\\/*$";
|
|
1065
1066
|
} else if (path !== "" && path !== "/") {
|
|
1066
1067
|
// If our path is non-empty and contains anything beyond an initial slash,
|
|
1067
|
-
// then we have _some_ form of path in our regex so we should expect to
|
|
1068
|
+
// then we have _some_ form of path in our regex, so we should expect to
|
|
1068
1069
|
// match only if we find the end of this path segment. Look for an optional
|
|
1069
1070
|
// non-captured trailing slash (to match a portion of the URL) or the end
|
|
1070
1071
|
// of the path (if we've matched to the end). We used to do this with a
|