@oxog/devinspector 1.2.0 → 1.3.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.
- package/CHANGELOG.md +36 -0
- package/LICENSE +0 -0
- package/README.md +85 -28
- package/dist/chunk-LNBLBFDA.js +92 -0
- package/dist/chunk-LNBLBFDA.js.map +1 -0
- package/dist/chunk-PPIEWSZ7.js +32 -0
- package/dist/chunk-PPIEWSZ7.js.map +1 -0
- package/dist/console-monitor-LBNXAQQ4.js +571 -0
- package/dist/console-monitor-LBNXAQQ4.js.map +1 -0
- package/dist/devinspector.umd.js +1782 -1074
- package/dist/devinspector.umd.js.map +1 -1
- package/dist/devinspector.umd.min.js +6 -1
- package/dist/devinspector.umd.min.js.map +1 -1
- package/dist/dom-monitor-IGQZTXMH.js +19 -0
- package/dist/dom-monitor-IGQZTXMH.js.map +1 -0
- package/dist/error-monitor-XDNRO4KS.js +423 -0
- package/dist/error-monitor-XDNRO4KS.js.map +1 -0
- package/dist/index.cjs +5918 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +582 -0
- package/dist/index.d.ts +582 -0
- package/dist/index.js +1983 -0
- package/dist/index.js.map +1 -0
- package/dist/inspector-ui-AFTUEVWA.js +1240 -0
- package/dist/inspector-ui-AFTUEVWA.js.map +1 -0
- package/dist/network-monitor-HUSRKEXE.js +841 -0
- package/dist/network-monitor-HUSRKEXE.js.map +1 -0
- package/dist/performance-monitor-66DQJGOJ.js +544 -0
- package/dist/performance-monitor-66DQJGOJ.js.map +1 -0
- package/dist/state-monitor-PS5Q7NWY.js +19 -0
- package/dist/state-monitor-PS5Q7NWY.js.map +1 -0
- package/dist/storage-monitor-QW634CEJ.js +19 -0
- package/dist/storage-monitor-QW634CEJ.js.map +1 -0
- package/package.json +51 -38
- package/dist/devinspector.cjs.js +0 -5494
- package/dist/devinspector.cjs.js.map +0 -1
- package/dist/devinspector.esm.js +0 -5482
- package/dist/devinspector.esm.js.map +0 -1
- package/dist/types/clean-inspector.d.ts +0 -52
- package/dist/types/core/event-emitter.d.ts +0 -21
- package/dist/types/core/inspector.d.ts +0 -121
- package/dist/types/core/plugin-system.d.ts +0 -60
- package/dist/types/core/storage.d.ts +0 -52
- package/dist/types/core/utils.d.ts +0 -34
- package/dist/types/enhanced-inspector.d.ts +0 -56
- package/dist/types/enhanced-simple.d.ts +0 -46
- package/dist/types/index-simple.d.ts +0 -11
- package/dist/types/index.d.ts +0 -19
- package/dist/types/monitors/console/console-interceptor.d.ts +0 -36
- package/dist/types/monitors/console/console-monitor.d.ts +0 -26
- package/dist/types/monitors/console/log-formatter.d.ts +0 -8
- package/dist/types/monitors/dom/dom-monitor.d.ts +0 -8
- package/dist/types/monitors/error/error-monitor.d.ts +0 -28
- package/dist/types/monitors/error/error-tracker.d.ts +0 -55
- package/dist/types/monitors/error/source-map-support.d.ts +0 -15
- package/dist/types/monitors/network/fetch-interceptor.d.ts +0 -45
- package/dist/types/monitors/network/network-monitor.d.ts +0 -47
- package/dist/types/monitors/network/websocket-monitor.d.ts +0 -44
- package/dist/types/monitors/network/xhr-interceptor.d.ts +0 -25
- package/dist/types/monitors/performance/fps-monitor.d.ts +0 -24
- package/dist/types/monitors/performance/long-task-detector.d.ts +0 -25
- package/dist/types/monitors/performance/memory-monitor.d.ts +0 -30
- package/dist/types/monitors/performance/metrics-collector.d.ts +0 -45
- package/dist/types/monitors/performance/performance-monitor.d.ts +0 -34
- package/dist/types/monitors/state/state-monitor.d.ts +0 -8
- package/dist/types/monitors/storage/storage-monitor.d.ts +0 -8
- package/dist/types/simple-index.d.ts +0 -3
- package/dist/types/simple-inspector.d.ts +0 -24
- package/dist/types/ui/components/floating-widget.d.ts +0 -21
- package/dist/types/ui/components/main-panel.d.ts +0 -38
- package/dist/types/ui/inspector-ui.d.ts +0 -29
- package/dist/types/ui/styles.d.ts +0 -1
|
@@ -0,0 +1,1240 @@
|
|
|
1
|
+
import {
|
|
2
|
+
escapeHtml
|
|
3
|
+
} from "./chunk-PPIEWSZ7.js";
|
|
4
|
+
|
|
5
|
+
// src/ui/components/floating-widget.ts
|
|
6
|
+
var FloatingWidget = class {
|
|
7
|
+
constructor(inspector) {
|
|
8
|
+
this.isDragging = false;
|
|
9
|
+
this.dragOffset = { x: 0, y: 0 };
|
|
10
|
+
this.errorCount = 0;
|
|
11
|
+
this.eventUnsubscribers = [];
|
|
12
|
+
this.inspector = inspector;
|
|
13
|
+
this.element = this.createElement();
|
|
14
|
+
this.boundMouseMove = this.handleMouseMove.bind(this);
|
|
15
|
+
this.boundMouseUp = this.handleMouseUp.bind(this);
|
|
16
|
+
this.setupEventListeners();
|
|
17
|
+
this.updatePosition();
|
|
18
|
+
}
|
|
19
|
+
createElement() {
|
|
20
|
+
const widget = document.createElement("div");
|
|
21
|
+
widget.className = "devinspector-floating-widget";
|
|
22
|
+
widget.innerHTML = "\u{1F50D}";
|
|
23
|
+
widget.title = "DevInspector - Click to toggle, drag to move";
|
|
24
|
+
return widget;
|
|
25
|
+
}
|
|
26
|
+
setupEventListeners() {
|
|
27
|
+
this.element.addEventListener("click", (e) => {
|
|
28
|
+
if (!this.isDragging) {
|
|
29
|
+
this.inspector.toggle();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.element.addEventListener("mousedown", this.handleMouseDown.bind(this));
|
|
33
|
+
document.addEventListener("mousemove", this.boundMouseMove);
|
|
34
|
+
document.addEventListener("mouseup", this.boundMouseUp);
|
|
35
|
+
const unsubErrorCaught = this.inspector.on("error:caught", () => {
|
|
36
|
+
this.errorCount++;
|
|
37
|
+
this.updateAppearance();
|
|
38
|
+
});
|
|
39
|
+
this.eventUnsubscribers.push(unsubErrorCaught);
|
|
40
|
+
const unsubErrorUncaught = this.inspector.on("error:uncaught", () => {
|
|
41
|
+
this.errorCount++;
|
|
42
|
+
this.updateAppearance();
|
|
43
|
+
});
|
|
44
|
+
this.eventUnsubscribers.push(unsubErrorUncaught);
|
|
45
|
+
const unsubInspectorShow = this.inspector.on("inspector:show", () => {
|
|
46
|
+
this.errorCount = 0;
|
|
47
|
+
this.updateAppearance();
|
|
48
|
+
});
|
|
49
|
+
this.eventUnsubscribers.push(unsubInspectorShow);
|
|
50
|
+
}
|
|
51
|
+
handleMouseDown(e) {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
this.isDragging = true;
|
|
54
|
+
const rect = this.element.getBoundingClientRect();
|
|
55
|
+
this.dragOffset = {
|
|
56
|
+
x: e.clientX - rect.left,
|
|
57
|
+
y: e.clientY - rect.top
|
|
58
|
+
};
|
|
59
|
+
this.element.style.cursor = "grabbing";
|
|
60
|
+
this.element.style.zIndex = "1000000";
|
|
61
|
+
}
|
|
62
|
+
handleMouseMove(e) {
|
|
63
|
+
if (!this.isDragging) return;
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
const x = e.clientX - this.dragOffset.x;
|
|
66
|
+
const y = e.clientY - this.dragOffset.y;
|
|
67
|
+
const maxX = window.innerWidth - this.element.offsetWidth;
|
|
68
|
+
const maxY = window.innerHeight - this.element.offsetHeight;
|
|
69
|
+
const clampedX = Math.max(0, Math.min(x, maxX));
|
|
70
|
+
const clampedY = Math.max(0, Math.min(y, maxY));
|
|
71
|
+
this.element.style.left = `${clampedX}px`;
|
|
72
|
+
this.element.style.top = `${clampedY}px`;
|
|
73
|
+
this.element.style.right = "auto";
|
|
74
|
+
this.element.style.bottom = "auto";
|
|
75
|
+
}
|
|
76
|
+
handleMouseUp() {
|
|
77
|
+
if (!this.isDragging) return;
|
|
78
|
+
this.isDragging = false;
|
|
79
|
+
this.element.style.cursor = "pointer";
|
|
80
|
+
this.element.style.zIndex = "999998";
|
|
81
|
+
this.snapToEdge();
|
|
82
|
+
}
|
|
83
|
+
snapToEdge() {
|
|
84
|
+
const rect = this.element.getBoundingClientRect();
|
|
85
|
+
const centerX = rect.left + rect.width / 2;
|
|
86
|
+
const centerY = rect.top + rect.height / 2;
|
|
87
|
+
const windowWidth = window.innerWidth;
|
|
88
|
+
const windowHeight = window.innerHeight;
|
|
89
|
+
const distances = {
|
|
90
|
+
left: centerX,
|
|
91
|
+
right: windowWidth - centerX,
|
|
92
|
+
top: centerY,
|
|
93
|
+
bottom: windowHeight - centerY
|
|
94
|
+
};
|
|
95
|
+
const closestEdge = Object.entries(distances).reduce((a, b) => a[1] < b[1] ? a : b)[0];
|
|
96
|
+
const margin = 20;
|
|
97
|
+
switch (closestEdge) {
|
|
98
|
+
case "left":
|
|
99
|
+
this.element.style.left = `${margin}px`;
|
|
100
|
+
break;
|
|
101
|
+
case "right":
|
|
102
|
+
this.element.style.left = "auto";
|
|
103
|
+
this.element.style.right = `${margin}px`;
|
|
104
|
+
break;
|
|
105
|
+
case "top":
|
|
106
|
+
this.element.style.top = `${margin}px`;
|
|
107
|
+
break;
|
|
108
|
+
case "bottom":
|
|
109
|
+
this.element.style.top = "auto";
|
|
110
|
+
this.element.style.bottom = `${margin}px`;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
updatePosition() {
|
|
115
|
+
const position = this.inspector.getConfig().position;
|
|
116
|
+
const margin = 20;
|
|
117
|
+
this.element.style.top = "auto";
|
|
118
|
+
this.element.style.right = "auto";
|
|
119
|
+
this.element.style.bottom = "auto";
|
|
120
|
+
this.element.style.left = "auto";
|
|
121
|
+
switch (position) {
|
|
122
|
+
case "top-left":
|
|
123
|
+
this.element.style.top = `${margin}px`;
|
|
124
|
+
this.element.style.left = `${margin}px`;
|
|
125
|
+
break;
|
|
126
|
+
case "top-right":
|
|
127
|
+
this.element.style.top = `${margin}px`;
|
|
128
|
+
this.element.style.right = `${margin}px`;
|
|
129
|
+
break;
|
|
130
|
+
case "bottom-left":
|
|
131
|
+
this.element.style.bottom = `${margin}px`;
|
|
132
|
+
this.element.style.left = `${margin}px`;
|
|
133
|
+
break;
|
|
134
|
+
case "bottom-right":
|
|
135
|
+
default:
|
|
136
|
+
this.element.style.bottom = `${margin}px`;
|
|
137
|
+
this.element.style.right = `${margin}px`;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
updateAppearance() {
|
|
142
|
+
if (this.errorCount > 0) {
|
|
143
|
+
this.element.classList.add("has-errors");
|
|
144
|
+
this.element.innerHTML = "\u26A0\uFE0F";
|
|
145
|
+
this.element.title = `DevInspector - ${this.errorCount} error${this.errorCount > 1 ? "s" : ""} detected`;
|
|
146
|
+
} else {
|
|
147
|
+
this.element.classList.remove("has-errors");
|
|
148
|
+
this.element.innerHTML = "\u{1F50D}";
|
|
149
|
+
this.element.title = "DevInspector - Click to toggle, drag to move";
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
show() {
|
|
153
|
+
if (!this.element.parentNode) {
|
|
154
|
+
document.body.appendChild(this.element);
|
|
155
|
+
}
|
|
156
|
+
this.element.style.display = "flex";
|
|
157
|
+
}
|
|
158
|
+
hide() {
|
|
159
|
+
this.element.style.display = "none";
|
|
160
|
+
}
|
|
161
|
+
destroy() {
|
|
162
|
+
document.removeEventListener("mousemove", this.boundMouseMove);
|
|
163
|
+
document.removeEventListener("mouseup", this.boundMouseUp);
|
|
164
|
+
this.eventUnsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
165
|
+
this.eventUnsubscribers = [];
|
|
166
|
+
if (this.element.parentNode) {
|
|
167
|
+
this.element.parentNode.removeChild(this.element);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
getElement() {
|
|
171
|
+
return this.element;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// src/ui/components/main-panel.ts
|
|
176
|
+
var MainPanel = class {
|
|
177
|
+
constructor(inspector) {
|
|
178
|
+
this.tabs = /* @__PURE__ */ new Map();
|
|
179
|
+
this.activeTab = null;
|
|
180
|
+
this.isDragging = false;
|
|
181
|
+
this.dragOffset = { x: 0, y: 0 };
|
|
182
|
+
this.isResizing = false;
|
|
183
|
+
this.badgeUpdateInterval = null;
|
|
184
|
+
this.boundMouseMove = (event) => this.handleMouseMove(event);
|
|
185
|
+
this.boundMouseUp = () => this.handleMouseUp();
|
|
186
|
+
this.inspector = inspector;
|
|
187
|
+
this.element = this.createElement();
|
|
188
|
+
this.setupEventListeners();
|
|
189
|
+
this.updatePosition();
|
|
190
|
+
}
|
|
191
|
+
createElement() {
|
|
192
|
+
const panel = document.createElement("div");
|
|
193
|
+
panel.className = `devinspector position-${this.inspector.getConfig().position}`;
|
|
194
|
+
panel.style.width = "600px";
|
|
195
|
+
panel.style.height = "400px";
|
|
196
|
+
panel.style.display = "none";
|
|
197
|
+
this.headerElement = document.createElement("div");
|
|
198
|
+
this.headerElement.className = "devinspector-header";
|
|
199
|
+
this.headerElement.innerHTML = `
|
|
200
|
+
<h3 class="devinspector-title">DevInspector</h3>
|
|
201
|
+
<div class="devinspector-controls">
|
|
202
|
+
<button class="devinspector-control settings" title="Settings">\u2699\uFE0F</button>
|
|
203
|
+
<button class="devinspector-control minimize" title="Minimize">\u2212</button>
|
|
204
|
+
<button class="devinspector-control close" title="Close">\xD7</button>
|
|
205
|
+
</div>
|
|
206
|
+
`;
|
|
207
|
+
this.tabsElement = document.createElement("div");
|
|
208
|
+
this.tabsElement.className = "devinspector-tabs";
|
|
209
|
+
this.bodyElement = document.createElement("div");
|
|
210
|
+
this.bodyElement.className = "devinspector-body";
|
|
211
|
+
const resizer = document.createElement("div");
|
|
212
|
+
resizer.className = "devinspector-resizer";
|
|
213
|
+
panel.appendChild(this.headerElement);
|
|
214
|
+
panel.appendChild(this.tabsElement);
|
|
215
|
+
panel.appendChild(this.bodyElement);
|
|
216
|
+
panel.appendChild(resizer);
|
|
217
|
+
return panel;
|
|
218
|
+
}
|
|
219
|
+
setupEventListeners() {
|
|
220
|
+
const controls = this.headerElement.querySelectorAll(".devinspector-control");
|
|
221
|
+
controls.forEach((control) => {
|
|
222
|
+
control.addEventListener("click", (e) => {
|
|
223
|
+
e.stopPropagation();
|
|
224
|
+
const className = control.className;
|
|
225
|
+
if (className.includes("minimize")) {
|
|
226
|
+
this.inspector.minimize();
|
|
227
|
+
} else if (className.includes("close")) {
|
|
228
|
+
this.inspector.hide();
|
|
229
|
+
} else if (className.includes("settings")) {
|
|
230
|
+
this.showSettings();
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
this.headerElement.addEventListener("mousedown", this.handleHeaderMouseDown.bind(this));
|
|
235
|
+
document.addEventListener("mousemove", this.boundMouseMove);
|
|
236
|
+
document.addEventListener("mouseup", this.boundMouseUp);
|
|
237
|
+
const resizer = this.element.querySelector(".devinspector-resizer");
|
|
238
|
+
resizer.addEventListener("mousedown", this.handleResizerMouseDown.bind(this));
|
|
239
|
+
this.tabsElement.addEventListener("click", (e) => {
|
|
240
|
+
const tab = e.target.closest(".devinspector-tab");
|
|
241
|
+
if (tab) {
|
|
242
|
+
const tabId = tab.dataset.tabId;
|
|
243
|
+
if (tabId) {
|
|
244
|
+
this.setActiveTab(tabId);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
this.badgeUpdateInterval = window.setInterval(() => this.updateBadges(), 1e3);
|
|
249
|
+
}
|
|
250
|
+
handleHeaderMouseDown(e) {
|
|
251
|
+
if (e.target.closest(".devinspector-control")) return;
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
this.isDragging = true;
|
|
254
|
+
const rect = this.element.getBoundingClientRect();
|
|
255
|
+
this.dragOffset = {
|
|
256
|
+
x: e.clientX - rect.left,
|
|
257
|
+
y: e.clientY - rect.top
|
|
258
|
+
};
|
|
259
|
+
this.headerElement.style.cursor = "grabbing";
|
|
260
|
+
this.element.style.zIndex = "1000000";
|
|
261
|
+
}
|
|
262
|
+
handleResizerMouseDown(e) {
|
|
263
|
+
e.preventDefault();
|
|
264
|
+
e.stopPropagation();
|
|
265
|
+
this.isResizing = true;
|
|
266
|
+
this.element.style.zIndex = "1000000";
|
|
267
|
+
document.body.style.cursor = "nw-resize";
|
|
268
|
+
}
|
|
269
|
+
handleMouseMove(e) {
|
|
270
|
+
if (this.isDragging) {
|
|
271
|
+
e.preventDefault();
|
|
272
|
+
const x = e.clientX - this.dragOffset.x;
|
|
273
|
+
const y = e.clientY - this.dragOffset.y;
|
|
274
|
+
const maxX = window.innerWidth - this.element.offsetWidth;
|
|
275
|
+
const maxY = window.innerHeight - this.element.offsetHeight;
|
|
276
|
+
const clampedX = Math.max(0, Math.min(x, maxX));
|
|
277
|
+
const clampedY = Math.max(0, Math.min(y, maxY));
|
|
278
|
+
this.element.style.left = `${clampedX}px`;
|
|
279
|
+
this.element.style.top = `${clampedY}px`;
|
|
280
|
+
this.element.style.right = "auto";
|
|
281
|
+
this.element.style.bottom = "auto";
|
|
282
|
+
} else if (this.isResizing) {
|
|
283
|
+
e.preventDefault();
|
|
284
|
+
const rect = this.element.getBoundingClientRect();
|
|
285
|
+
const newWidth = e.clientX - rect.left;
|
|
286
|
+
const newHeight = e.clientY - rect.top;
|
|
287
|
+
const minWidth = 300;
|
|
288
|
+
const minHeight = 200;
|
|
289
|
+
const maxWidth = window.innerWidth - rect.left;
|
|
290
|
+
const maxHeight = window.innerHeight - rect.top;
|
|
291
|
+
const width = Math.max(minWidth, Math.min(newWidth, maxWidth));
|
|
292
|
+
const height = Math.max(minHeight, Math.min(newHeight, maxHeight));
|
|
293
|
+
this.element.style.width = `${width}px`;
|
|
294
|
+
this.element.style.height = `${height}px`;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
handleMouseUp() {
|
|
298
|
+
if (this.isDragging) {
|
|
299
|
+
this.isDragging = false;
|
|
300
|
+
this.headerElement.style.cursor = "move";
|
|
301
|
+
this.element.style.zIndex = "999999";
|
|
302
|
+
}
|
|
303
|
+
if (this.isResizing) {
|
|
304
|
+
this.isResizing = false;
|
|
305
|
+
this.element.style.zIndex = "999999";
|
|
306
|
+
document.body.style.cursor = "auto";
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
updatePosition() {
|
|
310
|
+
const position = this.inspector.getConfig().position;
|
|
311
|
+
this.element.classList.remove(
|
|
312
|
+
"position-top-left",
|
|
313
|
+
"position-top-right",
|
|
314
|
+
"position-bottom-left",
|
|
315
|
+
"position-bottom-right"
|
|
316
|
+
);
|
|
317
|
+
this.element.classList.add(`position-${position}`);
|
|
318
|
+
}
|
|
319
|
+
showSettings() {
|
|
320
|
+
console.log("Settings not implemented yet");
|
|
321
|
+
}
|
|
322
|
+
addTab(config) {
|
|
323
|
+
this.tabs.set(config.id, config);
|
|
324
|
+
const tab = document.createElement("button");
|
|
325
|
+
tab.className = "devinspector-tab";
|
|
326
|
+
tab.dataset.tabId = config.id;
|
|
327
|
+
tab.textContent = config.label;
|
|
328
|
+
if (config.badge) {
|
|
329
|
+
const badge = document.createElement("span");
|
|
330
|
+
badge.className = "devinspector-tab-badge";
|
|
331
|
+
badge.textContent = "0";
|
|
332
|
+
tab.appendChild(badge);
|
|
333
|
+
}
|
|
334
|
+
this.tabsElement.appendChild(tab);
|
|
335
|
+
const panel = document.createElement("div");
|
|
336
|
+
panel.className = "devinspector-panel";
|
|
337
|
+
panel.dataset.panelId = config.id;
|
|
338
|
+
panel.appendChild(config.content);
|
|
339
|
+
this.bodyElement.appendChild(panel);
|
|
340
|
+
if (this.tabs.size === 1) {
|
|
341
|
+
this.setActiveTab(config.id);
|
|
342
|
+
}
|
|
343
|
+
this.updateBadges();
|
|
344
|
+
}
|
|
345
|
+
removeTab(tabId) {
|
|
346
|
+
if (!this.tabs.has(tabId)) return;
|
|
347
|
+
this.tabs.delete(tabId);
|
|
348
|
+
const tab = Array.from(this.tabsElement.querySelectorAll(".devinspector-tab")).find((el) => el.dataset.tabId === tabId);
|
|
349
|
+
if (tab) {
|
|
350
|
+
tab.remove();
|
|
351
|
+
}
|
|
352
|
+
const panel = Array.from(this.bodyElement.querySelectorAll(".devinspector-panel")).find((el) => el.dataset.panelId === tabId);
|
|
353
|
+
if (panel) {
|
|
354
|
+
panel.remove();
|
|
355
|
+
}
|
|
356
|
+
if (this.activeTab === tabId) {
|
|
357
|
+
const firstTab = this.tabs.keys().next().value;
|
|
358
|
+
if (firstTab) {
|
|
359
|
+
this.setActiveTab(firstTab);
|
|
360
|
+
} else {
|
|
361
|
+
this.activeTab = null;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
setActiveTab(tabId) {
|
|
366
|
+
if (!this.tabs.has(tabId)) return;
|
|
367
|
+
this.activeTab = tabId;
|
|
368
|
+
this.tabsElement.querySelectorAll(".devinspector-tab").forEach((tab) => {
|
|
369
|
+
const htmlTab = tab;
|
|
370
|
+
tab.classList.toggle("active", htmlTab.dataset.tabId === tabId);
|
|
371
|
+
});
|
|
372
|
+
this.bodyElement.querySelectorAll(".devinspector-panel").forEach((panel) => {
|
|
373
|
+
const htmlPanel = panel;
|
|
374
|
+
panel.classList.toggle("active", htmlPanel.dataset.panelId === tabId);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
updateBadges() {
|
|
378
|
+
this.tabs.forEach((config, tabId) => {
|
|
379
|
+
if (config.badge) {
|
|
380
|
+
const count = config.badge();
|
|
381
|
+
const tab = Array.from(this.tabsElement.querySelectorAll(".devinspector-tab")).find((el) => el.dataset.tabId === tabId);
|
|
382
|
+
const badge = tab == null ? void 0 : tab.querySelector(".devinspector-tab-badge");
|
|
383
|
+
if (badge) {
|
|
384
|
+
badge.textContent = count.toString();
|
|
385
|
+
badge.style.display = count > 0 ? "inline-block" : "none";
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
show() {
|
|
391
|
+
if (!this.element.parentNode) {
|
|
392
|
+
document.body.appendChild(this.element);
|
|
393
|
+
}
|
|
394
|
+
this.element.style.display = "flex";
|
|
395
|
+
this.element.classList.remove("minimized");
|
|
396
|
+
}
|
|
397
|
+
hide() {
|
|
398
|
+
this.element.style.display = "none";
|
|
399
|
+
}
|
|
400
|
+
minimize() {
|
|
401
|
+
this.element.classList.add("minimized");
|
|
402
|
+
}
|
|
403
|
+
destroy() {
|
|
404
|
+
if (this.badgeUpdateInterval !== null) {
|
|
405
|
+
clearInterval(this.badgeUpdateInterval);
|
|
406
|
+
this.badgeUpdateInterval = null;
|
|
407
|
+
}
|
|
408
|
+
document.removeEventListener("mousemove", this.boundMouseMove);
|
|
409
|
+
document.removeEventListener("mouseup", this.boundMouseUp);
|
|
410
|
+
if (this.element.parentNode) {
|
|
411
|
+
this.element.parentNode.removeChild(this.element);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
getElement() {
|
|
415
|
+
return this.element;
|
|
416
|
+
}
|
|
417
|
+
getActiveTab() {
|
|
418
|
+
return this.activeTab;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// src/ui/styles.ts
|
|
423
|
+
var createStyles = (theme = "dark") => {
|
|
424
|
+
const colors = theme === "dark" ? {
|
|
425
|
+
primary: "#1e1e1e",
|
|
426
|
+
secondary: "#2d2d30",
|
|
427
|
+
tertiary: "#3e3e42",
|
|
428
|
+
accent: "#007acc",
|
|
429
|
+
text: "#cccccc",
|
|
430
|
+
textSecondary: "#9d9d9d",
|
|
431
|
+
border: "#3e3e42",
|
|
432
|
+
success: "#4caf50",
|
|
433
|
+
warning: "#ff9800",
|
|
434
|
+
error: "#f44336",
|
|
435
|
+
info: "#2196f3"
|
|
436
|
+
} : {
|
|
437
|
+
primary: "#ffffff",
|
|
438
|
+
secondary: "#f5f5f5",
|
|
439
|
+
tertiary: "#e0e0e0",
|
|
440
|
+
accent: "#1976d2",
|
|
441
|
+
text: "#333333",
|
|
442
|
+
textSecondary: "#666666",
|
|
443
|
+
border: "#ddd",
|
|
444
|
+
success: "#4caf50",
|
|
445
|
+
warning: "#ff9800",
|
|
446
|
+
error: "#f44336",
|
|
447
|
+
info: "#2196f3"
|
|
448
|
+
};
|
|
449
|
+
return `
|
|
450
|
+
.devinspector {
|
|
451
|
+
position: fixed;
|
|
452
|
+
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
453
|
+
font-size: 12px;
|
|
454
|
+
line-height: 1.4;
|
|
455
|
+
color: ${colors.text};
|
|
456
|
+
background: ${colors.primary};
|
|
457
|
+
border: 1px solid ${colors.border};
|
|
458
|
+
border-radius: 8px;
|
|
459
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
|
460
|
+
z-index: 999999;
|
|
461
|
+
min-width: 300px;
|
|
462
|
+
min-height: 200px;
|
|
463
|
+
resize: both;
|
|
464
|
+
overflow: hidden;
|
|
465
|
+
backdrop-filter: blur(10px);
|
|
466
|
+
transition: all 0.3s ease;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.devinspector.fullwidth {
|
|
470
|
+
width: calc(100vw - 40px) !important;
|
|
471
|
+
left: 20px !important;
|
|
472
|
+
right: 20px !important;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.devinspector.bottom-sidebar {
|
|
476
|
+
bottom: 0 !important;
|
|
477
|
+
left: 0 !important;
|
|
478
|
+
right: 0 !important;
|
|
479
|
+
top: auto !important;
|
|
480
|
+
width: 100vw !important;
|
|
481
|
+
height: 40vh !important;
|
|
482
|
+
border-radius: 0 !important;
|
|
483
|
+
border-left: none !important;
|
|
484
|
+
border-right: none !important;
|
|
485
|
+
border-bottom: none !important;
|
|
486
|
+
resize: vertical;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.devinspector.bottom-sidebar .devinspector-header {
|
|
490
|
+
border-radius: 0;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.devinspector * {
|
|
494
|
+
box-sizing: border-box;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.devinspector.position-top-left {
|
|
498
|
+
top: 20px;
|
|
499
|
+
left: 20px;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.devinspector.position-top-right {
|
|
503
|
+
top: 20px;
|
|
504
|
+
right: 20px;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
.devinspector.position-bottom-left {
|
|
508
|
+
bottom: 20px;
|
|
509
|
+
left: 20px;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.devinspector.position-bottom-right {
|
|
513
|
+
bottom: 20px;
|
|
514
|
+
right: 20px;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.devinspector.position-bottom-sidebar {
|
|
518
|
+
bottom: 0;
|
|
519
|
+
left: 0;
|
|
520
|
+
right: 0;
|
|
521
|
+
width: 100vw;
|
|
522
|
+
height: 40vh;
|
|
523
|
+
border-radius: 0;
|
|
524
|
+
border-left: none;
|
|
525
|
+
border-right: none;
|
|
526
|
+
border-bottom: none;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.devinspector.minimized {
|
|
530
|
+
width: 50px !important;
|
|
531
|
+
height: 50px !important;
|
|
532
|
+
overflow: hidden;
|
|
533
|
+
border-radius: 50%;
|
|
534
|
+
cursor: pointer;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.devinspector.minimized .devinspector-header {
|
|
538
|
+
height: 100%;
|
|
539
|
+
border-radius: 50%;
|
|
540
|
+
justify-content: center;
|
|
541
|
+
align-items: center;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.devinspector.minimized .devinspector-body,
|
|
545
|
+
.devinspector.minimized .devinspector-tabs,
|
|
546
|
+
.devinspector.minimized .devinspector-title {
|
|
547
|
+
display: none !important;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.devinspector-header {
|
|
551
|
+
display: flex;
|
|
552
|
+
align-items: center;
|
|
553
|
+
justify-content: space-between;
|
|
554
|
+
padding: 8px 12px;
|
|
555
|
+
background: ${colors.secondary};
|
|
556
|
+
border-bottom: 1px solid ${colors.border};
|
|
557
|
+
cursor: move;
|
|
558
|
+
user-select: none;
|
|
559
|
+
border-radius: 8px 8px 0 0;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.devinspector-title {
|
|
563
|
+
font-weight: 600;
|
|
564
|
+
color: ${colors.text};
|
|
565
|
+
margin: 0;
|
|
566
|
+
font-size: 13px;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.devinspector-controls {
|
|
570
|
+
display: flex;
|
|
571
|
+
gap: 4px;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.devinspector-control {
|
|
575
|
+
width: 18px;
|
|
576
|
+
height: 18px;
|
|
577
|
+
border: none;
|
|
578
|
+
border-radius: 3px;
|
|
579
|
+
cursor: pointer;
|
|
580
|
+
display: flex;
|
|
581
|
+
align-items: center;
|
|
582
|
+
justify-content: center;
|
|
583
|
+
font-size: 12px;
|
|
584
|
+
font-weight: bold;
|
|
585
|
+
transition: all 0.2s ease;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.devinspector-control:hover {
|
|
589
|
+
opacity: 0.8;
|
|
590
|
+
transform: scale(1.1);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.devinspector-control.minimize {
|
|
594
|
+
background: ${colors.warning};
|
|
595
|
+
color: white;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.devinspector-control.close {
|
|
599
|
+
background: ${colors.error};
|
|
600
|
+
color: white;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.devinspector-control.settings {
|
|
604
|
+
background: ${colors.tertiary};
|
|
605
|
+
color: ${colors.text};
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.devinspector-tabs {
|
|
609
|
+
display: flex;
|
|
610
|
+
background: ${colors.secondary};
|
|
611
|
+
border-bottom: 1px solid ${colors.border};
|
|
612
|
+
overflow-x: auto;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.devinspector-tab {
|
|
616
|
+
padding: 8px 16px;
|
|
617
|
+
background: none;
|
|
618
|
+
border: none;
|
|
619
|
+
color: ${colors.textSecondary};
|
|
620
|
+
cursor: pointer;
|
|
621
|
+
font-family: inherit;
|
|
622
|
+
font-size: 11px;
|
|
623
|
+
font-weight: 500;
|
|
624
|
+
text-transform: uppercase;
|
|
625
|
+
letter-spacing: 0.5px;
|
|
626
|
+
border-bottom: 2px solid transparent;
|
|
627
|
+
transition: all 0.2s ease;
|
|
628
|
+
white-space: nowrap;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.devinspector-tab:hover {
|
|
632
|
+
color: ${colors.text};
|
|
633
|
+
background: ${colors.tertiary};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
.devinspector-tab.active {
|
|
637
|
+
color: ${colors.accent};
|
|
638
|
+
border-bottom-color: ${colors.accent};
|
|
639
|
+
background: ${colors.primary};
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.devinspector-tab-badge {
|
|
643
|
+
display: inline-block;
|
|
644
|
+
background: ${colors.error};
|
|
645
|
+
color: white;
|
|
646
|
+
border-radius: 10px;
|
|
647
|
+
padding: 1px 6px;
|
|
648
|
+
font-size: 10px;
|
|
649
|
+
margin-left: 6px;
|
|
650
|
+
min-width: 16px;
|
|
651
|
+
text-align: center;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
.devinspector-body {
|
|
655
|
+
flex: 1;
|
|
656
|
+
overflow: hidden;
|
|
657
|
+
display: flex;
|
|
658
|
+
flex-direction: column;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.devinspector-panel {
|
|
662
|
+
flex: 1;
|
|
663
|
+
display: none;
|
|
664
|
+
flex-direction: column;
|
|
665
|
+
overflow: hidden;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
.devinspector-panel.active {
|
|
669
|
+
display: flex;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
.devinspector-toolbar {
|
|
673
|
+
display: flex;
|
|
674
|
+
align-items: center;
|
|
675
|
+
gap: 8px;
|
|
676
|
+
padding: 8px 12px;
|
|
677
|
+
background: ${colors.secondary};
|
|
678
|
+
border-bottom: 1px solid ${colors.border};
|
|
679
|
+
flex-wrap: wrap;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
.devinspector-search {
|
|
683
|
+
flex: 1;
|
|
684
|
+
min-width: 200px;
|
|
685
|
+
padding: 4px 8px;
|
|
686
|
+
border: 1px solid ${colors.border};
|
|
687
|
+
border-radius: 4px;
|
|
688
|
+
background: ${colors.primary};
|
|
689
|
+
color: ${colors.text};
|
|
690
|
+
font-family: inherit;
|
|
691
|
+
font-size: 11px;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.devinspector-search::placeholder {
|
|
695
|
+
color: ${colors.textSecondary};
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
.devinspector-button {
|
|
699
|
+
padding: 4px 8px;
|
|
700
|
+
border: 1px solid ${colors.border};
|
|
701
|
+
border-radius: 4px;
|
|
702
|
+
background: ${colors.tertiary};
|
|
703
|
+
color: ${colors.text};
|
|
704
|
+
cursor: pointer;
|
|
705
|
+
font-family: inherit;
|
|
706
|
+
font-size: 11px;
|
|
707
|
+
transition: all 0.2s ease;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
.devinspector-button:hover {
|
|
711
|
+
background: ${colors.accent};
|
|
712
|
+
color: white;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.devinspector-button.active {
|
|
716
|
+
background: ${colors.accent};
|
|
717
|
+
color: white;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.devinspector-content {
|
|
721
|
+
flex: 1;
|
|
722
|
+
overflow: auto;
|
|
723
|
+
padding: 8px;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.devinspector-list {
|
|
727
|
+
list-style: none;
|
|
728
|
+
margin: 0;
|
|
729
|
+
padding: 0;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.devinspector-list-item {
|
|
733
|
+
padding: 8px 12px;
|
|
734
|
+
border-bottom: 1px solid ${colors.border};
|
|
735
|
+
cursor: pointer;
|
|
736
|
+
transition: background 0.2s ease;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.devinspector-list-item:hover {
|
|
740
|
+
background: ${colors.secondary};
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
.devinspector-list-item.selected {
|
|
744
|
+
background: ${colors.accent};
|
|
745
|
+
color: white;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.devinspector-timestamp {
|
|
749
|
+
color: ${colors.textSecondary};
|
|
750
|
+
font-size: 10px;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.devinspector-status {
|
|
754
|
+
display: inline-block;
|
|
755
|
+
padding: 2px 6px;
|
|
756
|
+
border-radius: 3px;
|
|
757
|
+
font-size: 10px;
|
|
758
|
+
font-weight: bold;
|
|
759
|
+
text-transform: uppercase;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.devinspector-status.success {
|
|
763
|
+
background: ${colors.success};
|
|
764
|
+
color: white;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
.devinspector-status.error {
|
|
768
|
+
background: ${colors.error};
|
|
769
|
+
color: white;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
.devinspector-status.warning {
|
|
773
|
+
background: ${colors.warning};
|
|
774
|
+
color: white;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
.devinspector-status.info {
|
|
778
|
+
background: ${colors.info};
|
|
779
|
+
color: white;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.devinspector-json {
|
|
783
|
+
font-family: 'Monaco', 'Menlo', monospace;
|
|
784
|
+
font-size: 11px;
|
|
785
|
+
line-height: 1.4;
|
|
786
|
+
white-space: pre-wrap;
|
|
787
|
+
word-break: break-word;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
.devinspector-json .json-key {
|
|
791
|
+
color: ${theme === "dark" ? "#9cdcfe" : "#0451a5"};
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
.devinspector-json .json-string {
|
|
795
|
+
color: ${theme === "dark" ? "#ce9178" : "#a31515"};
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
.devinspector-json .json-number {
|
|
799
|
+
color: ${theme === "dark" ? "#b5cea8" : "#09885a"};
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
.devinspector-json .json-boolean {
|
|
803
|
+
color: ${theme === "dark" ? "#569cd6" : "#0000ff"};
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
.devinspector-json .json-null {
|
|
807
|
+
color: ${theme === "dark" ? "#569cd6" : "#0000ff"};
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
.devinspector-console-entry {
|
|
811
|
+
display: flex;
|
|
812
|
+
align-items: flex-start;
|
|
813
|
+
gap: 8px;
|
|
814
|
+
padding: 4px 8px;
|
|
815
|
+
border-bottom: 1px solid ${colors.border};
|
|
816
|
+
font-family: 'Monaco', 'Menlo', monospace;
|
|
817
|
+
font-size: 11px;
|
|
818
|
+
line-height: 1.4;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
.devinspector-console-entry.log {
|
|
822
|
+
color: ${colors.text};
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
.devinspector-console-entry.info {
|
|
826
|
+
color: ${colors.info};
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
.devinspector-console-entry.warn {
|
|
830
|
+
color: ${colors.warning};
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
.devinspector-console-entry.error {
|
|
834
|
+
color: ${colors.error};
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
.devinspector-console-entry.debug {
|
|
838
|
+
color: ${colors.textSecondary};
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
.devinspector-console-level {
|
|
842
|
+
font-weight: bold;
|
|
843
|
+
text-transform: uppercase;
|
|
844
|
+
font-size: 10px;
|
|
845
|
+
min-width: 40px;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
.devinspector-chart {
|
|
849
|
+
height: 100px;
|
|
850
|
+
background: ${colors.secondary};
|
|
851
|
+
border: 1px solid ${colors.border};
|
|
852
|
+
border-radius: 4px;
|
|
853
|
+
margin: 8px 0;
|
|
854
|
+
position: relative;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
.devinspector-metric {
|
|
858
|
+
display: flex;
|
|
859
|
+
justify-content: space-between;
|
|
860
|
+
align-items: center;
|
|
861
|
+
padding: 8px;
|
|
862
|
+
background: ${colors.secondary};
|
|
863
|
+
border: 1px solid ${colors.border};
|
|
864
|
+
border-radius: 4px;
|
|
865
|
+
margin: 4px 0;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
.devinspector-metric-label {
|
|
869
|
+
font-weight: 500;
|
|
870
|
+
color: ${colors.text};
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.devinspector-metric-value {
|
|
874
|
+
font-weight: bold;
|
|
875
|
+
color: ${colors.accent};
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.devinspector-error-group {
|
|
879
|
+
border-left: 4px solid ${colors.error};
|
|
880
|
+
padding-left: 8px;
|
|
881
|
+
margin: 8px 0;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
.devinspector-error-message {
|
|
885
|
+
font-weight: bold;
|
|
886
|
+
color: ${colors.error};
|
|
887
|
+
margin-bottom: 4px;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
.devinspector-error-stack {
|
|
891
|
+
font-family: 'Monaco', 'Menlo', monospace;
|
|
892
|
+
font-size: 10px;
|
|
893
|
+
color: ${colors.textSecondary};
|
|
894
|
+
background: ${colors.secondary};
|
|
895
|
+
padding: 8px;
|
|
896
|
+
border-radius: 4px;
|
|
897
|
+
overflow-x: auto;
|
|
898
|
+
white-space: pre;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
.devinspector-resizer {
|
|
902
|
+
position: absolute;
|
|
903
|
+
bottom: 0;
|
|
904
|
+
right: 0;
|
|
905
|
+
width: 16px;
|
|
906
|
+
height: 16px;
|
|
907
|
+
cursor: nw-resize;
|
|
908
|
+
background: linear-gradient(
|
|
909
|
+
-45deg,
|
|
910
|
+
transparent 0%,
|
|
911
|
+
transparent 40%,
|
|
912
|
+
${colors.border} 40%,
|
|
913
|
+
${colors.border} 60%,
|
|
914
|
+
transparent 60%,
|
|
915
|
+
transparent 100%
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
.devinspector-floating-widget {
|
|
920
|
+
position: fixed;
|
|
921
|
+
width: 60px;
|
|
922
|
+
height: 60px;
|
|
923
|
+
background: ${colors.accent};
|
|
924
|
+
border-radius: 50%;
|
|
925
|
+
display: flex;
|
|
926
|
+
align-items: center;
|
|
927
|
+
justify-content: center;
|
|
928
|
+
cursor: pointer;
|
|
929
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
|
|
930
|
+
z-index: 999998;
|
|
931
|
+
transition: all 0.3s ease;
|
|
932
|
+
color: white;
|
|
933
|
+
font-weight: bold;
|
|
934
|
+
font-size: 14px;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
.devinspector-floating-widget:hover {
|
|
938
|
+
transform: scale(1.1);
|
|
939
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
.devinspector-floating-widget.has-errors {
|
|
943
|
+
background: ${colors.error};
|
|
944
|
+
animation: pulse 2s infinite;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
@keyframes pulse {
|
|
948
|
+
0% { opacity: 1; }
|
|
949
|
+
50% { opacity: 0.7; }
|
|
950
|
+
100% { opacity: 1; }
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/* Scrollbar styles */
|
|
954
|
+
.devinspector *::-webkit-scrollbar {
|
|
955
|
+
width: 8px;
|
|
956
|
+
height: 8px;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
.devinspector *::-webkit-scrollbar-track {
|
|
960
|
+
background: ${colors.secondary};
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
.devinspector *::-webkit-scrollbar-thumb {
|
|
964
|
+
background: ${colors.tertiary};
|
|
965
|
+
border-radius: 4px;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
.devinspector *::-webkit-scrollbar-thumb:hover {
|
|
969
|
+
background: ${colors.accent};
|
|
970
|
+
}
|
|
971
|
+
`;
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
// src/ui/inspector-ui.ts
|
|
975
|
+
var DevInspectorUI = class {
|
|
976
|
+
constructor(inspector) {
|
|
977
|
+
this.styleElement = null;
|
|
978
|
+
this.isVisible = false;
|
|
979
|
+
this.isMinimized = false;
|
|
980
|
+
this.inspector = inspector;
|
|
981
|
+
this.floatingWidget = new FloatingWidget(inspector);
|
|
982
|
+
this.mainPanel = new MainPanel(inspector);
|
|
983
|
+
}
|
|
984
|
+
async init() {
|
|
985
|
+
this.injectStyles();
|
|
986
|
+
this.setupTabs();
|
|
987
|
+
this.setupEventListeners();
|
|
988
|
+
this.floatingWidget.show();
|
|
989
|
+
}
|
|
990
|
+
injectStyles() {
|
|
991
|
+
this.styleElement = document.createElement("style");
|
|
992
|
+
const theme = this.inspector.getConfig().theme;
|
|
993
|
+
const prefersDark = typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
994
|
+
const resolvedTheme = theme === "auto" ? prefersDark ? "dark" : "light" : theme;
|
|
995
|
+
this.styleElement.textContent = createStyles(resolvedTheme);
|
|
996
|
+
document.head.appendChild(this.styleElement);
|
|
997
|
+
}
|
|
998
|
+
setupTabs() {
|
|
999
|
+
const networkTab = {
|
|
1000
|
+
id: "network",
|
|
1001
|
+
label: "Network",
|
|
1002
|
+
badge: () => this.inspector.getStorage("network").getSize(),
|
|
1003
|
+
content: this.createNetworkPanel()
|
|
1004
|
+
};
|
|
1005
|
+
const consoleTab = {
|
|
1006
|
+
id: "console",
|
|
1007
|
+
label: "Console",
|
|
1008
|
+
badge: () => this.inspector.getStorage("console").getSize(),
|
|
1009
|
+
content: this.createConsolePanel()
|
|
1010
|
+
};
|
|
1011
|
+
const performanceTab = {
|
|
1012
|
+
id: "performance",
|
|
1013
|
+
label: "Performance",
|
|
1014
|
+
content: this.createPerformancePanel()
|
|
1015
|
+
};
|
|
1016
|
+
const errorsTab = {
|
|
1017
|
+
id: "errors",
|
|
1018
|
+
label: "Errors",
|
|
1019
|
+
badge: () => this.inspector.getStorage("error").getSize(),
|
|
1020
|
+
content: this.createErrorsPanel()
|
|
1021
|
+
};
|
|
1022
|
+
this.mainPanel.addTab(networkTab);
|
|
1023
|
+
this.mainPanel.addTab(consoleTab);
|
|
1024
|
+
this.mainPanel.addTab(performanceTab);
|
|
1025
|
+
this.mainPanel.addTab(errorsTab);
|
|
1026
|
+
}
|
|
1027
|
+
createNetworkPanel() {
|
|
1028
|
+
const panel = document.createElement("div");
|
|
1029
|
+
panel.innerHTML = `
|
|
1030
|
+
<div class="devinspector-toolbar">
|
|
1031
|
+
<input type="text" class="devinspector-search" placeholder="Filter requests...">
|
|
1032
|
+
<button class="devinspector-button">Clear</button>
|
|
1033
|
+
<button class="devinspector-button">Export</button>
|
|
1034
|
+
</div>
|
|
1035
|
+
<div class="devinspector-content">
|
|
1036
|
+
<div class="devinspector-network-list">
|
|
1037
|
+
<p style="text-align: center; color: #666; margin-top: 40px;">
|
|
1038
|
+
Network requests will appear here...
|
|
1039
|
+
</p>
|
|
1040
|
+
</div>
|
|
1041
|
+
</div>
|
|
1042
|
+
`;
|
|
1043
|
+
this.inspector.on("network:request", (request) => {
|
|
1044
|
+
this.addNetworkEntry(panel, request);
|
|
1045
|
+
});
|
|
1046
|
+
this.inspector.on("network:response", (response) => {
|
|
1047
|
+
this.updateNetworkEntry(panel, response);
|
|
1048
|
+
});
|
|
1049
|
+
return panel;
|
|
1050
|
+
}
|
|
1051
|
+
createConsolePanel() {
|
|
1052
|
+
const panel = document.createElement("div");
|
|
1053
|
+
panel.innerHTML = `
|
|
1054
|
+
<div class="devinspector-toolbar">
|
|
1055
|
+
<input type="text" class="devinspector-search" placeholder="Filter logs...">
|
|
1056
|
+
<button class="devinspector-button">Clear</button>
|
|
1057
|
+
<button class="devinspector-button">Export</button>
|
|
1058
|
+
</div>
|
|
1059
|
+
<div class="devinspector-content">
|
|
1060
|
+
<div class="devinspector-console-list">
|
|
1061
|
+
<p style="text-align: center; color: #666; margin-top: 40px;">
|
|
1062
|
+
Console logs will appear here...
|
|
1063
|
+
</p>
|
|
1064
|
+
</div>
|
|
1065
|
+
</div>
|
|
1066
|
+
`;
|
|
1067
|
+
this.inspector.on("console:log", (entry) => {
|
|
1068
|
+
this.addConsoleEntry(panel, entry);
|
|
1069
|
+
});
|
|
1070
|
+
return panel;
|
|
1071
|
+
}
|
|
1072
|
+
createPerformancePanel() {
|
|
1073
|
+
const panel = document.createElement("div");
|
|
1074
|
+
panel.innerHTML = `
|
|
1075
|
+
<div class="devinspector-content">
|
|
1076
|
+
<div class="devinspector-metrics">
|
|
1077
|
+
<div class="devinspector-metric">
|
|
1078
|
+
<span class="devinspector-metric-label">FPS</span>
|
|
1079
|
+
<span class="devinspector-metric-value" id="fps-value">--</span>
|
|
1080
|
+
</div>
|
|
1081
|
+
<div class="devinspector-metric">
|
|
1082
|
+
<span class="devinspector-metric-label">Memory</span>
|
|
1083
|
+
<span class="devinspector-metric-value" id="memory-value">--</span>
|
|
1084
|
+
</div>
|
|
1085
|
+
<div class="devinspector-chart" id="fps-chart"></div>
|
|
1086
|
+
<div class="devinspector-chart" id="memory-chart"></div>
|
|
1087
|
+
</div>
|
|
1088
|
+
</div>
|
|
1089
|
+
`;
|
|
1090
|
+
this.inspector.on("performance:data", (data) => {
|
|
1091
|
+
this.updatePerformanceMetrics(panel, data);
|
|
1092
|
+
});
|
|
1093
|
+
return panel;
|
|
1094
|
+
}
|
|
1095
|
+
createErrorsPanel() {
|
|
1096
|
+
const panel = document.createElement("div");
|
|
1097
|
+
panel.innerHTML = `
|
|
1098
|
+
<div class="devinspector-toolbar">
|
|
1099
|
+
<button class="devinspector-button">Clear All</button>
|
|
1100
|
+
<button class="devinspector-button">Export</button>
|
|
1101
|
+
</div>
|
|
1102
|
+
<div class="devinspector-content">
|
|
1103
|
+
<div class="devinspector-errors-list">
|
|
1104
|
+
<p style="text-align: center; color: #666; margin-top: 40px;">
|
|
1105
|
+
No errors detected
|
|
1106
|
+
</p>
|
|
1107
|
+
</div>
|
|
1108
|
+
</div>
|
|
1109
|
+
`;
|
|
1110
|
+
this.inspector.on("error:caught", (error) => {
|
|
1111
|
+
this.addErrorEntry(panel, error);
|
|
1112
|
+
});
|
|
1113
|
+
this.inspector.on("error:uncaught", (error) => {
|
|
1114
|
+
this.addErrorEntry(panel, error);
|
|
1115
|
+
});
|
|
1116
|
+
return panel;
|
|
1117
|
+
}
|
|
1118
|
+
setupEventListeners() {
|
|
1119
|
+
this.inspector.on("console:clear", () => {
|
|
1120
|
+
const consoleList = document.querySelector(".devinspector-console-list");
|
|
1121
|
+
if (consoleList) {
|
|
1122
|
+
consoleList.innerHTML = `
|
|
1123
|
+
<p style="text-align: center; color: #666; margin-top: 40px;">
|
|
1124
|
+
Console cleared
|
|
1125
|
+
</p>
|
|
1126
|
+
`;
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
addNetworkEntry(panel, request) {
|
|
1131
|
+
const list = panel.querySelector(".devinspector-network-list");
|
|
1132
|
+
if (!list) return;
|
|
1133
|
+
const placeholder = list.querySelector("p");
|
|
1134
|
+
if (placeholder) {
|
|
1135
|
+
placeholder.remove();
|
|
1136
|
+
}
|
|
1137
|
+
const entry = document.createElement("div");
|
|
1138
|
+
entry.className = "devinspector-list-item";
|
|
1139
|
+
entry.dataset.requestId = request.id;
|
|
1140
|
+
entry.innerHTML = `
|
|
1141
|
+
<div style="display: flex; justify-content: space-between; align-items: center;">
|
|
1142
|
+
<span>${escapeHtml(request.method)} ${escapeHtml(request.url)}</span>
|
|
1143
|
+
<span class="devinspector-status info">Pending</span>
|
|
1144
|
+
</div>
|
|
1145
|
+
<div class="devinspector-timestamp">${new Date(request.timestamp).toLocaleTimeString()}</div>
|
|
1146
|
+
`;
|
|
1147
|
+
list.appendChild(entry);
|
|
1148
|
+
}
|
|
1149
|
+
updateNetworkEntry(panel, response) {
|
|
1150
|
+
const entry = Array.from(panel.querySelectorAll("[data-request-id]")).find((el) => el.dataset.requestId === String(response.id));
|
|
1151
|
+
if (!entry) return;
|
|
1152
|
+
const status = entry.querySelector(".devinspector-status");
|
|
1153
|
+
if (status) {
|
|
1154
|
+
status.textContent = `${response.status}`;
|
|
1155
|
+
status.className = `devinspector-status ${response.status >= 400 ? "error" : "success"}`;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
addConsoleEntry(panel, entry) {
|
|
1159
|
+
const list = panel.querySelector(".devinspector-console-list");
|
|
1160
|
+
if (!list) return;
|
|
1161
|
+
const placeholder = list.querySelector("p");
|
|
1162
|
+
if (placeholder) {
|
|
1163
|
+
placeholder.remove();
|
|
1164
|
+
}
|
|
1165
|
+
const consoleEntry = document.createElement("div");
|
|
1166
|
+
consoleEntry.className = `devinspector-console-entry ${String(entry.level).replace(/[^a-zA-Z]/g, "")}`;
|
|
1167
|
+
consoleEntry.innerHTML = `
|
|
1168
|
+
<span class="devinspector-console-level">${escapeHtml(entry.level)}</span>
|
|
1169
|
+
<span class="devinspector-console-content">${escapeHtml(this.formatConsoleArgs(entry.formattedArgs))}</span>
|
|
1170
|
+
<span class="devinspector-timestamp">${new Date(entry.timestamp).toLocaleTimeString()}</span>
|
|
1171
|
+
`;
|
|
1172
|
+
list.appendChild(consoleEntry);
|
|
1173
|
+
list.scrollTop = list.scrollHeight;
|
|
1174
|
+
}
|
|
1175
|
+
addErrorEntry(panel, error) {
|
|
1176
|
+
const list = panel.querySelector(".devinspector-errors-list");
|
|
1177
|
+
if (!list) return;
|
|
1178
|
+
const placeholder = list.querySelector("p");
|
|
1179
|
+
if (placeholder) {
|
|
1180
|
+
placeholder.remove();
|
|
1181
|
+
}
|
|
1182
|
+
const errorEntry = document.createElement("div");
|
|
1183
|
+
errorEntry.className = "devinspector-error-group";
|
|
1184
|
+
errorEntry.innerHTML = `
|
|
1185
|
+
<div class="devinspector-error-message">${escapeHtml(error.message)}</div>
|
|
1186
|
+
<div class="devinspector-timestamp">${new Date(error.timestamp).toLocaleTimeString()}</div>
|
|
1187
|
+
${error.stack ? `<pre class="devinspector-error-stack">${escapeHtml(Array.isArray(error.stack) ? error.stack.join("\n") : error.stack)}</pre>` : ""}
|
|
1188
|
+
`;
|
|
1189
|
+
list.appendChild(errorEntry);
|
|
1190
|
+
}
|
|
1191
|
+
updatePerformanceMetrics(panel, data) {
|
|
1192
|
+
const fpsValue = panel.querySelector("#fps-value");
|
|
1193
|
+
const memoryValue = panel.querySelector("#memory-value");
|
|
1194
|
+
if (fpsValue && data.fps) {
|
|
1195
|
+
fpsValue.textContent = `${data.fps.fps} FPS`;
|
|
1196
|
+
}
|
|
1197
|
+
if (memoryValue && data.memory) {
|
|
1198
|
+
const memoryMB = Math.round(data.memory.usedJSHeapSize / 1024 / 1024);
|
|
1199
|
+
memoryValue.textContent = `${memoryMB} MB`;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
formatConsoleArgs(args) {
|
|
1203
|
+
return args.map((arg) => {
|
|
1204
|
+
if (typeof arg === "string") {
|
|
1205
|
+
return arg;
|
|
1206
|
+
} else if (arg && typeof arg === "object") {
|
|
1207
|
+
return JSON.stringify(arg, null, 2);
|
|
1208
|
+
} else {
|
|
1209
|
+
return String(arg);
|
|
1210
|
+
}
|
|
1211
|
+
}).join(" ");
|
|
1212
|
+
}
|
|
1213
|
+
show() {
|
|
1214
|
+
this.mainPanel.show();
|
|
1215
|
+
this.isVisible = true;
|
|
1216
|
+
this.isMinimized = false;
|
|
1217
|
+
}
|
|
1218
|
+
hide() {
|
|
1219
|
+
this.mainPanel.hide();
|
|
1220
|
+
this.isVisible = false;
|
|
1221
|
+
}
|
|
1222
|
+
minimize() {
|
|
1223
|
+
this.mainPanel.minimize();
|
|
1224
|
+
this.isMinimized = true;
|
|
1225
|
+
}
|
|
1226
|
+
destroy() {
|
|
1227
|
+
this.floatingWidget.destroy();
|
|
1228
|
+
this.mainPanel.destroy();
|
|
1229
|
+
if (this.styleElement && this.styleElement.parentNode) {
|
|
1230
|
+
this.styleElement.parentNode.removeChild(this.styleElement);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
getElement() {
|
|
1234
|
+
return this.mainPanel.getElement();
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
export {
|
|
1238
|
+
DevInspectorUI
|
|
1239
|
+
};
|
|
1240
|
+
//# sourceMappingURL=inspector-ui-AFTUEVWA.js.map
|