@tanstack/react-query-devtools 5.0.0-alpha.2 → 5.0.0-alpha.23
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/lib/CachePanel/ActiveQuery.d.ts +18 -0
- package/build/lib/CachePanel/ActiveQuery.esm.js +271 -0
- package/build/lib/CachePanel/ActiveQuery.esm.js.map +1 -0
- package/build/lib/CachePanel/ActiveQuery.js +275 -0
- package/build/lib/CachePanel/ActiveQuery.js.map +1 -0
- package/build/lib/CachePanel/ActiveQuery.mjs +257 -0
- package/build/lib/CachePanel/ActiveQuery.mjs.map +1 -0
- package/build/lib/CachePanel/CachePanel.d.ts +57 -0
- package/build/lib/CachePanel/CachePanel.esm.js +310 -0
- package/build/lib/CachePanel/CachePanel.esm.js.map +1 -0
- package/build/lib/CachePanel/CachePanel.js +315 -0
- package/build/lib/CachePanel/CachePanel.js.map +1 -0
- package/build/lib/CachePanel/CachePanel.mjs +310 -0
- package/build/lib/CachePanel/CachePanel.mjs.map +1 -0
- package/build/lib/CachePanel/Header/QueryStatusCount.d.ts +7 -0
- package/build/lib/CachePanel/Header/QueryStatusCount.esm.js +49 -0
- package/build/lib/CachePanel/Header/QueryStatusCount.esm.js.map +1 -0
- package/build/lib/CachePanel/Header/QueryStatusCount.js +53 -0
- package/build/lib/CachePanel/Header/QueryStatusCount.js.map +1 -0
- package/build/lib/CachePanel/Header/QueryStatusCount.mjs +49 -0
- package/build/lib/CachePanel/Header/QueryStatusCount.mjs.map +1 -0
- package/build/lib/CachePanel/QueryRow.d.ts +13 -0
- package/build/lib/CachePanel/QueryRow.esm.js +98 -0
- package/build/lib/CachePanel/QueryRow.esm.js.map +1 -0
- package/build/lib/CachePanel/QueryRow.js +102 -0
- package/build/lib/CachePanel/QueryRow.js.map +1 -0
- package/build/lib/CachePanel/QueryRow.mjs +82 -0
- package/build/lib/CachePanel/QueryRow.mjs.map +1 -0
- package/build/lib/Explorer.esm.js +2 -1
- package/build/lib/Explorer.esm.js.map +1 -1
- package/build/lib/Explorer.js +2 -1
- package/build/lib/Explorer.js.map +1 -1
- package/build/lib/Explorer.mjs +1 -0
- package/build/lib/Explorer.mjs.map +1 -1
- package/build/lib/devtools.d.ts +5 -48
- package/build/lib/devtools.esm.js +11 -550
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +12 -551
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +7 -547
- package/build/lib/devtools.mjs.map +1 -1
- package/build/lib/index.esm.js +3 -1
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +3 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +3 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/index.prod.esm.js +821 -651
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +819 -650
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +764 -625
- package/build/lib/index.prod.mjs.map +1 -1
- package/build/lib/styledComponents.d.ts +0 -1
- package/build/lib/styledComponents.esm.js +11 -1
- package/build/lib/styledComponents.esm.js.map +1 -1
- package/build/lib/styledComponents.js +11 -1
- package/build/lib/styledComponents.js.map +1 -1
- package/build/lib/styledComponents.mjs +11 -1
- package/build/lib/styledComponents.mjs.map +1 -1
- package/build/lib/theme.esm.js +1 -0
- package/build/lib/theme.esm.js.map +1 -1
- package/build/lib/theme.js +1 -0
- package/build/lib/theme.js.map +1 -1
- package/build/lib/theme.mjs +1 -0
- package/build/lib/theme.mjs.map +1 -1
- package/build/lib/types.d.ts +11 -0
- package/build/lib/useSubscribeToQueryCache.d.ts +3 -0
- package/build/lib/useSubscribeToQueryCache.esm.js +15 -0
- package/build/lib/useSubscribeToQueryCache.esm.js.map +1 -0
- package/build/lib/useSubscribeToQueryCache.js +19 -0
- package/build/lib/useSubscribeToQueryCache.js.map +1 -0
- package/build/lib/useSubscribeToQueryCache.mjs +15 -0
- package/build/lib/useSubscribeToQueryCache.mjs.map +1 -0
- package/build/umd/index.development.js +1667 -1529
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +4 -4
- package/src/CachePanel/ActiveQuery.tsx +380 -0
- package/src/CachePanel/CachePanel.tsx +439 -0
- package/src/CachePanel/Header/QueryStatusCount.tsx +93 -0
- package/src/CachePanel/QueryRow.tsx +125 -0
- package/src/__tests__/Explorer.test.tsx +3 -2
- package/src/__tests__/devtools.test.tsx +229 -9
- package/src/devtools.tsx +10 -865
- package/src/styledComponents.ts +19 -1
- package/src/types.ts +12 -0
- package/src/useSubscribeToQueryCache.ts +26 -0
package/build/lib/devtools.mjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
3
|
import * as React from 'react';
|
|
3
|
-
import { useQueryClient, onlineManager, notifyManager } from '@tanstack/react-query';
|
|
4
|
-
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
5
4
|
import useLocalStorage from './useLocalStorage.mjs';
|
|
6
|
-
import { defaultPanelSize, useIsMounted, getSidedProp, getSidePanelStyle,
|
|
7
|
-
import { Panel, Select, Input, Button, ActiveQueryPanel, Code, QueryKeys, QueryKey } from './styledComponents.mjs';
|
|
5
|
+
import { defaultPanelSize, useIsMounted, getSidedProp, getSidePanelStyle, isVerticalSide, minPanelSize } from './utils.mjs';
|
|
8
6
|
import ScreenReader from './screenreader.mjs';
|
|
9
7
|
import { defaultTheme, ThemeProvider } from './theme.mjs';
|
|
10
|
-
import Explorer from './Explorer.mjs';
|
|
11
8
|
import Logo from './Logo.mjs';
|
|
9
|
+
import ReactQueryDevtoolsPanel from './CachePanel/CachePanel.mjs';
|
|
12
10
|
|
|
13
11
|
function ReactQueryDevtools({
|
|
14
12
|
initialIsOpen,
|
|
@@ -19,7 +17,8 @@ function ReactQueryDevtools({
|
|
|
19
17
|
containerElement: Container = 'aside',
|
|
20
18
|
queryClient,
|
|
21
19
|
styleNonce,
|
|
22
|
-
panelPosition: initialPanelPosition = 'bottom'
|
|
20
|
+
panelPosition: initialPanelPosition = 'bottom',
|
|
21
|
+
errorTypes = []
|
|
23
22
|
}) {
|
|
24
23
|
const rootRef = React.useRef(null);
|
|
25
24
|
const panelRef = React.useRef(null);
|
|
@@ -184,7 +183,8 @@ function ReactQueryDevtools({
|
|
|
184
183
|
style: style,
|
|
185
184
|
isOpen: isResolvedOpen,
|
|
186
185
|
setIsOpen: setIsOpen,
|
|
187
|
-
onDragStart: e => handleDragStart(panelRef.current, e)
|
|
186
|
+
onDragStart: e => handleDragStart(panelRef.current, e),
|
|
187
|
+
errorTypes: errorTypes
|
|
188
188
|
}))), !isResolvedOpen ? /*#__PURE__*/React.createElement("button", _extends({
|
|
189
189
|
type: "button"
|
|
190
190
|
}, otherToggleButtonProps, {
|
|
@@ -228,546 +228,6 @@ function ReactQueryDevtools({
|
|
|
228
228
|
text: "Open React Query Devtools"
|
|
229
229
|
})) : null);
|
|
230
230
|
}
|
|
231
|
-
const useSubscribeToQueryCache = (queryCache, getSnapshot, skip = false) => {
|
|
232
|
-
return React.useSyncExternalStore(React.useCallback(onStoreChange => {
|
|
233
|
-
if (!skip) return queryCache.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
234
|
-
return () => {
|
|
235
|
-
return;
|
|
236
|
-
};
|
|
237
|
-
}, [queryCache, skip]), getSnapshot, getSnapshot);
|
|
238
|
-
};
|
|
239
|
-
const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
|
|
240
|
-
const {
|
|
241
|
-
isOpen = true,
|
|
242
|
-
styleNonce,
|
|
243
|
-
setIsOpen,
|
|
244
|
-
queryClient,
|
|
245
|
-
onDragStart,
|
|
246
|
-
onPositionChange,
|
|
247
|
-
showCloseButton,
|
|
248
|
-
position,
|
|
249
|
-
closeButtonProps = {},
|
|
250
|
-
...panelProps
|
|
251
|
-
} = props;
|
|
252
|
-
const {
|
|
253
|
-
onClick: onCloseClick,
|
|
254
|
-
...otherCloseButtonProps
|
|
255
|
-
} = closeButtonProps;
|
|
256
|
-
const client = useQueryClient(queryClient);
|
|
257
|
-
const queryCache = client.getQueryCache();
|
|
258
|
-
const [sort, setSort] = useLocalStorage('reactQueryDevtoolsSortFn', Object.keys(sortFns)[0]);
|
|
259
|
-
const [filter, setFilter] = useLocalStorage('reactQueryDevtoolsFilter', '');
|
|
260
|
-
const [baseSort, setBaseSort] = useLocalStorage('reactQueryDevtoolsBaseSort', 1);
|
|
261
|
-
const sortFn = React.useMemo(() => sortFns[sort], [sort]);
|
|
262
|
-
const queriesCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().length, !isOpen);
|
|
263
|
-
const [activeQueryHash, setActiveQueryHash] = useLocalStorage('reactQueryDevtoolsActiveQueryHash', '');
|
|
264
|
-
const queries = React.useMemo(() => {
|
|
265
|
-
const unsortedQueries = queryCache.getAll();
|
|
266
|
-
if (queriesCount === 0) {
|
|
267
|
-
return [];
|
|
268
|
-
}
|
|
269
|
-
const filtered = filter ? unsortedQueries.filter(item => rankItem(item.queryHash, filter).passed) : [...unsortedQueries];
|
|
270
|
-
const sorted = sortFn ? filtered.sort((a, b) => sortFn(a, b) * baseSort) : filtered;
|
|
271
|
-
return sorted;
|
|
272
|
-
}, [baseSort, sortFn, filter, queriesCount, queryCache]);
|
|
273
|
-
const [isMockOffline, setMockOffline] = React.useState(false);
|
|
274
|
-
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
275
|
-
theme: defaultTheme
|
|
276
|
-
}, /*#__PURE__*/React.createElement(Panel, _extends({
|
|
277
|
-
ref: ref,
|
|
278
|
-
className: "ReactQueryDevtoolsPanel",
|
|
279
|
-
"aria-label": "React Query Devtools Panel",
|
|
280
|
-
id: "ReactQueryDevtoolsPanel"
|
|
281
|
-
}, panelProps, {
|
|
282
|
-
style: {
|
|
283
|
-
height: defaultPanelSize,
|
|
284
|
-
position: 'relative',
|
|
285
|
-
...panelProps.style
|
|
286
|
-
}
|
|
287
|
-
}), /*#__PURE__*/React.createElement("style", {
|
|
288
|
-
nonce: styleNonce,
|
|
289
|
-
dangerouslySetInnerHTML: {
|
|
290
|
-
__html: `
|
|
291
|
-
.ReactQueryDevtoolsPanel * {
|
|
292
|
-
scrollbar-color: ${defaultTheme.backgroundAlt} ${defaultTheme.gray};
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {
|
|
296
|
-
width: 1em;
|
|
297
|
-
height: 1em;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
.ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {
|
|
301
|
-
background: ${defaultTheme.backgroundAlt};
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
.ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {
|
|
305
|
-
background: ${defaultTheme.gray};
|
|
306
|
-
border-radius: .5em;
|
|
307
|
-
border: 3px solid ${defaultTheme.backgroundAlt};
|
|
308
|
-
}
|
|
309
|
-
`
|
|
310
|
-
}
|
|
311
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
312
|
-
style: getResizeHandleStyle(position),
|
|
313
|
-
onMouseDown: onDragStart
|
|
314
|
-
}), isOpen && /*#__PURE__*/React.createElement("div", {
|
|
315
|
-
style: {
|
|
316
|
-
flex: '1 1 500px',
|
|
317
|
-
minHeight: '40%',
|
|
318
|
-
maxHeight: '100%',
|
|
319
|
-
overflow: 'auto',
|
|
320
|
-
borderRight: `1px solid ${defaultTheme.grayAlt}`,
|
|
321
|
-
display: 'flex',
|
|
322
|
-
flexDirection: 'column'
|
|
323
|
-
}
|
|
324
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
325
|
-
style: {
|
|
326
|
-
padding: '.5em',
|
|
327
|
-
background: defaultTheme.backgroundAlt,
|
|
328
|
-
display: 'flex',
|
|
329
|
-
justifyContent: 'space-between',
|
|
330
|
-
alignItems: 'center'
|
|
331
|
-
}
|
|
332
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
333
|
-
type: "button",
|
|
334
|
-
"aria-label": "Close React Query Devtools",
|
|
335
|
-
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
336
|
-
"aria-haspopup": "true",
|
|
337
|
-
"aria-expanded": "true",
|
|
338
|
-
onClick: () => setIsOpen(false),
|
|
339
|
-
style: {
|
|
340
|
-
display: 'inline-flex',
|
|
341
|
-
background: 'none',
|
|
342
|
-
border: 0,
|
|
343
|
-
padding: 0,
|
|
344
|
-
marginRight: '.5em',
|
|
345
|
-
cursor: 'pointer'
|
|
346
|
-
}
|
|
347
|
-
}, /*#__PURE__*/React.createElement(Logo, {
|
|
348
|
-
"aria-hidden": true
|
|
349
|
-
}), /*#__PURE__*/React.createElement(ScreenReader, {
|
|
350
|
-
text: "Close React Query Devtools"
|
|
351
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
352
|
-
style: {
|
|
353
|
-
display: 'flex',
|
|
354
|
-
flexDirection: 'column'
|
|
355
|
-
}
|
|
356
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
357
|
-
style: {
|
|
358
|
-
display: 'flex',
|
|
359
|
-
justifyContent: 'space-between',
|
|
360
|
-
alignItems: 'center',
|
|
361
|
-
marginBottom: '.5em'
|
|
362
|
-
}
|
|
363
|
-
}, /*#__PURE__*/React.createElement(QueryStatusCount, {
|
|
364
|
-
queryCache: queryCache
|
|
365
|
-
}), position && onPositionChange ? /*#__PURE__*/React.createElement(Select, {
|
|
366
|
-
"aria-label": "Panel position",
|
|
367
|
-
value: position,
|
|
368
|
-
style: {
|
|
369
|
-
marginInlineStart: '.5em'
|
|
370
|
-
},
|
|
371
|
-
onChange: e => onPositionChange(e.target.value)
|
|
372
|
-
}, /*#__PURE__*/React.createElement("option", {
|
|
373
|
-
value: "left"
|
|
374
|
-
}, "Left"), /*#__PURE__*/React.createElement("option", {
|
|
375
|
-
value: "right"
|
|
376
|
-
}, "Right"), /*#__PURE__*/React.createElement("option", {
|
|
377
|
-
value: "top"
|
|
378
|
-
}, "Top"), /*#__PURE__*/React.createElement("option", {
|
|
379
|
-
value: "bottom"
|
|
380
|
-
}, "Bottom")) : null), /*#__PURE__*/React.createElement("div", {
|
|
381
|
-
style: {
|
|
382
|
-
display: 'flex',
|
|
383
|
-
alignItems: 'center'
|
|
384
|
-
}
|
|
385
|
-
}, /*#__PURE__*/React.createElement(Input, {
|
|
386
|
-
placeholder: "Filter",
|
|
387
|
-
"aria-label": "Filter by queryhash",
|
|
388
|
-
value: filter ?? '',
|
|
389
|
-
onChange: e => setFilter(e.target.value),
|
|
390
|
-
onKeyDown: e => {
|
|
391
|
-
if (e.key === 'Escape') setFilter('');
|
|
392
|
-
},
|
|
393
|
-
style: {
|
|
394
|
-
flex: '1',
|
|
395
|
-
marginRight: '.5em',
|
|
396
|
-
width: '100%'
|
|
397
|
-
}
|
|
398
|
-
}), /*#__PURE__*/React.createElement(Select, {
|
|
399
|
-
"aria-label": "Sort queries",
|
|
400
|
-
value: sort,
|
|
401
|
-
onChange: e => setSort(e.target.value),
|
|
402
|
-
style: {
|
|
403
|
-
flex: '1',
|
|
404
|
-
minWidth: 75,
|
|
405
|
-
marginRight: '.5em'
|
|
406
|
-
}
|
|
407
|
-
}, Object.keys(sortFns).map(key => /*#__PURE__*/React.createElement("option", {
|
|
408
|
-
key: key,
|
|
409
|
-
value: key
|
|
410
|
-
}, "Sort by ", key))), /*#__PURE__*/React.createElement(Button, {
|
|
411
|
-
type: "button",
|
|
412
|
-
onClick: () => setBaseSort(old => old * -1),
|
|
413
|
-
style: {
|
|
414
|
-
padding: '.3em .4em',
|
|
415
|
-
marginRight: '.5em'
|
|
416
|
-
}
|
|
417
|
-
}, baseSort === 1 ? '⬆ Asc' : '⬇ Desc'), /*#__PURE__*/React.createElement(Button, {
|
|
418
|
-
type: "button",
|
|
419
|
-
onClick: () => {
|
|
420
|
-
if (isMockOffline) {
|
|
421
|
-
onlineManager.setOnline(undefined);
|
|
422
|
-
setMockOffline(false);
|
|
423
|
-
window.dispatchEvent(new Event('online'));
|
|
424
|
-
} else {
|
|
425
|
-
onlineManager.setOnline(false);
|
|
426
|
-
setMockOffline(true);
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
"aria-label": isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
|
|
430
|
-
title: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
|
|
431
|
-
style: {
|
|
432
|
-
padding: '0',
|
|
433
|
-
height: '2em'
|
|
434
|
-
}
|
|
435
|
-
}, /*#__PURE__*/React.createElement("svg", {
|
|
436
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
437
|
-
width: "2em",
|
|
438
|
-
height: "2em",
|
|
439
|
-
viewBox: "0 0 24 24",
|
|
440
|
-
stroke: isMockOffline ? defaultTheme.danger : 'currentColor',
|
|
441
|
-
fill: "none"
|
|
442
|
-
}, isMockOffline ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("path", {
|
|
443
|
-
stroke: "none",
|
|
444
|
-
d: "M0 0h24v24H0z",
|
|
445
|
-
fill: "none"
|
|
446
|
-
}), /*#__PURE__*/React.createElement("line", {
|
|
447
|
-
x1: "12",
|
|
448
|
-
y1: "18",
|
|
449
|
-
x2: "12.01",
|
|
450
|
-
y2: "18"
|
|
451
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
452
|
-
d: "M9.172 15.172a4 4 0 0 1 5.656 0"
|
|
453
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
454
|
-
d: "M6.343 12.343a7.963 7.963 0 0 1 3.864 -2.14m4.163 .155a7.965 7.965 0 0 1 3.287 2"
|
|
455
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
456
|
-
d: "M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374"
|
|
457
|
-
}), /*#__PURE__*/React.createElement("line", {
|
|
458
|
-
x1: "3",
|
|
459
|
-
y1: "3",
|
|
460
|
-
x2: "21",
|
|
461
|
-
y2: "21"
|
|
462
|
-
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("path", {
|
|
463
|
-
stroke: "none",
|
|
464
|
-
d: "M0 0h24v24H0z",
|
|
465
|
-
fill: "none"
|
|
466
|
-
}), /*#__PURE__*/React.createElement("line", {
|
|
467
|
-
x1: "12",
|
|
468
|
-
y1: "18",
|
|
469
|
-
x2: "12.01",
|
|
470
|
-
y2: "18"
|
|
471
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
472
|
-
d: "M9.172 15.172a4 4 0 0 1 5.656 0"
|
|
473
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
474
|
-
d: "M6.343 12.343a8 8 0 0 1 11.314 0"
|
|
475
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
476
|
-
d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
|
|
477
|
-
}))), /*#__PURE__*/React.createElement(ScreenReader, {
|
|
478
|
-
text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
|
|
479
|
-
}))))), /*#__PURE__*/React.createElement("div", {
|
|
480
|
-
style: {
|
|
481
|
-
overflowY: 'auto',
|
|
482
|
-
flex: '1'
|
|
483
|
-
}
|
|
484
|
-
}, queries.map(query => {
|
|
485
|
-
return /*#__PURE__*/React.createElement(QueryRow, {
|
|
486
|
-
queryKey: query.queryKey,
|
|
487
|
-
activeQueryHash: activeQueryHash,
|
|
488
|
-
setActiveQueryHash: setActiveQueryHash,
|
|
489
|
-
key: query.queryHash,
|
|
490
|
-
queryCache: queryCache
|
|
491
|
-
});
|
|
492
|
-
}))), activeQueryHash && isOpen ? /*#__PURE__*/React.createElement(ActiveQuery, {
|
|
493
|
-
activeQueryHash: activeQueryHash,
|
|
494
|
-
queryCache: queryCache,
|
|
495
|
-
queryClient: client
|
|
496
|
-
}) : null, showCloseButton ? /*#__PURE__*/React.createElement(Button, _extends({
|
|
497
|
-
type: "button",
|
|
498
|
-
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
499
|
-
"aria-haspopup": "true",
|
|
500
|
-
"aria-expanded": "true"
|
|
501
|
-
}, otherCloseButtonProps, {
|
|
502
|
-
style: {
|
|
503
|
-
position: 'absolute',
|
|
504
|
-
zIndex: 99999,
|
|
505
|
-
margin: '.5em',
|
|
506
|
-
bottom: 0,
|
|
507
|
-
left: 0,
|
|
508
|
-
...otherCloseButtonProps.style
|
|
509
|
-
},
|
|
510
|
-
onClick: e => {
|
|
511
|
-
setIsOpen(false);
|
|
512
|
-
onCloseClick?.(e);
|
|
513
|
-
}
|
|
514
|
-
}), "Close") : null));
|
|
515
|
-
});
|
|
516
|
-
const ActiveQuery = ({
|
|
517
|
-
queryCache,
|
|
518
|
-
activeQueryHash,
|
|
519
|
-
queryClient
|
|
520
|
-
}) => {
|
|
521
|
-
const activeQuery = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
|
|
522
|
-
const activeQueryState = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.state);
|
|
523
|
-
const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.isStale()) ?? false;
|
|
524
|
-
const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.getObserversCount()) ?? 0;
|
|
525
|
-
const handleRefetch = () => {
|
|
526
|
-
const promise = activeQuery?.fetch();
|
|
527
|
-
promise?.catch(noop);
|
|
528
|
-
};
|
|
529
|
-
if (!activeQuery || !activeQueryState) {
|
|
530
|
-
return null;
|
|
531
|
-
}
|
|
532
|
-
return /*#__PURE__*/React.createElement(ActiveQueryPanel, null, /*#__PURE__*/React.createElement("div", {
|
|
533
|
-
style: {
|
|
534
|
-
padding: '.5em',
|
|
535
|
-
background: defaultTheme.backgroundAlt,
|
|
536
|
-
position: 'sticky',
|
|
537
|
-
top: 0,
|
|
538
|
-
zIndex: 1
|
|
539
|
-
}
|
|
540
|
-
}, "Query Details"), /*#__PURE__*/React.createElement("div", {
|
|
541
|
-
style: {
|
|
542
|
-
padding: '.5em'
|
|
543
|
-
}
|
|
544
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
545
|
-
style: {
|
|
546
|
-
marginBottom: '.5em',
|
|
547
|
-
display: 'flex',
|
|
548
|
-
alignItems: 'flex-start',
|
|
549
|
-
justifyContent: 'space-between'
|
|
550
|
-
}
|
|
551
|
-
}, /*#__PURE__*/React.createElement(Code, {
|
|
552
|
-
style: {
|
|
553
|
-
lineHeight: '1.8em'
|
|
554
|
-
}
|
|
555
|
-
}, /*#__PURE__*/React.createElement("pre", {
|
|
556
|
-
style: {
|
|
557
|
-
margin: 0,
|
|
558
|
-
padding: 0,
|
|
559
|
-
overflow: 'auto'
|
|
560
|
-
}
|
|
561
|
-
}, displayValue(activeQuery.queryKey, true))), /*#__PURE__*/React.createElement("span", {
|
|
562
|
-
style: {
|
|
563
|
-
padding: '0.3em .6em',
|
|
564
|
-
borderRadius: '0.4em',
|
|
565
|
-
fontWeight: 'bold',
|
|
566
|
-
textShadow: '0 2px 10px black',
|
|
567
|
-
background: getQueryStatusColor({
|
|
568
|
-
queryState: activeQueryState,
|
|
569
|
-
isStale: isStale,
|
|
570
|
-
observerCount: observerCount,
|
|
571
|
-
theme: defaultTheme
|
|
572
|
-
}),
|
|
573
|
-
flexShrink: 0
|
|
574
|
-
}
|
|
575
|
-
}, getQueryStatusLabel(activeQuery))), /*#__PURE__*/React.createElement("div", {
|
|
576
|
-
style: {
|
|
577
|
-
marginBottom: '.5em',
|
|
578
|
-
display: 'flex',
|
|
579
|
-
alignItems: 'center',
|
|
580
|
-
justifyContent: 'space-between'
|
|
581
|
-
}
|
|
582
|
-
}, "Observers: ", /*#__PURE__*/React.createElement(Code, null, observerCount)), /*#__PURE__*/React.createElement("div", {
|
|
583
|
-
style: {
|
|
584
|
-
display: 'flex',
|
|
585
|
-
alignItems: 'center',
|
|
586
|
-
justifyContent: 'space-between'
|
|
587
|
-
}
|
|
588
|
-
}, "Last Updated:", ' ', /*#__PURE__*/React.createElement(Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React.createElement("div", {
|
|
589
|
-
style: {
|
|
590
|
-
background: defaultTheme.backgroundAlt,
|
|
591
|
-
padding: '.5em',
|
|
592
|
-
position: 'sticky',
|
|
593
|
-
top: 0,
|
|
594
|
-
zIndex: 1
|
|
595
|
-
}
|
|
596
|
-
}, "Actions"), /*#__PURE__*/React.createElement("div", {
|
|
597
|
-
style: {
|
|
598
|
-
padding: '0.5em'
|
|
599
|
-
}
|
|
600
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
601
|
-
type: "button",
|
|
602
|
-
onClick: handleRefetch,
|
|
603
|
-
disabled: activeQueryState.fetchStatus === 'fetching',
|
|
604
|
-
style: {
|
|
605
|
-
background: defaultTheme.active
|
|
606
|
-
}
|
|
607
|
-
}, "Refetch"), ' ', /*#__PURE__*/React.createElement(Button, {
|
|
608
|
-
type: "button",
|
|
609
|
-
onClick: () => queryClient.invalidateQueries(activeQuery),
|
|
610
|
-
style: {
|
|
611
|
-
background: defaultTheme.warning,
|
|
612
|
-
color: defaultTheme.inputTextColor
|
|
613
|
-
}
|
|
614
|
-
}, "Invalidate"), ' ', /*#__PURE__*/React.createElement(Button, {
|
|
615
|
-
type: "button",
|
|
616
|
-
onClick: () => queryClient.resetQueries(activeQuery),
|
|
617
|
-
style: {
|
|
618
|
-
background: defaultTheme.gray
|
|
619
|
-
}
|
|
620
|
-
}, "Reset"), ' ', /*#__PURE__*/React.createElement(Button, {
|
|
621
|
-
type: "button",
|
|
622
|
-
onClick: () => queryClient.removeQueries(activeQuery),
|
|
623
|
-
style: {
|
|
624
|
-
background: defaultTheme.danger
|
|
625
|
-
}
|
|
626
|
-
}, "Remove")), /*#__PURE__*/React.createElement("div", {
|
|
627
|
-
style: {
|
|
628
|
-
background: defaultTheme.backgroundAlt,
|
|
629
|
-
padding: '.5em',
|
|
630
|
-
position: 'sticky',
|
|
631
|
-
top: 0,
|
|
632
|
-
zIndex: 1
|
|
633
|
-
}
|
|
634
|
-
}, "Data Explorer"), /*#__PURE__*/React.createElement("div", {
|
|
635
|
-
style: {
|
|
636
|
-
padding: '.5em'
|
|
637
|
-
}
|
|
638
|
-
}, /*#__PURE__*/React.createElement(Explorer, {
|
|
639
|
-
label: "Data",
|
|
640
|
-
value: activeQueryState.data,
|
|
641
|
-
defaultExpanded: {},
|
|
642
|
-
copyable: true
|
|
643
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
644
|
-
style: {
|
|
645
|
-
background: defaultTheme.backgroundAlt,
|
|
646
|
-
padding: '.5em',
|
|
647
|
-
position: 'sticky',
|
|
648
|
-
top: 0,
|
|
649
|
-
zIndex: 1
|
|
650
|
-
}
|
|
651
|
-
}, "Query Explorer"), /*#__PURE__*/React.createElement("div", {
|
|
652
|
-
style: {
|
|
653
|
-
padding: '.5em'
|
|
654
|
-
}
|
|
655
|
-
}, /*#__PURE__*/React.createElement(Explorer, {
|
|
656
|
-
label: "Query",
|
|
657
|
-
value: activeQuery,
|
|
658
|
-
defaultExpanded: {
|
|
659
|
-
queryKey: true
|
|
660
|
-
}
|
|
661
|
-
})));
|
|
662
|
-
};
|
|
663
|
-
const QueryStatusCount = ({
|
|
664
|
-
queryCache
|
|
665
|
-
}) => {
|
|
666
|
-
const hasFresh = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fresh').length);
|
|
667
|
-
const hasFetching = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fetching').length);
|
|
668
|
-
const hasPaused = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'paused').length);
|
|
669
|
-
const hasStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'stale').length);
|
|
670
|
-
const hasInactive = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'inactive').length);
|
|
671
|
-
return /*#__PURE__*/React.createElement(QueryKeys, null, /*#__PURE__*/React.createElement(QueryKey, {
|
|
672
|
-
style: {
|
|
673
|
-
background: defaultTheme.success,
|
|
674
|
-
opacity: hasFresh ? 1 : 0.3
|
|
675
|
-
}
|
|
676
|
-
}, "fresh ", /*#__PURE__*/React.createElement(Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
|
|
677
|
-
style: {
|
|
678
|
-
background: defaultTheme.active,
|
|
679
|
-
opacity: hasFetching ? 1 : 0.3
|
|
680
|
-
}
|
|
681
|
-
}, "fetching ", /*#__PURE__*/React.createElement(Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
|
|
682
|
-
style: {
|
|
683
|
-
background: defaultTheme.paused,
|
|
684
|
-
opacity: hasPaused ? 1 : 0.3
|
|
685
|
-
}
|
|
686
|
-
}, "paused ", /*#__PURE__*/React.createElement(Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
|
|
687
|
-
style: {
|
|
688
|
-
background: defaultTheme.warning,
|
|
689
|
-
color: 'black',
|
|
690
|
-
textShadow: '0',
|
|
691
|
-
opacity: hasStale ? 1 : 0.3
|
|
692
|
-
}
|
|
693
|
-
}, "stale ", /*#__PURE__*/React.createElement(Code, null, "(", hasStale, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
|
|
694
|
-
style: {
|
|
695
|
-
background: defaultTheme.gray,
|
|
696
|
-
opacity: hasInactive ? 1 : 0.3
|
|
697
|
-
}
|
|
698
|
-
}, "inactive ", /*#__PURE__*/React.createElement(Code, null, "(", hasInactive, ")")));
|
|
699
|
-
};
|
|
700
|
-
const QueryRow = /*#__PURE__*/React.memo(({
|
|
701
|
-
queryKey,
|
|
702
|
-
setActiveQueryHash,
|
|
703
|
-
activeQueryHash,
|
|
704
|
-
queryCache
|
|
705
|
-
}) => {
|
|
706
|
-
const queryHash = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
707
|
-
queryKey
|
|
708
|
-
})?.queryHash) ?? '';
|
|
709
|
-
const queryState = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
710
|
-
queryKey
|
|
711
|
-
})?.state);
|
|
712
|
-
const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
713
|
-
queryKey
|
|
714
|
-
})?.isStale()) ?? false;
|
|
715
|
-
const isDisabled = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
716
|
-
queryKey
|
|
717
|
-
})?.isDisabled()) ?? false;
|
|
718
|
-
const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
719
|
-
queryKey
|
|
720
|
-
})?.getObserversCount()) ?? 0;
|
|
721
|
-
if (!queryState) {
|
|
722
|
-
return null;
|
|
723
|
-
}
|
|
724
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
725
|
-
role: "button",
|
|
726
|
-
"aria-label": `Open query details for ${queryHash}`,
|
|
727
|
-
onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
|
|
728
|
-
style: {
|
|
729
|
-
display: 'flex',
|
|
730
|
-
borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
|
|
731
|
-
cursor: 'pointer',
|
|
732
|
-
background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
|
|
733
|
-
}
|
|
734
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
735
|
-
style: {
|
|
736
|
-
flex: '0 0 auto',
|
|
737
|
-
width: '2em',
|
|
738
|
-
height: '2em',
|
|
739
|
-
background: getQueryStatusColor({
|
|
740
|
-
queryState,
|
|
741
|
-
isStale,
|
|
742
|
-
observerCount,
|
|
743
|
-
theme: defaultTheme
|
|
744
|
-
}),
|
|
745
|
-
display: 'flex',
|
|
746
|
-
alignItems: 'center',
|
|
747
|
-
justifyContent: 'center',
|
|
748
|
-
fontWeight: 'bold',
|
|
749
|
-
textShadow: isStale ? '0' : '0 0 10px black',
|
|
750
|
-
color: isStale ? 'black' : 'white'
|
|
751
|
-
}
|
|
752
|
-
}, observerCount), isDisabled ? /*#__PURE__*/React.createElement("div", {
|
|
753
|
-
style: {
|
|
754
|
-
flex: '0 0 auto',
|
|
755
|
-
height: '2em',
|
|
756
|
-
background: defaultTheme.gray,
|
|
757
|
-
display: 'flex',
|
|
758
|
-
alignItems: 'center',
|
|
759
|
-
fontWeight: 'bold',
|
|
760
|
-
padding: '0 0.5em'
|
|
761
|
-
}
|
|
762
|
-
}, "disabled") : null, /*#__PURE__*/React.createElement(Code, {
|
|
763
|
-
style: {
|
|
764
|
-
padding: '.5em'
|
|
765
|
-
}
|
|
766
|
-
}, `${queryHash}`));
|
|
767
|
-
});
|
|
768
|
-
|
|
769
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
770
|
-
function noop() {}
|
|
771
231
|
|
|
772
232
|
export { ReactQueryDevtools, ReactQueryDevtoolsPanel };
|
|
773
233
|
//# sourceMappingURL=devtools.mjs.map
|