SOURCE / PINNED RELEASE
Made of little things.
Rail Game
- Release
- ccdd5b913413…
- Author-recorded commit
- ddf0122b6acc…
- License
- LICENSE
- Author’s source reference
- nostr://npub1n8ga89w8h6tvwamxusfyzexw8gjy84yxu9rxgnmk955cxtml4ujswzxydd/wss%3A%2F%2Fgit.napplet.soy%2F/n-91ec90c6fdf
Archive hash verified: dad7b678e25f96a3…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
import { config, type Subscription } from '@napplet/sdk';
import { runtimeHasDomain } from './domain-availability.js';
import settingsSchema from '../config.schema.json';
export interface GameSettings { soundEnabled: boolean; reducedMotion: boolean }
export function connectSettings(apply: (settings: GameSettings) => void): () => void {
let subscription: Subscription | undefined;
let closed = false;
if (runtimeHasDomain('config')) {
void (async () => {
if (!config.schema) await config.registerSchema(settingsSchema as Parameters<typeof config.registerSchema>[0]);
if (closed) return;
subscription = config.subscribe(values => apply({ soundEnabled: values.soundEnabled === true, reducedMotion: values.reducedMotion === true }));
})().catch(() => { /* Optional settings retain local defaults when denied. */ });
}
return () => { closed = true; subscription?.close(); };
}
