Skip to content

Settings only main changes, settings checks, and kit.settings.onChange() - #74

Merged
WillTDA merged 1 commit into
masterfrom
main-only-settings
Oct 26, 2026
Merged

WillTDA merged 1 commit into
masterfrom
main-only-settings

Conversation

@WillTDA

@WillTDA WillTDA commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Closes #66.

What's new

  • kit.start({ settings: { mainOnly: [...] } }): the page's kitAPI.setSettings() naming one of them is refused whole ("The setting "downloadFolder" can't be changed from the page."), and nothing of that change is stored. kit.settings.set() in main changes them as any other, and the page reads them as before.
  • settings: { checks: { key: (value) => boolean } }: a function per setting, handed a copy of the value once its kind is checked. Unless it returns true the change is refused whole, from the page or from main ("The setting "transfersAtOnce" doesn't take that value."). Reads aren't checked.
  • Both are checked at start(): the app's own settings only (keys of defaults, never the kit's), each check a function; a mistake throws with kit.start()'s name, before anything is registered.
  • kit.settings.onChange(listener) returns the function that stops it, and hears every stored change as (changes, after, { from }), from "page" or "main" (the updater saving the build's channel the first time counts as main's). Each listener gets its own copies, and is told after the kit's own updater and log handling. A refused change tells no one. A listener that throws, or rejects, is logged as an error; the change stays stored and the other listeners still hear it.
  • The demo gains exportFolder, main's alone, with a check that it's a whole path when set.
  • Docs: docs/main-process.md (Settings Only Main Changes, and Checks; Hearing a Change), and the docs index line.

Tests

  • test/store.test.js +13: the refusals at start() (and in createSettings()); the page's change naming a main-only key refused with nothing stored, main's taken and read by the page; checks refusing from the page and from main, kind checked first, a copy handed over; reads unchecked; the listener's arguments for both; a refused change heard by no one; copies per listener; the order after the updater (an update already downloading) and the memory log (debug.log already on disk); the updater's own channel save; unsubscribe, and one function added twice; listeners added or stopped while a change is told; a throwing and a rejecting listener.
  • e2e/log-store.spec.js +1: in the demo, the page's change of exportFolder refused with nothing stored, main's accepted and read by the page, a relative folder refused by the check, and onChange hearing main's and the page's changes with from.
  • npm test 318 of 318; the e2e suite locally 179 passed, 8 skipped (packaged only).

No page change, so no visual image changes: the 86 baselines are untouched, and the local run matched all of them.

…ange()

kit.start({ settings: { mainOnly, checks } }): the page's change naming a
setting only main changes is refused whole, and nothing of it is stored;
a setting's check refuses a value from the page or from main. Both name
the app's own settings only, checked at start().

kit.settings.onChange(listener) hears every stored change as
(changes, after, { from }), after the updater and the log have acted on
it, and returns the function that stops it. A listener that throws or
rejects is logged; the change stays stored and the others still hear it.

The demo's export folder is main's alone, and a whole path when set.
@WillTDA
WillTDA merged commit 3638749 into master Oct 26, 2026
12 of 13 checks passed
@WillTDA
WillTDA deleted the main-only-settings branch October 26, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings only main may change (kit.start({ settings: { mainOnly } }))

1 participant