Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

chore(dashboard): remove the 4.0.0 release moment (#1792)

Maurice143200cae6f3
diff --git a/client/src/components/FourZero/NoFearBeacon.test.tsx b/client/src/components/FourZero/NoFearBeacon.test.tsx
deleted file mode 100644
index ecc9e25fc..000000000
--- a/client/src/components/FourZero/NoFearBeacon.test.tsx
+++ /dev/null
@@ -1,381 +0,0 @@
-// FE-NOFEAR-BCN-001 to FE-NOFEAR-BCN-019
-import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
-import { render, screen, act, fireEvent } from '../../../tests/helpers/render'
-import NoFearBeacon from './NoFearBeacon'
-
-vi.mock('./NoFearShow', () => ({
- default: ({ onClose }: { onClose: () => void }) => (
- <div role="dialog" aria-label="show stub">
- <button type="button" onClick={onClose}>close show</button>
- </div>
- ),
-}))
-
-const DISMISS_KEY = 'trek.fourzero.dismissed'
-const POINT_COUNT = 24
-
-interface StrokeRecord {
- style: string
- width: number
-}
-
-interface FakeCtx {
- strokeStyle: string
- lineWidth: number
- fillStyle: string
- globalCompositeOperation: string
- setTransform: ReturnType<typeof vi.fn>
- clearRect: ReturnType<typeof vi.fn>
- beginPath: ReturnType<typeof vi.fn>
- moveTo: ReturnType<typeof vi.fn>
- lineTo: ReturnType<typeof vi.fn>
- stroke: ReturnType<typeof vi.fn>
- arc: ReturnType<typeof vi.fn>
- fill: ReturnType<typeof vi.fn>
- strokes: StrokeRecord[]
-}
-
-interface FakeObserver {
- cb: ResizeObserverCallback
- observe: ReturnType<typeof vi.fn>
- unobserve: ReturnType<typeof vi.fn>
- disconnect: ReturnType<typeof vi.fn>
-}
-
-let frames: FrameRequestCallback[] = []
-let cancelSpy: ReturnType<typeof vi.fn>
-let ctx: FakeCtx | null = null
-let observers: FakeObserver[] = []
-let randomQueue: number[] = []
-const originalGetContext = HTMLCanvasElement.prototype.getContext
-const OriginalResizeObserver = globalThis.ResizeObserver
-
-function makeCtx(): FakeCtx {
- const c: FakeCtx = {
- strokeStyle: '',
- lineWidth: 0,
- fillStyle: '',
- globalCompositeOperation: 'source-over',
- setTransform: vi.fn(),
- clearRect: vi.fn(),
- beginPath: vi.fn(),
- moveTo: vi.fn(),
- lineTo: vi.fn(),
- stroke: vi.fn(() => { c.strokes.push({ style: c.strokeStyle, width: c.lineWidth }) }),
- arc: vi.fn(),
- fill: vi.fn(),
- strokes: [],
- }
- return c
-}
-
-class FakeResizeObserver {
- observe = vi.fn()
- unobserve = vi.fn()
- disconnect = vi.fn()
- constructor(public cb: ResizeObserverCallback) { observers.push(this) }
-}
-
-/** Runs the pending rAF callback with the given timestamp (ms). */
-function frame(ms: number): void {
- const pending = frames
- frames = []
- act(() => { pending.forEach(cb => cb(ms)) })
-}
-
-function resetDrawCounters(): void {
- ctx?.moveTo.mockClear()
- ctx?.lineTo.mockClear()
- ctx?.arc.mockClear()
- ctx?.fill.mockClear()
- if (ctx) ctx.strokes.length = 0
-}
-
-function setReducedMotion(reduce: boolean): void {
- window.matchMedia = vi.fn().mockImplementation((query: string) => ({
- matches: reduce,
- media: query,
- onchange: null,
- addListener: vi.fn(),
- removeListener: vi.fn(),
- addEventListener: vi.fn(),
- removeEventListener: vi.fn(),
- dispatchEvent: vi.fn(),
- }))
-}
-
-beforeEach(() => {
- vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'Date'] })
- // Well inside the release window so the beacon is not retired by the calendar.
- vi.setSystemTime(new Date('2026-08-01T09:00:00'))
- frames = []
- observers = []
- cancelSpy = vi.fn()
- ctx = makeCtx()
- randomQueue = [0]
- let randomIdx = 0
- vi.spyOn(Math, 'random').mockImplementation(() => {
- const v = randomQueue[randomIdx % randomQueue.length]
- randomIdx++
- return v
- })
- vi.stubGlobal('requestAnimationFrame', vi.fn((cb: FrameRequestCallback) => {
- frames.push(cb)
- return frames.length
- }))
- vi.stubGlobal('cancelAnimationFrame', cancelSpy)
- globalThis.ResizeObserver = FakeResizeObserver as unknown as typeof ResizeObserver
- HTMLCanvasElement.prototype.getContext = vi.fn(() => ctx) as unknown as typeof originalGetContext
- Object.defineProperty(HTMLCanvasElement.prototype, 'clientWidth', { configurable: true, get: () => 800 })
- Object.defineProperty(HTMLCanvasElement.prototype, 'clientHeight', { configurable: true, get: () => 400 })
- Object.defineProperty(window, 'devicePixelRatio', { configurable: true, writable: true, value: 1 })
- setReducedMotion(false)
-})
-
-afterEach(() => {
- HTMLCanvasElement.prototype.getContext = originalGetContext
- Reflect.deleteProperty(HTMLCanvasElement.prototype, 'clientWidth')
- Reflect.deleteProperty(HTMLCanvasElement.prototype, 'clientHeight')
- globalThis.ResizeObserver = OriginalResizeObserver
- vi.unstubAllGlobals()
- vi.restoreAllMocks()
- vi.useRealTimers()
-})
-
-describe('NoFearBeacon', () => {
- it('FE-NOFEAR-BCN-001: renders the trigger card with title, subtitle and retirement badge', () => {
- render(<NoFearBeacon />)
-
- const play = screen.getByRole('button', { name: 'Press play.' })
- expect(play).toHaveTextContent('NO FEAR')
- expect(play).toHaveTextContent('A sign for an open world.')
- expect(screen.getByText('Shown until Aug 23')).toBeInTheDocument()
- expect(screen.getByRole('button', { name: 'Dismiss' })).toBeInTheDocument()
- })
-
- it('FE-NOFEAR-BCN-002: renders nothing once the release window has passed', () => {
- vi.setSystemTime(new Date('2026-08-24T00:00:01'))
-
- const { container } = render(<NoFearBeacon />)
-
- expect(container).toBeEmptyDOMElement()
- expect(screen.queryByText('NO FEAR')).toBeNull()
- })
-
- it('FE-NOFEAR-BCN-003: stays hidden when it was dismissed before', () => {
- localStorage.setItem(DISMISS_KEY, '1')
-
- const { container } = render(<NoFearBeacon />)
-
- expect(container).toBeEmptyDOMElement()
- })
-
- it('FE-NOFEAR-BCN-004: still renders when localStorage cannot be read', () => {
- vi.spyOn(Storage.prototype, 'getItem').mockImplementation((key: string) => {
- if (key === DISMISS_KEY) throw new Error('storage blocked')
- return null
- })
-
- render(<NoFearBeacon />)
-
- expect(screen.getByText('NO FEAR')).toBeInTheDocument()
- })
-
- it('FE-NOFEAR-BCN-005: needs two clicks to retire the moment and persists the choice', () => {
- render(<NoFearBeacon />)
- const dismiss = screen.getByRole('button', { name: 'Dismiss' })
-
- fireEvent.click(dismiss)
-
- expect(dismiss).toHaveTextContent('Hide for good?')
- expect(dismiss).toHaveClass('fz-beacon-dismiss-confirm')
- expect(screen.getByText('NO FEAR')).toBeInTheDocument()
-
- fireEvent.click(dismiss)
-
- expect(screen.queryByText('NO FEAR')).toBeNull()
- expect(localStorage.getItem(DISMISS_KEY)).toBe('1')
- })
-
- it('FE-NOFEAR-BCN-006: disarms the confirm state when the pointer leaves', () => {
- render(<NoFearBeacon />)
- const dismiss = screen.getByRole('button', { name: 'Dismiss' })
-
- fireEvent.click(dismiss)
- expect(dismiss).toHaveTextContent('Hide for good?')
-
- fireEvent.mouseLeave(dismiss)
-
- expect(dismiss).not.toHaveTextContent('Hide for good?')
- expect(dismiss).not.toHaveClass('fz-beacon-dismiss-confirm')
- })
-
- it('FE-NOFEAR-BCN-007: disarms the confirm state on blur', () => {
- render(<NoFearBeacon />)
- const dismiss = screen.getByRole('button', { name: 'Dismiss' })
-
- fireEvent.click(dismiss)
- fireEvent.blur(dismiss)
-
- expect(dismiss).not.toHaveTextContent('Hide for good?')
- })
-
- it('FE-NOFEAR-BCN-008: hides for the session when the choice cannot be persisted', () => {
- vi.spyOn(Storage.prototype, 'setItem').mockImplementation(() => { throw new Error('quota') })
- render(<NoFearBeacon />)
- const dismiss = screen.getByRole('button', { name: 'Dismiss' })
-
- fireEvent.click(dismiss)
- fireEvent.click(dismiss)
-
- expect(screen.queryByText('NO FEAR')).toBeNull()
- })
-
- it('FE-NOFEAR-BCN-009: opens the show on play and closes it again', async () => {
- render(<NoFearBeacon />)
- expect(screen.queryByRole('dialog')).toBeNull()
-
- fireEvent.click(screen.getByRole('button', { name: 'Press play.' }))
- await act(async () => { await Promise.resolve() })
-
- expect(screen.getByRole('dialog', { name: 'show stub' })).toBeInTheDocument()
-
- fireEvent.click(screen.getByRole('button', { name: 'close show' }))
-
- expect(screen.queryByRole('dialog')).toBeNull()
- expect(screen.getByText('NO FEAR')).toBeInTheDocument()
- })
-
- it('FE-NOFEAR-BCN-010: sizes the teaser canvas by capped device pixel ratio', () => {
- Object.defineProperty(window, 'devicePixelRatio', { configurable: true, writable: true, value: 3 })
-
- render(<NoFearBeacon />)
-
- const canvas = document.querySelector<HTMLCanvasElement>('canvas.fz-beacon-canvas')
- expect(canvas?.width).toBe(1200)
- expect(canvas?.height).toBe(600)
- expect(ctx?.setTransform).toHaveBeenCalledWith(1.5, 0, 0, 1.5, 0, 0)
- expect(observers[0].observe).toHaveBeenCalledWith(canvas)
- })
-
- it('FE-NOFEAR-BCN-011: re-fits the canvas when the observer reports a resize', () => {
- render(<NoFearBeacon />)
- expect(ctx?.setTransform).toHaveBeenCalledTimes(1)
-
- act(() => { observers[0].cb([], observers[0] as unknown as ResizeObserver) })
-
- expect(ctx?.setTransform).toHaveBeenCalledTimes(2)
- })
-
- it('FE-NOFEAR-BCN-012: breathes every light twice per frame and keeps animating', () => {
- render(<NoFearBeacon />)
-
- frame(0)
-
- expect(ctx?.clearRect).toHaveBeenCalledWith(0, 0, 800, 400)
- expect(ctx?.arc).toHaveBeenCalledTimes(POINT_COUNT * 2)
- expect(ctx?.fill).toHaveBeenCalledTimes(POINT_COUNT * 2)
- expect(ctx?.moveTo).not.toHaveBeenCalled()
- expect(ctx?.globalCompositeOperation).toBe('source-over')
- expect(frames).toHaveLength(1)
- })
-
- it('FE-NOFEAR-BCN-013: spawns a golden arc between two distant lights and grows it', () => {
- // a = point 0, first b throwaway, then a far point so the search breaks at once.
- randomQueue = [0, 0, 0.9]
- render(<NoFearBeacon />)
-
- frame(0)
- resetDrawCounters()
-
- frame(2000)
- expect(ctx?.moveTo).toHaveBeenCalledTimes(1)
- // Two passes per arc: wide warm halo, then the bright core.
- expect(ctx?.strokes).toEqual([
- { style: 'rgba(255, 180, 95, 0.12)', width: 3.4 },
- { style: 'rgba(255, 208, 130, 0.55)', width: 1.1 },
- ])
- const partial = ctx?.lineTo.mock.calls.length ?? 0
- expect(partial).toBeGreaterThan(0)
- expect(partial).toBeLessThan(22)
-
- resetDrawCounters()
- frame(3600)
- expect(ctx?.lineTo).toHaveBeenCalledTimes(22)
- })
-
- it('FE-NOFEAR-BCN-014: fades an arc out and drops it once it is older than 4.5s', () => {
- randomQueue = [0, 0, 0.9]
- render(<NoFearBeacon />)
-
- frame(0)
- frame(2000)
-
- // 3.75s old: half faded, drawn behind the arc that just spawned.
- resetDrawCounters()
- frame(5750)
- expect(ctx?.moveTo).toHaveBeenCalledTimes(2)
- expect(ctx?.strokes.slice(2)).toEqual([
- { style: 'rgba(255, 180, 95, 0.06)', width: 3.4 },
- { style: 'rgba(255, 208, 130, 0.275)', width: 1.1 },
- ])
-
- // Past 4.5s it is dropped and only the younger arc remains.
- resetDrawCounters()
- frame(7000)
- expect(ctx?.moveTo).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-BCN-015: gives up looking for a distant partner after six tries', () => {
- // Every draw returns the same index, so no candidate is ever far enough away.
- randomQueue = [0]
- render(<NoFearBeacon />)
-
- frame(0)
- resetDrawCounters()
- frame(2000)
-
- expect(ctx?.moveTo).toHaveBeenCalledTimes(1)
- expect(Math.random).toHaveBeenCalledTimes(8)
- })
-
- it('FE-NOFEAR-BCN-016: paints a single frame and stops when motion is reduced', () => {
- setReducedMotion(true)
-
- render(<NoFearBeacon />)
- expect(frames).toHaveLength(1)
-
- frame(0)
-
- expect(ctx?.fill).toHaveBeenCalledTimes(POINT_COUNT * 2)
- expect(frames).toHaveLength(0)
- })
-
- it('FE-NOFEAR-BCN-017: skips the teaser entirely without a 2d context', () => {
- ctx = null
-
- render(<NoFearBeacon />)
-
- expect(frames).toHaveLength(0)
- expect(observers).toHaveLength(0)
- expect(screen.getByText('NO FEAR')).toBeInTheDocument()
- })
-
- it('FE-NOFEAR-BCN-018: cancels the frame and disconnects the observer on unmount', () => {
- const { unmount } = render(<NoFearBeacon />)
-
- unmount()
-
- expect(cancelSpy).toHaveBeenCalled()
- expect(observers[0].disconnect).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-BCN-019: falls back to a pixel ratio of 1 when the browser reports none', () => {
- Object.defineProperty(window, 'devicePixelRatio', { configurable: true, writable: true, value: 0 })
-
- render(<NoFearBeacon />)
-
- expect(document.querySelector<HTMLCanvasElement>('canvas.fz-beacon-canvas')?.width).toBe(800)
- expect(ctx?.setTransform).toHaveBeenCalledWith(1, 0, 0, 1, 0, 0)
- })
-})
diff --git a/client/src/components/FourZero/NoFearBeacon.tsx b/client/src/components/FourZero/NoFearBeacon.tsx
deleted file mode 100644
index 5f0db5743..000000000
--- a/client/src/components/FourZero/NoFearBeacon.tsx
+++ /dev/null
@@ -1,180 +0,0 @@
-import { lazy, Suspense, useEffect, useRef, useState } from 'react'
-import { X } from 'lucide-react'
-import { useTranslation } from '../../i18n'
-import { noFearChrome, noFearCopy } from './noFearLines'
-import './fourzero.css'
-
-// TREK 4.0.0 release moment — remove together with the FourZero folder.
-
-const NoFearShow = lazy(() => import('./NoFearShow'))
-
-// The moment retires itself. Last day it shows: 2026-08-23 (local midnight after
-// it ends the run). After that the beacon renders nothing even if the folder is
-// still in the build — so self-hosters who don't update past this version still
-// see it disappear on time. The end date holds regardless of updates.
-const VISIBLE_UNTIL = new Date('2026-08-24T00:00:00').getTime()
-const DISMISS_KEY = 'trek.fourzero.dismissed'
-
-// Abstract night-world for the teaser: light points loosely shaped like the
-// inhabited continents (relative coords), between which golden arcs travel.
-const TEASER_POINTS: [number, number][] = [
- [0.46, 0.28], [0.5, 0.22], [0.53, 0.3], [0.48, 0.38], [0.55, 0.42], [0.44, 0.5],
- [0.58, 0.55], [0.52, 0.62], [0.62, 0.3], [0.68, 0.4], [0.74, 0.32], [0.8, 0.45],
- [0.84, 0.58], [0.88, 0.36], [0.2, 0.3], [0.14, 0.4], [0.24, 0.52], [0.3, 0.66],
- [0.26, 0.78], [0.34, 0.35], [0.9, 0.72], [0.66, 0.68], [0.1, 0.26], [0.4, 0.72],
-]
-
-interface TeaserArc { a: number; b: number; born: number }
-
-/** The living background of the beacon: pulsing lights, traveling golden arcs. */
-function TeaserCanvas() {
- const ref = useRef<HTMLCanvasElement>(null)
- useEffect(() => {
- const cv = ref.current
- const c = cv?.getContext('2d')
- if (!cv || !c) return
- const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches
- const dpr = Math.min(window.devicePixelRatio || 1, 1.5)
- const fit = () => {
- cv.width = Math.round(cv.clientWidth * dpr)
- cv.height = Math.round(cv.clientHeight * dpr)
- c.setTransform(dpr, 0, 0, dpr, 0, 0)
- }
- fit()
- const ro = new ResizeObserver(fit)
- ro.observe(cv)
- const arcs: TeaserArc[] = []
- let last = 0
- let raf = 0
- const draw = (now: number) => {
- const t = now / 1000
- const w = cv.clientWidth
- const h = cv.clientHeight
- c.clearRect(0, 0, w, h)
- // A new arc every ~1.6s between two far-apart lights.
- if (t - last > 1.6 && arcs.length < 7) {
- last = t
- const a = Math.floor(Math.random() * TEASER_POINTS.length)
- let b = Math.floor(Math.random() * TEASER_POINTS.length)
- for (let tries = 0; tries < 6; tries++) {
- b = Math.floor(Math.random() * TEASER_POINTS.length)
- if (Math.abs(TEASER_POINTS[a][0] - TEASER_POINTS[b][0]) > 0.22) break
- }
- arcs.push({ a, b, born: t })
- }
- c.globalCompositeOperation = 'lighter'
- // Arcs: grow 1.4s, glow, fade until 4.5s.
- for (let i = arcs.length - 1; i >= 0; i--) {
- const arc = arcs[i]
- const age = t - arc.born
- if (age > 4.5) { arcs.splice(i, 1); continue }
- const grow = Math.min(age / 1.4, 1)
- const fade = age < 3 ? 1 : 1 - (age - 3) / 1.5
- const [ax, ay] = TEASER_POINTS[arc.a]
- const [bx, by] = TEASER_POINTS[arc.b]
- const x1 = ax * w; const y1 = ay * h
- const x2 = bx * w; const y2 = by * h
- const mx = (x1 + x2) / 2
- const my = (y1 + y2) / 2 - Math.min(Math.abs(x2 - x1) * 0.35, h * 0.34)
- c.beginPath()
- const steps = 22
- const eased = 1 - (1 - grow) ** 3
- const upto = Math.floor(steps * eased)
- const pt = (q: number): [number, number] => [
- (1 - q) * (1 - q) * x1 + 2 * (1 - q) * q * mx + q * q * x2,
- (1 - q) * (1 - q) * y1 + 2 * (1 - q) * q * my + q * q * y2,
- ]
- for (let s = 0; s <= upto; s++) {
- const [ix, iy] = pt(s / steps)
- if (s === 0) c.moveTo(ix, iy)
- else c.lineTo(ix, iy)
- }
- if (eased < 1) {
- const [tx, ty] = pt(eased)
- c.lineTo(tx, ty)
- }
- c.strokeStyle = `rgba(255, 180, 95, ${0.12 * fade})`
- c.lineWidth = 3.4
- c.stroke()
- c.strokeStyle = `rgba(255, 208, 130, ${0.55 * fade})`
- c.lineWidth = 1.1
- c.stroke()
- }
- // Lights: soft breathing points.
- for (let i = 0; i < TEASER_POINTS.length; i++) {
- const [px, py] = TEASER_POINTS[i]
- const breathe = 0.55 + 0.45 * Math.sin(t * 1.4 + i * 1.7)
- c.fillStyle = `rgba(255, 214, 150, ${0.5 * breathe})`
- c.beginPath()
- c.arc(px * w, py * h, 1.4 + breathe * 0.8, 0, Math.PI * 2)
- c.fill()
- c.fillStyle = `rgba(255, 190, 110, ${0.1 * breathe})`
- c.beginPath()
- c.arc(px * w, py * h, 6 + breathe * 3, 0, Math.PI * 2)
- c.fill()
- }
- c.globalCompositeOperation = 'source-over'
- if (!reduced) raf = requestAnimationFrame(draw)
- }
- raf = requestAnimationFrame(draw)
- return () => { cancelAnimationFrame(raf); ro.disconnect() }
- }, [])
- return <canvas ref={ref} className="fz-beacon-canvas" aria-hidden />
-}
-
-/**
- * The dashboard trigger for the 4.0.0 "KEINE ANGST" show: a dark cinematic card
- * with a living web of golden travel arcs (desktop only). One click starts the
- * show. Core colors ride inline so no dashboard widget CSS can wash them out.
- */
-export default function NoFearBeacon() {
- const { language } = useTranslation()
- const copy = noFearCopy(language)
- const chrome = noFearChrome(language)
- const [open, setOpen] = useState(false)
- const [confirming, setConfirming] = useState(false)
- const [dismissed, setDismissed] = useState(() => {
- try { return localStorage.getItem(DISMISS_KEY) === '1' } catch { return false }
- })
-
- // Past the end date, or dismissed for good — nothing renders.
- if (dismissed || Date.now() >= VISIBLE_UNTIL) return null
-
- const dismiss = () => {
- try { localStorage.setItem(DISMISS_KEY, '1') } catch { /* private mode — hide for this session at least */ }
- setDismissed(true)
- }
-
- return (
- <>
- <div className="fz-beacon" style={{ background: '#07080d', color: '#f5f2ea' }}>
- <TeaserCanvas />
- <div className="fz-beacon-glow" aria-hidden />
- <button type="button" className="fz-beacon-play" aria-label={copy.beaconCta} onClick={() => setOpen(true)}>
- <span className="fz-beacon-title">{copy.beaconTitle}</span>
- <span className="fz-beacon-sub" style={{ color: 'rgba(245, 240, 225, 0.75)' }}>{copy.beaconSub}</span>
- </button>
- {/* Top-right X: two-step so a stray click can't retire the moment for good.
- Dismissing is permanent (localStorage) — only an update brings it back. */}
- <button
- type="button"
- className={`fz-beacon-dismiss ${confirming ? 'fz-beacon-dismiss-confirm' : ''}`}
- aria-label={chrome.dismiss}
- title={chrome.dismiss}
- onClick={() => (confirming ? dismiss() : setConfirming(true))}
- onMouseLeave={() => setConfirming(false)}
- onBlur={() => setConfirming(false)}
- >
- {confirming ? chrome.confirm : <X size={15} />}
- </button>
- {/* White retirement badge: viewable until Aug 23. */}
- <span className="fz-beacon-until">{chrome.until}</span>
- </div>
- {open && (
- <Suspense fallback={null}>
- <NoFearShow onClose={() => setOpen(false)} />
- </Suspense>
- )}
- </>
- )
-}
diff --git a/client/src/components/FourZero/NoFearShow.test.tsx b/client/src/components/FourZero/NoFearShow.test.tsx
deleted file mode 100644
index 2de2a7628..000000000
--- a/client/src/components/FourZero/NoFearShow.test.tsx
+++ /dev/null
@@ -1,662 +0,0 @@
-// FE-NOFEAR-SHOW-001 to FE-NOFEAR-SHOW-035
-import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
-import { render, screen, act } from '../../../tests/helpers/render'
-import apiClient, { placesApi, tripsApi } from '../../api/client'
-import NoFearShow from './NoFearShow'
-
-interface AudioStub {
- start: ReturnType<typeof vi.fn>
- setMuted: ReturnType<typeof vi.fn>
- resume: ReturnType<typeof vi.fn>
- setSuspended: ReturnType<typeof vi.fn>
- swell: ReturnType<typeof vi.fn>
- impact: ReturnType<typeof vi.fn>
- setAct: ReturnType<typeof vi.fn>
- dispose: ReturnType<typeof vi.fn>
-}
-
-interface SceneStub {
- layout: ReturnType<typeof vi.fn>
- load: ReturnType<typeof vi.fn>
- setPersonalPlaces: ReturnType<typeof vi.fn>
- draw: ReturnType<typeof vi.fn>
-}
-
-interface AssemblyStub {
- init: ReturnType<typeof vi.fn>
- draw: ReturnType<typeof vi.fn>
- isReady: ReturnType<typeof vi.fn>
-}
-
-// Audio, scene and the finale's particle assembly are replaced wholesale: this
-// suite is about the React shell (acts, clock, portal, teardown), not WebAudio
-// or canvas painting, both of which have their own unit tests.
-const stubs = vi.hoisted(() => {
- const audio: AudioStub[] = []
- const scene: SceneStub[] = []
- const assembly: AssemblyStub[] = []
- class FakeAudio {
- start = vi.fn()
- setMuted = vi.fn()
- resume = vi.fn()
- setSuspended = vi.fn()
- swell = vi.fn()
- impact = vi.fn()
- setAct = vi.fn()
- dispose = vi.fn()
- constructor() { audio.push(this) }
- }
- class FakeScene {
- layout = vi.fn()
- load = vi.fn()
- setPersonalPlaces = vi.fn()
- draw = vi.fn()
- constructor() { scene.push(this) }
- }
- class FakeAssembly {
- init = vi.fn()
- draw = vi.fn()
- isReady = vi.fn()
- constructor() { assembly.push(this) }
- }
- return { audio, scene, assembly, FakeAudio, FakeScene, FakeAssembly }
-})
-
-vi.mock('./noFearAudio', () => ({ NoFearAudio: stubs.FakeAudio }))
-vi.mock('./noFearScene', () => ({ NoFearScene: stubs.FakeScene }))
-vi.mock('./noFearAssembly', () => ({ TextAssembly: stubs.FakeAssembly }))
-
-const LINES = {
- afraid: 'They want you to be afraid.',
- ofTheStranger: 'Afraid of the stranger. Afraid of everything you don’t know.',
- fearTool: 'Because fear closes borders — first on maps, then in minds.',
- hateTrade: 'Fear is their tool. Hatred is their trade.',
- butYouTraveled: 'But you have traveled.',
- tables: 'You have eaten at foreign tables. Slept under foreign roofs. Laughed with strangers.',
- notAnOpinion: 'Racism is not an opinion. Fascism is not an alternative.',
- everyDot: 'Every one of these lights is a table where someone was welcome.',
- yourPlaces: 'This — this was you.',
-}
-
-let nowMs = 0
-let frames: FrameRequestCallback[] = []
-let cancelSpy: ReturnType<typeof vi.fn>
-let ctxStub: { setTransform: ReturnType<typeof vi.fn> } | null = null
-const originalGetContext = HTMLCanvasElement.prototype.getContext
-
-const audio = () => stubs.audio[0]
-const scene = () => stubs.scene[0]
-
-/** Runs the pending rAF callback at the given show time (seconds). */
-function frame(seconds: number): void {
- nowMs = seconds * 1000
- const pending = frames
- frames = []
- act(() => { pending.forEach(cb => cb(nowMs)) })
-}
-
-async function flush(): Promise<void> {
- await act(async () => {
- for (let i = 0; i < 12; i++) await Promise.resolve()
- })
-}
-
-function canvas(): HTMLCanvasElement {
- const el = document.querySelector<HTMLCanvasElement>('canvas.fz-canvas')
- if (!el) throw new Error('show canvas missing')
- return el
-}
-
-/** The scene state handed to the canvas on the most recent frame. */
-function lastSceneState(): { opacity: number; particles: number } {
- const calls = scene().draw.mock.calls
- return calls[calls.length - 1][1] as { opacity: number; particles: number }
-}
-
-/** Visible line text, normalised across the sentence-by-sentence reveal. */
-function lineText(): string {
- const el = document.querySelector('.fz-line:not(.fz-line-ghost)')
- return (el?.textContent ?? '').replace(/\s+/g, ' ').trim()
-}
-
-function setReducedMotion(reduce: boolean): void {
- window.matchMedia = vi.fn().mockImplementation((query: string) => ({
- matches: reduce,
- media: query,
- onchange: null,
- addListener: vi.fn(),
- removeListener: vi.fn(),
- addEventListener: vi.fn(),
- removeEventListener: vi.fn(),
- dispatchEvent: vi.fn(),
- }))
-}
-
-beforeEach(() => {
- vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'Date'] })
- nowMs = 0
- frames = []
- stubs.audio.length = 0
- stubs.scene.length = 0
- stubs.assembly.length = 0
- cancelSpy = vi.fn()
- ctxStub = { setTransform: vi.fn() }
- vi.spyOn(performance, 'now').mockImplementation(() => nowMs)
- vi.stubGlobal('requestAnimationFrame', vi.fn((cb: FrameRequestCallback) => {
- frames.push(cb)
- return frames.length
- }))
- vi.stubGlobal('cancelAnimationFrame', cancelSpy)
- HTMLCanvasElement.prototype.getContext = vi.fn(() => ctxStub) as unknown as typeof originalGetContext
- Object.defineProperty(HTMLCanvasElement.prototype, 'clientWidth', { configurable: true, get: () => 800 })
- Object.defineProperty(HTMLCanvasElement.prototype, 'clientHeight', { configurable: true, get: () => 600 })
- Object.defineProperty(window, 'devicePixelRatio', { configurable: true, writable: true, value: 1 })
- setReducedMotion(false)
- // No traveler data by default — the generic show.
- vi.spyOn(tripsApi, 'list').mockResolvedValue([])
- vi.spyOn(placesApi, 'list').mockResolvedValue([])
- vi.spyOn(apiClient, 'get').mockRejectedValue(new Error('no atlas'))
-})
-
-afterEach(() => {
- HTMLCanvasElement.prototype.getContext = originalGetContext
- Reflect.deleteProperty(HTMLCanvasElement.prototype, 'clientWidth')
- Reflect.deleteProperty(HTMLCanvasElement.prototype, 'clientHeight')
- vi.unstubAllGlobals()
- vi.restoreAllMocks()
- vi.useRealTimers()
- document.body.classList.remove('fz-show-open')
-})
-
-describe('NoFearShow', () => {
- it('FE-NOFEAR-SHOW-001: portals a labelled dialog into the body and locks the page chrome', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- const dialog = screen.getByRole('dialog', { name: 'NO FEAR' })
- expect(dialog).toHaveAttribute('aria-modal', 'true')
- expect(dialog.parentElement).toBe(document.body)
- expect(document.body).toHaveClass('fz-show-open')
- })
-
- it('FE-NOFEAR-SHOW-002: boots audio and scene and starts the soundtrack', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- expect(stubs.audio).toHaveLength(1)
- expect(stubs.scene).toHaveLength(1)
- expect(audio().start).toHaveBeenCalledTimes(1)
- expect(scene().layout).toHaveBeenCalledWith(800, 600)
- })
-
- it('FE-NOFEAR-SHOW-003: sizes the canvas by capped device pixel ratio', () => {
- Object.defineProperty(window, 'devicePixelRatio', { configurable: true, writable: true, value: 4 })
-
- render(<NoFearShow onClose={vi.fn()} />)
-
- expect(canvas().width).toBe(1400)
- expect(canvas().height).toBe(1050)
- expect(ctxStub?.setTransform).toHaveBeenCalledWith(1.75, 0, 0, 1.75, 0, 0)
- })
-
- it('FE-NOFEAR-SHOW-004: loads the scene with a live abort signal that aborts on unmount', () => {
- const { unmount } = render(<NoFearShow onClose={vi.fn()} />)
-
- const signal = scene().load.mock.calls[0][2] as AbortSignal
- expect(scene().load).toHaveBeenCalledWith(800, 600, signal)
- expect(signal.aborted).toBe(false)
-
- unmount()
- expect(signal.aborted).toBe(true)
- })
-
- it('FE-NOFEAR-SHOW-005: coalesces a resize storm into a single re-fit', () => {
- render(<NoFearShow onClose={vi.fn()} />)
- expect(scene().layout).toHaveBeenCalledTimes(1)
-
- act(() => {
- for (let i = 0; i < 20; i++) window.dispatchEvent(new Event('resize'))
- })
- // layout() rebakes every static layer, so nothing happens while the drag runs
- expect(scene().layout).toHaveBeenCalledTimes(1)
-
- act(() => { vi.advanceTimersByTime(150) })
-
- expect(scene().layout).toHaveBeenCalledTimes(2)
- expect(scene().layout).toHaveBeenLastCalledWith(800, 600)
- })
-
- it('FE-NOFEAR-SHOW-006: shows no line before the first cue', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(0.2)
-
- expect(document.querySelector('.fz-line')).toBeNull()
- expect(audio().setAct).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-SHOW-007: opens on the fear act with the first line', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(0.9)
-
- expect(lineText()).toBe(LINES.afraid)
- expect(audio().setAct).toHaveBeenCalledWith('fear')
- expect(scene().draw).toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-SHOW-008: decays the replaced fear line into a per-character ghost', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(0.9)
- expect(document.querySelector('.fz-line-ghost')).toBeNull()
-
- frame(6.1)
- expect(lineText()).toBe(LINES.ofTheStranger)
- const ghost = document.querySelector('.fz-line-ghost')
- expect(ghost).not.toBeNull()
- expect(ghost?.querySelectorAll('.fz-char-decay')).toHaveLength(LINES.afraid.length)
-
- // Once its letters have decayed the ghost retires itself.
- act(() => { vi.advanceTimersByTime(1400) })
- expect(document.querySelector('.fz-line-ghost')).toBeNull()
-
- frame(12.1)
- const ghostText = document.querySelector('.fz-line-ghost')?.textContent ?? ''
- expect(ghostText.replace(/\u00a0/g, ' ')).toBe(LINES.ofTheStranger)
- })
-
- it('FE-NOFEAR-SHOW-009: raises the red vignette while the borders burn', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(12.1)
- expect(lineText()).toBe(LINES.fearTool)
- expect(audio().setAct).toHaveBeenLastCalledWith('dread')
- expect(document.querySelector('.fz-vignette')).not.toBeNull()
-
- frame(18.6)
- expect(lineText()).toBe(LINES.hateTrade)
- expect(document.querySelector('.fz-vignette')).not.toBeNull()
-
- frame(26.1)
- expect(document.querySelector('.fz-vignette')).toBeNull()
- })
-
- it('FE-NOFEAR-SHOW-010: strobes the staccato words and hides the line inside a flash window', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(18.6)
- expect(lineText()).toBe(LINES.hateTrade)
-
- frame(22.5)
- expect(screen.getByText('FEAR.')).toBeInTheDocument()
- expect(document.querySelector('.fz-line')).toBeNull()
-
- frame(23.8)
- expect(screen.getByText('HATRED.')).toBeInTheDocument()
-
- frame(25.2)
- expect(screen.getByText('WALLS.')).toBeInTheDocument()
-
- frame(25.8)
- expect(document.querySelector('.fz-flash')).toBeNull()
- expect(lineText()).toBe(LINES.hateTrade)
- })
-
- it('FE-NOFEAR-SHOW-011: cuts to silence with no line at all', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(18.6)
- frame(26.2)
-
- expect(audio().setAct).toHaveBeenLastCalledWith('silence')
- expect(document.querySelector('.fz-line:not(.fz-line-ghost)')).toBeNull()
- })
-
- it('FE-NOFEAR-SHOW-012: swells into the soft pivot line', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(26.2)
- frame(28.6)
-
- expect(lineText()).toBe(LINES.butYouTraveled)
- expect(document.querySelector('.fz-line-soft')).not.toBeNull()
- expect(audio().swell).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-SHOW-013: reveals hope-act lines sentence by sentence', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(34.1)
-
- expect(audio().setAct).toHaveBeenLastCalledWith('hope')
- expect(lineText()).toBe(LINES.tables)
- const segments = document.querySelectorAll('.fz-seg')
- expect(segments).toHaveLength(3)
- expect(segments[0].textContent?.trim()).toBe('You have eaten at foreign tables.')
- expect((segments[2] as HTMLElement).style.animationDelay).toBe('1.9s')
- })
-
- it('FE-NOFEAR-SHOW-014: renders the hard line unsegmented and punches the audio', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(34.1)
- frame(64.1)
-
- expect(lineText()).toBe(LINES.notAnOpinion)
- expect(document.querySelector('.fz-line-hard')).not.toBeNull()
- expect(document.querySelectorAll('.fz-seg')).toHaveLength(0)
- expect(audio().impact).toHaveBeenCalledWith(1)
- })
-
- it('FE-NOFEAR-SHOW-015: falls back to the generic line when the traveler has no data', async () => {
- render(<NoFearShow onClose={vi.fn()} />)
- await flush()
-
- frame(55.6)
- expect(lineText()).toBe(LINES.everyDot)
- expect(audio().impact).toHaveBeenCalledWith(0.35)
-
- frame(58.9)
- expect(lineText()).toBe(LINES.everyDot)
- expect(scene().setPersonalPlaces).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-SHOW-016: feeds the traveler places into the scene and states the country count', async () => {
- vi.mocked(tripsApi.list).mockResolvedValue([{ id: 1 }, { id: 2 }])
- vi.mocked(placesApi.list).mockResolvedValue([
- { lat: 48.1, lng: 11.5 },
- { lat: 52.5, lng: 13.4 },
- { lat: null, lng: 9.9 },
- ])
- vi.mocked(apiClient.get).mockResolvedValue({ data: { stats: { totalCountries: 9 } } })
-
- render(<NoFearShow onClose={vi.fn()} />)
- await flush()
-
- expect(scene().setPersonalPlaces).toHaveBeenCalledWith([
- { lat: 48.1, lng: 11.5 },
- { lat: 52.5, lng: 13.4 },
- { lat: 48.1, lng: 11.5 },
- { lat: 52.5, lng: 13.4 },
- ])
-
- frame(55.6)
- expect(lineText()).toBe(LINES.yourPlaces)
-
- frame(58.9)
- expect(lineText()).toBe('4 places. 9 countries. And not once did the world hurt you.')
- })
-
- it('FE-NOFEAR-SHOW-017: falls back to trip counts when Atlas reports no countries', async () => {
- vi.mocked(tripsApi.list).mockResolvedValue([{ id: 1 }, { id: 2 }, { id: 3 }])
- vi.mocked(placesApi.list).mockResolvedValue([{ lat: 1, lng: 2 }])
- vi.mocked(apiClient.get).mockResolvedValue({ data: { stats: { totalCountries: 0 } } })
-
- render(<NoFearShow onClose={vi.fn()} />)
- await flush()
-
- frame(58.9)
-
- expect(lineText()).toBe('3 places. 3 journeys. And not once did the world hurt you.')
- })
-
- it('FE-NOFEAR-SHOW-018: falls back to trip counts when the Atlas request fails', async () => {
- vi.mocked(tripsApi.list).mockResolvedValue([{ id: 7 }])
- vi.mocked(placesApi.list).mockResolvedValue([
- { lat: 1, lng: 2 },
- { lat: 3, lng: 4 },
- { lat: 5, lng: 6 },
- ])
-
- render(<NoFearShow onClose={vi.fn()} />)
- await flush()
-
- frame(58.9)
-
- expect(lineText()).toBe('3 places. 1 journeys. And not once did the world hurt you.')
- })
-
- it('FE-NOFEAR-SHOW-019: ignores a trip whose places fail to load and skips thin data sets', async () => {
- vi.mocked(tripsApi.list).mockResolvedValue([{ id: 1 }, { id: 2 }])
- vi.mocked(placesApi.list)
- .mockResolvedValueOnce([{ lat: 1, lng: 2 }])
- .mockRejectedValueOnce(new Error('boom'))
-
- render(<NoFearShow onClose={vi.fn()} />)
- await flush()
-
- expect(scene().setPersonalPlaces).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-SHOW-020: survives a failing trip list', async () => {
- vi.mocked(tripsApi.list).mockRejectedValue(new Error('offline'))
-
- render(<NoFearShow onClose={vi.fn()} />)
- await flush()
-
- frame(58.9)
-
- expect(lineText()).toBe(LINES.everyDot)
- expect(scene().setPersonalPlaces).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-SHOW-021: ignores a non-array trip response', async () => {
- vi.mocked(tripsApi.list).mockResolvedValue({ trips: [] })
-
- render(<NoFearShow onClose={vi.fn()} />)
- await flush()
-
- expect(placesApi.list).not.toHaveBeenCalled()
- expect(scene().setPersonalPlaces).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-SHOW-022: drops late place results after unmount', async () => {
- let releasePlaces: (value: { lat: number; lng: number }[]) => void = () => {}
- vi.mocked(tripsApi.list).mockResolvedValue([{ id: 1 }])
- vi.mocked(placesApi.list).mockReturnValue(new Promise(resolve => { releasePlaces = resolve }))
-
- const { unmount } = render(<NoFearShow onClose={vi.fn()} />)
- await flush()
- unmount()
- releasePlaces([{ lat: 1, lng: 2 }, { lat: 3, lng: 4 }, { lat: 5, lng: 6 }])
- await flush()
-
- expect(scene().setPersonalPlaces).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-SHOW-023: pauses the clock while the tab is hidden', () => {
- render(<NoFearShow onClose={vi.fn()} />)
- frame(10)
- expect(lineText()).toBe(LINES.ofTheStranger)
-
- Object.defineProperty(document, 'hidden', { configurable: true, get: () => true })
- act(() => { document.dispatchEvent(new Event('visibilitychange')) })
- expect(audio().setSuspended).toHaveBeenCalledWith(true)
-
- nowMs = 30_000
- Object.defineProperty(document, 'hidden', { configurable: true, get: () => false })
- act(() => { document.dispatchEvent(new Event('visibilitychange')) })
- expect(audio().setSuspended).toHaveBeenLastCalledWith(false)
-
- // 21s of wall clock passed, but the show only advanced 1s.
- frame(31)
- expect(lineText()).toBe(LINES.ofTheStranger)
-
- Reflect.deleteProperty(document, 'hidden')
- })
-
- it('FE-NOFEAR-SHOW-024: resumes audio on any pointer gesture', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- act(() => { window.dispatchEvent(new Event('pointerdown')) })
-
- expect(audio().resume).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-SHOW-025: closes on Escape and ignores other keys', () => {
- const onClose = vi.fn()
- render(<NoFearShow onClose={onClose} />)
-
- act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'a' })) })
- expect(onClose).not.toHaveBeenCalled()
-
- act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })) })
- expect(onClose).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-SHOW-026: closes through the chrome button', () => {
- const onClose = vi.fn()
- render(<NoFearShow onClose={onClose} />)
-
- act(() => { screen.getByRole('button', { name: 'Carry it on' }).click() })
-
- expect(onClose).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-SHOW-027: toggles mute and relabels the button', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- act(() => { screen.getByRole('button', { name: 'Sound off' }).click() })
- expect(audio().setMuted).toHaveBeenCalledWith(true)
-
- act(() => { screen.getByRole('button', { name: 'Sound on' }).click() })
- expect(audio().setMuted).toHaveBeenLastCalledWith(false)
- })
-
- it('FE-NOFEAR-SHOW-028: skip jumps straight to the anthem and retires the skip button', () => {
- render(<NoFearShow onClose={vi.fn()} />)
- frame(5)
- expect(lineText()).toBe(LINES.afraid)
-
- act(() => { screen.getByRole('button', { name: 'Skip' }).click() })
-
- expect(audio().setAct).toHaveBeenLastCalledWith('anthem')
- expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('NO FEAR')
- expect(screen.queryByRole('button', { name: 'Skip' })).toBeNull()
- expect(document.querySelector('.fz-line')).toBeNull()
- })
-
- it('FE-NOFEAR-SHOW-029: closes the show with the anthem cascade in every other language', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(71.2)
-
- expect(audio().setAct).toHaveBeenLastCalledWith('anthem')
- expect(audio().impact).toHaveBeenLastCalledWith(0.8)
- const cascade = document.querySelectorAll('.fz-cascade-item')
- expect(cascade).toHaveLength(22)
- expect(cascade[0].textContent).toBe('Keine Angst')
- expect(screen.queryByText('No fear')).toBeNull()
- })
-
- it('FE-NOFEAR-SHOW-030: condenses the anthem title out of one lazily built particle assembly', () => {
- vi.spyOn(HTMLHeadingElement.prototype, 'getBoundingClientRect').mockReturnValue({
- left: 100, top: 200, width: 300, height: 60,
- } as unknown as DOMRect)
-
- render(<NoFearShow onClose={vi.fn()} />)
-
- // The title only exists from the frame after the anthem state flipped.
- frame(71.2)
- expect(stubs.assembly).toHaveLength(0)
-
- frame(72)
- expect(stubs.assembly).toHaveLength(1)
- expect(stubs.assembly[0].init).toHaveBeenCalledWith(
- 'NO FEAR',
- expect.any(String),
- { left: 100, top: 200, width: 300, height: 60 },
- 800,
- 600,
- )
- const [drawCtx, progress, fade, drawT] = stubs.assembly[0].draw.mock.calls[0] as [unknown, number, number, number]
- expect(drawCtx).toBe(ctxStub)
- expect(progress).toBeCloseTo(0.1875, 6)
- expect(fade).toBe(0)
- expect(drawT).toBe(72)
- expect(screen.getByRole('heading', { level: 1 })).toHaveClass('fz-word-hidden')
-
- frame(76)
- expect(stubs.assembly).toHaveLength(1)
- expect(screen.getByRole('heading', { level: 1 })).not.toHaveClass('fz-word-hidden')
-
- // Targets are absolute screen coordinates, so a resize invalidates them and
- // the next frame re-samples the moved title.
- act(() => { window.dispatchEvent(new Event('resize')) })
- act(() => { vi.advanceTimersByTime(150) })
- frame(77)
- expect(stubs.assembly).toHaveLength(2)
- })
-
- it('FE-NOFEAR-SHOW-031: tears down chrome, listeners and audio on unmount', () => {
- const { unmount } = render(<NoFearShow onClose={vi.fn()} />)
- const onClose = vi.fn()
- const layoutCalls = scene().layout.mock.calls.length
-
- unmount()
-
- expect(document.body).not.toHaveClass('fz-show-open')
- expect(audio().dispose).toHaveBeenCalledTimes(1)
- expect(cancelSpy).toHaveBeenCalled()
-
- window.dispatchEvent(new Event('resize'))
- window.dispatchEvent(new Event('pointerdown'))
- window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }))
-
- expect(scene().layout.mock.calls.length).toBe(layoutCalls)
- expect(audio().resume).not.toHaveBeenCalled()
- expect(onClose).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-SHOW-032: reduced motion renders the finale as one static frame without audio', () => {
- setReducedMotion(true)
-
- render(<NoFearShow onClose={vi.fn()} />)
-
- expect(audio().start).not.toHaveBeenCalled()
- expect(audio().setAct).toHaveBeenCalledWith('anthem')
- expect(requestAnimationFrame).not.toHaveBeenCalled()
- expect(scene().draw).toHaveBeenCalledTimes(1)
- const [, state, t] = scene().draw.mock.calls[0] as [unknown, { particles: number; opacity: number }, number]
- expect(state.particles).toBe(0)
- expect(state.opacity).toBe(1)
- expect(t).toBe(79)
- expect(screen.getByRole('heading', { level: 1 })).not.toHaveClass('fz-word-assembled')
- })
-
- it('FE-NOFEAR-SHOW-033: still runs the show when the canvas has no 2d context', () => {
- ctxStub = null
-
- render(<NoFearShow onClose={vi.fn()} />)
- frame(12.1)
-
- expect(lineText()).toBe(LINES.fearTool)
- expect(scene().draw).not.toHaveBeenCalled()
- expect(stubs.assembly).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SHOW-034: dims the world through the blackout and brings it back with the hope act', () => {
- render(<NoFearShow onClose={vi.fn()} />)
-
- frame(20)
- expect(lastSceneState().opacity).toBe(1)
-
- frame(27)
- expect(lastSceneState().opacity).toBe(0)
-
- frame(31)
- expect(lastSceneState().opacity).toBeGreaterThan(0.8)
- expect(lastSceneState().opacity).toBeLessThan(1)
-
- frame(32)
- expect(lastSceneState().opacity).toBe(1)
- })
-
- it('FE-NOFEAR-SHOW-035: falls back to a pixel ratio of 1 when the browser reports none', () => {
- Object.defineProperty(window, 'devicePixelRatio', { configurable: true, writable: true, value: 0 })
-
- render(<NoFearShow onClose={vi.fn()} />)
-
- expect(canvas().width).toBe(800)
- expect(ctxStub?.setTransform).toHaveBeenCalledWith(1, 0, 0, 1, 0, 0)
- })
-})
diff --git a/client/src/components/FourZero/NoFearShow.tsx b/client/src/components/FourZero/NoFearShow.tsx
deleted file mode 100644
index 4a72f05f1..000000000
--- a/client/src/components/FourZero/NoFearShow.tsx
+++ /dev/null
@@ -1,370 +0,0 @@
-import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
-import ReactDOM from 'react-dom'
-import { Volume2, VolumeX, X } from 'lucide-react'
-import { placesApi, tripsApi } from '../../api/client'
-import apiClient from '../../api/client'
-import { useTranslation } from '../../i18n'
-import type { Place, Trip } from '../../types'
-import { TextAssembly } from './noFearAssembly'
-import { NoFearAudio, type NoFearAct } from './noFearAudio'
-import { NoFearScene, type SceneState } from './noFearScene'
-import { ANTHEM_CASCADE, noFearCopy } from './noFearLines'
-import './fourzero.css'
-
-// TREK 4.0.0 release moment — remove together with the FourZero folder.
-
-type LineKey = keyof ReturnType<typeof noFearCopy>['lines']
-
-interface Cue {
- at: number
- act?: NoFearAct
- line?: LineKey | null
- hard?: boolean
- soft?: boolean
- impact?: number
- swell?: boolean
-}
-
-// The script. Times in seconds; the scene ramps below share the same clock.
-const CUES: Cue[] = [
- { at: 0.8, act: 'fear', line: 'afraid' },
- { at: 6.0, line: 'ofTheStranger' },
- { at: 12.0, act: 'dread', line: 'fearTool' },
- { at: 18.5, line: 'hateTrade' },
- { at: 26.0, act: 'silence', line: null },
- { at: 28.5, line: 'butYouTraveled', soft: true, swell: true },
- { at: 34.0, act: 'hope', line: 'tables' },
- { at: 42.0, line: 'face' },
- { at: 49.0, line: 'fences' },
- { at: 55.5, line: 'yourPlaces', impact: 0.35 },
- { at: 58.8, line: 'yourStatsCountries' },
- { at: 64.0, line: 'notAnOpinion', hard: true, impact: 1 },
- { at: 71.0, act: 'anthem', line: null, impact: 0.8 },
-]
-const ANTHEM_AT = 71
-// The three staccato words strobe with the late fear act, just before the cut.
-const FLASH_WINDOWS: [number, number][] = [[22.2, 22.85], [23.6, 24.25], [25.0, 25.65]]
-
-const ramp = (t: number, from: number, to: number): number =>
- Math.min(Math.max((t - from) / (to - from), 0), 1)
-
-function sceneAt(t: number): SceneState {
- // Hard cut to black at 26s; the pivot line stands alone in the dark, then the
- // world returns WITH the hope act (28→31.5) — that overlap is intentional.
- const blackout = t >= 26 && t < 31.5 ? 1 - ramp(t, 28, 31.5) : 0
- return {
- land: ramp(t, 6, 10),
- cityLife: ramp(t, 6.5, 11),
- cityDeath: ramp(t, 13, 22),
- borderHeat: t < 34 ? ramp(t, 12, 15.5) : 1 - 0.55 * ramp(t, 34, 38),
- borderBurst: ramp(t, 64, 70),
- web: ramp(t, 34, 62),
- warmth: ramp(t, 34, 46),
- personalGlow: ramp(t, 55.5, 60.5),
- particles: ramp(t, ANTHEM_AT, ANTHEM_AT + 4),
- opacity: 1 - blackout,
- }
-}
-
-/** Formats "{p} places. {c} countries. …" with the traveler's real numbers. */
-function fillStats(template: string, p: number, cOrT: number): string {
- return template.replace('{p}', String(p)).replace('{c}', String(cOrT)).replace('{t}', String(cOrT))
-}
-
-export default function NoFearShow({ onClose }: { onClose: () => void }) {
- const { language } = useTranslation()
- const copy = useMemo(() => noFearCopy(language), [language])
- const overlayRef = useRef<HTMLDivElement>(null)
- const canvasRef = useRef<HTMLCanvasElement>(null)
- const audioRef = useRef<NoFearAudio | null>(null)
- const sceneRef = useRef<NoFearScene | null>(null)
- const startRef = useRef<number>(performance.now())
- const statsRef = useRef<{ line: string } | null>(null)
- const assemblyRef = useRef<TextAssembly | null>(null)
- const anthemWordRef = useRef<HTMLHeadingElement>(null)
- const [cueIdx, setCueIdx] = useState(-1)
- const [flashIdx, setFlashIdx] = useState(-1)
- const [muted, setMuted] = useState(false)
- const [anthem, setAnthem] = useState(false)
- // A fear-act line that was just replaced — rendered once more while its
- // letters decay away (the words of fear literally fall apart).
- const [ghost, setGhost] = useState<{ text: string; id: number } | null>(null)
- const reducedMotion = useMemo(() => window.matchMedia('(prefers-reduced-motion: reduce)').matches, [])
-
- const skipToEnd = useCallback(() => {
- startRef.current = performance.now() - ANTHEM_AT * 1000
- setAnthem(true)
- audioRef.current?.setAct('anthem')
- }, [])
-
- // Boot: audio, scene, personal places, chrome side effects.
- useEffect(() => {
- document.body.classList.add('fz-show-open') // hides the dashboard FAB + locks scroll
- const audio = new NoFearAudio()
- audioRef.current = audio
- if (!reducedMotion) audio.start()
- const scene = new NoFearScene()
- sceneRef.current = scene
- const aborter = new AbortController()
- const cv = canvasRef.current
- const fit = () => {
- if (!cv) return
- const dpr = Math.min(window.devicePixelRatio || 1, 1.75)
- cv.width = Math.round(cv.clientWidth * dpr)
- cv.height = Math.round(cv.clientHeight * dpr)
- cv.getContext('2d')?.setTransform(dpr, 0, 0, dpr, 0, 0)
- scene.layout(cv.clientWidth, cv.clientHeight)
- // The finale samples the title rect in screen coordinates, so it has to be
- // re-sampled against the new geometry.
- assemblyRef.current = null
- }
- fit()
- if (cv) void scene.load(cv.clientWidth, cv.clientHeight, aborter.signal)
- // layout() rebakes every static layer, which is far too heavy for the event
- // storm a window drag produces — coalesce to the end of the gesture.
- let refitTimer = 0
- const onResize = () => {
- window.clearTimeout(refitTimer)
- refitTimer = window.setTimeout(fit, 150)
- }
- window.addEventListener('resize', onResize)
- // The traveler's own places, gathered quietly during the fear act. Fail-soft:
- // without them the show falls back to its generic lines.
- void (async () => {
- try {
- const trips = await tripsApi.list() as Trip[]
- if (aborter.signal.aborted || !Array.isArray(trips)) return
- const lists = await Promise.all(trips.slice(0, 12).map(t => placesApi.list(t.id).catch(() => [] as Place[])))
- if (aborter.signal.aborted) return
- const pts = lists.flat().filter((p: Place) => p.lat != null && p.lng != null).map((p: Place) => ({ lat: p.lat as number, lng: p.lng as number }))
- if (pts.length >= 3) {
- sceneRef.current?.setPersonalPlaces(pts)
- // Prefer real country counts from Atlas; fall back to trip counts.
- try {
- const { data } = await apiClient.get('/addons/atlas/stats', { signal: aborter.signal })
- const countries = data?.stats?.totalCountries
- statsRef.current = countries > 0
- ? { line: fillStats(copy.lines.yourStatsCountries, pts.length, countries) }
- : { line: fillStats(copy.lines.yourStatsTrips, pts.length, trips.length) }
- } catch {
- statsRef.current = { line: fillStats(copy.lines.yourStatsTrips, pts.length, trips.length) }
- }
- }
- } catch { /* not signed-in edge / API down — generic show */ }
- })()
- // Pause the whole show (clock + audio) while the tab is hidden.
- let hiddenAt: number | null = null
- const onVisibility = () => {
- if (document.hidden) {
- hiddenAt = performance.now()
- audio.setSuspended(true)
- } else {
- if (hiddenAt !== null) startRef.current += performance.now() - hiddenAt
- hiddenAt = null
- audio.setSuspended(false)
- }
- }
- document.addEventListener('visibilitychange', onVisibility)
- // Any real gesture inside the overlay doubles as an audio-resume recovery
- // for browsers that refused the post-lazy-load AudioContext start.
- const onPointer = () => audio.resume()
- window.addEventListener('pointerdown', onPointer)
- overlayRef.current?.focus()
- if (reducedMotion) skipToEnd()
- return () => {
- document.body.classList.remove('fz-show-open')
- window.clearTimeout(refitTimer)
- window.removeEventListener('resize', onResize)
- document.removeEventListener('visibilitychange', onVisibility)
- window.removeEventListener('pointerdown', onPointer)
- aborter.abort()
- audio.dispose()
- }
- }, [reducedMotion, skipToEnd, copy])
-
- // The clock: one rAF loop drives the canvas directly and only touches React
- // state on discrete cue/flash changes. Reduced motion renders one static frame.
- useEffect(() => {
- const cv = canvasRef.current
- const ctx = cv?.getContext('2d')
- if (reducedMotion) {
- setCueIdx(CUES.length - 1)
- if (ctx) sceneRef.current?.draw(ctx, { ...sceneAt(ANTHEM_AT + 8), particles: 0 }, ANTHEM_AT + 8)
- return
- }
- let raf = 0
- let lastCue = -1
- let lastFlash = -1
- const tick = () => {
- const t = (performance.now() - startRef.current) / 1000
- let idx = -1
- for (let i = 0; i < CUES.length; i++) if (t >= CUES[i].at) idx = i
- if (idx !== lastCue && idx >= 0) {
- // A replaced fear-act line decays letter by letter instead of vanishing.
- if (lastCue >= 0 && lastCue <= 3) {
- const ghostId = lastCue // pin it — lastCue advances on the next line
- const prevKey = CUES[ghostId].line
- if (prevKey) {
- setGhost({ text: copy.lines[prevKey], id: ghostId })
- window.setTimeout(() => setGhost(g => (g?.id === ghostId ? null : g)), 1400)
- }
- }
- lastCue = idx
- const cue = CUES[idx]
- if (cue.act) audioRef.current?.setAct(cue.act)
- if (cue.impact) audioRef.current?.impact(cue.impact)
- if (cue.swell) audioRef.current?.swell()
- setCueIdx(idx)
- if (t >= ANTHEM_AT) setAnthem(true)
- }
- let flash = -1
- for (let i = 0; i < FLASH_WINDOWS.length; i++) {
- if (t >= FLASH_WINDOWS[i][0] && t < FLASH_WINDOWS[i][1]) flash = i
- }
- if (flash !== lastFlash) {
- lastFlash = flash
- setFlashIdx(flash)
- }
- if (ctx) sceneRef.current?.draw(ctx, sceneAt(t), t)
- // The finale condenses out of light: once the anthem title is measurable,
- // sample its letterforms and gather rising particles into them; the real
- // DOM text takes over as they settle.
- if (ctx && cv && t >= ANTHEM_AT) {
- const word = anthemWordRef.current
- if (!assemblyRef.current && word) {
- const assembly = new TextAssembly()
- const style = window.getComputedStyle(word)
- const rect = word.getBoundingClientRect()
- assembly.init(
- word.textContent ?? '',
- `${style.fontWeight} ${style.fontSize} ${style.fontFamily}`,
- { left: rect.left, top: rect.top, width: rect.width, height: rect.height },
- cv.clientWidth,
- cv.clientHeight,
- )
- assemblyRef.current = assembly
- }
- const progress = ramp(t, ANTHEM_AT + 0.4, ANTHEM_AT + 3.6)
- const fade = ramp(t, ANTHEM_AT + 3.4, ANTHEM_AT + 4.8)
- assemblyRef.current?.draw(ctx, progress, fade, t)
- word?.classList.toggle('fz-word-hidden', fade < 0.15)
- }
- raf = requestAnimationFrame(tick)
- }
- raf = requestAnimationFrame(tick)
- return () => cancelAnimationFrame(raf)
- }, [reducedMotion])
-
- // ESC closes the show at any point.
- useEffect(() => {
- const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() }
- window.addEventListener('keydown', onKey)
- return () => window.removeEventListener('keydown', onKey)
- }, [onClose])
-
- const cue = cueIdx >= 0 ? CUES[cueIdx] : null
- const lineKey = cue?.line ?? null
- // The personal-stats line only exists when the traveler's data arrived; the
- // yourPlaces line falls back to the generic "every light" line without it,
- // and that line simply stays up through the stats slot (same text = no remount).
- let lineText: string | null = null
- if (lineKey === 'yourStatsCountries') lineText = statsRef.current?.line ?? copy.lines.everyDot
- else if (lineKey === 'yourPlaces') lineText = statsRef.current ? copy.lines.yourPlaces : copy.lines.everyDot
- else if (lineKey) lineText = copy.lines[lineKey]
- const hard = !!cue?.hard
-
- // Portal to body: the dashboard sidebar is position:sticky and forms its own
- // stacking context, so an in-place overlay would sit UNDER the fixed navbar
- // (z-200 at root level) no matter its z-index.
- return ReactDOM.createPortal(
- <div ref={overlayRef} className="fz-overlay" role="dialog" aria-modal="true" aria-label={copy.beaconTitle} tabIndex={-1}>
- <canvas ref={canvasRef} className="fz-canvas" />
-
- {/* Red vignette while the borders burn. */}
- {!anthem && cueIdx >= 2 && cueIdx <= 3 && <div className="fz-vignette" aria-hidden />}
-
- {/* Staccato words strobing to the heartbeat, right before the cut. */}
- {flashIdx >= 0 && !anthem && (
- <div className="fz-flash-wrap" aria-hidden>
- <span key={flashIdx} className="fz-flash">{copy.flashes[flashIdx]}</span>
- </div>
- )}
-
- {/* A replaced fear line decays away letter by letter. */}
- {!anthem && ghost && (
- <div className="fz-line-wrap" aria-hidden>
- <p key={`ghost-${ghost.id}`} className="fz-line fz-line-ghost">
- {[...ghost.text].map((ch, i) => (
- <span
- key={i}
- className="fz-char-decay"
- style={{
- '--dx': `${(Math.sin(i * 37.7) * 0.5) * 52}px`,
- '--dy': `${-(12 + Math.abs(Math.sin(i * 17.3)) * 34)}px`,
- '--rot': `${Math.sin(i * 53.1) * 14}deg`,
- animationDelay: `${Math.abs(Math.sin(i * 91.7)) * 0.3}s`,
- } as React.CSSProperties}
- >
- {ch === ' ' ? ' ' : ch}
- </span>
- ))}
- </p>
- </div>
- )}
-
- {/* The lines. Hope-act lines reveal sentence by sentence, like speech. */}
- {!anthem && lineText && flashIdx < 0 && (
- <div className="fz-line-wrap" aria-live="polite">
- <p key={lineText} className={`fz-line ${hard ? 'fz-line-hard' : ''} ${cue?.soft ? 'fz-line-soft' : ''}`}>
- {cueIdx >= 6 && cueIdx <= 10 && !hard
- ? lineText.split(/(?<=[.!?…])\s+/u).map((seg, i) => (
- <span key={i} className="fz-seg" style={{ animationDelay: `${i * 0.95}s` }}>{seg}{' '}</span>
- ))
- : lineText}
- </p>
- </div>
- )}
-
- {/* The ending: the big words condense out of rising light, then the
- cascade through every TREK language joins — and it all stays. */}
- {anthem && (
- <div className="fz-anthem">
- <h1
- ref={anthemWordRef}
- className={`fz-anthem-word ${reducedMotion ? '' : 'fz-word-assembled fz-word-hidden'}`}
- >
- {copy.anthem}
- </h1>
- <div className="fz-cascade">
- {ANTHEM_CASCADE.filter(c => c.lang !== language).map((c, i) => (
- <span key={c.lang} className="fz-cascade-item" style={{ animationDelay: `${(reducedMotion ? 0.2 : 4.6) + i * 0.42}s` }}>
- {c.text}
- </span>
- ))}
- </div>
- </div>
- )}
-
- {/* Chrome: mute, skip, close. */}
- <div className="fz-chrome">
- <button
- type="button"
- className="fz-chrome-btn"
- onClick={() => { const m = !muted; setMuted(m); audioRef.current?.setMuted(m) }}
- aria-label={muted ? copy.soundOn : copy.soundOff}
- >
- {muted ? <VolumeX size={15} /> : <Volume2 size={15} />}
- </button>
- {!anthem && (
- <button type="button" className="fz-chrome-btn fz-chrome-skip" onClick={skipToEnd}>
- {copy.skip}
- </button>
- )}
- <button type="button" className="fz-chrome-btn" onClick={onClose} aria-label={copy.close}>
- <X size={15} />
- </button>
- </div>
- </div>,
- document.body
- )
-}
diff --git a/client/src/components/FourZero/fourzero.css b/client/src/components/FourZero/fourzero.css
deleted file mode 100644
index 8a858a751..000000000
--- a/client/src/components/FourZero/fourzero.css
+++ /dev/null
@@ -1,435 +0,0 @@
-/* TREK 4.0.0 "KEINE ANGST" — styles for the beacon and the show.
- Temporary by design: remove together with the FourZero folder. */
-
-.fz-overlay {
- position: fixed;
- inset: 0;
- z-index: 9999;
- background: #05060a;
- overflow: hidden;
- color: #f5f2ea;
- font-family: inherit;
-}
-
-.fz-canvas {
- position: absolute;
- inset: 0;
- width: 100%;
- height: 100%;
-}
-
-.fz-vignette {
- position: absolute;
- inset: 0;
- pointer-events: none;
- background: radial-gradient(ellipse at center, transparent 52%, rgba(160, 25, 25, 0.28) 100%);
- animation: fzVignettePulse 2.6s ease-in-out infinite;
-}
-
-@keyframes fzVignettePulse {
- 0%, 100% { opacity: 0.55; }
- 50% { opacity: 1; }
-}
-
-/* ── the lines ── */
-
-.fz-line-wrap {
- position: absolute;
- inset: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 0 12vw;
- pointer-events: none;
- /* A soft radial pool of darkness under the words, so they never sink into
- the burning map — depth, not a hard box. */
- background: radial-gradient(52% 34% at 50% 50%, rgba(5, 6, 10, 0.55), rgba(5, 6, 10, 0) 72%);
-}
-
-.fz-line {
- max-width: 900px;
- text-align: center;
- font-size: clamp(22px, 3.2vw, 40px);
- font-weight: 300;
- line-height: 1.45;
- letter-spacing: 0.015em;
- text-shadow:
- 0 1px 2px rgba(5, 6, 10, 0.9),
- 0 4px 18px rgba(5, 6, 10, 0.8),
- 0 10px 46px rgba(5, 6, 10, 0.65);
- animation: fzLineIn 1.6s cubic-bezier(0.19, 1, 0.22, 1) both;
-}
-
-.fz-line-hard {
- font-weight: 700;
- font-size: clamp(26px, 3.8vw, 50px);
- letter-spacing: 0.01em;
-}
-
-/* The pivot line out of the silence breathes in slowly instead of arriving. */
-.fz-line-soft {
- animation-duration: 3.4s;
-}
-
-@keyframes fzLineIn {
- from { opacity: 0; transform: translateY(14px); filter: blur(6px); }
- to { opacity: 1; transform: translateY(0); filter: blur(0); }
-}
-
-/* A replaced fear line falls apart: every letter drifts off on its own path. */
-.fz-line-ghost {
- position: absolute;
- animation: none;
-}
-
-.fz-char-decay {
- display: inline-block;
- white-space: pre;
- animation: fzCharDecay 1.05s cubic-bezier(0.4, 0, 0.9, 0.4) both;
-}
-
-@keyframes fzCharDecay {
- 0% { opacity: 1; transform: translate(0, 0) rotate(0); filter: blur(0); }
- 100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, -20px)) rotate(var(--rot, 0)); filter: blur(7px); }
-}
-
-/* Hope-act lines arrive sentence by sentence, in speech rhythm. */
-.fz-seg {
- opacity: 0;
- animation: fzSegIn 1.5s cubic-bezier(0.19, 1, 0.22, 1) both;
-}
-
-@keyframes fzSegIn {
- from { opacity: 0; filter: blur(5px); }
- to { opacity: 1; filter: blur(0); }
-}
-
-/* Staccato words strobing to the heartbeat in the late fear act. */
-.fz-flash-wrap {
- position: absolute;
- inset: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- pointer-events: none;
-}
-
-/* A stamped title card, not a zoom: bone-white core, chromatic red/blue
- fringes, a nervous micro-jitter while it stands, tracking that slowly
- clenches, and a hard cut out. */
-.fz-flash {
- font-size: clamp(52px, 9vw, 130px);
- font-weight: 900;
- color: #f4ded9;
- text-shadow:
- -2px 0 0 rgba(235, 45, 38, 0.85),
- 2px 0 0 rgba(60, 90, 235, 0.5),
- 0 0 34px rgba(235, 50, 45, 0.5),
- 0 4px 26px rgba(0, 0, 0, 0.95);
- animation:
- fzFlashStamp 0.65s linear both,
- fzFlashJitter 0.1s steps(2, jump-none) infinite;
-}
-
-@keyframes fzFlashStamp {
- 0% { opacity: 0; letter-spacing: 0.2em; }
- 6% { opacity: 1; }
- 88% { opacity: 1; letter-spacing: 0.11em; }
- 100% { opacity: 0; letter-spacing: 0.11em; }
-}
-
-@keyframes fzFlashJitter {
- 0% { transform: translate(0, 0); }
- 50% { transform: translate(1.6px, -1px); }
- 100% { transform: translate(-1.4px, 0.8px); }
-}
-
-/* ── anthem ── */
-
-.fz-anthem {
- position: absolute;
- inset: 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: 4vh;
- pointer-events: none;
- padding: 0 6vw;
-}
-
-.fz-anthem-word {
- font-size: clamp(48px, 9vw, 128px);
- font-weight: 800;
- letter-spacing: 0.06em;
- text-align: center;
- margin: 0;
- text-shadow: 0 0 60px rgba(255, 200, 120, 0.35), 0 2px 30px rgba(0, 0, 0, 0.9);
- animation: fzAnthemIn 2.8s cubic-bezier(0.19, 1, 0.22, 1) both;
-}
-
-.fz-anthem-word-small {
- font-size: clamp(34px, 5vw, 64px);
-}
-
-@keyframes fzAnthemIn {
- from { opacity: 0; transform: scale(0.94); letter-spacing: 0.18em; filter: blur(10px); }
- to { opacity: 1; transform: scale(1); letter-spacing: 0.06em; filter: blur(0); }
-}
-
-/* Assembly mode: the DOM word skips the zoom-in (the particles ARE the
- entrance, and the zoom would skew the measured letterform targets); once the
- particles settle it fades in crisp and keeps breathing quietly forever. */
-.fz-anthem-word.fz-word-assembled {
- animation: fzAnthemBreathe 5.5s ease-in-out 5.5s infinite;
- transition: opacity 1.5s ease;
-}
-
-.fz-anthem-word.fz-word-hidden {
- opacity: 0;
- transition: none;
-}
-
-@keyframes fzAnthemBreathe {
- 0%, 100% { transform: scale(1); text-shadow: 0 0 60px rgba(255, 200, 120, 0.35), 0 2px 30px rgba(0, 0, 0, 0.9); }
- 50% { transform: scale(1.012); text-shadow: 0 0 84px rgba(255, 205, 130, 0.5), 0 2px 30px rgba(0, 0, 0, 0.9); }
-}
-
-.fz-cascade {
- display: flex;
- flex-wrap: wrap;
- justify-content: center;
- gap: 6px 26px;
- max-width: 1000px;
-}
-
-.fz-cascade-item {
- font-size: clamp(13px, 1.35vw, 19px);
- font-weight: 500;
- opacity: 0;
- color: rgba(245, 235, 215, 0.92);
- animation: fzCascadeIn 1.4s ease-out both;
-}
-
-@keyframes fzCascadeIn {
- from { opacity: 0; transform: translateY(8px); }
- to { opacity: 0.92; transform: translateY(0); }
-}
-
-/* ── chrome ── */
-
-.fz-chrome {
- position: absolute;
- right: 18px;
- bottom: 16px;
- display: flex;
- gap: 8px;
- align-items: center;
- opacity: 0;
- animation: fzChromeIn 1s ease-out 2.5s both;
-}
-
-@keyframes fzChromeIn { to { opacity: 1; } }
-
-.fz-chrome-btn {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 8px 12px;
- border-radius: 999px;
- border: 1px solid rgba(245, 240, 225, 0.22);
- background: rgba(10, 12, 18, 0.55);
- color: rgba(245, 240, 225, 0.75);
- font-size: 12px;
- font-weight: 600;
- font-family: inherit;
- cursor: pointer;
- backdrop-filter: blur(6px);
- transition: color 0.15s, border-color 0.15s;
-}
-
-.fz-chrome-btn:hover { color: #fff; border-color: rgba(245, 240, 225, 0.55); }
-
-/* ── beacon (dashboard trigger) ── */
-
-/* Wrapper is a div so the dismiss can be a real sibling <button> — a button
- may not contain another interactive element. Core colors also ride inline in
- the component so no dashboard widget CSS can wash them out. */
-.fz-beacon {
- position: relative;
- display: none;
- width: 100%;
- min-height: 196px;
- border-radius: var(--r-xl, 16px); /* same corner radius as the dashboard tool widgets */
- overflow: hidden;
- isolation: isolate;
- box-shadow: 0 12px 34px -14px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 190, 110, 0.14);
- transition: box-shadow 0.35s ease, transform 0.35s ease;
-}
-
-.fz-beacon:hover {
- box-shadow: 0 16px 44px -14px rgba(220, 80, 50, 0.35), inset 0 0 0 1px rgba(255, 190, 110, 0.3);
- transform: translateY(-2px);
-}
-
-@media (min-width: 1024px) {
- .fz-beacon { display: block; }
-}
-
-/* The living night-world painted by TeaserCanvas. */
-.fz-beacon-canvas {
- position: absolute;
- inset: 0;
- width: 100%;
- height: 100%;
- z-index: 0;
-}
-
-/* Slow-breathing colored glows drifting over the canvas. */
-.fz-beacon-glow {
- position: absolute;
- inset: -30%;
- z-index: 1;
- pointer-events: none;
- background:
- radial-gradient(45% 40% at 22% 18%, rgba(235, 60, 55, 0.2), transparent 70%),
- radial-gradient(50% 45% at 82% 78%, rgba(255, 170, 80, 0.16), transparent 70%);
- animation: fzGlowDrift 9s ease-in-out infinite alternate;
-}
-
-@keyframes fzGlowDrift {
- from { transform: translate(-2%, -2%) scale(1); opacity: 0.8; }
- to { transform: translate(2%, 3%) scale(1.08); opacity: 1; }
-}
-
-.fz-beacon-play {
- position: relative;
- z-index: 2;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 100%;
- min-height: 216px;
- border: none;
- text-align: center;
- cursor: pointer;
- padding: 22px 18px 18px;
- font-family: inherit;
- color: #f5f2ea;
- /* Cinema scrim: a dark pool behind the centered copy, corners vignetted. */
- background:
- radial-gradient(120% 105% at 50% 52%, rgba(7, 8, 13, 0.62) 0%, rgba(7, 8, 13, 0.28) 52%, rgba(7, 8, 13, 0.7) 100%) !important;
-}
-
-/* Ivory-to-gold text with a traveling sheen and a slow breathing glow —
- quiet effects, jewelry-grade, no gimmicks. */
-.fz-beacon-title {
- display: block;
- font-size: 31px;
- font-weight: 900;
- letter-spacing: 0.14em;
- text-indent: 0.14em;
- line-height: 1.04;
- margin: 0 0 8px;
- background-image:
- linear-gradient(110deg, transparent 40%, rgba(255, 244, 214, 0.95) 50%, transparent 60%),
- linear-gradient(180deg, #fdfaf1 0%, #f4e6c2 52%, #e5c084 100%);
- background-size: 260% 100%, 100% 100%;
- -webkit-background-clip: text;
- background-clip: text;
- -webkit-text-fill-color: transparent;
- animation:
- fzTitleSheen 5.5s ease-in-out infinite,
- fzTitleBreathe 4.5s ease-in-out infinite;
-}
-
-@keyframes fzTitleSheen {
- 0%, 30% { background-position: 130% 0, 0 0; }
- 62%, 100% { background-position: -70% 0, 0 0; }
-}
-
-@keyframes fzTitleBreathe {
- 0%, 100% { filter: drop-shadow(0 0 16px rgba(255, 205, 130, 0.18)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.85)); }
- 50% { filter: drop-shadow(0 0 30px rgba(255, 210, 140, 0.42)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.85)); }
-}
-
-.fz-beacon-sub {
- display: block;
- font-size: 12.5px;
- font-weight: 400;
- letter-spacing: 0.02em;
- color: rgba(245, 240, 225, 0.75);
- margin: 0;
- text-shadow: 0 1px 8px rgba(5, 6, 10, 0.9);
-}
-
-.fz-beacon-dismiss {
- position: absolute;
- top: 10px;
- inset-inline-end: 10px;
- z-index: 3;
- display: inline-flex;
- align-items: center;
- padding: 5px;
- border: none;
- border-radius: 999px;
- background: rgba(8, 10, 16, 0.4);
- color: rgba(245, 240, 225, 0.55);
- font-family: inherit;
- font-size: 11px;
- font-weight: 600;
- cursor: pointer;
- opacity: 0;
- backdrop-filter: blur(4px);
- transition: opacity 0.3s ease, color 0.2s, background 0.2s;
-}
-
-/* Stays out of the way until the card is hovered or the button is focused. */
-.fz-beacon:hover .fz-beacon-dismiss,
-.fz-beacon-dismiss:focus-visible { opacity: 1; }
-
-.fz-beacon-dismiss:hover { color: #fff; background: rgba(8, 10, 16, 0.65); }
-
-/* Armed confirm: a clear, deliberate red pill — this click is permanent. */
-.fz-beacon-dismiss-confirm {
- opacity: 1;
- padding: 5px 11px;
- background: rgba(200, 60, 45, 0.9);
- color: #fff;
-}
-
-.fz-beacon-dismiss-confirm:hover { background: rgba(214, 68, 52, 0.95); }
-
-/* White retirement badge at the foot of the card: viewable until Aug 23. */
-.fz-beacon-until {
- position: absolute;
- left: 50%;
- bottom: 14px;
- transform: translateX(-50%);
- z-index: 3;
- pointer-events: none;
- padding: 4px 12px;
- border-radius: 999px;
- background: rgba(255, 255, 255, 0.92);
- color: #1a1712;
- font-size: 11px;
- font-weight: 600;
- letter-spacing: 0.01em;
- white-space: nowrap;
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
-}
-
-/* While the show runs: no floating dashboard chrome above it, no page scroll. */
-body.fz-show-open { overflow: hidden; }
-body.fz-show-open .fab-new-trip { display: none; }
-
-/* Accessibility: with reduced motion the component renders a single static
- frame and skips straight to the credits; flatten every looping accent too. */
-@media (prefers-reduced-motion: reduce) {
- .fz-overlay *,
- .fz-vignette {
- animation-duration: 0.01s !important;
- animation-iteration-count: 1 !important;
- }
-}
diff --git a/client/src/components/FourZero/noFearAssembly.test.ts b/client/src/components/FourZero/noFearAssembly.test.ts
deleted file mode 100644
index 91cf91055..000000000
--- a/client/src/components/FourZero/noFearAssembly.test.ts
+++ /dev/null
@@ -1,346 +0,0 @@
-// FE-NOFEAR-ASM-001 to FE-NOFEAR-ASM-017
-import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
-import { TextAssembly } from './noFearAssembly'
-
-interface FillRecord {
- fillStyle: string
- globalAlpha: number
- composite: string
- x: number
- y: number
- r: number
-}
-
-interface FakeCtx {
- font: string
- textAlign: string
- textBaseline: string
- fillStyle: string
- globalAlpha: number
- globalCompositeOperation: string
- save: ReturnType<typeof vi.fn>
- restore: ReturnType<typeof vi.fn>
- beginPath: ReturnType<typeof vi.fn>
- fillText: ReturnType<typeof vi.fn>
- arc: ReturnType<typeof vi.fn>
- fill: ReturnType<typeof vi.fn>
- getImageData: ReturnType<typeof vi.fn>
- fills: FillRecord[]
-}
-
-// jsdom has no canvas backend, so every 2d context in these tests is a recorder.
-// getImageData replays `alphaAt` so the sampled letterform is fully deterministic.
-let alphaAt: (x: number, y: number) => number = () => 0
-let contextAvailable = true
-let contexts: FakeCtx[] = []
-const originalGetContext = HTMLCanvasElement.prototype.getContext
-
-function makeCtx(): FakeCtx {
- let lastArc: { x: number; y: number; r: number } | null = null
- const ctx: FakeCtx = {
- font: '',
- textAlign: '',
- textBaseline: '',
- fillStyle: '',
- globalAlpha: 1,
- globalCompositeOperation: 'source-over',
- save: vi.fn(),
- restore: vi.fn(),
- beginPath: vi.fn(),
- fillText: vi.fn(),
- arc: vi.fn((x: number, y: number, r: number) => { lastArc = { x, y, r } }),
- fill: vi.fn(() => {
- const a = lastArc ?? { x: NaN, y: NaN, r: NaN }
- ctx.fills.push({
- fillStyle: ctx.fillStyle,
- globalAlpha: ctx.globalAlpha,
- composite: ctx.globalCompositeOperation,
- x: a.x,
- y: a.y,
- r: a.r,
- })
- }),
- getImageData: vi.fn((_x: number, _y: number, w: number, h: number) => {
- const data = new Uint8ClampedArray(w * h * 4)
- for (let y = 0; y < h; y++) {
- for (let x = 0; x < w; x++) data[(y * w + x) * 4 + 3] = alphaAt(x, y)
- }
- return { data }
- }),
- fills: [],
- }
- return ctx
-}
-
-/** Math.random replaced by a repeating sequence — init consumes exactly 6 per particle. */
-function cycleRandom(values: number[]): void {
- let i = 0
- vi.spyOn(Math, 'random').mockImplementation(() => values[i++ % values.length])
-}
-
-const asCtx = (c: FakeCtx) => c as unknown as CanvasRenderingContext2D
-
-beforeEach(() => {
- alphaAt = () => 0
- contextAvailable = true
- contexts = []
- HTMLCanvasElement.prototype.getContext = vi.fn(() => {
- if (!contextAvailable) return null
- const c = makeCtx()
- contexts.push(c)
- return c
- }) as unknown as HTMLCanvasElement['getContext']
-})
-
-afterEach(() => {
- HTMLCanvasElement.prototype.getContext = originalGetContext
- vi.restoreAllMocks()
-})
-
-const BOX = { left: 100, top: 50, width: 12, height: 12 }
-
-describe('TextAssembly.init', () => {
- it('FE-NOFEAR-ASM-001: turns every opaque raster cell into a particle aimed at its screen position', () => {
- alphaAt = (x, y) => (x === 3 && y === 6 ? 200 : 0)
- cycleRandom([0.1, 0.1, 0.1, 0.1, 0.1, 0])
-
- const a = new TextAssembly()
- a.init('KEINE ANGST', 'bold 64px Inter', BOX, 1000, 600)
- expect(a.isReady()).toBe(true)
-
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
- expect(main.fills).toHaveLength(1)
- expect(main.fills[0].x).toBeCloseTo(103, 6)
- expect(main.fills[0].y).toBeCloseTo(56, 6)
- })
-
- it('FE-NOFEAR-ASM-002: rasters the text centred in the offscreen box', () => {
- alphaAt = () => 0
- cycleRandom([0.1])
-
- new TextAssembly().init('KEINE ANGST', 'bold 64px Inter', BOX, 1000, 600)
-
- const off = contexts[0]
- expect(off.font).toBe('bold 64px Inter')
- expect(off.textAlign).toBe('center')
- expect(off.textBaseline).toBe('middle')
- expect(off.fillStyle).toBe('#fff')
- expect(off.fillText).toHaveBeenCalledWith('KEINE ANGST', 6, 6)
- expect(off.getImageData).toHaveBeenCalledWith(0, 0, 12, 12)
- })
-
- it('FE-NOFEAR-ASM-003: caps the raster at 700px and scales the font shorthand with it', () => {
- alphaAt = () => 0
- cycleRandom([0.1])
-
- new TextAssembly().init('KEINE ANGST', 'bold 200px Inter', { left: 0, top: 0, width: 1400, height: 6 }, 1000, 600)
-
- const off = contexts[0]
- expect(off.font).toBe('bold 100px Inter')
- expect(off.fillText).toHaveBeenCalledWith('KEINE ANGST', 350, 1.5)
- expect(off.getImageData).toHaveBeenCalledWith(0, 0, 700, 3)
- })
-
- it('FE-NOFEAR-ASM-004: maps raster coordinates back through the scale factor', () => {
- alphaAt = (x, y) => (x === 6 && y === 0 ? 200 : 0)
- cycleRandom([0.1, 0.1, 0.1, 0.1, 0.1, 0])
-
- const a = new TextAssembly()
- a.init('X', 'bold 200px Inter', { left: 0, top: 0, width: 1400, height: 6 }, 1000, 600)
-
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
- expect(main.fills).toHaveLength(1)
- // raster x 6 at scale 0.5 lands at screen x 12
- expect(main.fills[0].x).toBeCloseTo(12, 6)
- expect(main.fills[0].y).toBeCloseTo(0, 6)
- })
-
- it('FE-NOFEAR-ASM-005: treats alpha 128 as transparent and 129 as solid', () => {
- alphaAt = (x, y) => (y === 0 && x === 0 ? 128 : y === 0 && x === 3 ? 129 : 0)
- cycleRandom([0.1, 0.1, 0.1, 0.1, 0.1, 0])
-
- const a = new TextAssembly()
- a.init('X', 'bold 64px Inter', { left: 0, top: 0, width: 12, height: 12 }, 1000, 600)
-
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
- expect(main.fills).toHaveLength(1)
- expect(main.fills[0].x).toBeCloseTo(3, 6)
- })
-
- it('FE-NOFEAR-ASM-006: samples the raster on a 3px grid', () => {
- alphaAt = () => 255
- cycleRandom([0.1, 0.1, 0.1, 0.1, 0.1, 0])
-
- const a = new TextAssembly()
- a.init('X', 'bold 64px Inter', { left: 0, top: 0, width: 12, height: 12 }, 1000, 600)
-
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
- // 12x12 raster stepped by 3 → 4x4 sample points
- expect(main.fills).toHaveLength(16)
- })
-
- it('FE-NOFEAR-ASM-007: is ready but silent when the raster is empty', () => {
- alphaAt = () => 0
- cycleRandom([0.1])
-
- const a = new TextAssembly()
- a.init('X', 'bold 64px Inter', BOX, 1000, 600)
- expect(a.isReady()).toBe(true)
-
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
- expect(main.save).toHaveBeenCalledTimes(1)
- expect(main.restore).toHaveBeenCalledTimes(1)
- expect(main.fills).toHaveLength(0)
- })
-
- it('FE-NOFEAR-ASM-008: stays unready when no 2d context is available', () => {
- contextAvailable = false
- alphaAt = () => 255
- cycleRandom([0.1])
-
- const a = new TextAssembly()
- a.init('X', 'bold 64px Inter', BOX, 1000, 600)
- expect(a.isReady()).toBe(false)
-
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
- expect(main.save).not.toHaveBeenCalled()
- expect(main.fills).toHaveLength(0)
- })
-
- it('FE-NOFEAR-ASM-019: drops the previous targets when a re-init cannot raster', () => {
- alphaAt = () => 255
- cycleRandom([0.1])
-
- const a = new TextAssembly()
- a.init('X', 'bold 64px Inter', BOX, 1000, 600)
- expect(a.isReady()).toBe(true)
-
- contextAvailable = false
- a.init('X', 'bold 64px Inter', BOX, 1000, 600)
- expect(a.isReady()).toBe(false)
-
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
- expect(main.fills).toHaveLength(0)
- })
-
- it('FE-NOFEAR-ASM-009: keeps a degenerate box at one raster pixel', () => {
- alphaAt = () => 255
- cycleRandom([0.1, 0.1, 0.1, 0.1, 0.1, 0])
-
- const a = new TextAssembly()
- a.init('X', 'bold 64px Inter', { left: 5, top: 7, width: 0, height: 0 }, 1000, 600)
-
- expect(contexts[0].getImageData).toHaveBeenCalledWith(0, 0, 1, 1)
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
- expect(main.fills).toHaveLength(1)
- expect(main.fills[0].x).toBeCloseTo(5, 6)
- expect(main.fills[0].y).toBeCloseTo(7, 6)
- })
-})
-
-describe('TextAssembly.draw', () => {
- function seeded(values: number[], box = BOX): TextAssembly {
- alphaAt = (x, y) => (x === 0 && y === 0 ? 200 : 0)
- cycleRandom(values)
- const a = new TextAssembly()
- a.init('X', 'bold 64px Inter', box, 1000, 600)
- return a
- }
-
- it('FE-NOFEAR-ASM-010: does nothing before init', () => {
- const main = makeCtx()
- new TextAssembly().draw(asCtx(main), 0.5, 0, 0)
- expect(main.save).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-ASM-011: bails out once the DOM title has fully taken over', () => {
- const a = seeded([0.1, 0.1, 0.1, 0.1, 0.1, 0])
- const main = makeCtx()
- a.draw(asCtx(main), 1, 1, 0)
- expect(main.save).not.toHaveBeenCalled()
- expect(main.fills).toHaveLength(0)
- })
-
- it('FE-NOFEAR-ASM-012: skips particles whose delay has not elapsed', () => {
- const a = seeded([0.1, 0.1, 0.1, 0.1, 0.1, 0]) // delay 0.045
- const main = makeCtx()
- a.draw(asCtx(main), 0.04, 0, 0)
- expect(main.save).toHaveBeenCalledTimes(1)
- expect(main.restore).toHaveBeenCalledTimes(1)
- expect(main.fills).toHaveLength(0)
- })
-
- it('FE-NOFEAR-ASM-013: settled particles cool to ivory, shrink and additively blend', () => {
- const a = seeded([0.1, 0.1, 0.1, 0.1, 0.1, 0]) // size 1.02
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0, 0)
-
- expect(main.fills).toEqual([
- expect.objectContaining({ fillStyle: 'rgb(247, 240, 226)', composite: 'lighter' }),
- ])
- expect(main.fills[0].globalAlpha).toBeCloseTo(0.9, 6)
- expect(main.fills[0].r).toBeCloseTo(1.02 * 0.85, 6)
- })
-
- it('FE-NOFEAR-ASM-014: in-flight particles glow warm and flicker with t', () => {
- const a = seeded([0.1, 0.1, 0.1, 0.1, 0.1, 0]) // delay 0.045, size 1.02, seed 0
- const main = makeCtx()
- a.draw(asCtx(main), 0.5, 0, 0)
-
- const local = 1 - (1 - (0.5 - 0.045) / 0.955) ** 3
- expect(main.fills).toHaveLength(1)
- expect(main.fills[0].fillStyle).toBe('rgb(255, 205, 130)')
- expect(main.fills[0].r).toBeCloseTo(1.02, 6)
- // sin(0) → flicker sits at its 0.65 floor
- expect(main.fills[0].globalAlpha).toBeCloseTo(0.75 * 0.65, 6)
- expect(main.fills[0].x).toBeCloseTo(-30 + (100 + 30) * local, 6)
- expect(main.fills[0].y).toBeCloseTo(60 + (50 - 60) * local, 6)
- })
-
- it('FE-NOFEAR-ASM-015: the flicker peaks a quarter period into the sine', () => {
- const a = seeded([0.1, 0.1, 0.1, 0.1, 0.1, 0])
- const main = makeCtx()
- a.draw(asCtx(main), 0.5, 0, Math.PI / 10)
- expect(main.fills[0].globalAlpha).toBeCloseTo(0.75, 6)
- })
-
- it('FE-NOFEAR-ASM-016: fade dissolves the particle layer', () => {
- const a = seeded([0.1, 0.1, 0.1, 0.1, 0.1, 0])
- const main = makeCtx()
- a.draw(asCtx(main), 1, 0.5, 0)
- expect(main.fills[0].globalAlpha).toBeCloseTo(0.45, 6)
- })
-
- it('FE-NOFEAR-ASM-017: side entries start beyond the right edge and fly in', () => {
- // fromSide true, second draw >= 0.5 → spawn at screenW + 30
- const a = seeded([0.1, 0.9, 0.2, 0.4, 0.5, 0.3], { left: 0, top: 0, width: 12, height: 12 })
- const main = makeCtx()
- a.draw(asCtx(main), 0.18, 0, 0)
- expect(main.fills).toHaveLength(0)
-
- a.draw(asCtx(main), 0.59, 0, 0)
- expect(main.fills).toHaveLength(1)
- expect(main.fills[0].x).toBeCloseTo(128.75, 6)
- expect(main.fills[0].y).toBeCloseTo(15, 6)
- expect(main.fills[0].r).toBeCloseTo(1.5, 6)
- expect(main.fills[0].globalAlpha).toBeCloseTo(0.75 * (0.65 + 0.35 * Math.sin(2.1)), 6)
- })
-
- it('FE-NOFEAR-ASM-018: ground entries rise from below the viewport', () => {
- // fromSide false → sx inside the viewport, sy below screenH
- const a = seeded([0.5, 0.5, 0.5, 0.5, 0.5, 0.5], { left: 0, top: 0, width: 12, height: 12 })
- const main = makeCtx()
- a.draw(asCtx(main), 0.6125, 0, 0)
- expect(main.fills).toHaveLength(1)
- expect(main.fills[0].x).toBeCloseTo(62.5, 6)
- expect(main.fills[0].y).toBeCloseTo(82.5, 6)
- })
-})
diff --git a/client/src/components/FourZero/noFearAssembly.ts b/client/src/components/FourZero/noFearAssembly.ts
deleted file mode 100644
index d8f6b21ca..000000000
--- a/client/src/components/FourZero/noFearAssembly.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-// The finale's signature move: "KEINE ANGST" is not faded in — it CONDENSES.
-// Hundreds of light particles rise out of the world and gather into the
-// letterforms; once they settle, the real DOM title takes over for crispness.
-// The targets are sampled from an offscreen raster of the exact same text in
-// the exact same font, so the swap is seamless.
-
-interface AssemblyParticle {
- sx: number
- sy: number
- tx: number
- ty: number
- delay: number
- size: number
- seed: number
-}
-
-const easeOutCubic = (q: number): number => 1 - (1 - q) ** 3
-
-export class TextAssembly {
- private particles: AssemblyParticle[] = []
- private ready = false
-
- /**
- * Samples particle targets from the given text. `font` is a full CSS font
- * shorthand measured off the real DOM title; the box is the title's screen
- * rect so canvas particles land exactly where the DOM text will appear.
- */
- init(text: string, font: string, box: { left: number; top: number; width: number; height: number }, screenW: number, screenH: number): void {
- const off = document.createElement('canvas')
- // Raster at a capped size — targets only need ~2px precision.
- const scale = Math.min(1, 700 / Math.max(box.width, 1))
- off.width = Math.max(Math.round(box.width * scale), 1)
- off.height = Math.max(Math.round(box.height * scale), 1)
- const c = off.getContext('2d')
- // A re-init that cannot raster must go quiet rather than keep the previous
- // run's particles on screen at coordinates that no longer hold.
- this.ready = false
- this.particles = []
- if (!c) return
- c.font = font.replace(/(\d+(?:\.\d+)?)px/, (_, n) => `${Number(n) * scale}px`)
- c.textAlign = 'center'
- c.textBaseline = 'middle'
- c.fillStyle = '#fff'
- c.fillText(text, off.width / 2, off.height / 2)
- const img = c.getImageData(0, 0, off.width, off.height).data
- const step = 3 // sample grid in raster px — ~800-1400 particles for a title
- for (let y = 0; y < off.height; y += step) {
- for (let x = 0; x < off.width; x += step) {
- if (img[(y * off.width + x) * 4 + 3] > 128) {
- const tx = box.left + x / scale
- const ty = box.top + y / scale
- // Particles rise from below and drift in from the sides — they come
- // OUT of the world, not from nowhere.
- const fromSide = Math.random() < 0.3
- this.particles.push({
- sx: fromSide ? (Math.random() < 0.5 ? -30 : screenW + 30) : Math.random() * screenW,
- sy: fromSide ? Math.random() * screenH : screenH + 20 + Math.random() * 80,
- tx,
- ty,
- delay: Math.random() * 0.45,
- size: 0.9 + Math.random() * 1.2,
- seed: Math.random() * 7,
- })
- }
- }
- }
- this.ready = true
- }
-
- isReady(): boolean {
- return this.ready
- }
-
- /** progress 0→1 gathers, `fade` 0→1 dissolves the particles into the DOM text. */
- draw(c: CanvasRenderingContext2D, progress: number, fade: number, t: number): void {
- if (!this.ready || fade >= 1) return
- c.save()
- c.globalCompositeOperation = 'lighter'
- for (const p of this.particles) {
- const local = easeOutCubic(Math.min(Math.max((progress - p.delay) / (1 - p.delay), 0), 1))
- if (local <= 0) continue
- const x = p.sx + (p.tx - p.sx) * local
- const y = p.sy + (p.ty - p.sy) * local
- // In flight the particle glows warm; settled it cools toward the ivory of the text.
- const settled = local > 0.98
- const flicker = 0.65 + 0.35 * Math.sin(t * 5 + p.seed)
- c.globalAlpha = (1 - fade) * (settled ? 0.9 : 0.75 * flicker)
- c.fillStyle = settled ? 'rgb(247, 240, 226)' : 'rgb(255, 205, 130)'
- c.beginPath()
- c.arc(x, y, settled ? p.size * 0.85 : p.size, 0, Math.PI * 2)
- c.fill()
- }
- c.restore()
- }
-}
diff --git a/client/src/components/FourZero/noFearAudio.test.ts b/client/src/components/FourZero/noFearAudio.test.ts
deleted file mode 100644
index a25937174..000000000
--- a/client/src/components/FourZero/noFearAudio.test.ts
+++ /dev/null
@@ -1,969 +0,0 @@
-// FE-NOFEAR-AUD-001 to FE-NOFEAR-AUD-043
-import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
-import { NoFearAudio } from './noFearAudio'
-
-// jsdom ships no Web Audio implementation, so the graph below is a recorder:
-// every node keeps its outgoing connections, every AudioParam keeps the calls
-// that were scheduled on it, and the context clock is driven by `nowMs` so the
-// fake timers and the audio clock stay in lockstep.
-
-type NodeKind =
- | 'gain'
- | 'oscillator'
- | 'bufferSource'
- | 'biquad'
- | 'convolver'
- | 'compressor'
- | 'delay'
- | 'destination'
-
-let created: FakeNode[] = []
-let contexts: FakeAudioContext[] = []
-let nowMs = 0
-
-const behavior = {
- state: 'running' as AudioContextState,
- resumeRejects: false,
- suspendRejects: false,
- closeRejects: false,
-}
-
-class FakeAudioParam {
- value: number
- setValueAtTime = vi.fn((value: number, _at: number) => {
- this.value = value
- })
- linearRampToValueAtTime = vi.fn((_value: number, _at: number) => undefined)
- exponentialRampToValueAtTime = vi.fn((_value: number, _at: number) => undefined)
- setTargetAtTime = vi.fn((_value: number, _at: number, _timeConstant: number) => undefined)
- cancelScheduledValues = vi.fn((_at: number) => undefined)
-
- constructor(value = 0) {
- this.value = value
- }
-}
-
-class FakeNode {
- kind: NodeKind
- connections: unknown[] = []
- connect: ReturnType<typeof vi.fn>
- disconnect: ReturnType<typeof vi.fn>
-
- constructor(kind: NodeKind) {
- this.kind = kind
- this.connect = vi.fn((target: unknown) => {
- this.connections.push(target)
- return target
- })
- this.disconnect = vi.fn(() => {
- this.connections = []
- })
- created.push(this)
- }
-}
-
-class FakeSource extends FakeNode {
- started: number[] = []
- stopped: number[] = []
- throwOnStop = false
- start = vi.fn((at = 0) => {
- this.started.push(at)
- })
- stop = vi.fn((at = 0) => {
- if (this.throwOnStop) throw new Error('InvalidStateError')
- this.stopped.push(at)
- })
-}
-
-class FakeOscillator extends FakeSource {
- type = 'sine'
- frequency = new FakeAudioParam(440)
- detune = new FakeAudioParam(0)
-
- constructor() {
- super('oscillator')
- }
-}
-
-class FakeBufferSource extends FakeSource {
- buffer: FakeAudioBuffer | null = null
- loop = false
- playbackRate = new FakeAudioParam(1)
-
- constructor() {
- super('bufferSource')
- }
-}
-
-class FakeGain extends FakeNode {
- gain = new FakeAudioParam(1)
-
- constructor() {
- super('gain')
- }
-}
-
-class FakeBiquadFilter extends FakeNode {
- type = 'lowpass'
- frequency = new FakeAudioParam(350)
- Q = new FakeAudioParam(1)
- detune = new FakeAudioParam(0)
- gain = new FakeAudioParam(0)
-
- constructor() {
- super('biquad')
- }
-}
-
-class FakeConvolver extends FakeNode {
- buffer: FakeAudioBuffer | null = null
- normalize = true
-
- constructor() {
- super('convolver')
- }
-}
-
-class FakeCompressor extends FakeNode {
- threshold = new FakeAudioParam(-24)
- knee = new FakeAudioParam(30)
- ratio = new FakeAudioParam(12)
- attack = new FakeAudioParam(0.003)
- release = new FakeAudioParam(0.25)
-
- constructor() {
- super('compressor')
- }
-}
-
-class FakeDelay extends FakeNode {
- delayTime = new FakeAudioParam(0)
- maxDelayTime: number
-
- constructor(maxDelayTime: number) {
- super('delay')
- this.maxDelayTime = maxDelayTime
- }
-}
-
-class FakeAudioBuffer {
- numberOfChannels: number
- length: number
- sampleRate: number
- duration: number
- private channels: Float32Array[]
-
- constructor(numberOfChannels: number, length: number, sampleRate: number) {
- this.numberOfChannels = numberOfChannels
- this.length = length
- this.sampleRate = sampleRate
- this.duration = length / sampleRate
- this.channels = Array.from({ length: numberOfChannels }, () => new Float32Array(length))
- }
-
- getChannelData(channel: number): Float32Array {
- return this.channels[channel]
- }
-}
-
-class FakeAudioContext {
- state: AudioContextState
- // A low rate keeps the procedurally filled impulse response and noise buffer
- // small; the code only ever multiplies against it.
- sampleRate = 8000
- destination = new FakeNode('destination')
- resume = vi.fn(() =>
- behavior.resumeRejects ? Promise.reject(new Error('resume blocked')) : Promise.resolve(),
- )
- suspend = vi.fn(() =>
- behavior.suspendRejects ? Promise.reject(new Error('suspend blocked')) : Promise.resolve(),
- )
- close = vi.fn(() =>
- behavior.closeRejects ? Promise.reject(new Error('close failed')) : Promise.resolve(),
- )
- decodeAudioData = vi.fn(() => Promise.resolve(new FakeAudioBuffer(2, 16, 8000)))
-
- constructor() {
- this.state = behavior.state
- contexts.push(this)
- }
-
- get currentTime(): number {
- return nowMs / 1000
- }
-
- createGain(): FakeGain {
- return new FakeGain()
- }
- createOscillator(): FakeOscillator {
- return new FakeOscillator()
- }
- createBufferSource(): FakeBufferSource {
- return new FakeBufferSource()
- }
- createBiquadFilter(): FakeBiquadFilter {
- return new FakeBiquadFilter()
- }
- createConvolver(): FakeConvolver {
- return new FakeConvolver()
- }
- createDynamicsCompressor(): FakeCompressor {
- return new FakeCompressor()
- }
- createDelay(maxDelayTime = 1): FakeDelay {
- return new FakeDelay(maxDelayTime)
- }
- createBuffer(numberOfChannels: number, length: number, sampleRate: number): FakeAudioBuffer {
- return new FakeAudioBuffer(numberOfChannels, length, sampleRate)
- }
-}
-
-// ── query helpers ────────────────────────────────────────────────────────────
-
-function mark(): number {
- return created.length
-}
-
-function since(from: number): FakeNode[] {
- return created.slice(from)
-}
-
-function oscs(list: FakeNode[]): FakeOscillator[] {
- return list.filter((n) => n.kind === 'oscillator') as FakeOscillator[]
-}
-
-function bufs(list: FakeNode[]): FakeBufferSource[] {
- return list.filter((n) => n.kind === 'bufferSource') as FakeBufferSource[]
-}
-
-function gains(list: FakeNode[]): FakeGain[] {
- return list.filter((n) => n.kind === 'gain') as FakeGain[]
-}
-
-function filters(list: FakeNode[]): FakeBiquadFilter[] {
- return list.filter((n) => n.kind === 'biquad') as FakeBiquadFilter[]
-}
-
-function only<T>(list: T[]): T {
- expect(list).toHaveLength(1)
- return list[0]
-}
-
-function ctx(): FakeAudioContext {
- return contexts[contexts.length - 1]
-}
-
-function compressor(): FakeCompressor {
- return created.find((n) => n.kind === 'compressor') as FakeCompressor
-}
-
-function masterGain(): FakeGain {
- const limiter = compressor()
- return gains(created).find((g) => g.connections.includes(limiter)) as FakeGain
-}
-
-function reverbIn(): FakeGain {
- const convolver = created.find((n) => n.kind === 'convolver')
- return gains(created).find((g) => g.connections.includes(convolver)) as FakeGain
-}
-
-/** How much of `node` is sent into the hall, or undefined when it stays dry. */
-function hallSend(node: FakeNode): number | undefined {
- const hall = reverbIn()
- const send = node.connections.find(
- (target) => target instanceof FakeGain && target.connections.includes(hall),
- )
- return (send as FakeGain | undefined)?.gain.value
-}
-
-/** Start times of the heartbeat's sine bodies — its 58 Hz drop is the signature. */
-function thumpTimes(list: FakeNode[]): number[] {
- return oscs(list)
- .filter((o) => o.frequency.setValueAtTime.mock.calls.some((call) => call[0] === 58))
- .map((o) => o.started[0])
-}
-
-function rms(data: Float32Array, from: number, to: number): number {
- let sum = 0
- for (let i = from; i < to; i++) sum += data[i] * data[i]
- return Math.sqrt(sum / (to - from))
-}
-
-/** Advances the audio clock and the timer queue together, in interval-sized steps. */
-function advance(ms: number): void {
- let left = ms
- while (left > 0) {
- const step = Math.min(50, left)
- nowMs += step
- vi.advanceTimersByTime(step)
- left -= step
- }
-}
-
-describe('NoFearAudio', () => {
- let audio: NoFearAudio
-
- beforeEach(() => {
- vi.useFakeTimers()
- created = []
- contexts = []
- nowMs = 0
- behavior.state = 'running'
- behavior.resumeRejects = false
- behavior.suspendRejects = false
- behavior.closeRejects = false
- vi.stubGlobal('AudioContext', FakeAudioContext)
- vi.stubGlobal('webkitAudioContext', undefined)
- audio = new NoFearAudio()
- })
-
- afterEach(() => {
- vi.useRealTimers()
- vi.unstubAllGlobals()
- })
-
- describe('start', () => {
- it('FE-NOFEAR-AUD-001: routes master through a limiter into the destination', () => {
- audio.start()
-
- const limiter = compressor()
- expect(limiter.threshold.value).toBe(-12)
- expect(limiter.knee.value).toBe(22)
- expect(limiter.ratio.value).toBe(12)
- expect(limiter.connections).toEqual([ctx().destination])
- expect(masterGain().gain.value).toBe(0.9)
- expect(masterGain().connections).toEqual([limiter])
- })
-
- it('FE-NOFEAR-AUD-002: is idempotent — a second call keeps the first context', () => {
- audio.start()
- audio.start()
-
- expect(contexts).toHaveLength(1)
- })
-
- it('FE-NOFEAR-AUD-003: without a Web Audio constructor every entry point stays a no-op', () => {
- vi.stubGlobal('AudioContext', undefined)
-
- audio.start()
- audio.setMuted(true)
- audio.resume()
- audio.setSuspended(true)
- audio.swell()
- audio.impact()
- audio.setAct('fear')
- audio.dispose()
-
- expect(contexts).toHaveLength(0)
- expect(created).toHaveLength(0)
- })
-
- it('FE-NOFEAR-AUD-004: falls back to the prefixed webkitAudioContext', () => {
- vi.stubGlobal('AudioContext', undefined)
- vi.stubGlobal('webkitAudioContext', FakeAudioContext)
-
- audio.start()
-
- expect(contexts).toHaveLength(1)
- expect(masterGain().gain.value).toBe(0.9)
- })
-
- it('FE-NOFEAR-AUD-005: re-arms a context the browser started suspended', () => {
- behavior.state = 'suspended'
-
- audio.start()
-
- expect(ctx().resume).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-AUD-006: swallows a rejected resume on start', async () => {
- behavior.state = 'suspended'
- behavior.resumeRejects = true
-
- expect(() => audio.start()).not.toThrow()
- await Promise.resolve()
-
- expect(ctx().resume).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-AUD-007: builds a 3.4s stereo impulse response that decays', () => {
- audio.start()
-
- const convolver = created.find((n) => n.kind === 'convolver') as FakeConvolver
- const ir = convolver.buffer as FakeAudioBuffer
- expect(ir.numberOfChannels).toBe(2)
- expect(ir.length).toBe(Math.floor(8000 * 3.4))
- const left = ir.getChannelData(0)
- expect(rms(left, 0, 400)).toBeGreaterThan(rms(left, left.length - 400, left.length))
- expect(rms(ir.getChannelData(1), 0, 400)).toBeGreaterThan(0)
- })
-
- it('FE-NOFEAR-AUD-008: returns the hall through a 0.5 wet gain on the master bus', () => {
- audio.start()
-
- const convolver = created.find((n) => n.kind === 'convolver') as FakeConvolver
- expect(reverbIn().connections).toEqual([convolver])
- const wet = gains(created).find((g) => convolver.connections.includes(g)) as FakeGain
- expect(wet.gain.value).toBe(0.5)
- expect(wet.connections).toEqual([masterGain()])
- })
-
- it('FE-NOFEAR-AUD-009: fills a 2s noise buffer that every texture reuses', () => {
- audio.start()
- const m = mark()
- audio.setAct('fear')
-
- const noise = bufs(since(m))
- expect(noise.length).toBeGreaterThan(0)
- const buffer = noise[0].buffer as FakeAudioBuffer
- expect(buffer.length).toBe(8000 * 2)
- expect(buffer.numberOfChannels).toBe(1)
- const data = buffer.getChannelData(0)
- expect(rms(data, 0, 1000)).toBeGreaterThan(0.4)
- expect(Math.max(...data.slice(0, 1000))).toBeLessThan(1)
- expect(Math.min(...data.slice(0, 1000))).toBeGreaterThan(-1)
- // all textures share the one buffer
- expect(noise.every((n) => n.buffer === buffer)).toBe(true)
- })
-
- it('FE-NOFEAR-AUD-010: starts silent when the show was muted before the gesture', () => {
- audio.setMuted(true)
- audio.start()
-
- expect(masterGain().gain.value).toBe(0)
- })
- })
-
- describe('transport', () => {
- it('FE-NOFEAR-AUD-011: setMuted ramps the master down and back up', () => {
- audio.start()
- const master = masterGain()
-
- audio.setMuted(true)
- expect(master.gain.setTargetAtTime).toHaveBeenLastCalledWith(0, 0, 0.05)
-
- advance(500)
- audio.setMuted(false)
- expect(master.gain.setTargetAtTime).toHaveBeenLastCalledWith(0.9, 0.5, 0.05)
- })
-
- it('FE-NOFEAR-AUD-012: unmuting recovers a context the browser refused to start', () => {
- audio.start()
- ctx().state = 'suspended'
-
- audio.setMuted(false)
-
- expect(ctx().resume).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-AUD-013: muting never tries to resume', () => {
- audio.start()
- ctx().state = 'suspended'
-
- audio.setMuted(true)
-
- expect(ctx().resume).not.toHaveBeenCalled()
- })
-
- it('FE-NOFEAR-AUD-014: resume only touches a suspended context', () => {
- audio.start()
-
- audio.resume()
- expect(ctx().resume).not.toHaveBeenCalled()
-
- ctx().state = 'suspended'
- audio.resume()
- expect(ctx().resume).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-AUD-043: a browser that rejects resume/suspend never surfaces the error', async () => {
- behavior.resumeRejects = true
- behavior.suspendRejects = true
- audio.start()
- ctx().state = 'suspended'
-
- audio.setMuted(false)
- audio.resume()
- audio.setSuspended(true)
- audio.setSuspended(false)
- await Promise.resolve()
- await Promise.resolve()
-
- expect(ctx().resume).toHaveBeenCalledTimes(3)
- expect(ctx().suspend).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-AUD-015: setSuspended freezes and unfreezes with the show clock', () => {
- audio.start()
-
- audio.setSuspended(true)
- expect(ctx().suspend).toHaveBeenCalledTimes(1)
- expect(ctx().resume).not.toHaveBeenCalled()
-
- audio.setSuspended(false)
- expect(ctx().resume).toHaveBeenCalledTimes(1)
- })
- })
-
- describe('one-shots', () => {
- it('FE-NOFEAR-AUD-016: swell blooms a 55 Hz sine over 1.6s and dies at +5', () => {
- audio.start()
- const m = mark()
-
- audio.swell()
-
- const o = only(oscs(since(m)))
- expect(o.type).toBe('sine')
- expect(o.frequency.value).toBe(55)
- expect(o.started[0]).toBeCloseTo(0.05)
- expect(o.stopped[0]).toBeCloseTo(5.25)
- const envelope = gains(since(m))[0]
- expect(o.connections).toEqual([envelope])
- const ramps = envelope.gain.exponentialRampToValueAtTime.mock.calls
- expect(ramps[0][0]).toBeCloseTo(0.22)
- expect(ramps[0][1]).toBeCloseTo(1.65)
- expect(ramps[1][0]).toBeCloseTo(0.0001)
- expect(ramps[1][1]).toBeCloseTo(5.05)
- expect(hallSend(envelope)).toBe(0.6)
- })
-
- it('FE-NOFEAR-AUD-017: impact drops a sub from 82 to 28 Hz and scales with strength', () => {
- audio.start()
- const m = mark()
-
- audio.impact(0.5)
-
- const sub = oscs(since(m))[0]
- expect(sub.frequency.setValueAtTime.mock.calls[0][0]).toBe(82)
- const sweep = sub.frequency.exponentialRampToValueAtTime.mock.calls[0]
- expect(sweep[0]).toBe(28)
- expect(sweep[1]).toBeCloseTo(0.92)
- expect(sub.started[0]).toBeCloseTo(0.02)
- expect(sub.stopped[0]).toBeCloseTo(1.82)
- const body = gains(since(m))[0]
- expect(body.gain.exponentialRampToValueAtTime.mock.calls[0][0]).toBeCloseTo(0.45)
- expect(hallSend(body)).toBe(0.5)
- })
-
- it('FE-NOFEAR-AUD-018: impact doubles the sub with a lowpassed noise burst', () => {
- audio.start()
- const m = mark()
-
- audio.impact()
-
- const burst = only(bufs(since(m)))
- expect(burst.started[0]).toBeCloseTo(0.02)
- expect(burst.stopped[0]).toBeCloseTo(0.82)
- const lp = only(filters(since(m)))
- expect(lp.type).toBe('lowpass')
- expect(lp.frequency.setValueAtTime.mock.calls[0][0]).toBe(900)
- expect(lp.frequency.exponentialRampToValueAtTime.mock.calls[0][0]).toBe(120)
- expect(burst.connections).toEqual([lp])
- const noiseGain = gains(since(m)).find((g) => lp.connections.includes(g)) as FakeGain
- expect(noiseGain.gain.exponentialRampToValueAtTime.mock.calls[0][0]).toBeCloseTo(0.3)
- expect(hallSend(noiseGain)).toBe(0.6)
- })
- })
-
- describe('acts', () => {
- it('FE-NOFEAR-AUD-019: fear lays a sub, a drifting fifth and a breathing rumble', () => {
- audio.start()
- const m = mark()
-
- audio.setAct('fear')
-
- const list = since(m)
- const sub = oscs(list).find((o) => o.type === 'sine' && o.frequency.value === 55)
- expect(sub).toBeDefined()
- const fifth = oscs(list).find((o) => o.type === 'triangle' && o.frequency.value === 82.4)
- expect(fifth).toBeDefined()
- // the detune LFO drives the fifth's detune param, not its output
- const drift = gains(list).find((g) => g.connections.includes(fifth!.detune)) as FakeGain
- expect(drift.gain.value).toBe(6)
- // the rumble's gain breathes from a second LFO
- const rumble = bufs(list).find((n) => n.loop) as FakeBufferSource
- const rlp = filters(list).find((f) => rumble.connections.includes(f)) as FakeBiquadFilter
- expect(rlp.type).toBe('lowpass')
- expect(rlp.frequency.value).toBe(120)
- const rumbleGain = gains(list).find((g) => rlp.connections.includes(g)) as FakeGain
- const breathe = gains(list).find((g) => g.connections.includes(rumbleGain.gain)) as FakeGain
- expect(breathe.gain.value).toBe(0.25)
- // no grind semitone in the fear act
- expect(oscs(list).some((o) => o.frequency.value === 58.27)).toBe(false)
- })
-
- it('FE-NOFEAR-AUD-020: fear opens the bed and the wind from silence', () => {
- audio.start()
- const m = mark()
-
- audio.setAct('fear')
-
- const list = since(m)
- const bed = gains(list)[0]
- expect(bed.gain.setValueAtTime.mock.calls[0][0]).toBe(0.0001)
- expect(bed.gain.exponentialRampToValueAtTime.mock.calls[0]).toEqual([0.16, 3])
- expect(hallSend(bed)).toBe(0.3)
- const bp = filters(list).find((f) => f.type === 'bandpass') as FakeBiquadFilter
- expect(bp.frequency.value).toBe(420)
- expect(bp.Q.value).toBe(0.6)
- })
-
- it('FE-NOFEAR-AUD-021: the wind LFO modulates a series stage, never the release envelope', () => {
- audio.start()
- const m = mark()
-
- audio.setAct('fear')
-
- const list = since(m)
- const trem = gains(list).find((g) => g.gain.value === 0.75) as FakeGain
- expect(trem).toBeDefined()
- const lfoGain = gains(list).find((g) => g.connections.includes(trem.gain)) as FakeGain
- expect(lfoGain.gain.value).toBe(0.4)
- // the wind envelope itself must stay free of LFO input, otherwise the hard
- // cut into the silence act could never mute it
- const windEnv = gains(list).find((g) => trem.connections.includes(g)) as FakeGain
- expect(gains(list).some((g) => g.connections.includes(windEnv.gain))).toBe(false)
- })
-
- it('FE-NOFEAR-AUD-022: dread adds the grinding semitone and a 14s riser', () => {
- audio.start()
- const m = mark()
-
- audio.setAct('dread')
-
- const list = since(m)
- expect(oscs(list).some((o) => o.frequency.value === 58.27)).toBe(true)
- const riser = only(oscs(list).filter((o) => o.type === 'sawtooth'))
- expect(riser.frequency.setValueAtTime.mock.calls[0][0]).toBe(180)
- expect(riser.frequency.exponentialRampToValueAtTime.mock.calls[0]).toEqual([820, 14])
- const riserBp = filters(list).find(
- (f) => f.type === 'bandpass' && f.Q.value === 8,
- ) as FakeBiquadFilter
- expect(riserBp.frequency.exponentialRampToValueAtTime.mock.calls[0]).toEqual([1400, 14])
- const noiseSweep = filters(list).find(
- (f) => f.type === 'bandpass' && f.Q.value === 1.4,
- ) as FakeBiquadFilter
- expect(noiseSweep.frequency.exponentialRampToValueAtTime.mock.calls[0]).toEqual([3200, 14])
- })
-
- it('FE-NOFEAR-AUD-023: setting the same act twice changes nothing', () => {
- audio.start()
- audio.setAct('fear')
- const m = mark()
-
- audio.setAct('fear')
-
- expect(since(m)).toHaveLength(0)
- })
-
- it('FE-NOFEAR-AUD-024: silence pulls the fear act away fast and stops the beat', () => {
- audio.start()
- const m = mark()
- audio.setAct('fear')
- const bed = gains(since(m))[0]
- const bedOscs = oscs(since(m))
- advance(400)
-
- const afterCut = mark()
- audio.setAct('silence')
-
- // release 0.6 instead of the usual 1.6
- expect(bed.gain.cancelScheduledValues).toHaveBeenCalledWith(0)
- const target = bed.gain.setTargetAtTime.mock.calls[0]
- expect(target[0]).toBe(0)
- expect(target[1]).toBeCloseTo(0.9)
- expect(target[2]).toBe(0.25)
- expect(bedOscs[0].stopped[0]).toBeCloseTo(2.5)
-
- advance(2000)
- expect(thumpTimes(since(afterCut))).toHaveLength(0)
- })
-
- it('FE-NOFEAR-AUD-025: a normal act change uses the slow 1.6s release', () => {
- audio.start()
- const m = mark()
- audio.setAct('fear')
- const bedOscs = oscs(since(m))
-
- audio.setAct('dread')
-
- expect(bedOscs[0].stopped[0]).toBeCloseTo(3.1)
- })
-
- it('FE-NOFEAR-AUD-026: hope opens the progression without a sub root', () => {
- audio.start()
- const m = mark()
-
- audio.setAct('hope')
-
- const list = since(m)
- const pads = oscs(list).filter((o) => o.type === 'triangle')
- expect(pads).toHaveLength(10)
- expect(oscs(list).some((o) => o.type === 'sine')).toBe(false)
- const lp = only(filters(list))
- expect(lp.frequency.setValueAtTime.mock.calls[0][0]).toBeCloseTo(245)
- expect(lp.frequency.exponentialRampToValueAtTime.mock.calls[0]).toEqual([700, 7])
- const padGain = gains(list).find((g) => lp.connections.includes(g)) as FakeGain
- expect(padGain.gain.exponentialRampToValueAtTime.mock.calls[0]).toEqual([0.085, 3.2])
- expect(hallSend(padGain)).toBe(0.55)
- })
-
- it('FE-NOFEAR-AUD-027: the pad is ten detuned voices on the opening D chord', () => {
- audio.start()
- const m = mark()
-
- audio.setAct('hope')
-
- const pads = oscs(since(m)).filter((o) => o.type === 'triangle')
- expect(pads.map((o) => o.frequency.value)).toEqual([
- 73.42, 73.42, 110.0, 110.0, 146.83, 146.83, 185.0, 185.0, 293.66, 293.66,
- ])
- expect(pads.map((o) => o.detune.value)).toEqual([-5, 5, -5, 5, -5, 5, -5, 5, -5, 5])
- expect(pads.every((o) => o.started[0] === 0)).toBe(true)
- })
-
- it('FE-NOFEAR-AUD-028: anthem adds a dry sub root and opens the filter wide', () => {
- audio.start()
- const m = mark()
-
- audio.setAct('anthem')
-
- const list = since(m)
- const lp = filters(list).find((f) => f.type === 'lowpass') as FakeBiquadFilter
- expect(lp.frequency.setValueAtTime.mock.calls[0][0]).toBeCloseTo(840)
- const sub = oscs(list).find((o) => o.frequency.value === 36.71) as FakeOscillator
- expect(sub.type).toBe('sine')
- const subGain = gains(list).find((g) => sub.connections.includes(g)) as FakeGain
- expect(subGain.gain.exponentialRampToValueAtTime.mock.calls[0]).toEqual([0.16, 2.5])
- // low end stays out of the hall, otherwise it turns to mud
- expect(hallSend(subGain)).toBeUndefined()
- expect(subGain.connections).toEqual([masterGain()])
- })
-
- it('FE-NOFEAR-AUD-029: anthem sprinkles pentatonic pings through a feedback delay', () => {
- audio.start()
- const m = mark()
-
- audio.setAct('anthem')
-
- const list = since(m)
- const delay = created.find((n) => n.kind === 'delay') as FakeDelay
- expect(delay.delayTime.value).toBe(0.38)
- const feedback = gains(list).find((g) => delay.connections.includes(g)) as FakeGain
- expect(feedback.gain.value).toBe(0.35)
- expect(feedback.connections).toEqual([delay])
- expect(hallSend(delay)).toBe(0.8)
-
- const pings = oscs(list).filter((o) => o.type === 'sine' && o.frequency.value !== 36.71)
- expect(pings).toHaveLength(14)
- const scale = [880, 1108.7, 1318.5, 1479.98, 1760]
- expect(pings.every((o) => scale.includes(o.frequency.value))).toBe(true)
- // one ping every ~0.8s, each ringing 2.1s
- expect(pings[0].started[0]).toBeGreaterThanOrEqual(0.8)
- expect(pings[13].started[0]).toBeGreaterThanOrEqual(0.8 + 13 * 0.8)
- expect(pings[0].stopped[0]).toBeCloseTo(pings[0].started[0] + 2.1)
- })
-
- it('FE-NOFEAR-AUD-030: end fades the master out on a long tail', () => {
- audio.start()
- const master = masterGain()
- advance(1000)
-
- audio.setAct('end')
-
- const call = master.gain.setTargetAtTime.mock.calls[0]
- expect(call[0]).toBe(0)
- expect(call[1]).toBeCloseTo(3.5)
- expect(call[2]).toBe(1.2)
- })
-
- it('FE-NOFEAR-AUD-031: acts before the first gesture are ignored', () => {
- audio.setAct('anthem')
-
- expect(created).toHaveLength(0)
- })
- })
-
- describe('progression', () => {
- it('FE-NOFEAR-AUD-032: steps the pad onto the next chord every 4.4s', () => {
- audio.start()
- const m = mark()
- audio.setAct('anthem')
- const pads = oscs(since(m)).filter((o) => o.type === 'triangle')
-
- advance(4400)
-
- const expected = [82.41, 82.41, 110.0, 110.0, 164.81, 164.81, 220.0, 220.0, 277.18, 277.18]
- pads.forEach((o, i) => {
- const call = o.frequency.setTargetAtTime.mock.calls[0]
- expect(call[0]).toBe(expected[i])
- expect(call[2]).toBe(0.55)
- })
- })
-
- it('FE-NOFEAR-AUD-033: the sub root walks D–E–F#–E and wraps around', () => {
- audio.start()
- const m = mark()
- audio.setAct('anthem')
- const sub = oscs(since(m)).find((o) => o.frequency.value === 36.71) as FakeOscillator
-
- advance(4400 * 4)
-
- const roots = sub.frequency.setTargetAtTime.mock.calls.map((call) => call[0])
- expect(roots).toEqual([41.2, 46.25, 41.2, 36.71])
- expect(sub.frequency.setTargetAtTime.mock.calls[0][2]).toBe(0.5)
- })
-
- it('FE-NOFEAR-AUD-034: hope has no sub, so only the pad glides', () => {
- audio.start()
- const m = mark()
- audio.setAct('hope')
- const opened = since(m)
- const pads = oscs(opened).filter((o) => o.type === 'triangle')
- expect(oscs(opened).some((o) => o.type === 'sine')).toBe(false)
-
- advance(4400)
-
- expect(pads[0].frequency.setTargetAtTime).toHaveBeenCalledTimes(1)
- expect(pads[0].frequency.setTargetAtTime.mock.calls[0][0]).toBe(82.41)
- })
-
- it('FE-NOFEAR-AUD-035: leaving the act stops the chord clock', () => {
- audio.start()
- const m = mark()
- audio.setAct('hope')
- const pads = oscs(since(m)).filter((o) => o.type === 'triangle')
-
- audio.setAct('end')
- advance(4400 * 2)
-
- expect(pads[0].frequency.setTargetAtTime).not.toHaveBeenCalled()
- })
- })
-
- describe('heartbeat', () => {
- it('FE-NOFEAR-AUD-036: schedules a beat plus its echo ahead of the clock', () => {
- audio.start()
- const m = mark()
-
- advance(1000)
-
- const times = thumpTimes(since(m))
- expect(times).toHaveLength(4)
- expect(times[0]).toBeCloseTo(0.2)
- expect(times[1]).toBeCloseTo(0.39)
- expect(times[2] - times[0]).toBeCloseTo(60 / 76)
- expect(times[3] - times[2]).toBeCloseTo(0.19)
- })
-
- it('FE-NOFEAR-AUD-037: a beat is a sine body plus a highpassed click', () => {
- audio.start()
- const m = mark()
-
- advance(100)
-
- const list = since(m)
- const body = oscs(list)[0]
- expect(body.type).toBe('sine')
- expect(body.frequency.exponentialRampToValueAtTime.mock.calls[0][0]).toBe(34)
- expect(body.stopped[0]).toBeCloseTo(0.52)
- const bodyGain = body.connections[0] as FakeGain
- expect(bodyGain.gain.exponentialRampToValueAtTime.mock.calls[0][0]).toBeCloseTo(0.55)
- expect(hallSend(bodyGain)).toBe(0.1)
-
- const click = bufs(list)[0]
- const hp = filters(list)[0]
- expect(hp.type).toBe('highpass')
- expect(hp.frequency.value).toBe(1700)
- expect(click.connections).toEqual([hp])
- const clickGain = gains(list).find((g) => hp.connections.includes(g)) as FakeGain
- expect(clickGain.gain.exponentialRampToValueAtTime.mock.calls[0][0]).toBeCloseTo(0.165)
- // the click is close, not in the hall
- expect(clickGain.connections).toEqual([masterGain()])
- })
-
- it('FE-NOFEAR-AUD-038: dread doubles the tempo and hits harder', () => {
- audio.start()
- audio.setAct('dread')
- const m = mark()
-
- advance(1000)
-
- const times = thumpTimes(since(m))
- expect(times).toHaveLength(6)
- expect(times[2] - times[0]).toBeCloseTo(60 / 116)
- const first = oscs(since(m))[0].connections[0] as FakeGain
- expect(first.gain.exponentialRampToValueAtTime.mock.calls[0][0]).toBeCloseTo(0.7)
- })
-
- it('FE-NOFEAR-AUD-039: clamps the beat clock instead of back-filling after the silence', () => {
- audio.start()
- audio.setAct('silence')
- advance(3000)
- const m = mark()
-
- audio.setAct('hope')
- advance(100)
-
- const times = thumpTimes(since(m))
- expect(times).toHaveLength(2)
- expect(times[0]).toBeCloseTo(3.2)
- expect(times[1]).toBeCloseTo(3.39)
- })
- })
-
- describe('teardown', () => {
- it('FE-NOFEAR-AUD-040: dispose mutes immediately and closes the context late', async () => {
- audio.start()
- const master = masterGain()
- audio.setAct('fear')
- const context = ctx()
- const m = mark()
-
- audio.dispose()
-
- expect(master.gain.setTargetAtTime).toHaveBeenLastCalledWith(0, 0, 0.05)
- expect(context.close).not.toHaveBeenCalled()
-
- advance(300)
- await Promise.resolve()
- expect(context.close).toHaveBeenCalledTimes(1)
-
- // the heartbeat interval is gone with it
- advance(2000)
- expect(thumpTimes(since(m))).toHaveLength(0)
- })
-
- it('FE-NOFEAR-AUD-041: dispose swallows a rejected close and survives a second call', async () => {
- behavior.closeRejects = true
- audio.start()
- const context = ctx()
-
- audio.dispose()
- advance(300)
- await Promise.resolve()
- expect(context.close).toHaveBeenCalledTimes(1)
-
- const m = mark()
- expect(() => audio.dispose()).not.toThrow()
- advance(300)
- expect(context.close).toHaveBeenCalledTimes(1)
- audio.swell()
- audio.impact()
- audio.setAct('anthem')
- expect(since(m)).toHaveLength(0)
- })
-
- it('FE-NOFEAR-AUD-042: a voice that refuses to stop does not break the act change', () => {
- audio.start()
- const m = mark()
- audio.setAct('anthem')
- const voices = [...oscs(since(m)), ...bufs(since(m))]
- for (const v of voices) v.throwOnStop = true
-
- expect(() => audio.setAct('end')).not.toThrow()
-
- expect(voices.every((v) => v.stop.mock.calls.length > 0)).toBe(true)
- })
- })
-})
diff --git a/client/src/components/FourZero/noFearAudio.ts b/client/src/components/FourZero/noFearAudio.ts
deleted file mode 100644
index b6f7bf463..000000000
--- a/client/src/components/FourZero/noFearAudio.ts
+++ /dev/null
@@ -1,530 +0,0 @@
-// Procedural soundtrack for the 4.0.0 "KEINE ANGST" show. Everything is
-// synthesized with the Web Audio API at runtime — no audio assets, no
-// copyrighted material. The cinema comes from three things: a convolution
-// reverb fed by a procedurally generated impulse response (dry synthesis
-// always sounds like a buzzer; a hall makes it a room), an organic low bed of
-// sub sine + filtered rumble instead of raw sawtooths, and cue-driven sub
-// impacts whose tails bloom in that same hall.
-
-export type NoFearAct = 'fear' | 'dread' | 'silence' | 'hope' | 'anthem' | 'end'
-
-interface Voice {
- stop: (at: number) => void
-}
-
-// The hope/anthem harmony: D — A — f#m — E in open voicings, five gliding
-// voices each. Movement is what makes the release feel alive.
-const PROGRESSION: number[][] = [
- [73.42, 110.0, 146.83, 185.0, 293.66], // D2 A2 D3 F#3 D4
- [82.41, 110.0, 164.81, 220.0, 277.18], // E2 A2 E3 A3 C#4
- [92.5, 110.0, 138.59, 185.0, 277.18], // F#2 A2 C#3 F#3 C#4
- [82.41, 123.47, 164.81, 207.65, 246.94], // E2 B2 E3 G#3 B3
-]
-const CHORD_SECONDS = 4.4
-const BASS_ROOTS = [36.71, 41.2, 46.25, 41.2] // D1 E1 F#1 E1
-
-export class NoFearAudio {
- private ctx: AudioContext | null = null
- private master: GainNode | null = null
- private reverbIn: GainNode | null = null
- private noiseBuf: AudioBuffer | null = null
- private muted = false
- private act: NoFearAct | null = null
- private heartbeatTimer: number | null = null
- private nextBeat = 0
- private bpm = 76
- private beatGain = 0.55
- private voices: Voice[] = []
- private padVoices: OscillatorNode[] = []
- private bassOsc: OscillatorNode | null = null
- private chordTimer: number | null = null
- private chordIdx = 0
-
- /** Must be called from a user gesture (the beacon click) so autoplay rules allow it. */
- start(): void {
- if (this.ctx) return
- const Ctor = window.AudioContext ?? (window as { webkitAudioContext?: typeof AudioContext }).webkitAudioContext
- if (!Ctor) return
- this.ctx = new Ctor()
- // A lazily-loaded chunk can construct us a beat after the click gesture —
- // resume() re-arms the context if the browser started it suspended.
- if (this.ctx.state === 'suspended') void this.ctx.resume().catch(() => {})
- const limiter = this.ctx.createDynamicsCompressor()
- limiter.threshold.value = -12
- limiter.knee.value = 22
- limiter.ratio.value = 12
- limiter.connect(this.ctx.destination)
- this.master = this.ctx.createGain()
- this.master.gain.value = this.muted ? 0 : 0.9
- this.master.connect(limiter)
- // The hall: a convolver fed by 3.4s of exponentially decaying stereo noise.
- // Everything sends into it in different amounts; the wet return rides the
- // same master gain so mute/fade cover it too.
- const convolver = this.ctx.createConvolver()
- convolver.buffer = this.makeImpulseResponse(3.4, 2.7)
- const wet = this.ctx.createGain()
- wet.gain.value = 0.5
- this.reverbIn = this.ctx.createGain()
- this.reverbIn.connect(convolver)
- convolver.connect(wet)
- wet.connect(this.master)
- // 2s of looped white noise feeds every texture (wind, rumble, risers, ticks).
- const len = this.ctx.sampleRate * 2
- this.noiseBuf = this.ctx.createBuffer(1, len, this.ctx.sampleRate)
- const data = this.noiseBuf.getChannelData(0)
- for (let i = 0; i < len; i++) data[i] = Math.random() * 2 - 1
- this.nextBeat = this.ctx.currentTime + 0.2
- this.heartbeatTimer = window.setInterval(() => this.scheduleBeats(), 100)
- }
-
- private makeImpulseResponse(seconds: number, decay: number): AudioBuffer {
- const ctx = this.ctx as AudioContext
- const rate = ctx.sampleRate
- const len = Math.floor(rate * seconds)
- const ir = ctx.createBuffer(2, len, rate)
- for (let ch = 0; ch < 2; ch++) {
- const d = ir.getChannelData(ch)
- for (let i = 0; i < len; i++) {
- d[i] = (Math.random() * 2 - 1) * (1 - i / len) ** decay
- }
- }
- return ir
- }
-
- /** Routes a node to the dry bus plus a measured send into the hall. */
- private out(node: AudioNode, send: number): void {
- if (!this.master || !this.reverbIn) return
- node.connect(this.master)
- if (send > 0) {
- const g = (this.ctx as AudioContext).createGain()
- g.gain.value = send
- node.connect(g)
- g.connect(this.reverbIn)
- }
- }
-
- setMuted(muted: boolean): void {
- this.muted = muted
- if (this.master && this.ctx) {
- // The mute button is a real gesture — use it as a recovery path for
- // browsers (Safari) that refused to start the context earlier.
- if (!muted && this.ctx.state === 'suspended') void this.ctx.resume().catch(() => {})
- this.master.gain.setTargetAtTime(muted ? 0 : 0.9, this.ctx.currentTime, 0.05)
- }
- }
-
- /** Best-effort resume from any fresh user gesture (overlay pointerdown). */
- resume(): void {
- if (this.ctx?.state === 'suspended') void this.ctx.resume().catch(() => {})
- }
-
- /** Freeze/unfreeze with the show clock when the tab goes hidden. */
- setSuspended(suspended: boolean): void {
- if (!this.ctx) return
- if (suspended) void this.ctx.suspend().catch(() => {})
- else void this.ctx.resume().catch(() => {})
- }
-
- /** A soft warm swell out of the silence — the first calm breath, not a hit. */
- swell(): void {
- if (!this.ctx || !this.master) return
- const t = this.ctx.currentTime + 0.05
- const o = this.ctx.createOscillator()
- o.type = 'sine'
- o.frequency.value = 55 // A1 — the root the hope act will grow from
- const g = this.ctx.createGain()
- g.gain.setValueAtTime(0.0001, t)
- g.gain.exponentialRampToValueAtTime(0.22, t + 1.6)
- g.gain.exponentialRampToValueAtTime(0.0001, t + 5)
- o.connect(g)
- this.out(g, 0.6)
- o.start(t); o.stop(t + 5.2)
- }
-
- /** A cue-driven cinema hit: sub boom + filtered noise burst, tail blooming in the hall. */
- impact(strength = 1): void {
- if (!this.ctx || !this.master) return
- const t = this.ctx.currentTime + 0.02
- const o = this.ctx.createOscillator()
- o.type = 'sine'
- o.frequency.setValueAtTime(82, t)
- o.frequency.exponentialRampToValueAtTime(28, t + 0.9)
- const g = this.ctx.createGain()
- g.gain.setValueAtTime(0.0001, t)
- g.gain.exponentialRampToValueAtTime(0.9 * strength, t + 0.018)
- g.gain.exponentialRampToValueAtTime(0.0001, t + 1.6)
- o.connect(g)
- this.out(g, 0.5)
- o.start(t); o.stop(t + 1.8)
- if (this.noiseBuf) {
- const n = this.ctx.createBufferSource()
- n.buffer = this.noiseBuf
- const lp = this.ctx.createBiquadFilter()
- lp.type = 'lowpass'
- lp.frequency.setValueAtTime(900, t)
- lp.frequency.exponentialRampToValueAtTime(120, t + 0.5)
- const ng = this.ctx.createGain()
- ng.gain.setValueAtTime(0.0001, t)
- ng.gain.exponentialRampToValueAtTime(0.3 * strength, t + 0.012)
- ng.gain.exponentialRampToValueAtTime(0.0001, t + 0.6)
- n.connect(lp); lp.connect(ng)
- this.out(ng, 0.6)
- n.start(t); n.stop(t + 0.8)
- }
- }
-
- setAct(act: NoFearAct): void {
- if (!this.ctx || !this.master || this.act === act) return
- this.act = act
- const t = this.ctx.currentTime
- // Into the silence: a fast pull-away rather than a hard kill — the fear's
- // hall tail is left ringing out on its own, like a room falling quiet.
- this.releaseVoices(act === 'silence' ? 0.6 : 1.6)
- this.stopChords()
- switch (act) {
- case 'fear':
- this.bpm = 74
- this.beatGain = 0.55
- this.darkBed(0.16, false)
- this.wind(0.05, 420)
- break
- case 'dread':
- this.bpm = 116
- this.beatGain = 0.7
- this.darkBed(0.21, true) // + a semitone rub that grinds
- this.wind(0.09, 700)
- this.riser(t)
- break
- case 'silence':
- this.bpm = 0 // the cut itself is the effect
- break
- case 'hope':
- this.bpm = 54
- this.beatGain = 0.3
- this.startChords(700, 0.085, false)
- break
- case 'anthem':
- this.bpm = 0
- this.startChords(2400, 0.075, true)
- this.shimmer(t)
- break
- case 'end':
- this.bpm = 0
- this.master.gain.setTargetAtTime(0, t + 2.5, 1.2)
- break
- }
- }
-
- dispose(): void {
- if (this.heartbeatTimer !== null) window.clearInterval(this.heartbeatTimer)
- this.heartbeatTimer = null
- this.stopChords()
- this.releaseVoices(0.1)
- // Pull the master down fast BEFORE the deferred close — closing mid-release
- // (voices still ~30% hot plus the hall tail) would pop.
- if (this.master && this.ctx) this.master.gain.setTargetAtTime(0, this.ctx.currentTime, 0.05)
- const ctx = this.ctx
- this.ctx = null
- this.master = null
- this.reverbIn = null
- if (ctx) window.setTimeout(() => { void ctx.close().catch(() => {}) }, 300)
- }
-
- // ── sustained voices ──────────────────────────────────────────────────────
-
- private releaseVoices(release: number): void {
- if (!this.ctx) return
- const at = this.ctx.currentTime + release
- for (const v of this.voices) v.stop(at)
- this.voices = []
- }
-
- private hold(gain: GainNode, oscs: (OscillatorNode | AudioBufferSourceNode)[]): void {
- this.voices.push({
- stop: (at) => {
- gain.gain.cancelScheduledValues(0)
- gain.gain.setTargetAtTime(0, Math.max(at - 0.1, 0), 0.25)
- for (const o of oscs) { try { o.stop(at + 1.5) } catch { /* already stopped */ } }
- },
- })
- }
-
- /**
- * The fear act's floor: a sine sub, a quiet detune-drifting fifth and a
- * low rumble of filtered noise that breathes — a room, not a synthesizer.
- * `grind` adds a close semitone against the sub that beats uneasily.
- */
- private darkBed(level: number, grind: boolean): void {
- if (!this.ctx || !this.noiseBuf) return
- const t = this.ctx.currentTime
- const g = this.ctx.createGain()
- g.gain.setValueAtTime(0.0001, t)
- g.gain.exponentialRampToValueAtTime(level, t + 3)
- const sub = this.ctx.createOscillator()
- sub.type = 'sine'
- sub.frequency.value = 55
- const subG = this.ctx.createGain()
- subG.gain.value = 0.85
- sub.connect(subG); subG.connect(g)
- const fifth = this.ctx.createOscillator()
- fifth.type = 'triangle'
- fifth.frequency.value = 82.4
- const fifthG = this.ctx.createGain()
- fifthG.gain.value = 0.3
- fifth.connect(fifthG); fifthG.connect(g)
- // Slow detune drift keeps the interval from ever sitting still.
- const drift = this.ctx.createOscillator()
- drift.frequency.value = 0.07
- const driftG = this.ctx.createGain()
- driftG.gain.value = 6
- drift.connect(driftG); driftG.connect(fifth.detune)
- const oscs: (OscillatorNode | AudioBufferSourceNode)[] = [sub, fifth, drift]
- if (grind) {
- const rub = this.ctx.createOscillator()
- rub.type = 'sine'
- rub.frequency.value = 58.27 // a semitone against the sub — it grinds
- const rubG = this.ctx.createGain()
- rubG.gain.value = 0.4
- rub.connect(rubG); rubG.connect(g)
- rub.start(t)
- oscs.push(rub)
- }
- // The rumble: looped noise through a low lowpass, its gain breathing slowly.
- const rumble = this.ctx.createBufferSource()
- rumble.buffer = this.noiseBuf
- rumble.loop = true
- const rlp = this.ctx.createBiquadFilter()
- rlp.type = 'lowpass'
- rlp.frequency.value = 120
- const rg = this.ctx.createGain()
- rg.gain.value = 0.5
- const breathe = this.ctx.createOscillator()
- breathe.frequency.value = 0.06
- const breatheG = this.ctx.createGain()
- breatheG.gain.value = 0.25
- breathe.connect(breatheG); breatheG.connect(rg.gain)
- rumble.connect(rlp); rlp.connect(rg); rg.connect(g)
- sub.start(t); fifth.start(t); drift.start(t); rumble.start(t); breathe.start(t)
- oscs.push(rumble, breathe)
- this.out(g, 0.3)
- this.hold(g, oscs)
- }
-
- /** Bandpassed noise that slowly swells and recedes — wind through the scene. */
- private wind(level: number, freq: number): void {
- if (!this.ctx || !this.noiseBuf) return
- const t = this.ctx.currentTime
- const src = this.ctx.createBufferSource()
- src.buffer = this.noiseBuf
- src.loop = true
- const bp = this.ctx.createBiquadFilter()
- bp.type = 'bandpass'
- bp.frequency.value = freq
- bp.Q.value = 0.6
- const g = this.ctx.createGain()
- g.gain.setValueAtTime(0.0001, t)
- g.gain.exponentialRampToValueAtTime(level, t + 4)
- // The swell LFO modulates a SERIES tremolo stage, not g itself — an input
- // on g.gain would ADD to the release automation and the wind could never
- // be silenced for the hard cut into the silence act.
- const trem = this.ctx.createGain()
- trem.gain.value = 0.75
- const lfo = this.ctx.createOscillator()
- lfo.frequency.value = 0.07
- const lfoGain = this.ctx.createGain()
- lfoGain.gain.value = 0.4
- lfo.connect(lfoGain); lfoGain.connect(trem.gain)
- lfo.start(t)
- src.connect(bp); bp.connect(trem); trem.connect(g)
- this.out(g, 0.55)
- src.start(t)
- this.hold(g, [src, lfo])
- }
-
- /** Trailer riser: a saw sweep doubled by a noise sweep, 14s of climb. */
- private riser(t: number): void {
- if (!this.ctx) return
- const o = this.ctx.createOscillator()
- o.type = 'sawtooth'
- o.frequency.setValueAtTime(180, t)
- o.frequency.exponentialRampToValueAtTime(820, t + 14)
- const bp = this.ctx.createBiquadFilter()
- bp.type = 'bandpass'
- bp.frequency.setValueAtTime(300, t)
- bp.frequency.exponentialRampToValueAtTime(1400, t + 14)
- bp.Q.value = 8
- const g = this.ctx.createGain()
- g.gain.setValueAtTime(0.0001, t)
- g.gain.exponentialRampToValueAtTime(0.05, t + 7)
- o.connect(bp); bp.connect(g)
- this.out(g, 0.35)
- o.start(t)
- const nodes: (OscillatorNode | AudioBufferSourceNode)[] = [o]
- if (this.noiseBuf) {
- const n = this.ctx.createBufferSource()
- n.buffer = this.noiseBuf
- n.loop = true
- const nbp = this.ctx.createBiquadFilter()
- nbp.type = 'bandpass'
- nbp.frequency.setValueAtTime(240, t)
- nbp.frequency.exponentialRampToValueAtTime(3200, t + 14)
- nbp.Q.value = 1.4
- const ng = this.ctx.createGain()
- ng.gain.setValueAtTime(0.0001, t)
- ng.gain.exponentialRampToValueAtTime(0.08, t + 12)
- n.connect(nbp); nbp.connect(ng)
- this.out(ng, 0.35)
- n.start(t)
- nodes.push(n)
- this.hold(ng, [n])
- }
- this.hold(g, nodes)
- }
-
- // ── the progression ───────────────────────────────────────────────────────
-
- /** Five gliding triangle voices + a sub root, stepping through D–A–f#m–E. */
- private startChords(cutoff: number, level: number, withSub: boolean): void {
- if (!this.ctx) return
- const t = this.ctx.currentTime
- const lp = this.ctx.createBiquadFilter()
- lp.type = 'lowpass'
- lp.frequency.setValueAtTime(cutoff * 0.35, t)
- lp.frequency.exponentialRampToValueAtTime(cutoff, t + 7)
- const g = this.ctx.createGain()
- g.gain.setValueAtTime(0.0001, t)
- g.gain.exponentialRampToValueAtTime(level, t + 3.2)
- this.padVoices = []
- const first = PROGRESSION[0]
- const oscs: OscillatorNode[] = []
- for (let v = 0; v < first.length; v++) {
- for (const det of [-5, 5]) {
- const o = this.ctx.createOscillator()
- o.type = 'triangle'
- o.frequency.value = first[v]
- o.detune.value = det
- o.connect(lp)
- o.start(t)
- oscs.push(o)
- this.padVoices.push(o)
- }
- }
- lp.connect(g)
- this.out(g, 0.55) // the pad lives IN the hall — that's what makes it big
- this.hold(g, oscs)
- if (withSub) {
- const sub = this.ctx.createOscillator()
- sub.type = 'sine'
- sub.frequency.value = BASS_ROOTS[0]
- const sg = this.ctx.createGain()
- sg.gain.setValueAtTime(0.0001, t)
- sg.gain.exponentialRampToValueAtTime(0.16, t + 2.5)
- sub.connect(sg)
- this.out(sg, 0) // sub stays dry — low end in the hall turns to mud
- sub.start(t)
- this.bassOsc = sub
- this.hold(sg, [sub])
- }
- this.chordIdx = 0
- this.chordTimer = window.setInterval(() => this.nextChord(), CHORD_SECONDS * 1000)
- }
-
- private nextChord(): void {
- if (!this.ctx || this.padVoices.length === 0) return
- this.chordIdx = (this.chordIdx + 1) % PROGRESSION.length
- const chord = PROGRESSION[this.chordIdx]
- const t = this.ctx.currentTime
- for (let i = 0; i < this.padVoices.length; i++) {
- const target = chord[Math.floor(i / 2) % chord.length]
- this.padVoices[i].frequency.setTargetAtTime(target, t, 0.55)
- }
- this.bassOsc?.frequency.setTargetAtTime(BASS_ROOTS[this.chordIdx], t, 0.5)
- }
-
- private stopChords(): void {
- if (this.chordTimer !== null) window.clearInterval(this.chordTimer)
- this.chordTimer = null
- this.padVoices = []
- this.bassOsc = null
- }
-
- /** Sparse pentatonic pings through a feedback echo, drowned in the hall. */
- private shimmer(t: number): void {
- if (!this.ctx) return
- const notes = [880, 1108.7, 1318.5, 1479.98, 1760]
- const g = this.ctx.createGain()
- g.gain.value = 0.045
- // A 0.38s feedback delay turns each ping into a trailing echo.
- const delay = this.ctx.createDelay(1)
- delay.delayTime.value = 0.38
- const fb = this.ctx.createGain()
- fb.gain.value = 0.35
- delay.connect(fb); fb.connect(delay)
- g.connect(delay)
- this.out(g, 0.8)
- this.out(delay, 0.8)
- const oscs: OscillatorNode[] = []
- for (let i = 0; i < 14; i++) {
- const o = this.ctx.createOscillator()
- o.type = 'sine'
- o.frequency.value = notes[Math.floor(Math.random() * notes.length)]
- const eg = this.ctx.createGain()
- const at = t + 0.8 + i * 0.8 + Math.random() * 0.4
- eg.gain.setValueAtTime(0.0001, at)
- eg.gain.exponentialRampToValueAtTime(1, at + 0.02)
- eg.gain.exponentialRampToValueAtTime(0.0001, at + 1.9)
- o.connect(eg); eg.connect(g)
- o.start(at)
- o.stop(at + 2.1)
- oscs.push(o)
- }
- this.voices.push({ stop: (stopAt) => { g.gain.setTargetAtTime(0, stopAt, 0.2); for (const o of oscs) { try { o.stop(stopAt + 0.5) } catch { /* ok */ } } } })
- }
-
- // ── heartbeat ─────────────────────────────────────────────────────────────
-
- private scheduleBeats(): void {
- if (!this.ctx || !this.master || this.bpm <= 0) return
- // Clamp BEFORE scheduling: after a bpm=0 act (the silence) nextBeat lags far
- // behind and would otherwise back-fill a burst of past-due thumps at once.
- if (this.nextBeat < this.ctx.currentTime) this.nextBeat = this.ctx.currentTime + 0.1
- const ahead = this.ctx.currentTime + 0.3
- while (this.nextBeat < ahead) {
- this.thump(this.nextBeat, this.beatGain)
- this.thump(this.nextBeat + 0.19, this.beatGain * 0.55)
- this.nextBeat += 60 / this.bpm
- }
- }
-
- /** A heartbeat with body AND transient: low sine thump + tiny filtered click.
- Stays nearly dry — a heart is close, not in a hall. */
- private thump(at: number, level: number): void {
- if (!this.ctx || !this.master) return
- const o = this.ctx.createOscillator()
- o.type = 'sine'
- o.frequency.setValueAtTime(58, at)
- o.frequency.exponentialRampToValueAtTime(34, at + 0.12)
- const g = this.ctx.createGain()
- g.gain.setValueAtTime(0.0001, at)
- g.gain.exponentialRampToValueAtTime(level, at + 0.01)
- g.gain.exponentialRampToValueAtTime(0.0001, at + 0.24)
- o.connect(g)
- this.out(g, 0.1)
- o.start(at)
- o.stop(at + 0.32)
- if (this.noiseBuf) {
- const n = this.ctx.createBufferSource()
- n.buffer = this.noiseBuf
- const hp = this.ctx.createBiquadFilter()
- hp.type = 'highpass' // the CLICK of the valve — the sine above is the body
- hp.frequency.value = 1700
- const ng = this.ctx.createGain()
- ng.gain.setValueAtTime(0.0001, at)
- ng.gain.exponentialRampToValueAtTime(level * 0.3, at + 0.005)
- ng.gain.exponentialRampToValueAtTime(0.0001, at + 0.04)
- n.connect(hp); hp.connect(ng); ng.connect(this.master)
- n.start(at)
- n.stop(at + 0.07)
- }
- }
-}
diff --git a/client/src/components/FourZero/noFearLines.ts b/client/src/components/FourZero/noFearLines.ts
deleted file mode 100644
index 6092e21c4..000000000
--- a/client/src/components/FourZero/noFearLines.ts
+++ /dev/null
@@ -1,833 +0,0 @@
-// TREK 4.0.0 release moment — "KEINE ANGST". Temporary by design: this whole
-// folder ships for one release and is removed afterwards, so the copy lives in a
-// local dictionary instead of the shared i18n bundles (no parity churn across
-// 20+ locale files for a feature with a lifespan of one version).
-
-export interface NoFearCopy {
- beaconTitle: string
- beaconSub: string
- beaconCta: string
- // The show's spoken lines, in order. Index maps to the show script.
- lines: {
- afraid: string
- ofTheStranger: string
- fearTool: string
- hateTrade: string
- butYouTraveled: string
- tables: string
- face: string
- fences: string
- notAnOpinion: string
- everyDot: string
- yourPlaces: string
- yourStatsCountries: string
- yourStatsTrips: string
- }
- // Three staccato words flashed to the heartbeat in the fear act.
- flashes: [string, string, string]
- tooBeautiful: string
- anthem: string
- creditTitle: string
- creditBody: string
- inspiredBy: string
- close: string
- skip: string
- soundOn: string
- soundOff: string
-}
-
-const en: NoFearCopy = {
- beaconTitle: 'NO FEAR',
- beaconSub: 'A sign for an open world.',
- beaconCta: 'Press play.',
- lines: {
- afraid: 'They want you to be afraid.',
- ofTheStranger: 'Afraid of the stranger. Afraid of everything you don’t know.',
- fearTool: 'Because fear closes borders — first on maps, then in minds.',
- hateTrade: 'Fear is their tool. Hatred is their trade.',
- butYouTraveled: 'But you have traveled.',
- tables: 'You have eaten at foreign tables. Slept under foreign roofs. Laughed with strangers.',
- face: 'You know: the stranger has a face. And it looks like yours.',
- fences: 'No one who has seen the world wants it locked behind fences again.',
- notAnOpinion: 'Racism is not an opinion. Fascism is not an alternative.',
- everyDot: 'Every one of these lights is a table where someone was welcome.',
- yourPlaces: 'This — this was you.',
- yourStatsCountries: '{p} places. {c} countries. And not once did the world hurt you.',
- yourStatsTrips: '{p} places. {t} journeys. And not once did the world hurt you.',
- },
- flashes: ['FEAR.', 'HATRED.', 'WALLS.'],
- tooBeautiful: 'The world is too beautiful for fear. You have seen it yourself.',
- anthem: 'NO FEAR',
- creditTitle: 'TREK 4.0.0 — for an open world.',
- creditBody: 'Against racism, hatred and fascism. Travel turns strangers into neighbors.',
- inspiredBy: 'Inspired by Danger Dan — “Keine Angst”',
- close: 'Carry it on',
- skip: 'Skip',
- soundOn: 'Sound on',
- soundOff: 'Sound off',
-}
-
-const de: NoFearCopy = {
- beaconTitle: 'KEINE ANGST',
- beaconSub: 'Ein Zeichen für eine offene Welt.',
- beaconCta: 'Drück Play.',
- lines: {
- afraid: 'Sie wollen, dass du Angst hast.',
- ofTheStranger: 'Angst vor dem Fremden. Angst vor allem, was du nicht kennst.',
- fearTool: 'Denn Angst schließt Grenzen — erst auf Karten, dann in Köpfen.',
- hateTrade: 'Angst ist ihr Werkzeug. Hass ist ihr Geschäft.',
- butYouTraveled: 'Aber du bist gereist.',
- tables: 'Du hast an fremden Tischen gegessen. Unter fremden Dächern geschlafen. Mit Fremden gelacht.',
- face: 'Du weißt: Das Fremde hat ein Gesicht. Und es sieht aus wie deins.',
- fences: 'Niemand, der die Welt gesehen hat, will sie wieder hinter Zäune sperren.',
- notAnOpinion: 'Rassismus ist keine Meinung. Faschismus ist keine Alternative.',
- everyDot: 'Jedes dieser Lichter ist ein Tisch, an dem jemand willkommen war.',
- yourPlaces: 'Das hier — das warst du.',
- yourStatsCountries: '{p} Orte. {c} Länder. Und nicht ein einziges Mal hat die Welt dir wehgetan.',
- yourStatsTrips: '{p} Orte. {t} Reisen. Und nicht ein einziges Mal hat die Welt dir wehgetan.',
- },
- flashes: ['ANGST.', 'HASS.', 'MAUERN.'],
- tooBeautiful: 'Die Welt ist zu schön für Angst. Du hast sie selbst gesehen.',
- anthem: 'KEINE ANGST',
- creditTitle: 'TREK 4.0.0 — für eine offene Welt.',
- creditBody: 'Gegen Rassismus, Hass und Faschismus. Reisen macht aus Fremden Nachbarn.',
- inspiredBy: 'Inspiriert von Danger Dan — „Keine Angst“',
- close: 'Weitertragen',
- skip: 'Überspringen',
- soundOn: 'Ton an',
- soundOff: 'Ton aus',
-}
-
-const es: NoFearCopy = {
- beaconTitle: 'SIN MIEDO',
- beaconSub: 'Una señal por un mundo abierto.',
- beaconCta: 'Pulsa play.',
- lines: {
- afraid: 'Quieren que tengas miedo.',
- ofTheStranger: 'Miedo al extranjero. Miedo a todo lo que no conoces.',
- fearTool: 'Porque el miedo cierra fronteras — primero en los mapas, luego en las mentes.',
- hateTrade: 'El miedo es su herramienta. El odio, su negocio.',
- butYouTraveled: 'Pero tú has viajado.',
- tables: 'Has comido en mesas ajenas. Dormido bajo techos ajenos. Reído con desconocidos.',
- face: 'Lo sabes: el extranjero tiene un rostro. Y se parece al tuyo.',
- fences: 'Nadie que haya visto el mundo quiere volver a encerrarlo tras vallas.',
- notAnOpinion: 'El racismo no es una opinión. El fascismo no es una alternativa.',
- everyDot: 'Cada una de estas luces es una mesa donde alguien fue bienvenido.',
- yourPlaces: 'Esto — esto fuiste tú.',
- yourStatsCountries: '{p} lugares. {c} países. Y ni una sola vez el mundo te hizo daño.',
- yourStatsTrips: '{p} lugares. {t} viajes. Y ni una sola vez el mundo te hizo daño.',
- },
- flashes: ['MIEDO.', 'ODIO.', 'MUROS.'],
- tooBeautiful: 'El mundo es demasiado hermoso para el miedo. Tú mismo lo has visto.',
- anthem: 'SIN MIEDO',
- creditTitle: 'TREK 4.0.0 — por un mundo abierto.',
- creditBody: 'Contra el racismo, el odio y el fascismo. Viajar convierte a extraños en vecinos.',
- inspiredBy: 'Inspirado en Danger Dan — “Keine Angst”',
- close: 'Pásalo',
- skip: 'Saltar',
- soundOn: 'Con sonido',
- soundOff: 'Sin sonido',
-}
-
-const fr: NoFearCopy = {
- beaconTitle: 'SANS PEUR',
- beaconSub: 'Un signe pour un monde ouvert.',
- beaconCta: 'Appuie sur play.',
- lines: {
- afraid: 'Ils veulent que tu aies peur.',
- ofTheStranger: 'Peur de l’étranger. Peur de tout ce que tu ne connais pas.',
- fearTool: 'Car la peur ferme les frontières — d’abord sur les cartes, puis dans les têtes.',
- hateTrade: 'La peur est leur outil. La haine, leur commerce.',
- butYouTraveled: 'Mais toi, tu as voyagé.',
- tables: 'Tu as mangé à des tables étrangères. Dormi sous des toits étrangers. Ri avec des inconnus.',
- face: 'Tu le sais : l’étranger a un visage. Et il ressemble au tien.',
- fences: 'Personne qui ait vu le monde ne veut l’enfermer à nouveau derrière des clôtures.',
- notAnOpinion: 'Le racisme n’est pas une opinion. Le fascisme n’est pas une alternative.',
- everyDot: 'Chacune de ces lumières est une table où quelqu’un a été bienvenu.',
- yourPlaces: 'Ça — c’était toi.',
- yourStatsCountries: '{p} lieux. {c} pays. Et pas une seule fois le monde ne t’a fait de mal.',
- yourStatsTrips: '{p} lieux. {t} voyages. Et pas une seule fois le monde ne t’a fait de mal.',
- },
- flashes: ['PEUR.', 'HAINE.', 'MURS.'],
- tooBeautiful: 'Le monde est trop beau pour la peur. Tu l’as vu de tes yeux.',
- anthem: 'SANS PEUR',
- creditTitle: 'TREK 4.0.0 — pour un monde ouvert.',
- creditBody: 'Contre le racisme, la haine et le fascisme. Voyager transforme les étrangers en voisins.',
- inspiredBy: 'Inspiré par Danger Dan — « Keine Angst »',
- close: 'Fais-le vivre',
- skip: 'Passer',
- soundOn: 'Son activé',
- soundOff: 'Son coupé',
-}
-
-const it: NoFearCopy = {
- beaconTitle: 'SENZA PAURA',
- beaconSub: 'Un segno per un mondo aperto.',
- beaconCta: 'Premi play.',
- lines: {
- afraid: 'Vogliono che tu abbia paura.',
- ofTheStranger: 'Paura dello straniero. Paura di tutto ciò che non conosci.',
- fearTool: 'Perché la paura chiude i confini — prima sulle mappe, poi nelle teste.',
- hateTrade: 'La paura è il loro strumento. L’odio, il loro commercio.',
- butYouTraveled: 'Ma tu hai viaggiato.',
- tables: 'Hai mangiato a tavole straniere. Dormito sotto tetti stranieri. Riso con sconosciuti.',
- face: 'Lo sai: lo straniero ha un volto. E assomiglia al tuo.',
- fences: 'Nessuno che abbia visto il mondo vuole richiuderlo dietro recinzioni.',
- notAnOpinion: 'Il razzismo non è un’opinione. Il fascismo non è un’alternativa.',
- everyDot: 'Ognuna di queste luci è una tavola dove qualcuno è stato benvenuto.',
- yourPlaces: 'Questo — questo eri tu.',
- yourStatsCountries: '{p} luoghi. {c} paesi. E il mondo non ti ha fatto male neanche una volta.',
- yourStatsTrips: '{p} luoghi. {t} viaggi. E il mondo non ti ha fatto male neanche una volta.',
- },
- flashes: ['PAURA.', 'ODIO.', 'MURI.'],
- tooBeautiful: 'Il mondo è troppo bello per la paura. L’hai visto con i tuoi occhi.',
- anthem: 'SENZA PAURA',
- creditTitle: 'TREK 4.0.0 — per un mondo aperto.',
- creditBody: 'Contro il razzismo, l’odio e il fascismo. Viaggiare trasforma gli estranei in vicini.',
- inspiredBy: 'Ispirato a Danger Dan — “Keine Angst”',
- close: 'Portalo avanti',
- skip: 'Salta',
- soundOn: 'Audio attivo',
- soundOff: 'Audio disattivato',
-}
-
-const nl: NoFearCopy = {
- beaconTitle: 'GEEN ANGST',
- beaconSub: 'Een teken voor een open wereld.',
- beaconCta: 'Druk op play.',
- lines: {
- afraid: 'Ze willen dat je bang bent.',
- ofTheStranger: 'Bang voor de vreemdeling. Bang voor alles wat je niet kent.',
- fearTool: 'Want angst sluit grenzen — eerst op kaarten, dan in hoofden.',
- hateTrade: 'Angst is hun gereedschap. Haat is hun handel.',
- butYouTraveled: 'Maar jij hebt gereisd.',
- tables: 'Je hebt aan vreemde tafels gegeten. Onder vreemde daken geslapen. Met vreemden gelachen.',
- face: 'Je weet het: het vreemde heeft een gezicht. En het lijkt op het jouwe.',
- fences: 'Niemand die de wereld heeft gezien, wil hem weer achter hekken opsluiten.',
- notAnOpinion: 'Racisme is geen mening. Fascisme is geen alternatief.',
- everyDot: 'Elk van deze lichtjes is een tafel waar iemand welkom was.',
- yourPlaces: 'Dit — dit was jij.',
- yourStatsCountries: '{p} plekken. {c} landen. En niet één keer heeft de wereld je pijn gedaan.',
- yourStatsTrips: '{p} plekken. {t} reizen. En niet één keer heeft de wereld je pijn gedaan.',
- },
- flashes: ['ANGST.', 'HAAT.', 'MUREN.'],
- tooBeautiful: 'De wereld is te mooi voor angst. Je hebt het zelf gezien.',
- anthem: 'GEEN ANGST',
- creditTitle: 'TREK 4.0.0 — voor een open wereld.',
- creditBody: 'Tegen racisme, haat en fascisme. Reizen maakt van vreemden buren.',
- inspiredBy: 'Geïnspireerd door Danger Dan — “Keine Angst”',
- close: 'Geef het door',
- skip: 'Overslaan',
- soundOn: 'Geluid aan',
- soundOff: 'Geluid uit',
-}
-
-const pl: NoFearCopy = {
- beaconTitle: 'BEZ STRACHU',
- beaconSub: 'Znak dla otwartego świata.',
- beaconCta: 'Naciśnij play.',
- lines: {
- afraid: 'Chcą, żebyś się bał.',
- ofTheStranger: 'Bał obcego. Bał wszystkiego, czego nie znasz.',
- fearTool: 'Bo strach zamyka granice — najpierw na mapach, potem w głowach.',
- hateTrade: 'Strach to ich narzędzie. Nienawiść to ich interes.',
- butYouTraveled: 'Ale ty podróżowałeś.',
- tables: 'Jadłeś przy obcych stołach. Spałeś pod obcymi dachami. Śmiałeś się z nieznajomymi.',
- face: 'Wiesz: obcy ma twarz. I wygląda jak twoja.',
- fences: 'Nikt, kto widział świat, nie chce go znów zamykać za płotami.',
- notAnOpinion: 'Rasizm to nie opinia. Faszyzm to nie alternatywa.',
- everyDot: 'Każde z tych świateł to stół, przy którym ktoś był mile widziany.',
- yourPlaces: 'To — to byłeś ty.',
- yourStatsCountries: '{p} miejsc. {c} krajów. I ani razu świat nie zrobił ci krzywdy.',
- yourStatsTrips: '{p} miejsc. {t} podróży. I ani razu świat nie zrobił ci krzywdy.',
- },
- flashes: ['STRACH.', 'NIENAWIŚĆ.', 'MURY.'],
- tooBeautiful: 'Świat jest zbyt piękny na strach. Widziałeś to na własne oczy.',
- anthem: 'BEZ STRACHU',
- creditTitle: 'TREK 4.0.0 — dla otwartego świata.',
- creditBody: 'Przeciw rasizmowi, nienawiści i faszyzmowi. Podróże zmieniają obcych w sąsiadów.',
- inspiredBy: 'Inspirowane utworem Danger Dan — „Keine Angst”',
- close: 'Nieś to dalej',
- skip: 'Pomiń',
- soundOn: 'Dźwięk wł.',
- soundOff: 'Dźwięk wył.',
-}
-
-const ru: NoFearCopy = {
- beaconTitle: 'БЕЗ СТРАХА',
- beaconSub: 'Знак открытого мира.',
- beaconCta: 'Нажми play.',
- lines: {
- afraid: 'Они хотят, чтобы ты боялся.',
- ofTheStranger: 'Боялся чужого. Боялся всего, чего не знаешь.',
- fearTool: 'Потому что страх закрывает границы — сначала на картах, потом в головах.',
- hateTrade: 'Страх — их инструмент. Ненависть — их ремесло.',
- butYouTraveled: 'Но ты путешествовал.',
- tables: 'Ты ел за чужими столами. Спал под чужими крышами. Смеялся с незнакомцами.',
- face: 'Ты знаешь: у чужого есть лицо. И оно похоже на твоё.',
- fences: 'Никто, кто видел мир, не хочет снова запирать его за заборами.',
- notAnOpinion: 'Расизм — не мнение. Фашизм — не альтернатива.',
- everyDot: 'Каждый из этих огней — стол, за которым кому-то были рады.',
- yourPlaces: 'Это — это был ты.',
- yourStatsCountries: '{p} мест. {c} стран. И ни разу мир не причинил тебе зла.',
- yourStatsTrips: '{p} мест. {t} путешествий. И ни разу мир не причинил тебе зла.',
- },
- flashes: ['СТРАХ.', 'НЕНАВИСТЬ.', 'СТЕНЫ.'],
- tooBeautiful: 'Мир слишком красив для страха. Ты видел это своими глазами.',
- anthem: 'БЕЗ СТРАХА',
- creditTitle: 'TREK 4.0.0 — за открытый мир.',
- creditBody: 'Против расизма, ненависти и фашизма. Путешествия превращают чужих в соседей.',
- inspiredBy: 'Вдохновлено Danger Dan — «Keine Angst»',
- close: 'Передай дальше',
- skip: 'Пропустить',
- soundOn: 'Звук вкл.',
- soundOff: 'Звук выкл.',
-}
-
-const uk: NoFearCopy = {
- beaconTitle: 'БЕЗ СТРАХУ',
- beaconSub: 'Знак відкритого світу.',
- beaconCta: 'Натисни play.',
- lines: {
- afraid: 'Вони хочуть, щоб ти боявся.',
- ofTheStranger: 'Боявся чужого. Боявся всього, чого не знаєш.',
- fearTool: 'Бо страх закриває кордони — спершу на мапах, потім у головах.',
- hateTrade: 'Страх — їхній інструмент. Ненависть — їхнє ремесло.',
- butYouTraveled: 'Але ти подорожував.',
- tables: 'Ти їв за чужими столами. Спав під чужими дахами. Сміявся з незнайомцями.',
- face: 'Ти знаєш: чуже має обличчя. І воно схоже на твоє.',
- fences: 'Ніхто, хто бачив світ, не хоче знову замикати його за парканами.',
- notAnOpinion: 'Расизм — не думка. Фашизм — не альтернатива.',
- everyDot: 'Кожен із цих вогників — стіл, за яким комусь були раді.',
- yourPlaces: 'Це — це був ти.',
- yourStatsCountries: '{p} місць. {c} країн. І жодного разу світ не заподіяв тобі зла.',
- yourStatsTrips: '{p} місць. {t} подорожей. І жодного разу світ не заподіяв тобі зла.',
- },
- flashes: ['СТРАХ.', 'НЕНАВИСТЬ.', 'МУРИ.'],
- tooBeautiful: 'Світ надто гарний для страху. Ти бачив це на власні очі.',
- anthem: 'БЕЗ СТРАХУ',
- creditTitle: 'TREK 4.0.0 — за відкритий світ.',
- creditBody: 'Проти расизму, ненависті й фашизму. Подорожі перетворюють чужих на сусідів.',
- inspiredBy: 'Натхнено Danger Dan — «Keine Angst»',
- close: 'Передай далі',
- skip: 'Пропустити',
- soundOn: 'Звук увімк.',
- soundOff: 'Звук вимк.',
-}
-
-const cs: NoFearCopy = {
- beaconTitle: 'BEZE STRACHU',
- beaconSub: 'Znamení pro otevřený svět.',
- beaconCta: 'Stiskni play.',
- lines: {
- afraid: 'Chtějí, aby ses bál.',
- ofTheStranger: 'Bál cizího. Bál všeho, co neznáš.',
- fearTool: 'Protože strach zavírá hranice — nejdřív na mapách, pak v hlavách.',
- hateTrade: 'Strach je jejich nástroj. Nenávist jejich obchod.',
- butYouTraveled: 'Ale ty jsi cestoval.',
- tables: 'Jedl jsi u cizích stolů. Spal pod cizími střechami. Smál se s cizinci.',
- face: 'Víš: cizí má tvář. A vypadá jako ta tvoje.',
- fences: 'Nikdo, kdo viděl svět, ho nechce znovu zavírat za ploty.',
- notAnOpinion: 'Rasismus není názor. Fašismus není alternativa.',
- everyDot: 'Každé z těchto světel je stůl, u kterého byl někdo vítán.',
- yourPlaces: 'Tohle — tohle jsi byl ty.',
- yourStatsCountries: '{p} míst. {c} zemí. A svět ti ani jednou neublížil.',
- yourStatsTrips: '{p} míst. {t} cest. A svět ti ani jednou neublížil.',
- },
- flashes: ['STRACH.', 'NENÁVIST.', 'ZDI.'],
- tooBeautiful: 'Svět je na strach příliš krásný. Viděl jsi to na vlastní oči.',
- anthem: 'BEZE STRACHU',
- creditTitle: 'TREK 4.0.0 — pro otevřený svět.',
- creditBody: 'Proti rasismu, nenávisti a fašismu. Cestování dělá z cizinců sousedy.',
- inspiredBy: 'Inspirováno Danger Dan — „Keine Angst“',
- close: 'Nes to dál',
- skip: 'Přeskočit',
- soundOn: 'Zvuk zap.',
- soundOff: 'Zvuk vyp.',
-}
-
-const sv: NoFearCopy = {
- beaconTitle: 'INGEN RÄDSLA',
- beaconSub: 'Ett tecken för en öppen värld.',
- beaconCta: 'Tryck på play.',
- lines: {
- afraid: 'De vill att du ska vara rädd.',
- ofTheStranger: 'Rädd för främlingen. Rädd för allt du inte känner till.',
- fearTool: 'För rädsla stänger gränser — först på kartor, sedan i huvuden.',
- hateTrade: 'Rädsla är deras verktyg. Hat är deras handelsvara.',
- butYouTraveled: 'Men du har rest.',
- tables: 'Du har ätit vid främmande bord. Sovit under främmande tak. Skrattat med främlingar.',
- face: 'Du vet: det främmande har ett ansikte. Och det liknar ditt.',
- fences: 'Ingen som har sett världen vill låsa in den bakom stängsel igen.',
- notAnOpinion: 'Rasism är ingen åsikt. Fascism är inget alternativ.',
- everyDot: 'Varje ljus här är ett bord där någon var välkommen.',
- yourPlaces: 'Det här — det var du.',
- yourStatsCountries: '{p} platser. {c} länder. Och inte en enda gång gjorde världen dig illa.',
- yourStatsTrips: '{p} platser. {t} resor. Och inte en enda gång gjorde världen dig illa.',
- },
- flashes: ['RÄDSLA.', 'HAT.', 'MURAR.'],
- tooBeautiful: 'Världen är för vacker för rädsla. Du har sett det själv.',
- anthem: 'INGEN RÄDSLA',
- creditTitle: 'TREK 4.0.0 — för en öppen värld.',
- creditBody: 'Mot rasism, hat och fascism. Att resa gör främlingar till grannar.',
- inspiredBy: 'Inspirerat av Danger Dan — ”Keine Angst”',
- close: 'För det vidare',
- skip: 'Hoppa över',
- soundOn: 'Ljud på',
- soundOff: 'Ljud av',
-}
-
-const tr: NoFearCopy = {
- beaconTitle: 'KORKMA',
- beaconSub: 'Açık bir dünya için bir işaret.',
- beaconCta: 'Play’e bas.',
- lines: {
- afraid: 'Korkmanı istiyorlar.',
- ofTheStranger: 'Yabancıdan korkmanı. Bilmediğin her şeyden korkmanı.',
- fearTool: 'Çünkü korku sınırları kapatır — önce haritalarda, sonra zihinlerde.',
- hateTrade: 'Korku onların aracı. Nefret onların ticareti.',
- butYouTraveled: 'Ama sen seyahat ettin.',
- tables: 'Yabancı sofralarda yemek yedin. Yabancı çatılar altında uyudun. Yabancılarla güldün.',
- face: 'Biliyorsun: yabancının bir yüzü var. Ve seninkine benziyor.',
- fences: 'Dünyayı görmüş hiç kimse onu yeniden çitlerin arkasına kapatmak istemez.',
- notAnOpinion: 'Irkçılık bir fikir değil. Faşizm bir alternatif değil.',
- everyDot: 'Bu ışıkların her biri, birinin hoş karşılandığı bir sofra.',
- yourPlaces: 'Bu — buydun sen.',
- yourStatsCountries: '{p} yer. {c} ülke. Ve dünya sana bir kez bile zarar vermedi.',
- yourStatsTrips: '{p} yer. {t} seyahat. Ve dünya sana bir kez bile zarar vermedi.',
- },
- flashes: ['KORKU.', 'NEFRET.', 'DUVARLAR.'],
- tooBeautiful: 'Dünya korku için fazla güzel. Kendi gözlerinle gördün.',
- anthem: 'KORKMA',
- creditTitle: 'TREK 4.0.0 — açık bir dünya için.',
- creditBody: 'Irkçılığa, nefrete ve faşizme karşı. Seyahat, yabancıları komşulara dönüştürür.',
- inspiredBy: 'Danger Dan’den ilhamla — “Keine Angst”',
- close: 'İleri taşı',
- skip: 'Atla',
- soundOn: 'Ses açık',
- soundOff: 'Ses kapalı',
-}
-
-const gr: NoFearCopy = {
- beaconTitle: 'ΧΩΡΙΣ ΦΟΒΟ',
- beaconSub: 'Ένα σημάδι για έναν ανοιχτό κόσμο.',
- beaconCta: 'Πάτα play.',
- lines: {
- afraid: 'Θέλουν να φοβάσαι.',
- ofTheStranger: 'Να φοβάσαι τον ξένο. Να φοβάσαι ό,τι δεν γνωρίζεις.',
- fearTool: 'Γιατί ο φόβος κλείνει σύνορα — πρώτα στους χάρτες, μετά στα μυαλά.',
- hateTrade: 'Ο φόβος είναι το εργαλείο τους. Το μίσος, το εμπόριό τους.',
- butYouTraveled: 'Όμως εσύ ταξίδεψες.',
- tables: 'Έφαγες σε ξένα τραπέζια. Κοιμήθηκες κάτω από ξένες στέγες. Γέλασες με αγνώστους.',
- face: 'Το ξέρεις: το ξένο έχει πρόσωπο. Και μοιάζει με το δικό σου.',
- fences: 'Κανείς που είδε τον κόσμο δεν θέλει να τον ξανακλείσει πίσω από φράχτες.',
- notAnOpinion: 'Ο ρατσισμός δεν είναι άποψη. Ο φασισμός δεν είναι εναλλακτική.',
- everyDot: 'Καθένα από αυτά τα φώτα είναι ένα τραπέζι όπου κάποιος ήταν ευπρόσδεκτος.',
- yourPlaces: 'Αυτό — αυτό ήσουν εσύ.',
- yourStatsCountries: '{p} μέρη. {c} χώρες. Και ούτε μία φορά ο κόσμος δεν σε πλήγωσε.',
- yourStatsTrips: '{p} μέρη. {t} ταξίδια. Και ούτε μία φορά ο κόσμος δεν σε πλήγωσε.',
- },
- flashes: ['ΦΟΒΟΣ.', 'ΜΙΣΟΣ.', 'ΤΕΙΧΗ.'],
- tooBeautiful: 'Ο κόσμος είναι πολύ όμορφος για φόβο. Το είδες με τα μάτια σου.',
- anthem: 'ΧΩΡΙΣ ΦΟΒΟ',
- creditTitle: 'TREK 4.0.0 — για έναν ανοιχτό κόσμο.',
- creditBody: 'Ενάντια στον ρατσισμό, το μίσος και τον φασισμό. Το ταξίδι κάνει τους ξένους γείτονες.',
- inspiredBy: 'Εμπνευσμένο από τον Danger Dan — «Keine Angst»',
- close: 'Δώσ’ το παρακάτω',
- skip: 'Παράλειψη',
- soundOn: 'Με ήχο',
- soundOff: 'Χωρίς ήχο',
-}
-
-const hu: NoFearCopy = {
- beaconTitle: 'NE FÉLJ',
- beaconSub: 'Jel egy nyitott világért.',
- beaconCta: 'Nyomd meg a play-t.',
- lines: {
- afraid: 'Azt akarják, hogy félj.',
- ofTheStranger: 'Félj az idegentől. Félj mindentől, amit nem ismersz.',
- fearTool: 'Mert a félelem határokat zár le — előbb a térképeken, aztán a fejekben.',
- hateTrade: 'A félelem az eszközük. A gyűlölet az üzletük.',
- butYouTraveled: 'De te utaztál.',
- tables: 'Idegen asztaloknál ettél. Idegen tetők alatt aludtál. Idegenekkel nevettél.',
- face: 'Tudod: az idegennek arca van. És a tiédre hasonlít.',
- fences: 'Senki, aki látta a világot, nem akarja újra kerítések mögé zárni.',
- notAnOpinion: 'A rasszizmus nem vélemény. A fasizmus nem alternatíva.',
- everyDot: 'Ezek a fények mind egy-egy asztal, ahol valakit szívesen láttak.',
- yourPlaces: 'Ez — ez te voltál.',
- yourStatsCountries: '{p} hely. {c} ország. És a világ egyetlenegyszer sem bántott.',
- yourStatsTrips: '{p} hely. {t} utazás. És a világ egyetlenegyszer sem bántott.',
- },
- flashes: ['FÉLELEM.', 'GYŰLÖLET.', 'FALAK.'],
- tooBeautiful: 'A világ túl szép a félelemhez. A saját szemeddel láttad.',
- anthem: 'NE FÉLJ',
- creditTitle: 'TREK 4.0.0 — egy nyitott világért.',
- creditBody: 'A rasszizmus, a gyűlölet és a fasizmus ellen. Az utazás szomszédokká teszi az idegeneket.',
- inspiredBy: 'Danger Dan ihlette — „Keine Angst”',
- close: 'Add tovább',
- skip: 'Kihagyás',
- soundOn: 'Hang be',
- soundOff: 'Hang ki',
-}
-
-const br: NoFearCopy = {
- beaconTitle: 'SEM MEDO',
- beaconSub: 'Um sinal por um mundo aberto.',
- beaconCta: 'Aperte o play.',
- lines: {
- afraid: 'Eles querem que você tenha medo.',
- ofTheStranger: 'Medo do estrangeiro. Medo de tudo o que você não conhece.',
- fearTool: 'Porque o medo fecha fronteiras — primeiro nos mapas, depois nas mentes.',
- hateTrade: 'O medo é a ferramenta deles. O ódio, o negócio deles.',
- butYouTraveled: 'Mas você viajou.',
- tables: 'Você comeu em mesas estrangeiras. Dormiu sob tetos estrangeiros. Riu com desconhecidos.',
- face: 'Você sabe: o estrangeiro tem um rosto. E ele se parece com o seu.',
- fences: 'Ninguém que viu o mundo quer trancá-lo atrás de cercas de novo.',
- notAnOpinion: 'Racismo não é opinião. Fascismo não é alternativa.',
- everyDot: 'Cada uma destas luzes é uma mesa onde alguém foi bem-vindo.',
- yourPlaces: 'Isto — isto foi você.',
- yourStatsCountries: '{p} lugares. {c} países. E nem uma única vez o mundo te machucou.',
- yourStatsTrips: '{p} lugares. {t} viagens. E nem uma única vez o mundo te machucou.',
- },
- flashes: ['MEDO.', 'ÓDIO.', 'MUROS.'],
- tooBeautiful: 'O mundo é bonito demais para o medo. Você viu com os próprios olhos.',
- anthem: 'SEM MEDO',
- creditTitle: 'TREK 4.0.0 — por um mundo aberto.',
- creditBody: 'Contra o racismo, o ódio e o fascismo. Viajar transforma estranhos em vizinhos.',
- inspiredBy: 'Inspirado em Danger Dan — “Keine Angst”',
- close: 'Leve adiante',
- skip: 'Pular',
- soundOn: 'Som ligado',
- soundOff: 'Som desligado',
-}
-
-const ca: NoFearCopy = {
- beaconTitle: 'SENSE POR',
- beaconSub: 'Un senyal per un món obert.',
- beaconCta: 'Prem play.',
- lines: {
- afraid: 'Volen que tinguis por.',
- ofTheStranger: 'Por de l’estranger. Por de tot allò que no coneixes.',
- fearTool: 'Perquè la por tanca fronteres — primer als mapes, després a les ments.',
- hateTrade: 'La por és la seva eina. L’odi, el seu negoci.',
- butYouTraveled: 'Però tu has viatjat.',
- tables: 'Has menjat a taules estrangeres. Dormit sota sostres estrangers. Rigut amb desconeguts.',
- face: 'Ho saps: l’estranger té un rostre. I s’assembla al teu.',
- fences: 'Ningú que hagi vist el món vol tornar-lo a tancar rere tanques.',
- notAnOpinion: 'El racisme no és una opinió. El feixisme no és una alternativa.',
- everyDot: 'Cadascuna d’aquestes llums és una taula on algú va ser benvingut.',
- yourPlaces: 'Això — això eres tu.',
- yourStatsCountries: '{p} llocs. {c} països. I ni una sola vegada el món et va fer mal.',
- yourStatsTrips: '{p} llocs. {t} viatges. I ni una sola vegada el món et va fer mal.',
- },
- flashes: ['POR.', 'ODI.', 'MURS.'],
- tooBeautiful: 'El món és massa bonic per a la por. Ho has vist amb els teus ulls.',
- anthem: 'SENSE POR',
- creditTitle: 'TREK 4.0.0 — per un món obert.',
- creditBody: 'Contra el racisme, l’odi i el feixisme. Viatjar converteix els estranys en veïns.',
- inspiredBy: 'Inspirat en Danger Dan — «Keine Angst»',
- close: 'Porta-ho endavant',
- skip: 'Omet',
- soundOn: 'So activat',
- soundOff: 'So desactivat',
-}
-
-const id: NoFearCopy = {
- beaconTitle: 'JANGAN TAKUT',
- beaconSub: 'Tanda untuk dunia yang terbuka.',
- beaconCta: 'Tekan play.',
- lines: {
- afraid: 'Mereka ingin kamu takut.',
- ofTheStranger: 'Takut pada orang asing. Takut pada semua yang tidak kamu kenal.',
- fearTool: 'Karena rasa takut menutup perbatasan — mula-mula di peta, lalu di kepala.',
- hateTrade: 'Rasa takut adalah alat mereka. Kebencian adalah dagangan mereka.',
- butYouTraveled: 'Tapi kamu sudah bepergian.',
- tables: 'Kamu pernah makan di meja orang asing. Tidur di bawah atap asing. Tertawa bersama orang tak dikenal.',
- face: 'Kamu tahu: orang asing punya wajah. Dan wajah itu mirip wajahmu.',
- fences: 'Tak seorang pun yang pernah melihat dunia ingin menguncinya lagi di balik pagar.',
- notAnOpinion: 'Rasisme bukan pendapat. Fasisme bukan alternatif.',
- everyDot: 'Setiap cahaya ini adalah meja tempat seseorang disambut.',
- yourPlaces: 'Ini — ini adalah kamu.',
- yourStatsCountries: '{p} tempat. {c} negara. Dan dunia tak pernah sekali pun menyakitimu.',
- yourStatsTrips: '{p} tempat. {t} perjalanan. Dan dunia tak pernah sekali pun menyakitimu.',
- },
- flashes: ['TAKUT.', 'BENCI.', 'TEMBOK.'],
- tooBeautiful: 'Dunia terlalu indah untuk rasa takut. Kamu sudah melihatnya sendiri.',
- anthem: 'JANGAN TAKUT',
- creditTitle: 'TREK 4.0.0 — untuk dunia yang terbuka.',
- creditBody: 'Melawan rasisme, kebencian, dan fasisme. Bepergian mengubah orang asing menjadi tetangga.',
- inspiredBy: 'Terinspirasi oleh Danger Dan — “Keine Angst”',
- close: 'Teruskan',
- skip: 'Lewati',
- soundOn: 'Suara aktif',
- soundOff: 'Suara mati',
-}
-
-const vi: NoFearCopy = {
- beaconTitle: 'ĐỪNG SỢ',
- beaconSub: 'Một dấu hiệu cho thế giới rộng mở.',
- beaconCta: 'Nhấn play.',
- lines: {
- afraid: 'Họ muốn bạn sợ hãi.',
- ofTheStranger: 'Sợ người lạ. Sợ tất cả những gì bạn không biết.',
- fearTool: 'Vì nỗi sợ đóng lại biên giới — trước tiên trên bản đồ, rồi trong tâm trí.',
- hateTrade: 'Nỗi sợ là công cụ của họ. Hận thù là món hàng của họ.',
- butYouTraveled: 'Nhưng bạn đã đi xa.',
- tables: 'Bạn đã ăn ở những bàn ăn xa lạ. Ngủ dưới những mái nhà xa lạ. Cười với những người chưa quen.',
- face: 'Bạn biết: người lạ có một gương mặt. Và nó giống gương mặt bạn.',
- fences: 'Không ai từng thấy thế giới lại muốn nhốt nó sau hàng rào lần nữa.',
- notAnOpinion: 'Phân biệt chủng tộc không phải là quan điểm. Chủ nghĩa phát xít không phải là lựa chọn thay thế.',
- everyDot: 'Mỗi ánh đèn này là một bàn ăn nơi ai đó từng được chào đón.',
- yourPlaces: 'Đây — đây chính là bạn.',
- yourStatsCountries: '{p} địa điểm. {c} quốc gia. Và chưa một lần nào thế giới làm bạn tổn thương.',
- yourStatsTrips: '{p} địa điểm. {t} chuyến đi. Và chưa một lần nào thế giới làm bạn tổn thương.',
- },
- flashes: ['SỢ HÃI.', 'HẬN THÙ.', 'BỨC TƯỜNG.'],
- tooBeautiful: 'Thế giới quá đẹp để phải sợ hãi. Chính bạn đã thấy điều đó.',
- anthem: 'ĐỪNG SỢ',
- creditTitle: 'TREK 4.0.0 — vì một thế giới rộng mở.',
- creditBody: 'Chống phân biệt chủng tộc, hận thù và chủ nghĩa phát xít. Du lịch biến người lạ thành láng giềng.',
- inspiredBy: 'Lấy cảm hứng từ Danger Dan — “Keine Angst”',
- close: 'Lan tỏa tiếp',
- skip: 'Bỏ qua',
- soundOn: 'Bật âm thanh',
- soundOff: 'Tắt âm thanh',
-}
-
-const ja: NoFearCopy = {
- beaconTitle: '恐れないで',
- beaconSub: '開かれた世界へのしるし。',
- beaconCta: '再生を押して。',
- lines: {
- afraid: '彼らはあなたに怯えてほしいのです。',
- ofTheStranger: '見知らぬ人を恐れ、知らないものすべてを恐れるように。',
- fearTool: '恐怖は国境を閉ざします — まず地図の上で、やがて心の中で。',
- hateTrade: '恐怖は彼らの道具。憎しみは彼らの商売。',
- butYouTraveled: 'でも、あなたは旅をしてきた。',
- tables: '見知らぬ食卓で食事をし、見知らぬ屋根の下で眠り、見知らぬ人と笑い合った。',
- face: 'あなたは知っている。「よそ者」には顔があり、それはあなたの顔に似ていることを。',
- fences: '世界を見た人は誰も、それを再び柵の中に閉じ込めたいとは思わない。',
- notAnOpinion: 'レイシズムは意見ではない。ファシズムは選択肢ではない。',
- everyDot: 'この光のひとつひとつが、誰かが歓迎された食卓です。',
- yourPlaces: 'これは — あなたでした。',
- yourStatsCountries: '{p}の場所。{c}の国。世界があなたを傷つけたことは、一度もなかった。',
- yourStatsTrips: '{p}の場所。{t}の旅。世界があなたを傷つけたことは、一度もなかった。',
- },
- flashes: ['恐怖。', '憎悪。', '壁。'],
- tooBeautiful: '世界は恐れるにはあまりに美しい。あなた自身が見てきたのだから。',
- anthem: '恐れないで',
- creditTitle: 'TREK 4.0.0 — 開かれた世界のために。',
- creditBody: 'レイシズム、憎しみ、ファシズムに抗して。旅は見知らぬ人を隣人に変える。',
- inspiredBy: 'Danger Dan「Keine Angst」に着想を得て',
- close: '受け継いでいく',
- skip: 'スキップ',
- soundOn: '音を出す',
- soundOff: '音を消す',
-}
-
-const ko: NoFearCopy = {
- beaconTitle: '두려워하지 마',
- beaconSub: '열린 세상을 위한 신호.',
- beaconCta: '재생을 눌러요.',
- lines: {
- afraid: '그들은 당신이 두려워하길 바랍니다.',
- ofTheStranger: '낯선 사람을 두려워하고, 알지 못하는 모든 것을 두려워하기를.',
- fearTool: '두려움은 국경을 닫습니다 — 처음엔 지도에서, 그다음엔 마음속에서.',
- hateTrade: '두려움은 그들의 도구이고, 증오는 그들의 장사입니다.',
- butYouTraveled: '하지만 당신은 여행을 했습니다.',
- tables: '낯선 식탁에서 밥을 먹고, 낯선 지붕 아래 잠들고, 낯선 사람들과 웃었습니다.',
- face: '당신은 압니다. 낯선 이에게도 얼굴이 있고, 그 얼굴이 당신을 닮았다는 것을.',
- fences: '세상을 본 사람이라면 누구도 그것을 다시 울타리 뒤에 가두고 싶어 하지 않습니다.',
- notAnOpinion: '인종차별은 의견이 아닙니다. 파시즘은 대안이 아닙니다.',
- everyDot: '이 불빛 하나하나가 누군가 환영받았던 식탁입니다.',
- yourPlaces: '이것이 — 바로 당신이었습니다.',
- yourStatsCountries: '{p}곳의 장소. {c}개의 나라. 그리고 세상은 단 한 번도 당신을 해치지 않았습니다.',
- yourStatsTrips: '{p}곳의 장소. {t}번의 여행. 그리고 세상은 단 한 번도 당신을 해치지 않았습니다.',
- },
- flashes: ['두려움.', '증오.', '장벽.'],
- tooBeautiful: '세상은 두려워하기엔 너무 아름답습니다. 당신이 직접 보았습니다.',
- anthem: '두려워하지 마',
- creditTitle: 'TREK 4.0.0 — 열린 세상을 위하여.',
- creditBody: '인종차별, 증오, 파시즘에 반대하며. 여행은 낯선 사람을 이웃으로 만듭니다.',
- inspiredBy: 'Danger Dan의 「Keine Angst」에서 영감을 받아',
- close: '이어가기',
- skip: '건너뛰기',
- soundOn: '소리 켜기',
- soundOff: '소리 끄기',
-}
-
-const zh: NoFearCopy = {
- beaconTitle: '别害怕',
- beaconSub: '为开放世界而立的标记。',
- beaconCta: '按下播放。',
- lines: {
- afraid: '他们想让你害怕。',
- ofTheStranger: '害怕陌生人,害怕一切你不了解的东西。',
- fearTool: '因为恐惧会关闭边界——先是在地图上,然后是在头脑里。',
- hateTrade: '恐惧是他们的工具,仇恨是他们的生意。',
- butYouTraveled: '但你旅行过。',
- tables: '你曾在陌生的餐桌旁吃饭,在陌生的屋檐下入睡,与陌生人一起欢笑。',
- face: '你知道:陌生人也有一张脸,而那张脸和你的很像。',
- fences: '见过世界的人,没有谁愿意再把它锁回栅栏之后。',
- notAnOpinion: '种族主义不是一种观点。法西斯主义不是一种选择。',
- everyDot: '这里的每一盏灯,都是一张有人被欢迎过的餐桌。',
- yourPlaces: '这——就是你。',
- yourStatsCountries: '{p} 个地方。{c} 个国家。而世界从未伤害过你一次。',
- yourStatsTrips: '{p} 个地方。{t} 次旅行。而世界从未伤害过你一次。',
- },
- flashes: ['恐惧。', '仇恨。', '高墙。'],
- tooBeautiful: '这个世界美得容不下恐惧。你亲眼见过。',
- anthem: '别害怕',
- creditTitle: 'TREK 4.0.0 — 为了一个开放的世界。',
- creditBody: '反对种族主义、仇恨与法西斯主义。旅行让陌生人成为邻居。',
- inspiredBy: '灵感来自 Danger Dan——《Keine Angst》',
- close: '传递下去',
- skip: '跳过',
- soundOn: '开启声音',
- soundOff: '关闭声音',
-}
-
-const zhTW: NoFearCopy = {
- beaconTitle: '別害怕',
- beaconSub: '為開放世界而立的標記。',
- beaconCta: '按下播放。',
- lines: {
- afraid: '他們想讓你害怕。',
- ofTheStranger: '害怕陌生人,害怕一切你不了解的事物。',
- fearTool: '因為恐懼會關閉邊界——先是在地圖上,然後是在腦海裡。',
- hateTrade: '恐懼是他們的工具,仇恨是他們的生意。',
- butYouTraveled: '但你旅行過。',
- tables: '你曾在陌生的餐桌旁吃飯,在陌生的屋簷下入睡,與陌生人一起歡笑。',
- face: '你知道:陌生人也有一張臉,而那張臉和你的很像。',
- fences: '見過世界的人,沒有誰願意再把它鎖回柵欄之後。',
- notAnOpinion: '種族主義不是一種觀點。法西斯主義不是一種選項。',
- everyDot: '這裡的每一盞燈,都是一張有人被歡迎過的餐桌。',
- yourPlaces: '這——就是你。',
- yourStatsCountries: '{p} 個地方。{c} 個國家。而世界從未傷害過你一次。',
- yourStatsTrips: '{p} 個地方。{t} 次旅行。而世界從未傷害過你一次。',
- },
- flashes: ['恐懼。', '仇恨。', '高牆。'],
- tooBeautiful: '這個世界美得容不下恐懼。你親眼見過。',
- anthem: '別害怕',
- creditTitle: 'TREK 4.0.0 — 為了一個開放的世界。',
- creditBody: '反對種族主義、仇恨與法西斯主義。旅行讓陌生人成為鄰居。',
- inspiredBy: '靈感來自 Danger Dan——《Keine Angst》',
- close: '傳遞下去',
- skip: '跳過',
- soundOn: '開啟聲音',
- soundOff: '關閉聲音',
-}
-
-const ar: NoFearCopy = {
- beaconTitle: 'لا تخف',
- beaconSub: 'علامة من أجل عالم مفتوح.',
- beaconCta: 'اضغط تشغيل.',
- lines: {
- afraid: 'يريدونك أن تخاف.',
- ofTheStranger: 'أن تخاف من الغريب. أن تخاف من كل ما لا تعرفه.',
- fearTool: 'لأن الخوف يغلق الحدود — أولًا على الخرائط، ثم في العقول.',
- hateTrade: 'الخوف أداتهم. والكراهية تجارتهم.',
- butYouTraveled: 'لكنك سافرت.',
- tables: 'أكلت على موائد غريبة. نمت تحت سقوف غريبة. ضحكت مع غرباء.',
- face: 'أنت تعرف: للغريب وجه. وهو يشبه وجهك.',
- fences: 'لا أحد رأى العالم يريد أن يحبسه خلف الأسوار من جديد.',
- notAnOpinion: 'العنصرية ليست رأيًا. الفاشية ليست بديلًا.',
- everyDot: 'كل ضوء من هذه الأضواء مائدة رُحّب فيها بأحدهم.',
- yourPlaces: 'هذا — كان أنت.',
- yourStatsCountries: '{p} أماكن. {c} دولة. ولم يؤذِك العالم ولا مرة واحدة.',
- yourStatsTrips: '{p} أماكن. {t} رحلة. ولم يؤذِك العالم ولا مرة واحدة.',
- },
- flashes: ['الخوف.', 'الكراهية.', 'الجدران.'],
- tooBeautiful: 'العالم أجمل من أن نخاف. لقد رأيته بعينيك.',
- anthem: 'لا تخف',
- creditTitle: 'TREK 4.0.0 — من أجل عالم مفتوح.',
- creditBody: 'ضد العنصرية والكراهية والفاشية. السفر يحوّل الغرباء إلى جيران.',
- inspiredBy: 'مستوحى من Danger Dan — «Keine Angst»',
- close: 'احمله معك',
- skip: 'تخطَّ',
- soundOn: 'تشغيل الصوت',
- soundOff: 'كتم الصوت',
-}
-
-const COPY: Record<string, NoFearCopy> = {
- en, de, es, fr, it, nl, pl, ru, uk, cs, sv, tr, gr, hu, br, ca, id, vi, ja, ko, zh, ar,
- 'zh-TW': zhTW,
-}
-
-export function noFearCopy(language: string): NoFearCopy {
- return COPY[language] ?? en
-}
-
-/**
- * "No fear" in every language TREK speaks — the anthem cascade. The German song
- * sparked this, but the message belongs to everyone, so it closes in all 23.
- */
-export const ANTHEM_CASCADE: { lang: string; text: string }[] = [
- { lang: 'de', text: 'Keine Angst' },
- { lang: 'en', text: 'No fear' },
- { lang: 'uk', text: 'Без страху' },
- { lang: 'fr', text: 'Sans peur' },
- { lang: 'es', text: 'Sin miedo' },
- { lang: 'ar', text: 'لا تخف' },
- { lang: 'it', text: 'Senza paura' },
- { lang: 'pl', text: 'Bez strachu' },
- { lang: 'tr', text: 'Korkma' },
- { lang: 'nl', text: 'Geen angst' },
- { lang: 'gr', text: 'Χωρίς φόβο' },
- { lang: 'ja', text: '恐れないで' },
- { lang: 'br', text: 'Sem medo' },
- { lang: 'ko', text: '두려워하지 마' },
- { lang: 'cs', text: 'Beze strachu' },
- { lang: 'zh', text: '别害怕' },
- { lang: 'sv', text: 'Ingen rädsla' },
- { lang: 'vi', text: 'Đừng sợ' },
- { lang: 'hu', text: 'Ne félj' },
- { lang: 'id', text: 'Jangan takut' },
- { lang: 'ca', text: 'Sense por' },
- { lang: 'ru', text: 'Без страха' },
- { lang: 'zh-TW', text: '別害怕' },
-]
-
-export const INSPIRED_URL = 'https://www.youtube.com/watch?v=Gg-SCpXba64'
-
-// The beacon retires itself after the release window. The white "viewable until"
-// badge and the dismiss copy live in one compact table so the 23 language blocks
-// above stay untouched — and it all still leaves with the folder.
-interface NoFearChrome {
- /** The white badge: this moment is viewable until Aug 23. */
- until: string
- /** aria-label / title of the top-right X. */
- dismiss: string
- /** Armed confirm label — a stray click must not retire it for good. */
- confirm: string
-}
-
-const CHROME: Record<string, NoFearChrome> = {
- de: { until: 'Noch bis 23.08. zu sehen', dismiss: 'Ausblenden', confirm: 'Dauerhaft ausblenden?' },
- en: { until: 'Shown until Aug 23', dismiss: 'Dismiss', confirm: 'Hide for good?' },
- es: { until: 'Visible hasta el 23 ago', dismiss: 'Ocultar', confirm: '¿Ocultar para siempre?' },
- fr: { until: 'Visible jusqu’au 23 août', dismiss: 'Masquer', confirm: 'Masquer définitivement ?' },
- it: { until: 'Visibile fino al 23 ago', dismiss: 'Nascondi', confirm: 'Nascondere per sempre?' },
- nl: { until: 'Te zien tot 23 aug', dismiss: 'Verbergen', confirm: 'Voorgoed verbergen?' },
- pl: { until: 'Widoczne do 23 sierpnia', dismiss: 'Ukryj', confirm: 'Ukryć na zawsze?' },
- ru: { until: 'Показывается до 23 августа', dismiss: 'Скрыть', confirm: 'Скрыть навсегда?' },
- uk: { until: 'Доступно до 23 серпня', dismiss: 'Сховати', confirm: 'Сховати назавжди?' },
- cs: { until: 'K vidění do 23. srpna', dismiss: 'Skrýt', confirm: 'Skrýt natrvalo?' },
- sv: { until: 'Visas till 23 aug', dismiss: 'Dölj', confirm: 'Dölj för gott?' },
- tr: { until: '23 Ağustos’a kadar görünür', dismiss: 'Gizle', confirm: 'Kalıcı olarak gizlensin mi?' },
- gr: { until: 'Έως 23 Αυγούστου', dismiss: 'Απόκρυψη', confirm: 'Μόνιμη απόκρυψη;' },
- hu: { until: 'Augusztus 23-ig látható', dismiss: 'Elrejtés', confirm: 'Végleg elrejti?' },
- br: { until: 'Visível até 23 de ago', dismiss: 'Ocultar', confirm: 'Ocultar para sempre?' },
- ca: { until: 'Visible fins al 23 d’ag.', dismiss: 'Amaga', confirm: 'Amagar per sempre?' },
- id: { until: 'Tampil hingga 23 Agu', dismiss: 'Sembunyikan', confirm: 'Sembunyikan selamanya?' },
- vi: { until: 'Hiển thị đến 23 tháng 8', dismiss: 'Ẩn', confirm: 'Ẩn vĩnh viễn?' },
- ja: { until: '8月23日まで公開', dismiss: '非表示', confirm: '完全に非表示にしますか?' },
- ko: { until: '8월 23일까지 표시', dismiss: '숨기기', confirm: '영구히 숨기시겠어요?' },
- zh: { until: '展示至 8月23日', dismiss: '隐藏', confirm: '永久隐藏?' },
- ar: { until: 'يظهر حتى 23 أغسطس', dismiss: 'إخفاء', confirm: 'إخفاء نهائيًا؟' },
- 'zh-TW': { until: '展示至 8月23日', dismiss: '隱藏', confirm: '永久隱藏?' },
-}
-
-export function noFearChrome(language: string): NoFearChrome {
- return CHROME[language] ?? CHROME.en
-}
diff --git a/client/src/components/FourZero/noFearScene.test.ts b/client/src/components/FourZero/noFearScene.test.ts
deleted file mode 100644
index 9a8f7e416..000000000
--- a/client/src/components/FourZero/noFearScene.test.ts
+++ /dev/null
@@ -1,609 +0,0 @@
-// FE-NOFEAR-SCN-001 to FE-NOFEAR-SCN-028
-import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
-import { http, HttpResponse } from 'msw'
-import { server } from '../../../tests/helpers/msw/server'
-import { NoFearScene, type SceneState } from './noFearScene'
-
-const GEO_URL = '/api/addons/atlas/countries/geo'
-
-interface DrawImageRecord { image: unknown; args: number[]; globalAlpha: number; composite: string }
-interface FillRectRecord { args: number[]; fillStyle: string; globalAlpha: number; composite: string }
-interface StrokeRecord { strokeStyle: string; lineWidth: number; globalAlpha: number }
-interface ArcFillRecord { x: number; y: number; r: number; fillStyle: string; globalAlpha: number; composite: string }
-
-interface FakeCtx {
- fillStyle: string
- strokeStyle: string
- lineWidth: number
- globalAlpha: number
- globalCompositeOperation: string
- clearRect: ReturnType<typeof vi.fn>
- save: ReturnType<typeof vi.fn>
- restore: ReturnType<typeof vi.fn>
- beginPath: ReturnType<typeof vi.fn>
- closePath: ReturnType<typeof vi.fn>
- moveTo: ReturnType<typeof vi.fn>
- lineTo: ReturnType<typeof vi.fn>
- arc: ReturnType<typeof vi.fn>
- fill: ReturnType<typeof vi.fn>
- stroke: ReturnType<typeof vi.fn>
- drawImage: ReturnType<typeof vi.fn>
- fillRect: ReturnType<typeof vi.fn>
- createRadialGradient: ReturnType<typeof vi.fn>
- getImageData: ReturnType<typeof vi.fn>
- images: DrawImageRecord[]
- rects: FillRectRecord[]
- strokes: StrokeRecord[]
- arcFills: ArcFillRecord[]
- rasters: number[][]
- points: number[][]
-}
-
-// jsdom ships no canvas backend: every context is a recorder, getImageData
-// replays `alphaAt`, and Path2D is a call log so the baked border geometry
-// stays observable.
-let alphaAt: (x: number, y: number, w: number) => number = () => 0
-let contextAvailable = true
-let contexts: FakeCtx[] = []
-let path2dCount = 0
-let pathMoveTo = 0
-let pathLineTo = 0
-let pathClose = 0
-let rafCount = 0
-let onFrame: ((n: number) => void) | null = null
-
-const originalGetContext = HTMLCanvasElement.prototype.getContext
-
-function makeCtx(): FakeCtx {
- let lastArc: { x: number; y: number; r: number } | null = null
- const ctx: FakeCtx = {
- fillStyle: '',
- strokeStyle: '',
- lineWidth: 1,
- globalAlpha: 1,
- globalCompositeOperation: 'source-over',
- clearRect: vi.fn(),
- save: vi.fn(),
- restore: vi.fn(),
- beginPath: vi.fn(),
- closePath: vi.fn(),
- moveTo: vi.fn((x: number, y: number) => { ctx.points.push([x, y]) }),
- lineTo: vi.fn((x: number, y: number) => { ctx.points.push([x, y]) }),
- arc: vi.fn((x: number, y: number, r: number) => { lastArc = { x, y, r } }),
- fill: vi.fn(() => {
- if (!lastArc) return
- ctx.arcFills.push({
- x: lastArc.x, y: lastArc.y, r: lastArc.r,
- fillStyle: ctx.fillStyle, globalAlpha: ctx.globalAlpha, composite: ctx.globalCompositeOperation,
- })
- }),
- stroke: vi.fn(() => {
- ctx.strokes.push({ strokeStyle: ctx.strokeStyle, lineWidth: ctx.lineWidth, globalAlpha: ctx.globalAlpha })
- }),
- drawImage: vi.fn((image: unknown, ...args: number[]) => {
- ctx.images.push({ image, args, globalAlpha: ctx.globalAlpha, composite: ctx.globalCompositeOperation })
- }),
- fillRect: vi.fn((...args: number[]) => {
- ctx.rects.push({ args, fillStyle: ctx.fillStyle, globalAlpha: ctx.globalAlpha, composite: ctx.globalCompositeOperation })
- }),
- createRadialGradient: vi.fn(() => ({ addColorStop: vi.fn() })),
- getImageData: vi.fn((_x: number, _y: number, w: number, h: number) => {
- ctx.rasters.push([w, h])
- const data = new Uint8ClampedArray(w * h * 4)
- for (let y = 0; y < h; y++) {
- for (let x = 0; x < w; x++) data[(y * w + x) * 4 + 3] = alphaAt(x, y, w)
- }
- return { data }
- }),
- images: [],
- rects: [],
- strokes: [],
- arcFills: [],
- rasters: [],
- points: [],
- }
- return ctx
-}
-
-class FakePath2D {
- moveTo(): void { pathMoveTo++ }
- lineTo(): void { pathLineTo++ }
- closePath(): void { pathClose++ }
- constructor() { path2dCount++ }
-}
-
-/** mulberry32 — a fixed seed keeps arcs, dots and sparks identical across runs. */
-function seedRandom(seed: number): void {
- let a = seed >>> 0
- vi.spyOn(Math, 'random').mockImplementation(() => {
- a = (a + 0x6d2b79f5) >>> 0
- let t = Math.imul(a ^ (a >>> 15), 1 | a)
- t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t
- return ((t ^ (t >>> 14)) >>> 0) / 4294967296
- })
-}
-
-const asCtx = (c: FakeCtx) => c as unknown as CanvasRenderingContext2D
-
-const state = (over: Partial<SceneState> = {}): SceneState => ({
- land: 0, cityLife: 0, cityDeath: 0, borderHeat: 0, borderBurst: 0,
- web: 0, warmth: 0, personalGlow: 0, particles: 0, opacity: 1, ...over,
-})
-
-type Ring = [number, number][]
-const ringA: Ring = [[-10, 50], [10, 50], [10, 40], [-10, 40], [-10, 50]]
-const ringB: Ring = [[100, -20], [120, -20], [120, -30], [100, -30], [100, -20]]
-const sliver: Ring = [[0, 0], [1, 1]]
-
-const GEO = {
- features: [
- { geometry: { type: 'Polygon', coordinates: [ringA] } },
- { geometry: { type: 'MultiPolygon', coordinates: [[ringB], [sliver]] } },
- {},
- { geometry: { type: 'Point', coordinates: [0, 0] } },
- ],
-}
-
-function serveGeo(body: unknown): void {
- server.use(http.get(GEO_URL, () => HttpResponse.json(body)))
-}
-
-/** The land-dot raster is the only 168-wide getImageData in this module. */
-const isDotRaster = (r: number[]) => r[0] === 168 && r[1] === 84
-const dotRasters = () => contexts.flatMap(c => c.rasters).filter(isDotRaster)
-
-/** The web layer is the only offscreen context stroked in the arc's amber. */
-const webContext = () => contexts.find(c => c.strokes.some(s => s.strokeStyle.startsWith('rgba(255, 176, 90')))
-
-async function loadedScene(width = 800, height = 600): Promise<NoFearScene> {
- serveGeo(GEO)
- const scene = new NoFearScene()
- await scene.load(width, height)
- return scene
-}
-
-beforeEach(() => {
- alphaAt = (x, y, w) => (w === 168 && x < 6 && y < 2 ? 255 : 0)
- contextAvailable = true
- contexts = []
- path2dCount = 0
- pathMoveTo = 0
- pathLineTo = 0
- pathClose = 0
- rafCount = 0
- onFrame = null
- seedRandom(12345)
-
- HTMLCanvasElement.prototype.getContext = vi.fn(() => {
- if (!contextAvailable) return null
- const c = makeCtx()
- contexts.push(c)
- return c
- }) as unknown as HTMLCanvasElement['getContext']
-
- vi.stubGlobal('Path2D', FakePath2D)
- vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => {
- rafCount += 1
- onFrame?.(rafCount)
- cb(0)
- return rafCount
- })
-})
-
-afterEach(() => {
- HTMLCanvasElement.prototype.getContext = originalGetContext
- vi.unstubAllGlobals()
- vi.restoreAllMocks()
-})
-
-describe('NoFearScene.load', () => {
- it('FE-NOFEAR-SCN-001: bakes border, dot and web layers from the Atlas bundle', async () => {
- const scene = await loadedScene()
-
- expect(dotRasters()).toHaveLength(1)
- expect(path2dCount).toBe(1)
- // two surviving rings of five points each
- expect(pathMoveTo).toBe(2)
- expect(pathLineTo).toBe(8)
- expect(pathClose).toBe(2)
-
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ land: 1, borderHeat: 1 }), 0)
- expect(ctx.images.length).toBeGreaterThan(0)
- })
-
- it('FE-NOFEAR-SCN-002: decimates rings against the global vertex budget', async () => {
- const dense: Ring = Array.from({ length: 14001 }, (_, i) => [i % 360 - 180, (i % 120) - 50])
- serveGeo({ features: [{ geometry: { type: 'Polygon', coordinates: [dense] } }] })
-
- await new NoFearScene().load(800, 600)
-
- // 14001 vertices → step 2 → 7001 kept, one moveTo + 7000 lineTo
- expect(pathMoveTo).toBe(1)
- expect(pathLineTo).toBe(7000)
- })
-
- it('FE-NOFEAR-SCN-003: drops rings too short to survive decimation', async () => {
- serveGeo({ features: [{ geometry: { type: 'Polygon', coordinates: [sliver] } }] })
- const scene = new NoFearScene()
- await scene.load(800, 600)
-
- // border layer still baked, but with an empty path and no sparks
- expect(path2dCount).toBe(1)
- expect(pathMoveTo).toBe(0)
-
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ borderBurst: 0.5 }), 0)
- expect(ctx.rects).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-004: ignores a bundle without usable geometry', async () => {
- serveGeo({ features: [{}, { geometry: { type: 'Point', coordinates: [0, 0] } }] })
- await new NoFearScene().load(800, 600)
-
- expect(path2dCount).toBe(0)
- expect(dotRasters()).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-005: ignores a bundle without a features array', async () => {
- serveGeo({})
- await new NoFearScene().load(800, 600)
- expect(path2dCount).toBe(0)
- })
-
- it('FE-NOFEAR-SCN-006: ignores a non-ok response', async () => {
- server.use(http.get(GEO_URL, () => HttpResponse.json({ error: 'off' }, { status: 404 })))
- await new NoFearScene().load(800, 600)
- expect(path2dCount).toBe(0)
- expect(dotRasters()).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-007: swallows a network failure and keeps the scene usable', async () => {
- server.use(http.get(GEO_URL, () => HttpResponse.error()))
- const scene = new NoFearScene()
- await expect(scene.load(800, 600)).resolves.toBeUndefined()
- expect(path2dCount).toBe(0)
-
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ land: 1, borderHeat: 1 }), 0)
- expect(ctx.images).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-008: aborts before the geometry pass', async () => {
- const controller = new AbortController()
- // The abort has to land between the response and the first frame yield,
- // which only a hand-rolled fetch can time precisely.
- vi.stubGlobal('fetch', vi.fn(async () => ({
- ok: true,
- json: async () => { controller.abort(); return GEO },
- })))
-
- const scene = new NoFearScene()
- await scene.load(800, 600, controller.signal)
-
- expect(dotRasters()).toHaveLength(0)
- expect(path2dCount).toBe(0)
- // no rings were stored, so a resize cannot rebake either
- scene.layout(1000, 700)
- expect(path2dCount).toBe(0)
- })
-
- it('FE-NOFEAR-SCN-009: aborts after the rings are decimated', async () => {
- const controller = new AbortController()
- onFrame = n => { if (n === 1) controller.abort() }
- serveGeo(GEO)
-
- const scene = new NoFearScene()
- await scene.load(800, 600, controller.signal)
-
- expect(dotRasters()).toHaveLength(0)
- expect(path2dCount).toBe(0)
- // the decimated rings survived, so a resize bakes them
- onFrame = null
- scene.layout(1000, 700)
- expect(path2dCount).toBe(1)
- })
-
- it('FE-NOFEAR-SCN-010: aborts after the land dots are sampled', async () => {
- const controller = new AbortController()
- onFrame = n => { if (n === 2) controller.abort() }
- serveGeo(GEO)
-
- const scene = new NoFearScene()
- await scene.load(800, 600, controller.signal)
-
- expect(dotRasters()).toHaveLength(1)
- expect(path2dCount).toBe(0)
- })
-
- it('FE-NOFEAR-SCN-011: survives a browser without a 2d context', async () => {
- contextAvailable = false
- serveGeo(GEO)
- const scene = new NoFearScene()
- await expect(scene.load(800, 600)).resolves.toBeUndefined()
-
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ land: 1, borderHeat: 1 }), 0)
- // no dot layers and no border layer were baked
- expect(ctx.images).toHaveLength(0)
- })
-})
-
-describe('NoFearScene.layout', () => {
- it('FE-NOFEAR-SCN-012: rebakes the layers on resize but not on a no-op layout', async () => {
- const scene = await loadedScene(800, 600)
- expect(path2dCount).toBe(1)
-
- scene.layout(1000, 700)
- expect(path2dCount).toBe(2)
- scene.layout(1000, 700)
- expect(path2dCount).toBe(2)
- })
-
- it('FE-NOFEAR-SCN-031: draws in raw lon/lat until the first layout', () => {
- const raw = makeCtx()
- new NoFearScene().draw(asCtx(raw), state({ web: 0.5 }), 0)
-
- expect(raw.points.length).toBeGreaterThan(0)
- expect(raw.points.every(([x, y]) => x >= -180 && x <= 180 && y >= -90 && y <= 90)).toBe(true)
-
- const scene = new NoFearScene()
- scene.layout(800, 600)
- const projected = makeCtx()
- scene.draw(asCtx(projected), state({ web: 0.5 }), 0)
- expect(projected.points.some(([x]) => x < -180 || x > 180)).toBe(true)
- })
-
- it('FE-NOFEAR-SCN-013: projects longitude and latitude into a cover-fitted equirectangular frame', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ cityLife: 1 }), 0)
-
- // scale = max(800/360, 600/136) ≈ 4.41; Berlin (13.4E) sits right of centre
- const scale = Math.max(800 / 360, 600 / 136)
- const ox = (800 - 360 * scale) / 2
- const oy = (600 - 136 * scale) / 2
- const berlin = ctx.images[0]
- expect(berlin.args[0]).toBeCloseTo(ox + (13.4 + 180) * scale - 8, 6)
- expect(berlin.args[1]).toBeCloseTo(oy + (78 - 52.52) * scale - 8, 6)
- })
-})
-
-describe('NoFearScene.draw', () => {
- it('FE-NOFEAR-SCN-014: clears the canvas and stops at zero opacity', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ land: 1, opacity: 0 }), 0)
-
- expect(ctx.clearRect).toHaveBeenCalledWith(0, 0, 800, 600)
- expect(ctx.save).not.toHaveBeenCalled()
- expect(ctx.images).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-015: blits one cold dot layer per twinkle group', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ land: 1 }), 0)
-
- expect(ctx.images).toHaveLength(3)
- // twinkle at t=0, g=0 sits at its 0.72 floor
- expect(ctx.images[0].globalAlpha).toBeCloseTo(0.6 * 0.72, 6)
- expect(ctx.images[1].globalAlpha).toBeCloseTo(0.6 * (0.72 + 0.28 * Math.sin(2.1)), 6)
- expect(ctx.globalAlpha).toBe(1)
- expect(ctx.restore).toHaveBeenCalledTimes(1)
- })
-
- it('FE-NOFEAR-SCN-016: crossfades the cold dot layers into the warm ones', async () => {
- const scene = await loadedScene(800, 600)
-
- const cold = makeCtx()
- scene.draw(asCtx(cold), state({ land: 1, warmth: 0 }), 0)
- const warm = makeCtx()
- scene.draw(asCtx(warm), state({ land: 1, warmth: 1 }), 0)
- const both = makeCtx()
- scene.draw(asCtx(both), state({ land: 1, warmth: 0.5 }), 0)
-
- expect(warm.images).toHaveLength(3)
- expect(both.images).toHaveLength(6)
- const coldLayers = cold.images.map(i => i.image)
- expect(warm.images.some(i => coldLayers.includes(i.image))).toBe(false)
- expect(both.images[0].globalAlpha).toBeCloseTo(0.6 * 0.72 * 0.5, 6)
- })
-
- it('FE-NOFEAR-SCN-017: lights every city in the opening act', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ cityLife: 1 }), 0)
-
- expect(ctx.images).toHaveLength(51)
- expect(ctx.images[0].args.slice(2)).toEqual([16, 16])
- expect(ctx.images[0].composite).toBe('lighter')
- expect(ctx.images[0].globalAlpha).toBeCloseTo(0.5, 6)
- expect(ctx.globalCompositeOperation).toBe('source-over')
- })
-
- it('FE-NOFEAR-SCN-018: kills the city lights one by one during the fear act', async () => {
- const scene = await loadedScene(800, 600)
-
- const half = makeCtx()
- scene.draw(asCtx(half), state({ cityLife: 1, cityDeath: 0.5 }), 0)
- expect(half.images.length).toBeGreaterThan(0)
- expect(half.images.length).toBeLessThan(51)
-
- const dead = makeCtx()
- scene.draw(asCtx(dead), state({ cityLife: 1, cityDeath: 1 }), 0)
- expect(dead.images).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-019: hands the cities over to the web layer once the web grows', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ cityLife: 1, web: 0.01 }), 0)
-
- // no 16x16 opening sprites — the web block owns the cities from here
- expect(ctx.images.filter(i => i.args[2] === 16)).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-020: pulses the baked border layer', async () => {
- const scene = await loadedScene(800, 600)
-
- const hot = makeCtx()
- scene.draw(asCtx(hot), state({ borderHeat: 1 }), 0)
- expect(hot.images).toHaveLength(1)
- expect(hot.images[0].args).toEqual([0, 0])
- expect(hot.images[0].globalAlpha).toBeCloseTo(0.72, 6)
-
- const halfLit = makeCtx()
- scene.draw(asCtx(halfLit), state({ borderHeat: 1, borderBurst: 0.5 }), 0)
- expect(halfLit.images[0].globalAlpha).toBeCloseTo(0.5 * 0.72, 6)
-
- const gone = makeCtx()
- scene.draw(asCtx(gone), state({ borderHeat: 1, borderBurst: 1 }), 0)
- expect(gone.images).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-021: shatters the borders into drifting sparks', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ borderBurst: 0.5 }), 0)
-
- expect(ctx.rects.length).toBeGreaterThan(0)
- expect(ctx.rects.length).toBeLessThanOrEqual(10)
- for (const r of ctx.rects) {
- expect(r.args.slice(2)).toEqual([1.6, 1.6])
- expect(['rgb(255, 150, 95)', 'rgb(255, 205, 130)']).toContain(r.fillStyle)
- expect(r.composite).toBe('lighter')
- }
- })
-
- it('FE-NOFEAR-SCN-022: drops sparks once they have burned out', async () => {
- const scene = await loadedScene(800, 600)
-
- const spent = makeCtx()
- scene.draw(asCtx(spent), state({ borderBurst: 0.99 }), 0)
- expect(spent.rects).toHaveLength(0)
-
- const over = makeCtx()
- scene.draw(asCtx(over), state({ borderBurst: 1 }), 0)
- expect(over.rects).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-023: bakes finished arcs once and strokes only the growing ones', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ web: 0.5 }), 0)
-
- const web = webContext()
- expect(web).toBeDefined()
- const bakedStrokes = web!.strokes.length
- expect(bakedStrokes).toBeGreaterThan(0)
- // two passes (glow + core) per baked arc
- expect(bakedStrokes % 2).toBe(0)
- expect(web!.strokes[0].lineWidth).toBe(4.2)
- expect(web!.strokes[1].lineWidth).toBe(1.2)
-
- // arcs still in flight are stroked on the live context instead
- expect(ctx.strokes.length).toBeGreaterThan(0)
- expect(ctx.images.some(i => i.args.length === 2)).toBe(true)
-
- // a second frame at the same progress must not re-bake anything
- const again = makeCtx()
- scene.draw(asCtx(again), state({ web: 0.5 }), 0)
- expect(web!.strokes).toHaveLength(bakedStrokes)
- })
-
- it('FE-NOFEAR-SCN-024: strokes a full arc with a fractional tip while it grows', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ web: 0.5 }), 0)
-
- const growing = ctx.strokes.length / 2
- expect(growing).toBeGreaterThan(0)
- // per growing arc: one moveTo, floor(48*local) segments plus the tip
- expect(ctx.moveTo).toHaveBeenCalledTimes(growing)
- expect(ctx.lineTo.mock.calls.length).toBeGreaterThan(growing)
- expect(ctx.strokes[0].strokeStyle).toMatch(/^rgba\(255, 176, 90, /)
- expect(ctx.strokes[1].strokeStyle).toMatch(/^rgba\(255, 202, 122, /)
- })
-
- it('FE-NOFEAR-SCN-025: a fully grown web lives entirely in the baked layer', async () => {
- const scene = await loadedScene(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ web: 1 }), 0)
-
- expect(ctx.strokes).toHaveLength(0)
- // one web-layer blit plus a halo and a core per city
- expect(ctx.images).toHaveLength(1 + 51 * 2)
- expect(ctx.images[0].args).toEqual([0, 0])
- expect(ctx.images[2].args.slice(2)).toEqual([6.4, 6.4])
- })
-
- it('FE-NOFEAR-SCN-026: grows the web without any Atlas geometry', () => {
- const scene = new NoFearScene()
- scene.layout(800, 600)
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ web: 0.5 }), 0)
-
- expect(ctx.strokes.length).toBeGreaterThan(0)
- expect(ctx.images).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-027: ignites the user places in order with an overshoot pulse', async () => {
- const scene = await loadedScene(800, 600)
- scene.setPersonalPlaces([
- { lat: 52.5, lng: 13.4 }, { lat: 48.8, lng: 2.3 },
- { lat: -33.9, lng: 151.2 }, { lat: 40.7, lng: -74 },
- ])
-
- const full = makeCtx()
- scene.draw(asCtx(full), state({ personalGlow: 1 }), 0)
- expect(full.images).toHaveLength(8)
- expect(full.images[1].args.slice(2)).toEqual([5.2, 5.2])
- // fully lit → no overshoot left on the halo
- expect(full.images[0].args[2]).toBeCloseTo(14, 6)
-
- const early = makeCtx()
- scene.draw(asCtx(early), state({ personalGlow: 0.1 }), 0)
- expect(early.images).toHaveLength(2)
- expect(early.images[0].args[2]).toBeGreaterThan(14)
- })
-
- it('FE-NOFEAR-SCN-028: caps the personal places at 400', async () => {
- const scene = await loadedScene(800, 600)
- scene.setPersonalPlaces(Array.from({ length: 450 }, (_, i) => ({ lat: (i % 80) - 40, lng: (i % 300) - 150 })))
-
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ personalGlow: 1 }), 0)
- expect(ctx.images).toHaveLength(800)
- })
-
- it('FE-NOFEAR-SCN-029: skips the personal glow before the sprites are baked', () => {
- const scene = new NoFearScene()
- scene.layout(800, 600)
- scene.setPersonalPlaces([{ lat: 10, lng: 10 }])
-
- const ctx = makeCtx()
- scene.draw(asCtx(ctx), state({ personalGlow: 1 }), 0)
- expect(ctx.images).toHaveLength(0)
- })
-
- it('FE-NOFEAR-SCN-030: raises the anthem particles and wraps them around the viewport', () => {
- const scene = new NoFearScene()
- scene.layout(800, 600)
-
- const start = makeCtx()
- scene.draw(asCtx(start), state({ particles: 1 }), 0)
- expect(start.arcFills).toHaveLength(90)
- for (const f of start.arcFills) {
- expect(f.fillStyle).toBe('rgb(255, 210, 150)')
- expect(f.composite).toBe('lighter')
- expect(f.y).toBeGreaterThanOrEqual(0)
- expect(f.y).toBeLessThanOrEqual(1.15 * 600)
- }
-
- const later = makeCtx()
- scene.draw(asCtx(later), state({ particles: 1 }), 12)
- expect(later.arcFills.map(f => f.y)).not.toEqual(start.arcFills.map(f => f.y))
- expect(later.arcFills.every(f => f.y >= 0 && f.y <= 1.15 * 600)).toBe(true)
- })
-})
diff --git a/client/src/components/FourZero/noFearScene.ts b/client/src/components/FourZero/noFearScene.ts
deleted file mode 100644
index 249149eb8..000000000
--- a/client/src/components/FourZero/noFearScene.ts
+++ /dev/null
@@ -1,481 +0,0 @@
-// Canvas scene for the 4.0.0 "KEINE ANGST" show: a world of dots whose city
-// lights die while its borders burn red — until the travel web returns, the
-// user's own places ignite, and the borders shatter into drifting sparks.
-//
-// Perf model: nothing expensive happens per frame. The Atlas rings are
-// decimated to a global vertex budget first; land dots, borders and the
-// finished part of the travel web are pre-rendered into offscreen layers
-// (rebuilt on resize) and blitted with drawImage. No shadowBlur anywhere in
-// the frame path — every glow is baked into a layer or a sprite.
-//
-// The geometry comes from TREK's own Atlas bundle (/addons/atlas/countries/geo).
-// If the Atlas addon is disabled the show degrades gracefully: no map, but the
-// city web and typography still carry it.
-
-type Ring = [number, number][]
-
-export interface SceneState {
- /** 0→1: how far the land dots have faded in. */
- land: number
- /** 0→1: the calm city lights of the opening. */
- cityLife: number
- /** 0→1: how far those lights have died during the fear act. */
- cityDeath: number
- /** 0→1: how hot the borders burn (red act). */
- borderHeat: number
- /** 0→1: the borders shattering into sparks at the climax. */
- borderBurst: number
- /** 0→1: how much of the city web has grown. */
- web: number
- /** 0→1: warm ambient glow of the release act. */
- warmth: number
- /** 0→1: the user's own places igniting gold. */
- personalGlow: number
- /** 0→1: rising particles of the anthem. */
- particles: number
- /** Master opacity for the whole scene. */
- opacity: number
-}
-
-// Landmark cities on every continent — the web's anchor points.
-const CITIES: [number, number][] = [
- [52.52, 13.4], [48.85, 2.35], [51.5, -0.12], [40.4, -3.7], [41.9, 12.5], [37.98, 23.7],
- [41.0, 28.98], [50.45, 30.52], [52.23, 21.01], [59.33, 18.07], [64.15, -21.9], [38.72, -9.14],
- [52.37, 4.9], [48.2, 16.37], [50.08, 14.44], [30.04, 31.24], [6.52, 3.38], [-1.29, 36.82],
- [-33.92, 18.42], [33.57, -7.59], [9.03, 38.74], [5.56, -0.2], [25.2, 55.27], [35.69, 51.39],
- [19.08, 72.88], [28.61, 77.21], [13.76, 100.5], [1.35, 103.82], [-6.21, 106.85], [21.03, 105.85],
- [35.68, 139.69], [37.57, 126.98], [39.9, 116.4], [31.23, 121.47], [25.03, 121.56], [14.6, 120.98],
- [-33.87, 151.21], [-36.85, 174.76], [61.22, -149.9], [49.28, -123.12], [37.77, -122.42],
- [19.43, -99.13], [40.71, -74.01], [43.65, -79.38], [23.11, -82.37], [4.71, -74.07],
- [-12.05, -77.04], [-23.55, -46.63], [-34.6, -58.38], [-33.45, -70.67], [-22.91, -43.17],
-]
-
-const LAT_TOP = 78
-const LAT_BOT = -58
-const TWINKLE_GROUPS = 3
-const BORDER_VERTEX_BUDGET = 14000
-const BURST_SPARKS = 2200
-
-interface Arc { a: number; b: number; delay: number; baked: boolean }
-interface Particle { x: number; y: number; v: number; drift: number; size: number; seed: number }
-interface Spark { lon: number; lat: number; vx: number; vy: number; seed: number }
-
-const nextFrame = () => new Promise<void>(r => requestAnimationFrame(() => r()))
-
-export class NoFearScene {
- private rings: Ring[] = []
- private dotLonLat: { x: number; y: number; r: number; g: number }[] = []
- private arcs: Arc[] = []
- private particlesPool: Particle[] = []
- private sparks: Spark[] = []
- private personal: { lat: number; lng: number }[] = []
- private w = 0
- private h = 0
-
- // Prebaked layers (screen-sized). Rebuilt on resize / when geometry arrives.
- private coldLayers: HTMLCanvasElement[] = []
- private warmLayers: HTMLCanvasElement[] = []
- private borderLayer: HTMLCanvasElement | null = null
- private webLayer: HTMLCanvasElement | null = null
- private webCtx: CanvasRenderingContext2D | null = null
- private citySprite: HTMLCanvasElement | null = null
- private goldSprite: HTMLCanvasElement | null = null
- private lastWeb = 0
-
- private px = (lon: number): number => lon
- private py = (lat: number): number => lat
-
- constructor() {
- // Every city connects to a couple of far-away peers — long lines across
- // many borders are the whole point.
- const d2 = (i: number, j: number) => {
- const [la, lo] = CITIES[i]
- const [lb, lob] = CITIES[j]
- return (la - lb) ** 2 + (lo - lob) ** 2
- }
- const seen = new Set<string>()
- CITIES.forEach((_, i) => {
- const peers = CITIES.map((_, j) => j).filter(j => j !== i && d2(i, j) > 900)
- for (let k = 0; k < 2 && peers.length > 0; k++) {
- const j = peers.splice(Math.floor(Math.random() * peers.length), 1)[0]
- const key = i < j ? `${i}-${j}` : `${j}-${i}`
- if (seen.has(key)) continue
- seen.add(key)
- this.arcs.push({ a: i, b: j, delay: Math.random(), baked: false })
- }
- })
- this.arcs.sort((x, y) => x.delay - y.delay)
- for (let i = 0; i < 90; i++) {
- this.particlesPool.push({
- x: Math.random(), y: 1 + Math.random(), v: 0.02 + Math.random() * 0.05,
- drift: (Math.random() - 0.5) * 0.02, size: 0.7 + Math.random() * 1.7, seed: Math.random() * 7,
- })
- }
- }
-
- /** The user's own visited places — they ignite gold in the release act. */
- setPersonalPlaces(points: { lat: number; lng: number }[]): void {
- this.personal = points.slice(0, 400)
- }
-
- /** Fetches the Atlas country bundle and builds all static layers. Safe to fail. */
- async load(width: number, height: number, signal?: AbortSignal): Promise<void> {
- this.layout(width, height)
- try {
- const res = await fetch('/api/addons/atlas/countries/geo', { credentials: 'include', signal })
- if (!res.ok) return
- const geo = await res.json() as { features?: { geometry?: { type: string; coordinates: unknown } }[] }
- if (signal?.aborted) return
- await nextFrame() // let the parse frame paint before the geometry pass
- const raw: Ring[] = []
- for (const f of geo.features ?? []) {
- const g = f.geometry
- if (!g) continue
- if (g.type === 'Polygon') for (const r of g.coordinates as Ring[]) raw.push(r)
- else if (g.type === 'MultiPolygon') for (const p of g.coordinates as Ring[][]) for (const r of p) raw.push(r)
- }
- if (raw.length === 0) return
- // Decimate against a global vertex budget BEFORE any rasterizing — the
- // Atlas bundle carries ~2M points, the show needs a fraction of that.
- const total = raw.reduce((n, r) => n + r.length, 0)
- const step = Math.max(1, Math.ceil(total / BORDER_VERTEX_BUDGET))
- const rings: Ring[] = []
- for (const r of raw) {
- if (r.length < step * 4) continue // rings too small to survive decimation are visual noise
- const thin: Ring = []
- for (let i = 0; i < r.length; i += step) thin.push(r[i])
- rings.push(thin)
- }
- this.rings = rings
- if (signal?.aborted) return
- await nextFrame()
- this.sampleDots(rings)
- if (signal?.aborted) return
- await nextFrame()
- this.bake()
- } catch {
- // Atlas addon off / offline / aborted — the show runs without the map.
- }
- }
-
- layout(width: number, height: number): void {
- const changed = width !== this.w || height !== this.h
- this.w = width
- this.h = height
- // Equirectangular, latitude clamped (no empty Antarctica band), "cover" fit.
- const scale = Math.max(width / 360, height / (LAT_TOP - LAT_BOT))
- const mapW = 360 * scale
- const mapH = (LAT_TOP - LAT_BOT) * scale
- const ox = (width - mapW) / 2
- const oy = (height - mapH) / 2
- this.px = (lon: number) => ox + (lon + 180) * scale
- this.py = (lat: number) => oy + (LAT_TOP - lat) * scale
- // Layers bake in pixel space — a resize invalidates them all.
- if (changed && this.rings.length > 0) this.bake()
- }
-
- private sampleDots(rings: Ring[]): void {
- const cols = 168
- const rows = 84
- const off = document.createElement('canvas')
- off.width = cols
- off.height = rows
- const c = off.getContext('2d')
- if (!c) return
- const sx = (lon: number) => ((lon + 180) / 360) * cols
- const sy = (lat: number) => ((LAT_TOP - lat) / (LAT_TOP - LAT_BOT)) * rows
- c.fillStyle = '#fff'
- c.beginPath()
- for (const ring of rings) {
- c.moveTo(sx(ring[0][0]), sy(ring[0][1]))
- for (let i = 1; i < ring.length; i++) c.lineTo(sx(ring[i][0]), sy(ring[i][1]))
- c.closePath()
- }
- c.fill('evenodd')
- const img = c.getImageData(0, 0, cols, rows).data
- this.dotLonLat = []
- for (let y = 0; y < rows; y++) {
- for (let x = 0; x < cols; x++) {
- if (img[(y * cols + x) * 4 + 3] > 96) {
- this.dotLonLat.push({
- x: (x / cols) * 360 - 180,
- y: LAT_TOP - (y / rows) * (LAT_TOP - LAT_BOT),
- r: 0.8 + Math.random() * 0.9,
- g: Math.floor(Math.random() * TWINKLE_GROUPS),
- })
- }
- }
- }
- }
-
- /** (Re)builds every static layer in current screen coordinates. */
- private bake(): void {
- const mk = () => {
- const cv = document.createElement('canvas')
- cv.width = Math.max(this.w, 1)
- cv.height = Math.max(this.h, 1)
- return cv
- }
- // Dot layers: one cold + one warm canvas per twinkle group.
- this.coldLayers = []
- this.warmLayers = []
- for (let g = 0; g < TWINKLE_GROUPS; g++) {
- const cold = mk(); const warm = mk()
- const cc = cold.getContext('2d'); const wc = warm.getContext('2d')
- if (!cc || !wc) continue
- cc.fillStyle = 'rgb(112, 132, 168)'
- wc.fillStyle = 'rgb(214, 189, 141)'
- for (const d of this.dotLonLat) {
- if (d.g !== g) continue
- const x = this.px(d.x); const y = this.py(d.y)
- cc.beginPath(); cc.arc(x, y, d.r, 0, Math.PI * 2); cc.fill()
- wc.beginPath(); wc.arc(x, y, d.r, 0, Math.PI * 2); wc.fill()
- }
- this.coldLayers.push(cold)
- this.warmLayers.push(warm)
- }
- // Border layer: glow baked once via a wide soft stroke under a hot core.
- const borders = mk()
- const bc = borders.getContext('2d')
- if (bc) {
- const path = new Path2D()
- for (const ring of this.rings) {
- path.moveTo(this.px(ring[0][0]), this.py(ring[0][1]))
- for (let i = 1; i < ring.length; i++) path.lineTo(this.px(ring[i][0]), this.py(ring[i][1]))
- path.closePath()
- }
- bc.strokeStyle = 'rgba(210, 40, 35, 0.16)'
- bc.lineWidth = 6
- bc.stroke(path)
- bc.strokeStyle = 'rgba(235, 62, 52, 0.55)'
- bc.lineWidth = 2.6
- bc.stroke(path)
- bc.strokeStyle = 'rgba(255, 120, 95, 0.9)'
- bc.lineWidth = 1.1
- bc.stroke(path)
- this.borderLayer = borders
- }
- // Sparks for the shatter: sampled along the borders, each with a drift vector.
- this.sparks = []
- const every = Math.max(1, Math.floor(this.rings.reduce((n, r) => n + r.length, 0) / BURST_SPARKS))
- let idx = 0
- for (const ring of this.rings) {
- for (const [lon, lat] of ring) {
- if (idx++ % every !== 0) continue
- const ang = Math.random() * Math.PI * 2
- const sp = 0.4 + Math.random() * 0.6
- this.sparks.push({ lon, lat, vx: Math.cos(ang) * sp, vy: Math.sin(ang) * sp - 0.55, seed: Math.random() })
- }
- }
- // Web layer: finished arcs + lit cities accumulate here.
- this.webLayer = mk()
- this.webCtx = this.webLayer.getContext('2d')
- for (const a of this.arcs) a.baked = false
- this.lastWeb = 0
- // Glow sprites: one warm (cities), one gold (the user's own places).
- this.citySprite = this.makeSprite('rgba(255, 216, 140, 0.95)', 'rgba(255, 190, 110, 0.45)', 'rgba(255, 180, 100, 0)')
- this.goldSprite = this.makeSprite('rgba(255, 232, 170, 1)', 'rgba(255, 205, 120, 0.55)', 'rgba(255, 195, 105, 0)')
- }
-
- private makeSprite(inner: string, mid: string, outer: string): HTMLCanvasElement {
- const sprite = document.createElement('canvas')
- sprite.width = 64
- sprite.height = 64
- const sc = sprite.getContext('2d')
- if (sc) {
- const grad = sc.createRadialGradient(32, 32, 0, 32, 32, 32)
- grad.addColorStop(0, inner)
- grad.addColorStop(0.25, mid)
- grad.addColorStop(1, outer)
- sc.fillStyle = grad
- sc.fillRect(0, 0, 64, 64)
- }
- return sprite
- }
-
- private arcPoint(arc: Arc, q: number): [number, number] {
- const [alat, alon] = CITIES[arc.a]
- const [blat, blon] = CITIES[arc.b]
- const x1 = this.px(alon); const y1 = this.py(alat)
- const x2 = this.px(blon); const y2 = this.py(blat)
- const mx = (x1 + x2) / 2
- const my = (y1 + y2) / 2 - Math.min(Math.hypot(x2 - x1, y2 - y1) * 0.22, this.h * 0.2)
- return [
- (1 - q) * (1 - q) * x1 + 2 * (1 - q) * q * mx + q * q * x2,
- (1 - q) * (1 - q) * y1 + 2 * (1 - q) * q * my + q * q * y2,
- ]
- }
-
- private strokeArc(c: CanvasRenderingContext2D, arc: Arc, upTo: number, alpha: number): void {
- // The tip interpolates FRACTIONALLY along the curve — quantizing growth to
- // whole segments made the heads visibly step forward instead of glide.
- const steps = 48
- const n = Math.floor(steps * upTo)
- c.beginPath()
- for (let i = 0; i <= n; i++) {
- const [ix, iy] = this.arcPoint(arc, (i / steps))
- if (i === 0) c.moveTo(ix, iy)
- else c.lineTo(ix, iy)
- }
- if (upTo < 1) {
- const [tx, ty] = this.arcPoint(arc, upTo)
- c.lineTo(tx, ty)
- }
- c.strokeStyle = `rgba(255, 176, 90, ${0.10 * alpha})`
- c.lineWidth = 4.2
- c.stroke()
- c.strokeStyle = `rgba(255, 202, 122, ${0.4 * alpha})`
- c.lineWidth = 1.2
- c.stroke()
- }
-
- private arcLocal(arc: Arc, web: number): number {
- // A tighter growth window + ease-out: each arc shoots off and settles,
- // rather than crawling for a third of the act.
- const q = Math.min(Math.max((web - arc.delay * 0.84) / 0.16, 0), 1)
- return 1 - (1 - q) ** 3
- }
-
- draw(c: CanvasRenderingContext2D, s: SceneState, t: number): void {
- const { w, h } = this
- c.clearRect(0, 0, w, h)
- if (s.opacity <= 0) return
- c.save()
-
- // Land: TWINKLE_GROUPS×2 drawImages, alpha does the twinkle and the warmth mix.
- if (s.land > 0 && this.coldLayers.length > 0) {
- for (let g = 0; g < this.coldLayers.length; g++) {
- const twinkle = 0.72 + 0.28 * Math.sin(t * 0.8 + g * 2.1)
- const a = s.opacity * s.land * 0.6 * twinkle
- if (s.warmth < 1) {
- c.globalAlpha = a * (1 - s.warmth)
- c.drawImage(this.coldLayers[g], 0, 0)
- }
- if (s.warmth > 0) {
- c.globalAlpha = a * s.warmth
- c.drawImage(this.warmLayers[g], 0, 0)
- }
- }
- }
-
- // The opening's calm city lights — and their death in the fear act. Each city
- // dies at its own pseudo-random moment while the borders heat up.
- if (this.citySprite && s.cityLife > 0 && s.cityDeath < 1 && s.web <= 0) {
- c.globalCompositeOperation = 'lighter'
- for (let i = 0; i < CITIES.length; i++) {
- const on = Math.min(Math.max(s.cityLife * 1.5 - ((i * 29) % 100) / 100 * 0.5, 0), 1)
- const deathAt = ((i * 37) % 100) / 100 * 0.8
- const dead = Math.min(Math.max((s.cityDeath * 1.25 - deathAt) / 0.2, 0), 1)
- const a = on * (1 - dead)
- if (a <= 0) continue
- // A light flickers just before it dies.
- const flicker = dead > 0 && dead < 1 ? 0.5 + 0.5 * Math.sin(t * 26 + i * 3) : 1
- const [lat, lon] = CITIES[i]
- const x = this.px(lon); const y = this.py(lat)
- c.globalAlpha = s.opacity * 0.5 * a * flicker
- c.drawImage(this.citySprite, x - 8, y - 8, 16, 16)
- }
- c.globalCompositeOperation = 'source-over'
- }
-
- // Borders: one blit; pulse via alpha. The climax shatter replaces the layer
- // with sparks that drift off and burn out.
- if (this.borderLayer && s.borderHeat > 0 && s.borderBurst < 1) {
- const alive = 1 - s.borderBurst
- const pulse = 0.72 + 0.28 * Math.sin(t * 2.4)
- c.globalAlpha = s.opacity * alive * s.borderHeat * pulse
- c.drawImage(this.borderLayer, 0, 0)
- }
- if (s.borderBurst > 0 && s.borderBurst < 1 && this.sparks.length > 0) {
- c.globalCompositeOperation = 'lighter'
- const prog = s.borderBurst
- const ease = 1 - (1 - prog) * (1 - prog)
- for (const sp of this.sparks) {
- const a = (1 - prog) * (0.5 + 0.5 * Math.sin(sp.seed * 9 + t * 7))
- if (a <= 0.02) continue
- const x = this.px(sp.lon) + sp.vx * ease * 46
- const y = this.py(sp.lat) + sp.vy * ease * 46
- c.globalAlpha = s.opacity * a
- c.fillStyle = sp.seed > 0.5 ? 'rgb(255, 150, 95)' : 'rgb(255, 205, 130)'
- c.fillRect(x, y, 1.6, 1.6)
- }
- c.globalCompositeOperation = 'source-over'
- }
-
- // Web: finished arcs live in the baked layer; only growing arcs are stroked.
- if (s.web > 0) {
- c.globalCompositeOperation = 'lighter'
- if (this.webCtx && s.web > this.lastWeb) {
- for (const arc of this.arcs) {
- if (!arc.baked && this.arcLocal(arc, s.web) >= 1) {
- this.strokeArc(this.webCtx, arc, 1, 1)
- arc.baked = true
- }
- }
- this.lastWeb = s.web
- }
- if (this.webLayer) {
- c.globalAlpha = s.opacity
- c.drawImage(this.webLayer, 0, 0)
- }
- c.globalAlpha = s.opacity
- for (const arc of this.arcs) {
- if (arc.baked) continue
- const local = this.arcLocal(arc, s.web)
- if (local <= 0) continue
- this.strokeArc(c, arc, local, local)
- }
- if (this.citySprite) {
- for (let i = 0; i < CITIES.length; i++) {
- const local = Math.min(Math.max((s.web - (i / CITIES.length) * 0.5) / 0.2, 0), 1)
- if (local <= 0) continue
- const [lat, lon] = CITIES[i]
- const x = this.px(lon); const y = this.py(lat)
- const halo = (11 + Math.sin(t * 1.8 + i) * 3) * (0.6 + 0.4 * local)
- c.globalAlpha = s.opacity * 0.55 * local
- c.drawImage(this.citySprite, x - halo, y - halo, halo * 2, halo * 2)
- c.globalAlpha = s.opacity * local
- c.drawImage(this.citySprite, x - 3.2, y - 3.2, 6.4, 6.4)
- }
- }
- c.globalCompositeOperation = 'source-over'
- }
-
- // The user's own places igniting gold — each with a small overshoot pulse.
- if (this.goldSprite && s.personalGlow > 0 && this.personal.length > 0) {
- c.globalCompositeOperation = 'lighter'
- const n = this.personal.length
- for (let i = 0; i < n; i++) {
- const local = Math.min(Math.max((s.personalGlow - (i / n) * 0.6) / 0.25, 0), 1)
- if (local <= 0) continue
- const p = this.personal[i]
- const x = this.px(p.lng); const y = this.py(p.lat)
- const overshoot = 1 + (1 - local) * 2.2
- const halo = 7 * overshoot
- c.globalAlpha = s.opacity * 0.85 * local
- c.drawImage(this.goldSprite, x - halo, y - halo, halo * 2, halo * 2)
- c.globalAlpha = s.opacity * local
- c.drawImage(this.goldSprite, x - 2.6, y - 2.6, 5.2, 5.2)
- }
- c.globalCompositeOperation = 'source-over'
- }
-
- // Rising particles for the anthem.
- if (s.particles > 0) {
- c.globalCompositeOperation = 'lighter'
- for (const p of this.particlesPool) {
- const y = ((((p.y - t * p.v * 0.13) % 1.15) + 1.15) % 1.15)
- const x = p.x + Math.sin(t * 0.4 + p.seed) * p.drift
- c.globalAlpha = s.opacity * 0.28 * s.particles * (0.4 + 0.6 * Math.abs(Math.sin(t + p.seed)))
- c.fillStyle = 'rgb(255, 210, 150)'
- c.beginPath()
- c.arc(x * w, y * h, p.size, 0, Math.PI * 2)
- c.fill()
- }
- c.globalCompositeOperation = 'source-over'
- }
-
- c.globalAlpha = 1
- c.restore()
- }
-}
diff --git a/client/src/pages/DashboardPage.tsx b/client/src/pages/DashboardPage.tsx
index 290bccf33..c43994ce1 100644
--- a/client/src/pages/DashboardPage.tsx
+++ b/client/src/pages/DashboardPage.tsx
@@ -21,7 +21,6 @@ import {
} from 'lucide-react'
import { IcsSubscribeModal } from '../components/Planner/IcsSubscribeModal'
import CollectionsWidget from '../components/Dashboard/CollectionsWidget'
-import NoFearBeacon from '../components/FourZero/NoFearBeacon' // 4.0.0 release moment — remove with the FourZero folder
import PluginWidgets from '../components/Plugins/PluginWidgets'
import PluginFrame from '../components/Plugins/PluginFrame'
import { TripCardBadges, useTripCardBadges } from '../components/Plugins/TripCardBadges'
@@ -246,7 +245,6 @@ function DashboardPageDesktop(): React.ReactElement {
{sidebarVisible && (
<aside className="page-sidebar">
- <NoFearBeacon /> {/* 4.0.0 release moment — remove with the FourZero folder */}
{showCurrency && <CurrencyTool />}
{showCollections && <CollectionsWidget onOpen={() => navigate('/collections')} />}
{showTimezones && <TimezoneTool locale={locale} />}