@theia/core 1.78.0-next.0 → 1.78.0-next.19
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/lib/browser/catalog.json +208 -32
- package/lib/browser/encoding-registry.js +1 -1
- package/lib/browser/encoding-registry.js.map +1 -1
- package/lib/browser/encoding-registry.spec.d.ts +2 -0
- package/lib/browser/encoding-registry.spec.d.ts.map +1 -0
- package/lib/browser/encoding-registry.spec.js +43 -0
- package/lib/browser/encoding-registry.spec.js.map +1 -0
- package/lib/browser/messaging/service-connection-provider.d.ts.map +1 -1
- package/lib/browser/messaging/service-connection-provider.js +9 -1
- package/lib/browser/messaging/service-connection-provider.js.map +1 -1
- package/lib/browser/messaging/service-connection-provider.spec.d.ts +2 -0
- package/lib/browser/messaging/service-connection-provider.spec.d.ts.map +1 -0
- package/lib/browser/messaging/service-connection-provider.spec.js +76 -0
- package/lib/browser/messaging/service-connection-provider.spec.js.map +1 -0
- package/lib/browser/shell/tab-bars.d.ts +7 -0
- package/lib/browser/shell/tab-bars.d.ts.map +1 -1
- package/lib/browser/shell/tab-bars.js +25 -11
- package/lib/browser/shell/tab-bars.js.map +1 -1
- package/lib/browser/shell/tab-bars.spec.js +20 -0
- package/lib/browser/shell/tab-bars.spec.js.map +1 -1
- package/lib/common/core-preferences.d.ts +1 -0
- package/lib/common/core-preferences.d.ts.map +1 -1
- package/lib/common/core-preferences.js +11 -1
- package/lib/common/core-preferences.js.map +1 -1
- package/lib/common/messaging/handler.d.ts +11 -0
- package/lib/common/messaging/handler.d.ts.map +1 -1
- package/lib/common/messaging/proxy-factory.d.ts +8 -1
- package/lib/common/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/common/messaging/proxy-factory.js +4 -2
- package/lib/common/messaging/proxy-factory.js.map +1 -1
- package/lib/common/messaging/proxy-factory.spec.js +16 -1
- package/lib/common/messaging/proxy-factory.spec.js.map +1 -1
- package/lib/common/shell-environment.d.ts +61 -0
- package/lib/common/shell-environment.d.ts.map +1 -0
- package/lib/common/shell-environment.js +29 -0
- package/lib/common/shell-environment.js.map +1 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-contribution.d.ts +20 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-contribution.d.ts.map +1 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-contribution.js +72 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-contribution.js.map +1 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-contribution.spec.d.ts +2 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-contribution.spec.d.ts.map +1 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-contribution.spec.js +86 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-contribution.spec.js.map +1 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-module.d.ts +4 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-module.d.ts.map +1 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-module.js +26 -0
- package/lib/electron-browser/shell-environment/electron-shell-environment-module.js.map +1 -0
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +12 -4
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/electron-node/keyboard/electron-backend-keyboard-module.d.ts.map +1 -1
- package/lib/electron-node/keyboard/electron-backend-keyboard-module.js +1 -1
- package/lib/electron-node/keyboard/electron-backend-keyboard-module.js.map +1 -1
- package/lib/electron-node/request/electron-backend-request-service.d.ts +4 -1
- package/lib/electron-node/request/electron-backend-request-service.d.ts.map +1 -1
- package/lib/electron-node/request/electron-backend-request-service.js +56 -13
- package/lib/electron-node/request/electron-backend-request-service.js.map +1 -1
- package/lib/node/backend-application-module.d.ts.map +1 -1
- package/lib/node/backend-application-module.js +13 -5
- package/lib/node/backend-application-module.js.map +1 -1
- package/lib/node/env-variables/env-variables-server.d.ts +13 -3
- package/lib/node/env-variables/env-variables-server.d.ts.map +1 -1
- package/lib/node/env-variables/env-variables-server.js +21 -14
- package/lib/node/env-variables/env-variables-server.js.map +1 -1
- package/lib/node/env-variables/env-variables-server.spec.d.ts +2 -0
- package/lib/node/env-variables/env-variables-server.spec.d.ts.map +1 -0
- package/lib/node/env-variables/env-variables-server.spec.js +83 -0
- package/lib/node/env-variables/env-variables-server.spec.js.map +1 -0
- package/lib/node/i18n/i18n-backend-module.js +2 -2
- package/lib/node/i18n/i18n-backend-module.js.map +1 -1
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/logger-backend-module.js +1 -1
- package/lib/node/logger-backend-module.js.map +1 -1
- package/lib/node/messaging/connection-container-module.d.ts +11 -2
- package/lib/node/messaging/connection-container-module.d.ts.map +1 -1
- package/lib/node/messaging/connection-container-module.js +13 -2
- package/lib/node/messaging/connection-container-module.js.map +1 -1
- package/lib/node/messaging/connection-container-module.spec.d.ts +2 -0
- package/lib/node/messaging/connection-container-module.spec.d.ts.map +1 -0
- package/lib/node/messaging/connection-container-module.spec.js +37 -0
- package/lib/node/messaging/connection-container-module.spec.js.map +1 -0
- package/lib/node/messaging/default-messaging-service.d.ts +33 -4
- package/lib/node/messaging/default-messaging-service.d.ts.map +1 -1
- package/lib/node/messaging/default-messaging-service.js +52 -10
- package/lib/node/messaging/default-messaging-service.js.map +1 -1
- package/lib/node/messaging/gated-channel-multiplexer.d.ts +20 -0
- package/lib/node/messaging/gated-channel-multiplexer.d.ts.map +1 -0
- package/lib/node/messaging/gated-channel-multiplexer.js +50 -0
- package/lib/node/messaging/gated-channel-multiplexer.js.map +1 -0
- package/lib/node/messaging/gated-channel-multiplexer.spec.d.ts +2 -0
- package/lib/node/messaging/gated-channel-multiplexer.spec.d.ts.map +1 -0
- package/lib/node/messaging/gated-channel-multiplexer.spec.js +74 -0
- package/lib/node/messaging/gated-channel-multiplexer.spec.js.map +1 -0
- package/lib/node/messaging/index.d.ts +1 -0
- package/lib/node/messaging/index.d.ts.map +1 -1
- package/lib/node/messaging/index.js +1 -0
- package/lib/node/messaging/index.js.map +1 -1
- package/lib/node/messaging/messaging-backend-module.js +1 -1
- package/lib/node/messaging/messaging-backend-module.js.map +1 -1
- package/lib/node/messaging/messaging-service.d.ts +5 -1
- package/lib/node/messaging/messaging-service.d.ts.map +1 -1
- package/lib/node/messaging/messaging-service.js.map +1 -1
- package/lib/node/messaging/test/default-messaging-service.spec.js +82 -2
- package/lib/node/messaging/test/default-messaging-service.spec.js.map +1 -1
- package/lib/node/messaging/websocket-frontend-connection-service.d.ts +1 -0
- package/lib/node/messaging/websocket-frontend-connection-service.d.ts.map +1 -1
- package/lib/node/messaging/websocket-frontend-connection-service.js +8 -0
- package/lib/node/messaging/websocket-frontend-connection-service.js.map +1 -1
- package/lib/node/messaging/websocket-frontend-connection-service.spec.d.ts +2 -0
- package/lib/node/messaging/websocket-frontend-connection-service.spec.d.ts.map +1 -0
- package/lib/node/messaging/websocket-frontend-connection-service.spec.js +141 -0
- package/lib/node/messaging/websocket-frontend-connection-service.spec.js.map +1 -0
- package/lib/node/performance/measurement-backend-bindings.js +1 -1
- package/lib/node/performance/measurement-backend-bindings.js.map +1 -1
- package/lib/node/process-utils.d.ts +125 -2
- package/lib/node/process-utils.d.ts.map +1 -1
- package/lib/node/process-utils.js +297 -25
- package/lib/node/process-utils.js.map +1 -1
- package/lib/node/process-utils.slow-spec.js +78 -3
- package/lib/node/process-utils.slow-spec.js.map +1 -1
- package/lib/node/process-utils.spec.js +237 -2
- package/lib/node/process-utils.spec.js.map +1 -1
- package/lib/node/shell-environment.d.ts +107 -0
- package/lib/node/shell-environment.d.ts.map +1 -0
- package/lib/node/shell-environment.js +396 -0
- package/lib/node/shell-environment.js.map +1 -0
- package/lib/node/shell-environment.spec.d.ts +2 -0
- package/lib/node/shell-environment.spec.d.ts.map +1 -0
- package/lib/node/shell-environment.spec.js +348 -0
- package/lib/node/shell-environment.spec.js.map +1 -0
- package/lib/node/test/exiting-backend.d.ts +5 -0
- package/lib/node/test/exiting-backend.d.ts.map +1 -1
- package/lib/node/test/exiting-backend.js +16 -3
- package/lib/node/test/exiting-backend.js.map +1 -1
- package/package.json +7 -4
- package/src/browser/encoding-registry.spec.ts +48 -0
- package/src/browser/encoding-registry.ts +1 -1
- package/src/browser/messaging/service-connection-provider.spec.ts +88 -0
- package/src/browser/messaging/service-connection-provider.ts +9 -2
- package/src/browser/shell/tab-bars.spec.ts +22 -0
- package/src/browser/shell/tab-bars.ts +25 -12
- package/src/common/core-preferences.ts +12 -1
- package/src/common/messaging/handler.ts +11 -0
- package/src/common/messaging/proxy-factory.spec.ts +17 -1
- package/src/common/messaging/proxy-factory.ts +16 -2
- package/src/common/shell-environment.ts +81 -0
- package/src/electron-browser/shell-environment/electron-shell-environment-contribution.spec.ts +95 -0
- package/src/electron-browser/shell-environment/electron-shell-environment-contribution.ts +72 -0
- package/src/electron-browser/shell-environment/electron-shell-environment-module.ts +29 -0
- package/src/electron-main/electron-main-application.ts +15 -4
- package/src/electron-node/keyboard/electron-backend-keyboard-module.ts +2 -1
- package/src/electron-node/request/electron-backend-request-service.ts +59 -11
- package/src/node/backend-application-module.ts +19 -5
- package/src/node/env-variables/env-variables-server.spec.ts +93 -0
- package/src/node/env-variables/env-variables-server.ts +22 -14
- package/src/node/i18n/i18n-backend-module.ts +2 -2
- package/src/node/index.ts +1 -0
- package/src/node/logger-backend-module.ts +1 -1
- package/src/node/messaging/connection-container-module.spec.ts +39 -0
- package/src/node/messaging/connection-container-module.ts +16 -4
- package/src/node/messaging/default-messaging-service.ts +64 -10
- package/src/node/messaging/gated-channel-multiplexer.spec.ts +80 -0
- package/src/node/messaging/gated-channel-multiplexer.ts +52 -0
- package/src/node/messaging/index.ts +1 -0
- package/src/node/messaging/messaging-backend-module.ts +1 -1
- package/src/node/messaging/messaging-service.ts +5 -1
- package/src/node/messaging/test/default-messaging-service.spec.ts +89 -2
- package/src/node/messaging/websocket-frontend-connection-service.spec.ts +158 -0
- package/src/node/messaging/websocket-frontend-connection-service.ts +9 -0
- package/src/node/performance/measurement-backend-bindings.ts +1 -1
- package/src/node/process-utils.slow-spec.ts +90 -3
- package/src/node/process-utils.spec.ts +268 -3
- package/src/node/process-utils.ts +342 -24
- package/src/node/shell-environment.spec.ts +388 -0
- package/src/node/shell-environment.ts +406 -0
- package/src/node/test/exiting-backend.ts +17 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { expect } from 'chai';
|
|
18
|
+
import { Container } from 'inversify';
|
|
19
|
+
import * as sinon from 'sinon';
|
|
20
|
+
import { Emitter } from '../../common/event.js';
|
|
21
|
+
import { Channel, ChannelMultiplexer } from '../../common/message-rpc/channel.js';
|
|
22
|
+
import { ChannelPipe } from '../../common/message-rpc/channel.spec.js';
|
|
23
|
+
import { wait } from '../../common/promise-util.js';
|
|
24
|
+
import { ConnectionSource } from './connection-source.js';
|
|
25
|
+
import { ServiceConnectionProvider } from './service-connection-provider.js';
|
|
26
|
+
|
|
27
|
+
describe('ServiceConnectionProvider', () => {
|
|
28
|
+
|
|
29
|
+
let debug: sinon.SinonStub;
|
|
30
|
+
let connections: Emitter<Channel>;
|
|
31
|
+
let provider: ServiceConnectionProvider;
|
|
32
|
+
let opened: Channel[];
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
// the provider cannot inject a logger, so it reports an interrupted open on the console
|
|
36
|
+
debug = sinon.stub(console, 'debug');
|
|
37
|
+
connections = new Emitter<Channel>();
|
|
38
|
+
const container = new Container();
|
|
39
|
+
container.bind(ConnectionSource).toConstantValue(<ConnectionSource>{ onConnectionDidOpen: connections.event });
|
|
40
|
+
container.bind(ServiceConnectionProvider).toSelf();
|
|
41
|
+
provider = container.get(ServiceConnectionProvider);
|
|
42
|
+
opened = [];
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
debug.restore();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** Connects to a backend that holds every channel and then drops the connection. */
|
|
50
|
+
const interrupt = async (): Promise<void> => {
|
|
51
|
+
const connection = new ChannelPipe();
|
|
52
|
+
connections.fire(connection.left);
|
|
53
|
+
await wait(0);
|
|
54
|
+
connection.left.onCloseEmitter.fire({ reason: 'The connection dropped' });
|
|
55
|
+
await wait(0);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Connects to a backend that acknowledges every channel. */
|
|
59
|
+
const connect = async (): Promise<void> => {
|
|
60
|
+
const connection = new ChannelPipe();
|
|
61
|
+
new ChannelMultiplexer(connection.right);
|
|
62
|
+
connections.fire(connection.left);
|
|
63
|
+
await wait(0);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
it('opens a channel again on the next connection when the first open was interrupted', async () => {
|
|
67
|
+
provider.listen('/services/held', (_, channel) => opened.push(channel), true);
|
|
68
|
+
|
|
69
|
+
await interrupt();
|
|
70
|
+
expect(opened).to.be.empty;
|
|
71
|
+
sinon.assert.calledOnce(debug);
|
|
72
|
+
expect(debug.firstCall.args[0]).to.equal("Could not open the channel '/services/held', opening it on the next connection:");
|
|
73
|
+
|
|
74
|
+
await connect();
|
|
75
|
+
expect(opened).to.have.lengthOf(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('does not announce another open when an interrupted open is not to be repeated', async () => {
|
|
79
|
+
provider.listen('/services/once', (_, channel) => opened.push(channel), false);
|
|
80
|
+
|
|
81
|
+
await interrupt();
|
|
82
|
+
sinon.assert.calledOnce(debug);
|
|
83
|
+
expect(debug.firstCall.args[0]).to.equal("Could not open the channel '/services/once':");
|
|
84
|
+
|
|
85
|
+
await connect();
|
|
86
|
+
expect(opened).to.be.empty;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -124,12 +124,19 @@ export class ServiceConnectionProvider {
|
|
|
124
124
|
* Install a connection handler for the given path.
|
|
125
125
|
*/
|
|
126
126
|
listen(path: string, handler: ServiceConnectionProvider.ConnectionHandler, reconnect: boolean): void {
|
|
127
|
-
|
|
127
|
+
const remember = (): void => {
|
|
128
128
|
if (reconnect) {
|
|
129
129
|
this.channelHandlers.set(path, handler);
|
|
130
130
|
}
|
|
131
|
+
};
|
|
132
|
+
// The handler is recorded once the channel is open, as the first connection opens it on its own.
|
|
133
|
+
// If the connection drops while the backend still holds the channel, the next connection opens it.
|
|
134
|
+
this.openChannel(path, handler).then(remember, error => {
|
|
135
|
+
// The frontend logger's RPC rides on this provider, so an ILogger cannot be injected here.
|
|
136
|
+
// eslint-disable-next-line @theia/named-logger-check
|
|
137
|
+
console.debug(`Could not open the channel '${path}'${reconnect ? ', opening it on the next connection' : ''}:`, error);
|
|
138
|
+
remember();
|
|
131
139
|
});
|
|
132
|
-
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
private async openChannel(path: string, handler: ServiceConnectionProvider.ConnectionHandler): Promise<void> {
|
|
@@ -19,11 +19,13 @@ let disableJSDOM = enableJSDOM();
|
|
|
19
19
|
import { expect } from 'chai';
|
|
20
20
|
|
|
21
21
|
import { MessageLoop } from '@lumino/messaging';
|
|
22
|
+
import { VirtualDOM } from '@lumino/virtualdom';
|
|
22
23
|
import { TabBar, Title, Widget } from '@lumino/widgets';
|
|
23
24
|
import { BreadcrumbsRenderer } from '../breadcrumbs/breadcrumbs-renderer.js';
|
|
24
25
|
import { NativeTabDragService } from './native-tab-drag-service.js';
|
|
25
26
|
import { TabBarToolbar, TabBarToolbarRegistry } from './tab-bar-toolbar/index.js';
|
|
26
27
|
import { SideTabBar, TabBarRenderer, ToolbarAwareTabBar } from './tab-bars.js';
|
|
28
|
+
import { pin } from '../widgets/widget.js';
|
|
27
29
|
|
|
28
30
|
disableJSDOM();
|
|
29
31
|
|
|
@@ -75,6 +77,26 @@ describe('tab bar', () => {
|
|
|
75
77
|
expect(pathMap.get(tabPaths[6])).to.be.equal(undefined);
|
|
76
78
|
});
|
|
77
79
|
|
|
80
|
+
it('should only render a close icon for closable or pinned tabs', () => {
|
|
81
|
+
class TestTabBarRenderer extends TabBarRenderer {
|
|
82
|
+
constructor() {
|
|
83
|
+
super();
|
|
84
|
+
this._tabBar = new TabBar<Widget>({ renderer: this });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const renderer = new TestTabBarRenderer();
|
|
88
|
+
const [closable, notClosable, pinned] = ['closable', 'notClosable', 'pinned'].map(label => new Title<Widget>({ owner: new Widget(), label }));
|
|
89
|
+
closable.closable = true;
|
|
90
|
+
notClosable.closable = false;
|
|
91
|
+
pin(pinned);
|
|
92
|
+
|
|
93
|
+
const closeIconTitles = [closable, notClosable, pinned].map(title => {
|
|
94
|
+
const tab = VirtualDOM.realize(renderer.renderTab({ title, current: false, zIndex: 0 }));
|
|
95
|
+
return tab.querySelector('.lm-TabBar-tabCloseIcon')?.getAttribute('title');
|
|
96
|
+
});
|
|
97
|
+
expect(closeIconTitles).to.deep.equal(['Close', undefined, 'Unpin']);
|
|
98
|
+
});
|
|
99
|
+
|
|
78
100
|
describe('side tab bar', () => {
|
|
79
101
|
|
|
80
102
|
class TestSideTabBar extends SideTabBar {
|
|
@@ -31,7 +31,7 @@ import { IconThemeService } from '../icon-theme-service.js';
|
|
|
31
31
|
import { BreadcrumbsRenderer, BreadcrumbsRendererFactory } from '../breadcrumbs/breadcrumbs-renderer.js';
|
|
32
32
|
import { NavigatableWidget } from '../navigatable-types.js';
|
|
33
33
|
import { Drag } from '@lumino/dragdrop';
|
|
34
|
-
import {
|
|
34
|
+
import { isPinned, LOCKED_CLASS } from '../widgets/widget.js';
|
|
35
35
|
import { CorePreferences } from '../../common/core-preferences.js';
|
|
36
36
|
import { HoverService } from '../hover-service.js';
|
|
37
37
|
import { Root, createRoot } from 'react-dom/client';
|
|
@@ -183,9 +183,6 @@ export class TabBarRenderer extends TabBar.Renderer {
|
|
|
183
183
|
const style = this.createTabStyle(data);
|
|
184
184
|
const className = `${this.createTabClass(data)}${tabCloseIconStart ? ' closeIcon-start' : ''}`;
|
|
185
185
|
const dataset = this.createTabDataset(data);
|
|
186
|
-
const closeIconTitle = data.title.className.includes(PINNED_CLASS)
|
|
187
|
-
? nls.localizeByDefault('Unpin')
|
|
188
|
-
: nls.localizeByDefault('Close');
|
|
189
186
|
|
|
190
187
|
const hover = {
|
|
191
188
|
onmouseenter: this.handleMouseEnterEvent
|
|
@@ -199,13 +196,15 @@ export class TabBarRenderer extends TabBar.Renderer {
|
|
|
199
196
|
this.renderBadge(data, isInSidePanel),
|
|
200
197
|
this.renderLock(data, isInSidePanel)
|
|
201
198
|
);
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
199
|
+
const tabContents = [tabLabel];
|
|
200
|
+
if (title.closable || isPinned(title)) {
|
|
201
|
+
const tabCloseIcon = this.renderCloseIcon(data);
|
|
202
|
+
if (tabCloseIconStart) {
|
|
203
|
+
tabContents.unshift(tabCloseIcon);
|
|
204
|
+
} else {
|
|
205
|
+
tabContents.push(tabCloseIcon);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
209
208
|
const draggable = this.tabBar instanceof ToolbarAwareTabBar && this.tabBar.isNativeTabDragEnabled ? { draggable: 'true' } : {};
|
|
210
209
|
|
|
211
210
|
return h.li(
|
|
@@ -224,6 +223,20 @@ export class TabBarRenderer extends TabBar.Renderer {
|
|
|
224
223
|
);
|
|
225
224
|
}
|
|
226
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Render the close icon of a tab, which unpins the tab if it is pinned.
|
|
228
|
+
* Only called for tabs that are closable or pinned.
|
|
229
|
+
* @param {SideBarRenderData} data Data used to render the tab.
|
|
230
|
+
* @returns {VirtualElement} The virtual element of the close icon.
|
|
231
|
+
*/
|
|
232
|
+
override renderCloseIcon(data: SideBarRenderData): VirtualElement {
|
|
233
|
+
return h.div({
|
|
234
|
+
className: 'lm-TabBar-tabCloseIcon action-label',
|
|
235
|
+
title: isPinned(data.title) ? nls.localizeByDefault('Unpin') : nls.localizeByDefault('Close'),
|
|
236
|
+
onclick: this.handleCloseClickEvent,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
227
240
|
override createTabClass(data: SideBarRenderData): string {
|
|
228
241
|
let tabClass = super.createTabClass(data);
|
|
229
242
|
if (!(data.visible ?? true)) {
|
|
@@ -698,7 +711,7 @@ export class TabBarRenderer extends TabBar.Renderer {
|
|
|
698
711
|
if (this.tabBar && event.currentTarget instanceof HTMLElement) {
|
|
699
712
|
const id = event.currentTarget.parentElement!.id;
|
|
700
713
|
const title = this.tabBar.titles.find(t => this.createTabId(t) === id);
|
|
701
|
-
if (title
|
|
714
|
+
if (title && isPinned(title) && this.commandService) {
|
|
702
715
|
this.commandService.executeCommand('workbench.action.unpinEditor', event);
|
|
703
716
|
}
|
|
704
717
|
}
|
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
import { interfaces } from 'inversify';
|
|
18
18
|
import { environment } from '@theia/application-package/lib/environment';
|
|
19
19
|
import { SUPPORTED_ENCODINGS } from './supported-encodings.js';
|
|
20
|
-
import { isOSX } from '../common/os.js';
|
|
20
|
+
import { isOSX, isWindows } from '../common/os.js';
|
|
21
21
|
import { nls } from '../common/nls.js';
|
|
22
22
|
import { PreferenceContribution, PreferenceSchema } from '../common/preferences/preference-schema.js';
|
|
23
23
|
import { createPreferenceProxy, PreferenceProxy, PreferenceService } from '../common/preferences/index.js';
|
|
24
24
|
import { PreferenceScope } from '../common/preferences/preference-scope.js';
|
|
25
|
+
import { ShellEnvironmentResolutionTimeout } from './shell-environment.js';
|
|
25
26
|
|
|
26
27
|
/* eslint-disable max-len */
|
|
27
28
|
const windowTitleDescription = [
|
|
@@ -54,6 +55,15 @@ export const corePreferenceSchema: PreferenceSchema = {
|
|
|
54
55
|
default: 'ifRequired',
|
|
55
56
|
description: nls.localizeByDefault('Controls whether to show a confirmation dialog before closing the browser tab or window. Note that even if enabled, browsers may still decide to close a tab or window without confirmation and that this setting is only a hint that may not work in all cases.'),
|
|
56
57
|
},
|
|
58
|
+
'application.shellEnvironmentResolutionTimeout': {
|
|
59
|
+
type: 'number',
|
|
60
|
+
default: ShellEnvironmentResolutionTimeout.DEFAULT,
|
|
61
|
+
minimum: ShellEnvironmentResolutionTimeout.MIN,
|
|
62
|
+
maximum: ShellEnvironmentResolutionTimeout.MAX,
|
|
63
|
+
included: environment.electron.is() && !isWindows,
|
|
64
|
+
scope: PreferenceScope.User,
|
|
65
|
+
description: nls.localize('theia/core/shellEnvironmentResolutionTimeout', 'Controls the timeout in seconds before giving up resolving the environment of your login shell when the application starts. Its `PATH` lets terminals, tasks, debug adapters, and extensions find the tools that your shell configuration provides. Takes effect at the next start of the application.'),
|
|
66
|
+
},
|
|
57
67
|
'breadcrumbs.enabled': {
|
|
58
68
|
'type': 'boolean',
|
|
59
69
|
'default': true,
|
|
@@ -328,6 +338,7 @@ export const corePreferenceSchema: PreferenceSchema = {
|
|
|
328
338
|
|
|
329
339
|
export interface CoreConfiguration {
|
|
330
340
|
'application.confirmExit': 'never' | 'ifRequired' | 'always';
|
|
341
|
+
'application.shellEnvironmentResolutionTimeout': number;
|
|
331
342
|
'breadcrumbs.enabled': boolean;
|
|
332
343
|
'files.encoding': string;
|
|
333
344
|
'keyboard.dispatch': 'code' | 'keyCode';
|
|
@@ -22,5 +22,16 @@ export const ConnectionHandler = Symbol('ConnectionHandler');
|
|
|
22
22
|
|
|
23
23
|
export interface ConnectionHandler {
|
|
24
24
|
readonly path: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the frontend may use the service before the process environment of the backend is complete.
|
|
27
|
+
*
|
|
28
|
+
* In an Electron application, the backend resolves the environment of the user's login shell after it has started
|
|
29
|
+
* (see `ShellEnvironmentServer`). Until that is done, `process.env` lacks the `PATH` of the user's shell
|
|
30
|
+
* configuration, so the processes that a service starts would not find the user's tools.
|
|
31
|
+
* The backend therefore holds the opening of every service channel until the environment is known.
|
|
32
|
+
* A service that starts no processes and that the frontend needs in order to start up declares its independence,
|
|
33
|
+
* so that the workbench does not wait for the shell. The default is `false`.
|
|
34
|
+
*/
|
|
35
|
+
readonly independentOfShellEnvironment?: boolean;
|
|
25
36
|
onConnection(connection: Channel): void;
|
|
26
37
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import * as chai from 'chai';
|
|
18
|
-
import { RpcProxyFactory, RpcProxy } from './proxy-factory.js';
|
|
18
|
+
import { RpcConnectionHandler, RpcProxyFactory, RpcProxy } from './proxy-factory.js';
|
|
19
19
|
import { ChannelPipe } from '../message-rpc/channel.spec.js';
|
|
20
20
|
|
|
21
21
|
const expect = chai.expect;
|
|
@@ -106,3 +106,19 @@ function getSetup(): {
|
|
|
106
106
|
serverProxy
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
describe('RpcConnectionHandler', () => {
|
|
111
|
+
it('is held until the shell environment is resolved unless declared independent of it', () => {
|
|
112
|
+
const held = new RpcConnectionHandler('/services/held', () => new TestServer());
|
|
113
|
+
expect(held.independentOfShellEnvironment).to.be.false;
|
|
114
|
+
const independent = new RpcConnectionHandler('/services/independent', () => new TestServer(), { independentOfShellEnvironment: true });
|
|
115
|
+
expect(independent.independentOfShellEnvironment).to.be.true;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('takes the proxy factory constructor from the options or, as before, as the third argument', () => {
|
|
119
|
+
class CustomFactory extends RpcProxyFactory<TestServer> { }
|
|
120
|
+
expect(new RpcConnectionHandler('/services/a', () => new TestServer()).factoryConstructor).to.equal(RpcProxyFactory);
|
|
121
|
+
expect(new RpcConnectionHandler('/services/b', () => new TestServer(), CustomFactory).factoryConstructor).to.equal(CustomFactory);
|
|
122
|
+
expect(new RpcConnectionHandler('/services/c', () => new TestServer(), { factoryConstructor: CustomFactory }).factoryConstructor).to.equal(CustomFactory);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -42,12 +42,26 @@ export interface RpcConnectionEventEmitter {
|
|
|
42
42
|
}
|
|
43
43
|
export type RpcProxy<T> = T & RpcConnectionEventEmitter;
|
|
44
44
|
|
|
45
|
+
export interface RpcConnectionHandlerOptions<T extends object> {
|
|
46
|
+
/** See {@link ConnectionHandler.independentOfShellEnvironment}. The default is `false`. */
|
|
47
|
+
independentOfShellEnvironment?: boolean;
|
|
48
|
+
/** Creates the proxy factory of each connection. The default is {@link RpcProxyFactory}. */
|
|
49
|
+
factoryConstructor?: new () => RpcProxyFactory<T>;
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
export class RpcConnectionHandler<T extends object> implements ConnectionHandler {
|
|
53
|
+
readonly factoryConstructor: new () => RpcProxyFactory<T>;
|
|
54
|
+
readonly independentOfShellEnvironment: boolean;
|
|
55
|
+
|
|
46
56
|
constructor(
|
|
47
57
|
readonly path: string,
|
|
48
58
|
readonly targetFactory: (proxy: RpcProxy<T>) => any,
|
|
49
|
-
|
|
50
|
-
) {
|
|
59
|
+
options: RpcConnectionHandlerOptions<T> | (new () => RpcProxyFactory<T>) = {}
|
|
60
|
+
) {
|
|
61
|
+
const { factoryConstructor, independentOfShellEnvironment } = typeof options === 'function' ? { factoryConstructor: options } : options;
|
|
62
|
+
this.factoryConstructor = factoryConstructor ?? RpcProxyFactory;
|
|
63
|
+
this.independentOfShellEnvironment = independentOfShellEnvironment ?? false;
|
|
64
|
+
}
|
|
51
65
|
|
|
52
66
|
onConnection(connection: Channel): void {
|
|
53
67
|
const factory = new this.factoryConstructor();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export const shellEnvironmentPath = '/services/shell-environment';
|
|
18
|
+
|
|
19
|
+
export const ShellEnvironmentServer = Symbol('ShellEnvironmentServer');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The environment of the user's login shell, resolved by the backend when it starts.
|
|
23
|
+
*
|
|
24
|
+
* A GUI application on macOS and Linux does not inherit the variables that the user's dotfiles
|
|
25
|
+
* (`.zshrc`, `.bash_profile`, ...) define, `PATH` among them, so the processes that the backend
|
|
26
|
+
* spawns for the user, such as terminals, tasks, debug adapters and the plugin host, would not find
|
|
27
|
+
* the user's tools. The backend of an Electron application therefore runs the login shell once at
|
|
28
|
+
* start-up and applies its `PATH` to its own `process.env`, from where every process spawned
|
|
29
|
+
* later inherits it. The other variables of the login shell are not applied. The channel of every
|
|
30
|
+
* service that a frontend opens is held until that has happened, unless the service is declared
|
|
31
|
+
* independent of the shell environment (see `ConnectionHandler.independentOfShellEnvironment`),
|
|
32
|
+
* so backend code that serves a request of a held
|
|
33
|
+
* service sees the resolved environment without waiting. Only code that spawns processes on its own,
|
|
34
|
+
* before any frontend connects, needs to await {@link whenResolved}.
|
|
35
|
+
*
|
|
36
|
+
* The resolution is skipped in browser deployments, on Windows, and when the backend itself was
|
|
37
|
+
* started from the login shell that is being resolved.
|
|
38
|
+
*/
|
|
39
|
+
export interface ShellEnvironmentServer {
|
|
40
|
+
/**
|
|
41
|
+
* Settles once the `PATH` of the login shell has been applied to the backend's `process.env`,
|
|
42
|
+
* or once the resolution has been skipped, has failed or has timed out, with the outcome.
|
|
43
|
+
* The returned promise never rejects.
|
|
44
|
+
*/
|
|
45
|
+
whenResolved(): Promise<ShellEnvironmentResolution>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Stores the time in seconds to wait for the login shell at the next start of the backend,
|
|
49
|
+
* `undefined` to restore the default.
|
|
50
|
+
*/
|
|
51
|
+
setResolutionTimeout(seconds: number | undefined): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The outcome of the resolution of the login shell environment, see {@link ShellEnvironmentServer}.
|
|
56
|
+
*/
|
|
57
|
+
export interface ShellEnvironmentResolution {
|
|
58
|
+
/**
|
|
59
|
+
* - `applied`: the `PATH` of the login shell has been applied to `process.env`
|
|
60
|
+
* - `skipped`: there was nothing to resolve, see `reason`
|
|
61
|
+
* - `timeout`: the login shell did not answer within the resolution timeout; `process.env` is unchanged
|
|
62
|
+
* - `failed`: the login shell could not be run or its output could not be read or defines no `PATH`, see `reason`;
|
|
63
|
+
* `process.env` is unchanged
|
|
64
|
+
*/
|
|
65
|
+
readonly status: 'applied' | 'skipped' | 'timeout' | 'failed';
|
|
66
|
+
/**
|
|
67
|
+
* Why the resolution was skipped or what went wrong.
|
|
68
|
+
*/
|
|
69
|
+
readonly reason?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The preference that controls how long the backend waits for the login shell, in seconds, and the bounds
|
|
74
|
+
* within which its value is honoured.
|
|
75
|
+
*/
|
|
76
|
+
export namespace ShellEnvironmentResolutionTimeout {
|
|
77
|
+
export const PREFERENCE = 'application.shellEnvironmentResolutionTimeout';
|
|
78
|
+
export const DEFAULT = 10;
|
|
79
|
+
export const MIN = 1;
|
|
80
|
+
export const MAX = 120;
|
|
81
|
+
}
|
package/src/electron-browser/shell-environment/electron-shell-environment-contribution.spec.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { expect } from 'chai';
|
|
18
|
+
import { Container } from 'inversify';
|
|
19
|
+
import { Emitter } from '../../common/event.js';
|
|
20
|
+
import { ILogger } from '../../common/logger.js';
|
|
21
|
+
import { MessageService } from '../../common/message-service.js';
|
|
22
|
+
import { PreferenceService } from '../../common/preferences/preference-service.js';
|
|
23
|
+
import { Deferred, wait } from '../../common/promise-util.js';
|
|
24
|
+
import { ShellEnvironmentResolutionTimeout, ShellEnvironmentResolution, ShellEnvironmentServer } from '../../common/shell-environment.js';
|
|
25
|
+
import { MockLogger } from '../../common/test/mock-logger.js';
|
|
26
|
+
import { ElectronShellEnvironmentContribution } from './electron-shell-environment-contribution.js';
|
|
27
|
+
|
|
28
|
+
describe('ElectronShellEnvironmentContribution', () => {
|
|
29
|
+
|
|
30
|
+
let resolution: Deferred<ShellEnvironmentResolution>;
|
|
31
|
+
let warnings: string[];
|
|
32
|
+
let storedTimeouts: (number | undefined)[];
|
|
33
|
+
let configuredTimeout: number | undefined;
|
|
34
|
+
let preferenceChanged: Emitter<{ preferenceName: string }>;
|
|
35
|
+
|
|
36
|
+
const setup = (): ElectronShellEnvironmentContribution => {
|
|
37
|
+
resolution = new Deferred();
|
|
38
|
+
warnings = [];
|
|
39
|
+
storedTimeouts = [];
|
|
40
|
+
configuredTimeout = undefined;
|
|
41
|
+
preferenceChanged = new Emitter();
|
|
42
|
+
const container = new Container({ defaultScope: 'Singleton' });
|
|
43
|
+
container.bind(ILogger).to(MockLogger);
|
|
44
|
+
container.bind(MessageService).toConstantValue({
|
|
45
|
+
warn: async (message: string) => { warnings.push(message); return undefined; }
|
|
46
|
+
} as unknown as MessageService);
|
|
47
|
+
container.bind(PreferenceService).toConstantValue({
|
|
48
|
+
ready: Promise.resolve(),
|
|
49
|
+
inspect: () => ({ globalValue: configuredTimeout }),
|
|
50
|
+
onPreferenceChanged: preferenceChanged.event
|
|
51
|
+
} as unknown as PreferenceService);
|
|
52
|
+
container.bind(ShellEnvironmentServer).toConstantValue(<ShellEnvironmentServer>{
|
|
53
|
+
whenResolved: () => resolution.promise,
|
|
54
|
+
setResolutionTimeout: async seconds => { storedTimeouts.push(seconds); }
|
|
55
|
+
});
|
|
56
|
+
container.bind(ElectronShellEnvironmentContribution).toSelf();
|
|
57
|
+
return container.get(ElectronShellEnvironmentContribution);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const start = async (outcome: ShellEnvironmentResolution): Promise<void> => {
|
|
61
|
+
setup().onStart();
|
|
62
|
+
resolution.resolve(outcome);
|
|
63
|
+
await wait(0);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
it('warns when the login shell did not answer in time', async () => {
|
|
67
|
+
await start({ status: 'timeout' });
|
|
68
|
+
expect(warnings).to.have.lengthOf(1);
|
|
69
|
+
expect(warnings[0]).to.contain('reasonable time');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('warns with the reason when the login shell could not be resolved', async () => {
|
|
73
|
+
await start({ status: 'failed', reason: 'The login shell exited with code 3' });
|
|
74
|
+
expect(warnings).to.deep.equal(['Unable to resolve your shell environment: The login shell exited with code 3']);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('says nothing when the environment was applied or the resolution skipped', async () => {
|
|
78
|
+
await start({ status: 'applied' });
|
|
79
|
+
await start({ status: 'skipped', reason: 'the application runs on Windows' });
|
|
80
|
+
expect(warnings).to.be.empty;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('stores the configured timeout for the next start, and again when it changes', async () => {
|
|
84
|
+
const contribution = setup();
|
|
85
|
+
contribution.onStart();
|
|
86
|
+
await wait(0);
|
|
87
|
+
expect(storedTimeouts).to.deep.equal([undefined]);
|
|
88
|
+
|
|
89
|
+
configuredTimeout = 30;
|
|
90
|
+
preferenceChanged.fire({ preferenceName: 'application.confirmExit' });
|
|
91
|
+
expect(storedTimeouts).to.deep.equal([undefined]);
|
|
92
|
+
preferenceChanged.fire({ preferenceName: ShellEnvironmentResolutionTimeout.PREFERENCE });
|
|
93
|
+
expect(storedTimeouts).to.deep.equal([undefined, 30]);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { inject, injectable, named } from 'inversify';
|
|
18
|
+
import { FrontendApplicationContribution } from '../../browser/frontend-application-contribution.js';
|
|
19
|
+
import { ILogger } from '../../common/logger.js';
|
|
20
|
+
import { MessageService } from '../../common/message-service.js';
|
|
21
|
+
import { nls } from '../../common/nls.js';
|
|
22
|
+
import { PreferenceService } from '../../common/preferences/preference-service.js';
|
|
23
|
+
import { ShellEnvironmentResolutionTimeout, ShellEnvironmentResolution, ShellEnvironmentServer } from '../../common/shell-environment.js';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Tells the user when the environment of the login shell could not be resolved, as the backend's child processes
|
|
27
|
+
* may then not find the user's tools, and stores the resolution timeout preference for the next start of the backend,
|
|
28
|
+
* which resolves the environment before the preferences are available.
|
|
29
|
+
*/
|
|
30
|
+
@injectable()
|
|
31
|
+
export class ElectronShellEnvironmentContribution implements FrontendApplicationContribution {
|
|
32
|
+
|
|
33
|
+
@inject(ShellEnvironmentServer)
|
|
34
|
+
protected readonly shellEnvironment: ShellEnvironmentServer;
|
|
35
|
+
|
|
36
|
+
@inject(MessageService)
|
|
37
|
+
protected readonly messageService: MessageService;
|
|
38
|
+
|
|
39
|
+
@inject(PreferenceService)
|
|
40
|
+
protected readonly preferences: PreferenceService;
|
|
41
|
+
|
|
42
|
+
@inject(ILogger) @named('core:ElectronShellEnvironmentContribution')
|
|
43
|
+
protected readonly logger: ILogger;
|
|
44
|
+
|
|
45
|
+
onStart(): void {
|
|
46
|
+
this.shellEnvironment.whenResolved().then(resolution => this.report(resolution))
|
|
47
|
+
.catch(error => this.logger.warn('Could not learn whether the shell environment was resolved:', error));
|
|
48
|
+
this.preferences.ready.then(() => {
|
|
49
|
+
this.storeResolutionTimeout();
|
|
50
|
+
this.preferences.onPreferenceChanged(event => {
|
|
51
|
+
if (event.preferenceName === ShellEnvironmentResolutionTimeout.PREFERENCE) {
|
|
52
|
+
this.storeResolutionTimeout();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected report(resolution: ShellEnvironmentResolution): void {
|
|
59
|
+
if (resolution.status === 'timeout') {
|
|
60
|
+
this.messageService.warn(nls.localizeByDefault(
|
|
61
|
+
'Unable to resolve your shell environment in a reasonable time. Please review your shell configuration and restart.'));
|
|
62
|
+
} else if (resolution.status === 'failed') {
|
|
63
|
+
this.messageService.warn(nls.localizeByDefault('Unable to resolve your shell environment: {0}', resolution.reason ?? ''));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected storeResolutionTimeout(): void {
|
|
68
|
+
const configured = this.preferences.inspect<number>(ShellEnvironmentResolutionTimeout.PREFERENCE)?.globalValue;
|
|
69
|
+
this.shellEnvironment.setResolutionTimeout(typeof configured === 'number' ? configured : undefined)
|
|
70
|
+
.catch(error => this.logger.warn('Could not store the shell environment resolution timeout:', error));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from 'inversify';
|
|
18
|
+
import { FrontendApplicationContribution } from '../../browser/frontend-application-contribution.js';
|
|
19
|
+
import { WebSocketConnectionProvider } from '../../browser/messaging/ws-connection-provider.js';
|
|
20
|
+
import { ShellEnvironmentServer, shellEnvironmentPath } from '../../common/shell-environment.js';
|
|
21
|
+
import { ElectronShellEnvironmentContribution } from './electron-shell-environment-contribution.js';
|
|
22
|
+
|
|
23
|
+
export default new ContainerModule(bind => {
|
|
24
|
+
bind(ShellEnvironmentServer).toDynamicValue(ctx =>
|
|
25
|
+
WebSocketConnectionProvider.createProxy<ShellEnvironmentServer>(ctx.container, shellEnvironmentPath)
|
|
26
|
+
).inSingletonScope();
|
|
27
|
+
bind(ElectronShellEnvironmentContribution).toSelf().inSingletonScope();
|
|
28
|
+
bind(FrontendApplicationContribution).toService(ElectronShellEnvironmentContribution);
|
|
29
|
+
});
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { inject, injectable, named } from 'inversify';
|
|
18
18
|
import {
|
|
19
19
|
screen, app, BrowserWindow, WebContents, Event as ElectronEvent, BrowserWindowConstructorOptions, nativeImage,
|
|
20
|
-
nativeTheme, shell, dialog
|
|
20
|
+
nativeTheme, shell, dialog, session
|
|
21
21
|
} from '../../electron-shared/electron/index.cjs';
|
|
22
22
|
import * as path from 'path';
|
|
23
23
|
import { Argv } from '../../shared/yargs/index.cjs';
|
|
@@ -849,9 +849,20 @@ export class ElectronMainApplication {
|
|
|
849
849
|
await this.getForkOptions(),
|
|
850
850
|
);
|
|
851
851
|
return new Promise((resolve, reject) => {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
852
|
+
backendProcess.on('message', (msg: AddressInfo | { type: string, id: string, url: string }) => {
|
|
853
|
+
// The backend server main file is supposed to send the resolved proxy via IPC.
|
|
854
|
+
if (msg && typeof msg === 'object' && 'type' in msg && msg.type === 'resolve-proxy') {
|
|
855
|
+
session.defaultSession.resolveProxy(msg.url).then(
|
|
856
|
+
result => backendProcess.send({ type: 'resolve-proxy-response', id: msg.id, result }),
|
|
857
|
+
error => {
|
|
858
|
+
console.warn(`Proxy resolution failed for ${msg.url}:`, error);
|
|
859
|
+
backendProcess.send({ type: 'resolve-proxy-response', id: msg.id, result: undefined });
|
|
860
|
+
}
|
|
861
|
+
);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
// The backend server main file is also supposed to send the resolved http(s) server port via IPC.
|
|
865
|
+
resolve((msg as AddressInfo).port);
|
|
855
866
|
});
|
|
856
867
|
backendProcess.on('error', error => {
|
|
857
868
|
reject(error);
|