@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
|
@@ -16135,9 +16135,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16135
16135
|
}
|
|
16136
16136
|
return svgString;
|
|
16137
16137
|
}
|
|
16138
|
-
const resolvedPackageVersion = "0.5.
|
|
16138
|
+
const resolvedPackageVersion = "0.5.171";
|
|
16139
16139
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16140
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16140
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.171";
|
|
16141
16141
|
const roundParityValue = (value) => {
|
|
16142
16142
|
if (typeof value !== "number") return value;
|
|
16143
16143
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16635,7 +16635,7 @@ class PixldocsRenderer {
|
|
|
16635
16635
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16636
16636
|
}
|
|
16637
16637
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16638
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
16638
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BrwXcGkA.cjs"));
|
|
16639
16639
|
const prepared = preparePagesForExport(
|
|
16640
16640
|
cloned.pages,
|
|
16641
16641
|
canvasWidth,
|
|
@@ -16655,28 +16655,46 @@ class PixldocsRenderer {
|
|
|
16655
16655
|
}
|
|
16656
16656
|
}
|
|
16657
16657
|
getExpectedImageCount(config, pageIndex) {
|
|
16658
|
+
return this.getExpectedImageIds(config, pageIndex).length;
|
|
16659
|
+
}
|
|
16660
|
+
/**
|
|
16661
|
+
* Collects ids of nodes that the renderer expects to produce a renderable
|
|
16662
|
+
* fabric image. Excludes SVG sources because those are loaded as Groups,
|
|
16663
|
+
* not HTMLImageElement-backed Images, and would otherwise inflate the
|
|
16664
|
+
* `expected` counter forever.
|
|
16665
|
+
*/
|
|
16666
|
+
getExpectedImageIds(config, pageIndex) {
|
|
16658
16667
|
const page = config.pages[pageIndex];
|
|
16659
|
-
if (!(page == null ? void 0 : page.children)) return
|
|
16660
|
-
|
|
16668
|
+
if (!(page == null ? void 0 : page.children)) return [];
|
|
16669
|
+
const ids = [];
|
|
16670
|
+
const isSvgUrl = (u) => /\.svg(\?|#|$)/i.test(u) || u.startsWith("data:image/svg");
|
|
16661
16671
|
const walk = (nodes) => {
|
|
16662
16672
|
for (const node of nodes) {
|
|
16663
16673
|
if (!node || node.visible === false) continue;
|
|
16664
16674
|
const src = typeof node.src === "string" ? node.src.trim() : "";
|
|
16665
16675
|
const imageUrl = typeof node.imageUrl === "string" ? node.imageUrl.trim() : "";
|
|
16666
|
-
|
|
16676
|
+
const url = src || imageUrl;
|
|
16677
|
+
if (node.type === "image" && url && !isSvgUrl(url) && node.id) {
|
|
16678
|
+
ids.push(String(node.id));
|
|
16679
|
+
}
|
|
16667
16680
|
if (Array.isArray(node.children) && node.children.length > 0) {
|
|
16668
16681
|
walk(node.children);
|
|
16669
16682
|
}
|
|
16670
16683
|
}
|
|
16671
16684
|
};
|
|
16672
16685
|
walk(page.children);
|
|
16673
|
-
return
|
|
16686
|
+
return ids;
|
|
16674
16687
|
}
|
|
16675
|
-
waitForCanvasImages(container, expectedImageCount, maxWaitMs
|
|
16688
|
+
waitForCanvasImages(container, expectedImageCount, maxWaitMs, pollMs = 120) {
|
|
16689
|
+
const timeout = Math.max(500, maxWaitMs ?? this.config.assetWaitTimeoutMs ?? 15e3);
|
|
16690
|
+
const earlyExitMs = Math.max(250, this.config.assetWaitEarlyExitMs ?? 1500);
|
|
16691
|
+
const debug = !!this.config.debug;
|
|
16676
16692
|
return new Promise((resolve) => {
|
|
16677
16693
|
const start = Date.now();
|
|
16678
16694
|
let stableFrames = 0;
|
|
16679
16695
|
let lastSummary = "";
|
|
16696
|
+
let lastActual = -1;
|
|
16697
|
+
let lastProgressAt = Date.now();
|
|
16680
16698
|
const isRenderableImage = (value) => value instanceof HTMLImageElement && value.complete && value.naturalWidth > 0 && value.naturalHeight > 0;
|
|
16681
16699
|
const collectRenderableImages = (obj, seen) => {
|
|
16682
16700
|
if (!obj || typeof obj !== "object") return;
|
|
@@ -16740,19 +16758,34 @@ class PixldocsRenderer {
|
|
|
16740
16758
|
const summary = `expected=${expectedImageCount} actual=${actualImageCount} dom=${domImages.length} fabricReady=${fabricReady} domReady=${allDomLoaded} canvasReady=${canvasReady}`;
|
|
16741
16759
|
if (summary !== lastSummary) {
|
|
16742
16760
|
lastSummary = summary;
|
|
16743
|
-
console.log(`[canvas-renderer][asset-wait] ${summary}`);
|
|
16761
|
+
if (debug) console.log(`[canvas-renderer][asset-wait] ${summary}`);
|
|
16762
|
+
}
|
|
16763
|
+
if (actualImageCount !== lastActual) {
|
|
16764
|
+
lastActual = actualImageCount;
|
|
16765
|
+
lastProgressAt = Date.now();
|
|
16744
16766
|
}
|
|
16745
16767
|
if (ready) {
|
|
16746
16768
|
stableFrames += 1;
|
|
16747
16769
|
if (stableFrames >= 2) {
|
|
16748
|
-
console.log(`[canvas-renderer][asset-wait] ready after ${elapsed}ms (${summary})`);
|
|
16770
|
+
if (debug) console.log(`[canvas-renderer][asset-wait] ready after ${elapsed}ms (${summary})`);
|
|
16749
16771
|
settle();
|
|
16750
16772
|
return;
|
|
16751
16773
|
}
|
|
16752
16774
|
} else {
|
|
16753
16775
|
stableFrames = 0;
|
|
16754
16776
|
}
|
|
16755
|
-
|
|
16777
|
+
const sceneSettled = fabricReady && allDomLoaded && canvasReady && fabricObjects.length > 0;
|
|
16778
|
+
const idleFor = Date.now() - lastProgressAt;
|
|
16779
|
+
if (sceneSettled && actualImageCount < expectedImageCount && idleFor >= earlyExitMs) {
|
|
16780
|
+
if (debug) {
|
|
16781
|
+
console.log(
|
|
16782
|
+
`[canvas-renderer][asset-wait] early-exit after ${elapsed}ms (idle=${idleFor}ms, ${summary})`
|
|
16783
|
+
);
|
|
16784
|
+
}
|
|
16785
|
+
settle();
|
|
16786
|
+
return;
|
|
16787
|
+
}
|
|
16788
|
+
if (elapsed >= timeout) {
|
|
16756
16789
|
const fabricImageDebug = [];
|
|
16757
16790
|
for (const obj of fabricObjects) {
|
|
16758
16791
|
getImageDebugInfo(obj, fabricImageDebug);
|
|
@@ -18737,7 +18770,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18737
18770
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18738
18771
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18739
18772
|
try {
|
|
18740
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
18773
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BrwXcGkA.cjs"));
|
|
18741
18774
|
try {
|
|
18742
18775
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18743
18776
|
} catch {
|
|
@@ -19136,4 +19169,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
19136
19169
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
19137
19170
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
19138
19171
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
19139
|
-
//# sourceMappingURL=index-
|
|
19172
|
+
//# sourceMappingURL=index-BgOzEKmN.cjs.map
|