@checkflow/sdk 1.1.2 → 1.1.3

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
+ // src/screenshot.ts
2
+ var screenshotData = null;
3
+ async function captureScreenshot() {
4
+ try {
5
+ const stream = await navigator.mediaDevices.getDisplayMedia({
6
+ video: { displaySurface: "browser" },
7
+ preferCurrentTab: true
8
+ });
9
+ const track = stream.getVideoTracks()[0];
10
+ const imageCapture = new window.ImageCapture(track);
11
+ await new Promise((r) => setTimeout(r, 300));
12
+ let bitmap;
13
+ try {
14
+ bitmap = await imageCapture.grabFrame();
15
+ } catch {
16
+ const video = document.createElement("video");
17
+ video.srcObject = stream;
18
+ video.autoplay = true;
19
+ await new Promise((resolve) => {
20
+ video.onloadedmetadata = () => {
21
+ video.play();
22
+ resolve();
23
+ };
24
+ });
25
+ await new Promise((r) => setTimeout(r, 200));
26
+ const canvas2 = document.createElement("canvas");
27
+ canvas2.width = video.videoWidth;
28
+ canvas2.height = video.videoHeight;
29
+ const ctx2 = canvas2.getContext("2d");
30
+ ctx2.drawImage(video, 0, 0);
31
+ track.stop();
32
+ screenshotData = canvas2.toDataURL("image/png", 0.92);
33
+ return screenshotData;
34
+ }
35
+ const canvas = document.createElement("canvas");
36
+ canvas.width = bitmap.width;
37
+ canvas.height = bitmap.height;
38
+ const ctx = canvas.getContext("2d");
39
+ ctx.drawImage(bitmap, 0, 0);
40
+ bitmap.close();
41
+ track.stop();
42
+ screenshotData = canvas.toDataURL("image/png", 0.92);
43
+ return screenshotData;
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+ function getLastScreenshot() {
49
+ return screenshotData;
50
+ }
51
+ function clearScreenshot() {
52
+ screenshotData = null;
53
+ }
54
+
55
+ export {
56
+ captureScreenshot,
57
+ getLastScreenshot,
58
+ clearScreenshot
59
+ };
@@ -37,6 +37,8 @@ interface FeedbackPayload {
37
37
  javascript_errors?: any[];
38
38
  screenshot_url?: string;
39
39
  sdk_version?: string;
40
+ reporter_name?: string;
41
+ reporter_email?: string;
40
42
  }
41
43
  interface FeedbackResponse {
42
44
  success: boolean;
@@ -37,6 +37,8 @@ interface FeedbackPayload {
37
37
  javascript_errors?: any[];
38
38
  screenshot_url?: string;
39
39
  sdk_version?: string;
40
+ reporter_name?: string;
41
+ reporter_email?: string;
40
42
  }
41
43
  interface FeedbackResponse {
42
44
  success: boolean;
package/dist/index.d.mts CHANGED
@@ -1,9 +1,14 @@
1
- import { C as CheckflowConfig, F as FeedbackPayload, H as HighlightAnnotation, a as FeedbackResponse } from './highlighter-D_wZWHlS.mjs';
2
- export { W as WidgetConfig, s as startHighlighting } from './highlighter-D_wZWHlS.mjs';
1
+ import { C as CheckflowConfig, F as FeedbackPayload, H as HighlightAnnotation, a as FeedbackResponse } from './highlighter-Dx2zURb6.mjs';
2
+ export { W as WidgetConfig, s as startHighlighting } from './highlighter-Dx2zURb6.mjs';
3
3
 
4
4
  /**
5
- * Screenshot capture using html2canvas-like approach.
6
- * Falls back to a simple canvas capture if html2canvas is not available.
5
+ * Screenshot capture using the browser's native getDisplayMedia API.
6
+ * This prompts the user for permission to capture their tab/screen,
7
+ * producing a real screenshot of the visible page.
8
+ */
9
+ /**
10
+ * Capture a screenshot using getDisplayMedia (browser permission dialog).
11
+ * Returns a base64 data URL of the captured image, or null on failure/cancel.
7
12
  */
8
13
  declare function captureScreenshot(): Promise<string | null>;
9
14
 
@@ -20,7 +25,7 @@ declare function init(cfg: CheckflowConfig): void;
20
25
  /**
21
26
  * Send feedback programmatically.
22
27
  */
23
- declare function sendFeedback(data: Pick<FeedbackPayload, 'title' | 'description' | 'type' | 'priority' | 'screenshot_url'> & {
28
+ declare function sendFeedback(data: Pick<FeedbackPayload, 'title' | 'description' | 'type' | 'priority' | 'screenshot_url' | 'reporter_name' | 'reporter_email'> & {
24
29
  screenshot_data?: string;
25
30
  annotations?: HighlightAnnotation[];
26
31
  }): Promise<FeedbackResponse>;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,14 @@
1
- import { C as CheckflowConfig, F as FeedbackPayload, H as HighlightAnnotation, a as FeedbackResponse } from './highlighter-D_wZWHlS.js';
2
- export { W as WidgetConfig, s as startHighlighting } from './highlighter-D_wZWHlS.js';
1
+ import { C as CheckflowConfig, F as FeedbackPayload, H as HighlightAnnotation, a as FeedbackResponse } from './highlighter-Dx2zURb6.js';
2
+ export { W as WidgetConfig, s as startHighlighting } from './highlighter-Dx2zURb6.js';
3
3
 
4
4
  /**
5
- * Screenshot capture using html2canvas-like approach.
6
- * Falls back to a simple canvas capture if html2canvas is not available.
5
+ * Screenshot capture using the browser's native getDisplayMedia API.
6
+ * This prompts the user for permission to capture their tab/screen,
7
+ * producing a real screenshot of the visible page.
8
+ */
9
+ /**
10
+ * Capture a screenshot using getDisplayMedia (browser permission dialog).
11
+ * Returns a base64 data URL of the captured image, or null on failure/cancel.
7
12
  */
8
13
  declare function captureScreenshot(): Promise<string | null>;
9
14
 
@@ -20,7 +25,7 @@ declare function init(cfg: CheckflowConfig): void;
20
25
  /**
21
26
  * Send feedback programmatically.
22
27
  */
23
- declare function sendFeedback(data: Pick<FeedbackPayload, 'title' | 'description' | 'type' | 'priority' | 'screenshot_url'> & {
28
+ declare function sendFeedback(data: Pick<FeedbackPayload, 'title' | 'description' | 'type' | 'priority' | 'screenshot_url' | 'reporter_name' | 'reporter_email'> & {
24
29
  screenshot_data?: string;
25
30
  annotations?: HighlightAnnotation[];
26
31
  }): Promise<FeedbackResponse>;