// Teaser picture: every element is set from the time t alone (window.teaser.seek(t)), so frames render // deterministically, in any order. URL: ?w=1080&h=1920 (or 1920x1080) · &t=12.5 to hold a frame · &play=1 to preview. import { BAR, BEAT, BLOCKERS, BLOCKERS_AT, BLOCKER_GAP, CMD_CPS, CUTS, DESK_CURSOR, DESK_DIALOG, DESK_HOVER_AT, DESK_LINK_AT, DESKTOP, DURATION, FIX_AT, FIX_GAP, FPS, LANGS, PRICES, PROMPT, PROMPT_AT, PROMPT_CPS, SCENES, TERMINAL, scene } from './script.js'; const q = new URLSearchParams(location.search); const W = Number(q.get('w') ?? 1080), H = Number(q.get('h') ?? 1920); const V = H > W; const $ = s => document.querySelector(s); const stage = $('#stage'); stage.style.width = `${W}px`; stage.style.height = `${H}px`; document.body.classList.add(V ? 'v' : 'h'); // ---------- easing ---------- const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x)); const prog = (t, a, d) => clamp((t - a) / d); const eoc = p => 1 - Math.pow(1 - p, 3); const eic = p => p * p * p; const eob = p => { const c1 = 1.70158, c3 = c1 + 1; return 1 + c3 * Math.pow(p - 1, 3) + c1 * Math.pow(p - 1, 2); }; const lerp = (a, b, p) => a + (b - a) * p; const esc = s => s.replace(/&/g, '&').replace(//g, '>'); const sceneAt = t => SCENES.find(s => t >= s.start && t < s.end) ?? SCENES[SCENES.length - 1]; // ---------- background ---------- const g1 = $('#bg .g1'), g2 = $('#bg .g2'), g3 = $('#bg .g3'), grid = $('#bg .grid'), flash = $('#flash'); function background(t) { let pulse = 0; for (const c of CUTS) if (t >= c) pulse = Math.max(pulse, 1 - prog(t, c, 0.6)); const beat = 1 - prog((t % BEAT), 0, BEAT * 0.6); g1.style.transform = `translate(${W * 0.15 + Math.sin(t * 0.31) * 140 - 450}px, ${H * 0.28 + Math.cos(t * 0.23) * 120 - 450}px) scale(${1 + pulse * 0.18})`; g2.style.transform = `translate(${W * 0.85 + Math.cos(t * 0.27) * 160 - 380}px, ${H * 0.72 + Math.sin(t * 0.35) * 140 - 380}px)`; g3.style.transform = `translate(${W * 0.7 + Math.sin(t * 0.19) * 200 - 320}px, ${H * 0.1 + Math.cos(t * 0.29) * 100 - 320}px)`; g1.style.opacity = String(0.8 + 0.2 * beat * (t > SCENES[1].start ? 1 : 0.3)); grid.style.transform = `translate(${(t * 18) % 64}px, ${(t * 26) % 64}px)`; let f = 0; for (const c of CUTS) if (t >= c && t < c + 0.14) f = Math.max(f, (c === scene('brand').start || c === scene('submit').start ? 0.45 : 0.2) * (1 - (t - c) / 0.14)); flash.style.opacity = String(f); } // ---------- captions ---------- // lines: array of [text, at] ; words wrapped in *...* are highlighted. at = seconds after the caption start. const CAPS = [ { id: 'prompt', lines: [['One prompt.', 0.15], ['Two *stores.*', 1.35]] }, { id: 'config', lines: [['One *config.*', 0.05]], sub: ['storebound.config.ts + store/*.md', 0.55] }, { id: 'prices', lines: [['IAP *prices.*', 0.05], ['Every region.', 0.55]] }, { id: 'languages', lines: [['Listings in', 0.05], ['*14* languages.', 0.45]] }, { id: 'questionnaires', lines: [['Every', 0.05], ['*questionnaire.*', 0.3]], sub: ['Data safety · age rating · App Privacy', 0.9] }, { id: 'shots', lines: [['Store art,', 0.05], ['*rendered.*', 0.4]], sub: ['real renders · Prism Puddle demo', 1.0] }, { id: 'validate', lines: [['Blockers', 0.05], ['#count', 0.3]], sub: ['read-only check · in fix order', 0.8] }, { id: 'desktop', lines: [['And a', 0.05], ['*desktop* app.', 0.3]], sub: ['macOS · Windows · Linux', 0.9] }, ]; const capEl = $('#caption'); let capId = null, capWords = [], capSub = null, capCount = null; function buildCaption(c) { const base = V ? 112 : 108; capEl.style.fontSize = `${base}px`; capEl.innerHTML = c.lines.map(([text]) => text === '#count' ? '7' : `${text.split(' ').map(w => w.startsWith('*') ? `${esc(w.replace(/\*/g, ''))}` : `${esc(w)}`).join(' ')}`).join('') + (c.sub ? `${esc(c.sub[0])}` : ''); // fit: the widest line must fit the caption box const avail = capEl.clientWidth; const widest = Math.max(...[...capEl.querySelectorAll('.line')].map(l => l.scrollWidth)); if (widest > avail) capEl.style.fontSize = `${Math.floor(base * avail / widest)}px`; capWords = []; [...capEl.querySelectorAll('.line')].forEach((l, i) => { [...l.querySelectorAll('.w')].forEach((w, j) => capWords.push({ el: w, at: c.lines[i][1] + j * 0.07 })); }); capSub = c.sub ? { el: capEl.querySelector('.sub'), at: c.sub[1] } : null; capCount = capEl.querySelector('[data-count]'); } function captions(t) { const s = sceneAt(t); const c = CAPS.find(x => x.id === s.id); if (!c) { capEl.style.opacity = '0'; return; } if (capId !== c.id) { capId = c.id; buildCaption(c); } const r = t - s.start; const out = prog(t, s.end - 0.16, 0.16); capEl.style.opacity = String(1 - out); capEl.style.transform = `translateY(${-50 * eic(out)}px)`; for (const w of capWords) { const p = prog(r, w.at, 0.3); w.el.style.opacity = String(clamp(p * 4)); w.el.style.transform = `translateY(${(1 - eob(p)) * 0.45}em) scale(${1 + 0.3 * (1 - eoc(p))})`; } if (capSub) { const p = prog(r, capSub.at, 0.3); capSub.el.style.opacity = String(p); capSub.el.style.transform = `translateY(${(1 - eoc(p)) * 20}px)`; } if (capCount) { const n = BLOCKERS.length - fixedCount(r); capCount.textContent = n === 0 ? '0' : String(n); capCount.classList.toggle('g', n === 0); const last = n < BLOCKERS.length ? FIX_AT + (BLOCKERS.length - n - 1) * FIX_GAP : -9; const pop = 1 - prog(r, last, 0.18); const base = prog(r, 0.3, 0.3); capCount.style.transform = `translateY(${(1 - eob(base)) * 0.45}em) scale(${(1 + 0.3 * (1 - eoc(base))) * (1 + (n === 0 ? 0.35 : 0.18) * pop)})`; capCount.style.opacity = String(clamp(base * 4)); capCount.style.color = n === 0 ? 'var(--green)' : '#f87171'; } } const fixedCount = r => r < FIX_AT ? 0 : Math.min(BLOCKERS.length, Math.floor((r - FIX_AT) / FIX_GAP) + 1); // ---------- terminal ---------- const term = $('#term'), pin = $('#term .pin'), linesEl = $('#term .lines'); const TERM_SCENES = ['prompt', 'config', 'prices', 'languages', 'questionnaires', 'shots', 'validate']; const PANEL_FOR = { prices: '#prices', languages: '#langs', questionnaires: '#quest' }; const cursor = ''; const fmtOut = text => { const m = text.match(/^\[(\w+)\](.*)$/s); if (!m) return esc(text); let rest = esc(m[2]).replace(/\(dry\)/g, '(dry)'); return `[${m[1]}]${rest}`; }; let lastLines = '', lastPin = '', panelTopCache = null; function terminal(t) { const s = sceneAt(t); const on = TERM_SCENES.includes(s.id); if (!on) { term.style.opacity = '0'; return; } const r = t - s.start; // enter + punch on every cut const enter = s.id === 'prompt' ? eoc(prog(t, 0, 0.35)) : 1; const punch = s.id === 'prompt' ? 0 : 1 - eoc(prog(r, 0, 0.28)); const dim = s.id === 'shots' ? 0.72 * eoc(prog(r, 0.35, 0.35)) : 0; term.style.opacity = String(enter * (1 - dim)); term.style.transform = `translateY(${(1 - enter) * 60}px) scale(${(0.94 + 0.06 * enter) * (1 + 0.035 * punch)})`; // pinned user prompt const n = clamp(Math.floor((t - PROMPT_AT) * PROMPT_CPS), 0, PROMPT.length); const typing = n < PROMPT.length; const blink = Math.floor(t * 2.6) % 2 === 0; const pinHtml = `> ${esc(PROMPT.slice(0, n))}${s.id === 'prompt' && (typing || blink) ? cursor : ''}`; if (pinHtml !== lastPin) { pin.innerHTML = pinHtml; lastPin = pinHtml; } // scene lines const out = []; let busy = false; for (const l of TERMINAL[s.id] ?? []) { if (r < l.at) break; if (l.kind === 'cmd') { const k = Math.min(l.text.length, Math.floor((r - l.at) * CMD_CPS) + 1); busy = k < l.text.length; out.push(`

`).join('')}
`).join('');
const frameEls = Object.fromEntries([...cam.querySelectorAll('img')].map(im => [im.dataset.f, im]));
// the dialog's dry run restates the diff rows of the prices-diff frame (fixture data)
dlg.querySelector('pre').textContent = [
'Dry run (storebound prices import --dry):',
'coins_small Google Play TR TRY 21.99 -> 24.99',
'coins_small Google Play BR R$3.99 -> R$4.49',
'coins_small App Store TR TRY 29.99 -> 24.99',
'no_ads App Store BR R$14.90 -> R$12.90',
].join('\n');
if (V) { stepEl.style.left = '0'; stepEl.style.right = '0'; stepEl.style.textAlign = 'center'; stepEl.style.top = `${DW.y + TB + VH + 56}px`; }
else { stepEl.style.left = '120px'; stepEl.style.top = '790px'; }
const focusOf = f => (typeof f === 'string' ? (b => [b.x + b.w / 2, b.y + b.h / 2])(BOXES[f]) : f);
/** Camera for a step: scale and offset of the frame inside the view, the focus kept on screen, no empty edge. */
function camFor(st, p) {
const z = lerp(1, st.zoom, p), S = (VW / FW) * z;
const [fx, fy] = focusOf(st.focus);
const ox = clamp(VW / 2 - fx * FW * S, VW - FW * S, 0), oy = clamp(VH / 2 - fy * FH * S, VH - FH * S, 0);
return { S, ox, oy };
}
let deskCam = { S: VW / FW, ox: 0, oy: 0 };
/** A point of the frame (fractions) in stage pixels, through the current camera. */
const framePt = (fx, fy) => [DW.x + deskCam.ox + fx * FW * deskCam.S, DW.y + TB + deskCam.oy + fy * FH * deskCam.S];
function deskTarget(name) {
if (name === 'off') return [DW.x + VW + 120, DW.y + TB + VH + 160];
if (name === 'dialog-ok') { const b = dlg.querySelector('.ok').getBoundingClientRect(); return [b.left + b.width * 0.9, b.top + b.height * 0.7]; }
const b = BOXES[name];
return framePt(b.x + b.w * (b.w ? 0.9 : 1), b.y + b.h * (b.h ? 0.75 : 1));
}
function desktop(t) {
const s = sceneAt(t), r = t - s.start;
if (s.id !== 'desktop') { deskEl.style.opacity = '0'; deskEl.style.display = 'none'; return; }
deskEl.style.display = ''; deskEl.style.opacity = '1';
// window in, a punch on every step
const ip = prog(r, 0.0, 0.45);
const si = DESKTOP.findLastIndex(x => r >= x.at), st = DESKTOP[Math.max(0, si)];
const punch = si > 0 && !st.dialog ? 1 - eoc(prog(r, st.at, 0.25)) : 0;
win.style.opacity = String(clamp(ip * 2.5));
win.style.transform = `translateY(${(1 - eob(ip)) * 120}px) scale(${(0.9 + 0.1 * eoc(ip)) * (1 + 0.02 * punch)})`;
// frames: a quick crossfade on each cut; the chart tooltip fades in when the cursor gets there
const prev = DESKTOP[si - 1];
const fade = prev && prev.frame !== st.frame ? prog(r, st.at, 0.16) : 1;
const frameName = x => (x.frame === 'growth' && r >= DESK_HOVER_AT ? 'growth-hover' : x.frame);
for (const [f, im] of Object.entries(frameEls)) {
im.style.opacity = f === frameName(st) ? '1' : prev && f === frameName(prev) && fade < 1 ? '1' : '0';
im.style.zIndex = f === frameName(st) ? '2' : '1';
}
if (frameEls[frameName(st)]) frameEls[frameName(st)].style.opacity = String(fade);
const growthTip = st.frame === 'growth' ? prog(r, DESK_HOVER_AT, 0.15) : 0;
if (st.frame === 'growth' && r >= DESK_HOVER_AT) { frameEls.growth.style.opacity = '1'; frameEls['growth-hover'].style.opacity = String(growthTip); }
// camera: ease into the step's zoom (a fresh frame starts from the whole window)
const keep = prev && prev.frame === st.frame;
const from = keep ? camFor(prev, 1) : camFor(st, 0), to = camFor(st, 1);
const cp = eoc(prog(r, st.at + 0.1, 0.9));
deskCam = { S: lerp(from.S, to.S, cp), ox: lerp(from.ox, to.ox, cp), oy: lerp(from.oy, to.oy, cp) };
cam.style.transform = `translate(${deskCam.ox}px, ${deskCam.oy}px) scale(${deskCam.S})`;
// the confirm dialog
const dIn = prog(r, DESK_DIALOG[0], 0.3), dOut = prog(r, DESK_DIALOG[1] + 0.12, 0.2);
const dv = clamp(dIn * 3) * (1 - dOut);
shade.style.opacity = String(dv);
dlg.style.opacity = String(dv);
dlg.style.transform = `translate(-50%, -50%) scale(${(V ? 1.25 : 1.05) * (0.85 + 0.15 * eob(dIn)) * (1 - 0.06 * dOut)})`;
// step label
const sp = prog(r, st.at + 0.05, 0.3);
stepEl.innerHTML = `${String(si + 1).padStart(2, '0')}${esc(st.step)}`;
stepEl.style.opacity = String(clamp(sp * 2) * (1 - prog(t, s.end - 0.16, 0.16)));
stepEl.style.transform = `translateY(${(1 - eoc(sp)) * 24}px)`;
// cursor
const k = DESK_CURSOR.findLastIndex(([a]) => r >= a);
if (k < 0) dcur.style.opacity = '0';
else {
const [a0, n0] = DESK_CURSOR[k], nx = DESK_CURSOR[k + 1];
const p0 = deskTarget(n0);
let [x, y] = p0;
if (nx) { const p1 = deskTarget(nx[1]); const mp = eoc(clamp((r - a0) / (nx[0] - a0))); x = lerp(p0[0], p1[0], mp); y = lerp(p0[1], p1[1], mp); }
const click = DESK_CURSOR.filter(c => c[2]).reduce((m, c) => Math.max(m, 1 - Math.min(1, Math.abs(r - c[0]) / 0.12)), 0);
dcur.style.opacity = String(clamp((r - DESK_CURSOR[0][0]) * 5));
dcur.style.transform = `translate(${x - 10}px, ${y - 10}px) scale(${1 - 0.18 * click})`;
}
// "Submit for review · your click" by the console button
const lp = prog(r, DESK_LINK_AT, 0.35);
const cb = BOXES.console, [bx, by] = framePt(cb.x + cb.w, cb.y + cb.h);
linkEl.style.opacity = String(clamp(lp * 3));
linkEl.style.left = `${Math.min(bx, DW.x + VW - 12)}px`; linkEl.style.top = `${by + 26}px`;
linkEl.style.transform = `translateX(-100%) scale(${0.6 + 0.4 * eob(lp)})`;
}
// ---------- end cards ----------
const submitEl = $('#submit'), btn = $('#submit .btn'), ring = $('#submit .ring'), kick = $('#submit .kick'),
yours = $('#submit .yours'), fine = $('#submit .fine'), cur = $('#cursor');
const brandEl = $('#brand');
const brandParts = [...brandEl.children];
function pop(el, r, at, dist = 50, d = 0.35) {
const p = prog(r, at, d);
el.style.opacity = String(clamp(p * 2.5));
el.style.transform = `translateY(${(1 - eob(p)) * dist}px) scale(${0.85 + 0.15 * eob(p)})`;
}
function endCards(t) {
const s = sceneAt(t), r = t - s.start;
submitEl.style.opacity = s.id === 'submit' ? '1' : '0';
brandEl.style.opacity = s.id === 'brand' ? '1' : '0';
cur.style.opacity = '0';
if (s.id === 'submit') {
pop(kick, r, 0.0, 30);
const bp = prog(r, 0.08, 0.42);
btn.style.opacity = String(clamp(bp * 3));
const hover = eoc(prog(r, 1.25, 0.2));
btn.style.transform = `scale(${(0.4 + 0.6 * eob(bp)) * (1 + 0.04 * hover)})`;
btn.style.filter = `brightness(${1 + 0.18 * hover})`;
const rp = ((r - 0.5) % BEAT) / BEAT;
ring.style.opacity = r > 0.5 ? String(0.7 * (1 - rp)) : '0';
ring.style.transform = `scale(${1 + 0.12 * eoc(rp)})`;
pop(yours, r, 0.95, 70, 0.4);
pop(fine, r, 1.55, 30);
// the cursor comes close and waits: the click stays yours
const b = btn.getBoundingClientRect();
const tx = b.left + b.width * 0.78, ty = b.top + b.height * 0.72;
const cp = eoc(prog(r, 0.55, 0.8));
const wob = Math.sin(r * 5) * 4 * prog(r, 1.35, 0.3);
cur.style.opacity = String(clamp((r - 0.55) * 4));
cur.style.transform = `translate(${lerp(tx + 380, tx, cp) + wob}px, ${lerp(ty + 420, ty, cp) + wob * 0.6}px)`;
} else if (s.id === 'brand') {
const [mark, word, tag, url, meta, desk, inst] = brandParts;
const mp = prog(r, 0.0, 0.45);
mark.style.opacity = String(clamp(mp * 3));
mark.style.transform = `scale(${eob(mp)}) rotate(${(1 - eoc(mp)) * -25}deg)`;
pop(word, r, 0.15, 60);
pop(tag, r, 0.5, 40);
pop(url, r, 0.85, 40);
pop(meta, r, 1.05, 30);
pop(desk, r, 1.2, 30);
pop(inst, r, 1.4, 30);
const beat = 1 - prog(((r + 1e-6) % BEAT), 0, BEAT * 0.5);
url.style.textShadow = `0 0 ${20 + 30 * beat * (r > 0.85 ? 1 : 0)}px rgba(129,140,248,${0.35 + 0.35 * beat})`;
}
}
// ---------- seek ----------
function seek(t) {
t = clamp(t, 0, DURATION - 1e-6);
background(t);
captions(t);
terminal(t);
panels(t);
shots(t);
desktop(t);
endCards(t);
}
const ready = (async () => {
await document.fonts.ready;
await Promise.all([...document.images].map(im => im.decode().catch(() => { throw new Error(`image failed: ${im.src}`); })));
seek(0);
})();
window.teaser = { ready, seek, DURATION, FPS, BAR, W, H };
if (q.has('t')) ready.then(() => seek(Number(q.get('t'))));
if (q.has('play')) ready.then(() => {
const t0 = performance.now();
const loop = () => { seek(((performance.now() - t0) / 1000) % DURATION); requestAnimationFrame(loop); };
loop();
});