@pixldocs/canvas-renderer 0.5.13 → 0.5.14
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 +42 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11843,6 +11843,7 @@ function PixldocsPreview(props) {
|
|
|
11843
11843
|
const [fontsReady, setFontsReady] = useState(false);
|
|
11844
11844
|
const [fontsReadyVersion, setFontsReadyVersion] = useState(0);
|
|
11845
11845
|
const [canvasSettled, setCanvasSettled] = useState(false);
|
|
11846
|
+
const [stabilizationPass, setStabilizationPass] = useState(0);
|
|
11846
11847
|
const isResolveMode = !("config" in props && props.config);
|
|
11847
11848
|
useEffect(() => {
|
|
11848
11849
|
if (!isResolveMode) {
|
|
@@ -11901,6 +11902,7 @@ function PixldocsPreview(props) {
|
|
|
11901
11902
|
if (!config) return;
|
|
11902
11903
|
let cancelled = false;
|
|
11903
11904
|
setCanvasSettled(false);
|
|
11905
|
+
setStabilizationPass(0);
|
|
11904
11906
|
const bump = () => {
|
|
11905
11907
|
if (cancelled) return;
|
|
11906
11908
|
clearMeasurementCache();
|
|
@@ -11913,22 +11915,32 @@ function PixldocsPreview(props) {
|
|
|
11913
11915
|
window.clearTimeout(timeoutId);
|
|
11914
11916
|
};
|
|
11915
11917
|
}, [config]);
|
|
11916
|
-
const previewKey = useMemo(
|
|
11918
|
+
const previewKey = useMemo(
|
|
11919
|
+
() => `${pageIndex}-${fontsReadyVersion}-${stabilizationPass}`,
|
|
11920
|
+
[pageIndex, fontsReadyVersion, stabilizationPass]
|
|
11921
|
+
);
|
|
11917
11922
|
useEffect(() => {
|
|
11918
11923
|
if (isResolveMode) return;
|
|
11919
11924
|
if (!config) {
|
|
11920
11925
|
setFontsReady(false);
|
|
11921
11926
|
setCanvasSettled(false);
|
|
11927
|
+
setStabilizationPass(0);
|
|
11922
11928
|
return;
|
|
11923
11929
|
}
|
|
11924
11930
|
setFontsReady(false);
|
|
11925
11931
|
setCanvasSettled(false);
|
|
11932
|
+
setStabilizationPass(0);
|
|
11926
11933
|
ensureFontsForResolvedConfig(config).then(() => setFontsReady(true)).catch(() => setFontsReady(true));
|
|
11927
11934
|
}, [isResolveMode, config]);
|
|
11928
11935
|
const handleCanvasReady = useCallback(() => {
|
|
11936
|
+
if (stabilizationPass === 0) {
|
|
11937
|
+
setCanvasSettled(false);
|
|
11938
|
+
setStabilizationPass(1);
|
|
11939
|
+
return;
|
|
11940
|
+
}
|
|
11929
11941
|
setCanvasSettled(true);
|
|
11930
11942
|
onReady == null ? void 0 : onReady();
|
|
11931
|
-
}, [onReady]);
|
|
11943
|
+
}, [onReady, stabilizationPass]);
|
|
11932
11944
|
if (isLoading) {
|
|
11933
11945
|
return /* @__PURE__ */ jsx("div", { className, style: { ...style, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) });
|
|
11934
11946
|
}
|
|
@@ -12342,6 +12354,7 @@ class PixldocsRenderer {
|
|
|
12342
12354
|
cleanup();
|
|
12343
12355
|
reject(new Error("Render timeout (30s)"));
|
|
12344
12356
|
}, 3e4);
|
|
12357
|
+
let stabilizationPass = 0;
|
|
12345
12358
|
const cleanup = () => {
|
|
12346
12359
|
clearTimeout(timeout);
|
|
12347
12360
|
try {
|
|
@@ -12351,6 +12364,19 @@ class PixldocsRenderer {
|
|
|
12351
12364
|
container.remove();
|
|
12352
12365
|
};
|
|
12353
12366
|
const onReady = () => {
|
|
12367
|
+
if (stabilizationPass === 0) {
|
|
12368
|
+
stabilizationPass = 1;
|
|
12369
|
+
root.render(
|
|
12370
|
+
createElement(PreviewCanvas2, {
|
|
12371
|
+
config,
|
|
12372
|
+
pageIndex,
|
|
12373
|
+
zoom: pixelRatio,
|
|
12374
|
+
absoluteZoom: true,
|
|
12375
|
+
onReady
|
|
12376
|
+
})
|
|
12377
|
+
);
|
|
12378
|
+
return;
|
|
12379
|
+
}
|
|
12354
12380
|
const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
|
|
12355
12381
|
this.waitForCanvasImages(container, expectedImageCount).then(async () => {
|
|
12356
12382
|
try {
|
|
@@ -12422,6 +12448,7 @@ class PixldocsRenderer {
|
|
|
12422
12448
|
cleanup();
|
|
12423
12449
|
reject(new Error("SVG render timeout (30s)"));
|
|
12424
12450
|
}, 3e4);
|
|
12451
|
+
let stabilizationPass = 0;
|
|
12425
12452
|
const cleanup = () => {
|
|
12426
12453
|
clearTimeout(timeout);
|
|
12427
12454
|
try {
|
|
@@ -12431,6 +12458,19 @@ class PixldocsRenderer {
|
|
|
12431
12458
|
container.remove();
|
|
12432
12459
|
};
|
|
12433
12460
|
const onReady = () => {
|
|
12461
|
+
if (stabilizationPass === 0) {
|
|
12462
|
+
stabilizationPass = 1;
|
|
12463
|
+
root.render(
|
|
12464
|
+
createElement(PreviewCanvas2, {
|
|
12465
|
+
config,
|
|
12466
|
+
pageIndex,
|
|
12467
|
+
zoom: 1,
|
|
12468
|
+
absoluteZoom: true,
|
|
12469
|
+
onReady
|
|
12470
|
+
})
|
|
12471
|
+
);
|
|
12472
|
+
return;
|
|
12473
|
+
}
|
|
12434
12474
|
const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
|
|
12435
12475
|
this.waitForCanvasImages(container, expectedImageCount).then(async () => {
|
|
12436
12476
|
var _a, _b;
|