From 60dd4e188f082a69ba9e64f21f90130b46c5c8d9 Mon Sep 17 00:00:00 2001 From: "Felix W. Dekker" Date: Thu, 31 Oct 2019 19:08:09 +0100 Subject: [PATCH] Fix #18 --- package-lock.json | Bin 193151 -> 193693 bytes package.json | 4 ++++ src/main/index.html | 3 --- src/main/js/commands.ts | 6 +----- src/main/js/main.ts | 5 +++-- src/main/js/shell.ts | 6 +----- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0a0eab45cdfaf615f54ea010a275982dfd149565..1f7be1694fdfd664203bdcc9d764cfd6a1dd8865 100644 GIT binary patch delta 329 zcmezWgnRBw?g@1~C6xuK#rj#ry2<(Z(+zl;WT$_4$YiSEfGnP!nX0b~RRd(}8tEBL ze^|$;IC%m$OK5mVTCl63Yhr0)w!U9cx>>TLrCWMHh+A1$VtHy-abl)fRYZQFL11J^ zpmA=6zh7!liF<~3MWT7RZ%$}cczAAAQEo_Tn08UQPnJh|v2$KYN>TB2M;<2i$pSq5 zlLN%qre76i5}h0;s!Y9$;@!4{yooVDhhEsnj5DZs4{6rdX%Mj82MCr>bp8d zC5M(fT4)>OdHa=wdlUw1N9AT_`8XOI1eHfQ8YJbLhvYjaXJ>hv`ewUlWVyOndgliv oNBEmLCAxbWds>EiRs}m6x_P?=_y^kBDz!&VVcZ@yg-JCI0J61lGXMYp delta 44 zcmV+{0Mq}S=?nkl3y^-3$q){ca2E!bHFp9RlYkRMgAD?=4FUmwlZT3y0k?{l0ux@5 C0T4?7 diff --git a/package.json b/package.json index 463c3b5..83fb0a4 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,11 @@ "deploy": "grunt deploy", "test": "echo TODO" }, + "dependencies": { + "js-cookie": "^2.2.1" + }, "devDependencies": { + "@types/js-cookie": "^2.2.4", "grunt": "^1.0.4", "grunt-cli": "^1.3.2", "grunt-contrib-clean": "^2.0.0", diff --git a/src/main/index.html b/src/main/index.html index 28c1a4b..a2594e7 100644 --- a/src/main/index.html +++ b/src/main/index.html @@ -27,9 +27,6 @@ - diff --git a/src/main/js/commands.ts b/src/main/js/commands.ts index 95144fc..feaabdf 100644 --- a/src/main/js/commands.ts +++ b/src/main/js/commands.ts @@ -1,3 +1,4 @@ +import * as Cookies from "js-cookie"; import "./extensions" import {File, FileSystem, Path} from "./fs" import {stripHtmlTags} from "./shared"; @@ -194,11 +195,8 @@ export class Commands { */ execute(inputString: string): OutputAction { if (inputString === "factory-reset") { - // @ts-ignore Cookies.remove("files"); - // @ts-ignore Cookies.remove("cwd"); - // @ts-ignore Cookies.remove("user"); location.reload(); throw "Goodbye"; @@ -359,7 +357,6 @@ export class Commands { if (!(node instanceof File)) return ["append", `'${fileName}' is not a file`]; - // @ts-ignore: False positive window.open(node.contents, target); return ["nothing"]; } @@ -369,7 +366,6 @@ export class Commands { if (user === undefined) throw "Cannot execute `poweroff` while not logged in."; - // @ts-ignore Cookies.set("poweroff", "true", { "expires": new Date(new Date().setSeconds(new Date().getSeconds() + 30)), "path": "/" diff --git a/src/main/js/main.ts b/src/main/js/main.ts index 793b06e..0a10866 100644 --- a/src/main/js/main.ts +++ b/src/main/js/main.ts @@ -3,6 +3,7 @@ import {Terminal} from "./terminal"; // TODO Ignore ts-ignore in whole block +// TODO Add interface for Window to add types addOnLoad(() => { // @ts-ignore: Force definition window.terminal = new Terminal( @@ -16,8 +17,8 @@ addOnLoad(() => { // @ts-ignore: Force definition window.run = (command: string) => window.terminal.processInput(command); - // @ts-ignore + // @ts-ignore: Force definition if (window.terminal.shell.userSession.isLoggedIn) - // @ts-ignore + // @ts-ignore: Force definition window.terminal.processInput("ls"); }); diff --git a/src/main/js/shell.ts b/src/main/js/shell.ts index 59ed060..f583978 100644 --- a/src/main/js/shell.ts +++ b/src/main/js/shell.ts @@ -1,3 +1,4 @@ +import * as Cookies from "js-cookie"; import {Commands} from "./commands"; import {FileSystem} from "./fs"; import {asciiHeaderHtml} from "./shared"; @@ -41,7 +42,6 @@ export class Shell { constructor(inputHistory: InputHistory) { this.inputHistory = inputHistory; - // @ts-ignore const user = Cookies.get("user"); if (user === undefined) this.userSession = new UserSession("felix"); @@ -50,7 +50,6 @@ export class Shell { else this.userSession = new UserSession(user); - // @ts-ignore this.fileSystem = new FileSystem(Cookies.get("files"), Cookies.get("cwd")); this.commands = new Commands(this.userSession, this.fileSystem); } @@ -137,16 +136,13 @@ export class Shell { * Saves the shell's state in cookies. */ private saveState() { - // @ts-ignore Cookies.set("files", this.fileSystem.serializedRoot, { "expires": new Date(new Date().setFullYear(new Date().getFullYear() + 25)), "path": "/" }); - // @ts-ignore Cookies.set("cwd", this.fileSystem.cwd, {"path": "/"}); const user = this.userSession.currentUser; - // @ts-ignore Cookies.set("user", user === undefined ? "" : user.name, {"path": "/"}); } }