@lightworkai.official/debug-capture 0.16.0 → 0.17.1

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.
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The team's marks on this page (0.17) — ชี้ · วาด · กรอบ, drawn by the support team on the screen this person is
3
+ * sharing with them, shown here where they are working (the support host's docs/CALLS-PLAN.md §17).
4
+ *
5
+ * The call lives in its frame in a corner (ui/callFrame), which cannot draw outside itself; it hands each mark up and
6
+ * this layer draws it over the whole page: never in the way (no pointer events — every click goes to the app beneath),
7
+ * gone when the marks fade, and taken away with the call. The same drawing as the support host's (../ink). Marked as
8
+ * ours, so a report filed meanwhile does not photograph it.
9
+ *
10
+ * It covers the page exactly as the shared picture does: a tab is shared as its viewport, so a mark at a fraction of
11
+ * the picture is at that fraction of the window.
12
+ */
13
+ import { InkPainter, InkScene, type InkOp } from "../ink";
14
+
15
+ const HOST_TAG = "lw-call-ink";
16
+
17
+ let host: HTMLElement | null = null;
18
+ let scene: InkScene | null = null;
19
+ let painter: InkPainter | null = null;
20
+
21
+ function mount(): void {
22
+ if (host?.isConnected && painter) return;
23
+ host = document.createElement(HOST_TAG);
24
+ host.dataset.debugReporter = "true";
25
+ const root = host.attachShadow({ mode: "open" });
26
+ const style = document.createElement("style");
27
+ // Over the page and its scrollbar, as the shared picture is; under the call's own frame.
28
+ style.textContent = `:host { all: initial; }
29
+ canvas { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2147483002; }`;
30
+ const canvas = document.createElement("canvas");
31
+ canvas.setAttribute("aria-hidden", "true");
32
+ canvas.dataset.lwCallInk = "";
33
+ root.append(style, canvas);
34
+ document.body.append(host);
35
+ scene = new InkScene();
36
+ painter = new InkPainter(canvas, scene, () => ({ w: window.innerWidth, h: window.innerHeight }));
37
+ }
38
+
39
+ /** A mark from the team, as the call's frame handed it up (already read by `readInkOp`). */
40
+ export function inkOnPage(op: InkOp): void {
41
+ if (typeof document === "undefined") return;
42
+ if (op.op === "clear" && !host) return;
43
+ mount();
44
+ scene!.apply(op);
45
+ painter!.kick();
46
+ }
47
+
48
+ export function inkMarksOnPage(): number {
49
+ return scene?.size ?? 0;
50
+ }
51
+
52
+ /** The call is over: the layer goes. */
53
+ export function removeInkLayer(): void {
54
+ painter?.stop();
55
+ host?.remove();
56
+ host = null;
57
+ scene = null;
58
+ painter = null;
59
+ }