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
package/README.md
CHANGED
|
@@ -69,6 +69,22 @@ for (const entry of results) {
|
|
|
69
69
|
archive.close();
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
Browser or in-memory usage:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { MpqArchive } from 'stormlib-js/browser';
|
|
76
|
+
|
|
77
|
+
const file = input.files?.[0];
|
|
78
|
+
if (!file) throw new Error('No file selected');
|
|
79
|
+
|
|
80
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
81
|
+
const archive = MpqArchive.openFromBuffer(arrayBuffer);
|
|
82
|
+
const war3mapJ = archive.extractFile('war3map.j');
|
|
83
|
+
archive.close();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`stormlib-js/browser` is browser-safe and does not include Node `fs` loading code.
|
|
87
|
+
|
|
72
88
|
## API
|
|
73
89
|
|
|
74
90
|
### `MpqArchive`
|
|
@@ -79,6 +95,8 @@ The main class for working with MPQ archives.
|
|
|
79
95
|
|
|
80
96
|
Opens an MPQ archive from a file path.
|
|
81
97
|
|
|
98
|
+
> In `stormlib-js/browser`, `MpqArchive.open()` throws by design. Use `openFromBuffer()`.
|
|
99
|
+
|
|
82
100
|
```typescript
|
|
83
101
|
const archive = MpqArchive.open('archive.mpq');
|
|
84
102
|
|
|
@@ -91,6 +109,17 @@ const archive = MpqArchive.open('archive.mpq', {
|
|
|
91
109
|
});
|
|
92
110
|
```
|
|
93
111
|
|
|
112
|
+
#### `MpqArchive.openFromBuffer(data, options?)`
|
|
113
|
+
|
|
114
|
+
Opens an MPQ archive from in-memory binary data (`ArrayBuffer`, `Uint8Array`, or `Buffer`).
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { MpqArchive } from 'stormlib-js/browser';
|
|
118
|
+
|
|
119
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
120
|
+
const archive = MpqArchive.openFromBuffer(arrayBuffer);
|
|
121
|
+
```
|
|
122
|
+
|
|
94
123
|
#### `archive.hasFile(name)`
|
|
95
124
|
|
|
96
125
|
Returns `true` if the file exists in the archive.
|