SOURCE / PINNED RELEASE
Made of little things.
Soybert 3D
- Release
- 4bf80e758af1…
- Author-recorded commit
- 298fa2d0e8b1…
- License
- LICENSE
- Author’s source reference
- nostr://npub1n8ga89w8h6tvwamxusfyzexw8gjy84yxu9rxgnmk955cxtml4ujswzxydd/wss%3A%2F%2Fgit.napplet.soy%2F/n-9021e1b6a96
Archive hash verified: 7083223a53bbd320…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
import { config } from '@napplet/sdk';
import { runtimeHasDomain } from './domain-availability.js';
import { DEFAULT_MOVE_SPEED } from './simulation.js';
import settingsSchema from '../config.schema.json';
export type Settings = { sound: boolean; reducedMotion: boolean; movementSpeed: number };
export function subscribeSettings(apply: (settings: Settings) => void): () => void {
let close: (() => void) | undefined;
let stopped = false;
if (runtimeHasDomain('config')) {
void (async () => {
if (!config.schema) await config.registerSchema(settingsSchema as Parameters<typeof config.registerSchema>[0]);
if (stopped) return;
const subscription = config.subscribe(values => apply({
sound: values.sound !== false,
reducedMotion: values.reducedMotion === true || matchMedia('(prefers-reduced-motion: reduce)').matches,
movementSpeed: typeof values.movementSpeed === 'number' ? Math.max(1, Math.min(10, values.movementSpeed)) : DEFAULT_MOVE_SPEED,
}));
close = () => subscription.close();
})().catch(() => { /* An optional host enhancement; keep local defaults. */ });
}
return () => { stopped = true; close?.(); };
}
