TTS redeems, skip button, per-source chat placement

- Redeem variations can have a TTS voice: the viewer's text is cleaned
  (links out, repeats collapsed, max length, blocked words -> not read),
  spoken as "<name> says: ..." and shown as the big paper note; the
  variation's sound is not played when TTS is on (picker greyed out)
- Settings: TTS max length, say-the-name, blocked words (never sent to
  overlay pages: db.getOverlaySettings)
- Dashboard "Skip current alert" -> /alerts/skip -> overlay skips it
- db.migrate()/addColumn: new columns on existing databases
- Chat: ?chat=left,top,width,height and ?chatflow=up per browser source
  (e.g. the Intermission panel); default unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-11-21 14:34:41 +02:00
parent b5a81bdb15
commit 4fda6060bf
16 changed files with 228 additions and 28 deletions

View file

@ -2,7 +2,8 @@
Special redeem visuals, called by polaroid.js (shared queue). Each returns a Promise that resolves when done.
FxAlert.giant(d, cur, snd) Gigantify Power-up: the viewer's emote grows huge, pulses while the sound plays
FxAlert.rain(d, cur, snd) On-Screen Celebration Power-up: copies of the emote bounce around the screen
FxAlert.message(d, cur, snd) Highlight my message / Message Effect: big taped paper note with the message
FxAlert.message(d, cur, snd) Highlight my message / Message Effect / TTS redeems: big taped paper note with the message
(d.tts = spoken message URL, d.ttsMs = its length; TTS redeems come without a sound)
d: { name (user), line, msg, emote (image URL or null) }; snd: { url, len, volume }
cur: { anims, timer, audio } so reset/skip can stop it (anything with cancel() can go in anims).
*/
@ -118,7 +119,14 @@
{ delay:550, duration:Math.min(1600, 300 + 18 * text.length), easing:'ease-in-out' });
playSound(cur, snd);
const read = 2000 + 70 * text.length; // time to read it
const exitAt = Math.max(650 + AFTER_ANIM, 650 + read, SOUND_LEAD + snd.len);
let exitAt = Math.max(650 + AFTER_ANIM, 650 + read, SOUND_LEAD + snd.len);
if (d.tts) { // TTS: after the intro sound, keep the note up until it is said
const ttsAt = SOUND_LEAD + (snd.url ? snd.len + 250 : 300);
const a = new Audio(d.tts); a.volume = snd.volume;
const t = setTimeout(() => { cur.audio = a; a.play().catch(err => console.warn('[alerts] TTS blocked:', err.message)); }, ttsAt);
cur.anims.push({ cancel: () => { clearTimeout(t); a.pause(); } }); // skip/reset stop the voice too
exitAt = Math.max(exitAt, ttsAt + (d.ttsMs || 4000) + 900);
}
return done(cur, A(cur, el, [{ transform:'translateY(0)', opacity:1 }, { transform:'translateY(140px) rotate(8deg)', opacity:0 }],
{ delay:exitAt, duration:500, easing:'ease-in' }));
}

View file

@ -6,6 +6,7 @@
but never interrupts or drops a real one (it queues behind it).
A real alert cuts off a test that is showing.
window.PolaroidAlerts.reset() stop the current alert and clear the queue
window.PolaroidAlerts.skip() stop the current alert (e.g. a TTS message), carry on with the queue
Alert shapes come from src/alerts.js:
{ type:'follow', user }
@ -127,7 +128,8 @@
return { cassette: true, style: e.style || 'cassette', emote: e.emote || null, sticker: rebase(e.art) || null,
name: e.user || 'Someone', line: fill(e.caption || 'redeemed it! ♡'), msg: e.input,
title: e.variation || e.reward, sub: e.reward, rarity: e.rarity,
sound: e.sound || null, volume: e.volume, soundOnly: e.polaroid === false };
sound: e.sound || null, volume: e.volume, soundOnly: e.polaroid === false && !e.tts,
tts: e.tts ? rebase(e.tts) : null, ttsMs: e.tts_ms || 0 };
}
case 'bits': {
if (!(e.bits >= BITS_MIN)) return null;
@ -211,6 +213,13 @@
play({ ...alert, test: true }); // a real one on screen: wait
}
// dashboard Skip button: cut what is on screen (sound/TTS too), then play the next queued alert
function skip() {
if (!current) return;
skipCurrent();
setTimeout(() => { if (!busy) next(); }, GAP);
}
function reset() {
gen++;
queue.length = 0;
@ -362,6 +371,6 @@
.catch(() => {}); // cancelled by reset()
}
window.PolaroidAlerts = { play, playTest, reset, describe };
window.PolaroidAlerts = { play, playTest, reset, skip, describe };
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', preload); else preload();
})();