@eclipse-emfcloud/modelserver-theia
Version:
## Typescript Client API
53 lines • 3.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/********************************************************************************
* Copyright (c) 2019-2022 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
* https://www.eclipse.org/legal/epl-2.0, or the MIT License which is
* available at https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: EPL-2.0 OR MIT
*******************************************************************************/
const core_1 = require("@theia/core");
const node_1 = require("@theia/core/lib/node");
const inversify_1 = require("@theia/core/shared/inversify");
const common_1 = require("../common");
const launch_options_1 = require("./launch-options");
const model_server_backend_contribution_1 = require("./model-server-backend-contribution");
const theia_model_server_client_1 = require("./theia-model-server-client");
const theia_model_server_client_v2_1 = require("./theia-model-server-client-v2");
exports.default = new inversify_1.ContainerModule(bind => {
bind(model_server_backend_contribution_1.DefaultModelServerLauncher).toSelf().inSingletonScope();
bind(model_server_backend_contribution_1.DefaultModelServerNodeLauncher).toSelf().inSingletonScope();
bind(model_server_backend_contribution_1.ModelServerLauncher).toDynamicValue(({ container }) => {
// If we are configured to launch the modelserver-node, then bind that launcher,
// otherwise just the Java server launcher
if (container.isBound(launch_options_1.LaunchOptions) && container.get(launch_options_1.LaunchOptions).modelServerNode) {
return container.get(model_server_backend_contribution_1.DefaultModelServerNodeLauncher);
}
return container.get(model_server_backend_contribution_1.DefaultModelServerLauncher);
});
bind(node_1.BackendApplicationContribution).toService(model_server_backend_contribution_1.ModelServerLauncher);
bind(common_1.TheiaModelServerClient).to(theia_model_server_client_1.TheiaBackendModelServerClient).inSingletonScope();
bind(core_1.ConnectionHandler)
.toDynamicValue(ctx => new core_1.JsonRpcConnectionHandler(common_1.MODEL_SERVER_CLIENT_SERVICE_PATH, client => {
const modelServerClient = ctx.container.get(common_1.TheiaModelServerClient);
modelServerClient.setClient(client);
client.onDidCloseConnection(() => modelServerClient.dispose());
return modelServerClient;
}, common_1.TheiaModelServerJsonRpcProxyFactory))
.inSingletonScope();
// For Model Server API v2
bind(common_1.TheiaModelServerClientV2).to(theia_model_server_client_v2_1.TheiaBackendModelServerClientV2).inSingletonScope();
bind(core_1.ConnectionHandler)
.toDynamicValue(ctx => new core_1.JsonRpcConnectionHandler(common_1.MODEL_SERVER_CLIENT_V2_SERVICE_PATH, client => {
const modelServerClient = ctx.container.get(common_1.TheiaModelServerClientV2);
modelServerClient.setClient(client);
client.onDidCloseConnection(() => modelServerClient.dispose());
return modelServerClient;
}, common_1.TheiaModelServerJsonRpcProxyFactory))
.inSingletonScope();
});
//# sourceMappingURL=backend-module.js.map