@checkflow/sdk 1.1.2 → 1.1.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.
@@ -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
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Element highlighter for visual bug reporting.
3
+ * Allows users to click on elements to highlight them and annotate.
4
+ */
5
+ interface HighlightAnnotation {
6
+ selector: string;
7
+ tagName: string;
8
+ text?: string;
9
+ rect: {
10
+ x: number;
11
+ y: number;
12
+ width: number;
13
+ height: number;
14
+ };
15
+ note?: string;
16
+ }
17
+
18
+ export type { HighlightAnnotation as H };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Element highlighter for visual bug reporting.
3
+ * Allows users to click on elements to highlight them and annotate.
4
+ */
5
+ interface HighlightAnnotation {
6
+ selector: string;
7
+ tagName: string;
8
+ text?: string;
9
+ rect: {
10
+ x: number;
11
+ y: number;
12
+ width: number;
13
+ height: number;
14
+ };
15
+ note?: string;
16
+ }
17
+
18
+ export type { HighlightAnnotation as H };
@@ -124,8 +124,7 @@ function startHighlighting() {
124
124
  function isHighlighting() {
125
125
  return isActive;
126
126
  }
127
-
128
127
  export {
129
- startHighlighting,
130
- isHighlighting
128
+ isHighlighting,
129
+ startHighlighting
131
130
  };
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, a as FeedbackResponse } from './types-CBCRUGst.mjs';
2
+ export { W as WidgetConfig } from './types-CBCRUGst.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,9 +25,9 @@ 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
- annotations?: HighlightAnnotation[];
30
+ annotations?: any[];
26
31
  }): Promise<FeedbackResponse>;
27
32
 
28
33
  /**
@@ -38,4 +43,4 @@ declare function hideWidget(): void;
38
43
  */
39
44
  declare function destroy(): void;
40
45
 
41
- export { CheckflowConfig, FeedbackPayload, FeedbackResponse, HighlightAnnotation, captureScreenshot, destroy, hideWidget, init, sendFeedback, showWidget };
46
+ export { CheckflowConfig, FeedbackPayload, FeedbackResponse, captureScreenshot, destroy, hideWidget, init, sendFeedback, showWidget };
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, a as FeedbackResponse } from './types-CBCRUGst.js';
2
+ export { W as WidgetConfig } from './types-CBCRUGst.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,9 +25,9 @@ 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
- annotations?: HighlightAnnotation[];
30
+ annotations?: any[];
26
31
  }): Promise<FeedbackResponse>;
27
32
 
28
33
  /**
@@ -38,4 +43,4 @@ declare function hideWidget(): void;
38
43
  */
39
44
  declare function destroy(): void;
40
45
 
41
- export { CheckflowConfig, FeedbackPayload, FeedbackResponse, HighlightAnnotation, captureScreenshot, destroy, hideWidget, init, sendFeedback, showWidget };
46
+ export { CheckflowConfig, FeedbackPayload, FeedbackResponse, captureScreenshot, destroy, hideWidget, init, sendFeedback, showWidget };