Three coordinated layers — spirit, saveNative, bridge — solving write ordering, process lifecycle, and I/O durability inside a browser tab. No server. No Electron wrapper kindly asking if that's okay.
Type in the fields. Kill the tab. Come back. Your work is here.
Spirit debounces saves to IndexedDB on every keystroke and force-saves on
visibilitychange. Password fields are never touched.
Every save, restore, and field exclusion logged in real time. Watch it react as you type — or switch to another tab.
Mount a local folder. Writes are serialised per filename and backed by a write-ahead shelf.
Kill the process mid-write and replay on next wake() — nothing is lost.
Successful writes, shelf fallbacks, and flush recoveries appear here. The shelf is the write-ahead buffer — your crash safety net.
One wake() call restores form state, re-acquires the directory handle,
flushes shelved writes, and attaches a permission watcher. This is the recommended integration point.
// load the bundle // <script src="gnoke-persist.js"></script> // if (!window.__GNOKE_READY__) throw new Error('Gnoke not loaded'); // provide an openDB adapter — idb or native (see examples/opendb-native.js) import { openDB } from 'idb'; // mount once — user picks a folder await Gnoke.bridge.mount(openDB); // every page load after that Gnoke.bridge.onPermissionLost = () => showBanner('permission lost'); Gnoke.bridge.onPermissionRestored = () => hideBanner(); Gnoke.bridge.onFlushComplete = n => toast(`recovered ${n} writes`); await Gnoke.bridge.wake(openDB, { formEl: document.querySelector('form') }); await Gnoke.bridge.write('output.json', JSON.stringify(data)); console.log(Gnoke.inspect()); // → { woken: true, hasWorkspace: true, permission: true, shelfFailures: 0 }
Each layer is independently usable. The bundle is convenience, not a requirement.