@tanstack/devtools 0.10.9 → 0.10.11

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.
@@ -0,0 +1,5 @@
1
+ // src/constants.ts
2
+ var PLUGIN_CONTAINER_ID = "plugin-container";
3
+ var PLUGIN_TITLE_CONTAINER_ID = "plugin-title-container";
4
+
5
+ export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID };
@@ -1,11 +1,8 @@
1
+ import { initialState } from './BNGI36V3.js';
1
2
  import { createComponent, delegateEvents } from 'solid-js/web';
2
- import { createContext, createSignal, createEffect, onCleanup, createMemo, useContext } from 'solid-js';
3
+ import { createContext, createEffect, createSignal, onCleanup, createMemo, useContext } from 'solid-js';
3
4
  import { createStore } from 'solid-js/store';
4
5
 
5
- // src/constants.ts
6
- var PLUGIN_CONTAINER_ID = "plugin-container";
7
- var PLUGIN_TITLE_CONTAINER_ID = "plugin-title-container";
8
-
9
6
  // src/utils/storage.ts
10
7
  var getStorageItem = (key) => localStorage.getItem(key);
11
8
  var setStorageItem = (key, value) => {
@@ -18,121 +15,21 @@ var setStorageItem = (key, value) => {
18
15
  var TANSTACK_DEVTOOLS = "tanstack_devtools";
19
16
  var TANSTACK_DEVTOOLS_STATE = "tanstack_devtools_state";
20
17
  var TANSTACK_DEVTOOLS_SETTINGS = "tanstack_devtools_settings";
21
- var PiPContext = createContext(void 0);
22
- var PiPProvider = (props) => {
23
- const [pipWindow, setPipWindow] = createSignal(null);
24
- const closePipWindow = () => {
25
- const w = pipWindow();
26
- if (w != null) {
27
- w.close();
28
- setPipWindow(null);
29
- }
30
- };
31
- const requestPipWindow = (settings) => {
32
- if (pipWindow() != null) {
33
- return;
34
- }
35
- const pip = window.open("", "TSDT-Devtools-Panel", `${settings},popup`);
36
- if (!pip) {
37
- throw new Error("Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.");
38
- }
39
- if (import.meta.hot && typeof import.meta.hot.on === "function") {
40
- import.meta.hot.on("vite:beforeUpdate", () => {
41
- localStorage.setItem("pip_open", "false");
42
- closePipWindow();
43
- });
44
- }
45
- window.addEventListener("beforeunload", () => {
46
- localStorage.setItem("pip_open", "false");
47
- closePipWindow();
48
- });
49
- pip.document.head.innerHTML = "";
50
- pip.document.body.innerHTML = "";
51
- pip.document.title = "TanStack Devtools";
52
- pip.document.body.style.margin = "0";
53
- pip.addEventListener("pagehide", () => {
54
- localStorage.setItem("pip_open", "false");
55
- closePipWindow();
56
- });
57
- [...document.styleSheets].forEach((styleSheet) => {
58
- try {
59
- const cssRules = [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
60
- const style = document.createElement("style");
61
- const style_node = styleSheet.ownerNode;
62
- let style_id = "";
63
- if (style_node && "id" in style_node) {
64
- style_id = style_node.id;
65
- }
66
- if (style_id) {
67
- style.setAttribute("id", style_id);
68
- }
69
- style.textContent = cssRules;
70
- pip.document.head.appendChild(style);
71
- } catch (e) {
72
- const link = document.createElement("link");
73
- if (styleSheet.href == null) {
74
- return;
75
- }
76
- link.rel = "stylesheet";
77
- link.type = styleSheet.type;
78
- link.media = styleSheet.media.toString();
79
- link.href = styleSheet.href;
80
- pip.document.head.appendChild(link);
81
- }
82
- });
83
- delegateEvents(["focusin", "focusout", "pointermove", "keydown", "pointerdown", "pointerup", "click", "mousedown", "input"], pip.document);
84
- setPipWindow(pip);
85
- };
86
- createEffect(() => {
87
- const gooberStyles = document.querySelector("#_goober");
88
- const w = pipWindow();
89
- if (gooberStyles && w) {
90
- const observer = new MutationObserver(() => {
91
- const pip_style = w.document.querySelector("#_goober");
92
- if (pip_style) {
93
- pip_style.textContent = gooberStyles.textContent;
94
- }
95
- });
96
- observer.observe(gooberStyles, {
97
- childList: true,
98
- // observe direct children
99
- subtree: true,
100
- // and lower descendants too
101
- characterDataOldValue: true
102
- // pass old data to callback
103
- });
104
- onCleanup(() => {
105
- observer.disconnect();
106
- });
107
- }
108
- });
109
- const value = createMemo(() => ({
110
- pipWindow: pipWindow(),
111
- requestPipWindow,
112
- closePipWindow,
113
- disabled: props.disabled ?? false
114
- }));
115
- return createComponent(PiPContext.Provider, {
116
- value,
117
- get children() {
118
- return props.children;
119
- }
120
- });
121
- };
122
- var usePiPWindow = () => {
123
- const context = createMemo(() => {
124
- const ctx = useContext(PiPContext);
125
- if (!ctx) {
126
- throw new Error("usePiPWindow must be used within a PiPProvider");
127
- }
128
- return ctx();
129
- });
130
- return context;
131
- };
132
18
 
133
19
  // src/utils/constants.ts
134
20
  var MAX_ACTIVE_PLUGINS = 3;
135
21
 
22
+ // src/utils/get-default-active-plugins.ts
23
+ function getDefaultActivePlugins(plugins) {
24
+ if (plugins.length === 0) {
25
+ return [];
26
+ }
27
+ if (plugins.length === 1) {
28
+ return [plugins[0].id];
29
+ }
30
+ return plugins.filter((plugin) => plugin.defaultOpen === true).slice(0, MAX_ACTIVE_PLUGINS).map((plugin) => plugin.id);
31
+ }
32
+
136
33
  // src/utils/sanitize.ts
137
34
  var tryParseJson = (json) => {
138
35
  if (!json) return void 0;
@@ -160,47 +57,6 @@ var getAllPermutations = (arr) => {
160
57
  return res;
161
58
  };
162
59
 
163
- // src/context/devtools-store.ts
164
- var keyboardModifiers = [
165
- "Alt",
166
- "Control",
167
- "Meta",
168
- "Shift",
169
- "CtrlOrMeta"
170
- ];
171
- var initialState = {
172
- settings: {
173
- defaultOpen: false,
174
- hideUntilHover: false,
175
- position: "bottom-right",
176
- panelLocation: "bottom",
177
- openHotkey: ["Control", "~"],
178
- inspectHotkey: ["Shift", "Alt", "CtrlOrMeta"],
179
- requireUrlFlag: false,
180
- urlFlag: "tanstack-devtools",
181
- theme: typeof window !== "undefined" && typeof window.matchMedia !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light",
182
- triggerHidden: false,
183
- customTrigger: void 0
184
- },
185
- state: {
186
- activeTab: "plugins",
187
- height: 400,
188
- activePlugins: [],
189
- persistOpen: false
190
- }
191
- };
192
-
193
- // src/utils/get-default-active-plugins.ts
194
- function getDefaultActivePlugins(plugins) {
195
- if (plugins.length === 0) {
196
- return [];
197
- }
198
- if (plugins.length === 1) {
199
- return [plugins[0].id];
200
- }
201
- return plugins.filter((plugin) => plugin.defaultOpen === true).slice(0, MAX_ACTIVE_PLUGINS).map((plugin) => plugin.id);
202
- }
203
-
204
60
  // src/context/devtools-context.tsx
205
61
  var DevtoolsContext = createContext();
206
62
  var getSettings = () => {
@@ -303,5 +159,116 @@ var DevtoolsProvider = (props) => {
303
159
  }
304
160
  });
305
161
  };
162
+ var PiPContext = createContext(void 0);
163
+ var PiPProvider = (props) => {
164
+ const [pipWindow, setPipWindow] = createSignal(null);
165
+ const closePipWindow = () => {
166
+ const w = pipWindow();
167
+ if (w != null) {
168
+ w.close();
169
+ setPipWindow(null);
170
+ }
171
+ };
172
+ const requestPipWindow = (settings) => {
173
+ if (pipWindow() != null) {
174
+ return;
175
+ }
176
+ const pip = window.open("", "TSDT-Devtools-Panel", `${settings},popup`);
177
+ if (!pip) {
178
+ throw new Error("Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.");
179
+ }
180
+ if (import.meta.hot && typeof import.meta.hot.on === "function") {
181
+ import.meta.hot.on("vite:beforeUpdate", () => {
182
+ localStorage.setItem("pip_open", "false");
183
+ closePipWindow();
184
+ });
185
+ }
186
+ window.addEventListener("beforeunload", () => {
187
+ localStorage.setItem("pip_open", "false");
188
+ closePipWindow();
189
+ });
190
+ pip.document.head.innerHTML = "";
191
+ pip.document.body.innerHTML = "";
192
+ pip.document.title = "TanStack Devtools";
193
+ pip.document.body.style.margin = "0";
194
+ pip.addEventListener("pagehide", () => {
195
+ localStorage.setItem("pip_open", "false");
196
+ closePipWindow();
197
+ });
198
+ [...document.styleSheets].forEach((styleSheet) => {
199
+ try {
200
+ const cssRules = [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
201
+ const style = document.createElement("style");
202
+ const style_node = styleSheet.ownerNode;
203
+ let style_id = "";
204
+ if (style_node && "id" in style_node) {
205
+ style_id = style_node.id;
206
+ }
207
+ if (style_id) {
208
+ style.setAttribute("id", style_id);
209
+ }
210
+ style.textContent = cssRules;
211
+ pip.document.head.appendChild(style);
212
+ } catch (e) {
213
+ const link = document.createElement("link");
214
+ if (styleSheet.href == null) {
215
+ return;
216
+ }
217
+ link.rel = "stylesheet";
218
+ link.type = styleSheet.type;
219
+ link.media = styleSheet.media.toString();
220
+ link.href = styleSheet.href;
221
+ pip.document.head.appendChild(link);
222
+ }
223
+ });
224
+ delegateEvents(["focusin", "focusout", "pointermove", "keydown", "pointerdown", "pointerup", "click", "mousedown", "input"], pip.document);
225
+ setPipWindow(pip);
226
+ };
227
+ createEffect(() => {
228
+ const gooberStyles = document.querySelector("#_goober");
229
+ const w = pipWindow();
230
+ if (gooberStyles && w) {
231
+ const observer = new MutationObserver(() => {
232
+ const pip_style = w.document.querySelector("#_goober");
233
+ if (pip_style) {
234
+ pip_style.textContent = gooberStyles.textContent;
235
+ }
236
+ });
237
+ observer.observe(gooberStyles, {
238
+ childList: true,
239
+ // observe direct children
240
+ subtree: true,
241
+ // and lower descendants too
242
+ characterDataOldValue: true
243
+ // pass old data to callback
244
+ });
245
+ onCleanup(() => {
246
+ observer.disconnect();
247
+ });
248
+ }
249
+ });
250
+ const value = createMemo(() => ({
251
+ pipWindow: pipWindow(),
252
+ requestPipWindow,
253
+ closePipWindow,
254
+ disabled: props.disabled ?? false
255
+ }));
256
+ return createComponent(PiPContext.Provider, {
257
+ value,
258
+ get children() {
259
+ return props.children;
260
+ }
261
+ });
262
+ };
263
+ var usePiPWindow = () => {
264
+ const context = createMemo(() => {
265
+ const ctx = useContext(PiPContext);
266
+ if (!ctx) {
267
+ throw new Error("usePiPWindow must be used within a PiPProvider");
268
+ }
269
+ return ctx();
270
+ });
271
+ return context;
272
+ };
306
273
 
307
- export { DevtoolsContext, DevtoolsProvider, MAX_ACTIVE_PLUGINS, PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID, PiPProvider, TANSTACK_DEVTOOLS, getAllPermutations, initialState, keyboardModifiers, uppercaseFirstLetter, usePiPWindow };
274
+ export { DevtoolsContext, DevtoolsProvider, MAX_ACTIVE_PLUGINS, PiPProvider, TANSTACK_DEVTOOLS, getAllPermutations, uppercaseFirstLetter, usePiPWindow };
@@ -0,0 +1,31 @@
1
+ // src/context/devtools-store.ts
2
+ var keyboardModifiers = [
3
+ "Alt",
4
+ "Control",
5
+ "Meta",
6
+ "Shift",
7
+ "CtrlOrMeta"
8
+ ];
9
+ var initialState = {
10
+ settings: {
11
+ defaultOpen: false,
12
+ hideUntilHover: false,
13
+ position: "bottom-right",
14
+ panelLocation: "bottom",
15
+ openHotkey: ["Control", "~"],
16
+ inspectHotkey: ["Shift", "Alt", "CtrlOrMeta"],
17
+ requireUrlFlag: false,
18
+ urlFlag: "tanstack-devtools",
19
+ theme: typeof window !== "undefined" && typeof window.matchMedia !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light",
20
+ triggerHidden: false,
21
+ customTrigger: void 0
22
+ },
23
+ state: {
24
+ activeTab: "plugins",
25
+ height: 400,
26
+ activePlugins: [],
27
+ persistOpen: false
28
+ }
29
+ };
30
+
31
+ export { initialState, keyboardModifiers };
package/dist/dev.js CHANGED
@@ -1,17 +1,16 @@
1
- import { initialState, DevtoolsProvider, PiPProvider } from './chunk/ULTYUGME.js';
2
- export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID } from './chunk/ULTYUGME.js';
3
- import { render, createComponent, Portal } from 'solid-js/web';
4
- import { lazy } from 'solid-js';
5
- import { ClientEventBus } from '@tanstack/devtools-event-bus/client';
1
+ export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID } from './chunk/A767CXXU.js';
2
+ import { initialState } from './chunk/BNGI36V3.js';
6
3
 
4
+ // src/core.ts
7
5
  var TanStackDevtoolsCore = class {
8
6
  #config = {
9
7
  ...initialState.settings
10
8
  };
11
9
  #plugins = [];
12
10
  #isMounted = false;
11
+ #isMounting = false;
12
+ #abortMount = false;
13
13
  #dispose;
14
- #Component;
15
14
  #eventBus;
16
15
  #eventBusConfig;
17
16
  #setPlugins;
@@ -24,47 +23,44 @@ var TanStackDevtoolsCore = class {
24
23
  };
25
24
  }
26
25
  mount(el) {
27
- if (this.#isMounted) {
26
+ if (typeof document === "undefined") return;
27
+ if (this.#isMounted || this.#isMounting) {
28
28
  throw new Error("Devtools is already mounted");
29
29
  }
30
- const mountTo = el;
31
- const dispose = render(() => {
32
- const _self$ = this;
33
- this.#Component = lazy(() => import('./devtools/BX2FS55Z.js'));
34
- const Devtools = this.#Component;
35
- this.#eventBus = new ClientEventBus(this.#eventBusConfig);
36
- this.#eventBus.start();
37
- return createComponent(DevtoolsProvider, {
38
- get plugins() {
39
- return _self$.#plugins;
40
- },
41
- get config() {
42
- return _self$.#config;
43
- },
30
+ this.#isMounting = true;
31
+ this.#abortMount = false;
32
+ import('./mount-impl/E4RX7DUJ.js').then(({ mountDevtools }) => {
33
+ if (this.#abortMount) {
34
+ this.#isMounting = false;
35
+ return;
36
+ }
37
+ const result = mountDevtools({
38
+ el,
39
+ plugins: this.#plugins,
40
+ config: this.#config,
41
+ eventBusConfig: this.#eventBusConfig,
44
42
  onSetPlugins: (setPlugins) => {
45
- _self$.#setPlugins = setPlugins;
46
- },
47
- get children() {
48
- return createComponent(PiPProvider, {
49
- get children() {
50
- return createComponent(Portal, {
51
- mount: mountTo,
52
- get children() {
53
- return createComponent(Devtools, {});
54
- }
55
- });
56
- }
57
- });
43
+ this.#setPlugins = setPlugins;
58
44
  }
59
45
  });
60
- }, mountTo);
61
- this.#isMounted = true;
62
- this.#dispose = dispose;
46
+ this.#dispose = result.dispose;
47
+ this.#eventBus = result.eventBus;
48
+ this.#isMounted = true;
49
+ this.#isMounting = false;
50
+ }).catch((err) => {
51
+ this.#isMounting = false;
52
+ console.error("[TanStack Devtools] Failed to load:", err);
53
+ });
63
54
  }
64
55
  unmount() {
65
- if (!this.#isMounted) {
56
+ if (!this.#isMounted && !this.#isMounting) {
66
57
  throw new Error("Devtools is not mounted");
67
58
  }
59
+ if (this.#isMounting) {
60
+ this.#abortMount = true;
61
+ this.#isMounting = false;
62
+ return;
63
+ }
68
64
  this.#eventBus?.stop();
69
65
  this.#dispose?.();
70
66
  this.#isMounted = false;
@@ -1,5 +1,7 @@
1
- import { usePiPWindow, TANSTACK_DEVTOOLS, keyboardModifiers, getAllPermutations, DevtoolsContext, PLUGIN_TITLE_CONTAINER_ID, PLUGIN_CONTAINER_ID, MAX_ACTIVE_PLUGINS, uppercaseFirstLetter } from '../chunk/ULTYUGME.js';
2
- import { delegateEvents, createComponent, Portal, template, use, setAttribute, insert, memo, effect, className, addEventListener, style, classList } from 'solid-js/web';
1
+ import { PLUGIN_TITLE_CONTAINER_ID, PLUGIN_CONTAINER_ID } from '../chunk/A767CXXU.js';
2
+ import { usePiPWindow, TANSTACK_DEVTOOLS, getAllPermutations, DevtoolsContext, MAX_ACTIVE_PLUGINS, uppercaseFirstLetter } from '../chunk/AP5L3KAF.js';
3
+ import { keyboardModifiers } from '../chunk/BNGI36V3.js';
4
+ import { delegateEvents, createComponent, Portal, use, setAttribute, insert, memo, effect, className, setStyleProperty, addEventListener, style, template, classList } from 'solid-js/web';
3
5
  import { createContext, createSignal, createEffect, onCleanup, Show, createMemo, For, useContext, onMount } from 'solid-js';
4
6
  import { createShortcut, useKeyDownList } from '@solid-primitives/keyboard';
5
7
  import { ThemeContextProvider, MainPanel as MainPanel$1, Section, SectionTitle, SectionIcon, SectionDescription, Checkbox, Select, Input, Button, ChevronDownIcon, CloseIcon, SearchIcon, SettingsIcon, PackageIcon, ExternalLinkIcon, CheckCircleIcon, XCircleIcon } from '@tanstack/devtools-ui';
@@ -1917,8 +1919,8 @@ var MainPanel = (props) => {
1917
1919
  }));
1918
1920
  effect((_p$) => {
1919
1921
  var _v$ = pip().pipWindow ? "100vh" : height() + "px", _v$2 = pip().pipWindow ? "100vh" : height() + "px", _v$3 = clsx3(styles().devtoolsPanelContainer(settings().panelLocation, Boolean(pip().pipWindow)), styles().devtoolsPanelContainerAnimation(props.isOpen(), height(), settings().panelLocation), styles().devtoolsPanelContainerVisibility(props.isOpen()), styles().devtoolsPanelContainerResizing(props.isResizing));
1920
- _v$ !== _p$.e && ((_p$.e = _v$) != null ? _el$.style.setProperty("height", _v$) : _el$.style.removeProperty("height"));
1921
- _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("--tsd-main-panel-height", _v$2) : _el$.style.removeProperty("--tsd-main-panel-height"));
1922
+ _v$ !== _p$.e && setStyleProperty(_el$, "height", _p$.e = _v$);
1923
+ _v$2 !== _p$.t && setStyleProperty(_el$, "--tsd-main-panel-height", _p$.t = _v$2);
1922
1924
  _v$3 !== _p$.a && className(_el$, _p$.a = _v$3);
1923
1925
  return _p$;
1924
1926
  }, {
@@ -1954,7 +1956,7 @@ var ContentPanel = (props) => {
1954
1956
  })();
1955
1957
  };
1956
1958
  delegateEvents(["mousedown"]);
1957
- var _tmpl$6 = /* @__PURE__ */ template(`<div><h4></h4><div></div>Final shortcut is: `);
1959
+ var _tmpl$6 = /* @__PURE__ */ template(`<div><h4 style=margin:0></h4><div></div>Final shortcut is: `);
1958
1960
  var MODIFIER_DISPLAY_NAMES = {
1959
1961
  Shift: "Shift",
1960
1962
  Alt: "Alt",
@@ -1995,7 +1997,6 @@ var HotkeyConfig = (props) => {
1995
1997
  };
1996
1998
  return (() => {
1997
1999
  var _el$ = _tmpl$6(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.nextSibling;
1998
- _el$2.style.setProperty("margin", "0");
1999
2000
  insert(_el$2, () => props.description);
2000
2001
  insert(_el$3, createComponent(Show, {
2001
2002
  keyed: true,
@@ -2361,7 +2362,7 @@ var _tmpl$32 = /* @__PURE__ */ template(`<span>\u2713 v<!> \u2022 Min v`);
2361
2362
  var _tmpl$42 = /* @__PURE__ */ template(`<p>`);
2362
2363
  var _tmpl$52 = /* @__PURE__ */ template(`<a target=_blank rel="noopener noreferrer">Documentation `);
2363
2364
  var _tmpl$62 = /* @__PURE__ */ template(`<div>`);
2364
- var _tmpl$72 = /* @__PURE__ */ template(`<div><span></span><div></div><div><h3></h3><p></p><p>`);
2365
+ var _tmpl$72 = /* @__PURE__ */ template(`<div style=position:relative><span></span><div></div><div><h3></h3><p></p><p>`);
2365
2366
  var _tmpl$82 = /* @__PURE__ */ template(`<span>\u26A0\uFE0F v<!> \u2022 Requires v<!>+`);
2366
2367
  var _tmpl$9 = /* @__PURE__ */ template(`<span>`);
2367
2368
  var _tmpl$0 = /* @__PURE__ */ template(`<span>Installing...`);
@@ -2373,7 +2374,6 @@ var PluginCardComponent = (props) => {
2373
2374
  } = props;
2374
2375
  return (() => {
2375
2376
  var _el$ = _tmpl$72(), _el$3 = _el$.firstChild, _el$4 = _el$3.nextSibling, _el$6 = _el$4.nextSibling, _el$7 = _el$6.firstChild, _el$8 = _el$7.nextSibling, _el$9 = _el$8.nextSibling;
2376
- _el$.style.setProperty("position", "relative");
2377
2377
  insert(_el$, createComponent(Show, {
2378
2378
  get when() {
2379
2379
  return card.metadata?.isNew;
@@ -2410,7 +2410,10 @@ var PluginCardComponent = (props) => {
2410
2410
  }));
2411
2411
  insert(_el$7, () => card.metadata?.title || card.devtoolsPackage);
2412
2412
  insert(_el$8, () => card.devtoolsPackage);
2413
- insert(_el$9, () => card.actionType === "requires-package" ? `Requires ${card.requiredPackageName}` : card.actionType === "wrong-framework" ? `For different framework projects` : card.actionType === "already-installed" ? `Active in your devtools` : card.actionType === "version-mismatch" ? card.versionInfo?.reason || "Version incompatible" : card.metadata?.description || `For ${card.requiredPackageName}`);
2413
+ insert(_el$9, (() => {
2414
+ var _c$ = memo(() => card.actionType === "requires-package");
2415
+ return () => _c$() ? `Requires ${card.requiredPackageName}` : memo(() => card.actionType === "wrong-framework")() ? `For different framework projects` : memo(() => card.actionType === "already-installed")() ? `Active in your devtools` : memo(() => card.actionType === "version-mismatch")() ? card.versionInfo?.reason || "Version incompatible" : card.metadata?.description || `For ${card.requiredPackageName}`;
2416
+ })());
2414
2417
  insert(_el$6, createComponent(Show, {
2415
2418
  get when() {
2416
2419
  return card.versionInfo;
@@ -2463,7 +2466,7 @@ var PluginCardComponent = (props) => {
2463
2466
  }), null);
2464
2467
  insert(_el$6, createComponent(Show, {
2465
2468
  get when() {
2466
- return card.metadata?.tags && card.metadata.tags.length > 0;
2469
+ return memo(() => !!card.metadata?.tags)() && card.metadata.tags.length > 0;
2467
2470
  },
2468
2471
  get children() {
2469
2472
  var _el$15 = _tmpl$62();
@@ -2752,13 +2755,11 @@ var TagFilters = (props) => {
2752
2755
  delegateEvents(["click"]);
2753
2756
 
2754
2757
  // src/tabs/marketplace/marketplace-header.tsx
2755
- var _tmpl$13 = /* @__PURE__ */ template(`<div><div><h2>Plugin Marketplace</h2><div><div><input type=text placeholder="Search plugins..."></div><button></button></div></div><p>Discover and install devtools for TanStack Query, Router, Form, and Pacer`);
2758
+ var _tmpl$13 = /* @__PURE__ */ template(`<div><div><h2>Plugin Marketplace</h2><div style=display:flex;align-items:center><div><input type=text placeholder="Search plugins..."></div><button></button></div></div><p>Discover and install devtools for TanStack Query, Router, Form, and Pacer`);
2756
2759
  var MarketplaceHeader = (props) => {
2757
2760
  const styles = useStyles();
2758
2761
  return (() => {
2759
2762
  var _el$ = _tmpl$13(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.firstChild, _el$6 = _el$5.firstChild, _el$7 = _el$5.nextSibling, _el$8 = _el$2.nextSibling;
2760
- _el$4.style.setProperty("display", "flex");
2761
- _el$4.style.setProperty("align-items", "center");
2762
2763
  insert(_el$5, createComponent(SearchIcon, {}), _el$6);
2763
2764
  _el$6.$$input = (e) => props.onSearchInput(e.currentTarget.value);
2764
2765
  addEventListener(_el$7, "click", props.onSettingsClick, true);
@@ -3642,7 +3643,7 @@ function useHeadChanges(onChange, opts = {}) {
3642
3643
  // src/tabs/seo-tab.tsx
3643
3644
  var _tmpl$16 = /* @__PURE__ */ template(`<div><div> Preview</div><div></div><div></div><div>`);
3644
3645
  var _tmpl$28 = /* @__PURE__ */ template(`<img alt=Preview>`);
3645
- var _tmpl$35 = /* @__PURE__ */ template(`<div>No Image`);
3646
+ var _tmpl$35 = /* @__PURE__ */ template(`<div style=background:#222;color:#888;display:flex;align-items:center;justify-content:center;min-height:80px;width:100%>No Image`);
3646
3647
  var _tmpl$44 = /* @__PURE__ */ template(`<div>`);
3647
3648
  var _tmpl$54 = /* @__PURE__ */ template(`<div><strong>Missing tags for <!>:</strong><ul>`);
3648
3649
  var _tmpl$63 = /* @__PURE__ */ template(`<li>`);
@@ -3789,13 +3790,6 @@ function SocialPreview(props) {
3789
3790
  return _el$7;
3790
3791
  })() : (() => {
3791
3792
  var _el$8 = _tmpl$35();
3792
- _el$8.style.setProperty("background", "#222");
3793
- _el$8.style.setProperty("color", "#888");
3794
- _el$8.style.setProperty("display", "flex");
3795
- _el$8.style.setProperty("align-items", "center");
3796
- _el$8.style.setProperty("justify-content", "center");
3797
- _el$8.style.setProperty("min-height", "80px");
3798
- _el$8.style.setProperty("width", "100%");
3799
3793
  effect(() => className(_el$8, styles().seoPreviewImage));
3800
3794
  return _el$8;
3801
3795
  })();
@@ -3806,9 +3800,9 @@ function SocialPreview(props) {
3806
3800
  effect((_p$) => {
3807
3801
  var _v$ = styles().seoPreviewCard, _v$2 = props.color, _v$3 = styles().seoPreviewHeader, _v$4 = props.color, _v$5 = styles().seoPreviewTitle, _v$6 = styles().seoPreviewDesc, _v$7 = styles().seoPreviewUrl;
3808
3802
  _v$ !== _p$.e && className(_el$, _p$.e = _v$);
3809
- _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("border-color", _v$2) : _el$.style.removeProperty("border-color"));
3803
+ _v$2 !== _p$.t && setStyleProperty(_el$, "border-color", _p$.t = _v$2);
3810
3804
  _v$3 !== _p$.a && className(_el$2, _p$.a = _v$3);
3811
- _v$4 !== _p$.o && ((_p$.o = _v$4) != null ? _el$2.style.setProperty("color", _v$4) : _el$2.style.removeProperty("color"));
3805
+ _v$4 !== _p$.o && setStyleProperty(_el$2, "color", _p$.o = _v$4);
3812
3806
  _v$5 !== _p$.i && className(_el$4, _p$.i = _v$5);
3813
3807
  _v$6 !== _p$.n && className(_el$5, _p$.n = _v$6);
3814
3808
  _v$7 !== _p$.s && className(_el$6, _p$.s = _v$7);
@@ -3951,7 +3945,7 @@ var tabs = [{
3951
3945
  // src/components/tabs.tsx
3952
3946
  var _tmpl$17 = /* @__PURE__ */ template(`<div>`);
3953
3947
  var _tmpl$29 = /* @__PURE__ */ template(`<button type=button>`);
3954
- var _tmpl$36 = /* @__PURE__ */ template(`<div><button type=button></button><button type=button>`);
3948
+ var _tmpl$36 = /* @__PURE__ */ template(`<div style=margin-top:auto;width:100%><button type=button></button><button type=button>`);
3955
3949
  var Tabs = (props) => {
3956
3950
  const styles = useStyles();
3957
3951
  const {
@@ -3991,8 +3985,6 @@ var Tabs = (props) => {
3991
3985
  var _c$ = memo(() => pipWindow().pipWindow !== null);
3992
3986
  return () => _c$() ? null : (() => {
3993
3987
  var _el$3 = _tmpl$36(), _el$4 = _el$3.firstChild, _el$5 = _el$4.nextSibling;
3994
- _el$3.style.setProperty("margin-top", "auto");
3995
- _el$3.style.setProperty("width", "100%");
3996
3988
  _el$4.$$click = handleDetachment;
3997
3989
  insert(_el$4, createComponent(PiP, {}));
3998
3990
  _el$5.$$click = () => props.toggleOpen();
@@ -4028,7 +4020,7 @@ var TabContent = () => {
4028
4020
  return _el$;
4029
4021
  })();
4030
4022
  };
4031
- var _tmpl$19 = /* @__PURE__ */ template(`<div>`);
4023
+ var _tmpl$19 = /* @__PURE__ */ template(`<div style=pointer-events:none>`);
4032
4024
  var SourceInspector = () => {
4033
4025
  const {
4034
4026
  settings
@@ -4161,15 +4153,13 @@ var SourceInspector = () => {
4161
4153
  use(setNameTagRef, _el$);
4162
4154
  insert(_el$, () => highlightState.dataSource);
4163
4155
  effect((_$p) => style(_el$, {
4164
- ...fileNameStyles(),
4165
- "pointer-events": "none"
4156
+ ...fileNameStyles()
4166
4157
  }, _$p));
4167
4158
  return _el$;
4168
4159
  })(), (() => {
4169
4160
  var _el$2 = _tmpl$19();
4170
4161
  effect((_$p) => style(_el$2, {
4171
- ...currentElementBoxStyles(),
4172
- "pointer-events": "none"
4162
+ ...currentElementBoxStyles()
4173
4163
  }, _$p));
4174
4164
  return _el$2;
4175
4165
  })()];
@@ -1,5 +1,7 @@
1
- import { usePiPWindow, TANSTACK_DEVTOOLS, keyboardModifiers, getAllPermutations, DevtoolsContext, PLUGIN_TITLE_CONTAINER_ID, PLUGIN_CONTAINER_ID, MAX_ACTIVE_PLUGINS, uppercaseFirstLetter } from '../chunk/ULTYUGME.js';
2
- import { createComponent, Portal, ssr, ssrAttribute, escape, ssrStyle } from 'solid-js/web';
1
+ import { PLUGIN_TITLE_CONTAINER_ID, PLUGIN_CONTAINER_ID } from '../chunk/A767CXXU.js';
2
+ import { usePiPWindow, TANSTACK_DEVTOOLS, getAllPermutations, DevtoolsContext, MAX_ACTIVE_PLUGINS, uppercaseFirstLetter } from '../chunk/AP5L3KAF.js';
3
+ import { keyboardModifiers } from '../chunk/BNGI36V3.js';
4
+ import { createComponent, Portal, ssr, ssrAttribute, escape, ssrStyleProperty, ssrStyle } from 'solid-js/web';
3
5
  import { createContext, createSignal, createEffect, onCleanup, Show, createMemo, For, useContext, onMount } from 'solid-js';
4
6
  import { createShortcut, useKeyDownList } from '@solid-primitives/keyboard';
5
7
  import { ThemeContextProvider, MainPanel as MainPanel$1, Section, SectionTitle, SectionIcon, SectionDescription, Checkbox, Select, Input, Button, ChevronDownIcon, CloseIcon, SearchIcon, SettingsIcon, PackageIcon, ExternalLinkIcon, CheckCircleIcon, XCircleIcon } from '@tanstack/devtools-ui';
@@ -1895,7 +1897,7 @@ var MainPanel = (props) => {
1895
1897
  settings
1896
1898
  } = useDevtoolsSettings();
1897
1899
  const pip = usePiPWindow();
1898
- return ssr(_tmpl$4, ssrAttribute("id", escape(TANSTACK_DEVTOOLS, true), false), "height:" + (pip().pipWindow ? "100vh" : escape(height(), true) + "px") + (";--tsd-main-panel-height:" + (pip().pipWindow ? "100vh" : escape(height(), true) + "px")), ssrAttribute("class", escape(clsx3(styles().devtoolsPanelContainer(settings().panelLocation, Boolean(pip().pipWindow)), styles().devtoolsPanelContainerAnimation(props.isOpen(), height(), settings().panelLocation), styles().devtoolsPanelContainerVisibility(props.isOpen()), styles().devtoolsPanelContainerResizing(props.isResizing)), true), false), escape(createComponent(DrawClientProvider, {
1900
+ return ssr(_tmpl$4, ssrAttribute("id", escape(TANSTACK_DEVTOOLS, true), false), ssrStyleProperty("height:", pip().pipWindow ? "100vh" : escape(height(), true) + "px") + ssrStyleProperty(";--tsd-main-panel-height:", pip().pipWindow ? "100vh" : escape(height(), true) + "px"), ssrAttribute("class", escape(clsx3(styles().devtoolsPanelContainer(settings().panelLocation, Boolean(pip().pipWindow)), styles().devtoolsPanelContainerAnimation(props.isOpen(), height(), settings().panelLocation), styles().devtoolsPanelContainerVisibility(props.isOpen()), styles().devtoolsPanelContainerResizing(props.isResizing)), true), false), escape(createComponent(DrawClientProvider, {
1899
1901
  animationMs: 400,
1900
1902
  get children() {
1901
1903
  return props.children;
@@ -1950,7 +1952,7 @@ var HotkeyConfig = (props) => {
1950
1952
  const getDisplayHotkey = () => {
1951
1953
  return props.hotkey.join(" + ");
1952
1954
  };
1953
- return ssr(_tmpl$6, ssrAttribute("class", escape(styles().settingsGroup, true), false), "margin:0", escape(props.description), ssrAttribute("class", escape(styles().settingsModifiers, true), false), escape(createComponent(Show, {
1955
+ return ssr(_tmpl$6, ssrAttribute("class", escape(styles().settingsGroup, true), false), ssrStyleProperty("margin:", 0), escape(props.description), ssrAttribute("class", escape(styles().settingsModifiers, true), false), escape(createComponent(Show, {
1954
1956
  keyed: true,
1955
1957
  get when() {
1956
1958
  return props.hotkey;
@@ -2278,7 +2280,7 @@ var PluginCardComponent = (props) => {
2278
2280
  const {
2279
2281
  card
2280
2282
  } = props;
2281
- return ssr(_tmpl$72, `${escape(styles().pluginMarketplaceCard, true) || ""} ${!card.isCurrentFramework && card.actionType !== "already-installed" ? escape(escape(styles().pluginMarketplaceCardDisabled, true), true) : ""} ${!!card.metadata?.featured && card.actionType !== "already-installed" ? escape(escape(styles().pluginMarketplaceCardFeatured, true), true) : ""} ${card.actionType === "already-installed" ? escape(escape(styles().pluginMarketplaceCardActive, true), true) : ""}`, "position:relative", escape(createComponent(Show, {
2283
+ return ssr(_tmpl$72, `${escape(styles().pluginMarketplaceCard, true) || ""} ${!card.isCurrentFramework && card.actionType !== "already-installed" ? escape(escape(styles().pluginMarketplaceCardDisabled, true), true) : ""} ${!!card.metadata?.featured && card.actionType !== "already-installed" ? escape(escape(styles().pluginMarketplaceCardFeatured, true), true) : ""} ${card.actionType === "already-installed" ? escape(escape(styles().pluginMarketplaceCardActive, true), true) : ""}`, ssrStyleProperty("position:", "relative"), escape(createComponent(Show, {
2282
2284
  get when() {
2283
2285
  return card.metadata?.isNew;
2284
2286
  },
@@ -2457,7 +2459,7 @@ var TagFilters = (props) => {
2457
2459
  var _tmpl$15 = ["<div", "><div", "><h2", '>Plugin Marketplace</h2><div style="', '"><div', ">", '<input type="text"', ' placeholder="Search plugins..."', "></div><button", ">", "</button></div></div><p", ">Discover and install devtools for TanStack Query, Router, Form, and Pacer</p>", "</div>"];
2458
2460
  var MarketplaceHeader = (props) => {
2459
2461
  const styles = useStyles();
2460
- return ssr(_tmpl$15, ssrAttribute("class", escape(styles().pluginMarketplaceHeader, true), false), ssrAttribute("class", escape(styles().pluginMarketplaceTitleRow, true), false), ssrAttribute("class", escape(styles().pluginMarketplaceTitle, true), false), "display:flex;align-items:center", ssrAttribute("class", escape(styles().pluginMarketplaceSearchWrapper, true), false), escape(createComponent(SearchIcon, {})), ssrAttribute("class", escape(styles().pluginMarketplaceSearch, true), false), ssrAttribute("value", escape(props.searchInput(), true), false), ssrAttribute("class", escape(styles().pluginMarketplaceSettingsButton, true), false), escape(createComponent(SettingsIcon, {})), ssrAttribute("class", escape(styles().pluginMarketplaceDescription, true), false), escape(createComponent(TagFilters, {
2462
+ return ssr(_tmpl$15, ssrAttribute("class", escape(styles().pluginMarketplaceHeader, true), false), ssrAttribute("class", escape(styles().pluginMarketplaceTitleRow, true), false), ssrAttribute("class", escape(styles().pluginMarketplaceTitle, true), false), ssrStyleProperty("display:", "flex") + ssrStyleProperty(";align-items:", "center"), ssrAttribute("class", escape(styles().pluginMarketplaceSearchWrapper, true), false), escape(createComponent(SearchIcon, {})), ssrAttribute("class", escape(styles().pluginMarketplaceSearch, true), false), ssrAttribute("value", escape(props.searchInput(), true), false), ssrAttribute("class", escape(styles().pluginMarketplaceSettingsButton, true), false), escape(createComponent(SettingsIcon, {})), ssrAttribute("class", escape(styles().pluginMarketplaceDescription, true), false), escape(createComponent(TagFilters, {
2461
2463
  get tags() {
2462
2464
  return props.tags;
2463
2465
  },
@@ -3356,7 +3358,7 @@ var SOCIALS = [
3356
3358
  ];
3357
3359
  function SocialPreview(props) {
3358
3360
  const styles = useStyles();
3359
- return ssr(_tmpl$18, ssrAttribute("class", escape(styles().seoPreviewCard, true), false), "border-color:" + escape(props.color, true), ssrAttribute("class", escape(styles().seoPreviewHeader, true), false), "color:" + escape(props.color, true), escape(props.network), props.meta.image ? ssr(_tmpl$29, ssrAttribute("src", escape(props.meta.image, true), false), ssrAttribute("class", escape(styles().seoPreviewImage, true), false)) : ssr(_tmpl$36, ssrAttribute("class", escape(styles().seoPreviewImage, true), false), "background:#222;color:#888;display:flex;align-items:center;justify-content:center;min-height:80px;width:100%"), ssrAttribute("class", escape(styles().seoPreviewTitle, true), false), escape(props.meta.title) || "No Title", ssrAttribute("class", escape(styles().seoPreviewDesc, true), false), escape(props.meta.description) || "No Description", ssrAttribute("class", escape(styles().seoPreviewUrl, true), false), escape(props.meta.url) || escape(window.location.href));
3361
+ return ssr(_tmpl$18, ssrAttribute("class", escape(styles().seoPreviewCard, true), false), ssrStyleProperty("border-color:", escape(props.color, true)), ssrAttribute("class", escape(styles().seoPreviewHeader, true), false), ssrStyleProperty("color:", escape(props.color, true)), escape(props.network), props.meta.image ? ssr(_tmpl$29, ssrAttribute("src", escape(props.meta.image, true), false), ssrAttribute("class", escape(styles().seoPreviewImage, true), false)) : ssr(_tmpl$36, ssrAttribute("class", escape(styles().seoPreviewImage, true), false), ssrStyleProperty("background:", "#222") + ssrStyleProperty(";color:", "#888") + ssrStyleProperty(";display:", "flex") + ssrStyleProperty(";align-items:", "center") + ssrStyleProperty(";justify-content:", "center") + ssrStyleProperty(";min-height:", "80px") + ssrStyleProperty(";width:", "100%")), ssrAttribute("class", escape(styles().seoPreviewTitle, true), false), escape(props.meta.title) || "No Title", ssrAttribute("class", escape(styles().seoPreviewDesc, true), false), escape(props.meta.description) || "No Description", ssrAttribute("class", escape(styles().seoPreviewUrl, true), false), escape(props.meta.url) || escape(window.location.href));
3360
3362
  }
3361
3363
  var SeoTab = () => {
3362
3364
  const [reports, setReports] = createSignal(analyzeHead());
@@ -3468,7 +3470,7 @@ var Tabs = (props) => {
3468
3470
  children: (tab) => ssr(_tmpl$210, ssrAttribute("class", escape(clsx3(styles().tab, {
3469
3471
  active: state().activeTab === tab.id
3470
3472
  }), true), false), escape(tab.icon()))
3471
- })), pipWindow().pipWindow !== null ? escape(null) : ssr(_tmpl$37, "margin-top:auto;width:100%", ssrAttribute("class", escape(clsx3(styles().tab, "detach"), true), false), escape(createComponent(PiP, {})), ssrAttribute("class", escape(clsx3(styles().tab, "close"), true), false), escape(createComponent(X, {}))));
3473
+ })), pipWindow().pipWindow !== null ? escape(null) : ssr(_tmpl$37, ssrStyleProperty("margin-top:", "auto") + ssrStyleProperty(";width:", "100%"), ssrAttribute("class", escape(clsx3(styles().tab, "detach"), true), false), escape(createComponent(PiP, {})), ssrAttribute("class", escape(clsx3(styles().tab, "close"), true), false), escape(createComponent(X, {}))));
3472
3474
  };
3473
3475
  var _tmpl$20 = ["<div", ">", "</div>"];
3474
3476
  var TabContent = () => {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import * as solid_js from 'solid-js';
1
2
  import { ClientEventBusConfig } from '@tanstack/devtools-event-bus/client';
2
3
  export { ClientEventBusConfig } from '@tanstack/devtools-event-bus/client';
3
- import * as solid_js from 'solid-js';
4
4
 
5
5
  declare const PLUGIN_CONTAINER_ID = "plugin-container";
6
6
  declare const PLUGIN_TITLE_CONTAINER_ID = "plugin-title-container";
package/dist/index.js CHANGED
@@ -1,17 +1,16 @@
1
- import { initialState, DevtoolsProvider, PiPProvider } from './chunk/ULTYUGME.js';
2
- export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID } from './chunk/ULTYUGME.js';
3
- import { render, createComponent, Portal } from 'solid-js/web';
4
- import { lazy } from 'solid-js';
5
- import { ClientEventBus } from '@tanstack/devtools-event-bus/client';
1
+ export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID } from './chunk/A767CXXU.js';
2
+ import { initialState } from './chunk/BNGI36V3.js';
6
3
 
4
+ // src/core.ts
7
5
  var TanStackDevtoolsCore = class {
8
6
  #config = {
9
7
  ...initialState.settings
10
8
  };
11
9
  #plugins = [];
12
10
  #isMounted = false;
11
+ #isMounting = false;
12
+ #abortMount = false;
13
13
  #dispose;
14
- #Component;
15
14
  #eventBus;
16
15
  #eventBusConfig;
17
16
  #setPlugins;
@@ -24,47 +23,43 @@ var TanStackDevtoolsCore = class {
24
23
  };
25
24
  }
26
25
  mount(el) {
27
- if (this.#isMounted) {
26
+ if (typeof document === "undefined") return;
27
+ if (this.#isMounted || this.#isMounting) {
28
28
  throw new Error("Devtools is already mounted");
29
29
  }
30
- const mountTo = el;
31
- const dispose = render(() => {
32
- const _self$ = this;
33
- this.#Component = lazy(() => import('./devtools/BX2FS55Z.js'));
34
- const Devtools = this.#Component;
35
- this.#eventBus = new ClientEventBus(this.#eventBusConfig);
36
- this.#eventBus.start();
37
- return createComponent(DevtoolsProvider, {
38
- get plugins() {
39
- return _self$.#plugins;
40
- },
41
- get config() {
42
- return _self$.#config;
43
- },
30
+ this.#isMounting = true;
31
+ this.#abortMount = false;
32
+ import('./mount-impl/E4RX7DUJ.js').then(({ mountDevtools }) => {
33
+ if (this.#abortMount) {
34
+ this.#isMounting = false;
35
+ return;
36
+ }
37
+ const result = mountDevtools({
38
+ el,
39
+ plugins: this.#plugins,
40
+ config: this.#config,
41
+ eventBusConfig: this.#eventBusConfig,
44
42
  onSetPlugins: (setPlugins) => {
45
- _self$.#setPlugins = setPlugins;
46
- },
47
- get children() {
48
- return createComponent(PiPProvider, {
49
- get children() {
50
- return createComponent(Portal, {
51
- mount: mountTo,
52
- get children() {
53
- return createComponent(Devtools, {});
54
- }
55
- });
56
- }
57
- });
43
+ this.#setPlugins = setPlugins;
58
44
  }
59
45
  });
60
- }, mountTo);
61
- this.#isMounted = true;
62
- this.#dispose = dispose;
46
+ this.#dispose = result.dispose;
47
+ this.#eventBus = result.eventBus;
48
+ this.#isMounted = true;
49
+ this.#isMounting = false;
50
+ }).catch((err) => {
51
+ this.#isMounting = false;
52
+ });
63
53
  }
64
54
  unmount() {
65
- if (!this.#isMounted) {
55
+ if (!this.#isMounted && !this.#isMounting) {
66
56
  throw new Error("Devtools is not mounted");
67
57
  }
58
+ if (this.#isMounting) {
59
+ this.#abortMount = true;
60
+ this.#isMounting = false;
61
+ return;
62
+ }
68
63
  this.#eventBus?.stop();
69
64
  this.#dispose?.();
70
65
  this.#isMounted = false;
@@ -0,0 +1,41 @@
1
+ import { DevtoolsProvider, PiPProvider } from '../chunk/AP5L3KAF.js';
2
+ import '../chunk/BNGI36V3.js';
3
+ import { render, createComponent, Portal } from 'solid-js/web';
4
+ import { lazy } from 'solid-js';
5
+ import { ClientEventBus } from '@tanstack/devtools-event-bus/client';
6
+
7
+ function mountDevtools(options) {
8
+ const {
9
+ el,
10
+ plugins,
11
+ config,
12
+ eventBusConfig,
13
+ onSetPlugins
14
+ } = options;
15
+ const eventBus = new ClientEventBus(eventBusConfig);
16
+ eventBus.start();
17
+ const Devtools = lazy(() => import('../devtools/NTZWLI2C.js'));
18
+ const dispose = render(() => createComponent(DevtoolsProvider, {
19
+ plugins,
20
+ config,
21
+ onSetPlugins,
22
+ get children() {
23
+ return createComponent(PiPProvider, {
24
+ get children() {
25
+ return createComponent(Portal, {
26
+ mount: el,
27
+ get children() {
28
+ return createComponent(Devtools, {});
29
+ }
30
+ });
31
+ }
32
+ });
33
+ }
34
+ }), el);
35
+ return {
36
+ dispose,
37
+ eventBus
38
+ };
39
+ }
40
+
41
+ export { mountDevtools };
@@ -0,0 +1,41 @@
1
+ import { DevtoolsProvider, PiPProvider } from '../chunk/AP5L3KAF.js';
2
+ import '../chunk/BNGI36V3.js';
3
+ import { render, createComponent, Portal } from 'solid-js/web';
4
+ import { lazy } from 'solid-js';
5
+ import { ClientEventBus } from '@tanstack/devtools-event-bus/client';
6
+
7
+ function mountDevtools(options) {
8
+ const {
9
+ el,
10
+ plugins,
11
+ config,
12
+ eventBusConfig,
13
+ onSetPlugins
14
+ } = options;
15
+ const eventBus = new ClientEventBus(eventBusConfig);
16
+ eventBus.start();
17
+ const Devtools = lazy(() => import('../devtools/AHAZGWBE.js'));
18
+ const dispose = render(() => createComponent(DevtoolsProvider, {
19
+ plugins,
20
+ config,
21
+ onSetPlugins,
22
+ get children() {
23
+ return createComponent(PiPProvider, {
24
+ get children() {
25
+ return createComponent(Portal, {
26
+ mount: el,
27
+ get children() {
28
+ return createComponent(Devtools, {});
29
+ }
30
+ });
31
+ }
32
+ });
33
+ }
34
+ }), el);
35
+ return {
36
+ dispose,
37
+ eventBus
38
+ };
39
+ }
40
+
41
+ export { mountDevtools };
package/dist/server.js CHANGED
@@ -1,17 +1,16 @@
1
- import { initialState } from './chunk/ULTYUGME.js';
2
- export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID } from './chunk/ULTYUGME.js';
3
- import 'solid-js/web';
4
- import 'solid-js';
5
- import '@tanstack/devtools-event-bus/client';
1
+ export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID } from './chunk/A767CXXU.js';
2
+ import { initialState } from './chunk/BNGI36V3.js';
6
3
 
4
+ // src/core.ts
7
5
  var TanStackDevtoolsCore = class {
8
6
  #config = {
9
7
  ...initialState.settings
10
8
  };
11
9
  #plugins = [];
12
10
  #isMounted = false;
11
+ #isMounting = false;
12
+ #abortMount = false;
13
13
  #dispose;
14
- #Component;
15
14
  #eventBus;
16
15
  #eventBusConfig;
17
16
  #setPlugins;
@@ -24,12 +23,43 @@ var TanStackDevtoolsCore = class {
24
23
  };
25
24
  }
26
25
  mount(el) {
27
- return;
26
+ if (typeof document === "undefined") return;
27
+ if (this.#isMounted || this.#isMounting) {
28
+ throw new Error("Devtools is already mounted");
29
+ }
30
+ this.#isMounting = true;
31
+ this.#abortMount = false;
32
+ import('./mount-impl/22DJOLY6.js').then(({ mountDevtools }) => {
33
+ if (this.#abortMount) {
34
+ this.#isMounting = false;
35
+ return;
36
+ }
37
+ const result = mountDevtools({
38
+ el,
39
+ plugins: this.#plugins,
40
+ config: this.#config,
41
+ eventBusConfig: this.#eventBusConfig,
42
+ onSetPlugins: (setPlugins) => {
43
+ this.#setPlugins = setPlugins;
44
+ }
45
+ });
46
+ this.#dispose = result.dispose;
47
+ this.#eventBus = result.eventBus;
48
+ this.#isMounted = true;
49
+ this.#isMounting = false;
50
+ }).catch((err) => {
51
+ this.#isMounting = false;
52
+ });
28
53
  }
29
54
  unmount() {
30
- if (!this.#isMounted) {
55
+ if (!this.#isMounted && !this.#isMounting) {
31
56
  throw new Error("Devtools is not mounted");
32
57
  }
58
+ if (this.#isMounting) {
59
+ this.#abortMount = true;
60
+ this.#isMounting = false;
61
+ return;
62
+ }
33
63
  this.#eventBus?.stop();
34
64
  this.#dispose?.();
35
65
  this.#isMounted = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/devtools",
3
- "version": "0.10.9",
3
+ "version": "0.10.11",
4
4
  "description": "TanStack Devtools is a set of tools for building advanced devtools for your application.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -57,7 +57,7 @@
57
57
  "solid-js": "^1.9.9",
58
58
  "@tanstack/devtools-client": "0.0.6",
59
59
  "@tanstack/devtools-event-bus": "0.4.1",
60
- "@tanstack/devtools-ui": "0.4.4"
60
+ "@tanstack/devtools-ui": "0.5.0"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "solid-js": ">=1.9.7"
@@ -1,14 +1,9 @@
1
- import { lazy } from 'solid-js'
2
- import { Portal, render } from 'solid-js/web'
3
- import { ClientEventBus } from '@tanstack/devtools-event-bus/client'
4
- import { DevtoolsProvider } from './context/devtools-context'
5
1
  import { initialState } from './context/devtools-store'
6
- import { PiPProvider } from './context/pip-context'
7
- import type { ClientEventBusConfig } from '@tanstack/devtools-event-bus/client'
8
2
  import type {
9
3
  TanStackDevtoolsConfig,
10
4
  TanStackDevtoolsPlugin,
11
5
  } from './context/devtools-context'
6
+ import type { ClientEventBusConfig } from '@tanstack/devtools-event-bus/client'
12
7
 
13
8
  export interface TanStackDevtoolsInit {
14
9
  /**
@@ -46,9 +41,10 @@ export class TanStackDevtoolsCore {
46
41
  }
47
42
  #plugins: Array<TanStackDevtoolsPlugin> = []
48
43
  #isMounted = false
44
+ #isMounting = false
45
+ #abortMount = false
49
46
  #dispose?: () => void
50
- #Component: any
51
- #eventBus: ClientEventBus | undefined
47
+ #eventBus?: { stop: () => void }
52
48
  #eventBusConfig: ClientEventBusConfig | undefined
53
49
  #setPlugins?: (plugins: Array<TanStackDevtoolsPlugin>) => void
54
50
 
@@ -62,45 +58,51 @@ export class TanStackDevtoolsCore {
62
58
  }
63
59
 
64
60
  mount<T extends HTMLElement>(el: T) {
65
- // tsup-preset-solid statically replaces this variable during build, which eliminates this code from server bundle
66
- // can be run outside of vite so we ignore the rule
67
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
68
- if (import.meta?.env?.SSR) return
61
+ if (typeof document === 'undefined') return
69
62
 
70
- if (this.#isMounted) {
63
+ if (this.#isMounted || this.#isMounting) {
71
64
  throw new Error('Devtools is already mounted')
72
65
  }
73
- const mountTo = el
74
- const dispose = render(() => {
75
- this.#Component = lazy(() => import('./devtools'))
76
- const Devtools = this.#Component
77
- this.#eventBus = new ClientEventBus(this.#eventBusConfig)
78
- this.#eventBus.start()
79
- return (
80
- <DevtoolsProvider
81
- plugins={this.#plugins}
82
- config={this.#config}
83
- onSetPlugins={(setPlugins) => {
66
+ this.#isMounting = true
67
+ this.#abortMount = false
68
+
69
+ import('./mount-impl')
70
+ .then(({ mountDevtools }) => {
71
+ if (this.#abortMount) {
72
+ this.#isMounting = false
73
+ return
74
+ }
75
+
76
+ const result = mountDevtools({
77
+ el,
78
+ plugins: this.#plugins,
79
+ config: this.#config,
80
+ eventBusConfig: this.#eventBusConfig,
81
+ onSetPlugins: (setPlugins) => {
84
82
  this.#setPlugins = setPlugins
85
- }}
86
- >
87
- <PiPProvider>
88
- <Portal mount={mountTo}>
89
- <Devtools />
90
- </Portal>
91
- </PiPProvider>
92
- </DevtoolsProvider>
93
- )
94
- }, mountTo)
83
+ },
84
+ })
95
85
 
96
- this.#isMounted = true
97
- this.#dispose = dispose
86
+ this.#dispose = result.dispose
87
+ this.#eventBus = result.eventBus
88
+ this.#isMounted = true
89
+ this.#isMounting = false
90
+ })
91
+ .catch((err) => {
92
+ this.#isMounting = false
93
+ console.error('[TanStack Devtools] Failed to load:', err)
94
+ })
98
95
  }
99
96
 
100
97
  unmount() {
101
- if (!this.#isMounted) {
98
+ if (!this.#isMounted && !this.#isMounting) {
102
99
  throw new Error('Devtools is not mounted')
103
100
  }
101
+ if (this.#isMounting) {
102
+ this.#abortMount = true
103
+ this.#isMounting = false
104
+ return
105
+ }
104
106
  this.#eventBus?.stop()
105
107
  this.#dispose?.()
106
108
  this.#isMounted = false
@@ -0,0 +1,53 @@
1
+ import { lazy } from 'solid-js'
2
+ import { Portal, render } from 'solid-js/web'
3
+ import { ClientEventBus } from '@tanstack/devtools-event-bus/client'
4
+ import { DevtoolsProvider } from './context/devtools-context'
5
+ import { PiPProvider } from './context/pip-context'
6
+ import type {
7
+ TanStackDevtoolsConfig,
8
+ TanStackDevtoolsPlugin,
9
+ } from './context/devtools-context'
10
+ import type { ClientEventBusConfig } from '@tanstack/devtools-event-bus/client'
11
+
12
+ interface MountOptions {
13
+ el: HTMLElement
14
+ plugins: Array<TanStackDevtoolsPlugin>
15
+ config: TanStackDevtoolsConfig
16
+ eventBusConfig?: ClientEventBusConfig
17
+ onSetPlugins: (
18
+ setPlugins: (plugins: Array<TanStackDevtoolsPlugin>) => void,
19
+ ) => void
20
+ }
21
+
22
+ interface MountResult {
23
+ dispose: () => void
24
+ eventBus: { stop: () => void }
25
+ }
26
+
27
+ export function mountDevtools(options: MountOptions): MountResult {
28
+ const { el, plugins, config, eventBusConfig, onSetPlugins } = options
29
+
30
+ const eventBus = new ClientEventBus(eventBusConfig)
31
+ eventBus.start()
32
+
33
+ const Devtools = lazy(() => import('./devtools'))
34
+
35
+ const dispose = render(
36
+ () => (
37
+ <DevtoolsProvider
38
+ plugins={plugins}
39
+ config={config}
40
+ onSetPlugins={onSetPlugins}
41
+ >
42
+ <PiPProvider>
43
+ <Portal mount={el}>
44
+ <Devtools />
45
+ </Portal>
46
+ </PiPProvider>
47
+ </DevtoolsProvider>
48
+ ),
49
+ el,
50
+ )
51
+
52
+ return { dispose, eventBus }
53
+ }