Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

v0.9.7: fix live collab + speaker-in-fullscreen; variable-speed loops; Live status dot

nyblnetee50495b8b06
diff --git a/CLAUDE.md b/CLAUDE.md
index 37e4afc3..b390393d 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -40,6 +40,13 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.
visually on canvas (`editor/patheditor.ts`): draggable anchors auto-smoothed
Catmull-Rom→cubic bezier; the stored path is RELATIVE to the element's rest
position (first anchor = rest position; committing moves the element there).
+ **Variable speed (v0.9.7)**: `fx.loop` motion-path takes `ease` (per-lap tempo,
+ panel dropdown) and `speeds[]` (per-anchor multipliers, one per anchor —
+ scroll a point in the path editor to set it; badge shows non-1 values). anim.ts
+ `samplePath(d, speeds)` warps time→arc-length: locate each anchor's arc-length
+ fraction (nearest sample), integrate 1/speed to a time LUT, invert — so the
+ element dwells at low-speed anchors and rushes at high ones. Uniform speeds =
+ identity (no cost); speeds omitted from the model unless they vary.
- **File modes (v0.9.0)**: `doc.readonly` = PLAYER file (boots straight into
the show; exit lands on a minimal card, never the editor; "Save read-only
copy…" strips collab). Password encryption: the #bento-doc block can hold a
@@ -172,7 +179,11 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.
synced on slidechanged, closed on present exit. Reveal's notes plugin is
NOT used: its speaker window reloads the presentation URL in iframes,
which boots the Bento EDITOR (a whole second app instance) — never
- reintroduce it.
+ reintroduce it. GOTCHA (fixed v0.9.7): opening the speaker popup while in
+ real fullscreen makes the browser leave fullscreen, whose `fullscreenchange`
+ would call `exit()` and END the show — `openingSpeaker` guards onFsChange and
+ re-enters fullscreen. Escape stays a separate exit path, so the guard can't
+ strand the presenter.
- **Animation robustness**: slide exit kills tweens AND restores model frames; a
2.8s wall-clock settle guarantee lands entrances on starved render loops; never
put entrance tweens on motion-path elements (transform conflict).
@@ -234,6 +245,14 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.
`server/sync-worker/` (blind DO, ciphertext-only storage — verified;
`npx wrangler dev --port 8787` + localStorage 'bento-sync-url' for local
testing; NEVER pipe wrangler dev through `head` — SIGPIPE kills it).
+ **The DO MUST use the WebSocket Hibernation API** (`state.acceptWebSocket` +
+ `webSocketMessage`/`webSocketClose` handlers, `getWebSockets()` for fan-out,
+ per-socket state via `serializeAttachment`) — plain `server.accept()` keeps
+ the invocation alive for the whole connection and throws "Exceeded allowed
+ duration in Durable Objects free tier", which silently breaks ALL live
+ collab (the bug behind v0.9.7). The relay must be redeployed
+ (`wrangler deploy`) for worker changes to take effect — the app shell release
+ does NOT touch it.
Undo under collab is snapshot-based and may revert concurrent remote
edits to the same properties (documented LWW compromise).
- `src/editor/` — vanilla-TS editor. Moveable + Selecto handle manipulation.
diff --git a/server/sync-worker/src/worker.js b/server/sync-worker/src/worker.js
index 2be875fc..397b7ac3 100644
--- a/server/sync-worker/src/worker.js
+++ b/server/sync-worker/src/worker.js
@@ -36,14 +36,23 @@ export default {
})
}
const id = env.ROOM.idFromName(m[1])
- return env.ROOM.get(id).fetch(req)
+ // Surface DO failures as a readable body instead of an opaque CF 1101
+ // ("Worker threw exception") — the room path needs the SQLite storage
+ // backend, so a mis-provisioned migration shows up right here.
+ try {
+ return await env.ROOM.get(id).fetch(req)
+ } catch (e) {
+ return new Response('room error: ' + (e && e.stack ? e.stack : String(e)), {
+ status: 500,
+ headers: { 'content-type': 'text/plain' },
+ })
+ }
},
}
export class Room {
constructor(state) {
this.state = state
- this.sockets = new Map() // ws → { count, windowStart }
}
async fetch(req) {
@@ -60,20 +69,30 @@ export class Room {
const since = Math.max(0, parseInt(url.searchParams.get('since') || '0', 10) || 0)
const pair = new WebSocketPair()
const [client, server] = Object.values(pair)
- server.accept()
- this.sockets.set(server, { count: 0, windowStart: Date.now() })
- server.addEventListener('message', (ev) => {
- this.onMessage(server, ev).catch(() => {})
- })
- const drop = () => this.sockets.delete(server)
- server.addEventListener('close', drop)
- server.addEventListener('error', drop)
+ // WebSocket Hibernation: the runtime owns the socket, so the Durable Object
+ // can be evicted from memory while connections stay open — it accrues no
+ // active duration while idle. This is what keeps a live relay within the DO
+ // free-tier duration limit (plain server.accept() keeps the invocation
+ // running for the whole connection and throws "Exceeded allowed duration").
+ // Per-socket rate-limit state rides on the socket's serialized attachment
+ // (in-memory Maps don't survive hibernation).
+ this.state.acceptWebSocket(server)
+ server.serializeAttachment({ count: 0, windowStart: Date.now() })
await this.replay(server, since)
await this.state.storage.setAlarm(Date.now() + IDLE_TTL_MS)
return new Response(null, { status: 101, webSocket: client })
}
+ // --- hibernation handlers (fire on wake; replace addEventListener) ---------
+ async webSocketMessage(ws, data) {
+ await this.onMessage(ws, data).catch(() => {})
+ }
+ webSocketClose(ws) {
+ try { ws.close() } catch { /* already closed */ }
+ }
+ webSocketError() { /* the runtime drops the socket; nothing to clean up */ }
+
async replay(ws, since) {
const seq = (await this.state.storage.get('seq')) || 0
const snap = await this.state.storage.get('snap')
@@ -98,19 +117,21 @@ export class Room {
}
}
- async onMessage(ws, ev) {
- if (typeof ev.data !== 'string' || ev.data.length > MAX_FRAME) return
- const meta = this.sockets.get(ws)
- if (!meta) return
+ async onMessage(ws, data) {
+ if (typeof data !== 'string' || data.length > MAX_FRAME) return
+ // rate-limit window lives on the socket attachment (survives hibernation)
+ const meta = ws.deserializeAttachment() || { count: 0, windowStart: Date.now() }
const now = Date.now()
if (now - meta.windowStart > RATE_WINDOW_MS) {
meta.windowStart = now
meta.count = 0
}
- if (++meta.count > RATE_BURST) return
+ meta.count++
+ ws.serializeAttachment(meta)
+ if (meta.count > RATE_BURST) return
let f
try {
- f = JSON.parse(ev.data)
+ f = JSON.parse(data)
} catch {
return
}
@@ -140,13 +161,11 @@ export class Room {
}
const text = JSON.stringify(out)
- for (const [peer] of this.sockets) {
+ for (const peer of this.state.getWebSockets()) {
if (peer === ws) continue
try {
peer.send(text)
- } catch {
- this.sockets.delete(peer)
- }
+ } catch { /* runtime reaps dead sockets */ }
}
await this.state.storage.setAlarm(Date.now() + IDLE_TTL_MS)
}
diff --git a/slides/package.json b/slides/package.json
index ae5e72e2..c23ab71d 100644
--- a/slides/package.json
+++ b/slides/package.json
@@ -1,7 +1,7 @@
{
"name": "bento-slides",
"private": true,
- "version": "0.9.6",
+ "version": "0.9.7",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/slides/src/anim.ts b/slides/src/anim.ts
index 8f15a186..26dcfe0d 100644
--- a/slides/src/anim.ts
+++ b/slides/src/anim.ts
@@ -104,7 +104,56 @@ export function resetXform(el: Element) {
const SVG_NS = 'http://www.w3.org/2000/svg'
-function samplePath(d: string): ((t: number) => { x: number; y: number }) | null {
+/** on-curve anchor points of a path (the last coord pair of each M/L/C/Q). */
+function onCurvePoints(d: string): Array<{ x: number; y: number }> {
+ const out: Array<{ x: number; y: number }> = []
+ const re = /([MLCQ])([^MLCQZmlcqz]*)/gi
+ let m: RegExpExecArray | null
+ while ((m = re.exec(d))) {
+ const nums = (m[2].match(/-?\d*\.?\d+(?:e-?\d+)?/g) ?? []).map(Number)
+ if (nums.length >= 2) out.push({ x: nums[nums.length - 2], y: nums[nums.length - 1] })
+ }
+ return out
+}
+
+/**
+ * Warp time→arc-length so the element dwells at low-speed anchors and rushes
+ * at high-speed ones. `us` are the anchors' arc-length fractions (0..1),
+ * `speeds` their multipliers. Returns identity if the profile is uniform.
+ */
+function makeWarp(us: number[], speeds: number[]): (t: number) => number {
+ if (us.length < 2 || us.length !== speeds.length) return (t) => t
+ if (speeds.every((s) => Math.abs(s - speeds[0]) < 1e-3)) return (t) => t
+ const clampSp = (s: number) => Math.max(0.05, s)
+ const v = (u: number) => {
+ if (u <= us[0]) return clampSp(speeds[0])
+ if (u >= us[us.length - 1]) return clampSp(speeds[speeds.length - 1])
+ for (let i = 1; i < us.length; i++) {
+ if (u <= us[i]) {
+ const f = (u - us[i - 1]) / (us[i] - us[i - 1] || 1)
+ return clampSp(speeds[i - 1] + (speeds[i] - speeds[i - 1]) * f)
+ }
+ }
+ return clampSp(speeds[speeds.length - 1])
+ }
+ // cumulative traversal time T(u) = ∫ du/v ; normalise to [0,1], then invert
+ const M = 240
+ const T = new Float64Array(M + 1)
+ for (let j = 1; j <= M; j++) T[j] = T[j - 1] + (1 / M) / v((j - 0.5) / M)
+ const total = T[M] || 1
+ for (let j = 0; j <= M; j++) T[j] /= total
+ return (t) => {
+ t = Math.min(Math.max(t, 0), 1)
+ let lo = 0, hi = M
+ while (lo < hi) { const mid = (lo + hi) >> 1; if (T[mid] < t) lo = mid + 1; else hi = mid }
+ if (lo === 0) return 0
+ const t0 = T[lo - 1], t1 = T[lo]
+ const f = (t - t0) / (t1 - t0 || 1)
+ return ((lo - 1) + f) / M
+ }
+}
+
+function samplePath(d: string, speeds?: number[]): ((t: number) => { x: number; y: number }) | null {
const svg = document.createElementNS(SVG_NS, 'svg')
svg.style.cssText = 'position:absolute;width:0;height:0;overflow:hidden'
const path = document.createElementNS(SVG_NS, 'path')
@@ -121,13 +170,32 @@ function samplePath(d: string): ((t: number) => { x: number; y: number }) | null
const p = path.getPointAtLength((total * i) / N)
pts.push({ x: p.x, y: p.y })
}
+ // variable speed: locate each anchor's arc-length fraction (nearest sample),
+ // then build a time-warp from the per-anchor speed multipliers
+ let warp: (t: number) => number = (t) => t
+ if (speeds && speeds.length >= 2) {
+ const anchors = onCurvePoints(d)
+ if (anchors.length === speeds.length) {
+ const us = anchors.map((a) => {
+ let best = 0, bestD = Infinity
+ for (let i = 0; i <= N; i++) {
+ const dx = pts[i].x - a.x, dy = pts[i].y - a.y
+ const dd = dx * dx + dy * dy
+ if (dd < bestD) { bestD = dd; best = i }
+ }
+ return best / N
+ })
+ warp = makeWarp(us, speeds)
+ }
+ }
svg.remove()
- return (t) => {
- const f = Math.min(Math.max(t, 0), 1) * N
+ const geom = (u: number) => {
+ const f = Math.min(Math.max(u, 0), 1) * N
const i = Math.min(Math.floor(f), N - 1)
const k = f - i
return { x: pts[i].x + (pts[i + 1].x - pts[i].x) * k, y: pts[i].y + (pts[i + 1].y - pts[i].y) * k }
}
+ return (t) => geom(warp(t))
}
// --- the tween -----------------------------------------------------------------
@@ -231,8 +299,9 @@ export class Tween {
this.applies.push((p) => el.setAttribute(name, String(lerp(p))))
}
} else if (key === 'motionPath') {
- const d = (toVal as { path: string }).path
- const sample = samplePath(d)
+ const mp = toVal as { path: string; speeds?: number[] }
+ const d = mp.path
+ const sample = samplePath(d, mp.speeds)
if (sample) {
const x = xformOf(el)
this.applies.push((p) => {
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index c69c1280..1be3fd06 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -110,11 +110,15 @@ export class Editor {
const tr = onlineTransport()
if (!tr) {
this.shareB.classList.remove('ed-btn-live', 'ed-btn-connecting')
+ this.shareB.title = t('Not sharing yet — click to start a live session')
return
}
tr.onStatus = () => this.wireOnlineStatus()
this.shareB.classList.toggle('ed-btn-live', tr.status === 'open')
this.shareB.classList.toggle('ed-btn-connecting', tr.status !== 'open')
+ this.shareB.title = tr.status === 'open'
+ ? t('Live — this deck is being shared')
+ : t('Connecting to the live session…')
if (this.shareWrap.classList.contains('open')) this.renderSharePanel()
}
@@ -505,6 +509,9 @@ export class Editor {
wrap.classList.toggle('open')
if (wrap.classList.contains('open')) this.renderSharePanel()
}, t('Live collaboration — work on this deck together'))
+ // stable hook for the status dot (grey dormant / amber connecting / green live)
+ this.shareB.classList.add('ed-btn-share')
+ this.shareB.title = t('Not sharing yet — click to start a live session')
const panel = div('ed-menu ed-share-pop')
wrap.append(this.shareB, panel)
document.addEventListener('pointerdown', (ev) => {
diff --git a/slides/src/editor/panels.ts b/slides/src/editor/panels.ts
index 3472b135..18380ff6 100644
--- a/slides/src/editor/panels.ts
+++ b/slides/src/editor/panels.ts
@@ -427,13 +427,27 @@ export class PropsPanel {
this.mutate(el.id, (e) => { if (e.fx?.loop?.type === 'motion-path') e.fx.loop.path = path.value }, true))
this.row(t('Path'), path)
+ // lap easing — the tempo of a whole lap (per-anchor speed is edited on canvas)
+ this.row(t('Lap easing'), this.labeledSelect(
+ [['none', t('Constant')], ['sine.inOut', t('Ease in-out')], ['power2.in', t('Ease in')], ['power2.out', t('Ease out')]],
+ (loop as { ease?: string }).ease ?? 'none',
+ (v) => this.mutate(el.id, (e) => {
+ const lp = e.fx?.loop
+ if (lp?.type !== 'motion-path') return
+ if (v === 'none') delete lp.ease; else lp.ease = v
+ }, true)))
+
const editPath = document.createElement('button')
editPath.className = 'ed-btn ed-btn-block'
editPath.textContent = t('✎ Edit path on canvas')
- editPath.title = t('Drag anchor points on the slide; double-click adds and removes points')
+ editPath.title = t('Drag points to reshape · double-click to add/remove · scroll a point to change its speed')
editPath.addEventListener('click', () =>
document.dispatchEvent(new CustomEvent('bento:edit-path', { detail: { id: el.id } })))
this.host.appendChild(editPath)
+ const speedHint = document.createElement('p')
+ speedHint.className = 'ed-hint'
+ speedHint.textContent = t('Tip: on the canvas, scroll a point to make the element dwell there or rush past it.')
+ this.host.appendChild(speedHint)
}
}
diff --git a/slides/src/editor/patheditor.ts b/slides/src/editor/patheditor.ts
index 1ef08f9f..9193ba91 100644
--- a/slides/src/editor/patheditor.ts
+++ b/slides/src/editor/patheditor.ts
@@ -126,6 +126,7 @@ export class PathEditor {
private overlay: SVGSVGElement | null = null
private hint: HTMLElement | null = null
private pts: Pt[] = []
+ private speeds: number[] = [] // per-anchor speed multipliers, mirrors pts
private elId = ''
private scale = () => 1
private dirty = false
@@ -159,6 +160,9 @@ export class PathEditor {
if (this.pts.length === 1) this.pts.push({ x: cx + 160, y: cy })
// A synthesized default line counts as an edit — Done should save it.
if (rel.length < 2) this.dirty = true
+ // per-anchor speeds (mirror pts length; default uniform)
+ const savedSpeeds = (el.fx.loop as { speeds?: number[] }).speeds
+ this.speeds = this.pts.map((_, i) => (savedSpeeds && savedSpeeds.length === this.pts.length ? savedSpeeds[i] : 1))
const svg = document.createElementNS(SVG_NS, 'svg')
svg.classList.add('ed-pathedit')
@@ -172,7 +176,7 @@ export class PathEditor {
this.hint = document.createElement('div')
this.hint.className = 'ed-setbar ed-pathbar'
this.hint.innerHTML =
- '<span class="ed-setbar-label">Motion path — drag points · double-click path to insert · double-click point to remove · double-click canvas to append</span>'
+ '<span class="ed-setbar-label">Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed</span>'
const done = document.createElement('button')
done.className = 'ed-setchip active'
done.textContent = 'Done'
@@ -204,6 +208,10 @@ export class PathEditor {
const live = this.store.element(el.id)
if (!live || live.fx?.loop?.type !== 'motion-path') return
live.fx.loop.path = relPath
+ // persist per-anchor speeds only when they actually vary (keep the model clean)
+ const sp = this.speeds.slice(0, pts.length)
+ if (sp.length === pts.length && sp.some((s) => Math.abs(s - 1) > 1e-3)) live.fx.loop.speeds = sp
+ else delete live.fx.loop.speeds
live.x = r(p0.x - live.w / 2)
live.y = r(p0.y - live.h / 2)
})
@@ -248,6 +256,9 @@ export class PathEditor {
line.style.pointerEvents = 'none'
svg.appendChild(line)
+ // keep the speeds array aligned with the anchors (defensive)
+ if (this.speeds.length !== this.pts.length) this.speeds = this.pts.map((_, i) => this.speeds[i] ?? 1)
+
this.pts.forEach((p, i) => {
const dot = mk('circle')
dot.setAttribute('cx', String(p.x))
@@ -262,19 +273,51 @@ export class PathEditor {
dot.append(Object.assign(mk('title'), { textContent: 'Start — also the element’s rest position' }))
dot.addEventListener('mousedown', (ev) => this.dragAnchor(ev, i))
+ // scroll a point to change how fast the element moves through it
+ dot.addEventListener('wheel', (ev) => {
+ ev.preventDefault()
+ const step = ev.deltaY < 0 ? 0.1 : -0.1
+ this.speeds[i] = Math.round(Math.max(0.2, Math.min(4, (this.speeds[i] ?? 1) + step)) * 10) / 10
+ this.dirty = true
+ this.draw()
+ })
svg.appendChild(dot)
+
+ // speed badge (only when it differs from normal, to avoid clutter)
+ if (Math.abs((this.speeds[i] ?? 1) - 1) > 1e-3) {
+ const label = mk('text')
+ label.setAttribute('x', String(p.x + 11 * k))
+ label.setAttribute('y', String(p.y - 9 * k))
+ label.setAttribute('font-size', String(12 * k))
+ label.setAttribute('font-weight', '700')
+ label.setAttribute('fill', '#31445c')
+ label.setAttribute('paint-order', 'stroke')
+ label.setAttribute('stroke', '#fff')
+ label.setAttribute('stroke-width', String(3 * k))
+ label.style.pointerEvents = 'none'
+ label.textContent = `${(this.speeds[i] ?? 1).toFixed(1)}×`
+ svg.appendChild(label)
+ }
})
- // live preview: a dot loops the path at the element's configured speed
- const el = this.store.element(this.elId)
- const dur = (el?.fx?.loop as any)?.duration ?? 3
+ // live preview: a dot loops the path at the element's configured speed —
+ // including per-anchor variable speed and lap easing, so edits are visible
+ const loop = this.store.element(this.elId)?.fx?.loop as
+ | { duration?: number; ease?: string }
+ | undefined
+ const dur = loop?.duration ?? 3
const preview = mk('circle')
preview.setAttribute('r', String(4.5 * k))
preview.setAttribute('fill', '#f7a600')
preview.style.pointerEvents = 'none'
preview.classList.add('ed-pe-dot')
svg.appendChild(preview)
- anim.to(preview, { motionPath: { path: d }, duration: Math.max(dur, 0.5), ease: 'none', repeat: -1 })
+ anim.to(preview, {
+ motionPath: { path: d, speeds: this.speeds.slice() },
+ duration: Math.max(dur, 0.5),
+ ease: loop?.ease ?? 'none',
+ repeat: -1,
+ })
}
// --- interaction ------------------------------------------------------------
@@ -328,6 +371,7 @@ export class PathEditor {
const idx = Number((target as SVGElement).dataset.idx)
if (this.pts.length > 2) {
this.pts.splice(idx, 1)
+ this.speeds.splice(idx, 1)
this.dirty = true
}
this.draw()
@@ -344,12 +388,14 @@ export class PathEditor {
if (dist < bestDist) { bestDist = dist; best = i }
}
this.pts.splice(best + 1, 0, p)
+ this.speeds.splice(best + 1, 0, (this.speeds[best] + (this.speeds[best + 1] ?? this.speeds[best])) / 2)
this.dirty = true
this.draw()
return
}
// empty canvas: append to the end
this.pts.push(p)
+ this.speeds.push(1)
this.dirty = true
this.draw()
}
diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.ts
index f4717ee7..d4bb5e6f 100644
--- a/slides/src/i18n/de.ts
+++ b/slides/src/i18n/de.ts
@@ -357,4 +357,14 @@ export const de: Catalog = {
"Advanced (JSON)": "Erweitert (JSON)",
"Slices": "Segmente",
"+ Add slice": "+ Segment",
+ "Not sharing yet — click to start a live session": "Noch nicht geteilt — zum Starten einer Live-Sitzung klicken",
+ "Live — this deck is being shared": "Live — diese Präsentation wird geteilt",
+ "Connecting to the live session…": "Verbinde mit der Live-Sitzung…",
+ "Lap easing": "Runden-Easing",
+ "Constant": "Konstant",
+ "Ease in-out": "Weich ein/aus",
+ "Ease in": "Weich starten",
+ "Ease out": "Weich enden",
+ "Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "Tipp: Scrolle auf der Fläche über einen Punkt, damit das Element dort verweilt oder vorbeieilt.",
+ "Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "Punkte ziehen zum Umformen · Doppelklick zum Hinzufügen/Entfernen · Punkt scrollen für Geschwindigkeit",
}
diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.ts
index f5018a2a..90a5682f 100644
--- a/slides/src/i18n/es.ts
+++ b/slides/src/i18n/es.ts
@@ -357,4 +357,14 @@ export const es: Catalog = {
"Advanced (JSON)": "Avanzado (JSON)",
"Slices": "Segmentos",
"+ Add slice": "+ Añadir segmento",
+ "Not sharing yet — click to start a live session": "Aún no se comparte — haz clic para iniciar una sesión en vivo",
+ "Live — this deck is being shared": "En vivo — esta presentación se está compartiendo",
+ "Connecting to the live session…": "Conectando a la sesión en vivo…",
+ "Lap easing": "Suavizado de vuelta",
+ "Constant": "Constante",
+ "Ease in-out": "Entrada y salida suaves",
+ "Ease in": "Entrada suave",
+ "Ease out": "Salida suave",
+ "Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "Consejo: en el lienzo, desplázate sobre un punto para que el elemento se detenga o pase rápido por ahí.",
+ "Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "Arrastra puntos para remodelar · doble clic para añadir/quitar · desplaza un punto para su velocidad",
}
diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.ts
index 80d93369..eb4f9b91 100644
--- a/slides/src/i18n/fr.ts
+++ b/slides/src/i18n/fr.ts
@@ -357,4 +357,14 @@ export const fr: Catalog = {
"Advanced (JSON)": "Avancé (JSON)",
"Slices": "Secteurs",
"+ Add slice": "+ Ajouter un secteur",
+ "Not sharing yet — click to start a live session": "Pas encore partagé — cliquez pour démarrer une session en direct",
+ "Live — this deck is being shared": "En direct — cette présentation est partagée",
+ "Connecting to the live session…": "Connexion à la session en direct…",
+ "Lap easing": "Accélération du tour",
+ "Constant": "Constante",
+ "Ease in-out": "Entrée-sortie douce",
+ "Ease in": "Entrée douce",
+ "Ease out": "Sortie douce",
+ "Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "Astuce : sur le canevas, faites défiler sur un point pour que l’élément s’y attarde ou passe vite.",
+ "Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "Glissez les points pour remodeler · double-clic pour ajouter/retirer · faites défiler un point pour sa vitesse",
}
diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.ts
index b80902b2..589c1ded 100644
--- a/slides/src/i18n/it.ts
+++ b/slides/src/i18n/it.ts
@@ -357,4 +357,14 @@ export const it: Catalog = {
"Advanced (JSON)": "Avanzato (JSON)",
"Slices": "Segmenti",
"+ Add slice": "+ Aggiungi segmento",
+ "Not sharing yet — click to start a live session": "Non ancora condiviso — clicca per avviare una sessione dal vivo",
+ "Live — this deck is being shared": "Dal vivo — questa presentazione è condivisa",
+ "Connecting to the live session…": "Connessione alla sessione dal vivo…",
+ "Lap easing": "Easing del giro",
+ "Constant": "Costante",
+ "Ease in-out": "Entrata-uscita morbida",
+ "Ease in": "Entrata morbida",
+ "Ease out": "Uscita morbida",
+ "Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "Suggerimento: sulla tela, scorri su un punto per far sostare l’elemento o passare veloce.",
+ "Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "Trascina i punti per rimodellare · doppio clic per aggiungere/rimuovere · scorri un punto per la velocità",
}
diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.ts
index c3656ff2..76ee70c4 100644
--- a/slides/src/i18n/ja.ts
+++ b/slides/src/i18n/ja.ts
@@ -357,4 +357,14 @@ export const ja: Catalog = {
"Advanced (JSON)": "詳細 (JSON)",
"Slices": "スライス",
"+ Add slice": "+ スライスを追加",
+ "Not sharing yet — click to start a live session": "まだ共有していません — クリックしてライブセッションを開始",
+ "Live — this deck is being shared": "ライブ — このデッキは共有中です",
+ "Connecting to the live session…": "ライブセッションに接続中…",
+ "Lap easing": "周回のイージング",
+ "Constant": "一定",
+ "Ease in-out": "イーズイン・アウト",
+ "Ease in": "イーズイン",
+ "Ease out": "イーズアウト",
+ "Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "ヒント:キャンバス上で点をスクロールすると、その位置で留まったり速く通過したりします。",
+ "Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "ドラッグで形を変更・ダブルクリックで追加/削除・点をスクロールで速度変更",
}
diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.ts
index 86d465de..b584b3fd 100644
--- a/slides/src/i18n/zh-Hans.ts
+++ b/slides/src/i18n/zh-Hans.ts
@@ -357,4 +357,14 @@ export const zhHans: Catalog = {
"Advanced (JSON)": "高级 (JSON)",
"Slices": "扇区",
"+ Add slice": "+ 添加扇区",
+ "Not sharing yet — click to start a live session": "尚未共享 — 点击开始实时协作",
+ "Live — this deck is being shared": "实时 — 正在共享此演示文稿",
+ "Connecting to the live session…": "正在连接实时会话…",
+ "Lap easing": "每圈缓动",
+ "Constant": "匀速",
+ "Ease in-out": "缓入缓出",
+ "Ease in": "缓入",
+ "Ease out": "缓出",
+ "Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "提示:在画布上滚动某个点,可让元素在此停留或快速掠过。",
+ "Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "拖动点以调整形状 · 双击添加/删除 · 滚动某点以改变其速度",
}
diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.ts
index c531b139..dc2b7599 100644
--- a/slides/src/i18n/zh-Hant.ts
+++ b/slides/src/i18n/zh-Hant.ts
@@ -357,4 +357,14 @@ export const zhHant: Catalog = {
"Advanced (JSON)": "進階 (JSON)",
"Slices": "扇區",
"+ Add slice": "+ 新增扇區",
+ "Not sharing yet — click to start a live session": "尚未共享 — 點擊開始即時協作",
+ "Live — this deck is being shared": "即時 — 正在共享此簡報",
+ "Connecting to the live session…": "正在連接即時工作階段…",
+ "Lap easing": "每圈緩動",
+ "Constant": "等速",
+ "Ease in-out": "緩入緩出",
+ "Ease in": "緩入",
+ "Ease out": "緩出",
+ "Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "提示:在畫布上捲動某個點,可讓元素在此停留或快速掠過。",
+ "Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "拖曳點以調整形狀 · 雙擊新增/刪除 · 捲動某點以改變其速度",
}
diff --git a/slides/src/model.ts b/slides/src/model.ts
index 096063c6..087763db 100644
--- a/slides/src/model.ts
+++ b/slides/src/model.ts
@@ -43,7 +43,18 @@ export interface ElementBase {
/** continuous looping animation */
loop?:
| { type: 'dash-march'; distance?: number; duration?: number }
- | { type: 'motion-path'; path: string; duration: number; delay?: number }
+ | {
+ type: 'motion-path'
+ path: string
+ duration: number
+ delay?: number
+ /** easing over each lap (default 'none' = constant tempo) */
+ ease?: string
+ /** per-anchor speed multipliers (1 = normal, <1 dwells, >1 rushes);
+ * length matches the path's anchor count. Warps the arc-length map
+ * so the element can linger at some points and rush between others. */
+ speeds?: number[]
+ }
}
/** while presenting, clicking this element jumps to the slide with this id */
link?: string
diff --git a/slides/src/present.ts b/slides/src/present.ts
index d38d255b..eecd880e 100644
--- a/slides/src/present.ts
+++ b/slides/src/present.ts
@@ -133,6 +133,10 @@ export function startPresentation(
let speaker: Window | null = null
let speakerTimer = 0
let speakerStart = 0
+ // opening the speaker popup drops the main window out of OS fullscreen on most
+ // browsers; this guards the fullscreenchange handler so that bounce doesn't
+ // end the show (see onFsChange).
+ let openingSpeaker = false
const nextVisibleIndex = (from: number) => {
for (let i = (isState(from) ? anchorOf(from) : from) + 1; i < doc.slides.length; i++) {
if (!isState(i)) return i
@@ -178,8 +182,12 @@ export function startPresentation(
speaker.focus()
return
}
+ // guard the whole open + fullscreen-restore dance: the popup makes the
+ // browser leave fullscreen, and without this that would end the show
+ const wasFullscreen = document.fullscreenElement === overlay
+ openingSpeaker = true
speaker = window.open('', 'bento-speaker', 'width=1080,height=640')
- if (!speaker) return // popup blocked
+ if (!speaker) { openingSpeaker = false; return } // popup blocked
;(window as unknown as Record<string, unknown>).__bentoSpeaker = speaker // diagnostics
const d = speaker.document
d.title = `${doc.title} — ${t('Speaker view')}`
@@ -210,6 +218,18 @@ export function startPresentation(
if (clock) clock.textContent = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
}, 1000)
updateSpeaker()
+ // If we were fullscreen, the popup just knocked us out of it. Put the slides
+ // back into fullscreen (best effort — may need re-activation) and keep the
+ // bounce from ending the show. Escape still exits via its own handler.
+ if (wasFullscreen) {
+ window.setTimeout(() => {
+ window.focus()
+ enterFullscreen()
+ window.setTimeout(() => { openingSpeaker = false }, 400)
+ }, 120)
+ } else {
+ openingSpeaker = false
+ }
}
// Real fullscreen (F toggles; Present enters it by default). The overlay
@@ -229,7 +249,7 @@ export function startPresentation(
let wentFullscreen = false
const onFsChange = () => {
if (document.fullscreenElement === overlay) wentFullscreen = true
- else if (wentFullscreen && !exited) exit()
+ else if (wentFullscreen && !exited && !openingSpeaker) exit()
}
document.addEventListener('fullscreenchange', onFsChange)
if (opts.fullscreen !== false) enterFullscreen()
@@ -559,10 +579,10 @@ function runAmbientFx(slide: Slide, section: HTMLElement) {
}
if (fx.loop?.type === 'motion-path') {
anim.to(node, {
- motionPath: { path: fx.loop.path },
+ motionPath: { path: fx.loop.path, speeds: fx.loop.speeds },
duration: fx.loop.duration,
delay: fx.loop.delay ?? 0,
- ease: 'none',
+ ease: fx.loop.ease ?? 'none',
repeat: -1,
})
}
diff --git a/slides/src/styles.css b/slides/src/styles.css
index 5375803e..75e81955 100644
--- a/slides/src/styles.css
+++ b/slides/src/styles.css
@@ -1179,7 +1179,12 @@ body.ed-col-resizing { cursor: col-resize; user-select: none; }
}
.ed-share-peer .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-share-peer .where { color: var(--muted, #5d6b80); font-size: 11.5px; flex: none; }
+/* Live button status dot: always present — grey when dormant (not sharing),
+ amber+pulsing while connecting, green when live. The dot makes the on/off
+ state legible at a glance instead of the button looking inert. */
+.ed-btn-share,
.ed-btn-live { position: relative; }
+.ed-btn-share::after,
.ed-btn-live::after,
.ed-btn-connecting::after {
content: '';
@@ -1189,9 +1194,13 @@ body.ed-col-resizing { cursor: col-resize; user-select: none; }
width: 7px;
height: 7px;
border-radius: 50%;
- background: #34a866;
+ background: #9aa4b2; /* dormant / not sharing */
}
-.ed-btn-connecting::after { background: #d9a13b; }
+.ed-btn-share.ed-btn-connecting::after,
+.ed-btn-connecting::after { background: #d9a13b; animation: ed-live-pulse 1.1s ease-in-out infinite; }
+.ed-btn-share.ed-btn-live::after,
+.ed-btn-live::after { background: #34a866; animation: none; }
+@keyframes ed-live-pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.3 } }
/* about rows wrap instead of overflowing the dialog */
.ed-about-row {