@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.
- package/dist/features/screenshot.d.ts +1 -1
- package/dist/features/screenshot.d.ts.map +1 -1
- package/dist/reportly.cjs.js +51 -5
- package/dist/reportly.cjs.js.map +1 -1
- package/dist/reportly.esm.js +51 -5
- package/dist/reportly.esm.js.map +1 -1
- package/dist/reportly.js +51 -5
- package/dist/reportly.js.map +1 -1
- package/dist/reportly.min.js +1 -1
- package/dist/reportly.min.js.map +1 -1
- package/package.json +1 -1
package/dist/reportly.esm.js
CHANGED
@@ -9447,24 +9447,48 @@ class Screenshot {
|
|
9447
9447
|
constructor() {
|
9448
9448
|
this.currentScreenshot = null;
|
9449
9449
|
}
|
9450
|
-
async capture(mode =
|
9450
|
+
async capture(mode = "fullpage") {
|
9451
9451
|
try {
|
9452
9452
|
// Hide UXbert UI elements before capturing
|
9453
9453
|
this.hideUXbertElements();
|
9454
9454
|
const originalScrollY = window.scrollY;
|
9455
9455
|
let canvas;
|
9456
|
-
if (mode ===
|
9456
|
+
if (mode === "viewport") {
|
9457
9457
|
// Capture only the current viewport
|
9458
9458
|
canvas = await html2canvas(document.body, {
|
9459
|
-
|
9459
|
+
// foreignObjectRendering: true,
|
9460
|
+
imageTimeout: 40000,
|
9460
9461
|
useCORS: true,
|
9461
|
-
|
9462
|
+
allowTaint: false,
|
9463
|
+
logging: true,
|
9462
9464
|
width: window.innerWidth,
|
9463
9465
|
height: window.innerHeight,
|
9464
9466
|
windowWidth: window.innerWidth,
|
9465
9467
|
windowHeight: window.innerHeight,
|
9466
9468
|
x: window.scrollX,
|
9467
9469
|
y: window.scrollY,
|
9470
|
+
ignoreElements: (element) => {
|
9471
|
+
// Skip cross-origin images that might cause issues
|
9472
|
+
if (element.tagName === "IMG") {
|
9473
|
+
const img = element;
|
9474
|
+
try {
|
9475
|
+
// Test if image is accessible
|
9476
|
+
const canvas = document.createElement("canvas");
|
9477
|
+
const ctx = canvas.getContext("2d");
|
9478
|
+
canvas.width = 1;
|
9479
|
+
canvas.height = 1;
|
9480
|
+
ctx?.drawImage(img, 0, 0, 1, 1);
|
9481
|
+
canvas.toDataURL(); // This will throw if tainted
|
9482
|
+
return false; // Include the image
|
9483
|
+
}
|
9484
|
+
catch (e) {
|
9485
|
+
// Image is tainted, skip it
|
9486
|
+
console.warn("Skipping cross-origin image:", img.src);
|
9487
|
+
return true;
|
9488
|
+
}
|
9489
|
+
}
|
9490
|
+
return false;
|
9491
|
+
},
|
9468
9492
|
});
|
9469
9493
|
}
|
9470
9494
|
else {
|
@@ -9475,11 +9499,33 @@ class Screenshot {
|
|
9475
9499
|
const fullPageWidth = Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);
|
9476
9500
|
// Capture the full page
|
9477
9501
|
canvas = await html2canvas(document.body, {
|
9478
|
-
allowTaint: true,
|
9479
9502
|
useCORS: true,
|
9503
|
+
allowTaint: false,
|
9480
9504
|
logging: false,
|
9481
9505
|
width: fullPageWidth,
|
9482
9506
|
height: fullPageHeight,
|
9507
|
+
ignoreElements: (element) => {
|
9508
|
+
// Skip cross-origin images that might cause issues
|
9509
|
+
if (element.tagName === "IMG") {
|
9510
|
+
const img = element;
|
9511
|
+
try {
|
9512
|
+
// Test if image is accessible
|
9513
|
+
const canvas = document.createElement("canvas");
|
9514
|
+
const ctx = canvas.getContext("2d");
|
9515
|
+
canvas.width = 1;
|
9516
|
+
canvas.height = 1;
|
9517
|
+
ctx?.drawImage(img, 0, 0, 1, 1);
|
9518
|
+
canvas.toDataURL(); // This will throw if tainted
|
9519
|
+
return false; // Include the image
|
9520
|
+
}
|
9521
|
+
catch (e) {
|
9522
|
+
// Image is tainted, skip it
|
9523
|
+
console.warn("Skipping cross-origin image:", img.src);
|
9524
|
+
return true;
|
9525
|
+
}
|
9526
|
+
}
|
9527
|
+
return false;
|
9528
|
+
},
|
9483
9529
|
});
|
9484
9530
|
// Restore scroll position
|
9485
9531
|
window.scrollTo(0, originalScrollY);
|