windowState
Install the required plugin:
tynd add window-stateimport { windowState } from "@tynd/plugin-window-state/client";Geometry per label is serialised into the app’s data dir (os.appDataDir()) and rehydrated on the next app launch.
API surface
Section titled “API surface”await windowState.init(); // load saved states, start auto-savingawait windowState.restore(); // apply the saved state to this windowwindowState.init(opts?): Promise<void>— load saved states from disk and attach the auto-save listeners (resize, move, maximize, fullscreen; debounced). Idempotent. Options:storagePath(absolute path inside the fs scope; default<appDataDir>/window-states.json),debounceMs(default 500).windowState.restore(label?): Promise<boolean>— apply the last saved snapshot to a window (default: the current one). Resolvestruewhen a snapshot existed,falseotherwise. For another label the snapshot is only reported — that window must callrestore()itself.windowState.save(label?): Promise<void>— flush the current state to disk immediately, bypassing the debounce.windowState.get(label?): Promise<WindowStateSnapshot | null>— read the saved snapshot without applying it.windowState.clear(label?): Promise<void>— drop one saved entry, or all whenlabelis omitted.windowState.setStoragePath(path): Promise<void>— override the JSON file location (default<appDataDir>/window-states.json). Pass an absolute path inside the fs scope: a relative one resolves against the host’s working directory.initalready does this fromstoragePath, so call it only to move the file afterwards.
label defaults to the current window’s label.
WindowStateSnapshot carries x, y, width, height (logical pixels, each optional until reported), maximized and fullscreen.