@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 +51 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +51 -13
- 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.65";
|
|
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.65";
|
|
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;
|
|
@@ -13270,6 +13271,8 @@ class PixldocsRenderer {
|
|
|
13270
13271
|
reject(new Error("SVG render timeout (30s)"));
|
|
13271
13272
|
}, 3e4);
|
|
13272
13273
|
let root = null;
|
|
13274
|
+
let mountKey = 0;
|
|
13275
|
+
let didPreviewParityRemount = false;
|
|
13273
13276
|
const cleanup = () => {
|
|
13274
13277
|
clearTimeout(timeout);
|
|
13275
13278
|
try {
|
|
@@ -13278,6 +13281,48 @@ class PixldocsRenderer {
|
|
|
13278
13281
|
}
|
|
13279
13282
|
container.remove();
|
|
13280
13283
|
};
|
|
13284
|
+
const mountPreview = (readyHandler) => {
|
|
13285
|
+
root = createRoot(container);
|
|
13286
|
+
root.render(
|
|
13287
|
+
createElement(PreviewCanvas2, {
|
|
13288
|
+
key: `svg-capture-${mountKey}`,
|
|
13289
|
+
config,
|
|
13290
|
+
pageIndex,
|
|
13291
|
+
zoom: 1,
|
|
13292
|
+
absoluteZoom: true,
|
|
13293
|
+
skipFontReadyWait: false,
|
|
13294
|
+
onReady: readyHandler
|
|
13295
|
+
})
|
|
13296
|
+
);
|
|
13297
|
+
};
|
|
13298
|
+
const remountForPreviewParity = async () => {
|
|
13299
|
+
if (didPreviewParityRemount) return;
|
|
13300
|
+
didPreviewParityRemount = true;
|
|
13301
|
+
mountKey += 1;
|
|
13302
|
+
try {
|
|
13303
|
+
clearMeasurementCache();
|
|
13304
|
+
} catch {
|
|
13305
|
+
}
|
|
13306
|
+
try {
|
|
13307
|
+
clearFabricCharCache();
|
|
13308
|
+
} catch {
|
|
13309
|
+
}
|
|
13310
|
+
try {
|
|
13311
|
+
root == null ? void 0 : root.unmount();
|
|
13312
|
+
} catch {
|
|
13313
|
+
}
|
|
13314
|
+
await new Promise((settle) => {
|
|
13315
|
+
mountPreview(() => {
|
|
13316
|
+
this.waitForCanvasScene(container, config, pageIndex).then(async () => {
|
|
13317
|
+
const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
|
|
13318
|
+
await this.waitForCanvasImages(container, expectedImageCount);
|
|
13319
|
+
await this.waitForStableTextMetrics(container, config);
|
|
13320
|
+
await this.waitForCanvasScene(container, config, pageIndex);
|
|
13321
|
+
settle();
|
|
13322
|
+
}).catch(() => settle());
|
|
13323
|
+
});
|
|
13324
|
+
});
|
|
13325
|
+
};
|
|
13281
13326
|
const onReady = () => {
|
|
13282
13327
|
this.waitForCanvasScene(container, config, pageIndex).then(async () => {
|
|
13283
13328
|
var _a, _b;
|
|
@@ -13286,6 +13331,10 @@ class PixldocsRenderer {
|
|
|
13286
13331
|
await this.waitForCanvasImages(container, expectedImageCount);
|
|
13287
13332
|
await this.waitForStableTextMetrics(container, config);
|
|
13288
13333
|
await this.waitForCanvasScene(container, config, pageIndex);
|
|
13334
|
+
if (hasAutoShrink && !didPreviewParityRemount) {
|
|
13335
|
+
console.log("[canvas-renderer][svg-parity] remounting once to match PixldocsPreview auto-shrink stabilization");
|
|
13336
|
+
await remountForPreviewParity();
|
|
13337
|
+
}
|
|
13289
13338
|
const fabricInstance = this.getFabricCanvasFromContainer(container);
|
|
13290
13339
|
if (!fabricInstance) {
|
|
13291
13340
|
cleanup();
|
|
@@ -13334,18 +13383,7 @@ class PixldocsRenderer {
|
|
|
13334
13383
|
}
|
|
13335
13384
|
});
|
|
13336
13385
|
};
|
|
13337
|
-
|
|
13338
|
-
root.render(
|
|
13339
|
-
createElement(PreviewCanvas2, {
|
|
13340
|
-
config,
|
|
13341
|
-
pageIndex,
|
|
13342
|
-
zoom: 1,
|
|
13343
|
-
// 1:1 — no UI scaling for SVG capture
|
|
13344
|
-
absoluteZoom: true,
|
|
13345
|
-
skipFontReadyWait: false,
|
|
13346
|
-
onReady
|
|
13347
|
-
})
|
|
13348
|
-
);
|
|
13386
|
+
mountPreview(onReady);
|
|
13349
13387
|
});
|
|
13350
13388
|
}
|
|
13351
13389
|
/**
|