@zip.js/zip.js 2.8.34 → 2.8.36

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.
Files changed (52) hide show
  1. package/README.md +13 -1
  2. package/deno.json +5 -2
  3. package/dist/README.md +3 -1
  4. package/dist/zip-core.js +494 -221
  5. package/dist/zip-core.min.js +1 -1
  6. package/dist/zip-fs-core.js +471 -221
  7. package/dist/zip-fs-core.min.js +1 -1
  8. package/dist/zip-fs-native.js +498 -227
  9. package/dist/zip-fs-native.min.js +1 -1
  10. package/dist/zip-fs.js +500 -229
  11. package/dist/zip-fs.min.js +1 -1
  12. package/dist/zip-legacy.js +496 -223
  13. package/dist/zip-legacy.min.js +1 -1
  14. package/dist/zip-native.js +497 -224
  15. package/dist/zip-native.min.js +1 -1
  16. package/dist/zip-web-worker-native.js +1 -1
  17. package/dist/zip-web-worker.js +1 -1
  18. package/dist/zip.js +499 -226
  19. package/dist/zip.min.js +1 -1
  20. package/index-native.cjs +498 -227
  21. package/index-native.min.js +1 -1
  22. package/index.cjs +500 -229
  23. package/index.d.cts +61 -0
  24. package/index.d.ts +61 -0
  25. package/index.min.js +1 -1
  26. package/lib/core/codec-pool.js +2 -2
  27. package/lib/core/codec-worker.js +6 -2
  28. package/lib/core/configuration.js +22 -1
  29. package/lib/core/io.js +230 -56
  30. package/lib/core/streams/aes-crypto-stream.js +1 -10
  31. package/lib/core/streams/codec-stream.js +37 -16
  32. package/lib/core/streams/zip-entry-stream.js +19 -28
  33. package/lib/core/util/array.js +48 -0
  34. package/lib/core/web-worker-base.js +3 -3
  35. package/lib/core/web-worker-inline-native.js +1 -1
  36. package/lib/core/web-worker-inline-wasm.js +1 -1
  37. package/lib/core/zip-fs.js +2 -3
  38. package/lib/core/zip-reader.js +37 -40
  39. package/lib/core/zip-writer.js +58 -51
  40. package/lib/core/zlib-streams-inline.js +1 -1
  41. package/lib/zip-core-base.js +5 -3
  42. package/lib/zip-fs-native.js +2 -2
  43. package/lib/zip-fs-wasm.js +2 -2
  44. package/lib/zip-legacy.js +2 -2
  45. package/lib/zip-module-native.js +2 -2
  46. package/lib/zip-module-wasm.js +3 -3
  47. package/lib/zip-native.js +2 -2
  48. package/lib/zip-wasm.js +2 -2
  49. package/package.json +3 -3
  50. package/worker-message-property-names.js +3 -0
  51. package/.github/workflows/publish.yml +0 -30
  52. package/reserved-property-names.js +0 -50
package/index.d.cts CHANGED
@@ -197,6 +197,11 @@ declare class TransformStreamLike {
197
197
  */
198
198
  export function configure(configuration: Configuration): void;
199
199
 
200
+ /**
201
+ * Restores the default configuration of zip.js
202
+ */
203
+ export function resetConfiguration(): void;
204
+
200
205
  /**
201
206
  * Represents the configuration passed to {@link configure}.
202
207
  */
@@ -494,6 +499,16 @@ export class Reader<Type> implements Initializable, ReadableReader {
494
499
  * Initializes the instance asynchronously
495
500
  */
496
501
  init?(): Promise<void>;
502
+ /**
503
+ * Creates a `ReadableStream` of the data, optionally restricted to a byte range.
504
+ *
505
+ * The default implementation reads the data with {@link Reader#readUint8Array}. Custom readers can
506
+ * override this method to return a stream provided natively by the underlying data source.
507
+ *
508
+ * @param options The options.
509
+ * @returns The `ReadableStream` instance.
510
+ */
511
+ createReadable(options?: CreateReadableOptions): ReadableStream<Uint8Array>;
497
512
  /**
498
513
  * Reads a chunk of data
499
514
  *
@@ -504,6 +519,27 @@ export class Reader<Type> implements Initializable, ReadableReader {
504
519
  readUint8Array(index: number, length: number): Promise<Uint8Array>;
505
520
  }
506
521
 
522
+ /**
523
+ * Represents the options passed to {@link Reader#createReadable}.
524
+ */
525
+ export interface CreateReadableOptions {
526
+ /**
527
+ * The byte offset of the start of the range to read.
528
+ *
529
+ * @defaultValue 0
530
+ */
531
+ offset?: number;
532
+ /**
533
+ * The size of the range to read in bytes (until the end of the data by default).
534
+ */
535
+ size?: number;
536
+ /**
537
+ * The size in bytes of the chunks emitted by the default implementation (the `chunkSize` value
538
+ * of the global configuration by default).
539
+ */
540
+ chunkSize?: number;
541
+ }
542
+
507
543
  /**
508
544
  * Represents a {@link Reader} instance used to read data provided as a `string`.
509
545
  */
@@ -617,6 +653,23 @@ export interface HttpRangeOptions {
617
653
  * The HTTP headers.
618
654
  */
619
655
  headers?: Iterable<[string, string]> | Map<string, string>;
656
+ /**
657
+ * `true` to throw an {@link ERR_HTTP_RESOURCE_CHANGED} error when the `ETag`, `Last-Modified` or total size headers
658
+ * returned by a range request differ from the ones returned by the first range request, i.e. when the resource has
659
+ * been modified while being read. Headers missing from the responses are ignored, note that `Access-Control-Expose-Headers`
660
+ * must include them when the resource is fetched cross-origin.
661
+ *
662
+ * @defaultValue true
663
+ */
664
+ checkResourceChanges?: boolean;
665
+ /**
666
+ * The maximum size in bytes of the range requests sent to read the data of an entry. The data is
667
+ * read with as many range requests as necessary, each response body being streamed, so that the
668
+ * size of a request never depends on the size of the entry.
669
+ *
670
+ * @defaultValue 16777216
671
+ */
672
+ maximumRangeSize?: number;
620
673
  }
621
674
 
622
675
  /**
@@ -763,6 +816,10 @@ export class SplitDataWriter implements Initializable, WritableWriter {
763
816
  * Initializes the instance asynchronously
764
817
  */
765
818
  init(): Promise<void>;
819
+ /**
820
+ * Closes the disk being written, the next disk being opened when more data is written
821
+ */
822
+ closeDisk(): Promise<void>;
766
823
  /**
767
824
  * Creates the {@link SplitDataWriter} instance
768
825
  *
@@ -2729,6 +2786,10 @@ export const fs: {
2729
2786
  * HTTP range error
2730
2787
  */
2731
2788
  export const ERR_HTTP_RANGE: string;
2789
+ /**
2790
+ * HTTP resource changed while being read error
2791
+ */
2792
+ export const ERR_HTTP_RESOURCE_CHANGED: string;
2732
2793
  /**
2733
2794
  * Zip format error
2734
2795
  */
package/index.d.ts CHANGED
@@ -197,6 +197,11 @@ declare class TransformStreamLike {
197
197
  */
198
198
  export function configure(configuration: Configuration): void;
199
199
 
200
+ /**
201
+ * Restores the default configuration of zip.js
202
+ */
203
+ export function resetConfiguration(): void;
204
+
200
205
  /**
201
206
  * Represents the configuration passed to {@link configure}.
202
207
  */
@@ -494,6 +499,16 @@ export class Reader<Type> implements Initializable, ReadableReader {
494
499
  * Initializes the instance asynchronously
495
500
  */
496
501
  init?(): Promise<void>;
502
+ /**
503
+ * Creates a `ReadableStream` of the data, optionally restricted to a byte range.
504
+ *
505
+ * The default implementation reads the data with {@link Reader#readUint8Array}. Custom readers can
506
+ * override this method to return a stream provided natively by the underlying data source.
507
+ *
508
+ * @param options The options.
509
+ * @returns The `ReadableStream` instance.
510
+ */
511
+ createReadable(options?: CreateReadableOptions): ReadableStream<Uint8Array>;
497
512
  /**
498
513
  * Reads a chunk of data
499
514
  *
@@ -504,6 +519,27 @@ export class Reader<Type> implements Initializable, ReadableReader {
504
519
  readUint8Array(index: number, length: number): Promise<Uint8Array>;
505
520
  }
506
521
 
522
+ /**
523
+ * Represents the options passed to {@link Reader#createReadable}.
524
+ */
525
+ export interface CreateReadableOptions {
526
+ /**
527
+ * The byte offset of the start of the range to read.
528
+ *
529
+ * @defaultValue 0
530
+ */
531
+ offset?: number;
532
+ /**
533
+ * The size of the range to read in bytes (until the end of the data by default).
534
+ */
535
+ size?: number;
536
+ /**
537
+ * The size in bytes of the chunks emitted by the default implementation (the `chunkSize` value
538
+ * of the global configuration by default).
539
+ */
540
+ chunkSize?: number;
541
+ }
542
+
507
543
  /**
508
544
  * Represents a {@link Reader} instance used to read data provided as a `string`.
509
545
  */
@@ -617,6 +653,23 @@ export interface HttpRangeOptions {
617
653
  * The HTTP headers.
618
654
  */
619
655
  headers?: Iterable<[string, string]> | Map<string, string>;
656
+ /**
657
+ * `true` to throw an {@link ERR_HTTP_RESOURCE_CHANGED} error when the `ETag`, `Last-Modified` or total size headers
658
+ * returned by a range request differ from the ones returned by the first range request, i.e. when the resource has
659
+ * been modified while being read. Headers missing from the responses are ignored, note that `Access-Control-Expose-Headers`
660
+ * must include them when the resource is fetched cross-origin.
661
+ *
662
+ * @defaultValue true
663
+ */
664
+ checkResourceChanges?: boolean;
665
+ /**
666
+ * The maximum size in bytes of the range requests sent to read the data of an entry. The data is
667
+ * read with as many range requests as necessary, each response body being streamed, so that the
668
+ * size of a request never depends on the size of the entry.
669
+ *
670
+ * @defaultValue 16777216
671
+ */
672
+ maximumRangeSize?: number;
620
673
  }
621
674
 
622
675
  /**
@@ -763,6 +816,10 @@ export class SplitDataWriter implements Initializable, WritableWriter {
763
816
  * Initializes the instance asynchronously
764
817
  */
765
818
  init(): Promise<void>;
819
+ /**
820
+ * Closes the disk being written, the next disk being opened when more data is written
821
+ */
822
+ closeDisk(): Promise<void>;
766
823
  /**
767
824
  * Creates the {@link SplitDataWriter} instance
768
825
  *
@@ -2729,6 +2786,10 @@ export const fs: {
2729
2786
  * HTTP range error
2730
2787
  */
2731
2788
  export const ERR_HTTP_RANGE: string;
2789
+ /**
2790
+ * HTTP resource changed while being read error
2791
+ */
2792
+ export const ERR_HTTP_RESOURCE_CHANGED: string;
2732
2793
  /**
2733
2794
  * Zip format error
2734
2795
  */