@qaiddev/thumbs-embed 1.7.0 → 1.8.0
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/README.md +32 -21
- package/dist/chunks/{annotate-CMq95aXG.js → annotate-D-o8xCV9.js} +23 -17
- package/dist/chunks/annotate-D-o8xCV9.js.map +1 -0
- package/dist/chunks/dom-DvdtcUS8.js +17 -0
- package/dist/chunks/dom-DvdtcUS8.js.map +1 -0
- package/dist/chunks/{loader-CYM1rxDH.js → loader-DHtXHt1z.js} +172 -156
- package/dist/chunks/loader-DHtXHt1z.js.map +1 -0
- package/dist/chunks/modal-CTbqN-h9.js +213 -0
- package/dist/chunks/modal-CTbqN-h9.js.map +1 -0
- package/dist/chunks/{recording-BVFd_ryf.js → recording-Dx8AX-BC.js} +103 -98
- package/dist/chunks/recording-Dx8AX-BC.js.map +1 -0
- package/dist/chunks/{screenshot-BkOCLuS2.js → screenshot-DYOKg2bS.js} +2 -2
- package/dist/chunks/{screenshot-BkOCLuS2.js.map → screenshot-DYOKg2bS.js.map} +1 -1
- package/dist/chunks/{targeting-1pK6nJI9.js → targeting-Dz6z1BYl.js} +2 -2
- package/dist/chunks/{targeting-1pK6nJI9.js.map → targeting-Dz6z1BYl.js.map} +1 -1
- package/dist/chunks/{video-BOYqf2Im.js → video-Bd_29-rK.js} +76 -71
- package/dist/chunks/video-Bd_29-rK.js.map +1 -0
- package/dist/embed.d.ts +11 -0
- package/dist/icons.d.ts +2 -0
- package/dist/index.js +523 -418
- package/dist/index.js.map +1 -1
- package/dist/loader.js +1 -1
- package/dist/modal.d.ts +14 -4
- package/dist/qaid.umd.cjs +12 -36
- package/dist/qaid.umd.cjs.map +1 -1
- package/dist/recording.d.ts +6 -0
- package/dist/screenshot.d.ts +1 -1
- package/dist/types.d.ts +14 -2
- package/dist/video-capture.d.ts +6 -0
- package/package.json +1 -1
- package/dist/chunks/annotate-CMq95aXG.js.map +0 -1
- package/dist/chunks/loader-CYM1rxDH.js.map +0 -1
- package/dist/chunks/modal-Br5x7m6f.js +0 -150
- package/dist/chunks/modal-Br5x7m6f.js.map +0 -1
- package/dist/chunks/recording-BVFd_ryf.js.map +0 -1
- package/dist/chunks/video-BOYqf2Im.js.map +0 -1
|
@@ -1,78 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (t.class && (e.className = t.class), t.style && (e.style.cssText = t.style), t.html != null && (e.innerHTML = t.html), t.text != null && (e.textContent = t.text), t.attrs)
|
|
7
|
-
for (const i in t.attrs) e.setAttribute(i, t.attrs[i]);
|
|
8
|
-
if (t.on)
|
|
9
|
-
for (const i in t.on) e.addEventListener(i, t.on[i]);
|
|
10
|
-
}
|
|
11
|
-
for (const i of o)
|
|
12
|
-
i != null && i !== !1 && e.append(i);
|
|
13
|
-
return e;
|
|
14
|
-
}
|
|
15
|
-
const R = 20, u = 4096;
|
|
16
|
-
function l(n) {
|
|
17
|
-
const t = typeof n == "string" ? n : JSON.stringify(n);
|
|
1
|
+
import { h as r } from "./dom-DvdtcUS8.js";
|
|
2
|
+
import { b as f } from "./annotate-D-o8xCV9.js";
|
|
3
|
+
const g = 20, u = 4096;
|
|
4
|
+
function l(d) {
|
|
5
|
+
const t = typeof d == "string" ? d : JSON.stringify(d);
|
|
18
6
|
return t.length > u ? t.slice(0, u) + "…[truncated]" : t;
|
|
19
7
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
8
|
+
function p(d, t) {
|
|
9
|
+
d.length >= g && d.shift(), d.push(t);
|
|
22
10
|
}
|
|
23
|
-
async function b(
|
|
11
|
+
async function b(d) {
|
|
24
12
|
try {
|
|
25
|
-
const t = await
|
|
13
|
+
const t = await d.clone().text();
|
|
26
14
|
return l(t);
|
|
27
15
|
} catch {
|
|
28
16
|
return;
|
|
29
17
|
}
|
|
30
18
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
window.fetch = async function(
|
|
34
|
-
const
|
|
35
|
-
let
|
|
36
|
-
s?.body && (
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
url:
|
|
42
|
-
method:
|
|
43
|
-
status:
|
|
44
|
-
statusText:
|
|
45
|
-
requestBody:
|
|
46
|
-
responseBody:
|
|
19
|
+
function R() {
|
|
20
|
+
const d = [], t = window.fetch;
|
|
21
|
+
window.fetch = async function(o, s) {
|
|
22
|
+
const n = typeof o == "string" ? o : o instanceof URL ? o.toString() : o.url, c = s?.method ?? (typeof o == "object" && "method" in o ? o.method : "GET");
|
|
23
|
+
let a;
|
|
24
|
+
s?.body && (a = l(s.body));
|
|
25
|
+
const h = await t.apply(window, [o, s]);
|
|
26
|
+
if (h.status >= 400) {
|
|
27
|
+
const v = await b(h);
|
|
28
|
+
p(d, {
|
|
29
|
+
url: n,
|
|
30
|
+
method: c.toUpperCase(),
|
|
31
|
+
status: h.status,
|
|
32
|
+
statusText: h.statusText,
|
|
33
|
+
requestBody: a,
|
|
34
|
+
responseBody: v,
|
|
47
35
|
timestamp: Date.now()
|
|
48
36
|
});
|
|
49
37
|
}
|
|
50
|
-
return
|
|
38
|
+
return h;
|
|
51
39
|
};
|
|
52
|
-
const
|
|
53
|
-
return XMLHttpRequest.prototype.open = function(
|
|
54
|
-
return this._qaid_method =
|
|
55
|
-
}, XMLHttpRequest.prototype.send = function(
|
|
56
|
-
const s = this,
|
|
40
|
+
const i = XMLHttpRequest.prototype.open, e = XMLHttpRequest.prototype.send;
|
|
41
|
+
return XMLHttpRequest.prototype.open = function(o, s, ...n) {
|
|
42
|
+
return this._qaid_method = o, this._qaid_url = typeof s == "string" ? s : s.toString(), i.apply(this, [o, s, ...n]);
|
|
43
|
+
}, XMLHttpRequest.prototype.send = function(o) {
|
|
44
|
+
const s = this, n = o ? l(o) : void 0;
|
|
57
45
|
return s.addEventListener("load", function() {
|
|
58
|
-
s.status >= 400 &&
|
|
46
|
+
s.status >= 400 && p(d, {
|
|
59
47
|
url: s._qaid_url,
|
|
60
48
|
method: s._qaid_method.toUpperCase(),
|
|
61
49
|
status: s.status,
|
|
62
50
|
statusText: s.statusText,
|
|
63
|
-
requestBody:
|
|
51
|
+
requestBody: n,
|
|
64
52
|
responseBody: l(s.responseText),
|
|
65
53
|
timestamp: Date.now()
|
|
66
54
|
});
|
|
67
|
-
}), e.apply(this, [
|
|
55
|
+
}), e.apply(this, [o]);
|
|
68
56
|
}, {
|
|
69
|
-
errors:
|
|
57
|
+
errors: d,
|
|
70
58
|
restore: () => {
|
|
71
|
-
window.fetch = t, XMLHttpRequest.prototype.open =
|
|
59
|
+
window.fetch = t, XMLHttpRequest.prototype.open = i, XMLHttpRequest.prototype.send = e;
|
|
72
60
|
}
|
|
73
61
|
};
|
|
74
62
|
}
|
|
75
|
-
class
|
|
63
|
+
class m {
|
|
76
64
|
constructor(t) {
|
|
77
65
|
this.host = t;
|
|
78
66
|
}
|
|
@@ -99,9 +87,9 @@ class w {
|
|
|
99
87
|
async startRecording(t = []) {
|
|
100
88
|
if (!(this.isRecording || this.host.state !== "IDLE"))
|
|
101
89
|
try {
|
|
102
|
-
this.networkCapture =
|
|
103
|
-
const { createVideoRecorder:
|
|
104
|
-
this.videoRecorder =
|
|
90
|
+
this.networkCapture = R();
|
|
91
|
+
const { createVideoRecorder: i } = await import("./video-Bd_29-rK.js");
|
|
92
|
+
this.videoRecorder = i({
|
|
105
93
|
maxDuration: this.host.config.videoOptions.maxDuration,
|
|
106
94
|
redactionElements: t
|
|
107
95
|
}), this.videoRecorder.onTick((e) => {
|
|
@@ -109,8 +97,8 @@ class w {
|
|
|
109
97
|
}), this.videoRecorder.onStop((e) => {
|
|
110
98
|
this.isRecording && (this.recordedBlob = e, this.isRecording = !1, this.host.announceMsg("Recording stopped"), this.removeRecordingIndicator(), document.removeEventListener("keydown", this.host.boundKeyDown), this.host.setButtonsDisabled(!1), e && e.size > 0 ? this.showRecordingPreview() : this.cleanupRecording());
|
|
111
99
|
}), await this.videoRecorder.start(), this.isRecording = !0, this.host.announceMsg("Recording started"), this.host.setButtonsDisabled(!0), this.showRecordingIndicator(), document.addEventListener("keydown", this.host.boundKeyDown);
|
|
112
|
-
} catch (
|
|
113
|
-
|
|
100
|
+
} catch (i) {
|
|
101
|
+
i instanceof Error && /current tab|cannot blur/i.test(i.message) && this.host.announceMsg(i.message), this.cleanupRecording();
|
|
114
102
|
}
|
|
115
103
|
}
|
|
116
104
|
async stopRecording() {
|
|
@@ -130,10 +118,10 @@ class w {
|
|
|
130
118
|
startPicking() {
|
|
131
119
|
if (this.isRecording || this.host.state !== "IDLE") return;
|
|
132
120
|
this.host.setState("REDACT_PICKING"), this.redactPicks = [];
|
|
133
|
-
const t = this.host.ensureOverlayHost(),
|
|
121
|
+
const t = this.host.ensureOverlayHost(), i = r("div", { style: "position:absolute;inset:0;" }), e = r(
|
|
134
122
|
"div",
|
|
135
123
|
{ class: "qaid-redact-picker", style: "position:fixed;inset:0;pointer-events:none;" },
|
|
136
|
-
|
|
124
|
+
i,
|
|
137
125
|
// Control bar — the only pointer-interactive part of the overlay.
|
|
138
126
|
r(
|
|
139
127
|
"div",
|
|
@@ -159,27 +147,27 @@ class w {
|
|
|
159
147
|
)
|
|
160
148
|
);
|
|
161
149
|
t.appendChild(e), this.redactPickerRoot = e;
|
|
162
|
-
const
|
|
163
|
-
this.renderRedactPicks(
|
|
150
|
+
const o = () => {
|
|
151
|
+
this.renderRedactPicks(i), this.redactRafId = requestAnimationFrame(o);
|
|
164
152
|
};
|
|
165
|
-
|
|
153
|
+
o(), document.addEventListener("click", this.boundRedactClick, !0), document.addEventListener("keydown", this.host.boundKeyDown), this.host.announceMsg("Click sensitive areas to blur, then start recording");
|
|
166
154
|
}
|
|
167
155
|
handleRedactPickClick(t) {
|
|
168
|
-
const
|
|
169
|
-
if (!
|
|
156
|
+
const i = t.target instanceof Element ? t.target : null;
|
|
157
|
+
if (!i || f(i) || this.redactPickerRoot?.contains(i)) return;
|
|
170
158
|
t.preventDefault(), t.stopPropagation();
|
|
171
|
-
const e = this.redactPicks.indexOf(
|
|
172
|
-
e >= 0 ? this.redactPicks.splice(e, 1) : this.redactPicks.push(
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
159
|
+
const e = this.redactPicks.indexOf(i);
|
|
160
|
+
e >= 0 ? this.redactPicks.splice(e, 1) : this.redactPicks.push(i);
|
|
161
|
+
const o = this.redactPickerRoot?.querySelector("[data-qaid-redact-label]");
|
|
162
|
+
if (o) {
|
|
175
163
|
const s = this.redactPicks.length;
|
|
176
|
-
|
|
164
|
+
o.textContent = s === 0 ? "Click sensitive areas to blur" : `${s} area${s === 1 ? "" : "s"} will be blurred`;
|
|
177
165
|
}
|
|
178
166
|
}
|
|
179
167
|
renderRedactPicks(t) {
|
|
180
168
|
t.textContent = "";
|
|
181
|
-
for (const
|
|
182
|
-
const e =
|
|
169
|
+
for (const i of this.redactPicks) {
|
|
170
|
+
const e = i.getBoundingClientRect();
|
|
183
171
|
e.width <= 0 || e.height <= 0 || t.appendChild(
|
|
184
172
|
r("div", {
|
|
185
173
|
style: `position:fixed;left:${e.left}px;top:${e.top}px;width:${e.width}px;height:${e.height}px;border:2px solid #ff6b6b;border-radius:4px;background:rgba(255,107,107,.18);pointer-events:none;`
|
|
@@ -189,8 +177,8 @@ class w {
|
|
|
189
177
|
}
|
|
190
178
|
finishRedactionPicking(t) {
|
|
191
179
|
this.redactRafId && cancelAnimationFrame(this.redactRafId), this.redactRafId = 0, document.removeEventListener("click", this.boundRedactClick, !0), document.removeEventListener("keydown", this.host.boundKeyDown), this.redactPickerRoot && (this.redactPickerRoot.remove(), this.redactPickerRoot = null);
|
|
192
|
-
const
|
|
193
|
-
this.redactPicks = [], this.host.setState("IDLE"), t && this.startRecording(
|
|
180
|
+
const i = this.redactPicks;
|
|
181
|
+
this.redactPicks = [], this.host.setState("IDLE"), t && this.startRecording(i);
|
|
194
182
|
}
|
|
195
183
|
showRecordingIndicator() {
|
|
196
184
|
const t = this.host.ensureOverlayHost();
|
|
@@ -212,38 +200,38 @@ class w {
|
|
|
212
200
|
}
|
|
213
201
|
updateRecordingTimer(t) {
|
|
214
202
|
if (!this.recordingIndicator) return;
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
203
|
+
const i = this.recordingIndicator.querySelector(".qaid-recording-time");
|
|
204
|
+
if (i) {
|
|
217
205
|
const e = Math.max(0, this.host.config.videoOptions.maxDuration - t);
|
|
218
|
-
|
|
206
|
+
i.textContent = this.formatTime(e), e > 0 && e <= 5 && this.host.announceMsg(`${e} second${e === 1 ? "" : "s"} remaining`);
|
|
219
207
|
}
|
|
220
208
|
}
|
|
221
209
|
formatTime(t) {
|
|
222
|
-
const
|
|
223
|
-
return `${
|
|
210
|
+
const i = Math.floor(t / 60), e = t % 60;
|
|
211
|
+
return `${i}:${e.toString().padStart(2, "0")}`;
|
|
224
212
|
}
|
|
225
213
|
removeRecordingIndicator() {
|
|
226
214
|
this.recordingIndicator && (this.recordingIndicator.remove(), this.recordingIndicator = null);
|
|
227
215
|
}
|
|
228
216
|
showRecordingPreview() {
|
|
229
|
-
const t = this.host.ensureOverlayHost(),
|
|
230
|
-
s.src =
|
|
231
|
-
const
|
|
217
|
+
const t = this.host.ensureOverlayHost(), i = URL.createObjectURL(this.recordedBlob), e = `qaid-video-title-${this.host.uid}`, o = r("h3", { text: "Review your recording", attrs: { id: e } }), s = r("video");
|
|
218
|
+
s.src = i, s.controls = !0, s.autoplay = !0, s.muted = !0;
|
|
219
|
+
const n = r("textarea", {
|
|
232
220
|
attrs: {
|
|
233
221
|
placeholder: "Optional: Describe the issue you recorded...",
|
|
234
222
|
"aria-label": "Describe the issue you recorded"
|
|
235
223
|
}
|
|
236
|
-
}),
|
|
224
|
+
}), c = r("button", {
|
|
237
225
|
class: "qaid-video-btn qaid-video-btn-send",
|
|
238
226
|
text: "Send",
|
|
239
227
|
attrs: { type: "button" },
|
|
240
|
-
on: { click: () => this.submitVideoFeedback(
|
|
241
|
-
}),
|
|
228
|
+
on: { click: () => this.submitVideoFeedback(n.value.trim() || null, c) }
|
|
229
|
+
}), a = r(
|
|
242
230
|
"div",
|
|
243
231
|
{ class: "qaid-video-preview-box" },
|
|
244
|
-
|
|
232
|
+
o,
|
|
245
233
|
s,
|
|
246
|
-
|
|
234
|
+
n,
|
|
247
235
|
r(
|
|
248
236
|
"div",
|
|
249
237
|
{ class: "qaid-video-preview-actions" },
|
|
@@ -263,14 +251,14 @@ class w {
|
|
|
263
251
|
}
|
|
264
252
|
}
|
|
265
253
|
}),
|
|
266
|
-
|
|
254
|
+
c
|
|
267
255
|
)
|
|
268
256
|
);
|
|
269
257
|
this.videoPreview = r(
|
|
270
258
|
"div",
|
|
271
259
|
{ class: "qaid-video-preview", style: `z-index:${this.host.config.zIndex + 100}` },
|
|
272
|
-
|
|
273
|
-
), this.host.applyVars(this.videoPreview), this.host.overlayShadowHost && (this.host.overlayShadowHost.style.pointerEvents = "auto"), t.appendChild(this.videoPreview), this.host.openDialogA11y(
|
|
260
|
+
a
|
|
261
|
+
), this.host.applyVars(this.videoPreview), this.host.overlayShadowHost && (this.host.overlayShadowHost.style.pointerEvents = "auto"), t.appendChild(this.videoPreview), this.host.openDialogA11y(a, { labelledbyId: o.id }), document.addEventListener("keydown", this.host.boundKeyDown);
|
|
274
262
|
}
|
|
275
263
|
cancelRecordingPreview() {
|
|
276
264
|
this.removeVideoPreview(), this.cleanupRecording();
|
|
@@ -282,35 +270,52 @@ class w {
|
|
|
282
270
|
}
|
|
283
271
|
document.removeEventListener("keydown", this.host.boundKeyDown);
|
|
284
272
|
}
|
|
285
|
-
async submitVideoFeedback(t,
|
|
273
|
+
async submitVideoFeedback(t, i) {
|
|
286
274
|
if (!this.recordedBlob || this.isSendingVideo) return;
|
|
287
|
-
this.isSendingVideo = !0,
|
|
275
|
+
this.isSendingVideo = !0, i.disabled = !0, i.textContent = "Sending...";
|
|
288
276
|
const e = new FormData();
|
|
289
277
|
e.append("video", this.recordedBlob, `recording.${this.recordedBlob.type.includes("mp4") ? "mp4" : "webm"}`), e.append("pageUrl", window.location.href), e.append("visitorId", this.host.visitorId), this.host.config.apiKey && e.append("apiKey", this.host.config.apiKey), t && e.append("message", t), this.host.consoleCapture && e.append("consoleErrors", JSON.stringify(this.host.consoleCapture.errors)), this.networkCapture && e.append("networkErrors", JSON.stringify(this.networkCapture.errors));
|
|
290
|
-
let
|
|
278
|
+
let o = null, s = null;
|
|
291
279
|
try {
|
|
292
|
-
const
|
|
280
|
+
const n = await fetch(`${this.host.config.endpoint}/video`, {
|
|
293
281
|
method: "POST",
|
|
294
282
|
body: e
|
|
295
283
|
});
|
|
296
|
-
if (
|
|
284
|
+
if (n.ok) {
|
|
297
285
|
this.host.announceMsg("Recording sent");
|
|
298
286
|
try {
|
|
299
|
-
|
|
287
|
+
o = (await n.json())?.id ?? null;
|
|
300
288
|
} catch {
|
|
301
289
|
}
|
|
302
290
|
} else
|
|
303
|
-
console.error("Failed to submit video feedback:", await
|
|
304
|
-
} catch (
|
|
305
|
-
console.error("Failed to submit video feedback:",
|
|
291
|
+
console.error("Failed to submit video feedback:", await n.text()), s = n.status === 413 ? "This recording is too large to send. Try a shorter one." : "Your recording could not be sent.";
|
|
292
|
+
} catch (n) {
|
|
293
|
+
console.error("Failed to submit video feedback:", n), s = "Your recording could not be sent. Check your connection and try again.";
|
|
294
|
+
}
|
|
295
|
+
if (this.isSendingVideo = !1, s) {
|
|
296
|
+
this.showSendError(s, i);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
this.removeVideoPreview(), this.cleanupRecording(), await this.host.tryLaunchQuest("video", o);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Keep the preview open and say the upload failed. Closing it, as a success
|
|
303
|
+
* does, told the visitor their recording had arrived when it had not. Send
|
|
304
|
+
* is re-enabled for another try; Cancel and Re-record still work.
|
|
305
|
+
*/
|
|
306
|
+
showSendError(t, i) {
|
|
307
|
+
this.host.announceMsg(`Failed to send recording. ${t}`, !0), i.disabled = !1, i.textContent = "Send";
|
|
308
|
+
const e = this.videoPreview?.querySelector(".qaid-video-preview-actions");
|
|
309
|
+
if (e) {
|
|
310
|
+
let o = this.videoPreview.querySelector(".qaid-video-error");
|
|
311
|
+
o || (o = r("p", { class: "qaid-video-error" }), e.before(o)), o.textContent = t;
|
|
306
312
|
}
|
|
307
|
-
this.isSendingVideo = !1, this.removeVideoPreview(), this.cleanupRecording(), await this.host.tryLaunchQuest("video", i);
|
|
308
313
|
}
|
|
309
314
|
cleanupRecording() {
|
|
310
315
|
this.isRecording = !1, this.removeRecordingIndicator(), this.videoRecorder && (this.videoRecorder.destroy(), this.videoRecorder = null), this.networkCapture && (this.networkCapture.restore(), this.networkCapture = null), this.recordedBlob && (this.recordedBlob = null), this.host.setButtonsDisabled(!1), this.host.overlayShadowHost && this.host.state === "IDLE" && (this.host.overlayShadowHost.style.pointerEvents = "none");
|
|
311
316
|
}
|
|
312
317
|
}
|
|
313
318
|
export {
|
|
314
|
-
|
|
319
|
+
m as RecordingController
|
|
315
320
|
};
|
|
316
|
-
//# sourceMappingURL=recording-
|
|
321
|
+
//# sourceMappingURL=recording-Dx8AX-BC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recording-Dx8AX-BC.js","sources":["../../src/network-capture.ts","../../src/recording.ts"],"sourcesContent":["/**\n * Network capture utilities\n * Intercepts fetch() and XMLHttpRequest to capture 4xx/5xx errors\n */\n\nimport type { NetworkError } from \"./types\";\n\nconst MAX_ENTRIES = 20;\nconst MAX_BODY_SIZE = 4096; // 4KB\n\nexport interface NetworkCapture {\n errors: NetworkError[];\n restore: () => void;\n}\n\n/**\n * Truncate a body to max size. Callers must guard against null/undefined.\n */\nexport function truncateBody(body: unknown): string {\n const str = typeof body === \"string\" ? body : JSON.stringify(body);\n if (str.length > MAX_BODY_SIZE) {\n return str.slice(0, MAX_BODY_SIZE) + \"…[truncated]\";\n }\n return str;\n}\n\n/**\n * Add an error to the buffer, evicting oldest if at capacity\n */\nexport function addEntry(errors: NetworkError[], entry: NetworkError): void {\n if (errors.length >= MAX_ENTRIES) {\n errors.shift();\n }\n errors.push(entry);\n}\n\n/**\n * Read response body as text, with size limit\n */\nasync function safeReadBody(response: Response): Promise<string | undefined> {\n try {\n const text = await response.clone().text();\n return truncateBody(text);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Intercept fetch() and XMLHttpRequest to capture network errors (4xx/5xx)\n */\nexport function captureNetworkErrors(): NetworkCapture {\n const errors: NetworkError[] = [];\n const originalFetch = window.fetch;\n\n // Monkey-patch fetch\n window.fetch = async function (input: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n const url = typeof input === \"string\" ? input : input instanceof URL ? input.toString() : input.url;\n const method = init?.method ?? (typeof input === \"object\" && \"method\" in input ? input.method : \"GET\");\n let requestBody: string | undefined;\n if (init?.body) {\n requestBody = truncateBody(init.body);\n }\n\n const response = await originalFetch.apply(window, [input, init]);\n\n if (response.status >= 400) {\n const responseBody = await safeReadBody(response);\n addEntry(errors, {\n url,\n method: method.toUpperCase(),\n status: response.status,\n statusText: response.statusText,\n requestBody,\n responseBody,\n timestamp: Date.now(),\n });\n }\n\n return response;\n };\n\n // Monkey-patch XMLHttpRequest\n const originalXHROpen = XMLHttpRequest.prototype.open;\n const originalXHRSend = XMLHttpRequest.prototype.send;\n\n XMLHttpRequest.prototype.open = function (method: string, url: string | URL, ...rest: unknown[]) {\n (this as XMLHttpRequest & { _qaid_method: string; _qaid_url: string })._qaid_method = method;\n (this as XMLHttpRequest & { _qaid_url: string })._qaid_url = typeof url === \"string\" ? url : url.toString();\n return originalXHROpen.apply(this, [method, url, ...rest] as Parameters<typeof originalXHROpen>);\n };\n\n XMLHttpRequest.prototype.send = function (body?: Document | XMLHttpRequestBodyInit | null) {\n const xhr = this as XMLHttpRequest & { _qaid_method: string; _qaid_url: string };\n const requestBody = body ? truncateBody(body) : undefined;\n\n xhr.addEventListener(\"load\", function () {\n if (xhr.status >= 400) {\n addEntry(errors, {\n url: xhr._qaid_url,\n method: xhr._qaid_method.toUpperCase(),\n status: xhr.status,\n statusText: xhr.statusText,\n requestBody,\n responseBody: truncateBody(xhr.responseText),\n timestamp: Date.now(),\n });\n }\n });\n\n return originalXHRSend.apply(this, [body]);\n };\n\n return {\n errors,\n restore: () => {\n window.fetch = originalFetch;\n XMLHttpRequest.prototype.open = originalXHROpen;\n XMLHttpRequest.prototype.send = originalXHRSend;\n },\n };\n}\n","/**\n * Video-recording subsystem — extracted from embed.ts so it lives in its own\n * lazily-loaded chunk. A thumbs-only visitor never downloads any of this; the\n * embed dynamically imports it the first time the record button is used (and\n * warms it on hover — see embed.ts prewarmVideo).\n *\n * The controller owns all recording state and UI (recorder, redaction picker,\n * indicator, preview, submit). It talks back to the embed through the narrow\n * `RecordingHost` interface, so embed internals stay private and the coupling\n * is explicit.\n */\n\nimport { h } from \"./dom\";\nimport { isEmbedElement } from \"./dom-utils\";\nimport { captureNetworkErrors, type NetworkCapture } from \"./network-capture\";\nimport type { VideoRecorder } from \"./video-capture\";\nimport type { ResolvedFeedbackConfig, EmbedState } from \"./types\";\nimport type { ConsoleCapture } from \"./console-capture\";\n\n/** The slice of the embed the recording subsystem needs. */\nexport interface RecordingHost {\n readonly config: ResolvedFeedbackConfig;\n readonly visitorId: string;\n readonly uid: string;\n readonly overlayShadowHost: HTMLDivElement | null;\n readonly consoleCapture: ConsoleCapture | null;\n readonly boundKeyDown: (e: KeyboardEvent) => void;\n readonly state: EmbedState;\n setState(state: EmbedState): void;\n ensureOverlayHost(): ShadowRoot;\n applyVars(el: HTMLElement): void;\n announceMsg(message: string, assertive?: boolean): void;\n openDialogA11y(\n container: HTMLElement,\n opts: { labelledbyId?: string; describedbyId?: string; label?: string }\n ): void;\n closeDialogA11y(): void;\n setButtonsDisabled(disabled: boolean): void;\n tryLaunchQuest(\n type: \"up\" | \"down\" | \"video\",\n feedbackId: number | string | null\n ): Promise<boolean>;\n}\n\nexport class RecordingController {\n private videoRecorder: VideoRecorder | null = null;\n private networkCapture: NetworkCapture | null = null;\n private recordedBlob: Blob | null = null;\n private recordingIndicator: HTMLDivElement | null = null;\n private videoPreview: HTMLDivElement | null = null;\n private isRecording = false;\n private isSendingVideo = false;\n\n // Pre-recording redaction picking.\n private redactPicks: Element[] = [];\n private redactPickerRoot: HTMLDivElement | null = null;\n private redactRafId = 0;\n private boundRedactClick = (e: MouseEvent): void => this.handleRedactPickClick(e);\n\n constructor(private host: RecordingHost) {}\n\n /** Escape-key handler; returns true when it consumed the key. */\n handleEscape(): boolean {\n if (this.isRecording) {\n void this.stopRecording();\n return true;\n }\n if (this.videoPreview) {\n this.cancelRecordingPreview();\n return true;\n }\n if (this.redactPickerRoot) {\n this.finishRedactionPicking(false);\n return true;\n }\n return false;\n }\n\n destroy(): void {\n if (this.redactRafId) cancelAnimationFrame(this.redactRafId);\n this.redactRafId = 0;\n document.removeEventListener(\"click\", this.boundRedactClick, true);\n if (this.redactPickerRoot) {\n this.redactPickerRoot.remove();\n this.redactPickerRoot = null;\n }\n this.redactPicks = [];\n this.cleanupRecording();\n this.removeVideoPreview();\n }\n\n async startRecording(redactionElements: Element[] = []): Promise<void> {\n // Don't start if already recording or in a targeting/modal flow.\n if (this.isRecording || this.host.state !== \"IDLE\") return;\n\n try {\n this.networkCapture = captureNetworkErrors();\n\n const { createVideoRecorder } = await import(\"./video-capture\");\n this.videoRecorder = createVideoRecorder({\n maxDuration: this.host.config.videoOptions.maxDuration,\n redactionElements,\n });\n\n this.videoRecorder.onTick((elapsed) => {\n this.updateRecordingTimer(elapsed);\n });\n\n // Handle unexpected stops (browser stop button, max duration).\n this.videoRecorder.onStop((blob) => {\n if (this.isRecording) {\n this.recordedBlob = blob;\n this.isRecording = false;\n this.host.announceMsg(\"Recording stopped\");\n this.removeRecordingIndicator();\n document.removeEventListener(\"keydown\", this.host.boundKeyDown);\n this.host.setButtonsDisabled(false);\n\n if (blob && blob.size > 0) {\n this.showRecordingPreview();\n } else {\n this.cleanupRecording();\n }\n }\n });\n\n await this.videoRecorder.start();\n this.isRecording = true;\n this.host.announceMsg(\"Recording started\");\n this.host.setButtonsDisabled(true);\n this.showRecordingIndicator();\n document.addEventListener(\"keydown\", this.host.boundKeyDown);\n } catch (error) {\n // User denied screen share, shared a disallowed surface (window / whole\n // screen), the browser cannot blur the picked areas, or another error\n // occurred. Surface the tab-only and no-blur messages so neither is a\n // silent no-op. (Matched by text: video-capture is a separate lazy\n // chunk, so importing its constant here would merge the two.)\n if (error instanceof Error && /current tab|cannot blur/i.test(error.message)) {\n this.host.announceMsg(error.message);\n }\n this.cleanupRecording();\n }\n }\n\n private async stopRecording(): Promise<void> {\n try {\n this.recordedBlob = await this.videoRecorder!.stop();\n } catch {\n this.recordedBlob = null;\n }\n\n this.isRecording = false;\n this.host.announceMsg(\"Recording stopped\");\n this.removeRecordingIndicator();\n document.removeEventListener(\"keydown\", this.host.boundKeyDown);\n\n if (this.recordedBlob && this.recordedBlob.size > 0) {\n this.showRecordingPreview();\n } else {\n this.cleanupRecording();\n }\n }\n\n /**\n * Pre-recording redaction picker. The user clicks page areas to blur; each\n * gets an outline that tracks its position, then \"Start recording\" hands the\n * picks to the recorder, which blurs their live bounding boxes so the\n * redaction follows the content as the page scrolls. \"Cancel\"/Escape aborts.\n */\n startPicking(): void {\n if (this.isRecording || this.host.state !== \"IDLE\") return;\n this.host.setState(\"REDACT_PICKING\");\n this.redactPicks = [];\n\n const root = this.host.ensureOverlayHost();\n\n // Layer holding the per-pick outlines (repositioned every frame).\n const boxHost = h(\"div\", { style: \"position:absolute;inset:0;\" });\n\n const container = h(\n \"div\",\n { class: \"qaid-redact-picker\", style: \"position:fixed;inset:0;pointer-events:none;\" },\n boxHost,\n // Control bar — the only pointer-interactive part of the overlay.\n h(\n \"div\",\n {\n style:\n \"position:fixed;left:50%;bottom:24px;transform:translateX(-50%);\" +\n \"display:flex;gap:12px;align-items:center;pointer-events:auto;\" +\n \"background:#0b1220;color:#fff;border:1px solid #ff6b6b;border-radius:9999px;\" +\n \"padding:10px 16px;font:600 13px system-ui,sans-serif;box-shadow:0 8px 30px rgba(0,0,0,.5);\",\n },\n h(\"span\", {\n text: \"Click sensitive areas to blur\",\n attrs: { \"data-qaid-redact-label\": \"\" },\n }),\n h(\"button\", {\n text: \"Start recording\",\n attrs: { type: \"button\" },\n style:\n \"cursor:pointer;border:0;border-radius:9999px;padding:8px 14px;background:#ff6b6b;color:#0b1220;font:inherit;\",\n on: { click: () => this.finishRedactionPicking(true) },\n }),\n h(\"button\", {\n text: \"Cancel\",\n attrs: { type: \"button\" },\n style: \"cursor:pointer;border:0;background:transparent;color:#9fb3c8;font:inherit;\",\n on: { click: () => this.finishRedactionPicking(false) },\n }),\n ),\n );\n\n root.appendChild(container);\n this.redactPickerRoot = container;\n\n // Keep the outlines glued to their elements while the user scrolls/picks.\n const tick = (): void => {\n this.renderRedactPicks(boxHost);\n this.redactRafId = requestAnimationFrame(tick);\n };\n tick();\n\n document.addEventListener(\"click\", this.boundRedactClick, true);\n document.addEventListener(\"keydown\", this.host.boundKeyDown);\n this.host.announceMsg(\"Click sensitive areas to blur, then start recording\");\n }\n\n private handleRedactPickClick(e: MouseEvent): void {\n const target = e.target instanceof Element ? e.target : null;\n // Ignore clicks on the embed's own UI. isEmbedElement catches the retargeted\n // shadow host (real browsers compose click events to it); the contains()\n // check catches the picker's own control-bar buttons when the event isn't\n // retargeted, so their handlers still fire instead of being swallowed here.\n if (!target || isEmbedElement(target) || this.redactPickerRoot?.contains(target)) return;\n e.preventDefault();\n e.stopPropagation();\n\n const idx = this.redactPicks.indexOf(target);\n if (idx >= 0) {\n this.redactPicks.splice(idx, 1);\n } else {\n this.redactPicks.push(target);\n }\n\n const label = this.redactPickerRoot?.querySelector(\"[data-qaid-redact-label]\");\n if (label) {\n const n = this.redactPicks.length;\n label.textContent =\n n === 0 ? \"Click sensitive areas to blur\" : `${n} area${n === 1 ? \"\" : \"s\"} will be blurred`;\n }\n }\n\n private renderRedactPicks(layer: HTMLElement): void {\n // Rebuild the outline boxes to match current picks and their live positions.\n layer.textContent = \"\";\n for (const el of this.redactPicks) {\n const r = el.getBoundingClientRect();\n if (r.width <= 0 || r.height <= 0) continue;\n layer.appendChild(\n h(\"div\", {\n style:\n `position:fixed;left:${r.left}px;top:${r.top}px;width:${r.width}px;height:${r.height}px;` +\n \"border:2px solid #ff6b6b;border-radius:4px;background:rgba(255,107,107,.18);pointer-events:none;\",\n }),\n );\n }\n }\n\n private finishRedactionPicking(record: boolean): void {\n if (this.redactRafId) cancelAnimationFrame(this.redactRafId);\n this.redactRafId = 0;\n document.removeEventListener(\"click\", this.boundRedactClick, true);\n document.removeEventListener(\"keydown\", this.host.boundKeyDown);\n if (this.redactPickerRoot) {\n this.redactPickerRoot.remove();\n this.redactPickerRoot = null;\n }\n const picks = this.redactPicks;\n this.redactPicks = [];\n this.host.setState(\"IDLE\");\n if (record) {\n void this.startRecording(picks);\n }\n }\n\n private showRecordingIndicator(): void {\n const root = this.host.ensureOverlayHost();\n\n this.recordingIndicator = h(\n \"div\",\n { class: \"qaid-recording-indicator\", style: `z-index:${this.host.config.zIndex + 100}` },\n h(\"div\", { class: \"qaid-recording-dot\" }),\n h(\"span\", {\n class: \"qaid-recording-time\",\n text: this.formatTime(this.host.config.videoOptions.maxDuration),\n }),\n h(\"button\", {\n class: \"qaid-recording-stop\",\n text: \"Stop\",\n attrs: { type: \"button\" },\n on: { click: () => this.stopRecording() },\n }),\n );\n\n this.host.applyVars(this.recordingIndicator);\n\n // Enable pointer events on the overlay host for the recording indicator.\n if (this.host.overlayShadowHost) {\n this.host.overlayShadowHost.style.pointerEvents = \"auto\";\n }\n\n root.appendChild(this.recordingIndicator);\n }\n\n private updateRecordingTimer(elapsed: number): void {\n if (!this.recordingIndicator) return;\n const timer = this.recordingIndicator.querySelector<HTMLSpanElement>(\".qaid-recording-time\");\n if (timer) {\n const remaining = Math.max(0, this.host.config.videoOptions.maxDuration - elapsed);\n timer.textContent = this.formatTime(remaining);\n // Announce the final countdown so it is perceivable non-visually.\n if (remaining > 0 && remaining <= 5) {\n this.host.announceMsg(`${remaining} second${remaining === 1 ? \"\" : \"s\"} remaining`);\n }\n }\n }\n\n private formatTime(seconds: number): string {\n const m = Math.floor(seconds / 60);\n const s = seconds % 60;\n return `${m}:${s.toString().padStart(2, \"0\")}`;\n }\n\n private removeRecordingIndicator(): void {\n if (this.recordingIndicator) {\n this.recordingIndicator.remove();\n this.recordingIndicator = null;\n }\n }\n\n private showRecordingPreview(): void {\n const root = this.host.ensureOverlayHost();\n\n const videoUrl = URL.createObjectURL(this.recordedBlob!);\n const titleId = `qaid-video-title-${this.host.uid}`;\n\n const title = h(\"h3\", { text: \"Review your recording\", attrs: { id: titleId } });\n\n // Boolean media props must be set as properties (the `muted` attribute is\n // unreliable for autoplay), so build the element then assign them.\n const videoEl = h(\"video\");\n videoEl.src = videoUrl;\n videoEl.controls = true;\n videoEl.autoplay = true;\n videoEl.muted = true;\n\n const textarea = h(\"textarea\", {\n attrs: {\n placeholder: \"Optional: Describe the issue you recorded...\",\n \"aria-label\": \"Describe the issue you recorded\",\n },\n });\n\n const sendBtn = h(\"button\", {\n class: \"qaid-video-btn qaid-video-btn-send\",\n text: \"Send\",\n attrs: { type: \"button\" },\n on: { click: () => this.submitVideoFeedback(textarea.value.trim() || null, sendBtn) },\n });\n\n const box = h(\n \"div\",\n { class: \"qaid-video-preview-box\" },\n title,\n videoEl,\n textarea,\n h(\n \"div\",\n { class: \"qaid-video-preview-actions\" },\n h(\"button\", {\n class: \"qaid-video-btn qaid-video-btn-cancel\",\n text: \"Cancel\",\n attrs: { type: \"button\" },\n on: { click: () => this.cancelRecordingPreview() },\n }),\n h(\"button\", {\n class: \"qaid-video-btn qaid-video-btn-rerecord\",\n text: \"Re-record\",\n attrs: { type: \"button\" },\n on: {\n click: () => {\n this.cancelRecordingPreview();\n this.startRecording();\n },\n },\n }),\n sendBtn,\n ),\n );\n\n this.videoPreview = h(\n \"div\",\n { class: \"qaid-video-preview\", style: `z-index:${this.host.config.zIndex + 100}` },\n box,\n );\n\n this.host.applyVars(this.videoPreview);\n\n // Enable pointer events on the overlay host for the video preview.\n if (this.host.overlayShadowHost) {\n this.host.overlayShadowHost.style.pointerEvents = \"auto\";\n }\n\n root.appendChild(this.videoPreview);\n\n // Dialog semantics + focus trap + background inert.\n this.host.openDialogA11y(box, { labelledbyId: title.id });\n\n // Listen for the escape key.\n document.addEventListener(\"keydown\", this.host.boundKeyDown);\n }\n\n private cancelRecordingPreview(): void {\n this.removeVideoPreview();\n this.cleanupRecording();\n }\n\n private removeVideoPreview(): void {\n // Release focus trap / inert and restore focus before removing the DOM.\n this.host.closeDialogA11y();\n if (this.videoPreview) {\n const videoEl = this.videoPreview.querySelector<HTMLVideoElement>(\"video\");\n if (videoEl?.src) {\n URL.revokeObjectURL(videoEl.src);\n }\n this.videoPreview.remove();\n this.videoPreview = null;\n }\n document.removeEventListener(\"keydown\", this.host.boundKeyDown);\n }\n\n private async submitVideoFeedback(message: string | null, sendBtn: HTMLButtonElement): Promise<void> {\n if (!this.recordedBlob || this.isSendingVideo) return;\n\n this.isSendingVideo = true;\n sendBtn.disabled = true;\n sendBtn.textContent = \"Sending...\";\n\n const formData = new FormData();\n formData.append(\"video\", this.recordedBlob, `recording.${this.recordedBlob.type.includes(\"mp4\") ? \"mp4\" : \"webm\"}`);\n formData.append(\"pageUrl\", window.location.href);\n formData.append(\"visitorId\", this.host.visitorId);\n\n if (this.host.config.apiKey) {\n formData.append(\"apiKey\", this.host.config.apiKey);\n }\n if (message) {\n formData.append(\"message\", message);\n }\n if (this.host.consoleCapture) {\n formData.append(\"consoleErrors\", JSON.stringify(this.host.consoleCapture.errors));\n }\n if (this.networkCapture) {\n formData.append(\"networkErrors\", JSON.stringify(this.networkCapture.errors));\n }\n\n let videoFeedbackId: string | number | null = null;\n // Set when the upload failed: the reason shown to the visitor.\n let failure: string | null = null;\n try {\n const response = await fetch(`${this.host.config.endpoint}/video`, {\n method: \"POST\",\n body: formData,\n });\n\n if (response.ok) {\n this.host.announceMsg(\"Recording sent\");\n try {\n const data = (await response.json()) as { id?: string | number };\n videoFeedbackId = data?.id ?? null;\n } catch {\n // Non-JSON / no id — the quest can still launch, just unlinked.\n }\n } else {\n // A refusal (403 on a plan without video, 400, 413 too large, 429…)\n // used to close the preview exactly like a success.\n console.error(\"Failed to submit video feedback:\", await response.text());\n failure =\n response.status === 413\n ? \"This recording is too large to send. Try a shorter one.\"\n : \"Your recording could not be sent.\";\n }\n } catch (error) {\n console.error(\"Failed to submit video feedback:\", error);\n failure = \"Your recording could not be sent. Check your connection and try again.\";\n }\n\n this.isSendingVideo = false;\n\n if (failure) {\n this.showSendError(failure, sendBtn);\n return;\n }\n\n this.removeVideoPreview();\n this.cleanupRecording();\n\n // Once the recording is safely sent, launch the linked quest (if any),\n // passing the new feedback record id so its response is joinable.\n await this.host.tryLaunchQuest(\"video\", videoFeedbackId);\n }\n\n /**\n * Keep the preview open and say the upload failed. Closing it, as a success\n * does, told the visitor their recording had arrived when it had not. Send\n * is re-enabled for another try; Cancel and Re-record still work.\n */\n private showSendError(message: string, sendBtn: HTMLButtonElement): void {\n this.host.announceMsg(`Failed to send recording. ${message}`, true);\n sendBtn.disabled = false;\n sendBtn.textContent = \"Send\";\n\n const actions = this.videoPreview?.querySelector(\".qaid-video-preview-actions\");\n if (actions) {\n let note = this.videoPreview!.querySelector<HTMLElement>(\".qaid-video-error\");\n if (!note) {\n note = h(\"p\", { class: \"qaid-video-error\" });\n actions.before(note);\n }\n note.textContent = message;\n }\n }\n\n private cleanupRecording(): void {\n this.isRecording = false;\n this.removeRecordingIndicator();\n\n if (this.videoRecorder) {\n this.videoRecorder.destroy();\n this.videoRecorder = null;\n }\n if (this.networkCapture) {\n this.networkCapture.restore();\n this.networkCapture = null;\n }\n if (this.recordedBlob) {\n this.recordedBlob = null;\n }\n\n this.host.setButtonsDisabled(false);\n\n // Reset overlay host pointer events if nothing else needs them.\n if (this.host.overlayShadowHost && this.host.state === \"IDLE\") {\n this.host.overlayShadowHost.style.pointerEvents = \"none\";\n }\n }\n}\n"],"names":["MAX_ENTRIES","MAX_BODY_SIZE","truncateBody","body","str","addEntry","errors","entry","safeReadBody","response","text","captureNetworkErrors","originalFetch","input","init","url","method","requestBody","responseBody","originalXHROpen","originalXHRSend","rest","xhr","RecordingController","host","e","redactionElements","createVideoRecorder","elapsed","blob","error","root","boxHost","h","container","tick","target","isEmbedElement","idx","label","n","layer","el","r","record","picks","timer","remaining","seconds","m","s","videoUrl","titleId","title","videoEl","textarea","sendBtn","box","message","formData","videoFeedbackId","failure","actions","note"],"mappings":";;AAOA,MAAMA,IAAc,IACdC,IAAgB;AAUf,SAASC,EAAaC,GAAuB;AAClD,QAAMC,IAAM,OAAOD,KAAS,WAAWA,IAAO,KAAK,UAAUA,CAAI;AACjE,SAAIC,EAAI,SAASH,IACRG,EAAI,MAAM,GAAGH,CAAa,IAAI,iBAEhCG;AACT;AAKO,SAASC,EAASC,GAAwBC,GAA2B;AAC1E,EAAID,EAAO,UAAUN,KACnBM,EAAO,MAAA,GAETA,EAAO,KAAKC,CAAK;AACnB;AAKA,eAAeC,EAAaC,GAAiD;AAC3E,MAAI;AACF,UAAMC,IAAO,MAAMD,EAAS,MAAA,EAAQ,KAAA;AACpC,WAAOP,EAAaQ,CAAI;AAAA,EAC1B,QAAQ;AACN;AAAA,EACF;AACF;AAKO,SAASC,IAAuC;AACrD,QAAML,IAAyB,CAAA,GACzBM,IAAgB,OAAO;AAG7B,SAAO,QAAQ,eAAgBC,GAA0BC,GAAuC;AAC9F,UAAMC,IAAM,OAAOF,KAAU,WAAWA,IAAQA,aAAiB,MAAMA,EAAM,SAAA,IAAaA,EAAM,KAC1FG,IAASF,GAAM,WAAW,OAAOD,KAAU,YAAY,YAAYA,IAAQA,EAAM,SAAS;AAChG,QAAII;AACJ,IAAIH,GAAM,SACRG,IAAcf,EAAaY,EAAK,IAAI;AAGtC,UAAML,I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KAAK,iBACP,KAAK,eAAe,OAGtB,KAAK,KAAK,mBAAmB,EAAK,GAG9B,KAAK,KAAK,qBAAqB,KAAK,KAAK,UAAU,WACrD,KAAK,KAAK,kBAAkB,MAAM,gBAAgB;AAAA,EAEtD;AACF;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
async function v(m = {}) {
|
|
2
|
-
const { quality: g =
|
|
2
|
+
const { quality: g = 0.8, maxWidth: w = 1280, maxHeight: p = 800 } = m;
|
|
3
3
|
try {
|
|
4
4
|
if (!navigator.mediaDevices?.getDisplayMedia)
|
|
5
5
|
return console.warn("Screen Capture API not available"), null;
|
|
@@ -30,4 +30,4 @@ async function v(m = {}) {
|
|
|
30
30
|
export {
|
|
31
31
|
v as captureScreenshot
|
|
32
32
|
};
|
|
33
|
-
//# sourceMappingURL=screenshot-
|
|
33
|
+
//# sourceMappingURL=screenshot-DYOKg2bS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot-
|
|
1
|
+
{"version":3,"file":"screenshot-DYOKg2bS.js","sources":["../../src/screenshot.ts"],"sourcesContent":["/**\n * Screenshot capture utility using native Screen Capture API\n */\n\nexport interface ScreenshotOptions {\n /** Quality of WebP compression (0-1). Default: 0.8 */\n quality?: number;\n /** Max width of the screenshot. Default: 1280 */\n maxWidth?: number;\n /** Max height of the screenshot. Default: 800 */\n maxHeight?: number;\n}\n\n/**\n * Captures a screenshot using the native Screen Capture API\n * Requires user permission but produces accurate results\n * Returns a base64-encoded WebP data URL\n */\nexport async function captureScreenshot(\n options: ScreenshotOptions = {}\n): Promise<string | null> {\n const { quality = 0.8, maxWidth = 1280, maxHeight = 800 } = options;\n\n try {\n // Check if API is available\n if (!navigator.mediaDevices?.getDisplayMedia) {\n console.warn('Screen Capture API not available');\n return null;\n }\n\n // Request screen capture - preferCurrentTab auto-selects current tab in supported browsers\n const stream = await navigator.mediaDevices.getDisplayMedia({\n preferCurrentTab: true,\n video: {\n displaySurface: 'browser',\n },\n } as DisplayMediaStreamOptions);\n\n // Get video track\n const track = stream.getVideoTracks()[0];\n const settings = track.getSettings();\n\n // Create video element\n const video = document.createElement('video');\n video.srcObject = stream;\n video.muted = true;\n\n await new Promise<void>((resolve) => {\n video.onloadedmetadata = () => {\n video.play();\n resolve();\n };\n });\n\n // Wait for video to have actual frame data\n await new Promise<void>((resolve) => {\n const checkFrame = () => {\n if (video.readyState >= 2) {\n resolve();\n } else {\n requestAnimationFrame(checkFrame);\n }\n };\n checkFrame();\n });\n\n // Extra delay to ensure frame is rendered\n await new Promise((resolve) => setTimeout(resolve, 100));\n\n // Calculate dimensions\n const srcWidth = settings.width || video.videoWidth;\n const srcHeight = settings.height || video.videoHeight;\n const scale = Math.min(maxWidth / srcWidth, maxHeight / srcHeight, 1);\n const width = Math.round(srcWidth * scale);\n const height = Math.round(srcHeight * scale);\n\n // Draw to canvas\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n track.stop();\n return null;\n }\n\n ctx.drawImage(video, 0, 0, width, height);\n\n // Stop the stream\n track.stop();\n\n return canvas.toDataURL('image/webp', quality);\n } catch (error) {\n console.warn('Screenshot capture failed:', error);\n return null;\n }\n}\n"],"names":["captureScreenshot","options","quality","maxWidth","maxHeight","stream","track","settings","video","resolve","checkFrame","srcWidth","srcHeight","scale","width","height","canvas","ctx","error"],"mappings":"AAkBA,eAAsBA,EACpBC,IAA6B,IACL;AACxB,QAAM,EAAE,SAAAC,IAAU,KAAK,UAAAC,IAAW,MAAM,WAAAC,IAAY,QAAQH;AAE5D,MAAI;AAEF,QAAI,CAAC,UAAU,cAAc;AAC3B,qBAAQ,KAAK,kCAAkC,GACxC;AAIT,UAAMI,IAAS,MAAM,UAAU,aAAa,gBAAgB;AAAA,MAC1D,kBAAkB;AAAA,MAClB,OAAO;AAAA,QACL,gBAAgB;AAAA,MAAA;AAAA,IAClB,CAC4B,GAGxBC,IAAQD,EAAO,eAAA,EAAiB,CAAC,GACjCE,IAAWD,EAAM,YAAA,GAGjBE,IAAQ,SAAS,cAAc,OAAO;AAC5C,IAAAA,EAAM,YAAYH,GAClBG,EAAM,QAAQ,IAEd,MAAM,IAAI,QAAc,CAACC,MAAY;AACnC,MAAAD,EAAM,mBAAmB,MAAM;AAC7B,QAAAA,EAAM,KAAA,GACNC,EAAA;AAAA,MACF;AAAA,IACF,CAAC,GAGD,MAAM,IAAI,QAAc,CAACA,MAAY;AACnC,YAAMC,IAAa,MAAM;AACvB,QAAIF,EAAM,cAAc,IACtBC,EAAA,IAEA,sBAAsBC,CAAU;AAAA,MAEpC;AACA,MAAAA,EAAA;AAAA,IACF,CAAC,GAGD,MAAM,IAAI,QAAQ,CAACD,MAAY,WAAWA,GAAS,GAAG,CAAC;AAGvD,UAAME,IAAWJ,EAAS,SAASC,EAAM,YACnCI,IAAYL,EAAS,UAAUC,EAAM,aACrCK,IAAQ,KAAK,IAAIV,IAAWQ,GAAUP,IAAYQ,GAAW,CAAC,GAC9DE,IAAQ,KAAK,MAAMH,IAAWE,CAAK,GACnCE,IAAS,KAAK,MAAMH,IAAYC,CAAK,GAGrCG,IAAS,SAAS,cAAc,QAAQ;AAC9C,IAAAA,EAAO,QAAQF,GACfE,EAAO,SAASD;AAEhB,UAAME,IAAMD,EAAO,WAAW,IAAI;AAClC,WAAKC,KAKLA,EAAI,UAAUT,GAAO,GAAG,GAAGM,GAAOC,CAAM,GAGxCT,EAAM,KAAA,GAECU,EAAO,UAAU,cAAcd,CAAO,MAT3CI,EAAM,KAAA,GACC;AAAA,EASX,SAASY,GAAO;AACd,mBAAQ,KAAK,8BAA8BA,CAAK,GACzC;AAAA,EACT;AACF;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as k, c as T, b as m } from "./annotate-
|
|
1
|
+
import { g as k, c as T, b as m } from "./annotate-D-o8xCV9.js";
|
|
2
2
|
const E = ["data-comp", "data-qa", "data-testid", "data-id"];
|
|
3
3
|
function C(s, t = document.body) {
|
|
4
4
|
let e = s;
|
|
@@ -293,4 +293,4 @@ class O {
|
|
|
293
293
|
export {
|
|
294
294
|
O as TargetingController
|
|
295
295
|
};
|
|
296
|
-
//# sourceMappingURL=targeting-
|
|
296
|
+
//# sourceMappingURL=targeting-Dz6z1BYl.js.map
|