neozipkit 0.7.2 → 1.0.2
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 +57 -24
- package/WHATS_NEW.md +114 -0
- package/dist/browser/zstd-browser-shim.d.ts +28 -0
- package/dist/browser/zstd-browser-shim.d.ts.map +1 -0
- package/dist/browser/zstd-browser-shim.js +66 -0
- package/dist/browser/zstd-browser-shim.js.map +1 -0
- package/dist/browser-esm/index.js +1786 -41737
- package/dist/browser-esm/index.js.map +4 -4
- package/dist/browser-umd/index.js +1786 -41737
- package/dist/browser-umd/index.js.map +4 -4
- package/dist/browser-umd/index.min.js +3 -21
- package/dist/core/ZipCompress.d.ts +2 -7
- package/dist/core/ZipCompress.d.ts.map +1 -1
- package/dist/core/ZipCompress.js +45 -22
- package/dist/core/ZipCompress.js.map +1 -1
- package/dist/core/ZipDecompress.d.ts +1 -3
- package/dist/core/ZipDecompress.d.ts.map +1 -1
- package/dist/core/ZipDecompress.js +14 -9
- package/dist/core/ZipDecompress.js.map +1 -1
- package/dist/core/encryption/AesCrypto.d.ts +55 -11
- package/dist/core/encryption/AesCrypto.d.ts.map +1 -1
- package/dist/core/encryption/AesCrypto.js +223 -68
- package/dist/core/encryption/AesCrypto.js.map +1 -1
- package/dist/core/encryption/index.d.ts +1 -1
- package/dist/core/encryption/index.d.ts.map +1 -1
- package/dist/core/encryption/index.js +3 -1
- package/dist/core/encryption/index.js.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/node/LegacyZstd.d.ts +67 -0
- package/dist/node/LegacyZstd.d.ts.map +1 -0
- package/dist/node/LegacyZstd.js +209 -0
- package/dist/node/LegacyZstd.js.map +1 -0
- package/dist/node/ZipCompressNode.d.ts +9 -7
- package/dist/node/ZipCompressNode.d.ts.map +1 -1
- package/dist/node/ZipCompressNode.js +85 -46
- package/dist/node/ZipCompressNode.js.map +1 -1
- package/dist/node/ZipDecompressNode.d.ts +7 -3
- package/dist/node/ZipDecompressNode.d.ts.map +1 -1
- package/dist/node/ZipDecompressNode.js +51 -55
- package/dist/node/ZipDecompressNode.js.map +1 -1
- package/dist/node/ZipkitNode.d.ts +14 -0
- package/dist/node/ZipkitNode.d.ts.map +1 -1
- package/dist/node/ZipkitNode.js +130 -39
- package/dist/node/ZipkitNode.js.map +1 -1
- package/dist/node/ZstdNode.d.ts +39 -0
- package/dist/node/ZstdNode.d.ts.map +1 -0
- package/dist/node/ZstdNode.js +171 -0
- package/dist/node/ZstdNode.js.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +11 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +10 -10
- package/src/browser/zstd-browser-shim.ts +76 -0
- package/src/core/ZipCompress.ts +57 -29
- package/src/core/ZipDecompress.ts +21 -10
- package/src/core/encryption/AesCrypto.ts +265 -86
- package/src/core/encryption/index.ts +1 -1
- package/src/core/version.ts +1 -1
- package/src/node/LegacyZstd.ts +270 -0
- package/src/node/ZipCompressNode.ts +107 -55
- package/src/node/ZipDecompressNode.ts +80 -66
- package/src/node/ZipkitNode.ts +150 -40
- package/src/node/ZstdNode.ts +155 -0
- package/src/node/index.ts +10 -0
- package/dist/core/ZstdManager.d.ts +0 -56
- package/dist/core/ZstdManager.d.ts.map +0 -1
- package/dist/core/ZstdManager.js +0 -144
- package/dist/core/ZstdManager.js.map +0 -1
- package/src/core/ZstdManager.ts +0 -165
package/README.md
CHANGED
|
@@ -4,13 +4,9 @@ Advanced ZIP file creation, compression, and encryption library for Node.js and
|
|
|
4
4
|
|
|
5
5
|
**Scope of this package:** NeoZipKit focuses solely on creating and manipulating ZIP files (compression, encryption, extraction). All blockchain-related functionality—timestamping, NFT tokenization, verification, wallet integration, and smart contracts—lives in the sibling **[neozip-blockchain](../neozip-blockchain/)** package within this monorepo. Use that package when you need to link ZIPs to the blockchain.
|
|
6
6
|
|
|
7
|
-
>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> - Breaking changes may occur before the stable release
|
|
11
|
-
> - Use in production with caution and thorough testing
|
|
12
|
-
>
|
|
13
|
-
> We welcome feedback and contributions! Please report issues on [GitHub](https://github.com/NeoWareInc/neozipkit/issues). This package is part of the [neozipkit monorepo](../../README.md).
|
|
7
|
+
> **Stable 1.0:** NeoZipKit **1.0.2** is the first non-beta release. Please report issues on [GitHub](https://github.com/NeoWareInc/neozipkit/issues). This package is part of the [neozipkit monorepo](../../README.md).
|
|
8
|
+
|
|
9
|
+
|
|
14
10
|
|
|
15
11
|
## Features
|
|
16
12
|
|
|
@@ -22,10 +18,12 @@ Advanced ZIP file creation, compression, and encryption library for Node.js and
|
|
|
22
18
|
- **Browser and Node.js compatibility** with clean platform separation
|
|
23
19
|
- **TypeScript support** with full type definitions
|
|
24
20
|
|
|
21
|
+
|
|
22
|
+
|
|
25
23
|
## Installation
|
|
26
24
|
|
|
27
25
|
```bash
|
|
28
|
-
|
|
26
|
+
pnpm add neozipkit
|
|
29
27
|
```
|
|
30
28
|
|
|
31
29
|
Or with npm:
|
|
@@ -34,8 +32,12 @@ Or with npm:
|
|
|
34
32
|
npm install neozipkit
|
|
35
33
|
```
|
|
36
34
|
|
|
35
|
+
|
|
36
|
+
|
|
37
37
|
## Quick Start
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
|
|
39
41
|
### Node.js
|
|
40
42
|
|
|
41
43
|
```typescript
|
|
@@ -50,6 +52,8 @@ await zip.createZipFromFiles(['file1.txt', 'file2.txt'], 'output.zip');
|
|
|
50
52
|
await zip.extractZipFile('archive.zip', './output');
|
|
51
53
|
```
|
|
52
54
|
|
|
55
|
+
|
|
56
|
+
|
|
53
57
|
### Browser
|
|
54
58
|
|
|
55
59
|
```typescript
|
|
@@ -60,32 +64,53 @@ await zip.addFile(file, { level: 6 });
|
|
|
60
64
|
const zipBlob = await zip.createZipBlob();
|
|
61
65
|
```
|
|
62
66
|
|
|
67
|
+
|
|
68
|
+
|
|
63
69
|
### Examples
|
|
64
70
|
|
|
65
|
-
Runnable examples live **only in this repository**—they are **not** shipped in the [npm package](https://www.npmjs.com/package/neozipkit)
|
|
71
|
+
Runnable examples live **only in this repository**—they are **not** shipped in the [npm package](https://www.npmjs.com/package/neozipkit). Browse or clone the repo to use them.
|
|
66
72
|
|
|
67
73
|
On GitHub: [`packages/neozipkit/examples/`](https://github.com/NeoWareInc/neozipkit/tree/main/packages/neozipkit/examples) — see [`examples/README.md`](examples/README.md) for scripts (create/extract/list/copy ZIP, AES demos, encrypted listing) and how to run them from a checkout.
|
|
68
74
|
|
|
69
75
|
```bash
|
|
70
|
-
# From monorepo root, after
|
|
76
|
+
# From monorepo root, after pnpm install
|
|
71
77
|
cd packages/neozipkit
|
|
72
78
|
npx ts-node examples/create-zip.ts
|
|
73
79
|
```
|
|
74
80
|
|
|
81
|
+
|
|
82
|
+
|
|
75
83
|
## Blockchain integration
|
|
76
84
|
|
|
77
85
|
All blockchain code lives in the sibling **[neozip-blockchain](../neozip-blockchain/)** package within this monorepo. For timestamping, NFT tokenization, on-chain verification, wallet management, and OpenTimestamps, install `neozip-blockchain` alongside this package. It depends on `neozipkit` for ZIP handling and adds all blockchain features on top. NeoZipKit itself contains no blockchain, contract, or wallet code.
|
|
78
86
|
|
|
79
87
|
## Package layout
|
|
80
88
|
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
89
|
+
- `neozipkit` – Main entry (core + platform detection)
|
|
90
|
+
- `neozipkit/node` – Node.js-only (ZipkitNode, file I/O, streaming)
|
|
91
|
+
- `neozipkit/browser` – Browser-only (ZipkitBrowser, Blob API)
|
|
92
|
+
- `neozipkit/browser-esm` – Browser ESM bundle (tree-shaking)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## I/O model (aligned with Rust NeoZipKit)
|
|
97
|
+
|
|
98
|
+
**Node / CLI product path:** one streaming (chunked) engine — read → hash → compress/encrypt → write in ~512 KiB buffers. There is no separate full-archive “VM / in-memory” mode. Small entries may still use an in-API buffer fast path inside the same APIs.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
| Surface | Behavior |
|
|
102
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
103
|
+
| `ZipkitNode` create / extract / list | File streaming (`loadZipFile`, `writeZipEntry`, `extractToFile`, …) |
|
|
104
|
+
| Core `Zipkit.loadZip(Buffer)` / browser | Buffer APIs kept for browser and small in-process buffers |
|
|
105
|
+
| Zstd (method 93) | Node native `zlib` Transform streams only (no WASM). Requires Node ≥ 22.15 |
|
|
106
|
+
| Legacy WASM zstd archives | Detect with `detectLegacyWasmZstd` / `ZipkitNode.detectLegacyZstdEntries`; extract truncates +18 zero padding |
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
See also: [docs/ZSTD_USAGE.md](docs/ZSTD_USAGE.md) and the Rust crate notes in `neozip-rust` (`crates/neozipkit/src/limits.rs`).
|
|
85
110
|
|
|
86
111
|
## Publishing (npm)
|
|
87
112
|
|
|
88
|
-
The published tarball includes **`dist/`**, **`src/`** (for `neozipkit/src` conditional exports),
|
|
113
|
+
The published tarball includes **`dist/`**, **`src/`** (for `neozipkit/src` conditional exports), **[`README.md`](README.md)**, and **[`WHATS_NEW.md`](WHATS_NEW.md)**. **`examples/`** and other repo-only folders are excluded—use **`pnpm publish:dry-run`** (`npm publish --dry-run`) to preview the file list.
|
|
89
114
|
|
|
90
115
|
## Development
|
|
91
116
|
|
|
@@ -93,30 +118,32 @@ This package is part of the [neozipkit monorepo](../../README.md). From the **re
|
|
|
93
118
|
|
|
94
119
|
```bash
|
|
95
120
|
# Install all dependencies
|
|
96
|
-
|
|
121
|
+
pnpm install
|
|
97
122
|
|
|
98
123
|
# Build all packages (topological order)
|
|
99
|
-
|
|
124
|
+
pnpm build
|
|
100
125
|
|
|
101
126
|
# Run all unit tests
|
|
102
|
-
|
|
127
|
+
pnpm test:unit
|
|
103
128
|
```
|
|
104
129
|
|
|
105
130
|
To work on this package alone:
|
|
106
131
|
|
|
107
132
|
```bash
|
|
108
133
|
cd packages/neozipkit
|
|
109
|
-
|
|
110
|
-
|
|
134
|
+
pnpm build
|
|
135
|
+
pnpm test
|
|
111
136
|
```
|
|
112
137
|
|
|
113
|
-
See [
|
|
138
|
+
See `[docs/DEV_BUILD.md](docs/DEV_BUILD.md)` for the development build system and the [monorepo README](../../README.md) for version management and release workflow.
|
|
114
139
|
|
|
115
140
|
## API overview
|
|
116
141
|
|
|
142
|
+
|
|
143
|
+
|
|
117
144
|
### ZipkitNode and file handles (Node.js)
|
|
118
145
|
|
|
119
|
-
`ZipkitNode.loadZipFile()` opens the archive with `fs.promises.open()`. You should call
|
|
146
|
+
`ZipkitNode.loadZipFile()` opens the archive with `fs.promises.open()`. You should call `closeFile()` when you are done reading so the `FileHandle` is released promptly. Node deprecates relying on garbage collection to close handles ([DEP0137](https://nodejs.org/api/deprecations.html#DEP0137)).
|
|
120
147
|
|
|
121
148
|
As of **v0.6.1**, `loadZipFile()` automatically **closes any prior read handle** before loading another path on the **same** instance, so reusing a `ZipkitNode` does not leak descriptors. `closeFile()` remains the right way to finish with the current archive.
|
|
122
149
|
|
|
@@ -131,21 +158,27 @@ As of **v0.6.1**, `loadZipFile()` automatically **closes any prior read handle**
|
|
|
131
158
|
- **EncryptionManager** / **ZipCrypto** – Legacy ZIP encryption
|
|
132
159
|
- **AesCrypto** / **EncryptionMethod.AES_256** – AES-256 encryption (WinZip AE-1/AE-2)
|
|
133
160
|
|
|
161
|
+
|
|
162
|
+
|
|
134
163
|
### Compression methods
|
|
135
164
|
|
|
136
165
|
- **STORED (0)** – No compression
|
|
137
166
|
- **DEFLATED (8)** – Deflate (default)
|
|
138
167
|
- **ZSTD (93)** – Zstandard
|
|
139
168
|
|
|
169
|
+
|
|
170
|
+
|
|
140
171
|
### Encryption
|
|
141
172
|
|
|
142
173
|
- **ZIP (Legacy)** – Classic ZIP encryption; use `password` in options (no `encryptionMethod`).
|
|
143
174
|
- **AES-256** – WinZip-compatible (AE-1/AE-2); use `password` and `encryptionMethod: 'aes256'` in compress options. Create and extract supported in Node and browser. See [WHATS_NEW.md](WHATS_NEW.md#060-2025-01-27) for details. For on-disk layout (headers, extra field 0x9901), AE-1 vs AE-2, and how this differs from ZipCrypto and PKWARE strong encryption, see [docs/WINZIP_AES_FORMAT.md](docs/WINZIP_AES_FORMAT.md).
|
|
144
175
|
- **NeoEncrypt (NEO AES-256)** – NeoZip-specific: use `password` and `encryptionMethod: 'neo-aes256'`. The LO/CEN compression method stays a normal ZIP code (e.g. deflate, zstd); encryption is indicated by the encrypted flag plus extra field `0x024E`. Ciphertext layout matches the WinZip AES stream (PBKDF2, CTR, HMAC). Specification: [docs/NEO_CRYPTO_FORMAT.md](docs/NEO_CRYPTO_FORMAT.md).
|
|
145
176
|
|
|
177
|
+
|
|
178
|
+
|
|
146
179
|
## What’s new
|
|
147
180
|
|
|
148
|
-
See [WHATS_NEW.md](WHATS_NEW.md) for release notes.
|
|
181
|
+
See [WHATS_NEW.md](WHATS_NEW.md) for release notes.
|
|
149
182
|
|
|
150
183
|
## Security
|
|
151
184
|
|
|
@@ -153,4 +186,4 @@ See [SECURITY.md](SECURITY.md) for security considerations and best practices.
|
|
|
153
186
|
|
|
154
187
|
## License
|
|
155
188
|
|
|
156
|
-
MIT
|
|
189
|
+
MIT
|
package/WHATS_NEW.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# What’s New in NeoZipKit
|
|
2
|
+
|
|
3
|
+
Release notes for people who install and use **`neozipkit`** from npm. For blockchain timestamping and NFTs, see the sibling package [`neozip-blockchain`](https://www.npmjs.com/package/neozip-blockchain).
|
|
4
|
+
|
|
5
|
+
## 1.0.2 (2026-07-28)
|
|
6
|
+
|
|
7
|
+
### First stable release
|
|
8
|
+
|
|
9
|
+
**1.0.2** is the first non-beta release. From here on, NeoZipKit follows [Semantic Versioning](https://semver.org/): breaking API changes bump the major version.
|
|
10
|
+
|
|
11
|
+
*(Versions `1.0.0` / `1.0.1` were reserved earlier on npm and are not used for this stable line.)*
|
|
12
|
+
|
|
13
|
+
### Zstandard compression (Node.js)
|
|
14
|
+
|
|
15
|
+
Zstd (ZIP method **93**) now uses **Node.js built-in `zlib` streaming**. The previous WASM-based codec is removed.
|
|
16
|
+
|
|
17
|
+
**What this means for you:**
|
|
18
|
+
|
|
19
|
+
- Use Zstd only on **Node.js ≥ 22.15** or **≥ 23.8**.
|
|
20
|
+
- Archives are compatible with other tools that support ZIP method 93 / libzstd.
|
|
21
|
+
- Large files stay memory-efficient (chunked streaming, default buffer ~512 KiB).
|
|
22
|
+
- **Browsers do not support Zstd.** Use Deflate (or Stored) in the browser, or create/extract Zstd archives in Node.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { ZipkitNode } from 'neozipkit/node';
|
|
26
|
+
|
|
27
|
+
const zip = new ZipkitNode();
|
|
28
|
+
await zip.createZipFromFiles(['file1.txt', 'file2.txt'], 'output.zip', {
|
|
29
|
+
useZstd: true,
|
|
30
|
+
level: 6,
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Upgrading from older NeoZipKit Zstd archives:** Older releases wrote frames with a small padding quirk. Extract still works; you can also scan an archive:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const hits = await zip.detectLegacyZstdEntries('old-archive.zip');
|
|
38
|
+
for (const { entry, detection } of hits) {
|
|
39
|
+
if (detection.isLegacyWasm) {
|
|
40
|
+
console.log(entry.filename, detection.confidence, detection.reason);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Streaming-first I/O (Node)
|
|
46
|
+
|
|
47
|
+
Node create/extract/list paths are **streaming** (read → hash → compress/encrypt → write in chunks). There is no separate “load the whole archive into a VM” mode.
|
|
48
|
+
|
|
49
|
+
- Prefer `ZipkitNode` file APIs for disk workflows.
|
|
50
|
+
- Buffer APIs remain for the browser and small in-process use cases.
|
|
51
|
+
|
|
52
|
+
### Compatibility snapshot
|
|
53
|
+
|
|
54
|
+
| Environment | Deflate / Stored | Zstd | AES-256 / NeoEncrypt / ZipCrypto |
|
|
55
|
+
|-------------|------------------|------|-----------------------------------|
|
|
56
|
+
| Node.js (see version above for Zstd) | Yes | Yes | Yes |
|
|
57
|
+
| Browser (ESM / UMD) | Yes | No | Yes |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 0.6.1 (2026-03-30)
|
|
62
|
+
|
|
63
|
+
### More reliable file handle reuse (Node.js)
|
|
64
|
+
|
|
65
|
+
If you call `loadZipFile()` more than once on the same `ZipkitNode` instance, NeoZipKit now **closes the previous read handle** before opening the next file. Failed loads also clean up so handles are not left open. `closeFile()` clears path/size metadata so “closed” means no archive is loaded.
|
|
66
|
+
|
|
67
|
+
This avoids descriptor leaks and Node’s `FileHandle` GC deprecation warning when reusing a `ZipkitNode`.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 0.6.0 (2025-01-27)
|
|
72
|
+
|
|
73
|
+
### AES-256 encryption
|
|
74
|
+
|
|
75
|
+
Full **WinZip-compatible AES-256 (AE-1/AE-2)** support, in addition to legacy ZIP encryption.
|
|
76
|
+
|
|
77
|
+
- Create and extract encrypted ZIPs in **Node and the browser**.
|
|
78
|
+
- Interop with WinZip, 7-Zip, The Unarchiver (`unar`/`lsar`), and other AE-1/AE-2 tools.
|
|
79
|
+
|
|
80
|
+
**Create:**
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const zip = new ZipkitNode();
|
|
84
|
+
await zip.createZipFromFiles(
|
|
85
|
+
['file1.txt', 'file2.txt'],
|
|
86
|
+
'secure.zip',
|
|
87
|
+
{
|
|
88
|
+
password: 'YourStrongPassword',
|
|
89
|
+
encryptionMethod: 'aes256',
|
|
90
|
+
level: 6,
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Extract:**
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
await zip.extractZipFile('secure.zip', './out', {
|
|
99
|
+
password: 'YourStrongPassword',
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**How it works (summary):** PBKDF2-HMAC-SHA1 (1000 iterations), AES-256-CTR (WinZip little-endian counter), HMAC-SHA1 over ciphertext (10-byte auth code per entry).
|
|
104
|
+
|
|
105
|
+
Also in this release:
|
|
106
|
+
|
|
107
|
+
- Encryption bit set correctly on all encrypted local headers (including the last entry).
|
|
108
|
+
- Copy/append helpers for building archives by copying entries then finalizing the central directory.
|
|
109
|
+
|
|
110
|
+
**NeoEncrypt** (NeoZip-specific AES via extra field `0x024E`, normal compression method in headers) is available with `encryptionMethod: 'neo-aes256'`. See the package README for details.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
For password handling and security notes, see the [SECURITY.md](https://github.com/NeoWareInc/neozipkit/blob/main/packages/neozipkit/SECURITY.md) in the repository.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser stub for ZSTD — native zlib streaming is Node-only.
|
|
3
|
+
* Browser builds alias `ZstdNode` to this module so the bad WASM codec is never shipped.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isNativeZstdAvailable(): boolean;
|
|
6
|
+
export declare function mapCompressionLevel(_level: number): number;
|
|
7
|
+
export declare function createCompressTransform(_level?: number): never;
|
|
8
|
+
export declare function createDecompressTransform(): never;
|
|
9
|
+
export declare function compress(_data: Buffer, _level?: number): Promise<Buffer>;
|
|
10
|
+
export declare function decompress(_data: Buffer): Promise<Buffer>;
|
|
11
|
+
export declare function compressSync(_data: Buffer, _level?: number): Buffer;
|
|
12
|
+
export declare function decompressSync(_data: Buffer): Buffer;
|
|
13
|
+
export declare function compressChunks(_readChunk: (position: number, size: number) => Buffer, _totalSize: number, _chunkSize: number, _level: number, _onPlainChunk?: (chunk: Buffer) => void, _onCompressedChunk?: (chunk: Buffer) => void | Promise<void>): Promise<number>;
|
|
14
|
+
export declare function decompressStream(_compressedStream: AsyncIterable<Buffer>): AsyncGenerator<Buffer>;
|
|
15
|
+
export declare const ZstdNode: {
|
|
16
|
+
isNativeZstdAvailable: typeof isNativeZstdAvailable;
|
|
17
|
+
mapCompressionLevel: typeof mapCompressionLevel;
|
|
18
|
+
createCompressTransform: typeof createCompressTransform;
|
|
19
|
+
createDecompressTransform: typeof createDecompressTransform;
|
|
20
|
+
compress: typeof compress;
|
|
21
|
+
decompress: typeof decompress;
|
|
22
|
+
compressSync: typeof compressSync;
|
|
23
|
+
decompressSync: typeof decompressSync;
|
|
24
|
+
compressChunks: typeof compressChunks;
|
|
25
|
+
decompressStream: typeof decompressStream;
|
|
26
|
+
};
|
|
27
|
+
export default ZstdNode;
|
|
28
|
+
//# sourceMappingURL=zstd-browser-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zstd-browser-shim.d.ts","sourceRoot":"","sources":["../../src/browser/zstd-browser-shim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAE9D;AAED,wBAAgB,yBAAyB,IAAI,KAAK,CAEjD;AAED,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9E;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,EACtD,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,EACvC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC3D,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAuB,gBAAgB,CACrC,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,GACvC,cAAc,CAAC,MAAM,CAAC,CAExB;AAED,eAAO,MAAM,QAAQ;;;;;;;;;;;CAWpB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Browser stub for ZSTD — native zlib streaming is Node-only.
|
|
4
|
+
* Browser builds alias `ZstdNode` to this module so the bad WASM codec is never shipped.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ZstdNode = void 0;
|
|
8
|
+
exports.isNativeZstdAvailable = isNativeZstdAvailable;
|
|
9
|
+
exports.mapCompressionLevel = mapCompressionLevel;
|
|
10
|
+
exports.createCompressTransform = createCompressTransform;
|
|
11
|
+
exports.createDecompressTransform = createDecompressTransform;
|
|
12
|
+
exports.compress = compress;
|
|
13
|
+
exports.decompress = decompress;
|
|
14
|
+
exports.compressSync = compressSync;
|
|
15
|
+
exports.decompressSync = decompressSync;
|
|
16
|
+
exports.compressChunks = compressChunks;
|
|
17
|
+
exports.decompressStream = decompressStream;
|
|
18
|
+
const ZSTD_BROWSER_UNSUPPORTED = 'ZSTD requires Node.js with native zlib support (Node.js >= 22.15 or >= 23.8). ' +
|
|
19
|
+
'Browser builds do not include a zstd codec; use Deflate or process zstd archives in Node.';
|
|
20
|
+
function unsupported() {
|
|
21
|
+
throw new Error(ZSTD_BROWSER_UNSUPPORTED);
|
|
22
|
+
}
|
|
23
|
+
function isNativeZstdAvailable() {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
function mapCompressionLevel(_level) {
|
|
27
|
+
return unsupported();
|
|
28
|
+
}
|
|
29
|
+
function createCompressTransform(_level) {
|
|
30
|
+
return unsupported();
|
|
31
|
+
}
|
|
32
|
+
function createDecompressTransform() {
|
|
33
|
+
return unsupported();
|
|
34
|
+
}
|
|
35
|
+
async function compress(_data, _level) {
|
|
36
|
+
return unsupported();
|
|
37
|
+
}
|
|
38
|
+
async function decompress(_data) {
|
|
39
|
+
return unsupported();
|
|
40
|
+
}
|
|
41
|
+
function compressSync(_data, _level) {
|
|
42
|
+
return unsupported();
|
|
43
|
+
}
|
|
44
|
+
function decompressSync(_data) {
|
|
45
|
+
return unsupported();
|
|
46
|
+
}
|
|
47
|
+
async function compressChunks(_readChunk, _totalSize, _chunkSize, _level, _onPlainChunk, _onCompressedChunk) {
|
|
48
|
+
return unsupported();
|
|
49
|
+
}
|
|
50
|
+
async function* decompressStream(_compressedStream) {
|
|
51
|
+
unsupported();
|
|
52
|
+
}
|
|
53
|
+
exports.ZstdNode = {
|
|
54
|
+
isNativeZstdAvailable,
|
|
55
|
+
mapCompressionLevel,
|
|
56
|
+
createCompressTransform,
|
|
57
|
+
createDecompressTransform,
|
|
58
|
+
compress,
|
|
59
|
+
decompress,
|
|
60
|
+
compressSync,
|
|
61
|
+
decompressSync,
|
|
62
|
+
compressChunks,
|
|
63
|
+
decompressStream,
|
|
64
|
+
};
|
|
65
|
+
exports.default = exports.ZstdNode;
|
|
66
|
+
//# sourceMappingURL=zstd-browser-shim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zstd-browser-shim.js","sourceRoot":"","sources":["../../src/browser/zstd-browser-shim.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUH,sDAEC;AAED,kDAEC;AAED,0DAEC;AAED,8DAEC;AAED,4BAEC;AAED,gCAEC;AAED,oCAEC;AAED,wCAEC;AAED,wCASC;AAED,4CAIC;AAvDD,MAAM,wBAAwB,GAC5B,gFAAgF;IAChF,2FAA2F,CAAC;AAE9F,SAAS,WAAW;IAClB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAC5C,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,mBAAmB,CAAC,MAAc;IAChD,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC;AAED,SAAgB,uBAAuB,CAAC,MAAe;IACrD,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC;AAED,SAAgB,yBAAyB;IACvC,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC;AAEM,KAAK,UAAU,QAAQ,CAAC,KAAa,EAAE,MAAe;IAC3D,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,KAAa;IAC5C,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC;AAED,SAAgB,YAAY,CAAC,KAAa,EAAE,MAAe;IACzD,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC;AAED,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,UAAsD,EACtD,UAAkB,EAClB,UAAkB,EAClB,MAAc,EACd,aAAuC,EACvC,kBAA4D;IAE5D,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC;AAEM,KAAK,SAAS,CAAC,CAAC,gBAAgB,CACrC,iBAAwC;IAExC,WAAW,EAAE,CAAC;AAChB,CAAC;AAEY,QAAA,QAAQ,GAAG;IACtB,qBAAqB;IACrB,mBAAmB;IACnB,uBAAuB;IACvB,yBAAyB;IACzB,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,cAAc;IACd,cAAc;IACd,gBAAgB;CACjB,CAAC;AAEF,kBAAe,gBAAQ,CAAC"}
|