@tanstack/react-query-devtools 5.0.0-alpha.12 → 5.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/devtools.d.ts +3 -64
- package/build/lib/devtools.esm.js +2 -669
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +3 -669
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +2 -639
- package/build/lib/devtools.mjs.map +1 -1
- package/build/lib/index.esm.js +2 -1
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +2 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +2 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/index.prod.esm.js +754 -713
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +751 -710
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +755 -714
- package/build/lib/index.prod.mjs.map +1 -1
- package/build/lib/styledComponents.esm.js +8 -0
- package/build/lib/styledComponents.esm.js.map +1 -1
- package/build/lib/styledComponents.js +8 -0
- package/build/lib/styledComponents.js.map +1 -1
- package/build/lib/styledComponents.mjs +8 -0
- package/build/lib/styledComponents.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 +2394 -2353
- package/build/umd/index.development.js.map +1 -1
- package/package.json +1 -1
- 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__/devtools.test.tsx +46 -0
- package/src/devtools.tsx +5 -1008
- package/src/styledComponents.ts +16 -0
- package/src/types.ts +12 -0
- package/src/useSubscribeToQueryCache.ts +26 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { useQueryClient, onlineManager, notifyManager } from '@tanstack/react-query';
|
|
4
|
-
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
2
|
+
import React__default from 'react';
|
|
5
3
|
import SuperJSON from 'superjson';
|
|
4
|
+
import { notifyManager, useQueryClient, onlineManager } from '@tanstack/react-query';
|
|
5
|
+
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
6
6
|
|
|
7
7
|
function _extends() {
|
|
8
8
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -291,6 +291,46 @@ function getResizeHandleStyle(position = 'bottom') {
|
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
function ScreenReader({
|
|
295
|
+
text
|
|
296
|
+
}) {
|
|
297
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
298
|
+
style: {
|
|
299
|
+
position: 'absolute',
|
|
300
|
+
width: '0.1px',
|
|
301
|
+
height: '0.1px',
|
|
302
|
+
overflow: 'hidden'
|
|
303
|
+
}
|
|
304
|
+
}, text);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function Logo(props) {
|
|
308
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
309
|
+
width: "40px",
|
|
310
|
+
height: "40px",
|
|
311
|
+
viewBox: "0 0 190 190",
|
|
312
|
+
version: "1.1"
|
|
313
|
+
}, props), /*#__PURE__*/React.createElement("g", {
|
|
314
|
+
stroke: "none",
|
|
315
|
+
strokeWidth: "1",
|
|
316
|
+
fill: "none",
|
|
317
|
+
fillRule: "evenodd"
|
|
318
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
319
|
+
transform: "translate(-33.000000, 0.000000)"
|
|
320
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
321
|
+
d: "M72.7239712,61.3436237 C69.631224,46.362877 68.9675112,34.8727722 70.9666331,26.5293551 C72.1555965,21.5671678 74.3293088,17.5190846 77.6346064,14.5984631 C81.1241394,11.5150478 85.5360327,10.0020122 90.493257,10.0020122 C98.6712013,10.0020122 107.26826,13.7273214 116.455725,20.8044264 C120.20312,23.6910458 124.092437,27.170411 128.131651,31.2444746 C128.45314,30.8310265 128.816542,30.4410453 129.22143,30.0806152 C140.64098,19.9149716 150.255245,13.5989272 158.478408,11.1636507 C163.367899,9.715636 167.958526,9.57768202 172.138936,10.983031 C176.551631,12.4664684 180.06766,15.5329489 182.548314,19.8281091 C186.642288,26.9166735 187.721918,36.2310983 186.195595,47.7320243 C185.573451,52.4199112 184.50985,57.5263831 183.007094,63.0593153 C183.574045,63.1277086 184.142416,63.2532808 184.705041,63.4395297 C199.193932,68.2358678 209.453582,73.3937462 215.665021,79.2882839 C219.360669,82.7953831 221.773972,86.6998434 222.646365,91.0218204 C223.567176,95.5836746 222.669313,100.159332 220.191548,104.451297 C216.105211,111.529614 208.591643,117.11221 197.887587,121.534031 C193.589552,123.309539 188.726579,124.917559 183.293259,126.363748 C183.541176,126.92292 183.733521,127.516759 183.862138,128.139758 C186.954886,143.120505 187.618598,154.61061 185.619477,162.954027 C184.430513,167.916214 182.256801,171.964297 178.951503,174.884919 C175.46197,177.968334 171.050077,179.48137 166.092853,179.48137 C157.914908,179.48137 149.31785,175.756061 140.130385,168.678956 C136.343104,165.761613 132.410866,162.238839 128.325434,158.108619 C127.905075,158.765474 127.388968,159.376011 126.77857,159.919385 C115.35902,170.085028 105.744755,176.401073 97.5215915,178.836349 C92.6321009,180.284364 88.0414736,180.422318 83.8610636,179.016969 C79.4483686,177.533532 75.9323404,174.467051 73.4516862,170.171891 C69.3577116,163.083327 68.2780823,153.768902 69.8044053,142.267976 C70.449038,137.410634 71.56762,132.103898 73.1575891,126.339009 C72.5361041,126.276104 71.9120754,126.144816 71.2949591,125.940529 C56.8060684,121.144191 46.5464184,115.986312 40.3349789,110.091775 C36.6393312,106.584675 34.2260275,102.680215 33.3536352,98.3582381 C32.4328237,93.7963839 33.3306866,89.2207269 35.8084524,84.9287618 C39.8947886,77.8504443 47.4083565,72.2678481 58.1124133,67.8460273 C62.5385143,66.0176154 67.5637208,64.366822 73.1939394,62.8874674 C72.9933393,62.3969171 72.8349374,61.8811235 72.7239712,61.3436237 Z",
|
|
322
|
+
fill: "#002C4B",
|
|
323
|
+
fillRule: "nonzero",
|
|
324
|
+
transform: "translate(128.000000, 95.000000) scale(-1, 1) translate(-128.000000, -95.000000) "
|
|
325
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
326
|
+
d: "M113.396882,64 L142.608177,64 C144.399254,64 146.053521,64.958025 146.944933,66.5115174 L161.577138,92.0115174 C162.461464,93.5526583 162.461464,95.4473417 161.577138,96.9884826 L146.944933,122.488483 C146.053521,124.041975 144.399254,125 142.608177,125 L113.396882,125 C111.605806,125 109.951539,124.041975 109.060126,122.488483 L94.4279211,96.9884826 C93.543596,95.4473417 93.543596,93.5526583 94.4279211,92.0115174 L109.060126,66.5115174 C109.951539,64.958025 111.605806,64 113.396882,64 Z M138.987827,70.2765273 C140.779849,70.2765273 142.434839,71.2355558 143.325899,72.7903404 L154.343038,92.0138131 C155.225607,93.5537825 155.225607,95.4462175 154.343038,96.9861869 L143.325899,116.20966 C142.434839,117.764444 140.779849,118.723473 138.987827,118.723473 L117.017233,118.723473 C115.225211,118.723473 113.570221,117.764444 112.67916,116.20966 L101.662022,96.9861869 C100.779452,95.4462175 100.779452,93.5537825 101.662022,92.0138131 L112.67916,72.7903404 C113.570221,71.2355558 115.225211,70.2765273 117.017233,70.2765273 L138.987827,70.2765273 Z M135.080648,77.1414791 L120.924411,77.1414791 C119.134228,77.1414791 117.480644,78.0985567 116.5889,79.6508285 L116.5889,79.6508285 L109.489217,92.0093494 C108.603232,93.5515958 108.603232,95.4484042 109.489217,96.9906506 L109.489217,96.9906506 L116.5889,109.349172 C117.480644,110.901443 119.134228,111.858521 120.924411,111.858521 L120.924411,111.858521 L135.080648,111.858521 C136.870831,111.858521 138.524416,110.901443 139.41616,109.349172 L139.41616,109.349172 L146.515843,96.9906506 C147.401828,95.4484042 147.401828,93.5515958 146.515843,92.0093494 L146.515843,92.0093494 L139.41616,79.6508285 C138.524416,78.0985567 136.870831,77.1414791 135.080648,77.1414791 L135.080648,77.1414791 Z M131.319186,83.7122186 C133.108028,83.7122186 134.760587,84.6678753 135.652827,86.2183156 L138.983552,92.0060969 C139.87203,93.5500005 139.87203,95.4499995 138.983552,96.9939031 L135.652827,102.781684 C134.760587,104.332125 133.108028,105.287781 131.319186,105.287781 L124.685874,105.287781 C122.897032,105.287781 121.244473,104.332125 120.352233,102.781684 L117.021508,96.9939031 C116.13303,95.4499995 116.13303,93.5500005 117.021508,92.0060969 L120.352233,86.2183156 C121.244473,84.6678753 122.897032,83.7122186 124.685874,83.7122186 L131.319186,83.7122186 Z M128.003794,90.1848875 C126.459294,90.1848875 125.034382,91.0072828 124.263005,92.3424437 C123.491732,93.6774232 123.491732,95.3225768 124.263005,96.6575563 C125.034382,97.9927172 126.459294,98.8151125 128.001266,98.8151125 L128.001266,98.8151125 C129.545766,98.8151125 130.970678,97.9927172 131.742055,96.6575563 C132.513327,95.3225768 132.513327,93.6774232 131.742055,92.3424437 C130.970678,91.0072828 129.545766,90.1848875 128.003794,90.1848875 L128.003794,90.1848875 Z M93,94.5009646 L100.767764,94.5009646",
|
|
327
|
+
fill: "#FFD94C"
|
|
328
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
329
|
+
d: "M87.8601729,108.357758 C89.1715224,107.608286 90.8360246,108.074601 91.5779424,109.399303 L91.5779424,109.399303 L92.0525843,110.24352 C95.8563392,116.982993 99.8190116,123.380176 103.940602,129.435068 C108.807881,136.585427 114.28184,143.82411 120.362479,151.151115 C121.316878,152.30114 121.184944,154.011176 120.065686,154.997937 L120.065686,154.997937 L119.454208,155.534625 C99.3465389,173.103314 86.2778188,176.612552 80.2480482,166.062341 C74.3500652,155.742717 76.4844915,136.982888 86.6513274,109.782853 C86.876818,109.179582 87.3045861,108.675291 87.8601729,108.357758 Z M173.534177,129.041504 C174.986131,128.785177 176.375496,129.742138 176.65963,131.194242 L176.65963,131.194242 L176.812815,131.986376 C181.782365,157.995459 178.283348,171 166.315764,171 C154.609745,171 139.708724,159.909007 121.612702,137.727022 C121.211349,137.235047 120.994572,136.617371 121,135.981509 C121.013158,134.480686 122.235785,133.274651 123.730918,133.287756 L123.730918,133.287756 L124.684654,133.294531 C132.305698,133.335994 139.714387,133.071591 146.910723,132.501323 C155.409039,131.82788 164.283523,130.674607 173.534177,129.041504 Z M180.408726,73.8119663 C180.932139,72.4026903 182.508386,71.6634537 183.954581,72.149012 L183.954581,72.149012 L184.742552,72.4154854 C210.583763,81.217922 220.402356,90.8916805 214.198332,101.436761 C208.129904,111.751366 190.484347,119.260339 161.26166,123.963678 C160.613529,124.067994 159.948643,123.945969 159.382735,123.618843 C158.047025,122.846729 157.602046,121.158214 158.388848,119.847438 L158.388848,119.847438 L158.889328,119.0105 C162.877183,112.31633 166.481358,105.654262 169.701854,99.0242957 C173.50501,91.1948179 177.073967,82.7907081 180.408726,73.8119663 Z M94.7383398,66.0363218 C95.3864708,65.9320063 96.0513565,66.0540315 96.6172646,66.3811573 C97.9529754,67.153271 98.3979538,68.8417862 97.6111517,70.1525615 L97.6111517,70.1525615 L97.1106718,70.9895001 C93.1228168,77.6836699 89.5186416,84.3457379 86.2981462,90.9757043 C82.49499,98.8051821 78.9260328,107.209292 75.5912744,116.188034 C75.0678608,117.59731 73.4916142,118.336546 72.045419,117.850988 L72.045419,117.850988 L71.2574475,117.584515 C45.4162372,108.782078 35.597644,99.1083195 41.8016679,88.5632391 C47.8700957,78.2486335 65.515653,70.7396611 94.7383398,66.0363218 Z M136.545792,34.4653746 C156.653461,16.8966864 169.722181,13.3874478 175.751952,23.9376587 C181.649935,34.2572826 179.515508,53.0171122 169.348673,80.2171474 C169.123182,80.8204179 168.695414,81.324709 168.139827,81.6422422 C166.828478,82.3917144 165.163975,81.9253986 164.422058,80.6006966 L164.422058,80.6006966 L163.947416,79.7564798 C160.143661,73.0170065 156.180988,66.6198239 152.059398,60.564932 C147.192119,53.4145727 141.71816,46.1758903 135.637521,38.8488847 C134.683122,37.6988602 134.815056,35.9888243 135.934314,35.0020629 L135.934314,35.0020629 Z M90.6842361,18 C102.390255,18 117.291276,29.0909926 135.387298,51.2729777 C135.788651,51.7649527 136.005428,52.3826288 136,53.0184911 C135.986842,54.5193144 134.764215,55.7253489 133.269082,55.7122445 L133.269082,55.7122445 L132.315346,55.7054689 C124.694302,55.6640063 117.285613,55.9284091 110.089277,56.4986773 C101.590961,57.17212 92.7164767,58.325393 83.4658235,59.9584962 C82.0138691,60.2148231 80.6245044,59.2578618 80.3403697,57.805758 L80.3403697,57.805758 L80.1871846,57.0136235 C75.2176347,31.0045412 78.7166519,18 90.6842361,18 Z",
|
|
330
|
+
fill: "#FF4154"
|
|
331
|
+
}))));
|
|
332
|
+
}
|
|
333
|
+
|
|
294
334
|
const Panel = styled('div', (_props, theme) => ({
|
|
295
335
|
fontSize: 'clamp(12px, 1.5vw, 14px)',
|
|
296
336
|
fontFamily: `sans-serif`,
|
|
@@ -307,6 +347,7 @@ const Panel = styled('div', (_props, theme) => ({
|
|
|
307
347
|
}
|
|
308
348
|
});
|
|
309
349
|
|
|
350
|
+
Panel.displayName = 'Panel';
|
|
310
351
|
const ActiveQueryPanel = styled('div', () => ({
|
|
311
352
|
flex: '1 1 500px',
|
|
312
353
|
display: 'flex',
|
|
@@ -318,6 +359,7 @@ const ActiveQueryPanel = styled('div', () => ({
|
|
|
318
359
|
borderTop: `2px solid ${theme.gray}`
|
|
319
360
|
})
|
|
320
361
|
});
|
|
362
|
+
ActiveQueryPanel.displayName = 'ActiveQueryPanel';
|
|
321
363
|
const Button = styled('button', (props, theme) => ({
|
|
322
364
|
appearance: 'none',
|
|
323
365
|
fontSize: '.9em',
|
|
@@ -330,12 +372,14 @@ const Button = styled('button', (props, theme) => ({
|
|
|
330
372
|
opacity: props.disabled ? '.5' : undefined,
|
|
331
373
|
cursor: 'pointer'
|
|
332
374
|
}));
|
|
375
|
+
Button.displayName = 'Button';
|
|
333
376
|
const QueryKeys = styled('span', {
|
|
334
377
|
display: 'flex',
|
|
335
378
|
flexWrap: 'wrap',
|
|
336
379
|
gap: '0.5em',
|
|
337
380
|
fontSize: '0.9em'
|
|
338
381
|
});
|
|
382
|
+
QueryKeys.displayName = 'QueryKeys';
|
|
339
383
|
const QueryKey = styled('span', {
|
|
340
384
|
display: 'inline-flex',
|
|
341
385
|
alignItems: 'center',
|
|
@@ -344,11 +388,13 @@ const QueryKey = styled('span', {
|
|
|
344
388
|
textShadow: '0 0 10px black',
|
|
345
389
|
borderRadius: '.2em'
|
|
346
390
|
});
|
|
391
|
+
QueryKey.displayName = 'QueryKey';
|
|
347
392
|
const Code = styled('code', {
|
|
348
393
|
fontSize: '.9em',
|
|
349
394
|
color: 'inherit',
|
|
350
395
|
background: 'inherit'
|
|
351
396
|
});
|
|
397
|
+
Code.displayName = 'Code';
|
|
352
398
|
const Input = styled('input', (_props, theme) => ({
|
|
353
399
|
backgroundColor: theme.inputBackgroundColor,
|
|
354
400
|
border: 0,
|
|
@@ -358,6 +404,7 @@ const Input = styled('input', (_props, theme) => ({
|
|
|
358
404
|
lineHeight: `1.3`,
|
|
359
405
|
padding: '.3em .4em'
|
|
360
406
|
}));
|
|
407
|
+
Input.displayName = 'Input';
|
|
361
408
|
const Select = styled('select', (_props, theme) => ({
|
|
362
409
|
display: `inline-block`,
|
|
363
410
|
fontSize: `.9em`,
|
|
@@ -381,20 +428,149 @@ const Select = styled('select', (_props, theme) => ({
|
|
|
381
428
|
display: 'none'
|
|
382
429
|
}
|
|
383
430
|
});
|
|
431
|
+
Select.displayName = 'Select';
|
|
384
432
|
|
|
385
|
-
|
|
386
|
-
|
|
433
|
+
const useSubscribeToQueryCache = (queryCache, getSnapshot, skip = false) => {
|
|
434
|
+
return React__default.useSyncExternalStore(React__default.useCallback(onStoreChange => {
|
|
435
|
+
if (!skip) return queryCache.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
436
|
+
return () => {
|
|
437
|
+
return;
|
|
438
|
+
};
|
|
439
|
+
}, [queryCache, skip]), getSnapshot, getSnapshot);
|
|
440
|
+
};
|
|
441
|
+
var useSubscribeToQueryCache$1 = useSubscribeToQueryCache;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Displays the number of queries for each status
|
|
445
|
+
*/
|
|
446
|
+
function QueryStatusCount({
|
|
447
|
+
queryCache
|
|
387
448
|
}) {
|
|
388
|
-
|
|
449
|
+
const hasFresh = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fresh').length);
|
|
450
|
+
const hasFetching = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fetching').length);
|
|
451
|
+
const hasPaused = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'paused').length);
|
|
452
|
+
const hasStale = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'stale').length);
|
|
453
|
+
const hasInactive = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'inactive').length);
|
|
454
|
+
return /*#__PURE__*/React__default.createElement(QueryKeys, null, /*#__PURE__*/React__default.createElement(QueryKey, {
|
|
389
455
|
style: {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
height: '0.1px',
|
|
393
|
-
overflow: 'hidden'
|
|
456
|
+
background: defaultTheme.success,
|
|
457
|
+
opacity: hasFresh ? 1 : 0.3
|
|
394
458
|
}
|
|
395
|
-
},
|
|
459
|
+
}, "fresh ", /*#__PURE__*/React__default.createElement(Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React__default.createElement(QueryKey, {
|
|
460
|
+
style: {
|
|
461
|
+
background: defaultTheme.active,
|
|
462
|
+
opacity: hasFetching ? 1 : 0.3
|
|
463
|
+
}
|
|
464
|
+
}, "fetching ", /*#__PURE__*/React__default.createElement(Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React__default.createElement(QueryKey, {
|
|
465
|
+
style: {
|
|
466
|
+
background: defaultTheme.paused,
|
|
467
|
+
opacity: hasPaused ? 1 : 0.3
|
|
468
|
+
}
|
|
469
|
+
}, "paused ", /*#__PURE__*/React__default.createElement(Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React__default.createElement(QueryKey, {
|
|
470
|
+
style: {
|
|
471
|
+
background: defaultTheme.warning,
|
|
472
|
+
color: 'black',
|
|
473
|
+
textShadow: '0',
|
|
474
|
+
opacity: hasStale ? 1 : 0.3
|
|
475
|
+
}
|
|
476
|
+
}, "stale ", /*#__PURE__*/React__default.createElement(Code, null, "(", hasStale, ")")), ' ', /*#__PURE__*/React__default.createElement(QueryKey, {
|
|
477
|
+
style: {
|
|
478
|
+
background: defaultTheme.gray,
|
|
479
|
+
opacity: hasInactive ? 1 : 0.3
|
|
480
|
+
}
|
|
481
|
+
}, "inactive ", /*#__PURE__*/React__default.createElement(Code, null, "(", hasInactive, ")")));
|
|
396
482
|
}
|
|
397
483
|
|
|
484
|
+
/**
|
|
485
|
+
* Row for a query in the query list
|
|
486
|
+
*/
|
|
487
|
+
const QueryRow = /*#__PURE__*/React__default.memo(({
|
|
488
|
+
queryKey,
|
|
489
|
+
setActiveQueryHash,
|
|
490
|
+
activeQueryHash,
|
|
491
|
+
queryCache
|
|
492
|
+
}) => {
|
|
493
|
+
var _useSubscribeToQueryC, _useSubscribeToQueryC2, _useSubscribeToQueryC3, _useSubscribeToQueryC4;
|
|
494
|
+
const queryHash = (_useSubscribeToQueryC = useSubscribeToQueryCache$1(queryCache, () => {
|
|
495
|
+
var _queryCache$find;
|
|
496
|
+
return (_queryCache$find = queryCache.find({
|
|
497
|
+
queryKey
|
|
498
|
+
})) == null ? void 0 : _queryCache$find.queryHash;
|
|
499
|
+
})) != null ? _useSubscribeToQueryC : '';
|
|
500
|
+
const queryState = useSubscribeToQueryCache$1(queryCache, () => {
|
|
501
|
+
var _queryCache$find2;
|
|
502
|
+
return (_queryCache$find2 = queryCache.find({
|
|
503
|
+
queryKey
|
|
504
|
+
})) == null ? void 0 : _queryCache$find2.state;
|
|
505
|
+
});
|
|
506
|
+
const isStale = (_useSubscribeToQueryC2 = useSubscribeToQueryCache$1(queryCache, () => {
|
|
507
|
+
var _queryCache$find3;
|
|
508
|
+
return (_queryCache$find3 = queryCache.find({
|
|
509
|
+
queryKey
|
|
510
|
+
})) == null ? void 0 : _queryCache$find3.isStale();
|
|
511
|
+
})) != null ? _useSubscribeToQueryC2 : false;
|
|
512
|
+
const isDisabled = (_useSubscribeToQueryC3 = useSubscribeToQueryCache$1(queryCache, () => {
|
|
513
|
+
var _queryCache$find4;
|
|
514
|
+
return (_queryCache$find4 = queryCache.find({
|
|
515
|
+
queryKey
|
|
516
|
+
})) == null ? void 0 : _queryCache$find4.isDisabled();
|
|
517
|
+
})) != null ? _useSubscribeToQueryC3 : false;
|
|
518
|
+
const observerCount = (_useSubscribeToQueryC4 = useSubscribeToQueryCache$1(queryCache, () => {
|
|
519
|
+
var _queryCache$find5;
|
|
520
|
+
return (_queryCache$find5 = queryCache.find({
|
|
521
|
+
queryKey
|
|
522
|
+
})) == null ? void 0 : _queryCache$find5.getObserversCount();
|
|
523
|
+
})) != null ? _useSubscribeToQueryC4 : 0;
|
|
524
|
+
if (!queryState) {
|
|
525
|
+
return null;
|
|
526
|
+
}
|
|
527
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
528
|
+
role: "button",
|
|
529
|
+
"aria-label": `Open query details for ${queryHash}`,
|
|
530
|
+
onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
|
|
531
|
+
style: {
|
|
532
|
+
display: 'flex',
|
|
533
|
+
borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
|
|
534
|
+
cursor: 'pointer',
|
|
535
|
+
background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
|
|
536
|
+
}
|
|
537
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
538
|
+
style: {
|
|
539
|
+
flex: '0 0 auto',
|
|
540
|
+
width: '2em',
|
|
541
|
+
height: '2em',
|
|
542
|
+
background: getQueryStatusColor({
|
|
543
|
+
queryState,
|
|
544
|
+
isStale,
|
|
545
|
+
observerCount,
|
|
546
|
+
theme: defaultTheme
|
|
547
|
+
}),
|
|
548
|
+
display: 'flex',
|
|
549
|
+
alignItems: 'center',
|
|
550
|
+
justifyContent: 'center',
|
|
551
|
+
fontWeight: 'bold',
|
|
552
|
+
textShadow: isStale ? '0' : '0 0 10px black',
|
|
553
|
+
color: isStale ? 'black' : 'white'
|
|
554
|
+
}
|
|
555
|
+
}, observerCount), isDisabled ? /*#__PURE__*/React__default.createElement("div", {
|
|
556
|
+
style: {
|
|
557
|
+
flex: '0 0 auto',
|
|
558
|
+
height: '2em',
|
|
559
|
+
background: defaultTheme.gray,
|
|
560
|
+
display: 'flex',
|
|
561
|
+
alignItems: 'center',
|
|
562
|
+
fontWeight: 'bold',
|
|
563
|
+
padding: '0 0.5em'
|
|
564
|
+
}
|
|
565
|
+
}, "disabled") : null, /*#__PURE__*/React__default.createElement(Code, {
|
|
566
|
+
style: {
|
|
567
|
+
padding: '.5em'
|
|
568
|
+
}
|
|
569
|
+
}, `${queryHash}`));
|
|
570
|
+
});
|
|
571
|
+
QueryRow.displayName = 'QueryRow';
|
|
572
|
+
var QueryRow$1 = QueryRow;
|
|
573
|
+
|
|
398
574
|
const Entry = styled('div', {
|
|
399
575
|
fontFamily: 'Menlo, monospace',
|
|
400
576
|
fontSize: '1em',
|
|
@@ -641,318 +817,324 @@ function Explorer({
|
|
|
641
817
|
});
|
|
642
818
|
}
|
|
643
819
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
width: "40px",
|
|
647
|
-
height: "40px",
|
|
648
|
-
viewBox: "0 0 190 190",
|
|
649
|
-
version: "1.1"
|
|
650
|
-
}, props), /*#__PURE__*/React.createElement("g", {
|
|
651
|
-
stroke: "none",
|
|
652
|
-
strokeWidth: "1",
|
|
653
|
-
fill: "none",
|
|
654
|
-
fillRule: "evenodd"
|
|
655
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
656
|
-
transform: "translate(-33.000000, 0.000000)"
|
|
657
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
658
|
-
d: "M72.7239712,61.3436237 C69.631224,46.362877 68.9675112,34.8727722 70.9666331,26.5293551 C72.1555965,21.5671678 74.3293088,17.5190846 77.6346064,14.5984631 C81.1241394,11.5150478 85.5360327,10.0020122 90.493257,10.0020122 C98.6712013,10.0020122 107.26826,13.7273214 116.455725,20.8044264 C120.20312,23.6910458 124.092437,27.170411 128.131651,31.2444746 C128.45314,30.8310265 128.816542,30.4410453 129.22143,30.0806152 C140.64098,19.9149716 150.255245,13.5989272 158.478408,11.1636507 C163.367899,9.715636 167.958526,9.57768202 172.138936,10.983031 C176.551631,12.4664684 180.06766,15.5329489 182.548314,19.8281091 C186.642288,26.9166735 187.721918,36.2310983 186.195595,47.7320243 C185.573451,52.4199112 184.50985,57.5263831 183.007094,63.0593153 C183.574045,63.1277086 184.142416,63.2532808 184.705041,63.4395297 C199.193932,68.2358678 209.453582,73.3937462 215.665021,79.2882839 C219.360669,82.7953831 221.773972,86.6998434 222.646365,91.0218204 C223.567176,95.5836746 222.669313,100.159332 220.191548,104.451297 C216.105211,111.529614 208.591643,117.11221 197.887587,121.534031 C193.589552,123.309539 188.726579,124.917559 183.293259,126.363748 C183.541176,126.92292 183.733521,127.516759 183.862138,128.139758 C186.954886,143.120505 187.618598,154.61061 185.619477,162.954027 C184.430513,167.916214 182.256801,171.964297 178.951503,174.884919 C175.46197,177.968334 171.050077,179.48137 166.092853,179.48137 C157.914908,179.48137 149.31785,175.756061 140.130385,168.678956 C136.343104,165.761613 132.410866,162.238839 128.325434,158.108619 C127.905075,158.765474 127.388968,159.376011 126.77857,159.919385 C115.35902,170.085028 105.744755,176.401073 97.5215915,178.836349 C92.6321009,180.284364 88.0414736,180.422318 83.8610636,179.016969 C79.4483686,177.533532 75.9323404,174.467051 73.4516862,170.171891 C69.3577116,163.083327 68.2780823,153.768902 69.8044053,142.267976 C70.449038,137.410634 71.56762,132.103898 73.1575891,126.339009 C72.5361041,126.276104 71.9120754,126.144816 71.2949591,125.940529 C56.8060684,121.144191 46.5464184,115.986312 40.3349789,110.091775 C36.6393312,106.584675 34.2260275,102.680215 33.3536352,98.3582381 C32.4328237,93.7963839 33.3306866,89.2207269 35.8084524,84.9287618 C39.8947886,77.8504443 47.4083565,72.2678481 58.1124133,67.8460273 C62.5385143,66.0176154 67.5637208,64.366822 73.1939394,62.8874674 C72.9933393,62.3969171 72.8349374,61.8811235 72.7239712,61.3436237 Z",
|
|
659
|
-
fill: "#002C4B",
|
|
660
|
-
fillRule: "nonzero",
|
|
661
|
-
transform: "translate(128.000000, 95.000000) scale(-1, 1) translate(-128.000000, -95.000000) "
|
|
662
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
663
|
-
d: "M113.396882,64 L142.608177,64 C144.399254,64 146.053521,64.958025 146.944933,66.5115174 L161.577138,92.0115174 C162.461464,93.5526583 162.461464,95.4473417 161.577138,96.9884826 L146.944933,122.488483 C146.053521,124.041975 144.399254,125 142.608177,125 L113.396882,125 C111.605806,125 109.951539,124.041975 109.060126,122.488483 L94.4279211,96.9884826 C93.543596,95.4473417 93.543596,93.5526583 94.4279211,92.0115174 L109.060126,66.5115174 C109.951539,64.958025 111.605806,64 113.396882,64 Z M138.987827,70.2765273 C140.779849,70.2765273 142.434839,71.2355558 143.325899,72.7903404 L154.343038,92.0138131 C155.225607,93.5537825 155.225607,95.4462175 154.343038,96.9861869 L143.325899,116.20966 C142.434839,117.764444 140.779849,118.723473 138.987827,118.723473 L117.017233,118.723473 C115.225211,118.723473 113.570221,117.764444 112.67916,116.20966 L101.662022,96.9861869 C100.779452,95.4462175 100.779452,93.5537825 101.662022,92.0138131 L112.67916,72.7903404 C113.570221,71.2355558 115.225211,70.2765273 117.017233,70.2765273 L138.987827,70.2765273 Z M135.080648,77.1414791 L120.924411,77.1414791 C119.134228,77.1414791 117.480644,78.0985567 116.5889,79.6508285 L116.5889,79.6508285 L109.489217,92.0093494 C108.603232,93.5515958 108.603232,95.4484042 109.489217,96.9906506 L109.489217,96.9906506 L116.5889,109.349172 C117.480644,110.901443 119.134228,111.858521 120.924411,111.858521 L120.924411,111.858521 L135.080648,111.858521 C136.870831,111.858521 138.524416,110.901443 139.41616,109.349172 L139.41616,109.349172 L146.515843,96.9906506 C147.401828,95.4484042 147.401828,93.5515958 146.515843,92.0093494 L146.515843,92.0093494 L139.41616,79.6508285 C138.524416,78.0985567 136.870831,77.1414791 135.080648,77.1414791 L135.080648,77.1414791 Z M131.319186,83.7122186 C133.108028,83.7122186 134.760587,84.6678753 135.652827,86.2183156 L138.983552,92.0060969 C139.87203,93.5500005 139.87203,95.4499995 138.983552,96.9939031 L135.652827,102.781684 C134.760587,104.332125 133.108028,105.287781 131.319186,105.287781 L124.685874,105.287781 C122.897032,105.287781 121.244473,104.332125 120.352233,102.781684 L117.021508,96.9939031 C116.13303,95.4499995 116.13303,93.5500005 117.021508,92.0060969 L120.352233,86.2183156 C121.244473,84.6678753 122.897032,83.7122186 124.685874,83.7122186 L131.319186,83.7122186 Z M128.003794,90.1848875 C126.459294,90.1848875 125.034382,91.0072828 124.263005,92.3424437 C123.491732,93.6774232 123.491732,95.3225768 124.263005,96.6575563 C125.034382,97.9927172 126.459294,98.8151125 128.001266,98.8151125 L128.001266,98.8151125 C129.545766,98.8151125 130.970678,97.9927172 131.742055,96.6575563 C132.513327,95.3225768 132.513327,93.6774232 131.742055,92.3424437 C130.970678,91.0072828 129.545766,90.1848875 128.003794,90.1848875 L128.003794,90.1848875 Z M93,94.5009646 L100.767764,94.5009646",
|
|
664
|
-
fill: "#FFD94C"
|
|
665
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
666
|
-
d: "M87.8601729,108.357758 C89.1715224,107.608286 90.8360246,108.074601 91.5779424,109.399303 L91.5779424,109.399303 L92.0525843,110.24352 C95.8563392,116.982993 99.8190116,123.380176 103.940602,129.435068 C108.807881,136.585427 114.28184,143.82411 120.362479,151.151115 C121.316878,152.30114 121.184944,154.011176 120.065686,154.997937 L120.065686,154.997937 L119.454208,155.534625 C99.3465389,173.103314 86.2778188,176.612552 80.2480482,166.062341 C74.3500652,155.742717 76.4844915,136.982888 86.6513274,109.782853 C86.876818,109.179582 87.3045861,108.675291 87.8601729,108.357758 Z M173.534177,129.041504 C174.986131,128.785177 176.375496,129.742138 176.65963,131.194242 L176.65963,131.194242 L176.812815,131.986376 C181.782365,157.995459 178.283348,171 166.315764,171 C154.609745,171 139.708724,159.909007 121.612702,137.727022 C121.211349,137.235047 120.994572,136.617371 121,135.981509 C121.013158,134.480686 122.235785,133.274651 123.730918,133.287756 L123.730918,133.287756 L124.684654,133.294531 C132.305698,133.335994 139.714387,133.071591 146.910723,132.501323 C155.409039,131.82788 164.283523,130.674607 173.534177,129.041504 Z M180.408726,73.8119663 C180.932139,72.4026903 182.508386,71.6634537 183.954581,72.149012 L183.954581,72.149012 L184.742552,72.4154854 C210.583763,81.217922 220.402356,90.8916805 214.198332,101.436761 C208.129904,111.751366 190.484347,119.260339 161.26166,123.963678 C160.613529,124.067994 159.948643,123.945969 159.382735,123.618843 C158.047025,122.846729 157.602046,121.158214 158.388848,119.847438 L158.388848,119.847438 L158.889328,119.0105 C162.877183,112.31633 166.481358,105.654262 169.701854,99.0242957 C173.50501,91.1948179 177.073967,82.7907081 180.408726,73.8119663 Z M94.7383398,66.0363218 C95.3864708,65.9320063 96.0513565,66.0540315 96.6172646,66.3811573 C97.9529754,67.153271 98.3979538,68.8417862 97.6111517,70.1525615 L97.6111517,70.1525615 L97.1106718,70.9895001 C93.1228168,77.6836699 89.5186416,84.3457379 86.2981462,90.9757043 C82.49499,98.8051821 78.9260328,107.209292 75.5912744,116.188034 C75.0678608,117.59731 73.4916142,118.336546 72.045419,117.850988 L72.045419,117.850988 L71.2574475,117.584515 C45.4162372,108.782078 35.597644,99.1083195 41.8016679,88.5632391 C47.8700957,78.2486335 65.515653,70.7396611 94.7383398,66.0363218 Z M136.545792,34.4653746 C156.653461,16.8966864 169.722181,13.3874478 175.751952,23.9376587 C181.649935,34.2572826 179.515508,53.0171122 169.348673,80.2171474 C169.123182,80.8204179 168.695414,81.324709 168.139827,81.6422422 C166.828478,82.3917144 165.163975,81.9253986 164.422058,80.6006966 L164.422058,80.6006966 L163.947416,79.7564798 C160.143661,73.0170065 156.180988,66.6198239 152.059398,60.564932 C147.192119,53.4145727 141.71816,46.1758903 135.637521,38.8488847 C134.683122,37.6988602 134.815056,35.9888243 135.934314,35.0020629 L135.934314,35.0020629 Z M90.6842361,18 C102.390255,18 117.291276,29.0909926 135.387298,51.2729777 C135.788651,51.7649527 136.005428,52.3826288 136,53.0184911 C135.986842,54.5193144 134.764215,55.7253489 133.269082,55.7122445 L133.269082,55.7122445 L132.315346,55.7054689 C124.694302,55.6640063 117.285613,55.9284091 110.089277,56.4986773 C101.590961,57.17212 92.7164767,58.325393 83.4658235,59.9584962 C82.0138691,60.2148231 80.6245044,59.2578618 80.3403697,57.805758 L80.3403697,57.805758 L80.1871846,57.0136235 C75.2176347,31.0045412 78.7166519,18 90.6842361,18 Z",
|
|
667
|
-
fill: "#FF4154"
|
|
668
|
-
}))));
|
|
669
|
-
}
|
|
820
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
821
|
+
function noop() {}
|
|
670
822
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
823
|
+
/**
|
|
824
|
+
* Panel for the query currently being inspected
|
|
825
|
+
*
|
|
826
|
+
* It displays query details (key, observers...), query actions,
|
|
827
|
+
* the data explorer and the query explorer
|
|
828
|
+
*/
|
|
829
|
+
const ActiveQuery = ({
|
|
830
|
+
queryCache,
|
|
831
|
+
activeQueryHash,
|
|
678
832
|
queryClient,
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
moveEvent.preventDefault();
|
|
707
|
-
|
|
708
|
-
// calculate the correct size based on mouse position and current panel position
|
|
709
|
-
// hint: it is different formula for the opposite sides
|
|
710
|
-
if (isVertical) {
|
|
711
|
-
newSize = width + (panelPosition === 'right' ? startX - moveEvent.clientX : moveEvent.clientX - startX);
|
|
712
|
-
setDevtoolsWidth(newSize);
|
|
713
|
-
} else {
|
|
714
|
-
newSize = height + (panelPosition === 'bottom' ? startY - moveEvent.clientY : moveEvent.clientY - startY);
|
|
715
|
-
setDevtoolsHeight(newSize);
|
|
716
|
-
}
|
|
717
|
-
if (newSize < minPanelSize) {
|
|
718
|
-
setIsOpen(false);
|
|
719
|
-
} else {
|
|
720
|
-
setIsOpen(true);
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
const unsub = () => {
|
|
724
|
-
if (isResizing) {
|
|
725
|
-
setIsResizing(false);
|
|
726
|
-
}
|
|
727
|
-
document.removeEventListener('mousemove', run, false);
|
|
728
|
-
document.removeEventListener('mouseUp', unsub, false);
|
|
729
|
-
};
|
|
730
|
-
document.addEventListener('mousemove', run, false);
|
|
731
|
-
document.addEventListener('mouseup', unsub, false);
|
|
732
|
-
};
|
|
733
|
-
React.useEffect(() => {
|
|
734
|
-
setIsResolvedOpen(isOpen != null ? isOpen : false);
|
|
735
|
-
}, [isOpen, isResolvedOpen, setIsResolvedOpen]);
|
|
736
|
-
|
|
737
|
-
// Toggle panel visibility before/after transition (depending on direction).
|
|
738
|
-
// Prevents focusing in a closed panel.
|
|
739
|
-
React.useEffect(() => {
|
|
740
|
-
const ref = panelRef.current;
|
|
741
|
-
if (ref) {
|
|
742
|
-
const handlePanelTransitionStart = () => {
|
|
743
|
-
if (isResolvedOpen) {
|
|
744
|
-
ref.style.visibility = 'visible';
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
const handlePanelTransitionEnd = () => {
|
|
748
|
-
if (!isResolvedOpen) {
|
|
749
|
-
ref.style.visibility = 'hidden';
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
ref.addEventListener('transitionstart', handlePanelTransitionStart);
|
|
753
|
-
ref.addEventListener('transitionend', handlePanelTransitionEnd);
|
|
754
|
-
return () => {
|
|
755
|
-
ref.removeEventListener('transitionstart', handlePanelTransitionStart);
|
|
756
|
-
ref.removeEventListener('transitionend', handlePanelTransitionEnd);
|
|
757
|
-
};
|
|
833
|
+
errorTypes
|
|
834
|
+
}) => {
|
|
835
|
+
var _useSubscribeToQueryC, _useSubscribeToQueryC2;
|
|
836
|
+
const activeQuery = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
|
|
837
|
+
const activeQueryState = useSubscribeToQueryCache$1(queryCache, () => {
|
|
838
|
+
var _queryCache$getAll$fi;
|
|
839
|
+
return (_queryCache$getAll$fi = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi.state;
|
|
840
|
+
});
|
|
841
|
+
const isStale = (_useSubscribeToQueryC = useSubscribeToQueryCache$1(queryCache, () => {
|
|
842
|
+
var _queryCache$getAll$fi2;
|
|
843
|
+
return (_queryCache$getAll$fi2 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi2.isStale();
|
|
844
|
+
})) != null ? _useSubscribeToQueryC : false;
|
|
845
|
+
const observerCount = (_useSubscribeToQueryC2 = useSubscribeToQueryCache$1(queryCache, () => {
|
|
846
|
+
var _queryCache$getAll$fi3;
|
|
847
|
+
return (_queryCache$getAll$fi3 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi3.getObserversCount();
|
|
848
|
+
})) != null ? _useSubscribeToQueryC2 : 0;
|
|
849
|
+
const handleRefetch = () => {
|
|
850
|
+
const promise = activeQuery == null ? void 0 : activeQuery.fetch();
|
|
851
|
+
promise == null ? void 0 : promise.catch(noop);
|
|
852
|
+
};
|
|
853
|
+
const currentErrorTypeName = React__default.useMemo(() => {
|
|
854
|
+
if (activeQuery && activeQueryState != null && activeQueryState.error) {
|
|
855
|
+
const errorType = errorTypes.find(type => {
|
|
856
|
+
var _activeQueryState$err;
|
|
857
|
+
return type.initializer(activeQuery).toString() === ((_activeQueryState$err = activeQueryState.error) == null ? void 0 : _activeQueryState$err.toString());
|
|
858
|
+
});
|
|
859
|
+
return errorType == null ? void 0 : errorType.name;
|
|
758
860
|
}
|
|
759
|
-
return;
|
|
760
|
-
}, [
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}) => ({
|
|
776
|
-
padding,
|
|
777
|
-
paddingTop,
|
|
778
|
-
paddingBottom,
|
|
779
|
-
paddingLeft,
|
|
780
|
-
paddingRight
|
|
781
|
-
}))(parentElement.style);
|
|
782
|
-
const run = () => {
|
|
783
|
-
// reset the padding
|
|
784
|
-
parentElement.style.padding = '0px';
|
|
785
|
-
parentElement.style.paddingTop = '0px';
|
|
786
|
-
parentElement.style.paddingBottom = '0px';
|
|
787
|
-
parentElement.style.paddingLeft = '0px';
|
|
788
|
-
parentElement.style.paddingRight = '0px';
|
|
789
|
-
// set the new padding based on the new panel position
|
|
790
|
-
|
|
791
|
-
parentElement.style[styleProp] = `${isVertical ? devtoolsWidth : devtoolsHeight}px`;
|
|
792
|
-
};
|
|
793
|
-
run();
|
|
794
|
-
if (typeof window !== 'undefined') {
|
|
795
|
-
window.addEventListener('resize', run);
|
|
796
|
-
return () => {
|
|
797
|
-
window.removeEventListener('resize', run);
|
|
798
|
-
Object.entries(previousPaddings).forEach(([property, previousValue]) => {
|
|
799
|
-
parentElement.style[property] = previousValue;
|
|
800
|
-
});
|
|
801
|
-
};
|
|
861
|
+
return undefined;
|
|
862
|
+
}, [activeQuery, activeQueryState == null ? void 0 : activeQueryState.error, errorTypes]);
|
|
863
|
+
if (!activeQuery || !activeQueryState) {
|
|
864
|
+
return null;
|
|
865
|
+
}
|
|
866
|
+
const triggerError = errorType => {
|
|
867
|
+
var _errorType$initialize;
|
|
868
|
+
const error = (_errorType$initialize = errorType == null ? void 0 : errorType.initializer(activeQuery)) != null ? _errorType$initialize : new Error('Unknown error from devtools');
|
|
869
|
+
const __previousQueryOptions = activeQuery.options;
|
|
870
|
+
activeQuery.setState({
|
|
871
|
+
status: 'error',
|
|
872
|
+
error,
|
|
873
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
874
|
+
fetchMeta: {
|
|
875
|
+
...activeQuery.state.fetchMeta,
|
|
876
|
+
__previousQueryOptions
|
|
802
877
|
}
|
|
878
|
+
});
|
|
879
|
+
};
|
|
880
|
+
const restoreQueryAfterLoadingOrError = () => {
|
|
881
|
+
activeQuery.fetch(activeQuery.state.fetchMeta.__previousQueryOptions, {
|
|
882
|
+
// Make sure this fetch will cancel the previous one
|
|
883
|
+
cancelRefetch: true
|
|
884
|
+
});
|
|
885
|
+
};
|
|
886
|
+
return /*#__PURE__*/React__default.createElement(ActiveQueryPanel, null, /*#__PURE__*/React__default.createElement("div", {
|
|
887
|
+
style: {
|
|
888
|
+
padding: '.5em',
|
|
889
|
+
background: defaultTheme.backgroundAlt,
|
|
890
|
+
position: 'sticky',
|
|
891
|
+
top: 0,
|
|
892
|
+
zIndex: 1
|
|
803
893
|
}
|
|
804
|
-
|
|
805
|
-
}, [isResolvedOpen, panelPosition, devtoolsHeight, devtoolsWidth]);
|
|
806
|
-
const {
|
|
807
|
-
style: panelStyle = {},
|
|
808
|
-
...otherPanelProps
|
|
809
|
-
} = panelProps;
|
|
810
|
-
const {
|
|
811
|
-
style: toggleButtonStyle = {},
|
|
812
|
-
onClick: onToggleClick,
|
|
813
|
-
...otherToggleButtonProps
|
|
814
|
-
} = toggleButtonProps;
|
|
815
|
-
|
|
816
|
-
// get computed style based on panel position
|
|
817
|
-
const style = getSidePanelStyle({
|
|
818
|
-
position: panelPosition,
|
|
819
|
-
devtoolsTheme: defaultTheme,
|
|
820
|
-
isOpen: isResolvedOpen,
|
|
821
|
-
height: devtoolsHeight,
|
|
822
|
-
width: devtoolsWidth,
|
|
823
|
-
isResizing,
|
|
824
|
-
panelStyle
|
|
825
|
-
});
|
|
826
|
-
|
|
827
|
-
// Do not render on the server
|
|
828
|
-
if (!isMounted()) return null;
|
|
829
|
-
return /*#__PURE__*/React.createElement(Container, {
|
|
830
|
-
ref: rootRef,
|
|
831
|
-
className: "ReactQueryDevtools",
|
|
832
|
-
"aria-label": "React Query Devtools"
|
|
833
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
834
|
-
theme: defaultTheme
|
|
835
|
-
}, /*#__PURE__*/React.createElement(ReactQueryDevtoolsPanel$1, _extends({
|
|
836
|
-
ref: panelRef,
|
|
837
|
-
queryClient: queryClient,
|
|
838
|
-
styleNonce: styleNonce,
|
|
839
|
-
position: panelPosition,
|
|
840
|
-
onPositionChange: setPanelPosition,
|
|
841
|
-
showCloseButton: true,
|
|
842
|
-
closeButtonProps: closeButtonProps
|
|
843
|
-
}, otherPanelProps, {
|
|
844
|
-
style: style,
|
|
845
|
-
isOpen: isResolvedOpen,
|
|
846
|
-
setIsOpen: setIsOpen,
|
|
847
|
-
onDragStart: e => handleDragStart(panelRef.current, e),
|
|
848
|
-
errorTypes: errorTypes
|
|
849
|
-
}))), !isResolvedOpen ? /*#__PURE__*/React.createElement("button", _extends({
|
|
850
|
-
type: "button"
|
|
851
|
-
}, otherToggleButtonProps, {
|
|
852
|
-
"aria-label": "Open React Query Devtools",
|
|
853
|
-
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
854
|
-
"aria-haspopup": "true",
|
|
855
|
-
"aria-expanded": "false",
|
|
856
|
-
onClick: e => {
|
|
857
|
-
setIsOpen(true);
|
|
858
|
-
onToggleClick == null ? void 0 : onToggleClick(e);
|
|
859
|
-
},
|
|
894
|
+
}, "Query Details"), /*#__PURE__*/React__default.createElement("div", {
|
|
860
895
|
style: {
|
|
861
|
-
|
|
862
|
-
border: 0,
|
|
863
|
-
padding: 0,
|
|
864
|
-
position: 'fixed',
|
|
865
|
-
zIndex: 99999,
|
|
866
|
-
display: 'inline-flex',
|
|
867
|
-
fontSize: '1.5em',
|
|
868
|
-
margin: '.5em',
|
|
869
|
-
cursor: 'pointer',
|
|
870
|
-
width: 'fit-content',
|
|
871
|
-
...(position === 'top-right' ? {
|
|
872
|
-
top: '0',
|
|
873
|
-
right: '0'
|
|
874
|
-
} : position === 'top-left' ? {
|
|
875
|
-
top: '0',
|
|
876
|
-
left: '0'
|
|
877
|
-
} : position === 'bottom-right' ? {
|
|
878
|
-
bottom: '0',
|
|
879
|
-
right: '0'
|
|
880
|
-
} : {
|
|
881
|
-
bottom: '0',
|
|
882
|
-
left: '0'
|
|
883
|
-
}),
|
|
884
|
-
...toggleButtonStyle
|
|
896
|
+
padding: '.5em'
|
|
885
897
|
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
const useSubscribeToQueryCache = (queryCache, getSnapshot, skip = false) => {
|
|
893
|
-
return React.useSyncExternalStore(React.useCallback(onStoreChange => {
|
|
894
|
-
if (!skip) return queryCache.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
895
|
-
return () => {
|
|
896
|
-
return;
|
|
897
|
-
};
|
|
898
|
-
}, [queryCache, skip]), getSnapshot, getSnapshot);
|
|
899
|
-
};
|
|
900
|
-
const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
|
|
901
|
-
const {
|
|
902
|
-
isOpen = true,
|
|
903
|
-
styleNonce,
|
|
904
|
-
setIsOpen,
|
|
905
|
-
queryClient,
|
|
906
|
-
onDragStart,
|
|
907
|
-
onPositionChange,
|
|
908
|
-
showCloseButton,
|
|
909
|
-
position,
|
|
910
|
-
closeButtonProps = {},
|
|
911
|
-
errorTypes = [],
|
|
912
|
-
...panelProps
|
|
913
|
-
} = props;
|
|
914
|
-
const {
|
|
915
|
-
onClick: onCloseClick,
|
|
916
|
-
...otherCloseButtonProps
|
|
917
|
-
} = closeButtonProps;
|
|
918
|
-
const client = useQueryClient(queryClient);
|
|
919
|
-
const queryCache = client.getQueryCache();
|
|
920
|
-
const [sort, setSort] = useLocalStorage('reactQueryDevtoolsSortFn', Object.keys(sortFns)[0]);
|
|
921
|
-
const [filter, setFilter] = useLocalStorage('reactQueryDevtoolsFilter', '');
|
|
922
|
-
const [baseSort, setBaseSort] = useLocalStorage('reactQueryDevtoolsBaseSort', 1);
|
|
923
|
-
const sortFn = React.useMemo(() => sortFns[sort], [sort]);
|
|
924
|
-
const queriesCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().length, !isOpen);
|
|
925
|
-
const [activeQueryHash, setActiveQueryHash] = useLocalStorage('reactQueryDevtoolsActiveQueryHash', '');
|
|
926
|
-
const queries = React.useMemo(() => {
|
|
927
|
-
const unsortedQueries = queryCache.getAll();
|
|
928
|
-
if (queriesCount === 0) {
|
|
929
|
-
return [];
|
|
898
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
899
|
+
style: {
|
|
900
|
+
marginBottom: '.5em',
|
|
901
|
+
display: 'flex',
|
|
902
|
+
alignItems: 'flex-start',
|
|
903
|
+
justifyContent: 'space-between'
|
|
930
904
|
}
|
|
931
|
-
|
|
932
|
-
const sorted = sortFn ? filtered.sort((a, b) => sortFn(a, b) * baseSort) : filtered;
|
|
933
|
-
return sorted;
|
|
934
|
-
}, [baseSort, sortFn, filter, queriesCount, queryCache]);
|
|
935
|
-
const [isMockOffline, setMockOffline] = React.useState(false);
|
|
936
|
-
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
937
|
-
theme: defaultTheme
|
|
938
|
-
}, /*#__PURE__*/React.createElement(Panel, _extends({
|
|
939
|
-
ref: ref,
|
|
940
|
-
className: "ReactQueryDevtoolsPanel",
|
|
941
|
-
"aria-label": "React Query Devtools Panel",
|
|
942
|
-
id: "ReactQueryDevtoolsPanel"
|
|
943
|
-
}, panelProps, {
|
|
905
|
+
}, /*#__PURE__*/React__default.createElement(Code, {
|
|
944
906
|
style: {
|
|
945
|
-
|
|
946
|
-
position: 'relative',
|
|
947
|
-
...panelProps.style
|
|
907
|
+
lineHeight: '1.8em'
|
|
948
908
|
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
909
|
+
}, /*#__PURE__*/React__default.createElement("pre", {
|
|
910
|
+
style: {
|
|
911
|
+
margin: 0,
|
|
912
|
+
padding: 0,
|
|
913
|
+
overflow: 'auto'
|
|
914
|
+
}
|
|
915
|
+
}, displayValue(activeQuery.queryKey, true))), /*#__PURE__*/React__default.createElement("span", {
|
|
916
|
+
style: {
|
|
917
|
+
padding: '0.3em .6em',
|
|
918
|
+
borderRadius: '0.4em',
|
|
919
|
+
fontWeight: 'bold',
|
|
920
|
+
textShadow: '0 2px 10px black',
|
|
921
|
+
background: getQueryStatusColor({
|
|
922
|
+
queryState: activeQueryState,
|
|
923
|
+
isStale: isStale,
|
|
924
|
+
observerCount: observerCount,
|
|
925
|
+
theme: defaultTheme
|
|
926
|
+
}),
|
|
927
|
+
flexShrink: 0
|
|
928
|
+
}
|
|
929
|
+
}, getQueryStatusLabel(activeQuery))), /*#__PURE__*/React__default.createElement("div", {
|
|
930
|
+
style: {
|
|
931
|
+
marginBottom: '.5em',
|
|
932
|
+
display: 'flex',
|
|
933
|
+
alignItems: 'center',
|
|
934
|
+
justifyContent: 'space-between'
|
|
935
|
+
}
|
|
936
|
+
}, "Observers: ", /*#__PURE__*/React__default.createElement(Code, null, observerCount)), /*#__PURE__*/React__default.createElement("div", {
|
|
937
|
+
style: {
|
|
938
|
+
display: 'flex',
|
|
939
|
+
alignItems: 'center',
|
|
940
|
+
justifyContent: 'space-between'
|
|
941
|
+
}
|
|
942
|
+
}, "Last Updated:", ' ', /*#__PURE__*/React__default.createElement(Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React__default.createElement("div", {
|
|
943
|
+
style: {
|
|
944
|
+
background: defaultTheme.backgroundAlt,
|
|
945
|
+
padding: '.5em',
|
|
946
|
+
position: 'sticky',
|
|
947
|
+
top: 0,
|
|
948
|
+
zIndex: 1
|
|
949
|
+
}
|
|
950
|
+
}, "Actions"), /*#__PURE__*/React__default.createElement("div", {
|
|
951
|
+
style: {
|
|
952
|
+
padding: '0.5em',
|
|
953
|
+
display: 'flex',
|
|
954
|
+
flexWrap: 'wrap',
|
|
955
|
+
gap: '0.5em',
|
|
956
|
+
alignItems: 'flex-end'
|
|
957
|
+
}
|
|
958
|
+
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
959
|
+
type: "button",
|
|
960
|
+
onClick: handleRefetch,
|
|
961
|
+
disabled: activeQueryState.fetchStatus === 'fetching',
|
|
962
|
+
style: {
|
|
963
|
+
background: defaultTheme.active
|
|
964
|
+
}
|
|
965
|
+
}, "Refetch"), ' ', /*#__PURE__*/React__default.createElement(Button, {
|
|
966
|
+
type: "button",
|
|
967
|
+
onClick: () => queryClient.invalidateQueries(activeQuery),
|
|
968
|
+
style: {
|
|
969
|
+
background: defaultTheme.warning,
|
|
970
|
+
color: defaultTheme.inputTextColor
|
|
971
|
+
}
|
|
972
|
+
}, "Invalidate"), ' ', /*#__PURE__*/React__default.createElement(Button, {
|
|
973
|
+
type: "button",
|
|
974
|
+
onClick: () => queryClient.resetQueries(activeQuery),
|
|
975
|
+
style: {
|
|
976
|
+
background: defaultTheme.gray
|
|
977
|
+
}
|
|
978
|
+
}, "Reset"), ' ', /*#__PURE__*/React__default.createElement(Button, {
|
|
979
|
+
type: "button",
|
|
980
|
+
onClick: () => queryClient.removeQueries(activeQuery),
|
|
981
|
+
style: {
|
|
982
|
+
background: defaultTheme.danger
|
|
983
|
+
}
|
|
984
|
+
}, "Remove"), ' ', /*#__PURE__*/React__default.createElement(Button, {
|
|
985
|
+
type: "button",
|
|
986
|
+
onClick: () => {
|
|
987
|
+
if (activeQuery.state.data === undefined) {
|
|
988
|
+
restoreQueryAfterLoadingOrError();
|
|
989
|
+
} else {
|
|
990
|
+
const __previousQueryOptions = activeQuery.options;
|
|
991
|
+
// Trigger a fetch in order to trigger suspense as well.
|
|
992
|
+
activeQuery.fetch({
|
|
993
|
+
...__previousQueryOptions,
|
|
994
|
+
queryFn: () => {
|
|
995
|
+
return new Promise(() => {
|
|
996
|
+
// Never resolve
|
|
997
|
+
});
|
|
998
|
+
},
|
|
999
|
+
gcTime: -1
|
|
1000
|
+
});
|
|
1001
|
+
activeQuery.setState({
|
|
1002
|
+
data: undefined,
|
|
1003
|
+
status: 'pending',
|
|
1004
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
1005
|
+
fetchMeta: {
|
|
1006
|
+
...activeQuery.state.fetchMeta,
|
|
1007
|
+
__previousQueryOptions
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
style: {
|
|
1013
|
+
background: defaultTheme.paused
|
|
1014
|
+
}
|
|
1015
|
+
}, activeQuery.state.status === 'pending' ? 'Restore' : 'Trigger', ' ', "loading"), ' ', errorTypes.length === 0 || activeQuery.state.status === 'error' ? /*#__PURE__*/React__default.createElement(Button, {
|
|
1016
|
+
type: "button",
|
|
1017
|
+
onClick: () => {
|
|
1018
|
+
if (!activeQuery.state.error) {
|
|
1019
|
+
triggerError();
|
|
1020
|
+
} else {
|
|
1021
|
+
queryClient.resetQueries(activeQuery);
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
style: {
|
|
1025
|
+
background: defaultTheme.danger
|
|
1026
|
+
}
|
|
1027
|
+
}, activeQuery.state.status === 'error' ? 'Restore' : 'Trigger', " error") : /*#__PURE__*/React__default.createElement("label", null, "Trigger error:", /*#__PURE__*/React__default.createElement(Select, {
|
|
1028
|
+
value: currentErrorTypeName != null ? currentErrorTypeName : '',
|
|
1029
|
+
style: {
|
|
1030
|
+
marginInlineStart: '.5em'
|
|
1031
|
+
},
|
|
1032
|
+
onChange: e => {
|
|
1033
|
+
const errorType = errorTypes.find(t => t.name === e.target.value);
|
|
1034
|
+
triggerError(errorType);
|
|
1035
|
+
}
|
|
1036
|
+
}, /*#__PURE__*/React__default.createElement("option", {
|
|
1037
|
+
key: "",
|
|
1038
|
+
value: ""
|
|
1039
|
+
}), errorTypes.map(errorType => /*#__PURE__*/React__default.createElement("option", {
|
|
1040
|
+
key: errorType.name,
|
|
1041
|
+
value: errorType.name
|
|
1042
|
+
}, errorType.name))))), /*#__PURE__*/React__default.createElement("div", {
|
|
1043
|
+
style: {
|
|
1044
|
+
background: defaultTheme.backgroundAlt,
|
|
1045
|
+
padding: '.5em',
|
|
1046
|
+
position: 'sticky',
|
|
1047
|
+
top: 0,
|
|
1048
|
+
zIndex: 1
|
|
1049
|
+
}
|
|
1050
|
+
}, "Data Explorer"), /*#__PURE__*/React__default.createElement("div", {
|
|
1051
|
+
style: {
|
|
1052
|
+
padding: '.5em'
|
|
1053
|
+
}
|
|
1054
|
+
}, /*#__PURE__*/React__default.createElement(Explorer, {
|
|
1055
|
+
label: "Data",
|
|
1056
|
+
value: activeQueryState.data,
|
|
1057
|
+
defaultExpanded: {},
|
|
1058
|
+
copyable: true
|
|
1059
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
1060
|
+
style: {
|
|
1061
|
+
background: defaultTheme.backgroundAlt,
|
|
1062
|
+
padding: '.5em',
|
|
1063
|
+
position: 'sticky',
|
|
1064
|
+
top: 0,
|
|
1065
|
+
zIndex: 1
|
|
1066
|
+
}
|
|
1067
|
+
}, "Query Explorer"), /*#__PURE__*/React__default.createElement("div", {
|
|
1068
|
+
style: {
|
|
1069
|
+
padding: '.5em'
|
|
1070
|
+
}
|
|
1071
|
+
}, /*#__PURE__*/React__default.createElement(Explorer, {
|
|
1072
|
+
label: "Query",
|
|
1073
|
+
value: activeQuery,
|
|
1074
|
+
defaultExpanded: {
|
|
1075
|
+
queryKey: true
|
|
1076
|
+
}
|
|
1077
|
+
})));
|
|
1078
|
+
};
|
|
1079
|
+
ActiveQuery.displayName = 'ActiveQuery';
|
|
1080
|
+
var ActiveQuery$1 = ActiveQuery;
|
|
1081
|
+
|
|
1082
|
+
const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__default.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
|
|
1083
|
+
const {
|
|
1084
|
+
isOpen = true,
|
|
1085
|
+
styleNonce,
|
|
1086
|
+
setIsOpen,
|
|
1087
|
+
queryClient,
|
|
1088
|
+
onDragStart,
|
|
1089
|
+
onPositionChange,
|
|
1090
|
+
showCloseButton,
|
|
1091
|
+
position,
|
|
1092
|
+
closeButtonProps = {},
|
|
1093
|
+
errorTypes = [],
|
|
1094
|
+
...panelProps
|
|
1095
|
+
} = props;
|
|
1096
|
+
const {
|
|
1097
|
+
onClick: onCloseClick,
|
|
1098
|
+
...otherCloseButtonProps
|
|
1099
|
+
} = closeButtonProps;
|
|
1100
|
+
const client = useQueryClient(queryClient);
|
|
1101
|
+
const queryCache = client.getQueryCache();
|
|
1102
|
+
const [sort, setSort] = useLocalStorage('reactQueryDevtoolsSortFn', Object.keys(sortFns)[0]);
|
|
1103
|
+
const [filter, setFilter] = useLocalStorage('reactQueryDevtoolsFilter', '');
|
|
1104
|
+
const [baseSort, setBaseSort] = useLocalStorage('reactQueryDevtoolsBaseSort', 1);
|
|
1105
|
+
const sortFn = React__default.useMemo(() => sortFns[sort], [sort]);
|
|
1106
|
+
const queriesCount = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().length, !isOpen);
|
|
1107
|
+
const [activeQueryHash, setActiveQueryHash] = useLocalStorage('reactQueryDevtoolsActiveQueryHash', '');
|
|
1108
|
+
const queries = React__default.useMemo(() => {
|
|
1109
|
+
const unsortedQueries = queryCache.getAll();
|
|
1110
|
+
if (queriesCount === 0) {
|
|
1111
|
+
return [];
|
|
1112
|
+
}
|
|
1113
|
+
const filtered = filter ? unsortedQueries.filter(item => rankItem(item.queryHash, filter).passed) : [...unsortedQueries];
|
|
1114
|
+
const sorted = sortFn ? filtered.sort((a, b) => sortFn(a, b) * baseSort) : filtered;
|
|
1115
|
+
return sorted;
|
|
1116
|
+
}, [baseSort, sortFn, filter, queriesCount, queryCache]);
|
|
1117
|
+
const [isMockOffline, setMockOffline] = React__default.useState(false);
|
|
1118
|
+
return /*#__PURE__*/React__default.createElement(ThemeProvider, {
|
|
1119
|
+
theme: defaultTheme
|
|
1120
|
+
}, /*#__PURE__*/React__default.createElement(Panel, _extends({
|
|
1121
|
+
ref: ref,
|
|
1122
|
+
className: "ReactQueryDevtoolsPanel",
|
|
1123
|
+
"aria-label": "React Query Devtools Panel",
|
|
1124
|
+
id: "ReactQueryDevtoolsPanel"
|
|
1125
|
+
}, panelProps, {
|
|
1126
|
+
style: {
|
|
1127
|
+
height: defaultPanelSize,
|
|
1128
|
+
position: 'relative',
|
|
1129
|
+
...panelProps.style
|
|
1130
|
+
}
|
|
1131
|
+
}), /*#__PURE__*/React__default.createElement("style", {
|
|
1132
|
+
nonce: styleNonce,
|
|
1133
|
+
dangerouslySetInnerHTML: {
|
|
1134
|
+
__html: `
|
|
1135
|
+
.ReactQueryDevtoolsPanel * {
|
|
1136
|
+
scrollbar-color: ${defaultTheme.backgroundAlt} ${defaultTheme.gray};
|
|
1137
|
+
}
|
|
956
1138
|
|
|
957
1139
|
.ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {
|
|
958
1140
|
width: 1em;
|
|
@@ -970,10 +1152,10 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
970
1152
|
}
|
|
971
1153
|
`
|
|
972
1154
|
}
|
|
973
|
-
}), /*#__PURE__*/
|
|
1155
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
974
1156
|
style: getResizeHandleStyle(position),
|
|
975
1157
|
onMouseDown: onDragStart
|
|
976
|
-
}), isOpen && /*#__PURE__*/
|
|
1158
|
+
}), isOpen && /*#__PURE__*/React__default.createElement("div", {
|
|
977
1159
|
style: {
|
|
978
1160
|
flex: '1 1 500px',
|
|
979
1161
|
minHeight: '40%',
|
|
@@ -983,7 +1165,7 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
983
1165
|
display: 'flex',
|
|
984
1166
|
flexDirection: 'column'
|
|
985
1167
|
}
|
|
986
|
-
}, /*#__PURE__*/
|
|
1168
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
987
1169
|
style: {
|
|
988
1170
|
padding: '.5em',
|
|
989
1171
|
background: defaultTheme.backgroundAlt,
|
|
@@ -991,7 +1173,7 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
991
1173
|
justifyContent: 'space-between',
|
|
992
1174
|
alignItems: 'center'
|
|
993
1175
|
}
|
|
994
|
-
}, /*#__PURE__*/
|
|
1176
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
995
1177
|
type: "button",
|
|
996
1178
|
"aria-label": "Close React Query Devtools",
|
|
997
1179
|
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
@@ -1006,47 +1188,47 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
1006
1188
|
marginRight: '.5em',
|
|
1007
1189
|
cursor: 'pointer'
|
|
1008
1190
|
}
|
|
1009
|
-
}, /*#__PURE__*/
|
|
1191
|
+
}, /*#__PURE__*/React__default.createElement(Logo, {
|
|
1010
1192
|
"aria-hidden": true
|
|
1011
|
-
}), /*#__PURE__*/
|
|
1193
|
+
}), /*#__PURE__*/React__default.createElement(ScreenReader, {
|
|
1012
1194
|
text: "Close React Query Devtools"
|
|
1013
|
-
})), /*#__PURE__*/
|
|
1195
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
1014
1196
|
style: {
|
|
1015
1197
|
display: 'flex',
|
|
1016
1198
|
flexDirection: 'column'
|
|
1017
1199
|
}
|
|
1018
|
-
}, /*#__PURE__*/
|
|
1200
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
1019
1201
|
style: {
|
|
1020
1202
|
display: 'flex',
|
|
1021
1203
|
justifyContent: 'space-between',
|
|
1022
1204
|
alignItems: 'center',
|
|
1023
1205
|
marginBottom: '.5em'
|
|
1024
1206
|
}
|
|
1025
|
-
}, /*#__PURE__*/
|
|
1207
|
+
}, /*#__PURE__*/React__default.createElement(QueryStatusCount, {
|
|
1026
1208
|
queryCache: queryCache
|
|
1027
|
-
}), position && onPositionChange ? /*#__PURE__*/
|
|
1209
|
+
}), position && onPositionChange ? /*#__PURE__*/React__default.createElement(Select, {
|
|
1028
1210
|
"aria-label": "Panel position",
|
|
1029
1211
|
value: position,
|
|
1030
1212
|
style: {
|
|
1031
1213
|
marginInlineStart: '.5em'
|
|
1032
1214
|
},
|
|
1033
1215
|
onChange: e => onPositionChange(e.target.value)
|
|
1034
|
-
}, /*#__PURE__*/
|
|
1216
|
+
}, /*#__PURE__*/React__default.createElement("option", {
|
|
1035
1217
|
value: "left"
|
|
1036
|
-
}, "Left"), /*#__PURE__*/
|
|
1218
|
+
}, "Left"), /*#__PURE__*/React__default.createElement("option", {
|
|
1037
1219
|
value: "right"
|
|
1038
|
-
}, "Right"), /*#__PURE__*/
|
|
1220
|
+
}, "Right"), /*#__PURE__*/React__default.createElement("option", {
|
|
1039
1221
|
value: "top"
|
|
1040
|
-
}, "Top"), /*#__PURE__*/
|
|
1222
|
+
}, "Top"), /*#__PURE__*/React__default.createElement("option", {
|
|
1041
1223
|
value: "bottom"
|
|
1042
|
-
}, "Bottom")) : null), /*#__PURE__*/
|
|
1224
|
+
}, "Bottom")) : null), /*#__PURE__*/React__default.createElement("div", {
|
|
1043
1225
|
style: {
|
|
1044
1226
|
display: 'flex',
|
|
1045
1227
|
alignItems: 'center',
|
|
1046
1228
|
flexWrap: 'wrap',
|
|
1047
1229
|
gap: '0.5em'
|
|
1048
1230
|
}
|
|
1049
|
-
}, /*#__PURE__*/
|
|
1231
|
+
}, /*#__PURE__*/React__default.createElement(Input, {
|
|
1050
1232
|
placeholder: "Filter",
|
|
1051
1233
|
"aria-label": "Filter by queryhash",
|
|
1052
1234
|
value: filter != null ? filter : '',
|
|
@@ -1058,7 +1240,7 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
1058
1240
|
flex: '1',
|
|
1059
1241
|
width: '100%'
|
|
1060
1242
|
}
|
|
1061
|
-
}), /*#__PURE__*/
|
|
1243
|
+
}), /*#__PURE__*/React__default.createElement(Select, {
|
|
1062
1244
|
"aria-label": "Sort queries",
|
|
1063
1245
|
value: sort,
|
|
1064
1246
|
onChange: e => setSort(e.target.value),
|
|
@@ -1067,17 +1249,26 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
1067
1249
|
minWidth: 75,
|
|
1068
1250
|
marginRight: '.5em'
|
|
1069
1251
|
}
|
|
1070
|
-
}, Object.keys(sortFns).map(key => /*#__PURE__*/
|
|
1252
|
+
}, Object.keys(sortFns).map(key => /*#__PURE__*/React__default.createElement("option", {
|
|
1071
1253
|
key: key,
|
|
1072
1254
|
value: key
|
|
1073
|
-
}, "Sort by ", key))), /*#__PURE__*/
|
|
1255
|
+
}, "Sort by ", key))), /*#__PURE__*/React__default.createElement(Button, {
|
|
1074
1256
|
type: "button",
|
|
1075
1257
|
onClick: () => setBaseSort(old => old * -1),
|
|
1076
1258
|
style: {
|
|
1077
1259
|
padding: '.3em .4em',
|
|
1078
1260
|
marginRight: '.5em'
|
|
1079
1261
|
}
|
|
1080
|
-
}, baseSort === 1 ? '⬆ Asc' : '⬇ Desc'), /*#__PURE__*/
|
|
1262
|
+
}, baseSort === 1 ? '⬆ Asc' : '⬇ Desc'), /*#__PURE__*/React__default.createElement(Button, {
|
|
1263
|
+
title: "Clear cache",
|
|
1264
|
+
"aria-label": "Clear cache",
|
|
1265
|
+
type: "button",
|
|
1266
|
+
onClick: () => queryCache.clear(),
|
|
1267
|
+
style: {
|
|
1268
|
+
padding: '.3em .4em',
|
|
1269
|
+
marginRight: '.5em'
|
|
1270
|
+
}
|
|
1271
|
+
}, "Clear"), /*#__PURE__*/React__default.createElement(Button, {
|
|
1081
1272
|
type: "button",
|
|
1082
1273
|
onClick: () => {
|
|
1083
1274
|
if (isMockOffline) {
|
|
@@ -1096,69 +1287,69 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
1096
1287
|
padding: '0',
|
|
1097
1288
|
height: '2em'
|
|
1098
1289
|
}
|
|
1099
|
-
}, /*#__PURE__*/
|
|
1290
|
+
}, /*#__PURE__*/React__default.createElement("svg", {
|
|
1100
1291
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1101
1292
|
width: "2em",
|
|
1102
1293
|
height: "2em",
|
|
1103
1294
|
viewBox: "0 0 24 24",
|
|
1104
1295
|
stroke: isMockOffline ? defaultTheme.danger : 'currentColor',
|
|
1105
1296
|
fill: "none"
|
|
1106
|
-
}, isMockOffline ? /*#__PURE__*/
|
|
1297
|
+
}, isMockOffline ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("path", {
|
|
1107
1298
|
stroke: "none",
|
|
1108
1299
|
d: "M0 0h24v24H0z",
|
|
1109
1300
|
fill: "none"
|
|
1110
|
-
}), /*#__PURE__*/
|
|
1301
|
+
}), /*#__PURE__*/React__default.createElement("line", {
|
|
1111
1302
|
x1: "12",
|
|
1112
1303
|
y1: "18",
|
|
1113
1304
|
x2: "12.01",
|
|
1114
1305
|
y2: "18"
|
|
1115
|
-
}), /*#__PURE__*/
|
|
1306
|
+
}), /*#__PURE__*/React__default.createElement("path", {
|
|
1116
1307
|
d: "M9.172 15.172a4 4 0 0 1 5.656 0"
|
|
1117
|
-
}), /*#__PURE__*/
|
|
1308
|
+
}), /*#__PURE__*/React__default.createElement("path", {
|
|
1118
1309
|
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"
|
|
1119
|
-
}), /*#__PURE__*/
|
|
1310
|
+
}), /*#__PURE__*/React__default.createElement("path", {
|
|
1120
1311
|
d: "M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374"
|
|
1121
|
-
}), /*#__PURE__*/
|
|
1312
|
+
}), /*#__PURE__*/React__default.createElement("line", {
|
|
1122
1313
|
x1: "3",
|
|
1123
1314
|
y1: "3",
|
|
1124
1315
|
x2: "21",
|
|
1125
1316
|
y2: "21"
|
|
1126
|
-
})) : /*#__PURE__*/
|
|
1317
|
+
})) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("path", {
|
|
1127
1318
|
stroke: "none",
|
|
1128
1319
|
d: "M0 0h24v24H0z",
|
|
1129
1320
|
fill: "none"
|
|
1130
|
-
}), /*#__PURE__*/
|
|
1321
|
+
}), /*#__PURE__*/React__default.createElement("line", {
|
|
1131
1322
|
x1: "12",
|
|
1132
1323
|
y1: "18",
|
|
1133
1324
|
x2: "12.01",
|
|
1134
1325
|
y2: "18"
|
|
1135
|
-
}), /*#__PURE__*/
|
|
1326
|
+
}), /*#__PURE__*/React__default.createElement("path", {
|
|
1136
1327
|
d: "M9.172 15.172a4 4 0 0 1 5.656 0"
|
|
1137
|
-
}), /*#__PURE__*/
|
|
1328
|
+
}), /*#__PURE__*/React__default.createElement("path", {
|
|
1138
1329
|
d: "M6.343 12.343a8 8 0 0 1 11.314 0"
|
|
1139
|
-
}), /*#__PURE__*/
|
|
1330
|
+
}), /*#__PURE__*/React__default.createElement("path", {
|
|
1140
1331
|
d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
|
|
1141
|
-
}))), /*#__PURE__*/
|
|
1332
|
+
}))), /*#__PURE__*/React__default.createElement(ScreenReader, {
|
|
1142
1333
|
text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
|
|
1143
|
-
}))))), /*#__PURE__*/
|
|
1334
|
+
}))))), /*#__PURE__*/React__default.createElement("div", {
|
|
1144
1335
|
style: {
|
|
1145
1336
|
overflowY: 'auto',
|
|
1146
1337
|
flex: '1'
|
|
1147
1338
|
}
|
|
1148
1339
|
}, queries.map(query => {
|
|
1149
|
-
return /*#__PURE__*/
|
|
1340
|
+
return /*#__PURE__*/React__default.createElement(QueryRow$1, {
|
|
1150
1341
|
queryKey: query.queryKey,
|
|
1151
1342
|
activeQueryHash: activeQueryHash,
|
|
1152
1343
|
setActiveQueryHash: setActiveQueryHash,
|
|
1153
1344
|
key: query.queryHash,
|
|
1154
1345
|
queryCache: queryCache
|
|
1155
1346
|
});
|
|
1156
|
-
}))), activeQueryHash && isOpen ? /*#__PURE__*/
|
|
1347
|
+
}))), activeQueryHash && isOpen ? /*#__PURE__*/React__default.createElement(ActiveQuery$1, {
|
|
1157
1348
|
activeQueryHash: activeQueryHash,
|
|
1158
1349
|
queryCache: queryCache,
|
|
1159
1350
|
queryClient: client,
|
|
1160
1351
|
errorTypes: errorTypes
|
|
1161
|
-
}) : null, showCloseButton ? /*#__PURE__*/
|
|
1352
|
+
}) : null, showCloseButton ? /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
1162
1353
|
type: "button",
|
|
1163
1354
|
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
1164
1355
|
"aria-haspopup": "true",
|
|
@@ -1178,383 +1369,233 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
1178
1369
|
}
|
|
1179
1370
|
}), "Close") : null));
|
|
1180
1371
|
});
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1372
|
+
ReactQueryDevtoolsPanel$1.displayName = 'ReactQueryDevtoolsPanel';
|
|
1373
|
+
var ReactQueryDevtoolsPanel$2 = ReactQueryDevtoolsPanel$1;
|
|
1374
|
+
|
|
1375
|
+
function ReactQueryDevtools$1({
|
|
1376
|
+
initialIsOpen,
|
|
1377
|
+
panelProps = {},
|
|
1378
|
+
closeButtonProps = {},
|
|
1379
|
+
toggleButtonProps = {},
|
|
1380
|
+
position = 'bottom-left',
|
|
1381
|
+
containerElement: Container = 'aside',
|
|
1184
1382
|
queryClient,
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
var _errorType$initialize;
|
|
1220
|
-
const error = (_errorType$initialize = errorType == null ? void 0 : errorType.initializer(activeQuery)) != null ? _errorType$initialize : new Error('Unknown error from devtools');
|
|
1221
|
-
const __previousQueryOptions = activeQuery.options;
|
|
1222
|
-
activeQuery.setState({
|
|
1223
|
-
status: 'error',
|
|
1224
|
-
error,
|
|
1225
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
1226
|
-
fetchMeta: {
|
|
1227
|
-
...activeQuery.state.fetchMeta,
|
|
1228
|
-
__previousQueryOptions
|
|
1229
|
-
}
|
|
1230
|
-
});
|
|
1231
|
-
};
|
|
1232
|
-
const restoreQueryAfterLoadingOrError = () => {
|
|
1233
|
-
activeQuery.fetch(activeQuery.state.fetchMeta.__previousQueryOptions, {
|
|
1234
|
-
// Make sure this fetch will cancel the previous one
|
|
1235
|
-
cancelRefetch: true
|
|
1236
|
-
});
|
|
1237
|
-
};
|
|
1238
|
-
return /*#__PURE__*/React.createElement(ActiveQueryPanel, null, /*#__PURE__*/React.createElement("div", {
|
|
1239
|
-
style: {
|
|
1240
|
-
padding: '.5em',
|
|
1241
|
-
background: defaultTheme.backgroundAlt,
|
|
1242
|
-
position: 'sticky',
|
|
1243
|
-
top: 0,
|
|
1244
|
-
zIndex: 1
|
|
1245
|
-
}
|
|
1246
|
-
}, "Query Details"), /*#__PURE__*/React.createElement("div", {
|
|
1247
|
-
style: {
|
|
1248
|
-
padding: '.5em'
|
|
1249
|
-
}
|
|
1250
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1251
|
-
style: {
|
|
1252
|
-
marginBottom: '.5em',
|
|
1253
|
-
display: 'flex',
|
|
1254
|
-
alignItems: 'flex-start',
|
|
1255
|
-
justifyContent: 'space-between'
|
|
1256
|
-
}
|
|
1257
|
-
}, /*#__PURE__*/React.createElement(Code, {
|
|
1258
|
-
style: {
|
|
1259
|
-
lineHeight: '1.8em'
|
|
1260
|
-
}
|
|
1261
|
-
}, /*#__PURE__*/React.createElement("pre", {
|
|
1262
|
-
style: {
|
|
1263
|
-
margin: 0,
|
|
1264
|
-
padding: 0,
|
|
1265
|
-
overflow: 'auto'
|
|
1266
|
-
}
|
|
1267
|
-
}, displayValue(activeQuery.queryKey, true))), /*#__PURE__*/React.createElement("span", {
|
|
1268
|
-
style: {
|
|
1269
|
-
padding: '0.3em .6em',
|
|
1270
|
-
borderRadius: '0.4em',
|
|
1271
|
-
fontWeight: 'bold',
|
|
1272
|
-
textShadow: '0 2px 10px black',
|
|
1273
|
-
background: getQueryStatusColor({
|
|
1274
|
-
queryState: activeQueryState,
|
|
1275
|
-
isStale: isStale,
|
|
1276
|
-
observerCount: observerCount,
|
|
1277
|
-
theme: defaultTheme
|
|
1278
|
-
}),
|
|
1279
|
-
flexShrink: 0
|
|
1280
|
-
}
|
|
1281
|
-
}, getQueryStatusLabel(activeQuery))), /*#__PURE__*/React.createElement("div", {
|
|
1282
|
-
style: {
|
|
1283
|
-
marginBottom: '.5em',
|
|
1284
|
-
display: 'flex',
|
|
1285
|
-
alignItems: 'center',
|
|
1286
|
-
justifyContent: 'space-between'
|
|
1287
|
-
}
|
|
1288
|
-
}, "Observers: ", /*#__PURE__*/React.createElement(Code, null, observerCount)), /*#__PURE__*/React.createElement("div", {
|
|
1289
|
-
style: {
|
|
1290
|
-
display: 'flex',
|
|
1291
|
-
alignItems: 'center',
|
|
1292
|
-
justifyContent: 'space-between'
|
|
1293
|
-
}
|
|
1294
|
-
}, "Last Updated:", ' ', /*#__PURE__*/React.createElement(Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React.createElement("div", {
|
|
1295
|
-
style: {
|
|
1296
|
-
background: defaultTheme.backgroundAlt,
|
|
1297
|
-
padding: '.5em',
|
|
1298
|
-
position: 'sticky',
|
|
1299
|
-
top: 0,
|
|
1300
|
-
zIndex: 1
|
|
1301
|
-
}
|
|
1302
|
-
}, "Actions"), /*#__PURE__*/React.createElement("div", {
|
|
1303
|
-
style: {
|
|
1304
|
-
padding: '0.5em',
|
|
1305
|
-
display: 'flex',
|
|
1306
|
-
flexWrap: 'wrap',
|
|
1307
|
-
gap: '0.5em',
|
|
1308
|
-
alignItems: 'flex-end'
|
|
1309
|
-
}
|
|
1310
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
1311
|
-
type: "button",
|
|
1312
|
-
onClick: handleRefetch,
|
|
1313
|
-
disabled: activeQueryState.fetchStatus === 'fetching',
|
|
1314
|
-
style: {
|
|
1315
|
-
background: defaultTheme.active
|
|
1316
|
-
}
|
|
1317
|
-
}, "Refetch"), ' ', /*#__PURE__*/React.createElement(Button, {
|
|
1318
|
-
type: "button",
|
|
1319
|
-
onClick: () => queryClient.invalidateQueries(activeQuery),
|
|
1320
|
-
style: {
|
|
1321
|
-
background: defaultTheme.warning,
|
|
1322
|
-
color: defaultTheme.inputTextColor
|
|
1323
|
-
}
|
|
1324
|
-
}, "Invalidate"), ' ', /*#__PURE__*/React.createElement(Button, {
|
|
1325
|
-
type: "button",
|
|
1326
|
-
onClick: () => queryClient.resetQueries(activeQuery),
|
|
1327
|
-
style: {
|
|
1328
|
-
background: defaultTheme.gray
|
|
1329
|
-
}
|
|
1330
|
-
}, "Reset"), ' ', /*#__PURE__*/React.createElement(Button, {
|
|
1331
|
-
type: "button",
|
|
1332
|
-
onClick: () => queryClient.removeQueries(activeQuery),
|
|
1333
|
-
style: {
|
|
1334
|
-
background: defaultTheme.danger
|
|
1335
|
-
}
|
|
1336
|
-
}, "Remove"), ' ', /*#__PURE__*/React.createElement(Button, {
|
|
1337
|
-
type: "button",
|
|
1338
|
-
onClick: () => {
|
|
1339
|
-
if (activeQuery.state.data === undefined) {
|
|
1340
|
-
restoreQueryAfterLoadingOrError();
|
|
1383
|
+
styleNonce,
|
|
1384
|
+
panelPosition: initialPanelPosition = 'bottom',
|
|
1385
|
+
errorTypes = []
|
|
1386
|
+
}) {
|
|
1387
|
+
const rootRef = React.useRef(null);
|
|
1388
|
+
const panelRef = React.useRef(null);
|
|
1389
|
+
const [isOpen, setIsOpen] = useLocalStorage('reactQueryDevtoolsOpen', initialIsOpen);
|
|
1390
|
+
const [devtoolsHeight, setDevtoolsHeight] = useLocalStorage('reactQueryDevtoolsHeight', defaultPanelSize);
|
|
1391
|
+
const [devtoolsWidth, setDevtoolsWidth] = useLocalStorage('reactQueryDevtoolsWidth', defaultPanelSize);
|
|
1392
|
+
const [panelPosition = 'bottom', setPanelPosition] = useLocalStorage('reactQueryDevtoolsPanelPosition', initialPanelPosition);
|
|
1393
|
+
const [isResolvedOpen, setIsResolvedOpen] = React.useState(false);
|
|
1394
|
+
const [isResizing, setIsResizing] = React.useState(false);
|
|
1395
|
+
const isMounted = useIsMounted();
|
|
1396
|
+
const handleDragStart = (panelElement, startEvent) => {
|
|
1397
|
+
if (!panelElement) return;
|
|
1398
|
+
if (startEvent.button !== 0) return; // Only allow left click for drag
|
|
1399
|
+
const isVertical = isVerticalSide(panelPosition);
|
|
1400
|
+
setIsResizing(true);
|
|
1401
|
+
const {
|
|
1402
|
+
height,
|
|
1403
|
+
width
|
|
1404
|
+
} = panelElement.getBoundingClientRect();
|
|
1405
|
+
const startX = startEvent.clientX;
|
|
1406
|
+
const startY = startEvent.clientY;
|
|
1407
|
+
let newSize = 0;
|
|
1408
|
+
const run = moveEvent => {
|
|
1409
|
+
// prevent mouse selecting stuff with mouse drag
|
|
1410
|
+
moveEvent.preventDefault();
|
|
1411
|
+
|
|
1412
|
+
// calculate the correct size based on mouse position and current panel position
|
|
1413
|
+
// hint: it is different formula for the opposite sides
|
|
1414
|
+
if (isVertical) {
|
|
1415
|
+
newSize = width + (panelPosition === 'right' ? startX - moveEvent.clientX : moveEvent.clientX - startX);
|
|
1416
|
+
setDevtoolsWidth(newSize);
|
|
1341
1417
|
} else {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
activeQuery.fetch({
|
|
1345
|
-
...__previousQueryOptions,
|
|
1346
|
-
queryFn: () => {
|
|
1347
|
-
return new Promise(() => {
|
|
1348
|
-
// Never resolve
|
|
1349
|
-
});
|
|
1350
|
-
},
|
|
1351
|
-
gcTime: -1
|
|
1352
|
-
});
|
|
1353
|
-
activeQuery.setState({
|
|
1354
|
-
data: undefined,
|
|
1355
|
-
status: 'pending',
|
|
1356
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
1357
|
-
fetchMeta: {
|
|
1358
|
-
...activeQuery.state.fetchMeta,
|
|
1359
|
-
__previousQueryOptions
|
|
1360
|
-
}
|
|
1361
|
-
});
|
|
1418
|
+
newSize = height + (panelPosition === 'bottom' ? startY - moveEvent.clientY : moveEvent.clientY - startY);
|
|
1419
|
+
setDevtoolsHeight(newSize);
|
|
1362
1420
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
background: defaultTheme.paused
|
|
1366
|
-
}
|
|
1367
|
-
}, activeQuery.state.status === 'pending' ? 'Restore' : 'Trigger', ' ', "loading"), ' ', errorTypes.length === 0 || activeQuery.state.status === 'error' ? /*#__PURE__*/React.createElement(Button, {
|
|
1368
|
-
type: "button",
|
|
1369
|
-
onClick: () => {
|
|
1370
|
-
if (!activeQuery.state.error) {
|
|
1371
|
-
triggerError();
|
|
1421
|
+
if (newSize < minPanelSize) {
|
|
1422
|
+
setIsOpen(false);
|
|
1372
1423
|
} else {
|
|
1373
|
-
|
|
1424
|
+
setIsOpen(true);
|
|
1374
1425
|
}
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
},
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
1412
|
-
style: {
|
|
1413
|
-
background: defaultTheme.backgroundAlt,
|
|
1414
|
-
padding: '.5em',
|
|
1415
|
-
position: 'sticky',
|
|
1416
|
-
top: 0,
|
|
1417
|
-
zIndex: 1
|
|
1418
|
-
}
|
|
1419
|
-
}, "Query Explorer"), /*#__PURE__*/React.createElement("div", {
|
|
1420
|
-
style: {
|
|
1421
|
-
padding: '.5em'
|
|
1422
|
-
}
|
|
1423
|
-
}, /*#__PURE__*/React.createElement(Explorer, {
|
|
1424
|
-
label: "Query",
|
|
1425
|
-
value: activeQuery,
|
|
1426
|
-
defaultExpanded: {
|
|
1427
|
-
queryKey: true
|
|
1428
|
-
}
|
|
1429
|
-
})));
|
|
1430
|
-
};
|
|
1431
|
-
const QueryStatusCount = ({
|
|
1432
|
-
queryCache
|
|
1433
|
-
}) => {
|
|
1434
|
-
const hasFresh = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fresh').length);
|
|
1435
|
-
const hasFetching = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fetching').length);
|
|
1436
|
-
const hasPaused = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'paused').length);
|
|
1437
|
-
const hasStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'stale').length);
|
|
1438
|
-
const hasInactive = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'inactive').length);
|
|
1439
|
-
return /*#__PURE__*/React.createElement(QueryKeys, null, /*#__PURE__*/React.createElement(QueryKey, {
|
|
1440
|
-
style: {
|
|
1441
|
-
background: defaultTheme.success,
|
|
1442
|
-
opacity: hasFresh ? 1 : 0.3
|
|
1443
|
-
}
|
|
1444
|
-
}, "fresh ", /*#__PURE__*/React.createElement(Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
|
|
1445
|
-
style: {
|
|
1446
|
-
background: defaultTheme.active,
|
|
1447
|
-
opacity: hasFetching ? 1 : 0.3
|
|
1448
|
-
}
|
|
1449
|
-
}, "fetching ", /*#__PURE__*/React.createElement(Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
|
|
1450
|
-
style: {
|
|
1451
|
-
background: defaultTheme.paused,
|
|
1452
|
-
opacity: hasPaused ? 1 : 0.3
|
|
1453
|
-
}
|
|
1454
|
-
}, "paused ", /*#__PURE__*/React.createElement(Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
|
|
1455
|
-
style: {
|
|
1456
|
-
background: defaultTheme.warning,
|
|
1457
|
-
color: 'black',
|
|
1458
|
-
textShadow: '0',
|
|
1459
|
-
opacity: hasStale ? 1 : 0.3
|
|
1426
|
+
};
|
|
1427
|
+
const unsub = () => {
|
|
1428
|
+
if (isResizing) {
|
|
1429
|
+
setIsResizing(false);
|
|
1430
|
+
}
|
|
1431
|
+
document.removeEventListener('mousemove', run, false);
|
|
1432
|
+
document.removeEventListener('mouseUp', unsub, false);
|
|
1433
|
+
};
|
|
1434
|
+
document.addEventListener('mousemove', run, false);
|
|
1435
|
+
document.addEventListener('mouseup', unsub, false);
|
|
1436
|
+
};
|
|
1437
|
+
React.useEffect(() => {
|
|
1438
|
+
setIsResolvedOpen(isOpen != null ? isOpen : false);
|
|
1439
|
+
}, [isOpen, isResolvedOpen, setIsResolvedOpen]);
|
|
1440
|
+
|
|
1441
|
+
// Toggle panel visibility before/after transition (depending on direction).
|
|
1442
|
+
// Prevents focusing in a closed panel.
|
|
1443
|
+
React.useEffect(() => {
|
|
1444
|
+
const ref = panelRef.current;
|
|
1445
|
+
if (ref) {
|
|
1446
|
+
const handlePanelTransitionStart = () => {
|
|
1447
|
+
if (isResolvedOpen) {
|
|
1448
|
+
ref.style.visibility = 'visible';
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
const handlePanelTransitionEnd = () => {
|
|
1452
|
+
if (!isResolvedOpen) {
|
|
1453
|
+
ref.style.visibility = 'hidden';
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
ref.addEventListener('transitionstart', handlePanelTransitionStart);
|
|
1457
|
+
ref.addEventListener('transitionend', handlePanelTransitionEnd);
|
|
1458
|
+
return () => {
|
|
1459
|
+
ref.removeEventListener('transitionstart', handlePanelTransitionStart);
|
|
1460
|
+
ref.removeEventListener('transitionend', handlePanelTransitionEnd);
|
|
1461
|
+
};
|
|
1460
1462
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1463
|
+
return;
|
|
1464
|
+
}, [isResolvedOpen]);
|
|
1465
|
+
React.useEffect(() => {
|
|
1466
|
+
var _rootRef$current;
|
|
1467
|
+
if (isResolvedOpen && (_rootRef$current = rootRef.current) != null && _rootRef$current.parentElement) {
|
|
1468
|
+
const {
|
|
1469
|
+
parentElement
|
|
1470
|
+
} = rootRef.current;
|
|
1471
|
+
const styleProp = getSidedProp('padding', panelPosition);
|
|
1472
|
+
const isVertical = isVerticalSide(panelPosition);
|
|
1473
|
+
const previousPaddings = (({
|
|
1474
|
+
padding,
|
|
1475
|
+
paddingTop,
|
|
1476
|
+
paddingBottom,
|
|
1477
|
+
paddingLeft,
|
|
1478
|
+
paddingRight
|
|
1479
|
+
}) => ({
|
|
1480
|
+
padding,
|
|
1481
|
+
paddingTop,
|
|
1482
|
+
paddingBottom,
|
|
1483
|
+
paddingLeft,
|
|
1484
|
+
paddingRight
|
|
1485
|
+
}))(parentElement.style);
|
|
1486
|
+
const run = () => {
|
|
1487
|
+
// reset the padding
|
|
1488
|
+
parentElement.style.padding = '0px';
|
|
1489
|
+
parentElement.style.paddingTop = '0px';
|
|
1490
|
+
parentElement.style.paddingBottom = '0px';
|
|
1491
|
+
parentElement.style.paddingLeft = '0px';
|
|
1492
|
+
parentElement.style.paddingRight = '0px';
|
|
1493
|
+
// set the new padding based on the new panel position
|
|
1494
|
+
|
|
1495
|
+
parentElement.style[styleProp] = `${isVertical ? devtoolsWidth : devtoolsHeight}px`;
|
|
1496
|
+
};
|
|
1497
|
+
run();
|
|
1498
|
+
if (typeof window !== 'undefined') {
|
|
1499
|
+
window.addEventListener('resize', run);
|
|
1500
|
+
return () => {
|
|
1501
|
+
window.removeEventListener('resize', run);
|
|
1502
|
+
Object.entries(previousPaddings).forEach(([property, previousValue]) => {
|
|
1503
|
+
parentElement.style[property] = previousValue;
|
|
1504
|
+
});
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1465
1507
|
}
|
|
1466
|
-
|
|
1467
|
-
};
|
|
1468
|
-
const
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1508
|
+
return;
|
|
1509
|
+
}, [isResolvedOpen, panelPosition, devtoolsHeight, devtoolsWidth]);
|
|
1510
|
+
const {
|
|
1511
|
+
style: panelStyle = {},
|
|
1512
|
+
...otherPanelProps
|
|
1513
|
+
} = panelProps;
|
|
1514
|
+
const {
|
|
1515
|
+
style: toggleButtonStyle = {},
|
|
1516
|
+
onClick: onToggleClick,
|
|
1517
|
+
...otherToggleButtonProps
|
|
1518
|
+
} = toggleButtonProps;
|
|
1519
|
+
|
|
1520
|
+
// get computed style based on panel position
|
|
1521
|
+
const style = getSidePanelStyle({
|
|
1522
|
+
position: panelPosition,
|
|
1523
|
+
devtoolsTheme: defaultTheme,
|
|
1524
|
+
isOpen: isResolvedOpen,
|
|
1525
|
+
height: devtoolsHeight,
|
|
1526
|
+
width: devtoolsWidth,
|
|
1527
|
+
isResizing,
|
|
1528
|
+
panelStyle
|
|
1486
1529
|
});
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1530
|
+
|
|
1531
|
+
// Do not render on the server
|
|
1532
|
+
if (!isMounted()) return null;
|
|
1533
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
1534
|
+
ref: rootRef,
|
|
1535
|
+
className: "ReactQueryDevtools",
|
|
1536
|
+
"aria-label": "React Query Devtools"
|
|
1537
|
+
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
1538
|
+
theme: defaultTheme
|
|
1539
|
+
}, /*#__PURE__*/React.createElement(ReactQueryDevtoolsPanel$2, _extends({
|
|
1540
|
+
ref: panelRef,
|
|
1541
|
+
queryClient: queryClient,
|
|
1542
|
+
styleNonce: styleNonce,
|
|
1543
|
+
position: panelPosition,
|
|
1544
|
+
onPositionChange: setPanelPosition,
|
|
1545
|
+
showCloseButton: true,
|
|
1546
|
+
closeButtonProps: closeButtonProps
|
|
1547
|
+
}, otherPanelProps, {
|
|
1548
|
+
style: style,
|
|
1549
|
+
isOpen: isResolvedOpen,
|
|
1550
|
+
setIsOpen: setIsOpen,
|
|
1551
|
+
onDragStart: e => handleDragStart(panelRef.current, e),
|
|
1552
|
+
errorTypes: errorTypes
|
|
1553
|
+
}))), !isResolvedOpen ? /*#__PURE__*/React.createElement("button", _extends({
|
|
1554
|
+
type: "button"
|
|
1555
|
+
}, otherToggleButtonProps, {
|
|
1556
|
+
"aria-label": "Open React Query Devtools",
|
|
1557
|
+
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
1558
|
+
"aria-haspopup": "true",
|
|
1559
|
+
"aria-expanded": "false",
|
|
1560
|
+
onClick: e => {
|
|
1561
|
+
setIsOpen(true);
|
|
1562
|
+
onToggleClick == null ? void 0 : onToggleClick(e);
|
|
1563
|
+
},
|
|
1512
1564
|
style: {
|
|
1513
|
-
|
|
1514
|
-
|
|
1565
|
+
background: 'none',
|
|
1566
|
+
border: 0,
|
|
1567
|
+
padding: 0,
|
|
1568
|
+
position: 'fixed',
|
|
1569
|
+
zIndex: 99999,
|
|
1570
|
+
display: 'inline-flex',
|
|
1571
|
+
fontSize: '1.5em',
|
|
1572
|
+
margin: '.5em',
|
|
1515
1573
|
cursor: 'pointer',
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1574
|
+
width: 'fit-content',
|
|
1575
|
+
...(position === 'top-right' ? {
|
|
1576
|
+
top: '0',
|
|
1577
|
+
right: '0'
|
|
1578
|
+
} : position === 'top-left' ? {
|
|
1579
|
+
top: '0',
|
|
1580
|
+
left: '0'
|
|
1581
|
+
} : position === 'bottom-right' ? {
|
|
1582
|
+
bottom: '0',
|
|
1583
|
+
right: '0'
|
|
1584
|
+
} : {
|
|
1585
|
+
bottom: '0',
|
|
1586
|
+
left: '0'
|
|
1528
1587
|
}),
|
|
1529
|
-
|
|
1530
|
-
alignItems: 'center',
|
|
1531
|
-
justifyContent: 'center',
|
|
1532
|
-
fontWeight: 'bold',
|
|
1533
|
-
textShadow: isStale ? '0' : '0 0 10px black',
|
|
1534
|
-
color: isStale ? 'black' : 'white'
|
|
1535
|
-
}
|
|
1536
|
-
}, observerCount), isDisabled ? /*#__PURE__*/React.createElement("div", {
|
|
1537
|
-
style: {
|
|
1538
|
-
flex: '0 0 auto',
|
|
1539
|
-
height: '2em',
|
|
1540
|
-
background: defaultTheme.gray,
|
|
1541
|
-
display: 'flex',
|
|
1542
|
-
alignItems: 'center',
|
|
1543
|
-
fontWeight: 'bold',
|
|
1544
|
-
padding: '0 0.5em'
|
|
1545
|
-
}
|
|
1546
|
-
}, "disabled") : null, /*#__PURE__*/React.createElement(Code, {
|
|
1547
|
-
style: {
|
|
1548
|
-
padding: '.5em'
|
|
1588
|
+
...toggleButtonStyle
|
|
1549
1589
|
}
|
|
1550
|
-
},
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1590
|
+
}), /*#__PURE__*/React.createElement(Logo, {
|
|
1591
|
+
"aria-hidden": true
|
|
1592
|
+
}), /*#__PURE__*/React.createElement(ScreenReader, {
|
|
1593
|
+
text: "Open React Query Devtools"
|
|
1594
|
+
})) : null);
|
|
1595
|
+
}
|
|
1555
1596
|
|
|
1556
1597
|
const ReactQueryDevtools = ReactQueryDevtools$1;
|
|
1557
|
-
const ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel$
|
|
1598
|
+
const ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel$2;
|
|
1558
1599
|
|
|
1559
1600
|
export { ReactQueryDevtools, ReactQueryDevtoolsPanel };
|
|
1560
1601
|
//# sourceMappingURL=index.prod.esm.js.map
|