Merge branch 'master' into chore/sharp-to-resvg-js

This commit is contained in:
MathieuG-P
2024-04-11 18:52:42 +02:00
5 changed files with 51 additions and 28 deletions
+9
View File
@@ -708,5 +708,14 @@
"ReleaseImg": "https://clan.cloudflare.steamstatic.com/images//32055887/9a141be5c44ca6fc81551a2c7e7f28407df413ed.png",
"ReleaseDate": "1709831174",
"year": "2024"
},
{
"BSVersion": "1.36.0",
"BSManifest": "8533509040167838423",
"OculusBinaryId": "6863072637125790",
"ReleaseURL": "https://store.steampowered.com/news/app/620980/view/4205873192610459250",
"ReleaseImg": "https://clan.akamai.steamstatic.com/images//32055887/b8bd8a050e2bc3903cf18a277c5489ade01f7e75.png",
"ReleaseDate": "1712681263",
"year": "2024"
}
]
+7 -17
View File
@@ -18,9 +18,6 @@
{
"username": "Falmil"
},
{
"username": "K1Lc4m"
},
{
"username": "Anonymously42",
"type": "diamond",
@@ -30,9 +27,6 @@
"username": "Burt",
"type": "gold"
},
{
"username": "Ilnahro"
},
{
"username": "Phil",
"type": "gold"
@@ -41,18 +35,10 @@
"username": "Protocrush",
"type": "gold"
},
{
"username": "ServerMensch",
"type": "gold"
},
{
"username": "Karlito",
"type": "gold"
},
{
"username": "Cathery",
"type": "gold"
},
{
"username": ".sharkey"
},
@@ -74,9 +60,6 @@
{
"username": "Minescence"
},
{
"username": "Finlay"
},
{
"username": "mereknom"
},
@@ -89,5 +72,12 @@
},
{
"username": "rhythmshade"
},
{
"username": "liborsaf"
},
{
"username": "aatame3",
"type": "gold"
}
]
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "bs-manager",
"version": "1.4.6",
"version": "1.4.7",
"description": "BSManager",
"main": "./dist/main/main.js",
"author": {
@@ -155,8 +155,13 @@ export class BsModsManagerService {
}
return new Promise<boolean>(resolve => {
log.info("START IPA PROCESS", `start /wait /min "" "${ipaPath}" ${args.join(" ")}`);
const processIPA = spawn(`start /wait /min "" "${ipaPath}" ${args.join(" ")}`, { cwd: versionPath, detached: true, shell: true });
const cmd = process.platform === 'linux'
? `screen -dmS "BSIPA" dotnet ${ipaPath} ${args.join(" ")}` // Must run through screen, otherwise BSIPA tries to move console cursor and crashes.
: `start /wait /min "" "${ipaPath}" ${args.join(" ")}`;
log.info("START IPA PROCESS", cmd);
const processIPA = spawn(cmd, { cwd: versionPath, detached: true, shell: true });
processIPA.once("exit", code => {
if (code === 0) {
log.info("Ipa process exist with code 0");
@@ -230,7 +235,7 @@ export class BsModsManagerService {
log.error("Error while extracting mod zip", e);
return false;
});
log.info("Mod zip extraction end", mod.name, "to", destDir, "success:", extracted);
const res = isBSIPA
+26 -7
View File
@@ -1,9 +1,11 @@
import { Agent, get } from "https";
import { Agent, RequestOptions, get } from "https";
import { createWriteStream, unlink } from "fs";
import { Progression } from "main/helpers/fs.helpers";
import { Observable, shareReplay, tap } from "rxjs";
import log from "electron-log";
import fetch, { RequestInfo, RequestInit } from "node-fetch";
import { app } from "electron";
import os from "os";
export class RequestService {
private static instance: RequestService;
@@ -15,16 +17,33 @@ export class RequestService {
return RequestService.instance;
}
private constructor() {}
private readonly defaultRequestInit: RequestInit;
private get ipv4Agent(){
return new Agent({ family: 4 });
private constructor() {
this.defaultRequestInit = {
headers: {
"User-Agent": `BSManager/${app.getVersion()} (${os.type()} ${os.release()})`
},
agent: new Agent({ family: 4 }),
};
}
private getInitWithOptions(options?: RequestInit): RequestInit {
return { ...this.defaultRequestInit, ...(options || {}) };
}
private requestOptionsFromDefaultInit(): RequestOptions {
return {
headers: this.defaultRequestInit.headers as Record<string, string>,
agent: this.defaultRequestInit.agent as Agent,
};
}
public async getJSON<T = unknown>(url: RequestInfo, options?: RequestInit): Promise<T> {
try {
const response = await fetch(url, {...options, agent: this.ipv4Agent});
const response = await fetch(url, this.getInitWithOptions(options));
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status} ${url}`);
@@ -50,7 +69,7 @@ export class RequestService {
});
file.on("error", err => unlink(dest, () => subscriber.error(err)));
const req = get(url, { agent: this.ipv4Agent }, res => {
const req = get(url, this.requestOptionsFromDefaultInit(), res => {
progress.total = parseInt(res.headers?.["content-length"] || "0", 10);
res.on("data", chunk => {
@@ -77,7 +96,7 @@ export class RequestService {
const allChunks: Buffer[] = [];
const req = get(url, { agent: this.ipv4Agent }, res => {
const req = get(url, this.requestOptionsFromDefaultInit(), res => {
progress.total = parseInt(res.headers?.["content-length"] || "0", 10);
res.on("data", chunk => {