jszip
Advanced tools
Comparing version 3.8.0 to 3.9.0
@@ -7,2 +7,8 @@ --- | ||
### v3.9.0 2022-04-04 | ||
- Update types JSZip#loadAsync to accept a promise for data, and remove arguments from `new JSZip()` (see [#752](https://github.com/Stuk/jszip/pull/752)) | ||
- Update types for `compressionOptions` to JSZipFileOptions and JSZipGeneratorOptions (see [#722](https://github.com/Stuk/jszip/pull/722)) | ||
- Add types for `generateInternalStream` (see [#774](https://github.com/Stuk/jszip/pull/774)) | ||
### v3.8.0 2022-03-30 | ||
@@ -9,0 +15,0 @@ |
@@ -18,2 +18,10 @@ // Type definitions for JSZip 3.1 | ||
/** | ||
* Depends on the compression type. With `STORE` (no compression), these options are ignored. With | ||
* `DEFLATE`, you can give the compression level between 1 (best speed) and 9 (best compression). | ||
*/ | ||
interface CompressionOptions { | ||
level: number; | ||
} | ||
interface Metadata { | ||
@@ -60,3 +68,3 @@ percent: number; | ||
type InputFileFormat = InputByType[keyof InputByType]; | ||
type InputFileFormat = InputByType[keyof InputByType] | Promise<InputFileFormat>; | ||
@@ -106,3 +114,10 @@ declare namespace JSZip { | ||
date?: Date; | ||
compression?: string; | ||
/** | ||
* Sets per file compression. The `compressionOptions` parameter depends on the compression type. | ||
*/ | ||
compression?: Compression; | ||
/** | ||
* Sets per file compression level for `DEFLATE` compression. | ||
*/ | ||
compressionOptions?: null | CompressionOptions; | ||
comment?: string; | ||
@@ -130,6 +145,10 @@ /** Set to `true` if (and only if) the input is a "binary string" and has already been prepared with a `0xFF` mask. */ | ||
interface JSZipGeneratorOptions<T extends OutputType = OutputType> { | ||
/** | ||
* Sets compression option for all entries that have not specified their own `compression` option | ||
*/ | ||
compression?: Compression; | ||
compressionOptions?: null | { | ||
level: number; | ||
}; | ||
/** | ||
* Sets compression level for `DEFLATE` compression. | ||
*/ | ||
compressionOptions?: null | CompressionOptions; | ||
type?: T; | ||
@@ -157,2 +176,42 @@ comment?: string; | ||
} | ||
interface JSZipMetadata { | ||
percent: number; | ||
currentFile: string; | ||
} | ||
type DataEventCallback<T> = (dataChunk: T, metadata: JSZipMetadata) => void | ||
type EndEventCallback = () => void | ||
type ErrorEventCallback = (error: Error) => void | ||
interface JSZipStreamHelper<T> { | ||
/** | ||
* Register a listener on an event | ||
*/ | ||
on(event: 'data', callback: DataEventCallback<T>): this; | ||
on(event: 'end', callback: EndEventCallback): this; | ||
on(event: 'error', callback: ErrorEventCallback): this; | ||
/** | ||
* Read the whole stream and call a callback with the complete content | ||
* | ||
* @param updateCallback The function called every time the stream updates | ||
* @return A Promise of the full content | ||
*/ | ||
accumulate(updateCallback?: (metadata: JSZipMetadata) => void): Promise<T>; | ||
/** | ||
* Resume the stream if the stream is paused. Once resumed, the stream starts sending data events again | ||
* | ||
* @return The current StreamHelper object, for chaining | ||
*/ | ||
resume(): this; | ||
/** | ||
* Pause the stream if the stream is running. Once paused, the stream stops sending data events | ||
* | ||
* @return The current StreamHelper object, for chaining | ||
*/ | ||
pause(): this; | ||
} | ||
} | ||
@@ -248,2 +307,10 @@ | ||
/** | ||
* Generates the complete zip file with the internal stream implementation | ||
* | ||
* @param options Optional options for the generator | ||
* @return a StreamHelper | ||
*/ | ||
generateInternalStream<T extends JSZip.OutputType>(options?: JSZip.JSZipGeneratorOptions<T>): JSZip.JSZipStreamHelper<OutputByType[T]>; | ||
/** | ||
* Deserialize zip file asynchronously | ||
@@ -260,12 +327,4 @@ * | ||
*/ | ||
new(): this; | ||
/** | ||
* Create JSZip instance | ||
* If no parameters given an empty zip archive will be created | ||
* | ||
* @param data Serialized zip archive | ||
* @param options Description of the serialized zip archive | ||
*/ | ||
new (data?: InputFileFormat, options?: JSZip.JSZipLoadOptions): this; | ||
(): JSZip; | ||
@@ -272,0 +331,0 @@ |
@@ -48,3 +48,3 @@ 'use strict'; | ||
// a require('package.json').version doesn't work with webpack, see #327 | ||
JSZip.version = "3.8.0"; | ||
JSZip.version = "3.9.0"; | ||
@@ -51,0 +51,0 @@ JSZip.loadAsync = function (content, options) { |
{ | ||
"name": "jszip", | ||
"version": "3.8.0", | ||
"version": "3.9.0", | ||
"author": "Stuart Knightley <stuart@stuartk.com>", | ||
"description": "Create, read and edit .zip files with JavaScript http://stuartk.com/jszip", | ||
"scripts": { | ||
"test": "npm run test-node && npm run test-browser", | ||
"test": "npm run test-node && npm run test-browser && tsc", | ||
"test-node": "qunit --require ./test/helpers/test-utils.js --require ./test/helpers/node-test-utils.js test/asserts/", | ||
@@ -28,4 +28,4 @@ "test-browser": "grunt build && node test/run.js", | ||
"browser": { | ||
"readable-stream": "./lib/readable-stream-browser.js", | ||
"./lib/index": "./dist/jszip.min.js" | ||
"./lib/index": "./dist/jszip.min.js", | ||
"readable-stream": "./lib/readable-stream-browser.js" | ||
}, | ||
@@ -55,3 +55,4 @@ "types": "./index.d.ts", | ||
"qunit": "~2.9.2", | ||
"tmp": "0.0.28" | ||
"tmp": "0.0.28", | ||
"typescript": "^4.6.3" | ||
}, | ||
@@ -58,0 +59,0 @@ "dependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
679865
14457
14