@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.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.71";
259
+ export declare const PACKAGE_VERSION = "0.5.73";
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
  );
@@ -12369,7 +12388,6 @@ function PixldocsPreview(props) {
12369
12388
  const [resolvedConfig, setResolvedConfig] = useState(null);
12370
12389
  const [isLoading, setIsLoading] = useState(false);
12371
12390
  const [fontsReady, setFontsReady] = useState(false);
12372
- const [fontsReadyVersion, setFontsReadyVersion] = useState(0);
12373
12391
  const [canvasSettled, setCanvasSettled] = useState(false);
12374
12392
  const [stabilizationPass, setStabilizationPass] = useState(0);
12375
12393
  const isResolveMode = !("config" in props && props.config);
@@ -12442,38 +12460,9 @@ function PixldocsPreview(props) {
12442
12460
  isResolveMode ? props.themeId : void 0
12443
12461
  ]);
12444
12462
  const config = isResolveMode ? resolvedConfig : props.config;
12445
- useEffect(() => {
12446
- var _a, _b, _c;
12447
- if (!config) return;
12448
- let cancelled = false;
12449
- setCanvasSettled(false);
12450
- setStabilizationPass(0);
12451
- console.log(PREVIEW_DEBUG_PREFIX, "config-changed", {
12452
- pageIndex,
12453
- pages: ((_a = config.pages) == null ? void 0 : _a.length) ?? 0,
12454
- underlinedNodes: countUnderlinedNodes(config),
12455
- isResolveMode
12456
- });
12457
- const bump = () => {
12458
- if (cancelled) return;
12459
- clearMeasurementCache();
12460
- clearFabricCharCache();
12461
- setFontsReadyVersion((v) => {
12462
- const next = v + 1;
12463
- console.log(PREVIEW_DEBUG_PREFIX, "font-bump", { pageIndex, next, stabilizationPass });
12464
- return next;
12465
- });
12466
- };
12467
- (_c = (_b = document.fonts) == null ? void 0 : _b.ready) == null ? void 0 : _c.then(bump);
12468
- const timeoutId = window.setTimeout(bump, 350);
12469
- return () => {
12470
- cancelled = true;
12471
- window.clearTimeout(timeoutId);
12472
- };
12473
- }, [config]);
12474
12463
  const previewKey = useMemo(
12475
- () => `${pageIndex}-${fontsReadyVersion}-${stabilizationPass}`,
12476
- [pageIndex, fontsReadyVersion, stabilizationPass]
12464
+ () => `${pageIndex}-${stabilizationPass}`,
12465
+ [pageIndex, stabilizationPass]
12477
12466
  );
12478
12467
  useEffect(() => {
12479
12468
  if (isResolveMode) return;
@@ -12542,7 +12531,7 @@ function PixldocsPreview(props) {
12542
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..." }) })
12543
12532
  ] });
12544
12533
  }
12545
- const PACKAGE_VERSION = "0.5.71";
12534
+ const PACKAGE_VERSION = "0.5.73";
12546
12535
  let __underlineFixInstalled = false;
12547
12536
  function installUnderlineFix(fab) {
12548
12537
  var _a;
@@ -15659,7 +15648,7 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
15659
15648
  const hasGradient = !!((_b = (_a = page.backgroundGradient) == null ? void 0 : _a.stops) == null ? void 0 : _b.length);
15660
15649
  drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
15661
15650
  const shouldStripBg = stripPageBackground ?? hasGradient;
15662
- const shouldOutlineText = options.outlineText === true;
15651
+ const shouldOutlineText = options.outlineText !== false;
15663
15652
  const pageSvg = page.svg;
15664
15653
  let processedSvg = await prepareLiveCanvasSvgForPdf(pageSvg, page.width, page.height, `page-${i + 1}`, {
15665
15654
  stripPageBackground: shouldStripBg