@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.cjs CHANGED
@@ -12337,6 +12337,25 @@ async function awaitFontsForConfig(config, maxWaitMs) {
12337
12337
  document.fonts.ready.catch(() => void 0).then(() => void 0),
12338
12338
  new Promise((r) => setTimeout(r, Math.min(500, maxWaitMs)))
12339
12339
  ]);
12340
+ const checkSpecs = [];
12341
+ for (const d of descriptors) {
12342
+ const stylePrefix = d.style === "italic" ? "italic " : "";
12343
+ checkSpecs.push(`${stylePrefix}${d.weight} 16px "${d.family}"`);
12344
+ }
12345
+ const startedAt = Date.now();
12346
+ const pollBudget = Math.min(maxWaitMs, 2500);
12347
+ const allReady = () => {
12348
+ for (const spec of checkSpecs) {
12349
+ try {
12350
+ if (!document.fonts.check(spec)) return false;
12351
+ } catch {
12352
+ }
12353
+ }
12354
+ return true;
12355
+ };
12356
+ while (!allReady() && Date.now() - startedAt < pollBudget) {
12357
+ await new Promise((resolve) => setTimeout(resolve, 50));
12358
+ }
12340
12359
  await new Promise(
12341
12360
  (resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
12342
12361
  );
@@ -12531,7 +12550,7 @@ function PixldocsPreview(props) {
12531
12550
  !canvasSettled && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
12532
12551
  ] });
12533
12552
  }
12534
- const PACKAGE_VERSION = "0.5.72";
12553
+ const PACKAGE_VERSION = "0.5.74";
12535
12554
  let __underlineFixInstalled = false;
12536
12555
  function installUnderlineFix(fab) {
12537
12556
  var _a;
@@ -15611,13 +15630,13 @@ function drawPageBackground(pdf, pageIndex, pageWidth, pageHeight, backgroundCol
15611
15630
  }
15612
15631
  }
15613
15632
  async function assemblePdfFromSvgs(svgResults, options = {}) {
15614
- var _a, _b, _c;
15633
+ var _a, _b;
15615
15634
  if (svgResults.length === 0) throw new Error("No pages to export");
15616
15635
  const { title, stripPageBackground } = options;
15617
15636
  const firstPage = svgResults[0];
15618
15637
  const orientation = firstPage.width > firstPage.height ? "landscape" : "portrait";
15619
15638
  const PARITY_TAG = "[canvas-renderer][parity-diag][pkg-pdf]";
15620
- console.log(`${PARITY_TAG} pkg-version=0.5.71 pages=${svgResults.length}`);
15639
+ console.log(`${PARITY_TAG} pkg-version=0.5.74 pages=${svgResults.length}`);
15621
15640
  try {
15622
15641
  for (let pi = 0; pi < svgResults.length; pi++) {
15623
15642
  dumpSvgTextDiagnostics(svgResults[pi].svg, pi, PARITY_TAG, "STAGE-1-raw-toSVG");
@@ -15649,7 +15668,22 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
15649
15668
  drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
15650
15669
  const shouldStripBg = stripPageBackground ?? hasGradient;
15651
15670
  const shouldOutlineText = options.outlineText !== false;
15652
- const pageSvg = page.svg;
15671
+ let pageSvg = page.svg;
15672
+ if (shouldOutlineText) {
15673
+ try {
15674
+ const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-BTHnqJpM.cjs"));
15675
+ pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl);
15676
+ try {
15677
+ dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
15678
+ } catch {
15679
+ }
15680
+ } catch (outlineErr) {
15681
+ console.warn(
15682
+ "[canvas-renderer][pdf] raw-stage text outlining unavailable, falling back to embedded SVG text:",
15683
+ outlineErr
15684
+ );
15685
+ }
15686
+ }
15653
15687
  let processedSvg = await prepareLiveCanvasSvgForPdf(pageSvg, page.width, page.height, `page-${i + 1}`, {
15654
15688
  stripPageBackground: shouldStripBg
15655
15689
  });
@@ -15664,22 +15698,6 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
15664
15698
  } catch {
15665
15699
  }
15666
15700
  await convertTextDecorationsToLines(processedSvg);
15667
- if (shouldOutlineText) {
15668
- try {
15669
- const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-BTHnqJpM.cjs"));
15670
- const outlinedSvg = await convertAllTextToPath(
15671
- new XMLSerializer().serializeToString(processedSvg),
15672
- fontBaseUrl
15673
- );
15674
- const outlineDoc = new DOMParser().parseFromString(outlinedSvg, "image/svg+xml");
15675
- const outlinedRoot = outlineDoc.documentElement;
15676
- if (outlinedRoot && ((_c = outlinedRoot.tagName) == null ? void 0 : _c.toLowerCase()) === "svg" && !outlineDoc.querySelector("parsererror")) {
15677
- processedSvg = outlinedRoot;
15678
- }
15679
- } catch (outlineErr) {
15680
- console.warn("[canvas-renderer][pdf] text outlining unavailable, falling back to embedded SVG text:", outlineErr);
15681
- }
15682
- }
15683
15701
  const rewrittenSvg = rewriteSvgFontsForJsPDF(new XMLSerializer().serializeToString(processedSvg));
15684
15702
  const reParser = new DOMParser();
15685
15703
  const reDoc = reParser.parseFromString(rewrittenSvg, "image/svg+xml");