@tanstack/react-query-devtools 5.0.0-alpha.0 → 5.0.0-alpha.10
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/Explorer.esm.js +2 -1
- package/build/lib/Explorer.esm.js.map +1 -1
- package/build/lib/Explorer.js +2 -1
- package/build/lib/Explorer.js.map +1 -1
- package/build/lib/Explorer.mjs +1 -0
- package/build/lib/Explorer.mjs.map +1 -1
- package/build/lib/devtools.d.ts +20 -2
- package/build/lib/devtools.esm.js +161 -34
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +160 -34
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +105 -9
- package/build/lib/devtools.mjs.map +1 -1
- package/build/lib/index.esm.js +1 -0
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +1 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +1 -0
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/index.prod.esm.js +164 -36
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +163 -36
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +107 -10
- package/build/lib/index.prod.mjs.map +1 -1
- package/build/lib/styledComponents.d.ts +0 -1
- package/build/lib/styledComponents.esm.js +3 -1
- package/build/lib/styledComponents.esm.js.map +1 -1
- package/build/lib/styledComponents.js +3 -1
- package/build/lib/styledComponents.js.map +1 -1
- package/build/lib/styledComponents.mjs +3 -1
- package/build/lib/styledComponents.mjs.map +1 -1
- package/build/lib/theme.esm.js +1 -0
- package/build/lib/theme.esm.js.map +1 -1
- package/build/lib/theme.js +1 -0
- package/build/lib/theme.js.map +1 -1
- package/build/lib/theme.mjs +1 -0
- package/build/lib/theme.mjs.map +1 -1
- package/build/umd/index.development.js +106 -10
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/Explorer.test.tsx +3 -2
- package/src/__tests__/devtools.test.tsx +163 -14
- package/src/devtools.tsx +150 -3
- package/src/index.ts +2 -0
- package/src/styledComponents.ts +3 -1
package/build/lib/index.prod.js
CHANGED
|
@@ -351,7 +351,9 @@ const Button = styled('button', (props, theme) => ({
|
|
|
351
351
|
cursor: 'pointer'
|
|
352
352
|
}));
|
|
353
353
|
const QueryKeys = styled('span', {
|
|
354
|
-
display: '
|
|
354
|
+
display: 'flex',
|
|
355
|
+
flexWrap: 'wrap',
|
|
356
|
+
gap: '0.5em',
|
|
355
357
|
fontSize: '0.9em'
|
|
356
358
|
});
|
|
357
359
|
const QueryKey = styled('span', {
|
|
@@ -614,7 +616,7 @@ function Explorer({
|
|
|
614
616
|
const makeProperty = sub => {
|
|
615
617
|
const subDefaultExpanded = defaultExpanded === true ? {
|
|
616
618
|
[sub.label]: true
|
|
617
|
-
} : defaultExpanded
|
|
619
|
+
} : defaultExpanded == null ? void 0 : defaultExpanded[sub.label];
|
|
618
620
|
return {
|
|
619
621
|
...sub,
|
|
620
622
|
defaultExpanded: subDefaultExpanded
|
|
@@ -695,7 +697,8 @@ function ReactQueryDevtools$1({
|
|
|
695
697
|
containerElement: Container = 'aside',
|
|
696
698
|
queryClient,
|
|
697
699
|
styleNonce,
|
|
698
|
-
panelPosition: initialPanelPosition = 'bottom'
|
|
700
|
+
panelPosition: initialPanelPosition = 'bottom',
|
|
701
|
+
errorTypes = []
|
|
699
702
|
}) {
|
|
700
703
|
const rootRef = React__namespace.useRef(null);
|
|
701
704
|
const panelRef = React__namespace.useRef(null);
|
|
@@ -748,7 +751,7 @@ function ReactQueryDevtools$1({
|
|
|
748
751
|
document.addEventListener('mouseup', unsub, false);
|
|
749
752
|
};
|
|
750
753
|
React__namespace.useEffect(() => {
|
|
751
|
-
setIsResolvedOpen(isOpen
|
|
754
|
+
setIsResolvedOpen(isOpen != null ? isOpen : false);
|
|
752
755
|
}, [isOpen, isResolvedOpen, setIsResolvedOpen]);
|
|
753
756
|
|
|
754
757
|
// Toggle panel visibility before/after transition (depending on direction).
|
|
@@ -776,7 +779,8 @@ function ReactQueryDevtools$1({
|
|
|
776
779
|
return;
|
|
777
780
|
}, [isResolvedOpen]);
|
|
778
781
|
React__namespace.useEffect(() => {
|
|
779
|
-
|
|
782
|
+
var _rootRef$current;
|
|
783
|
+
if (isResolvedOpen && (_rootRef$current = rootRef.current) != null && _rootRef$current.parentElement) {
|
|
780
784
|
const {
|
|
781
785
|
parentElement
|
|
782
786
|
} = rootRef.current;
|
|
@@ -860,7 +864,8 @@ function ReactQueryDevtools$1({
|
|
|
860
864
|
style: style,
|
|
861
865
|
isOpen: isResolvedOpen,
|
|
862
866
|
setIsOpen: setIsOpen,
|
|
863
|
-
onDragStart: e => handleDragStart(panelRef.current, e)
|
|
867
|
+
onDragStart: e => handleDragStart(panelRef.current, e),
|
|
868
|
+
errorTypes: errorTypes
|
|
864
869
|
}))), !isResolvedOpen ? /*#__PURE__*/React__namespace.createElement("button", _extends({
|
|
865
870
|
type: "button"
|
|
866
871
|
}, otherToggleButtonProps, {
|
|
@@ -870,7 +875,7 @@ function ReactQueryDevtools$1({
|
|
|
870
875
|
"aria-expanded": "false",
|
|
871
876
|
onClick: e => {
|
|
872
877
|
setIsOpen(true);
|
|
873
|
-
onToggleClick
|
|
878
|
+
onToggleClick == null ? void 0 : onToggleClick(e);
|
|
874
879
|
},
|
|
875
880
|
style: {
|
|
876
881
|
background: 'none',
|
|
@@ -923,6 +928,7 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
923
928
|
showCloseButton,
|
|
924
929
|
position,
|
|
925
930
|
closeButtonProps = {},
|
|
931
|
+
errorTypes = [],
|
|
926
932
|
...panelProps
|
|
927
933
|
} = props;
|
|
928
934
|
const {
|
|
@@ -1056,19 +1062,20 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
1056
1062
|
}, "Bottom")) : null), /*#__PURE__*/React__namespace.createElement("div", {
|
|
1057
1063
|
style: {
|
|
1058
1064
|
display: 'flex',
|
|
1059
|
-
alignItems: 'center'
|
|
1065
|
+
alignItems: 'center',
|
|
1066
|
+
flexWrap: 'wrap',
|
|
1067
|
+
gap: '0.5em'
|
|
1060
1068
|
}
|
|
1061
1069
|
}, /*#__PURE__*/React__namespace.createElement(Input, {
|
|
1062
1070
|
placeholder: "Filter",
|
|
1063
1071
|
"aria-label": "Filter by queryhash",
|
|
1064
|
-
value: filter
|
|
1072
|
+
value: filter != null ? filter : '',
|
|
1065
1073
|
onChange: e => setFilter(e.target.value),
|
|
1066
1074
|
onKeyDown: e => {
|
|
1067
1075
|
if (e.key === 'Escape') setFilter('');
|
|
1068
1076
|
},
|
|
1069
1077
|
style: {
|
|
1070
1078
|
flex: '1',
|
|
1071
|
-
marginRight: '.5em',
|
|
1072
1079
|
width: '100%'
|
|
1073
1080
|
}
|
|
1074
1081
|
}), /*#__PURE__*/React__namespace.createElement(Select, {
|
|
@@ -1168,7 +1175,8 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
1168
1175
|
}))), activeQueryHash && isOpen ? /*#__PURE__*/React__namespace.createElement(ActiveQuery, {
|
|
1169
1176
|
activeQueryHash: activeQueryHash,
|
|
1170
1177
|
queryCache: queryCache,
|
|
1171
|
-
queryClient: client
|
|
1178
|
+
queryClient: client,
|
|
1179
|
+
errorTypes: errorTypes
|
|
1172
1180
|
}) : null, showCloseButton ? /*#__PURE__*/React__namespace.createElement(Button, _extends({
|
|
1173
1181
|
type: "button",
|
|
1174
1182
|
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
@@ -1185,26 +1193,67 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
1185
1193
|
},
|
|
1186
1194
|
onClick: e => {
|
|
1187
1195
|
setIsOpen(false);
|
|
1188
|
-
onCloseClick
|
|
1196
|
+
onCloseClick == null ? void 0 : onCloseClick(e);
|
|
1189
1197
|
}
|
|
1190
1198
|
}), "Close") : null));
|
|
1191
1199
|
});
|
|
1192
1200
|
const ActiveQuery = ({
|
|
1193
1201
|
queryCache,
|
|
1194
1202
|
activeQueryHash,
|
|
1195
|
-
queryClient
|
|
1203
|
+
queryClient,
|
|
1204
|
+
errorTypes
|
|
1196
1205
|
}) => {
|
|
1206
|
+
var _useSubscribeToQueryC, _useSubscribeToQueryC2;
|
|
1197
1207
|
const activeQuery = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
|
|
1198
|
-
const activeQueryState = useSubscribeToQueryCache(queryCache, () =>
|
|
1199
|
-
|
|
1200
|
-
|
|
1208
|
+
const activeQueryState = useSubscribeToQueryCache(queryCache, () => {
|
|
1209
|
+
var _queryCache$getAll$fi;
|
|
1210
|
+
return (_queryCache$getAll$fi = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi.state;
|
|
1211
|
+
});
|
|
1212
|
+
const isStale = (_useSubscribeToQueryC = useSubscribeToQueryCache(queryCache, () => {
|
|
1213
|
+
var _queryCache$getAll$fi2;
|
|
1214
|
+
return (_queryCache$getAll$fi2 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi2.isStale();
|
|
1215
|
+
})) != null ? _useSubscribeToQueryC : false;
|
|
1216
|
+
const observerCount = (_useSubscribeToQueryC2 = useSubscribeToQueryCache(queryCache, () => {
|
|
1217
|
+
var _queryCache$getAll$fi3;
|
|
1218
|
+
return (_queryCache$getAll$fi3 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi3.getObserversCount();
|
|
1219
|
+
})) != null ? _useSubscribeToQueryC2 : 0;
|
|
1201
1220
|
const handleRefetch = () => {
|
|
1202
|
-
const promise = activeQuery
|
|
1203
|
-
promise
|
|
1221
|
+
const promise = activeQuery == null ? void 0 : activeQuery.fetch();
|
|
1222
|
+
promise == null ? void 0 : promise.catch(noop);
|
|
1204
1223
|
};
|
|
1224
|
+
const currentErrorTypeName = React.useMemo(() => {
|
|
1225
|
+
if (activeQuery && activeQueryState != null && activeQueryState.error) {
|
|
1226
|
+
const errorType = errorTypes.find(type => {
|
|
1227
|
+
var _activeQueryState$err;
|
|
1228
|
+
return type.initializer(activeQuery).toString() === ((_activeQueryState$err = activeQueryState.error) == null ? void 0 : _activeQueryState$err.toString());
|
|
1229
|
+
});
|
|
1230
|
+
return errorType == null ? void 0 : errorType.name;
|
|
1231
|
+
}
|
|
1232
|
+
return undefined;
|
|
1233
|
+
}, [activeQuery, activeQueryState == null ? void 0 : activeQueryState.error, errorTypes]);
|
|
1205
1234
|
if (!activeQuery || !activeQueryState) {
|
|
1206
1235
|
return null;
|
|
1207
1236
|
}
|
|
1237
|
+
const triggerError = errorType => {
|
|
1238
|
+
var _errorType$initialize;
|
|
1239
|
+
const error = (_errorType$initialize = errorType == null ? void 0 : errorType.initializer(activeQuery)) != null ? _errorType$initialize : new Error('Unknown error from devtools');
|
|
1240
|
+
const __previousQueryOptions = activeQuery.options;
|
|
1241
|
+
activeQuery.setState({
|
|
1242
|
+
status: 'error',
|
|
1243
|
+
error,
|
|
1244
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
1245
|
+
fetchMeta: {
|
|
1246
|
+
...activeQuery.state.fetchMeta,
|
|
1247
|
+
__previousQueryOptions
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
};
|
|
1251
|
+
const restoreQueryAfterLoadingOrError = () => {
|
|
1252
|
+
activeQuery.fetch(activeQuery.state.fetchMeta.__previousQueryOptions, {
|
|
1253
|
+
// Make sure this fetch will cancel the previous one
|
|
1254
|
+
cancelRefetch: true
|
|
1255
|
+
});
|
|
1256
|
+
};
|
|
1208
1257
|
return /*#__PURE__*/React__namespace.createElement(ActiveQueryPanel, null, /*#__PURE__*/React__namespace.createElement("div", {
|
|
1209
1258
|
style: {
|
|
1210
1259
|
padding: '.5em',
|
|
@@ -1221,7 +1270,7 @@ const ActiveQuery = ({
|
|
|
1221
1270
|
style: {
|
|
1222
1271
|
marginBottom: '.5em',
|
|
1223
1272
|
display: 'flex',
|
|
1224
|
-
alignItems: '
|
|
1273
|
+
alignItems: 'flex-start',
|
|
1225
1274
|
justifyContent: 'space-between'
|
|
1226
1275
|
}
|
|
1227
1276
|
}, /*#__PURE__*/React__namespace.createElement(Code, {
|
|
@@ -1271,7 +1320,11 @@ const ActiveQuery = ({
|
|
|
1271
1320
|
}
|
|
1272
1321
|
}, "Actions"), /*#__PURE__*/React__namespace.createElement("div", {
|
|
1273
1322
|
style: {
|
|
1274
|
-
padding: '0.5em'
|
|
1323
|
+
padding: '0.5em',
|
|
1324
|
+
display: 'flex',
|
|
1325
|
+
flexWrap: 'wrap',
|
|
1326
|
+
gap: '0.5em',
|
|
1327
|
+
alignItems: 'flex-end'
|
|
1275
1328
|
}
|
|
1276
1329
|
}, /*#__PURE__*/React__namespace.createElement(Button, {
|
|
1277
1330
|
type: "button",
|
|
@@ -1299,7 +1352,65 @@ const ActiveQuery = ({
|
|
|
1299
1352
|
style: {
|
|
1300
1353
|
background: defaultTheme.danger
|
|
1301
1354
|
}
|
|
1302
|
-
}, "Remove")
|
|
1355
|
+
}, "Remove"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
|
|
1356
|
+
type: "button",
|
|
1357
|
+
onClick: () => {
|
|
1358
|
+
if (activeQuery.state.data === undefined) {
|
|
1359
|
+
restoreQueryAfterLoadingOrError();
|
|
1360
|
+
} else {
|
|
1361
|
+
const __previousQueryOptions = activeQuery.options;
|
|
1362
|
+
// Trigger a fetch in order to trigger suspense as well.
|
|
1363
|
+
activeQuery.fetch({
|
|
1364
|
+
...__previousQueryOptions,
|
|
1365
|
+
queryFn: () => {
|
|
1366
|
+
return new Promise(() => {
|
|
1367
|
+
// Never resolve
|
|
1368
|
+
});
|
|
1369
|
+
},
|
|
1370
|
+
gcTime: -1
|
|
1371
|
+
});
|
|
1372
|
+
activeQuery.setState({
|
|
1373
|
+
data: undefined,
|
|
1374
|
+
status: 'pending',
|
|
1375
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
1376
|
+
fetchMeta: {
|
|
1377
|
+
...activeQuery.state.fetchMeta,
|
|
1378
|
+
__previousQueryOptions
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
},
|
|
1383
|
+
style: {
|
|
1384
|
+
background: defaultTheme.paused
|
|
1385
|
+
}
|
|
1386
|
+
}, activeQuery.state.status === 'pending' ? 'Restore' : 'Trigger', ' ', "loading"), ' ', errorTypes.length === 0 || activeQuery.state.status === 'error' ? /*#__PURE__*/React__namespace.createElement(Button, {
|
|
1387
|
+
type: "button",
|
|
1388
|
+
onClick: () => {
|
|
1389
|
+
if (!activeQuery.state.error) {
|
|
1390
|
+
triggerError();
|
|
1391
|
+
} else {
|
|
1392
|
+
queryClient.resetQueries(activeQuery);
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
style: {
|
|
1396
|
+
background: defaultTheme.danger
|
|
1397
|
+
}
|
|
1398
|
+
}, activeQuery.state.status === 'error' ? 'Restore' : 'Trigger', " error") : /*#__PURE__*/React__namespace.createElement("label", null, "Trigger error:", /*#__PURE__*/React__namespace.createElement(Select, {
|
|
1399
|
+
value: currentErrorTypeName != null ? currentErrorTypeName : '',
|
|
1400
|
+
style: {
|
|
1401
|
+
marginInlineStart: '.5em'
|
|
1402
|
+
},
|
|
1403
|
+
onChange: e => {
|
|
1404
|
+
const errorType = errorTypes.find(t => t.name === e.target.value);
|
|
1405
|
+
triggerError(errorType);
|
|
1406
|
+
}
|
|
1407
|
+
}, /*#__PURE__*/React__namespace.createElement("option", {
|
|
1408
|
+
key: "",
|
|
1409
|
+
value: ""
|
|
1410
|
+
}), errorTypes.map(errorType => /*#__PURE__*/React__namespace.createElement("option", {
|
|
1411
|
+
key: errorType.name,
|
|
1412
|
+
value: errorType.name
|
|
1413
|
+
}, errorType.name))))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
1303
1414
|
style: {
|
|
1304
1415
|
background: defaultTheme.backgroundAlt,
|
|
1305
1416
|
padding: '.5em',
|
|
@@ -1379,21 +1490,37 @@ const QueryRow = /*#__PURE__*/React__namespace.memo(({
|
|
|
1379
1490
|
activeQueryHash,
|
|
1380
1491
|
queryCache
|
|
1381
1492
|
}) => {
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1493
|
+
var _useSubscribeToQueryC3, _useSubscribeToQueryC4, _useSubscribeToQueryC5, _useSubscribeToQueryC6;
|
|
1494
|
+
const queryHash = (_useSubscribeToQueryC3 = useSubscribeToQueryCache(queryCache, () => {
|
|
1495
|
+
var _queryCache$find;
|
|
1496
|
+
return (_queryCache$find = queryCache.find({
|
|
1497
|
+
queryKey
|
|
1498
|
+
})) == null ? void 0 : _queryCache$find.queryHash;
|
|
1499
|
+
})) != null ? _useSubscribeToQueryC3 : '';
|
|
1500
|
+
const queryState = useSubscribeToQueryCache(queryCache, () => {
|
|
1501
|
+
var _queryCache$find2;
|
|
1502
|
+
return (_queryCache$find2 = queryCache.find({
|
|
1503
|
+
queryKey
|
|
1504
|
+
})) == null ? void 0 : _queryCache$find2.state;
|
|
1505
|
+
});
|
|
1506
|
+
const isStale = (_useSubscribeToQueryC4 = useSubscribeToQueryCache(queryCache, () => {
|
|
1507
|
+
var _queryCache$find3;
|
|
1508
|
+
return (_queryCache$find3 = queryCache.find({
|
|
1509
|
+
queryKey
|
|
1510
|
+
})) == null ? void 0 : _queryCache$find3.isStale();
|
|
1511
|
+
})) != null ? _useSubscribeToQueryC4 : false;
|
|
1512
|
+
const isDisabled = (_useSubscribeToQueryC5 = useSubscribeToQueryCache(queryCache, () => {
|
|
1513
|
+
var _queryCache$find4;
|
|
1514
|
+
return (_queryCache$find4 = queryCache.find({
|
|
1515
|
+
queryKey
|
|
1516
|
+
})) == null ? void 0 : _queryCache$find4.isDisabled();
|
|
1517
|
+
})) != null ? _useSubscribeToQueryC5 : false;
|
|
1518
|
+
const observerCount = (_useSubscribeToQueryC6 = useSubscribeToQueryCache(queryCache, () => {
|
|
1519
|
+
var _queryCache$find5;
|
|
1520
|
+
return (_queryCache$find5 = queryCache.find({
|
|
1521
|
+
queryKey
|
|
1522
|
+
})) == null ? void 0 : _queryCache$find5.getObserversCount();
|
|
1523
|
+
})) != null ? _useSubscribeToQueryC6 : 0;
|
|
1397
1524
|
if (!queryState) {
|
|
1398
1525
|
return null;
|
|
1399
1526
|
}
|