@pixldocs/canvas-renderer 0.5.124 → 0.5.126
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-DpsVjlDU.cjs → index-8Dj3s-9A.cjs} +127 -82
- package/dist/index-8Dj3s-9A.cjs.map +1 -0
- package/dist/{index-HIMi3Y6V.js → index-D-lngEWM.js} +166 -121
- package/dist/index-D-lngEWM.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/{vectorPdfExport-DzfRoSxz.cjs → vectorPdfExport-DSf_ziXM.cjs} +9 -16
- package/dist/vectorPdfExport-DSf_ziXM.cjs.map +1 -0
- package/dist/{vectorPdfExport-CWJRsyl0.js → vectorPdfExport-ix7Z1pGO.js} +9 -16
- package/dist/vectorPdfExport-ix7Z1pGO.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-DpsVjlDU.cjs.map +0 -1
- package/dist/index-HIMi3Y6V.js.map +0 -1
- package/dist/vectorPdfExport-CWJRsyl0.js.map +0 -1
- package/dist/vectorPdfExport-DzfRoSxz.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.126";
|
|
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-ix7Z1pGO.js");
|
|
16065
16186
|
const prepared = preparePagesForExport(
|
|
16066
16187
|
cloned.pages,
|
|
16067
16188
|
canvasWidth,
|
|
@@ -16539,88 +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 isFadedCropGroup = obj instanceof fabric.Group && (Boolean(obj.__edgeFadeRenderConfig) || Boolean(obj.__edgeFadeKey) || Boolean(obj.__edgeFadeInputKey));
|
|
16559
|
-
if (!isFadedCropGroup) continue;
|
|
16560
|
-
try {
|
|
16561
|
-
const baked = obj.toCanvasElement({
|
|
16562
|
-
multiplier: 2,
|
|
16563
|
-
enableRetinaScaling: false
|
|
16564
|
-
});
|
|
16565
|
-
const rect = obj.getBoundingRect();
|
|
16566
|
-
const replacement = new fabric.FabricImage(baked, {
|
|
16567
|
-
left: rect.left,
|
|
16568
|
-
top: rect.top,
|
|
16569
|
-
originX: "left",
|
|
16570
|
-
originY: "top",
|
|
16571
|
-
scaleX: rect.width / baked.width,
|
|
16572
|
-
scaleY: rect.height / baked.height,
|
|
16573
|
-
selectable: false,
|
|
16574
|
-
evented: false,
|
|
16575
|
-
objectCaching: false
|
|
16576
|
-
});
|
|
16577
|
-
const insertIndex = fabricInstance._objects.indexOf(obj);
|
|
16578
|
-
const prevExclude = obj.excludeFromExport;
|
|
16579
|
-
obj.excludeFromExport = true;
|
|
16580
|
-
if (insertIndex >= 0) {
|
|
16581
|
-
fabricInstance.insertAt(insertIndex + 1, replacement);
|
|
16582
|
-
} else {
|
|
16583
|
-
fabricInstance.add(replacement);
|
|
16584
|
-
}
|
|
16585
|
-
fadeBakeRecords.push({
|
|
16586
|
-
original: obj,
|
|
16587
|
-
replacement,
|
|
16588
|
-
prevExclude,
|
|
16589
|
-
insertIndex
|
|
16590
|
-
});
|
|
16591
|
-
} catch (bakeErr) {
|
|
16592
|
-
console.warn("[canvas-renderer][edgeFade] bake-for-svg failed:", bakeErr);
|
|
16593
|
-
}
|
|
16594
|
-
}
|
|
16595
|
-
if (fadeBakeRecords.length) {
|
|
16596
|
-
fabricInstance.renderAll();
|
|
16597
|
-
console.log(
|
|
16598
|
-
`[canvas-renderer][edgeFade] baked ${fadeBakeRecords.length} faded object(s) for SVG capture`
|
|
16599
|
-
);
|
|
16600
|
-
}
|
|
16601
|
-
} catch (e) {
|
|
16602
|
-
console.warn("[canvas-renderer][edgeFade] bake pass failed:", e);
|
|
16603
|
-
}
|
|
16604
|
-
const rawSvgString = fabricInstance.toSVG();
|
|
16605
|
-
const svgString = this.normalizeSvgDimensions(
|
|
16606
|
-
rawSvgString,
|
|
16663
|
+
const svgString = captureFabricCanvasSvgForPdf(
|
|
16664
|
+
fabricInstance,
|
|
16607
16665
|
canvasWidth,
|
|
16608
16666
|
canvasHeight
|
|
16609
16667
|
);
|
|
16610
|
-
for (const rec of fadeBakeRecords) {
|
|
16611
|
-
try {
|
|
16612
|
-
fabricInstance.remove(rec.replacement);
|
|
16613
|
-
rec.original.excludeFromExport = rec.prevExclude;
|
|
16614
|
-
} catch {
|
|
16615
|
-
}
|
|
16616
|
-
}
|
|
16617
|
-
fabricInstance.enableRetinaScaling = prevRetina;
|
|
16618
|
-
fabricInstance.setDimensions(
|
|
16619
|
-
{ width: prevWidth, height: prevHeight },
|
|
16620
|
-
{ cssOnly: false, backstoreOnly: false }
|
|
16621
|
-
);
|
|
16622
|
-
if (prevVPT) fabricInstance.viewportTransform = prevVPT;
|
|
16623
|
-
fabricInstance.svgViewportTransformation = prevSvgVPT;
|
|
16624
16668
|
const page = renderConfig.pages[pageIndex];
|
|
16625
16669
|
const backgroundColor = ((_a = page == null ? void 0 : page.settings) == null ? void 0 : _a.backgroundColor) || "#ffffff";
|
|
16626
16670
|
const backgroundGradient = (_b = page == null ? void 0 : page.settings) == null ? void 0 : _b.backgroundGradient;
|
|
@@ -18417,56 +18461,57 @@ function setAutoShrinkDebug(enabled) {
|
|
|
18417
18461
|
}
|
|
18418
18462
|
export {
|
|
18419
18463
|
API_URL as A,
|
|
18420
|
-
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18464
|
+
collectImageUrls as B,
|
|
18465
|
+
configHasAutoShrinkText$1 as C,
|
|
18466
|
+
dumpSvgTextDiagnostics as D,
|
|
18467
|
+
embedFont as E,
|
|
18424
18468
|
FONT_FALLBACK_DEVANAGARI as F,
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
|
|
18428
|
-
|
|
18429
|
-
|
|
18430
|
-
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
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,
|
|
18434
18478
|
PACKAGE_VERSION as P,
|
|
18435
|
-
|
|
18436
|
-
|
|
18437
|
-
|
|
18479
|
+
normalizeFontFamily as Q,
|
|
18480
|
+
resolveFontWeight as R,
|
|
18481
|
+
resolveFromForm as S,
|
|
18438
18482
|
TRIANGLE_STROKE_MITER_LIMIT as T,
|
|
18439
|
-
|
|
18440
|
-
|
|
18441
|
-
|
|
18442
|
-
|
|
18443
|
-
|
|
18444
|
-
|
|
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 _,
|
|
18445
18490
|
getAbsoluteBounds as a,
|
|
18446
18491
|
getProxiedImageUrl as b,
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18492
|
+
captureFabricCanvasSvgForPdf as c,
|
|
18493
|
+
bakeEdgeFade as d,
|
|
18494
|
+
isGroup as e,
|
|
18450
18495
|
findNodeById as f,
|
|
18451
18496
|
getCanvasForPage as g,
|
|
18452
18497
|
hasEdgeFade as h,
|
|
18453
18498
|
isElement as i,
|
|
18454
|
-
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
|
|
18499
|
+
buildRoundedTrianglePath as j,
|
|
18500
|
+
getImageProxyFetchOptions as k,
|
|
18501
|
+
getRoundedRectRadii as l,
|
|
18502
|
+
getTrianglePoints as m,
|
|
18458
18503
|
normalizeShapeType as n,
|
|
18459
|
-
|
|
18504
|
+
FONT_FALLBACK_MATH as o,
|
|
18460
18505
|
parseTextMarkdown as p,
|
|
18461
|
-
|
|
18506
|
+
FONT_FALLBACK_SYMBOLS as q,
|
|
18462
18507
|
renderSmartElementToSvg as r,
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
|
|
18468
|
-
|
|
18469
|
-
|
|
18470
|
-
|
|
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
|
|
18471
18516
|
};
|
|
18472
|
-
//# sourceMappingURL=index-
|
|
18517
|
+
//# sourceMappingURL=index-D-lngEWM.js.map
|