@etothepii/satisfactory-file-parser 0.0.32 → 0.0.34
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/build/index.js +41 -51
- package/build/parser/byte/alignment.enum.js +8 -18
- package/build/parser/byte/binary-operable.interface.js +2 -12
- package/build/parser/byte/binary-readable.interface.js +2 -12
- package/build/parser/byte/byte-reader.class.js +122 -132
- package/build/parser/byte/byte-writer.class.js +133 -143
- package/build/parser/error/parser.error.js +40 -50
- package/build/parser/file.types.js +2 -12
- package/build/parser/parser.d.ts +0 -9
- package/build/parser/parser.js +84 -192
- package/build/parser/satisfactory/blueprint/blueprint-reader.js +109 -119
- package/build/parser/satisfactory/blueprint/blueprint-writer.js +56 -66
- package/build/parser/satisfactory/blueprint/blueprint.types.js +2 -12
- package/build/parser/satisfactory/objects/DataFields.js +297 -307
- package/build/parser/satisfactory/objects/ObjectReference.js +14 -24
- package/build/parser/satisfactory/objects/Property.js +967 -977
- package/build/parser/satisfactory/objects/SaveComponent.js +28 -38
- package/build/parser/satisfactory/objects/SaveEntity.js +65 -75
- package/build/parser/satisfactory/objects/SaveObject.js +26 -36
- package/build/parser/satisfactory/save/asynchronous-level.class.js +60 -70
- package/build/parser/satisfactory/save/level.class.js +122 -133
- package/build/parser/satisfactory/save/satisfactory-save.js +10 -20
- package/build/parser/satisfactory/save/save-reader.js +158 -168
- package/build/parser/satisfactory/save/save-writer.js +97 -107
- package/build/parser/satisfactory/save/save.types.js +2 -12
- package/build/parser/satisfactory/structs/util.types.js +89 -99
- package/build/parser/stream/byte-stream-reader.class.js +217 -227
- package/build/parser/stream/json-stream-state-writer.js +15 -25
- package/build/parser/stream/json-stream-writable.js +72 -82
- package/build/parser/stream/json-stream-writer.js +122 -132
- package/build/parser/stream/save-stream-json-stringifier.js +29 -39
- package/build/parser/stream/save-stream-reader.class.js +106 -116
- package/build/parser/stream/save-stream-writer.class.js +90 -100
- package/build/parser/stream/stream-level.class.js +93 -103
- package/package.json +1 -1
|
@@ -1,149 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
writeString(value) {
|
|
92
|
-
if (value.length === 0) {
|
|
93
|
-
this.writeInt32(0);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (ByteWriter.IsASCIICompatible(value)) {
|
|
97
|
-
this.writeInt32(value.length + 1);
|
|
98
|
-
for (let i = 0; i < value.length; i++) {
|
|
99
|
-
this.writeByte(value.charCodeAt(i));
|
|
100
|
-
}
|
|
101
|
-
this.writeUint8(0);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
this.writeInt32(-value.length - 1);
|
|
105
|
-
for (let i = 0; i < value.length; i++) {
|
|
106
|
-
this.writeUint16(value.charCodeAt(i));
|
|
107
|
-
}
|
|
108
|
-
this.writeUint16(0);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ByteWriter = void 0;
|
|
4
|
+
const alignment_enum_1 = require("./alignment.enum");
|
|
5
|
+
class ByteWriter {
|
|
6
|
+
constructor(alignment, bufferSize = 500) {
|
|
7
|
+
this.getBufferPosition = () => this.currentByte;
|
|
8
|
+
this.getBufferSlice = (start, end) => this.bufferArray.slice(start, end);
|
|
9
|
+
this.alignment = alignment;
|
|
10
|
+
this.bufferArray = new ArrayBuffer(bufferSize);
|
|
11
|
+
this.bufferView = new DataView(this.bufferArray);
|
|
12
|
+
this.currentByte = 0;
|
|
13
|
+
}
|
|
14
|
+
skipBytes(count = 1) {
|
|
15
|
+
this.extendBufferIfNeeded(count);
|
|
16
|
+
this.currentByte += count;
|
|
17
|
+
}
|
|
18
|
+
jumpTo(pos) {
|
|
19
|
+
const count = pos - this.getBufferPosition();
|
|
20
|
+
this.skipBytes(count);
|
|
21
|
+
}
|
|
22
|
+
writeByte(value) {
|
|
23
|
+
this.extendBufferIfNeeded(1);
|
|
24
|
+
this.bufferView.setUint8(this.currentByte, value);
|
|
25
|
+
this.currentByte += 1;
|
|
26
|
+
}
|
|
27
|
+
writeBytesArray(bytes) {
|
|
28
|
+
this.writeBytes(new Uint8Array(bytes));
|
|
29
|
+
}
|
|
30
|
+
writeBytes(bytes) {
|
|
31
|
+
this.extendBufferIfNeeded(bytes.length);
|
|
32
|
+
bytes.forEach(byte => this.bufferView.setUint8(this.currentByte++, byte));
|
|
33
|
+
}
|
|
34
|
+
writeInt8(value) {
|
|
35
|
+
this.extendBufferIfNeeded(1);
|
|
36
|
+
this.bufferView.setInt8(this.currentByte, value);
|
|
37
|
+
this.currentByte += 1;
|
|
38
|
+
}
|
|
39
|
+
writeUint8(value) {
|
|
40
|
+
this.writeByte(value);
|
|
41
|
+
}
|
|
42
|
+
writeInt16(value) {
|
|
43
|
+
this.extendBufferIfNeeded(2);
|
|
44
|
+
this.bufferView.setInt16(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
45
|
+
this.currentByte += 2;
|
|
46
|
+
}
|
|
47
|
+
writeUint16(value) {
|
|
48
|
+
this.extendBufferIfNeeded(2);
|
|
49
|
+
this.bufferView.setUint16(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
50
|
+
this.currentByte += 2;
|
|
51
|
+
}
|
|
52
|
+
writeInt32(value) {
|
|
53
|
+
this.extendBufferIfNeeded(4);
|
|
54
|
+
this.bufferView.setInt32(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
55
|
+
this.currentByte += 4;
|
|
56
|
+
}
|
|
57
|
+
writeUint32(value) {
|
|
58
|
+
this.extendBufferIfNeeded(4);
|
|
59
|
+
this.bufferView.setUint32(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
60
|
+
this.currentByte += 4;
|
|
61
|
+
}
|
|
62
|
+
writeInt64(value) {
|
|
63
|
+
this.extendBufferIfNeeded(8);
|
|
64
|
+
this.bufferView.setBigInt64(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
65
|
+
this.currentByte += 8;
|
|
66
|
+
}
|
|
67
|
+
writeUint64(value) {
|
|
68
|
+
this.extendBufferIfNeeded(8);
|
|
69
|
+
this.bufferView.setBigUint64(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
70
|
+
this.currentByte += 8;
|
|
71
|
+
}
|
|
72
|
+
writeFloat(value) {
|
|
73
|
+
this.extendBufferIfNeeded(4);
|
|
74
|
+
this.bufferView.setFloat32(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
75
|
+
this.currentByte += 4;
|
|
76
|
+
}
|
|
77
|
+
writeDouble(value) {
|
|
78
|
+
this.extendBufferIfNeeded(8);
|
|
79
|
+
this.bufferView.setFloat64(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
80
|
+
this.currentByte += 8;
|
|
81
|
+
}
|
|
82
|
+
writeString(value) {
|
|
83
|
+
if (value.length === 0) {
|
|
84
|
+
this.writeInt32(0);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (ByteWriter.IsASCIICompatible(value)) {
|
|
88
|
+
this.writeInt32(value.length + 1);
|
|
89
|
+
for (let i = 0; i < value.length; i++) {
|
|
90
|
+
this.writeByte(value.charCodeAt(i));
|
|
109
91
|
}
|
|
92
|
+
this.writeUint8(0);
|
|
110
93
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.writeInt32(writtenBytes);
|
|
116
|
-
this.jumpTo(after);
|
|
117
|
-
}
|
|
118
|
-
extendBufferIfNeeded(countNeededBytes, factor = 1.5) {
|
|
119
|
-
if (this.currentByte + countNeededBytes > this.bufferView.byteLength) {
|
|
120
|
-
this.bufferArray = ByteWriter.AppendBuffer(this.bufferArray, new ArrayBuffer(factor * this.bufferArray.byteLength));
|
|
121
|
-
this.bufferView = new DataView(this.bufferArray);
|
|
94
|
+
else {
|
|
95
|
+
this.writeInt32(-value.length - 1);
|
|
96
|
+
for (let i = 0; i < value.length; i++) {
|
|
97
|
+
this.writeUint16(value.charCodeAt(i));
|
|
122
98
|
}
|
|
99
|
+
this.writeUint16(0);
|
|
123
100
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
(num & 0x000000ff)
|
|
137
|
-
]);
|
|
138
|
-
}
|
|
139
|
-
static AppendBuffer(buffer1, buffer2) {
|
|
140
|
-
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
|
|
141
|
-
tmp.set(new Uint8Array(buffer1), 0);
|
|
142
|
-
tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
|
|
143
|
-
return tmp.buffer;
|
|
101
|
+
}
|
|
102
|
+
writeBinarySizeFromPosition(lenIndicatorPos, start) {
|
|
103
|
+
const after = this.getBufferPosition();
|
|
104
|
+
const writtenBytes = after - start;
|
|
105
|
+
this.jumpTo(lenIndicatorPos);
|
|
106
|
+
this.writeInt32(writtenBytes);
|
|
107
|
+
this.jumpTo(after);
|
|
108
|
+
}
|
|
109
|
+
extendBufferIfNeeded(countNeededBytes, factor = 1.5) {
|
|
110
|
+
if (this.currentByte + countNeededBytes > this.bufferView.byteLength) {
|
|
111
|
+
this.bufferArray = ByteWriter.AppendBuffer(this.bufferArray, new ArrayBuffer(factor * this.bufferArray.byteLength));
|
|
112
|
+
this.bufferView = new DataView(this.bufferArray);
|
|
144
113
|
}
|
|
145
|
-
;
|
|
146
114
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
115
|
+
truncateBuffer() {
|
|
116
|
+
this.bufferArray = this.bufferArray.slice(0, this.currentByte);
|
|
117
|
+
}
|
|
118
|
+
endWriting() {
|
|
119
|
+
this.truncateBuffer();
|
|
120
|
+
return this.bufferArray;
|
|
121
|
+
}
|
|
122
|
+
static ToInt32(num) {
|
|
123
|
+
return new Uint8Array([
|
|
124
|
+
(num & 0xff000000) >> 24,
|
|
125
|
+
(num & 0x00ff0000) >> 16,
|
|
126
|
+
(num & 0x0000ff00) >> 8,
|
|
127
|
+
(num & 0x000000ff)
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
static AppendBuffer(buffer1, buffer2) {
|
|
131
|
+
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
|
|
132
|
+
tmp.set(new Uint8Array(buffer1), 0);
|
|
133
|
+
tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
|
|
134
|
+
return tmp.buffer;
|
|
135
|
+
}
|
|
136
|
+
;
|
|
137
|
+
}
|
|
138
|
+
ByteWriter.IsASCIICompatible = (value) => /^[\x00-\x7F]*$/.test(value);
|
|
139
|
+
exports.ByteWriter = ByteWriter;
|
|
@@ -1,50 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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;
|
|
50
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnimplementedError = exports.TimeoutError = exports.CompressionLibraryError = exports.CorruptSaveError = exports.UnsupportedVersionError = exports.ParserError = void 0;
|
|
4
|
+
class ParserError extends Error {
|
|
5
|
+
constructor(name, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = name;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ParserError = ParserError;
|
|
11
|
+
class UnsupportedVersionError extends ParserError {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super('UnsupportedVersionError', message ?? 'This save version is not supported.');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.UnsupportedVersionError = UnsupportedVersionError;
|
|
17
|
+
class CorruptSaveError extends ParserError {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super('CorruptSaveError', message ?? 'This save data is most likely corrupt.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.CorruptSaveError = CorruptSaveError;
|
|
23
|
+
class CompressionLibraryError extends ParserError {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super('CompressionLibraryError', message ?? 'Failed to compress/decompress save data.');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.CompressionLibraryError = CompressionLibraryError;
|
|
29
|
+
class TimeoutError extends ParserError {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super('TimeoutError', message ?? 'Operation timed out.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.TimeoutError = TimeoutError;
|
|
35
|
+
class UnimplementedError extends ParserError {
|
|
36
|
+
constructor(message) {
|
|
37
|
+
super('UnimplementedError', message ?? 'Unimplemented Operation.');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.UnimplementedError = UnimplementedError;
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/build/parser/parser.d.ts
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { TransformStream, WritableStream } from "stream/web";
|
|
4
2
|
import { ChunkSummary } from "./file.types";
|
|
5
3
|
import { Blueprint } from "./satisfactory/blueprint/blueprint.types";
|
|
6
4
|
import { SatisfactorySave } from "./satisfactory/save/satisfactory-save";
|
|
7
5
|
import { SaveProjectionConfig } from "./satisfactory/save/save-reader";
|
|
8
|
-
export declare class PassthroughWebTransform extends TransformStream<Uint8Array, Uint8Array> {
|
|
9
|
-
constructor();
|
|
10
|
-
}
|
|
11
6
|
export declare class Parser {
|
|
12
7
|
static WriteSave(save: SatisfactorySave, onBinaryBeforeCompressing: (buffer: ArrayBuffer) => void, onHeader: (header: Uint8Array) => void, onChunk: (chunk: Uint8Array) => void): ChunkSummary[];
|
|
13
|
-
private static ParseSaveFileStream;
|
|
14
|
-
private static ParseStreamSave;
|
|
15
|
-
private static DecompressStreamSave;
|
|
16
8
|
static ParseSaveFile(file: Buffer, onDecompressedSaveBody?: (buffer: ArrayBuffer) => void, onProgress?: (progress: number, message?: string) => void): SatisfactorySave;
|
|
17
|
-
static ParseSaveFileAsynchronousToOutput(file: Buffer, outputJson: WritableStream<string>, onDecompressedSaveBody?: (buffer: ArrayBuffer) => void, onProgress?: (progress: number, message?: string) => void): Promise<SatisfactorySave>;
|
|
18
9
|
static WriteBlueprintFiles(blueprint: Blueprint, onMainFileBinaryBeforeCompressing?: (binary: ArrayBuffer) => void, onMainFileHeader?: (header: Uint8Array) => void, onMainFileChunk?: (chunk: Uint8Array) => void): {
|
|
19
10
|
mainFileChunkSummary: ChunkSummary[];
|
|
20
11
|
configFileBinary: ArrayBuffer;
|