mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Merge branch 'master' into add-ua-locale
This commit is contained in:
@@ -25,6 +25,11 @@ jobs:
|
|||||||
node-version: 22.11.0
|
node-version: 22.11.0
|
||||||
cache: "npm"
|
cache: "npm"
|
||||||
|
|
||||||
|
# Update package lists
|
||||||
|
- name: update apt-get
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
# Install and setup rpm/Flatpak for Ubuntu
|
# Install and setup rpm/Flatpak for Ubuntu
|
||||||
- name: Install rpm/flatpak packages (Ubuntu only)
|
- name: Install rpm/flatpak packages (Ubuntu only)
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ jobs:
|
|||||||
- name: Check out Git repository
|
- name: Check out Git repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: update apt-get
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
- name: Install rpm/flatpak packages
|
- name: Install rpm/flatpak packages
|
||||||
run: sudo apt-get install -y flatpak flatpak-builder rpm libarchive-tools
|
run: sudo apt-get install -y flatpak flatpak-builder rpm libarchive-tools
|
||||||
|
|
||||||
|
|||||||
@@ -472,7 +472,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<h2>Credits</h2>
|
<h2>Credits</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="https://github.com/Zagrios">Zagrios - Mathieu Gries</a> - Lead Developer & Founder.</li>
|
<li><a href="https://github.com/Zagrios">Zagrios</a> - Lead Developer & Founder.</li>
|
||||||
<li><a href="https://github.com/Iluhadesu">Iluhadesu</a> - Co-Developer & Co-Founder, Discord Bot Developer.</li>
|
<li><a href="https://github.com/Iluhadesu">Iluhadesu</a> - Co-Developer & Co-Founder, Discord Bot Developer.</li>
|
||||||
<li><a href="https://github.com/GaetanGrd">GaetanGrd</a> - Co-Developer & Co-Founder, Documentation Lead.</li>
|
<li><a href="https://github.com/GaetanGrd">GaetanGrd</a> - Co-Developer & Co-Founder, Documentation Lead.</li>
|
||||||
<li><a href="https://github.com/cheddZy">cheddZy</a> - Icon Creator.</li>
|
<li><a href="https://github.com/cheddZy">cheddZy</a> - Icon Creator.</li>
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"name": "bs-manager",
|
"name": "bs-manager",
|
||||||
"description": "Manage maps, mods and more for Beat Saber",
|
"description": "Manage maps, mods and more for Beat Saber",
|
||||||
"main": "./.erb/dll/main.bundle.dev.js",
|
"main": "./.erb/dll/main.bundle.dev.js",
|
||||||
"version": "1.5.1",
|
"version": "1.5.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build-rust-scripts": "ts-node ./.erb/scripts/build-rust-scripts.js",
|
"build-rust-scripts": "ts-node ./.erb/scripts/build-rust-scripts.js",
|
||||||
"build": "concurrently \"npm run build:main\" \"npm run build:renderer\"",
|
"build": "concurrently \"npm run build:main\" \"npm run build:renderer\"",
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "bs-manager",
|
"name": "bs-manager",
|
||||||
"version": "1.5.1",
|
"version": "1.5.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bs-manager",
|
"name": "bs-manager",
|
||||||
"version": "1.5.1",
|
"version": "1.5.2",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bs-manager",
|
"name": "bs-manager",
|
||||||
"version": "1.5.1",
|
"version": "1.5.2",
|
||||||
"description": "BSManager",
|
"description": "BSManager",
|
||||||
"main": "./dist/main/main.js",
|
"main": "./dist/main/main.js",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -10,16 +10,22 @@ import path from 'path';
|
|||||||
import { pipeline } from 'stream/promises';
|
import { pipeline } from 'stream/promises';
|
||||||
import sanitize from 'sanitize-filename';
|
import sanitize from 'sanitize-filename';
|
||||||
import internal from 'stream';
|
import internal from 'stream';
|
||||||
|
import { app } from 'electron';
|
||||||
|
|
||||||
export class RequestService {
|
export class RequestService {
|
||||||
private static instance: RequestService;
|
private static instance: RequestService;
|
||||||
private preferredFamily: number | undefined = undefined;
|
private preferredFamily: number | undefined = undefined;
|
||||||
|
private readonly baseHeaders = {
|
||||||
|
'User-Agent': `BSManager/${app.getVersion()} (Electron/${process.versions.electron} Chrome/${process.versions.chrome} Node/${process.versions.node})`,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static getInstance(): RequestService {
|
public static getInstance(): RequestService {
|
||||||
if (!RequestService.instance) {
|
if (!RequestService.instance) {
|
||||||
RequestService.instance = new RequestService();
|
RequestService.instance = new RequestService();
|
||||||
}
|
}
|
||||||
return RequestService.instance;
|
return RequestService.instance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructor() {}
|
private constructor() {}
|
||||||
@@ -32,7 +38,7 @@ export class RequestService {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
// @ts-ignore (ESM is not well supported in this project, We need to move out electron-react-boilerplate, and use Vite)
|
// @ts-ignore (ESM is not well supported in this project, We need to move out electron-react-boilerplate, and use Vite)
|
||||||
const res = await got(url, { dnsLookupIpVersion: family, responseType: 'json' });
|
const res = await got(url, { dnsLookupIpVersion: family, responseType: 'json', headers: this.baseHeaders });
|
||||||
this.preferredFamily = family;
|
this.preferredFamily = family;
|
||||||
return { data: res.body as T, headers: res.headers };
|
return { data: res.body as T, headers: res.headers };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -67,7 +73,7 @@ export class RequestService {
|
|||||||
let file: WriteStream | undefined;
|
let file: WriteStream | undefined;
|
||||||
|
|
||||||
// @ts-ignore (ESM is not well supported in this project, We need to move out electron-react-boilerplate, and use Vite)
|
// @ts-ignore (ESM is not well supported in this project, We need to move out electron-react-boilerplate, and use Vite)
|
||||||
stream = got.stream(url, { dnsLookupIpVersion: family });
|
stream = got.stream(url, { dnsLookupIpVersion: family, headers: this.baseHeaders });
|
||||||
|
|
||||||
stream.on('response', (response) => {
|
stream.on('response', (response) => {
|
||||||
this.preferredFamily = family;
|
this.preferredFamily = family;
|
||||||
@@ -130,6 +136,7 @@ export class RequestService {
|
|||||||
data: null,
|
data: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const headers = { ...this.baseHeaders, ...(options?.headers ?? {}) };
|
||||||
const familiesToTry = this.preferredFamily ? [this.preferredFamily, this.preferredFamily === 4 ? 6 : 4] : [4, 6];
|
const familiesToTry = this.preferredFamily ? [this.preferredFamily, this.preferredFamily === 4 ? 6 : 4] : [4, 6];
|
||||||
|
|
||||||
let attempt = 0;
|
let attempt = 0;
|
||||||
@@ -142,9 +149,8 @@ export class RequestService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const family = familiesToTry[attempt++];
|
const family = familiesToTry[attempt++];
|
||||||
|
|
||||||
// @ts-ignore (ESM is not well supported in this project, We need to move out electron-react-boilerplate, and use Vite)
|
// @ts-ignore (ESM is not well supported in this project, We need to move out electron-react-boilerplate, and use Vite)
|
||||||
stream = got.stream(url, { dnsLookupIpVersion: family, ...(options ?? {}) });
|
stream = got.stream(url, { dnsLookupIpVersion: family, ...(options ?? {}), headers });
|
||||||
|
|
||||||
let data = Buffer.alloc(0);
|
let data = Buffer.alloc(0);
|
||||||
let response: IncomingMessage;
|
let response: IncomingMessage;
|
||||||
|
|||||||
Reference in New Issue
Block a user