@pixldocs/canvas-renderer 0.5.196 → 0.5.198
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-DQnFS9GV.cjs → index-CM6Bzcyx.cjs} +48 -14
- package/dist/index-CM6Bzcyx.cjs.map +1 -0
- package/dist/{index-KqyAyv91.js → index-Cgi6Y_WS.js} +48 -14
- package/dist/index-Cgi6Y_WS.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-BGlG4zN9.cjs → vectorPdfExport-CBUSNaeP.cjs} +4 -4
- package/dist/{vectorPdfExport-BGlG4zN9.cjs.map → vectorPdfExport-CBUSNaeP.cjs.map} +1 -1
- package/dist/{vectorPdfExport-BBQHeFKb.js → vectorPdfExport-xj7xRXH7.js} +4 -4
- package/dist/{vectorPdfExport-BBQHeFKb.js.map → vectorPdfExport-xj7xRXH7.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-DQnFS9GV.cjs.map +0 -1
- package/dist/index-KqyAyv91.js.map +0 -1
|
@@ -3427,7 +3427,9 @@ function preloadImage(url) {
|
|
|
3427
3427
|
if (cached) return Promise.resolve(cached);
|
|
3428
3428
|
return new Promise((resolve, reject) => {
|
|
3429
3429
|
const img = new Image();
|
|
3430
|
-
|
|
3430
|
+
if (!url.startsWith("data:") && !url.startsWith("blob:")) {
|
|
3431
|
+
img.crossOrigin = "anonymous";
|
|
3432
|
+
}
|
|
3431
3433
|
img.onload = () => {
|
|
3432
3434
|
htmlImageCache.set(url, img);
|
|
3433
3435
|
trimCache(htmlImageCache);
|
|
@@ -3653,7 +3655,6 @@ function loadPlaceholderTile() {
|
|
|
3653
3655
|
if (placeholderTilePromise) return placeholderTilePromise;
|
|
3654
3656
|
placeholderTilePromise = new Promise((resolve, reject) => {
|
|
3655
3657
|
const img = new Image();
|
|
3656
|
-
img.crossOrigin = "anonymous";
|
|
3657
3658
|
img.onload = () => {
|
|
3658
3659
|
placeholderTileImage = img;
|
|
3659
3660
|
resolve(img);
|
|
@@ -3891,7 +3892,8 @@ async function loadImageAsync(element, placeholder, fc, fabricRef, syncLockedRef
|
|
|
3891
3892
|
resolvedUrl: url.slice(0, 240),
|
|
3892
3893
|
usedProxy: !url.startsWith("data:") && !url.startsWith("blob:") && url !== imageUrl
|
|
3893
3894
|
});
|
|
3894
|
-
const
|
|
3895
|
+
const imgLoadOptions = url.startsWith("data:") || url.startsWith("blob:") ? {} : { crossOrigin: "anonymous" };
|
|
3896
|
+
const img = await fabric.FabricImage.fromURL(url, imgLoadOptions);
|
|
3895
3897
|
if (!fabricRef.current) return;
|
|
3896
3898
|
await normalizeSvgImageDimensions(img, imageUrl, element.sourceFormat);
|
|
3897
3899
|
const isHidden = !element.visible;
|
|
@@ -16919,9 +16921,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16919
16921
|
}
|
|
16920
16922
|
return svgString;
|
|
16921
16923
|
}
|
|
16922
|
-
const resolvedPackageVersion = "0.5.
|
|
16924
|
+
const resolvedPackageVersion = "0.5.198";
|
|
16923
16925
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16924
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16926
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.198";
|
|
16925
16927
|
const roundParityValue = (value) => {
|
|
16926
16928
|
if (typeof value !== "number") return value;
|
|
16927
16929
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -17006,19 +17008,44 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
|
|
|
17006
17008
|
if (targets.length === 0) return 0;
|
|
17007
17009
|
const shrinkOne = async (dataUrl) => {
|
|
17008
17010
|
try {
|
|
17009
|
-
const
|
|
17011
|
+
const decode = async (src) => new Promise((resolve, reject) => {
|
|
17010
17012
|
const el = new Image();
|
|
17013
|
+
if (!src.startsWith("data:") && !src.startsWith("blob:")) {
|
|
17014
|
+
el.crossOrigin = "anonymous";
|
|
17015
|
+
}
|
|
17011
17016
|
el.onload = () => resolve(el);
|
|
17012
17017
|
el.onerror = (e) => reject(e);
|
|
17013
17018
|
el.decoding = "sync";
|
|
17014
|
-
el.src =
|
|
17019
|
+
el.src = src;
|
|
17015
17020
|
});
|
|
17021
|
+
let img;
|
|
17022
|
+
let blobUrl = null;
|
|
17023
|
+
try {
|
|
17024
|
+
img = await decode(dataUrl);
|
|
17025
|
+
} catch {
|
|
17026
|
+
try {
|
|
17027
|
+
const resp = await fetch(dataUrl);
|
|
17028
|
+
const blob = await resp.blob();
|
|
17029
|
+
blobUrl = URL.createObjectURL(blob);
|
|
17030
|
+
img = await decode(blobUrl);
|
|
17031
|
+
} catch (inner) {
|
|
17032
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17033
|
+
console.warn("[canvas-renderer] shrinkOne: failed to decode oversized data URL on this browser, dropping shrink attempt", inner);
|
|
17034
|
+
return null;
|
|
17035
|
+
}
|
|
17036
|
+
}
|
|
17016
17037
|
const w = img.naturalWidth, h = img.naturalHeight;
|
|
17017
|
-
if (!w || !h)
|
|
17038
|
+
if (!w || !h) {
|
|
17039
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17040
|
+
return null;
|
|
17041
|
+
}
|
|
17018
17042
|
const longest = Math.max(w, h);
|
|
17019
17043
|
const tooLargeByEdge = longest > maxEdgePx;
|
|
17020
17044
|
const tooLargeByBytes = estimateDataUrlBytes(dataUrl) > maxDataUrlBytes;
|
|
17021
|
-
if (!tooLargeByEdge && !tooLargeByBytes)
|
|
17045
|
+
if (!tooLargeByEdge && !tooLargeByBytes) {
|
|
17046
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17047
|
+
return null;
|
|
17048
|
+
}
|
|
17022
17049
|
let scale = tooLargeByEdge ? maxEdgePx / longest : 1;
|
|
17023
17050
|
let quality = 0.85;
|
|
17024
17051
|
let best = null;
|
|
@@ -17029,17 +17056,24 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
|
|
|
17029
17056
|
canvas.width = tw;
|
|
17030
17057
|
canvas.height = th;
|
|
17031
17058
|
const ctx = canvas.getContext("2d");
|
|
17032
|
-
if (!ctx)
|
|
17059
|
+
if (!ctx) {
|
|
17060
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17061
|
+
return best;
|
|
17062
|
+
}
|
|
17033
17063
|
ctx.fillStyle = "#ffffff";
|
|
17034
17064
|
ctx.fillRect(0, 0, tw, th);
|
|
17035
17065
|
ctx.drawImage(img, 0, 0, tw, th);
|
|
17036
17066
|
best = canvas.toDataURL("image/jpeg", quality);
|
|
17037
17067
|
const outBytes = estimateDataUrlBytes(best);
|
|
17038
|
-
if (outBytes <= maxDataUrlBytes || attempt === 3)
|
|
17068
|
+
if (outBytes <= maxDataUrlBytes || attempt === 3) {
|
|
17069
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17070
|
+
return best;
|
|
17071
|
+
}
|
|
17039
17072
|
const byteScale = Math.sqrt(maxDataUrlBytes / Math.max(1, outBytes)) * 0.92;
|
|
17040
17073
|
scale = Math.max(0.1, scale * Math.min(0.95, byteScale));
|
|
17041
17074
|
quality = Math.max(0.68, quality - 0.06);
|
|
17042
17075
|
}
|
|
17076
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17043
17077
|
return best;
|
|
17044
17078
|
} catch {
|
|
17045
17079
|
return null;
|
|
@@ -17568,7 +17602,7 @@ class PixldocsRenderer {
|
|
|
17568
17602
|
await this.waitForCanvasScene(container, cloned, i);
|
|
17569
17603
|
}
|
|
17570
17604
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
17571
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
17605
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-xj7xRXH7.js");
|
|
17572
17606
|
const prepared = preparePagesForExport(
|
|
17573
17607
|
cloned.pages,
|
|
17574
17608
|
canvasWidth,
|
|
@@ -19765,7 +19799,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
19765
19799
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
19766
19800
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
19767
19801
|
try {
|
|
19768
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
19802
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-xj7xRXH7.js");
|
|
19769
19803
|
try {
|
|
19770
19804
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
19771
19805
|
} catch {
|
|
@@ -20165,4 +20199,4 @@ export {
|
|
|
20165
20199
|
buildTeaserBlurFlatKeys as y,
|
|
20166
20200
|
collectFontDescriptorsFromConfig as z
|
|
20167
20201
|
};
|
|
20168
|
-
//# sourceMappingURL=index-
|
|
20202
|
+
//# sourceMappingURL=index-Cgi6Y_WS.js.map
|