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