import { Event } from '@vscode-alt/monaco-editor/esm/vs/base/common/event'; import { IStorageScope as StorageScope } from '../generated-model'; export interface IStorage { length: number; key(index: number): string; clear(): void; setItem(key: string, value: any): void; getItem(key: string): string; removeItem(key: string): void; } export interface IWorkspaceStorageChangeEvent { key: string; scope: StorageScope; } export interface IStorageChangeEvent { key: string; } export interface IStorageService { /** * * Emitted whenever data is updated or deleted. */ readonly onDidChangeStorage?: Event; /** * Store a string value under the given key to local storage. * * The optional scope argument allows to define the scope of the operation. */ store(key: string, value: any, scope?: StorageScope): void; /** * Swap the value of a stored element to one of the two provided * values and use the defaultValue if no element with the given key * exists. * * The optional scope argument allows to define the scope of the operation. */ swap?(key: string, valueA: any, valueB: any, scope?: StorageScope, defaultValue?: any): void; /** * Delete an element stored under the provided key from local storage. * * The optional scope argument allows to define the scope of the operation. */ remove(key: string, scope?: StorageScope): void; /** * Retrieve an element stored with the given key from local storage. Use * the provided defaultValue if the element is null or undefined. * * The optional scope argument allows to define the scope of the operation. */ get(key: string, scope?: StorageScope, defaultValue?: string): string; /** * Retrieve an element stored with the given key from local storage. Use * the provided defaultValue if the element is null or undefined. The element * will be converted to a number using parseInt with a base of 10. * * The optional scope argument allows to define the scope of the operation. */ getInteger(key: string, scope?: StorageScope, defaultValue?: number): number; /** * Retrieve an element stored with the given key from local storage. Use * the provided defaultValue if the element is null or undefined. The element * will be converted to a boolean. * * The optional scope argument allows to define the scope of the operation. */ getBoolean(key: string, scope?: StorageScope, defaultValue?: boolean): boolean; } export interface IStorageMainService { /** * Emitted whenever data is udpated or deleted. */ readonly onDidChangeStorage: Event; /** * Emitted when the storage is about to persist. This is the right time * to persist data to ensure it is stored before the application shuts * down. */ readonly onWillSaveState: Event; /** * Retrieve an element stored with the given key from storage. Use * the provided defaultValue if the element is null or undefined. */ get(key: string, fallbackValue: string): string; /** * Retrieve an element stored with the given key from storage. Use * the provided defaultValue if the element is null or undefined. The element * will be converted to boolean. */ getBoolean(key: string, fallbackValue: boolean): boolean; /** * Retrieve an element stored with the given key from storage. Use * the provided defaultValue if the element is null or undefined. The element * will be converted to a number using parseInt with a base of 10. */ getInteger(key: string, fallbackValue: number): number; /** * Store a string value under the given key to storage. The value will * be converted to a string. */ store(key: string, value: any): void; /** * Delete an element under the provided key from storage. */ remove(key: string): void; }