@tanstack/query-devtools 5.21.3 → 5.23.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.
@@ -9073,6 +9073,21 @@ function Settings() {
9073
9073
  />
9074
9074
  </svg>;
9075
9075
  }
9076
+ function PiPIcon() {
9077
+ return <svg
9078
+ width="24"
9079
+ height="24"
9080
+ viewBox="0 0 24 24"
9081
+ fill="none"
9082
+ xmlns="http://www.w3.org/2000/svg"
9083
+ ><path
9084
+ 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"
9085
+ stroke="currentColor"
9086
+ stroke-width="2"
9087
+ stroke-linecap="round"
9088
+ stroke-linejoin="round"
9089
+ /></svg>;
9090
+ }
9076
9091
  function Copier() {
9077
9092
  return <svg
9078
9093
  width="24"
@@ -10291,7 +10306,8 @@ var stylesFactory = (theme) => {
10291
10306
  entry: u`
10292
10307
  & * {
10293
10308
  font-size: ${font.size.xs};
10294
- font-family: 'Menlo', 'Fira Code', monospace;
10309
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
10310
+ 'Liberation Mono', 'Courier New', monospace;
10295
10311
  }
10296
10312
  position: relative;
10297
10313
  outline: none;
@@ -10435,6 +10451,124 @@ 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("", "", `width=${width},height=${height},popup`);
10471
+ if (!pip) {
10472
+ throw new Error(
10473
+ "Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode."
10474
+ );
10475
+ }
10476
+ pip.document.title = "TanStack Query Devtools";
10477
+ pip.document.body.style.margin = "0";
10478
+ pip.addEventListener("pagehide", () => {
10479
+ setPipWindow(null);
10480
+ });
10481
+ [...document.styleSheets].forEach((styleSheet) => {
10482
+ try {
10483
+ const cssRules = [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
10484
+ const style2 = document.createElement("style");
10485
+ const style_node = styleSheet.ownerNode;
10486
+ let style_id = "";
10487
+ if (style_node && "id" in style_node) {
10488
+ style_id = style_node.id;
10489
+ }
10490
+ if (style_id) {
10491
+ style2.setAttribute("id", style_id);
10492
+ }
10493
+ style2.textContent = cssRules;
10494
+ pip.document.head.appendChild(style2);
10495
+ } catch (e2) {
10496
+ const link = document.createElement("link");
10497
+ if (styleSheet.href == null) {
10498
+ return;
10499
+ }
10500
+ link.rel = "stylesheet";
10501
+ link.type = styleSheet.type;
10502
+ link.media = styleSheet.media.toString();
10503
+ link.href = styleSheet.href;
10504
+ pip.document.head.appendChild(link);
10505
+ }
10506
+ });
10507
+ delegateEvents(
10508
+ [
10509
+ "focusin",
10510
+ "focusout",
10511
+ "pointermove",
10512
+ "keydown",
10513
+ "pointerdown",
10514
+ "pointerup",
10515
+ "click",
10516
+ "mousedown",
10517
+ "input"
10518
+ ],
10519
+ pip.document
10520
+ );
10521
+ setPipWindow(pip);
10522
+ };
10523
+ createEffect(() => {
10524
+ const closePipWindowOnUnload = () => {
10525
+ closePipWindow();
10526
+ };
10527
+ window.addEventListener("beforeunload", closePipWindowOnUnload);
10528
+ onCleanup(() => {
10529
+ window.removeEventListener("beforeunload", closePipWindowOnUnload);
10530
+ });
10531
+ });
10532
+ createEffect(() => {
10533
+ const gooberStyles = document.getElementById("_goober");
10534
+ const w = pipWindow();
10535
+ if (gooberStyles && w) {
10536
+ const observer = new MutationObserver(() => {
10537
+ const pip_style = w.document.getElementById("_goober");
10538
+ if (pip_style) {
10539
+ pip_style.textContent = gooberStyles.textContent;
10540
+ }
10541
+ });
10542
+ observer.observe(gooberStyles, {
10543
+ childList: true,
10544
+ // observe direct children
10545
+ subtree: true,
10546
+ // and lower descendants too
10547
+ characterDataOldValue: true
10548
+ // pass old data to callback
10549
+ });
10550
+ onCleanup(() => {
10551
+ observer.disconnect();
10552
+ });
10553
+ }
10554
+ });
10555
+ const value = createMemo(() => ({
10556
+ pipWindow: pipWindow(),
10557
+ requestPipWindow,
10558
+ closePipWindow
10559
+ }));
10560
+ return <PiPContext.Provider value={value}>{props.children}</PiPContext.Provider>;
10561
+ };
10562
+ var usePiPWindow = () => {
10563
+ const context = createMemo(() => {
10564
+ const ctx = useContext(PiPContext);
10565
+ if (!ctx) {
10566
+ throw new Error("usePiPWindow must be used within a PiPProvider");
10567
+ }
10568
+ return ctx();
10569
+ });
10570
+ return context;
10571
+ };
10438
10572
  var DevtoolsComponent = (props) => {
10439
10573
  const [localStore, setLocalStore] = createLocalStorage({
10440
10574
  prefix: "TanstackQueryDevtools"
@@ -10446,7 +10580,7 @@ var DevtoolsComponent = (props) => {
10446
10580
  return preference;
10447
10581
  return colorScheme();
10448
10582
  });
10449
- return <QueryDevtoolsContext.Provider value={props}><ThemeContext.Provider value={theme}><Devtools localStore={localStore} setLocalStore={setLocalStore} /></ThemeContext.Provider></QueryDevtoolsContext.Provider>;
10583
+ return <QueryDevtoolsContext.Provider value={props}><PiPProvider><ThemeContext.Provider value={theme}><Devtools localStore={localStore} setLocalStore={setLocalStore} /></ThemeContext.Provider></PiPProvider></QueryDevtoolsContext.Provider>;
10450
10584
  };
10451
10585
  var Devtools_default = DevtoolsComponent;
10452
10586
  var Devtools = (props) => {
@@ -10454,6 +10588,7 @@ var Devtools = (props) => {
10454
10588
  const styles = createMemo(() => {
10455
10589
  return theme() === "dark" ? darkStyles2 : lightStyles2;
10456
10590
  });
10591
+ const pip = usePiPWindow();
10457
10592
  const buttonPosition = createMemo(() => {
10458
10593
  return useQueryDevtoolsContext().buttonPosition || BUTTON_POSITION;
10459
10594
  });
@@ -10490,56 +10625,119 @@ var Devtools = (props) => {
10490
10625
  window.removeEventListener("focus", onFocus);
10491
10626
  });
10492
10627
  });
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
10628
+ return <>
10629
+ <Show when={pip().pipWindow}><Portal mount={pip().pipWindow?.document.body}><PiPPanel><ContentView
10527
10630
  localStore={props.localStore}
10528
10631
  setLocalStore={props.setLocalStore}
10529
- /></Show></TransitionGroup>
10530
- <TransitionGroup name="tsqd-button-transition"><Show when={!isOpen()}><div
10632
+ /></PiPPanel></Portal></Show>
10633
+ <div
10531
10634
  class={clsx(
10532
- styles().devtoolsBtn,
10533
- styles()[`devtoolsBtn-position-${buttonPosition()}`]
10635
+ u`
10636
+ & .tsqd-panel-transition-exit-active,
10637
+ & .tsqd-panel-transition-enter-active {
10638
+ transition:
10639
+ opacity 0.3s,
10640
+ transform 0.3s;
10641
+ }
10642
+
10643
+ & .tsqd-panel-transition-exit-to,
10644
+ & .tsqd-panel-transition-enter {
10645
+ ${position() === "top" || position() === "bottom" ? `transform: translateY(var(--tsqd-panel-height));` : `transform: translateX(var(--tsqd-panel-width));`}
10646
+ }
10647
+
10648
+ & .tsqd-button-transition-exit-active,
10649
+ & .tsqd-button-transition-enter-active {
10650
+ transition:
10651
+ opacity 0.3s,
10652
+ transform 0.3s;
10653
+ opacity: 1;
10654
+ }
10655
+
10656
+ & .tsqd-button-transition-exit-to,
10657
+ & .tsqd-button-transition-enter {
10658
+ transform: ${buttonPosition() === "relative" ? `none;` : buttonPosition() === "top-left" ? `translateX(-72px);` : buttonPosition() === "top-right" ? `translateX(72px);` : `translateY(72px);`};
10659
+ opacity: 0;
10660
+ }
10661
+ `,
10662
+ "tsqd-transitions-container"
10534
10663
  )}
10664
+ ref={transitionsContainerRef}
10535
10665
  >
10536
- <div aria-hidden="true"><TanstackLogo /></div>
10537
- <button
10538
- aria-label="Open Tanstack query devtools"
10539
- onClick={() => props.setLocalStore("open", "true")}
10540
- ><TanstackLogo /></button>
10541
- </div></Show></TransitionGroup>
10542
- </div>;
10666
+ <TransitionGroup name="tsqd-panel-transition"><Show when={isOpen() && !pip().pipWindow}><DevtoolsPanel
10667
+ localStore={props.localStore}
10668
+ setLocalStore={props.setLocalStore}
10669
+ /></Show></TransitionGroup>
10670
+ <TransitionGroup name="tsqd-button-transition"><Show when={!isOpen()}><div
10671
+ class={clsx(
10672
+ styles().devtoolsBtn,
10673
+ styles()[`devtoolsBtn-position-${buttonPosition()}`],
10674
+ "tsqd-open-btn-container"
10675
+ )}
10676
+ >
10677
+ <div aria-hidden="true"><TanstackLogo /></div>
10678
+ <button
10679
+ aria-label="Open Tanstack query devtools"
10680
+ onClick={() => props.setLocalStore("open", "true")}
10681
+ class="tsqd-open-btn"
10682
+ ><TanstackLogo /></button>
10683
+ </div></Show></TransitionGroup>
10684
+ </div>
10685
+ </>;
10686
+ };
10687
+ var PiPPanel = (props) => {
10688
+ const pip = usePiPWindow();
10689
+ const theme = useTheme();
10690
+ const styles = createMemo(() => {
10691
+ return theme() === "dark" ? darkStyles2 : lightStyles2;
10692
+ });
10693
+ const getPanelDynamicStyles = () => {
10694
+ const { colors } = tokens;
10695
+ const t2 = (light, dark) => theme() === "dark" ? dark : light;
10696
+ if (panelWidth() < secondBreakpoint) {
10697
+ return u`
10698
+ flex-direction: column;
10699
+ background-color: ${t2(colors.gray[300], colors.gray[600])};
10700
+ `;
10701
+ }
10702
+ return u`
10703
+ flex-direction: row;
10704
+ background-color: ${t2(colors.gray[200], colors.darkGray[900])};
10705
+ `;
10706
+ };
10707
+ createEffect(() => {
10708
+ const win = pip().pipWindow;
10709
+ const resizeCB = () => {
10710
+ if (!win)
10711
+ return;
10712
+ setPanelWidth(win.innerWidth);
10713
+ };
10714
+ if (win) {
10715
+ win.addEventListener("resize", resizeCB);
10716
+ }
10717
+ onCleanup(() => {
10718
+ if (win) {
10719
+ win.removeEventListener("resize", resizeCB);
10720
+ }
10721
+ });
10722
+ });
10723
+ return <div
10724
+ style={{
10725
+ "--tsqd-font-size": "16px",
10726
+ "max-height": "100vh",
10727
+ height: "100vh",
10728
+ width: "100vw"
10729
+ }}
10730
+ class={clsx(
10731
+ styles().panel,
10732
+ getPanelDynamicStyles(),
10733
+ {
10734
+ [u`
10735
+ min-width: min-content;
10736
+ `]: panelWidth() < thirdBreakpoint
10737
+ },
10738
+ "tsqd-main-panel"
10739
+ )}
10740
+ >{props.children}</div>;
10543
10741
  };
10544
10742
  var DevtoolsPanel = (props) => {
10545
10743
  const theme = useTheme();
@@ -10693,6 +10891,7 @@ var ContentView = (props) => {
10693
10891
  const styles = createMemo(() => {
10694
10892
  return theme() === "dark" ? darkStyles2 : lightStyles2;
10695
10893
  });
10894
+ const pip = usePiPWindow();
10696
10895
  const [selectedView, setSelectedView] = createSignal(
10697
10896
  "queries"
10698
10897
  );
@@ -10791,7 +10990,11 @@ var ContentView = (props) => {
10791
10990
  <div class={styles().logoAndToggleContainer}>
10792
10991
  <button
10793
10992
  class={clsx(styles().logo, "tsqd-text-logo-container")}
10794
- onClick={() => props.setLocalStore("open", "false")}
10993
+ onClick={() => {
10994
+ if (!pip().pipWindow) {
10995
+ props.setLocalStore("open", "false");
10996
+ }
10997
+ }}
10795
10998
  aria-label="Close Tanstack query devtools"
10796
10999
  >
10797
11000
  <span
@@ -10852,7 +11055,7 @@ var ContentView = (props) => {
10852
11055
  props.setLocalStore("mutationFilter", e2.currentTarget.value);
10853
11056
  }
10854
11057
  }}
10855
- class="tsqd-query-filter-textfield"
11058
+ class={clsx("tsqd-query-filter-textfield")}
10856
11059
  name="tsqd-query-filter-input"
10857
11060
  value={selectedView() === "queries" ? props.localStore.filter || "" : props.localStore.mutationFilter || ""}
10858
11061
  />
@@ -10951,6 +11154,21 @@ var ContentView = (props) => {
10951
11154
  aria-pressed={offline()}
10952
11155
  title={`${offline() ? "Unset offline mocking behavior" : "Mock offline behavior"}`}
10953
11156
  >{offline() ? <Offline /> : <Wifi />}</button>
11157
+ <Show when={!pip().pipWindow}><button
11158
+ onClick={() => {
11159
+ pip().requestPipWindow(
11160
+ Number(window.innerWidth),
11161
+ Number(props.localStore.height ?? 500)
11162
+ );
11163
+ }}
11164
+ class={clsx(
11165
+ styles().actionsBtn,
11166
+ "tsqd-actions-btn",
11167
+ "tsqd-action-open-pip"
11168
+ )}
11169
+ aria-label="Open in picture-in-picture mode"
11170
+ title="Open in picture-in-picture mode"
11171
+ ><PiPIcon /></button></Show>
10954
11172
  <index$f.Root gutter={4}>
10955
11173
  <index$f.Trigger
10956
11174
  class={clsx(
@@ -10961,6 +11179,7 @@ var ContentView = (props) => {
10961
11179
  ><Settings /></index$f.Trigger>
10962
11180
  <index$f.Portal
10963
11181
  ref={(el) => setComputedVariables(el)}
11182
+ mount={pip().pipWindow ? pip().pipWindow.document.body : document.body}
10964
11183
  ><index$f.Content
10965
11184
  class={clsx(styles().settingsMenu, "tsqd-settings-menu")}
10966
11185
  >
@@ -10983,6 +11202,7 @@ var ContentView = (props) => {
10983
11202
  </index$f.SubTrigger>
10984
11203
  <index$f.Portal
10985
11204
  ref={(el) => setComputedVariables(el)}
11205
+ mount={pip().pipWindow ? pip().pipWindow.document.body : document.body}
10986
11206
  ><index$f.SubContent
10987
11207
  class={clsx(
10988
11208
  styles().settingsMenu,
@@ -11060,6 +11280,7 @@ var ContentView = (props) => {
11060
11280
  </index$f.SubTrigger>
11061
11281
  <index$f.Portal
11062
11282
  ref={(el) => setComputedVariables(el)}
11283
+ mount={pip().pipWindow ? pip().pipWindow.document.body : document.body}
11063
11284
  ><index$f.SubContent
11064
11285
  class={clsx(
11065
11286
  styles().settingsMenu,
@@ -12232,7 +12453,7 @@ var stylesFactory2 = (theme) => {
12232
12453
  display: flex;
12233
12454
  flex-direction: column;
12234
12455
  & * {
12235
- font-family: 'Inter', sans-serif;
12456
+ font-family: ui-sans-serif, Inter, system-ui, sans-serif, sans-serif;
12236
12457
  }
12237
12458
  `,
12238
12459
  dragHandle: u`
@@ -12412,8 +12633,8 @@ var stylesFactory2 = (theme) => {
12412
12633
  gap: ${tokens.size[2]};
12413
12634
  & > button {
12414
12635
  cursor: pointer;
12415
- padding: ${tokens.size[0.5]} ${tokens.size[2]};
12416
- padding-right: ${tokens.size[1.5]};
12636
+ padding: ${tokens.size[0.5]} ${tokens.size[1.5]} ${tokens.size[0.5]}
12637
+ ${tokens.size[2]};
12417
12638
  border-radius: ${tokens.border.radius.sm};
12418
12639
  background-color: ${t2(colors.gray[100], colors.darkGray[400])};
12419
12640
  border: 1px solid ${t2(colors.gray[300], colors.darkGray[200])};
@@ -12597,7 +12818,8 @@ var stylesFactory2 = (theme) => {
12597
12818
  min-height: ${tokens.size[6]};
12598
12819
  flex: 1;
12599
12820
  padding: ${tokens.size[1]} ${tokens.size[2]};
12600
- font-family: 'Menlo', 'Fira Code', monospace;
12821
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
12822
+ 'Liberation Mono', 'Courier New', monospace;
12601
12823
  border-bottom: 1px solid ${t2(colors.gray[300], colors.darkGray[400])};
12602
12824
  text-align: left;
12603
12825
  text-overflow: clip;
@@ -12622,7 +12844,7 @@ var stylesFactory2 = (theme) => {
12622
12844
  flex: 1 1 700px;
12623
12845
  background-color: ${t2(colors.gray[50], colors.darkGray[700])};
12624
12846
  color: ${t2(colors.gray[700], colors.gray[300])};
12625
- font-family: 'Inter', sans-serif;
12847
+ font-family: ui-sans-serif, Inter, system-ui, sans-serif, sans-serif;
12626
12848
  display: flex;
12627
12849
  flex-direction: column;
12628
12850
  overflow-y: auto;
@@ -12630,7 +12852,7 @@ var stylesFactory2 = (theme) => {
12630
12852
  text-align: left;
12631
12853
  `,
12632
12854
  detailsHeader: u`
12633
- font-family: 'Inter', sans-serif;
12855
+ font-family: ui-sans-serif, Inter, system-ui, sans-serif, sans-serif;
12634
12856
  position: sticky;
12635
12857
  top: 0;
12636
12858
  z-index: 2;
@@ -12662,7 +12884,8 @@ var stylesFactory2 = (theme) => {
12662
12884
  }
12663
12885
 
12664
12886
  & code {
12665
- font-family: 'Menlo', 'Fira Code', monospace;
12887
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
12888
+ 'Liberation Mono', 'Courier New', monospace;
12666
12889
  margin: 0;
12667
12890
  font-size: ${font.size.xs};
12668
12891
  line-height: ${font.lineHeight.xs};
@@ -12687,7 +12910,7 @@ var stylesFactory2 = (theme) => {
12687
12910
  gap: ${tokens.size[2]};
12688
12911
  padding: 0px ${tokens.size[2]};
12689
12912
  & > button {
12690
- font-family: 'Inter', sans-serif;
12913
+ font-family: ui-sans-serif, Inter, system-ui, sans-serif, sans-serif;
12691
12914
  font-size: ${font.size.xs};
12692
12915
  padding: ${tokens.size[1]} ${tokens.size[2]};
12693
12916
  display: flex;
@@ -12772,7 +12995,7 @@ var stylesFactory2 = (theme) => {
12772
12995
  settingsMenu: u`
12773
12996
  display: flex;
12774
12997
  & * {
12775
- font-family: 'Inter', sans-serif;
12998
+ font-family: ui-sans-serif, Inter, system-ui, sans-serif, sans-serif;
12776
12999
  }
12777
13000
  flex-direction: column;
12778
13001
  gap: ${size2[0.5]};