@pixldocs/canvas-renderer 0.5.494 → 0.5.496
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-CCMdTuIr.cjs → index-CZtvER5z.cjs} +8677 -1031
- package/dist/index-CZtvER5z.cjs.map +1 -0
- package/dist/{index-dxfsI5E1.js → index-CiSoT2Lk.js} +8719 -1073
- package/dist/index-CiSoT2Lk.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +41 -41
- package/dist/{pdfFonts-DhEaMTZl.js → pdfFonts-B_rPB0OF.js} +3 -1
- package/dist/pdfFonts-B_rPB0OF.js.map +1 -0
- package/dist/{pdfFonts-BTj2f465.cjs → pdfFonts-CySSLV-P.cjs} +3 -1
- package/dist/pdfFonts-CySSLV-P.cjs.map +1 -0
- package/dist/{svgTextToPath-BT7lcwLT.cjs → svgTextToPath-Bzd3FsHH.cjs} +2 -2
- package/dist/{svgTextToPath-BT7lcwLT.cjs.map → svgTextToPath-Bzd3FsHH.cjs.map} +1 -1
- package/dist/{svgTextToPath-Bw974R9h.js → svgTextToPath-RmE-6Dbn.js} +2 -2
- package/dist/{svgTextToPath-Bw974R9h.js.map → svgTextToPath-RmE-6Dbn.js.map} +1 -1
- package/dist/{vectorPdfExport-BkAhiIFX.cjs → vectorPdfExport-B2KtFs76.cjs} +32 -19
- package/dist/vectorPdfExport-B2KtFs76.cjs.map +1 -0
- package/dist/{vectorPdfExport-Bazeq3bN.js → vectorPdfExport-E3x8GBto.js} +32 -19
- package/dist/vectorPdfExport-E3x8GBto.js.map +1 -0
- package/package.json +2 -1
- package/dist/index-CCMdTuIr.cjs.map +0 -1
- package/dist/index-dxfsI5E1.js.map +0 -1
- package/dist/pdfFonts-BTj2f465.cjs.map +0 -1
- package/dist/pdfFonts-DhEaMTZl.js.map +0 -1
- package/dist/vectorPdfExport-Bazeq3bN.js.map +0 -1
- package/dist/vectorPdfExport-BkAhiIFX.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsPDF, ShadingPattern } from "jspdf";
|
|
2
2
|
import { svg2pdf } from "svg2pdf.js";
|
|
3
3
|
import * as fabric from "fabric";
|
|
4
|
-
import { p as parseTextMarkdown, r as renderSmartElementToSvg, g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, b as getProxiedImageUrl, d as getImageProxyFetchOptions, A as API_URL, n as normalizeShapeType, i as isElement, e as isGroup, h as buildRoundedTrianglePath, j as hasEdgeFade, k as bakeEdgeFade, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-
|
|
5
|
-
import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-
|
|
4
|
+
import { p as parseTextMarkdown, r as renderSmartElementToSvg, g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, b as getProxiedImageUrl, d as getImageProxyFetchOptions, A as API_URL, n as normalizeShapeType, i as isElement, e as isGroup, h as buildRoundedTrianglePath, j as hasEdgeFade, k as bakeEdgeFade, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints, o as getWorldAngleDeg } from "./index-CiSoT2Lk.js";
|
|
5
|
+
import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-B_rPB0OF.js";
|
|
6
6
|
async function embedFontsForSvg(pdf, svgStr) {
|
|
7
7
|
var _a;
|
|
8
8
|
const {
|
|
@@ -12,7 +12,7 @@ async function embedFontsForSvg(pdf, svgStr) {
|
|
|
12
12
|
FONT_FALLBACK_SYMBOLS: FONT_FALLBACK_SYMBOLS2,
|
|
13
13
|
FONT_FALLBACK_DEVANAGARI: FONT_FALLBACK_DEVANAGARI2,
|
|
14
14
|
FONT_FALLBACK_MATH: FONT_FALLBACK_MATH2
|
|
15
|
-
} = await import("./pdfFonts-
|
|
15
|
+
} = await import("./pdfFonts-B_rPB0OF.js");
|
|
16
16
|
const parser = new DOMParser();
|
|
17
17
|
const doc = parser.parseFromString(svgStr, "image/svg+xml");
|
|
18
18
|
const textEls = Array.from(doc.querySelectorAll("text, tspan, textPath"));
|
|
@@ -1814,7 +1814,7 @@ function stripSuspiciousFullPageOverlayNodes(svg) {
|
|
|
1814
1814
|
let isPathLike = false;
|
|
1815
1815
|
if (el.tagName.toLowerCase() === "path") {
|
|
1816
1816
|
const d = (el.getAttribute("d") || "").replace(/\s+/g, " ").trim();
|
|
1817
|
-
isPathLike = !!d && (new RegExp(`^
|
|
1817
|
+
isPathLike = !!d && (new RegExp(`^M\\s*0(?:\\.0+)?\\s+0(?:\\.0+)?\\s*H\\s*${Math.round(pageWidth)}(?:\\.0+)?\\s*V\\s*${Math.round(pageHeight)}(?:\\.0+)?\\s*H\\s*0(?:\\.0+)?\\s*Z?$`, "i").test(d) || new RegExp(`^M\\s*0(?:\\.0+)?\\s+0(?:\\.0+)?\\s*L\\s*${Math.round(pageWidth)}(?:\\.0+)?\\s+0(?:\\.0+)?\\s*L\\s*${Math.round(pageWidth)}(?:\\.0+)?\\s+${Math.round(pageHeight)}(?:\\.0+)?\\s*L\\s*0(?:\\.0+)?\\s+${Math.round(pageHeight)}(?:\\.0+)?\\s*Z?$`, "i").test(d));
|
|
1818
1818
|
}
|
|
1819
1819
|
const inlineStyle = el.getAttribute("style") || "";
|
|
1820
1820
|
const likelyOverlay = isRectLike || isPathLike || hasVisibleStyleToken(inlineStyle, "mix-blend-mode");
|
|
@@ -2607,7 +2607,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
2607
2607
|
logSvgGradientClipDiagnostics("prepare:after-flatten-nested-viewports", svg, { pageKey, pageWidth, pageHeight });
|
|
2608
2608
|
disambiguateNestedSvgIds(svg);
|
|
2609
2609
|
expandSvgUseElements(svg, pageKey);
|
|
2610
|
-
|
|
2610
|
+
const svgToDraw = normalizeSvgExplicitColors(svg);
|
|
2611
2611
|
logSvgGradientClipDiagnostics("prepare:after-explicit-colors", svgToDraw, { pageKey, pageWidth, pageHeight });
|
|
2612
2612
|
inlineComputedStyles(svgToDraw);
|
|
2613
2613
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
@@ -3252,7 +3252,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
3252
3252
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
3253
3253
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
3254
3254
|
try {
|
|
3255
|
-
const { getNormalizedSvgUrl } = await import("./index-
|
|
3255
|
+
const { getNormalizedSvgUrl } = await import("./index-CiSoT2Lk.js").then((n) => n.a8);
|
|
3256
3256
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
3257
3257
|
} catch {
|
|
3258
3258
|
return null;
|
|
@@ -4061,7 +4061,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
4061
4061
|
}
|
|
4062
4062
|
let fetchUrl = imageUrl;
|
|
4063
4063
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
4064
|
-
const { isPrivateUrl } = await import("./index-
|
|
4064
|
+
const { isPrivateUrl } = await import("./index-CiSoT2Lk.js").then((n) => n.a8);
|
|
4065
4065
|
if (isPrivateUrl(imageUrl)) return null;
|
|
4066
4066
|
const proxyUrl = new URL(`${API_URL}/image-proxy`);
|
|
4067
4067
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -4159,7 +4159,7 @@ function getShapePoints(shapeType, x, y, w, h) {
|
|
|
4159
4159
|
{ x: x + w, y: y + h },
|
|
4160
4160
|
{ x, y: y + h }
|
|
4161
4161
|
];
|
|
4162
|
-
case "cross":
|
|
4162
|
+
case "cross": {
|
|
4163
4163
|
const t = 0.35;
|
|
4164
4164
|
return [
|
|
4165
4165
|
{ x: x + w * t, y },
|
|
@@ -4175,6 +4175,7 @@ function getShapePoints(shapeType, x, y, w, h) {
|
|
|
4175
4175
|
{ x, y: y + h * t },
|
|
4176
4176
|
{ x: x + w * t, y: y + h * t }
|
|
4177
4177
|
];
|
|
4178
|
+
}
|
|
4178
4179
|
default:
|
|
4179
4180
|
return null;
|
|
4180
4181
|
}
|
|
@@ -4678,7 +4679,7 @@ async function rasterizeCropGroupToPng(liveGroup, frameW, frameH, multiplier = 2
|
|
|
4678
4679
|
return png;
|
|
4679
4680
|
}
|
|
4680
4681
|
async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeight, backgroundColor, fabricMatrix, fabricIntrinsic, pageId, liveFabricText, pageChildren) {
|
|
4681
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4682
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4682
4683
|
if (!element.visible) return;
|
|
4683
4684
|
debugLog(`drawElement START id=${element.id} type=${element.type}`);
|
|
4684
4685
|
const norm = normalizeElement(element);
|
|
@@ -4690,6 +4691,18 @@ async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeigh
|
|
|
4690
4691
|
norm.y = abs.top;
|
|
4691
4692
|
norm.w = abs.width;
|
|
4692
4693
|
norm.h = abs.height;
|
|
4694
|
+
if (isElement(node)) {
|
|
4695
|
+
norm.angle = getWorldAngleDeg(node, pageChildren);
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4698
|
+
}
|
|
4699
|
+
{
|
|
4700
|
+
const elBg = element.backgroundColor;
|
|
4701
|
+
if (elBg && elBg !== "transparent" && elBg !== "none" && !fabricMatrix && norm.w > 0 && norm.h > 0) {
|
|
4702
|
+
const prevFill = (_a = pdf.getFillColor) == null ? void 0 : _a.call(pdf);
|
|
4703
|
+
pdf.setFillColor(normalizeBgColor(elBg));
|
|
4704
|
+
pdf.rect(norm.x, norm.y, norm.w, norm.h, "F");
|
|
4705
|
+
if (prevFill) pdf.setFillColor(prevFill);
|
|
4693
4706
|
}
|
|
4694
4707
|
}
|
|
4695
4708
|
if (element.smartElementType && element.smartProps && norm.w > 0 && norm.h > 0) {
|
|
@@ -4765,11 +4778,11 @@ async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeigh
|
|
|
4765
4778
|
const anyPdf3 = pdf;
|
|
4766
4779
|
const canUseAdvancedTransforms3 = typeof anyPdf3.advancedAPI === "function" && typeof anyPdf3.setCurrentTransformationMatrix === "function" && typeof anyPdf3.Matrix === "function";
|
|
4767
4780
|
pdf.setGState(pdf.GState({ opacity: 1, "stroke-opacity": 1 }));
|
|
4768
|
-
const cropZoomVal = cropData ? Math.max(1, ((
|
|
4769
|
-
const cropPanXVal = cropData ? Math.max(0, Math.min(1, ((
|
|
4770
|
-
const cropPanYVal = cropData ? Math.max(0, Math.min(1, ((
|
|
4771
|
-
const naturalW = Math.max(1, Number(element.imageNaturalWidth ?? 0) || Number(((
|
|
4772
|
-
const naturalH = Math.max(1, Number(element.imageNaturalHeight ?? 0) || Number(((
|
|
4781
|
+
const cropZoomVal = cropData ? Math.max(1, ((_c = (_b = cropData._img) == null ? void 0 : _b._ct) == null ? void 0 : _c.zoom) ?? element.cropZoom ?? 1) : 1;
|
|
4782
|
+
const cropPanXVal = cropData ? Math.max(0, Math.min(1, ((_e = (_d = cropData._img) == null ? void 0 : _d._ct) == null ? void 0 : _e.panX) ?? element.cropPanX ?? 0.5)) : 0.5;
|
|
4783
|
+
const cropPanYVal = cropData ? Math.max(0, Math.min(1, ((_g = (_f = cropData._img) == null ? void 0 : _f._ct) == null ? void 0 : _g.panY) ?? element.cropPanY ?? 0.5)) : 0.5;
|
|
4784
|
+
const naturalW = Math.max(1, Number(element.imageNaturalWidth ?? 0) || Number(((_h = cropData == null ? void 0 : cropData._img) == null ? void 0 : _h.width) ?? 0) || frameW);
|
|
4785
|
+
const naturalH = Math.max(1, Number(element.imageNaturalHeight ?? 0) || Number(((_i = cropData == null ? void 0 : cropData._img) == null ? void 0 : _i.height) ?? 0) || frameH);
|
|
4773
4786
|
const fitContain = ((cropData == null ? void 0 : cropData.fit) ?? element.imageFit ?? "cover") === "contain";
|
|
4774
4787
|
const alignH = element.imageAlignH ?? "center";
|
|
4775
4788
|
const alignV = element.imageAlignV ?? "middle";
|
|
@@ -5199,7 +5212,7 @@ async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeigh
|
|
|
5199
5212
|
liveFabricText ?? void 0
|
|
5200
5213
|
);
|
|
5201
5214
|
pdf.setGState(pdf.GState({ opacity: 1, "stroke-opacity": 1 }));
|
|
5202
|
-
const linkUrl2 = (
|
|
5215
|
+
const linkUrl2 = (_j = element.linkConfig) == null ? void 0 : _j.url;
|
|
5203
5216
|
if (linkUrl2) {
|
|
5204
5217
|
addLinkAnnotation(pdf, linkUrl2, norm.x, norm.y, visualW, visualH);
|
|
5205
5218
|
}
|
|
@@ -5299,7 +5312,7 @@ async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeigh
|
|
|
5299
5312
|
);
|
|
5300
5313
|
}
|
|
5301
5314
|
pdf.setGState(pdf.GState({ opacity: 1, "stroke-opacity": 1 }));
|
|
5302
|
-
const linkUrl = (
|
|
5315
|
+
const linkUrl = (_k = element.linkConfig) == null ? void 0 : _k.url;
|
|
5303
5316
|
if (linkUrl) {
|
|
5304
5317
|
addLinkAnnotation(pdf, linkUrl, norm.x, norm.y, visualW, visualH);
|
|
5305
5318
|
}
|
|
@@ -5935,7 +5948,7 @@ async function __exportMultiPagePdfInner(pages, options) {
|
|
|
5935
5948
|
}
|
|
5936
5949
|
let preppedSvgString = liveSvgString;
|
|
5937
5950
|
try {
|
|
5938
|
-
const { prepareSvgTextForPdfMode } = await import("./svgTextToPath-
|
|
5951
|
+
const { prepareSvgTextForPdfMode } = await import("./svgTextToPath-RmE-6Dbn.js");
|
|
5939
5952
|
preppedSvgString = await prepareSvgTextForPdfMode(liveSvgString, pdfTextMode);
|
|
5940
5953
|
console.log("[client-pdf-export] gradient text mode", {
|
|
5941
5954
|
pdfTextMode,
|
|
@@ -6160,7 +6173,7 @@ async function __exportMultiPagePdfInner(pages, options) {
|
|
|
6160
6173
|
const liveMatrix = matrixByElementId.get(element.id);
|
|
6161
6174
|
const storedMatrix = element.transformMatrix;
|
|
6162
6175
|
const m = liveMatrix ?? storedMatrix ?? null;
|
|
6163
|
-
|
|
6176
|
+
const intrinsic = intrinsicByElementId.get(element.id) ?? null;
|
|
6164
6177
|
const liveText = element.type === "text" ? liveTextByElementId.get(element.id) : void 0;
|
|
6165
6178
|
await drawElement(pdf, element, embeddedFonts, page.width, page.height, page.backgroundColor, m, intrinsic, page.pageId, liveText, page.pageChildren);
|
|
6166
6179
|
if (drawIndex % 3 === 2) await yieldToUI();
|
|
@@ -6196,4 +6209,4 @@ export {
|
|
|
6196
6209
|
preparePagesForExport,
|
|
6197
6210
|
rewriteSvgFontsForJsPDFWithSourceMeta
|
|
6198
6211
|
};
|
|
6199
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
6212
|
+
//# sourceMappingURL=vectorPdfExport-E3x8GBto.js.map
|