@remix-run/router 1.9.0-pre.0 → 1.9.0-pre.2
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 +16 -0
- package/dist/history.d.ts +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/router.cjs.js +32 -44
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -9
- package/dist/router.js +24 -26
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +32 -44
- 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 +16 -8
- package/history.ts +8 -5
- package/index.ts +2 -0
- package/package.json +1 -1
- package/router.ts +4 -27
- package/utils.ts +48 -16
package/dist/router.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { History, Location, Path, To } from "./history";
|
|
2
2
|
import { Action as HistoryAction } from "./history";
|
|
3
|
-
import type { AgnosticDataRouteMatch, AgnosticDataRouteObject,
|
|
3
|
+
import type { AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticRouteObject, DeferredData, DetectErrorBoundaryFunction, FormEncType, HTMLFormMethod, MapRoutePropertiesFunction, RouteData, Submission, UIMatch } from "./utils";
|
|
4
4
|
/**
|
|
5
5
|
* A Router instance manages all navigation and data loading/mutations
|
|
6
6
|
*/
|
|
@@ -293,19 +293,12 @@ export interface StaticHandler {
|
|
|
293
293
|
export interface RouterSubscriber {
|
|
294
294
|
(state: RouterState): void;
|
|
295
295
|
}
|
|
296
|
-
interface UseMatchesMatch {
|
|
297
|
-
id: string;
|
|
298
|
-
pathname: string;
|
|
299
|
-
params: AgnosticRouteMatch["params"];
|
|
300
|
-
data: unknown;
|
|
301
|
-
handle: unknown;
|
|
302
|
-
}
|
|
303
296
|
/**
|
|
304
297
|
* Function signature for determining the key to be used in scroll restoration
|
|
305
298
|
* for a given location
|
|
306
299
|
*/
|
|
307
300
|
export interface GetScrollRestorationKeyFunction {
|
|
308
|
-
(location: Location, matches:
|
|
301
|
+
(location: Location, matches: UIMatch[]): string | null;
|
|
309
302
|
}
|
|
310
303
|
/**
|
|
311
304
|
* Function signature for determining the current scroll position
|
package/dist/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.9.0-pre.
|
|
2
|
+
* @remix-run/router v1.9.0-pre.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -248,7 +248,7 @@ function warning(cond, message) {
|
|
|
248
248
|
try {
|
|
249
249
|
// Welcome to debugging history!
|
|
250
250
|
//
|
|
251
|
-
// This error is thrown as a convenience so you can more easily
|
|
251
|
+
// This error is thrown as a convenience, so you can more easily
|
|
252
252
|
// find the source for a warning that appears in the console by
|
|
253
253
|
// enabling "pause on exceptions" in your JavaScript debugger.
|
|
254
254
|
throw new Error(message);
|
|
@@ -472,7 +472,7 @@ const immutableRouteKeys = new Set(["lazy", "caseSensitive", "path", "id", "inde
|
|
|
472
472
|
function isIndexRoute(route) {
|
|
473
473
|
return route.index === true;
|
|
474
474
|
}
|
|
475
|
-
// Walk the route tree generating unique IDs where necessary so we are working
|
|
475
|
+
// Walk the route tree generating unique IDs where necessary, so we are working
|
|
476
476
|
// solely with AgnosticDataRouteObject's within the Router
|
|
477
477
|
function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath, manifest) {
|
|
478
478
|
if (parentPath === void 0) {
|
|
@@ -534,6 +534,20 @@ function matchRoutes(routes, locationArg, basename) {
|
|
|
534
534
|
}
|
|
535
535
|
return matches;
|
|
536
536
|
}
|
|
537
|
+
function convertRouteMatchToUiMatch(match, loaderData) {
|
|
538
|
+
let {
|
|
539
|
+
route,
|
|
540
|
+
pathname,
|
|
541
|
+
params
|
|
542
|
+
} = match;
|
|
543
|
+
return {
|
|
544
|
+
id: route.id,
|
|
545
|
+
pathname,
|
|
546
|
+
params,
|
|
547
|
+
data: loaderData[route.id],
|
|
548
|
+
handle: route.handle
|
|
549
|
+
};
|
|
550
|
+
}
|
|
537
551
|
function flattenRoutes(routes, branches, parentsMeta, parentPath) {
|
|
538
552
|
if (branches === void 0) {
|
|
539
553
|
branches = [];
|
|
@@ -557,7 +571,7 @@ function flattenRoutes(routes, branches, parentsMeta, parentPath) {
|
|
|
557
571
|
}
|
|
558
572
|
let path = joinPaths([parentPath, meta.relativePath]);
|
|
559
573
|
let routesMeta = parentsMeta.concat(meta);
|
|
560
|
-
// Add the children before adding this route to the array so we traverse the
|
|
574
|
+
// Add the children before adding this route to the array, so we traverse the
|
|
561
575
|
// route tree depth-first and child routes appear before their parents in
|
|
562
576
|
// the "flattened" version.
|
|
563
577
|
if (route.children && route.children.length > 0) {
|
|
@@ -621,14 +635,14 @@ function explodeOptionalSegments(path) {
|
|
|
621
635
|
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
622
636
|
let result = [];
|
|
623
637
|
// All child paths with the prefix. Do this for all children before the
|
|
624
|
-
// optional version for all children so we get consistent ordering where the
|
|
638
|
+
// optional version for all children, so we get consistent ordering where the
|
|
625
639
|
// parent optional aspect is preferred as required. Otherwise, we can get
|
|
626
640
|
// child sections interspersed where deeper optional segments are higher than
|
|
627
|
-
// parent optional segments, where for example, /:two would
|
|
641
|
+
// parent optional segments, where for example, /:two would explode _earlier_
|
|
628
642
|
// then /:one. By always including the parent as required _for all children_
|
|
629
643
|
// first, we avoid this issue
|
|
630
644
|
result.push(...restExploded.map(subpath => subpath === "" ? required : [required, subpath].join("/")));
|
|
631
|
-
// Then if this is an optional value, add all child versions without
|
|
645
|
+
// Then, if this is an optional value, add all child versions without
|
|
632
646
|
if (isOptional) {
|
|
633
647
|
result.push(...restExploded);
|
|
634
648
|
}
|
|
@@ -802,7 +816,7 @@ function compilePath(path, caseSensitive, end) {
|
|
|
802
816
|
regexpSource += "\\/*$";
|
|
803
817
|
} else if (path !== "" && path !== "/") {
|
|
804
818
|
// If our path is non-empty and contains anything beyond an initial slash,
|
|
805
|
-
// then we have _some_ form of path in our regex so we should expect to
|
|
819
|
+
// then we have _some_ form of path in our regex, so we should expect to
|
|
806
820
|
// match only if we find the end of this path segment. Look for an optional
|
|
807
821
|
// non-captured trailing slash (to match a portion of the URL) or the end
|
|
808
822
|
// of the path (if we've matched to the end). We used to do this with a
|
|
@@ -2524,7 +2538,7 @@ function createRouter(init) {
|
|
|
2524
2538
|
}
|
|
2525
2539
|
function getScrollKey(location, matches) {
|
|
2526
2540
|
if (getScrollRestorationKey) {
|
|
2527
|
-
let key = getScrollRestorationKey(location, matches.map(m =>
|
|
2541
|
+
let key = getScrollRestorationKey(location, matches.map(m => convertRouteMatchToUiMatch(m, state.loaderData)));
|
|
2528
2542
|
return key || location.key;
|
|
2529
2543
|
}
|
|
2530
2544
|
return location.key;
|
|
@@ -3875,22 +3889,6 @@ async function resolveDeferredData(result, signal, unwrap) {
|
|
|
3875
3889
|
function hasNakedIndexQuery(search) {
|
|
3876
3890
|
return new URLSearchParams(search).getAll("index").some(v => v === "");
|
|
3877
3891
|
}
|
|
3878
|
-
// Note: This should match the format exported by useMatches, so if you change
|
|
3879
|
-
// this please also change that :) Eventually we'll DRY this up
|
|
3880
|
-
function createUseMatchesMatch(match, loaderData) {
|
|
3881
|
-
let {
|
|
3882
|
-
route,
|
|
3883
|
-
pathname,
|
|
3884
|
-
params
|
|
3885
|
-
} = match;
|
|
3886
|
-
return {
|
|
3887
|
-
id: route.id,
|
|
3888
|
-
pathname,
|
|
3889
|
-
params,
|
|
3890
|
-
data: loaderData[route.id],
|
|
3891
|
-
handle: route.handle
|
|
3892
|
-
};
|
|
3893
|
-
}
|
|
3894
3892
|
function getTargetMatch(matches, location) {
|
|
3895
3893
|
let search = typeof location === "string" ? parsePath(location).search : location.search;
|
|
3896
3894
|
if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
|
|
@@ -4038,5 +4036,5 @@ function getDoneFetcher(data) {
|
|
|
4038
4036
|
}
|
|
4039
4037
|
//#endregion
|
|
4040
4038
|
|
|
4041
|
-
export { AbortedDeferredError, Action, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, UNSAFE_DEFERRED_SYMBOL, DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, getPathContributingMatches as UNSAFE_getPathContributingMatches, invariant as UNSAFE_invariant, warning as UNSAFE_warning, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, createRouter, createStaticHandler, defer, generatePath, getStaticContextFromError, getToPathname, isDeferredData, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, parsePath, redirect, redirectDocument, resolvePath, resolveTo, stripBasename };
|
|
4039
|
+
export { AbortedDeferredError, Action, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, UNSAFE_DEFERRED_SYMBOL, DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, getPathContributingMatches as UNSAFE_getPathContributingMatches, invariant as UNSAFE_invariant, warning as UNSAFE_warning, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, createRouter, createStaticHandler, defer, generatePath, getStaticContextFromError, getToPathname, isDeferredData, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, parsePath, redirect, redirectDocument, resolvePath, resolveTo, stripBasename };
|
|
4042
4040
|
//# sourceMappingURL=router.js.map
|