Archived
1
0

not finished

This commit is contained in:
Asher
2019-01-07 18:46:19 -06:00
committed by Kyle Carberry
parent 776bb227e6
commit 9cd81f73fa
79 changed files with 11015 additions and 0 deletions

View File

@ -0,0 +1,6 @@
module.exports = function(source) {
if (this.resourcePath.endsWith(".ts")) {
this.resourcePath = this.resourcePath.replace(".ts", ".css");
}
return `module.exports = require("${this.resourcePath}");`;
};

View File

@ -0,0 +1,8 @@
module.exports = {
getCurrentKeyboardLayout: (): null => {
return null;
},
getKeyMap: (): undefined[] => {
return [];
},
};

View File

@ -0,0 +1,73 @@
import * as cp from "child_process";
import { EventEmitter } from "events";
import * as nodePty from "node-pty";
type nodePtyType = typeof nodePty;
/**
* Implementation of nodePty for the browser.
*/
class Pty implements nodePty.IPty {
private readonly emitter: EventEmitter;
public constructor(file: string, args: string[] | string, options: nodePty.IPtyForkOptions) {
this.emitter = new EventEmitter();
const session = wush.execute({
command: `${file} ${Array.isArray(args) ? args.join(" ") : args}`,
directory: options.cwd,
environment: {
...(options.env || {}),
TERM: "xterm-color",
},
size: options && options.cols && options.rows ? {
columns: options.cols,
rows: options.rows,
} : {
columns: 100,
rows: 100,
},
});
this.on("write", (data) => session.sendStdin(data));
this.on("kill", (exitCode) => session.close());
this.on("resize", (columns, rows) => session.setSize({ columns, rows }));
session.onStdout((data) => this.emitter.emit("data", data));
session.onStderr((data) => this.emitter.emit("data", data));
session.onDone((exitCode) => this.emitter.emit("exit", exitCode));
}
public get pid(): number {
return 1;
}
public get process(): string {
return "unknown";
}
public on(event: string, listener: (...args) => void): void {
this.emitter.on(event, listener);
}
public resize(columns: number, rows: number): void {
this.emitter.emit("resize", columns, rows);
}
public write(data: string): void {
this.emitter.emit("write", data);
}
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;