mirror of
https://github.com/coder/code-server.git
synced 2024-12-26 11:12:07 +03:00
34c6751bf8
* Update VS Code to 1.92.2 * Use server-main.js to load VS Code It looks like the bootstrap files are now bundled so we can no longer require them. We could make them included again, but maybe it is better to go through the main entrypoint anyway because it includes some nls stuff which is maybe necessary. This also fixes what looks like a bug where we could create two servers if two requests came in. I am not sure what the practical consequences of that would be, but it will no longer do that. * Drop es2020 patch Unfortunately, VS Code will not load with this. It seems to be because `this` is being used in static properties, and it becomes `void 0` for some reason under the es2020 target. For example: static PREFIX_BY_CATEGORY = `${this.PREFIX}${this.SCOPE_PREFIX}`; becomes AbstractGotoSymbolQuickAccessProvider.PREFIX_BY_CATEGORY = `${(void 0).PREFIX}${(void 0).SCOPE_PREFIX}`; Which, obviously, will not work. Older versions of Safari (and maybe other browsers) are likely affected. * Fix display language * Update Playwright I think maybe because of the dropped es2020 patch that Webkit is now failing because it is too old. * Do not wait for networkidle in e2e tests I am not sure what is going on but some tests on Webkit are timing out and it seems the page is loaded but something is still trying to download. Not good, but for now try to at least get the tests passing.
130 lines
4.9 KiB
Diff
130 lines
4.9 KiB
Diff
Store the IPC socket with workspace metadata.
|
|
|
|
This lets us use it to open files inside code-server from outside of
|
|
code-server.
|
|
|
|
To test this:
|
|
1. run code-server
|
|
2. open file outside of code-server i.e. `code-server <path-to-file`
|
|
|
|
It should open in your existing code-server instance.
|
|
|
|
When the extension host is terminated, the socket is unregistered.
|
|
|
|
Index: code-server/lib/vscode/src/vs/workbench/api/node/extHostExtensionService.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/api/node/extHostExtensionService.ts
|
|
+++ code-server/lib/vscode/src/vs/workbench/api/node/extHostExtensionService.ts
|
|
@@ -2,7 +2,7 @@
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
-
|
|
+import * as _http from 'http';
|
|
import * as performance from 'vs/base/common/performance';
|
|
import { createApiFactoryAndRegisterActors } from 'vs/workbench/api/common/extHost.api.impl';
|
|
import { RequireInterceptor } from 'vs/workbench/api/common/extHostRequireInterceptor';
|
|
@@ -17,6 +17,7 @@ import { ExtensionRuntime } from 'vs/wor
|
|
import { CLIServer } from 'vs/workbench/api/node/extHostCLIServer';
|
|
import { realpathSync } from 'vs/base/node/extpath';
|
|
import { ExtHostConsoleForwarder } from 'vs/workbench/api/node/extHostConsoleForwarder';
|
|
+import { IExtHostWorkspace } from '../common/extHostWorkspace';
|
|
import { ExtHostDiskFileSystemProvider } from 'vs/workbench/api/node/extHostDiskFileSystemProvider';
|
|
// ESM-uncomment-begin
|
|
// import { createRequire } from 'node:module';
|
|
@@ -87,6 +88,52 @@ export class ExtHostExtensionService ext
|
|
await interceptor.install();
|
|
performance.mark('code/extHost/didInitAPI');
|
|
|
|
+ (async () => {
|
|
+ const socketPath = process.env['VSCODE_IPC_HOOK_CLI'];
|
|
+ const codeServerSocketPath = process.env['CODE_SERVER_SESSION_SOCKET']
|
|
+ if (!socketPath || !codeServerSocketPath) {
|
|
+ return;
|
|
+ }
|
|
+ const workspace = this._instaService.invokeFunction((accessor) => {
|
|
+ const workspaceService = accessor.get(IExtHostWorkspace);
|
|
+ return workspaceService.workspace;
|
|
+ });
|
|
+ const entry = {
|
|
+ workspace,
|
|
+ socketPath
|
|
+ };
|
|
+ const message = JSON.stringify({entry});
|
|
+ await new Promise<void>((resolve, reject) => {
|
|
+ const opts: _http.RequestOptions = {
|
|
+ path: '/add-session',
|
|
+ socketPath: codeServerSocketPath,
|
|
+ method: 'POST',
|
|
+ headers: {
|
|
+ 'content-type': 'application/json',
|
|
+ }
|
|
+ };
|
|
+ const req = _http.request(opts, (res) => {
|
|
+ res.on('error', reject);
|
|
+ res.on('end', () => {
|
|
+ try {
|
|
+ if (res.statusCode === 200) {
|
|
+ resolve();
|
|
+ } else {
|
|
+ reject(new Error('Unexpected status code: ' + res.statusCode));
|
|
+ }
|
|
+ } catch (e: unknown) {
|
|
+ reject(e);
|
|
+ }
|
|
+ });
|
|
+ });
|
|
+ req.on('error', reject);
|
|
+ req.write(message);
|
|
+ req.end();
|
|
+ });
|
|
+ })().catch(error => {
|
|
+ this._logService.error(error);
|
|
+ });
|
|
+
|
|
// Do this when extension service exists, but extensions are not being activated yet.
|
|
const configProvider = await this._extHostConfiguration.getConfigProvider();
|
|
await connectProxyResolver(this._extHostWorkspace, configProvider, this, this._logService, this._mainThreadTelemetryProxy, this._initData);
|
|
Index: code-server/lib/vscode/src/vs/workbench/api/node/extensionHostProcess.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/api/node/extensionHostProcess.ts
|
|
+++ code-server/lib/vscode/src/vs/workbench/api/node/extensionHostProcess.ts
|
|
@@ -3,6 +3,7 @@
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
+import * as _http from 'http';
|
|
import minimist from 'minimist';
|
|
import * as nativeWatchdog from 'native-watchdog';
|
|
import * as net from 'net';
|
|
@@ -421,7 +422,28 @@ async function startExtensionHostProcess
|
|
);
|
|
|
|
// rewrite onTerminate-function to be a proper shutdown
|
|
- onTerminate = (reason: string) => extensionHostMain.terminate(reason);
|
|
+ onTerminate = (reason: string) => {
|
|
+ extensionHostMain.terminate(reason);
|
|
+
|
|
+ const socketPath = process.env['VSCODE_IPC_HOOK_CLI'];
|
|
+ const codeServerSocketPath = process.env['CODE_SERVER_SESSION_SOCKET']
|
|
+ if (!socketPath || !codeServerSocketPath) {
|
|
+ return;
|
|
+ }
|
|
+ const message = JSON.stringify({socketPath});
|
|
+ const opts: _http.RequestOptions = {
|
|
+ path: '/delete-session',
|
|
+ socketPath: codeServerSocketPath,
|
|
+ method: 'POST',
|
|
+ headers: {
|
|
+ 'content-type': 'application/json',
|
|
+ 'accept': 'application/json'
|
|
+ }
|
|
+ };
|
|
+ const req = _http.request(opts);
|
|
+ req.write(message);
|
|
+ req.end();
|
|
+ };
|
|
}
|
|
|
|
startExtensionHostProcess().catch((err) => console.log(err));
|