Getting the client to run (#12)
* Clean up workbench and integrate initialization data * Uncomment Electron fill * Run server & client together * Clean up Electron fill & patch * Bind fs methods This makes them usable with the promise form: `promisify(access)(...)`. * Add space between tag and title to browser logger * Add typescript dep to server and default __dirname for path * Serve web files from server * Adjust some dev options * Rework workbench a bit to use a class and catch unexpected errors * No mkdirs for now, fix util fill, use bash with exec * More fills, make general client abstract * More fills * Fix cp.exec * Fix require calls in fs fill being aliased * Create data and storage dir * Implement fs.watch Using exec for now. * Implement storage database fill * Fix os export and homedir * Add comment to use navigator.sendBeacon * Fix fs callbacks (some args are optional) * Make sure data directory exists when passing it back * Update patch * Target es5 * More fills * Add APIs required for bootstrap-fork to function (#15) * Add bootstrap-fork execution * Add createConnection * Bundle bootstrap-fork into cli * Remove .node directory created from spdlog * Fix npm start * Remove unnecessary comment * Add webpack-hot-middleware if CLI env is not set * Add restarting to shared process * Fix starting with yarn
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import { ReadWriteConnection, InitData, OperatingSystem } from "../common/connection";
|
||||
import { NewEvalMessage, ServerMessage, EvalDoneMessage, EvalFailedMessage, TypedValue, ClientMessage, NewSessionMessage, TTYDimensions, SessionOutputMessage, CloseSessionInputMessage, InitMessage } from "../proto";
|
||||
import { Emitter, Event } from "@coder/events";
|
||||
import { NewEvalMessage, ServerMessage, EvalDoneMessage, EvalFailedMessage, TypedValue, ClientMessage, NewSessionMessage, TTYDimensions, SessionOutputMessage, CloseSessionInputMessage, WorkingInitMessage, NewConnectionMessage } from "../proto";
|
||||
import { Emitter } from "@coder/events";
|
||||
import { logger, field } from "@coder/logger";
|
||||
import { ChildProcess, SpawnOptions, ServerProcess } from "./command";
|
||||
import { ChildProcess, SpawnOptions, ServerProcess, ServerSocket, Socket } from "./command";
|
||||
|
||||
/**
|
||||
* Client accepts an arbitrary connection intended to communicate with the Server.
|
||||
@ -13,10 +13,14 @@ export class Client {
|
||||
private evalFailedEmitter: Emitter<EvalFailedMessage> = new Emitter();
|
||||
|
||||
private sessionId: number = 0;
|
||||
private sessions: Map<number, ServerProcess> = new Map();
|
||||
private readonly sessions: Map<number, ServerProcess> = new Map();
|
||||
|
||||
private connectionId: number = 0;
|
||||
private readonly connections: Map<number, ServerSocket> = new Map();
|
||||
|
||||
private _initData: InitData | undefined;
|
||||
private initDataEmitter: Emitter<InitData> = new Emitter();
|
||||
private initDataPromise: Promise<InitData>;
|
||||
|
||||
/**
|
||||
* @param connection Established connection to the server
|
||||
@ -33,14 +37,14 @@ export class Client {
|
||||
logger.error("Failed to handle server message", field("length", data.byteLength), field("exception", ex));
|
||||
}
|
||||
});
|
||||
|
||||
this.initDataPromise = new Promise((resolve): void => {
|
||||
this.initDataEmitter.event(resolve);
|
||||
});
|
||||
}
|
||||
|
||||
public get onInitData(): Event<InitData> {
|
||||
return this.initDataEmitter.event;
|
||||
}
|
||||
|
||||
public get initData(): InitData | undefined {
|
||||
return this._initData;
|
||||
public get initData(): Promise<InitData> {
|
||||
return this.initDataPromise;
|
||||
}
|
||||
|
||||
public evaluate<R>(func: () => R | Promise<R>): Promise<R>;
|
||||
@ -62,7 +66,7 @@ export class Client {
|
||||
* @param func Function to evaluate
|
||||
* @returns Promise rejected or resolved from the evaluated function
|
||||
*/
|
||||
public evaluate<R, T1, T2, T3, T4, T5, T6>(func: (a1?: T1, a2?: T2, a3?: T3, a4?: T4, a5?: T5, a6?: T6) => R | Promise<R>, a1?: T1, a2?: T2, a3?: T3, a4?: T4, a5?: T5, a6?: T6): Promise<R> {
|
||||
public evaluate<R, T1, T2, T3, T4, T5, T6>(func: (a1?: T1, a2?: T2, a3?: T3, a4?: T4, a5?: T5, a6?: T6) => R | Promise<R>, a1?: T1, a2?: T2, a3?: T3, a4?: T4, a5?: T5, a6?: T6): Promise<R> {
|
||||
const newEval = new NewEvalMessage();
|
||||
const id = this.evalId++;
|
||||
newEval.setId(id);
|
||||
@ -151,6 +155,27 @@ export class Client {
|
||||
return this.doSpawn(modulePath, args, options, true);
|
||||
}
|
||||
|
||||
public createConnection(path: string, callback?: () => void): Socket;
|
||||
public createConnection(port: number, callback?: () => void): Socket;
|
||||
public createConnection(target: string | number, callback?: () => void): Socket {
|
||||
const id = this.connectionId++;
|
||||
const newCon = new NewConnectionMessage();
|
||||
newCon.setId(id);
|
||||
if (typeof target === "string") {
|
||||
newCon.setPath(target);
|
||||
} else {
|
||||
newCon.setPort(target);
|
||||
}
|
||||
const clientMsg = new ClientMessage();
|
||||
clientMsg.setNewConnection(newCon);
|
||||
this.connection.send(clientMsg.serializeBinary());
|
||||
|
||||
const socket = new ServerSocket(this.connection, id, callback);
|
||||
this.connections.set(id, socket);
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
private doSpawn(command: string, args: string[] = [], options?: SpawnOptions, isFork: boolean = false): ChildProcess {
|
||||
const id = this.sessionId++;
|
||||
const newSess = new NewSessionMessage();
|
||||
@ -200,13 +225,13 @@ export class Client {
|
||||
const init = message.getInit()!;
|
||||
let opSys: OperatingSystem;
|
||||
switch (init.getOperatingSystem()) {
|
||||
case InitMessage.OperatingSystem.WINDOWS:
|
||||
case WorkingInitMessage.OperatingSystem.WINDOWS:
|
||||
opSys = OperatingSystem.Windows;
|
||||
break;
|
||||
case InitMessage.OperatingSystem.LINUX:
|
||||
case WorkingInitMessage.OperatingSystem.LINUX:
|
||||
opSys = OperatingSystem.Linux;
|
||||
break;
|
||||
case InitMessage.OperatingSystem.MAC:
|
||||
case WorkingInitMessage.OperatingSystem.MAC:
|
||||
opSys = OperatingSystem.Mac;
|
||||
break;
|
||||
default:
|
||||
@ -253,6 +278,33 @@ export class Client {
|
||||
return;
|
||||
}
|
||||
s.pid = message.getIdentifySession()!.getPid();
|
||||
} else if (message.hasConnectionEstablished()) {
|
||||
const c = this.connections.get(message.getConnectionEstablished()!.getId());
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c.emit("connect");
|
||||
} else if (message.hasConnectionOutput()) {
|
||||
const c = this.connections.get(message.getConnectionOutput()!.getId());
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c.emit("data", Buffer.from(message.getConnectionOutput()!.getData_asU8()));
|
||||
} else if (message.hasConnectionClose()) {
|
||||
const c = this.connections.get(message.getConnectionClose()!.getId());
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c.emit("close");
|
||||
c.emit("end");
|
||||
this.connections.delete(message.getConnectionClose()!.getId());
|
||||
} else if (message.hasConnectionFailure()) {
|
||||
const c = this.connections.get(message.getConnectionFailure()!.getId());
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c.emit("end");
|
||||
this.connections.delete(message.getConnectionFailure()!.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as events from "events";
|
||||
import * as stream from "stream";
|
||||
import { SendableConnection } from "../common/connection";
|
||||
import { ShutdownSessionMessage, ClientMessage, SessionOutputMessage, WriteToSessionMessage, ResizeSessionTTYMessage, TTYDimensions as ProtoTTYDimensions } from "../proto";
|
||||
import { ShutdownSessionMessage, ClientMessage, WriteToSessionMessage, ResizeSessionTTYMessage, TTYDimensions as ProtoTTYDimensions, ConnectionOutputMessage, ConnectionCloseMessage } from "../proto";
|
||||
|
||||
export interface TTYDimensions {
|
||||
readonly columns: number;
|
||||
@ -33,8 +33,8 @@ export interface ChildProcess {
|
||||
|
||||
export class ServerProcess extends events.EventEmitter implements ChildProcess {
|
||||
public readonly stdin = new stream.Writable();
|
||||
public readonly stdout = new stream.Readable({ read: () => true });
|
||||
public readonly stderr = new stream.Readable({ read: () => true });
|
||||
public readonly stdout = new stream.Readable({ read: (): boolean => true });
|
||||
public readonly stderr = new stream.Readable({ read: (): boolean => true });
|
||||
public pid: number | undefined;
|
||||
|
||||
private _killed: boolean = false;
|
||||
@ -42,7 +42,7 @@ export class ServerProcess extends events.EventEmitter implements ChildProcess {
|
||||
public constructor(
|
||||
private readonly connection: SendableConnection,
|
||||
private readonly id: number,
|
||||
private readonly hasTty: boolean = false,
|
||||
private readonly hasTty: boolean = false,
|
||||
) {
|
||||
super();
|
||||
|
||||
@ -77,7 +77,7 @@ export class ServerProcess extends events.EventEmitter implements ChildProcess {
|
||||
this.connection.send(client.serializeBinary());
|
||||
}
|
||||
|
||||
public resize(dimensions: TTYDimensions) {
|
||||
public resize(dimensions: TTYDimensions): void {
|
||||
const resize = new ResizeSessionTTYMessage();
|
||||
resize.setId(this.id);
|
||||
const tty = new ProtoTTYDimensions();
|
||||
@ -89,3 +89,129 @@ export class ServerProcess extends events.EventEmitter implements ChildProcess {
|
||||
this.connection.send(client.serializeBinary());
|
||||
}
|
||||
}
|
||||
|
||||
export interface Socket {
|
||||
readonly destroyed: boolean;
|
||||
readonly connecting: boolean;
|
||||
write(buffer: Buffer): void;
|
||||
end(): void;
|
||||
|
||||
addListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
addListener(event: "close", listener: (hasError: boolean) => void): this;
|
||||
addListener(event: "connect", listener: () => void): this;
|
||||
addListener(event: "end", listener: () => void): this;
|
||||
|
||||
on(event: "data", listener: (data: Buffer) => void): this;
|
||||
on(event: "close", listener: (hasError: boolean) => void): this;
|
||||
on(event: "connect", listener: () => void): this;
|
||||
on(event: "end", listener: () => void): this;
|
||||
|
||||
once(event: "data", listener: (data: Buffer) => void): this;
|
||||
once(event: "close", listener: (hasError: boolean) => void): this;
|
||||
once(event: "connect", listener: () => void): this;
|
||||
once(event: "end", listener: () => void): this;
|
||||
|
||||
removeListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
removeListener(event: "close", listener: (hasError: boolean) => void): this;
|
||||
removeListener(event: "connect", listener: () => void): this;
|
||||
removeListener(event: "end", listener: () => void): this;
|
||||
|
||||
emit(event: "data", data: Buffer): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "connect"): boolean;
|
||||
emit(event: "end"): boolean;
|
||||
}
|
||||
|
||||
|
||||
export class ServerSocket extends events.EventEmitter implements Socket {
|
||||
|
||||
public writable: boolean = true;
|
||||
public readable: boolean = true;
|
||||
|
||||
private _destroyed: boolean = false;
|
||||
private _connecting: boolean = true;
|
||||
|
||||
public constructor(
|
||||
private readonly connection: SendableConnection,
|
||||
private readonly id: number,
|
||||
connectCallback?: () => void,
|
||||
) {
|
||||
super();
|
||||
|
||||
if (connectCallback) {
|
||||
this.once("connect", () => {
|
||||
this._connecting = false;
|
||||
connectCallback();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public get destroyed(): boolean {
|
||||
return this._destroyed;
|
||||
}
|
||||
|
||||
public get connecting(): boolean {
|
||||
return this._connecting;
|
||||
}
|
||||
|
||||
public write(buffer: Buffer): void {
|
||||
const sendData = new ConnectionOutputMessage();
|
||||
sendData.setId(this.id);
|
||||
sendData.setData(buffer);
|
||||
const client = new ClientMessage();
|
||||
client.setConnectionOutput(sendData);
|
||||
this.connection.send(client.serializeBinary());
|
||||
}
|
||||
|
||||
public end(): void {
|
||||
const closeMsg = new ConnectionCloseMessage();
|
||||
closeMsg.setId(this.id);
|
||||
const client = new ClientMessage();
|
||||
client.setConnectionClose(closeMsg);
|
||||
this.connection.send(client.serializeBinary());
|
||||
}
|
||||
|
||||
public addListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
public addListener(event: "close", listener: (hasError: boolean) => void): this;
|
||||
public addListener(event: "connect", listener: () => void): this;
|
||||
public addListener(event: "end", listener: () => void): this;
|
||||
public addListener(event: string, listener: any): this {
|
||||
return super.addListener(event, listener);
|
||||
}
|
||||
|
||||
public removeListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
public removeListener(event: "close", listener: (hasError: boolean) => void): this;
|
||||
public removeListener(event: "connect", listener: () => void): this;
|
||||
public removeListener(event: "end", listener: () => void): this;
|
||||
public removeListener(event: string, listener: any): this {
|
||||
return super.removeListener(event, listener);
|
||||
}
|
||||
|
||||
public on(event: "data", listener: (data: Buffer) => void): this;
|
||||
public on(event: "close", listener: (hasError: boolean) => void): this;
|
||||
public on(event: "connect", listener: () => void): this;
|
||||
public on(event: "end", listener: () => void): this;
|
||||
public on(event: string, listener: any): this {
|
||||
return super.on(event, listener);
|
||||
}
|
||||
|
||||
public once(event: "data", listener: (data: Buffer) => void): this;
|
||||
public once(event: "close", listener: (hasError: boolean) => void): this;
|
||||
public once(event: "connect", listener: () => void): this;
|
||||
public once(event: "end", listener: () => void): this;
|
||||
public once(event: string, listener: any): this {
|
||||
return super.once(event, listener);
|
||||
}
|
||||
|
||||
public emit(event: "data", data: Buffer): boolean;
|
||||
public emit(event: "close"): boolean;
|
||||
public emit(event: "connect"): boolean;
|
||||
public emit(event: "end"): boolean;
|
||||
public emit(event: string, ...args: any[]): boolean {
|
||||
return super.emit(event, ...args);
|
||||
}
|
||||
|
||||
public setDefaultEncoding(encoding: string): this {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import * as cp from "child_process";
|
||||
import { Client } from "../client";
|
||||
import { useBuffer } from "./util";
|
||||
import { useBuffer } from "../../common/util";
|
||||
|
||||
export class CP {
|
||||
|
||||
@ -13,19 +13,21 @@ export class CP {
|
||||
options?: { encoding?: BufferEncoding | string | "buffer" | null } & cp.ExecOptions | null | ((error: Error | null, stdout: string, stderr: string) => void) | ((error: Error | null, stdout: Buffer, stderr: Buffer) => void),
|
||||
callback?: ((error: Error | null, stdout: string, stderr: string) => void) | ((error: Error | null, stdout: Buffer, stderr: Buffer) => void),
|
||||
): cp.ChildProcess => {
|
||||
const process = this.client.spawn(command);
|
||||
// TODO: Probably should add an `exec` instead of using `spawn`, especially
|
||||
// since bash might not be available.
|
||||
const childProcess = this.client.spawn("bash", ["-c", command.replace(/"/g, "\\\"")]);
|
||||
|
||||
let stdout = "";
|
||||
process.stdout.on("data", (data) => {
|
||||
childProcess.stdout.on("data", (data) => {
|
||||
stdout += data.toString();
|
||||
});
|
||||
|
||||
let stderr = "";
|
||||
process.stderr.on("data", (data) => {
|
||||
childProcess.stderr.on("data", (data) => {
|
||||
stderr += data.toString();
|
||||
});
|
||||
|
||||
process.on("exit", (exitCode) => {
|
||||
childProcess.on("exit", (exitCode) => {
|
||||
const error = exitCode !== 0 ? new Error(stderr) : null;
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
@ -39,15 +41,15 @@ export class CP {
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
return process;
|
||||
return childProcess;
|
||||
}
|
||||
|
||||
public fork(modulePath: string): cp.ChildProcess {
|
||||
public fork = (modulePath: string, args?: ReadonlyArray<string> | cp.ForkOptions, options?: cp.ForkOptions): cp.ChildProcess => {
|
||||
//@ts-ignore
|
||||
return this.client.fork(modulePath);
|
||||
return this.client.fork(modulePath, args, options);
|
||||
}
|
||||
|
||||
public spawn(command: string, args?: ReadonlyArray<string> | cp.SpawnOptions, _options?: cp.SpawnOptions): cp.ChildProcess {
|
||||
public spawn = (command: string, args?: ReadonlyArray<string> | cp.SpawnOptions, options?: cp.SpawnOptions): cp.ChildProcess => {
|
||||
// TODO: fix this ignore. Should check for args or options here
|
||||
//@ts-ignore
|
||||
return this.client.spawn(command, args, options);
|
||||
|
@ -1,9 +1,20 @@
|
||||
import { exec, ChildProcess } from "child_process";
|
||||
import { EventEmitter } from "events";
|
||||
import * as fs from "fs";
|
||||
import { IEncodingOptions, IEncodingOptionsCallback, escapePath, useBuffer } from "../../common/util";
|
||||
import { Client } from "../client";
|
||||
|
||||
// Use this to get around Webpack inserting our fills.
|
||||
// TODO: is there a better way?
|
||||
declare var _require: typeof require;
|
||||
|
||||
/**
|
||||
* Implements the native fs module
|
||||
* Doesn't use `implements typeof import("fs")` to remove need for __promisify__ impls
|
||||
*
|
||||
* TODO: For now we can't use async in the evaluate calls because they get
|
||||
* transpiled to TypeScript's helpers. tslib is included but we also need to set
|
||||
* _this somehow which the __awaiter helper uses.
|
||||
*/
|
||||
export class FS {
|
||||
|
||||
@ -11,34 +22,46 @@ export class FS {
|
||||
private readonly client: Client,
|
||||
) { }
|
||||
|
||||
public access(path: fs.PathLike, mode: number | undefined, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public access = (path: fs.PathLike, mode: number | undefined | ((err: NodeJS.ErrnoException) => void), callback?: (err: NodeJS.ErrnoException) => void): void => {
|
||||
if (typeof mode === "function") {
|
||||
callback = mode;
|
||||
mode = undefined;
|
||||
}
|
||||
this.client.evaluate((path, mode) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.access)(path, mode);
|
||||
}, path, mode).then(() => {
|
||||
callback(undefined!);
|
||||
callback!(undefined!);
|
||||
}).catch((ex) => {
|
||||
callback(ex);
|
||||
callback!(ex);
|
||||
});
|
||||
}
|
||||
|
||||
public appendFile(file: fs.PathLike | number, data: any, options: { encoding?: string | null, mode?: string | number, flag?: string } | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
// tslint:disable-next-line no-any
|
||||
public appendFile = (file: fs.PathLike | number, data: any, options: IEncodingOptionsCallback, callback?: (err: NodeJS.ErrnoException) => void): void => {
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
this.client.evaluate((path, data, options) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.appendFile)(path, data, options);
|
||||
}, file, data, options).then(() => {
|
||||
callback(undefined!);
|
||||
callback!(undefined!);
|
||||
}).catch((ex) => {
|
||||
callback(ex);
|
||||
callback!(ex);
|
||||
});
|
||||
}
|
||||
|
||||
public chmod(path: fs.PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public chmod = (path: fs.PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((path, mode) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.chmod)(path, mode);
|
||||
}, path, mode).then(() => {
|
||||
callback(undefined!);
|
||||
@ -47,10 +70,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public chown(path: fs.PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public chown = (path: fs.PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((path, uid, gid) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.chown)(path, uid, gid);
|
||||
}, path, uid, gid).then(() => {
|
||||
callback(undefined!);
|
||||
@ -59,10 +83,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public close(fd: number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public close = (fd: number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((fd) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.close)(fd);
|
||||
}, fd).then(() => {
|
||||
callback(undefined!);
|
||||
@ -71,26 +96,31 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public copyFile(src: fs.PathLike, dest: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
this.client.evaluate((src, dest) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
return util.promisify(fs.copyFile)(src, dest);
|
||||
}, src, dest).then(() => {
|
||||
callback(undefined!);
|
||||
public copyFile = (src: fs.PathLike, dest: fs.PathLike, flags: number | ((err: NodeJS.ErrnoException) => void), callback?: (err: NodeJS.ErrnoException) => void): void => {
|
||||
if (typeof flags === "function") {
|
||||
callback = flags;
|
||||
}
|
||||
this.client.evaluate((src, dest, flags) => {
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.copyFile)(src, dest, flags);
|
||||
}, src, dest, typeof flags !== "function" ? flags : undefined).then(() => {
|
||||
callback!(undefined!);
|
||||
}).catch((ex) => {
|
||||
callback(ex);
|
||||
callback!(ex);
|
||||
});
|
||||
}
|
||||
|
||||
public createWriteStream(): void {
|
||||
public createWriteStream = (): void => {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public exists(path: fs.PathLike, callback: (exists: boolean) => void): void {
|
||||
public exists = (path: fs.PathLike, callback: (exists: boolean) => void): void => {
|
||||
this.client.evaluate((path) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.exists)(path);
|
||||
}, path).then((r) => {
|
||||
callback(r);
|
||||
@ -99,10 +129,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public fchmod(fd: number, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public fchmod = (fd: number, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((fd, mode) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.fchmod)(fd, mode);
|
||||
}, fd, mode).then(() => {
|
||||
callback(undefined!);
|
||||
@ -111,10 +142,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public fchown(fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public fchown = (fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((fd, uid, gid) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.fchown)(fd, uid, gid);
|
||||
}, fd, uid, gid).then(() => {
|
||||
callback(undefined!);
|
||||
@ -123,10 +155,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public fdatasync(fd: number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public fdatasync = (fd: number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((fd) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.fdatasync)(fd);
|
||||
}, fd).then(() => {
|
||||
callback(undefined!);
|
||||
@ -135,21 +168,23 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public fstat(fd: number, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => void): void {
|
||||
this.client.evaluate(async (fd) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const stats = await util.promisify(fs.fstat)(fd);
|
||||
return {
|
||||
...stats,
|
||||
_isBlockDevice: stats.isBlockDevice(),
|
||||
_isCharacterDevice: stats.isCharacterDevice(),
|
||||
_isDirectory: stats.isDirectory(),
|
||||
_isFIFO: stats.isFIFO(),
|
||||
_isFile: stats.isFile(),
|
||||
_isSocket: stats.isSocket(),
|
||||
_isSymbolicLink: stats.isSymbolicLink(),
|
||||
};
|
||||
public fstat = (fd: number, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => void): void => {
|
||||
this.client.evaluate((fd) => {
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.fstat)(fd).then((stats) => {
|
||||
return {
|
||||
...stats,
|
||||
_isBlockDevice: stats.isBlockDevice(),
|
||||
_isCharacterDevice: stats.isCharacterDevice(),
|
||||
_isDirectory: stats.isDirectory(),
|
||||
_isFIFO: stats.isFIFO(),
|
||||
_isFile: stats.isFile(),
|
||||
_isSocket: stats.isSocket(),
|
||||
_isSymbolicLink: stats.isSymbolicLink(),
|
||||
};
|
||||
});
|
||||
}, fd).then((stats) => {
|
||||
callback(undefined!, Stats.fromObject(stats));
|
||||
}).catch((ex) => {
|
||||
@ -157,10 +192,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public fsync(fd: number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public fsync = (fd: number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((fd) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.fsync)(fd);
|
||||
}, fd).then(() => {
|
||||
callback(undefined!);
|
||||
@ -169,22 +205,28 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public ftruncate(fd: number, len: number | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public ftruncate = (fd: number, len: number | undefined | null | ((err: NodeJS.ErrnoException) => void), callback?: (err: NodeJS.ErrnoException) => void): void => {
|
||||
if (typeof len === "function") {
|
||||
callback = len;
|
||||
len = undefined;
|
||||
}
|
||||
this.client.evaluate((fd, len) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.ftruncate)(fd, len);
|
||||
}, fd, len).then(() => {
|
||||
callback(undefined!);
|
||||
callback!(undefined!);
|
||||
}).catch((ex) => {
|
||||
callback(ex);
|
||||
callback!(ex);
|
||||
});
|
||||
}
|
||||
|
||||
public futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public futimes = (fd: number, atime: string | number | Date, mtime: string | number | Date, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((fd, atime, mtime) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.futimes)(fd, atime, mtime);
|
||||
}, fd, atime, mtime).then(() => {
|
||||
callback(undefined!);
|
||||
@ -193,10 +235,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public lchmod(path: fs.PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public lchmod = (path: fs.PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((path, mode) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.lchmod)(path, mode);
|
||||
}, path, mode).then(() => {
|
||||
callback(undefined!);
|
||||
@ -205,10 +248,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public lchown(path: fs.PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public lchown = (path: fs.PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((path, uid, gid) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.lchown)(path, uid, gid);
|
||||
}, path, uid, gid).then(() => {
|
||||
callback(undefined!);
|
||||
@ -217,10 +261,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public link(existingPath: fs.PathLike, newPath: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public link = (existingPath: fs.PathLike, newPath: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((existingPath, newPath) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.link)(existingPath, newPath);
|
||||
}, existingPath, newPath).then(() => {
|
||||
callback(undefined!);
|
||||
@ -229,21 +274,23 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public lstat(path: fs.PathLike, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => void): void {
|
||||
this.client.evaluate(async (path) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const stats = await util.promisify(fs.lstat)(path);
|
||||
return {
|
||||
...stats,
|
||||
_isBlockDevice: stats.isBlockDevice(),
|
||||
_isCharacterDevice: stats.isCharacterDevice(),
|
||||
_isDirectory: stats.isDirectory(),
|
||||
_isFIFO: stats.isFIFO(),
|
||||
_isFile: stats.isFile(),
|
||||
_isSocket: stats.isSocket(),
|
||||
_isSymbolicLink: stats.isSymbolicLink(),
|
||||
};
|
||||
public lstat = (path: fs.PathLike, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => void): void => {
|
||||
this.client.evaluate((path) => {
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.lstat)(path).then((stats) => {
|
||||
return {
|
||||
...stats,
|
||||
_isBlockDevice: stats.isBlockDevice(),
|
||||
_isCharacterDevice: stats.isCharacterDevice(),
|
||||
_isDirectory: stats.isDirectory(),
|
||||
_isFIFO: stats.isFIFO(),
|
||||
_isFile: stats.isFile(),
|
||||
_isSocket: stats.isSocket(),
|
||||
_isSymbolicLink: stats.isSymbolicLink(),
|
||||
};
|
||||
});
|
||||
}, path).then((stats) => {
|
||||
callback(undefined!, Stats.fromObject(stats));
|
||||
}).catch((ex) => {
|
||||
@ -251,54 +298,70 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public mkdir(path: fs.PathLike, mode: number | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public mkdir = (path: fs.PathLike, mode: number | string | fs.MakeDirectoryOptions | undefined | null | ((err: NodeJS.ErrnoException) => void), callback?: (err: NodeJS.ErrnoException) => void): void => {
|
||||
if (typeof mode === "function") {
|
||||
callback = mode;
|
||||
mode = undefined;
|
||||
}
|
||||
this.client.evaluate((path, mode) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.mkdir)(path, mode);
|
||||
}, path, mode).then(() => {
|
||||
callback(undefined!);
|
||||
callback!(undefined!);
|
||||
}).catch((ex) => {
|
||||
callback(ex);
|
||||
callback!(ex);
|
||||
});
|
||||
}
|
||||
|
||||
public mkdtemp(prefix: string, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, folder: string) => void): void {
|
||||
public mkdtemp = (prefix: string, options: IEncodingOptionsCallback, callback?: (err: NodeJS.ErrnoException, folder: string | Buffer) => void): void => {
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
this.client.evaluate((prefix, options) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.mkdtemp)(prefix, options);
|
||||
}, prefix, options).then((folder) => {
|
||||
callback(undefined!, folder);
|
||||
callback!(undefined!, folder);
|
||||
}).catch((ex) => {
|
||||
callback(ex, undefined!);
|
||||
callback!(ex, undefined!);
|
||||
});
|
||||
}
|
||||
|
||||
public open(path: fs.PathLike, flags: string | number, mode: string | number | undefined | null, callback: (err: NodeJS.ErrnoException, fd: number) => void): void {
|
||||
public open = (path: fs.PathLike, flags: string | number, mode: string | number | undefined | null | ((err: NodeJS.ErrnoException, fd: number) => void), callback?: (err: NodeJS.ErrnoException, fd: number) => void): void => {
|
||||
if (typeof mode === "function") {
|
||||
callback = mode;
|
||||
mode = undefined;
|
||||
}
|
||||
this.client.evaluate((path, flags, mode) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.open)(path, flags, mode);
|
||||
}, path, flags, mode).then((fd) => {
|
||||
callback(undefined!, fd);
|
||||
callback!(undefined!, fd);
|
||||
}).catch((ex) => {
|
||||
callback(ex, undefined!);
|
||||
callback!(ex, undefined!);
|
||||
});
|
||||
}
|
||||
|
||||
public read<TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: TBuffer) => void): void {
|
||||
this.client.evaluate(async (fd, bufferLength, length, position) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
public read = <TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: TBuffer) => void): void => {
|
||||
this.client.evaluate((fd, length, position) => {
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
const buffer = new Buffer(length);
|
||||
const resp = await util.promisify(fs.read)(fd, buffer, 0, length, position);
|
||||
|
||||
return {
|
||||
bytesRead: resp.bytesRead,
|
||||
content: buffer.toString("utf8"),
|
||||
};
|
||||
}, fd, buffer.byteLength, length, position).then((resp) => {
|
||||
return util.promisify(fs.read)(fd, buffer, 0, length, position).then((resp) => {
|
||||
return {
|
||||
bytesRead: resp.bytesRead,
|
||||
content: buffer.toString("utf8"),
|
||||
};
|
||||
}):
|
||||
}, fd, length, position).then((resp) => {
|
||||
const newBuf = Buffer.from(resp.content, "utf8");
|
||||
buffer.set(newBuf, offset);
|
||||
callback(undefined!, resp.bytesRead, newBuf as TBuffer);
|
||||
@ -307,60 +370,80 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public readFile(path: fs.PathLike | number, options: string | { encoding?: string | null | undefined; flag?: string | undefined; } | null | undefined, callback: (err: NodeJS.ErrnoException, data: string | Buffer) => void): void {
|
||||
this.client.evaluate(async (path, options) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const value = await util.promisify(fs.readFile)(path, options);
|
||||
public readFile = (path: fs.PathLike | number, options: IEncodingOptionsCallback, callback?: (err: NodeJS.ErrnoException, data: string | Buffer) => void): void => {
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
this.client.evaluate((path, options) => {
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return value.toString();
|
||||
return util.promisify(fs.readFile)(path, options).then((value) => value.toString());
|
||||
}, path, options).then((buffer) => {
|
||||
callback(undefined!, buffer);
|
||||
callback!(undefined!, buffer);
|
||||
}).catch((ex) => {
|
||||
callback(ex, undefined!);
|
||||
callback!(ex, undefined!);
|
||||
});
|
||||
}
|
||||
|
||||
public readdir(path: fs.PathLike, options: { encoding: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void {
|
||||
public readdir = (path: fs.PathLike, options: IEncodingOptionsCallback, callback?: (err: NodeJS.ErrnoException, files: Buffer[] | fs.Dirent[] | string[]) => void): void => {
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
// TODO: options can also take `withFileTypes` but the types aren't working.
|
||||
this.client.evaluate((path, options) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.readdir)(path, options);
|
||||
}, path, options).then((files) => {
|
||||
callback(undefined!, files);
|
||||
callback!(undefined!, files);
|
||||
}).catch((ex) => {
|
||||
callback(ex, undefined!);
|
||||
callback!(ex, undefined!);
|
||||
});
|
||||
}
|
||||
|
||||
public readlink(path: fs.PathLike, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, linkString: string) => void): void {
|
||||
public readlink = (path: fs.PathLike, options: IEncodingOptionsCallback, callback?: (err: NodeJS.ErrnoException, linkString: string | Buffer) => void): void => {
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
this.client.evaluate((path, options) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.readlink)(path, options);
|
||||
}, path, options).then((linkString) => {
|
||||
callback(undefined!, linkString);
|
||||
callback!(undefined!, linkString);
|
||||
}).catch((ex) => {
|
||||
callback(ex, undefined!);
|
||||
callback!(ex, undefined!);
|
||||
});
|
||||
}
|
||||
|
||||
public realpath(path: fs.PathLike, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => void): void {
|
||||
public realpath = (path: fs.PathLike, options: IEncodingOptionsCallback, callback?: (err: NodeJS.ErrnoException, resolvedPath: string | Buffer) => void): void => {
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
this.client.evaluate((path, options) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.realpath)(path, options);
|
||||
}, path, options).then((resolvedPath) => {
|
||||
callback(undefined!, resolvedPath);
|
||||
callback!(undefined!, resolvedPath);
|
||||
}).catch((ex) => {
|
||||
callback(ex, undefined!);
|
||||
callback!(ex, undefined!);
|
||||
});
|
||||
}
|
||||
|
||||
public rename(oldPath: fs.PathLike, newPath: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public rename = (oldPath: fs.PathLike, newPath: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((oldPath, newPath) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.rename)(oldPath, newPath);
|
||||
}, oldPath, newPath).then(() => {
|
||||
callback(undefined!);
|
||||
@ -369,10 +452,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public rmdir(path: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public rmdir = (path: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((path) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.rmdir)(path);
|
||||
}, path).then(() => {
|
||||
callback(undefined!);
|
||||
@ -381,21 +465,23 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public stat(path: fs.PathLike, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => void): void {
|
||||
this.client.evaluate(async (path) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const stats = await util.promisify(fs.stat)(path);
|
||||
return {
|
||||
...stats,
|
||||
_isBlockDevice: stats.isBlockDevice(),
|
||||
_isCharacterDevice: stats.isCharacterDevice(),
|
||||
_isDirectory: stats.isDirectory(),
|
||||
_isFIFO: stats.isFIFO(),
|
||||
_isFile: stats.isFile(),
|
||||
_isSocket: stats.isSocket(),
|
||||
_isSymbolicLink: stats.isSymbolicLink(),
|
||||
};
|
||||
public stat = (path: fs.PathLike, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => void): void => {
|
||||
this.client.evaluate((path) => {
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.stat)(path).then((stats) => {
|
||||
return {
|
||||
...stats,
|
||||
_isBlockDevice: stats.isBlockDevice(),
|
||||
_isCharacterDevice: stats.isCharacterDevice(),
|
||||
_isDirectory: stats.isDirectory(),
|
||||
_isFIFO: stats.isFIFO(),
|
||||
_isFile: stats.isFile(),
|
||||
_isSocket: stats.isSocket(),
|
||||
_isSymbolicLink: stats.isSymbolicLink(),
|
||||
};
|
||||
});
|
||||
}, path).then((stats) => {
|
||||
callback(undefined!, Stats.fromObject(stats));
|
||||
}).catch((ex) => {
|
||||
@ -403,34 +489,45 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public symlink(target: fs.PathLike, path: fs.PathLike, type: fs.symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public symlink = (target: fs.PathLike, path: fs.PathLike, type: fs.symlink.Type | undefined | null | ((err: NodeJS.ErrnoException) => void), callback?: (err: NodeJS.ErrnoException) => void): void => {
|
||||
if (typeof type === "function") {
|
||||
callback = type;
|
||||
type = undefined;
|
||||
}
|
||||
this.client.evaluate((target, path, type) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.symlink)(target, path, type);
|
||||
}, target, path, type).then(() => {
|
||||
callback(undefined!);
|
||||
callback!(undefined!);
|
||||
}).catch((ex) => {
|
||||
callback(ex);
|
||||
callback!(ex);
|
||||
});
|
||||
}
|
||||
|
||||
public truncate(path: fs.PathLike, len: number | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public truncate = (path: fs.PathLike, len: number | undefined | null | ((err: NodeJS.ErrnoException) => void), callback?: (err: NodeJS.ErrnoException) => void): void => {
|
||||
if (typeof len === "function") {
|
||||
callback = len;
|
||||
len = undefined;
|
||||
}
|
||||
this.client.evaluate((path, len) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.truncate)(path, len);
|
||||
}, path, len).then(() => {
|
||||
callback(undefined!);
|
||||
callback!(undefined!);
|
||||
}).catch((ex) => {
|
||||
callback(ex);
|
||||
callback!(ex);
|
||||
});
|
||||
}
|
||||
|
||||
public unlink(path: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public unlink = (path: fs.PathLike, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((path) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.unlink)(path);
|
||||
}, path).then(() => {
|
||||
callback(undefined!);
|
||||
@ -439,10 +536,11 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public utimes(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
public utimes = (path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date, callback: (err: NodeJS.ErrnoException) => void): void => {
|
||||
this.client.evaluate((path, atime, mtime) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.utimes)(path, atime, mtime);
|
||||
}, path, atime, mtime).then(() => {
|
||||
callback(undefined!);
|
||||
@ -451,38 +549,112 @@ export class FS {
|
||||
});
|
||||
}
|
||||
|
||||
public write<TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number | undefined, length: number | undefined, position: number | undefined, callback: (err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void): void {
|
||||
this.client.evaluate(async (fd, buffer, offset, length, position) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const resp = await util.promisify(fs.write)(fd, Buffer.from(buffer, "utf8"), offset, length, position);
|
||||
public write = <TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number | undefined, length: number | undefined, position: number | undefined | ((err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void), callback?: (err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void): void => {
|
||||
if (typeof position === "function") {
|
||||
callback = position;
|
||||
position = undefined;
|
||||
}
|
||||
this.client.evaluate((fd, buffer, offset, length, position) => {
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return {
|
||||
bytesWritten: resp.bytesWritten,
|
||||
content: resp.buffer.toString("utf8"),
|
||||
}
|
||||
return util.promisify(fs.write)(fd, Buffer.from(buffer, "utf8"), offset, length, position).then((resp) => {
|
||||
return {
|
||||
bytesWritten: resp.bytesWritten,
|
||||
content: resp.buffer.toString("utf8"),
|
||||
};
|
||||
});
|
||||
}, fd, buffer.toString(), offset, length, position).then((r) => {
|
||||
callback(undefined!, r.bytesWritten, Buffer.from(r.content, "utf8") as TBuffer);
|
||||
callback!(undefined!, r.bytesWritten, Buffer.from(r.content, "utf8") as TBuffer);
|
||||
}).catch((ex) => {
|
||||
callback(ex, undefined!, undefined!);
|
||||
callback!(ex, undefined!, undefined!);
|
||||
});
|
||||
}
|
||||
|
||||
public writeFile(path: fs.PathLike | number, data: any, options: { encoding?: string | null; mode?: number | string; flag?: string; } | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void {
|
||||
// tslint:disable-next-line no-any
|
||||
public writeFile = (path: fs.PathLike | number, data: any, options: IEncodingOptionsCallback, callback?: (err: NodeJS.ErrnoException) => void): void => {
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
this.client.evaluate((path, data, options) => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const util = require("util") as typeof import("util");
|
||||
const fs = _require("fs") as typeof import("fs");
|
||||
const util = _require("util") as typeof import("util");
|
||||
|
||||
return util.promisify(fs.writeFile)(path, data, options);
|
||||
}, path, data, options).then(() => {
|
||||
callback(undefined!);
|
||||
callback!(undefined!);
|
||||
}).catch((ex) => {
|
||||
callback(ex);
|
||||
callback!(ex);
|
||||
});
|
||||
}
|
||||
|
||||
public watch = (filename: fs.PathLike, options: IEncodingOptions, listener?: ((event: string, filename: string) => void) | ((event: string, filename: Buffer) => void)): fs.FSWatcher => {
|
||||
// TODO: can we modify `evaluate` for long-running processes like watch?
|
||||
// Especially since inotifywait might not be available.
|
||||
const buffer = new NewlineInputBuffer((msg): void => {
|
||||
msg = msg.trim();
|
||||
const index = msg.lastIndexOf(":");
|
||||
const events = msg.substring(index + 1).split(",");
|
||||
const baseFilename = msg.substring(0, index).split("/").pop();
|
||||
events.forEach((event) => {
|
||||
switch (event) {
|
||||
// Rename is emitted when a file appears or disappears in the directory.
|
||||
case "CREATE":
|
||||
case "DELETE":
|
||||
case "MOVED_FROM":
|
||||
case "MOVED_TO":
|
||||
watcher.emit("rename", baseFilename);
|
||||
break;
|
||||
case "CLOSE_WRITE":
|
||||
watcher.emit("change", baseFilename);
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: `exec` is undefined for some reason.
|
||||
const process = exec(`inotifywait ${escapePath(filename.toString())} -m --format "%w%f:%e"`);
|
||||
process.on("exit", (exitCode) => {
|
||||
watcher.emit("error", new Error(`process terminated unexpectedly with code ${exitCode}`));
|
||||
});
|
||||
process.stdout.on("data", (data) => {
|
||||
buffer.push(data);
|
||||
});
|
||||
|
||||
const watcher = new Watcher(process);
|
||||
if (listener) {
|
||||
const l = listener;
|
||||
watcher.on("change", (filename) => {
|
||||
// @ts-ignore not sure how to make this work.
|
||||
l("change", useBuffer(options) ? Buffer.from(filename) : filename);
|
||||
});
|
||||
watcher.on("rename", (filename) => {
|
||||
// @ts-ignore not sure how to make this work.
|
||||
l("rename", useBuffer(options) ? Buffer.from(filename) : filename);
|
||||
});
|
||||
}
|
||||
|
||||
return watcher;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Watcher extends EventEmitter implements fs.FSWatcher {
|
||||
|
||||
public constructor(private readonly process: ChildProcess) {
|
||||
super();
|
||||
}
|
||||
|
||||
public close(): void {
|
||||
this.process.kill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Stats implements fs.Stats {
|
||||
|
||||
// tslint:disable-next-line no-any
|
||||
public static fromObject(object: any): Stats {
|
||||
return new Stats(object);
|
||||
}
|
||||
@ -575,3 +747,39 @@ class Stats implements fs.Stats {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for safely taking input and turning it into separate messages.
|
||||
* Assumes that messages are split by newlines.
|
||||
*/
|
||||
export class NewlineInputBuffer {
|
||||
|
||||
private callback: (msg: string) => void;
|
||||
private buffer: string | undefined;
|
||||
|
||||
public constructor(callback: (msg: string) => void) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to be buffered.
|
||||
*/
|
||||
public push(data: string | Uint8Array): void {
|
||||
let input = typeof data === "string" ? data : data.toString();
|
||||
if (this.buffer) {
|
||||
input = this.buffer + input;
|
||||
this.buffer = undefined;
|
||||
}
|
||||
const lines = input.split("\n");
|
||||
const length = lines.length - 1;
|
||||
const lastLine = lines[length];
|
||||
if (lastLine.length > 0) {
|
||||
this.buffer = lastLine;
|
||||
}
|
||||
lines.pop(); // This is either the line we buffered or an empty string.
|
||||
for (let i = 0; i < length; ++i) {
|
||||
this.callback(lines[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import * as net from "net";
|
||||
import { Client } from '../client';
|
||||
|
||||
type NodeNet = typeof net;
|
||||
|
||||
@ -7,6 +8,10 @@ type NodeNet = typeof net;
|
||||
*/
|
||||
export class Net implements NodeNet {
|
||||
|
||||
public constructor(
|
||||
private readonly client: Client,
|
||||
) {}
|
||||
|
||||
public get Socket(): typeof net.Socket {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
@ -19,8 +24,9 @@ export class Net implements NodeNet {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public createConnection(): net.Socket {
|
||||
throw new Error("not implemented");
|
||||
public createConnection(...args: any[]): net.Socket {
|
||||
//@ts-ignore
|
||||
return this.client.createConnection(...args) as net.Socket;
|
||||
}
|
||||
|
||||
public isIP(_input: string): number {
|
||||
|
@ -1,8 +0,0 @@
|
||||
/**
|
||||
* Return true if the options specify to use a Buffer instead of string.
|
||||
*/
|
||||
export const useBuffer = (options: { encoding?: string | null } | string | undefined | null | Function): boolean => {
|
||||
return options === "buffer"
|
||||
|| (!!options && typeof options !== "string" && typeof options !== "function"
|
||||
&& (options.encoding === "buffer" || options.encoding === null));
|
||||
};
|
@ -12,3 +12,23 @@ export const isBrowserEnvironment = (): boolean => {
|
||||
export const escapePath = (path: string): string => {
|
||||
return `'${path.replace(/'/g, "'\\''")}'`;
|
||||
};
|
||||
|
||||
export type IEncodingOptions = {
|
||||
encoding?: string | null;
|
||||
flag?: string;
|
||||
mode?: string;
|
||||
persistent?: boolean;
|
||||
recursive?: boolean;
|
||||
} | string | undefined | null;
|
||||
|
||||
// tslint:disable-next-line no-any
|
||||
export type IEncodingOptionsCallback = IEncodingOptions | ((err: NodeJS.ErrnoException, ...args: any[]) => void);
|
||||
|
||||
/**
|
||||
* Return true if the options specify to use a Buffer instead of string.
|
||||
*/
|
||||
export const useBuffer = (options: IEncodingOptionsCallback): boolean => {
|
||||
return options === "buffer"
|
||||
|| (!!options && typeof options !== "string" && typeof options !== "function"
|
||||
&& (options.encoding === "buffer" || options.encoding === null));
|
||||
};
|
||||
|
@ -1,8 +1,9 @@
|
||||
import * as cp from "child_process";
|
||||
import * as net from "net";
|
||||
import * as nodePty from "node-pty";
|
||||
import * as stream from "stream";
|
||||
import { TextEncoder } from "text-encoding";
|
||||
import { NewSessionMessage, ServerMessage, SessionDoneMessage, SessionOutputMessage, ShutdownSessionMessage, IdentifySessionMessage, ClientMessage } from "../proto";
|
||||
import { NewSessionMessage, ServerMessage, SessionDoneMessage, SessionOutputMessage, ShutdownSessionMessage, IdentifySessionMessage, ClientMessage, NewConnectionMessage, ConnectionEstablishedMessage, NewConnectionFailureMessage, ConnectionCloseMessage, ConnectionOutputMessage } from "../proto";
|
||||
import { SendableConnection } from "../common/connection";
|
||||
|
||||
export interface Process {
|
||||
@ -59,7 +60,7 @@ export const handleNewSession = (connection: SendableConnection, newSession: New
|
||||
};
|
||||
}
|
||||
|
||||
const sendOutput = (fd: SessionOutputMessage.FD, msg: string | Uint8Array): void => {
|
||||
const sendOutput = (_fd: SessionOutputMessage.FD, msg: string | Uint8Array): void => {
|
||||
const serverMsg = new ServerMessage();
|
||||
const d = new SessionOutputMessage();
|
||||
d.setId(newSession.getId());
|
||||
@ -90,7 +91,7 @@ export const handleNewSession = (connection: SendableConnection, newSession: New
|
||||
sm.setIdentifySession(id);
|
||||
connection.send(sm.serializeBinary());
|
||||
|
||||
process.on("exit", (code, signal) => {
|
||||
process.on("exit", (code) => {
|
||||
const serverMsg = new ServerMessage();
|
||||
const exit = new SessionDoneMessage();
|
||||
exit.setId(newSession.getId());
|
||||
@ -103,3 +104,61 @@ export const handleNewSession = (connection: SendableConnection, newSession: New
|
||||
|
||||
return process;
|
||||
};
|
||||
|
||||
export const handleNewConnection = (connection: SendableConnection, newConnection: NewConnectionMessage, onExit: () => void): net.Socket => {
|
||||
const id = newConnection.getId();
|
||||
let socket: net.Socket;
|
||||
let didConnect = false;
|
||||
const connectCallback = () => {
|
||||
didConnect = true;
|
||||
const estab = new ConnectionEstablishedMessage();
|
||||
estab.setId(id);
|
||||
const servMsg = new ServerMessage();
|
||||
servMsg.setConnectionEstablished(estab);
|
||||
connection.send(servMsg.serializeBinary());
|
||||
};
|
||||
|
||||
if (newConnection.getPath()) {
|
||||
socket = net.createConnection(newConnection.getPath(), connectCallback);
|
||||
} else if (newConnection.getPort()) {
|
||||
socket = net.createConnection(newConnection.getPort(), undefined, connectCallback);
|
||||
} else {
|
||||
throw new Error("No path or port provided for new connection");
|
||||
}
|
||||
|
||||
socket.addListener("error", (err) => {
|
||||
if (!didConnect) {
|
||||
const errMsg = new NewConnectionFailureMessage();
|
||||
errMsg.setId(id);
|
||||
errMsg.setMessage(err.message);
|
||||
const servMsg = new ServerMessage();
|
||||
servMsg.setConnectionFailure(errMsg);
|
||||
connection.send(servMsg.serializeBinary());
|
||||
|
||||
onExit();
|
||||
}
|
||||
});
|
||||
|
||||
socket.addListener("close", () => {
|
||||
if (didConnect) {
|
||||
const closed = new ConnectionCloseMessage();
|
||||
closed.setId(id);
|
||||
const servMsg = new ServerMessage();
|
||||
servMsg.setConnectionClose(closed);
|
||||
connection.send(servMsg.serializeBinary());
|
||||
|
||||
onExit();
|
||||
}
|
||||
});
|
||||
|
||||
socket.addListener("data", (data) => {
|
||||
const dataMsg = new ConnectionOutputMessage();
|
||||
dataMsg.setId(id);
|
||||
dataMsg.setData(data);
|
||||
const servMsg = new ServerMessage();
|
||||
servMsg.setConnectionOutput(dataMsg);
|
||||
connection.send(servMsg.serializeBinary());
|
||||
});
|
||||
|
||||
return socket;
|
||||
}
|
@ -29,8 +29,7 @@ export const evaluate = async (connection: SendableConnection, message: NewEvalM
|
||||
t = TypedValue.Type.NUMBER;
|
||||
break;
|
||||
default:
|
||||
sendErr(EvalFailedMessage.Reason.EXCEPTION, `unsupported response type ${tof}`);
|
||||
return;
|
||||
return sendErr(EvalFailedMessage.Reason.EXCEPTION, `unsupported response type ${tof}`);
|
||||
}
|
||||
tv.setValue(tof === "string" ? resp : JSON.stringify(resp));
|
||||
tv.setType(t);
|
||||
@ -52,11 +51,17 @@ export const evaluate = async (connection: SendableConnection, message: NewEvalM
|
||||
connection.send(serverMsg.serializeBinary());
|
||||
};
|
||||
try {
|
||||
const value = vm.runInNewContext(`(${message.getFunction()})(${argStr.join(",")})`, { Buffer, require: typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__ : require, setTimeout }, {
|
||||
const value = vm.runInNewContext(`(${message.getFunction()})(${argStr.join(",")})`, {
|
||||
Buffer,
|
||||
require: typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__ : require,
|
||||
_require: typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__ : require,
|
||||
tslib_1: require("tslib"), // TODO: is there a better way to do this?
|
||||
setTimeout,
|
||||
}, {
|
||||
timeout: message.getTimeout() || 30000,
|
||||
});
|
||||
sendResp(await value);
|
||||
} catch (ex) {
|
||||
sendErr(EvalFailedMessage.Reason.EXCEPTION, ex.toString());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -1,10 +1,14 @@
|
||||
import { logger, field } from "@coder/logger";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { mkdir } from "fs";
|
||||
import { promisify } from "util";
|
||||
import { TextDecoder } from "text-encoding";
|
||||
import { ClientMessage, InitMessage, ServerMessage } from "../proto";
|
||||
import { logger, field } from "@coder/logger";
|
||||
import { ClientMessage, WorkingInitMessage, ServerMessage } from "../proto";
|
||||
import { evaluate } from "./evaluate";
|
||||
import { ReadWriteConnection } from "../common/connection";
|
||||
import { Process, handleNewSession } from "./command";
|
||||
import { Process, handleNewSession, handleNewConnection } from "./command";
|
||||
import * as net from "net";
|
||||
|
||||
export interface ServerOptions {
|
||||
readonly workingDirectory: string;
|
||||
@ -13,14 +17,13 @@ export interface ServerOptions {
|
||||
|
||||
export class Server {
|
||||
|
||||
private readonly sessions: Map<number, Process>;
|
||||
private readonly sessions: Map<number, Process> = new Map();
|
||||
private readonly connections: Map<number, net.Socket> = new Map();
|
||||
|
||||
public constructor(
|
||||
private readonly connection: ReadWriteConnection,
|
||||
options?: ServerOptions,
|
||||
) {
|
||||
this.sessions = new Map();
|
||||
|
||||
connection.onMessage((data) => {
|
||||
try {
|
||||
this.handleMessage(ClientMessage.deserializeBinary(data));
|
||||
@ -35,22 +38,43 @@ export class Server {
|
||||
return;
|
||||
}
|
||||
|
||||
const initMsg = new InitMessage();
|
||||
// Ensure the data directory exists.
|
||||
const mkdirP = async (path: string): Promise<void> => {
|
||||
const split = path.replace(/^\/*|\/*$/g, "").split("/");
|
||||
let dir = "";
|
||||
while (split.length > 0) {
|
||||
dir += "/" + split.shift();
|
||||
try {
|
||||
await promisify(mkdir)(dir);
|
||||
} catch (error) {
|
||||
if (error.code !== "EEXIST") {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Promise.all([ mkdirP(path.join(options.dataDirectory, "User", "workspaceStorage")) ]).then(() => {
|
||||
logger.info("Created data directory");
|
||||
}).catch((error) => {
|
||||
logger.error(error.message, field("error", error));
|
||||
});
|
||||
|
||||
const initMsg = new WorkingInitMessage();
|
||||
initMsg.setDataDirectory(options.dataDirectory);
|
||||
initMsg.setWorkingDirectory(options.workingDirectory);
|
||||
initMsg.setHomeDirectory(os.homedir());
|
||||
initMsg.setTmpDirectory(os.tmpdir());
|
||||
const platform = os.platform();
|
||||
let operatingSystem: InitMessage.OperatingSystem;
|
||||
let operatingSystem: WorkingInitMessage.OperatingSystem;
|
||||
switch (platform) {
|
||||
case "win32":
|
||||
operatingSystem = InitMessage.OperatingSystem.WINDOWS;
|
||||
operatingSystem = WorkingInitMessage.OperatingSystem.WINDOWS;
|
||||
break;
|
||||
case "linux":
|
||||
operatingSystem = InitMessage.OperatingSystem.LINUX;
|
||||
operatingSystem = WorkingInitMessage.OperatingSystem.LINUX;
|
||||
break;
|
||||
case "darwin":
|
||||
operatingSystem = InitMessage.OperatingSystem.MAC;
|
||||
operatingSystem = WorkingInitMessage.OperatingSystem.MAC;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`unrecognized platform "${platform}"`);
|
||||
@ -66,9 +90,8 @@ export class Server {
|
||||
evaluate(this.connection, message.getNewEval()!);
|
||||
} else if (message.hasNewSession()) {
|
||||
const session = handleNewSession(this.connection, message.getNewSession()!, () => {
|
||||
this.sessions.delete(message.getNewSession()!.getId());
|
||||
this.sessions.delete(message.getNewSession()!.getId());
|
||||
});
|
||||
|
||||
this.sessions.set(message.getNewSession()!.getId(), session);
|
||||
} else if (message.hasCloseSessionInput()) {
|
||||
const s = this.getSession(message.getCloseSessionInput()!.getId());
|
||||
@ -95,9 +118,30 @@ export class Server {
|
||||
return;
|
||||
}
|
||||
s.write(new TextDecoder().decode(message.getWriteToSession()!.getData_asU8()));
|
||||
} else if (message.hasNewConnection()) {
|
||||
const socket = handleNewConnection(this.connection, message.getNewConnection()!, () => {
|
||||
this.connections.delete(message.getNewConnection()!.getId());
|
||||
});
|
||||
this.connections.set(message.getNewConnection()!.getId(), socket);
|
||||
} else if (message.hasConnectionOutput()) {
|
||||
const c = this.getConnection(message.getConnectionOutput()!.getId());
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c.write(Buffer.from(message.getConnectionOutput()!.getData_asU8()));
|
||||
} else if (message.hasConnectionClose()) {
|
||||
const c = this.getConnection(message.getConnectionClose()!.getId());
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c.end();
|
||||
}
|
||||
}
|
||||
|
||||
private getConnection(id: number): net.Socket | undefined {
|
||||
return this.connections.get(id);
|
||||
}
|
||||
|
||||
private getSession(id: number): Process | undefined {
|
||||
return this.sessions.get(id);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
syntax = "proto3";
|
||||
import "command.proto";
|
||||
import "node.proto";
|
||||
import "vscode.proto";
|
||||
|
||||
message ClientMessage {
|
||||
oneof msg {
|
||||
@ -10,9 +11,14 @@ message ClientMessage {
|
||||
WriteToSessionMessage write_to_session = 3;
|
||||
CloseSessionInputMessage close_session_input = 4;
|
||||
ResizeSessionTTYMessage resize_session_tty = 5;
|
||||
|
||||
NewConnectionMessage new_connection = 6;
|
||||
ConnectionOutputMessage connection_output = 7;
|
||||
ConnectionCloseMessage connection_close = 8;
|
||||
|
||||
// node.proto
|
||||
NewEvalMessage new_eval = 6;
|
||||
NewEvalMessage new_eval = 9;
|
||||
|
||||
SharedProcessInitMessage shared_process_init = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,16 +29,20 @@ message ServerMessage {
|
||||
SessionDoneMessage session_done = 2;
|
||||
SessionOutputMessage session_output = 3;
|
||||
IdentifySessionMessage identify_session = 4;
|
||||
NewConnectionFailureMessage connection_failure = 5;
|
||||
ConnectionOutputMessage connection_output = 6;
|
||||
ConnectionCloseMessage connection_close = 7;
|
||||
ConnectionEstablishedMessage connection_established = 8;
|
||||
|
||||
// node.proto
|
||||
EvalFailedMessage eval_failed = 5;
|
||||
EvalDoneMessage eval_done = 6;
|
||||
EvalFailedMessage eval_failed = 9;
|
||||
EvalDoneMessage eval_done = 10;
|
||||
|
||||
InitMessage init = 7;
|
||||
WorkingInitMessage init = 11;
|
||||
}
|
||||
}
|
||||
|
||||
message InitMessage {
|
||||
message WorkingInitMessage {
|
||||
string home_directory = 1;
|
||||
string tmp_directory = 2;
|
||||
string data_directory = 3;
|
||||
@ -43,4 +53,4 @@ message InitMessage {
|
||||
Mac = 2;
|
||||
}
|
||||
OperatingSystem operating_system = 5;
|
||||
}
|
||||
}
|
||||
|
91
packages/protocol/src/proto/client_pb.d.ts
vendored
91
packages/protocol/src/proto/client_pb.d.ts
vendored
@ -4,6 +4,7 @@
|
||||
import * as jspb from "google-protobuf";
|
||||
import * as command_pb from "./command_pb";
|
||||
import * as node_pb from "./node_pb";
|
||||
import * as vscode_pb from "./vscode_pb";
|
||||
|
||||
export class ClientMessage extends jspb.Message {
|
||||
hasNewSession(): boolean;
|
||||
@ -31,11 +32,31 @@ export class ClientMessage extends jspb.Message {
|
||||
getResizeSessionTty(): command_pb.ResizeSessionTTYMessage | undefined;
|
||||
setResizeSessionTty(value?: command_pb.ResizeSessionTTYMessage): void;
|
||||
|
||||
hasNewConnection(): boolean;
|
||||
clearNewConnection(): void;
|
||||
getNewConnection(): command_pb.NewConnectionMessage | undefined;
|
||||
setNewConnection(value?: command_pb.NewConnectionMessage): void;
|
||||
|
||||
hasConnectionOutput(): boolean;
|
||||
clearConnectionOutput(): void;
|
||||
getConnectionOutput(): command_pb.ConnectionOutputMessage | undefined;
|
||||
setConnectionOutput(value?: command_pb.ConnectionOutputMessage): void;
|
||||
|
||||
hasConnectionClose(): boolean;
|
||||
clearConnectionClose(): void;
|
||||
getConnectionClose(): command_pb.ConnectionCloseMessage | undefined;
|
||||
setConnectionClose(value?: command_pb.ConnectionCloseMessage): void;
|
||||
|
||||
hasNewEval(): boolean;
|
||||
clearNewEval(): void;
|
||||
getNewEval(): node_pb.NewEvalMessage | undefined;
|
||||
setNewEval(value?: node_pb.NewEvalMessage): void;
|
||||
|
||||
hasSharedProcessInit(): boolean;
|
||||
clearSharedProcessInit(): void;
|
||||
getSharedProcessInit(): vscode_pb.SharedProcessInitMessage | undefined;
|
||||
setSharedProcessInit(value?: vscode_pb.SharedProcessInitMessage): void;
|
||||
|
||||
getMsgCase(): ClientMessage.MsgCase;
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): ClientMessage.AsObject;
|
||||
@ -54,7 +75,11 @@ export namespace ClientMessage {
|
||||
writeToSession?: command_pb.WriteToSessionMessage.AsObject,
|
||||
closeSessionInput?: command_pb.CloseSessionInputMessage.AsObject,
|
||||
resizeSessionTty?: command_pb.ResizeSessionTTYMessage.AsObject,
|
||||
newConnection?: command_pb.NewConnectionMessage.AsObject,
|
||||
connectionOutput?: command_pb.ConnectionOutputMessage.AsObject,
|
||||
connectionClose?: command_pb.ConnectionCloseMessage.AsObject,
|
||||
newEval?: node_pb.NewEvalMessage.AsObject,
|
||||
sharedProcessInit?: vscode_pb.SharedProcessInitMessage.AsObject,
|
||||
}
|
||||
|
||||
export enum MsgCase {
|
||||
@ -64,7 +89,11 @@ export namespace ClientMessage {
|
||||
WRITE_TO_SESSION = 3,
|
||||
CLOSE_SESSION_INPUT = 4,
|
||||
RESIZE_SESSION_TTY = 5,
|
||||
NEW_EVAL = 6,
|
||||
NEW_CONNECTION = 6,
|
||||
CONNECTION_OUTPUT = 7,
|
||||
CONNECTION_CLOSE = 8,
|
||||
NEW_EVAL = 9,
|
||||
SHARED_PROCESS_INIT = 10,
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,6 +118,26 @@ export class ServerMessage extends jspb.Message {
|
||||
getIdentifySession(): command_pb.IdentifySessionMessage | undefined;
|
||||
setIdentifySession(value?: command_pb.IdentifySessionMessage): void;
|
||||
|
||||
hasConnectionFailure(): boolean;
|
||||
clearConnectionFailure(): void;
|
||||
getConnectionFailure(): command_pb.NewConnectionFailureMessage | undefined;
|
||||
setConnectionFailure(value?: command_pb.NewConnectionFailureMessage): void;
|
||||
|
||||
hasConnectionOutput(): boolean;
|
||||
clearConnectionOutput(): void;
|
||||
getConnectionOutput(): command_pb.ConnectionOutputMessage | undefined;
|
||||
setConnectionOutput(value?: command_pb.ConnectionOutputMessage): void;
|
||||
|
||||
hasConnectionClose(): boolean;
|
||||
clearConnectionClose(): void;
|
||||
getConnectionClose(): command_pb.ConnectionCloseMessage | undefined;
|
||||
setConnectionClose(value?: command_pb.ConnectionCloseMessage): void;
|
||||
|
||||
hasConnectionEstablished(): boolean;
|
||||
clearConnectionEstablished(): void;
|
||||
getConnectionEstablished(): command_pb.ConnectionEstablishedMessage | undefined;
|
||||
setConnectionEstablished(value?: command_pb.ConnectionEstablishedMessage): void;
|
||||
|
||||
hasEvalFailed(): boolean;
|
||||
clearEvalFailed(): void;
|
||||
getEvalFailed(): node_pb.EvalFailedMessage | undefined;
|
||||
@ -101,8 +150,8 @@ export class ServerMessage extends jspb.Message {
|
||||
|
||||
hasInit(): boolean;
|
||||
clearInit(): void;
|
||||
getInit(): InitMessage | undefined;
|
||||
setInit(value?: InitMessage): void;
|
||||
getInit(): WorkingInitMessage | undefined;
|
||||
setInit(value?: WorkingInitMessage): void;
|
||||
|
||||
getMsgCase(): ServerMessage.MsgCase;
|
||||
serializeBinary(): Uint8Array;
|
||||
@ -121,9 +170,13 @@ export namespace ServerMessage {
|
||||
sessionDone?: command_pb.SessionDoneMessage.AsObject,
|
||||
sessionOutput?: command_pb.SessionOutputMessage.AsObject,
|
||||
identifySession?: command_pb.IdentifySessionMessage.AsObject,
|
||||
connectionFailure?: command_pb.NewConnectionFailureMessage.AsObject,
|
||||
connectionOutput?: command_pb.ConnectionOutputMessage.AsObject,
|
||||
connectionClose?: command_pb.ConnectionCloseMessage.AsObject,
|
||||
connectionEstablished?: command_pb.ConnectionEstablishedMessage.AsObject,
|
||||
evalFailed?: node_pb.EvalFailedMessage.AsObject,
|
||||
evalDone?: node_pb.EvalDoneMessage.AsObject,
|
||||
init?: InitMessage.AsObject,
|
||||
init?: WorkingInitMessage.AsObject,
|
||||
}
|
||||
|
||||
export enum MsgCase {
|
||||
@ -132,13 +185,17 @@ export namespace ServerMessage {
|
||||
SESSION_DONE = 2,
|
||||
SESSION_OUTPUT = 3,
|
||||
IDENTIFY_SESSION = 4,
|
||||
EVAL_FAILED = 5,
|
||||
EVAL_DONE = 6,
|
||||
INIT = 7,
|
||||
CONNECTION_FAILURE = 5,
|
||||
CONNECTION_OUTPUT = 6,
|
||||
CONNECTION_CLOSE = 7,
|
||||
CONNECTION_ESTABLISHED = 8,
|
||||
EVAL_FAILED = 9,
|
||||
EVAL_DONE = 10,
|
||||
INIT = 11,
|
||||
}
|
||||
}
|
||||
|
||||
export class InitMessage extends jspb.Message {
|
||||
export class WorkingInitMessage extends jspb.Message {
|
||||
getHomeDirectory(): string;
|
||||
setHomeDirectory(value: string): void;
|
||||
|
||||
@ -151,26 +208,26 @@ export class InitMessage extends jspb.Message {
|
||||
getWorkingDirectory(): string;
|
||||
setWorkingDirectory(value: string): void;
|
||||
|
||||
getOperatingSystem(): InitMessage.OperatingSystem;
|
||||
setOperatingSystem(value: InitMessage.OperatingSystem): void;
|
||||
getOperatingSystem(): WorkingInitMessage.OperatingSystem;
|
||||
setOperatingSystem(value: WorkingInitMessage.OperatingSystem): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): InitMessage.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: InitMessage): InitMessage.AsObject;
|
||||
toObject(includeInstance?: boolean): WorkingInitMessage.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: WorkingInitMessage): WorkingInitMessage.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: InitMessage, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): InitMessage;
|
||||
static deserializeBinaryFromReader(message: InitMessage, reader: jspb.BinaryReader): InitMessage;
|
||||
static serializeBinaryToWriter(message: WorkingInitMessage, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): WorkingInitMessage;
|
||||
static deserializeBinaryFromReader(message: WorkingInitMessage, reader: jspb.BinaryReader): WorkingInitMessage;
|
||||
}
|
||||
|
||||
export namespace InitMessage {
|
||||
export namespace WorkingInitMessage {
|
||||
export type AsObject = {
|
||||
homeDirectory: string,
|
||||
tmpDirectory: string,
|
||||
dataDirectory: string,
|
||||
workingDirectory: string,
|
||||
operatingSystem: InitMessage.OperatingSystem,
|
||||
operatingSystem: WorkingInitMessage.OperatingSystem,
|
||||
}
|
||||
|
||||
export enum OperatingSystem {
|
||||
|
@ -11,10 +11,11 @@ var global = Function('return this')();
|
||||
|
||||
var command_pb = require('./command_pb.js');
|
||||
var node_pb = require('./node_pb.js');
|
||||
var vscode_pb = require('./vscode_pb.js');
|
||||
goog.exportSymbol('proto.ClientMessage', null, global);
|
||||
goog.exportSymbol('proto.InitMessage', null, global);
|
||||
goog.exportSymbol('proto.InitMessage.OperatingSystem', null, global);
|
||||
goog.exportSymbol('proto.ServerMessage', null, global);
|
||||
goog.exportSymbol('proto.WorkingInitMessage', null, global);
|
||||
goog.exportSymbol('proto.WorkingInitMessage.OperatingSystem', null, global);
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
@ -41,7 +42,7 @@ if (goog.DEBUG && !COMPILED) {
|
||||
* @private {!Array<!Array<number>>}
|
||||
* @const
|
||||
*/
|
||||
proto.ClientMessage.oneofGroups_ = [[1,2,3,4,5,6]];
|
||||
proto.ClientMessage.oneofGroups_ = [[1,2,3,4,5,6,7,8,9,10]];
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
@ -53,7 +54,11 @@ proto.ClientMessage.MsgCase = {
|
||||
WRITE_TO_SESSION: 3,
|
||||
CLOSE_SESSION_INPUT: 4,
|
||||
RESIZE_SESSION_TTY: 5,
|
||||
NEW_EVAL: 6
|
||||
NEW_CONNECTION: 6,
|
||||
CONNECTION_OUTPUT: 7,
|
||||
CONNECTION_CLOSE: 8,
|
||||
NEW_EVAL: 9,
|
||||
SHARED_PROCESS_INIT: 10
|
||||
};
|
||||
|
||||
/**
|
||||
@ -96,7 +101,11 @@ proto.ClientMessage.toObject = function(includeInstance, msg) {
|
||||
writeToSession: (f = msg.getWriteToSession()) && command_pb.WriteToSessionMessage.toObject(includeInstance, f),
|
||||
closeSessionInput: (f = msg.getCloseSessionInput()) && command_pb.CloseSessionInputMessage.toObject(includeInstance, f),
|
||||
resizeSessionTty: (f = msg.getResizeSessionTty()) && command_pb.ResizeSessionTTYMessage.toObject(includeInstance, f),
|
||||
newEval: (f = msg.getNewEval()) && node_pb.NewEvalMessage.toObject(includeInstance, f)
|
||||
newConnection: (f = msg.getNewConnection()) && command_pb.NewConnectionMessage.toObject(includeInstance, f),
|
||||
connectionOutput: (f = msg.getConnectionOutput()) && command_pb.ConnectionOutputMessage.toObject(includeInstance, f),
|
||||
connectionClose: (f = msg.getConnectionClose()) && command_pb.ConnectionCloseMessage.toObject(includeInstance, f),
|
||||
newEval: (f = msg.getNewEval()) && node_pb.NewEvalMessage.toObject(includeInstance, f),
|
||||
sharedProcessInit: (f = msg.getSharedProcessInit()) && vscode_pb.SharedProcessInitMessage.toObject(includeInstance, f)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@ -159,10 +168,30 @@ proto.ClientMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
msg.setResizeSessionTty(value);
|
||||
break;
|
||||
case 6:
|
||||
var value = new command_pb.NewConnectionMessage;
|
||||
reader.readMessage(value,command_pb.NewConnectionMessage.deserializeBinaryFromReader);
|
||||
msg.setNewConnection(value);
|
||||
break;
|
||||
case 7:
|
||||
var value = new command_pb.ConnectionOutputMessage;
|
||||
reader.readMessage(value,command_pb.ConnectionOutputMessage.deserializeBinaryFromReader);
|
||||
msg.setConnectionOutput(value);
|
||||
break;
|
||||
case 8:
|
||||
var value = new command_pb.ConnectionCloseMessage;
|
||||
reader.readMessage(value,command_pb.ConnectionCloseMessage.deserializeBinaryFromReader);
|
||||
msg.setConnectionClose(value);
|
||||
break;
|
||||
case 9:
|
||||
var value = new node_pb.NewEvalMessage;
|
||||
reader.readMessage(value,node_pb.NewEvalMessage.deserializeBinaryFromReader);
|
||||
msg.setNewEval(value);
|
||||
break;
|
||||
case 10:
|
||||
var value = new vscode_pb.SharedProcessInitMessage;
|
||||
reader.readMessage(value,vscode_pb.SharedProcessInitMessage.deserializeBinaryFromReader);
|
||||
msg.setSharedProcessInit(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@ -241,14 +270,46 @@ proto.ClientMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
command_pb.ResizeSessionTTYMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getNewEval();
|
||||
f = this.getNewConnection();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
6,
|
||||
f,
|
||||
command_pb.NewConnectionMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getConnectionOutput();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
7,
|
||||
f,
|
||||
command_pb.ConnectionOutputMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getConnectionClose();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
8,
|
||||
f,
|
||||
command_pb.ConnectionCloseMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getNewEval();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
9,
|
||||
f,
|
||||
node_pb.NewEvalMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getSharedProcessInit();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
10,
|
||||
f,
|
||||
vscode_pb.SharedProcessInitMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -412,18 +473,108 @@ proto.ClientMessage.prototype.hasResizeSessionTty = function() {
|
||||
|
||||
|
||||
/**
|
||||
* optional NewEvalMessage new_eval = 6;
|
||||
* optional NewConnectionMessage new_connection = 6;
|
||||
* @return {proto.NewConnectionMessage}
|
||||
*/
|
||||
proto.ClientMessage.prototype.getNewConnection = function() {
|
||||
return /** @type{proto.NewConnectionMessage} */ (
|
||||
jspb.Message.getWrapperField(this, command_pb.NewConnectionMessage, 6));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.NewConnectionMessage|undefined} value */
|
||||
proto.ClientMessage.prototype.setNewConnection = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 6, proto.ClientMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
proto.ClientMessage.prototype.clearNewConnection = function() {
|
||||
this.setNewConnection(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ClientMessage.prototype.hasNewConnection = function() {
|
||||
return jspb.Message.getField(this, 6) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional ConnectionOutputMessage connection_output = 7;
|
||||
* @return {proto.ConnectionOutputMessage}
|
||||
*/
|
||||
proto.ClientMessage.prototype.getConnectionOutput = function() {
|
||||
return /** @type{proto.ConnectionOutputMessage} */ (
|
||||
jspb.Message.getWrapperField(this, command_pb.ConnectionOutputMessage, 7));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.ConnectionOutputMessage|undefined} value */
|
||||
proto.ClientMessage.prototype.setConnectionOutput = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 7, proto.ClientMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
proto.ClientMessage.prototype.clearConnectionOutput = function() {
|
||||
this.setConnectionOutput(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ClientMessage.prototype.hasConnectionOutput = function() {
|
||||
return jspb.Message.getField(this, 7) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional ConnectionCloseMessage connection_close = 8;
|
||||
* @return {proto.ConnectionCloseMessage}
|
||||
*/
|
||||
proto.ClientMessage.prototype.getConnectionClose = function() {
|
||||
return /** @type{proto.ConnectionCloseMessage} */ (
|
||||
jspb.Message.getWrapperField(this, command_pb.ConnectionCloseMessage, 8));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.ConnectionCloseMessage|undefined} value */
|
||||
proto.ClientMessage.prototype.setConnectionClose = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 8, proto.ClientMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
proto.ClientMessage.prototype.clearConnectionClose = function() {
|
||||
this.setConnectionClose(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ClientMessage.prototype.hasConnectionClose = function() {
|
||||
return jspb.Message.getField(this, 8) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional NewEvalMessage new_eval = 9;
|
||||
* @return {proto.NewEvalMessage}
|
||||
*/
|
||||
proto.ClientMessage.prototype.getNewEval = function() {
|
||||
return /** @type{proto.NewEvalMessage} */ (
|
||||
jspb.Message.getWrapperField(this, node_pb.NewEvalMessage, 6));
|
||||
jspb.Message.getWrapperField(this, node_pb.NewEvalMessage, 9));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.NewEvalMessage|undefined} value */
|
||||
proto.ClientMessage.prototype.setNewEval = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 6, proto.ClientMessage.oneofGroups_[0], value);
|
||||
jspb.Message.setOneofWrapperField(this, 9, proto.ClientMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
@ -437,7 +588,37 @@ proto.ClientMessage.prototype.clearNewEval = function() {
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ClientMessage.prototype.hasNewEval = function() {
|
||||
return jspb.Message.getField(this, 6) != null;
|
||||
return jspb.Message.getField(this, 9) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional SharedProcessInitMessage shared_process_init = 10;
|
||||
* @return {proto.SharedProcessInitMessage}
|
||||
*/
|
||||
proto.ClientMessage.prototype.getSharedProcessInit = function() {
|
||||
return /** @type{proto.SharedProcessInitMessage} */ (
|
||||
jspb.Message.getWrapperField(this, vscode_pb.SharedProcessInitMessage, 10));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.SharedProcessInitMessage|undefined} value */
|
||||
proto.ClientMessage.prototype.setSharedProcessInit = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 10, proto.ClientMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
proto.ClientMessage.prototype.clearSharedProcessInit = function() {
|
||||
this.setSharedProcessInit(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ClientMessage.prototype.hasSharedProcessInit = function() {
|
||||
return jspb.Message.getField(this, 10) != null;
|
||||
};
|
||||
|
||||
|
||||
@ -467,7 +648,7 @@ if (goog.DEBUG && !COMPILED) {
|
||||
* @private {!Array<!Array<number>>}
|
||||
* @const
|
||||
*/
|
||||
proto.ServerMessage.oneofGroups_ = [[1,2,3,4,5,6,7]];
|
||||
proto.ServerMessage.oneofGroups_ = [[1,2,3,4,5,6,7,8,9,10,11]];
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
@ -478,9 +659,13 @@ proto.ServerMessage.MsgCase = {
|
||||
SESSION_DONE: 2,
|
||||
SESSION_OUTPUT: 3,
|
||||
IDENTIFY_SESSION: 4,
|
||||
EVAL_FAILED: 5,
|
||||
EVAL_DONE: 6,
|
||||
INIT: 7
|
||||
CONNECTION_FAILURE: 5,
|
||||
CONNECTION_OUTPUT: 6,
|
||||
CONNECTION_CLOSE: 7,
|
||||
CONNECTION_ESTABLISHED: 8,
|
||||
EVAL_FAILED: 9,
|
||||
EVAL_DONE: 10,
|
||||
INIT: 11
|
||||
};
|
||||
|
||||
/**
|
||||
@ -522,9 +707,13 @@ proto.ServerMessage.toObject = function(includeInstance, msg) {
|
||||
sessionDone: (f = msg.getSessionDone()) && command_pb.SessionDoneMessage.toObject(includeInstance, f),
|
||||
sessionOutput: (f = msg.getSessionOutput()) && command_pb.SessionOutputMessage.toObject(includeInstance, f),
|
||||
identifySession: (f = msg.getIdentifySession()) && command_pb.IdentifySessionMessage.toObject(includeInstance, f),
|
||||
connectionFailure: (f = msg.getConnectionFailure()) && command_pb.NewConnectionFailureMessage.toObject(includeInstance, f),
|
||||
connectionOutput: (f = msg.getConnectionOutput()) && command_pb.ConnectionOutputMessage.toObject(includeInstance, f),
|
||||
connectionClose: (f = msg.getConnectionClose()) && command_pb.ConnectionCloseMessage.toObject(includeInstance, f),
|
||||
connectionEstablished: (f = msg.getConnectionEstablished()) && command_pb.ConnectionEstablishedMessage.toObject(includeInstance, f),
|
||||
evalFailed: (f = msg.getEvalFailed()) && node_pb.EvalFailedMessage.toObject(includeInstance, f),
|
||||
evalDone: (f = msg.getEvalDone()) && node_pb.EvalDoneMessage.toObject(includeInstance, f),
|
||||
init: (f = msg.getInit()) && proto.InitMessage.toObject(includeInstance, f)
|
||||
init: (f = msg.getInit()) && proto.WorkingInitMessage.toObject(includeInstance, f)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@ -582,18 +771,38 @@ proto.ServerMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
msg.setIdentifySession(value);
|
||||
break;
|
||||
case 5:
|
||||
var value = new command_pb.NewConnectionFailureMessage;
|
||||
reader.readMessage(value,command_pb.NewConnectionFailureMessage.deserializeBinaryFromReader);
|
||||
msg.setConnectionFailure(value);
|
||||
break;
|
||||
case 6:
|
||||
var value = new command_pb.ConnectionOutputMessage;
|
||||
reader.readMessage(value,command_pb.ConnectionOutputMessage.deserializeBinaryFromReader);
|
||||
msg.setConnectionOutput(value);
|
||||
break;
|
||||
case 7:
|
||||
var value = new command_pb.ConnectionCloseMessage;
|
||||
reader.readMessage(value,command_pb.ConnectionCloseMessage.deserializeBinaryFromReader);
|
||||
msg.setConnectionClose(value);
|
||||
break;
|
||||
case 8:
|
||||
var value = new command_pb.ConnectionEstablishedMessage;
|
||||
reader.readMessage(value,command_pb.ConnectionEstablishedMessage.deserializeBinaryFromReader);
|
||||
msg.setConnectionEstablished(value);
|
||||
break;
|
||||
case 9:
|
||||
var value = new node_pb.EvalFailedMessage;
|
||||
reader.readMessage(value,node_pb.EvalFailedMessage.deserializeBinaryFromReader);
|
||||
msg.setEvalFailed(value);
|
||||
break;
|
||||
case 6:
|
||||
case 10:
|
||||
var value = new node_pb.EvalDoneMessage;
|
||||
reader.readMessage(value,node_pb.EvalDoneMessage.deserializeBinaryFromReader);
|
||||
msg.setEvalDone(value);
|
||||
break;
|
||||
case 7:
|
||||
var value = new proto.InitMessage;
|
||||
reader.readMessage(value,proto.InitMessage.deserializeBinaryFromReader);
|
||||
case 11:
|
||||
var value = new proto.WorkingInitMessage;
|
||||
reader.readMessage(value,proto.WorkingInitMessage.deserializeBinaryFromReader);
|
||||
msg.setInit(value);
|
||||
break;
|
||||
default:
|
||||
@ -666,18 +875,50 @@ proto.ServerMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
command_pb.IdentifySessionMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getEvalFailed();
|
||||
f = this.getConnectionFailure();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
5,
|
||||
f,
|
||||
command_pb.NewConnectionFailureMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getConnectionOutput();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
6,
|
||||
f,
|
||||
command_pb.ConnectionOutputMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getConnectionClose();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
7,
|
||||
f,
|
||||
command_pb.ConnectionCloseMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getConnectionEstablished();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
8,
|
||||
f,
|
||||
command_pb.ConnectionEstablishedMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getEvalFailed();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
9,
|
||||
f,
|
||||
node_pb.EvalFailedMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = this.getEvalDone();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
6,
|
||||
10,
|
||||
f,
|
||||
node_pb.EvalDoneMessage.serializeBinaryToWriter
|
||||
);
|
||||
@ -685,9 +926,9 @@ proto.ServerMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
f = this.getInit();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
7,
|
||||
11,
|
||||
f,
|
||||
proto.InitMessage.serializeBinaryToWriter
|
||||
proto.WorkingInitMessage.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -823,18 +1064,138 @@ proto.ServerMessage.prototype.hasIdentifySession = function() {
|
||||
|
||||
|
||||
/**
|
||||
* optional EvalFailedMessage eval_failed = 5;
|
||||
* optional NewConnectionFailureMessage connection_failure = 5;
|
||||
* @return {proto.NewConnectionFailureMessage}
|
||||
*/
|
||||
proto.ServerMessage.prototype.getConnectionFailure = function() {
|
||||
return /** @type{proto.NewConnectionFailureMessage} */ (
|
||||
jspb.Message.getWrapperField(this, command_pb.NewConnectionFailureMessage, 5));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.NewConnectionFailureMessage|undefined} value */
|
||||
proto.ServerMessage.prototype.setConnectionFailure = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 5, proto.ServerMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
proto.ServerMessage.prototype.clearConnectionFailure = function() {
|
||||
this.setConnectionFailure(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ServerMessage.prototype.hasConnectionFailure = function() {
|
||||
return jspb.Message.getField(this, 5) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional ConnectionOutputMessage connection_output = 6;
|
||||
* @return {proto.ConnectionOutputMessage}
|
||||
*/
|
||||
proto.ServerMessage.prototype.getConnectionOutput = function() {
|
||||
return /** @type{proto.ConnectionOutputMessage} */ (
|
||||
jspb.Message.getWrapperField(this, command_pb.ConnectionOutputMessage, 6));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.ConnectionOutputMessage|undefined} value */
|
||||
proto.ServerMessage.prototype.setConnectionOutput = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 6, proto.ServerMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
proto.ServerMessage.prototype.clearConnectionOutput = function() {
|
||||
this.setConnectionOutput(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ServerMessage.prototype.hasConnectionOutput = function() {
|
||||
return jspb.Message.getField(this, 6) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional ConnectionCloseMessage connection_close = 7;
|
||||
* @return {proto.ConnectionCloseMessage}
|
||||
*/
|
||||
proto.ServerMessage.prototype.getConnectionClose = function() {
|
||||
return /** @type{proto.ConnectionCloseMessage} */ (
|
||||
jspb.Message.getWrapperField(this, command_pb.ConnectionCloseMessage, 7));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.ConnectionCloseMessage|undefined} value */
|
||||
proto.ServerMessage.prototype.setConnectionClose = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 7, proto.ServerMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
proto.ServerMessage.prototype.clearConnectionClose = function() {
|
||||
this.setConnectionClose(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ServerMessage.prototype.hasConnectionClose = function() {
|
||||
return jspb.Message.getField(this, 7) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional ConnectionEstablishedMessage connection_established = 8;
|
||||
* @return {proto.ConnectionEstablishedMessage}
|
||||
*/
|
||||
proto.ServerMessage.prototype.getConnectionEstablished = function() {
|
||||
return /** @type{proto.ConnectionEstablishedMessage} */ (
|
||||
jspb.Message.getWrapperField(this, command_pb.ConnectionEstablishedMessage, 8));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.ConnectionEstablishedMessage|undefined} value */
|
||||
proto.ServerMessage.prototype.setConnectionEstablished = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 8, proto.ServerMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
proto.ServerMessage.prototype.clearConnectionEstablished = function() {
|
||||
this.setConnectionEstablished(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ServerMessage.prototype.hasConnectionEstablished = function() {
|
||||
return jspb.Message.getField(this, 8) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional EvalFailedMessage eval_failed = 9;
|
||||
* @return {proto.EvalFailedMessage}
|
||||
*/
|
||||
proto.ServerMessage.prototype.getEvalFailed = function() {
|
||||
return /** @type{proto.EvalFailedMessage} */ (
|
||||
jspb.Message.getWrapperField(this, node_pb.EvalFailedMessage, 5));
|
||||
jspb.Message.getWrapperField(this, node_pb.EvalFailedMessage, 9));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.EvalFailedMessage|undefined} value */
|
||||
proto.ServerMessage.prototype.setEvalFailed = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 5, proto.ServerMessage.oneofGroups_[0], value);
|
||||
jspb.Message.setOneofWrapperField(this, 9, proto.ServerMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
@ -848,23 +1209,23 @@ proto.ServerMessage.prototype.clearEvalFailed = function() {
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ServerMessage.prototype.hasEvalFailed = function() {
|
||||
return jspb.Message.getField(this, 5) != null;
|
||||
return jspb.Message.getField(this, 9) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional EvalDoneMessage eval_done = 6;
|
||||
* optional EvalDoneMessage eval_done = 10;
|
||||
* @return {proto.EvalDoneMessage}
|
||||
*/
|
||||
proto.ServerMessage.prototype.getEvalDone = function() {
|
||||
return /** @type{proto.EvalDoneMessage} */ (
|
||||
jspb.Message.getWrapperField(this, node_pb.EvalDoneMessage, 6));
|
||||
jspb.Message.getWrapperField(this, node_pb.EvalDoneMessage, 10));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.EvalDoneMessage|undefined} value */
|
||||
proto.ServerMessage.prototype.setEvalDone = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 6, proto.ServerMessage.oneofGroups_[0], value);
|
||||
jspb.Message.setOneofWrapperField(this, 10, proto.ServerMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
@ -878,23 +1239,23 @@ proto.ServerMessage.prototype.clearEvalDone = function() {
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ServerMessage.prototype.hasEvalDone = function() {
|
||||
return jspb.Message.getField(this, 6) != null;
|
||||
return jspb.Message.getField(this, 10) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional InitMessage init = 7;
|
||||
* @return {proto.InitMessage}
|
||||
* optional WorkingInitMessage init = 11;
|
||||
* @return {proto.WorkingInitMessage}
|
||||
*/
|
||||
proto.ServerMessage.prototype.getInit = function() {
|
||||
return /** @type{proto.InitMessage} */ (
|
||||
jspb.Message.getWrapperField(this, proto.InitMessage, 7));
|
||||
return /** @type{proto.WorkingInitMessage} */ (
|
||||
jspb.Message.getWrapperField(this, proto.WorkingInitMessage, 11));
|
||||
};
|
||||
|
||||
|
||||
/** @param {proto.InitMessage|undefined} value */
|
||||
/** @param {proto.WorkingInitMessage|undefined} value */
|
||||
proto.ServerMessage.prototype.setInit = function(value) {
|
||||
jspb.Message.setOneofWrapperField(this, 7, proto.ServerMessage.oneofGroups_[0], value);
|
||||
jspb.Message.setOneofWrapperField(this, 11, proto.ServerMessage.oneofGroups_[0], value);
|
||||
};
|
||||
|
||||
|
||||
@ -908,7 +1269,7 @@ proto.ServerMessage.prototype.clearInit = function() {
|
||||
* @return{!boolean}
|
||||
*/
|
||||
proto.ServerMessage.prototype.hasInit = function() {
|
||||
return jspb.Message.getField(this, 7) != null;
|
||||
return jspb.Message.getField(this, 11) != null;
|
||||
};
|
||||
|
||||
|
||||
@ -923,12 +1284,12 @@ proto.ServerMessage.prototype.hasInit = function() {
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.InitMessage = function(opt_data) {
|
||||
proto.WorkingInitMessage = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.InitMessage, jspb.Message);
|
||||
goog.inherits(proto.WorkingInitMessage, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.InitMessage.displayName = 'proto.InitMessage';
|
||||
proto.WorkingInitMessage.displayName = 'proto.WorkingInitMessage';
|
||||
}
|
||||
|
||||
|
||||
@ -943,8 +1304,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.InitMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.InitMessage.toObject(opt_includeInstance, this);
|
||||
proto.WorkingInitMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.WorkingInitMessage.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
@ -953,10 +1314,10 @@ proto.InitMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.InitMessage} msg The msg instance to transform.
|
||||
* @param {!proto.WorkingInitMessage} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.InitMessage.toObject = function(includeInstance, msg) {
|
||||
proto.WorkingInitMessage.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
homeDirectory: msg.getHomeDirectory(),
|
||||
tmpDirectory: msg.getTmpDirectory(),
|
||||
@ -976,23 +1337,23 @@ proto.InitMessage.toObject = function(includeInstance, msg) {
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.InitMessage}
|
||||
* @return {!proto.WorkingInitMessage}
|
||||
*/
|
||||
proto.InitMessage.deserializeBinary = function(bytes) {
|
||||
proto.WorkingInitMessage.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.InitMessage;
|
||||
return proto.InitMessage.deserializeBinaryFromReader(msg, reader);
|
||||
var msg = new proto.WorkingInitMessage;
|
||||
return proto.WorkingInitMessage.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.InitMessage} msg The message object to deserialize into.
|
||||
* @param {!proto.WorkingInitMessage} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.InitMessage}
|
||||
* @return {!proto.WorkingInitMessage}
|
||||
*/
|
||||
proto.InitMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
proto.WorkingInitMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
@ -1016,7 +1377,7 @@ proto.InitMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
msg.setWorkingDirectory(value);
|
||||
break;
|
||||
case 5:
|
||||
var value = /** @type {!proto.InitMessage.OperatingSystem} */ (reader.readEnum());
|
||||
var value = /** @type {!proto.WorkingInitMessage.OperatingSystem} */ (reader.readEnum());
|
||||
msg.setOperatingSystem(value);
|
||||
break;
|
||||
default:
|
||||
@ -1031,10 +1392,10 @@ proto.InitMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
/**
|
||||
* Class method variant: serializes the given message to binary data
|
||||
* (in protobuf wire format), writing to the given BinaryWriter.
|
||||
* @param {!proto.InitMessage} message
|
||||
* @param {!proto.WorkingInitMessage} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.InitMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
proto.WorkingInitMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
message.serializeBinaryToWriter(writer);
|
||||
};
|
||||
|
||||
@ -1043,7 +1404,7 @@ proto.InitMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.InitMessage.prototype.serializeBinary = function() {
|
||||
proto.WorkingInitMessage.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
this.serializeBinaryToWriter(writer);
|
||||
return writer.getResultBuffer();
|
||||
@ -1055,7 +1416,7 @@ proto.InitMessage.prototype.serializeBinary = function() {
|
||||
* writing to the given BinaryWriter.
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.InitMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
proto.WorkingInitMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
var f = undefined;
|
||||
f = this.getHomeDirectory();
|
||||
if (f.length > 0) {
|
||||
@ -1097,10 +1458,10 @@ proto.InitMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
|
||||
/**
|
||||
* Creates a deep clone of this proto. No data is shared with the original.
|
||||
* @return {!proto.InitMessage} The clone.
|
||||
* @return {!proto.WorkingInitMessage} The clone.
|
||||
*/
|
||||
proto.InitMessage.prototype.cloneMessage = function() {
|
||||
return /** @type {!proto.InitMessage} */ (jspb.Message.cloneMessage(this));
|
||||
proto.WorkingInitMessage.prototype.cloneMessage = function() {
|
||||
return /** @type {!proto.WorkingInitMessage} */ (jspb.Message.cloneMessage(this));
|
||||
};
|
||||
|
||||
|
||||
@ -1108,13 +1469,13 @@ proto.InitMessage.prototype.cloneMessage = function() {
|
||||
* optional string home_directory = 1;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.InitMessage.prototype.getHomeDirectory = function() {
|
||||
proto.WorkingInitMessage.prototype.getHomeDirectory = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 1, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.InitMessage.prototype.setHomeDirectory = function(value) {
|
||||
proto.WorkingInitMessage.prototype.setHomeDirectory = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
@ -1123,13 +1484,13 @@ proto.InitMessage.prototype.setHomeDirectory = function(value) {
|
||||
* optional string tmp_directory = 2;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.InitMessage.prototype.getTmpDirectory = function() {
|
||||
proto.WorkingInitMessage.prototype.getTmpDirectory = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 2, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.InitMessage.prototype.setTmpDirectory = function(value) {
|
||||
proto.WorkingInitMessage.prototype.setTmpDirectory = function(value) {
|
||||
jspb.Message.setField(this, 2, value);
|
||||
};
|
||||
|
||||
@ -1138,13 +1499,13 @@ proto.InitMessage.prototype.setTmpDirectory = function(value) {
|
||||
* optional string data_directory = 3;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.InitMessage.prototype.getDataDirectory = function() {
|
||||
proto.WorkingInitMessage.prototype.getDataDirectory = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 3, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.InitMessage.prototype.setDataDirectory = function(value) {
|
||||
proto.WorkingInitMessage.prototype.setDataDirectory = function(value) {
|
||||
jspb.Message.setField(this, 3, value);
|
||||
};
|
||||
|
||||
@ -1153,28 +1514,28 @@ proto.InitMessage.prototype.setDataDirectory = function(value) {
|
||||
* optional string working_directory = 4;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.InitMessage.prototype.getWorkingDirectory = function() {
|
||||
proto.WorkingInitMessage.prototype.getWorkingDirectory = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 4, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.InitMessage.prototype.setWorkingDirectory = function(value) {
|
||||
proto.WorkingInitMessage.prototype.setWorkingDirectory = function(value) {
|
||||
jspb.Message.setField(this, 4, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional OperatingSystem operating_system = 5;
|
||||
* @return {!proto.InitMessage.OperatingSystem}
|
||||
* @return {!proto.WorkingInitMessage.OperatingSystem}
|
||||
*/
|
||||
proto.InitMessage.prototype.getOperatingSystem = function() {
|
||||
return /** @type {!proto.InitMessage.OperatingSystem} */ (jspb.Message.getFieldProto3(this, 5, 0));
|
||||
proto.WorkingInitMessage.prototype.getOperatingSystem = function() {
|
||||
return /** @type {!proto.WorkingInitMessage.OperatingSystem} */ (jspb.Message.getFieldProto3(this, 5, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {!proto.InitMessage.OperatingSystem} value */
|
||||
proto.InitMessage.prototype.setOperatingSystem = function(value) {
|
||||
/** @param {!proto.WorkingInitMessage.OperatingSystem} value */
|
||||
proto.WorkingInitMessage.prototype.setOperatingSystem = function(value) {
|
||||
jspb.Message.setField(this, 5, value);
|
||||
};
|
||||
|
||||
@ -1182,7 +1543,7 @@ proto.InitMessage.prototype.setOperatingSystem = function(value) {
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
proto.InitMessage.OperatingSystem = {
|
||||
proto.WorkingInitMessage.OperatingSystem = {
|
||||
WINDOWS: 0,
|
||||
LINUX: 1,
|
||||
MAC: 2
|
||||
|
@ -76,3 +76,32 @@ message TTYDimensions {
|
||||
uint32 height = 1;
|
||||
uint32 width = 2;
|
||||
}
|
||||
|
||||
// Initializes a new connection to a port or path
|
||||
message NewConnectionMessage {
|
||||
uint64 id = 1;
|
||||
uint64 port = 2;
|
||||
string path = 3;
|
||||
}
|
||||
|
||||
// Sent when a connection has successfully established
|
||||
message ConnectionEstablishedMessage {
|
||||
uint64 id = 1;
|
||||
}
|
||||
|
||||
// Sent when a connection fails
|
||||
message NewConnectionFailureMessage {
|
||||
uint64 id = 1;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
// Sent for connection output
|
||||
message ConnectionOutputMessage {
|
||||
uint64 id = 1;
|
||||
bytes data = 2;
|
||||
}
|
||||
|
||||
// Sent to close a connection
|
||||
message ConnectionCloseMessage {
|
||||
uint64 id = 1;
|
||||
}
|
||||
|
118
packages/protocol/src/proto/command_pb.d.ts
vendored
118
packages/protocol/src/proto/command_pb.d.ts
vendored
@ -286,3 +286,121 @@ export namespace TTYDimensions {
|
||||
}
|
||||
}
|
||||
|
||||
export class NewConnectionMessage extends jspb.Message {
|
||||
getId(): number;
|
||||
setId(value: number): void;
|
||||
|
||||
getPort(): number;
|
||||
setPort(value: number): void;
|
||||
|
||||
getPath(): string;
|
||||
setPath(value: string): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): NewConnectionMessage.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: NewConnectionMessage): NewConnectionMessage.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: NewConnectionMessage, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): NewConnectionMessage;
|
||||
static deserializeBinaryFromReader(message: NewConnectionMessage, reader: jspb.BinaryReader): NewConnectionMessage;
|
||||
}
|
||||
|
||||
export namespace NewConnectionMessage {
|
||||
export type AsObject = {
|
||||
id: number,
|
||||
port: number,
|
||||
path: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class ConnectionEstablishedMessage extends jspb.Message {
|
||||
getId(): number;
|
||||
setId(value: number): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): ConnectionEstablishedMessage.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: ConnectionEstablishedMessage): ConnectionEstablishedMessage.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: ConnectionEstablishedMessage, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): ConnectionEstablishedMessage;
|
||||
static deserializeBinaryFromReader(message: ConnectionEstablishedMessage, reader: jspb.BinaryReader): ConnectionEstablishedMessage;
|
||||
}
|
||||
|
||||
export namespace ConnectionEstablishedMessage {
|
||||
export type AsObject = {
|
||||
id: number,
|
||||
}
|
||||
}
|
||||
|
||||
export class NewConnectionFailureMessage extends jspb.Message {
|
||||
getId(): number;
|
||||
setId(value: number): void;
|
||||
|
||||
getMessage(): string;
|
||||
setMessage(value: string): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): NewConnectionFailureMessage.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: NewConnectionFailureMessage): NewConnectionFailureMessage.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: NewConnectionFailureMessage, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): NewConnectionFailureMessage;
|
||||
static deserializeBinaryFromReader(message: NewConnectionFailureMessage, reader: jspb.BinaryReader): NewConnectionFailureMessage;
|
||||
}
|
||||
|
||||
export namespace NewConnectionFailureMessage {
|
||||
export type AsObject = {
|
||||
id: number,
|
||||
message: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class ConnectionOutputMessage extends jspb.Message {
|
||||
getId(): number;
|
||||
setId(value: number): void;
|
||||
|
||||
getData(): Uint8Array | string;
|
||||
getData_asU8(): Uint8Array;
|
||||
getData_asB64(): string;
|
||||
setData(value: Uint8Array | string): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): ConnectionOutputMessage.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: ConnectionOutputMessage): ConnectionOutputMessage.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: ConnectionOutputMessage, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): ConnectionOutputMessage;
|
||||
static deserializeBinaryFromReader(message: ConnectionOutputMessage, reader: jspb.BinaryReader): ConnectionOutputMessage;
|
||||
}
|
||||
|
||||
export namespace ConnectionOutputMessage {
|
||||
export type AsObject = {
|
||||
id: number,
|
||||
data: Uint8Array | string,
|
||||
}
|
||||
}
|
||||
|
||||
export class ConnectionCloseMessage extends jspb.Message {
|
||||
getId(): number;
|
||||
setId(value: number): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): ConnectionCloseMessage.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: ConnectionCloseMessage): ConnectionCloseMessage.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: ConnectionCloseMessage, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): ConnectionCloseMessage;
|
||||
static deserializeBinaryFromReader(message: ConnectionCloseMessage, reader: jspb.BinaryReader): ConnectionCloseMessage;
|
||||
}
|
||||
|
||||
export namespace ConnectionCloseMessage {
|
||||
export type AsObject = {
|
||||
id: number,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,12 @@ var goog = jspb;
|
||||
var global = Function('return this')();
|
||||
|
||||
goog.exportSymbol('proto.CloseSessionInputMessage', null, global);
|
||||
goog.exportSymbol('proto.ConnectionCloseMessage', null, global);
|
||||
goog.exportSymbol('proto.ConnectionEstablishedMessage', null, global);
|
||||
goog.exportSymbol('proto.ConnectionOutputMessage', null, global);
|
||||
goog.exportSymbol('proto.IdentifySessionMessage', null, global);
|
||||
goog.exportSymbol('proto.NewConnectionFailureMessage', null, global);
|
||||
goog.exportSymbol('proto.NewConnectionMessage', null, global);
|
||||
goog.exportSymbol('proto.NewSessionFailureMessage', null, global);
|
||||
goog.exportSymbol('proto.NewSessionFailureMessage.Reason', null, global);
|
||||
goog.exportSymbol('proto.NewSessionMessage', null, global);
|
||||
@ -2155,4 +2160,931 @@ proto.TTYDimensions.prototype.setWidth = function(value) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.NewConnectionMessage = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.NewConnectionMessage, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.NewConnectionMessage.displayName = 'proto.NewConnectionMessage';
|
||||
}
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto suitable for use in Soy templates.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
|
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.NewConnectionMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.NewConnectionMessage.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.NewConnectionMessage} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.NewConnectionMessage.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
id: msg.getId(),
|
||||
port: msg.getPort(),
|
||||
path: msg.getPath()
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.NewConnectionMessage}
|
||||
*/
|
||||
proto.NewConnectionMessage.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.NewConnectionMessage;
|
||||
return proto.NewConnectionMessage.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.NewConnectionMessage} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.NewConnectionMessage}
|
||||
*/
|
||||
proto.NewConnectionMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {number} */ (reader.readUint64());
|
||||
msg.setId(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {number} */ (reader.readUint64());
|
||||
msg.setPort(value);
|
||||
break;
|
||||
case 3:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setPath(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class method variant: serializes the given message to binary data
|
||||
* (in protobuf wire format), writing to the given BinaryWriter.
|
||||
* @param {!proto.NewConnectionMessage} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.NewConnectionMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
message.serializeBinaryToWriter(writer);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.NewConnectionMessage.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
this.serializeBinaryToWriter(writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format),
|
||||
* writing to the given BinaryWriter.
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.NewConnectionMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
var f = undefined;
|
||||
f = this.getId();
|
||||
if (f !== 0) {
|
||||
writer.writeUint64(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = this.getPort();
|
||||
if (f !== 0) {
|
||||
writer.writeUint64(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = this.getPath();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
3,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a deep clone of this proto. No data is shared with the original.
|
||||
* @return {!proto.NewConnectionMessage} The clone.
|
||||
*/
|
||||
proto.NewConnectionMessage.prototype.cloneMessage = function() {
|
||||
return /** @type {!proto.NewConnectionMessage} */ (jspb.Message.cloneMessage(this));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint64 id = 1;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.NewConnectionMessage.prototype.getId = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.NewConnectionMessage.prototype.setId = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint64 port = 2;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.NewConnectionMessage.prototype.getPort = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 2, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.NewConnectionMessage.prototype.setPort = function(value) {
|
||||
jspb.Message.setField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string path = 3;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.NewConnectionMessage.prototype.getPath = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 3, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.NewConnectionMessage.prototype.setPath = function(value) {
|
||||
jspb.Message.setField(this, 3, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.ConnectionEstablishedMessage, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.ConnectionEstablishedMessage.displayName = 'proto.ConnectionEstablishedMessage';
|
||||
}
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto suitable for use in Soy templates.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
|
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.ConnectionEstablishedMessage.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.ConnectionEstablishedMessage} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
id: msg.getId()
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.ConnectionEstablishedMessage}
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.ConnectionEstablishedMessage;
|
||||
return proto.ConnectionEstablishedMessage.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.ConnectionEstablishedMessage} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.ConnectionEstablishedMessage}
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {number} */ (reader.readUint64());
|
||||
msg.setId(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class method variant: serializes the given message to binary data
|
||||
* (in protobuf wire format), writing to the given BinaryWriter.
|
||||
* @param {!proto.ConnectionEstablishedMessage} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
message.serializeBinaryToWriter(writer);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
this.serializeBinaryToWriter(writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format),
|
||||
* writing to the given BinaryWriter.
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
var f = undefined;
|
||||
f = this.getId();
|
||||
if (f !== 0) {
|
||||
writer.writeUint64(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a deep clone of this proto. No data is shared with the original.
|
||||
* @return {!proto.ConnectionEstablishedMessage} The clone.
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.prototype.cloneMessage = function() {
|
||||
return /** @type {!proto.ConnectionEstablishedMessage} */ (jspb.Message.cloneMessage(this));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint64 id = 1;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.ConnectionEstablishedMessage.prototype.getId = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.ConnectionEstablishedMessage.prototype.setId = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.NewConnectionFailureMessage = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.NewConnectionFailureMessage, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.NewConnectionFailureMessage.displayName = 'proto.NewConnectionFailureMessage';
|
||||
}
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto suitable for use in Soy templates.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
|
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.NewConnectionFailureMessage.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.NewConnectionFailureMessage} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
id: msg.getId(),
|
||||
message: msg.getMessage()
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.NewConnectionFailureMessage}
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.NewConnectionFailureMessage;
|
||||
return proto.NewConnectionFailureMessage.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.NewConnectionFailureMessage} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.NewConnectionFailureMessage}
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {number} */ (reader.readUint64());
|
||||
msg.setId(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setMessage(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class method variant: serializes the given message to binary data
|
||||
* (in protobuf wire format), writing to the given BinaryWriter.
|
||||
* @param {!proto.NewConnectionFailureMessage} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
message.serializeBinaryToWriter(writer);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
this.serializeBinaryToWriter(writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format),
|
||||
* writing to the given BinaryWriter.
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
var f = undefined;
|
||||
f = this.getId();
|
||||
if (f !== 0) {
|
||||
writer.writeUint64(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = this.getMessage();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a deep clone of this proto. No data is shared with the original.
|
||||
* @return {!proto.NewConnectionFailureMessage} The clone.
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.prototype.cloneMessage = function() {
|
||||
return /** @type {!proto.NewConnectionFailureMessage} */ (jspb.Message.cloneMessage(this));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint64 id = 1;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.prototype.getId = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.NewConnectionFailureMessage.prototype.setId = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string message = 2;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.NewConnectionFailureMessage.prototype.getMessage = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 2, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.NewConnectionFailureMessage.prototype.setMessage = function(value) {
|
||||
jspb.Message.setField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.ConnectionOutputMessage = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.ConnectionOutputMessage, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.ConnectionOutputMessage.displayName = 'proto.ConnectionOutputMessage';
|
||||
}
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto suitable for use in Soy templates.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
|
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.ConnectionOutputMessage.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.ConnectionOutputMessage} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
id: msg.getId(),
|
||||
data: msg.getData_asB64()
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.ConnectionOutputMessage}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.ConnectionOutputMessage;
|
||||
return proto.ConnectionOutputMessage.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.ConnectionOutputMessage} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.ConnectionOutputMessage}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {number} */ (reader.readUint64());
|
||||
msg.setId(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {!Uint8Array} */ (reader.readBytes());
|
||||
msg.setData(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class method variant: serializes the given message to binary data
|
||||
* (in protobuf wire format), writing to the given BinaryWriter.
|
||||
* @param {!proto.ConnectionOutputMessage} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.ConnectionOutputMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
message.serializeBinaryToWriter(writer);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
this.serializeBinaryToWriter(writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format),
|
||||
* writing to the given BinaryWriter.
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.ConnectionOutputMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
var f = undefined;
|
||||
f = this.getId();
|
||||
if (f !== 0) {
|
||||
writer.writeUint64(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = this.getData_asU8();
|
||||
if (f.length > 0) {
|
||||
writer.writeBytes(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a deep clone of this proto. No data is shared with the original.
|
||||
* @return {!proto.ConnectionOutputMessage} The clone.
|
||||
*/
|
||||
proto.ConnectionOutputMessage.prototype.cloneMessage = function() {
|
||||
return /** @type {!proto.ConnectionOutputMessage} */ (jspb.Message.cloneMessage(this));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint64 id = 1;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.prototype.getId = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.ConnectionOutputMessage.prototype.setId = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bytes data = 2;
|
||||
* @return {!(string|Uint8Array)}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.prototype.getData = function() {
|
||||
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldProto3(this, 2, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bytes data = 2;
|
||||
* This is a type-conversion wrapper around `getData()`
|
||||
* @return {string}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.prototype.getData_asB64 = function() {
|
||||
return /** @type {string} */ (jspb.Message.bytesAsB64(
|
||||
this.getData()));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bytes data = 2;
|
||||
* Note that Uint8Array is not supported on all browsers.
|
||||
* @see http://caniuse.com/Uint8Array
|
||||
* This is a type-conversion wrapper around `getData()`
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.ConnectionOutputMessage.prototype.getData_asU8 = function() {
|
||||
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
|
||||
this.getData()));
|
||||
};
|
||||
|
||||
|
||||
/** @param {!(string|Uint8Array)} value */
|
||||
proto.ConnectionOutputMessage.prototype.setData = function(value) {
|
||||
jspb.Message.setField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.ConnectionCloseMessage = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.ConnectionCloseMessage, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.ConnectionCloseMessage.displayName = 'proto.ConnectionCloseMessage';
|
||||
}
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto suitable for use in Soy templates.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
|
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.ConnectionCloseMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.ConnectionCloseMessage.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.ConnectionCloseMessage} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.ConnectionCloseMessage.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
id: msg.getId()
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.ConnectionCloseMessage}
|
||||
*/
|
||||
proto.ConnectionCloseMessage.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.ConnectionCloseMessage;
|
||||
return proto.ConnectionCloseMessage.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.ConnectionCloseMessage} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.ConnectionCloseMessage}
|
||||
*/
|
||||
proto.ConnectionCloseMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {number} */ (reader.readUint64());
|
||||
msg.setId(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class method variant: serializes the given message to binary data
|
||||
* (in protobuf wire format), writing to the given BinaryWriter.
|
||||
* @param {!proto.ConnectionCloseMessage} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.ConnectionCloseMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
message.serializeBinaryToWriter(writer);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.ConnectionCloseMessage.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
this.serializeBinaryToWriter(writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format),
|
||||
* writing to the given BinaryWriter.
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.ConnectionCloseMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
var f = undefined;
|
||||
f = this.getId();
|
||||
if (f !== 0) {
|
||||
writer.writeUint64(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a deep clone of this proto. No data is shared with the original.
|
||||
* @return {!proto.ConnectionCloseMessage} The clone.
|
||||
*/
|
||||
proto.ConnectionCloseMessage.prototype.cloneMessage = function() {
|
||||
return /** @type {!proto.ConnectionCloseMessage} */ (jspb.Message.cloneMessage(this));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint64 id = 1;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.ConnectionCloseMessage.prototype.getId = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.ConnectionCloseMessage.prototype.setId = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
goog.object.extend(exports, proto);
|
||||
|
@ -1,3 +1,4 @@
|
||||
export * from "./client_pb";
|
||||
export * from "./command_pb";
|
||||
export * from "./node_pb";
|
||||
export * from "./vscode_pb";
|
||||
|
9
packages/protocol/src/proto/vscode.proto
Normal file
9
packages/protocol/src/proto/vscode.proto
Normal file
@ -0,0 +1,9 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message SharedProcessInitMessage {
|
||||
uint64 window_id = 1;
|
||||
string log_directory = 2;
|
||||
|
||||
// Maps to `"vs/platform/log/common/log".LogLevel`
|
||||
uint32 log_level = 3;
|
||||
}
|
33
packages/protocol/src/proto/vscode_pb.d.ts
vendored
Normal file
33
packages/protocol/src/proto/vscode_pb.d.ts
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// package:
|
||||
// file: vscode.proto
|
||||
|
||||
import * as jspb from "google-protobuf";
|
||||
|
||||
export class SharedProcessInitMessage extends jspb.Message {
|
||||
getWindowId(): number;
|
||||
setWindowId(value: number): void;
|
||||
|
||||
getLogDirectory(): string;
|
||||
setLogDirectory(value: string): void;
|
||||
|
||||
getLogLevel(): number;
|
||||
setLogLevel(value: number): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): SharedProcessInitMessage.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: SharedProcessInitMessage): SharedProcessInitMessage.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: SharedProcessInitMessage, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): SharedProcessInitMessage;
|
||||
static deserializeBinaryFromReader(message: SharedProcessInitMessage, reader: jspb.BinaryReader): SharedProcessInitMessage;
|
||||
}
|
||||
|
||||
export namespace SharedProcessInitMessage {
|
||||
export type AsObject = {
|
||||
windowId: number,
|
||||
logDirectory: string,
|
||||
logLevel: number,
|
||||
}
|
||||
}
|
||||
|
226
packages/protocol/src/proto/vscode_pb.js
Normal file
226
packages/protocol/src/proto/vscode_pb.js
Normal file
@ -0,0 +1,226 @@
|
||||
/**
|
||||
* @fileoverview
|
||||
* @enhanceable
|
||||
* @public
|
||||
*/
|
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
|
||||
var jspb = require('google-protobuf');
|
||||
var goog = jspb;
|
||||
var global = Function('return this')();
|
||||
|
||||
goog.exportSymbol('proto.SharedProcessInitMessage', null, global);
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.SharedProcessInitMessage = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.SharedProcessInitMessage, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.SharedProcessInitMessage.displayName = 'proto.SharedProcessInitMessage';
|
||||
}
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto suitable for use in Soy templates.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
|
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.SharedProcessInitMessage.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.SharedProcessInitMessage.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.SharedProcessInitMessage} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.SharedProcessInitMessage.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
windowId: msg.getWindowId(),
|
||||
logDirectory: msg.getLogDirectory(),
|
||||
logLevel: msg.getLogLevel()
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.SharedProcessInitMessage}
|
||||
*/
|
||||
proto.SharedProcessInitMessage.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.SharedProcessInitMessage;
|
||||
return proto.SharedProcessInitMessage.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.SharedProcessInitMessage} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.SharedProcessInitMessage}
|
||||
*/
|
||||
proto.SharedProcessInitMessage.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {number} */ (reader.readUint64());
|
||||
msg.setWindowId(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setLogDirectory(value);
|
||||
break;
|
||||
case 3:
|
||||
var value = /** @type {number} */ (reader.readUint32());
|
||||
msg.setLogLevel(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class method variant: serializes the given message to binary data
|
||||
* (in protobuf wire format), writing to the given BinaryWriter.
|
||||
* @param {!proto.SharedProcessInitMessage} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.SharedProcessInitMessage.serializeBinaryToWriter = function(message, writer) {
|
||||
message.serializeBinaryToWriter(writer);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.SharedProcessInitMessage.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
this.serializeBinaryToWriter(writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format),
|
||||
* writing to the given BinaryWriter.
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.SharedProcessInitMessage.prototype.serializeBinaryToWriter = function (writer) {
|
||||
var f = undefined;
|
||||
f = this.getWindowId();
|
||||
if (f !== 0) {
|
||||
writer.writeUint64(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = this.getLogDirectory();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = this.getLogLevel();
|
||||
if (f !== 0) {
|
||||
writer.writeUint32(
|
||||
3,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a deep clone of this proto. No data is shared with the original.
|
||||
* @return {!proto.SharedProcessInitMessage} The clone.
|
||||
*/
|
||||
proto.SharedProcessInitMessage.prototype.cloneMessage = function() {
|
||||
return /** @type {!proto.SharedProcessInitMessage} */ (jspb.Message.cloneMessage(this));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint64 window_id = 1;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.SharedProcessInitMessage.prototype.getWindowId = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.SharedProcessInitMessage.prototype.setWindowId = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string log_directory = 2;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.SharedProcessInitMessage.prototype.getLogDirectory = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 2, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.SharedProcessInitMessage.prototype.setLogDirectory = function(value) {
|
||||
jspb.Message.setField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint32 log_level = 3;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.SharedProcessInitMessage.prototype.getLogLevel = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 3, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.SharedProcessInitMessage.prototype.setLogLevel = function(value) {
|
||||
jspb.Message.setField(this, 3, value);
|
||||
};
|
||||
|
||||
|
||||
goog.object.extend(exports, proto);
|
@ -1,3 +1,5 @@
|
||||
import * as net from "net";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { TextEncoder, TextDecoder } from "text-encoding";
|
||||
import { createClient } from "./helpers";
|
||||
@ -5,7 +7,7 @@ import { createClient } from "./helpers";
|
||||
(<any>global).TextDecoder = TextDecoder;
|
||||
(<any>global).TextEncoder = TextEncoder;
|
||||
|
||||
describe("Command", () => {
|
||||
describe("spawn", () => {
|
||||
const client = createClient();
|
||||
|
||||
it("should execute command and return output", (done) => {
|
||||
@ -129,4 +131,60 @@ describe("Command", () => {
|
||||
});
|
||||
proc.on("exit", () => done());
|
||||
});
|
||||
});
|
||||
|
||||
describe("createConnection", () => {
|
||||
const client = createClient();
|
||||
const tmpPath = path.join(os.tmpdir(), Math.random().toString());
|
||||
let server: net.Server;
|
||||
beforeAll(async () => {
|
||||
await new Promise((r) => {
|
||||
server = net.createServer().listen(tmpPath, () => {
|
||||
r();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
it("should connect to socket", (done) => {
|
||||
const socket = client.createConnection(tmpPath, () => {
|
||||
socket.end();
|
||||
socket.addListener("close", () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should get data from server", (done) => {
|
||||
server.once("connection", (socket: net.Socket) => {
|
||||
socket.write("hi how r u");
|
||||
});
|
||||
|
||||
const socket = client.createConnection(tmpPath);
|
||||
|
||||
socket.addListener("data", (data) => {
|
||||
expect(data.toString()).toEqual("hi how r u");
|
||||
socket.end();
|
||||
socket.addListener("close", () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should send data to server", (done) => {
|
||||
const clientSocket = client.createConnection(tmpPath);
|
||||
clientSocket.write(Buffer.from("bananas"));
|
||||
server.once("connection", (socket: net.Socket) => {
|
||||
socket.addListener("data", (data) => {
|
||||
expect(data.toString()).toEqual("bananas");
|
||||
socket.end();
|
||||
clientSocket.addListener("end", () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -9,10 +9,10 @@ describe("Server", () => {
|
||||
});
|
||||
|
||||
it("should get init msg", (done) => {
|
||||
client.onInitData((data) => {
|
||||
client.initData.then((data) => {
|
||||
expect(data.dataDirectory).toEqual(dataDirectory);
|
||||
expect(data.workingDirectory).toEqual(workingDirectory);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user