@theia/core 1.44.0 → 1.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/i18n/nls.cs.json +10 -3
- package/i18n/nls.de.json +10 -3
- package/i18n/nls.es.json +10 -3
- package/i18n/nls.fr.json +10 -3
- package/i18n/nls.hu.json +10 -3
- package/i18n/nls.it.json +10 -3
- package/i18n/nls.ja.json +10 -3
- package/i18n/nls.json +10 -3
- package/i18n/nls.pl.json +10 -3
- package/i18n/nls.pt-br.json +10 -3
- package/i18n/nls.pt-pt.json +10 -3
- package/i18n/nls.ru.json +10 -3
- package/i18n/nls.zh-cn.json +10 -3
- package/lib/browser/common-frontend-contribution.d.ts +6 -0
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +52 -9
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/connection-status-service.d.ts +2 -2
- package/lib/browser/connection-status-service.d.ts.map +1 -1
- package/lib/browser/connection-status-service.js +3 -3
- package/lib/browser/connection-status-service.js.map +1 -1
- package/lib/browser/connection-status-service.spec.js +6 -6
- package/lib/browser/connection-status-service.spec.js.map +1 -1
- package/lib/browser/core-preferences.d.ts.map +1 -1
- package/lib/browser/core-preferences.js +16 -0
- package/lib/browser/core-preferences.js.map +1 -1
- package/lib/browser/dialogs.d.ts +0 -1
- package/lib/browser/dialogs.d.ts.map +1 -1
- package/lib/browser/dialogs.js +1 -34
- package/lib/browser/dialogs.js.map +1 -1
- package/lib/browser/frontend-application-module.d.ts.map +1 -1
- package/lib/browser/frontend-application-module.js +1 -0
- package/lib/browser/frontend-application-module.js.map +1 -1
- package/lib/browser/messaging/connection-source.d.ts +9 -0
- package/lib/browser/messaging/connection-source.d.ts.map +1 -0
- package/lib/browser/messaging/connection-source.js +20 -0
- package/lib/browser/messaging/connection-source.js.map +1 -0
- package/lib/browser/messaging/frontend-id-provider.d.ts +13 -0
- package/lib/browser/messaging/frontend-id-provider.d.ts.map +1 -0
- package/lib/browser/messaging/frontend-id-provider.js +40 -0
- package/lib/browser/messaging/frontend-id-provider.js.map +1 -0
- package/lib/browser/messaging/messaging-frontend-module.d.ts.map +1 -1
- package/lib/browser/messaging/messaging-frontend-module.js +18 -1
- package/lib/browser/messaging/messaging-frontend-module.js.map +1 -1
- package/lib/browser/messaging/service-connection-provider.d.ts +48 -0
- package/lib/browser/messaging/service-connection-provider.d.ts.map +1 -0
- package/lib/browser/messaging/service-connection-provider.js +115 -0
- package/lib/browser/messaging/service-connection-provider.js.map +1 -0
- package/lib/browser/messaging/ws-connection-provider.d.ts +7 -38
- package/lib/browser/messaging/ws-connection-provider.d.ts.map +1 -1
- package/lib/browser/messaging/ws-connection-provider.js +17 -121
- package/lib/browser/messaging/ws-connection-provider.js.map +1 -1
- package/lib/browser/messaging/ws-connection-source.d.ts +41 -0
- package/lib/browser/messaging/ws-connection-source.d.ts.map +1 -0
- package/lib/browser/messaging/ws-connection-source.js +210 -0
- package/lib/browser/messaging/ws-connection-source.js.map +1 -0
- package/lib/browser/preload/i18n-preload-contribution.js +1 -1
- package/lib/browser/preload/i18n-preload-contribution.js.map +1 -1
- package/lib/browser/shell/application-shell.js +1 -1
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-widget.d.ts +1 -0
- package/lib/browser/tree/tree-compression/compressed-tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-widget.js +5 -0
- package/lib/browser/tree/tree-compression/compressed-tree-widget.js.map +1 -1
- package/lib/browser/tree/tree-widget.d.ts +6 -0
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +21 -11
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/user-working-directory-provider.d.ts +8 -1
- package/lib/browser/user-working-directory-provider.d.ts.map +1 -1
- package/lib/browser/user-working-directory-provider.js +22 -1
- package/lib/browser/user-working-directory-provider.js.map +1 -1
- package/lib/browser/window/default-secondary-window-service.d.ts +3 -0
- package/lib/browser/window/default-secondary-window-service.d.ts.map +1 -1
- package/lib/browser/window/default-secondary-window-service.js +55 -1
- package/lib/browser/window/default-secondary-window-service.js.map +1 -1
- package/lib/common/message-rpc/channel.d.ts.map +1 -1
- package/lib/common/message-rpc/channel.js +7 -1
- package/lib/common/message-rpc/channel.js.map +1 -1
- package/lib/common/message-rpc/message-buffer.d.ts +2 -0
- package/lib/common/message-rpc/message-buffer.d.ts.map +1 -1
- package/lib/common/message-rpc/message-buffer.js +4 -0
- package/lib/common/message-rpc/message-buffer.js.map +1 -1
- package/lib/common/message-rpc/uint8-array-message-buffer.d.ts +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.d.ts.map +1 -1
- package/lib/common/message-rpc/uint8-array-message-buffer.js +6 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.js.map +1 -1
- package/lib/common/messaging/connection-management.d.ts +25 -0
- package/lib/common/messaging/connection-management.d.ts.map +1 -0
- package/lib/common/messaging/connection-management.js +38 -0
- package/lib/common/messaging/connection-management.js.map +1 -0
- package/lib/common/messaging/handler.d.ts +1 -0
- package/lib/common/messaging/handler.d.ts.map +1 -1
- package/lib/common/messaging/handler.js +2 -1
- package/lib/common/messaging/handler.js.map +1 -1
- package/lib/common/messaging/socket-write-buffer.d.ts +11 -0
- package/lib/common/messaging/socket-write-buffer.d.ts.map +1 -0
- package/lib/common/messaging/socket-write-buffer.js +50 -0
- package/lib/common/messaging/socket-write-buffer.js.map +1 -0
- package/lib/common/messaging/web-socket-channel.d.ts +7 -35
- package/lib/common/messaging/web-socket-channel.d.ts.map +1 -1
- package/lib/common/messaging/web-socket-channel.js +20 -9
- package/lib/common/messaging/web-socket-channel.js.map +1 -1
- package/lib/electron-browser/messaging/electron-frontend-id-provider.d.ts +5 -0
- package/lib/electron-browser/messaging/electron-frontend-id-provider.d.ts.map +1 -0
- package/lib/{electron-node/token/electron-token-messaging-contribution.js → electron-browser/messaging/electron-frontend-id-provider.js} +9 -28
- package/lib/electron-browser/messaging/electron-frontend-id-provider.js.map +1 -0
- package/lib/electron-browser/messaging/electron-ipc-connection-source.d.ts +24 -0
- package/lib/electron-browser/messaging/electron-ipc-connection-source.d.ts.map +1 -0
- package/lib/electron-browser/messaging/{electron-ipc-connection-provider.js → electron-ipc-connection-source.js} +19 -19
- package/lib/electron-browser/messaging/electron-ipc-connection-source.js.map +1 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts +7 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts.map +1 -0
- package/lib/electron-browser/messaging/{electron-local-ws-connection-provider.js → electron-local-ws-connection-source.js} +7 -7
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.js.map +1 -0
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.js +45 -13
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.js.map +1 -1
- package/lib/electron-browser/messaging/electron-ws-connection-source.d.ts +12 -0
- package/lib/electron-browser/messaging/electron-ws-connection-source.d.ts.map +1 -0
- package/lib/electron-browser/messaging/{electron-ws-connection-provider.js → electron-ws-connection-source.js} +14 -21
- package/lib/electron-browser/messaging/electron-ws-connection-source.js.map +1 -0
- package/lib/electron-browser/preload.d.ts.map +1 -1
- package/lib/electron-browser/preload.js +10 -0
- package/lib/electron-browser/preload.js.map +1 -1
- package/lib/electron-browser/window/electron-window-module.js +2 -2
- package/lib/electron-browser/window/electron-window-module.js.map +1 -1
- package/lib/electron-browser/window/electron-window-service.d.ts +4 -0
- package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-window-service.js +13 -0
- package/lib/electron-browser/window/electron-window-service.js.map +1 -1
- package/lib/electron-common/electron-api.d.ts +6 -0
- package/lib/electron-common/electron-api.d.ts.map +1 -1
- package/lib/electron-common/electron-api.js +3 -1
- package/lib/electron-common/electron-api.js.map +1 -1
- package/lib/electron-main/electron-api-main.d.ts +1 -0
- package/lib/electron-main/electron-api-main.d.ts.map +1 -1
- package/lib/electron-main/electron-api-main.js +15 -0
- package/lib/electron-main/electron-api-main.js.map +1 -1
- package/lib/electron-main/electron-main-application-module.js +5 -5
- package/lib/electron-main/electron-main-application-module.js.map +1 -1
- package/lib/electron-main/electron-main-application.d.ts +7 -13
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +36 -26
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/electron-main/messaging/electron-connection-handler.d.ts.map +1 -0
- package/lib/electron-main/messaging/electron-connection-handler.js.map +1 -0
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +13 -22
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-contribution.js +39 -39
- package/lib/electron-main/messaging/electron-messaging-contribution.js.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-service.d.ts.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-service.js.map +1 -1
- package/lib/electron-main/theia-electron-window.d.ts +2 -2
- package/lib/electron-main/theia-electron-window.d.ts.map +1 -1
- package/lib/electron-main/theia-electron-window.js +3 -2
- package/lib/electron-main/theia-electron-window.js.map +1 -1
- package/lib/node/messaging/default-messaging-service.d.ts +29 -0
- package/lib/node/messaging/default-messaging-service.d.ts.map +1 -0
- package/lib/node/messaging/default-messaging-service.js +140 -0
- package/lib/node/messaging/default-messaging-service.js.map +1 -0
- package/lib/node/messaging/frontend-connection-service.d.ts +7 -0
- package/lib/node/messaging/frontend-connection-service.d.ts.map +1 -0
- package/lib/node/messaging/frontend-connection-service.js +19 -0
- package/lib/node/messaging/frontend-connection-service.js.map +1 -0
- package/lib/node/messaging/messaging-backend-module.d.ts.map +1 -1
- package/lib/node/messaging/messaging-backend-module.js +23 -9
- package/lib/node/messaging/messaging-backend-module.js.map +1 -1
- package/lib/node/messaging/messaging-service.d.ts +2 -3
- package/lib/node/messaging/messaging-service.d.ts.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.d.ts +3 -3
- package/lib/node/messaging/test/test-web-socket-channel.d.ts.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.js +38 -24
- package/lib/node/messaging/test/test-web-socket-channel.js.map +1 -1
- package/lib/node/messaging/websocket-endpoint.d.ts +21 -0
- package/lib/node/messaging/websocket-endpoint.d.ts.map +1 -0
- package/lib/node/messaging/websocket-endpoint.js +89 -0
- package/lib/node/messaging/websocket-endpoint.js.map +1 -0
- package/lib/node/messaging/websocket-frontend-connection-service.d.ts +30 -0
- package/lib/node/messaging/websocket-frontend-connection-service.d.ts.map +1 -0
- package/lib/node/messaging/websocket-frontend-connection-service.js +173 -0
- package/lib/node/messaging/websocket-frontend-connection-service.js.map +1 -0
- package/package.json +6 -6
- package/src/browser/common-frontend-contribution.ts +55 -9
- package/src/browser/connection-status-service.spec.ts +6 -6
- package/src/browser/connection-status-service.ts +2 -2
- package/src/browser/core-preferences.ts +16 -0
- package/src/browser/dialogs.ts +0 -34
- package/src/browser/frontend-application-module.ts +1 -0
- package/src/browser/messaging/connection-source.ts +26 -0
- package/src/browser/messaging/frontend-id-provider.ts +37 -0
- package/src/browser/messaging/messaging-frontend-module.ts +20 -2
- package/src/browser/messaging/service-connection-provider.ts +126 -0
- package/src/browser/messaging/ws-connection-provider.ts +16 -141
- package/src/browser/messaging/ws-connection-source.ts +210 -0
- package/src/browser/preload/i18n-preload-contribution.ts +1 -1
- package/src/browser/shell/application-shell.ts +1 -1
- package/src/browser/tree/tree-compression/compressed-tree-widget.tsx +27 -7
- package/src/browser/tree/tree-widget.tsx +21 -10
- package/src/browser/user-working-directory-provider.ts +32 -3
- package/src/browser/window/default-secondary-window-service.ts +54 -1
- package/src/common/i18n/nls.metadata.json +7208 -6923
- package/src/common/message-rpc/channel.ts +5 -1
- package/src/common/message-rpc/message-buffer.ts +6 -0
- package/src/common/message-rpc/uint8-array-message-buffer.ts +7 -0
- package/src/common/messaging/connection-management.ts +43 -0
- package/src/common/messaging/handler.ts +2 -0
- package/src/common/messaging/socket-write-buffer.ts +52 -0
- package/src/common/messaging/web-socket-channel.ts +28 -45
- package/src/electron-browser/messaging/electron-frontend-id-provider.ts +25 -0
- package/src/electron-browser/messaging/{electron-ipc-connection-provider.ts → electron-ipc-connection-source.ts} +17 -13
- package/src/electron-browser/messaging/{electron-local-ws-connection-provider.ts → electron-local-ws-connection-source.ts} +2 -2
- package/src/electron-browser/messaging/electron-messaging-frontend-module.ts +49 -12
- package/src/electron-browser/messaging/{electron-ws-connection-provider.ts → electron-ws-connection-source.ts} +6 -17
- package/src/electron-browser/preload.ts +15 -1
- package/src/electron-browser/window/electron-window-module.ts +1 -1
- package/src/electron-browser/window/electron-window-service.ts +11 -0
- package/src/electron-common/electron-api.ts +7 -0
- package/src/electron-main/electron-api-main.ts +20 -1
- package/src/electron-main/electron-main-application-module.ts +5 -5
- package/src/electron-main/electron-main-application.ts +46 -41
- package/src/electron-main/messaging/electron-messaging-contribution.ts +45 -43
- package/src/electron-main/messaging/electron-messaging-service.ts +1 -0
- package/src/electron-main/theia-electron-window.ts +4 -3
- package/src/node/messaging/default-messaging-service.ts +129 -0
- package/src/node/messaging/frontend-connection-service.ts +24 -0
- package/src/node/messaging/messaging-backend-module.ts +25 -10
- package/src/node/messaging/messaging-service.ts +3 -3
- package/src/node/messaging/test/test-web-socket-channel.ts +32 -27
- package/src/node/messaging/websocket-endpoint.ts +79 -0
- package/src/node/messaging/websocket-frontend-connection-service.ts +171 -0
- package/lib/common/messaging/abstract-connection-provider.d.ts +0 -45
- package/lib/common/messaging/abstract-connection-provider.d.ts.map +0 -1
- package/lib/common/messaging/abstract-connection-provider.js +0 -93
- package/lib/common/messaging/abstract-connection-provider.js.map +0 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts +0 -19
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts.map +0 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.js.map +0 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.d.ts +0 -7
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.d.ts.map +0 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.js.map +0 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts +0 -17
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts.map +0 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.js.map +0 -1
- package/lib/electron-common/messaging/electron-connection-handler.d.ts.map +0 -1
- package/lib/electron-common/messaging/electron-connection-handler.js.map +0 -1
- package/lib/electron-node/token/electron-token-messaging-contribution.d.ts +0 -16
- package/lib/electron-node/token/electron-token-messaging-contribution.d.ts.map +0 -1
- package/lib/electron-node/token/electron-token-messaging-contribution.js.map +0 -1
- package/lib/node/messaging/messaging-contribution.d.ts +0 -44
- package/lib/node/messaging/messaging-contribution.d.ts.map +0 -1
- package/lib/node/messaging/messaging-contribution.js +0 -210
- package/lib/node/messaging/messaging-contribution.js.map +0 -1
- package/src/common/messaging/abstract-connection-provider.ts +0 -115
- package/src/electron-node/token/electron-token-messaging-contribution.ts +0 -41
- package/src/node/messaging/messaging-contribution.ts +0 -197
- /package/lib/{electron-common → electron-main}/messaging/electron-connection-handler.d.ts +0 -0
- /package/lib/{electron-common → electron-main}/messaging/electron-connection-handler.js +0 -0
- /package/src/{electron-common → electron-main}/messaging/electron-connection-handler.ts +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
17
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
+
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;
|
|
20
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
+
};
|
|
22
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
23
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.WebsocketFrontendConnectionService = void 0;
|
|
27
|
+
const inversify_1 = require("inversify");
|
|
28
|
+
const default_messaging_service_1 = require("./default-messaging-service");
|
|
29
|
+
const socket_write_buffer_1 = require("../../common/messaging/socket-write-buffer");
|
|
30
|
+
const channel_1 = require("../../common/message-rpc/channel");
|
|
31
|
+
const uint8_array_message_buffer_1 = require("../../common/message-rpc/uint8-array-message-buffer");
|
|
32
|
+
const backend_application_config_provider_1 = require("../backend-application-config-provider");
|
|
33
|
+
const websocket_endpoint_1 = require("./websocket-endpoint");
|
|
34
|
+
const connection_management_1 = require("../../common/messaging/connection-management");
|
|
35
|
+
const common_1 = require("../../common");
|
|
36
|
+
let WebsocketFrontendConnectionService = class WebsocketFrontendConnectionService {
|
|
37
|
+
constructor() {
|
|
38
|
+
this.wsHandlers = new default_messaging_service_1.ConnectionHandlers();
|
|
39
|
+
this.connectionsByFrontend = new Map();
|
|
40
|
+
this.closeTimeouts = new Map();
|
|
41
|
+
this.channelsMarkedForClose = new Set();
|
|
42
|
+
}
|
|
43
|
+
registerConnectionHandler(spec, callback) {
|
|
44
|
+
this.websocketServer.registerConnectionHandler(spec, (params, socket) => this.handleConnection(socket, channel => callback(params, channel)));
|
|
45
|
+
}
|
|
46
|
+
async handleConnection(socket, channelCreatedHandler) {
|
|
47
|
+
// eslint-disable-next-line prefer-const
|
|
48
|
+
let reconnectListener;
|
|
49
|
+
const initialConnectListener = (frontEndId) => {
|
|
50
|
+
socket.off(connection_management_1.ConnectionManagementMessages.INITIAL_CONNECT, initialConnectListener);
|
|
51
|
+
socket.off(connection_management_1.ConnectionManagementMessages.RECONNECT, reconnectListener);
|
|
52
|
+
if (this.connectionsByFrontend.has(frontEndId)) {
|
|
53
|
+
this.closeConnection(frontEndId, 'reconnecting same front end');
|
|
54
|
+
}
|
|
55
|
+
channelCreatedHandler(this.createConnection(socket, frontEndId));
|
|
56
|
+
socket.emit(connection_management_1.ConnectionManagementMessages.INITIAL_CONNECT);
|
|
57
|
+
};
|
|
58
|
+
reconnectListener = (frontEndId) => {
|
|
59
|
+
socket.off(connection_management_1.ConnectionManagementMessages.INITIAL_CONNECT, initialConnectListener);
|
|
60
|
+
socket.off(connection_management_1.ConnectionManagementMessages.RECONNECT, reconnectListener);
|
|
61
|
+
const channel = this.connectionsByFrontend.get(frontEndId);
|
|
62
|
+
if (channel) {
|
|
63
|
+
console.info(`Reconnecting to front end ${frontEndId}`);
|
|
64
|
+
socket.emit(connection_management_1.ConnectionManagementMessages.RECONNECT, true);
|
|
65
|
+
channel.connect(socket);
|
|
66
|
+
const pendingTimeout = this.closeTimeouts.get(frontEndId);
|
|
67
|
+
clearTimeout(pendingTimeout);
|
|
68
|
+
this.closeTimeouts.delete(frontEndId);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.info(`Reconnecting failed for ${frontEndId}`);
|
|
72
|
+
socket.emit(connection_management_1.ConnectionManagementMessages.RECONNECT, false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
socket.on(connection_management_1.ConnectionManagementMessages.INITIAL_CONNECT, initialConnectListener);
|
|
76
|
+
socket.on(connection_management_1.ConnectionManagementMessages.RECONNECT, reconnectListener);
|
|
77
|
+
}
|
|
78
|
+
closeConnection(frontEndId, reason) {
|
|
79
|
+
console.info(`closing connection for ${frontEndId}`);
|
|
80
|
+
const connection = this.connectionsByFrontend.get(frontEndId); // not called when no connection is present
|
|
81
|
+
this.connectionsByFrontend.delete(frontEndId);
|
|
82
|
+
const pendingTimeout = this.closeTimeouts.get(frontEndId);
|
|
83
|
+
clearTimeout(pendingTimeout);
|
|
84
|
+
this.closeTimeouts.delete(frontEndId);
|
|
85
|
+
connection.onCloseEmitter.fire({ reason });
|
|
86
|
+
connection.close();
|
|
87
|
+
}
|
|
88
|
+
createConnection(socket, frontEndId) {
|
|
89
|
+
console.info(`creating connection for ${frontEndId}`);
|
|
90
|
+
const channel = new ReconnectableSocketChannel();
|
|
91
|
+
channel.connect(socket);
|
|
92
|
+
socket.on('disconnect', evt => {
|
|
93
|
+
console.info('socked closed');
|
|
94
|
+
channel.disconnect();
|
|
95
|
+
const timeout = backend_application_config_provider_1.BackendApplicationConfigProvider.get().frontendConnectionTimeout;
|
|
96
|
+
const isMarkedForClose = this.channelsMarkedForClose.delete(frontEndId);
|
|
97
|
+
if (timeout === 0 || isMarkedForClose) {
|
|
98
|
+
this.closeConnection(frontEndId, evt);
|
|
99
|
+
}
|
|
100
|
+
else if (timeout > 0) {
|
|
101
|
+
console.info(`setting close timeout for id ${frontEndId} to ${timeout}`);
|
|
102
|
+
const handle = setTimeout(() => {
|
|
103
|
+
this.closeConnection(frontEndId, evt);
|
|
104
|
+
}, timeout);
|
|
105
|
+
this.closeTimeouts.set(frontEndId, handle);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// timeout < 0: never close the back end
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
this.connectionsByFrontend.set(frontEndId, channel);
|
|
112
|
+
return channel;
|
|
113
|
+
}
|
|
114
|
+
markForClose(channelId) {
|
|
115
|
+
this.channelsMarkedForClose.add(channelId);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, inversify_1.inject)(websocket_endpoint_1.WebsocketEndpoint),
|
|
120
|
+
__metadata("design:type", websocket_endpoint_1.WebsocketEndpoint)
|
|
121
|
+
], WebsocketFrontendConnectionService.prototype, "websocketServer", void 0);
|
|
122
|
+
WebsocketFrontendConnectionService = __decorate([
|
|
123
|
+
(0, inversify_1.injectable)()
|
|
124
|
+
], WebsocketFrontendConnectionService);
|
|
125
|
+
exports.WebsocketFrontendConnectionService = WebsocketFrontendConnectionService;
|
|
126
|
+
class ReconnectableSocketChannel extends channel_1.AbstractChannel {
|
|
127
|
+
constructor() {
|
|
128
|
+
super(...arguments);
|
|
129
|
+
this.socketBuffer = new socket_write_buffer_1.SocketWriteBuffer();
|
|
130
|
+
this.disposables = new common_1.DisposableCollection();
|
|
131
|
+
}
|
|
132
|
+
connect(socket) {
|
|
133
|
+
this.disposables = new common_1.DisposableCollection();
|
|
134
|
+
this.socket = socket;
|
|
135
|
+
const errorHandler = (err) => {
|
|
136
|
+
this.onErrorEmitter.fire(err);
|
|
137
|
+
};
|
|
138
|
+
this.disposables.push(common_1.Disposable.create(() => {
|
|
139
|
+
socket.off('error', errorHandler);
|
|
140
|
+
}));
|
|
141
|
+
socket.on('error', errorHandler);
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
143
|
+
const dataListener = (data) => {
|
|
144
|
+
// In the browser context socketIO receives binary messages as ArrayBuffers.
|
|
145
|
+
// So we have to convert them to a Uint8Array before delegating the message to the read buffer.
|
|
146
|
+
const buffer = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
|
|
147
|
+
this.onMessageEmitter.fire(() => new uint8_array_message_buffer_1.Uint8ArrayReadBuffer(buffer));
|
|
148
|
+
};
|
|
149
|
+
this.disposables.push(common_1.Disposable.create(() => {
|
|
150
|
+
socket.off('message', dataListener);
|
|
151
|
+
}));
|
|
152
|
+
socket.on('message', dataListener);
|
|
153
|
+
this.socketBuffer.flush(socket);
|
|
154
|
+
}
|
|
155
|
+
disconnect() {
|
|
156
|
+
this.disposables.dispose();
|
|
157
|
+
this.socket = undefined;
|
|
158
|
+
}
|
|
159
|
+
getWriteBuffer() {
|
|
160
|
+
const writeBuffer = new uint8_array_message_buffer_1.Uint8ArrayWriteBuffer();
|
|
161
|
+
writeBuffer.onCommit(data => {
|
|
162
|
+
var _a;
|
|
163
|
+
if ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected) {
|
|
164
|
+
this.socket.send(data);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
this.socketBuffer.buffer(data);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
return writeBuffer;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=websocket-frontend-connection-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-frontend-connection-service.js","sourceRoot":"","sources":["../../../src/node/messaging/websocket-frontend-connection-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;;;;;;;;;;;;AAIhF,yCAA+C;AAE/C,2EAAiE;AACjE,oFAA+E;AAE/E,8DAAmE;AACnE,oGAAkH;AAClH,gGAA0F;AAC1F,6DAAyD;AACz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C,CAAC,CAAC,IAAI,CAAC;YACzE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,iDAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAU,CAAC,MAAM,CAAC,GAAG,EAAE;YACzC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC,CAAC;QACJ,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,UAAU;QACN,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC5B,CAAC;IAEQ,cAAc;QACnB,MAAM,WAAW,GAAG,IAAI,kDAAqB,EAAE,CAAC;QAChD,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;;YACxB,IAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,SAAS,EAAE;gBACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC1B;iBAAM;gBACH,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAClC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.0",
|
|
4
4
|
"description": "Theia is a cloud & desktop IDE framework implemented in TypeScript.",
|
|
5
5
|
"main": "lib/common/index.js",
|
|
6
6
|
"typings": "lib/common/index.d.ts",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"@phosphor/signaling": "1",
|
|
17
17
|
"@phosphor/virtualdom": "1",
|
|
18
18
|
"@phosphor/widgets": "1",
|
|
19
|
-
"@theia/application-package": "1.
|
|
20
|
-
"@theia/request": "1.
|
|
19
|
+
"@theia/application-package": "1.45.0",
|
|
20
|
+
"@theia/request": "1.45.0",
|
|
21
21
|
"@types/body-parser": "^1.16.4",
|
|
22
22
|
"@types/cookie": "^0.3.3",
|
|
23
23
|
"@types/dompurify": "^2.2.2",
|
|
@@ -200,12 +200,12 @@
|
|
|
200
200
|
"watch": "theiaext watch"
|
|
201
201
|
},
|
|
202
202
|
"devDependencies": {
|
|
203
|
-
"@theia/ext-scripts": "1.
|
|
204
|
-
"@theia/re-exports": "1.
|
|
203
|
+
"@theia/ext-scripts": "1.45.0",
|
|
204
|
+
"@theia/re-exports": "1.45.0",
|
|
205
205
|
"minimist": "^1.2.0"
|
|
206
206
|
},
|
|
207
207
|
"nyc": {
|
|
208
208
|
"extends": "../../configs/nyc.json"
|
|
209
209
|
},
|
|
210
|
-
"gitHead": "
|
|
210
|
+
"gitHead": "2b20a60a0f9b54b19838a0f71760989a19622495"
|
|
211
211
|
}
|
|
@@ -57,7 +57,7 @@ import { QuickInputService, QuickPickItem, QuickPickItemOrSeparator, QuickPickSe
|
|
|
57
57
|
import { AsyncLocalizationProvider } from '../common/i18n/localization';
|
|
58
58
|
import { nls } from '../common/nls';
|
|
59
59
|
import { CurrentWidgetCommandAdapter } from './shell/current-widget-command-adapter';
|
|
60
|
-
import { ConfirmDialog,
|
|
60
|
+
import { ConfirmDialog, confirmExit, ConfirmSaveDialog, Dialog } from './dialogs';
|
|
61
61
|
import { WindowService } from './window/window-service';
|
|
62
62
|
import { FrontendApplicationConfigProvider } from './frontend-application-config-provider';
|
|
63
63
|
import { DecorationStyle } from './decoration-style';
|
|
@@ -1200,22 +1200,60 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
|
|
|
1200
1200
|
action: async () => {
|
|
1201
1201
|
const captionsToSave = this.unsavedTabsCaptions();
|
|
1202
1202
|
const untitledCaptionsToSave = this.unsavedUntitledTabsCaptions();
|
|
1203
|
-
const
|
|
1203
|
+
const shouldExit = await this.confirmExitWithOrWithoutSaving(captionsToSave, async () => {
|
|
1204
1204
|
await this.saveDirty(untitledCaptionsToSave);
|
|
1205
1205
|
await this.shell.saveAll();
|
|
1206
1206
|
});
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1207
|
+
const allSavedOrDoNotSave = (
|
|
1208
|
+
shouldExit === true && untitledCaptionsToSave.length === 0 // Should save and cancel if any captions failed to save
|
|
1209
|
+
) || shouldExit === false; // Do not save
|
|
1210
|
+
|
|
1211
|
+
this.shouldPreventClose = !allSavedOrDoNotSave;
|
|
1212
|
+
return allSavedOrDoNotSave;
|
|
1214
1213
|
|
|
1215
1214
|
}
|
|
1216
1215
|
};
|
|
1217
1216
|
}
|
|
1218
1217
|
}
|
|
1218
|
+
// Asks the user to confirm whether they want to exit with or without saving the changes
|
|
1219
|
+
private async confirmExitWithOrWithoutSaving(captionsToSave: string[], performSave: () => Promise<void>): Promise<boolean | undefined> {
|
|
1220
|
+
const div: HTMLElement = document.createElement('div');
|
|
1221
|
+
div.innerText = nls.localizeByDefault("Your changes will be lost if you don't save them.");
|
|
1222
|
+
|
|
1223
|
+
let result;
|
|
1224
|
+
if (captionsToSave.length > 0) {
|
|
1225
|
+
const span = document.createElement('span');
|
|
1226
|
+
span.appendChild(document.createElement('br'));
|
|
1227
|
+
captionsToSave.forEach(cap => {
|
|
1228
|
+
const b = document.createElement('b');
|
|
1229
|
+
b.innerText = cap;
|
|
1230
|
+
span.appendChild(b);
|
|
1231
|
+
span.appendChild(document.createElement('br'));
|
|
1232
|
+
});
|
|
1233
|
+
span.appendChild(document.createElement('br'));
|
|
1234
|
+
div.appendChild(span);
|
|
1235
|
+
result = await new ConfirmSaveDialog({
|
|
1236
|
+
title: nls.localizeByDefault('Do you want to save the changes to the following {0} files?', captionsToSave.length),
|
|
1237
|
+
msg: div,
|
|
1238
|
+
dontSave: nls.localizeByDefault("Don't Save"),
|
|
1239
|
+
save: nls.localizeByDefault('Save All'),
|
|
1240
|
+
cancel: Dialog.CANCEL
|
|
1241
|
+
}).open();
|
|
1242
|
+
|
|
1243
|
+
if (result) {
|
|
1244
|
+
await performSave();
|
|
1245
|
+
}
|
|
1246
|
+
} else {
|
|
1247
|
+
// fallback if not passed with an empty caption-list.
|
|
1248
|
+
result = confirmExit();
|
|
1249
|
+
}
|
|
1250
|
+
if (result !== undefined) {
|
|
1251
|
+
return result === true;
|
|
1252
|
+
} else {
|
|
1253
|
+
return undefined;
|
|
1254
|
+
};
|
|
1255
|
+
|
|
1256
|
+
}
|
|
1219
1257
|
protected unsavedTabsCaptions(): string[] {
|
|
1220
1258
|
return this.shell.widgets
|
|
1221
1259
|
.filter(widget => this.saveResourceService.canSave(widget))
|
|
@@ -1236,11 +1274,19 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
|
|
|
1236
1274
|
this.windowService.reload();
|
|
1237
1275
|
}
|
|
1238
1276
|
}
|
|
1277
|
+
/**
|
|
1278
|
+
* saves any dirty widget in toSave
|
|
1279
|
+
* side effect - will pop all widgets from toSave that was saved
|
|
1280
|
+
* @param toSave
|
|
1281
|
+
*/
|
|
1239
1282
|
protected async saveDirty(toSave: Widget[]): Promise<void> {
|
|
1240
1283
|
for (const widget of toSave) {
|
|
1241
1284
|
const saveable = Saveable.get(widget);
|
|
1242
1285
|
if (saveable?.dirty) {
|
|
1243
1286
|
await this.saveResourceService.save(widget);
|
|
1287
|
+
if (!this.saveResourceService.canSave(widget)) {
|
|
1288
|
+
toSave.pop();
|
|
1289
|
+
}
|
|
1244
1290
|
}
|
|
1245
1291
|
}
|
|
1246
1292
|
}
|
|
@@ -33,8 +33,8 @@ import { MockConnectionStatusService } from './test/mock-connection-status-servi
|
|
|
33
33
|
import * as sinon from 'sinon';
|
|
34
34
|
|
|
35
35
|
import { Container } from 'inversify';
|
|
36
|
-
import { WebSocketConnectionProvider } from './messaging/ws-connection-provider';
|
|
37
36
|
import { ILogger, Emitter, Loggable } from '../common';
|
|
37
|
+
import { WebSocketConnectionSource } from './messaging/ws-connection-source';
|
|
38
38
|
|
|
39
39
|
disableJSDOM();
|
|
40
40
|
|
|
@@ -101,7 +101,7 @@ describe('frontend-connection-status', function (): void {
|
|
|
101
101
|
let timer: sinon.SinonFakeTimers;
|
|
102
102
|
let pingSpy: sinon.SinonSpy;
|
|
103
103
|
beforeEach(() => {
|
|
104
|
-
const
|
|
104
|
+
const mockWebSocketConnectionSource = sinon.createStubInstance(WebSocketConnectionSource);
|
|
105
105
|
const mockPingService: PingService = <PingService>{
|
|
106
106
|
ping(): Promise<void> {
|
|
107
107
|
return Promise.resolve(undefined);
|
|
@@ -118,11 +118,11 @@ describe('frontend-connection-status', function (): void {
|
|
|
118
118
|
testContainer.bind(PingService).toConstantValue(mockPingService);
|
|
119
119
|
testContainer.bind(ILogger).toConstantValue(mockILogger);
|
|
120
120
|
testContainer.bind(ConnectionStatusOptions).toConstantValue({ offlineTimeout: OFFLINE_TIMEOUT });
|
|
121
|
-
testContainer.bind(
|
|
121
|
+
testContainer.bind(WebSocketConnectionSource).toConstantValue(mockWebSocketConnectionSource);
|
|
122
122
|
|
|
123
|
-
sinon.stub(
|
|
124
|
-
sinon.stub(
|
|
125
|
-
sinon.stub(
|
|
123
|
+
sinon.stub(mockWebSocketConnectionSource, 'onSocketDidOpen').value(mockSocketOpenedEmitter.event);
|
|
124
|
+
sinon.stub(mockWebSocketConnectionSource, 'onSocketDidClose').value(mockSocketClosedEmitter.event);
|
|
125
|
+
sinon.stub(mockWebSocketConnectionSource, 'onIncomingMessageActivity').value(mockIncomingMessageActivityEmitter.event);
|
|
126
126
|
|
|
127
127
|
timer = sinon.useFakeTimers();
|
|
128
128
|
|
|
@@ -19,8 +19,8 @@ import { ILogger } from '../common/logger';
|
|
|
19
19
|
import { Event, Emitter } from '../common/event';
|
|
20
20
|
import { DefaultFrontendApplicationContribution } from './frontend-application-contribution';
|
|
21
21
|
import { StatusBar, StatusBarAlignment } from './status-bar/status-bar';
|
|
22
|
-
import { WebSocketConnectionProvider } from './messaging/ws-connection-provider';
|
|
23
22
|
import { Disposable, DisposableCollection, nls } from '../common';
|
|
23
|
+
import { WebSocketConnectionSource } from './messaging/ws-connection-source';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Service for listening on backend connection changes.
|
|
@@ -119,7 +119,7 @@ export class FrontendConnectionStatusService extends AbstractConnectionStatusSer
|
|
|
119
119
|
|
|
120
120
|
private scheduledPing: number | undefined;
|
|
121
121
|
|
|
122
|
-
@inject(
|
|
122
|
+
@inject(WebSocketConnectionSource) protected readonly wsConnectionProvider: WebSocketConnectionSource;
|
|
123
123
|
@inject(PingService) protected readonly pingService: PingService;
|
|
124
124
|
|
|
125
125
|
@postConstruct()
|
|
@@ -119,6 +119,22 @@ export const corePreferenceSchema: PreferenceSchema = {
|
|
|
119
119
|
scope: 'application',
|
|
120
120
|
markdownDescription: nls.localizeByDefault('Separator used by {0}.', '`#window.title#`')
|
|
121
121
|
},
|
|
122
|
+
'window.secondaryWindowPlacement': {
|
|
123
|
+
type: 'string',
|
|
124
|
+
enum: ['originalSize', 'halfWidth', 'fullSize'],
|
|
125
|
+
enumDescriptions: [
|
|
126
|
+
nls.localize('theia/core/secondaryWindow/originalSize', 'The position and size of the extracted widget will be the same as the original widget.'),
|
|
127
|
+
nls.localize('theia/core/secondaryWindow/halfWidth', 'The position and size of the extracted widget will be half the width of the running Theia application.'),
|
|
128
|
+
nls.localize('theia/core/secondaryWindow/fullSize', 'The position and size of the extracted widget will be the same as the running Theia application.'),
|
|
129
|
+
],
|
|
130
|
+
default: 'originalSize',
|
|
131
|
+
description: nls.localize('theia/core/secondaryWindow/description', 'Sets the initial position and size of the extracted secondary window.'),
|
|
132
|
+
},
|
|
133
|
+
'window.secondaryWindowAlwaysOnTop': {
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
default: false,
|
|
136
|
+
description: nls.localize('theia/core/secondaryWindow/alwaysOnTop', 'When enabled, the secondary window stays above all other windows, including those of different applications.'),
|
|
137
|
+
},
|
|
122
138
|
'http.proxy': {
|
|
123
139
|
type: 'string',
|
|
124
140
|
pattern: '^https?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$',
|
package/src/browser/dialogs.ts
CHANGED
|
@@ -458,40 +458,6 @@ export class ConfirmSaveDialog extends AbstractDialog<boolean | undefined> {
|
|
|
458
458
|
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
-
// Asks the user to confirm whether they want to exit with or without saving the changes
|
|
462
|
-
export async function confirmExitWithOrWithoutSaving(captionsToSave: string[], performSave: () => Promise<void>): Promise<boolean> {
|
|
463
|
-
const div: HTMLElement = document.createElement('div');
|
|
464
|
-
div.innerText = nls.localizeByDefault("Your changes will be lost if you don't save them.");
|
|
465
|
-
|
|
466
|
-
if (captionsToSave.length > 0) {
|
|
467
|
-
const span = document.createElement('span');
|
|
468
|
-
span.appendChild(document.createElement('br'));
|
|
469
|
-
captionsToSave.forEach(cap => {
|
|
470
|
-
const b = document.createElement('b');
|
|
471
|
-
b.innerText = cap;
|
|
472
|
-
span.appendChild(b);
|
|
473
|
-
span.appendChild(document.createElement('br'));
|
|
474
|
-
});
|
|
475
|
-
span.appendChild(document.createElement('br'));
|
|
476
|
-
div.appendChild(span);
|
|
477
|
-
const result = await new ConfirmSaveDialog({
|
|
478
|
-
title: nls.localizeByDefault('Do you want to save the changes to the following {0} files?', captionsToSave.length),
|
|
479
|
-
msg: div,
|
|
480
|
-
dontSave: nls.localizeByDefault("Don't Save"),
|
|
481
|
-
save: nls.localizeByDefault('Save All'),
|
|
482
|
-
cancel: Dialog.CANCEL
|
|
483
|
-
}).open();
|
|
484
|
-
|
|
485
|
-
if (result) {
|
|
486
|
-
await performSave();
|
|
487
|
-
}
|
|
488
|
-
return result !== undefined;
|
|
489
|
-
} else {
|
|
490
|
-
// fallback if not passed with an empty caption-list.
|
|
491
|
-
return confirmExit();
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
}
|
|
495
461
|
@injectable()
|
|
496
462
|
export class SingleTextInputDialogProps extends DialogProps {
|
|
497
463
|
readonly confirmButtonLabel?: string;
|
|
@@ -445,6 +445,7 @@ export const frontendApplicationModule = new ContainerModule((bind, _unbind, _is
|
|
|
445
445
|
|
|
446
446
|
bind(SaveResourceService).toSelf().inSingletonScope();
|
|
447
447
|
bind(UserWorkingDirectoryProvider).toSelf().inSingletonScope();
|
|
448
|
+
bind(FrontendApplicationContribution).toService(UserWorkingDirectoryProvider);
|
|
448
449
|
|
|
449
450
|
bind(HoverService).toSelf().inSingletonScope();
|
|
450
451
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Channel, Event } from '../../common';
|
|
18
|
+
|
|
19
|
+
export const ConnectionSource = Symbol('ConnectionSource');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A ConnectionSource creates a Channel. The channel is valid until it sends a close event.
|
|
23
|
+
*/
|
|
24
|
+
export interface ConnectionSource {
|
|
25
|
+
onConnectionDidOpen: Event<Channel>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable } from 'inversify';
|
|
18
|
+
import { generateUuid } from '../../common/uuid';
|
|
19
|
+
|
|
20
|
+
export const FrontendIdProvider = Symbol('FrontendIdProvider');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A FrontendIdProvider computes an id for an instance of the front end that may be reconnected to a back end
|
|
24
|
+
* connection context.
|
|
25
|
+
*/
|
|
26
|
+
export interface FrontendIdProvider {
|
|
27
|
+
getId(): string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@injectable()
|
|
31
|
+
export class BrowserFrontendIdProvider implements FrontendIdProvider {
|
|
32
|
+
protected readonly id = generateUuid(); // generate a new id each time we load the application
|
|
33
|
+
|
|
34
|
+
getId(): string {
|
|
35
|
+
return this.id;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -15,9 +15,27 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { ContainerModule } from 'inversify';
|
|
18
|
-
import {
|
|
18
|
+
import { BrowserFrontendIdProvider, FrontendIdProvider } from './frontend-id-provider';
|
|
19
|
+
import { WebSocketConnectionSource } from './ws-connection-source';
|
|
20
|
+
import { LocalConnectionProvider, RemoteConnectionProvider, ServiceConnectionProvider } from './service-connection-provider';
|
|
21
|
+
import { ConnectionSource } from './connection-source';
|
|
22
|
+
import { ConnectionCloseService, connectionCloseServicePath } from '../../common/messaging/connection-management';
|
|
23
|
+
import { WebSocketConnectionProvider } from './ws-connection-provider';
|
|
24
|
+
|
|
25
|
+
const backendServiceProvider = Symbol('backendServiceProvider');
|
|
19
26
|
|
|
20
27
|
export const messagingFrontendModule = new ContainerModule(bind => {
|
|
28
|
+
bind(ConnectionCloseService).toDynamicValue(ctx => WebSocketConnectionProvider.createProxy(ctx.container, connectionCloseServicePath)).inSingletonScope();
|
|
29
|
+
bind(BrowserFrontendIdProvider).toSelf().inSingletonScope();
|
|
30
|
+
bind(FrontendIdProvider).toService(BrowserFrontendIdProvider);
|
|
31
|
+
bind(WebSocketConnectionSource).toSelf().inSingletonScope();
|
|
32
|
+
bind(backendServiceProvider).toDynamicValue(ctx => {
|
|
33
|
+
bind(ServiceConnectionProvider).toSelf().inSingletonScope();
|
|
34
|
+
const container = ctx.container.createChild();
|
|
35
|
+
container.bind(ConnectionSource).toService(WebSocketConnectionSource);
|
|
36
|
+
return container.get(ServiceConnectionProvider);
|
|
37
|
+
}).inSingletonScope();
|
|
38
|
+
bind(LocalConnectionProvider).toService(backendServiceProvider);
|
|
39
|
+
bind(RemoteConnectionProvider).toService(backendServiceProvider);
|
|
21
40
|
bind(WebSocketConnectionProvider).toSelf().inSingletonScope();
|
|
22
|
-
bind(LocalWebSocketConnectionProvider).toService(WebSocketConnectionProvider);
|
|
23
41
|
});
|