@tanstack/react-query-devtools 4.13.5 → 4.13.7
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.esm.js +4 -5
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +3 -4
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +4 -5
- package/build/lib/devtools.mjs.map +1 -1
- package/build/lib/index.prod.esm.js +6 -6
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +6 -6
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +6 -6
- package/build/lib/index.prod.mjs.map +1 -1
- package/build/lib/utils.d.ts +2 -1
- package/build/lib/utils.esm.js +3 -2
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +3 -2
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +3 -2
- package/build/lib/utils.mjs.map +1 -1
- package/build/umd/index.development.js +6 -6
- package/build/umd/index.development.js.map +1 -1
- package/package.json +1 -1
- package/src/devtools.tsx +84 -81
- package/src/utils.ts +3 -2
package/package.json
CHANGED
package/src/devtools.tsx
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
getResizeHandleStyle,
|
|
23
23
|
getSidedProp,
|
|
24
24
|
defaultPanelSize,
|
|
25
|
+
displayValue,
|
|
25
26
|
} from './utils'
|
|
26
27
|
import type { Corner, Side } from './utils'
|
|
27
28
|
import {
|
|
@@ -846,7 +847,7 @@ const ActiveQuery = ({
|
|
|
846
847
|
overflow: 'auto',
|
|
847
848
|
}}
|
|
848
849
|
>
|
|
849
|
-
{
|
|
850
|
+
{displayValue(activeQuery.queryKey, true)}
|
|
850
851
|
</pre>
|
|
851
852
|
</Code>
|
|
852
853
|
<span
|
|
@@ -1081,103 +1082,105 @@ interface QueryRowProps {
|
|
|
1081
1082
|
queryCache: QueryCache
|
|
1082
1083
|
}
|
|
1083
1084
|
|
|
1084
|
-
const QueryRow = (
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}: QueryRowProps) => {
|
|
1090
|
-
const queryHash =
|
|
1091
|
-
useSubscribeToQueryCache(
|
|
1092
|
-
queryCache,
|
|
1093
|
-
() => queryCache.find(queryKey)?.queryHash,
|
|
1094
|
-
) ?? ''
|
|
1095
|
-
|
|
1096
|
-
const queryState = useSubscribeToQueryCache(
|
|
1085
|
+
const QueryRow = React.memo(
|
|
1086
|
+
({
|
|
1087
|
+
queryKey,
|
|
1088
|
+
setActiveQueryHash,
|
|
1089
|
+
activeQueryHash,
|
|
1097
1090
|
queryCache,
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1091
|
+
}: QueryRowProps) => {
|
|
1092
|
+
const queryHash =
|
|
1093
|
+
useSubscribeToQueryCache(
|
|
1094
|
+
queryCache,
|
|
1095
|
+
() => queryCache.find(queryKey)?.queryHash,
|
|
1096
|
+
) ?? ''
|
|
1097
|
+
|
|
1098
|
+
const queryState = useSubscribeToQueryCache(
|
|
1099
|
+
queryCache,
|
|
1100
|
+
() => queryCache.find(queryKey)?.state,
|
|
1101
|
+
)
|
|
1102
|
+
|
|
1103
|
+
const isStale =
|
|
1104
|
+
useSubscribeToQueryCache(queryCache, () =>
|
|
1105
|
+
queryCache.find(queryKey)?.isStale(),
|
|
1106
|
+
) ?? false
|
|
1107
|
+
|
|
1108
|
+
const isDisabled =
|
|
1109
|
+
useSubscribeToQueryCache(queryCache, () =>
|
|
1110
|
+
queryCache.find(queryKey)?.isDisabled(),
|
|
1111
|
+
) ?? false
|
|
1112
|
+
|
|
1113
|
+
const observerCount =
|
|
1114
|
+
useSubscribeToQueryCache(queryCache, () =>
|
|
1115
|
+
queryCache.find(queryKey)?.getObserversCount(),
|
|
1116
|
+
) ?? 0
|
|
1117
|
+
|
|
1118
|
+
if (!queryState) {
|
|
1119
|
+
return null
|
|
1120
|
+
}
|
|
1119
1121
|
|
|
1120
|
-
|
|
1121
|
-
<div
|
|
1122
|
-
role="button"
|
|
1123
|
-
aria-label={`Open query details for ${queryHash}`}
|
|
1124
|
-
onClick={() =>
|
|
1125
|
-
setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash)
|
|
1126
|
-
}
|
|
1127
|
-
style={{
|
|
1128
|
-
display: 'flex',
|
|
1129
|
-
borderBottom: `solid 1px ${theme.grayAlt}`,
|
|
1130
|
-
cursor: 'pointer',
|
|
1131
|
-
background:
|
|
1132
|
-
queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined,
|
|
1133
|
-
}}
|
|
1134
|
-
>
|
|
1122
|
+
return (
|
|
1135
1123
|
<div
|
|
1124
|
+
role="button"
|
|
1125
|
+
aria-label={`Open query details for ${queryHash}`}
|
|
1126
|
+
onClick={() =>
|
|
1127
|
+
setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash)
|
|
1128
|
+
}
|
|
1136
1129
|
style={{
|
|
1137
|
-
flex: '0 0 auto',
|
|
1138
|
-
width: '2em',
|
|
1139
|
-
height: '2em',
|
|
1140
|
-
background: getQueryStatusColor({
|
|
1141
|
-
queryState,
|
|
1142
|
-
isStale,
|
|
1143
|
-
observerCount,
|
|
1144
|
-
theme,
|
|
1145
|
-
}),
|
|
1146
1130
|
display: 'flex',
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
color: isStale ? 'black' : 'white',
|
|
1131
|
+
borderBottom: `solid 1px ${theme.grayAlt}`,
|
|
1132
|
+
cursor: 'pointer',
|
|
1133
|
+
background:
|
|
1134
|
+
queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined,
|
|
1152
1135
|
}}
|
|
1153
1136
|
>
|
|
1154
|
-
{observerCount}
|
|
1155
|
-
</div>
|
|
1156
|
-
{isDisabled ? (
|
|
1157
1137
|
<div
|
|
1158
1138
|
style={{
|
|
1159
1139
|
flex: '0 0 auto',
|
|
1140
|
+
width: '2em',
|
|
1160
1141
|
height: '2em',
|
|
1161
|
-
background:
|
|
1142
|
+
background: getQueryStatusColor({
|
|
1143
|
+
queryState,
|
|
1144
|
+
isStale,
|
|
1145
|
+
observerCount,
|
|
1146
|
+
theme,
|
|
1147
|
+
}),
|
|
1162
1148
|
display: 'flex',
|
|
1163
1149
|
alignItems: 'center',
|
|
1150
|
+
justifyContent: 'center',
|
|
1164
1151
|
fontWeight: 'bold',
|
|
1165
|
-
|
|
1152
|
+
textShadow: isStale ? '0' : '0 0 10px black',
|
|
1153
|
+
color: isStale ? 'black' : 'white',
|
|
1166
1154
|
}}
|
|
1167
1155
|
>
|
|
1168
|
-
|
|
1156
|
+
{observerCount}
|
|
1169
1157
|
</div>
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
}
|
|
1158
|
+
{isDisabled ? (
|
|
1159
|
+
<div
|
|
1160
|
+
style={{
|
|
1161
|
+
flex: '0 0 auto',
|
|
1162
|
+
height: '2em',
|
|
1163
|
+
background: theme.gray,
|
|
1164
|
+
display: 'flex',
|
|
1165
|
+
alignItems: 'center',
|
|
1166
|
+
fontWeight: 'bold',
|
|
1167
|
+
padding: '0 0.5em',
|
|
1168
|
+
}}
|
|
1169
|
+
>
|
|
1170
|
+
disabled
|
|
1171
|
+
</div>
|
|
1172
|
+
) : null}
|
|
1173
|
+
<Code
|
|
1174
|
+
style={{
|
|
1175
|
+
padding: '.5em',
|
|
1176
|
+
}}
|
|
1177
|
+
>
|
|
1178
|
+
{`${queryHash}`}
|
|
1179
|
+
</Code>
|
|
1180
|
+
</div>
|
|
1181
|
+
)
|
|
1182
|
+
},
|
|
1183
|
+
)
|
|
1181
1184
|
|
|
1182
1185
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1183
1186
|
function noop() {}
|
package/src/utils.ts
CHANGED
|
@@ -117,11 +117,12 @@ export function useIsMounted() {
|
|
|
117
117
|
/**
|
|
118
118
|
* Displays a string regardless the type of the data
|
|
119
119
|
* @param {unknown} value Value to be stringified
|
|
120
|
+
* @param {boolean} beautify Formats json to multiline
|
|
120
121
|
*/
|
|
121
|
-
export const displayValue = (value: unknown) => {
|
|
122
|
+
export const displayValue = (value: unknown, beautify: boolean = false) => {
|
|
122
123
|
const { json } = SuperJSON.serialize(value)
|
|
123
124
|
|
|
124
|
-
return JSON.stringify(json)
|
|
125
|
+
return JSON.stringify(json, null, beautify ? 2 : undefined)
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
// Sorting functions
|