1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-08 08:04:49 +00:00
This commit is contained in:
zumbiepig 2024-09-02 13:27:29 -07:00
parent 71999367c6
commit 3928bab178
No known key found for this signature in database
GPG Key ID: 17C891BE28B953DE
3 changed files with 42 additions and 1 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -20,6 +20,7 @@
"express": "^4.19.2",
"helmet": "^7.1.0",
"morgan": "^1.10.0",
"pako": "^2.1.0",
"semver": "^7.6.3",
"serve-favicon": "^2.5.0"
},
@ -32,6 +33,7 @@
"@types/errorhandler": "^1.5.3",
"@types/eslint__js": "^8.42.3",
"@types/morgan": "^1.9.9",
"@types/pako": "^2.0.3",
"@types/semver": "^7.5.8",
"@types/serve-favicon": "^2.5.7",
"eslint": "^9.9.1",

View File

@ -1,4 +1,5 @@
import { gt, coerce } from 'semver';
import { inflate, deflate } from 'pako';
let selectedVersion: string;
@ -308,6 +309,44 @@ const serviceworker = {
},
};
const base64Gzip = {
decode: function (base64: string) {
// Decode Base64 to binary string
const binaryString = atob(base64);
// Convert binary string to Uint8Array
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
// Use pako to decompress the Uint8Array
const decompressed = inflate(bytes, { to: 'string' });
return decompressed;
},
encode: function (inputString: string) {
// Convert the input string to a Uint8Array
const encoder = new TextEncoder();
const inputBytes = encoder.encode(inputString);
// Use pako to compress the Uint8Array
const compressedBytes = deflate(inputBytes);
// Convert the compressed Uint8Array to a binary string
let binaryString = '';
for (const byte of compressedBytes) {
binaryString += String.fromCharCode(byte);
}
// Encode the binary string to Base64
const base64String = btoa(binaryString);
return base64String;
},
};
theme.load();
if (detect.mobile()) {
@ -527,5 +566,5 @@ if (window.location.pathname === '/settings/') {
if (window.location.hostname === null) {
// Stop the minifier from removing these functions
console.debug([navigate, query, versionSelector, game, mods]);
console.debug([navigate, query, versionSelector, game, mods, base64Gzip]);
}