@zip.js/zip.js 2.8.41 → 2.8.42
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/README.md +37 -0
- package/deno.json +6 -2
- package/dist/README.md +10 -1
- package/dist/zip-core-external.js +8180 -0
- package/dist/zip-core-external.min.js +1 -0
- package/dist/zip-core.js +55 -3
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +9196 -0
- package/dist/zip-fs-core-external.min.js +1 -0
- package/dist/zip-fs-core.js +55 -3
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +10833 -0
- package/dist/zip-fs-external.min.js +1 -0
- package/dist/zip-fs-native.js +57 -5
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +131 -24
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +57 -5
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +57 -5
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +131 -24
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +57 -5
- package/index-native.min.js +1 -1
- package/index.cjs +131 -24
- package/index.min.js +1 -1
- package/lib/core/codec-worker.js +4 -1
- package/lib/core/external-assets.js +42 -0
- package/lib/core/streams/zip-entry-stream.js +51 -2
- package/lib/core/streams/zlib-wasm/zlib-streams-loader.js +27 -17
- package/lib/core/streams/zlib-wasm/zlib-streams.js +14 -1
- package/lib/core/web-worker-base.js +6 -2
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/zip-core-external.js +34 -0
- package/lib/zip-fs-core-external.js +30 -0
- package/lib/zip-fs-external.js +30 -0
- package/lib/zip-mime-types.js +29 -0
- package/lib/zip-module-wasm-base.js +64 -0
- package/lib/zip-module-wasm.js +1 -31
- package/package.json +63 -2
- package/worker-message-property-names.js +1 -1
package/README.md
CHANGED
|
@@ -171,6 +171,43 @@ function downloadFile(blob) {
|
|
|
171
171
|
|
|
172
172
|
Run the code on Plunker: https://plnkr.co/edit/4sVljNIpqSUE9HCA?preview
|
|
173
173
|
|
|
174
|
+
## Using external assets
|
|
175
|
+
|
|
176
|
+
By default, zip.js embeds the code of the web worker and the WebAssembly module
|
|
177
|
+
in the library. The `@zip.js/zip.js/external` entry point references them as
|
|
178
|
+
external files instead.
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
import * as zip from "@zip.js/zip.js/external";
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Bundlers like webpack and Vite detect these references. They emit
|
|
185
|
+
`zip-web-worker.js` and `zip-module.wasm` as separate assets and remove
|
|
186
|
+
approximately 45KB of embedded payloads from the main bundle. The worker also
|
|
187
|
+
runs from a real file URL. This avoids `blob:` restrictions on pages and
|
|
188
|
+
browser extensions with a strict Content Security Policy.
|
|
189
|
+
|
|
190
|
+
With Vite, add `@zip.js/zip.js` to `optimizeDeps.exclude` to resolve the assets
|
|
191
|
+
during development. With bundlers which do not rewrite
|
|
192
|
+
`new URL(..., import.meta.url)` expressions, copy the two files next to the
|
|
193
|
+
output bundle.
|
|
194
|
+
|
|
195
|
+
The build `dist/zip-fs-external.min.js` offers the same behavior without a
|
|
196
|
+
bundler. It resolves `zip-web-worker.js` and `zip-module.wasm` relative to its
|
|
197
|
+
own location. The three files must be deployed in the same directory.
|
|
198
|
+
|
|
199
|
+
Smaller compositions of this entry point are also available.
|
|
200
|
+
`@zip.js/zip.js/lib/zip-fs-core-external.js` excludes the MIME type table
|
|
201
|
+
(approximately 23KB), `getMimeType()` then returns
|
|
202
|
+
`"application/octet-stream"`. `@zip.js/zip.js/lib/zip-core-external.js` also
|
|
203
|
+
excludes the filesystem API. Both compositions come with prebuilt bundles in
|
|
204
|
+
the `/dist` directory. The full table remains available from any entry point
|
|
205
|
+
via `@zip.js/zip.js/mime-types`:
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
import { getMimeType } from "@zip.js/zip.js/mime-types";
|
|
209
|
+
```
|
|
210
|
+
|
|
174
211
|
## Tests
|
|
175
212
|
|
|
176
213
|
See https://github.com/gildas-lormeau/zip.js/tree/master/tests/all
|
package/deno.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zip-js/zip-js",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.42",
|
|
4
4
|
"exports": {
|
|
5
|
-
".": "./index.js"
|
|
5
|
+
".": "./index.js",
|
|
6
|
+
"./external": "./lib/zip-fs-external.js",
|
|
7
|
+
"./mime-types": "./lib/zip-mime-types.js",
|
|
8
|
+
"./lib/zip-core-external.js": "./lib/zip-core-external.js",
|
|
9
|
+
"./lib/zip-fs-core-external.js": "./lib/zip-fs-core-external.js"
|
|
6
10
|
},
|
|
7
11
|
"lint": {
|
|
8
12
|
"exclude": [
|
package/dist/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Prebuilt zip.js bundles
|
|
2
2
|
|
|
3
|
-
**Note**: These bundles are not ES module compatible (you cannot `import` them directly). Use `index.js` at the project root or one of the `zip-*.js` files in [`/lib`](../lib) (e.g. `/lib/zip-core.js`) for ESM usage.
|
|
3
|
+
**Note**: These bundles are not ES module compatible (you cannot `import` them directly), except the files suffixed with `-external` which are ES modules. Use `index.js` at the project root or one of the `zip-*.js` files in [`/lib`](../lib) (e.g. `/lib/zip-core.js`) for ESM usage.
|
|
4
4
|
|
|
5
5
|
**Note**: These bundles are standalone and always contain both `ZipReader` and `ZipWriter`, they are not tree-shaken. With a bundler, importing named identifiers from `index.js` already removes the direction you do not use.
|
|
6
6
|
|
|
@@ -10,6 +10,15 @@ Contents:
|
|
|
10
10
|
- `zip-fs.js` / `zip-fs.min.js`: Full `ZipWriter` / `ZipReader` plus virtual file system (`fs`), with embedded Web Worker code and WASM.
|
|
11
11
|
- `zip-core.js` / `zip-core.min.js`: Minimal `ZipWriter` / `ZipReader`.
|
|
12
12
|
- `zip-fs-core.js` / `zip-fs-core.min.js`: Minimal `ZipWriter` / `ZipReader` plus virtual file system (`fs`).
|
|
13
|
+
- `zip-fs-external.js` / `zip-fs-external.min.js`: ES module equivalent of `zip-fs.min.js` which references `zip-web-worker.js` and `zip-module.wasm` as external files instead of embedding them. The worker runs from a real file URL, which avoids `blob:` restrictions on pages and browser extensions with a strict Content Security Policy.
|
|
14
|
+
- `zip-fs-core-external.js` / `zip-fs-core-external.min.js`: Same as `zip-fs-external.min.js` without the MIME type table, `getMimeType()` returns `"application/octet-stream"`.
|
|
15
|
+
- `zip-core-external.js` / `zip-core-external.min.js`: Same as `zip-fs-core-external.min.js` without the virtual file system.
|
|
16
|
+
- `zip-native.js` / `zip-native.min.js`, `zip-fs-native.js` / `zip-fs-native.min.js`: Equivalents of `zip.min.js` and `zip-fs.min.js` embedding a JavaScript implementation of the Compression Streams API instead of the WASM module (see the notes below).
|
|
17
|
+
- `zip-legacy.js` / `zip-legacy.min.js`: Equivalent of `zip.min.js` before the version `2.8` (see the notes below).
|
|
18
|
+
- `zip-web-worker.js`, `zip-web-worker-native.js`: Web Worker scripts embedding the codecs, referenced by the `-external` bundles or passed manually via the `workerURI` option of `configure()`.
|
|
19
|
+
- `zip-module.wasm`: The WASM module (zlib), referenced by the `-external` bundles or passed manually via the `wasmURI` option of `configure()`.
|
|
20
|
+
|
|
21
|
+
The `-external` bundles resolve `zip-web-worker.js` and `zip-module.wasm` relative to their own location, the files must be deployed in the same directory.
|
|
13
22
|
|
|
14
23
|
Online builder:
|
|
15
24
|
|