@pixldocs/canvas-renderer 0.5.146 → 0.5.148
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-oR6VOGAL.js → index-BkhtOI5W.js} +38 -25
- package/dist/{index-oR6VOGAL.js.map → index-BkhtOI5W.js.map} +1 -1
- package/dist/{index-DoPXmxDJ.cjs → index-Bt1m9Esp.cjs} +17 -4
- package/dist/{index-DoPXmxDJ.cjs.map → index-Bt1m9Esp.cjs.map} +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +22 -21
- package/dist/{vectorPdfExport-DI7k8pt7.js → vectorPdfExport-BX2pT0Zn.js} +68 -4
- package/dist/vectorPdfExport-BX2pT0Zn.js.map +1 -0
- package/dist/{vectorPdfExport-SMvSP0el.cjs → vectorPdfExport-JGntLQJQ.cjs} +68 -4
- package/dist/vectorPdfExport-JGntLQJQ.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/vectorPdfExport-DI7k8pt7.js.map +0 -1
- package/dist/vectorPdfExport-SMvSP0el.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-Bt1m9Esp.cjs");
|
|
4
|
+
exports.DEPLOYMENT_VERSION_MARKER = index.DEPLOYMENT_VERSION_MARKER;
|
|
4
5
|
exports.FONT_FALLBACK_DEVANAGARI = index.FONT_FALLBACK_DEVANAGARI;
|
|
5
6
|
exports.FONT_FALLBACK_MATH = index.FONT_FALLBACK_MATH;
|
|
6
7
|
exports.FONT_FALLBACK_SYMBOLS = index.FONT_FALLBACK_SYMBOLS;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -87,6 +87,8 @@ export declare function collectImageUrls(config: TemplateConfig): string[];
|
|
|
87
87
|
*/
|
|
88
88
|
export declare function configHasAutoShrinkText(config: TemplateConfig | null | undefined): boolean;
|
|
89
89
|
|
|
90
|
+
export declare const DEPLOYMENT_VERSION_MARKER: string;
|
|
91
|
+
|
|
90
92
|
export declare function dumpSvgTextDiagnostics(svgStr: string, pageIndex: number, tag: string, stage: string, maxItems?: number): void;
|
|
91
93
|
|
|
92
94
|
export declare interface DynamicField {
|
|
@@ -255,11 +257,7 @@ export declare function loadGoogleFontCSS(rawFontFamily: string): Promise<void>;
|
|
|
255
257
|
*/
|
|
256
258
|
export declare function normalizeFontFamily(fontStack: string): string;
|
|
257
259
|
|
|
258
|
-
|
|
259
|
-
* Package version banner. Bump alongside package.json so we can confirm
|
|
260
|
-
* (via browser:log) that the deployed bundle matches the expected build.
|
|
261
|
-
*/
|
|
262
|
-
export declare const PACKAGE_VERSION = "0.5.145";
|
|
260
|
+
export declare const PACKAGE_VERSION: string;
|
|
263
261
|
|
|
264
262
|
export declare interface PageSettings {
|
|
265
263
|
backgroundColor?: string;
|
|
@@ -382,6 +380,7 @@ export declare interface PixldocsPreviewResolveProps extends PixldocsPreviewBase
|
|
|
382
380
|
export declare class PixldocsRenderer {
|
|
383
381
|
private config;
|
|
384
382
|
constructor(config: RendererConfig);
|
|
383
|
+
private installRuntimeGlobals;
|
|
385
384
|
/**
|
|
386
385
|
* Render a pre-resolved template config to an image using the full PageCanvas engine.
|
|
387
386
|
* Mounts a hidden PreviewCanvas component and captures the Fabric canvas output.
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { F, o, q, s, P, t, u, v, w, x, y, z, B, C,
|
|
1
|
+
import { D, F, o, q, s, P, t, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, b, M, N, O, Q, R, S, U, V, W, X, Y, Z, _ } from "./index-BkhtOI5W.js";
|
|
2
2
|
export {
|
|
3
|
+
D as DEPLOYMENT_VERSION_MARKER,
|
|
3
4
|
F as FONT_FALLBACK_DEVANAGARI,
|
|
4
5
|
o as FONT_FALLBACK_MATH,
|
|
5
6
|
q as FONT_FALLBACK_SYMBOLS,
|
|
@@ -14,26 +15,26 @@ export {
|
|
|
14
15
|
z as collectFontsFromConfig,
|
|
15
16
|
B as collectImageUrls,
|
|
16
17
|
C as configHasAutoShrinkText,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
E as dumpSvgTextDiagnostics,
|
|
19
|
+
G as embedFont,
|
|
20
|
+
H as embedFontsForConfig,
|
|
21
|
+
I as embedFontsInPdf,
|
|
22
|
+
J as ensureFontsForResolvedConfig,
|
|
23
|
+
K as extractFontFamiliesFromSvgs,
|
|
24
|
+
L as getEmbeddedJsPDFFontName,
|
|
24
25
|
b as getProxiedImageUrl,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
M as isBundledAssetUrl,
|
|
27
|
+
N as isFontAvailable,
|
|
28
|
+
O as isPrivateUrl,
|
|
29
|
+
Q as loadGoogleFontCSS,
|
|
30
|
+
R as normalizeFontFamily,
|
|
31
|
+
S as resolveFontWeight,
|
|
32
|
+
U as resolveFromForm,
|
|
33
|
+
V as resolveTemplateData,
|
|
34
|
+
W as rewriteSvgFontsForJsPDF,
|
|
35
|
+
X as setAutoShrinkDebug,
|
|
36
|
+
Y as setBundledAssetPrefixes,
|
|
37
|
+
Z as warmResolvedTemplateForPreview,
|
|
38
|
+
_ as warmTemplateFromForm
|
|
38
39
|
};
|
|
39
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsPDF, ShadingPattern } from "jspdf";
|
|
2
2
|
import { svg2pdf } from "svg2pdf.js";
|
|
3
3
|
import * as fabric from "fabric";
|
|
4
|
-
import { g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, p as parseTextMarkdown, r as renderSmartElementToSvg, n as normalizeShapeType, h as hasEdgeFade, b as getProxiedImageUrl, d as bakeEdgeFade, i as isElement, e as isGroup, j as buildRoundedTrianglePath, A as API_URL, k as getImageProxyFetchOptions, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-
|
|
4
|
+
import { g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, p as parseTextMarkdown, r as renderSmartElementToSvg, n as normalizeShapeType, h as hasEdgeFade, b as getProxiedImageUrl, d as bakeEdgeFade, i as isElement, e as isGroup, j as buildRoundedTrianglePath, A as API_URL, k as getImageProxyFetchOptions, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-BkhtOI5W.js";
|
|
5
5
|
import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-b3_bv7F0.js";
|
|
6
6
|
async function embedFontsForSvg(pdf, svgStr) {
|
|
7
7
|
var _a;
|
|
@@ -1180,6 +1180,44 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
|
|
|
1180
1180
|
tempContainer.appendChild(clone);
|
|
1181
1181
|
document.body.appendChild(tempContainer);
|
|
1182
1182
|
let baked = 0;
|
|
1183
|
+
const _measureCanvas = typeof document !== "undefined" ? document.createElement("canvas") : null;
|
|
1184
|
+
const _mctx = (_measureCanvas == null ? void 0 : _measureCanvas.getContext("2d")) || null;
|
|
1185
|
+
const _resolveFontSize = (node) => {
|
|
1186
|
+
let cur = node;
|
|
1187
|
+
while (cur) {
|
|
1188
|
+
const fs = cur.getAttribute("font-size");
|
|
1189
|
+
if (fs) {
|
|
1190
|
+
const n = parseFloat(fs);
|
|
1191
|
+
if (Number.isFinite(n) && n > 0) return n;
|
|
1192
|
+
}
|
|
1193
|
+
cur = cur.parentElement;
|
|
1194
|
+
}
|
|
1195
|
+
return 16;
|
|
1196
|
+
};
|
|
1197
|
+
const _resolveFontAttr = (node, attr, fallback) => {
|
|
1198
|
+
let cur = node;
|
|
1199
|
+
while (cur) {
|
|
1200
|
+
const v = cur.getAttribute(`data-source-${attr}`) || cur.getAttribute(attr);
|
|
1201
|
+
if (v) return v;
|
|
1202
|
+
cur = cur.parentElement;
|
|
1203
|
+
}
|
|
1204
|
+
return fallback;
|
|
1205
|
+
};
|
|
1206
|
+
const _measureWidthCanvas = (srcNode, content) => {
|
|
1207
|
+
if (!_mctx || !content) return null;
|
|
1208
|
+
const family = _resolveFontAttr(srcNode, "font-family", "").replace(/['"]/g, "").trim();
|
|
1209
|
+
const weight = _resolveFontAttr(srcNode, "font-weight", "400");
|
|
1210
|
+
const style = _resolveFontAttr(srcNode, "font-style", "normal");
|
|
1211
|
+
const size = _resolveFontSize(srcNode);
|
|
1212
|
+
if (!family) return null;
|
|
1213
|
+
try {
|
|
1214
|
+
_mctx.font = `${style} ${weight} ${size}px "${family}"`;
|
|
1215
|
+
const w = _mctx.measureText(content).width;
|
|
1216
|
+
return Number.isFinite(w) && w > 0 ? w : null;
|
|
1217
|
+
} catch {
|
|
1218
|
+
return null;
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1183
1221
|
try {
|
|
1184
1222
|
const srcTexts = Array.from(svg.querySelectorAll("text"));
|
|
1185
1223
|
const liveTexts = Array.from(clone.querySelectorAll("text"));
|
|
@@ -1199,6 +1237,32 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
|
|
|
1199
1237
|
const bakeNode = (srcNode, liveNode, anchorOverride) => {
|
|
1200
1238
|
const anchor = (anchorOverride || _resolveAnchor(srcNode)).trim().toLowerCase();
|
|
1201
1239
|
if (anchor !== "middle" && anchor !== "end") return;
|
|
1240
|
+
try {
|
|
1241
|
+
const content = srcNode.textContent || "";
|
|
1242
|
+
if (content.length > 0) {
|
|
1243
|
+
const width = _measureWidthCanvas(srcNode, content);
|
|
1244
|
+
let refXAttr = null;
|
|
1245
|
+
let cur = srcNode;
|
|
1246
|
+
while (cur) {
|
|
1247
|
+
const v = cur.getAttribute("x");
|
|
1248
|
+
if (v) {
|
|
1249
|
+
refXAttr = v;
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
cur = cur.parentElement;
|
|
1253
|
+
}
|
|
1254
|
+
const refX = refXAttr !== null ? parseFloat(refXAttr.split(/[\s,]+/)[0]) : NaN;
|
|
1255
|
+
if (width !== null && Number.isFinite(refX)) {
|
|
1256
|
+
const newX = anchor === "middle" ? refX - width / 2 : refX - width;
|
|
1257
|
+
srcNode.setAttribute("x", String(newX));
|
|
1258
|
+
srcNode.setAttribute("text-anchor", "start");
|
|
1259
|
+
stripTextAnchorStyle(srcNode);
|
|
1260
|
+
baked++;
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
} catch {
|
|
1265
|
+
}
|
|
1202
1266
|
try {
|
|
1203
1267
|
const n = typeof liveNode.getNumberOfChars === "function" ? liveNode.getNumberOfChars() : 0;
|
|
1204
1268
|
if (!n) return;
|
|
@@ -2386,7 +2450,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
2386
2450
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
2387
2451
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
2388
2452
|
try {
|
|
2389
|
-
const { getNormalizedSvgUrl } = await import("./index-
|
|
2453
|
+
const { getNormalizedSvgUrl } = await import("./index-BkhtOI5W.js").then((n) => n.$);
|
|
2390
2454
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
2391
2455
|
} catch {
|
|
2392
2456
|
return null;
|
|
@@ -3167,7 +3231,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
3167
3231
|
}
|
|
3168
3232
|
let fetchUrl = imageUrl;
|
|
3169
3233
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
3170
|
-
const { isPrivateUrl } = await import("./index-
|
|
3234
|
+
const { isPrivateUrl } = await import("./index-BkhtOI5W.js").then((n) => n.$);
|
|
3171
3235
|
if (isPrivateUrl(imageUrl)) return null;
|
|
3172
3236
|
const proxyUrl = new URL(`${API_URL}/image-proxy`);
|
|
3173
3237
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -5151,4 +5215,4 @@ export {
|
|
|
5151
5215
|
preparePagesForExport,
|
|
5152
5216
|
rewriteSvgFontsForJsPDFWithSourceMeta
|
|
5153
5217
|
};
|
|
5154
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
5218
|
+
//# sourceMappingURL=vectorPdfExport-BX2pT0Zn.js.map
|