@tanstack/react-query-devtools 4.26.1 → 4.27.0
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/devtools.d.ts +23 -2
- package/build/lib/devtools.esm.js +107 -8
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +106 -8
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +107 -8
- package/build/lib/devtools.mjs.map +1 -1
- package/build/lib/index.prod.esm.js +110 -9
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +109 -9
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +110 -9
- package/build/lib/index.prod.mjs.map +1 -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/umd/index.development.js +109 -9
- package/build/umd/index.development.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/devtools.test.tsx +139 -0
- package/src/devtools.tsx +144 -2
- package/src/styledComponents.ts +3 -1
package/build/lib/index.prod.js
CHANGED
|
@@ -368,7 +368,9 @@ const Button = styled('button', (props, theme) => ({
|
|
|
368
368
|
cursor: 'pointer'
|
|
369
369
|
}));
|
|
370
370
|
const QueryKeys = styled('span', {
|
|
371
|
-
display: '
|
|
371
|
+
display: 'flex',
|
|
372
|
+
flexWrap: 'wrap',
|
|
373
|
+
gap: '0.5em',
|
|
372
374
|
fontSize: '0.9em'
|
|
373
375
|
});
|
|
374
376
|
const QueryKey = styled('span', {
|
|
@@ -722,7 +724,8 @@ function ReactQueryDevtools$1({
|
|
|
722
724
|
containerElement: Container = 'aside',
|
|
723
725
|
context,
|
|
724
726
|
styleNonce,
|
|
725
|
-
panelPosition: initialPanelPosition = 'bottom'
|
|
727
|
+
panelPosition: initialPanelPosition = 'bottom',
|
|
728
|
+
errorTypes = []
|
|
726
729
|
}) {
|
|
727
730
|
const rootRef = React__namespace.useRef(null);
|
|
728
731
|
const panelRef = React__namespace.useRef(null);
|
|
@@ -901,7 +904,8 @@ function ReactQueryDevtools$1({
|
|
|
901
904
|
style: style,
|
|
902
905
|
isOpen: isResolvedOpen,
|
|
903
906
|
setIsOpen: setIsOpen,
|
|
904
|
-
onDragStart: e => handleDragStart(panelRef.current, e)
|
|
907
|
+
onDragStart: e => handleDragStart(panelRef.current, e),
|
|
908
|
+
errorTypes: errorTypes
|
|
905
909
|
}))), !isResolvedOpen ? /*#__PURE__*/React__namespace.createElement("button", _extends({
|
|
906
910
|
type: "button"
|
|
907
911
|
}, otherToggleButtonProps, {
|
|
@@ -966,6 +970,7 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
966
970
|
showCloseButton,
|
|
967
971
|
position,
|
|
968
972
|
closeButtonProps = {},
|
|
973
|
+
errorTypes = [],
|
|
969
974
|
...panelProps
|
|
970
975
|
} = props;
|
|
971
976
|
const {
|
|
@@ -1084,7 +1089,9 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
1084
1089
|
}, "Bottom")) : null), /*#__PURE__*/React__namespace.createElement("div", {
|
|
1085
1090
|
style: {
|
|
1086
1091
|
display: 'flex',
|
|
1087
|
-
alignItems: 'center'
|
|
1092
|
+
alignItems: 'center',
|
|
1093
|
+
flexWrap: 'wrap',
|
|
1094
|
+
gap: '0.5em'
|
|
1088
1095
|
}
|
|
1089
1096
|
}, /*#__PURE__*/React__namespace.createElement(Input, {
|
|
1090
1097
|
placeholder: "Filter",
|
|
@@ -1096,7 +1103,6 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
1096
1103
|
},
|
|
1097
1104
|
style: {
|
|
1098
1105
|
flex: '1',
|
|
1099
|
-
marginRight: '.5em',
|
|
1100
1106
|
width: '100%'
|
|
1101
1107
|
}
|
|
1102
1108
|
}), /*#__PURE__*/React__namespace.createElement(Select, {
|
|
@@ -1196,7 +1202,8 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
1196
1202
|
}))), activeQueryHash && isOpen ? /*#__PURE__*/React__namespace.createElement(ActiveQuery, {
|
|
1197
1203
|
activeQueryHash: activeQueryHash,
|
|
1198
1204
|
queryCache: queryCache,
|
|
1199
|
-
queryClient: queryClient
|
|
1205
|
+
queryClient: queryClient,
|
|
1206
|
+
errorTypes: errorTypes
|
|
1200
1207
|
}) : null, showCloseButton ? /*#__PURE__*/React__namespace.createElement(Button, _extends({
|
|
1201
1208
|
type: "button",
|
|
1202
1209
|
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
@@ -1221,7 +1228,8 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
|
|
|
1221
1228
|
const ActiveQuery = ({
|
|
1222
1229
|
queryCache,
|
|
1223
1230
|
activeQueryHash,
|
|
1224
|
-
queryClient
|
|
1231
|
+
queryClient,
|
|
1232
|
+
errorTypes
|
|
1225
1233
|
}) => {
|
|
1226
1234
|
var _useSubscribeToQueryC, _useSubscribeToQueryC2;
|
|
1227
1235
|
|
|
@@ -1247,10 +1255,44 @@ const ActiveQuery = ({
|
|
|
1247
1255
|
promise == null ? void 0 : promise.catch(noop);
|
|
1248
1256
|
};
|
|
1249
1257
|
|
|
1258
|
+
const currentErrorTypeName = React.useMemo(() => {
|
|
1259
|
+
if (activeQuery && activeQueryState != null && activeQueryState.error) {
|
|
1260
|
+
const errorType = errorTypes.find(type => {
|
|
1261
|
+
var _activeQueryState$err;
|
|
1262
|
+
|
|
1263
|
+
return type.initializer(activeQuery).toString() === ((_activeQueryState$err = activeQueryState.error) == null ? void 0 : _activeQueryState$err.toString());
|
|
1264
|
+
});
|
|
1265
|
+
return errorType == null ? void 0 : errorType.name;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
return undefined;
|
|
1269
|
+
}, [activeQuery, activeQueryState == null ? void 0 : activeQueryState.error, errorTypes]);
|
|
1270
|
+
|
|
1250
1271
|
if (!activeQuery || !activeQueryState) {
|
|
1251
1272
|
return null;
|
|
1252
1273
|
}
|
|
1253
1274
|
|
|
1275
|
+
const triggerError = errorType => {
|
|
1276
|
+
var _errorType$initialize;
|
|
1277
|
+
|
|
1278
|
+
const error = (_errorType$initialize = errorType == null ? void 0 : errorType.initializer(activeQuery)) != null ? _errorType$initialize : new Error('Unknown error from devtools');
|
|
1279
|
+
const __previousQueryOptions = activeQuery.options;
|
|
1280
|
+
activeQuery.setState({
|
|
1281
|
+
status: 'error',
|
|
1282
|
+
error,
|
|
1283
|
+
fetchMeta: { ...activeQuery.state.fetchMeta,
|
|
1284
|
+
__previousQueryOptions
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
const restoreQueryAfterLoadingOrError = () => {
|
|
1290
|
+
activeQuery.fetch(activeQuery.state.fetchMeta.__previousQueryOptions, {
|
|
1291
|
+
// Make sure this fetch will cancel the previous one
|
|
1292
|
+
cancelRefetch: true
|
|
1293
|
+
});
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1254
1296
|
return /*#__PURE__*/React__namespace.createElement(ActiveQueryPanel, null, /*#__PURE__*/React__namespace.createElement("div", {
|
|
1255
1297
|
style: {
|
|
1256
1298
|
padding: '.5em',
|
|
@@ -1317,7 +1359,11 @@ const ActiveQuery = ({
|
|
|
1317
1359
|
}
|
|
1318
1360
|
}, "Actions"), /*#__PURE__*/React__namespace.createElement("div", {
|
|
1319
1361
|
style: {
|
|
1320
|
-
padding: '0.5em'
|
|
1362
|
+
padding: '0.5em',
|
|
1363
|
+
display: 'flex',
|
|
1364
|
+
flexWrap: 'wrap',
|
|
1365
|
+
gap: '0.5em',
|
|
1366
|
+
alignItems: 'flex-end'
|
|
1321
1367
|
}
|
|
1322
1368
|
}, /*#__PURE__*/React__namespace.createElement(Button, {
|
|
1323
1369
|
type: "button",
|
|
@@ -1345,7 +1391,61 @@ const ActiveQuery = ({
|
|
|
1345
1391
|
style: {
|
|
1346
1392
|
background: defaultTheme.danger
|
|
1347
1393
|
}
|
|
1348
|
-
}, "Remove")
|
|
1394
|
+
}, "Remove"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
|
|
1395
|
+
type: "button",
|
|
1396
|
+
onClick: () => {
|
|
1397
|
+
if (activeQuery.state.data === undefined) {
|
|
1398
|
+
restoreQueryAfterLoadingOrError();
|
|
1399
|
+
} else {
|
|
1400
|
+
const __previousQueryOptions = activeQuery.options; // Trigger a fetch in order to trigger suspense as well.
|
|
1401
|
+
|
|
1402
|
+
activeQuery.fetch({ ...__previousQueryOptions,
|
|
1403
|
+
queryFn: () => {
|
|
1404
|
+
return new Promise(() => {// Never resolve
|
|
1405
|
+
});
|
|
1406
|
+
},
|
|
1407
|
+
cacheTime: -1
|
|
1408
|
+
});
|
|
1409
|
+
activeQuery.setState({
|
|
1410
|
+
data: undefined,
|
|
1411
|
+
status: 'loading',
|
|
1412
|
+
fetchMeta: { ...activeQuery.state.fetchMeta,
|
|
1413
|
+
__previousQueryOptions
|
|
1414
|
+
}
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
},
|
|
1418
|
+
style: {
|
|
1419
|
+
background: defaultTheme.paused
|
|
1420
|
+
}
|
|
1421
|
+
}, activeQuery.state.status === 'loading' ? 'Restore' : 'Trigger', ' ', "loading"), ' ', errorTypes.length === 0 || activeQuery.state.status === 'error' ? /*#__PURE__*/React__namespace.createElement(Button, {
|
|
1422
|
+
type: "button",
|
|
1423
|
+
onClick: () => {
|
|
1424
|
+
if (!activeQuery.state.error) {
|
|
1425
|
+
triggerError();
|
|
1426
|
+
} else {
|
|
1427
|
+
queryClient.resetQueries(activeQuery);
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
style: {
|
|
1431
|
+
background: defaultTheme.danger
|
|
1432
|
+
}
|
|
1433
|
+
}, activeQuery.state.status === 'error' ? 'Restore' : 'Trigger', " error") : /*#__PURE__*/React__namespace.createElement("label", null, "Trigger error:", /*#__PURE__*/React__namespace.createElement(Select, {
|
|
1434
|
+
value: currentErrorTypeName != null ? currentErrorTypeName : '',
|
|
1435
|
+
style: {
|
|
1436
|
+
marginInlineStart: '.5em'
|
|
1437
|
+
},
|
|
1438
|
+
onChange: e => {
|
|
1439
|
+
const errorType = errorTypes.find(t => t.name === e.target.value);
|
|
1440
|
+
triggerError(errorType);
|
|
1441
|
+
}
|
|
1442
|
+
}, /*#__PURE__*/React__namespace.createElement("option", {
|
|
1443
|
+
key: "",
|
|
1444
|
+
value: ""
|
|
1445
|
+
}), errorTypes.map(errorType => /*#__PURE__*/React__namespace.createElement("option", {
|
|
1446
|
+
key: errorType.name,
|
|
1447
|
+
value: errorType.name
|
|
1448
|
+
}, errorType.name))))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
1349
1449
|
style: {
|
|
1350
1450
|
background: defaultTheme.backgroundAlt,
|
|
1351
1451
|
padding: '.5em',
|