@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.d.ts
CHANGED
|
@@ -181,7 +181,8 @@ export declare class PixldocsRenderer {
|
|
|
181
181
|
renderById(templateId: string, formData?: Record<string, any>, options?: RenderOptions): Promise<RenderResult>;
|
|
182
182
|
/**
|
|
183
183
|
* Wait until every image on the Fabric canvas inside the container has loaded.
|
|
184
|
-
*
|
|
184
|
+
* Checks both DOM <img> elements AND Fabric canvas image objects to ensure
|
|
185
|
+
* all async assets are fully painted before capture.
|
|
185
186
|
*/
|
|
186
187
|
private waitForCanvasImages;
|
|
187
188
|
private getNormalizedGradientStops;
|
package/dist/index.js
CHANGED
|
@@ -10383,12 +10383,7 @@ async function loadGoogleFontCSS(rawFontFamily) {
|
|
|
10383
10383
|
const existing = loadingPromises.get(fontFamily);
|
|
10384
10384
|
if (existing) return existing;
|
|
10385
10385
|
const promise = (async () => {
|
|
10386
|
-
var _a;
|
|
10387
10386
|
try {
|
|
10388
|
-
if ((_a = document.fonts) == null ? void 0 : _a.check(`16px "${fontFamily}"`)) {
|
|
10389
|
-
loadedFonts.add(fontFamily);
|
|
10390
|
-
return;
|
|
10391
|
-
}
|
|
10392
10387
|
const encoded = encodeURIComponent(fontFamily);
|
|
10393
10388
|
const url = `https://fonts.googleapis.com/css?family=${encoded}:300,400,500,600,700&display=swap`;
|
|
10394
10389
|
const link = document.createElement("link");
|
|
@@ -10696,7 +10691,8 @@ class PixldocsRenderer {
|
|
|
10696
10691
|
// ─── Internal: render a page using the full PreviewCanvas engine ───
|
|
10697
10692
|
/**
|
|
10698
10693
|
* Wait until every image on the Fabric canvas inside the container has loaded.
|
|
10699
|
-
*
|
|
10694
|
+
* Checks both DOM <img> elements AND Fabric canvas image objects to ensure
|
|
10695
|
+
* all async assets are fully painted before capture.
|
|
10700
10696
|
*/
|
|
10701
10697
|
waitForCanvasImages(container, maxWaitMs = 15e3, pollMs = 200) {
|
|
10702
10698
|
return new Promise((resolve) => {
|
|
@@ -10707,6 +10703,29 @@ class PixldocsRenderer {
|
|
|
10707
10703
|
images.forEach((img) => {
|
|
10708
10704
|
if (!img.complete) allLoaded = false;
|
|
10709
10705
|
});
|
|
10706
|
+
if (allLoaded) {
|
|
10707
|
+
const canvasEl = container.querySelector("canvas.lower-canvas, canvas");
|
|
10708
|
+
const fabricCanvas = canvasEl && canvasEl.__fabric;
|
|
10709
|
+
if (fabricCanvas && typeof fabricCanvas.getObjects === "function") {
|
|
10710
|
+
for (const obj of fabricCanvas.getObjects()) {
|
|
10711
|
+
const el = obj._element || obj._originalElement;
|
|
10712
|
+
if (el instanceof HTMLImageElement && !el.complete) {
|
|
10713
|
+
allLoaded = false;
|
|
10714
|
+
break;
|
|
10715
|
+
}
|
|
10716
|
+
if (obj._objects) {
|
|
10717
|
+
for (const child of obj._objects) {
|
|
10718
|
+
const childEl = child._element || child._originalElement;
|
|
10719
|
+
if (childEl instanceof HTMLImageElement && !childEl.complete) {
|
|
10720
|
+
allLoaded = false;
|
|
10721
|
+
break;
|
|
10722
|
+
}
|
|
10723
|
+
}
|
|
10724
|
+
if (!allLoaded) break;
|
|
10725
|
+
}
|
|
10726
|
+
}
|
|
10727
|
+
}
|
|
10728
|
+
}
|
|
10710
10729
|
if (allLoaded || Date.now() - start > maxWaitMs) {
|
|
10711
10730
|
requestAnimationFrame(() => setTimeout(resolve, 400));
|
|
10712
10731
|
return;
|