@pixldocs/canvas-renderer 0.5.72 → 0.5.74

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.d.ts CHANGED
@@ -256,7 +256,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
256
256
  * Package version banner. Bump alongside package.json so we can confirm
257
257
  * (via browser:log) that the deployed bundle matches the expected build.
258
258
  */
259
- export declare const PACKAGE_VERSION = "0.5.72";
259
+ export declare const PACKAGE_VERSION = "0.5.74";
260
260
 
261
261
  export declare interface PageSettings {
262
262
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -12318,6 +12318,25 @@ async function awaitFontsForConfig(config, maxWaitMs) {
12318
12318
  document.fonts.ready.catch(() => void 0).then(() => void 0),
12319
12319
  new Promise((r) => setTimeout(r, Math.min(500, maxWaitMs)))
12320
12320
  ]);
12321
+ const checkSpecs = [];
12322
+ for (const d of descriptors) {
12323
+ const stylePrefix = d.style === "italic" ? "italic " : "";
12324
+ checkSpecs.push(`${stylePrefix}${d.weight} 16px "${d.family}"`);
12325
+ }
12326
+ const startedAt = Date.now();
12327
+ const pollBudget = Math.min(maxWaitMs, 2500);
12328
+ const allReady = () => {
12329
+ for (const spec of checkSpecs) {
12330
+ try {
12331
+ if (!document.fonts.check(spec)) return false;
12332
+ } catch {
12333
+ }
12334
+ }
12335
+ return true;
12336
+ };
12337
+ while (!allReady() && Date.now() - startedAt < pollBudget) {
12338
+ await new Promise((resolve) => setTimeout(resolve, 50));
12339
+ }
12321
12340
  await new Promise(
12322
12341
  (resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
12323
12342
  );
@@ -12512,7 +12531,7 @@ function PixldocsPreview(props) {
12512
12531
  !canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
12513
12532
  ] });
12514
12533
  }
12515
- const PACKAGE_VERSION = "0.5.72";
12534
+ const PACKAGE_VERSION = "0.5.74";
12516
12535
  let __underlineFixInstalled = false;
12517
12536
  function installUnderlineFix(fab) {
12518
12537
  var _a;
@@ -15592,13 +15611,13 @@ function drawPageBackground(pdf, pageIndex, pageWidth, pageHeight, backgroundCol
15592
15611
  }
15593
15612
  }
15594
15613
  async function assemblePdfFromSvgs(svgResults, options = {}) {
15595
- var _a, _b, _c;
15614
+ var _a, _b;
15596
15615
  if (svgResults.length === 0) throw new Error("No pages to export");
15597
15616
  const { title, stripPageBackground } = options;
15598
15617
  const firstPage = svgResults[0];
15599
15618
  const orientation = firstPage.width > firstPage.height ? "landscape" : "portrait";
15600
15619
  const PARITY_TAG = "[canvas-renderer][parity-diag][pkg-pdf]";
15601
- console.log(`${PARITY_TAG} pkg-version=0.5.71 pages=${svgResults.length}`);
15620
+ console.log(`${PARITY_TAG} pkg-version=0.5.74 pages=${svgResults.length}`);
15602
15621
  try {
15603
15622
  for (let pi = 0; pi < svgResults.length; pi++) {
15604
15623
  dumpSvgTextDiagnostics(svgResults[pi].svg, pi, PARITY_TAG, "STAGE-1-raw-toSVG");
@@ -15630,7 +15649,22 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
15630
15649
  drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
15631
15650
  const shouldStripBg = stripPageBackground ?? hasGradient;
15632
15651
  const shouldOutlineText = options.outlineText !== false;
15633
- const pageSvg = page.svg;
15652
+ let pageSvg = page.svg;
15653
+ if (shouldOutlineText) {
15654
+ try {
15655
+ const { convertAllTextToPath } = await import("./svgTextToPath-BP0Kppla.js");
15656
+ pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl);
15657
+ try {
15658
+ dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
15659
+ } catch {
15660
+ }
15661
+ } catch (outlineErr) {
15662
+ console.warn(
15663
+ "[canvas-renderer][pdf] raw-stage text outlining unavailable, falling back to embedded SVG text:",
15664
+ outlineErr
15665
+ );
15666
+ }
15667
+ }
15634
15668
  let processedSvg = await prepareLiveCanvasSvgForPdf(pageSvg, page.width, page.height, `page-${i + 1}`, {
15635
15669
  stripPageBackground: shouldStripBg
15636
15670
  });
@@ -15645,22 +15679,6 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
15645
15679
  } catch {
15646
15680
  }
15647
15681
  await convertTextDecorationsToLines(processedSvg);
15648
- if (shouldOutlineText) {
15649
- try {
15650
- const { convertAllTextToPath } = await import("./svgTextToPath-BP0Kppla.js");
15651
- const outlinedSvg = await convertAllTextToPath(
15652
- new XMLSerializer().serializeToString(processedSvg),
15653
- fontBaseUrl
15654
- );
15655
- const outlineDoc = new DOMParser().parseFromString(outlinedSvg, "image/svg+xml");
15656
- const outlinedRoot = outlineDoc.documentElement;
15657
- if (outlinedRoot && ((_c = outlinedRoot.tagName) == null ? void 0 : _c.toLowerCase()) === "svg" && !outlineDoc.querySelector("parsererror")) {
15658
- processedSvg = outlinedRoot;
15659
- }
15660
- } catch (outlineErr) {
15661
- console.warn("[canvas-renderer][pdf] text outlining unavailable, falling back to embedded SVG text:", outlineErr);
15662
- }
15663
- }
15664
15682
  const rewrittenSvg = rewriteSvgFontsForJsPDF(new XMLSerializer().serializeToString(processedSvg));
15665
15683
  const reParser = new DOMParser();
15666
15684
  const reDoc = reParser.parseFromString(rewrittenSvg, "image/svg+xml");