@pixldocs/canvas-renderer 0.5.168 → 0.5.170

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.
@@ -6374,6 +6374,8 @@ function createText(element) {
6374
6374
  const fixedWidth = Math.max(baseWidth, 1);
6375
6375
  const splitByGrapheme = overflowPolicy === "auto-shrink" ? false : element.splitByGrapheme ?? element.wordWrap === "break-word";
6376
6376
  if (overflowPolicy === "auto-shrink") {
6377
+ const minBoxHForShrink = Math.max(0, Number(element.minBoxHeight) || 0);
6378
+ const heightBound = Math.max(baseHeight || 0, minBoxHForShrink);
6377
6379
  const explicitLineCount = Math.max(1, text.split("\n").length);
6378
6380
  const debugAutoShrink = typeof window !== "undefined" && window.__pixldocsDebugAutoShrink === true;
6379
6381
  const startFontSize = fontSize;
@@ -6396,7 +6398,7 @@ function createText(element) {
6396
6398
  const textHeight = testTextbox.height || 0;
6397
6399
  const renderedLineCount = ((_a = testTextbox.textLines) == null ? void 0 : _a.length) || 1;
6398
6400
  const hasNoImplicitWrap = renderedLineCount <= explicitLineCount;
6399
- const fitsHeight = !baseHeight || textHeight <= baseHeight;
6401
+ const fitsHeight = heightBound <= 0 || textHeight <= heightBound;
6400
6402
  const widthMetrics = getTextboxWidthFitMetrics(testTextbox, fixedWidth);
6401
6403
  const { maxLineWidth, widthDidGrow, fitsWidth } = widthMetrics;
6402
6404
  if (debugAutoShrink) {
@@ -15768,6 +15770,20 @@ function paintRepeatableSections(config, repeatableSections) {
15768
15770
  }
15769
15771
  }
15770
15772
  const PREVIEW_DEBUG_PREFIX = "[canvas-renderer][preview-debug]";
15773
+ function computeFontSignature(config) {
15774
+ var _a;
15775
+ if (!((_a = config == null ? void 0 : config.pages) == null ? void 0 : _a.length)) return "";
15776
+ const fams = /* @__PURE__ */ new Set();
15777
+ const walk = (nodes) => {
15778
+ var _a2;
15779
+ for (const node of nodes || []) {
15780
+ if (node == null ? void 0 : node.fontFamily) fams.add(String(node.fontFamily));
15781
+ if ((_a2 = node == null ? void 0 : node.children) == null ? void 0 : _a2.length) walk(node.children);
15782
+ }
15783
+ };
15784
+ for (const page of config.pages) walk(page.children || []);
15785
+ return Array.from(fams).sort().join("|");
15786
+ }
15771
15787
  function countUnderlinedNodes(config) {
15772
15788
  var _a;
15773
15789
  if (!((_a = config == null ? void 0 : config.pages) == null ? void 0 : _a.length)) return 0;
@@ -15886,6 +15902,7 @@ function PixldocsPreview(props) {
15886
15902
  ]);
15887
15903
  const config = isResolveMode ? resolvedConfig : props.config;
15888
15904
  const previewKey = react.useMemo(() => `${pageIndex}`, [pageIndex]);
15905
+ const fontSignature = react.useMemo(() => computeFontSignature(config), [config]);
15889
15906
  react.useEffect(() => {
15890
15907
  if (isResolveMode) return;
15891
15908
  if (!config) {
@@ -15915,7 +15932,7 @@ function PixldocsPreview(props) {
15915
15932
  return () => {
15916
15933
  cancelled = true;
15917
15934
  };
15918
- }, [isResolveMode, config]);
15935
+ }, [isResolveMode, fontSignature]);
15919
15936
  const handleCanvasReady = react.useCallback(() => {
15920
15937
  console.log(PREVIEW_DEBUG_PREFIX, "canvas-ready", { pageIndex, action: "settled" });
15921
15938
  setCanvasSettled(true);
@@ -16118,9 +16135,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
16118
16135
  }
16119
16136
  return svgString;
16120
16137
  }
16121
- const resolvedPackageVersion = "0.5.168";
16138
+ const resolvedPackageVersion = "0.5.170";
16122
16139
  const PACKAGE_VERSION = resolvedPackageVersion;
16123
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.168";
16140
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.170";
16124
16141
  const roundParityValue = (value) => {
16125
16142
  if (typeof value !== "number") return value;
16126
16143
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -16618,7 +16635,7 @@ class PixldocsRenderer {
16618
16635
  await this.waitForCanvasScene(container, cloned, i);
16619
16636
  }
16620
16637
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
16621
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Bw2WQNoU.cjs"));
16638
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BnFtIh0l.cjs"));
16622
16639
  const prepared = preparePagesForExport(
16623
16640
  cloned.pages,
16624
16641
  canvasWidth,
@@ -18720,7 +18737,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
18720
18737
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
18721
18738
  sanitizeSvgTreeForPdf(svgToDraw);
18722
18739
  try {
18723
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Bw2WQNoU.cjs"));
18740
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BnFtIh0l.cjs"));
18724
18741
  try {
18725
18742
  await logTextMeasurementDiagnostic(svgToDraw);
18726
18743
  } catch {
@@ -19119,4 +19136,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
19119
19136
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
19120
19137
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
19121
19138
  exports.warmTemplateFromForm = warmTemplateFromForm;
19122
- //# sourceMappingURL=index-DgX2Y94P.cjs.map
19139
+ //# sourceMappingURL=index-CtWVrKc-.cjs.map