@abbox/inspector 0.4.10 → 0.4.12
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/host/client-bridge.d.ts.map +1 -1
- package/dist/host/client-bridge.js +6 -52
- package/dist/host/validate.d.ts.map +1 -1
- package/dist/host/validate.js +1 -21
- package/dist/protocol.d.ts +15 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/runtime/inspector.d.ts.map +1 -1
- package/dist/runtime/inspector.js +14 -1
- package/dist/runtime/metadata.d.ts.map +1 -1
- package/dist/runtime/metadata.js +52 -0
- package/dist/runtime/overlay.d.ts +0 -1
- package/dist/runtime/overlay.d.ts.map +1 -1
- package/dist/runtime/overlay.js +2 -46
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-bridge.d.ts","sourceRoot":"","sources":["../../src/host/client-bridge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client-bridge.d.ts","sourceRoot":"","sources":["../../src/host/client-bridge.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,eAAe,CAyEjB"}
|
|
@@ -2,51 +2,15 @@ import { ABBBOX_INSPECTOR_CHANNEL, PROTOCOL_VERSION, } from "../protocol.js";
|
|
|
2
2
|
import { createInspectorRuntime } from "../runtime/inspector.js";
|
|
3
3
|
import { withLocalhostAliases } from "./origin-aliases.js";
|
|
4
4
|
import { validateIncomingMessage } from "./validate.js";
|
|
5
|
-
// Only available in browser context
|
|
6
|
-
let addDebugLog = () => { };
|
|
7
|
-
if (typeof window !== "undefined") {
|
|
8
|
-
import("../runtime/overlay.js").then((m) => {
|
|
9
|
-
addDebugLog = m.addDebugLog;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
5
|
export function createInspectorClient(options) {
|
|
13
6
|
const win = options.window ?? globalThis.window;
|
|
14
7
|
const doc = options.document ?? win.document;
|
|
15
8
|
const allowedOrigins = withLocalhostAliases(options.allowedHostOrigins);
|
|
16
|
-
addDebugLog(`Client init: sessionId=${options.sessionId}`);
|
|
17
|
-
addDebugLog(`Allowed origins: ${allowedOrigins.join(", ")}`);
|
|
18
|
-
addDebugLog(`Window href: ${win.location.href}`);
|
|
19
|
-
addDebugLog(`Parent href: ${win.parent?.location?.href ?? "N/A"}`);
|
|
20
9
|
const send = (message) => {
|
|
21
|
-
if (!win.parent || win.parent === win)
|
|
22
|
-
addDebugLog(`send() skipped: parent=${!!win.parent}`);
|
|
10
|
+
if (!win.parent || win.parent === win)
|
|
23
11
|
return;
|
|
24
|
-
}
|
|
25
|
-
let sent = false;
|
|
26
|
-
// Try each allowed origin
|
|
27
12
|
for (const targetOrigin of allowedOrigins) {
|
|
28
|
-
|
|
29
|
-
addDebugLog(`→ ${message.type} on ${targetOrigin}`);
|
|
30
|
-
win.parent.postMessage(message, targetOrigin);
|
|
31
|
-
sent = true;
|
|
32
|
-
addDebugLog(`✓ ${message.type} sent`);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
addDebugLog(`✗ ${targetOrigin}: ${String(err).slice(0, 40)}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// If all allowed origins failed, try wildcard
|
|
40
|
-
if (!sent) {
|
|
41
|
-
try {
|
|
42
|
-
addDebugLog(`→ ${message.type} on wildcard`);
|
|
43
|
-
win.parent.postMessage(message, "*");
|
|
44
|
-
sent = true;
|
|
45
|
-
addDebugLog(`✓ ${message.type} sent via *`);
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
addDebugLog(`✗ Wildcard: ${String(err).slice(0, 40)}`);
|
|
49
|
-
}
|
|
13
|
+
win.parent.postMessage(message, targetOrigin);
|
|
50
14
|
}
|
|
51
15
|
};
|
|
52
16
|
const base = () => ({
|
|
@@ -83,25 +47,15 @@ export function createInspectorClient(options) {
|
|
|
83
47
|
sessionId: options.sessionId,
|
|
84
48
|
allowedOrigins,
|
|
85
49
|
});
|
|
86
|
-
if (!msg)
|
|
87
|
-
addDebugLog(`Message rejected from ${event.origin}`);
|
|
50
|
+
if (!msg)
|
|
88
51
|
return;
|
|
89
|
-
|
|
90
|
-
addDebugLog(`← Received: ${msg.type}`);
|
|
91
|
-
if (msg.type === "INSPECTOR_HOST_HELLO") {
|
|
92
|
-
addDebugLog(` Sending INSPECTOR_READY`);
|
|
52
|
+
if (msg.type === "INSPECTOR_HOST_HELLO")
|
|
93
53
|
sendReady();
|
|
94
|
-
|
|
95
|
-
if (msg.type === "INSPECTOR_ENABLE") {
|
|
96
|
-
addDebugLog(` Enabling inspector runtime`);
|
|
54
|
+
if (msg.type === "INSPECTOR_ENABLE")
|
|
97
55
|
runtime.enable();
|
|
98
|
-
|
|
99
|
-
if (msg.type === "INSPECTOR_DISABLE") {
|
|
100
|
-
addDebugLog(` Disabling inspector runtime`);
|
|
56
|
+
if (msg.type === "INSPECTOR_DISABLE")
|
|
101
57
|
runtime.disable();
|
|
102
|
-
}
|
|
103
58
|
if (msg.type === "APPLY_CHANGE_MARKERS") {
|
|
104
|
-
addDebugLog(` Applying ${msg.markers.length} change markers`);
|
|
105
59
|
runtime.setChangeMarkers(msg.markers);
|
|
106
60
|
}
|
|
107
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/host/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,gBAAgB,CAAC;AAE3E,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,GACvB,gBAAgB,GAAG,IAAI,CAKzB;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,MAAM,GACnB,IAAI,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/host/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,gBAAgB,CAAC;AAE3E,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,GACvB,gBAAgB,GAAG,IAAI,CAKzB;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,MAAM,GACnB,IAAI,CAEN"}
|
package/dist/host/validate.js
CHANGED
|
@@ -9,25 +9,5 @@ export function validateIncomingMessage(data, origin, options) {
|
|
|
9
9
|
return data;
|
|
10
10
|
}
|
|
11
11
|
export function postToTarget(target, message, targetOrigin) {
|
|
12
|
-
|
|
13
|
-
target.postMessage(message, targetOrigin);
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
// If postMessage fails (e.g., origin mismatch with localhost vs 127.0.0.1),
|
|
17
|
-
// try common alternative origins
|
|
18
|
-
const fallbackOrigins = [
|
|
19
|
-
targetOrigin.replace("://localhost", "://127.0.0.1"),
|
|
20
|
-
targetOrigin.replace("://127.0.0.1", "://localhost"),
|
|
21
|
-
"*",
|
|
22
|
-
];
|
|
23
|
-
for (const origin of fallbackOrigins) {
|
|
24
|
-
try {
|
|
25
|
-
target.postMessage(message, origin);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
// Continue to next fallback
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
12
|
+
target.postMessage(message, targetOrigin);
|
|
33
13
|
}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -47,6 +47,21 @@ export type ElementMetadata = {
|
|
|
47
47
|
/** Native disabled state when the element supports it (e.g. button, input). */
|
|
48
48
|
disabled: boolean | null;
|
|
49
49
|
attributes: Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* Live state of form controls near the element (its form, or the nearest
|
|
52
|
+
* container with controls). Values are never included, only whether filled.
|
|
53
|
+
*/
|
|
54
|
+
nearbyFields?: NearbyFieldState[];
|
|
55
|
+
};
|
|
56
|
+
export type NearbyFieldState = {
|
|
57
|
+
tagName: string;
|
|
58
|
+
type: string | null;
|
|
59
|
+
label: string | null;
|
|
60
|
+
placeholder: string | null;
|
|
61
|
+
required: boolean;
|
|
62
|
+
disabled: boolean;
|
|
63
|
+
state: "empty" | "filled" | "checked" | "unchecked";
|
|
64
|
+
isSelected: boolean;
|
|
50
65
|
};
|
|
51
66
|
export type RuntimeElementRef = {
|
|
52
67
|
/** Stable within a preview session for a given DOM node identity. */
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAE3C,eAAO,MAAM,wBAAwB,EAAG,iBAA0B,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAA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AC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IACrD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":["../../src/runtime/inspector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAkBxE,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,gBAAgB,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IACpD,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IACrD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CAuPlB"}
|
|
@@ -15,6 +15,19 @@ export function createInspectorRuntime(options) {
|
|
|
15
15
|
const teardownListeners = () => {
|
|
16
16
|
win.removeEventListener("mousemove", onMove, true);
|
|
17
17
|
win.removeEventListener("pointerdown", onPointerDownCapture, true);
|
|
18
|
+
doc.removeEventListener("mouseout", onLeave, true);
|
|
19
|
+
};
|
|
20
|
+
/** No mousemove fires once the pointer leaves the iframe, so clear hover here. */
|
|
21
|
+
const onLeave = (event) => {
|
|
22
|
+
if (event.relatedTarget)
|
|
23
|
+
return;
|
|
24
|
+
if (raf) {
|
|
25
|
+
win.cancelAnimationFrame(raf);
|
|
26
|
+
raf = 0;
|
|
27
|
+
}
|
|
28
|
+
pendingTarget = null;
|
|
29
|
+
hovered = null;
|
|
30
|
+
hideHighlight(overlay.highlight);
|
|
18
31
|
};
|
|
19
32
|
const onMove = (event) => {
|
|
20
33
|
if (!enabled)
|
|
@@ -81,7 +94,6 @@ export function createInspectorRuntime(options) {
|
|
|
81
94
|
options.onHover?.(payloadFor(el));
|
|
82
95
|
}
|
|
83
96
|
function select(el) {
|
|
84
|
-
console.log("[inspector] element selected", el.tagName);
|
|
85
97
|
selected = el;
|
|
86
98
|
hovered = el;
|
|
87
99
|
positionSelectedHighlight(overlay.selectedHighlight, rectForElement(el));
|
|
@@ -147,6 +159,7 @@ export function createInspectorRuntime(options) {
|
|
|
147
159
|
enabled = true;
|
|
148
160
|
win.addEventListener("mousemove", onMove, true);
|
|
149
161
|
win.addEventListener("pointerdown", onPointerDownCapture, true);
|
|
162
|
+
doc.addEventListener("mouseout", onLeave, true);
|
|
150
163
|
},
|
|
151
164
|
disable: () => {
|
|
152
165
|
if (!enabled)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/runtime/metadata.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/runtime/metadata.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EAEf,cAAc,EACd,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAYxB,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAarE;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,GAAG,IAAI,GAC5B,mBAAmB,CAGrB;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,OAAO,GAAG,eAAe,CAkC5D;AAyFD,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAGzE"}
|
package/dist/runtime/metadata.js
CHANGED
|
@@ -60,8 +60,60 @@ export function extractMetadata(el) {
|
|
|
60
60
|
textPreview,
|
|
61
61
|
disabled: readDisabledState(el),
|
|
62
62
|
attributes,
|
|
63
|
+
nearbyFields: nearbyFieldStates(el),
|
|
63
64
|
};
|
|
64
65
|
}
|
|
66
|
+
const FIELD_SELECTOR = "input:not([type=hidden]), textarea, select";
|
|
67
|
+
const MAX_CONTAINER_HOPS = 4;
|
|
68
|
+
const MAX_NEARBY_FIELDS = 15;
|
|
69
|
+
function fieldContainer(el) {
|
|
70
|
+
const form = el.closest("form");
|
|
71
|
+
if (form)
|
|
72
|
+
return form;
|
|
73
|
+
let node = el.parentElement;
|
|
74
|
+
for (let hop = 0; node && hop < MAX_CONTAINER_HOPS; hop++) {
|
|
75
|
+
if (node.querySelector(FIELD_SELECTOR))
|
|
76
|
+
return node;
|
|
77
|
+
node = node.parentElement;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
function fieldLabel(control) {
|
|
82
|
+
const text = control.getAttribute("aria-label") ??
|
|
83
|
+
control.labels?.[0]?.textContent ??
|
|
84
|
+
null;
|
|
85
|
+
return text?.trim().slice(0, 80) || null;
|
|
86
|
+
}
|
|
87
|
+
/** Field emptiness only; typed values never leave the preview. */
|
|
88
|
+
function nearbyFieldStates(el) {
|
|
89
|
+
const container = fieldContainer(el);
|
|
90
|
+
if (!container)
|
|
91
|
+
return undefined;
|
|
92
|
+
const controls = Array.from(container.querySelectorAll(FIELD_SELECTOR)).slice(0, MAX_NEARBY_FIELDS);
|
|
93
|
+
if (controls.length === 0)
|
|
94
|
+
return undefined;
|
|
95
|
+
return controls.map((control) => {
|
|
96
|
+
const type = control instanceof HTMLInputElement ? control.type : control.getAttribute("type");
|
|
97
|
+
const checkable = control instanceof HTMLInputElement &&
|
|
98
|
+
(control.type === "checkbox" || control.type === "radio");
|
|
99
|
+
return {
|
|
100
|
+
tagName: control.tagName.toLowerCase(),
|
|
101
|
+
type,
|
|
102
|
+
label: fieldLabel(control),
|
|
103
|
+
placeholder: control.getAttribute("placeholder"),
|
|
104
|
+
required: control.required,
|
|
105
|
+
disabled: control.disabled,
|
|
106
|
+
state: checkable
|
|
107
|
+
? control.checked
|
|
108
|
+
? "checked"
|
|
109
|
+
: "unchecked"
|
|
110
|
+
: control.value.trim()
|
|
111
|
+
? "filled"
|
|
112
|
+
: "empty",
|
|
113
|
+
isSelected: control === el,
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
}
|
|
65
117
|
function readDisabledState(el) {
|
|
66
118
|
if (el instanceof HTMLButtonElement ||
|
|
67
119
|
el instanceof HTMLInputElement ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/runtime/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/runtime/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMhE,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,cAAc,CAAC;IAC1B,iBAAiB,EAAE,cAAc,CAAC;IAClC,WAAW,EAAE,cAAc,CAAC;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAgD5D;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,WAAW,GAChB,IAAI,CAQN;AAED,wBAAgB,yBAAyB,CACvC,iBAAiB,EAAE,cAAc,EACjC,IAAI,EAAE,WAAW,GAChB,IAAI,CAQN;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,CAE7D;AAED,wBAAgB,qBAAqB,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAE7E;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,WAAW,CAQvD;AAOD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,YAAY,EAAE,EACvB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,EACjD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GACpC,IAAI,CA+DN"}
|
package/dist/runtime/overlay.js
CHANGED
|
@@ -1,56 +1,13 @@
|
|
|
1
1
|
const HIGHLIGHT_Z = 2147483646;
|
|
2
2
|
const SELECTED_HIGHLIGHT_Z = 2147483643;
|
|
3
3
|
const MARKER_Z = 2147483645;
|
|
4
|
-
// Debug panel for on-screen logging
|
|
5
|
-
let debugPanel = null;
|
|
6
|
-
let debugLogs = [];
|
|
7
|
-
export function addDebugLog(message) {
|
|
8
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
9
|
-
const log = `[${timestamp}] ${message}`;
|
|
10
|
-
debugLogs.push(log);
|
|
11
|
-
if (debugLogs.length > 20)
|
|
12
|
-
debugLogs.shift(); // Keep last 20 logs
|
|
13
|
-
updateDebugPanel();
|
|
14
|
-
}
|
|
15
|
-
function updateDebugPanel() {
|
|
16
|
-
if (!debugPanel)
|
|
17
|
-
createDebugPanel();
|
|
18
|
-
if (debugPanel) {
|
|
19
|
-
debugPanel.textContent = debugLogs.join("\n");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function createDebugPanel() {
|
|
23
|
-
if (debugPanel)
|
|
24
|
-
return;
|
|
25
|
-
debugPanel = document.createElement("div");
|
|
26
|
-
debugPanel.setAttribute("data-abbox-debug-panel", "true");
|
|
27
|
-
Object.assign(debugPanel.style, {
|
|
28
|
-
position: "fixed",
|
|
29
|
-
bottom: "10px",
|
|
30
|
-
right: "10px",
|
|
31
|
-
background: "rgba(0, 0, 0, 0.9)",
|
|
32
|
-
color: "#0f0",
|
|
33
|
-
padding: "10px",
|
|
34
|
-
borderRadius: "4px",
|
|
35
|
-
fontFamily: "monospace",
|
|
36
|
-
fontSize: "11px",
|
|
37
|
-
maxWidth: "400px",
|
|
38
|
-
maxHeight: "300px",
|
|
39
|
-
overflowY: "auto",
|
|
40
|
-
zIndex: "2147483647",
|
|
41
|
-
whiteSpace: "pre-wrap",
|
|
42
|
-
wordBreak: "break-word",
|
|
43
|
-
});
|
|
44
|
-
document.body.appendChild(debugPanel);
|
|
45
|
-
}
|
|
46
4
|
export function createOverlay(root) {
|
|
47
|
-
addDebugLog("Creating overlay elements");
|
|
48
5
|
const selectedHighlight = root.createElement("div");
|
|
49
6
|
selectedHighlight.setAttribute("data-abbox-inspector", "selected-highlight");
|
|
50
7
|
Object.assign(selectedHighlight.style, {
|
|
51
8
|
position: "fixed",
|
|
52
9
|
pointerEvents: "none",
|
|
53
|
-
border: "
|
|
10
|
+
border: "2px dashed #2563eb",
|
|
54
11
|
background: "rgba(37, 99, 235, 0.06)",
|
|
55
12
|
borderRadius: "2px",
|
|
56
13
|
zIndex: String(SELECTED_HIGHLIGHT_Z),
|
|
@@ -62,7 +19,7 @@ export function createOverlay(root) {
|
|
|
62
19
|
Object.assign(highlight.style, {
|
|
63
20
|
position: "fixed",
|
|
64
21
|
pointerEvents: "none",
|
|
65
|
-
border: "
|
|
22
|
+
border: "2px solid #2563eb",
|
|
66
23
|
background: "rgba(37, 99, 235, 0.12)",
|
|
67
24
|
borderRadius: "2px",
|
|
68
25
|
zIndex: String(HIGHLIGHT_Z),
|
|
@@ -99,7 +56,6 @@ export function positionHighlight(highlight, rect) {
|
|
|
99
56
|
});
|
|
100
57
|
}
|
|
101
58
|
export function positionSelectedHighlight(selectedHighlight, rect) {
|
|
102
|
-
addDebugLog(`Selected: ${rect.width}×${rect.height} at ${Math.round(rect.x)},${Math.round(rect.y)}`);
|
|
103
59
|
Object.assign(selectedHighlight.style, {
|
|
104
60
|
display: "block",
|
|
105
61
|
left: `${rect.x}px`,
|