@pixldocs/canvas-renderer 0.3.14 → 0.3.15
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.cjs +25 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +25 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10402,12 +10402,7 @@ async function loadGoogleFontCSS(rawFontFamily) {
|
|
|
10402
10402
|
const existing = loadingPromises.get(fontFamily);
|
|
10403
10403
|
if (existing) return existing;
|
|
10404
10404
|
const promise = (async () => {
|
|
10405
|
-
var _a;
|
|
10406
10405
|
try {
|
|
10407
|
-
if ((_a = document.fonts) == null ? void 0 : _a.check(`16px "${fontFamily}"`)) {
|
|
10408
|
-
loadedFonts.add(fontFamily);
|
|
10409
|
-
return;
|
|
10410
|
-
}
|
|
10411
10406
|
const encoded = encodeURIComponent(fontFamily);
|
|
10412
10407
|
const url = `https://fonts.googleapis.com/css?family=${encoded}:300,400,500,600,700&display=swap`;
|
|
10413
10408
|
const link = document.createElement("link");
|
|
@@ -10715,7 +10710,8 @@ class PixldocsRenderer {
|
|
|
10715
10710
|
// ─── Internal: render a page using the full PreviewCanvas engine ───
|
|
10716
10711
|
/**
|
|
10717
10712
|
* Wait until every image on the Fabric canvas inside the container has loaded.
|
|
10718
|
-
*
|
|
10713
|
+
* Checks both DOM <img> elements AND Fabric canvas image objects to ensure
|
|
10714
|
+
* all async assets are fully painted before capture.
|
|
10719
10715
|
*/
|
|
10720
10716
|
waitForCanvasImages(container, maxWaitMs = 15e3, pollMs = 200) {
|
|
10721
10717
|
return new Promise((resolve) => {
|
|
@@ -10726,6 +10722,29 @@ class PixldocsRenderer {
|
|
|
10726
10722
|
images.forEach((img) => {
|
|
10727
10723
|
if (!img.complete) allLoaded = false;
|
|
10728
10724
|
});
|
|
10725
|
+
if (allLoaded) {
|
|
10726
|
+
const canvasEl = container.querySelector("canvas.lower-canvas, canvas");
|
|
10727
|
+
const fabricCanvas = canvasEl && canvasEl.__fabric;
|
|
10728
|
+
if (fabricCanvas && typeof fabricCanvas.getObjects === "function") {
|
|
10729
|
+
for (const obj of fabricCanvas.getObjects()) {
|
|
10730
|
+
const el = obj._element || obj._originalElement;
|
|
10731
|
+
if (el instanceof HTMLImageElement && !el.complete) {
|
|
10732
|
+
allLoaded = false;
|
|
10733
|
+
break;
|
|
10734
|
+
}
|
|
10735
|
+
if (obj._objects) {
|
|
10736
|
+
for (const child of obj._objects) {
|
|
10737
|
+
const childEl = child._element || child._originalElement;
|
|
10738
|
+
if (childEl instanceof HTMLImageElement && !childEl.complete) {
|
|
10739
|
+
allLoaded = false;
|
|
10740
|
+
break;
|
|
10741
|
+
}
|
|
10742
|
+
}
|
|
10743
|
+
if (!allLoaded) break;
|
|
10744
|
+
}
|
|
10745
|
+
}
|
|
10746
|
+
}
|
|
10747
|
+
}
|
|
10729
10748
|
if (allLoaded || Date.now() - start > maxWaitMs) {
|
|
10730
10749
|
requestAnimationFrame(() => setTimeout(resolve, 400));
|
|
10731
10750
|
return;
|