rar-stream 5.1.1 → 5.2.0

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/browser.d.ts CHANGED
@@ -18,9 +18,44 @@ export declare function parseRarHeaders(data: Uint8Array): Promise<any[]>;
18
18
  export declare function parseRar5Header(data: Uint8Array): Promise<any>;
19
19
  export declare function parseRar5Headers(data: Uint8Array): Promise<any[]>;
20
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
+
21
27
  // Classes (require init() before construction)
22
- export { WasmRarDecoder, WasmRar5Decoder, WasmRar5Crypto } from '../pkg/rar_stream.d.ts';
23
- export { WasmRarDecoder as RarDecoder, WasmRar5Decoder as Rar5Decoder } from '../pkg/rar_stream.d.ts';
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
+ }
24
59
 
25
60
  // Direct snake_case access (require init() before use)
26
61
  export {
@@ -30,6 +65,7 @@ export {
30
65
  parse_rar_headers,
31
66
  parse_rar5_header,
32
67
  parse_rar5_headers,
68
+ extract_file,
33
69
  } from '../pkg/rar_stream.d.ts';
34
70
 
35
71
  /** Options for creating a ReadableStream */
package/lib/browser.mjs CHANGED
@@ -12,6 +12,8 @@ import wasmInit, {
12
12
  parse_rar_headers,
13
13
  parse_rar5_header,
14
14
  parse_rar5_headers,
15
+ extract_file,
16
+ WasmRarArchive,
15
17
  WasmRarDecoder,
16
18
  WasmRar5Decoder,
17
19
  WasmRar5Crypto,
@@ -75,10 +77,24 @@ export async function parseRar5Headers(data) {
75
77
  return parse_rar5_headers(data);
76
78
  }
77
79
 
78
- // Re-export classes (require manual init() before use)
79
- export { WasmRarDecoder, WasmRar5Decoder, WasmRar5Crypto };
80
- // Aliases
81
- export { WasmRarDecoder as RarDecoder, WasmRar5Decoder as Rar5Decoder };
80
+ // Re-export classes with aligned names (require manual init() before use)
81
+ export {
82
+ WasmRarArchive as RarFilesPackage,
83
+ WasmRarDecoder as RarDecoder,
84
+ WasmRar5Decoder as Rar5Decoder,
85
+ WasmRar5Crypto as Rar5Crypto,
86
+ };
87
+
88
+ /**
89
+ * Extract the first file from a RAR archive buffer.
90
+ * Auto-detects RAR4/RAR5, parses headers, and decompresses in one call.
91
+ * @param {Uint8Array} data - The entire RAR archive
92
+ * @returns {Promise<{name: string, data: Uint8Array, size: number}>}
93
+ */
94
+ export async function extractFile(data) {
95
+ await ensureInit();
96
+ return extract_file(data);
97
+ }
82
98
 
83
99
  // Re-export snake_case direct access (require manual init() before use)
84
100
  export {
@@ -88,6 +104,7 @@ export {
88
104
  parse_rar_headers,
89
105
  parse_rar5_header,
90
106
  parse_rar5_headers,
107
+ extract_file,
91
108
  };
92
109
 
93
110
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rar-stream",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "RAR streaming library - Rust implementation with NAPI and WASM bindings",
5
5
  "main": "lib/index.mjs",
6
6
  "browser": "lib/browser.mjs",
@@ -105,12 +105,12 @@
105
105
  "*.node"
106
106
  ],
107
107
  "optionalDependencies": {
108
- "rar-stream-win32-x64-msvc": "5.1.1",
109
- "rar-stream-darwin-x64": "5.1.1",
110
- "rar-stream-linux-x64-gnu": "5.1.1",
111
- "rar-stream-linux-x64-musl": "5.1.1",
112
- "rar-stream-linux-arm64-gnu": "5.1.1",
113
- "rar-stream-darwin-arm64": "5.1.1",
114
- "rar-stream-linux-arm64-musl": "5.1.1"
108
+ "rar-stream-win32-x64-msvc": "5.2.0",
109
+ "rar-stream-darwin-x64": "5.2.0",
110
+ "rar-stream-linux-x64-gnu": "5.2.0",
111
+ "rar-stream-linux-x64-musl": "5.2.0",
112
+ "rar-stream-linux-arm64-gnu": "5.2.0",
113
+ "rar-stream-darwin-arm64": "5.2.0",
114
+ "rar-stream-linux-arm64-musl": "5.2.0"
115
115
  }
116
116
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file