UNPKG

svelte-settings

Version:

> [!WARNING] > This project is a work in progress. Do not use it in any of your projects yet.

28 lines (27 loc) 1.49 kB
import type { SettingsBlueprint, SettingsFromBlueprint } from './types.js'; import { type Options } from './options.js'; import type { DeepPartial } from './utils.js'; export type { SettingsFromBlueprint, SettingsBlueprint } from './types.js'; export type InitializedSettings = ReturnType<typeof useSettings>; export { default as SettingsView } from './components/SettingsView.svelte'; export * as migration from './utils/migration.js'; export { performMigrations } from './migrate.js'; /** * Creates an instance of svelte-settings following the given blueprint. * Should only be called once, as this initializes the settings and creates a store for it. * Having multiple instances would break reactivity. * You can re-export the initialized settings for use in your app. */ export declare function useSettings<T extends SettingsBlueprint>(blueprint: T, options: DeepPartial<Options>): { subscribe: (this: void, run: import("svelte/store").Subscriber<SettingsFromBlueprint<T>>, invalidate?: () => void) => import("svelte/store").Unsubscriber; select: <U>(selector: (s: SettingsFromBlueprint<T>) => U, isEqual?: (a: U, b: U) => boolean) => import("svelte/store").Readable<U>; readSetting: (path: readonly string[]) => { value: unknown; changed: boolean; }; writeSetting: (path: readonly string[], value: unknown) => void; resetSetting: (path: string[]) => unknown; defaults: SettingsFromBlueprint<T>; blueprint: T; options: Options; };