UNPKG

@eclipse-glsp/protocol

Version:

The protocol definition for client-server communication in GLSP

104 lines 4.93 kB
/******************************************************************************** * Copyright (c) 2021-2023 STMicroelectronics and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ import * as sprotty from 'sprotty-protocol/lib/actions'; import { Action, RequestAction, ResponseAction } from './base-protocol'; /** * Sent from the client to the server in order to persist the current model state back to the source model. * A new fileUri can be defined to save the model to a new destination different from its original source model. * The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks * and creating new `SaveModelActions`. */ export interface SaveModelAction extends Action { kind: typeof SaveModelAction.KIND; /** * The optional destination file uri. */ fileUri?: string; } export declare namespace SaveModelAction { const KIND = "saveModel"; function is(object: unknown): object is SaveModelAction; function create(options?: { fileUri?: string; }): SaveModelAction; } /** * The server sends this action to indicate to the client that the current model state on the server does not correspond * to the persisted model state of the source model. A client may ignore such an action or use it to indicate to the user the dirty state. * The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks * and creating new `SetDirtyStateActions`. */ export interface SetDirtyStateAction extends Action { kind: typeof SetDirtyStateAction.KIND; /** * True if the current model state is dirty */ isDirty: boolean; /** * A string indicating the reason for the dirty state change e.g 'operation', 'undo',... */ reason?: DirtyStateChangeReason; } export type DirtyStateChangeReason = 'operation' | 'undo' | 'redo' | 'save' | 'external'; export declare namespace SetDirtyStateAction { const KIND = "setDirtyState"; function is(object: unknown): object is SetDirtyStateAction; function create(isDirty: boolean, options?: { reason?: DirtyStateChangeReason; }): SetDirtyStateAction; } /** * A `RequestExportSvgAction` is sent by the client (or the server) to initiate the SVG export of the current diagram. * The handler of this action is expected to retrieve the diagram SVG and should send a {@link ExportSvgAction} as response. * Typically the {@link ExportSvgAction} is handled directly on client side. */ export interface RequestExportSvgAction extends RequestAction<ExportSvgAction>, sprotty.RequestExportSvgAction { kind: typeof RequestExportSvgAction.KIND; options?: ExportSvgOptions; } export declare namespace RequestExportSvgAction { const KIND = "requestExportSvg"; function is(object: unknown): object is RequestExportSvgAction; function create(options?: { options?: ExportSvgOptions; requestId?: string; }): RequestExportSvgAction; } /** Configuration options for the {@link RequestExportSvgAction */ export interface ExportSvgOptions extends sprotty.ExportSvgOptions { skipCopyStyles?: boolean; } /** * The client sends an `ExportSvgAction` to indicate that the diagram, which represents the current model state, * should be exported in SVG format. The action only provides the diagram SVG as plain string. The expected result of executing * an `ExportSvgAction` is a new file in SVG-format on the underlying filesystem. However, other details like the target destination, * concrete file name, file extension etc. are not specified in the protocol. So it is the responsibility of the action handler to * process this information accordingly and export the result to the underlying filesystem. */ export interface ExportSvgAction extends ResponseAction, sprotty.ExportSvgAction { kind: typeof ExportSvgAction.KIND; svg: string; options?: ExportSvgOptions; } export declare namespace ExportSvgAction { const KIND = "exportSvg"; function is(object: unknown): object is ExportSvgAction; function create(svg: string, options?: { options?: ExportSvgOptions; responseId?: string; }): ExportSvgAction; } //# sourceMappingURL=model-saving.d.ts.map