mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Use fflate for zlib in the web interface
ModPack and map exchange strings need synchronous inflate and deflate. In the browser these came from the browserify-zlib polyfill, which brings pako, assert and util along. The browser build now imports fflate through a #zlib_sync subpath import, Node.js keeps node:zlib. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
909f6ab08b
commit
4d7c1020b0
8 files changed
+64
-3
No files matched your search
@@ -0,0 +1,15 @@
|
||||
/* eslint-disable node/no-sync */
|
||||
import { strToU8, unzlibSync, zlibSync } from "fflate";
|
||||
|
||||
export function inflateSync(data: Uint8Array): Uint8Array {
|
||||
try {
|
||||
return unzlibSync(data);
|
||||
} catch (err: any) {
|
||||
// Match the error code node:zlib gives for invalid data.
|
||||
throw Object.assign(new Error(err.message), { code: "Z_DATA_ERROR" });
|
||||
}
|
||||
}
|
||||
|
||||
export function deflateSync(data: Uint8Array | string): Uint8Array {
|
||||
return zlibSync(typeof data === "string" ? strToU8(data) : data);
|
||||
}
|
||||
Reference in new issue
Block a user