Image export: surface rasterize/serialize failures instead of reporting 'not ready'

This commit is contained in:
2026-06-14 20:39:10 +03:00
parent 91b8b1e7fe
commit 6fc8c29b50
3 changed files with 114 additions and 13 deletions
+6 -7
View File
@@ -342,8 +342,11 @@ export function LivePreview() {
]);
// Rasterize/serialize the live view for the per-chart export (spec §08). Reads
// `handleRef` (the view LivePreview owns); returns null when no view is live or
// the export fails, so the export UI can report it. Stable identity (no deps).
// `handleRef` (the view LivePreview owns); returns null only when no view is live
// (the "not ready" case). A rasterize/serialize *failure* is a real error, not a
// not-ready state, so it propagates for the export UI to report with its detail —
// burying it here would misreport a tainted canvas or a serialization bug as
// "not ready yet" (arch 02 fail-loud). Stable identity (no deps).
const getImageUrl = useCallback(
async (
format: 'png' | 'svg',
@@ -351,11 +354,7 @@ export function LivePreview() {
): Promise<string | null> => {
const handle = handleRef.current;
if (!handle) return null;
try {
return await handle.toImageURL(format, options);
} catch {
return null;
}
return await handle.toImageURL(format, options);
},
[],
);