UNPKG

@eclipse-glsp/vscode-integration

Version:

Glue code to integrate GLSP diagrams in VSCode extensions (extension part)

55 lines 2.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BrowserGlspVscodeServer = void 0; /******************************************************************************** * Copyright (c) 2021-2024 EclipseSource 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 ********************************************************************************/ const protocol_1 = require("@eclipse-glsp/protocol"); const di_1 = require("@eclipse-glsp/protocol/lib/di"); const inversify_1 = require("inversify"); const base_glsp_vscode_server_1 = require("../../common/quickstart-components/base-glsp-vscode-server"); /** * This component can be used to bootstrap your extension when using the typescript * GLSP server implementation directly in a web extension without a dedicated webworker, which you can find here: * https://github.com/eclipse-glsp/glsp-server-node * * It sets up a a server running directly in the extension context and * provides an interface, ready to be used by the `GlspVscodeConnector` for the * GLSP-VSCode integration. */ class BrowserGlspVscodeServer extends base_glsp_vscode_server_1.BaseGlspVscodeServer { constructor(options) { super(options); this.options = options; } createGLSPClient() { const client = new protocol_1.BaseGLSPClient({ id: this.options.clientId }); const proxyModule = new inversify_1.ContainerModule(bind => { bind(protocol_1.GLSPClientProxy).toConstantValue(client.proxy); }); this.serverContainer = this.createContainer(proxyModule); const server = this.serverContainer.get(protocol_1.GLSPServer); client.configureServer(server); return client; } createContainer(...additionalConfiguration) { const container = new inversify_1.Container(); return (0, di_1.initializeContainer)(container, ...this.options.serverModules, ...additionalConfiguration); } } exports.BrowserGlspVscodeServer = BrowserGlspVscodeServer; //# sourceMappingURL=browser-glsp-vscode-server.js.map