mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-20 00:41:48 +03:00
Fix TS Errors
This commit is contained in:
parent
9dc5b47983
commit
e02892ea74
6 changed files with 14 additions and 19 deletions
|
@ -5,6 +5,9 @@ import type {
|
||||||
ArchiveInfo
|
ArchiveInfo
|
||||||
} from './types/Archive';
|
} from './types/Archive';
|
||||||
|
|
||||||
|
declare const Neutralino;
|
||||||
|
declare const NL_CWD;
|
||||||
|
|
||||||
class Stream
|
class Stream
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -60,10 +63,8 @@ class Stream
|
||||||
|
|
||||||
let remainedFiles = this.archive.files;
|
let remainedFiles = this.archive.files;
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
const baseDir = unpackDir ?? NL_CWD;
|
const baseDir = unpackDir ?? NL_CWD;
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.os.execCommand(command, {
|
Neutralino.os.execCommand(command, {
|
||||||
background: true
|
background: true
|
||||||
});
|
});
|
||||||
|
@ -74,7 +75,6 @@ class Stream
|
||||||
remainedFiles.forEach((file) => {
|
remainedFiles.forEach((file) => {
|
||||||
if (file.path != '#unpacked#')
|
if (file.path != '#unpacked#')
|
||||||
{
|
{
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.filesystem.getStats(`${baseDir}/${file.path}`)
|
Neutralino.filesystem.getStats(`${baseDir}/${file.path}`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.unpacked += file.size.uncompressed;
|
this.unpacked += file.size.uncompressed;
|
||||||
|
@ -198,7 +198,6 @@ export default class Archive
|
||||||
switch (archive.type)
|
switch (archive.type)
|
||||||
{
|
{
|
||||||
case 'tar':
|
case 'tar':
|
||||||
// @ts-expect-error
|
|
||||||
const tarOutput = await Neutralino.os.execCommand(`tar -tvf "${path}"`);
|
const tarOutput = await Neutralino.os.execCommand(`tar -tvf "${path}"`);
|
||||||
|
|
||||||
for (const match of tarOutput.stdOut.matchAll(/^[dwxr\-]+ [\w/]+[ ]+(\d+) [0-9\-]+ [0-9\:]+ (.+)/gm))
|
for (const match of tarOutput.stdOut.matchAll(/^[dwxr\-]+ [\w/]+[ ]+(\d+) [0-9\-]+ [0-9\:]+ (.+)/gm))
|
||||||
|
@ -221,7 +220,6 @@ export default class Archive
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'zip':
|
case 'zip':
|
||||||
// @ts-expect-error
|
|
||||||
const zipOutput = await Neutralino.os.execCommand(`unzip -v "${path}"`);
|
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))
|
for (const match of zipOutput.stdOut.matchAll(/^(\d+) [a-zA-Z\:]+[ ]+(\d+)[ ]+[0-9\-]+% [0-9\-]+ [0-9\:]+ [a-f0-9]{8} (.+)/gm))
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import Constants from './Constants';
|
import Constants from './Constants';
|
||||||
|
declare const Neutralino;
|
||||||
|
declare const NL_CWD;
|
||||||
|
|
||||||
// Ok yea, null and object aren't scalars
|
// Ok yea, null and object aren't scalars
|
||||||
// but I don't care
|
// but I don't care
|
||||||
|
@ -15,7 +17,6 @@ export default class Configs
|
||||||
public static get(name: string = ''): Promise<undefined|scalar|scalar[]>
|
public static get(name: string = ''): Promise<undefined|scalar|scalar[]>
|
||||||
{
|
{
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.filesystem.readFile(await Constants.paths.config).then((config) => {
|
Neutralino.filesystem.readFile(await Constants.paths.config).then((config) => {
|
||||||
config = JSON.parse(config);
|
config = JSON.parse(config);
|
||||||
|
|
||||||
|
@ -48,17 +49,14 @@ export default class Configs
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.filesystem.readFile(await Constants.paths.config).then(async (config) => {
|
Neutralino.filesystem.readFile(await Constants.paths.config).then(async (config) => {
|
||||||
config = JSON.stringify(getUpdatedArray(name.split('.'), JSON.parse(config), value), null, 4);
|
config = JSON.stringify(getUpdatedArray(name.split('.'), JSON.parse(config), value), null, 4);
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.filesystem.writeFile(await Constants.paths.config, config)
|
Neutralino.filesystem.writeFile(await Constants.paths.config, config)
|
||||||
.then(() => resolve());
|
.then(() => resolve());
|
||||||
}).catch(async () => {
|
}).catch(async () => {
|
||||||
let config = JSON.stringify(getUpdatedArray(name.split('.'), {}, value), null, 4);
|
let config = JSON.stringify(getUpdatedArray(name.split('.'), {}, value), null, 4);
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.filesystem.writeFile(await Constants.paths.config, config)
|
Neutralino.filesystem.writeFile(await Constants.paths.config, config)
|
||||||
.then(() => resolve());
|
.then(() => resolve());
|
||||||
});
|
});
|
||||||
|
@ -98,12 +96,10 @@ export default class Configs
|
||||||
|
|
||||||
current = JSON.stringify(updateDefaults(current, configs), null, 4);
|
current = JSON.stringify(updateDefaults(current, configs), null, 4);
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.filesystem.writeFile(await Constants.paths.config, current)
|
Neutralino.filesystem.writeFile(await Constants.paths.config, current)
|
||||||
.then(() => resolve());
|
.then(() => resolve());
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.filesystem.readFile(await Constants.paths.config)
|
Neutralino.filesystem.readFile(await Constants.paths.config)
|
||||||
.then((config) => setDefaults(JSON.parse(config)))
|
.then((config) => setDefaults(JSON.parse(config)))
|
||||||
.catch(() => setDefaults({}));
|
.catch(() => setDefaults({}));
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
declare const Neutralino;
|
||||||
|
|
||||||
class Paths
|
class Paths
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +28,6 @@ class Paths
|
||||||
*/
|
*/
|
||||||
public static get launcher(): Promise<string>
|
public static get launcher(): Promise<string>
|
||||||
{
|
{
|
||||||
// @ts-expect-error
|
|
||||||
return new Promise(async (resolve) => resolve(`${await Neutralino.os.getPath('data')}/anime-game-launcher`));
|
return new Promise(async (resolve) => resolve(`${await Neutralino.os.getPath('data')}/anime-game-launcher`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
declare const Neutralino;
|
||||||
|
declare const NL_CWD;
|
||||||
|
|
||||||
class Stream
|
class Stream
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -25,13 +28,11 @@ class Stream
|
||||||
if (this.onStart)
|
if (this.onStart)
|
||||||
this.onStart();
|
this.onStart();
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.os.execCommand(`curl -s -L -N -o "${output}" "${uri}"`, {
|
Neutralino.os.execCommand(`curl -s -L -N -o "${output}" "${uri}"`, {
|
||||||
background: true
|
background: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateProgress = () => {
|
const updateProgress = () => {
|
||||||
// @ts-expect-error
|
|
||||||
Neutralino.filesystem.getStats(output).then((stats) => {
|
Neutralino.filesystem.getStats(output).then((stats) => {
|
||||||
if (this.onProgress)
|
if (this.onProgress)
|
||||||
this.onProgress(stats.size, this.total, this.previous - stats.size);
|
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>
|
public static async download(uri: string, output: string|null = null): Promise<Stream>
|
||||||
{
|
{
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
// @ts-expect-error
|
|
||||||
let statsRaw = await Neutralino.os.execCommand(`curl -s -I -L "${uri}"`);
|
let statsRaw = await Neutralino.os.execCommand(`curl -s -I -L "${uri}"`);
|
||||||
|
|
||||||
if (statsRaw.stdOut == '')
|
if (statsRaw.stdOut == '')
|
||||||
|
|
|
@ -3,6 +3,8 @@ import {
|
||||||
RunnerFamily
|
RunnerFamily
|
||||||
} from './types/Runners';
|
} from './types/Runners';
|
||||||
|
|
||||||
|
declare const Neutralino;
|
||||||
|
|
||||||
import Constants from './Constants';
|
import Constants from './Constants';
|
||||||
import Downloader from './Downloader';
|
import Downloader from './Downloader';
|
||||||
import Archive from './Archive';
|
import Archive from './Archive';
|
||||||
|
@ -175,10 +177,8 @@ class Runners
|
||||||
{
|
{
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
Constants.paths.runners.then(async (runnersDir: string) => {
|
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`));
|
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);
|
const installed: { entry: string, type: string }[] = await Neutralino.filesystem.readDirectory(runnersDir);
|
||||||
|
|
||||||
let runners: RunnerFamily[] = [];
|
let runners: RunnerFamily[] = [];
|
||||||
|
|
|
@ -22,18 +22,18 @@ type WindowOptions = WindowSize & {
|
||||||
processArgs?: string;
|
processArgs?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare const Neutralino;
|
||||||
|
|
||||||
class Window
|
class Window
|
||||||
{
|
{
|
||||||
public static get current(): any
|
public static get current(): any
|
||||||
{
|
{
|
||||||
// @ts-expect-error
|
|
||||||
return Neutralino.window;
|
return Neutralino.window;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async open(name: string, options: WindowOptions = {}): Promise<boolean>
|
public static async open(name: string, options: WindowOptions = {}): Promise<boolean>
|
||||||
{
|
{
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
// @ts-expect-error
|
|
||||||
const status = Neutralino.window.create(`/${name}.html`, {
|
const status = Neutralino.window.create(`/${name}.html`, {
|
||||||
width: 600,
|
width: 600,
|
||||||
height: 400,
|
height: 400,
|
||||||
|
|
Loading…
Reference in a new issue