UNPKG

@theia/core

Version:

Theia is a cloud & desktop IDE framework implemented in TypeScript.

55 lines • 2.96 kB
import { Emitter, Event } from '../../common/event.js'; import { Deferred } from '../../common/promise-util.js'; import { LocalStorageService } from '../storage-service.js'; export declare const SidePanelItemVisibility: unique symbol; /** * Tracks which side panel items are hidden from the side bar. A hidden item keeps its widget * attached: its view still opens through commands and its tab shows while it is the current one. * Items are identified by the id of the widget that owns the tab. */ export interface SidePanelItemVisibility { /** Fires with the id of the widget whose hidden state the user changed. */ readonly onDidChange: Event<string>; /** Fires when the user's choices are discarded and every item falls back to its default. */ readonly onDidReset: Event<void>; /** Resolves once the user's stored choices are loaded; until then every item has its default state. */ readonly ready: Promise<void>; isHidden(widgetId: string): boolean; setHidden(widgetId: string, hidden: boolean): void; /** Discards the user's choices so every item falls back to its default. */ reset(): void; } /** * To keep the user's choices somewhere other than local storage, override `load()` and `save()` * rather than rebinding `LocalStorageService`, which every other consumer of it shares. */ export declare class SidePanelItemVisibilityImpl implements SidePanelItemVisibility { static readonly STORAGE_KEY = "sidePanel.hiddenItems"; /** Hidden items hold across workspaces, and `@theia/workspace` scopes the bound `StorageService` per workspace. */ protected readonly storageService: LocalStorageService; protected readonly onDidChangeEmitter: Emitter<string>; readonly onDidChange: Event<string>; protected readonly onDidResetEmitter: Emitter<void>; readonly onDidReset: Event<void>; protected readonly loaded: Deferred<void>; readonly ready: Promise<void>; /** Explicit user choices only, so items the user never touched follow `isHiddenByDefault`. */ protected overrides: Record<string, boolean>; protected init(): void; protected load(): Promise<void>; isHidden(widgetId: string): boolean; setHidden(widgetId: string, hidden: boolean): void; reset(): void; /** * Whether an item the user has neither hidden nor shown starts hidden. Override this to * give an application its own defaults. * * Defaults are not limited to leaving one item visible per side the way the user's choices are, * so an application can start every item on a side hidden. Expanding a side panel without naming * a view can still open a hidden item, through the last active index or the first tab, and its * tab then shows while it is current, the same as opening it by command. */ protected isHiddenByDefault(widgetId: string): boolean; protected save(): void; } //# sourceMappingURL=side-panel-item-visibility.d.ts.map