rar-stream 5.7.0 → 5.7.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/index.js +1 -319
- package/package.json +3 -103
- package/LICENSE +0 -21
- package/README.md +0 -283
- package/browser.d.ts +0 -126
- package/browser.js +0 -22
- package/index.d.ts +0 -60
- package/lib/browser.d.ts +0 -114
- package/lib/browser.mjs +0 -214
- package/lib/index.d.ts +0 -119
- package/lib/index.mjs +0 -376
- package/scripts/postinstall.js +0 -88
package/README.md
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<h1>rar-stream</h1>
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
<div align="center"><p>
|
|
6
|
-
<a href="https://crates.io/crates/rar-stream"><img alt="Crates.io" src="https://img.shields.io/crates/v/rar-stream?style=for-the-badge&logo=rust&color=C9CBFF&logoColor=D9E0EE&labelColor=302D41" /></a>
|
|
7
|
-
<a href="https://crates.io/crates/rar-stream"><img alt="Crates.io Downloads" src="https://img.shields.io/crates/d/rar-stream?style=for-the-badge&logo=rust&color=A6E3A1&logoColor=D9E0EE&labelColor=302D41" /></a>
|
|
8
|
-
<a href="https://docs.rs/rar-stream"><img alt="docs.rs" src="https://img.shields.io/docsrs/rar-stream?style=for-the-badge&logo=docs.rs&color=8bd5ca&logoColor=D9E0EE&labelColor=302D41" /></a>
|
|
9
|
-
<a href="https://www.npmjs.com/package/rar-stream"><img alt="npm" src="https://img.shields.io/npm/v/rar-stream?style=for-the-badge&logo=npm&color=F5A97F&logoColor=D9E0EE&labelColor=302D41" /></a>
|
|
10
|
-
<a href="https://www.npmjs.com/package/rar-stream"><img alt="npm Downloads" src="https://img.shields.io/npm/dm/rar-stream?style=for-the-badge&logo=npm&color=F5E0DC&logoColor=D9E0EE&labelColor=302D41" /></a>
|
|
11
|
-
<a href="https://github.com/doom-fish/rar-stream#license"><img alt="License" src="https://img.shields.io/crates/l/rar-stream?style=for-the-badge&logo=apache&color=ee999f&logoColor=D9E0EE&labelColor=302D41" /></a>
|
|
12
|
-
<a href="https://github.com/doom-fish/rar-stream/actions"><img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/doom-fish/rar-stream/ci.yml?branch=main&style=for-the-badge&logo=github&color=c69ff5&logoColor=D9E0EE&labelColor=302D41" /></a>
|
|
13
|
-
<a href="https://codecov.io/gh/doom-fish/rar-stream"><img alt="Coverage" src="https://img.shields.io/codecov/c/github/doom-fish/rar-stream?style=for-the-badge&logo=codecov&color=F0C6C6&logoColor=D9E0EE&labelColor=302D41" /></a>
|
|
14
|
-
</p></div>
|
|
15
|
-
|
|
16
|
-
> Fast RAR archive streaming for Rust, Node.js, and browsers. Zero dependencies core.
|
|
17
|
-
|
|
18
|
-
## 📑 Table of Contents
|
|
19
|
-
|
|
20
|
-
- [Installation](#installation)
|
|
21
|
-
- [Quick Start](#quick-start)
|
|
22
|
-
- [Examples](#examples)
|
|
23
|
-
- [API](#api)
|
|
24
|
-
- [Feature Flags](#feature-flags)
|
|
25
|
-
- [Format Support](#format-support)
|
|
26
|
-
- [Performance](#performance)
|
|
27
|
-
- [Migrating from v3.x](#migrating-from-v3x)
|
|
28
|
-
- [Architecture](ARCHITECTURE.md)
|
|
29
|
-
- [Contributing](CONTRIBUTING.md)
|
|
30
|
-
- [Security](SECURITY.md)
|
|
31
|
-
- [Changelog](CHANGELOG.md)
|
|
32
|
-
- [License](#license)
|
|
33
|
-
|
|
34
|
-
## Installation
|
|
35
|
-
|
|
36
|
-
### Node.js
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install rar-stream
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Native binaries are automatically downloaded from [GitHub Releases](https://github.com/doom-fish/rar-stream/releases) during install. Supported platforms: Linux (x64, arm64), macOS (x64, arm64), Windows (x64).
|
|
43
|
-
|
|
44
|
-
### Rust
|
|
45
|
-
|
|
46
|
-
```toml
|
|
47
|
-
[dependencies]
|
|
48
|
-
rar-stream = { version = "5", features = ["async", "crypto"] }
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Browser (WASM)
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
wasm-pack build --target web --features "wasm,crypto" --no-default-features
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Quick Start
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
import { LocalFileMedia, RarFilesPackage } from 'rar-stream';
|
|
61
|
-
|
|
62
|
-
const media = new LocalFileMedia('./archive.rar');
|
|
63
|
-
const pkg = new RarFilesPackage([media]);
|
|
64
|
-
const files = await pkg.parse();
|
|
65
|
-
|
|
66
|
-
for (const file of files) {
|
|
67
|
-
console.log(`${file.name}: ${file.length} bytes`);
|
|
68
|
-
const buffer = await file.readToEnd();
|
|
69
|
-
// or stream: file.createReadStream().pipe(process.stdout);
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Examples
|
|
74
|
-
|
|
75
|
-
Runnable examples in [`examples/`](./examples):
|
|
76
|
-
|
|
77
|
-
| Example | Run | Description |
|
|
78
|
-
|---------|-----|-------------|
|
|
79
|
-
| [basic.ts](./examples/basic.ts) | `npx tsx examples/basic.ts <path>` | Parse RAR, list files, read content |
|
|
80
|
-
| [http-stream.ts](./examples/http-stream.ts) | `npx tsx examples/http-stream.ts <rar>` | HTTP video server with range requests |
|
|
81
|
-
| [extract.rs](./examples/extract.rs) | `cargo run --release --example extract --features async -- archive.rar out/` | Extract files to disk |
|
|
82
|
-
| [browser.html](./examples/browser.html) | Open in browser (after `npm run build:wasm`) | WASM decompression demo |
|
|
83
|
-
| [profile.rs](./examples/profile.rs) | `cargo run --release --example profile` | Benchmark decompression loop |
|
|
84
|
-
| [benchmark_sizes.rs](./examples/benchmark_sizes.rs) | `cargo run --release --example benchmark_sizes` | Benchmark across file sizes |
|
|
85
|
-
|
|
86
|
-
## API
|
|
87
|
-
|
|
88
|
-
### Classes
|
|
89
|
-
|
|
90
|
-
| Class | Description |
|
|
91
|
-
|-------|-------------|
|
|
92
|
-
| `LocalFileMedia(path)` | Wraps a local file for reading |
|
|
93
|
-
| `RarFilesPackage(files)` | Parses single or multi-volume RAR archives |
|
|
94
|
-
| `InnerFile` | A file inside the archive |
|
|
95
|
-
|
|
96
|
-
### InnerFile
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
class InnerFile {
|
|
100
|
-
readonly name: string; // Full path inside archive
|
|
101
|
-
readonly length: number; // Uncompressed size in bytes
|
|
102
|
-
readToEnd(): Promise<Buffer>;
|
|
103
|
-
createReadStream(opts?: { start?: number; end?: number }): Readable;
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### FileMedia Interface
|
|
108
|
-
|
|
109
|
-
Custom data sources (WebTorrent, S3, HTTP) must implement:
|
|
110
|
-
|
|
111
|
-
```typescript
|
|
112
|
-
interface FileMedia {
|
|
113
|
-
readonly name: string;
|
|
114
|
-
readonly length: number;
|
|
115
|
-
createReadStream(opts: { start: number; end: number }): Readable;
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Utility Functions
|
|
120
|
-
|
|
121
|
-
| Function | Description |
|
|
122
|
-
|----------|-------------|
|
|
123
|
-
| `isRarArchive(buffer)` | Check if buffer starts with RAR signature |
|
|
124
|
-
| `parseRarHeader(buffer)` | Parse RAR4 header from buffer (~300 bytes) |
|
|
125
|
-
| `streamToBuffer(stream)` | Convert Readable to Buffer |
|
|
126
|
-
| `createFileMedia(source)` | Wrap any `{ createReadStream }` as FileMedia |
|
|
127
|
-
|
|
128
|
-
### Rust API
|
|
129
|
-
|
|
130
|
-
#### In-Memory (no features required)
|
|
131
|
-
|
|
132
|
-
```rust
|
|
133
|
-
use rar_stream::{MemoryArchive, is_rar_archive, detect_version};
|
|
134
|
-
|
|
135
|
-
// Check format
|
|
136
|
-
let data = std::fs::read("archive.rar")?;
|
|
137
|
-
assert!(is_rar_archive(&data));
|
|
138
|
-
|
|
139
|
-
// Parse and extract
|
|
140
|
-
let archive = MemoryArchive::new(&data)?;
|
|
141
|
-
let info = archive.archive_info();
|
|
142
|
-
println!("Format: {:?}, solid: {}", info.version, info.is_solid);
|
|
143
|
-
|
|
144
|
-
for entry in archive.entries() {
|
|
145
|
-
println!("{}: {} bytes", entry.name, entry.unpacked_size);
|
|
146
|
-
}
|
|
147
|
-
let content = archive.extract(0)?;
|
|
148
|
-
let readme = archive.extract_by_name("README.md")?;
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
#### Async (requires `async` feature)
|
|
152
|
-
|
|
153
|
-
```rust
|
|
154
|
-
use rar_stream::{RarFilesPackage, ParseOptions, LocalFileMedia, FileMedia};
|
|
155
|
-
use std::sync::Arc;
|
|
156
|
-
|
|
157
|
-
let file: Arc<dyn FileMedia> = Arc::new(LocalFileMedia::new("archive.rar")?);
|
|
158
|
-
let package = RarFilesPackage::new(vec![file]);
|
|
159
|
-
let files = package.parse(ParseOptions::default()).await?;
|
|
160
|
-
let content = files[0].read_to_end().await?;
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Feature Flags
|
|
164
|
-
|
|
165
|
-
### Rust (Cargo)
|
|
166
|
-
|
|
167
|
-
| Feature | Default | Description |
|
|
168
|
-
|---------|---------|-------------|
|
|
169
|
-
| `async` | No | Async archive reading via tokio (`RarFilesPackage`, `InnerFile`) |
|
|
170
|
-
| `crypto` | No | AES encryption (RAR4: AES-128, RAR5: AES-256) |
|
|
171
|
-
| `parallel` | No | Multi-threaded RAR5 decompression (rayon) |
|
|
172
|
-
| `napi` | No | Node.js bindings (implies `async` + `parallel`) |
|
|
173
|
-
| `wasm` | No | Browser WASM bindings |
|
|
174
|
-
|
|
175
|
-
### Platform Support
|
|
176
|
-
|
|
177
|
-
| Capability | Rust | Node.js (NAPI) | Browser (WASM) |
|
|
178
|
-
|-----------|------|----------------|----------------|
|
|
179
|
-
| Parse RAR4/RAR5 | ✅ | ✅ | ✅ |
|
|
180
|
-
| Decompress | ✅ | ✅ | ✅ |
|
|
181
|
-
| Encryption | ✅ (`crypto`) | ✅ (always on) | ✅ (`crypto`) |
|
|
182
|
-
| Async I/O | ✅ (`async`) | ✅ | — |
|
|
183
|
-
| Parallel decompress | ✅ (`parallel`) | ✅ (always on) | — |
|
|
184
|
-
| Multi-volume | ✅ | ✅ | ✅ |
|
|
185
|
-
| Streaming reads | ✅ | ✅ | — |
|
|
186
|
-
|
|
187
|
-
## Format Support
|
|
188
|
-
|
|
189
|
-
| Feature | RAR4 | RAR5 |
|
|
190
|
-
|---------|------|------|
|
|
191
|
-
| Stored (no compression) | Yes | Yes |
|
|
192
|
-
| LZSS (Huffman + LZ77) | Yes | Yes |
|
|
193
|
-
| PPMd | Yes | -- |
|
|
194
|
-
| Solid archives | Yes | Yes |
|
|
195
|
-
| SFX (self-extracting) | Yes | Yes |
|
|
196
|
-
| E8/E8E9 filters (x86) | Yes | Yes |
|
|
197
|
-
| Delta filter | Yes | Yes |
|
|
198
|
-
| ARM filter | -- | Yes |
|
|
199
|
-
| Itanium/RGB/Audio filters | Yes | -- |
|
|
200
|
-
| Encrypted files (AES) | Yes | Yes |
|
|
201
|
-
| Encrypted headers | -- | Yes |
|
|
202
|
-
| Multi-volume | Yes | Yes |
|
|
203
|
-
|
|
204
|
-
Encryption requires the `crypto` feature (always enabled in npm builds).
|
|
205
|
-
|
|
206
|
-
## Performance
|
|
207
|
-
|
|
208
|
-
Benchmarked against the official C `unrar` (v7.0) using `cargo bench`.
|
|
209
|
-
|
|
210
|
-
Core decompression (3 KB files, single-threaded):
|
|
211
|
-
|
|
212
|
-
| Method | rar-stream | unrar | Speedup |
|
|
213
|
-
|--------|-----------|-------|---------|
|
|
214
|
-
| LZSS | 8 µs | 92 µs | 11x |
|
|
215
|
-
| PPMd | 107 µs | 177 µs | 1.7x |
|
|
216
|
-
| Stored | 54 ns | 123 µs | 2170x |
|
|
217
|
-
|
|
218
|
-
Single-threaded decompression vs unrar across data types (200 MB, method 5, 128 MB dict):
|
|
219
|
-
|
|
220
|
-
| Data type | rar-stream | unrar | Ratio |
|
|
221
|
-
|-----------|-----------|-------|-------|
|
|
222
|
-
| Text | 631 MiB/s | 535 MiB/s | **1.18x faster** |
|
|
223
|
-
| Binary | 424 MiB/s | 439 MiB/s | 0.97x |
|
|
224
|
-
| ISO (x86) | 297 MiB/s | 440 MiB/s | 0.67x |
|
|
225
|
-
|
|
226
|
-
With the `parallel` feature (enabled by default in npm), rar-stream's pipeline beats unrar across all 24 benchmark scenarios. Best case: 1.9x faster.
|
|
227
|
-
|
|
228
|
-
| Archive | Size | Pipeline | unrar | Ratio |
|
|
229
|
-
|---------|------|----------|-------|-------|
|
|
230
|
-
| Binary (ISO) | 200 MB | 289ms | 420ms | 0.69x |
|
|
231
|
-
| Text | 200 MB | 119ms | 197ms | 0.61x |
|
|
232
|
-
| Mixed | 200 MB | 307ms | 524ms | 0.59x |
|
|
233
|
-
| Binary | 500 MB | 683ms | 1088ms | 0.63x |
|
|
234
|
-
| Text | 500 MB | 357ms | 590ms | 0.61x |
|
|
235
|
-
| Mixed | 1 GB | 1671ms | 2407ms | 0.69x |
|
|
236
|
-
|
|
237
|
-
<details>
|
|
238
|
-
<summary>Full benchmark matrix (24 scenarios)</summary>
|
|
239
|
-
|
|
240
|
-
```
|
|
241
|
-
Archive Single Pipeline Unrar Pipe/Unrar
|
|
242
|
-
----------------------------------------------------------------
|
|
243
|
-
bin-500_m3_32m 1187ms 736ms 1122ms 0.66x
|
|
244
|
-
bin-500_m5_128m 1122ms 683ms 1088ms 0.63x
|
|
245
|
-
bin-500_m5_32m 1183ms 711ms 1119ms 0.64x
|
|
246
|
-
bin-500_m5_4m 1311ms 765ms 1206ms 0.63x
|
|
247
|
-
iso-200_m3_32m 693ms 289ms 420ms 0.69x
|
|
248
|
-
iso-200_m5_128m 694ms 296ms 455ms 0.65x
|
|
249
|
-
iso-200_m5_32m 697ms 290ms 418ms 0.69x
|
|
250
|
-
iso-200_m5_4m 694ms 293ms 426ms 0.69x
|
|
251
|
-
mixed-1g_m3_32m 2690ms 1818ms 2603ms 0.70x
|
|
252
|
-
mixed-1g_m5_128m 2909ms 1916ms 2852ms 0.67x
|
|
253
|
-
mixed-1g_m5_32m 2699ms 1794ms 2598ms 0.69x
|
|
254
|
-
mixed-1g_m5_4m 2611ms 1671ms 2407ms 0.69x
|
|
255
|
-
mixed-200_m3_32m 465ms 344ms 537ms 0.64x
|
|
256
|
-
mixed-200_m5_128m 413ms 307ms 524ms 0.59x
|
|
257
|
-
mixed-200_m5_32m 463ms 338ms 527ms 0.64x
|
|
258
|
-
mixed-200_m5_4m 487ms 350ms 531ms 0.66x
|
|
259
|
-
text-200_m3_32m 199ms 120ms 200ms 0.60x
|
|
260
|
-
text-200_m5_128m 196ms 119ms 230ms 0.52x
|
|
261
|
-
text-200_m5_32m 197ms 120ms 197ms 0.61x
|
|
262
|
-
text-200_m5_4m 218ms 127ms 199ms 0.64x
|
|
263
|
-
text-500_m3_32m 583ms 362ms 591ms 0.61x
|
|
264
|
-
text-500_m5_128m 572ms 365ms 628ms 0.58x
|
|
265
|
-
text-500_m5_32m 567ms 357ms 590ms 0.61x
|
|
266
|
-
text-500_m5_4m 623ms 382ms 620ms 0.62x
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
Ratio < 1.0 = rar-stream is faster.
|
|
270
|
-
|
|
271
|
-
</details>
|
|
272
|
-
|
|
273
|
-
## Migrating from v3.x
|
|
274
|
-
|
|
275
|
-
Drop-in replacement. Same API, native Rust implementation. Requires Node.js 18+.
|
|
276
|
-
|
|
277
|
-
## Contributing
|
|
278
|
-
|
|
279
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, conventions, and the PR process.
|
|
280
|
-
|
|
281
|
-
## License
|
|
282
|
-
|
|
283
|
-
MIT
|
package/browser.d.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* rar-stream browser type definitions
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export { InitInput, InitOutput, SyncInitInput } from './pkg/rar_stream.d.ts';
|
|
6
|
-
|
|
7
|
-
/** Initialize WASM module (must be called before using other functions) */
|
|
8
|
-
export { default as init } from './pkg/rar_stream.js';
|
|
9
|
-
|
|
10
|
-
/** Initialize WASM module synchronously */
|
|
11
|
-
export { initSync } from './pkg/rar_stream.js';
|
|
12
|
-
|
|
13
|
-
/** Check if data is a RAR archive */
|
|
14
|
-
export function isRarArchive(data: Uint8Array): boolean;
|
|
15
|
-
|
|
16
|
-
/** Get RAR version (15 for RAR4, 50 for RAR5, 0 if not RAR) */
|
|
17
|
-
export function getRarVersion(data: Uint8Array): number;
|
|
18
|
-
|
|
19
|
-
/** Extract the first file from a RAR archive buffer */
|
|
20
|
-
export function extractFile(archive: Uint8Array): {
|
|
21
|
-
name: string;
|
|
22
|
-
data: Uint8Array;
|
|
23
|
-
length: number;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** Parse RAR4 header information (returns first file's header) */
|
|
27
|
-
export function parseRarHeader(data: Uint8Array): {
|
|
28
|
-
name: string;
|
|
29
|
-
packedSize: number;
|
|
30
|
-
unpackedSize: number;
|
|
31
|
-
method: number;
|
|
32
|
-
isCompressed: boolean;
|
|
33
|
-
dataOffset: number;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/** Parse RAR5 header information (returns first file's header) */
|
|
37
|
-
export function parseRar5Header(data: Uint8Array): {
|
|
38
|
-
name: string;
|
|
39
|
-
packedSize: number;
|
|
40
|
-
unpackedSize: number;
|
|
41
|
-
method: number;
|
|
42
|
-
dictSizeLog: number;
|
|
43
|
-
isCompressed: boolean;
|
|
44
|
-
isDirectory: boolean;
|
|
45
|
-
dataOffset: number;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/** Parse all RAR4 file headers from a buffer */
|
|
49
|
-
export function parseRarHeaders(data: Uint8Array): Array<{
|
|
50
|
-
name: string;
|
|
51
|
-
packedSize: number;
|
|
52
|
-
unpackedSize: number;
|
|
53
|
-
method: number;
|
|
54
|
-
isCompressed: boolean;
|
|
55
|
-
dataOffset: number;
|
|
56
|
-
}>;
|
|
57
|
-
|
|
58
|
-
/** Parse all RAR5 file headers from a buffer */
|
|
59
|
-
export function parseRar5Headers(data: Uint8Array): Array<{
|
|
60
|
-
name: string;
|
|
61
|
-
packedSize: number;
|
|
62
|
-
unpackedSize: number;
|
|
63
|
-
method: number;
|
|
64
|
-
dictSizeLog: number;
|
|
65
|
-
isCompressed: boolean;
|
|
66
|
-
isDirectory: boolean;
|
|
67
|
-
dataOffset: number;
|
|
68
|
-
}>;
|
|
69
|
-
|
|
70
|
-
/** High-level RAR archive reader */
|
|
71
|
-
export class RarFilesPackage {
|
|
72
|
-
constructor(data: Uint8Array);
|
|
73
|
-
free(): void;
|
|
74
|
-
[Symbol.dispose](): void;
|
|
75
|
-
readonly length: number;
|
|
76
|
-
parse(): Array<{
|
|
77
|
-
name: string;
|
|
78
|
-
length: number;
|
|
79
|
-
packedSize: number;
|
|
80
|
-
isDirectory: boolean;
|
|
81
|
-
}>;
|
|
82
|
-
extract(index: number): { name: string; data: Uint8Array; length: number };
|
|
83
|
-
extractAll(): Array<{ name: string; data: Uint8Array; length: number }>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** RAR4 decompressor */
|
|
87
|
-
export class RarDecoder {
|
|
88
|
-
constructor(unpacked_size: bigint);
|
|
89
|
-
free(): void;
|
|
90
|
-
[Symbol.dispose](): void;
|
|
91
|
-
bytes_written(): bigint;
|
|
92
|
-
decompress(data: Uint8Array): Uint8Array;
|
|
93
|
-
is_complete(): boolean;
|
|
94
|
-
reset(): void;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** RAR5 decompressor */
|
|
98
|
-
export class Rar5Decoder {
|
|
99
|
-
constructor(unpacked_size: bigint, dict_size_log: number, method: number, is_solid: boolean);
|
|
100
|
-
free(): void;
|
|
101
|
-
[Symbol.dispose](): void;
|
|
102
|
-
decompress(data: Uint8Array): Uint8Array;
|
|
103
|
-
reset(): void;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** RAR5 AES-256 crypto helper */
|
|
107
|
-
export class Rar5Crypto {
|
|
108
|
-
constructor(password: string, salt: Uint8Array, lg2_count: number);
|
|
109
|
-
free(): void;
|
|
110
|
-
[Symbol.dispose](): void;
|
|
111
|
-
decrypt(iv: Uint8Array, data: Uint8Array): Uint8Array;
|
|
112
|
-
verify_password(check_value: Uint8Array): boolean;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Snake_case aliases for compatibility
|
|
116
|
-
export { isRarArchive as is_rar_archive };
|
|
117
|
-
export { getRarVersion as get_rar_version };
|
|
118
|
-
export { extractFile as extract_file };
|
|
119
|
-
export { parseRarHeader as parse_rar_header };
|
|
120
|
-
export { parseRar5Header as parse_rar5_header };
|
|
121
|
-
export { parseRarHeaders as parse_rar_headers };
|
|
122
|
-
export { parseRar5Headers as parse_rar5_headers };
|
|
123
|
-
export { RarDecoder as WasmRarDecoder };
|
|
124
|
-
export { Rar5Decoder as WasmRar5Decoder };
|
|
125
|
-
export { Rar5Crypto as WasmRar5Crypto };
|
|
126
|
-
export { RarFilesPackage as WasmRarArchive };
|
package/browser.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* rar-stream browser entry point
|
|
3
|
-
* Re-exports WASM bindings with unified API
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Re-export all WASM bindings
|
|
7
|
-
export {
|
|
8
|
-
default as init,
|
|
9
|
-
initSync,
|
|
10
|
-
is_rar_archive as isRarArchive,
|
|
11
|
-
get_rar_version as getRarVersion,
|
|
12
|
-
parse_rar_header as parseRarHeader,
|
|
13
|
-
WasmRarDecoder as RarDecoder,
|
|
14
|
-
} from './pkg/rar_stream.js';
|
|
15
|
-
|
|
16
|
-
// Also export snake_case versions for compatibility
|
|
17
|
-
export {
|
|
18
|
-
is_rar_archive,
|
|
19
|
-
get_rar_version,
|
|
20
|
-
parse_rar_header,
|
|
21
|
-
WasmRarDecoder,
|
|
22
|
-
} from './pkg/rar_stream.js';
|
package/index.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
/** Read interval options. */
|
|
7
|
-
export interface ReadIntervalJs {
|
|
8
|
-
start: number
|
|
9
|
-
end: number
|
|
10
|
-
}
|
|
11
|
-
/** Parse options for filtering results. */
|
|
12
|
-
export interface ParseOptionsJs {
|
|
13
|
-
maxFiles?: number
|
|
14
|
-
/**
|
|
15
|
-
* Prefetch buffer size for header parsing in bytes (default: 32768).
|
|
16
|
-
* Increase for archives with many files over slow connections.
|
|
17
|
-
*/
|
|
18
|
-
headerPrefetchSize?: number
|
|
19
|
-
}
|
|
20
|
-
/** Parsed file info from RAR header. */
|
|
21
|
-
export interface RarFileInfo {
|
|
22
|
-
name: string
|
|
23
|
-
packedSize: number
|
|
24
|
-
unpackedSize: number
|
|
25
|
-
method: number
|
|
26
|
-
continuesInNext: boolean
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Parse RAR file header from a buffer.
|
|
30
|
-
* This can be used to detect RAR archives and get inner file info
|
|
31
|
-
* without downloading the entire archive.
|
|
32
|
-
*
|
|
33
|
-
* The buffer should contain at least the first ~300 bytes of a .rar file.
|
|
34
|
-
*/
|
|
35
|
-
export declare function parseRarHeader(buffer: Buffer): RarFileInfo | null
|
|
36
|
-
/** Check if a buffer starts with a RAR signature (RAR4 or RAR5). */
|
|
37
|
-
export declare function isRarArchive(buffer: Buffer): boolean
|
|
38
|
-
/** LocalFileMedia - reads from local filesystem. */
|
|
39
|
-
export declare class LocalFileMedia {
|
|
40
|
-
constructor(path: string)
|
|
41
|
-
get name(): string
|
|
42
|
-
get length(): number
|
|
43
|
-
createReadStream(opts: ReadIntervalJs): Promise<Buffer>
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* InnerFile - a file inside the RAR archive.
|
|
47
|
-
* Note: We use the name "NapiInnerFile" in Rust to avoid conflict with RustInnerFile,
|
|
48
|
-
* but it's exported to JS as "InnerFile".
|
|
49
|
-
*/
|
|
50
|
-
export declare class InnerFile {
|
|
51
|
-
get name(): string
|
|
52
|
-
get length(): number
|
|
53
|
-
createReadStream(opts: ReadIntervalJs): Promise<Buffer>
|
|
54
|
-
readToEnd(): Promise<Buffer>
|
|
55
|
-
}
|
|
56
|
-
/** RarFilesPackage - parses multi-volume RAR archives. */
|
|
57
|
-
export declare class RarFilesPackage {
|
|
58
|
-
constructor(files: Array<LocalFileMedia>)
|
|
59
|
-
parse(opts?: ParseOptionsJs | undefined | null): Promise<Array<InnerFile>>
|
|
60
|
-
}
|
package/lib/browser.d.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* rar-stream browser entry point with Web Streams API support
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// WASM init
|
|
6
|
-
/**
|
|
7
|
-
* Initialize the WASM module. Safe to call multiple times.
|
|
8
|
-
* Automatically called by all async helper functions.
|
|
9
|
-
*/
|
|
10
|
-
export declare function init(wasmUrl?: string | URL | Request | Response | BufferSource | WebAssembly.Module): Promise<void>;
|
|
11
|
-
export declare function initSync(module: { module: BufferSource | WebAssembly.Module } | BufferSource | WebAssembly.Module): void;
|
|
12
|
-
|
|
13
|
-
// Auto-init async helpers (call init() automatically)
|
|
14
|
-
export declare function isRarArchive(data: Uint8Array): Promise<boolean>;
|
|
15
|
-
export declare function getRarVersion(data: Uint8Array): Promise<number>;
|
|
16
|
-
export declare function parseRarHeader(data: Uint8Array): Promise<any>;
|
|
17
|
-
export declare function parseRarHeaders(data: Uint8Array): Promise<any[]>;
|
|
18
|
-
export declare function parseRar5Header(data: Uint8Array): Promise<any>;
|
|
19
|
-
export declare function parseRar5Headers(data: Uint8Array): Promise<any[]>;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Extract the first file from a RAR archive buffer.
|
|
23
|
-
* Auto-detects RAR4/RAR5, parses headers, and decompresses in one call.
|
|
24
|
-
*/
|
|
25
|
-
export declare function extractFile(data: Uint8Array): Promise<{name: string, data: Uint8Array, length: number}>;
|
|
26
|
-
|
|
27
|
-
// Classes (require init() before construction)
|
|
28
|
-
export declare class RarFilesPackage {
|
|
29
|
-
constructor(data: Uint8Array);
|
|
30
|
-
readonly length: number;
|
|
31
|
-
parse(): Array<{name: string, length: number, packedSize: number, isDirectory: boolean}>;
|
|
32
|
-
extract(index: number): {name: string, data: Uint8Array, length: number};
|
|
33
|
-
extractAll(): Array<{name: string, data: Uint8Array, length: number}>;
|
|
34
|
-
free(): void;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export declare class RarDecoder {
|
|
38
|
-
constructor(unpackedSize: bigint);
|
|
39
|
-
decompress(data: Uint8Array): Uint8Array;
|
|
40
|
-
bytes_written(): bigint;
|
|
41
|
-
is_complete(): boolean;
|
|
42
|
-
reset(): void;
|
|
43
|
-
free(): void;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export declare class Rar5Decoder {
|
|
47
|
-
constructor(unpackedSize: bigint, dictSizeLog: number, method: number, isSolid: boolean);
|
|
48
|
-
decompress(data: Uint8Array): Uint8Array;
|
|
49
|
-
reset(): void;
|
|
50
|
-
free(): void;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export declare class Rar5Crypto {
|
|
54
|
-
constructor(password: string, salt: Uint8Array, lg2Count: number);
|
|
55
|
-
decrypt(iv: Uint8Array, data: Uint8Array): Uint8Array;
|
|
56
|
-
verify_password(checkValue: Uint8Array): boolean;
|
|
57
|
-
free(): void;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Direct snake_case access (require init() before use)
|
|
61
|
-
export {
|
|
62
|
-
is_rar_archive,
|
|
63
|
-
get_rar_version,
|
|
64
|
-
parse_rar_header,
|
|
65
|
-
parse_rar_headers,
|
|
66
|
-
parse_rar5_header,
|
|
67
|
-
parse_rar5_headers,
|
|
68
|
-
extract_file,
|
|
69
|
-
} from '../pkg/rar_stream.d.ts';
|
|
70
|
-
|
|
71
|
-
/** Options for creating a ReadableStream */
|
|
72
|
-
export interface ReadableStreamOptions {
|
|
73
|
-
/** Total size of the data */
|
|
74
|
-
totalSize: number;
|
|
75
|
-
/** Start offset (default: 0) */
|
|
76
|
-
start?: number;
|
|
77
|
-
/** End offset inclusive (default: totalSize - 1) */
|
|
78
|
-
end?: number;
|
|
79
|
-
/** Size of each chunk to read (default: 65536) */
|
|
80
|
-
chunkSize?: number;
|
|
81
|
-
/** Function to read a chunk of data */
|
|
82
|
-
readChunk: (start: number, end: number) => Promise<Uint8Array>;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Options for creating a range response */
|
|
86
|
-
export interface RangeResponseOptions {
|
|
87
|
-
/** Total file size */
|
|
88
|
-
totalSize: number;
|
|
89
|
-
/** HTTP Range header value */
|
|
90
|
-
rangeHeader?: string;
|
|
91
|
-
/** MIME type (default: 'application/octet-stream') */
|
|
92
|
-
contentType?: string;
|
|
93
|
-
/** Function to read a chunk of data */
|
|
94
|
-
readChunk: (start: number, end: number) => Promise<Uint8Array>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** Result from createRangeResponse */
|
|
98
|
-
export interface RangeResponseResult {
|
|
99
|
-
stream: ReadableStream<Uint8Array>;
|
|
100
|
-
headers: Headers;
|
|
101
|
-
status: number;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Create a Web ReadableStream from an async data source.
|
|
106
|
-
* Useful for Service Workers and streaming responses.
|
|
107
|
-
*/
|
|
108
|
-
export declare function createReadableStream(options: ReadableStreamOptions): ReadableStream<Uint8Array>;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Helper to create a streaming response for HTTP range requests.
|
|
112
|
-
* Parses the Range header and returns appropriate stream, headers, and status.
|
|
113
|
-
*/
|
|
114
|
-
export declare function createRangeResponse(options: RangeResponseOptions): RangeResponseResult;
|