jevstrudel.git / website / src / pages / jev-samples / strudel.json.js

The sample map for the repo's samples/ folder (one folder per sound), built statically so songs can load it on any host with samples('jev-samples/strudel.json'). Vite bundles each file into _astro/; no-inline keeps small files as files, since Strudel prefixes every entry with _base and a data: URI cannot take a prefix. In the dev server the glob is live, so a sound added to samples/ plays after a reload.

The map itself is built by src/jev/sampleMap.mjs, which the headless tools use too. The extensions are its SAMPLE_EXTENSIONS, written out because a glob must be a literal; sampleMap.test.mjs checks that they agree.

11import { sampleMap } from '../../jev/sampleMap.mjs';
13const files = import.meta.glob('../../../../samples/*/*.{mp3,wav,ogg}', {
14  eager: true,
15  query: '?url&no-inline',
16  import: 'default',
17});
18
19export function GET() {
20  return new Response(JSON.stringify(sampleMap(Object.entries(files))), {
21    headers: { 'Content-Type': 'application/json' },
22  });
23}