@tanstack/react-query-devtools 4.24.10 → 5.0.0-alpha.0
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 +73 -108
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +95 -133
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +73 -108
- 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 +121 -176
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +126 -187
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +121 -176
- 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 +124 -439
- 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 +121 -175
- package/src/__tests__/utils.tsx +2 -2
- package/src/devtools.tsx +110 -116
- 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',
|
|
@@ -621,106 +627,94 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
|
|
|
621
627
|
width: '100%',
|
|
622
628
|
}}
|
|
623
629
|
/>
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
>
|
|
636
|
-
{
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
)}
|
|
713
|
-
</svg>
|
|
714
|
-
<ScreenReader
|
|
715
|
-
text={
|
|
716
|
-
isMockOffline
|
|
717
|
-
? 'Restore offline mock'
|
|
718
|
-
: 'Mock offline behavior'
|
|
719
|
-
}
|
|
720
|
-
/>
|
|
721
|
-
</Button>
|
|
722
|
-
</>
|
|
723
|
-
) : null}
|
|
630
|
+
<Select
|
|
631
|
+
aria-label="Sort queries"
|
|
632
|
+
value={sort}
|
|
633
|
+
onChange={(e) => setSort(e.target.value)}
|
|
634
|
+
style={{
|
|
635
|
+
flex: '1',
|
|
636
|
+
minWidth: 75,
|
|
637
|
+
marginRight: '.5em',
|
|
638
|
+
}}
|
|
639
|
+
>
|
|
640
|
+
{Object.keys(sortFns).map((key) => (
|
|
641
|
+
<option key={key} value={key}>
|
|
642
|
+
Sort by {key}
|
|
643
|
+
</option>
|
|
644
|
+
))}
|
|
645
|
+
</Select>
|
|
646
|
+
<Button
|
|
647
|
+
type="button"
|
|
648
|
+
onClick={() => setBaseSort((old) => old * -1)}
|
|
649
|
+
style={{
|
|
650
|
+
padding: '.3em .4em',
|
|
651
|
+
marginRight: '.5em',
|
|
652
|
+
}}
|
|
653
|
+
>
|
|
654
|
+
{baseSort === 1 ? '⬆ Asc' : '⬇ Desc'}
|
|
655
|
+
</Button>
|
|
656
|
+
<Button
|
|
657
|
+
type="button"
|
|
658
|
+
onClick={() => {
|
|
659
|
+
if (isMockOffline) {
|
|
660
|
+
onlineManager.setOnline(undefined)
|
|
661
|
+
setMockOffline(false)
|
|
662
|
+
window.dispatchEvent(new Event('online'))
|
|
663
|
+
} else {
|
|
664
|
+
onlineManager.setOnline(false)
|
|
665
|
+
setMockOffline(true)
|
|
666
|
+
}
|
|
667
|
+
}}
|
|
668
|
+
aria-label={
|
|
669
|
+
isMockOffline
|
|
670
|
+
? 'Restore offline mock'
|
|
671
|
+
: 'Mock offline behavior'
|
|
672
|
+
}
|
|
673
|
+
title={
|
|
674
|
+
isMockOffline
|
|
675
|
+
? 'Restore offline mock'
|
|
676
|
+
: 'Mock offline behavior'
|
|
677
|
+
}
|
|
678
|
+
style={{
|
|
679
|
+
padding: '0',
|
|
680
|
+
height: '2em',
|
|
681
|
+
}}
|
|
682
|
+
>
|
|
683
|
+
<svg
|
|
684
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
685
|
+
width="2em"
|
|
686
|
+
height="2em"
|
|
687
|
+
viewBox="0 0 24 24"
|
|
688
|
+
stroke={isMockOffline ? theme.danger : 'currentColor'}
|
|
689
|
+
fill="none"
|
|
690
|
+
>
|
|
691
|
+
{isMockOffline ? (
|
|
692
|
+
<>
|
|
693
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
694
|
+
<line x1="12" y1="18" x2="12.01" y2="18" />
|
|
695
|
+
<path d="M9.172 15.172a4 4 0 0 1 5.656 0" />
|
|
696
|
+
<path d="M6.343 12.343a7.963 7.963 0 0 1 3.864 -2.14m4.163 .155a7.965 7.965 0 0 1 3.287 2" />
|
|
697
|
+
<path d="M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374" />
|
|
698
|
+
<line x1="3" y1="3" x2="21" y2="21" />
|
|
699
|
+
</>
|
|
700
|
+
) : (
|
|
701
|
+
<>
|
|
702
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
703
|
+
<line x1="12" y1="18" x2="12.01" y2="18" />
|
|
704
|
+
<path d="M9.172 15.172a4 4 0 0 1 5.656 0" />
|
|
705
|
+
<path d="M6.343 12.343a8 8 0 0 1 11.314 0" />
|
|
706
|
+
<path d="M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0" />
|
|
707
|
+
</>
|
|
708
|
+
)}
|
|
709
|
+
</svg>
|
|
710
|
+
<ScreenReader
|
|
711
|
+
text={
|
|
712
|
+
isMockOffline
|
|
713
|
+
? 'Restore offline mock'
|
|
714
|
+
: 'Mock offline behavior'
|
|
715
|
+
}
|
|
716
|
+
/>
|
|
717
|
+
</Button>
|
|
724
718
|
</div>
|
|
725
719
|
</div>
|
|
726
720
|
</div>
|
|
@@ -749,7 +743,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
|
|
|
749
743
|
<ActiveQuery
|
|
750
744
|
activeQueryHash={activeQueryHash}
|
|
751
745
|
queryCache={queryCache}
|
|
752
|
-
queryClient={
|
|
746
|
+
queryClient={client}
|
|
753
747
|
/>
|
|
754
748
|
) : null}
|
|
755
749
|
|
|
@@ -1110,27 +1104,27 @@ const QueryRow = React.memo(
|
|
|
1110
1104
|
const queryHash =
|
|
1111
1105
|
useSubscribeToQueryCache(
|
|
1112
1106
|
queryCache,
|
|
1113
|
-
() => queryCache.find(queryKey)?.queryHash,
|
|
1107
|
+
() => queryCache.find({ queryKey })?.queryHash,
|
|
1114
1108
|
) ?? ''
|
|
1115
1109
|
|
|
1116
1110
|
const queryState = useSubscribeToQueryCache(
|
|
1117
1111
|
queryCache,
|
|
1118
|
-
() => queryCache.find(queryKey)?.state,
|
|
1112
|
+
() => queryCache.find({ queryKey })?.state,
|
|
1119
1113
|
)
|
|
1120
1114
|
|
|
1121
1115
|
const isStale =
|
|
1122
1116
|
useSubscribeToQueryCache(queryCache, () =>
|
|
1123
|
-
queryCache.find(queryKey)?.isStale(),
|
|
1117
|
+
queryCache.find({ queryKey })?.isStale(),
|
|
1124
1118
|
) ?? false
|
|
1125
1119
|
|
|
1126
1120
|
const isDisabled =
|
|
1127
1121
|
useSubscribeToQueryCache(queryCache, () =>
|
|
1128
|
-
queryCache.find(queryKey)?.isDisabled(),
|
|
1122
|
+
queryCache.find({ queryKey })?.isDisabled(),
|
|
1129
1123
|
) ?? false
|
|
1130
1124
|
|
|
1131
1125
|
const observerCount =
|
|
1132
1126
|
useSubscribeToQueryCache(queryCache, () =>
|
|
1133
|
-
queryCache.find(queryKey)?.getObserversCount(),
|
|
1127
|
+
queryCache.find({ queryKey })?.getObserversCount(),
|
|
1134
1128
|
) ?? 0
|
|
1135
1129
|
|
|
1136
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';
|