@theia/remote-wsl 1.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/lib/electron-browser/remote-wsl-frontend-module.d.ts +4 -0
- package/lib/electron-browser/remote-wsl-frontend-module.d.ts.map +1 -0
- package/lib/electron-browser/remote-wsl-frontend-module.js +30 -0
- package/lib/electron-browser/remote-wsl-frontend-module.js.map +1 -0
- package/lib/electron-browser/wsl-connection-contribution.d.ts +29 -0
- package/lib/electron-browser/wsl-connection-contribution.d.ts.map +1 -0
- package/lib/electron-browser/wsl-connection-contribution.js +179 -0
- package/lib/electron-browser/wsl-connection-contribution.js.map +1 -0
- package/lib/electron-common/remote-wsl-connection-provider.d.ts +20 -0
- package/lib/electron-common/remote-wsl-connection-provider.d.ts.map +1 -0
- package/lib/electron-common/remote-wsl-connection-provider.js +21 -0
- package/lib/electron-common/remote-wsl-connection-provider.js.map +1 -0
- package/lib/electron-common/wsl-workspaces.d.ts +2 -0
- package/lib/electron-common/wsl-workspaces.d.ts.map +1 -0
- package/lib/electron-common/wsl-workspaces.js +20 -0
- package/lib/electron-common/wsl-workspaces.js.map +1 -0
- package/lib/electron-node/remote-wsl-backend-module.d.ts +5 -0
- package/lib/electron-node/remote-wsl-backend-module.d.ts.map +1 -0
- package/lib/electron-node/remote-wsl-backend-module.js +39 -0
- package/lib/electron-node/remote-wsl-backend-module.js.map +1 -0
- package/lib/electron-node/remote-wsl-connection-provider.d.ts +25 -0
- package/lib/electron-node/remote-wsl-connection-provider.d.ts.map +1 -0
- package/lib/electron-node/remote-wsl-connection-provider.js +121 -0
- package/lib/electron-node/remote-wsl-connection-provider.js.map +1 -0
- package/lib/electron-node/remote-wsl-connection.d.ts +31 -0
- package/lib/electron-node/remote-wsl-connection.d.ts.map +1 -0
- package/lib/electron-node/remote-wsl-connection.js +138 -0
- package/lib/electron-node/remote-wsl-connection.js.map +1 -0
- package/lib/electron-node/wsl-workspace-handler.d.ts +8 -0
- package/lib/electron-node/wsl-workspace-handler.d.ts.map +1 -0
- package/lib/electron-node/wsl-workspace-handler.js +23 -0
- package/lib/electron-node/wsl-workspace-handler.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +26 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +48 -0
- package/src/electron-browser/remote-wsl-frontend-module.ts +32 -0
- package/src/electron-browser/wsl-connection-contribution.ts +180 -0
- package/src/electron-common/remote-wsl-connection-provider.ts +39 -0
- package/src/electron-common/wsl-workspaces.ts +17 -0
- package/src/electron-node/remote-wsl-backend-module.ts +41 -0
- package/src/electron-node/remote-wsl-connection-provider.ts +123 -0
- package/src/electron-node/remote-wsl-connection.ts +161 -0
- package/src/electron-node/wsl-workspace-handler.ts +38 -0
- package/src/package.spec.ts +29 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
import { Emitter, Event } from '@theia/core';
|
|
6
|
+
import { RemoteConnection, RemoteExecOptions, RemoteExecResult, RemoteExecTester } from '@theia/remote/lib/electron-node/remote-types';
|
|
7
|
+
import { Socket } from 'net';
|
|
8
|
+
export interface RemoteWslConnectionOptions {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
distribution: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class RemoteWslConnection implements RemoteConnection {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
remotePort: number;
|
|
19
|
+
distribution: string;
|
|
20
|
+
get localPort(): number;
|
|
21
|
+
protected readonly onDidDisconnectEmitter: Emitter<void>;
|
|
22
|
+
onDidDisconnect: Event<void>;
|
|
23
|
+
constructor(options: RemoteWslConnectionOptions);
|
|
24
|
+
forwardOut(socket: Socket, port: number): Promise<void>;
|
|
25
|
+
exec(cmd: string, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
|
|
26
|
+
execPartial(cmd: string, tester: RemoteExecTester, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
|
|
27
|
+
copy(localPath: string | Buffer | NodeJS.ReadableStream, remotePath: string): Promise<void>;
|
|
28
|
+
dispose(): void;
|
|
29
|
+
disposeSync(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=remote-wsl-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-wsl-connection.d.ts","sourceRoot":"","sources":["../../src/electron-node/remote-wsl-connection.ts"],"names":[],"mappings":";;;;AAgBA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACvI,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAK7B,MAAM,WAAW,0BAA0B;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,mBAAoB,YAAW,gBAAgB;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IAErB,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,SAAS,CAAC,QAAQ,CAAC,sBAAsB,gBAAuB;IAChE,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,CAAqC;gBAErD,OAAO,EAAE,0BAA0B;IAOzC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMvD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAe1F,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmD3H,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BjG,OAAO,IAAI,IAAI;IAIf,WAAW,IAAI,IAAI;CAGtB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.RemoteWslConnection = void 0;
|
|
19
|
+
const core_1 = require("@theia/core");
|
|
20
|
+
const net_1 = require("net");
|
|
21
|
+
const child_process_1 = require("child_process");
|
|
22
|
+
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
23
|
+
const fs = require("fs");
|
|
24
|
+
class RemoteWslConnection {
|
|
25
|
+
get localPort() {
|
|
26
|
+
return this.remotePort;
|
|
27
|
+
}
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.onDidDisconnectEmitter = new core_1.Emitter();
|
|
30
|
+
this.onDidDisconnect = this.onDidDisconnectEmitter.event;
|
|
31
|
+
this.id = options.id;
|
|
32
|
+
this.name = options.name;
|
|
33
|
+
this.type = options.type;
|
|
34
|
+
this.distribution = options.distribution;
|
|
35
|
+
}
|
|
36
|
+
async forwardOut(socket, port) {
|
|
37
|
+
new net_1.Socket().connect(port, 'localhost', () => {
|
|
38
|
+
socket.pipe(new net_1.Socket().connect(port, 'localhost'));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async exec(cmd, args, options) {
|
|
42
|
+
var _a;
|
|
43
|
+
const deferred = new promise_util_1.Deferred();
|
|
44
|
+
const fullCommand = `wsl -d ${this.distribution} ${cmd} ${(_a = args === null || args === void 0 ? void 0 : args.join(' ')) !== null && _a !== void 0 ? _a : ''}`;
|
|
45
|
+
try {
|
|
46
|
+
(0, child_process_1.exec)(fullCommand, { env: options === null || options === void 0 ? void 0 : options.env }, (error, stdout, stderr) => {
|
|
47
|
+
deferred.resolve({ stdout, stderr });
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
deferred.reject(e);
|
|
52
|
+
}
|
|
53
|
+
return deferred.promise;
|
|
54
|
+
}
|
|
55
|
+
async execPartial(cmd, tester, args, options) {
|
|
56
|
+
var _a;
|
|
57
|
+
const deferred = new promise_util_1.Deferred();
|
|
58
|
+
try {
|
|
59
|
+
let cdPath = undefined;
|
|
60
|
+
if (cmd.startsWith('cd') && cmd.includes(';')) {
|
|
61
|
+
const parts = cmd.split(';');
|
|
62
|
+
cdPath = parts[0].replace('cd', '').trim();
|
|
63
|
+
cmd = parts[1];
|
|
64
|
+
}
|
|
65
|
+
const fullCommand = `wsl -d ${this.distribution} ${cdPath ? `--cd ${cdPath} ${cmd}` : cmd} ${(_a = args === null || args === void 0 ? void 0 : args.join(' ')) !== null && _a !== void 0 ? _a : ''}`;
|
|
66
|
+
const process = (0, child_process_1.spawn)(fullCommand, { env: options === null || options === void 0 ? void 0 : options.env, shell: 'powershell' });
|
|
67
|
+
let stdoutBuffer = '';
|
|
68
|
+
let stderrBuffer = '';
|
|
69
|
+
process.stdout.on('data', (data) => {
|
|
70
|
+
if (deferred.state === 'unresolved') {
|
|
71
|
+
stdoutBuffer += data.toString();
|
|
72
|
+
if (tester(stdoutBuffer, stderrBuffer)) {
|
|
73
|
+
deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
process.stderr.on('data', (data) => {
|
|
78
|
+
if (deferred.state === 'unresolved') {
|
|
79
|
+
stderrBuffer += data.toString();
|
|
80
|
+
if (tester(stdoutBuffer, stderrBuffer)) {
|
|
81
|
+
deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
process.on('close', () => {
|
|
86
|
+
if (deferred.state === 'unresolved') {
|
|
87
|
+
deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
process.on('error', error => {
|
|
91
|
+
deferred.reject(error);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
deferred.reject(e);
|
|
96
|
+
}
|
|
97
|
+
return deferred.promise;
|
|
98
|
+
}
|
|
99
|
+
async copy(localPath, remotePath) {
|
|
100
|
+
const deferred = new promise_util_1.Deferred();
|
|
101
|
+
const wslPath = `\\\\wsl$\\${this.distribution}\\${remotePath}`;
|
|
102
|
+
if (typeof localPath === 'string') {
|
|
103
|
+
(0, child_process_1.exec)(`copy "${localPath}" "${wslPath}"`, error => {
|
|
104
|
+
if (error) {
|
|
105
|
+
deferred.reject(error);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
deferred.resolve();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else if (Buffer.isBuffer(localPath)) {
|
|
113
|
+
fs.writeFile(wslPath, localPath, (error) => {
|
|
114
|
+
if (error) {
|
|
115
|
+
deferred.reject(error);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
deferred.resolve();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const writeStream = fs.createWriteStream(wslPath);
|
|
124
|
+
localPath.pipe(writeStream);
|
|
125
|
+
writeStream.on('finish', () => deferred.resolve());
|
|
126
|
+
writeStream.on('error', (error) => deferred.reject(error));
|
|
127
|
+
}
|
|
128
|
+
return deferred.promise;
|
|
129
|
+
}
|
|
130
|
+
dispose() {
|
|
131
|
+
this.onDidDisconnectEmitter.dispose();
|
|
132
|
+
}
|
|
133
|
+
disposeSync() {
|
|
134
|
+
// No special cleanup needed for WSL
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.RemoteWslConnection = RemoteWslConnection;
|
|
138
|
+
//# sourceMappingURL=remote-wsl-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-wsl-connection.js","sourceRoot":"","sources":["../../src/electron-node/remote-wsl-connection.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,gFAAgF;AAChF,gFAAgF;;;AAEhF,sCAA6C;AAE7C,6BAA6B;AAC7B,iDAA4C;AAC5C,sEA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E,CAAC;QAED,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED,OAAO;QACH,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;IAC1C,CAAC;IAED,WAAW;QACP,oCAAoC;IACxC,CAAC;CACJ;AAlID,kDAkIC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { URI } from '@theia/core';
|
|
2
|
+
import { WorkspaceHandlerContribution } from '@theia/workspace/lib/node/default-workspace-server';
|
|
3
|
+
export declare class WslWorkspaceHandler implements WorkspaceHandlerContribution {
|
|
4
|
+
canHandle(uri: URI): boolean;
|
|
5
|
+
workspaceStillExists(uri: URI): Promise<boolean>;
|
|
6
|
+
private toWindowsPath;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=wsl-workspace-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsl-workspace-handler.d.ts","sourceRoot":"","sources":["../../src/electron-node/wsl-workspace-handler.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAElG,qBAAa,mBAAoB,YAAW,4BAA4B;IACpE,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;IAG5B,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhD,OAAO,CAAC,aAAa;CAUxB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WslWorkspaceHandler = void 0;
|
|
4
|
+
const fs = require("@theia/core/shared/fs-extra");
|
|
5
|
+
class WslWorkspaceHandler {
|
|
6
|
+
canHandle(uri) {
|
|
7
|
+
return uri.scheme === 'wsl';
|
|
8
|
+
}
|
|
9
|
+
workspaceStillExists(uri) {
|
|
10
|
+
return fs.pathExists(this.toWindowsPath(uri.path.toString()));
|
|
11
|
+
}
|
|
12
|
+
toWindowsPath(path) {
|
|
13
|
+
const match = path.match(/^\/mnt\/([a-z])\/(.*)/i);
|
|
14
|
+
if (match) {
|
|
15
|
+
const driveLetter = match[1].toUpperCase();
|
|
16
|
+
const windowsPath = match[2].replace(/\//g, '\\');
|
|
17
|
+
return `${driveLetter}:\\${windowsPath}`;
|
|
18
|
+
}
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.WslWorkspaceHandler = WslWorkspaceHandler;
|
|
23
|
+
//# sourceMappingURL=wsl-workspace-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsl-workspace-handler.js","sourceRoot":"","sources":["../../src/electron-node/wsl-workspace-handler.ts"],"names":[],"mappings":";;;AAgBA,kDAAkD;AAGlD,MAAa,mBAAmB;IAC5B,SAAS,CAAC,GAAQ;QACd,OAAO,GAAG,CAAC,MAAM,KAAK,KAAK,CAAC;IAChC,CAAC;IACD,oBAAoB,CAAC,GAAQ;QACzB,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;IAEO,aAAa,CAAC,IAAY;QAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACnD,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAClD,OAAO,GAAG,WAAW,MAAM,WAAW,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ;AAlBD,kDAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=package.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
/* note: this bogus test file is required so that
|
|
17
|
+
we are able to run mocha unit tests on this
|
|
18
|
+
package, without having any actual unit tests in it.
|
|
19
|
+
This way a coverage report will be generated,
|
|
20
|
+
showing 0% coverage, instead of no report.
|
|
21
|
+
This file can be removed once we have real unit
|
|
22
|
+
tests in place. */
|
|
23
|
+
describe('remote-wsl package', () => {
|
|
24
|
+
it('support code coverage statistics', () => true);
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=package.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.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,gFAAgF;AAChF,gFAAgF;AAEhF;;;;;;qBAMqB;AAErB,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAEhC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AAEvD,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theia/remote-wsl",
|
|
3
|
+
"version": "1.62.0",
|
|
4
|
+
"description": "Theia - Remote WSL",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@theia/core": "1.62.0",
|
|
7
|
+
"@theia/remote": "1.62.0",
|
|
8
|
+
"@theia/workspace": "1.62.0",
|
|
9
|
+
"tslib": "^2.6.2"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"theiaExtensions": [
|
|
15
|
+
{
|
|
16
|
+
"frontendElectron": "lib/electron-browser/remote-wsl-frontend-module",
|
|
17
|
+
"backendElectron": "lib/electron-node/remote-wsl-backend-module"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"theia-extension"
|
|
22
|
+
],
|
|
23
|
+
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/eclipse-theia/theia.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/theia-ide/theia/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/theia-ide/theia",
|
|
32
|
+
"files": [
|
|
33
|
+
"lib",
|
|
34
|
+
"src"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "theiaext build",
|
|
38
|
+
"clean": "theiaext clean",
|
|
39
|
+
"compile": "theiaext compile",
|
|
40
|
+
"lint": "theiaext lint",
|
|
41
|
+
"test": "theiaext test",
|
|
42
|
+
"watch": "theiaext watch"
|
|
43
|
+
},
|
|
44
|
+
"nyc": {
|
|
45
|
+
"extends": "../../configs/nyc.json"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "a4e035ccc26fde24c2769a466cb18e3b54c517c5"
|
|
48
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { RemoteRegistryContribution } from '@theia/remote/lib/electron-browser/remote-registry-contribution';
|
|
19
|
+
import { RemoteWslConnectionProvider, RemoteWslConnectionProviderPath } from '../electron-common/remote-wsl-connection-provider';
|
|
20
|
+
import { WslConnectionContribution } from './wsl-connection-contribution';
|
|
21
|
+
import { ServiceConnectionProvider } from '@theia/core/lib/browser/messaging/service-connection-provider';
|
|
22
|
+
import { WorkspaceOpenHandlerContribution } from '@theia/workspace/lib/browser/workspace-service';
|
|
23
|
+
|
|
24
|
+
export default new ContainerModule(bind => {
|
|
25
|
+
bind(WslConnectionContribution).toSelf().inSingletonScope();
|
|
26
|
+
bind(RemoteRegistryContribution).toService(WslConnectionContribution);
|
|
27
|
+
bind(WorkspaceOpenHandlerContribution).toService(WslConnectionContribution);
|
|
28
|
+
|
|
29
|
+
bind(RemoteWslConnectionProvider).toDynamicValue(ctx =>
|
|
30
|
+
ServiceConnectionProvider.createLocalProxy<RemoteWslConnectionProvider>(ctx.container, RemoteWslConnectionProviderPath)
|
|
31
|
+
).inSingletonScope();
|
|
32
|
+
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { AbstractRemoteRegistryContribution, RemoteRegistry } from '@theia/remote/lib/electron-browser/remote-registry-contribution';
|
|
19
|
+
import { RemotePreferences } from '@theia/remote/lib/electron-browser/remote-preferences';
|
|
20
|
+
import { WorkspaceStorageService } from '@theia/workspace/lib/browser/workspace-storage-service';
|
|
21
|
+
import { Command, MessageService, QuickInputService, URI, isWindows, nls } from '@theia/core';
|
|
22
|
+
import { WorkspaceInput, WorkspaceOpenHandlerContribution, WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
|
23
|
+
import { WorkspaceServer } from '@theia/workspace/lib/common';
|
|
24
|
+
import { RemoteWslConnectionProvider, WslDistribution } from '../electron-common/remote-wsl-connection-provider';
|
|
25
|
+
import { WSL_WORKSPACE_SCHEME } from '../electron-common/wsl-workspaces';
|
|
26
|
+
|
|
27
|
+
export namespace RemoteWslCommands {
|
|
28
|
+
export const CONNECT_TO_WSL = Command.toLocalizedCommand({
|
|
29
|
+
id: 'remote-wsl.connect-to-wsl',
|
|
30
|
+
label: 'Connect to WSL',
|
|
31
|
+
category: 'WSL'
|
|
32
|
+
}, 'theia/remote/wsl/connectToWsl');
|
|
33
|
+
|
|
34
|
+
export const CONNECT_TO_WSL_WITH_DISTRO = Command.toLocalizedCommand({
|
|
35
|
+
id: 'remote-wsl.connect-to-wsl-with-distro',
|
|
36
|
+
label: 'Connect to WSL using Distro...',
|
|
37
|
+
category: 'WSL'
|
|
38
|
+
}, 'theia/remote/wsl/connectToWslUsingDistro');
|
|
39
|
+
|
|
40
|
+
export const OPEN_CURRENT_FOLDER_IN_WSL = Command.toLocalizedCommand({
|
|
41
|
+
id: 'remote-wsl.open-current-folder-in-wsl',
|
|
42
|
+
label: 'Reopen Folder in WSL',
|
|
43
|
+
category: 'WSL'
|
|
44
|
+
}, 'theia/remote/wsl/reopenInWsl');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@injectable()
|
|
48
|
+
export class WslConnectionContribution extends AbstractRemoteRegistryContribution implements
|
|
49
|
+
WorkspaceOpenHandlerContribution, WorkspaceOpenHandlerContribution {
|
|
50
|
+
|
|
51
|
+
@inject(RemoteWslConnectionProvider)
|
|
52
|
+
protected readonly connectionProvider: RemoteWslConnectionProvider;
|
|
53
|
+
|
|
54
|
+
@inject(RemotePreferences)
|
|
55
|
+
protected readonly remotePreferences: RemotePreferences;
|
|
56
|
+
|
|
57
|
+
@inject(WorkspaceStorageService)
|
|
58
|
+
protected readonly workspaceStorageService: WorkspaceStorageService;
|
|
59
|
+
|
|
60
|
+
@inject(WorkspaceService)
|
|
61
|
+
protected readonly workspaceService: WorkspaceService;
|
|
62
|
+
|
|
63
|
+
@inject(WorkspaceServer)
|
|
64
|
+
protected readonly workspaceServer: WorkspaceServer;
|
|
65
|
+
|
|
66
|
+
@inject(QuickInputService)
|
|
67
|
+
protected readonly quickInputService: QuickInputService;
|
|
68
|
+
|
|
69
|
+
@inject(MessageService)
|
|
70
|
+
protected readonly messageService: MessageService;
|
|
71
|
+
|
|
72
|
+
registerRemoteCommands(registry: RemoteRegistry): void {
|
|
73
|
+
if (!isWindows) {
|
|
74
|
+
// ignore this feature on non-Windows platforms
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
registry.registerCommand(RemoteWslCommands.CONNECT_TO_WSL, {
|
|
78
|
+
execute: () => {
|
|
79
|
+
this.connectionProvider.getWslDistributions().then(distributions => {
|
|
80
|
+
const defaultDistro = distributions.find(dist => dist.default);
|
|
81
|
+
if (defaultDistro) {
|
|
82
|
+
this.connectToWSL(defaultDistro);
|
|
83
|
+
} else {
|
|
84
|
+
this.getOrSelectWslDistribution().then(distribution => {
|
|
85
|
+
if (distribution) {
|
|
86
|
+
this.connectToWSL(distribution);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
registry.registerCommand(RemoteWslCommands.CONNECT_TO_WSL_WITH_DISTRO, {
|
|
95
|
+
execute: () => this.getOrSelectWslDistribution().then(distribution => {
|
|
96
|
+
if (distribution) {
|
|
97
|
+
this.connectToWSL(distribution);
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
registry.registerCommand(RemoteWslCommands.OPEN_CURRENT_FOLDER_IN_WSL, {
|
|
103
|
+
execute: () => this.getOrSelectWslDistribution().then(distribution => {
|
|
104
|
+
if (distribution) {
|
|
105
|
+
const workspacePath = this.workspaceService.workspace?.resource.path.fsPath();
|
|
106
|
+
if (workspacePath) {
|
|
107
|
+
this.connectToWSL(distribution, this.toWSLMountPath(workspacePath));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
isVisible: () => !!this.workspaceService.workspace
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async connectToWSL(distribution: WslDistribution, workspace?: string, preserveWindow = true): Promise<void> {
|
|
116
|
+
const connectionResult = await this.connectionProvider.connectToWsl({
|
|
117
|
+
nodeDownloadTemplate: this.remotePreferences['remote.nodeDownloadTemplate'],
|
|
118
|
+
distribution: distribution.name,
|
|
119
|
+
workspacePath: this.workspaceService.workspace?.resource.path?.fsPath()
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (workspace) {
|
|
123
|
+
this.workspaceServer.setMostRecentlyUsedWorkspace(
|
|
124
|
+
`${WSL_WORKSPACE_SCHEME}:${workspace}?distro=${distribution.name}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this.openRemote(connectionResult.port.toString(), !preserveWindow, workspace);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async getOrSelectWslDistribution(): Promise<WslDistribution | undefined> {
|
|
132
|
+
const distributions = await this.connectionProvider.getWslDistributions();
|
|
133
|
+
|
|
134
|
+
if (distributions.length === 0) {
|
|
135
|
+
this.messageService.error(nls.localize('theia/remote/wsl/noWslDistroFound', 'No WSL distributions found. Please install a WSL distribution first.'));
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (distributions.length === 1) {
|
|
140
|
+
return distributions[0];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (await this.quickInputService.pick(distributions.map(dist => ({
|
|
144
|
+
type: 'item',
|
|
145
|
+
label: dist.name,
|
|
146
|
+
description: dist.default ? nls.localizeByDefault('Default') : dist.version,
|
|
147
|
+
distribution: dist,
|
|
148
|
+
})), {
|
|
149
|
+
title: nls.localize('theia/remote/wsl/selectWSLDistro', 'Select a WSL distribution')
|
|
150
|
+
}))?.distribution;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
canHandle(uri: URI): boolean {
|
|
154
|
+
return uri.scheme === WSL_WORKSPACE_SCHEME; // WSL doesn't use a special URI scheme
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async openWorkspace(uri: URI, options?: WorkspaceInput | undefined): Promise<void> {
|
|
158
|
+
const workspacePath = uri.path.toString();
|
|
159
|
+
const distroName = new URLSearchParams(uri.query).get('distro');
|
|
160
|
+
if (distroName) {
|
|
161
|
+
const distros = await this.connectionProvider.getWslDistributions();
|
|
162
|
+
const distro = distros.find(d => d.name === distroName);
|
|
163
|
+
if (!distro) {
|
|
164
|
+
throw new Error(`Invalid WSL workspace URI. Distribution ${distroName} not found.`);
|
|
165
|
+
}
|
|
166
|
+
this.connectToWSL(distro, workspacePath, options?.preserveWindow);
|
|
167
|
+
}
|
|
168
|
+
throw new Error('Invalid WSL workspace URI. No distrubution specified.');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async getWorkspaceLabel(uri: URI): Promise<string | undefined> {
|
|
172
|
+
return `[WSL] ${uri.path.base}`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
protected toWSLMountPath(path: string): string {
|
|
176
|
+
const driveLetter = path.charAt(0).toLowerCase();
|
|
177
|
+
const wslPath = path.replace(/^[a-zA-Z]:\\/, `/mnt/${driveLetter}/`);
|
|
178
|
+
return wslPath.replace(/\\/g, '/');
|
|
179
|
+
}
|
|
180
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export interface WslDistribution {
|
|
18
|
+
name: string;
|
|
19
|
+
default: boolean;
|
|
20
|
+
version: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface WslConnectionOptions {
|
|
24
|
+
nodeDownloadTemplate: string;
|
|
25
|
+
distribution: string;
|
|
26
|
+
workspacePath?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface WslConnectionResult {
|
|
30
|
+
port: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const RemoteWslConnectionProviderPath = '/remote/wsl';
|
|
34
|
+
|
|
35
|
+
export const RemoteWslConnectionProvider = Symbol('RemoteWslConnectionProvider');
|
|
36
|
+
export interface RemoteWslConnectionProvider {
|
|
37
|
+
getWslDistributions(): Promise<WslDistribution[]>;
|
|
38
|
+
connectToWsl(options: WslConnectionOptions): Promise<WslConnectionResult>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export const WSL_WORKSPACE_SCHEME = 'wsl';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { RemoteWslConnectionProviderImpl } from './remote-wsl-connection-provider';
|
|
19
|
+
import { RemoteWslConnectionProvider, RemoteWslConnectionProviderPath } from '../electron-common/remote-wsl-connection-provider';
|
|
20
|
+
import { ConnectionContainerModule } from '@theia/core/lib/node/messaging/connection-container-module';
|
|
21
|
+
import { ConnectionHandler, RpcConnectionHandler } from '@theia/core';
|
|
22
|
+
import { WslWorkspaceHandler } from './wsl-workspace-handler';
|
|
23
|
+
import { WorkspaceHandlerContribution } from '@theia/workspace/lib/node/default-workspace-server';
|
|
24
|
+
|
|
25
|
+
export const wslRemoteConnectionModule = ConnectionContainerModule.create(({ bind, bindBackendService }) => {
|
|
26
|
+
bind(RemoteWslConnectionProviderImpl).toSelf().inSingletonScope();
|
|
27
|
+
bind(RemoteWslConnectionProvider).toService(RemoteWslConnectionProviderImpl);
|
|
28
|
+
bind(ConnectionHandler).toDynamicValue(ctx =>
|
|
29
|
+
new RpcConnectionHandler<RemoteWslConnectionProvider>(RemoteWslConnectionProviderPath, client => {
|
|
30
|
+
const server = ctx.container.get<RemoteWslConnectionProvider>(RemoteWslConnectionProvider);
|
|
31
|
+
return server;
|
|
32
|
+
}));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export default new ContainerModule(bind => {
|
|
36
|
+
bind(ConnectionContainerModule).toConstantValue(wslRemoteConnectionModule);
|
|
37
|
+
|
|
38
|
+
bind(WslWorkspaceHandler).toSelf().inSingletonScope();
|
|
39
|
+
bind(WorkspaceHandlerContribution).toService(WslWorkspaceHandler);
|
|
40
|
+
|
|
41
|
+
});
|