The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(studio): auto layout keeps every page in the book's own styles and every photo in a frame
Maurice9c3649f01143
diff --git a/shared/src/book/design/design-template-pick.spec.ts b/shared/src/book/design/design-template-pick.spec.tsindex 72286716c..35610db23 100644--- a/shared/src/book/design/design-template-pick.spec.ts+++ b/shared/src/book/design/design-template-pick.spec.ts@@ -209,4 +209,24 @@ describe('the template picker', () => {expect(innerPool('riso').every((t) => ['riso', 'poster-pop', 'cutout'].includes(t.archetype))).toBe(true);expect([...chunkSizesOf(innerPool('riso')).story]).toContain(0);});++ it("AUTOTPL-013: a page the book's own styles can frame every photo of stays in them, whatever the rhythm", () => {+ for (const archetype of BOOK_COVER_ARCHETYPES) {+ const kin = [archetype, ...ARCHETYPE_KIN[archetype]];+ for (let n = 0; n <= 12; n++) {+ for (const story of ['', STORY]) {+ const frames = (t: BookDecoratedTemplate) =>+ templatePhotoSlots(t) === n && (!story || roles(t).includes('body')) && !roles(t).includes('map');+ if (!innerPool(archetype).some(frames)) continue;+ const pick = pickInnerTemplate(chunk(n, story), ctxOf({ archetype, theme: null }));+ expect(pick && templatePhotoSlots(pick), `${archetype} ${n}`).toBe(n);+ expect(kin, `${archetype} ${n} ${story ? 'story' : ''}`).toContain(pick?.archetype);+ // The page before on its own is given up rather than a frame or the style.+ const again = pickInnerTemplate(chunk(n, story), ctxOf({ archetype, theme: null, history: [pick!.id] }));+ expect(again && templatePhotoSlots(again), `${archetype} ${n} again`).toBe(n);+ expect(kin).toContain(again?.archetype);+ }+ }+ }+ });});diff --git a/shared/src/book/design/design-template-pick.ts b/shared/src/book/design/design-template-pick.tsindex bc91a023e..23a79efe4 100644--- a/shared/src/book/design/design-template-pick.ts+++ b/shared/src/book/design/design-template-pick.ts@@ -52,7 +52,7 @@ export const THEME_ARCHETYPE: Readonly<Record<BookThemeId, BookCoverArchetype>>/** The archetypes whose spreads sit well in a book of another, nearest first. */export const ARCHETYPE_KIN: Readonly<Record<BookCoverArchetype, readonly BookCoverArchetype[]>> = {'spine-band': ['minimal-serif', 'postcard'],- 'poster-pop': ['cutout', 'stamp-collage'],+ 'poster-pop': ['cutout', 'riso', 'stamp-collage'],cutout: ['poster-pop', 'riso'],postcard: ['vintage-poster', 'spine-band'],'grid-badge': ['minimal-serif', 'stamp-collage'],@@ -260,11 +260,19 @@ function admits(ctx: TemplatePickCtx,before: TemplateEnergy | undefined,) {- if (tpl.kind !== 'inner' || slots(tpl) > chunk.photos.length) return false;+ return fitsAtAll(tpl, chunk, ctx) && !keepsApart(tpl, ctx, before);+}++/** Whether a template can hold the page: no frame left empty, the story and the map where it has them. */+function fitsAtAll(tpl: BookDecoratedTemplate, chunk: TemplateChunk, ctx: TemplatePickCtx) {+ if (tpl.kind !== 'inner' || slots(tpl) > chunk.photos.length || ctx.avoid?.includes(tpl.id)) return false;if (chunk.story && !hasRole(tpl, 'body')) return false;- if (hasRole(tpl, 'map') && !chunk.mappable) return false;- if (ctx.history[ctx.history.length - 1] === tpl.id || ctx.avoid?.includes(tpl.id)) return false;- return !(isLoud(templateEnergy(tpl)) && isBusy(before));+ return !hasRole(tpl, 'map') || chunk.mappable;+}++/** The rhythm a book keeps where it can: never the page before again, never loud after loud or lively. */+function keepsApart(tpl: BookDecoratedTemplate, ctx: TemplatePickCtx, before: TemplateEnergy | undefined) {+ return ctx.history[ctx.history.length - 1] === tpl.id || (isLoud(templateEnergy(tpl)) && isBusy(before));}/** The orientation of a template's first frame on this format: wide, tall or square. */@@ -287,7 +295,7 @@ function storyScore(tpl: BookDecoratedTemplate, chunk: TemplateChunk, ctx: Templ/** What a photo left without a frame costs a template. */const UNUSED_PHOTO = 60;-/** What a template of an archetype neither the book's nor its kin costs: taken only where those leave a photo out. */+/** What a template of an archetype neither the book's nor its kin costs, where only such can take the page. */const FOREIGN = 25;/** How well a template suits the page, the higher the better. */@@ -297,7 +305,7 @@ function scoreOf(ctx: TemplatePickCtx,before: TemplateEnergy | undefined,) {- // A photo the page has no frame for waits in the tray: worse than a template of a kin archetype.+ // A photo the page has no frame for waits in the tray.let score = 100 - UNUSED_PHOTO * (chunk.photos.length - slots(tpl));if (tpl.archetype === ctx.archetype) score += 20;else if (ARCHETYPE_KIN[ctx.archetype].includes(tpl.archetype)) score += 8;@@ -332,17 +340,36 @@ function energyOfId(pool: readonly BookDecoratedTemplate[], id: string | undefin}/**- * The template a page is laid on: the archetype's own and its kin's first,- * another archetype's only where theirs would leave a photo without a frame;- * undefined when none at all can take the page.+ * The template a page is laid on. A frame for every photo comes first, then+ * the book's own styles (its archetype and its kin), then the rhythm:+ *+ * 1. the own styles, every photo framed, the rhythm kept;+ * 2. the own styles, every photo framed, the rhythm given up for this page;+ * 3. another archetype, every photo framed, the rhythm kept;+ * 4. the own styles with a photo left to wait in the tray;+ * 5. whatever can take the page at all.+ *+ * Undefined when nothing can.*/export function pickInnerTemplate(chunk: TemplateChunk, ctx: TemplatePickCtx): BookDecoratedTemplate | undefined {const all = decoratedTemplatesFor('inner');+ const own = innerPool(ctx.archetype);const before = energyOfId(all, ctx.history[ctx.history.length - 1]);- const scored = all- .filter((t) => admits(t, chunk, ctx, before))- .map((tpl) => ({ tpl, score: scoreOf(tpl, chunk, ctx, before) }));- return bestOf(scored, ctx.seed, ctx.key);+ const full = (t: BookDecoratedTemplate) => slots(t) === chunk.photos.length;+ const kept = (t: BookDecoratedTemplate) => admits(t, chunk, ctx, before);+ const held = (t: BookDecoratedTemplate) => fitsAtAll(t, chunk, ctx);+ const tiers: [readonly BookDecoratedTemplate[], (t: BookDecoratedTemplate) => boolean][] = [+ [own, (t) => full(t) && kept(t)],+ [own, (t) => full(t) && held(t)],+ [all, (t) => full(t) && kept(t)],+ [own, kept],+ [all, held],+ ];+ for (const [pool, takes] of tiers) {+ const scored = pool.filter(takes).map((tpl) => ({ tpl, score: scoreOf(tpl, chunk, ctx, before) }));+ if (scored.length) return bestOf(scored, ctx.seed, ctx.key);+ }+ return undefined;}/** What a cover may be laid with: how many photos there are, and whether the cover photo stands tall. */diff --git a/shared/src/book/design/design-templated.parity.json b/shared/src/book/design/design-templated.parity.jsonindex 7063dab29..2bea8127f 100644--- a/shared/src/book/design/design-templated.parity.json+++ b/shared/src/book/design/design-templated.parity.json@@ -1,46 +1,47 @@{- "A/fabric-classic/head": "fb618faf28e68d0f",- "A/fabric-classic/plan": "2ca591e0d4dd17bb",- "A/fabric-classic/spread/0": "98d1af5f8b6090b7",+ "A/fabric-classic/head": "74bb0439e4575ed7",+ "A/fabric-classic/plan": "2e813091b20151b7",+ "A/fabric-classic/spread/0": "8f7e1afe57460ae6","A/fabric-classic/spread/1": "aa637b0de2518bf5",- "A/fabric-classic/spread/10": "4e2ff8d6a3dbb703",- "A/fabric-classic/spread/11": "b2194950c53cdd3c",- "A/fabric-classic/spread/12": "8fbffee2569b59e1",- "A/fabric-classic/spread/13": "71b83c5324f9e7fd",- "A/fabric-classic/spread/14": "52c76dae8b0aa332",- "A/fabric-classic/spread/15": "0056090b0878b3fa",- "A/fabric-classic/spread/16": "31003c2416a1cf66",- "A/fabric-classic/spread/17": "c2e94f7701145f81",- "A/fabric-classic/spread/18": "3f5fe08a57fe334e",- "A/fabric-classic/spread/19": "57963677a89b5ca2",+ "A/fabric-classic/spread/10": "e69ba5b8577eaccd",+ "A/fabric-classic/spread/11": "bc296929478ee85f",+ "A/fabric-classic/spread/12": "3053f53078476b2a",+ "A/fabric-classic/spread/13": "e636be9ac1bfac5c",+ "A/fabric-classic/spread/14": "9c9506b1446385fa",+ "A/fabric-classic/spread/15": "f9c0ddb3332943e1",+ "A/fabric-classic/spread/16": "a63442848952fded",+ "A/fabric-classic/spread/17": "31aff9e6d65d8da4",+ "A/fabric-classic/spread/18": "bf897175ec7245e3",+ "A/fabric-classic/spread/19": "bf8169ba3d96440e","A/fabric-classic/spread/2": "8278d3c2507527f9",- "A/fabric-classic/spread/20": "359bf9a8b179fbd4",- "A/fabric-classic/spread/21": "61f06e7b8b03a23e",- "A/fabric-classic/spread/22": "b11b5b3fb34a34eb",- "A/fabric-classic/spread/23": "a55189e7bfd3934d",+ "A/fabric-classic/spread/20": "7233b4dfd372d1e1",+ "A/fabric-classic/spread/21": "5bb02502fc0ad047",+ "A/fabric-classic/spread/22": "61f06e7b8b03a23e",+ "A/fabric-classic/spread/23": "b11b5b3fb34a34eb",+ "A/fabric-classic/spread/24": "a55189e7bfd3934d","A/fabric-classic/spread/3": "2ceb4890ba95c249","A/fabric-classic/spread/4": "7f5a904449283690","A/fabric-classic/spread/5": "61024db654103dd4",- "A/fabric-classic/spread/6": "ac8b6bb2ee46806e",- "A/fabric-classic/spread/7": "f6eaad286cbe258a",- "A/fabric-classic/spread/8": "a19d4e9230364789",- "A/fabric-classic/spread/9": "5081bc598f459c9f",+ "A/fabric-classic/spread/6": "8117ccbdc6dc7f1e",+ "A/fabric-classic/spread/7": "da36e9e35e753415",+ "A/fabric-classic/spread/8": "198e5a3ff4c85366",+ "A/fabric-classic/spread/9": "516fc6e34b8a200e","A/midnight/head": "ce0d82281cbc3e1f",- "A/midnight/plan": "f71989d04f78b247",- "A/midnight/spread/0": "d6067998399ebc18",+ "A/midnight/plan": "59eb38db863e4b47",+ "A/midnight/spread/0": "eb607a0fc5b592ac","A/midnight/spread/1": "d9f5d78659332b45",- "A/midnight/spread/10": "e4508723fcc91fd2",- "A/midnight/spread/11": "b42c27c1e29b454b",- "A/midnight/spread/12": "9aef640eb48543d4",- "A/midnight/spread/13": "9298685922238183",- "A/midnight/spread/14": "a8f283b63056dc82",- "A/midnight/spread/15": "4603d240cc7fa47d",- "A/midnight/spread/16": "c7f989b59b859ef5",- "A/midnight/spread/17": "47628c608d0fcf77",- "A/midnight/spread/18": "1afcdd2152188bc5",- "A/midnight/spread/19": "990391282f4663f5",+ "A/midnight/spread/10": "cad00147fd8ffd13",+ "A/midnight/spread/11": "4cc728884c5e85f9",+ "A/midnight/spread/12": "f2e0ed48e8d5b738",+ "A/midnight/spread/13": "a05050ef05c8a754",+ "A/midnight/spread/14": "b9c738456d6cbf49",+ "A/midnight/spread/15": "050c1237febc94e8",+ "A/midnight/spread/16": "f2761e7e09ff254b",+ "A/midnight/spread/17": "e4d8bf042e9f24d2",+ "A/midnight/spread/18": "3daa8f2074ce601b",+ "A/midnight/spread/19": "faf534a56be6f24a","A/midnight/spread/2": "b00839cd0dc1451b",- "A/midnight/spread/20": "0c98113176e3f09a",+ "A/midnight/spread/20": "3c5d249069097110","A/midnight/spread/21": "38d76ca81db84db0","A/midnight/spread/22": "eba329fd185958b3","A/midnight/spread/23": "9664fbd24505a632",@@ -48,35 +49,36 @@"A/midnight/spread/4": "98f7916fe80a1243","A/midnight/spread/5": "b57ccdf57fffaec4","A/midnight/spread/6": "ed8bd8657c310997",- "A/midnight/spread/7": "d19ae08326e5f88d",- "A/midnight/spread/8": "56424e21fced774a",- "A/midnight/spread/9": "303032b7354eba0c",- "A/riso/head": "f23966c329e4e7f3",- "A/riso/plan": "1b5beca655ce0cd6",- "A/riso/spread/0": "874dffde4ac89d0b",+ "A/midnight/spread/7": "4eb6a338f0d7fc68",+ "A/midnight/spread/8": "e2d2c7791a83e1a1",+ "A/midnight/spread/9": "05c31075e8a1f631",+ "A/riso/head": "7d43d0900fbe0f57",+ "A/riso/plan": "7e50f5d2a0b80e0e",+ "A/riso/spread/0": "657be2c47bd8ad61","A/riso/spread/1": "8de92788de29277b",- "A/riso/spread/10": "ac5238ef848adccf",- "A/riso/spread/11": "651e7f318aba0dc3",- "A/riso/spread/12": "f32a719e61a22cf3",- "A/riso/spread/13": "aa0bf6589df257be",- "A/riso/spread/14": "4bdd5ea5f37f88ce",- "A/riso/spread/15": "7111cc1d2fdaee5a",- "A/riso/spread/16": "3c6fb9d26c3340d7",- "A/riso/spread/17": "d2b7fb8a739bfc1c",- "A/riso/spread/18": "71c3301e6970b43f",- "A/riso/spread/19": "3dc796729fe6e1fc",+ "A/riso/spread/10": "8f8039b3c8548358",+ "A/riso/spread/11": "5dc1c12abcf36f29",+ "A/riso/spread/12": "84b6af0e7a851a60",+ "A/riso/spread/13": "c0aff5dc75e09532",+ "A/riso/spread/14": "3d8e67e0c536334c",+ "A/riso/spread/15": "29101a4941a4e9c5",+ "A/riso/spread/16": "d58f70c381d9f6ae",+ "A/riso/spread/17": "00caa407cb2a0677",+ "A/riso/spread/18": "ed1fbeca6e577132",+ "A/riso/spread/19": "323e6d081b913240","A/riso/spread/2": "5c9a93de9e6467d6",- "A/riso/spread/20": "8189fd41b9d13628",- "A/riso/spread/21": "f696e1aad9a5e0f6",- "A/riso/spread/22": "a748ada7a028818e",- "A/riso/spread/23": "9abf456403732463",+ "A/riso/spread/20": "84f564cff0148bc3",+ "A/riso/spread/21": "cc4b2d6f3ad38662",+ "A/riso/spread/22": "f696e1aad9a5e0f6",+ "A/riso/spread/23": "a748ada7a028818e",+ "A/riso/spread/24": "9abf456403732463","A/riso/spread/3": "20a199a47535dea7","A/riso/spread/4": "45bfc268e430c87d","A/riso/spread/5": "d15be16f42113e11","A/riso/spread/6": "3056ef6c2b6ebdd1","A/riso/spread/7": "3f58daf471a89d43",- "A/riso/spread/8": "333f3efc450a109e",- "A/riso/spread/9": "4696b11649bdae79",+ "A/riso/spread/8": "ce87c24b384a8bf0",+ "A/riso/spread/9": "6e02b9784f9d5791","B/fabric-classic/head": "b7377b9e48255d7b","B/fabric-classic/plan": "121194e82b626f79","B/fabric-classic/spread/0": "87325aa216fe9c6a",@@ -109,102 +111,112 @@"B/riso/spread/6": "a748ada7a028818e","B/riso/spread/7": "877657cfa95e3cac","C/fabric-classic/head": "ddd21691c506a600",- "C/fabric-classic/plan": "24dedbf02c4837ad",- "C/fabric-classic/spread/0": "65b310c86982ba73",+ "C/fabric-classic/plan": "c31dcaa9b3603acc",+ "C/fabric-classic/spread/0": "92d21ac9d8e866df","C/fabric-classic/spread/1": "7094bacb28cc210a","C/fabric-classic/spread/10": "b11b5b3fb34a34eb","C/fabric-classic/spread/11": "f7d9814c6b8649fd",- "C/fabric-classic/spread/2": "0f44c632cf8a2a16",- "C/fabric-classic/spread/3": "550e08d70efb38af",- "C/fabric-classic/spread/4": "1798f89f0de08592",- "C/fabric-classic/spread/5": "e270122f62d0c8a0",- "C/fabric-classic/spread/6": "1f4e718719dc5a21",- "C/fabric-classic/spread/7": "6a5148ce5980f492",+ "C/fabric-classic/spread/2": "3e514b7dd87c7d49",+ "C/fabric-classic/spread/3": "a964aa1e7f057294",+ "C/fabric-classic/spread/4": "4a275bcefa9a8eb0",+ "C/fabric-classic/spread/5": "10ed185ab3fd9756",+ "C/fabric-classic/spread/6": "7bfbef523f58c3fc",+ "C/fabric-classic/spread/7": "71330d722ab54efd","C/fabric-classic/spread/8": "a7f0ed591793b5e1",- "C/fabric-classic/spread/9": "2622a67a8883ad77",- "C/midnight/head": "192eab52ca6d5847",- "C/midnight/plan": "f102868f1869fae5",- "C/midnight/spread/0": "d0179be86d1ad360",+ "C/fabric-classic/spread/9": "31665bce59abeafe",+ "C/midnight/head": "f1e6077175cb2e20",+ "C/midnight/plan": "14fb454d02caf6f9",+ "C/midnight/spread/0": "79eae9202a85d430","C/midnight/spread/1": "d9f5d78659332b45",- "C/midnight/spread/10": "2363fcae0008acbc",- "C/midnight/spread/11": "eba329fd185958b3",- "C/midnight/spread/12": "ebbba57a4116faa3",+ "C/midnight/spread/10": "81411f2fe106cd7e",+ "C/midnight/spread/11": "191aa44138c1e076",+ "C/midnight/spread/12": "abe0197797669d57",+ "C/midnight/spread/13": "eba329fd185958b3",+ "C/midnight/spread/14": "ebbba57a4116faa3","C/midnight/spread/2": "7b99390522f39fe5",- "C/midnight/spread/3": "00bbf4a300b065d9",- "C/midnight/spread/4": "41e460c85814e66c",- "C/midnight/spread/5": "aa2882594aedb3cc",- "C/midnight/spread/6": "bae5ec4f220e42bd",- "C/midnight/spread/7": "fa6b080fc5dde83e",- "C/midnight/spread/8": "3d99b3e9932ef3b4",- "C/midnight/spread/9": "921410b25c401cf0",- "C/riso/head": "13bb3a22ba5ffb72",- "C/riso/plan": "5b16a60268358e50",- "C/riso/spread/0": "81f272372d90da7b",+ "C/midnight/spread/3": "7391268691e50ede",+ "C/midnight/spread/4": "4f08a3fc6da821a5",+ "C/midnight/spread/5": "6d06a2d469c2d5e2",+ "C/midnight/spread/6": "6238c8bc28c5964e",+ "C/midnight/spread/7": "8a5cc2233372bb47",+ "C/midnight/spread/8": "a445fe1b9090293d",+ "C/midnight/spread/9": "e2af9bfdb8789b4b",+ "C/riso/head": "d19997b07778d1dc",+ "C/riso/plan": "175dadeb8bb730a6",+ "C/riso/spread/0": "8453dd7b94afe68d","C/riso/spread/1": "8de92788de29277b",- "C/riso/spread/10": "62638c6830cc5a89",- "C/riso/spread/11": "9683c291014e90a4",- "C/riso/spread/12": "a748ada7a028818e",- "C/riso/spread/13": "81e4b4a0dcc6961a",- "C/riso/spread/2": "bab7a9d12fd0aa7e",- "C/riso/spread/3": "edb0ebe3a843a937",- "C/riso/spread/4": "a4b3de47c30627ef",- "C/riso/spread/5": "7c2581b0113b5426",- "C/riso/spread/6": "5863b346ecff6743",- "C/riso/spread/7": "f4e17840337b10ef",- "C/riso/spread/8": "41c4f9a40716f107",- "C/riso/spread/9": "355adfa6c181a5e5",- "D/fabric-classic/head": "00392b522e232495",- "D/fabric-classic/plan": "9a293013918e025e",- "D/fabric-classic/spread/0": "972d99b392069408",+ "C/riso/spread/10": "6b5aa1dac73ab777",+ "C/riso/spread/11": "c20262603c86d43e",+ "C/riso/spread/12": "8e263c445c0418d2",+ "C/riso/spread/13": "a748ada7a028818e",+ "C/riso/spread/14": "81e4b4a0dcc6961a",+ "C/riso/spread/2": "5e43386b045d926c",+ "C/riso/spread/3": "9587f2fe2fc9cd04",+ "C/riso/spread/4": "edb0ebe3a843a937",+ "C/riso/spread/5": "f8a935188537c224",+ "C/riso/spread/6": "d2ca03597f3732c6",+ "C/riso/spread/7": "7a4374ec7906855f",+ "C/riso/spread/8": "2dd867bf81ca7901",+ "C/riso/spread/9": "aea9baf94aa13bc8",+ "D/fabric-classic/head": "54fa8987fea87ce4",+ "D/fabric-classic/plan": "a2d0423833838dcc",+ "D/fabric-classic/spread/0": "1136daea45c98c7d","D/fabric-classic/spread/1": "931682bc5827ad8a",- "D/fabric-classic/spread/10": "83ce523a523ba7ea",- "D/fabric-classic/spread/11": "27739eb8a77f0035",- "D/fabric-classic/spread/12": "e2a0171226254031",- "D/fabric-classic/spread/13": "a0bf0a056caa1f44",- "D/fabric-classic/spread/14": "b11b5b3fb34a34eb",- "D/fabric-classic/spread/15": "c40cdcb18e2ef0bc",+ "D/fabric-classic/spread/10": "98449436f064fc7c",+ "D/fabric-classic/spread/11": "e58c5ea28b6e5d14",+ "D/fabric-classic/spread/12": "a422c04ae2d9e32f",+ "D/fabric-classic/spread/13": "b512aff5192eae71",+ "D/fabric-classic/spread/14": "b92cc5c3c532f2cb",+ "D/fabric-classic/spread/15": "b11b5b3fb34a34eb",+ "D/fabric-classic/spread/16": "c40cdcb18e2ef0bc","D/fabric-classic/spread/2": "86dd9a101af346f4","D/fabric-classic/spread/3": "afe19cb105dfefa0","D/fabric-classic/spread/4": "80d31e5986b670e2",- "D/fabric-classic/spread/5": "8127a39f5b6a7541",- "D/fabric-classic/spread/6": "5446e309eae3c696",- "D/fabric-classic/spread/7": "1afc341fcd06a62b",- "D/fabric-classic/spread/8": "8513bc24ffc7db1d",- "D/fabric-classic/spread/9": "a33e805786bafb0f",- "D/midnight/head": "f68b1563b89dd3f8",- "D/midnight/plan": "d413165d19365a09",- "D/midnight/spread/0": "7cd2f7ff23d75a76",+ "D/fabric-classic/spread/5": "664cd81373c14243",+ "D/fabric-classic/spread/6": "c1d232a5aed51318",+ "D/fabric-classic/spread/7": "8d08e54aa79c8c74",+ "D/fabric-classic/spread/8": "18f531e0a85ff3de",+ "D/fabric-classic/spread/9": "a7ddf2eb33bb75f6",+ "D/midnight/head": "da510cf5f95bad40",+ "D/midnight/plan": "3bd0d52ed4e476c7",+ "D/midnight/spread/0": "440b7d69daa18a7a","D/midnight/spread/1": "d9f5d78659332b45",- "D/midnight/spread/10": "d55a6a868ef1afd6",- "D/midnight/spread/11": "2b249dffc109e11f",- "D/midnight/spread/12": "61f2f1d0a1010041",- "D/midnight/spread/13": "084752209131d1e9",- "D/midnight/spread/14": "eba329fd185958b3",- "D/midnight/spread/15": "6e6e6c877443c5e7",+ "D/midnight/spread/10": "824d62135a0fe827",+ "D/midnight/spread/11": "03bbcf527fcbce9f",+ "D/midnight/spread/12": "d2e1ae86b69d8a5c",+ "D/midnight/spread/13": "7025aef32f444ab2",+ "D/midnight/spread/14": "581f0008497c1143",+ "D/midnight/spread/15": "f86784f4b061a31e",+ "D/midnight/spread/16": "ec6c98d1713ff353",+ "D/midnight/spread/17": "03888512d15a5895",+ "D/midnight/spread/18": "eba329fd185958b3",+ "D/midnight/spread/19": "6e6e6c877443c5e7","D/midnight/spread/2": "cef4235690d44e53","D/midnight/spread/3": "cd34cb85119476ee",- "D/midnight/spread/4": "278b027b3ee6da5e",- "D/midnight/spread/5": "11c77cb59d466cee",- "D/midnight/spread/6": "18f3f3000e140a7f",- "D/midnight/spread/7": "2b6e0be2001fc0f6",- "D/midnight/spread/8": "7ff118f54e235945",- "D/midnight/spread/9": "d42eac1e9e169a65",- "D/riso/head": "92d1faaa7684dc71",- "D/riso/plan": "6b7a7e5621354232",- "D/riso/spread/0": "0e7a9e0446c17176",+ "D/midnight/spread/4": "eeafe83df0612856",+ "D/midnight/spread/5": "597d729fb1cfb962",+ "D/midnight/spread/6": "0023fe5672ad9141",+ "D/midnight/spread/7": "84bdb5c0cf502f37",+ "D/midnight/spread/8": "ea1a0157b2405cff",+ "D/midnight/spread/9": "5d38d38d1226fe1e",+ "D/riso/head": "1c8f99d99acdea28",+ "D/riso/plan": "f2a8704019582093",+ "D/riso/spread/0": "7b0d816ffda1dd01","D/riso/spread/1": "8de92788de29277b",- "D/riso/spread/10": "3bf04d7ce7be2b8c",- "D/riso/spread/11": "72220ff9ab285b8b",- "D/riso/spread/12": "3ea9311b14cfd10b",- "D/riso/spread/13": "c7a09a0eac8e6b15",- "D/riso/spread/14": "a748ada7a028818e",- "D/riso/spread/15": "ed87c0a4c77f241c",+ "D/riso/spread/10": "c85c0634205e3232",+ "D/riso/spread/11": "f97635aee763f93e",+ "D/riso/spread/12": "37f5d0dc381cfdb4",+ "D/riso/spread/13": "7083d486cc5556c5",+ "D/riso/spread/14": "711a3787fce72914",+ "D/riso/spread/15": "27d0db240d32de9a",+ "D/riso/spread/16": "a748ada7a028818e",+ "D/riso/spread/17": "ed87c0a4c77f241c","D/riso/spread/2": "78f24755fb7ad38a","D/riso/spread/3": "047741da3e1adc20",- "D/riso/spread/4": "e5422a6420e638e8",- "D/riso/spread/5": "048d150f1354f995",- "D/riso/spread/6": "b5ec167d7af3af62",- "D/riso/spread/7": "c2dcd8909c7a12a0",- "D/riso/spread/8": "ba544d78e16ead7c",- "D/riso/spread/9": "bc85383342f55f6d"+ "D/riso/spread/4": "294d0c2a0600ed4a",+ "D/riso/spread/5": "b1f6c2832a5f5737",+ "D/riso/spread/6": "a898defea41081ec",+ "D/riso/spread/7": "027026c49ea68a27",+ "D/riso/spread/8": "4ff93cb4d24f729c",+ "D/riso/spread/9": "988a20c009c9d562"}diff --git a/shared/src/book/design/design-templated.ts b/shared/src/book/design/design-templated.tsindex 9a0627063..369e85eed 100644--- a/shared/src/book/design/design-templated.ts+++ b/shared/src/book/design/design-templated.ts@@ -243,27 +243,36 @@ function storyRoom(c: ComposeCtx, pool: readonly BookDecoratedTemplate[]): Map<nreturn room;}-/** A page of a template from outside the book's own pool costs this much more than one of its own. */-const FOREIGN_PAGE = 8;/** A first page whose story frame cannot hold the story costs this much more: a page of words follows. */const SHORT_STORY_PAGE = 12;+/** A page only another archetype has a template for costs this much more, so as few as can be are. */+const FOREIGN_PAGE = 8;/*** The photo counts a chapter's pages may take: those of the book's own pool- * of templates, and those only another archetype has at a price, so a photo- * finds a frame there rather than none.+ * of templates, the pool the picker lays them from. `wide` adds those only+ * another archetype has, at a price, for a chapter the own pool would leave+ * a photo of without a frame.*/-function chunkSizesFor(c: ComposeCtx, archetype: BookCoverArchetype, words: string): ChunkSizes {+function chunkSizesFor(c: ComposeCtx, archetype: BookCoverArchetype, words: string, wide = false): ChunkSizes {const pool = innerPool(archetype);const own = chunkSizesOf(pool);- const all = chunkSizesOf(decoratedTemplatesFor('inner'));- const room = storyRoom(c, words ? decoratedTemplatesFor('inner') : []);+ const sizes = wide ? chunkSizesOf(decoratedTemplatesFor('inner')) : own;+ const room = storyRoom(c, words ? (wide ? decoratedTemplatesFor('inner') : pool) : []);const pageCost = (s: number, first: boolean) => {const foreign = !(first && words ? own.story : own.any).has(s);const short = first && words && (room.get(s) ?? 0) < words.length;return (foreign ? FOREIGN_PAGE : 0) + (short ? SHORT_STORY_PAGE : 0);};- return { any: all.any, story: all.story, pageCost };+ return { any: sizes.any, story: sizes.story, pageCost };+}++/** A chapter's photos cut into pages of the own pool, or of any where the own pool leaves one without a frame. */+function cutChapter(c: ComposeCtx, archetype: BookCoverArchetype, words: string, photos: number) {+ const own = chunkPhotos(photos, !!words, chunkSizesFor(c, archetype, words));+ if (!own.parked) return own;+ const wide = chunkPhotos(photos, !!words, chunkSizesFor(c, archetype, words, true));+ return wide.parked < own.parked ? wide : own;}/** A chapter's pages: its photos cut into parts, the first taking its first entry's words, then the rest of them. */@@ -272,8 +281,7 @@ function chapterPages(l: Laying, chapter: DesignChapter, notes: string[]) {if (!entry) return;const name = chapter.label ?? entry.title ?? null;const words = storyOf(l.c, entry);- const sizes = chunkSizesFor(l.c, l.base.archetype, words);- const cut = chunkPhotos(chapter.photos.length, !!words, sizes);+ const cut = cutChapter(l.c, l.base.archetype, words, chapter.photos.length);let at = 0;let rest = '';cut.sizes.forEach((size, i) => {