@abbox/inspector 0.4.10 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/host/client-bridge.d.ts.map +1 -1
- package/dist/host/client-bridge.js +7 -35
- package/dist/host/validate.d.ts.map +1 -1
- package/dist/host/validate.js +23 -16
- package/dist/runtime/overlay.d.ts +0 -1
- package/dist/runtime/overlay.d.ts.map +1 -1
- package/dist/runtime/overlay.js +2 -44
- 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,CA2FjB"}
|
|
@@ -2,50 +2,32 @@ 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
12
|
let sent = false;
|
|
26
13
|
// Try each allowed origin
|
|
27
14
|
for (const targetOrigin of allowedOrigins) {
|
|
28
15
|
try {
|
|
29
|
-
addDebugLog(`→ ${message.type} on ${targetOrigin}`);
|
|
30
16
|
win.parent.postMessage(message, targetOrigin);
|
|
31
17
|
sent = true;
|
|
32
|
-
addDebugLog(`✓ ${message.type} sent`);
|
|
33
18
|
break;
|
|
34
19
|
}
|
|
35
20
|
catch (err) {
|
|
36
|
-
|
|
21
|
+
// Try next origin
|
|
37
22
|
}
|
|
38
23
|
}
|
|
39
24
|
// If all allowed origins failed, try wildcard
|
|
40
25
|
if (!sent) {
|
|
41
26
|
try {
|
|
42
|
-
addDebugLog(`→ ${message.type} on wildcard`);
|
|
43
27
|
win.parent.postMessage(message, "*");
|
|
44
|
-
sent = true;
|
|
45
|
-
addDebugLog(`✓ ${message.type} sent via *`);
|
|
46
28
|
}
|
|
47
29
|
catch (err) {
|
|
48
|
-
|
|
30
|
+
// Give up silently
|
|
49
31
|
}
|
|
50
32
|
}
|
|
51
33
|
};
|
|
@@ -83,25 +65,15 @@ export function createInspectorClient(options) {
|
|
|
83
65
|
sessionId: options.sessionId,
|
|
84
66
|
allowedOrigins,
|
|
85
67
|
});
|
|
86
|
-
if (!msg)
|
|
87
|
-
addDebugLog(`Message rejected from ${event.origin}`);
|
|
68
|
+
if (!msg)
|
|
88
69
|
return;
|
|
89
|
-
|
|
90
|
-
addDebugLog(`← Received: ${msg.type}`);
|
|
91
|
-
if (msg.type === "INSPECTOR_HOST_HELLO") {
|
|
92
|
-
addDebugLog(` Sending INSPECTOR_READY`);
|
|
70
|
+
if (msg.type === "INSPECTOR_HOST_HELLO")
|
|
93
71
|
sendReady();
|
|
94
|
-
|
|
95
|
-
if (msg.type === "INSPECTOR_ENABLE") {
|
|
96
|
-
addDebugLog(` Enabling inspector runtime`);
|
|
72
|
+
if (msg.type === "INSPECTOR_ENABLE")
|
|
97
73
|
runtime.enable();
|
|
98
|
-
|
|
99
|
-
if (msg.type === "INSPECTOR_DISABLE") {
|
|
100
|
-
addDebugLog(` Disabling inspector runtime`);
|
|
74
|
+
if (msg.type === "INSPECTOR_DISABLE")
|
|
101
75
|
runtime.disable();
|
|
102
|
-
}
|
|
103
76
|
if (msg.type === "APPLY_CHANGE_MARKERS") {
|
|
104
|
-
addDebugLog(` Applying ${msg.markers.length} change markers`);
|
|
105
77
|
runtime.setChangeMarkers(msg.markers);
|
|
106
78
|
}
|
|
107
79
|
};
|
|
@@ -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,CA6BN"}
|
package/dist/host/validate.js
CHANGED
|
@@ -9,25 +9,32 @@ export function validateIncomingMessage(data, origin, options) {
|
|
|
9
9
|
return data;
|
|
10
10
|
}
|
|
11
11
|
export function postToTarget(target, message, targetOrigin) {
|
|
12
|
+
// Try primary origin first
|
|
12
13
|
try {
|
|
13
14
|
target.postMessage(message, targetOrigin);
|
|
15
|
+
return;
|
|
14
16
|
}
|
|
15
|
-
catch
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Continue to next fallback
|
|
30
|
-
}
|
|
17
|
+
catch {
|
|
18
|
+
// Silently fail and try fallback
|
|
19
|
+
}
|
|
20
|
+
// Try localhost/127.0.0.1 variant
|
|
21
|
+
const variant = targetOrigin
|
|
22
|
+
.replace("://localhost", "://127.0.0.1")
|
|
23
|
+
.replace("://127.0.0.1", "://localhost");
|
|
24
|
+
if (variant !== targetOrigin) {
|
|
25
|
+
try {
|
|
26
|
+
target.postMessage(message, variant);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Silently fail and try wildcard
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
// Last resort: wildcard (bypasses origin check)
|
|
34
|
+
try {
|
|
35
|
+
target.postMessage(message, "*");
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Give up silently
|
|
39
|
+
}
|
|
33
40
|
}
|
|
@@ -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,CAiD5D;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,CASN;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,50 +1,8 @@
|
|
|
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
|
-
|
|
5
|
+
console.log("[inspector] creating overlay");
|
|
48
6
|
const selectedHighlight = root.createElement("div");
|
|
49
7
|
selectedHighlight.setAttribute("data-abbox-inspector", "selected-highlight");
|
|
50
8
|
Object.assign(selectedHighlight.style, {
|
|
@@ -99,7 +57,7 @@ export function positionHighlight(highlight, rect) {
|
|
|
99
57
|
});
|
|
100
58
|
}
|
|
101
59
|
export function positionSelectedHighlight(selectedHighlight, rect) {
|
|
102
|
-
|
|
60
|
+
console.log("[inspector] positioning selected highlight at", rect);
|
|
103
61
|
Object.assign(selectedHighlight.style, {
|
|
104
62
|
display: "block",
|
|
105
63
|
left: `${rect.x}px`,
|