Back to Napplet Machines V8
SOURCE / PINNED RELEASE

Made of little things.

Napplet Machines V8

Release
b3f614e739f0…
Author-recorded commit
534f19acb4ba…
License
LICENSE
Author’s source reference
nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-b5572362d4a

Archive hash verified: 0f7feb97e2c3d336…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

src/napplet-settings.ts
import { config } from '@napplet/sdk';
import { runtimeHasDomain } from './domain-availability.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 also supplies these 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) => {
      const root = document.documentElement.style;
      const textSize = typeof values.textSize === 'number' ? values.textSize : 13;
      const controlSize = typeof values.controlSize === 'number' ? values.controlSize : 28;
      root.fontSize = `${textSize}px`;
      root.setProperty('--control-h', `${controlSize}px`);
      root.setProperty('--napplet-text-selection', values.selectText === true ? 'text' : 'none');
    });
    window.addEventListener('pagehide', () => subscription.close(), { once: true });
  })().catch(() => {
    // Optional operations may be unavailable even when a host exposes the domain.
    // Keep stylesheet defaults so this example still works in a limited host.
  });
}