@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
|
@@ -3224,8 +3224,8 @@ const clearFabricCharCache = () => {
|
|
|
3224
3224
|
fabric__namespace.util.clearFabricFontCache();
|
|
3225
3225
|
}
|
|
3226
3226
|
};
|
|
3227
|
-
const clearFontCacheAndRerender = (canvas) => {
|
|
3228
|
-
clearFabricCharCache();
|
|
3227
|
+
const clearFontCacheAndRerender = (canvas, options = {}) => {
|
|
3228
|
+
if (options.clearGlobalCharCache !== false) clearFabricCharCache();
|
|
3229
3229
|
const logUnderlineDebug = (stage, payload) => {
|
|
3230
3230
|
try {
|
|
3231
3231
|
console.log(`[canvas-renderer][underline-debug] ${stage} ${JSON.stringify(payload)}`);
|
|
@@ -3316,9 +3316,9 @@ const ensureFontLoaded = async (fontFamily) => {
|
|
|
3316
3316
|
} catch {
|
|
3317
3317
|
}
|
|
3318
3318
|
};
|
|
3319
|
-
const setupFontLoadingListener = (canvas, afterRerender) => {
|
|
3319
|
+
const setupFontLoadingListener = (canvas, afterRerender, options = {}) => {
|
|
3320
3320
|
const handleFontLoad = () => {
|
|
3321
|
-
clearFontCacheAndRerender(canvas);
|
|
3321
|
+
clearFontCacheAndRerender(canvas, options);
|
|
3322
3322
|
afterRerender == null ? void 0 : afterRerender(canvas);
|
|
3323
3323
|
};
|
|
3324
3324
|
if (document.fonts) {
|
|
@@ -7378,6 +7378,7 @@ const PageCanvas = react.forwardRef(
|
|
|
7378
7378
|
canvasUpdateVersion = 0,
|
|
7379
7379
|
pageChildren,
|
|
7380
7380
|
skipFontReadyWait = false,
|
|
7381
|
+
preserveGlobalFontCache = false,
|
|
7381
7382
|
onReady
|
|
7382
7383
|
}, ref) => {
|
|
7383
7384
|
setMarkdownThemeColors({
|
|
@@ -7615,6 +7616,10 @@ const PageCanvas = react.forwardRef(
|
|
|
7615
7616
|
const id = getObjectId(obj);
|
|
7616
7617
|
const element = id ? elementById.get(id) : void 0;
|
|
7617
7618
|
if (!element) return;
|
|
7619
|
+
if (element.overflowPolicy === "auto-shrink") {
|
|
7620
|
+
obj.dirty = true;
|
|
7621
|
+
return;
|
|
7622
|
+
}
|
|
7618
7623
|
const targetWidth = Math.max(1, Number(element.width) > 0 ? Number(element.width) : Number(obj.width ?? 200));
|
|
7619
7624
|
const overflowPolicy = element.overflowPolicy || "grow-and-push";
|
|
7620
7625
|
const splitByGrapheme = overflowPolicy === "auto-shrink" ? false : element.splitByGrapheme ?? element.wordWrap === "break-word";
|
|
@@ -7743,7 +7748,7 @@ const PageCanvas = react.forwardRef(
|
|
|
7743
7748
|
await waitUntilFontsAvailable(fontFamilies, { timeoutMs: 3500, pollIntervalMs: 60 });
|
|
7744
7749
|
await new Promise((r) => requestAnimationFrame(() => r()));
|
|
7745
7750
|
}
|
|
7746
|
-
clearFabricCharCache();
|
|
7751
|
+
if (!preserveGlobalFontCache) clearFabricCharCache();
|
|
7747
7752
|
clearMeasurementCache();
|
|
7748
7753
|
setReady(true);
|
|
7749
7754
|
} catch (e) {
|
|
@@ -7782,7 +7787,11 @@ const PageCanvas = react.forwardRef(
|
|
|
7782
7787
|
}
|
|
7783
7788
|
});
|
|
7784
7789
|
};
|
|
7785
|
-
const fontCleanup = setupFontLoadingListener(
|
|
7790
|
+
const fontCleanup = setupFontLoadingListener(
|
|
7791
|
+
fabricCanvas,
|
|
7792
|
+
persistTextDimensionsAfterFontLoad,
|
|
7793
|
+
{ clearGlobalCharCache: !preserveGlobalFontCache }
|
|
7794
|
+
);
|
|
7786
7795
|
fabricCanvas.__fontCleanup = fontCleanup;
|
|
7787
7796
|
fabricCanvas.__isUserTransforming = false;
|
|
7788
7797
|
fabricCanvas.on("mouse:down", () => {
|
|
@@ -9782,7 +9791,7 @@ const PageCanvas = react.forwardRef(
|
|
|
9782
9791
|
pendingSyncRef.current = false;
|
|
9783
9792
|
if (ready && !hasClearedCachesBeforeFirstSyncRef.current) {
|
|
9784
9793
|
hasClearedCachesBeforeFirstSyncRef.current = true;
|
|
9785
|
-
clearFabricCharCache();
|
|
9794
|
+
if (!preserveGlobalFontCache) clearFabricCharCache();
|
|
9786
9795
|
clearMeasurementCache();
|
|
9787
9796
|
}
|
|
9788
9797
|
doSyncRef.current();
|
|
@@ -9866,7 +9875,7 @@ const PageCanvas = react.forwardRef(
|
|
|
9866
9875
|
const runReflowAndPersist = () => {
|
|
9867
9876
|
const fc = fabricRef.current;
|
|
9868
9877
|
if (!fc || cancelled) return;
|
|
9869
|
-
clearFontCacheAndRerender(fc);
|
|
9878
|
+
clearFontCacheAndRerender(fc, { clearGlobalCharCache: !preserveGlobalFontCache });
|
|
9870
9879
|
const state = useEditorStore.getState();
|
|
9871
9880
|
const page = state.canvas.pages.find((p) => p.id === pageId);
|
|
9872
9881
|
if (page) {
|
|
@@ -11443,6 +11452,7 @@ function PreviewCanvas({
|
|
|
11443
11452
|
zoom = 1,
|
|
11444
11453
|
absoluteZoom = false,
|
|
11445
11454
|
skipFontReadyWait = false,
|
|
11455
|
+
preserveGlobalFontCache = false,
|
|
11446
11456
|
pageIdOverride,
|
|
11447
11457
|
className,
|
|
11448
11458
|
onDynamicFieldClick,
|
|
@@ -11605,6 +11615,7 @@ function PreviewCanvas({
|
|
|
11605
11615
|
activeTool: "select",
|
|
11606
11616
|
mode: "preview",
|
|
11607
11617
|
skipFontReadyWait,
|
|
11618
|
+
preserveGlobalFontCache,
|
|
11608
11619
|
dynamicFieldIds,
|
|
11609
11620
|
onDynamicFieldClick: handleDynamicFieldClick,
|
|
11610
11621
|
onReady
|
|
@@ -16349,9 +16360,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16349
16360
|
}
|
|
16350
16361
|
return svgString;
|
|
16351
16362
|
}
|
|
16352
|
-
const resolvedPackageVersion = "0.5.
|
|
16363
|
+
const resolvedPackageVersion = "0.5.177";
|
|
16353
16364
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16354
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16365
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.177";
|
|
16355
16366
|
const roundParityValue = (value) => {
|
|
16356
16367
|
if (typeof value !== "number") return value;
|
|
16357
16368
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16838,6 +16849,7 @@ class PixldocsRenderer {
|
|
|
16838
16849
|
zoom: 1,
|
|
16839
16850
|
absoluteZoom: true,
|
|
16840
16851
|
skipFontReadyWait: false,
|
|
16852
|
+
preserveGlobalFontCache: true,
|
|
16841
16853
|
onReady: () => {
|
|
16842
16854
|
clearTimeout(timer);
|
|
16843
16855
|
resolve();
|
|
@@ -16852,7 +16864,7 @@ class PixldocsRenderer {
|
|
|
16852
16864
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16853
16865
|
}
|
|
16854
16866
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16855
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
16867
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-ztZqqhey.cjs"));
|
|
16856
16868
|
const prepared = preparePagesForExport(
|
|
16857
16869
|
cloned.pages,
|
|
16858
16870
|
canvasWidth,
|
|
@@ -17235,6 +17247,7 @@ class PixldocsRenderer {
|
|
|
17235
17247
|
zoom: pixelRatio,
|
|
17236
17248
|
absoluteZoom: true,
|
|
17237
17249
|
skipFontReadyWait: false,
|
|
17250
|
+
preserveGlobalFontCache: true,
|
|
17238
17251
|
onReady: onReadyOnce
|
|
17239
17252
|
})
|
|
17240
17253
|
);
|
|
@@ -17295,6 +17308,7 @@ class PixldocsRenderer {
|
|
|
17295
17308
|
zoom: pixelRatio,
|
|
17296
17309
|
absoluteZoom: true,
|
|
17297
17310
|
skipFontReadyWait: false,
|
|
17311
|
+
preserveGlobalFontCache: true,
|
|
17298
17312
|
onReady
|
|
17299
17313
|
})
|
|
17300
17314
|
);
|
|
@@ -17346,6 +17360,7 @@ class PixldocsRenderer {
|
|
|
17346
17360
|
zoom: 1,
|
|
17347
17361
|
absoluteZoom: true,
|
|
17348
17362
|
skipFontReadyWait: false,
|
|
17363
|
+
preserveGlobalFontCache: true,
|
|
17349
17364
|
onReady: readyHandler
|
|
17350
17365
|
})
|
|
17351
17366
|
);
|
|
@@ -18990,7 +19005,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18990
19005
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18991
19006
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18992
19007
|
try {
|
|
18993
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
19008
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-ztZqqhey.cjs"));
|
|
18994
19009
|
try {
|
|
18995
19010
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18996
19011
|
} catch {
|
|
@@ -19112,8 +19127,6 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
19112
19127
|
drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
|
|
19113
19128
|
const shouldStripBg = stripPageBackground ?? hasGradient;
|
|
19114
19129
|
const textMode = options.textMode ?? (options.outlineText === true ? "pixel-perfect" : "selectable");
|
|
19115
|
-
const shouldOutlineText = textMode === "pixel-perfect" || textMode === "auto";
|
|
19116
|
-
const outlineSubMode = textMode === "pixel-perfect" ? "all" : "gradient-only";
|
|
19117
19130
|
let pageSvg = page.svg;
|
|
19118
19131
|
try {
|
|
19119
19132
|
pageSvg = await convertSvgTextDecorationsToLinesString(pageSvg);
|
|
@@ -19123,30 +19136,15 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
19123
19136
|
underlineErr
|
|
19124
19137
|
);
|
|
19125
19138
|
}
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
|
|
19130
|
-
try {
|
|
19131
|
-
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
|
|
19132
|
-
} catch {
|
|
19133
|
-
}
|
|
19134
|
-
} catch (outlineErr) {
|
|
19135
|
-
console.warn(
|
|
19136
|
-
"[canvas-renderer][pdf] raw-stage text outlining unavailable, falling back to embedded SVG text:",
|
|
19137
|
-
outlineErr
|
|
19138
|
-
);
|
|
19139
|
-
}
|
|
19140
|
-
} else {
|
|
19139
|
+
try {
|
|
19140
|
+
const { prepareSvgTextForPdfMode } = await Promise.resolve().then(() => require("./svgTextToPath-hYM9qTeC.cjs"));
|
|
19141
|
+
pageSvg = await prepareSvgTextForPdfMode(pageSvg, textMode, fontBaseUrl);
|
|
19141
19142
|
try {
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
} catch (gradErr) {
|
|
19145
|
-
console.warn(
|
|
19146
|
-
"[canvas-renderer][pdf] gradient-text fill resolution failed:",
|
|
19147
|
-
gradErr
|
|
19148
|
-
);
|
|
19143
|
+
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-shared-text-prep");
|
|
19144
|
+
} catch {
|
|
19149
19145
|
}
|
|
19146
|
+
} catch (textPrepErr) {
|
|
19147
|
+
console.warn("[canvas-renderer][pdf] shared text prep failed:", textPrepErr);
|
|
19150
19148
|
}
|
|
19151
19149
|
let processedSvg = await prepareLiveCanvasSvgForPdf(pageSvg, page.width, page.height, `page-${i + 1}`, {
|
|
19152
19150
|
stripPageBackground: shouldStripBg
|
|
@@ -19400,4 +19398,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
19400
19398
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
19401
19399
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
19402
19400
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
19403
|
-
//# sourceMappingURL=index-
|
|
19401
|
+
//# sourceMappingURL=index-CF9NOy22.cjs.map
|