@pixldocs/canvas-renderer 0.5.145 → 0.5.147
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-DVjmPr0D.cjs → index-D78ekQx5.cjs} +17 -4
- package/dist/{index-DVjmPr0D.cjs.map → index-D78ekQx5.cjs.map} +1 -1
- package/dist/{index-Br7Pk6Ol.js → index-NMZJF9C9.js} +38 -25
- package/dist/{index-Br7Pk6Ol.js.map → index-NMZJF9C9.js.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-C9jFFq3k.cjs → vectorPdfExport-DmFmkPUr.cjs} +46 -8
- package/dist/vectorPdfExport-DmFmkPUr.cjs.map +1 -0
- package/dist/{vectorPdfExport-B63qQqDW.js → vectorPdfExport-_m5TiQjK.js} +46 -8
- package/dist/vectorPdfExport-_m5TiQjK.js.map +1 -0
- package/package.json +1 -1
- package/dist/vectorPdfExport-B63qQqDW.js.map +0 -1
- package/dist/vectorPdfExport-C9jFFq3k.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-D78ekQx5.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-NMZJF9C9.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
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jspdf = require("jspdf");
|
|
4
4
|
const svg2pdf_js = require("svg2pdf.js");
|
|
5
5
|
const fabric = require("fabric");
|
|
6
|
-
const index = require("./index-
|
|
6
|
+
const index = require("./index-D78ekQx5.cjs");
|
|
7
7
|
const pdfFonts = require("./pdfFonts-BTEVnYX8.cjs");
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
9
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -142,6 +142,33 @@ const yieldToUI = () => new Promise((resolve) => {
|
|
|
142
142
|
requestAnimationFrame(() => setTimeout(resolve, 0));
|
|
143
143
|
});
|
|
144
144
|
const SHADOW_RASTER_ALPHA_COMPENSATION = 0.84;
|
|
145
|
+
function collectFontSpecsFromShadowMarkup(markup) {
|
|
146
|
+
const specs = /* @__PURE__ */ new Set();
|
|
147
|
+
const re = /<(?:text|tspan)\b[^>]*>/gi;
|
|
148
|
+
let match;
|
|
149
|
+
while ((match = re.exec(markup)) !== null) {
|
|
150
|
+
const tag = match[0];
|
|
151
|
+
const get = (attr) => {
|
|
152
|
+
const m = tag.match(new RegExp(`\\s${attr}\\s*=\\s*"([^"]*)"`, "i"));
|
|
153
|
+
if (m) return m[1];
|
|
154
|
+
const styleM = tag.match(/\sstyle\s*=\s*"([^"]*)"/i);
|
|
155
|
+
if (styleM) {
|
|
156
|
+
const sm = styleM[1].match(new RegExp(`${attr}\\s*:\\s*([^;]+)`, "i"));
|
|
157
|
+
if (sm) return sm[1].trim();
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
};
|
|
161
|
+
const family = (get("font-family") || "").split(",")[0].replace(/['"]/g, "").trim();
|
|
162
|
+
if (!family) continue;
|
|
163
|
+
const weight = get("font-weight") || "400";
|
|
164
|
+
const style = get("font-style") || "normal";
|
|
165
|
+
const size = get("font-size") || "16px";
|
|
166
|
+
const sizePx = /[a-z%]/i.test(size) ? size : `${size}px`;
|
|
167
|
+
const famSpec = /\s/.test(family) ? `"${family}"` : family;
|
|
168
|
+
specs.add(`${style} ${weight} ${sizePx} ${famSpec}`);
|
|
169
|
+
}
|
|
170
|
+
return Array.from(specs);
|
|
171
|
+
}
|
|
145
172
|
let debugSvgDrawSequence = 0;
|
|
146
173
|
function debugLog(...args) {
|
|
147
174
|
}
|
|
@@ -1522,7 +1549,7 @@ async function convertSvgTextDecorationsToLinesString(svgStr) {
|
|
|
1522
1549
|
}
|
|
1523
1550
|
}
|
|
1524
1551
|
async function rasterizeShadowMarkers(svg) {
|
|
1525
|
-
var _a, _b, _c, _d, _e;
|
|
1552
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1526
1553
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
1527
1554
|
const markers = Array.from(svg.querySelectorAll("g.__pdShadowRaster"));
|
|
1528
1555
|
if (markers.length === 0) return;
|
|
@@ -1549,6 +1576,17 @@ async function rasterizeShadowMarkers(svg) {
|
|
|
1549
1576
|
const innerXml = restoreSourceFontsForShadowRaster(
|
|
1550
1577
|
Array.from(marker.childNodes).map((n) => n instanceof Element ? new XMLSerializer().serializeToString(n) : "").join("")
|
|
1551
1578
|
);
|
|
1579
|
+
try {
|
|
1580
|
+
const fontSpecs = collectFontSpecsFromShadowMarkup(innerXml);
|
|
1581
|
+
if (fontSpecs.length > 0 && ((_c = document.fonts) == null ? void 0 : _c.load)) {
|
|
1582
|
+
await Promise.all(
|
|
1583
|
+
fontSpecs.map(
|
|
1584
|
+
(spec) => document.fonts.load(spec).catch(() => void 0)
|
|
1585
|
+
)
|
|
1586
|
+
);
|
|
1587
|
+
}
|
|
1588
|
+
} catch {
|
|
1589
|
+
}
|
|
1552
1590
|
const scale = 2;
|
|
1553
1591
|
const pxW = Math.min(4096, Math.max(8, Math.ceil(bw * scale)));
|
|
1554
1592
|
const pxH = Math.min(4096, Math.max(8, Math.ceil(bh * scale)));
|
|
@@ -1558,7 +1596,7 @@ async function rasterizeShadowMarkers(svg) {
|
|
|
1558
1596
|
const miniSvg = `<svg xmlns="${SVG_NS}" xmlns:xlink="${XLINK_NS}" width="${pxW}" height="${pxH}" viewBox="${bx} ${by} ${bw} ${bh}">${styleBlock}<defs><filter id="${filterId}" filterUnits="userSpaceOnUse" x="${bx}" y="${by}" width="${bw}" height="${bh}" color-interpolation-filters="sRGB"><feOffset dx="${ox}" dy="${oy}" result="offsetShadow" /><feGaussianBlur in="offsetShadow" stdDeviation="${stdDev}" /></filter></defs><g filter="url(#${filterId})">${innerXml}</g></svg>`;
|
|
1559
1597
|
const dataUrl = await rasterSvgToPngDataUrl(miniSvg, pxW, pxH);
|
|
1560
1598
|
if (!dataUrl) {
|
|
1561
|
-
(
|
|
1599
|
+
(_d = marker.parentNode) == null ? void 0 : _d.removeChild(marker);
|
|
1562
1600
|
continue;
|
|
1563
1601
|
}
|
|
1564
1602
|
const img = svg.ownerDocument.createElementNS(SVG_NS, "image");
|
|
@@ -1570,11 +1608,11 @@ async function rasterizeShadowMarkers(svg) {
|
|
|
1570
1608
|
img.setAttribute("preserveAspectRatio", "none");
|
|
1571
1609
|
img.setAttributeNS(XLINK_NS, "xlink:href", dataUrl);
|
|
1572
1610
|
img.setAttribute("href", dataUrl);
|
|
1573
|
-
(
|
|
1611
|
+
(_e = marker.parentNode) == null ? void 0 : _e.replaceChild(img, marker);
|
|
1574
1612
|
} catch (error) {
|
|
1575
1613
|
console.warn("[Vector PDF] text shadow rasterization failed for one marker:", error);
|
|
1576
1614
|
try {
|
|
1577
|
-
(
|
|
1615
|
+
(_f = marker.parentNode) == null ? void 0 : _f.removeChild(marker);
|
|
1578
1616
|
} catch {
|
|
1579
1617
|
}
|
|
1580
1618
|
}
|
|
@@ -2367,7 +2405,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
2367
2405
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
2368
2406
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
2369
2407
|
try {
|
|
2370
|
-
const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-
|
|
2408
|
+
const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-D78ekQx5.cjs")).then((n) => n.canvasImageLoader);
|
|
2371
2409
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
2372
2410
|
} catch {
|
|
2373
2411
|
return null;
|
|
@@ -3148,7 +3186,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
3148
3186
|
}
|
|
3149
3187
|
let fetchUrl = imageUrl;
|
|
3150
3188
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
3151
|
-
const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-
|
|
3189
|
+
const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-D78ekQx5.cjs")).then((n) => n.canvasImageLoader);
|
|
3152
3190
|
if (isPrivateUrl(imageUrl)) return null;
|
|
3153
3191
|
const proxyUrl = new URL(`${index.API_URL}/image-proxy`);
|
|
3154
3192
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -5130,4 +5168,4 @@ exports.exportMultiPagePdf = exportMultiPagePdf;
|
|
|
5130
5168
|
exports.logTextMeasurementDiagnostic = logTextMeasurementDiagnostic;
|
|
5131
5169
|
exports.preparePagesForExport = preparePagesForExport;
|
|
5132
5170
|
exports.rewriteSvgFontsForJsPDFWithSourceMeta = rewriteSvgFontsForJsPDFWithSourceMeta;
|
|
5133
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
5171
|
+
//# sourceMappingURL=vectorPdfExport-DmFmkPUr.cjs.map
|