@pixldocs/canvas-renderer 0.5.71 → 0.5.73

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
  );
@@ -12388,7 +12407,6 @@ function PixldocsPreview(props) {
12388
12407
  const [resolvedConfig, setResolvedConfig] = react.useState(null);
12389
12408
  const [isLoading, setIsLoading] = react.useState(false);
12390
12409
  const [fontsReady, setFontsReady] = react.useState(false);
12391
- const [fontsReadyVersion, setFontsReadyVersion] = react.useState(0);
12392
12410
  const [canvasSettled, setCanvasSettled] = react.useState(false);
12393
12411
  const [stabilizationPass, setStabilizationPass] = react.useState(0);
12394
12412
  const isResolveMode = !("config" in props && props.config);
@@ -12461,38 +12479,9 @@ function PixldocsPreview(props) {
12461
12479
  isResolveMode ? props.themeId : void 0
12462
12480
  ]);
12463
12481
  const config = isResolveMode ? resolvedConfig : props.config;
12464
- react.useEffect(() => {
12465
- var _a, _b, _c;
12466
- if (!config) return;
12467
- let cancelled = false;
12468
- setCanvasSettled(false);
12469
- setStabilizationPass(0);
12470
- console.log(PREVIEW_DEBUG_PREFIX, "config-changed", {
12471
- pageIndex,
12472
- pages: ((_a = config.pages) == null ? void 0 : _a.length) ?? 0,
12473
- underlinedNodes: countUnderlinedNodes(config),
12474
- isResolveMode
12475
- });
12476
- const bump = () => {
12477
- if (cancelled) return;
12478
- clearMeasurementCache();
12479
- clearFabricCharCache();
12480
- setFontsReadyVersion((v) => {
12481
- const next = v + 1;
12482
- console.log(PREVIEW_DEBUG_PREFIX, "font-bump", { pageIndex, next, stabilizationPass });
12483
- return next;
12484
- });
12485
- };
12486
- (_c = (_b = document.fonts) == null ? void 0 : _b.ready) == null ? void 0 : _c.then(bump);
12487
- const timeoutId = window.setTimeout(bump, 350);
12488
- return () => {
12489
- cancelled = true;
12490
- window.clearTimeout(timeoutId);
12491
- };
12492
- }, [config]);
12493
12482
  const previewKey = react.useMemo(
12494
- () => `${pageIndex}-${fontsReadyVersion}-${stabilizationPass}`,
12495
- [pageIndex, fontsReadyVersion, stabilizationPass]
12483
+ () => `${pageIndex}-${stabilizationPass}`,
12484
+ [pageIndex, stabilizationPass]
12496
12485
  );
12497
12486
  react.useEffect(() => {
12498
12487
  if (isResolveMode) return;
@@ -12561,7 +12550,7 @@ function PixldocsPreview(props) {
12561
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..." }) })
12562
12551
  ] });
12563
12552
  }
12564
- const PACKAGE_VERSION = "0.5.71";
12553
+ const PACKAGE_VERSION = "0.5.73";
12565
12554
  let __underlineFixInstalled = false;
12566
12555
  function installUnderlineFix(fab) {
12567
12556
  var _a;
@@ -15678,7 +15667,7 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
15678
15667
  const hasGradient = !!((_b = (_a = page.backgroundGradient) == null ? void 0 : _a.stops) == null ? void 0 : _b.length);
15679
15668
  drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
15680
15669
  const shouldStripBg = stripPageBackground ?? hasGradient;
15681
- const shouldOutlineText = options.outlineText === true;
15670
+ const shouldOutlineText = options.outlineText !== false;
15682
15671
  const pageSvg = page.svg;
15683
15672
  let processedSvg = await prepareLiveCanvasSvgForPdf(pageSvg, page.width, page.height, `page-${i + 1}`, {
15684
15673
  stripPageBackground: shouldStripBg