@tanstack/query-devtools 5.0.0-beta.37 → 5.0.0-rc.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/Devtools/{H2EROWFU.jsx → 56YMBTAH.jsx} +286 -27
- package/build/Devtools/{HTDVDYMT.js → B5V4HXOX.js} +405 -105
- package/build/Devtools/{ALVY75L5.jsx → ECUC7UFN.jsx} +286 -27
- package/build/Devtools/{66PXWIOF.js → UZ6MTF6A.js} +405 -105
- package/build/dev.cjs +418 -114
- package/build/dev.js +1 -1
- package/build/dev.jsx +1 -1
- package/build/index.cjs +418 -114
- package/build/index.js +1 -1
- package/build/index.jsx +1 -1
- package/package.json +4 -4
- package/src/Devtools.tsx +2 -1
- package/src/Explorer.tsx +227 -19
- package/src/__tests__/utils.test.ts +725 -0
- package/src/icons/index.tsx +55 -0
- package/src/utils.tsx +137 -0
|
@@ -9478,6 +9478,86 @@ var sortFns = {
|
|
|
9478
9478
|
var convertRemToPixels = (rem) => {
|
|
9479
9479
|
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
9480
9480
|
};
|
|
9481
|
+
var updateNestedDataByPath = (oldData, updatePath2, value) => {
|
|
9482
|
+
if (updatePath2.length === 0) {
|
|
9483
|
+
return value;
|
|
9484
|
+
}
|
|
9485
|
+
if (oldData instanceof Map) {
|
|
9486
|
+
const newData = new Map(oldData);
|
|
9487
|
+
if (updatePath2.length === 1) {
|
|
9488
|
+
newData.set(updatePath2[0], value);
|
|
9489
|
+
return newData;
|
|
9490
|
+
}
|
|
9491
|
+
const [head, ...tail] = updatePath2;
|
|
9492
|
+
newData.set(head, updateNestedDataByPath(newData.get(head), tail, value));
|
|
9493
|
+
return newData;
|
|
9494
|
+
}
|
|
9495
|
+
if (oldData instanceof Set) {
|
|
9496
|
+
const setAsArray = updateNestedDataByPath(
|
|
9497
|
+
Array.from(oldData),
|
|
9498
|
+
updatePath2,
|
|
9499
|
+
value
|
|
9500
|
+
);
|
|
9501
|
+
return new Set(setAsArray);
|
|
9502
|
+
}
|
|
9503
|
+
if (Array.isArray(oldData)) {
|
|
9504
|
+
const newData = [...oldData];
|
|
9505
|
+
if (updatePath2.length === 1) {
|
|
9506
|
+
newData[updatePath2[0]] = value;
|
|
9507
|
+
return newData;
|
|
9508
|
+
}
|
|
9509
|
+
const [head, ...tail] = updatePath2;
|
|
9510
|
+
newData[head] = updateNestedDataByPath(newData[head], tail, value);
|
|
9511
|
+
return newData;
|
|
9512
|
+
}
|
|
9513
|
+
if (oldData instanceof Object) {
|
|
9514
|
+
const newData = { ...oldData };
|
|
9515
|
+
if (updatePath2.length === 1) {
|
|
9516
|
+
newData[updatePath2[0]] = value;
|
|
9517
|
+
return newData;
|
|
9518
|
+
}
|
|
9519
|
+
const [head, ...tail] = updatePath2;
|
|
9520
|
+
newData[head] = updateNestedDataByPath(newData[head], tail, value);
|
|
9521
|
+
return newData;
|
|
9522
|
+
}
|
|
9523
|
+
return oldData;
|
|
9524
|
+
};
|
|
9525
|
+
var deleteNestedDataByPath = (oldData, deletePath) => {
|
|
9526
|
+
if (oldData instanceof Map) {
|
|
9527
|
+
const newData = new Map(oldData);
|
|
9528
|
+
if (deletePath.length === 1) {
|
|
9529
|
+
newData.delete(deletePath[0]);
|
|
9530
|
+
return newData;
|
|
9531
|
+
}
|
|
9532
|
+
const [head, ...tail] = deletePath;
|
|
9533
|
+
newData.set(head, deleteNestedDataByPath(newData.get(head), tail));
|
|
9534
|
+
return newData;
|
|
9535
|
+
}
|
|
9536
|
+
if (oldData instanceof Set) {
|
|
9537
|
+
const setAsArray = deleteNestedDataByPath(Array.from(oldData), deletePath);
|
|
9538
|
+
return new Set(setAsArray);
|
|
9539
|
+
}
|
|
9540
|
+
if (Array.isArray(oldData)) {
|
|
9541
|
+
const newData = [...oldData];
|
|
9542
|
+
if (deletePath.length === 1) {
|
|
9543
|
+
return newData.filter((_, idx) => idx.toString() !== deletePath[0]);
|
|
9544
|
+
}
|
|
9545
|
+
const [head, ...tail] = deletePath;
|
|
9546
|
+
newData[head] = deleteNestedDataByPath(newData[head], tail);
|
|
9547
|
+
return newData;
|
|
9548
|
+
}
|
|
9549
|
+
if (oldData instanceof Object) {
|
|
9550
|
+
const newData = { ...oldData };
|
|
9551
|
+
if (deletePath.length === 1) {
|
|
9552
|
+
delete newData[deletePath[0]];
|
|
9553
|
+
return newData;
|
|
9554
|
+
}
|
|
9555
|
+
const [head, ...tail] = deletePath;
|
|
9556
|
+
newData[head] = deleteNestedDataByPath(newData[head], tail);
|
|
9557
|
+
return newData;
|
|
9558
|
+
}
|
|
9559
|
+
return oldData;
|
|
9560
|
+
};
|
|
9481
9561
|
|
|
9482
9562
|
// src/icons/index.tsx
|
|
9483
9563
|
function Search() {
|
|
@@ -9692,6 +9772,53 @@ function ErrorCopier() {
|
|
|
9692
9772
|
stroke-linejoin="round"
|
|
9693
9773
|
/></svg>;
|
|
9694
9774
|
}
|
|
9775
|
+
function List() {
|
|
9776
|
+
return <svg
|
|
9777
|
+
width="24"
|
|
9778
|
+
height="24"
|
|
9779
|
+
viewBox="0 0 24 24"
|
|
9780
|
+
fill="none"
|
|
9781
|
+
stroke="#98A2B3"
|
|
9782
|
+
stroke-width="2"
|
|
9783
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9784
|
+
>
|
|
9785
|
+
<rect class="list" width="20" height="20" y="2" x="2" rx="2" />
|
|
9786
|
+
<line class="list-item" y1="7" y2="7" x1="6" x2="18" />
|
|
9787
|
+
<line class="list-item" y2="12" y1="12" x1="6" x2="18" />
|
|
9788
|
+
<line class="list-item" y1="17" y2="17" x1="6" x2="18" />
|
|
9789
|
+
</svg>;
|
|
9790
|
+
}
|
|
9791
|
+
function Check(props) {
|
|
9792
|
+
return <svg
|
|
9793
|
+
width="24"
|
|
9794
|
+
height="24"
|
|
9795
|
+
viewBox="0 0 24 24"
|
|
9796
|
+
fill="none"
|
|
9797
|
+
stroke="#98A2B3"
|
|
9798
|
+
stroke-width="2"
|
|
9799
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9800
|
+
>
|
|
9801
|
+
<rect x="2" y="2" width="20" height="20" rx="2" class="check" />
|
|
9802
|
+
{props.checked && <g>
|
|
9803
|
+
<line
|
|
9804
|
+
transform="rotate(45 7.18873 14.6316)"
|
|
9805
|
+
x1="3.56453"
|
|
9806
|
+
y1="14.63158"
|
|
9807
|
+
x2="10.81294"
|
|
9808
|
+
y2="14.63158"
|
|
9809
|
+
class="check"
|
|
9810
|
+
/>
|
|
9811
|
+
<line
|
|
9812
|
+
transform="rotate(-45 13.9674 11.5826)"
|
|
9813
|
+
x1="6.02012"
|
|
9814
|
+
y1="11.58263"
|
|
9815
|
+
x2="21.91469"
|
|
9816
|
+
y2="11.58263"
|
|
9817
|
+
class="check"
|
|
9818
|
+
/>
|
|
9819
|
+
</g>}
|
|
9820
|
+
</svg>;
|
|
9821
|
+
}
|
|
9695
9822
|
function TanstackLogo() {
|
|
9696
9823
|
return <svg version="1.0" viewBox="0 0 633 633">
|
|
9697
9824
|
<linearGradient
|
|
@@ -10408,6 +10535,17 @@ function TanstackLogo() {
|
|
|
10408
10535
|
</svg>;
|
|
10409
10536
|
}
|
|
10410
10537
|
|
|
10538
|
+
// src/Context.ts
|
|
10539
|
+
var QueryDevtoolsContext = createContext({
|
|
10540
|
+
client: void 0,
|
|
10541
|
+
onlineManager: void 0,
|
|
10542
|
+
queryFlavor: "",
|
|
10543
|
+
version: ""
|
|
10544
|
+
});
|
|
10545
|
+
function useQueryDevtoolsContext() {
|
|
10546
|
+
return useContext(QueryDevtoolsContext);
|
|
10547
|
+
}
|
|
10548
|
+
|
|
10411
10549
|
// src/Explorer.tsx
|
|
10412
10550
|
function chunkArray(array, size2) {
|
|
10413
10551
|
if (size2 < 1)
|
|
@@ -10451,7 +10589,8 @@ var CopyButton = (props) => {
|
|
|
10451
10589
|
const styles = getStyles();
|
|
10452
10590
|
const [copyState, setCopyState] = createSignal("NoCopy");
|
|
10453
10591
|
return <button
|
|
10454
|
-
class={styles.
|
|
10592
|
+
class={styles.actionButton}
|
|
10593
|
+
title="Copy object to clipboard"
|
|
10455
10594
|
aria-label={`${copyState() === "NoCopy" ? "Copy object to clipboard" : copyState() === "SuccessCopy" ? "Object copied to clipboard" : "Error copying object to clipboard"}`}
|
|
10456
10595
|
onClick={copyState() === "NoCopy" ? () => {
|
|
10457
10596
|
navigator.clipboard.writeText(stringify(props.value)).then(
|
|
@@ -10476,11 +10615,58 @@ var CopyButton = (props) => {
|
|
|
10476
10615
|
<Match when={copyState() === "ErrorCopy"}><ErrorCopier /></Match>
|
|
10477
10616
|
</Switch></button>;
|
|
10478
10617
|
};
|
|
10618
|
+
var ClearArrayButton = (props) => {
|
|
10619
|
+
const styles = getStyles();
|
|
10620
|
+
const queryClient = useQueryDevtoolsContext().client;
|
|
10621
|
+
return <button
|
|
10622
|
+
class={styles.actionButton}
|
|
10623
|
+
title="Remove all items"
|
|
10624
|
+
aria-label="Remove all items"
|
|
10625
|
+
onClick={() => {
|
|
10626
|
+
const oldData = props.activeQuery.state.data;
|
|
10627
|
+
const newData = updateNestedDataByPath(oldData, props.dataPath, []);
|
|
10628
|
+
queryClient.setQueryData(props.activeQuery.queryKey, newData);
|
|
10629
|
+
}}
|
|
10630
|
+
><List /></button>;
|
|
10631
|
+
};
|
|
10632
|
+
var DeleteItemButton = (props) => {
|
|
10633
|
+
const styles = getStyles();
|
|
10634
|
+
const queryClient = useQueryDevtoolsContext().client;
|
|
10635
|
+
return <button
|
|
10636
|
+
class={clsx(styles.actionButton)}
|
|
10637
|
+
title="Delete item"
|
|
10638
|
+
aria-label="Delete item"
|
|
10639
|
+
onClick={() => {
|
|
10640
|
+
const oldData = props.activeQuery.state.data;
|
|
10641
|
+
const newData = deleteNestedDataByPath(oldData, props.dataPath);
|
|
10642
|
+
queryClient.setQueryData(props.activeQuery.queryKey, newData);
|
|
10643
|
+
}}
|
|
10644
|
+
><Trash /></button>;
|
|
10645
|
+
};
|
|
10646
|
+
var ToggleValueButton = (props) => {
|
|
10647
|
+
const styles = getStyles();
|
|
10648
|
+
const queryClient = useQueryDevtoolsContext().client;
|
|
10649
|
+
return <button
|
|
10650
|
+
class={clsx(styles.actionButton)}
|
|
10651
|
+
title="Toggle value"
|
|
10652
|
+
aria-label="Toggle value"
|
|
10653
|
+
onClick={() => {
|
|
10654
|
+
const oldData = props.activeQuery.state.data;
|
|
10655
|
+
const newData = updateNestedDataByPath(
|
|
10656
|
+
oldData,
|
|
10657
|
+
props.dataPath,
|
|
10658
|
+
!props.value
|
|
10659
|
+
);
|
|
10660
|
+
queryClient.setQueryData(props.activeQuery.queryKey, newData);
|
|
10661
|
+
}}
|
|
10662
|
+
><Check checked={props.value} /></button>;
|
|
10663
|
+
};
|
|
10479
10664
|
function isIterable(x) {
|
|
10480
10665
|
return Symbol.iterator in x;
|
|
10481
10666
|
}
|
|
10482
10667
|
function Explorer(props) {
|
|
10483
10668
|
const styles = getStyles();
|
|
10669
|
+
const queryClient = useQueryDevtoolsContext().client;
|
|
10484
10670
|
const [expanded, setExpanded] = createSignal(
|
|
10485
10671
|
(props.defaultExpanded || []).includes(props.label)
|
|
10486
10672
|
);
|
|
@@ -10522,6 +10708,7 @@ function Explorer(props) {
|
|
|
10522
10708
|
return typeof props.value;
|
|
10523
10709
|
});
|
|
10524
10710
|
const subEntryPages = createMemo(() => chunkArray(subEntries(), 100));
|
|
10711
|
+
const currentDataPath = props.dataPath ?? [];
|
|
10525
10712
|
return <div class={styles.entry}>
|
|
10526
10713
|
<Show when={subEntryPages().length}>
|
|
10527
10714
|
<div class={styles.expanderButtonContainer}>
|
|
@@ -10540,7 +10727,21 @@ function Explorer(props) {
|
|
|
10540
10727
|
{subEntries().length > 1 ? `items` : `item`}
|
|
10541
10728
|
</span>
|
|
10542
10729
|
</button>
|
|
10543
|
-
<Show when={props.
|
|
10730
|
+
<Show when={props.editable}><div class={styles.actions}>
|
|
10731
|
+
<CopyButton value={props.value} />
|
|
10732
|
+
<Show
|
|
10733
|
+
when={props.itemsDeletable && props.activeQuery !== void 0}
|
|
10734
|
+
><DeleteItemButton
|
|
10735
|
+
activeQuery={props.activeQuery}
|
|
10736
|
+
dataPath={currentDataPath}
|
|
10737
|
+
/></Show>
|
|
10738
|
+
<Show
|
|
10739
|
+
when={type() === "array" && props.activeQuery !== void 0}
|
|
10740
|
+
><ClearArrayButton
|
|
10741
|
+
activeQuery={props.activeQuery}
|
|
10742
|
+
dataPath={currentDataPath}
|
|
10743
|
+
/></Show>
|
|
10744
|
+
</div></Show>
|
|
10544
10745
|
</div>
|
|
10545
10746
|
<Show when={expanded()}>
|
|
10546
10747
|
<Show when={subEntryPages().length === 1}><div class={styles.subEntry}><Key each={subEntries()} by={(item) => item.label}>{(entry) => {
|
|
@@ -10548,7 +10749,10 @@ function Explorer(props) {
|
|
|
10548
10749
|
defaultExpanded={props.defaultExpanded}
|
|
10549
10750
|
label={entry().label}
|
|
10550
10751
|
value={entry().value}
|
|
10551
|
-
|
|
10752
|
+
editable={props.editable}
|
|
10753
|
+
dataPath={[...currentDataPath, entry().label]}
|
|
10754
|
+
activeQuery={props.activeQuery}
|
|
10755
|
+
itemsDeletable={type() === "array" || type() === "Iterable" || type() === "object"}
|
|
10552
10756
|
/>;
|
|
10553
10757
|
}}</Key></div></Show>
|
|
10554
10758
|
<Show when={subEntryPages().length > 1}><div class={styles.subEntry}><Index each={subEntryPages()}>{(entries3, index) => <div><div class={styles.entry}>
|
|
@@ -10570,22 +10774,55 @@ function Explorer(props) {
|
|
|
10570
10774
|
defaultExpanded={props.defaultExpanded}
|
|
10571
10775
|
label={entry().label}
|
|
10572
10776
|
value={entry().value}
|
|
10573
|
-
|
|
10777
|
+
editable={props.editable}
|
|
10778
|
+
dataPath={[...currentDataPath, entry().label]}
|
|
10779
|
+
activeQuery={props.activeQuery}
|
|
10574
10780
|
/>}</Key></div></Show>
|
|
10575
10781
|
</div></div>}</Index></div></Show>
|
|
10576
10782
|
</Show>
|
|
10577
10783
|
</Show>
|
|
10578
|
-
<Show when={subEntryPages().length === 0}><div
|
|
10579
|
-
style={{
|
|
10580
|
-
"line-height": "1.125rem"
|
|
10581
|
-
}}
|
|
10582
|
-
>
|
|
10784
|
+
<Show when={subEntryPages().length === 0}><div class={styles.row}>
|
|
10583
10785
|
<span class={styles.label}>
|
|
10584
10786
|
{props.label}
|
|
10585
10787
|
{":"}
|
|
10586
10788
|
</span>
|
|
10587
|
-
|
|
10588
|
-
|
|
10789
|
+
<Show
|
|
10790
|
+
when={props.editable && props.activeQuery !== void 0 && (type() === "string" || type() === "number" || type() === "boolean")}
|
|
10791
|
+
fallback={<span class={styles.value}>{displayValue(props.value)}</span>}
|
|
10792
|
+
>
|
|
10793
|
+
<Show
|
|
10794
|
+
when={props.editable && props.activeQuery !== void 0 && (type() === "string" || type() === "number")}
|
|
10795
|
+
><input
|
|
10796
|
+
type={type() === "number" ? "number" : "text"}
|
|
10797
|
+
class={clsx(styles.value, styles.editableInput)}
|
|
10798
|
+
value={props.value}
|
|
10799
|
+
onChange={(changeEvent) => {
|
|
10800
|
+
const oldData = props.activeQuery.state.data;
|
|
10801
|
+
const newData = updateNestedDataByPath(
|
|
10802
|
+
oldData,
|
|
10803
|
+
currentDataPath,
|
|
10804
|
+
type() === "number" ? changeEvent.target.valueAsNumber : changeEvent.target.value
|
|
10805
|
+
);
|
|
10806
|
+
queryClient.setQueryData(props.activeQuery.queryKey, newData);
|
|
10807
|
+
}}
|
|
10808
|
+
/></Show>
|
|
10809
|
+
<Show when={type() === "boolean"}><span
|
|
10810
|
+
class={clsx(styles.value, styles.actions, styles.editableInput)}
|
|
10811
|
+
>
|
|
10812
|
+
<ToggleValueButton
|
|
10813
|
+
activeQuery={props.activeQuery}
|
|
10814
|
+
dataPath={currentDataPath}
|
|
10815
|
+
value={props.value}
|
|
10816
|
+
/>
|
|
10817
|
+
{displayValue(props.value)}
|
|
10818
|
+
</span></Show>
|
|
10819
|
+
</Show>
|
|
10820
|
+
<Show
|
|
10821
|
+
when={props.editable && props.itemsDeletable && props.activeQuery !== void 0}
|
|
10822
|
+
><DeleteItemButton
|
|
10823
|
+
activeQuery={props.activeQuery}
|
|
10824
|
+
dataPath={currentDataPath}
|
|
10825
|
+
/></Show>
|
|
10589
10826
|
</div></Show>
|
|
10590
10827
|
</div>;
|
|
10591
10828
|
}
|
|
@@ -10625,6 +10862,7 @@ var getStyles = () => {
|
|
|
10625
10862
|
align-items: center;
|
|
10626
10863
|
line-height: 1.125rem;
|
|
10627
10864
|
min-height: 1.125rem;
|
|
10865
|
+
gap: ${size2[2]};
|
|
10628
10866
|
`,
|
|
10629
10867
|
expanderButton: u`
|
|
10630
10868
|
cursor: pointer;
|
|
@@ -10662,8 +10900,32 @@ var getStyles = () => {
|
|
|
10662
10900
|
`,
|
|
10663
10901
|
value: u`
|
|
10664
10902
|
color: ${colors.purple[400]};
|
|
10903
|
+
flex-grow: 1;
|
|
10904
|
+
`,
|
|
10905
|
+
actions: u`
|
|
10906
|
+
display: inline-flex;
|
|
10907
|
+
gap: ${size2[2]};
|
|
10908
|
+
align-items: center;
|
|
10665
10909
|
`,
|
|
10666
|
-
|
|
10910
|
+
row: u`
|
|
10911
|
+
display: inline-flex;
|
|
10912
|
+
gap: ${size2[2]};
|
|
10913
|
+
width: 100%;
|
|
10914
|
+
margin-bottom: ${size2[0.5]};
|
|
10915
|
+
line-height: 1.125rem;
|
|
10916
|
+
align-items: center;
|
|
10917
|
+
`,
|
|
10918
|
+
editableInput: u`
|
|
10919
|
+
border: none;
|
|
10920
|
+
padding: ${size2[0.5]} ${size2[1]};
|
|
10921
|
+
flex-grow: 1;
|
|
10922
|
+
background-color: ${colors.gray[900]};
|
|
10923
|
+
|
|
10924
|
+
&:hover {
|
|
10925
|
+
background-color: ${colors.gray[800]};
|
|
10926
|
+
}
|
|
10927
|
+
`,
|
|
10928
|
+
actionButton: u`
|
|
10667
10929
|
background-color: transparent;
|
|
10668
10930
|
border: none;
|
|
10669
10931
|
display: inline-flex;
|
|
@@ -10674,11 +10936,18 @@ var getStyles = () => {
|
|
|
10674
10936
|
width: ${size2[3]};
|
|
10675
10937
|
height: ${size2[3]};
|
|
10676
10938
|
position: relative;
|
|
10677
|
-
left: ${size2[2]};
|
|
10678
10939
|
z-index: 1;
|
|
10679
10940
|
|
|
10680
|
-
&:hover svg
|
|
10681
|
-
|
|
10941
|
+
&:hover svg {
|
|
10942
|
+
.copier,
|
|
10943
|
+
.check,
|
|
10944
|
+
.list {
|
|
10945
|
+
stroke: ${colors.gray[500]} !important;
|
|
10946
|
+
}
|
|
10947
|
+
|
|
10948
|
+
.list-item {
|
|
10949
|
+
stroke: ${colors.gray[700]};
|
|
10950
|
+
}
|
|
10682
10951
|
}
|
|
10683
10952
|
|
|
10684
10953
|
&:focus-visible {
|
|
@@ -10690,17 +10959,6 @@ var getStyles = () => {
|
|
|
10690
10959
|
};
|
|
10691
10960
|
};
|
|
10692
10961
|
|
|
10693
|
-
// src/Context.ts
|
|
10694
|
-
var QueryDevtoolsContext = createContext({
|
|
10695
|
-
client: void 0,
|
|
10696
|
-
onlineManager: void 0,
|
|
10697
|
-
queryFlavor: "",
|
|
10698
|
-
version: ""
|
|
10699
|
-
});
|
|
10700
|
-
function useQueryDevtoolsContext() {
|
|
10701
|
-
return useContext(QueryDevtoolsContext);
|
|
10702
|
-
}
|
|
10703
|
-
|
|
10704
10962
|
// src/fonts.ts
|
|
10705
10963
|
var loadFonts = () => {
|
|
10706
10964
|
const link = document.createElement("link");
|
|
@@ -11628,7 +11886,8 @@ var QueryDetails = () => {
|
|
|
11628
11886
|
label="Data"
|
|
11629
11887
|
defaultExpanded={["Data"]}
|
|
11630
11888
|
value={activeQueryStateData()}
|
|
11631
|
-
|
|
11889
|
+
editable={true}
|
|
11890
|
+
activeQuery={activeQuery()}
|
|
11632
11891
|
/></div>
|
|
11633
11892
|
<div class={clsx(styles.detailsHeader, "tsqd-query-details-header")}>Query Explorer</div>
|
|
11634
11893
|
<div
|