@pixldocs/canvas-renderer 0.5.170 → 0.5.171
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-CtWVrKc-.cjs → index-BgOzEKmN.cjs} +46 -13
- package/dist/{index-CtWVrKc-.cjs.map → index-BgOzEKmN.cjs.map} +1 -1
- package/dist/{index-BvYxWljO.js → index-Cq9sQGri.js} +46 -13
- package/dist/{index-BvYxWljO.js.map → index-Cq9sQGri.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-BD0zlq42.js → vectorPdfExport--EtCdnlG.js} +4 -4
- package/dist/{vectorPdfExport-BD0zlq42.js.map → vectorPdfExport--EtCdnlG.js.map} +1 -1
- package/dist/{vectorPdfExport-BnFtIh0l.cjs → vectorPdfExport-BrwXcGkA.cjs} +4 -4
- package/dist/{vectorPdfExport-BnFtIh0l.cjs.map → vectorPdfExport-BrwXcGkA.cjs.map} +1 -1
- package/package.json +1 -1
|
@@ -16117,9 +16117,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16117
16117
|
}
|
|
16118
16118
|
return svgString;
|
|
16119
16119
|
}
|
|
16120
|
-
const resolvedPackageVersion = "0.5.
|
|
16120
|
+
const resolvedPackageVersion = "0.5.171";
|
|
16121
16121
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16122
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16122
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.171";
|
|
16123
16123
|
const roundParityValue = (value) => {
|
|
16124
16124
|
if (typeof value !== "number") return value;
|
|
16125
16125
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16617,7 +16617,7 @@ class PixldocsRenderer {
|
|
|
16617
16617
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16618
16618
|
}
|
|
16619
16619
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16620
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport
|
|
16620
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport--EtCdnlG.js");
|
|
16621
16621
|
const prepared = preparePagesForExport(
|
|
16622
16622
|
cloned.pages,
|
|
16623
16623
|
canvasWidth,
|
|
@@ -16637,28 +16637,46 @@ class PixldocsRenderer {
|
|
|
16637
16637
|
}
|
|
16638
16638
|
}
|
|
16639
16639
|
getExpectedImageCount(config, pageIndex) {
|
|
16640
|
+
return this.getExpectedImageIds(config, pageIndex).length;
|
|
16641
|
+
}
|
|
16642
|
+
/**
|
|
16643
|
+
* Collects ids of nodes that the renderer expects to produce a renderable
|
|
16644
|
+
* fabric image. Excludes SVG sources because those are loaded as Groups,
|
|
16645
|
+
* not HTMLImageElement-backed Images, and would otherwise inflate the
|
|
16646
|
+
* `expected` counter forever.
|
|
16647
|
+
*/
|
|
16648
|
+
getExpectedImageIds(config, pageIndex) {
|
|
16640
16649
|
const page = config.pages[pageIndex];
|
|
16641
|
-
if (!(page == null ? void 0 : page.children)) return
|
|
16642
|
-
|
|
16650
|
+
if (!(page == null ? void 0 : page.children)) return [];
|
|
16651
|
+
const ids = [];
|
|
16652
|
+
const isSvgUrl = (u) => /\.svg(\?|#|$)/i.test(u) || u.startsWith("data:image/svg");
|
|
16643
16653
|
const walk = (nodes) => {
|
|
16644
16654
|
for (const node of nodes) {
|
|
16645
16655
|
if (!node || node.visible === false) continue;
|
|
16646
16656
|
const src = typeof node.src === "string" ? node.src.trim() : "";
|
|
16647
16657
|
const imageUrl = typeof node.imageUrl === "string" ? node.imageUrl.trim() : "";
|
|
16648
|
-
|
|
16658
|
+
const url = src || imageUrl;
|
|
16659
|
+
if (node.type === "image" && url && !isSvgUrl(url) && node.id) {
|
|
16660
|
+
ids.push(String(node.id));
|
|
16661
|
+
}
|
|
16649
16662
|
if (Array.isArray(node.children) && node.children.length > 0) {
|
|
16650
16663
|
walk(node.children);
|
|
16651
16664
|
}
|
|
16652
16665
|
}
|
|
16653
16666
|
};
|
|
16654
16667
|
walk(page.children);
|
|
16655
|
-
return
|
|
16668
|
+
return ids;
|
|
16656
16669
|
}
|
|
16657
|
-
waitForCanvasImages(container, expectedImageCount, maxWaitMs
|
|
16670
|
+
waitForCanvasImages(container, expectedImageCount, maxWaitMs, pollMs = 120) {
|
|
16671
|
+
const timeout = Math.max(500, maxWaitMs ?? this.config.assetWaitTimeoutMs ?? 15e3);
|
|
16672
|
+
const earlyExitMs = Math.max(250, this.config.assetWaitEarlyExitMs ?? 1500);
|
|
16673
|
+
const debug = !!this.config.debug;
|
|
16658
16674
|
return new Promise((resolve) => {
|
|
16659
16675
|
const start = Date.now();
|
|
16660
16676
|
let stableFrames = 0;
|
|
16661
16677
|
let lastSummary = "";
|
|
16678
|
+
let lastActual = -1;
|
|
16679
|
+
let lastProgressAt = Date.now();
|
|
16662
16680
|
const isRenderableImage = (value) => value instanceof HTMLImageElement && value.complete && value.naturalWidth > 0 && value.naturalHeight > 0;
|
|
16663
16681
|
const collectRenderableImages = (obj, seen) => {
|
|
16664
16682
|
if (!obj || typeof obj !== "object") return;
|
|
@@ -16722,19 +16740,34 @@ class PixldocsRenderer {
|
|
|
16722
16740
|
const summary = `expected=${expectedImageCount} actual=${actualImageCount} dom=${domImages.length} fabricReady=${fabricReady} domReady=${allDomLoaded} canvasReady=${canvasReady}`;
|
|
16723
16741
|
if (summary !== lastSummary) {
|
|
16724
16742
|
lastSummary = summary;
|
|
16725
|
-
console.log(`[canvas-renderer][asset-wait] ${summary}`);
|
|
16743
|
+
if (debug) console.log(`[canvas-renderer][asset-wait] ${summary}`);
|
|
16744
|
+
}
|
|
16745
|
+
if (actualImageCount !== lastActual) {
|
|
16746
|
+
lastActual = actualImageCount;
|
|
16747
|
+
lastProgressAt = Date.now();
|
|
16726
16748
|
}
|
|
16727
16749
|
if (ready) {
|
|
16728
16750
|
stableFrames += 1;
|
|
16729
16751
|
if (stableFrames >= 2) {
|
|
16730
|
-
console.log(`[canvas-renderer][asset-wait] ready after ${elapsed}ms (${summary})`);
|
|
16752
|
+
if (debug) console.log(`[canvas-renderer][asset-wait] ready after ${elapsed}ms (${summary})`);
|
|
16731
16753
|
settle();
|
|
16732
16754
|
return;
|
|
16733
16755
|
}
|
|
16734
16756
|
} else {
|
|
16735
16757
|
stableFrames = 0;
|
|
16736
16758
|
}
|
|
16737
|
-
|
|
16759
|
+
const sceneSettled = fabricReady && allDomLoaded && canvasReady && fabricObjects.length > 0;
|
|
16760
|
+
const idleFor = Date.now() - lastProgressAt;
|
|
16761
|
+
if (sceneSettled && actualImageCount < expectedImageCount && idleFor >= earlyExitMs) {
|
|
16762
|
+
if (debug) {
|
|
16763
|
+
console.log(
|
|
16764
|
+
`[canvas-renderer][asset-wait] early-exit after ${elapsed}ms (idle=${idleFor}ms, ${summary})`
|
|
16765
|
+
);
|
|
16766
|
+
}
|
|
16767
|
+
settle();
|
|
16768
|
+
return;
|
|
16769
|
+
}
|
|
16770
|
+
if (elapsed >= timeout) {
|
|
16738
16771
|
const fabricImageDebug = [];
|
|
16739
16772
|
for (const obj of fabricObjects) {
|
|
16740
16773
|
getImageDebugInfo(obj, fabricImageDebug);
|
|
@@ -18719,7 +18752,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18719
18752
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18720
18753
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18721
18754
|
try {
|
|
18722
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport
|
|
18755
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport--EtCdnlG.js");
|
|
18723
18756
|
try {
|
|
18724
18757
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18725
18758
|
} catch {
|
|
@@ -19121,4 +19154,4 @@ export {
|
|
|
19121
19154
|
collectFontDescriptorsFromConfig as y,
|
|
19122
19155
|
collectFontsFromConfig as z
|
|
19123
19156
|
};
|
|
19124
|
-
//# sourceMappingURL=index-
|
|
19157
|
+
//# sourceMappingURL=index-Cq9sQGri.js.map
|