@tanstack/react-query-devtools 4.24.13 → 5.0.0-alpha.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.
Files changed (86) hide show
  1. package/build/lib/Explorer.d.ts +4 -4
  2. package/build/lib/Explorer.esm.js +5 -15
  3. package/build/lib/Explorer.esm.js.map +1 -1
  4. package/build/lib/Explorer.js +11 -25
  5. package/build/lib/Explorer.js.map +1 -1
  6. package/build/lib/Explorer.mjs +5 -15
  7. package/build/lib/Explorer.mjs.map +1 -1
  8. package/build/lib/Logo.d.ts +0 -1
  9. package/build/lib/Logo.esm.js.map +1 -1
  10. package/build/lib/Logo.js +5 -6
  11. package/build/lib/Logo.js.map +1 -1
  12. package/build/lib/Logo.mjs.map +1 -1
  13. package/build/lib/__tests__/devtools.test.d.ts +0 -5
  14. package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +0 -2
  15. package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -1
  16. package/build/lib/_virtual/_rollupPluginBabelHelpers.js +1 -5
  17. package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  18. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +0 -2
  19. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -1
  20. package/build/lib/devtools.d.ts +12 -4
  21. package/build/lib/devtools.esm.js +72 -107
  22. package/build/lib/devtools.esm.js.map +1 -1
  23. package/build/lib/devtools.js +94 -132
  24. package/build/lib/devtools.js.map +1 -1
  25. package/build/lib/devtools.mjs +72 -107
  26. package/build/lib/devtools.mjs.map +1 -1
  27. package/build/lib/index.d.ts +2 -2
  28. package/build/lib/index.esm.js.map +1 -1
  29. package/build/lib/index.js +0 -2
  30. package/build/lib/index.js.map +1 -1
  31. package/build/lib/index.mjs.map +1 -1
  32. package/build/lib/index.prod.d.ts +2 -2
  33. package/build/lib/index.prod.esm.js +120 -175
  34. package/build/lib/index.prod.esm.js.map +1 -1
  35. package/build/lib/index.prod.js +125 -186
  36. package/build/lib/index.prod.js.map +1 -1
  37. package/build/lib/index.prod.mjs +120 -175
  38. package/build/lib/index.prod.mjs.map +1 -1
  39. package/build/lib/screenreader.d.ts +0 -1
  40. package/build/lib/screenreader.esm.js.map +1 -1
  41. package/build/lib/screenreader.js +4 -5
  42. package/build/lib/screenreader.js.map +1 -1
  43. package/build/lib/screenreader.mjs.map +1 -1
  44. package/build/lib/styledComponents.esm.js +17 -16
  45. package/build/lib/styledComponents.esm.js.map +1 -1
  46. package/build/lib/styledComponents.js +17 -18
  47. package/build/lib/styledComponents.js.map +1 -1
  48. package/build/lib/styledComponents.mjs +17 -16
  49. package/build/lib/styledComponents.mjs.map +1 -1
  50. package/build/lib/theme.esm.js.map +1 -1
  51. package/build/lib/theme.js +4 -7
  52. package/build/lib/theme.js.map +1 -1
  53. package/build/lib/theme.mjs.map +1 -1
  54. package/build/lib/useLocalStorage.esm.js +0 -7
  55. package/build/lib/useLocalStorage.esm.js.map +1 -1
  56. package/build/lib/useLocalStorage.js +4 -12
  57. package/build/lib/useLocalStorage.js.map +1 -1
  58. package/build/lib/useLocalStorage.mjs +0 -7
  59. package/build/lib/useLocalStorage.mjs.map +1 -1
  60. package/build/lib/useMediaQuery.esm.js +6 -6
  61. package/build/lib/useMediaQuery.esm.js.map +1 -1
  62. package/build/lib/useMediaQuery.js +10 -11
  63. package/build/lib/useMediaQuery.js.map +1 -1
  64. package/build/lib/useMediaQuery.mjs +6 -6
  65. package/build/lib/useMediaQuery.mjs.map +1 -1
  66. package/build/lib/utils.esm.js +20 -22
  67. package/build/lib/utils.esm.js.map +1 -1
  68. package/build/lib/utils.js +24 -32
  69. package/build/lib/utils.js.map +1 -1
  70. package/build/lib/utils.mjs +20 -22
  71. package/build/lib/utils.mjs.map +1 -1
  72. package/build/umd/index.development.js +123 -438
  73. package/build/umd/index.development.js.map +1 -1
  74. package/build/umd/index.production.js +1 -1
  75. package/build/umd/index.production.js.map +1 -1
  76. package/package.json +6 -10
  77. package/src/Explorer.tsx +4 -4
  78. package/src/__tests__/Explorer.test.tsx +5 -0
  79. package/src/__tests__/devtools.test.tsx +127 -181
  80. package/src/__tests__/utils.tsx +2 -2
  81. package/src/devtools.tsx +23 -17
  82. package/src/index.ts +2 -2
  83. package/build/lib/useSyncExternalStore.d.ts +0 -1
  84. package/build/lib/useSyncExternalStore.native.d.ts +0 -1
  85. package/src/useSyncExternalStore.native.ts +0 -3
  86. package/src/useSyncExternalStore.ts +0 -2
package/src/devtools.tsx CHANGED
@@ -1,11 +1,9 @@
1
1
  'use client'
2
2
  import * as React from 'react'
3
- import { useSyncExternalStore } from './useSyncExternalStore'
4
3
  import type {
5
4
  QueryCache,
6
5
  QueryClient,
7
6
  QueryKey as QueryKeyType,
8
- ContextOptions,
9
7
  } from '@tanstack/react-query'
10
8
  import {
11
9
  useQueryClient,
@@ -42,7 +40,7 @@ import { getQueryStatusLabel, getQueryStatusColor } from './utils'
42
40
  import Explorer from './Explorer'
43
41
  import Logo from './Logo'
44
42
 
45
- export interface DevtoolsOptions extends ContextOptions {
43
+ export interface DevtoolsOptions {
46
44
  /**
47
45
  * Set this true if you want the dev tools to default to being open
48
46
  */
@@ -79,9 +77,13 @@ export interface DevtoolsOptions extends ContextOptions {
79
77
  * nonce for style element for CSP
80
78
  */
81
79
  styleNonce?: string
80
+ /**
81
+ * Custom instance of QueryClient
82
+ */
83
+ queryClient?: QueryClient
82
84
  }
83
85
 
84
- interface DevtoolsPanelOptions extends ContextOptions {
86
+ interface DevtoolsPanelOptions {
85
87
  /**
86
88
  * The standard React style object used to style a component with inline styles
87
89
  */
@@ -123,6 +125,10 @@ interface DevtoolsPanelOptions extends ContextOptions {
123
125
  * Use this to add props to the close button. For example, you can add className, style (merge and override default style), onClick (extend default handler), etc.
124
126
  */
125
127
  closeButtonProps?: React.ComponentPropsWithoutRef<'button'>
128
+ /**
129
+ * Custom instance of QueryClient
130
+ */
131
+ queryClient?: QueryClient
126
132
  }
127
133
 
128
134
  export function ReactQueryDevtools({
@@ -132,7 +138,7 @@ export function ReactQueryDevtools({
132
138
  toggleButtonProps = {},
133
139
  position = 'bottom-left',
134
140
  containerElement: Container = 'aside',
135
- context,
141
+ queryClient,
136
142
  styleNonce,
137
143
  panelPosition: initialPanelPosition = 'bottom',
138
144
  }: DevtoolsOptions): React.ReactElement | null {
@@ -332,7 +338,7 @@ export function ReactQueryDevtools({
332
338
  <ThemeProvider theme={theme}>
333
339
  <ReactQueryDevtoolsPanel
334
340
  ref={panelRef as any}
335
- context={context}
341
+ queryClient={queryClient}
336
342
  styleNonce={styleNonce}
337
343
  position={panelPosition}
338
344
  onPositionChange={setPanelPosition}
@@ -403,7 +409,7 @@ const useSubscribeToQueryCache = <T,>(
403
409
  getSnapshot: () => T,
404
410
  skip: boolean = false,
405
411
  ): T => {
406
- return useSyncExternalStore(
412
+ return React.useSyncExternalStore(
407
413
  React.useCallback(
408
414
  (onStoreChange) => {
409
415
  if (!skip)
@@ -427,7 +433,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
427
433
  isOpen = true,
428
434
  styleNonce,
429
435
  setIsOpen,
430
- context,
436
+ queryClient,
431
437
  onDragStart,
432
438
  onPositionChange,
433
439
  showCloseButton,
@@ -438,8 +444,8 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
438
444
 
439
445
  const { onClick: onCloseClick, ...otherCloseButtonProps } = closeButtonProps
440
446
 
441
- const queryClient = useQueryClient({ context })
442
- const queryCache = queryClient.getQueryCache()
447
+ const client = useQueryClient(queryClient)
448
+ const queryCache = client.getQueryCache()
443
449
 
444
450
  const [sort, setSort] = useLocalStorage(
445
451
  'reactQueryDevtoolsSortFn',
@@ -737,7 +743,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
737
743
  <ActiveQuery
738
744
  activeQueryHash={activeQueryHash}
739
745
  queryCache={queryCache}
740
- queryClient={queryClient}
746
+ queryClient={client}
741
747
  />
742
748
  ) : null}
743
749
 
@@ -836,7 +842,7 @@ const ActiveQuery = ({
836
842
  style={{
837
843
  marginBottom: '.5em',
838
844
  display: 'flex',
839
- alignItems: 'flex-start',
845
+ alignItems: 'stretch',
840
846
  justifyContent: 'space-between',
841
847
  }}
842
848
  >
@@ -1098,27 +1104,27 @@ const QueryRow = React.memo(
1098
1104
  const queryHash =
1099
1105
  useSubscribeToQueryCache(
1100
1106
  queryCache,
1101
- () => queryCache.find(queryKey)?.queryHash,
1107
+ () => queryCache.find({ queryKey })?.queryHash,
1102
1108
  ) ?? ''
1103
1109
 
1104
1110
  const queryState = useSubscribeToQueryCache(
1105
1111
  queryCache,
1106
- () => queryCache.find(queryKey)?.state,
1112
+ () => queryCache.find({ queryKey })?.state,
1107
1113
  )
1108
1114
 
1109
1115
  const isStale =
1110
1116
  useSubscribeToQueryCache(queryCache, () =>
1111
- queryCache.find(queryKey)?.isStale(),
1117
+ queryCache.find({ queryKey })?.isStale(),
1112
1118
  ) ?? false
1113
1119
 
1114
1120
  const isDisabled =
1115
1121
  useSubscribeToQueryCache(queryCache, () =>
1116
- queryCache.find(queryKey)?.isDisabled(),
1122
+ queryCache.find({ queryKey })?.isDisabled(),
1117
1123
  ) ?? false
1118
1124
 
1119
1125
  const observerCount =
1120
1126
  useSubscribeToQueryCache(queryCache, () =>
1121
- queryCache.find(queryKey)?.getObserversCount(),
1127
+ queryCache.find({ queryKey })?.getObserversCount(),
1122
1128
  ) ?? 0
1123
1129
 
1124
1130
  if (!queryState) {
package/src/index.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as devtools from './devtools'
2
2
 
3
- export const ReactQueryDevtools: typeof devtools['ReactQueryDevtools'] =
3
+ export const ReactQueryDevtools: (typeof devtools)['ReactQueryDevtools'] =
4
4
  process.env.NODE_ENV !== 'development'
5
5
  ? function () {
6
6
  return null
7
7
  }
8
8
  : devtools.ReactQueryDevtools
9
9
 
10
- export const ReactQueryDevtoolsPanel: typeof devtools['ReactQueryDevtoolsPanel'] =
10
+ export const ReactQueryDevtoolsPanel: (typeof devtools)['ReactQueryDevtoolsPanel'] =
11
11
  process.env.NODE_ENV !== 'development'
12
12
  ? (function () {
13
13
  return null
@@ -1 +0,0 @@
1
- export { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
@@ -1 +0,0 @@
1
- export { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js';
@@ -1,3 +0,0 @@
1
- // Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
2
- // @ts-ignore
3
- export { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js'
@@ -1,2 +0,0 @@
1
- // Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
2
- export { useSyncExternalStore } from 'use-sync-external-store/shim/index.js'