diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 58076b6..f8bb8c3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -173,6 +173,35 @@ jobs:
path: output/release-evidence/
if-no-files-found: warn
+ receiver-node26:
+ name: Receiver regression / Node 26 / ${{ matrix.os }}
+ if: github.event_name != 'schedule'
+ runs-on: ${{ matrix.os }}
+ timeout-minutes: 10
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ # Issue #55 was reported on Node 26. This additive renderer check keeps
+ # the maintained Node 22/24 platform and playback matrix unchanged.
+ steps:
+ - name: Checkout
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - name: Setup Node
+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
+ with:
+ node-version: 26.x
+ cache: npm
+
+ - name: Install
+ run: npm ci
+
+ - name: Receiver output, memory and terminal compatibility
+ env:
+ VITEST_MAX_WORKERS: '1'
+ run: npx vitest run src/cli-tui-runtime.test.ts src/ui/components/ReceiverVisualRow.test.tsx src/ui/visual-baseline.test.tsx src/ui/portable-render.test.tsx src/ui/receiver-animation.test.tsx
+
playback-smoke:
name: Playback Smoke
runs-on: ${{ matrix.os }}
@@ -272,16 +301,17 @@ jobs:
required-release-checks:
name: Required Release Checks
- needs: [verify, playback-smoke, docs]
+ needs: [verify, receiver-node26, playback-smoke, docs]
if: always() && github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- name: Require all maintained-platform jobs
env:
VERIFY: ${{ needs.verify.result }}
+ RECEIVER_NODE26: ${{ needs.receiver-node26.result }}
PLAYBACK: ${{ needs.playback-smoke.result }}
DOCS: ${{ needs.docs.result }}
- run: test "$VERIFY" = success && test "$PLAYBACK" = success && test "$DOCS" = success
+ run: test "$VERIFY" = success && test "$RECEIVER_NODE26" = success && test "$PLAYBACK" = success && test "$DOCS" = success
# Experimental jobs run in full guest kernels, not Linux containers. They are
# opt-in/weekly and do not establish maintained or audible-playback support.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e3a0723..f8346b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,38 @@
All notable changes to RadioCLI are documented in this file.
+## [0.2.6] - 2026-10-28
+
+### Added
+
+- Added the Boat Lake receiver, bringing the collection to 64 animated styles.
+- Expanded the display palette from 14 to 48 colors, with matching listening
+ activity shades and color choices in the website receiver gallery.
+
+### Changed
+
+- Refined Sumi Ocean with a clearer moon, moving water, and wider reflections
+ that remain readable in compact and micro layouts.
+- Updated the website receiver previews and project demos to match the terminal
+ renderers, including Boat Lake, Sumi Ocean, and the expanded color palette.
+
+### Fixed
+
+- Prevented long-running animated receiver sessions from exhausting Node.js
+ memory, including Manhattan and the other scenery styles, across full,
+ compact, and micro layouts.
+- Kept normal TUI launches on the production React runtime while preserving
+ explicitly enabled development diagnostics.
+- Preserved new colors and receiver selections while older RadioCLI and MCP
+ processes continue reading and writing the same library.
+- Avoided transient library-lock failures on Windows while another writer
+ releases its lock.
+
+### Security
+
+- Updated Zod and Undici to patched versions within their existing dependency
+ ranges.
+
## [0.2.5] - 2026-10-18
### Added
@@ -546,3 +578,4 @@ Initial public release.
[0.1.2]: https://github.com/Ciphore/RadioCLI/releases/tag/v0.1.2
[0.1.1]: https://github.com/Ciphore/RadioCLI/releases/tag/v0.1.1
[0.2.5]: https://github.com/Ciphore/RadioCLI/releases/tag/v0.2.5
+[0.2.6]: https://github.com/Ciphore/RadioCLI/releases/tag/v0.2.6
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6a83bed..86bff27 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -95,6 +95,24 @@ major screens, and receiver styles. Preserve Unicode captures. When rendering
changes intentionally, describe the visible effect in the pull request and do
not update snapshots merely to hide failures.
+Receiver changes also run an isolated real-Ink memory regression in the normal
+test suite. For a longer accelerated soak (frames run without the 80 ms delay):
+
+```bash
+node --expose-gc --import tsx scripts/receiver-memory-smoke.mjs --frames=10000
+```
+
+The harness updates one persistent Ink root, discards terminal output, waits
+for each frame to flush, and compares
+post-GC JavaScript heap after warmup; RSS includes allocator high-water memory
+and is recorded separately. It cycles scenery, sizes, themes, ASCII, and
+background settings. Like the CLI, it defaults to the production React runtime
+before loading the renderer. An explicit `NODE_ENV=development` keeps React's
+developer diagnostics, including profiling entries retained by Node; use the
+production runtime for memory acceptance. Node 26 has an additional receiver-only CI check on Linux,
+macOS, and Windows for issue #55; this does not replace the full Node 22/24
+platform matrix or establish full Node 26 platform verification.
+
## Issue Triage
Playback issues should include station name, country, backend, and
diff --git a/README.md b/README.md
index 5249e76..a613267 100644
--- a/README.md
+++ b/README.md
@@ -16,9 +16,9 @@ world without leaving your terminal. No account. No cloud library.
codec, and bitrate, or browse country lists. The interactive world map uses a
cached station atlas to find broadcasts around the map cursor and sort them by
distance. Cached directory results remain available during provider outages.
-- **63 receiver styles:** Switch between braille animation, ASCII geometry,
+- **64 receiver styles:** Switch between braille animation, ASCII geometry,
waves, fire, cityscapes, and the Gallop display without interrupting
- playback. Color themes are selected independently. Receivers animate during
+ playback. Choose from 48 color themes independently. Receivers animate during
active playback and return to a zero-signal display when audio is inactive.
- **Listening stats:** A 52-week activity graph, listening time, session counts,
active days, streaks, and your most-listened station. Stats are recorded locally
diff --git a/apps/docs/app/(home)/page.tsx b/apps/docs/app/(home)/page.tsx
index 950d430..31f028c 100644
--- a/apps/docs/app/(home)/page.tsx
+++ b/apps/docs/app/(home)/page.tsx
@@ -81,7 +81,7 @@ export default function HomePage() {
- Try all 63 receiver styles →
+ Try all 64 receiver styles →
{features.filter((_, index) => index > 1 && index !== 4).map(feature =>
)}
diff --git a/apps/docs/app/(home)/receivers/page.tsx b/apps/docs/app/(home)/receivers/page.tsx
index 3ae079d..1a2666d 100644
--- a/apps/docs/app/(home)/receivers/page.tsx
+++ b/apps/docs/app/(home)/receivers/page.tsx
@@ -5,10 +5,10 @@ import './receiver-names.css';
import { ReceiverGallery } from '@/components/receiver-gallery';
export const metadata: Metadata = {
- title: '63 Receiver Styles',
- description: 'Explore all 63 RadioCLI receiver styles, with their original palettes and supported theme colors. Animated directly from the terminal renderer.',
+ title: '64 Receiver Styles',
+ description: 'Explore all 64 RadioCLI receiver styles, with their original palettes and supported theme colors. Animated directly from the terminal renderer.',
alternates: { canonical: '/receivers' },
- openGraph: { title: 'RadioCLI Receiver Styles', url: '/receivers', description: '63 animated receiver styles, original palettes, and supported theme colors.' },
+ openGraph: { title: 'RadioCLI Receiver Styles', url: '/receivers', description: '64 animated receiver styles, original palettes, and supported theme colors.' },
};
export default function ReceiversPage() {
diff --git a/apps/docs/components/receiver-gallery.tsx b/apps/docs/components/receiver-gallery.tsx
index 346b404..45d3772 100644
--- a/apps/docs/components/receiver-gallery.tsx
+++ b/apps/docs/components/receiver-gallery.tsx
@@ -148,8 +148,8 @@ export function ReceiverGallery({ preview = false }: { preview?: boolean }) {
-
{preview ? '63 animated receiver styles' : 'Receiver styles'}
-
{preview ? 'Choose from ASCII patterns, waves, cityscapes, and more.' : '63 animated playback visuals, from flowing patterns to cityscapes and landscapes.'}
+
{preview ? '64 animated receiver styles' : 'Receiver styles'}
+
{preview ? 'Choose from ASCII patterns, waves, cityscapes, and more.' : '64 animated playback visuals, from flowing patterns to cityscapes and landscapes.'}
{!preview &&
diff --git a/apps/docs/content/docs/changelog.mdx b/apps/docs/content/docs/changelog.mdx
index c0bd8e5..a30092c 100644
--- a/apps/docs/content/docs/changelog.mdx
+++ b/apps/docs/content/docs/changelog.mdx
@@ -3,6 +3,38 @@ title: Changelog
description: Release history for RadioCLI.
---
+## 0.2.6 - 2026-10-28
+
+### Added
+
+- Added the Boat Lake receiver, bringing the collection to 64 animated styles.
+- Expanded the display palette from 14 to 48 colors, with matching listening
+ activity shades and color choices in the website receiver gallery.
+
+### Changed
+
+- Refined Sumi Ocean with a clearer moon, moving water, and wider reflections
+ that remain readable in compact and micro layouts.
+- Updated the website receiver previews and project demos to match the terminal
+ renderers, including Boat Lake, Sumi Ocean, and the expanded color palette.
+
+### Fixed
+
+- Prevented long-running animated receiver sessions from exhausting Node.js
+ memory, including Manhattan and the other scenery styles, across full,
+ compact, and micro layouts.
+- Kept normal TUI launches on the production React runtime while preserving
+ explicitly enabled development diagnostics.
+- Preserved new colors and receiver selections while older RadioCLI and MCP
+ processes continue reading and writing the same library.
+- Avoided transient library-lock failures on Windows while another writer
+ releases its lock.
+
+### Security
+
+- Updated Zod and Undici to patched versions within their existing dependency
+ ranges.
+
## 0.2.5 - 2026-10-18
### Added
diff --git a/apps/docs/content/docs/release-packaging.mdx b/apps/docs/content/docs/release-packaging.mdx
index b587db2..264c150 100644
--- a/apps/docs/content/docs/release-packaging.mdx
+++ b/apps/docs/content/docs/release-packaging.mdx
@@ -51,7 +51,7 @@ recorded evidence; npm cannot rerun the source verification from that artifact.
Test the packed tarball locally:
```bash
-VERSION=0.2.5
+VERSION=0.2.6
npm pack
npm install -g "./ciphore-radiocli-$VERSION.tgz"
radiocli --help
@@ -63,7 +63,7 @@ Publish:
```bash
npm login
-npm publish ./output/release-evidence/ciphore-radiocli-0.2.5.tgz --access public
+npm publish ./output/release-evidence/ciphore-radiocli-0.2.6.tgz --access public
```
After publishing, `npm install -g @ciphore/radiocli` should install the
@@ -99,9 +99,9 @@ The evidence directory also retains the tested tarball and a `candidate.json`
source record. `--require-clean` rejects a dirty or unknown source state when
running the fresh-install harness directly.
-The same harness upgrades separate installations of published versions 0.2.3
-and 0.2.4 to the candidate tarball. It keeps each older storage implementation
-running throughout the replacement, then checks all 63 supported receivers while
+The same harness upgrades separate installations of published versions 0.2.3, 0.2.4,
+and 0.2.5 to the candidate tarball. It keeps each older storage implementation
+running throughout the replacement, then checks all 64 supported receivers while
old and new processes read and write one library. Favorites, recent stations,
track/search history, alarms, and the previously selected receiver must survive.
Each `upgrade-.json` record is bound to the tested artifact, source, and
@@ -200,7 +200,7 @@ The reusable formula template lives in `packaging/homebrew/radiocli.rb.template`
After each npm publish, fetch the npm tarball URL and SHA:
```bash
-VERSION=0.2.5
+VERSION=0.2.6
TARBALL="$(npm view @ciphore/radiocli@$VERSION dist.tarball)"
curl -L "$TARBALL" -o "/tmp/radiocli-$VERSION.tgz"
shasum -a 256 "/tmp/radiocli-$VERSION.tgz"
diff --git a/apps/docs/lib/receiver-canvas.ts b/apps/docs/lib/receiver-canvas.ts
index 3c0e645..a5ff977 100644
--- a/apps/docs/lib/receiver-canvas.ts
+++ b/apps/docs/lib/receiver-canvas.ts
@@ -9,6 +9,10 @@ const cellHeight = 20;
const playback = {state: 'playing', ready: true} as PlaybackState;
let surface: HTMLCanvasElement | undefined;
const brailleBits = [[1, 8], [2, 16], [4, 32], [64, 128]];
+const triangles: Record = {
+ '◢': [[1, 0], [1, 1], [0, 1]], '◣': [[0, 0], [0, 1], [1, 1]],
+ '◤': [[0, 0], [1, 0], [0, 1]], '◥': [[0, 0], [1, 0], [1, 1]],
+};
const quadrants: Record = {
'▘': 1, '▝': 2, '▖': 4, '▗': 8, '▌': 5, '▐': 10, '▀': 3, '▄': 12,
'▚': 9, '▞': 6, '▛': 7, '▜': 11, '▙': 13, '▟': 14, '█': 15,
@@ -51,6 +55,17 @@ export function drawReceiver(canvas: HTMLCanvasElement, style: ReceiverStyle, pu
}
}
context.fill();
+ } else if (style === 'sumi-ocean' && glyph === '●') {
+ context.beginPath();
+ context.arc(left + cellWidth / 2, top + cellHeight / 2, cellWidth / 2, 0, Math.PI * 2);
+ context.fill();
+ } else if (glyph in triangles) {
+ context.beginPath();
+ triangles[glyph].forEach(([dx, dy], index) => {
+ if (index === 0) context.moveTo(left + dx * cellWidth, top + dy * cellHeight);
+ else context.lineTo(left + dx * cellWidth, top + dy * cellHeight);
+ });
+ context.fill();
} else if (glyph in quadrants) {
const mask = quadrants[glyph];
for (let dy = 0; dy < 2; dy++) for (let dx = 0; dx < 2; dx++) {
diff --git a/apps/docs/lib/seo.ts b/apps/docs/lib/seo.ts
index 671d33a..931fc15 100644
--- a/apps/docs/lib/seo.ts
+++ b/apps/docs/lib/seo.ts
@@ -94,7 +94,7 @@ export function getHomeJsonLd() {
codeRepository: repositoryUrl,
downloadUrl: 'https://www.npmjs.com/package/@ciphore/radiocli',
installUrl: absoluteUrl('/docs/getting-started/install'),
- softwareVersion: '0.2.5',
+ softwareVersion: '0.2.6',
license: licenseUrl,
isAccessibleForFree: true,
author: {
diff --git a/apps/docs/package-lock.json b/apps/docs/package-lock.json
index 2f43f91..cbe05b4 100644
--- a/apps/docs/package-lock.json
+++ b/apps/docs/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "radiocli-docs",
- "version": "0.2.5",
+ "version": "0.2.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "radiocli-docs",
- "version": "0.2.5",
+ "version": "0.2.6",
"hasInstallScript": true,
"dependencies": {
"fumadocs-core": "16.9.3",
@@ -6125,9 +6125,9 @@
}
},
"node_modules/zod": {
- "version": "4.4.3",
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
- "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
+ "version": "4.6.7",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
+ "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
diff --git a/apps/docs/package.json b/apps/docs/package.json
index 3e75642..9bd7414 100644
--- a/apps/docs/package.json
+++ b/apps/docs/package.json
@@ -1,6 +1,6 @@
{
"name": "radiocli-docs",
- "version": "0.2.5",
+ "version": "0.2.6",
"private": true,
"description": "Public website and documentation for RadioCLI.",
"type": "module",
diff --git a/apps/docs/public/demo/radiocli-alarm-editor.webm b/apps/docs/public/demo/radiocli-alarm-editor.webm
new file mode 100644
index 0000000..f1d6194
Binary files /dev/null and b/apps/docs/public/demo/radiocli-alarm-editor.webm differ
diff --git a/apps/docs/public/demo/radiocli-explore-map.webm b/apps/docs/public/demo/radiocli-explore-map.webm
new file mode 100644
index 0000000..2c1b742
Binary files /dev/null and b/apps/docs/public/demo/radiocli-explore-map.webm differ
diff --git a/apps/docs/public/demo/radiocli-layout-micro.png b/apps/docs/public/demo/radiocli-layout-micro.png
new file mode 100644
index 0000000..dd2d4ae
Binary files /dev/null and b/apps/docs/public/demo/radiocli-layout-micro.png differ
diff --git a/apps/docs/public/demo/radiocli-library.webm b/apps/docs/public/demo/radiocli-library.webm
new file mode 100644
index 0000000..c6d21ae
Binary files /dev/null and b/apps/docs/public/demo/radiocli-library.webm differ
diff --git a/apps/docs/public/demo/radiocli-mcp-controls.png b/apps/docs/public/demo/radiocli-mcp-controls.png
new file mode 100644
index 0000000..19d8fc0
Binary files /dev/null and b/apps/docs/public/demo/radiocli-mcp-controls.png differ
diff --git a/apps/docs/public/demo/radiocli-nearby.webm b/apps/docs/public/demo/radiocli-nearby.webm
new file mode 100644
index 0000000..8880e70
Binary files /dev/null and b/apps/docs/public/demo/radiocli-nearby.webm differ
diff --git a/apps/docs/public/demo/radiocli-search.webm b/apps/docs/public/demo/radiocli-search.webm
new file mode 100644
index 0000000..2cab07c
Binary files /dev/null and b/apps/docs/public/demo/radiocli-search.webm differ
diff --git a/apps/docs/public/demo/radiocli-stats-colors.png b/apps/docs/public/demo/radiocli-stats-colors.png
new file mode 100644
index 0000000..f03b0fb
Binary files /dev/null and b/apps/docs/public/demo/radiocli-stats-colors.png differ
diff --git a/apps/docs/public/demo/radiocli-stats-colors.webm b/apps/docs/public/demo/radiocli-stats-colors.webm
new file mode 100644
index 0000000..41a571e
Binary files /dev/null and b/apps/docs/public/demo/radiocli-stats-colors.webm differ
diff --git a/apps/docs/public/demo/radiocli-stats-ruby.png b/apps/docs/public/demo/radiocli-stats-ruby.png
new file mode 100644
index 0000000..2b00f12
Binary files /dev/null and b/apps/docs/public/demo/radiocli-stats-ruby.png differ
diff --git a/docs/boat-lake.md b/docs/boat-lake.md
new file mode 100644
index 0000000..8e5e703
--- /dev/null
+++ b/docs/boat-lake.md
@@ -0,0 +1,88 @@
+# Boat Lake receiver
+
+`boat-lake` is a local adaptation of the procedural lake behind [boat.dev](https://boat.dev/).
+The original scene was extracted on October 28, 2026 from the public client bundle
+[`26-7j4wbk3v76.js`](https://boat.dev/_next/static/chunks/26-7j4wbk3v76.js).
+The landscape, lighting, water, reflections and sail polygons come from that
+scene. Provenance comments are retained in the isolated kernel and local
+reference. No website copy, branding, fonts, analytics or network code is included.
+
+## Preview locally
+
+```sh
+node scripts/build-boat-lake-preview.mjs
+python3 -m http.server 4178 --bind 127.0.0.1 --directory output/boat-lake
+```
+
+Open . Switch between **Extracted scene** and **Receiver style**.
+The reference runs the original layered drawing and character quantizer. The
+receiver runs the terminal adapter. The preview defaults to actual TUI proportions
+with 8×16 pixel cells. **Enlarge** magnifies those cells without inventing detail.
+Sizes range from 120×30 to 20×3, including the normal 120×18 receiver maximum.
+[Size checks](http://127.0.0.1:4178/sizes.html) show several sizes together, plus
+real Unicode text rendered in browser monospace for the smaller layouts.
+Terminal font metrics can differ from the canvas representation.
+
+Pause/play is available; the preview also pauses in hidden tabs and starts still
+when reduced motion is requested. Both reference and receiver use fixed daytime
+lighting (phase `0.44`) with no page fade. The builder uses installed esbuild and
+bundled local sources. It does not fetch assets. Output is ignored by Git.
+
+Select **Boat Lake** in RadioCLI's existing receiver-style picker. The docs
+receiver gallery uses the same registry and renderer. The radio default and saved
+receiver selection are unchanged.
+
+## Composition and rendering
+
+- Size the scene to the viewport rather than squeezing a fixed 160×42 artboard
+ into every receiver. Short layouts use a lower horizon, with fewer, larger boats.
+- Keep the foreground boat away from the bright sun reflection for contrast.
+- Rasterize the original sail and hull polygons directly; sampling already
+ quantized sprites a second time erased their small features.
+- Preserve eight samples per cell, with quadrant blocks, diagonal triangles,
+ quarter-height blocks and fine ordered shading. Evaluate two-color cluster
+ errors from their sums rather than repeatedly calculating every residual.
+- At 3–6 rows, use explicit terminal-grid sails, hull and pine silhouettes so they
+ remain recognizable. The smallest receivers use one boat.
+- Adapt the upstream pine minimum height so short scenes retain their tips.
+- Cache static scenery, encoded static cells and a detailed reflection field.
+ Interpolated horizontal refraction animates the cached water; larger boats bob
+ gently. This is an approximation of the original water animation, rather than
+ rerunning its full reflected scene on every frame.
+- Retain at most four viewport caches with no playback history. Preserve the
+ original blue palette, with grayscale for the mono theme, and merge adjacent
+ equal-color cells into terminal runs.
+
+The receiver needs no GPU, images, external fonts or network service. Motion uses
+RadioCLI's existing receiver clock and pause behavior.
+
+## Measurements
+
+```sh
+npx tsx scripts/boat-lake/benchmark.mts
+```
+
+The benchmark warms both renderers for 60 frames, then measures 200 frames per
+output resolution. The reference measures original field sampling and original
+character quantization on its fixed artboard. The receiver additionally includes
+boat compositing and segment creation, and uses its adaptive composition and
+cached refraction animation. This compares their steady-state costs, not identical
+per-frame algorithms. A first frame or cache miss also builds the reflected field.
+Neither measurement includes browser painting, Ink rendering or terminal I/O.
+
+Node v24.15.0 on this machine:
+
+| Viewport | Reference median | Receiver median | Receiver p95 |
+| --- | ---: | ---: | ---: |
+| 120×30 | 9.258 ms | 0.869 ms | 1.115 ms |
+| 120×18 | 5.952 ms | 0.522 ms | 0.751 ms |
+| 100×14 | 3.547 ms | 0.360 ms | 0.445 ms |
+| 80×10 | 2.041 ms | 0.225 ms | 0.318 ms |
+| 60×7 | 1.135 ms | 0.142 ms | 0.209 ms |
+| 36×4 | 0.374 ms | 0.061 ms | 0.092 ms |
+| 24×4 | 0.246 ms | 0.026 ms | 0.027 ms |
+| 20×3 | 0.148 ms | 0.016 ms | 0.017 ms |
+
+Tests cover terminal column widths, glyphs and palettes, merged segments,
+monochrome, steady scenery with animated water, detailed shading, recognizable
+compact sails/hulls/pines throughout playback, and determinism after cache eviction.
diff --git a/docs/sumi-ocean.md b/docs/sumi-ocean.md
new file mode 100644
index 0000000..a5cc129
--- /dev/null
+++ b/docs/sumi-ocean.md
@@ -0,0 +1,80 @@
+# Sumi Ocean refinement
+
+The existing `sumi-ocean` receiver takes visual cues from the moonlit harbour above
+[boat.dev's footer](https://boat.dev/): a clear moon, soft halo, quiet horizon and
+broken silver reflections. Its artwork is original typed TypeScript. It uses no
+harbour code, boats, jetty, barrels, images, external fonts or network services.
+
+The style ID, saved selection and indigo palette remain the same, including a
+monochrome version. The sky stays steady. Reflections shimmer and refract through
+RadioCLI's existing receiver clock and pause behavior.
+
+## Local comparison
+
+```sh
+node scripts/build-boat-lake-preview.mjs
+python3 -m http.server 4178 --bind 127.0.0.1 --directory output/boat-lake
+```
+
+Open . The **Previous receiver** button shows the
+four-sample renderer immediately before this refinement. Compare sizes from
+120×30 down to 20×3, in indigo or monochrome. The normal receiver maximum is 14
+rows; 30 rows are an enlarged study. The preview now defaults to actual TUI
+proportions with 8×16 pixel cells. **Enlarge** magnifies those same cells.
+
+[Size checks](http://127.0.0.1:4178/ocean-sizes.html) show several sizes together,
+including real Unicode text in browser monospace. Terminal font metrics can
+differ from the canvas representation. The preview pauses in hidden tabs and
+starts still when reduced motion is requested. An optional local footer screenshot
+appears when `output/boat-lake/footer-reference.png` is present. No asset is fetched
+from the original website.
+
+## Small receivers and detail
+
+- Use eight samples per cell on a 2×4 square-subpixel grid, matching the terminal's
+ 1:2 cell aspect. The sky uses Boat Lake's fine cell encoder and ordered shading.
+- Keep the previous receiver's broad quadrant marks for water. Average the fine
+ samples into quadrants instead of fitting diagonal shapes to the reflection.
+- Adapt the horizon, moon size and number of wave bands to the viewport. Short
+ receivers avoid undersampling a fixed thirty-band water field.
+- Below nine rows, draw a round native circle glyph so the moon stays legible.
+- Restore the previous receiver's wide, ripple-broken reflection. Its center
+ meanders gently, its path widens toward the foreground, and travelling water
+ texture determines which fragments catch the moonlight.
+
+## Caching and animation
+
+Cache the sky field, encoded sky rows and depth coordinates by viewport. Animate
+water across its full width with the previous receiver's travelling noise and
+perspective-dependent speed. Reflection and water share the same moving texture,
+so their motion stays connected. Do not freeze the sea outside the reflection
+band: that optimization removed the lateral motion that made the previous scene
+work.
+
+The cache retains at most four viewports and no playback history. Water fields
+and returned segments are newly created, so consumer mutations cannot damage
+cached data. The renderer adds no dependency, timer or GPU requirement.
+
+## Local measurements
+
+```sh
+npx tsx scripts/boat-lake/benchmark-ocean.mts
+```
+
+The immediately preceding renderer is frozen in
+`scripts/boat-lake/sumi-quadrants.mjs`. Each renderer receives 60 warm-up frames
+and 200 measured frames at matching dimensions. Measurements report scene setup,
+median and p95 CPU time, and average color-run counts. They exclude browser
+painting, Ink rendering and terminal I/O.
+
+Node v24.15.0 on this machine measured a 0.114 ms median and 0.145 ms p95
+for the current 100×14 renderer, versus 0.068 ms and 0.100 ms for the previous
+four-sample version. At 36×4, the current median was 0.015 ms versus 0.007 ms.
+Restoring full-surface motion does more work than animating only a narrow strip;
+these local CPU measurements exclude painting and terminal I/O.
+
+Tests cover terminal column widths, glyphs, continuous backgrounds, merged runs,
+a visible moon and reflected light throughout long playback at small sizes,
+water texture moving on both sides of the reflection, steady sky, monochrome,
+cache eviction, and mutation isolation. Water uses broad quadrant marks without
+forced bars or diagonal reflection shapes. The terminal snapshot is updated.
diff --git a/package-lock.json b/package-lock.json
index 3acc3b8..4b396c3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,17 +1,18 @@
{
"name": "@ciphore/radiocli",
- "version": "0.2.5",
+ "version": "0.2.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@ciphore/radiocli",
- "version": "0.2.5",
+ "version": "0.2.6",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
"@homebridge/dbus-native": "^0.7.9",
"@modelcontextprotocol/server": "^2.3.1",
+ "chalk": "^5.6.2",
"ink": "^7.0.5",
"jsonc-parser": "^3.3.1",
"react": "^19.2.6",
@@ -3664,9 +3665,9 @@
}
},
"node_modules/undici": {
- "version": "6.28.1",
- "resolved": "https://registry.npmjs.org/undici/-/undici-6.28.1.tgz",
- "integrity": "sha512-zWpdTVD54H48CIybL0rWQ3ukpb9d23wM7eH5RtfdmeP70cWHNjtfo7P4vZX+5CoDcO53J4Pu5uXp7lNfjc6DRA==",
+ "version": "6.29.1",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz",
+ "integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==",
"license": "MIT",
"optional": true,
"engines": {
@@ -3999,9 +4000,9 @@
"license": "MIT"
},
"node_modules/zod": {
- "version": "4.4.3",
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
- "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
+ "version": "4.6.7",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
+ "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
diff --git a/package.json b/package.json
index b897526..0a0d005 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@ciphore/radiocli",
- "version": "0.2.5",
+ "version": "0.2.6",
"description": "A terminal-first world radio receiver built with Ink, mpv, and resilient public-radio providers.",
"type": "module",
"license": "MIT",
@@ -82,6 +82,7 @@
"dependencies": {
"@homebridge/dbus-native": "^0.7.9",
"@modelcontextprotocol/server": "^2.3.1",
+ "chalk": "^5.6.2",
"ink": "^7.0.5",
"jsonc-parser": "^3.3.1",
"react": "^19.2.6",
diff --git a/scripts/boat-lake/benchmark-ocean.mts b/scripts/boat-lake/benchmark-ocean.mts
new file mode 100644
index 0000000..d8b05d6
--- /dev/null
+++ b/scripts/boat-lake/benchmark-ocean.mts
@@ -0,0 +1,29 @@
+import {performance} from 'node:perf_hooks';
+import {buildSumiOcean} from '../../src/ui/visualizers/sumi-ocean.js';
+import {buildSumiOceanQuadrants} from './sumi-quadrants.mjs';
+
+type Frame = ReturnType;
+type Builder = (pulse: number, width: number, height: number, theme: 'blue') => Frame;
+function measure(build: Builder, width: number, height: number) {
+ const coldStart = performance.now();
+ build(0, width, height, 'blue');
+ const coldMs = performance.now() - coldStart;
+ for (let frame = 0; frame < 60; frame++) build(frame, width, height, 'blue');
+ const times: number[] = [];
+ let runs = 0;
+ for (let frame = 0; frame < 200; frame++) {
+ const start = performance.now();
+ const result = build(frame + 60, width, height, 'blue');
+ times.push(performance.now() - start);
+ runs += result.reduce((sum, row) => sum + row.segments.length, 0);
+ }
+ times.sort((a, b) => a - b);
+ return {coldMs: +coldMs.toFixed(3), medianMs: +times[100]!.toFixed(3), p95Ms: +times[190]!.toFixed(3), colorRuns: Math.round(runs / 200)};
+}
+const results = [];
+for (const [width, height] of [[120, 30], [100, 14], [80, 10], [60, 7], [36, 4], [24, 4], [20, 3]] as const) {
+ const before = measure(buildSumiOceanQuadrants, width, height);
+ const after = measure(buildSumiOcean, width, height);
+ results.push({viewport: `${width}x${height}`, before, after, speedup: +(before.medianMs / after.medianMs).toFixed(2)});
+}
+console.log(JSON.stringify({runtime: process.version, results}, null, 2));
diff --git a/scripts/boat-lake/benchmark.mts b/scripts/boat-lake/benchmark.mts
new file mode 100644
index 0000000..7d084d4
--- /dev/null
+++ b/scripts/boat-lake/benchmark.mts
@@ -0,0 +1,14 @@
+import {performance} from 'node:perf_hooks';
+import {buildBoatLake} from '../../src/ui/visualizers/boat-lake.js';
+import * as lake from './reference.mjs';
+import * as draw from './reference.mjs';
+const layout={...draw.m89369_m(160,42,22),full:true,copyW:0,fade:0};
+const fleet=draw.m89369_V(layout);
+function reference(pulse,width,height){
+ const light=lake.m59908_z(layout,.44,pulse*.08),cells=new Int8Array(width*height*3);
+ const field=(x,y)=>{x*=layout.W/(width*8);y*=layout.H/(height*16);let v=lake.m59908_h(layout,light,x,y);if(v>=0)return v;if(y>=layout.hz)return lake.m59908_P(layout,light,fleet,x,y);v=lake.m59908_I(layout,light,x,y);return v>=0?v:lake.m59908_d(layout,light,x,y)};
+ for(let y=0;ya-b);return{medianMs:+times[100].toFixed(3),p95Ms:+times[190].toFixed(3)}}
+const results=[];for(const [width,height]of [[120,30],[120,18],[100,14],[80,10],[60,7],[36,4],[24,4],[20,3]]){const original=measure(reference,width,height),optimized=measure((p,w,h)=>buildBoatLake(p,w,h,'blue'),width,height);results.push({viewport:`${width}x${height}`,original,optimized,speedup:+(original.medianMs/optimized.medianMs).toFixed(2)})}console.log(JSON.stringify({runtime:process.version,results},null,2));
diff --git a/scripts/boat-lake/ocean-preview.html b/scripts/boat-lake/ocean-preview.html
new file mode 100644
index 0000000..52cb7e2
--- /dev/null
+++ b/scripts/boat-lake/ocean-preview.html
@@ -0,0 +1,23 @@
+Sumi Ocean · Local comparison
+
+
+
Current receiver · travelling ripples / broad moonlight
+The current receiver brings back the previous version’s travelling water and broad, broken moonlight. Ripples move across the whole surface, and the same texture shapes the reflection. Softer quadrant marks keep the water loose; the clearer moon, halo and native small-size composition stay. Sky rows are cached, while the water is animated across its full width. Compare all small sizes and terminal glyphs. All rendering is procedural and local.
+Footer reference
+
diff --git a/scripts/boat-lake/ocean-sizes.html b/scripts/boat-lake/ocean-sizes.html
new file mode 100644
index 0000000..ed89409
--- /dev/null
+++ b/scripts/boat-lake/ocean-sizes.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+Sumi Ocean · TUI size checks
+
+Sumi Ocean at TUI sizes
+Each scene uses its own composition and the exact receiver output. Canvas cells are 8 × 16 pixels. The text views use real Unicode glyphs in the browser’s monospace font; terminal fonts may render their edges differently. Back to the animated comparison.
+
+
+
diff --git a/scripts/boat-lake/preview.html b/scripts/boat-lake/preview.html
new file mode 100644
index 0000000..420fdca
--- /dev/null
+++ b/scripts/boat-lake/preview.html
@@ -0,0 +1,19 @@
+Boat Lake · Local extraction
+
+RadioCLI / Local study 01 Boat Lake Pine islands, bright sails, and a lake in motion.
Receiver style Large study · 120 × 30 Wide · 120 × 18 Standard · 100 × 14 Compact · 80 × 10 Small · 60 × 7 Micro · 36 × 4 Tiny · 24 × 4 Minimum · 20 × 3 Enlarge Pause
+
Boat Lake · actual TUI proportions (8 × 16 px cells)
+The extracted view runs the original procedural scene without the website. The receiver uses the original landscape, sail polygons, and water kernel. Its composition adapts to each TUI size, with larger compact sails, eight samples per cell, and fine ordered shading. The detailed reflection field is cached; gentle refraction animates the water. Enlarge inspects the same terminal cells; it does not add detail. Compare all small sizes, including terminal glyphs. All scripts and drawing data are local. Motion pauses in a hidden tab and respects reduced motion.
+
diff --git a/scripts/boat-lake/reference.mjs b/scripts/boat-lake/reference.mjs
new file mode 100644
index 0000000..ceb4984
--- /dev/null
+++ b/scripts/boat-lake/reference.mjs
@@ -0,0 +1,770 @@
+// Original scene extracted from https://boat.dev/ on 2026-10-28.
+// Preserved locally for visual comparison and performance measurements. See docs/boat-lake.md.
+
+// output/boat-lake/scene-0.js
+var e = ["#FEFEFE", "#F8F9FC", "#F1F3F9", "#E9EBF6", "#E0E3F2", "#D1D6EC", "#C2C9E6", "#AAB4DD", "#929FD3", "#7F8ECC", "#6B7CC4", "#5A6DBE", "#495EB7", "#384FB0", "#263FA9", "#223895", "#1E3180", "#1A2A6C", "#162358", "#131D46", "#0F1634"], r = e.map((t2) => (-16777216 | parseInt(t2.slice(5, 7), 16) << 16 | parseInt(t2.slice(3, 5), 16) << 8 | parseInt(t2.slice(1, 3), 16)) >>> 0), m97596_h = 12, m97596_D = 6, m97596_z = class {
+ w;
+ h;
+ ch;
+ fg;
+ bg;
+ constructor(t2, e2, r22 = -1) {
+ this.w = t2, this.h = e2, this.ch = Array.from({ length: e2 }, () => Array(t2).fill(" ")), this.fg = Array.from({ length: e2 }, () => Array(t2).fill(-1)), this.bg = Array.from({ length: e2 }, () => Array(t2).fill(r22));
+ }
+ in(t2, e2) {
+ return t2 >= 0 && e2 >= 0 && t2 < this.w && e2 < this.h;
+ }
+ set(t2, e2, r22, n2, l3) {
+ this.in(t2, e2) && (this.ch[e2][t2] = r22, this.fg[e2][t2] = n2, l3 !== void 0 && (this.bg[e2][t2] = l3));
+ }
+ paint(t2, e2, r22) {
+ this.in(t2, e2) && (this.bg[e2][t2] = r22);
+ }
+ get(t2, e2) {
+ return this.in(t2, e2) ? this.ch[e2][t2] : "";
+ }
+ put(t2, e2, r22, n2, l3) {
+ [...r22].forEach((r3, a3) => {
+ r3 !== " " ? this.set(t2 + a3, e2, r3, n2, l3) : l3 !== void 0 && this.paint(t2 + a3, e2, l3);
+ });
+ }
+ blit(t2, e2, r22) {
+ for (let n2 = 0; n2 < t2.h; n2++) for (let l3 = 0; l3 < t2.w; l3++) t2.ch[n2][l3] === " " && t2.bg[n2][l3] < 0 || this.set(e2 + l3, r22 + n2, t2.ch[n2][l3], t2.fg[n2][l3], t2.bg[n2][l3] >= 0 ? t2.bg[n2][l3] : void 0);
+ }
+};
+var m97596_P = (t2 = window.devicePixelRatio || 1) => t2 > 2 ? t2 / Math.ceil(t2 / 2) : t2, m97596_q = function() {
+ return { w: 6, h: 12 };
+}, m97596_Q = function(t2, e2, r22, n2, l3, a3, o3 = 0, h3 = 1) {
+ if (e2 = Math.max(0, e2), r22 = Math.max(0, r22), n2 = Math.min(t2.w, n2), l3 = Math.min(t2.h, l3), !(e2 >= n2) && !(r22 >= l3)) {
+ e2 < t2.x0 && (t2.x0 = e2), r22 < t2.y0 && (t2.y0 = r22), n2 > t2.x1 && (t2.x1 = n2), l3 > t2.y1 && (t2.y1 = l3);
+ for (let i3 = r22; i3 < l3; i3++) {
+ let r3 = i3 * t2.w;
+ if (!o3) {
+ t2.u.fill(a3, r3 + e2, r3 + n2);
+ continue;
+ }
+ let l22 = 1 & Math.floor(i3 / h3), f3 = [o3 === 16 ? !l22 : o3 !== 17 || !l22, o3 !== 16 && (o3 === 17 ? !!l22 : !l22)], u3 = 1 & Math.floor(e2 / h3);
+ for (let l32 = e2, o22 = (Math.floor(e2 / h3) + 1) * h3; l32 < n2; l32 = o22, o22 += h3, u3 ^= 1) f3[u3] && t2.u.fill(a3, r3 + l32, r3 + Math.min(o22, n2));
+ }
+ }
+}, m97596_K = function(t2, e2) {
+ if (e2.x0 >= e2.x1 || e2.y0 >= e2.y1) return;
+ let r22 = e2.y1 - e2.y0, n2 = new ImageData(new Uint8ClampedArray(e2.img.data.buffer, e2.y0 * e2.w * 4, r22 * e2.w * 4), e2.w, r22);
+ t2.putImageData(n2, 0, e2.y0, e2.x0, 0, e2.x1 - e2.x0, r22), e2.x0 = e2.w, e2.y0 = e2.h, e2.x1 = 0, e2.y1 = 0;
+}, m97596_m = function(t2, e2, r22, n2, l3, a3) {
+ e2 = Math.max(0, e2), r22 = Math.max(0, r22), n2 = Math.min(t2.w, n2), l3 = Math.min(t2.h, l3);
+ for (let o3 = r22; o3 < l3; o3++) {
+ let r3 = o3 * t2.w, l22 = 1 & Math.floor(o3 / a3), h3 = 1 & Math.floor(e2 / a3);
+ for (let o22 = e2, i3 = (Math.floor(e2 / a3) + 1) * a3; o22 < n2; o22 = i3, i3 += a3, h3 ^= 1) h3 === l22 && t2.u.fill(0, r3 + o22, r3 + Math.min(i3, n2));
+ }
+}, m97596_B = function(t2, e2) {
+ let r22 = new ImageData(t2, e2);
+ return { img: r22, u: new Uint32Array(r22.data.buffer), w: t2, h: e2, x0: t2, y0: e2, x1: 0, y1: 0 };
+};
+
+// output/boat-lake/scene-2.js
+var r2 = e.map((t2) => [parseInt(t2.slice(1, 3), 16), parseInt(t2.slice(3, 5), 16), parseInt(t2.slice(5, 7), 16)]), n = (t2) => (t2 /= 255) <= 0.04045 ? t2 / 12.92 : ((t2 + 0.055) / 1.055) ** 2.4, l = (t2) => 255 * (t2 <= 31308e-7 ? 12.92 * t2 : 1.055 * t2 ** (1 / 2.4) - 0.055), a = r2.map((t2) => t2.map(n)), o = [];
+r2.forEach((t2, e2) => o.push([t2, " ", -1, e2]));
+var h = [[0.25, "\u2591"], [0.5, "\u2592"], [0.75, "\u2593"]];
+for (let t2 = 0; t2 < r2.length; t2++) for (let e2 = 0; e2 < r2.length; e2++) if (!(t2 === e2 || Math.abs(t2 - e2) > 1)) for (let [r22, n2] of h) {
+ let h22 = a[t2].map((t3, n3) => l(t3 * (1 - r22) + a[e2][n3] * r22));
+ o.push([h22, n2, e2, t2]);
+}
+var i = (t2, e2) => (t2[0] - e2[0]) ** 2 + (t2[1] - e2[1]) ** 2 + (t2[2] - e2[2]) ** 2;
+function f(t2) {
+ let e2 = 0, n2 = 1 / 0;
+ for (let l22 = 0; l22 < r2.length; l22++) {
+ let a22 = i(t2, r2[l22]);
+ a22 < n2 && (n2 = a22, e2 = l22);
+ }
+ return e2;
+}
+var u = /* @__PURE__ */ new Map(), M = [0, 0, 0], s = [0, 0, 0], c = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5], d = ["", "\u2598", "\u259D", "\u2580", "\u2596", "\u258C", "\u259E", "\u259B", "\u2597", "\u259A", "\u2590", "\u259C", "\u2584", "\u2599", "\u259F"];
+function p(t2, e2, n2, l22 = 0.8) {
+ let a22, h22, m22, x22, w22, g22, y22 = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]];
+ for (let r22 = 0; r22 < 4; r22++) for (let l3 = 0; l3 < 2; l3++) {
+ let a3 = t2(8 * e2 + 4 * (l3 + 0.5), 16 * n2 + 4 * (r22 + 0.5)), o22 = (r22 < 2 ? 0 : 2) + (l3 < 1 ? 0 : 1);
+ y22[o22][0] += a3[0], y22[o22][1] += a3[1], y22[o22][2] += a3[2];
+ }
+ let b22 = (L(0.93 * e2 + 0.5, 1.71 * n2 + 0.5, 77) - 0.5) * 0 + (c[(3 & n2) * 4 + (3 & e2)] / 16 - 0.47) * 0;
+ y22.forEach((t3) => {
+ t3[0] = t3[0] / 2 + b22, t3[1] = t3[1] / 2 + b22, t3[2] = t3[2] / 2 + b22;
+ });
+ let z22 = (a22 = [0, 0, 0], y22.forEach((t3) => {
+ a22[0] += t3[0], a22[1] += t3[1], a22[2] += t3[2];
+ }), a22.map((t3) => t3 / y22.length)), [H22, W22, A22] = (h22 = Math.round(z22[0] / 2), m22 = Math.round(z22[1] / 2), w22 = h22 << 16 | m22 << 8 | (x22 = Math.round(z22[2] / 2)), (g22 = u.get(w22)) || (g22 = (function(t3) {
+ let e3 = o[0], r22 = o[0], n3 = 1 / 0, l3 = 1 / 0;
+ for (let a4 of o) {
+ let o22 = i(t3, a4[0]);
+ o22 < n3 ? (r22 = e3, l3 = n3, e3 = a4, n3 = o22) : o22 < l3 && (r22 = a4, l3 = o22);
+ }
+ let a3 = Math.sqrt(n3), h3 = Math.sqrt(l3);
+ return [e3, r22, a3 + h3 > 0 ? a3 / (a3 + h3) : 0];
+ })([2 * h22, 2 * m22, 2 * x22]), u.set(w22, g22)), g22), R22 = H22[3] <= 1 && W22[3] <= 1 && H22[2] <= 1 && W22[2] <= 1 ? o[1 >= f(z22) ? f(z22) : H22[3]] : (A22 > 0.34 ? e2 + n2 & 1 : A22 > 0.17 && (e2 + 2 * n2 & 3) == 0) ? W22 : H22, E22 = [R22[1], R22[2], R22[3]], F22 = y22.reduce((t3, e3) => t3 + i(e3, R22[0]), 0) * l22;
+ for (let t3 = 1; t3 < 15; t3++) {
+ let e3 = 0, n3 = 0, l3 = 0, a3 = 0, o22 = 0, h3 = 0, u22 = 0, c22 = 0;
+ for (let r22 = 0; r22 < 4; r22++) {
+ let i22 = y22[r22];
+ t3 & 1 << r22 ? (e3 += i22[0], n3 += i22[1], l3 += i22[2], a3++) : (o22 += i22[0], h3 += i22[1], u22 += i22[2], c22++);
+ }
+ M[0] = e3 / a3, M[1] = n3 / a3, M[2] = l3 / a3, s[0] = o22 / c22, s[1] = h3 / c22, s[2] = u22 / c22;
+ let p22 = f(M), m3 = f(s);
+ if (p22 === m3) continue;
+ let x3 = 0;
+ for (let e4 = 0; e4 < 4; e4++) x3 += i(y22[e4], t3 & 1 << e4 ? r2[p22] : r2[m3]);
+ x3 < F22 && (F22 = x3, E22 = [d[t3], p22, m3]);
+ }
+ return E22;
+}
+var m = (t2) => r2[t2], x = (t2, e2, r22) => [t2[0] + (e2[0] - t2[0]) * r22, t2[1] + (e2[1] - t2[1]) * r22, t2[2] + (e2[2] - t2[2]) * r22], w = (t2, e2 = 0, r22 = 1) => Math.max(e2, Math.min(r22, t2)), g = (t2, e2, r22) => {
+ let n2 = w((r22 - t2) / (e2 - t2));
+ return n2 * n2 * (3 - 2 * n2);
+};
+function y(t2, e2) {
+ if (e2 <= t2[0][0]) return t2[0][1];
+ for (let r22 = 1; r22 < t2.length; r22++) if (e2 <= t2[r22][0]) return x(t2[r22 - 1][1], t2[r22][1], (e2 - t2[r22 - 1][0]) / (t2[r22][0] - t2[r22 - 1][0]));
+ return t2[t2.length - 1][1];
+}
+function b(t2, e2, r22) {
+ let n2 = 374761393 * t2 + 668265263 * e2 + 2147483647 * r22 | 0;
+ return (((n2 = Math.imul(n2 ^ n2 >>> 13, 1274126177)) ^ n2 >>> 16) >>> 0) / 4294967295;
+}
+function L(t2, e2, r22 = 0) {
+ let n2 = Math.floor(t2), l22 = Math.floor(e2), a22 = t2 - n2, o22 = e2 - l22, h22 = a22 * a22 * (3 - 2 * a22), i22 = o22 * o22 * (3 - 2 * o22), f22 = b(n2, l22, r22), u22 = b(n2 + 1, l22, r22), M22 = b(n2, l22 + 1, r22);
+ return f22 + (u22 - f22) * h22 + (M22 - f22) * i22 + (f22 - u22 - M22 + b(n2 + 1, l22 + 1, r22)) * h22 * i22;
+}
+var z = (t2, e2, r22 = 0) => 0.55 * L(t2, e2, r22) + 0.3 * L(2.1 * t2, 2.1 * e2, r22 + 1) + 0.15 * L(4.3 * t2, 4.3 * e2, r22 + 2);
+var m87928_x = function(t2, r22, n2, l22 = new m97596_z(r22, n2), a22, o22 = 0, h22 = r22) {
+ for (let e2 of a22 ?? Array.from({ length: n2 }, (t3, e3) => e3)) for (let n3 = Math.max(0, o22); n3 < Math.min(r22, h22); n3++) {
+ let [r3, a3, o3] = p(t2, n3, e2);
+ l22.ch[e2][n3] = r3, l22.fg[e2][n3] = a3, l22.bg[e2][n3] = o3;
+ }
+ return l22;
+};
+var H = [[43, 338], [240, 0], [322, 240], [244, 338]], W = [[282, 338], [444, 126], [455, 132], [498, 338]], A = [[0, 361], [498, 361], [498, 412], [465, 412], [465, 462], [84, 462], [8, 412], [0, 404]];
+function R(t2, e2, r22) {
+ let n2 = !1;
+ for (let l22 = 0, a22 = t2.length - 1; l22 < t2.length; a22 = l22++) {
+ let [o22, h22] = t2[l22], [i22, f22] = t2[a22];
+ h22 > r22 != f22 > r22 && e2 < (i22 - o22) * (r22 - h22) / (f22 - h22) + o22 && (n2 = !n2);
+ }
+ return n2;
+}
+function E(t2, e2, r22) {
+ let n2 = t2.h / 462, l22 = (e2 - t2.x) / n2 + 249, a22 = (r22 - t2.y) / n2 + 462;
+ return l22 < 0 || l22 > 498 || a22 < 0 || a22 > 462 ? 0 : R(A, l22, a22) ? 3 : R(H, l22, a22) ? 1 : 2 * !!R(W, l22, a22);
+}
+var F = [[0, 0, 0], m(0), m(5), m(3)];
+function k(t2, e2, r22) {
+ let n2 = 8 * t2, l22 = 16 * e2, a22 = r22 != null ? l22 - 16 * r22 : Math.round(0.42 * l22);
+ return { W: n2, H: l22, hz: a22, mx: Math.round(n2 - Math.max(0.2 * n2, Math.min(340, 0.26 * n2))), my: Math.round(a22 * (a22 < 200 ? 0.6 : 0.36)) };
+}
+var Q = /* @__PURE__ */ new Map();
+function v(t2) {
+ let e2 = 2 * t2 - 3, r22 = Math.round(0.7 * e2), n2 = e2 + 3 + r22, l22 = n2 + 3, a22 = [];
+ for (let t3 = 0; t3 < e2; t3++) {
+ let o22 = Array(l22).fill("."), h22 = Math.max(0, Math.round((e2 - 1) * ((t3 + 1) / e2) ** 0.78));
+ for (let t4 = e2 - h22; t4 <= e2; t4++) o22[t4] = "L";
+ let i22 = t3 - (e2 - r22);
+ if (i22 >= 0) for (let t4 = n2 - i22; t4 <= n2; t4++) o22[t4] = "R";
+ a22.push(o22.join(""));
+ }
+ return a22.push("H".repeat(l22), ".." + "H".repeat(l22 - 4) + "..", ".".repeat(l22)), a22;
+}
+var I = ["", "\u2598", "\u259D", "\u2580", "\u2596", "\u258C", "\u259E", "\u259B", "\u2597", "\u259A", "\u2590", "\u259C", "\u2584", "\u2599", "\u259F", "\u2588"];
+function C(t2, r22) {
+ let n2 = Math.ceil(Math.max(...t2.map((t3) => t3.length)) / 2), l22 = Math.ceil(t2.length / 2), a22 = new m97596_z(n2, l22);
+ for (let e2 = 0; e2 < l22; e2++) for (let l3 = 0; l3 < n2; l3++) {
+ let n3 = [t2[2 * e2]?.[2 * l3], t2[2 * e2]?.[2 * l3 + 1], t2[2 * e2 + 1]?.[2 * l3], t2[2 * e2 + 1]?.[2 * l3 + 1]].map((t3) => t3 && t3 in r22 ? r22[t3] : -1), o22 = /* @__PURE__ */ new Map();
+ if (n3.forEach((t3) => {
+ t3 >= 0 && o22.set(t3, (o22.get(t3) ?? 0) + 1);
+ }), !o22.size) continue;
+ let [h22, i22] = [...o22.entries()].sort((t3, e3) => e3[1] - t3[1]).map((t3) => t3[0]), f22 = n3.reduce((t3, e3, r3) => t3 | (e3 === h22 || e3 >= 0 && e3 !== i22 ? 1 << r3 : 0), 0);
+ a22.set(l3, e2, I[f22], h22, i22 ?? void 0);
+ }
+ return a22;
+}
+var D = { 2: ["...L....", "..LL.R..", ".HHHHHH.", "........"], 3: [".....L....", "....LL....", "...LLL.R..", "..LLLL.RR.", ".HHHHHHHHH", ".........."], 4: ["......L.....", ".....LL.....", "....LLL.R...", "...LLLL.RR..", "..LLLLL.RRR.", "HHHHHHHHHHHH", ".HHHHHHHHHH.", "............"] }, B = { day: { L: [12, 13, 14], R: [10, 11], H: 16 }, night: { L: [6, 8, 10], R: [6, 7], H: 18 }, bay: { L: [4, 6, 8], R: [5, 6], H: 13 }, haze: { L: [0, 1, 2], R: [1, 2], H: 7 }, dim: { L: [9, 10, 11], R: [7, 8], H: 13 } };
+function U(t2, e2 = "night", r22 = 0) {
+ let n2 = B[e2];
+ return P(t2, n2.L, n2.R, n2.H, r22);
+}
+function P(t2, e2, r22, n2, l22 = 0) {
+ let a22 = D[t2] ?? v(t2), o22 = a22.filter((t3) => /[LR]/.test(t3)).length, h22 = 0, i22 = a22.map((t3) => {
+ if (!/[LR]/.test(t3)) return t3;
+ let e3 = h22++ / Math.max(1, o22);
+ return t3.replace(/L/g, "abc"[Math.min(2, Math.floor(3 * e3))]).replace(/R/g, "de"[Math.min(1, Math.floor(2 * e3))]);
+ }), f22 = (t3) => Math.max(0, Math.min(20, t3 + l22));
+ return C(i22, { a: f22(e2[0]), b: f22(e2[1]), c: f22(e2[2]), d: f22(r22[0]), e: f22(r22[1]), H: f22(n2) });
+}
+var $ = /* @__PURE__ */ new Map();
+function j(t2, e2, r22, n2, l22 = 0, a22 = []) {
+ let o22 = 8 * t2, h22 = 16 * e2, i22 = h22 - 96, f22 = o22 > 1300 ? [[0, m(14)], [0.35, m(17)], [1, m(15)]] : [[0, m(16)], [0.5, m(17)], [1, m(15)]], u22 = Math.round(0.82 * o22), M22 = Math.round(i22 > 400 ? i22 - 110 : 0.5 * i22), s22 = (t3, e3, r3 = !1) => {
+ let n3 = y(f22, e3 / i22), l3 = Math.hypot((t3 - u22) / o22 * 2, (e3 - M22) / (1.6 * i22));
+ o22 > 1300 && (n3 = x(n3, m(9), 0.35 * Math.exp(-(l3 * l3) / 0.012)));
+ let a3 = Math.floor(t3 / 8), h3 = Math.floor(e3 / 16);
+ o22 > 1e3 && t3 > 0.62 * o22 && e3 > 0.3 * i22 && e3 < 0.75 * i22 && l3 > 0.2 && t3 % 8 < 4 && e3 % 16 < 8 && (a3 + h3) % 3 == 0 && L(a3, h3, 79) > 0.982 && (n3 = x(n3, m(5), 0.6));
+ let s3 = Math.hypot(t3 - u22, e3 - M22), c22 = o22 > 1e3 ? 22 : 15;
+ return !r3 && s3 < c22 ? n3 = x(m(0), m(4), g(0.45 * c22, c22, s3)) : !r3 && s3 < c22 + 8 && (n3 = x(n3, m(6), 0.6 * (1 - g(c22, c22 + 8, s3)))), e3 > i22 - 4 - 12 * z(t3 / 200, 0.3, 13) && (n3 = m(17)), n3;
+ };
+ return (t3, e3) => {
+ let f3 = 0;
+ for (let r3 of a22) {
+ let n3 = (function(t4, e4, r4) {
+ let n4 = (r4 - (t4.y - t4.h)) / t4.h;
+ if (n4 < 0 || n4 >= 1) return null;
+ let l3 = t4.w / 2 * (1 - 0.16 * (2 * n4 - 1) ** 2), a3 = (e4 - t4.cx) / l3;
+ if (Math.abs(a3) > 1) return null;
+ let o3 = a3 < -0.35 ? 0 : a3 < 0.4 ? 1 : 2, h3 = m([9, 12, 15][o3]);
+ return 0.06 > Math.abs(a3) && (h3 = m([11, 14, 17][o3])), (n4 > 0.16 && n4 < 0.26 || n4 > 0.74 && n4 < 0.84) && (h3 = m([15, 17, 19][o3])), n4 < 0.08 && (h3 = m([6, 9, 12][o3])), h3;
+ })(r3, t3, e3);
+ if (n3) return n3;
+ }
+ if (t3 >= n2[0] && t3 < n2[1]) {
+ if (e3 >= i22 - 2 && e3 < i22 + 4) return e3 < i22 ? m(8) : m(12);
+ if (e3 >= i22 + 4 && e3 < i22 + 44 && (t3 - n2[0]) % 48 < 8) return x(m(19), m(16), g(i22 + 20, i22 + 44, e3));
+ }
+ if (e3 < i22) return s22(t3, e3);
+ let M3 = (e3 - i22) / (h22 - i22), c22 = Math.sin(1.1 * e3 + 1.7 * l22 + 3 * L(t3 / 30, e3 / 5, 4)) * (1 + 4 * M3);
+ (f3 = E(r22, t3 + c22, 2 * r22.y - e3)) && -0.3 > Math.sin(0.55 * e3 + 3 * L(t3 / 40, e3 / 8, 5)) && (f3 = 0);
+ let d22 = f3 ? x(F[f3], m(16), 0.68) : s22(t3 + c22, 2 * i22 - e3, !0);
+ d22 = x(d22, m(17), 0.35 + 0.3 * M3);
+ let p22 = Math.exp(-(((t3 - u22) / (0.06 * o22)) ** 2));
+ d22 = K(d22, t3, e3, M3, 9, x(m(11), m(4), p22), m(19), 0.38, l22);
+ let w22 = Math.exp(-(((t3 - u22) / (32 + 90 * M3)) ** 2)) * g(0.55, 0.7, L(t3 / 48, e3 / 6 + 0.6 * l22, 9));
+ return o22 > 1e3 && (d22 = x(d22, m(7), 0.6 * w22)), x(d22, m(14), g(h22 - 48, h22, e3));
+ };
+}
+function K(t2, e2, r22, n2, l22, a22, o22, h22 = 0.4, i22 = 0, f22 = 0) {
+ let u22 = (function(t3, e3, r3, n3, l3 = 0, a3 = 0) {
+ let o3 = Math.floor(e3 / 8), h3 = 18 + 56 * r3, i3 = 0.8 - 0.04 * r3 + a3, f3 = (e4) => L((t3 + 5 * l3 * (1 + r3)) / h3, 0.5, 131 * n3 + 17 * e4), u3 = f3(o3), M22 = f3(o3 - 1);
+ return u3 > i3 && M22 <= i3 ? 1 : M22 > i3 && f3(o3 - 2) <= i3 ? -1 : 0;
+ })(e2, r22, n2, l22, i22, f22);
+ return u22 > 0 ? x(t2, a22, 0.8 * h22) : u22 < 0 ? x(t2, o22, 0.45 * h22) : t2;
+}
+var O = { x: 13, deck: 13, w: 38 }, T = { harbour: (t2, e2, r22, n2, l22, a22) => j(t2, e2, r22, n2, l22, a22), wall: (t2, e2) => {
+ let r22;
+ return (function(t3, e3, r3 = 0) {
+ let { W: n2, H: l22, hz: a22, mx: o22, my: h22 } = t3, i22 = (function(t4) {
+ let e4 = [], r4 = Math.max(2, Math.round(t4.W / 420));
+ for (let n4 = 0; n4 < r4; n4++) {
+ let r5 = 10 + n4 * (0.03 * t4.W) + 10 * L(n4, 1, 7), l3 = Math.min(0.36 * t4.hz, 120) * (0.75 + 0.25 * L(n4, 2, 7)) * (1 - 0.15 * n4);
+ e4.push({ x: r5, top: t4.hz + 10 - l3, base: t4.hz + 12, w: 9 });
+ }
+ let n3 = Math.max(3, Math.round(t4.W / 300));
+ for (let r5 = 0; r5 < n3; r5++) {
+ let n4 = t4.W - 12 - r5 * (0.032 * t4.W) - 8 * L(r5, 3, 7), l3 = Math.min(t4.hz, 300) * (0.5 + 0.22 * L(r5, 4, 7)) * (1 - 0.13 * r5) * (t4.W < 700 ? 0.4 : 1);
+ e4.push({ x: n4, top: t4.hz + 10 - l3, base: t4.hz + 12, w: 11 });
+ }
+ return e4;
+ })(t3), f22 = [[0, m(14)], [0.16, m(14)], [0.58, m(13)], [0.88, m(11)], [1, m(9)]], u22 = (t4) => a22 - 6 - (z(t4 / 340, 0.5, 5) - 0.45) * 110, M22 = (t4, e4, r4) => {
+ let l3 = Math.hypot((t4 - o22) / n2 * 2, (e4 - h22) / (1.6 * a22)), M3 = y(f22, e4 / a22), s3 = g(0.04 * a22, 0.32 * a22, e4 + (L(t4 / 60, 0.5, 13) - 0.5) * a22 * 0.16);
+ M3 = x(M3, m(5), 0.55 * Math.exp(-(l3 * l3) / 0.05) * s3);
+ let c3 = g(0.58, 0.78, z(t4 / 170, e4 / 16, 3)) * g(a22, 0.3 * a22, e4) * g(0.3, 0.6, t4 / n2) * s3;
+ M3 = x(M3, x(m(10), m(6), Math.exp(-(l3 * l3) / 0.08)), c3 * (n2 < 700 ? 0.15 : 0.5));
+ let d3 = Math.floor(t4 / 8), p3 = Math.floor(e4 / 16);
+ n2 > 1200 && t4 > 0.64 * n2 && e4 > 0.1 * a22 && e4 < 0.6 * a22 && l3 > 0.24 && t4 % 8 < 4 && e4 % 16 < 8 && (d3 + p3) % 3 == 0 && L(d3, p3, 77) > 0.982 && (M3 = x(M3, m(3), 0.7));
+ let b22 = Math.hypot(t4 - o22, (e4 - h22) * 1);
+ if (b22 < 22 ? M3 = x(m(0), m(4), g(10, 22, b22)) : b22 < 30 && (M3 = x(M3, m(6), 0.6 * (1 - g(22, 30, b22)))), e4 > u22(t4) && (M3 = x(m(15), m(12), 0.35)), ((t5, e5) => {
+ let r5 = 7 * Math.round(t5 / 7) + (L(Math.round(t5 / 7), 0, 11) - 0.5) * 3, n3 = a22 - u22(r5);
+ if (n3 < 3) return !1;
+ let l4 = (5 + 10 * L(Math.round(t5 / 7), 1, 11)) * w((n3 - 3) / 14);
+ return e5 > u22(r5) - l4 + 2.4 * Math.abs(t5 - r5);
+ })(t4, e4) && (M3 = m(17)), !r4 || e4 > a22 - 40) for (let r5 of i22) {
+ let n3 = (function(t5, e5, r6) {
+ if (r6 < t5.top || r6 > t5.base) return 0;
+ let n4 = r6 - t5.top, l4 = 0.72 + 0.28 * (n4 / (1.1 * t5.w) % 1), a3 = 0.24 * n4 * l4 + 0.6, o3 = e5 - t5.x;
+ return Math.abs(o3) > a3 ? +(1 > Math.abs(o3) && r6 > t5.base - 6) : o3 > a3 - 2.2 ? 2 : 1;
+ })(r5, t4, e4);
+ if (n3) {
+ M3 = m(n3 === 2 ? 16 : 19);
+ break;
+ }
+ }
+ return M3;
+ }, s22 = `${n2},${l22},${a22}`, c22 = Q.get(s22);
+ if (!c22) {
+ let t4 = Math.ceil(n2 / 4) + 1, e4 = Math.ceil(a22 / 4) + 1;
+ c22 = { bw: t4, bh: e4, data: new Float32Array(t4 * e4 * 3), done: new Uint8Array(e4) }, Q.size > 3 && Q.clear(), Q.set(s22, c22);
+ }
+ let d22 = c22, p22 = (t4, e4) => {
+ let r4 = Math.max(0, Math.min(d22.bw - 1, Math.floor(t4 / 4))), n3 = Math.max(0, Math.min(d22.bh - 1, Math.floor(e4 / 4)));
+ if (!d22.done[n3]) {
+ for (let t5 = 0; t5 < d22.bw; t5++) d22.data.set(M22(4 * t5 + 2, 4 * n3 + 2, !1), (n3 * d22.bw + t5) * 3);
+ d22.done[n3] = 1;
+ }
+ let l3 = (n3 * d22.bw + r4) * 3;
+ return [d22.data[l3], d22.data[l3 + 1], d22.data[l3 + 2]];
+ };
+ return (h3, f3) => {
+ if (f3 < a22) return p22(h3, f3);
+ for (let t4 of i22) if (Math.abs(h3 - t4.x) < 26 - (f3 - a22) * 1.4 && f3 < t4.base + 4) return m(19);
+ let u3 = (f3 - a22) / (l22 - a22), M3 = Math.sin(0.9 * f3 + 1.7 * r3 + 4 * L(h3 / 220, f3 / 6, 4)) * (1 + 5 * u3), s3 = [0, 0, 0], c3 = 0;
+ for (let t4 of e3) {
+ if (t4.off) continue;
+ let e4 = E(t4, h3 + M3, 2 * t4.y - f3);
+ if (e4) {
+ c3 = e4;
+ break;
+ }
+ }
+ c3 && -0.2 > Math.sin(0.55 * f3 + 3 * L(h3 / 40, f3 / 8, 5)) && (c3 = 0);
+ let d3 = x(m(14), m(17), u3);
+ s3 = c3 ? x(F[c3], m(15), 0.82) : -0.35 > Math.sin(0.55 * f3 + 3 * L(h3 / 40, f3 / 8, 6)) ? d3 : x(x(p22(h3 + M3, 2 * a22 - f3), m(15), 0.45), d3, g(0.15, 0.5, u3)), s3 = x(s3, m(17), 0.3 + 0.35 * u3);
+ let w22 = Math.exp(-(((h3 - o22) / (0.09 * n2)) ** 2));
+ s3 = K(s3, h3, f3, u3, 8, x(m(11), m(4), w22), m(19), 0.38, r3);
+ let y22 = Math.exp(-(((h3 - o22) / (4 + 34 * u3)) ** 2)) * g(0.5, 0.66, L(h3 / 16, 1.7 * Math.floor(f3 / 8) + 0.6 * r3, 9)), b22 = t3.fade ? g(l22 - (t3.fade + 6) * 16, l22 - 16 * t3.fade, f3) : 0;
+ return s3 = x(s3, m(3), y22 * (n2 < 700 ? 0.4 : 0.8) * (1 - b22)), t3.fade && (s3 = x(s3, m(0), g(l22 - (t3.fade + 1) * 16, l22 - 40, Math.min(l22 - 40, f3 + (L(h3 / 160, 3.3, 17) - 0.5) * 22)))), s3;
+ };
+ })({ ...r22 = k(t2, e2), hz: Math.round(0.55 * r22.H), my: Math.round(0.22 * r22.H) }, []);
+}, demo: (t2, e2) => (function(t3, e3 = Math.round(0.55 * t3)) {
+ return (r22, n2) => {
+ let l22 = 16 * e3 + 12, a22 = x(m(2), m(5), Math.min(1, n2 / l22)), o22 = Math.max(0, (n2 - l22) / (16 * t3 - l22)), h22 = K(x(m(11), m(17), o22), r22, n2, o22, 41, m(9), m(18), 0.3 * g(1, 0.8, o22));
+ return x(a22, h22, g(l22 - 8, l22 + 16, n2));
+ };
+})(t2, e2), sea: (t2, e2) => {
+ let r22;
+ return r22 = O.deck, (t3, n2) => {
+ let l22 = (r22 + 2) * 16 - 6, a22 = 8 * O.x, o22 = (O.x + O.w) * 8, h22 = 16 * r22, i22 = (r22 + 2) * 16 + 4;
+ if (n2 >= h22 && n2 < i22) {
+ let e3 = (n2 - h22) * 0.6;
+ if (t3 >= a22 + e3 && t3 < o22 - 0.3 * e3) return n2 < h22 + 4 ? m(8) : x(m(13), m(17), (n2 - h22) / (i22 - h22));
+ }
+ if (t3 >= o22 - 48 && t3 < o22 - 16 && n2 >= h22 - 32 && n2 < h22) return n2 < h22 - 24 ? m(16) : n2 >= h22 - 20 && n2 < h22 - 12 && (t3 - o22) % 12 < -6 ? m(3) : m(12);
+ if (n2 < l22) return x(m(3), m(6), n2 / l22);
+ let f22 = (n2 - l22) / (16 * e2 - l22);
+ return K(x(m(12), m(17), f22), t3, n2, f22, 61, m(8), m(18), 0.4);
+ };
+}, shore: (t2) => (e2, r22) => {
+ if (e2 < 136 && r22 >= 184 && r22 < 208) return m(10);
+ if (r22 < 192) return x(m(2), m(5), r22 / 192);
+ let n2 = (r22 - 192) / (16 * t2 - 192);
+ return K(x(m(11), m(17), n2), e2, r22, n2, 71, m(7), m(18), 0.4);
+}, night: (t2) => (e2, r22) => K(x(m(18), m(15), r22 / (16 * t2)), e2, r22, r22 / (16 * t2), 31, m(11), m(19), 0.45), bay: (t2, e2) => (function(t3, e3 = Math.round(0.13 * t3)) {
+ return (r22, n2) => {
+ let l22 = 16 * e3;
+ if (n2 < l22 - 16) return y([[0, m(1)], [1, m(4)]], n2 / Math.max(1, l22));
+ let a22 = l22 - 3 - 6 * z(r22 / 160, 0.2, 35), o22 = 6 * Math.round(r22 / 6), h22 = a22 - (3 + 6 * L(o22 / 6, 1, 36)) + 2.2 * Math.abs(r22 - o22);
+ if (n2 < l22 && n2 > Math.min(a22, h22)) return x(m(6), m(8), 0.5);
+ if (n2 < l22) return m(4);
+ let i22 = (n2 - l22) / Math.max(1, 16 * t3 - l22);
+ return K(y([[0, m(5)], [0.12, m(8)], [0.5, m(11)], [1, m(14)]], i22), r22, n2, i22, 33, x(m(3), m(9), i22), x(m(9), m(17), i22), 0.42, 0, 0.08);
+ };
+})(t2, e2) };
+var m89369_U = function(t2, e2) {
+ let r22 = v(t2), n2 = 2 * t2 - 3, l22 = r22.filter((t3) => /[LR]/.test(t3)).length;
+ return C(r22.map((t3, e3) => t3.includes("H") || e3 >= l22 ? t3 : [...t3].map((t4, r3) => r3 === n2 ? "M" : e3 >= l22 - 2 && r3 >= n2 - Math.round(0.8 * l22) && r3 <= n2 ? "L" : ".").join("")), { M: e2[0], L: e2[1], R: Math.min(20, e2[1] + 2), H: e2[2] });
+};
+var m89369_i = function(t2, r22) {
+ let n2 = Math.max(...t2.map((t3) => t3.length)), l22 = new m97596_z(n2, Math.ceil(t2.length / 2));
+ for (let e2 = 0; e2 < l22.h; e2++) for (let a22 = 0; a22 < n2; a22++) {
+ let n3 = r22[t2[2 * e2]?.[a22] ?? "."] ?? -1, o22 = r22[t2[2 * e2 + 1]?.[a22] ?? "."] ?? -1;
+ n3 < 0 && o22 < 0 || (n3 === o22 ? l22.set(a22, e2, "\u2588", n3) : o22 < 0 ? l22.set(a22, e2, "\u2580", n3) : n3 < 0 ? l22.set(a22, e2, "\u2584", o22) : l22.set(a22, e2, "\u2580", n3, o22));
+ }
+ return l22;
+};
+var m89369_A = (t2) => t2 >= 170 ? 40 : t2 < 90 ? 18 : 21, m89369_V = function(t2) {
+ let e2 = [], r22 = Math.ceil(t2.hz / 16), n2 = t2.H / 16;
+ return [{ row: r22 + 4, h: 3, n: Math.max(2, Math.round(t2.W / 420)) }, { row: r22 + 9, h: 4, n: Math.max(1, Math.round(t2.W / 600)) }, { row: n2 - 1 - (t2.fade ?? 0), h: 5, n: Math.max(1, Math.round(t2.W / 1e3)) }].forEach((r3, n3) => {
+ for (let l22 = 0; l22 < r3.n; l22++) {
+ let a22 = t2.W * (0.2 + 0.62 * ((l22 + 0.5 + 0.37 * n3 + (L(l22, n3, 21) - 0.5) * 0.4) / r3.n % 1));
+ Math.abs(a22 - t2.mx) < 16 * r3.h && n3 < 2 || e2.push({ x: 8 * Math.round(a22 / 8), y: (r3.row - (n3 < 2 ? Math.round(2 * L(l22, n3, 23)) : 0)) * 16, h: 16 * r3.h });
+ }
+ }), e2;
+};
+var m89369_E = (t2) => T[t2.name](...t2.args);
+var m89369_J = function(t2) {
+ let e2 = $.get(t2);
+ return e2 || (e2 = U(t2), $.set(t2, e2)), e2;
+};
+
+// output/boat-lake/scene-1.js
+var l2 = 2 * Math.PI, a2 = [[-1, { zen: 16.6, hor: 12.5, horFar: 14, band: 0.16, glow: 0, glowR: 0.3, cloud: 17, cloudLit: 14, star: 1, land: 17.5, landLit: 15.5, pine: 19, pineLit: 17, deep: 18.6, far: 16, fres: 0.55, crest: -2.4, trough: 1, road: 4, roadA: 0.8, sail: 6, hull: 17 }], [-0.2, { zen: 16.6, hor: 11, horFar: 14, band: 0.14, glow: 2, glowR: 0.4, cloud: 16.5, cloudLit: 13, star: 0.85, land: 17.5, landLit: 16, pine: 19, pineLit: 17.5, deep: 18.4, far: 15, fres: 0.6, crest: -2.4, trough: 1, road: 4.5, roadA: 0.8, sail: 6, hull: 17 }], [-0.06, { zen: 16.2, hor: 5, horFar: 12.5, band: 0.08, glow: 7, glowR: 0.45, cloud: 15, cloudLit: 6, star: 0.25, land: 18, landLit: 16.5, pine: 19, pineLit: 18, deep: 17.6, far: 11, fres: 0.75, crest: -2.6, trough: 1, road: 3, roadA: 0.6, sail: 5, hull: 16.5 }], [0.03, { zen: 15.4, hor: 1, horFar: 10.5, band: 0.06, glow: 9, glowR: 0.4, cloud: 14, cloudLit: 2, star: 0, land: 17.5, landLit: 13.5, pine: 18.8, pineLit: 15.5, deep: 16.6, far: 7, fres: 0.8, crest: -2.8, trough: 1.2, road: 0, roadA: 1, sail: 3, hull: 16 }], [0.16, { zen: 14.6, hor: 1.5, horFar: 8, band: 0.08, glow: 8, glowR: 0.35, cloud: 12, cloudLit: 3, star: 0, land: 15.5, landLit: 10.5, pine: 18, pineLit: 14, deep: 15.6, far: 6.5, fres: 0.75, crest: -2.8, trough: 1.2, road: 0, roadA: 1, sail: 2, hull: 15.5 }], [0.42, { zen: 13.9, hor: 4, horFar: 5.5, band: 0.12, glow: 5, glowR: 0.25, cloud: 9, cloudLit: 3, star: 0, land: 13.5, landLit: 9, pine: 16.5, pineLit: 12.5, deep: 14, far: 7, fres: 0.7, crest: -2.6, trough: 1.2, road: 1, roadA: 0.9, sail: 1, hull: 14.5 }], [1, { zen: 13.6, hor: 4.5, horFar: 5, band: 0.14, glow: 4, glowR: 0.2, cloud: 8, cloudLit: 3, star: 0, land: 13, landLit: 8.5, pine: 16, pineLit: 12, deep: 13.6, far: 7, fres: 0.7, crest: -2.6, trough: 1.2, road: 1.5, roadA: 0.9, sail: 1, hull: 14.5 }]], o2 = (t2) => t2 * t2 * (3 - 2 * t2), h2 = (t2, e2 = 0, r22 = 1) => t2 < e2 ? e2 : t2 > r22 ? r22 : t2, i2 = (t2, e2, r22) => o2(h2((r22 - t2) / (e2 - t2))), f2 = (t2, e2, r22) => t2 + (e2 - t2) * r22, u2 = /* @__PURE__ */ new WeakMap();
+function M2(t2, e2) {
+ let n2 = u2.get(t2);
+ if (!n2) {
+ n2 = new Float32Array(t2.W + 200);
+ for (let e3 = 0; e3 < n2.length; e3++) n2[e3] = Math.max(t2.hz - 48, t2.hz + 4 - (z((e3 - 100) / 300, 0.5, 5) - 0.45) * 180);
+ u2.set(t2, n2);
+ }
+ let l22 = Math.round(e2) + 100;
+ return n2[l22 < 0 ? 0 : l22 >= n2.length ? n2.length - 1 : l22];
+}
+var s2 = /* @__PURE__ */ new WeakMap();
+function c2(t2) {
+ let e2 = s2.get(t2);
+ if (e2) return e2;
+ if (e2 = [], !t2.full) return s2.set(t2, e2), e2;
+ let n2 = (n3, l22, a22, o22, h22, i22) => {
+ let f22 = l22;
+ for (let l3 = 0; l3 < n3; l3++) {
+ let u22 = Math.max(64, o22 * (0.62 + 0.38 * L(l3 + 0.5, 2, h22)) * (1 - l3 / n3 * 0.55));
+ e2.push({ x: f22, top: t2.hz + 10 - u22, base: t2.hz + 12, w: i22 }), f22 += a22 * u22 * (0.18 + 0.22 * L(l3 + 0.5, 3, h22));
+ }
+ };
+ return n2(Math.max(3, Math.round(t2.W / 360)), 10, 1, Math.min(0.36 * t2.hz, 130), 7, 9), n2(Math.max(4, Math.round(t2.W / 240)), t2.W - 12, -1, 0.66 * Math.min(t2.hz, 300), 8, 11), s2.set(t2, e2), e2;
+}
+function d2(t2, e2, r22, n2) {
+ if (r22 < t2.top || r22 > t2.base) return 0;
+ let l22 = r22 - t2.top, a22 = 0.72 + 0.28 * (l22 / (1.1 * t2.w) % 1), o22 = 0.24 * l22 * a22 + 0.6, h22 = e2 - t2.x;
+ return Math.abs(h22) > o22 ? +(1 > Math.abs(h22) && r22 > t2.base - 6) : (n2 > t2.x ? h22 > 0.15 * o22 : h22 < -(0.15 * o22)) && Math.abs(h22) > o22 - 3.2 ? 2 : 1;
+}
+var p2 = /* @__PURE__ */ new WeakMap(), m2 = (t2) => Math.min(t2.hz, ...c2(t2).map((t3) => t3.top)), x2 = (t2) => t2.hz - 104;
+function w2(t2, e2, n2, l22, a22 = !1) {
+ let o22 = h2(1 - l22 / t2.hz), u22 = Math.exp(-(((n2 - e2.sx) / (0.42 * t2.W)) ** 2)), M22 = f2(e2.horFar, e2.hor, u22), s22 = e2.zen - 1.4 * (1 - o22);
+ s22 -= (s22 - M22) * Math.exp(-o22 / e2.band);
+ let c22 = (n2 - e2.sx) / t2.W, d22 = (l22 - e2.sy) / t2.hz;
+ if (s22 -= e2.glow * Math.exp(-(c22 * c22 * 2.2 + d22 * d22) / (e2.glowR * e2.glowR)) * (0.35 + 0.65 * i2(0.5, 0, o22)), e2.moonEl > -0.1) {
+ let r22 = (n2 - e2.mx) / t2.W, a3 = (l22 - e2.my) / t2.hz;
+ s22 -= 2.6 * e2.night * Math.exp(-(r22 * r22 * 3 + a3 * a3) / 0.03);
+ }
+ if (t2.full || t2.W > 0) {
+ let a3 = i2(0.5 * t2.W, 0.62 * t2.W, n2);
+ if (a3 > 0 && o22 > 0.12 && o22 < 0.7) {
+ let h22 = i2(0.6, 0.76, z((n2 - 4 * e2.t) / 230, l22 / 15, 3)) * i2(0.12, 0.22, o22) * i2(0.7, 0.5, o22) * a3;
+ if (h22 > 0) {
+ let r22 = Math.exp(-(((n2 - e2.lx) / t2.W) ** 2 * 6 + ((l22 - e2.ly) / t2.hz) ** 2 * 2));
+ s22 = f2(s22, f2(e2.cloud, e2.cloudLit, r22), 0.85 * h22);
+ }
+ }
+ }
+ if (t2.full || (s22 = f2(14, s22, i2(80, 200, l22))), !a22) {
+ if (e2.star > 0 && n2 % 8 < 4 && l22 % 16 < 8 && o22 > 0.3) {
+ let a3 = Math.floor(n2 / 8), h22 = Math.floor(l22 / 16), i22 = L(1.37 * a3 + 0.5, 2.11 * h22 + 0.5, 91);
+ (a3 + h22) % 3 == 0 && i22 > 0.86 && n2 > t2.copyW && L(a3 + 0.5, h22 + 0.5, 93) < e2.star * (o22 - 0.2) && Math.hypot((n2 - e2.mx) / t2.W * 2, (l22 - e2.my) / t2.hz) > 0.22 && (s22 = Math.min(s22, 4 + 6 * L(a3 + 0.5, h22 + 0.5, 95)));
+ }
+ if (t2.full && n2 < t2.copyW + 520) {
+ let e3 = i2(t2.copyW + 520, t2.copyW - 60, n2) * i2(0.1, 0.22, o22);
+ s22 < 13 && (s22 = f2(s22, 13, e3));
+ }
+ e2.sunEl > -0.2 && (s22 = g2(s22, n2, l22, e2.sx, e2.sy, 21, 0, 1.5, 0)), e2.moonEl > -0.2 && (s22 = g2(s22, n2, l22, e2.mx, e2.my, 18, 1, 3, 1));
+ }
+ return h2(s22, 0, 20);
+}
+function g2(t2, e2, r22, n2, l22, a22, o22, u22, M22) {
+ let s22 = Math.hypot(e2 - n2, r22 - l22);
+ if (s22 > a22 + 16) return t2;
+ t2 = Math.min(t2, f2(t2, u22 + 2.5, 0.85 * Math.exp(-(((s22 - a22) / 7) ** 2))));
+ let c22 = h2((a22 - s22) / 8 + 0.5);
+ if (c22 <= 0) return t2;
+ let d22 = o22 + (u22 - o22) * i2(0.5 * a22, a22, s22);
+ return M22 && 7 > Math.hypot(e2 - n2 + 6, r22 - l22 + 2) && (d22 = 3.5), f2(t2, Math.min(t2, d22), c22);
+}
+function y2(t2, e2, n2, l22) {
+ let a22 = (function(t3, e3, n3) {
+ if (n3 >= t3.hz) return 0;
+ let l3 = Math.round(e3 / 16), a3 = 16 * l3, o3 = t3.hz - M2(t3, a3);
+ if (o3 < 6 || t3.hz - M2(t3, e3) < 6) return 0;
+ let i3 = (10 + 12 * L(l3, 1, 11)) * h2((o3 - 3) / 18), f22 = Math.min(M2(t3, e3), M2(t3, a3) - i3 + 1.4 * Math.abs(e3 - a3));
+ return n3 > f22 ? 1 + n3 - f22 : 0;
+ })(t2, n2, l22);
+ if (!a22) return -1;
+ if (l22 > t2.hz - 5) return f2(e2.land, e2.landLit, 0.5);
+ let o22 = M2(t2, n2 + 40) - M2(t2, n2 - 40), i22 = h2((e2.lx > n2 ? o22 : -o22) / 30, -1, 1), u22 = f2(e2.land, e2.landLit, 0.25 + 0.25 * i22);
+ return a22 < 5 && (u22 = f2(u22, e2.landLit, 0.7)), u22;
+}
+var b2 = (t2, e2, r22, n2) => Math.sin(1.6 / (h2((r22 - t2.hz) / (t2.H - t2.hz)) + 0.12) + e2 / t2.W * 2.1 + 1e3 * n2 / 4200 * l2);
+function L2(t2, e2, r22, n2) {
+ if (n2 < t2.hz) {
+ for (let l22 of c2(t2)) {
+ let t3 = d2(l22, r22, n2, e2.lx);
+ if (t3) return t3 === 2 ? e2.pineLit : e2.pine;
+ }
+ return -1;
+ }
+ for (let [l22, a22] of (function(t3) {
+ let e3 = p2.get(t3);
+ if (!e3) {
+ let r3 = c2(t3);
+ e3 = [r3.filter((e4) => e4.x < t3.W / 2).map((t4) => t4.x), r3.filter((e4) => e4.x >= t3.W / 2).map((t4) => t4.x)].filter((t4) => t4.length).map((t4) => [Math.min(...t4), Math.max(...t4)]), p2.set(t3, e3);
+ }
+ return e3;
+ })(t2)) if (r22 > l22 - 26 + (n2 - t2.hz) * 1.4 && r22 < a22 + 26 - (n2 - t2.hz) * 1.4 && n2 < t2.hz + 16) return e2.pine + 0.5;
+ return -1;
+}
+function z2(t2, e2, l22, a22, o22) {
+ var u22;
+ let M22, s22, p22, m22, x22;
+ if (o22 < t2.hz) return -1;
+ let g22 = c2(t2), L22 = e2.t, z22 = h2((o22 - t2.hz) / (t2.H - t2.hz)), H22 = b2(t2, a22, o22, L22) * i2(0.02, 0.3, z22), W22 = H22 * (1.5 + 6 * z22), A22 = 2 * t2.hz - o22 + H22 * (3 + 10 * z22), R22 = w2(t2, e2, a22 + W22, A22, !0), E22 = y2(t2, e2, a22 + W22, A22);
+ for (let t3 of (E22 >= 0 && (R22 = E22), g22)) if (d2(t3, a22 + W22, A22, e2.lx)) {
+ R22 = f2(e2.pine, R22, 0.3);
+ break;
+ }
+ for (let t3 of l22) {
+ if (t3.off || o22 < t3.y || o22 > t3.y + t3.h || Math.abs(a22 - t3.x) > 0.7 * t3.h) continue;
+ let l3 = E(t3, a22 + W22, 2 * t3.y - o22);
+ if (l3 && Math.sin(0.55 * o22 + 3 * L(a22 / 40, o22 / 8, 5)) > -0.2) {
+ R22 = f2(R22, l3 === 3 ? e2.hull : e2.sail + 2 * (l3 === 2), 0.5);
+ break;
+ }
+ }
+ let F22 = f2(e2.far, e2.deep, Math.pow(z22, 0.7)), k22 = f2(F22, R22, e2.fres * Math.pow(1 - z22, 1.3));
+ k22 -= 0.4 * H22;
+ let Q22 = (u22 = 0.78 - 0.03 * z22 - 0.05 * H22, M22 = Math.floor(o22 / 8), s22 = 16 + 60 * z22, m22 = (p22 = (t3) => L((a22 + L22 * (4 + 10 * z22) * (1 & t3 ? 1 : -0.6)) / s22, 0.05 * L22 + (7 & t3) * 3.1, 131 + 17 * t3))(M22), x22 = p22(M22 - 1), m22 > u22 && x22 <= u22 ? 1 : x22 > u22 && p22(M22 - 2) <= u22 ? -1 : 0), v22 = t2.full ? 1 : 0.6;
+ if (Q22 > 0 ? k22 += e2.crest * (0.4 + 0.3 * z22) * v22 : Q22 < 0 && (k22 += 0.6 * e2.trough * v22), e2.lEl > -0.05) {
+ let t3 = Math.max(0, e2.lEl), n2 = (7 + 70 * z22) * (0.7 + 0.9 * t3), l3 = Math.exp(-(((a22 - e2.lx) / n2) ** 2));
+ if (l3 > 0.02) {
+ let n3 = l3 * i2(0, 0.35, z22 + 0.3 - 0.5 * t3) * e2.roadA * (e2.sunEl > -0.05 ? 1 : 0.85) * i2(-0.05, 0.03, e2.lEl), h22 = Q22 > 0 ? 1 : 0.6 * (Q22 === 0 && L(a22 / 10, 1.3 * Math.floor(o22 / 8) + 0.3 * L22, 9) > 0.62);
+ k22 = f2(k22, e2.road, n3 * h22);
+ }
+ }
+ return t2.fade && (k22 = f2(k22, 0, i2(t2.H - (t2.fade + 1) * 16, t2.H - 40, Math.min(t2.H - 40, o22 + (L(a22 / 160, 3.3, 17) - 0.5) * 22 + (L(a22 / 36, 7.1, 19) - 0.5) * 24)))), h2(k22, 0, 20);
+}
+function H2(t2, e2, r22 = 1) {
+ let n2 = (t3) => Math.max(0, Math.min(20, Math.floor(t3 + e2))), l22 = t2.back * i2(0.5, 0.15, r22) > 0.5 ? 15 : t2.sail;
+ return [n2(l22), n2(l22 + 1.6), n2(l22 + 3.2), n2(l22 + 1), n2(l22 + 2.4), n2(t2.hull)];
+}
+var W2 = /* @__PURE__ */ new Map();
+function A2(t2, e2) {
+ let r22 = `${t2.h},${+!!t2.off},${e2.join(",")}`, l22 = W2.get(r22);
+ return l22 || (l22 = t2.off ? m89369_U(t2.h / 16, [e2[1], e2[0], e2[5]]) : P(t2.h / 16, e2.slice(0, 3), e2.slice(3, 5), e2[5]), W2.size > 300 && W2.clear(), W2.set(r22, l22)), l22;
+}
+var R2 = e.map((t2) => {
+ let e2 = [1, 3, 5].map((e3) => parseInt(t2.slice(e3, e3 + 2), 16) / 255).map((t3) => t3 <= 0.04045 ? t3 / 12.92 : ((t3 + 0.055) / 1.055) ** 2.4);
+ return 0.2126 * e2[0] + 0.7152 * e2[1] + 0.0722 * e2[2];
+}), E2 = e.length, F2 = [];
+for (let t2 = 0; t2 < E2; t2++) F2.push({ pos: t2, g: 0, f: -1, b: t2 }), t2 < E2 - 1 && [0.25, 0.5, 0.75].forEach((e2, r22) => F2.push({ pos: (function(t3) {
+ for (let e3 = 0; e3 < E2 - 1; e3++) if (t3 >= R2[e3 + 1]) return e3 + (R2[e3] - t3) / (R2[e3] - R2[e3 + 1]);
+ return E2 - 1;
+})(R2[t2] * (1 - e2) + R2[t2 + 1] * e2), g: 16 + r22, f: t2 + 1, b: t2 }));
+var k2 = (() => {
+ let t2 = [1, 0, 3, 2], e2 = [2, 3, 0, 1], r22 = [];
+ for (let n2 = 0; n2 < 4; n2++) for (let l22 = 0; l22 < 4; l22++) r22.push(l22 + n2 & 1 ? l22 === t2[n2] ? 0.17 : 0.33 : l22 === e2[n2] ? 0.67 : 0.83);
+ return r22;
+})(), Q2 = new Float64Array(4), v2 = new Int8Array(4);
+function I2(t2, e2, r22, n2, l22, a22 = !0, o22 = 0.8) {
+ Q2.fill(0), v2.fill(0);
+ let i22 = a22 ? 4 : 2;
+ for (let n3 = 0; n3 < i22; n3++) for (let l3 = 0; l3 < 2; l3++) {
+ let a3 = t2(8 * e2 + 4 * (l3 + 0.5), 16 * r22 + 16 / i22 * (n3 + 0.5));
+ if (a3 < 0) continue;
+ let o3 = (n3 < i22 / 2 ? 0 : 2) + (l3 < 1 ? 0 : 1);
+ Q2[o3] += a3, v2[o3]++;
+ }
+ let f22 = 0, u22 = 0, M22 = 0;
+ for (let t3 = 0; t3 < 4; t3++) v2[t3] && (Q2[t3] /= v2[t3], f22 |= 1 << t3, u22++, M22 += Q2[t3]);
+ if (!u22) {
+ n2[l22] = 0, n2[l22 + 1] = -1, n2[l22 + 2] = -1;
+ return;
+ }
+ if (u22 < 4) {
+ n2[l22] = f22, n2[l22 + 1] = Math.round(M22 / u22), n2[l22 + 2] = -1;
+ return;
+ }
+ let s22 = M22 / 4, c22 = 0;
+ for (; c22 < F2.length - 2 && F2[c22 + 1].pos <= s22; ) c22++;
+ let d22 = F2[c22], p22 = F2[c22 + 1], m22 = h2((s22 - d22.pos) / (p22.pos - d22.pos)) >= k2[(3 & r22) << 2 | 3 & e2] ? p22 : d22;
+ p22.pos <= 1 && (m22 = F2[4 * (Math.round(s22) !== 0)]);
+ let x22 = 0, w22 = m22.f, g22 = m22.b, y22 = m22.g, b22 = ((Q2[0] - m22.pos) ** 2 + (Q2[1] - m22.pos) ** 2 + (Q2[2] - m22.pos) ** 2 + (Q2[3] - m22.pos) ** 2) * o22;
+ for (let t3 = 1; t3 < 15; t3++) {
+ let e3 = 0, r3 = 0, n3 = 0, l3 = 0;
+ for (let a4 = 0; a4 < 4; a4++) t3 & 1 << a4 ? (e3 += Q2[a4], r3++) : (n3 += Q2[a4], l3++);
+ let a3 = Math.round(e3 / r3), o3 = Math.round(n3 / l3);
+ if (a3 === o3) continue;
+ let h22 = 0;
+ for (let e4 = 0; e4 < 4; e4++) h22 += (Q2[e4] - (t3 & 1 << e4 ? a3 : o3)) ** 2;
+ h22 < b22 && (b22 = h22, x22 = t3, w22 = a3, g22 = o3);
+ }
+ x22 ? n2[l22] = x22 : n2[l22] = y22, n2[l22 + 1] = w22, n2[l22 + 2] = g22;
+}
+function C2(t2, r22) {
+ if (!t2.px) {
+ let n2 = P2(t2.r0, t2.r1, t2.cols, r22);
+ t2.px = m97596_B(n2.w, n2.h);
+ }
+ return t2.px;
+}
+function D2(t2, e2, r22, n2, l22 = 0, a22 = t2.cols) {
+ for (let o22 of r22) {
+ if (o22 < t2.r0 || o22 >= t2.r1) continue;
+ let r3 = (o22 - t2.r0) * t2.cols * 3;
+ for (let h22 = Math.max(0, l22); h22 < Math.min(t2.cols, a22); h22++) I2(e2, h22, o22, t2.cells, r3 + 3 * h22, n2);
+ }
+}
+var m59908_A = 12e4, m59908_$ = 0.44, m59908_F = function(t2, e2, r22) {
+ return r22.map((r3, n2) => {
+ let l22 = A2(r3, H2(e2, (0.618 * n2 + 0.13) % 1, h2((r3.y - t2.hz) / (t2.H - t2.hz)))), a22 = r3.h >= 64 ? 4 : 2;
+ return { g: l22, cx: Math.round(r3.x / 8 - l22.w / 2), cy: (r3.y - r3.h) / 16, dy: -b2(t2, r3.x, r3.y, e2.t) * a22, y: r3.y };
+ }).sort((t3, e3) => t3.y - e3.y);
+};
+var m59908_B = (t2) => [Math.floor((t2 - 21 - 18) / 8), Math.ceil((t2 + 21 + 18) / 8)], m59908_C = (t2) => {
+ let e2 = Math.floor((t2 - 21 - 18) / 16);
+ return Array.from({ length: Math.max(0, Math.ceil((t2 + 21 + 18) / 16) - e2) }, (t3, r22) => e2 + r22);
+};
+var m59908_z = function(t2, e2, r22) {
+ let n2, u22, M22, s22 = l2 * (n2 = (e2 % 1 + 1) % 1) - 0.25 * Math.sin(2 * l2 * n2), { cx: c22, rx: d22, ry: p22 } = (u22 = Math.min(t2.copyW + 40, 0.6 * t2.W), M22 = t2.full ? u22 + (t2.W - u22) * 0.3 : 0.5 * t2.W, { cx: M22, rx: t2.full ? (t2.W - u22) * 0.24 : 0.36 * t2.W, ry: t2.full ? 0.72 * t2.hz : Math.max(16, t2.hz - 96 - 21 - 4) }), m22 = Math.sin(s22), x22 = c22 - d22 * Math.cos(s22), w22 = t2.hz - p22 * m22, g22 = c22 + d22 * Math.cos(s22), y22 = t2.hz + p22 * m22, b22 = (function(t3) {
+ let e3 = 1;
+ for (; e3 < a2.length - 1 && t3 > a2[e3][0]; ) e3++;
+ let [r3, n3] = a2[e3 - 1], [l22, i22] = a2[e3], u3 = o2(h2((t3 - r3) / (l22 - r3))), M3 = {};
+ for (let t4 in n3) M3[t4] = f2(n3[t4], i22[t4], u3);
+ return M3;
+ })(m22), L22 = m22 > -0.05;
+ return { ...b22, p: e2, t: r22, sx: x22, sy: w22, sunEl: m22, mx: g22, my: y22, moonEl: -m22, lx: L22 ? x22 : g22, ly: L22 ? w22 : y22, lEl: L22 ? m22 : -m22, night: i2(-0.02, -0.25, m22), back: i2(0.4, 0.12, m22) * i2(-0.1, 0, m22) };
+};
+var B2 = (t2) => Array.from({ length: t2.r1 - t2.r0 }, (e2, r22) => t2.r0 + r22), U2 = (t2, e2) => Math.round(t2 * e2);
+function P2(t2, r22, n2, l22) {
+ let a22 = U2(t2 * m97596_h, l22);
+ return { top: a22, w: U2(n2 * m97596_D, l22), h: U2(r22 * m97596_h, l22) - a22 };
+}
+var $2 = { "\u2598": 1, "\u259D": 2, "\u2580": 3, "\u2596": 4, "\u258C": 5, "\u259E": 6, "\u259B": 7, "\u2597": 8, "\u259A": 9, "\u2590": 10, "\u259C": 11, "\u2584": 12, "\u2599": 13, "\u259F": 14, "\u2588": 15 };
+function j2(t2, e2, r22, n2) {
+ if (n2.kind === "sky") return (r3, n3) => w2(t2, e2, r3, n3);
+ if (n2.kind === "horizon") return (r3, n3) => {
+ let l3 = L2(t2, e2, r3, n3);
+ return l3 >= 0 ? l3 : y2(t2, e2, r3, n3);
+ };
+ let l22 = 16 * n2.w0;
+ return (n3, a22) => {
+ if (a22 < l22) return -1;
+ let o22 = L2(t2, e2, n3, a22);
+ return o22 >= 0 ? o22 : z2(t2, e2, r22, n3, a22);
+ };
+}
+var K2 = (t2, e2) => t2.kind === "water" ? e2.filter((e3) => O2(e3) >= t2.w0 && O2(e3) < t2.w1) : [], O2 = (t2) => t2.y / 16 - 1;
+var m55548_Z = (t2, e2) => t2.findIndex((t3) => t3.kind === "water" && e2 >= t3.w0 && e2 < t3.w1);
+var m55548_U = function(t2, r22, n2, l22) {
+ let a22 = (t3) => U2(t3 * m97596_D, l22), o22 = U2(r22.r0 * m97596_h, l22), h22 = C2(r22, l22);
+ for (let t3 of n2) {
+ let n3 = (r3) => U2(r3 * m97596_h + t3.dy, l22) - o22;
+ for (let l3 = 0; l3 < t3.g.h; l3++) for (let o3 = 0; o3 < t3.g.w; o3++) {
+ let i22 = t3.cx + o3, f22 = t3.cy + l3, u22 = t3.g.fg[l3][o3], M22 = t3.g.bg[l3][o3], s22 = $2[t3.g.ch[l3][o3]] ?? 0;
+ if (i22 < 0 || i22 >= r22.cols) continue;
+ let c22 = a22(i22), d22 = a22(i22 + 1), p22 = a22(i22 + 0.5), m22 = n3(f22), x22 = n3(f22 + 1), w22 = n3(f22 + 0.5);
+ if (M22 >= 0 && m97596_Q(h22, c22, m22, d22, x22, r[M22]), !s22 || u22 < 0) continue;
+ let g22 = r[u22];
+ 1 & s22 && m97596_Q(h22, c22, m22, p22, w22, g22), 2 & s22 && m97596_Q(h22, p22, m22, d22, w22, g22), 4 & s22 && m97596_Q(h22, c22, w22, p22, x22, g22), 8 & s22 && m97596_Q(h22, p22, w22, d22, x22, g22);
+ }
+ }
+ m97596_K(t2, h22);
+}, m55548_q = function(t2, r22, n2) {
+ let l22 = r22.drawn, a22 = C2(r22, n2), o22 = Math.max(1, Math.round(n2)), h22 = U2(r22.r0 * m97596_h, n2), i22 = (t3) => U2(t3 * m97596_D, n2), f22 = (t3) => U2((r22.r0 + t3) * m97596_h, n2) - h22, u22 = r22.cells;
+ for (let t3 = 0; t3 < r22.r1 - r22.r0; t3++) {
+ let n3 = f22(t3), h3 = f22(t3 + 1), M22 = f22(t3 + 0.5);
+ for (let f3 = 0; f3 < r22.cols; f3++) {
+ let s22 = (t3 * r22.cols + f3) * 3, c22 = u22[s22], d22 = u22[s22 + 1], p22 = u22[s22 + 2];
+ if (l22[s22] === c22 && l22[s22 + 1] === d22 && l22[s22 + 2] === p22) continue;
+ l22[s22] = c22, l22[s22 + 1] = d22, l22[s22 + 2] = p22;
+ let m22 = i22(f3), x22 = i22(f3 + 1), w22 = i22(f3 + 0.5);
+ if (m97596_Q(a22, m22, n3, x22, h3, p22 >= 0 ? r[p22] : 0), c22 && d22 >= 0) {
+ let t4 = r[d22];
+ c22 < 16 ? (1 & c22 && m97596_Q(a22, m22, n3, w22, M22, t4), 2 & c22 && m97596_Q(a22, w22, n3, x22, M22, t4), 4 & c22 && m97596_Q(a22, m22, M22, w22, h3, t4), 8 & c22 && m97596_Q(a22, w22, M22, x22, h3, t4)) : m97596_Q(a22, m22, n3, x22, h3, t4, c22, o22);
+ }
+ r22.r0 + t3 !== r22.blend || r22.solid?.[f3] || m97596_m(a22, m22, n3, x22, h3, o22);
+ }
+ }
+ m97596_K(t2, a22);
+};
+var m55548_Q = function(t2) {
+ let e2 = t2.hz / 16, r22 = t2.H / 16, n2 = [{ name: "sky", kind: "sky", r0: 0, r1: e2 + 1, w0: 0, w1: 0, f: 0.26, fine: !1 }], l22 = (t3, n3) => Math.round(0.26 * (1 - ((t3 + n3) / 2 - e2) / (r22 - e2)) ** 1.6 * 100) / 100;
+ for (let t3 = e2; t3 < r22; ) {
+ let a22 = Math.min(r22, t3 + 4), o22 = t3 === e2 ? 0.26 : l22(t3, a22);
+ o22 < 0.05 && (a22 = r22, o22 = 0), n2.push({ name: `w${t3}`, kind: "water", r0: t3 - 4, r1: a22 + 1, w0: t3, w1: a22, f: o22, fine: !1 }), t3 = a22;
+ }
+ return n2.splice(1, 0, { name: "horizon", kind: "horizon", r0: Math.max(0, Math.floor(Math.min(x2(t2), m2(t2)) / 16)), r1: e2 + 2, w0: 0, w1: 0, f: 0.26, fine: !0 }), n2;
+};
+var m55548_i = (t2, e2) => {
+ let r22 = t2.find((t3) => t3.kind === "water");
+ return t2.map((t3) => {
+ var n2, l22, a22;
+ let o22;
+ return n2 = t3.r0, l22 = t3.r1, a22 = t3.kind === "water" && t3 !== r22 ? t3.w0 : void 0, o22 = (l22 - n2) * e2 * 3, { r0: n2, r1: l22, cols: e2, cells: new Int8Array(o22), drawn: new Int8Array(o22).fill(-2), blend: a22 };
+ });
+}, m55548_n = function(t2, e2, r22, n2, l22) {
+ n2.forEach((n3, a22) => D2(l22[a22], j2(t2, e2, r22, n3), B2(l22[a22]), n3.fine));
+};
+var m55548_G = function(t2, e2) {
+ let r22 = Math.round(1e3 * t2 * e2);
+ return { "--par": r22 / e2 + "px", "--n": Math.max(1, r22) };
+}, m55548_C = function(t2, r22, n2) {
+ let l22 = -1;
+ t2.forEach((a22, o22) => {
+ if (a22.kind !== "water") return;
+ let h22 = r22[o22];
+ if (l22 >= 0 && h22.blend !== void 0) {
+ let r3 = Math.ceil((t2[l22].f - a22.f) * 1e3 / m97596_h) + 1, o3 = new Uint8Array(h22.cols);
+ for (let e2 of K2(t2[l22], n2)) if (O2(e2) >= a22.w0 - r3) for (let t3 = Math.max(0, e2.cx - 1); t3 < Math.min(h22.cols, e2.cx + e2.g.w + 1); t3++) o3[t3] = 1;
+ for (let t3 = 0; t3 < h22.cols; t3++) o3[t3] !== (h22.solid?.[t3] ?? 0) && (h22.drawn[((h22.blend - h22.r0) * h22.cols + t3) * 3] = -2);
+ h22.solid = o3;
+ }
+ l22 = o22;
+ });
+}, m55548_D = function(t2, e2) {
+ for (let r22 of e2) for (let e3 = Math.floor(r22.cy) - 1; e3 < r22.cy + r22.g.h + 1; e3++) if (!(e3 < t2.r0) && !(e3 >= t2.r1)) for (let n2 = Math.max(0, r22.cx); n2 < Math.min(t2.cols, r22.cx + r22.g.w); n2++) t2.drawn[((e3 - t2.r0) * t2.cols + n2) * 3] = -2;
+}, m55548_M = function(t2, r22, n2) {
+ let l22 = -1;
+ for (let a22 = t2.length - 1; a22 >= 0; a22--) {
+ let o22 = t2[a22];
+ if (o22.kind !== "water") continue;
+ l22 = a22;
+ let h22 = r22 - n2(a22);
+ if (h22 >= o22.w0 * m97596_h && h22 < o22.w1 * m97596_h) return h22;
+ }
+ return l22 < 0 ? r22 : r22 - n2(l22);
+};
+export {
+ m55548_C,
+ m55548_D,
+ O2 as m55548_E,
+ m55548_G,
+ B2 as m55548_I,
+ m55548_M,
+ m55548_Q,
+ m55548_U,
+ m55548_Z,
+ K2 as m55548_b,
+ m55548_i,
+ P2 as m55548_j,
+ m55548_n,
+ m55548_q,
+ D2 as m55548_r,
+ j2 as m55548_v,
+ m59908_$,
+ m59908_A,
+ m59908_B,
+ m59908_C,
+ m59908_F,
+ I2 as m59908_G,
+ y2 as m59908_I,
+ A2 as m59908_N,
+ z2 as m59908_P,
+ m2 as m59908_T,
+ x2 as m59908_c,
+ w2 as m59908_d,
+ L2 as m59908_h,
+ H2 as m59908_o,
+ m59908_z,
+ y as m87928_C,
+ p as m87928_F,
+ m as m87928_G,
+ w as m87928_O,
+ L as m87928_Q,
+ g as m87928_k,
+ z as m87928_m,
+ m87928_x,
+ x as m87928_y,
+ m89369_A,
+ m89369_E,
+ O as m89369_I,
+ m89369_J,
+ P as m89369_O,
+ E as m89369_P,
+ m89369_U,
+ m89369_V,
+ C as m89369_W,
+ U as m89369__,
+ m89369_i,
+ k as m89369_m,
+ j as m89369_x,
+ m97596_B,
+ m97596_D,
+ m97596_K,
+ m97596_P,
+ m97596_Q,
+ m97596_h,
+ m97596_m,
+ e as m97596_p,
+ m97596_q,
+ r as m97596_v,
+ m97596_z
+};
diff --git a/scripts/boat-lake/sizes.html b/scripts/boat-lake/sizes.html
new file mode 100644
index 0000000..3f97a15
--- /dev/null
+++ b/scripts/boat-lake/sizes.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+Boat Lake · TUI size checks
+
+Boat Lake at TUI sizes
+Each scene uses its own composition and the exact receiver output. Canvas cells are 8 × 16 pixels. The text views use real Unicode glyphs in the browser’s monospace font; terminal fonts may render their edges differently. Back to the animated reference comparison.
+
+
+
diff --git a/scripts/boat-lake/sumi-quadrants.mjs b/scripts/boat-lake/sumi-quadrants.mjs
new file mode 100644
index 0000000..0f1e802
--- /dev/null
+++ b/scripts/boat-lake/sumi-quadrants.mjs
@@ -0,0 +1,2 @@
+// Frozen receiver before the small-TUI refinement, 2026-10-28.
+var E=["#05091b","#080e26","#0b1432","#101c40","#14254e","#192e60","#1f3973","#284784","#335694","#4165a4","#5376b4","#688ac2","#809fd0","#9ab4dd","#b8cbe9","#d6e2f3","#ecf2fb","#fcfdff"],G=E.map(n=>{let t=Number.parseInt(n.slice(1),16);return`#${Math.round((t>>16)*.2126+(t>>8&255)*.7152+(t&255)*.0722).toString(16).padStart(2,"0").repeat(3)}`}),H=" \u2598\u259D\u2580\u2596\u258C\u259E\u259B\u2597\u259A\u2590\u259C\u2584\u2599\u259F\u2588",C=new Map,J=n=>Math.max(0,Math.min(1,n)),R=n=>{let t=J(n);return t*t*(3-2*t)};function j(n,t){let e=Math.imul(n,374761393)^Math.imul(t,668265263);return e=Math.imul(e^e>>>13,1274126177),((e^e>>>16)>>>0)/4294967295}function q(n,t){let e=Math.floor(n),S=R(n-e);return j(e,t)*(1-S)+j(e+1,t)*S}function K(n,t){let e=`${n}:${t}`,S=C.get(e);if(S)return S;let y=n*2,h=t*2,W=.47,F=.78,N=.21,a=Math.max(.095,.65/t),z=n/(t*2),g=new Float32Array(y*h),O=Float32Array.from({length:y},(c,o)=>(o+.5)/y),X=Float32Array.from({length:h},(c,o)=>((o+.5)/h-W)/(1-W)),l=X.findIndex(c=>c>=0);for(let c=0;ca*2.4&&j(m,u+17)>.987&&Math.abs(i*Math.max(18,n/3)%1-.5)<.12&&Math.abs(o*Math.max(8,t)%1-.5)<.2&&(r+=3)}g[c*y+k]=r}}let s={field:g,xs:O,depths:X,firstWater:l,moonX:F};return C.size>=4&&C.delete(C.keys().next().value),C.set(e,s),s}function L(n,t,e,S){let y=K(t,e),{field:h,xs:W,depths:F,moonX:N}=y,a=t*2,z=e*2,g=n*.08,O=S==="mono"?G:E;for(let l=y.firstWater;l=0,i=5.7-o*2.6+Math.sin(o*24-g*.42)*.4,A=Math.max(1,Math.floor(i-.35));for(let d=0;du?(M|=1,v+=x,p++):w+=x,r>u?(M|=2,v+=r,p++):w+=r,b>u?(M|=4,v+=b,p++):w+=b,m>u?(M|=8,v+=m,p++):w+=m;let I=Math.max(0,Math.min(17,Math.round(p?v/p:u))),T=Math.max(0,Math.min(17,Math.round(p<4?w/(4-p):u)));if(k&&Math.abs((d+.5)/t-N)>.018+o*.13){let $=i+.2;M=(x>$?1:0)|(r>$?2:0)|(b>$?4:0)|(m>$?8:0),I=A+2,T=A}let Y=I===T?" ":H[M],B=O[I],D=O[T];s+=Y;let _=c.at(-1);_?.color===B&&_.backgroundColor===D?_.text+=Y:c.push({text:Y,color:B,backgroundColor:D})}X.push({text:s,color:O[7],segments:c})}return X}export{L as buildSumiOceanQuadrants};
diff --git a/scripts/boat-lake/terminal-canvas.mjs b/scripts/boat-lake/terminal-canvas.mjs
new file mode 100644
index 0000000..3686e6c
--- /dev/null
+++ b/scripts/boat-lake/terminal-canvas.mjs
@@ -0,0 +1,39 @@
+/** Paint exactly the glyphs/colors emitted to the TUI; no extra scene detail. */
+const quadrants = ' ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█';
+const triangles = {
+ '◢': [[1, 0], [1, 1], [0, 1]], '◣': [[0, 0], [0, 1], [1, 1]],
+ '◤': [[0, 0], [1, 0], [0, 1]], '◥': [[0, 0], [1, 0], [1, 1]],
+};
+export function paintReceiver(context, frame, cw = 8, ch = 16) {
+ frame.forEach((row, y) => {
+ let x = 0;
+ for (const segment of row.segments) for (const glyph of segment.text) {
+ const left = x++ * cw, top = y * ch;
+ context.fillStyle = segment.backgroundColor;
+ context.fillRect(left, top, cw, ch);
+ context.fillStyle = segment.color;
+ const mask = quadrants.indexOf(glyph);
+ if (mask > 0) {
+ for (let bit = 0; bit < 4; bit++) if (mask & (1 << bit)) context.fillRect(left + (bit & 1) * cw / 2, top + (bit >> 1) * ch / 2, cw / 2, ch / 2);
+ } else if (glyph in triangles) {
+ context.beginPath();
+ triangles[glyph].forEach(([dx, dy], index) => context[index ? 'lineTo' : 'moveTo'](left + dx * cw, top + dy * ch));
+ context.fill();
+ } else if (glyph === '●') {
+ context.beginPath();
+ context.arc(left + cw / 2, top + ch / 2, cw / 2, 0, Math.PI * 2);
+ context.fill();
+ } else if (glyph === '─') {
+ context.fillRect(left, top + ch / 2 - ch / 16, cw, ch / 8);
+ } else if (glyph >= '▁' && glyph <= '▇') {
+ const fill = (glyph.codePointAt(0) - 0x2580) / 8 * ch;
+ context.fillRect(left, top + ch - fill, cw, fill);
+ } else if ('░▒▓'.includes(glyph)) {
+ const level = '░▒▓'.indexOf(glyph) + 1;
+ for (let dy = 0; dy < ch; dy += 2) for (let dx = 0; dx < cw; dx += 2) {
+ if ((dx / 2 + dy / 2 * 3) % 4 < level) context.fillRect(left + dx, top + dy, 2, 2);
+ }
+ }
+ }
+ });
+}
diff --git a/scripts/build-boat-lake-preview.mjs b/scripts/build-boat-lake-preview.mjs
new file mode 100644
index 0000000..22a77e8
--- /dev/null
+++ b/scripts/build-boat-lake-preview.mjs
@@ -0,0 +1,37 @@
+/** Rebuild the offline scene comparison; never fetches assets or publishes. */
+import {createRequire} from 'node:module';
+import {mkdir, copyFile, readFile, writeFile} from 'node:fs/promises';
+import {createHash} from 'node:crypto';
+import {fileURLToPath} from 'node:url';
+
+const requireDocs = createRequire(new URL('../apps/docs/package.json', import.meta.url));
+const {build} = requireDocs('esbuild');
+const root = fileURLToPath(new URL('../', import.meta.url));
+const output = new URL('../output/boat-lake/', import.meta.url);
+await mkdir(output, {recursive: true});
+await build({
+ stdin: {contents: "export {buildBoatLake} from './src/ui/visualizers/boat-lake.js';", resolveDir: root, loader: 'ts'},
+ outfile: fileURLToPath(new URL('receiver.js', output)),
+ bundle: true, format: 'esm', target: 'es2022', minify: true,
+});
+await build({
+ stdin: {contents: "export {buildSumiOcean} from './src/ui/visualizers/sumi-ocean.js';", resolveDir: root, loader: 'ts'},
+ outfile: fileURLToPath(new URL('ocean.js', output)),
+ bundle: true, format: 'esm', target: 'es2022', minify: true,
+});
+await copyFile(new URL('boat-lake/sumi-quadrants.mjs', import.meta.url), new URL('sumi-quadrants.js', output));
+await copyFile(new URL('boat-lake/ocean-sizes.html', import.meta.url), new URL('ocean-sizes.html', output));
+await copyFile(new URL('boat-lake/ocean-preview.html', import.meta.url), new URL('ocean.html', output));
+await copyFile(new URL('boat-lake/reference.mjs', import.meta.url), new URL('reference.js', output));
+await copyFile(new URL('boat-lake/terminal-canvas.mjs', import.meta.url), new URL('terminal-canvas.js', output));
+await copyFile(new URL('boat-lake/sizes.html', import.meta.url), new URL('sizes.html', output));
+await copyFile(new URL('boat-lake/preview.html', import.meta.url), new URL('index.html', output));
+// Local browsers may retain imported modules while an HTML tab is refreshed.
+// Give each renderer build a content version so comparison tabs stay current.
+const oceanVersion = createHash('sha256').update(await readFile(new URL('ocean.js', output))).digest('hex').slice(0, 12);
+for (const page of ['ocean.html', 'ocean-sizes.html']) {
+ const url = new URL(page, output);
+ const source = await readFile(url, 'utf8');
+ await writeFile(url, source.replaceAll("'./ocean.js'", `'./ocean.js?v=${oceanVersion}'`));
+}
+console.log('Local previews: output/boat-lake/index.html and output/boat-lake/ocean.html');
diff --git a/scripts/receiver-memory-smoke.mjs b/scripts/receiver-memory-smoke.mjs
new file mode 100644
index 0000000..ed13c87
--- /dev/null
+++ b/scripts/receiver-memory-smoke.mjs
@@ -0,0 +1,82 @@
+// Run with: node --expose-gc --import tsx scripts/receiver-memory-smoke.mjs
+// Use one persistent real Ink root and discard output. Testing-library's
+// frames[] would itself retain the history and invalidate memory measurements.
+import assert from 'node:assert/strict';
+import {PassThrough, Writable} from 'node:stream';
+import {setImmediate as settle} from 'node:timers/promises';
+
+// Match the CLI's pre-import default. Explicit NODE_ENV values are preserved.
+process.env.NODE_ENV ??= 'production';
+const [
+ {default: React}, {Box, render}, {receiverStyleNames},
+ {DisplayContext, resolveDisplayMode}, {configureTerminalRenderer},
+ {ReceiverVisualRow}, {buildVisualizer}
+] = await Promise.all([
+ import('react'), import('ink'), import('../src/types.js'),
+ import('../src/ui/display-context.js'), import('../src/ui/terminal-renderer.js'),
+ import('../src/ui/components/ReceiverVisualRow.js'), import('../src/ui/visualizers/receiver-visualizers.js')
+]);
+assert.equal(typeof global.gc, 'function', 'Run Node with --expose-gc');
+const frames = Number(process.argv.find(value => value.startsWith('--frames='))?.split('=')[1] ?? 2000);
+assert(Number.isInteger(frames) && frames >= 1000, '--frames must be an integer >= 1000');
+const playback = {state: 'playing', ready: true, backend: 'mpv', volume: 70, muted: false};
+const scenes = ['manhattan', 'skyline', 'golden-gate', 'alpine', 'flyover', 'planetarium', 'sumi-ocean', 'boat-lake'];
+const viewports = [{width: 100, height: 14}, {width: 50, height: 7}, {width: 24, height: 3}];
+const env = {FORCE_COLOR: '3'};
+await configureTerminalRenderer(env);
+const displays = [false, true].map(transparentBackground => resolveDisplayMode({transparentBackground}, env));
+const sink = Object.assign(new Writable({write(_chunk, _encoding, callback) { callback(); }}), {isTTY: true, columns: 100, rows: 30});
+const input = Object.assign(new PassThrough(), {isTTY: true, setRawMode: () => input});
+let rendered = 0;
+const view = render(null, {
+ stdout: sink, stderr: sink, stdin: input, interactive: true,
+ isScreenReaderEnabled: false,
+ patchConsole: false, exitOnCtrlC: false, maxFps: 100_000,
+ kittyKeyboard: {mode: 'disabled'}, onRender: () => { rendered++; }
+});
+async function renderFrame(style, pulse, profile) {
+ const {width, height} = viewports[profile % viewports.length];
+ const display = displays[profile % displays.length];
+ const rows = buildVisualizer(style, pulse, width, height, null, playback, profile % 2 ? 'mono' : 'amber', width === 24 ? 'micro' : 'standard');
+ view.rerender(React.createElement(DisplayContext.Provider, {value: display},
+ React.createElement(Box, {width, height, flexDirection: 'column', overflow: 'hidden', backgroundColor: display.panel},
+ rows.map((row, key) => React.createElement(ReceiverVisualRow, {key, row, width, ascii: profile % 2 === 1, backgroundColor: display.panel})))));
+ await view.waitUntilRenderFlush();
+}
+
+let result;
+try {
+ // Warm every style and viewport before measuring initialization/JIT separately
+ // from retention. Let React finish its work before collecting the heap.
+ for (const style of receiverStyleNames) {
+ for (let profile = 0; profile < 6; profile++) await renderFrame(style, 0, profile);
+ }
+ await settle();
+ global.gc();
+ const baseline = process.memoryUsage();
+ const baselineRendered = rendered;
+ const samples = [];
+ for (let index = 0; index < frames; index++) {
+ // Half the frames stress the two richest scenes at full size. The rest
+ // exercise style, viewport, palette, ASCII and background changes.
+ const full = index % 2 === 0;
+ await renderFrame(full ? scenes[index % 4 === 0 ? 0 : 1] : scenes[Math.floor(index / 2) % scenes.length], index + 1, full ? 0 : Math.floor(index / 7) % 6);
+ if ((index + 1) % 250 === 0) {
+ global.gc();
+ samples.push({frame: index + 1, ...process.memoryUsage()});
+ }
+ }
+ await settle();
+ global.gc();
+ const final = process.memoryUsage();
+ const heapGrowthBytes = final.heapUsed - baseline.heapUsed;
+ result = {node: process.version, platform: process.platform, arch: process.arch, runtime: process.env.NODE_ENV, frames, rendered: rendered - baselineRendered, baseline, final, heapGrowthBytes, performanceMeasures: performance.getEntriesByType('measure').length, samples};
+} finally {
+ view.unmount();
+ await view.waitUntilExit();
+ input.destroy();
+ sink.destroy();
+}
+console.log(JSON.stringify(result));
+assert(result.rendered >= frames, 'Every requested frame must actually render');
+assert(result.heapGrowthBytes < 8 * 1024 * 1024, `Retained heap grew by ${result.heapGrowthBytes} bytes (limit 8 MiB)`);
diff --git a/scripts/release-evidence.mjs b/scripts/release-evidence.mjs
index 1bdb3c0..972ba9f 100644
--- a/scripts/release-evidence.mjs
+++ b/scripts/release-evidence.mjs
@@ -4,7 +4,7 @@ import {existsSync, mkdirSync, readFileSync, writeFileSync} from 'node:fs';
import {join, resolve} from 'node:path';
import {fileURLToPath} from 'node:url';
-export const upgradeBaselines = ['0.2.3', '0.2.4'];
+export const upgradeBaselines = ['0.2.3', '0.2.4', '0.2.5'];
export function sourceIdentity(root, execute = spawnSync) {
const readGit = args => {
@@ -40,7 +40,7 @@ export function buildReleaseEvidence({candidate, normal, portable, audit, networ
const record = upgrades.find(item => item?.baseline === baseline);
if (record?.result !== 'passed' || record.tarballSha256 !== candidate?.tarballSha256 || JSON.stringify(record?.source) !== JSON.stringify(candidate?.source)
|| ['platform', 'architecture', 'node'].some(key => record?.[key] !== normal?.[key])
- || !['in-place-install', 'saved-library-preservation', 'all-supported-receivers', 'installed-renderers', 'retired-style-migration', 'old-process-live-reads-and-writes', 'background-polling'].every(check => record?.checks?.includes(check))) {
+ || !['in-place-install', 'saved-library-preservation', 'all-supported-receivers', 'all-supported-colors', 'installed-renderers', 'retired-style-migration', 'old-process-live-reads-and-writes', 'background-polling'].every(check => record?.checks?.includes(check))) {
reasons.push(`Missing matching successful upgrade evidence from ${baseline}.`);
}
}
diff --git a/scripts/release-evidence.test-node.mjs b/scripts/release-evidence.test-node.mjs
index b61ce84..0d56ce6 100644
--- a/scripts/release-evidence.test-node.mjs
+++ b/scripts/release-evidence.test-node.mjs
@@ -12,8 +12,8 @@ function complete() {
return {candidate, normal: {...installed, install: 'normal'}, portable: {...installed, install: 'omit-optional'}, audit: {status: 'passed', scope: 'required-runtime', sourceRevision: source.revision, arguments: ['--omit=dev', '--include=optional', '--audit-level=low']},
network: {result: 'passed', sourceRevision: source.revision, platform: installed.platform, architecture: installed.architecture, node: installed.node,
checks: {mpv_tls_rejection: 'passed: untrusted TLS', finite_eof: 'passed: stopped', mpv_disconnect: 'passed: recovered', mpv_stall: 'passed: recovered', mpv_nested_tls: 'passed: untrusted TLS'}},
- upgrades: ['0.2.3', '0.2.4'].map(baseline => ({...installed, baseline,
- checks: ['in-place-install', 'saved-library-preservation', 'all-supported-receivers', 'installed-renderers', 'retired-style-migration', 'old-process-live-reads-and-writes', 'background-polling']})),
+ upgrades: ['0.2.3', '0.2.4', '0.2.5'].map(baseline => ({...installed, baseline,
+ checks: ['in-place-install', 'saved-library-preservation', 'all-supported-receivers', 'all-supported-colors', 'installed-renderers', 'retired-style-migration', 'old-process-live-reads-and-writes', 'background-polling']})),
checks: ['typecheck', 'lint', 'tests', 'harness', 'build', 'package', 'native-tui', 'native-network', 'source-mcp', 'background-cli', 'packed'].map(name => ({name, status: 'passed'}))};
}
@@ -40,6 +40,7 @@ for (const [name, mutate] of [
['missing one upgrade baseline', data => { data.upgrades.pop(); }],
['stale upgrade artifact', data => { data.upgrades[0].tarballSha256 = 'd'.repeat(64); }],
['foreign upgrade runtime', data => { data.upgrades[0].platform = 'win32'; }],
+ ['missing color upgrade regression', data => { data.upgrades[0].checks = data.upgrades[0].checks.filter(check => check !== 'all-supported-colors'); }],
['missing old-process regression', data => { data.upgrades[0].checks = []; }],
['failed packed pipeline', data => { data.checks.find(check => check.name === 'packed').status = 'failed'; }],
['stale native network evidence', data => { data.network.sourceRevision = 'd'.repeat(40); }],
diff --git a/scripts/upgrade-smoke.mjs b/scripts/upgrade-smoke.mjs
index 206aa07..b9d284b 100644
--- a/scripts/upgrade-smoke.mjs
+++ b/scripts/upgrade-smoke.mjs
@@ -13,6 +13,7 @@ import {sha256, upgradeBaselines} from './release-evidence.mjs';
// even older releases without refresh() exercise their original schema.
const driver = `
const {JsonLibraryStore} = await import(process.argv[2]);
+const {receiverStyleNames, themeNames} = await import(new URL('../types.js', process.argv[2]).href);
const file = process.argv[3];
function details(error) {
return {message: error.message, code: error.code, syscall: error.syscall,
@@ -21,7 +22,8 @@ function details(error) {
process.on('message', ({id, method, args = []}) => {
try {
const store = new JsonLibraryStore(file);
- const result = method === 'snapshot' ? store.snapshot() : store[method](...args);
+ const result = method === 'choices' ? {receivers: receiverStyleNames, themes: themeNames}
+ : method === 'snapshot' ? store.snapshot() : store[method](...args);
process.send({id, result});
} catch (error) { process.send({id, error: details(error)}); }
});
@@ -94,6 +96,7 @@ export async function runUpgradeSmoke(tarball, {baseline, source = null, evidenc
writeFileSync(script, driver);
const old = storeProcess(script, module, file, env, `baseline ${baseline}`); clients.push(old);
await old.ready;
+ const legacyChoices = await old.call('choices');
const station = {id: 'upgrade-fixture', provider: 'playlist', name: 'Retained 日本 station', tags: ['upgrade'], streamUrl: 'https://example.invalid/upgrade'};
await old.call('toggleFavorite', station);
await old.call('addRecent', station);
@@ -114,31 +117,44 @@ export async function runUpgradeSmoke(tarball, {baseline, source = null, evidenc
const rendered = JSON.parse(runCommand(process.execPath, ['--input-type=module', '-e', `
import {createHash} from 'node:crypto';
const m = await import(process.argv[1]);
+ const {themeNames} = await import(new URL('../../types.js', process.argv[1]).href);
const {buildVisualizer} = await import(process.argv[2]);
const playback = {state:'playing', backend:'mpv', volume:70, muted:false, ready:true};
const hashes = m.receiverStyleNames.map(style => createHash('sha256').update(JSON.stringify(buildVisualizer(style, 37, 100, 14, null, playback, 'green'))).digest('hex'));
- console.log(JSON.stringify({names:m.receiverStyleNames, defaultStyle:m.defaultReceiverStyle, hashes}));
+ console.log(JSON.stringify({names:m.receiverStyleNames, defaultStyle:m.defaultReceiverStyle, themes:themeNames, hashes}));
`, pathToFileURL(join(packageRoot, 'dist', 'ui', 'visualizers', 'receiver-style-registry.js')).href,
pathToFileURL(join(packageRoot, 'dist', 'ui', 'visualizers', 'receiver-visualizers.js')).href], {cwd: project, env}).stdout);
const registry = rendered.names;
assert.equal(rendered.defaultStyle, 'ultracode');
assert.equal(registry[0], 'ultracode');
assert.equal(registry[8], 'gallop-fine');
- assert.equal(registry.length, 63);
- assert.deepEqual(registry.slice(-2), ['alpine', 'crossfade']);
+ assert.equal(registry.length, 64);
+ assert.deepEqual(registry.slice(-3), ['alpine', 'boat-lake', 'crossfade']);
assert.equal(rendered.hashes.length, registry.length);
for (const receiverStyle of registry) {
await candidate.call('updateSettings', {receiverStyle});
// Force both a legacy read and a legacy write, in addition to polling.
- assert.equal((await old.call('snapshot')).settings.receiverStyle, receiverStyle);
+ assert.equal((await old.call('snapshot')).settings.receiverStyle, legacyChoices.receivers.includes(receiverStyle) ? receiverStyle : 'ultracode');
await old.call('updateSettings', {volume: 41});
const retained = await candidate.call('snapshot');
assert.equal(retained.settings.receiverStyle, receiverStyle);
assert.equal(retained.settings.volume, 41);
for (const key of ['favorites', 'recent', 'trackHistory', 'searchHistory', 'alarms']) assert.deepEqual(retained[key], before[key], `Mixed-version writes lost ${key}.`);
}
+ await candidate.call('updateSettings', {receiverStyle: 'boat-lake'});
await delay(1200);
- assert.equal((await candidate.call('snapshot')).settings.receiverStyle, 'crossfade');
+ assert.equal((await candidate.call('snapshot')).settings.receiverStyle, 'boat-lake');
+ for (const theme of rendered.themes) {
+ await candidate.call('updateSettings', {theme});
+ assert.equal((await old.call('snapshot')).settings.theme, legacyChoices.themes.includes(theme) ? theme : 'green');
+ await old.call('updateSettings', {volume: 43});
+ const retained = await candidate.call('snapshot');
+ assert.equal(retained.settings.theme, theme);
+ assert.equal(retained.settings.receiverStyle, 'boat-lake');
+ assert.equal(retained.settings.volume, 43);
+ for (const key of ['favorites', 'recent', 'trackHistory', 'searchHistory', 'alarms']) assert.deepEqual(retained[key], before[key], `Mixed-version color writes lost ${key}.`);
+ }
+ await candidate.call('updateSettings', {theme: 'green'});
assert.equal(readdirSync(home).some(name => name.includes('.bad-')), false, 'An old process quarantined the shared library.');
await candidate.call('updateSettings', {receiverStyle: 'ultracode'});
assert.equal((await candidate.call('snapshot')).settings.receiverStyle, 'ultracode');
@@ -150,7 +166,7 @@ export async function runUpgradeSmoke(tarball, {baseline, source = null, evidenc
const evidence = {schemaVersion: 1, checkedAt: new Date().toISOString(), source, baseline, tarballSha256: sha256(tarball),
package: JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8')).version,
platform: process.platform, architecture: process.arch, node: process.version,
- checks: ['in-place-install', 'saved-library-preservation', 'legacy-style-preservation', 'canonical-style-order', 'all-supported-receivers', 'installed-renderers', 'retired-style-migration', 'old-process-live-reads-and-writes', 'background-polling', 'return-to-default'], result: 'passed'};
+ checks: ['in-place-install', 'saved-library-preservation', 'legacy-style-preservation', 'canonical-style-order', 'all-supported-receivers', 'all-supported-colors', 'installed-renderers', 'retired-style-migration', 'old-process-live-reads-and-writes', 'background-polling', 'return-to-default'], result: 'passed'};
if (evidencePath) { mkdirSync(dirname(evidencePath), {recursive: true}); writeFileSync(evidencePath, `${JSON.stringify(evidence, null, 2)}\n`); }
console.log(`upgrade_smoke=${JSON.stringify(evidence)}`);
return evidence;
diff --git a/src/cli-tui-runtime.test.ts b/src/cli-tui-runtime.test.ts
new file mode 100644
index 0000000..38cf927
--- /dev/null
+++ b/src/cli-tui-runtime.test.ts
@@ -0,0 +1,28 @@
+import {execFile} from 'node:child_process';
+import {fileURLToPath} from 'node:url';
+import {promisify} from 'node:util';
+import {describe, expect, it} from 'vitest';
+
+describe('TUI runtime bootstrap', () => {
+ for (const args of [[], ['agent-ui', 'fixture']]) {
+ it.each([undefined, 'development'])('selects React before importing JSX with NODE_ENV=%s', async nodeEnv => {
+ const env = {...process.env};
+ if (nodeEnv === undefined) delete env.NODE_ENV;
+ else env.NODE_ENV = nodeEnv;
+ const cli = fileURLToPath(new URL('./cli.tsx', import.meta.url));
+ // Non-TTY input stops before playback or storage opens. JSX still loads
+ // React, making this sensitive to setting NODE_ENV too late in bootstrap.
+ const code = `
+ import {pathToFileURL} from 'node:url';
+ process.argv = [process.execPath, ${JSON.stringify(cli)}, ...${JSON.stringify(args)}];
+ await import(pathToFileURL(process.argv[1]).href);
+ const React = await import('react');
+ process.exitCode = 0;
+ console.log('RUNTIME=' + JSON.stringify({env: process.env.NODE_ENV, development: typeof React.act === 'function'}));
+ `;
+ const {stdout} = await promisify(execFile)(process.execPath, ['--import', 'tsx', '--input-type=module', '-e', code], {env});
+ const runtime = JSON.parse(stdout.split('RUNTIME=')[1]!.trim());
+ expect(runtime).toEqual({env: nodeEnv ?? 'production', development: nodeEnv === 'development'});
+ });
+ }
+});
diff --git a/src/cli.tsx b/src/cli.tsx
index d4e5987..e3f424b 100644
--- a/src/cli.tsx
+++ b/src/cli.tsx
@@ -34,6 +34,10 @@ if (isDirectRun(process.argv[1], import.meta.url)) {
}
async function renderTui(encodedCommand?: string): Promise {
+ // React's development profiler retains per-frame timing entries in Node.
+ // Choose the production runtime before loading Ink or JSX; explicit developer
+ // environments still take precedence.
+ process.env.NODE_ENV ??= 'production';
const {renderTui: render} = await import('./cli/render-tui.js');
await render(printHelp, encodedCommand);
}
diff --git a/src/storage/architecture.test.ts b/src/storage/architecture.test.ts
index 0b9ada3..2263485 100644
--- a/src/storage/architecture.test.ts
+++ b/src/storage/architecture.test.ts
@@ -1,4 +1,4 @@
-import {mkdtempSync, mkdirSync, rmSync, utimesSync, writeFileSync} from 'node:fs';
+import {mkdtempSync, mkdirSync, readFileSync, rmSync, utimesSync, writeFileSync} from 'node:fs';
import {spawn} from 'node:child_process';
import {once} from 'node:events';
import {tmpdir} from 'node:os';
@@ -116,16 +116,35 @@ describe('station identity and fresh library reads', () => {
});
describe('asynchronous library repository', () => {
- it.each([true, false])('publishes receiver preference changes with worker=%s', async worker => {
+ it.each([true, false])('publishes display color preference changes with worker=%s', async worker => {
+ const path = file(); const writer = new JsonLibraryStore(path);
+ writer.updateSettings({theme: 'jade'});
+ const repository = new LibraryRepository(new JsonLibraryStore(path), {worker});
+ try {
+ await repository.readFresh();
+ writeFileSync(`${path}.theme.json`, JSON.stringify({version: 1, theme: 'pine', libraryTheme: 'green'}));
+ await expect.poll(() => repository.settings().theme, {timeout: 5000}).toBe('pine');
+ await repository.updateSettings({volume: 42});
+ expect(new JsonLibraryStore(path).settings()).toMatchObject({theme: 'pine', volume: 42});
+ expect(JSON.parse(readFileSync(path, 'utf8')).settings.theme).toBe('green');
+ } finally { await repository.close(); }
+ }, 10_000);
+
+ it.each([
+ {worker: true, suffix: 'receiver.json', receiverStyle: 'mesh'},
+ {worker: false, suffix: 'receiver.json', receiverStyle: 'mesh'},
+ {worker: true, suffix: 'receiver-v2.json', receiverStyle: 'boat-lake'},
+ {worker: false, suffix: 'receiver-v2.json', receiverStyle: 'boat-lake'}
+ ] as const)('publishes $suffix changes with worker=$worker', async ({worker, suffix, receiverStyle}) => {
const path = file(); const writer = new JsonLibraryStore(path);
writer.updateSettings({receiverStyle: 'ultracode'});
const repository = new LibraryRepository(new JsonLibraryStore(path), {worker});
try {
await repository.readFresh();
- writeFileSync(`${path}.receiver.json`, JSON.stringify({version: 1, receiverStyle: 'mesh', libraryReceiverStyle: 'ultracode'}));
- await expect.poll(() => repository.settings().receiverStyle, {timeout: 5000}).toBe('mesh');
+ writeFileSync(`${path}.${suffix}`, JSON.stringify({version: 1, receiverStyle, libraryReceiverStyle: 'ultracode'}));
+ await expect.poll(() => repository.settings().receiverStyle, {timeout: 5000}).toBe(receiverStyle);
await repository.updateSettings({volume: 42});
- expect(new JsonLibraryStore(path).settings()).toMatchObject({receiverStyle: 'mesh', volume: 42});
+ expect(new JsonLibraryStore(path).settings()).toMatchObject({receiverStyle, volume: 42});
} finally { await repository.close(); }
}, 10_000);
diff --git a/src/storage/file-lock.test.ts b/src/storage/file-lock.test.ts
index e43c621..ad07b83 100644
--- a/src/storage/file-lock.test.ts
+++ b/src/storage/file-lock.test.ts
@@ -3,6 +3,7 @@ import {mkdtempSync, mkdirSync, readdirSync, rmSync, utimesSync, writeFileSync}
import {randomUUID} from 'node:crypto';
import {tmpdir} from 'node:os';
import {join} from 'node:path';
+import {performance} from 'node:perf_hooks';
import {afterEach, describe, expect, it, vi} from 'vitest';
import {acquireFileLock} from './file-lock.js';
@@ -10,8 +11,111 @@ vi.mock('node:fs', async original => ({...await original { vi.restoreAllMocks(); for (const root of roots.splice(0)) rmSync(root, {recursive: true, force: true}); });
function fixture() { const root = mkdtempSync(join(tmpdir(), 'radiocli-lock-')); roots.push(root); return join(root, 'library.lock'); }
+function simulatedWait() {
+ let elapsed = 0;
+ vi.spyOn(performance, 'now').mockImplementation(() => elapsed);
+ return vi.spyOn(Atomics, 'wait').mockImplementation((_array, _index, _value, timeout) => {
+ elapsed += timeout ?? 0;
+ return 'timed-out';
+ });
+}
describe('library writer ownership', () => {
+ for (const operation of ['mkdirSync', 'readdirSync'] as const) {
+ it.each(['EPERM', 'EACCES', 'EBUSY'])(`retries transient Windows %s during ${operation} before taking ownership`, code => {
+ const directory = fixture();
+ if (operation === 'readdirSync') mkdirSync(directory);
+ const failure = Object.assign(new Error('previous directory is pending deletion'), {code});
+ const attempt = vi.spyOn(fs, operation)
+ .mockImplementationOnce(() => { throw failure; })
+ .mockImplementationOnce(() => { throw failure; });
+ if (operation === 'readdirSync') attempt.mockImplementationOnce(() => {
+ // The other writer finishes releasing its legacy lock between retries.
+ rmSync(directory, {recursive: true});
+ return [];
+ });
+ const wait = simulatedWait();
+ const release = acquireFileLock(directory, undefined, 'win32');
+ expect(attempt).toHaveBeenCalledTimes(3);
+ expect(wait).toHaveBeenCalled();
+ expect(readdirSync(directory)).toHaveLength(1);
+ expect(readdirSync(directory)[0]).toMatch(new RegExp(`^owner-${process.pid}-`));
+ release();
+ expect(fs.existsSync(directory)).toBe(false);
+ });
+
+ it.each(['EPERM', 'EACCES', 'EBUSY'])(`preserves persistent Windows %s from ${operation} at the original deadline`, code => {
+ const directory = fixture();
+ const owner = `owner-${process.pid}-${randomUUID()}`;
+ if (operation === 'readdirSync') { mkdirSync(directory); writeFileSync(join(directory, owner), ''); }
+ const failure = Object.assign(new Error('permission denied'), {code});
+ const attempt = vi.spyOn(fs, operation).mockImplementation(() => { throw failure; });
+ const wait = simulatedWait();
+ let reported: unknown;
+ try { acquireFileLock(directory, undefined, 'win32'); } catch (error) { reported = error; }
+ expect(reported).toBe(failure);
+ expect(attempt).toHaveBeenCalledTimes(101);
+ expect(wait.mock.calls.reduce((total, call) => total + (call[3] ?? 0), 0)).toBe(1000);
+ attempt.mockRestore();
+ if (operation === 'readdirSync') expect(readdirSync(directory)).toEqual([owner]);
+ else expect(fs.existsSync(directory)).toBe(false);
+ });
+
+ it.each([['linux', 'EPERM'], ['darwin', 'EACCES'], ['win32', 'EIO'], ['win32', 'ENOSPC']] as const)(
+ `immediately reports %s %s from ${operation}`, (platform, code) => {
+ const directory = fixture();
+ if (operation === 'readdirSync') mkdirSync(directory);
+ const failure = Object.assign(new Error('filesystem failure'), {code});
+ const attempt = vi.spyOn(fs, operation).mockImplementation(() => { throw failure; });
+ const wait = simulatedWait();
+ expect(() => acquireFileLock(directory, undefined, platform)).toThrow(failure);
+ expect(attempt).toHaveBeenCalledTimes(1);
+ expect(wait).not.toHaveBeenCalled();
+ }
+ );
+ }
+
+ it('does not retry Windows owner-marker failures after creating the directory', () => {
+ const directory = fixture();
+ const failure = Object.assign(new Error('marker denied'), {code: 'EPERM'});
+ const write = vi.spyOn(fs, 'writeFileSync').mockImplementation(() => { throw failure; });
+ const wait = simulatedWait();
+ expect(() => acquireFileLock(directory, undefined, 'win32')).toThrow(failure);
+ expect(write).toHaveBeenCalledTimes(1);
+ expect(wait).not.toHaveBeenCalled();
+ expect(fs.existsSync(directory)).toBe(false);
+ });
+
+ it('still protects a live owner after transient Windows inspection denial', () => {
+ const directory = fixture(); const release = acquireFileLock(directory);
+ const original = readdirSync(directory);
+ vi.spyOn(fs, 'readdirSync').mockImplementationOnce(() => { throw Object.assign(new Error('pending access'), {code: 'EPERM'}); });
+ simulatedWait();
+ expect(() => acquireFileLock(directory, 20, 'win32')).toThrow(expect.objectContaining({code: 'EBUSY'}));
+ expect(readdirSync(directory)).toEqual(original);
+ release();
+ });
+
+ it('rechecks ownership after a Windows denial while claiming a dead generation', () => {
+ const directory = fixture(); mkdirSync(directory);
+ const dead = `owner-12345-${randomUUID()}`;
+ const alive = `owner-${process.pid}-${randomUUID()}`;
+ writeFileSync(join(directory, dead), '');
+ vi.spyOn(process, 'kill').mockImplementation(pid => {
+ if (pid === 12345) throw Object.assign(new Error('dead'), {code: 'ESRCH'});
+ return true;
+ });
+ const rename = vi.spyOn(fs, 'renameSync').mockImplementationOnce(() => {
+ fs.unlinkSync(join(directory, dead));
+ writeFileSync(join(directory, alive), '');
+ throw Object.assign(new Error('pending access'), {code: 'EPERM'});
+ });
+ simulatedWait();
+ expect(() => acquireFileLock(directory, 20, 'win32')).toThrow(expect.objectContaining({code: 'EBUSY'}));
+ expect(rename).toHaveBeenCalledTimes(1);
+ expect(readdirSync(directory)).toEqual([alive]);
+ });
+
it('releases its marker after a partial owner-marker write fails', () => {
const directory = fixture();
const write = fs.writeFileSync;
diff --git a/src/storage/file-lock.ts b/src/storage/file-lock.ts
index 77fb3ef..d11b7fc 100644
--- a/src/storage/file-lock.ts
+++ b/src/storage/file-lock.ts
@@ -6,13 +6,30 @@ import {performance} from 'node:perf_hooks';
/** An owner is never evicted for being slow. Only a positively dead PID or an
* explicitly released generation can be reclaimed. Unknown/legacy locks fail
* closed; their age cannot distinguish a crashed writer from a suspended one. */
-export function acquireFileLock(directory: string, timeoutMs = 1000): () => void {
+export function acquireFileLock(directory: string, timeoutMs = 1000, platform: NodeJS.Platform = process.platform): () => void {
const marker = `owner-${process.pid}-${randomUUID()}`;
const deadline = performance.now() + timeoutMs;
+ const pause = new Int32Array(new SharedArrayBuffer(4));
+ const retry = (error?: unknown): void => {
+ if (performance.now() >= deadline) {
+ if (error) throw error;
+ throw Object.assign(new Error('The library lock has a live or unknown owner.'), {code: 'EBUSY'});
+ }
+ Atomics.wait(pause, 0, 0, 10);
+ };
+ // Windows can briefly deny access while a previous lock directory is pending
+ // deletion. Retry only before ownership, without treating denial as absence.
+ const transient = (error: unknown): boolean => platform === 'win32' && ['EACCES', 'EPERM', 'EBUSY'].includes(codeOf(error) ?? '');
while (true) {
let acquired = false;
try { mkdirSync(directory, {mode: 0o700}); acquired = true; }
- catch (error) { if (codeOf(error) !== 'EEXIST') throw error; }
+ catch (error) {
+ if (codeOf(error) !== 'EEXIST') {
+ if (!transient(error)) throw error;
+ retry(error);
+ continue;
+ }
+ }
if (acquired) {
try { writeFileSync(join(directory, marker), '', {mode: 0o600, flag: 'wx'}); }
catch (error) {
@@ -37,11 +54,14 @@ export function acquireFileLock(directory: string, timeoutMs = 1000): () => void
renameSync(join(directory, owner), join(directory, reaper));
finishLock(directory, reaper);
}
- } catch (error) { if (codeOf(error) !== 'ENOENT') throw error; }
- if (performance.now() >= deadline) {
- throw Object.assign(new Error('The library lock has a live or unknown owner.'), {code: 'EBUSY'});
+ } catch (error) {
+ if (codeOf(error) !== 'ENOENT') {
+ if (!transient(error)) throw error;
+ retry(error);
+ continue;
+ }
}
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10);
+ retry();
}
}
diff --git a/src/storage/store.test.ts b/src/storage/store.test.ts
index 8ab6b3d..e570acd 100644
--- a/src/storage/store.test.ts
+++ b/src/storage/store.test.ts
@@ -1025,7 +1025,8 @@ describe('JsonLibraryStore', () => {
for (const receiverStyle of receiverStyleNames) {
store.updateSettings({receiverStyle});
const legacy = JSON.parse(readFileSync(file, 'utf8'));
- expect(legacy.settings.receiverStyle).toBe(receiverStyle);
+ expect(legacy.settings.receiverStyle).toBe(receiverStyle === 'boat-lake' ? 'ultracode' : receiverStyle);
+ expect(existsSync(`${file}.receiver.json`)).toBe(false);
// Old stores rewrite only the fields they know, leaving the sidecar alone.
legacy.settings.volume = 39;
writeFileSync(file, JSON.stringify(legacy));
@@ -1034,10 +1035,70 @@ describe('JsonLibraryStore', () => {
}
store.updateSettings({receiverStyle: 'ultracode'});
expect(existsSync(`${file}.receiver.json`)).toBe(false);
+ expect(existsSync(`${file}.receiver-v2.json`)).toBe(false);
expect(observer.snapshot().settings.receiverStyle).toBe('ultracode');
expect(readdirSync(root).some(name => name.includes('.bad-'))).toBe(false);
}, 20_000);
+ it('keeps Boat Lake out of the 0.2.5 preference namespace and honors explicit legacy selections', () => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ const writer = new JsonLibraryStore(file);
+ writer.toggleFavorite(exampleAlarm().station);
+ writeFileSync(`${file}.receiver.json`, JSON.stringify({version: 1, receiverStyle: 'mesh', libraryReceiverStyle: 'ultracode'}));
+ writer.updateSettings({receiverStyle: 'boat-lake'});
+ expect(existsSync(`${file}.receiver.json`)).toBe(false);
+ expect(JSON.parse(readFileSync(`${file}.receiver-v2.json`, 'utf8'))).toEqual({version: 1, receiverStyle: 'boat-lake', libraryReceiverStyle: 'ultracode'});
+ const legacy = JSON.parse(readFileSync(file, 'utf8'));
+ expect(legacy.settings.receiverStyle).toBe('ultracode');
+ const observer = new JsonLibraryStore(file);
+ legacy.settings.volume = 39;
+ writeFileSync(file, JSON.stringify(legacy));
+ expect(observer.settings()).toMatchObject({receiverStyle: 'boat-lake', volume: 39});
+ const backup = writer.exportBackup(join(root, 'backup.json'));
+ expect(JSON.parse(readFileSync(backup, 'utf8')).library.settings.receiverStyle).toBe('boat-lake');
+ legacy.settings.receiverStyle = 'galaxy';
+ writeFileSync(file, JSON.stringify(legacy));
+ expect(observer.settings().receiverStyle).toBe('galaxy');
+ writer.updateSettings({volume: 40});
+ expect(existsSync(`${file}.receiver-v2.json`)).toBe(false);
+ expect(observer.settings().receiverStyle).toBe('galaxy');
+ writer.importBackup(backup);
+ expect(observer.settings().receiverStyle).toBe('boat-lake');
+ expect(observer.snapshot().favorites).toHaveLength(1);
+ });
+
+ it('moves a preview Boat Lake preference out of the legacy namespace on opening', () => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ new JsonLibraryStore(file).toggleFavorite(exampleAlarm().station);
+ writeFileSync(`${file}.receiver.json`, JSON.stringify({version: 1, receiverStyle: 'boat-lake', libraryReceiverStyle: 'ultracode'}));
+ const store = new JsonLibraryStore(file);
+ expect(store.settings().receiverStyle).toBe('boat-lake');
+ expect(existsSync(`${file}.receiver.json`)).toBe(false);
+ expect(JSON.parse(readFileSync(`${file}.receiver-v2.json`, 'utf8')).receiverStyle).toBe('boat-lake');
+ expect(JSON.parse(readFileSync(file, 'utf8')).settings.receiverStyle).toBe('ultracode');
+ expect(store.snapshot().favorites).toHaveLength(1);
+ });
+
+ it('refreshes changes confined to the new preference and prefers it over a stale legacy file', () => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ const store = new JsonLibraryStore(file);
+ store.updateSettings({receiverStyle: 'ultracode'});
+ writeFileSync(`${file}.receiver-v2.json`, JSON.stringify({version: 1, receiverStyle: 'boat-lake', libraryReceiverStyle: 'ultracode'}));
+ expect(store.settings().receiverStyle).toBe('boat-lake');
+ writeFileSync(`${file}.receiver.json`, JSON.stringify({version: 1, receiverStyle: 'mesh', libraryReceiverStyle: 'ultracode'}));
+ expect(store.settings().receiverStyle).toBe('boat-lake');
+ store.updateSettings({volume: 40});
+ expect(existsSync(`${file}.receiver.json`)).toBe(false);
+ rmSync(`${file}.receiver-v2.json`);
+ expect(store.settings().receiverStyle).toBe('ultracode');
+ });
+
it('refreshes receiver-only changes and exports and restores the actual selection', () => {
const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
roots.push(root);
@@ -1082,7 +1143,7 @@ describe('JsonLibraryStore', () => {
expect(readdirSync(root).some(name => name.includes('.bad-'))).toBe(false);
});
- it.each(['mesh', 'galaxy', 'ultracode'] as const)('rolls back a legacy receiver preference if the library replacement fails (%s)', receiverStyle => {
+ it.each(['mesh', 'galaxy', 'ultracode', 'boat-lake'] as const)('rolls back a legacy receiver preference if the library replacement fails (%s)', receiverStyle => {
const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
roots.push(root);
const file = join(root, 'library.json');
@@ -1099,10 +1160,11 @@ describe('JsonLibraryStore', () => {
expect(() => store.updateSettings({receiverStyle, volume: 40})).toThrow(/write/);
expect(readFileSync(file, 'utf8')).toBe(library);
expect(readFileSync(`${file}.receiver.json`, 'utf8')).toBe(preference);
+ expect(existsSync(`${file}.receiver-v2.json`)).toBe(false);
expect(store.settings().receiverStyle).toBe('mesh');
});
- it('preserves the library when a newer receiver preference is unsupported', () => {
+ it.each(['receiver.json', 'receiver-v2.json'])('preserves the library when %s contains an unsupported receiver', suffix => {
const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
roots.push(root);
const file = join(root, 'library.json');
@@ -1110,13 +1172,31 @@ describe('JsonLibraryStore', () => {
store.updateSettings({receiverStyle: 'ultracode'});
const library = readFileSync(file, 'utf8');
const preference = JSON.stringify({version: 1, receiverStyle: 'future-scene', libraryReceiverStyle: 'ultracode'});
- writeFileSync(`${file}.receiver.json`, preference);
+ writeFileSync(`${file}.${suffix}`, preference);
expect(() => store.updateSettings({volume: 25})).toThrow(/library has been preserved/);
expect(readFileSync(file, 'utf8')).toBe(library);
- expect(readFileSync(`${file}.receiver.json`, 'utf8')).toBe(preference);
+ expect(readFileSync(`${file}.${suffix}`, 'utf8')).toBe(preference);
expect(readdirSync(root).some(name => name.includes('.bad-'))).toBe(false);
});
+ it.each(['boat-lake', 'ultracode'] as const)('rolls back both new appearance preferences after a failed library save (%s)', receiverStyle => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ const store = new JsonLibraryStore(file);
+ store.updateSettings({receiverStyle: 'boat-lake', theme: 'jade'});
+ const paths = [file, `${file}.receiver-v2.json`, `${file}.theme.json`];
+ const before = paths.map(path => readFileSync(path, 'utf8'));
+ const rename = fs.renameSync;
+ vi.spyOn(fs, 'renameSync').mockImplementation((from, to) => {
+ if (to === file) throw Object.assign(new Error('replacement failed'), {code: 'EIO'});
+ return rename(from, to);
+ });
+ expect(() => store.updateSettings({receiverStyle, theme: 'pine'})).toThrow(/write/);
+ expect(paths.map(path => readFileSync(path, 'utf8'))).toEqual(before);
+ expect(store.settings()).toMatchObject({receiverStyle: 'boat-lake', theme: 'jade'});
+ });
+
it('persists every display color exposed by the UI cycle', () => {
const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
roots.push(root);
@@ -1129,6 +1209,119 @@ describe('JsonLibraryStore', () => {
}
});
+ it('preserves all display colors and favorites when legacy playback writers save', () => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ // Freeze the enum understood by already-running pre-palette processes.
+ const legacyThemes = ['green', 'amber', 'blue', 'ruby', 'ice', 'teal', 'violet', 'copper', 'cyan', 'lime', 'coral', 'rose', 'slate', 'mono'];
+ const writer = new JsonLibraryStore(file);
+ writer.toggleFavorite(exampleAlarm().station);
+ const observer = new JsonLibraryStore(file);
+ for (const theme of themeNames) {
+ writer.updateSettings({theme});
+ const legacy = JSON.parse(readFileSync(file, 'utf8'));
+ expect(legacyThemes, theme).toContain(legacy.settings.theme);
+ legacy.settings.volume = 39;
+ writeFileSync(file, JSON.stringify(legacy));
+ expect(observer.snapshot().settings).toMatchObject({theme, volume: 39});
+ expect(observer.snapshot().favorites).toHaveLength(1);
+ }
+ writer.updateSettings({theme: 'amber'});
+ expect(existsSync(`${file}.theme.json`)).toBe(false);
+ expect(observer.settings().theme).toBe('amber');
+ expect(readdirSync(root).some(name => name.includes('.bad-'))).toBe(false);
+ });
+
+ it('normalizes an inline preview color before legacy readers see it again', () => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ const original = new JsonLibraryStore(file).toggleFavorite(exampleAlarm().station);
+ writeFileSync(file, JSON.stringify({...original, settings: {...original.settings, theme: 'jade'}}));
+ expect(new JsonLibraryStore(file).settings().theme).toBe('jade');
+ expect(JSON.parse(readFileSync(file, 'utf8')).settings.theme).toBe('green');
+ expect(new JsonLibraryStore(file).snapshot().favorites).toHaveLength(1);
+ });
+
+ it('refreshes theme-only changes and backs up the actual selection', () => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ const writer = new JsonLibraryStore(file);
+ writer.updateSettings({theme: 'jade'});
+ const observer = new JsonLibraryStore(file);
+ const backup = writer.exportBackup(join(root, 'backup.json'));
+ expect(JSON.parse(readFileSync(backup, 'utf8')).library.settings.theme).toBe('jade');
+ writeFileSync(`${file}.theme.json`, JSON.stringify({version: 1, theme: 'pine', libraryTheme: 'green'}));
+ expect(observer.settings().theme).toBe('pine');
+ writer.importBackup(backup);
+ expect(observer.settings().theme).toBe('jade');
+ // An explicit legacy selection takes precedence over a stale preference.
+ const legacy = JSON.parse(readFileSync(file, 'utf8'));
+ legacy.settings.theme = 'blue';
+ writeFileSync(file, JSON.stringify(legacy));
+ expect(observer.settings().theme).toBe('blue');
+ });
+
+ it.each(['jade', 'cobalt', 'amber'] as const)('rolls back the display color when the library save fails (%s)', theme => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ const store = new JsonLibraryStore(file);
+ store.updateSettings({theme: 'jade'});
+ const library = readFileSync(file, 'utf8');
+ const preference = readFileSync(`${file}.theme.json`, 'utf8');
+ const rename = fs.renameSync;
+ vi.spyOn(fs, 'renameSync').mockImplementation((from, to) => {
+ if (to === file) throw Object.assign(new Error('replacement failed'), {code: 'EIO'});
+ return rename(from, to);
+ });
+ expect(() => store.updateSettings({theme, volume: 40})).toThrow(/write/);
+ expect(readFileSync(file, 'utf8')).toBe(library);
+ expect(readFileSync(`${file}.theme.json`, 'utf8')).toBe(preference);
+ expect(store.settings().theme).toBe('jade');
+ });
+
+ it.each(['library', 'preference'])('preserves data when a future display color is unsupported in the %s', location => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ const store = new JsonLibraryStore(file);
+ store.toggleFavorite(exampleAlarm().station);
+ if (location === 'library') {
+ const library = JSON.parse(readFileSync(file, 'utf8'));
+ library.settings.theme = 'future-color';
+ writeFileSync(file, JSON.stringify(library));
+ } else {
+ writeFileSync(`${file}.theme.json`, JSON.stringify({version: 1, theme: 'future-color', libraryTheme: 'green'}));
+ }
+ const library = readFileSync(file, 'utf8');
+ expect(() => store.updateSettings({volume: 25})).toThrow(/display color/);
+ expect(readFileSync(file, 'utf8')).toBe(library);
+ expect(readdirSync(root).some(name => name.includes('.bad-'))).toBe(false);
+ });
+
+ it.each(['ultracode', 'boat-lake'] as const)('restores receiver preferences when saving a display color preference fails (%s)', receiverStyle => {
+ const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
+ roots.push(root);
+ const file = join(root, 'library.json');
+ new JsonLibraryStore(file).updateSettings({theme: 'jade', receiverStyle: 'ultracode'});
+ writeFileSync(`${file}.receiver.json`, JSON.stringify({version: 1, receiverStyle: 'mesh', libraryReceiverStyle: 'ultracode'}));
+ const store = new JsonLibraryStore(file);
+ const paths = [file, `${file}.receiver.json`, `${file}.theme.json`];
+ const before = paths.map(path => readFileSync(path, 'utf8'));
+ const rename = fs.renameSync;
+ vi.spyOn(fs, 'renameSync').mockImplementation((from, to) => {
+ if (to === `${file}.theme.json`) throw Object.assign(new Error('replacement failed'), {code: 'EIO'});
+ return rename(from, to);
+ });
+ expect(() => store.updateSettings({theme: 'cobalt', receiverStyle})).toThrow(/write/);
+ expect(paths.map(path => readFileSync(path, 'utf8'))).toEqual(before);
+ expect(existsSync(`${file}.receiver-v2.json`)).toBe(false);
+ expect(store.settings()).toMatchObject({theme: 'jade', receiverStyle: 'mesh'});
+ });
+
it('uses the new RADIOCLI_HOME override', () => {
const root = mkdtempSync(join(tmpdir(), 'radiocli-'));
roots.push(root);
diff --git a/src/storage/store.ts b/src/storage/store.ts
index 6e3a9bf..94c0be1 100644
--- a/src/storage/store.ts
+++ b/src/storage/store.ts
@@ -36,16 +36,36 @@ const defaultMediaKeys = {
const MAX_ALARMS = 500;
-// Keep the shared library readable by pre-scene releases whose background MCP
-// workers quarantine an entire library when they see an unfamiliar enum value.
-// Crossfade is the last style understood by those releases. New styles live in
-// a separate preference file that old writers never read or overwrite.
-const sharedLibraryReceiverStyles = new Set(receiverStyleNames.slice(0, receiverStyleNames.indexOf('crossfade') + 1));
+// Freeze the 0.2.5 enum independently of UI ordering. New styles must stay out
+// of both its shared library and its strictly validated .receiver.json sidecar.
+// The new namespace is ignored by old playback/MCP readers and writers.
+const sharedLibraryReceiverStyles = new Set([
+ 'ultracode', 'pulse-grid', 'hex-pulse', 'moire', 'galaxy', 'cyclone', 'nebula', 'lava-lamp',
+ 'gallop-fine', 'motion-contour', 'ribbon', 'braille-wave', 'silk', 'lissajous', 'harmonograph',
+ 'spirograph', 'goniometer', 'radial-eq', 'spectrogram', 'caustics', 'ripple-tank', 'leds',
+ 'matrix', 'cascade', 'ordered-dither', 'xor-texture', 'pixel-crush', 'copper-bars',
+ 'rotozoomer', 'mesh', 'hologram', 'equalizer', 'tunnel', 'kaleidoscope', 'phosphene',
+ 'phyllotaxis', 'chladni', 'newton', 'cube', 'spinning-donut', 'tesseract', 'torus-knot',
+ 'twister', 'lorenz', 'fern', 'fractal-tree', 'julia', 'neural-net', 'constellation',
+ 'starfield', 'fireworks', 'fire', 'aurora', 'stormfront', 'planetarium', 'sumi-ocean',
+ 'liftoff', 'flyover', 'skyline', 'golden-gate', 'manhattan', 'alpine', 'crossfade'
+]);
const receiverPreferenceSchema = z.object({
version: z.literal(1),
receiverStyle: z.preprocess(migrateReceiverStyle, z.enum(receiverStyleNames)),
libraryReceiverStyle: z.literal('ultracode')
});
+// Older playback/MCP processes validate this original enum on every refresh.
+// New colors must stay out of their shared JSON, even after unrelated saves.
+const sharedLibraryThemes = new Set([
+ 'green', 'amber', 'blue', 'ruby', 'ice', 'teal', 'violet', 'copper',
+ 'cyan', 'lime', 'coral', 'rose', 'slate', 'mono'
+]);
+const themePreferenceSchema = z.object({
+ version: z.literal(1),
+ theme: z.enum(themeNames),
+ libraryTheme: z.literal('green')
+});
const settingsSchema: z.ZodType = z.object({
theme: z.enum(themeNames).default('green'),
@@ -290,7 +310,10 @@ export class JsonLibraryStore {
this.state = this.read();
// Normalize libraries saved by an earlier preview before any legacy
// background reader encounters its new enum value again.
- if (!sharedLibraryReceiverStyles.has(this.state.settings.receiverStyle) && !existsSync(this.receiverPreferencePath())) this.commit(this.state);
+ if (
+ (!sharedLibraryReceiverStyles.has(this.state.settings.receiverStyle) && !existsSync(this.receiverPreferenceV2Path())) ||
+ (!sharedLibraryThemes.has(this.state.settings.theme) && !existsSync(this.themePreferencePath()))
+ ) this.commit(this.state);
}
snapshot(): LibraryState {
@@ -318,7 +341,7 @@ export class JsonLibraryStore {
}
private diskRevision(): string {
- return [this.filePath, this.receiverPreferencePath()].map(file => {
+ return [this.filePath, this.receiverPreferencePath(), this.receiverPreferenceV2Path(), this.themePreferencePath()].map(file => {
try {
const info = statSync(file, {bigint: true});
return `${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}`;
@@ -710,11 +733,11 @@ export class JsonLibraryStore {
} catch (error) {
if (error instanceof z.ZodError && error.issues.some(issue =>
issue.code === 'invalid_value' && issue.path.length === 2 &&
- issue.path[0] === 'settings' && issue.path[1] === 'receiverStyle'
+ issue.path[0] === 'settings' && (issue.path[1] === 'receiverStyle' || issue.path[1] === 'theme')
)) {
- // Another running build may have saved a newer receiver. Its library
+ // Another running build may have saved a newer appearance. Its library
// is intact: never quarantine it or replace it with empty defaults.
- throw new Error('The RadioCLI library uses a receiver style this process does not support. Restart RadioCLI and its MCP clients to load the updated styles.');
+ throw new Error('The RadioCLI library uses a display color or receiver style this process does not support. Restart RadioCLI and its MCP clients to load the updated colors and styles.');
}
try {
assertStorageWritable(this.filePath);
@@ -727,20 +750,40 @@ export class JsonLibraryStore {
}
// A legacy writer can still change ordinary preferences and favorites. Its
// fallback style must not erase the selection saved by an updated process.
+ // The newer namespace wins over a leftover preview preference. Continue
+ // reading the old namespace when no newer selection has been saved.
+ for (const path of [this.receiverPreferenceV2Path(), this.receiverPreferencePath()]) {
+ let preference: string;
+ try { preference = readFileSync(path, 'utf8'); }
+ catch (error) {
+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;
+ throw storageError('read the receiver preference', error);
+ }
+ const parsed = receiverPreferenceSchema.safeParse(JSON.parse(preference));
+ if (!parsed.success) throw new Error('The RadioCLI receiver preference is unsupported or invalid. Restart RadioCLI and its MCP clients with the latest version. Your library has been preserved.');
+ if (state.settings.receiverStyle === parsed.data.libraryReceiverStyle) state.settings.receiverStyle = parsed.data.receiverStyle;
+ break;
+ }
+ return this.readThemePreference(state);
+ }
+
+ private receiverPreferencePath(): string { return `${this.filePath}.receiver.json`; }
+ private receiverPreferenceV2Path(): string { return `${this.filePath}.receiver-v2.json`; }
+ private themePreferencePath(): string { return `${this.filePath}.theme.json`; }
+
+ private readThemePreference(state: LibraryState): LibraryState {
let preference: string;
- try { preference = readFileSync(this.receiverPreferencePath(), 'utf8'); }
+ try { preference = readFileSync(this.themePreferencePath(), 'utf8'); }
catch (error) {
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return state;
- throw storageError('read the receiver preference', error);
+ throw storageError('read the display color preference', error);
}
- const parsed = receiverPreferenceSchema.safeParse(JSON.parse(preference));
- if (!parsed.success) throw new Error('The RadioCLI receiver preference is unsupported or invalid. Restart RadioCLI and its MCP clients with the latest version. Your library has been preserved.');
- if (state.settings.receiverStyle === parsed.data.libraryReceiverStyle) state.settings.receiverStyle = parsed.data.receiverStyle;
+ const parsed = themePreferenceSchema.safeParse(JSON.parse(preference));
+ if (!parsed.success) throw new Error('The RadioCLI display color preference is unsupported or invalid. Restart RadioCLI and its MCP clients with the latest version. Your library has been preserved.');
+ if (state.settings.theme === parsed.data.libraryTheme) state.settings.theme = parsed.data.theme;
return state;
}
- private receiverPreferencePath(): string { return `${this.filePath}.receiver.json`; }
-
private readForCurrentSession(): LibraryState {
const next = this.read();
// Disk intentionally stores auto instead of reopening a receiver on launch.
@@ -770,26 +813,46 @@ export class JsonLibraryStore {
mkdirSync(dirname(this.filePath), {recursive: true, mode: 0o700});
const diskState = libraryStateForDisk(state);
const separateReceiver = !sharedLibraryReceiverStyles.has(state.settings.receiverStyle);
- const preferencePath = this.receiverPreferencePath();
- let previousPreference: string | undefined;
- try { previousPreference = readFileSync(preferencePath, 'utf8'); }
- catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }
- const nextPreference = separateReceiver
- ? `${JSON.stringify({version: 1, receiverStyle: state.settings.receiverStyle, libraryReceiverStyle: 'ultracode'}, null, 2)}\n`
- : undefined;
- const preferenceChanged = previousPreference !== nextPreference;
- if (preferenceChanged) {
- if (nextPreference === undefined) rmSync(preferencePath);
- else writeTextAtomically(preferencePath, nextPreference);
- }
+ const separateTheme = !sharedLibraryThemes.has(state.settings.theme);
+ const preferences = [
+ {
+ path: this.receiverPreferenceV2Path(),
+ next: separateReceiver
+ ? `${JSON.stringify({version: 1, receiverStyle: state.settings.receiverStyle, libraryReceiverStyle: 'ultracode'}, null, 2)}\n`
+ : undefined
+ },
+ {path: this.receiverPreferencePath(), next: undefined},
+ {
+ path: this.themePreferencePath(),
+ next: separateTheme
+ ? `${JSON.stringify({version: 1, theme: state.settings.theme, libraryTheme: 'green'}, null, 2)}\n`
+ : undefined
+ }
+ ].map(preference => {
+ let previous: string | undefined;
+ try { previous = readFileSync(preference.path, 'utf8'); }
+ catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }
+ return {...preference, previous};
+ }).filter(preference => preference.previous !== preference.next);
+ const applied: typeof preferences = [];
try {
- writeJsonAtomically(this.filePath, separateReceiver
- ? {...diskState, settings: {...diskState.settings, receiverStyle: 'ultracode'}}
- : diskState);
+ for (const preference of preferences) {
+ if (preference.next === undefined) rmSync(preference.path);
+ else writeTextAtomically(preference.path, preference.next);
+ applied.push(preference);
+ }
+ writeJsonAtomically(this.filePath, {
+ ...diskState,
+ settings: {
+ ...diskState.settings,
+ ...(separateReceiver ? {receiverStyle: 'ultracode'} : {}),
+ ...(separateTheme ? {theme: 'green'} : {})
+ }
+ });
} catch (error) {
- if (preferenceChanged) {
- if (previousPreference === undefined) rmSync(preferencePath, {force: true});
- else writeTextAtomically(preferencePath, previousPreference);
+ for (const preference of applied.reverse()) {
+ if (preference.previous === undefined) rmSync(preference.path, {force: true});
+ else writeTextAtomically(preference.path, preference.previous);
}
throw error;
}
diff --git a/src/types.ts b/src/types.ts
index 323aa38..d3646e2 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -7,7 +7,28 @@ import {
export {defaultReceiverStyle, receiverStyleNames};
const providerIds = ['radio-browser', 'radio-garden', 'playlist'] as const;
-export const themeNames = ['green', 'amber', 'blue', 'ruby', 'ice', 'teal', 'violet', 'copper', 'cyan', 'lime', 'coral', 'rose', 'slate', 'mono'] as const;
+export const themeNames = [
+ // Reds
+ 'vermilion', 'scarlet',
+ // Oranges and earth tones
+ 'cocoa', 'copper', 'tangerine', 'blaze-orange', 'coral', 'apricot',
+ // Golds and creams
+ 'bronze', 'amber', 'sunflower', 'butter', 'parchment', 'ivory',
+ // Yellow greens
+ 'olive', 'lime', 'chartreuse', 'acid-yellow', 'pistachio',
+ // Greens
+ 'pine', 'laser-green', 'green',
+ // Teals and cyans
+ 'midnight-teal', 'jade', 'teal', 'cyan', 'ice',
+ // Blues
+ 'cobalt', 'blue', 'slate', 'periwinkle', 'ultramarine', 'indigo',
+ // Purples and mauves
+ 'neon-violet', 'violet', 'aubergine', 'plum', 'heather', 'dusty-mauve',
+ // Magentas and pinks
+ 'hot-magenta', 'wineberry', 'raspberry', 'ruby', 'dracula-pink', 'rose', 'blush',
+ // Neutrals
+ 'soft-silver', 'mono'
+] as const;
type ProviderId = (typeof providerIds)[number];
export type Screen =
diff --git a/src/ui/AdaptiveContent.tsx b/src/ui/AdaptiveContent.tsx
index 4b4c28b..5d68137 100644
--- a/src/ui/AdaptiveContent.tsx
+++ b/src/ui/AdaptiveContent.tsx
@@ -31,6 +31,7 @@ import {formatExploreCursor} from './app-state.js';
import {buildCosmoWorldMap, type CosmoMapCellKind, type CosmoMapRow} from './cosmo-world-map.js';
import {adaptiveExploreFrameMetrics, computeAdaptiveExploreLayout} from './adaptive-explore-layout.js';
import {AdaptiveMarquee} from './components/AdaptiveMarquee.js';
+import {ReceiverVisualRow} from './components/ReceiverVisualRow.js';
type AdaptiveContentProps = {
platform?: NodeJS.Platform;
@@ -628,7 +629,7 @@ function AdaptiveNowPlaying({
reduceMotion: boolean;
}): React.ReactElement {
const pulse = useReceiverPulse();
- const {screenReader} = useDisplay();
+ const {screenReader, app: appBackground} = useDisplay();
const accent = themeAccent(theme);
const stationName = station?.name ?? 'No station tuned';
const showMetadata = Boolean(metadata?.title) && (screenReader || mode === 'compact' && height >= 9);
@@ -663,13 +664,7 @@ function AdaptiveNowPlaying({
{gapRows ? : null}
{!screenReader ?
{visualRows.map((row, index) => (
-
- {row.segments
- ? renderAdaptiveSegments(row.segments, ascii)
- : ascii
- ? toAsciiSafe(row.text)
- : row.text}
-
+
))}
: null}
{showMetadata ? (
@@ -682,22 +677,6 @@ function AdaptiveNowPlaying({
);
}
-function renderAdaptiveSegments(
- segments: Array<{text: string; color: string; backgroundColor?: string; bold?: boolean}>,
- ascii: boolean
-): React.ReactNode {
- let offset = 0;
- return segments.map(segment => {
- const key = offset;
- offset += segment.text.length;
- return (
-
- {ascii ? toAsciiSafe(segment.text) : segment.text}
-
- );
- });
-}
-
function AdaptiveSearch({
mode,
query,
diff --git a/src/ui/__snapshots__/visual-baseline.test.tsx.snap b/src/ui/__snapshots__/visual-baseline.test.tsx.snap
index dcc3805..d491156 100644
--- a/src/ui/__snapshots__/visual-baseline.test.tsx.snap
+++ b/src/ui/__snapshots__/visual-baseline.test.tsx.snap
@@ -1,5 +1,61 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
+exports[`palette baseline > 'acid-yellow/home' 1`] = `
+"[1m[48;2;7;10;15mRADIOCLI[22m [38;2;255;75;92m██[38;2;255;159;67m██[38;2;255;209;102m██[38;2;163;230;53m██[38;2;34;197;94m██[38;2;45;212;191m██[38;2;56;189;248m██[38;2;129;140;248m██[38;2;192;132;252m██[39m [49m
+[48;2;7;10;15m[38;2;170;180;194mLive public radio from around the world[39m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[1m[48;2;7;10;15m> [22m[38;2;170;180;194m1 [1m[38;2;244;255;69mPlaying[39m[22m [38;2;170;180;194m Receiver display and controls[39m [49m
+[48;2;7;10;15m [38;2;170;180;194m2 [39mLibrary [38;2;170;180;194m Favorites, imported streams, recent stations[39m [49m
+[48;2;7;10;15m [38;2;170;180;194m3 [39mExplore [38;2;170;180;194m Move a map cursor through geotagged stations[39m [49m
+[48;2;7;10;15m [38;2;170;180;194m4 [39mSearch [38;2;170;180;194m Find stations by name, genre, language, place[39m [49m
+[48;2;7;10;15m [38;2;170;180;194m5 [39mCountries [38;2;170;180;194m Browse by country list with a world-map toggle[39m [49m
+[48;2;7;10;15m [38;2;170;180;194m6 [39mNearby [38;2;170;180;194m Approximate IP location for local stations[39m [49m
+[48;2;7;10;15m [38;2;170;180;194m7 [39mStats [38;2;170;180;194m Listening graph, stations, streaks, hours[39m [49m
+[48;2;7;10;15m [38;2;170;180;194m8 [39mAlarms (beta) [38;2;170;180;194m Wake to radio and schedule station playback[39m [49m
+[48;2;7;10;15m [38;2;170;180;194m9 [39mSettings [38;2;170;180;194m Audio output, colors, providers[39m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m[38;2;170;180;194m1 recent · 1 favorites · 1 imported[39m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m
+[48;2;7;10;15m [49m"
+`;
+
+exports[`palette baseline > 'acid-yellow/stats' 1`] = `
+"[1m[48;2;7;10;15m[38;2;244;255;69mListening stats[22m[38;2;138;150;168m ─────────────────────────────────────────────────────────────────────────────────[39m [49m
+[48;2;7;10;15m[38;2;170;180;194mLocal listening history · never leaves this machine[39m [49m
+[48;2;7;10;15m [49m
+[48;2;9;13;20m[38;2;40;49;60m┌────────────────────────────────────────────────────────────────────────────────────────────────┐[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[1m[38;2;244;255;69mActivity — 2026[39m[22m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194m Dec Jan Feb Mar Apr May Jun Jul Aug Sep [39m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194m [39m[48;2;28;28;28m [48;2;244;255;69m [48;2;9;13;20m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194mMon [39m[48;2;28;28;28m [48;2;190;198;59m [48;2;9;13;20m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194m [39m[48;2;28;28;28m [48;2;9;13;20m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194mWed [39m[48;2;28;28;28m [48;2;9;13;20m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194m [39m[48;2;28;28;28m [48;2;9;13;20m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194mFri [39m[48;2;28;28;28m [48;2;9;13;20m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194m [39m[48;2;28;28;28m [48;2;9;13;20m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[39m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m└────────────────────────────────────────────────────────────────────────────────────────────────┘[39m[49m
+[48;2;7;10;15m [49m
+[48;2;9;13;20m[38;2;40;49;60m┌────────────────────────────────────────────────────────────────────────────────────────────────┐[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[1m[38;2;244;255;69mSummary[39m[22m [38;2;40;49;60m│[39m[49m
+[48;2;9;13;20m[38;2;40;49;60m│[38;2;170;180;194mFavorite station: [38;2;244;255;69mKEXP 90.3 FM