diff --git a/.gitignore b/.gitignore index 29b44e3c..e5c7dc00 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules/ *.jks *.p12 .DS_Store +media/teaser/out/ diff --git a/media/teaser/README.md b/media/teaser/README.md new file mode 100644 index 00000000..b9fc3f1d --- /dev/null +++ b/media/teaser/README.md @@ -0,0 +1,35 @@ +# storebound teaser (30-40 s social video) + +A scripted terminal animation, not a screen recording. Every frame is a pure function of time, rendered from an +HTML/CSS/JS timeline in headless Chrome and encoded with ffmpeg. The music is original and synthesized from scratch in +the same browser (Web Audio `OfflineAudioContext`): no samples, no downloaded audio, nothing to license. + +| file | what | +|---|---| +| `script.js` | the timeline: tempo (128 BPM, 20 bars = 37.5 s), scenes, terminal lines, prices, languages, blockers | +| `index.html` + `teaser.js` | the picture; `window.teaser.seek(t)` sets every element for time `t` | +| `music.js` | the music: arp, kick, hats, clap, offbeat bass, pad, impacts on the cuts, key clicks, riser | +| `render.ts` | frames -> ffmpeg (H.264 high, yuv420p, 30 fps), music -> loudnorm (-14 LUFS, -1.5 dBTP), mux, posters | +| `poster.jpg` | end card still (1920x1080, small) | + +The terminal text is modelled on real storebound output for the demo game (`examples/demo-game`, placeholder ids, +dry runs); the price table values are illustrative. The store art is the demo game's real renders. + +## Render + +Needs Bun, ffmpeg and Playwright (repo devDependency; Playwright's Chromium or an installed Google Chrome). + +```sh +# optional, for sharp store art: the demo renders (otherwise crops of docs/img/showcase.jpg are used) +cd examples/demo-game && bun serve.ts & bun ../../cli/index.ts shots capture && bun ../../cli/index.ts shots fonts && bun ../../cli/index.ts shots render +# from the repo root +bun media/teaser/render.ts # both formats + music, about 10 min +bun media/teaser/render.ts --only v # vertical only (h = horizontal) +bun media/teaser/render.ts --stills 2,12.5,30 # PNG stills in out/stills for a quick layout check +bun media/teaser/render.ts --serve --port 8750 # live preview: /index.html?w=1080&h=1920&play=1 (or &t=12.5) +``` + +Outputs (gitignored) in `media/teaser/out/`: `teaser-1080x1920.mp4` (X / TikTok / Reels), `teaser-1920x1080.mp4` +(X / YouTube), `-silent` variants, `poster-*.jpg`, `music.wav`. + +Vertical layout keeps captions and key text inside the central 80% and leaves the bottom ~22% free for app overlays. diff --git a/media/teaser/index.html b/media/teaser/index.html new file mode 100644 index 00000000..3edd7bf3 --- /dev/null +++ b/media/teaser/index.html @@ -0,0 +1,222 @@ + + + + + +storebound teaser + + + +
+
+ +
+
+ your AI agentprism-puddle · scripted demo
+
+
+ +
+

Regional prices API

+

USD base · Play converts per region · your overrides

+
regioncurremove_adsdrops_500
+
+
+ +
+

Store listings API0/14

+

title · short + full description · keywords · per language

+
+
+ +
+

Store questionnaires

+

API where the stores have one · a skill where they do not

+
+
+ +
+
+ +
+ +
+
storebound never presses Submit.
+
Submit for review
+
your click.YOU
+
Play: Send changes for review · App Store: Submit for Review
+
+ + +
+
+
storebound
+
From zero to “Submit for review”
on Google Play and the App Store.
+
storebound.dev
+
open source · MIT
+
$bunx storebound init
+
+ +
+
+ + + diff --git a/media/teaser/music.js b/media/teaser/music.js new file mode 100644 index 00000000..76667919 --- /dev/null +++ b/media/teaser/music.js @@ -0,0 +1,242 @@ +// Original teaser music, synthesized from nothing with the Web Audio API (OfflineAudioContext): no samples, no +// downloaded audio. 128 BPM, F minor, tight 16th arpeggio, kick / hats / clap, offbeat bass, a pad, impacts on every +// scene cut (script.js CUTS), key clicks on every typed character, a riser into the end card. Deterministic (seeded). +// renderWav() returns a 32-bit float stereo WAV (48 kHz) as base64; render.ts masters it with ffmpeg loudnorm. +import { BAR, BEAT, CUTS, DURATION, keyTimes, scene } from './script.js'; + +const SR = 48000; +const midi = m => 440 * Math.pow(2, (m - 69) / 12); +function rng(seed) { // mulberry32 + let a = seed >>> 0; + return () => { a = (a + 0x6d2b79f5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; +} + +// chords per bar (root midi in octave 3, intervals) +const CH = { Fm: [53, [0, 3, 7]], Db: [49, [0, 4, 7]], Ab: [56, [0, 4, 7]], Eb: [51, [0, 4, 7]] }; +const BARS = ['Ab', 'Eb', 'Fm', 'Db', 'Ab', 'Eb', 'Fm', 'Db', 'Ab', 'Eb', 'Fm', 'Db', 'Ab', 'Eb', 'Eb', 'Db', 'Eb', 'Fm', 'Eb', 'Fm']; +const ARP = [0, 2, 4, 3, 5, 4, 2, 3, 0, 2, 4, 6, 5, 4, 3, 2]; + +export async function renderMusic() { + const ctx = new OfflineAudioContext({ numberOfChannels: 2, length: Math.ceil(DURATION * SR) + SR, sampleRate: SR }); + const R = rng(20261010); + + // shared noise + const noise = ctx.createBuffer(2, SR * 3, SR); + for (let c = 0; c < 2; c++) { const d = noise.getChannelData(c); for (let i = 0; i < d.length; i++) d[i] = R() * 2 - 1; } + + // reverb impulse + const ir = ctx.createBuffer(2, Math.floor(SR * 2.6), SR); + for (let c = 0; c < 2; c++) { const d = ir.getChannelData(c); for (let i = 0; i < d.length; i++) d[i] = (R() * 2 - 1) * Math.pow(1 - i / d.length, 3.2); } + + // buses + const comp = ctx.createDynamicsCompressor(); + comp.threshold.value = -14; comp.knee.value = 6; comp.ratio.value = 3.5; comp.attack.value = 0.004; comp.release.value = 0.16; + const master = ctx.createGain(); master.gain.value = 0.7; + master.connect(comp); comp.connect(ctx.destination); + const verb = ctx.createConvolver(); verb.buffer = ir; + const verbIn = ctx.createGain(); verbIn.gain.value = 0.5; verbIn.connect(verb); verb.connect(master); + const duck = ctx.createGain(); duck.connect(master); // sidechained group: pad, bass, arp + const drums = ctx.createGain(); drums.gain.value = 0.9; drums.connect(master); + + const arpBus = ctx.createGain(); arpBus.gain.value = 0.55; + const arpLP = ctx.createBiquadFilter(); arpLP.type = 'lowpass'; arpLP.Q.value = 6; + arpBus.connect(arpLP); arpLP.connect(duck); + // stereo echo on the arp + for (const [time, pan] of [[BEAT * 0.75, -0.6], [BEAT * 1.5, 0.6]]) { + const dl = ctx.createDelay(2); dl.delayTime.value = time; + const fb = ctx.createGain(); fb.gain.value = 0.28; + const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.value = 2600; + const p = ctx.createStereoPanner(); p.pan.value = pan; + const wet = ctx.createGain(); wet.gain.value = 0.32; + arpLP.connect(dl); dl.connect(lp); lp.connect(fb); fb.connect(dl); lp.connect(wet); wet.connect(p); p.connect(duck); + } + const arpVerb = ctx.createGain(); arpVerb.gain.value = 0.18; arpLP.connect(arpVerb); arpVerb.connect(verbIn); + + // arp filter: closed intro, open drop, wide on the riser, dark under the Submit card, bright on the brand + const f = arpLP.frequency; + const at = s => scene(s).start; + f.setValueAtTime(420, 0); + f.exponentialRampToValueAtTime(2400, at('config') - 0.02); + f.setValueAtTime(3000, at('config')); + f.linearRampToValueAtTime(3400, at('submit') - BAR); + f.exponentialRampToValueAtTime(7000, at('submit') - 0.01); + f.setValueAtTime(900, at('submit')); + f.exponentialRampToValueAtTime(1800, at('brand') - 0.01); + f.setValueAtTime(4200, at('brand')); + f.setValueAtTime(4200, at('brand') + BAR * 2); + f.exponentialRampToValueAtTime(800, DURATION); + + const env = (g, t, a, peak, d, end = 0.0005) => { + g.gain.setValueAtTime(0, t); g.gain.linearRampToValueAtTime(peak, t + a); g.gain.exponentialRampToValueAtTime(end, t + a + d); + }; + const noiseSrc = (t, dur, off = R() * 1.5) => { const s = ctx.createBufferSource(); s.buffer = noise; s.start(t, off, dur); return s; }; + + // ---- voices ---- + function kick(t, g = 1) { + const o = ctx.createOscillator(); o.type = 'sine'; + o.frequency.setValueAtTime(155, t); o.frequency.exponentialRampToValueAtTime(44, t + 0.11); + const v = ctx.createGain(); env(v, t, 0.002, 1.0 * g, 0.42); + o.connect(v); v.connect(drums); o.start(t); o.stop(t + 0.5); + const n = noiseSrc(t, 0.01); const hp = ctx.createBiquadFilter(); hp.type = 'highpass'; hp.frequency.value = 3500; + const nv = ctx.createGain(); env(nv, t, 0.001, 0.22 * g, 0.012); n.connect(hp); hp.connect(nv); nv.connect(drums); + duck.gain.setValueAtTime(0.28, t); duck.gain.linearRampToValueAtTime(1, t + 0.22); + } + function hat(t, g, pan) { + const n = noiseSrc(t, 0.06); const hp = ctx.createBiquadFilter(); hp.type = 'highpass'; hp.frequency.value = 7500; + const p = ctx.createStereoPanner(); p.pan.value = pan; + const v = ctx.createGain(); env(v, t, 0.001, g, 0.04); n.connect(hp); hp.connect(v); v.connect(p); p.connect(drums); + } + function clap(t, g = 0.4) { + const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = 1300; bp.Q.value = 0.9; + const v = ctx.createGain(); v.gain.setValueAtTime(0, t); + for (let i = 0; i < 3; i++) { v.gain.setValueAtTime(g, t + i * 0.011); v.gain.exponentialRampToValueAtTime(g * 0.2, t + i * 0.011 + 0.009); } + v.gain.setValueAtTime(g * 0.8, t + 0.034); v.gain.exponentialRampToValueAtTime(0.0005, t + 0.2); + const n = noiseSrc(t, 0.25); n.connect(bp); bp.connect(v); v.connect(drums); + const s = ctx.createGain(); s.gain.value = 0.5; v.connect(s); s.connect(verbIn); + } + function snare(t, g) { + const n = noiseSrc(t, 0.12); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = 1900; bp.Q.value = 0.7; + const v = ctx.createGain(); env(v, t, 0.001, g, 0.09); n.connect(bp); bp.connect(v); v.connect(drums); + const o = ctx.createOscillator(); o.type = 'triangle'; o.frequency.setValueAtTime(240, t); o.frequency.exponentialRampToValueAtTime(160, t + 0.05); + const ov = ctx.createGain(); env(ov, t, 0.001, g * 0.5, 0.06); o.connect(ov); ov.connect(drums); o.start(t); o.stop(t + 0.12); + } + function arpNote(t, m, g = 0.12, len = 0.17) { + const v = ctx.createGain(); env(v, t, 0.003, g, len); v.connect(arpBus); + for (const [type, det] of [['sawtooth', -7], ['square', 7]]) { + const o = ctx.createOscillator(); o.type = type; o.frequency.value = midi(m); o.detune.value = det; + const og = ctx.createGain(); og.gain.value = type === 'square' ? 0.5 : 0.8; + o.connect(og); og.connect(v); o.start(t); o.stop(t + len + 0.05); + } + } + function bass(t, m, g = 0.32, len = BEAT * 0.45) { + const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.setValueAtTime(900, t); lp.frequency.exponentialRampToValueAtTime(220, t + len); lp.Q.value = 4; + const v = ctx.createGain(); v.gain.setValueAtTime(0, t); v.gain.linearRampToValueAtTime(g, t + 0.004); v.gain.setValueAtTime(g, t + len * 0.7); v.gain.linearRampToValueAtTime(0, t + len); + lp.connect(v); v.connect(duck); + const o = ctx.createOscillator(); o.type = 'sawtooth'; o.frequency.value = midi(m); o.connect(lp); o.start(t); o.stop(t + len + 0.02); + const sub = ctx.createOscillator(); sub.type = 'sine'; sub.frequency.value = midi(m - 12); + const sg = ctx.createGain(); sg.gain.value = 0.9; sub.connect(sg); sg.connect(v); sub.start(t); sub.stop(t + len + 0.02); + } + function pad(t, dur, notes, g = 0.05, cutoff = 1500) { + const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.value = cutoff; lp.Q.value = 0.7; + const v = ctx.createGain(); v.gain.setValueAtTime(0, t); v.gain.linearRampToValueAtTime(g, t + 0.25); v.gain.setValueAtTime(g, t + dur - 0.1); v.gain.linearRampToValueAtTime(0, t + dur + 0.25); + lp.connect(v); v.connect(duck); + const s = ctx.createGain(); s.gain.value = 0.6; v.connect(s); s.connect(verbIn); + for (const m of notes) for (const det of [-9, 9]) { + const o = ctx.createOscillator(); o.type = 'sawtooth'; o.frequency.value = midi(m); o.detune.value = det; + const p = ctx.createStereoPanner(); p.pan.value = det < 0 ? -0.4 : 0.4; + o.connect(p); p.connect(lp); o.start(t); o.stop(t + dur + 0.3); + } + } + function impact(t, big = false) { + const o = ctx.createOscillator(); o.type = 'sine'; + o.frequency.setValueAtTime(big ? 120 : 100, t); o.frequency.exponentialRampToValueAtTime(32, t + (big ? 0.9 : 0.5)); + const v = ctx.createGain(); env(v, t, 0.003, big ? 0.95 : 0.6, big ? 1.3 : 0.6); o.connect(v); v.connect(master); o.start(t); o.stop(t + 1.6); + const n = noiseSrc(t, 2.0); const hp = ctx.createBiquadFilter(); hp.type = 'highpass'; hp.frequency.value = big ? 1800 : 3200; + const nv = ctx.createGain(); env(nv, t, 0.002, big ? 0.32 : 0.16, big ? 1.8 : 0.9); n.connect(hp); hp.connect(nv); nv.connect(master); + const s = ctx.createGain(); s.gain.value = big ? 0.7 : 0.4; nv.connect(s); s.connect(verbIn); + } + function stab(t, name, g = 0.09) { + const [root, iv] = CH[name]; + const notes = [root - 12, ...iv.map(i => root + i), ...iv.map(i => root + 12 + i)]; + const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.setValueAtTime(5000, t); lp.frequency.exponentialRampToValueAtTime(600, t + 1.4); + const v = ctx.createGain(); env(v, t, 0.004, g, 1.6); lp.connect(v); v.connect(master); + const s = ctx.createGain(); s.gain.value = 0.8; v.connect(s); s.connect(verbIn); + for (const m of notes) for (const det of [-11, 0, 11]) { + const o = ctx.createOscillator(); o.type = 'sawtooth'; o.frequency.value = midi(m); o.detune.value = det; + o.connect(lp); o.start(t); o.stop(t + 1.8); + } + } + function whoosh(t, dur, g = 0.22, from = 500, to = 7000) { + const n = noiseSrc(t, dur + 0.05); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.Q.value = 2.2; + bp.frequency.setValueAtTime(from, t); bp.frequency.exponentialRampToValueAtTime(to, t + dur); + const v = ctx.createGain(); v.gain.setValueAtTime(0.0001, t); v.gain.exponentialRampToValueAtTime(g, t + dur * 0.95); v.gain.linearRampToValueAtTime(0, t + dur); + n.connect(bp); bp.connect(v); v.connect(master); + } + function riser(t, dur, g = 0.07) { + whoosh(t, dur, 0.3, 300, 9000); + const o = ctx.createOscillator(); o.type = 'sawtooth'; o.frequency.setValueAtTime(midi(53), t); o.frequency.exponentialRampToValueAtTime(midi(77), t + dur); + const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.setValueAtTime(800, t); lp.frequency.exponentialRampToValueAtTime(6000, t + dur); + const v = ctx.createGain(); v.gain.setValueAtTime(0, t); v.gain.linearRampToValueAtTime(g, t + dur); v.gain.linearRampToValueAtTime(0, t + dur + 0.02); + o.connect(lp); lp.connect(v); v.connect(master); o.start(t); o.stop(t + dur + 0.05); + } + function key(t, g) { + const n = noiseSrc(t, 0.02); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = 2600 + R() * 2600; bp.Q.value = 3; + const p = ctx.createStereoPanner(); p.pan.value = R() * 0.5 - 0.25; + const v = ctx.createGain(); env(v, t, 0.0008, g * (0.7 + R() * 0.6), 0.012); n.connect(bp); bp.connect(v); v.connect(p); p.connect(master); + } + + // ---- arrangement ---- + const sub = scene('submit').start, brand = scene('brand').start, drop = scene('config').start; + const rollBar = scene('validate').end - BAR; // last bar before the Submit card + duck.gain.setValueAtTime(1, 0); + for (let b = 0; b < 20; b++) { + const t0 = b * BAR, name = BARS[b], [root, iv] = CH[name]; + const tones = [0, iv[1], iv[2], 12, 12 + iv[1], 12 + iv[2], 24].map(x => root + 12 + x); + const main = t0 >= drop && t0 < sub, end = b === 19, calm = t0 >= sub && t0 < brand; + const groove = main || (t0 >= brand && !end); + // pad + if (!end) pad(t0, BAR, [root, root + iv[1], root + iv[2], root + 12], calm ? 0.06 : t0 < drop ? 0.045 : 0.035, calm ? 1100 : 1500); + for (let s = 0; s < 16; s++) { + const t = t0 + s * BEAT / 4; + const beat = s % 4 === 0, off = s % 4 === 2; + const cutDrums = t0 === rollBar && s >= 8; // drums drop out for the last half bar of the riser + // arp + if (!end) { + if (calm) { if (s % 2 === 0) arpNote(t, tones[ARP[s]] ?? root, 0.09, 0.3); } + else arpNote(t, tones[ARP[s]] ?? root, t0 < drop ? 0.08 : 0.11, 0.16); + } + if (groove && !cutDrums) { + if (beat) kick(t); + if (off) { hat(t, 0.14, 0.2); bass(t, root - 12); } + else if (!beat) hat(t, 0.045, -0.2); + if (t0 >= drop + BAR * 2 && (s === 4 || s === 12)) clap(t); + } + if (calm && off) hat(t, 0.05, 0.15); + if (b === 1 && s >= 8 && s % 2 === 0) hat(t, 0.02 + 0.06 * (s - 8) / 8, 0); // intro tick-in + } + } + // snare roll + riser into the Submit card + for (let i = 0; i < 8; i++) snare(rollBar + i * BEAT / 4, 0.04 + 0.1 * i / 7); + for (let i = 0; i < 16; i++) snare(rollBar + BAR / 2 + i * BEAT / 8, 0.14 + 0.18 * i / 15); + riser(rollBar, BAR); + riser(brand - BAR / 2, BAR / 2, 0.05); + whoosh(drop - BAR / 2, BAR / 2, 0.25); + // hits on the cuts + for (const c of CUTS) { + const big = c === sub || c === brand; + if (!big && c !== drop) whoosh(c - 0.32, 0.32, 0.16, 800, 6000); + impact(c, big || c === drop); + } + stab(drop, 'Fm', 0.06); + stab(sub, 'Db', 0.1); + stab(brand, 'Fm', 0.1); + stab(19 * BAR, 'Fm', 0.11); + impact(19 * BAR, true); + kick(19 * BAR, 1); + // key clicks + for (const t of keyTimes()) key(t, t < drop ? 0.16 : 0.07); + + const buf = await ctx.startRendering(); + const n = Math.round(DURATION * SR); + return { sampleRate: SR, left: buf.getChannelData(0).slice(0, n), right: buf.getChannelData(1).slice(0, n) }; +} + +/** 32-bit float stereo WAV, base64. */ +export async function renderWav() { + const { sampleRate, left, right } = await renderMusic(); + const n = left.length, bytes = 44 + n * 8; + const ab = new ArrayBuffer(bytes), dv = new DataView(ab); + const str = (o, s) => { for (let i = 0; i < s.length; i++) dv.setUint8(o + i, s.charCodeAt(i)); }; + str(0, 'RIFF'); dv.setUint32(4, bytes - 8, true); str(8, 'WAVE'); str(12, 'fmt '); + dv.setUint32(16, 16, true); dv.setUint16(20, 3, true); dv.setUint16(22, 2, true); dv.setUint32(24, sampleRate, true); + dv.setUint32(28, sampleRate * 8, true); dv.setUint16(32, 8, true); dv.setUint16(34, 32, true); str(36, 'data'); dv.setUint32(40, n * 8, true); + let peak = 0; + for (let i = 0; i < n; i++) { + dv.setFloat32(44 + i * 8, left[i], true); dv.setFloat32(48 + i * 8, right[i], true); + peak = Math.max(peak, Math.abs(left[i]), Math.abs(right[i])); + } + const u8 = new Uint8Array(ab); + let bin = ''; + for (let i = 0; i < u8.length; i += 0x8000) bin += String.fromCharCode.apply(null, u8.subarray(i, i + 0x8000)); + return { base64: btoa(bin), peak, seconds: n / sampleRate }; +} diff --git a/media/teaser/poster.jpg b/media/teaser/poster.jpg new file mode 100644 index 00000000..fd8e67a2 Binary files /dev/null and b/media/teaser/poster.jpg differ diff --git a/media/teaser/render.ts b/media/teaser/render.ts new file mode 100644 index 00000000..c94569e7 --- /dev/null +++ b/media/teaser/render.ts @@ -0,0 +1,133 @@ +#!/usr/bin/env bun +// Renders the storebound teaser: frames from index.html (Playwright, headless Chrome) piped into ffmpeg, plus the +// original music (music.js, OfflineAudioContext in the same browser), mastered to about -14 LUFS. +// bun media/teaser/render.ts both formats, music, posters -> media/teaser/out/ +// bun media/teaser/render.ts --only v vertical only (v = 1080x1920, h = 1920x1080) +// bun media/teaser/render.ts --stills 1,9.5,30 PNG stills only (out/stills/), quick layout check +// bun media/teaser/render.ts --serve preview server: open /index.html?w=1080&h=1920&play=1 +// Needs ffmpeg and Playwright (devDependency; Playwright's Chromium or an installed Google Chrome). +import { existsSync, mkdirSync, statSync } from 'node:fs'; +import { join } from 'node:path'; +import { launch } from '../../cli/shots/browser'; + +const DIR = import.meta.dir; +const ROOT = join(DIR, '../..'); +const OUT = join(DIR, 'out'); +const ASSETS = join(OUT, 'assets'); +const args = process.argv.slice(2); +const opt = (k: string): string | undefined => { const i = args.indexOf(`--${k}`); return i >= 0 ? args[i + 1] : undefined; }; +const FORMATS = [{ id: 'v', w: 1080, h: 1920 }, { id: 'h', w: 1920, h: 1080 }].filter(f => !opt('only') || opt('only') === f.id); +const log = (m: string): void => console.log(`${new Date().toISOString().slice(11, 19)} [teaser] ${m}`); + +function sh(cmd: string[], input?: Uint8Array): void { + const r = Bun.spawnSync(cmd, { stdin: input, stdout: 'pipe', stderr: 'pipe' }); + if (r.exitCode !== 0) throw new Error(`${cmd.slice(0, 3).join(' ')} failed:\n${r.stderr.toString().slice(-2000)}`); +} +const ff = (...a: string[]): void => sh(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-y', ...a]); + +/** Screenshots used by the store-art scene: the demo game's real renders, or crops of docs/img/showcase.jpg. */ +function prepAssets(): void { + mkdirSync(ASSETS, { recursive: true }); + const names = ['en-01', 'en-02', 'en-03', 'en-04', 'tr-01', 'ja-01', 'ar-01']; + const renders = join(ROOT, 'examples/demo-game/store/renders'); + const src = (n: string): string => { const [l, k] = n.split('-'); return join(renders, l!, 'play', `${k}.png`); }; + if (names.every(n => existsSync(src(n)))) { + for (const n of names) ff('-i', src(n), '-vf', 'scale=720:1280:flags=lanczos', '-q:v', '2', join(ASSETS, `${n}.jpg`)); + log('assets: demo game renders (examples/demo-game/store/renders)'); + } else { + // showcase.jpg: 7 panes (en 01-04, tr, ja, ar hero), 263 x 571 each, 283 px apart, from (20, 20) + const show = join(ROOT, 'docs/img/showcase.jpg'); + names.forEach((n, i) => ff('-i', show, '-vf', `crop=263:468:${20 + i * 283}:20,scale=720:1280:flags=lanczos`, '-q:v', '2', join(ASSETS, `${n}.jpg`))); + log('assets: demo renders not found, using crops of docs/img/showcase.jpg (run the demo\'s `shots render` for sharper art)'); + } +} + +function serve(): ReturnType { + return Bun.serve({ + port: Number(opt('port') ?? 0), + fetch(req) { + const p = decodeURIComponent(new URL(req.url).pathname).replace(/^\/+/, '') || 'index.html'; + if (p.includes('..')) return new Response('no', { status: 400 }); + const f = Bun.file(join(DIR, p)); + return f.size ? new Response(f) : new Response('not found', { status: 404 }); + }, + }); +} + +async function main(): Promise { + mkdirSync(OUT, { recursive: true }); + prepAssets(); + const server = serve(); + const base = `http://127.0.0.1:${server.port}/index.html`; + if (args.includes('--serve')) { log(`preview: ${base}?w=1080&h=1920&play=1`); return; } + + const browser = await launch(ROOT, { headless: true }); + try { + const stills = opt('stills'); + for (const f of FORMATS) { + const page = await browser.newPage({ viewport: { width: f.w, height: f.h }, deviceScaleFactor: 1 }); + page.on('pageerror', (e: Error) => console.error('page error:', e.message)); + await page.goto(`${base}?w=${f.w}&h=${f.h}`); + await page.evaluate('window.teaser.ready'); + const { DURATION, FPS } = await page.evaluate('({ DURATION: teaser.DURATION, FPS: teaser.FPS })') as { DURATION: number; FPS: number }; + const shot = async (t: number): Promise => { + await page.evaluate(`teaser.seek(${t})`); + return page.screenshot({ type: 'png' }); + }; + if (stills) { + mkdirSync(join(OUT, 'stills'), { recursive: true }); + for (const t of stills.split(',').map(Number)) { + await Bun.write(join(OUT, 'stills', `${f.id}-${t.toFixed(2)}.png`), await shot(t)); + } + log(`${f.id}: ${stills.split(',').length} stills in out/stills`); + await page.close(); + continue; + } + const frames = Math.round(DURATION * FPS); + const silent = join(OUT, `teaser-${f.w}x${f.h}-silent.mp4`); + const enc = Bun.spawn(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-y', '-f', 'image2pipe', '-framerate', String(FPS), '-c:v', 'png', '-i', '-', + '-c:v', 'libx264', '-profile:v', 'high', '-preset', 'slow', '-crf', '17', '-pix_fmt', 'yuv420p', '-r', String(FPS), + '-g', String(FPS * 2), '-movflags', '+faststart', silent], { stdin: 'pipe', stdout: 'inherit', stderr: 'inherit' }); + const t0 = Date.now(); + for (let i = 0; i < frames; i++) { + enc.stdin.write(await shot(i / FPS)); + if (i % 60 === 0 || i === frames - 1) { + const el = (Date.now() - t0) / 1000; + log(`${f.id}: frame ${i + 1}/${frames} · ${el.toFixed(0)}s · eta ${((frames - i - 1) * el / (i + 1)).toFixed(0)}s`); + } + } + await enc.stdin.end(); + if (await enc.exited !== 0) throw new Error('ffmpeg encode failed'); + ff('-ss', String(DURATION - 0.5), '-i', silent, '-frames:v', '1', '-q:v', '3', join(OUT, `poster-${f.w}x${f.h}.jpg`)); + log(`${f.id}: ${silent} (${(statSync(silent).size / 1e6).toFixed(1)} MB)`); + await page.close(); + } + if (stills || args.includes('--no-audio')) return; + + // music + const page = await browser.newPage(); + await page.goto(base); + log('music: rendering (OfflineAudioContext)'); + const wav = await page.evaluate(`import('./music.js').then(m => m.renderWav())`) as { base64: string; peak: number; seconds: number }; + log(`music: ${wav.seconds.toFixed(2)} s, raw peak ${wav.peak.toFixed(3)}`); + const raw = join(OUT, 'music-raw.wav'), music = join(OUT, 'music.wav'); + await Bun.write(raw, Buffer.from(wav.base64, 'base64')); + const dur = wav.seconds; + // two-pass loudnorm to -14 LUFS / -1 dBTP, then a 2 s fade out + const m = Bun.spawnSync(['ffmpeg', '-hide_banner', '-i', raw, '-af', 'loudnorm=I=-14:TP=-1.5:LRA=11:print_format=json', '-f', 'null', '-'], { stderr: 'pipe' }); + const j = JSON.parse(m.stderr.toString().match(/\{[\s\S]*?\}/)![0]) as Record; + ff('-i', raw, '-af', `loudnorm=I=-14:TP=-1.5:LRA=11:measured_I=${j.input_i}:measured_TP=${j.input_tp}:measured_LRA=${j.input_lra}:measured_thresh=${j.input_thresh}:offset=${j.target_offset}:linear=true,afade=t=out:st=${(dur - 2).toFixed(2)}:d=2,aresample=48000`, + '-c:a', 'pcm_s16le', '-ar', '48000', '-ac', '2', music); + for (const f of FORMATS) { + const silent = join(OUT, `teaser-${f.w}x${f.h}-silent.mp4`), out = join(OUT, `teaser-${f.w}x${f.h}.mp4`); + if (!existsSync(silent)) continue; + ff('-i', silent, '-i', music, '-map', '0:v', '-map', '1:a', '-c:v', 'copy', '-c:a', 'aac', '-b:a', '192k', '-ar', '48000', '-ac', '2', '-shortest', '-movflags', '+faststart', out); + log(`${out} (${(statSync(out).size / 1e6).toFixed(1)} MB)`); + } + } finally { + await browser.close(); + server.stop(true); + } +} + +await main(); diff --git a/media/teaser/script.js b/media/teaser/script.js new file mode 100644 index 00000000..bbd1ba94 --- /dev/null +++ b/media/teaser/script.js @@ -0,0 +1,142 @@ +// Teaser timeline: the single source of truth for the picture (teaser.js) and the music (music.js). +// Everything is a pure function of time, so a frame at t always looks the same and the hits land on the cuts. +// The terminal text is scripted, modelled on real storebound output for the demo game (examples/demo-game, +// placeholder ids, dry runs). Nothing here talks to a store. + +export const BPM = 128; +export const BEAT = 60 / BPM; // 0.46875 s +export const BAR = BEAT * 4; // 1.875 s +export const FPS = 30; +export const BARS = 20; +export const DURATION = BARS * BAR; // 37.5 s + +/** Scenes in bars; start/end in seconds are derived below. */ +const SCENE_BARS = [ + ['prompt', 2], + ['config', 2], + ['prices', 2], + ['languages', 2], + ['questionnaires', 2], + ['shots', 3], + ['validate', 2], + ['submit', 2], + ['brand', 3], +]; +let acc = 0; +export const SCENES = SCENE_BARS.map(([id, bars]) => { + const s = { id, start: acc * BAR, end: (acc + bars) * BAR, bars }; + acc += bars; + return s; +}); +export const scene = id => SCENES.find(s => s.id === id); + +export const PROMPT = 'ship Prism Puddle to Google Play and the App Store'; +export const PROMPT_AT = 0.35; // seconds +export const PROMPT_CPS = 21; // the user types +export const CMD_CPS = 62; // the agent types + +export const LANGS = ['en-US', 'tr-TR', 'de-DE', 'fr-FR', 'es-ES', 'es-419', 'it-IT', 'pt-BR', 'ja-JP', 'ko-KR', 'zh-CN', 'ru-RU', 'ar', 'hi-IN']; + +// Price rows for the flicker panel: illustrative local price points for a 2.99 / 0.99 USD pair (Play converts from +// USD per region; TR is a config override, as in templates/storebound.config.ts). +export const PRICES = [ + ['US', 'USD', '2.99', '0.99'], + ['TR', 'TRY', '99.99', '34.99'], + ['DE', 'EUR', '2.99', '0.99'], + ['GB', 'GBP', '2.79', '0.89'], + ['JP', 'JPY', '450', '150'], + ['BR', 'BRL', '14.90', '4.90'], + ['IN', 'INR', '249', '79'], + ['KR', 'KRW', '4,100', '1,300'], + ['MX', 'MXN', '59.00', '19.00'], + ['ID', 'IDR', '45,000', '15,000'], + ['SA', 'SAR', '10.99', '3.69'], + ['FR', 'EUR', '2.99', '0.99'], + ['CA', 'CAD', '3.99', '1.39'], + ['AU', 'AUD', '4.49', '1.49'], +]; + +export const BLOCKERS = [ + ['apple', 'build 12 is PROCESSING'], + ['apple', 'ja: missing keywords'], + ['apple', 'remove_ads: MISSING_METADATA'], + ['apple', 'no app price schedule'], + ['play', 'tr-TR: no listing'], + ['play', 'drops_500: not on Play'], + ['play', 'no release on any track'], +]; +export const BLOCKERS_AT = 0.45; // first blocker line, relative to the validate scene +export const BLOCKER_GAP = 0.05; +export const FIX_AT = 1.05; // first flip to ok +export const FIX_GAP = 0.26; + +/** + * Terminal lines per scene. at = seconds after the scene start. + * kind: cmd (typed by the agent), out (printed), note (agent comment), ok / bad (coloured output). + */ +const T = { + prompt: [ + { at: 2.85, kind: 'note', text: 'agent using storebound · dry runs first' }, + ], + config: [ + { at: 0.0, kind: 'cmd', text: 'bunx storebound init' }, + { at: 0.45, kind: 'out', text: '[init] create storebound.config.ts' }, + { at: 0.55, kind: 'out', text: '[init] create store/listing.md' }, + { at: 0.65, kind: 'out', text: '[init] create store/appstore.md' }, + { at: 0.75, kind: 'out', text: '[init] create store/declarations.md' }, + { at: 0.85, kind: 'out', text: '[init] create store/app-privacy.md' }, + { at: 0.95, kind: 'out', text: '[init] create store/privacy-policy.html' }, + { at: 1.875, kind: 'cmd', text: 'bunx storebound check' }, + { at: 2.3, kind: 'out', text: '[check] config ok: storebound.config.ts' }, + { at: 2.42, kind: 'out', text: '[check] play listing: 14 languages' }, + { at: 2.54, kind: 'out', text: '[check] appstore listing: 14 locales' }, + { at: 2.66, kind: 'out', text: '[check] data safety: 764 CSV rows' }, + { at: 2.78, kind: 'out', text: '[check] shots copy: 14 languages x 4 scenes' }, + ], + prices: [ + { at: 0.0, kind: 'cmd', text: 'bunx storebound play products --dry' }, + { at: 0.62, kind: 'out', text: '[play] 1/2 remove_ads: create · 173 regions (dry)' }, + { at: 0.9, kind: 'out', text: '[play] 2/2 drops_500: create · 173 regions (dry)' }, + { at: 1.4, kind: 'cmd', text: 'bunx storebound apple iap --dry' }, + { at: 1.95, kind: 'out', text: '[apple] 1/2 remove_ads: missing (dry)' }, + { at: 2.07, kind: 'out', text: '[apple] 2/2 drops_500: missing (dry)' }, + ], + languages: [ + { at: 0.0, kind: 'cmd', text: 'bunx storebound play listing --dry' }, + { at: 0.6, kind: 'out', text: `[play] 14 listings: ${LANGS.slice(0, 4).join(', ')} ...` }, + ...LANGS.map((l, i) => ({ at: 0.8 + i * 0.13, kind: 'out', text: `[play] ${String(i + 1).padStart(2)}/14 ${l}` })), + ], + questionnaires: [ + { at: 0.0, kind: 'cmd', text: 'bunx storebound play data-safety --dry' }, + { at: 0.62, kind: 'out', text: '[play] data safety: 6 data types declared' }, + { at: 0.95, kind: 'cmd', text: 'bunx storebound apple appinfo --dry' }, + { at: 1.55, kind: 'out', text: '[apple] categories: GAMES / GAMES_CASUAL (dry)' }, + { at: 1.67, kind: 'out', text: '[apple] age rating declaration: all NONE (dry)' }, + { at: 1.85, kind: 'note', text: '[apple] appinfo done (App Privacy is UI-only: store-declarations skill)' }, + ], + shots: [ + { at: 0.0, kind: 'cmd', text: 'bunx storebound shots render' }, + ...['play', 'tab7', 'tab10', 'ios69', 'ios65', 'ipad13', 'feature'].flatMap((d, k) => + ['en', 'tr', 'ja', 'ar'].map((l, j) => ({ at: 0.5 + (k * 4 + j) * 0.14, kind: 'out', + text: `[shots] store/renders/${l}/${d}/${d === 'feature' ? '1024x500' : '01'}.png` }))), + ], + validate: [ + { at: 0.0, kind: 'cmd', text: 'bunx storebound validate' }, + // the blocker lines are drawn by teaser.js from BLOCKERS (they change state) + ], +}; +export const TERMINAL = T; + +/** Seconds at which each typed character lands (for key clicks in the music). */ +export function keyTimes() { + const out = []; + for (let i = 0; i < PROMPT.length; i++) out.push(PROMPT_AT + i / PROMPT_CPS); + for (const s of SCENES) for (const l of T[s.id] ?? []) { + if (l.kind !== 'cmd') continue; + for (let i = 0; i < l.text.length; i++) out.push(s.start + l.at + i / CMD_CPS); + } + return out; +} + +/** Seconds of the scene cuts that get a hit (every scene after the first). */ +export const CUTS = SCENES.slice(1).map(s => s.start); diff --git a/media/teaser/teaser.js b/media/teaser/teaser.js new file mode 100644 index 00000000..4d9b5438 --- /dev/null +++ b/media/teaser/teaser.js @@ -0,0 +1,378 @@ +// 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, 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] }, +]; +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(`
$ ${esc(l.text.slice(0, k))}${busy ? cursor : ''}
`); + } else if (l.kind === 'note') out.push(`
${fmtOut(l.text)}
`); + else out.push(`
${fmtOut(l.text)}
`); + } + if (s.id === 'validate') { + const fixed = fixedCount(r); + BLOCKERS.forEach(([store, msg], i) => { + if (r < BLOCKERS_AT + i * BLOCKER_GAP) return; + const ok = i < fixed; + out.push(`
${String(i + 1).padStart(2)}. ${ok ? 'ok ' : 'BLOCKER'} [${store}] ${esc(msg)}
`); + }); + const winAt = FIX_AT + BLOCKERS.length * FIX_GAP + 0.05; + if (r >= winAt) out.push('
[validate] no blockers
'); + if (r >= winAt + 0.2) out.push('
(UI-only steps are not visible to the API: App Privacy, Play App content)
'); + } + const last = out.length ? out[out.length - 1] : ''; + const idle = !busy && s.id !== 'prompt' && (blink || r < 0.05); + const html = out.join('') + (idle && !last.includes('cur') ? `
${cursor}
` : ''); + // visible height: up to the panel when one is shown + const panel = PANEL_FOR[s.id]; + const body = linesEl.parentElement; + const top = term.offsetTop + body.offsetTop + linesEl.offsetTop; + const bottom = panel && r > 0.4 ? panelTop(panel) - 14 : term.offsetTop + term.offsetHeight - 22; + const lh = parseFloat(getComputedStyle(linesEl).lineHeight) || 40; + linesEl.style.height = `${Math.max(lh, Math.floor((bottom - top) / lh) * lh)}px`; + if (html !== lastLines) { linesEl.innerHTML = html; lastLines = html; } + linesEl.scrollTop = linesEl.scrollHeight; +} +function panelTop(sel) { + panelTopCache ??= {}; + if (panelTopCache[sel] === undefined) { + const el = $(sel); + panelTopCache[sel] = parseFloat(getComputedStyle(el).top); + } + return panelTopCache[sel]; +} + +// ---------- panels ---------- +const pricesEl = $('#prices'), langsEl = $('#langs'), questEl = $('#quest'); +langsEl.querySelector('.chips').innerHTML = LANGS.map(l => `${l}`).join(''); +const chips = [...langsEl.querySelectorAll('.chip')]; +const QUEST = [ + ['Play Data safety', 'the whole form, from the config', 'api'], + ['App Store age rating', 'categories, content rights too', 'api'], + ['Export compliance', 'your answer, set once in the config', 'api'], + ['Play content rating (IARC)', 'the skill walks your agent through it', 'ui'], + ['App Privacy labels + Publish', 'the skill walks your agent through it', 'ui'], + ['The answers themselves', 'your statements · the agent asks', 'you'], +]; +const ICON = { + api: '', + ui: '', + you: '', +}; +const BG = { api: 'var(--api-bg)', ui: 'var(--ui-bg)', you: 'var(--you-bg)' }; +questEl.querySelector('.rows').innerHTML = QUEST.map(([nm, ds, k]) => + `
${ICON[k]}
${esc(nm)}
${esc(ds)}
${k.toUpperCase()}
`).join(''); +const qrows = [...questEl.querySelectorAll('.row')]; +const tbody = pricesEl.querySelector('tbody'), psum = pricesEl.querySelector('.sum'); +let lastPrices = ''; + +function panelIn(el, r, at) { + const p = prog(r, at, 0.32); + el.style.opacity = String(clamp(p * 2)); + el.style.transform = `translateY(${(1 - eob(p)) * 90}px) scale(${0.96 + 0.04 * eoc(p)})`; +} +function panels(t) { + const s = sceneAt(t), r = t - s.start; + for (const el of [pricesEl, langsEl, questEl]) el.style.opacity = '0'; + if (s.id === 'prices') { + panelIn(pricesEl, r, 0.45); + const flick = r < 3.05; + const k = flick ? Math.max(0, Math.floor((r - 0.7) / 0.085)) : 0; + const rows = Array.from({ length: 5 }, (_, i) => PRICES[(k + i) % PRICES.length]); + const html = rows.map(([reg, cur, a, b], i) => + `${reg}${reg === 'TR' ? 'OVERRIDE' : ''}${cur}${a}${b}`).join(''); + if (html !== lastPrices) { tbody.innerHTML = html; lastPrices = html; } + psum.textContent = flick ? `${String(Math.min(173, Math.max(1, Math.floor((r - 0.7) * 72)))).padStart(3)} / 173 regions` : 'Play: 173 regions · App Store: equalized from the USA'; + } else if (s.id === 'languages') { + panelIn(langsEl, r, 0.45); + let n = 0; + chips.forEach((c, i) => { + const at = 0.8 + i * 0.13; + const on = r >= at; + if (on) n++; + c.classList.toggle('on', on); + const p = prog(r, at, 0.2); + c.style.transform = `scale(${on ? 1 + 0.25 * (1 - eoc(p)) : 1})`; + }); + langsEl.querySelector('.count').textContent = `${n}/14`; + } else if (s.id === 'questionnaires') { + panelIn(questEl, r, 0.3); + qrows.forEach((row, i) => { + const p = prog(r, 0.55 + i * 0.36, 0.28); + row.style.opacity = String(p); + row.style.transform = `translateX(${(1 - eob(p)) * 60}px)`; + const ico = row.querySelector('.ico'); + ico.style.transform = `scale(${p >= 1 ? 1 + 0.3 * (1 - eoc(prog(r, 0.55 + i * 0.36 + 0.28, 0.2))) : eob(p)})`; + }); + } +} + +// ---------- store art ---------- +const shotsEl = $('#shots'), sizesEl = $('#sizes'); +const FAN = ['en-01', 'en-02', 'en-03', 'en-04']; +const BIG = [['en-01', 'English'], ['tr-01', 'Türkçe'], ['ja-01', '日本語'], ['ar-01', 'العربية']]; +const SIZES = ['Play phone', '7" tablet', '10" tablet', 'iPhone 6.9"', 'iPhone 6.5"', 'iPad 13"', 'feature graphic']; +const L = V + ? { cx: 540, cy: 1040, w: 300, off: [-330, -110, 110, 330], rot: [-9, -3, 3, 9], dy: [36, 0, 0, 36], bw: 390, bcy: 1000, ly: 1318 } + : { cx: 1360, cy: 540, w: 290, off: [-330, -110, 110, 330], rot: [-9, -3, 3, 9], dy: [30, 0, 0, 30], bw: 330, bcy: 515, ly: 790 }; +const RATIO = 1920 / 1080; +shotsEl.innerHTML = FAN.map(f => `
`).join('') + + `
${BIG.map(([f]) => ``).join('')}
` + + '
'; +sizesEl.innerHTML = SIZES.map(s => `${esc(s)}`).join(''); +const fanEls = [...shotsEl.querySelectorAll('.card.fan')], bigEl = shotsEl.querySelector('.card.big'), bigImgs = [...bigEl.querySelectorAll('img')]; +const langEl = shotsEl.querySelector('.lang'), sizeEls = [...sizesEl.querySelectorAll('.sz')]; +for (const c of fanEls) { c.style.width = `${L.w}px`; c.style.height = `${L.w * RATIO}px`; } +bigEl.style.width = `${L.bw}px`; bigEl.style.height = `${L.bw * RATIO}px`; + +function place(el, cx, cy, w, h, rot, sc, op) { + el.style.transform = `translate(${cx - w / 2}px, ${cy - h / 2}px) rotate(${rot}deg) scale(${sc})`; + el.style.opacity = String(op); +} +function shots(t) { + const s = sceneAt(t), r = t - s.start; + const on = s.id === 'shots'; + shotsEl.style.display = on ? '' : 'none'; + sizesEl.style.display = on ? '' : 'none'; + if (!on) return; + const h = L.w * RATIO; + const spread = eoc(prog(r, 1.95, 0.35)); + fanEls.forEach((el, i) => { + const p = prog(r, 0.3 + i * 0.2, 0.5); + const e = eob(p); + const dir = i < 2 ? -1 : 1; + const x0 = L.cx + dir * (V ? 700 : 900), y0 = L.cy + (V ? 1100 : 800); + const fx = L.cx + L.off[i] + dir * 70 * spread, fy = L.cy + L.dy[i] + Math.sin(t * 2 + i) * 6; + place(el, lerp(x0, fx, e), lerp(y0, fy, e), L.w, h, lerp(dir * 40, L.rot[i] + dir * 4 * spread, e), 1 - 0.12 * spread, clamp(p * 3) * (1 - 0.45 * spread)); + }); + // big card cycling the hero screenshot through four languages + const bp = prog(r, 1.95, 0.42); + const bh = L.bw * RATIO; + const idx = r < 2.5 ? 0 : r < 2.95 ? 1 : r < 3.4 ? 2 : 3; + const sw = [2.5, 2.95, 3.4].map(a => 1 - Math.min(1, Math.abs(r - a) / 0.09)).reduce((a, b) => Math.max(a, b), 0); + place(bigEl, L.cx, L.bcy + (1 - eob(bp)) * 500 + Math.sin(t * 1.6) * 5, L.bw, bh, (1 - eoc(bp)) * 12, (0.7 + 0.3 * eob(bp)), clamp(bp * 3)); + bigEl.style.transform += ` scaleX(${1 - 0.18 * sw})`; + bigImgs.forEach((im, i) => { im.style.opacity = i === idx ? '1' : '0'; }); + langEl.textContent = BIG[idx][1]; + const lp = prog(r, 2.2, 0.25); + langEl.style.opacity = String(lp); + langEl.style.left = `${L.cx}px`; langEl.style.top = `${L.ly}px`; + langEl.style.transform = `translateX(-50%) scale(${(1 + 0.2 * sw) * (0.6 + 0.4 * eob(lp))})`; + // sizes + sizeEls.forEach((el, i) => { + const at = 3.75 + i * 0.16; + const p = prog(r, at, 0.22); + el.style.opacity = String(clamp(p * 3)); + el.style.transform = `translateY(${(1 - eob(p)) * 30}px) scale(${1 + 0.2 * (1 - eoc(p))})`; + el.classList.toggle('on', r >= at); + }); +} + +// ---------- 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, 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(inst, r, 1.3, 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); + 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(); +}); diff --git a/tsconfig.json b/tsconfig.json index 528846cb..c33681a3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,5 +12,5 @@ "skipLibCheck": true, "resolveJsonModule": true }, - "include": ["cli", "tests", "tools", "templates/storebound.config.ts", "examples/demo-game/storebound.config.ts", "examples/demo-game/serve.ts"] + "include": ["cli", "tests", "tools", "templates/storebound.config.ts", "examples/demo-game/storebound.config.ts", "examples/demo-game/serve.ts", "media/teaser/render.ts"] }