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.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,9 +748,8 @@ 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, 1920, 0.7);
746
- const base64Data = compressedScreenshot.split(",")[1];
747
- const binaryData = Uint8Array.from(atob(base64Data), (c) => c.charCodeAt(0));
751
+ const compressedScreenshot = await compressScreenshot(screenshot, 2560, 0.9);
752
+ const base64Content = compressedScreenshot.includes(",") ? compressedScreenshot.split(",")[1] : compressedScreenshot;
748
753
  const repoResponse = await fetch(
749
754
  `https://api.github.com/repos/${owner}/${repo}`,
750
755
  {
@@ -765,7 +770,6 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
765
770
  const randomId = Math.random().toString(36).substring(2, 9);
766
771
  const filename = `feedback-${timestamp}-${randomId}.jpg`;
767
772
  const path = `${folderPath}/${filename}`;
768
- const base64Content = btoa(String.fromCharCode(...binaryData));
769
773
  const folderCheckUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${folderPath}`;
770
774
  try {
771
775
  const folderCheck = await fetch(folderCheckUrl, {
@@ -846,7 +850,7 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
846
850
  console.log(`Screenshot uploaded successfully to: ${rawUrl}`);
847
851
  return rawUrl;
848
852
  }
849
- function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.7) {
853
+ function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
850
854
  return new Promise((resolve, reject) => {
851
855
  if (typeof window === "undefined" || typeof document === "undefined") {
852
856
  reject(new Error("Screenshot compression only works in browser environments"));
@@ -861,13 +865,17 @@ function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.7) {
861
865
  height = height * maxWidth / width;
862
866
  width = maxWidth;
863
867
  }
864
- canvas.width = width;
865
- canvas.height = height;
868
+ const dpr = window.devicePixelRatio || 1;
869
+ canvas.width = width * dpr;
870
+ canvas.height = height * dpr;
866
871
  const ctx = canvas.getContext("2d");
867
872
  if (!ctx) {
868
873
  reject(new Error("Could not get canvas context"));
869
874
  return;
870
875
  }
876
+ ctx.imageSmoothingEnabled = true;
877
+ ctx.imageSmoothingQuality = "high";
878
+ ctx.scale(dpr, dpr);
871
879
  ctx.drawImage(img, 0, 0, width, height);
872
880
  const compressedDataUrl = canvas.toDataURL("image/jpeg", quality);
873
881
  resolve(compressedDataUrl);