@tanstack/query-devtools 5.0.0-rc.5 → 5.0.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/Devtools/{5OOWR6BQ.jsx → 3BAJISSX.jsx} +604 -266
- package/build/Devtools/{CIR3WCBJ.js → 4TNE5QTO.js} +733 -428
- package/build/Devtools/{336SHOD5.jsx → OWSLDUSP.jsx} +604 -266
- package/build/Devtools/{XXDYGLB2.js → YSRICXZI.js} +733 -428
- package/build/dev.cjs +781 -464
- package/build/dev.js +42 -32
- package/build/dev.jsx +42 -32
- package/build/index.cjs +781 -464
- package/build/index.d.cts +1 -14
- package/build/index.d.ts +1 -14
- package/build/index.js +42 -32
- package/build/index.jsx +42 -32
- package/package.json +4 -4
- package/src/Context.ts +9 -0
- package/src/Devtools.tsx +422 -206
- package/src/Explorer.tsx +140 -61
- package/src/icons/index.tsx +118 -19
- package/src/index.tsx +41 -41
- package/src/utils.tsx +17 -0
package/src/index.tsx
CHANGED
|
@@ -17,17 +17,17 @@ export type { DevtoolsButtonPosition, DevtoolsPosition, DevToolsErrorType }
|
|
|
17
17
|
export interface TanstackQueryDevtoolsConfig extends QueryDevtoolsProps {}
|
|
18
18
|
|
|
19
19
|
class TanstackQueryDevtools {
|
|
20
|
-
client: Signal<QueryClient>
|
|
21
|
-
onlineManager: typeof TonlineManager
|
|
22
|
-
queryFlavor: string
|
|
23
|
-
version: string
|
|
24
|
-
isMounted = false
|
|
25
|
-
buttonPosition: Signal<DevtoolsButtonPosition | undefined>
|
|
26
|
-
position: Signal<DevtoolsPosition | undefined>
|
|
27
|
-
initialIsOpen: Signal<boolean | undefined>
|
|
28
|
-
errorTypes: Signal<Array<DevToolsErrorType> | undefined>
|
|
29
|
-
Component: typeof DevtoolsComponent | undefined
|
|
30
|
-
dispose?: () => void
|
|
20
|
+
#client: Signal<QueryClient>
|
|
21
|
+
#onlineManager: typeof TonlineManager
|
|
22
|
+
#queryFlavor: string
|
|
23
|
+
#version: string
|
|
24
|
+
#isMounted = false
|
|
25
|
+
#buttonPosition: Signal<DevtoolsButtonPosition | undefined>
|
|
26
|
+
#position: Signal<DevtoolsPosition | undefined>
|
|
27
|
+
#initialIsOpen: Signal<boolean | undefined>
|
|
28
|
+
#errorTypes: Signal<Array<DevToolsErrorType> | undefined>
|
|
29
|
+
#Component: typeof DevtoolsComponent | undefined
|
|
30
|
+
#dispose?: () => void
|
|
31
31
|
|
|
32
32
|
constructor(config: TanstackQueryDevtoolsConfig) {
|
|
33
33
|
const {
|
|
@@ -40,61 +40,61 @@ class TanstackQueryDevtools {
|
|
|
40
40
|
initialIsOpen,
|
|
41
41
|
errorTypes,
|
|
42
42
|
} = config
|
|
43
|
-
this
|
|
44
|
-
this
|
|
45
|
-
this
|
|
46
|
-
this
|
|
47
|
-
this
|
|
48
|
-
this
|
|
49
|
-
this
|
|
50
|
-
this
|
|
43
|
+
this.#client = createSignal(client)
|
|
44
|
+
this.#queryFlavor = queryFlavor
|
|
45
|
+
this.#version = version
|
|
46
|
+
this.#onlineManager = onlineManager
|
|
47
|
+
this.#buttonPosition = createSignal(buttonPosition)
|
|
48
|
+
this.#position = createSignal(position)
|
|
49
|
+
this.#initialIsOpen = createSignal(initialIsOpen)
|
|
50
|
+
this.#errorTypes = createSignal(errorTypes)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
setButtonPosition(position: DevtoolsButtonPosition) {
|
|
54
|
-
this
|
|
54
|
+
this.#buttonPosition[1](position)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
setPosition(position: DevtoolsPosition) {
|
|
58
|
-
this
|
|
58
|
+
this.#position[1](position)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
setInitialIsOpen(isOpen: boolean) {
|
|
62
|
-
this
|
|
62
|
+
this.#initialIsOpen[1](isOpen)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
setErrorTypes(errorTypes: Array<DevToolsErrorType>) {
|
|
66
|
-
this
|
|
66
|
+
this.#errorTypes[1](errorTypes)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
setClient(client: QueryClient) {
|
|
70
|
-
this
|
|
70
|
+
this.#client[1](client)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
mount<T extends HTMLElement>(el: T) {
|
|
74
|
-
if (this
|
|
74
|
+
if (this.#isMounted) {
|
|
75
75
|
throw new Error('Devtools is already mounted')
|
|
76
76
|
}
|
|
77
77
|
const dispose = render(() => {
|
|
78
|
-
const [btnPosition] = this
|
|
79
|
-
const [pos] = this
|
|
80
|
-
const [isOpen] = this
|
|
81
|
-
const [errors] = this
|
|
82
|
-
const [queryClient] = this
|
|
78
|
+
const [btnPosition] = this.#buttonPosition
|
|
79
|
+
const [pos] = this.#position
|
|
80
|
+
const [isOpen] = this.#initialIsOpen
|
|
81
|
+
const [errors] = this.#errorTypes
|
|
82
|
+
const [queryClient] = this.#client
|
|
83
83
|
|
|
84
84
|
let Devtools: typeof DevtoolsComponent
|
|
85
85
|
|
|
86
|
-
if (this
|
|
87
|
-
Devtools = this
|
|
86
|
+
if (this.#Component) {
|
|
87
|
+
Devtools = this.#Component
|
|
88
88
|
} else {
|
|
89
89
|
Devtools = lazy(() => import('./Devtools'))
|
|
90
|
-
this
|
|
90
|
+
this.#Component = Devtools
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
return (
|
|
94
94
|
<Devtools
|
|
95
|
-
queryFlavor={this
|
|
96
|
-
version={this
|
|
97
|
-
onlineManager={this
|
|
95
|
+
queryFlavor={this.#queryFlavor}
|
|
96
|
+
version={this.#version}
|
|
97
|
+
onlineManager={this.#onlineManager}
|
|
98
98
|
{...{
|
|
99
99
|
get client() {
|
|
100
100
|
return queryClient()
|
|
@@ -115,16 +115,16 @@ class TanstackQueryDevtools {
|
|
|
115
115
|
/>
|
|
116
116
|
)
|
|
117
117
|
}, el)
|
|
118
|
-
this
|
|
119
|
-
this
|
|
118
|
+
this.#isMounted = true
|
|
119
|
+
this.#dispose = dispose
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
unmount() {
|
|
123
|
-
if (!this
|
|
123
|
+
if (!this.#isMounted) {
|
|
124
124
|
throw new Error('Devtools is not mounted')
|
|
125
125
|
}
|
|
126
|
-
this
|
|
127
|
-
this
|
|
126
|
+
this.#dispose?.()
|
|
127
|
+
this.#isMounted = false
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
package/src/utils.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { serialize } from 'superjson'
|
|
2
|
+
import { createSignal, onCleanup, onMount } from 'solid-js'
|
|
2
3
|
import type { Query } from '@tanstack/query-core'
|
|
3
4
|
import type { DevtoolsPosition } from './Context'
|
|
4
5
|
|
|
@@ -112,6 +113,22 @@ export const convertRemToPixels = (rem: number) => {
|
|
|
112
113
|
|
|
113
114
|
export const convertPixelsToRem = (px: number) => px / convertRemToPixels(1)
|
|
114
115
|
|
|
116
|
+
export const getPreferredColorScheme = () => {
|
|
117
|
+
const [colorScheme, setColorScheme] = createSignal<'light' | 'dark'>('dark')
|
|
118
|
+
|
|
119
|
+
onMount(() => {
|
|
120
|
+
const query = window.matchMedia('(prefers-color-scheme: dark)')
|
|
121
|
+
setColorScheme(query.matches ? 'dark' : 'light')
|
|
122
|
+
const listener = (e: MediaQueryListEvent) => {
|
|
123
|
+
setColorScheme(e.matches ? 'dark' : 'light')
|
|
124
|
+
}
|
|
125
|
+
query.addEventListener('change', listener)
|
|
126
|
+
onCleanup(() => query.removeEventListener('change', listener))
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
return colorScheme
|
|
130
|
+
}
|
|
131
|
+
|
|
115
132
|
/**
|
|
116
133
|
* updates nested data by path
|
|
117
134
|
*
|