@tanstack/router-core 0.0.1-beta.172 → 0.0.1-beta.174

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.172",
4
+ "version": "0.0.1-beta.174",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -43,7 +43,7 @@
43
43
  "tiny-invariant": "^1.3.1",
44
44
  "tiny-warning": "^1.0.3",
45
45
  "@gisatcz/cross-package-react-context": "^0.2.0",
46
- "@tanstack/react-store": "0.0.1-beta.172"
46
+ "@tanstack/react-store": "0.0.1-beta.174"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "rollup --config rollup.config.js",
package/src/router.ts CHANGED
@@ -37,6 +37,7 @@ import {
37
37
  FullSearchSchema,
38
38
  RouteById,
39
39
  RoutePaths,
40
+ RouteIds,
40
41
  } from './routeInfo'
41
42
  import { defaultParseSearch, defaultStringifySearch } from './searchParams'
42
43
  import {
@@ -108,13 +109,13 @@ export type HydrationCtx = {
108
109
 
109
110
  export interface RouteMatch<
110
111
  TRouteTree extends AnyRoute = AnyRoute,
111
- TRoute extends AnyRoute = AnyRoute,
112
+ TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],
112
113
  > {
113
114
  id: string
114
115
  key?: string
115
- routeId: string
116
+ routeId: TRouteId
116
117
  pathname: string
117
- params: TRoute['types']['allParams']
118
+ params: RouteById<TRouteTree, TRouteId>['types']['allParams']
118
119
  status: 'pending' | 'success' | 'error'
119
120
  isFetching: boolean
120
121
  invalid: boolean
@@ -124,18 +125,19 @@ export interface RouteMatch<
124
125
  updatedAt: number
125
126
  invalidAt: number
126
127
  preloadInvalidAt: number
127
- loaderData: TRoute['types']['loader']
128
+ loaderData: RouteById<TRouteTree, TRouteId>['types']['loader']
128
129
  loadPromise?: Promise<void>
129
130
  __resolveLoadPromise?: () => void
130
- routeContext: TRoute['types']['routeContext']
131
- context: TRoute['types']['context']
132
- routeSearch: TRoute['types']['searchSchema']
133
- search: FullSearchSchema<TRouteTree> & TRoute['types']['fullSearchSchema']
131
+ routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']
132
+ context: RouteById<TRouteTree, TRouteId>['types']['context']
133
+ routeSearch: RouteById<TRouteTree, TRouteId>['types']['searchSchema']
134
+ search: FullSearchSchema<TRouteTree> &
135
+ RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema']
134
136
  fetchedAt: number
135
137
  abortController: AbortController
136
138
  }
137
139
 
138
- export type AnyRouteMatch = RouteMatch<AnyRoute, AnyRoute>
140
+ export type AnyRouteMatch = RouteMatch<any>
139
141
 
140
142
  export type RouterContextOptions<TRouteTree extends AnyRoute> =
141
143
  AnyContext extends TRouteTree['types']['routerContext']
@@ -196,11 +198,11 @@ export interface RouterState<
196
198
  > {
197
199
  status: 'idle' | 'pending'
198
200
  isFetching: boolean
199
- matchesById: Record<string, RouteMatch<TRouteTree, ParseRoute<TRouteTree>>>
201
+ matchesById: Record<string, RouteMatch<TRouteTree>>
200
202
  matchIds: string[]
201
203
  pendingMatchIds: string[]
202
- matches: RouteMatch<TRouteTree, ParseRoute<TRouteTree>>[]
203
- pendingMatches: RouteMatch<TRouteTree, ParseRoute<TRouteTree>>[]
204
+ matches: RouteMatch<TRouteTree>[]
205
+ pendingMatches: RouteMatch<TRouteTree>[]
204
206
  location: ParsedLocation<FullSearchSchema<TRouteTree>>
205
207
  resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>
206
208
  lastUpdated: number
@@ -607,12 +609,9 @@ export class Router<
607
609
  }
608
610
 
609
611
  #mergeMatches = (
610
- prevMatchesById: Record<
611
- string,
612
- RouteMatch<TRouteTree, ParseRoute<TRouteTree>>
613
- >,
612
+ prevMatchesById: Record<string, RouteMatch<TRouteTree>>,
614
613
  nextMatches: AnyRouteMatch[],
615
- ): Record<string, RouteMatch<TRouteTree, ParseRoute<TRouteTree>>> => {
614
+ ): Record<string, RouteMatch<TRouteTree>> => {
616
615
  const nextMatchesById: any = {
617
616
  ...prevMatchesById,
618
617
  }
@@ -701,7 +700,7 @@ export class Router<
701
700
  pathname: string,
702
701
  locationSearch: AnySearchSchema,
703
702
  opts?: { throwOnError?: boolean; debug?: boolean },
704
- ): RouteMatch<TRouteTree, ParseRoute<TRouteTree>>[] => {
703
+ ): RouteMatch<TRouteTree>[] => {
705
704
  let routeParams: AnyPathParams = {}
706
705
 
707
706
  let foundRoute = this.flatRoutes.find((route) => {
@@ -1715,17 +1714,13 @@ export class Router<
1715
1714
  return this.latestLoadPromise
1716
1715
  }
1717
1716
 
1718
- getRouteMatch = (
1719
- id: string,
1720
- ): undefined | RouteMatch<TRouteTree, AnyRoute> => {
1717
+ getRouteMatch = (id: string): undefined | RouteMatch<TRouteTree> => {
1721
1718
  return this.state.matchesById[id]
1722
1719
  }
1723
1720
 
1724
1721
  setRouteMatch = (
1725
1722
  id: string,
1726
- updater: (
1727
- prev: RouteMatch<TRouteTree, AnyRoute>,
1728
- ) => RouteMatch<TRouteTree, AnyRoute>,
1723
+ updater: (prev: RouteMatch<TRouteTree>) => RouteMatch<TRouteTree>,
1729
1724
  ) => {
1730
1725
  this.__store.setState((prev) => {
1731
1726
  if (!prev.matchesById[id]) {