feedback-vos 1.0.37 → 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 +16 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -394,11 +394,17 @@ function ScreenshotButton({
|
|
|
394
394
|
scrollY: -window.scrollY,
|
|
395
395
|
windowWidth: window.innerWidth,
|
|
396
396
|
windowHeight: window.innerHeight,
|
|
397
|
+
scale: window.devicePixelRatio || 1,
|
|
398
|
+
// Use device pixel ratio for better quality
|
|
399
|
+
useCORS: true,
|
|
400
|
+
// Enable CORS for better image rendering
|
|
401
|
+
logging: false,
|
|
402
|
+
// Disable logging for cleaner output
|
|
397
403
|
ignoreElements: (element) => {
|
|
398
404
|
return element.hasAttribute("data-feedback-widget") || element.closest("[data-feedback-widget]") !== null;
|
|
399
405
|
}
|
|
400
406
|
});
|
|
401
|
-
const base64image = canvas.toDataURL("image/png");
|
|
407
|
+
const base64image = canvas.toDataURL("image/png", 1);
|
|
402
408
|
onScreenshotTook(base64image);
|
|
403
409
|
setIsTakenScreenShot(false);
|
|
404
410
|
}
|
|
@@ -748,9 +754,8 @@ async function uploadFileToRepo(token, owner, repo, file, folderPath, defaultBra
|
|
|
748
754
|
return rawUrl;
|
|
749
755
|
}
|
|
750
756
|
async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshotPath) {
|
|
751
|
-
const compressedScreenshot = await compressScreenshot(screenshot,
|
|
752
|
-
const
|
|
753
|
-
const binaryData = Uint8Array.from(atob(base64Data), (c) => c.charCodeAt(0));
|
|
757
|
+
const compressedScreenshot = await compressScreenshot(screenshot, 2560, 0.9);
|
|
758
|
+
const base64Content = compressedScreenshot.includes(",") ? compressedScreenshot.split(",")[1] : compressedScreenshot;
|
|
754
759
|
const repoResponse = await fetch(
|
|
755
760
|
`https://api.github.com/repos/${owner}/${repo}`,
|
|
756
761
|
{
|
|
@@ -771,7 +776,6 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
|
|
|
771
776
|
const randomId = Math.random().toString(36).substring(2, 9);
|
|
772
777
|
const filename = `feedback-${timestamp}-${randomId}.jpg`;
|
|
773
778
|
const path = `${folderPath}/${filename}`;
|
|
774
|
-
const base64Content = btoa(String.fromCharCode(...binaryData));
|
|
775
779
|
const folderCheckUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${folderPath}`;
|
|
776
780
|
try {
|
|
777
781
|
const folderCheck = await fetch(folderCheckUrl, {
|
|
@@ -852,7 +856,7 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
|
|
|
852
856
|
console.log(`Screenshot uploaded successfully to: ${rawUrl}`);
|
|
853
857
|
return rawUrl;
|
|
854
858
|
}
|
|
855
|
-
function compressScreenshot(dataUrl, maxWidth =
|
|
859
|
+
function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
|
|
856
860
|
return new Promise((resolve, reject) => {
|
|
857
861
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
858
862
|
reject(new Error("Screenshot compression only works in browser environments"));
|
|
@@ -867,13 +871,17 @@ function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.7) {
|
|
|
867
871
|
height = height * maxWidth / width;
|
|
868
872
|
width = maxWidth;
|
|
869
873
|
}
|
|
870
|
-
|
|
871
|
-
canvas.
|
|
874
|
+
const dpr = window.devicePixelRatio || 1;
|
|
875
|
+
canvas.width = width * dpr;
|
|
876
|
+
canvas.height = height * dpr;
|
|
872
877
|
const ctx = canvas.getContext("2d");
|
|
873
878
|
if (!ctx) {
|
|
874
879
|
reject(new Error("Could not get canvas context"));
|
|
875
880
|
return;
|
|
876
881
|
}
|
|
882
|
+
ctx.imageSmoothingEnabled = true;
|
|
883
|
+
ctx.imageSmoothingQuality = "high";
|
|
884
|
+
ctx.scale(dpr, dpr);
|
|
877
885
|
ctx.drawImage(img, 0, 0, width, height);
|
|
878
886
|
const compressedDataUrl = canvas.toDataURL("image/jpeg", quality);
|
|
879
887
|
resolve(compressedDataUrl);
|