@zip.js/zip.js 2.7.57 → 2.7.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -175,7 +175,7 @@ export interface dataHandler {
175
175
  /**
176
176
  * @param data The processed chunk of data.
177
177
  */
178
- (data: Uint8Array): void;
178
+ (data: Uint8Array<ArrayBuffer>): void;
179
179
  }
180
180
 
181
181
  /**
@@ -206,13 +206,13 @@ declare class EventBasedCodec {
206
206
  *
207
207
  * @param data The chunk of data to append.
208
208
  */
209
- push(data: Uint8Array): void;
209
+ push(data: Uint8Array<ArrayBuffer>): void;
210
210
  /**
211
211
  * The function called when a chunk of data has been compressed/decompressed.
212
212
  *
213
213
  * @param data The chunk of compressed/decompressed data.
214
214
  */
215
- ondata(data?: Uint8Array): void;
215
+ ondata(data?: Uint8Array<ArrayBuffer>): void;
216
216
  }
217
217
 
218
218
  /**
@@ -240,7 +240,7 @@ declare class SyncCodec {
240
240
  * @param data The chunk of decompressed data to append.
241
241
  * @returns A chunk of compressed data.
242
242
  */
243
- append(data: Uint8Array): Uint8Array;
243
+ append(data: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>;
244
244
  }
245
245
 
246
246
  /**
@@ -252,7 +252,7 @@ declare class ZipDeflate extends SyncCodec {
252
252
  *
253
253
  * @returns A chunk of compressed data.
254
254
  */
255
- flush(): Uint8Array;
255
+ flush(): Uint8Array<ArrayBuffer>;
256
256
  }
257
257
 
258
258
  /**
@@ -355,7 +355,7 @@ export class Reader<Type> implements Initializable, ReadableReader {
355
355
  * @param length The length of the data to read in bytes.
356
356
  * @returns A promise resolving to a chunk of data.
357
357
  */
358
- readUint8Array(index: number, length: number): Promise<Uint8Array>;
358
+ readUint8Array(index: number, length: number): Promise<Uint8Array<ArrayBuffer>>;
359
359
  }
360
360
 
361
361
  /**
@@ -376,7 +376,7 @@ export class Data64URIReader extends Reader<string> { }
376
376
  /**
377
377
  * Represents a {@link Reader} instance used to read data provided as a `Uint8Array` instance.
378
378
  */
379
- export class Uint8ArrayReader extends Reader<Uint8Array> { }
379
+ export class Uint8ArrayReader extends Reader<Uint8Array<ArrayBuffer>> { }
380
380
 
381
381
  /**
382
382
  * Represents a {@link Reader} instance used to read data provided as an array of {@link ReadableReader} instances (e.g. split zip files).
@@ -391,22 +391,17 @@ export class SplitZipReader extends SplitDataReader { }
391
391
  export class SplitDataReader
392
392
  extends Reader<Reader<unknown>[] | ReadableReader[] | ReadableStream[]> { }
393
393
 
394
- /**
395
- * Represents a URL stored into a `string`.
396
- */
397
- interface URLString extends String { }
398
-
399
394
  /**
400
395
  * Represents a {@link Reader} instance used to fetch data from a URL.
401
396
  */
402
- export class HttpReader extends Reader<URLString> {
397
+ export class HttpReader extends Reader<string> {
403
398
  /**
404
399
  * Creates the {@link HttpReader} instance
405
400
  *
406
401
  * @param url The URL of the data.
407
402
  * @param options The options.
408
403
  */
409
- constructor(url: URLString | URL, options?: HttpOptions);
404
+ constructor(url: string | URL, options?: HttpOptions);
410
405
  }
411
406
 
412
407
  /**
@@ -419,7 +414,7 @@ export class HttpRangeReader extends HttpReader {
419
414
  * @param url The URL of the data.
420
415
  * @param options The options.
421
416
  */
422
- constructor(url: URLString | URL, options?: HttpRangeOptions);
417
+ constructor(url: string | URL, options?: HttpRangeOptions);
423
418
  }
424
419
 
425
420
  /**
@@ -526,7 +521,7 @@ export class Writer<Type> implements Initializable, WritableWriter {
526
521
  *
527
522
  * @virtual
528
523
  */
529
- writeUint8Array(array: Uint8Array): Promise<void>;
524
+ writeUint8Array(array: Uint8Array<ArrayBuffer>): Promise<void>;
530
525
  /**
531
526
  * Retrieves all the written data
532
527
  *
@@ -622,7 +617,7 @@ export class SplitDataWriter implements Initializable, WritableWriter {
622
617
  /**
623
618
  * Represents a {@link Writer} instance used to retrieve the written data as a `Uint8Array` instance.
624
619
  */
625
- export class Uint8ArrayWriter extends Writer<Uint8Array> { }
620
+ export class Uint8ArrayWriter extends Writer<Uint8Array<ArrayBuffer>> { }
626
621
 
627
622
  /**
628
623
  * Represents an instance used to create an unzipped stream.
@@ -657,7 +652,7 @@ export class ZipReaderStream<T> {
657
652
  * The readable stream.
658
653
  */
659
654
  readable: ReadableStream<
660
- Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array> }
655
+ Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array<ArrayBuffer>> }
661
656
  >;
662
657
 
663
658
  /**
@@ -718,15 +713,15 @@ export class ZipReader<Type> {
718
713
  /**
719
714
  * The global comment of the zip file.
720
715
  */
721
- comment: Uint8Array;
716
+ comment: Uint8Array<ArrayBuffer>;
722
717
  /**
723
718
  * The data prepended before the zip file.
724
719
  */
725
- prependedData?: Uint8Array;
720
+ prependedData?: Uint8Array<ArrayBuffer>;
726
721
  /**
727
722
  * The data appended after the zip file.
728
723
  */
729
- appendedData?: Uint8Array;
724
+ appendedData?: Uint8Array<ArrayBuffer>;
730
725
  /**
731
726
  * Returns all the entries in the zip file
732
727
  *
@@ -787,13 +782,13 @@ export interface GetEntriesOptions {
787
782
  */
788
783
  commentEncoding?: string;
789
784
  /**
790
- * Decodes the filename and the comment of the entry.
791
- *
785
+ * The function called for decoding the filename and the comment of the entry.
786
+ *
792
787
  * @param value The raw text value.
793
788
  * @param encoding The encoding of the text.
794
789
  * @returns The decoded text value or `undefined` if the raw text value should be decoded by zip.js.
795
790
  */
796
- decodeText?(value: Uint8Array, encoding: string): string | undefined;
791
+ decodeText?(value: Uint8Array<ArrayBuffer>, encoding: string): string | undefined;
797
792
  }
798
793
 
799
794
  /**
@@ -823,7 +818,7 @@ export interface ZipReaderOptions {
823
818
  /**
824
819
  * The password used to encrypt the content of the entry (raw).
825
820
  */
826
- rawPassword?: Uint8Array;
821
+ rawPassword?: Uint8Array<ArrayBuffer>;
827
822
  /**
828
823
  * The `AbortSignal` instance used to cancel the decompression.
829
824
  */
@@ -857,7 +852,7 @@ export interface EntryMetaData {
857
852
  /**
858
853
  * The filename of the entry (raw).
859
854
  */
860
- rawFilename: Uint8Array;
855
+ rawFilename: Uint8Array<ArrayBuffer>;
861
856
  /**
862
857
  * `true` if the filename is encoded in UTF-8.
863
858
  */
@@ -917,7 +912,7 @@ export interface EntryMetaData {
917
912
  /**
918
913
  * The comment of the entry (raw).
919
914
  */
920
- rawComment: Uint8Array;
915
+ rawComment: Uint8Array<ArrayBuffer>;
921
916
  /**
922
917
  * `true` if the comment is encoded in UTF-8.
923
918
  */
@@ -929,11 +924,11 @@ export interface EntryMetaData {
929
924
  /**
930
925
  * The extra field.
931
926
  */
932
- extraField?: Map<number, { type: number, data: Uint8Array }>;
927
+ extraField?: Map<number, { type: number, data: Uint8Array<ArrayBuffer> }>;
933
928
  /**
934
929
  * The extra field (raw).
935
930
  */
936
- rawExtraField: Uint8Array;
931
+ rawExtraField: Uint8Array<ArrayBuffer>;
937
932
  /**
938
933
  * `true` if the entry is using Zip64.
939
934
  */
@@ -1064,7 +1059,7 @@ export class ZipWriterStream {
1064
1059
  /**
1065
1060
  * The readable stream.
1066
1061
  */
1067
- readable: ReadableStream<Uint8Array>;
1062
+ readable: ReadableStream<Uint8Array<ArrayBuffer>>;
1068
1063
 
1069
1064
  /**
1070
1065
  * The ZipWriter property.
@@ -1097,7 +1092,7 @@ export class ZipWriterStream {
1097
1092
  * @returns The content of the zip file.
1098
1093
  */
1099
1094
  close(
1100
- comment?: Uint8Array,
1095
+ comment?: Uint8Array<ArrayBuffer>,
1101
1096
  options?: ZipWriterCloseOptions,
1102
1097
  ): Promise<unknown>;
1103
1098
  }
@@ -1170,7 +1165,7 @@ export class ZipWriter<Type> {
1170
1165
  * @param options The options.
1171
1166
  * @returns The content of the zip file.
1172
1167
  */
1173
- close(comment?: Uint8Array, options?: ZipWriterCloseOptions): Promise<Type>;
1168
+ close(comment?: Uint8Array<ArrayBuffer>, options?: ZipWriterCloseOptions): Promise<Type>;
1174
1169
  }
1175
1170
 
1176
1171
  /**
@@ -1200,7 +1195,7 @@ export interface ZipWriterAddDataOptions
1200
1195
  /**
1201
1196
  * The extra field of the entry.
1202
1197
  */
1203
- extraField?: Map<number, Uint8Array>;
1198
+ extraField?: Map<number, Uint8Array<ArrayBuffer>>;
1204
1199
  /**
1205
1200
  * The uncompressed size of the entry. This option is ignored if the {@link ZipWriterConstructorOptions#passThrough} option is not set to `true`.
1206
1201
  */
@@ -1279,9 +1274,12 @@ export interface ZipWriterConstructorOptions {
1279
1274
  /**
1280
1275
  * The password used to encrypt the content of the entry (raw).
1281
1276
  */
1282
- rawPassword?: Uint8Array;
1277
+ rawPassword?: Uint8Array<ArrayBuffer>;
1283
1278
  /**
1284
- * The encryption strength (AES).
1279
+ * The encryption strength (AES):
1280
+ * - 1: 128-bit encryption key
1281
+ * - 2: 192-bit encryption key
1282
+ * - 3: 256-bit encryption key
1285
1283
  *
1286
1284
  * @defaultValue 3
1287
1285
  */
@@ -1340,7 +1338,7 @@ export interface ZipWriterConstructorOptions {
1340
1338
  versionMadeBy?: number;
1341
1339
  /**
1342
1340
  * `true` to mark the file names as UTF-8 setting the general purpose bit 11 in the header (see Appendix D - Language Encoding (EFS)), `false` to mark the names as compliant with the original IBM Code Page 437.
1343
- *
1341
+ *
1344
1342
  * Note that this does not ensure that the file names are in the correct encoding.
1345
1343
  *
1346
1344
  * @defaultValue true
@@ -1407,12 +1405,12 @@ export interface ZipWriterConstructorOptions {
1407
1405
  */
1408
1406
  compressionMethod?: number
1409
1407
  /**
1410
- * Encode the filename and the comment of the entry.
1411
- *
1408
+ * The function called for encoding the filename and the comment of the entry.
1409
+ *
1412
1410
  * @param text The text to encode.
1413
1411
  * @returns The encoded text or `undefined` if the text should be encoded by zip.js.
1414
1412
  */
1415
- encodeText?(text: string): Uint8Array | undefined;
1413
+ encodeText?(text: string): Uint8Array<ArrayBuffer> | undefined;
1416
1414
  }
1417
1415
 
1418
1416
  /**
@@ -1588,7 +1586,7 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
1588
1586
  * @param options The options.
1589
1587
  * @returns A promise resolving to a `Uint8Array` instance.
1590
1588
  */
1591
- getUint8Array(options?: EntryGetDataOptions): Promise<Uint8Array>;
1589
+ getUint8Array(options?: EntryGetDataOptions): Promise<Uint8Array<ArrayBuffer>>;
1592
1590
  /**
1593
1591
  * Retrieves the content of the entry via a `WritableStream` instance
1594
1592
  *
@@ -1638,7 +1636,7 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
1638
1636
  *
1639
1637
  * @param array The `Uint8Array` instance.
1640
1638
  */
1641
- replaceUint8Array(array: Uint8Array): void;
1639
+ replaceUint8Array(array: Uint8Array<ArrayBuffer>): void;
1642
1640
  /**
1643
1641
  * Replaces the content of the entry with a `ReadableStream` instance
1644
1642
  *
@@ -1722,9 +1720,9 @@ export class ZipDirectoryEntry extends ZipEntry {
1722
1720
  */
1723
1721
  addUint8Array(
1724
1722
  name: string,
1725
- array: Uint8Array,
1723
+ array: Uint8Array<ArrayBuffer>,
1726
1724
  options?: ZipWriterAddDataOptions,
1727
- ): ZipFileEntry<Uint8Array, Uint8Array>;
1725
+ ): ZipFileEntry<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
1728
1726
  /**
1729
1727
  * Adds an entry with content fetched from a URL
1730
1728
  *
@@ -1811,7 +1809,7 @@ export class ZipDirectoryEntry extends ZipEntry {
1811
1809
  * @param options The options.
1812
1810
  */
1813
1811
  importUint8Array(
1814
- array: Uint8Array,
1812
+ array: Uint8Array<ArrayBuffer>,
1815
1813
  options?: ZipReaderConstructorOptions,
1816
1814
  ): Promise<[ZipEntry]>;
1817
1815
  /**
@@ -1872,7 +1870,7 @@ export class ZipDirectoryEntry extends ZipEntry {
1872
1870
  */
1873
1871
  exportUint8Array(
1874
1872
  options?: ZipDirectoryEntryExportOptions,
1875
- ): Promise<Uint8Array>;
1873
+ ): Promise<Uint8Array<ArrayBuffer>>;
1876
1874
  /**
1877
1875
  * Creates a zip file via a `WritableStream` instance containing the entry and its descendants
1878
1876
  *
@@ -2098,4 +2096,8 @@ export const ERR_ITERATOR_COMPLETED_TOO_SOON: string;
2098
2096
  /**
2099
2097
  * Undefined uncompressed size error
2100
2098
  */
2101
- export const ERR_UNDEFINED_UNCOMPRESSED_SIZE: string
2099
+ export const ERR_UNDEFINED_UNCOMPRESSED_SIZE: string
2100
+ /**
2101
+ * Writer not initialized error
2102
+ */
2103
+ export const ERR_WRITER_NOT_INITIALIZED: string;
package/index.js CHANGED
@@ -83,6 +83,7 @@ export {
83
83
  ERR_UNSUPPORTED_FORMAT,
84
84
  ERR_UNDEFINED_UNCOMPRESSED_SIZE,
85
85
  ERR_SPLIT_ZIP_FILE,
86
- ERR_ITERATOR_COMPLETED_TOO_SOON
86
+ ERR_ITERATOR_COMPLETED_TOO_SOON,
87
+ ERR_WRITER_NOT_INITIALIZED
87
88
  } from "./lib/zip-fs.js";
88
89
  export { getMimeType, terminateWorkers };