@remix-run/router 1.9.0-pre.0 → 1.9.0-pre.1

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/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, AgnosticRouteMatch, AgnosticRouteObject, DeferredData, DetectErrorBoundaryFunction, FormEncType, HTMLFormMethod, MapRoutePropertiesFunction, RouteData, Submission } from "./utils";
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: UseMatchesMatch[]): string | null;
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.0
2
+ * @remix-run/router v1.9.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -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 = [];
@@ -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 => createUseMatchesMatch(m, state.loaderData)));
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