@pixldocs/canvas-renderer 0.5.139 → 0.5.141

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.
@@ -14876,7 +14876,7 @@ function collectFontsFromConfig(config) {
14876
14876
  }
14877
14877
  return fonts;
14878
14878
  }
14879
- function collectFontDescriptorsFromConfig(config) {
14879
+ function collectFontDescriptorsFromConfig(config, includeCommonTextVariants = true) {
14880
14880
  var _a;
14881
14881
  const seen = /* @__PURE__ */ new Set();
14882
14882
  const descriptors = [];
@@ -14896,7 +14896,7 @@ function collectFontDescriptorsFromConfig(config) {
14896
14896
  for (const node of nodes) {
14897
14897
  if (node.fontFamily) {
14898
14898
  add(node.fontFamily, node.fontWeight, node.fontStyle);
14899
- if (node.type === "text") {
14899
+ if (includeCommonTextVariants && node.type === "text") {
14900
14900
  for (const w of [300, 400, 500, 600, 700]) {
14901
14901
  add(node.fontFamily, w, node.fontStyle);
14902
14902
  add(node.fontFamily, w, "italic");
@@ -14956,12 +14956,19 @@ function collectFontDescriptorsFromConfig(config) {
14956
14956
  }
14957
14957
  async function ensureFontsForResolvedConfig(config) {
14958
14958
  if (typeof document === "undefined") return;
14959
- const descriptors = collectFontDescriptorsFromConfig(config);
14959
+ const descriptors = collectFontDescriptorsFromConfig(config, false);
14960
14960
  const families = new Set(descriptors.map((d) => d.family));
14961
- await withTimeout(Promise.all([...families].map((f) => loadGoogleFontCSS(f))), 3500);
14962
- await withTimeout(Promise.all(
14963
- descriptors.map((d) => registerRemoteFontFaceViaProxy(d.family, d.weight, d.style))
14964
- ), 5e3);
14961
+ const proxyOutcomes = await withTimeout(Promise.all(
14962
+ descriptors.map(async (d) => ({ family: d.family, ok: await registerRemoteFontFaceViaProxy(d.family, d.weight, d.style) }))
14963
+ ), 9e3);
14964
+ const proxyLoadedFamilies = new Set((proxyOutcomes || []).filter((r) => r.ok).map((r) => r.family));
14965
+ await withTimeout(Promise.all([...families].map((f) => {
14966
+ if (proxyLoadedFamilies.has(f)) {
14967
+ loadedFonts.add(f);
14968
+ return Promise.resolve();
14969
+ }
14970
+ return loadGoogleFontCSS(f);
14971
+ })), 3500);
14965
14972
  if (document.fonts) {
14966
14973
  descriptors.forEach((d) => {
14967
14974
  const stylePrefix = d.style === "italic" ? "italic " : "";
@@ -14991,7 +14998,7 @@ function configHasAutoShrinkText$1(config) {
14991
14998
  async function awaitFontsForConfig(config, maxWaitMs) {
14992
14999
  if (typeof document === "undefined" || !document.fonts) return;
14993
15000
  await ensureFontsForResolvedConfig(config);
14994
- const descriptors = collectFontDescriptorsFromConfig(config);
15001
+ const descriptors = collectFontDescriptorsFromConfig(config, false);
14995
15002
  if (descriptors.length === 0) return;
14996
15003
  const overallBudget = Math.max(maxWaitMs, 5e3);
14997
15004
  const loads = Promise.all(
@@ -15949,7 +15956,7 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
15949
15956
  }
15950
15957
  return svgString;
15951
15958
  }
15952
- const PACKAGE_VERSION = "0.5.138";
15959
+ const PACKAGE_VERSION = "0.5.141";
15953
15960
  const roundParityValue = (value) => {
15954
15961
  if (typeof value !== "number") return value;
15955
15962
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -16374,7 +16381,7 @@ class PixldocsRenderer {
16374
16381
  await this.waitForCanvasScene(container, cloned, i);
16375
16382
  }
16376
16383
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
16377
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Cj8x52ZL.js");
16384
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Bkg5qekb.js");
16378
16385
  const prepared = preparePagesForExport(
16379
16386
  cloned.pages,
16380
16387
  canvasWidth,
@@ -16971,7 +16978,7 @@ class PixldocsRenderer {
16971
16978
  maxLineWidth: lineWidths.length ? Math.max(...lineWidths) : 0
16972
16979
  });
16973
16980
  }
16974
- if (obj instanceof fabric.Group && typeof obj.getObjects === "function") {
16981
+ if (isFabricGroupLike(obj)) {
16975
16982
  const nextPath = [groupPath, getObjectId(obj) || obj.type || "group"].filter(Boolean).join("/");
16976
16983
  obj.getObjects().forEach((child) => visit(child, nextPath));
16977
16984
  }
@@ -16990,7 +16997,7 @@ class PixldocsRenderer {
16990
16997
  this.logFabricTextParitySnapshot("before-stable-text-metrics", fabricInstance);
16991
16998
  const waitForPaint = () => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
16992
16999
  const primeCharBounds = (obj) => {
16993
- if (obj instanceof fabric.Textbox) {
17000
+ if (isFabricTextboxLike(obj)) {
16994
17001
  try {
16995
17002
  obj.__lineWidths = [];
16996
17003
  obj.__lineHeights = [];
@@ -18472,7 +18479,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
18472
18479
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
18473
18480
  sanitizeSvgTreeForPdf(svgToDraw);
18474
18481
  try {
18475
- const { bakeTextAnchorPositionsFromLiveSvg } = await import("./vectorPdfExport-Cj8x52ZL.js");
18482
+ const { bakeTextAnchorPositionsFromLiveSvg } = await import("./vectorPdfExport-Bkg5qekb.js");
18476
18483
  await bakeTextAnchorPositionsFromLiveSvg(svgToDraw);
18477
18484
  } catch (e) {
18478
18485
  console.warn("[canvas-renderer][pdf-export] anchor-bake pass failed (continuing):", e);
@@ -18603,7 +18610,7 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
18603
18610
  }
18604
18611
  if (shouldOutlineText) {
18605
18612
  try {
18606
- const { convertAllTextToPath } = await import("./svgTextToPath-DG7rcbDE.js");
18613
+ const { convertAllTextToPath } = await import("./svgTextToPath-ws6Fh3rx.js");
18607
18614
  pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
18608
18615
  try {
18609
18616
  dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
@@ -18817,4 +18824,4 @@ export {
18817
18824
  collectFontDescriptorsFromConfig as y,
18818
18825
  collectFontsFromConfig as z
18819
18826
  };
18820
- //# sourceMappingURL=index-O3SyxMKA.js.map
18827
+ //# sourceMappingURL=index-DA3Nf1nG.js.map