diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 8f84c0383..e48498c17 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1661,15 +1661,15 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { (_hostname: unknown = workerScript.hostname): IServerDef => { const hostname = ctx.helper.string("hostname", _hostname); const server = safeGetServer(hostname, ctx); - const copy = Object.assign({}, server) as any; + const copy = Object.assign({}, server) as Server; // These fields should be hidden. - copy.contracts = undefined; - copy.messages = undefined; - copy.runningScripts = undefined; - copy.scripts = undefined; - copy.textFiles = undefined; - copy.programs = undefined; - copy.serversOnNetwork = undefined; + copy.contracts = []; + copy.messages = []; + copy.runningScripts = []; + copy.scripts = []; + copy.textFiles = []; + copy.programs = []; + copy.serversOnNetwork = []; if (!copy.baseDifficulty) copy.baseDifficulty = 0; if (!copy.hackDifficulty) copy.hackDifficulty = 0; if (!copy.minDifficulty) copy.minDifficulty = 0; diff --git a/src/SaveObject.tsx b/src/SaveObject.tsx index 2bc8999c3..df9aa9231 100755 --- a/src/SaveObject.tsx +++ b/src/SaveObject.tsx @@ -402,7 +402,7 @@ function evaluateVersionCompatibility(ver: string | number): void { } } if (ver < 15) { - (Settings as any).EditorTheme = { ...defaultMonacoTheme }; + Settings.EditorTheme = { ...defaultMonacoTheme }; } //Fix contract names if (ver < 16) { @@ -605,23 +605,17 @@ function createBetaUpdateText(): void { function download(filename: string, content: string): void { const file = new Blob([content], { type: "text/plain" }); - const navigator = window.navigator as any; - if (navigator.msSaveOrOpenBlob) { - // IE10+ - navigator.msSaveOrOpenBlob(file, filename); - } else { - // Others - const a = document.createElement("a"), - url = URL.createObjectURL(file); - a.href = url; - a.download = filename; - document.body.appendChild(a); - a.click(); - setTimeout(function () { - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - }, 0); - } + + const a = document.createElement("a"), + url = URL.createObjectURL(file); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + setTimeout(function () { + document.body.removeChild(a); + window.URL.revokeObjectURL(url); + }, 0); } Reviver.constructors.BitburnerSaveObject = BitburnerSaveObject; diff --git a/src/Script/Script.ts b/src/Script/Script.ts index be46c3e8f..e4ea95c3d 100644 --- a/src/Script/Script.ts +++ b/src/Script/Script.ts @@ -67,23 +67,16 @@ export class Script { download(): void { const filename = this.filename; const file = new Blob([this.code], { type: "text/plain" }); - const navigator = window.navigator as any; - if (navigator.msSaveOrOpenBlob) { - // IE10+ - navigator.msSaveOrOpenBlob(file, filename); - } else { - // Others - const a = document.createElement("a"), - url = URL.createObjectURL(file); - a.href = url; - a.download = filename; - document.body.appendChild(a); - a.click(); - setTimeout(function () { - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - }, 0); - } + const a = document.createElement("a"), + url = URL.createObjectURL(file); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + setTimeout(function () { + document.body.removeChild(a); + window.URL.revokeObjectURL(url); + }, 0); } /** diff --git a/src/TextFile.ts b/src/TextFile.ts index 64594a158..948b4f1d1 100644 --- a/src/TextFile.ts +++ b/src/TextFile.ts @@ -47,26 +47,17 @@ export class TextFile { * Serves the file to the user as a downloadable resource through the browser. */ download(): void { - const filename: string = this.fn; const file: Blob = new Blob([this.text], { type: "text/plain" }); - /* tslint:disable-next-line:strict-boolean-expressions */ - const navigator = window.navigator as any; - if (navigator.msSaveOrOpenBlob) { - // IE10+ - navigator.msSaveOrOpenBlob(file, filename); - } else { - // Others - const a: HTMLAnchorElement = document.createElement("a"); - const url: string = URL.createObjectURL(file); - a.href = url; - a.download = this.fn; - document.body.appendChild(a); - a.click(); - setTimeout(() => { - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - }, 0); - } + const a: HTMLAnchorElement = document.createElement("a"); + const url: string = URL.createObjectURL(file); + a.href = url; + a.download = this.fn; + document.body.appendChild(a); + a.click(); + setTimeout(() => { + document.body.removeChild(a); + window.URL.revokeObjectURL(url); + }, 0); } /** diff --git a/src/Themes/ui/StyleEditorModal.tsx b/src/Themes/ui/StyleEditorModal.tsx index b5b7bec4c..374cd3ff1 100644 --- a/src/Themes/ui/StyleEditorModal.tsx +++ b/src/Themes/ui/StyleEditorModal.tsx @@ -140,13 +140,13 @@ export function StyleEditorModal(props: IProps): React.ReactElement { update({ ...customStyle, fontFamily: value as any }, error)} + onChange={(value, error) => update({ ...customStyle, fontFamily: value ?? "" }, error)} />
update({ ...customStyle, lineHeight: value as any }, error)} + onChange={(value, error) => update({ ...customStyle, lineHeight: Number(value) ?? 0 }, error)} />