@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/src/contexts/types.ts
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
MutationCache,
|
|
3
|
+
MutationCacheNotifyEvent,
|
|
4
|
+
Query,
|
|
5
|
+
QueryCache,
|
|
6
|
+
QueryCacheNotifyEvent,
|
|
7
|
+
QueryClient,
|
|
8
|
+
onlineManager,
|
|
9
|
+
} from '@tanstack/query-core'
|
|
10
|
+
import type { Accessor, Setter } from 'solid-js'
|
|
11
|
+
import type { createCacheSubscriptionRegistry } from '../createCacheSubscriptionRegistry'
|
|
2
12
|
|
|
3
13
|
type XPosition = 'left' | 'right'
|
|
4
14
|
type YPosition = 'top' | 'bottom'
|
|
5
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The side of the screen the devtools panel opens on.
|
|
18
|
+
*/
|
|
6
19
|
export type DevtoolsPosition = XPosition | YPosition
|
|
20
|
+
/**
|
|
21
|
+
* The corner of the screen the toggle button is placed in, or `'relative'` to place it in the
|
|
22
|
+
* normal document flow.
|
|
23
|
+
*/
|
|
7
24
|
export type DevtoolsButtonPosition = `${YPosition}-${XPosition}` | 'relative'
|
|
25
|
+
/**
|
|
26
|
+
* The color theme of the devtools. `'system'` follows the user's color scheme preference.
|
|
27
|
+
*/
|
|
8
28
|
export type Theme = 'dark' | 'light' | 'system'
|
|
9
29
|
|
|
30
|
+
/**
|
|
31
|
+
* A custom error that can be triggered on a query from the devtools.
|
|
32
|
+
*/
|
|
10
33
|
export interface DevtoolsErrorType {
|
|
11
34
|
/**
|
|
12
35
|
* The name of the error.
|
|
@@ -18,18 +41,127 @@ export interface DevtoolsErrorType {
|
|
|
18
41
|
initializer: (query: Query) => Error
|
|
19
42
|
}
|
|
20
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The options shared by every devtools entry point: the `client` to inspect, the adapter's
|
|
46
|
+
* `queryFlavor` and `version` shown in the header, and the display options.
|
|
47
|
+
* `onClose` is only used by the panel entry point.
|
|
48
|
+
*/
|
|
21
49
|
export interface QueryDevtoolsProps {
|
|
50
|
+
/**
|
|
51
|
+
* The `QueryClient` whose caches the devtools inspect.
|
|
52
|
+
*/
|
|
22
53
|
readonly client: QueryClient
|
|
54
|
+
/**
|
|
55
|
+
* The adapter name shown next to the logo in the header, e.g. `'React Query'`.
|
|
56
|
+
*/
|
|
23
57
|
queryFlavor: string
|
|
58
|
+
/**
|
|
59
|
+
* The adapter version shown next to `queryFlavor` in the header.
|
|
60
|
+
*/
|
|
24
61
|
version: string
|
|
62
|
+
/**
|
|
63
|
+
* The `onlineManager` the devtools read and toggle to simulate going offline.
|
|
64
|
+
*/
|
|
25
65
|
onlineManager: typeof onlineManager
|
|
26
66
|
|
|
67
|
+
/**
|
|
68
|
+
* The position of the TanStack logo to open and close the devtools panel.
|
|
69
|
+
*/
|
|
27
70
|
buttonPosition?: DevtoolsButtonPosition
|
|
71
|
+
/**
|
|
72
|
+
* The position of the devtools panel.
|
|
73
|
+
*/
|
|
28
74
|
position?: DevtoolsPosition
|
|
75
|
+
/**
|
|
76
|
+
* Set this to `true` if you want the devtools to default to being open.
|
|
77
|
+
*/
|
|
29
78
|
initialIsOpen?: boolean
|
|
79
|
+
/**
|
|
80
|
+
* Use this so you can define custom errors that can be shown in the devtools.
|
|
81
|
+
*/
|
|
30
82
|
errorTypes?: Array<DevtoolsErrorType>
|
|
83
|
+
/**
|
|
84
|
+
* Use this to pass a shadow DOM target to the devtools so that the styles will be applied
|
|
85
|
+
* within the shadow DOM instead of within the head tag in the light DOM.
|
|
86
|
+
*/
|
|
31
87
|
shadowDOMTarget?: ShadowRoot
|
|
88
|
+
/**
|
|
89
|
+
* Callback function that is called when the devtools panel is closed. Only used by the panel
|
|
90
|
+
* entry point.
|
|
91
|
+
*/
|
|
32
92
|
onClose?: () => void
|
|
93
|
+
/**
|
|
94
|
+
* Set this to `true` to hide disabled queries from the devtools panel.
|
|
95
|
+
*/
|
|
33
96
|
hideDisabledQueries?: boolean
|
|
97
|
+
/**
|
|
98
|
+
* Set this to `'light'`, `'dark'`, or `'system'` to change the theme of the devtools panel.
|
|
99
|
+
*/
|
|
34
100
|
theme?: Theme
|
|
35
101
|
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The devtools UI state: the selected query and mutation, and the panel width.
|
|
105
|
+
*/
|
|
106
|
+
export interface DevtoolsState {
|
|
107
|
+
/**
|
|
108
|
+
* The hash of the query whose details are shown, or `null` if none is selected.
|
|
109
|
+
*/
|
|
110
|
+
selectedQueryHash: Accessor<string | null>
|
|
111
|
+
/**
|
|
112
|
+
* Selects a query by its hash, or clears the selection with `null`.
|
|
113
|
+
*/
|
|
114
|
+
setSelectedQueryHash: Setter<string | null>
|
|
115
|
+
/**
|
|
116
|
+
* The `mutationId` of the mutation whose details are shown, or `null` if none is selected.
|
|
117
|
+
*/
|
|
118
|
+
selectedMutationId: Accessor<number | null>
|
|
119
|
+
/**
|
|
120
|
+
* Selects a mutation by its `mutationId`, or clears the selection with `null`.
|
|
121
|
+
*/
|
|
122
|
+
setSelectedMutationId: Setter<number | null>
|
|
123
|
+
/**
|
|
124
|
+
* The current width of the devtools panel in pixels, used for the responsive layout.
|
|
125
|
+
*/
|
|
126
|
+
panelWidth: Accessor<number>
|
|
127
|
+
/**
|
|
128
|
+
* Updates the stored panel width, e.g. when the panel is resized.
|
|
129
|
+
*/
|
|
130
|
+
setPanelWidth: Setter<number>
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The registries through which devtools components subscribe to the query cache and the mutation
|
|
135
|
+
* cache, each one only updating for the cache events it cares about.
|
|
136
|
+
*/
|
|
137
|
+
export interface DevtoolsSubscriptions {
|
|
138
|
+
/**
|
|
139
|
+
* The registry through which devtools components subscribe to query cache events.
|
|
140
|
+
*/
|
|
141
|
+
queryCacheSubscriptions: ReturnType<
|
|
142
|
+
typeof createCacheSubscriptionRegistry<QueryCache, QueryCacheNotifyEvent>
|
|
143
|
+
>
|
|
144
|
+
/**
|
|
145
|
+
* The registry through which devtools components subscribe to mutation cache events.
|
|
146
|
+
*/
|
|
147
|
+
mutationCacheSubscriptions: ReturnType<
|
|
148
|
+
typeof createCacheSubscriptionRegistry<
|
|
149
|
+
MutationCache,
|
|
150
|
+
MutationCacheNotifyEvent
|
|
151
|
+
>
|
|
152
|
+
>
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Whether the devtools' `onlineManager` is offline, and a function that toggles it.
|
|
157
|
+
*/
|
|
158
|
+
export interface DevtoolsOfflineState {
|
|
159
|
+
/**
|
|
160
|
+
* Whether the devtools' `onlineManager` is currently offline.
|
|
161
|
+
*/
|
|
162
|
+
offline: Accessor<boolean>
|
|
163
|
+
/**
|
|
164
|
+
* Switches the devtools' `onlineManager` between online and offline.
|
|
165
|
+
*/
|
|
166
|
+
toggleOffline: () => void
|
|
167
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { onCleanup } from 'solid-js'
|
|
2
|
+
import type { Accessor, Setter } from 'solid-js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a registry of components subscribed to a cache, so each one only updates for the cache
|
|
6
|
+
* events it cares about.
|
|
7
|
+
* @returns The `register` and `notify` functions of the registry.
|
|
8
|
+
*/
|
|
9
|
+
export function createCacheSubscriptionRegistry<TCache, TEvent>() {
|
|
10
|
+
const subscriptions = new Map<
|
|
11
|
+
symbol,
|
|
12
|
+
{
|
|
13
|
+
shouldUpdate: (event: TEvent) => boolean
|
|
14
|
+
update: (cache: Accessor<TCache>) => void
|
|
15
|
+
}
|
|
16
|
+
>()
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Registers a subscription that is removed when the current owner is cleaned up.
|
|
20
|
+
* @param callback - Computes the value from the cache.
|
|
21
|
+
* @param setter - Receives the computed value on every update.
|
|
22
|
+
* @param shouldUpdate - Decides whether an event updates this subscription. Defaults to every
|
|
23
|
+
* event.
|
|
24
|
+
*/
|
|
25
|
+
function register<T>(
|
|
26
|
+
callback: (cache: Accessor<TCache>) => Exclude<T, Function>,
|
|
27
|
+
setter: Setter<T>,
|
|
28
|
+
shouldUpdate: (event: TEvent) => boolean = () => true,
|
|
29
|
+
) {
|
|
30
|
+
const id = Symbol()
|
|
31
|
+
subscriptions.set(id, {
|
|
32
|
+
shouldUpdate,
|
|
33
|
+
update: (cache) => setter(callback(cache)),
|
|
34
|
+
})
|
|
35
|
+
onCleanup(() => subscriptions.delete(id))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Updates every subscription whose `shouldUpdate` accepts the event.
|
|
40
|
+
* @param cache - The cache to compute the values from.
|
|
41
|
+
* @param event - The cache event.
|
|
42
|
+
* @param schedule - Runs each update. Defaults to running it right away.
|
|
43
|
+
*/
|
|
44
|
+
function notify(
|
|
45
|
+
cache: Accessor<TCache>,
|
|
46
|
+
event: TEvent,
|
|
47
|
+
schedule: (update: () => void) => void = (update) => update(),
|
|
48
|
+
) {
|
|
49
|
+
for (const [id, subscription] of subscriptions) {
|
|
50
|
+
if (!subscription.shouldUpdate(event)) continue
|
|
51
|
+
schedule(() => {
|
|
52
|
+
if (subscriptions.has(id)) subscription.update(cache)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { register, notify }
|
|
58
|
+
}
|
package/src/icons/index.tsx
CHANGED
|
@@ -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 (
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createEffect, createSignal, onCleanup } from 'solid-js'
|
|
2
|
+
import { useQueryDevtoolsContext } from '../contexts/QueryDevtoolsContext'
|
|
3
|
+
import { DevtoolsOfflineContext } from '../contexts/DevtoolsOfflineContext'
|
|
4
|
+
import type { DevtoolsOfflineState } from '../contexts/types'
|
|
5
|
+
import type { ParentProps } from 'solid-js'
|
|
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
|
+
*/
|
|
13
|
+
export function DevtoolsOfflineProvider(props: ParentProps) {
|
|
14
|
+
const [offline, setOffline] = createSignal(false)
|
|
15
|
+
const context = useQueryDevtoolsContext()
|
|
16
|
+
|
|
17
|
+
createEffect(() => {
|
|
18
|
+
const manager = context.onlineManager
|
|
19
|
+
setOffline(!manager.isOnline())
|
|
20
|
+
const unsubscribe = manager.subscribe((online) => setOffline(!online))
|
|
21
|
+
onCleanup(unsubscribe)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const state: DevtoolsOfflineState = {
|
|
25
|
+
offline,
|
|
26
|
+
toggleOffline: () => {
|
|
27
|
+
const manager = context.onlineManager
|
|
28
|
+
manager.setOnline(!manager.isOnline())
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<DevtoolsOfflineContext.Provider value={state}>
|
|
34
|
+
{props.children}
|
|
35
|
+
</DevtoolsOfflineContext.Provider>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createSignal } from 'solid-js'
|
|
2
|
+
import { DevtoolsStateContext } from '../contexts/DevtoolsStateContext'
|
|
3
|
+
import type { DevtoolsState } from '../contexts/types'
|
|
4
|
+
import type { ParentProps } from 'solid-js'
|
|
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
|
+
*/
|
|
11
|
+
export function DevtoolsStateProvider(props: ParentProps) {
|
|
12
|
+
const [selectedQueryHash, setSelectedQueryHash] = createSignal<string | null>(
|
|
13
|
+
null,
|
|
14
|
+
)
|
|
15
|
+
const [selectedMutationId, setSelectedMutationId] = createSignal<
|
|
16
|
+
number | null
|
|
17
|
+
>(null)
|
|
18
|
+
const [panelWidth, setPanelWidth] = createSignal(0)
|
|
19
|
+
|
|
20
|
+
const state: DevtoolsState = {
|
|
21
|
+
selectedQueryHash,
|
|
22
|
+
setSelectedQueryHash,
|
|
23
|
+
selectedMutationId,
|
|
24
|
+
setSelectedMutationId,
|
|
25
|
+
panelWidth,
|
|
26
|
+
setPanelWidth,
|
|
27
|
+
}
|
|
28
|
+
return (
|
|
29
|
+
<DevtoolsStateContext.Provider value={state}>
|
|
30
|
+
{props.children}
|
|
31
|
+
</DevtoolsStateContext.Provider>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createCacheSubscriptionRegistry } from '../createCacheSubscriptionRegistry'
|
|
2
|
+
import { DevtoolsSubscriptionsContext } from '../contexts/DevtoolsSubscriptionsContext'
|
|
3
|
+
import type {
|
|
4
|
+
MutationCache,
|
|
5
|
+
MutationCacheNotifyEvent,
|
|
6
|
+
QueryCache,
|
|
7
|
+
QueryCacheNotifyEvent,
|
|
8
|
+
} from '@tanstack/query-core'
|
|
9
|
+
import type { DevtoolsSubscriptions } from '../contexts/types'
|
|
10
|
+
import type { ParentProps } from 'solid-js'
|
|
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
|
+
*/
|
|
17
|
+
export function DevtoolsSubscriptionsProvider(props: ParentProps) {
|
|
18
|
+
const queryCacheSubscriptions = createCacheSubscriptionRegistry<
|
|
19
|
+
QueryCache,
|
|
20
|
+
QueryCacheNotifyEvent
|
|
21
|
+
>()
|
|
22
|
+
const mutationCacheSubscriptions = createCacheSubscriptionRegistry<
|
|
23
|
+
MutationCache,
|
|
24
|
+
MutationCacheNotifyEvent
|
|
25
|
+
>()
|
|
26
|
+
const subscriptions: DevtoolsSubscriptions = {
|
|
27
|
+
queryCacheSubscriptions,
|
|
28
|
+
mutationCacheSubscriptions,
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<DevtoolsSubscriptionsContext.Provider value={subscriptions}>
|
|
32
|
+
{props.children}
|
|
33
|
+
</DevtoolsSubscriptionsContext.Provider>
|
|
34
|
+
)
|
|
35
|
+
}
|