From 761cb11d76a62c8381a9bbe88e9c6c1ac968e36d Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 17:48:03 +0000 Subject: [PATCH] teaser v4: calm 60 s 16:9 cut, from an empty folder to ready on both stores Nine scenes of 6-7 s, one slow camera move each, soft dissolves, one plain-English caption per scene at the top (on screen at least 4 s): the stores' to-do list and one rejection mail, `init` in an empty folder, the agent prompt and `release plan` (25 steps), store text and renders in 7 sizes x 4 languages, `play products --dry` and `catalog diff`, the scan's declarations proposal with the ask-owner line, three findings with plain reasons turning green, the desktop release timeline and Store readiness "No blockers", Submit and the end card. Every CLI line is real output: tests/teaser.test.ts runs each command (store answers from tests/helpers/teaser-store-mock.ts, preloaded through bunfig.toml, never the network) and checks scene lengths, caption holds, the 55-65 s total and 16:9 only. The vertical output is gone; the web version targets 4.5 MB. Calmer music (D major pads, soft pluck, bells on scene changes). desktop.ts adds the Store readiness frame. --- media/teaser/README.md | 89 +- media/teaser/desktop.ts | 27 +- media/teaser/icons/magnifying-glass-bold.svg | 1 - media/teaser/icons/pencil-simple-bold.svg | 1 - media/teaser/index.html | 429 +++++----- media/teaser/music.js | 354 +++----- media/teaser/render.ts | 86 +- media/teaser/script.js | 398 +++++---- media/teaser/teaser.js | 851 +++++++------------ tests/helpers/teaser-store-mock.ts | 90 ++ tests/teaser.test.ts | 250 +++--- tools/site-icons.ts | 2 +- 12 files changed, 1197 insertions(+), 1381 deletions(-) delete mode 100644 media/teaser/icons/magnifying-glass-bold.svg delete mode 100644 media/teaser/icons/pencil-simple-bold.svg create mode 100644 tests/helpers/teaser-store-mock.ts diff --git a/media/teaser/README.md b/media/teaser/README.md index d6560f71..4659027b 100644 --- a/media/teaser/README.md +++ b/media/teaser/README.md @@ -1,59 +1,64 @@ -# storebound teaser (about 37 s social video) +# storebound teaser (60 s, 16:9) -A scripted motion piece, 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 and the sound design are original and -synthesized from scratch in the same browser (Web Audio `OfflineAudioContext`): no samples, no downloaded audio, -nothing to license. +A calm, scripted motion piece: from an empty folder to everything ready on both stores. Every frame is a pure function +of time, rendered from an HTML/CSS/JS timeline in headless Chrome and encoded with ffmpeg. The music and the sound +design are original and synthesized from scratch in the same browser (Web Audio `OfflineAudioContext`): no samples, +no downloaded audio, nothing to license. -| s | scene | -|---|---| -| 0.00-3.28 | hook: a generic, made-up inbox; three rejection mails stack up, then "Rejected. Again." | -| 3.28-11.25 | hard cut to black: `storebound scan` is typed; the real output: SDKs with file:line, five findings with guideline and fix, the camera on each | -| 11.25-14.06 | the re-scan after the fixes: the five reds flip green, 0 blockers | -| 14.06-16.88 | the store screenshot wall (the demo game's real renders), 200 store screenshots | -| 16.88-19.69 | the declarations proposal from the scan, Data safety answers ticking, 764 answers | -| 19.69-28.13 | the desktop app (real frames, fixture data): Portfolio across studios · release timeline, rollout filling to 20% · Checks, rejection risks turning green | -| 28.13-30.94 | CLI montage, three panels cut on the beat: `storebound api coverage` (1303 App Store Connect + 170 Google Play endpoints) · `play build --dry` plan · `console fill apple-app-privacy --dry` answers | -| 30.94-33.75 | "It never presses Submit. You do." over a Submit button | -| 33.75-36.56 | logo, storebound.dev, Open source · macOS · Windows · Linux | +One idea per scene, 6-7 s each, one slow camera move per scene, soft dissolves between scenes. Each scene has one +plain-English caption at the top, fully on screen for at least 4 s; below it, the real product. + +| s | shows | caption | +|---|---|---| +| 0-6 | the demo game's icon, "Done"; the stores' to-do list line by line; one rejection mail (Guideline 2.1) | Your app is done. The stores are not. | +| 6-12 | an empty folder; `bunx storebound init` is typed; the files it creates list in | storebound takes it from an empty folder. | +| 12-19 | the prompt "Get my app ready for both stores."; `storebound release plan 1.0.0`: 25 steps in fix order | You ask once. It plans every step. | +| 19-26 | the demo game's store text in 4 languages; its renders in 7 store sizes x 4 languages | Store text and screenshots. Every language, every size. | +| 26-33 | `play products --dry` (174 regions), then `catalog diff` (175 / 174 region prices, 0 mismatches) | In-app products on both stores, priced in 175 countries. | +| 33-40 | the scan's declarations proposal: detected answers with file:line, one "ask owner" line highlighted; 764 Data safety answers | The forms, answered from your code. It asks what it can't know. | +| 40-47 | `storebound scan`: three findings, each with a plain reason; fixed, the re-scan is clean | It catches rejections before Apple does. | +| 47-54 | the desktop app: the release timeline with both stores on one track, then Store readiness: "No blockers" | Both stores, one view. Ready for review. | +| 54-60 | "Submit for Review" with the cursor resting on it (it never clicks), then the end card: storebound.dev, Open source · CLI · Desktop app | You press Submit. That's it. | | file | what | |---|---| -| `script.js` | the timeline: 128 BPM, scenes in beats (every cut on the beat), captions, the inbox, the scan lines, the desktop camera, the sound cues | -| `desktop.ts` | the desktop scenes' frames: apps/desktop's Vite dev server in fixture mode (`VITE_FIXTURES=1`, example.com-style data), captured headlessly in dark at 1280x800 @2x with the dev markers hidden, plus `boxes.json` (cursor and callout targets) -> `out/desktop/` | +| `script.js` | the timeline: scenes in seconds, camera moves, captions, every line shown, the sound cues | +| `desktop.ts` | the desktop frames: apps/desktop's Vite dev server in fixture mode (`VITE_FIXTURES=1`, example.com-style data), captured headlessly in dark at 1280x800 @2x with the dev markers hidden, plus `boxes.json` (callout targets) -> `out/desktop/` | | `index.html` + `teaser.js` | the picture; `window.teaser.seek(t)` sets every element for time `t` | -| `music.js` | music (F minor: tense intro, silence for the typed command, the groove from Enter, a calm bar under Submit, the logo hit) and sound design: mail blips, key clicks, a whoosh into every whip / mask / zoom, a hit on every cut, ticks on findings, rising chimes on fixes | -| `render.ts` | frames at 60 fps blended to 30 fps (motion blur) -> ffmpeg (H.264 high, yuv420p), sound -> loudnorm (-14 LUFS, -1.5 dBTP), mux, posters, the 1280x720 web version | +| `music.js` | calm music (D major, one chord per scene: pads, a slow soft pluck, a quiet sub) and soft sound design: a bell and an airy swell on each scene change, key clicks, quiet ticks, chimes for the fixes | +| `render.ts` | frames at 60 fps blended to 30 fps -> ffmpeg (H.264 high, yuv420p), sound -> loudnorm (-16 LUFS, -1.5 dBTP), mux, poster, the 1280x720 web version | | `icons/` | the mouse cursor and the UI icons: Phosphor files copied unchanged by `bun tools/site-icons.ts` (no hand-written SVG; CI checks it) | -| `poster.jpg` | end card still (1920x1080, small) | -The scan text is the real `storebound scan` output of `tests/fixtures/scan/teaser` (five classic App Review -rejections) and, after the fixes, of `tests/fixtures/scan/teaser-fixed`; `tests/teaser.test.ts` runs both scans and -checks every line the video shows, the beat grid, the caption lengths (at most 7 words) and holds (at least 1.2 s), and -that every scene holds at least 2.5 s. Each fix line shows a verbatim piece of the real fix. The mail list is fictional: -no real names or addresses, no mail-app branding. The montage lines are real output too, trimmed (revision dates, -clock prefixes and the source column left out): `api coverage` in the repo, `play build --dry --version-code 12` in a -throwaway example.com Capacitor project, `console fill apple-app-privacy --dry` in `examples/demo-app`; the test runs -each command and checks every line and the endpoint counts. The desktop scenes are real frames of the app on its fixture data; -the "after" Checks frame is the same tab with the fixture's scan answering no findings. +Every CLI line in the video is real output, and `tests/teaser.test.ts` runs each command and checks every line (the +clock prefix and the "(0s)" timer left out): + +- `storebound init` in an empty temp folder. +- `storebound release plan 1.0.0`, `play products --dry` and `catalog diff` in that folder, with the stores answered by + `tests/helpers/teaser-store-mock.ts` (preloaded through a `bunfig.toml` in the folder, so the children `release plan` + starts use it too; nothing reaches the network): a brand-new app record with nothing on it for the plan and the dry + run, then the two products on both stores for the diff. Regions: the App Store's 175 storefronts, Google Play 174 + (the count Play answered in a recorded read-only run). +- `storebound scan` of `tests/fixtures/scan/teaser` (findings, declarations proposal) and of `teaser-fixed` after the + fixes, and the Data safety answer count of `storebound check`. + +The plain reasons under the findings and the callouts on the desktop frames are annotations, set apart from the CLI +text. The store text is `examples/demo-game/store/shots/copy.json`, the screenshots its real renders, the app icon its +`store/icon/icon.png`. The mail row is fictional: no real names or addresses, no mail-app branding. The test also checks +the timing: scenes 6-7 s, captions on screen at least 4 s, 55-65 s in total, 16:9 only. ## Render -Needs Bun, ffmpeg and Playwright (repo devDependency; Playwright's Chromium or an installed Google Chrome). +Needs Bun, ffmpeg, Playwright (repo devDependency; Playwright's Chromium or an installed Google Chrome) and the demo +game's store renders: ```sh -# optional, for the real screenshot wall: 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, sound, posters, web version: about 15 min -bun media/teaser/render.ts --desktop # capture the desktop app frames again (after a UI change) -bun media/teaser/render.ts --only v # vertical only (h = horizontal; the web version is made from h) -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) +bun media/teaser/render.ts > media/teaser/out/render.log 2>&1 & # master, sound, poster, web version: about 15 min +bun media/teaser/render.ts --desktop # capture the desktop app frames again (after a UI change) +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?play=1 (or ?t=12.5) ``` -Outputs (gitignored) in `media/teaser/out/`: `teaser-1080x1920.mp4` (X / TikTok / Reels), `teaser-1920x1080.mp4` -(X / YouTube), `teaser-web.mp4` (1280x720, about 3.5 MB, for the site) with `poster-web.jpg`, `-silent` variants, -`poster-*.jpg`, `music.wav`. - -The vertical layout keeps captions inside the centre 80% and the bottom ~22% free of key text for app overlays. +Outputs (gitignored) in `media/teaser/out/`: `teaser-1920x1080.mp4` (master), `teaser-web.mp4` (1280x720, about +4.5 MB) with `poster-web.jpg`, `teaser-1920x1080-silent.mp4`, `poster-1920x1080.jpg`, `music.wav`. diff --git a/media/teaser/desktop.ts b/media/teaser/desktop.ts index 1a5883c5..4fdb814d 100644 --- a/media/teaser/desktop.ts +++ b/media/teaser/desktop.ts @@ -1,14 +1,16 @@ #!/usr/bin/env bun -// Real desktop-app frames for the teaser's three desktop scenes: the Vite dev server of apps/desktop in fixture mode +// Real desktop-app frames for the teaser's desktop scene: the Vite dev server of apps/desktop in fixture mode // (VITE_FIXTURES=1: example.com-style fixture data, no Tauri, no store accounts), captured headlessly, dark theme, // with the two dev-build markers hidden (they are not in a release build). -// Writes media/teaser/out/desktop/*.jpg plus boxes.json (cursor and callout targets, as fractions of the frame). +// Writes media/teaser/out/desktop/*.jpg plus boxes.json (callout targets, as fractions of the frame). // portfolio.jpg Portfolio: every app of every studio, grouped by studio // releases.jpg Prism Puddle's release timeline, both stores rolling out at 20% // releases-empty.jpg the same frame with the rollout bars' fill and "20%" hidden (the video fills the bar) // checks.jpg the Checks tab: the "Rejection risks" card with its findings // checks-clean.jpg the same tab after the fixes: the fixture's scan answer with no findings (the app's own // "No rejection risks found" state; the fixture module is served with an empty findings list) +// ready.jpg the same tab scrolled to "Store readiness" (validate, both stores) after the fixes: the +// fixture's validate answer with no findings (the app's own "No blockers" state) // render.ts runs it when out/desktop/ is missing; run it by hand after a UI change: bun media/teaser/desktop.ts import { mkdirSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; @@ -46,8 +48,11 @@ export async function captureDesktop(): Promise { await ctx.route(/\/src\/dev\/fixtures\.ts/, async (route: any) => { const res = await route.fetch(); const src = await res.text(); - const body = src.replace(/findings:\s*SCAN_PRISM,\s*counts:\s*scanCounts\(SCAN_PRISM\)/, 'findings: [], counts: scanCounts([])'); - if (body === src) errors.push('fixtures.ts: the Prism Puddle scan entry moved (desktop.ts clean capture)'); + const scan = src.replace(/findings:\s*SCAN_PRISM,\s*counts:\s*scanCounts\(SCAN_PRISM\)/, 'findings: [], counts: scanCounts([])'); + if (scan === src) errors.push('fixtures.ts: the Prism Puddle scan entry moved (desktop.ts clean capture)'); + // ... and its store readiness report (validate) answers with no blockers and no findings + const body = scan.replace(/(["']p-prism["']:\s*\{\s*blockers:\s*)1(,\s*findings:\s*)\[[^\]]*\]/, '$10$2[]'); + if (body === scan) errors.push('fixtures.ts: the Prism Puddle validate entry moved (desktop.ts clean capture)'); await route.fulfill({ response: res, body }); }); } @@ -104,12 +109,24 @@ export async function captureDesktop(): Promise { await open(b.page, 'app:checks'); await box(b.page, 'scanClean', b.page.locator('.card').first()); await shot(b.page, 'checks-clean'); + // the store readiness card (validate) at the top of the view: "No blockers" for both stores + // (room below the last row, so the card can scroll up to the top of the view) + await b.page.addStyleTag({ content: '#content { padding-bottom: 640px !important; }' }); + const ready = b.page.locator('.card').filter({ hasText: 'Store readiness' }).first(); + await ready.evaluate((el: HTMLElement) => { + el.scrollIntoView({ block: 'start' }); + document.getElementById('content')?.scrollBy({ top: -120 }); + }); + await b.page.waitForTimeout(300); + await box(b.page, 'ready', ready); + await box(b.page, 'readyEmpty', ready.locator('.empty, [class*=empty]').first()); + await shot(b.page, 'ready'); await b.ctx.close(); writeFileSync(join(OUT, 'boxes.json'), `${JSON.stringify(boxes, null, 1)}\n`); await browser.close(); if (errors.length) throw new Error(`page errors:\n ${[...new Set(errors)].join('\n ')}`); - log(`5 frames + boxes.json -> ${OUT}`); + log(`6 frames + boxes.json -> ${OUT}`); } finally { vite.kill(); } diff --git a/media/teaser/icons/magnifying-glass-bold.svg b/media/teaser/icons/magnifying-glass-bold.svg deleted file mode 100644 index 0a90a2fb..00000000 --- a/media/teaser/icons/magnifying-glass-bold.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/media/teaser/icons/pencil-simple-bold.svg b/media/teaser/icons/pencil-simple-bold.svg deleted file mode 100644 index 83e2db01..00000000 --- a/media/teaser/icons/pencil-simple-bold.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/media/teaser/index.html b/media/teaser/index.html index 4af6e479..d341d714 100644 --- a/media/teaser/index.html +++ b/media/teaser/index.html @@ -6,13 +6,12 @@ storebound teaser
-
+
-
-
Inbox3
-
Flagged
Sent
Drafts
Archive
-
-
-

Inbox

0 new -
-
-
-
- -
- -
-
-
-
5
rejection risks
+
Done
+
Still to do on the stores
+
-
-
0 store screenshots
-
$ storebound shots render
-
+
+
empty folder
+
Terminal
+
-
-
storebound scandeclarations proposal
+
+
You, to your agent
+
Terminalread-only
+
+
+ +
+
+
+
+
$
+
+ +
+
TerminalApp Store Connect · Google Play
+
+
+ +
+
storebound scandeclarations proposal
Data safetyGoogle Play
-
0 answers
-
- -
-
-
- -
- -
-
Submit for Review
-
- -
- -
storebound
-
storebound.dev
-
Open source · macOS · Windows · Linux
+
+
+
Terminal
+
+ +
+ +
+
Submit for Review
+
+ +
storebound
+
+
+
+
+ +
-
-
-
diff --git a/media/teaser/music.js b/media/teaser/music.js index dc4c986b..59fe7661 100644 --- a/media/teaser/music.js +++ b/media/teaser/music.js @@ -1,10 +1,10 @@ -// Original teaser music and sound design, synthesized from nothing with the Web Audio API (OfflineAudioContext): no -// samples, no downloaded audio. 128 BPM, F minor: a tense intro under the inbox, a hard cut to near silence for the -// typed command, the groove from the Enter key on, a calm bar under the Submit button, the hit on the logo. On top: -// mail blips, key clicks, a whoosh into every whip / mask / zoom and a hit on every cut (script.js CUTS), ticks on -// every finding, rising chimes on every fix, ticks for the screenshot wall and the Data safety rows. Deterministic. +// Original teaser music and sound design (v4, calm), synthesized from nothing with the Web Audio API +// (OfflineAudioContext): no samples, no downloaded audio. D major, one chord per scene: warm pads that cross-fade on the +// scene changes, a slow, soft plucked arpeggio, a quiet sub, and only soft accents on the scene changes (a bell and a +// short airy swell into each one). On top, quiet UI sounds from script.js: key clicks for typed text, ticks for lines +// and rows, a low tone per finding, rising chimes for the fixes, a warm swell under the end card. Deterministic. // renderWav() returns a 32-bit float stereo WAV (48 kHz) as base64; render.ts masters it with ffmpeg loudnorm. -import { B, BAR, BEAT, CUTS, DESKTOP, DURATION, ENTER_AT, keyTimes, scene, TICKS } from './script.js'; +import { CUTS, DURATION, keyTimes, SCENES, scene, SUBMIT, ticks } from './script.js'; const SR = 48000; const midi = m => 440 * Math.pow(2, (m - 69) / 12); @@ -13,270 +13,138 @@ function rng(seed) { // mulberry32 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]] }; -// 20 bars (the video ends half way into the last): hook (0-1) · command + scan (1-5) · fixed, shots, decl (6-10) · -// desktop (10-14) · the CLI montage (15-16) · submit (16-17) · brand (18-19) -const BARS = ['Fm', 'Db', 'Fm', 'Db', 'Ab', 'Eb', 'Fm', 'Db', 'Ab', 'Eb', 'Fm', 'Db', 'Ab', 'Eb', 'Fm', 'Ab', 'Db', 'Eb', 'Fm', 'Fm']; -const ARP = [0, 2, 4, 3, 5, 4, 2, 3, 0, 2, 4, 6, 5, 4, 3, 2]; +// chords (root midi in octave 3, intervals): one per scene, in scene order +const CH = { + Bm: [47, [0, 3, 7, 14]], G: [43, [0, 4, 7, 14]], D: [50, [0, 4, 7, 11]], A: [45, [0, 4, 7, 14]], Em: [52, [0, 3, 7, 10]], Dadd9: [50, [0, 4, 7, 14]], +}; +const SCENE_CHORD = { hook: 'Bm', init: 'G', plan: 'D', store: 'A', products: 'Bm', forms: 'G', rejections: 'Em', desktop: 'A', submit: 'D' }; +const ARP = [0, 1, 2, 3, 2, 1, 2, 3]; +const STEP = 0.5; // one soft note every half second export async function renderMusic() { - const ctx = new OfflineAudioContext({ numberOfChannels: 2, length: Math.ceil(DURATION * SR) + SR, sampleRate: SR }); - const R = rng(20261010); + const ctx = new OfflineAudioContext({ numberOfChannels: 2, length: Math.ceil(DURATION * SR) + SR * 2, sampleRate: SR }); + const R = rng(20261012); - // 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; } + const ir = ctx.createBuffer(2, Math.floor(SR * 3.2), 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.6); } - // 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 + // buses: a gentle compressor, a long room 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; + comp.threshold.value = -18; comp.knee.value = 10; comp.ratio.value = 2.5; comp.attack.value = 0.02; comp.release.value = 0.4; 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 verbIn = ctx.createGain(); verbIn.gain.value = 0.55; verbIn.connect(verb); verb.connect(master); + const sfx = ctx.createGain(); sfx.gain.value = 0.7; sfx.connect(master); + const sfxVerb = ctx.createGain(); sfxVerb.gain.value = 0.3; sfxVerb.connect(verbIn); - 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 under the inbox, open from the Enter key, wide into the Submit card, dark under it, bright on the logo - const f = arpLP.frequency; - const sub = scene('submit').start, brand = scene('brand').start; - f.setValueAtTime(380, 0); - f.exponentialRampToValueAtTime(900, B(7) - 0.01); - f.setValueAtTime(2600, ENTER_AT); - f.linearRampToValueAtTime(3400, sub - BAR); - f.exponentialRampToValueAtTime(7000, sub - 0.01); - f.setValueAtTime(900, sub); - f.exponentialRampToValueAtTime(1800, brand - 0.01); - f.setValueAtTime(4200, brand); - f.exponentialRampToValueAtTime(900, DURATION); - - const env = (g, t, a, peak, d, end = 0.0005) => { + const env = (g, t, a, peak, d, end = 0.0003) => { 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; }; - // sound effects bus (balanced under the music, before the master compressor) - const sfx = ctx.createGain(); sfx.gain.value = 0.85; sfx.connect(master); - const sfxVerb = ctx.createGain(); sfxVerb.gain.value = 0.35; sfxVerb.connect(verbIn); - function blip(t, m, g, len = 0.18, type = 'sine', pan = 0) { + /** A warm pad: detuned saws through a soft low-pass, slow attack and release (cross-fades with the next one). */ + function pad(t0, t1, notes, g = 0.035, cutoff = 1100) { + const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.value = cutoff; lp.Q.value = 0.5; + const v = ctx.createGain(); + v.gain.setValueAtTime(0, t0); v.gain.linearRampToValueAtTime(g, t0 + 1.2); v.gain.setValueAtTime(g, t1 - 0.2); v.gain.linearRampToValueAtTime(0, t1 + 1.0); + lp.connect(v); v.connect(master); + const s = ctx.createGain(); s.gain.value = 0.7; v.connect(s); s.connect(verbIn); + for (const m of notes) for (const det of [-7, 7]) { + 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.35 : 0.35; + o.connect(p); p.connect(lp); o.start(t0); o.stop(t1 + 1.1); + } + } + /** A soft pluck (sine + a little triangle), the arpeggio voice. */ + function pluck(t, m, g = 0.05, pan = 0) { + const v = ctx.createGain(); env(v, t, 0.006, g, 1.1); + const p = ctx.createStereoPanner(); p.pan.value = pan; + v.connect(p); p.connect(master); + const s = ctx.createGain(); s.gain.value = 0.6; p.connect(s); s.connect(verbIn); + for (const [type, k, mul] of [['sine', 1, 1], ['triangle', 2, 0.18]]) { + const o = ctx.createOscillator(); o.type = type; o.frequency.value = midi(m) * k; + const og = ctx.createGain(); og.gain.value = mul; o.connect(og); og.connect(v); o.start(t); o.stop(t + 1.3); + } + } + /** A quiet sub under each scene. */ + function sub(t0, t1, m, g = 0.07) { + const o = ctx.createOscillator(); o.type = 'sine'; o.frequency.value = midi(m - 12); + const v = ctx.createGain(); v.gain.setValueAtTime(0, t0); v.gain.linearRampToValueAtTime(g, t0 + 0.8); v.gain.setValueAtTime(g, t1 - 0.3); v.gain.linearRampToValueAtTime(0, t1 + 0.4); + o.connect(v); v.connect(master); o.start(t0); o.stop(t1 + 0.5); + } + /** The soft accent on a scene change: a bell an octave or two up, with a long tail. */ + function bell(t, m, g = 0.05, pan = 0) { + const p = ctx.createStereoPanner(); p.pan.value = pan; p.connect(sfx); p.connect(sfxVerb); + for (const [k, mul, d] of [[1, 1, 2.2], [2.01, 0.25, 1.2], [3.0, 0.08, 0.7]]) { + const o = ctx.createOscillator(); o.type = 'sine'; o.frequency.value = midi(m) * k; + const v = ctx.createGain(); env(v, t, 0.004, g * mul, d); o.connect(v); v.connect(p); o.start(t); o.stop(t + d + 0.1); + } + } + /** A short airy swell into a scene change (very quiet). */ + function swell(t, dur = 0.9, g = 0.03) { + const n = noiseSrc(t - dur, dur + 0.1); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.Q.value = 0.8; + bp.frequency.setValueAtTime(600, t - dur); bp.frequency.exponentialRampToValueAtTime(3200, t); + const v = ctx.createGain(); v.gain.setValueAtTime(0.0001, t - dur); v.gain.exponentialRampToValueAtTime(g, t - 0.05); v.gain.linearRampToValueAtTime(0, t + 0.1); + n.connect(bp); bp.connect(v); v.connect(sfx); v.connect(sfxVerb); + } + function tone(t, m, g, len = 0.25, type = 'sine', pan = 0) { const o = ctx.createOscillator(); o.type = type; o.frequency.value = midi(m); const p = ctx.createStereoPanner(); p.pan.value = pan; - const v = ctx.createGain(); env(v, t, 0.003, g, len); o.connect(v); v.connect(p); p.connect(sfx); p.connect(sfxVerb); + const v = ctx.createGain(); env(v, t, 0.004, g, len); o.connect(v); v.connect(p); p.connect(sfx); p.connect(sfxVerb); o.start(t); o.stop(t + len + 0.05); } - /** A mail arriving: a soft two-tone notification blip and a short swish. */ - function mail(t) { blip(t, 84, 0.12, 0.16); blip(t + 0.075, 91, 0.1, 0.3); whoosh(t - 0.12, 0.14, 0.08, 1200, 6000); } - /** A finding landing: a low, slightly sour thud with a click on top. */ - function bad(t) { - blip(t, 41, 0.3, 0.28, 'triangle'); blip(t, 47, 0.12, 0.2, 'square'); - const n = noiseSrc(t, 0.03); const hp = ctx.createBiquadFilter(); hp.type = 'highpass'; hp.frequency.value = 2500; - const v = ctx.createGain(); env(v, t, 0.001, 0.25, 0.03); n.connect(hp); hp.connect(v); v.connect(sfx); + function tick(t, g = 0.03, f0 = 3000) { + const n = noiseSrc(t, 0.015); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = f0; bp.Q.value = 3; + const v = ctx.createGain(); env(v, t, 0.0006, g, 0.014); n.connect(bp); bp.connect(v); v.connect(sfx); } - /** A fix: rising bell chimes (Ab major pentatonic), the fifth one brighter. */ - const GOOD = [68, 70, 72, 75, 80]; - function good(t, i) { blip(t, GOOD[i], 0.13, 0.5, 'sine', -0.3 + i * 0.15); blip(t, GOOD[i] + 12, 0.05, 0.35, 'triangle', 0.2); if (i === 4) { blip(t + 0.09, 84, 0.1, 0.8); blip(t + 0.09, 87, 0.07, 0.8); } } - /** A small UI pop (callouts). */ - function pop(t) { const o = ctx.createOscillator(); o.type = 'sine'; o.frequency.setValueAtTime(520, t); o.frequency.exponentialRampToValueAtTime(1300, t + 0.07); - const v = ctx.createGain(); env(v, t, 0.002, 0.14, 0.09); o.connect(v); v.connect(sfx); o.start(t); o.stop(t + 0.15); } - /** A tick (screenshot tiles, checkboxes). */ - function tick(t, g = 0.08, f0 = 3200) { const n = noiseSrc(t, 0.015); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = f0; bp.Q.value = 4; - const v = ctx.createGain(); env(v, t, 0.0006, g, 0.012); n.connect(bp); bp.connect(v); v.connect(sfx); } - /** A mouse click. */ - function click(t) { tick(t, 0.22, 2400); tick(t + 0.055, 0.12, 1800); } - /** A sub drop for the hard cut. */ - function thud(t, g = 0.7) { const o = ctx.createOscillator(); o.type = 'sine'; o.frequency.setValueAtTime(70, t); o.frequency.exponentialRampToValueAtTime(30, t + 0.6); - const v = ctx.createGain(); env(v, t, 0.004, g, 0.7); o.connect(v); v.connect(master); o.start(t); o.stop(t + 0.8); } - - // ---- 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); + function key(t) { + const n = noiseSrc(t, 0.02); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = 2400 + R() * 1800; bp.Q.value = 2.5; + const p = ctx.createStereoPanner(); p.pan.value = R() * 0.4 - 0.2; + const v = ctx.createGain(); env(v, t, 0.0008, 0.05 * (0.7 + R() * 0.6), 0.016); n.connect(bp); bp.connect(v); v.connect(p); p.connect(sfx); } - // ---- arrangement ---- - const cut = scene('scan').start; // the hook's hard cut to black - const drop = ENTER_AT; // the Enter key: the groove starts - const roll = sub - BAR; // the bar before the Submit card - const music = ctx.createGain(); music.gain.value = 1; // the arrangement's gain: silent for the typed command - duck.disconnect(); duck.connect(music); drums.disconnect(); drums.connect(music); music.connect(master); - music.gain.setValueAtTime(1, 0); music.gain.setValueAtTime(1, cut - 0.01); music.gain.linearRampToValueAtTime(0.0, cut + 0.005); - music.gain.setValueAtTime(0.0, drop - 0.02); music.gain.linearRampToValueAtTime(1, drop); - duck.gain.setValueAtTime(1, 0); - const last = BARS.length - 1; - for (let b = 0; b <= last; 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 calmBar = t0 >= sub && t0 < brand, end = b === last, intro = t0 < cut; - if (!end) pad(t0, BAR, [root, root + iv[1], root + iv[2], root + 12], calmBar ? 0.06 : intro ? 0.05 : 0.035, calmBar ? 1100 : intro ? 900 : 1500); - else pad(t0, BAR * 0.9, [root, root + iv[1], root + iv[2], root + 12], 0.05, 1600); - for (let s = 0; s < 16; s++) { - const t = t0 + s * BEAT / 4; - const beat = s % 4 === 0, off = s % 4 === 2, calm = t >= sub && t < brand; - const groove = t >= drop - 0.001 && t < sub && !(t >= roll + BAR / 2); - if (!end) { - if (calm) { if (s % 2 === 0) arpNote(t, tones[ARP[s]] ?? root, 0.08, 0.3); } - else if (t < cut) arpNote(t, tones[ARP[s]] ?? root, 0.07, 0.14); - else if (t >= drop) arpNote(t, tones[ARP[s]] ?? root, 0.1, 0.16); - } - if (intro && s % 2 === 0) hat(t, s % 4 === 0 ? 0.05 : 0.025, 0.1); - if (intro && beat) { const o = ctx.createOscillator(); o.type = 'sine'; o.frequency.setValueAtTime(58, t); o.frequency.exponentialRampToValueAtTime(40, t + 0.2); - const v = ctx.createGain(); env(v, t, 0.004, 0.35, 0.3); o.connect(v); v.connect(drums); o.start(t); o.stop(t + 0.4); } - if (groove) { - if (beat) kick(t); - if (off) { hat(t, 0.13, 0.2); bass(t, root - 12); } else if (!beat) hat(t, 0.04, -0.2); - if (t >= drop + BAR && (s === 4 || s === 12)) clap(t, 0.32); - } - if (calm && off) hat(t, 0.045, 0.15); + // ---- the bed: one chord per scene ---- + SCENES.forEach((s, i) => { + const [root, iv] = CH[SCENE_CHORD[s.id]]; + const last = i === SCENES.length - 1; + const t0 = Math.max(0, s.start - 0.4), t1 = last ? DURATION + 0.6 : s.end; + const notes = [root, root + iv[1], root + iv[2], root + 12]; + pad(t0, last ? scene('submit').start + SUBMIT.logoAt : t1, notes, s.id === 'hook' ? 0.03 : 0.034, s.id === 'hook' ? 800 : 1100); + sub(t0, t1, root, s.id === 'hook' ? 0.05 : 0.065); + // the arpeggio: quiet under the hook, then a steady, soft pulse + const tones = iv.map(x => root + 12 + x).concat(iv.map(x => root + 24 + x)); + for (let t = Math.max(0.5, s.start), k = 0; t < (last ? s.start + SUBMIT.logoAt : s.end) - 0.05; t += STEP, k++) { + const m = tones[ARP[k % ARP.length] + (k % 16 >= 8 ? 1 : 0)] ?? tones[0]; + pluck(t, m, s.id === 'hook' ? 0.028 : 0.04, (k % 2 ? 0.25 : -0.25)); } - } - // snare roll + riser into the Submit card - for (let i = 0; i < 8; i++) snare(roll + i * BEAT / 4, 0.04 + 0.09 * i / 7); - for (let i = 0; i < 16; i++) snare(roll + BAR / 2 + i * BEAT / 8, 0.12 + 0.16 * i / 15); - riser(roll, BAR, 0.06); - riser(brand - BAR / 2, BAR / 2, 0.045); + }); + // the end card: a warm, open chord swell and one bell + const end = scene('submit').start + SUBMIT.logoAt; + const [er, eiv] = CH.Dadd9; + pad(end - 0.3, DURATION + 0.6, [er - 12, er, er + eiv[1], er + eiv[2], er + eiv[3]], 0.045, 1500); + bell(end + 0.2, er + 24, 0.06); + bell(end + 0.55, er + 24 + 7, 0.04, 0.2); - // ---- sound design on the cuts ---- - // the hook: mails, then the two slams; the hard cut drops to silence with a sub thud - for (const t of TICKS.filter(x => x.kind === 'mail').map(x => x.t)) mail(t); - impact(B(3), true); stab(B(3), 'Db', 0.07); snare(B(3), 0.3); - impact(B(4), true); stab(B(4), 'Fm', 0.09); kick(B(4), 1); clap(B(4), 0.4); - riser(B(5), B(2) - 0.02, 0.035); - thud(cut, 0.55); - // the Enter key - click(drop - 0.01); impact(drop, true); stab(drop, 'Fm', 0.07); - // every later cut: a whoosh into it and a hit on it + // ---- soft accents on the scene changes ---- for (const c of CUTS) { - if (c.kind === 'hard' || c.t === drop) continue; - const big = c.id === 'submit' || c.id === 'brand'; - if (c.kind.startsWith('whip')) whoosh(c.t - 0.3, 0.32, 0.2, 700, 7500); - else if (c.kind === 'iris' || c.kind === 'wipe') whoosh(c.t - 0.22, 0.42, 0.14, 300, 3500); - else if (c.kind === 'zoom') whoosh(c.t - 0.36, 0.36, 0.22, 400, 9000); - impact(c.t, big); + const [root, iv] = CH[SCENE_CHORD[c.id]]; + swell(c.t, 0.9, 0.025); + bell(c.t + 0.02, root + 24 + iv[2], 0.045, (c.t * 7) % 2 - 1 > 0 ? 0.15 : -0.15); } - stab(sub, 'Db', 0.09); - stab(brand, 'Fm', 0.1); kick(brand, 1); - // ticks: SDKs and the risks line (soft), findings (bad), fixes (good), callouts (pop) - for (const x of TICKS) { - if (x.kind === 'soft') tick(x.t, 0.12, 2600); - else if (x.kind === 'bad') bad(x.t); - else if (x.kind === 'good') good(x.t, x.step); - else if (x.kind === 'pop') pop(x.t); + + // ---- UI sounds ---- + for (const x of ticks()) { + if (x.kind === 'tiny') tick(x.t, 0.022, 2800); + else if (x.kind === 'soft') { tick(x.t, 0.03, 2400); tone(x.t, 86, 0.012, 0.18); } + else if (x.kind === 'mail') { tone(x.t, 81, 0.04, 0.2); tone(x.t + 0.09, 88, 0.035, 0.4); } + else if (x.kind === 'low') { tone(x.t, 50, 0.07, 0.5, 'triangle'); tone(x.t, 57, 0.02, 0.3); } + else if (x.kind === 'ask') { tone(x.t, 83, 0.035, 0.3); tone(x.t + 0.14, 81, 0.03, 0.45); } + else if (x.kind === 'good') { const m = [74, 78, 81][x.step] ?? 81; tone(x.t, m, 0.04, 0.6, 'sine', -0.2 + 0.2 * x.step); tone(x.t, m + 12, 0.012, 0.4); } } - // the screenshot wall (tiles pop for 1.5 s) and the Data safety rows - const shots = scene('shots').start, decl = scene('decl').start; - for (let i = 0; i < 26; i++) tick(shots + 0.14 + i * 0.058, 0.05 + 0.03 * Math.sin(i), 2800 + (i % 5) * 300); - for (let i = 0; i < 7; i++) { tick(decl + 0.95 + i * 0.16, 0.12, 2000); blip(decl + 0.95 + i * 0.16, 79 + (i % 3) * 2, 0.035, 0.08); } - // the mouse click on "Scan again" in the desktop Checks tab - click(scene('desk3').start + DESKTOP.desk3.cursor[1][0] + 0.02); - // key clicks: the typed command loud (the only sound there), the re-scan softer - for (const t of keyTimes()) key(t, t < drop ? 0.24 : 0.08); + for (const t of keyTimes()) key(t); const buf = await ctx.startRendering(); const n = Math.round(DURATION * SR); diff --git a/media/teaser/render.ts b/media/teaser/render.ts index bb2b5553..28f2ab21 100644 --- a/media/teaser/render.ts +++ b/media/teaser/render.ts @@ -1,13 +1,13 @@ #!/usr/bin/env bun -// Renders the storebound teaser: frames from index.html (Playwright, headless Chrome) piped into ffmpeg, plus the -// original music and sound design (music.js, OfflineAudioContext in the same browser), mastered to about -14 LUFS. -// Frames are captured at 60 fps and blended in pairs down to 30 fps (a 180° shutter), so fast moves get real motion blur. -// bun media/teaser/render.ts both formats, sound, posters, web version -> media/teaser/out/ -// bun media/teaser/render.ts --only v vertical only (v = 1080x1920, h = 1920x1080; the web version needs h) +// Renders the storebound teaser (16:9 only): frames from index.html (Playwright, headless Chrome) piped into ffmpeg, +// plus the original music and sound design (music.js, OfflineAudioContext in the same browser), mastered to about +// -16 LUFS. Frames are captured at 60 fps and blended in pairs down to 30 fps (a 180° shutter): slow moves stay smooth. +// bun media/teaser/render.ts master 1920x1080, sound, poster, 1280x720 web version -> media/teaser/out/ // bun media/teaser/render.ts --stills 1,9.5,30 PNG stills only (out/stills/), quick layout check // bun media/teaser/render.ts --desktop capture the desktop app frames again first (desktop.ts) -// 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). +// bun media/teaser/render.ts --serve preview server: open /index.html?play=1 (or ?t=12.5) +// Needs ffmpeg and Playwright (devDependency; Playwright's Chromium or an installed Google Chrome), and the demo game's +// store renders (examples/demo-game: `shots capture`, `shots fonts`, `shots render`, see its README). import { existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; import { launch } from '../../cli/shots/browser'; @@ -19,7 +19,10 @@ 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); +/** 16:9 only. */ +const FORMAT = { w: 1920, h: 1080 }; +/** The web version: 1280x720 H.264, two-pass to about this many bytes. */ +const WEB_BYTES = 4.5e6; const CAPTURE_FPS = 60; const log = (m: string): void => console.log(`${new Date().toISOString().slice(11, 19)} [teaser] ${m}`); @@ -30,28 +33,22 @@ function sh(cmd: string[], input?: Uint8Array): string { } const ff = (...a: string[]): string => sh(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-y', ...a]); -/** The screenshot wall: the demo game's real store renders (4 languages, two sets), or crops of docs/img/showcase.jpg. */ +/** The screenshot grid: the demo game's real store renders, the first image of every size in every language. */ function prepAssets(): void { - const dir = join(ASSETS, 'grid'); + const dir = join(ASSETS, 'shots'); rmSync(dir, { recursive: true, force: true }); mkdirSync(dir, { recursive: true }); const renders = join(ROOT, 'examples/demo-game/store/renders'); - const files: string[] = []; - for (const set of ['', 'b/']) for (const lang of ['en', 'tr', 'ja', 'ar']) for (const n of ['01', '02', '03', '04']) { - const src = join(renders, `${set}${lang}`, 'play', `${n}.png`); - if (!existsSync(src)) continue; - const name = `${set ? 'b-' : ''}${lang}-${n}.jpg`; - ff('-i', src, '-vf', 'scale=360:640:flags=lanczos', '-q:v', '3', join(dir, name)); - files.push(name); + const missing: string[] = []; + let n = 0; + for (const lang of ['en', 'tr', 'ja', 'ar']) for (const size of ['ios69', 'ios65', 'ipad13', 'play', 'tab7', 'tab10', 'feature']) { + const src = join(renders, lang, size, size === 'feature' ? '1024x500.png' : '01.png'); + if (!existsSync(src)) { missing.push(`${lang}/${size}`); continue; } + ff('-i', src, '-vf', size === 'feature' ? 'scale=600:-2:flags=lanczos' : 'scale=-2:360:flags=lanczos', '-q:v', '3', join(dir, `${lang}-${size}.jpg`)); + n++; } - if (files.length) log(`assets: ${files.length} 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'); - for (let i = 0; i < 7; i++) { const name = `show-${i}.jpg`; ff('-i', show, '-vf', `crop=263:468:${20 + i * 283}:20,scale=360:640:flags=lanczos`, '-q:v', '3', join(dir, name)); files.push(name); } - log('assets: demo renders not found, using crops of docs/img/showcase.jpg (run the demo\'s `shots render` for the real wall)'); - } - writeFileSync(join(ASSETS, 'grid.json'), `${JSON.stringify(files)}\n`); + if (missing.length) throw new Error(`demo game renders missing (${missing.slice(0, 4).join(', ')}${missing.length > 4 ? ', ...' : ''}): run its shots capture, fonts and render first (examples/demo-game/README.md)`); + log(`assets: ${n} demo game renders (examples/demo-game/store/renders)`); } function serve(): ReturnType { @@ -60,8 +57,8 @@ function serve(): ReturnType { fetch(req) { const p = decodeURIComponent(new URL(req.url).pathname).replace(/^\/+/, '') || 'index.html'; if (p.includes('..')) return new Response('no', { status: 400 }); - // the logo comes from the repo's brand/ folder (tools/brand-assets.py), not a copy - const f = Bun.file(p.startsWith('brand/') ? join(ROOT, p) : join(DIR, p)); + // the logo comes from the repo's brand/ folder (tools/brand-assets.py) and the app icon from the demo game, not copies + const f = Bun.file(p.startsWith('brand/') || p.startsWith('examples/demo-game/store/icon/') ? join(ROOT, p) : join(DIR, p)); return f.size ? new Response(f) : new Response('not found', { status: 404 }); }, }); @@ -73,17 +70,18 @@ async function main(): Promise { if (args.includes('--desktop') || !existsSync(join(OUT, 'desktop/boxes.json'))) await captureDesktop(); 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; } + if (args.includes('--serve')) { log(`preview: ${base}?play=1`); return; } const browser = await launch(ROOT, { headless: true }); try { const stills = opt('stills'); - for (const f of FORMATS) { + { + const f = FORMAT; const page = await browser.newPage({ viewport: { width: f.w, height: f.h }, deviceScaleFactor: 1 }); const errors: string[] = []; page.on('pageerror', (e: Error) => errors.push(e.message)); page.on('response', (r: any) => { if (r.status() >= 400 && !r.url().endsWith('/favicon.ico')) errors.push(`${r.status()} ${r.url()}`); }); - await page.goto(`${base}?w=${f.w}&h=${f.h}`); + await page.goto(base); await page.waitForFunction('window.teaser', null, { timeout: 30_000 }); await page.evaluate('window.teaser.ready'); const { DURATION, FPS } = await page.evaluate('({ DURATION: teaser.DURATION, FPS: teaser.FPS })') as { DURATION: number; FPS: number }; @@ -93,11 +91,11 @@ async function main(): Promise { }; 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`); + for (const t of stills.split(',').map(Number)) await Bun.write(join(OUT, 'stills', `${t.toFixed(2)}.png`), await shot(t)); + log(`${stills.split(',').length} stills in out/stills`); if (errors.length) throw new Error(`page errors:\n ${errors.join('\n ')}`); await page.close(); - continue; + return; } // 60 fps capture, then each pair of frames is averaged into one 30 fps frame (motion blur on fast moves) const frames = Math.round(DURATION * CAPTURE_FPS); @@ -112,17 +110,17 @@ async function main(): Promise { enc.stdin.write(await shot(i / CAPTURE_FPS)); if (i % 120 === 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`); + log(`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'); if (errors.length) throw new Error(`page errors:\n ${[...new Set(errors)].join('\n ')}`); 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)`); + log(`${silent} (${(statSync(silent).size / 1e6).toFixed(1)} MB)`); await page.close(); } - if (stills || args.includes('--no-audio')) return; + if (args.includes('--no-audio')) return; // music + sound design const page = await browser.newPage(); @@ -133,23 +131,23 @@ async function main(): Promise { 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.5 dBTP, then a short 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' }); + // two-pass loudnorm to -16 LUFS / -1.5 dBTP (calm music), then a short fade out + const m = Bun.spawnSync(['ffmpeg', '-hide_banner', '-i', raw, '-af', 'loudnorm=I=-16: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 - 1.2).toFixed(2)}:d=1.2,aresample=48000`, + ff('-i', raw, '-af', `loudnorm=I=-16: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 - 1.5).toFixed(2)}:d=1.5,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; + { + const silent = join(OUT, `teaser-${FORMAT.w}x${FORMAT.h}-silent.mp4`), out = join(OUT, `teaser-${FORMAT.w}x${FORMAT.h}.mp4`); + if (!existsSync(silent)) throw new Error(`${silent} missing`); 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)`); } - // web version for the site: 1280x720 H.264, about 3.5 MB (two-pass), plus its poster + // web version: 1280x720 H.264, about 4.5 MB (two-pass), plus its poster const h = join(OUT, 'teaser-1920x1080.mp4'); if (existsSync(h)) { const web = join(OUT, 'teaser-web.mp4'), pass = join(OUT, 'web-pass'); - const kbps = Math.floor((3.5e6 * 8) / dur / 1000) - 96; + const kbps = Math.floor((WEB_BYTES * 8) / dur / 1000) - 96; const common = ['-vf', 'scale=1280:720:flags=lanczos', '-c:v', 'libx264', '-profile:v', 'high', '-preset', 'slow', '-b:v', `${kbps}k`, '-maxrate', `${Math.round(kbps * 1.8)}k`, '-bufsize', `${kbps * 3}k`, '-pix_fmt', 'yuv420p', '-g', '60', '-passlogfile', pass]; ff('-i', h, ...common, '-pass', '1', '-an', '-f', 'mp4', '/dev/null'); ff('-i', h, ...common, '-pass', '2', '-c:a', 'aac', '-b:a', '96k', '-ac', '2', '-movflags', '+faststart', web); diff --git a/media/teaser/script.js b/media/teaser/script.js index 73e6c87f..beb0ffe1 100644 --- a/media/teaser/script.js +++ b/media/teaser/script.js @@ -1,207 +1,253 @@ -// Teaser timeline: the single source of truth for the picture (teaser.js) and the sound (music.js). -// Every frame is a pure function of time; every cut sits on a beat of the 128 BPM grid, and the sound effects (whoosh, -// tick, hit) are placed from the same numbers, so they land on the cuts. +// Teaser timeline (v4): the single source of truth for the picture (teaser.js) and the sound (music.js). +// One idea per scene, 6-7 s each, one slow camera move per scene, soft dissolves between scenes (no whips, no rapid +// cuts). Every scene has one plain-English caption at the top that is fully on screen for at least 4 s; the lower part +// shows the real product: CLI output and desktop-app frames. // -// The scan text is the real `storebound scan` output of tests/fixtures/scan/teaser (before) and teaser-fixed (after -// the five fixes); tests/teaser.test.ts runs the scan and checks every line shown here against it. +// Every CLI line shown here is real output; tests/teaser.test.ts runs each command and checks every line: +// init `storebound init` in an empty folder (the clock prefix left out) +// plan `storebound release plan 1.0.0` in that folder, the stores answered by tests/helpers/teaser-store-mock.ts +// (a brand-new app record: nothing on either store yet); the "-> fix" lines left out +// products `storebound play products --dry` and `storebound catalog diff` in that folder with two products added +// to the config, the same store double (before: nothing on the stores; after: both products on both) +// forms the declarations proposal of `storebound scan` (tests/fixtures/scan/teaser) and the Data safety +// answer count of `storebound check` +// rejections `storebound scan` of tests/fixtures/scan/teaser and, after the fixes, of teaser-fixed +// The store text is examples/demo-game/store/shots/copy.json, the screenshots its real renders (render.ts copies +// them), the desktop frames the app in fixture mode (desktop.ts). The plain reasons under the findings and the +// callouts are annotations, set apart from the terminal text. -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 B = n => n * BEAT; // beats -> seconds -export const BEATS = 78; // 19.5 bars -export const DURATION = B(BEATS); // 36.5625 s +/** 16:9 only: the master; render.ts also makes the 1280x720 web version from it. */ +export const FORMAT = { w: 1920, h: 1080 }; -/** Scenes in beats (start, end). Cuts: the hook's hard cut, then whips and masks on the beat. */ +/** Scenes in seconds. Each holds 6-7 s; the next one dissolves in over DISSOLVE s centred on the cut. */ export const SCENES = [ - { id: 'hook', from: 0, to: 7, in: null }, // inbox, rejection mails stack, "Rejected. Again." - { id: 'scan', from: 7, to: 24, in: 'hard' }, // black, the terminal types `storebound scan`, the output - { id: 'fixed', from: 24, to: 30, in: 'whip-left' }, // the re-scan after the fixes: reds flip green, 0 blockers - { id: 'shots', from: 30, to: 36, in: 'iris' }, // store screenshots wall - { id: 'decl', from: 36, to: 42, in: 'whip-up' }, // declarations proposal -> Data safety answers - { id: 'desk1', from: 42, to: 48, in: 'wipe' }, // desktop: Portfolio across studios - { id: 'desk2', from: 48, to: 54, in: 'whip-left' }, // desktop: release timeline, rollout to 20% - { id: 'desk3', from: 54, to: 60, in: 'whip-left' }, // desktop: Checks, rejection risks turn green - { id: 'more', from: 60, to: 66, in: 'whip-left' }, // montage: api coverage · play build --dry · console fill --dry - { id: 'submit', from: 66, to: 72, in: 'zoom' }, // "It never presses Submit. You do." - { id: 'brand', from: 72, to: 78, in: 'iris' }, // logo, storebound.dev, platforms -].map(s => ({ ...s, start: B(s.from), end: B(s.to) })); -export const scene = id => SCENES.find(s => s.id === id); -/** Transition length (seconds) per kind; the incoming scene starts at the cut, the outgoing one leaves before it. */ -export const TRANS = { hard: 0, 'whip-left': 0.34, 'whip-up': 0.34, iris: 0.42, wipe: 0.42, zoom: 0.36 }; - -/** - * Captions: one display font, at most 7 words. at / to in seconds (absolute). *word* = highlighted. - * Every caption holds at least 1.2 s (tests/teaser.test.ts). - */ -export const CAPTIONS = [ - { id: 'rejected', at: B(3), to: B(7), lines: ['*Rejected.*', 'Again.'], hl: 'red', big: true, word: [B(3), B(4)] }, - { id: 'reads', at: B(10.5), to: B(16), lines: ['It reads', 'your project.'] }, - { id: 'finds', at: B(16), to: B(24), lines: ['Finds the rejections', 'before *Apple* does.'] }, - { id: 'fixed', at: B(24), to: B(30), lines: ['Fix it.', 'Scan *again.*'], hl: 'green' }, - { id: 'shots', at: B(30), to: B(36), lines: ['*200* store screenshots.', 'One command.'] }, - { id: 'decl', at: B(36), to: B(42), lines: ['*764* answers,', 'read from your code.'] }, - { id: 'desk1', at: B(42), to: B(48), lines: ['Every app.', 'Every *studio.*'] }, - { id: 'desk2', at: B(48), to: B(54), lines: ['Both stores.', 'One *timeline.*'] }, - { id: 'desk3', at: B(54), to: B(60), lines: ['Risks turn', '*green.*'], hl: 'green' }, - { id: 'more', at: B(60), to: B(66), lines: ['Every *endpoint.*', 'Build, upload, fill the forms.'] }, - { id: 'submit', at: B(66.5), to: B(72), lines: ['It never presses *Submit.*', 'You do.'] }, + { id: 'hook', start: 0, end: 6 }, + { id: 'init', start: 6, end: 12 }, + { id: 'plan', start: 12, end: 19 }, + { id: 'store', start: 19, end: 26 }, + { id: 'products', start: 26, end: 33 }, + { id: 'forms', start: 33, end: 40 }, + { id: 'rejections', start: 40, end: 47 }, + { id: 'desktop', start: 47, end: 54 }, + { id: 'submit', start: 54, end: 60 }, ]; +export const DURATION = SCENES.at(-1).end; +export const DISSOLVE = 0.6; +export const scene = id => SCENES.find(s => s.id === id); /** - * When each caption is fully readable (every word in, before its exit), as teaser.js animates it: words pop in 0.07 s - * apart over 0.34 s (the hook's two words slam in over 0.2 s at their beats); the exit fades over the last 0.16 s - * (the hook ends on a hard cut instead). + * One slow camera move per scene, over the whole scene: from -> to, eased in and out. + * z = zoom, x / y = pan in px (applied to the scene's content, never to the caption). */ +export const CAMERA = { + hook: { from: { z: 1.0, x: 0, y: 0 }, to: { z: 1.05, x: 0, y: 6 } }, + init: { from: { z: 1.0, x: 20, y: 0 }, to: { z: 1.06, x: -40, y: 0 } }, + plan: { from: { z: 1.0, x: 0, y: 0 }, to: { z: 1.05, x: 0, y: -24 } }, + store: { from: { z: 1.02, x: 40, y: 0 }, to: { z: 1.02, x: -40, y: 0 } }, + products: { from: { z: 1.0, x: 0, y: 0 }, to: { z: 1.06, x: 0, y: -10 } }, + forms: { from: { z: 1.02, x: 30, y: 0 }, to: { z: 1.02, x: -30, y: 0 } }, + rejections: { from: { z: 1.0, x: 0, y: 0 }, to: { z: 1.05, x: 0, y: -12 } }, + desktop: { from: { z: 1.0, x: 0, y: 0 }, to: { z: 1.0, x: 0, y: 0 } }, // the push happens inside the app window + submit: { from: { z: 1.0, x: 0, y: 0 }, to: { z: 1.05, x: 0, y: 0 } }, +}; + +/** Captions: one per scene, at the top. *word* = highlighted. Lines are set as written. */ +export const CAPTIONS = [ + { id: 'hook', lines: ['Your app is done. The stores are *not.*'], hl: 'red' }, + { id: 'init', lines: ['storebound takes it from an *empty folder.*'] }, + { id: 'plan', lines: ['You ask once. It plans *every step.*'] }, + { id: 'store', lines: ['Store text and screenshots.', '*Every language, every size.*'] }, + { id: 'products', lines: ['In-app products on both stores,', 'priced in *175 countries.*'] }, + { id: 'forms', lines: ['The forms, answered from your code.', 'It asks what it *can\'t know.*'] }, + { id: 'rejections', lines: ['It catches rejections *before Apple does.*'], hl: 'green' }, + { id: 'desktop', lines: ['Both stores, one view. *Ready for review.*'] }, + { id: 'submit', lines: ['You press *Submit.* That\'s it.'] }, +]; +/** Caption fade: in over CAP_IN from CAP_DELAY after the scene starts; out over CAP_OUT, ending CAP_END before it ends. */ +export const CAP_DELAY = 0.15, CAP_IN = 0.4, CAP_OUT = 0.4, CAP_END = 0.1; +/** When each caption is fully on screen (tests: at least 4 s). */ export function captionTimes() { return CAPTIONS.map(c => { - const words = c.lines.join(' ').replace(/\*/g, ''); - const from = c.big ? c.word[c.word.length - 1] + 0.2 : c.at + 0.34 + 0.07 * (words.split(' ').length - 1); - const to = c.big ? c.to : c.to - 0.16; - return { id: c.id, words, count: words.split(' ').length, at: c.at, from, to, hold: to - from }; + const s = scene(c.id); + const at = s.start + CAP_DELAY, from = at + CAP_IN, to = s.end - CAP_END - CAP_OUT, gone = s.end - CAP_END; + return { id: c.id, text: c.lines.join(' ').replace(/\*/g, ''), at, from, to, gone, hold: to - from }; }); } -// ---------- hook: a generic, made-up inbox (no real product, no real names or addresses) ---------- -export const MAIL_SUBJECT = "There's an issue with your Prism Puddle submission"; -export const MAILS = [ - { at: B(0.5), date: 'Mon', guideline: 'Guideline 2.1 · Information Needed' }, - { at: B(1.25), date: 'Wed', guideline: 'Guideline 5.1.1(v) · Data Collection and Storage' }, - { at: B(2), date: '9:41 AM', guideline: 'Guideline 4.8 · Login Services' }, +// ---------- 1 hook: the app is done, the stores' to-do list, one rejection mail ---------- +export const APP_NAME = 'Prism Puddle'; +/** The stores' to-do list (line by line at reading speed). at = seconds into the scene. */ +export const TODO = [ + { at: 0.6, text: '2 store consoles' }, + { at: 1.25, text: 'dozens of forms' }, + { at: 1.9, text: '7 screenshot sizes × 14 languages' }, + { at: 2.6, text: 'prices in 175 countries' }, ]; -/** Earlier, unrelated mails under the rejections (generic, fictional). */ -export const OLD_MAILS = [ - { from: 'Team Calendar', subject: 'Sprint review moved to Thursday', preview: 'The demo slot is now 3 pm. Bring the build.', date: 'Sun' }, - { from: 'Build Server', subject: 'Prism Puddle 1.0 (12) uploaded', preview: 'Processing finished. The build is ready to submit.', date: 'Sat' }, - { from: 'Design', subject: 'Final icon + screenshots', preview: 'All sizes exported, see the shared folder.', date: 'Fri' }, +/** A generic, made-up inbox row (no mail-app branding, no real names or addresses): fades in over MAIL_IN from `at`, + * then holds to the cut. */ +export const MAIL_IN = 0.5; +export const MAIL = { at: 3.3, from: 'App Store Connect', date: '9:41 AM', subject: "There's an issue with your Prism Puddle submission", guideline: 'Guideline 2.1 · Information Needed' }; + +// ---------- 2 init: an empty folder, `storebound init` ---------- +export const FOLDER = 'my-app'; +export const INIT_CMD = 'bunx storebound init'; +export const INIT_TYPE_AT = 0.5, INIT_CPS = 13, INIT_OUT_AT = 2.5, INIT_STEP = 0.22; +/** Real output of `storebound init` (clock prefix left out). file = the file the line creates (the folder list). */ +export const INIT_LINES = [ + '[init] create storebound.config.ts', + '[init] create store/listing.md', + '[init] create store/appstore.md', + '[init] create store/shots/copy.json', + '[init] create store/app-privacy.md', + '[init] create store/declarations.md', + '[init] create store/privacy-policy.html', + '[init] create .storebound/credentials.json', + '[init] create .storebound/testers.csv', + '[init] .gitignore: added .storebound/', ]; -// ---------- terminal: `storebound scan` ---------- -export const CMD = 'storebound scan'; -export const TYPE_AT = B(7.6); -export const TYPE_CPS = 15; -export const ENTER_AT = B(10); - -/** Real output lines (tests/teaser.test.ts checks each against the scan of the fixture). at = seconds (absolute). */ -export const SCAN_HEAD = [ - { at: B(10.15), text: 'storebound scan · storebound.config.ts', kind: 'head' }, - { at: B(10.4), text: 'stack: iOS (native) · targets: iOS · 11 files', kind: 'dim' }, -]; -export const SDK_AT = B(11); -export const SDKS = [ - { at: B(11.5), name: 'Google AdMob', what: 'ads, tracking-capable', dep: 'CocoaPods Google-Mobile-Ads-SDK 11.10.0', where: 'Podfile.lock:2' }, - { at: B(12.25), name: 'Google Sign-In', what: 'auth', dep: 'CocoaPods GoogleSignIn 7.1.0', where: 'Podfile.lock:3' }, -]; -export const RISKS_AT = B(13.25); -export const RISKS_LINE = 'Rejection risks: 2 blocker, 3 high, 0 medium, 0 low'; -/** The five findings. fix = a verbatim fragment of the real fix (the full text is in the CLI output). */ -export const FINDINGS = [ - { at: B(14), sev: 'BLOCKER', guideline: '2.1(a)', title: 'Sign-in is required but there is no demo account for App Review', - where: 'storebound.config.ts:12', fix: 'Create a demo account that sees every feature', skill: 'review-access', short: 'Demo account for App Review' }, - { at: B(16), sev: 'BLOCKER', guideline: '5.1.1(v)', title: 'Accounts can be created but no in-app account deletion was found', - where: 'Planner/LoginView.swift:11', fix: 'Add "Delete account" in the app', skill: 'account-deletion', short: 'In-app account deletion' }, - { at: B(18), sev: 'HIGH', guideline: '4.8', title: 'Third-party login (Google / Facebook / ...) without Sign in with Apple or another equivalent login option', - where: 'Planner/LoginView.swift:9', fix: 'Offer Sign in with Apple', skill: 'review-rejections', short: 'Sign in with Apple' }, - { at: B(20), sev: 'HIGH', guideline: '3.1.1', title: 'Restorable purchases (non-consumables or subscriptions) but no Restore Purchases path was found', - where: 'storebound.config.ts:16', fix: 'Add a visible "Restore Purchases" button', skill: 'store-iap-setup', short: 'Restore Purchases' }, - { at: B(22), sev: 'HIGH', guideline: '5.1.2(i)', title: 'Tracking-capable code without App Tracking Transparency (Google AdMob, IDFA)', - where: 'Planner/Ads.swift:7', fix: 'add NSUserTrackingUsageDescription and request ATT before the SDKs start', skill: 'ads-mediation-checks', short: 'App Tracking Transparency' }, +// ---------- 3 plan: the agent prompt, `storebound release plan` ---------- +export const PROMPT = 'Get my app ready for both stores.'; +export const PROMPT_AT = 0.3, PROMPT_CPS = 26; +export const PLAN_CMD = 'storebound release plan 1.0.0'; +export const PLAN_CMD_AT = 1.9, PLAN_AT = 2.3, PLAN_STEP = 0.2; +/** Real lines of the plan (a brand-new app record on both stores); the "-> fix" lines and some steps left out. */ +export const PLAN_LINES = [ + 'Example App 1.0.0', + ' both stores (fix first):', + ' 1. CONFIG App Review needs a demo account (sign-in required) · add reviewDemoAccount to .storebound/credentials.json · review-access skill', + ' 2. CONFIG missing file: store/icon/icon.png', + ' App Store: not on the store', + ' 5. STORE 1.0.0 is not on App Store yet: upload a build (Xcode / Transporter), then create the version with its texts', + ' 6. BLOCKER no App Store version being prepared', + ' 12. BLOCKER no app price schedule', + ' Google Play: not on the store', + ' 16. STORE 1.0.0 is not on Google Play yet: upload the AAB to a testing track', + ' 20. BLOCKER no release on any track', ]; +/** Steps in the whole plan (the numbered lines of the real output). */ +export const PLAN_STEPS = 25; +export const PLAN_PILL = `*${PLAN_STEPS}* steps · both stores · in fix order`; -// ---------- fixed: the re-scan of the fixed copy (tests/fixtures/scan/teaser-fixed) ---------- -export const RESCAN_CMD = 'storebound scan'; -export const RESCAN_TYPE_AT = B(24.3); -export const FLIP_AT = [B(25.5), B(26), B(26.5), B(27), B(27.5)]; // each red row turns green -export const RESCAN_LINE = 'Rejection risks: 0 blocker, 0 high, 0 medium, 0 low'; -export const RESCAN_NONE = 'none found in the project files and config'; -export const RESCAN_LINE_AT = B(28); - -// ---------- payoff ---------- -export const SHOTS_TOTAL = 200; // examples/demo-game: 4 languages x 2 sets x 25 store images (+ 8 extra) +// ---------- 4 store: listing text in every language, screenshots in every size ---------- +/** examples/demo-game/store/shots/copy.json, the hero title per language. */ +export const COPY_FILE = 'store/shots/copy.json'; +export const COPY = [ + { lang: 'en', title: ['Catch every', 'color drop!'] }, + { lang: 'tr', title: ['Renkli damlaları', 'yakala!'] }, + { lang: 'ja', title: ['カラフルなしずくを', 'キャッチ!'] }, + { lang: 'ar', title: ['التقط كل', 'قطرة ملوّنة!'], rtl: true }, +]; +export const COPY_AT = 0.5, COPY_STEP = 0.5; +/** The demo game's renders, one column per store size (cli/shots/lib.ts SIZES), one row per language. */ +export const SHOT_SIZES = [ + { id: 'ios69', label: 'iPhone\n6.9″' }, + { id: 'ios65', label: 'iPhone\n6.5″' }, + { id: 'ipad13', label: 'iPad\n13″' }, + { id: 'play', label: 'Play\nphone' }, + { id: 'tab7', label: 'Play\n7″ tab' }, + { id: 'tab10', label: 'Play\n10″ tab' }, + { id: 'feature', label: 'Play\nfeature graphic' }, +]; +export const SHOT_LANGS = COPY.map(c => c.lang); +export const SHOTS_AT = 0.9, SHOTS_STEP = 0.38; export const SHOTS_CMD = 'storebound shots render'; -export const DECL_TOTAL = 764; // Play Data safety CSV rows built from the config (`storebound check`) -/** Real lines of the declarations proposal (scan of the teaser fixture). */ -export const DECL_LINES = [ - { area: 'Data safety', what: 'PSL_DEVICE_ID', value: 'collect: advertising, analytics, fraud', where: 'Podfile.lock:2' }, - { area: 'Data safety', what: 'PSL_APPROX_LOCATION', value: 'collect: advertising, analytics, fraud', where: 'Podfile.lock:2' }, - { area: 'Data safety', what: 'PSL_EMAIL', value: 'collect: account, functionality', where: 'Podfile.lock:3' }, - { area: 'Data safety', what: 'PSL_USER_ACCOUNT', value: 'collect: account, functionality', where: 'Podfile.lock:3' }, -]; -export const DECL_ASK = 'ask owner encryptedInTransit'; -export const DATA_SAFETY_ROWS = [ - 'Device or other IDs', 'Approximate location', 'App interactions', 'Diagnostics', 'Name', 'Email address', 'User IDs', -]; +export const SHOTS_PILL = `*${SHOT_SIZES.length}* sizes × *${COPY.length}* languages`; -// ---------- desktop: real frames (desktop.ts), camera from -> to (focus as fractions of the 1280 x 800 frame) ---------- +// ---------- 5 products: `play products --dry`, then `catalog diff` ---------- +/** Real output (clock prefix and the "(0s)" timer left out). at = seconds into the scene. */ +export const PRODUCT_LINES = [ + { at: 0.4, text: '$ storebound play products --dry', cmd: true }, + { at: 0.9, text: '[play] 1/2 com.example.app.no_ads: would create · 174 regions · 2 listings (dry)' }, + { at: 1.2, text: '[play] 2/2 com.example.app.gems_100: would create · 174 regions · 2 listings (dry)' }, + { at: 1.5, text: '[play] products checked (dry run, nothing written)' }, + { at: 2.2, text: '$ storebound catalog diff', cmd: true }, + { at: 2.7, text: 'ok [apple] com.example.app.gems_100: consumable, 175 region prices, READY_TO_SUBMIT' }, + { at: 3.0, text: 'ok [play] com.example.app.gems_100: consumable, 174 region prices, ACTIVE' }, + { at: 3.3, text: 'ok [apple] com.example.app.no_ads: non_consumable, 175 region prices, READY_TO_SUBMIT' }, + { at: 3.6, text: 'ok [play] com.example.app.no_ads: non_consumable, 174 region prices, ACTIVE' }, + { at: 4.0, text: '[catalog] 2 catalog items: 0 mismatch(es), 0 warning(s), 0 price difference(s) between the stores' }, +]; +export const PRODUCTS_PILL = { at: 4.5, text: '*175* App Store regions · *174* Google Play regions · parity *✓*' }; + +// ---------- 6 forms: the declarations proposal from the scan, then the Data safety answers ---------- +/** Real lines of the proposal (scan of the teaser fixture). */ +export const DECL_LINES = [ + { what: 'PSL_DEVICE_ID', value: 'collect: advertising, analytics, fraud', where: 'Podfile.lock:2' }, + { what: 'PSL_APPROX_LOCATION', value: 'collect: advertising, analytics, fraud', where: 'Podfile.lock:2' }, + { what: 'PSL_EMAIL', value: 'collect: account, functionality', where: 'Podfile.lock:3' }, + { what: 'PSL_USER_ACCOUNT', value: 'collect: account, functionality', where: 'Podfile.lock:3' }, +]; +export const DECL_ASK = 'ask owner encryptedInTransit: ? · all traffic over HTTPS / TLS?'; +export const DECL_AT = 0.5, DECL_STEP = 0.4, ASK_AT = 2.3; +/** Play Data safety form rows the detected answers fill (Play's own labels for the PSL_* types above and the rest). */ +export const DATA_SAFETY_ROWS = ['Device or other IDs', 'Approximate location', 'App interactions', 'Diagnostics', 'Name', 'Email address', 'User IDs']; +export const FORM_AT = 2.9, FORM_STEP = 0.2; +/** Data safety CSV rows `storebound check` builds from the config. */ +export const DECL_TOTAL = 764; +export const FORMS_PILL = { at: 4.5, text: 'Data safety answers' }; + +// ---------- 7 rejections: three findings with a plain reason each, then fixed ---------- +export const SCAN_CMD = 'storebound scan'; +export const RISKS_LINE = 'Rejection risks: 2 blocker, 3 high, 0 medium, 0 low'; +/** Three of the five findings (real text); why = a plain-English annotation, not CLI output. */ +export const FINDINGS = [ + { at: 1.1, sev: 'BLOCKER', guideline: '2.1(a)', title: 'Sign-in is required but there is no demo account for App Review', where: 'storebound.config.ts:12', + why: 'Apple rejects sign-in apps without a demo account.' }, + { at: 1.9, sev: 'BLOCKER', guideline: '5.1.1(v)', title: 'Accounts can be created but no in-app account deletion was found', where: 'Planner/LoginView.swift:11', + why: 'Apps that create accounts must let people delete them.' }, + { at: 2.7, sev: 'HIGH', guideline: '5.1.2(i)', title: 'Tracking-capable code without App Tracking Transparency (Google AdMob, IDFA)', where: 'Planner/Ads.swift:7', + why: 'Ads that track people must ask permission first.' }, +]; +/** Each finding turns green (fixed), then the re-scan of the fixed copy (tests/fixtures/scan/teaser-fixed). */ +export const FIX_AT = [4.0, 4.35, 4.7]; +export const RESCAN_AT = 5.2; +export const RESCAN_LINE = 'Rejection risks: 0 blocker, 0 high, 0 medium, 0 low'; + +// ---------- 8 desktop: the release timeline (both stores), then Store readiness: no blockers ---------- +/** Real frames (desktop.ts). The camera pushes from the timeline to the readiness card; the frames dissolve between. */ export const DESKTOP = { - desk1: { frame: 'portfolio', from: { f: [0.5, 0.5], z: 1.0 }, to: { f: [0.62, 0.52], z: 1.12 }, - cursor: [[0.6, 'off'], [1.25, 'studios']], callout: { at: 1.35, target: 'studios', text: '3 studios · 2 stores' } }, - desk2: { frame: 'releases', empty: 'releases-empty', from: { f: [0.55, 0.5], z: 1.0 }, to: { f: [0.72, 0.62], z: 1.22 }, - cursor: [[0.5, 'off'], [1.15, 'roll']], fill: [1.1, 2.0], callout: { at: 1.3, target: 'roll', text: 'Rollout · 20%' } }, - desk3: { frame: 'checks', clean: 'checks-clean', from: { f: [0.55, 0.55], z: 1.0 }, to: { f: [0.55, 0.6], z: 1.14 }, - cursor: [[0.5, 'off'], [1.0, 'scanAgain']], flip: 1.25, callout: { at: 1.55, target: 'scanClean', text: '0 rejection risks' } }, + frames: ['releases', 'ready'], + swap: [3.1, 3.8], + cam: { from: { f: [0.56, 0.42], z: 1.0 }, to: { f: [0.8, 0.4], z: 1.22 } }, + callouts: [ + { at: 1.1, until: 3.0, target: 'timeline', text: 'App Store + Google Play, one track' }, + { at: 4.3, until: 7, target: 'readyEmpty', text: 'Validate: 0 blockers on both', green: true }, + ], }; -// ---------- more: a montage of real CLI output, three panels, two cuts on the beat ---------- -/** - * Real output, trimmed (tests/teaser.test.ts runs each command and checks every line): - * api coverage in the repo; the API revision dates in parentheses are left out - * play build --dry in a throwaway Capacitor project (example.com config); the clock and "[build]" prefixes are left out - * console fill examples/demo-app; the "(dataSafety.…)" source column is left out - * at = the panel's cut (seconds, absolute); stat = the pill under the card. - */ -export const MORE = [ - { at: B(60), cmd: 'storebound api coverage', sub: 'App Store Connect · Google Play', - lines: [ - 'App Store Connect API 4.5.1: 1303 operations', - 'Google Play Android Developer API v3: 145 operations', - 'Google Play Developer Reporting API v1beta1: 25 operations', - ], - stat: { text: '*1303* App Store Connect + *170* Google Play endpoints' } }, - { at: B(62), cmd: 'storebound play build --dry --version-code 12', sub: 'plan', - lines: [ - 'capacitor: android :app:bundleRelease, versionCode 12', - "signing: the project's own signingConfig", - 'would run (in android): ./gradlew :app:bundleRelease', - 'build planned (dry run)', - ], - stat: { text: 'Dry run first. *Always.*' } }, - { at: B(64), cmd: 'storebound console fill apple-app-privacy --dry', sub: 'App Privacy', - lines: [ - '[ok] Data type: Contact Info > Email Address: Yes', - '[ok] Data type: Identifiers > User ID: Yes', - '[ok] Data type: Diagnostics > Crash Data: Yes', - '[check] Data type: Usage Data > Advertising Data: (you decide)', - ], - stat: { text: 'Fills it in. *You* press Publish.' } }, -]; -/** The two cuts inside the montage (on the beat). */ -export const MORE_CUTS = MORE.slice(1).map(p => p.at); - -// ---------- end ---------- -export const SUBMIT_HOVER = B(67.5); // the cursor stops on the button, it never clicks +// ---------- 9 submit + end card ---------- +export const SUBMIT = { hover: 1.5, logoAt: 3.0, logoIn: 0.8 }; export const URL = 'storebound.dev'; -export const PLATFORMS = 'Open source · macOS · Windows · Linux'; +export const TAGLINE = 'Open source · CLI · Desktop app'; // ---------- sound cues (music.js) ---------- -/** Every cut that gets a hit, with the kind of transition (a whoosh leads into whips, masks and zooms). */ -export const CUTS = [...SCENES.slice(1).map(s => ({ t: s.start, kind: s.in, id: s.id })), ...MORE_CUTS.map(t => ({ t, kind: 'cut', id: 'more' }))] - .sort((a, b) => a.t - b.t); -/** Ticks: mails landing, findings landing, green flips, callouts. */ -export const TICKS = [ - ...MAILS.map(m => ({ t: m.at, kind: 'mail' })), - ...SDKS.map(s => ({ t: s.at, kind: 'soft' })), - { t: RISKS_AT, kind: 'soft' }, - ...FINDINGS.map(f => ({ t: f.at, kind: 'bad' })), - ...FLIP_AT.map((t, i) => ({ t, kind: 'good', step: i })), - ...Object.entries(DESKTOP).map(([id, d]) => ({ t: scene(id).start + d.callout.at, kind: 'pop' })), - ...MORE.map(p => ({ t: p.at + 0.3, kind: 'pop' })), -]; -/** Seconds at which each typed character lands (key clicks). */ +/** Soft accents: one on every scene change. */ +export const CUTS = SCENES.slice(1).map(s => ({ t: s.start, id: s.id })); +/** Gentle ticks: list items, files, plan lines, products, form rows, findings (low), fixes (bright). */ +export function ticks() { + const at = id => scene(id).start; + return [ + ...TODO.map(x => ({ t: at('hook') + x.at, kind: 'soft' })), + { t: at('hook') + MAIL.at, kind: 'mail' }, + ...INIT_LINES.map((_, i) => ({ t: at('init') + INIT_OUT_AT + 0.2 + i * INIT_STEP, kind: 'tiny' })), + ...PLAN_LINES.map((_, i) => ({ t: at('plan') + PLAN_AT + i * PLAN_STEP, kind: 'tiny' })), + ...COPY.map((_, i) => ({ t: at('store') + COPY_AT + i * COPY_STEP, kind: 'soft' })), + ...PRODUCT_LINES.filter(l => !l.cmd).map(l => ({ t: at('products') + l.at, kind: 'tiny' })), + { t: at('products') + PRODUCTS_PILL.at, kind: 'good', step: 2 }, + ...DECL_LINES.map((_, i) => ({ t: at('forms') + DECL_AT + i * DECL_STEP, kind: 'tiny' })), + { t: at('forms') + ASK_AT, kind: 'ask' }, + ...DATA_SAFETY_ROWS.map((_, i) => ({ t: at('forms') + FORM_AT + i * FORM_STEP, kind: 'tiny' })), + ...FINDINGS.map(f => ({ t: at('rejections') + f.at, kind: 'low' })), + ...FIX_AT.map((t, i) => ({ t: at('rejections') + t, kind: 'good', step: i })), + ...DESKTOP.callouts.map(c => ({ t: at('desktop') + c.at, kind: 'soft' })), + ]; +} +/** Seconds at which each typed character lands (soft key clicks). */ export function keyTimes() { const out = []; - for (let i = 0; i < CMD.length; i++) out.push(TYPE_AT + i / TYPE_CPS); - for (let i = 0; i < RESCAN_CMD.length; i++) out.push(RESCAN_TYPE_AT + i / 24); + for (let i = 0; i < INIT_CMD.length; i++) out.push(scene('init').start + INIT_TYPE_AT + i / INIT_CPS); + for (let i = 0; i < PROMPT.length; i++) out.push(scene('plan').start + PROMPT_AT + i / PROMPT_CPS); return out; } diff --git a/media/teaser/teaser.js b/media/teaser/teaser.js index 0cb2aefb..a1457bcf 100644 --- a/media/teaser/teaser.js +++ b/media/teaser/teaser.js @@ -1,626 +1,393 @@ -// 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 { B, BEAT, CAPTIONS, captionTimes, CMD, DATA_SAFETY_ROWS, DECL_ASK, DECL_LINES, DECL_TOTAL, DESKTOP, DURATION, ENTER_AT, FINDINGS, - FLIP_AT, FPS, MAIL_SUBJECT, MAILS, MORE, MORE_CUTS, OLD_MAILS, PLATFORMS, RESCAN_CMD, RESCAN_LINE, RESCAN_LINE_AT, RESCAN_NONE, RESCAN_TYPE_AT, - RISKS_AT, RISKS_LINE, SCAN_HEAD, SCENES, SDK_AT, SDKS, SHOTS_TOTAL, SUBMIT_HOVER, TRANS, TYPE_AT, TYPE_CPS, URL, scene } from './script.js'; +// Teaser picture (v4): every element is set from the time t alone (window.teaser.seek(t)), so frames render +// deterministically, in any order. 16:9 only (1920x1080). URL: &t=12.5 holds a frame, &play=1 previews in real time. +import { APP_NAME, ASK_AT, CAMERA, CAP_DELAY, CAP_END, CAP_IN, CAP_OUT, CAPTIONS, captionTimes, COPY, COPY_AT, COPY_FILE, COPY_STEP, + DATA_SAFETY_ROWS, DECL_ASK, DECL_AT, DECL_LINES, DECL_STEP, DECL_TOTAL, DESKTOP, DISSOLVE, DURATION, FINDINGS, FIX_AT, FOLDER, + FORM_AT, FORM_STEP, FORMAT, FORMS_PILL, FPS, INIT_CMD, INIT_CPS, INIT_LINES, INIT_OUT_AT, INIT_STEP, INIT_TYPE_AT, + MAIL, MAIL_IN, PLAN_AT, PLAN_CMD, PLAN_CMD_AT, PLAN_LINES, PLAN_PILL, PLAN_STEP, PRODUCT_LINES, PRODUCTS_PILL, PROMPT, PROMPT_AT, PROMPT_CPS, + RESCAN_AT, RESCAN_LINE, RISKS_LINE, SCAN_CMD, SCENES, SHOT_LANGS, SHOT_SIZES, SHOTS_AT, SHOTS_CMD, SHOTS_PILL, SHOTS_STEP, + SUBMIT, TAGLINE, TODO, URL, 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 W = FORMAT.w, H = FORMAT.h; 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 ---------- +// ---------- helpers ---------- const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x)); const prog = (t, a, d) => (d <= 0 ? (t >= a ? 1 : 0) : clamp((t - a) / d)); const eoc = p => 1 - Math.pow(1 - p, 3); -const eoq = p => 1 - Math.pow(1 - p, 5); -const eic = p => p * p * p; const eio = p => (p < 0.5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2); -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 ess = p => p * p * (3 - 2 * p); // smoothstep: the slow camera moves const lerp = (a, b, p) => a + (b - a) * p; const esc = s => String(s).replace(/&/g, '&').replace(//g, '>'); const set = (el, k, v) => { if (el.__s?.[k] !== v) { (el.__s ??= {})[k] = v; el.style[k] = v; } }; const html = (el, v) => { if (el.__h !== v) { el.__h = v; el.innerHTML = v; } }; -const decay = (t, at, d) => (t >= at && t < at + d ? 1 - (t - at) / d : 0); - -/** Layout per format: caption band on top, content below; the bottom ~22% of the vertical frame stays calm. */ -const L = V - ? { cy: 1010, top: 520, bottom: 1490, margin: 60 } - : { cy: 675, top: 300, bottom: 1045, margin: 160 }; - -// ---------- scenes and transitions ---------- -const sceneEls = Object.fromEntries(SCENES.map(s => [s.id, $(`#s-${s.id}`)])); -const DIAG = Math.hypot(W, H); -/** Visibility, transform, clip and blur of a scene at t, from its own entry and the next scene's entry. */ -function sceneFx(i, t) { - const s = SCENES[i], next = SCENES[i + 1]; - const enter = s.in, exit = next?.in ?? null; - const lead = k => (k && k.startsWith('whip') ? 0.08 : 0); - const tail = k => (k === 'iris' || k === 'wipe' ? TRANS[k] : k && k.startsWith('whip') ? 0.08 : 0); - if (t < s.start - lead(enter) || t >= s.end + tail(exit)) return null; - let tx = 0, ty = 0, sc = 1, blur = 0, op = 1, clip = 'none', dark = 0; - // entry - if (enter === 'whip-left' || enter === 'whip-up') { - const p = prog(t, s.start - 0.08, 0.34), e = eoq(p); - if (enter === 'whip-left') tx += (1 - e) * W * 1.05; else ty += (1 - e) * H * 1.05; - blur += (1 - eoc(p)) * 26; - } else if (enter === 'iris') { - const p = prog(t, s.start, TRANS.iris); - if (p < 1) clip = `circle(${(eio(p) * DIAG * 0.55).toFixed(1)}px at 50% 50%)`; - } else if (enter === 'wipe') { - const p = prog(t, s.start, TRANS.wipe); - if (p < 1) { const sk = H * 0.35, x = lerp(-sk, W + sk, eio(p)); clip = `polygon(0 0, ${x + sk}px 0, ${x}px 100%, 0 100%)`; } - } else if (enter === 'zoom') { - const p = prog(t, s.start, TRANS.zoom); - sc *= lerp(0.8, 1, eoc(p)); op *= eoc(p); blur += (1 - p) * 12; - } - // exit - if (exit === 'whip-left' || exit === 'whip-up') { - const p = prog(t, s.end - 0.22, 0.3), e = eic(p); - if (exit === 'whip-left') tx -= e * W * 1.05; else ty -= e * H * 1.05; - blur += p * 26; - } else if (exit === 'iris' || exit === 'wipe') { - const p = prog(t, s.end - 0.1, TRANS[exit] + 0.1); - sc *= 1 + 0.07 * eio(p); dark = 0.5 * p; - } else if (exit === 'zoom') { - const p = prog(t, s.end - 0.26, 0.26); - sc *= 1 + 0.8 * eic(p); op *= 1 - eic(p); blur += eic(p) * 16; - } - return { tx, ty, sc, blur, op, clip, dark }; +/** *word* -> word (pills) */ +const bold = s => esc(s).replace(/\*([^*]+)\*/g, '$1'); +/** A gentle appear: opacity and a small rise. */ +function appear(el, t, at, d = 0.35, rise = 14) { + const p = prog(t, at, d); + set(el, 'opacity', String(eoc(p))); + set(el, 'transform', `translateY(${((1 - eoc(p)) * rise).toFixed(1)}px)`); + return p; } +function pillAt(el, t, at, base = 'translate(-50%, 0)') { + const p = prog(t, at, 0.4); + set(el, 'opacity', String(eoc(p))); + set(el, 'transform', `${base} translateY(${((1 - eoc(p)) * 16).toFixed(1)}px)`); +} + +// ---------- scenes: dissolves and one slow camera move each ---------- +const sceneEls = Object.fromEntries(SCENES.map(s => [s.id, { el: $(`#s-${s.id}`), cam: $(`#s-${s.id} > .cam`) }])); function scenes(t) { SCENES.forEach((s, i) => { - const el = sceneEls[s.id], fx = sceneFx(i, t); - if (!fx) { set(el, 'opacity', '0'); set(el, 'visibility', 'hidden'); return; } + const { el, cam } = sceneEls[s.id]; + const from = i === 0 ? -1 : s.start - DISSOLVE / 2, until = i === SCENES.length - 1 ? Infinity : s.end + DISSOLVE / 2; + if (t < from || t >= until) { set(el, 'visibility', 'hidden'); set(el, 'opacity', '0'); return; } set(el, 'visibility', 'visible'); - set(el, 'opacity', String(fx.op)); - set(el, 'transform', `translate(${fx.tx.toFixed(1)}px, ${fx.ty.toFixed(1)}px) scale(${fx.sc.toFixed(4)})`); - set(el, 'filter', [fx.blur > 0.3 ? `blur(${fx.blur.toFixed(1)}px)` : '', fx.dark > 0.01 ? `brightness(${(1 - fx.dark).toFixed(3)})` : ''].join(' ').trim() || 'none'); - set(el, 'clipPath', fx.clip); + set(el, 'opacity', String(i === 0 ? 1 : eio(prog(t, from, DISSOLVE)))); + const c = CAMERA[s.id]; + const p = ess(clamp((t - (s.start - DISSOLVE / 2)) / (s.end - s.start + DISSOLVE))); + const z = lerp(c.from.z, c.to.z, p), x = lerp(c.from.x, c.to.x, p), y = lerp(c.from.y, c.to.y, p); + set(cam, 'transform', `translate(${x.toFixed(2)}px, ${y.toFixed(2)}px) scale(${z.toFixed(5)})`); }); } const active = t => SCENES.find(s => t >= s.start && t < s.end) ?? SCENES[SCENES.length - 1]; -// ---------- background, flash ---------- -const g1 = $('#bg .g1'), g2 = $('#bg .g2'), g3 = $('#bg .g3'), grid = $('#bg .grid'), flash = $('#flash'), bg = $('#bg'); -const HITS = [ - { t: B(3), a: 0.5, c: '#ff3b3b' }, { t: B(4), a: 0.6, c: '#ff3b3b' }, { t: ENTER_AT, a: 0.5, c: '#ffffff' }, - ...SCENES.slice(2).map(s => ({ t: s.start, a: s.id === 'brand' ? 0.55 : 0.28, c: '#ffffff' })), - ...MORE_CUTS.map(t => ({ t, a: 0.28, c: '#ffffff' })), - ...FINDINGS.map(f => ({ t: f.at, a: 0.18, c: '#ff3b3b' })), -]; +// ---------- background: a slow drift ---------- +const g1 = $('#bg .g1'), g2 = $('#bg .g2'), grid = $('#bg .grid'); function background(t) { - set(bg, 'opacity', t >= scene('scan').start ? '1' : '0'); - let pulse = 0; - for (const h of HITS) pulse = Math.max(pulse, decay(t, h.t, 0.6) * h.a); - g1.style.transform = `translate(${W * 0.2 + Math.sin(t * 0.33) * 160 - 550}px, ${H * 0.3 + Math.cos(t * 0.25) * 140 - 550}px) scale(${1 + pulse * 0.3})`; - g2.style.transform = `translate(${W * 0.85 + Math.cos(t * 0.29) * 180 - 450}px, ${H * 0.75 + Math.sin(t * 0.37) * 150 - 450}px)`; - const red = t >= scene('scan').start && t < scene('fixed').start + 1.5 ? clamp((t - FINDINGS[0].at) / 1.5) * (1 - prog(t, FLIP_AT[0], 1.5)) : 0; - g3.style.background = `radial-gradient(circle, rgba(255,90,95,${(0.22 * red).toFixed(3)}), rgba(255,90,95,0) 62%)`; - g3.style.transform = `translate(${W * 0.75 - 400}px, ${H * 0.45 - 400}px)`; - grid.style.transform = `translate(${(t * 20) % 96}px, ${(t * 28) % 96}px)`; - let f = 0, c = '#fff'; - for (const h of HITS) { const v = decay(t, h.t, 0.18) * h.a; if (v > f) { f = v; c = h.c; } } - set(flash, 'opacity', f.toFixed(3)); - set(flash, 'background', c); + set(g1, 'transform', `translate(${(W * 0.25 + Math.sin(t * 0.11) * 160 - 700).toFixed(1)}px, ${(H * 0.35 + Math.cos(t * 0.09) * 120 - 700).toFixed(1)}px)`); + set(g2, 'transform', `translate(${(W * 0.8 + Math.cos(t * 0.1) * 160 - 550).toFixed(1)}px, ${(H * 0.75 + Math.sin(t * 0.12) * 110 - 550).toFixed(1)}px)`); + set(grid, 'transform', `translate(${((t * 6) % 96).toFixed(2)}px, ${((t * 8) % 96).toFixed(2)}px)`); } -// ---------- captions ---------- +// ---------- caption ---------- const capEl = $('#cap'); -let capId = null, capWords = []; +const CT = Object.fromEntries(captionTimes().map(c => [c.id, c])); +let capId = null; function buildCaption(c) { - capEl.className = [c.big ? 'big' : '', c.hl ?? ''].join(' '); + capEl.className = c.hl ?? ''; capEl.style.fontSize = ''; - const one = !V && !c.big && c.lines.join(' ').length <= 30; - const lines = one ? [c.lines.join(' ')] : c.lines; - capEl.innerHTML = lines.map(l => `${l.split(' ').map(w => `${esc(w.replace(/\*/g, ''))}`).join(' ')}`).join(''); - // fit: the widest line stays inside the centre 80% (safe area) + capEl.innerHTML = c.lines.map(l => `${esc(l).replace(/\*([^*]+)\*/g, '$1')}`).join(''); const avail = capEl.clientWidth, base = parseFloat(getComputedStyle(capEl).fontSize); 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) => { - const at = c.big ? c.word[i] : c.at + capWords.length * 0.07; - capWords.push({ el: w, at }); - })); } function captions(t) { - const c = CAPTIONS.find(x => t >= x.at && t < x.to); + const s = active(t), c = CAPTIONS.find(x => x.id === s.id), ct = CT[s.id]; if (!c) { set(capEl, 'opacity', '0'); return; } if (capId !== c.id) { capId = c.id; buildCaption(c); } - const hard = c.id === 'rejected'; // the hook ends on a hard cut - const out = hard ? 0 : prog(t, c.to - 0.16, 0.16); - set(capEl, 'opacity', String(1 - out)); - let shake = 0; - for (const w of capWords) { - const p = prog(t, w.at, c.big ? 0.2 : 0.34); - if (c.big) { - shake = Math.max(shake, decay(t, w.at + 0.05, 0.3)); - set(w.el, 'opacity', String(clamp(p * 3))); - set(w.el, 'transform', `scale(${lerp(2.4, 1, eoc(p)).toFixed(3)})`); - set(w.el, 'filter', p < 1 ? `blur(${((1 - p) * 14).toFixed(1)}px)` : 'none'); - } else { - set(w.el, 'opacity', String(clamp(p * 3))); - set(w.el, 'transform', `translateY(${((1 - eob(p)) * 0.42).toFixed(3)}em) scale(${(1 + 0.25 * (1 - eoc(p))).toFixed(3)})`); - set(w.el, 'filter', p < 1 ? `blur(${((1 - eoc(p)) * 10).toFixed(1)}px)` : 'none'); - } - } - const sx = c.big ? Math.sin(t * 97) * 14 * shake : 0, sy = c.big ? Math.cos(t * 83) * 10 * shake : 0; - set(capEl, 'transform', c.big ? `translate(${sx.toFixed(1)}px, calc(-50% + ${sy.toFixed(1)}px))` : `translateY(${(-40 * eic(out)).toFixed(1)}px)`); + const pin = s === SCENES[0] && t < CAP_DELAY ? 0 : eoc(prog(t, ct.at, CAP_IN)); + const pout = s === SCENES.at(-1) ? 0 : prog(t, ct.to, CAP_OUT); + set(capEl, 'opacity', String(pin * (1 - pout))); + set(capEl, 'transform', `translateY(${((1 - pin) * 12 - pout * 8).toFixed(1)}px)`); } +// keep the constants in use (they define captionTimes, imported above for the timing test) +void CAP_DELAY; void CAP_END; -// ---------- hook: inbox ---------- -const list = $('#inbox .list'), hookCam = $('#s-hook .cam'), hookDim = $('#s-hook .dim'), unread = $('#inbox .cnt'); -const ROW_H = V ? 236 : 168; -const mailRow = (m, rej) => { - const el = document.createElement('div'); - el.className = `mrow${rej ? '' : ' old'}`; - el.innerHTML = rej - ? `App Store Connect${esc(m.date)} - ${esc(MAIL_SUBJECT)}Hello, Thank you for submitting… ${esc(m.guideline)}` - : `${esc(m.from)}${esc(m.date)} - ${esc(m.subject)}${esc(m.preview)}`; - list.appendChild(el); - return el; -}; -const oldRows = OLD_MAILS.map(m => ({ el: mailRow(m, false), at: -1 })); -const newRows = MAILS.map(m => ({ el: mailRow(m, true), at: m.at })); +// ---------- 1 hook ---------- +const todoRows = $('#todo .rows'), mailEl = $('#mail'), appcard = $('#appcard'); +$('#appcard .nm').textContent = APP_NAME; +todoRows.innerHTML = TODO.map(x => `
${esc(x.text)}
`).join(''); +const todoEls = [...todoRows.querySelectorAll('.row')]; +mailEl.querySelector('.from').textContent = MAIL.from; +mailEl.querySelector('.date').textContent = MAIL.date; +mailEl.querySelector('.subj').textContent = MAIL.subject; +mailEl.querySelector('.prev').innerHTML = `Hello, Thank you for submitting your app… ${esc(MAIL.guideline)}`; function hook(t) { - if (t >= scene('hook').end) return; - const slots = r => MAILS.filter(m => m.at > r.at).reduce((n, m) => n + eoc(prog(t, m.at, 0.3)), 0); - for (const r of [...oldRows.map((r, i) => ({ ...r, base: i })), ...newRows.map(r => ({ ...r, base: 0 }))]) { - const y = (r.base + slots(r)) * ROW_H; - if (r.at < 0) { set(r.el, 'transform', `translateY(${y.toFixed(1)}px)`); continue; } - const p = prog(t, r.at, 0.3); - set(r.el, 'opacity', String(clamp(p * 2.5))); - set(r.el, 'transform', `translateY(${(y - (1 - eoc(p)) * ROW_H * 0.7).toFixed(1)}px)`); - set(r.el, 'zIndex', String(10 + MAILS.findIndex(m => m.at === r.at))); - set(r.el.querySelector('.hi'), 'opacity', (0.95 * (1 - prog(t, r.at + 0.2, 1.0))).toFixed(3)); - } - const n = MAILS.filter(m => t >= m.at).length; - html(unread, `${n} new`); - let shake = 0; - for (const m of MAILS) shake = Math.max(shake, decay(t, m.at + 0.1, 0.22)); - const slam = eoc(prog(t, B(3), 0.2)); - const z = 1 + 0.035 * t + 0.06 * slam; - set(hookCam, 'transform', `translate(${(Math.sin(t * 90) * 7 * shake).toFixed(1)}px, ${(Math.cos(t * 70) * 5 * shake).toFixed(1)}px) scale(${z.toFixed(4)})`); - set(hookCam, 'filter', slam > 0 ? `blur(${(slam * 7).toFixed(1)}px)` : 'none'); - set(hookDim, 'opacity', (0.74 * slam).toFixed(3)); + const s = scene('hook'); if (t > s.end + 1) return; + const r = t - s.start; + appear(appcard, r, 0.1, 0.5, 20); + appear($('#todo'), r, 0.35, 0.45, 20); + todoEls.forEach((el, i) => appear(el, r, TODO[i].at, 0.4, 10)); + const p = prog(r, MAIL.at, MAIL_IN); + set(mailEl, 'opacity', String(eoc(p))); + set(mailEl, 'transform', `translateY(${((1 - eoc(p)) * 50).toFixed(1)}px)`); } -// ---------- scan: the terminal ---------- -const term = $('#term'), scanCam = $('#s-scan .cam'); -const CW = V ? 840 : 1560; -term.innerHTML = [ - '', - ' ', - ...SCAN_HEAD.map((l, i) => `${esc(l.text)}`), - ' ', - `SDKs`, - ...SDKS.map((s, i) => ` ${esc(s.name)} · ${esc(s.what)}\n ${esc(s.where)} ${esc(s.dep)}`), - ' ', - `${esc(RISKS_LINE).replace(/(2 blocker, 3 high)/, '$1')}`, - ...FINDINGS.map((f, i) => `` - + `${i + 1}. ${f.sev}${esc(f.guideline)} · App Store` - + `${esc(f.title)}` - + `at ${esc(f.where)}` - + `fix: ${f.fix.match(/^[a-z]/) ? '… ' : ''}${esc(f.fix)} …`), -].join(''); -const tl = Object.fromEntries([...term.querySelectorAll('[data-k]')].map(e => [e.dataset.k, e])); -const timed = [...term.querySelectorAll('[data-at]')].map(e => ({ el: e, at: Number(e.dataset.at), fd: e.classList.contains('fd') })); -const box = el => ({ y: el.offsetTop, h: el.offsetHeight }); -/** Camera keys: [time, element key, zoom]. The camera eases to each key over 0.42 s, starting a little before. */ -const ZF = V ? 1.14 : 1.1; -const SCAN_CAM = [ - [scene('scan').start, 'prompt', V ? 1.9 : 1.7], - [ENTER_AT, 'head0', ZF + 0.04], - [SDK_AT, 'sdk0', ZF], - [RISKS_AT, 'risks', ZF], - ...FINDINGS.map((f, i) => [f.at, `f${i}`, ZF]), -]; -let camBoxes = null; -function scanCamAt(t) { - camBoxes ??= Object.fromEntries(SCAN_CAM.map(([, k]) => [k, box(tl[k])])); - const pos = k => { const b = camBoxes[k]; return b.y + b.h / 2; }; - let y = pos(SCAN_CAM[0][1]), z = SCAN_CAM[0][2], typing = 1; - for (let i = 1; i < SCAN_CAM.length; i++) { - const [at, k, zz] = SCAN_CAM[i]; - const p = eio(prog(t, at - 0.12, 0.42)); - y = lerp(y, pos(k), p); z = lerp(z, zz, p); - if (i === 1) typing = 1 - p; - } - // while typing the command sits centred; afterwards the column is centred - const cmdW = (CMD.length + 2) * (V ? 31 : 30) * 0.6; - const sx = lerp(W / 2, (W - cmdW * z) / 2, typing), ax = lerp(CW / 2, 0, typing); - return { tx: sx - ax * z, ty: L.cy - y * z, z }; -} -function scan(t) { - const s = scene('scan'); - if (t < s.start - 0.1 || t > s.end + 0.2) return; - const n = clamp(Math.floor((t - TYPE_AT) * TYPE_CPS), 0, CMD.length); - const caret = t < ENTER_AT ? (n < CMD.length || Math.floor(t * 2.4) % 2 === 0) : false; - html(tl.prompt, `$ ${esc(CMD.slice(0, n))}${caret ? '' : ''}`); - set(tl.prompt, 'opacity', '1'); - let focus = -1; - FINDINGS.forEach((f, i) => { if (t >= f.at - 0.1) focus = i; }); - for (const l of timed) { - const p = prog(t, l.at, l.fd ? 0.28 : 0.2); - set(l.el, 'opacity', String(clamp(p * 2))); - set(l.el, 'transform', `translateX(${((1 - eoc(p)) * (l.fd ? 60 : 30)).toFixed(1)}px)`); - if (l.fd) { - const i = Number(l.el.dataset.k.slice(1)); - const g = l.el.querySelector('.glow'); - set(g, 'opacity', (i === focus ? 1 - 0.4 * prog(t, l.at + 0.3, 0.4) : 0.18 * p).toFixed(3)); - set(l.el, 'filter', i === focus || focus < 0 ? 'none' : 'brightness(.62)'); - } - } - const c = scanCamAt(t); - // a small push-in on every finding as it lands (about the focus line) - let punch = 0; - for (const f of FINDINGS) punch = Math.max(punch, Math.sin(Math.PI * prog(t, f.at - 0.05, 0.9)) * 0.035); - const k = 1 + punch; - set(scanCam, 'transform', `translate(${(c.tx * k - (W / 2) * (k - 1)).toFixed(1)}px, ${(c.ty * k - L.cy * (k - 1)).toFixed(1)}px) scale(${(c.z * k).toFixed(4)})`); -} - -// ---------- fixed: re-scan, reds flip green ---------- -const frows = $('#frows'), rescan = $('#rescan'), counter = $('#counter'), cN = $('#counter .n'), cLab = $('#counter .lab'); -const FR = V ? { x: 60, w: 960, top: 690, h: 112, gap: 18 } : { x: 150, w: 920, top: 330, h: 118, gap: 22 }; -frows.innerHTML = FINDINGS.map((f, i) => `
- - - ${esc(f.short)}${esc(f.guideline)} · ${esc(f.where)} - ${f.sev}FIXED
`).join(''); -const frowEls = [...frows.querySelectorAll('.frow')]; -if (V) Object.assign(rescan.style, { left: '60px', top: '560px', width: '960px', fontSize: '29px' }); -else Object.assign(rescan.style, { left: '1150px', top: '340px', width: '660px', fontSize: '25px' }); -rescan.innerHTML = `${esc(RESCAN_LINE)}` - + (V ? '' : ` ${esc(RESCAN_NONE)}`); -if (V) Object.assign(counter.style, { left: '0', width: '100%', top: '1340px' }); -else Object.assign(counter.style, { left: '1150px', width: '660px', top: '560px' }); -cN.style.fontSize = V ? '120px' : '230px'; cLab.style.fontSize = V ? '40px' : '50px'; -if (V) { counter.style.display = 'flex'; counter.style.justifyContent = 'center'; counter.style.alignItems = 'baseline'; counter.style.gap = '24px'; } -function fixed(t) { - const s = scene('fixed'); - if (t < s.start - 0.3 || t > s.end + 0.5) return; - const n = clamp(Math.floor((t - RESCAN_TYPE_AT) * 24), 0, RESCAN_CMD.length); - const p = rescan.querySelector('[data-k="p"]'), r = rescan.querySelector('[data-k="r"]'), none = rescan.querySelector('[data-k="n"]'); - html(p, `$ ${esc(RESCAN_CMD.slice(0, n))}${n < RESCAN_CMD.length || t < FLIP_AT[0] - 0.2 ? '' : ''}`); - set(p, 'opacity', '1'); - const rp = prog(t, RESCAN_LINE_AT, 0.25); - set(r, 'opacity', String(rp)); set(r, 'transform', `translateX(${((1 - eoc(rp)) * 30).toFixed(1)}px)`); - if (none) { const np = prog(t, RESCAN_LINE_AT + 0.15, 0.25); set(none, 'opacity', String(np)); } - let left = FINDINGS.length; - frowEls.forEach((el, i) => { - const enter = prog(t, s.start + 0.05 + i * 0.06, 0.3); - const f = prog(t, FLIP_AT[i], 0.32); - if (t >= FLIP_AT[i]) left--; - const pop = decay(t, FLIP_AT[i], 0.3); - set(el, 'opacity', String(enter)); - set(el, 'transform', `translateY(${((1 - eoc(enter)) * 40).toFixed(1)}px) scale(${(1 + 0.035 * pop).toFixed(4)})`); - set(el, 'borderColor', f > 0.5 ? 'rgba(61,220,132,.55)' : 'rgba(255,90,95,.4)'); - set(el.querySelector('.t-good'), 'opacity', String(eoc(f))); - set(el.querySelector('.t-bad'), 'opacity', String(1 - eoc(f))); - set(el.querySelector('.bad'), 'transform', `scale(${(1 - eic(f)).toFixed(3)}) rotate(${(-90 * f).toFixed(1)}deg)`); - set(el.querySelector('.good'), 'transform', `scale(${eob(f).toFixed(3)})`); - set(el.querySelector('.good'), 'opacity', String(clamp(f * 3))); - const c2 = el.querySelector('.c2'); - set(c2, 'clipPath', `inset(0 ${((1 - eoc(f)) * 100).toFixed(1)}% 0 0)`); +// ---------- 2 init ---------- +const folderEl = $('#folder'), filesEl = $('#folder .files'), emptyEl = $('#folder .empty'), initBody = $('#initterm .body'); +$('#folder .fname').textContent = `${FOLDER}/`; +/** The folder list: one entry per file `init` creates (from the real output lines). */ +const FILES = INIT_LINES.map((l, i) => ({ i, m: l.match(/^\[init\] create (.+)$/) })).filter(x => x.m).map(x => ({ i: x.i, path: x.m[1] })); +filesEl.innerHTML = FILES.map(f => { + const k = f.path.lastIndexOf('/'); + return `
${k >= 0 ? `${esc(f.path.slice(0, k + 1))}` : ''}${esc(f.path.slice(k + 1))}
`; +}).join(''); +const fileEls = [...filesEl.querySelectorAll('.f')]; +const tagged = l => esc(l).replace(/^(\[\w+\])/, '$1'); +initBody.innerHTML = `${INIT_LINES.map(l => `${tagged(l).replace(/ (create) /, ' $1 ')}`).join('')}`; +const initLns = [...initBody.querySelectorAll('.ln')]; +function init(t) { + const s = scene('init'); if (t < s.start - 1 || t > s.end + 1) return; + const r = t - s.start; + const n = clamp(Math.floor((r - INIT_TYPE_AT) * INIT_CPS), 0, INIT_CMD.length); + const caret = r < INIT_OUT_AT && (n < INIT_CMD.length || Math.floor(r * 2.2) % 2 === 0); + html(initLns[0], `~/${esc(FOLDER)} $ ${esc(INIT_CMD.slice(0, n))}${caret ? '' : ''}`); + set(initLns[0], 'opacity', '1'); + initLns.slice(1).forEach((el, i) => appear(el, r, INIT_OUT_AT + 0.2 + i * INIT_STEP, 0.25, 6)); + fileEls.forEach((el, k) => { + const p = prog(r, INIT_OUT_AT + 0.2 + FILES[k].i * INIT_STEP, 0.3); + set(el, 'opacity', String(eoc(p))); + set(el, 'transform', `translateX(${((1 - eoc(p)) * -16).toFixed(1)}px)`); }); - const zero = left === 0; - html(cN, String(left)); - html(cLab, zero ? 'blockers' : 'rejection risks'); - set(cN, 'color', zero ? 'var(--green)' : 'var(--red)'); - let pop = 0; - FLIP_AT.forEach((a, i) => { pop = Math.max(pop, decay(t, a, 0.25) * (i === 4 ? 1.6 : 1)); }); - const ce = prog(t, s.start + 0.25, 0.35); - set(counter, 'opacity', String(ce)); - set(cN, 'transform', `scale(${(1 + 0.22 * pop).toFixed(3)})`); - set(cN, 'display', 'inline-block'); - set(cN, 'textShadow', zero ? `0 0 ${(40 + 60 * pop).toFixed(0)}px rgba(61,220,132,.6)` : '0 0 40px rgba(255,90,95,.4)'); + set(emptyEl, 'opacity', String(1 - prog(r, INIT_OUT_AT + 0.1, 0.3))); + void folderEl; } -// ---------- shots: the screenshot wall ---------- -const wall = $('#wall'), shotNum = $('#shotcount .num'), shotCount = $('#shotcount'), shotCmd = $('#shotcmd'); -const GRID = await fetch('out/assets/grid.json').then(r => { if (!r.ok) throw new Error('out/assets/grid.json missing (bun media/teaser/render.ts prepares it)'); return r.json(); }); -const WALL = V ? { cols: 7, rows: 7, tw: 210, th: 373, gap: 22 } : { cols: 11, rows: 4, tw: 200, th: 356, gap: 22 }; -const tiles = []; +// ---------- 3 plan ---------- +const promptEl = $('#prompt'), promptTxt = $('#prompt .txt'), planTerm = $('#planterm'), planBody = $('#planterm .body'), planPill = $('#plan-pill'); +const planLine = l => { + if (/^\S/.test(l)) return `${esc(l)}`; + if (/^ (both stores|App Store|Google Play)/.test(l)) return `${esc(l)}`; + return esc(l).replace(/^(\s+\d+\.) (CONFIG |STORE |BLOCKER)/, (m, a, b) => `${a} ${b}`); +}; +planBody.innerHTML = `${PLAN_LINES.map(l => `${planLine(l)}`).join('')}`; +const planLns = [...planBody.querySelectorAll('.ln')]; +planPill.innerHTML = bold(PLAN_PILL); +function plan(t) { + const s = scene('plan'); if (t < s.start - 1 || t > s.end + 1) return; + const r = t - s.start; + appear(promptEl, r, 0.05, 0.35, 10); + const n = clamp(Math.floor((r - PROMPT_AT) * PROMPT_CPS), 0, PROMPT.length); + html(promptTxt, `${esc(PROMPT.slice(0, n))}${n < PROMPT.length || r < PLAN_CMD_AT ? '' : ''}`); + appear(planTerm, r, PLAN_CMD_AT - 0.35, 0.4, 16); + html(planLns[0], `$ ${esc(PLAN_CMD)}`); + appear(planLns[0], r, PLAN_CMD_AT, 0.25, 4); + planLns.slice(1).forEach((el, i) => appear(el, r, PLAN_AT + i * PLAN_STEP, 0.25, 6)); + pillAt(planPill, r, PLAN_AT + PLAN_LINES.length * PLAN_STEP + 0.15); +} + +// ---------- 4 store ---------- +const copyRows = $('#copy .rows'), shotsEl = $('#shots'), storePill = $('#store-pill'), shotCmd = $('#shotcmd'); +$('#copy .fname').textContent = COPY_FILE; +copyRows.innerHTML = COPY.map(c => `
${esc(c.lang)}${esc(c.title.join(' '))}
`).join(''); +const copyEls = [...copyRows.querySelectorAll('.row')]; +storePill.innerHTML = bold(SHOTS_PILL); +shotCmd.querySelector('.cmd').textContent = SHOTS_CMD; +/** The grid: one column per size (portrait sizes by aspect, the feature graphic last), one row per language. */ +const DIMS = { ios69: [1320, 2868], ios65: [1284, 2778], ipad13: [2064, 2752], play: [1080, 1920], tab7: [1080, 1920], tab10: [1440, 2560], feature: [1024, 500] }; +const shotTiles = [], shotLabels = [], langLabels = []; { - const ww = WALL.cols * (WALL.tw + WALL.gap), wh = WALL.rows * (WALL.th + WALL.gap); - let k = 0; - for (let r = 0; r < WALL.rows; r++) for (let c = 0; c < WALL.cols; c++) { + const LAB = 50, LANGW = 52, GAP = 14, AREA_W = 1020, AREA_H = 700; + const RH = (AREA_H - LAB - GAP * (SHOT_LANGS.length - 1)) / SHOT_LANGS.length; + const FW = 280, FH = FW * DIMS.feature[1] / DIMS.feature[0]; + const widths = SHOT_SIZES.map(sz => (sz.id === 'feature' ? FW : RH * DIMS[sz.id][0] / DIMS[sz.id][1])); + const total = LANGW + widths.reduce((a, b) => a + b, 0) + GAP * SHOT_SIZES.length; + let x = (AREA_W - total) / 2 + LANGW + GAP; + SHOT_LANGS.forEach((lang, j) => { const el = document.createElement('div'); - el.className = 'tile'; - const x = c * (WALL.tw + WALL.gap) - ww / 2 + (r % 2 ? WALL.tw * 0.25 : 0), y = r * (WALL.th + WALL.gap) - wh / 2; - Object.assign(el.style, { left: `${x}px`, top: `${y}px`, width: `${WALL.tw}px`, height: `${WALL.th}px`, backgroundImage: `url(out/assets/grid/${GRID[(k * 7) % GRID.length]})` }); - wall.appendChild(el); - const d = Math.hypot(x + WALL.tw / 2, (y + WALL.th / 2) * 0.8); - tiles.push({ el, d: d + ((k * 37) % 11) * 18 }); - k++; - } - const order = [...tiles].sort((a, b) => a.d - b.d); - order.forEach((tl2, i) => { tl2.at = 0.12 + (i / order.length) * 1.45; }); + el.className = 'lang'; el.textContent = lang; + Object.assign(el.style, { left: `${(AREA_W - total) / 2}px`, top: `${LAB + j * (RH + GAP) + RH / 2 - 10}px` }); + shotsEl.appendChild(el); langLabels.push(el); + }); + SHOT_SIZES.forEach((sz, i) => { + const w = widths[i], h = sz.id === 'feature' ? FH : RH; + const lab = document.createElement('div'); + lab.className = 'lab'; lab.textContent = sz.label; + Object.assign(lab.style, { left: `${x + w / 2}px`, top: '0px', transform: 'translateX(-50%)' }); + shotsEl.appendChild(lab); shotLabels.push({ el: lab, col: i }); + SHOT_LANGS.forEach((lang, j) => { + const el = document.createElement('div'); + el.className = 'tile'; + Object.assign(el.style, { left: `${x}px`, top: `${LAB + j * (RH + GAP) + (RH - h) / 2}px`, width: `${w}px`, height: `${h}px`, + backgroundImage: `url(out/assets/shots/${lang}-${sz.id}.jpg)`, borderRadius: sz.id === 'feature' ? '6px' : '9px' }); + shotsEl.appendChild(el); + shotTiles.push({ el, col: i, row: j }); + }); + x += w + GAP; + }); } -if (V) { Object.assign(shotCmd.style, { left: '50%', top: '500px' }); Object.assign(shotCount.style, { left: '50%', top: '1300px', fontSize: '58px' }); } -else { Object.assign(shotCmd.style, { left: '50%', top: '290px' }); Object.assign(shotCount.style, { left: '50%', top: '880px', fontSize: '56px' }); } -function shots(t) { - const s = scene('shots'); - if (t < s.start - 0.1 || t > s.end + 0.6) return; +function store(t) { + const s = scene('store'); if (t < s.start - 1 || t > s.end + 1) return; const r = t - s.start; - let shown = 0; - for (const tile of tiles) { - const p = prog(r, tile.at, 0.26); - if (p > 0) shown++; - set(tile.el, 'opacity', String(clamp(p * 2))); - set(tile.el, 'transform', `translateZ(${((1 - eoc(p)) * 260).toFixed(1)}px) scale(${lerp(0.72, 1, eob(p)).toFixed(3)})`); + appear($('#copy'), r, 0.0, 0.4, 14); + copyEls.forEach((el, i) => appear(el, r, COPY_AT + i * COPY_STEP, 0.4, 10)); + langLabels.forEach((el, j) => appear(el, r, SHOTS_AT - 0.2 + j * 0.05, 0.3, 0)); + shotLabels.forEach(({ el, col }) => { const p = prog(r, SHOTS_AT + col * SHOTS_STEP, 0.35); set(el, 'opacity', String(eoc(p))); }); + for (const { el, col, row } of shotTiles) { + const p = prog(r, SHOTS_AT + col * SHOTS_STEP + row * 0.06, 0.4); + set(el, 'opacity', String(eoc(p))); + set(el, 'transform', `scale(${lerp(0.9, 1, eoc(p)).toFixed(4)})`); } - const z = lerp(1.12, 0.98, eio(prog(r, 0, s.end - s.start + 0.4))); - set(wall, 'transform', `translate(-50%, -50%) translateY(${(-60 * r).toFixed(1)}px) perspective(2200px) rotateX(20deg) rotateZ(-11deg) scale(${z.toFixed(4)})`); - const frac = shown / tiles.length; - html(shotNum, String(Math.round(SHOTS_TOTAL * eoc(clamp(r / 1.65)) * (frac > 0 ? 1 : 0)))); - const cp = prog(r, 0.1, 0.35), np = prog(r, 0.35, 0.35); - set(shotCmd, 'opacity', String(cp)); set(shotCmd, 'transform', `translate(-50%, ${((1 - eoc(cp)) * 20).toFixed(1)}px)`); - const pop = decay(r, 1.65, 0.3); - set(shotCount, 'opacity', String(np)); set(shotCount, 'transform', `translate(-50%, ${((1 - eoc(np)) * 30).toFixed(1)}px) scale(${(1 + 0.12 * pop).toFixed(3)})`); + const done = SHOTS_AT + SHOT_SIZES.length * SHOTS_STEP + 0.2; + pillAt(storePill, r, done); + pillAt(shotCmd, r, done + 0.2, 'translateX(-50%)'); } -// ---------- declarations ---------- -const prop = $('#prop'), form = $('#form'), declNum = $('#declcount .num'), declCount = $('#declcount'); -const PROP_LINES = [...DECL_LINES.map(d => ({ k: 'detected', w: d.what, v: d.value, loc: d.where })), { k: 'ask owner', w: DECL_ASK.replace('ask owner ', ''), v: '?', loc: '', ask: true }]; -prop.querySelector('.body').innerHTML = PROP_LINES.map(l => `${esc(l.k)} ${esc(l.w)}${l.loc ? ` ${esc(l.loc)}` : ` ${esc(l.v)}`}`).join(''); -const ROW = V ? 54 : 62; -form.querySelector('.body').innerHTML = DATA_SAFETY_ROWS.map(r => `
${esc(r)}detected
`).join(''); -if (V) { - Object.assign(prop.style, { left: '60px', width: '960px', top: '540px' }); - Object.assign(form.style, { left: '60px', width: '960px', top: '890px' }); - Object.assign(declCount.style, { left: '50%', top: '1372px', fontSize: '50px' }); -} else { - Object.assign(prop.style, { left: '130px', width: '860px', top: '320px' }); - Object.assign(form.style, { left: '1040px', width: '750px', top: '300px' }); - Object.assign(declCount.style, { left: '560px', top: '820px', fontSize: '56px' }); -} -const propLns = [...prop.querySelectorAll('.ln')], formRows = [...form.querySelectorAll('.row')]; -function decl(t) { - const s = scene('decl'); - if (t < s.start - 0.4 || t > s.end + 0.5) return; +// ---------- 5 products ---------- +const prodBody = $('#prodterm .body'), prodPill = $('#prod-pill'); +const prodLine = l => (l.cmd ? `$ ${esc(l.text.replace(/^\$ /, ''))}` + : tagged(l.text).replace(/^ok {4}/, 'ok ').replace(/(\d+ regions?|\d+ region prices)/, '$1') + .replace(/(0 mismatch\(es\))/, '$1')); +prodBody.innerHTML = PRODUCT_LINES.map((l, i) => `${i && l.cmd ? ' ' : ''}${prodLine(l)}`).join(''); +const prodLns = [...prodBody.querySelectorAll('.ln')].filter(el => el.style.opacity !== '1'); +prodPill.innerHTML = bold(PRODUCTS_PILL.text); +function products(t) { + const s = scene('products'); if (t < s.start - 1 || t > s.end + 1) return; const r = t - s.start; - const ce = eoc(prog(r, 0, 0.4)); - set(prop, 'transform', `translateY(${((1 - ce) * 40).toFixed(1)}px)`); set(prop, 'opacity', String(ce)); - const fe = eoc(prog(r, 0.35, 0.4)); - set(form, 'transform', `translateY(${((1 - fe) * 40).toFixed(1)}px)`); set(form, 'opacity', String(fe)); - propLns.forEach((el, i) => { const p = prog(r, 0.2 + i * 0.16, 0.22); set(el, 'opacity', String(p)); set(el, 'transform', `translateX(${((1 - eoc(p)) * 30).toFixed(1)}px)`); }); + appear($('#prodterm'), r, 0.0, 0.4, 14); + prodLns.forEach((el, i) => appear(el, r, PRODUCT_LINES[i].at, 0.3, 6)); + pillAt(prodPill, r, PRODUCTS_PILL.at); +} + +// ---------- 6 forms ---------- +const propBody = $('#prop .body'), formBody = $('#form .body'), formsPill = $('#forms-pill'); +propBody.innerHTML = DECL_LINES.map(d => `detected ${esc(d.what)}:(${esc(d.where)})${esc(d.value)}`).join('') + + `ask owner ${esc(DECL_ASK.replace(/^ask owner /, '').split(':')[0])}:${esc(DECL_ASK.replace(/^ask owner [^:]+:/, ''))}` + + 'Only you know this one: storebound asks.'; +const propLns = [...propBody.querySelectorAll('.ln')], askGlow = $('#prop .ask .glow'), askNote = $('#prop .askn'); +formBody.innerHTML = DATA_SAFETY_ROWS.map(r => `
${esc(r)}detected
`).join(''); +const formRows = [...formBody.querySelectorAll('.row')]; +function forms(t) { + const s = scene('forms'); if (t < s.start - 1 || t > s.end + 1) return; + const r = t - s.start; + appear($('#prop'), r, 0.0, 0.4, 14); + appear($('#form'), r, 0.25, 0.4, 14); + propLns.forEach((el, i) => appear(el, r, i < DECL_LINES.length ? DECL_AT + i * DECL_STEP : ASK_AT, 0.3, 6)); + const g = prog(r, ASK_AT + 0.15, 0.4); + set(askGlow, 'opacity', String(eoc(g))); + appear(askNote, r, ASK_AT + 0.4, 0.4, 6); formRows.forEach((el, i) => { - const p = prog(r, 0.95 + i * 0.16, 0.24); + const p = prog(r, FORM_AT + i * FORM_STEP, 0.25); set(el.querySelector('.fill'), 'opacity', String(eoc(p))); - set(el.querySelector('.pi'), 'transform', `scale(${eob(p).toFixed(3)})`); + set(el.querySelector('.pi'), 'opacity', String(eoc(p))); set(el.querySelector('.box'), 'borderColor', p > 0 ? 'var(--green)' : 'var(--line-2)'); - set(el.querySelector('.tag'), 'opacity', String(p)); + set(el.querySelector('.tg'), 'opacity', String(p)); set(el, 'color', p > 0.5 ? '#fff' : 'var(--ink-2)'); }); - const np = prog(r, 0.95, 1.3); - html(declNum, String(Math.round(DECL_TOTAL * eoc(np)))); - const dp = prog(r, 0.8, 0.3), pop = decay(r, 2.25, 0.3); - set(declCount, 'opacity', String(dp)); - set(declCount, 'transform', `translate(${V ? '-50%' : '0'}, ${((1 - eoc(dp)) * 30).toFixed(1)}px) scale(${(1 + 0.12 * pop).toFixed(3)})`); + const np = prog(r, FORMS_PILL.at, 1.0); + html(formsPill, `${Math.round(DECL_TOTAL * eoc(np))} ${esc(FORMS_PILL.text)}`); + pillAt(formsPill, r, FORMS_PILL.at); } -// ---------- desktop: real frames in a window, slow camera, one callout ---------- -const BOXES = await fetch('out/desktop/boxes.json').then(r => { if (!r.ok) throw new Error('out/desktop/boxes.json missing (bun media/teaser/desktop.ts)'); return r.json(); }); -const WIN = V ? { x: 40, y: 520, w: 1000, h: 950 } : { x: 210, y: 285, w: 1500, h: 760 }; -const VIEW = { w: WIN.w, h: WIN.h - 44 }; -const S0 = Math.max(VIEW.w / 1280, VIEW.h / 800); -const desk = {}; -for (const [id, d] of Object.entries(DESKTOP)) { - const el = $(`#s-${id}`); - const img = f => ``; - el.innerHTML = `
-
storebound
-
- ${img(d.empty ?? d.frame)} - ${d.empty ? `
${img(d.frame)}
${img(d.frame)}
` : ''} - ${d.clean ? `
${img(d.clean)}
` : ''} -
-
${esc(d.callout.text)}
`; - desk[id] = { el, d, win: el.querySelector('.win'), cam: el.querySelector('.cam'), c1: el.querySelector('.c1'), c2: el.querySelector('.c2'), - cl: el.querySelector('.cl'), line: el.querySelector('.scanline'), ring: el.querySelector('.ring'), callout: el.querySelector('.callout') }; +// ---------- 7 rejections ---------- +const scanBody = $('#scanterm .body'); +scanBody.innerHTML = `$ ${esc(SCAN_CMD)}` + + `${esc(RISKS_LINE).replace(/(2 blocker, 3 high)/, '$1')}` + + FINDINGS.map((f, i) => `
+
${i + 1}.${f.sev}${esc(f.guideline)}${esc(f.title)}
+
${esc(f.why)}at ${esc(f.where)}FIXED
`).join('') + + `$ ${esc(SCAN_CMD)} (after the fixes)` + + `${esc(RESCAN_LINE)}`; +const scanLns = [...scanBody.querySelectorAll(':scope > .ln')], fdEls = [...scanBody.querySelectorAll('.fd')]; +function rejections(t) { + const s = scene('rejections'); if (t < s.start - 1 || t > s.end + 1) return; + const r = t - s.start; + appear($('#scanterm'), r, 0.0, 0.4, 14); + appear(scanLns[0], r, 0.25, 0.25, 4); + appear(scanLns[1], r, 0.6, 0.3, 6); + fdEls.forEach((el, i) => { + appear(el, r, FINDINGS[i].at, 0.4, 10); + const f = prog(r, FIX_AT[i], 0.45); + set(el.querySelector('.tint.g'), 'opacity', String(eoc(f))); + set(el.querySelector('.tint.b'), 'opacity', String(1 - eoc(f))); + set(el.querySelector('.fixed'), 'opacity', String(eoc(f))); + set(el.querySelector('.why .pi'), 'color', f > 0.5 ? 'var(--green)' : 'var(--red)'); + }); + appear(scanLns[2], r, RESCAN_AT, 0.3, 6); + appear(scanLns[3], r, RESCAN_AT + 0.35, 0.3, 6); } -const pct = v => `${(v * 100).toFixed(3)}%`; -/** Camera of a desktop scene at r seconds: image scale and offset inside the window view. */ -function deskCam(d, r, len) { - const p = eio(clamp(r / len)); - // the vertical window shows a portrait crop of the landscape app: a gentler push, and the Checks card kept whole-ish - const zk = V ? 0.45 : 1, fxv = V && d.clean ? 0.6 : null; - const z = 1 + (lerp(d.from.z, d.to.z, p) - 1) * zk, fx = fxv ?? lerp(d.from.f[0], d.to.f[0], p), fy = lerp(d.from.f[1], d.to.f[1], p); - const S = S0 * z; + +// ---------- 8 desktop: real frames in a window, the camera pushes from the timeline to the readiness card ---------- +const BOXES = await fetch('out/desktop/boxes.json').then(r => { if (!r.ok) throw new Error('out/desktop/boxes.json missing (bun media/teaser/desktop.ts)'); return r.json(); }); +const WIN = { x: 370, y: 236, w: 1180, bar: 40 }; +const VIEW = { w: WIN.w, h: WIN.w * 800 / 1280 }; +WIN.h = VIEW.h + WIN.bar; +const S0 = VIEW.w / 1280; +const deskCam = $('#s-desktop > .cam'); +deskCam.innerHTML = `
+
storebound
+
${DESKTOP.frames.map((f, i) => ``).join('')}
+ ${DESKTOP.callouts.map(c => `
${esc(c.text)}
`).join('')}`; +const cam2 = $('#s-desktop .cam2'), frameEls = [...cam2.querySelectorAll('img')]; +const rings = [...deskCam.querySelectorAll('.ring')], callouts = [...deskCam.querySelectorAll('.callout')]; +function deskView(r) { + const s = scene('desktop'), len = s.end - s.start; + const p = ess(clamp((r + DISSOLVE / 2) / (len + DISSOLVE))); + const { from, to } = DESKTOP.cam; + const S = S0 * lerp(from.z, to.z, p), fx = lerp(from.f[0], to.f[0], p), fy = lerp(from.f[1], to.f[1], p); const ox = clamp(VIEW.w / 2 - fx * 1280 * S, VIEW.w - 1280 * S, 0), oy = clamp(VIEW.h / 2 - fy * 800 * S, VIEW.h - 800 * S, 0); return { S, ox, oy }; } -/** A boxes.json entry in stage pixels for the current camera (plus the window's own transform, applied by the caller). */ -const stageBox = (b, c) => ({ x: WIN.x + c.ox + b.x * 1280 * c.S, y: WIN.y + 44 + c.oy + b.y * 800 * c.S, w: b.w * 1280 * c.S, h: b.h * 800 * c.S }); -const cursorEl = $('#cursor'), clickEl = $('#click'); -let cursorShown = false; -function cursorAt(x, y, op, press = 0) { - cursorShown = op > 0; - set(cursorEl, 'opacity', String(op)); - set(cursorEl, 'transform', `translate(${(x - 10).toFixed(1)}px, ${(y - 10).toFixed(1)}px) scale(${(1 - 0.14 * press).toFixed(3)})`); -} +const stageBox = (b, c) => ({ x: WIN.x + c.ox + b.x * 1280 * c.S, y: WIN.y + WIN.bar + c.oy + b.y * 800 * c.S, w: b.w * 1280 * c.S, h: b.h * 800 * c.S }); function desktop(t) { - for (const [id, k] of Object.entries(desk)) { - const s = scene(id), d = k.d, r = t - s.start, len = s.end - s.start; - if (t < s.start - 0.2 || t > s.end + 0.5) continue; - const c = deskCam(d, r, len + 0.3); - set(k.cam, 'transform', `translate(${c.ox.toFixed(2)}px, ${c.oy.toFixed(2)}px) scale(${(c.S).toFixed(5)})`); - if (k.c1) { - const p = eio(prog(r, d.fill[0], d.fill[1] - d.fill[0])); - for (const [el, b] of [[k.c1, BOXES.roll], [k.c2, BOXES.roll2]]) { - set(el, 'clipPath', `inset(${pct(b.y)} ${pct(1 - b.x - b.w * p)} ${pct(1 - b.y - b.h)} ${pct(b.x)})`); - } - } - if (k.cl) { - const p = eio(prog(r, d.flip, 0.5)); - set(k.cl, 'clipPath', `inset(0 0 ${pct(1 - p)} 0)`); - set(k.line, 'opacity', String(p > 0 && p < 1 ? 1 : 0)); - set(k.line, 'top', `${(p * 800 - 3).toFixed(1)}px`); - } - // the window itself: a gentle settle - const we = eoc(prog(r, 0, 0.6)); - set(k.win, 'transform', `scale(${lerp(0.97, 1, we).toFixed(4)})`); - // callout + ring on the target - const b = BOXES[d.callout.target]; - const sb = stageBox(b, c); - const cp = prog(r, d.callout.at, 0.34); - const ring = k.ring; - set(ring, 'opacity', String(clamp(cp * 2))); - // the ring stays inside the window - const rx0 = Math.max(sb.x - 10, WIN.x + 8), ry0 = Math.max(sb.y - 10, WIN.y + 52); - const rx1 = Math.min(sb.x + sb.w + 10, WIN.x + WIN.w - 8), ry1 = Math.min(sb.y + sb.h + 10, WIN.y + WIN.h - 8); - set(ring, 'left', `${rx0.toFixed(1)}px`); set(ring, 'top', `${ry0.toFixed(1)}px`); - set(ring, 'width', `${(rx1 - rx0).toFixed(1)}px`); set(ring, 'height', `${(ry1 - ry0).toFixed(1)}px`); - set(ring, 'transform', `scale(${lerp(1.15, 1, eoc(cp)).toFixed(3)})`); - let text = d.callout.text; - if (d.fill) text = `Rollout · ${Math.round(20 * eio(prog(r, d.fill[0], d.fill[1] - d.fill[0])))}%`; - html(k.callout, esc(text)); - const cw = k.callout.offsetWidth; - const cx = clamp(sb.x + sb.w / 2, W * 0.1 + cw / 2, W * 0.9 - cw / 2); - const above = sb.y - 30 > WIN.y + 90; - const cy = above ? sb.y - 26 : sb.y + sb.h + 26 + 70; - set(k.callout, 'opacity', String(clamp(cp * 2.5))); - set(k.callout, 'left', `${cx.toFixed(1)}px`); set(k.callout, 'top', `${cy.toFixed(1)}px`); - set(k.callout, 'transform', `translate(-50%, -100%) scale(${lerp(0.5, 1, eob(cp)).toFixed(3)})`); - } -} -/** The cursor: in the desktop scenes and over the Submit button. */ -function cursor(t) { - const s = active(t); - set(clickEl, 'opacity', '0'); - if (desk[s.id]) { - const k = desk[s.id], d = k.d, r = t - s.start; - const c = deskCam(d, r, s.end - s.start + 0.3); - const [[a0], [a1, target]] = d.cursor; - const b = stageBox(BOXES[target], c); - const tx = b.x + b.w * (target === 'roll' ? 0.35 : 0.5), ty = b.y + b.h * 0.6; - const sx = W * 0.92, sy = WIN.y + WIN.h * 0.95; - const p = eio(prog(r, a0, a1 - a0)); - const arc = Math.sin(Math.PI * p) * 70; - const x = lerp(sx, tx, p) + arc * 0.4, y = lerp(sy, ty, p) - arc; - const op = prog(r, a0 - 0.15, 0.15) * (1 - prog(t, s.end - 0.12, 0.12)); - let press = 0; - if (id3(s.id)) { - press = decay(r, a1 + 0.02, 0.22); - const cp = prog(r, a1 + 0.02, 0.4); - if (cp > 0 && cp < 1) { - set(clickEl, 'opacity', String(0.9 * (1 - cp))); - set(clickEl, 'transform', `translate(${tx.toFixed(1)}px, ${ty.toFixed(1)}px) scale(${lerp(0.3, 1.4, eoc(cp)).toFixed(3)})`); - } - } - cursorAt(x, y, op, press); - return; - } - if (s.id === 'submit') { - const btn = $('#sbtn').getBoundingClientRect(); - const tx = btn.left + btn.width * 0.62, ty = btn.top + btn.height * 0.62; - const a0 = s.start + 0.35; - const p = eio(prog(t, a0, SUBMIT_HOVER - a0)); - const arc = Math.sin(Math.PI * p) * 80; - // it stops on the button and waits: no click - const hes = Math.sin(Math.max(0, t - SUBMIT_HOVER) * 3.2) * 6 * prog(t, SUBMIT_HOVER, 0.4); - cursorAt(lerp(W * 0.9, tx, p) + arc * 0.3 + hes, lerp(H * 0.95, ty, p) - arc, prog(t, a0, 0.15) * (1 - prog(t, s.end - 0.15, 0.15))); - return; - } - if (cursorShown) cursorAt(0, 0, 0); -} -const id3 = id => id === 'desk3'; - -// ---------- more: three panels of real CLI output, a cut on the beat between them ---------- -const moreEl = $('#s-more'); -const MC = V ? { x: 60, w: 960, top: 640, stat: 1010 } : { x: 260, w: 1400, top: 370, stat: 740 }; -/** Colour the real text without changing it: counts white, [ok] green, [check] yellow, the dry-run verdict green. */ -const moreLine = l => esc(l) - .replace(/^(\[ok\])/, '$1').replace(/^(\[check\])/, '$1') - .replace(/(\d+ operations)/, '$1').replace(/(: )(Yes)$/, '$1$2') - .replace(/^(build planned \(dry run\))$/, '$1'); -moreEl.innerHTML = MORE.map(p => `
-
$ ${esc(p.cmd)}${V ? '' : `${esc(p.sub)}`}
-
${p.lines.map(l => `${moreLine(l)}`).join('')}
-
${p.stat.text.split(' ').map(w => w.startsWith('*') ? `${esc(w.replace(/\*/g, ''))}` : esc(w)).join(' ')}
`).join(''); -const morePanels = [...moreEl.querySelectorAll('.panel')].map((el, i) => ({ - el, card: el.querySelector('.card'), lines: [...el.querySelectorAll('.ln')], stat: el.querySelector('.stat'), at: MORE[i].at, until: MORE[i + 1]?.at ?? Infinity, -})); -function more(t) { - const s = scene('more'); - if (t < s.start - 0.2 || t > s.end + 0.5) return; - morePanels.forEach((p, i) => { - const on = (i === 0 ? t >= s.start - 0.2 : t >= p.at) && t < p.until; - set(p.el, 'visibility', on ? 'visible' : 'hidden'); - if (!on) return; - const r = t - p.at; - // the first panel arrives with the scene's whip; the next two cut in with a short push - const ce = i === 0 ? 1 : eoq(prog(r, 0, 0.22)); - set(p.card, 'transform', `translateX(${((1 - ce) * 90).toFixed(1)}px) scale(${lerp(1.05, 1, ce).toFixed(4)})`); - p.lines.forEach((el, j) => { - const lp = prog(r, (i === 0 ? 0.12 : 0.06) + j * 0.07, 0.18); - set(el, 'opacity', String(clamp(lp * 2))); - set(el, 'transform', `translateX(${((1 - eoc(lp)) * 30).toFixed(1)}px)`); - }); - const sp = prog(r, 0.3, 0.3); - set(p.stat, 'opacity', String(clamp(sp * 2.5))); - set(p.stat, 'transform', `translate(-50%, ${((1 - eoc(sp)) * 26).toFixed(1)}px) scale(${lerp(0.85, 1, eob(sp)).toFixed(3)})`); + const s = scene('desktop'); if (t < s.start - 1 || t > s.end + 1) return; + const r = t - s.start; + const c = deskView(r); + set(cam2, 'transform', `translate(${c.ox.toFixed(2)}px, ${c.oy.toFixed(2)}px) scale(${c.S.toFixed(5)})`); + const sw = eio(prog(r, DESKTOP.swap[0], DESKTOP.swap[1] - DESKTOP.swap[0])); + set(frameEls[1], 'opacity', String(sw)); + DESKTOP.callouts.forEach((co, i) => { + const b = stageBox(BOXES[co.target], c); + const op = eoc(prog(r, co.at, 0.4)) * (1 - prog(r, co.until - 0.3, 0.3)); + const ring = rings[i], call = callouts[i]; + const x0 = Math.max(b.x - 10, WIN.x + 8), y0 = Math.max(b.y - 10, WIN.y + WIN.bar + 6); + const x1 = Math.min(b.x + b.w + 10, WIN.x + WIN.w - 8), y1 = Math.min(b.y + b.h + 10, WIN.y + WIN.h - 8); + set(ring, 'opacity', String(op)); + set(ring, 'left', `${x0.toFixed(1)}px`); set(ring, 'top', `${y0.toFixed(1)}px`); + set(ring, 'width', `${(x1 - x0).toFixed(1)}px`); set(ring, 'height', `${(y1 - y0).toFixed(1)}px`); + const cw = call.offsetWidth; + const cx = clamp((x0 + x1) / 2, 60 + cw / 2, W - 60 - cw / 2); + const below = y1 + 90 < WIN.y + WIN.h; + set(call, 'opacity', String(op)); + set(call, 'left', `${cx.toFixed(1)}px`); + set(call, 'top', `${(below ? y1 + 24 : y0 - 24).toFixed(1)}px`); + set(call, 'transform', `translate(-50%, ${below ? '0' : '-100%'}) scale(${lerp(0.92, 1, eoc(prog(r, co.at, 0.4))).toFixed(3)})`); }); } -// ---------- submit + brand ---------- -const sbtn = $('#sbtn'), shov = $('#sbtn .hov'); -if (V) sbtn.style.top = '980px'; else sbtn.style.top = '560px'; -const brandWrap = $('#s-brand .wrap'); -brandWrap.querySelector('.url').textContent = URL; -brandWrap.querySelector('.plat').textContent = PLATFORMS; -if (!V) { brandWrap.querySelector('.mark').style.width = brandWrap.querySelector('.mark').style.height = '200px'; brandWrap.querySelector('.word').style.fontSize = '130px'; } -function endCards(t) { +// ---------- 9 submit + end card ---------- +const sbtn = $('#sbtn'), shov = $('#sbtn .hov'), brand = $('#brand'), cursorEl = $('#cursor'); +brand.querySelector('.url').textContent = URL; +brand.querySelector('.plat').textContent = TAGLINE; +function submit(t) { const s = scene('submit'); - if (t >= s.start - 0.1 && t < s.end + 0.5) { - const r = t - s.start, e = eob(prog(r, 0.05, 0.45)); - const hov = prog(t, SUBMIT_HOVER, 0.15); - set(sbtn, 'transform', `translate(-50%, 0) scale(${(lerp(0.7, 1, e) * (1 + 0.03 * hov)).toFixed(4)})`); - set(sbtn, 'opacity', String(clamp(prog(r, 0.05, 0.2)))); - set(shov, 'opacity', String(hov)); - } - const b = scene('brand'); - if (t >= b.start - 0.1) { - const r = t - b.start; - set(brandWrap, 'transform', `translateY(-50%) scale(${lerp(1.0, 1.04, clamp(r / 4)).toFixed(4)})`); - [...brandWrap.children].forEach((el, i) => { - const p = prog(r, 0.08 + i * 0.16, i === 0 ? 0.5 : 0.36); - set(el, 'opacity', String(clamp(p * 2))); - set(el, 'transform', i === 0 ? `scale(${lerp(0.4, 1, eob(p)).toFixed(3)}) rotate(${((1 - eoc(p)) * -12).toFixed(2)}deg)` : `translateY(${((1 - eoc(p)) * 40).toFixed(1)}px)`); - set(el, 'filter', p < 1 ? `blur(${((1 - eoc(p)) * 12).toFixed(1)}px)` : 'none'); - }); - } + const r = t - s.start; + if (t < s.start - 1) { set(cursorEl, 'opacity', '0'); return; } + const hov = prog(r, SUBMIT.hover, 0.25); + const out = prog(r, SUBMIT.logoAt, 0.6); + set(sbtn, 'opacity', String(eoc(prog(r, 0.0, 0.4)) * (1 - eio(out)))); + set(sbtn, 'transform', `translate(-50%, 0) scale(${(lerp(0.96, 1, eoc(prog(r, 0, 0.5))) * (1 + 0.02 * hov)).toFixed(4)})`); + set(shov, 'opacity', String(hov)); + // the cursor glides in and rests on the button: it never clicks + const btn = sbtn.getBoundingClientRect(); + const tx = btn.left + btn.width * 0.64, ty = btn.top + btn.height * 0.66; + const p = eio(prog(r, 0.3, SUBMIT.hover - 0.3)); + set(cursorEl, 'opacity', String(prog(r, 0.3, 0.3) * (1 - eio(out)))); + set(cursorEl, 'transform', `translate(${(lerp(W * 0.86, tx, p) - 10).toFixed(1)}px, ${(lerp(H * 0.95, ty, p) - 10).toFixed(1)}px)`); + [...brand.children].forEach((el, i) => { + const q2 = prog(r, SUBMIT.logoAt + 0.2 + i * 0.18, SUBMIT.logoIn); + set(el, 'opacity', String(eoc(q2))); + set(el, 'transform', `translateY(${((1 - eoc(q2)) * 18).toFixed(1)}px)`); + }); } function seek(t) { scenes(t); background(t); hook(t); - scan(t); - fixed(t); - shots(t); - decl(t); + init(t); + plan(t); + store(t); + products(t); + forms(t); + rejections(t); desktop(t); - more(t); - endCards(t); - cursor(t); + submit(t); captions(t); } const ready = (async () => { await document.fonts.ready; - const imgs = [...document.images, ...GRID.map(f => Object.assign(new Image(), { src: `out/assets/grid/${f}` }))]; - await Promise.all(imgs.map(im => im.decode().catch(() => { throw new Error(`image failed: ${im.src}`); }))); + const imgs = [...document.images]; + const bgs = [...document.querySelectorAll('.tile')].map(el => Object.assign(new Image(), { src: el.style.backgroundImage.replace(/^url\("?|"?\)$/g, '') })); + await Promise.all([...imgs, ...bgs].map(im => im.decode().catch(() => { throw new Error(`image failed: ${im.src}`); }))); seek(0); })(); -window.teaser = { ready, seek, DURATION, FPS, W, H, BEAT, captionTimes }; +window.teaser = { ready, seek, DURATION, FPS, W, H, captionTimes }; if (q.has('t')) ready.then(() => seek(Number(q.get('t')))); if (q.has('play')) ready.then(() => { diff --git a/tests/helpers/teaser-store-mock.ts b/tests/helpers/teaser-store-mock.ts new file mode 100644 index 00000000..d347b619 --- /dev/null +++ b/tests/helpers/teaser-store-mock.ts @@ -0,0 +1,90 @@ +// Store double for the teaser's CLI scenes (tests/teaser.test.ts): loaded with `preload` from a bunfig.toml in a temp +// project, so every `bun cli/index.ts …` started there (and the children `release plan` starts) answers from here and +// never reaches the network. It answers in the shapes App Store Connect and Google Play use (sanitized: placeholder +// ids only) for a brand-new app record of the placeholder project: +// TEASER_STORE=new the app record exists, nothing else: no version, no build, no listings, no products +// TEASER_STORE=catalog the two products of the teaser project exist on both stores, priced in every region +// Regions: the App Store's 175 storefronts (ALPHA3 in cli/lib/money.ts); Google Play the same list without mainland +// China (Play is not offered there), 174 regions, the count Play answered in a recorded read-only run +// (tests/play-post-reads.test.ts). Pages under https://example.com/ (the template's privacy policy and +// delete-account URLs) answer 200; any other request answers 599 with its URL. +import { ALPHA3, toMoney } from '../../cli/lib/money'; +import { CURRENCY } from '../../cli/lib/ppp'; + +const STATE = process.env.TEASER_STORE ?? 'new'; +const APP = '6400000101'; +const ASC = 'https://api.appstoreconnect.apple.com'; +const json = (o: unknown, status = 200): Response => new Response(JSON.stringify(o), { status, headers: { 'content-type': 'application/json' } }); +const list = (data: unknown[], included: unknown[] = []): Response => json({ data, included, links: {}, meta: { paging: { total: data.length, limit: 200 } } }); + +/** The teaser project's products (the config in tests/teaser.test.ts): id, Apple type, US price. */ +const PRODUCTS = [ + { id: 'com.example.app.no_ads', type: 'NON_CONSUMABLE', usd: 2.99 }, + { id: 'com.example.app.gems_100', type: 'CONSUMABLE', usd: 0.99 }, +]; +const APPLE_REGIONS = Object.keys(ALPHA3); +const PLAY_REGIONS = APPLE_REGIONS.filter(r => r !== 'CN'); +/** One price per product everywhere (the values are not shown; the same price on both stores, so no parity gaps). */ +const currency = (r: string): string => CURRENCY[r] ?? 'USD'; + +function apple(m: string, p: string): Response { + if (/^\/v1\/apps\?filter\[bundleId\]=/.test(p)) return list([{ type: 'apps', id: APP, attributes: { name: 'Example App', bundleId: decodeURIComponent(p.split('=')[1]!), primaryLocale: 'en-US', sku: 'EXAMPLE' } }]); + if (p.startsWith(`/v1/apps/${APP}/appInfos`)) return list([{ type: 'appInfos', id: 'info-1', attributes: { appStoreState: 'PREPARE_FOR_SUBMISSION', state: 'PREPARE_FOR_SUBMISSION' } }]); + if (STATE === 'catalog') { + if (p.startsWith(`/v1/apps/${APP}/inAppPurchasesV2`)) return list(PRODUCTS.map((x, i) => ({ type: 'inAppPurchases', id: `iap-${i}`, attributes: { productId: x.id, name: x.id.split('.').pop(), inAppPurchaseType: x.type, state: 'READY_TO_SUBMIT' } }))); + const loc = p.match(/^\/v2\/inAppPurchases\/iap-\d\/inAppPurchaseLocalizations/); + if (loc) return list(['en-US', 'tr'].map((locale, i) => ({ type: 'inAppPurchaseLocalizations', id: `loc-${i}`, attributes: { locale, name: 'Example', description: 'Example.' } }))); + const sched = p.match(/^\/v2\/inAppPurchases\/(iap-\d)\/iapPriceSchedule/); + if (sched) return json({ data: { type: 'inAppPurchasePriceSchedules', id: sched[1] } }); + const prices = p.match(/^\/v1\/inAppPurchasePriceSchedules\/iap-(\d)\/(manualPrices|automaticPrices)/); + if (prices) { + const x = PRODUCTS[Number(prices[1])]!; + // US is the base territory (manual); every other storefront is equalized by Apple (automatic) + const regions = prices[2] === 'manualPrices' ? ['US'] : APPLE_REGIONS.filter(r => r !== 'US'); + const data = regions.map(r => ({ type: 'inAppPurchasePrices', id: `price-${r}`, attributes: { startDate: null, endDate: null, manual: r === 'US' }, + relationships: { inAppPurchasePricePoint: { data: { type: 'inAppPurchasePricePoints', id: `point-${r}` } }, territory: { data: { type: 'territories', id: ALPHA3[r] } } } })); + const included = regions.flatMap(r => [ + { type: 'inAppPurchasePricePoints', id: `point-${r}`, attributes: { customerPrice: String(x.usd), proceeds: String(x.usd * 0.85) } }, + { type: 'territories', id: ALPHA3[r], attributes: { currency: currency(r) } }, + ]); + return list(data, included); + } + if (/^\/v1\/inAppPurchasePriceSchedules\/iap-\d\/baseTerritory/.test(p)) return json({ data: { type: 'territories', id: 'USA', attributes: { currency: 'USD' } } }); + } + if (m === 'GET') return list([]); + return json({ errors: [{ status: '599', detail: `teaser store double: no route for ${m} ${p}` }] }, 599); +} + +function play(m: string, url: string): Response { + if (m === 'POST' && /\/edits$/.test(url)) return json({ id: 'edit-1', expiryTimeSeconds: '9999999999' }); + if (m === 'DELETE') return new Response(null, { status: 204 }); + if (/\/edits\/edit-1\/tracks$/.test(url)) return json({ kind: 'androidpublisher#tracksListResponse', tracks: [] }); + if (/\/edits\/edit-1\/listings$/.test(url)) return json({ kind: 'androidpublisher#listingsListResponse' }); + if (m === 'POST' && /\/pricing:convertRegionPrices$/.test(url)) return json({ + convertedRegionPrices: Object.fromEntries(PLAY_REGIONS.map(r => [r, { regionCode: r, price: toMoney(currency(r), 1.99), taxAmount: toMoney(currency(r), 0) }])), + convertedOtherRegionsPrice: { usdPrice: toMoney('USD', 1.99), eurPrice: toMoney('EUR', 1.99) }, + regionVersion: { version: '2022/02' }, + }); + const product = (x: (typeof PRODUCTS)[number]) => ({ + packageName: 'com.example.app', productId: x.id, + listings: [{ languageCode: 'en-US', title: 'Example', description: 'Example.' }, { languageCode: 'tr-TR', title: 'Example', description: 'Example.' }], + purchaseOptions: [{ purchaseOptionId: 'buy', state: 'ACTIVE', buyOption: { legacyCompatible: true }, + regionalPricingAndAvailabilityConfigs: PLAY_REGIONS.map(r => ({ regionCode: r, availability: 'AVAILABLE', price: toMoney(currency(r), x.usd) })) }], + }); + if (/\/oneTimeProducts\?pageSize=/.test(url)) return json(STATE === 'catalog' ? { oneTimeProducts: PRODUCTS.map(product) } : {}); + const one = url.match(/\/oneTimeProducts\/([^/?]+)$/); + if (one) { const x = PRODUCTS.find(p => p.id === decodeURIComponent(one[1]!)); return x && STATE === 'catalog' ? json(product(x)) : json({ error: { code: 404, message: 'not found', status: 'NOT_FOUND' } }, 404); } + if (/\/subscriptions\?pageSize=/.test(url)) return json({}); + if (m === 'GET') return json({}); + return json({ error: { code: 599, message: `teaser store double: no route for ${m} ${url}` } }, 599); +} + +globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => { + const url = String(input instanceof Request ? input.url : input); + const m = (init?.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase(); + if (url.startsWith('https://oauth2.googleapis.com/token')) return json({ access_token: 'ya29.example', expires_in: 3600 }); + if (url.startsWith(ASC)) return apple(m, url.slice(ASC.length)); + if (url.startsWith('https://androidpublisher.googleapis.com/')) return play(m, url); + if (url.startsWith('https://example.com/')) return new Response('Example

Example page.

', { status: 200, headers: { 'content-type': 'text/html' } }); + return new Response(`teaser store double: no route for ${m} ${url}`, { status: 599 }); +}) as typeof fetch; diff --git a/tests/teaser.test.ts b/tests/teaser.test.ts index ac8b054d..c6f6dd9f 100644 --- a/tests/teaser.test.ts +++ b/tests/teaser.test.ts @@ -1,140 +1,184 @@ -// The teaser video (media/teaser): the scan text it shows is the real `storebound scan` output of the teaser fixtures, -// every cut sits on the beat grid, every caption is short and stays readable, every scene holds long enough. -import { beforeAll, describe, expect, test } from 'bun:test'; -import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +// The teaser video (media/teaser, v4): every CLI line it shows is real output of the command it names, each scene holds +// 6-7 s, each caption is fully on screen for at least 4 s, the whole cut is 55-65 s, and it is 16:9 only. +import { afterAll, beforeAll, describe, expect, test } from 'bun:test'; +import { generateKeyPairSync } from 'node:crypto'; +import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; +import { ALPHA3 } from '../cli/lib/money'; +import { SIZES } from '../cli/shots/lib'; const ROOT = join(import.meta.dir, '..'); const CLI = join(ROOT, 'cli', 'index.ts'); const FX = join(import.meta.dir, 'fixtures', 'scan'); +const MOCK = join(import.meta.dir, 'helpers', 'teaser-store-mock.ts'); -interface Scene { id: string; from: number; to: number; start: number; end: number; in: string | null } -interface Finding { sev: string; guideline: string; title: string; where: string; fix: string; skill: string } +interface Scene { id: string; start: number; end: number } interface Teaser { - BEAT: number; DURATION: number; SCENES: Scene[]; + FORMAT: { w: number; h: number }; DURATION: number; SCENES: Scene[]; DISSOLVE: number; CAPTIONS: { id: string; lines: string[] }[]; - captionTimes(): { id: string; words: string; count: number; at: number; from: number; to: number; hold: number }[]; - SCAN_HEAD: { text: string }[]; SDKS: { name: string; what: string; dep: string; where: string }[]; - RISKS_LINE: string; FINDINGS: Finding[]; RESCAN_LINE: string; RESCAN_NONE: string; - DECL_LINES: { what: string; value: string; where: string }[]; DECL_ASK: string; CMD: string; - MORE: { at: number; cmd: string; lines: string[]; stat: { text: string } }[]; MORE_CUTS: number[]; + captionTimes(): { id: string; text: string; at: number; from: number; to: number; hold: number }[]; + TODO: { text: string }[]; MAIL: { at: number; subject: string; guideline: string }; MAIL_IN: number; + INIT_CMD: string; INIT_LINES: string[]; + PLAN_CMD: string; PLAN_LINES: string[]; PLAN_STEPS: number; PLAN_PILL: string; + COPY_FILE: string; COPY: { lang: string; title: string[] }[]; SHOT_SIZES: { id: string }[]; SHOT_LANGS: string[]; SHOTS_PILL: string; + PRODUCT_LINES: { text: string; cmd?: boolean }[]; PRODUCTS_PILL: { text: string }; + DECL_LINES: { what: string; value: string; where: string }[]; DECL_ASK: string; DECL_TOTAL: number; + SCAN_CMD: string; RISKS_LINE: string; RESCAN_LINE: string; + FINDINGS: { sev: string; guideline: string; title: string; where: string; why: string }[]; } -const path: string = join(ROOT, 'media/teaser/script.js'); -const T = (await import(path)) as Teaser; +const T = (await import(join(ROOT, 'media/teaser/script.js'))) as Teaser; -const scanText = (dir: string, demo: boolean): string => { - const env = { ...process.env, NO_COLOR: '1', REVIEW_DEMO_USER: demo ? 'demo@example.com' : '', REVIEW_DEMO_PASSWORD: demo ? 'example' : '' }; - const r = Bun.spawnSync(['bun', CLI, 'scan', '--dir', join(FX, dir)], { env, stdout: 'pipe', stderr: 'pipe' }); - // exit code 1 when blockers are found (the fixture before the fixes), 0 after - expect(r.exitCode).toBe(demo ? 0 : 1); - return r.stdout.toString() + r.stderr.toString(); +/** Output lines without the clock prefix and the "(0s)" timer, as the video shows them. */ +const lines = (out: string): string[] => out.split('\n').map(l => l.replace(/^\d\d:\d\d:\d\d /, '').replace(/ \(\d+s\)$/, '').trimEnd()); +const run = (argv: string[], cwd: string, env: Record = {}): { code: number; out: string } => { + const r = Bun.spawnSync(['bun', CLI, ...argv], { cwd, env: { ...process.env, NO_COLOR: '1', ASC_KEY_ID: '', ASC_ISSUER_ID: '', ASC_P8: '', PLAY_SERVICE_ACCOUNT: '', ...env }, stdout: 'pipe', stderr: 'pipe' }); + return { code: r.exitCode, out: r.stdout.toString() + r.stderr.toString() }; }; -let before = '', after = ''; -beforeAll(() => { before = scanText('teaser', false); after = scanText('teaser-fixed', true); }); -/** Runs a CLI command as the montage shows it (`storebound …` -> bun cli/index.ts …), offline, no store keys. */ -const run = (cmd: string, cwd: string): string => { - const env = { ...process.env, NO_COLOR: '1', ASC_KEY_ID: '', ASC_ISSUER_ID: '', ASC_P8: '', PLAY_SERVICE_ACCOUNT: '' }; - const r = Bun.spawnSync(['bun', CLI, ...cmd.replace(/^storebound /, '').split(' ')], { cwd, env, stdout: 'pipe', stderr: 'pipe' }); - expect(r.exitCode, cmd).toBe(0); - return r.stdout.toString() + r.stderr.toString(); -}; -/** A throwaway Capacitor project with an example.com config (as in tests/build-sign.test.ts) for `play build --dry`. */ -function buildProject(): string { - const d = mkdtempSync(join(tmpdir(), 'sb-teaser-')); - const put = (f: string, body = ''): void => { mkdirSync(join(d, f, '..'), { recursive: true }); writeFileSync(join(d, f), body); }; - put('storebound.config.ts', `export default { app: { name: 'Example', privacyPolicyUrl: 'https://example.com/p', supportUrl: 'https://example.com', website: 'https://example.com', contactEmail: 'hi@example.com' }, - languages: [{ id: 'en', apple: 'en-US', play: 'en-US' }], apple: { bundleId: 'com.example.game' }, play: { packageName: 'com.example.game' } };\n`); - put('capacitor.config.ts', 'export default {}'); - put('android/settings.gradle'); put('android/gradlew', '#!/bin/sh'); put('android/app/build.gradle'); - return d; -} +// One throwaway project for the init, plan and products scenes: `storebound init` in an empty folder, store answers +// from the teaser store double (tests/helpers/teaser-store-mock.ts, preloaded through bunfig.toml), placeholder keys. +let dir = '', initOut = '', keys: Record = {}; +beforeAll(() => { + dir = mkdtempSync(join(tmpdir(), 'sb-teaser-')); + initOut = run(['init'], dir).out; + writeFileSync(join(dir, 'bunfig.toml'), `preload = [${JSON.stringify(MOCK)}]\n`); + const ec = generateKeyPairSync('ec', { namedCurve: 'P-256' }).privateKey.export({ type: 'pkcs8', format: 'pem' }).toString(); + const rsa = generateKeyPairSync('rsa', { modulusLength: 2048 }).privateKey.export({ type: 'pkcs8', format: 'pem' }).toString(); + writeFileSync(join(dir, 'k.p8'), ec); + writeFileSync(join(dir, 'sa.json'), JSON.stringify({ client_email: 'sb@example.com', private_key: rsa, token_uri: 'https://oauth2.googleapis.com/token' })); + keys = { ASC_KEY_ID: 'ABCDE12345', ASC_ISSUER_ID: '00000000-0000-0000-0000-000000000000', ASC_P8: join(dir, 'k.p8'), PLAY_SERVICE_ACCOUNT: join(dir, 'sa.json') }; +}); +afterAll(() => rmSync(dir, { recursive: true, force: true })); -describe('teaser: the CLI montage is real output', () => { - test('three panels, two cuts on the beat', () => { - expect(T.MORE).toHaveLength(3); - expect(T.MORE_CUTS).toEqual([T.MORE[1]!.at, T.MORE[2]!.at]); - const s = T.SCENES.find(x => x.id === 'more')!; - expect(T.MORE[0]!.at).toBe(s.start); - for (const t of T.MORE_CUTS) { expect(t).toBeGreaterThan(s.start); expect(t).toBeLessThan(s.end); } +describe('teaser: every CLI line is real output', () => { + test('init: `storebound init` in an empty folder', () => { + expect(T.INIT_CMD).toBe('bunx storebound init'); + const out = lines(initOut); + for (const l of T.INIT_LINES) expect(out, l).toContain(l); }); - test('`storebound api coverage`: the operation counts (revision dates left out)', () => { - const p = T.MORE[0]!; - expect(p.cmd).toBe('storebound api coverage'); - const out = run(p.cmd, ROOT).replace(/ \(\d{8}\)/g, ''); - for (const l of p.lines) expect(out).toContain(l); - const ops = (name: string): number => Number(out.match(new RegExp(`${name}[^:\n]*: (\\d+) operations`))![1]); - const apple = ops('App Store Connect API'), play = ops('Google Play Android Developer API') + ops('Google Play Developer Reporting API'); - expect(p.stat.text).toBe(`*${apple}* App Store Connect + *${play}* Google Play endpoints`); + + test('plan: `storebound release plan 1.0.0` against a brand-new app record on both stores', () => { + expect(T.PLAN_CMD).toBe('storebound release plan 1.0.0'); + const r = run(T.PLAN_CMD.split(' ').slice(1), dir, { ...keys, TEASER_STORE: 'new' }); + const out = lines(r.out); + for (const l of T.PLAN_LINES) expect(out, l).toContain(l); + // the lines keep the order of the real plan + const idx = T.PLAN_LINES.map(l => out.indexOf(l)); + expect([...idx].sort((a, b) => a - b)).toEqual(idx); + const steps = out.filter(l => /^\s+\d+\. /.test(l)).length; + expect(steps).toBe(T.PLAN_STEPS); + expect(T.PLAN_PILL).toStartWith(`*${steps}* steps`); + expect(r.out).not.toContain('could not be read'); }); - test('`storebound play build --dry`: the plan (clock and [build] prefix left out, the gradle flags trimmed)', () => { - const p = T.MORE[1]!; - expect(p.cmd).toStartWith('storebound play build --dry'); - const d = buildProject(); + + test('products: `play products --dry` before, `catalog diff` after, with two products in the config', () => { + const cfg = join(dir, 'storebound.config.ts'); + const src = readFileSync(cfg, 'utf8'); + writeFileSync(cfg, src.replace(' dataSafety: {', ` products: [ + { id: 'com.example.app.no_ads', type: 'non_consumable', usd: 2.99, listings: { en: { title: 'No Ads', description: 'Removes every ad.' }, tr: { title: 'Reklamsız', description: 'Tüm reklamları kaldırır.' } } }, + { id: 'com.example.app.gems_100', type: 'consumable', usd: 0.99, listings: { en: { title: '100 Gems', description: 'A pouch of 100 gems.' }, tr: { title: '100 Mücevher', description: '100 mücevherlik bir kese.' } } }, + ], + dataSafety: {`)); try { - const out = run(p.cmd, d).split('\n').map(l => l.replace(/^\d\d:\d\d:\d\d \[build\] /, '').replace(/ \(\d+s\)$/, '')); - for (const l of p.lines) expect(out.some(o => o.startsWith(l)), l).toBe(true); - } finally { rmSync(d, { recursive: true, force: true }); } + const cmds = T.PRODUCT_LINES.filter(l => l.cmd).map(l => l.text.replace(/^\$ storebound /, '')); + expect(cmds).toEqual(['play products --dry', 'catalog diff']); + const before = run(cmds[0]!.split(' '), dir, { ...keys, TEASER_STORE: 'new' }); + const after = run(cmds[1]!.split(' '), dir, { ...keys, TEASER_STORE: 'catalog' }); + expect(before.code).toBe(0); + expect(after.code).toBe(0); + const out = [...lines(before.out), ...lines(after.out)]; + for (const l of T.PRODUCT_LINES.filter(x => !x.cmd)) expect(out, l.text).toContain(l.text); + // the pill's numbers are the region counts above, and the App Store's 175 storefronts + expect(Object.keys(ALPHA3)).toHaveLength(175); + expect(T.PRODUCTS_PILL.text).toContain('*175* App Store regions'); + expect(T.PRODUCTS_PILL.text).toContain('*174* Google Play regions'); + expect(out.join('\n')).toContain('0 mismatch(es), 0 warning(s), 0 price difference(s)'); + } finally { writeFileSync(cfg, src); } }); - test('`storebound console fill apple-app-privacy --dry` in examples/demo-app: answer lines (source column left out)', () => { - const p = T.MORE[2]!; - expect(p.cmd).toBe('storebound console fill apple-app-privacy --dry'); - const out = run(p.cmd, join(ROOT, 'examples/demo-app')).split('\n').map(l => l.trim().replace(/\s+\([^()]*\)$/, '')); - for (const l of p.lines) expect(out).toContain(l); - expect(out.join('\n')).toContain('press Publish yourself'); + + test('forms: the Data safety answer count of `storebound check`', () => { + expect(run(['check'], dir).out).toContain(`data safety: ${T.DECL_TOTAL} CSV rows`); }); }); describe('teaser: the scan text is real', () => { - test('command, header, SDKs and the risks line come from `storebound scan` of tests/fixtures/scan/teaser', () => { - expect(T.CMD).toBe('storebound scan'); - for (const l of T.SCAN_HEAD) expect(before).toContain(l.text); - for (const s of T.SDKS) expect(before).toMatch(new RegExp(`${s.name}\\s+${s.what.replace(/[()]/g, '\\$&')} · ${s.dep} \\(${s.where}\\)`)); + const scanText = (fixture: string, demo: boolean): string => { + const env = { REVIEW_DEMO_USER: demo ? 'demo@example.com' : '', REVIEW_DEMO_PASSWORD: demo ? 'example' : '' }; + const r = run(['scan', '--dir', join(FX, fixture)], ROOT, env); + expect(r.code).toBe(demo ? 0 : 1); // exit 1 on blockers (before the fixes) + return r.out; + }; + let before = '', after = ''; + beforeAll(() => { before = scanText('teaser', false); after = scanText('teaser-fixed', true); }); + + test('rejections: the risks line and three findings (severity, guideline, title, file:line)', () => { + expect(T.SCAN_CMD).toBe('storebound scan'); expect(before).toContain(T.RISKS_LINE); - }); - test('the five findings: severity, guideline, title, file:line, a verbatim piece of the fix, the skill', () => { - expect(T.FINDINGS).toHaveLength(5); const blocks = before.split(/\n\s+\d\. /).slice(1); - T.FINDINGS.forEach((f, i) => { - const b = blocks[i]!; - expect(b.startsWith(`${f.sev.padEnd(7)} ${f.guideline} · App Store · ${f.title}`)).toBe(true); - expect(b).toContain(`at ${f.where}`); - expect(b).toContain(`skill: ${f.skill}`); - expect(b.match(/fix: (.*)/)![1]).toContain(f.fix); - }); + for (const f of T.FINDINGS) { + const b = blocks.find(x => x.startsWith(`${f.sev.padEnd(7)} ${f.guideline} · App Store · ${f.title}`)); + expect(b, f.title).toBeDefined(); + expect(b!).toContain(`at ${f.where}`); + // the plain reason is an annotation, short enough to read + expect(f.why.split(' ').length, f.why).toBeLessThanOrEqual(10); + } }); - test('declarations proposal lines', () => { + test('rejections: the re-scan after the fixes (tests/fixtures/scan/teaser-fixed) is clean', () => { + expect(after).toContain(T.RESCAN_LINE); + }); + test('forms: the declarations proposal lines and the ask-owner line', () => { for (const d of T.DECL_LINES) expect(before).toContain(`detected ${d.what}: ${d.value}`); for (const d of T.DECL_LINES) expect(before).toContain(`(${d.where})`); expect(before).toContain(T.DECL_ASK); }); - test('the re-scan after the fixes (tests/fixtures/scan/teaser-fixed, demo account in the environment) is clean', () => { - expect(after).toContain(T.RESCAN_LINE); - expect(after).toContain(T.RESCAN_NONE); +}); + +describe('teaser: the store text and screenshots are the demo game\'s', () => { + test('copy: the hero title per language from examples/demo-game/store/shots/copy.json', () => { + const copy = JSON.parse(readFileSync(join(ROOT, 'examples/demo-game', T.COPY_FILE), 'utf8')) as Record; + for (const c of T.COPY) expect(c.title).toEqual(copy[c.lang]!.hero.title); + expect(T.SHOT_LANGS).toEqual(T.COPY.map(c => c.lang)); + }); + test('sizes: seven store sizes the demo game renders (iPhone, iPad, Play phone and tablets, feature graphic)', () => { + for (const s of T.SHOT_SIZES) expect(SIZES[s.id], s.id).toBeDefined(); + expect(T.SHOT_SIZES).toHaveLength(7); + expect(T.SHOTS_PILL).toBe(`*7* sizes × *${T.COPY.length}* languages`); + expect(T.TODO.map(x => x.text)).toContain('7 screenshot sizes × 14 languages'); + expect(T.TODO.map(x => x.text)).toContain('prices in 175 countries'); }); }); -describe('teaser: timing', () => { - const near = (x: number): boolean => Math.abs(x / T.BEAT - Math.round(x / T.BEAT)) < 1e-9; - test('scenes are contiguous, cover the video and cut on the beat', () => { +describe('teaser: timing and format', () => { + test('16:9 only: the master is 1920x1080; the pipeline has no vertical output', () => { + expect(T.FORMAT).toEqual({ w: 1920, h: 1080 }); + const render = readFileSync(join(ROOT, 'media/teaser/render.ts'), 'utf8'); + expect(render).not.toMatch(/1080\s*x\s*1920|w: 1080, h: 1920|vertical/i); + expect(render).toContain('scale=1280:720'); + }); + test('scenes are contiguous, 6-7 s each, 55-65 s in total', () => { expect(T.SCENES[0]!.start).toBe(0); for (let i = 1; i < T.SCENES.length; i++) expect(T.SCENES[i]!.start).toBe(T.SCENES[i - 1]!.end); - expect(T.SCENES.at(-1)!.end).toBeCloseTo(T.DURATION, 9); - for (const s of T.SCENES) expect(near(s.start), s.id).toBe(true); - expect(T.DURATION).toBeGreaterThan(29); - expect(T.DURATION).toBeLessThan(38); - }); - test('every scene holds at least 2.5 s', () => { - for (const s of T.SCENES) expect(s.end - s.start, s.id).toBeGreaterThanOrEqual(2.5); - }); - test('captions: at most 7 words, fully on screen for at least 1.2 s, never overlapping', () => { - const c = T.captionTimes(); - expect(c).toHaveLength(T.CAPTIONS.length); - for (const x of c) { - expect(x.count, x.words).toBeLessThanOrEqual(7); - expect(x.hold, x.words).toBeGreaterThanOrEqual(1.2); + for (const s of T.SCENES) { + expect(s.end - s.start, s.id).toBeGreaterThanOrEqual(6); + expect(s.end - s.start, s.id).toBeLessThanOrEqual(7); } - for (let i = 1; i < c.length; i++) expect(c[i]!.at).toBeGreaterThanOrEqual(c[i - 1]!.to); + expect(T.DURATION).toBe(T.SCENES.at(-1)!.end); + expect(T.DURATION).toBeGreaterThanOrEqual(55); + expect(T.DURATION).toBeLessThanOrEqual(65); + }); + test('one caption per scene, fully on screen for at least 4 s, inside its scene', () => { + const c = T.captionTimes(); + expect(c.map(x => x.id)).toEqual(T.SCENES.map(s => s.id)); + for (const x of c) { + const s = T.SCENES.find(y => y.id === x.id)!; + expect(x.hold, x.text).toBeGreaterThanOrEqual(4); + expect(x.at).toBeGreaterThanOrEqual(s.start); + expect(x.to).toBeLessThanOrEqual(s.end); + } + }); + test('the rejection mail holds at least 2 s before the first cut', () => { + expect(T.SCENES[0]!.end - T.MAIL.at - T.MAIL_IN).toBeGreaterThanOrEqual(2); + expect(T.MAIL.guideline).toStartWith('Guideline 2.1'); }); }); diff --git a/tools/site-icons.ts b/tools/site-icons.ts index 092e915c..5af2248f 100644 --- a/tools/site-icons.ts +++ b/tools/site-icons.ts @@ -18,7 +18,7 @@ export const SITE_ICONS = ['caret-right', 'play', 'user', 'squares-four', 'brief export const STORE_MARKS = ['appstore', 'googleplay'] as const; /** Teaser icons: [Phosphor weight, icon name], vendored as -.svg (the package's own file name). */ export const TEASER_ICONS = [['fill', 'navigation-arrow'], ['bold', 'check'], ['fill', 'x-circle'], ['fill', 'check-circle'], ['bold', 'tray'], - ['bold', 'magnifying-glass'], ['bold', 'pencil-simple'], ['fill', 'warning-octagon'], ['fill', 'paper-plane-tilt'], ['bold', 'terminal-window']] as const; + ['fill', 'warning-octagon'], ['fill', 'paper-plane-tilt'], ['bold', 'terminal-window']] as const; const root = new URL('..', import.meta.url).pathname; const phosphor = join(root, 'node_modules/@phosphor-icons/core');