@tanstack/query-devtools 5.21.5 → 5.24.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.
@@ -11,6 +11,7 @@ import {
11
11
  Switch,
12
12
  batch,
13
13
  children,
14
+ clearDelegatedEvents,
14
15
  convertRemToPixels,
15
16
  createComponent,
16
17
  createComputed,
@@ -49,7 +50,7 @@ import {
49
50
  use,
50
51
  useContext,
51
52
  useTransition
52
- } from "../chunk/AZNCIVVX.jsx";
53
+ } from "../chunk/LJVATCV2.jsx";
53
54
 
54
55
  // ../../node_modules/.pnpm/@tanstack+match-sorter-utils@8.11.8/node_modules/@tanstack/match-sorter-utils/build/lib/index.mjs
55
56
  var characterMap = {
@@ -9073,6 +9074,21 @@ function Settings() {
9073
9074
  />
9074
9075
  </svg>;
9075
9076
  }
9077
+ function PiPIcon() {
9078
+ return <svg
9079
+ width="24"
9080
+ height="24"
9081
+ viewBox="0 0 24 24"
9082
+ fill="none"
9083
+ xmlns="http://www.w3.org/2000/svg"
9084
+ ><path
9085
+ d="M16 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V8M11.5 12.5L17 7M17 7H12M17 7V12M6.2 21H8.8C9.9201 21 10.4802 21 10.908 20.782C11.2843 20.5903 11.5903 20.2843 11.782 19.908C12 19.4802 12 18.9201 12 17.8V15.2C12 14.0799 12 13.5198 11.782 13.092C11.5903 12.7157 11.2843 12.4097 10.908 12.218C10.4802 12 9.92011 12 8.8 12H6.2C5.0799 12 4.51984 12 4.09202 12.218C3.71569 12.4097 3.40973 12.7157 3.21799 13.092C3 13.5198 3 14.0799 3 15.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z"
9086
+ stroke="currentColor"
9087
+ stroke-width="2"
9088
+ stroke-linecap="round"
9089
+ stroke-linejoin="round"
9090
+ /></svg>;
9091
+ }
9076
9092
  function Copier() {
9077
9093
  return <svg
9078
9094
  width="24"
@@ -10435,6 +10451,133 @@ var [selectedMutationId, setSelectedMutationId] = createSignal(
10435
10451
  null
10436
10452
  );
10437
10453
  var [panelWidth, setPanelWidth] = createSignal(0);
10454
+ var PiPContext = createContext(
10455
+ void 0
10456
+ );
10457
+ var PiPProvider = (props) => {
10458
+ const [pipWindow, setPipWindow] = createSignal(null);
10459
+ const closePipWindow = () => {
10460
+ const w = pipWindow();
10461
+ if (w != null) {
10462
+ w.close();
10463
+ setPipWindow(null);
10464
+ }
10465
+ };
10466
+ const requestPipWindow = async (width, height) => {
10467
+ if (pipWindow() != null) {
10468
+ return;
10469
+ }
10470
+ const pip = window.open(
10471
+ "",
10472
+ "TSQD-Devtools-Panel",
10473
+ `width=${width},height=${height},popup`
10474
+ );
10475
+ if (!pip) {
10476
+ throw new Error(
10477
+ "Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode."
10478
+ );
10479
+ }
10480
+ pip.document.head.innerHTML = "";
10481
+ pip.document.body.innerHTML = "";
10482
+ clearDelegatedEvents(pip.document);
10483
+ pip.document.title = "TanStack Query Devtools";
10484
+ pip.document.body.style.margin = "0";
10485
+ pip.addEventListener("pagehide", () => {
10486
+ props.setLocalStore("pip_open", "false");
10487
+ setPipWindow(null);
10488
+ });
10489
+ [...document.styleSheets].forEach((styleSheet) => {
10490
+ try {
10491
+ const cssRules = [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
10492
+ const style2 = document.createElement("style");
10493
+ const style_node = styleSheet.ownerNode;
10494
+ let style_id = "";
10495
+ if (style_node && "id" in style_node) {
10496
+ style_id = style_node.id;
10497
+ }
10498
+ if (style_id) {
10499
+ style2.setAttribute("id", style_id);
10500
+ }
10501
+ style2.textContent = cssRules;
10502
+ pip.document.head.appendChild(style2);
10503
+ } catch (e2) {
10504
+ const link = document.createElement("link");
10505
+ if (styleSheet.href == null) {
10506
+ return;
10507
+ }
10508
+ link.rel = "stylesheet";
10509
+ link.type = styleSheet.type;
10510
+ link.media = styleSheet.media.toString();
10511
+ link.href = styleSheet.href;
10512
+ pip.document.head.appendChild(link);
10513
+ }
10514
+ });
10515
+ delegateEvents(
10516
+ [
10517
+ "focusin",
10518
+ "focusout",
10519
+ "pointermove",
10520
+ "keydown",
10521
+ "pointerdown",
10522
+ "pointerup",
10523
+ "click",
10524
+ "mousedown",
10525
+ "input"
10526
+ ],
10527
+ pip.document
10528
+ );
10529
+ props.setLocalStore("pip_open", "true");
10530
+ setPipWindow(pip);
10531
+ };
10532
+ createEffect(() => {
10533
+ const pip_open = props.localStore.pip_open ?? "false";
10534
+ if (pip_open === "true") {
10535
+ requestPipWindow(
10536
+ Number(window.innerWidth),
10537
+ Number(props.localStore.height || DEFAULT_HEIGHT)
10538
+ );
10539
+ }
10540
+ });
10541
+ createEffect(() => {
10542
+ const gooberStyles = document.getElementById("_goober");
10543
+ const w = pipWindow();
10544
+ if (gooberStyles && w) {
10545
+ const observer = new MutationObserver(() => {
10546
+ const pip_style = w.document.getElementById("_goober");
10547
+ if (pip_style) {
10548
+ pip_style.textContent = gooberStyles.textContent;
10549
+ }
10550
+ });
10551
+ observer.observe(gooberStyles, {
10552
+ childList: true,
10553
+ // observe direct children
10554
+ subtree: true,
10555
+ // and lower descendants too
10556
+ characterDataOldValue: true
10557
+ // pass old data to callback
10558
+ });
10559
+ onCleanup(() => {
10560
+ observer.disconnect();
10561
+ });
10562
+ }
10563
+ });
10564
+ const value = createMemo(() => ({
10565
+ pipWindow: pipWindow(),
10566
+ requestPipWindow,
10567
+ closePipWindow
10568
+ }));
10569
+ return <PiPContext.Provider value={value}>{props.children}</PiPContext.Provider>;
10570
+ };
10571
+ var usePiPWindow = () => {
10572
+ const context = createMemo(() => {
10573
+ const ctx = useContext(PiPContext);
10574
+ if (!ctx) {
10575
+ throw new Error("usePiPWindow must be used within a PiPProvider");
10576
+ }
10577
+ return ctx();
10578
+ });
10579
+ return context;
10580
+ };
10438
10581
  var DevtoolsComponent = (props) => {
10439
10582
  const [localStore, setLocalStore] = createLocalStorage({
10440
10583
  prefix: "TanstackQueryDevtools"
@@ -10446,7 +10589,7 @@ var DevtoolsComponent = (props) => {
10446
10589
  return preference;
10447
10590
  return colorScheme();
10448
10591
  });
10449
- return <QueryDevtoolsContext.Provider value={props}><ThemeContext.Provider value={theme}><Devtools localStore={localStore} setLocalStore={setLocalStore} /></ThemeContext.Provider></QueryDevtoolsContext.Provider>;
10592
+ return <QueryDevtoolsContext.Provider value={props}><PiPProvider localStore={localStore} setLocalStore={setLocalStore}><ThemeContext.Provider value={theme}><Devtools localStore={localStore} setLocalStore={setLocalStore} /></ThemeContext.Provider></PiPProvider></QueryDevtoolsContext.Provider>;
10450
10593
  };
10451
10594
  var Devtools_default = DevtoolsComponent;
10452
10595
  var Devtools = (props) => {
@@ -10454,6 +10597,7 @@ var Devtools = (props) => {
10454
10597
  const styles = createMemo(() => {
10455
10598
  return theme() === "dark" ? darkStyles2 : lightStyles2;
10456
10599
  });
10600
+ const pip = usePiPWindow();
10457
10601
  const buttonPosition = createMemo(() => {
10458
10602
  return useQueryDevtoolsContext().buttonPosition || BUTTON_POSITION;
10459
10603
  });
@@ -10490,58 +10634,123 @@ var Devtools = (props) => {
10490
10634
  window.removeEventListener("focus", onFocus);
10491
10635
  });
10492
10636
  });
10493
- return <div
10494
- class={clsx(
10495
- u`
10496
- & .tsqd-panel-transition-exit-active,
10497
- & .tsqd-panel-transition-enter-active {
10498
- transition:
10499
- opacity 0.3s,
10500
- transform 0.3s;
10501
- }
10502
-
10503
- & .tsqd-panel-transition-exit-to,
10504
- & .tsqd-panel-transition-enter {
10505
- ${position() === "top" || position() === "bottom" ? `transform: translateY(var(--tsqd-panel-height));` : `transform: translateX(var(--tsqd-panel-width));`}
10506
- }
10507
-
10508
- & .tsqd-button-transition-exit-active,
10509
- & .tsqd-button-transition-enter-active {
10510
- transition:
10511
- opacity 0.3s,
10512
- transform 0.3s;
10513
- opacity: 1;
10514
- }
10515
-
10516
- & .tsqd-button-transition-exit-to,
10517
- & .tsqd-button-transition-enter {
10518
- transform: ${buttonPosition() === "relative" ? `none;` : buttonPosition() === "top-left" ? `translateX(-72px);` : buttonPosition() === "top-right" ? `translateX(72px);` : `translateY(72px);`};
10519
- opacity: 0;
10520
- }
10521
- `,
10522
- "tsqd-transitions-container"
10523
- )}
10524
- ref={transitionsContainerRef}
10525
- >
10526
- <TransitionGroup name="tsqd-panel-transition"><Show when={isOpen()}><DevtoolsPanel
10637
+ const pip_open = createMemo(
10638
+ () => props.localStore.pip_open ?? "false"
10639
+ );
10640
+ return <>
10641
+ <Show when={pip().pipWindow && pip_open() == "true"}><Portal mount={pip().pipWindow?.document.body}><PiPPanel><ContentView
10527
10642
  localStore={props.localStore}
10528
10643
  setLocalStore={props.setLocalStore}
10529
- /></Show></TransitionGroup>
10530
- <TransitionGroup name="tsqd-button-transition"><Show when={!isOpen()}><div
10644
+ /></PiPPanel></Portal></Show>
10645
+ <div
10531
10646
  class={clsx(
10532
- styles().devtoolsBtn,
10533
- styles()[`devtoolsBtn-position-${buttonPosition()}`],
10534
- "tsqd-open-btn-container"
10647
+ u`
10648
+ & .tsqd-panel-transition-exit-active,
10649
+ & .tsqd-panel-transition-enter-active {
10650
+ transition:
10651
+ opacity 0.3s,
10652
+ transform 0.3s;
10653
+ }
10654
+
10655
+ & .tsqd-panel-transition-exit-to,
10656
+ & .tsqd-panel-transition-enter {
10657
+ ${position() === "top" || position() === "bottom" ? `transform: translateY(var(--tsqd-panel-height));` : `transform: translateX(var(--tsqd-panel-width));`}
10658
+ }
10659
+
10660
+ & .tsqd-button-transition-exit-active,
10661
+ & .tsqd-button-transition-enter-active {
10662
+ transition:
10663
+ opacity 0.3s,
10664
+ transform 0.3s;
10665
+ opacity: 1;
10666
+ }
10667
+
10668
+ & .tsqd-button-transition-exit-to,
10669
+ & .tsqd-button-transition-enter {
10670
+ transform: ${buttonPosition() === "relative" ? `none;` : buttonPosition() === "top-left" ? `translateX(-72px);` : buttonPosition() === "top-right" ? `translateX(72px);` : `translateY(72px);`};
10671
+ opacity: 0;
10672
+ }
10673
+ `,
10674
+ "tsqd-transitions-container"
10535
10675
  )}
10676
+ ref={transitionsContainerRef}
10536
10677
  >
10537
- <div aria-hidden="true"><TanstackLogo /></div>
10538
- <button
10539
- aria-label="Open Tanstack query devtools"
10540
- onClick={() => props.setLocalStore("open", "true")}
10541
- class="tsqd-open-btn"
10542
- ><TanstackLogo /></button>
10543
- </div></Show></TransitionGroup>
10544
- </div>;
10678
+ <TransitionGroup name="tsqd-panel-transition"><Show when={isOpen() && !pip().pipWindow && pip_open() == "false"}><DevtoolsPanel
10679
+ localStore={props.localStore}
10680
+ setLocalStore={props.setLocalStore}
10681
+ /></Show></TransitionGroup>
10682
+ <TransitionGroup name="tsqd-button-transition"><Show when={!isOpen()}><div
10683
+ class={clsx(
10684
+ styles().devtoolsBtn,
10685
+ styles()[`devtoolsBtn-position-${buttonPosition()}`],
10686
+ "tsqd-open-btn-container"
10687
+ )}
10688
+ >
10689
+ <div aria-hidden="true"><TanstackLogo /></div>
10690
+ <button
10691
+ aria-label="Open Tanstack query devtools"
10692
+ onClick={() => props.setLocalStore("open", "true")}
10693
+ class="tsqd-open-btn"
10694
+ ><TanstackLogo /></button>
10695
+ </div></Show></TransitionGroup>
10696
+ </div>
10697
+ </>;
10698
+ };
10699
+ var PiPPanel = (props) => {
10700
+ const pip = usePiPWindow();
10701
+ const theme = useTheme();
10702
+ const styles = createMemo(() => {
10703
+ return theme() === "dark" ? darkStyles2 : lightStyles2;
10704
+ });
10705
+ const getPanelDynamicStyles = () => {
10706
+ const { colors } = tokens;
10707
+ const t2 = (light, dark) => theme() === "dark" ? dark : light;
10708
+ if (panelWidth() < secondBreakpoint) {
10709
+ return u`
10710
+ flex-direction: column;
10711
+ background-color: ${t2(colors.gray[300], colors.gray[600])};
10712
+ `;
10713
+ }
10714
+ return u`
10715
+ flex-direction: row;
10716
+ background-color: ${t2(colors.gray[200], colors.darkGray[900])};
10717
+ `;
10718
+ };
10719
+ createEffect(() => {
10720
+ const win = pip().pipWindow;
10721
+ const resizeCB = () => {
10722
+ if (!win)
10723
+ return;
10724
+ setPanelWidth(win.innerWidth);
10725
+ };
10726
+ if (win) {
10727
+ win.addEventListener("resize", resizeCB);
10728
+ resizeCB();
10729
+ }
10730
+ onCleanup(() => {
10731
+ if (win) {
10732
+ win.removeEventListener("resize", resizeCB);
10733
+ }
10734
+ });
10735
+ });
10736
+ return <div
10737
+ style={{
10738
+ "--tsqd-font-size": "16px",
10739
+ "max-height": "100vh",
10740
+ height: "100vh",
10741
+ width: "100vw"
10742
+ }}
10743
+ class={clsx(
10744
+ styles().panel,
10745
+ getPanelDynamicStyles(),
10746
+ {
10747
+ [u`
10748
+ min-width: min-content;
10749
+ `]: panelWidth() < thirdBreakpoint
10750
+ },
10751
+ "tsqd-main-panel"
10752
+ )}
10753
+ >{props.children}</div>;
10545
10754
  };
10546
10755
  var DevtoolsPanel = (props) => {
10547
10756
  const theme = useTheme();
@@ -10695,6 +10904,7 @@ var ContentView = (props) => {
10695
10904
  const styles = createMemo(() => {
10696
10905
  return theme() === "dark" ? darkStyles2 : lightStyles2;
10697
10906
  });
10907
+ const pip = usePiPWindow();
10698
10908
  const [selectedView, setSelectedView] = createSignal(
10699
10909
  "queries"
10700
10910
  );
@@ -10793,7 +11003,11 @@ var ContentView = (props) => {
10793
11003
  <div class={styles().logoAndToggleContainer}>
10794
11004
  <button
10795
11005
  class={clsx(styles().logo, "tsqd-text-logo-container")}
10796
- onClick={() => props.setLocalStore("open", "false")}
11006
+ onClick={() => {
11007
+ if (!pip().pipWindow) {
11008
+ props.setLocalStore("open", "false");
11009
+ }
11010
+ }}
10797
11011
  aria-label="Close Tanstack query devtools"
10798
11012
  >
10799
11013
  <span
@@ -10854,7 +11068,7 @@ var ContentView = (props) => {
10854
11068
  props.setLocalStore("mutationFilter", e2.currentTarget.value);
10855
11069
  }
10856
11070
  }}
10857
- class="tsqd-query-filter-textfield"
11071
+ class={clsx("tsqd-query-filter-textfield")}
10858
11072
  name="tsqd-query-filter-input"
10859
11073
  value={selectedView() === "queries" ? props.localStore.filter || "" : props.localStore.mutationFilter || ""}
10860
11074
  />
@@ -10953,6 +11167,21 @@ var ContentView = (props) => {
10953
11167
  aria-pressed={offline()}
10954
11168
  title={`${offline() ? "Unset offline mocking behavior" : "Mock offline behavior"}`}
10955
11169
  >{offline() ? <Offline /> : <Wifi />}</button>
11170
+ <Show when={!pip().pipWindow}><button
11171
+ onClick={() => {
11172
+ pip().requestPipWindow(
11173
+ Number(window.innerWidth),
11174
+ Number(props.localStore.height ?? 500)
11175
+ );
11176
+ }}
11177
+ class={clsx(
11178
+ styles().actionsBtn,
11179
+ "tsqd-actions-btn",
11180
+ "tsqd-action-open-pip"
11181
+ )}
11182
+ aria-label="Open in picture-in-picture mode"
11183
+ title="Open in picture-in-picture mode"
11184
+ ><PiPIcon /></button></Show>
10956
11185
  <index$f.Root gutter={4}>
10957
11186
  <index$f.Trigger
10958
11187
  class={clsx(
@@ -10963,6 +11192,7 @@ var ContentView = (props) => {
10963
11192
  ><Settings /></index$f.Trigger>
10964
11193
  <index$f.Portal
10965
11194
  ref={(el) => setComputedVariables(el)}
11195
+ mount={pip().pipWindow ? pip().pipWindow.document.body : document.body}
10966
11196
  ><index$f.Content
10967
11197
  class={clsx(styles().settingsMenu, "tsqd-settings-menu")}
10968
11198
  >
@@ -10985,6 +11215,7 @@ var ContentView = (props) => {
10985
11215
  </index$f.SubTrigger>
10986
11216
  <index$f.Portal
10987
11217
  ref={(el) => setComputedVariables(el)}
11218
+ mount={pip().pipWindow ? pip().pipWindow.document.body : document.body}
10988
11219
  ><index$f.SubContent
10989
11220
  class={clsx(
10990
11221
  styles().settingsMenu,
@@ -11062,6 +11293,7 @@ var ContentView = (props) => {
11062
11293
  </index$f.SubTrigger>
11063
11294
  <index$f.Portal
11064
11295
  ref={(el) => setComputedVariables(el)}
11296
+ mount={pip().pipWindow ? pip().pipWindow.document.body : document.body}
11065
11297
  ><index$f.SubContent
11066
11298
  class={clsx(
11067
11299
  styles().settingsMenu,
@@ -12414,8 +12646,8 @@ var stylesFactory2 = (theme) => {
12414
12646
  gap: ${tokens.size[2]};
12415
12647
  & > button {
12416
12648
  cursor: pointer;
12417
- padding: ${tokens.size[0.5]} ${tokens.size[2]};
12418
- padding-right: ${tokens.size[1.5]};
12649
+ padding: ${tokens.size[0.5]} ${tokens.size[1.5]} ${tokens.size[0.5]}
12650
+ ${tokens.size[2]};
12419
12651
  border-radius: ${tokens.border.radius.sm};
12420
12652
  background-color: ${t2(colors.gray[100], colors.darkGray[400])};
12421
12653
  border: 1px solid ${t2(colors.gray[300], colors.darkGray[200])};