Skip to content

Commit 69c128b

Browse files
committed
Flesh out code-server refactor to upstream's server.
1 parent 18e854a commit 69c128b

26 files changed

+855
-54
lines changed

build/gulpfile.reh.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ const serverWithWebEntryPoints = [
125125
...vscodeWebEntryPoints
126126
];
127127

128-
function getNodeVersion() {
128+
function getNodeVersion () {
129+
// NOTE@coder: Fix version due to .yarnrc removal.
130+
return process.versions.node;
131+
129132
const yarnrc = fs.readFileSync(path.join(REPO_ROOT, 'remote', '.yarnrc'), 'utf8');
130133
const target = /^target "(.*)"$/m.exec(yarnrc)[1];
131134
return target;

build/lib/node.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as path from 'path';
7-
import * as fs from 'fs';
87

98
const root = path.dirname(path.dirname(__dirname));
10-
const yarnrcPath = path.join(root, 'remote', '.yarnrc');
11-
const yarnrc = fs.readFileSync(yarnrcPath, 'utf8');
12-
const version = /^target\s+"([^"]+)"$/m.exec(yarnrc)![1];
139

10+
// NOTE@coder: Fix version due to .yarnrc removal.
11+
const version = process.versions.node;
1412
const platform = process.platform;
1513
const arch = platform === 'darwin' ? 'x64' : process.arch;
1614

build/lib/util.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ export function streamToPromise(stream: NodeJS.ReadWriteStream): Promise<void> {
336336
}
337337

338338
export function getElectronVersion(): string {
339+
// NOTE@coder: Fix version due to .yarnrc removal.
340+
return process.versions.node;
341+
339342
const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8');
340343
const target = /^target "(.*)"$/m.exec(yarnrc)![1];
341344
return target;

resources/server/code-192.png

2.7 KB
Loading

resources/server/code-512.png

11.7 KB
Loading

resources/server/code.png

18.9 KB
Loading
Lines changed: 7 additions & 0 deletions
Loading

resources/server/favicon.ico

-28.9 KB
Binary file not shown.

resources/server/favicon.svg

Lines changed: 1 addition & 0 deletions
Loading

resources/server/web.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ fi
1010
function code() {
1111
cd $ROOT
1212

13-
# Sync built-in extensions
14-
yarn download-builtin-extensions
13+
# # Sync built-in extensions
14+
# yarn download-builtin-extensions
1515

16-
# Load remote node
17-
yarn gulp node
16+
# # Load remote node
17+
# yarn gulp node
1818

1919
NODE=$(node build/lib/node.js)
2020

src/tsec.exemptions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"vs/workbench/services/keybinding/test/electron-browser/keyboardMapperTestUtils.ts"
1111
],
1212
"ban-trustedtypes-createpolicy": [
13+
"vs/workbench/browser/client.ts",
1314
"vs/base/browser/dom.ts",
1415
"vs/base/browser/markdownRenderer.ts",
1516
"vs/base/worker/defaultWorkerFactory.ts",

src/vs/base/common/product.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ export type ExtensionVirtualWorkspaceSupport = {
3131
};
3232

3333
export interface IProductConfiguration {
34+
// @coder BEGIN
35+
readonly codeServerVersion?: string;
36+
readonly authed?: boolean;
37+
readonly logoutEndpointUrl: string;
38+
readonly proxyEndpointUrlTemplate?: string;
39+
readonly serviceWorker?: {
40+
readonly url: string;
41+
readonly scope: string;
42+
}
43+
readonly icons: Array<{ src: string; type: string; sizes: string }>;
44+
// @coder END */
45+
3446
readonly version: string;
3547
readonly date?: string;
3648
readonly quality?: string;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable header/header */
2+
/*---------------------------------------------------------------------------------------------
3+
* Copyright (c) Coder Technologies. All rights reserved.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
/// <reference lib="webworker" />
8+
9+
const sw = self as unknown as ServiceWorkerGlobalScope;
10+
11+
sw.addEventListener('install', () => {
12+
console.debug('[Service Worker] installed');
13+
});
14+
15+
sw.addEventListener('activate', (event) => {
16+
event.waitUntil(sw.clients.claim());
17+
console.debug('[Service Worker] activated');
18+
});
19+
20+
sw.addEventListener('fetch', () => {
21+
// Without this event handler we won't be recognized as a PWA.
22+
});

src/vs/code/browser/workbench/workbench-dev.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
22
<!DOCTYPE html>
3-
<html>
3+
<html style="--vs-theme-background-color: {{CLIENT_BACKGROUND_COLOR}}; --vs-theme-foreground-color: {{CLIENT_FOREGROUND_COLOR}}">
44
<head>
55
<script>
66
performance.mark('code/didStartRenderer')
@@ -26,11 +26,18 @@
2626
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
2727

2828
<!-- Workbench Icon/Manifest/CSS -->
29+
<link rel="icon" href="./static/resources/server/favicon-dark-support.svg" type="image/svg+xml" />
30+
<link rel="alternate icon" href="./static/resources/server/favicon.svg" type="image/svg+xml" />
31+
<link rel="apple-touch-icon" sizes="192x192" href="./static/resources/server/code-192.png" />
32+
<link rel="apple-touch-icon" sizes="512x512" href="./static/resources/server/code-512.png" />
33+
<meta name="apple-mobile-web-app-capable" content="yes" />
34+
<meta name="theme-color" content="{{CLIENT_BACKGROUND_COLOR}}">
35+
2936
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
3037
<link rel="manifest" href="/manifest.json">
3138
</head>
3239

33-
<body aria-label="">
40+
<body style="background-color: var(--vs-theme-background-color); color: var(--vs-theme-foreground-color)" aria-label="">
3441
</body>
3542

3643
<!-- Startup (do not modify order of script tags!) -->
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!-- Copyright (C) Coder Technologies. All rights reserved. -->
2+
<!DOCTYPE html>
3+
<html style="--vs-theme-background-color: {{CLIENT_BACKGROUND_COLOR}}; --vs-theme-foreground-color: {{CLIENT_FOREGROUND_COLOR}}">
4+
<head>
5+
<meta charset="utf-8" />
6+
7+
<!-- Disable pinch zooming -->
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
9+
10+
<!-- Workbench Icon/Manifest/CSS -->
11+
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
12+
<link rel="manifest" href="./manifest.json">
13+
14+
<meta name="theme-color" content="{{CLIENT_BACKGROUND_COLOR}}">
15+
16+
<style>
17+
* {
18+
box-sizing: border-box;
19+
}
20+
21+
body {
22+
margin: 0;
23+
height: 100vh;
24+
font-size: 16px;
25+
}
26+
main {
27+
display: grid;
28+
justify-content: center;
29+
align-content: space-between;
30+
grid-template-rows: 1fr 4fr 1fr;
31+
grid-gap: 8px;
32+
padding: 8px;
33+
font-family: monospace;
34+
height: 100%;
35+
}
36+
37+
footer {
38+
place-self: end center;
39+
font-size: .75rem;
40+
}
41+
</style>
42+
</head>
43+
44+
<body style="background-color: var(--vs-theme-background-color); color: var(--vs-theme-foreground-color)" aria-label="">
45+
46+
<main>
47+
<header>
48+
<h1>{{ERROR_HEADER}}</h1>
49+
</header>
50+
<section>
51+
<h2>⚠️ Error {{ERROR_CODE}}</h2>
52+
{{ERROR_MESSAGE}}
53+
</section>
54+
<footer>{{ERROR_FOOTER}}</footer>
55+
</main>
56+
</body>
57+
</html>

src/vs/code/browser/workbench/workbench.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
22
<!DOCTYPE html>
3-
<html>
3+
<html style="--vs-theme-background-color: {{CLIENT_BACKGROUND_COLOR}}; --vs-theme-foreground-color: {{CLIENT_FOREGROUND_COLOR}}">
44
<head>
55
<script>
66
performance.mark('code/didStartRenderer');
@@ -23,13 +23,20 @@
2323
<meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
2424

2525
<!-- Workbench Icon/Manifest/CSS -->
26+
<link rel="icon" href="./static/resources/server/favicon-dark-support.svg" type="image/svg+xml" />
27+
<link rel="alternate icon" href="./static/resources/server/favicon.svg" type="image/svg+xml" />
28+
<link rel="apple-touch-icon" sizes="192x192" href="./static/resources/server/code-192.png" />
29+
<link rel="apple-touch-icon" sizes="512x512" href="./static/resources/server/code-512.png" />
30+
<meta name="apple-mobile-web-app-capable" content="yes" />
31+
2632
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
27-
<link rel="manifest" href="/manifest.json">
28-
<link data-name="vs/workbench/workbench.web.api" rel="stylesheet" href="./static/out/vs/workbench/workbench.web.api.css">
33+
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
34+
<meta name="theme-color" content="{{CLIENT_BACKGROUND_COLOR}}">
2935

36+
<link data-name="vs/workbench/workbench.web.api" rel="stylesheet" href="./static/out/vs/workbench/workbench.web.api.css">
3037
</head>
3138

32-
<body aria-label="">
39+
<body style="background-color: var(--vs-theme-background-color); color: var(--vs-theme-foreground-color)" aria-label="">
3340
</body>
3441

3542
<!-- Startup (do not modify order of script tags!) -->
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/* eslint-disable header/header */
2+
/*---------------------------------------------------------------------------------------------
3+
* Copyright (c) Coder Technologies. All rights reserved.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
import type { NLSConfiguration, InternalNLSConfiguration } from '../../../base/node/languagePacks';
8+
import type * as http from 'http';
9+
import type * as net from 'net';
10+
11+
declare global {
12+
namespace CodeServerLib {
13+
export interface ServerParsedArgs {
14+
port?: string;
15+
connectionToken?: string;
16+
/**
17+
* A path to a filename which will be read on startup.
18+
* Consider placing this file in a folder readable only by the same user (a `chmod 0700` directory).
19+
*
20+
* The contents of the file will be used as the connectionToken. Use only `[0-9A-Z\-]` as contents in the file.
21+
* The file can optionally end in a `\n` which will be ignored.
22+
*
23+
* This secret must be communicated to any vscode instance via the resolver or embedder API.
24+
*/
25+
'connection-secret'?: string;
26+
host?: string;
27+
'socket-path'?: string;
28+
driver?: string;
29+
'print-startup-performance'?: boolean;
30+
'print-ip-address'?: boolean;
31+
'disable-websocket-compression'?: boolean;
32+
'disable-telemetry'?: boolean;
33+
fileWatcherPolling?: string;
34+
'start-server'?: boolean;
35+
36+
'enable-remote-auto-shutdown'?: boolean;
37+
'remote-auto-shutdown-without-delay'?: boolean;
38+
39+
'extensions-dir'?: string;
40+
'extensions-download-dir'?: string;
41+
'install-extension'?: string[];
42+
'install-builtin-extension'?: string[];
43+
'uninstall-extension'?: string[];
44+
'list-extensions'?: boolean;
45+
'locate-extension'?: string[];
46+
'show-versions'?: boolean;
47+
'category'?: string;
48+
49+
'force-disable-user-env'?: boolean;
50+
'use-host-proxy'?: string;
51+
52+
'without-browser-env-var'?: boolean;
53+
54+
force?: boolean; // used by install-extension
55+
'do-not-sync'?: boolean; // used by install-extension
56+
57+
'user-data-dir'?: string;
58+
'builtin-extensions-dir'?: string;
59+
60+
// web
61+
workspace: string;
62+
folder: string;
63+
'web-user-data-dir'?: string;
64+
'enable-sync'?: boolean;
65+
'github-auth'?: string;
66+
'log'?: string;
67+
'logsPath'?: string;
68+
69+
_: string[];
70+
}
71+
72+
export interface StartPath {
73+
url: string;
74+
workspace: boolean;
75+
}
76+
77+
export interface ServerConfiguration {
78+
args: ServerParsedArgs;
79+
authed: boolean;
80+
disableUpdateCheck: boolean;
81+
startPath?: StartPath;
82+
codeServerVersion?: string;
83+
serverUrl: URL;
84+
}
85+
86+
export type CreateServer = (address: string | net.AddressInfo | null, args: ServerParsedArgs, REMOTE_DATA_FOLDER: string) => Promise<IServerAPI>;
87+
88+
export interface IServerAPI {
89+
handleRequest(req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
90+
handleUpgrade(req: http.IncomingMessage, socket: net.Socket): void;
91+
handleServerError(err: Error): void;
92+
dispose(): void;
93+
}
94+
95+
/**
96+
* @deprecated This should be removed when code-server merges with lib/vscode
97+
*/
98+
export interface IMainCli {
99+
main: (argv: NodeJS.Process['argv']) => Promise<void>;
100+
}
101+
102+
/**
103+
* @deprecated This should be removed when code-server merges with lib/vscode
104+
*/
105+
export interface CliMessage {
106+
type: 'cli';
107+
args: ServerParsedArgs;
108+
}
109+
110+
/**
111+
* @deprecated This should be removed when code-server merges with lib/vscode
112+
*/
113+
export interface OpenCommandPipeArgs {
114+
type: 'open';
115+
fileURIs?: string[];
116+
folderURIs: string[];
117+
forceNewWindow?: boolean;
118+
diffMode?: boolean;
119+
addMode?: boolean;
120+
gotoLineMode?: boolean;
121+
forceReuseWindow?: boolean;
122+
waitMarkerFilePath?: string;
123+
}
124+
125+
export type NLSConfigurationWeb = NLSConfiguration | InternalNLSConfiguration;
126+
export { NLSConfiguration, InternalNLSConfiguration };
127+
}
128+
}
129+
130+
export { };

0 commit comments

Comments
 (0)