@etothepii/satisfactory-file-parser 0.4.13 → 0.4.14
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/CHANGELOG.md +12 -0
- package/README.md +43 -22
- package/build/parser/byte/binary-readable.interface.d.ts +0 -3
- package/build/parser/byte/binary-writable.interface.d.ts +20 -0
- package/build/parser/byte/binary-writable.interface.js +2 -0
- package/build/parser/byte/byte-reader.class.d.ts +0 -3
- package/build/parser/byte/byte-reader.class.js +0 -8
- package/build/parser/byte/byte-writer.class.d.ts +6 -3
- package/build/parser/byte/byte-writer.class.js +3 -1
- package/build/parser/satisfactory/blueprint/blueprint-reader.js +8 -8
- package/build/parser/satisfactory/edit/edit-constants.d.ts +2 -0
- package/build/parser/satisfactory/edit/edit-constants.js +82 -158
- package/build/parser/satisfactory/objects/DataFields.js +9 -9
- package/build/parser/satisfactory/objects/SaveObject.d.ts +1 -1
- package/build/parser/satisfactory/objects/SaveObject.js +1 -1
- package/build/parser/satisfactory/objects/property/generic/FloatProperty.js +1 -1
- package/build/parser/satisfactory/objects/property/generic/StructProperty.js +11 -4
- package/build/parser/satisfactory/save/level.class.d.ts +1 -2
- package/build/parser/satisfactory/save/level.class.js +10 -15
- package/build/parser/satisfactory/save/save-reader.js +8 -4
- package/build/parser/satisfactory/save/save.types.d.ts +0 -25
- package/build/parser/satisfactory/structs/util.types.js +8 -8
- package/build/parser/stream/reworked/readable-stream-parser.d.ts +1 -0
- package/build/parser/stream/reworked/readable-stream-parser.js +28 -3
- package/package.json +1 -1
- package/build/parser/satisfactory/objects/ObjectReference.d.ts +0 -10
- package/build/parser/satisfactory/objects/ObjectReference.js +0 -17
- package/build/parser/satisfactory/objects/Property.d.ts +0 -272
- package/build/parser/satisfactory/objects/Property.js +0 -1177
- package/build/parser/satisfactory/objects/ue/FMD5Hash.d.ts +0 -7
- package/build/parser/satisfactory/objects/ue/FMD5Hash.js +0 -19
- package/build/parser/satisfactory/objects/ue/GUID.d.ts +0 -6
- package/build/parser/satisfactory/objects/ue/GUID.js +0 -21
- package/build/parser/satisfactory/save/asynchronous-level.class.d.ts +0 -9
- package/build/parser/satisfactory/save/asynchronous-level.class.js +0 -66
- package/build/parser/stream/byte-stream-reader.class.d.ts +0 -57
- package/build/parser/stream/byte-stream-reader.class.js +0 -241
- package/build/parser/stream/json-stream-state-writer.d.ts +0 -12
- package/build/parser/stream/json-stream-state-writer.js +0 -18
- package/build/parser/stream/json-stream-writable.d.ts +0 -20
- package/build/parser/stream/json-stream-writable.js +0 -83
- package/build/parser/stream/json-stream-writer.d.ts +0 -22
- package/build/parser/stream/json-stream-writer.js +0 -127
- package/build/parser/stream/reworked/stream-parser.d.ts +0 -6
- package/build/parser/stream/reworked/stream-parser.js +0 -31
- package/build/parser/stream/save-stream-json-stringifier.d.ts +0 -6
- package/build/parser/stream/save-stream-json-stringifier.js +0 -35
- package/build/parser/stream/save-stream-reader.class.d.ts +0 -15
- package/build/parser/stream/save-stream-reader.class.js +0 -121
- package/build/parser/stream/save-stream-writer.class.d.ts +0 -25
- package/build/parser/stream/save-stream-writer.class.js +0 -119
- package/build/parser/stream/stream-level.class.d.ts +0 -12
- package/build/parser/stream/stream-level.class.js +0 -103
- package/build/parser/stream/stream-parser.d.ts +0 -40
- package/build/parser/stream/stream-parser.js +0 -225
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ByteReader, ByteWriter } from '../../../..';
|
|
2
|
-
export type MD5Hash = {
|
|
3
|
-
isValid: boolean;
|
|
4
|
-
hash?: number[];
|
|
5
|
-
};
|
|
6
|
-
export declare const readMD5Hash: (reader: ByteReader) => MD5Hash;
|
|
7
|
-
export declare const writeMD5Hash: (writer: ByteWriter, md5Hash: MD5Hash) => void;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.writeMD5Hash = exports.readMD5Hash = void 0;
|
|
4
|
-
const readMD5Hash = (reader) => {
|
|
5
|
-
const md5Hash = { isValid: false };
|
|
6
|
-
md5Hash.isValid = reader.readInt32() === 1;
|
|
7
|
-
if (md5Hash.isValid) {
|
|
8
|
-
md5Hash.hash = Array.from(reader.readBytes(16));
|
|
9
|
-
}
|
|
10
|
-
return md5Hash;
|
|
11
|
-
};
|
|
12
|
-
exports.readMD5Hash = readMD5Hash;
|
|
13
|
-
const writeMD5Hash = (writer, md5Hash) => {
|
|
14
|
-
writer.writeInt32(md5Hash.isValid ? 1 : 0);
|
|
15
|
-
if (md5Hash.isValid) {
|
|
16
|
-
writer.writeBytesArray(md5Hash.hash);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.writeMD5Hash = writeMD5Hash;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GUID = void 0;
|
|
4
|
-
var GUID;
|
|
5
|
-
(function (GUID) {
|
|
6
|
-
GUID.read = (reader) => {
|
|
7
|
-
return [
|
|
8
|
-
reader.readUint32(),
|
|
9
|
-
reader.readUint32(),
|
|
10
|
-
reader.readUint32(),
|
|
11
|
-
reader.readUint32(),
|
|
12
|
-
];
|
|
13
|
-
};
|
|
14
|
-
GUID.write = (writer, guid) => {
|
|
15
|
-
writer.writeUint32(guid[0]);
|
|
16
|
-
writer.writeUint32(guid[1]);
|
|
17
|
-
writer.writeUint32(guid[2]);
|
|
18
|
-
writer.writeUint32(guid[3]);
|
|
19
|
-
};
|
|
20
|
-
})(GUID = exports.GUID || (exports.GUID = {}));
|
|
21
|
-
;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ByteReader } from "../../byte/byte-reader.class";
|
|
2
|
-
import { SaveStreamWriter } from "../../stream/save-stream-writer.class";
|
|
3
|
-
import { SaveObject } from "../objects/SaveObject";
|
|
4
|
-
import { Level } from "./level.class";
|
|
5
|
-
import { SaveReader } from "./save-reader";
|
|
6
|
-
export declare class AsynchronousLevel {
|
|
7
|
-
static StreamReadObjectContents(reader: ByteReader, objectsList: SaveObject[], buildVersion: number, writer: SaveStreamWriter, onProgressCallback: (progress: number, msg?: string) => void): Promise<void>;
|
|
8
|
-
static StreamReadLevel(reader: SaveReader, levelName: string, buildVersion: number, writer: SaveStreamWriter): Promise<Level>;
|
|
9
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsynchronousLevel = void 0;
|
|
4
|
-
const SaveComponent_1 = require("../objects/SaveComponent");
|
|
5
|
-
const SaveEntity_1 = require("../objects/SaveEntity");
|
|
6
|
-
const level_class_1 = require("./level.class");
|
|
7
|
-
class AsynchronousLevel {
|
|
8
|
-
static async StreamReadObjectContents(reader, objectsList, buildVersion, writer, onProgressCallback) {
|
|
9
|
-
const binarySize = reader.readInt32();
|
|
10
|
-
const posBefore = reader.getBufferPosition();
|
|
11
|
-
await reader.allocate(binarySize);
|
|
12
|
-
const countEntities = reader.readInt32();
|
|
13
|
-
if (countEntities !== objectsList.length) {
|
|
14
|
-
throw new Error(`possibly corrupt. entity content count ${countEntities} does not equal object count of ${objectsList.length}`);
|
|
15
|
-
}
|
|
16
|
-
let dynamicObjectBatch = [];
|
|
17
|
-
for (let i = 0; i < countEntities; i++) {
|
|
18
|
-
if (i % 1000 === 0) {
|
|
19
|
-
console.log(`having some objects, writing ${i + 1}/${countEntities}.`);
|
|
20
|
-
onProgressCallback(reader.getBufferProgress());
|
|
21
|
-
await writer.writeObjects(...dynamicObjectBatch);
|
|
22
|
-
dynamicObjectBatch = [];
|
|
23
|
-
}
|
|
24
|
-
const len = reader.readInt32();
|
|
25
|
-
const before = reader.getBufferPosition();
|
|
26
|
-
if (len < reader.getAmountAllocatedLeft()) {
|
|
27
|
-
await reader.allocate(Math.max(before - binarySize, 300 * 1000 * 1000));
|
|
28
|
-
}
|
|
29
|
-
const obj = objectsList[i];
|
|
30
|
-
if ((0, SaveEntity_1.isSaveEntity)(obj)) {
|
|
31
|
-
SaveEntity_1.SaveEntity.ParseData(obj, len, reader, buildVersion, obj.typePath);
|
|
32
|
-
}
|
|
33
|
-
else if ((0, SaveComponent_1.isSaveComponent)(obj)) {
|
|
34
|
-
SaveComponent_1.SaveComponent.ParseData(obj, len, reader, buildVersion, obj.typePath);
|
|
35
|
-
}
|
|
36
|
-
dynamicObjectBatch.push(obj);
|
|
37
|
-
const after = reader.getBufferPosition();
|
|
38
|
-
if (after - before !== len) {
|
|
39
|
-
console.warn('entity may be corrupt', this.name, i);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
await writer.writeObjects(...dynamicObjectBatch);
|
|
43
|
-
const posAfter = reader.getBufferPosition();
|
|
44
|
-
if (posAfter - posBefore !== binarySize) {
|
|
45
|
-
console.warn('save seems corrupt.', this.name);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
static async StreamReadLevel(reader, levelName, buildVersion, writer) {
|
|
49
|
-
const level = new level_class_1.Level(levelName);
|
|
50
|
-
const binaryLength = reader.readInt32();
|
|
51
|
-
await reader.allocate(binaryLength);
|
|
52
|
-
await writer.openLevel(levelName);
|
|
53
|
-
level_class_1.Level.ReadObjectHeaders(reader, level.objects, reader.onProgressCallback);
|
|
54
|
-
reader.onProgressCallback(reader.getBufferProgress());
|
|
55
|
-
level.collectables = level_class_1.Level.ReadCollectablesList(reader, undefined);
|
|
56
|
-
console.log(`before object contents buffer pos ${reader.getBufferPosition()}`);
|
|
57
|
-
await AsynchronousLevel.StreamReadObjectContents(reader, level.objects, buildVersion, writer, reader.onProgressCallback);
|
|
58
|
-
await writer.switchInLevelToCollectables();
|
|
59
|
-
await writer.writeCollectables(...level.collectables);
|
|
60
|
-
reader.onProgressCallback(reader.getBufferProgress());
|
|
61
|
-
level_class_1.Level.ReadCollectablesList(reader, undefined);
|
|
62
|
-
await writer.endLevel();
|
|
63
|
-
return level;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.AsynchronousLevel = AsynchronousLevel;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ReadableStreamDefaultReader } from "stream/web";
|
|
3
|
-
import { Alignment } from "../byte/alignment.enum";
|
|
4
|
-
import { BinaryReadable } from "../byte/binary-readable.interface";
|
|
5
|
-
export interface StreamBinaryReadable extends BinaryReadable {
|
|
6
|
-
pause: () => void;
|
|
7
|
-
resume: () => void;
|
|
8
|
-
hasInput: () => boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare abstract class ByteStreamReader implements StreamBinaryReadable {
|
|
11
|
-
private reader;
|
|
12
|
-
onCloseCallback: () => Promise<void>;
|
|
13
|
-
private timeout;
|
|
14
|
-
maxBufferThreshold: number;
|
|
15
|
-
alignment: Alignment;
|
|
16
|
-
protected operatingStreamBuffer: Uint8Array;
|
|
17
|
-
protected operatingDataView: DataView;
|
|
18
|
-
protected callbackAfterRead: undefined | (() => void);
|
|
19
|
-
protected currentByte: number;
|
|
20
|
-
protected inputStreamIsDone: boolean;
|
|
21
|
-
protected paused: boolean;
|
|
22
|
-
debug: boolean;
|
|
23
|
-
protected closedAlready: boolean;
|
|
24
|
-
protected neededNextAmountOfBytes: number;
|
|
25
|
-
private readLoopHandle;
|
|
26
|
-
private waitingTimeoutHandle;
|
|
27
|
-
protected totalNumberOfBytesRead: number;
|
|
28
|
-
protected trailingBufferSize: number;
|
|
29
|
-
constructor(reader: ReadableStreamDefaultReader<Uint8Array>, onCloseCallback: () => Promise<void>, timeout?: number, maxBufferThreshold?: number, alignment?: Alignment);
|
|
30
|
-
pause(): void;
|
|
31
|
-
resume(): void;
|
|
32
|
-
hasInput(): boolean;
|
|
33
|
-
close(): Promise<void>;
|
|
34
|
-
protected continuousRead: () => Promise<void>;
|
|
35
|
-
allocate(count: number): Promise<void>;
|
|
36
|
-
private waitUntilNumBytesAvailable;
|
|
37
|
-
skipBytes(byteLength?: number): void;
|
|
38
|
-
readByte(): number;
|
|
39
|
-
readBytes(count: number): Uint8Array;
|
|
40
|
-
readHex(hexLength: number): string;
|
|
41
|
-
readInt8(): number;
|
|
42
|
-
readUint8(): number;
|
|
43
|
-
readInt16(): number;
|
|
44
|
-
readUint16(): number;
|
|
45
|
-
readInt32(): number;
|
|
46
|
-
readUint32(): number;
|
|
47
|
-
readLong(): bigint;
|
|
48
|
-
readInt64(): bigint;
|
|
49
|
-
readUint64(): bigint;
|
|
50
|
-
readFloat32(): number;
|
|
51
|
-
readDouble(): number;
|
|
52
|
-
readString(): string;
|
|
53
|
-
getBufferPosition(): number;
|
|
54
|
-
getBufferProgress(): number;
|
|
55
|
-
getBufferLength(): number;
|
|
56
|
-
getAmountAllocatedLeft(): number;
|
|
57
|
-
}
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ByteStreamReader = void 0;
|
|
4
|
-
const alignment_enum_1 = require("../byte/alignment.enum");
|
|
5
|
-
const byte_writer_class_1 = require("../byte/byte-writer.class");
|
|
6
|
-
const parser_error_1 = require("../error/parser.error");
|
|
7
|
-
class ByteStreamReader {
|
|
8
|
-
constructor(reader, onCloseCallback, timeout = 30000, maxBufferThreshold = 100 * 1000 * 1000, alignment = alignment_enum_1.Alignment.LITTLE_ENDIAN) {
|
|
9
|
-
this.reader = reader;
|
|
10
|
-
this.onCloseCallback = onCloseCallback;
|
|
11
|
-
this.timeout = timeout;
|
|
12
|
-
this.maxBufferThreshold = maxBufferThreshold;
|
|
13
|
-
this.alignment = alignment;
|
|
14
|
-
this.debug = false;
|
|
15
|
-
this.closedAlready = false;
|
|
16
|
-
this.totalNumberOfBytesRead = 0;
|
|
17
|
-
this.trailingBufferSize = 0;
|
|
18
|
-
this.continuousRead = async () => {
|
|
19
|
-
while (!this.inputStreamIsDone && !this.paused) {
|
|
20
|
-
const { done, value } = await this.reader.read();
|
|
21
|
-
if (!this.inputStreamIsDone) {
|
|
22
|
-
if (value) {
|
|
23
|
-
const trailingPos = Math.max(0, this.currentByte - this.trailingBufferSize);
|
|
24
|
-
this.operatingStreamBuffer = new Uint8Array(byte_writer_class_1.ByteWriter.AppendBuffer(this.operatingStreamBuffer.slice(trailingPos), value));
|
|
25
|
-
this.operatingDataView = new DataView(this.operatingStreamBuffer.buffer);
|
|
26
|
-
this.currentByte = Math.min(this.currentByte, this.trailingBufferSize);
|
|
27
|
-
if (this.operatingStreamBuffer.byteLength > this.maxBufferThreshold) {
|
|
28
|
-
console.warn('pausing due to size.');
|
|
29
|
-
this.pause();
|
|
30
|
-
}
|
|
31
|
-
if (this.callbackAfterRead) {
|
|
32
|
-
this.callbackAfterRead();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.close();
|
|
38
|
-
}
|
|
39
|
-
this.inputStreamIsDone = done;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
this.operatingStreamBuffer = new Uint8Array();
|
|
43
|
-
this.operatingDataView = new DataView(this.operatingStreamBuffer.buffer);
|
|
44
|
-
this.inputStreamIsDone = false;
|
|
45
|
-
this.currentByte = 0;
|
|
46
|
-
this.neededNextAmountOfBytes = 0;
|
|
47
|
-
this.paused = false;
|
|
48
|
-
this.trailingBufferSize = 2000;
|
|
49
|
-
this.readLoopHandle = setTimeout(this.continuousRead);
|
|
50
|
-
this.waitingTimeoutHandle = undefined;
|
|
51
|
-
}
|
|
52
|
-
pause() {
|
|
53
|
-
this.paused = true;
|
|
54
|
-
clearTimeout(this.readLoopHandle);
|
|
55
|
-
this.readLoopHandle = undefined;
|
|
56
|
-
if (this.waitingTimeoutHandle) {
|
|
57
|
-
clearTimeout(this.waitingTimeoutHandle);
|
|
58
|
-
this.waitingTimeoutHandle = undefined;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
resume() {
|
|
62
|
-
if (this.paused) {
|
|
63
|
-
this.paused = false;
|
|
64
|
-
this.readLoopHandle = setTimeout(this.continuousRead);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
hasInput() {
|
|
68
|
-
return !this.inputStreamIsDone;
|
|
69
|
-
}
|
|
70
|
-
async close() {
|
|
71
|
-
this.inputStreamIsDone = true;
|
|
72
|
-
this.pause();
|
|
73
|
-
await this.onCloseCallback();
|
|
74
|
-
this.closedAlready = true;
|
|
75
|
-
}
|
|
76
|
-
async allocate(count) {
|
|
77
|
-
if (count > this.maxBufferThreshold * 0.5) {
|
|
78
|
-
console.warn(`you are waiting for a very big chunk here mate. ${count} bytes. U sure you have your numbers right?`);
|
|
79
|
-
}
|
|
80
|
-
if (this.getAmountAllocatedLeft() < count) {
|
|
81
|
-
if (this.inputStreamIsDone) {
|
|
82
|
-
throw new parser_error_1.CorruptSaveError('Input Stream has finished before needed data was received.');
|
|
83
|
-
}
|
|
84
|
-
if (this.paused) {
|
|
85
|
-
this.resume();
|
|
86
|
-
}
|
|
87
|
-
await this.waitUntilNumBytesAvailable(count);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
waitUntilNumBytesAvailable(count) {
|
|
91
|
-
this.neededNextAmountOfBytes = count;
|
|
92
|
-
return new Promise((resolve, reject) => {
|
|
93
|
-
if (this.getAmountAllocatedLeft() >= this.neededNextAmountOfBytes) {
|
|
94
|
-
this.neededNextAmountOfBytes = 0;
|
|
95
|
-
return resolve();
|
|
96
|
-
}
|
|
97
|
-
this.callbackAfterRead = () => {
|
|
98
|
-
if (this.getAmountAllocatedLeft() >= this.neededNextAmountOfBytes) {
|
|
99
|
-
if (this.waitingTimeoutHandle) {
|
|
100
|
-
clearTimeout(this.waitingTimeoutHandle);
|
|
101
|
-
}
|
|
102
|
-
this.neededNextAmountOfBytes = 0;
|
|
103
|
-
this.callbackAfterRead = undefined;
|
|
104
|
-
return resolve();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
if (this.waitingTimeoutHandle) {
|
|
108
|
-
clearTimeout(this.waitingTimeoutHandle);
|
|
109
|
-
}
|
|
110
|
-
this.waitingTimeoutHandle = setTimeout(() => {
|
|
111
|
-
if (!this.inputStreamIsDone) {
|
|
112
|
-
reject(new parser_error_1.TimeoutError(`Timed out before ${this.neededNextAmountOfBytes} bytes were available to read next.`));
|
|
113
|
-
}
|
|
114
|
-
return resolve();
|
|
115
|
-
}, this.timeout);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
skipBytes(byteLength = 1) {
|
|
119
|
-
this.currentByte += byteLength;
|
|
120
|
-
this.totalNumberOfBytesRead += byteLength;
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
readByte() {
|
|
124
|
-
this.totalNumberOfBytesRead += 1;
|
|
125
|
-
return this.operatingDataView.getUint8(this.currentByte++);
|
|
126
|
-
}
|
|
127
|
-
readBytes(count) {
|
|
128
|
-
this.totalNumberOfBytesRead += count;
|
|
129
|
-
return new Uint8Array(new Array(count).fill(0).map(pl => this.operatingDataView.getUint8(this.currentByte++)));
|
|
130
|
-
}
|
|
131
|
-
readHex(hexLength) {
|
|
132
|
-
let hexPart = [];
|
|
133
|
-
for (let i = 0; i < hexLength; i++) {
|
|
134
|
-
let currentHex = String.fromCharCode(this.operatingDataView.getUint8(this.currentByte++));
|
|
135
|
-
hexPart.push(currentHex);
|
|
136
|
-
}
|
|
137
|
-
this.totalNumberOfBytesRead += hexLength;
|
|
138
|
-
return hexPart.join('');
|
|
139
|
-
}
|
|
140
|
-
readInt8() {
|
|
141
|
-
this.totalNumberOfBytesRead += 1;
|
|
142
|
-
let data = this.operatingDataView.getInt8(this.currentByte++);
|
|
143
|
-
return data;
|
|
144
|
-
}
|
|
145
|
-
readUint8() {
|
|
146
|
-
this.totalNumberOfBytesRead += 1;
|
|
147
|
-
let data = this.operatingDataView.getUint8(this.currentByte++);
|
|
148
|
-
return data;
|
|
149
|
-
}
|
|
150
|
-
readInt16() {
|
|
151
|
-
this.totalNumberOfBytesRead += 2;
|
|
152
|
-
let data = this.operatingDataView.getInt16(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
153
|
-
this.currentByte += 2;
|
|
154
|
-
return data;
|
|
155
|
-
}
|
|
156
|
-
readUint16() {
|
|
157
|
-
this.totalNumberOfBytesRead += 2;
|
|
158
|
-
let data = this.operatingDataView.getUint16(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
159
|
-
this.currentByte += 2;
|
|
160
|
-
return data;
|
|
161
|
-
}
|
|
162
|
-
readInt32() {
|
|
163
|
-
this.totalNumberOfBytesRead += 4;
|
|
164
|
-
let data = this.operatingDataView.getInt32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
165
|
-
this.currentByte += 4;
|
|
166
|
-
return data;
|
|
167
|
-
}
|
|
168
|
-
readUint32() {
|
|
169
|
-
this.totalNumberOfBytesRead += 4;
|
|
170
|
-
let data = this.operatingDataView.getUint32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
171
|
-
this.currentByte += 4;
|
|
172
|
-
return data;
|
|
173
|
-
}
|
|
174
|
-
readLong() {
|
|
175
|
-
this.totalNumberOfBytesRead += 8;
|
|
176
|
-
let data = this.operatingDataView.getBigInt64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
177
|
-
this.currentByte += 8;
|
|
178
|
-
return data;
|
|
179
|
-
}
|
|
180
|
-
readInt64() {
|
|
181
|
-
return this.readLong();
|
|
182
|
-
}
|
|
183
|
-
readUint64() {
|
|
184
|
-
this.totalNumberOfBytesRead += 8;
|
|
185
|
-
let data = this.operatingDataView.getBigUint64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
186
|
-
this.currentByte += 8;
|
|
187
|
-
return data;
|
|
188
|
-
}
|
|
189
|
-
readFloat32() {
|
|
190
|
-
this.totalNumberOfBytesRead += 4;
|
|
191
|
-
let data = this.operatingDataView.getFloat32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
192
|
-
this.currentByte += 4;
|
|
193
|
-
return data;
|
|
194
|
-
}
|
|
195
|
-
readDouble() {
|
|
196
|
-
this.totalNumberOfBytesRead += 8;
|
|
197
|
-
let data = this.operatingDataView.getFloat64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
198
|
-
this.currentByte += 8;
|
|
199
|
-
return data;
|
|
200
|
-
}
|
|
201
|
-
readString() {
|
|
202
|
-
let strLength = this.readInt32();
|
|
203
|
-
if (strLength === 0) {
|
|
204
|
-
return '';
|
|
205
|
-
}
|
|
206
|
-
if (strLength > (this.operatingDataView.buffer.byteLength - this.currentByte)) {
|
|
207
|
-
let errorMessage = `Cannot read string of length ${strLength} at position ${this.currentByte} as it exceeds the end at ${this.operatingDataView.buffer.byteLength}`;
|
|
208
|
-
throw new Error(errorMessage);
|
|
209
|
-
}
|
|
210
|
-
if (strLength < 0) {
|
|
211
|
-
const string = new Array(-strLength - 1).fill('').map(c => String.fromCharCode(this.readUint16()));
|
|
212
|
-
this.currentByte += 2;
|
|
213
|
-
this.totalNumberOfBytesRead += 2;
|
|
214
|
-
return string.join('');
|
|
215
|
-
}
|
|
216
|
-
try {
|
|
217
|
-
const string = new Array(strLength - 1).fill('').map(c => String.fromCharCode(this.readUint8()));
|
|
218
|
-
this.currentByte += 1;
|
|
219
|
-
this.totalNumberOfBytesRead += 1;
|
|
220
|
-
return string.join('');
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
let errorMessage = `Cannot read UTF8 string of length ${strLength} at position ${this.currentByte}.`;
|
|
224
|
-
console.log(errorMessage, error);
|
|
225
|
-
throw error;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
getBufferPosition() {
|
|
229
|
-
return this.totalNumberOfBytesRead;
|
|
230
|
-
}
|
|
231
|
-
getBufferProgress() {
|
|
232
|
-
throw new parser_error_1.UnimplementedError();
|
|
233
|
-
}
|
|
234
|
-
getBufferLength() {
|
|
235
|
-
return this.operatingStreamBuffer.byteLength;
|
|
236
|
-
}
|
|
237
|
-
getAmountAllocatedLeft() {
|
|
238
|
-
return this.operatingStreamBuffer.byteLength - this.currentByte;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
exports.ByteStreamReader = ByteStreamReader;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { JsonStreamWritable } from "./json-stream-writable";
|
|
2
|
-
export type Transition<S extends string> = {
|
|
3
|
-
name: string;
|
|
4
|
-
requiresOneOfThemToBeBefore: S[];
|
|
5
|
-
do: (...params: any[]) => Promise<void>;
|
|
6
|
-
assignOnFinish: S;
|
|
7
|
-
};
|
|
8
|
-
export declare abstract class JsonStreamStateWriter<S extends string> extends JsonStreamWritable {
|
|
9
|
-
private currentState;
|
|
10
|
-
constructor(pushWritable: (value: string) => Promise<void>, startState: S);
|
|
11
|
-
protected useTransition(transition: Transition<S>, ...params: any[]): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonStreamStateWriter = void 0;
|
|
4
|
-
const json_stream_writable_1 = require("./json-stream-writable");
|
|
5
|
-
class JsonStreamStateWriter extends json_stream_writable_1.JsonStreamWritable {
|
|
6
|
-
constructor(pushWritable, startState) {
|
|
7
|
-
super(pushWritable);
|
|
8
|
-
this.currentState = startState;
|
|
9
|
-
}
|
|
10
|
-
async useTransition(transition, ...params) {
|
|
11
|
-
if (!transition.requiresOneOfThemToBeBefore.includes(this.currentState)) {
|
|
12
|
-
throw new Error(`Invalid command. Method ${transition.name} is not allowed to be called at this state.`);
|
|
13
|
-
}
|
|
14
|
-
await transition.do(...params);
|
|
15
|
-
this.currentState = transition.assignOnFinish;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.JsonStreamStateWriter = JsonStreamStateWriter;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare abstract class JsonStreamWritable {
|
|
2
|
-
protected pushWritable: (value: string) => Promise<void>;
|
|
3
|
-
private openedSymbols;
|
|
4
|
-
private numberPropertiesInOpenedSymbol;
|
|
5
|
-
private currentPropertyOpen;
|
|
6
|
-
constructor(pushWritable: (value: string) => Promise<void>);
|
|
7
|
-
protected isValid: () => boolean;
|
|
8
|
-
private numPropertiesInCurrentOpenedSymbol;
|
|
9
|
-
protected startObject(): Promise<void>;
|
|
10
|
-
protected endObject(): Promise<void>;
|
|
11
|
-
protected startArray(): Promise<void>;
|
|
12
|
-
protected endArray(): Promise<void>;
|
|
13
|
-
protected writeProperty<T>(name: string, value: Promise<string>): Promise<void>;
|
|
14
|
-
protected writeProperties<T>(properties: {
|
|
15
|
-
name: string;
|
|
16
|
-
value: Promise<string>;
|
|
17
|
-
}[]): Promise<void>;
|
|
18
|
-
protected writePropertyName(name: string): Promise<void>;
|
|
19
|
-
protected writeValue<T>(value: Promise<string>): Promise<void>;
|
|
20
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonStreamWritable = void 0;
|
|
4
|
-
class JsonStreamWritable {
|
|
5
|
-
constructor(pushWritable) {
|
|
6
|
-
this.pushWritable = pushWritable;
|
|
7
|
-
this.isValid = () => this.openedSymbols.length === 0;
|
|
8
|
-
this.numPropertiesInCurrentOpenedSymbol = () => this.numberPropertiesInOpenedSymbol.length > 0 ? this.numberPropertiesInOpenedSymbol.at(-1) : 0;
|
|
9
|
-
this.openedSymbols = [];
|
|
10
|
-
this.numberPropertiesInOpenedSymbol = [];
|
|
11
|
-
this.currentPropertyOpen = false;
|
|
12
|
-
}
|
|
13
|
-
async startObject() {
|
|
14
|
-
await this.pushWritable('{');
|
|
15
|
-
this.openedSymbols.push('object');
|
|
16
|
-
this.numberPropertiesInOpenedSymbol.push(0);
|
|
17
|
-
this.currentPropertyOpen = false;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
async endObject() {
|
|
21
|
-
await this.pushWritable('}');
|
|
22
|
-
this.openedSymbols.splice(this.openedSymbols.lastIndexOf('object'), 1);
|
|
23
|
-
if (this.numberPropertiesInOpenedSymbol.length > 0) {
|
|
24
|
-
this.numberPropertiesInOpenedSymbol.splice(this.numberPropertiesInOpenedSymbol.length - 1, 1);
|
|
25
|
-
}
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
async startArray() {
|
|
29
|
-
await this.pushWritable('[');
|
|
30
|
-
this.openedSymbols.push('array');
|
|
31
|
-
this.numberPropertiesInOpenedSymbol.push(0);
|
|
32
|
-
this.currentPropertyOpen = false;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
async endArray() {
|
|
36
|
-
this.pushWritable(']');
|
|
37
|
-
this.openedSymbols.splice(this.openedSymbols.lastIndexOf('array'), 1);
|
|
38
|
-
if (this.numberPropertiesInOpenedSymbol.length > 0) {
|
|
39
|
-
this.numberPropertiesInOpenedSymbol.splice(this.numberPropertiesInOpenedSymbol.length - 1, 1);
|
|
40
|
-
}
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
async writeProperty(name, value) {
|
|
44
|
-
if (this.openedSymbols.length <= 0 || this.openedSymbols.at(-1) !== 'object' || this.currentPropertyOpen) {
|
|
45
|
-
throw new Error(`Json Write Method is not allowed for property ${name} here.`);
|
|
46
|
-
}
|
|
47
|
-
const prefix = this.numPropertiesInCurrentOpenedSymbol() > 0 ? ', ' : '';
|
|
48
|
-
await this.pushWritable(`${prefix}${name}: ${await value}`);
|
|
49
|
-
this.numberPropertiesInOpenedSymbol[this.numberPropertiesInOpenedSymbol.length - 1] += 1;
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
async writeProperties(properties) {
|
|
53
|
-
if (this.currentPropertyOpen) {
|
|
54
|
-
throw new Error(`Json Write Method is not allowed, since currently a property value needs to be written.`);
|
|
55
|
-
}
|
|
56
|
-
for (const property of properties) {
|
|
57
|
-
await this.writeProperty(property.name, property.value);
|
|
58
|
-
}
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
async writePropertyName(name) {
|
|
62
|
-
if (this.currentPropertyOpen) {
|
|
63
|
-
throw new Error(`Json Write Method is not allowed, since currently a property value needs to be written.`);
|
|
64
|
-
}
|
|
65
|
-
const prefix = this.numPropertiesInCurrentOpenedSymbol() > 0 ? ', ' : '';
|
|
66
|
-
this.currentPropertyOpen = true;
|
|
67
|
-
await this.pushWritable(`${prefix}${name}:`);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
async writeValue(value) {
|
|
71
|
-
if (this.openedSymbols.length <= 0 || (!this.currentPropertyOpen && this.openedSymbols.at(-1) !== 'array')) {
|
|
72
|
-
throw new Error(`Json Write Method is not allowed for any value here.`);
|
|
73
|
-
}
|
|
74
|
-
const prefix = this.numPropertiesInCurrentOpenedSymbol() > 0 ? ', ' : '';
|
|
75
|
-
if (this.currentPropertyOpen) {
|
|
76
|
-
this.currentPropertyOpen = false;
|
|
77
|
-
}
|
|
78
|
-
await this.pushWritable(`${prefix}${await value}`);
|
|
79
|
-
this.numberPropertiesInOpenedSymbol[this.numberPropertiesInOpenedSymbol.length - 1] += 1;
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.JsonStreamWritable = JsonStreamWritable;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { WritableStreamDefaultWriter } from "stream/web";
|
|
3
|
-
import { ChunkCompressionInfo, ObjectReference, SatisfactorySaveHeader, SaveComponent, SaveEntity } from "../..";
|
|
4
|
-
import { JsonStreamStateWriter } from "./json-stream-state-writer";
|
|
5
|
-
type State = 'BEFORE_START' | 'OPENED_SAVE' | 'FINISHED_HEADER' | 'OPENED_LEVELS' | 'FINISHED_LEVELS' | 'OPENED_LEVEL' | 'FINISHED_LEVEL' | 'FINISHED_SAVE' | 'WROTE_COMPRESSION_INFO' | 'WROTE_OBJECT' | 'SWITCH_TO_COLLECTABLES' | 'WROTE_COLLECTABLE';
|
|
6
|
-
export declare class JsonStreamWriter extends JsonStreamStateWriter<State> {
|
|
7
|
-
private writer;
|
|
8
|
-
private readonly stateMachine;
|
|
9
|
-
constructor(writer: WritableStreamDefaultWriter<string>);
|
|
10
|
-
beginSave(): Promise<void>;
|
|
11
|
-
writeHeader(header: SatisfactorySaveHeader): Promise<void>;
|
|
12
|
-
writeCompressionInfo(compressionInfo: ChunkCompressionInfo): Promise<void>;
|
|
13
|
-
openLevels(): Promise<void>;
|
|
14
|
-
openLevel(): Promise<void>;
|
|
15
|
-
writeObject(object: SaveEntity | SaveComponent): Promise<void>;
|
|
16
|
-
switchToCollectables(): Promise<void>;
|
|
17
|
-
writeCollectable(object: ObjectReference): Promise<void>;
|
|
18
|
-
closeLevel(): Promise<void>;
|
|
19
|
-
closeLevels(): Promise<void>;
|
|
20
|
-
endSave(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export {};
|