@eclipse-emfcloud/modelserver-theia
Version:
## Typescript Client API
75 lines • 3.68 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TheiaBackendModelServerClient = void 0;
/********************************************************************************
* Copyright (c) 2022 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
* 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 modelserver_client_1 = require("@eclipse-emfcloud/modelserver-client");
const inversify_1 = require("@theia/core/shared/inversify");
const urijs_1 = __importDefault(require("urijs"));
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
const launch_options_1 = require("./launch-options");
(0, inversify_1.decorate)((0, inversify_1.injectable)(), modelserver_client_1.ModelServerClient);
let TheiaBackendModelServerClient = class TheiaBackendModelServerClient extends modelserver_client_1.ModelServerClient {
constructor(launchOptions = launch_options_1.DEFAULT_LAUNCH_OPTIONS) {
super();
this.launchOptions = launchOptions;
const baseUrl = this.getBaseUrl();
this.initialize(baseUrl);
}
getBaseUrl() {
const baseUrl = new urijs_1.default({
protocol: 'http',
hostname: this.launchOptions.hostname,
port: this.launchOptions.serverPort,
path: this.launchOptions.baseURL
});
return baseUrl;
}
setClient(client) {
this.subscriptionClient = client;
}
subscribe(modeluri, options = {}) {
// Handle optional arguments finding the RPC cancellation token in their place
if (vscode_jsonrpc_1.CancellationToken.is(options)) {
options = {};
}
if (!options.listener) {
options.listener = this.subscriptionClient;
}
super.subscribe(modeluri, options);
}
dispose() {
Array.from(this.openSockets.values()).forEach(openSocket => openSocket.close());
}
};
TheiaBackendModelServerClient = __decorate([
(0, inversify_1.injectable)(),
__param(0, (0, inversify_1.inject)(launch_options_1.LaunchOptions)),
__param(0, (0, inversify_1.optional)()),
__metadata("design:paramtypes", [Object])
], TheiaBackendModelServerClient);
exports.TheiaBackendModelServerClient = TheiaBackendModelServerClient;
//# sourceMappingURL=theia-model-server-client.js.map