@etothepii/satisfactory-file-parser 0.0.31 → 0.0.33
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 +5 -1
- package/build/index.js +7 -7
- 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 +11 -9
- package/build/parser/byte/byte-reader.class.js +23 -15
- package/build/parser/error/parser.error.d.ts +6 -0
- package/build/parser/error/parser.error.js +13 -1
- package/build/parser/satisfactory/blueprint/blueprint-reader.d.ts +3 -2
- package/build/parser/satisfactory/blueprint/blueprint-writer.js +1 -1
- package/build/parser/satisfactory/objects/DataFields.d.ts +34 -6
- package/build/parser/satisfactory/objects/DataFields.js +86 -3
- package/build/parser/satisfactory/objects/ObjectReference.d.ts +2 -2
- package/build/parser/satisfactory/objects/Property.d.ts +72 -72
- package/build/parser/satisfactory/objects/Property.js +24 -23
- package/build/parser/satisfactory/objects/SaveComponent.d.ts +8 -5
- package/build/parser/satisfactory/objects/SaveComponent.js +2 -2
- package/build/parser/satisfactory/objects/SaveEntity.d.ts +9 -4
- package/build/parser/satisfactory/objects/SaveEntity.js +2 -2
- package/build/parser/satisfactory/objects/SaveObject.d.ts +9 -4
- package/build/parser/satisfactory/objects/SaveObject.js +3 -3
- 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 +5 -5
- package/build/parser/satisfactory/save/level.class.js +6 -6
- package/build/parser/satisfactory/save/save-reader.d.ts +4 -13
- package/build/parser/satisfactory/save/save-reader.js +17 -72
- package/build/parser/satisfactory/structs/util.types.d.ts +7 -7
- package/build/parser/satisfactory/structs/util.types.js +10 -10
- 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 +3 -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
CHANGED
|
@@ -7,6 +7,8 @@ export { SaveEntity } from './parser/satisfactory/objects/SaveEntity';
|
|
|
7
7
|
export { Level } from './parser/satisfactory/save/level.class';
|
|
8
8
|
export { SatisfactorySave } from './parser/satisfactory/save/satisfactory-save';
|
|
9
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';
|
|
10
12
|
export { ByteReader } from './parser/byte/byte-reader.class';
|
|
11
13
|
export { ByteWriter } from './parser/byte/byte-writer.class';
|
|
12
14
|
export { BlueprintConfigReader, BlueprintReader } from './parser/satisfactory/blueprint/blueprint-reader';
|
|
@@ -14,6 +16,8 @@ export { BlueprintConfigWriter, BlueprintWriter } from './parser/satisfactory/bl
|
|
|
14
16
|
export { SaveReader } from './parser/satisfactory/save/save-reader';
|
|
15
17
|
export { SaveWriter } from './parser/satisfactory/save/save-writer';
|
|
16
18
|
export * from './parser/satisfactory/structs/util.types';
|
|
17
|
-
export {
|
|
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';
|
|
18
22
|
export * from './parser/file.types';
|
|
19
23
|
export { Parser } from './parser/parser';
|
package/build/index.js
CHANGED
|
@@ -18,12 +18,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
if (v !== undefined) module.exports = v;
|
|
19
19
|
}
|
|
20
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/error/parser.error", "./parser/file.types", "./parser/parser"], factory);
|
|
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
22
|
}
|
|
23
23
|
})(function (require, exports) {
|
|
24
24
|
"use strict";
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Parser = exports.
|
|
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
27
|
__exportStar(require("./parser/satisfactory/blueprint/blueprint.types"), exports);
|
|
28
28
|
var DataFields_1 = require("./parser/satisfactory/objects/DataFields");
|
|
29
29
|
Object.defineProperty(exports, "DataFields", { enumerable: true, get: function () { return DataFields_1.DataFields; } });
|
|
@@ -54,11 +54,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
54
54
|
var save_writer_1 = require("./parser/satisfactory/save/save-writer");
|
|
55
55
|
Object.defineProperty(exports, "SaveWriter", { enumerable: true, get: function () { return save_writer_1.SaveWriter; } });
|
|
56
56
|
__exportStar(require("./parser/satisfactory/structs/util.types"), exports);
|
|
57
|
-
var
|
|
58
|
-
Object.defineProperty(exports, "
|
|
59
|
-
|
|
60
|
-
Object.defineProperty(exports, "
|
|
61
|
-
|
|
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
62
|
__exportStar(require("./parser/file.types"), exports);
|
|
63
63
|
var parser_1 = require("./parser/parser");
|
|
64
64
|
Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return parser_1.Parser; } });
|
|
@@ -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
|
+
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Alignment } from "./alignment.enum";
|
|
2
|
-
|
|
2
|
+
import { BinaryReadable } from "./binary-readable.interface";
|
|
3
|
+
export declare abstract class ByteReader implements BinaryReadable {
|
|
3
4
|
protected bufferView: DataView;
|
|
4
5
|
protected fileBuffer: ArrayBuffer;
|
|
5
|
-
|
|
6
|
+
alignment: Alignment;
|
|
7
|
+
debug: boolean;
|
|
6
8
|
protected currentByte: number;
|
|
7
9
|
protected handledByte: number;
|
|
8
10
|
protected maxByte: number;
|
|
9
|
-
protected lastStrRead: number;
|
|
10
11
|
constructor(fileBuffer: ArrayBuffer, alignment: Alignment);
|
|
11
12
|
reset(newFileBuffer: ArrayBuffer): void;
|
|
12
13
|
skipBytes(byteLength?: number): void;
|
|
@@ -15,20 +16,21 @@ export declare abstract class ByteReader {
|
|
|
15
16
|
readHex(hexLength: number): string;
|
|
16
17
|
readInt8(): number;
|
|
17
18
|
readUint8(): number;
|
|
19
|
+
readInt16(): number;
|
|
18
20
|
readUint16(): number;
|
|
19
21
|
readInt32(): number;
|
|
20
22
|
readUint32(): number;
|
|
21
23
|
readLong(): bigint;
|
|
22
|
-
|
|
24
|
+
readInt64(): bigint;
|
|
25
|
+
readUint64(): bigint;
|
|
26
|
+
readFloat32(): number;
|
|
23
27
|
readDouble(): number;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
+
readString(): string;
|
|
29
|
+
allocate(count: number): Promise<void>;
|
|
30
|
+
getAmountAllocatedLeft: () => number;
|
|
28
31
|
getBufferPosition: () => number;
|
|
29
32
|
getBufferSlice: (begin: number, end: number | undefined) => ArrayBuffer;
|
|
30
33
|
getBufferProgress: () => number;
|
|
31
34
|
getBufferLength: () => number;
|
|
32
35
|
getBuffer: () => ArrayBuffer;
|
|
33
|
-
readString(): string;
|
|
34
36
|
}
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
const alignment_enum_1 = require("./alignment.enum");
|
|
14
14
|
class ByteReader {
|
|
15
15
|
constructor(fileBuffer, alignment) {
|
|
16
|
+
this.debug = false;
|
|
16
17
|
this.currentByte = 0;
|
|
17
18
|
this.handledByte = 0;
|
|
18
19
|
this.maxByte = 0;
|
|
19
|
-
this.
|
|
20
|
+
this.getAmountAllocatedLeft = () => this.bufferView.byteLength - this.currentByte;
|
|
20
21
|
this.getBufferPosition = () => this.currentByte;
|
|
21
22
|
this.getBufferSlice = (begin, end) => this.bufferView.buffer.slice(begin, end);
|
|
22
23
|
this.getBufferProgress = () => this.currentByte / this.bufferView.buffer.byteLength;
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
}
|
|
35
36
|
skipBytes(byteLength = 1) {
|
|
36
37
|
this.currentByte += byteLength;
|
|
38
|
+
return;
|
|
37
39
|
}
|
|
38
40
|
readByte() {
|
|
39
41
|
return parseInt(this.bufferView.getUint8(this.currentByte++).toString());
|
|
@@ -57,6 +59,11 @@
|
|
|
57
59
|
let data = this.bufferView.getUint8(this.currentByte++);
|
|
58
60
|
return data;
|
|
59
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
|
+
}
|
|
60
67
|
readUint16() {
|
|
61
68
|
let data = this.bufferView.getUint16(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
62
69
|
this.currentByte += 2;
|
|
@@ -77,7 +84,15 @@
|
|
|
77
84
|
this.currentByte += 8;
|
|
78
85
|
return data;
|
|
79
86
|
}
|
|
80
|
-
|
|
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() {
|
|
81
96
|
let data = this.bufferView.getFloat32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
82
97
|
this.currentByte += 4;
|
|
83
98
|
return data;
|
|
@@ -87,21 +102,8 @@
|
|
|
87
102
|
this.currentByte += 8;
|
|
88
103
|
return data;
|
|
89
104
|
}
|
|
90
|
-
getStringInfo() {
|
|
91
|
-
let payload = '';
|
|
92
|
-
let counter = this.currentByte;
|
|
93
|
-
try {
|
|
94
|
-
let strLength = this.bufferView.getInt32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
95
|
-
counter += 4;
|
|
96
|
-
payload = new Array(strLength - 1).fill('').map(c => String.fromCharCode(this.bufferView.getUint8(counter++))).join('');
|
|
97
|
-
}
|
|
98
|
-
catch (error) { }
|
|
99
|
-
this.currentByte -= counter;
|
|
100
|
-
return { payload, counter };
|
|
101
|
-
}
|
|
102
105
|
readString() {
|
|
103
106
|
let strLength = this.readInt32();
|
|
104
|
-
this.lastStrRead = strLength;
|
|
105
107
|
let startBytes = this.currentByte;
|
|
106
108
|
if (strLength === 0) {
|
|
107
109
|
return '';
|
|
@@ -126,6 +128,12 @@
|
|
|
126
128
|
throw error;
|
|
127
129
|
}
|
|
128
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
|
+
}
|
|
129
137
|
}
|
|
130
138
|
exports.ByteReader = ByteReader;
|
|
131
139
|
});
|
|
@@ -10,3 +10,9 @@ export declare class CorruptSaveError extends ParserError {
|
|
|
10
10
|
export declare class CompressionLibraryError extends ParserError {
|
|
11
11
|
constructor(message?: string);
|
|
12
12
|
}
|
|
13
|
+
export declare class TimeoutError extends ParserError {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class UnimplementedError extends ParserError {
|
|
17
|
+
constructor(message?: string);
|
|
18
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CompressionLibraryError = exports.CorruptSaveError = exports.UnsupportedVersionError = exports.ParserError = void 0;
|
|
12
|
+
exports.UnimplementedError = exports.TimeoutError = exports.CompressionLibraryError = exports.CorruptSaveError = exports.UnsupportedVersionError = exports.ParserError = void 0;
|
|
13
13
|
class ParserError extends Error {
|
|
14
14
|
constructor(name, message) {
|
|
15
15
|
super(message);
|
|
@@ -35,4 +35,16 @@
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
exports.CompressionLibraryError = CompressionLibraryError;
|
|
38
|
+
class TimeoutError extends ParserError {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super('TimeoutError', message ?? 'Operation timed out.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.TimeoutError = TimeoutError;
|
|
44
|
+
class UnimplementedError extends ParserError {
|
|
45
|
+
constructor(message) {
|
|
46
|
+
super('UnimplementedError', message ?? 'Unimplemented Operation.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.UnimplementedError = UnimplementedError;
|
|
38
50
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BinaryReadable } from "../../byte/binary-readable.interface";
|
|
1
2
|
import { ByteReader } from "../../byte/byte-reader.class";
|
|
2
3
|
import { ChunkCompressionInfo } from "../../file.types";
|
|
3
4
|
import { SaveComponent } from "../objects/SaveComponent";
|
|
@@ -6,7 +7,7 @@ import { BlueprintConfig, BlueprintHeader } from "./blueprint.types";
|
|
|
6
7
|
export declare class BlueprintReader extends ByteReader {
|
|
7
8
|
compressionInfo: ChunkCompressionInfo;
|
|
8
9
|
constructor(bluePrintBuffer: ArrayBuffer);
|
|
9
|
-
static ReadHeader(reader:
|
|
10
|
+
static ReadHeader(reader: BinaryReadable): BlueprintHeader;
|
|
10
11
|
inflateChunks(): any;
|
|
11
12
|
static ParseObjects(reader: ByteReader): (SaveEntity | SaveComponent)[];
|
|
12
13
|
}
|
|
@@ -14,5 +15,5 @@ export declare class BlueprintConfigReader extends ByteReader {
|
|
|
14
15
|
bluePrintConfigBuffer: ArrayBuffer;
|
|
15
16
|
constructor(bluePrintConfigBuffer: ArrayBuffer);
|
|
16
17
|
parse: () => BlueprintConfig;
|
|
17
|
-
static ParseConfig(reader:
|
|
18
|
+
static ParseConfig(reader: BinaryReadable): BlueprintConfig;
|
|
18
19
|
}
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
writer.writeInt32(0);
|
|
55
55
|
level_class_1.Level.SerializeObjectHeaders(writer, objects);
|
|
56
56
|
writer.writeBinarySizeFromPosition(headersLenIndicator, headersLenIndicator + 4);
|
|
57
|
-
level_class_1.Level.SerializeObjectContents(writer, objects, 0);
|
|
57
|
+
level_class_1.Level.SerializeObjectContents(writer, objects, 0, '');
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
exports.BlueprintWriter = BlueprintWriter;
|
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ByteWriter } from "../../..";
|
|
2
|
+
import { BinaryReadable } from "../../byte/binary-readable.interface";
|
|
2
3
|
import { SaveWriter } from "../save/save-writer";
|
|
4
|
+
import { vec3 } from "../structs/util.types";
|
|
5
|
+
import { ObjectReference } from "./ObjectReference";
|
|
3
6
|
import { AbstractBaseProperty } from "./Property";
|
|
7
|
+
export type SpecialAnyProperty = {} | PowerLineSpecialProperty;
|
|
8
|
+
export type PowerLineSpecialProperty = {
|
|
9
|
+
num: number;
|
|
10
|
+
source: ObjectReference;
|
|
11
|
+
target: ObjectReference;
|
|
12
|
+
sourceTranslation?: vec3;
|
|
13
|
+
targetTranslation?: vec3;
|
|
14
|
+
};
|
|
15
|
+
export type PlayerSpecialProperty = {
|
|
16
|
+
flag: number;
|
|
17
|
+
eosData?: string;
|
|
18
|
+
steamPlayerData?: string;
|
|
19
|
+
};
|
|
20
|
+
export type ItemSpecialProperty = {
|
|
21
|
+
length: number;
|
|
22
|
+
name: string;
|
|
23
|
+
position: number;
|
|
24
|
+
pathName: string;
|
|
25
|
+
};
|
|
26
|
+
export type ConveyorSpecialProperty = {
|
|
27
|
+
items: ItemSpecialProperty[];
|
|
28
|
+
};
|
|
4
29
|
export declare class DataFields {
|
|
5
|
-
properties:
|
|
30
|
+
properties: AbstractBaseProperty[];
|
|
31
|
+
specialProperties: SpecialAnyProperty;
|
|
6
32
|
trailingData: number[];
|
|
7
33
|
shouldBeNulled: boolean;
|
|
8
34
|
constructor();
|
|
9
|
-
static Parse(length: number, reader:
|
|
10
|
-
static
|
|
11
|
-
static
|
|
12
|
-
static
|
|
35
|
+
static Parse(length: number, reader: BinaryReadable, buildVersion: number, typePath: string): DataFields;
|
|
36
|
+
static ParseAdditionalSpecialProperties(reader: BinaryReadable, typePath: string, remainingLen: number): SpecialAnyProperty;
|
|
37
|
+
static ParseProperty(reader: BinaryReadable, buildVersion: number, propertyName: string): AbstractBaseProperty | null;
|
|
38
|
+
static Serialize(writer: SaveWriter, fields: DataFields, buildVersion: number, typePath: string): void;
|
|
39
|
+
static SerializeAdditionalSpecialProperties(writer: ByteWriter, typePath: string, property: SpecialAnyProperty): void;
|
|
40
|
+
static SerializeProperty(writer: ByteWriter, property: AbstractBaseProperty, propertyName: string, buildVersion: number): void;
|
|
13
41
|
}
|