SOURCE / PINNED RELEASE
Made of little things.
winniegolf
- Release
- 017b791c0f4b…
- Author-recorded commit
- 612845c125fd…
- License
- LICENSE
- Author’s source reference
- nostr://npub18weq5jzw27gkhwcuf6gu57alcptjdvh78nlulgpkz8s7pnlxfnnspc00s9/wss%3A%2F%2Fgit.napplet.soy%2F/n-2d501957e21
Archive hash verified: 713b42364f27a576…. 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 { settings } from './game/settings.js';
import settingsSchema from '../config.schema.json';
// The upstream Vite plugin embeds config.schema.json into the signed build.
// Config is optional here: the stylesheet and the module defaults above supply
// the same values, so a host without the domain just plays with defaults.
if (runtimeHasDomain('config')) {
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) => {
if (typeof values.textSize === 'number' && Number.isFinite(values.textSize)) {
settings.textSize = values.textSize;
}
if (typeof values.aimGuide === 'boolean') settings.aimGuide = values.aimGuide;
if (typeof values.effects === 'boolean') settings.effects = values.effects;
if (typeof values.playerName === 'string') {
settings.playerName = values.playerName.slice(0, 32);
}
document.documentElement.style.setProperty('--hud-fs', `${settings.textSize}px`);
});
window.addEventListener('pagehide', () => subscription.close(), { once: true });
})().catch(() => {
// Optional operations may be unavailable even when a host exposes the
// domain. Keep the module defaults so the game still runs in a limited host.
});
}
