diff --git a/.github/workflows/cerebral-bench.yml b/.github/workflows/cerebral-bench.yml new file mode 100644 index 0000000..ce18823 --- /dev/null +++ b/.github/workflows/cerebral-bench.yml @@ -0,0 +1,54 @@ +name: Cerebral benchmark site +on: + pull_request: + paths: + - 'cerebral-src/**' + - 'visualization-wasm/**' + - 'third-party/**' + - 'scripts/build-gallery.mjs' + - 'scripts/gallery-contract.mjs' + - 'tests/cerebral-gallery.test.mjs' + - 'tests/gallery*' + - 'package.json' + - 'package-lock.json' + - 'scripts/*cerebral*' + - 'scripts/bench-data.mjs' + - 'tests/cerebral-bench.test.mjs' + - 'wrangler.cerebral.jsonc' + - '.github/workflows/cerebral-bench.yml' + workflow_dispatch: +permissions: + contents: read +jobs: + validate: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + - run: npm ci --ignore-scripts --no-audit --no-fund + - run: cargo test --manifest-path visualization-wasm/Cargo.toml -- --test-threads=1 + - run: node --test tests/cerebral-bench.test.mjs + - run: node scripts/build-cerebral.mjs + - run: npm run test:gallery + - run: npx playwright install --with-deps chromium + - run: npm run test:gallery:browser + - name: Validate Cerebral Worker without deployment + run: npx --yes wrangler@4.107.0 deploy --config wrangler.cerebral.jsonc --dry-run --outdir /tmp/cerebral-bench-worker + - name: Retain reviewable static artifact + uses: actions/upload-artifact@v4 + with: + name: cerebral-bench + path: cerebral/ + - name: Retain gallery browser evidence + if: always() + uses: actions/upload-artifact@v4 + with: + name: cerebral-gallery-browser + path: test-results/gallery/ + if-no-files-found: ignore diff --git a/.gitignore b/.gitignore index f6e7f10..4023767 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,11 @@ node_modules/ # evals evals/logs/ evals/.venv/ + +# Generated Cerebral benchmark site +/cerebral/ + +# Visualization kernel build artifacts +/visualization-wasm/target/ + +/test-results/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8244209 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +## [Unreleased] + +### Added + +- Cerebral benchmark observatory for bench.cerebral.work, with the extracted Cerebral V2 visual system, Scorcher local measurements, Cortex reference coverage, Saga simulations and fixture controls, accessible result filters, latency/plan views and downloadable evidence. +- Data-integrity checks, a separate Worker configuration and a CI-built review artifact for the Cerebral site. +- Visualization lab with all 174 entries from the pinned D3 gallery, Three.js graphics, compiled Rust/WASM numeric kernels, maps and local GeoTIFF contours, searchable source attribution, accessible controls, data downloads, and automated full-gallery rendering checks. diff --git a/README.md b/README.md index 3d88181..b12c374 100644 --- a/README.md +++ b/README.md @@ -66,3 +66,35 @@ Manual deploy (from a machine with `wrangler login`): ```bash npm run deploy ``` + +## Cerebral benchmark observatory + +`bench.cerebral.work` has its own source tree (`cerebral-src/`), generated artifact (`cerebral/`) and Worker config (`wrangler.cerebral.jsonc`). It presents Scorcher measurements, Cortex reference coverage and Saga simulation/fixture evidence in the Cerebral V2 visual system. + +```sh +npm run test:cerebral +npm run build:cerebral +npm run check:cerebral +npm run dev:cerebral +``` + +See [the implementation and evidence guide](docs/bench-cerebral-work.md). The Cerebral PR workflow checks and packages the site; production deployment is a separate operator-approved step. + +### Visualization lab + +The Cerebral site includes `/visualizations/`: 174 entries from the pinned Observable D3 gallery, adapted to Three.js with Rust/WebAssembly data kernels. Local demonstration values are labeled separately from benchmark measurements; every entry links to its original author. The featured-libraries collection is linked alongside the attribution guide. + +The Cerebral build now needs Node 22+ and a Rust toolchain with `wasm32-unknown-unknown` installed: + +```sh +rustup target add wasm32-unknown-unknown +npm ci --ignore-scripts +npm run build:cerebral +npm run test:gallery +npx playwright install chromium +npm run test:gallery:browser +``` + +`CHROME_PATH=/usr/bin/google-chrome` can select an existing browser for the last command. Native kernel tests: `cargo test --manifest-path visualization-wasm/Cargo.toml -- --test-threads=1`. + +See [the gallery implementation guide](docs/visualization-gallery.md) and [validation evidence](docs/qa/visualization-gallery-2026-10-26.md). No remote Observable iframe or notebook runtime is required. diff --git a/cerebral-src/404.html b/cerebral-src/404.html new file mode 100644 index 0000000..af845fa --- /dev/null +++ b/cerebral-src/404.html @@ -0,0 +1 @@ +Page not found — Cerebral Bench

Cerebral Bench / 404

This page is absent.

Return to the benchmarks ↗
diff --git a/cerebral-src/app.js b/cerebral-src/app.js new file mode 100644 index 0000000..655b06a --- /dev/null +++ b/cerebral-src/app.js @@ -0,0 +1,18 @@ +(() => { + 'use strict'; + const html=document.documentElement,toggle=document.getElementById('theme-toggle'); + function describeTheme(){const dark=html.dataset.theme==='dark';toggle.setAttribute('aria-label',dark?'Switch to light theme':'Switch to dark theme');toggle.setAttribute('aria-pressed',String(dark));document.querySelector('meta[name="theme-color"]').content=dark?'#000000':'#F0EEE9';} + toggle.hidden=false;describeTheme();toggle.addEventListener('click',()=>{html.dataset.theme=html.dataset.theme==='dark'?'light':'dark';try{localStorage.setItem('cerebral-theme',html.dataset.theme)}catch{}describeTheme()}); + const articles=[...document.querySelectorAll('[data-system]')],buttons=[...document.querySelectorAll('[data-filter]')],search=document.getElementById('search'),evidence=document.getElementById('evidence-filter'),status=document.getElementById('filter-status'); + let selected='all';const searchable=new Map(articles.map(a=>[a,a.textContent.toLowerCase()])); + const validSystems=new Set(['all',...articles.map(a=>a.dataset.system)]),validEvidence=new Set(['all','measured','simulation','protocol']); + function fromURL(){const params=new URLSearchParams(location.search);selected=validSystems.has(params.get('system'))?params.get('system'):'all';search.value=params.get('q')||'';evidence.value=validEvidence.has(params.get('evidence'))?params.get('evidence'):'all';apply(false)} + function apply(write=true){const q=search.value.trim().toLowerCase();let count=0;for(const a of articles){const show=(selected==='all'||a.dataset.system===selected)&&(evidence.value==='all'||a.dataset.evidence===evidence.value)&&(!q||searchable.get(a).includes(q));a.hidden=!show;if(show)count++;}for(const b of buttons)b.setAttribute('aria-pressed',String(b.dataset.filter===selected));status.textContent=`Showing ${count} of ${articles.length} systems`;document.getElementById('no-results').hidden=count>0;if(write){const url=new URL(location.href);for(const [key,value] of [['system',selected],['q',search.value.trim()],['evidence',evidence.value]]){if(!value||value==='all')url.searchParams.delete(key);else url.searchParams.set(key,value)}history.replaceState(null,'',url)}} + document.getElementById('filters').hidden=false;status.hidden=false; + buttons.forEach(b=>b.addEventListener('click',()=>{selected=b.dataset.filter;apply()}));search.addEventListener('input',()=>apply());evidence.addEventListener('change',()=>apply());document.getElementById('reset-filters').addEventListener('click',()=>{selected='all';search.value='';evidence.value='all';apply();buttons[0].focus()});window.addEventListener('popstate',fromURL);fromURL(); + const format=n=>new Intl.NumberFormat('en-US',{maximumFractionDigits:2}).format(n),latency=[...document.querySelectorAll('[data-latency]')]; + document.querySelector('[data-percentile-controls]').hidden=false; + document.querySelectorAll('[data-percentile]').forEach(b=>b.addEventListener('click',()=>{const p=b.dataset.percentile;document.getElementById('percentile-label').textContent=p;const max=Math.max(...latency.map(r=>Number(r.dataset[p])));document.querySelectorAll('[data-percentile]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)));for(const r of latency){const value=Number(r.dataset[p]);r.querySelector('.plot-fill').style.width=`${100*value/max}%`;r.querySelector('.plot-value').replaceChildren(document.createTextNode(format(value)+' '),Object.assign(document.createElement('span'),{textContent:'µs'}));}document.querySelector('#transport-chart').setAttribute('aria-label',`Delivery latency ${p} in microseconds`)})); + const rows=JSON.parse(document.getElementById('chart-data').textContent).scheduler,plan=document.getElementById('plan-select');document.querySelector('[data-plan-control]').hidden=false; + plan.addEventListener('change',()=>{const chosen=rows.filter(r=>r.plan===plan.value),max=Math.max(...chosen.map(r=>r.makespan));for(const r of chosen){const el=document.querySelector(`[data-strategy="${r.strategy}"]`);el.querySelector('.plot-fill').style.width=`${100*r.makespan/max}%`;el.querySelector('.plot-value').replaceChildren(document.createTextNode(r.makespan+' '),Object.assign(document.createElement('span'),{textContent:'units'}));}document.getElementById('saga-chart-caption').textContent=plan.options[plan.selectedIndex].text+'. Virtual-clock model; no agent tasks are executed.'}); +})(); diff --git a/cerebral-src/data/benchmarks.json b/cerebral-src/data/benchmarks.json new file mode 100644 index 0000000..3641ef0 --- /dev/null +++ b/cerebral-src/data/benchmarks.json @@ -0,0 +1,254 @@ +{ + "schemaVersion": 1, + "snapshot": "2026-10-26", + "publisher": "Cerebral Work Institute", + "designSource": "https://cerebral.work/", + "systems": [ + { + "id": "scorcher", + "name": "Scorcher", + "number": "01", + "type": "measured", + "subtitle": "The transport layer", + "summary": "Routing, shared memory, verified object storage. A local microbenchmark capture with the sample size beside every result.", + "record": "scorcher-local.json" + }, + { + "id": "cortex", + "name": "Cortex", + "number": "02", + "type": "protocol", + "subtitle": "The coordination layer", + "summary": "The reference edge, cache and custody protocol. Coverage is documented; a separate result receipt is still to come.", + "record": "cortex-protocol.json" + }, + { + "id": "saga", + "name": "Saga", + "number": "03", + "type": "simulation", + "subtitle": "The orchestration layer", + "summary": "Three scheduling strategies, four declared plans, one virtual clock. Plus the negative and reference controls behind the evaluation fixtures.", + "record": "saga-scheduler.json" + } + ], + "measurements": [ + { + "id": "scorcher-affinity", + "system": "scorcher", + "name": "Affinity routing", + "category": "routing", + "evidence": "measured", + "value": 257, + "unit": "ns", + "percentile": "p50", + "samples": 10000, + "source": "scorcher-local.json", + "pointer": "/bench/metrics/ring_p50_ns", + "samplePointer": "/bench/metrics/iters" + }, + { + "id": "scorcher-cache", + "system": "scorcher", + "name": "Hot object-cache lookup", + "category": "cache", + "evidence": "measured", + "value": 92, + "unit": "ns", + "percentile": "p50", + "samples": 5000, + "source": "scorcher-local.json", + "pointer": "/bench/metrics/tier0_p50_ns", + "samplePointer": "/bench/metrics/tier0_iters" + }, + { + "id": "scorcher-roundtrip", + "system": "scorcher", + "name": "8 KiB shared-memory roundtrip", + "category": "transport", + "evidence": "measured", + "value": 9.138, + "unit": "\u00b5s", + "percentile": "p50", + "samples": 100, + "source": "scorcher-local.json", + "pointer": "/shm_roundtrip/latency_p50_us", + "samplePointer": "/shm_roundtrip/round_trips" + }, + { + "id": "scorcher-coalescing", + "system": "scorcher", + "name": "Upstream calls for 64 concurrent misses", + "category": "coalescing", + "evidence": "measured", + "value": 1, + "unit": "calls", + "samples": 64, + "source": "scorcher-local.json", + "pointer": "/bench/metrics/actual_calls", + "samplePointer": "/bench/metrics/concurrency" + }, + { + "id": "saga-bench-diamond-cpm", + "system": "saga", + "name": "diamond / CPM", + "category": "scheduling", + "evidence": "simulation", + "value": 31, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-diamond", + "strategy": "cpm" + }, + { + "id": "saga-bench-diamond-dbr", + "system": "saga", + "name": "diamond / DBR", + "category": "scheduling", + "evidence": "simulation", + "value": 31, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-diamond", + "strategy": "dbr" + }, + { + "id": "saga-bench-diamond-dsm", + "system": "saga", + "name": "diamond / DSM", + "category": "scheduling", + "evidence": "simulation", + "value": 31, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-diamond", + "strategy": "dsm" + }, + { + "id": "saga-bench-chain-stragglers-cpm", + "system": "saga", + "name": "chain-stragglers / CPM", + "category": "scheduling", + "evidence": "simulation", + "value": 31, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-chain-stragglers", + "strategy": "cpm" + }, + { + "id": "saga-bench-chain-stragglers-dbr", + "system": "saga", + "name": "chain-stragglers / DBR", + "category": "scheduling", + "evidence": "simulation", + "value": 32, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-chain-stragglers", + "strategy": "dbr" + }, + { + "id": "saga-bench-chain-stragglers-dsm", + "system": "saga", + "name": "chain-stragglers / DSM", + "category": "scheduling", + "evidence": "simulation", + "value": 31, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-chain-stragglers", + "strategy": "dsm" + }, + { + "id": "saga-bench-lock-bound-cpm", + "system": "saga", + "name": "lock-bound / CPM", + "category": "scheduling", + "evidence": "simulation", + "value": 36, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-lock-bound", + "strategy": "cpm" + }, + { + "id": "saga-bench-lock-bound-dbr", + "system": "saga", + "name": "lock-bound / DBR", + "category": "scheduling", + "evidence": "simulation", + "value": 31, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-lock-bound", + "strategy": "dbr" + }, + { + "id": "saga-bench-lock-bound-dsm", + "system": "saga", + "name": "lock-bound / DSM", + "category": "scheduling", + "evidence": "simulation", + "value": 36, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-lock-bound", + "strategy": "dsm" + }, + { + "id": "saga-bench-probe-fanout-cpm", + "system": "saga", + "name": "probe-fanout / CPM", + "category": "scheduling", + "evidence": "simulation", + "value": 41, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-probe-fanout", + "strategy": "cpm" + }, + { + "id": "saga-bench-probe-fanout-dbr", + "system": "saga", + "name": "probe-fanout / DBR", + "category": "scheduling", + "evidence": "simulation", + "value": 41, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-probe-fanout", + "strategy": "dbr" + }, + { + "id": "saga-bench-probe-fanout-dsm", + "system": "saga", + "name": "probe-fanout / DSM", + "category": "scheduling", + "evidence": "simulation", + "value": 41, + "unit": "plan units", + "source": "saga-scheduler.json", + "plan": "bench-probe-fanout", + "strategy": "dsm" + } + ], + "artifacts": [ + { + "file": "scorcher-local.json", + "sha256": "bfc189c52c6e80ba63ad1dc10cdbbe8bb8c1728a27a7a9feb135926f3c822767" + }, + { + "file": "cortex-protocol.json", + "sha256": "db4d450d075d8a64b14f40084627ba2a861590c132eaad9df3d5aa7602967b22" + }, + { + "file": "saga-scheduler.json", + "sha256": "ef6961755beec759958eef1b5704f4efe5986acd0f2f62a1348901fa89761c44" + }, + { + "file": "saga-controls.json", + "sha256": "d98bb59fa86c82eabda47c6aaab7c51f7a93aaf79c152f941afc967ef3bdf8a8" + } + ] +} diff --git a/cerebral-src/data/cortex-protocol.json b/cerebral-src/data/cortex-protocol.json new file mode 100644 index 0000000..69dd32a --- /dev/null +++ b/cerebral-src/data/cortex-protocol.json @@ -0,0 +1,21 @@ +{ + "kind": "protocol", + "capturedAt": "2026-10-26", + "name": "Cortex reference suite 0056", + "sourceContext": { + "repository": "cerebral-work/cortex", + "revision": "7d2f9a3f3c65386159080dee9f77742b0dad9195", + "path": "crates/cortex-edge/tests/spec_0056_bench.rs", + "sha256": "e851bdde55cf07e6f072c51943baa47202ff268aa5fb2f846c9fd0643f789ddc" + }, + "result": null, + "coverage": [ + "Stateful and adaptive routing", + "Verified object-store writes and reads", + "Sealed-descriptor and copied-socket delivery", + "Concurrent miss coalescing", + "Workspace overlay setup", + "Custody-store operations" + ], + "note": "Protocol inspected. A separate Cortex result receipt has not been attached. Scorcher derives from this suite; its local numbers remain Scorcher results." +} diff --git a/cerebral-src/data/saga-controls.json b/cerebral-src/data/saga-controls.json new file mode 100644 index 0000000..b60e5d7 --- /dev/null +++ b/cerebral-src/data/saga-controls.json @@ -0,0 +1,34 @@ +{ + "kind": "fixture-validation", + "controls": [ + { + "task": "pr1953", + "valid": true, + "negativeControlPassed": false, + "referencePatchPassed": [ + true, + true + ], + "validatedAt": "2026-10-11T08:22:08.808682328Z", + "sourceSha256": "e207e3d330ce71a0a39abfab5a1b914b25cd70c7886aae414e8e699ef2f421a8", + "note": "Fixture validation with a no-op negative control and reference patches; no agent model was graded. Advisory judge output is excluded." + }, + { + "task": "pr2082", + "valid": true, + "negativeControlPassed": false, + "referencePatchPassed": [ + true, + true + ], + "validatedAt": "2026-10-11T08:21:58.279670733Z", + "sourceSha256": "f69d48f1c2e7220ca1e8b9acc42c8638212dc06941bae6eed2d0544d1ef1b669", + "note": "Fixture validation with a no-op negative control and reference patches; no agent model was graded. Advisory judge output is excluded." + } + ], + "sourceContext": { + "repository": "cerebral-work/saga", + "revision": "63b2bc39d4a864bafc86550e37be3743ad62cbf9", + "path": ".saga/evals/syn//validation.json" + } +} diff --git a/cerebral-src/data/saga-scheduler.json b/cerebral-src/data/saga-scheduler.json new file mode 100644 index 0000000..bcd0c9d --- /dev/null +++ b/cerebral-src/data/saga-scheduler.json @@ -0,0 +1,181 @@ +{ + "schema": "saga.plan.bench.v1", + "rows": [ + { + "strategy": "cpm", + "plan": "bench-diamond", + "max_concurrency": 3, + "waves": 3, + "makespan": 31, + "slip": 5, + "drum_serial": 10, + "utilization_ppm": 333333, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "dbr", + "plan": "bench-diamond", + "max_concurrency": 3, + "waves": 3, + "makespan": 31, + "slip": 5, + "drum_serial": 10, + "utilization_ppm": 333333, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "dsm", + "plan": "bench-diamond", + "max_concurrency": 3, + "waves": 3, + "makespan": 31, + "slip": 5, + "drum_serial": 10, + "utilization_ppm": 333333, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "cpm", + "plan": "bench-chain-stragglers", + "max_concurrency": 2, + "waves": 4, + "makespan": 31, + "slip": 0, + "drum_serial": 2, + "utilization_ppm": 532258, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "dbr", + "plan": "bench-chain-stragglers", + "max_concurrency": 2, + "waves": 5, + "makespan": 32, + "slip": 1, + "drum_serial": 2, + "utilization_ppm": 515625, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "dsm", + "plan": "bench-chain-stragglers", + "max_concurrency": 2, + "waves": 4, + "makespan": 31, + "slip": 0, + "drum_serial": 2, + "utilization_ppm": 532258, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "cpm", + "plan": "bench-lock-bound", + "max_concurrency": 3, + "waves": 4, + "makespan": 36, + "slip": 25, + "drum_serial": 30, + "utilization_ppm": 472222, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "dbr", + "plan": "bench-lock-bound", + "max_concurrency": 3, + "waves": 4, + "makespan": 31, + "slip": 20, + "drum_serial": 30, + "utilization_ppm": 548387, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "dsm", + "plan": "bench-lock-bound", + "max_concurrency": 3, + "waves": 4, + "makespan": 36, + "slip": 25, + "drum_serial": 30, + "utilization_ppm": 472222, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "cpm", + "plan": "bench-probe-fanout", + "max_concurrency": 3, + "waves": 3, + "makespan": 41, + "slip": 10, + "drum_serial": 30, + "utilization_ppm": 414634, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "dbr", + "plan": "bench-probe-fanout", + "max_concurrency": 3, + "waves": 3, + "makespan": 41, + "slip": 10, + "drum_serial": 30, + "utilization_ppm": 414634, + "held": 0, + "trips": {}, + "error": null + }, + { + "strategy": "dsm", + "plan": "bench-probe-fanout", + "max_concurrency": 3, + "waves": 4, + "makespan": 41, + "slip": 10, + "drum_serial": 30, + "utilization_ppm": 414634, + "held": 0, + "trips": {}, + "error": null + } + ], + "capture": { + "capturedAt": "2026-10-26", + "kind": "simulation", + "command": "saga plan bench --json ", + "binarySha256": "fdec108c223f6f9ec8fc42a4e6dbfbec2141136dd56d256f047a1314b8ec4294", + "sourceContext": { + "repository": "cerebral-work/saga", + "revision": "63b2bc39d4a864bafc86550e37be3743ad62cbf9", + "path": "crates/saga-domain/src/scheduling/bench.rs", + "sha256": "b871a4e14fb4a90f507ed14c5d05f56ff13a3c8894294398417ff347d5d1fd73" + }, + "unit": "plan time units", + "profile": "debug; virtual-clock simulation", + "limitations": [ + "Runs the scheduler model; no agent tasks are executed.", + "Makespan is expressed in declared plan time units, not milliseconds.", + "No host-pressure trace was supplied.", + "Executable identity is recorded separately from inspected source context." + ] + } +} diff --git a/cerebral-src/data/scorcher-local.json b/cerebral-src/data/scorcher-local.json new file mode 100644 index 0000000..3b71169 --- /dev/null +++ b/cerebral-src/data/scorcher-local.json @@ -0,0 +1,134 @@ +{ + "schema_version": 2, + "scorcher_version": "0.1.0", + "iters": 10000, + "bench": { + "metrics": { + "iters": 10000, + "ring_ops_s": 2554651.6630271394, + "ring_p50_ns": 257, + "ring_p99_ns": 974, + "p2c_ops_s": 1724377.8574018832, + "p2c_p50_ns": 331, + "p2c_p99_ns": 1680, + "put_count": 20, + "put_ops_s": 6025.668141147661, + "put_p50_us": 133.922, + "put_p99_us": 597.527, + "tier0_iters": 5000, + "tier0_ops_s": 7325137.968973645, + "tier0_p50_ns": 92, + "tier0_p99_ns": 184, + "tier0_gib_s": 7153.455047825825, + "tier1_ops_s": 19123.384074045745, + "tier1_p50_us": 56.629, + "tier1_p99_us": 67.329, + "ipc_iters": 20, + "memfd_supported": true, + "memfd_ops_s": 6421.4198016038135, + "memfd_p50_us": 4.151, + "memfd_p99_us": 2948.49, + "memfd_gib_s": 50.16734220002979, + "raw_ops_s": 518.0370797990793, + "raw_p50_us": 1467.192, + "raw_p99_us": 5262.465, + "raw_gib_s": 4.047164685930307, + "concurrency": 64, + "actual_calls": 1, + "sf_wall_ms": 7.541389, + "ws_iters": 5, + "phys_ms": 2.3626502, + "phys_sess_s": 423.25351421044047, + "mode_a_ms": 0.062202, + "mode_a_sess_s": 16076.65348381081, + "mode_a_speedup": 37.98350856885631, + "mode_b_ms": 0.17947760000000001, + "mode_b_sess_s": 5571.725942401726, + "mode_b_speedup": 13.164039412160626, + "turso_rows": 50, + "turso_upsert_rows_s": 22867.28286371557, + "turso_upsert_us": 43.730599999999995, + "turso_scan_ms": 1.083582, + "turso_scan_rows_s": 46143.25450219734, + "delta_rows": 20, + "turso_delta_ops_s": 6809.465702083152, + "turso_delta_us": 146.8544, + "turso_stream_ms": 0.10435, + "turso_wt_us": 37.388999999999996, + "scds_json_bytes": 5800, + "scds_wire_bytes": 992, + "scds_compression_ratio": 5.846774193548387, + "scds_encode_ops_s": 339213.02578018996, + "scds_encode_p50_us": 2.149, + "scds_decode_ops_s": 153529.64657475357, + "scds_decode_p50_us": 4.16, + "scds_view_ops_s": 697934.1150195422, + "scds_view_p50_us": 0.937, + "scds_migration_us": 22.446, + "scdp_base_bytes": 65536, + "scdp_patch_wire_bytes": 412, + "scdp_savings_ratio": 159.06796116504853, + "scdp_compute_ops_s": 34042.147582922415, + "scdp_compute_p50_us": 29.453, + "scdp_apply_ops_s": 44825.661794864325, + "scdp_apply_p50_us": 14.309, + "scdp_view_apply_ops_s": 870738.821890374, + "scdp_view_apply_p50_us": 0.928 + } + }, + "shm_roundtrip": { + "status": "ok", + "payload_bytes": 8192, + "round_trips": 100, + "total_us": 2343.387, + "latency_p50_us": 9.138, + "latency_p99_us": 85.982 + }, + "admission": { + "schema_version": 1, + "worker_lanes": 2, + "tasks_solved": 8, + "total_context_switches": 0, + "peak_in_flight_bytes": 134217728, + "peak_in_flight_items": 2, + "total_service_units": 108, + "flow_metrics": { + "total_wip": 8, + "effective_service_time_ms": 50, + "utilization_bps": 500, + "littles_law_cycle_time_ms": 4000, + "kingman_queue_wait_ms": 0, + "cobham_priority_wait_ms": 0, + "admission": "hold_buffer_full" + }, + "batch_receipt_digest": "sha256:d7fc0c9096c5958252a5a1239d9ff0d5ff537a4cd372ee30aebcc0840eab83ac" + }, + "capture": { + "capturedAt": "2026-10-26", + "kind": "local-measurement", + "command": "scorcher bench --iters 10000 --json", + "binarySha256": "2fb529150a5cf5a6e0fef349eb5f6a1cd92d2fea48196a7ffda3cc8ad1a38244", + "sourceContext": { + "repository": "cerebral-work/scorcher", + "revision": "3388c2cd2157135ba609f73d22ca6b709525128a", + "path": "crates/scorcher-edge/src/bench.rs", + "sha256": "82612c3996953ef3406748c98088033ce10c4f5cfb7f0bf275244decf0cffd82" + }, + "environment": { + "os": "Linux / WSL2", + "architecture": "x86_64", + "cpu": "AMD Ryzen 7 9800X3D", + "logicalCpus": 16, + "profile": "release", + "isolation": "shared workstation; uncontrolled background load" + }, + "limitations": [ + "One capture; no confidence interval or repeated-run distribution.", + "Routing N=10000; hot-cache N=5000; writes and delivery N=20; workspace sessions N=5.", + "The 8 KiB roundtrip uses 100 samples; it is a different workload from 8 MiB delivery.", + "Inspected source revision is context, not a cryptographic build attestation.", + "Logical cache throughput reports referenced bytes, not physical memory bandwidth." + ], + "originalOutputSha256": "799cdcaee220c9d23fbedb76568da47c3776671af08cfabdf3aca8e46b0e5e9d" + } +} diff --git a/cerebral-src/favicon.svg b/cerebral-src/favicon.svg new file mode 100644 index 0000000..8730d49 --- /dev/null +++ b/cerebral-src/favicon.svg @@ -0,0 +1 @@ + diff --git a/cerebral-src/index.html b/cerebral-src/index.html new file mode 100644 index 0000000..a9c11b5 --- /dev/null +++ b/cerebral-src/index.html @@ -0,0 +1,57 @@ + + + + + +Cerebral Bench — performance, with a paper trail + + + + + + + + + + + + + +
+ + +
+
+
+
Cerebral / systems researchSnapshot · 26 October 2026
+

Performance,
with a
paper trail.

The systems we build.
The measurements behind them.

Explore the results
+
Scorcher / shared memoryLocal sample
{{ROUNDTRIP}}µs

8 KiB roundtrip · median latency

+ A shared-memory roundtrip from sender to receiver, with an acknowledgement returning to the sender.8 KiBSENDERRECEIVERACKNOWLEDGEMENT +
n = 100 · Linux / x86_64p99 {{ROUNDTRIP_TAIL}} µs

One workstation capture. The run record carries the context.

+
03systems
under study
01local measurement
capture
04scheduler
fixtures
02evaluation
control pairs
+
+
+

01 / The results

Three layers.
Different questions.

Transport, coordination, orchestration. Every result carries its workload, its unit, and a way back to the evidence.

+ + +
01

The transport layer

Scorcher

Measured · local capture
+

Move the reference.
Keep the record.

Shared memory, routing and verified object storage. Measured together in a release-binary microbenchmark on a shared workstation.

Ryzen 7 9800X3D · Linux / WSL2 · {{SNAPSHOT}}

+
{{SCORCHER_FACTS}}
+

Two paths. One payload.

8 MiB delivery · p50 · microseconds · lower is better

{{TRANSPORT_CHART}}
20 samples per path. Read the tail alongside the median; small samples and background load influence both.
+
{{SCORCHER_ROWS}}
Measured operations / local capture
Workloadp50p99Samples
+

These are operation timings from one run. No confidence interval is estimated; the capture is a reproducibility starting point.

{{SCORCHER_RECORD}}
+
02

The coordination layer

Cortex

Protocol · results pending
+

One reference.
A repeatable question.

Suite 0056 defines the edge-routing, object-store and custody workloads from which Scorcher was derived. Its coverage is recorded here.

Reference suite 0056 · inspected {{SNAPSHOT}}

+
Published result
—

Waiting for a run record.

A separate Cortex execution receipt will establish the result. Scorcher’s numbers retain their own attribution.

    {{CORTEX_COVERAGE}}
{{CORTEX_RECORD}}
+
03

The orchestration layer

Saga

Simulation · virtual clock
+

Give every strategy
the same plan.

CPM, drum-buffer-rope and dependency-structure scheduling, compared across four declared fixtures. The virtual clock reveals where capacity and the build lock cost time.

4 plans · 3 strategies · 12 simulated rows

+

The cost of a shared lock.

Makespan · declared plan units · lower is better

{{SAGA_CHART}}
Lock-bound fixture. A virtual-clock model; no agent tasks are executed.
+
{{SAGA_ROWS}}
Every strategy / every plan
PlanStrategyMakespan (units)WavesUtilization
+

The controls behind the task.

Saved evaluation-fixture validation. A no-op must fail and the reference patch must pass before a task is used to evaluate an agent.

{{CONTROL_ROWS}}
Fixture validation / not a model score
FixtureNo-op controlReference patchValidated
Download fixture controls ↓{{SAGA_RECORD}}
+
+

02 / Methodology

The limit belongs
beside the number.

Useful benchmarks make their conditions legible. Three evidence types, each answering a different question.

01

Measured

A local executable capture. Workload, percentile, sample count and environment travel with the result. Repeat on your own hardware before generalizing.

02

Simulated

A declared scheduling model on a virtual clock. Units belong to the plan; makespan describes that model rather than wall-clock execution.

03

Specified

An inspected protocol with its coverage and source identity. Numeric results appear when a corresponding execution record is attached.

+

03 / Open the record

Take the data.
Ask a better question.

First-party evidence, with the context intact. Every download includes its capture type; the index carries artifact fingerprints.

+
+ + + diff --git a/cerebral-src/robots.txt b/cerebral-src/robots.txt new file mode 100644 index 0000000..a94b696 --- /dev/null +++ b/cerebral-src/robots.txt @@ -0,0 +1,3 @@ +User-agent: * +Allow: / +Sitemap: https://bench.cerebral.work/sitemap.xml diff --git a/cerebral-src/styles.css b/cerebral-src/styles.css new file mode 100644 index 0000000..106b861 --- /dev/null +++ b/cerebral-src/styles.css @@ -0,0 +1,12 @@ +@font-face{font-family:'Space Mono';src:url('https://cerebral.work/fonts/SpaceMono-Regular.woff2') format('woff2');font-display:swap} +:root{--bg:#F0EEE9;--text:#0A0A0B;--text-dim:#0A0A0B;--line:#0A0A0B;--soft-line:color-mix(in srgb,var(--text) 23%,var(--bg));--wash:color-mix(in srgb,var(--text) 4%,var(--bg));--mono:'Space Mono',ui-monospace,Menlo,monospace;--font-display:'fractul-variable','gunter','Space Mono',ui-monospace,monospace;--gutter:clamp(16px,2.2vw,36px);--signal:#312CC5;color-scheme:light} +:root[data-theme=dark]{--bg:#000;--text:#fff;--text-dim:#fff;--line:#fff;--signal:#B9B6FF;color-scheme:dark} +*{box-sizing:border-box}html{scroll-behavior:smooth;scroll-padding-top:24px}body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font-display);font-size:16px;font-weight:400;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select{font:inherit;color:inherit}button,a,input,select{-webkit-tap-highlight-color:transparent}a{color:inherit;text-underline-offset:4px}button{cursor:pointer}button,select{border-radius:0}button{background:transparent}h1,h2,h3,h4,p,figure{margin:0}h1,h2,h3,h4{font-weight:400}::selection{background:var(--text);color:var(--bg)}:focus-visible{outline:2px solid var(--text);outline-offset:5px}#content:focus{outline:none}[hidden]{display:none!important}.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.skip{position:fixed;top:10px;left:var(--gutter);z-index:100;background:var(--text);color:var(--bg);padding:14px 20px;transform:translateY(-200%)}.skip:focus{transform:none}.masthead,main,footer{padding-left:var(--gutter);padding-right:var(--gutter);max-width:1800px;margin:auto}.masthead{padding-top:26px}.masthead-row{display:flex;justify-content:space-between;align-items:center;gap:20px}.wordmark{display:flex;gap:18px;align-items:center;font-size:15px;letter-spacing:.27em;text-transform:uppercase;text-decoration:none}.wordmark>span{letter-spacing:0;text-transform:none;font-size:16px}.header-tools{display:flex;align-items:center;gap:30px}.studio-link{text-decoration:none;font-size:15px}.studio-link span{margin-left:15px}.theme-button{width:42px;height:42px;border:1px solid;display:grid;place-items:center}.theme-button svg{width:24px;height:24px}.theme-button:hover{background:var(--text);color:var(--bg)}.page-nav{display:flex;gap:30px;padding:25px 0 20px;border-bottom:1px solid var(--line);align-items:baseline}.page-nav a{font-size:15px;text-decoration:none}.page-nav a:hover{text-decoration:underline}.page-nav sup{font-family:var(--mono);font-size:9px;vertical-align:super;margin-left:3px}.nav-download{margin-left:auto}.nav-download span{margin-left:16px}.eyebrow{font-family:var(--mono);font-size:10px;letter-spacing:.1em;text-transform:uppercase;line-height:1.6}.hero{padding-top:28px}.hero-top{display:flex;justify-content:space-between;gap:20px}.hero-grid{display:grid;grid-template-columns:1.08fr 1fr;gap:clamp(40px,8vw,140px);padding:clamp(48px,6.5vw,100px) 0 65px;align-items:center}.hero h1{font-size:clamp(64px,7.6vw,116px);line-height:.95;letter-spacing:-.055em}.marked{position:relative;white-space:nowrap}.marked:after{content:'';position:absolute;height:1px;left:0;right:0;bottom:-6px;background:currentColor}.hero-lede{font-size:clamp(19px,1.9vw,27px);line-height:1.25;margin-top:38px}.text-link{display:flex;justify-content:space-between;align-items:center;max-width:310px;border-bottom:1px solid;padding:16px 0 12px;margin-top:25px;text-decoration:none;font-size:16px}.text-link span{font-size:24px}.text-link:hover span{transform:translate(3px,3px)}.hero-figure{position:relative;border-top:1px solid;padding-top:16px;align-self:center}.figure-top{display:flex;justify-content:space-between;align-items:baseline;gap:10px}.sample-tag{font-family:var(--mono);font-size:9px;text-transform:uppercase;letter-spacing:.06em;padding:5px 7px;border:1px solid}.large-measure{font-size:clamp(105px,12vw,185px);letter-spacing:-.065em;line-height:1.05;margin:32px 0 4px}.large-measure>span{font-size:.25em;letter-spacing:-.03em;margin-left:12px}.measure-caption{font-size:18px}.signal-diagram{display:block;width:100%;margin-top:35px;color:var(--text)}.signal-diagram text{fill:currentColor;font-family:var(--mono);font-size:9px;letter-spacing:.05em}.hero-figure figcaption{border-top:1px solid;padding-top:13px;display:flex;justify-content:space-between;gap:12px;font:10px/1.6 var(--mono)}.figure-note{font-size:13px;line-height:1.5;margin-top:14px;max-width:40ch}.snapshot-index{display:grid;grid-template-columns:repeat(4,1fr);border-top:1px solid;border-bottom:1px solid;padding:23px 0;gap:25px}.snapshot-index>div{display:flex;align-items:center;gap:20px}.snapshot-index b{font-size:50px;font-weight:400;line-height:1;letter-spacing:-.04em}.snapshot-index span{font-family:var(--mono);font-size:10px;line-height:1.5;letter-spacing:.02em}.results-section{padding-top:90px}.section-heading{display:grid;grid-template-columns:1.08fr 1fr;gap:clamp(30px,8vw,140px);align-items:end;margin-bottom:50px}.section-heading h2{font-size:clamp(36px,4vw,64px);line-height:1.02;letter-spacing:-.035em;margin-top:24px}.section-heading>p{font-size:20px;line-height:1.45;max-width:43ch}.filters{border-top:1px solid;border-bottom:1px solid;display:flex;align-items:center;justify-content:space-between;gap:25px;padding:14px 0}.system-filters{display:flex;gap:25px;flex-wrap:wrap}.system-filters button{padding:7px 0;border:0;font-size:15px;position:relative;white-space:nowrap}.system-filters button[aria-pressed=true]:after{content:'';height:2px;background:currentColor;position:absolute;bottom:0;left:0;right:0}.system-filters sup{font:9px var(--mono);margin-left:4px}.search-tools{display:flex;align-items:center;gap:20px}.search-label{display:flex;gap:9px;align-items:center;max-width:220px}.search-label svg{width:17px;height:17px;stroke:currentColor;fill:none;flex:none}.search-label input{background:transparent;border:0;font-size:13px;min-width:0;width:100%;padding:8px 0}.search-label input::placeholder{color:var(--text);opacity:.75}select{background:var(--bg);border:1px solid var(--line);font-size:12px;min-height:36px;padding:7px 28px 7px 10px;max-width:100%}.filter-status{font:10px/1.5 var(--mono);margin-top:16px}.empty-state{padding:65px 0;border-bottom:1px solid}.empty-state h3{font-size:32px;margin-bottom:15px}.empty-state p{margin-bottom:20px}.outline-button{border:1px solid;padding:10px 18px}.system{margin-top:52px;padding-top:24px;border-top:1px solid}.system-heading{display:flex;justify-content:space-between;align-items:center;gap:20px}.system-identity{display:flex;align-items:baseline;gap:22px}.system-number{font-family:var(--mono);font-size:14px;align-self:start;padding-top:7px}.system-identity h3{font-size:clamp(44px,5vw,76px);line-height:1;letter-spacing:-.045em;margin-top:10px}.evidence-label{font:10px/1.6 var(--mono);letter-spacing:.04em;display:flex;gap:9px;align-items:center}.state-square{display:block;width:6px;height:6px;background:var(--text);flex:none}.protocol-label .state-square{background:transparent;border:1px solid}.simulation-label .state-square{background:repeating-linear-gradient(135deg,var(--text) 0 1px,var(--bg) 1px 2px)}.system-intro{display:grid;grid-template-columns:1.08fr 1fr;gap:clamp(30px,8vw,140px);margin-top:36px}.system-intro>p{font-size:clamp(24px,2.6vw,39px);line-height:1.15;letter-spacing:-.02em}.system-intro>div>p:first-child{font-size:16px;line-height:1.6;max-width:54ch}.context-line{font-family:var(--mono);font-size:10px;line-height:1.8;margin-top:15px}.fact-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:25px;border-top:1px solid var(--soft-line);margin-top:42px;padding-top:25px}.fact-value{font-size:clamp(45px,5.5vw,76px);line-height:1;letter-spacing:-.045em;white-space:nowrap}.fact-value>span{font-size:.3em;margin-left:8px;letter-spacing:0}.fact>p{font-family:var(--mono);font-size:10px;line-height:1.65;margin-top:15px}.chart-section{margin-top:48px;background:var(--wash);padding:26px 30px 22px}.chart-title{display:flex;justify-content:space-between;align-items:center;gap:25px}.chart-title h4,.fixture-heading h4{font-size:22px;line-height:1.2;letter-spacing:-.02em}.chart-title p{font:10px/1.7 var(--mono);margin-top:10px}.segmented{display:flex;align-items:center;border:1px solid}.segmented button{border:0;min-width:48px;min-height:32px;font:11px var(--mono)}.segmented button[aria-pressed=true]{background:var(--text);color:var(--bg)}.bar-chart{margin-top:32px}.plot-row{display:grid;grid-template-columns:160px minmax(0,1fr) 135px;align-items:center;gap:15px;margin:20px 0}.plot-label{font:11px/1.6 var(--mono)}.plot-track{height:24px;border-left:1px solid var(--text);background:repeating-linear-gradient(to right,transparent 0,transparent calc(25% - 1px),var(--soft-line) calc(25% - 1px),var(--soft-line) 25%)}.plot-fill{height:24px;background:var(--text)}.plot-row:last-child .plot-fill{background:repeating-linear-gradient(135deg,var(--text) 0 1px,var(--bg) 1px 4px);border:1px solid var(--text)}.plot-value{text-align:right;font-size:19px;white-space:nowrap}.plot-value span{font:10px var(--mono)}.bar-chart figcaption{margin-top:30px;font:10px/1.8 var(--mono);max-width:85ch}.table-wrap{overflow-x:auto;scrollbar-width:thin;margin-top:30px}.table-wrap:focus-visible{outline-offset:3px}table{border-collapse:collapse;width:100%;font-size:14px;line-height:1.5;text-align:left}caption{text-align:left;font:10px/1.6 var(--mono);text-transform:uppercase;letter-spacing:.1em;padding:0 0 13px}th,td{border-bottom:1px solid var(--soft-line);padding:14px 14px 14px 0}thead th{border-top:1px solid var(--line);border-bottom:1px solid var(--line);font:10px/1.5 var(--mono);white-space:nowrap}tbody th{font-weight:400}td:not(:first-child){font-family:var(--mono);font-size:12px;white-space:nowrap}td span,th span{font-size:10px}tbody tr:hover{background:var(--wash)}.limitation{max-width:77ch;font-size:13px;line-height:1.65;margin-top:20px}.record{border-top:1px solid;border-bottom:1px solid;margin-top:32px}.record summary{display:flex;justify-content:space-between;cursor:pointer;padding:18px 0;font-size:14px;list-style:none}.record summary::-webkit-details-marker{display:none}.record[open] summary span{transform:rotate(90deg)}.record-body{padding:0 0 24px;font-size:13px;line-height:1.65}.record-body a{display:inline-block;margin-top:10px}.record-body dl{margin-bottom:0}.record-body dt{font-family:var(--mono);font-size:10px;margin-top:20px}.record-body dd{margin:8px 0 0;overflow-wrap:anywhere;max-width:85ch}.record-body code{font:10px/1.8 var(--mono)}.protocol-grid{display:grid;grid-template-columns:1fr 1.2fr;gap:80px;margin-top:42px;padding:30px 0;border-top:1px solid var(--soft-line)}.pending-value{font-size:90px;line-height:1;margin:4px 0 10px}.pending-result h4{font-size:22px}.pending-result>p{font-size:14px;line-height:1.6;max-width:40ch;margin-top:12px}.coverage-list{list-style:none;padding:0;margin:0}.coverage-list li{display:flex;align-items:baseline;gap:15px;border-bottom:1px solid var(--soft-line);padding:14px 0;font-size:14px}.coverage-list li:first-child{padding-top:0}.coverage-list li>span:first-child{font:9px var(--mono)}.coverage-label{margin-left:auto;font:9px var(--mono)}.fixture-heading{display:grid;grid-template-columns:1fr 1fr;gap:45px;margin-top:45px}.fixture-heading p{font-size:14px;line-height:1.6;max-width:50ch}.control-dot{display:inline-block;width:5px;height:5px;background:currentColor;vertical-align:middle;margin-right:8px}.subtle-link{display:inline-block;font-size:12px;margin-top:20px}.methods{margin-top:100px;padding-top:38px;border-top:1px solid}.method-rows>div{display:grid;grid-template-columns:50px 1fr 1.5fr;gap:25px;border-top:1px solid var(--soft-line);padding:27px 0}.method-rows>div>span{font:11px var(--mono);padding-top:5px}.method-rows h3{font-size:30px;letter-spacing:-.025em}.method-rows p{font-size:16px;line-height:1.6;max-width:62ch}.evidence-section{display:grid;grid-template-columns:1fr 1fr;gap:clamp(40px,8vw,140px);margin:90px 0 100px;border-top:1px solid;padding-top:40px}.evidence-section h2{font-size:clamp(36px,4vw,62px);line-height:1.02;letter-spacing:-.035em;margin:24px 0}.evidence-section p{font-size:16px;line-height:1.6;max-width:48ch}.download-list>a{display:flex;align-items:center;justify-content:space-between;padding:20px 0;border-bottom:1px solid;text-decoration:none;font-size:20px}.download-list>a:first-child{border-top:1px solid}.download-list small{display:block;font:10px/1.7 var(--mono);margin-top:7px}.download-list>a:hover{background:var(--wash)}footer{border-top:1px solid;padding-top:36px;padding-bottom:22px;display:grid;grid-template-columns:1fr 1fr;gap:50px}.footer-brand{text-decoration:none;font-size:clamp(30px,4vw,58px);line-height:1.02;letter-spacing:-.035em}.footer-brand>span{display:inline-block;margin-left:45px}.footer-meta{font-size:13px;line-height:1.7;display:flex;flex-direction:column;gap:8px;align-items:flex-end}.footer-bottom{grid-column:1/-1;display:flex;justify-content:space-between;font:9px/1.6 var(--mono);padding-top:30px;gap:20px} +@media(min-width:1600px){.hero-grid{padding-top:110px;padding-bottom:90px}} +@media(max-width:1050px){.system-filters{gap:18px}.filters{align-items:flex-start;flex-direction:column;gap:18px}.search-tools{width:100%;justify-content:space-between}.search-label{max-width:300px}.protocol-grid{gap:40px}.hero-grid{gap:40px}.hero h1{font-size:clamp(64px,8.5vw,95px)}.plot-row{grid-template-columns:130px minmax(0,1fr) 120px}.hero-figure figcaption{flex-direction:column;gap:4px}} +@media(max-width:720px){.department,.wordmark>span:first-child,.studio-link{display:none}.wordmark{font-size:13px}.masthead{padding-top:18px}.page-nav{gap:20px;padding-top:20px}.page-nav a{font-size:12px}.nav-download{font-size:0!important}.nav-download span{font-size:18px}.hero-top{align-items:flex-start}.hero-top .eyebrow{font-size:8px;max-width:21ch}.hero-top .eyebrow:last-child{text-align:right}.hero-grid{grid-template-columns:1fr;padding:45px 0;gap:50px}.hero h1{font-size:clamp(62px,14vw,100px)}.hero-lede{font-size:22px;margin-top:25px}.text-link{margin-top:20px}.hero-figure{padding-top:16px}.large-measure{font-size:120px;margin-top:24px}.signal-diagram{margin-top:20px}.hero-figure figcaption{flex-direction:row}.snapshot-index{grid-template-columns:1fr 1fr;gap:24px;padding:23px 0}.snapshot-index b{font-size:43px}.snapshot-index>div{gap:14px}.snapshot-index span{font-size:9px}.results-section{padding-top:60px}.section-heading{grid-template-columns:1fr;gap:25px;margin-bottom:35px}.section-heading h2{font-size:42px;margin-top:18px}.section-heading>p{font-size:17px;max-width:45ch}.system-filters{gap:20px;justify-content:space-between;width:100%}.system-filters button{font-size:12px}.system-filters sup{font-size:8px}.search-tools{gap:15px}.search-label{max-width:52%}.search-label input{font-size:12px}.search-tools select{font-size:11px}.system{margin-top:40px}.system-heading{align-items:flex-start;flex-direction:column;gap:18px}.system-identity{gap:15px}.system-identity h3{font-size:54px}.system-intro{grid-template-columns:1fr;gap:25px;margin-top:30px}.system-intro>p{font-size:28px}.system-intro>div>p:first-child{font-size:15px}.context-line{font-size:9px}.fact-grid{gap:18px;grid-template-columns:1fr 1fr;margin-top:30px}.fact-grid .fact:last-child{grid-column:1/-1;border-top:1px solid var(--soft-line);padding-top:20px}.fact-value{font-size:50px}.fact>p{font-size:9px;margin-top:10px}.chart-section{padding:20px 16px;margin-top:35px}.chart-title{gap:15px;align-items:flex-start;flex-wrap:wrap}.chart-title h4{font-size:20px}.chart-title p{font-size:9px}.bar-chart{margin-top:25px}.plot-row{grid-template-columns:minmax(0,1fr) 115px;gap:9px;margin:22px 0}.plot-label{grid-column:1/-1;font-size:10px}.plot-value{font-size:17px}.plot-track,.plot-fill{height:20px}.bar-chart figcaption{font-size:9px;margin-top:25px}table{font-size:12px;min-width:560px}th,td{padding-top:13px;padding-bottom:13px}td:not(:first-child){font-size:11px}.table-wrap{margin-top:25px}.protocol-grid{grid-template-columns:1fr;gap:30px}.pending-result>p{max-width:none}.coverage-list li{font-size:13px;gap:12px}.coverage-label{font-size:8px}.fixture-heading{grid-template-columns:1fr;gap:15px;margin-top:32px}.fixture-heading h4{font-size:21px}.methods{margin-top:65px}.method-rows>div{grid-template-columns:25px 1fr;gap:15px}.method-rows p{grid-column:2;font-size:14px}.method-rows h3{font-size:26px}.evidence-section{grid-template-columns:1fr;margin-top:60px;margin-bottom:65px;gap:32px}.evidence-section h2{font-size:42px}.evidence-section p{font-size:15px}footer{grid-template-columns:1fr;gap:35px;padding-top:30px}.footer-brand{font-size:45px}.footer-meta{align-items:flex-start;font-size:12px}.footer-bottom{font-size:8px;align-items:flex-start;padding-top:10px}.footer-bottom>span:last-child{text-align:right}.record summary{font-size:13px}} +@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}*,*::before,*::after{animation:none!important;transition:none!important}} +@media print{.header-tools,.filters,.segmented,.plan-control,.skip{display:none!important}[hidden][data-system]{display:block!important}body{background:white;color:black}.system{break-inside:avoid}.table-wrap{overflow:visible}footer{margin-top:40px}} +@media(max-width:360px){.hero h1{font-size:clamp(46px,15.5vw,55px)}.system-filters{gap:12px}.system-filters button{font-size:11px}.evidence-label{font-size:9px}.snapshot-index>div{gap:10px}.plot-row{grid-template-columns:minmax(0,1fr) 105px}} +/* The visualization lab extends the shared navigation. */ +@media(max-width:700px){.page-nav{flex-wrap:wrap;row-gap:14px}.page-nav .nav-download{margin-left:0}} diff --git a/cerebral-src/visualizations/index.html b/cerebral-src/visualizations/index.html new file mode 100644 index 0000000..a6c89c2 --- /dev/null +++ b/cerebral-src/visualizations/index.html @@ -0,0 +1,235 @@ + + + + + + Visualization lab — Cerebral Bench + + + + + + + + + + +
+ CEREBRAL / Bench + +
+
+
+

Visualization lab / Field notes 001

+

174 ways to see
the data.

+
+
+

+ A working collection of visual ideas.
Change a parameter. Follow + a pattern. +

+

+ Based on the + D3 gallery. Local + examples use deterministic demonstration data. Benchmark measurements + keep their own evidence records. +

+
+ WASM / initializingThree.js / initializing +
+
+
+
+ +
+
+
+

Bars / 072 of 174

+

Bar chart

+

+ Compare values through position and length on a shared baseline. +

+
+ Original example ↗ +
+
+ +
+
+
+ + + + + +
+
+ Deterministic demo values / Three.js rendering / WASM processing +
+
+
+ +
+

+ Move over the chart or use arrow keys to inspect values. The data + table is available below. +

+
+ +
+ + Read the demonstration data + Local / synthetic / not measured performance + +
+ + + + + + + + + + + + +
+ Generated sample values for the selected visualization +
SampleXValueComparisonGroup
+
+

+ The table lists the first 48 input samples. Download CSV for the + complete input. Layout algorithms derive positions, bins, + hierarchies or contours from these values; maps use Natural Earth / + US Atlas geometry. Frame-driven examples also use the displayed + animation state. These examples do not reproduce the source + notebooks’ historical datasets. +

+
+
+

How to read this collection

+
+

Keep the encoding.
Expose the assumptions.

+

+ Each entry links to the original author’s example. This lab + reimplements the visual concept with reusable local layouts, an + orthographic Three.js renderer, and compiled Rust numeric kernels. + Titles identify the source concept; values and historical-looking + profiles are demonstrations. +

+

+ Pan and zoom examples expose their view controls. Brush examples + select a region. Hierarchical examples let you drill in and reset. + Motion is opt-in and respects reduced-motion settings. +

+ Featured libraries ↗
+ Source & library attribution ↗ +
+
+
+
+ + + diff --git a/cerebral-src/visualizations/inventory.json b/cerebral-src/visualizations/inventory.json new file mode 100644 index 0000000..6ae9734 --- /dev/null +++ b/cerebral-src/visualizations/inventory.json @@ -0,0 +1,2270 @@ +{ + "source": "https://observablehq.com/@d3/gallery", + "revision": 1120, + "captured": "2026-10-26", + "sourceSha256": "e9b19333c720b5cf3eebc6dc682a124a052c449627ac7b0861e763d95b8ac3e0", + "entries": [ + { + "category": "animation", + "title": "Animated treemap", + "author": "D3", + "id": "d3-animated-treemap", + "source": "https://observablehq.com/@d3/animated-treemap", + "index": 1, + "adapter": "treemap", + "variant": "d3-animated-treemap", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Temporal force-directed graph", + "author": "D3", + "id": "d3-temporal-force-directed-graph", + "source": "https://observablehq.com/@d3/temporal-force-directed-graph", + "index": 2, + "adapter": "network", + "variant": "d3-temporal-force-directed-graph", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Connected scatterplot", + "author": "D3", + "id": "d3-connected-scatterplot-2", + "source": "https://observablehq.com/@d3/connected-scatterplot/2", + "index": 3, + "adapter": "scatter", + "variant": "d3-connected-scatterplot-2", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "The wealth & health of nations", + "author": "Mike Bostock", + "id": "mbostock-the-wealth-health-of-nations", + "source": "https://observablehq.com/@mbostock/the-wealth-health-of-nations", + "index": 4, + "adapter": "scatter", + "variant": "mbostock-the-wealth-health-of-nations", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Scatterplot tour", + "author": "D3", + "id": "d3-scatterplot-tour", + "source": "https://observablehq.com/@d3/scatterplot-tour", + "index": 5, + "adapter": "scatter", + "variant": "d3-scatterplot-tour", + "animated": true, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Bar chart race", + "author": "D3", + "id": "d3-bar-chart-race", + "source": "https://observablehq.com/@d3/bar-chart-race", + "index": 6, + "adapter": "bars", + "variant": "d3-bar-chart-race", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Stacked-to-grouped bars", + "author": "D3", + "id": "d3-stacked-to-grouped-bars", + "source": "https://observablehq.com/@d3/stacked-to-grouped-bars", + "index": 7, + "adapter": "bars", + "variant": "d3-stacked-to-grouped-bars", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Streamgraph transitions", + "author": "D3", + "id": "d3-streamgraph-transitions", + "source": "https://observablehq.com/@d3/streamgraph-transitions", + "index": 8, + "adapter": "area", + "variant": "d3-streamgraph-transitions", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Smooth zooming", + "author": "D3", + "id": "d3-smooth-zooming", + "source": "https://observablehq.com/@d3/smooth-zooming", + "index": 9, + "adapter": "circles", + "variant": "d3-smooth-zooming", + "animated": true, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Zoom to bounding box", + "author": "D3", + "id": "d3-zoom-to-bounding-box", + "source": "https://observablehq.com/@d3/zoom-to-bounding-box", + "index": 10, + "adapter": "map", + "variant": "d3-zoom-to-bounding-box", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Orthographic to equirectangular", + "author": "D3", + "id": "d3-orthographic-to-equirectangular", + "source": "https://observablehq.com/@d3/orthographic-to-equirectangular", + "index": 11, + "adapter": "map", + "variant": "d3-orthographic-to-equirectangular", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "World tour", + "author": "D3", + "id": "d3-world-tour", + "source": "https://observablehq.com/@d3/world-tour", + "index": 12, + "adapter": "map", + "variant": "d3-world-tour", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Walmart\u2019s growth", + "author": "D3", + "id": "d3-walmarts-growth", + "source": "https://observablehq.com/@d3/walmarts-growth", + "index": 13, + "adapter": "map", + "variant": "d3-walmarts-growth", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Hierarchical bar chart", + "author": "D3", + "id": "d3-hierarchical-bar-chart", + "source": "https://observablehq.com/@d3/hierarchical-bar-chart", + "index": 14, + "adapter": "bars", + "variant": "d3-hierarchical-bar-chart", + "animated": false, + "interaction": "drill", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Zoomable treemap", + "author": "D3", + "id": "d3-zoomable-treemap", + "source": "https://observablehq.com/@d3/zoomable-treemap", + "index": 15, + "adapter": "treemap", + "variant": "d3-zoomable-treemap", + "animated": false, + "interaction": "drill", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Zoomable circle packing", + "author": "D3", + "id": "d3-zoomable-circle-packing", + "source": "https://observablehq.com/@d3/zoomable-circle-packing", + "index": 16, + "adapter": "pack", + "variant": "d3-zoomable-circle-packing", + "animated": false, + "interaction": "drill", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Collapsible tree", + "author": "D3", + "id": "d3-collapsible-tree", + "source": "https://observablehq.com/@d3/collapsible-tree", + "index": 17, + "adapter": "tree", + "variant": "d3-collapsible-tree", + "animated": false, + "interaction": "drill", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Zoomable icicle", + "author": "D3", + "id": "d3-zoomable-icicle", + "source": "https://observablehq.com/@d3/zoomable-icicle", + "index": 18, + "adapter": "icicle", + "variant": "d3-zoomable-icicle", + "animated": false, + "interaction": "drill", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Zoomable sunburst", + "author": "D3", + "id": "d3-zoomable-sunburst", + "source": "https://observablehq.com/@d3/zoomable-sunburst", + "index": 19, + "adapter": "sunburst", + "variant": "d3-zoomable-sunburst", + "animated": false, + "interaction": "drill", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Sortable bar chart", + "author": "D3", + "id": "d3-bar-chart-transitions-2", + "source": "https://observablehq.com/@d3/bar-chart-transitions/2", + "index": 20, + "adapter": "bars", + "variant": "d3-bar-chart-transitions-2", + "animated": false, + "interaction": "sort", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Icelandic population by age, 1841\u20132019", + "author": "D3", + "id": "d3-icelandic-population-by-age-1841-2019", + "source": "https://observablehq.com/@d3/icelandic-population-by-age-1841-2019", + "index": 21, + "adapter": "pyramid", + "variant": "d3-icelandic-population-by-age-1841-2019", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Pie chart update", + "author": "D3", + "id": "d3-pie-chart-update", + "source": "https://observablehq.com/@d3/pie-chart-update", + "index": 22, + "adapter": "pie", + "variant": "d3-pie-chart-update", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "animation", + "title": "Arc tween", + "author": "D3", + "id": "d3-arc-tween", + "source": "https://observablehq.com/@d3/arc-tween", + "index": 23, + "adapter": "arc", + "variant": "d3-arc-tween", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Versor dragging", + "author": "D3", + "id": "d3-versor-dragging", + "source": "https://observablehq.com/@d3/versor-dragging", + "index": 24, + "adapter": "map", + "variant": "d3-versor-dragging", + "animated": true, + "interaction": "rotate", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Index chart", + "author": "D3", + "id": "d3-index-chart-2", + "source": "https://observablehq.com/@d3/index-chart/2", + "index": 25, + "adapter": "line", + "variant": "d3-index-chart-2", + "animated": false, + "interaction": "index", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Sequences sunburst", + "author": "Kerry Rodden", + "id": "kerryrodden-sequences-sunburst", + "source": "https://observablehq.com/@kerryrodden/sequences-sunburst", + "index": 26, + "adapter": "sunburst", + "variant": "kerryrodden-sequences-sunburst", + "animated": false, + "interaction": "sequence", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Brushable scatterplot", + "author": "D3", + "id": "d3-brushable-scatterplot", + "source": "https://observablehq.com/@d3/brushable-scatterplot", + "index": 27, + "adapter": "scatter", + "variant": "d3-brushable-scatterplot", + "animated": false, + "interaction": "brush", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Brushable scatterplot matrix", + "author": "D3", + "id": "d3-brushable-scatterplot-matrix", + "source": "https://observablehq.com/@d3/brushable-scatterplot-matrix", + "index": 28, + "adapter": "matrix", + "variant": "d3-brushable-scatterplot-matrix", + "animated": false, + "interaction": "brush", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Pannable chart", + "author": "D3", + "id": "d3-pannable-chart", + "source": "https://observablehq.com/@d3/pannable-chart", + "index": 29, + "adapter": "line", + "variant": "d3-pannable-chart", + "animated": false, + "interaction": "pan", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Zoomable area chart", + "author": "D3", + "id": "d3-zoomable-area-chart", + "source": "https://observablehq.com/@d3/zoomable-area-chart", + "index": 30, + "adapter": "area", + "variant": "d3-zoomable-area-chart", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Zoomable bar chart", + "author": "D3", + "id": "d3-zoomable-bar-chart", + "source": "https://observablehq.com/@d3/zoomable-bar-chart", + "index": 31, + "adapter": "bars", + "variant": "d3-zoomable-bar-chart", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "interaction", + "title": "Seamless zoomable map tiles", + "author": "D3", + "id": "d3-seamless-zoomable-map-tiles", + "source": "https://observablehq.com/@d3/seamless-zoomable-map-tiles", + "index": 32, + "adapter": "tiles", + "variant": "d3-seamless-zoomable-map-tiles", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Moving average", + "author": "D3", + "id": "d3-moving-average", + "source": "https://observablehq.com/@d3/moving-average", + "index": 33, + "adapter": "line", + "variant": "d3-moving-average", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Bollinger bands", + "author": "D3", + "id": "d3-bollinger-bands-2", + "source": "https://observablehq.com/@d3/bollinger-bands/2", + "index": 34, + "adapter": "line", + "variant": "d3-bollinger-bands-2", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Box plot", + "author": "D3", + "id": "d3-box-plot-2", + "source": "https://observablehq.com/@d3/box-plot/2", + "index": 35, + "adapter": "box", + "variant": "d3-box-plot-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Histogram", + "author": "D3", + "id": "d3-histogram-2", + "source": "https://observablehq.com/@d3/histogram/2", + "index": 36, + "adapter": "histogram", + "variant": "d3-histogram-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Kernel density estimation", + "author": "D3", + "id": "d3-kernel-density-estimation", + "source": "https://observablehq.com/@d3/kernel-density-estimation", + "index": 37, + "adapter": "kde", + "variant": "d3-kernel-density-estimation", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Density contours", + "author": "D3", + "id": "d3-density-contours", + "source": "https://observablehq.com/@d3/density-contours", + "index": 38, + "adapter": "density", + "variant": "d3-density-contours", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Volcano contours", + "author": "D3", + "id": "d3-volcano-contours-2", + "source": "https://observablehq.com/@d3/volcano-contours/2", + "index": 39, + "adapter": "contours", + "variant": "d3-volcano-contours-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Contours", + "author": "D3", + "id": "d3-contours", + "source": "https://observablehq.com/@d3/contours", + "index": 40, + "adapter": "contours", + "variant": "d3-contours", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Hexbin", + "author": "D3", + "id": "d3-hexbin", + "source": "https://observablehq.com/@d3/hexbin", + "index": 41, + "adapter": "hexbin", + "variant": "d3-hexbin", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Hexbin (area)", + "author": "D3", + "id": "d3-hexbin-area", + "source": "https://observablehq.com/@d3/hexbin-area", + "index": 42, + "adapter": "hexbin", + "variant": "d3-hexbin-area", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Hexbin map", + "author": "D3", + "id": "d3-hexbin-map", + "source": "https://observablehq.com/@d3/hexbin-map", + "index": 43, + "adapter": "hexbin", + "variant": "d3-hexbin-map", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Q\u2013Q plot", + "author": "D3", + "id": "d3-q-q-plot", + "source": "https://observablehq.com/@d3/q-q-plot", + "index": 44, + "adapter": "qq", + "variant": "d3-q-q-plot", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Normal quantile plot", + "author": "D3", + "id": "d3-normal-quantile-plot", + "source": "https://observablehq.com/@d3/normal-quantile-plot", + "index": 45, + "adapter": "qq", + "variant": "d3-normal-quantile-plot", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "analysis", + "title": "Parallel sets", + "author": "D3", + "id": "d3-parallel-sets", + "source": "https://observablehq.com/@d3/parallel-sets", + "index": 46, + "adapter": "parallelsets", + "variant": "d3-parallel-sets", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Treemap", + "author": "D3", + "id": "d3-treemap-2", + "source": "https://observablehq.com/@d3/treemap/2", + "index": 47, + "adapter": "treemap", + "variant": "d3-treemap-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Cascaded treemap", + "author": "D3", + "id": "d3-cascaded-treemap", + "source": "https://observablehq.com/@d3/cascaded-treemap", + "index": 48, + "adapter": "treemap", + "variant": "d3-cascaded-treemap", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Nested treemap", + "author": "D3", + "id": "d3-nested-treemap", + "source": "https://observablehq.com/@d3/nested-treemap", + "index": 49, + "adapter": "treemap", + "variant": "d3-nested-treemap", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Circle packing", + "author": "D3", + "id": "d3-pack-2", + "source": "https://observablehq.com/@d3/pack/2", + "index": 50, + "adapter": "pack", + "variant": "d3-pack-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Indented tree", + "author": "D3", + "id": "d3-indented-tree", + "source": "https://observablehq.com/@d3/indented-tree", + "index": 51, + "adapter": "tree", + "variant": "d3-indented-tree", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Tidy tree", + "author": "D3", + "id": "d3-tree-2", + "source": "https://observablehq.com/@d3/tree/2", + "index": 52, + "adapter": "tree", + "variant": "d3-tree-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Radial tidy tree", + "author": "D3", + "id": "d3-radial-tree-2", + "source": "https://observablehq.com/@d3/radial-tree/2", + "index": 53, + "adapter": "tree", + "variant": "d3-radial-tree-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Cluster dendrogram", + "author": "D3", + "id": "d3-cluster-2", + "source": "https://observablehq.com/@d3/cluster/2", + "index": 54, + "adapter": "tree", + "variant": "d3-cluster-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Radial dendrogram", + "author": "D3", + "id": "d3-radial-cluster-2", + "source": "https://observablehq.com/@d3/radial-cluster/2", + "index": 55, + "adapter": "tree", + "variant": "d3-radial-cluster-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Sunburst", + "author": "D3", + "id": "d3-sunburst-2", + "source": "https://observablehq.com/@d3/sunburst/2", + "index": 56, + "adapter": "sunburst", + "variant": "d3-sunburst-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Icicle", + "author": "D3", + "id": "d3-icicle-2", + "source": "https://observablehq.com/@d3/icicle/2", + "index": 57, + "adapter": "icicle", + "variant": "d3-icicle-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Tangled tree visualization", + "author": "Matteo Abrate", + "id": "nitaku-tangled-tree-visualization-ii", + "source": "https://observablehq.com/@nitaku/tangled-tree-visualization-ii", + "index": 58, + "adapter": "tangled", + "variant": "nitaku-tangled-tree-visualization-ii", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Phylogenetic tree", + "author": "D3", + "id": "d3-tree-of-life", + "source": "https://observablehq.com/@d3/tree-of-life", + "index": 59, + "adapter": "tree", + "variant": "d3-tree-of-life", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "hierarchies", + "title": "Force-directed tree", + "author": "D3", + "id": "d3-force-directed-tree", + "source": "https://observablehq.com/@d3/force-directed-tree", + "index": 60, + "adapter": "network", + "variant": "d3-force-directed-tree", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Force-directed graph", + "author": "D3", + "id": "d3-force-directed-graph-2", + "source": "https://observablehq.com/@d3/force-directed-graph/2", + "index": 61, + "adapter": "network", + "variant": "d3-force-directed-graph-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Disjoint force-directed graph", + "author": "D3", + "id": "d3-disjoint-force-directed-graph-2", + "source": "https://observablehq.com/@d3/disjoint-force-directed-graph/2", + "index": 62, + "adapter": "network", + "variant": "d3-disjoint-force-directed-graph-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Mobile patent suits", + "author": "D3", + "id": "d3-mobile-patent-suits", + "source": "https://observablehq.com/@d3/mobile-patent-suits", + "index": 63, + "adapter": "network", + "variant": "d3-mobile-patent-suits", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Arc diagram", + "author": "D3", + "id": "d3-arc-diagram", + "source": "https://observablehq.com/@d3/arc-diagram", + "index": 64, + "adapter": "arcdiagram", + "variant": "d3-arc-diagram", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Sankey diagram", + "author": "D3", + "id": "d3-sankey-2", + "source": "https://observablehq.com/@d3/sankey/2", + "index": 65, + "adapter": "sankey", + "variant": "d3-sankey-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Hierarchical edge bundling", + "author": "D3", + "id": "d3-hierarchical-edge-bundling", + "source": "https://observablehq.com/@d3/hierarchical-edge-bundling", + "index": 66, + "adapter": "bundle", + "variant": "d3-hierarchical-edge-bundling", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Hierarchical edge bundling", + "author": "D3", + "id": "d3-hierarchical-edge-bundling-2", + "source": "https://observablehq.com/@d3/hierarchical-edge-bundling/2", + "index": 67, + "adapter": "bundle", + "variant": "d3-hierarchical-edge-bundling-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Chord diagram", + "author": "D3", + "id": "d3-chord-diagram", + "source": "https://observablehq.com/@d3/chord-diagram", + "index": 68, + "adapter": "chord", + "variant": "d3-chord-diagram", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Chord diagram", + "author": "D3", + "id": "d3-chord-diagram-2", + "source": "https://observablehq.com/@d3/chord-diagram/2", + "index": 69, + "adapter": "chord", + "variant": "d3-chord-diagram-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Directed chord diagram", + "author": "D3", + "id": "d3-directed-chord-diagram-2", + "source": "https://observablehq.com/@d3/directed-chord-diagram/2", + "index": 70, + "adapter": "chord", + "variant": "d3-directed-chord-diagram-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "networks", + "title": "Chord dependency diagram", + "author": "D3", + "id": "d3-chord-dependency-diagram-2", + "source": "https://observablehq.com/@d3/chord-dependency-diagram/2", + "index": 71, + "adapter": "chord", + "variant": "d3-chord-dependency-diagram-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Bar chart", + "author": "D3", + "id": "d3-bar-chart-2", + "source": "https://observablehq.com/@d3/bar-chart/2", + "index": 72, + "adapter": "bars", + "variant": "d3-bar-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Horizontal bar chart", + "author": "D3", + "id": "d3-horizontal-bar-chart-2", + "source": "https://observablehq.com/@d3/horizontal-bar-chart/2", + "index": 73, + "adapter": "bars", + "variant": "d3-horizontal-bar-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Diverging bar chart", + "author": "D3", + "id": "d3-diverging-bar-chart-2", + "source": "https://observablehq.com/@d3/diverging-bar-chart/2", + "index": 74, + "adapter": "bars", + "variant": "d3-diverging-bar-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Stacked bar chart", + "author": "D3", + "id": "d3-stacked-bar-chart-2", + "source": "https://observablehq.com/@d3/stacked-bar-chart/2", + "index": 75, + "adapter": "bars", + "variant": "d3-stacked-bar-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Stacked horizontal bar chart", + "author": "D3", + "id": "d3-stacked-horizontal-bar-chart-2", + "source": "https://observablehq.com/@d3/stacked-horizontal-bar-chart/2", + "index": 76, + "adapter": "bars", + "variant": "d3-stacked-horizontal-bar-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Stacked normalized horizontal bar chart", + "author": "D3", + "id": "d3-stacked-normalized-horizontal-bar-2", + "source": "https://observablehq.com/@d3/stacked-normalized-horizontal-bar/2", + "index": 77, + "adapter": "bars", + "variant": "d3-stacked-normalized-horizontal-bar-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Grouped bar chart", + "author": "D3", + "id": "d3-grouped-bar-chart-2", + "source": "https://observablehq.com/@d3/grouped-bar-chart/2", + "index": 78, + "adapter": "bars", + "variant": "d3-grouped-bar-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Diverging stacked bar chart", + "author": "D3", + "id": "d3-diverging-stacked-bar-chart-2", + "source": "https://observablehq.com/@d3/diverging-stacked-bar-chart/2", + "index": 79, + "adapter": "bars", + "variant": "d3-diverging-stacked-bar-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Marimekko chart", + "author": "D3", + "id": "d3-marimekko-chart", + "source": "https://observablehq.com/@d3/marimekko-chart", + "index": 80, + "adapter": "mosaic", + "variant": "d3-marimekko-chart", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "World history timeline", + "author": "Danilo Di Cuia", + "id": "tezzutezzu-world-history-timeline", + "source": "https://observablehq.com/@tezzutezzu/world-history-timeline", + "index": 81, + "adapter": "timeline", + "variant": "tezzutezzu-world-history-timeline", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Calendar", + "author": "D3", + "id": "d3-calendar-2", + "source": "https://observablehq.com/@d3/calendar/2", + "index": 82, + "adapter": "calendar", + "variant": "d3-calendar-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "The impact of vaccines", + "author": "D3", + "id": "d3-the-impact-of-vaccines", + "source": "https://observablehq.com/@d3/the-impact-of-vaccines", + "index": 83, + "adapter": "heatmap", + "variant": "d3-the-impact-of-vaccines", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Electricity usage, 2019", + "author": "Mike Bostock", + "id": "mbostock-electric-usage-2019", + "source": "https://observablehq.com/@mbostock/electric-usage-2019", + "index": 84, + "adapter": "heatmap", + "variant": "mbostock-electric-usage-2019", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "bars", + "title": "Revenue by music format, 1973\u20132018", + "author": "D3", + "id": "d3-revenue-by-music-format-1973-2018", + "source": "https://observablehq.com/@d3/revenue-by-music-format-1973-2018", + "index": 85, + "adapter": "bars", + "variant": "d3-revenue-by-music-format-1973-2018", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Line chart", + "author": "D3", + "id": "d3-line-chart-2", + "source": "https://observablehq.com/@d3/line-chart/2", + "index": 86, + "adapter": "line", + "variant": "d3-line-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Line with missing data", + "author": "D3", + "id": "d3-line-chart-missing-data-2", + "source": "https://observablehq.com/@d3/line-chart-missing-data/2", + "index": 87, + "adapter": "line", + "variant": "d3-line-chart-missing-data-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Multi-line chart", + "author": "D3", + "id": "d3-multi-line-chart-2", + "source": "https://observablehq.com/@d3/multi-line-chart/2", + "index": 88, + "adapter": "line", + "variant": "d3-multi-line-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Change line chart", + "author": "D3", + "id": "d3-change-line-chart-2", + "source": "https://observablehq.com/@d3/change-line-chart/2", + "index": 89, + "adapter": "line", + "variant": "d3-change-line-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Slope chart", + "author": "D3", + "id": "d3-slope-chart-3", + "source": "https://observablehq.com/@d3/slope-chart/3", + "index": 90, + "adapter": "slope", + "variant": "d3-slope-chart-3", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Slope chart II", + "author": "D3", + "id": "d3-cancer-survival-rates-2", + "source": "https://observablehq.com/@d3/cancer-survival-rates/2", + "index": 91, + "adapter": "slope", + "variant": "d3-cancer-survival-rates-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Marey\u2019s trains", + "author": "D3", + "id": "d3-mareys-trains", + "source": "https://observablehq.com/@d3/mareys-trains", + "index": 92, + "adapter": "trains", + "variant": "d3-mareys-trains", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Candlestick chart", + "author": "D3", + "id": "d3-candlestick-chart-2", + "source": "https://observablehq.com/@d3/candlestick-chart/2", + "index": 93, + "adapter": "candle", + "variant": "d3-candlestick-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Variable-color line", + "author": "D3", + "id": "d3-variable-color-line", + "source": "https://observablehq.com/@d3/variable-color-line", + "index": 94, + "adapter": "line", + "variant": "d3-variable-color-line", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Gradient encoding", + "author": "D3", + "id": "d3-gradient-encoding", + "source": "https://observablehq.com/@d3/gradient-encoding", + "index": 95, + "adapter": "line", + "variant": "d3-gradient-encoding", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Threshold encoding", + "author": "D3", + "id": "d3-threshold-encoding", + "source": "https://observablehq.com/@d3/threshold-encoding", + "index": 96, + "adapter": "line", + "variant": "d3-threshold-encoding", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Parallel coordinates", + "author": "D3", + "id": "d3-parallel-coordinates", + "source": "https://observablehq.com/@d3/parallel-coordinates", + "index": 97, + "adapter": "parallel", + "variant": "d3-parallel-coordinates", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Inequality in American cities", + "author": "D3", + "id": "d3-inequality-in-american-cities", + "source": "https://observablehq.com/@d3/inequality-in-american-cities", + "index": 98, + "adapter": "line", + "variant": "d3-inequality-in-american-cities", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "New zealand tourists, 1921\u20132018", + "author": "D3", + "id": "d3-new-zealand-tourists-1921-2018", + "source": "https://observablehq.com/@d3/new-zealand-tourists-1921-2018", + "index": 99, + "adapter": "line", + "variant": "d3-new-zealand-tourists-1921-2018", + "animated": false, + "interaction": "scale", + "data": "deterministic-demo" + }, + { + "category": "lines", + "title": "Sea ice extent, 1978\u20132017", + "author": "D3", + "id": "d3-sea-ice-extent-1978-2017", + "source": "https://observablehq.com/@d3/sea-ice-extent-1978-2017", + "index": 100, + "adapter": "line", + "variant": "d3-sea-ice-extent-1978-2017", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Area chart", + "author": "D3", + "id": "d3-area-chart-2", + "source": "https://observablehq.com/@d3/area-chart/2", + "index": 101, + "adapter": "area", + "variant": "d3-area-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Area with missing data", + "author": "D3", + "id": "d3-area-chart-missing-data-2", + "source": "https://observablehq.com/@d3/area-chart-missing-data/2", + "index": 102, + "adapter": "area", + "variant": "d3-area-chart-missing-data-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Stacked area chart", + "author": "D3", + "id": "d3-stacked-area-chart-2", + "source": "https://observablehq.com/@d3/stacked-area-chart/2", + "index": 103, + "adapter": "area", + "variant": "d3-stacked-area-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Normalized stacked area chart", + "author": "D3", + "id": "d3-normalized-stacked-area-chart-2", + "source": "https://observablehq.com/@d3/normalized-stacked-area-chart/2", + "index": 104, + "adapter": "area", + "variant": "d3-normalized-stacked-area-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "U.S. population by state, 1790\u20131990", + "author": "D3", + "id": "d3-u-s-population-by-state-1790-1990", + "source": "https://observablehq.com/@d3/u-s-population-by-state-1790-1990", + "index": 105, + "adapter": "area", + "variant": "d3-u-s-population-by-state-1790-1990", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Streamgraph", + "author": "D3", + "id": "d3-streamgraph-2", + "source": "https://observablehq.com/@d3/streamgraph/2", + "index": 106, + "adapter": "area", + "variant": "d3-streamgraph-2", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Difference chart", + "author": "D3", + "id": "d3-difference-chart-2", + "source": "https://observablehq.com/@d3/difference-chart/2", + "index": 107, + "adapter": "area", + "variant": "d3-difference-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Band chart", + "author": "D3", + "id": "d3-band-chart-2", + "source": "https://observablehq.com/@d3/band-chart/2", + "index": 108, + "adapter": "area", + "variant": "d3-band-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Ridgeline (joy) plot", + "author": "D3", + "id": "d3-ridgeline-plot", + "source": "https://observablehq.com/@d3/ridgeline-plot", + "index": 109, + "adapter": "ridgeline", + "variant": "d3-ridgeline-plot", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Horizon chart", + "author": "D3", + "id": "d3-horizon-chart-2", + "source": "https://observablehq.com/@d3/horizon-chart/2", + "index": 110, + "adapter": "horizon", + "variant": "d3-horizon-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "areas", + "title": "Realtime horizon chart", + "author": "D3", + "id": "d3-realtime-horizon-chart", + "source": "https://observablehq.com/@d3/realtime-horizon-chart", + "index": 111, + "adapter": "horizon", + "variant": "d3-realtime-horizon-chart", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Scatterplot", + "author": "D3", + "id": "d3-scatterplot-2", + "source": "https://observablehq.com/@d3/scatterplot/2", + "index": 112, + "adapter": "scatter", + "variant": "d3-scatterplot-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Scatterplot with shapes", + "author": "D3", + "id": "d3-scatterplot-with-shapes", + "source": "https://observablehq.com/@d3/scatterplot-with-shapes", + "index": 113, + "adapter": "scatter", + "variant": "d3-scatterplot-with-shapes", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Scatterplot matrix", + "author": "D3", + "id": "d3-splom-2", + "source": "https://observablehq.com/@d3/splom/2", + "index": 114, + "adapter": "matrix", + "variant": "d3-splom-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Dot plot", + "author": "D3", + "id": "d3-dot-plot-2", + "source": "https://observablehq.com/@d3/dot-plot/2", + "index": 115, + "adapter": "dots", + "variant": "d3-dot-plot-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Global temperature trends", + "author": "D3", + "id": "d3-global-temperature-trends", + "source": "https://observablehq.com/@d3/global-temperature-trends", + "index": 116, + "adapter": "scatter", + "variant": "d3-global-temperature-trends", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Bubble map", + "author": "D3", + "id": "d3-bubble-map-2", + "source": "https://observablehq.com/@d3/bubble-map/2", + "index": 117, + "adapter": "map", + "variant": "d3-bubble-map-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Spike map", + "author": "D3", + "id": "d3-spike-map-2", + "source": "https://observablehq.com/@d3/spike-map/2", + "index": 118, + "adapter": "map", + "variant": "d3-spike-map-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Bubble chart", + "author": "D3", + "id": "d3-bubble-chart-2", + "source": "https://observablehq.com/@d3/bubble-chart/2", + "index": 119, + "adapter": "bubbles", + "variant": "d3-bubble-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Beeswarm", + "author": "D3", + "id": "d3-beeswarm-2", + "source": "https://observablehq.com/@d3/beeswarm/2", + "index": 120, + "adapter": "beeswarm", + "variant": "d3-beeswarm-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Mirrored beeswarm", + "author": "D3", + "id": "d3-beeswarm-mirrored-2", + "source": "https://observablehq.com/@d3/beeswarm-mirrored/2", + "index": 121, + "adapter": "beeswarm", + "variant": "d3-beeswarm-mirrored-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "dots", + "title": "Hertzsprung\u2013Russell diagram", + "author": "D3", + "id": "d3-hertzsprung-russell-diagram", + "source": "https://observablehq.com/@d3/hertzsprung-russell-diagram", + "index": 122, + "adapter": "scatter", + "variant": "d3-hertzsprung-russell-diagram", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "radial", + "title": "Pie chart", + "author": "D3", + "id": "d3-pie-chart-2", + "source": "https://observablehq.com/@d3/pie-chart/2", + "index": 123, + "adapter": "pie", + "variant": "d3-pie-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "radial", + "title": "Donut chart", + "author": "D3", + "id": "d3-donut-chart-2", + "source": "https://observablehq.com/@d3/donut-chart/2", + "index": 124, + "adapter": "pie", + "variant": "d3-donut-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "radial", + "title": "Radial area chart", + "author": "D3", + "id": "d3-radial-area-chart-2", + "source": "https://observablehq.com/@d3/radial-area-chart/2", + "index": 125, + "adapter": "radialarea", + "variant": "d3-radial-area-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "radial", + "title": "Radial stacked bar chart", + "author": "D3", + "id": "d3-radial-stacked-bar-chart-2", + "source": "https://observablehq.com/@d3/radial-stacked-bar-chart/2", + "index": 126, + "adapter": "radialbars", + "variant": "d3-radial-stacked-bar-chart-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "radial", + "title": "Radial stacked bar chart (sorted)", + "author": "D3", + "id": "d3-radial-stacked-bar-chart-3", + "source": "https://observablehq.com/@d3/radial-stacked-bar-chart/3", + "index": 127, + "adapter": "radialbars", + "variant": "d3-radial-stacked-bar-chart-3", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "annotation", + "title": "Inline labels", + "author": "D3", + "id": "d3-inline-labels-2", + "source": "https://observablehq.com/@d3/inline-labels/2", + "index": 128, + "adapter": "line", + "variant": "d3-inline-labels-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "annotation", + "title": "Directly labelling lines", + "author": "Harry Stevens", + "id": "harrystevens-directly-labelling-lines", + "source": "https://observablehq.com/@harrystevens/directly-labelling-lines", + "index": 129, + "adapter": "line", + "variant": "harrystevens-directly-labelling-lines", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "annotation", + "title": "Line chart with tooltip", + "author": "D3", + "id": "d3-line-with-tooltip-2", + "source": "https://observablehq.com/@d3/line-with-tooltip/2", + "index": 130, + "adapter": "line", + "variant": "d3-line-with-tooltip-2", + "animated": false, + "interaction": "tooltip", + "data": "deterministic-demo" + }, + { + "category": "annotation", + "title": "Voronoi labels", + "author": "D3", + "id": "d3-voronoi-labels", + "source": "https://observablehq.com/@d3/voronoi-labels", + "index": 131, + "adapter": "voronoi", + "variant": "d3-voronoi-labels", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "annotation", + "title": "Occlusion", + "author": "Fil", + "id": "fil-occlusion", + "source": "https://observablehq.com/@fil/occlusion", + "index": 132, + "adapter": "occlusion", + "variant": "fil-occlusion", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "annotation", + "title": "Graticule labels", + "author": "D3", + "id": "d3-graticule-labels-stereographic", + "source": "https://observablehq.com/@d3/graticule-labels-stereographic", + "index": 133, + "adapter": "map", + "variant": "d3-graticule-labels-stereographic", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "annotation", + "title": "Styled axes", + "author": "D3", + "id": "d3-styled-axes", + "source": "https://observablehq.com/@d3/styled-axes", + "index": 134, + "adapter": "line", + "variant": "d3-styled-axes", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "annotation", + "title": "Color legend", + "author": "D3", + "id": "d3-color-legend", + "source": "https://observablehq.com/@d3/color-legend", + "index": 135, + "adapter": "legend", + "variant": "d3-color-legend", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Choropleth", + "author": "D3", + "id": "d3-choropleth-2", + "source": "https://observablehq.com/@d3/choropleth/2", + "index": 136, + "adapter": "map", + "variant": "d3-choropleth-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Bivariate choropleth", + "author": "D3", + "id": "d3-bivariate-choropleth", + "source": "https://observablehq.com/@d3/bivariate-choropleth", + "index": 137, + "adapter": "map", + "variant": "d3-bivariate-choropleth", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "State choropleth", + "author": "D3", + "id": "d3-us-state-choropleth-2", + "source": "https://observablehq.com/@d3/us-state-choropleth/2", + "index": 138, + "adapter": "map", + "variant": "d3-us-state-choropleth-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "World choropleth", + "author": "D3", + "id": "d3-world-choropleth-2", + "source": "https://observablehq.com/@d3/world-choropleth/2", + "index": 139, + "adapter": "map", + "variant": "d3-world-choropleth-2", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "World map", + "author": "D3", + "id": "d3-world-map", + "source": "https://observablehq.com/@d3/world-map", + "index": 140, + "adapter": "map", + "variant": "d3-world-map", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Projection transitions", + "author": "D3", + "id": "d3-projection-transitions", + "source": "https://observablehq.com/@d3/projection-transitions", + "index": 141, + "adapter": "map", + "variant": "d3-projection-transitions", + "animated": true, + "interaction": "projection", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Projection comparison", + "author": "D3", + "id": "d3-projection-comparison", + "source": "https://observablehq.com/@d3/projection-comparison", + "index": 142, + "adapter": "map", + "variant": "d3-projection-comparison", + "animated": false, + "interaction": "projection", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Antimeridian cutting", + "author": "D3", + "id": "d3-antimeridian-cutting", + "source": "https://observablehq.com/@d3/antimeridian-cutting", + "index": 143, + "adapter": "map", + "variant": "d3-antimeridian-cutting", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Tissot\u2019s indicatrix", + "author": "D3", + "id": "d3-tissots-indicatrix", + "source": "https://observablehq.com/@d3/tissots-indicatrix", + "index": 144, + "adapter": "map", + "variant": "d3-tissots-indicatrix", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Web Mercator tiles", + "author": "D3", + "id": "d3-web-mercator-tiles", + "source": "https://observablehq.com/@d3/web-mercator-tiles", + "index": 145, + "adapter": "tiles", + "variant": "d3-web-mercator-tiles", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Raster tiles", + "author": "D3", + "id": "d3-raster-tiles", + "source": "https://observablehq.com/@d3/raster-tiles", + "index": 146, + "adapter": "tiles", + "variant": "d3-raster-tiles", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Vector tiles", + "author": "D3", + "id": "d3-vector-tiles", + "source": "https://observablehq.com/@d3/vector-tiles", + "index": 147, + "adapter": "tiles", + "variant": "d3-vector-tiles", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Clipped map tiles", + "author": "D3", + "id": "d3-clipped-map-tiles", + "source": "https://observablehq.com/@d3/clipped-map-tiles", + "index": 148, + "adapter": "tiles", + "variant": "d3-clipped-map-tiles", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Raster & vector", + "author": "D3", + "id": "d3-raster-vector", + "source": "https://observablehq.com/@d3/raster-vector", + "index": 149, + "adapter": "tiles", + "variant": "d3-raster-vector", + "animated": false, + "interaction": "zoom", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Vector field", + "author": "D3", + "id": "d3-vector-field", + "source": "https://observablehq.com/@d3/vector-field", + "index": 150, + "adapter": "vectorfield", + "variant": "d3-vector-field", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "GeoTIFF contours", + "author": "D3", + "id": "d3-geotiff-contours-ii", + "source": "https://observablehq.com/@d3/geotiff-contours-ii", + "index": 151, + "adapter": "contours", + "variant": "d3-geotiff-contours-ii", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "U.S. airports voronoi", + "author": "D3", + "id": "d3-us-airports-voronoi", + "source": "https://observablehq.com/@d3/us-airports-voronoi", + "index": 152, + "adapter": "map", + "variant": "d3-us-airports-voronoi", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "World airports voronoi", + "author": "D3", + "id": "d3-world-airports-voronoi", + "source": "https://observablehq.com/@d3/world-airports-voronoi", + "index": 153, + "adapter": "map", + "variant": "d3-world-airports-voronoi", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Solar terminator", + "author": "D3", + "id": "d3-solar-terminator", + "source": "https://observablehq.com/@d3/solar-terminator", + "index": 154, + "adapter": "map", + "variant": "d3-solar-terminator", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Solar path", + "author": "D3", + "id": "d3-solar-path", + "source": "https://observablehq.com/@d3/solar-path", + "index": 155, + "adapter": "map", + "variant": "d3-solar-path", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Star map", + "author": "D3", + "id": "d3-star-map", + "source": "https://observablehq.com/@d3/star-map", + "index": 156, + "adapter": "stars", + "variant": "d3-star-map", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "maps", + "title": "Non-contiguous cartogram", + "author": "D3", + "id": "d3-non-contiguous-cartogram", + "source": "https://observablehq.com/@d3/non-contiguous-cartogram", + "index": 157, + "adapter": "cartogram", + "variant": "d3-non-contiguous-cartogram", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "essays", + "title": "d3.packEnclose", + "author": "D3", + "id": "d3-d3-packenclose", + "source": "https://observablehq.com/@d3/d3-packenclose", + "index": 158, + "adapter": "enclosure", + "variant": "d3-d3-packenclose", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "essays", + "title": "Centerline labeling", + "author": "Noah Veltman", + "id": "veltman-centerline-labeling", + "source": "https://observablehq.com/@veltman/centerline-labeling", + "index": 159, + "adapter": "centerline", + "variant": "veltman-centerline-labeling", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "essays", + "title": "Methods of comparison, compared", + "author": "Mike Bostock", + "id": "mbostock-methods-of-comparison-compared", + "source": "https://observablehq.com/@mbostock/methods-of-comparison-compared", + "index": 160, + "adapter": "comparison", + "variant": "mbostock-methods-of-comparison-compared", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "essays", + "title": "Predator and prey", + "author": "Mike Bostock", + "id": "mbostock-predator-and-prey", + "source": "https://observablehq.com/@mbostock/predator-and-prey", + "index": 161, + "adapter": "predator", + "variant": "mbostock-predator-and-prey", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Collision detection", + "author": "Mike Bostock", + "id": "d3-collision-detection-2", + "source": "https://observablehq.com/@d3/collision-detection/2", + "index": 162, + "adapter": "network", + "variant": "d3-collision-detection-2", + "animated": true, + "interaction": "drag", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Polar clock", + "author": "Mike Bostock", + "id": "mbostock-polar-clock", + "source": "https://observablehq.com/@mbostock/polar-clock", + "index": 163, + "adapter": "clock", + "variant": "mbostock-polar-clock", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Stern\u2013brocot tree", + "author": "Mike Bostock", + "id": "mbostock-stern-brocot-tree", + "source": "https://observablehq.com/@mbostock/stern-brocot-tree", + "index": 164, + "adapter": "fractions", + "variant": "mbostock-stern-brocot-tree", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Voronoi stippling", + "author": "Mike Bostock", + "id": "mbostock-voronoi-stippling", + "source": "https://observablehq.com/@mbostock/voronoi-stippling", + "index": 165, + "adapter": "stipple", + "variant": "mbostock-voronoi-stippling", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Watercolor", + "author": "Noah Veltman", + "id": "veltman-watercolor", + "source": "https://observablehq.com/@veltman/watercolor", + "index": 166, + "adapter": "watercolor", + "variant": "veltman-watercolor", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "PSR B1919+21", + "author": "D3", + "id": "d3-psr-b1919-21", + "source": "https://observablehq.com/@d3/psr-b1919-21", + "index": 167, + "adapter": "ridgeline", + "variant": "d3-psr-b1919-21", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Epicyclic gearing", + "author": "D3", + "id": "d3-epicyclic-gearing", + "source": "https://observablehq.com/@d3/epicyclic-gearing", + "index": 168, + "adapter": "gears", + "variant": "d3-epicyclic-gearing", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Owls to the max", + "author": "Mike Bostock", + "id": "mbostock-owls-to-the-max", + "source": "https://observablehq.com/@mbostock/owls-to-the-max", + "index": 169, + "adapter": "owl", + "variant": "mbostock-owls-to-the-max", + "animated": true, + "interaction": "refine", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Tadpoles", + "author": "Mike Bostock", + "id": "mbostock-tadpoles", + "source": "https://observablehq.com/@mbostock/tadpoles", + "index": 170, + "adapter": "tadpoles", + "variant": "mbostock-tadpoles", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Word cloud", + "author": "D3", + "id": "d3-word-cloud", + "source": "https://observablehq.com/@d3/word-cloud", + "index": 171, + "adapter": "words", + "variant": "d3-word-cloud", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Spilhaus shoreline map", + "author": "D3", + "id": "d3-spilhaus-shoreline-map", + "source": "https://observablehq.com/@d3/spilhaus-shoreline-map", + "index": 172, + "adapter": "map", + "variant": "d3-spilhaus-shoreline-map", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Phases of the moon", + "author": "Mike Bostock", + "id": "mbostock-phases-of-the-moon", + "source": "https://observablehq.com/@mbostock/phases-of-the-moon", + "index": 173, + "adapter": "moon", + "variant": "mbostock-phases-of-the-moon", + "animated": true, + "interaction": "inspect", + "data": "deterministic-demo" + }, + { + "category": "fun", + "title": "Color schemes", + "author": "D3", + "id": "d3-color-schemes", + "source": "https://observablehq.com/@d3/color-schemes", + "index": 174, + "adapter": "schemes", + "variant": "d3-color-schemes", + "animated": false, + "interaction": "inspect", + "data": "deterministic-demo" + } + ] +} diff --git a/cerebral-src/visualizations/kernels.js b/cerebral-src/visualizations/kernels.js new file mode 100644 index 0000000..dac15e9 --- /dev/null +++ b/cerebral-src/visualizations/kernels.js @@ -0,0 +1,85 @@ +export async function loadKernels(url = "/visualizations/kernels.wasm") { + const response = await fetch(url); + if (!response.ok) + throw new Error(`WASM download returned ${response.status}`); + const { instance } = await WebAssembly.instantiate( + await response.arrayBuffer(), + ); + const e = instance.exports; + if (!e.generate || !e.memory || e.capacity() !== 32768) + throw new Error("Unexpected WASM kernel interface"); + const input = () => + new Float64Array(e.memory.buffer, e.input_ptr(), e.capacity()); + const output = (n) => + Array.from(new Float64Array(e.memory.buffer, e.output_ptr(), n)); + return { + exports: e, + generate(seed, count, phase) { + const n = e.generate(seed, count, phase); + const raw = output(n * 6); + return Array.from({ length: n }, (_, i) => ({ + x: raw[6 * i], + value: raw[6 * i + 1], + comparison: raw[6 * i + 2], + group: raw[6 * i + 3], + angle: raw[6 * i + 4], + weight: raw[6 * i + 5], + name: `Sample ${i + 1}`, + })); + }, + average(values, window) { + input().set(values); + return output(e.moving_average(values.length, window)); + }, + bands(values, window) { + input().set(values); + const n = e.rolling_bands(values.length, window); + const raw = output(n * 2); + return Array.from({ length: n }, (_, i) => ({ + mean: raw[i * 2], + std: raw[i * 2 + 1], + })); + }, + histogram(values, bins, min, max) { + input().set(values); + return output(e.histogram(values.length, bins, min, max)); + }, + quantiles(values) { + input().set(values); + return output(e.quantiles(values.length)); + }, + kde(values, bandwidth, min, max) { + input().set(values); + const n = e.kde(values.length, bandwidth, min, max); + const raw = output(n * 2); + return Array.from({ length: n }, (_, i) => [raw[i * 2], raw[i * 2 + 1]]); + }, + force(nodes, links, iterations = 35) { + let positions = nodes.flatMap((n) => [n.x, n.y]); + const edges = links.flatMap((e) => [e.source, e.target]); + for (let i = 0; i < iterations; i++) { + input().set([...positions, ...edges]); + e.force_step(nodes.length, links.length, 0.06); + positions = output(nodes.length * 2); + } + return nodes.map((n, i) => ({ + ...n, + x: positions[i * 2], + y: positions[i * 2 + 1], + })); + }, + nearest(points, x, y) { + input().set(points.flatMap((p) => [p[0], p[1]])); + return e.nearest(points.length, x, y); + }, + predator(count, dt) { + const n = e.predator_prey(count, dt); + const raw = output(n * 3); + return Array.from({ length: n }, (_, i) => ({ + x: raw[3 * i], + prey: raw[3 * i + 1], + predator: raw[3 * i + 2], + })); + }, + }; +} diff --git a/cerebral-src/visualizations/lab.css b/cerebral-src/visualizations/lab.css new file mode 100644 index 0000000..dcff09a --- /dev/null +++ b/cerebral-src/visualizations/lab.css @@ -0,0 +1,619 @@ +@font-face { + font-family: "Space Mono"; + src: url("https://cerebral.work/fonts/SpaceMono-Regular.woff2") + format("woff2"); + font-display: swap; +} +:root { + --paper: #f0eee9; + --ink: #0a0a0b; + --muted: #58564f; + --line: #b9b6ae; + --panel: #e5e2db; + color-scheme: light; + --mono: "Space Mono", ui-monospace, monospace; + --display: "fractul-variable", "gunter", Arial, sans-serif; +} +:root[data-theme="dark"] { + --paper: #0a0a0b; + --ink: #f0eee9; + --muted: #b9b6ae; + --line: #55534e; + --panel: #1c1c1c; + color-scheme: dark; +} +* { + box-sizing: border-box; +} +body { + margin: 0; + background: var(--paper); + color: var(--ink); + font: 16px/1.5 var(--display); + -webkit-font-smoothing: antialiased; +} +a { + color: inherit; + text-underline-offset: 4px; +} +button, +input, +select { + font: inherit; + color: inherit; + border-radius: 0; +} +button, +select, +input[type="search"] { + background: transparent; + border: 1px solid var(--line); + padding: 10px 12px; +} +button { + cursor: pointer; +} +button:hover { + background: var(--panel); +} +button:disabled { + opacity: 0.6; + cursor: default; +} +:focus-visible { + outline: 2px solid var(--ink); + outline-offset: 4px; +} +[hidden] { + display: none !important; +} +h1, +h2, +h3, +p, +figure { + margin: 0; +} +h1, +h2, +h3 { + font-weight: 400; +} +button { + white-space: nowrap; +} +.muted { + color: var(--muted); +} +.eyebrow { + font: 10px/1.6 var(--mono); + text-transform: uppercase; + letter-spacing: 0.07em; +} +.skip { + position: fixed; + z-index: 100; + top: 10px; + left: 16px; + padding: 12px; + background: var(--ink); + color: var(--paper); + transform: translateY(-180%); +} +.skip:focus { + transform: none; +} +.lab-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 24px clamp(16px, 2.2vw, 36px); + border-bottom: 1px solid var(--line); + gap: 24px; +} +.brand { + text-decoration: none; + letter-spacing: 0.22em; + font-size: 14px; +} +.brand span { + letter-spacing: 0; + margin-left: 16px; +} +.lab-header nav { + display: flex; + align-items: center; + gap: 28px; + font-size: 13px; +} +.lab-header nav a { + text-decoration: none; +} +#lab-theme { + width: 40px; + height: 40px; + padding: 0; +} +.lab-intro { + padding: 44px clamp(16px, 2.2vw, 36px) 56px; + display: grid; + grid-template-columns: 1.1fr 1fr; + gap: 64px; +} +.lab-intro h1 { + font-size: clamp(56px, 6.5vw, 102px); + line-height: 1; + letter-spacing: -0.05em; + margin-top: 28px; +} +.intro-lead { + font-size: clamp(20px, 2.2vw, 32px); + line-height: 1.25; + margin: 38px 0 24px; +} +.lab-intro .muted { + max-width: 560px; + font-size: 14px; +} +.runtime { + display: flex; + gap: 24px; + margin-top: 28px; + font: 10px var(--mono); + flex-wrap: wrap; +} +.runtime span:before { + content: ""; + display: inline-block; + width: 5px; + height: 5px; + background: currentColor; + margin-right: 8px; +} +.lab-layout { + display: grid; + grid-template-columns: 260px minmax(0, 1fr); + border-top: 1px solid var(--line); +} +.catalog { + border-right: 1px solid var(--line); + padding: 24px 18px; + align-self: start; + position: sticky; + top: 0; + max-height: 100vh; + overflow: auto; +} +.catalog label { + display: block; + font: 11px var(--mono); + margin: 0 0 10px; +} +.catalog input, +.catalog select { + width: 100%; + min-width: 0; + font-size: 12px; +} +.catalog select { + margin-bottom: 0; +} +.catalog label[for="catalog-category"] { + margin-top: 20px; +} +.catalog-status { + font: 10px var(--mono); + padding: 24px 0 12px; +} +.catalog nav { + display: grid; +} +.catalog nav a { + display: grid; + grid-template-columns: 24px 1fr; + gap: 8px; + text-decoration: none; + padding: 10px 8px; + border-top: 1px solid var(--line); + font-size: 12px; + line-height: 1.4; +} +.catalog nav a small { + font: 9px var(--mono); + padding-top: 2px; +} +.catalog nav a[aria-current="page"] { + background: var(--ink); + color: var(--paper); +} +.catalog nav a:hover { + text-decoration: underline; +} +.catalog-source { + font: 10px/1.8 var(--mono); + color: var(--muted); + margin-top: 32px; +} +.catalog-source a { + display: block; + margin-top: 10px; +} +.lab-layout main { + min-width: 0; + padding: 0 clamp(16px, 2.5vw, 44px); +} +.lab-layout main:focus { + outline: none; +} +.example-heading { + display: flex; + align-items: start; + justify-content: space-between; + gap: 24px; + padding: 32px 0 28px; +} +.example-heading h2 { + font-size: clamp(28px, 3vw, 46px); + line-height: 1.1; + letter-spacing: -0.035em; + margin: 16px 0; +} +.example-heading .muted { + max-width: 680px; + font-size: 14px; +} +.example-heading > a { + font-size: 11px; + white-space: nowrap; + margin-top: 30px; +} +.viewer-controls { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 12px; + padding: 16px 0; + border-top: 1px solid var(--line); + font-size: 12px; +} +.frame-control { + display: flex; + gap: 12px; + align-items: center; + flex: 1; + min-width: 180px; +} +.frame-control input { + width: 100%; + max-width: 240px; + min-width: 60px; +} +.frame-control output { + font: 10px var(--mono); + min-width: 22px; +} +.canvas-stage { + position: relative; + aspect-ratio: 960/560; + border: 1px solid var(--line); + overflow: hidden; + touch-action: none; + background: var(--paper); +} +#chart { + display: block; + width: 100%; + height: 100%; +} +#chart-labels { + position: absolute; + inset: 0; + pointer-events: none; + overflow: hidden; +} +.chart-label { + position: absolute; + white-space: nowrap; + font: 11px/1 var(--mono); + transform: translateY(-50%); + transform-origin: left center; +} +.visualization figcaption { + padding: 14px 0; + border-bottom: 1px solid var(--line); + font: 10px/1.6 var(--mono); + color: var(--muted); +} +#chart-tooltip { + position: absolute; + max-width: 250px; + bottom: 12px; + left: 12px; + background: var(--ink); + color: var(--paper); + padding: 10px 14px; + font: 11px/1.5 var(--mono); + pointer-events: none; +} +#renderer-error { + position: absolute; + inset: 20%; + padding: 20px; + background: var(--paper); + border: 1px solid var(--ink); + font-size: 14px; +} +#brush-selection { + position: absolute; + border: 1px solid var(--ink); + background: color-mix(in srgb, var(--ink) 10%, transparent); + pointer-events: none; +} +.parameter-bar { + display: flex; + gap: 24px; + justify-content: space-between; + align-items: center; + padding: 18px 0; + border-bottom: 1px solid var(--line); + font-size: 11px; + flex-wrap: wrap; +} +.parameter-bar label { + display: flex; + align-items: center; + gap: 12px; +} +.parameter-bar select { + padding: 8px; +} +.parameter-bar output { + font: 10px var(--mono); +} +input[type="range"] { + accent-color: var(--ink); +} +.interaction-help, +.selection-status { + font-size: 12px; + color: var(--muted); + margin: 18px 0; +} +.selection-status:empty { + display: none; +} +.data-details { + border-top: 1px solid var(--line); + padding: 24px 0; + margin-top: 28px; +} +.data-details summary { + cursor: pointer; + font-size: 14px; +} +.data-details summary span { + display: block; + font: 10px var(--mono); + color: var(--muted); + margin-top: 8px; +} +.data-details > p { + font-size: 12px; + max-width: 800px; + line-height: 1.7; +} +.table-scroll { + overflow: auto; + max-height: 400px; + max-width: 100%; + margin: 24px 0; +} +table { + border-collapse: collapse; + min-width: 600px; + width: 100%; + font: 11px var(--mono); +} +td, +th { + padding: 12px; + border-bottom: 1px solid var(--line); + text-align: left; +} +caption { + text-align: left; + padding: 12px; + color: var(--muted); +} +.lab-method { + display: grid; + grid-template-columns: 1fr 2fr; + gap: 36px; + border-top: 1px solid var(--line); + padding: 40px 0; +} +.lab-method h3 { + font-size: 32px; + line-height: 1.15; + letter-spacing: -0.03em; + margin-bottom: 24px; +} +.lab-method p:not(.eyebrow) { + font-size: 14px; + color: var(--muted); + margin: 20px 0; +} +.lab-method a { + font-size: 13px; +} +footer { + padding: 28px clamp(16px, 2.2vw, 36px); + border-top: 1px solid var(--line); + display: flex; + gap: 24px; + justify-content: space-between; + font: 10px var(--mono); + flex-wrap: wrap; +} +.fallback-note { + padding: 20px; + border: 1px solid var(--line); + font-size: 14px; +} +@media (min-width: 1800px) { + .lab-header, + .lab-intro, + .lab-layout, + footer { + max-width: 1800px; + margin: auto; + } +} +@media (max-width: 1000px) { + .lab-layout { + grid-template-columns: 220px minmax(0, 1fr); + } + .example-heading { + flex-direction: column; + gap: 4px; + } + .example-heading > a { + margin-top: 8px; + } + .lab-intro { + gap: 32px; + } + .frame-control { + flex-basis: 100%; + } + .lab-method { + grid-template-columns: 1fr; + } +} +@media (max-width: 760px) { + .lab-intro { + grid-template-columns: 1fr; + gap: 0; + padding-bottom: 32px; + } + .lab-intro h1 { + font-size: 64px; + } + .intro-lead { + margin-top: 24px; + } + .lab-layout { + grid-template-columns: 1fr; + } + .catalog { + position: static; + max-height: none; + border-right: 0; + border-bottom: 1px solid var(--line); + display: grid; + grid-template-columns: 1fr 1fr; + gap: 10px 20px; + } + .catalog label { + margin: 0 !important; + } + .catalog input { + grid-column: 1; + grid-row: 2; + } + .catalog select { + grid-column: 2; + grid-row: 2; + } + .catalog-status { + grid-column: 1/-1; + padding: 8px 0; + } + .catalog nav { + grid-column: 1/-1; + max-height: 190px; + overflow: auto; + grid-template-columns: 1fr 1fr; + column-gap: 20px; + } + .catalog-source { + display: none; + } + .lab-header nav { + gap: 16px; + } + .lab-header nav a:nth-child(2) { + display: none; + } + .canvas-stage { + min-height: 240px; + } + .chart-label { + font-size: 8px !important; + } + .parameter-bar { + gap: 16px; + } + .parameter-bar label:first-child { + flex-basis: 100%; + } + .parameter-bar input { + max-width: 180px; + } + .lab-method { + gap: 16px; + } + .runtime { + font-size: 9px; + } + .data-details summary span { + line-height: 1.7; + } +} +@media (max-width: 380px) { + .lab-intro h1 { + font-size: 54px; + } + .brand { + font-size: 11px; + } + .brand span { + margin-left: 6px; + } + .lab-header nav { + gap: 10px; + font-size: 11px; + } + .catalog { + gap: 10px 12px; + } + .catalog nav { + column-gap: 12px; + } + .example-heading h2 { + font-size: 30px; + } + .viewer-controls { + gap: 8px; + } + .canvas-stage { + min-height: 210px; + } +} +@media (prefers-reduced-motion: reduce) { + * { + scroll-behavior: auto !important; + animation: none !important; + transition: none !important; + } +} +/* Keep the fixed chart coordinate system proportional at narrow widths. */ +.canvas-stage { + width: 100%; + min-width: 0; +} +@media (max-width: 760px) { + .canvas-stage { + min-height: 0; + } +} diff --git a/cerebral-src/visualizations/lab.js b/cerebral-src/visualizations/lab.js new file mode 100644 index 0000000..8e8b2f2 --- /dev/null +++ b/cerebral-src/visualizations/lab.js @@ -0,0 +1,694 @@ +import inventory from "./inventory.json"; +import { Quaternion, Vector3, Euler } from "three"; +import { loadKernels } from "./kernels.js"; +import { Painter, Viewport } from "./painter.js"; +import { draw } from "./layouts.js"; +import { getTerrain, loadTerrain } from "./raster.js"; +const $ = (id) => document.getElementById(id), + entries = inventory.entries, + canvas = $("chart"); +const state = { + frame: 50, + window: 16, + count: 192, + zoom: 1, + pan: [0, 0], + rotation: 0, + projection: 0, + depth: 0, + focus: 0, + collapsed: false, + sorted: false, + log: false, + refine: 0, + dragNode: null, +}; +let renderedView = { zoom: 1, pan: [0, 0] }; +let terrainLoading = false; +let entry = entries[71], + kernels, + viewport, + painter, + rows = [], + playing = false, + selected = -1, + lastFrame = 0, + raf = 0, + drag = null; +const descriptions = { + treemap: + "Partition an area by value while preserving parent–child relationships.", + network: "Balance repulsion and link constraints to reveal connectivity.", + scatter: + "Position observations by two variables; inspect the relationship rather than a summary alone.", + bars: "Compare values through position and length on a shared baseline.", + area: "Compare continuous quantities through filled area and common time coordinates.", + map: "Project geographic geometry and inspect a spatial encoding.", + tree: "Follow explicit parent–child relationships through a hierarchical layout.", + pack: "Use nested circles to reveal containment and relative weight.", + sunburst: "Encode hierarchical depth as radial bands and value as angle.", + icicle: "Encode hierarchical depth as horizontal bands and value as width.", + histogram: + "Aggregate numeric observations into bins using the WASM histogram kernel.", + kde: "Estimate a continuous density using the WASM Gaussian kernel.", + box: "Summarize each group with minimum, quartiles, median and maximum.", + qq: "Compare ordered observations with corresponding sample or normal quantiles.", + tiles: + "Explore local raster and vector tiles with Web Mercator z/x/y coordinates.", + predator: "Integrate the coupled Lotka–Volterra equations using WASM.", + chord: "Encode flows between groups with arcs and ribbons.", + sankey: "Preserve flow quantities between successive stages.", + beeswarm: + "Resolve overlap while preserving each observation’s value coordinate.", + matrix: "Compare pairs of variables across a matrix of scatterplots.", + density: "Estimate a two-dimensional density and trace its isolines.", + contours: "Trace raster thresholds with marching squares.", + hexbin: "Aggregate observations in a hexagonal spatial grid.", + words: + "Place weighted words with collision checks in a compact spiral layout.", +}; +const help = { + inspect: + "Move over the chart or use Left / Right arrow keys to inspect marks. The input table is below.", + brush: + "Drag a rectangular brush to select marks. Use arrow keys to inspect individual observations.", + zoom: "Use + / −, the mouse wheel, or drag to pan. Reset view returns to the original extent.", + pan: "Drag to pan the view; + / − or the mouse wheel change scale. Reset view returns to the original extent.", + rotate: + "Drag horizontally to rotate the globe. The frame slider changes its orientation.", + drill: + "Select a region or press Enter on the canvas to drill into the hierarchy. Reset view returns to the root.", + sort: "Use “Sort values” to reorder the bars. Reset view restores the original order.", + sequence: + "Move over an arc to inspect its place in the sequence. Click to focus a branch; reset to return.", + scale: "Use “Log / linear” to compare how the scale changes the same series.", + projection: + "Use “Next projection” or scrub the frame slider to compare projections.", + drag: "Drag a node to change its position. Reset view restores the layout.", + refine: + "Click the canvas or press Enter to subdivide the image. Reset view restores the initial level.", + index: + "Scrub the frame slider to change the reference observation used to index every series.", + tooltip: + "Move over the line or use Left / Right arrow keys to inspect a value.", +}; +function reset() { + Object.assign(state, { + zoom: 1, + pan: [0, 0], + rotation: 0, + rotation3D: null, + projection: 0, + depth: 0, + focus: 0, + collapsed: false, + sorted: false, + log: false, + refine: 0, + dragNode: null, + }); + $("brush-selection").hidden = true; + $("selection-status").textContent = ""; + selected = -1; +} +function setPlaying(value) { + playing = value && !matchMedia("(prefers-reduced-motion: reduce)").matches; + $("play").textContent = playing ? "Pause" : "Play"; + $("play").setAttribute("aria-pressed", String(playing)); + if (playing && !raf) raf = requestAnimationFrame(tick); +} +function tick(time) { + raf = 0; + if (!playing || document.hidden) return; + if (time - lastFrame > 160) { + lastFrame = time; + state.frame = (state.frame + 1) % 101; + $("frame").value = state.frame; + $("frame-value").textContent = state.frame; + syncUrl(); + render(false); + } + if (playing) raf = requestAnimationFrame(tick); +} +function syncUrl(push = false) { + const url = new URL(location.href); + url.searchParams.set("chart", entry.id); + const q = $("catalog-search").value.trim(), + category = $("catalog-category").value; + if (q) url.searchParams.set("q", q); + else url.searchParams.delete("q"); + if (category !== "all") url.searchParams.set("category", category); + else url.searchParams.delete("category"); + for (const [key, value, defaultValue] of [ + ["frame", state.frame, 50], + ["detail", state.window, 16], + ["samples", state.count, 192], + ]) { + if (value !== defaultValue) url.searchParams.set(key, String(value)); + else url.searchParams.delete(key); + } + history[push ? "pushState" : "replaceState"]({}, "", url); +} +function filter(sync = true) { + const query = $("catalog-search").value.trim().toLowerCase(), + category = $("catalog-category").value; + let count = 0; + for (const a of $("catalog-list").querySelectorAll("a")) { + const item = entries.find((e) => e.id === a.dataset.example); + const show = + (category === "all" || item.category === category) && + `${item.title} ${item.category} ${item.adapter}` + .toLowerCase() + .includes(query); + a.hidden = !show; + if (show) count++; + } + $("catalog-status").textContent = + `${count} of 174 examples${count ? "" : " · no matches"}`; + if (sync) syncUrl(); +} +function choose(id, push = true) { + const found = entries.find((e) => e.id === id); + entry = found || entries[71]; + reset(); + setPlaying(false); + $("example-title").textContent = entry.title; + $("example-category").textContent = + `${entry.category} / ${String(entry.index).padStart(3, "0")} of 174`; + $("example-description").textContent = + descriptions[entry.adapter] || + `Explore ${entry.title.toLowerCase()} using local geometry and a reproducible demonstration dataset.`; + $("example-source").href = entry.source; + $("example-source").textContent = `${entry.author} / original example ↗`; + $("interaction-help").textContent = help[entry.interaction] || help.inspect; + for (const a of $("catalog-list").querySelectorAll("a")) { + if (a.dataset.example === entry.id) a.setAttribute("aria-current", "page"); + else a.removeAttribute("aria-current"); + } + const labels = { + drill: "Drill into branch", + sequence: "Focus sequence", + sort: "Sort values", + scale: "Log / linear", + projection: "Next projection", + refine: "Refine image", + index: "Advance reference", + }; + const action = $("action"); + action.hidden = !labels[entry.interaction]; + action.textContent = labels[entry.interaction] || "Change view"; + $("frame-control").hidden = !( + entry.animated || + ["index", "projection", "rotate"].includes(entry.interaction) + ); + $("detail-control").hidden = !( + ["histogram", "kde", "density", "hexbin"].includes(entry.adapter) || + /moving-average|bollinger/.test(entry.variant) + ); + $("play").disabled = + !entry.animated || matchMedia("(prefers-reduced-motion: reduce)").matches; + document.title = `${entry.title} — Cerebral visualization lab`; + if (!found && id) + $("selection-status").textContent = + "Unknown example. Showing the bar chart."; + if (push) syncUrl(true); + render(); +} +function table() { + const body = $("data-body"); + body.replaceChildren(); + for (const [i, r] of rows.slice(0, 48).entries()) { + const tr = document.createElement("tr"); + for (const value of [ + i + 1, + r.x.toFixed(4), + r.value.toFixed(4), + r.comparison.toFixed(4), + r.group + 1, + ]) { + const td = document.createElement("td"); + td.textContent = value; + tr.append(td); + } + body.append(tr); + } + $("data-caption").textContent = + `${entry.title} / first ${Math.min(48, rows.length)} of ${rows.length} generated input samples`; +} +function labels(zoom = state.zoom, pan = state.pan) { + const layer = $("chart-labels"); + layer.replaceChildren(); + for (const l of painter.labels.slice(0, 250)) { + const span = document.createElement("span"); + span.className = "chart-label"; + span.textContent = l.text; + const x = (l.x - 480) * zoom + 480 - pan[0] * zoom, + y = (l.y - 280) * zoom + 280 - pan[1] * zoom; + span.style.left = x / 9.6 + "%"; + span.style.top = y / 5.6 + "%"; + span.style.fontSize = (l.size || 11) + "px"; + if (l.background) { + span.style.background = "var(--paper)"; + span.style.padding = "3px"; + } + if (l.fill) + span.style.color = + l.fill === "#ffffff" + ? l.fill + : `color-mix(in srgb, ${l.fill} 60%, var(--ink))`; + else if (l.muted) span.style.color = "var(--muted)"; + span.style.transform = `translate(${l.anchor === "middle" ? "-50%" : l.anchor === "end" ? "-100%" : "0"}, -50%)`; + layer.append(span); + } +} +function render(updateTable = true) { + if (!kernels || !viewport) return; + if (entry.variant.includes("geotiff") && !getTerrain()) { + if (!terrainLoading) { + terrainLoading = true; + loadTerrain() + .then(() => { + terrainLoading = false; + render(); + }) + .catch((error) => { + canvas.dataset.error = error.message; + $("renderer-error").textContent = error.message; + $("renderer-error").hidden = false; + }); + } + return; + } + try { + rows = kernels.generate( + 174 + entry.index * 981, + state.count, + entry.animated ? state.frame * 0.025 : 0, + ); + if (entry.variant.includes("geotiff")) { + const terrain = getTerrain(); + rows = terrain.values.map((value, i) => ({ + x: (i % terrain.width) / terrain.width, + value, + comparison: 0, + group: Math.floor(i / terrain.width) % 6, + weight: 1, + })); + } + painter = new Painter( + 960, + 560, + document.documentElement.dataset.theme === "dark", + ); + draw(painter, rows, state, entry, kernels); + if ( + !painter.marks || + !painter.tri.every(Number.isFinite) || + !painter.segments.every(Number.isFinite) + ) + throw new Error("The layout produced no finite geometry"); + let zoom = state.zoom, + pan = state.pan; + if (/scatterplot-tour|smooth-zooming/.test(entry.variant)) { + const t = state.frame / 100; + zoom *= 1 + 2 * Math.sin(t * Math.PI) ** 2; + pan = [Math.cos(t * Math.PI * 2) * 140, Math.sin(t * Math.PI * 2) * 70]; + } + viewport.render(painter, zoom, pan); + renderedView = { zoom, pan }; + labels(zoom, pan); + if (updateTable) table(); + canvas.dataset.example = entry.id; + canvas.dataset.marks = painter.marks; + canvas.dataset.vertices = + (painter.tri.length + painter.segments.length) / 3 + + painter.images.length * 6; + delete canvas.dataset.error; + $("renderer-error").hidden = true; + $("chart-caption").textContent = + `${entry.title} / deterministic demo / ${painter.marks.toLocaleString()} marks / Three.js + WASM`; + } catch (error) { + canvas.dataset.error = error.message; + $("renderer-error").textContent = + `This example could not render: ${error.message}. The source link and catalog remain available.`; + $("renderer-error").hidden = false; + console.error(error); + } +} +function position(event) { + const rect = canvas.getBoundingClientRect(); + return [ + ((event.clientX - rect.left) / rect.width) * 960, + ((event.clientY - rect.top) / rect.height) * 560, + ]; +} +function worldPosition(pos) { + return [ + (pos[0] - 480) / renderedView.zoom + 480 + renderedView.pan[0], + (pos[1] - 280) / renderedView.zoom + 280 + renderedView.pan[1], + ]; +} +function inspect(index) { + if (!painter?.hits.length) return; + selected = (index + painter.hits.length) % painter.hits.length; + const hit = painter.hits[selected]; + $("chart-tooltip").textContent = + `${hit.label}: ${typeof hit.value === "number" ? Number(hit.value.toPrecision(5)) : hit.value}`; + $("chart-tooltip").hidden = false; + if (entry.interaction === "sequence" && hit.path) + $("selection-status").textContent = hit.path; +} +function action() { + switch (entry.interaction) { + case "drill": + case "sequence": + state.depth = state.depth ? 0 : 1; + state.focus = + selected < 0 ? 0 : (painter?.hits[selected]?.group ?? selected); + state.collapsed = !state.collapsed; + break; + case "sort": + state.sorted = !state.sorted; + break; + case "scale": + state.log = !state.log; + break; + case "projection": + state.projection = (state.projection + 1) % 4; + break; + case "refine": + state.refine = (state.refine + 1) % 6; + break; + case "index": + state.frame = (state.frame + 10) % 101; + $("frame").value = state.frame; + $("frame-value").textContent = state.frame; + break; + } + render(); +} +$("catalog-list").addEventListener("click", (event) => { + const a = event.target.closest("a[data-example]"); + if (a) { + event.preventDefault(); + choose(a.dataset.example); + } +}); +$("catalog-search").addEventListener("input", () => filter()); +$("catalog-category").addEventListener("change", () => filter()); +$("frame").addEventListener("input", (event) => { + state.frame = Number(event.target.value); + $("frame-value").textContent = state.frame; + syncUrl(); + render(); +}); +$("detail").addEventListener("input", (event) => { + state.window = Number(event.target.value); + $("detail-value").textContent = state.window; + syncUrl(); + render(); +}); +$("samples").addEventListener("change", (event) => { + state.count = Number(event.target.value); + syncUrl(); + render(); +}); +$("reset").addEventListener("click", () => { + reset(); + render(); +}); +$("action").addEventListener("click", action); +$("play").addEventListener("click", () => setPlaying(!playing)); +for (const [id, factor] of [ + ["zoom-in", 1.25], + ["zoom-out", 0.8], +]) + $(id).addEventListener("click", () => { + state.zoom = Math.max(0.5, Math.min(6, state.zoom * factor)); + render(false); + }); +$("lab-theme").addEventListener("click", () => { + const dark = document.documentElement.dataset.theme !== "dark"; + document.documentElement.dataset.theme = dark ? "dark" : "light"; + $("lab-theme").setAttribute( + "aria-label", + `Switch to ${dark ? "light" : "dark"} theme`, + ); + try { + localStorage.setItem("cerebral-theme", dark ? "dark" : "light"); + } catch {} + render(false); +}); +function spherePoint(pos) { + const x = (pos[0] - 480) / 240, + y = (280 - pos[1]) / 240; + return new Vector3( + x, + y, + Math.sqrt(Math.max(0, 1 - x * x - y * y)), + ).normalize(); +} +canvas.addEventListener("pointerdown", (event) => { + const pos = position(event); + drag = { start: pos, last: pos, moved: false }; + if (entry.interaction === "rotate") { + const rotation = state.rotation3D || [ + state.rotation + state.frame * 3.6, + -15, + 0, + ]; + drag.quaternion = new Quaternion().setFromEuler( + new Euler( + (rotation[1] * Math.PI) / 180, + (rotation[0] * Math.PI) / 180, + ((rotation[2] || 0) * Math.PI) / 180, + "YXZ", + ), + ); + } + if (entry.interaction === "drag" && painter?.hits.length) { + state.dragNode = kernels.nearest( + painter.hits.map((h) => [h.x, h.y]), + ...worldPosition(pos), + ); + } + canvas.setPointerCapture(event.pointerId); +}); +canvas.addEventListener("pointermove", (event) => { + if (!painter) return; + const pos = position(event); + if (drag) { + drag.moved ||= + Math.hypot(pos[0] - drag.start[0], pos[1] - drag.start[1]) > 4; + if (entry.interaction === "brush") { + const a = drag.start, + b = pos, + box = $("brush-selection"); + box.hidden = false; + box.style.left = Math.min(a[0], b[0]) / 9.6 + "%"; + box.style.top = Math.min(a[1], b[1]) / 5.6 + "%"; + box.style.width = Math.abs(a[0] - b[0]) / 9.6 + "%"; + box.style.height = Math.abs(a[1] - b[1]) / 5.6 + "%"; + const [lo, hi] = [ + worldPosition([Math.min(a[0], b[0]), Math.min(a[1], b[1])]), + worldPosition([Math.max(a[0], b[0]), Math.max(a[1], b[1])]), + ]; + const count = painter.hits.filter( + (h) => h.x >= lo[0] && h.x <= hi[0] && h.y >= lo[1] && h.y <= hi[1], + ).length; + $("selection-status").textContent = + `${count} marks selected in the brush region.`; + } else if (entry.interaction === "rotate") { + const delta = new Quaternion().setFromUnitVectors( + spherePoint(drag.start), + spherePoint(pos), + ); + const euler = new Euler().setFromQuaternion( + delta.multiply(drag.quaternion), + "YXZ", + ); + state.rotation3D = [ + (euler.y * 180) / Math.PI, + (euler.x * 180) / Math.PI, + (euler.z * 180) / Math.PI, + ]; + render(false); + } else if (entry.interaction === "drag") { + const w = worldPosition(pos); + state.dragX = Math.max(0.02, Math.min(0.98, (w[0] - 70) / 820)); + state.dragY = Math.max(0.02, Math.min(0.98, (w[1] - 40) / 470)); + render(false); + } else if (["zoom", "pan"].includes(entry.interaction)) { + state.pan[0] -= (pos[0] - drag.last[0]) / state.zoom; + state.pan[1] -= (pos[1] - drag.last[1]) / state.zoom; + render(false); + } + drag.last = pos; + } else if (painter.hits.length) + inspect( + kernels.nearest( + painter.hits.map((h) => [h.x, h.y]), + ...worldPosition(pos), + ), + ); +}); +canvas.addEventListener("pointerup", () => { + if ( + drag && + !drag.moved && + ["drill", "sequence", "refine"].includes(entry.interaction) + ) { + if (painter?.hits.length) + inspect( + kernels.nearest( + painter.hits.map((h) => [h.x, h.y]), + ...worldPosition(drag.start), + ), + ); + action(); + } + if ( + drag && + !drag.moved && + entry.variant.includes("zoom-to-bounding-box") && + painter?.hits.length + ) { + inspect( + kernels.nearest( + painter.hits.map((h) => [h.x, h.y]), + ...worldPosition(drag.start), + ), + ); + const bounds = painter.hits[selected]?.bounds; + if (bounds) { + const [[x0, y0], [x1, y1]] = bounds; + state.zoom = Math.min( + 6, + 0.85 * Math.min(960 / Math.max(1, x1 - x0), 560 / Math.max(1, y1 - y0)), + ); + state.pan = [(x0 + x1) / 2 - 480, (y0 + y1) / 2 - 280]; + render(false); + } + } + drag = null; +}); +canvas.addEventListener("pointercancel", () => { + drag = null; +}); +canvas.addEventListener("pointerleave", () => { + if (!drag) $("chart-tooltip").hidden = true; +}); +canvas.addEventListener( + "wheel", + (event) => { + if (!["zoom", "pan"].includes(entry.interaction) || event.ctrlKey) return; + event.preventDefault(); + state.zoom = Math.max( + 0.5, + Math.min(6, state.zoom * (event.deltaY > 0 ? 0.9 : 1.1)), + ); + render(false); + }, + { passive: false }, +); +canvas.addEventListener("keydown", (event) => { + if (["ArrowLeft", "ArrowRight"].includes(event.key)) { + event.preventDefault(); + inspect(selected + (event.key === "ArrowRight" ? 1 : -1)); + } + if (event.key === "Enter") { + event.preventDefault(); + action(); + } + if (event.key === "+" || event.key === "=") { + state.zoom = Math.min(6, state.zoom * 1.2); + render(false); + } + if (event.key === "-") { + state.zoom = Math.max(0.5, state.zoom / 1.2); + render(false); + } + if (event.key === "Escape") { + reset(); + render(); + } +}); +$("download-data").addEventListener("click", () => { + const csv = [ + "sample,x,value,comparison,group,weight", + ...rows.map((r, i) => + [i + 1, r.x, r.value, r.comparison, r.group + 1, r.weight].join(","), + ), + ].join("\n"); + const url = URL.createObjectURL(new Blob([csv], { type: "text/csv" })); + const a = document.createElement("a"); + a.href = url; + a.download = `${entry.id}-demo.csv`; + a.click(); + setTimeout(() => URL.revokeObjectURL(url), 1000); +}); +function readUrl() { + const params = new URLSearchParams(location.search); + $("catalog-search").value = params.get("q") || ""; + const category = params.get("category") || "all"; + $("catalog-category").value = [...$("catalog-category").options].some( + (o) => o.value === category, + ) + ? category + : "all"; + filter(false); + choose(params.get("chart") || entries[71].id, false); + const number = (key, defaultValue, min, max) => { + const value = Number(params.get(key) ?? defaultValue); + return Number.isFinite(value) + ? Math.min(max, Math.max(min, Math.round(value))) + : defaultValue; + }; + state.frame = number("frame", 50, 0, 100); + state.window = number("detail", 16, 4, 32); + state.count = number("samples", 192, 96, 384); + if (![96, 192, 384].includes(state.count)) state.count = 192; + $("frame").value = state.frame; + $("frame-value").textContent = state.frame; + $("detail").value = state.window; + $("detail-value").textContent = state.window; + $("samples").value = state.count; + render(); +} +window.addEventListener("popstate", readUrl); +document.addEventListener("visibilitychange", () => { + if (document.hidden) { + if (raf) cancelAnimationFrame(raf); + raf = 0; + } else if (playing && !raf) raf = requestAnimationFrame(tick); +}); +new ResizeObserver(() => { + if (viewport) render(false); +}).observe($("canvas-stage")); +window.addEventListener("pagehide", () => { + setPlaying(false); + viewport?.dispose(); +}); +readUrl(); +try { + kernels = await loadKernels(); + $("wasm-status").textContent = "WASM / ready"; + viewport = new Viewport(canvas); + $("webgl-status").textContent = "Three.js / WebGL ready"; + render(); +} catch (error) { + if (kernels) { + rows = kernels.generate(174 + entry.index * 981, state.count, 0); + table(); + } + $("wasm-status").textContent = kernels + ? "WASM / ready" + : "WASM / unavailable"; + $("webgl-status").textContent = viewport + ? "Three.js / ready" + : "Three.js / unavailable"; + $("renderer-error").textContent = + `Interactive rendering is unavailable: ${error.message}. Browse the source catalog or return to the benchmark evidence.`; + $("renderer-error").hidden = false; + canvas.dataset.error = error.message; +} diff --git a/cerebral-src/visualizations/layouts.js b/cerebral-src/visualizations/layouts.js new file mode 100644 index 0000000..b73dbae --- /dev/null +++ b/cerebral-src/visualizations/layouts.js @@ -0,0 +1,1711 @@ +import * as d3 from "d3"; +import { sankey, sankeyLinkHorizontal } from "d3-sankey"; +import { hexbin } from "d3-hexbin"; +import { palette } from "./painter.js"; +import { drawMap } from "./maps.js"; +import { drawSpecial } from "./special.js"; +import { getTerrain } from "./raster.js"; + +import { adapterNames } from "./registry.mjs"; +export { adapterNames }; +const color = (i) => + palette[((i % palette.length) + palette.length) % palette.length]; +const point = (x, y) => [x, y]; +const chart = { left: 64, top: 40, right: 928, bottom: 510 }; +function scales(p, domain = [0, 110]) { + return { + x: d3.scaleLinear([0, 1], [chart.left, p.width - 30]), + y: d3.scaleLinear(domain, [chart.bottom, chart.top]), + }; +} +function series(rows, g = 0, phase = 0) { + return rows.map((r, i) => ({ + ...r, + value: Math.max( + 1, + r.value * (0.6 + g * 0.13) + Math.sin(i * 0.15 + g + phase) * g * 3, + ), + group: g, + })); +} +function hierarchy(rows, state, animated = false) { + const data = { + name: "All demand", + children: Array.from({ length: 6 }, (_, g) => ({ + name: ["Arbor", "Birch", "Cedar", "Delta", "Elm", "Fir"][g], + group: g, + children: rows.slice(g * 6, g * 6 + 6).map((r, i) => ({ + name: `${String.fromCharCode(65 + g)}${i + 1}`, + value: + r.value * + (animated ? 1 + 0.25 * Math.sin(state.frame * 0.08 + g + i) : 1), + group: g, + length: r.weight, + })), + })), + }; + const focus = state.depth > 0 ? data.children[state.focus % 6] : data; + return d3 + .hierarchy(focus) + .sum((n) => n.value || 0) + .sort((a, b) => b.value - a.value); +} +function treeLayout(p, rows, state, entry) { + let root = hierarchy(rows, state, entry.animated); + const v = entry.variant; + const radial = /radial|tree-of-life/.test(v); + const indented = v.includes("indented"); + if (state.collapsed && root.children) + root.children = root.children.slice(0, 3); + const layout = + v.includes("cluster") || v.includes("tree-of-life") + ? d3.cluster() + : d3.tree(); + layout.size(radial ? [2 * Math.PI, 215] : [440, 760])(root); + const pos = (n) => + radial + ? [ + 480 + Math.cos(n.x - Math.PI / 2) * n.y, + 280 + Math.sin(n.x - Math.PI / 2) * n.y, + ] + : [90 + n.y, 55 + n.x]; + if (v.includes("tree-of-life")) + for (const n of root.descendants()) + n.y = Math.min(215, n.depth * 45 + (n.data.length || 0) * 4); + if (indented) { + root.eachBefore((n) => { + n.x = 30 + root.descendants().indexOf(n) * 13; + n.y = n.depth * 36; + }); + } + for (const link of root.links()) { + const a = pos(link.source), + b = pos(link.target); + if (radial) p.line([a, b], color(link.target.data.group || 0)); + else p.path(d3.linkHorizontal()({ source: a, target: b }), null, p.rule); + } + for (const n of root.descendants()) { + const [x, y] = pos(n); + p.circle(x, y, n.children ? 4 : 2.8, color(n.data.group || 0)); + p.text(x + (radial ? 5 : 8), y, n.data.name, { size: 11 }); + p.hit(x, y, n.data.name, n.value, { + group: n.data.group ?? 0, + path: n + .ancestors() + .reverse() + .map((a) => a.data.name) + .join(" → "), + }); + } +} +function treemap(p, rows, state, entry) { + const root = hierarchy(rows, state, entry.animated); + const cascade = entry.variant.includes("cascaded"), + nested = entry.variant.includes("nested"); + d3 + .treemap() + .size([870, 470]) + .paddingOuter(nested ? 8 : 3) + .paddingInner(nested ? 5 : 2) + .paddingTop(nested ? 20 : 2)(root); + const nodes = + nested || cascade + ? root.descendants().filter((n) => n.depth > 0) + : root.leaves(); + for (const n of nodes) { + const offset = cascade ? n.depth * 7 : 0; + const x = 45 + n.x0 + offset, + y = 40 + n.y0 + offset, + w = n.x1 - n.x0 - offset, + h = n.y1 - n.y0 - offset; + if (w <= 0 || h <= 0) continue; + p.rect(x, y, w, h, color(n.data.group || 0)); + if (w > 24 && h > 18) + p.text(x + 6, y + 14, n.data.name, { fill: "#ffffff", size: 11 }); + p.hit(x + w / 2, y + h / 2, n.data.name, n.value, { + group: n.data.group ?? 0, + }); + } +} +function packing(p, rows, state, entry) { + const root = hierarchy(rows, state, entry.animated); + d3.pack().size([880, 470]).padding(5)(root); + for (const n of root.descendants()) { + p.circle( + 40 + n.x, + 40 + n.y, + n.r, + n.children ? p.paper : color(n.data.group || 0), + p.rule, + ); + if (!n.children) { + p.text(40 + n.x, 40 + n.y, n.data.name, { + anchor: "middle", + fill: "#ffffff", + size: 11, + }); + p.hit(40 + n.x, 40 + n.y, n.data.name, n.value, { + group: n.data.group ?? 0, + }); + } + } +} +function partition(p, rows, state, entry) { + const root = hierarchy(rows, state, entry.animated); + const radial = entry.adapter === "sunburst"; + d3.partition().size(radial ? [2 * Math.PI, 220] : [860, 470])(root); + if (radial) { + for (const n of root.descendants().slice(1)) { + const arc = d3 + .arc() + .innerRadius(n.y0) + .outerRadius(n.y1 - 1) + .startAngle(n.x0) + .endAngle(n.x1 - 0.005); + const d = arc(); + p.path(translatePath(d, 480, 280), color(n.data.group || 0), p.paper); + const [x, y] = arc.centroid(); + p.hit(480 + x, 280 + y, n.data.name, n.value, { + group: n.data.group ?? 0, + path: n + .ancestors() + .reverse() + .map((a) => a.data.name) + .join(" → "), + }); + if (n.x1 - n.x0 > 0.25) + p.text(480 + x, 280 + y, n.data.name, { + anchor: "middle", + fill: "#ffffff", + size: 11, + }); + } + } else + for (const n of root.descendants()) { + p.rect( + 50 + n.x0, + 40 + n.y0, + Math.max(0, n.x1 - n.x0 - 1), + n.y1 - n.y0 - 1, + color(n.data.group || 0), + ); + if (n.x1 - n.x0 > 25) + p.text(55 + n.x0, 55 + n.y0, n.data.name, { + fill: "#ffffff", + size: 11, + }); + p.hit( + 50 + (n.x0 + n.x1) / 2, + 40 + (n.y0 + n.y1) / 2, + n.data.name, + n.value, + ); + } +} +// D3 paths are parsed into geometry, never mounted as SVG in the document. +function translatePath(d, x, y) { + if (!d) return null; + return d + .replace( + /([ML])(-?[\d.e+-]+),(-?[\d.e+-]+)/g, + (_, c, a, b) => `${c}${Number(a) + x},${Number(b) + y}`, + ) + .replace(/([Aa])([^AaMLCZ]*)/g, (all, c, rest) => { + const nums = rest.split(","); + if (nums.length === 7) { + nums[5] = String(Number(nums[5]) + x); + nums[6] = String(Number(nums[6]) + y); + return c + nums.join(","); + } + return all; + }); +} +// Arc/radial transforms use a temporary coordinate offset on painter primitives. +function withOffset(p, x, y, fn) { + const tri = p.tri.length, + seg = p.segments.length, + labels = p.labels.length, + hits = p.hits.length; + fn(); + for (let i = tri; i < p.tri.length; i += 3) { + p.tri[i] += x; + p.tri[i + 1] += y; + } + for (let i = seg; i < p.segments.length; i += 3) { + p.segments[i] += x; + p.segments[i + 1] += y; + } + for (let i = labels; i < p.labels.length; i++) { + p.labels[i].x += x; + p.labels[i].y += y; + } + for (let i = hits; i < p.hits.length; i++) { + p.hits[i].x += x; + p.hits[i].y += y; + } +} +function bars(p, rows, state, entry) { + const v = entry.variant; + const horizontal = /horizontal|race|hierarchical/.test(v); + const diverge = /diverging/.test(v); + const grouped = /grouped|stacked-to-grouped/.test(v); + const stacked = + /stacked|revenue/.test(v) && (!grouped || v.includes("stacked-to-grouped")); + const normalized = /normalized/.test(v); + let data = rows.slice(0, horizontal ? 12 : 20).map((r, i) => ({ + ...r, + value: + r.value * + (entry.animated ? 1 + 0.25 * Math.sin(state.frame * 0.06 + i) : 1), + name: `Group ${i + 1}`, + })); + if (state.sorted || v.includes("race")) + data.sort((a, b) => b.value - a.value); + if (v.includes("hierarchical")) { + data = + state.depth > 0 + ? rows + .slice((state.focus % 6) * 6, (state.focus % 6) * 6 + 6) + .map((r, i) => ({ ...r, name: `Item ${i + 1}` })) + : d3.range(6).map((g) => ({ + ...rows[g], + value: d3.sum(rows.slice(g * 6, g * 6 + 6), (r) => r.value), + name: `Group ${g + 1}`, + group: g, + })); + } + const max = normalized + ? 1 + : d3.max(data, (r) => + stacked + ? r.value + r.comparison + r.weight + : grouped + ? Math.max(r.value, r.comparison, r.weight) + : r.value, + ) * 1.1; + const scale = d3.scaleLinear( + [diverge ? -max : max * 0, max], + horizontal ? [100, 900] : [510, 40], + ); + const band = d3 + .scaleBand( + data.map((r) => r.name), + horizontal ? [45, 500] : [65, 925], + ) + .padding(0.18); + if (horizontal) { + p.line( + [ + [100, 510], + [900, 510], + ], + p.rule, + ); + for (let i = 0; i <= 4; i++) { + const value = (diverge ? -max : 0) + ((diverge ? max * 2 : max) * i) / 4, + x = scale(value); + p.line( + [ + [x, 40], + [x, 510], + ], + p.rule, + ); + p.text(x, 532, Number(value.toPrecision(3)), { + anchor: "middle", + muted: true, + }); + } + p.text(100, 20, normalized ? "Share" : "Demo units", { muted: true }); + } else + p.axis(64, 510, diverge ? [-max, max] : [0, max], [ + "Groups", + normalized ? "Share" : "Demo units", + ]); + for (const [i, r] of data.entries()) { + const n = stacked || grouped ? 3 : 1; + let base = 0; + const total = r.value + r.comparison + r.weight; + for (let g = 0; g < n; g++) { + let value = [r.value, r.comparison, r.weight][g]; + if (normalized) value /= total; + if (diverge) value *= i % 3 === 0 ? -1 : 1; + const transition = v.includes("stacked-to-grouped") + ? d3.easeCubic(state.frame / 100) + : null; + const groupAmount = transition ?? (grouped && !stacked ? 1 : 0); + const baseValue = stacked ? base * (1 - groupAmount) : 0; + const a = scale(baseValue), + b = scale(baseValue + value); + const thickness = band.bandwidth() * (1 - (groupAmount * 2) / 3); + const t = band(r.name) + ((g * band.bandwidth()) / 3) * groupAmount; + if (horizontal) { + p.rect( + Math.min(a, b), + t, + Math.abs(b - a), + thickness, + color(n > 1 ? g : r.group), + ); + p.hit(Math.max(a, b), t + thickness / 2, r.name, value); + if (g === 0) + p.text(92, t + thickness / 2, r.name, { anchor: "end", size: 11 }); + } else { + p.rect( + t, + Math.min(a, b), + thickness, + Math.abs(b - a), + color(n > 1 ? g : r.group), + ); + p.hit(t + thickness / 2, Math.min(a, b), r.name, value); + if (g === 0 && i % 2 === 0) + p.text(t, 530, r.name.replace("Group ", ""), { size: 10 }); + } + if (stacked) base += value; + } + } +} +function lineChart(p, rows, state, entry, k) { + const v = entry.variant, + tourism = v.includes("tourists"), + index = v.includes("index-chart"), + change = v.includes("change-line"); + const count = /multi|ice|inline|labelling|inequality|index/.test(v) ? 6 : 1; + let dataSets = Array.from({ length: count }, (_, g) => + rows.map((r, i) => ({ + ...r, + value: + g === 0 + ? r.value + : Math.max( + 1, + r.value * (0.6 + g * 0.1) + Math.sin(i * 0.15 + g) * g * 3, + ), + })), + ); + if (tourism) + dataSets = [ + rows.map((r) => ({ + ...r, + value: 0.5 * Math.exp(r.x * 5) * (1 + (r.value - 50) / 300), + })), + ]; + if (v.includes("sea-ice")) + dataSets = dataSets.map((data, g) => + data.map((r) => ({ + ...r, + value: 45 + 30 * Math.cos(r.x * Math.PI * 2) + g * 4 + r.weight * 0.15, + })), + ); + if (index) + dataSets = dataSets.map((data) => { + const reference = + data[Math.floor((state.frame / 100) * (data.length - 1))].value; + return data.map((r) => ({ ...r, value: (r.value / reference) * 100 })); + }); + if (change) + dataSets = dataSets.map((data) => + data.map((r) => ({ ...r, value: (r.value / data[0].value - 1) * 100 })), + ); + if (v.includes("moving-average")) { + const mean = k.average( + rows.map((r) => r.value), + state.window, + ); + dataSets = [rows.map((r, i) => ({ ...r, value: mean[i] }))]; + } + const band = v.includes("bollinger") + ? k.bands( + rows.map((r) => r.value), + state.window, + ) + : null; + const all = dataSets.flat().map((r) => r.value); + if (band) + all.push(...band.flatMap((r) => [r.mean - 2 * r.std, r.mean + 2 * r.std])); + const min = tourism && state.log ? d3.min(all) : Math.min(0, d3.min(all)), + max = d3.max(all) * 1.08; + const x = d3.scaleLinear([0, 1], [64, 930]), + y = (tourism && state.log ? d3.scaleLog() : d3.scaleLinear()) + .domain([min, max]) + .range([510, 40]); + p.line( + [ + [64, 40], + [64, 510], + [930, 510], + ], + p.rule, + ); + const ticks = + tourism && state.log + ? [0.5, 1, 2, 5, 10, 20, 50].filter((t) => t >= min && t <= max) + : y.ticks(5); + for (const tick of ticks) { + p.line( + [ + [64, y(tick)], + [930, y(tick)], + ], + p.rule, + ); + p.text(54, y(tick), Number(tick.toPrecision(3)), { + anchor: "end", + muted: true, + }); + } + p.text( + 64, + 18, + index + ? "Index / reference = 100" + : change + ? "Relative change (%)" + : tourism && state.log + ? "Value / logarithmic scale" + : "Demo units", + { muted: true }, + ); + p.text(930, 538, "Sample position", { anchor: "end", muted: true }); + if (band) { + p.path( + d3 + .area() + .x((r) => x(r.x)) + .y0((r, i) => y(band[i].mean - 2 * band[i].std)) + .y1((r, i) => y(band[i].mean + 2 * band[i].std))(rows), + "#A8BFD2", + null, + ); + p.line( + rows.map((r, i) => [x(r.x), y(band[i].mean)]), + color(1), + ); + } + dataSets.forEach((data, g) => { + if (/variable-color|gradient-encoding|threshold-encoding/.test(v)) { + for (let i = 1; i < data.length; i++) { + const stroke = v.includes("threshold") + ? data[i].value > 60 + ? color(1) + : color(0) + : d3.interpolateTurbo(i / data.length); + p.line( + [ + [x(data[i - 1].x), y(data[i - 1].value)], + [x(data[i].x), y(data[i].value)], + ], + stroke, + ); + } + } else + p.path( + d3 + .line() + .defined((r, i) => !v.includes("missing") || i % 18 < 13) + .x((r) => x(r.x)) + .y((r) => y(r.value)) + .curve(d3.curveMonotoneX)(data), + null, + color(g), + ); + if (v.includes("inline")) { + const r = data[Math.floor(data.length * (0.25 + g * 0.1))]; + p.text(x(r.x), y(r.value), `Series ${g + 1}`, { + anchor: "middle", + fill: color(g), + size: 11, + background: true, + }); + } else if (/labelling|ice/.test(v)) { + const r = data.at(-1); + p.text(x(r.x) - 4, y(r.value) - 8, `Series ${g + 1}`, { + anchor: "end", + fill: color(g), + size: 11, + }); + } + if (v.includes("styled-axes")) { + p.line( + [ + [64, 40], + [64, 510], + [930, 510], + ], + color(1), + ); + p.text(70, 535, "Styled ticks / aligned grid / explicit units", { + size: 11, + }); + } + data + .filter((r, i) => i % 4 === 0) + .forEach((r, i) => + p.hit(x(r.x), y(r.value), `Series ${g + 1} / ${i * 4 + 1}`, r.value), + ); + }); +} +function areaChart(p, rows, state, entry) { + const v = entry.variant; + const { x, y } = scales(p, [ + 0, + /stacked|stream|population/.test(v) ? 400 : 110, + ]); + const stack = /stacked|stream|population/.test(v); + const normalized = v.includes("normalized"); + p.axis(64, 510, normalized ? [0, 1] : [0, stack ? 400 : 110], [ + "Sample position", + normalized ? "Share" : "Demo units", + ]); + if (stack) { + const matrix = rows.map((r, i) => + Object.fromEntries( + Array.from({ length: 6 }, (_, g) => [ + g, + Math.max( + 1, + r.value * 0.6 + 25 * Math.sin(i * 0.12 + g + state.frame * 0.03), + ), + ]), + ), + ); + const layers = d3 + .stack() + .keys(d3.range(6)) + .offset( + normalized + ? d3.stackOffsetExpand + : v.includes("stream") + ? d3.stackOffsetWiggle + : d3.stackOffsetNone, + )(matrix); + const sy = d3.scaleLinear(d3.extent(layers.flat(2)), [510, 40]); + for (let g = 0; g < layers.length; g++) { + const area = d3 + .area() + .x((r, i) => x(rows[i].x)) + .y0((r) => sy(r[0])) + .y1((r) => sy(r[1])) + .curve(d3.curveBasis); + p.path(area(layers[g]), color(g), null); + } + } else if (v.includes("difference")) { + for (let i = 1; i < rows.length; i++) { + const a = rows[i - 1], + b = rows[i]; + p.polygon( + [ + [x(a.x), y(a.value)], + [x(b.x), y(b.value)], + [x(b.x), y(b.comparison)], + [x(a.x), y(a.comparison)], + ], + b.value > b.comparison ? color(0) : color(1), + ); + } + } else { + const area = d3 + .area() + .defined((r, i) => !v.includes("missing") || i % 20 < 14) + .x((r) => x(r.x)) + .y0((r) => (v.includes("band") ? y(r.comparison) : 510)) + .y1((r) => y(r.value)) + .curve(d3.curveMonotoneX); + p.path(area(rows), color(0), null); + } + rows + .filter((r, i) => i % 6 === 0) + .forEach((r) => p.hit(x(r.x), y(r.value), r.name, r.value)); +} +function scatter(p, rows, state, entry) { + const v = entry.variant; + const { x, y } = scales(p); + p.axis(64, 510, [0, 110], ["Demo variable X", "Demo variable Y"]); + const points = rows.map((r, i) => [ + x(v.includes("hertzsprung") ? Math.log10(r.weight) / 1.4 : r.x), + y(r.comparison * 0.8 + Math.sin(r.angle + state.frame * 0.02) * 12), + r, + ]); + if (v.includes("connected")) + p.line( + points.map((r) => r.slice(0, 2)), + p.muted, + ); + for (const [i, [a, b, r]] of points.entries()) { + const rsize = /wealth|bubble/.test(v) ? r.weight : 3.5; + if (v.includes("shapes") && i % 3 === 0) + p.polygon( + [ + [a, b - rsize], + [a + rsize, b + rsize], + [a - rsize, b + rsize], + ], + color(r.group), + ); + else if (v.includes("shapes") && i % 3 === 1) + p.rect(a - rsize, b - rsize, rsize * 2, rsize * 2, color(r.group)); + else p.circle(a, b, rsize, color(r.group)); + p.hit(a, b, r.name, r.comparison); + } +} +function matrix(p, rows, state, entry) { + const n = 4, + size = 113, + gap = 8; + for (let a = 0; a < n; a++) + for (let b = 0; b < n; b++) { + const left = 220 + a * (size + gap), + top = 35 + b * (size + gap); + p.line( + [ + [left, top], + [left + size, top], + [left + size, top + size], + [left, top + size], + [left, top], + ], + p.rule, + ); + if (a === b) { + p.text( + left + size / 2, + top + size / 2, + ["Value", "Comparison", "Weight", "Phase"][a], + { anchor: "middle", size: 11 }, + ); + continue; + } + for (const r of rows.slice(0, 80)) { + const vars = [ + r.value / 110, + r.comparison / 100, + r.weight / 22, + r.angle / (Math.PI * 2), + ]; + const x = left + vars[a] * size, + y = top + (1 - vars[b]) * size; + p.circle(x, y, 2, color(r.group)); + p.hit(x, y, r.name, vars[a]); + } + } +} +function network(p, rows, state, entry, k) { + const n = entry.variant.includes("tree") + ? 31 + : entry.variant.includes("temporal") + ? 12 + Math.floor(state.frame / 4) + : 40; + const nodes = rows.slice(0, n).map((r, i) => ({ + x: 0.5 + 0.32 * Math.cos((i / n) * 6.283), + y: 0.5 + 0.32 * Math.sin((i / n) * 6.283), + group: r.group, + })); + let links = d3.range(1, n).map((i) => ({ + source: entry.variant.includes("tree") + ? Math.floor((i - 1) / 2) + : Math.max(0, i - 1 - (i % 4)), + target: i, + })); + if (entry.variant.includes("disjoint")) + links = links.filter((e) => e.target % 10 !== 0); + let positions = k.force(nodes, links, 25 + Math.floor(state.frame / 5)); + if (entry.variant.includes("collision")) { + positions = positions.map((n, i) => ({ ...n, r: (5 + (i % 3)) / 820 })); + d3.forceSimulation(positions) + .force( + "collide", + d3.forceCollide((n) => n.r * 2), + ) + .stop() + .tick(45); + } + if ( + state.dragNode !== null && + state.dragNode !== undefined && + positions[state.dragNode] + ) { + positions[state.dragNode].x = state.dragX; + positions[state.dragNode].y = state.dragY; + } + for (const e of links) { + const a = positions[e.source], + b = positions[e.target]; + p.line( + [ + [70 + a.x * 820, 40 + a.y * 470], + [70 + b.x * 820, 40 + b.y * 470], + ], + p.rule, + ); + if (entry.variant.includes("patent")) { + const x = 70 + b.x * 820, + y = 40 + b.y * 470; + p.polygon( + [ + [x, y], + [x - 7, y - 3], + [x - 5, y + 6], + ], + p.muted, + ); + } + } + positions.forEach((r, i) => { + p.circle(70 + r.x * 820, 40 + r.y * 470, 5 + (i % 3), color(r.group)); + p.hit(70 + r.x * 820, 40 + r.y * 470, `Node ${i + 1}`, i); + }); +} +function sankeyChart(p, rows, state, entry) { + const nodes = Array.from({ length: 12 }, (_, i) => ({ + id: i, + name: `Stage ${Math.floor(i / 4) + 1}.${(i % 4) + 1}`, + })); + const links = []; + for (let s = 0; s < 8; s++) { + for (let g = 0; g < 2; g++) + links.push({ + source: s, + target: Math.floor(s / 4) * 4 + 4 + ((s + g) % 4), + value: rows[s * 2 + g].weight, + }); + } + const graph = sankey() + .nodeId((n) => n.id) + .nodeWidth(12) + .nodePadding(16) + .extent([ + [90, 40], + [870, 510], + ])({ nodes, links }); + for (const e of graph.links) { + const source = [e.source.x1, e.y0], + target = [e.target.x0, e.y1]; + const path = d3.path(); + path.moveTo(source[0], source[1] - e.width / 2); + path.bezierCurveTo( + (source[0] + target[0]) / 2, + source[1] - e.width / 2, + (source[0] + target[0]) / 2, + target[1] - e.width / 2, + target[0], + target[1] - e.width / 2, + ); + path.lineTo(target[0], target[1] + e.width / 2); + path.bezierCurveTo( + (source[0] + target[0]) / 2, + target[1] + e.width / 2, + (source[0] + target[0]) / 2, + source[1] + e.width / 2, + source[0], + source[1] + e.width / 2, + ); + path.closePath(); + p.path(path.toString(), color(e.source.index % 4), null); + } + for (const n of graph.nodes) { + p.rect(n.x0, n.y0, n.x1 - n.x0, n.y1 - n.y0, p.ink); + p.text(n.x0 + 16, n.y0 + 10, n.name, { size: 11 }); + p.hit(n.x0, (n.y0 + n.y1) / 2, n.name, n.value); + } +} +function chordChart(p, rows, state, entry) { + const n = 6, + matrix = Array.from({ length: n }, (_, i) => + Array.from({ length: n }, (_, j) => + Math.round(rows[(i * n + j) % rows.length].weight), + ), + ); + const directed = /directed|dependency/.test(entry.variant); + const layout = (directed ? d3.chordDirected() : d3.chord()).padAngle(0.035)( + matrix, + ); + withOffset(p, 480, 280, () => { + for (const arc of layout.groups) { + p.path( + d3.arc().innerRadius(206).outerRadius(220)(arc), + color(arc.index), + null, + ); + const a = (arc.startAngle + arc.endAngle) / 2; + p.text(Math.sin(a) * 237, -Math.cos(a) * 237, `G${arc.index + 1}`, { + anchor: "middle", + size: 12, + }); + } + for (const ribbon of layout) { + p.path( + (directed ? d3.ribbonArrow() : d3.ribbon()).radius(202)(ribbon), + color(ribbon.source.index), + null, + ); + } + }); +} +function bundleChart(p, rows, state, entry) { + const root = hierarchy(rows, state, entry.animated); + d3.cluster().size([2 * Math.PI, 210])(root); + const leaves = root.leaves(); + withOffset(p, 480, 280, () => { + const line = d3 + .lineRadial() + .radius((d) => d.y) + .angle((d) => d.x) + .curve(d3.curveBundle.beta(entry.variant.endsWith("-2") ? 0.75 : 0.93)); + leaves.forEach((n, i) => { + const other = leaves[(i * 7 + 11) % leaves.length]; + p.path(line(n.path(other)), null, color(n.data.group)); + const x = Math.sin(n.x) * n.y, + y = -Math.cos(n.x) * n.y; + p.text(x * 1.09, y * 1.09, n.data.name, { anchor: "middle", size: 10 }); + p.hit(x, y, n.data.name, n.value, { + group: n.data.group ?? 0, + path: n + .ancestors() + .reverse() + .map((a) => a.data.name) + .join(" → "), + }); + }); + }); +} +function pieChart(p, rows, state, entry) { + const donut = entry.variant.includes("donut"), + values = rows.slice(0, 8).map((r, i) => ({ + ...r, + value: + r.value * + (entry.animated ? 1 + 0.3 * Math.sin(state.frame * 0.06 + i) : 1), + })); + const arcs = d3.pie().value((r) => r.value)(values); + withOffset(p, 480, 280, () => { + for (const a of arcs) { + const arc = d3 + .arc() + .innerRadius(donut ? 120 : 0) + .outerRadius(220) + .padAngle(0.012); + p.path(arc(a), color(a.index), null); + const [x, y] = arc.centroid(a); + p.text(x, y, `${a.index + 1}`, { anchor: "middle", fill: "#ffffff" }); + p.hit(x, y, a.data.name, a.value); + } + }); +} +function heatmap(p, rows, state, entry) { + const calendar = entry.adapter === "calendar"; + const usage = entry.variant.includes("electric"); + const cols = calendar ? 52 : usage ? 48 : 40, + rs = calendar ? 7 : usage ? 12 : 20; + const dx = 840 / cols, + dy = Math.min(58, 450 / rs); + for (let r = 0; r < rs; r++) + for (let c = 0; c < cols; c++) { + let value = rows[(r * cols + c) % rows.length].value / 110; + if (entry.variant.includes("vaccines")) value *= c < 22 ? 1 : 0.18; + p.rect( + 70 + c * dx, + 50 + r * dy, + Math.max(1, dx - 1), + dy - 1, + d3.interpolateViridis(value), + ); + p.hit( + 70 + (c + 0.5) * dx, + 50 + (r + 0.5) * dy, + `${calendar ? "Week" : "Column"} ${c + 1} / ${r + 1}`, + value, + ); + } + p.text( + 70, + 30, + calendar + ? "52 weeks × 7 days" + : usage + ? "Days × half-hour intervals" + : "Time × category", + { muted: true }, + ); + if (entry.variant.includes("vaccines")) { + p.line( + [ + [70 + 22 * dx, 45], + [70 + 22 * dx, 510], + ], + p.ink, + ); + p.text(70 + 22 * dx + 6, 530, "Intervention boundary (demo)", { size: 11 }); + } +} +function statistics(p, rows, state, entry, k) { + const v = entry.variant, + { x, y } = scales(p); + const values = rows.map((r) => r.value); + if (entry.adapter === "box") { + for (let g = 0; g < 6; g++) { + const q = k.quantiles( + rows.filter((r) => r.group === g).map((r) => r.value), + ), + xx = 140 + g * 135; + const sy = d3.scaleLinear([0, 110], [500, 40]); + p.line( + [ + [xx, sy(q[0])], + [xx, sy(q[4])], + ], + p.ink, + ); + p.rect(xx - 30, sy(q[3]), 60, sy(q[1]) - sy(q[3]), color(g)); + p.line( + [ + [xx - 30, sy(q[2])], + [xx + 30, sy(q[2])], + ], + p.paper, + ); + p.line( + [ + [xx - 16, sy(q[0])], + [xx + 16, sy(q[0])], + ], + p.ink, + ); + p.line( + [ + [xx - 16, sy(q[4])], + [xx + 16, sy(q[4])], + ], + p.ink, + ); + p.text(xx, 530, `G${g + 1}`, { anchor: "middle" }); + p.hit(xx, sy(q[2]), `Group ${g + 1} median`, q[2]); + } + p.axis(64, 510); + } else if (entry.adapter === "histogram") { + const bins = k.histogram(values, state.window, 0, 110); + const max = d3.max(bins) || 1; + bins.forEach((n, i) => { + const h = (n / max) * 440; + p.rect( + 65 + (i * 860) / bins.length, + 510 - h, + 860 / bins.length - 2, + h, + color(0), + ); + p.hit(65 + ((i + 0.5) * 860) / bins.length, 510 - h, `Bin ${i + 1}`, n); + }); + p.axis(64, 510, [0, max], ["Value bin", "Count"]); + } else if (entry.adapter === "kde") { + const density = k.kde(values, state.window / 2, 0, 110), + sx = d3.scaleLinear([0, 110], [65, 930]), + sy = d3.scaleLinear([0, d3.max(density, (r) => r[1])], [510, 40]); + p.path( + d3 + .area() + .x((r) => sx(r[0])) + .y0(510) + .y1((r) => sy(r[1])) + .curve(d3.curveBasis)(density), + color(0), + null, + ); + p.axis( + 64, + 510, + [0, d3.max(density, (r) => r[1])], + ["Value", "Estimated density"], + ); + } else { + const a = values.slice().sort(d3.ascending), + b = v.includes("normal") + ? a.map((r, i) => inverseNormal((i + 0.5) / a.length)) + : rows.map((r) => r.comparison).sort(d3.ascending); + const sx = d3.scaleLinear(d3.extent(a), [65, 930]), + sy = d3.scaleLinear(d3.extent(b), [510, 40]); + a.forEach((r, i) => p.circle(sx(r), sy(b[i]), 3, color(0))); + p.line( + [ + [65, 510], + [930, 40], + ], + p.rule, + ); + p.axis(64, 510, d3.extent(b), [ + "Sample quantile", + v.includes("normal") ? "Normal quantile" : "Comparison quantile", + ]); + } +} +function inverseNormal(p) { + const a = [ + -39.6968302866538, 220.946098424521, -275.928510446969, 138.357751867269, + -30.6647980661472, 2.50662827745924, + ], + b = [ + -54.4760987982241, 161.585836858041, -155.698979859887, 66.8013118877197, + -13.2806815528857, + ], + c = [ + -0.00778489400243029, -0.322396458041136, -2.40075827716184, + -2.54973253934373, 4.37466414146497, 2.93816398269878, + ], + d = [ + 0.00778469570904146, 0.32246712907004, 2.445134137143, 3.75440866190742, + ]; + const poly = (cs, x) => cs.reduce((v, c) => v * x + c, 0); + if (p < 0.02425) { + const q = Math.sqrt(-2 * Math.log(p)); + return poly(c, q) / (poly(d, q) * q + 1); + } + if (p > 0.97575) return -inverseNormal(1 - p); + const q = p - 0.5, + r = q * q; + return (poly(a, r) * q) / (poly(b, r) * r + 1); +} +function contourChart(p, rows, state, entry, k) { + const density = entry.adapter === "density"; + let contours; + if (density) + contours = d3 + .contourDensity() + .x((r) => 70 + r.x * 820) + .y((r) => 60 + r.comparison * 4) + .size([960, 560]) + .bandwidth(state.window * 2) + .thresholds(12)(rows); + else { + const size = 64, + values = d3.range(size * size).map((i) => { + const x = ((i % size) - size / 2) / size, + y = (Math.floor(i / size) - size / 2) / size; + return entry.variant.includes("volcano") || + entry.variant.includes("geotiff") + ? 110 * Math.exp(-(x * x + y * y) * 12) + Math.sin(x * 40) * 8 + : 40 * (Math.sin(x * 15) + Math.cos(y * 15)); + }); + const raster = entry.variant.includes("geotiff") ? getTerrain() : null; + contours = d3 + .contours() + .size([raster?.width || size, raster?.height || size]) + .thresholds(raster ? k.quantiles(raster.values) : 18)( + raster ? raster.values : values, + ); + } + const path = d3.geoPath( + density ? null : d3.geoIdentity().scale(7).translate([260, 45]), + ); + for (const c of contours) + p.path( + path(c), + d3.interpolateViridis( + (c.value - (density ? 0 : -80)) / + (density ? d3.max(contours, (r) => r.value) : 190), + ), + p.paper, + ); + p.text( + 65, + 25, + entry.variant.includes("geotiff") + ? "Decoded GeoTIFF · EPSG:4326 · 64 × 64 elevation raster" + : density + ? "Kernel density isolines" + : "Marching-squares raster contours", + { muted: true }, + ); +} +function hexChart(p, rows, state, entry) { + const points = rows.map((r) => [70 + r.x * 820, 50 + r.comparison * 4.3]); + const bins = hexbin() + .radius(state.window) + .extent([ + [65, 40], + [930, 510], + ])(points), + max = d3.max(bins, (r) => r.length) || 1; + for (const bin of bins) { + const radius = entry.variant.includes("area") + ? state.window * Math.sqrt(bin.length / max) + : state.window; + const points = d3 + .range(6) + .map((i) => [ + bin.x + Math.sin((i * Math.PI) / 3) * radius, + bin.y + Math.cos((i * Math.PI) / 3) * radius, + ]); + p.polygon( + points, + d3.interpolateBlues(0.2 + (0.8 * bin.length) / max), + p.paper, + ); + p.hit(bin.x, bin.y, "Hexagonal bin", bin.length); + } + p.text( + 65, + 25, + entry.variant.includes("area") + ? "Area encodes bin count" + : "Color encodes bin count", + { muted: true }, + ); +} +function parallel(p, rows, state, entry) { + const dimensions = ["value", "comparison", "weight", "angle"]; + const sy = dimensions.map((dim) => + d3.scaleLinear( + d3.extent(rows, (r) => r[dim]), + [510, 40], + ), + ); + dimensions.forEach((dim, i) => { + const x = 120 + i * 240; + p.line( + [ + [x, 40], + [x, 510], + ], + p.rule, + ); + p.text(x, 530, dim, { anchor: "middle" }); + }); + for (const r of rows.slice(0, 55)) + p.line( + dimensions.map((dim, i) => [120 + i * 240, sy[i](r[dim])]), + color(r.group), + ); +} +function slope(p, rows, state, entry) { + const max = entry.variant.includes("cancer") ? 4 : 2; + const sy = d3.scaleLinear([0, 110], [510, 40]); + for (let g = 0; g < 10; g++) { + const r = rows[g]; + const pts = d3 + .range(max) + .map((i) => [ + 100 + (i * 760) / (max - 1), + sy(i % 2 ? r.comparison : r.value), + ]); + p.line(pts, color(g)); + pts.forEach(([x, y]) => p.circle(x, y, 4, color(g))); + p.text(90, pts[0][1], `G${g + 1}`, { anchor: "end", size: 11 }); + p.text(870, pts.at(-1)[1], r.comparison.toFixed(1), { size: 11 }); + } + p.text(100, 25, "Before"); + p.text(850, 25, "After"); +} +function radialBars(p, rows, state, entry) { + const groups = entry.adapter === "radialarea" ? 1 : 3; + let data = rows.slice(0, 24); + if (entry.variant.endsWith("-3")) + data = data.slice().sort((a, b) => b.value - a.value); + withOffset(p, 480, 280, () => { + if (entry.adapter === "radialarea") { + p.path( + d3 + .areaRadial() + .angle((r, i) => (i / data.length) * 2 * Math.PI) + .innerRadius(65) + .outerRadius((r) => 65 + r.value * 1.5) + .curve(d3.curveCardinalClosed)(data), + color(0), + null, + ); + } else { + data.forEach((r, i) => { + let radius = 75; + for (let g = 0; g < groups; g++) { + const h = [r.value, r.comparison, r.weight][g] * 0.7; + const arc = d3 + .arc() + .startAngle((i / data.length) * 6.283) + .endAngle(((i + 0.9) / data.length) * 6.283) + .innerRadius(radius) + .outerRadius(radius + h); + p.path(arc(), color(g), null); + radius += h; + } + }); + } + for (let r = 75; r <= 225; r += 50) p.circle(0, 0, r, null, p.rule); + }); +} +function beeswarm(p, rows, state, entry) { + const x = d3.scaleLinear([0, 110], [75, 915]); + const mirrored = entry.variant.includes("mirrored"); + const nodes = rows.slice(0, 140).map((r, i) => ({ + x: x(r.value), + y: 280, + group: r.group, + value: r.value, + r: 3 + (i % 3), + })); + d3.forceSimulation(nodes) + .force("x", d3.forceX((n) => x(n.value)).strength(1)) + .force( + "y", + d3 + .forceY((n) => (mirrored ? (n.group % 2 ? 240 : 320) : 280)) + .strength(0.1), + ) + .force( + "collide", + d3.forceCollide((n) => n.r + 1), + ) + .stop() + .tick(90); + for (const [i, n] of nodes.entries()) { + p.circle(n.x, n.y, n.r, color(n.group)); + p.hit(n.x, n.y, `Sample ${i + 1}`, n.value); + } + p.axis(64, 510, [0, 110], ["Demo value", "Collision-free placement"]); +} +function ridgeline(p, rows, state, entry, k) { + const pulsar = entry.variant.includes("psr"); + const n = pulsar ? 35 : 9; + for (let g = 0; g < n; g++) { + const base = 70 + g * (pulsar ? 12 : 48); + const values = rows + .slice(0, 100) + .map((r, i) => [ + 70 + r.x * 830, + base - + (pulsar + ? Math.exp(-(((r.x - 0.5) * 10) ** 2)) * r.weight * 2 + : Math.sin(r.x * 10 + g) * 10 + r.weight), + ]); + p.path( + d3 + .area() + .x((r) => r[0]) + .y0(base) + .y1((r) => r[1])(values), + p.paper, + pulsar ? p.ink : color(g), + ); + } + p.text( + 70, + 25, + pulsar + ? "Synthetic stacked pulse profiles" + : "Overlapping group distributions", + { muted: true }, + ); +} +function horizon(p, rows, state, entry) { + for (let g = 0; g < 6; g++) { + const baseline = 70 + g * 76; + for (let band = 0; band < 3; band++) { + const points = rows.map((r) => [ + 70 + r.x * 840, + baseline + + 55 - + Math.max( + 0, + Math.min( + 1, + (r.value + 20 * Math.sin(g + state.frame * 0.04) - 20 * band) / + 20, + ), + ) * + 52, + ]); + p.path( + d3 + .area() + .x((r) => r[0]) + .y0(baseline + 55) + .y1((r) => r[1])(points), + d3.interpolateBlues(0.25 + 0.25 * band), + null, + ); + } + p.text(10, baseline + 30, `G${g + 1}`, { size: 11 }); + } +} +function miscellaneous(p, rows, state, entry, k) { + switch (entry.adapter) { + case "arcdiagram": { + const nodes = rows.slice(0, 24); + nodes.forEach((r, i) => { + const x = 60 + i * 36; + p.circle(x, 490, 4, color(r.group)); + p.text(x, 515, i + 1, { anchor: "middle", size: 10 }); + const j = (i * 7 + 3) % 24; + if (j > i) { + const path = d3.path(); + path.moveTo(x, 490); + path.quadraticCurveTo( + (x + 60 + j * 36) / 2, + 490 - (j - i) * 20, + 60 + j * 36, + 490, + ); + p.path(path.toString(), null, color(r.group)); + } + }); + break; + } + case "pyramid": { + const sx = d3.scaleLinear([0, 110], [0, 360]); + for (let i = 0; i < 20; i++) { + const r = rows[i], + y = 50 + i * 23; + p.rect(480 - sx(r.value), y, sx(r.value), 18, color(0)); + p.rect(482, y, sx(r.comparison), 18, color(1)); + p.text(470, y + 11, `${i * 5}`, { + anchor: "end", + fill: "#ffffff", + size: 9, + }); + } + p.text(100, 25, "Population profile · synthetic groups", { muted: true }); + break; + } + case "mosaic": { + const sums = d3.range(6).map((g) => + d3.sum( + rows.filter((r) => r.group === g), + (r) => r.value, + ), + ), + total = d3.sum(sums); + let left = 60; + for (let g = 0; g < 6; g++) { + const w = (sums[g] / total) * 850; + let top = 45; + const vals = rows.slice(g * 3, g * 3 + 3), + sum = d3.sum(vals, (r) => r.value); + for (let j = 0; j < 3; j++) { + const h = (vals[j].value / sum) * 465; + p.rect(left, top, w - 2, h - 2, color(j)); + top += h; + } + p.text(left, 530, `G${g + 1}`, { size: 11 }); + left += w; + } + break; + } + case "timeline": { + for (let i = 0; i < 18; i++) { + const r = rows[i], + start = r.x * 640, + w = 80 + r.weight * 6; + p.rect(130 + start, 40 + i * 27, w, 16, color(r.group)); + p.text(120, 48 + i * 27, `Interval ${i + 1}`, { + anchor: "end", + size: 11, + }); + } + break; + } + case "trains": { + for (let i = 0; i < 14; i++) { + const pts = d3 + .range(7) + .map((j) => [ + 70 + j * 140, + 50 + ((rows[i].value * 4 + j * 33 + i * 13) % 430), + ]); + p.line(pts, color(i)); + } + p.axis(64, 510, [0, 100], ["Time", "Station distance"]); + break; + } + case "candle": { + const sy = d3.scaleLinear([0, 110], [510, 40]); + for (let i = 0; i < 35; i++) { + const r = rows[i], + x = 75 + i * 24, + open = r.value, + close = r.comparison; + p.line( + [ + [x, sy(Math.max(open, close) + 8)], + [x, sy(Math.min(open, close) - 8)], + ], + p.ink, + ); + p.rect( + x - 7, + sy(Math.max(open, close)), + 14, + Math.max(1, Math.abs(sy(open) - sy(close))), + close > open ? color(2) : color(1), + ); + p.hit(x, sy(close), `Period ${i + 1}`, close); + } + p.axis(64, 510); + break; + } + case "dots": { + for (let i = 0; i < 15; i++) { + const r = rows[i], + y = 45 + i * 31; + p.line( + [ + [120, y], + [900, y], + ], + p.rule, + ); + p.circle(120 + r.value * 7, y, 6, color(0)); + p.circle(120 + r.comparison * 7, y, 4, color(1)); + p.text(110, y, `G${i + 1}`, { anchor: "end", size: 11 }); + } + break; + } + case "bubbles": { + const nodes = rows + .slice(0, 55) + .map((r) => ({ r: r.weight * 1.3, group: r.group, x: 480, y: 280 })); + d3.forceSimulation(nodes) + .force( + "x", + d3.forceX((n) => 120 + n.group * 135), + ) + .force("y", d3.forceY(280)) + .force( + "c", + d3.forceCollide((n) => n.r + 2), + ) + .stop() + .tick(100); + nodes.forEach((n, i) => { + p.circle(n.x, n.y, n.r, color(n.group)); + p.hit(n.x, n.y, `Bubble ${i + 1}`, n.r); + }); + break; + } + case "voronoi": { + const points = rows + .slice(0, 50) + .map((r) => [65 + r.x * 830, 50 + r.comparison * 4.4]); + const vor = d3.Delaunay.from(points).voronoi([60, 40, 930, 520]); + for (let i = 0; i < points.length; i++) { + p.path(vor.renderCell(i), null, p.rule); + p.circle(...points[i], 3, color(0)); + p.text(points[i][0] + 4, points[i][1] - 5, `P${i + 1}`, { size: 10 }); + } + break; + } + case "occlusion": { + const placed = []; + for (const r of rows.slice(0, 65)) { + const x = 70 + r.x * 830, + y = 50 + r.comparison * 4.2; + p.circle(x, y, 3, color(r.group)); + const box = [x + 5, y - 12, 44, 13]; + if ( + !placed.some( + (b) => Math.abs(b[0] - box[0]) < 44 && Math.abs(b[1] - box[1]) < 13, + ) + ) { + placed.push(box); + p.text(box[0], box[1], r.name, { size: 10 }); + } + } + break; + } + case "tangled": { + for (let level = 0; level < 5; level++) + for (let i = 0; i < 6; i++) { + const x = 110 + level * 175, + y = 75 + i * 75; + p.rect(x - 24, y - 12, 48, 24, color(i)); + p.text(x, y, `${level}.${i}`, { + anchor: "middle", + fill: "#ffffff", + size: 11, + }); + if (level < 4) + for (let g = 0; g < 2; g++) { + const yy = 75 + ((i * 2 + g) % 6) * 75; + p.path( + d3.linkHorizontal()({ + source: [x + 24, y], + target: [x + 151, yy], + }), + null, + p.rule, + ); + } + } + break; + } + case "legend": + case "schemes": { + const interpolators = [ + d3.interpolateViridis, + d3.interpolateTurbo, + d3.interpolateBlues, + d3.interpolateRdBu, + ]; + for (let g = 0; g < 4; g++) { + p.text( + 65, + 65 + g * 120, + [ + "Sequential / Viridis", + "Sequential / Turbo", + "Sequential / Blues", + "Diverging / RdBu", + ][g], + ); + for (let i = 0; i < 100; i++) + p.rect(65 + i * 8.4, 85 + g * 120, 8.5, 36, interpolators[g](i / 99)); + p.text(65, 140 + g * 120, "Low", { size: 11 }); + p.text(905, 140 + g * 120, "High", { anchor: "end", size: 11 }); + } + break; + } + case "arc": { + const end = 0.2 + (state.frame / 100) * 5.6; + withOffset(p, 480, 280, () => + p.path( + d3 + .arc() + .innerRadius(130) + .outerRadius(220) + .startAngle(0) + .endAngle(end)(), + color(0), + null, + ), + ); + p.text(480, 280, `${((end / Math.PI) * 180).toFixed(0)}°`, { + anchor: "middle", + }); + break; + } + case "circles": { + rows + .slice(0, 32) + .forEach((r, i) => + p.circle( + 100 + r.x * 750, + 80 + r.comparison * 4, + 10 + r.weight * (0.7 + 0.3 * Math.sin(state.frame * 0.03 + i)), + color(r.group), + ), + ); + break; + } + default: + throw new Error(`No miscellaneous adapter for ${entry.adapter}`); + } +} + +export function draw(p, rows, state, entry, k) { + if (!adapterNames.has(entry.adapter)) + throw new Error(`Unknown adapter ${entry.adapter}`); + switch (entry.adapter) { + case "treemap": + treemap(p, rows, state, entry); + break; + case "pack": + packing(p, rows, state, entry); + break; + case "tree": + treeLayout(p, rows, state, entry); + break; + case "sunburst": + case "icicle": + partition(p, rows, state, entry); + break; + case "bars": + bars(p, rows, state, entry); + break; + case "line": + lineChart(p, rows, state, entry, k); + break; + case "area": + areaChart(p, rows, state, entry); + break; + case "scatter": + scatter(p, rows, state, entry); + break; + case "matrix": + matrix(p, rows, state, entry); + break; + case "network": + network(p, rows, state, entry, k); + break; + case "sankey": + case "parallelsets": + sankeyChart(p, rows, state, entry); + break; + case "chord": + chordChart(p, rows, state, entry); + break; + case "bundle": + bundleChart(p, rows, state, entry); + break; + case "pie": + pieChart(p, rows, state, entry); + break; + case "calendar": + case "heatmap": + heatmap(p, rows, state, entry); + break; + case "box": + case "histogram": + case "kde": + case "qq": + statistics(p, rows, state, entry, k); + break; + case "density": + case "contours": + contourChart(p, rows, state, entry, k); + break; + case "hexbin": + if (entry.variant.includes("map")) drawMap(p, rows, state, entry, k); + else hexChart(p, rows, state, entry); + break; + case "parallel": + parallel(p, rows, state, entry); + break; + case "slope": + slope(p, rows, state, entry); + break; + case "radialarea": + case "radialbars": + radialBars(p, rows, state, entry); + break; + case "beeswarm": + beeswarm(p, rows, state, entry); + break; + case "ridgeline": + ridgeline(p, rows, state, entry, k); + break; + case "horizon": + horizon(p, rows, state, entry); + break; + case "map": + case "tiles": + case "vectorfield": + case "stars": + case "cartogram": + drawMap(p, rows, state, entry, k); + break; + case "enclosure": + case "centerline": + case "comparison": + case "predator": + case "clock": + case "fractions": + case "stipple": + case "watercolor": + case "gears": + case "owl": + case "tadpoles": + case "words": + case "moon": + drawSpecial(p, rows, state, entry, k); + break; + default: + miscellaneous(p, rows, state, entry, k); + } +} diff --git a/cerebral-src/visualizations/maps.js b/cerebral-src/visualizations/maps.js new file mode 100644 index 0000000..189ebfd --- /dev/null +++ b/cerebral-src/visualizations/maps.js @@ -0,0 +1,376 @@ +import * as d3 from "d3"; +import * as geo from "d3-geo-projection"; +import { feature } from "topojson-client"; +import { geoVoronoi } from "d3-geo-voronoi"; +import world from "world-atlas/countries-110m.json"; +import us from "us-atlas/states-10m.json"; +import { palette } from "./painter.js"; +const sphere = { type: "Sphere" }, + land = feature(world, world.objects.countries), + states = feature(us, us.objects.states); +const tileCache = new Map(); +const graticule = d3.geoGraticule10(); +function projection(entry, state) { + const v = entry.variant; + let p; + if (/spilhaus/.test(v)) + return d3 + .geoStereographic() + .rotate([95, 45]) + .center([30, -5]) + .clipAngle(166) + .translate([480, 280]) + .scale(47); + if (/orthographic-to|projection-transitions/.test(v)) { + const t = state.frame / 100; + p = d3 + .geoProjection((lambda, phi) => { + const a = d3.geoOrthographicRaw(lambda, phi), + b = d3.geoEquirectangularRaw(lambda, phi); + return [a[0] * (1 - t) + b[0] * t, a[1] * (1 - t) + b[1] * t]; + }) + .clipAngle(90 + t * 90) + .rotate([state.rotation, 0]); + } else if (/world-tour|versor|solar|graticule-labels/.test(v)) + p = d3 + .geoOrthographic() + .rotate(state.rotation3D || [state.rotation + state.frame * 3.6, -15]); + else if (/projection-comparison/.test(v)) + p = [ + d3.geoEqualEarth, + geo.geoMollweide, + d3.geoNaturalEarth1, + d3.geoMercator, + ][state.projection % 4](); + else if (/mercator|tiles/.test(v)) p = d3.geoMercator(); + else p = d3.geoNaturalEarth1(); + return p.fitExtent( + [ + [45, 40], + [915, 510], + ], + sphere, + ); +} +function rasterTiles(p, state, entry) { + const z = Math.min(3, Math.max(1, Math.round(state.zoom) + 1)), + n = 2 ** z, + size = 480 / n, + left = 240, + top = 40; + const v = entry.variant; + for (let y = 0; y < n; y++) + for (let x = 0; x < n; x++) { + const key = `${p.paper}:${z}:${x}:${y}:${v.includes("clip")}`; + let canvas = tileCache.get(key); + if (!canvas) { + canvas = document.createElement("canvas"); + canvas.width = canvas.height = 128; + const ctx = canvas.getContext("2d"); + if (v.includes("clipped")) { + ctx.beginPath(); + ctx.arc(64, 64, 61, 0, Math.PI * 2); + ctx.clip(); + } + ctx.fillStyle = p.paper; + ctx.fillRect(0, 0, 128, 128); + const pr = d3 + .geoMercator() + .scale((n * 128) / (2 * Math.PI)) + .translate([n * 64 - x * 128, n * 64 - y * 128]); + const path = d3.geoPath(pr, ctx); + ctx.beginPath(); + path(land); + ctx.fillStyle = p.paper === "#0A0A0B" ? "#334E61" : "#B7C6CE"; + ctx.fill(); + ctx.beginPath(); + path(graticule); + ctx.strokeStyle = p.rule; + ctx.lineWidth = 0.4; + ctx.stroke(); + tileCache.set(key, canvas); + if (tileCache.size > 200) + tileCache.delete(tileCache.keys().next().value); + } + if (!v.includes("vector-tiles")) + p.image(left + x * size, top + y * size, size, size, canvas); + if (/vector-tiles|raster-vector/.test(v)) { + const pr = d3 + .geoMercator() + .scale(480 / (2 * Math.PI)) + .translate([left + 240, top + 240]) + .clipExtent([ + [left + x * size, top + y * size], + [left + (x + 1) * size, top + (y + 1) * size], + ]); + p.path( + d3.geoPath(pr)(land), + v.includes("vector-tiles") ? palette[0] : null, + p.ink, + ); + } + if (!v.includes("seamless")) + p.line( + [ + [left + x * size, top + y * size], + [left + (x + 1) * size, top + y * size], + [left + (x + 1) * size, top + (y + 1) * size], + [left + x * size, top + (y + 1) * size], + [left + x * size, top + y * size], + ], + p.rule, + ); + if (n <= 4) + p.text(left + x * size + 5, top + y * size + 14, `${z}/${x}/${y}`, { + size: 10, + }); + } + p.text(240, 545, "Local Natural Earth tiles · Web Mercator · z/x/y", { + muted: true, + size: 11, + }); +} +export function drawMap(p, rows, state, entry, k) { + const v = entry.variant; + if (entry.adapter === "tiles") { + rasterTiles(p, state, entry); + return; + } + if (entry.adapter === "vectorfield") { + for (let y = 60; y < 510; y += 25) + for (let x = 60; x < 920; x += 25) { + const angle = + Math.sin(x / 180 + state.frame * 0.02) + Math.cos(y / 120), + dx = Math.cos(angle) * 15, + dy = Math.sin(angle) * 15; + p.line( + [ + [x, y], + [x + dx, y + dy], + ], + palette[0], + ); + p.polygon( + [ + [x + dx, y + dy], + [x + dx - dx * 0.3 - dy * 0.22, y + dy - dy * 0.3 + dx * 0.22], + [x + dx - dx * 0.3 + dy * 0.22, y + dy - dy * 0.3 - dx * 0.22], + ], + palette[0], + ); + } + p.text(60, 25, "Sampled vector direction and magnitude", { muted: true }); + return; + } + if (entry.adapter === "stars") { + const pr = d3 + .geoStereographic() + .rotate([state.rotation, 90]) + .clipAngle(90) + .fitExtent( + [ + [245, 35], + [715, 525], + ], + sphere, + ); + const path = d3.geoPath(pr); + p.path(path(graticule), null, p.rule); + for (const r of rows) { + const pos = pr([r.x * 360 - 180, r.comparison * 1.5 - 75]); + if (pos && pos[0] > 245 && pos[0] < 715 && pos[1] > 35 && pos[1] < 525) + p.circle(...pos, r.weight / 8, p.ink); + } + p.text(245, 545, "Synthetic star field · stereographic sky view", { + muted: true, + size: 11, + }); + return; + } + const usView = + /us-state|us-airports|non-contiguous|choropleth-2$|hexbin-map|bubble-map|spike-map/.test( + v, + ) && !/world|bivariate/.test(v); + const dataset = usView ? states : land; + const pr = usView + ? d3.geoAlbersUsa().fitExtent( + [ + [60, 50], + [900, 505], + ], + states, + ) + : projection(entry, state); + const path = d3.geoPath(pr); + if (!usView) { + p.path(path(sphere), p.paper, p.rule); + p.path(path(graticule), null, p.rule); + } + const choropleth = /choropleth|cartogram/.test(v); + for (const [i, f] of dataset.features.entries()) { + const value = rows[i % rows.length].value / 110; + let fill = choropleth + ? v.includes("bivariate") + ? d3.interpolateRgbBasis(["#e8e8e8", "#ace4e4", "#dfb0d6", "#5a478b"])( + (value + (i % 4) / 4) / 2, + ) + : d3.interpolateBlues(0.15 + 0.8 * value) + : p.paper; + { + const center = path.centroid(f); + if (center.every(Number.isFinite)) + p.hit( + ...center, + f.properties?.name || String(f.id), + rows[i % rows.length].value, + { bounds: path.bounds(f) }, + ); + } + const beforeTri = p.tri.length, + beforeSeg = p.segments.length; + p.path(path(f), fill, p.muted); + if (entry.adapter === "cartogram") { + const c = path.centroid(f), + scale = 0.35 + value * 0.6; + for (const [array, start] of [ + [p.tri, beforeTri], + [p.segments, beforeSeg], + ]) + for (let j = start; j < array.length; j += 3) { + array[j] = c[0] + (array[j] - c[0]) * scale; + array[j + 1] = c[1] + (array[j + 1] - c[1]) * scale; + } + } + } + if (/tissot/.test(v)) { + for (let lon = -150; lon < 180; lon += 30) + for (let lat = -60; lat < 90; lat += 30) + p.path( + path(d3.geoCircle().center([lon, lat]).radius(5)()), + null, + palette[1], + ); + } + if (/antimeridian/.test(v)) { + p.path( + path({ + type: "LineString", + coordinates: [ + [140, 35], + [-145, 40], + [-90, 10], + ], + }), + null, + palette[1], + ); + p.text(70, 540, "A great-circle path crossing the antimeridian", { + muted: true, + }); + } + if (/solar-terminator/.test(v)) { + const center = [ + state.frame * 3.6 - 180, + 23.4 * Math.sin((state.frame / 100) * Math.PI * 2), + ]; + p.path(path(d3.geoCircle().center(center).radius(90)()), "#445065", p.ink); + } + if (/solar-path/.test(v)) { + const coords = d3 + .range(0, 361, 4) + .map((t) => [ + t - 180, + 23.4 * Math.sin(((t + state.frame) * Math.PI) / 180), + ]); + p.path(path({ type: "LineString", coordinates: coords }), null, palette[1]); + const sun = pr( + coords[Math.floor((state.frame / 100) * (coords.length - 1))], + ); + if (sun) p.circle(...sun, 7, palette[4]); + } + if (/graticule-labels/.test(v)) { + for (let lon = -120; lon < 180; lon += 30) { + const pos = pr([lon, 0]); + if (pos && pos[0] > 40 && pos[0] < 920) + p.text(...pos, `${lon}°`, { size: 10 }); + } + } + if (/bubble-map|spike-map|airports|walmarts|hexbin-map/.test(v)) { + const points = [], + coordinates = []; + const n = v.includes("walmarts") + ? Math.max(3, Math.floor(state.frame * 1.8)) + : 90; + for (let i = 0; i < n; i++) { + const r = rows[i % rows.length]; + const lon = usView ? -123 + r.x * 55 : r.x * 350 - 175, + lat = usView ? 27 + (r.comparison % 24) : -60 + (r.comparison % 120); + const pos = pr([lon, lat]); + if (pos && pos.every(Number.isFinite)) { + points.push(pos); + coordinates.push([lon, lat]); + if (v.includes("spike")) + p.polygon( + [ + [pos[0] - 3, pos[1]], + [pos[0] + 3, pos[1]], + [pos[0], pos[1] - r.weight * 1.6], + ], + palette[1], + ); + else if (!v.includes("voronoi") && !v.includes("hexbin")) + p.circle( + ...pos, + v.includes("bubble") ? r.weight * 0.6 : 2.5, + palette[1], + ); + p.hit(...pos, `Location ${i + 1}`, r.value); + } + } + if (v.includes("voronoi")) { + if (v.includes("world")) { + p.path(path(geoVoronoi(coordinates).polygons()), null, palette[0]); + } else { + const vor = d3.Delaunay.from(points).voronoi([50, 40, 920, 515]); + points.forEach((pos, i) => p.path(vor.renderCell(i), null, palette[0])); + } + points.forEach((pos) => p.circle(...pos, 2, palette[1])); + } + if (v.includes("hexbin")) { + const bins = new Map(); + for (const [x, y] of points) { + const q = Math.round(x / 16), + r = Math.round(y / 14); + const key = q + "," + r; + bins.set(key, { + x: q * 16 + (r % 2) * 8, + y: r * 14, + n: (bins.get(key)?.n || 0) + 1, + }); + } + for (const b of bins.values()) + p.polygon( + d3 + .range(6) + .map((i) => [ + b.x + Math.cos((i * Math.PI) / 3) * 9, + b.y + Math.sin((i * Math.PI) / 3) * 9, + ]), + d3.interpolateBlues(Math.min(1, 0.25 + b.n * 0.15)), + p.paper, + ); + } + } + if (choropleth) + for (let i = 0; i < 8; i++) { + p.rect(65 + i * 25, 520, 25, 12, d3.interpolateBlues(0.15 + i * 0.1)); + } + p.text( + 65, + 553, + usView + ? "US Atlas geometry / synthetic values" + : "Natural Earth geometry / synthetic values", + { muted: true, size: 10 }, + ); +} diff --git a/cerebral-src/visualizations/painter.js b/cerebral-src/visualizations/painter.js new file mode 100644 index 0000000..1a69e49 --- /dev/null +++ b/cerebral-src/visualizations/painter.js @@ -0,0 +1,271 @@ +import * as THREE from "three"; +import { SVGLoader } from "three/addons/loaders/SVGLoader.js"; + +const loader = new SVGLoader(); +export const palette = [ + "#165DAD", + "#C74B23", + "#2B7D56", + "#8A4C9C", + "#936800", + "#427E89", + "#AF405C", + "#6B7150", +]; +const colors = new Map(); +function color(value) { + if (!colors.has(value)) { + const c = new THREE.Color(value); + colors.set(value, [c.r, c.g, c.b]); + } + return colors.get(value); +} + +export class Painter { + constructor(width = 960, height = 560, dark = false) { + this.width = width; + this.height = height; + this.ink = dark ? "#F0EEE9" : "#0A0A0B"; + this.muted = dark ? "#A8A6A0" : "#66645F"; + this.rule = dark ? "#444442" : "#CBC8C1"; + this.paper = dark ? "#0A0A0B" : "#F0EEE9"; + this.tri = []; + this.triColors = []; + this.segments = []; + this.segmentColors = []; + this.labels = []; + this.hits = []; + this.images = []; + this.marks = 0; + } + triangle(a, b, c, fill) { + this.tri.push(...a, 0, ...b, 0, ...c, 0); + this.triColors.push(...color(fill), ...color(fill), ...color(fill)); + } + polygon(points, fill, stroke) { + if (points.length < 3) return; + const contour = points.map((p) => new THREE.Vector2(...p)); + if (fill) { + for (const f of THREE.ShapeUtils.triangulateShape(contour, [])) + this.triangle(points[f[0]], points[f[1]], points[f[2]], fill); + } + if (stroke) this.line([...points, points[0]], stroke); + this.marks++; + } + rect(x, y, w, h, fill = this.ink) { + if (![x, y, w, h].every(Number.isFinite) || w < 0 || h < 0) return; + this.triangle([x, y], [x + w, y], [x + w, y + h], fill); + this.triangle([x, y], [x + w, y + h], [x, y + h], fill); + this.marks++; + } + line(points, stroke = this.ink) { + for (let i = 1; i < points.length; i++) { + const a = points[i - 1], + b = points[i]; + if ([...a, ...b].every(Number.isFinite)) { + this.segments.push(...a, 0, ...b, 0); + this.segmentColors.push(...color(stroke), ...color(stroke)); + } + } + this.marks++; + } + circle(x, y, r, fill = this.ink, stroke) { + const n = Math.max(12, Math.min(48, Math.ceil(r))); + const p = Array.from({ length: n }, (_, i) => [ + x + r * Math.cos((i / n) * Math.PI * 2), + y + r * Math.sin((i / n) * Math.PI * 2), + ]); + this.polygon(p, fill, stroke); + } + path(d, fill = null, stroke = this.ink) { + if (!d) return; + const parsed = loader.parse( + ``, + ); + for (const path of parsed.paths) { + if (fill) { + for (const shape of SVGLoader.createShapes(path)) { + const points = shape.extractPoints(6); + const contour = points.shape.map((p) => [p.x, p.y]); + const holes = points.holes.map((h) => h.map((p) => [p.x, p.y])); + const flat = [...contour, ...holes.flat()]; + for (const f of THREE.ShapeUtils.triangulateShape( + points.shape, + points.holes, + )) + this.triangle(flat[f[0]], flat[f[1]], flat[f[2]], fill); + } + } + if (stroke) + for (const part of path.subPaths) + this.line( + part.getPoints(80).map((p) => [p.x, p.y]), + stroke, + ); + } + this.marks++; + } + text(x, y, text, options = {}) { + if (!Number.isFinite(x + y)) return; + this.labels.push({ x, y, text: String(text), ...options }); + } + hit(x, y, label, value, meta = {}) { + if (Number.isFinite(x + y)) + this.hits.push({ x, y, label: String(label), value, ...meta }); + } + axis(x, y, domain = [0, 100], labels = ["Sample", "Value"]) { + this.line( + [ + [x, y], + [this.width - 30, y], + ], + this.rule, + ); + this.line( + [ + [x, 35], + [x, y], + ], + this.rule, + ); + for (let i = 0; i <= 4; i++) { + const yy = y - ((y - 35) * i) / 4; + this.line( + [ + [x, yy], + [this.width - 30, yy], + ], + this.rule, + ); + this.text( + x - 10, + yy, + Number((domain[0] + ((domain[1] - domain[0]) * i) / 4).toPrecision(3)), + { anchor: "end", muted: true }, + ); + } + this.text(x, 18, labels[1], { muted: true }); + this.text(this.width - 30, y + 28, labels[0], { + anchor: "end", + muted: true, + }); + } + glyph(x, y, text, size, fill) { + const canvas = document.createElement("canvas"); + const context = canvas.getContext("2d"); + context.font = `${size}px monospace`; + const width = Math.ceil(context.measureText(text).width) + 4; + canvas.width = width * 2; + canvas.height = Math.ceil(size * 1.4) * 2; + context.scale(2, 2); + context.font = `${size}px monospace`; + context.fillStyle = fill; + context.fillText(text, 2, size); + this.image(x, y - size, width, canvas.height / 2, canvas, 1); + } + image(x, y, w, h, canvas, layer = -1) { + this.images.push({ x, y, w, h, canvas, layer }); + this.marks++; + } + group() { + const group = new THREE.Group(); + for (const [positions, vertexColors, type] of [ + [this.tri, this.triColors, "tri"], + [this.segments, this.segmentColors, "line"], + ]) { + if (!positions.length) continue; + const geometry = new THREE.BufferGeometry(); + geometry.setAttribute( + "position", + new THREE.Float32BufferAttribute(positions, 3), + ); + geometry.setAttribute( + "color", + new THREE.Float32BufferAttribute(vertexColors, 3), + ); + const material = + type === "tri" + ? new THREE.MeshBasicMaterial({ + vertexColors: true, + side: THREE.DoubleSide, + depthTest: false, + }) + : new THREE.LineBasicMaterial({ + vertexColors: true, + depthTest: false, + }); + group.add( + type === "tri" + ? new THREE.Mesh(geometry, material) + : new THREE.LineSegments(geometry, material), + ); + } + for (const image of this.images) { + const texture = new THREE.CanvasTexture(image.canvas); + texture.colorSpace = THREE.SRGBColorSpace; + const geometry = new THREE.PlaneGeometry(image.w, image.h); + const material = new THREE.MeshBasicMaterial({ + map: texture, + side: THREE.DoubleSide, + depthTest: false, + transparent: image.layer > 0, + alphaTest: image.layer > 0 ? 0 : 0.01, + }); + const mesh = new THREE.Mesh(geometry, material); + mesh.position.set(image.x + image.w / 2, image.y + image.h / 2, 0); + mesh.scale.y = -1; + mesh.renderOrder = image.layer; + group.add(mesh); + } + return group; + } +} + +export class Viewport { + constructor(canvas) { + this.renderer = new THREE.WebGLRenderer({ + canvas, + antialias: true, + alpha: false, + preserveDrawingBuffer: true, + powerPreference: "low-power", + }); + this.renderer.setPixelRatio(Math.min(devicePixelRatio, 2)); + this.scene = new THREE.Scene(); + this.camera = new THREE.OrthographicCamera(0, 960, 0, 560, -10, 10); + this.group = null; + this.zoom = 1; + this.pan = [0, 0]; + } + render(painter, zoom = 1, pan = [0, 0]) { + if (this.group) { + this.scene.remove(this.group); + this.group.traverse((o) => { + o.geometry?.dispose(); + o.material?.map?.dispose(); + o.material?.dispose(); + }); + } + this.group = painter.group(); + this.scene.add(this.group); + this.scene.background = new THREE.Color(painter.paper); + const canvas = this.renderer.domElement; + this.renderer.setSize(canvas.clientWidth, canvas.clientHeight, false); + this.camera.left = 0; + this.camera.right = painter.width; + this.camera.top = 0; + this.camera.bottom = painter.height; + this.camera.zoom = zoom; + this.camera.position.set(pan[0], pan[1], 1); + this.camera.updateProjectionMatrix(); + this.renderer.render(this.scene, this.camera); + } + dispose() { + this.group?.traverse((o) => { + o.geometry?.dispose(); + o.material?.map?.dispose(); + o.material?.dispose(); + }); + this.renderer.dispose(); + } +} diff --git a/cerebral-src/visualizations/raster.js b/cerebral-src/visualizations/raster.js new file mode 100644 index 0000000..5ee814e --- /dev/null +++ b/cerebral-src/visualizations/raster.js @@ -0,0 +1,22 @@ +import { fromArrayBuffer } from "geotiff"; +let terrain = null, + pending = null; +export function getTerrain() { + return terrain; +} +export function loadTerrain() { + return (pending ??= (async () => { + const response = await fetch("/visualizations/terrain.tiff"); + if (!response.ok) throw Error("Local GeoTIFF is unavailable"); + const tiff = await fromArrayBuffer(await response.arrayBuffer()); + const image = await tiff.getImage(); + const values = await image.readRasters({ interleave: true }); + terrain = { + width: image.getWidth(), + height: image.getHeight(), + bbox: image.getBoundingBox(), + values: Array.from(values), + }; + return terrain; + })()); +} diff --git a/cerebral-src/visualizations/registry.mjs b/cerebral-src/visualizations/registry.mjs new file mode 100644 index 0000000..52c31bb --- /dev/null +++ b/cerebral-src/visualizations/registry.mjs @@ -0,0 +1,5 @@ +export const adapterNames = new Set( + "treemap network scatter bars area circles map pack tree icicle sunburst pyramid pie arc line matrix tiles box histogram kde density contours hexbin qq parallelsets tangled arcdiagram sankey bundle chord mosaic timeline calendar heatmap slope trains candle parallel ridgeline horizon dots bubbles beeswarm radialarea radialbars voronoi occlusion legend vectorfield stars cartogram enclosure centerline comparison predator clock fractions stipple watercolor gears owl tadpoles words moon schemes".split( + " ", + ), +); diff --git a/cerebral-src/visualizations/special.js b/cerebral-src/visualizations/special.js new file mode 100644 index 0000000..f68b7d2 --- /dev/null +++ b/cerebral-src/visualizations/special.js @@ -0,0 +1,362 @@ +import * as d3 from "d3"; +import { palette } from "./painter.js"; +const c = (i) => palette[i % palette.length]; +function gear(p, cx, cy, r, teeth, angle, fill) { + const points = []; + for (let i = 0; i < teeth * 4; i++) { + const a = angle + (i / (teeth * 4)) * Math.PI * 2, + rr = i % 4 < 2 ? r : r * 0.87; + points.push([cx + Math.cos(a) * rr, cy + Math.sin(a) * rr]); + } + p.polygon(points, fill); + p.circle(cx, cy, r * 0.2, p.paper, p.ink); +} +function fractionTree(depth, left, right, x, y, spread, p) { + const [a, b] = left, + [c, d] = right, + mid = [a + c, b + d]; + p.text(x, y, `${mid[0]}/${mid[1]}`, { anchor: "middle", size: 11 }); + if (!depth) return; + for (const [side, nextLeft, nextRight] of [ + [-1, left, mid], + [1, mid, right], + ]) { + const xx = x + side * spread; + p.line( + [ + [x, y + 8], + [xx, y + 74], + ], + p.rule, + ); + fractionTree(depth - 1, nextLeft, nextRight, xx, y + 82, spread / 2, p); + } +} +export function drawSpecial(p, rows, state, entry, k) { + switch (entry.adapter) { + case "enclosure": { + const circles = rows.slice(0, 18).map((r) => ({ + x: 100 + r.x * 730, + y: 90 + r.comparison * 3.5, + r: 8 + r.weight, + })); + const enclose = d3.packEnclose(circles); + p.circle(enclose.x, enclose.y, enclose.r, null, p.ink); + circles.forEach((r, i) => p.circle(r.x, r.y, r.r, c(i))); + p.text(65, 30, "Smallest enclosing circle of weighted disks", { + muted: true, + }); + break; + } + case "centerline": { + const top = rows + .slice(0, 70) + .map((r) => [ + 60 + r.x * 840, + 170 + Math.sin(r.x * 7) * 50 - r.weight * 2, + ]); + const bottom = rows + .slice(0, 70) + .map((r) => [ + 60 + r.x * 840, + 350 + Math.sin(r.x * 7) * 50 + r.weight * 2, + ]); + p.polygon([...top, ...bottom.slice().reverse()], c(0)); + const center = top.map((r, i) => [r[0], (r[1] + bottom[i][1]) / 2]); + p.line(center, p.paper); + const text = "FOLLOW THE CENTERLINE"; + for (let i = 0; i < text.length; i++) { + const q = + center[ + Math.floor(((i + 1) / (text.length + 1)) * (center.length - 1)) + ]; + p.text(...q, text[i], { anchor: "middle", fill: "#ffffff", size: 14 }); + } + break; + } + case "comparison": { + const values = rows.slice(0, 6); + for (let g = 0; g < 3; g++) { + const left = 60 + g * 300; + p.text(left, 45, ["Position", "Length", "Area"][g]); + for (let i = 0; i < values.length; i++) { + const y = 95 + i * 72, + v = values[i].value; + if (g === 0) { + p.line( + [ + [left, y], + [left + 250, y], + ], + p.rule, + ); + p.circle(left + v * 2, y, 5, c(i)); + } else if (g === 1) p.rect(left, y - 7, v * 2, 14, c(i)); + else p.circle(left + 125, y, Math.sqrt(v) * 2.8, c(i)); + } + } + break; + } + case "predator": { + const data = k.predator(500, 0.03), + max = d3.max(data, (r) => Math.max(r.prey, r.predator)), + x = d3.scaleLinear([0, data.at(-1).x], [65, 930]), + y = d3.scaleLinear([0, max], [510, 40]); + for (const [g, key] of ["prey", "predator"].entries()) + p.path( + d3 + .line() + .x((r) => x(r.x)) + .y((r) => y(r[key]))( + data.slice( + 0, + Math.max(20, Math.round((data.length * state.frame) / 100)), + ), + ), + null, + c(g), + ); + p.axis( + 64, + 510, + [0, max], + ["Simulation time", "Population (model units)"], + ); + p.text(65, 25, "Lotka–Volterra numerical integration / WASM", { + muted: true, + }); + break; + } + case "clock": { + const date = new Date( + Date.UTC(2026, 0, 1, 0, 0, 0) + (state.frame / 100) * 86400000, + ); + const fractions = [ + date.getUTCSeconds() / 60, + date.getUTCMinutes() / 60, + date.getUTCHours() / 24, + (date.getUTCDay() + 1) / 7, + date.getUTCDate() / 31, + (date.getUTCMonth() + 1) / 12, + ]; + fractions.forEach((v, i) => { + const inner = 65 + i * 26, + outer = inner + 20; + const d = d3 + .arc() + .innerRadius(inner) + .outerRadius(outer) + .startAngle(0) + .endAngle(v * Math.PI * 2)(); + const before = p.tri.length; + p.path(d, c(i), null); + for (let j = before; j < p.tri.length; j += 3) { + p.tri[j] += 480; + p.tri[j + 1] += 280; + } + }); + p.text(480, 280, date.toISOString().slice(11, 19), { anchor: "middle" }); + p.text(480, 305, "UTC demonstration day", { anchor: "middle", size: 11 }); + break; + } + case "fractions": + fractionTree(4, [0, 1], [1, 0], 480, 55, 225, p); + break; + case "stipple": { + let points = rows + .slice(0, 250) + .map((r) => [80 + r.x * 800, 60 + r.comparison * 4.2]); + for (let iter = 0; iter < Math.floor(state.frame / 5); iter++) { + const vor = d3.Delaunay.from(points).voronoi([60, 40, 930, 515]); + points = points.map((point, i) => { + const polygon = vor.cellPolygon(i); + if (!polygon) return point; + const center = d3.polygonCentroid(polygon); + return [ + point[0] + (center[0] - point[0]) * 0.6, + point[1] + (center[1] - point[1]) * 0.6, + ]; + }); + } + points.forEach(([x, y], i) => + p.circle( + x, + y, + 1 + 3 * Math.exp(-((x - 480) ** 2 + (y - 280) ** 2) / 50000), + p.ink, + ), + ); + p.text(65, 25, "Voronoi relaxation / weighted synthetic field", { + muted: true, + }); + break; + } + case "watercolor": { + for (let layer = 0; layer < 18; layer++) { + const points = d3.range(80).map((i) => { + const a = (i / 80) * Math.PI * 2, + r = 140 + layer * 4 + rows[(i + layer) % rows.length].weight; + return [480 + Math.cos(a) * r, 280 + Math.sin(a) * r * 0.8]; + }); + p.polygon( + points, + d3.interpolateRgb(p.paper, c(layer % 3))(0.05 + (18 - layer) * 0.025), + ); + } + break; + } + case "gears": { + const angle = (state.frame / 100) * Math.PI * 2; + gear(p, 480, 280, 205, 48, -angle / 3, p.muted); + p.circle(480, 280, 172, p.paper); + gear(p, 480, 280, 70, 16, angle, c(0)); + for (let i = 0; i < 3; i++) { + const a = (i / 3) * Math.PI * 2 - angle / 3; + gear( + p, + 480 + Math.cos(a) * 120, + 280 + Math.sin(a) * 120, + 50, + 12, + (-angle * 16) / 12, + c(i + 1), + ); + } + p.text(480, 535, "Sun / planet / ring gear ratios", { + anchor: "middle", + muted: true, + }); + break; + } + case "owl": { + const depth = 2 + Math.min(5, state.refine), + n = 2 ** depth, + w = 430 / n; + for (let y = 0; y < n; y++) + for (let x = 0; x < n; x++) { + const nx = ((x + 0.5) / n) * 2 - 1, + ny = ((y + 0.5) / n) * 2 - 1; + const face = nx * nx + ny * ny < 0.8, + eyes = + (nx - 0.35) ** 2 + (ny + 0.2) ** 2 < 0.07 || + (nx + 0.35) ** 2 + (ny + 0.2) ** 2 < 0.07; + const pupil = (Math.abs(nx) - 0.35) ** 2 + (ny + 0.2) ** 2 < 0.012; + p.circle( + 265 + (x + 0.5) * w, + 45 + (y + 0.5) * w, + w * 0.48, + pupil ? p.ink : eyes ? "#EEE6C9" : face ? "#9A774D" : p.paper, + ); + } + p.text( + 265, + 515, + `Adaptive subdivision depth ${depth} / click to refine`, + { muted: true, size: 11 }, + ); + break; + } + case "tadpoles": { + for (let i = 0; i < 50; i++) { + const r = rows[i], + a = r.angle + state.frame * 0.02, + x = 480 + Math.cos(a) * (100 + r.value * 2.2), + y = 280 + Math.sin(a * 1.2) * (50 + r.weight * 7); + const tail = d3 + .range(9) + .map((j) => [ + x - j * 5 * Math.cos(a) + Math.sin(j + state.frame * 0.2) * j, + y - j * 5 * Math.sin(a), + ]); + p.line(tail, p.muted); + p.circle(x, y, 4, c(r.group)); + } + break; + } + case "words": { + const words = [ + "intent", + "evidence", + "memory", + "routing", + "latency", + "affinity", + "objects", + "cohort", + "cortex", + "scorcher", + "saga", + "samples", + "trace", + "scheduler", + "cache", + "protocol", + "plan", + "clock", + "simulation", + "result", + "transport", + "queue", + "data", + "work", + ]; + const placed = []; + words.forEach((word, i) => { + const size = 13 + rows[i].weight * 1.1, + w = word.length * size * 0.6, + h = size; + let found; + for (let j = 0; j < 1800; j++) { + const a = j * 0.19, + r = j * 0.15, + x = 480 + Math.cos(a) * r - w / 2, + y = 280 + Math.sin(a) * r * 0.6 - h / 2; + if (x < 55 || x + w > 920 || y < 40 || y + h > 510) continue; + if ( + !placed.some( + (b) => + x < b.x + b.w + 4 && + x + w + 4 > b.x && + y < b.y + b.h + 4 && + y + h + 4 > b.y, + ) + ) { + found = { x, y, w, h }; + break; + } + } + if (found) { + placed.push(found); + p.glyph(found.x, found.y + h, word, size, c(i)); + p.hit(found.x + w / 2, found.y + h / 2, word, size); + } + }); + break; + } + case "moon": { + for (let moon = 0; moon < 8; moon++) { + const cx = 110 + (moon % 4) * 240, + cy = 145 + Math.floor(moon / 4) * 250, + r = 72, + phase = (moon / 8 + state.frame / 100) % 1, + angle = phase * Math.PI * 2; + p.circle(cx, cy, r, p.muted); + for (let x = -r; x < r; x += 2) { + const height = Math.sqrt(r * r - x * x); + for (let y = -height; y < height; y += 3) { + const z = Math.sqrt(Math.max(0, r * r - x * x - y * y)), + light = x * Math.sin(angle) + z * Math.cos(angle); + if (light > 0) p.rect(cx + x, cy + y, 2.1, 3.1, "#EBE3C9"); + } + } + p.text(cx, cy + 95, `${Math.round(phase * 360)}°`, { + anchor: "middle", + size: 11, + }); + } + break; + } + default: + throw new Error(`Missing special ${entry.adapter}`); + } +} diff --git a/docs/bench-cerebral-work.md b/docs/bench-cerebral-work.md new file mode 100644 index 0000000..44d059a --- /dev/null +++ b/docs/bench-cerebral-work.md @@ -0,0 +1,52 @@ +# bench.cerebral.work + +A separate Cerebral benchmark site in `unsigned-gg/bench`, the established benchmark repository. The existing `bench.unsigned.gg` model bank continues to use `public/` and `wrangler.jsonc`. + +## Source and design + +- `cerebral-src/`: page template, CSS, browser behavior, and evidence JSON. +- `scripts/build-cerebral.mjs`: generates `cerebral/`, a static asset tree, including initial server-readable results and a CSV export. +- `scripts/bench-data.mjs`: validates evidence types, denominators, source values, artifact hashes and public-data boundaries. +- `wrangler.cerebral.jsonc`: the separate `cerebral-bench` Worker and `bench.cerebral.work` custom-domain target. +- `.github/workflows/cerebral-bench.yml`: checks PRs and retains the static site as a review artifact. It does not deploy. + +Visual source: the Cerebral V2 homepage captured on 2026-10-26. Warm paper `#F0EEE9`, ink `#0A0A0B`, black/white dark theme, the existing Fractul/Gunter display stack, Space Mono labels, full-width two-column structure, square controls, and 1px rules. Extraction is recorded in `cerebral-work/cerebral-design` PR #40 and the site implementation map in `cerebral-work/site` PR #52. This consumer does not ratify or modify shared brand contracts. Fonts are requested from their existing hosted locations; no font binaries are redistributed here. A platform mono fallback remains functional if those fonts are unavailable. + +## Evidence model + +All initial results are first-party. There is no universal score or cross-system ranking. + +| Source | Captured evidence | Boundary | +| --- | --- | --- | +| Scorcher | Local release-binary microbenchmark; 10,000 routing iterations; 100 shared-memory roundtrips | Other loop denominators scale separately. One capture on a shared Linux/WSL2 workstation; no confidence interval or production claim. | +| Cortex | Inspected reference suite 0056 coverage | No distinct run record was found/attached during this capture. Its numbers remain absent. Scorcher's vendored lineage is not an independent Cortex execution. | +| Saga scheduling | Local debug-binary run: four plans × three strategies | Virtual-clock simulation in declared plan units; no tasks executed and no host-pressure trace. | +| Saga eval fixtures | Two committed validation records, each with a failing no-op and two passing reference-patch runs | Fixture validity, not an agent-model pass rate. Advisory judge scores and transcripts are excluded. | + +Each source record includes the inspected revision/path and SHA-256. Captured executable SHA-256 and source-context revision are separate fields because the source revision is not a binary-build attestation. The public index includes SHA-256 for each published JSON artifact. The original Scorcher output's hash is retained; the public capture omits per-request solver outputs and retains the relevant summary. + +The source repos were read without editing their shared checkouts or launching a distributed benchmark. A bounded local Scorcher capture and Saga simulation supplied new evidence. Cortex remains protocol-only. The public tree contains no local machine names, personal paths, internal endpoints or raw agent transcripts. + +## Develop and verify + +```sh +npm install +npm run test:cerebral +npm run build:cerebral +npm run check:cerebral +npm run dev:cerebral +``` + +The builder requires only Node. Wrangler uses the existing pinned dev dependency. `check:cerebral` runs tests, generates the static tree and performs a Worker dry run. The browser UI progressively adds query/search/evidence filters, percentile selection, scheduler fixture selection, and a saved theme. Initial results and evidence links are present without JavaScript. + +A query such as `?system=saga&q=lock&evidence=simulation` is shareable. Filters update URL state, not the underlying evidence. Numeric downloads retain original units and evidence labels. + +## Updating results + +Add/update a sanitized artifact in `cerebral-src/data/`, record its context and limitations, and update its SHA-256 in `benchmarks.json`. Every displayed index measurement must resolve to its source value, with an independent sample count for each measured workload. Add a dedicated validated adapter before attaching a numeric Cortex result. Retain negative controls for eval fixtures. Build and inspect the rendered page at desktop/mobile widths in both themes before opening a PR. + +## Production handoff + +The configured hostname was not resolvable when this work started; `cerebral.work` and the existing benchmark host resolved as controls. The hostname and Worker target are prepared in source. Merge/deployment and external DNS/edge changes remain operator-gated under the estate rules. + +After approval, deploy the reviewed revision with `npm run deploy:cerebral` (or the estate `cf` deploy workflow where supported), then probe the real hostname, downloadable records and custom 404. The separate config keeps the model-bank deployment independent. No new credentials, Access changes or infrastructure application are part of this implementation. diff --git a/docs/qa/cerebral-bench-2026-10-26.md b/docs/qa/cerebral-bench-2026-10-26.md new file mode 100644 index 0000000..9c65521 --- /dev/null +++ b/docs/qa/cerebral-bench-2026-10-26.md @@ -0,0 +1,12 @@ +# Cerebral benchmark site verification — 2026-10-26 + +- Data-integrity suite: 12/12 pass, including tampered artifact/value/unit/denominator rejection, simulation classification, absent Cortex result handling and negative-control enforcement. +- Browser behavior: 26/26 pass. Covers keyboard skip navigation, system/search/evidence filters, reset and empty state, query reload, actual p99 value selection, scheduler fixture switching, theme persistence, six evidence/CSV downloads, and no-JavaScript results. +- Responsive checks: no document-width overflow at 320, 375, 390, 768, 1024 or 1440px after fixing the narrow heading. +- Automated axe WCAG A/AA checks: zero violations at 1440/390px in light and dark themes and at 320px light; no uncaught page errors. This is targeted automated evidence, not comprehensive accessibility certification. +- Visual review: desktop/mobile hero and results reviewed against the extracted paper/ink V2 system. +- Worker dry runs: both the Cerebral config and existing unsigned config pass. +- Local Worker emulator: root returns 200 HTML, evidence index 200 JSON, CSV 200 text/csv, unknown route 404 with the custom return link. +- Existing unsigned model-bank assets, root Worker configuration, eval definitions and deploy workflow have no changes. + +Source executable captures are a bounded local Scorcher run and a Saga virtual-clock simulation, with separate binary fingerprints and inspected source context. Cortex has protocol coverage only; the UI does not assign it a score. The production hostname and deployment are prepared in source and remain pending operator approval. diff --git a/docs/qa/visualization-gallery-2026-10-26.md b/docs/qa/visualization-gallery-2026-10-26.md new file mode 100644 index 0000000..a15a41d --- /dev/null +++ b/docs/qa/visualization-gallery-2026-10-26.md @@ -0,0 +1,25 @@ +# Visualization gallery validation — 2026-10-26 + +## Coverage + +- Pinned D3 gallery revision 1120: 174 unique attributed entries, 14 categories. +- All 174 selected in an actual Chrome browser: finite Three.js geometry, positive mark/vertex counts, nonempty pixel output. No uncaught page errors. +- Browser coverage is reproducible with `CHROME_PATH=/usr/bin/google-chrome npm run test:gallery:browser`; CI uses its installed Playwright Chromium. Both use SwiftShader software WebGL. Results are not a hardware-performance benchmark. +- Eight accessibility combinations: widths 1440, 768, 390, 320 × light/dark, zero axe WCAG A/AA and WCAG 2.1 A/AA violations; no horizontal document overflow. +- Search, category count, empty/reset state, deep links/reload, frame persistence, hierarchy drill/reset, brush selection, keyboard mark inspection, zoom/reset, quaternion globe drag, geographic bounding-box focus, stacked/grouped interpolation, adaptive image subdivision, CSV download, animation play/pause and reduced-motion behavior pass. +- Failure controls: blocked WASM request, unavailable WebGL context, and disabled JavaScript preserve the catalog and explain renderer availability. + +## Numeric and packaging checks + +- 3 native Rust tests pass with the shared-buffer tests serialized. +- 24 Node tests pass: 12 existing benchmark evidence checks plus 12 gallery/kernel checks. Unknown adapter, missing/duplicate inventory and source drift controls fail as expected. Compiled WASM magic, deterministic sampling, histogram count conservation, rolling means/deviations, interpolated quantiles, nearest-point selection, density integration and public-path remapping are verified. +- GeoTIFF decodes as a 64 × 64 EPSG:4326 raster with nonconstant values. +- Static catalog contains exactly 174 local entries. No Observable iframe/API runtime is bundled. +- Cerebral and legacy Worker dry-runs both pass; the Cerebral assets include the gallery bundle, WASM, terrain file and complete bundled-package attribution. +- Original homepage browser regression passes: filters, real p99 values, Saga fixture selection, persistence, downloads, 320/375/768/1024 overflow controls and no-JavaScript evidence rendering. The gallery navigation addition wraps at narrow widths. + +## Artifacts and release + +Browser output: `test-results/gallery/coverage.json`, desktop/mobile PNGs (generated, gitignored, retained by CI). Additional local evidence is in `/tmp/cerebral-gallery-20261026/`. Screenshots were visually reviewed. Source snapshot, data types, attribution and limitations are recorded in `docs/visualization-gallery.md`. + +No merge, production deploy or DNS change was performed. The existing benchmark capture limitations remain in force, including Cortex results pending and Saga virtual-clock units. diff --git a/docs/visualization-gallery.md b/docs/visualization-gallery.md new file mode 100644 index 0000000..9ed6aff --- /dev/null +++ b/docs/visualization-gallery.md @@ -0,0 +1,33 @@ +# Cerebral visualization lab + +The `/visualizations/` surface belongs to the Cerebral consumer of unsigned-gg/bench. The legacy model benchmark site is unaffected. The homepage navigation links to the lab and wraps at narrow widths. + +## Coverage and sources + +The requested source is [D3 gallery](https://observablehq.com/@d3/gallery), observed as notebook revision **1120** on 2026-10-26, with 174 entries across 14 categories. SHA-256 of its retrieved JavaScript source: `e9b19333c720b5cf3eebc6dc682a124a052c449627ac7b0861e763d95b8ac3e0`. The same entry count was verified in the rendered notebook. `cerebral-src/visualizations/inventory.json` pins every title, author, original URL, adapter, interaction and stable local ID. + +The [featured-libraries collection](https://observablehq.com/@observablehq/-/collection/featured-libraries) points to the D3 gallery, Plot Gallery and Hello Inputs. It informs the library/control references; the complete implementation set here is the requested 174-entry D3 snapshot. This does not claim to port every example in the separate Plot gallery. + +These are local concept implementations with demonstration data, rather than copies of the original notebooks or their historical datasets. Titles identify the source example; a historical title does not identify the local data as a historical measurement. The lab does not execute or embed remote notebook code. Every source entry has an explicit adapter, and validation rejects an unknown adapter instead of substituting a generic chart. + +## Rendering and data + +- `painter.js`: Three.js orthographic camera, batched triangle/line buffers, raster tile/text texture quads, semantic HTML labels, bounded pixel ratio and resource disposal. Word-cloud glyphs are WebGL textures; labels elsewhere are HTML annotations. +- `layouts.js`, `maps.js`, `special.js`: explicit chart-family encodings and per-example variants. D3 supplies scales, shapes, contours, layouts and geographic math; Three.js owns the graphics. +- `visualization-wasm/src/lib.rs`: compiled WASM for deterministic sampling, rolling means/deviations, histograms, quantiles, Gaussian density estimation, force steps, nearest-mark selection and Lotka–Volterra integration. This is actual numeric processing, not a JavaScript fallback labeled as WASM. Layout/projection algorithms remain JavaScript; no performance speedup is claimed. +- `raster.js`: decodes a real locally generated EPSG:4326 GeoTIFF; WASM quantiles choose its contour thresholds. Geographic outlines use locally bundled Natural Earth and US Atlas data; raster/vector tile examples derive their own local tiles. +- `lab.js`: category/search/example query state, frame/detail/sample deep links, keyboard/touch inspection, brush selection, hierarchy focus/reset, scale/sort changes, camera zoom/pan, quaternion globe dragging, bounding-box focus and opt-in animation. Reduced motion disables playback; hidden documents suspend the frame loop. + +Synthetic seed data is independent of benchmark receipts. The existing Scorcher/Cortex/Saga JSON records remain unchanged. No demonstration is presented as a measured benchmark result. Table/CSV expose input samples; some layouts derive groups, positions or model outputs, while frame-driven geometry also uses the displayed animation state. + +## Build and package + +`node scripts/build-cerebral.mjs` compiles the WASM crate for `wasm32-unknown-unknown`, builds the local gallery bundle and writes it into `cerebral/visualizations/`. The observed local compiler is rustc 1.99.0. Cargo has no third-party crate dependencies; JavaScript packages are pinned in package-lock.json. Compiler home-directory paths are remapped in the public WASM. + +The build emits the catalog, runtime, WASM, source inventory, generated terrain TIFF and a NOTICE file containing licenses for every bundled package identified by esbuild's dependency graph. The LERC Apache notice is kept under `third-party/` because its npm package omits the full license file. Hosted display typography uses the same Cerebral CSS URL as the benchmark homepage; no commercial font binary is copied into the repo. + +The CI workflow installs the WASM target, runs native and compiled-kernel tests, builds all assets, exercises every example in Chromium and performs a Worker dry-run. It retains review artifacts and does not deploy this hostname. + +## Practical boundaries + +The interactive lab needs JavaScript, WebAssembly and WebGL. Its static 174-entry catalog and source links remain readable without JavaScript. WASM/WebGL failures have explicit fallback messages; the benchmark homepage retains its independently verified no-JavaScript results. Browser render tests use software WebGL and establish correctness, not GPU performance. Original essay prose, original historical datasets, live third-party map tiles and pixel-identical notebook reproductions are outside this consumer. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..c50c6a2 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2804 @@ +{ + "name": "unsigned-bench", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "unsigned-bench", + "devDependencies": { + "@axe-core/playwright": "4.14.0", + "d3": "7.9.0", + "d3-geo-projection": "4.0.0", + "d3-geo-voronoi": "2.1.0", + "d3-hexbin": "0.2.2", + "d3-sankey": "0.12.3", + "esbuild": "0.25.11", + "geotiff": "3.0.5", + "playwright": "1.61.1", + "three": "0.186.0", + "topojson-client": "3.1.0", + "us-atlas": "3.0.1", + "world-atlas": "2.0.2", + "wrangler": "4.107.0" + } + }, + "node_modules/@axe-core/playwright": { + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@axe-core/playwright/-/playwright-4.14.0.tgz", + "integrity": "sha512-SGUhG5PIHd2eMdpgBF2PyQLOhX+qyDR2PT4cmoS4Qk2ak+jX/rrSvst9l0PGv5WTHolKpUMvVmoHpr4cZgf1RQ==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "axe-core": "~4.14.0" + }, + "engines": { + "node": ">=22.12.0" + }, + "peerDependencies": { + "playwright-core": ">= 1.0.0" + } + }, + "node_modules/@cloudflare/kv-asset-handler": { + "version": "0.5.0", + "dev": true, + "license": "MIT OR Apache-2.0", + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@cloudflare/unenv-preset": { + "version": "2.16.1", + "dev": true, + "license": "MIT OR Apache-2.0", + "peerDependencies": { + "unenv": "2.0.0-rc.24", + "workerd": ">1.20260305.0 <2.0.0-0" + }, + "peerDependenciesMeta": { + "workerd": { + "optional": true + } + } + }, + "node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20260701.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260701.1.tgz", + "integrity": "sha512-Zd9Y1bah6DwwBN2RW8vJohffQrIUazb8UXnqSNecOxM+jJLhUuvv5IOG8dbHcV83TyZAubea6gsQXo2yH1lDdw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20260701.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260701.1.tgz", + "integrity": "sha512-yBLsjS1qCWqFyCY37qRUrYfzHHvMGvjh8zRKJ6MvUivYDhkZTzqduppK38FoqYvayLJ5KbcxH7zo5rkxGqbsaA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20260701.1", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20260701.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260701.1.tgz", + "integrity": "sha512-HRfwbKU2pK44V2NhoM0+iH0JJSj7nQ9Wv13ifIiGYCmTtDL8/zKtEhX7kQ3D4Vy/Cpjhttl0FkfqXj1aqLDPPg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20260701.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260701.1.tgz", + "integrity": "sha512-ngxCiIN9s/fM2o1IBMD0o1/mcXrv2NJVdyznh51UH8sQuvrTrXvV2nM0Uj/qU2wMwF6prgNBcdcd7AZeZGiBQA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.11.tgz", + "integrity": "sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.11.tgz", + "integrity": "sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.11.tgz", + "integrity": "sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.11.tgz", + "integrity": "sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.11.tgz", + "integrity": "sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.11.tgz", + "integrity": "sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.11.tgz", + "integrity": "sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.11.tgz", + "integrity": "sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.11.tgz", + "integrity": "sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.11.tgz", + "integrity": "sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.11.tgz", + "integrity": "sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.11.tgz", + "integrity": "sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.11.tgz", + "integrity": "sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.11.tgz", + "integrity": "sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.11.tgz", + "integrity": "sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.11.tgz", + "integrity": "sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.11.tgz", + "integrity": "sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.11.tgz", + "integrity": "sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.11.tgz", + "integrity": "sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.11.tgz", + "integrity": "sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.11.tgz", + "integrity": "sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.11.tgz", + "integrity": "sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.11.tgz", + "integrity": "sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.11.tgz", + "integrity": "sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.11.tgz", + "integrity": "sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.11.tgz", + "integrity": "sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.2.4", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.34.5", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.7.0" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@petamoriken/float16": { + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.9.3.tgz", + "integrity": "sha512-8awtpHXCx/bNpFt4mt2xdkgtgVvKqty8VbjHI/WWWQuEw+KLzFot3f4+LkQY9YmOtq7A5GdOnqoIC8Pdygjk2g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@poppinss/colors": { + "version": "4.1.6", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^4.1.5" + } + }, + "node_modules/@poppinss/dumper": { + "version": "0.6.5", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@sindresorhus/is": "^7.0.2", + "supports-color": "^10.0.0" + } + }, + "node_modules/@poppinss/exception": { + "version": "1.2.3", + "dev": true, + "license": "MIT" + }, + "node_modules/@sindresorhus/is": { + "version": "7.2.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@speed-highlight/core": { + "version": "1.2.24", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/axe-core": { + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.14.0.tgz", + "integrity": "sha512-9WTZxEjsZ7b13TH8JPmbV2z8CHbl80/2hm3XPEG4JgNdQLK81IBRXmSxHfMAOkSqQeRxT/0dwNDz2GOm3zzpcQ==", + "dev": true, + "license": "MPL-2.0", + "engines": { + "node": ">=4" + } + }, + "node_modules/blake3-wasm": { + "version": "2.1.5", + "dev": true, + "license": "MIT" + }, + "node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/cookie": { + "version": "1.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/d3": { + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/d3/-/d3-7.9.0.tgz", + "integrity": "sha512-e1U46jVP+w7Iut8Jt8ri1YsPOvFpg46k+K8TpCb0P+zjCkjkPnV7WzfDJzMHy1LnA+wj5pLT1wjO901gLXeEhA==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-axis": "3", + "d3-brush": "3", + "d3-chord": "3", + "d3-color": "3", + "d3-contour": "4", + "d3-delaunay": "6", + "d3-dispatch": "3", + "d3-drag": "3", + "d3-dsv": "3", + "d3-ease": "3", + "d3-fetch": "3", + "d3-force": "3", + "d3-format": "3", + "d3-geo": "3", + "d3-hierarchy": "3", + "d3-interpolate": "3", + "d3-path": "3", + "d3-polygon": "3", + "d3-quadtree": "3", + "d3-random": "3", + "d3-scale": "4", + "d3-scale-chromatic": "3", + "d3-selection": "3", + "d3-shape": "3", + "d3-time": "3", + "d3-time-format": "4", + "d3-timer": "3", + "d3-transition": "3", + "d3-zoom": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", + "dev": true, + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-axis": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-3.0.0.tgz", + "integrity": "sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-brush": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-3.0.0.tgz", + "integrity": "sha512-ALnjWlVYkXsVIGlOsuWH1+3udkYFI48Ljihfnh8FZPF2QS9o+PzGLBslO0PjzVoHLZ2KCVgAM8NVkXPJB2aNnQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "3", + "d3-transition": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-chord": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-3.0.1.tgz", + "integrity": "sha512-VE5S6TNa+j8msksl7HwjxMHDM2yNK3XCkusIlpX5kwauBfXuyLAtNg9jCp/iHH61tgI4sb6R/EIMWCqEIdjT/g==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-path": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-contour": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-4.0.2.tgz", + "integrity": "sha512-4EzFTRIikzs47RGmdxbeUvLWtGedDUNkTcmzoeyg4sP/dvCexO47AaQL7VKy/gul85TOxw+IBgA8US2xwbToNA==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "^3.2.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-delaunay": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==", + "dev": true, + "license": "ISC", + "dependencies": { + "delaunator": "5" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.1.tgz", + "integrity": "sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==", + "dev": true, + "license": "ISC", + "dependencies": { + "commander": "7", + "iconv-lite": "0.6", + "rw": "1" + }, + "bin": { + "csv2json": "bin/dsv2json.js", + "csv2tsv": "bin/dsv2dsv.js", + "dsv2dsv": "bin/dsv2dsv.js", + "dsv2json": "bin/dsv2json.js", + "json2csv": "bin/json2dsv.js", + "json2dsv": "bin/json2dsv.js", + "json2tsv": "bin/json2dsv.js", + "tsv2csv": "bin/dsv2dsv.js", + "tsv2json": "bin/dsv2json.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-fetch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-3.0.1.tgz", + "integrity": "sha512-kpkQIM20n3oLVBKGg6oHrUchHM3xODkTzjMoj7aWQFq5QEM+R6E4WkzT5+tojDY7yjez8KgCBRoj4aEr99Fdqw==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dsv": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-force": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.0.tgz", + "integrity": "sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-quadtree": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.2.tgz", + "integrity": "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz", + "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "2.5.0 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo-projection": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/d3-geo-projection/-/d3-geo-projection-4.0.0.tgz", + "integrity": "sha512-p0bK60CEzph1iqmnxut7d/1kyTmm3UWtPlwdkM31AU+LW+BXazd5zJdoCn7VFxNCHXRngPHRnsNn5uGjLRGndg==", + "dev": true, + "license": "ISC", + "dependencies": { + "commander": "7", + "d3-array": "1 - 3", + "d3-geo": "1.12.0 - 3" + }, + "bin": { + "geo2svg": "bin/geo2svg.js", + "geograticule": "bin/geograticule.js", + "geoproject": "bin/geoproject.js", + "geoquantize": "bin/geoquantize.js", + "geostitch": "bin/geostitch.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo-voronoi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/d3-geo-voronoi/-/d3-geo-voronoi-2.1.0.tgz", + "integrity": "sha512-kqE4yYuOjPbKdBXG0xztCacPwkVSK2REF1opSNrnqqtXJmNcM++UbwQ8SxvwP6IQTj9RvIjjK4qeiVsEfj0Z2Q==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-delaunay": "6", + "d3-geo": "3", + "d3-tricontour": "1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-hexbin": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/d3-hexbin/-/d3-hexbin-0.2.2.tgz", + "integrity": "sha512-KS3fUT2ReD4RlGCjvCEm1RgMtp2NFZumdMu4DBzQK8AZv3fXRM6Xm8I4fSU07UXvH4xxg03NwWKWdvxfS/yc4w==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/d3-hierarchy": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", + "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz", + "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-polygon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-3.0.1.tgz", + "integrity": "sha512-3vbA7vXYwfe1SYhED++fPUQlWSYTTGmFmQiany/gdbiWgU/iEyQzyymwL9SkJjFFuCS4902BSzewVGsHHmHtXg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-quadtree": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz", + "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-random": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.1.tgz", + "integrity": "sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-sankey": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/d3-sankey/-/d3-sankey-0.12.3.tgz", + "integrity": "sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "d3-array": "1 - 2", + "d3-shape": "^1.2.0" + } + }, + "node_modules/d3-sankey/node_modules/d3-array": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz", + "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "internmap": "^1.0.0" + } + }, + "node_modules/d3-sankey/node_modules/d3-path": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz", + "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/d3-sankey/node_modules/d3-shape": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz", + "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "d3-path": "1" + } + }, + "node_modules/d3-sankey/node_modules/internmap": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz", + "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==", + "dev": true, + "license": "ISC" + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-shape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", + "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-path": "^3.1.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-tricontour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/d3-tricontour/-/d3-tricontour-1.1.0.tgz", + "integrity": "sha512-G7gHKj89n2owmkGb6WX6ixcnQ0Kf/0wpa9VIh9DGdbHu8wdrlaHU4ir3/bFNERl8N8nn4G7e7qbtBG8N9caihQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-delaunay": "6", + "d3-scale": "4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/delaunator": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.1.0.tgz", + "integrity": "sha512-AGrQ4QSgssa1NGmWmLPqN5NY2KajF5MqxetNEO+o0n3ZwZZeTmt7bBnvzHWrmkZFxGgr4HdyFgelzgi06otLuQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/error-stack-parser-es": { + "version": "1.0.5", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/esbuild": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.11.tgz", + "integrity": "sha512-KohQwyzrKTQmhXDW1PjCv3Tyspn9n5GcY2RTDqeORIdIJY8yKIF7sTSopFmn/wpMPW4rdPXI0UE5LJLuq3bx0Q==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.11", + "@esbuild/android-arm": "0.25.11", + "@esbuild/android-arm64": "0.25.11", + "@esbuild/android-x64": "0.25.11", + "@esbuild/darwin-arm64": "0.25.11", + "@esbuild/darwin-x64": "0.25.11", + "@esbuild/freebsd-arm64": "0.25.11", + "@esbuild/freebsd-x64": "0.25.11", + "@esbuild/linux-arm": "0.25.11", + "@esbuild/linux-arm64": "0.25.11", + "@esbuild/linux-ia32": "0.25.11", + "@esbuild/linux-loong64": "0.25.11", + "@esbuild/linux-mips64el": "0.25.11", + "@esbuild/linux-ppc64": "0.25.11", + "@esbuild/linux-riscv64": "0.25.11", + "@esbuild/linux-s390x": "0.25.11", + "@esbuild/linux-x64": "0.25.11", + "@esbuild/netbsd-arm64": "0.25.11", + "@esbuild/netbsd-x64": "0.25.11", + "@esbuild/openbsd-arm64": "0.25.11", + "@esbuild/openbsd-x64": "0.25.11", + "@esbuild/openharmony-arm64": "0.25.11", + "@esbuild/sunos-x64": "0.25.11", + "@esbuild/win32-arm64": "0.25.11", + "@esbuild/win32-ia32": "0.25.11", + "@esbuild/win32-x64": "0.25.11" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/geotiff": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-3.0.5.tgz", + "integrity": "sha512-OWcL9S9+yDZ6iAlXMt32T1iwUApJM8UiD47xbm6ZP1h33d10fqkPs14EG/ttT5EnefpZSx3G15iDFC5FxUNUwA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@petamoriken/float16": "^3.9.3", + "lerc": "^3.0.0", + "pako": "^2.0.4", + "parse-headers": "^2.0.2", + "quick-lru": "^6.1.1", + "web-worker": "^1.5.0", + "xml-utils": "^1.10.2", + "zstddec": "^0.2.0" + }, + "engines": { + "node": ">=10.19" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/kleur": { + "version": "4.1.5", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/lerc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lerc/-/lerc-3.0.0.tgz", + "integrity": "sha512-Rm4J/WaHhRa93nCN2mwWDZFoRVF18G1f47C+kvQWyHGEZxFpTUi73p7lMVSAndyxGt6lJ2/CFbOcf9ra5p8aww==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/miniflare": { + "version": "4.20260701.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "0.34.5", + "undici": "7.28.0", + "workerd": "1.20260701.1", + "ws": "8.21.0", + "youch": "4.1.0-beta.10" + }, + "bin": { + "miniflare": "bootstrap.js" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/pako": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.2.0.tgz", + "integrity": "sha512-zJq6RP/5q+TO2OpFV3FHzlPnFjmkb7Nc99a5SNjJE+uu/PkpChs+NIZSSzbBoD+6kjiISXjfYdwj1ZRQ81dz/w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "(MIT AND Zlib)" + }, + "node_modules/parse-headers": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.6.tgz", + "integrity": "sha512-Tz11t3uKztEW5FEVZnj1ox8GKblWn+PvHY9TmJV5Mll2uHEwRdR/5Li1OlXoECjLYkApdhWy44ocONwXLiKO5A==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-to-regexp": { + "version": "6.3.0", + "dev": true, + "license": "MIT" + }, + "node_modules/pathe": { + "version": "2.0.3", + "dev": true, + "license": "MIT" + }, + "node_modules/playwright": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.61.1.tgz", + "integrity": "sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.61.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", + "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/playwright/node_modules/playwright-core": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.61.1.tgz", + "integrity": "sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/quick-lru": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-6.1.2.tgz", + "integrity": "sha512-AAFUA5O1d83pIHEhJwWCq/RQcRukCkn/NSm2QsTEMle5f2hP0ChI2+3Xb051PZCkLryI/Ir1MVKviT2FIloaTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/robust-predicates": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.3.tgz", + "integrity": "sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==", + "dev": true, + "license": "Unlicense" + }, + "node_modules/rw": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", + "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.5", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sharp": { + "version": "0.34.5", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.0.0", + "detect-libc": "^2.1.2", + "semver": "^7.7.3" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.34.5", + "@img/sharp-darwin-x64": "0.34.5", + "@img/sharp-libvips-darwin-arm64": "1.2.4", + "@img/sharp-libvips-darwin-x64": "1.2.4", + "@img/sharp-libvips-linux-arm": "1.2.4", + "@img/sharp-libvips-linux-arm64": "1.2.4", + "@img/sharp-libvips-linux-ppc64": "1.2.4", + "@img/sharp-libvips-linux-riscv64": "1.2.4", + "@img/sharp-libvips-linux-s390x": "1.2.4", + "@img/sharp-libvips-linux-x64": "1.2.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", + "@img/sharp-libvips-linuxmusl-x64": "1.2.4", + "@img/sharp-linux-arm": "0.34.5", + "@img/sharp-linux-arm64": "0.34.5", + "@img/sharp-linux-ppc64": "0.34.5", + "@img/sharp-linux-riscv64": "0.34.5", + "@img/sharp-linux-s390x": "0.34.5", + "@img/sharp-linux-x64": "0.34.5", + "@img/sharp-linuxmusl-arm64": "0.34.5", + "@img/sharp-linuxmusl-x64": "0.34.5", + "@img/sharp-wasm32": "0.34.5", + "@img/sharp-win32-arm64": "0.34.5", + "@img/sharp-win32-ia32": "0.34.5", + "@img/sharp-win32-x64": "0.34.5" + } + }, + "node_modules/supports-color": { + "version": "10.2.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/three": { + "version": "0.186.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.186.0.tgz", + "integrity": "sha512-cr/fIM2ddMSVbYVgkfD4jLJv7Fh/8ZTjvo+7gQeSVGUZHxpx9FDwoL5iC7hUz/LiRA8wMbqfnb90xKfm1/HHkQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/topojson-client": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/topojson-client/-/topojson-client-3.1.0.tgz", + "integrity": "sha512-605uxS6bcYxGXw9qi62XyrV6Q3xwbndjachmNxu8HWTtVPxZfEJN9fd/SZS1Q54Sn2y0TMyMxFj/cJINqGHrKw==", + "dev": true, + "license": "ISC", + "dependencies": { + "commander": "2" + }, + "bin": { + "topo2geo": "bin/topo2geo", + "topomerge": "bin/topomerge", + "topoquantize": "bin/topoquantize" + } + }, + "node_modules/topojson-client/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/undici": { + "version": "7.28.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/unenv": { + "version": "2.0.0-rc.24", + "dev": true, + "license": "MIT", + "dependencies": { + "pathe": "^2.0.3" + } + }, + "node_modules/us-atlas": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/us-atlas/-/us-atlas-3.0.1.tgz", + "integrity": "sha512-wEIZCq0ImPvGblTd8gZMqNNCPkQshugMUG/8nkSWXb02+XqNFREg9atHOKP9w6prLZTpqcLhSvdBW81MkV3/0Q==", + "dev": true, + "license": "ISC" + }, + "node_modules/web-worker": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.5.0.tgz", + "integrity": "sha512-RiMReJrTAiA+mBjGONMnjVDP2u3p9R1vkcGz6gDIrOMT3oGuYwX2WRMYI9ipkphSuE5XKEhydbhNEJh4NY9mlw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/workerd": { + "version": "1.20260701.1", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20260701.1", + "@cloudflare/workerd-darwin-arm64": "1.20260701.1", + "@cloudflare/workerd-linux-64": "1.20260701.1", + "@cloudflare/workerd-linux-arm64": "1.20260701.1", + "@cloudflare/workerd-windows-64": "1.20260701.1" + } + }, + "node_modules/world-atlas": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/world-atlas/-/world-atlas-2.0.2.tgz", + "integrity": "sha512-IXfV0qwlKXpckz1FhwXVwKRjiIhOnWttOskm5CtxMsjgE/MXAYRHWJqgXOpM8IkcPBoXnyTU5lFHcYa5ChG0LQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/wrangler": { + "version": "4.107.0", + "dev": true, + "license": "MIT OR Apache-2.0", + "dependencies": { + "@cloudflare/kv-asset-handler": "0.5.0", + "@cloudflare/unenv-preset": "2.16.1", + "blake3-wasm": "2.1.5", + "esbuild": "0.28.1", + "miniflare": "4.20260701.0", + "path-to-regexp": "6.3.0", + "unenv": "2.0.0-rc.24", + "workerd": "1.20260701.1" + }, + "bin": { + "cf-wrangler": "bin/cf-wrangler.js", + "wrangler": "bin/wrangler.js", + "wrangler2": "bin/wrangler.js" + }, + "engines": { + "node": ">=22.0.0" + }, + "optionalDependencies": { + "fsevents": "2.3.3" + }, + "peerDependencies": { + "@cloudflare/workers-types": "^4.20260701.1" + }, + "peerDependenciesMeta": { + "@cloudflare/workers-types": { + "optional": true + } + } + }, + "node_modules/wrangler/node_modules/@esbuild/aix-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz", + "integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/android-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz", + "integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/android-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz", + "integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/android-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz", + "integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/darwin-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz", + "integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/darwin-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz", + "integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz", + "integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/freebsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz", + "integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz", + "integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz", + "integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz", + "integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-loong64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz", + "integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-mips64el": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz", + "integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz", + "integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-riscv64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz", + "integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-s390x": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz", + "integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz", + "integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz", + "integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/netbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz", + "integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz", + "integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/openbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz", + "integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz", + "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/sunos-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz", + "integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/win32-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz", + "integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/win32-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz", + "integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/win32-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz", + "integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/esbuild": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz", + "integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.1", + "@esbuild/android-arm": "0.28.1", + "@esbuild/android-arm64": "0.28.1", + "@esbuild/android-x64": "0.28.1", + "@esbuild/darwin-arm64": "0.28.1", + "@esbuild/darwin-x64": "0.28.1", + "@esbuild/freebsd-arm64": "0.28.1", + "@esbuild/freebsd-x64": "0.28.1", + "@esbuild/linux-arm": "0.28.1", + "@esbuild/linux-arm64": "0.28.1", + "@esbuild/linux-ia32": "0.28.1", + "@esbuild/linux-loong64": "0.28.1", + "@esbuild/linux-mips64el": "0.28.1", + "@esbuild/linux-ppc64": "0.28.1", + "@esbuild/linux-riscv64": "0.28.1", + "@esbuild/linux-s390x": "0.28.1", + "@esbuild/linux-x64": "0.28.1", + "@esbuild/netbsd-arm64": "0.28.1", + "@esbuild/netbsd-x64": "0.28.1", + "@esbuild/openbsd-arm64": "0.28.1", + "@esbuild/openbsd-x64": "0.28.1", + "@esbuild/openharmony-arm64": "0.28.1", + "@esbuild/sunos-x64": "0.28.1", + "@esbuild/win32-arm64": "0.28.1", + "@esbuild/win32-ia32": "0.28.1", + "@esbuild/win32-x64": "0.28.1" + } + }, + "node_modules/ws": { + "version": "8.21.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xml-utils": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/xml-utils/-/xml-utils-1.10.2.tgz", + "integrity": "sha512-RqM+2o1RYs6T8+3DzDSoTRAUfrvaejbVHcp3+thnAtDKo8LskR+HomLajEy5UjTz24rpka7AxVBRR3g2wTUkJA==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/youch": { + "version": "4.1.0-beta.10", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@poppinss/dumper": "^0.6.4", + "@speed-highlight/core": "^1.2.7", + "cookie": "^1.0.2", + "youch-core": "^0.3.3" + } + }, + "node_modules/youch-core": { + "version": "0.3.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/exception": "^1.2.2", + "error-stack-parser-es": "^1.0.5" + } + }, + "node_modules/zstddec": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/zstddec/-/zstddec-0.2.0.tgz", + "integrity": "sha512-oyPnDa1X5c13+Y7mA/FDMNJrn4S8UNBe0KCqtDmor40Re7ALrPN6npFwyYVRRh+PqozZQdeg23QtbcamZnG5rA==", + "dev": true, + "license": "MIT AND BSD-3-Clause" + } + } +} diff --git a/package.json b/package.json index dde75b0..cdd7df0 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,30 @@ "scripts": { "dev": "wrangler dev", "deploy": "wrangler deploy", - "check": "wrangler deploy --dry-run --outdir /tmp/wr-build" + "check": "wrangler deploy --dry-run --outdir /tmp/wr-build", + "build:cerebral": "node scripts/build-cerebral.mjs", + "validate:cerebral": "node scripts/validate-cerebral-bench.mjs", + "test:cerebral": "node --test tests/cerebral-bench.test.mjs", + "dev:cerebral": "npm run build:cerebral && wrangler dev --config wrangler.cerebral.jsonc", + "check:cerebral": "npm run test:cerebral && npm run build:cerebral && npm run test:gallery && wrangler deploy --config wrangler.cerebral.jsonc --dry-run --outdir /tmp/cerebral-bench-worker", + "deploy:cerebral": "npm run check:cerebral && wrangler deploy --config wrangler.cerebral.jsonc", + "test:gallery": "node --test tests/cerebral-gallery.test.mjs", + "test:gallery:browser": "node tests/gallery-browser.mjs" }, "devDependencies": { + "@axe-core/playwright": "4.14.0", + "d3": "7.9.0", + "d3-geo-projection": "4.0.0", + "d3-geo-voronoi": "2.1.0", + "d3-hexbin": "0.2.2", + "d3-sankey": "0.12.3", + "esbuild": "0.25.11", + "geotiff": "3.0.5", + "playwright": "1.61.1", + "three": "0.186.0", + "topojson-client": "3.1.0", + "us-atlas": "3.0.1", + "world-atlas": "2.0.2", "wrangler": "4.107.0" } } diff --git a/scripts/bench-data.mjs b/scripts/bench-data.mjs new file mode 100644 index 0000000..d8ef0bf --- /dev/null +++ b/scripts/bench-data.mjs @@ -0,0 +1,46 @@ +import {readFileSync} from 'node:fs'; +import {join} from 'node:path'; +import {createHash} from 'node:crypto'; +export const digest = bytes => createHash('sha256').update(bytes).digest('hex'); +export function validateData(data, records) { + if (data.schemaVersion !== 1 || !/^\d{4}-\d{2}-\d{2}$/.test(data.snapshot)) throw Error('Invalid snapshot schema'); + if (data.systems.map(s=>s.id).sort().join(',') !== 'cortex,saga,scorcher') throw Error('Expected three named systems'); + const allowed = {scorcher:'measured',cortex:'protocol',saga:'simulation'}; + for(const s of data.systems) if(s.type!==allowed[s.id]) throw Error('System evidence type changed'); + for(const a of data.artifacts) { + if(!/^[a-z-]+\.json$/.test(a.file)||!records[a.file]) throw Error('Missing evidence record'); + if(digest(records[a.file])!==a.sha256) throw Error('Evidence digest mismatch'); + } + const parsed=Object.fromEntries(Object.entries(records).map(([name,bytes])=>[name,JSON.parse(bytes)])); + const seen=new Set(); + for(const m of data.measurements){ + if(seen.has(m.id)) throw Error('Duplicate measurement');seen.add(m.id); + if(!Number.isFinite(m.value)||m.value<0) throw Error('Invalid measurement value'); + if(m.evidence!==allowed[m.system]||m.system==='cortex') throw Error('Unsupported numeric evidence claim'); + if(!parsed[m.source]) throw Error('Missing measurement source'); + if(m.evidence==='measured'){ + if(!Number.isInteger(m.samples)||m.samples<=0) throw Error('Missing measurement denominator'); + const value=m.pointer.split('/').slice(1).reduce((obj,key)=>obj?.[key],parsed[m.source]); + if(value!==m.value) throw Error('Measurement differs from receipt'); + const expectedUnit=m.pointer.endsWith('_ns')?'ns':m.pointer.endsWith('_us')?'µs':m.pointer.endsWith('/actual_calls')?'calls':null; + if(!expectedUnit||m.unit!==expectedUnit) throw Error('Measured unit differs from source schema'); + const count=m.samplePointer?.split('/').slice(1).reduce((obj,key)=>obj?.[key],parsed[m.source]); + if(count!==m.samples) throw Error('Sample denominator differs from receipt'); + }else{ + const row=parsed[m.source].rows?.find(r=>r.plan===m.plan&&r.strategy===m.strategy); + if(!row||row.error||row.makespan!==m.value||m.unit!=='plan units') throw Error('Simulation differs from receipt'); + } + } + if(parsed['cortex-protocol.json'].result!==null) throw Error('Cortex needs a separate validated result adapter'); + for(const c of parsed['saga-controls.json'].controls){ + if(!c.valid||c.negativeControlPassed!==false||c.referencePatchPassed.length<1||c.referencePatchPassed.some(p=>p!==true)) throw Error('Invalid negative/reference controls'); + } + const unsafe=/\b(?:ctodie|cygnus|tailnet|tail769bd2|ganymede)\b|\/home\/|https?:\/\/(?:127\.|10\.|192\.168\.)/i; + if(unsafe.test(JSON.stringify([data,parsed]))) throw Error('Private machine or network detail in public evidence'); + return parsed; +} +export function loadData(root){ + const data=JSON.parse(readFileSync(join(root,'benchmarks.json'))); + const records=Object.fromEntries(data.artifacts.map(a=>[a.file,readFileSync(join(root,a.file))])); + return {data,records,parsed:validateData(data,records)}; +} diff --git a/scripts/build-cerebral.mjs b/scripts/build-cerebral.mjs new file mode 100644 index 0000000..b7a9de6 --- /dev/null +++ b/scripts/build-cerebral.mjs @@ -0,0 +1,40 @@ +import {readFileSync,writeFileSync,mkdirSync,cpSync,rmSync} from 'node:fs'; +import {fileURLToPath} from 'node:url'; +import {join} from 'node:path'; +import {loadData} from './bench-data.mjs'; +import {buildGallery} from './build-gallery.mjs'; +const root=fileURLToPath(new URL('../',import.meta.url)),src=join(root,'cerebral-src'),out=join(root,'cerebral'); +const {data,parsed}=loadData(join(src,'data'));const sc=parsed['scorcher-local.json'],m=sc.bench.metrics,sa=parsed['saga-scheduler.json']; +const escape=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); +const number=(n,d=2)=>new Intl.NumberFormat('en-US',{maximumFractionDigits:d}).format(n); +const stat=(value,unit,label)=>`
${escape(value)}${escape(unit)}

${escape(label)}

`; +const rows=[['Affinity routing',m.ring_p50_ns,m.ring_p99_ns,'ns',sc.iters],['Adaptive routing',m.p2c_p50_ns,m.p2c_p99_ns,'ns',sc.iters],['Hot-cache lookup',m.tier0_p50_ns,m.tier0_p99_ns,'ns',m.tier0_iters],['Durable object write · 64 KiB',m.put_p50_us,m.put_p99_us,'µs',m.put_count],['Verified object read · 64 KiB',m.tier1_p50_us,m.tier1_p99_us,'µs',m.put_count],['Sealed-descriptor delivery · 8 MiB',m.memfd_p50_us,m.memfd_p99_us,'µs',m.ipc_iters],['Copied-socket delivery · 8 MiB',m.raw_p50_us,m.raw_p99_us,'µs',m.ipc_iters],['Shared-memory roundtrip · 8 KiB',sc.shm_roundtrip.latency_p50_us,sc.shm_roundtrip.latency_p99_us,'µs',sc.shm_roundtrip.round_trips]]; +const scRows=rows.map(([name,p50,p99,unit,n])=>`${escape(name)}${number(p50)} ${unit}${number(p99)} ${unit}${number(n,0)}`).join(''); +const plans=[...new Set(sa.rows.map(r=>r.plan))];const current=plans[2]; +const sagaRows=sa.rows.map(r=>`${escape(r.plan.replace('bench-',''))}${escape(r.strategy.toUpperCase())}${r.makespan}${r.waves}${number(r.utilization_ppm/10000,1)}%`).join(''); +const bar=(name,value,max,attrs='')=>`
${escape(name)}
${number(value)} µs
`; +const transportChart=[['Sealed descriptor',m.memfd_p50_us,m.memfd_p99_us],['Socket copy',m.raw_p50_us,m.raw_p99_us]].map(([name,p50,p99])=>bar(name,p50,Math.max(m.raw_p50_us,m.memfd_p50_us),`data-latency data-p50="${p50}" data-p99="${p99}"`)).join(''); +const sagaChart=sa.rows.filter(r=>r.plan===current).map(r=>`
${r.strategy.toUpperCase()}
${r.makespan} units
`).join(''); +const protocol=parsed['cortex-protocol.json']; +const controls=parsed['saga-controls.json'].controls.map(c=>`syn / ${escape(c.task)} Fails as expected${c.referencePatchPassed.length}/${c.referencePatchPassed.length} pass${escape(c.validatedAt.slice(0,10))}`).join(''); +const record=(name,file)=>`
Read the ${escape(name)} run record

Evidence and capture context are included with this download.

Download ${escape(file)} ↓
Artifact SHA-256
${data.artifacts.find(a=>a.file===file).sha256}
`; +let template=readFileSync(join(src,'index.html'),'utf8'); +const replacements={ + SNAPSHOT:data.snapshot,ROUNDTRIP:number(sc.shm_roundtrip.latency_p50_us),ROUNDTRIP_TAIL:number(sc.shm_roundtrip.latency_p99_us), + SCORCHER_FACTS:stat(number(m.ring_p50_ns,0),'ns','Affinity routing · p50 · n = 10,000')+stat(number(sc.shm_roundtrip.latency_p50_us),'µs','8 KiB roundtrip · p50 · n = 100')+stat(String(m.actual_calls),`/ ${m.concurrency}`,'Upstream calls / concurrent misses'), + SCORCHER_ROWS:scRows,TRANSPORT_CHART:transportChart, + CORTEX_COVERAGE:protocol.coverage.map((s,i)=>`
  • ${String(i+1).padStart(2,'0')}${escape(s)}specified
  • `).join(''), + SAGA_CHART:sagaChart,SAGA_ROWS:sagaRows,SAGA_OPTIONS:plans.map(p=>``).join(''), + CONTROL_ROWS:controls,SCORCHER_RECORD:record('Scorcher','scorcher-local.json'),CORTEX_RECORD:record('Cortex protocol','cortex-protocol.json'),SAGA_RECORD:record('Saga simulation','saga-scheduler.json'), + CLIENT_DATA:JSON.stringify({scheduler:sa.rows}).replaceAll('<','\\u003c') +}; +for(const [key,value] of Object.entries(replacements))template=template.replaceAll(`{{${key}}}`,value); +if(/\{\{[A-Z_]+\}\}/.test(template))throw Error('Unresolved template marker'); +rmSync(out,{recursive:true,force:true});mkdirSync(out,{recursive:true}); +for(const file of ['styles.css','app.js','favicon.svg','robots.txt','404.html'])cpSync(join(src,file),join(out,file)); +cpSync(join(src,'data'),join(out,'data'),{recursive:true});writeFileSync(join(out,'index.html'),template); +const csv=['system,workload,evidence,value,unit,samples,source',...data.measurements.map(r=>[r.system,r.name,r.evidence,r.value,r.unit,r.samples??'',r.source].map(v=>'"'+String(v).replaceAll('"','""')+'"').join(','))].join('\n')+'\n';writeFileSync(join(out,'data/measurements.csv'),csv); +writeFileSync(join(out,'sitemap.xml'),'https://bench.cerebral.work/https://bench.cerebral.work/visualizations/\n'); +console.log(`Built ${out}: static results, four evidence records, CSV export`); + +await buildGallery(join(out,'visualizations')); diff --git a/scripts/build-gallery.mjs b/scripts/build-gallery.mjs new file mode 100644 index 0000000..869b8f4 --- /dev/null +++ b/scripts/build-gallery.mjs @@ -0,0 +1,147 @@ +import { readFileSync, writeFileSync, mkdirSync, cpSync } from "node:fs"; +import { join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { spawnSync } from "node:child_process"; +import { build } from "esbuild"; +import { writeArrayBuffer } from "geotiff"; +import { validateInventory } from "./gallery-contract.mjs"; +const root = fileURLToPath(new URL("../", import.meta.url)); +export async function buildGallery( + out = join(root, "cerebral/visualizations"), +) { + const src = join(root, "cerebral-src/visualizations"), + inventory = JSON.parse(readFileSync(join(src, "inventory.json"), "utf8")); + validateInventory(inventory); + const result = spawnSync( + "cargo", + [ + "build", + "--manifest-path", + join(root, "visualization-wasm/Cargo.toml"), + "--locked", + "--target", + "wasm32-unknown-unknown", + "--release", + ], + { + stdio: "inherit", + env: { + ...process.env, + CARGO_ENCODED_RUSTFLAGS: [ + ...(process.env.CARGO_ENCODED_RUSTFLAGS?.split("\x1f") || []), + `--remap-path-prefix=${process.env.HOME || root}=/build`, + ].join("\x1f"), + }, + }, + ); + if (result.status !== 0) throw Error("WASM compilation failed"); + mkdirSync(out, { recursive: true }); + const escape = (s) => + String(s).replace( + /[&<>"']/g, + (c) => + ({ + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + })[c], + ); + const categories = [...new Set(inventory.entries.map((e) => e.category))]; + const catalog = inventory.entries + .map( + (e) => + `${String(e.index).padStart(3, "0")}${escape(e.title)}`, + ) + .join("\n"); + const html = readFileSync(join(src, "index.html"), "utf8") + .replace( + "{{CATEGORY_OPTIONS}}", + categories + .map( + (c) => + ``, + ) + .join(""), + ) + .replace("{{CATALOG}}", catalog); + writeFileSync(join(out, "index.html"), html); + for (const f of ["lab.css", "inventory.json"]) + cpSync(join(src, f), join(out, f)); + cpSync( + join( + root, + "visualization-wasm/target/wasm32-unknown-unknown/release/cerebral_visualization_kernels.wasm", + ), + join(out, "kernels.wasm"), + ); + const terrain = Array.from({ length: 64 * 64 }, (_, i) => { + const x = ((i % 64) - 32) / 64, + y = (Math.floor(i / 64) - 32) / 64; + return Math.round( + 20 + + 180 * Math.exp(-(x * x + y * y) * 12) + + 20 * Math.sin(x * 24) * Math.cos(y * 18), + ); + }); + const raster = await writeArrayBuffer(terrain, { + width: 64, + height: 64, + BitsPerSample: [8], + SampleFormat: [1], + GeographicTypeGeoKey: 4326, + ModelPixelScale: [0.01, 0.01, 0], + ModelTiepoint: [0, 0, 0, 11, 46, 0], + }); + writeFileSync(join(out, "terrain.tiff"), new Uint8Array(raster)); + const bundle = await build({ + entryPoints: [join(src, "lab.js")], + bundle: true, + format: "esm", + target: ["es2022"], + minify: true, + outfile: join(out, "lab.js"), + legalComments: "eof", + metafile: true, + }); + const packages = [ + ...new Set( + Object.keys(bundle.metafile.inputs).flatMap((file) => { + const match = file.match(/node_modules\/((?:@[^/]+\/)?[^/]+)/); + return match ? [match[1]] : []; + }), + ), + ].sort(); + let notice = + "Cerebral visualization lab\n\n174 original implementations of concepts indexed in the D3 gallery.\nSource inventory: https://observablehq.com/@d3/gallery @1120\nAuthor attribution and original notebook links: inventory.json\nGallery metadata: Copyright Mike Bostock / Observable; ISC.\nNo source notebook body or historical dataset is redistributed.\nDemo values are synthetic, generated by local Rust/WASM kernels.\nNatural Earth geographic source data is public domain; atlas packaging notices follow.\n\n"; + for (const name of packages) { + const base = join(root, "node_modules", name); + let license = ""; + for (const f of [ + "LICENSE", + "LICENSE.md", + "LICENSE.txt", + "license", + "license.md", + "LICENSE-MIT", + "COPYING", + ]) { + try { + license = readFileSync(join(base, f), "utf8"); + break; + } catch {} + } + if (!license && name === "lerc") + license = + "Copyright 2015–2021 Esri\n" + + readFileSync(join(root, "third-party/LICENSE-LERC.txt"), "utf8"); + if (!license) throw Error(`Missing bundled license: ${name}`); + notice += `\n--- ${name} ---\n${license}\n`; + } + writeFileSync(join(out, "NOTICE.txt"), notice); + console.log( + "Built visualization lab: 174 entries, Three.js bundle, compiled WASM, source inventory and attribution", + ); +} +if (process.argv[1] === fileURLToPath(import.meta.url)) await buildGallery(); diff --git a/scripts/gallery-contract.mjs b/scripts/gallery-contract.mjs new file mode 100644 index 0000000..b168e98 --- /dev/null +++ b/scripts/gallery-contract.mjs @@ -0,0 +1,52 @@ +import { adapterNames } from "../cerebral-src/visualizations/registry.mjs"; +const interactions = new Set([ + "inspect", + "zoom", + "pan", + "drill", + "sort", + "scale", + "rotate", + "sequence", + "brush", + "projection", + "refine", + "index", + "tooltip", + "drag", +]); +export function validateInventory(data) { + if ( + data.revision !== 1120 || + data.sourceSha256 !== + "e9b19333c720b5cf3eebc6dc682a124a052c449627ac7b0861e763d95b8ac3e0" + ) + throw Error("Unknown gallery snapshot"); + if ( + data.entries.length !== 174 || + new Set(data.entries.map((e) => e.id)).size !== 174 + ) + throw Error("Coverage must contain 174 unique examples"); + if (new Set(data.entries.map((e) => e.category)).size !== 14) + throw Error("Category coverage changed"); + data.entries.forEach((e, i) => { + if ( + e.index !== i + 1 || + !e.title || + !e.author || + !/^https:\/\/observablehq\.com\/@[a-z0-9-]+\/[a-z0-9-]+(?:\/\d+)?$/.test( + e.source, + ) + ) + throw Error(`Invalid source attribution at ${i}`); + if (!adapterNames.has(e.adapter)) + throw Error(`Unsupported adapter: ${e.adapter}`); + if ( + !interactions.has(e.interaction) || + typeof e.animated !== "boolean" || + e.data !== "deterministic-demo" + ) + throw Error(`Invalid behavior metadata: ${e.id}`); + }); + return true; +} diff --git a/scripts/validate-cerebral-bench.mjs b/scripts/validate-cerebral-bench.mjs new file mode 100644 index 0000000..b00fe5a --- /dev/null +++ b/scripts/validate-cerebral-bench.mjs @@ -0,0 +1,3 @@ +import {loadData} from './bench-data.mjs'; +const {data}=loadData(new URL('../cerebral-src/data/',import.meta.url).pathname); +console.log(`Cerebral evidence valid: ${data.systems.length} systems, ${data.measurements.length} numeric records, ${data.artifacts.length} hashed artifacts`); diff --git a/specs/0001-cerebral-bench.md b/specs/0001-cerebral-bench.md new file mode 100644 index 0000000..83c15d7 --- /dev/null +++ b/specs/0001-cerebral-bench.md @@ -0,0 +1,23 @@ +# 0001 — Cerebral benchmark observatory + +Status: implementation + +## Intent + +Implement bench.cerebral.work as a separate static Worker asset tree in the existing benchmark repository, using the observed Cerebral V2 website design. The unsigned model-bank asset tree and its deployment retain their existing scope. + +## Requirements + +- REQ-0001-01: The site shall cover Scorcher transport/CAS, Cortex's reference benchmark protocol, and Saga scheduler/evaluation evidence. +- REQ-0001-02: Every numeric result shall retain its evidence type, unit, sample context, source record and capture date; unavailable results shall remain absent. +- REQ-0001-03: Local microbenchmark measurements, virtual-clock simulations and fixture validation shall have distinct labels and shall not be combined into a universal score. +- REQ-0001-04: The initial page shall render its results without JavaScript; JavaScript shall add system/search/evidence filters, percentile and plan selectors, shareable query state, and a persistent accessible theme control. +- REQ-0001-05: The site shall support mobile and desktop, visible keyboard focus, skip navigation, readable themes and reduced motion. +- REQ-0001-06: Public artifacts shall exclude machine names, personal paths, internal endpoints, credentials, raw agent transcripts and proprietary source bodies. +- REQ-0001-07: Build, data-integrity and Worker dry-run checks shall run before publication; the production hostname shall remain an operator-approved deployment step. + +## Evidence boundary + +Scorcher: one local release-binary run, 10,000 routing iterations; sub-benchmark samples scale independently. Executable SHA-256 identifies the measured binary. The inspected source revision is context and is not a build attestation. +Saga: a local debug-binary virtual-clock run on four checked-in fixtures; plan time units are not wall-clock latency. Two committed syn fixture validation records establish negative/gold controls, not model pass rates. +Cortex: reference protocol inspected; a separate numeric run is not attached. Scorcher's vendored lineage does not make its measurements a Cortex result. diff --git a/specs/0002-visualization-gallery.md b/specs/0002-visualization-gallery.md new file mode 100644 index 0000000..cf210e6 --- /dev/null +++ b/specs/0002-visualization-gallery.md @@ -0,0 +1,30 @@ +--- +status: draft +created: 2026-10-26 +scope: cerebral-src/visualizations, visualization-wasm, scripts/build-cerebral.mjs +--- + +# Visualization gallery + +## Intent + +Implement the 174 entries in the Observable D3 gallery snapshot @1120 (captured 2026-10-26) in bench.cerebral.work, using Three.js for rendering and WebAssembly for data processing. Preserve the benchmark observatory and its evidence boundaries. The featured-libraries collection (D3 gallery, Plot Gallery, Hello Inputs) informs the presentation and controls; this spec's complete coverage set is the 174 D3 entries requested by the operator. + +## Requirements + +- Each source entry has a stable local identifier, category, attribution URL and an explicit implementation adapter; unsupported adapters fail validation rather than using a generic default. +- Every adapter provides the source visualization's defining encoding/behavior, with deterministic local demonstration data labeled separately from measured benchmarks. +- Rendering uses Three.js geometry with an orthographic view and semantic HTML labels/data alternatives; no remote Observable embeds are required to run an example. +- A Rust-generated WebAssembly module performs deterministic sampling and numeric processing; runtime status describes whether WASM and WebGL actually initialized. +- Search, category selection and individual example state are deep-linkable. Keyboard and touch users can select examples, inspect data and operate interactions. +- Animation honors reduced motion, can pause and scrub; animation does not run while the document is hidden. Resize and theme changes update the visualization, with old GPU resources disposed. +- Build/CI validates all 174 adapters and compiles WASM, without deploying. Browser checks exercise every example and the important interactive states. +- Original benchmark records and attribution remain intact; demonstration values are never presented as measured performance. + +## Implementation + +Add a static `/visualizations/` consumer built with the existing Cerebral site. Keep a pinned source inventory and metadata coverage manifest. Use reusable encoding/layout primitives, with per-example parameters and interactions, rather than copied remote notebook execution. D3's math/layout functions may supply complex hierarchies and geographic projections; Three.js owns graphics. Bundle pinned dependencies locally and ship the compiled WASM with source and reproducible build commands. + +## Validation + +Verify Rust numeric kernels with negative/edge controls, schema/adapter coverage, stable geometry output and every example in a real browser. Check no empty canvases, runtime exceptions, horizontal overflow or accessibility violations in the UI. Exercise filtering, deep links, animation controls, brushing, zooming, dragging and renderer/WASM failure states. Record source/data licenses and remaining limitations honestly. diff --git a/tests/cerebral-bench.test.mjs b/tests/cerebral-bench.test.mjs new file mode 100644 index 0000000..0aa0a19 --- /dev/null +++ b/tests/cerebral-bench.test.mjs @@ -0,0 +1,20 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {readFileSync} from 'node:fs'; +import {loadData,validateData,digest} from '../scripts/bench-data.mjs'; +const root=new URL('../cerebral-src/data/',import.meta.url).pathname; +function fixture(){const {data,records}=loadData(root);return {data:structuredClone(data),records:{...records}}} +function editRecord(f,name,edit){const d=JSON.parse(f.records[name]);edit(d);f.records[name]=Buffer.from(JSON.stringify(d));f.data.artifacts.find(a=>a.file===name).sha256=digest(f.records[name])} +test('published snapshot validates against every evidence record',()=>{const f=fixture();assert.doesNotThrow(()=>validateData(f.data,f.records));assert.equal(f.data.measurements.length,16)}); +test('a modified evidence file cannot retain its old digest',()=>{const f=fixture();f.records['scorcher-local.json']=Buffer.from('{}');assert.throws(()=>validateData(f.data,f.records),/digest mismatch/)}); +test('a displayed result must match its source pointer',()=>{const f=fixture();f.data.measurements[0].value+=1;assert.throws(()=>validateData(f.data,f.records),/differs from receipt/)}); +test('measured timings require a sample denominator',()=>{const f=fixture();delete f.data.measurements[0].samples;assert.throws(()=>validateData(f.data,f.records),/denominator/)}); +test('simulation cannot be relabeled as a physical measurement',()=>{const f=fixture();f.data.measurements.find(m=>m.system==='saga').evidence='measured';assert.throws(()=>validateData(f.data,f.records),/evidence claim/)}); +test('virtual clock rows cannot be labeled milliseconds',()=>{const f=fixture();f.data.measurements.find(m=>m.system==='saga').unit='ms';assert.throws(()=>validateData(f.data,f.records),/Simulation differs/)}); +test('Cortex has no numeric score without a separate result adapter',()=>{const f=fixture();editRecord(f,'cortex-protocol.json',r=>{r.result={p50:100}});assert.throws(()=>validateData(f.data,f.records),/separate validated result/)}); +test('an ineffective negative control blocks publication',()=>{const f=fixture();editRecord(f,'saga-controls.json',r=>{r.controls[0].negativeControlPassed=true});assert.throws(()=>validateData(f.data,f.records),/negative\/reference controls/)}); +test('machine paths and internal addresses cannot enter public evidence',()=>{const f=fixture();f.data.measurements[0].note='/home/example/private';assert.throws(()=>validateData(f.data,f.records),/Private machine/)}); +test('the existing model-bank Worker keeps its hostname and asset tree',()=>{const text=readFileSync(new URL('../wrangler.jsonc',import.meta.url),'utf8');const config=JSON.parse(text);assert.equal(config.name,'unsigned-bench');assert.equal(config.assets.directory,'./public');assert.equal(config.routes[0].pattern,'bench.unsigned.gg')}); + +test('timing unit changes cannot inflate a measured result',()=>{const f=fixture();f.data.measurements[0].unit='µs';assert.throws(()=>validateData(f.data,f.records),/Measured unit/)}); +test('a displayed sample denominator must match the receipt',()=>{const f=fixture();f.data.measurements[0].samples=100000;assert.throws(()=>validateData(f.data,f.records),/Sample denominator differs/)}); diff --git a/tests/cerebral-gallery.test.mjs b/tests/cerebral-gallery.test.mjs new file mode 100644 index 0000000..0077be2 --- /dev/null +++ b/tests/cerebral-gallery.test.mjs @@ -0,0 +1,128 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { fromArrayBuffer } from "geotiff"; +import { validateInventory } from "../scripts/gallery-contract.mjs"; +const inventory = JSON.parse( + readFileSync( + new URL("../cerebral-src/visualizations/inventory.json", import.meta.url), + "utf8", + ), +); +const binary = readFileSync( + new URL("../cerebral/visualizations/kernels.wasm", import.meta.url), +); +function kernels() { + return new WebAssembly.Instance(new WebAssembly.Module(binary)).exports; +} +const input = (e) => + new Float64Array(e.memory.buffer, e.input_ptr(), e.capacity()); +const output = (e, n) => + Array.from(new Float64Array(e.memory.buffer, e.output_ptr(), n)); +test("the pinned source has complete, attributed, supported coverage", () => + assert.equal(validateInventory(inventory), true)); +test("unknown adapters cannot silently use a generic fallback", () => { + const data = structuredClone(inventory); + data.entries[0].adapter = "made-up"; + assert.throws(() => validateInventory(data), /Unsupported adapter/); +}); +test("missing or duplicated entries and source drift fail closed", () => { + for (const mutate of [ + (d) => d.entries.pop(), + (d) => (d.entries[1].id = d.entries[0].id), + (d) => (d.sourceSha256 = "drift"), + (d) => (d.entries[0].source = "https://example.org/embed"), + ]) { + const d = structuredClone(inventory); + mutate(d); + assert.throws(() => validateInventory(d)); + } +}); +test("the browser artifact is actual deterministic WASM", () => { + assert.deepEqual(Array.from(binary.slice(0, 4)), [0, 97, 115, 109]); + const e = kernels(); + e.generate(42, 192, 0); + const first = output(e, 1152); + e.generate(42, 192, 0); + assert.deepEqual(output(e, 1152), first); + assert.ok(first.every(Number.isFinite)); + e.generate(43, 192, 0); + assert.notDeepEqual(output(e, 1152), first); +}); +test("histograms retain observations and reject invalid domains", () => { + const e = kernels(); + input(e).set([-1, 0, 1, 2, 3, 4, 5, 6, NaN]); + assert.equal(e.histogram(9, 3, 0, 6), 3); + assert.equal( + output(e, 3).reduce((a, b) => a + b), + 7, + ); + assert.equal(e.histogram(9, 3, 6, 0), 0); +}); +test("rolling means and interpolated quantiles preserve numeric meaning", () => { + const e = kernels(); + input(e).set([1, 2, 3, 4]); + e.moving_average(4, 2); + assert.deepEqual(output(e, 4), [1, 1.5, 2.5, 3.5]); + e.quantiles(4); + assert.deepEqual(output(e, 5), [1, 1.75, 2.5, 3.25, 4]); + assert.equal(e.quantiles(0), 0); +}); +test("nearest-point selection and empty controls use the real kernel", () => { + const e = kernels(); + input(e).set([1, 2, 8, 9, 12, 4]); + assert.equal(e.nearest(3, 8, 8), 1); + assert.equal(e.nearest(0, 0, 0), -1); + assert.equal(e.nearest(3, NaN, 0), -1); +}); +test("density is finite and integrates close to one on a broad grid", () => { + const e = kernels(); + input(e).set([49, 50, 51]); + assert.equal(e.kde(3, 3, 0, 100), 128); + const pairs = output(e, 256); + const integral = + (pairs.filter((_, i) => i % 2 === 1).reduce((a, b) => a + b, 0) * 100) / + 127; + assert.ok(Math.abs(integral - 1) < 0.02); + assert.equal(e.kde(3, 0, 0, 100), 0); +}); +test("the local geographic raster really decodes as EPSG:4326 GeoTIFF", async () => { + const bytes = readFileSync( + new URL("../cerebral/visualizations/terrain.tiff", import.meta.url), + ); + const file = await fromArrayBuffer( + bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength), + ); + const image = await file.getImage(); + assert.equal(image.getWidth(), 64); + assert.equal(image.getHeight(), 64); + assert.equal(image.getGeoKeys().GeographicTypeGeoKey, 4326); + const values = await image.readRasters({ interleave: true }); + assert.equal(values.length, 4096); + assert.ok(new Set(values).size > 50); +}); +test("the static catalog and locally bundled runtime require no Observable embed", () => { + const html = readFileSync( + new URL("../cerebral/visualizations/index.html", import.meta.url), + "utf8", + ); + assert.equal((html.match(/data-example=/g) || []).length, 174); + assert.ok(!html.includes(" { + const e = kernels(); + input(e).set([1, 2, 3, 4]); + e.rolling_bands(4, 2); + assert.deepEqual(output(e, 8), [1, 0, 1.5, 0.5, 2.5, 0.5, 3.5, 0.5]); +}); + +test("published WASM remaps personal compiler source paths", () => { + assert.ok(binary.includes(Buffer.from("memory"))); + assert.ok(!/\/(?:home|Users)\//.test(binary.toString("latin1"))); +}); diff --git a/tests/gallery-browser.mjs b/tests/gallery-browser.mjs new file mode 100644 index 0000000..afba8a8 --- /dev/null +++ b/tests/gallery-browser.mjs @@ -0,0 +1,331 @@ +import { chromium } from "playwright"; +import AxeBuilder from "@axe-core/playwright"; +import assert from "node:assert/strict"; +import { createServer } from "node:http"; +import { readFile, stat, mkdir, writeFile } from "node:fs/promises"; +import { resolve, extname } from "node:path"; +const root = resolve("cerebral"), + inventory = JSON.parse( + await readFile("cerebral-src/visualizations/inventory.json", "utf8"), + ); +const mime = { + ".html": "text/html", + ".js": "text/javascript", + ".css": "text/css", + ".json": "application/json", + ".wasm": "application/wasm", + ".svg": "image/svg+xml", + ".tiff": "image/tiff", +}; +const server = createServer(async (req, res) => { + try { + const url = new URL(req.url, "http://local"); + let file = resolve(root, "." + decodeURIComponent(url.pathname)); + if (!file.startsWith(root + "/") && file !== root) throw Error("path"); + if ((await stat(file)).isDirectory()) file = resolve(file, "index.html"); + res.setHeader("Content-Type", mime[extname(file)] || "text/plain"); + res.end(await readFile(file)); + } catch { + res.statusCode = 404; + res.end("Not found"); + } +}); +await new Promise((r) => server.listen(0, "127.0.0.1", r)); +const base = `http://127.0.0.1:${server.address().port}`; +await mkdir("test-results/gallery", { recursive: true }); +const browser = await chromium.launch({ + executablePath: process.env.CHROME_PATH || undefined, + headless: true, + args: [ + "--no-sandbox", + "--enable-unsafe-swiftshader", + "--use-angle=swiftshader", + ], +}); +const checks = [], + errors = []; +try { + const context = await browser.newContext({ + viewport: { width: 1440, height: 1000 }, + reducedMotion: "reduce", + }); + const page = await context.newPage(); + page.on("pageerror", (e) => errors.push(e.message)); + const select = async (id) => { + await page + .locator(`#catalog-list a[data-example="${id}"]`) + .evaluate((a) => a.click()); + await page.waitForFunction( + (id) => + document.querySelector("#chart").dataset.example === id || + !!document.querySelector("#chart").dataset.error, + id, + ); + assert.equal( + await page.locator("#chart").getAttribute("data-error"), + null, + id, + ); + }; + await page.goto(base + "/visualizations/", { waitUntil: "networkidle" }); + await page.waitForFunction( + () => document.querySelector("#chart").dataset.example, + ); + assert.match(await page.locator(".runtime").innerText(), /WASM \/ ready/); + assert.match(await page.locator(".runtime").innerText(), /WebGL ready/); + for (const item of inventory.entries) { + await select(item.id); + const geometry = await page.locator("#chart").evaluate((canvas) => { + const scratch = document.createElement("canvas"); + scratch.width = 128; + scratch.height = 80; + const context = scratch.getContext("2d"); + context.drawImage(canvas, 0, 0, 128, 80); + const pixels = context.getImageData(0, 0, 128, 80).data; + const background = [pixels[0], pixels[1], pixels[2]]; + let changed = 0; + for (let i = 0; i < pixels.length; i += 4) + if ( + Math.abs(pixels[i] - background[0]) + + Math.abs(pixels[i + 1] - background[1]) + + Math.abs(pixels[i + 2] - background[2]) > + 18 + ) + changed++; + return { + marks: Number(canvas.dataset.marks), + vertices: Number(canvas.dataset.vertices), + changed, + }; + }); + assert.ok( + geometry.marks > 0 && geometry.vertices > 0 && geometry.changed > 8, + `${item.title}: empty render ${JSON.stringify(geometry)}`, + ); + checks.push({ id: item.id, ...geometry }); + } + console.log("174 examples: finite GPU geometry and nonempty pixels"); + for (const width of [1440, 768, 390, 320]) { + await page.setViewportSize({ width, height: 1000 }); + for (const theme of ["light", "dark"]) { + if ((await page.locator("html").getAttribute("data-theme")) !== theme) + await page.locator("#lab-theme").click(); + const result = await new AxeBuilder({ page }) + .withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"]) + .analyze(); + assert.deepEqual( + result.violations, + [], + `${width} ${theme} accessibility`, + ); + assert.equal( + await page.evaluate( + () => document.documentElement.scrollWidth > innerWidth, + ), + false, + `${width} overflow`, + ); + } + } + console.log( + "Responsive light/dark accessibility: zero violations and no overflow", + ); + await page.setViewportSize({ width: 1440, height: 1000 }); + await page.getByLabel("Find a visualization").fill("treemap"); + assert.match(await page.locator("#catalog-status").innerText(), /5 of 174/); + await page.getByLabel("Find a visualization").fill("zznonesuch"); + assert.match(await page.locator("#catalog-status").innerText(), /0 of 174/); + await page.getByLabel("Find a visualization").fill(""); + await page.getByLabel("Category", { exact: true }).selectOption("maps"); + assert.match(await page.locator("#catalog-status").innerText(), /22 of 174/); + await page.getByLabel("Category", { exact: true }).selectOption("all"); + await select("d3-zoomable-treemap"); + const before = await page.locator("#chart").getAttribute("data-vertices"); + await page.locator("#action").click(); + assert.notEqual( + await page.locator("#chart").getAttribute("data-vertices"), + before, + ); + await page.locator("#reset").click(); + assert.equal( + await page.locator("#chart").getAttribute("data-vertices"), + before, + ); + await select("d3-brushable-scatterplot"); + const box = await page.locator("#chart").boundingBox(); + await page.mouse.move(box.x + 50, box.y + 50); + await page.mouse.down(); + await page.mouse.move(box.x + box.width * 0.75, box.y + box.height * 0.8); + await page.mouse.up(); + assert.match( + await page.locator("#selection-status").innerText(), + /marks selected/, + ); + await page.locator("#chart").focus(); + await page.keyboard.press("ArrowRight"); + assert.ok((await page.locator("#chart-tooltip").innerText()).length > 0); + await select("d3-zoomable-bar-chart"); + const initial = await page.locator("#chart-labels").innerHTML(); + await page.getByRole("button", { name: "Zoom in", exact: true }).click(); + assert.notEqual(await page.locator("#chart-labels").innerHTML(), initial); + await page.getByRole("button", { name: "Reset view", exact: true }).click(); + await select("mbostock-owls-to-the-max"); + const coarse = await page.locator("#chart").getAttribute("data-marks"); + await page.locator("#action").click(); + assert.ok( + Number(await page.locator("#chart").getAttribute("data-marks")) > + Number(coarse), + ); + await select("d3-new-zealand-tourists-1921-2018"); + const linear = await page.locator("#chart").getAttribute("data-vertices"); + await page.locator("#action").click(); + assert.ok(Number(linear) > 0); + await select("d3-versor-dragging"); + let imageBefore = await page.locator("#chart").evaluate((c) => c.toDataURL()); + let bounds = await page.locator("#chart").boundingBox(); + await page.mouse.move( + bounds.x + bounds.width * 0.5, + bounds.y + bounds.height * 0.5, + ); + await page.mouse.down(); + await page.mouse.move( + bounds.x + bounds.width * 0.6, + bounds.y + bounds.height * 0.65, + ); + await page.mouse.up(); + assert.notEqual( + await page.locator("#chart").evaluate((c) => c.toDataURL()), + imageBefore, + "Quaternion dragging rotates the globe", + ); + await select("d3-zoom-to-bounding-box"); + imageBefore = await page.locator("#chart").evaluate((c) => c.toDataURL()); + bounds = await page.locator("#chart").boundingBox(); + await page.mouse.click( + bounds.x + bounds.width * 0.5, + bounds.y + bounds.height * 0.5, + ); + assert.notEqual( + await page.locator("#chart").evaluate((c) => c.toDataURL()), + imageBefore, + "Country bounding-box selection changes view", + ); + await select("d3-stacked-to-grouped-bars"); + await page.locator("#frame").fill("25"); + const quarter = await page.locator("#chart").evaluate((c) => c.toDataURL()); + await page.locator("#frame").fill("75"); + assert.notEqual( + await page.locator("#chart").evaluate((c) => c.toDataURL()), + quarter, + "Stacked/grouped positions interpolate", + ); + assert.match(page.url(), /frame=75/); + await page.reload({ waitUntil: "networkidle" }); + assert.equal(await page.locator("#frame").inputValue(), "75"); + await select("d3-bar-chart-2"); + await page.locator("#chart").focus(); + await page.keyboard.press("ArrowRight"); + const tooltipValue = Number( + (await page.locator("#chart-tooltip").innerText()).split(":").at(-1), + ); + const tableValue = Number( + await page + .locator("#data-body tr") + .first() + .locator("td") + .nth(2) + .textContent(), + ); + assert.ok( + Math.abs(tooltipValue - tableValue) < 0.001, + "Bar heights preserve the input quantity", + ); + + await page.reload({ waitUntil: "networkidle" }); + assert.equal(await page.locator("#example-title").innerText(), "Bar chart"); + assert.equal(await page.locator("#play").isDisabled(), true); + await page.goto(base + "/visualizations/", { waitUntil: "networkidle" }); + await page.keyboard.press("Tab"); + assert.equal( + await page.locator(":focus").innerText(), + "Skip to visualization", + ); + await page.keyboard.press("Enter"); + assert.equal(await page.locator(":focus").getAttribute("id"), "lab-content"); + const download = page.waitForEvent("download"); + await page.locator("#download-data").click(); + assert.match((await download).suggestedFilename(), /demo\.csv$/); + await page.screenshot({ + path: "test-results/gallery/desktop.png", + fullPage: true, + }); + await page.setViewportSize({ width: 390, height: 844 }); + await page.screenshot({ + path: "test-results/gallery/mobile.png", + fullPage: true, + }); + const animated = await browser.newContext({ + viewport: { width: 1100, height: 900 }, + reducedMotion: "no-preference", + }); + const a = await animated.newPage(); + await a.goto(base + "/visualizations/?chart=d3-animated-treemap", { + waitUntil: "networkidle", + }); + await a.waitForFunction( + () => document.querySelector("#chart").dataset.example, + ); + const frame = await a.locator("#frame").inputValue(); + await a.locator("#play").click(); + await a.waitForFunction( + (frame) => document.querySelector("#frame").value !== frame, + frame, + ); + await a.locator("#play").click(); + assert.equal(await a.locator("#play").getAttribute("aria-pressed"), "false"); + await animated.close(); + const unavailable = await browser.newContext(); + const f = await unavailable.newPage(); + await f.route("**/kernels.wasm", (route) => route.abort()); + await f.goto(base + "/visualizations/", { waitUntil: "networkidle" }); + await f.locator("#renderer-error").waitFor({ state: "visible" }); + assert.match(await f.locator("#wasm-status").innerText(), /unavailable/); + assert.equal(await f.locator("#catalog-list a").count(), 174); + await unavailable.close(); + const noGL = await browser.newContext(); + await noGL.addInitScript(() => { + const original = HTMLCanvasElement.prototype.getContext; + HTMLCanvasElement.prototype.getContext = function (type, ...args) { + if ( + type === "webgl" || + type === "webgl2" || + type === "experimental-webgl" + ) + return null; + return original.call(this, type, ...args); + }; + }); + const g = await noGL.newPage(); + await g.goto(base + "/visualizations/", { waitUntil: "networkidle" }); + await g.locator("#renderer-error").waitFor({ state: "visible" }); + assert.match(await g.locator("#webgl-status").innerText(), /unavailable/); + assert.equal(await g.locator("#catalog-list a").count(), 174); + await noGL.close(); + const nojs = await browser.newContext({ javaScriptEnabled: false }); + const n = await nojs.newPage(); + await n.goto(base + "/visualizations/"); + assert.equal(await n.locator("#catalog-list a").count(), 174); + assert.match(await n.locator("noscript").innerText(), /JavaScript/); + await nojs.close(); + assert.deepEqual(errors, []); + console.log( + "Search, filters, drill/reset, brush, keyboard inspection, zoom, refinement, links, CSV, motion and failure fallback pass", + ); + await writeFile( + "test-results/gallery/coverage.json", + JSON.stringify({ checks, errors }, null, 2), + ); +} finally { + await browser.close(); + await new Promise((r) => server.close(r)); +} diff --git a/third-party/LICENSE-LERC.txt b/third-party/LICENSE-LERC.txt new file mode 100644 index 0000000..863d150 --- /dev/null +++ b/third-party/LICENSE-LERC.txt @@ -0,0 +1,101 @@ +Apache License - 2.0 + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control +with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management +of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial +ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to +compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work +or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual +or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing +by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, +publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, +non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, +sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are +necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You +under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, +and in Source or Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices + from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a + readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the + Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the + Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever + such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. + You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, + provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to + Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your + modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You +to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, +nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except +as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides +its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, +any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for +determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under +this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required +by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, +including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the +use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a +fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting +such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree +to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/visualization-wasm/Cargo.lock b/visualization-wasm/Cargo.lock new file mode 100644 index 0000000..aec13cb --- /dev/null +++ b/visualization-wasm/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "cerebral-visualization-kernels" +version = "0.1.0" diff --git a/visualization-wasm/Cargo.toml b/visualization-wasm/Cargo.toml new file mode 100644 index 0000000..e9761af --- /dev/null +++ b/visualization-wasm/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "cerebral-visualization-kernels" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib", "rlib"] + +[profile.release] +opt-level = 3 +lto = true +panic = "abort" +strip = true diff --git a/visualization-wasm/src/lib.rs b/visualization-wasm/src/lib.rs new file mode 100644 index 0000000..81b6c5d --- /dev/null +++ b/visualization-wasm/src/lib.rs @@ -0,0 +1,287 @@ +//! Local demonstration-data kernels. No network, I/O, clocks or benchmark claims. +use std::ptr::{addr_of, addr_of_mut}; +const CAP: usize = 32768; +static mut INPUT: [f64; CAP] = [0.0; CAP]; +static mut OUTPUT: [f64; CAP] = [0.0; CAP]; +#[no_mangle] +pub extern "C" fn input_ptr() -> *mut f64 { + addr_of_mut!(INPUT).cast() +} +#[no_mangle] +pub extern "C" fn output_ptr() -> *const f64 { + addr_of!(OUTPUT).cast() +} +#[no_mangle] +pub extern "C" fn capacity() -> usize { + CAP +} +fn random(state: &mut u32) -> f64 { + *state = state.wrapping_mul(1664525).wrapping_add(1013904223); + (*state as f64) / (u32::MAX as f64) +} + +/// Six columns: x, value, comparison, group, angle, weight. Stable by seed/frame. +#[no_mangle] +pub extern "C" fn generate(seed: u32, n: usize, phase: f64) -> usize { + let n = n.min(CAP / 6); + let mut rng = seed.max(1); + let phase = if phase.is_finite() { phase } else { 0.0 }; + for i in 0..n { + let x = i as f64 / n.max(1) as f64; + let a = random(&mut rng); + let b = random(&mut rng); + let y = 40.0 + 22.0 * (x * 13.0 + phase).sin() + 15.0 * a + x * 30.0; + unsafe { + OUTPUT[i * 6] = x; + OUTPUT[i * 6 + 1] = y; + OUTPUT[i * 6 + 2] = 42.0 + 18.0 * (x * 10.0 - phase * 0.7).cos() + b * 18.0; + OUTPUT[i * 6 + 3] = (i % 6) as f64; + OUTPUT[i * 6 + 4] = a * std::f64::consts::TAU; + OUTPUT[i * 6 + 5] = 2.0 + b * 18.0; + } + } + n +} +#[no_mangle] +pub extern "C" fn moving_average(n: usize, window: usize) -> usize { + let n = n.min(CAP); + let window = window.clamp(1, CAP); + let mut sum = 0.0; + for i in 0..n { + unsafe { + sum += INPUT[i]; + if i >= window { + sum -= INPUT[i - window]; + } + OUTPUT[i] = sum / (i + 1).min(window) as f64; + } + } + n +} +/// Rolling population mean and standard deviation, interleaved. +#[no_mangle] +pub extern "C" fn rolling_bands(n: usize, window: usize) -> usize { + let n = n.min(CAP / 2); + let window = window.clamp(1, CAP); + let (mut sum, mut squares) = (0.0, 0.0); + for i in 0..n { + unsafe { + sum += INPUT[i]; + squares += INPUT[i] * INPUT[i]; + if i >= window { + sum -= INPUT[i - window]; + squares -= INPUT[i - window] * INPUT[i - window]; + } + let count = (i + 1).min(window) as f64; + let mean = sum / count; + OUTPUT[i * 2] = mean; + OUTPUT[i * 2 + 1] = (squares / count - mean * mean).max(0.0).sqrt(); + } + } + n +} +#[no_mangle] +pub extern "C" fn histogram(n: usize, bins: usize, min: f64, max: f64) -> usize { + let bins = bins.clamp(1, 512); + unsafe { + for i in 0..bins { + OUTPUT[i] = 0.0; + } + } + if !min.is_finite() || !max.is_finite() || max <= min { + return 0; + } + for i in 0..n.min(CAP) { + let v = unsafe { INPUT[i] }; + if v.is_finite() && v >= min && v <= max { + let b = (((v - min) / (max - min) * bins as f64) as usize).min(bins - 1); + unsafe { + OUTPUT[b] += 1.0; + } + } + } + bins +} +#[no_mangle] +pub extern "C" fn kde(n: usize, bandwidth: f64, min: f64, max: f64) -> usize { + let n = n.min(CAP); + if n == 0 + || bandwidth <= 0.0 + || !bandwidth.is_finite() + || !min.is_finite() + || !max.is_finite() + || max <= min + { + return 0; + } + for i in 0..128 { + let x = min + (max - min) * i as f64 / 127.0; + let mut density = 0.0; + for j in 0..n { + let v = unsafe { INPUT[j] }; + if v.is_finite() { + let u = (x - v) / bandwidth; + density += (-0.5 * u * u).exp(); + } + } + unsafe { + OUTPUT[i * 2] = x; + OUTPUT[i * 2 + 1] = + density / (n as f64 * bandwidth * (2.0 * std::f64::consts::PI).sqrt()); + } + } + 128 +} +#[no_mangle] +pub extern "C" fn quantiles(n: usize) -> usize { + let mut values: Vec = (0..n.min(CAP)) + .map(|i| unsafe { INPUT[i] }) + .filter(|v| v.is_finite()) + .collect(); + if values.is_empty() { + return 0; + } + values.sort_by(f64::total_cmp); + for (i, q) in [0.0, 0.25, 0.5, 0.75, 1.0].iter().enumerate() { + let p = q * (values.len() - 1) as f64; + let lo = p.floor() as usize; + let hi = p.ceil() as usize; + unsafe { + OUTPUT[i] = values[lo] + (values[hi] - values[lo]) * (p - lo as f64); + } + } + 5 +} +/// Positions followed by edge index pairs. One bounded repulsion/spring step. +#[no_mangle] +pub extern "C" fn force_step(n: usize, links: usize, step: f64) -> usize { + let n = n.min(256); + let links = links.min((CAP - n * 2) / 2); + let step = if step.is_finite() { + step.clamp(0.0, 0.1) + } else { + 0.0 + }; + for i in 0..n { + let x = unsafe { INPUT[2 * i] }; + let y = unsafe { INPUT[2 * i + 1] }; + let mut fx = (0.5 - x) * 0.12; + let mut fy = (0.5 - y) * 0.12; + for j in 0..n { + if i != j { + let dx = x - unsafe { INPUT[2 * j] }; + let dy = y - unsafe { INPUT[2 * j + 1] }; + let d = (dx * dx + dy * dy).max(0.0005); + fx += dx * 0.0003 / d; + fy += dy * 0.0003 / d; + } + } + for e in 0..links { + let a = unsafe { INPUT[2 * n + e * 2] } as usize; + let b = unsafe { INPUT[2 * n + e * 2 + 1] } as usize; + if a >= n || b >= n { + continue; + } + let j = if a == i { + b + } else if b == i { + a + } else { + continue; + }; + let dx = unsafe { INPUT[2 * j] } - x; + let dy = unsafe { INPUT[2 * j + 1] } - y; + let d = (dx * dx + dy * dy).sqrt().max(0.001); + let f = (d - 0.13) * 1.1; + fx += dx / d * f; + fy += dy / d * f; + } + unsafe { + OUTPUT[2 * i] = (x + fx * step).clamp(0.02, 0.98); + OUTPUT[2 * i + 1] = (y + fy * step).clamp(0.02, 0.98); + } + } + n +} +#[no_mangle] +pub extern "C" fn nearest(n: usize, x: f64, y: f64) -> i32 { + if !x.is_finite() || !y.is_finite() { + return -1; + } + let mut best = -1; + let mut dist = f64::INFINITY; + for i in 0..n.min(CAP / 2) { + let dx = unsafe { INPUT[i * 2] } - x; + let dy = unsafe { INPUT[i * 2 + 1] } - y; + let d = dx * dx + dy * dy; + if d < dist { + dist = d; + best = i as i32; + } + } + best +} +#[no_mangle] +pub extern "C" fn predator_prey(n: usize, dt: f64) -> usize { + let n = n.min(CAP / 3); + let dt = if dt.is_finite() { + dt.clamp(0.001, 0.05) + } else { + 0.01 + }; + let (mut prey, mut predator) = (1.2, 0.8); + for i in 0..n { + unsafe { + OUTPUT[3 * i] = i as f64 * dt; + OUTPUT[3 * i + 1] = prey; + OUTPUT[3 * i + 2] = predator; + } + let dx = prey * (1.2 - predator); + let dy = predator * (prey - 1.0); + prey = (prey + dt * dx).max(0.0); + predator = (predator + dt * dy).max(0.0); + } + n +} +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn deterministic_and_bounded() { + assert_eq!(generate(42, 100, 0.0), 100); + let a = unsafe { OUTPUT[43] }; + generate(42, 100, 0.0); + assert_eq!(unsafe { OUTPUT[43] }, a); + assert_eq!(generate(1, usize::MAX, f64::NAN), CAP / 6); + } + #[test] + fn statistics_and_controls() { + unsafe { + INPUT[..5].copy_from_slice(&[1.0, 2.0, 3.0, 4.0, 5.0]); + } + moving_average(5, 2); + assert_eq!(unsafe { OUTPUT[4] }, 4.5); + quantiles(5); + assert_eq!(unsafe { OUTPUT[2] }, 3.0); + histogram(5, 2, 1.0, 5.0); + assert_eq!(unsafe { OUTPUT[0] + OUTPUT[1] }, 5.0); + assert_eq!(histogram(5, 2, 5.0, 1.0), 0); + assert_eq!(kde(5, 0.0, 0.0, 1.0), 0); + assert_eq!(quantiles(0), 0); + assert_eq!(nearest(0, 0.0, 0.0), -1); + } + #[test] + fn simulation_is_finite() { + predator_prey(4096, 0.02); + for i in 0..4096 * 3 { + assert!(unsafe { OUTPUT[i] }.is_finite()); + } + unsafe { + INPUT[..8].copy_from_slice(&[0.3, 0.4, 0.5, 0.7, 0.0, 1.0, 99.0, 0.0]); + } + force_step(2, 2, 0.02); + for i in 0..4 { + assert!((0.0..=1.0).contains(&unsafe { OUTPUT[i] })); + } + } +} diff --git a/wrangler.cerebral.jsonc b/wrangler.cerebral.jsonc new file mode 100644 index 0000000..cc8bed0 --- /dev/null +++ b/wrangler.cerebral.jsonc @@ -0,0 +1,16 @@ +{ + "$schema": "./node_modules/wrangler/config-schema.json", + "name": "cerebral-bench", + "account_id": "07ae57cca8fc1a438f9c9b875d1e2283", + "compatibility_date": "2026-06-20", + "workers_dev": false, + "preview_urls": false, + "assets": { + "directory": "./cerebral", + "html_handling": "auto-trailing-slash", + "not_found_handling": "404-page" + }, + "routes": [ + { "pattern": "bench.cerebral.work", "custom_domain": true } + ] +}