@pixldocs/canvas-renderer 0.5.134 → 0.5.135

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.
@@ -14633,6 +14633,26 @@ function normalizeFontFamily(fontStack) {
14633
14633
  const loadedFonts = /* @__PURE__ */ new Set();
14634
14634
  const loadingPromises = /* @__PURE__ */ new Map();
14635
14635
  const registeredLocalFontFaces = /* @__PURE__ */ new Set();
14636
+ let localFontFaceStyleEl = null;
14637
+ function ensureLocalFontFaceStyle() {
14638
+ if (typeof document === "undefined") return null;
14639
+ if (localFontFaceStyleEl && localFontFaceStyleEl.isConnected) return localFontFaceStyleEl;
14640
+ try {
14641
+ localFontFaceStyleEl = document.createElement("style");
14642
+ localFontFaceStyleEl.setAttribute("data-pixldocs-local-fontfaces", "1");
14643
+ document.head.appendChild(localFontFaceStyleEl);
14644
+ return localFontFaceStyleEl;
14645
+ } catch {
14646
+ return null;
14647
+ }
14648
+ }
14649
+ function appendLocalFontFaceRule(family, weight, style, file) {
14650
+ const styleEl = ensureLocalFontFaceStyle();
14651
+ if (!styleEl) return;
14652
+ const cssText = `@font-face{font-family:"${family}";src:url("/fonts/${file}");font-weight:${weight};font-style:${style};font-display:swap;}
14653
+ `;
14654
+ styleEl.appendChild(document.createTextNode(cssText));
14655
+ }
14636
14656
  const LOCAL_FONT_FACE_VARIANTS = [
14637
14657
  { key: "regular", weight: 400, style: "normal" },
14638
14658
  { key: "bold", weight: 700, style: "normal" },
@@ -14662,6 +14682,7 @@ async function registerLocalFontFaces(fontFamily) {
14662
14682
  style: variant.style
14663
14683
  });
14664
14684
  document.fonts.add(face);
14685
+ appendLocalFontFaceRule(fontFamily, variant.weight, variant.style, file);
14665
14686
  loads.push(face.load().catch(() => void 0));
14666
14687
  } catch {
14667
14688
  }
@@ -15813,7 +15834,7 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
15813
15834
  }
15814
15835
  return svgString;
15815
15836
  }
15816
- const PACKAGE_VERSION = "0.5.131";
15837
+ const PACKAGE_VERSION = "0.5.135";
15817
15838
  const roundParityValue = (value) => {
15818
15839
  if (typeof value !== "number") return value;
15819
15840
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -16232,7 +16253,7 @@ class PixldocsRenderer {
16232
16253
  await this.waitForCanvasScene(container, cloned, i);
16233
16254
  }
16234
16255
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
16235
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-8Q3O7Z_Q.cjs"));
16256
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DFgDiZck.cjs"));
16236
16257
  const prepared = preparePagesForExport(
16237
16258
  cloned.pages,
16238
16259
  canvasWidth,
@@ -18135,7 +18156,6 @@ function rasterSvgToPngDataUrl(svgMarkup, pxW, pxH) {
18135
18156
  const blob = new Blob([svgMarkup], { type: "image/svg+xml;charset=utf-8" });
18136
18157
  const url = URL.createObjectURL(blob);
18137
18158
  const img = new Image();
18138
- img.crossOrigin = "anonymous";
18139
18159
  const cleanup = () => {
18140
18160
  try {
18141
18161
  URL.revokeObjectURL(url);
@@ -18153,6 +18173,7 @@ function rasterSvgToPngDataUrl(svgMarkup, pxW, pxH) {
18153
18173
  resolve(null);
18154
18174
  return;
18155
18175
  }
18176
+ ctx.clearRect(0, 0, pxW, pxH);
18156
18177
  ctx.drawImage(img, 0, 0, pxW, pxH);
18157
18178
  const dataUrl = canvas.toDataURL("image/png");
18158
18179
  cleanup();
@@ -18324,7 +18345,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
18324
18345
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
18325
18346
  sanitizeSvgTreeForPdf(svgToDraw);
18326
18347
  try {
18327
- const { bakeTextAnchorPositionsFromLiveSvg } = await Promise.resolve().then(() => require("./vectorPdfExport-8Q3O7Z_Q.cjs"));
18348
+ const { bakeTextAnchorPositionsFromLiveSvg } = await Promise.resolve().then(() => require("./vectorPdfExport-DFgDiZck.cjs"));
18328
18349
  await bakeTextAnchorPositionsFromLiveSvg(svgToDraw);
18329
18350
  } catch (e) {
18330
18351
  console.warn("[canvas-renderer][pdf-export] anchor-bake pass failed (continuing):", e);
@@ -18666,4 +18687,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
18666
18687
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
18667
18688
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
18668
18689
  exports.warmTemplateFromForm = warmTemplateFromForm;
18669
- //# sourceMappingURL=index-DmqoeVsF.cjs.map
18690
+ //# sourceMappingURL=index-BCvB875s.cjs.map