@tanstack/query-devtools 5.104.1 → 5.104.3

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 (35) hide show
  1. package/build/Devtools-BTIH1dw_.js.map +1 -1
  2. package/build/{Devtools-DDPb_OXS.cjs → Devtools-CJHY2Wx-.cjs} +212 -5
  3. package/build/{Devtools-BR7-Ww0_.js → Devtools-DBqcRO2f.js} +212 -5
  4. package/build/{DevtoolsComponent-PDsMk_-d.js → DevtoolsComponent-BdsgosNO.js} +2 -2
  5. package/build/{DevtoolsComponent-DdJdz_3E.cjs → DevtoolsComponent-BjB9B9oL.cjs} +2 -2
  6. package/build/{DevtoolsPanelComponent-D7InkRel.cjs → DevtoolsPanelComponent-Co1Z91vW.cjs} +2 -2
  7. package/build/{DevtoolsPanelComponent-DWMNAgBe.js → DevtoolsPanelComponent-Jyh8juKn.js} +2 -2
  8. package/build/dev.cjs +3 -3
  9. package/build/dev.js +3 -3
  10. package/build/index.d.cts +81 -0
  11. package/build/index.d.cts.map +1 -1
  12. package/build/index.d.ts +81 -0
  13. package/build/index.d.ts.map +1 -1
  14. package/build/index.js.map +1 -1
  15. package/build/{utils-BSq_mRvI.cjs → utils-C0KLuaCQ.cjs} +57 -12
  16. package/build/{utils-Fz9uQv9N.js → utils-DPVWL709.js} +57 -12
  17. package/build/utils-po3vZo_N.js.map +1 -1
  18. package/package.json +4 -4
  19. package/src/Devtools.tsx +25 -0
  20. package/src/Explorer.tsx +18 -4
  21. package/src/TanstackQueryDevtools.tsx +11 -0
  22. package/src/TanstackQueryDevtoolsPanel.tsx +14 -0
  23. package/src/contexts/DevtoolsOfflineContext.ts +5 -0
  24. package/src/contexts/DevtoolsStateContext.ts +5 -0
  25. package/src/contexts/DevtoolsSubscriptionsContext.ts +5 -0
  26. package/src/contexts/PiPContext.tsx +13 -0
  27. package/src/contexts/QueryDevtoolsContext.ts +4 -0
  28. package/src/contexts/ThemeContext.ts +4 -0
  29. package/src/contexts/types.ts +96 -0
  30. package/src/createCacheSubscriptionRegistry.ts +18 -0
  31. package/src/icons/index.tsx +102 -0
  32. package/src/providers/DevtoolsOfflineProvider.tsx +6 -0
  33. package/src/providers/DevtoolsStateProvider.tsx +5 -0
  34. package/src/providers/DevtoolsSubscriptionsProvider.tsx +5 -0
  35. package/src/utils.tsx +59 -15
@@ -1,5 +1,9 @@
1
1
  import { Show, createUniqueId } from 'solid-js'
2
2
 
3
+ /**
4
+ * Renders the search icon.
5
+ * @returns The icon's SVG element.
6
+ */
3
7
  export function Search() {
4
8
  return (
5
9
  <svg
@@ -20,6 +24,10 @@ export function Search() {
20
24
  )
21
25
  }
22
26
 
27
+ /**
28
+ * Renders the trash icon.
29
+ * @returns The icon's SVG element.
30
+ */
23
31
  export function Trash() {
24
32
  return (
25
33
  <svg
@@ -40,6 +48,10 @@ export function Trash() {
40
48
  )
41
49
  }
42
50
 
51
+ /**
52
+ * Renders the chevron-down icon.
53
+ * @returns The icon's SVG element.
54
+ */
43
55
  export function ChevronDown() {
44
56
  return (
45
57
  <svg
@@ -60,6 +72,10 @@ export function ChevronDown() {
60
72
  )
61
73
  }
62
74
 
75
+ /**
76
+ * Renders the up arrow icon.
77
+ * @returns The icon's SVG element.
78
+ */
63
79
  export function ArrowUp() {
64
80
  return (
65
81
  <svg
@@ -80,6 +96,10 @@ export function ArrowUp() {
80
96
  )
81
97
  }
82
98
 
99
+ /**
100
+ * Renders the down arrow icon.
101
+ * @returns The icon's SVG element.
102
+ */
83
103
  export function ArrowDown() {
84
104
  return (
85
105
  <svg
@@ -100,6 +120,10 @@ export function ArrowDown() {
100
120
  )
101
121
  }
102
122
 
123
+ /**
124
+ * Renders the left arrow icon.
125
+ * @returns The icon's SVG element.
126
+ */
103
127
  export function ArrowLeft() {
104
128
  return (
105
129
  <svg
@@ -123,6 +147,10 @@ export function ArrowLeft() {
123
147
  )
124
148
  }
125
149
 
150
+ /**
151
+ * Renders the right arrow icon.
152
+ * @returns The icon's SVG element.
153
+ */
126
154
  export function ArrowRight() {
127
155
  return (
128
156
  <svg
@@ -146,6 +174,10 @@ export function ArrowRight() {
146
174
  )
147
175
  }
148
176
 
177
+ /**
178
+ * Renders the sun (light theme) icon.
179
+ * @returns The icon's SVG element.
180
+ */
149
181
  export function Sun() {
150
182
  return (
151
183
  <svg
@@ -166,6 +198,10 @@ export function Sun() {
166
198
  )
167
199
  }
168
200
 
201
+ /**
202
+ * Renders the moon (dark theme) icon.
203
+ * @returns The icon's SVG element.
204
+ */
169
205
  export function Moon() {
170
206
  return (
171
207
  <svg
@@ -186,6 +222,10 @@ export function Moon() {
186
222
  )
187
223
  }
188
224
 
225
+ /**
226
+ * Renders the monitor (system theme) icon.
227
+ * @returns The icon's SVG element.
228
+ */
189
229
  export function Monitor() {
190
230
  return (
191
231
  <svg
@@ -206,6 +246,10 @@ export function Monitor() {
206
246
  )
207
247
  }
208
248
 
249
+ /**
250
+ * Renders the Wi-Fi (online) icon.
251
+ * @returns The icon's SVG element.
252
+ */
209
253
  export function Wifi() {
210
254
  return (
211
255
  <svg
@@ -223,6 +267,10 @@ export function Wifi() {
223
267
  )
224
268
  }
225
269
 
270
+ /**
271
+ * Renders the offline icon.
272
+ * @returns The icon's SVG element.
273
+ */
226
274
  export function Offline() {
227
275
  return (
228
276
  <svg
@@ -241,6 +289,10 @@ export function Offline() {
241
289
  )
242
290
  }
243
291
 
292
+ /**
293
+ * Renders the settings icon.
294
+ * @returns The icon's SVG element.
295
+ */
244
296
  export function Settings() {
245
297
  return (
246
298
  <svg
@@ -268,6 +320,10 @@ export function Settings() {
268
320
  )
269
321
  }
270
322
 
323
+ /**
324
+ * Renders the picture-in-picture icon.
325
+ * @returns The icon's SVG element.
326
+ */
271
327
  export function PiPIcon() {
272
328
  return (
273
329
  <svg
@@ -288,6 +344,10 @@ export function PiPIcon() {
288
344
  )
289
345
  }
290
346
 
347
+ /**
348
+ * Renders the copy icon.
349
+ * @returns The icon's SVG element.
350
+ */
291
351
  export function Copier() {
292
352
  return (
293
353
  <svg
@@ -309,6 +369,10 @@ export function Copier() {
309
369
  )
310
370
  }
311
371
 
372
+ /**
373
+ * Renders the pencil (edit) icon.
374
+ * @returns The icon's SVG element.
375
+ */
312
376
  export function Pencil() {
313
377
  return (
314
378
  <svg
@@ -329,6 +393,11 @@ export function Pencil() {
329
393
  )
330
394
  }
331
395
 
396
+ /**
397
+ * Renders the icon shown after a value was copied.
398
+ * @param props - The `theme` that decides the icon's color.
399
+ * @returns The icon's SVG element.
400
+ */
332
401
  export function CopiedCopier(props: { theme: 'light' | 'dark' }) {
333
402
  return (
334
403
  <svg
@@ -349,6 +418,10 @@ export function CopiedCopier(props: { theme: 'light' | 'dark' }) {
349
418
  )
350
419
  }
351
420
 
421
+ /**
422
+ * Renders the copy error icon.
423
+ * @returns The icon's SVG element.
424
+ */
352
425
  export function ErrorCopier() {
353
426
  return (
354
427
  <svg
@@ -369,6 +442,10 @@ export function ErrorCopier() {
369
442
  )
370
443
  }
371
444
 
445
+ /**
446
+ * Renders the list icon.
447
+ * @returns The icon's SVG element.
448
+ */
372
449
  export function List() {
373
450
  return (
374
451
  <svg
@@ -388,6 +465,11 @@ export function List() {
388
465
  )
389
466
  }
390
467
 
468
+ /**
469
+ * Renders a checkbox icon.
470
+ * @param props - Whether the checkbox is `checked`, and the `theme` that decides its color.
471
+ * @returns The checked or unchecked checkbox icon.
472
+ */
391
473
  export function Check(props: { checked: boolean; theme: 'light' | 'dark' }) {
392
474
  return (
393
475
  <>
@@ -429,6 +511,10 @@ export function Check(props: { checked: boolean; theme: 'light' | 'dark' }) {
429
511
  )
430
512
  }
431
513
 
514
+ /**
515
+ * Renders the check circle icon.
516
+ * @returns The icon's SVG element.
517
+ */
432
518
  export function CheckCircle() {
433
519
  return (
434
520
  <svg
@@ -449,6 +535,10 @@ export function CheckCircle() {
449
535
  )
450
536
  }
451
537
 
538
+ /**
539
+ * Renders the loading circle icon.
540
+ * @returns The icon's SVG element.
541
+ */
452
542
  export function LoadingCircle() {
453
543
  return (
454
544
  <svg
@@ -478,6 +568,10 @@ export function LoadingCircle() {
478
568
  )
479
569
  }
480
570
 
571
+ /**
572
+ * Renders the X circle icon.
573
+ * @returns The icon's SVG element.
574
+ */
481
575
  export function XCircle() {
482
576
  return (
483
577
  <svg
@@ -498,6 +592,10 @@ export function XCircle() {
498
592
  )
499
593
  }
500
594
 
595
+ /**
596
+ * Renders the pause circle icon.
597
+ * @returns The icon's SVG element.
598
+ */
501
599
  export function PauseCircle() {
502
600
  return (
503
601
  <svg
@@ -518,6 +616,10 @@ export function PauseCircle() {
518
616
  )
519
617
  }
520
618
 
619
+ /**
620
+ * Renders the TanStack logo.
621
+ * @returns The logo's SVG element.
622
+ */
521
623
  export function TanstackLogo() {
522
624
  const id = createUniqueId()
523
625
  return (
@@ -4,6 +4,12 @@ import { DevtoolsOfflineContext } from '../contexts/DevtoolsOfflineContext'
4
4
  import type { DevtoolsOfflineState } from '../contexts/types'
5
5
  import type { ParentProps } from 'solid-js'
6
6
 
7
+ /**
8
+ * Provides its children with the offline state of the devtools `onlineManager`, and a function
9
+ * that toggles it.
10
+ * @param props - The `children` to render.
11
+ * @returns The `children`, wrapped in the context provider.
12
+ */
7
13
  export function DevtoolsOfflineProvider(props: ParentProps) {
8
14
  const [offline, setOffline] = createSignal(false)
9
15
  const context = useQueryDevtoolsContext()
@@ -3,6 +3,11 @@ import { DevtoolsStateContext } from '../contexts/DevtoolsStateContext'
3
3
  import type { DevtoolsState } from '../contexts/types'
4
4
  import type { ParentProps } from 'solid-js'
5
5
 
6
+ /**
7
+ * Provides the selected query and mutation and the panel width to its children.
8
+ * @param props - The `children` to render.
9
+ * @returns The `children`, wrapped in the context provider.
10
+ */
6
11
  export function DevtoolsStateProvider(props: ParentProps) {
7
12
  const [selectedQueryHash, setSelectedQueryHash] = createSignal<string | null>(
8
13
  null,
@@ -9,6 +9,11 @@ import type {
9
9
  import type { DevtoolsSubscriptions } from '../contexts/types'
10
10
  import type { ParentProps } from 'solid-js'
11
11
 
12
+ /**
13
+ * Provides the query and mutation cache subscription registries to its children.
14
+ * @param props - The `children` to render.
15
+ * @returns The `children`, wrapped in the context provider.
16
+ */
12
17
  export function DevtoolsSubscriptionsProvider(props: ParentProps) {
13
18
  const queryCacheSubscriptions = createCacheSubscriptionRegistry<
14
19
  QueryCache,
package/src/utils.tsx CHANGED
@@ -3,6 +3,12 @@ import { createSignal, onCleanup, onMount } from 'solid-js'
3
3
  import type { Mutation, Query } from '@tanstack/query-core'
4
4
  import type { DevtoolsPosition } from './contexts'
5
5
 
6
+ /**
7
+ * Returns the status label of a query: fetching, inactive (no observers), paused, stale, or fresh,
8
+ * checked in that order.
9
+ * @param query - The query to label.
10
+ * @returns One of `'fetching'`, `'inactive'`, `'paused'`, `'stale'`, or `'fresh'`.
11
+ */
6
12
  export function getQueryStatusLabel(query: Query) {
7
13
  return query.state.fetchStatus === 'fetching'
8
14
  ? 'fetching'
@@ -17,6 +23,12 @@ export function getQueryStatusLabel(query: Query) {
17
23
 
18
24
  type QueryStatusLabel = 'fresh' | 'stale' | 'paused' | 'inactive' | 'fetching'
19
25
 
26
+ /**
27
+ * Appends a capitalized side to a CSS property name, e.g. `border` and `left` to `borderLeft`.
28
+ * @param prop - The property name.
29
+ * @param side - The side to append.
30
+ * @returns The sided property name.
31
+ */
20
32
  export function getSidedProp<T extends string>(
21
33
  prop: T,
22
34
  side: DevtoolsPosition,
@@ -26,6 +38,12 @@ export function getSidedProp<T extends string>(
26
38
  }` as `${T}${Capitalize<DevtoolsPosition>}`
27
39
  }
28
40
 
41
+ /**
42
+ * Returns the color of a query's status: blue while fetching, gray without observers, purple while
43
+ * paused, yellow when stale, otherwise green.
44
+ * @param params - The query's `queryState`, `observerCount`, and `isStale`.
45
+ * @returns The color name.
46
+ */
29
47
  export function getQueryStatusColor({
30
48
  queryState,
31
49
  observerCount,
@@ -46,6 +64,12 @@ export function getQueryStatusColor({
46
64
  : 'green'
47
65
  }
48
66
 
67
+ /**
68
+ * Returns the color of a mutation's status: purple while paused, red on error, yellow while pending,
69
+ * green on success, otherwise gray.
70
+ * @param params - The mutation's `status` and `isPaused`.
71
+ * @returns The color name.
72
+ */
49
73
  export function getMutationStatusColor({
50
74
  status,
51
75
  isPaused,
@@ -64,6 +88,11 @@ export function getMutationStatusColor({
64
88
  : 'gray'
65
89
  }
66
90
 
91
+ /**
92
+ * Returns the color of a query status label.
93
+ * @param label - A label returned by {@link getQueryStatusLabel}.
94
+ * @returns The color name.
95
+ */
67
96
  export function getQueryStatusColorByLabel(label: QueryStatusLabel) {
68
97
  return label === 'fresh'
69
98
  ? 'green'
@@ -77,9 +106,10 @@ export function getQueryStatusColorByLabel(label: QueryStatusLabel) {
77
106
  }
78
107
 
79
108
  /**
80
- * Displays a string regardless of the type of the data
81
- * @param {unknown} value Value to be stringified
82
- * @param {boolean} beautify Formats json to multiline
109
+ * Displays a string regardless of the type of the data.
110
+ * @param value - Value to be stringified
111
+ * @param beautify - Formats json to multiline
112
+ * @returns The value serialized with `superjson`, as a JSON string.
83
113
  */
84
114
  export const displayValue = (value: unknown, beautify: boolean = false) => {
85
115
  const { json } = serialize(value)
@@ -147,10 +177,20 @@ export const mutationSortFns: Record<string, MutationSortFn> = {
147
177
  'last updated': mutationDateSort,
148
178
  }
149
179
 
180
+ /**
181
+ * Converts a length in `rem` to pixels, using the root element's font size.
182
+ * @param rem - The length in `rem`.
183
+ * @returns The length in pixels.
184
+ */
150
185
  export const convertRemToPixels = (rem: number) => {
151
186
  return rem * parseFloat(getComputedStyle(document.documentElement).fontSize)
152
187
  }
153
188
 
189
+ /**
190
+ * Tracks the user's `prefers-color-scheme` setting.
191
+ * @returns An accessor of `'light'` or `'dark'`, updated when the setting
192
+ * changes.
193
+ */
154
194
  export const getPreferredColorScheme = () => {
155
195
  const [colorScheme, setColorScheme] = createSignal<'light' | 'dark'>('dark')
156
196
 
@@ -168,11 +208,11 @@ export const getPreferredColorScheme = () => {
168
208
  }
169
209
 
170
210
  /**
171
- * updates nested data by path
172
- *
173
- * @param {unknown} oldData Data to be updated
174
- * @param {Array<string>} updatePath Path to the data to be updated
175
- * @param {unknown} value New value
211
+ * Updates nested data by path.
212
+ * @param oldData - Data to be updated
213
+ * @param updatePath - Path to the data to be updated
214
+ * @param value - New value
215
+ * @returns A copy of `oldData` with the value at `updatePath` replaced.
176
216
  */
177
217
  export const updateNestedDataByPath = (
178
218
  oldData: unknown,
@@ -242,10 +282,9 @@ export const updateNestedDataByPath = (
242
282
  }
243
283
 
244
284
  /**
245
- * Deletes nested data by path
246
- *
247
- * @param {unknown} oldData Data to be updated
248
- * @param {Array<string>} deletePath Path to the data to be deleted
285
+ * Deletes nested data by path.
286
+ * @param oldData - Data to be updated
287
+ * @param deletePath - Path to the data to be deleted
249
288
  * @returns newData without the deleted items by path
250
289
  */
251
290
  export const deleteNestedDataByPath = (
@@ -304,10 +343,15 @@ export const deleteNestedDataByPath = (
304
343
  return oldData
305
344
  }
306
345
 
307
- // Sets up the goober stylesheet
308
- // Adds a nonce to the style tag if needed
346
+ /**
347
+ * Sets up the goober stylesheet with a `nonce`, for pages with a Content Security Policy. Without a
348
+ * `nonce`, it does nothing and goober creates the stylesheet itself.
349
+ * @param nonce - The nonce to set on the style tag.
350
+ * @param target - The shadow root to add the style tag to, instead of `document.head`.
351
+ */
309
352
  export const setupStyleSheet = (nonce?: string, target?: ShadowRoot) => {
310
- if (!nonce) return // Goober reads window.__nonce__ every time it creates or accesses its style
353
+ if (!nonce)
354
+ return // Goober reads window.__nonce__ every time it creates or accesses its style
311
355
  // element (el.nonce = window.__nonce__). Without this, goober overwrites the
312
356
  // nonce we set on the pre-created element with undefined, clearing it.
313
357
  ;(window as any).__nonce__ = nonce