SOURCE / PINNED RELEASE
Made of little things.
Wizard Duel
- Release
- 48b4ed933a32…
- Author-recorded commit
- 3ed8fcbbf62c…
- License
- LICENSE
- Author’s source reference
- nostr://npub1ny7l44q0au5xkv3mjgt6zks5f0e2ydefslq4nhh2ve2xypgc2mqqat8qx2/wss%3A%2F%2Fgit.napplet.soy%2F/n-86005d75eb4
Archive hash verified: 4196bfb69e536a86…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
import { config } from '@napplet/sdk';
import settingsSchema from '../config.schema.json';
export type SettingsValues = Record<string, unknown>;
// The upstream Vite plugin embeds config.schema.json into the signed build.
// Config is optional: callers should only start this when the domain exists,
// and the game keeps its defaults if anything here fails.
export function startSettings(apply: (values: SettingsValues) => void): void {
void (async () => {
// Some hosts consume the embedded schema; others need standard registration.
// Do not replace a schema that the host already supplied.
if (!config.schema) {
await config.registerSchema(settingsSchema as Parameters<typeof config.registerSchema>[0]);
}
const subscription = config.subscribe((values) => apply(values as SettingsValues));
window.addEventListener('pagehide', () => subscription.close(), { once: true });
})().catch(() => {
// Optional operations may be unavailable even when a host exposes the domain.
});
}
