@zip.js/zip.js 2.7.57 → 2.7.59

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/lib/core/io.js CHANGED
@@ -39,6 +39,7 @@ import { getConfiguration } from "./configuration.js";
39
39
  const ERR_HTTP_STATUS = "HTTP error ";
40
40
  const ERR_HTTP_RANGE = "HTTP Range not supported";
41
41
  const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
42
+ const ERR_WRITER_NOT_INITIALIZED = "Writer not initialized";
42
43
 
43
44
  const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
44
45
  const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
@@ -76,8 +77,10 @@ class Reader extends Stream {
76
77
  async pull(controller) {
77
78
  const { offset = 0, size, diskNumberStart } = readable;
78
79
  const { chunkOffset } = this;
79
- controller.enqueue(await readUint8Array(reader, offset + chunkOffset, Math.min(chunkSize, size - chunkOffset), diskNumberStart));
80
- if (chunkOffset + chunkSize > size) {
80
+ const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
81
+ const data = await readUint8Array(reader, offset + chunkOffset, dataSize, diskNumberStart);
82
+ controller.enqueue(data);
83
+ if ((chunkOffset + chunkSize > size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
81
84
  controller.close();
82
85
  } else {
83
86
  this.chunkOffset += chunkSize;
@@ -95,6 +98,9 @@ class Writer extends Stream {
95
98
  const writer = this;
96
99
  const writable = new WritableStream({
97
100
  write(chunk) {
101
+ if (!writer.initialized) {
102
+ throw new Error(ERR_WRITER_NOT_INITIALIZED);
103
+ }
98
104
  return writer.writeUint8Array(chunk);
99
105
  }
100
106
  });
@@ -745,5 +751,6 @@ export {
745
751
  SplitDataReader,
746
752
  SplitDataWriter,
747
753
  ERR_HTTP_RANGE,
748
- ERR_ITERATOR_COMPLETED_TOO_SOON
754
+ ERR_ITERATOR_COMPLETED_TOO_SOON,
755
+ ERR_WRITER_NOT_INITIALIZED
749
756
  };
@@ -1,3 +1,5 @@
1
+ /// <reference types="./../index.d.ts" />
2
+
1
3
  /*
2
4
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
3
5
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
4
4
  "author": "Gildas Lormeau",
5
5
  "license": "BSD-3-Clause",
6
- "version": "2.7.57",
6
+ "version": "2.7.59",
7
7
  "type": "module",
8
8
  "keywords": [
9
9
  "zip",
@@ -37,7 +37,7 @@
37
37
  "build-fflate": "npm i --no-save fflate && npx rollup -c rollup-fflate.config.js",
38
38
  "build-fflate-dev": "npm i --no-save fflate && npx rollup -c rollup-fflate.config.dev.js",
39
39
  "build-doc-api": "npx typedoc",
40
- "build-markdown-docs": "npx typedoc --plugin typedoc-plugin-markdown --out ./docs",
40
+ "build-doc-markdown": "npx typedoc --plugin typedoc-plugin-markdown --out ./docs",
41
41
  "test-deno": "cd ./tests && deno test --allow-read ./deno-runner.js",
42
42
  "test-node": "cd ./tests && node ./node-runner.js",
43
43
  "test-bun": "cd ./tests && bun test ./bun-runner.js",
@@ -49,7 +49,6 @@
49
49
  "types": "./index.d.ts",
50
50
  "exports": {
51
51
  "./package.json": "./package.json",
52
- "./index.min.js": "./index.min.js",
53
52
  ".": {
54
53
  "import": {
55
54
  "types": "./index.d.ts",
@@ -60,13 +59,64 @@
60
59
  "default": "./index.cjs"
61
60
  }
62
61
  },
63
- "./data-uri.js": "./lib/zip-data-uri.js",
64
- "./lib/zip-fs.js": "./lib/zip-fs.js",
65
- "./lib/zip-full.js": "./lib/zip-full.js",
66
- "./lib/zip-no-worker-deflate.js": "./lib/zip-no-worker-deflate.js",
67
- "./lib/zip-no-worker-inflate.js": "./lib/zip-no-worker-inflate.js",
68
- "./lib/zip-no-worker.js": "./lib/zip-no-worker.js",
69
- "./lib/zip.js": "./lib/zip.js"
62
+ "./legacy-5.6": {
63
+ "import": {
64
+ "types": "./index-legacy-5.6.d.ts",
65
+ "default": "./index.js"
66
+ },
67
+ "require": {
68
+ "types": "./index-legacy-5.6.d.ts",
69
+ "default": "./index.cjs"
70
+ }
71
+ },
72
+ "./index.min.js": {
73
+ "import": {
74
+ "types": "./index.d.ts",
75
+ "default": "./index.min.js"
76
+ }
77
+ },
78
+ "./data-uri.js": {
79
+ "import": {
80
+ "types": "./index.d.ts",
81
+ "default": "./lib/zip-data-uri.js"
82
+ }
83
+ },
84
+ "./lib/zip-fs.js": {
85
+ "import": {
86
+ "types": "./lib/zip-fs.d.ts",
87
+ "default": "./lib/zip-fs.js"
88
+ }
89
+ },
90
+ "./lib/zip-full.js": {
91
+ "import": {
92
+ "types": "./lib/zip-full.d.ts",
93
+ "default": "./lib/zip-full.js"
94
+ }
95
+ },
96
+ "./lib/zip-no-worker-deflate.js": {
97
+ "import": {
98
+ "types": "./lib/zip-no-worker-deflate.d.ts",
99
+ "default": "./lib/zip-no-worker-deflate.js"
100
+ }
101
+ },
102
+ "./lib/zip-no-worker-inflate.js": {
103
+ "import": {
104
+ "types": "./lib/zip-no-worker-inflate.d.ts",
105
+ "default": "./lib/zip-no-worker-inflate.js"
106
+ }
107
+ },
108
+ "./lib/zip-no-worker.js": {
109
+ "import": {
110
+ "types": "./lib/zip-no-worker.d.ts",
111
+ "default": "./lib/zip-no-worker.js"
112
+ }
113
+ },
114
+ "./lib/zip.js": {
115
+ "import": {
116
+ "types": "./lib/zip.d.ts",
117
+ "default": "./lib/zip.js"
118
+ }
119
+ }
70
120
  },
71
121
  "repository": {
72
122
  "type": "git",
@@ -77,13 +127,13 @@
77
127
  },
78
128
  "homepage": "https://gildas-lormeau.github.io/zip.js",
79
129
  "devDependencies": {
80
- "@rollup/plugin-node-resolve": "^15.3.0",
81
- "@rollup/plugin-replace": "^6.0.1",
130
+ "@rollup/plugin-node-resolve": "^16.0.1",
131
+ "@rollup/plugin-replace": "^6.0.2",
82
132
  "@rollup/plugin-terser": "^0.4.4",
83
- "eslint": "^9.19.0",
133
+ "eslint": "^9.23.0",
84
134
  "http-server": "^14.1.1",
85
- "rollup": "^4.28.0",
86
- "typedoc": "^0.27.4",
87
- "typedoc-plugin-markdown": "^4.3.2"
135
+ "rollup": "^4.38.0",
136
+ "typedoc": "^0.28.1",
137
+ "typedoc-plugin-markdown": "^4.6.0"
88
138
  }
89
- }
139
+ }