mirror of
https://github.com/nexu-io/open-design.git
synced 2026-10-27 09:51:12 +01:00
* Fix blank/clipped desktop PDF export by sizing the page to artifact content (#4067) The desktop PDF export wraps the artifact in a sandboxed-preview iframe (sandbox="allow-scripts", no allow-same-origin) inside an overflow:hidden wrapper. inferPageSize() measured the wrapper document, which is pinned to the window viewport, so taller artifacts were clipped and content sitting below the fold exported as a blank white page. The wrapper can't read the cross-origin iframe, so the artifact now reports its own content dimensions through the existing print-ready handshake. The parent caches them as window.__odPrintSize (nonce + source checked, validated as a positive finite size) and inferPageSize() prefers that over measuring the wrapper, falling back to direct measurement for the daemon path that runs no handshake. Purely additive: other export paths never set __odPrintSize and are unchanged. * Reject non-finite reported print sizes in the #4067 handshake guard The __odPrintSize validation accepted any `typeof === 'number'` that was `> 0`, so `Infinity` slipped through (`Infinity > 0` is true) despite the guard's intent — and its comment — being "positive finite numbers". A malformed `{ width: 756, height: Infinity }` then sized the desktop PDF page to a Frankenstein 756x900 (reported width kept, non-finite height dropped to 900) instead of falling back cleanly to direct measurement. Tighten both the parent write guard (apps/web/src/runtime/exports.ts) and the mirrored consumer guard (apps/desktop/src/main/pdf-export.ts) to `Number.isFinite(x) && x > 0`, and add a desktop regression that feeds a non-finite height and asserts the whole reported size is rejected.