@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.cjs +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9632,10 +9632,6 @@ function PreviewCanvas({
|
|
|
9632
9632
|
}
|
|
9633
9633
|
);
|
|
9634
9634
|
}
|
|
9635
|
-
const PreviewCanvas$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9636
|
-
__proto__: null,
|
|
9637
|
-
PreviewCanvas
|
|
9638
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
9639
9635
|
function applyThemeToConfig(config, themeOverrides) {
|
|
9640
9636
|
var _a, _b, _c;
|
|
9641
9637
|
if (!themeOverrides || Object.keys(themeOverrides).length === 0) return config;
|
|
@@ -12068,6 +12064,10 @@ function PixldocsPreview(props) {
|
|
|
12068
12064
|
!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..." }) })
|
|
12069
12065
|
] });
|
|
12070
12066
|
}
|
|
12067
|
+
const PixldocsPreview$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
12068
|
+
__proto__: null,
|
|
12069
|
+
PixldocsPreview
|
|
12070
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
12071
12071
|
const inlinedAssetCache = /* @__PURE__ */ new Map();
|
|
12072
12072
|
function shouldInlineImageUrl(url) {
|
|
12073
12073
|
if (!url || url.startsWith("data:")) return false;
|
|
@@ -12548,7 +12548,7 @@ class PixldocsRenderer {
|
|
|
12548
12548
|
}
|
|
12549
12549
|
}
|
|
12550
12550
|
async renderPageViaPreviewCanvas(config, pageIndex, pixelRatio, format, quality) {
|
|
12551
|
-
const {
|
|
12551
|
+
const { PixldocsPreview: PixldocsPreview2 } = await Promise.resolve().then(() => PixldocsPreview$1);
|
|
12552
12552
|
const canvasWidth = config.canvas.width;
|
|
12553
12553
|
const canvasHeight = config.canvas.height;
|
|
12554
12554
|
return new Promise((resolve, reject) => {
|
|
@@ -12590,8 +12590,8 @@ class PixldocsRenderer {
|
|
|
12590
12590
|
return;
|
|
12591
12591
|
}
|
|
12592
12592
|
const exportCanvas = document.createElement("canvas");
|
|
12593
|
-
exportCanvas.width =
|
|
12594
|
-
exportCanvas.height =
|
|
12593
|
+
exportCanvas.width = Math.round(canvasWidth * pixelRatio);
|
|
12594
|
+
exportCanvas.height = Math.round(canvasHeight * pixelRatio);
|
|
12595
12595
|
const exportCtx = exportCanvas.getContext("2d");
|
|
12596
12596
|
if (!exportCtx) {
|
|
12597
12597
|
cleanup();
|
|
@@ -12599,10 +12599,10 @@ class PixldocsRenderer {
|
|
|
12599
12599
|
return;
|
|
12600
12600
|
}
|
|
12601
12601
|
exportCtx.save();
|
|
12602
|
-
exportCtx.scale(
|
|
12602
|
+
exportCtx.scale(exportCanvas.width / canvasWidth, exportCanvas.height / canvasHeight);
|
|
12603
12603
|
this.paintPageBackground(exportCtx, config.pages[pageIndex], canvasWidth, canvasHeight);
|
|
12604
12604
|
exportCtx.restore();
|
|
12605
|
-
exportCtx.drawImage(sourceCanvas, 0, 0);
|
|
12605
|
+
exportCtx.drawImage(sourceCanvas, 0, 0, exportCanvas.width, exportCanvas.height);
|
|
12606
12606
|
const mimeType = format === "jpeg" ? "image/jpeg" : format === "webp" ? "image/webp" : "image/png";
|
|
12607
12607
|
const dataUrl = exportCanvas.toDataURL(mimeType, quality);
|
|
12608
12608
|
cleanup();
|
|
@@ -12615,10 +12615,10 @@ class PixldocsRenderer {
|
|
|
12615
12615
|
};
|
|
12616
12616
|
const root = client.createRoot(container);
|
|
12617
12617
|
root.render(
|
|
12618
|
-
react.createElement(
|
|
12618
|
+
react.createElement(PixldocsPreview2, {
|
|
12619
12619
|
config,
|
|
12620
12620
|
pageIndex,
|
|
12621
|
-
zoom:
|
|
12621
|
+
zoom: 1,
|
|
12622
12622
|
absoluteZoom: true,
|
|
12623
12623
|
onReady
|
|
12624
12624
|
})
|
|
@@ -12636,7 +12636,7 @@ class PixldocsRenderer {
|
|
|
12636
12636
|
// document space (e.g. 612x792) instead of inflated pixel space.
|
|
12637
12637
|
captureSvgViaPreviewCanvas(config, pageIndex, canvasWidth, canvasHeight) {
|
|
12638
12638
|
return new Promise(async (resolve, reject) => {
|
|
12639
|
-
const {
|
|
12639
|
+
const { PixldocsPreview: PixldocsPreview2 } = await Promise.resolve().then(() => PixldocsPreview$1);
|
|
12640
12640
|
const container = document.createElement("div");
|
|
12641
12641
|
container.style.cssText = `
|
|
12642
12642
|
position: fixed; left: -99999px; top: -99999px;
|
|
@@ -12717,7 +12717,7 @@ class PixldocsRenderer {
|
|
|
12717
12717
|
};
|
|
12718
12718
|
const root = client.createRoot(container);
|
|
12719
12719
|
root.render(
|
|
12720
|
-
react.createElement(
|
|
12720
|
+
react.createElement(PixldocsPreview2, {
|
|
12721
12721
|
config,
|
|
12722
12722
|
pageIndex,
|
|
12723
12723
|
zoom: 1,
|