Fix TS Errors

This commit is contained in:
Maroxy 2021-12-21 20:41:26 +01:00
parent 9dc5b47983
commit e02892ea74
No known key found for this signature in database
GPG key ID: F4B27EADB21E3021
6 changed files with 14 additions and 19 deletions

View file

@ -5,6 +5,9 @@ import type {
ArchiveInfo
} from './types/Archive';
declare const Neutralino;
declare const NL_CWD;
class Stream
{
/**
@ -60,10 +63,8 @@ class Stream
let remainedFiles = this.archive.files;
// @ts-expect-error
const baseDir = unpackDir ?? NL_CWD;
// @ts-expect-error
Neutralino.os.execCommand(command, {
background: true
});
@ -74,7 +75,6 @@ class Stream
remainedFiles.forEach((file) => {
if (file.path != '#unpacked#')
{
// @ts-expect-error
Neutralino.filesystem.getStats(`${baseDir}/${file.path}`)
.then(() => {
this.unpacked += file.size.uncompressed;
@ -198,7 +198,6 @@ export default class Archive
switch (archive.type)
{
case 'tar':
// @ts-expect-error
const tarOutput = await Neutralino.os.execCommand(`tar -tvf "${path}"`);
for (const match of tarOutput.stdOut.matchAll(/^[dwxr\-]+ [\w/]+[ ]+(\d+) [0-9\-]+ [0-9\:]+ (.+)/gm))
@ -221,7 +220,6 @@ export default class Archive
break;
case 'zip':
// @ts-expect-error
const zipOutput = await Neutralino.os.execCommand(`unzip -v "${path}"`);
for (const match of zipOutput.stdOut.matchAll(/^(\d+) [a-zA-Z\:]+[ ]+(\d+)[ ]+[0-9\-]+% [0-9\-]+ [0-9\:]+ [a-f0-9]{8} (.+)/gm))

View file

@ -1,4 +1,6 @@
import Constants from './Constants';
declare const Neutralino;
declare const NL_CWD;
// Ok yea, null and object aren't scalars
// but I don't care
@ -15,7 +17,6 @@ export default class Configs
public static get(name: string = ''): Promise<undefined|scalar|scalar[]>
{
return new Promise(async (resolve) => {
// @ts-expect-error
Neutralino.filesystem.readFile(await Constants.paths.config).then((config) => {
config = JSON.parse(config);
@ -48,17 +49,14 @@ export default class Configs
};
return new Promise(async (resolve) => {
// @ts-expect-error
Neutralino.filesystem.readFile(await Constants.paths.config).then(async (config) => {
config = JSON.stringify(getUpdatedArray(name.split('.'), JSON.parse(config), value), null, 4);
// @ts-expect-error
Neutralino.filesystem.writeFile(await Constants.paths.config, config)
.then(() => resolve());
}).catch(async () => {
let config = JSON.stringify(getUpdatedArray(name.split('.'), {}, value), null, 4);
// @ts-expect-error
Neutralino.filesystem.writeFile(await Constants.paths.config, config)
.then(() => resolve());
});
@ -98,12 +96,10 @@ export default class Configs
current = JSON.stringify(updateDefaults(current, configs), null, 4);
// @ts-expect-error
Neutralino.filesystem.writeFile(await Constants.paths.config, current)
.then(() => resolve());
};
// @ts-expect-error
Neutralino.filesystem.readFile(await Constants.paths.config)
.then((config) => setDefaults(JSON.parse(config)))
.catch(() => setDefaults({}));

View file

@ -1,3 +1,5 @@
declare const Neutralino;
class Paths
{
/**
@ -26,7 +28,6 @@ class Paths
*/
public static get launcher(): Promise<string>
{
// @ts-expect-error
return new Promise(async (resolve) => resolve(`${await Neutralino.os.getPath('data')}/anime-game-launcher`));
}

View file

@ -1,3 +1,6 @@
declare const Neutralino;
declare const NL_CWD;
class Stream
{
/**
@ -25,13 +28,11 @@ class Stream
if (this.onStart)
this.onStart();
// @ts-expect-error
Neutralino.os.execCommand(`curl -s -L -N -o "${output}" "${uri}"`, {
background: true
});
const updateProgress = () => {
// @ts-expect-error
Neutralino.filesystem.getStats(output).then((stats) => {
if (this.onProgress)
this.onProgress(stats.size, this.total, this.previous - stats.size);
@ -107,7 +108,6 @@ export default class Downloader
public static async download(uri: string, output: string|null = null): Promise<Stream>
{
return new Promise(async (resolve) => {
// @ts-expect-error
let statsRaw = await Neutralino.os.execCommand(`curl -s -I -L "${uri}"`);
if (statsRaw.stdOut == '')

View file

@ -3,6 +3,8 @@ import {
RunnerFamily
} from './types/Runners';
declare const Neutralino;
import Constants from './Constants';
import Downloader from './Downloader';
import Archive from './Archive';
@ -175,10 +177,8 @@ class Runners
{
return new Promise((resolve) => {
Constants.paths.runners.then(async (runnersDir: string) => {
// @ts-expect-error
let list: RunnerFamily[] = JSON.parse(await Neutralino.filesystem.readFile(`${Constants.paths.app}/public/runners.json`));
// @ts-expect-error
const installed: { entry: string, type: string }[] = await Neutralino.filesystem.readDirectory(runnersDir);
let runners: RunnerFamily[] = [];

View file

@ -22,18 +22,18 @@ type WindowOptions = WindowSize & {
processArgs?: string;
};
declare const Neutralino;
class Window
{
public static get current(): any
{
// @ts-expect-error
return Neutralino.window;
}
public static async open(name: string, options: WindowOptions = {}): Promise<boolean>
{
return new Promise(async (resolve) => {
// @ts-expect-error
const status = Neutralino.window.create(`/${name}.html`, {
width: 600,
height: 400,