dev-inspector 1.1.0 → 1.2.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/README.md +12 -7
- package/lib/init.d.ts +9 -0
- package/lib/init.js +3 -2
- package/lib/ui/panel/behavior/setupPanelBehavior.d.ts +3 -0
- package/lib/ui/panel/behavior/setupPanelBehavior.js +3 -1
- package/lib/ui/panel/index.d.ts +2 -0
- package/lib/ui/panel/index.js +2 -2
- package/lib/ui/panel/shared/ensureStyle.js +2 -1
- package/lib/ui/panel/skin/applySkin.d.ts +2 -0
- package/lib/ui/panel/skin/applySkin.js +6 -0
- package/lib/ui/panel/skin/cartoonStyles.d.ts +14 -0
- package/lib/ui/panel/skin/cartoonStyles.js +172 -0
- package/lib/ui/panel/skin/index.d.ts +3 -0
- package/lib/ui/panel/skin/index.js +7 -0
- package/lib/ui/panel/skin/types.d.ts +4 -0
- package/package.json +3 -2
- package/lib/integrations/index.d.ts +0 -2
- package/lib/integrations/index.js +0 -7
- package/lib/integrations/jira/adf.d.ts +0 -11
- package/lib/integrations/jira/adf.js +0 -17
- package/lib/integrations/jira/client.d.ts +0 -4
- package/lib/integrations/jira/client.js +0 -113
- package/lib/integrations/jira/errors.d.ts +0 -10
- package/lib/integrations/jira/errors.js +0 -13
- package/lib/integrations/jira/index.d.ts +0 -2
- package/lib/integrations/jira/index.js +0 -8
- package/lib/integrations/types.d.ts +0 -54
- package/lib/storage/localStorage.d.ts +0 -30
- package/lib/storage/localStorage.js +0 -166
- package/lib/ui/logList.d.ts +0 -7
- package/lib/ui/logList.js +0 -117
- package/lib/ui/panel/integrations/icons.d.ts +0 -1
- package/lib/ui/panel/integrations/icons.js +0 -7
- package/lib/ui/panel/integrations/index.d.ts +0 -1
- package/lib/ui/panel/integrations/index.js +0 -5
- package/lib/ui/panel/integrations/jiraDialog.d.ts +0 -6
- package/lib/ui/panel/integrations/jiraDialog.js +0 -234
- package/lib/ui/panel/integrations/screenshot.d.ts +0 -4
- package/lib/ui/panel/integrations/screenshot.js +0 -51
- package/lib/ui/panel/localStorage/createLocalStorageView.d.ts +0 -4
- package/lib/ui/panel/localStorage/createLocalStorageView.js +0 -108
- package/lib/ui/panel/localStorage/index.d.ts +0 -3
- package/lib/ui/panel/localStorage/index.js +0 -7
- package/lib/ui/panel/localStorage/setupLocalStorageSync.d.ts +0 -9
- package/lib/ui/panel/localStorage/setupLocalStorageSync.js +0 -30
- package/lib/ui/panel/localStorage/types.d.ts +0 -6
- package/lib/ui/panel/localStorage/types.js +0 -2
- package/lib/ui/panel.d.ts +0 -15
- package/lib/ui/panel.js +0 -375
- package/lib/ui/shared/copy.d.ts +0 -2
- package/lib/ui/shared/copy.js +0 -101
- /package/lib/{integrations → ui/panel/skin}/types.js +0 -0
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.captureScreenshotDisplayMedia = captureScreenshotDisplayMedia;
|
|
4
|
-
async function blobToDataUrl(blob) {
|
|
5
|
-
return await new Promise((resolve, reject) => {
|
|
6
|
-
const r = new FileReader();
|
|
7
|
-
r.onload = () => resolve(String(r.result));
|
|
8
|
-
r.onerror = () => reject(new Error("Failed to read screenshot."));
|
|
9
|
-
r.readAsDataURL(blob);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
async function captureScreenshotDisplayMedia() {
|
|
13
|
-
var _a, _b;
|
|
14
|
-
const nav = globalThis;
|
|
15
|
-
const getDisplayMedia = (_b = (_a = nav.navigator) === null || _a === void 0 ? void 0 : _a.mediaDevices) === null || _b === void 0 ? void 0 : _b.getDisplayMedia;
|
|
16
|
-
if (typeof getDisplayMedia !== "function")
|
|
17
|
-
return undefined;
|
|
18
|
-
const stream = await getDisplayMedia({ video: true, audio: false });
|
|
19
|
-
try {
|
|
20
|
-
const track = stream.getVideoTracks()[0];
|
|
21
|
-
if (!track)
|
|
22
|
-
return undefined;
|
|
23
|
-
const imageCapture = globalThis.ImageCapture;
|
|
24
|
-
if (typeof imageCapture === "function") {
|
|
25
|
-
const ic = new imageCapture(track);
|
|
26
|
-
const blob = await ic.takePhoto();
|
|
27
|
-
const dataUrl = await blobToDataUrl(blob);
|
|
28
|
-
return { dataUrl, filename: `screenshot-${Date.now()}.png` };
|
|
29
|
-
}
|
|
30
|
-
const video = document.createElement("video");
|
|
31
|
-
video.srcObject = stream;
|
|
32
|
-
video.muted = true;
|
|
33
|
-
await video.play();
|
|
34
|
-
await new Promise((r) => globalThis.setTimeout(r, 50));
|
|
35
|
-
const w = Math.max(1, video.videoWidth || 1);
|
|
36
|
-
const h = Math.max(1, video.videoHeight || 1);
|
|
37
|
-
const canvas = document.createElement("canvas");
|
|
38
|
-
canvas.width = w;
|
|
39
|
-
canvas.height = h;
|
|
40
|
-
const ctx = canvas.getContext("2d");
|
|
41
|
-
if (!ctx)
|
|
42
|
-
return undefined;
|
|
43
|
-
ctx.drawImage(video, 0, 0, w, h);
|
|
44
|
-
const dataUrl = canvas.toDataURL("image/png");
|
|
45
|
-
return { dataUrl, filename: `screenshot-${Date.now()}.png` };
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
for (const t of stream.getTracks())
|
|
49
|
-
t.stop();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLocalStorageView = createLocalStorageView;
|
|
4
|
-
const copy_1 = require("../../shared/copy");
|
|
5
|
-
const jsonViewer_1 = require("../../jsonViewer");
|
|
6
|
-
function tryParseJson(text) {
|
|
7
|
-
const t = text.trim();
|
|
8
|
-
if (t.length < 2)
|
|
9
|
-
return undefined;
|
|
10
|
-
const looksLikeObject = t.startsWith("{") && t.endsWith("}");
|
|
11
|
-
const looksLikeArray = t.startsWith("[") && t.endsWith("]");
|
|
12
|
-
if (!looksLikeObject && !looksLikeArray)
|
|
13
|
-
return undefined;
|
|
14
|
-
try {
|
|
15
|
-
return JSON.parse(t);
|
|
16
|
-
}
|
|
17
|
-
catch (_a) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function localStorageValueToElement(doc, value) {
|
|
22
|
-
const parsed = tryParseJson(value);
|
|
23
|
-
if (parsed && typeof parsed === "object") {
|
|
24
|
-
return (0, jsonViewer_1.createJsonViewer)(doc, parsed, { maxDepth: 6, maxKeys: 200, maxNodes: 2000, initiallyOpen: false });
|
|
25
|
-
}
|
|
26
|
-
const el = doc.createElement("div");
|
|
27
|
-
el.className = "di-netBodyText";
|
|
28
|
-
el.textContent = value;
|
|
29
|
-
return el;
|
|
30
|
-
}
|
|
31
|
-
function createLocalStorageView(doc, opts) {
|
|
32
|
-
const root = doc.createElement("div");
|
|
33
|
-
root.className = "di-lsRoot";
|
|
34
|
-
const msg = doc.createElement("div");
|
|
35
|
-
msg.className = "di-lsMsg di-hidden";
|
|
36
|
-
const empty = doc.createElement("div");
|
|
37
|
-
empty.className = "di-lsEmpty di-hidden";
|
|
38
|
-
empty.textContent = "localStorage is empty.";
|
|
39
|
-
const table = doc.createElement("div");
|
|
40
|
-
table.className = "di-lsTable di-hidden";
|
|
41
|
-
const head = doc.createElement("div");
|
|
42
|
-
head.className = "di-lsHead";
|
|
43
|
-
head.append(Object.assign(doc.createElement("div"), { className: "di-lsH di-lsHKey", textContent: "Key" }), Object.assign(doc.createElement("div"), { className: "di-lsH di-lsHVal", textContent: "Value" }), Object.assign(doc.createElement("div"), { className: "di-lsH di-lsHAct", textContent: "" }));
|
|
44
|
-
const body = doc.createElement("div");
|
|
45
|
-
body.className = "di-lsBody";
|
|
46
|
-
table.append(head, body);
|
|
47
|
-
const setMessage = (message) => {
|
|
48
|
-
var _a;
|
|
49
|
-
msg.textContent = message;
|
|
50
|
-
msg.classList.remove("di-hidden");
|
|
51
|
-
table.classList.add("di-hidden");
|
|
52
|
-
empty.classList.add("di-hidden");
|
|
53
|
-
(_a = opts.onCount) === null || _a === void 0 ? void 0 : _a.call(opts, 0);
|
|
54
|
-
};
|
|
55
|
-
const setSnapshot = (snapshot) => {
|
|
56
|
-
var _a;
|
|
57
|
-
msg.classList.add("di-hidden");
|
|
58
|
-
table.classList.remove("di-hidden");
|
|
59
|
-
body.replaceChildren();
|
|
60
|
-
(_a = opts.onCount) === null || _a === void 0 ? void 0 : _a.call(opts, snapshot.items.length);
|
|
61
|
-
if (snapshot.items.length === 0) {
|
|
62
|
-
empty.classList.remove("di-hidden");
|
|
63
|
-
table.classList.add("di-hidden");
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
empty.classList.add("di-hidden");
|
|
67
|
-
for (const it of snapshot.items) {
|
|
68
|
-
const row = doc.createElement("div");
|
|
69
|
-
row.className = "di-lsRow";
|
|
70
|
-
const key = doc.createElement("div");
|
|
71
|
-
key.className = "di-lsCell di-lsKey";
|
|
72
|
-
key.textContent = it.key;
|
|
73
|
-
key.title = it.key;
|
|
74
|
-
const valueCell = doc.createElement("div");
|
|
75
|
-
valueCell.className = "di-lsCell di-lsValue";
|
|
76
|
-
valueCell.append(localStorageValueToElement(doc, it.value));
|
|
77
|
-
const copyBtn = doc.createElement("button");
|
|
78
|
-
copyBtn.type = "button";
|
|
79
|
-
copyBtn.className = "di-copyBtn di-lsCopyBtn";
|
|
80
|
-
copyBtn.innerHTML =
|
|
81
|
-
`<svg class="di-iconSvg" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">` +
|
|
82
|
-
`<path d="M9 9H18.5C19.33 9 20 9.67 20 10.5V19.5C20 20.33 19.33 21 18.5 21H9.5C8.67 21 8 20.33 8 19.5V10.5C8 9.67 8.67 9 9.5 9Z" stroke="currentColor" stroke-width="1.5"/>` +
|
|
83
|
-
`<path d="M6 15H5.5C4.67 15 4 14.33 4 13.5V4.5C4 3.67 4.67 3 5.5 3H14.5C15.33 3 16 3.67 16 4.5V5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>` +
|
|
84
|
-
`</svg>`;
|
|
85
|
-
copyBtn.setAttribute("aria-label", `Copy value for ${it.key}`);
|
|
86
|
-
copyBtn.addEventListener("click", (ev) => {
|
|
87
|
-
ev.preventDefault();
|
|
88
|
-
ev.stopPropagation();
|
|
89
|
-
void (0, copy_1.copyText)(it.value).then((ok) => {
|
|
90
|
-
if (!ok)
|
|
91
|
-
return;
|
|
92
|
-
(0, copy_1.launchMiniConfetti)(copyBtn);
|
|
93
|
-
copyBtn.classList.add("di-copied");
|
|
94
|
-
globalThis.setTimeout(() => {
|
|
95
|
-
copyBtn.classList.remove("di-copied");
|
|
96
|
-
}, 900);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
const actions = doc.createElement("div");
|
|
100
|
-
actions.className = "di-lsCell di-lsActions";
|
|
101
|
-
actions.append(copyBtn);
|
|
102
|
-
row.append(key, valueCell, actions);
|
|
103
|
-
body.append(row);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
root.append(msg, empty, table);
|
|
107
|
-
return { el: root, setSnapshot, setMessage };
|
|
108
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupLocalStorageSync = exports.createLocalStorageView = void 0;
|
|
4
|
-
var createLocalStorageView_1 = require("./createLocalStorageView");
|
|
5
|
-
Object.defineProperty(exports, "createLocalStorageView", { enumerable: true, get: function () { return createLocalStorageView_1.createLocalStorageView; } });
|
|
6
|
-
var setupLocalStorageSync_1 = require("./setupLocalStorageSync");
|
|
7
|
-
Object.defineProperty(exports, "setupLocalStorageSync", { enumerable: true, get: function () { return setupLocalStorageSync_1.setupLocalStorageSync; } });
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupLocalStorageSync = setupLocalStorageSync;
|
|
4
|
-
const localStorage_1 = require("../../../storage/localStorage");
|
|
5
|
-
function setupLocalStorageSync(args) {
|
|
6
|
-
const access = (0, localStorage_1.getLocalStorageAccess)();
|
|
7
|
-
if (!access.ok) {
|
|
8
|
-
args.view.setMessage(access.message);
|
|
9
|
-
return { refresh: () => void 0, destroy: () => void 0 };
|
|
10
|
-
}
|
|
11
|
-
const refresh = () => {
|
|
12
|
-
try {
|
|
13
|
-
const snap = (0, localStorage_1.readLocalStorageSnapshot)(access.storage, { maxPreviewLength: args.maxPreviewLength });
|
|
14
|
-
args.view.setSnapshot(snap);
|
|
15
|
-
}
|
|
16
|
-
catch (_a) {
|
|
17
|
-
args.view.setMessage("localStorage could not be read (it may be blocked by browser settings).");
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
refresh();
|
|
21
|
-
const watcher = (0, localStorage_1.createLocalStorageWatcher)({
|
|
22
|
-
storage: access.storage,
|
|
23
|
-
pollIntervalMs: args.pollIntervalMs,
|
|
24
|
-
onChange: refresh,
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
refresh,
|
|
28
|
-
destroy: () => watcher.destroy(),
|
|
29
|
-
};
|
|
30
|
-
}
|
package/lib/ui/panel.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { LogStorage } from "../storage/logStorage";
|
|
2
|
-
export type PanelOptions = {
|
|
3
|
-
storage: LogStorage;
|
|
4
|
-
title?: string;
|
|
5
|
-
initiallyOpen?: boolean;
|
|
6
|
-
mount?: HTMLElement;
|
|
7
|
-
};
|
|
8
|
-
export type PanelHandle = {
|
|
9
|
-
open: () => void;
|
|
10
|
-
close: () => void;
|
|
11
|
-
toggle: () => void;
|
|
12
|
-
destroy: () => void;
|
|
13
|
-
isOpen: () => boolean;
|
|
14
|
-
};
|
|
15
|
-
export declare function createPanel(options: PanelOptions): PanelHandle;
|
package/lib/ui/panel.js
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPanel = createPanel;
|
|
4
|
-
const logList_1 = require("./logList");
|
|
5
|
-
const panelStyles_1 = require("./panelStyles");
|
|
6
|
-
function getWindow() {
|
|
7
|
-
return globalThis;
|
|
8
|
-
}
|
|
9
|
-
function queryOrThrow(root, selector) {
|
|
10
|
-
const el = root.querySelector(selector);
|
|
11
|
-
if (!el)
|
|
12
|
-
throw new Error(`Missing required element: ${selector}`);
|
|
13
|
-
return el;
|
|
14
|
-
}
|
|
15
|
-
const TOGGLE_BUTTON_HTML = `<span class="di-toggleTitle">Dev Inspector</span>` +
|
|
16
|
-
`<span class="di-toggleMeta">` +
|
|
17
|
-
`<span class="di-toggleBadge" data-di-toggle-count="console">` +
|
|
18
|
-
`<svg class="di-toggleIcon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 5.5C4 4.67 4.67 4 5.5 4H18.5C19.33 4 20 4.67 20 5.5V15.5C20 16.33 19.33 17 18.5 17H13.5L12 18.5L10.5 17H5.5C4.67 17 4 16.33 4 15.5V5.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><path d="M7 8H17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M7 11H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>` +
|
|
19
|
-
`<span data-di-toggle-count-value="console">0</span>` +
|
|
20
|
-
`<span class="di-toggleErr" data-di-toggle-error="console" aria-label="Console errors">` +
|
|
21
|
-
`<span class="di-toggleErrIcon">!</span>` +
|
|
22
|
-
`<span data-di-toggle-error-value="console">0</span>` +
|
|
23
|
-
`</span>` +
|
|
24
|
-
`</span>` +
|
|
25
|
-
`<span class="di-toggleBadge" data-di-toggle-count="network">` +
|
|
26
|
-
`<svg class="di-toggleIcon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 12C4 7.58 7.58 4 12 4C16.42 4 20 7.58 20 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M6 12C6 8.69 8.69 6 12 6C15.31 6 18 8.69 18 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M8.5 12C8.5 10.07 10.07 8.5 12 8.5C13.93 8.5 15.5 10.07 15.5 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M12 12L12 20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><circle cx="12" cy="20" r="1.5" fill="currentColor"/></svg>` +
|
|
27
|
-
`<span data-di-toggle-count-value="network">0</span>` +
|
|
28
|
-
`<span class="di-toggleErr" data-di-toggle-error="network" aria-label="Network errors">` +
|
|
29
|
-
`<span class="di-toggleErrIcon">!</span>` +
|
|
30
|
-
`<span data-di-toggle-error-value="network">0</span>` +
|
|
31
|
-
`</span>` +
|
|
32
|
-
`</span>` +
|
|
33
|
-
`</span>`;
|
|
34
|
-
const CONSOLE_TAB_HTML = `<svg class="di-tabIcon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 5.5C4 4.67 4.67 4 5.5 4H18.5C19.33 4 20 4.67 20 5.5V15.5C20 16.33 19.33 17 18.5 17H13.5L12 18.5L10.5 17H5.5C4.67 17 4 16.33 4 15.5V5.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><path d="M7 8H17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M7 11H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>` +
|
|
35
|
-
`<span>Console</span>` +
|
|
36
|
-
`<span class="di-badge" data-di-count="console">0</span>`;
|
|
37
|
-
const NETWORK_TAB_HTML = `<svg class="di-tabIcon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 12C4 7.58 7.58 4 12 4C16.42 4 20 7.58 20 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M6 12C6 8.69 8.69 6 12 6C15.31 6 18 8.69 18 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M8.5 12C8.5 10.07 10.07 8.5 12 8.5C13.93 8.5 15.5 10.07 15.5 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M12 12L12 20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><circle cx="12" cy="20" r="1.5" fill="currentColor"/></svg>` +
|
|
38
|
-
`<span>Network</span>` +
|
|
39
|
-
`<span class="di-badge" data-di-count="network">0</span>`;
|
|
40
|
-
function clamp(n, min, max) {
|
|
41
|
-
return Math.max(min, Math.min(max, n));
|
|
42
|
-
}
|
|
43
|
-
function ensureDocument() {
|
|
44
|
-
if (typeof document === "undefined") {
|
|
45
|
-
throw new Error("Panel UI requires a browser-like environment with document.");
|
|
46
|
-
}
|
|
47
|
-
return document;
|
|
48
|
-
}
|
|
49
|
-
function ensureStyle(doc) {
|
|
50
|
-
const id = "dev-inspector-panel-style";
|
|
51
|
-
const existing = doc.getElementById(id);
|
|
52
|
-
if (existing)
|
|
53
|
-
return;
|
|
54
|
-
const style = doc.createElement("style");
|
|
55
|
-
style.id = id;
|
|
56
|
-
style.textContent = panelStyles_1.PANEL_CSS;
|
|
57
|
-
doc.head.append(style);
|
|
58
|
-
}
|
|
59
|
-
function createPanelState(initiallyOpen) {
|
|
60
|
-
return {
|
|
61
|
-
open: initiallyOpen,
|
|
62
|
-
tab: "console",
|
|
63
|
-
entries: { console: [], network: [] },
|
|
64
|
-
errorCounts: { console: 0, network: 0 },
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function buildPanelDOM(doc, options) {
|
|
68
|
-
var _a, _b;
|
|
69
|
-
const mount = (_a = options.mount) !== null && _a !== void 0 ? _a : doc.body;
|
|
70
|
-
const title = (_b = options.title) !== null && _b !== void 0 ? _b : "Dev Inspector";
|
|
71
|
-
const root = doc.createElement("div");
|
|
72
|
-
root.className = "di-root";
|
|
73
|
-
const toggleBtn = doc.createElement("button");
|
|
74
|
-
toggleBtn.type = "button";
|
|
75
|
-
toggleBtn.className = "di-toggle";
|
|
76
|
-
toggleBtn.setAttribute("aria-label", "Dev Inspector");
|
|
77
|
-
toggleBtn.innerHTML = TOGGLE_BUTTON_HTML;
|
|
78
|
-
const panel = doc.createElement("div");
|
|
79
|
-
panel.className = "di-panel";
|
|
80
|
-
const resizeHandle = doc.createElement("div");
|
|
81
|
-
resizeHandle.className = "di-resizeHandle";
|
|
82
|
-
resizeHandle.setAttribute("role", "separator");
|
|
83
|
-
resizeHandle.setAttribute("aria-label", "Resize panel");
|
|
84
|
-
const header = doc.createElement("div");
|
|
85
|
-
header.className = "di-header";
|
|
86
|
-
const headerRow = doc.createElement("div");
|
|
87
|
-
headerRow.className = "di-headerRow";
|
|
88
|
-
const titleEl = doc.createElement("div");
|
|
89
|
-
titleEl.className = "di-title";
|
|
90
|
-
titleEl.textContent = title;
|
|
91
|
-
const actions = doc.createElement("div");
|
|
92
|
-
actions.className = "di-actions";
|
|
93
|
-
const clearBtn = doc.createElement("button");
|
|
94
|
-
clearBtn.type = "button";
|
|
95
|
-
clearBtn.className = "di-btn";
|
|
96
|
-
clearBtn.textContent = "Clear";
|
|
97
|
-
const closeBtn = doc.createElement("button");
|
|
98
|
-
closeBtn.type = "button";
|
|
99
|
-
closeBtn.className = "di-btn";
|
|
100
|
-
closeBtn.textContent = "Close";
|
|
101
|
-
actions.append(clearBtn, closeBtn);
|
|
102
|
-
headerRow.append(resizeHandle, titleEl, actions);
|
|
103
|
-
const tabs = doc.createElement("div");
|
|
104
|
-
tabs.className = "di-tabs";
|
|
105
|
-
const consoleTab = doc.createElement("button");
|
|
106
|
-
consoleTab.type = "button";
|
|
107
|
-
consoleTab.className = "di-tab";
|
|
108
|
-
consoleTab.innerHTML = CONSOLE_TAB_HTML;
|
|
109
|
-
const networkTab = doc.createElement("button");
|
|
110
|
-
networkTab.type = "button";
|
|
111
|
-
networkTab.className = "di-tab";
|
|
112
|
-
networkTab.innerHTML = NETWORK_TAB_HTML;
|
|
113
|
-
tabs.append(consoleTab, networkTab);
|
|
114
|
-
header.append(headerRow, tabs);
|
|
115
|
-
const body = doc.createElement("div");
|
|
116
|
-
body.className = "di-body";
|
|
117
|
-
const list = (0, logList_1.createLogList)(doc);
|
|
118
|
-
body.append(list.el);
|
|
119
|
-
panel.append(header, body);
|
|
120
|
-
root.append(toggleBtn, panel);
|
|
121
|
-
mount.append(root);
|
|
122
|
-
const counters = {
|
|
123
|
-
headerConsoleCount: queryOrThrow(header, '[data-di-count="console"]'),
|
|
124
|
-
headerNetworkCount: queryOrThrow(header, '[data-di-count="network"]'),
|
|
125
|
-
toggleConsoleCount: queryOrThrow(toggleBtn, '[data-di-toggle-count-value="console"]'),
|
|
126
|
-
toggleNetworkCount: queryOrThrow(toggleBtn, '[data-di-toggle-count-value="network"]'),
|
|
127
|
-
toggleConsoleErrorCount: queryOrThrow(toggleBtn, '[data-di-toggle-error-value="console"]'),
|
|
128
|
-
toggleNetworkErrorCount: queryOrThrow(toggleBtn, '[data-di-toggle-error-value="network"]'),
|
|
129
|
-
toggleConsoleErrorWrap: queryOrThrow(toggleBtn, '[data-di-toggle-error="console"]'),
|
|
130
|
-
toggleNetworkErrorWrap: queryOrThrow(toggleBtn, '[data-di-toggle-error="network"]'),
|
|
131
|
-
};
|
|
132
|
-
return { root, toggleBtn, panel, header, body, closeBtn, clearBtn, consoleTab, networkTab, resizeHandle, list, counters };
|
|
133
|
-
}
|
|
134
|
-
function attachResizeHandling(panel, resizeHandle) {
|
|
135
|
-
var _a;
|
|
136
|
-
const MAX_WIDTH_CAP = 920;
|
|
137
|
-
const MAX_HEIGHT_CAP = 720;
|
|
138
|
-
const MARGIN_X = 24;
|
|
139
|
-
const MARGIN_Y = 68;
|
|
140
|
-
const minSize = (() => {
|
|
141
|
-
const r = panel.getBoundingClientRect();
|
|
142
|
-
return { w: Math.round(r.width), h: Math.round(r.height) };
|
|
143
|
-
})();
|
|
144
|
-
const getMaxSize = () => {
|
|
145
|
-
const win = getWindow();
|
|
146
|
-
const vw = typeof win.innerWidth === "number" ? win.innerWidth : 0;
|
|
147
|
-
const vh = typeof win.innerHeight === "number" ? win.innerHeight : 0;
|
|
148
|
-
return {
|
|
149
|
-
w: Math.max(200, Math.min(MAX_WIDTH_CAP, vw - MARGIN_X)),
|
|
150
|
-
h: Math.max(180, Math.min(MAX_HEIGHT_CAP, vh - MARGIN_Y)),
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
const getCurrentSize = () => {
|
|
154
|
-
const r = panel.getBoundingClientRect();
|
|
155
|
-
return { w: Math.round(r.width), h: Math.round(r.height) };
|
|
156
|
-
};
|
|
157
|
-
const applySize = (next) => {
|
|
158
|
-
const max = getMaxSize();
|
|
159
|
-
const effMinW = Math.min(minSize.w, max.w);
|
|
160
|
-
const effMinH = Math.min(minSize.h, max.h);
|
|
161
|
-
const w = clamp(next.w, effMinW, max.w);
|
|
162
|
-
const h = clamp(next.h, effMinH, max.h);
|
|
163
|
-
panel.style.width = `${w}px`;
|
|
164
|
-
panel.style.height = `${h}px`;
|
|
165
|
-
};
|
|
166
|
-
const ensureWithinViewport = () => {
|
|
167
|
-
if (!panel.style.width && !panel.style.height)
|
|
168
|
-
return;
|
|
169
|
-
applySize(getCurrentSize());
|
|
170
|
-
};
|
|
171
|
-
let resizing = false;
|
|
172
|
-
let startX = 0;
|
|
173
|
-
let startY = 0;
|
|
174
|
-
let startW = 0;
|
|
175
|
-
let startH = 0;
|
|
176
|
-
const onResizeMove = (ev) => {
|
|
177
|
-
if (!resizing)
|
|
178
|
-
return;
|
|
179
|
-
const dx = startX - ev.clientX;
|
|
180
|
-
const dy = startY - ev.clientY;
|
|
181
|
-
applySize({ w: startW + dx, h: startH + dy });
|
|
182
|
-
};
|
|
183
|
-
const stopResize = () => {
|
|
184
|
-
var _a, _b, _c;
|
|
185
|
-
if (!resizing)
|
|
186
|
-
return;
|
|
187
|
-
resizing = false;
|
|
188
|
-
const win = getWindow();
|
|
189
|
-
(_a = win.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "pointermove", onResizeMove);
|
|
190
|
-
(_b = win.removeEventListener) === null || _b === void 0 ? void 0 : _b.call(win, "pointerup", stopResize);
|
|
191
|
-
(_c = win.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(win, "pointercancel", stopResize);
|
|
192
|
-
};
|
|
193
|
-
const onResizeStart = (ev) => {
|
|
194
|
-
var _a, _b, _c;
|
|
195
|
-
resizing = true;
|
|
196
|
-
startX = ev.clientX;
|
|
197
|
-
startY = ev.clientY;
|
|
198
|
-
const cur = getCurrentSize();
|
|
199
|
-
startW = cur.w;
|
|
200
|
-
startH = cur.h;
|
|
201
|
-
try {
|
|
202
|
-
resizeHandle.setPointerCapture(ev.pointerId);
|
|
203
|
-
}
|
|
204
|
-
catch (_d) {
|
|
205
|
-
void 0;
|
|
206
|
-
}
|
|
207
|
-
const win = getWindow();
|
|
208
|
-
(_a = win.addEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "pointermove", onResizeMove);
|
|
209
|
-
(_b = win.addEventListener) === null || _b === void 0 ? void 0 : _b.call(win, "pointerup", stopResize);
|
|
210
|
-
(_c = win.addEventListener) === null || _c === void 0 ? void 0 : _c.call(win, "pointercancel", stopResize);
|
|
211
|
-
};
|
|
212
|
-
const onWindowResize = () => ensureWithinViewport();
|
|
213
|
-
const win = getWindow();
|
|
214
|
-
(_a = win.addEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "resize", onWindowResize);
|
|
215
|
-
resizeHandle.addEventListener("pointerdown", onResizeStart);
|
|
216
|
-
const destroy = () => {
|
|
217
|
-
var _a;
|
|
218
|
-
resizeHandle.removeEventListener("pointerdown", onResizeStart);
|
|
219
|
-
stopResize();
|
|
220
|
-
(_a = win.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "resize", onWindowResize);
|
|
221
|
-
};
|
|
222
|
-
return { destroy };
|
|
223
|
-
}
|
|
224
|
-
function bindStorageToPanelView(args) {
|
|
225
|
-
const isConsoleError = (e) => e.source === "console" && e.level === "error";
|
|
226
|
-
const isNetworkError = (e) => e.source === "network" && (typeof e.status !== "number" || e.status >= 400);
|
|
227
|
-
const updateCounts = () => {
|
|
228
|
-
args.counters.headerConsoleCount.textContent = String(args.state.entries.console.length);
|
|
229
|
-
args.counters.headerNetworkCount.textContent = String(args.state.entries.network.length);
|
|
230
|
-
args.counters.toggleConsoleCount.textContent = String(args.state.entries.console.length);
|
|
231
|
-
args.counters.toggleNetworkCount.textContent = String(args.state.entries.network.length);
|
|
232
|
-
args.counters.toggleConsoleErrorCount.textContent = String(args.state.errorCounts.console);
|
|
233
|
-
args.counters.toggleNetworkErrorCount.textContent = String(args.state.errorCounts.network);
|
|
234
|
-
args.counters.toggleConsoleErrorWrap.style.display = args.state.errorCounts.console > 0 ? "inline-flex" : "none";
|
|
235
|
-
args.counters.toggleNetworkErrorWrap.style.display = args.state.errorCounts.network > 0 ? "inline-flex" : "none";
|
|
236
|
-
};
|
|
237
|
-
const renderActiveTab = () => {
|
|
238
|
-
args.list.clear();
|
|
239
|
-
args.state.entries[args.state.tab].forEach((e) => args.list.append(e));
|
|
240
|
-
args.body.scrollTop = args.body.scrollHeight;
|
|
241
|
-
};
|
|
242
|
-
const hydrate = () => {
|
|
243
|
-
args.state.entries.console = [];
|
|
244
|
-
args.state.entries.network = [];
|
|
245
|
-
args.state.errorCounts.console = 0;
|
|
246
|
-
args.state.errorCounts.network = 0;
|
|
247
|
-
args.storage.getAll().forEach((e) => {
|
|
248
|
-
if (e.source === "network") {
|
|
249
|
-
args.state.entries.network.push(e);
|
|
250
|
-
if (isNetworkError(e))
|
|
251
|
-
args.state.errorCounts.network += 1;
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
args.state.entries.console.push(e);
|
|
255
|
-
if (isConsoleError(e))
|
|
256
|
-
args.state.errorCounts.console += 1;
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
updateCounts();
|
|
260
|
-
args.updateTabStyles();
|
|
261
|
-
renderActiveTab();
|
|
262
|
-
};
|
|
263
|
-
const onNewLog = (entry) => {
|
|
264
|
-
if (entry.source === "network") {
|
|
265
|
-
args.state.entries.network.push(entry);
|
|
266
|
-
if (isNetworkError(entry))
|
|
267
|
-
args.state.errorCounts.network += 1;
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
args.state.entries.console.push(entry);
|
|
271
|
-
if (isConsoleError(entry))
|
|
272
|
-
args.state.errorCounts.console += 1;
|
|
273
|
-
}
|
|
274
|
-
updateCounts();
|
|
275
|
-
if (entry.source === args.state.tab) {
|
|
276
|
-
args.list.append(entry);
|
|
277
|
-
args.body.scrollTop = args.body.scrollHeight;
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
const unsub = args.storage.onNewLog(onNewLog);
|
|
281
|
-
const onCleared = () => {
|
|
282
|
-
args.state.entries.console = [];
|
|
283
|
-
args.state.entries.network = [];
|
|
284
|
-
args.state.errorCounts.console = 0;
|
|
285
|
-
args.state.errorCounts.network = 0;
|
|
286
|
-
updateCounts();
|
|
287
|
-
renderActiveTab();
|
|
288
|
-
};
|
|
289
|
-
args.storage.addEventListener("cleared", onCleared);
|
|
290
|
-
hydrate();
|
|
291
|
-
const destroy = () => {
|
|
292
|
-
args.storage.removeEventListener("cleared", onCleared);
|
|
293
|
-
unsub();
|
|
294
|
-
};
|
|
295
|
-
return { destroy, renderActiveTab, hydrate };
|
|
296
|
-
}
|
|
297
|
-
function setupPanelBehavior(dom, state, storage) {
|
|
298
|
-
const applyVisibility = () => {
|
|
299
|
-
if (state.open)
|
|
300
|
-
dom.panel.classList.remove("di-hidden");
|
|
301
|
-
else
|
|
302
|
-
dom.panel.classList.add("di-hidden");
|
|
303
|
-
};
|
|
304
|
-
const updateTabStyles = () => {
|
|
305
|
-
if (state.tab === "console") {
|
|
306
|
-
dom.consoleTab.classList.add("di-tabActive");
|
|
307
|
-
dom.networkTab.classList.remove("di-tabActive");
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
dom.networkTab.classList.add("di-tabActive");
|
|
311
|
-
dom.consoleTab.classList.remove("di-tabActive");
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
const bindings = bindStorageToPanelView({
|
|
315
|
-
storage,
|
|
316
|
-
state,
|
|
317
|
-
list: dom.list,
|
|
318
|
-
body: dom.body,
|
|
319
|
-
counters: dom.counters,
|
|
320
|
-
updateTabStyles,
|
|
321
|
-
});
|
|
322
|
-
applyVisibility();
|
|
323
|
-
updateTabStyles();
|
|
324
|
-
const resizeControls = attachResizeHandling(dom.panel, dom.resizeHandle);
|
|
325
|
-
const open = () => {
|
|
326
|
-
state.open = true;
|
|
327
|
-
applyVisibility();
|
|
328
|
-
};
|
|
329
|
-
const close = () => {
|
|
330
|
-
state.open = false;
|
|
331
|
-
applyVisibility();
|
|
332
|
-
};
|
|
333
|
-
const toggle = () => {
|
|
334
|
-
state.open = !state.open;
|
|
335
|
-
applyVisibility();
|
|
336
|
-
};
|
|
337
|
-
const onToggleClick = () => toggle();
|
|
338
|
-
const onCloseClick = () => close();
|
|
339
|
-
const onClearClick = () => storage.clear();
|
|
340
|
-
const onConsoleTab = () => {
|
|
341
|
-
state.tab = "console";
|
|
342
|
-
updateTabStyles();
|
|
343
|
-
bindings.renderActiveTab();
|
|
344
|
-
};
|
|
345
|
-
const onNetworkTab = () => {
|
|
346
|
-
state.tab = "network";
|
|
347
|
-
updateTabStyles();
|
|
348
|
-
bindings.renderActiveTab();
|
|
349
|
-
};
|
|
350
|
-
dom.toggleBtn.addEventListener("click", onToggleClick);
|
|
351
|
-
dom.closeBtn.addEventListener("click", onCloseClick);
|
|
352
|
-
dom.clearBtn.addEventListener("click", onClearClick);
|
|
353
|
-
dom.consoleTab.addEventListener("click", onConsoleTab);
|
|
354
|
-
dom.networkTab.addEventListener("click", onNetworkTab);
|
|
355
|
-
const destroy = () => {
|
|
356
|
-
dom.toggleBtn.removeEventListener("click", onToggleClick);
|
|
357
|
-
dom.closeBtn.removeEventListener("click", onCloseClick);
|
|
358
|
-
dom.clearBtn.removeEventListener("click", onClearClick);
|
|
359
|
-
dom.consoleTab.removeEventListener("click", onConsoleTab);
|
|
360
|
-
dom.networkTab.removeEventListener("click", onNetworkTab);
|
|
361
|
-
resizeControls.destroy();
|
|
362
|
-
bindings.destroy();
|
|
363
|
-
dom.root.remove();
|
|
364
|
-
};
|
|
365
|
-
return { open, close, toggle, destroy, isOpen: () => state.open };
|
|
366
|
-
}
|
|
367
|
-
function createPanel(options) {
|
|
368
|
-
var _a;
|
|
369
|
-
const doc = ensureDocument();
|
|
370
|
-
ensureStyle(doc);
|
|
371
|
-
const dom = buildPanelDOM(doc, options);
|
|
372
|
-
const state = createPanelState((_a = options.initiallyOpen) !== null && _a !== void 0 ? _a : false);
|
|
373
|
-
const handle = setupPanelBehavior(dom, state, options.storage);
|
|
374
|
-
return handle;
|
|
375
|
-
}
|
package/lib/ui/shared/copy.d.ts
DELETED