feedback-vos 1.0.39 → 1.0.41

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
@@ -265,8 +265,21 @@ function ScreenshotEditor({
265
265
  const editedScreenshot = canvas.toDataURL("image/png");
266
266
  onSave(editedScreenshot);
267
267
  };
268
- const maxWidth = 600;
269
- const displayWidth = image ? Math.min(maxWidth, image.width) : maxWidth;
268
+ const [maxDisplayWidth, setMaxDisplayWidth] = useState(600);
269
+ useEffect(() => {
270
+ const updateMaxWidth = () => {
271
+ if (window.innerWidth >= 768) {
272
+ const availableWidth = window.innerWidth * 0.9 - 64;
273
+ setMaxDisplayWidth(Math.max(1200, Math.min(availableWidth, 1600)));
274
+ } else {
275
+ setMaxDisplayWidth(600);
276
+ }
277
+ };
278
+ updateMaxWidth();
279
+ window.addEventListener("resize", updateMaxWidth);
280
+ return () => window.removeEventListener("resize", updateMaxWidth);
281
+ }, []);
282
+ const displayWidth = image ? Math.min(maxDisplayWidth, image.width) : maxDisplayWidth;
270
283
  const displayHeight = image ? displayWidth / image.width * image.height : 400;
271
284
  return /* @__PURE__ */ jsx("div", { className: `fixed inset-0 z-50 flex items-center justify-center ${themeClasses.overlay} p-2 md:p-4`, children: /* @__PURE__ */ jsxs("div", { className: `${themeClasses.bgSecondary} rounded-lg shadow-xl max-w-4xl w-full max-h-[95vh] md:max-h-[90vh] overflow-auto`, children: [
272
285
  /* @__PURE__ */ jsxs("div", { className: `sticky top-0 ${themeClasses.bgSecondary} border-b ${themeClasses.borderPrimary} p-2 md:p-4 flex items-center justify-between z-10 gap-2`, children: [
@@ -384,21 +397,55 @@ function ScreenshotButton({
384
397
  const canvas = await html2canvas(document.body, {
385
398
  width: window.innerWidth,
386
399
  height: window.innerHeight,
387
- scrollX: -window.scrollX,
388
- scrollY: -window.scrollY,
389
400
  windowWidth: window.innerWidth,
390
401
  windowHeight: window.innerHeight,
391
- scale: window.devicePixelRatio || 1,
392
- // Use device pixel ratio for better quality
402
+ scrollX: -window.scrollX,
403
+ scrollY: -window.scrollY,
404
+ scale: 1,
405
+ // Use scale 1 for consistent sizing
393
406
  useCORS: true,
394
- // Enable CORS for better image rendering
407
+ allowTaint: true,
408
+ // Allow external images for better rendering
409
+ backgroundColor: null,
410
+ // Preserve page background
411
+ removeContainer: false,
412
+ // Maintain proper container rendering
395
413
  logging: false,
396
- // Disable logging for cleaner output
397
414
  ignoreElements: (element) => {
398
415
  return element.hasAttribute("data-feedback-widget") || element.closest("[data-feedback-widget]") !== null;
399
416
  }
400
417
  });
401
- const base64image = canvas.toDataURL("image/png", 1);
418
+ const targetWidth = 1920;
419
+ const targetHeight = 1080;
420
+ const normalizedCanvas = document.createElement("canvas");
421
+ normalizedCanvas.width = targetWidth;
422
+ normalizedCanvas.height = targetHeight;
423
+ const ctx = normalizedCanvas.getContext("2d");
424
+ if (!ctx) {
425
+ setIsTakenScreenShot(false);
426
+ return;
427
+ }
428
+ ctx.imageSmoothingEnabled = true;
429
+ ctx.imageSmoothingQuality = "high";
430
+ const sourceAspect = canvas.width / canvas.height;
431
+ const targetAspect = targetWidth / targetHeight;
432
+ let drawWidth = targetWidth;
433
+ let drawHeight = targetHeight;
434
+ let drawX = 0;
435
+ let drawY = 0;
436
+ if (sourceAspect > targetAspect) {
437
+ drawHeight = targetHeight;
438
+ drawWidth = drawHeight * sourceAspect;
439
+ drawX = (targetWidth - drawWidth) / 2;
440
+ } else {
441
+ drawWidth = targetWidth;
442
+ drawHeight = drawWidth / sourceAspect;
443
+ drawY = (targetHeight - drawHeight) / 2;
444
+ }
445
+ ctx.fillStyle = "#ffffff";
446
+ ctx.fillRect(0, 0, targetWidth, targetHeight);
447
+ ctx.drawImage(canvas, drawX, drawY, drawWidth, drawHeight);
448
+ const base64image = normalizedCanvas.toDataURL("image/png", 1);
402
449
  onScreenshotTook(base64image);
403
450
  setIsTakenScreenShot(false);
404
451
  }
@@ -748,7 +795,7 @@ async function uploadFileToRepo(token, owner, repo, file, folderPath, defaultBra
748
795
  return rawUrl;
749
796
  }
750
797
  async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshotPath) {
751
- const compressedScreenshot = await compressScreenshot(screenshot, 2560, 0.9);
798
+ const compressedScreenshot = await compressScreenshot(screenshot, 1920, 0.85);
752
799
  const base64Content = compressedScreenshot.includes(",") ? compressedScreenshot.split(",")[1] : compressedScreenshot;
753
800
  const repoResponse = await fetch(
754
801
  `https://api.github.com/repos/${owner}/${repo}`,
@@ -850,7 +897,7 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
850
897
  console.log(`Screenshot uploaded successfully to: ${rawUrl}`);
851
898
  return rawUrl;
852
899
  }
853
- function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
900
+ function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.85) {
854
901
  return new Promise((resolve, reject) => {
855
902
  if (typeof window === "undefined" || typeof document === "undefined") {
856
903
  reject(new Error("Screenshot compression only works in browser environments"));
@@ -865,9 +912,8 @@ function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
865
912
  height = height * maxWidth / width;
866
913
  width = maxWidth;
867
914
  }
868
- const dpr = window.devicePixelRatio || 1;
869
- canvas.width = width * dpr;
870
- canvas.height = height * dpr;
915
+ canvas.width = width;
916
+ canvas.height = height;
871
917
  const ctx = canvas.getContext("2d");
872
918
  if (!ctx) {
873
919
  reject(new Error("Could not get canvas context"));
@@ -875,7 +921,6 @@ function compressScreenshot(dataUrl, maxWidth = 2560, quality = 0.9) {
875
921
  }
876
922
  ctx.imageSmoothingEnabled = true;
877
923
  ctx.imageSmoothingQuality = "high";
878
- ctx.scale(dpr, dpr);
879
924
  ctx.drawImage(img, 0, 0, width, height);
880
925
  const compressedDataUrl = canvas.toDataURL("image/jpeg", quality);
881
926
  resolve(compressedDataUrl);