@tanstack/react-query-devtools 4.0.11-beta.5 → 4.2.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 (103) hide show
  1. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +33 -0
  2. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  3. package/build/cjs/node_modules/@tanstack/match-sorter-utils/build/esm/index.js +757 -0
  4. package/build/cjs/node_modules/@tanstack/match-sorter-utils/build/esm/index.js.map +1 -0
  5. package/build/{lib → cjs}/noop.js +0 -0
  6. package/build/{lib → cjs}/noop.js.map +0 -0
  7. package/build/cjs/packages/react-query-devtools/src/Explorer.js +215 -0
  8. package/build/cjs/packages/react-query-devtools/src/Explorer.js.map +1 -0
  9. package/build/cjs/packages/react-query-devtools/src/Logo.js +66 -0
  10. package/build/cjs/packages/react-query-devtools/src/Logo.js.map +1 -0
  11. package/build/cjs/packages/react-query-devtools/src/devtools.js +812 -0
  12. package/build/cjs/packages/react-query-devtools/src/devtools.js.map +1 -0
  13. package/build/cjs/packages/react-query-devtools/src/index.js +26 -0
  14. package/build/cjs/packages/react-query-devtools/src/index.js.map +1 -0
  15. package/build/cjs/packages/react-query-devtools/src/screenreader.js +51 -0
  16. package/build/cjs/packages/react-query-devtools/src/screenreader.js.map +1 -0
  17. package/build/cjs/packages/react-query-devtools/src/styledComponents.js +113 -0
  18. package/build/cjs/packages/react-query-devtools/src/styledComponents.js.map +1 -0
  19. package/build/cjs/packages/react-query-devtools/src/theme.js +68 -0
  20. package/build/cjs/packages/react-query-devtools/src/theme.js.map +1 -0
  21. package/build/cjs/packages/react-query-devtools/src/useLocalStorage.js +81 -0
  22. package/build/cjs/packages/react-query-devtools/src/useLocalStorage.js.map +1 -0
  23. package/build/cjs/packages/react-query-devtools/src/useMediaQuery.js +66 -0
  24. package/build/cjs/packages/react-query-devtools/src/useMediaQuery.js.map +1 -0
  25. package/build/cjs/packages/react-query-devtools/src/utils.js +113 -0
  26. package/build/cjs/packages/react-query-devtools/src/utils.js.map +1 -0
  27. package/build/{lib/index.mjs → esm/index.js} +23 -283
  28. package/build/esm/index.js.map +1 -0
  29. package/build/{lib/noop.mjs → esm/noop.js} +1 -1
  30. package/build/esm/noop.js.map +1 -0
  31. package/build/stats-html.html +2689 -0
  32. package/build/stats.json +45 -0
  33. package/build/types/query-core/src/focusManager.d.ts +16 -0
  34. package/build/types/query-core/src/hydration.d.ts +34 -0
  35. package/build/types/query-core/src/index.d.ts +20 -0
  36. package/build/types/query-core/src/infiniteQueryBehavior.d.ts +15 -0
  37. package/build/types/query-core/src/infiniteQueryObserver.d.ts +18 -0
  38. package/build/types/query-core/src/logger.d.ts +8 -0
  39. package/build/types/query-core/src/mutation.d.ts +70 -0
  40. package/build/types/query-core/src/mutationCache.d.ts +57 -0
  41. package/build/types/query-core/src/mutationObserver.d.ts +23 -0
  42. package/build/types/query-core/src/notifyManager.d.ts +18 -0
  43. package/build/types/query-core/src/onlineManager.d.ts +16 -0
  44. package/build/types/query-core/src/queriesObserver.d.ts +23 -0
  45. package/build/types/query-core/src/query.d.ts +119 -0
  46. package/build/types/query-core/src/queryCache.d.ts +64 -0
  47. package/build/types/query-core/src/queryClient.d.ts +65 -0
  48. package/build/types/query-core/src/queryObserver.d.ts +61 -0
  49. package/build/types/query-core/src/removable.d.ts +9 -0
  50. package/build/types/query-core/src/retryer.d.ts +33 -0
  51. package/build/types/query-core/src/subscribable.d.ts +10 -0
  52. package/build/types/query-core/src/types.d.ts +419 -0
  53. package/build/types/query-core/src/utils.d.ts +99 -0
  54. package/build/types/react-query/src/Hydrate.d.ts +10 -0
  55. package/build/types/react-query/src/QueryClientProvider.d.ts +24 -0
  56. package/build/types/react-query/src/QueryErrorResetBoundary.d.ts +12 -0
  57. package/build/types/react-query/src/index.d.ts +17 -0
  58. package/build/types/react-query/src/isRestoring.d.ts +3 -0
  59. package/build/types/react-query/src/reactBatchedUpdates.d.ts +2 -0
  60. package/build/types/react-query/src/setBatchUpdatesFn.d.ts +1 -0
  61. package/build/types/react-query/src/types.d.ts +34 -0
  62. package/build/types/react-query/src/useBaseQuery.d.ts +3 -0
  63. package/build/types/react-query/src/useInfiniteQuery.d.ts +5 -0
  64. package/build/types/react-query/src/useIsFetching.d.ts +7 -0
  65. package/build/types/react-query/src/useIsMutating.d.ts +7 -0
  66. package/build/types/react-query/src/useMutation.d.ts +6 -0
  67. package/build/types/react-query/src/useQueries.d.ts +49 -0
  68. package/build/types/react-query/src/useQuery.d.ts +23 -0
  69. package/build/types/react-query/src/utils.d.ts +1 -0
  70. package/build/{lib → types/react-query-devtools/src}/Explorer.d.ts +0 -0
  71. package/build/{lib → types/react-query-devtools/src}/Logo.d.ts +0 -0
  72. package/build/types/react-query-devtools/src/__tests__/Explorer.test.d.ts +1 -0
  73. package/build/types/react-query-devtools/src/__tests__/devtools.test.d.ts +6 -0
  74. package/build/types/react-query-devtools/src/__tests__/utils.d.ts +22 -0
  75. package/build/{lib → types/react-query-devtools/src}/devtools.d.ts +0 -0
  76. package/build/{lib → types/react-query-devtools/src}/index.d.ts +0 -0
  77. package/build/{lib → types/react-query-devtools/src}/noop.d.ts +0 -0
  78. package/build/types/react-query-devtools/src/screenreader.d.ts +4 -0
  79. package/build/{lib → types/react-query-devtools/src}/styledComponents.d.ts +0 -0
  80. package/build/{lib → types/react-query-devtools/src}/theme.d.ts +0 -0
  81. package/build/{lib → types/react-query-devtools/src}/useLocalStorage.d.ts +0 -0
  82. package/build/{lib → types/react-query-devtools/src}/useMediaQuery.d.ts +0 -0
  83. package/build/{lib → types/react-query-devtools/src}/utils.d.ts +0 -0
  84. package/build/umd/index.development.js +9 -2240
  85. package/build/umd/index.development.js.map +1 -1
  86. package/build/umd/index.production.js +2 -2
  87. package/build/umd/index.production.js.map +1 -1
  88. package/package.json +20 -31
  89. package/src/devtools.tsx +11 -1
  90. package/src/screenreader.tsx +16 -0
  91. package/build/lib/index.js +0 -2286
  92. package/build/lib/index.js.map +0 -1
  93. package/build/lib/index.mjs.map +0 -1
  94. package/build/lib/noop.mjs.map +0 -1
  95. package/build/lib/useSyncExternalStore.d.ts +0 -1
  96. package/build/lib/useSyncExternalStore.native.d.ts +0 -1
  97. package/build/umd/noop.development.js +0 -30
  98. package/build/umd/noop.development.js.map +0 -1
  99. package/build/umd/noop.production.js +0 -12
  100. package/build/umd/noop.production.js.map +0 -1
  101. package/cjs.fallback.js +0 -13
  102. package/src/useSyncExternalStore.native.ts +0 -3
  103. package/src/useSyncExternalStore.ts +0 -2
@@ -0,0 +1,812 @@
1
+ /**
2
+ * react-query-devtools
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
16
+ var React = require('react');
17
+ var shim = require('use-sync-external-store/shim');
18
+ var reactQuery = require('@tanstack/react-query');
19
+ var index = require('../../../node_modules/@tanstack/match-sorter-utils/build/esm/index.js');
20
+ var useLocalStorage = require('./useLocalStorage.js');
21
+ var utils = require('./utils.js');
22
+ var screenreader = require('./screenreader.js');
23
+ var styledComponents = require('./styledComponents.js');
24
+ var theme = require('./theme.js');
25
+ var Explorer = require('./Explorer.js');
26
+ var Logo = require('./Logo.js');
27
+
28
+ function _interopNamespace(e) {
29
+ if (e && e.__esModule) return e;
30
+ var n = Object.create(null);
31
+ if (e) {
32
+ Object.keys(e).forEach(function (k) {
33
+ if (k !== 'default') {
34
+ var d = Object.getOwnPropertyDescriptor(e, k);
35
+ Object.defineProperty(n, k, d.get ? d : {
36
+ enumerable: true,
37
+ get: function () { return e[k]; }
38
+ });
39
+ }
40
+ });
41
+ }
42
+ n["default"] = e;
43
+ return Object.freeze(n);
44
+ }
45
+
46
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
47
+
48
+ const isServer = typeof window === 'undefined';
49
+ function ReactQueryDevtools({
50
+ initialIsOpen,
51
+ panelProps = {},
52
+ closeButtonProps = {},
53
+ toggleButtonProps = {},
54
+ position = 'bottom-left',
55
+ containerElement: Container = 'aside',
56
+ context,
57
+ styleNonce
58
+ }) {
59
+ const rootRef = React__namespace.useRef(null);
60
+ const panelRef = React__namespace.useRef(null);
61
+ const [isOpen, setIsOpen] = useLocalStorage["default"]('reactQueryDevtoolsOpen', initialIsOpen);
62
+ const [devtoolsHeight, setDevtoolsHeight] = useLocalStorage["default"]('reactQueryDevtoolsHeight', null);
63
+ const [isResolvedOpen, setIsResolvedOpen] = React__namespace.useState(false);
64
+ const [isResizing, setIsResizing] = React__namespace.useState(false);
65
+ const isMounted = utils.useIsMounted();
66
+
67
+ const handleDragStart = (panelElement, startEvent) => {
68
+ var _panelElement$getBoun;
69
+
70
+ if (startEvent.button !== 0) return; // Only allow left click for drag
71
+
72
+ setIsResizing(true);
73
+ const dragInfo = {
74
+ originalHeight: (_panelElement$getBoun = panelElement == null ? void 0 : panelElement.getBoundingClientRect().height) != null ? _panelElement$getBoun : 0,
75
+ pageY: startEvent.pageY
76
+ };
77
+
78
+ const run = moveEvent => {
79
+ const delta = dragInfo.pageY - moveEvent.pageY;
80
+ const newHeight = dragInfo.originalHeight + delta;
81
+ setDevtoolsHeight(newHeight);
82
+
83
+ if (newHeight < 70) {
84
+ setIsOpen(false);
85
+ } else {
86
+ setIsOpen(true);
87
+ }
88
+ };
89
+
90
+ const unsub = () => {
91
+ setIsResizing(false);
92
+ document.removeEventListener('mousemove', run);
93
+ document.removeEventListener('mouseUp', unsub);
94
+ };
95
+
96
+ document.addEventListener('mousemove', run);
97
+ document.addEventListener('mouseup', unsub);
98
+ };
99
+
100
+ React__namespace.useEffect(() => {
101
+ setIsResolvedOpen(isOpen != null ? isOpen : false);
102
+ }, [isOpen, isResolvedOpen, setIsResolvedOpen]); // Toggle panel visibility before/after transition (depending on direction).
103
+ // Prevents focusing in a closed panel.
104
+
105
+ React__namespace.useEffect(() => {
106
+ const ref = panelRef.current;
107
+
108
+ if (ref) {
109
+ const handlePanelTransitionStart = () => {
110
+ if (isResolvedOpen) {
111
+ ref.style.visibility = 'visible';
112
+ }
113
+ };
114
+
115
+ const handlePanelTransitionEnd = () => {
116
+ if (!isResolvedOpen) {
117
+ ref.style.visibility = 'hidden';
118
+ }
119
+ };
120
+
121
+ ref.addEventListener('transitionstart', handlePanelTransitionStart);
122
+ ref.addEventListener('transitionend', handlePanelTransitionEnd);
123
+ return () => {
124
+ ref.removeEventListener('transitionstart', handlePanelTransitionStart);
125
+ ref.removeEventListener('transitionend', handlePanelTransitionEnd);
126
+ };
127
+ }
128
+ }, [isResolvedOpen]);
129
+ React__namespace[isServer ? 'useEffect' : 'useLayoutEffect'](() => {
130
+ if (isResolvedOpen) {
131
+ var _rootRef$current, _rootRef$current$pare;
132
+
133
+ const previousValue = (_rootRef$current = rootRef.current) == null ? void 0 : (_rootRef$current$pare = _rootRef$current.parentElement) == null ? void 0 : _rootRef$current$pare.style.paddingBottom;
134
+
135
+ const run = () => {
136
+ var _panelRef$current, _rootRef$current2;
137
+
138
+ const containerHeight = (_panelRef$current = panelRef.current) == null ? void 0 : _panelRef$current.getBoundingClientRect().height;
139
+
140
+ if ((_rootRef$current2 = rootRef.current) != null && _rootRef$current2.parentElement) {
141
+ rootRef.current.parentElement.style.paddingBottom = containerHeight + "px";
142
+ }
143
+ };
144
+
145
+ run();
146
+
147
+ if (typeof window !== 'undefined') {
148
+ window.addEventListener('resize', run);
149
+ return () => {
150
+ var _rootRef$current3;
151
+
152
+ window.removeEventListener('resize', run);
153
+
154
+ if ((_rootRef$current3 = rootRef.current) != null && _rootRef$current3.parentElement && typeof previousValue === 'string') {
155
+ rootRef.current.parentElement.style.paddingBottom = previousValue;
156
+ }
157
+ };
158
+ }
159
+ }
160
+ }, [isResolvedOpen]);
161
+ const {
162
+ style: panelStyle = {},
163
+ ...otherPanelProps
164
+ } = panelProps;
165
+ const {
166
+ style: closeButtonStyle = {},
167
+ onClick: onCloseClick,
168
+ ...otherCloseButtonProps
169
+ } = closeButtonProps;
170
+ const {
171
+ style: toggleButtonStyle = {},
172
+ onClick: onToggleClick,
173
+ ...otherToggleButtonProps
174
+ } = toggleButtonProps; // Do not render on the server
175
+
176
+ if (!isMounted()) return null;
177
+ return /*#__PURE__*/React__namespace.createElement(Container, {
178
+ ref: rootRef,
179
+ className: "ReactQueryDevtools",
180
+ "aria-label": "React Query Devtools"
181
+ }, /*#__PURE__*/React__namespace.createElement(theme.ThemeProvider, {
182
+ theme: theme.defaultTheme
183
+ }, /*#__PURE__*/React__namespace.createElement(ReactQueryDevtoolsPanel, _rollupPluginBabelHelpers["extends"]({
184
+ ref: panelRef,
185
+ context: context,
186
+ styleNonce: styleNonce
187
+ }, otherPanelProps, {
188
+ style: {
189
+ position: 'fixed',
190
+ bottom: '0',
191
+ right: '0',
192
+ zIndex: 99999,
193
+ width: '100%',
194
+ height: devtoolsHeight != null ? devtoolsHeight : 500,
195
+ maxHeight: '90%',
196
+ boxShadow: '0 0 20px rgba(0,0,0,.3)',
197
+ borderTop: "1px solid " + theme.defaultTheme.gray,
198
+ transformOrigin: 'top',
199
+ // visibility will be toggled after transitions, but set initial state here
200
+ visibility: isOpen ? 'visible' : 'hidden',
201
+ ...panelStyle,
202
+ ...(isResizing ? {
203
+ transition: "none"
204
+ } : {
205
+ transition: "all .2s ease"
206
+ }),
207
+ ...(isResolvedOpen ? {
208
+ opacity: 1,
209
+ pointerEvents: 'all',
210
+ transform: "translateY(0) scale(1)"
211
+ } : {
212
+ opacity: 0,
213
+ pointerEvents: 'none',
214
+ transform: "translateY(15px) scale(1.02)"
215
+ })
216
+ },
217
+ isOpen: isResolvedOpen,
218
+ setIsOpen: setIsOpen,
219
+ handleDragStart: e => handleDragStart(panelRef.current, e)
220
+ })), isResolvedOpen ? /*#__PURE__*/React__namespace.createElement(styledComponents.Button, _rollupPluginBabelHelpers["extends"]({
221
+ type: "button",
222
+ "aria-controls": "ReactQueryDevtoolsPanel",
223
+ "aria-haspopup": "true",
224
+ "aria-expanded": "true"
225
+ }, otherCloseButtonProps, {
226
+ onClick: e => {
227
+ setIsOpen(false);
228
+ onCloseClick == null ? void 0 : onCloseClick(e);
229
+ },
230
+ style: {
231
+ position: 'fixed',
232
+ zIndex: 99999,
233
+ margin: '.5em',
234
+ bottom: 0,
235
+ ...(position === 'top-right' ? {
236
+ right: '0'
237
+ } : position === 'top-left' ? {
238
+ left: '0'
239
+ } : position === 'bottom-right' ? {
240
+ right: '0'
241
+ } : {
242
+ left: '0'
243
+ }),
244
+ ...closeButtonStyle
245
+ }
246
+ }), "Close") : null), !isResolvedOpen ? /*#__PURE__*/React__namespace.createElement("button", _rollupPluginBabelHelpers["extends"]({
247
+ type: "button"
248
+ }, otherToggleButtonProps, {
249
+ "aria-label": "Open React Query Devtools",
250
+ "aria-controls": "ReactQueryDevtoolsPanel",
251
+ "aria-haspopup": "true",
252
+ "aria-expanded": "false",
253
+ onClick: e => {
254
+ setIsOpen(true);
255
+ onToggleClick == null ? void 0 : onToggleClick(e);
256
+ },
257
+ style: {
258
+ background: 'none',
259
+ border: 0,
260
+ padding: 0,
261
+ position: 'fixed',
262
+ zIndex: 99999,
263
+ display: 'inline-flex',
264
+ fontSize: '1.5em',
265
+ margin: '.5em',
266
+ cursor: 'pointer',
267
+ width: 'fit-content',
268
+ ...(position === 'top-right' ? {
269
+ top: '0',
270
+ right: '0'
271
+ } : position === 'top-left' ? {
272
+ top: '0',
273
+ left: '0'
274
+ } : position === 'bottom-right' ? {
275
+ bottom: '0',
276
+ right: '0'
277
+ } : {
278
+ bottom: '0',
279
+ left: '0'
280
+ }),
281
+ ...toggleButtonStyle
282
+ }
283
+ }), /*#__PURE__*/React__namespace.createElement(Logo["default"], {
284
+ "aria-hidden": true
285
+ }), /*#__PURE__*/React__namespace.createElement(screenreader["default"], {
286
+ text: "Open React Query Devtools"
287
+ })) : null);
288
+ }
289
+
290
+ const useSubscribeToQueryCache = (queryCache, getSnapshot) => {
291
+ return shim.useSyncExternalStore(React__namespace.useCallback(onStoreChange => queryCache.subscribe(reactQuery.notifyManager.batchCalls(onStoreChange)), [queryCache]), getSnapshot, getSnapshot);
292
+ };
293
+
294
+ const ReactQueryDevtoolsPanel = /*#__PURE__*/React__namespace.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
295
+ const {
296
+ isOpen = true,
297
+ styleNonce,
298
+ setIsOpen,
299
+ handleDragStart,
300
+ context,
301
+ ...panelProps
302
+ } = props;
303
+ const queryClient = reactQuery.useQueryClient({
304
+ context
305
+ });
306
+ const queryCache = queryClient.getQueryCache();
307
+ const [sort, setSort] = useLocalStorage["default"]('reactQueryDevtoolsSortFn', Object.keys(utils.sortFns)[0]);
308
+ const [filter, setFilter] = useLocalStorage["default"]('reactQueryDevtoolsFilter', '');
309
+ const [sortDesc, setSortDesc] = useLocalStorage["default"]('reactQueryDevtoolsSortDesc', false);
310
+ const sortFn = React__namespace.useMemo(() => utils.sortFns[sort], [sort]);
311
+ const queriesCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().length);
312
+ const [activeQueryHash, setActiveQueryHash] = useLocalStorage["default"]('reactQueryDevtoolsActiveQueryHash', '');
313
+ const queries = React__namespace.useMemo(() => {
314
+ const unsortedQueries = queryCache.getAll();
315
+ const sorted = queriesCount > 0 ? [...unsortedQueries].sort(sortFn) : [];
316
+
317
+ if (sortDesc) {
318
+ sorted.reverse();
319
+ }
320
+
321
+ if (!filter) {
322
+ return sorted;
323
+ }
324
+
325
+ let ranked = sorted.map(item => [item, index.rankItem(item.queryHash, filter)]);
326
+ ranked = ranked.filter(d => d[1].passed);
327
+ ranked = ranked.sort((a, b) => index.compareItems(a[1], b[1]));
328
+ return ranked.map(d => d[0]);
329
+ }, [sortDesc, sortFn, filter, queriesCount, queryCache]);
330
+ const [isMockOffline, setMockOffline] = React__namespace.useState(false);
331
+ return /*#__PURE__*/React__namespace.createElement(theme.ThemeProvider, {
332
+ theme: theme.defaultTheme
333
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.Panel, _rollupPluginBabelHelpers["extends"]({
334
+ ref: ref,
335
+ className: "ReactQueryDevtoolsPanel",
336
+ "aria-label": "React Query Devtools Panel",
337
+ id: "ReactQueryDevtoolsPanel"
338
+ }, panelProps), /*#__PURE__*/React__namespace.createElement("style", {
339
+ nonce: styleNonce,
340
+ dangerouslySetInnerHTML: {
341
+ __html: "\n .ReactQueryDevtoolsPanel * {\n scrollbar-color: " + theme.defaultTheme.backgroundAlt + " " + theme.defaultTheme.gray + ";\n }\n\n .ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {\n width: 1em;\n height: 1em;\n }\n\n .ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {\n background: " + theme.defaultTheme.backgroundAlt + ";\n }\n\n .ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {\n background: " + theme.defaultTheme.gray + ";\n border-radius: .5em;\n border: 3px solid " + theme.defaultTheme.backgroundAlt + ";\n }\n "
342
+ }
343
+ }), /*#__PURE__*/React__namespace.createElement("div", {
344
+ style: {
345
+ position: 'absolute',
346
+ left: 0,
347
+ top: 0,
348
+ width: '100%',
349
+ height: '4px',
350
+ marginBottom: '-4px',
351
+ cursor: 'row-resize',
352
+ zIndex: 100000
353
+ },
354
+ onMouseDown: handleDragStart
355
+ }), /*#__PURE__*/React__namespace.createElement("div", {
356
+ style: {
357
+ flex: '1 1 500px',
358
+ minHeight: '40%',
359
+ maxHeight: '100%',
360
+ overflow: 'auto',
361
+ borderRight: "1px solid " + theme.defaultTheme.grayAlt,
362
+ display: isOpen ? 'flex' : 'none',
363
+ flexDirection: 'column'
364
+ }
365
+ }, /*#__PURE__*/React__namespace.createElement("div", {
366
+ style: {
367
+ padding: '.5em',
368
+ background: theme.defaultTheme.backgroundAlt,
369
+ display: 'flex',
370
+ justifyContent: 'space-between',
371
+ alignItems: 'center'
372
+ }
373
+ }, /*#__PURE__*/React__namespace.createElement("button", {
374
+ type: "button",
375
+ "aria-label": "Close React Query Devtools",
376
+ "aria-controls": "ReactQueryDevtoolsPanel",
377
+ "aria-haspopup": "true",
378
+ "aria-expanded": "true",
379
+ onClick: () => setIsOpen(false),
380
+ style: {
381
+ display: 'inline-flex',
382
+ background: 'none',
383
+ border: 0,
384
+ padding: 0,
385
+ marginRight: '.5em',
386
+ cursor: 'pointer'
387
+ }
388
+ }, /*#__PURE__*/React__namespace.createElement(Logo["default"], {
389
+ "aria-hidden": true
390
+ }), /*#__PURE__*/React__namespace.createElement(screenreader["default"], {
391
+ text: "Close React Query Devtools"
392
+ })), /*#__PURE__*/React__namespace.createElement("div", {
393
+ style: {
394
+ display: 'flex',
395
+ flexDirection: 'column'
396
+ }
397
+ }, /*#__PURE__*/React__namespace.createElement(QueryStatusCount, {
398
+ queryCache: queryCache
399
+ }), /*#__PURE__*/React__namespace.createElement("div", {
400
+ style: {
401
+ display: 'flex',
402
+ alignItems: 'center'
403
+ }
404
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.Input, {
405
+ placeholder: "Filter",
406
+ "aria-label": "Filter by queryhash",
407
+ value: filter != null ? filter : '',
408
+ onChange: e => setFilter(e.target.value),
409
+ onKeyDown: e => {
410
+ if (e.key === 'Escape') setFilter('');
411
+ },
412
+ style: {
413
+ flex: '1',
414
+ marginRight: '.5em',
415
+ width: '100%'
416
+ }
417
+ }), !filter ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(styledComponents.Select, {
418
+ "aria-label": "Sort queries",
419
+ value: sort,
420
+ onChange: e => setSort(e.target.value),
421
+ style: {
422
+ flex: '1',
423
+ minWidth: 75,
424
+ marginRight: '.5em'
425
+ }
426
+ }, Object.keys(utils.sortFns).map(key => /*#__PURE__*/React__namespace.createElement("option", {
427
+ key: key,
428
+ value: key
429
+ }, "Sort by ", key))), /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
430
+ type: "button",
431
+ onClick: () => setSortDesc(old => !old),
432
+ style: {
433
+ padding: '.3em .4em',
434
+ marginRight: '.5em'
435
+ }
436
+ }, sortDesc ? '⬇ Desc' : '⬆ Asc'), /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
437
+ type: "button",
438
+ onClick: () => {
439
+ if (isMockOffline) {
440
+ reactQuery.onlineManager.setOnline(undefined);
441
+ setMockOffline(false);
442
+ window.dispatchEvent(new Event('online'));
443
+ } else {
444
+ reactQuery.onlineManager.setOnline(false);
445
+ setMockOffline(true);
446
+ }
447
+ },
448
+ "aria-label": isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
449
+ title: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
450
+ style: {
451
+ padding: '0',
452
+ height: '2em'
453
+ }
454
+ }, /*#__PURE__*/React__namespace.createElement("svg", {
455
+ xmlns: "http://www.w3.org/2000/svg",
456
+ width: "2em",
457
+ height: "2em",
458
+ viewBox: "0 0 24 24",
459
+ stroke: isMockOffline ? theme.defaultTheme.danger : 'currentColor',
460
+ fill: "none"
461
+ }, isMockOffline ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
462
+ stroke: "none",
463
+ d: "M0 0h24v24H0z",
464
+ fill: "none"
465
+ }), /*#__PURE__*/React__namespace.createElement("line", {
466
+ x1: "12",
467
+ y1: "18",
468
+ x2: "12.01",
469
+ y2: "18"
470
+ }), /*#__PURE__*/React__namespace.createElement("path", {
471
+ d: "M9.172 15.172a4 4 0 0 1 5.656 0"
472
+ }), /*#__PURE__*/React__namespace.createElement("path", {
473
+ 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"
474
+ }), /*#__PURE__*/React__namespace.createElement("path", {
475
+ d: "M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374"
476
+ }), /*#__PURE__*/React__namespace.createElement("line", {
477
+ x1: "3",
478
+ y1: "3",
479
+ x2: "21",
480
+ y2: "21"
481
+ })) : /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
482
+ stroke: "none",
483
+ d: "M0 0h24v24H0z",
484
+ fill: "none"
485
+ }), /*#__PURE__*/React__namespace.createElement("line", {
486
+ x1: "12",
487
+ y1: "18",
488
+ x2: "12.01",
489
+ y2: "18"
490
+ }), /*#__PURE__*/React__namespace.createElement("path", {
491
+ d: "M9.172 15.172a4 4 0 0 1 5.656 0"
492
+ }), /*#__PURE__*/React__namespace.createElement("path", {
493
+ d: "M6.343 12.343a8 8 0 0 1 11.314 0"
494
+ }), /*#__PURE__*/React__namespace.createElement("path", {
495
+ d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
496
+ }))), /*#__PURE__*/React__namespace.createElement(screenreader["default"], {
497
+ text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
498
+ }))) : null))), /*#__PURE__*/React__namespace.createElement("div", {
499
+ style: {
500
+ overflowY: 'auto',
501
+ flex: '1'
502
+ }
503
+ }, queries.map(query => {
504
+ return /*#__PURE__*/React__namespace.createElement(QueryRow, {
505
+ queryKey: query.queryKey,
506
+ activeQueryHash: activeQueryHash,
507
+ setActiveQueryHash: setActiveQueryHash,
508
+ key: query.queryHash,
509
+ queryCache: queryCache
510
+ });
511
+ }))), activeQueryHash ? /*#__PURE__*/React__namespace.createElement(ActiveQuery, {
512
+ activeQueryHash: activeQueryHash,
513
+ queryCache: queryCache,
514
+ queryClient: queryClient
515
+ }) : null));
516
+ });
517
+
518
+ const ActiveQuery = ({
519
+ queryCache,
520
+ activeQueryHash,
521
+ queryClient
522
+ }) => {
523
+ var _useSubscribeToQueryC, _useSubscribeToQueryC2;
524
+
525
+ const activeQuery = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
526
+ const activeQueryState = useSubscribeToQueryCache(queryCache, () => {
527
+ var _queryCache$getAll$fi;
528
+
529
+ return (_queryCache$getAll$fi = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi.state;
530
+ });
531
+ const isStale = (_useSubscribeToQueryC = useSubscribeToQueryCache(queryCache, () => {
532
+ var _queryCache$getAll$fi2;
533
+
534
+ return (_queryCache$getAll$fi2 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi2.isStale();
535
+ })) != null ? _useSubscribeToQueryC : false;
536
+ const observerCount = (_useSubscribeToQueryC2 = useSubscribeToQueryCache(queryCache, () => {
537
+ var _queryCache$getAll$fi3;
538
+
539
+ return (_queryCache$getAll$fi3 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi3.getObserversCount();
540
+ })) != null ? _useSubscribeToQueryC2 : 0;
541
+
542
+ const handleRefetch = () => {
543
+ const promise = activeQuery == null ? void 0 : activeQuery.fetch();
544
+ promise == null ? void 0 : promise.catch(noop);
545
+ };
546
+
547
+ if (!activeQuery || !activeQueryState) {
548
+ return null;
549
+ }
550
+
551
+ return /*#__PURE__*/React__namespace.createElement(styledComponents.ActiveQueryPanel, null, /*#__PURE__*/React__namespace.createElement("div", {
552
+ style: {
553
+ padding: '.5em',
554
+ background: theme.defaultTheme.backgroundAlt,
555
+ position: 'sticky',
556
+ top: 0,
557
+ zIndex: 1
558
+ }
559
+ }, "Query Details"), /*#__PURE__*/React__namespace.createElement("div", {
560
+ style: {
561
+ padding: '.5em'
562
+ }
563
+ }, /*#__PURE__*/React__namespace.createElement("div", {
564
+ style: {
565
+ marginBottom: '.5em',
566
+ display: 'flex',
567
+ alignItems: 'stretch',
568
+ justifyContent: 'space-between'
569
+ }
570
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.Code, {
571
+ style: {
572
+ lineHeight: '1.8em'
573
+ }
574
+ }, /*#__PURE__*/React__namespace.createElement("pre", {
575
+ style: {
576
+ margin: 0,
577
+ padding: 0,
578
+ overflow: 'auto'
579
+ }
580
+ }, JSON.stringify(activeQuery.queryKey, null, 2))), /*#__PURE__*/React__namespace.createElement("span", {
581
+ style: {
582
+ padding: '0.3em .6em',
583
+ borderRadius: '0.4em',
584
+ fontWeight: 'bold',
585
+ textShadow: '0 2px 10px black',
586
+ background: utils.getQueryStatusColor({
587
+ queryState: activeQueryState,
588
+ isStale: isStale,
589
+ observerCount: observerCount,
590
+ theme: theme.defaultTheme
591
+ }),
592
+ flexShrink: 0
593
+ }
594
+ }, utils.getQueryStatusLabel(activeQuery))), /*#__PURE__*/React__namespace.createElement("div", {
595
+ style: {
596
+ marginBottom: '.5em',
597
+ display: 'flex',
598
+ alignItems: 'center',
599
+ justifyContent: 'space-between'
600
+ }
601
+ }, "Observers: ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, observerCount)), /*#__PURE__*/React__namespace.createElement("div", {
602
+ style: {
603
+ display: 'flex',
604
+ alignItems: 'center',
605
+ justifyContent: 'space-between'
606
+ }
607
+ }, "Last Updated:", ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React__namespace.createElement("div", {
608
+ style: {
609
+ background: theme.defaultTheme.backgroundAlt,
610
+ padding: '.5em',
611
+ position: 'sticky',
612
+ top: 0,
613
+ zIndex: 1
614
+ }
615
+ }, "Actions"), /*#__PURE__*/React__namespace.createElement("div", {
616
+ style: {
617
+ padding: '0.5em'
618
+ }
619
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
620
+ type: "button",
621
+ onClick: handleRefetch,
622
+ disabled: activeQueryState.fetchStatus === 'fetching',
623
+ style: {
624
+ background: theme.defaultTheme.active
625
+ }
626
+ }, "Refetch"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
627
+ type: "button",
628
+ onClick: () => queryClient.invalidateQueries(activeQuery),
629
+ style: {
630
+ background: theme.defaultTheme.warning,
631
+ color: theme.defaultTheme.inputTextColor
632
+ }
633
+ }, "Invalidate"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
634
+ type: "button",
635
+ onClick: () => queryClient.resetQueries(activeQuery),
636
+ style: {
637
+ background: theme.defaultTheme.gray
638
+ }
639
+ }, "Reset"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
640
+ type: "button",
641
+ onClick: () => queryClient.removeQueries(activeQuery),
642
+ style: {
643
+ background: theme.defaultTheme.danger
644
+ }
645
+ }, "Remove")), /*#__PURE__*/React__namespace.createElement("div", {
646
+ style: {
647
+ background: theme.defaultTheme.backgroundAlt,
648
+ padding: '.5em',
649
+ position: 'sticky',
650
+ top: 0,
651
+ zIndex: 1
652
+ }
653
+ }, "Data Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
654
+ style: {
655
+ padding: '.5em'
656
+ }
657
+ }, /*#__PURE__*/React__namespace.createElement(Explorer["default"], {
658
+ label: "Data",
659
+ value: activeQueryState.data,
660
+ defaultExpanded: {}
661
+ })), /*#__PURE__*/React__namespace.createElement("div", {
662
+ style: {
663
+ background: theme.defaultTheme.backgroundAlt,
664
+ padding: '.5em',
665
+ position: 'sticky',
666
+ top: 0,
667
+ zIndex: 1
668
+ }
669
+ }, "Query Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
670
+ style: {
671
+ padding: '.5em'
672
+ }
673
+ }, /*#__PURE__*/React__namespace.createElement(Explorer["default"], {
674
+ label: "Query",
675
+ value: activeQuery,
676
+ defaultExpanded: {
677
+ queryKey: true
678
+ }
679
+ })));
680
+ };
681
+
682
+ const QueryStatusCount = ({
683
+ queryCache
684
+ }) => {
685
+ const hasFresh = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'fresh').length);
686
+ const hasFetching = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'fetching').length);
687
+ const hasPaused = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'paused').length);
688
+ const hasStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'stale').length);
689
+ const hasInactive = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'inactive').length);
690
+ return /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKeys, {
691
+ style: {
692
+ marginBottom: '.5em'
693
+ }
694
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
695
+ style: {
696
+ background: theme.defaultTheme.success,
697
+ opacity: hasFresh ? 1 : 0.3
698
+ }
699
+ }, "fresh ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
700
+ style: {
701
+ background: theme.defaultTheme.active,
702
+ opacity: hasFetching ? 1 : 0.3
703
+ }
704
+ }, "fetching ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
705
+ style: {
706
+ background: theme.defaultTheme.paused,
707
+ opacity: hasPaused ? 1 : 0.3
708
+ }
709
+ }, "paused ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
710
+ style: {
711
+ background: theme.defaultTheme.warning,
712
+ color: 'black',
713
+ textShadow: '0',
714
+ opacity: hasStale ? 1 : 0.3
715
+ }
716
+ }, "stale ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasStale, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
717
+ style: {
718
+ background: theme.defaultTheme.gray,
719
+ opacity: hasInactive ? 1 : 0.3
720
+ }
721
+ }, "inactive ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasInactive, ")")));
722
+ };
723
+
724
+ const QueryRow = ({
725
+ queryKey,
726
+ setActiveQueryHash,
727
+ activeQueryHash,
728
+ queryCache
729
+ }) => {
730
+ var _useSubscribeToQueryC3, _useSubscribeToQueryC4, _useSubscribeToQueryC5, _useSubscribeToQueryC6;
731
+
732
+ const queryHash = (_useSubscribeToQueryC3 = useSubscribeToQueryCache(queryCache, () => {
733
+ var _queryCache$find;
734
+
735
+ return (_queryCache$find = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find.queryHash;
736
+ })) != null ? _useSubscribeToQueryC3 : '';
737
+ const queryState = useSubscribeToQueryCache(queryCache, () => {
738
+ var _queryCache$find2;
739
+
740
+ return (_queryCache$find2 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find2.state;
741
+ });
742
+ const isStale = (_useSubscribeToQueryC4 = useSubscribeToQueryCache(queryCache, () => {
743
+ var _queryCache$find3;
744
+
745
+ return (_queryCache$find3 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find3.isStale();
746
+ })) != null ? _useSubscribeToQueryC4 : false;
747
+ const isDisabled = (_useSubscribeToQueryC5 = useSubscribeToQueryCache(queryCache, () => {
748
+ var _queryCache$find4;
749
+
750
+ return (_queryCache$find4 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find4.isDisabled();
751
+ })) != null ? _useSubscribeToQueryC5 : false;
752
+ const observerCount = (_useSubscribeToQueryC6 = useSubscribeToQueryCache(queryCache, () => {
753
+ var _queryCache$find5;
754
+
755
+ return (_queryCache$find5 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find5.getObserversCount();
756
+ })) != null ? _useSubscribeToQueryC6 : 0;
757
+
758
+ if (!queryState) {
759
+ return null;
760
+ }
761
+
762
+ return /*#__PURE__*/React__namespace.createElement("div", {
763
+ role: "button",
764
+ "aria-label": "Open query details for " + queryHash,
765
+ onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
766
+ style: {
767
+ display: 'flex',
768
+ borderBottom: "solid 1px " + theme.defaultTheme.grayAlt,
769
+ cursor: 'pointer',
770
+ background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
771
+ }
772
+ }, /*#__PURE__*/React__namespace.createElement("div", {
773
+ style: {
774
+ flex: '0 0 auto',
775
+ width: '2em',
776
+ height: '2em',
777
+ background: utils.getQueryStatusColor({
778
+ queryState,
779
+ isStale,
780
+ observerCount,
781
+ theme: theme.defaultTheme
782
+ }),
783
+ display: 'flex',
784
+ alignItems: 'center',
785
+ justifyContent: 'center',
786
+ fontWeight: 'bold',
787
+ textShadow: isStale ? '0' : '0 0 10px black',
788
+ color: isStale ? 'black' : 'white'
789
+ }
790
+ }, observerCount), isDisabled ? /*#__PURE__*/React__namespace.createElement("div", {
791
+ style: {
792
+ flex: '0 0 auto',
793
+ height: '2em',
794
+ background: theme.defaultTheme.gray,
795
+ display: 'flex',
796
+ alignItems: 'center',
797
+ fontWeight: 'bold',
798
+ padding: '0 0.5em'
799
+ }
800
+ }, "disabled") : null, /*#__PURE__*/React__namespace.createElement(styledComponents.Code, {
801
+ style: {
802
+ padding: '.5em'
803
+ }
804
+ }, "" + queryHash));
805
+ }; // eslint-disable-next-line @typescript-eslint/no-empty-function
806
+
807
+
808
+ function noop() {}
809
+
810
+ exports.ReactQueryDevtools = ReactQueryDevtools;
811
+ exports.ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel;
812
+ //# sourceMappingURL=devtools.js.map