@etothepii/satisfactory-file-parser 0.0.30 → 0.0.32
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/LICENCE.md +20 -20
- package/README.md +112 -112
- package/build/index.d.ts +23 -0
- package/build/index.js +65 -0
- package/build/parser/byte/alignment.enum.d.ts +4 -0
- package/build/parser/byte/alignment.enum.js +18 -0
- package/build/parser/byte/binary-operable.interface.d.ts +6 -0
- package/build/parser/byte/binary-operable.interface.js +12 -0
- package/build/parser/byte/binary-readable.interface.d.ts +22 -0
- package/build/parser/byte/binary-readable.interface.js +12 -0
- package/build/parser/byte/byte-reader.class.d.ts +36 -0
- package/build/parser/byte/byte-reader.class.js +139 -0
- package/build/parser/byte/byte-writer.class.d.ts +33 -0
- package/build/parser/byte/byte-writer.class.js +149 -0
- package/build/parser/error/parser.error.d.ts +18 -0
- package/build/parser/error/parser.error.js +50 -0
- package/build/parser/file.types.d.ts +9 -0
- package/build/parser/file.types.js +12 -0
- package/build/parser/parser.d.ts +25 -0
- package/build/parser/parser.js +196 -0
- package/build/parser/satisfactory/blueprint/blueprint-reader.d.ts +19 -0
- package/build/parser/satisfactory/blueprint/blueprint-reader.js +134 -0
- package/build/parser/satisfactory/blueprint/blueprint-writer.d.ts +15 -0
- package/build/parser/satisfactory/blueprint/blueprint-writer.js +73 -0
- package/build/parser/satisfactory/blueprint/blueprint.types.d.ts +20 -0
- package/build/parser/satisfactory/blueprint/blueprint.types.js +12 -0
- package/build/parser/satisfactory/objects/DataFields.d.ts +41 -0
- package/build/parser/satisfactory/objects/DataFields.js +317 -0
- package/build/parser/satisfactory/objects/ObjectReference.d.ts +9 -0
- package/build/parser/satisfactory/objects/ObjectReference.js +27 -0
- package/build/parser/satisfactory/objects/Property.d.ts +270 -0
- package/build/parser/satisfactory/objects/Property.js +1012 -0
- package/build/parser/satisfactory/objects/SaveComponent.d.ts +19 -0
- package/build/parser/satisfactory/objects/SaveComponent.js +41 -0
- package/build/parser/satisfactory/objects/SaveEntity.d.ts +30 -0
- package/build/parser/satisfactory/objects/SaveEntity.js +80 -0
- package/build/parser/satisfactory/objects/SaveObject.d.ts +19 -0
- package/build/parser/satisfactory/objects/SaveObject.js +39 -0
- package/build/parser/satisfactory/save/asynchronous-level.class.d.ts +9 -0
- package/build/parser/satisfactory/save/asynchronous-level.class.js +76 -0
- package/build/parser/satisfactory/save/level.class.d.ts +21 -0
- package/build/parser/satisfactory/save/level.class.js +149 -0
- package/build/parser/satisfactory/save/satisfactory-save.d.ts +11 -0
- package/build/parser/satisfactory/save/satisfactory-save.js +21 -0
- package/build/parser/satisfactory/save/save-reader.d.ts +35 -0
- package/build/parser/satisfactory/save/save-reader.js +188 -0
- package/build/parser/satisfactory/save/save-writer.d.ts +12 -0
- package/build/parser/satisfactory/save/save-writer.js +122 -0
- package/build/parser/satisfactory/save/save.types.d.ts +49 -0
- package/build/parser/satisfactory/save/save.types.js +12 -0
- package/build/parser/satisfactory/structs/util.types.d.ts +40 -0
- package/build/parser/satisfactory/structs/util.types.js +105 -0
- package/build/parser/stream/byte-stream-reader.class.d.ts +57 -0
- package/build/parser/stream/byte-stream-reader.class.js +251 -0
- package/build/parser/stream/json-stream-state-writer.d.ts +12 -0
- package/build/parser/stream/json-stream-state-writer.js +28 -0
- package/build/parser/stream/json-stream-writable.d.ts +20 -0
- package/build/parser/stream/json-stream-writable.js +93 -0
- package/build/parser/stream/json-stream-writer.d.ts +22 -0
- package/build/parser/stream/json-stream-writer.js +137 -0
- package/build/parser/stream/save-stream-json-stringifier.d.ts +6 -0
- package/build/parser/stream/save-stream-json-stringifier.js +43 -0
- package/build/parser/stream/save-stream-reader.class.d.ts +15 -0
- package/build/parser/stream/save-stream-reader.class.js +131 -0
- package/build/parser/stream/save-stream-writer.class.d.ts +22 -0
- package/build/parser/stream/save-stream-writer.class.js +115 -0
- package/build/parser/stream/stream-level.class.d.ts +12 -0
- package/build/parser/stream/stream-level.class.js +113 -0
- package/package.json +5 -3
- package/dist/index.d.ts +0 -610
- package/dist/index.js +0 -1
package/LICENCE.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 etotheepii
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 etotheepii
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
# Satisfactory File Parser
|
|
2
|
-
This is an NPM TypeScript Module to parse Satisfactory Files. Satisfactory is a game released by Coffee Stain Studios.
|
|
3
|
-
|
|
4
|
-
The Module is written entirely in TypeScript and comes with Type Definitions.
|
|
5
|
-
Currently, only the built JavaScript and Type Definitions are available. But if needed, the TypeScript source can be provided as well in future versions.
|
|
6
|
-
|
|
7
|
-
This parser can read, modify and write:
|
|
8
|
-
- Save Files `.sav`
|
|
9
|
-
- Blueprint Files `.sbp`, `.sbpcfg`
|
|
10
|
-
|
|
11
|
-
## Supported Versions
|
|
12
|
-
Game Version Files of U5 and below are NOT supported. However, U6 and above is perfectly fine and parsable.
|
|
13
|
-
- ✅ U7
|
|
14
|
-
- ✅ U6
|
|
15
|
-
- ❌ <= U5
|
|
16
|
-
|
|
17
|
-
### U8 is on the Horizon!
|
|
18
|
-
We can not promise that U8 saves will work out of the box!
|
|
19
|
-
If there will be changes, those will come very soon as soon as U8 is out on Experimental.
|
|
20
|
-
|
|
21
|
-
## Installation via npm
|
|
22
|
-
`npm install @etothepii/satisfactory-file-parser`
|
|
23
|
-
|
|
24
|
-
## Usage of Save Parsing
|
|
25
|
-
Usage of the SaveParser is easy. For reading a save file (`.sav`), just pass a Buffer to the parser with the file content.
|
|
26
|
-
```js
|
|
27
|
-
import * as fs from 'fs';
|
|
28
|
-
import { Parser } from "@etothepii/satisfactory-file-parser";
|
|
29
|
-
|
|
30
|
-
const file = fs.readFileSync('./MySave.sav') as Buffer;
|
|
31
|
-
const parsedSave = Parser.ParseSaveFile(file);
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Consequently, writing a parsed save file back is just as easy.
|
|
35
|
-
The SaveParser has callbacks to assist in syncing on different occasions during the process.
|
|
36
|
-
For example, when writing the header or when writing a chunk of the save body.
|
|
37
|
-
The splitting in individual chunks enables you to more easily stream the binary data to somewhere else.
|
|
38
|
-
```js
|
|
39
|
-
import * as fs from 'fs';
|
|
40
|
-
import { Parser } from "@etothepii/satisfactory-file-parser";
|
|
41
|
-
|
|
42
|
-
let header: Uint8Array, bodyChunks: Uint8Array[] = [];
|
|
43
|
-
Parser.WriteSave(save, binaryBeforeCompressed => {
|
|
44
|
-
console.log('on binary data before being compressed.');
|
|
45
|
-
}, header => {
|
|
46
|
-
console.log('on save header.');
|
|
47
|
-
header = header;
|
|
48
|
-
}, chunk => {
|
|
49
|
-
console.log('on save body chunk.');
|
|
50
|
-
bodyChunks.push(chunk);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// write complete sav file back to disk
|
|
54
|
-
fs.writeFileSync('./MyModifiedSave.sav', Buffer.concat([header!, ...bodyChunks]));
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Usage of Blueprint Parsing
|
|
58
|
-
Blueprint parsing works very similiar. Note, that blueprints consist of 2 files. The `.sbp` main file and the config file `.sbpcfg`.
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
import * as fs from 'fs';
|
|
62
|
-
import { Parser } from "@etothepii/satisfactory-file-parser";
|
|
63
|
-
|
|
64
|
-
const mainFile = fs.readFileSync('./MyBlueprint.sbp') as Buffer;
|
|
65
|
-
const configFile = fs.readFileSync('./MyBlueprint.sbpcfg') as Buffer;
|
|
66
|
-
const parsedBlueprint = Parser.ParseBlueprintFiles('MyBlueprint', mainFile, configFile);
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Consequently, writing a blueprint into binary data works the same way with getting callbacks in the same style as the save parsing.
|
|
70
|
-
```js
|
|
71
|
-
import * as fs from 'fs';
|
|
72
|
-
import { Parser } from "@etothepii/satisfactory-file-parser";
|
|
73
|
-
|
|
74
|
-
let mainFileHeader: Uint8Array, mainFileBodyChunks: Uint8Array[] = [];
|
|
75
|
-
const summary = Parser.WriteBlueprintFiles(blueprint, mainFileBinaryBeforeCompressed => {
|
|
76
|
-
console.log('on main file binary data before being compressed.');
|
|
77
|
-
}, header => {
|
|
78
|
-
console.log('on main file blueprint header.');
|
|
79
|
-
mainFileHeader = header;
|
|
80
|
-
}, chunk => {
|
|
81
|
-
console.log('on main file blueprint body chunk.');
|
|
82
|
-
mainFileBodyChunks.push(chunk);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// write complete .sbp file back to disk
|
|
86
|
-
fs.writeFileSync('./MyModifiedBlueprint.sbp', Buffer.concat([mainFileHeader!, ...mainFileBodyChunks]));
|
|
87
|
-
|
|
88
|
-
// write .sbpcfg file back to disk, we get that data from the result of WriteBlueprintFiles
|
|
89
|
-
fs.writeFileSync('./MyModifiedSave.sbpcfg', Buffer.from(summary.configFileBinary));
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## License
|
|
93
|
-
MIT License
|
|
94
|
-
|
|
95
|
-
Copyright (c) 2023 etotheepii
|
|
96
|
-
|
|
97
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
98
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
99
|
-
in the Software without restriction, including without limitation the rights
|
|
100
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
101
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
102
|
-
furnished to do so, subject to the following conditions:
|
|
103
|
-
|
|
104
|
-
The above copyright notice and this permission notice shall be included in all
|
|
105
|
-
copies or substantial portions of the Software.
|
|
106
|
-
|
|
107
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
108
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
109
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
110
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
111
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
112
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
# Satisfactory File Parser
|
|
2
|
+
This is an NPM TypeScript Module to parse Satisfactory Files. Satisfactory is a game released by Coffee Stain Studios.
|
|
3
|
+
|
|
4
|
+
The Module is written entirely in TypeScript and comes with Type Definitions.
|
|
5
|
+
Currently, only the built JavaScript and Type Definitions are available. But if needed, the TypeScript source can be provided as well in future versions.
|
|
6
|
+
|
|
7
|
+
This parser can read, modify and write:
|
|
8
|
+
- Save Files `.sav`
|
|
9
|
+
- Blueprint Files `.sbp`, `.sbpcfg`
|
|
10
|
+
|
|
11
|
+
## Supported Versions
|
|
12
|
+
Game Version Files of U5 and below are NOT supported. However, U6 and above is perfectly fine and parsable.
|
|
13
|
+
- ✅ U7
|
|
14
|
+
- ✅ U6
|
|
15
|
+
- ❌ <= U5
|
|
16
|
+
|
|
17
|
+
### U8 is on the Horizon!
|
|
18
|
+
We can not promise that U8 saves will work out of the box!
|
|
19
|
+
If there will be changes, those will come very soon as soon as U8 is out on Experimental.
|
|
20
|
+
|
|
21
|
+
## Installation via npm
|
|
22
|
+
`npm install @etothepii/satisfactory-file-parser`
|
|
23
|
+
|
|
24
|
+
## Usage of Save Parsing
|
|
25
|
+
Usage of the SaveParser is easy. For reading a save file (`.sav`), just pass a Buffer to the parser with the file content.
|
|
26
|
+
```js
|
|
27
|
+
import * as fs from 'fs';
|
|
28
|
+
import { Parser } from "@etothepii/satisfactory-file-parser";
|
|
29
|
+
|
|
30
|
+
const file = fs.readFileSync('./MySave.sav') as Buffer;
|
|
31
|
+
const parsedSave = Parser.ParseSaveFile(file);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Consequently, writing a parsed save file back is just as easy.
|
|
35
|
+
The SaveParser has callbacks to assist in syncing on different occasions during the process.
|
|
36
|
+
For example, when writing the header or when writing a chunk of the save body.
|
|
37
|
+
The splitting in individual chunks enables you to more easily stream the binary data to somewhere else.
|
|
38
|
+
```js
|
|
39
|
+
import * as fs from 'fs';
|
|
40
|
+
import { Parser } from "@etothepii/satisfactory-file-parser";
|
|
41
|
+
|
|
42
|
+
let header: Uint8Array, bodyChunks: Uint8Array[] = [];
|
|
43
|
+
Parser.WriteSave(save, binaryBeforeCompressed => {
|
|
44
|
+
console.log('on binary data before being compressed.');
|
|
45
|
+
}, header => {
|
|
46
|
+
console.log('on save header.');
|
|
47
|
+
header = header;
|
|
48
|
+
}, chunk => {
|
|
49
|
+
console.log('on save body chunk.');
|
|
50
|
+
bodyChunks.push(chunk);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// write complete sav file back to disk
|
|
54
|
+
fs.writeFileSync('./MyModifiedSave.sav', Buffer.concat([header!, ...bodyChunks]));
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage of Blueprint Parsing
|
|
58
|
+
Blueprint parsing works very similiar. Note, that blueprints consist of 2 files. The `.sbp` main file and the config file `.sbpcfg`.
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import * as fs from 'fs';
|
|
62
|
+
import { Parser } from "@etothepii/satisfactory-file-parser";
|
|
63
|
+
|
|
64
|
+
const mainFile = fs.readFileSync('./MyBlueprint.sbp') as Buffer;
|
|
65
|
+
const configFile = fs.readFileSync('./MyBlueprint.sbpcfg') as Buffer;
|
|
66
|
+
const parsedBlueprint = Parser.ParseBlueprintFiles('MyBlueprint', mainFile, configFile);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Consequently, writing a blueprint into binary data works the same way with getting callbacks in the same style as the save parsing.
|
|
70
|
+
```js
|
|
71
|
+
import * as fs from 'fs';
|
|
72
|
+
import { Parser } from "@etothepii/satisfactory-file-parser";
|
|
73
|
+
|
|
74
|
+
let mainFileHeader: Uint8Array, mainFileBodyChunks: Uint8Array[] = [];
|
|
75
|
+
const summary = Parser.WriteBlueprintFiles(blueprint, mainFileBinaryBeforeCompressed => {
|
|
76
|
+
console.log('on main file binary data before being compressed.');
|
|
77
|
+
}, header => {
|
|
78
|
+
console.log('on main file blueprint header.');
|
|
79
|
+
mainFileHeader = header;
|
|
80
|
+
}, chunk => {
|
|
81
|
+
console.log('on main file blueprint body chunk.');
|
|
82
|
+
mainFileBodyChunks.push(chunk);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// write complete .sbp file back to disk
|
|
86
|
+
fs.writeFileSync('./MyModifiedBlueprint.sbp', Buffer.concat([mainFileHeader!, ...mainFileBodyChunks]));
|
|
87
|
+
|
|
88
|
+
// write .sbpcfg file back to disk, we get that data from the result of WriteBlueprintFiles
|
|
89
|
+
fs.writeFileSync('./MyModifiedSave.sbpcfg', Buffer.from(summary.configFileBinary));
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
MIT License
|
|
94
|
+
|
|
95
|
+
Copyright (c) 2023 etotheepii
|
|
96
|
+
|
|
97
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
98
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
99
|
+
in the Software without restriction, including without limitation the rights
|
|
100
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
101
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
102
|
+
furnished to do so, subject to the following conditions:
|
|
103
|
+
|
|
104
|
+
The above copyright notice and this permission notice shall be included in all
|
|
105
|
+
copies or substantial portions of the Software.
|
|
106
|
+
|
|
107
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
108
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
109
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
110
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
111
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
112
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
113
113
|
SOFTWARE.
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './parser/satisfactory/blueprint/blueprint.types';
|
|
2
|
+
export { DataFields } from './parser/satisfactory/objects/DataFields';
|
|
3
|
+
export { ObjectReference } from './parser/satisfactory/objects/ObjectReference';
|
|
4
|
+
export * from './parser/satisfactory/objects/Property';
|
|
5
|
+
export { SaveComponent } from './parser/satisfactory/objects/SaveComponent';
|
|
6
|
+
export { SaveEntity } from './parser/satisfactory/objects/SaveEntity';
|
|
7
|
+
export { Level } from './parser/satisfactory/save/level.class';
|
|
8
|
+
export { SatisfactorySave } from './parser/satisfactory/save/satisfactory-save';
|
|
9
|
+
export * from './parser/satisfactory/save/save.types';
|
|
10
|
+
export { BinaryOperable } from './parser/byte/binary-operable.interface';
|
|
11
|
+
export { BinaryReadable } from './parser/byte/binary-readable.interface';
|
|
12
|
+
export { ByteReader } from './parser/byte/byte-reader.class';
|
|
13
|
+
export { ByteWriter } from './parser/byte/byte-writer.class';
|
|
14
|
+
export { BlueprintConfigReader, BlueprintReader } from './parser/satisfactory/blueprint/blueprint-reader';
|
|
15
|
+
export { BlueprintConfigWriter, BlueprintWriter } from './parser/satisfactory/blueprint/blueprint-writer';
|
|
16
|
+
export { SaveReader } from './parser/satisfactory/save/save-reader';
|
|
17
|
+
export { SaveWriter } from './parser/satisfactory/save/save-writer';
|
|
18
|
+
export * from './parser/satisfactory/structs/util.types';
|
|
19
|
+
export { SaveStreamJsonStringifier } from './parser/stream/save-stream-json-stringifier';
|
|
20
|
+
export { SaveStreamWriter } from './parser/stream/save-stream-writer.class';
|
|
21
|
+
export * from './parser/error/parser.error';
|
|
22
|
+
export * from './parser/file.types';
|
|
23
|
+
export { Parser } from './parser/parser';
|
package/build/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
(function (factory) {
|
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
+
var v = factory(require, exports);
|
|
18
|
+
if (v !== undefined) module.exports = v;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
|
21
|
+
define(["require", "exports", "./parser/satisfactory/blueprint/blueprint.types", "./parser/satisfactory/objects/DataFields", "./parser/satisfactory/objects/ObjectReference", "./parser/satisfactory/objects/Property", "./parser/satisfactory/objects/SaveComponent", "./parser/satisfactory/objects/SaveEntity", "./parser/satisfactory/save/level.class", "./parser/satisfactory/save/satisfactory-save", "./parser/satisfactory/save/save.types", "./parser/byte/byte-reader.class", "./parser/byte/byte-writer.class", "./parser/satisfactory/blueprint/blueprint-reader", "./parser/satisfactory/blueprint/blueprint-writer", "./parser/satisfactory/save/save-reader", "./parser/satisfactory/save/save-writer", "./parser/satisfactory/structs/util.types", "./parser/stream/save-stream-json-stringifier", "./parser/stream/save-stream-writer.class", "./parser/error/parser.error", "./parser/file.types", "./parser/parser"], factory);
|
|
22
|
+
}
|
|
23
|
+
})(function (require, exports) {
|
|
24
|
+
"use strict";
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Parser = exports.SaveStreamWriter = exports.SaveStreamJsonStringifier = exports.SaveWriter = exports.SaveReader = exports.BlueprintWriter = exports.BlueprintConfigWriter = exports.BlueprintReader = exports.BlueprintConfigReader = exports.ByteWriter = exports.ByteReader = exports.SatisfactorySave = exports.Level = exports.SaveEntity = exports.SaveComponent = exports.ObjectReference = exports.DataFields = void 0;
|
|
27
|
+
__exportStar(require("./parser/satisfactory/blueprint/blueprint.types"), exports);
|
|
28
|
+
var DataFields_1 = require("./parser/satisfactory/objects/DataFields");
|
|
29
|
+
Object.defineProperty(exports, "DataFields", { enumerable: true, get: function () { return DataFields_1.DataFields; } });
|
|
30
|
+
var ObjectReference_1 = require("./parser/satisfactory/objects/ObjectReference");
|
|
31
|
+
Object.defineProperty(exports, "ObjectReference", { enumerable: true, get: function () { return ObjectReference_1.ObjectReference; } });
|
|
32
|
+
__exportStar(require("./parser/satisfactory/objects/Property"), exports);
|
|
33
|
+
var SaveComponent_1 = require("./parser/satisfactory/objects/SaveComponent");
|
|
34
|
+
Object.defineProperty(exports, "SaveComponent", { enumerable: true, get: function () { return SaveComponent_1.SaveComponent; } });
|
|
35
|
+
var SaveEntity_1 = require("./parser/satisfactory/objects/SaveEntity");
|
|
36
|
+
Object.defineProperty(exports, "SaveEntity", { enumerable: true, get: function () { return SaveEntity_1.SaveEntity; } });
|
|
37
|
+
var level_class_1 = require("./parser/satisfactory/save/level.class");
|
|
38
|
+
Object.defineProperty(exports, "Level", { enumerable: true, get: function () { return level_class_1.Level; } });
|
|
39
|
+
var satisfactory_save_1 = require("./parser/satisfactory/save/satisfactory-save");
|
|
40
|
+
Object.defineProperty(exports, "SatisfactorySave", { enumerable: true, get: function () { return satisfactory_save_1.SatisfactorySave; } });
|
|
41
|
+
__exportStar(require("./parser/satisfactory/save/save.types"), exports);
|
|
42
|
+
var byte_reader_class_1 = require("./parser/byte/byte-reader.class");
|
|
43
|
+
Object.defineProperty(exports, "ByteReader", { enumerable: true, get: function () { return byte_reader_class_1.ByteReader; } });
|
|
44
|
+
var byte_writer_class_1 = require("./parser/byte/byte-writer.class");
|
|
45
|
+
Object.defineProperty(exports, "ByteWriter", { enumerable: true, get: function () { return byte_writer_class_1.ByteWriter; } });
|
|
46
|
+
var blueprint_reader_1 = require("./parser/satisfactory/blueprint/blueprint-reader");
|
|
47
|
+
Object.defineProperty(exports, "BlueprintConfigReader", { enumerable: true, get: function () { return blueprint_reader_1.BlueprintConfigReader; } });
|
|
48
|
+
Object.defineProperty(exports, "BlueprintReader", { enumerable: true, get: function () { return blueprint_reader_1.BlueprintReader; } });
|
|
49
|
+
var blueprint_writer_1 = require("./parser/satisfactory/blueprint/blueprint-writer");
|
|
50
|
+
Object.defineProperty(exports, "BlueprintConfigWriter", { enumerable: true, get: function () { return blueprint_writer_1.BlueprintConfigWriter; } });
|
|
51
|
+
Object.defineProperty(exports, "BlueprintWriter", { enumerable: true, get: function () { return blueprint_writer_1.BlueprintWriter; } });
|
|
52
|
+
var save_reader_1 = require("./parser/satisfactory/save/save-reader");
|
|
53
|
+
Object.defineProperty(exports, "SaveReader", { enumerable: true, get: function () { return save_reader_1.SaveReader; } });
|
|
54
|
+
var save_writer_1 = require("./parser/satisfactory/save/save-writer");
|
|
55
|
+
Object.defineProperty(exports, "SaveWriter", { enumerable: true, get: function () { return save_writer_1.SaveWriter; } });
|
|
56
|
+
__exportStar(require("./parser/satisfactory/structs/util.types"), exports);
|
|
57
|
+
var save_stream_json_stringifier_1 = require("./parser/stream/save-stream-json-stringifier");
|
|
58
|
+
Object.defineProperty(exports, "SaveStreamJsonStringifier", { enumerable: true, get: function () { return save_stream_json_stringifier_1.SaveStreamJsonStringifier; } });
|
|
59
|
+
var save_stream_writer_class_1 = require("./parser/stream/save-stream-writer.class");
|
|
60
|
+
Object.defineProperty(exports, "SaveStreamWriter", { enumerable: true, get: function () { return save_stream_writer_class_1.SaveStreamWriter; } });
|
|
61
|
+
__exportStar(require("./parser/error/parser.error"), exports);
|
|
62
|
+
__exportStar(require("./parser/file.types"), exports);
|
|
63
|
+
var parser_1 = require("./parser/parser");
|
|
64
|
+
Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return parser_1.Parser; } });
|
|
65
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Alignment = void 0;
|
|
13
|
+
var Alignment;
|
|
14
|
+
(function (Alignment) {
|
|
15
|
+
Alignment[Alignment["BIG_ENDIAN"] = 0] = "BIG_ENDIAN";
|
|
16
|
+
Alignment[Alignment["LITTLE_ENDIAN"] = 1] = "LITTLE_ENDIAN";
|
|
17
|
+
})(Alignment = exports.Alignment || (exports.Alignment = {}));
|
|
18
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BinaryOperable } from "./binary-operable.interface";
|
|
2
|
+
export interface BinaryReadable extends BinaryOperable {
|
|
3
|
+
debug: boolean;
|
|
4
|
+
skipBytes: (count?: number) => void;
|
|
5
|
+
readBytes: (count: number) => Uint8Array;
|
|
6
|
+
readByte: () => number;
|
|
7
|
+
readHex: (count: number) => string;
|
|
8
|
+
readInt8: () => number;
|
|
9
|
+
readUint8: () => number;
|
|
10
|
+
readInt16: () => number;
|
|
11
|
+
readUint16: () => number;
|
|
12
|
+
readInt32: () => number;
|
|
13
|
+
readUint32: () => number;
|
|
14
|
+
readInt64: () => bigint;
|
|
15
|
+
readUint64: () => bigint;
|
|
16
|
+
readFloat32: () => number;
|
|
17
|
+
readDouble: () => number;
|
|
18
|
+
readString: () => string;
|
|
19
|
+
getBufferProgress: () => number;
|
|
20
|
+
allocate: (count: number) => PromiseLike<void>;
|
|
21
|
+
getAmountAllocatedLeft: () => number;
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Alignment } from "./alignment.enum";
|
|
2
|
+
import { BinaryReadable } from "./binary-readable.interface";
|
|
3
|
+
export declare abstract class ByteReader implements BinaryReadable {
|
|
4
|
+
protected bufferView: DataView;
|
|
5
|
+
protected fileBuffer: ArrayBuffer;
|
|
6
|
+
alignment: Alignment;
|
|
7
|
+
debug: boolean;
|
|
8
|
+
protected currentByte: number;
|
|
9
|
+
protected handledByte: number;
|
|
10
|
+
protected maxByte: number;
|
|
11
|
+
constructor(fileBuffer: ArrayBuffer, alignment: Alignment);
|
|
12
|
+
reset(newFileBuffer: ArrayBuffer): void;
|
|
13
|
+
skipBytes(byteLength?: number): void;
|
|
14
|
+
readByte(): number;
|
|
15
|
+
readBytes(count: number): Uint8Array;
|
|
16
|
+
readHex(hexLength: number): string;
|
|
17
|
+
readInt8(): number;
|
|
18
|
+
readUint8(): number;
|
|
19
|
+
readInt16(): number;
|
|
20
|
+
readUint16(): number;
|
|
21
|
+
readInt32(): number;
|
|
22
|
+
readUint32(): number;
|
|
23
|
+
readLong(): bigint;
|
|
24
|
+
readInt64(): bigint;
|
|
25
|
+
readUint64(): bigint;
|
|
26
|
+
readFloat32(): number;
|
|
27
|
+
readDouble(): number;
|
|
28
|
+
readString(): string;
|
|
29
|
+
allocate(count: number): Promise<void>;
|
|
30
|
+
getAmountAllocatedLeft: () => number;
|
|
31
|
+
getBufferPosition: () => number;
|
|
32
|
+
getBufferSlice: (begin: number, end: number | undefined) => ArrayBuffer;
|
|
33
|
+
getBufferProgress: () => number;
|
|
34
|
+
getBufferLength: () => number;
|
|
35
|
+
getBuffer: () => ArrayBuffer;
|
|
36
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./alignment.enum"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ByteReader = void 0;
|
|
13
|
+
const alignment_enum_1 = require("./alignment.enum");
|
|
14
|
+
class ByteReader {
|
|
15
|
+
constructor(fileBuffer, alignment) {
|
|
16
|
+
this.debug = false;
|
|
17
|
+
this.currentByte = 0;
|
|
18
|
+
this.handledByte = 0;
|
|
19
|
+
this.maxByte = 0;
|
|
20
|
+
this.getAmountAllocatedLeft = () => this.bufferView.byteLength - this.currentByte;
|
|
21
|
+
this.getBufferPosition = () => this.currentByte;
|
|
22
|
+
this.getBufferSlice = (begin, end) => this.bufferView.buffer.slice(begin, end);
|
|
23
|
+
this.getBufferProgress = () => this.currentByte / this.bufferView.buffer.byteLength;
|
|
24
|
+
this.getBufferLength = () => this.bufferView.buffer.byteLength;
|
|
25
|
+
this.getBuffer = () => this.bufferView.buffer;
|
|
26
|
+
this.alignment = alignment;
|
|
27
|
+
this.reset(fileBuffer);
|
|
28
|
+
}
|
|
29
|
+
reset(newFileBuffer) {
|
|
30
|
+
this.fileBuffer = newFileBuffer;
|
|
31
|
+
this.bufferView = new DataView(newFileBuffer, 0, Math.min(102400, this.fileBuffer.byteLength));
|
|
32
|
+
this.maxByte = newFileBuffer.byteLength;
|
|
33
|
+
this.currentByte = 0;
|
|
34
|
+
this.handledByte = 0;
|
|
35
|
+
}
|
|
36
|
+
skipBytes(byteLength = 1) {
|
|
37
|
+
this.currentByte += byteLength;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
readByte() {
|
|
41
|
+
return parseInt(this.bufferView.getUint8(this.currentByte++).toString());
|
|
42
|
+
}
|
|
43
|
+
readBytes(count) {
|
|
44
|
+
return new Uint8Array(new Array(count).fill(0).map(pl => this.bufferView.getUint8(this.currentByte++)));
|
|
45
|
+
}
|
|
46
|
+
readHex(hexLength) {
|
|
47
|
+
let hexPart = [];
|
|
48
|
+
for (let i = 0; i < hexLength; i++) {
|
|
49
|
+
let currentHex = String.fromCharCode(this.bufferView.getUint8(this.currentByte++));
|
|
50
|
+
hexPart.push(currentHex);
|
|
51
|
+
}
|
|
52
|
+
return hexPart.join('');
|
|
53
|
+
}
|
|
54
|
+
readInt8() {
|
|
55
|
+
let data = this.bufferView.getInt8(this.currentByte++);
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
readUint8() {
|
|
59
|
+
let data = this.bufferView.getUint8(this.currentByte++);
|
|
60
|
+
return data;
|
|
61
|
+
}
|
|
62
|
+
readInt16() {
|
|
63
|
+
let data = this.bufferView.getInt16(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
64
|
+
this.currentByte += 2;
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
readUint16() {
|
|
68
|
+
let data = this.bufferView.getUint16(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
69
|
+
this.currentByte += 2;
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
readInt32() {
|
|
73
|
+
let data = this.bufferView.getInt32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
74
|
+
this.currentByte += 4;
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
readUint32() {
|
|
78
|
+
let data = this.bufferView.getUint32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
79
|
+
this.currentByte += 4;
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
readLong() {
|
|
83
|
+
let data = this.bufferView.getBigInt64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
84
|
+
this.currentByte += 8;
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
readInt64() {
|
|
88
|
+
return this.readLong();
|
|
89
|
+
}
|
|
90
|
+
readUint64() {
|
|
91
|
+
let data = this.bufferView.getBigUint64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
92
|
+
this.currentByte += 8;
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
readFloat32() {
|
|
96
|
+
let data = this.bufferView.getFloat32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
97
|
+
this.currentByte += 4;
|
|
98
|
+
return data;
|
|
99
|
+
}
|
|
100
|
+
readDouble() {
|
|
101
|
+
let data = this.bufferView.getFloat64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
102
|
+
this.currentByte += 8;
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
readString() {
|
|
106
|
+
let strLength = this.readInt32();
|
|
107
|
+
let startBytes = this.currentByte;
|
|
108
|
+
if (strLength === 0) {
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
if (strLength > (this.bufferView.buffer.byteLength - this.currentByte)) {
|
|
112
|
+
let errorMessage = `Cannot read string of length ${strLength} at position ${this.currentByte} as it exceeds the end at ${this.bufferView.buffer.byteLength}`;
|
|
113
|
+
throw new Error(errorMessage);
|
|
114
|
+
}
|
|
115
|
+
if (strLength < 0) {
|
|
116
|
+
const string = new Array(-strLength - 1).fill('').map(c => String.fromCharCode(this.readUint16()));
|
|
117
|
+
this.currentByte += 2;
|
|
118
|
+
return string.join('');
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const string = new Array(strLength - 1).fill('').map(c => String.fromCharCode(this.readUint8()));
|
|
122
|
+
this.currentByte += 1;
|
|
123
|
+
return string.join('');
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
let errorMessage = `Cannot read UTF8 string of length ${strLength} at position ${this.currentByte}.`;
|
|
127
|
+
console.log(errorMessage, error);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
allocate(count) {
|
|
132
|
+
if (this.currentByte + count < this.bufferView.byteLength) {
|
|
133
|
+
console.warn('tried to allocate but there is not enough data left.');
|
|
134
|
+
}
|
|
135
|
+
return Promise.resolve();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.ByteReader = ByteReader;
|
|
139
|
+
});
|