@pixldocs/canvas-renderer 0.5.175 → 0.5.177
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-DOxhZsjV.cjs → index-CF9NOy22.cjs} +35 -37
- package/dist/index-CF9NOy22.cjs.map +1 -0
- package/dist/{index-CTIPncpy.js → index-Db_mrNdt.js} +35 -37
- package/dist/index-Db_mrNdt.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{svgTextToPath-ra4EhtBL.js → svgTextToPath-BoT6H7Lz.js} +12 -2
- package/dist/svgTextToPath-BoT6H7Lz.js.map +1 -0
- package/dist/{svgTextToPath-BLk_mcqi.cjs → svgTextToPath-hYM9qTeC.cjs} +12 -2
- package/dist/svgTextToPath-hYM9qTeC.cjs.map +1 -0
- package/dist/{vectorPdfExport-COqBgUXt.js → vectorPdfExport-CvOixt-O.js} +6 -22
- package/dist/{vectorPdfExport-COqBgUXt.js.map → vectorPdfExport-CvOixt-O.js.map} +1 -1
- package/dist/{vectorPdfExport-BZAl0Pdr.cjs → vectorPdfExport-ztZqqhey.cjs} +6 -22
- package/dist/{vectorPdfExport-BZAl0Pdr.cjs.map → vectorPdfExport-ztZqqhey.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-CTIPncpy.js.map +0 -1
- package/dist/index-DOxhZsjV.cjs.map +0 -1
- package/dist/svgTextToPath-BLk_mcqi.cjs.map +0 -1
- package/dist/svgTextToPath-ra4EhtBL.js.map +0 -1
|
@@ -3206,8 +3206,8 @@ const clearFabricCharCache = () => {
|
|
|
3206
3206
|
fabric.util.clearFabricFontCache();
|
|
3207
3207
|
}
|
|
3208
3208
|
};
|
|
3209
|
-
const clearFontCacheAndRerender = (canvas) => {
|
|
3210
|
-
clearFabricCharCache();
|
|
3209
|
+
const clearFontCacheAndRerender = (canvas, options = {}) => {
|
|
3210
|
+
if (options.clearGlobalCharCache !== false) clearFabricCharCache();
|
|
3211
3211
|
const logUnderlineDebug = (stage, payload) => {
|
|
3212
3212
|
try {
|
|
3213
3213
|
console.log(`[canvas-renderer][underline-debug] ${stage} ${JSON.stringify(payload)}`);
|
|
@@ -3298,9 +3298,9 @@ const ensureFontLoaded = async (fontFamily) => {
|
|
|
3298
3298
|
} catch {
|
|
3299
3299
|
}
|
|
3300
3300
|
};
|
|
3301
|
-
const setupFontLoadingListener = (canvas, afterRerender) => {
|
|
3301
|
+
const setupFontLoadingListener = (canvas, afterRerender, options = {}) => {
|
|
3302
3302
|
const handleFontLoad = () => {
|
|
3303
|
-
clearFontCacheAndRerender(canvas);
|
|
3303
|
+
clearFontCacheAndRerender(canvas, options);
|
|
3304
3304
|
afterRerender == null ? void 0 : afterRerender(canvas);
|
|
3305
3305
|
};
|
|
3306
3306
|
if (document.fonts) {
|
|
@@ -7360,6 +7360,7 @@ const PageCanvas = forwardRef(
|
|
|
7360
7360
|
canvasUpdateVersion = 0,
|
|
7361
7361
|
pageChildren,
|
|
7362
7362
|
skipFontReadyWait = false,
|
|
7363
|
+
preserveGlobalFontCache = false,
|
|
7363
7364
|
onReady
|
|
7364
7365
|
}, ref) => {
|
|
7365
7366
|
setMarkdownThemeColors({
|
|
@@ -7597,6 +7598,10 @@ const PageCanvas = forwardRef(
|
|
|
7597
7598
|
const id = getObjectId(obj);
|
|
7598
7599
|
const element = id ? elementById.get(id) : void 0;
|
|
7599
7600
|
if (!element) return;
|
|
7601
|
+
if (element.overflowPolicy === "auto-shrink") {
|
|
7602
|
+
obj.dirty = true;
|
|
7603
|
+
return;
|
|
7604
|
+
}
|
|
7600
7605
|
const targetWidth = Math.max(1, Number(element.width) > 0 ? Number(element.width) : Number(obj.width ?? 200));
|
|
7601
7606
|
const overflowPolicy = element.overflowPolicy || "grow-and-push";
|
|
7602
7607
|
const splitByGrapheme = overflowPolicy === "auto-shrink" ? false : element.splitByGrapheme ?? element.wordWrap === "break-word";
|
|
@@ -7725,7 +7730,7 @@ const PageCanvas = forwardRef(
|
|
|
7725
7730
|
await waitUntilFontsAvailable(fontFamilies, { timeoutMs: 3500, pollIntervalMs: 60 });
|
|
7726
7731
|
await new Promise((r) => requestAnimationFrame(() => r()));
|
|
7727
7732
|
}
|
|
7728
|
-
clearFabricCharCache();
|
|
7733
|
+
if (!preserveGlobalFontCache) clearFabricCharCache();
|
|
7729
7734
|
clearMeasurementCache();
|
|
7730
7735
|
setReady(true);
|
|
7731
7736
|
} catch (e) {
|
|
@@ -7764,7 +7769,11 @@ const PageCanvas = forwardRef(
|
|
|
7764
7769
|
}
|
|
7765
7770
|
});
|
|
7766
7771
|
};
|
|
7767
|
-
const fontCleanup = setupFontLoadingListener(
|
|
7772
|
+
const fontCleanup = setupFontLoadingListener(
|
|
7773
|
+
fabricCanvas,
|
|
7774
|
+
persistTextDimensionsAfterFontLoad,
|
|
7775
|
+
{ clearGlobalCharCache: !preserveGlobalFontCache }
|
|
7776
|
+
);
|
|
7768
7777
|
fabricCanvas.__fontCleanup = fontCleanup;
|
|
7769
7778
|
fabricCanvas.__isUserTransforming = false;
|
|
7770
7779
|
fabricCanvas.on("mouse:down", () => {
|
|
@@ -9764,7 +9773,7 @@ const PageCanvas = forwardRef(
|
|
|
9764
9773
|
pendingSyncRef.current = false;
|
|
9765
9774
|
if (ready && !hasClearedCachesBeforeFirstSyncRef.current) {
|
|
9766
9775
|
hasClearedCachesBeforeFirstSyncRef.current = true;
|
|
9767
|
-
clearFabricCharCache();
|
|
9776
|
+
if (!preserveGlobalFontCache) clearFabricCharCache();
|
|
9768
9777
|
clearMeasurementCache();
|
|
9769
9778
|
}
|
|
9770
9779
|
doSyncRef.current();
|
|
@@ -9848,7 +9857,7 @@ const PageCanvas = forwardRef(
|
|
|
9848
9857
|
const runReflowAndPersist = () => {
|
|
9849
9858
|
const fc = fabricRef.current;
|
|
9850
9859
|
if (!fc || cancelled) return;
|
|
9851
|
-
clearFontCacheAndRerender(fc);
|
|
9860
|
+
clearFontCacheAndRerender(fc, { clearGlobalCharCache: !preserveGlobalFontCache });
|
|
9852
9861
|
const state = useEditorStore.getState();
|
|
9853
9862
|
const page = state.canvas.pages.find((p) => p.id === pageId);
|
|
9854
9863
|
if (page) {
|
|
@@ -11425,6 +11434,7 @@ function PreviewCanvas({
|
|
|
11425
11434
|
zoom = 1,
|
|
11426
11435
|
absoluteZoom = false,
|
|
11427
11436
|
skipFontReadyWait = false,
|
|
11437
|
+
preserveGlobalFontCache = false,
|
|
11428
11438
|
pageIdOverride,
|
|
11429
11439
|
className,
|
|
11430
11440
|
onDynamicFieldClick,
|
|
@@ -11587,6 +11597,7 @@ function PreviewCanvas({
|
|
|
11587
11597
|
activeTool: "select",
|
|
11588
11598
|
mode: "preview",
|
|
11589
11599
|
skipFontReadyWait,
|
|
11600
|
+
preserveGlobalFontCache,
|
|
11590
11601
|
dynamicFieldIds,
|
|
11591
11602
|
onDynamicFieldClick: handleDynamicFieldClick,
|
|
11592
11603
|
onReady
|
|
@@ -16331,9 +16342,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16331
16342
|
}
|
|
16332
16343
|
return svgString;
|
|
16333
16344
|
}
|
|
16334
|
-
const resolvedPackageVersion = "0.5.
|
|
16345
|
+
const resolvedPackageVersion = "0.5.177";
|
|
16335
16346
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16336
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16347
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.177";
|
|
16337
16348
|
const roundParityValue = (value) => {
|
|
16338
16349
|
if (typeof value !== "number") return value;
|
|
16339
16350
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16820,6 +16831,7 @@ class PixldocsRenderer {
|
|
|
16820
16831
|
zoom: 1,
|
|
16821
16832
|
absoluteZoom: true,
|
|
16822
16833
|
skipFontReadyWait: false,
|
|
16834
|
+
preserveGlobalFontCache: true,
|
|
16823
16835
|
onReady: () => {
|
|
16824
16836
|
clearTimeout(timer);
|
|
16825
16837
|
resolve();
|
|
@@ -16834,7 +16846,7 @@ class PixldocsRenderer {
|
|
|
16834
16846
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16835
16847
|
}
|
|
16836
16848
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16837
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
16849
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CvOixt-O.js");
|
|
16838
16850
|
const prepared = preparePagesForExport(
|
|
16839
16851
|
cloned.pages,
|
|
16840
16852
|
canvasWidth,
|
|
@@ -17217,6 +17229,7 @@ class PixldocsRenderer {
|
|
|
17217
17229
|
zoom: pixelRatio,
|
|
17218
17230
|
absoluteZoom: true,
|
|
17219
17231
|
skipFontReadyWait: false,
|
|
17232
|
+
preserveGlobalFontCache: true,
|
|
17220
17233
|
onReady: onReadyOnce
|
|
17221
17234
|
})
|
|
17222
17235
|
);
|
|
@@ -17277,6 +17290,7 @@ class PixldocsRenderer {
|
|
|
17277
17290
|
zoom: pixelRatio,
|
|
17278
17291
|
absoluteZoom: true,
|
|
17279
17292
|
skipFontReadyWait: false,
|
|
17293
|
+
preserveGlobalFontCache: true,
|
|
17280
17294
|
onReady
|
|
17281
17295
|
})
|
|
17282
17296
|
);
|
|
@@ -17328,6 +17342,7 @@ class PixldocsRenderer {
|
|
|
17328
17342
|
zoom: 1,
|
|
17329
17343
|
absoluteZoom: true,
|
|
17330
17344
|
skipFontReadyWait: false,
|
|
17345
|
+
preserveGlobalFontCache: true,
|
|
17331
17346
|
onReady: readyHandler
|
|
17332
17347
|
})
|
|
17333
17348
|
);
|
|
@@ -18972,7 +18987,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18972
18987
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18973
18988
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18974
18989
|
try {
|
|
18975
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
18990
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CvOixt-O.js");
|
|
18976
18991
|
try {
|
|
18977
18992
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18978
18993
|
} catch {
|
|
@@ -19094,8 +19109,6 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
19094
19109
|
drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
|
|
19095
19110
|
const shouldStripBg = stripPageBackground ?? hasGradient;
|
|
19096
19111
|
const textMode = options.textMode ?? (options.outlineText === true ? "pixel-perfect" : "selectable");
|
|
19097
|
-
const shouldOutlineText = textMode === "pixel-perfect" || textMode === "auto";
|
|
19098
|
-
const outlineSubMode = textMode === "pixel-perfect" ? "all" : "gradient-only";
|
|
19099
19112
|
let pageSvg = page.svg;
|
|
19100
19113
|
try {
|
|
19101
19114
|
pageSvg = await convertSvgTextDecorationsToLinesString(pageSvg);
|
|
@@ -19105,30 +19118,15 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
19105
19118
|
underlineErr
|
|
19106
19119
|
);
|
|
19107
19120
|
}
|
|
19108
|
-
|
|
19109
|
-
|
|
19110
|
-
|
|
19111
|
-
pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
|
|
19112
|
-
try {
|
|
19113
|
-
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
|
|
19114
|
-
} catch {
|
|
19115
|
-
}
|
|
19116
|
-
} catch (outlineErr) {
|
|
19117
|
-
console.warn(
|
|
19118
|
-
"[canvas-renderer][pdf] raw-stage text outlining unavailable, falling back to embedded SVG text:",
|
|
19119
|
-
outlineErr
|
|
19120
|
-
);
|
|
19121
|
-
}
|
|
19122
|
-
} else {
|
|
19121
|
+
try {
|
|
19122
|
+
const { prepareSvgTextForPdfMode } = await import("./svgTextToPath-BoT6H7Lz.js");
|
|
19123
|
+
pageSvg = await prepareSvgTextForPdfMode(pageSvg, textMode, fontBaseUrl);
|
|
19123
19124
|
try {
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
} catch (gradErr) {
|
|
19127
|
-
console.warn(
|
|
19128
|
-
"[canvas-renderer][pdf] gradient-text fill resolution failed:",
|
|
19129
|
-
gradErr
|
|
19130
|
-
);
|
|
19125
|
+
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-shared-text-prep");
|
|
19126
|
+
} catch {
|
|
19131
19127
|
}
|
|
19128
|
+
} catch (textPrepErr) {
|
|
19129
|
+
console.warn("[canvas-renderer][pdf] shared text prep failed:", textPrepErr);
|
|
19132
19130
|
}
|
|
19133
19131
|
let processedSvg = await prepareLiveCanvasSvgForPdf(pageSvg, page.width, page.height, `page-${i + 1}`, {
|
|
19134
19132
|
stripPageBackground: shouldStripBg
|
|
@@ -19385,4 +19383,4 @@ export {
|
|
|
19385
19383
|
collectFontDescriptorsFromConfig as y,
|
|
19386
19384
|
collectFontsFromConfig as z
|
|
19387
19385
|
};
|
|
19388
|
-
//# sourceMappingURL=index-
|
|
19386
|
+
//# sourceMappingURL=index-Db_mrNdt.js.map
|