@tanstack/query-devtools 5.104.0 → 5.104.2
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/Devtools-BTIH1dw_.js +1238 -0
- package/build/Devtools-BTIH1dw_.js.map +1 -0
- package/build/{Devtools-XuAvSfeN.cjs → Devtools-CJHY2Wx-.cjs} +388 -66
- package/build/{Devtools-xfqOl5Dl.js → Devtools-DBqcRO2f.js} +371 -67
- package/build/Devtools-DE6wfpC3.cjs +1237 -0
- package/build/DevtoolsComponent-B-JX7seJ.js +2 -0
- package/build/DevtoolsComponent-B-JX7seJ.js.map +1 -0
- package/build/DevtoolsComponent-BdsgosNO.js +40 -0
- package/build/DevtoolsComponent-BjB9B9oL.cjs +40 -0
- package/build/DevtoolsComponent-u_hbjcma.cjs +1 -0
- package/build/DevtoolsPanelComponent-CdrNDWsc.js +2 -0
- package/build/DevtoolsPanelComponent-CdrNDWsc.js.map +1 -0
- package/build/DevtoolsPanelComponent-Co1Z91vW.cjs +47 -0
- package/build/DevtoolsPanelComponent-DyNlv9xD.cjs +1 -0
- package/build/DevtoolsPanelComponent-Jyh8juKn.js +47 -0
- package/build/dev.cjs +3 -3
- package/build/dev.js +3 -3
- package/build/index.cjs +1 -1
- package/build/index.d.cts +82 -0
- package/build/index.d.cts.map +1 -1
- package/build/index.d.ts +82 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/{utils-BSq_mRvI.cjs → utils-C0KLuaCQ.cjs} +57 -12
- package/build/{utils-Fz9uQv9N.js → utils-DPVWL709.js} +57 -12
- package/build/utils-po3vZo_N.js.map +1 -1
- package/package.json +9 -9
- package/src/Devtools.tsx +87 -82
- package/src/DevtoolsComponent.tsx +17 -5
- package/src/DevtoolsPanelComponent.tsx +23 -14
- package/src/Explorer.tsx +18 -4
- package/src/TanstackQueryDevtools.tsx +11 -0
- package/src/TanstackQueryDevtoolsPanel.tsx +14 -0
- package/src/contexts/DevtoolsOfflineContext.ts +15 -0
- package/src/contexts/DevtoolsStateContext.ts +15 -0
- package/src/contexts/DevtoolsSubscriptionsContext.ts +16 -0
- package/src/contexts/PiPContext.tsx +13 -0
- package/src/contexts/QueryDevtoolsContext.ts +4 -0
- package/src/contexts/ThemeContext.ts +4 -0
- package/src/contexts/types.ts +133 -1
- package/src/createCacheSubscriptionRegistry.ts +58 -0
- package/src/icons/index.tsx +102 -0
- package/src/providers/DevtoolsOfflineProvider.tsx +37 -0
- package/src/providers/DevtoolsStateProvider.tsx +33 -0
- package/src/providers/DevtoolsSubscriptionsProvider.tsx +35 -0
- package/src/utils.tsx +59 -15
- package/build/Devtools-DP9QP4ya.cjs +0 -1237
- package/build/Devtools-DpIxfOum.js +0 -1238
- package/build/Devtools-DpIxfOum.js.map +0 -1
- package/build/DevtoolsComponent-BEFw32kp.js +0 -2
- package/build/DevtoolsComponent-BEFw32kp.js.map +0 -1
- package/build/DevtoolsComponent-DRjJuLRU.js +0 -34
- package/build/DevtoolsComponent-DjkCvfLf.cjs +0 -34
- package/build/DevtoolsComponent-bl_b_SFT.cjs +0 -1
- package/build/DevtoolsPanelComponent-BE6hbJd6.js +0 -2
- package/build/DevtoolsPanelComponent-BE6hbJd6.js.map +0 -1
- package/build/DevtoolsPanelComponent-BTfH8T_h.cjs +0 -41
- package/build/DevtoolsPanelComponent-CkmpODyJ.js +0 -41
- package/build/DevtoolsPanelComponent-DfaRC3RE.cjs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/query-devtools",
|
|
3
|
-
"version": "5.104.
|
|
3
|
+
"version": "5.104.2",
|
|
4
4
|
"description": "Developer tools to interact with and visualize the TanStack Query cache",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@solid-primitives/resize-observer": "^2.2.0",
|
|
50
50
|
"@solid-primitives/storage": "^1.3.11",
|
|
51
51
|
"@tanstack/match-sorter-utils": "^9.1.2",
|
|
52
|
-
"@tanstack/query-core": "5.104.
|
|
52
|
+
"@tanstack/query-core": "5.104.2",
|
|
53
53
|
"clsx": "^2.1.1",
|
|
54
54
|
"goober": "^2.1.19",
|
|
55
55
|
"solid-js": "^1.9.15",
|
|
@@ -58,21 +58,21 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@solidjs/testing-library": "^0.8.10",
|
|
61
|
-
"
|
|
61
|
+
"typescript": "6.0.3",
|
|
62
62
|
"unplugin-solid": "^2.0.0",
|
|
63
63
|
"vite-plugin-solid": "^2.11.14"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"clean": "premove ./build ./coverage ./dist-ts ./.cache/test-types",
|
|
67
67
|
"compile": "tsc --project tsconfig.json",
|
|
68
|
-
"test:
|
|
68
|
+
"test:oxlint": "oxlint ./src",
|
|
69
69
|
"test:types": "npm-run-all --serial test:types:*",
|
|
70
|
-
"test:types:
|
|
71
|
-
"test:types:
|
|
72
|
-
"test:types:
|
|
73
|
-
"test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --project tsconfig.json --outDir .cache/test-types/ts59 --tsBuildInfoFile .cache/test-types/ts59.tsbuildinfo",
|
|
70
|
+
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts57 --tsBuildInfoFile .cache/test-types/ts57.tsbuildinfo",
|
|
71
|
+
"test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts58 --tsBuildInfoFile .cache/test-types/ts58.tsbuildinfo",
|
|
72
|
+
"test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts59 --tsBuildInfoFile .cache/test-types/ts59.tsbuildinfo",
|
|
74
73
|
"test:types:tscurrent": "tsc --project tsconfig.json --outDir .cache/test-types/tscurrent --tsBuildInfoFile .cache/test-types/tscurrent.tsbuildinfo",
|
|
75
|
-
"test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --project tsconfig.json --outDir .cache/test-types/ts70 --tsBuildInfoFile .cache/test-types/ts70.tsbuildinfo",
|
|
74
|
+
"test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts70 --tsBuildInfoFile .cache/test-types/ts70.tsbuildinfo",
|
|
75
|
+
"test:types:ts71": "node ../../node_modules/typescript71/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts71 --tsBuildInfoFile .cache/test-types/ts71.tsbuildinfo",
|
|
76
76
|
"test:lib": "vitest",
|
|
77
77
|
"test:lib:dev": "pnpm run test:lib --watch",
|
|
78
78
|
"test:build": "publint --strict && attw --pack",
|
package/src/Devtools.tsx
CHANGED
|
@@ -17,6 +17,9 @@ import { Key } from '@solid-primitives/keyed'
|
|
|
17
17
|
import { createResizeObserver } from '@solid-primitives/resize-observer'
|
|
18
18
|
import { DropdownMenu, RadioGroup } from '@kobalte/core'
|
|
19
19
|
import { Portal } from 'solid-js/web'
|
|
20
|
+
import { useDevtoolsOffline } from './contexts/DevtoolsOfflineContext'
|
|
21
|
+
import { useDevtoolsSubscriptions } from './contexts/DevtoolsSubscriptionsContext'
|
|
22
|
+
import { useDevtoolsState } from './contexts/DevtoolsStateContext'
|
|
20
23
|
import { tokens } from './theme'
|
|
21
24
|
import {
|
|
22
25
|
convertRemToPixels,
|
|
@@ -78,7 +81,7 @@ import type {
|
|
|
78
81
|
QueryCacheNotifyEvent,
|
|
79
82
|
} from '@tanstack/query-core'
|
|
80
83
|
import type { StorageObject, StorageSetter } from '@solid-primitives/storage'
|
|
81
|
-
import type { Accessor, Component, JSX
|
|
84
|
+
import type { Accessor, Component, JSX } from 'solid-js'
|
|
82
85
|
|
|
83
86
|
interface DevtoolsPanelProps {
|
|
84
87
|
localStore: StorageObject<string>
|
|
@@ -98,19 +101,21 @@ interface QueryStatusProps {
|
|
|
98
101
|
count: number
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
null,
|
|
106
|
-
)
|
|
107
|
-
const [panelWidth, setPanelWidth] = createSignal(0)
|
|
108
|
-
const [offline, setOffline] = createSignal(false)
|
|
109
|
-
|
|
104
|
+
/**
|
|
105
|
+
* The devtools component that `TanstackQueryDevtools` and `TanstackQueryDevtoolsPanel` lazily load
|
|
106
|
+
* and render.
|
|
107
|
+
*/
|
|
110
108
|
export type DevtoolsComponentType = Component<QueryDevtoolsProps> & {
|
|
111
109
|
shadowDOMTarget?: ShadowRoot
|
|
112
110
|
}
|
|
113
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The floating devtools: a toggle button that opens a resizable panel, or the
|
|
114
|
+
* panel in a picture-in-picture window when one is open.
|
|
115
|
+
* @param props - The `localStore` that persists the devtools settings, and its
|
|
116
|
+
* `setLocalStore` setter.
|
|
117
|
+
* @returns The toggle button and the panel.
|
|
118
|
+
*/
|
|
114
119
|
export const Devtools: Component<DevtoolsPanelProps> = (props) => {
|
|
115
120
|
const theme = useTheme()
|
|
116
121
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
@@ -119,19 +124,6 @@ export const Devtools: Component<DevtoolsPanelProps> = (props) => {
|
|
|
119
124
|
const styles = createMemo(() => {
|
|
120
125
|
return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
|
|
121
126
|
})
|
|
122
|
-
const onlineManager = createMemo(
|
|
123
|
-
() => useQueryDevtoolsContext().onlineManager,
|
|
124
|
-
)
|
|
125
|
-
onMount(() => {
|
|
126
|
-
const unsubscribe = onlineManager().subscribe((online) => {
|
|
127
|
-
setOffline(!online)
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
onCleanup(() => {
|
|
131
|
-
unsubscribe()
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
|
|
135
127
|
const pip = usePiPWindow()
|
|
136
128
|
|
|
137
129
|
const buttonPosition = createMemo(() => {
|
|
@@ -285,6 +277,8 @@ export const Devtools: Component<DevtoolsPanelProps> = (props) => {
|
|
|
285
277
|
const PiPPanel: Component<{
|
|
286
278
|
children: JSX.Element
|
|
287
279
|
}> = (props) => {
|
|
280
|
+
const { panelWidth, setPanelWidth } = useDevtoolsState()
|
|
281
|
+
|
|
288
282
|
const pip = usePiPWindow()
|
|
289
283
|
const theme = useTheme()
|
|
290
284
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
@@ -352,9 +346,17 @@ const PiPPanel: Component<{
|
|
|
352
346
|
)
|
|
353
347
|
}
|
|
354
348
|
|
|
349
|
+
/**
|
|
350
|
+
* The container of the embedded devtools panel, which tracks its width for
|
|
351
|
+
* the responsive layout.
|
|
352
|
+
* @param props - The `children` to render inside the panel.
|
|
353
|
+
* @returns The panel container.
|
|
354
|
+
*/
|
|
355
355
|
export const ParentPanel: Component<{
|
|
356
356
|
children: JSX.Element
|
|
357
357
|
}> = (props) => {
|
|
358
|
+
const { panelWidth, setPanelWidth } = useDevtoolsState()
|
|
359
|
+
|
|
358
360
|
const theme = useTheme()
|
|
359
361
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
360
362
|
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
@@ -412,6 +414,8 @@ export const ParentPanel: Component<{
|
|
|
412
414
|
}
|
|
413
415
|
|
|
414
416
|
const DraggablePanel: Component<DevtoolsPanelProps> = (props) => {
|
|
417
|
+
const { setSelectedQueryHash, panelWidth, setPanelWidth } = useDevtoolsState()
|
|
418
|
+
|
|
415
419
|
const theme = useTheme()
|
|
416
420
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
417
421
|
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
@@ -675,7 +679,25 @@ const DraggablePanel: Component<DevtoolsPanelProps> = (props) => {
|
|
|
675
679
|
)
|
|
676
680
|
}
|
|
677
681
|
|
|
682
|
+
/**
|
|
683
|
+
* The content of the devtools panel: the query and mutation lists with their
|
|
684
|
+
* filters and actions, and the details of the selected query or mutation.
|
|
685
|
+
* @param props - The `localStore` and `setLocalStore` that persist the devtools
|
|
686
|
+
* settings, `showPanelViewOnly` to hide the controls that only apply to the
|
|
687
|
+
* floating devtools, and `onClose` to close an embedded panel.
|
|
688
|
+
* @returns The panel content.
|
|
689
|
+
*/
|
|
678
690
|
export const ContentView: Component<ContentViewProps> = (props) => {
|
|
691
|
+
const {
|
|
692
|
+
selectedQueryHash,
|
|
693
|
+
setSelectedQueryHash,
|
|
694
|
+
selectedMutationId,
|
|
695
|
+
setSelectedMutationId,
|
|
696
|
+
panelWidth,
|
|
697
|
+
} = useDevtoolsState()
|
|
698
|
+
|
|
699
|
+
const { offline, toggleOffline } = useDevtoolsOffline()
|
|
700
|
+
|
|
679
701
|
setupQueryCacheSubscription()
|
|
680
702
|
setupMutationCacheSubscription()
|
|
681
703
|
let containerRef!: HTMLDivElement
|
|
@@ -710,10 +732,6 @@ export const ContentView: Component<ContentViewProps> = (props) => {
|
|
|
710
732
|
() => mutationSortFns[mutationSort() as string],
|
|
711
733
|
)
|
|
712
734
|
|
|
713
|
-
const onlineManager = createMemo(
|
|
714
|
-
() => useQueryDevtoolsContext().onlineManager,
|
|
715
|
-
)
|
|
716
|
-
|
|
717
735
|
const query_cache = createMemo(() => {
|
|
718
736
|
return useQueryDevtoolsContext().client.getQueryCache()
|
|
719
737
|
})
|
|
@@ -1035,9 +1053,7 @@ export const ContentView: Component<ContentViewProps> = (props) => {
|
|
|
1035
1053
|
<Trash />
|
|
1036
1054
|
</button>
|
|
1037
1055
|
<button
|
|
1038
|
-
onClick={
|
|
1039
|
-
onlineManager().setOnline(!onlineManager().isOnline())
|
|
1040
|
-
}}
|
|
1056
|
+
onClick={toggleOffline}
|
|
1041
1057
|
class={cx(
|
|
1042
1058
|
styles().actionsBtn,
|
|
1043
1059
|
offline() && styles().actionsBtnOffline,
|
|
@@ -1376,6 +1392,8 @@ export const ContentView: Component<ContentViewProps> = (props) => {
|
|
|
1376
1392
|
}
|
|
1377
1393
|
|
|
1378
1394
|
const QueryRow: Component<{ query: Query }> = (props) => {
|
|
1395
|
+
const { selectedQueryHash, setSelectedQueryHash } = useDevtoolsState()
|
|
1396
|
+
|
|
1379
1397
|
const theme = useTheme()
|
|
1380
1398
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
1381
1399
|
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
@@ -1485,6 +1503,8 @@ const QueryRow: Component<{ query: Query }> = (props) => {
|
|
|
1485
1503
|
}
|
|
1486
1504
|
|
|
1487
1505
|
const MutationRow: Component<{ mutation: Mutation }> = (props) => {
|
|
1506
|
+
const { selectedMutationId, setSelectedMutationId } = useDevtoolsState()
|
|
1507
|
+
|
|
1488
1508
|
const theme = useTheme()
|
|
1489
1509
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
1490
1510
|
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
@@ -1726,6 +1746,8 @@ const MutationStatusCount: Component = () => {
|
|
|
1726
1746
|
}
|
|
1727
1747
|
|
|
1728
1748
|
const QueryStatus: Component<QueryStatusProps> = (props) => {
|
|
1749
|
+
const { selectedQueryHash, panelWidth } = useDevtoolsState()
|
|
1750
|
+
|
|
1729
1751
|
const theme = useTheme()
|
|
1730
1752
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
1731
1753
|
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
@@ -1841,6 +1863,8 @@ const QueryStatus: Component<QueryStatusProps> = (props) => {
|
|
|
1841
1863
|
}
|
|
1842
1864
|
|
|
1843
1865
|
const QueryDetails = () => {
|
|
1866
|
+
const { selectedQueryHash, setSelectedQueryHash } = useDevtoolsState()
|
|
1867
|
+
|
|
1844
1868
|
const theme = useTheme()
|
|
1845
1869
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
1846
1870
|
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
@@ -2386,6 +2410,8 @@ const QueryDetails = () => {
|
|
|
2386
2410
|
}
|
|
2387
2411
|
|
|
2388
2412
|
const MutationDetails = () => {
|
|
2413
|
+
const { selectedMutationId } = useDevtoolsState()
|
|
2414
|
+
|
|
2389
2415
|
const theme = useTheme()
|
|
2390
2416
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
2391
2417
|
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
@@ -2573,35 +2599,22 @@ const MutationDetails = () => {
|
|
|
2573
2599
|
)
|
|
2574
2600
|
}
|
|
2575
2601
|
|
|
2576
|
-
const queryCacheMap = new Map<
|
|
2577
|
-
(q: Accessor<QueryCache>) => any,
|
|
2578
|
-
{
|
|
2579
|
-
setter: Setter<any>
|
|
2580
|
-
shouldUpdate: (event: QueryCacheNotifyEvent) => boolean
|
|
2581
|
-
}
|
|
2582
|
-
>()
|
|
2583
|
-
|
|
2584
2602
|
const setupQueryCacheSubscription = () => {
|
|
2603
|
+
const { queryCacheSubscriptions } = useDevtoolsSubscriptions()
|
|
2585
2604
|
const queryCache = createMemo(() => {
|
|
2586
2605
|
const client = useQueryDevtoolsContext().client
|
|
2587
2606
|
return client.getQueryCache()
|
|
2588
2607
|
})
|
|
2589
2608
|
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
}
|
|
2609
|
+
createEffect(() => {
|
|
2610
|
+
const cache = queryCache()
|
|
2611
|
+
const unsubscribe = cache.subscribe((event) => {
|
|
2612
|
+
batch(() => {
|
|
2613
|
+
queryCacheSubscriptions.notify(() => cache, event)
|
|
2614
|
+
})
|
|
2596
2615
|
})
|
|
2616
|
+
onCleanup(unsubscribe)
|
|
2597
2617
|
})
|
|
2598
|
-
|
|
2599
|
-
onCleanup(() => {
|
|
2600
|
-
queryCacheMap.clear()
|
|
2601
|
-
unsubscribe()
|
|
2602
|
-
})
|
|
2603
|
-
|
|
2604
|
-
return unsubscribe
|
|
2605
2618
|
}
|
|
2606
2619
|
|
|
2607
2620
|
const createSubscribeToQueryCacheBatcher = <T,>(
|
|
@@ -2609,6 +2622,7 @@ const createSubscribeToQueryCacheBatcher = <T,>(
|
|
|
2609
2622
|
equalityCheck: boolean = true,
|
|
2610
2623
|
shouldUpdate: (event: QueryCacheNotifyEvent) => boolean = () => true,
|
|
2611
2624
|
) => {
|
|
2625
|
+
const { queryCacheSubscriptions } = useDevtoolsSubscriptions()
|
|
2612
2626
|
const queryCache = createMemo(() => {
|
|
2613
2627
|
const client = useQueryDevtoolsContext().client
|
|
2614
2628
|
return client.getQueryCache()
|
|
@@ -2623,49 +2637,44 @@ const createSubscribeToQueryCacheBatcher = <T,>(
|
|
|
2623
2637
|
setValue(callback(queryCache))
|
|
2624
2638
|
})
|
|
2625
2639
|
|
|
2626
|
-
|
|
2627
|
-
setter: setValue,
|
|
2628
|
-
shouldUpdate: shouldUpdate,
|
|
2629
|
-
})
|
|
2630
|
-
|
|
2631
|
-
onCleanup(() => {
|
|
2632
|
-
queryCacheMap.delete(callback)
|
|
2633
|
-
})
|
|
2640
|
+
queryCacheSubscriptions.register(callback, setValue, shouldUpdate)
|
|
2634
2641
|
|
|
2635
2642
|
return value
|
|
2636
2643
|
}
|
|
2637
2644
|
|
|
2638
|
-
const mutationCacheMap = new Map<
|
|
2639
|
-
(q: Accessor<MutationCache>) => any,
|
|
2640
|
-
Setter<any>
|
|
2641
|
-
>()
|
|
2642
|
-
|
|
2643
2645
|
const setupMutationCacheSubscription = () => {
|
|
2646
|
+
const { mutationCacheSubscriptions } = useDevtoolsSubscriptions()
|
|
2644
2647
|
const mutationCache = createMemo(() => {
|
|
2645
2648
|
const client = useQueryDevtoolsContext().client
|
|
2646
2649
|
return client.getMutationCache()
|
|
2647
2650
|
})
|
|
2648
2651
|
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2652
|
+
createEffect(() => {
|
|
2653
|
+
const cache = mutationCache()
|
|
2654
|
+
let active = true
|
|
2655
|
+
const unsubscribe = cache.subscribe((event) => {
|
|
2656
|
+
mutationCacheSubscriptions.notify(
|
|
2657
|
+
() => cache,
|
|
2658
|
+
event,
|
|
2659
|
+
(update) => {
|
|
2660
|
+
queueMicrotask(() => {
|
|
2661
|
+
if (active) update()
|
|
2662
|
+
})
|
|
2663
|
+
},
|
|
2664
|
+
)
|
|
2665
|
+
})
|
|
2666
|
+
onCleanup(() => {
|
|
2667
|
+
active = false
|
|
2668
|
+
unsubscribe()
|
|
2669
|
+
})
|
|
2660
2670
|
})
|
|
2661
|
-
|
|
2662
|
-
return unsubscribe
|
|
2663
2671
|
}
|
|
2664
2672
|
|
|
2665
2673
|
const createSubscribeToMutationCacheBatcher = <T,>(
|
|
2666
2674
|
callback: (queryCache: Accessor<MutationCache>) => Exclude<T, Function>,
|
|
2667
2675
|
equalityCheck: boolean = true,
|
|
2668
2676
|
) => {
|
|
2677
|
+
const { mutationCacheSubscriptions } = useDevtoolsSubscriptions()
|
|
2669
2678
|
const mutationCache = createMemo(() => {
|
|
2670
2679
|
const client = useQueryDevtoolsContext().client
|
|
2671
2680
|
return client.getMutationCache()
|
|
@@ -2680,11 +2689,7 @@ const createSubscribeToMutationCacheBatcher = <T,>(
|
|
|
2680
2689
|
setValue(callback(mutationCache))
|
|
2681
2690
|
})
|
|
2682
2691
|
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
onCleanup(() => {
|
|
2686
|
-
mutationCacheMap.delete(callback)
|
|
2687
|
-
})
|
|
2692
|
+
mutationCacheSubscriptions.register(callback, setValue)
|
|
2688
2693
|
|
|
2689
2694
|
return value
|
|
2690
2695
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createLocalStorage } from '@solid-primitives/storage'
|
|
2
2
|
import { createMemo } from 'solid-js'
|
|
3
|
+
import { DevtoolsOfflineProvider } from './providers/DevtoolsOfflineProvider'
|
|
4
|
+
import { DevtoolsSubscriptionsProvider } from './providers/DevtoolsSubscriptionsProvider'
|
|
5
|
+
import { DevtoolsStateProvider } from './providers/DevtoolsStateProvider'
|
|
3
6
|
import { Devtools } from './Devtools'
|
|
4
7
|
import { getPreferredColorScheme } from './utils'
|
|
5
8
|
import { THEME_PREFERENCE } from './constants'
|
|
@@ -24,11 +27,20 @@ const DevtoolsComponent: DevtoolsComponentType = (props) => {
|
|
|
24
27
|
|
|
25
28
|
return (
|
|
26
29
|
<QueryDevtoolsContext.Provider value={props}>
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
<DevtoolsStateProvider>
|
|
31
|
+
<DevtoolsOfflineProvider>
|
|
32
|
+
<DevtoolsSubscriptionsProvider>
|
|
33
|
+
<PiPProvider localStore={localStore} setLocalStore={setLocalStore}>
|
|
34
|
+
<ThemeContext.Provider value={theme}>
|
|
35
|
+
<Devtools
|
|
36
|
+
localStore={localStore}
|
|
37
|
+
setLocalStore={setLocalStore}
|
|
38
|
+
/>
|
|
39
|
+
</ThemeContext.Provider>
|
|
40
|
+
</PiPProvider>
|
|
41
|
+
</DevtoolsSubscriptionsProvider>
|
|
42
|
+
</DevtoolsOfflineProvider>
|
|
43
|
+
</DevtoolsStateProvider>
|
|
32
44
|
</QueryDevtoolsContext.Provider>
|
|
33
45
|
)
|
|
34
46
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createLocalStorage } from '@solid-primitives/storage'
|
|
2
2
|
import { createMemo } from 'solid-js'
|
|
3
|
+
import { DevtoolsOfflineProvider } from './providers/DevtoolsOfflineProvider'
|
|
4
|
+
import { DevtoolsSubscriptionsProvider } from './providers/DevtoolsSubscriptionsProvider'
|
|
5
|
+
import { DevtoolsStateProvider } from './providers/DevtoolsStateProvider'
|
|
3
6
|
import { ContentView, ParentPanel } from './Devtools'
|
|
4
7
|
import { getPreferredColorScheme } from './utils'
|
|
5
8
|
import { THEME_PREFERENCE } from './constants'
|
|
@@ -24,22 +27,28 @@ const DevtoolsPanelComponent: DevtoolsComponentType = (props) => {
|
|
|
24
27
|
|
|
25
28
|
return (
|
|
26
29
|
<QueryDevtoolsContext.Provider value={props}>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<ThemeContext.Provider value={theme}>
|
|
33
|
-
<ParentPanel>
|
|
34
|
-
<ContentView
|
|
30
|
+
<DevtoolsStateProvider>
|
|
31
|
+
<DevtoolsOfflineProvider>
|
|
32
|
+
<DevtoolsSubscriptionsProvider>
|
|
33
|
+
<PiPProvider
|
|
34
|
+
disabled
|
|
35
35
|
localStore={localStore}
|
|
36
36
|
setLocalStore={setLocalStore}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
>
|
|
38
|
+
<ThemeContext.Provider value={theme}>
|
|
39
|
+
<ParentPanel>
|
|
40
|
+
<ContentView
|
|
41
|
+
localStore={localStore}
|
|
42
|
+
setLocalStore={setLocalStore}
|
|
43
|
+
onClose={props.onClose}
|
|
44
|
+
showPanelViewOnly
|
|
45
|
+
/>
|
|
46
|
+
</ParentPanel>
|
|
47
|
+
</ThemeContext.Provider>
|
|
48
|
+
</PiPProvider>
|
|
49
|
+
</DevtoolsSubscriptionsProvider>
|
|
50
|
+
</DevtoolsOfflineProvider>
|
|
51
|
+
</DevtoolsStateProvider>
|
|
43
52
|
</QueryDevtoolsContext.Provider>
|
|
44
53
|
)
|
|
45
54
|
}
|
package/src/Explorer.tsx
CHANGED
|
@@ -30,11 +30,13 @@ import { useQueryDevtoolsContext, useTheme } from './contexts'
|
|
|
30
30
|
import type { Query } from '@tanstack/query-core'
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Chunk elements in the array by size
|
|
34
|
-
*
|
|
35
|
-
* when the array cannot be chunked evenly by size, the last chunk will be
|
|
36
|
-
* filled with the remaining elements
|
|
33
|
+
* Chunk elements in the array by size.
|
|
37
34
|
*
|
|
35
|
+
* When the array cannot be chunked evenly by size, the last chunk will be
|
|
36
|
+
* filled with the remaining elements.
|
|
37
|
+
* @param array - The elements to chunk.
|
|
38
|
+
* @param size - The number of elements per chunk. Below `1`, no chunks are returned.
|
|
39
|
+
* @returns The chunks.
|
|
38
40
|
* @example
|
|
39
41
|
* chunkArray(['a','b', 'c', 'd', 'e'], 2) // returns [['a','b'], ['c', 'd'], ['e']]
|
|
40
42
|
*/
|
|
@@ -262,10 +264,22 @@ type ExplorerProps = {
|
|
|
262
264
|
onEdit?: () => void
|
|
263
265
|
}
|
|
264
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Checks whether a value is iterable.
|
|
269
|
+
* @param x - The value to check.
|
|
270
|
+
* @returns `true` if `x` has a `Symbol.iterator` method.
|
|
271
|
+
*/
|
|
265
272
|
function isIterable(x: any): x is Iterable<unknown> {
|
|
266
273
|
return Symbol.iterator in x
|
|
267
274
|
}
|
|
268
275
|
|
|
276
|
+
/**
|
|
277
|
+
* Renders an expandable tree view of a value, used to explore a query's data in the devtools. It
|
|
278
|
+
* can also edit and delete entries in the query's data.
|
|
279
|
+
* @param props - The value to show and its label, plus the options for expanding, editing, and
|
|
280
|
+
* deleting entries.
|
|
281
|
+
* @returns The tree view.
|
|
282
|
+
*/
|
|
269
283
|
export default function Explorer(props: ExplorerProps) {
|
|
270
284
|
const theme = useTheme()
|
|
271
285
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
@@ -15,8 +15,19 @@ import type {
|
|
|
15
15
|
} from './contexts/types'
|
|
16
16
|
import type { Signal } from 'solid-js'
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The options for `TanstackQueryDevtools`, which mounts the floating devtools.
|
|
20
|
+
*/
|
|
18
21
|
export interface TanstackQueryDevtoolsConfig extends QueryDevtoolsProps {
|
|
22
|
+
/**
|
|
23
|
+
* Use this to pass a nonce to the style tag that is added to the document head. This is useful if
|
|
24
|
+
* you are using a Content Security Policy (CSP) nonce to allow inline styles.
|
|
25
|
+
*/
|
|
19
26
|
styleNonce?: string
|
|
27
|
+
/**
|
|
28
|
+
* Use this to pass a shadow DOM target to the devtools so that the styles will be applied
|
|
29
|
+
* within the shadow DOM instead of within the head tag in the light DOM.
|
|
30
|
+
*/
|
|
20
31
|
shadowDOMTarget?: ShadowRoot
|
|
21
32
|
}
|
|
22
33
|
|
|
@@ -15,9 +15,23 @@ import type {
|
|
|
15
15
|
} from './contexts/types'
|
|
16
16
|
import type { Signal } from 'solid-js'
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The options for `TanstackQueryDevtoolsPanel`, which mounts the devtools as an embedded panel.
|
|
20
|
+
*/
|
|
18
21
|
export interface TanstackQueryDevtoolsPanelConfig extends QueryDevtoolsProps {
|
|
22
|
+
/**
|
|
23
|
+
* Use this to pass a nonce to the style tag that is added to the document head. This is useful if
|
|
24
|
+
* you are using a Content Security Policy (CSP) nonce to allow inline styles.
|
|
25
|
+
*/
|
|
19
26
|
styleNonce?: string
|
|
27
|
+
/**
|
|
28
|
+
* Use this to pass a shadow DOM target to the devtools so that the styles will be applied
|
|
29
|
+
* within the shadow DOM instead of within the head tag in the light DOM.
|
|
30
|
+
*/
|
|
20
31
|
shadowDOMTarget?: ShadowRoot
|
|
32
|
+
/**
|
|
33
|
+
* Callback function that is called when the devtools panel is closed.
|
|
34
|
+
*/
|
|
21
35
|
onClose?: () => void
|
|
22
36
|
}
|
|
23
37
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useContext } from 'solid-js'
|
|
2
|
+
import type { DevtoolsOfflineState } from './types'
|
|
3
|
+
|
|
4
|
+
export const DevtoolsOfflineContext = createContext<DevtoolsOfflineState>()
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns the devtools offline state provided by `DevtoolsOfflineProvider`.
|
|
8
|
+
* @returns The offline state.
|
|
9
|
+
* @throws {Error} If there is no `DevtoolsOfflineProvider` above.
|
|
10
|
+
*/
|
|
11
|
+
export function useDevtoolsOffline() {
|
|
12
|
+
const state = useContext(DevtoolsOfflineContext)
|
|
13
|
+
if (!state) throw new Error('Missing DevtoolsOfflineProvider')
|
|
14
|
+
return state
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useContext } from 'solid-js'
|
|
2
|
+
import type { DevtoolsState } from './types'
|
|
3
|
+
|
|
4
|
+
export const DevtoolsStateContext = createContext<DevtoolsState>()
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns the devtools selection and panel state provided by `DevtoolsStateProvider`.
|
|
8
|
+
* @returns The selection and panel state.
|
|
9
|
+
* @throws {Error} If there is no `DevtoolsStateProvider` above.
|
|
10
|
+
*/
|
|
11
|
+
export function useDevtoolsState() {
|
|
12
|
+
const state = useContext(DevtoolsStateContext)
|
|
13
|
+
if (!state) throw new Error('Missing DevtoolsStateProvider')
|
|
14
|
+
return state
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createContext, useContext } from 'solid-js'
|
|
2
|
+
import type { DevtoolsSubscriptions } from './types'
|
|
3
|
+
|
|
4
|
+
export const DevtoolsSubscriptionsContext =
|
|
5
|
+
createContext<DevtoolsSubscriptions>()
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the devtools cache subscription registries provided by `DevtoolsSubscriptionsProvider`.
|
|
9
|
+
* @returns The cache subscription registries.
|
|
10
|
+
* @throws {Error} If there is no `DevtoolsSubscriptionsProvider` above.
|
|
11
|
+
*/
|
|
12
|
+
export function useDevtoolsSubscriptions() {
|
|
13
|
+
const subscriptions = useContext(DevtoolsSubscriptionsContext)
|
|
14
|
+
if (!subscriptions) throw new Error('Missing DevtoolsSubscriptionsProvider')
|
|
15
|
+
return subscriptions
|
|
16
|
+
}
|
|
@@ -32,6 +32,14 @@ const PiPContext = createContext<Accessor<PiPContextType> | undefined>(
|
|
|
32
32
|
undefined,
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Provides the picture-in-picture window of the devtools, and functions to
|
|
37
|
+
* open and close it.
|
|
38
|
+
* @param props - The `children` to render, the `localStore` and
|
|
39
|
+
* `setLocalStore` that persist whether the window is open, and `disabled` to
|
|
40
|
+
* turn picture-in-picture off.
|
|
41
|
+
* @returns The context provider.
|
|
42
|
+
*/
|
|
35
43
|
export const PiPProvider = (props: PiPProviderProps) => {
|
|
36
44
|
// Expose pipWindow that is currently active
|
|
37
45
|
const [pipWindow, setPipWindow] = createSignal<Window | null>(null)
|
|
@@ -192,6 +200,11 @@ export const PiPProvider = (props: PiPProviderProps) => {
|
|
|
192
200
|
)
|
|
193
201
|
}
|
|
194
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Reads the picture-in-picture context provided by {@link PiPProvider}.
|
|
205
|
+
* @returns An accessor of the picture-in-picture window and the functions to
|
|
206
|
+
* open and close it.
|
|
207
|
+
*/
|
|
195
208
|
export const usePiPWindow = () => {
|
|
196
209
|
const context = createMemo(() => {
|
|
197
210
|
const ctx = useContext(PiPContext)
|
|
@@ -18,6 +18,10 @@ export const QueryDevtoolsContext = createContext<QueryDevtoolsProps>({
|
|
|
18
18
|
shadowDOMTarget: undefined,
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Returns the devtools configuration from context, such as the `client` and the `onlineManager`.
|
|
23
|
+
* @returns The devtools configuration.
|
|
24
|
+
*/
|
|
21
25
|
export function useQueryDevtoolsContext() {
|
|
22
26
|
return useContext(QueryDevtoolsContext)
|
|
23
27
|
}
|
|
@@ -5,6 +5,10 @@ export const ThemeContext = createContext<Accessor<'light' | 'dark'>>(
|
|
|
5
5
|
() => 'dark' as const,
|
|
6
6
|
)
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Returns the devtools theme from context.
|
|
10
|
+
* @returns A getter for the current theme, `'light'` or `'dark'`. Defaults to `'dark'`.
|
|
11
|
+
*/
|
|
8
12
|
export function useTheme() {
|
|
9
13
|
return useContext(ThemeContext)
|
|
10
14
|
}
|