stormlib-js 0.1.0 → 0.1.1
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 +29 -0
- package/dist/chunk-RRBXXQVG.mjs +2410 -0
- package/dist/chunk-RRBXXQVG.mjs.map +1 -0
- package/dist/index.browser.d.mts +195 -0
- package/dist/index.browser.d.ts +195 -0
- package/dist/index.browser.js +3002 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.browser.mjs +693 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.d.mts +25 -241
- package/dist/index.d.ts +25 -241
- package/dist/index.js +87 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -2338
- package/dist/index.mjs.map +1 -1
- package/dist/storm-buffer-nHXHoPVG.d.mts +242 -0
- package/dist/storm-buffer-nHXHoPVG.d.ts +242 -0
- package/package.json +20 -3
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { F as FileEntry, O as OpenArchiveOptions, a as FileFindData, M as MpqHeader } from './storm-buffer-nHXHoPVG.js';
|
|
2
|
+
export { A as ATTRIBUTES_NAME, B as BetTableHeader, H as HetTableHeader, I as ID_MPQ, b as ID_MPQ_USERDATA, L as LISTFILE_NAME, c as MPQ_COMPRESSION_ADPCM_MONO, d as MPQ_COMPRESSION_ADPCM_STEREO, e as MPQ_COMPRESSION_BZIP2, f as MPQ_COMPRESSION_HUFFMANN, g as MPQ_COMPRESSION_LZMA, h as MPQ_COMPRESSION_PKWARE, i as MPQ_COMPRESSION_SPARSE, j as MPQ_COMPRESSION_ZLIB, k as MPQ_FILE_COMPRESS, l as MPQ_FILE_ENCRYPTED, m as MPQ_FILE_EXISTS, n as MPQ_FILE_IMPLODE, o as MPQ_FILE_KEY_V2, p as MPQ_FILE_SINGLE_UNIT, q as MPQ_FORMAT_VERSION_1, r as MPQ_FORMAT_VERSION_2, s as MPQ_FORMAT_VERSION_3, t as MPQ_FORMAT_VERSION_4, u as MpqBlockEntry, v as MpqCompressionError, w as MpqCorruptError, x as MpqEncryptionError, y as MpqError, z as MpqHashEntry, C as MpqNotFoundError, D as MpqUnsupportedError, E as MpqUserData, S as SIGNATURE_NAME, G as decryptBlock, J as decryptFileKey, K as encryptBlock, N as getStormBuffer, P as hashFileKey, Q as hashNameA, R as hashNameB, T as hashString, U as hashTableIndex, V as jenkinsHash } from './storm-buffer-nHXHoPVG.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Browser-safe stream abstraction backed by in-memory binary data.
|
|
6
|
+
*/
|
|
7
|
+
type BinaryInput$1 = Buffer | Uint8Array | ArrayBuffer;
|
|
8
|
+
declare class FileStream {
|
|
9
|
+
private fileSize;
|
|
10
|
+
private filePath;
|
|
11
|
+
private memoryData;
|
|
12
|
+
private constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Path-based open is not available in browsers.
|
|
15
|
+
*/
|
|
16
|
+
static open(_path: string): never;
|
|
17
|
+
/**
|
|
18
|
+
* Create an in-memory stream from binary data.
|
|
19
|
+
*/
|
|
20
|
+
static fromBuffer(data: BinaryInput$1, filePath?: string): FileStream;
|
|
21
|
+
private static normalizeBuffer;
|
|
22
|
+
/**
|
|
23
|
+
* Read bytes at a given offset.
|
|
24
|
+
*/
|
|
25
|
+
read(offset: bigint, length: number): Buffer;
|
|
26
|
+
/**
|
|
27
|
+
* Read bytes into an existing buffer.
|
|
28
|
+
*/
|
|
29
|
+
readInto(offset: bigint, buffer: Buffer, bufOffset: number, length: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Get the total file size.
|
|
32
|
+
*/
|
|
33
|
+
getSize(): bigint;
|
|
34
|
+
/**
|
|
35
|
+
* Get the file path.
|
|
36
|
+
*/
|
|
37
|
+
getPath(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Close the stream.
|
|
40
|
+
*/
|
|
41
|
+
close(): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* MpqFile represents an open file handle within an MPQ archive.
|
|
46
|
+
* It provides methods to read file data.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
declare class MpqFile {
|
|
50
|
+
private stream;
|
|
51
|
+
private archiveOffset;
|
|
52
|
+
private entry;
|
|
53
|
+
private sectorSize;
|
|
54
|
+
private fileKey;
|
|
55
|
+
private closed;
|
|
56
|
+
constructor(stream: FileStream, archiveOffset: bigint, entry: FileEntry, sectorSize: number);
|
|
57
|
+
/** Uncompressed file size */
|
|
58
|
+
get size(): number;
|
|
59
|
+
/** Compressed file size */
|
|
60
|
+
get compressedSize(): number;
|
|
61
|
+
/** File flags */
|
|
62
|
+
get flags(): number;
|
|
63
|
+
/** File name */
|
|
64
|
+
get name(): string;
|
|
65
|
+
/** The underlying file entry */
|
|
66
|
+
get fileEntry(): FileEntry;
|
|
67
|
+
/**
|
|
68
|
+
* Read the entire file contents.
|
|
69
|
+
*
|
|
70
|
+
* @returns Buffer containing the decompressed file data
|
|
71
|
+
*/
|
|
72
|
+
read(): Buffer;
|
|
73
|
+
/**
|
|
74
|
+
* Close the file handle.
|
|
75
|
+
*/
|
|
76
|
+
close(): void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* MpqArchive - Main class for reading MPQ archives.
|
|
81
|
+
*
|
|
82
|
+
* This is the primary public API for opening and reading MPQ files.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
type BinaryInput = Buffer | Uint8Array | ArrayBuffer;
|
|
86
|
+
declare class MpqArchive {
|
|
87
|
+
private stream;
|
|
88
|
+
private header;
|
|
89
|
+
private archiveOffset;
|
|
90
|
+
private sectorSize;
|
|
91
|
+
private hashTable;
|
|
92
|
+
private blockTable;
|
|
93
|
+
private hiBlockTable;
|
|
94
|
+
private hetTable;
|
|
95
|
+
private betTable;
|
|
96
|
+
private fileEntries;
|
|
97
|
+
private attributes;
|
|
98
|
+
private closed;
|
|
99
|
+
private constructor();
|
|
100
|
+
/**
|
|
101
|
+
* Open an MPQ archive from a file path.
|
|
102
|
+
*
|
|
103
|
+
* @param path - Path to the MPQ file
|
|
104
|
+
* @param options - Open options
|
|
105
|
+
* @returns MpqArchive instance
|
|
106
|
+
*/
|
|
107
|
+
static open(path: string, options?: OpenArchiveOptions): MpqArchive;
|
|
108
|
+
/**
|
|
109
|
+
* Open an MPQ archive from in-memory binary data.
|
|
110
|
+
*
|
|
111
|
+
* This API works in both Node.js and browser runtimes.
|
|
112
|
+
*
|
|
113
|
+
* @param data - MPQ binary contents
|
|
114
|
+
* @param options - Open options
|
|
115
|
+
* @returns MpqArchive instance
|
|
116
|
+
*/
|
|
117
|
+
static openFromBuffer(data: BinaryInput, options?: OpenArchiveOptions): MpqArchive;
|
|
118
|
+
private static openFromStream;
|
|
119
|
+
/**
|
|
120
|
+
* Load all archive tables (hash, block, HET, BET).
|
|
121
|
+
*/
|
|
122
|
+
private loadTables;
|
|
123
|
+
/**
|
|
124
|
+
* Load and parse the (listfile) to populate file names.
|
|
125
|
+
*/
|
|
126
|
+
private loadListfile;
|
|
127
|
+
/**
|
|
128
|
+
* Load and parse the (attributes) file.
|
|
129
|
+
*/
|
|
130
|
+
private loadAttributes;
|
|
131
|
+
/**
|
|
132
|
+
* Internal: extract a file by name without relying on the listfile.
|
|
133
|
+
* Used for bootstrapping (listfile) and (attributes) loading.
|
|
134
|
+
*/
|
|
135
|
+
private extractFileByName;
|
|
136
|
+
/**
|
|
137
|
+
* Check if a file exists in the archive.
|
|
138
|
+
*/
|
|
139
|
+
hasFile(name: string): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Open a file within the archive for reading.
|
|
142
|
+
*
|
|
143
|
+
* @param name - File path within the archive
|
|
144
|
+
* @returns MpqFile handle
|
|
145
|
+
*/
|
|
146
|
+
openFile(name: string): MpqFile;
|
|
147
|
+
/**
|
|
148
|
+
* Extract a file's contents directly.
|
|
149
|
+
*
|
|
150
|
+
* @param name - File path within the archive
|
|
151
|
+
* @returns Buffer with the file contents
|
|
152
|
+
*/
|
|
153
|
+
extractFile(name: string): Buffer;
|
|
154
|
+
/**
|
|
155
|
+
* Get the list of all known file names (from listfile).
|
|
156
|
+
*/
|
|
157
|
+
getFileList(): string[];
|
|
158
|
+
/**
|
|
159
|
+
* Find files matching a wildcard pattern.
|
|
160
|
+
*
|
|
161
|
+
* @param mask - Wildcard pattern (supports '*' and '?')
|
|
162
|
+
* @returns Array of matching file entries
|
|
163
|
+
*/
|
|
164
|
+
findFiles(mask?: string): FileFindData[];
|
|
165
|
+
/**
|
|
166
|
+
* Apply an external list of file names to resolve unnamed entries.
|
|
167
|
+
* Equivalent to providing an external listfile to SFileFindFirstFile.
|
|
168
|
+
*
|
|
169
|
+
* @param names - Array of file names to try
|
|
170
|
+
* @returns Number of newly resolved names
|
|
171
|
+
*/
|
|
172
|
+
addListfile(names: string[]): number;
|
|
173
|
+
/**
|
|
174
|
+
* Enumerate all existing file entries, including those without names.
|
|
175
|
+
* Unnamed entries get a synthetic name like "File00001234.xxx".
|
|
176
|
+
*/
|
|
177
|
+
enumerateFiles(): FileFindData[];
|
|
178
|
+
/** Get the archive header */
|
|
179
|
+
getHeader(): Readonly<MpqHeader>;
|
|
180
|
+
/** Get the number of file entries */
|
|
181
|
+
get fileCount(): number;
|
|
182
|
+
/** Get the sector size */
|
|
183
|
+
getSectorSize(): number;
|
|
184
|
+
/**
|
|
185
|
+
* Close the archive and release resources.
|
|
186
|
+
*/
|
|
187
|
+
close(): void;
|
|
188
|
+
/**
|
|
189
|
+
* Resolve a file name to its FileEntry.
|
|
190
|
+
*/
|
|
191
|
+
private resolveFile;
|
|
192
|
+
private ensureOpen;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export { FileEntry, FileFindData, MpqArchive, MpqFile, MpqHeader, OpenArchiveOptions };
|