fix(zip): Tolerate XS null terminated string limitation
MODIFY
packages/zip/src/compression.js
packages/zip/src/compression.js
// @ts-check
// STORE is the magic number for "not compressed".
-export const STORE = '\x00\x00';
+export const STORE = 0;

MODIFY
packages/zip/src/format-reader.js
packages/zip/src/format-reader.js
@@ -90,7 +90,7 @@ function readHeaders(reader) {
return {
versionNeeded: reader.readUint16LE(),
bitFlag: reader.readUint16LE(),
- compressionMethod: textDecoder.decode(reader.read(2)),
+ compressionMethod: reader.readUint16LE(),
date: readDosDateTime(reader),
crc32: reader.readUint32LE(),
compressedLength: reader.readUint32LE(),

MODIFY
packages/zip/src/format-writer.js
packages/zip/src/format-writer.js
@@ -72,7 +72,7 @@ function writeFile(writer, file) {
// Version needed to extract
writer.writeUint16LE(10);
writer.writeUint16LE(file.bitFlag);
- writer.write(textEncoder.encode(file.compressionMethod));
+ writer.writeUint16LE(file.compressionMethod);
writeDosDateTime(writer, file.date);
writer.writeUint32LE(file.crc32);
writer.writeUint32LE(file.compressedLength);

MODIFY
packages/zip/src/types.js
packages/zip/src/types.js
* mode: number,
* date: Date?,
* crc32: number,
- * compressionMethod: string,
+ * compressionMethod: number,
* compressedLength: number,
* uncompressedLength: number,
* content: Uint8Array,
* @typedef {{
* versionNeeded: number,
* bitFlag: number,
- * compressionMethod: string,
+ * compressionMethod: number,
* date: Date?,
* crc32: number,
* compressedLength: number,

fix(zip): Tolerate XS null terminated string limitation