@pixldocs/canvas-renderer 0.5.64 → 0.5.65

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
@@ -12561,7 +12561,7 @@ function PixldocsPreview(props) {
12561
12561
  !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
12562
  ] });
12563
12563
  }
12564
- const PACKAGE_VERSION = "0.5.64";
12564
+ const PACKAGE_VERSION = "0.5.65";
12565
12565
  let __underlineFixInstalled = false;
12566
12566
  function installUnderlineFix(fab) {
12567
12567
  var _a;
@@ -13277,6 +13277,7 @@ class PixldocsRenderer {
13277
13277
  captureSvgViaPreviewCanvas(config, pageIndex, canvasWidth, canvasHeight) {
13278
13278
  return new Promise(async (resolve, reject) => {
13279
13279
  const { PreviewCanvas: PreviewCanvas2 } = await Promise.resolve().then(() => PreviewCanvas$1);
13280
+ const hasAutoShrink = configHasAutoShrinkText(config);
13280
13281
  const container = document.createElement("div");
13281
13282
  container.style.cssText = `
13282
13283
  position: fixed; left: -99999px; top: -99999px;
@@ -13289,6 +13290,8 @@ class PixldocsRenderer {
13289
13290
  reject(new Error("SVG render timeout (30s)"));
13290
13291
  }, 3e4);
13291
13292
  let root = null;
13293
+ let mountKey = 0;
13294
+ let didPreviewParityRemount = false;
13292
13295
  const cleanup = () => {
13293
13296
  clearTimeout(timeout);
13294
13297
  try {
@@ -13297,6 +13300,48 @@ class PixldocsRenderer {
13297
13300
  }
13298
13301
  container.remove();
13299
13302
  };
13303
+ const mountPreview = (readyHandler) => {
13304
+ root = client.createRoot(container);
13305
+ root.render(
13306
+ react.createElement(PreviewCanvas2, {
13307
+ key: `svg-capture-${mountKey}`,
13308
+ config,
13309
+ pageIndex,
13310
+ zoom: 1,
13311
+ absoluteZoom: true,
13312
+ skipFontReadyWait: false,
13313
+ onReady: readyHandler
13314
+ })
13315
+ );
13316
+ };
13317
+ const remountForPreviewParity = async () => {
13318
+ if (didPreviewParityRemount) return;
13319
+ didPreviewParityRemount = true;
13320
+ mountKey += 1;
13321
+ try {
13322
+ clearMeasurementCache();
13323
+ } catch {
13324
+ }
13325
+ try {
13326
+ clearFabricCharCache();
13327
+ } catch {
13328
+ }
13329
+ try {
13330
+ root == null ? void 0 : root.unmount();
13331
+ } catch {
13332
+ }
13333
+ await new Promise((settle) => {
13334
+ mountPreview(() => {
13335
+ this.waitForCanvasScene(container, config, pageIndex).then(async () => {
13336
+ const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
13337
+ await this.waitForCanvasImages(container, expectedImageCount);
13338
+ await this.waitForStableTextMetrics(container, config);
13339
+ await this.waitForCanvasScene(container, config, pageIndex);
13340
+ settle();
13341
+ }).catch(() => settle());
13342
+ });
13343
+ });
13344
+ };
13300
13345
  const onReady = () => {
13301
13346
  this.waitForCanvasScene(container, config, pageIndex).then(async () => {
13302
13347
  var _a, _b;
@@ -13305,6 +13350,10 @@ class PixldocsRenderer {
13305
13350
  await this.waitForCanvasImages(container, expectedImageCount);
13306
13351
  await this.waitForStableTextMetrics(container, config);
13307
13352
  await this.waitForCanvasScene(container, config, pageIndex);
13353
+ if (hasAutoShrink && !didPreviewParityRemount) {
13354
+ console.log("[canvas-renderer][svg-parity] remounting once to match PixldocsPreview auto-shrink stabilization");
13355
+ await remountForPreviewParity();
13356
+ }
13308
13357
  const fabricInstance = this.getFabricCanvasFromContainer(container);
13309
13358
  if (!fabricInstance) {
13310
13359
  cleanup();
@@ -13353,18 +13402,7 @@ class PixldocsRenderer {
13353
13402
  }
13354
13403
  });
13355
13404
  };
13356
- root = client.createRoot(container);
13357
- root.render(
13358
- react.createElement(PreviewCanvas2, {
13359
- config,
13360
- pageIndex,
13361
- zoom: 1,
13362
- // 1:1 — no UI scaling for SVG capture
13363
- absoluteZoom: true,
13364
- skipFontReadyWait: false,
13365
- onReady
13366
- })
13367
- );
13405
+ mountPreview(onReady);
13368
13406
  });
13369
13407
  }
13370
13408
  /**