SOURCE / PINNED RELEASE
Made of little things.
Funclet
- Release
- 0b497cfc2f66…
- Author-recorded commit
- 1e531b24f490…
- License
- LICENSE
- Author’s source reference
- nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-6b7a37cac1d
Archive hash verified: 71d97a89ed8c40c2…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
// Host fixtures for built-artifact browser tests; not live-service evidence.
export function fixture() {
const author = 'a'.repeat(64);
const makeStation = (identifier, name) => ({ id: identifier.padEnd(64, '0'), pubkey: author, kind: 31237, created_at: 10,
tags: [['d', identifier], ['name', name], ['location', 'Vienna'], ['country', 'AT'], ['c', 'jazz', 'genre']],
content: JSON.stringify({ description: 'A station fixture for interface testing.', streams: [{ url: `https://example.org/${identifier}.mp3`, format: 'mp3' }] }) });
const stations = [makeStation('1','Test Radio'), makeStation('2','Second Radio')];
const httpStation={...makeStation('4','HTTP Radio'),content:JSON.stringify({streams:[{url:'http://example.org:8000/live',format:'mp3',primary:true}]})};
const mixedStation={...makeStation('5','Mixed Radio'),content:JSON.stringify({streams:[{url:'http://example.org:8000/live',format:'mp3',primary:true},{url:'https://example.org/live.mp3',format:'mp3'}]})};
const favourite = { id: 'f'.repeat(64), pubkey: author, kind: 30078, created_at: 10,
tags: [['d','evening'], ['l','wavefunc_user_favourite_list'], ['a',`31237:${author}:1`]], content:'{"name":"Evening listening"}' };
let key = author; let identityChanged; let serial = 0;
const sessions = new Map();
window.__test = { calls: [], fail: false, failMetadata: false, partial: false, account(next) {key=next; identityChanged?.(next);}, omitOptional: false };
const savedVolume=new Map(Object.entries(window.__savedReceiver??{'receiver-volume':'0.6'}));
window.napplet = {
storage: {async getItem(key){return savedVolume.get(key)??null;},async setItem(key,value){savedVolume.set(key,value);window.__test.calls.push({type:'storage',key,value});}},
outbox: { async query(filters) {
window.__test.calls.push({type:'query', filters});
if(window.__test.fail) throw new Error('Fixture offline');
if(filters[0].search === 'slow') await new Promise(r=>setTimeout(r,200));
const events = filters[0].kinds[0] === 30078 ? (key ? [favourite] : []) : filters[0].search === 'http' ? [httpStation] : filters[0].search === 'mixed' ? [mixedStation] : filters[0].search ? [makeStation('3',filters[0].search)] : filters[0]['#d'] ? stations.filter(s=>filters.some(f=>f['#d'].includes(s.tags[0][1]))) : stations;
return {events:(window.__test.missingStations&&filters[0]['#d']?[]:events).map(event=>({event})),incomplete:window.__test.partial,...(window.__test.partial?{error:'OUTBOX_READ: another relay rejected search'}:{})};
} },
identity: { async getPublicKey(){return key;}, onChanged(cb){identityChanged=cb;return {close(){identityChanged=undefined;}};} },
link: {async open(url,options){window.__test.calls.push({type:'open',url,options});if(window.__test.linkError)throw new Error('Link unavailable');if(window.__test.deferLink)await new Promise(resolve=>{window.__test.finishLink=resolve;});return {status:window.__test.linkStatus||'opened'};}},
media: {
async createSession(options){const id=`canonical-${++serial}`;sessions.set(id,{options});window.__test.calls.push({type:'create',options,id});return {sessionId:id,owner:'shell'};},
onState(id,cb){sessions.get(id).state=cb;return {close(){}};},
onCapabilities(id,cb){setTimeout(()=>{if(sessions.has(id))cb(['play','pause','volume']);},0);return {close(){}};},
sendCommand(id,action,value){window.__test.calls.push({type:'command',id,action,value});const session=sessions.get(id);if(!session)return;if(action==='volume')session.volume=value;session.state?.({status:action==='pause'?'paused':'playing',volume:session.volume??.75});},
updateSession(id,metadata){window.__test.calls.push({type:'metadata',id,metadata});},
destroySession(id){sessions.delete(id);window.__test.calls.push({type:'destroy',id});}
},
cvm: { async callTool(server,name,args){window.__test.calls.push({type:'cvm',server,name,args});if(window.__test.failMetadata)throw new Error('Connection denied');return {structuredContent:{result:name==='extract_stream_metadata'?{song:'Fixture track',artist:'Fixture artist',source:'ICY'}:[{id:'music',name:args.query,country:'AT'}]}};},async close(){} }
};
}
