@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
|
@@ -3445,7 +3445,9 @@ function preloadImage(url) {
|
|
|
3445
3445
|
if (cached) return Promise.resolve(cached);
|
|
3446
3446
|
return new Promise((resolve, reject) => {
|
|
3447
3447
|
const img = new Image();
|
|
3448
|
-
|
|
3448
|
+
if (!url.startsWith("data:") && !url.startsWith("blob:")) {
|
|
3449
|
+
img.crossOrigin = "anonymous";
|
|
3450
|
+
}
|
|
3449
3451
|
img.onload = () => {
|
|
3450
3452
|
htmlImageCache.set(url, img);
|
|
3451
3453
|
trimCache(htmlImageCache);
|
|
@@ -3671,7 +3673,6 @@ function loadPlaceholderTile() {
|
|
|
3671
3673
|
if (placeholderTilePromise) return placeholderTilePromise;
|
|
3672
3674
|
placeholderTilePromise = new Promise((resolve, reject) => {
|
|
3673
3675
|
const img = new Image();
|
|
3674
|
-
img.crossOrigin = "anonymous";
|
|
3675
3676
|
img.onload = () => {
|
|
3676
3677
|
placeholderTileImage = img;
|
|
3677
3678
|
resolve(img);
|
|
@@ -3909,7 +3910,8 @@ async function loadImageAsync(element, placeholder, fc, fabricRef, syncLockedRef
|
|
|
3909
3910
|
resolvedUrl: url.slice(0, 240),
|
|
3910
3911
|
usedProxy: !url.startsWith("data:") && !url.startsWith("blob:") && url !== imageUrl
|
|
3911
3912
|
});
|
|
3912
|
-
const
|
|
3913
|
+
const imgLoadOptions = url.startsWith("data:") || url.startsWith("blob:") ? {} : { crossOrigin: "anonymous" };
|
|
3914
|
+
const img = await fabric__namespace.FabricImage.fromURL(url, imgLoadOptions);
|
|
3913
3915
|
if (!fabricRef.current) return;
|
|
3914
3916
|
await normalizeSvgImageDimensions(img, imageUrl, element.sourceFormat);
|
|
3915
3917
|
const isHidden = !element.visible;
|
|
@@ -16937,9 +16939,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16937
16939
|
}
|
|
16938
16940
|
return svgString;
|
|
16939
16941
|
}
|
|
16940
|
-
const resolvedPackageVersion = "0.5.
|
|
16942
|
+
const resolvedPackageVersion = "0.5.198";
|
|
16941
16943
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16942
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16944
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.198";
|
|
16943
16945
|
const roundParityValue = (value) => {
|
|
16944
16946
|
if (typeof value !== "number") return value;
|
|
16945
16947
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -17024,19 +17026,44 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
|
|
|
17024
17026
|
if (targets.length === 0) return 0;
|
|
17025
17027
|
const shrinkOne = async (dataUrl) => {
|
|
17026
17028
|
try {
|
|
17027
|
-
const
|
|
17029
|
+
const decode = async (src) => new Promise((resolve, reject) => {
|
|
17028
17030
|
const el = new Image();
|
|
17031
|
+
if (!src.startsWith("data:") && !src.startsWith("blob:")) {
|
|
17032
|
+
el.crossOrigin = "anonymous";
|
|
17033
|
+
}
|
|
17029
17034
|
el.onload = () => resolve(el);
|
|
17030
17035
|
el.onerror = (e) => reject(e);
|
|
17031
17036
|
el.decoding = "sync";
|
|
17032
|
-
el.src =
|
|
17037
|
+
el.src = src;
|
|
17033
17038
|
});
|
|
17039
|
+
let img;
|
|
17040
|
+
let blobUrl = null;
|
|
17041
|
+
try {
|
|
17042
|
+
img = await decode(dataUrl);
|
|
17043
|
+
} catch {
|
|
17044
|
+
try {
|
|
17045
|
+
const resp = await fetch(dataUrl);
|
|
17046
|
+
const blob = await resp.blob();
|
|
17047
|
+
blobUrl = URL.createObjectURL(blob);
|
|
17048
|
+
img = await decode(blobUrl);
|
|
17049
|
+
} catch (inner) {
|
|
17050
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17051
|
+
console.warn("[canvas-renderer] shrinkOne: failed to decode oversized data URL on this browser, dropping shrink attempt", inner);
|
|
17052
|
+
return null;
|
|
17053
|
+
}
|
|
17054
|
+
}
|
|
17034
17055
|
const w = img.naturalWidth, h = img.naturalHeight;
|
|
17035
|
-
if (!w || !h)
|
|
17056
|
+
if (!w || !h) {
|
|
17057
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17058
|
+
return null;
|
|
17059
|
+
}
|
|
17036
17060
|
const longest = Math.max(w, h);
|
|
17037
17061
|
const tooLargeByEdge = longest > maxEdgePx;
|
|
17038
17062
|
const tooLargeByBytes = estimateDataUrlBytes(dataUrl) > maxDataUrlBytes;
|
|
17039
|
-
if (!tooLargeByEdge && !tooLargeByBytes)
|
|
17063
|
+
if (!tooLargeByEdge && !tooLargeByBytes) {
|
|
17064
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17065
|
+
return null;
|
|
17066
|
+
}
|
|
17040
17067
|
let scale = tooLargeByEdge ? maxEdgePx / longest : 1;
|
|
17041
17068
|
let quality = 0.85;
|
|
17042
17069
|
let best = null;
|
|
@@ -17047,17 +17074,24 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
|
|
|
17047
17074
|
canvas.width = tw;
|
|
17048
17075
|
canvas.height = th;
|
|
17049
17076
|
const ctx = canvas.getContext("2d");
|
|
17050
|
-
if (!ctx)
|
|
17077
|
+
if (!ctx) {
|
|
17078
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17079
|
+
return best;
|
|
17080
|
+
}
|
|
17051
17081
|
ctx.fillStyle = "#ffffff";
|
|
17052
17082
|
ctx.fillRect(0, 0, tw, th);
|
|
17053
17083
|
ctx.drawImage(img, 0, 0, tw, th);
|
|
17054
17084
|
best = canvas.toDataURL("image/jpeg", quality);
|
|
17055
17085
|
const outBytes = estimateDataUrlBytes(best);
|
|
17056
|
-
if (outBytes <= maxDataUrlBytes || attempt === 3)
|
|
17086
|
+
if (outBytes <= maxDataUrlBytes || attempt === 3) {
|
|
17087
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17088
|
+
return best;
|
|
17089
|
+
}
|
|
17057
17090
|
const byteScale = Math.sqrt(maxDataUrlBytes / Math.max(1, outBytes)) * 0.92;
|
|
17058
17091
|
scale = Math.max(0.1, scale * Math.min(0.95, byteScale));
|
|
17059
17092
|
quality = Math.max(0.68, quality - 0.06);
|
|
17060
17093
|
}
|
|
17094
|
+
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
17061
17095
|
return best;
|
|
17062
17096
|
} catch {
|
|
17063
17097
|
return null;
|
|
@@ -17586,7 +17620,7 @@ class PixldocsRenderer {
|
|
|
17586
17620
|
await this.waitForCanvasScene(container, cloned, i);
|
|
17587
17621
|
}
|
|
17588
17622
|
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-
|
|
17623
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CBUSNaeP.cjs"));
|
|
17590
17624
|
const prepared = preparePagesForExport(
|
|
17591
17625
|
cloned.pages,
|
|
17592
17626
|
canvasWidth,
|
|
@@ -19783,7 +19817,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
19783
19817
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
19784
19818
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
19785
19819
|
try {
|
|
19786
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
19820
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CBUSNaeP.cjs"));
|
|
19787
19821
|
try {
|
|
19788
19822
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
19789
19823
|
} catch {
|
|
@@ -20180,4 +20214,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
20180
20214
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
20181
20215
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
20182
20216
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
20183
|
-
//# sourceMappingURL=index-
|
|
20217
|
+
//# sourceMappingURL=index-CM6Bzcyx.cjs.map
|