import { Container } from 'inversify';
import { ActionMessage } from 'sprotty-protocol';
/** All services that are required by the `klighd-core` package and have to be provided externally. */
interface Services {
    connection: Connection;
    sessionStorage: SessionStorage;
    persistenceStorage: PersistenceStorage;
}
export declare const ServiceTypes: {
    Connection: symbol;
    PersistenceStorage: symbol;
    SessionStorage: symbol;
};
/** Helper function to bind all required services to the given DI Container. */
export declare function bindServices(container: Container, services: Services): void;
/**
 * Notification types used in `klighd-core`. Most of the times the default Sprotty type
 * (diagram/accept) is used.
 * However, diagram options changes are communicated with separate method types.
 *
 * @see de.cau.cs.kieler.klighd.lsp.IDiagramOptionsLanguageServerExtension.xtend
 */
export declare const enum NotificationType {
    /** The default notification type that is used by Sprotty and thus most of the communication. */
    Accept = "diagram/accept",
    /** Notifies the server about an updated synthesis option. */
    SetSynthesisOption = "keith/diagramOptions/setSynthesisOptions",
    /** Notifies the server about an updated layout option. */
    SetLayoutOption = "keith/diagramOptions/setLayoutOptions",
    /** Perform an actionOption. Do not confuse this with the PerformActionAction with is send with the Accept type! */
    PerformAction = "keith/diagramOptions/performAction",
    /** Notifies the server about the current user preferences. */
    SetPreferences = "keith/preferences/setPreferences"
}
/** An abstract connection to a server. */
export interface Connection {
    /** Sends a {@link ActionMessage} to the server. ActionMessages should use the notification type "diagram/accept". This is the common scenario. */
    sendMessage(message: ActionMessage): void;
    /** Sends a generic notification message to the server with any payload. */
    sendNotification<T extends Record<string, unknown>>(type: NotificationType, payload: T): void;
    /** Registers a callback that is executed when a {@link ActionMessage} is received from the server. */
    onMessageReceived(handler: (message: ActionMessage) => void): void;
    /** Returns a promise that resolves when the connection is able to send and receive messages. */
    onReady(): Promise<void>;
}
/**
 * Key/Value Storage that should be used for short term persistence, lasting only the users
 * session. Uses the same interface as the web {@link Storage} API.
 */
export type SessionStorage = Storage;
/**
 * Key/Value Storage for items that should be persisted long term.
 * API is similar to the {@link Storage} API but is asynchronous, since not every
 * platform is able to provide synchronous storage access.
 *
 * The stored keys/items should be send to the server during initialization
 * as an object property of the `clientDiagramOptions` key.
 */
export interface PersistenceStorage {
    /**
     * Sets the item for a given key. Uses a setter function to update the value
     * based on the previous value, which is often desired.
     * This saves an additional read that would otherwise be required for an update.
     */
    setItem<T>(key: string, setter: (prev?: T) => T): void;
    /** Returns an item for the given key. Resolves to `undefined` if the key does not exist. */
    getItem<T>(key: string): Promise<T | undefined>;
    /** Removes an item for a given key. */
    removeItem(key: string): void;
    /** Clears the storage. Removes all stored items. */
    clear(): void;
    /** Attaches a listener that is notified when the storage gets cleared. */
    onClear(cb: () => void): void;
}
export {};
//# sourceMappingURL=services.d.ts.map