@pixldocs/canvas-renderer 0.5.125 → 0.5.127
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-CNN2CRQh.cjs → index-D3W__oF4.cjs} +128 -84
- package/dist/index-D3W__oF4.cjs.map +1 -0
- package/dist/{index-D7cGwzxX.js → index-DAeQbGws.js} +167 -123
- package/dist/index-DAeQbGws.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -33
- package/dist/{pdfFonts-BPQ8WSXF.cjs → pdfFonts-Cr8l-y3z.cjs} +10 -1
- package/dist/{pdfFonts-BPQ8WSXF.cjs.map → pdfFonts-Cr8l-y3z.cjs.map} +1 -1
- package/dist/{pdfFonts-CZpNVjX9.js → pdfFonts-Y49FLHuG.js} +25 -17
- package/dist/{pdfFonts-CZpNVjX9.js.map → pdfFonts-Y49FLHuG.js.map} +1 -1
- package/dist/{svgTextToPath-BytLBSI5.cjs → svgTextToPath-1WbtFu9C.cjs} +2 -2
- package/dist/{svgTextToPath-BytLBSI5.cjs.map → svgTextToPath-1WbtFu9C.cjs.map} +1 -1
- package/dist/{svgTextToPath-Bsxjuz6-.js → svgTextToPath-n7TTV6Xv.js} +2 -2
- package/dist/{svgTextToPath-Bsxjuz6-.js.map → svgTextToPath-n7TTV6Xv.js.map} +1 -1
- package/dist/{vectorPdfExport-DVISwrvS.cjs → vectorPdfExport-BDy3-lzN.cjs} +106 -17
- package/dist/vectorPdfExport-BDy3-lzN.cjs.map +1 -0
- package/dist/{vectorPdfExport-BBV3abJi.js → vectorPdfExport-DtWByjEA.js} +106 -17
- package/dist/vectorPdfExport-DtWByjEA.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-CNN2CRQh.cjs.map +0 -1
- package/dist/index-D7cGwzxX.js.map +0 -1
- package/dist/vectorPdfExport-BBV3abJi.js.map +0 -1
- package/dist/vectorPdfExport-DVISwrvS.cjs.map +0 -1
|
@@ -15642,7 +15642,128 @@ function PixldocsPreview(props) {
|
|
|
15642
15642
|
!canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
15643
15643
|
] });
|
|
15644
15644
|
}
|
|
15645
|
-
|
|
15645
|
+
function normalizeSvgDimensions(svg, targetWidth, targetHeight) {
|
|
15646
|
+
let normalized = svg;
|
|
15647
|
+
if (/\bwidth="[^"]*"/i.test(normalized)) {
|
|
15648
|
+
normalized = normalized.replace(/(<svg[^>]*\b)width="[^"]*"/i, `$1width="${targetWidth}"`);
|
|
15649
|
+
} else {
|
|
15650
|
+
normalized = normalized.replace(/<svg\b/i, `<svg width="${targetWidth}"`);
|
|
15651
|
+
}
|
|
15652
|
+
if (/\bheight="[^"]*"/i.test(normalized)) {
|
|
15653
|
+
normalized = normalized.replace(/(<svg[^>]*\b)height="[^"]*"/i, `$1height="${targetHeight}"`);
|
|
15654
|
+
} else {
|
|
15655
|
+
normalized = normalized.replace(/<svg\b/i, `<svg height="${targetHeight}"`);
|
|
15656
|
+
}
|
|
15657
|
+
const viewBox = `0 0 ${targetWidth} ${targetHeight}`;
|
|
15658
|
+
if (/\bviewBox="[^"]*"/i.test(normalized)) {
|
|
15659
|
+
normalized = normalized.replace(/viewBox="[^"]*"/i, `viewBox="${viewBox}"`);
|
|
15660
|
+
} else {
|
|
15661
|
+
normalized = normalized.replace(/<svg\b/i, `<svg viewBox="${viewBox}"`);
|
|
15662
|
+
}
|
|
15663
|
+
normalized = normalized.replace(/="undefined"/g, '="0"');
|
|
15664
|
+
normalized = normalized.replace(/="NaN"/g, '="0"');
|
|
15665
|
+
if (/\bx="[^"]*"/i.test(normalized)) {
|
|
15666
|
+
normalized = normalized.replace(/(<svg[^>]*\b)x="[^"]*"/i, '$1x="0"');
|
|
15667
|
+
} else {
|
|
15668
|
+
normalized = normalized.replace(/<svg\b/i, '<svg x="0"');
|
|
15669
|
+
}
|
|
15670
|
+
if (/\by="[^"]*"/i.test(normalized)) {
|
|
15671
|
+
normalized = normalized.replace(/(<svg[^>]*\b)y="[^"]*"/i, '$1y="0"');
|
|
15672
|
+
} else {
|
|
15673
|
+
normalized = normalized.replace(/<svg\b/i, '<svg y="0"');
|
|
15674
|
+
}
|
|
15675
|
+
normalized = normalized.replace(/\bpreserveAspectRatio="[^"]*"/i, 'preserveAspectRatio="none"');
|
|
15676
|
+
if (!/\bpreserveAspectRatio="[^"]*"/i.test(normalized)) {
|
|
15677
|
+
normalized = normalized.replace(/<svg\b/i, '<svg preserveAspectRatio="none"');
|
|
15678
|
+
}
|
|
15679
|
+
return normalized;
|
|
15680
|
+
}
|
|
15681
|
+
function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight) {
|
|
15682
|
+
const prevVPT = fabricInstance.viewportTransform ? [...fabricInstance.viewportTransform] : void 0;
|
|
15683
|
+
const prevSvgVPT = fabricInstance.svgViewportTransformation;
|
|
15684
|
+
const prevRetina = fabricInstance.enableRetinaScaling;
|
|
15685
|
+
const prevWidth = fabricInstance.width;
|
|
15686
|
+
const prevHeight = fabricInstance.height;
|
|
15687
|
+
fabricInstance.viewportTransform = [1, 0, 0, 1, 0, 0];
|
|
15688
|
+
fabricInstance.svgViewportTransformation = false;
|
|
15689
|
+
fabricInstance.enableRetinaScaling = false;
|
|
15690
|
+
try {
|
|
15691
|
+
fabricInstance.setDimensions(
|
|
15692
|
+
{ width: canvasWidth, height: canvasHeight },
|
|
15693
|
+
{ cssOnly: false, backstoreOnly: false }
|
|
15694
|
+
);
|
|
15695
|
+
} catch {
|
|
15696
|
+
}
|
|
15697
|
+
const fadeBakeRecords = [];
|
|
15698
|
+
try {
|
|
15699
|
+
const objs = fabricInstance.getObjects().slice();
|
|
15700
|
+
for (const obj of objs) {
|
|
15701
|
+
const isGroupLike = obj instanceof fabric.Group || (obj == null ? void 0 : obj.type) === "group" || Array.isArray(obj == null ? void 0 : obj._objects);
|
|
15702
|
+
const isFadedCropGroup = isGroupLike && (Boolean(obj.__edgeFadeRenderConfig) || Boolean(obj.__edgeFadeKey) || Boolean(obj.__edgeFadeInputKey));
|
|
15703
|
+
if (!isFadedCropGroup) continue;
|
|
15704
|
+
try {
|
|
15705
|
+
const baked = obj.toCanvasElement({
|
|
15706
|
+
multiplier: 2,
|
|
15707
|
+
enableRetinaScaling: false
|
|
15708
|
+
});
|
|
15709
|
+
const rect = obj.getBoundingRect();
|
|
15710
|
+
const replacement = new fabric.FabricImage(baked, {
|
|
15711
|
+
left: rect.left,
|
|
15712
|
+
top: rect.top,
|
|
15713
|
+
originX: "left",
|
|
15714
|
+
originY: "top",
|
|
15715
|
+
scaleX: rect.width / baked.width,
|
|
15716
|
+
scaleY: rect.height / baked.height,
|
|
15717
|
+
selectable: false,
|
|
15718
|
+
evented: false,
|
|
15719
|
+
objectCaching: false
|
|
15720
|
+
});
|
|
15721
|
+
const insertIndex = fabricInstance._objects.indexOf(obj);
|
|
15722
|
+
const prevExclude = obj.excludeFromExport;
|
|
15723
|
+
obj.excludeFromExport = true;
|
|
15724
|
+
if (insertIndex >= 0) {
|
|
15725
|
+
fabricInstance.insertAt(insertIndex + 1, replacement);
|
|
15726
|
+
} else {
|
|
15727
|
+
fabricInstance.add(replacement);
|
|
15728
|
+
}
|
|
15729
|
+
fadeBakeRecords.push({ original: obj, replacement, prevExclude, insertIndex });
|
|
15730
|
+
} catch (bakeErr) {
|
|
15731
|
+
console.warn("[canvas-svg-capture][edgeFade] bake failed:", bakeErr);
|
|
15732
|
+
}
|
|
15733
|
+
}
|
|
15734
|
+
if (fadeBakeRecords.length) {
|
|
15735
|
+
fabricInstance.renderAll();
|
|
15736
|
+
console.log(`[canvas-svg-capture][edgeFade] baked ${fadeBakeRecords.length} faded object(s)`);
|
|
15737
|
+
}
|
|
15738
|
+
} catch (e) {
|
|
15739
|
+
console.warn("[canvas-svg-capture][edgeFade] bake pass error:", e);
|
|
15740
|
+
}
|
|
15741
|
+
let svgString = "";
|
|
15742
|
+
try {
|
|
15743
|
+
const raw = fabricInstance.toSVG();
|
|
15744
|
+
svgString = normalizeSvgDimensions(raw, canvasWidth, canvasHeight);
|
|
15745
|
+
} finally {
|
|
15746
|
+
for (const rec of fadeBakeRecords) {
|
|
15747
|
+
try {
|
|
15748
|
+
fabricInstance.remove(rec.replacement);
|
|
15749
|
+
rec.original.excludeFromExport = rec.prevExclude;
|
|
15750
|
+
} catch {
|
|
15751
|
+
}
|
|
15752
|
+
}
|
|
15753
|
+
try {
|
|
15754
|
+
fabricInstance.enableRetinaScaling = prevRetina;
|
|
15755
|
+
fabricInstance.setDimensions(
|
|
15756
|
+
{ width: prevWidth, height: prevHeight },
|
|
15757
|
+
{ cssOnly: false, backstoreOnly: false }
|
|
15758
|
+
);
|
|
15759
|
+
} catch {
|
|
15760
|
+
}
|
|
15761
|
+
if (prevVPT) fabricInstance.viewportTransform = prevVPT;
|
|
15762
|
+
fabricInstance.svgViewportTransformation = prevSvgVPT;
|
|
15763
|
+
}
|
|
15764
|
+
return svgString;
|
|
15765
|
+
}
|
|
15766
|
+
const PACKAGE_VERSION = "0.5.127";
|
|
15646
15767
|
const roundParityValue = (value) => {
|
|
15647
15768
|
if (typeof value !== "number") return value;
|
|
15648
15769
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16061,7 +16182,7 @@ class PixldocsRenderer {
|
|
|
16061
16182
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16062
16183
|
}
|
|
16063
16184
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16064
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
16185
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DtWByjEA.js");
|
|
16065
16186
|
const prepared = preparePagesForExport(
|
|
16066
16187
|
cloned.pages,
|
|
16067
16188
|
canvasWidth,
|
|
@@ -16539,89 +16660,11 @@ class PixldocsRenderer {
|
|
|
16539
16660
|
reject(new Error("No Fabric canvas instance found for SVG capture"));
|
|
16540
16661
|
return;
|
|
16541
16662
|
}
|
|
16542
|
-
const
|
|
16543
|
-
|
|
16544
|
-
const prevRetina = fabricInstance.enableRetinaScaling;
|
|
16545
|
-
const prevWidth = fabricInstance.width;
|
|
16546
|
-
const prevHeight = fabricInstance.height;
|
|
16547
|
-
fabricInstance.viewportTransform = [1, 0, 0, 1, 0, 0];
|
|
16548
|
-
fabricInstance.svgViewportTransformation = false;
|
|
16549
|
-
fabricInstance.enableRetinaScaling = false;
|
|
16550
|
-
fabricInstance.setDimensions(
|
|
16551
|
-
{ width: canvasWidth, height: canvasHeight },
|
|
16552
|
-
{ cssOnly: false, backstoreOnly: false }
|
|
16553
|
-
);
|
|
16554
|
-
const fadeBakeRecords = [];
|
|
16555
|
-
try {
|
|
16556
|
-
const objs = fabricInstance.getObjects().slice();
|
|
16557
|
-
for (const obj of objs) {
|
|
16558
|
-
const isGroupLike = obj instanceof fabric.Group || (obj == null ? void 0 : obj.type) === "group" || Array.isArray(obj == null ? void 0 : obj._objects);
|
|
16559
|
-
const isFadedCropGroup = isGroupLike && (Boolean(obj.__edgeFadeRenderConfig) || Boolean(obj.__edgeFadeKey) || Boolean(obj.__edgeFadeInputKey));
|
|
16560
|
-
if (!isFadedCropGroup) continue;
|
|
16561
|
-
try {
|
|
16562
|
-
const baked = obj.toCanvasElement({
|
|
16563
|
-
multiplier: 2,
|
|
16564
|
-
enableRetinaScaling: false
|
|
16565
|
-
});
|
|
16566
|
-
const rect = obj.getBoundingRect();
|
|
16567
|
-
const replacement = new fabric.FabricImage(baked, {
|
|
16568
|
-
left: rect.left,
|
|
16569
|
-
top: rect.top,
|
|
16570
|
-
originX: "left",
|
|
16571
|
-
originY: "top",
|
|
16572
|
-
scaleX: rect.width / baked.width,
|
|
16573
|
-
scaleY: rect.height / baked.height,
|
|
16574
|
-
selectable: false,
|
|
16575
|
-
evented: false,
|
|
16576
|
-
objectCaching: false
|
|
16577
|
-
});
|
|
16578
|
-
const insertIndex = fabricInstance._objects.indexOf(obj);
|
|
16579
|
-
const prevExclude = obj.excludeFromExport;
|
|
16580
|
-
obj.excludeFromExport = true;
|
|
16581
|
-
if (insertIndex >= 0) {
|
|
16582
|
-
fabricInstance.insertAt(insertIndex + 1, replacement);
|
|
16583
|
-
} else {
|
|
16584
|
-
fabricInstance.add(replacement);
|
|
16585
|
-
}
|
|
16586
|
-
fadeBakeRecords.push({
|
|
16587
|
-
original: obj,
|
|
16588
|
-
replacement,
|
|
16589
|
-
prevExclude,
|
|
16590
|
-
insertIndex
|
|
16591
|
-
});
|
|
16592
|
-
} catch (bakeErr) {
|
|
16593
|
-
console.warn("[canvas-renderer][edgeFade] bake-for-svg failed:", bakeErr);
|
|
16594
|
-
}
|
|
16595
|
-
}
|
|
16596
|
-
if (fadeBakeRecords.length) {
|
|
16597
|
-
fabricInstance.renderAll();
|
|
16598
|
-
console.log(
|
|
16599
|
-
`[canvas-renderer][edgeFade] baked ${fadeBakeRecords.length} faded object(s) for SVG capture`
|
|
16600
|
-
);
|
|
16601
|
-
}
|
|
16602
|
-
} catch (e) {
|
|
16603
|
-
console.warn("[canvas-renderer][edgeFade] bake pass failed:", e);
|
|
16604
|
-
}
|
|
16605
|
-
const rawSvgString = fabricInstance.toSVG();
|
|
16606
|
-
const svgString = this.normalizeSvgDimensions(
|
|
16607
|
-
rawSvgString,
|
|
16663
|
+
const svgString = captureFabricCanvasSvgForPdf(
|
|
16664
|
+
fabricInstance,
|
|
16608
16665
|
canvasWidth,
|
|
16609
16666
|
canvasHeight
|
|
16610
16667
|
);
|
|
16611
|
-
for (const rec of fadeBakeRecords) {
|
|
16612
|
-
try {
|
|
16613
|
-
fabricInstance.remove(rec.replacement);
|
|
16614
|
-
rec.original.excludeFromExport = rec.prevExclude;
|
|
16615
|
-
} catch {
|
|
16616
|
-
}
|
|
16617
|
-
}
|
|
16618
|
-
fabricInstance.enableRetinaScaling = prevRetina;
|
|
16619
|
-
fabricInstance.setDimensions(
|
|
16620
|
-
{ width: prevWidth, height: prevHeight },
|
|
16621
|
-
{ cssOnly: false, backstoreOnly: false }
|
|
16622
|
-
);
|
|
16623
|
-
if (prevVPT) fabricInstance.viewportTransform = prevVPT;
|
|
16624
|
-
fabricInstance.svgViewportTransformation = prevSvgVPT;
|
|
16625
16668
|
const page = renderConfig.pages[pageIndex];
|
|
16626
16669
|
const backgroundColor = ((_a = page == null ? void 0 : page.settings) == null ? void 0 : _a.backgroundColor) || "#ffffff";
|
|
16627
16670
|
const backgroundGradient = (_b = page == null ? void 0 : page.settings) == null ? void 0 : _b.backgroundGradient;
|
|
@@ -18257,7 +18300,7 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
18257
18300
|
}
|
|
18258
18301
|
if (shouldOutlineText) {
|
|
18259
18302
|
try {
|
|
18260
|
-
const { convertAllTextToPath } = await import("./svgTextToPath-
|
|
18303
|
+
const { convertAllTextToPath } = await import("./svgTextToPath-n7TTV6Xv.js");
|
|
18261
18304
|
pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
|
|
18262
18305
|
try {
|
|
18263
18306
|
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
|
|
@@ -18418,56 +18461,57 @@ function setAutoShrinkDebug(enabled) {
|
|
|
18418
18461
|
}
|
|
18419
18462
|
export {
|
|
18420
18463
|
API_URL as A,
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18424
|
-
|
|
18464
|
+
collectImageUrls as B,
|
|
18465
|
+
configHasAutoShrinkText$1 as C,
|
|
18466
|
+
dumpSvgTextDiagnostics as D,
|
|
18467
|
+
embedFont as E,
|
|
18425
18468
|
FONT_FALLBACK_DEVANAGARI as F,
|
|
18426
|
-
|
|
18427
|
-
|
|
18428
|
-
|
|
18429
|
-
|
|
18430
|
-
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
18434
|
-
|
|
18469
|
+
embedFontsForConfig as G,
|
|
18470
|
+
embedFontsInPdf as H,
|
|
18471
|
+
ensureFontsForResolvedConfig as I,
|
|
18472
|
+
extractFontFamiliesFromSvgs as J,
|
|
18473
|
+
getEmbeddedJsPDFFontName as K,
|
|
18474
|
+
isBundledAssetUrl as L,
|
|
18475
|
+
isFontAvailable as M,
|
|
18476
|
+
isPrivateUrl as N,
|
|
18477
|
+
loadGoogleFontCSS as O,
|
|
18435
18478
|
PACKAGE_VERSION as P,
|
|
18436
|
-
|
|
18437
|
-
|
|
18438
|
-
|
|
18479
|
+
normalizeFontFamily as Q,
|
|
18480
|
+
resolveFontWeight as R,
|
|
18481
|
+
resolveFromForm as S,
|
|
18439
18482
|
TRIANGLE_STROKE_MITER_LIMIT as T,
|
|
18440
|
-
|
|
18441
|
-
|
|
18442
|
-
|
|
18443
|
-
|
|
18444
|
-
|
|
18445
|
-
|
|
18483
|
+
resolveTemplateData as U,
|
|
18484
|
+
rewriteSvgFontsForJsPDF as V,
|
|
18485
|
+
setAutoShrinkDebug as W,
|
|
18486
|
+
setBundledAssetPrefixes as X,
|
|
18487
|
+
warmResolvedTemplateForPreview as Y,
|
|
18488
|
+
warmTemplateFromForm as Z,
|
|
18489
|
+
canvasImageLoader as _,
|
|
18446
18490
|
getAbsoluteBounds as a,
|
|
18447
18491
|
getProxiedImageUrl as b,
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18492
|
+
captureFabricCanvasSvgForPdf as c,
|
|
18493
|
+
bakeEdgeFade as d,
|
|
18494
|
+
isGroup as e,
|
|
18451
18495
|
findNodeById as f,
|
|
18452
18496
|
getCanvasForPage as g,
|
|
18453
18497
|
hasEdgeFade as h,
|
|
18454
18498
|
isElement as i,
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
|
|
18458
|
-
|
|
18499
|
+
buildRoundedTrianglePath as j,
|
|
18500
|
+
getImageProxyFetchOptions as k,
|
|
18501
|
+
getRoundedRectRadii as l,
|
|
18502
|
+
getTrianglePoints as m,
|
|
18459
18503
|
normalizeShapeType as n,
|
|
18460
|
-
|
|
18504
|
+
FONT_FALLBACK_MATH as o,
|
|
18461
18505
|
parseTextMarkdown as p,
|
|
18462
|
-
|
|
18506
|
+
FONT_FALLBACK_SYMBOLS as q,
|
|
18463
18507
|
renderSmartElementToSvg as r,
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
|
|
18468
|
-
|
|
18469
|
-
|
|
18470
|
-
|
|
18471
|
-
|
|
18508
|
+
FONT_FILES as s,
|
|
18509
|
+
PixldocsPreview as t,
|
|
18510
|
+
PixldocsRenderer as u,
|
|
18511
|
+
applyThemeToConfig as v,
|
|
18512
|
+
assemblePdfFromSvgs as w,
|
|
18513
|
+
awaitFontsForConfig as x,
|
|
18514
|
+
collectFontDescriptorsFromConfig as y,
|
|
18515
|
+
collectFontsFromConfig as z
|
|
18472
18516
|
};
|
|
18473
|
-
//# sourceMappingURL=index-
|
|
18517
|
+
//# sourceMappingURL=index-DAeQbGws.js.map
|