@pixldocs/canvas-renderer 0.5.62 → 0.5.63
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 +54 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +54 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -254,7 +254,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
|
|
|
254
254
|
* Package version banner. Bump alongside package.json so we can confirm
|
|
255
255
|
* (via browser:log) that the deployed bundle matches the expected build.
|
|
256
256
|
*/
|
|
257
|
-
export declare const PACKAGE_VERSION = "0.5.
|
|
257
|
+
export declare const PACKAGE_VERSION = "0.5.63";
|
|
258
258
|
|
|
259
259
|
export declare interface PageSettings {
|
|
260
260
|
backgroundColor?: string;
|
package/dist/index.js
CHANGED
|
@@ -12542,7 +12542,7 @@ function PixldocsPreview(props) {
|
|
|
12542
12542
|
!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
12543
|
] });
|
|
12544
12544
|
}
|
|
12545
|
-
const PACKAGE_VERSION = "0.5.
|
|
12545
|
+
const PACKAGE_VERSION = "0.5.63";
|
|
12546
12546
|
let __underlineFixInstalled = false;
|
|
12547
12547
|
function installUnderlineFix(fab) {
|
|
12548
12548
|
var _a;
|
|
@@ -13258,6 +13258,7 @@ class PixldocsRenderer {
|
|
|
13258
13258
|
captureSvgViaPreviewCanvas(config, pageIndex, canvasWidth, canvasHeight) {
|
|
13259
13259
|
return new Promise(async (resolve, reject) => {
|
|
13260
13260
|
const { PreviewCanvas: PreviewCanvas2 } = await Promise.resolve().then(() => PreviewCanvas$1);
|
|
13261
|
+
const hasAutoShrink = configHasAutoShrinkText(config);
|
|
13261
13262
|
const container = document.createElement("div");
|
|
13262
13263
|
container.style.cssText = `
|
|
13263
13264
|
position: fixed; left: -99999px; top: -99999px;
|
|
@@ -13269,28 +13270,74 @@ class PixldocsRenderer {
|
|
|
13269
13270
|
cleanup();
|
|
13270
13271
|
reject(new Error("SVG render timeout (30s)"));
|
|
13271
13272
|
}, 3e4);
|
|
13273
|
+
let root = null;
|
|
13274
|
+
let mountKey = 0;
|
|
13275
|
+
let didAutoShrinkParityRemount = false;
|
|
13272
13276
|
const cleanup = () => {
|
|
13273
13277
|
clearTimeout(timeout);
|
|
13274
13278
|
try {
|
|
13275
|
-
root.unmount();
|
|
13279
|
+
root == null ? void 0 : root.unmount();
|
|
13276
13280
|
} catch {
|
|
13277
13281
|
}
|
|
13278
13282
|
container.remove();
|
|
13279
13283
|
};
|
|
13284
|
+
const remountForAutoShrinkParity = async () => {
|
|
13285
|
+
didAutoShrinkParityRemount = true;
|
|
13286
|
+
mountKey += 1;
|
|
13287
|
+
try {
|
|
13288
|
+
clearMeasurementCache();
|
|
13289
|
+
} catch {
|
|
13290
|
+
}
|
|
13291
|
+
try {
|
|
13292
|
+
clearFabricCharCache();
|
|
13293
|
+
} catch {
|
|
13294
|
+
}
|
|
13295
|
+
try {
|
|
13296
|
+
root == null ? void 0 : root.unmount();
|
|
13297
|
+
} catch {
|
|
13298
|
+
}
|
|
13299
|
+
root = createRoot(container);
|
|
13300
|
+
await new Promise((settle) => {
|
|
13301
|
+
const onReadyOnce = () => {
|
|
13302
|
+
this.waitForCanvasScene(container, config, pageIndex).then(async () => {
|
|
13303
|
+
const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
|
|
13304
|
+
await this.waitForCanvasImages(container, expectedImageCount);
|
|
13305
|
+
await this.waitForStableTextMetrics(container, config);
|
|
13306
|
+
await this.waitForCanvasScene(container, config, pageIndex);
|
|
13307
|
+
settle();
|
|
13308
|
+
}).catch(() => settle());
|
|
13309
|
+
};
|
|
13310
|
+
root.render(
|
|
13311
|
+
createElement(PreviewCanvas2, {
|
|
13312
|
+
key: `svg-auto-shrink-remount-${mountKey}`,
|
|
13313
|
+
config,
|
|
13314
|
+
pageIndex,
|
|
13315
|
+
zoom: 1,
|
|
13316
|
+
absoluteZoom: true,
|
|
13317
|
+
skipFontReadyWait: false,
|
|
13318
|
+
onReady: onReadyOnce
|
|
13319
|
+
})
|
|
13320
|
+
);
|
|
13321
|
+
});
|
|
13322
|
+
};
|
|
13280
13323
|
const onReady = () => {
|
|
13281
13324
|
this.waitForCanvasScene(container, config, pageIndex).then(async () => {
|
|
13282
13325
|
var _a, _b;
|
|
13283
13326
|
try {
|
|
13327
|
+
const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
|
|
13328
|
+
await this.waitForCanvasImages(container, expectedImageCount);
|
|
13329
|
+
await this.waitForStableTextMetrics(container, config);
|
|
13330
|
+
await this.waitForCanvasScene(container, config, pageIndex);
|
|
13331
|
+
if (hasAutoShrink && !didAutoShrinkParityRemount) {
|
|
13332
|
+
console.log("[canvas-renderer][svg-parity] remounting auto-shrink text before PDF SVG capture");
|
|
13333
|
+
await remountForAutoShrinkParity();
|
|
13334
|
+
}
|
|
13284
13335
|
const fabricInstance = this.getFabricCanvasFromContainer(container);
|
|
13285
13336
|
if (!fabricInstance) {
|
|
13286
13337
|
cleanup();
|
|
13287
13338
|
reject(new Error("No Fabric canvas instance found for SVG capture"));
|
|
13288
13339
|
return;
|
|
13289
13340
|
}
|
|
13290
|
-
const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
|
|
13291
|
-
await this.waitForCanvasImages(container, expectedImageCount);
|
|
13292
|
-
await this.waitForStableTextMetrics(container, config);
|
|
13293
|
-
await this.waitForCanvasScene(container, config, pageIndex);
|
|
13294
13341
|
const prevVPT = fabricInstance.viewportTransform ? [...fabricInstance.viewportTransform] : void 0;
|
|
13295
13342
|
const prevSvgVPT = fabricInstance.svgViewportTransformation;
|
|
13296
13343
|
const prevRetina = fabricInstance.enableRetinaScaling;
|
|
@@ -13334,7 +13381,7 @@ class PixldocsRenderer {
|
|
|
13334
13381
|
}
|
|
13335
13382
|
});
|
|
13336
13383
|
};
|
|
13337
|
-
|
|
13384
|
+
root = createRoot(container);
|
|
13338
13385
|
root.render(
|
|
13339
13386
|
createElement(PreviewCanvas2, {
|
|
13340
13387
|
config,
|