@tanstack/devtools 0.6.7 → 0.6.8
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/dist/chunk/CEHNENNI.js +251 -0
- package/dist/{esm/core.js → dev.js} +10 -12
- package/dist/devtools/DJF65R3Y.js +1674 -0
- package/dist/devtools/ITBBRMTQ.js +1966 -0
- package/dist/index.d.ts +168 -0
- package/dist/index.js +76 -0
- package/dist/server.js +44 -0
- package/package.json +21 -12
- package/src/core.tsx +3 -0
- package/dist/esm/components/content-panel.d.ts +0 -6
- package/dist/esm/components/content-panel.js +0 -32
- package/dist/esm/components/content-panel.js.map +0 -1
- package/dist/esm/components/main-panel.d.ts +0 -6
- package/dist/esm/components/main-panel.js +0 -42
- package/dist/esm/components/main-panel.js.map +0 -1
- package/dist/esm/components/tab-content.d.ts +0 -2
- package/dist/esm/components/tab-content.js +0 -23
- package/dist/esm/components/tab-content.js.map +0 -1
- package/dist/esm/components/tabs.d.ts +0 -5
- package/dist/esm/components/tabs.js +0 -75
- package/dist/esm/components/tabs.js.map +0 -1
- package/dist/esm/components/trigger.d.ts +0 -5
- package/dist/esm/components/trigger.js +0 -31
- package/dist/esm/components/trigger.js.map +0 -1
- package/dist/esm/constants.d.ts +0 -2
- package/dist/esm/constants.js +0 -7
- package/dist/esm/constants.js.map +0 -1
- package/dist/esm/context/devtools-context.d.ts +0 -62
- package/dist/esm/context/devtools-context.js +0 -77
- package/dist/esm/context/devtools-context.js.map +0 -1
- package/dist/esm/context/devtools-store.d.ts +0 -59
- package/dist/esm/context/devtools-store.js +0 -29
- package/dist/esm/context/devtools-store.js.map +0 -1
- package/dist/esm/context/draw-context.d.ts +0 -13
- package/dist/esm/context/draw-context.js +0 -55
- package/dist/esm/context/draw-context.js.map +0 -1
- package/dist/esm/context/pip-context.d.ts +0 -14
- package/dist/esm/context/pip-context.js +0 -117
- package/dist/esm/context/pip-context.js.map +0 -1
- package/dist/esm/context/use-devtools-context.d.ts +0 -40
- package/dist/esm/context/use-devtools-context.js +0 -96
- package/dist/esm/context/use-devtools-context.js.map +0 -1
- package/dist/esm/core.d.ts +0 -39
- package/dist/esm/core.js.map +0 -1
- package/dist/esm/devtools.d.ts +0 -1
- package/dist/esm/devtools.js +0 -200
- package/dist/esm/devtools.js.map +0 -1
- package/dist/esm/hooks/use-disable-tabbing.d.ts +0 -6
- package/dist/esm/hooks/use-disable-tabbing.js +0 -23
- package/dist/esm/hooks/use-disable-tabbing.js.map +0 -1
- package/dist/esm/hooks/use-head-changes.d.ts +0 -39
- package/dist/esm/hooks/use-head-changes.js +0 -65
- package/dist/esm/hooks/use-head-changes.js.map +0 -1
- package/dist/esm/index.d.ts +0 -4
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/styles/tokens.d.ts +0 -298
- package/dist/esm/styles/tokens.js +0 -63
- package/dist/esm/styles/tokens.js.map +0 -1
- package/dist/esm/styles/use-styles.d.ts +0 -42
- package/dist/esm/styles/use-styles.js +0 -422
- package/dist/esm/styles/use-styles.js.map +0 -1
- package/dist/esm/tabs/index.d.ts +0 -17
- package/dist/esm/tabs/index.js +0 -25
- package/dist/esm/tabs/index.js.map +0 -1
- package/dist/esm/tabs/plugins-tab.d.ts +0 -1
- package/dist/esm/tabs/plugins-tab.js +0 -88
- package/dist/esm/tabs/plugins-tab.js.map +0 -1
- package/dist/esm/tabs/seo-tab.d.ts +0 -1
- package/dist/esm/tabs/seo-tab.js +0 -296
- package/dist/esm/tabs/seo-tab.js.map +0 -1
- package/dist/esm/tabs/settings-tab.d.ts +0 -1
- package/dist/esm/tabs/settings-tab.js +0 -308
- package/dist/esm/tabs/settings-tab.js.map +0 -1
- package/dist/esm/utils/sanitize.d.ts +0 -3
- package/dist/esm/utils/sanitize.js +0 -31
- package/dist/esm/utils/sanitize.js.map +0 -1
- package/dist/esm/utils/storage.d.ts +0 -5
- package/dist/esm/utils/storage.js +0 -19
- package/dist/esm/utils/storage.js.map +0 -1
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { createComponent, delegateEvents } from 'solid-js/web';
|
|
2
|
+
import { createContext, createSignal, createEffect, onCleanup, createMemo, useContext } from 'solid-js';
|
|
3
|
+
import { createStore } from 'solid-js/store';
|
|
4
|
+
|
|
5
|
+
// src/constants.ts
|
|
6
|
+
var PLUGIN_CONTAINER_ID = "plugin-container";
|
|
7
|
+
var PLUGIN_TITLE_CONTAINER_ID = "plugin-title-container";
|
|
8
|
+
|
|
9
|
+
// src/utils/sanitize.ts
|
|
10
|
+
var tryParseJson = (json) => {
|
|
11
|
+
if (!json) return void 0;
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(json);
|
|
14
|
+
} catch (_e) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var uppercaseFirstLetter = (value) => value.charAt(0).toUpperCase() + value.slice(1);
|
|
19
|
+
var getAllPermutations = (arr) => {
|
|
20
|
+
const res = [];
|
|
21
|
+
function permutate(arr2, start) {
|
|
22
|
+
if (start === arr2.length - 1) {
|
|
23
|
+
res.push([...arr2]);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
for (let i = start; i < arr2.length; i++) {
|
|
27
|
+
[arr2[start], arr2[i]] = [arr2[i], arr2[start]];
|
|
28
|
+
permutate(arr2, start + 1);
|
|
29
|
+
[arr2[start], arr2[i]] = [arr2[i], arr2[start]];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
permutate(arr, 0);
|
|
33
|
+
return res;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/utils/storage.ts
|
|
37
|
+
var getStorageItem = (key) => localStorage.getItem(key);
|
|
38
|
+
var setStorageItem = (key, value) => {
|
|
39
|
+
try {
|
|
40
|
+
localStorage.setItem(key, value);
|
|
41
|
+
} catch (_e) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var TANSTACK_DEVTOOLS = "tanstack_devtools";
|
|
46
|
+
var TANSTACK_DEVTOOLS_STATE = "tanstack_devtools_state";
|
|
47
|
+
var TANSTACK_DEVTOOLS_SETTINGS = "tanstack_devtools_settings";
|
|
48
|
+
|
|
49
|
+
// src/context/devtools-store.ts
|
|
50
|
+
var keyboardModifiers = [
|
|
51
|
+
"Alt",
|
|
52
|
+
"Control",
|
|
53
|
+
"Meta",
|
|
54
|
+
"Shift"
|
|
55
|
+
];
|
|
56
|
+
var initialState = {
|
|
57
|
+
settings: {
|
|
58
|
+
defaultOpen: false,
|
|
59
|
+
hideUntilHover: false,
|
|
60
|
+
position: "bottom-right",
|
|
61
|
+
panelLocation: "bottom",
|
|
62
|
+
openHotkey: ["Shift", "A"],
|
|
63
|
+
requireUrlFlag: false,
|
|
64
|
+
urlFlag: "tanstack-devtools",
|
|
65
|
+
theme: typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
|
66
|
+
},
|
|
67
|
+
state: {
|
|
68
|
+
activeTab: "plugins",
|
|
69
|
+
height: 400,
|
|
70
|
+
activePlugin: void 0,
|
|
71
|
+
persistOpen: false
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var PiPContext = createContext(void 0);
|
|
75
|
+
var PiPProvider = (props) => {
|
|
76
|
+
const [pipWindow, setPipWindow] = createSignal(null);
|
|
77
|
+
const closePipWindow = () => {
|
|
78
|
+
const w = pipWindow();
|
|
79
|
+
if (w != null) {
|
|
80
|
+
w.close();
|
|
81
|
+
setPipWindow(null);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const requestPipWindow = (settings) => {
|
|
85
|
+
if (pipWindow() != null) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const pip = window.open("", "TSDT-Devtools-Panel", `${settings},popup`);
|
|
89
|
+
if (!pip) {
|
|
90
|
+
throw new Error("Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.");
|
|
91
|
+
}
|
|
92
|
+
const meta = typeof import.meta !== "undefined" ? import.meta : null;
|
|
93
|
+
meta?.hot?.on("vite:beforeUpdate", () => {
|
|
94
|
+
localStorage.setItem("pip_open", "false");
|
|
95
|
+
closePipWindow();
|
|
96
|
+
});
|
|
97
|
+
window.addEventListener("beforeunload", () => {
|
|
98
|
+
localStorage.setItem("pip_open", "false");
|
|
99
|
+
closePipWindow();
|
|
100
|
+
});
|
|
101
|
+
pip.document.head.innerHTML = "";
|
|
102
|
+
pip.document.body.innerHTML = "";
|
|
103
|
+
pip.document.title = "TanStack Devtools";
|
|
104
|
+
pip.document.body.style.margin = "0";
|
|
105
|
+
pip.addEventListener("pagehide", () => {
|
|
106
|
+
localStorage.setItem("pip_open", "false");
|
|
107
|
+
closePipWindow();
|
|
108
|
+
});
|
|
109
|
+
[...document.styleSheets].forEach((styleSheet) => {
|
|
110
|
+
try {
|
|
111
|
+
const cssRules = [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
|
|
112
|
+
const style = document.createElement("style");
|
|
113
|
+
const style_node = styleSheet.ownerNode;
|
|
114
|
+
let style_id = "";
|
|
115
|
+
if (style_node && "id" in style_node) {
|
|
116
|
+
style_id = style_node.id;
|
|
117
|
+
}
|
|
118
|
+
if (style_id) {
|
|
119
|
+
style.setAttribute("id", style_id);
|
|
120
|
+
}
|
|
121
|
+
style.textContent = cssRules;
|
|
122
|
+
pip.document.head.appendChild(style);
|
|
123
|
+
} catch (e) {
|
|
124
|
+
const link = document.createElement("link");
|
|
125
|
+
if (styleSheet.href == null) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
link.rel = "stylesheet";
|
|
129
|
+
link.type = styleSheet.type;
|
|
130
|
+
link.media = styleSheet.media.toString();
|
|
131
|
+
link.href = styleSheet.href;
|
|
132
|
+
pip.document.head.appendChild(link);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
delegateEvents(["focusin", "focusout", "pointermove", "keydown", "pointerdown", "pointerup", "click", "mousedown", "input"], pip.document);
|
|
136
|
+
setPipWindow(pip);
|
|
137
|
+
};
|
|
138
|
+
createEffect(() => {
|
|
139
|
+
const gooberStyles = document.querySelector("#_goober");
|
|
140
|
+
const w = pipWindow();
|
|
141
|
+
if (gooberStyles && w) {
|
|
142
|
+
const observer = new MutationObserver(() => {
|
|
143
|
+
const pip_style = w.document.querySelector("#_goober");
|
|
144
|
+
if (pip_style) {
|
|
145
|
+
pip_style.textContent = gooberStyles.textContent;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
observer.observe(gooberStyles, {
|
|
149
|
+
childList: true,
|
|
150
|
+
// observe direct children
|
|
151
|
+
subtree: true,
|
|
152
|
+
// and lower descendants too
|
|
153
|
+
characterDataOldValue: true
|
|
154
|
+
// pass old data to callback
|
|
155
|
+
});
|
|
156
|
+
onCleanup(() => {
|
|
157
|
+
observer.disconnect();
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const value = createMemo(() => ({
|
|
162
|
+
pipWindow: pipWindow(),
|
|
163
|
+
requestPipWindow,
|
|
164
|
+
closePipWindow,
|
|
165
|
+
disabled: props.disabled ?? false
|
|
166
|
+
}));
|
|
167
|
+
return createComponent(PiPContext.Provider, {
|
|
168
|
+
value,
|
|
169
|
+
get children() {
|
|
170
|
+
return props.children;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
var usePiPWindow = () => {
|
|
175
|
+
const context = createMemo(() => {
|
|
176
|
+
const ctx = useContext(PiPContext);
|
|
177
|
+
if (!ctx) {
|
|
178
|
+
throw new Error("usePiPWindow must be used within a PiPProvider");
|
|
179
|
+
}
|
|
180
|
+
return ctx();
|
|
181
|
+
});
|
|
182
|
+
return context;
|
|
183
|
+
};
|
|
184
|
+
var DevtoolsContext = createContext();
|
|
185
|
+
var getSettings = () => {
|
|
186
|
+
const settingsString = getStorageItem(TANSTACK_DEVTOOLS_SETTINGS);
|
|
187
|
+
const settings = tryParseJson(settingsString);
|
|
188
|
+
return {
|
|
189
|
+
...settings
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
var generatePluginId = (plugin, index) => {
|
|
193
|
+
if (plugin.id) {
|
|
194
|
+
return plugin.id;
|
|
195
|
+
}
|
|
196
|
+
if (typeof plugin.name === "string") {
|
|
197
|
+
return `${plugin.name.toLowerCase().replace(" ", "-")}-${index}`;
|
|
198
|
+
}
|
|
199
|
+
return index.toString();
|
|
200
|
+
};
|
|
201
|
+
var getExistingStateFromStorage = (config, plugins) => {
|
|
202
|
+
const existingState = getStorageItem(TANSTACK_DEVTOOLS_STATE);
|
|
203
|
+
const settings = getSettings();
|
|
204
|
+
const state = {
|
|
205
|
+
...initialState,
|
|
206
|
+
plugins: plugins?.map((plugin, i) => {
|
|
207
|
+
const id = generatePluginId(plugin, i);
|
|
208
|
+
return {
|
|
209
|
+
...plugin,
|
|
210
|
+
id
|
|
211
|
+
};
|
|
212
|
+
}) || [],
|
|
213
|
+
state: {
|
|
214
|
+
...initialState.state,
|
|
215
|
+
...existingState ? JSON.parse(existingState) : {}
|
|
216
|
+
},
|
|
217
|
+
settings: {
|
|
218
|
+
...initialState.settings,
|
|
219
|
+
...config,
|
|
220
|
+
...settings
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
return state;
|
|
224
|
+
};
|
|
225
|
+
var DevtoolsProvider = (props) => {
|
|
226
|
+
const [store, setStore] = createStore(getExistingStateFromStorage(props.config, props.plugins));
|
|
227
|
+
const value = {
|
|
228
|
+
store,
|
|
229
|
+
setStore: (updater) => {
|
|
230
|
+
const newState = updater(store);
|
|
231
|
+
const {
|
|
232
|
+
settings,
|
|
233
|
+
state: internalState
|
|
234
|
+
} = newState;
|
|
235
|
+
setStorageItem(TANSTACK_DEVTOOLS_SETTINGS, JSON.stringify(settings));
|
|
236
|
+
setStorageItem(TANSTACK_DEVTOOLS_STATE, JSON.stringify(internalState));
|
|
237
|
+
setStore((prev) => ({
|
|
238
|
+
...prev,
|
|
239
|
+
...newState
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
return createComponent(DevtoolsContext.Provider, {
|
|
244
|
+
value,
|
|
245
|
+
get children() {
|
|
246
|
+
return props.children;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export { DevtoolsContext, DevtoolsProvider, PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID, PiPProvider, TANSTACK_DEVTOOLS, getAllPermutations, initialState, keyboardModifiers, uppercaseFirstLetter, usePiPWindow };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { initialState, DevtoolsProvider, PiPProvider } from './chunk/CEHNENNI.js';
|
|
2
|
+
export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID } from './chunk/CEHNENNI.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
|
+
var TanStackDevtoolsCore = class {
|
|
8
8
|
#config = {
|
|
9
9
|
...initialState.settings
|
|
10
10
|
};
|
|
@@ -29,7 +29,7 @@ class TanStackDevtoolsCore {
|
|
|
29
29
|
const mountTo = el;
|
|
30
30
|
const dispose = render(() => {
|
|
31
31
|
const _self$ = this;
|
|
32
|
-
this.#Component = lazy(() => import(
|
|
32
|
+
this.#Component = lazy(() => import('./devtools/ITBBRMTQ.js'));
|
|
33
33
|
const Devtools = this.#Component;
|
|
34
34
|
this.#eventBus = new ClientEventBus(this.#eventBusConfig);
|
|
35
35
|
this.#eventBus.start();
|
|
@@ -71,8 +71,6 @@ class TanStackDevtoolsCore {
|
|
|
71
71
|
...config
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
}
|
|
75
|
-
export {
|
|
76
|
-
TanStackDevtoolsCore
|
|
77
74
|
};
|
|
78
|
-
|
|
75
|
+
|
|
76
|
+
export { TanStackDevtoolsCore };
|