declare module "disposable" { /** * Concept adapted from https://gist.github.com/dsherret/cf5d6bec3d0f791cef00 */ /** * Generic disposable interface. */ export interface IDisposable { dispose(): void; } /** * Disposable interface supporting aync promises. */ export interface IAyncDisposable { dispose(): Promise; } /** * Generic disposable implementation. */ export class Disposable implements IDisposable { private disposeFunc; constructor(disposeFunc: () => void); dispose(): void; } /** * Generic async disposable implementation. */ export class AsyncDisposable implements IAyncDisposable { private disposeFunc; constructor(disposeFunc: () => Promise); dispose(): Promise; } export function using(resource: T, func: (resource: T) => void): void; } declare module "audit" { import EventEmitter from 'eventemitter3'; import { IDisposable } from "disposable"; export class AuditEvent implements IDisposable { private audit; id: string; args: any[]; returns: any; error: Error; start: number; end: number; constructor(audit: Audit, id: string, running: boolean); addArgs(...args: any): void; addError(error: Error): void; addReturn(returns: any): void; dispose(): void; duration(): number; isError(): boolean; } /** * Audit can be used to view a chain of audit events. * Mainly useful for debugging performance issues. */ export class Audit extends EventEmitter { events: AuditEvent[]; constructor(); startEvent(id: string, ...args: any): AuditEvent; pushEvent(id: string, ...args: any): AuditEvent; } export function usingAudit(event: AuditEvent, func: (resource: AuditEvent) => void): void; const audit: Audit; export default audit; } declare module "config" { export interface ConfigSection { sections?: Record; [key: string]: any; } /** * Provides a config for the editor. */ export class Config { sections: Record; set(key: string, value: any): void; get(key: string): void; } } declare module "extensions/context" { import { IDisposable } from "disposable"; /** * Provides the extection context for extensions. */ export class ExtensionContext { subscriptions: IDisposable[]; } } declare module "extensions/extension" { import { ExtensionContext } from "extensions/context"; /** * Extension provides the interface for extensions. */ export interface Extension { /** * Activates the extension. * @param context the extension context */ activate(context: ExtensionContext): Promise; /** * Deactivate the extension. */ deactivate(): void; /** * Serializes the extension state. * * Returns a JSON serializable object * thats saved in the workspace state. */ serialize(): any; } } declare module "extensions/extension_instance" { import { ExtensionContext } from "extensions/context"; import { Extension } from "extensions/extension"; /** * Represents a loaded instance of an extension. */ export class ExtensionInstance { id: string; extension: Extension; context: ExtensionContext; activated: boolean; activating: boolean; /** * Contains the previously serialized state * if a pervious plugin state was saved to * the workspace state. */ state: any; constructor(id: string, extension: Extension); /** * Activate the wrapped extension */ activate(): Promise; /** * Deactivate the wrapped extension */ deactivate(): void; } } declare module "extensions/errors" { /** * ExtensionNotFoundError is thrown when an extension cannot be found. */ export class ExtensionNotFoundError extends Error { constructor(extension: string); } /** * ExtensionExistsError is thrown when an extension already exists. */ export class ExtensionExistsError extends Error { constructor(extension: string); } } declare module "extensions/manager" { import EventEmitter from 'eventemitter3'; import { ExtensionInstance } from "extensions/extension_instance"; import { Extension } from "extensions/extension"; import { IDisposable } from "disposable"; /** * Manages loaded and active extensions. */ export class ExtensionsManager extends EventEmitter { private extensions; constructor(); /** * Registers a new extension. * @param id unique extension id * @param extension extension handler */ register(id: string, extension: Extension): IDisposable; /** * Deregisters a previously registered extension; * @param id unique extension id */ deregister(id: string): void; /** * Activates an extension. * @param id extension id */ activate(id: string): Promise; /** * Deactivates an extension. * @param id extension id */ deactivate(id: string): void; /** * Returns the list of registered extensions. */ getExtensions(): ExtensionInstance[]; /** * Get all extensions that are activated. */ getActivatedExtensions(): ExtensionInstance[]; } } declare module "extensions/index" { export * from "extensions/context"; export * from "extensions/extension"; export * from "extensions/manager"; } declare module "commands/command" { /** * Represents a command implementations. */ export interface Command { execute(...args: any): T; } } declare module "commands/errors" { /** * CommandNotFoundError is thrown when a command cannot be found. */ export class CommandNotFoundError extends Error { constructor(command: string); } /** * CommandExistsError is thrown when a command already exists. */ export class CommandExistsError extends Error { constructor(command: string); } } declare module "commands/manager" { import EventEmitter from 'eventemitter3'; import { Command } from "commands/command"; import { IDisposable } from "disposable"; /** * Manages registering and executing commands. */ export class CommandManager extends EventEmitter { commands: Record; constructor(); /** * Registers a new command. * @param id id for the command * @param command command implementation */ register(id: string, command: Command): IDisposable; /** * Deregisters a previously registered command. * @param id command id */ deregister(id: string): void; /** * Execute the command. * @param command id of the command * @param args arguments for the command */ execute(command: string, ...args: any): T; /** * Returns the list of registered commands. */ getCommands(): Record; } } declare module "commands/index" { export * from "commands/command"; export * from "commands/errors"; export * from "commands/manager"; } declare module "window/model" { /** * Model represents a display model. */ export class Model { } } declare module "window/pane" { import EventEmitter from 'eventemitter3'; import { Model } from "window/model"; /** * Represents an item in a pane. */ export interface PaneItem { /** * Returns the title of the pane item. */ getTitle(): string; /** * Returns the URI representing this pane item. */ getURI(): string; /** * Returns the preferred location of the pane. */ getDefaultLocation?(): string; /** * Returns the allowed locations of the pane item; */ getAllowedLocations?(): string[]; } /** * Pane represents one of the areas in the center * of the workspace, typically containing tabs * for editor item. * * You can think of the center of the workspace as * a window, and that window is divided into panes. */ export class Pane extends Model { items: PaneItem[]; pendingItem: string; activeItem: number; emitter: EventEmitter; parent: Pane; constructor(); /** * Adds a new pane item. * @param pane pane uri */ addItem(pane: PaneItem): void; /** * Add items adds multiple pane items. * @param panes the items to add */ addItems(items: PaneItem[]): void; /** * Close a pane item. * @param uri pane uri */ destroyItem(uri: string): void; /** * Activates the item at the specified index. * @param index */ activateItemAtIndex(index: number): void; /** * Activates the specified item. * @param uri pane uri */ activateItem(item: PaneItem): void; /** * Activates the item with the specified uri. * @param index */ activateItemForUri(uri: string): void; /** * Replaces the pending pane item with a new item. * @param uri pane uri */ replacePendingItem(uri: string): void; /** * Returns the active pane item. */ getActiveItem(): PaneItem; /** * Returns the pane items. */ getItems(): PaneItem[]; } } declare module "window/pane_axis" { import { Pane } from "window/pane"; import { Model } from "window/model"; /** * Aligns panes along an axis. */ export class PaneAxis extends Model { children: (Pane | PaneAxis)[]; direction: string; constructor(direction?: string); addChild(child: Pane | PaneAxis): void; /** * Returns the pains in the axis. */ getPanes(): Pane[]; /** * Returns the child axis. */ getAxis(): PaneAxis[]; /** * Returns the axis direction. */ getDirection(): string; } } declare module "window/dock" { import { Pane } from "window/pane"; export enum DockAxis { AxisVertical = "vertical", AxisHorizontal = "horizontal" } /** * Represents a collapsible panel on the edges of the window. */ export class Dock { readonly axis: DockAxis; /** * The pane that contains the dock items. */ pane: Pane; constructor(axis: DockAxis); /** * Returns the axis for the dock. */ getAxis(): DockAxis; /** * Returns the pane for the dock. */ getPane(): Pane; } } declare module "window/panel" { /** * Represents a collection of views on the top * and bottom of the window that are stacked. */ export class Panel { view: string; } } declare module "window/window" { import { PaneAxis } from "window/pane_axis"; import { Pane } from "window/pane"; import { PaneItem } from "window/pane"; import { Dock } from "window/dock"; import { Panel } from "window/panel"; import { IDisposable } from "disposable"; /** * Window represents the Hazel window. */ export class Window { center: Pane | PaneAxis; modalPanels: Panel[]; headerPanels: Panel[]; footerPanels: Panel[]; topDock: Dock; leftDock: Dock; rightDock: Dock; bottomDock: Dock; constructor(); /** * Open the view for a uri. * @param uri */ open(uri: string): void; /** * Split the root panes. * @param direction direction to split the panes in * @param items items to move to the new pane */ splitCenter(direction: string, items: PaneItem[]): void; /** * Adds a new modal panel. * @param panel */ addModalPanel(panel: Panel): IDisposable; /** * Adds a new panel to the header. * @param panel */ addHeaderPanel(panel: Panel): IDisposable; /** * Adds a new panel to the footer. * @param panel */ addFooterPanel(panel: Panel): IDisposable; getCenter(): Pane | PaneAxis; getHeaderPanels(): Panel[]; getFooterPanels(): Panel[]; getTopDock(): Dock; getLeftDock(): Dock; getRightDock(): Dock; getBottomDock(): Dock; } } declare module "window/index" { export * from "window/window"; } declare module "providers/errors" { /** * ProviderNotFoundError is thrown when a URI provider cannot be found. */ export class ProviderNotFoundError extends Error { constructor(provider: string); } /** * ProviderExistsError is thrown when a URI provider already exists. */ export class ProviderExistsError extends Error { constructor(provider: string); } } declare module "providers/uri_provider" { import { IDisposable } from "disposable"; /** * Provides a handler for opening a URI type. */ export interface URIProvider { view: string; /** * Reads the file at the specified URI. * @param uri */ open(uri: string): Promise; /** * Writes to the file at the specified URI. * @param uri */ write(uri: string): Promise; } /** * Manages a registry of URI providers. */ export class URIProviders { providers: Record; /** * Registers a URI provider. * @param protocol uri protocol for the provider * @param provider provider implementation */ register(protocol: string, provider: URIProvider): IDisposable; /** * Unregisters a URI provider. * @param protocol uri protocol for the provider */ deregister(protocol: string): void; has(protocol: string): boolean; get(protocol: string): URIProvider; } } declare module "views/view" { import Vue from 'vue'; /** * Represents a view. */ export interface View { model?: any; /** * Create a new instance of the view. * @param element */ create(parent: Element): void; /** * Called before the view is destroyed. */ destroy(): void; } export type ViewConstructor = (...args: any[]) => View; export class VueView implements View { vue: typeof Vue; element: Element; vm: Vue; constructor(vue: typeof Vue); create(parent: Element): void; destroy(): void; } } declare module "views/errors" { /** * ViewNotFoundError is thrown when a view cannot be found. */ export class ViewNotFoundError extends Error { constructor(view: string); } /** * ViewExistsError is thrown when a view already exists. */ export class ViewExistsError extends Error { constructor(view: string); } } declare module "views/view_registry" { import { ViewConstructor } from "views/view"; import { IDisposable } from "disposable"; /** * The view registry manages registered views */ export class ViewRegistry { views: Record; /** * Registers a new view. * @param id * @param view */ register(id: string, view: ViewConstructor): IDisposable; /** * Unregisters a previously registered view. * @param id */ deregister(id: string): void; /** * Returns if the view with the specified id exists. * @param id */ has(id: string): boolean; get(id: string): ViewConstructor; } } declare module "workspace/project" { export interface Project { name: string; path: string; } } declare module "workspace/workspace" { import { Project } from "workspace/project"; export interface Workspace { name: string; projects: Project[]; } } declare module "workspace/provider" { import { Workspace } from "workspace/workspace"; /** * Provides a loader for a workspace. */ export interface WorkspaceProvider { /** * Load a workspace. * @param uri */ load(uri: string): Workspace; } } declare module "workspace/workspace_manager" { import { Workspace } from "workspace/workspace"; import { WorkspaceProvider } from "workspace/provider"; /** * Workspace manager manages the current workspace. */ export class WorkspaceManager { private providers; uri: string; workspace: Workspace; /** * Open a workspace. * @param uri */ open(uri: string): void; registerProvider(protocol: string, provider: WorkspaceProvider): void; /** * Returns if a workspace is loaded. */ loaded(): boolean; /** * Get the workspace. */ get(): Workspace; } } declare module "workspace/index" { export * from "workspace/workspace_manager"; } declare module "themes/errors" { /** * ThemeNotFoundError is thrown when a URI provider cannot be found. */ export class ThemeNotFoundError extends Error { constructor(theme: string); } /** * ThemeExistsError is thrown when a URI provider already exists. */ export class ThemeExistsError extends Error { constructor(theme: string); } } declare module "themes/theme" { /** * Represents a theme. */ export interface Theme { name?: string; } } declare module "themes/theme_manager" { import { Theme } from "themes/theme"; import { IDisposable } from "disposable"; /** * Manages loaded and active themes. */ export class ThemeManager { /** * Contains the list of known themes. */ themes: Record; /** * The stack contains the themes that should currently be applied. * * The themes on the stack are merged from top to bottom to allow * for the creation of partial themes that only effect part of * the editor (useful for custom extension elements). */ stack: Theme[]; /** * Registers a new theme. * * This does NOT make it active, you need to * add it to the active theme stack separately. * @param id * @param theme */ register(id: string, theme: Theme): IDisposable; deregister(id: string): void; } } declare module "themes/index" { export * from "themes/errors"; export * from "themes/theme_manager"; export * from "themes/theme"; } declare module "hazel" { import { ExtensionsManager } from "extensions/index"; import { CommandManager } from "commands/index"; import { Window } from "window/index"; import { Config } from "config"; import { URIProviders } from "providers/uri_provider"; import { ViewRegistry } from "views/view_registry"; import { WorkspaceManager } from "workspace/index"; import { ThemeManager } from "themes/index"; /** * Hazel provides the main entrypoint to the Hazel IDE framework. */ export class Hazel { config: Config; extensions: ExtensionsManager; commands: CommandManager; providers: URIProviders; themes: ThemeManager; views: ViewRegistry; workspace: WorkspaceManager; window: Window; constructor(); /** * Open the specified URI. * @param uri * @param options */ open(uri: string, options: any): void; } } declare module "providers/index" { export * from "providers/errors"; export * from "providers/uri_provider"; } declare module "views/index" { export * from "views/errors"; export * from "views/view_registry"; export * from "views/view"; } declare module "index" { export * from "commands/index"; export * from "extensions/index"; export * from "providers/index"; export * from "themes/index"; export * from "views/index"; export * from "window/index"; export * from "disposable"; export * from "hazel"; } declare module "dialog/dialog_manager" { /** * Manages displaying dialogs. */ export class DialogManager { } } declare module "dialog/index" { export * from "dialog/dialog_manager"; } declare module "services/service_registry" { /** * Manages registered services and consumers. */ export class ServiceRegistry { } } declare module "services/index" { export * from "services/service_registry"; } declare module "services/services" { import { IDisposable } from "disposable"; export type ServiceProvider = () => any; /** * Called when a service is ready. Should return a Disposable * that's disponsed when the service is unloaded. */ export type ServiceConsumer = (service: any) => IDisposable; }