@uxbertlabs/reportly 1.0.6 → 1.0.8

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.
@@ -1,7 +1,7 @@
1
1
  declare class Screenshot {
2
2
  private currentScreenshot;
3
3
  constructor();
4
- capture(mode?: 'viewport' | 'fullpage'): Promise<string>;
4
+ capture(mode?: "viewport" | "fullpage"): Promise<string>;
5
5
  private hideUXbertElements;
6
6
  private showUXbertElements;
7
7
  getScreenshot(): string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/features/screenshot.ts"],"names":[],"mappings":"AAGA,cAAM,UAAU;IACd,OAAO,CAAC,iBAAiB,CAAgB;;IAMnC,OAAO,CAAC,IAAI,GAAE,UAAU,GAAG,UAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;IAoE1E,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,kBAAkB;IAY1B,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,KAAK,IAAI,IAAI;CAGd;AAED,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/features/screenshot.ts"],"names":[],"mappings":"AAGA,cAAM,UAAU;IACd,OAAO,CAAC,iBAAiB,CAAgB;;IAMnC,OAAO,CAAC,IAAI,GAAE,UAAU,GAAG,UAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiH1E,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,kBAAkB;IAY1B,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,KAAK,IAAI,IAAI;CAGd;AAED,eAAe,UAAU,CAAC"}
@@ -9449,24 +9449,48 @@ class Screenshot {
9449
9449
  constructor() {
9450
9450
  this.currentScreenshot = null;
9451
9451
  }
9452
- async capture(mode = 'fullpage') {
9452
+ async capture(mode = "fullpage") {
9453
9453
  try {
9454
9454
  // Hide UXbert UI elements before capturing
9455
9455
  this.hideUXbertElements();
9456
9456
  const originalScrollY = window.scrollY;
9457
9457
  let canvas;
9458
- if (mode === 'viewport') {
9458
+ if (mode === "viewport") {
9459
9459
  // Capture only the current viewport
9460
9460
  canvas = await html2canvas(document.body, {
9461
- allowTaint: true,
9461
+ // foreignObjectRendering: true,
9462
+ imageTimeout: 40000,
9462
9463
  useCORS: true,
9463
- logging: false,
9464
+ allowTaint: false,
9465
+ logging: true,
9464
9466
  width: window.innerWidth,
9465
9467
  height: window.innerHeight,
9466
9468
  windowWidth: window.innerWidth,
9467
9469
  windowHeight: window.innerHeight,
9468
9470
  x: window.scrollX,
9469
9471
  y: window.scrollY,
9472
+ ignoreElements: (element) => {
9473
+ // Skip cross-origin images that might cause issues
9474
+ if (element.tagName === "IMG") {
9475
+ const img = element;
9476
+ try {
9477
+ // Test if image is accessible
9478
+ const canvas = document.createElement("canvas");
9479
+ const ctx = canvas.getContext("2d");
9480
+ canvas.width = 1;
9481
+ canvas.height = 1;
9482
+ ctx?.drawImage(img, 0, 0, 1, 1);
9483
+ canvas.toDataURL(); // This will throw if tainted
9484
+ return false; // Include the image
9485
+ }
9486
+ catch (e) {
9487
+ // Image is tainted, skip it
9488
+ console.warn("Skipping cross-origin image:", img.src);
9489
+ return true;
9490
+ }
9491
+ }
9492
+ return false;
9493
+ },
9470
9494
  });
9471
9495
  }
9472
9496
  else {
@@ -9477,11 +9501,33 @@ class Screenshot {
9477
9501
  const fullPageWidth = Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);
9478
9502
  // Capture the full page
9479
9503
  canvas = await html2canvas(document.body, {
9480
- allowTaint: true,
9481
9504
  useCORS: true,
9505
+ allowTaint: false,
9482
9506
  logging: false,
9483
9507
  width: fullPageWidth,
9484
9508
  height: fullPageHeight,
9509
+ ignoreElements: (element) => {
9510
+ // Skip cross-origin images that might cause issues
9511
+ if (element.tagName === "IMG") {
9512
+ const img = element;
9513
+ try {
9514
+ // Test if image is accessible
9515
+ const canvas = document.createElement("canvas");
9516
+ const ctx = canvas.getContext("2d");
9517
+ canvas.width = 1;
9518
+ canvas.height = 1;
9519
+ ctx?.drawImage(img, 0, 0, 1, 1);
9520
+ canvas.toDataURL(); // This will throw if tainted
9521
+ return false; // Include the image
9522
+ }
9523
+ catch (e) {
9524
+ // Image is tainted, skip it
9525
+ console.warn("Skipping cross-origin image:", img.src);
9526
+ return true;
9527
+ }
9528
+ }
9529
+ return false;
9530
+ },
9485
9531
  });
9486
9532
  // Restore scroll position
9487
9533
  window.scrollTo(0, originalScrollY);