@pixldocs/canvas-renderer 0.5.23 → 0.5.25

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.js CHANGED
@@ -9613,10 +9613,6 @@ function PreviewCanvas({
9613
9613
  }
9614
9614
  );
9615
9615
  }
9616
- const PreviewCanvas$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9617
- __proto__: null,
9618
- PreviewCanvas
9619
- }, Symbol.toStringTag, { value: "Module" }));
9620
9616
  function applyThemeToConfig(config, themeOverrides) {
9621
9617
  var _a, _b, _c;
9622
9618
  if (!themeOverrides || Object.keys(themeOverrides).length === 0) return config;
@@ -12049,6 +12045,10 @@ function PixldocsPreview(props) {
12049
12045
  !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..." }) })
12050
12046
  ] });
12051
12047
  }
12048
+ const PixldocsPreview$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12049
+ __proto__: null,
12050
+ PixldocsPreview
12051
+ }, Symbol.toStringTag, { value: "Module" }));
12052
12052
  const inlinedAssetCache = /* @__PURE__ */ new Map();
12053
12053
  function shouldInlineImageUrl(url) {
12054
12054
  if (!url || url.startsWith("data:")) return false;
@@ -12529,7 +12529,7 @@ class PixldocsRenderer {
12529
12529
  }
12530
12530
  }
12531
12531
  async renderPageViaPreviewCanvas(config, pageIndex, pixelRatio, format, quality) {
12532
- const { PreviewCanvas: PreviewCanvas2 } = await Promise.resolve().then(() => PreviewCanvas$1);
12532
+ const { PixldocsPreview: PixldocsPreview2 } = await Promise.resolve().then(() => PixldocsPreview$1);
12533
12533
  const canvasWidth = config.canvas.width;
12534
12534
  const canvasHeight = config.canvas.height;
12535
12535
  return new Promise((resolve, reject) => {
@@ -12571,8 +12571,8 @@ class PixldocsRenderer {
12571
12571
  return;
12572
12572
  }
12573
12573
  const exportCanvas = document.createElement("canvas");
12574
- exportCanvas.width = sourceCanvas.width;
12575
- exportCanvas.height = sourceCanvas.height;
12574
+ exportCanvas.width = Math.round(canvasWidth * pixelRatio);
12575
+ exportCanvas.height = Math.round(canvasHeight * pixelRatio);
12576
12576
  const exportCtx = exportCanvas.getContext("2d");
12577
12577
  if (!exportCtx) {
12578
12578
  cleanup();
@@ -12580,10 +12580,10 @@ class PixldocsRenderer {
12580
12580
  return;
12581
12581
  }
12582
12582
  exportCtx.save();
12583
- exportCtx.scale(sourceCanvas.width / canvasWidth, sourceCanvas.height / canvasHeight);
12583
+ exportCtx.scale(exportCanvas.width / canvasWidth, exportCanvas.height / canvasHeight);
12584
12584
  this.paintPageBackground(exportCtx, config.pages[pageIndex], canvasWidth, canvasHeight);
12585
12585
  exportCtx.restore();
12586
- exportCtx.drawImage(sourceCanvas, 0, 0);
12586
+ exportCtx.drawImage(sourceCanvas, 0, 0, exportCanvas.width, exportCanvas.height);
12587
12587
  const mimeType = format === "jpeg" ? "image/jpeg" : format === "webp" ? "image/webp" : "image/png";
12588
12588
  const dataUrl = exportCanvas.toDataURL(mimeType, quality);
12589
12589
  cleanup();
@@ -12596,10 +12596,10 @@ class PixldocsRenderer {
12596
12596
  };
12597
12597
  const root = createRoot(container);
12598
12598
  root.render(
12599
- createElement(PreviewCanvas2, {
12599
+ createElement(PixldocsPreview2, {
12600
12600
  config,
12601
12601
  pageIndex,
12602
- zoom: pixelRatio,
12602
+ zoom: 1,
12603
12603
  absoluteZoom: true,
12604
12604
  onReady
12605
12605
  })
@@ -12617,7 +12617,7 @@ class PixldocsRenderer {
12617
12617
  // document space (e.g. 612x792) instead of inflated pixel space.
12618
12618
  captureSvgViaPreviewCanvas(config, pageIndex, canvasWidth, canvasHeight) {
12619
12619
  return new Promise(async (resolve, reject) => {
12620
- const { PreviewCanvas: PreviewCanvas2 } = await Promise.resolve().then(() => PreviewCanvas$1);
12620
+ const { PixldocsPreview: PixldocsPreview2 } = await Promise.resolve().then(() => PixldocsPreview$1);
12621
12621
  const container = document.createElement("div");
12622
12622
  container.style.cssText = `
12623
12623
  position: fixed; left: -99999px; top: -99999px;
@@ -12698,7 +12698,7 @@ class PixldocsRenderer {
12698
12698
  };
12699
12699
  const root = createRoot(container);
12700
12700
  root.render(
12701
- createElement(PreviewCanvas2, {
12701
+ createElement(PixldocsPreview2, {
12702
12702
  config,
12703
12703
  pageIndex,
12704
12704
  zoom: 1,