@theia/core 1.78.0-next.0 → 1.78.0-next.4
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 +90 -17
- 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/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/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/package.json +4 -4
- package/src/browser/shell/tab-bars.spec.ts +22 -0
- package/src/browser/shell/tab-bars.ts +25 -12
- package/src/electron-main/electron-main-application.ts +15 -4
- package/src/electron-node/request/electron-backend-request-service.ts +59 -11
|
@@ -21,12 +21,34 @@ import { ILogger } from '../../common/index.js';
|
|
|
21
21
|
|
|
22
22
|
decorate(injectable(), NodeRequestService);
|
|
23
23
|
|
|
24
|
+
type ProxyResponseHandler = (result: string | undefined) => void;
|
|
25
|
+
|
|
24
26
|
@injectable()
|
|
25
27
|
export class ElectronBackendRequestService extends NodeRequestService {
|
|
26
28
|
|
|
27
29
|
@inject(ILogger) @named('core:ElectronBackendRequestService')
|
|
28
30
|
protected readonly logger: ILogger;
|
|
29
31
|
|
|
32
|
+
private static readonly pendingProxyRequests = new Map<string, ProxyResponseHandler>();
|
|
33
|
+
private static proxyResponseListenerAttached = false;
|
|
34
|
+
|
|
35
|
+
private static attachProxyResponseListener(): void {
|
|
36
|
+
if (this.proxyResponseListenerAttached || !process.send) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this.proxyResponseListenerAttached = true;
|
|
40
|
+
process.on('message', (msg: unknown) => {
|
|
41
|
+
const response = msg as { type: string, id: string, result: string };
|
|
42
|
+
if (response?.type === 'resolve-proxy-response' && response.id) {
|
|
43
|
+
const handler = this.pendingProxyRequests.get(response.id);
|
|
44
|
+
if (handler) {
|
|
45
|
+
this.pendingProxyRequests.delete(response.id);
|
|
46
|
+
handler(response.result);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
30
52
|
override async getProxyUrl(url: string): Promise<string | undefined> {
|
|
31
53
|
if (this.proxyUrl) {
|
|
32
54
|
return this.proxyUrl;
|
|
@@ -34,8 +56,15 @@ export class ElectronBackendRequestService extends NodeRequestService {
|
|
|
34
56
|
try {
|
|
35
57
|
const proxy = await this.resolveProxy(url);
|
|
36
58
|
if (proxy && proxy !== 'DIRECT') {
|
|
37
|
-
|
|
38
|
-
|
|
59
|
+
// Handle fallback proxies separated by semicolons, e.g., "PROXY proxy:8080; DIRECT"
|
|
60
|
+
const firstProxy = proxy.split(';')[0].trim();
|
|
61
|
+
const proxyType = firstProxy.split(' ')[0]; // e.g., "PROXY", "HTTPS"
|
|
62
|
+
const proxyHost = firstProxy.split(' ')[1];
|
|
63
|
+
if (!proxyHost) {
|
|
64
|
+
// Malformed proxy string, fall back
|
|
65
|
+
return super.getProxyUrl(url);
|
|
66
|
+
}
|
|
67
|
+
return this.buildProxyUrl(proxyHost, proxyType);
|
|
39
68
|
}
|
|
40
69
|
} catch (e) {
|
|
41
70
|
this.logger.error('Could not resolve electron proxy.', e);
|
|
@@ -44,20 +73,39 @@ export class ElectronBackendRequestService extends NodeRequestService {
|
|
|
44
73
|
}
|
|
45
74
|
|
|
46
75
|
override async resolveProxy(url: string): Promise<string | undefined> {
|
|
47
|
-
|
|
48
|
-
|
|
76
|
+
if (!process.send) {
|
|
77
|
+
// Running in --no-cluster mode (in the Electron main process): call session directly.
|
|
78
|
+
const { session } = await import('../../../electron-shared/electron/index.cjs');
|
|
79
|
+
return session.defaultSession.resolveProxy(url);
|
|
80
|
+
}
|
|
81
|
+
// Running as a forked child process: ask the main process via Node IPC.
|
|
82
|
+
return new Promise<string | undefined>(resolve => {
|
|
83
|
+
const id = Math.random().toString(36).slice(2);
|
|
84
|
+
ElectronBackendRequestService.attachProxyResponseListener();
|
|
85
|
+
const timer = setTimeout(() => {
|
|
86
|
+
ElectronBackendRequestService.pendingProxyRequests.delete(id);
|
|
87
|
+
resolve(undefined);
|
|
88
|
+
}, 5000);
|
|
89
|
+
ElectronBackendRequestService.pendingProxyRequests.set(id, (result: string | undefined) => {
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
resolve(result);
|
|
92
|
+
});
|
|
93
|
+
process.send!({ type: 'resolve-proxy', id, url });
|
|
94
|
+
});
|
|
49
95
|
}
|
|
50
96
|
|
|
51
|
-
protected buildProxyUrl(
|
|
97
|
+
protected buildProxyUrl(proxyHost: string, proxyType: string): string | undefined {
|
|
98
|
+
if (proxyType !== 'HTTPS' && proxyType !== 'PROXY') {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
52
102
|
if (proxyHost.startsWith('http://') || proxyHost.startsWith('https://')) {
|
|
53
103
|
return proxyHost;
|
|
54
104
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
return proxyHost;
|
|
105
|
+
|
|
106
|
+
return proxyType === 'HTTPS'
|
|
107
|
+
? 'https://' + proxyHost
|
|
108
|
+
: 'http://' + proxyHost;
|
|
61
109
|
}
|
|
62
110
|
|
|
63
111
|
protected override async processOptions(options: NodeRequestOptions): Promise<NodeRequestOptions> {
|