@lightworkai.official/debug-capture 0.19.2 → 0.19.4

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/live.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export interface RingingCall {
2
2
  id: string;
3
- ticketId: string;
3
+ /** A เรื่อง's call — or a chat's (โทรจากแชท, 0.19.4): then `chatId`, and the key "แชท". */
4
+ ticketId: string | null;
5
+ chatId?: string | null;
4
6
  ticketKey: string;
5
7
  ticketTitle: string;
6
8
  status: string;
@@ -10,7 +12,7 @@ export interface RingingCall {
10
12
  /** `wss://support.example/api/presence/ws?t=…` — the support host's scheme, the socket's own path. Pure, for the tests. */
11
13
  export declare function liveSocketUrl(host: string, ticket: string): string;
12
14
  /** Where the card sends them: their request, with the call — the support host rings it there. Pure, for the tests. */
13
- export declare function answerPath(call: Pick<RingingCall, "id" | "ticketId">): string;
15
+ export declare function answerPath(call: Pick<RingingCall, "id" | "ticketId" | "chatId">): string;
14
16
  /** Is this a call ringing for the person at this widget? */
15
17
  export declare function ringsHere(call: Pick<RingingCall, "status" | "side">): boolean;
16
18
  type LiveFrame = {
@@ -1,5 +1,7 @@
1
1
  /** The panel's address: the support host's page, told the realm, signing in by hand-off (no token in the address). */
2
2
  export declare function supportFrameUrl(host: string, realmKey: string): string;
3
+ /** Where the panel's เปิดในระบบแจ้งปัญหา may land: the person's chat or their เรื่อง — anything else, their chat. Pure. */
4
+ export declare function portalPath(path: string): string;
3
5
  /** The desk's face on the button — the support host's public file, the same picture as its replies (0.19.2). */
4
6
  export declare function supportFaceUrl(host: string): string;
5
7
  /**
package/dist/ui/ring.d.ts CHANGED
@@ -2,6 +2,8 @@ export interface RingCall {
2
2
  id: string;
3
3
  ticketKey: string;
4
4
  ticketTitle: string;
5
+ /** A chat's call (โทรจากแชท, 0.19.4) — said as แชทกับทีมงาน, never "เรื่อง แชท". */
6
+ chatId?: string | null;
5
7
  }
6
8
  export interface RingHandlers {
7
9
  /** The portal's way: runs INSIDE the press — a tab can be opened only there, before anything is awaited. */
@@ -14,8 +16,8 @@ export interface RingHandlers {
14
16
  }
15
17
  /** `frame`: the call's own card while its frame comes; `portal`: answer in a new tab (no frame, or it failed). */
16
18
  export type RingMode = "frame" | "portal";
17
- /** "เรื่อง CALL-12 · title" — the line under the card's title. Pure, for the tests. */
18
- export declare function ringAbout(template: string, call: RingCall): string;
19
+ /** "เรื่อง CALL-12 · title" — the line under the card's title; a chat's call, its own words (`chat`). Pure, for the tests. */
20
+ export declare function ringAbout(template: string, call: RingCall, chat?: string): string;
19
21
  /** Show the ring for this call — once; the same call again changes nothing. */
20
22
  export declare function showRing(call: RingCall, handlers: RingHandlers, mode?: RingMode): void;
21
23
  /** รับสาย pressed while the call's frame comes: said, and nothing more to press until it is there. */
@@ -106,6 +106,8 @@ export interface Strings {
106
106
  /** A call from the support team (ui/ring). `ringAbout` carries `{key}` and `{title}`. */
107
107
  ringTitle: string;
108
108
  ringAbout: string;
109
+ /** A call from the chat, not a เรื่อง (โทรจากแชท, 0.19.4) — the line under the card's title. */
110
+ ringChat: string;
109
111
  ringHow: string;
110
112
  ringOpen: string;
111
113
  ringDecline: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightworkai.official/debug-capture",
3
- "version": "0.19.2",
3
+ "version": "0.19.4",
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
@@ -31,7 +31,9 @@ import { inkOnPage, removeInkLayer } from "./ui/inkOverlay";
31
31
 
32
32
  export interface RingingCall {
33
33
  id: string;
34
- ticketId: string;
34
+ /** A เรื่อง's call — or a chat's (โทรจากแชท, 0.19.4): then `chatId`, and the key "แชท". */
35
+ ticketId: string | null;
36
+ chatId?: string | null;
35
37
  ticketKey: string;
36
38
  ticketTitle: string;
37
39
  status: string;
@@ -65,7 +67,9 @@ export function liveSocketUrl(host: string, ticket: string): string {
65
67
  }
66
68
 
67
69
  /** Where the card sends them: their request, with the call — the support host rings it there. Pure, for the tests. */
68
- export function answerPath(call: Pick<RingingCall, "id" | "ticketId">): string {
70
+ export function answerPath(call: Pick<RingingCall, "id" | "ticketId" | "chatId">): string {
71
+ // A chat's call (0.19.4): their chat with the team, where it rings.
72
+ if (call.chatId || !call.ticketId) return `/me/chat?call=${call.id}`;
69
73
  return `/me/tickets/${call.ticketId}?call=${call.id}`;
70
74
  }
71
75
 
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { chatPlace, getConfig } from "../config";
17
17
  import { hostToken, onLiveFrame } from "../live";
18
+ import { openSupportPortal } from "../portal";
18
19
  import { launch } from "../reporter";
19
20
  import { followHostFont, OWN_FONTS } from "./hostFont";
20
21
  import { strings } from "./strings";
@@ -110,6 +111,10 @@ export function supportFrameUrl(host: string, realmKey: string): string {
110
111
  url.searchParams.set("hand", "1");
111
112
  return url.toString();
112
113
  }
114
+ /** Where the panel's เปิดในระบบแจ้งปัญหา may land: the person's chat or their เรื่อง — anything else, their chat. Pure. */
115
+ export function portalPath(path: string): string {
116
+ return /^\/me\/(?:chat|tickets(?:\/[\w-]{1,64})?)$/.test(path) ? path : "/me/chat";
117
+ }
113
118
  /** The desk's face on the button — the support host's public file, the same picture as its replies (0.19.2). */
114
119
  export function supportFaceUrl(host: string): string {
115
120
  return new URL("support-face.webp", base(host)).toString();
@@ -389,11 +394,18 @@ function post(message: Record<string, unknown>): void {
389
394
 
390
395
  async function onFrame(e: MessageEvent): Promise<void> {
391
396
  if (!frame || e.source !== frame.contentWindow) return;
392
- const d = e.data as { source?: unknown; type?: unknown; total?: unknown; phase?: unknown; x?: unknown; y?: unknown } | null;
397
+ const d = e.data as { source?: unknown; type?: unknown; total?: unknown; phase?: unknown; x?: unknown; y?: unknown; path?: unknown } | null;
393
398
  if (!d || d.source !== FRAME) return;
394
399
  if (d.type === "hello") {
395
400
  const token = await hostToken();
396
- if (token) post({ type: "token", token });
401
+ // What this widget does for the panel — it shows only buttons that work here (0.19.3: the portal hand-off).
402
+ if (token) post({ type: "token", token, can: ["portal"] });
403
+ return;
404
+ }
405
+ if (d.type === "portal") {
406
+ // เปิดในระบบแจ้งปัญหา: the whole portal at that page, by the usual hand-off — its countdown over the open panel,
407
+ // a fresh sign-in, a new tab. Only the reporter's own pages; the portal checks again on arrival.
408
+ void openSupportPortal({ returnTo: portalPath(typeof d.path === "string" ? d.path : "") });
397
409
  return;
398
410
  }
399
411
  if (d.type === "ready") return post({ type: isOpen ? "shown" : "hidden" });
package/src/ui/ring.ts CHANGED
@@ -87,6 +87,8 @@ export interface RingCall {
87
87
  id: string;
88
88
  ticketKey: string;
89
89
  ticketTitle: string;
90
+ /** A chat's call (โทรจากแชท, 0.19.4) — said as แชทกับทีมงาน, never "เรื่อง แชท". */
91
+ chatId?: string | null;
90
92
  }
91
93
 
92
94
  export interface RingHandlers {
@@ -106,8 +108,9 @@ let host: HTMLElement | null = null;
106
108
  let shownId: string | null = null;
107
109
  let titleBefore: string | null = null;
108
110
 
109
- /** "เรื่อง CALL-12 · title" — the line under the card's title. Pure, for the tests. */
110
- export function ringAbout(template: string, call: RingCall): string {
111
+ /** "เรื่อง CALL-12 · title" — the line under the card's title; a chat's call, its own words (`chat`). Pure, for the tests. */
112
+ export function ringAbout(template: string, call: RingCall, chat?: string): string {
113
+ if (call.chatId) return chat ?? call.ticketTitle;
111
114
  return template.replace("{key}", call.ticketKey).replace("{title}", call.ticketTitle);
112
115
  }
113
116
 
@@ -164,7 +167,7 @@ function render(root: ShadowRoot, call: RingCall, handlers: RingHandlers, mode:
164
167
  h.textContent = s.ringTitle;
165
168
  const about = document.createElement("p");
166
169
  about.className = "about";
167
- about.textContent = ringAbout(s.ringAbout, call);
170
+ about.textContent = ringAbout(s.ringAbout, call, s.ringChat);
168
171
  about.title = about.textContent;
169
172
  words.append(h, about);
170
173
  head.append(icon, words);
package/src/ui/strings.ts CHANGED
@@ -111,6 +111,8 @@ export interface Strings {
111
111
  /** A call from the support team (ui/ring). `ringAbout` carries `{key}` and `{title}`. */
112
112
  ringTitle: string;
113
113
  ringAbout: string;
114
+ /** A call from the chat, not a เรื่อง (โทรจากแชท, 0.19.4) — the line under the card's title. */
115
+ ringChat: string;
114
116
  ringHow: string;
115
117
  ringOpen: string;
116
118
  ringDecline: string;
@@ -211,6 +213,7 @@ const th: Strings = {
211
213
  hours: "{n} ชั่วโมง",
212
214
  ringTitle: "ทีมงานกำลังโทรหาคุณ",
213
215
  ringAbout: "เรื่อง {key} · {title}",
216
+ ringChat: "จากแชทกับทีมงาน",
214
217
  ringHow: "รับสายในหน้าคำร้องของคุณ — เปิดในแท็บใหม่ ไม่ต้องเข้าสู่ระบบอีก",
215
218
  ringOpen: "เปิดเพื่อรับสาย",
216
219
  ringDecline: "ไม่รับ",
@@ -306,6 +309,7 @@ const en: Strings = {
306
309
  hours: "{n} hours",
307
310
  ringTitle: "The support team is calling you",
308
311
  ringAbout: "About {key} · {title}",
312
+ ringChat: "From your chat with support",
309
313
  ringHow: "Answer on your request's page — it opens in a new tab, already signed in",
310
314
  ringOpen: "Open to answer",
311
315
  ringDecline: "Decline",