@pixldocs/canvas-renderer 0.5.196 → 0.5.197
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-KqyAyv91.js → index-6bqq7X_L.js} +40 -11
- package/dist/{index-KqyAyv91.js.map → index-6bqq7X_L.js.map} +1 -1
- package/dist/{index-DQnFS9GV.cjs → index-dXQP21w2.cjs} +40 -11
- package/dist/{index-DQnFS9GV.cjs.map → index-dXQP21w2.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-BGlG4zN9.cjs → vectorPdfExport-CMSo382K.cjs} +4 -4
- package/dist/{vectorPdfExport-BGlG4zN9.cjs.map → vectorPdfExport-CMSo382K.cjs.map} +1 -1
- package/dist/{vectorPdfExport-BBQHeFKb.js → vectorPdfExport-D4pUlnXw.js} +4 -4
- package/dist/{vectorPdfExport-BBQHeFKb.js.map → vectorPdfExport-D4pUlnXw.js.map} +1 -1
- package/package.json +1 -1
|
@@ -16937,9 +16937,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16937
16937
|
}
|
|
16938
16938
|
return svgString;
|
|
16939
16939
|
}
|
|
16940
|
-
const resolvedPackageVersion = "0.5.
|
|
16940
|
+
const resolvedPackageVersion = "0.5.197";
|
|
16941
16941
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16942
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16942
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.197";
|
|
16943
16943
|
const roundParityValue = (value) => {
|
|
16944
16944
|
if (typeof value !== "number") return value;
|
|
16945
16945
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -17024,19 +17024,41 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
|
|
|
17024
17024
|
if (targets.length === 0) return 0;
|
|
17025
17025
|
const shrinkOne = async (dataUrl) => {
|
|
17026
17026
|
try {
|
|
17027
|
-
const
|
|
17027
|
+
const decode = async (src) => new Promise((resolve, reject) => {
|
|
17028
17028
|
const el = new Image();
|
|
17029
17029
|
el.onload = () => resolve(el);
|
|
17030
17030
|
el.onerror = (e) => reject(e);
|
|
17031
17031
|
el.decoding = "sync";
|
|
17032
|
-
el.src =
|
|
17032
|
+
el.src = src;
|
|
17033
17033
|
});
|
|
17034
|
+
let img;
|
|
17035
|
+
let blobUrl = null;
|
|
17036
|
+
try {
|
|
17037
|
+
img = await decode(dataUrl);
|
|
17038
|
+
} catch {
|
|
17039
|
+
try {
|
|
17040
|
+
const resp = await fetch(dataUrl);
|
|
17041
|
+
const blob = await resp.blob();
|
|
17042
|
+
blobUrl = URL.createObjectURL(blob);
|
|
17043
|
+
img = await decode(blobUrl);
|
|
17044
|
+
} catch (inner) {
|
|
17045
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17046
|
+
console.warn("[canvas-renderer] shrinkOne: failed to decode oversized data URL on this browser, dropping shrink attempt", inner);
|
|
17047
|
+
return null;
|
|
17048
|
+
}
|
|
17049
|
+
}
|
|
17034
17050
|
const w = img.naturalWidth, h = img.naturalHeight;
|
|
17035
|
-
if (!w || !h)
|
|
17051
|
+
if (!w || !h) {
|
|
17052
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17053
|
+
return null;
|
|
17054
|
+
}
|
|
17036
17055
|
const longest = Math.max(w, h);
|
|
17037
17056
|
const tooLargeByEdge = longest > maxEdgePx;
|
|
17038
17057
|
const tooLargeByBytes = estimateDataUrlBytes(dataUrl) > maxDataUrlBytes;
|
|
17039
|
-
if (!tooLargeByEdge && !tooLargeByBytes)
|
|
17058
|
+
if (!tooLargeByEdge && !tooLargeByBytes) {
|
|
17059
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17060
|
+
return null;
|
|
17061
|
+
}
|
|
17040
17062
|
let scale = tooLargeByEdge ? maxEdgePx / longest : 1;
|
|
17041
17063
|
let quality = 0.85;
|
|
17042
17064
|
let best = null;
|
|
@@ -17047,17 +17069,24 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
|
|
|
17047
17069
|
canvas.width = tw;
|
|
17048
17070
|
canvas.height = th;
|
|
17049
17071
|
const ctx = canvas.getContext("2d");
|
|
17050
|
-
if (!ctx)
|
|
17072
|
+
if (!ctx) {
|
|
17073
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17074
|
+
return best;
|
|
17075
|
+
}
|
|
17051
17076
|
ctx.fillStyle = "#ffffff";
|
|
17052
17077
|
ctx.fillRect(0, 0, tw, th);
|
|
17053
17078
|
ctx.drawImage(img, 0, 0, tw, th);
|
|
17054
17079
|
best = canvas.toDataURL("image/jpeg", quality);
|
|
17055
17080
|
const outBytes = estimateDataUrlBytes(best);
|
|
17056
|
-
if (outBytes <= maxDataUrlBytes || attempt === 3)
|
|
17081
|
+
if (outBytes <= maxDataUrlBytes || attempt === 3) {
|
|
17082
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17083
|
+
return best;
|
|
17084
|
+
}
|
|
17057
17085
|
const byteScale = Math.sqrt(maxDataUrlBytes / Math.max(1, outBytes)) * 0.92;
|
|
17058
17086
|
scale = Math.max(0.1, scale * Math.min(0.95, byteScale));
|
|
17059
17087
|
quality = Math.max(0.68, quality - 0.06);
|
|
17060
17088
|
}
|
|
17089
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17061
17090
|
return best;
|
|
17062
17091
|
} catch {
|
|
17063
17092
|
return null;
|
|
@@ -17586,7 +17615,7 @@ class PixldocsRenderer {
|
|
|
17586
17615
|
await this.waitForCanvasScene(container, cloned, i);
|
|
17587
17616
|
}
|
|
17588
17617
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
17589
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
17618
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CMSo382K.cjs"));
|
|
17590
17619
|
const prepared = preparePagesForExport(
|
|
17591
17620
|
cloned.pages,
|
|
17592
17621
|
canvasWidth,
|
|
@@ -19783,7 +19812,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
19783
19812
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
19784
19813
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
19785
19814
|
try {
|
|
19786
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
19815
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CMSo382K.cjs"));
|
|
19787
19816
|
try {
|
|
19788
19817
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
19789
19818
|
} catch {
|
|
@@ -20180,4 +20209,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
20180
20209
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
20181
20210
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
20182
20211
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
20183
|
-
//# sourceMappingURL=index-
|
|
20212
|
+
//# sourceMappingURL=index-dXQP21w2.cjs.map
|