@tanstack/react-query-devtools 5.0.0-alpha.12 → 5.0.0-alpha.17

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 (73) hide show
  1. package/build/lib/CachePanel/ActiveQuery.d.ts +18 -0
  2. package/build/lib/CachePanel/ActiveQuery.esm.js +271 -0
  3. package/build/lib/CachePanel/ActiveQuery.esm.js.map +1 -0
  4. package/build/lib/CachePanel/ActiveQuery.js +275 -0
  5. package/build/lib/CachePanel/ActiveQuery.js.map +1 -0
  6. package/build/lib/CachePanel/ActiveQuery.mjs +257 -0
  7. package/build/lib/CachePanel/ActiveQuery.mjs.map +1 -0
  8. package/build/lib/CachePanel/CachePanel.d.ts +57 -0
  9. package/build/lib/CachePanel/CachePanel.esm.js +310 -0
  10. package/build/lib/CachePanel/CachePanel.esm.js.map +1 -0
  11. package/build/lib/CachePanel/CachePanel.js +315 -0
  12. package/build/lib/CachePanel/CachePanel.js.map +1 -0
  13. package/build/lib/CachePanel/CachePanel.mjs +310 -0
  14. package/build/lib/CachePanel/CachePanel.mjs.map +1 -0
  15. package/build/lib/CachePanel/Header/QueryStatusCount.d.ts +7 -0
  16. package/build/lib/CachePanel/Header/QueryStatusCount.esm.js +49 -0
  17. package/build/lib/CachePanel/Header/QueryStatusCount.esm.js.map +1 -0
  18. package/build/lib/CachePanel/Header/QueryStatusCount.js +53 -0
  19. package/build/lib/CachePanel/Header/QueryStatusCount.js.map +1 -0
  20. package/build/lib/CachePanel/Header/QueryStatusCount.mjs +49 -0
  21. package/build/lib/CachePanel/Header/QueryStatusCount.mjs.map +1 -0
  22. package/build/lib/CachePanel/QueryRow.d.ts +13 -0
  23. package/build/lib/CachePanel/QueryRow.esm.js +98 -0
  24. package/build/lib/CachePanel/QueryRow.esm.js.map +1 -0
  25. package/build/lib/CachePanel/QueryRow.js +102 -0
  26. package/build/lib/CachePanel/QueryRow.js.map +1 -0
  27. package/build/lib/CachePanel/QueryRow.mjs +82 -0
  28. package/build/lib/CachePanel/QueryRow.mjs.map +1 -0
  29. package/build/lib/devtools.d.ts +3 -64
  30. package/build/lib/devtools.esm.js +2 -669
  31. package/build/lib/devtools.esm.js.map +1 -1
  32. package/build/lib/devtools.js +3 -669
  33. package/build/lib/devtools.js.map +1 -1
  34. package/build/lib/devtools.mjs +2 -639
  35. package/build/lib/devtools.mjs.map +1 -1
  36. package/build/lib/index.esm.js +2 -1
  37. package/build/lib/index.esm.js.map +1 -1
  38. package/build/lib/index.js +2 -1
  39. package/build/lib/index.js.map +1 -1
  40. package/build/lib/index.mjs +2 -1
  41. package/build/lib/index.mjs.map +1 -1
  42. package/build/lib/index.prod.esm.js +754 -713
  43. package/build/lib/index.prod.esm.js.map +1 -1
  44. package/build/lib/index.prod.js +751 -710
  45. package/build/lib/index.prod.js.map +1 -1
  46. package/build/lib/index.prod.mjs +755 -714
  47. package/build/lib/index.prod.mjs.map +1 -1
  48. package/build/lib/styledComponents.esm.js +8 -0
  49. package/build/lib/styledComponents.esm.js.map +1 -1
  50. package/build/lib/styledComponents.js +8 -0
  51. package/build/lib/styledComponents.js.map +1 -1
  52. package/build/lib/styledComponents.mjs +8 -0
  53. package/build/lib/styledComponents.mjs.map +1 -1
  54. package/build/lib/types.d.ts +11 -0
  55. package/build/lib/useSubscribeToQueryCache.d.ts +3 -0
  56. package/build/lib/useSubscribeToQueryCache.esm.js +15 -0
  57. package/build/lib/useSubscribeToQueryCache.esm.js.map +1 -0
  58. package/build/lib/useSubscribeToQueryCache.js +19 -0
  59. package/build/lib/useSubscribeToQueryCache.js.map +1 -0
  60. package/build/lib/useSubscribeToQueryCache.mjs +15 -0
  61. package/build/lib/useSubscribeToQueryCache.mjs.map +1 -0
  62. package/build/umd/index.development.js +2394 -2353
  63. package/build/umd/index.development.js.map +1 -1
  64. package/package.json +1 -1
  65. package/src/CachePanel/ActiveQuery.tsx +380 -0
  66. package/src/CachePanel/CachePanel.tsx +439 -0
  67. package/src/CachePanel/Header/QueryStatusCount.tsx +93 -0
  68. package/src/CachePanel/QueryRow.tsx +125 -0
  69. package/src/__tests__/devtools.test.tsx +46 -0
  70. package/src/devtools.tsx +5 -1008
  71. package/src/styledComponents.ts +16 -0
  72. package/src/types.ts +12 -0
  73. package/src/useSubscribeToQueryCache.ts +26 -0
@@ -20,6 +20,8 @@ export const Panel = styled(
20
20
  },
21
21
  )
22
22
 
23
+ Panel.displayName = 'Panel'
24
+
23
25
  export const ActiveQueryPanel = styled(
24
26
  'div',
25
27
  () => ({
@@ -36,6 +38,8 @@ export const ActiveQueryPanel = styled(
36
38
  },
37
39
  )
38
40
 
41
+ ActiveQueryPanel.displayName = 'ActiveQueryPanel'
42
+
39
43
  export const Button = styled('button', (props, theme) => ({
40
44
  appearance: 'none',
41
45
  fontSize: '.9em',
@@ -49,6 +53,8 @@ export const Button = styled('button', (props, theme) => ({
49
53
  cursor: 'pointer',
50
54
  }))
51
55
 
56
+ Button.displayName = 'Button'
57
+
52
58
  export const QueryKeys = styled('span', {
53
59
  display: 'flex',
54
60
  flexWrap: 'wrap',
@@ -56,6 +62,8 @@ export const QueryKeys = styled('span', {
56
62
  fontSize: '0.9em',
57
63
  })
58
64
 
65
+ QueryKeys.displayName = 'QueryKeys'
66
+
59
67
  export const QueryKey = styled('span', {
60
68
  display: 'inline-flex',
61
69
  alignItems: 'center',
@@ -65,12 +73,16 @@ export const QueryKey = styled('span', {
65
73
  borderRadius: '.2em',
66
74
  })
67
75
 
76
+ QueryKey.displayName = 'QueryKey'
77
+
68
78
  export const Code = styled('code', {
69
79
  fontSize: '.9em',
70
80
  color: 'inherit',
71
81
  background: 'inherit',
72
82
  })
73
83
 
84
+ Code.displayName = 'Code'
85
+
74
86
  export const Input = styled('input', (_props, theme) => ({
75
87
  backgroundColor: theme.inputBackgroundColor,
76
88
  border: 0,
@@ -81,6 +93,8 @@ export const Input = styled('input', (_props, theme) => ({
81
93
  padding: '.3em .4em',
82
94
  }))
83
95
 
96
+ Input.displayName = 'Input'
97
+
84
98
  export const Select = styled(
85
99
  'select',
86
100
  (_props, theme) => ({
@@ -108,3 +122,5 @@ export const Select = styled(
108
122
  },
109
123
  },
110
124
  )
125
+
126
+ Select.displayName = 'Select'
package/src/types.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { Query, DefaultError } from '@tanstack/react-query'
2
+
3
+ export interface DevToolsErrorType {
4
+ /**
5
+ * The name of the error.
6
+ */
7
+ name: string
8
+ /**
9
+ * How the error is initialized.
10
+ */
11
+ initializer: (query: Query) => DefaultError
12
+ }
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import type { QueryCache } from '@tanstack/react-query'
3
+ import { notifyManager } from '@tanstack/react-query'
4
+
5
+ const useSubscribeToQueryCache = <T>(
6
+ queryCache: QueryCache,
7
+ getSnapshot: () => T,
8
+ skip: boolean = false,
9
+ ): T => {
10
+ return React.useSyncExternalStore(
11
+ React.useCallback(
12
+ (onStoreChange) => {
13
+ if (!skip)
14
+ return queryCache.subscribe(notifyManager.batchCalls(onStoreChange))
15
+ return () => {
16
+ return
17
+ }
18
+ },
19
+ [queryCache, skip],
20
+ ),
21
+ getSnapshot,
22
+ getSnapshot,
23
+ )
24
+ }
25
+
26
+ export default useSubscribeToQueryCache