@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
|
@@ -22,12 +22,12 @@ import { ElectronSecurityToken } from '../electron-common/electron-token';
|
|
|
22
22
|
import { ElectronMainWindowService, electronMainWindowServicePath } from '../electron-common/electron-main-window-service';
|
|
23
23
|
import { ElectronMainApplication, ElectronMainApplicationContribution, ElectronMainProcessArgv } from './electron-main-application';
|
|
24
24
|
import { ElectronMainWindowServiceImpl } from './electron-main-window-service-impl';
|
|
25
|
-
import { ElectronMessagingContribution } from './messaging/electron-messaging-contribution';
|
|
26
|
-
import { ElectronMessagingService } from './messaging/electron-messaging-service';
|
|
27
|
-
import { ElectronConnectionHandler } from '../electron-common/messaging/electron-connection-handler';
|
|
28
|
-
import { ElectronSecurityTokenService } from './electron-security-token-service';
|
|
29
25
|
import { TheiaBrowserWindowOptions, TheiaElectronWindow, TheiaElectronWindowFactory, WindowApplicationConfig } from './theia-electron-window';
|
|
30
26
|
import { TheiaMainApi } from './electron-api-main';
|
|
27
|
+
import { ElectronMessagingContribution } from './messaging/electron-messaging-contribution';
|
|
28
|
+
import { ElectronSecurityTokenService } from './electron-security-token-service';
|
|
29
|
+
import { ElectronMessagingService } from './messaging/electron-messaging-service';
|
|
30
|
+
import { ElectronConnectionHandler } from './messaging/electron-connection-handler';
|
|
31
31
|
|
|
32
32
|
const electronSecurityToken: ElectronSecurityToken = { value: v4() };
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -36,6 +36,7 @@ const electronSecurityToken: ElectronSecurityToken = { value: v4() };
|
|
|
36
36
|
export default new ContainerModule(bind => {
|
|
37
37
|
bind(ElectronMainApplication).toSelf().inSingletonScope();
|
|
38
38
|
bind(ElectronMessagingContribution).toSelf().inSingletonScope();
|
|
39
|
+
bind(ElectronMainApplicationContribution).toService(ElectronMessagingContribution);
|
|
39
40
|
bind(ElectronSecurityToken).toConstantValue(electronSecurityToken);
|
|
40
41
|
bind(ElectronSecurityTokenService).toSelf().inSingletonScope();
|
|
41
42
|
|
|
@@ -43,7 +44,6 @@ export default new ContainerModule(bind => {
|
|
|
43
44
|
bindContributionProvider(bind, ElectronMessagingService.Contribution);
|
|
44
45
|
bindContributionProvider(bind, ElectronMainApplicationContribution);
|
|
45
46
|
|
|
46
|
-
bind(ElectronMainApplicationContribution).toService(ElectronMessagingContribution);
|
|
47
47
|
bind(TheiaMainApi).toSelf().inSingletonScope();
|
|
48
48
|
bind(ElectronMainApplicationContribution).toService(TheiaMainApi);
|
|
49
49
|
|
|
@@ -54,19 +54,13 @@ export interface ElectronMainCommandOptions {
|
|
|
54
54
|
*/
|
|
55
55
|
readonly file?: string;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
readonly cwd: string;
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* 1. The app is launched for the first time, `secondInstance` is false.
|
|
64
|
-
* 2. The app is already running but user relaunches it, `secondInstance` is true.
|
|
65
|
-
*/
|
|
66
|
-
export interface ElectronMainExecutionParams {
|
|
59
|
+
/**
|
|
60
|
+
* If the app is launched for the first time, `secondInstance` is false.
|
|
61
|
+
* If the app is already running but user relaunches it, `secondInstance` is true.
|
|
62
|
+
*/
|
|
67
63
|
readonly secondInstance: boolean;
|
|
68
|
-
readonly argv: string[];
|
|
69
|
-
readonly cwd: string;
|
|
70
64
|
}
|
|
71
65
|
|
|
72
66
|
/**
|
|
@@ -212,21 +206,38 @@ export class ElectronMainApplication {
|
|
|
212
206
|
}
|
|
213
207
|
|
|
214
208
|
async start(config: FrontendApplicationConfig): Promise<void> {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
209
|
+
const argv = this.processArgv.getProcessArgvWithoutBin(process.argv);
|
|
210
|
+
createYargs(argv, process.cwd())
|
|
211
|
+
.command('$0 [file]', false,
|
|
212
|
+
cmd => cmd
|
|
213
|
+
.option('electronUserData', {
|
|
214
|
+
type: 'string',
|
|
215
|
+
describe: 'The area where the electron main process puts its data'
|
|
216
|
+
})
|
|
217
|
+
.positional('file', { type: 'string' }),
|
|
218
|
+
async args => {
|
|
219
|
+
if (args.electronUserData) {
|
|
220
|
+
console.info(`using electron user data area : '${args.electronUserData}'`);
|
|
221
|
+
await fs.mkdir(args.electronUserData, { recursive: true });
|
|
222
|
+
app.setPath('userData', args.electronUserData);
|
|
223
|
+
}
|
|
224
|
+
this.useNativeWindowFrame = this.getTitleBarStyle(config) === 'native';
|
|
225
|
+
this._config = config;
|
|
226
|
+
this.hookApplicationEvents();
|
|
227
|
+
this.showInitialWindow();
|
|
228
|
+
const port = await this.startBackend();
|
|
229
|
+
this._backendPort.resolve(port);
|
|
230
|
+
await app.whenReady();
|
|
231
|
+
await this.attachElectronSecurityToken(port);
|
|
232
|
+
await this.startContributions();
|
|
233
|
+
|
|
234
|
+
this.handleMainCommand({
|
|
235
|
+
file: args.file,
|
|
236
|
+
cwd: process.cwd(),
|
|
237
|
+
secondInstance: false
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
).parse();
|
|
230
241
|
}
|
|
231
242
|
|
|
232
243
|
protected getTitleBarStyle(config: FrontendApplicationConfig): 'native' | 'custom' {
|
|
@@ -288,15 +299,6 @@ export class ElectronMainApplication {
|
|
|
288
299
|
}
|
|
289
300
|
}
|
|
290
301
|
|
|
291
|
-
protected async launch(params: ElectronMainExecutionParams): Promise<void> {
|
|
292
|
-
createYargs(params.argv, params.cwd)
|
|
293
|
-
.command('$0 [file]', false,
|
|
294
|
-
cmd => cmd
|
|
295
|
-
.positional('file', { type: 'string' }),
|
|
296
|
-
args => this.handleMainCommand(params, { file: args.file }),
|
|
297
|
-
).parse();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
302
|
/**
|
|
301
303
|
* Use this rather than creating `BrowserWindow` instances from scratch, since some security parameters need to be set, this method will do it.
|
|
302
304
|
*
|
|
@@ -395,7 +397,7 @@ export class ElectronMainApplication {
|
|
|
395
397
|
electronWindow.webContents.setWindowOpenHandler(() => {
|
|
396
398
|
const { minWidth, minHeight } = this.getDefaultOptions();
|
|
397
399
|
const options: BrowserWindowConstructorOptions = {
|
|
398
|
-
...this.
|
|
400
|
+
...this.getDefaultTheiaSecondaryWindowBounds(),
|
|
399
401
|
// We always need the native window frame for now because the secondary window does not have Theia's title bar by default.
|
|
400
402
|
// In 'custom' title bar mode this would leave the window without any window controls (close, min, max)
|
|
401
403
|
// TODO set to this.useNativeWindowFrame when secondary windows support a custom title bar.
|
|
@@ -422,15 +424,15 @@ export class ElectronMainApplication {
|
|
|
422
424
|
app.quit();
|
|
423
425
|
}
|
|
424
426
|
|
|
425
|
-
protected async handleMainCommand(
|
|
426
|
-
if (
|
|
427
|
+
protected async handleMainCommand(options: ElectronMainCommandOptions): Promise<void> {
|
|
428
|
+
if (options.secondInstance === false) {
|
|
427
429
|
await this.openWindowWithWorkspace(''); // restore previous workspace.
|
|
428
430
|
} else if (options.file === undefined) {
|
|
429
431
|
await this.openDefaultWindow();
|
|
430
432
|
} else {
|
|
431
433
|
let workspacePath: string | undefined;
|
|
432
434
|
try {
|
|
433
|
-
workspacePath = await fs.realpath(path.resolve(
|
|
435
|
+
workspacePath = await fs.realpath(path.resolve(options.cwd, options.file));
|
|
434
436
|
} catch {
|
|
435
437
|
console.error(`Could not resolve the workspace path. "${options.file}" is not a valid 'file' option. Falling back to the default workspace location.`);
|
|
436
438
|
}
|
|
@@ -461,6 +463,10 @@ export class ElectronMainApplication {
|
|
|
461
463
|
};
|
|
462
464
|
}
|
|
463
465
|
|
|
466
|
+
protected getDefaultTheiaSecondaryWindowBounds(): TheiaBrowserWindowOptions {
|
|
467
|
+
return {};
|
|
468
|
+
}
|
|
469
|
+
|
|
464
470
|
protected getDefaultTheiaWindowBounds(): TheiaBrowserWindowOptions {
|
|
465
471
|
// The `screen` API must be required when the application is ready.
|
|
466
472
|
// See: https://electronjs.org/docs/api/screen#screen
|
|
@@ -645,9 +651,8 @@ export class ElectronMainApplication {
|
|
|
645
651
|
if (wrapper) {
|
|
646
652
|
const listener = wrapper.onDidClose(async () => {
|
|
647
653
|
listener.dispose();
|
|
648
|
-
await this.
|
|
654
|
+
await this.handleMainCommand({
|
|
649
655
|
secondInstance: false,
|
|
650
|
-
argv: this.processArgv.getProcessArgvWithoutBin(process.argv),
|
|
651
656
|
cwd: process.cwd()
|
|
652
657
|
});
|
|
653
658
|
this.restarting = false;
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
|
|
17
17
|
import { WebContents } from '@theia/electron/shared/electron';
|
|
18
18
|
import { inject, injectable, named, postConstruct } from 'inversify';
|
|
19
|
-
import {
|
|
20
|
-
import { MessagingContribution } from '../../node/messaging/messaging-contribution';
|
|
21
|
-
import { ElectronConnectionHandler } from '../../electron-common/messaging/electron-connection-handler';
|
|
22
|
-
import { ElectronMainApplicationContribution } from '../electron-main-application';
|
|
23
|
-
import { ElectronMessagingService } from './electron-messaging-service';
|
|
19
|
+
import { ConnectionHandlers } from '../../node/messaging/default-messaging-service';
|
|
24
20
|
import { AbstractChannel, Channel, ChannelMultiplexer, MessageProvider } from '../../common/message-rpc/channel';
|
|
25
|
-
import { ConnectionHandler, Emitter, WriteBuffer } from '../../common';
|
|
21
|
+
import { ConnectionHandler, ContributionProvider, Emitter, WriteBuffer } from '../../common';
|
|
26
22
|
import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '../../common/message-rpc/uint8-array-message-buffer';
|
|
27
23
|
import { TheiaRendererAPI } from '../electron-api-main';
|
|
24
|
+
import { MessagingService } from '../../node';
|
|
25
|
+
import { ElectronMessagingService } from './electron-messaging-service';
|
|
26
|
+
import { ElectronConnectionHandler } from './electron-connection-handler';
|
|
27
|
+
import { ElectronMainApplicationContribution } from '../electron-main-application';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* This component replicates the role filled by `MessagingContribution` but for Electron.
|
|
@@ -36,37 +36,54 @@ import { TheiaRendererAPI } from '../electron-api-main';
|
|
|
36
36
|
|
|
37
37
|
@injectable()
|
|
38
38
|
export class ElectronMessagingContribution implements ElectronMainApplicationContribution, ElectronMessagingService {
|
|
39
|
-
|
|
40
39
|
@inject(ContributionProvider) @named(ElectronMessagingService.Contribution)
|
|
41
40
|
protected readonly messagingContributions: ContributionProvider<ElectronMessagingService.Contribution>;
|
|
42
41
|
|
|
43
42
|
@inject(ContributionProvider) @named(ElectronConnectionHandler)
|
|
44
43
|
protected readonly connectionHandlers: ContributionProvider<ConnectionHandler>;
|
|
45
44
|
|
|
46
|
-
protected readonly channelHandlers = new
|
|
45
|
+
protected readonly channelHandlers = new ConnectionHandlers<Channel>();
|
|
46
|
+
|
|
47
47
|
/**
|
|
48
48
|
* Each electron window has a main channel and its own multiplexer to route multiple client messages the same IPC connection.
|
|
49
49
|
*/
|
|
50
|
-
protected readonly
|
|
50
|
+
protected readonly openChannels = new Map<number, ElectronWebContentChannel>();
|
|
51
51
|
|
|
52
52
|
@postConstruct()
|
|
53
53
|
protected init(): void {
|
|
54
54
|
TheiaRendererAPI.onIpcData((sender, data) => this.handleIpcEvent(sender, data));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
ipcChannel(spec: string, callback: (params: any, channel: Channel) => void): void {
|
|
59
|
+
this.channelHandlers.push(spec, callback);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onStart(): void {
|
|
63
|
+
for (const contribution of this.messagingContributions.getContributions()) {
|
|
64
|
+
contribution.configure(this);
|
|
65
|
+
}
|
|
66
|
+
for (const connectionHandler of this.connectionHandlers.getContributions()) {
|
|
67
|
+
this.channelHandlers.push(connectionHandler.path, (params, channel) => {
|
|
68
|
+
connectionHandler.onConnection(channel);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
57
73
|
protected handleIpcEvent(sender: WebContents, data: Uint8Array): void {
|
|
58
74
|
// Get the multiplexer for a given window id
|
|
59
75
|
try {
|
|
60
|
-
const
|
|
61
|
-
|
|
76
|
+
const windowChannel = this.openChannels.get(sender.id) ?? this.createWindowChannel(sender);
|
|
77
|
+
windowChannel.onMessageEmitter.fire(() => new Uint8ArrayReadBuffer(data));
|
|
62
78
|
} catch (error) {
|
|
63
79
|
console.error('IPC: Failed to handle message', { error, data });
|
|
64
80
|
}
|
|
65
81
|
}
|
|
66
82
|
|
|
67
|
-
// Creates a new
|
|
68
|
-
protected
|
|
69
|
-
const mainChannel =
|
|
83
|
+
// Creates a new channel for a given sender/window
|
|
84
|
+
protected createWindowChannel(sender: Electron.WebContents): ElectronWebContentChannel {
|
|
85
|
+
const mainChannel = new ElectronWebContentChannel(sender);
|
|
86
|
+
|
|
70
87
|
const multiplexer = new ChannelMultiplexer(mainChannel);
|
|
71
88
|
multiplexer.onDidOpenChannel(openEvent => {
|
|
72
89
|
const { channel, id } = openEvent;
|
|
@@ -75,41 +92,26 @@ export class ElectronMessagingContribution implements ElectronMainApplicationCon
|
|
|
75
92
|
channel.onClose(() => console.debug(`Closing channel on service path '${id}'.`));
|
|
76
93
|
}
|
|
77
94
|
});
|
|
78
|
-
|
|
79
|
-
sender.once('
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.windowChannelMultiplexer.set(sender.id, data);
|
|
83
|
-
return data;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Creates the main channel to a window.
|
|
88
|
-
* @param sender The window that the channel should be established to.
|
|
89
|
-
*/
|
|
90
|
-
protected createWindowMainChannel(sender: WebContents): ElectronWebContentChannel {
|
|
91
|
-
return new ElectronWebContentChannel(sender);
|
|
95
|
+
sender.once('did-navigate', () => this.deleteChannel(sender.id, 'Window was refreshed'));
|
|
96
|
+
sender.once('destroyed', () => this.deleteChannel(sender.id, 'Window was closed'));
|
|
97
|
+
this.openChannels.set(sender.id, mainChannel);
|
|
98
|
+
return mainChannel;
|
|
92
99
|
}
|
|
93
100
|
|
|
94
|
-
protected
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
for (const contribution of this.messagingContributions.getContributions()) {
|
|
101
|
-
contribution.configure(this);
|
|
102
|
-
}
|
|
103
|
-
for (const connectionHandler of this.connectionHandlers.getContributions()) {
|
|
104
|
-
this.channelHandlers.push(connectionHandler.path, (params, channel) => {
|
|
105
|
-
connectionHandler.onConnection(channel);
|
|
101
|
+
protected deleteChannel(senderId: number, reason: string): void {
|
|
102
|
+
const channel = this.openChannels.get(senderId);
|
|
103
|
+
if (channel) {
|
|
104
|
+
this.openChannels.delete(senderId);
|
|
105
|
+
channel.onCloseEmitter.fire({
|
|
106
|
+
reason: reason
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
protected readonly wsHandlers = new ConnectionHandlers();
|
|
112
|
+
|
|
113
|
+
registerConnectionHandler(spec: string, callback: (params: MessagingService.PathParams, channel: Channel) => void): void {
|
|
114
|
+
this.wsHandlers.push(spec, callback);
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
|
|
@@ -23,6 +23,7 @@ export interface ElectronMessagingService {
|
|
|
23
23
|
*/
|
|
24
24
|
ipcChannel(path: string, callback: (params: ElectronMessagingService.PathParams, socket: Channel) => void): void;
|
|
25
25
|
}
|
|
26
|
+
|
|
26
27
|
export namespace ElectronMessagingService {
|
|
27
28
|
export interface PathParams {
|
|
28
29
|
[name: string]: string
|
|
@@ -129,8 +129,9 @@ export class TheiaElectronWindow {
|
|
|
129
129
|
}, this.toDispose);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
protected doCloseWindow(): void {
|
|
132
|
+
protected async doCloseWindow(): Promise<void> {
|
|
133
133
|
this.closeIsConfirmed = true;
|
|
134
|
+
await TheiaRendererAPI.sendAboutToClose(this._window.webContents);
|
|
134
135
|
this._window.close();
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -139,13 +140,13 @@ export class TheiaElectronWindow {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
protected reload(): void {
|
|
142
|
-
this.handleStopRequest(() => {
|
|
143
|
+
this.handleStopRequest(async () => {
|
|
143
144
|
this.applicationState = 'init';
|
|
144
145
|
this._window.reload();
|
|
145
146
|
}, StopReason.Reload);
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
protected async handleStopRequest(onSafeCallback: () => unknown
|
|
149
|
+
protected async handleStopRequest(onSafeCallback: () => Promise<unknown>, reason: StopReason): Promise<boolean> {
|
|
149
150
|
// Only confirm close to windows that have loaded our frontend.
|
|
150
151
|
// Both the windows's URL and the FS path of the `index.html` should be converted to the "same" format to be able to compare them. (#11226)
|
|
151
152
|
// Notes:
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox 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, inject, named, interfaces, Container } from 'inversify';
|
|
18
|
+
import { ContributionProvider, ConnectionHandler, bindContributionProvider, servicesPath } from '../../common';
|
|
19
|
+
import { MessagingService } from './messaging-service';
|
|
20
|
+
import { ConnectionContainerModule } from './connection-container-module';
|
|
21
|
+
import Route = require('route-parser');
|
|
22
|
+
import { Channel, ChannelMultiplexer } from '../../common/message-rpc/channel';
|
|
23
|
+
import { FrontendConnectionService } from './frontend-connection-service';
|
|
24
|
+
import { BackendApplicationContribution } from '../backend-application';
|
|
25
|
+
|
|
26
|
+
export const MessagingContainer = Symbol('MessagingContainer');
|
|
27
|
+
export const MainChannel = Symbol('MainChannel');
|
|
28
|
+
|
|
29
|
+
@injectable()
|
|
30
|
+
export class DefaultMessagingService implements MessagingService, BackendApplicationContribution {
|
|
31
|
+
@inject(MessagingContainer)
|
|
32
|
+
protected readonly container: interfaces.Container;
|
|
33
|
+
|
|
34
|
+
@inject(FrontendConnectionService)
|
|
35
|
+
protected readonly frontendConnectionService: FrontendConnectionService;
|
|
36
|
+
|
|
37
|
+
@inject(ContributionProvider) @named(ConnectionContainerModule)
|
|
38
|
+
protected readonly connectionModules: ContributionProvider<interfaces.ContainerModule>;
|
|
39
|
+
|
|
40
|
+
@inject(ContributionProvider) @named(MessagingService.Contribution)
|
|
41
|
+
protected readonly contributions: ContributionProvider<MessagingService.Contribution>;
|
|
42
|
+
|
|
43
|
+
protected readonly channelHandlers = new ConnectionHandlers<Channel>();
|
|
44
|
+
|
|
45
|
+
initialize(): void {
|
|
46
|
+
this.registerConnectionHandler(servicesPath, (_, socket) => this.handleConnection(socket));
|
|
47
|
+
for (const contribution of this.contributions.getContributions()) {
|
|
48
|
+
contribution.configure(this);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
registerConnectionHandler(path: string, callback: (params: MessagingService.PathParams, mainChannel: Channel) => void): void {
|
|
53
|
+
this.frontendConnectionService.registerConnectionHandler(path, callback);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
registerChannelHandler(spec: string, callback: (params: MessagingService.PathParams, channel: Channel) => void): void {
|
|
57
|
+
this.channelHandlers.push(spec, (params, channel) => callback(params, channel));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected handleConnection(channel: Channel): void {
|
|
61
|
+
const multiplexer = new ChannelMultiplexer(channel);
|
|
62
|
+
const channelHandlers = this.getConnectionChannelHandlers(channel);
|
|
63
|
+
multiplexer.onDidOpenChannel(event => {
|
|
64
|
+
if (channelHandlers.route(event.id, event.channel)) {
|
|
65
|
+
console.debug(`Opening channel for service path '${event.id}'.`);
|
|
66
|
+
event.channel.onClose(() => console.info(`Closing channel on service path '${event.id}'.`));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected createMainChannelContainer(socket: Channel): Container {
|
|
72
|
+
const connectionContainer: Container = this.container.createChild() as Container;
|
|
73
|
+
connectionContainer.bind(MainChannel).toConstantValue(socket);
|
|
74
|
+
return connectionContainer;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected getConnectionChannelHandlers(socket: Channel): ConnectionHandlers<Channel> {
|
|
78
|
+
const connectionContainer = this.createMainChannelContainer(socket);
|
|
79
|
+
bindContributionProvider(connectionContainer, ConnectionHandler);
|
|
80
|
+
connectionContainer.load(...this.connectionModules.getContributions());
|
|
81
|
+
const connectionChannelHandlers = new ConnectionHandlers<Channel>(this.channelHandlers);
|
|
82
|
+
const connectionHandlers = connectionContainer.getNamed<ContributionProvider<ConnectionHandler>>(ContributionProvider, ConnectionHandler);
|
|
83
|
+
for (const connectionHandler of connectionHandlers.getContributions(true)) {
|
|
84
|
+
connectionChannelHandlers.push(connectionHandler.path, (_, channel) => {
|
|
85
|
+
connectionHandler.onConnection(channel);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return connectionChannelHandlers;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class ConnectionHandlers<T> {
|
|
94
|
+
protected readonly handlers: ((path: string, connection: T) => string | false)[] = [];
|
|
95
|
+
|
|
96
|
+
constructor(
|
|
97
|
+
protected readonly parent?: ConnectionHandlers<T>
|
|
98
|
+
) { }
|
|
99
|
+
|
|
100
|
+
push(spec: string, callback: (params: MessagingService.PathParams, connection: T) => void): void {
|
|
101
|
+
const route = new Route(spec);
|
|
102
|
+
const handler = (path: string, channel: T): string | false => {
|
|
103
|
+
const params = route.match(path);
|
|
104
|
+
if (!params) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
callback(params, channel);
|
|
108
|
+
return route.reverse(params);
|
|
109
|
+
};
|
|
110
|
+
this.handlers.push(handler);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
route(path: string, connection: T): string | false {
|
|
114
|
+
for (const handler of this.handlers) {
|
|
115
|
+
try {
|
|
116
|
+
const result = handler(path, connection);
|
|
117
|
+
if (result) {
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
} catch (e) {
|
|
121
|
+
console.error(e);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (this.parent) {
|
|
125
|
+
return this.parent.route(path, connection);
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import { Channel } from '../../common/message-rpc/';
|
|
17
|
+
import { MessagingService } from './messaging-service';
|
|
18
|
+
|
|
19
|
+
export const FrontendConnectionService = Symbol('FrontendConnectionService');
|
|
20
|
+
|
|
21
|
+
export interface FrontendConnectionService {
|
|
22
|
+
registerConnectionHandler(path: string, callback: (params: MessagingService.PathParams, mainChannel: Channel) => void): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -15,23 +15,38 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { ContainerModule } from 'inversify';
|
|
18
|
-
import { bindContributionProvider } from '../../common';
|
|
19
|
-
import { BackendApplicationContribution } from '../backend-application';
|
|
20
|
-
import {
|
|
18
|
+
import { ConnectionHandler, RpcConnectionHandler, bindContributionProvider } from '../../common';
|
|
19
|
+
// import { BackendApplicationContribution } from '../backend-application';
|
|
20
|
+
import { DefaultMessagingService, MessagingContainer } from './default-messaging-service';
|
|
21
21
|
import { ConnectionContainerModule } from './connection-container-module';
|
|
22
22
|
import { MessagingService } from './messaging-service';
|
|
23
23
|
import { MessagingListener, MessagingListenerContribution } from './messaging-listeners';
|
|
24
|
+
import { FrontendConnectionService } from './frontend-connection-service';
|
|
25
|
+
import { BackendApplicationContribution } from '../backend-application';
|
|
26
|
+
import { connectionCloseServicePath } from '../../common/messaging/connection-management';
|
|
27
|
+
import { WebsocketFrontendConnectionService } from './websocket-frontend-connection-service';
|
|
28
|
+
import { WebsocketEndpoint } from './websocket-endpoint';
|
|
24
29
|
|
|
25
30
|
export const messagingBackendModule = new ContainerModule(bind => {
|
|
26
31
|
bindContributionProvider(bind, ConnectionContainerModule);
|
|
27
32
|
bindContributionProvider(bind, MessagingService.Contribution);
|
|
28
|
-
bind(
|
|
29
|
-
bind(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
bind(
|
|
33
|
+
bind(DefaultMessagingService).toSelf().inSingletonScope();
|
|
34
|
+
bind(MessagingService.Identifier).toService(DefaultMessagingService);
|
|
35
|
+
bind(BackendApplicationContribution).toService(DefaultMessagingService);
|
|
36
|
+
bind(MessagingContainer).toDynamicValue(({ container }) => container).inSingletonScope();
|
|
37
|
+
bind(WebsocketEndpoint).toSelf().inSingletonScope();
|
|
38
|
+
bind(BackendApplicationContribution).toService(WebsocketEndpoint);
|
|
39
|
+
bind(WebsocketFrontendConnectionService).toSelf().inSingletonScope();
|
|
40
|
+
bind(FrontendConnectionService).toService(WebsocketFrontendConnectionService);
|
|
35
41
|
bind(MessagingListener).toSelf().inSingletonScope();
|
|
36
42
|
bindContributionProvider(bind, MessagingListenerContribution);
|
|
43
|
+
|
|
44
|
+
bind(ConnectionHandler).toDynamicValue(context => {
|
|
45
|
+
const connectionService = context.container.get<WebsocketFrontendConnectionService>(FrontendConnectionService);
|
|
46
|
+
return new RpcConnectionHandler<object>(connectionCloseServicePath, () => ({
|
|
47
|
+
markForClose: (channelId: string) => {
|
|
48
|
+
connectionService.markForClose(channelId);
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
}).inSingletonScope();
|
|
37
52
|
});
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { Socket } from 'socket.io';
|
|
18
17
|
import { Channel } from '../../common/message-rpc/channel';
|
|
19
18
|
|
|
20
19
|
export interface MessagingService {
|
|
@@ -22,7 +21,7 @@ export interface MessagingService {
|
|
|
22
21
|
* Accept a web socket channel on the given path.
|
|
23
22
|
* A path supports the route syntax: https://github.com/rcs/route-parser#what-can-i-use-in-my-routes.
|
|
24
23
|
*/
|
|
25
|
-
|
|
24
|
+
registerChannelHandler(path: string, handler: (params: MessagingService.PathParams, channel: Channel) => void): void;
|
|
26
25
|
/**
|
|
27
26
|
* Accept a web socket connection on the given path.
|
|
28
27
|
* A path supports the route syntax: https://github.com/rcs/route-parser#what-can-i-use-in-my-routes.
|
|
@@ -31,8 +30,9 @@ export interface MessagingService {
|
|
|
31
30
|
* Prefer using web socket channels over establishing new web socket connection. Clients can handle only limited amount of web sockets
|
|
32
31
|
* and excessive amount can cause performance degradation. All web socket channels share a single web socket connection.
|
|
33
32
|
*/
|
|
34
|
-
|
|
33
|
+
registerConnectionHandler(path: string, callback: (params: MessagingService.PathParams, mainChannel: Channel) => void): void;
|
|
35
34
|
}
|
|
35
|
+
|
|
36
36
|
export namespace MessagingService {
|
|
37
37
|
/** Inversify container identifier for the `MessagingService` component. */
|
|
38
38
|
export const Identifier = Symbol('MessagingService');
|