Skip to content

Commit 61fe779

Browse files
authored
Completed web.js HSSP 5 support and some last fixes before 4.0.0 release
1 parent a3cff9a commit 61fe779

File tree

5 files changed

+619
-134
lines changed

5 files changed

+619
-134
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Continue with [learning about the API](#api).
2828
### Web
2929
- Load HSSP for JavaScript with:
3030
```html
31-
<script src="https://cdn.jsdelivr.net/npm/hssp@3/web.min.js"></script>
31+
<script src="https://cdn.jsdelivr.net/npm/hssp@4/web.min.js"></script>
3232
```
3333
- Create an editor:
3434
```js
@@ -62,6 +62,7 @@ editor.addFile('my-folder/test.txt', fs.readFileSync('test2.txt'));
6262
editor.addFile('my-folder/test.txt', (new TextEncoder()).encode('Hello, world! 2').buffer);
6363
```
6464
- Delete a file:
65+
6566
**Note:** _This method will return the file Buffer/ArrayBuffer._
6667
```js
6768
editor.remove('test.txt');
@@ -70,6 +71,7 @@ editor.remove('test.txt');
7071
```js
7172
editor.remove('my-folder');
7273
```
74+
7375
**Note:** _This will only remove the folder, not the files in it! If you want to remove the folder with the files in it, use:_
7476
```js
7577
var folderName = 'my-folder';
@@ -85,7 +87,7 @@ editor.remove(folderName); // Remove the folder itself
8587

8688
- Set output file version:
8789
```js
88-
editor.version = 4; // 4 is set by default, 1-4 are valid version numbers
90+
editor.version = 5; // 5 is set by default, 1-5 are valid version numbers
8991
```
9092
- Enable output encryption:
9193
```js
@@ -96,6 +98,7 @@ editor.password = 'MySecretPassword'; // write-only
9698
editor.password = null; // Encryption is disabled by default
9799
```
98100
- Enable output compression ([Supported algorithms](#supported-compression-algorithms)):
101+
99102
**Note:** _Requires editor.version is 4 or higher._
100103
```js
101104
editor.compression = { algorithm: 'LZMA', level: 9 }; // Level default is 5
@@ -105,14 +108,15 @@ editor.compression = { algorithm: 'LZMA', level: 9 }; // Level default is 5
105108
editor.compression = null; // default
106109
```
107110
- Add a comment:
111+
108112
**Note:** _Requires editor.version is 4 or higher. The comment can be up to 16 characters (UTF-8) long._
109113
```js
110114
editor.comment = 'Hello :)';
111115
```
112116

113117
#### Importing HSSP files
114118

115-
Currently supports HSSP 1-4.
119+
Currently supports HSSP 1-5.
116120

117121
- Importing HSSP files _without_ encryption:
118122
```js
@@ -145,7 +149,7 @@ document.querySelector('input[type=file]').onchange = async (ev) => {
145149

146150
#### Creating HSSP files
147151

148-
Currently supports HSSP 1-4.
152+
Currently supports HSSP 1-5.
149153

150154
- Creating _one_ file:
151155
```js
@@ -162,6 +166,7 @@ a.click();
162166
URL.revokeObjectURL(url);
163167
```
164168
- Creating _multiple_ files:
169+
165170
**Note:** _This method can only be used if `editor.version` is 4 or higher. You also cannot create more files than bytes included._
166171
```js
167172
// Node
@@ -185,7 +190,7 @@ editor.toBuffers(4).forEach((buf, i) => {
185190

186191
#### Fetching metadata from HSSP file
187192

188-
Currently supports HSSP 1-4.
193+
Currently supports HSSP 1-5.
189194

190195
Fetching metadata is as simple as that:
191196
```js
@@ -236,7 +241,7 @@ editor.addFolder(name, options);
236241

237242
Feel free to contribute by [opening an issue](https://github.com/HSSPfile/js/issues/new/choose) and requesting new features, reporting bugs or just asking questions.
238243

239-
You can also [fork the repository](https://github.com/HSSPfile/js/fork) and opening a [pull request](https://github.com/HSSPfile/js/pulls) after making some changes like fixing bugs.
244+
You can also [fork the repository](https://github.com/HSSPfile/js/fork) and open a [pull request](https://github.com/HSSPfile/js/pulls) after making some changes like fixing bugs.
240245

241246
## [License](LICENSE)
242247

main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ class Editor { // Can hold massive amounts of data in a single file
11751175
var fileStart = Buffer.alloc(size);
11761176
fileStart.write('HSSP', 0, 'utf8'); // Magic value :) | 4+0
11771177
fileStart.writeUint8(4, 4); // File standard version, see https://hssp.leox.dev/docs/versions | 1+4
1178-
out.writeUint8(parseInt([
1178+
fileStart.writeUint8(parseInt([
11791179
this.#pwd !== null, // F1: is encrypted
11801180
this.#compAlgo !== 'NONE', // F2: is compressed
11811181
true, // F3: is split
@@ -1185,7 +1185,7 @@ class Editor { // Can hold massive amounts of data in a single file
11851185
false, // F7: unallocated
11861186
false // F8: unallocated
11871187
].map(b => +b).join(''), 2), 5); // Flags #1, see https://hssp.leox.dev/docs/flags | 1+5
1188-
out.writeUint8(parseInt([
1188+
fileStart.writeUint8(parseInt([
11891189
false, // F9: unallocated
11901190
false, // F10: unallocated
11911191
false, // F11: unallocated
@@ -1195,7 +1195,7 @@ class Editor { // Can hold massive amounts of data in a single file
11951195
false, // F15: unallocated
11961196
false // F16: unallocated
11971197
].map(b => +b).join(''), 2), 6); // Flags #2, see https://hssp.leox.dev/docs/flags | 1+6
1198-
out.writeUint8(parseInt([
1198+
fileStart.writeUint8(parseInt([
11991199
false, // F17: unallocated
12001200
false, // F18: unallocated
12011201
false, // F19: unallocated
@@ -1660,7 +1660,7 @@ module.exports = {
16601660
return metadata;
16611661

16621662
case 5: // v5: Uses flags
1663-
metadata.version = 4;
1663+
metadata.version = 5;
16641664
const inp = buffer.subarray(128, buffer.byteLength);
16651665
metadata.hash.valid = true;
16661666
const hash = murmurhash.murmur3(inp.toString('utf8'), 0x31082007);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hssp",
3-
"version": "3.0.0",
3+
"version": "4.0.0",
44
"description": "Create, edit and read HSSP files in pure JavaScript",
55
"main": "main.js",
66
"scripts": {
@@ -11,8 +11,7 @@
1111
"HSSP",
1212
"HugeSizeSupportingPackage",
1313
"Huge",
14-
"Package",
15-
"64RiB"
14+
"Package"
1615
],
1716
"author": "HSSP",
1817
"license": "MIT",

0 commit comments

Comments
 (0)