@lightworkai.official/debug-capture 0.19.11 → 0.19.13
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/debug-capture.js +14 -14
- package/dist/index.mjs +17 -17
- package/dist/live.d.ts +12 -0
- package/package.json +1 -1
- package/src/live.ts +24 -6
- package/src/ui/chatBubble.ts +7 -1
package/dist/live.d.ts
CHANGED
|
@@ -9,6 +9,18 @@ export interface RingingCall {
|
|
|
9
9
|
ringUntil: string;
|
|
10
10
|
side?: string | null;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The support host restarting (a deploy — it says 1012 as it stops): every widget on every page of every host app lost
|
|
14
|
+
* its socket in the same instant, and each came back after exactly 2 s — the whole fleet's tickets, sign-ins and
|
|
15
|
+
* sockets on the support host's one thread in the same second. Back somewhere in this window instead, at random.
|
|
16
|
+
*/
|
|
17
|
+
export declare const RESTART_SPREAD_MS = 15000;
|
|
18
|
+
/**
|
|
19
|
+
* How long before trying again — each step ×0.5–1.5, never the same moment as every other widget's (the desk's own tabs
|
|
20
|
+
* do the same) — `restart`: the host said it restarts (1012); `slow`:
|
|
21
|
+
* refused for now (429), or nobody signed in yet; else the next step of the ladder. Pure but for the dice, for the tests.
|
|
22
|
+
*/
|
|
23
|
+
export declare function retryWait(how: "restart" | "slow" | null, attempt: number, roll?: () => number): number;
|
|
12
24
|
/** `wss://support.example/api/presence/ws?t=…` — the support host's scheme, the socket's own path. Pure, for the tests. */
|
|
13
25
|
export declare function liveSocketUrl(host: string, ticket: string): string;
|
|
14
26
|
/** Where the card sends them: their request, with the call — the support host rings it there. Pure, for the tests. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightworkai.official/debug-capture",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.13",
|
|
4
4
|
"description": "Report-a-problem widget: rolling network/console/action capture, optional rrweb session replay, annotated screenshot, and submission to a Lightwork Support host",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.mjs",
|
package/src/live.ts
CHANGED
|
@@ -42,6 +42,22 @@ export interface RingingCall {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const RETRY_MS = [2000, 5000, 15_000, 30_000, 60_000];
|
|
45
|
+
/**
|
|
46
|
+
* The support host restarting (a deploy — it says 1012 as it stops): every widget on every page of every host app lost
|
|
47
|
+
* its socket in the same instant, and each came back after exactly 2 s — the whole fleet's tickets, sign-ins and
|
|
48
|
+
* sockets on the support host's one thread in the same second. Back somewhere in this window instead, at random.
|
|
49
|
+
*/
|
|
50
|
+
export const RESTART_SPREAD_MS = 15_000;
|
|
51
|
+
/**
|
|
52
|
+
* How long before trying again — each step ×0.5–1.5, never the same moment as every other widget's (the desk's own tabs
|
|
53
|
+
* do the same) — `restart`: the host said it restarts (1012); `slow`:
|
|
54
|
+
* refused for now (429), or nobody signed in yet; else the next step of the ladder. Pure but for the dice, for the tests.
|
|
55
|
+
*/
|
|
56
|
+
export function retryWait(how: "restart" | "slow" | null, attempt: number, roll: () => number = Math.random): number {
|
|
57
|
+
if (how === "restart") return 1000 + Math.round(roll() * RESTART_SPREAD_MS);
|
|
58
|
+
const step = how === "slow" ? RETRY_MS[RETRY_MS.length - 1]! : RETRY_MS[Math.min(attempt, RETRY_MS.length - 1)]!;
|
|
59
|
+
return Math.round(step * (0.5 + roll()));
|
|
60
|
+
}
|
|
45
61
|
const LIVE_STATES = new Set(["ringing", "active"]);
|
|
46
62
|
const PING_MS = 20_000;
|
|
47
63
|
|
|
@@ -144,9 +160,9 @@ export function stopLiveRing(): void {
|
|
|
144
160
|
closeCallFrame();
|
|
145
161
|
}
|
|
146
162
|
|
|
147
|
-
function schedule(slow =
|
|
163
|
+
function schedule(how: "restart" | "slow" | null = null): void {
|
|
148
164
|
if (stopped) return;
|
|
149
|
-
const wait =
|
|
165
|
+
const wait = retryWait(how, how ? retry : retry++);
|
|
150
166
|
clearTimeout(reconnectTimer);
|
|
151
167
|
reconnectTimer = setTimeout(() => void connect(), wait);
|
|
152
168
|
}
|
|
@@ -160,7 +176,7 @@ async function connect(): Promise<void> {
|
|
|
160
176
|
stopped = true;
|
|
161
177
|
return;
|
|
162
178
|
}
|
|
163
|
-
return schedule(
|
|
179
|
+
return schedule("slow");
|
|
164
180
|
}
|
|
165
181
|
tokenless = 0;
|
|
166
182
|
let res: Response;
|
|
@@ -174,7 +190,8 @@ async function connect(): Promise<void> {
|
|
|
174
190
|
stopped = true;
|
|
175
191
|
return;
|
|
176
192
|
}
|
|
177
|
-
|
|
193
|
+
// Refused for now: slowly. The host restarting (its proxy answering for it): back at random within the window.
|
|
194
|
+
if (!res.ok) return schedule(res.status === 429 ? "slow" : res.status === 502 || res.status === 503 ? "restart" : null);
|
|
178
195
|
let out: { calls?: boolean; ticket?: string | null; call?: RingingCall | null };
|
|
179
196
|
try {
|
|
180
197
|
out = await res.json();
|
|
@@ -221,10 +238,11 @@ async function connect(): Promise<void> {
|
|
|
221
238
|
/* not ours to read */
|
|
222
239
|
}
|
|
223
240
|
};
|
|
224
|
-
ws.onclose = () => {
|
|
241
|
+
ws.onclose = (e) => {
|
|
225
242
|
clearInterval(pinger);
|
|
226
243
|
if (socket === ws) socket = null;
|
|
227
|
-
|
|
244
|
+
// 1012: the support host is restarting — every widget heard it at once; each comes back at its own moment.
|
|
245
|
+
schedule(e.code === 1012 ? "restart" : null);
|
|
228
246
|
};
|
|
229
247
|
}
|
|
230
248
|
|
package/src/ui/chatBubble.ts
CHANGED
|
@@ -540,6 +540,8 @@ function watchPage(on: boolean): void {
|
|
|
540
540
|
lastPath = pagePath();
|
|
541
541
|
layout();
|
|
542
542
|
queueRescan("now");
|
|
543
|
+
// The page the person is on travels with what they write (sup-plana CHAT-ASSIST-PLAN §10, decision 17).
|
|
544
|
+
if (frame) post({ type: "page", path: lastPath });
|
|
543
545
|
}, 1000);
|
|
544
546
|
}
|
|
545
547
|
|
|
@@ -704,7 +706,10 @@ async function onFrame(e: MessageEvent): Promise<void> {
|
|
|
704
706
|
void openSupportPortal({ returnTo: portalPath(typeof d.path === "string" ? d.path : "") });
|
|
705
707
|
return;
|
|
706
708
|
}
|
|
707
|
-
if (d.type === "ready")
|
|
709
|
+
if (d.type === "ready") {
|
|
710
|
+
post({ type: "page", path: pagePath() });
|
|
711
|
+
return post({ type: isOpen ? "shown" : "hidden" });
|
|
712
|
+
}
|
|
708
713
|
if (d.type === "close") return closeSupportChat();
|
|
709
714
|
if (d.type === "drag") return onPanelDrag(d);
|
|
710
715
|
if (d.type === "unread" && typeof d.total === "number") return setBadge(d.total);
|
|
@@ -743,6 +748,7 @@ export function openSupportChat(): void {
|
|
|
743
748
|
shadow?.querySelector(".wrap")?.classList.add("open");
|
|
744
749
|
bubble?.setAttribute("aria-expanded", "true");
|
|
745
750
|
setLabel();
|
|
751
|
+
post({ type: "page", path: pagePath() });
|
|
746
752
|
post({ type: "shown" });
|
|
747
753
|
frame.focus();
|
|
748
754
|
}
|