Extension host (#20)
* Implement net.Server * Move Socket class into Client This way we don't need to expose anything. * Remove some unused imports * Pass environment variables to bootstrap fork * Add debug log for when socket disconnects from server * Use VSCODE_ALLOW_IO for shared process only * Extension host can send messages now * Support callback for logging This lets us do potentially expensive operations which will only be performed if the log level is sufficiently low. * Stop extension host from committing suicide * Blank line * Add static serve (#21) * Add extension URLs * how did i remove this * Fix writing an empty string * Implement dialogs on window service
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
"build:nexe": "node scripts/nexe.js",
|
||||
"build:bootstrap-fork": "cd ../vscode && npm run build:bootstrap-fork; cp ./bin/bootstrap-fork.js ../server/build/bootstrap-fork.js",
|
||||
"build:default-extensions": "cd ../../lib/vscode && npx gulp vscode-linux-arm && cd ../.. && cp -r ./lib/VSCode-linux-arm/resources/app/extensions/* ./packages/server/build/extensions/",
|
||||
"build:web": "cd ../web && npm run build; mkdir ../server/build/web && cp ./out/* ../server/build/web",
|
||||
"build": "npm run build:bootstrap-fork && npm run build:webpack && npm run build:nexe"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -17,7 +18,7 @@
|
||||
"@oclif/plugin-help": "^2.1.4",
|
||||
"express": "^4.16.4",
|
||||
"nexe": "^2.0.0-rc.34",
|
||||
"node-pty": "^0.8.0",
|
||||
"node-pty": "^0.8.1",
|
||||
"spdlog": "^0.7.2",
|
||||
"ws": "^6.1.2"
|
||||
},
|
||||
|
@ -24,6 +24,7 @@ export class Entry extends Command {
|
||||
|
||||
// Dev flags
|
||||
"bootstrap-fork": flags.string({ hidden: true }),
|
||||
env: flags.string({ hidden: true }),
|
||||
};
|
||||
public static args = [{
|
||||
name: "workdir",
|
||||
@ -50,6 +51,10 @@ export class Entry extends Command {
|
||||
|
||||
const { args, flags } = this.parse(Entry);
|
||||
|
||||
if (flags.env) {
|
||||
Object.assign(process.env, JSON.parse(flags.env));
|
||||
}
|
||||
|
||||
if (flags["bootstrap-fork"]) {
|
||||
const modulePath = flags["bootstrap-fork"];
|
||||
if (!modulePath) {
|
||||
@ -95,7 +100,7 @@ export class Entry extends Command {
|
||||
|
||||
next();
|
||||
});
|
||||
if (process.env.CLI === "false" || !process.env.CLI) {
|
||||
if ((process.env.CLI === "false" || !process.env.CLI) && !process.env.SERVE_STATIC) {
|
||||
const webpackConfig = require(path.join(__dirname, "..", "..", "web", "webpack.dev.config.js"));
|
||||
const compiler = require("webpack")(webpackConfig);
|
||||
app.use(require("webpack-dev-middleware")(compiler, {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { field, logger } from "@coder/logger";
|
||||
import { logger } from "@coder/logger";
|
||||
import { ReadWriteConnection } from "@coder/protocol";
|
||||
import { Server, ServerOptions } from "@coder/protocol/src/node/server";
|
||||
import { NewSessionMessage } from '@coder/protocol/src/proto';
|
||||
import { ChildProcess } from "child_process";
|
||||
import * as express from "express";
|
||||
import * as http from "http";
|
||||
import * as path from "path";
|
||||
import * as ws from "ws";
|
||||
import { forkModule } from "./vscode/bootstrapFork";
|
||||
|
||||
@ -46,7 +47,11 @@ export const createApp = (registerMiddleware?: (app: express.Application) => voi
|
||||
forkProvider: (message: NewSessionMessage): ChildProcess => {
|
||||
let proc: ChildProcess;
|
||||
if (message.getIsBootstrapFork()) {
|
||||
proc = forkModule(message.getCommand());
|
||||
const env: NodeJS.ProcessEnv = {};
|
||||
message.getEnvMap().forEach((value, key) => {
|
||||
env[key] = value;
|
||||
});
|
||||
proc = forkModule(message.getCommand(), env);
|
||||
} else {
|
||||
throw new Error("No support for non bootstrap-forking yet");
|
||||
}
|
||||
@ -56,14 +61,7 @@ export const createApp = (registerMiddleware?: (app: express.Application) => voi
|
||||
} : undefined);
|
||||
});
|
||||
|
||||
/**
|
||||
* We should static-serve the `web` package at this point.
|
||||
*/
|
||||
app.get("/", (req, res, next) => {
|
||||
res.write("Example! :)");
|
||||
res.status(200);
|
||||
res.end();
|
||||
});
|
||||
app.use(express.static(path.join(__dirname, "../build/web")));
|
||||
|
||||
return {
|
||||
express: app,
|
||||
|
@ -5,7 +5,9 @@ import * as path from "path";
|
||||
|
||||
export const requireModule = (modulePath: string): void => {
|
||||
process.env.AMD_ENTRYPOINT = modulePath;
|
||||
process.env.VSCODE_ALLOW_IO = "true";
|
||||
|
||||
// Always do this so we can see console.logs.
|
||||
// process.env.VSCODE_ALLOW_IO = "true";
|
||||
|
||||
if (!process.send) {
|
||||
const socket = new net.Socket({ fd: 3 });
|
||||
@ -31,10 +33,13 @@ export const requireModule = (modulePath: string): void => {
|
||||
* cp.stderr.on("data", (data) => console.log(data.toString("utf8")));
|
||||
* @param modulePath Path of the VS Code module to load.
|
||||
*/
|
||||
export const forkModule = (modulePath: string): cp.ChildProcess => {
|
||||
export const forkModule = (modulePath: string, env?: NodeJS.ProcessEnv): cp.ChildProcess => {
|
||||
let proc: cp.ChildProcess | undefined;
|
||||
|
||||
const args = ["--bootstrap-fork", modulePath];
|
||||
if (env) {
|
||||
args.push("--env", JSON.stringify(env));
|
||||
}
|
||||
const options: cp.SpawnOptions = {
|
||||
stdio: [null, null, null, "pipe"],
|
||||
};
|
||||
|
@ -66,7 +66,9 @@ export class SharedProcess {
|
||||
state: SharedProcessState.Starting,
|
||||
});
|
||||
let resolved: boolean = false;
|
||||
this.activeProcess = forkModule("vs/code/electron-browser/sharedProcess/sharedProcessMain", true);
|
||||
this.activeProcess = forkModule("vs/code/electron-browser/sharedProcess/sharedProcessMain", {
|
||||
VSCODE_ALLOW_IO: "true",
|
||||
});
|
||||
this.activeProcess.on("exit", (err) => {
|
||||
if (this._state !== SharedProcessState.Stopped) {
|
||||
this.setState({
|
||||
|
@ -2313,12 +2313,7 @@ mute-stream@0.0.7:
|
||||
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
|
||||
integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=
|
||||
|
||||
nan@2.10.0:
|
||||
version "2.10.0"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f"
|
||||
integrity sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==
|
||||
|
||||
nan@^2.8.0, nan@^2.9.2:
|
||||
nan@2.12.1, nan@^2.8.0, nan@^2.9.2:
|
||||
version "2.12.1"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552"
|
||||
integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==
|
||||
@ -2396,12 +2391,12 @@ node-pre-gyp@^0.10.0:
|
||||
semver "^5.3.0"
|
||||
tar "^4"
|
||||
|
||||
node-pty@^0.8.0:
|
||||
version "0.8.0"
|
||||
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.8.0.tgz#08bccb633f49e2e3f7245eb56ea6b40f37ccd64f"
|
||||
integrity sha512-g5ggk3gN4gLrDmAllee5ScFyX3YzpOC/U8VJafha4pE7do0TIE1voiIxEbHSRUOPD1xYqmY+uHhOKAd3avbxGQ==
|
||||
node-pty@^0.8.1:
|
||||
version "0.8.1"
|
||||
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.8.1.tgz#94b457bec013e7a09b8d9141f63b0787fa25c23f"
|
||||
integrity sha512-j+/g0Q5dR+vkELclpJpz32HcS3O/3EdPSGPvDXJZVJQLCvgG0toEbfmymxAEyQyZEpaoKHAcoL+PvKM+4N9nlw==
|
||||
dependencies:
|
||||
nan "2.10.0"
|
||||
nan "2.12.1"
|
||||
|
||||
nopt@^4.0.1:
|
||||
version "4.0.1"
|
||||
|
Reference in New Issue
Block a user