@tanstack/react-router-devtools 0.0.1-beta.60 → 0.0.1-beta.62

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/react-router-devtools",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.60",
4
+ "version": "0.0.1-beta.62",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router/",
@@ -42,6 +42,6 @@
42
42
  "dependencies": {
43
43
  "@babel/runtime": "^7.16.7",
44
44
  "date-fns": "^2.29.1",
45
- "@tanstack/react-router": "0.0.1-beta.60"
45
+ "@tanstack/react-router": "0.0.1-beta.62"
46
46
  }
47
47
  }
package/src/devtools.tsx CHANGED
@@ -4,7 +4,8 @@ import {
4
4
  last,
5
5
  routerContext,
6
6
  invariant,
7
- useRouterStore,
7
+ useRouter,
8
+ AnyRouter,
8
9
  } from '@tanstack/react-router'
9
10
  import { formatDistanceStrict } from 'date-fns'
10
11
 
@@ -62,7 +63,7 @@ interface DevtoolsOptions {
62
63
  /**
63
64
  * A boolean variable indicating if the "lite" version of the library is being used
64
65
  */
65
- router?: Router<any, any, any>
66
+ router?: AnyRouter
66
67
  }
67
68
 
68
69
  interface DevtoolsPanelOptions {
@@ -89,7 +90,7 @@ interface DevtoolsPanelOptions {
89
90
  /**
90
91
  * A boolean variable indicating if the "lite" version of the library is being used
91
92
  */
92
- router?: Router<any, any, any>
93
+ router?: AnyRouter
93
94
  }
94
95
 
95
96
  const isServer = typeof window === 'undefined'
@@ -424,7 +425,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
424
425
  'No router was found for the TanStack Router Devtools. Please place the devtools in the <RouterProvider> component tree or pass the router instance to the devtools manually.',
425
426
  )
426
427
 
427
- useRouterStore()
428
+ useRouter()
428
429
 
429
430
  const [activeRouteId, setActiveRouteId] = useLocalStorage(
430
431
  'tanstackRouterDevtoolsActiveRouteId',
@@ -442,10 +443,10 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
442
443
 
443
444
  const allMatches = React.useMemo(
444
445
  () => [
445
- ...Object.values(router.store.state.currentMatches),
446
- ...Object.values(router.store.state.pendingMatches ?? []),
446
+ ...Object.values(router.state.currentMatches),
447
+ ...Object.values(router.state.pendingMatches ?? []),
447
448
  ],
448
- [router.store.state.currentMatches, router.store.state.pendingMatches],
449
+ [router.state.currentMatches, router.state.pendingMatches],
449
450
  )
450
451
 
451
452
  const activeMatch =
@@ -453,15 +454,15 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
453
454
  allMatches?.find((d) => d.route.id === activeRouteId)
454
455
 
455
456
  // const matchCacheValues = multiSortBy(
456
- // Object.keys(router.store.state.matchCache)
457
+ // Object.keys(router.state.matchCache)
457
458
  // .filter((key) => {
458
- // const cacheEntry = router.store.state.matchCache[key]!
459
+ // const cacheEntry = router.state.matchCache[key]!
459
460
  // return cacheEntry.gc > Date.now()
460
461
  // })
461
- // .map((key) => router.store.state.matchCache[key]!),
462
+ // .map((key) => router.state.matchCache[key]!),
462
463
  // [
463
- // (d) => (d.match.store.state.isFetching ? -1 : 1),
464
- // (d) => -d.match.store.state.updatedAt!,
464
+ // (d) => (d.match.state.isFetching ? -1 : 1),
465
+ // (d) => -d.match.state.updatedAt!,
465
466
  // ],
466
467
  // )
467
468
 
@@ -602,7 +603,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
602
603
  >
603
604
  Active Matches
604
605
  </div>
605
- {router.store.state.currentMatches.map((match, i) => {
606
+ {router.state.currentMatches.map((match, i) => {
606
607
  return (
607
608
  <div
608
609
  key={match.route.id || i}
@@ -647,7 +648,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
647
648
  </div>
648
649
  )
649
650
  })}
650
- {router.store.state.pendingMatches?.length ? (
651
+ {router.state.pendingMatches?.length ? (
651
652
  <>
652
653
  <div
653
654
  style={{
@@ -661,7 +662,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
661
662
  >
662
663
  Pending Matches
663
664
  </div>
664
- {router.store.state.pendingMatches?.map((match, i) => {
665
+ {router.state.pendingMatches?.map((match, i) => {
665
666
  return (
666
667
  <div
667
668
  key={match.route.id || i}
@@ -838,7 +839,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
838
839
  </tr>
839
840
  <tr>
840
841
  <td style={{ opacity: '.5' }}>Status</td>
841
- <td>{activeMatch.store.state.status}</td>
842
+ <td>{activeMatch.state.status}</td>
842
843
  </tr>
843
844
  {/* <tr>
844
845
  <td style={{ opacity: '.5' }}>Invalid</td>
@@ -847,9 +848,9 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
847
848
  <tr>
848
849
  <td style={{ opacity: '.5' }}>Last Updated</td>
849
850
  <td>
850
- {activeMatch.store.state.updatedAt
851
+ {activeMatch.state.updatedAt
851
852
  ? new Date(
852
- activeMatch.store.state.updatedAt as number,
853
+ activeMatch.state.updatedAt as number,
853
854
  ).toLocaleTimeString()
854
855
  : 'N/A'}
855
856
  </td>
@@ -938,16 +939,16 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
938
939
  }}
939
940
  >
940
941
  {Object.keys(
941
- last(router.store.state.currentMatches)?.store.state.loaderData ||
942
+ last(router.state.currentMatches)?.state.loaderData ||
942
943
  {},
943
944
  ).length ? (
944
945
  <Explorer
945
946
  value={
946
- last(router.store.state.currentMatches)?.store.state
947
+ last(router.state.currentMatches)?.state
947
948
  .loaderData || {}
948
949
  }
949
950
  defaultExpanded={Object.keys(
950
- (last(router.store.state.currentMatches)?.store.state
951
+ (last(router.state.currentMatches)?.state
951
952
  .loaderData as {}) || {},
952
953
  ).reduce((obj: any, next) => {
953
954
  obj[next] = {}
@@ -975,17 +976,12 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
975
976
  padding: '.5em',
976
977
  }}
977
978
  >
978
- {Object.keys(
979
- last(router.store.state.currentMatches)?.store.state.search || {},
980
- ).length ? (
979
+ {Object.keys(last(router.state.currentMatches)?.state.search || {})
980
+ .length ? (
981
981
  <Explorer
982
- value={
983
- last(router.store.state.currentMatches)?.store.state.search ||
984
- {}
985
- }
982
+ value={last(router.state.currentMatches)?.state.search || {}}
986
983
  defaultExpanded={Object.keys(
987
- (last(router.store.state.currentMatches)?.store.state
988
- .search as {}) || {},
984
+ (last(router.state.currentMatches)?.state.search as {}) || {},
989
985
  ).reduce((obj: any, next) => {
990
986
  obj[next] = {}
991
987
  return obj
package/src/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { RouteMatch } from '@tanstack/react-router'
2
+ import { AnyRouteMatch, RouteMatch } from '@tanstack/react-router'
3
3
 
4
4
  import { Theme, useTheme } from './theme'
5
5
  import useMediaQuery from './useMediaQuery'
@@ -25,12 +25,12 @@ type StyledComponent<T> = T extends 'button'
25
25
  ? React.HTMLAttributes<HTMLElementTagNameMap[T]>
26
26
  : never
27
27
 
28
- export function getStatusColor(match: RouteMatch, theme: Theme) {
29
- return match.store.state.status === 'pending'
28
+ export function getStatusColor(match: AnyRouteMatch, theme: Theme) {
29
+ return match.state.status === 'pending'
30
30
  ? theme.active
31
- : match.store.state.status === 'error'
31
+ : match.state.status === 'error'
32
32
  ? theme.danger
33
- : match.store.state.status === 'success'
33
+ : match.state.status === 'success'
34
34
  ? theme.success
35
35
  : theme.gray
36
36
  }