From ef7e85a4186f5c0892ec20ead2ce92f52b0d0b34 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 4 Jun 2026 15:10:19 -0400 Subject: [PATCH] fix(book): backfill cover spec flags so older books don't drop back/spine layers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ensureBookState() now fills in any defaultBookSpec() fields missing from state.book.spec. Older saved books that pre-date the coverHasBack / coverHasSpine flags would otherwise restore with those fields undefined, and the eleven '!!s.coverHasBack' / '!!s.coverHasSpine' truthiness checks scattered across the cover-preview filter, sheet sizing, renderDimensions, the cover edit slot layout, and the PDF export pipeline would all read those as 'false' — silently filtering back-cover and spine layers out of the spread. User symptom: a cover with text + linked designs + a background shape that spans the spread would render only the front panel's content, because the back / spine layers were being dropped by the filter. The spread width also collapsed to front + bleed, throwing off the bleed visualization. renderBookCoverPreview() now calls ensureBookState() before reading the spec so the backfill runs even if no prior code path touched the book this render cycle. Co-Authored-By: Claude Opus 4.7 --- src/index.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index b176d7f..1ad78d0 100644 --- a/src/index.html +++ b/src/index.html @@ -8852,6 +8852,16 @@ } function ensureBookState() { if (!state.book) state.book = defaultBookState(); + // Backfill any spec fields that pre-date later additions, so + // older saved books don't end up with undefined coverHasBack / + // coverHasSpine (which would make `!!s.coverHasBack` evaluate + // false and drop back-panel layers from the preview, sheet + // sizing, and PDF export). + if (!state.book.spec) state.book.spec = defaultBookSpec(); + const defaults = defaultBookSpec(); + for (const k of Object.keys(defaults)) { + if (state.book.spec[k] === undefined) state.book.spec[k] = defaults[k]; + } return state.book; } // Physical page count — manifest entries except reflow segments, @@ -12718,7 +12728,10 @@ function renderBookCoverPreview() { const wrap = document.getElementById('bookCoverPreview'); const summary = document.getElementById('bookCoverSummary'); - const book = state.book; + // Backfill any missing spec flags (older saved books) before we + // read coverHasBack / coverHasSpine — `!!undefined === false` + // would otherwise drop the back and spine layers entirely. + const book = state.book ? ensureBookState() : null; if (!wrap || !summary || !book) return; const s = book.spec; const spineW = bookSpineWidthInches();