@qaiddev/thumbs-embed 1.0.5 → 1.0.7

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/index.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Capture a screenshot of the current page using html2canvas
3
+ * Returns a base64-encoded WebP data URL, or null on failure
4
+ */
5
+ export declare function captureDomScreenshot(options?: DomScreenshotOptions): Promise<string | null>;
6
+
7
+ /**
8
+ * Intercept fetch() and XMLHttpRequest to capture network errors (4xx/5xx)
9
+ */
10
+ export declare function captureNetworkErrors(): NetworkCapture;
11
+
1
12
  /**
2
13
  * Console message captured during the session
3
14
  */
@@ -7,6 +18,24 @@ export declare interface ConsoleError {
7
18
  level: "error" | "warn" | "log";
8
19
  }
9
20
 
21
+ /**
22
+ * Create a video recorder that captures the screen
23
+ */
24
+ export declare function createVideoRecorder(options?: VideoRecorderOptions): VideoRecorder;
25
+
26
+ /**
27
+ * DOM-based screenshot capture using html2canvas
28
+ * No browser permission dialog required - reconstructs the page from the DOM
29
+ */
30
+ export declare interface DomScreenshotOptions {
31
+ /** Quality of WebP compression (0-1). Default: 0.8 */
32
+ quality?: number;
33
+ /** Max width of the screenshot. Default: 1280 */
34
+ maxWidth?: number;
35
+ /** Max height of the screenshot. Default: 800 */
36
+ maxHeight?: number;
37
+ }
38
+
10
39
  /**
11
40
  * Element bounds for server-side screenshot fallback
12
41
  */
@@ -18,7 +47,7 @@ declare interface ElementBounds {
18
47
  }
19
48
 
20
49
  /**
21
- * Configuration options for the FeedbackEmbed
50
+ * Configuration options for the QaidFeedback
22
51
  */
23
52
  export declare interface FeedbackConfig {
24
53
  /** Required: API endpoint URL for submitting feedback */
@@ -29,6 +58,8 @@ export declare interface FeedbackConfig {
29
58
  container?: string;
30
59
  /** Custom CSS class to apply to thumb buttons. When provided, default button styles are not applied */
31
60
  buttonClass?: string;
61
+ /** Button layout direction. Default: 'horizontal' */
62
+ direction?: "horizontal" | "vertical";
32
63
  /** Position of the feedback buttons. Default: 'bottom-right'. Ignored if container is provided */
33
64
  position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
34
65
  /** Offset from edge in pixels. Default: { x: 16, y: 16 } */
@@ -55,10 +86,6 @@ export declare interface FeedbackConfig {
55
86
  text?: {
56
87
  /** Tooltip text for buttons */
57
88
  tooltip?: string;
58
- /** Banner text during targeting */
59
- bannerText?: string;
60
- /** Banner hint text */
61
- bannerHint?: string;
62
89
  /** Modal title */
63
90
  modalTitle?: string;
64
91
  /** Modal subtitle */
@@ -80,12 +107,27 @@ export declare interface FeedbackConfig {
80
107
  fontSize?: number;
81
108
  /** Enable screenshot capture with feedback. Default: false */
82
109
  captureScreenshot?: boolean;
110
+ /** Enable video recording button. Default: false */
111
+ captureVideo?: boolean;
112
+ /** Video recording options */
113
+ videoOptions?: {
114
+ /** Max recording duration in seconds. Default: 15 */
115
+ maxDuration?: number;
116
+ };
117
+ /** Custom SVG string for record button icon */
118
+ recordIcon?: string;
83
119
  /** When true, buttons are hidden until hovered. Default: false */
84
120
  incognito?: boolean;
85
121
  /** Custom SVG string for positive feedback button icon */
86
122
  positiveIcon?: string;
87
123
  /** Custom SVG string for negative feedback button icon */
88
124
  negativeIcon?: string;
125
+ /** When true, hide thumbs up/down buttons (only show video button if enabled). Default: false */
126
+ hideThumbs?: boolean;
127
+ /** Custom CSS to inject into the embed's shadow root for theming */
128
+ css?: string;
129
+ /** Screenshot capture method. "dom" uses html2canvas (no permission), "permission" uses Screen Capture API. Default: "permission" */
130
+ screenshotMethod?: "dom" | "permission";
89
131
  /** Screenshot options */
90
132
  screenshotOptions?: {
91
133
  /** Quality of WebP compression (0-1). Default: 1.0 */
@@ -108,9 +150,84 @@ export declare interface FeedbackData {
108
150
  }
109
151
 
110
152
  /**
111
- * FeedbackEmbed - Standalone feedback collection embed
153
+ * Payload for updating feedback with a message
154
+ */
155
+ export declare interface FeedbackMessagePayload {
156
+ message: string | null;
157
+ }
158
+
159
+ /**
160
+ * Payload sent to the feedback API
161
+ */
162
+ export declare interface FeedbackPayload {
163
+ feedbackType: "up" | "down";
164
+ pageUrl: string;
165
+ /** API key for authenticating with the feedback service */
166
+ apiKey?: string;
167
+ elementSelector: string | null;
168
+ elementText: string | null;
169
+ consoleErrors: ConsoleError[];
170
+ screenWidth: number;
171
+ screenHeight: number;
172
+ clickX: number;
173
+ clickY: number;
174
+ scrollX: number;
175
+ scrollY: number;
176
+ /** Base64-encoded screenshot image (WebP) */
177
+ screenshot: string | null;
178
+ /** Random UUID stored in visitor's localStorage (for anonymous feedback) */
179
+ visitorId: string;
180
+ /** Element bounds for server-side screenshot fallback when client screenshot fails */
181
+ elementBounds?: ElementBounds | null;
182
+ /** User agent string for server-side rendering consistency */
183
+ userAgent?: string;
184
+ }
185
+
186
+ /**
187
+ * Response from the feedback API
188
+ */
189
+ export declare interface FeedbackResponse {
190
+ id: number;
191
+ }
192
+
193
+ /**
194
+ * Detect the best supported MIME type for recording
195
+ */
196
+ export declare function getSupportedMimeType(): string;
197
+
198
+ /**
199
+ * Check if DOM screenshot capture is supported
200
+ * Requires canvas and basic DOM APIs
201
+ */
202
+ export declare function isDomScreenshotSupported(): boolean;
203
+
204
+ /**
205
+ * Check if video recording is supported in this browser
206
+ */
207
+ export declare function isVideoRecordingSupported(): boolean;
208
+
209
+ export declare interface NetworkCapture {
210
+ errors: NetworkError[];
211
+ restore: () => void;
212
+ }
213
+
214
+ /**
215
+ * Network error captured during the session
216
+ */
217
+ export declare interface NetworkError {
218
+ url: string;
219
+ method: string;
220
+ status: number;
221
+ statusText: string;
222
+ requestBody?: string;
223
+ responseBody?: string;
224
+ timestamp: number;
225
+ }
226
+
227
+ /**
228
+ * QaidFeedback - Standalone feedback collection embed
112
229
  */
113
- export declare class FeedbackEmbed {
230
+ export declare class QaidFeedback {
114
231
  private config;
115
232
  private state;
116
233
  private feedbackData;
@@ -121,8 +238,18 @@ export declare class FeedbackEmbed {
121
238
  private isMobile;
122
239
  private visitorId;
123
240
  private consoleCapture;
124
- private allowedFeatures;
125
- private container;
241
+ private videoRecorder;
242
+ private networkCapture;
243
+ private recordedBlob;
244
+ private recordingIndicator;
245
+ private videoPreview;
246
+ private isRecording;
247
+ private isSendingVideo;
248
+ private shadowHost;
249
+ private shadowRoot;
250
+ private overlayShadowHost;
251
+ private overlayShadowRoot;
252
+ private buttonsContainer;
126
253
  private isUserProvidedContainer;
127
254
  private overlayContainer;
128
255
  private captureLayer;
@@ -132,16 +259,24 @@ export declare class FeedbackEmbed {
132
259
  private marker;
133
260
  private modalContainer;
134
261
  private backdrop;
262
+ private cssVars;
135
263
  private boundKeyDown;
136
264
  private boundMouseMove;
137
265
  private boundClick;
138
266
  private boundResize;
139
267
  constructor(config: FeedbackConfig);
268
+ private applyVars;
140
269
  private init;
141
- private fetchAllowedFeatures;
142
270
  private checkMobile;
143
271
  private handleResize;
144
272
  private createEmbed;
273
+ /**
274
+ * Lazily create a separate overlay shadow host on document.body.
275
+ * This host contains all full-page elements (targeting overlay, marker,
276
+ * backdrop, modal, recording indicator, video preview) so they escape
277
+ * clip-path / transform containing blocks in user containers.
278
+ */
279
+ private ensureOverlayHost;
145
280
  private tooltipElement;
146
281
  private showTooltip;
147
282
  private hideTooltip;
@@ -164,53 +299,24 @@ export declare class FeedbackEmbed {
164
299
  private setupModalInteractions;
165
300
  private submitMessage;
166
301
  private closeModal;
302
+ private startRecording;
303
+ private stopRecording;
304
+ private showRecordingIndicator;
305
+ private updateRecordingTimer;
306
+ private formatTime;
307
+ private removeRecordingIndicator;
308
+ private showRecordingPreview;
309
+ private cancelRecordingPreview;
310
+ private removeVideoPreview;
311
+ private submitVideoFeedback;
312
+ private cleanupRecording;
313
+ private setButtonsDisabled;
167
314
  /**
168
315
  * Destroy the embed and clean up all resources
169
316
  */
170
317
  destroy(): void;
171
318
  }
172
319
 
173
- /**
174
- * Payload for updating feedback with a message
175
- */
176
- export declare interface FeedbackMessagePayload {
177
- message: string | null;
178
- }
179
-
180
- /**
181
- * Payload sent to the feedback API
182
- */
183
- export declare interface FeedbackPayload {
184
- feedbackType: "up" | "down";
185
- pageUrl: string;
186
- /** API key for authenticating with the feedback service */
187
- apiKey?: string;
188
- elementSelector: string | null;
189
- elementText: string | null;
190
- consoleErrors: ConsoleError[];
191
- screenWidth: number;
192
- screenHeight: number;
193
- clickX: number;
194
- clickY: number;
195
- scrollX: number;
196
- scrollY: number;
197
- /** Base64-encoded screenshot image (WebP) */
198
- screenshot: string | null;
199
- /** Random UUID stored in visitor's localStorage (for anonymous feedback) */
200
- visitorId: string;
201
- /** Element bounds for server-side screenshot fallback when client screenshot fails */
202
- elementBounds?: ElementBounds | null;
203
- /** User agent string for server-side rendering consistency */
204
- userAgent?: string;
205
- }
206
-
207
- /**
208
- * Response from the feedback API
209
- */
210
- export declare interface FeedbackResponse {
211
- id: number;
212
- }
213
-
214
320
  /**
215
321
  * Fully resolved configuration with all defaults applied
216
322
  * Used internally by the embed after processing user config
@@ -220,6 +326,7 @@ export declare interface ResolvedFeedbackConfig {
220
326
  apiKey: string;
221
327
  container: string;
222
328
  buttonClass: string;
329
+ direction: "horizontal" | "vertical";
223
330
  position: "bottom-right" | "bottom-left" | "top-right" | "top-left";
224
331
  offset: {
225
332
  x: number;
@@ -235,8 +342,6 @@ export declare interface ResolvedFeedbackConfig {
235
342
  buttonSize: "small" | "medium" | "large";
236
343
  text: {
237
344
  tooltip: string;
238
- bannerText: string;
239
- bannerHint: string;
240
345
  modalTitle: string;
241
346
  modalSubtitle: string;
242
347
  placeholder: string;
@@ -248,6 +353,7 @@ export declare interface ResolvedFeedbackConfig {
248
353
  fontFamily: string;
249
354
  fontSize: number;
250
355
  captureScreenshot: boolean;
356
+ screenshotMethod: "dom" | "permission";
251
357
  screenshotOptions: {
252
358
  quality: number;
253
359
  maxWidth: number;
@@ -256,6 +362,13 @@ export declare interface ResolvedFeedbackConfig {
256
362
  incognito: boolean;
257
363
  positiveIcon: string;
258
364
  negativeIcon: string;
365
+ hideThumbs: boolean;
366
+ css: string;
367
+ captureVideo: boolean;
368
+ videoOptions: {
369
+ maxDuration: number;
370
+ };
371
+ recordIcon: string;
259
372
  }
260
373
 
261
374
  /**
@@ -271,4 +384,36 @@ export declare interface SelectedBounds {
271
384
  visible: boolean;
272
385
  }
273
386
 
387
+ export declare interface VideoRecorder {
388
+ /** Start recording. Requests getDisplayMedia if not already started. */
389
+ start(): Promise<void>;
390
+ /** Stop recording and return the video blob. */
391
+ stop(): Promise<Blob>;
392
+ /** Register a callback for each second tick (receives seconds elapsed). */
393
+ onTick(callback: (elapsed: number) => void): void;
394
+ /** Register a callback for when recording stops (e.g., browser stop button, max duration). */
395
+ onStop(callback: (blob: Blob | null) => void): void;
396
+ /** Clean up all resources. */
397
+ destroy(): void;
398
+ }
399
+
400
+ /**
401
+ * Video capture utilities
402
+ * Uses getDisplayMedia + MediaRecorder for screen recording
403
+ */
404
+ export declare interface VideoRecorderOptions {
405
+ /** Max recording duration in seconds. Default: 15 */
406
+ maxDuration?: number;
407
+ /** Video bitrate in bps. Default: 800000 (800kbps) */
408
+ videoBitsPerSecond?: number;
409
+ }
410
+
274
411
  export { }
412
+
413
+
414
+ declare global {
415
+ interface Window {
416
+ html2canvas?: (element: HTMLElement, options?: Record<string, unknown>) => Promise<HTMLCanvasElement>;
417
+ }
418
+ }
419
+