import * as Platform from '../platform/platform.js'; import * as Root from '../root/root.js'; import type { EventDescriptor, EventTargetEvent, GenericEvents } from './EventTarget.js'; import { ObjectWrapper } from './Object.js'; import { getLocalizedSettingsCategory, type LearnMore, maybeRemoveSettingExtension, type RegExpSettingItem, registerSettingExtension, registerSettingsForTest, resetSettings, SettingCategory, type SettingExtensionOption, type SettingRegistration, SettingType } from './SettingRegistration.js'; export interface SettingsCreationOptions { syncedStorage: SettingsStorage; globalStorage: SettingsStorage; localStorage: SettingsStorage; settingRegistrations: SettingRegistration[]; logSettingAccess?: (name: string, value: number | string | boolean) => Promise; runSettingsMigration?: boolean; } export declare class Settings { #private; readonly syncedStorage: SettingsStorage; readonly globalStorage: SettingsStorage; readonly localStorage: SettingsStorage; settingNameSet: Set; orderValuesBySettingCategory: Map>; readonly moduleSettings: Map>; constructor({ syncedStorage, globalStorage, localStorage, settingRegistrations, logSettingAccess, runSettingsMigration }: SettingsCreationOptions); getRegisteredSettings(): SettingRegistration[]; static hasInstance(): boolean; static instance(opts?: { forceNew: boolean | null; syncedStorage: SettingsStorage | null; globalStorage: SettingsStorage | null; localStorage: SettingsStorage | null; settingRegistrations: SettingRegistration[] | null; logSettingAccess?: (name: string, value: number | string | boolean) => Promise; runSettingsMigration?: boolean; }): Settings; static removeInstance(): void; private registerModuleSetting; static normalizeSettingName(name: string): string; /** * Prefer a module setting if this setting is one that you might not want to * surface to the user to control themselves. Examples of these are settings * to store UI state such as how a user choses to position a split widget or * which panel they last opened. * If you are creating a setting that you expect the user to control, and * sync, prefer {@link Settings.createSetting} */ moduleSetting(settingName: string): Setting; settingForTest(settingName: string): Setting; /** * Get setting via key, and create a new setting if the requested setting does not exist. * @param key kebab-case string ID * @param defaultValue * @param storageType If not specified, SettingStorageType.GLOBAL is used. */ createSetting(key: string, defaultValue: T, storageType?: SettingStorageType): Setting; createLocalSetting(key: string, defaultValue: T): Setting; createRegExpSetting(key: string, defaultValue: string, regexFlags?: string, storageType?: SettingStorageType): RegExpSetting; clearAll(): void; private storageFromType; getRegistry(): Map>; } export interface SettingsBackingStore { register(setting: string): void; get(setting: string): Promise; set(setting: string, value: string): void; remove(setting: string): void; clear(): void; } export declare class InMemoryStorage implements SettingsBackingStore { #private; register(_setting: string): void; set(key: string, value: string): void; get(key: string): Promise; remove(key: string): void; clear(): void; } export declare class SettingsStorage { private object; private readonly backingStore; private readonly storagePrefix; constructor(object: Record, backingStore?: SettingsBackingStore, storagePrefix?: string); register(name: string): void; set(name: string, value: string): void; has(name: string): boolean; get(name: string): string; forceGet(originalName: string): Promise; remove(name: string): void; removeAll(): void; keys(): string[]; dumpSizes(): void; } export declare class Deprecation { readonly disabled: boolean; readonly warning: Platform.UIString.LocalizedString; readonly experiment?: Root.Runtime.Experiment | Root.Runtime.HostExperiment; constructor({ deprecationNotice }: SettingRegistration); } export declare class Setting { #private; readonly name: string; readonly defaultValue: V; private readonly eventSupport; readonly storage: SettingsStorage; constructor(name: string, defaultValue: V, eventSupport: ObjectWrapper, storage: SettingsStorage, logSettingAccess?: (name: string, value: number | string | boolean) => Promise); setSerializer(serializer: Serializer): void; addChangeListener(listener: (arg0: EventTargetEvent) => void, thisObject?: Object): EventDescriptor; removeChangeListener(listener: (arg0: EventTargetEvent) => void, thisObject?: Object): void; title(): Platform.UIString.LocalizedString; setTitleFunction(titleFunction?: (() => Platform.UIString.LocalizedString)): void; setTitle(title: Platform.UIString.LocalizedString): void; setRequiresUserAction(requiresUserAction: boolean): void; disabled(): boolean; disabledReasons(): Platform.UIString.LocalizedString[]; setDisabled(disabled: boolean): void; get(): V; getIfNotDisabled(): V | undefined; forceGet(): Promise; set(value: V): void; setRegistration(registration: SettingRegistration): void; type(): SettingType | null; options(): SimpleSettingOption[]; reloadRequired(): boolean | null; category(): SettingCategory | null; tags(): string | null; order(): number | null; /** * See {@link LearnMore} for more info */ learnMore(): LearnMore | null; get deprecation(): Deprecation | null; private printSettingsSavingError; } export declare class RegExpSetting extends Setting { #private; constructor(name: string, defaultValue: string, eventSupport: ObjectWrapper, storage: SettingsStorage, regexFlags?: string, logSettingAccess?: (name: string, value: number | string | boolean) => Promise); get(): string; getAsArray(): RegExpSettingItem[]; set(value: string): void; setAsArray(value: RegExpSettingItem[]): void; asRegExp(): RegExp | null; } export declare const enum SettingStorageType { /** Persists with the active Chrome profile but also syncs the settings across devices via Chrome Sync. */ SYNCED = "Synced", /** * Persists with the active Chrome profile, but not synchronized to other devices. * The default SettingStorageType of createSetting(). */ GLOBAL = "Global", /** Uses Window.localStorage. Not recommended, legacy. */ LOCAL = "Local", /** * Session storage dies when DevTools window closes. Useful for atypical conditions that should be reverted when the * user is done with their task. (eg Emulation modes, Debug overlays). These are also not carried into/out of incognito */ SESSION = "Session" } export declare function moduleSetting(settingName: string): Setting; export declare function settingForTest(settingName: string): Setting; export { getLocalizedSettingsCategory, maybeRemoveSettingExtension, RegExpSettingItem, registerSettingExtension, registerSettingsForTest, resetSettings, SettingCategory, SettingExtensionOption, SettingRegistration, SettingType, }; export interface Serializer { stringify: (value: I) => string; parse: (value: string) => O; } export interface SimpleSettingOption { value: string | boolean; title: string; text?: string; raw?: boolean; }