Deck: presses, the talk's order and moves, shared by Go and JS
deck.Presses and ArrivalOf work a slide's presses out from its boxes' step values (ties, midpoints, each lists, columns containers, boxes that show nothing). TalkOrder, Start, Advance and Settle move an absolute Position through the core or full talk; ForReaders drops parked slides. fixtures/presses.mjs and moves.mjs are the browser's twins, and vectors/presses.json and moves.json hold both sides to one answer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 files changed,
+1,080
−0
fixtures/moves.mjs+104 −0fixtures/moves.test.mjs+28 −0fixtures/presses.mjs+118 −0fixtures/presses.test.mjs+22 −0fixtures/vectors/moves.json+63 −0fixtures/vectors/presses.json+200 −0internal/slides/deck/presses.go+205 −0internal/slides/deck/presses_test.go+66 −0internal/slides/deck/talk.go+193 −0internal/slides/deck/talk_test.go+81 −0
diff --git a/fixtures/moves.mjs b/fixtures/moves.mjs| new file mode 100644 |
| index 0000000..cba23ff |
| --- /dev/null |
| +++ b/fixtures/moves.mjs |
| @@ -0,0 +1,104 @@ |
| +// moves.mjs — the talk's order and where a press takes it, for the |
| +// browser: internal/slides/deck/talk.go's TalkOrder, Start, Advance and |
| +// Settle. vectors/moves.json holds the two to one answer, so a rule |
| +// changes on both sides or on neither. |
| +// |
| +// A position is {slide, step, mode, black}: the slide by id, the press |
| +// on it, 'core' or 'full', and whether the screen is black. A slide of |
| +// '' is nowhere, which is where an empty talk is. A move is {op, slide}. |
| +import { presses } from './presses.mjs' |
| + |
| +const slidesOf = view => (Array.isArray(view && view.slides) ? view.slides : []) |
| +const indexOf = (slides, id) => slides.findIndex(s => s.id === id) |
| +const count = slide => presses(slide).length |
| +const at = (slide, mode, step = 0) => ({ slide: slide.id, step, mode, black: false }) |
| +const nowhere = mode => ({ slide: '', step: 0, mode, black: false }) |
| +const clamp = (k, n) => Math.min(Math.max(k, 0), n) |
| + |
| +/** The deck indices of the slides in the talk: parked never, full-only only in full. */ |
| +export function talkOrder (view, mode) { |
| + const out = [] |
| + slidesOf(view).forEach((s, i) => { |
| + if (s.talk === 'parked' || (s.talk === 'full' && mode !== 'full')) return |
| + out.push(i) |
| + }) |
| + return out |
| +} |
| + |
| +/** Where a talk begins: the first slide of the core talk. */ |
| +export function start (view) { |
| + const order = talkOrder(view, 'core') |
| + return order.length ? at(slidesOf(view)[order[0]], 'core') : nowhere('core') |
| +} |
| + |
| +/** |
| + * Where a move takes the talk from pos. next and back step through the |
| + * slide's presses, then leave it for the neighbouring slide of the talk |
| + * by its place in the deck (back lands fully built); at either end they |
| + * stay. first, last and goto land at step 0. Each lifts black. goto a |
| + * full-only slide in core switches to full; goto a parked or missing |
| + * slide changes nothing. mode flips the mode, black toggles, and any |
| + * other op changes nothing. |
| + */ |
| +export function advance (view, pos, move) { |
| + const slides = slidesOf(view) |
| + const order = talkOrder(view, pos.mode) |
| + switch (move.op) { |
| + case 'black': |
| + return { ...pos, black: !pos.black } |
| + case 'mode': |
| + return { ...pos, mode: pos.mode === 'full' ? 'core' : 'full' } |
| + case 'goto': { |
| + const i = move.slide ? indexOf(slides, move.slide) : -1 |
| + if (i < 0 || slides[i].talk === 'parked') return pos |
| + return at(slides[i], slides[i].talk === 'full' ? 'full' : pos.mode) |
| + } |
| + case 'first': case 'last': |
| + if (!order.length) return nowhere(pos.mode) |
| + return at(slides[move.op === 'first' ? order[0] : order[order.length - 1]], pos.mode) |
| + case 'next': case 'back': |
| + return step(view, pos, move.op === 'next', order) |
| + } |
| + return pos |
| +} |
| + |
| +function step (view, pos, forward, order) { |
| + const slides = slidesOf(view) |
| + if (!order.length) return nowhere(pos.mode) |
| + const cur = indexOf(slides, pos.slide) |
| + if (cur < 0) return { ...settle(view, pos), black: false } |
| + const n = count(slides[cur]) |
| + const k = clamp(pos.step, n) |
| + if (forward && k < n) return { ...pos, step: k + 1, black: false } |
| + if (!forward && k > 0) return { ...pos, step: k - 1, black: false } |
| + if (forward) { |
| + const next = order.find(i => i > cur) |
| + if (next !== undefined) return at(slides[next], pos.mode) |
| + } else { |
| + const prev = order.findLast(i => i < cur) |
| + if (prev !== undefined) return at(slides[prev], pos.mode, count(slides[prev])) |
| + } |
| + return { ...pos, step: k, black: false } |
| +} |
| + |
| +/** |
| + * pos put back on its feet after the deck changed under it. A missing or |
| + * parked slide becomes the next slide of the order after its place in |
| + * the deck at step 0, or the order's last (a missing slide has no place, |
| + * so it is always the last). No slide at all becomes the first. A step |
| + * outside the slide's presses clamps into them. An empty talk gives the |
| + * mode alone. |
| + */ |
| +export function settle (view, pos) { |
| + const slides = slidesOf(view) |
| + const order = talkOrder(view, pos.mode) |
| + if (!order.length) return nowhere(pos.mode) |
| + const keep = slide => ({ ...at(slide, pos.mode), black: pos.black }) |
| + if (pos.slide === '') return keep(slides[order[0]]) |
| + const cur = indexOf(slides, pos.slide) |
| + if (cur < 0 || slides[cur].talk === 'parked') { |
| + const next = cur < 0 ? undefined : order.find(i => i > cur) |
| + return keep(slides[next ?? order[order.length - 1]]) |
| + } |
| + return { ...pos, step: clamp(pos.step, count(slides[cur])) } |
| +} |
diff --git a/fixtures/moves.test.mjs b/fixtures/moves.test.mjs| new file mode 100644 |
| index 0000000..3072713 |
| --- /dev/null |
| +++ b/fixtures/moves.test.mjs |
| @@ -0,0 +1,28 @@ |
| +// moves.test.mjs — the browser's moves against the server's, through the |
| +// shared vectors (vectors/moves.json, which |
| +// internal/slides/deck/talk_test.go reads too). Two ops there are not |
| +// moves: "start" is start(view) and "settle" is settle(view, from). |
| +import { test } from 'node:test' |
| +import assert from 'node:assert/strict' |
| +import { readFileSync } from 'node:fs' |
| +import { talkOrder, start, advance, settle } from './moves.mjs' |
| + |
| +const vectors = JSON.parse(readFileSync(new URL('./vectors/moves.json', import.meta.url))) |
| + |
| +test('moves vectors', async t => { |
| + assert.ok(vectors.length >= 20) |
| + for (const c of vectors) { |
| + await t.test(c.name, () => { |
| + const got = c.move.op === 'start' |
| + ? start(c.deck) |
| + : c.move.op === 'settle' ? settle(c.deck, c.from) : advance(c.deck, c.from, c.move) |
| + assert.deepEqual(got, c.to) |
| + }) |
| + } |
| +}) |
| + |
| +test('talkOrder leaves out parked slides, and full-only ones in core', () => { |
| + const view = { slides: [{ id: 'a' }, { id: 'b', talk: 'full' }, { id: 'c', talk: 'parked' }, { id: 'd' }] } |
| + assert.deepEqual(talkOrder(view, 'core'), [0, 3]) |
| + assert.deepEqual(talkOrder(view, 'full'), [0, 1, 3]) |
| +}) |
diff --git a/fixtures/presses.mjs b/fixtures/presses.mjs| new file mode 100644 |
| index 0000000..a4022b4 |
| --- /dev/null |
| +++ b/fixtures/presses.mjs |
| @@ -0,0 +1,118 @@ |
| +// presses.mjs — a slide's presses, worked out from its boxes and never |
| +// stored: internal/slides/deck/presses.go's Presses, for the browser. |
| +// vectors/presses.json holds the two to one answer, so a rule changes on |
| +// both sides or on neither. |
| +// |
| +// presses(slide) is [[{block, item}]]: element 0 is press 1, and press 0 |
| +// is the slide as it arrives. item -1 is the whole box; otherwise it is |
| +// the index of a list paragraph, blank paragraphs counted. |
| +// |
| +// - A box's value is its own step, or its columns container's when that |
| +// is later (and so on up). A box with no step of its own arrives with |
| +// whatever holds it, the slide or its container. |
| +// - The distinct values, ascending, are the presses, compared exactly as |
| +// stored. Boxes sharing a value arrive together. |
| +// - An `each` list at value v takes one press per non-blank item from v |
| +// on; everything else at v comes with the first of them, lists tied at |
| +// v pair up by index, and the next value starts after the longest. |
| +// - A box that shows nothing is in no press, so a value with only such |
| +// boxes makes none. |
| + |
| +// Go's unicode.IsSpace, spelled out: JS's \s differs at U+0085 and U+FEFF. |
| +const BLANK = /^[\t\n\v\f\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]*$/ |
| + |
| +const plain = para => (Array.isArray(para) ? para : []).map(run => (run && typeof run.t === 'string') ? run.t : '').join('') |
| + |
| +/** The indices of a text's non-blank paragraphs. */ |
| +function filledItems (text) { |
| + const out = [] |
| + ;(Array.isArray(text) ? text : []).forEach((para, i) => { |
| + if (!BLANK.test(plain(para))) out.push(i) |
| + }) |
| + return out |
| +} |
| + |
| +const ownStep = b => (typeof b.step === 'number' && b.step > 0) ? b.step : 0 |
| + |
| +/** A columns block's props.children, the strings among them. */ |
| +function children (b) { |
| + const v = b.props && b.props.children |
| + return Array.isArray(v) ? v.filter(id => typeof id === 'string') : [] |
| +} |
| + |
| +/** The blocks by id, and the columns box holding each: the first in block order naming it. */ |
| +function slideBoxes (blocks) { |
| + const byID = new Map() |
| + for (const b of blocks) byID.set(b.id, b) |
| + const parent = new Map() |
| + for (const b of blocks) { |
| + if (b.type !== 'columns') continue |
| + for (const id of children(b)) { |
| + if (byID.has(id) && id !== b.id && !parent.has(id)) parent.set(id, b.id) |
| + } |
| + } |
| + return { byID, parent } |
| +} |
| + |
| +/** The latest of a box's own step and its containers', until a container repeats. */ |
| +function value (sl, b) { |
| + let v = ownStep(b) |
| + const seen = new Set([b.id]) |
| + for (let id = sl.parent.get(b.id); id !== undefined && !seen.has(id); id = sl.parent.get(id)) { |
| + seen.add(id) |
| + v = Math.max(v, ownStep(sl.byID.get(id))) |
| + } |
| + return v |
| +} |
| + |
| +/** Whether a box puts anything on the slide; on is the columns boxes being looked into. */ |
| +function shows (sl, b, on) { |
| + switch (b.type) { |
| + case 'list': |
| + return filledItems(b.text).length > 0 |
| + case 'heading': case 'text': case 'quote': |
| + return !BLANK.test((Array.isArray(b.text) ? b.text : []).map(plain).join('\n')) |
| + case 'columns': |
| + on.add(b.id) |
| + for (const id of children(b)) { |
| + const c = sl.byID.get(id) |
| + if (c && !on.has(id) && shows(sl, c, on)) return true |
| + } |
| + return false |
| + } |
| + return true |
| +} |
| + |
| +export function presses (slide) { |
| + const blocks = Array.isArray(slide && slide.blocks) ? slide.blocks : [] |
| + const sl = slideBoxes(blocks) |
| + const all = [] |
| + const values = [] |
| + for (const b of blocks) { |
| + if (ownStep(b) === 0 || !shows(sl, b, new Set())) continue |
| + const a = { id: b.id, value: value(sl, b), items: null } |
| + if (b.type === 'list' && b.items === 'each') a.items = filledItems(b.text) |
| + all.push(a) |
| + if (!values.includes(a.value)) values.push(a.value) |
| + } |
| + values.sort((x, y) => x - y) |
| + |
| + const out = [] |
| + for (const v of values) { |
| + let n = 1 |
| + for (const a of all) if (a.value === v && a.items && a.items.length > n) n = a.items.length |
| + for (let j = 0; j < n; j++) { |
| + const press = [] |
| + for (const a of all) { |
| + if (a.value !== v) continue |
| + if (a.items) { |
| + if (j < a.items.length) press.push({ block: a.id, item: a.items[j] }) |
| + } else if (j === 0) { |
| + press.push({ block: a.id, item: -1 }) |
| + } |
| + } |
| + out.push(press) |
| + } |
| + } |
| + return out |
| +} |
diff --git a/fixtures/presses.test.mjs b/fixtures/presses.test.mjs| new file mode 100644 |
| index 0000000..a8e23ec |
| --- /dev/null |
| +++ b/fixtures/presses.test.mjs |
| @@ -0,0 +1,22 @@ |
| +// presses.test.mjs — the browser's presses against the server's, through |
| +// the shared vectors (vectors/presses.json, which |
| +// internal/slides/deck/presses_test.go reads too). |
| +import { test } from 'node:test' |
| +import assert from 'node:assert/strict' |
| +import { readFileSync } from 'node:fs' |
| +import { presses } from './presses.mjs' |
| + |
| +const vectors = JSON.parse(readFileSync(new URL('./vectors/presses.json', import.meta.url))) |
| + |
| +test('presses vectors', async t => { |
| + assert.ok(vectors.length >= 10) |
| + for (const c of vectors) { |
| + await t.test(c.name, () => { |
| + assert.deepEqual(presses(c.slide), c.presses) |
| + }) |
| + } |
| +}) |
| + |
| +test('a slide with no blocks key has no presses', () => { |
| + assert.deepEqual(presses({ id: 's' }), []) |
| +}) |
diff --git a/fixtures/vectors/moves.json b/fixtures/vectors/moves.json| new file mode 100644 |
| index 0000000..7134251 |
| --- /dev/null |
| +++ b/fixtures/vectors/moves.json |
| @@ -0,0 +1,63 @@ |
| +[ |
| + {"name":"next through a slide","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":0,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"s2","step":1,"mode":"core","black":false}}, |
| + {"name":"next through a slide to its last press","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"s2","step":2,"mode":"core","black":false}}, |
| + {"name":"next across slides with no steps","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s1","step":0,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"s2","step":0,"mode":"core","black":false}}, |
| + {"name":"next across slides skips full only and parked in core","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":2,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"next across slides shows full only in full","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":2,"mode":"full","black":false},"move":{"op":"next"},"to":{"slide":"f3","step":0,"mode":"full","black":false}}, |
| + {"name":"next across slides skips parked in full","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"f3","step":1,"mode":"full","black":false},"move":{"op":"next"},"to":{"slide":"s5","step":0,"mode":"full","black":false}}, |
| + {"name":"next from a step above the count leaves the slide","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":5,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"next at the end of the talk stays","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s5","step":0,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"back through a slide","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":2,"mode":"core","black":false},"move":{"op":"back"},"to":{"slide":"s2","step":1,"mode":"core","black":false}}, |
| + {"name":"back lands fully built","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s5","step":0,"mode":"core","black":false},"move":{"op":"back"},"to":{"slide":"s2","step":2,"mode":"core","black":false}}, |
| + {"name":"back lands fully built on a full only slide in full","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s5","step":0,"mode":"full","black":false},"move":{"op":"back"},"to":{"slide":"f3","step":1,"mode":"full","black":false}}, |
| + {"name":"back across a slide with no steps","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":0,"mode":"core","black":false},"move":{"op":"back"},"to":{"slide":"s1","step":0,"mode":"core","black":false}}, |
| + {"name":"back at the start of the talk stays","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s1","step":0,"mode":"core","black":false},"move":{"op":"back"},"to":{"slide":"s1","step":0,"mode":"core","black":false}}, |
| + {"name":"back at the start skips a full only first slide in core","deck":{"slides":[{"id":"f1","talk":"full","blocks":[]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]},{"id":"p3","talk":"parked","blocks":[]}]},"from":{"slide":"s2","step":0,"mode":"core","black":false},"move":{"op":"back"},"to":{"slide":"s2","step":0,"mode":"core","black":false}}, |
| + {"name":"first","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s5","step":0,"mode":"core","black":false},"move":{"op":"first"},"to":{"slide":"s1","step":0,"mode":"core","black":false}}, |
| + {"name":"first in core skips a full only first slide","deck":{"slides":[{"id":"f1","talk":"full","blocks":[]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]},{"id":"p3","talk":"parked","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":false},"move":{"op":"first"},"to":{"slide":"s2","step":0,"mode":"core","black":false}}, |
| + {"name":"first in full","deck":{"slides":[{"id":"f1","talk":"full","blocks":[]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]},{"id":"p3","talk":"parked","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"full","black":false},"move":{"op":"first"},"to":{"slide":"f1","step":0,"mode":"full","black":false}}, |
| + {"name":"last","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":false},"move":{"op":"last"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"last skips a parked last slide","deck":{"slides":[{"id":"f1","talk":"full","blocks":[]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]},{"id":"p3","talk":"parked","blocks":[]}]},"from":{"slide":"f1","step":0,"mode":"full","black":false},"move":{"op":"last"},"to":{"slide":"s2","step":0,"mode":"full","black":false}}, |
| + {"name":"goto lands at step 0","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s1","step":0,"mode":"core","black":false},"move":{"op":"goto","slide":"s2"},"to":{"slide":"s2","step":0,"mode":"core","black":false}}, |
| + {"name":"goto the current slide goes back to step 0","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":2,"mode":"core","black":false},"move":{"op":"goto","slide":"s2"},"to":{"slide":"s2","step":0,"mode":"core","black":false}}, |
| + {"name":"goto a full only slide from core switches to full","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s1","step":0,"mode":"core","black":false},"move":{"op":"goto","slide":"f3"},"to":{"slide":"f3","step":0,"mode":"full","black":false}}, |
| + {"name":"goto a parked slide changes nothing","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"goto","slide":"p4"},"to":{"slide":"s2","step":1,"mode":"core","black":true}}, |
| + {"name":"goto a missing slide changes nothing","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"goto","slide":"gone"},"to":{"slide":"s2","step":1,"mode":"core","black":true}}, |
| + {"name":"goto with no slide changes nothing","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"goto"},"to":{"slide":"s2","step":1,"mode":"core","black":true}}, |
| + {"name":"mode flips core to full and keeps the position","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":false},"move":{"op":"mode"},"to":{"slide":"s2","step":1,"mode":"full","black":false}}, |
| + {"name":"mode flips full to core on a full only slide and keeps the position","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"f3","step":1,"mode":"full","black":false},"move":{"op":"mode"},"to":{"slide":"f3","step":1,"mode":"core","black":false}}, |
| + {"name":"mode keeps black","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"mode"},"to":{"slide":"s2","step":1,"mode":"full","black":true}}, |
| + {"name":"next on a full only slide in core steps through it","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"f3","step":0,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"f3","step":1,"mode":"core","black":false}}, |
| + {"name":"next on a full only slide in core leaves by its place in the deck","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"f3","step":1,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"back on a full only slide in core leaves by its place in the deck","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"f3","step":0,"mode":"core","black":false},"move":{"op":"back"},"to":{"slide":"s2","step":2,"mode":"core","black":false}}, |
| + {"name":"next on a parked slide leaves by its place in the deck","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"p4","step":1,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"back on a parked slide leaves by its place in the deck","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"p4","step":0,"mode":"full","black":false},"move":{"op":"back"},"to":{"slide":"f3","step":1,"mode":"full","black":false}}, |
| + {"name":"next from a missing slide lands where settle would","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"gone","step":3,"mode":"core","black":true},"move":{"op":"next"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"black turns the screen black","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":false},"move":{"op":"black"},"to":{"slide":"s2","step":1,"mode":"core","black":true}}, |
| + {"name":"black again lifts it","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"black"},"to":{"slide":"s2","step":1,"mode":"core","black":false}}, |
| + {"name":"next lifts black","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"next"},"to":{"slide":"s2","step":2,"mode":"core","black":false}}, |
| + {"name":"next at the end lifts black and stays","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s5","step":0,"mode":"core","black":true},"move":{"op":"next"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"back lifts black","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"back"},"to":{"slide":"s2","step":0,"mode":"core","black":false}}, |
| + {"name":"back at the start lifts black and stays","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s1","step":0,"mode":"core","black":true},"move":{"op":"back"},"to":{"slide":"s1","step":0,"mode":"core","black":false}}, |
| + {"name":"first lifts black","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"first"},"to":{"slide":"s1","step":0,"mode":"core","black":false}}, |
| + {"name":"last lifts black","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"last"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"goto lifts black","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"goto","slide":"s5"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"an unknown move changes nothing","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"jump"},"to":{"slide":"s2","step":1,"mode":"core","black":true}}, |
| + {"name":"empty talk: next","deck":{"slides":[{"id":"p1","talk":"parked","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]}]},"from":{"slide":"","step":0,"mode":"core","black":false},"move":{"op":"next"},"to":{"slide":"","step":0,"mode":"core","black":false}}, |
| + {"name":"empty talk: back","deck":{"slides":[{"id":"p1","talk":"parked","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]}]},"from":{"slide":"","step":0,"mode":"full","black":true},"move":{"op":"back"},"to":{"slide":"","step":0,"mode":"full","black":false}}, |
| + {"name":"empty talk: first and last","deck":{"slides":[{"id":"p1","talk":"parked","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]}]},"from":{"slide":"","step":0,"mode":"core","black":false},"move":{"op":"last"},"to":{"slide":"","step":0,"mode":"core","black":false}}, |
| + {"name":"empty talk: mode flips and nothing else","deck":{"slides":[{"id":"p1","talk":"parked","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]}]},"from":{"slide":"","step":0,"mode":"core","black":false},"move":{"op":"mode"},"to":{"slide":"","step":0,"mode":"full","black":false}}, |
| + {"name":"empty talk: goto a parked slide changes nothing","deck":{"slides":[{"id":"p1","talk":"parked","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]}]},"from":{"slide":"","step":0,"mode":"core","black":false},"move":{"op":"goto","slide":"p1"},"to":{"slide":"","step":0,"mode":"core","black":false}}, |
| + {"name":"start: the first slide of the core talk","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"","step":0,"mode":"core","black":false},"move":{"op":"start"},"to":{"slide":"s1","step":0,"mode":"core","black":false}}, |
| + {"name":"start skips a full only first slide","deck":{"slides":[{"id":"f1","talk":"full","blocks":[]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]},{"id":"p3","talk":"parked","blocks":[]}]},"from":{"slide":"","step":0,"mode":"core","black":false},"move":{"op":"start"},"to":{"slide":"s2","step":0,"mode":"core","black":false}}, |
| + {"name":"start of an empty talk","deck":{"slides":[{"id":"p1","talk":"parked","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]}]},"from":{"slide":"","step":0,"mode":"core","black":false},"move":{"op":"start"},"to":{"slide":"","step":0,"mode":"core","black":false}}, |
| + {"name":"settle: a position in the talk stays","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":1,"mode":"core","black":true},"move":{"op":"settle"},"to":{"slide":"s2","step":1,"mode":"core","black":true}}, |
| + {"name":"settle: a step above the count clamps to the count","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":7,"mode":"core","black":false},"move":{"op":"settle"},"to":{"slide":"s2","step":2,"mode":"core","black":false}}, |
| + {"name":"settle: a step below 0 clamps to 0","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"s2","step":-1,"mode":"core","black":false},"move":{"op":"settle"},"to":{"slide":"s2","step":0,"mode":"core","black":false}}, |
| + {"name":"settle: a parked slide becomes the next slide of the order after it","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"p4","step":1,"mode":"full","black":true},"move":{"op":"settle"},"to":{"slide":"s5","step":0,"mode":"full","black":true}}, |
| + {"name":"settle: a parked slide with nothing after it becomes the last","deck":{"slides":[{"id":"f1","talk":"full","blocks":[]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]},{"id":"p3","talk":"parked","blocks":[]}]},"from":{"slide":"p3","step":0,"mode":"full","black":false},"move":{"op":"settle"},"to":{"slide":"s2","step":0,"mode":"full","black":false}}, |
| + {"name":"settle: a missing slide becomes the last","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"gone","step":2,"mode":"core","black":false},"move":{"op":"settle"},"to":{"slide":"s5","step":0,"mode":"core","black":false}}, |
| + {"name":"settle: a full only slide in core stays, its step clamped","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"f3","step":4,"mode":"core","black":false},"move":{"op":"settle"},"to":{"slide":"f3","step":1,"mode":"core","black":false}}, |
| + {"name":"settle: no slide yet becomes the first","deck":{"slides":[{"id":"s1","blocks":[{"id":"h1","type":"heading","text":[[{"t":"Hello"}]]}]},{"id":"s2","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]},{"id":"b","type":"text","step":2,"text":[[{"t":"b"}]]}]},{"id":"f3","talk":"full","blocks":[{"id":"c","type":"text","step":1,"text":[[{"t":"c"}]]}]},{"id":"p4","talk":"parked","blocks":[{"id":"d","type":"text","step":1,"text":[[{"t":"d"}]]}]},{"id":"s5","blocks":[]}]},"from":{"slide":"","step":0,"mode":"full","black":false},"move":{"op":"settle"},"to":{"slide":"s1","step":0,"mode":"full","black":false}}, |
| + {"name":"settle: an empty talk gives only the mode","deck":{"slides":[{"id":"p1","talk":"parked","blocks":[{"id":"a","type":"text","step":1,"text":[[{"t":"a"}]]}]}]},"from":{"slide":"p1","step":1,"mode":"full","black":true},"move":{"op":"settle"},"to":{"slide":"","step":0,"mode":"full","black":false}} |
| +] |
diff --git a/fixtures/vectors/presses.json b/fixtures/vectors/presses.json| new file mode 100644 |
| index 0000000..040bad8 |
| --- /dev/null |
| +++ b/fixtures/vectors/presses.json |
| @@ -0,0 +1,200 @@ |
| +[ |
| + { |
| + "name": "no steps: everything arrives with the slide", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "h", "type": "heading", "text": [[{"t": "Title"}]]}, |
| + {"id": "l", "type": "list", "items": "each", "text": [[{"t": "one"}], [{"t": "two"}]]} |
| + ]}, |
| + "presses": [] |
| + }, |
| + { |
| + "name": "ties: equal values arrive on one press, in block order", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "a", "type": "text", "step": 1, "text": [[{"t": "A"}]]}, |
| + {"id": "b", "type": "text", "step": 2, "text": [[{"t": "B"}]]}, |
| + {"id": "c", "type": "image", "step": 1} |
| + ]}, |
| + "presses": [ |
| + [{"block": "a", "item": -1}, {"block": "c", "item": -1}], |
| + [{"block": "b", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "1, 1.5, 2: a midpoint is a press between its neighbours", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "two", "type": "text", "step": 2, "text": [[{"t": "2"}]]}, |
| + {"id": "one", "type": "text", "step": 1, "text": [[{"t": "1"}]]}, |
| + {"id": "mid", "type": "text", "step": 1.5, "text": [[{"t": "1.5"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "one", "item": -1}], |
| + [{"block": "mid", "item": -1}], |
| + [{"block": "two", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "values compare exactly as stored", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "a", "type": "shape", "step": 0.30000000000000004}, |
| + {"id": "b", "type": "shape", "step": 0.3} |
| + ]}, |
| + "presses": [ |
| + [{"block": "b", "item": -1}], |
| + [{"block": "a", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "each: one press per item, the rest of its value with the first", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "t", "type": "text", "step": 1, "text": [[{"t": "with the first item"}]]}, |
| + {"id": "l", "type": "list", "step": 1, "items": "each", "text": [[{"t": "x"}], [{"t": "y"}], [{"t": "z"}]]}, |
| + {"id": "u", "type": "text", "step": 2, "text": [[{"t": "after the list"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "t", "item": -1}, {"block": "l", "item": 0}], |
| + [{"block": "l", "item": 1}], |
| + [{"block": "l", "item": 2}], |
| + [{"block": "u", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "each with blank items: they take no press and keep their index", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "l", "type": "list", "step": 1, "items": "each", "text": [ |
| + [{"t": "a"}], [], [{"t": " "}], [{"t": "\u00a0"}, {"t": "\t\u0085"}], [{"t": "b", "b": true}] |
| + ]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "l", "item": 0}], |
| + [{"block": "l", "item": 4}] |
| + ] |
| + }, |
| + { |
| + "name": "an empty list makes no press, with or without each", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "e1", "type": "list", "step": 1, "text": [[{"t": " "}], []]}, |
| + {"id": "e2", "type": "list", "step": 2, "items": "each", "text": []}, |
| + {"id": "e3", "type": "list", "step": 3, "items": "each"}, |
| + {"id": "t", "type": "text", "step": 4, "text": [[{"t": "T"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "t", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "a list without each arrives whole", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "l", "type": "list", "step": 1, "items": "together", "text": [[{"t": "x"}], [{"t": "y"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "l", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "two each lists tied pair up by index, the next value after the longest", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "a", "type": "list", "step": 1, "items": "each", "text": [[{"t": "a0"}], [{"t": "a1"}]]}, |
| + {"id": "b", "type": "list", "step": 1, "items": "each", "text": [[{"t": "b0"}], [{"t": ""}], [{"t": "b2"}], [{"t": "b3"}]]}, |
| + {"id": "c", "type": "text", "step": 2, "text": [[{"t": "C"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "a", "item": 0}, {"block": "b", "item": 0}], |
| + [{"block": "a", "item": 1}, {"block": "b", "item": 2}], |
| + [{"block": "b", "item": 3}], |
| + [{"block": "c", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "each with no step arrives with the slide", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "l", "type": "list", "items": "each", "text": [[{"t": "x"}], [{"t": "y"}]]}, |
| + {"id": "t", "type": "text", "step": 1, "text": [[{"t": "T"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "t", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "a blank text box makes no press; an image always shows", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "h", "type": "heading", "step": 1, "text": [[{"t": " "}]]}, |
| + {"id": "q", "type": "quote", "step": 2, "text": []}, |
| + {"id": "x", "type": "text", "step": 3}, |
| + {"id": "i", "type": "image", "step": 4} |
| + ]}, |
| + "presses": [ |
| + [{"block": "i", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "child later than container: the child keeps its own value", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "c", "type": "columns", "step": 1, "props": {"children": ["x", "y"]}}, |
| + {"id": "x", "type": "text", "text": [[{"t": "with the box"}]]}, |
| + {"id": "y", "type": "text", "step": 2, "text": [[{"t": "later"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "c", "item": -1}], |
| + [{"block": "y", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "child earlier than container: the child waits, and its own press goes", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "c", "type": "columns", "step": 2, "props": {"children": ["x", "y"]}}, |
| + {"id": "x", "type": "text", "step": 1, "text": [[{"t": "earlier"}]]}, |
| + {"id": "y", "type": "image"} |
| + ]}, |
| + "presses": [ |
| + [{"block": "c", "item": -1}, {"block": "x", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "a box two containers deep takes the latest of the three", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "o", "type": "columns", "step": 2, "props": {"children": ["i"]}}, |
| + {"id": "i", "type": "columns", "props": {"children": ["x"]}}, |
| + {"id": "x", "type": "text", "step": 1, "text": [[{"t": "deep"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "o", "item": -1}, {"block": "x", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "an each list in a later container starts at the container's value", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "c", "type": "columns", "step": 2, "props": {"children": ["l"]}}, |
| + {"id": "l", "type": "list", "step": 1, "items": "each", "text": [[{"t": "x"}], [{"t": "y"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "c", "item": -1}, {"block": "l", "item": 0}], |
| + [{"block": "l", "item": 1}] |
| + ] |
| + }, |
| + { |
| + "name": "empty columns make no press", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "c1", "type": "columns", "step": 1, "props": {"children": []}}, |
| + {"id": "c2", "type": "columns", "step": 2, "props": {"children": ["b", "gone"]}}, |
| + {"id": "b", "type": "text", "text": [[{"t": " "}]]}, |
| + {"id": "c3", "type": "columns", "step": 3, "props": {"children": ["c4"]}}, |
| + {"id": "c4", "type": "columns", "props": {"children": ["e"]}}, |
| + {"id": "e", "type": "list", "text": []}, |
| + {"id": "t", "type": "text", "step": 4, "text": [[{"t": "T"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "t", "item": -1}] |
| + ] |
| + }, |
| + { |
| + "name": "columns naming each other still settle", |
| + "slide": {"id": "s", "blocks": [ |
| + {"id": "a", "type": "columns", "step": 1, "props": {"children": ["b"]}}, |
| + {"id": "b", "type": "columns", "step": 2, "props": {"children": ["a", "t"]}}, |
| + {"id": "t", "type": "text", "text": [[{"t": "T"}]]} |
| + ]}, |
| + "presses": [ |
| + [{"block": "a", "item": -1}, {"block": "b", "item": -1}] |
| + ] |
| + } |
| +] |
diff --git a/internal/slides/deck/presses.go b/internal/slides/deck/presses.go| new file mode 100644 |
| index 0000000..a52503f |
| --- /dev/null |
| +++ b/internal/slides/deck/presses.go |
| @@ -0,0 +1,205 @@ |
| +package deck |
| + |
| +import ( |
| + "sort" |
| + "strings" |
| +) |
| + |
| +// Reveal is one thing a press brings in: a whole box (Item -1), or one |
| +// item of a list whose items arrive one per press (Item is the index of |
| +// its paragraph in the list's Text, blank paragraphs counted). |
| +type Reveal struct { |
| + Block string `json:"block"` |
| + Item int `json:"item"` // -1 is the whole box |
| +} |
| + |
| +// Press is everything one press reveals, in the slide's block order. |
| +type Press []Reveal |
| + |
| +// Presses works out a slide's presses from its boxes; they are never |
| +// stored. Element 0 is press 1, and press 0 is the slide as it arrives, |
| +// so a slide with no steps has none. fixtures/presses.mjs is the same |
| +// function for the browser, and fixtures/vectors/presses.json holds the |
| +// two to one answer: |
| +// |
| +// - A box's value is its own step, or its columns container's when |
| +// that is later (and so on up). A box with no step of its own arrives |
| +// with whatever holds it, the slide or its container. |
| +// - The distinct values, ascending, are the presses, compared exactly |
| +// as stored. Boxes sharing a value arrive together. |
| +// - An `each` list at value v takes one press per non-blank item from |
| +// v on; everything else at v comes with the first of them, lists tied |
| +// at v pair up by index, and the next value starts after the longest. |
| +// - A box that shows nothing is in no press, so a value with only such |
| +// boxes makes none. |
| +func Presses(s Slide) []Press { |
| + sl := newSlideBoxes(s) |
| + type arriving struct { |
| + b *Block |
| + value float64 |
| + items []int // non-blank paragraph indices, for an each list |
| + } |
| + var all []arriving |
| + var values []float64 |
| + seen := map[float64]bool{} |
| + for i := range s.Blocks { |
| + b := &s.Blocks[i] |
| + if ownStep(b) == 0 || !sl.shows(b, map[string]bool{}) { |
| + continue |
| + } |
| + a := arriving{b: b, value: sl.value(b)} |
| + if b.Type == "list" && b.Items == "each" { |
| + a.items = filledItems(b.Text) |
| + } |
| + all = append(all, a) |
| + if !seen[a.value] { |
| + seen[a.value] = true |
| + values = append(values, a.value) |
| + } |
| + } |
| + sort.Float64s(values) |
| + |
| + var out []Press |
| + for _, v := range values { |
| + n := 1 |
| + for _, a := range all { |
| + if a.value == v && len(a.items) > n { |
| + n = len(a.items) |
| + } |
| + } |
| + for j := 0; j < n; j++ { |
| + var p Press |
| + for _, a := range all { |
| + switch { |
| + case a.value != v: |
| + case a.items != nil: |
| + if j < len(a.items) { |
| + p = append(p, Reveal{Block: a.b.ID, Item: a.items[j]}) |
| + } |
| + case j == 0: |
| + p = append(p, Reveal{Block: a.b.ID, Item: -1}) |
| + } |
| + } |
| + out = append(out, p) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// ArrivalOf is the press number (from 1) of everything that arrives on a |
| +// press. What arrives with the slide is not in the map. |
| +func ArrivalOf(s Slide) map[Reveal]int { |
| + out := map[Reveal]int{} |
| + for i, p := range Presses(s) { |
| + for _, r := range p { |
| + out[r] = i + 1 |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// slideBoxes is a slide's blocks by id, and the columns box that holds |
| +// each one: the first in block order naming it in props.children, as |
| +// the renderer reads it (render.go's childIDs). |
| +type slideBoxes struct { |
| + byID map[string]*Block |
| + parent map[string]string |
| +} |
| + |
| +func newSlideBoxes(s Slide) slideBoxes { |
| + sl := slideBoxes{byID: map[string]*Block{}, parent: map[string]string{}} |
| + for i := range s.Blocks { |
| + sl.byID[s.Blocks[i].ID] = &s.Blocks[i] |
| + } |
| + for _, b := range s.Blocks { |
| + if b.Type != "columns" { |
| + continue |
| + } |
| + for _, id := range children(b) { |
| + _, named := sl.parent[id] |
| + if _, ok := sl.byID[id]; ok && id != b.ID && !named { |
| + sl.parent[id] = b.ID |
| + } |
| + } |
| + } |
| + return sl |
| +} |
| + |
| +// value is the latest of a box's own step and its containers', walking |
| +// up until a container repeats (columns naming each other). |
| +func (sl slideBoxes) value(b *Block) float64 { |
| + v := ownStep(b) |
| + seen := map[string]bool{b.ID: true} |
| + for id, ok := sl.parent[b.ID]; ok && !seen[id]; id, ok = sl.parent[id] { |
| + seen[id] = true |
| + if s := ownStep(sl.byID[id]); s > v { |
| + v = s |
| + } |
| + } |
| + return v |
| +} |
| + |
| +// shows is whether a box puts anything on the slide: a list with a |
| +// non-blank item, a heading, text or quote with non-blank text, a |
| +// columns box with a child that shows. Every other type does. on is the |
| +// columns boxes already being looked into, so a cycle ends. |
| +func (sl slideBoxes) shows(b *Block, on map[string]bool) bool { |
| + switch b.Type { |
| + case "list": |
| + return len(filledItems(b.Text)) > 0 |
| + case "heading", "text", "quote": |
| + return !blank(b.Text.Plain()) |
| + case "columns": |
| + on[b.ID] = true |
| + for _, id := range children(*b) { |
| + if c, ok := sl.byID[id]; ok && !on[id] && sl.shows(c, on) { |
| + return true |
| + } |
| + } |
| + return false |
| + } |
| + return true |
| +} |
| + |
| +// ownStep is a block's own step, 0 when it has none. |
| +func ownStep(b *Block) float64 { |
| + if b.Step > 0 { |
| + return b.Step |
| + } |
| + return 0 |
| +} |
| + |
| +// filledItems is the indices of a text's non-blank paragraphs. |
| +func filledItems(t Text) []int { |
| + out := []int{} |
| + for i, para := range t { |
| + if !blank(Text{para}.Plain()) { |
| + out = append(out, i) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// blank is text with nothing but white space in it, as Go's |
| +// unicode.IsSpace has it; presses.mjs spells the same set out. |
| +func blank(s string) bool { |
| + return strings.TrimSpace(s) == "" |
| +} |
| + |
| +// children is a columns block's props.children, as they arrive from |
| +// JSON (the same reading as render.go's childIDs). |
| +func children(b Block) []string { |
| + switch v := b.Props["children"].(type) { |
| + case []string: |
| + return v |
| + case []any: |
| + out := make([]string, 0, len(v)) |
| + for _, c := range v { |
| + if s, ok := c.(string); ok { |
| + out = append(out, s) |
| + } |
| + } |
| + return out |
| + } |
| + return nil |
| +} |
diff --git a/internal/slides/deck/presses_test.go b/internal/slides/deck/presses_test.go| new file mode 100644 |
| index 0000000..77876a6 |
| --- /dev/null |
| +++ b/internal/slides/deck/presses_test.go |
| @@ -0,0 +1,66 @@ |
| +package deck_test |
| + |
| +import ( |
| + "encoding/json" |
| + "os" |
| + "path/filepath" |
| + "reflect" |
| + "testing" |
| + |
| + "amadan.net/oficina/slides/internal/slides/deck" |
| +) |
| + |
| +// readVectors decodes fixtures/vectors/<name>, the file the JS twin's |
| +// test (fixtures/presses.test.mjs, moves.test.mjs) reads too. A case |
| +// that fails here and passes there is a drift between the two sides, |
| +// never something to fix by editing the vector. |
| +func readVectors(t *testing.T, name string, into any) { |
| + t.Helper() |
| + b, err := os.ReadFile(filepath.Join("..", "..", "..", "fixtures", "vectors", name)) |
| + if err != nil { |
| + t.Fatalf("read %s: %v", name, err) |
| + } |
| + if err := json.Unmarshal(b, into); err != nil { |
| + t.Fatalf("decode %s: %v", name, err) |
| + } |
| +} |
| + |
| +func TestPressesVectors(t *testing.T) { |
| + var cases []struct { |
| + Name string `json:"name"` |
| + Slide deck.Slide `json:"slide"` |
| + Presses []deck.Press `json:"presses"` |
| + } |
| + readVectors(t, "presses.json", &cases) |
| + if len(cases) < 10 { |
| + t.Fatalf("%d cases, want at least 10", len(cases)) |
| + } |
| + for _, c := range cases { |
| + got := deck.Presses(c.Slide) |
| + if len(got) == 0 && len(c.Presses) == 0 { |
| + continue |
| + } |
| + if !reflect.DeepEqual(got, c.Presses) { |
| + t.Errorf("%s:\n got %v\nwant %v", c.Name, got, c.Presses) |
| + } |
| + } |
| +} |
| + |
| +func TestArrivalOfNumbersEveryRevealByItsPress(t *testing.T) { |
| + s := deck.Slide{ID: "s", Blocks: []deck.Block{ |
| + {ID: "a", Type: "text", Step: 2, Text: deck.Text{{{T: "A"}}}}, |
| + {ID: "l", Type: "list", Step: 1, Items: "each", Text: deck.Text{{{T: "x"}}, {{T: "y"}}}}, |
| + {ID: "w", Type: "text", Text: deck.Text{{{T: "with the slide"}}}}, |
| + }} |
| + want := map[deck.Reveal]int{ |
| + {Block: "l", Item: 0}: 1, |
| + {Block: "l", Item: 1}: 2, |
| + {Block: "a", Item: -1}: 3, |
| + } |
| + if got := deck.ArrivalOf(s); !reflect.DeepEqual(got, want) { |
| + t.Errorf("ArrivalOf = %v, want %v", got, want) |
| + } |
| + if got := deck.ArrivalOf(deck.Slide{}); len(got) != 0 { |
| + t.Errorf("ArrivalOf(no blocks) = %v, want empty", got) |
| + } |
| +} |
diff --git a/internal/slides/deck/talk.go b/internal/slides/deck/talk.go| new file mode 100644 |
| index 0000000..7e13240 |
| --- /dev/null |
| +++ b/internal/slides/deck/talk.go |
| @@ -0,0 +1,193 @@ |
| +package deck |
| + |
| +// Mode is which version of the talk is being given: core leaves out the |
| +// slides marked full only, full has them. |
| +type Mode string |
| + |
| +const ( |
| + ModeCore Mode = "core" |
| + ModeFull Mode = "full" |
| +) |
| + |
| +// Position is where a talk is, absolutely: the slide by id (so an edit |
| +// that moves slides about cannot shift it), the press on that slide, the |
| +// mode, and whether the screen is black. A Slide of "" is nowhere, which |
| +// is where an empty talk is. |
| +type Position struct { |
| + Slide string `json:"slide"` // slide id |
| + Step int `json:"step"` |
| + Mode Mode `json:"mode"` |
| + Black bool `json:"black"` |
| +} |
| + |
| +// Move is one press of the presenter's: next, back, first, last, goto |
| +// (with Slide), mode or black. |
| +type Move struct { |
| + Op string `json:"op"` |
| + Slide string `json:"slide,omitempty"` |
| +} |
| + |
| +// TalkOrder is the deck indices of the slides in the talk, in deck |
| +// order: parked slides never, full-only slides only in full mode. |
| +func TalkOrder(d *Deck, m Mode) []int { |
| + var out []int |
| + for i, s := range d.Slides { |
| + if s.Talk == "parked" || (s.Talk == "full" && m != ModeFull) { |
| + continue |
| + } |
| + out = append(out, i) |
| + } |
| + return out |
| +} |
| + |
| +// Start is where a talk begins: the first slide of the core talk. |
| +func Start(d *Deck) Position { |
| + if order := TalkOrder(d, ModeCore); len(order) > 0 { |
| + return Position{Slide: d.Slides[order[0]].ID, Mode: ModeCore} |
| + } |
| + return Position{Mode: ModeCore} |
| +} |
| + |
| +// Advance is where a move takes the talk from p. fixtures/moves.mjs is |
| +// the same function for the browser, and fixtures/vectors/moves.json |
| +// holds the two to one answer. |
| +// |
| +// next and back step through the slide's presses, then leave it for the |
| +// neighbouring slide of the talk (back lands fully built); at either end |
| +// they stay. The neighbour is found by the slide's place in the deck, so |
| +// a position on a slide outside the order (full only in core, or parked) |
| +// still moves sensibly. first, last and goto land at step 0. Each of |
| +// these lifts black. goto a full-only slide in core switches to full; |
| +// goto a parked or missing slide changes nothing at all. mode flips the |
| +// mode and keeps the rest; black toggles. Any other op changes nothing. |
| +func Advance(d *Deck, p Position, mv Move) Position { |
| + order := TalkOrder(d, p.Mode) |
| + switch mv.Op { |
| + case "black": |
| + p.Black = !p.Black |
| + return p |
| + case "mode": |
| + if p.Mode == ModeFull { |
| + p.Mode = ModeCore |
| + } else { |
| + p.Mode = ModeFull |
| + } |
| + return p |
| + case "goto": |
| + i := d.slideIndex(mv.Slide) |
| + if mv.Slide == "" || i < 0 || d.Slides[i].Talk == "parked" { |
| + return p |
| + } |
| + if d.Slides[i].Talk == "full" { |
| + p.Mode = ModeFull |
| + } |
| + return Position{Slide: mv.Slide, Mode: p.Mode} |
| + case "first", "last": |
| + if len(order) == 0 { |
| + return Position{Mode: p.Mode} |
| + } |
| + at := order[0] |
| + if mv.Op == "last" { |
| + at = order[len(order)-1] |
| + } |
| + return Position{Slide: d.Slides[at].ID, Mode: p.Mode} |
| + case "next", "back": |
| + return step(d, p, mv.Op == "next", order) |
| + } |
| + return p |
| +} |
| + |
| +// step is next (forward) or back from p. |
| +func step(d *Deck, p Position, forward bool, order []int) Position { |
| + if len(order) == 0 { |
| + return Position{Mode: p.Mode} |
| + } |
| + cur := d.slideIndex(p.Slide) |
| + if cur < 0 { |
| + p = Settle(d, p) |
| + p.Black = false |
| + return p |
| + } |
| + count := len(Presses(d.Slides[cur])) |
| + k := min(max(p.Step, 0), count) |
| + p.Black = false |
| + switch { |
| + case forward && k < count: |
| + p.Step = k + 1 |
| + case !forward && k > 0: |
| + p.Step = k - 1 |
| + case forward: |
| + p.Step = k |
| + for _, i := range order { |
| + if i > cur { |
| + return Position{Slide: d.Slides[i].ID, Mode: p.Mode} |
| + } |
| + } |
| + default: |
| + p.Step = k |
| + for j := len(order) - 1; j >= 0; j-- { |
| + if i := order[j]; i < cur { |
| + s := d.Slides[i] |
| + return Position{Slide: s.ID, Step: len(Presses(s)), Mode: p.Mode} |
| + } |
| + } |
| + } |
| + return p |
| +} |
| + |
| +// Settle puts p back on its feet after the deck changed under it. A |
| +// slide that is missing or parked becomes the next slide of the order |
| +// after its place in the deck at step 0, or the order's last when |
| +// nothing follows (a missing slide has no place, so it is always the |
| +// last). No slide at all becomes the first. A step outside the slide's |
| +// presses clamps into them. A full-only slide in core mode is a place |
| +// the mode switch left it, and stays. An empty talk gives the mode |
| +// alone. |
| +func Settle(d *Deck, p Position) Position { |
| + order := TalkOrder(d, p.Mode) |
| + if len(order) == 0 { |
| + return Position{Mode: p.Mode} |
| + } |
| + if p.Slide == "" { |
| + return Position{Slide: d.Slides[order[0]].ID, Mode: p.Mode, Black: p.Black} |
| + } |
| + cur := d.slideIndex(p.Slide) |
| + if cur < 0 || d.Slides[cur].Talk == "parked" { |
| + at := order[len(order)-1] |
| + if cur >= 0 { |
| + for _, i := range order { |
| + if i > cur { |
| + at = i |
| + break |
| + } |
| + } |
| + } |
| + return Position{Slide: d.Slides[at].ID, Mode: p.Mode, Black: p.Black} |
| + } |
| + p.Step = min(max(p.Step, 0), len(Presses(d.Slides[cur]))) |
| + return p |
| +} |
| + |
| +// ForReaders is the deck as anybody holding only a share or follow link |
| +// may see it: a copy without the parked slides. Meta and the slides |
| +// themselves are copied by value; the assets map is shared, as nothing |
| +// downstream writes to it. |
| +func (d *Deck) ForReaders() *Deck { |
| + out := &Deck{Meta: d.Meta, Assets: d.Assets, Slides: make([]Slide, 0, len(d.Slides))} |
| + for _, s := range d.Slides { |
| + if s.Talk != "parked" { |
| + out.Slides = append(out.Slides, s) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// slideIndex is the deck index of the slide with this id, or -1. |
| +func (d *Deck) slideIndex(id string) int { |
| + for i, s := range d.Slides { |
| + if s.ID == id { |
| + return i |
| + } |
| + } |
| + return -1 |
| +} |
diff --git a/internal/slides/deck/talk_test.go b/internal/slides/deck/talk_test.go| new file mode 100644 |
| index 0000000..a79c0ae |
| --- /dev/null |
| +++ b/internal/slides/deck/talk_test.go |
| @@ -0,0 +1,81 @@ |
| +package deck_test |
| + |
| +import ( |
| + "reflect" |
| + "testing" |
| + |
| + "amadan.net/oficina/slides/internal/slides/deck" |
| +) |
| + |
| +// TestMovesVectors runs fixtures/vectors/moves.json, which |
| +// fixtures/moves.test.mjs runs too. Two ops there are not moves: "start" |
| +// is Start(deck) and "settle" is Settle(deck, from). |
| +func TestMovesVectors(t *testing.T) { |
| + var cases []struct { |
| + Name string `json:"name"` |
| + Deck deck.Deck `json:"deck"` |
| + From deck.Position `json:"from"` |
| + Move deck.Move `json:"move"` |
| + To deck.Position `json:"to"` |
| + } |
| + readVectors(t, "moves.json", &cases) |
| + if len(cases) < 20 { |
| + t.Fatalf("%d cases, want at least 20", len(cases)) |
| + } |
| + for _, c := range cases { |
| + var got deck.Position |
| + switch c.Move.Op { |
| + case "start": |
| + got = deck.Start(&c.Deck) |
| + case "settle": |
| + got = deck.Settle(&c.Deck, c.From) |
| + default: |
| + got = deck.Advance(&c.Deck, c.From, c.Move) |
| + } |
| + if got != c.To { |
| + t.Errorf("%s:\n got %+v\nwant %+v", c.Name, got, c.To) |
| + } |
| + } |
| +} |
| + |
| +func talkDeck() *deck.Deck { |
| + return &deck.Deck{ |
| + Meta: deck.Meta{Title: "T"}, |
| + Slides: []deck.Slide{ |
| + {ID: "a"}, |
| + {ID: "b", Talk: "full"}, |
| + {ID: "c", Talk: "parked"}, |
| + {ID: "d"}, |
| + }, |
| + Assets: map[string]deck.Asset{"x": {Ref: "sha256:x"}}, |
| + } |
| +} |
| + |
| +func TestTalkOrderLeavesOutParkedAndInCoreFullOnly(t *testing.T) { |
| + d := talkDeck() |
| + if got, want := deck.TalkOrder(d, deck.ModeCore), []int{0, 3}; !reflect.DeepEqual(got, want) { |
| + t.Errorf("core = %v, want %v", got, want) |
| + } |
| + if got, want := deck.TalkOrder(d, deck.ModeFull), []int{0, 1, 3}; !reflect.DeepEqual(got, want) { |
| + t.Errorf("full = %v, want %v", got, want) |
| + } |
| +} |
| + |
| +func TestForReadersIsACopyWithoutParkedSlides(t *testing.T) { |
| + d := talkDeck() |
| + r := d.ForReaders() |
| + var ids []string |
| + for _, s := range r.Slides { |
| + ids = append(ids, s.ID) |
| + } |
| + if want := []string{"a", "b", "d"}; !reflect.DeepEqual(ids, want) { |
| + t.Errorf("reader slides = %v, want %v", ids, want) |
| + } |
| + if r.Meta != d.Meta || !reflect.DeepEqual(r.Assets, d.Assets) { |
| + t.Errorf("reader meta or assets differ: %+v %+v", r.Meta, r.Assets) |
| + } |
| + r.Slides[0].ID = "changed" |
| + if len(d.Slides) != 4 || d.Slides[0].ID != "a" { |
| + t.Errorf("ForReaders changed the deck it copied: %+v", d.Slides) |
| + } |
| +} |