/******************************************************************************** * Copyright (c) 2021 TypeFox 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 { ServerActionHandlerRegistry } from './action-handler'; import { Action, ResponseAction, RequestModelAction, ComputedBoundsAction, LayoutAction, RequestAction } from './actions'; import { DiagramServices, DiagramState, IDiagramGenerator, IModelLayoutEngine } from './diagram-services'; import { SModelRoot } from './model'; import { Deferred } from './utils/async'; /** * An instance of this class is responsible for handling a single diagram client. It holds the current * state of the diagram and manages communication with the client via actions. */ export declare class DiagramServer { readonly state: DiagramState & { lastSubmittedModelType?: string; }; readonly dispatch: (action: A) => Promise; protected readonly diagramGenerator: IDiagramGenerator; protected readonly layoutEngine?: IModelLayoutEngine; protected actionHandlerRegistry?: ServerActionHandlerRegistry; protected readonly requests: Map>; constructor(dispatch: (action: A) => Promise, services: DiagramServices); /** * Set the model and submit it to the client. */ setModel(newRoot: SModelRoot): Promise; /** * Update the model to a new state and submit it to the client. */ updateModel(newRoot: SModelRoot): Promise; /** * Whether the client needs to compute the layout of parts of the model. This affects the behavior * of `submitModel`. * * This setting is determined by the `DiagramOptions` that are received with the `RequestModelAction` * from the client. If the client does not specify whether it needs client layout, the default value * is `true`. */ get needsClientLayout(): boolean; /** * Whether the server needs to compute the layout of parts of the model. This affects the behavior * of `submitModel`. * * This setting is determined by the `DiagramOptions` that are received with the `RequestModelAction` * from the client. If the client does not specify whether it needs server layout, the default value * is `false`. */ get needsServerLayout(): boolean; /** * Called when an action is received from the client. */ accept(action: Action): Promise; /** * Send a request action to the client. The resulting promise is resolved when a matching * response is received and rejected when a `RejectAction` is received. */ request(action: RequestAction): Promise; /** * Send a `RejectAction` to the client to notify that a request could not be fulfilled. */ rejectRemoteRequest(action: Action | undefined, error: Error): void; protected handleAction(action: Action): Promise; protected handleRequestModel(action: RequestModelAction): Promise; /** * Submit a model to the client after it has been updated in the server state. */ protected submitModel(newRoot: SModelRoot, update: boolean, cause?: Action): Promise; private doSubmitModel; protected handleComputedBounds(action: ComputedBoundsAction): Promise; protected handleLayout(action: LayoutAction): Promise; } //# sourceMappingURL=diagram-server.d.ts.map