feedback-vos 1.0.38 → 1.0.39
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.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -388,11 +388,17 @@ function ScreenshotButton({
|
|
|
388
388
|
scrollY: -window.scrollY,
|
|
389
389
|
windowWidth: window.innerWidth,
|
|
390
390
|
windowHeight: window.innerHeight,
|
|
391
|
+
scale: window.devicePixelRatio || 1,
|
|
392
|
+
// Use device pixel ratio for better quality
|
|
393
|
+
useCORS: true,
|
|
394
|
+
// Enable CORS for better image rendering
|
|
395
|
+
logging: false,
|
|
396
|
+
// Disable logging for cleaner output
|
|
391
397
|
ignoreElements: (element) => {
|
|
392
398
|
return element.hasAttribute("data-feedback-widget") || element.closest("[data-feedback-widget]") !== null;
|
|
393
399
|
}
|
|
394
400
|
});
|
|
395
|
-
const base64image = canvas.toDataURL("image/png");
|
|
401
|
+
const base64image = canvas.toDataURL("image/png", 1);
|
|
396
402
|
onScreenshotTook(base64image);
|
|
397
403
|
setIsTakenScreenShot(false);
|
|
398
404
|
}
|
|
@@ -742,7 +748,7 @@ async function uploadFileToRepo(token, owner, repo, file, folderPath, defaultBra
|
|
|
742
748
|
return rawUrl;
|
|
743
749
|
}
|
|
744
750
|
async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshotPath) {
|
|
745
|
-
const compressedScreenshot = await compressScreenshot(screenshot,
|
|
751
|
+
const compressedScreenshot = await compressScreenshot(screenshot, 2560, 0.9);
|
|
746
752
|
const base64Content = compressedScreenshot.includes(",") ? compressedScreenshot.split(",")[1] : compressedScreenshot;
|
|
747
753
|
const repoResponse = await fetch(
|
|
748
754
|
`https://api.github.com/repos/${owner}/${repo}`,
|
|
@@ -844,7 +850,7 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
|
|
|
844
850
|
console.log(`Screenshot uploaded successfully to: ${rawUrl}`);
|
|
845
851
|
return rawUrl;
|
|
846
852
|
}
|
|
847
|
-
function compressScreenshot(dataUrl, maxWidth =
|
|
853
|
+
function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
|
|
848
854
|
return new Promise((resolve, reject) => {
|
|
849
855
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
850
856
|
reject(new Error("Screenshot compression only works in browser environments"));
|
|
@@ -859,13 +865,17 @@ function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.7) {
|
|
|
859
865
|
height = height * maxWidth / width;
|
|
860
866
|
width = maxWidth;
|
|
861
867
|
}
|
|
862
|
-
|
|
863
|
-
canvas.
|
|
868
|
+
const dpr = window.devicePixelRatio || 1;
|
|
869
|
+
canvas.width = width * dpr;
|
|
870
|
+
canvas.height = height * dpr;
|
|
864
871
|
const ctx = canvas.getContext("2d");
|
|
865
872
|
if (!ctx) {
|
|
866
873
|
reject(new Error("Could not get canvas context"));
|
|
867
874
|
return;
|
|
868
875
|
}
|
|
876
|
+
ctx.imageSmoothingEnabled = true;
|
|
877
|
+
ctx.imageSmoothingQuality = "high";
|
|
878
|
+
ctx.scale(dpr, dpr);
|
|
869
879
|
ctx.drawImage(img, 0, 0, width, height);
|
|
870
880
|
const compressedDataUrl = canvas.toDataURL("image/jpeg", quality);
|
|
871
881
|
resolve(compressedDataUrl);
|