@theia/core 1.26.0 → 1.27.0-next.10
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 -7
- package/lib/browser/messaging/ws-connection-provider.d.ts +5 -4
- package/lib/browser/messaging/ws-connection-provider.d.ts.map +1 -1
- package/lib/browser/messaging/ws-connection-provider.js +30 -23
- package/lib/browser/messaging/ws-connection-provider.js.map +1 -1
- package/lib/browser/progress-status-bar-item.d.ts +1 -1
- package/lib/browser/progress-status-bar-item.d.ts.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-widget.js +2 -2
- package/lib/browser/tree/tree-compression/compressed-tree-widget.js.map +1 -1
- package/lib/browser/widgets/select-component.d.ts +4 -1
- package/lib/browser/widgets/select-component.d.ts.map +1 -1
- package/lib/browser/widgets/select-component.js +30 -16
- package/lib/browser/widgets/select-component.js.map +1 -1
- package/lib/common/cancellation.d.ts +1 -0
- package/lib/common/cancellation.d.ts.map +1 -1
- package/lib/common/cancellation.js +8 -0
- package/lib/common/cancellation.js.map +1 -1
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +2 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/message-rpc/channel.d.ts +106 -0
- package/lib/common/message-rpc/channel.d.ts.map +1 -0
- package/lib/common/message-rpc/channel.js +195 -0
- package/lib/common/message-rpc/channel.js.map +1 -0
- package/lib/common/message-rpc/channel.spec.d.ts +9 -0
- package/lib/common/message-rpc/channel.spec.d.ts.map +1 -0
- package/lib/common/message-rpc/channel.spec.js +80 -0
- package/lib/common/message-rpc/channel.spec.js.map +1 -0
- package/lib/common/message-rpc/index.d.ts +4 -0
- package/lib/common/message-rpc/index.d.ts.map +1 -0
- package/lib/{node/messaging/logger.js → common/message-rpc/index.js} +6 -19
- package/lib/common/message-rpc/index.js.map +1 -0
- package/lib/common/message-rpc/message-buffer.d.ts +50 -0
- package/lib/common/message-rpc/message-buffer.d.ts.map +1 -0
- package/lib/common/message-rpc/message-buffer.js +56 -0
- package/lib/common/message-rpc/message-buffer.js.map +1 -0
- package/lib/common/message-rpc/rpc-message-encoder.d.ts +159 -0
- package/lib/common/message-rpc/rpc-message-encoder.d.ts.map +1 -0
- package/lib/common/message-rpc/rpc-message-encoder.js +362 -0
- package/lib/common/message-rpc/rpc-message-encoder.js.map +1 -0
- package/lib/common/message-rpc/rpc-message-encoder.spec.d.ts +2 -0
- package/lib/common/message-rpc/rpc-message-encoder.spec.d.ts.map +1 -0
- package/lib/common/message-rpc/rpc-message-encoder.spec.js +37 -0
- package/lib/common/message-rpc/rpc-message-encoder.spec.js.map +1 -0
- package/lib/common/message-rpc/rpc-protocol.d.ts +61 -0
- package/lib/common/message-rpc/rpc-protocol.d.ts.map +1 -0
- package/lib/common/message-rpc/rpc-protocol.js +183 -0
- package/lib/common/message-rpc/rpc-protocol.js.map +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.d.ts +52 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.d.ts.map +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.js +169 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.js.map +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.spec.d.ts +2 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.spec.d.ts.map +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.spec.js +39 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.spec.js.map +1 -0
- package/lib/common/messaging/abstract-connection-provider.d.ts +9 -8
- package/lib/common/messaging/abstract-connection-provider.d.ts.map +1 -1
- package/lib/common/messaging/abstract-connection-provider.js +20 -35
- package/lib/common/messaging/abstract-connection-provider.js.map +1 -1
- package/lib/common/messaging/connection-error-handler.d.ts +1 -2
- package/lib/common/messaging/connection-error-handler.d.ts.map +1 -1
- package/lib/common/messaging/connection-error-handler.js +1 -1
- package/lib/common/messaging/connection-error-handler.js.map +1 -1
- package/lib/common/messaging/handler.d.ts +2 -2
- package/lib/common/messaging/handler.d.ts.map +1 -1
- package/lib/common/messaging/proxy-factory.d.ts +13 -7
- package/lib/common/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/common/messaging/proxy-factory.js +18 -13
- package/lib/common/messaging/proxy-factory.js.map +1 -1
- package/lib/common/messaging/proxy-factory.spec.js +4 -15
- package/lib/common/messaging/proxy-factory.spec.js.map +1 -1
- package/lib/common/messaging/web-socket-channel.d.ts +54 -48
- package/lib/common/messaging/web-socket-channel.d.ts.map +1 -1
- package/lib/common/messaging/web-socket-channel.js +41 -105
- package/lib/common/messaging/web-socket-channel.js.map +1 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts +2 -2
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.js +18 -7
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.js.map +1 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts +2 -2
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.js +5 -7
- package/lib/electron-browser/messaging/electron-ws-connection-provider.js.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +37 -9
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-contribution.js +83 -68
- package/lib/electron-main/messaging/electron-messaging-contribution.js.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-service.d.ts +2 -8
- 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.map +1 -1
- package/lib/electron-main/theia-electron-window.js +11 -8
- package/lib/electron-main/theia-electron-window.js.map +1 -1
- package/lib/node/messaging/binary-message-pipe.d.ts +45 -0
- package/lib/node/messaging/binary-message-pipe.d.ts.map +1 -0
- package/lib/node/messaging/binary-message-pipe.js +152 -0
- package/lib/node/messaging/binary-message-pipe.js.map +1 -0
- package/lib/node/messaging/ipc-bootstrap.js +2 -11
- package/lib/node/messaging/ipc-bootstrap.js.map +1 -1
- package/lib/node/messaging/ipc-channel.d.ts +26 -0
- package/lib/node/messaging/ipc-channel.d.ts.map +1 -0
- package/lib/node/messaging/ipc-channel.js +86 -0
- package/lib/node/messaging/ipc-channel.js.map +1 -0
- package/lib/node/messaging/ipc-connection-provider.d.ts +3 -5
- package/lib/node/messaging/ipc-connection-provider.d.ts.map +1 -1
- package/lib/node/messaging/ipc-connection-provider.js +14 -31
- package/lib/node/messaging/ipc-connection-provider.js.map +1 -1
- package/lib/node/messaging/ipc-protocol.d.ts +2 -2
- package/lib/node/messaging/ipc-protocol.d.ts.map +1 -1
- package/lib/node/messaging/messaging-contribution.d.ts +6 -9
- package/lib/node/messaging/messaging-contribution.d.ts.map +1 -1
- package/lib/node/messaging/messaging-contribution.js +23 -68
- package/lib/node/messaging/messaging-contribution.js.map +1 -1
- package/lib/node/messaging/messaging-service.d.ts +4 -23
- package/lib/node/messaging/messaging-service.d.ts.map +1 -1
- package/lib/node/messaging/messaging-service.js +1 -15
- package/lib/node/messaging/messaging-service.js.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.d.ts +4 -2
- package/lib/node/messaging/test/test-web-socket-channel.d.ts.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.js +25 -12
- package/lib/node/messaging/test/test-web-socket-channel.js.map +1 -1
- package/package.json +5 -8
- package/src/browser/messaging/ws-connection-provider.ts +34 -25
- package/src/browser/progress-status-bar-item.ts +1 -1
- package/src/browser/style/menus.css +1 -0
- package/src/browser/tree/tree-compression/compressed-tree-widget.tsx +2 -2
- package/src/browser/widgets/select-component.tsx +37 -17
- package/src/common/cancellation.ts +8 -0
- package/src/common/index.ts +2 -0
- package/src/common/message-rpc/channel.spec.ts +88 -0
- package/src/common/message-rpc/channel.ts +260 -0
- package/src/{node/messaging/logger.ts → common/message-rpc/index.ts} +4 -23
- package/src/common/message-rpc/message-buffer.ts +99 -0
- package/src/common/message-rpc/rpc-message-encoder.spec.ts +42 -0
- package/src/common/message-rpc/rpc-message-encoder.ts +497 -0
- package/src/common/message-rpc/rpc-protocol.ts +217 -0
- package/src/common/message-rpc/uint8-array-message-buffer.spec.ts +41 -0
- package/src/common/message-rpc/uint8-array-message-buffer.ts +206 -0
- package/src/common/messaging/abstract-connection-provider.ts +28 -37
- package/src/common/messaging/connection-error-handler.ts +1 -2
- package/src/common/messaging/handler.ts +2 -2
- package/src/common/messaging/proxy-factory.spec.ts +4 -17
- package/src/common/messaging/proxy-factory.ts +27 -16
- package/src/common/messaging/web-socket-channel.ts +79 -135
- package/src/electron-browser/messaging/electron-ipc-connection-provider.ts +21 -7
- package/src/electron-browser/messaging/electron-ws-connection-provider.ts +5 -8
- package/src/electron-main/messaging/electron-messaging-contribution.ts +87 -65
- package/src/electron-main/messaging/electron-messaging-service.ts +2 -8
- package/src/electron-main/theia-electron-window.ts +12 -9
- package/src/node/messaging/binary-message-pipe.ts +168 -0
- package/src/node/messaging/ipc-bootstrap.ts +3 -11
- package/src/node/messaging/ipc-channel.ts +97 -0
- package/src/node/messaging/ipc-connection-provider.ts +18 -35
- package/src/node/messaging/ipc-protocol.ts +2 -2
- package/src/node/messaging/messaging-contribution.ts +29 -74
- package/src/node/messaging/messaging-service.ts +4 -31
- package/src/node/messaging/test/test-web-socket-channel.ts +26 -17
- package/lib/node/messaging/logger.d.ts +0 -8
- package/lib/node/messaging/logger.d.ts.map +0 -1
- package/lib/node/messaging/logger.js.map +0 -1
- package/shared/vscode-ws-jsonrpc/index.d.ts +0 -1
- package/shared/vscode-ws-jsonrpc/index.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { interfaces } from 'inversify';
|
|
2
2
|
import { JsonRpcProxy } from '../../common/messaging';
|
|
3
|
-
import { WebSocketChannel } from '../../common/messaging/web-socket-channel';
|
|
4
3
|
import { AbstractConnectionProvider } from '../../common/messaging/abstract-connection-provider';
|
|
4
|
+
import { Channel } from '../../common/message-rpc/channel';
|
|
5
5
|
export interface ElectronIpcOptions {
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
@@ -10,6 +10,6 @@ export interface ElectronIpcOptions {
|
|
|
10
10
|
export declare class ElectronIpcConnectionProvider extends AbstractConnectionProvider<ElectronIpcOptions> {
|
|
11
11
|
static createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): JsonRpcProxy<T>;
|
|
12
12
|
constructor();
|
|
13
|
-
protected
|
|
13
|
+
protected createMainChannel(): Channel;
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=electron-ipc-connection-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-ipc-connection-provider.d.ts","sourceRoot":"","sources":["../../../src/electron-browser/messaging/electron-ipc-connection-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAc,UAAU,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"electron-ipc-connection-provider.d.ts","sourceRoot":"","sources":["../../../src/electron-browser/messaging/electron-ipc-connection-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAc,UAAU,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AAIjG,OAAO,EAAE,OAAO,EAAmB,MAAM,kCAAkC,CAAC;AAE5E,MAAM,WAAW,kBAAkB;CAClC;AAED;;GAEG;AACH,qBACa,6BAA8B,SAAQ,0BAA0B,CAAC,kBAAkB,CAAC;WAE7E,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC;;IAS3H,SAAS,CAAC,iBAAiB,IAAI,OAAO;CAoBzC"}
|
|
@@ -28,9 +28,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
28
|
exports.ElectronIpcConnectionProvider = void 0;
|
|
29
29
|
const electron_1 = require("@theia/electron/shared/electron");
|
|
30
30
|
const inversify_1 = require("inversify");
|
|
31
|
-
const web_socket_channel_1 = require("../../common/messaging/web-socket-channel");
|
|
32
31
|
const abstract_connection_provider_1 = require("../../common/messaging/abstract-connection-provider");
|
|
33
32
|
const electron_connection_handler_1 = require("../../electron-common/messaging/electron-connection-handler");
|
|
33
|
+
const common_1 = require("../../common");
|
|
34
|
+
const uint8_array_message_buffer_1 = require("../../common/message-rpc/uint8-array-message-buffer");
|
|
34
35
|
/**
|
|
35
36
|
* Connection provider between the Theia frontend and the electron-main process via IPC.
|
|
36
37
|
*/
|
|
@@ -40,14 +41,24 @@ let ElectronIpcConnectionProvider = ElectronIpcConnectionProvider_1 = class Elec
|
|
|
40
41
|
}
|
|
41
42
|
constructor() {
|
|
42
43
|
super();
|
|
43
|
-
|
|
44
|
-
this.handleIncomingRawMessage(data);
|
|
45
|
-
});
|
|
44
|
+
this.initializeMultiplexer();
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
createMainChannel() {
|
|
47
|
+
const onMessageEmitter = new common_1.Emitter();
|
|
48
|
+
electron_1.ipcRenderer.on(electron_connection_handler_1.THEIA_ELECTRON_IPC_CHANNEL_NAME, (_event, data) => {
|
|
49
|
+
onMessageEmitter.fire(() => new uint8_array_message_buffer_1.Uint8ArrayReadBuffer(data));
|
|
50
50
|
});
|
|
51
|
+
return {
|
|
52
|
+
close: () => common_1.Event.None,
|
|
53
|
+
getWriteBuffer: () => {
|
|
54
|
+
const writer = new uint8_array_message_buffer_1.Uint8ArrayWriteBuffer();
|
|
55
|
+
writer.onCommit(buffer => electron_1.ipcRenderer.send(electron_connection_handler_1.THEIA_ELECTRON_IPC_CHANNEL_NAME, buffer));
|
|
56
|
+
return writer;
|
|
57
|
+
},
|
|
58
|
+
onClose: common_1.Event.None,
|
|
59
|
+
onError: common_1.Event.None,
|
|
60
|
+
onMessage: onMessageEmitter.event
|
|
61
|
+
};
|
|
51
62
|
}
|
|
52
63
|
};
|
|
53
64
|
ElectronIpcConnectionProvider = ElectronIpcConnectionProvider_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-ipc-connection-provider.js","sourceRoot":"","sources":["../../../src/electron-browser/messaging/electron-ipc-connection-provider.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;;;;;AAEhF,8DAAsF;AACtF,yCAAmD;AAEnD,
|
|
1
|
+
{"version":3,"file":"electron-ipc-connection-provider.js","sourceRoot":"","sources":["../../../src/electron-browser/messaging/electron-ipc-connection-provider.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;;;;;AAEhF,8DAAsF;AACtF,yCAAmD;AAEnD,sGAAiG;AACjG,6GAA8G;AAC9G,yCAA8C;AAC9C,oGAAkH;AAMlH;;GAEG;AAEH,IAAa,6BAA6B,qCAA1C,MAAa,6BAA8B,SAAQ,yDAA8C;IAE7F,MAAM,CAAU,WAAW,CAAmB,SAA+B,EAAE,IAAY,EAAE,GAAY;QACrG,OAAO,SAAS,CAAC,GAAG,CAAC,+BAA6B,CAAC,CAAC,WAAW,CAAI,IAAI,EAAE,GAAG,CAAC,CAAC;IAClF,CAAC;IAED;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACjC,CAAC;IAES,iBAAiB;QACvB,MAAM,gBAAgB,GAAG,IAAI,gBAAO,EAAmB,CAAC;QACxD,sBAAW,CAAC,EAAE,CAAC,6DAA+B,EAAE,CAAC,MAAqB,EAAE,IAAgB,EAAE,EAAE;YACxF,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,iDAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;QACH,OAAO;YACH,KAAK,EAAE,GAAG,EAAE,CAAC,cAAK,CAAC,IAAI;YACvB,cAAc,EAAE,GAAG,EAAE;gBACjB,MAAM,MAAM,GAAG,IAAI,kDAAqB,EAAE,CAAC;gBAC3C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CACrB,sBAAW,CAAC,IAAI,CAAC,6DAA+B,EAAE,MAAM,CAAC,CAC5D,CAAC;gBACF,OAAO,MAAM,CAAC;YAClB,CAAC;YACD,OAAO,EAAE,cAAK,CAAC,IAAI;YACnB,OAAO,EAAE,cAAK,CAAC,IAAI;YACnB,SAAS,EAAE,gBAAgB,CAAC,KAAK;SACpC,CAAC;IACN,CAAC;CAEJ,CAAA;AA/BY,6BAA6B;IADzC,IAAA,sBAAU,GAAE;;GACA,6BAA6B,CA+BzC;AA/BY,sEAA6B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WebSocketChannel } from '../../common/messaging/web-socket-channel';
|
|
2
1
|
import { WebSocketConnectionProvider, WebSocketOptions } from '../../browser/messaging/ws-connection-provider';
|
|
3
2
|
import { FrontendApplicationContribution } from '../../browser/frontend-application';
|
|
3
|
+
import { Channel } from '../../common';
|
|
4
4
|
/**
|
|
5
5
|
* Customized connection provider between the frontend and the backend in electron environment.
|
|
6
6
|
* This customized connection provider makes sure the websocket connection does not try to reconnect
|
|
@@ -12,6 +12,6 @@ export declare class ElectronWebSocketConnectionProvider extends WebSocketConnec
|
|
|
12
12
|
*/
|
|
13
13
|
protected stopping: boolean;
|
|
14
14
|
onStop(): void;
|
|
15
|
-
openChannel(path: string, handler: (channel:
|
|
15
|
+
openChannel(path: string, handler: (channel: Channel) => void, options?: WebSocketOptions): Promise<void>;
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=electron-ws-connection-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-ws-connection-provider.d.ts","sourceRoot":"","sources":["../../../src/electron-browser/messaging/electron-ws-connection-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"electron-ws-connection-provider.d.ts","sourceRoot":"","sources":["../../../src/electron-browser/messaging/electron-ws-connection-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAC/G,OAAO,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;GAIG;AACH,qBACa,mCAAoC,SAAQ,2BAA4B,YAAW,+BAA+B;IAE3H;;OAEG;IACH,SAAS,CAAC,QAAQ,UAAS;IAE3B,MAAM,IAAI,IAAI;IAQC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAM3H"}
|
|
@@ -38,16 +38,14 @@ let ElectronWebSocketConnectionProvider = class ElectronWebSocketConnectionProvi
|
|
|
38
38
|
this.stopping = false;
|
|
39
39
|
}
|
|
40
40
|
onStop() {
|
|
41
|
+
var _a;
|
|
41
42
|
this.stopping = true;
|
|
42
|
-
//
|
|
43
|
+
// Manually close the websocket connections `onStop`. Otherwise, the channels will be closed with 30 sec (`MessagingContribution#checkAliveTimeout`) delay.
|
|
43
44
|
// https://github.com/eclipse-theia/theia/issues/6499
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// But we cannot use `1001`: https://github.com/TypeFox/vscode-ws-jsonrpc/issues/15
|
|
47
|
-
channel.close(1000, 'The frontend is "going away"...');
|
|
48
|
-
}
|
|
45
|
+
// `1001` indicates that an endpoint is "going away", such as a server going down or a browser having navigated away from a page.
|
|
46
|
+
(_a = this.channelMultiPlexer) === null || _a === void 0 ? void 0 : _a.onUnderlyingChannelClose({ reason: 'The frontend is "going away"', code: 1001 });
|
|
49
47
|
}
|
|
50
|
-
openChannel(path, handler, options) {
|
|
48
|
+
async openChannel(path, handler, options) {
|
|
51
49
|
if (!this.stopping) {
|
|
52
50
|
super.openChannel(path, handler, options);
|
|
53
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-ws-connection-provider.js","sourceRoot":"","sources":["../../../src/electron-browser/messaging/electron-ws-connection-provider.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;AAEhF,yCAAuC;
|
|
1
|
+
{"version":3,"file":"electron-ws-connection-provider.js","sourceRoot":"","sources":["../../../src/electron-browser/messaging/electron-ws-connection-provider.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;AAEhF,yCAAuC;AACvC,2FAA+G;AAI/G;;;;GAIG;AAEH,IAAa,mCAAmC,GAAhD,MAAa,mCAAoC,SAAQ,oDAA2B;IAApF;;QAEI;;WAEG;QACO,aAAQ,GAAG,KAAK,CAAC;IAgB/B,CAAC;IAdG,MAAM;;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,2JAA2J;QAC3J,qDAAqD;QACrD,iIAAiI;QACjI,MAAA,IAAI,CAAC,kBAAkB,0CAAE,wBAAwB,CAAC,EAAE,MAAM,EAAE,8BAA8B,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9G,CAAC;IAEQ,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,OAAmC,EAAE,OAA0B;QACpG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAChB,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7C;IACL,CAAC;CAEJ,CAAA;AArBY,mCAAmC;IAD/C,IAAA,sBAAU,GAAE;GACA,mCAAmC,CAqB/C;AArBY,kFAAmC"}
|
|
@@ -1,29 +1,57 @@
|
|
|
1
1
|
import { IpcMainEvent, WebContents } from '@theia/electron/shared/electron';
|
|
2
|
-
import { MessageConnection } from 'vscode-ws-jsonrpc';
|
|
3
2
|
import { ContributionProvider } from '../../common/contribution-provider';
|
|
4
|
-
import { WebSocketChannel } from '../../common/messaging/web-socket-channel';
|
|
5
3
|
import { MessagingContribution } from '../../node/messaging/messaging-contribution';
|
|
6
4
|
import { ElectronConnectionHandler } from '../../electron-common/messaging/electron-connection-handler';
|
|
7
5
|
import { ElectronMainApplicationContribution } from '../electron-main-application';
|
|
8
6
|
import { ElectronMessagingService } from './electron-messaging-service';
|
|
7
|
+
import { Channel, ChannelCloseEvent, ChannelMultiplexer, MessageProvider } from '../../common/message-rpc/channel';
|
|
8
|
+
import { Emitter, Event, WriteBuffer } from '../../common';
|
|
9
9
|
/**
|
|
10
10
|
* This component replicates the role filled by `MessagingContribution` but for Electron.
|
|
11
11
|
* Unlike the WebSocket based implementation, we do not expect to receive
|
|
12
12
|
* connection events. Instead, we'll create channels based on incoming `open`
|
|
13
13
|
* events on the `ipcMain` channel.
|
|
14
|
-
*
|
|
15
14
|
* This component allows communication between renderer process (frontend) and electron main process.
|
|
16
15
|
*/
|
|
17
16
|
export declare class ElectronMessagingContribution implements ElectronMainApplicationContribution, ElectronMessagingService {
|
|
18
17
|
protected readonly messagingContributions: ContributionProvider<ElectronMessagingService.Contribution>;
|
|
19
18
|
protected readonly connectionHandlers: ContributionProvider<ElectronConnectionHandler>;
|
|
20
|
-
protected readonly channelHandlers: MessagingContribution.ConnectionHandlers<
|
|
21
|
-
|
|
19
|
+
protected readonly channelHandlers: MessagingContribution.ConnectionHandlers<Channel>;
|
|
20
|
+
/**
|
|
21
|
+
* Each electron window has a main chanel and its own multiplexer to route multiple client messages the same IPC connection.
|
|
22
|
+
*/
|
|
23
|
+
protected readonly windowChannelMultiplexer: Map<number, {
|
|
24
|
+
channel: ElectronWebContentChannel;
|
|
25
|
+
multiPlexer: ChannelMultiplexer;
|
|
26
|
+
}>;
|
|
22
27
|
protected init(): void;
|
|
28
|
+
protected handleIpcEvent(event: IpcMainEvent, data: Uint8Array): void;
|
|
29
|
+
protected createWindowChannelData(sender: Electron.WebContents): {
|
|
30
|
+
channel: ElectronWebContentChannel;
|
|
31
|
+
multiPlexer: ChannelMultiplexer;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Creates the main channel to a window.
|
|
35
|
+
* @param sender The window that the channel should be established to.
|
|
36
|
+
*/
|
|
37
|
+
protected createWindowMainChannel(sender: WebContents): ElectronWebContentChannel;
|
|
23
38
|
onStart(): void;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
ipcChannel(spec: string, callback: (params: any, channel: Channel) => void): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Used to establish a connection between the ipcMain and the Electron frontend (window).
|
|
43
|
+
* Messages a transferred via electron IPC.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ElectronWebContentChannel implements Channel {
|
|
46
|
+
protected readonly sender: Electron.WebContents;
|
|
47
|
+
protected readonly onCloseEmitter: Emitter<ChannelCloseEvent>;
|
|
48
|
+
get onClose(): Event<ChannelCloseEvent>;
|
|
49
|
+
readonly onMessageEmitter: Emitter<MessageProvider>;
|
|
50
|
+
get onMessage(): Event<MessageProvider>;
|
|
51
|
+
protected readonly onErrorEmitter: Emitter<unknown>;
|
|
52
|
+
get onError(): Event<unknown>;
|
|
53
|
+
constructor(sender: Electron.WebContents);
|
|
54
|
+
getWriteBuffer(): WriteBuffer;
|
|
55
|
+
close(): void;
|
|
28
56
|
}
|
|
29
57
|
//# sourceMappingURL=electron-messaging-contribution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-messaging-contribution.d.ts","sourceRoot":"","sources":["../../../src/electron-main/messaging/electron-messaging-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAW,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAErF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"electron-messaging-contribution.d.ts","sourceRoot":"","sources":["../../../src/electron-main/messaging/electron-messaging-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAW,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAErF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,yBAAyB,EAAmC,MAAM,6DAA6D,CAAC;AACzI,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8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SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAiB;IAC9E,IAAI,OAAO,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAEtC;IAGD,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,eAAe,CAAC,CAAiB;IACpE,IAAI,SAAS,IAAI,KAAK,CAAC,eAAe,CAAC,CAEtC;IAED,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAiB;IACpE,IAAI,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAE5B;gBAE8B,MAAM,EAAE,QAAQ,CAAC,WAAW;IAG3D,cAAc,IAAI,WAAW;IAW7B,KAAK,IAAI,IAAI;CAKhB"}
|
|
@@ -24,108 +24,86 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
24
24
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.ElectronMessagingContribution = void 0;
|
|
27
|
+
exports.ElectronWebContentChannel = exports.ElectronMessagingContribution = void 0;
|
|
28
28
|
const electron_1 = require("@theia/electron/shared/electron");
|
|
29
29
|
const inversify_1 = require("inversify");
|
|
30
|
-
const connection_1 = require("vscode-ws-jsonrpc/lib/socket/connection");
|
|
31
30
|
const contribution_provider_1 = require("../../common/contribution-provider");
|
|
32
|
-
const web_socket_channel_1 = require("../../common/messaging/web-socket-channel");
|
|
33
31
|
const messaging_contribution_1 = require("../../node/messaging/messaging-contribution");
|
|
34
|
-
const logger_1 = require("../../node/messaging/logger");
|
|
35
32
|
const electron_connection_handler_1 = require("../../electron-common/messaging/electron-connection-handler");
|
|
36
33
|
const electron_messaging_service_1 = require("./electron-messaging-service");
|
|
34
|
+
const channel_1 = require("../../common/message-rpc/channel");
|
|
35
|
+
const common_1 = require("../../common");
|
|
36
|
+
const uint8_array_message_buffer_1 = require("../../common/message-rpc/uint8-array-message-buffer");
|
|
37
37
|
/**
|
|
38
38
|
* This component replicates the role filled by `MessagingContribution` but for Electron.
|
|
39
39
|
* Unlike the WebSocket based implementation, we do not expect to receive
|
|
40
40
|
* connection events. Instead, we'll create channels based on incoming `open`
|
|
41
41
|
* events on the `ipcMain` channel.
|
|
42
|
-
*
|
|
43
42
|
* This component allows communication between renderer process (frontend) and electron main process.
|
|
44
43
|
*/
|
|
45
44
|
let ElectronMessagingContribution = class ElectronMessagingContribution {
|
|
46
45
|
constructor() {
|
|
47
46
|
this.channelHandlers = new messaging_contribution_1.MessagingContribution.ConnectionHandlers();
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Each electron window has a main chanel and its own multiplexer to route multiple client messages the same IPC connection.
|
|
49
|
+
*/
|
|
50
|
+
this.windowChannelMultiplexer = new Map();
|
|
49
51
|
}
|
|
50
52
|
init() {
|
|
51
53
|
electron_1.ipcMain.on(electron_connection_handler_1.THEIA_ELECTRON_IPC_CHANNEL_NAME, (event, data) => {
|
|
52
|
-
this.
|
|
54
|
+
this.handleIpcEvent(event, data);
|
|
53
55
|
});
|
|
54
56
|
}
|
|
57
|
+
handleIpcEvent(event, data) {
|
|
58
|
+
var _a;
|
|
59
|
+
const sender = event.sender;
|
|
60
|
+
// Get the multiplexer for a given window id
|
|
61
|
+
try {
|
|
62
|
+
const windowChannelData = (_a = this.windowChannelMultiplexer.get(sender.id)) !== null && _a !== void 0 ? _a : this.createWindowChannelData(sender);
|
|
63
|
+
windowChannelData.channel.onMessageEmitter.fire(() => new uint8_array_message_buffer_1.Uint8ArrayReadBuffer(data));
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error('IPC: Failed to handle message', { error, data });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Creates a new multiplexer for a given sender/window
|
|
70
|
+
createWindowChannelData(sender) {
|
|
71
|
+
const mainChannel = this.createWindowMainChannel(sender);
|
|
72
|
+
const multiPlexer = new channel_1.ChannelMultiplexer(mainChannel);
|
|
73
|
+
multiPlexer.onDidOpenChannel(openEvent => {
|
|
74
|
+
const { channel, id } = openEvent;
|
|
75
|
+
if (this.channelHandlers.route(id, channel)) {
|
|
76
|
+
console.debug(`Opening channel for service path '${id}'.`);
|
|
77
|
+
channel.onClose(() => console.debug(`Closing channel on service path '${id}'.`));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
sender.once('did-navigate', () => multiPlexer.onUnderlyingChannelClose({ reason: 'Window was refreshed' })); // When refreshing the browser window.
|
|
81
|
+
sender.once('destroyed', () => multiPlexer.onUnderlyingChannelClose({ reason: 'Window was closed' })); // When closing the browser window.
|
|
82
|
+
const data = { channel: mainChannel, multiPlexer };
|
|
83
|
+
this.windowChannelMultiplexer.set(sender.id, data);
|
|
84
|
+
return data;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates the main channel to a window.
|
|
88
|
+
* @param sender The window that the channel should be established to.
|
|
89
|
+
*/
|
|
90
|
+
createWindowMainChannel(sender) {
|
|
91
|
+
return new ElectronWebContentChannel(sender);
|
|
92
|
+
}
|
|
55
93
|
onStart() {
|
|
56
94
|
for (const contribution of this.messagingContributions.getContributions()) {
|
|
57
95
|
contribution.configure(this);
|
|
58
96
|
}
|
|
59
97
|
for (const connectionHandler of this.connectionHandlers.getContributions()) {
|
|
60
98
|
this.channelHandlers.push(connectionHandler.path, (params, channel) => {
|
|
61
|
-
|
|
62
|
-
connectionHandler.onConnection(connection);
|
|
99
|
+
connectionHandler.onConnection(channel);
|
|
63
100
|
});
|
|
64
101
|
}
|
|
65
102
|
}
|
|
66
|
-
listen(spec, callback) {
|
|
67
|
-
this.ipcChannel(spec, (params, channel) => {
|
|
68
|
-
const connection = (0, connection_1.createWebSocketConnection)(channel, new logger_1.ConsoleLogger());
|
|
69
|
-
callback(params, connection);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
103
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
104
|
ipcChannel(spec, callback) {
|
|
74
105
|
this.channelHandlers.push(spec, callback);
|
|
75
106
|
}
|
|
76
|
-
handleIpcMessage(event, data) {
|
|
77
|
-
const sender = event.sender;
|
|
78
|
-
try {
|
|
79
|
-
// Get the channel map for a given window id
|
|
80
|
-
let channels = this.windowChannels.get(sender.id);
|
|
81
|
-
if (!channels) {
|
|
82
|
-
this.windowChannels.set(sender.id, channels = new Map());
|
|
83
|
-
}
|
|
84
|
-
// Start parsing the message to extract the channel id and route
|
|
85
|
-
const message = JSON.parse(data.toString());
|
|
86
|
-
// Someone wants to open a logical channel
|
|
87
|
-
if (message.kind === 'open') {
|
|
88
|
-
const { id, path } = message;
|
|
89
|
-
const channel = this.createChannel(id, sender);
|
|
90
|
-
if (this.channelHandlers.route(path, channel)) {
|
|
91
|
-
channel.ready();
|
|
92
|
-
channels.set(id, channel);
|
|
93
|
-
channel.onClose(() => channels.delete(id));
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
console.error('Cannot find a service for the path: ' + path);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const { id } = message;
|
|
101
|
-
const channel = channels.get(id);
|
|
102
|
-
if (channel) {
|
|
103
|
-
channel.handleMessage(message);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
console.error('The ipc channel does not exist', id);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const close = () => {
|
|
110
|
-
for (const channel of Array.from(channels.values())) {
|
|
111
|
-
channel.close(undefined, 'webContent destroyed');
|
|
112
|
-
}
|
|
113
|
-
channels.clear();
|
|
114
|
-
};
|
|
115
|
-
sender.once('did-navigate', close); // When refreshing the browser window.
|
|
116
|
-
sender.once('destroyed', close); // When closing the browser window.
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
console.error('IPC: Failed to handle message', { error, data });
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
createChannel(id, sender) {
|
|
123
|
-
return new web_socket_channel_1.WebSocketChannel(id, content => {
|
|
124
|
-
if (!sender.isDestroyed()) {
|
|
125
|
-
sender.send(electron_connection_handler_1.THEIA_ELECTRON_IPC_CHANNEL_NAME, content);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
107
|
};
|
|
130
108
|
__decorate([
|
|
131
109
|
(0, inversify_1.inject)(contribution_provider_1.ContributionProvider),
|
|
@@ -147,4 +125,41 @@ ElectronMessagingContribution = __decorate([
|
|
|
147
125
|
(0, inversify_1.injectable)()
|
|
148
126
|
], ElectronMessagingContribution);
|
|
149
127
|
exports.ElectronMessagingContribution = ElectronMessagingContribution;
|
|
128
|
+
/**
|
|
129
|
+
* Used to establish a connection between the ipcMain and the Electron frontend (window).
|
|
130
|
+
* Messages a transferred via electron IPC.
|
|
131
|
+
*/
|
|
132
|
+
class ElectronWebContentChannel {
|
|
133
|
+
constructor(sender) {
|
|
134
|
+
this.sender = sender;
|
|
135
|
+
this.onCloseEmitter = new common_1.Emitter();
|
|
136
|
+
// Make the message emitter public so that we can easily forward messages received from the ipcMain.
|
|
137
|
+
this.onMessageEmitter = new common_1.Emitter();
|
|
138
|
+
this.onErrorEmitter = new common_1.Emitter();
|
|
139
|
+
}
|
|
140
|
+
get onClose() {
|
|
141
|
+
return this.onCloseEmitter.event;
|
|
142
|
+
}
|
|
143
|
+
get onMessage() {
|
|
144
|
+
return this.onMessageEmitter.event;
|
|
145
|
+
}
|
|
146
|
+
get onError() {
|
|
147
|
+
return this.onErrorEmitter.event;
|
|
148
|
+
}
|
|
149
|
+
getWriteBuffer() {
|
|
150
|
+
const writer = new uint8_array_message_buffer_1.Uint8ArrayWriteBuffer();
|
|
151
|
+
writer.onCommit(buffer => {
|
|
152
|
+
if (!this.sender.isDestroyed()) {
|
|
153
|
+
this.sender.send(electron_connection_handler_1.THEIA_ELECTRON_IPC_CHANNEL_NAME, buffer);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return writer;
|
|
157
|
+
}
|
|
158
|
+
close() {
|
|
159
|
+
this.onCloseEmitter.dispose();
|
|
160
|
+
this.onMessageEmitter.dispose();
|
|
161
|
+
this.onErrorEmitter.dispose();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.ElectronWebContentChannel = ElectronWebContentChannel;
|
|
150
165
|
//# sourceMappingURL=electron-messaging-contribution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-messaging-contribution.js","sourceRoot":"","sources":["../../../src/electron-main/messaging/electron-messaging-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;;;;AAEhF,8DAAqF;AACrF,yCAAqE;
|
|
1
|
+
{"version":3,"file":"electron-messaging-contribution.js","sourceRoot":"","sources":["../../../src/electron-main/messaging/electron-messaging-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;;;;AAEhF,8DAAqF;AACrF,yCAAqE;AACrE,8EAA0E;AAC1E,wFAAoF;AACpF,6GAAyI;AAEzI,6EAAwE;AACxE,8DAAmH;AACnH,yCAA2D;AAC3D,oGAAkH;AAElH;;;;;;GAMG;AAGH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAA1C;QAQuB,oBAAe,GAAG,IAAI,8CAAqB,CAAC,kBAAkB,E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cAAc,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;CACJ;AApCD,8DAoCC"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { WebSocketChannel } from '../../common/messaging/web-socket-channel';
|
|
1
|
+
import { Channel } from '../../common/message-rpc/channel';
|
|
3
2
|
export interface ElectronMessagingService {
|
|
4
|
-
/**
|
|
5
|
-
* Accept a JSON-RPC connection on the given path.
|
|
6
|
-
* A path supports the route syntax: https://github.com/rcs/route-parser#what-can-i-use-in-my-routes.
|
|
7
|
-
*/
|
|
8
|
-
listen(path: string, callback: (params: ElectronMessagingService.PathParams, connection: MessageConnection) => void): void;
|
|
9
3
|
/**
|
|
10
4
|
* Accept an ipc channel on the given path.
|
|
11
5
|
* A path supports the route syntax: https://github.com/rcs/route-parser#what-can-i-use-in-my-routes.
|
|
12
6
|
*/
|
|
13
|
-
ipcChannel(path: string, callback: (params: ElectronMessagingService.PathParams, socket:
|
|
7
|
+
ipcChannel(path: string, callback: (params: ElectronMessagingService.PathParams, socket: Channel) => void): void;
|
|
14
8
|
}
|
|
15
9
|
export declare namespace ElectronMessagingService {
|
|
16
10
|
interface PathParams {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-messaging-service.d.ts","sourceRoot":"","sources":["../../../src/electron-main/messaging/electron-messaging-service.ts"],"names":[],"mappings":"AAgBA,OAAO,
|
|
1
|
+
{"version":3,"file":"electron-messaging-service.d.ts","sourceRoot":"","sources":["../../../src/electron-main/messaging/electron-messaging-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,MAAM,WAAW,wBAAwB;IACrC;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;CACpH;AACD,yBAAiB,wBAAwB,CAAC;IACtC,UAAiB,UAAU;QACvB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KACzB;IACM,MAAM,YAAY,eAAkD,CAAC;IAC5E,UAAiB,YAAY;QACzB,SAAS,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI,CAAC;KACtD;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-messaging-service.js","sourceRoot":"","sources":["../../../src/electron-main/messaging/electron-messaging-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;
|
|
1
|
+
{"version":3,"file":"electron-messaging-service.js","sourceRoot":"","sources":["../../../src/electron-main/messaging/electron-messaging-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;AAWhF,IAAiB,wBAAwB,CAQxC;AARD,WAAiB,wBAAwB;IAIxB,qCAAY,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAIhF,CAAC,EARgB,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAQxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theia-electron-window.d.ts","sourceRoot":"","sources":["../../src/electron-main/theia-electron-window.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAoF,UAAU,EAAE,MAAM,gDAAgD,CAAC;AAC9J,OAAO,EAAE,aAAa,EAAE,+BAA+B,EAAW,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEvH,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"theia-electron-window.d.ts","sourceRoot":"","sources":["../../src/electron-main/theia-electron-window.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAoF,UAAU,EAAE,MAAM,gDAAgD,CAAC;AAC9J,OAAO,EAAE,aAAa,EAAE,+BAA+B,EAAW,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEvH,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAKjE;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,+BAA+B;IAC9E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,yBAAyB,eAAsC,CAAC;AAE7E,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AACzE,oBAAY,uBAAuB,GAAG,yBAAyB,CAAC;AAEhE,qBACa,mBAAmB;IACO,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAC;IACxD,SAAS,CAAC,QAAQ,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1 = require("../../shared/inversify");
|
|
|
31
31
|
const electron_main_constants_1 = require("./electron-main-constants");
|
|
32
32
|
const common_1 = require("../common");
|
|
33
33
|
const event_utils_1 = require("./event-utils");
|
|
34
|
+
const uri_1 = require("../common/uri");
|
|
35
|
+
const file_uri_1 = require("../node/file-uri");
|
|
34
36
|
exports.TheiaBrowserWindowOptions = Symbol('TheiaBrowserWindowOptions');
|
|
35
37
|
exports.WindowApplicationConfig = Symbol('WindowApplicationConfig');
|
|
36
38
|
let TheiaElectronWindow = class TheiaElectronWindow {
|
|
@@ -89,14 +91,15 @@ let TheiaElectronWindow = class TheiaElectronWindow {
|
|
|
89
91
|
}, electron_messages_1.StopReason.Reload);
|
|
90
92
|
}
|
|
91
93
|
async handleStopRequest(onSafeCallback, reason) {
|
|
92
|
-
// Only confirm close to windows that have loaded our
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
// Only confirm close to windows that have loaded our frontend.
|
|
95
|
+
// 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)
|
|
96
|
+
// Notes:
|
|
97
|
+
// - Windows: file:///C:/path/to/somewhere vs file:///c%3A/path/to/somewhere
|
|
98
|
+
// - macOS: file:///Applications/App%20Name.app/Contents vs /Applications/App Name.app/Contents
|
|
99
|
+
// This URL string comes from electron, we can expect that this is properly encoded URL. For example, a space is `%20`
|
|
100
|
+
const currentUrl = new uri_1.URI(this.window.webContents.getURL()).toString();
|
|
101
|
+
// THEIA_FRONTEND_HTML_PATH is an FS path, we have to covert to an encoded URI string.
|
|
102
|
+
const frontendUri = file_uri_1.FileUri.create(this.globals.THEIA_FRONTEND_HTML_PATH).toString();
|
|
100
103
|
const safeToClose = !currentUrl.includes(frontendUri) || await this.checkSafeToStop(reason);
|
|
101
104
|
if (safeToClose) {
|
|
102
105
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theia-electron-window.js","sourceRoot":"","sources":["../../src/electron-main/theia-electron-window.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;;;;AAIhF,sFAA8J;AAC9J,6DAAuH;AACvH,sDAA2E;AAC3E,uEAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"theia-electron-window.js","sourceRoot":"","sources":["../../src/electron-main/theia-electron-window.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;;;;AAIhF,sFAA8J;AAC9J,6DAAuH;AACvH,sDAA2E;AAC3E,uEAA2E;AAC3E,sCAAiE;AACjE,+CAAyD;AACzD,uCAAoC;AACpC,+CAA2C;AAgB9B,QAAA,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAEhE,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAIzE,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAAhC;QAKc,sBAAiB,GAAG,IAAI,gBAAO,EAAQ,CAAC;QAM/B,cAAS,GAAG,IAAI,6BAAoB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAOtE,qBAAgB,GAAG,KAAK,CAAC;QACzB,qBAAgB,GAA6B,MAAM,CAAC;IA2HlE,CAAC;IAvIG,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,iBAAiB,CAAC,K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AAE,CAAC,CAAe,EAAE,KAA+B,EAAE,EAAE;YACpH,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;gBAClB,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;aACjC;QACL,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC;IAES,oBAAoB;QAC1B,IAAA,sCAAwB,EAAC,kBAAO,EAAE,2CAAuB,EAAE,CAAC,CAAe,EAAE,EAAE;YAC3E,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;gBAClB,IAAI,CAAC,MAAM,EAAE,CAAC;aACjB;QACL,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC;IAES,QAAQ,CAAC,CAAe;QAC9B,OAAO,wBAAa,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC;IAC9D,CAAC;IAED,OAAO;QACH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ,CAAA;AA7IsC;IAAlC,IAAA,kBAAM,EAAC,iCAAyB,CAAC;;oDAAuD;AACxD;IAAhC,IAAA,kBAAM,EAAC,+BAAuB,CAAC;;mDAAoD;AAC5C;IAAvC,IAAA,kBAAM,EAAC,wDAA8B,CAAC;;oDAA4D;AAmBnG;IADC,IAAA,yBAAa,GAAE;;;;+CASf;AA9BQ,mBAAmB;IAD/B,IAAA,sBAAU,GAAE;GACA,mBAAmB,CA8I/B;AA9IY,kDAAmB;AAoJnB,QAAA,0BAA0B,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Duplex } from 'stream';
|
|
3
|
+
import { Disposable, Emitter, Event } from '../../common';
|
|
4
|
+
/**
|
|
5
|
+
* A `BinaryMessagePipe` is capable of sending and retrieving binary messages i.e. {@link Uint8Array}s over
|
|
6
|
+
* and underlying streamed process pipe/fd. The message length of individual messages is encoding at the beginning of
|
|
7
|
+
* a new message. This makes it possible to extract messages from the streamed data.
|
|
8
|
+
*/
|
|
9
|
+
export declare class BinaryMessagePipe implements Disposable {
|
|
10
|
+
protected readonly underlyingPipe: Duplex;
|
|
11
|
+
static readonly MESSAGE_START_IDENTIFIER = "<MessageStart>";
|
|
12
|
+
protected dataHandler: (chunk: Uint8Array) => void;
|
|
13
|
+
protected onMessageEmitter: Emitter<Uint8Array>;
|
|
14
|
+
protected cachedMessageData: StreamedMessageData;
|
|
15
|
+
get onMessage(): Event<Uint8Array>;
|
|
16
|
+
constructor(underlyingPipe: Duplex);
|
|
17
|
+
send(message: Uint8Array): void;
|
|
18
|
+
protected handleChunk(chunk: Uint8Array): void;
|
|
19
|
+
protected handleNewMessage(chunk: Uint8Array): void;
|
|
20
|
+
protected handleMessageContentChunk(chunk: Uint8Array): void;
|
|
21
|
+
protected emitCachedMessage(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Encodes the start of a new message into a {@link Uint8Array}.
|
|
24
|
+
* The message start consists of a identifier string and the length of the following message.
|
|
25
|
+
* @returns the buffer contains the encoded message start
|
|
26
|
+
*/
|
|
27
|
+
protected encodeMessageStart(message: Uint8Array): Uint8Array;
|
|
28
|
+
protected get messageStartByteLength(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Reads the start of a new message from a stream chunk (or cached message) received from the underlying pipe.
|
|
31
|
+
* The message start is expected to consist of an identifier string and the length of the message.
|
|
32
|
+
* @param chunk The stream chunk.
|
|
33
|
+
* @returns The length of the message content to read.
|
|
34
|
+
* @throws An error if the message start can not be read successfully.
|
|
35
|
+
*/
|
|
36
|
+
protected readMessageStart(chunk: Uint8Array): number;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
}
|
|
39
|
+
interface StreamedMessageData {
|
|
40
|
+
chunks: Uint8Array[];
|
|
41
|
+
missingBytes: number;
|
|
42
|
+
partialMessageStart?: Uint8Array;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=binary-message-pipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-message-pipe.d.ts","sourceRoot":"","sources":["../../../src/node/messaging/binary-message-pipe.ts"],"names":[],"mappings":";AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1D;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,UAAU;IAcpC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM;IAbrD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,oBAAoB;IAC5D,SAAS,CAAC,WAAW,UAAW,UAAU,UAA6B;IAEvE,SAAS,CAAC,gBAAgB,sBAA6B;IACvD,SAAS,CAAC,iBAAiB,EAAE,mBAAmB,CAG9C;IAEF,IAAI,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,CAEjC;gBAE8B,cAAc,EAAE,MAAM;IAIrD,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;IAK/B,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAU9C,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAyBnD,SAAS,CAAC,yBAAyB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAsB5D,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAOnC;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;IAS7D,SAAS,KAAK,sBAAsB,IAAI,MAAM,CAG7C;IAED;;;;;;OAMG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM;IAcrD,OAAO,IAAI,IAAI;CASlB;AAED,UAAU,mBAAmB;IACzB,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