@yoamigo.com/core 0.3.10 → 0.3.12
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 +65 -18
- package/dist/lib.js +65 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -693,19 +693,40 @@ var BuilderSelectionManager = class {
|
|
|
693
693
|
el.style.display = "none";
|
|
694
694
|
});
|
|
695
695
|
const canvas = await html2canvas(document.body, {
|
|
696
|
-
scale:
|
|
697
|
-
//
|
|
696
|
+
scale: 1,
|
|
697
|
+
// Full resolution
|
|
698
698
|
logging: false,
|
|
699
699
|
useCORS: true,
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
700
|
+
backgroundColor: null,
|
|
701
|
+
// No background - preserve page's actual background
|
|
702
|
+
windowHeight: document.body.scrollHeight,
|
|
703
|
+
// Full page height
|
|
704
|
+
height: document.body.scrollHeight,
|
|
705
|
+
// Full page height
|
|
706
|
+
scrollX: 0,
|
|
707
|
+
// Render from left (no visible scroll)
|
|
708
|
+
scrollY: 0,
|
|
709
|
+
// Render from top (no visible scroll)
|
|
710
|
+
onclone: async (clonedDoc) => {
|
|
711
|
+
clonedDoc.querySelectorAll('img[loading="lazy"]').forEach((img) => {
|
|
712
|
+
img.removeAttribute("loading");
|
|
713
|
+
});
|
|
714
|
+
await Promise.all(
|
|
715
|
+
Array.from(clonedDoc.querySelectorAll("img")).map(
|
|
716
|
+
(img) => img.complete && img.naturalHeight !== 0 ? Promise.resolve() : new Promise((r) => {
|
|
717
|
+
img.onload = r;
|
|
718
|
+
img.onerror = r;
|
|
719
|
+
})
|
|
720
|
+
)
|
|
721
|
+
);
|
|
722
|
+
await clonedDoc.fonts?.ready;
|
|
723
|
+
}
|
|
703
724
|
});
|
|
704
725
|
overlays.forEach((el) => {
|
|
705
726
|
;
|
|
706
727
|
el.style.display = "";
|
|
707
728
|
});
|
|
708
|
-
const dataUrl = canvas.toDataURL("image/jpeg", 0.
|
|
729
|
+
const dataUrl = canvas.toDataURL("image/jpeg", 0.8);
|
|
709
730
|
this.sendToParent({
|
|
710
731
|
type: "SCREENSHOT_READY",
|
|
711
732
|
dataUrl
|
|
@@ -731,7 +752,6 @@ var BuilderSelectionManager = class {
|
|
|
731
752
|
scale: 1,
|
|
732
753
|
logging: false,
|
|
733
754
|
useCORS: true,
|
|
734
|
-
allowTaint: true,
|
|
735
755
|
backgroundColor: null
|
|
736
756
|
// Preserve transparency if any
|
|
737
757
|
});
|
|
@@ -939,33 +959,60 @@ var BuilderSelectionManager = class {
|
|
|
939
959
|
;
|
|
940
960
|
el.style.display = "none";
|
|
941
961
|
});
|
|
942
|
-
const
|
|
943
|
-
|
|
944
|
-
await new Promise((resolve) => requestAnimationFrame(resolve));
|
|
962
|
+
const scrollHeight = document.body.scrollHeight;
|
|
963
|
+
console.log("[BuilderSelection] capturePageAsArrayBuffer - scrollHeight:", scrollHeight);
|
|
945
964
|
const canvas = await html2canvas(document.body, {
|
|
946
|
-
scale:
|
|
947
|
-
//
|
|
948
|
-
logging:
|
|
965
|
+
scale: 1,
|
|
966
|
+
// Full resolution
|
|
967
|
+
logging: true,
|
|
968
|
+
// Enable logging for debugging
|
|
949
969
|
useCORS: true,
|
|
950
|
-
allowTaint: true,
|
|
951
970
|
backgroundColor: "#ffffff",
|
|
952
|
-
|
|
971
|
+
// White background to avoid transparent canvas issues
|
|
972
|
+
windowHeight: scrollHeight,
|
|
953
973
|
// Full page height
|
|
954
|
-
height:
|
|
974
|
+
height: scrollHeight,
|
|
975
|
+
scrollX: 0,
|
|
976
|
+
// Render from left (no visible scroll)
|
|
977
|
+
scrollY: 0,
|
|
978
|
+
// Render from top (no visible scroll)
|
|
979
|
+
onclone: async (clonedDoc) => {
|
|
980
|
+
console.log("[BuilderSelection] onclone called");
|
|
981
|
+
const lazyImages = clonedDoc.querySelectorAll('img[loading="lazy"]');
|
|
982
|
+
console.log("[BuilderSelection] Found lazy images:", lazyImages.length);
|
|
983
|
+
lazyImages.forEach((img) => {
|
|
984
|
+
img.removeAttribute("loading");
|
|
985
|
+
});
|
|
986
|
+
const allImages = Array.from(clonedDoc.querySelectorAll("img"));
|
|
987
|
+
console.log("[BuilderSelection] Total images to wait for:", allImages.length);
|
|
988
|
+
await Promise.all(
|
|
989
|
+
allImages.map(
|
|
990
|
+
(img) => img.complete && img.naturalHeight !== 0 ? Promise.resolve() : new Promise((r) => {
|
|
991
|
+
img.onload = r;
|
|
992
|
+
img.onerror = r;
|
|
993
|
+
})
|
|
994
|
+
)
|
|
995
|
+
);
|
|
996
|
+
console.log("[BuilderSelection] All images loaded");
|
|
997
|
+
await clonedDoc.fonts?.ready;
|
|
998
|
+
console.log("[BuilderSelection] Fonts ready");
|
|
999
|
+
}
|
|
955
1000
|
});
|
|
956
|
-
|
|
1001
|
+
console.log("[BuilderSelection] Canvas created:", canvas.width, "x", canvas.height);
|
|
957
1002
|
overlays.forEach((el) => {
|
|
958
1003
|
;
|
|
959
1004
|
el.style.display = "";
|
|
960
1005
|
});
|
|
961
1006
|
const blob = await new Promise((resolve) => {
|
|
962
|
-
canvas.toBlob((b) => resolve(b), "image/jpeg", 0.
|
|
1007
|
+
canvas.toBlob((b) => resolve(b), "image/jpeg", 0.8);
|
|
963
1008
|
});
|
|
964
1009
|
if (!blob) {
|
|
965
1010
|
console.error("[BuilderSelection] Failed to create blob from canvas");
|
|
966
1011
|
return null;
|
|
967
1012
|
}
|
|
1013
|
+
console.log("[BuilderSelection] Blob created, size:", blob.size, "bytes");
|
|
968
1014
|
const buffer = await blob.arrayBuffer();
|
|
1015
|
+
console.log("[BuilderSelection] ArrayBuffer ready, size:", buffer.byteLength);
|
|
969
1016
|
return buffer;
|
|
970
1017
|
} catch (error) {
|
|
971
1018
|
console.error("[BuilderSelection] Page capture failed:", error);
|
package/dist/lib.js
CHANGED
|
@@ -652,19 +652,40 @@ var BuilderSelectionManager = class {
|
|
|
652
652
|
el.style.display = "none";
|
|
653
653
|
});
|
|
654
654
|
const canvas = await html2canvas(document.body, {
|
|
655
|
-
scale:
|
|
656
|
-
//
|
|
655
|
+
scale: 1,
|
|
656
|
+
// Full resolution
|
|
657
657
|
logging: false,
|
|
658
658
|
useCORS: true,
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
659
|
+
backgroundColor: null,
|
|
660
|
+
// No background - preserve page's actual background
|
|
661
|
+
windowHeight: document.body.scrollHeight,
|
|
662
|
+
// Full page height
|
|
663
|
+
height: document.body.scrollHeight,
|
|
664
|
+
// Full page height
|
|
665
|
+
scrollX: 0,
|
|
666
|
+
// Render from left (no visible scroll)
|
|
667
|
+
scrollY: 0,
|
|
668
|
+
// Render from top (no visible scroll)
|
|
669
|
+
onclone: async (clonedDoc) => {
|
|
670
|
+
clonedDoc.querySelectorAll('img[loading="lazy"]').forEach((img) => {
|
|
671
|
+
img.removeAttribute("loading");
|
|
672
|
+
});
|
|
673
|
+
await Promise.all(
|
|
674
|
+
Array.from(clonedDoc.querySelectorAll("img")).map(
|
|
675
|
+
(img) => img.complete && img.naturalHeight !== 0 ? Promise.resolve() : new Promise((r) => {
|
|
676
|
+
img.onload = r;
|
|
677
|
+
img.onerror = r;
|
|
678
|
+
})
|
|
679
|
+
)
|
|
680
|
+
);
|
|
681
|
+
await clonedDoc.fonts?.ready;
|
|
682
|
+
}
|
|
662
683
|
});
|
|
663
684
|
overlays.forEach((el) => {
|
|
664
685
|
;
|
|
665
686
|
el.style.display = "";
|
|
666
687
|
});
|
|
667
|
-
const dataUrl = canvas.toDataURL("image/jpeg", 0.
|
|
688
|
+
const dataUrl = canvas.toDataURL("image/jpeg", 0.8);
|
|
668
689
|
this.sendToParent({
|
|
669
690
|
type: "SCREENSHOT_READY",
|
|
670
691
|
dataUrl
|
|
@@ -690,7 +711,6 @@ var BuilderSelectionManager = class {
|
|
|
690
711
|
scale: 1,
|
|
691
712
|
logging: false,
|
|
692
713
|
useCORS: true,
|
|
693
|
-
allowTaint: true,
|
|
694
714
|
backgroundColor: null
|
|
695
715
|
// Preserve transparency if any
|
|
696
716
|
});
|
|
@@ -898,33 +918,60 @@ var BuilderSelectionManager = class {
|
|
|
898
918
|
;
|
|
899
919
|
el.style.display = "none";
|
|
900
920
|
});
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
await new Promise((resolve) => requestAnimationFrame(resolve));
|
|
921
|
+
const scrollHeight = document.body.scrollHeight;
|
|
922
|
+
console.log("[BuilderSelection] capturePageAsArrayBuffer - scrollHeight:", scrollHeight);
|
|
904
923
|
const canvas = await html2canvas(document.body, {
|
|
905
|
-
scale:
|
|
906
|
-
//
|
|
907
|
-
logging:
|
|
924
|
+
scale: 1,
|
|
925
|
+
// Full resolution
|
|
926
|
+
logging: true,
|
|
927
|
+
// Enable logging for debugging
|
|
908
928
|
useCORS: true,
|
|
909
|
-
allowTaint: true,
|
|
910
929
|
backgroundColor: "#ffffff",
|
|
911
|
-
|
|
930
|
+
// White background to avoid transparent canvas issues
|
|
931
|
+
windowHeight: scrollHeight,
|
|
912
932
|
// Full page height
|
|
913
|
-
height:
|
|
933
|
+
height: scrollHeight,
|
|
934
|
+
scrollX: 0,
|
|
935
|
+
// Render from left (no visible scroll)
|
|
936
|
+
scrollY: 0,
|
|
937
|
+
// Render from top (no visible scroll)
|
|
938
|
+
onclone: async (clonedDoc) => {
|
|
939
|
+
console.log("[BuilderSelection] onclone called");
|
|
940
|
+
const lazyImages = clonedDoc.querySelectorAll('img[loading="lazy"]');
|
|
941
|
+
console.log("[BuilderSelection] Found lazy images:", lazyImages.length);
|
|
942
|
+
lazyImages.forEach((img) => {
|
|
943
|
+
img.removeAttribute("loading");
|
|
944
|
+
});
|
|
945
|
+
const allImages = Array.from(clonedDoc.querySelectorAll("img"));
|
|
946
|
+
console.log("[BuilderSelection] Total images to wait for:", allImages.length);
|
|
947
|
+
await Promise.all(
|
|
948
|
+
allImages.map(
|
|
949
|
+
(img) => img.complete && img.naturalHeight !== 0 ? Promise.resolve() : new Promise((r) => {
|
|
950
|
+
img.onload = r;
|
|
951
|
+
img.onerror = r;
|
|
952
|
+
})
|
|
953
|
+
)
|
|
954
|
+
);
|
|
955
|
+
console.log("[BuilderSelection] All images loaded");
|
|
956
|
+
await clonedDoc.fonts?.ready;
|
|
957
|
+
console.log("[BuilderSelection] Fonts ready");
|
|
958
|
+
}
|
|
914
959
|
});
|
|
915
|
-
|
|
960
|
+
console.log("[BuilderSelection] Canvas created:", canvas.width, "x", canvas.height);
|
|
916
961
|
overlays.forEach((el) => {
|
|
917
962
|
;
|
|
918
963
|
el.style.display = "";
|
|
919
964
|
});
|
|
920
965
|
const blob = await new Promise((resolve) => {
|
|
921
|
-
canvas.toBlob((b) => resolve(b), "image/jpeg", 0.
|
|
966
|
+
canvas.toBlob((b) => resolve(b), "image/jpeg", 0.8);
|
|
922
967
|
});
|
|
923
968
|
if (!blob) {
|
|
924
969
|
console.error("[BuilderSelection] Failed to create blob from canvas");
|
|
925
970
|
return null;
|
|
926
971
|
}
|
|
972
|
+
console.log("[BuilderSelection] Blob created, size:", blob.size, "bytes");
|
|
927
973
|
const buffer = await blob.arrayBuffer();
|
|
974
|
+
console.log("[BuilderSelection] ArrayBuffer ready, size:", buffer.byteLength);
|
|
928
975
|
return buffer;
|
|
929
976
|
} catch (error) {
|
|
930
977
|
console.error("[BuilderSelection] Page capture failed:", error);
|