mirror of
https://git.tuxpa.in/a/code-server.git
synced 2024-12-28 21:25:25 +00:00
Remove block padding (blank lines)
Also made a rule for it.
This commit is contained in:
parent
dc08df5540
commit
e770920be0
@ -1,5 +1,3 @@
|
||||
export interface IDisposable {
|
||||
|
||||
dispose(): void;
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ export interface Event<T> {
|
||||
* Emitter typecasts for a single event type
|
||||
*/
|
||||
export class Emitter<T> {
|
||||
|
||||
private listeners: Array<(e: T) => void> | undefined;
|
||||
|
||||
public constructor() {
|
||||
@ -56,5 +55,4 @@ export class Emitter<T> {
|
||||
public get hasListeners(): boolean {
|
||||
return !!this.listeners && this.listeners.length > 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import { IURIFactory } from "./fill/uri";
|
||||
* It also provides task management to help asynchronously load and time code.
|
||||
*/
|
||||
export abstract class Client {
|
||||
|
||||
public readonly retry = retry;
|
||||
public readonly clipboard = clipboard;
|
||||
public readonly uriFactory: IURIFactory;
|
||||
@ -191,5 +190,4 @@ export abstract class Client {
|
||||
* Create URI factory.
|
||||
*/
|
||||
protected abstract createUriFactory(): IURIFactory;
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import { retry } from "../retry";
|
||||
* messages during connection.
|
||||
*/
|
||||
class Connection implements ReadWriteConnection {
|
||||
|
||||
private activeSocket: WebSocket | undefined;
|
||||
private readonly messageEmitter: Emitter<Uint8Array> = new Emitter();
|
||||
private readonly closeEmitter: Emitter<void> = new Emitter();
|
||||
@ -143,7 +142,6 @@ class Connection implements ReadWriteConnection {
|
||||
this.activeSocket.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Global instance so all fills can use the same client.
|
||||
|
@ -2,10 +2,9 @@ import { IDisposable } from "@coder/disposable";
|
||||
import { Emitter } from "@coder/events";
|
||||
|
||||
/**
|
||||
* Native clipboard.
|
||||
* Wrapper around the native clipboard with some fallbacks.
|
||||
*/
|
||||
export class Clipboard {
|
||||
|
||||
private readonly enableEmitter: Emitter<boolean> = new Emitter();
|
||||
private _isEnabled: boolean = false;
|
||||
|
||||
@ -149,7 +148,6 @@ export class Clipboard {
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Global clipboard instance since it's used in the Electron fill.
|
||||
|
@ -3,9 +3,6 @@ import { Emitter } from "@coder/events";
|
||||
|
||||
import "./dialog.scss";
|
||||
|
||||
/**
|
||||
* Dialog options.
|
||||
*/
|
||||
export interface IDialogOptions {
|
||||
message?: string;
|
||||
detail?: string;
|
||||
@ -24,16 +21,12 @@ export interface IDialogAction {
|
||||
key?: IKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pressed keys.
|
||||
*/
|
||||
export enum IKey {
|
||||
Enter = "Enter",
|
||||
Escape = "Escape",
|
||||
}
|
||||
|
||||
export class Dialog {
|
||||
|
||||
private options: IDialogOptions;
|
||||
private overlay: HTMLElement;
|
||||
private cachedActiveElement: HTMLElement | undefined;
|
||||
@ -190,5 +183,4 @@ export class Dialog {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,7 +84,6 @@ const newCreateElement = <K extends keyof HTMLElementTagNameMap>(tagName: K): HT
|
||||
document.createElement = newCreateElement;
|
||||
|
||||
class Clipboard {
|
||||
|
||||
public has(): boolean {
|
||||
return false;
|
||||
}
|
||||
@ -92,21 +91,17 @@ class Clipboard {
|
||||
public writeText(value: string): Promise<void> {
|
||||
return clipboard.writeText(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Shell {
|
||||
|
||||
public async moveItemToTrash(path: string): Promise<void> {
|
||||
await promisify(exec)(
|
||||
`trash-put --trash-dir ${escapePath("~/.Trash")} ${escapePath(path)}`,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class App extends EventEmitter {
|
||||
|
||||
public isAccessibilitySupportEnabled(): boolean {
|
||||
return false;
|
||||
}
|
||||
@ -114,11 +109,9 @@ class App extends EventEmitter {
|
||||
public setAsDefaultProtocolClient(): void {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Dialog {
|
||||
|
||||
public showSaveDialog(_: void, options: Electron.SaveDialogOptions, callback: (filename: string | undefined) => void): void {
|
||||
const defaultPath = options.defaultPath || "/untitled";
|
||||
const fileIndex = defaultPath.lastIndexOf("/");
|
||||
@ -203,11 +196,9 @@ class Dialog {
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WebFrame {
|
||||
|
||||
public getZoomFactor(): number {
|
||||
return 1;
|
||||
}
|
||||
@ -219,19 +210,15 @@ class WebFrame {
|
||||
public setZoomLevel(): void {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Screen {
|
||||
|
||||
public getAllDisplays(): [] {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WebRequest extends EventEmitter {
|
||||
|
||||
public onBeforeRequest(): void {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
@ -243,28 +230,22 @@ class WebRequest extends EventEmitter {
|
||||
public onHeadersReceived(): void {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Session extends EventEmitter {
|
||||
|
||||
public webRequest = new WebRequest();
|
||||
|
||||
public resolveProxy(url: string, callback: (proxy: string) => void): void {
|
||||
// TODO: not sure what this actually does.
|
||||
callback(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WebContents extends EventEmitter {
|
||||
|
||||
public session = new Session();
|
||||
|
||||
}
|
||||
|
||||
class BrowserWindow extends EventEmitter {
|
||||
|
||||
public webContents = new WebContents();
|
||||
private representedFilename: string = "";
|
||||
|
||||
@ -323,7 +304,6 @@ class BrowserWindow extends EventEmitter {
|
||||
public setTitle(value: string): void {
|
||||
document.title = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -331,7 +311,6 @@ class BrowserWindow extends EventEmitter {
|
||||
* example returns a boolean while we need a promise.
|
||||
*/
|
||||
class ElectronFill {
|
||||
|
||||
public readonly shell = new Shell();
|
||||
public readonly clipboard = new Clipboard();
|
||||
public readonly app = new App();
|
||||
@ -382,7 +361,6 @@ class ElectronFill {
|
||||
};
|
||||
}
|
||||
// tslint:enable no-any
|
||||
|
||||
}
|
||||
|
||||
module.exports = new ElectronFill();
|
||||
|
@ -1,30 +1,11 @@
|
||||
import { logger, field } from "@coder/logger";
|
||||
|
||||
/**
|
||||
* Handle for a notification that allows it to be closed and updated.
|
||||
*/
|
||||
export interface INotificationHandle {
|
||||
|
||||
/**
|
||||
* Closes the notification.
|
||||
*/
|
||||
close(): void;
|
||||
|
||||
/**
|
||||
* Update the message.
|
||||
*/
|
||||
updateMessage(message: string): void;
|
||||
|
||||
/**
|
||||
* Update the buttons.
|
||||
*/
|
||||
updateButtons(buttons: INotificationButton[]): void;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification severity.
|
||||
*/
|
||||
export enum Severity {
|
||||
Ignore = 0,
|
||||
Info = 1,
|
||||
@ -32,9 +13,6 @@ export enum Severity {
|
||||
Error = 3,
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification button.
|
||||
*/
|
||||
export interface INotificationButton {
|
||||
label: string;
|
||||
run(): void;
|
||||
@ -44,48 +22,28 @@ export interface INotificationButton {
|
||||
* Optional notification service.
|
||||
*/
|
||||
export interface INotificationService {
|
||||
|
||||
/**
|
||||
* Display an error message.
|
||||
*/
|
||||
error(error: Error): void;
|
||||
|
||||
/**
|
||||
* Show a notification.
|
||||
*/
|
||||
prompt(severity: Severity, message: string, buttons: INotificationButton[], onCancel: () => void): INotificationHandle;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updatable progress.
|
||||
*/
|
||||
export interface IProgress {
|
||||
|
||||
/**
|
||||
* Report progress. Progress is the completed percentage from 0 to 100.
|
||||
* Report progress, which should be the completed percentage from 0 to 100.
|
||||
*/
|
||||
report(progress: number): void;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Option progress reporting service.
|
||||
*/
|
||||
export interface IProgressService {
|
||||
|
||||
/**
|
||||
* Start a new progress bar that resolves & disappears when the task finishes.
|
||||
*/
|
||||
start<T>(title: string, task: (progress: IProgress) => Promise<T>, onCancel: () => void): Promise<T>;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary notification service.
|
||||
*/
|
||||
export class NotificationService implements INotificationService {
|
||||
|
||||
public error(error: Error): void {
|
||||
logger.error(error.message, field("error", error));
|
||||
}
|
||||
@ -93,14 +51,12 @@ export class NotificationService implements INotificationService {
|
||||
public prompt(_severity: Severity, message: string, _buttons: INotificationButton[], _onCancel: () => void): INotificationHandle {
|
||||
throw new Error(`cannot prompt using the console: ${message}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary progress service.
|
||||
*/
|
||||
export class ProgressService implements IProgressService {
|
||||
|
||||
public start<T>(title: string, task: (progress: IProgress) => Promise<T>): Promise<T> {
|
||||
logger.info(title);
|
||||
|
||||
@ -110,5 +66,4 @@ export class ProgressService implements IProgressService {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import { InitData } from "@coder/protocol";
|
||||
import { client } from "./client";
|
||||
|
||||
class OS {
|
||||
|
||||
private _homedir: string | undefined;
|
||||
private _tmpdir: string | undefined;
|
||||
|
||||
@ -40,9 +39,9 @@ class OS {
|
||||
if (navigator.appVersion.indexOf("Mac") != -1) {
|
||||
return "darwin";
|
||||
}
|
||||
|
||||
return "linux";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export = new OS();
|
||||
|
@ -1,18 +1,14 @@
|
||||
export interface IURI {
|
||||
|
||||
readonly path: string;
|
||||
readonly fsPath: string;
|
||||
readonly scheme: string;
|
||||
|
||||
}
|
||||
|
||||
export interface IURIFactory {
|
||||
|
||||
/**
|
||||
* Convert the object to an instance of a real URI.
|
||||
*/
|
||||
create<T extends IURI>(uri: IURI): T;
|
||||
file(path: string): IURI;
|
||||
parse(raw: string): IURI;
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ interface IRetryItem {
|
||||
* to the user explaining what is happening with an option to immediately retry.
|
||||
*/
|
||||
export class Retry {
|
||||
|
||||
private items: Map<string, IRetryItem>;
|
||||
|
||||
// Times are in seconds.
|
||||
@ -284,7 +283,6 @@ export class Retry {
|
||||
item.timeout = undefined;
|
||||
item.end = undefined;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Global instance so we can block other retries when retrying the main
|
||||
|
@ -32,7 +32,6 @@ interface IEntry {
|
||||
* Handles file uploads.
|
||||
*/
|
||||
export class Upload {
|
||||
|
||||
private readonly maxParallelUploads = 100;
|
||||
private readonly readSize = 32000; // ~32kb max while reading in the file.
|
||||
private readonly packetSize = 32000; // ~32kb max when writing.
|
||||
@ -353,7 +352,6 @@ export class Upload {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Global instance.
|
||||
|
@ -12,7 +12,6 @@ export enum Level {
|
||||
* A field to log.
|
||||
*/
|
||||
export class Field<T> {
|
||||
|
||||
public constructor(
|
||||
public readonly identifier: string,
|
||||
public readonly value: T,
|
||||
@ -27,19 +26,16 @@ export class Field<T> {
|
||||
value: this.value,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the time something takes.
|
||||
*/
|
||||
export class Time {
|
||||
|
||||
public constructor(
|
||||
public readonly expected: number,
|
||||
public readonly ms: number,
|
||||
) { }
|
||||
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-any
|
||||
@ -117,7 +113,6 @@ const hashStringToColor = (str: string): string => {
|
||||
* currently built items and appends to that.
|
||||
*/
|
||||
export abstract class Formatter {
|
||||
|
||||
protected format: string = "";
|
||||
protected args: string[] = [];
|
||||
|
||||
@ -159,14 +154,12 @@ export abstract class Formatter {
|
||||
return "%s";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Browser formatter.
|
||||
*/
|
||||
export class BrowserFormatter extends Formatter {
|
||||
|
||||
public tag(name: string, color: string): void {
|
||||
this.format += `%c ${name} `;
|
||||
this.args.push(
|
||||
@ -207,14 +200,12 @@ export class BrowserFormatter extends Formatter {
|
||||
// tslint:disable-next-line no-console
|
||||
console.groupEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Server (Node) formatter.
|
||||
*/
|
||||
export class ServerFormatter extends Formatter {
|
||||
|
||||
public tag(name: string, color: string): void {
|
||||
const [r, g, b] = hexToRgb(color);
|
||||
while (name.length < 5) {
|
||||
@ -250,14 +241,12 @@ export class ServerFormatter extends Formatter {
|
||||
this.args.push(JSON.stringify(obj));
|
||||
console.log(...this.flush()); // tslint:disable-line no-console
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for logging.
|
||||
*/
|
||||
export class Logger {
|
||||
|
||||
public level = Level.Info;
|
||||
|
||||
private readonly nameColor?: string;
|
||||
@ -429,7 +418,6 @@ export class Logger {
|
||||
}
|
||||
// tslint:enable no-console
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const logger = new Logger(
|
||||
|
@ -9,7 +9,6 @@ import { EventEmitter } from "events";
|
||||
* Client accepts an arbitrary connection intended to communicate with the Server.
|
||||
*/
|
||||
export class Client {
|
||||
|
||||
public Socket: typeof ServerSocket;
|
||||
|
||||
private evalId: number = 0;
|
||||
@ -453,5 +452,4 @@ export class Client {
|
||||
}
|
||||
this.connections.set(id, socket);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -170,7 +170,6 @@ export interface Socket {
|
||||
}
|
||||
|
||||
export class ServerSocket extends events.EventEmitter implements Socket {
|
||||
|
||||
public writable: boolean = true;
|
||||
public readable: boolean = true;
|
||||
|
||||
@ -276,7 +275,6 @@ export class ServerSocket extends events.EventEmitter implements Socket {
|
||||
public setDefaultEncoding(encoding: string): this {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface Server {
|
||||
@ -307,7 +305,6 @@ export interface Server {
|
||||
}
|
||||
|
||||
export class ServerListener extends events.EventEmitter implements Server {
|
||||
|
||||
private _listening: boolean = false;
|
||||
|
||||
public constructor(
|
||||
@ -358,7 +355,6 @@ export class ServerListener extends events.EventEmitter implements Server {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface ActiveEval {
|
||||
|
@ -3,7 +3,6 @@ import { Client } from "../client";
|
||||
import { useBuffer } from "../../common/util";
|
||||
|
||||
export class CP {
|
||||
|
||||
public constructor(
|
||||
private readonly client: Client,
|
||||
) { }
|
||||
@ -75,5 +74,4 @@ export class CP {
|
||||
Array.isArray(args) || !args ? options : args,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ declare var _Buffer: typeof Buffer;
|
||||
* _this somehow which the __awaiter helper uses.
|
||||
*/
|
||||
export class FS {
|
||||
|
||||
public constructor(
|
||||
private readonly client: Client,
|
||||
) { }
|
||||
@ -686,11 +685,9 @@ export class FS {
|
||||
|
||||
return watcher;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Watcher extends EventEmitter implements fs.FSWatcher {
|
||||
|
||||
public constructor(private readonly process: ChildProcess) {
|
||||
super();
|
||||
}
|
||||
@ -698,7 +695,6 @@ class Watcher extends EventEmitter implements fs.FSWatcher {
|
||||
public close(): void {
|
||||
this.process.kill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface IStats {
|
||||
@ -730,7 +726,6 @@ interface IStats {
|
||||
}
|
||||
|
||||
class Stats implements fs.Stats {
|
||||
|
||||
public readonly atime: Date;
|
||||
public readonly mtime: Date;
|
||||
public readonly ctime: Date;
|
||||
@ -768,7 +763,6 @@ class Stats implements fs.Stats {
|
||||
public toObject(): object {
|
||||
return JSON.parse(JSON.stringify(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -776,7 +770,6 @@ class Stats implements fs.Stats {
|
||||
* Assumes that messages are split by newlines.
|
||||
*/
|
||||
export class NewlineInputBuffer {
|
||||
|
||||
private callback: (msg: string) => void;
|
||||
private buffer: string | undefined;
|
||||
|
||||
@ -804,5 +797,4 @@ export class NewlineInputBuffer {
|
||||
this.callback(lines[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ type NodeNet = typeof net;
|
||||
* Implementation of net for the browser.
|
||||
*/
|
||||
export class Net implements NodeNet {
|
||||
|
||||
public constructor(
|
||||
private readonly client: Client,
|
||||
) {}
|
||||
@ -51,5 +50,4 @@ export class Net implements NodeNet {
|
||||
): net.Server {
|
||||
return this.client.createServer() as net.Server;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as vm from "vm";
|
||||
import { NewEvalMessage, TypedValue, EvalFailedMessage, EvalDoneMessage, ServerMessage, EvalEventMessage, ClientMessage } from "../proto";
|
||||
import { NewEvalMessage, TypedValue, EvalFailedMessage, EvalDoneMessage, ServerMessage, EvalEventMessage } from "../proto";
|
||||
import { SendableConnection } from "../common/connection";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
|
@ -20,7 +20,6 @@ export interface ServerOptions {
|
||||
}
|
||||
|
||||
export class Server {
|
||||
|
||||
private readonly sessions: Map<number, Process> = new Map();
|
||||
private readonly connections: Map<number, net.Socket> = new Map();
|
||||
private readonly servers: Map<number, net.Server> = new Map();
|
||||
@ -250,5 +249,4 @@ export class Server {
|
||||
private getSession(id: number): Process | undefined {
|
||||
return this.sessions.get(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ describe("Evaluate", () => {
|
||||
const value = await client.evaluate(function () {
|
||||
return "hi";
|
||||
});
|
||||
|
||||
|
||||
expect(value).toEqual("hi");
|
||||
}, 100);
|
||||
|
||||
@ -24,7 +24,7 @@ describe("Evaluate", () => {
|
||||
const value = await client.evaluate((arg) => {
|
||||
return arg.bananas * 2;
|
||||
}, { bananas: 1 });
|
||||
|
||||
|
||||
expect(value).toEqual(2);
|
||||
}, 100);
|
||||
|
||||
@ -32,14 +32,14 @@ describe("Evaluate", () => {
|
||||
const value = await client.evaluate(() => {
|
||||
return { alpha: "beta" };
|
||||
});
|
||||
|
||||
|
||||
expect(value.alpha).toEqual("beta");
|
||||
}, 100);
|
||||
|
||||
it("should require", async () => {
|
||||
const value = await client.evaluate(() => {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
|
||||
|
||||
return Object.keys(fs).filter((f) => f === "readFileSync");
|
||||
});
|
||||
|
||||
@ -69,4 +69,4 @@ describe("Evaluate", () => {
|
||||
runner.on("2", () => runner.emit("3"));
|
||||
runner.on("close", () => done());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -13,7 +13,6 @@ export interface IFileReader {
|
||||
* RequireFS allows users to require from a file system.
|
||||
*/
|
||||
export class RequireFS {
|
||||
|
||||
private readonly reader: IFileReader;
|
||||
private readonly customModules: Map<string, { exports: object }>;
|
||||
private readonly requireCache: Map<string, { exports: object }>;
|
||||
@ -126,7 +125,6 @@ export class RequireFS {
|
||||
|
||||
return stripPrefix(resolvedPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const fromTar = (content: Uint8Array): RequireFS => {
|
||||
|
@ -5,7 +5,6 @@ const textDecoder = new (typeof TextDecoder === "undefined" ? require("text-enco
|
||||
* Tar represents a tar archive.
|
||||
*/
|
||||
export class Tar {
|
||||
|
||||
/**
|
||||
* Return a tar object from a Uint8Array.
|
||||
*/
|
||||
@ -42,14 +41,12 @@ export class Tar {
|
||||
public get files(): ReadonlyMap<string, TarFile> {
|
||||
return this._files;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a tar files location within a reader
|
||||
*/
|
||||
export class TarFile {
|
||||
|
||||
/**
|
||||
* Locate a tar file from a reader.
|
||||
*/
|
||||
@ -186,14 +183,12 @@ export class TarFile {
|
||||
public read(): Uint8Array {
|
||||
return this.reader.jump(this.data.offset).read(this.data.size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads within a Uint8Array.
|
||||
*/
|
||||
export class Reader {
|
||||
|
||||
private array: Uint8Array;
|
||||
private _offset: number;
|
||||
private lastClamp: number;
|
||||
@ -281,5 +276,4 @@ export class Reader {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,11 +8,10 @@ import * as WebSocket from "ws";
|
||||
import { createApp } from "./server";
|
||||
import { requireModule } from "./vscode/bootstrapFork";
|
||||
import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
|
||||
import { setup as setupNativeModules } from './modules';
|
||||
import { fillFs } from './fill';
|
||||
import { setup as setupNativeModules } from "./modules";
|
||||
import { fillFs } from "./fill";
|
||||
|
||||
export class Entry extends Command {
|
||||
|
||||
public static description = "Start your own self-hosted browser-accessible VS Code";
|
||||
public static flags = {
|
||||
cert: flags.string(),
|
||||
@ -167,7 +166,6 @@ export class Entry extends Command {
|
||||
logger.info(`http://localhost:${flags.port}/`);
|
||||
logger.info(" ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Entry.run(undefined, {
|
||||
|
@ -3,7 +3,7 @@ import * as util from "util";
|
||||
|
||||
const oldAccess = fs.access;
|
||||
const existsWithinBinary = (path: fs.PathLike): Promise<boolean> => {
|
||||
return new Promise<boolean>((resolve) => {
|
||||
return new Promise<boolean>((resolve): void => {
|
||||
if (typeof path === "number") {
|
||||
if (path < 0) {
|
||||
return resolve(true);
|
||||
@ -18,7 +18,7 @@ const existsWithinBinary = (path: fs.PathLike): Promise<boolean> => {
|
||||
});
|
||||
};
|
||||
|
||||
export const fillFs = () => {
|
||||
export const fillFs = (): void => {
|
||||
/**
|
||||
* Refer to https://github.com/nexe/nexe/blob/master/src/fs/patch.ts
|
||||
* For impls
|
||||
|
@ -7,7 +7,6 @@ export interface IpcMessage {
|
||||
}
|
||||
|
||||
export class StdioIpcHandler extends EventEmitter {
|
||||
|
||||
private isListening: boolean = false;
|
||||
|
||||
public constructor(
|
||||
@ -66,5 +65,4 @@ export class StdioIpcHandler extends EventEmitter {
|
||||
process.stdin.on("data", onData);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { logger } from "@coder/logger";
|
||||
import { ReadWriteConnection } from "@coder/protocol";
|
||||
import { Server, ServerOptions } from "@coder/protocol/src/node/server";
|
||||
import { NewSessionMessage } from '@coder/protocol/src/proto';
|
||||
import { NewSessionMessage } from "@coder/protocol/src/proto";
|
||||
import { ChildProcess } from "child_process";
|
||||
import * as express from "express";
|
||||
//@ts-ignore
|
||||
|
@ -6,7 +6,7 @@ import { forkModule } from "./bootstrapFork";
|
||||
import { StdioIpcHandler } from "../ipc";
|
||||
import { ParsedArgs } from "vs/platform/environment/common/environment";
|
||||
import { LogLevel } from "vs/platform/log/common/log";
|
||||
import { Emitter, Event } from '@coder/events/src';
|
||||
import { Emitter, Event } from "@coder/events/src";
|
||||
|
||||
export enum SharedProcessState {
|
||||
Stopped,
|
||||
@ -22,7 +22,6 @@ export type SharedProcessEvent = {
|
||||
};
|
||||
|
||||
export class SharedProcess {
|
||||
|
||||
public readonly socketPath: string = path.join(os.tmpdir(), `.vscode-remote${Math.random().toString()}`);
|
||||
private _state: SharedProcessState = SharedProcessState.Stopped;
|
||||
private activeProcess: ChildProcess | undefined;
|
||||
|
@ -26,7 +26,6 @@ import { ServiceCollection } from "vs/platform/instantiation/common/serviceColle
|
||||
import { RawContextKey, IContextKeyService } from "vs/platform/contextkey/common/contextkey";
|
||||
|
||||
export class Client extends IDEClient {
|
||||
|
||||
private readonly windowId = parseInt(new Date().toISOString().replace(/[-:.TZ]/g, ""), 10);
|
||||
private _serviceCollection: ServiceCollection | undefined;
|
||||
private _clipboardContextKey: RawContextKey<boolean> | undefined;
|
||||
@ -192,7 +191,6 @@ export class Client extends IDEClient {
|
||||
this.clipboard.initialize();
|
||||
}, this.initData, pathSets);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const client = new Client();
|
||||
|
@ -6,7 +6,6 @@ import { IDecorationRenderOptions } from "vs/editor/common/editorCommon";
|
||||
* This converts icon paths for decorations to the correct URL.
|
||||
*/
|
||||
abstract class CodeEditorServiceImpl extends editor.CodeEditorServiceImpl {
|
||||
|
||||
public registerDecorationType(key: string, options: IDecorationRenderOptions, parentTypeKey?: string): void {
|
||||
super.registerDecorationType(key, options ? {
|
||||
...options,
|
||||
@ -18,7 +17,6 @@ abstract class CodeEditorServiceImpl extends editor.CodeEditorServiceImpl {
|
||||
} :options.gutterIconPath,
|
||||
} : {}, parentTypeKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const target = editor as typeof editor;
|
||||
|
@ -2,11 +2,9 @@ import * as paths from "./paths";
|
||||
import * as environment from "vs/platform/environment/node/environmentService";
|
||||
|
||||
export class EnvironmentService extends environment.EnvironmentService {
|
||||
|
||||
public get sharedIPCHandle(): string {
|
||||
return paths._paths.socketPath || super.sharedIPCHandle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const target = environment as typeof environment;
|
||||
|
@ -2,7 +2,6 @@ import * as iconv from "../../node_modules/iconv-lite";
|
||||
import { Transform, TransformCallback } from "stream";
|
||||
|
||||
class IconvLiteDecoderStream extends Transform {
|
||||
|
||||
// tslint:disable-next-line no-any
|
||||
private conv: any;
|
||||
private encoding: string;
|
||||
|
@ -4,7 +4,6 @@ import * as mouse from "vs/base/browser/mouseEvent";
|
||||
* Fix the wheel event for Firefox.
|
||||
*/
|
||||
class StandardWheelEvent extends mouse.StandardWheelEvent {
|
||||
|
||||
public constructor(event: mouse.IMouseWheelEvent | null) {
|
||||
super(
|
||||
event,
|
||||
@ -12,7 +11,6 @@ class StandardWheelEvent extends mouse.StandardWheelEvent {
|
||||
(-(event as any as MouseWheelEvent).deltaY || 0) / 3, // tslint:disable-line no-any
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const target = mouse as typeof mouse;
|
||||
|
@ -1,5 +1,4 @@
|
||||
class NativeKeymap {
|
||||
|
||||
public getCurrentKeyboardLayout(): null {
|
||||
return null;
|
||||
}
|
||||
@ -7,7 +6,6 @@ class NativeKeymap {
|
||||
public getKeyMap(): undefined[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export = new NativeKeymap();
|
||||
|
@ -1,9 +1,7 @@
|
||||
class Watchdog {
|
||||
|
||||
public start(): void {
|
||||
// No action required.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export = new Watchdog();
|
||||
|
@ -9,7 +9,6 @@ type nodePtyType = typeof nodePty;
|
||||
* Implementation of nodePty for the browser.
|
||||
*/
|
||||
class Pty implements nodePty.IPty {
|
||||
|
||||
private readonly emitter: EventEmitter;
|
||||
private readonly cp: ChildProcess;
|
||||
|
||||
@ -54,15 +53,12 @@ class Pty implements nodePty.IPty {
|
||||
public kill(signal?: string): void {
|
||||
this.emitter.emit("kill", signal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const ptyType: nodePtyType = {
|
||||
|
||||
spawn: (file: string, args: string[] | string, options: nodePty.IPtyForkOptions): nodePty.IPty => {
|
||||
return new Pty(file, args, options);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
module.exports = ptyType;
|
||||
|
@ -13,7 +13,6 @@ const getLabel = (key: string, enabled: boolean): string => {
|
||||
};
|
||||
|
||||
export class PasteAction extends Action {
|
||||
|
||||
private static readonly KEY = "paste";
|
||||
|
||||
public constructor() {
|
||||
@ -30,11 +29,9 @@ export class PasteAction extends Action {
|
||||
this.enabled = enabled;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TerminalPasteAction extends Action {
|
||||
|
||||
private static readonly KEY = "workbench.action.terminal.paste";
|
||||
|
||||
public static readonly ID = TERMINAL_COMMAND_ID.PASTE;
|
||||
@ -61,11 +58,9 @@ class TerminalPasteAction extends Action {
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TerminalInstance extends instance.TerminalInstance {
|
||||
|
||||
public async paste(): Promise<void> {
|
||||
this.focus();
|
||||
if (clipboard.isEnabled) {
|
||||
@ -75,7 +70,6 @@ class TerminalInstance extends instance.TerminalInstance {
|
||||
document.execCommand("paste");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const actionsTarget = actions as typeof actions;
|
||||
|
@ -9,7 +9,6 @@ import { escapePath } from "@coder/protocol";
|
||||
// use that for the logging. Or maybe create an instance when the server starts,
|
||||
// and just always use that one (make it part of the protocol).
|
||||
export class RotatingLogger implements NodeRotatingLogger {
|
||||
|
||||
private format = true;
|
||||
private buffer = "";
|
||||
private flushPromise: Promise<void> | undefined;
|
||||
@ -178,7 +177,6 @@ export class RotatingLogger implements NodeRotatingLogger {
|
||||
await this.rotate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const setAsyncMode = (): void => {
|
||||
|
@ -4,7 +4,6 @@ import { IpcRenderer } from "electron";
|
||||
export * from "@coder/ide/src/fill/electron";
|
||||
|
||||
class StdioIpcRenderer extends StdioIpcHandler implements IpcRenderer {
|
||||
|
||||
public sendTo(windowId: number, channel: string, ...args: any[]): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
@ -16,7 +15,6 @@ class StdioIpcRenderer extends StdioIpcHandler implements IpcRenderer {
|
||||
public eventNames(): string[] {
|
||||
return super.eventNames() as string[];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const ipcRenderer = new StdioIpcRenderer();
|
||||
|
@ -9,7 +9,6 @@ import * as paths from "./paths";
|
||||
import { logger, field } from "@coder/logger";
|
||||
|
||||
class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
||||
|
||||
public readonly onDidChangeItemsExternal = Event.None;
|
||||
private items = new Map<string, string>();
|
||||
private fetched: boolean = false;
|
||||
@ -78,11 +77,9 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
||||
|
||||
return promisify(writeFile)(this.path, JSON.stringify(json));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GlobalStorageDatabase extends StorageDatabase implements IDisposable {
|
||||
|
||||
public constructor() {
|
||||
super(path.join(paths.getAppDataPath(), "globalStorage", "state.vscdb"));
|
||||
}
|
||||
@ -90,7 +87,6 @@ class GlobalStorageDatabase extends StorageDatabase implements IDisposable {
|
||||
public dispose(): void {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const workspaceTarget = workspaceStorage as typeof workspaceStorage;
|
||||
|
@ -14,7 +14,6 @@ import { client } from "../client";
|
||||
* the client. This setup means we can only control the current window.
|
||||
*/
|
||||
class WindowsService implements IWindowsService {
|
||||
|
||||
// tslint:disable-next-line no-any
|
||||
public _serviceBrand: any;
|
||||
|
||||
@ -278,7 +277,6 @@ class WindowsService implements IWindowsService {
|
||||
private getWindowById(_windowId: number): electron.BrowserWindow {
|
||||
return this.window;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const target = windowsIpc as typeof windowsIpc;
|
||||
|
89
rules/src/noBlockPaddingRule.ts
Normal file
89
rules/src/noBlockPaddingRule.ts
Normal file
@ -0,0 +1,89 @@
|
||||
import * as ts from "typescript";
|
||||
import * as Lint from "tslint";
|
||||
|
||||
/**
|
||||
* Rule for disallowing blank lines around the content of blocks.
|
||||
*/
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
public static BEFORE_FAILURE_STRING = "Blocks must not start with blank lines";
|
||||
public static AFTER_FAILURE_STRING = "Blocks must not end with blank lines";
|
||||
|
||||
/**
|
||||
* Apply the rule.
|
||||
*/
|
||||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
||||
return this.applyWithWalker(new NoBlockPaddingWalker(sourceFile, this.getOptions()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Walker for checking block padding.
|
||||
*/
|
||||
class NoBlockPaddingWalker extends Lint.RuleWalker {
|
||||
/**
|
||||
* Apply this rule to interfaces.
|
||||
*/
|
||||
public visitInterfaceDeclaration(node: ts.InterfaceDeclaration): void {
|
||||
this.visitBlockNode(node);
|
||||
super.visitInterfaceDeclaration(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply this rule to classes.
|
||||
*/
|
||||
public visitClassDeclaration(node: ts.ClassDeclaration): void {
|
||||
this.visitBlockNode(node);
|
||||
super.visitClassDeclaration(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add failures to blank lines surrounding a block's content.
|
||||
*/
|
||||
private visitBlockNode(node: ts.ClassDeclaration | ts.InterfaceDeclaration): void {
|
||||
const sourceFile = node.getSourceFile();
|
||||
const children = node.getChildren();
|
||||
|
||||
const openBraceIndex = children.findIndex((n) => n.kind === ts.SyntaxKind.OpenBraceToken);
|
||||
if (openBraceIndex !== -1) {
|
||||
const nextToken = children[openBraceIndex + 1];
|
||||
if (nextToken) {
|
||||
const startLine = this.getStartIncludingComments(sourceFile, nextToken);
|
||||
const openBraceToken = children[openBraceIndex];
|
||||
if (ts.getLineAndCharacterOfPosition(sourceFile, openBraceToken.getEnd()).line + 1 < startLine) {
|
||||
this.addFailureAt(openBraceToken.getEnd(), openBraceToken.getEnd(), Rule.BEFORE_FAILURE_STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const closeBraceIndex = children.findIndex((n) => n.kind === ts.SyntaxKind.CloseBraceToken);
|
||||
if (closeBraceIndex >= 2) {
|
||||
const previousToken = children[closeBraceIndex - 1];
|
||||
if (previousToken) {
|
||||
let endLine = ts.getLineAndCharacterOfPosition(sourceFile, previousToken.getEnd()).line;
|
||||
const closeBraceToken = children[closeBraceIndex];
|
||||
if (this.getStartIncludingComments(sourceFile, closeBraceToken) > endLine + 1) {
|
||||
this.addFailureAt(closeBraceToken.getStart(), closeBraceToken.getStart(), Rule.AFTER_FAILURE_STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getStart() doesn't account for comments while this does.
|
||||
*/
|
||||
private getStartIncludingComments(sourceFile: ts.SourceFile, node: ts.Node): number {
|
||||
// This gets the line the node starts on without counting comments.
|
||||
let startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.getStart()).line;
|
||||
|
||||
// Adjust the start line for the comments.
|
||||
const comments = ts.getLeadingCommentRanges(sourceFile.text, node.pos) || [];
|
||||
comments.forEach((c) => {
|
||||
const commentStartLine = ts.getLineAndCharacterOfPosition(sourceFile, c.pos).line;
|
||||
if (commentStartLine < startLine) {
|
||||
startLine = commentStartLine;
|
||||
}
|
||||
});
|
||||
|
||||
return startLine;
|
||||
}
|
||||
}
|
@ -3,12 +3,14 @@
|
||||
"rules": {
|
||||
"only-arrow-functions": true,
|
||||
"curly-statement-newlines": true,
|
||||
"no-block-padding": true,
|
||||
"adjacent-overload-signatures": true,
|
||||
"align": true,
|
||||
"await-promise": [true, "Thenable"],
|
||||
"class-name": true,
|
||||
"eofline": true,
|
||||
"import-spacing": true,
|
||||
"indent": [true, "tabs"],
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-bitwise": false,
|
||||
"no-any": true,
|
||||
|
Loading…
Reference in New Issue
Block a user