@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.
- package/build/lib/Explorer.d.ts +4 -4
- package/build/lib/Explorer.esm.js +5 -15
- package/build/lib/Explorer.esm.js.map +1 -1
- package/build/lib/Explorer.js +11 -25
- package/build/lib/Explorer.js.map +1 -1
- package/build/lib/Explorer.mjs +5 -15
- package/build/lib/Explorer.mjs.map +1 -1
- package/build/lib/Logo.d.ts +0 -1
- package/build/lib/Logo.esm.js.map +1 -1
- package/build/lib/Logo.js +5 -6
- package/build/lib/Logo.js.map +1 -1
- package/build/lib/Logo.mjs.map +1 -1
- package/build/lib/__tests__/devtools.test.d.ts +0 -5
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +0 -2
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +1 -5
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +0 -2
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -1
- package/build/lib/devtools.d.ts +12 -4
- package/build/lib/devtools.esm.js +72 -107
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +94 -132
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +72 -107
- package/build/lib/devtools.mjs.map +1 -1
- package/build/lib/index.d.ts +2 -2
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +0 -2
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/index.prod.d.ts +2 -2
- package/build/lib/index.prod.esm.js +120 -175
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +125 -186
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +120 -175
- package/build/lib/index.prod.mjs.map +1 -1
- package/build/lib/screenreader.d.ts +0 -1
- package/build/lib/screenreader.esm.js.map +1 -1
- package/build/lib/screenreader.js +4 -5
- package/build/lib/screenreader.js.map +1 -1
- package/build/lib/screenreader.mjs.map +1 -1
- package/build/lib/styledComponents.esm.js +17 -16
- package/build/lib/styledComponents.esm.js.map +1 -1
- package/build/lib/styledComponents.js +17 -18
- package/build/lib/styledComponents.js.map +1 -1
- package/build/lib/styledComponents.mjs +17 -16
- package/build/lib/styledComponents.mjs.map +1 -1
- package/build/lib/theme.esm.js.map +1 -1
- package/build/lib/theme.js +4 -7
- package/build/lib/theme.js.map +1 -1
- package/build/lib/theme.mjs.map +1 -1
- package/build/lib/useLocalStorage.esm.js +0 -7
- package/build/lib/useLocalStorage.esm.js.map +1 -1
- package/build/lib/useLocalStorage.js +4 -12
- package/build/lib/useLocalStorage.js.map +1 -1
- package/build/lib/useLocalStorage.mjs +0 -7
- package/build/lib/useLocalStorage.mjs.map +1 -1
- package/build/lib/useMediaQuery.esm.js +6 -6
- package/build/lib/useMediaQuery.esm.js.map +1 -1
- package/build/lib/useMediaQuery.js +10 -11
- package/build/lib/useMediaQuery.js.map +1 -1
- package/build/lib/useMediaQuery.mjs +6 -6
- package/build/lib/useMediaQuery.mjs.map +1 -1
- package/build/lib/utils.esm.js +20 -22
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +24 -32
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +20 -22
- package/build/lib/utils.mjs.map +1 -1
- package/build/umd/index.development.js +123 -438
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +6 -10
- package/src/Explorer.tsx +4 -4
- package/src/__tests__/Explorer.test.tsx +5 -0
- package/src/__tests__/devtools.test.tsx +127 -181
- package/src/__tests__/utils.tsx +2 -2
- package/src/devtools.tsx +23 -17
- package/src/index.ts +2 -2
- package/build/lib/useSyncExternalStore.d.ts +0 -1
- package/build/lib/useSyncExternalStore.native.d.ts +0 -1
- package/src/useSyncExternalStore.native.ts +0 -3
- 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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
442
|
-
const queryCache =
|
|
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={
|
|
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: '
|
|
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';
|