@etothepii/satisfactory-file-parser 0.1.24 → 0.1.26
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.d.ts +1 -0
- package/build/index.js +25 -58
- package/build/parser/byte/alignment.enum.js +2 -5
- package/build/parser/byte/binary-operable.interface.js +1 -2
- package/build/parser/byte/binary-readable.interface.js +1 -2
- package/build/parser/byte/byte-reader.class.js +10 -14
- package/build/parser/byte/byte-writer.class.js +10 -13
- package/build/parser/error/parser.error.js +6 -15
- package/build/parser/file.types.js +2 -5
- package/build/parser/parser.d.ts +1 -1
- package/build/parser/parser.js +24 -27
- package/build/parser/satisfactory/blueprint/blueprint-reader.js +28 -36
- package/build/parser/satisfactory/blueprint/blueprint-writer.js +20 -25
- package/build/parser/satisfactory/blueprint/blueprint.types.js +1 -2
- package/build/parser/satisfactory/objects/DataFields.js +79 -83
- package/build/parser/satisfactory/objects/GUIDInfo.js +5 -8
- package/build/parser/satisfactory/objects/ObjectReference.js +2 -5
- package/build/parser/satisfactory/objects/Property.js +91 -120
- package/build/parser/satisfactory/objects/SaveComponent.js +7 -11
- package/build/parser/satisfactory/objects/SaveEntity.js +13 -17
- package/build/parser/satisfactory/objects/SaveObject.js +4 -8
- package/build/parser/satisfactory/objects/ue/GUID.js +2 -5
- package/build/parser/satisfactory/objects/ue/MD5Hash.js +2 -5
- package/build/parser/satisfactory/save/asynchronous-level.class.js +12 -16
- package/build/parser/satisfactory/save/level.class.js +26 -30
- package/build/parser/satisfactory/save/satisfactory-save.d.ts +2 -1
- package/build/parser/satisfactory/save/satisfactory-save.js +3 -6
- package/build/parser/satisfactory/save/save-reader.js +31 -34
- package/build/parser/satisfactory/save/save-writer.js +34 -40
- package/build/parser/satisfactory/save/save.types.js +1 -2
- package/build/parser/satisfactory/structs/util.types.js +37 -63
- package/build/parser/stream/byte-stream-reader.class.js +17 -21
- package/build/parser/stream/json-stream-state-writer.js +2 -6
- package/build/parser/stream/json-stream-writable.js +1 -5
- package/build/parser/stream/json-stream-writer.js +2 -6
- package/build/parser/stream/reworked/readable-stream-parser.d.ts +12 -0
- package/build/parser/stream/reworked/readable-stream-parser.js +201 -0
- package/build/parser/stream/reworked/stream-parser.d.ts +3 -1
- package/build/parser/stream/reworked/stream-parser.js +86 -11
- package/build/parser/stream/save-stream-json-stringifier.js +3 -7
- package/build/parser/stream/save-stream-reader.class.js +18 -24
- package/build/parser/stream/save-stream-writer.class.d.ts +15 -13
- package/build/parser/stream/save-stream-writer.class.js +71 -108
- package/build/parser/stream/stream-level.class.js +11 -15
- package/build/parser/stream/stream-parser.js +11 -15
- package/package.json +4 -2
- package/build/parser/satisfactory/objects/ue/FMD5Hash.d.ts +0 -7
- package/build/parser/satisfactory/objects/ue/FMD5Hash.js +0 -19
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const parser_error_1 = require("../../error/parser.error");
|
|
11
|
-
const file_types_1 = require("../../file.types");
|
|
12
|
-
const MD5Hash_1 = require("../objects/ue/MD5Hash");
|
|
13
|
-
const level_class_1 = require("./level.class");
|
|
14
|
-
const save_reader_1 = require("./save-reader");
|
|
15
|
-
class SaveWriter extends byte_writer_class_1.ByteWriter {
|
|
1
|
+
import Pako from "pako";
|
|
2
|
+
import { Alignment } from "../../byte/alignment.enum";
|
|
3
|
+
import { ByteWriter } from "../../byte/byte-writer.class";
|
|
4
|
+
import { CompressionLibraryError, ParserError, UnsupportedVersionError } from "../../error/parser.error";
|
|
5
|
+
import { CompressionAlgorithmCode } from "../../file.types";
|
|
6
|
+
import { MD5Hash } from '../objects/ue/MD5Hash';
|
|
7
|
+
import { Level } from "./level.class";
|
|
8
|
+
import { SaveReader } from "./save-reader";
|
|
9
|
+
class SaveWriter extends ByteWriter {
|
|
16
10
|
constructor() {
|
|
17
|
-
super(
|
|
11
|
+
super(Alignment.LITTLE_ENDIAN);
|
|
18
12
|
}
|
|
19
13
|
static WriteHeader(writer, header) {
|
|
20
14
|
writer.writeInt32(header.saveHeaderType);
|
|
@@ -24,7 +18,7 @@ class SaveWriter extends byte_writer_class_1.ByteWriter {
|
|
|
24
18
|
writer.writeString(header.mapOptions);
|
|
25
19
|
writer.writeString(header.sessionName);
|
|
26
20
|
writer.writeInt32(header.playDurationSeconds);
|
|
27
|
-
writer.writeInt64(BigInt(header.saveDateTime) * 10000n +
|
|
21
|
+
writer.writeInt64(BigInt(header.saveDateTime) * 10000n + SaveReader.EPOCH_TICKS);
|
|
28
22
|
writer.writeByte(header.sessionVisibility);
|
|
29
23
|
if (header.saveHeaderType >= 7) {
|
|
30
24
|
writer.writeInt32(header.fEditorObjectVersion);
|
|
@@ -45,7 +39,7 @@ class SaveWriter extends byte_writer_class_1.ByteWriter {
|
|
|
45
39
|
writer.writeInt32(header.partitionEnabledFlag ? 1 : 0);
|
|
46
40
|
}
|
|
47
41
|
if (header.saveHeaderType >= 12) {
|
|
48
|
-
|
|
42
|
+
MD5Hash.write(writer, header.consistencyHashBytes);
|
|
49
43
|
}
|
|
50
44
|
if (header.saveHeaderType >= 13) {
|
|
51
45
|
writer.writeInt32(header.creativeModeEnabled ? 1 : 0);
|
|
@@ -53,7 +47,7 @@ class SaveWriter extends byte_writer_class_1.ByteWriter {
|
|
|
53
47
|
if (header.saveVersion >= 21) {
|
|
54
48
|
}
|
|
55
49
|
else {
|
|
56
|
-
throw new
|
|
50
|
+
throw new UnsupportedVersionError("The save version is too old to be supported currently.");
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
53
|
static WriteLevels(writer, save, buildVersion) {
|
|
@@ -62,17 +56,17 @@ class SaveWriter extends byte_writer_class_1.ByteWriter {
|
|
|
62
56
|
if (level.name !== save.header.mapName) {
|
|
63
57
|
writer.writeString(level.name);
|
|
64
58
|
}
|
|
65
|
-
|
|
59
|
+
Level.WriteLevel(writer, level, buildVersion);
|
|
66
60
|
}
|
|
67
|
-
|
|
61
|
+
Level.SerializeCollectablesList(writer, save.trailingCollectedObjects ?? []);
|
|
68
62
|
}
|
|
69
|
-
static GenerateCompressedChunksFromData(bufferArray, compressionInfo, onBinaryBeforeCompressing, onChunk, alignment =
|
|
63
|
+
static GenerateCompressedChunksFromData(bufferArray, compressionInfo, onBinaryBeforeCompressing, onChunk, alignment = Alignment.LITTLE_ENDIAN) {
|
|
70
64
|
const errors = [];
|
|
71
65
|
const totalUncompressedSize = bufferArray.byteLength;
|
|
72
66
|
const saveBody = new Uint8Array(bufferArray.byteLength + 8);
|
|
73
67
|
saveBody.set(new Uint8Array(bufferArray), 4);
|
|
74
68
|
const miniView = new DataView(saveBody.buffer);
|
|
75
|
-
miniView.setInt32(0, totalUncompressedSize, alignment ===
|
|
69
|
+
miniView.setInt32(0, totalUncompressedSize, alignment === Alignment.LITTLE_ENDIAN);
|
|
76
70
|
onBinaryBeforeCompressing(saveBody.buffer);
|
|
77
71
|
let handledByte = 0;
|
|
78
72
|
const chunkSummary = [];
|
|
@@ -81,27 +75,27 @@ class SaveWriter extends byte_writer_class_1.ByteWriter {
|
|
|
81
75
|
const uncompressedChunk = saveBody.buffer.slice(handledByte, handledByte + uncompressedContentSize);
|
|
82
76
|
let compressedChunk = new Uint8Array(0);
|
|
83
77
|
try {
|
|
84
|
-
compressedChunk =
|
|
78
|
+
compressedChunk = Pako.deflate(uncompressedChunk);
|
|
85
79
|
}
|
|
86
80
|
catch (err) {
|
|
87
|
-
throw new
|
|
81
|
+
throw new CompressionLibraryError("Could not compress save data. " + err);
|
|
88
82
|
}
|
|
89
83
|
const chunk = new Uint8Array(compressionInfo.chunkHeaderSize + compressedChunk.byteLength);
|
|
90
84
|
chunk.set(compressedChunk, compressionInfo.chunkHeaderSize);
|
|
91
85
|
const view = new DataView(chunk.buffer);
|
|
92
|
-
view.setInt32(0, compressionInfo.packageFileTag, alignment ===
|
|
93
|
-
view.setInt32(4, 0x22222222, alignment ===
|
|
94
|
-
view.setInt32(8, compressionInfo.maxUncompressedChunkContentSize, alignment ===
|
|
95
|
-
view.setInt32(12, 0, alignment ===
|
|
96
|
-
view.setUint8(16,
|
|
97
|
-
view.setInt32(17, compressedChunk.byteLength, alignment ===
|
|
98
|
-
view.setInt32(21, 0, alignment ===
|
|
99
|
-
view.setInt32(25, uncompressedContentSize, alignment ===
|
|
100
|
-
view.setInt32(29, 0, alignment ===
|
|
101
|
-
view.setInt32(33, compressedChunk.byteLength, alignment ===
|
|
102
|
-
view.setInt32(37, 0, alignment ===
|
|
103
|
-
view.setInt32(41, uncompressedContentSize, alignment ===
|
|
104
|
-
view.setInt32(45, 0, alignment ===
|
|
86
|
+
view.setInt32(0, compressionInfo.packageFileTag, alignment === Alignment.LITTLE_ENDIAN);
|
|
87
|
+
view.setInt32(4, 0x22222222, alignment === Alignment.LITTLE_ENDIAN);
|
|
88
|
+
view.setInt32(8, compressionInfo.maxUncompressedChunkContentSize, alignment === Alignment.LITTLE_ENDIAN);
|
|
89
|
+
view.setInt32(12, 0, alignment === Alignment.LITTLE_ENDIAN);
|
|
90
|
+
view.setUint8(16, CompressionAlgorithmCode.ZLIB);
|
|
91
|
+
view.setInt32(17, compressedChunk.byteLength, alignment === Alignment.LITTLE_ENDIAN);
|
|
92
|
+
view.setInt32(21, 0, alignment === Alignment.LITTLE_ENDIAN);
|
|
93
|
+
view.setInt32(25, uncompressedContentSize, alignment === Alignment.LITTLE_ENDIAN);
|
|
94
|
+
view.setInt32(29, 0, alignment === Alignment.LITTLE_ENDIAN);
|
|
95
|
+
view.setInt32(33, compressedChunk.byteLength, alignment === Alignment.LITTLE_ENDIAN);
|
|
96
|
+
view.setInt32(37, 0, alignment === Alignment.LITTLE_ENDIAN);
|
|
97
|
+
view.setInt32(41, uncompressedContentSize, alignment === Alignment.LITTLE_ENDIAN);
|
|
98
|
+
view.setInt32(45, 0, alignment === Alignment.LITTLE_ENDIAN);
|
|
105
99
|
onChunk(chunk);
|
|
106
100
|
chunkSummary.push({
|
|
107
101
|
uncompressedSize: uncompressedContentSize + compressionInfo.chunkHeaderSize,
|
|
@@ -113,7 +107,7 @@ class SaveWriter extends byte_writer_class_1.ByteWriter {
|
|
|
113
107
|
}
|
|
114
108
|
generateChunks(compressionInfo, posAfterHeader, onBinaryBeforeCompressing, onHeader, onChunk) {
|
|
115
109
|
if (posAfterHeader <= 0) {
|
|
116
|
-
throw new
|
|
110
|
+
throw new ParserError('ParserError', 'Seems like this buffer has no header. Please write the header first before you can generate chunks.');
|
|
117
111
|
}
|
|
118
112
|
const header = new Uint8Array(this.bufferArray.slice(0, posAfterHeader));
|
|
119
113
|
onHeader(header);
|
|
@@ -144,4 +138,4 @@ SaveWriter.WriteGrids = (writer, grids) => {
|
|
|
144
138
|
}
|
|
145
139
|
writer.writeInt32(0);
|
|
146
140
|
};
|
|
147
|
-
|
|
141
|
+
export { SaveWriter };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SerializeTransform = exports.ParseTransform = exports.SerializeVec2f = exports.ParseVec2f = exports.SerializeVec2 = exports.ParseVec2 = exports.SerializeVec3f = exports.ParseVec3f = exports.SerializeVec3 = exports.ParseVec3 = exports.norm = exports.mult = exports.length = exports.add = exports.sub = exports.SerializeVec4f = exports.ParseVec4f = exports.SerializeVec4 = exports.ParseVec4 = exports.ParseCol4BGRA = exports.SerializeCol4BGRA = exports.ParseCol4RGBA = exports.SerializeCol4RGBA = void 0;
|
|
4
|
-
const SerializeCol4RGBA = (writer, value) => {
|
|
1
|
+
export const SerializeCol4RGBA = (writer, value) => {
|
|
5
2
|
writer.writeFloat(value.r);
|
|
6
3
|
writer.writeFloat(value.g);
|
|
7
4
|
writer.writeFloat(value.b);
|
|
8
5
|
writer.writeFloat(value.a);
|
|
9
6
|
};
|
|
10
|
-
|
|
11
|
-
const ParseCol4RGBA = (reader) => {
|
|
7
|
+
export const ParseCol4RGBA = (reader) => {
|
|
12
8
|
return {
|
|
13
9
|
r: reader.readFloat32(),
|
|
14
10
|
g: reader.readFloat32(),
|
|
@@ -16,15 +12,13 @@ const ParseCol4RGBA = (reader) => {
|
|
|
16
12
|
a: reader.readFloat32(),
|
|
17
13
|
};
|
|
18
14
|
};
|
|
19
|
-
|
|
20
|
-
const SerializeCol4BGRA = (writer, value) => {
|
|
15
|
+
export const SerializeCol4BGRA = (writer, value) => {
|
|
21
16
|
writer.writeByte(value.b);
|
|
22
17
|
writer.writeByte(value.g);
|
|
23
18
|
writer.writeByte(value.r);
|
|
24
19
|
writer.writeByte(value.a);
|
|
25
20
|
};
|
|
26
|
-
|
|
27
|
-
const ParseCol4BGRA = (reader) => {
|
|
21
|
+
export const ParseCol4BGRA = (reader) => {
|
|
28
22
|
return {
|
|
29
23
|
b: reader.readByte(),
|
|
30
24
|
g: reader.readByte(),
|
|
@@ -32,100 +26,80 @@ const ParseCol4BGRA = (reader) => {
|
|
|
32
26
|
a: reader.readByte(),
|
|
33
27
|
};
|
|
34
28
|
};
|
|
35
|
-
|
|
36
|
-
const ParseVec4 = (reader) => {
|
|
29
|
+
export const ParseVec4 = (reader) => {
|
|
37
30
|
return {
|
|
38
|
-
...(
|
|
31
|
+
...(ParseVec3(reader)),
|
|
39
32
|
w: reader.readDouble()
|
|
40
33
|
};
|
|
41
34
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(0, exports.SerializeVec3)(writer, vec);
|
|
35
|
+
export const SerializeVec4 = (writer, vec) => {
|
|
36
|
+
SerializeVec3(writer, vec);
|
|
45
37
|
writer.writeDouble(vec.w);
|
|
46
38
|
};
|
|
47
|
-
|
|
48
|
-
const ParseVec4f = (reader) => {
|
|
39
|
+
export const ParseVec4f = (reader) => {
|
|
49
40
|
return {
|
|
50
|
-
...(
|
|
41
|
+
...(ParseVec3f(reader)),
|
|
51
42
|
w: reader.readFloat32()
|
|
52
43
|
};
|
|
53
44
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
(0, exports.SerializeVec3f)(writer, vec);
|
|
45
|
+
export const SerializeVec4f = (writer, vec) => {
|
|
46
|
+
SerializeVec3f(writer, vec);
|
|
57
47
|
writer.writeFloat(vec.w);
|
|
58
48
|
};
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
exports.length = length;
|
|
66
|
-
const mult = (vec, scale) => ({ x: vec.x * scale, y: vec.y * scale, z: vec.z * scale });
|
|
67
|
-
exports.mult = mult;
|
|
68
|
-
const norm = (vec) => (0, exports.mult)(vec, 1. / (0, exports.length)(vec));
|
|
69
|
-
exports.norm = norm;
|
|
70
|
-
const ParseVec3 = (reader) => {
|
|
49
|
+
export const sub = (other, vec) => ({ x: other.x - vec.x, y: other.y - vec.y, z: other.z - vec.z });
|
|
50
|
+
export const add = (vec, other) => ({ x: vec.x + other.x, y: vec.y + other.y, z: vec.z + other.z });
|
|
51
|
+
export const length = (vec) => Math.sqrt(vec.x ** 2 + vec.y ** 2 + vec.z ** 2);
|
|
52
|
+
export const mult = (vec, scale) => ({ x: vec.x * scale, y: vec.y * scale, z: vec.z * scale });
|
|
53
|
+
export const norm = (vec) => mult(vec, 1. / length(vec));
|
|
54
|
+
export const ParseVec3 = (reader) => {
|
|
71
55
|
return {
|
|
72
|
-
...(
|
|
56
|
+
...(ParseVec2(reader)),
|
|
73
57
|
z: reader.readDouble()
|
|
74
58
|
};
|
|
75
59
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
(0, exports.SerializeVec2)(writer, vec);
|
|
60
|
+
export const SerializeVec3 = (writer, vec) => {
|
|
61
|
+
SerializeVec2(writer, vec);
|
|
79
62
|
writer.writeDouble(vec.z);
|
|
80
63
|
};
|
|
81
|
-
|
|
82
|
-
const ParseVec3f = (reader) => {
|
|
64
|
+
export const ParseVec3f = (reader) => {
|
|
83
65
|
return {
|
|
84
|
-
...(
|
|
66
|
+
...(ParseVec2f(reader)),
|
|
85
67
|
z: reader.readFloat32()
|
|
86
68
|
};
|
|
87
69
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
(0, exports.SerializeVec2f)(writer, vec);
|
|
70
|
+
export const SerializeVec3f = (writer, vec) => {
|
|
71
|
+
SerializeVec2f(writer, vec);
|
|
91
72
|
writer.writeFloat(vec.z);
|
|
92
73
|
};
|
|
93
|
-
|
|
94
|
-
const ParseVec2 = (reader) => {
|
|
74
|
+
export const ParseVec2 = (reader) => {
|
|
95
75
|
return {
|
|
96
76
|
x: reader.readDouble(),
|
|
97
77
|
y: reader.readDouble(),
|
|
98
78
|
};
|
|
99
79
|
};
|
|
100
|
-
|
|
101
|
-
const SerializeVec2 = (writer, vec) => {
|
|
80
|
+
export const SerializeVec2 = (writer, vec) => {
|
|
102
81
|
writer.writeDouble(vec.x);
|
|
103
82
|
writer.writeDouble(vec.y);
|
|
104
83
|
};
|
|
105
|
-
|
|
106
|
-
const ParseVec2f = (reader) => {
|
|
84
|
+
export const ParseVec2f = (reader) => {
|
|
107
85
|
return {
|
|
108
86
|
x: reader.readFloat32(),
|
|
109
87
|
y: reader.readFloat32(),
|
|
110
88
|
};
|
|
111
89
|
};
|
|
112
|
-
|
|
113
|
-
const SerializeVec2f = (writer, vec) => {
|
|
90
|
+
export const SerializeVec2f = (writer, vec) => {
|
|
114
91
|
writer.writeFloat(vec.x);
|
|
115
92
|
writer.writeFloat(vec.y);
|
|
116
93
|
};
|
|
117
|
-
|
|
118
|
-
const ParseTransform = (reader) => {
|
|
94
|
+
export const ParseTransform = (reader) => {
|
|
119
95
|
return {
|
|
120
|
-
rotation:
|
|
121
|
-
translation:
|
|
122
|
-
scale3d:
|
|
96
|
+
rotation: ParseVec4f(reader),
|
|
97
|
+
translation: ParseVec3f(reader),
|
|
98
|
+
scale3d: ParseVec3f(reader),
|
|
123
99
|
};
|
|
124
100
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
(
|
|
128
|
-
|
|
129
|
-
(0, exports.SerializeVec3f)(writer, transform.scale3d);
|
|
101
|
+
export const SerializeTransform = (writer, transform) => {
|
|
102
|
+
SerializeVec4f(writer, transform.rotation);
|
|
103
|
+
SerializeVec3f(writer, transform.translation);
|
|
104
|
+
SerializeVec3f(writer, transform.scale3d);
|
|
130
105
|
};
|
|
131
|
-
exports.SerializeTransform = SerializeTransform;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) {
|
|
1
|
+
import { Alignment } from "../byte/alignment.enum";
|
|
2
|
+
import { ByteWriter } from "../byte/byte-writer.class";
|
|
3
|
+
import { CorruptSaveError, TimeoutError, UnimplementedError } from "../error/parser.error";
|
|
4
|
+
export class ByteStreamReader {
|
|
5
|
+
constructor(reader, onCloseCallback, timeout = 30000, maxBufferThreshold = 100 * 1000 * 1000, alignment = Alignment.LITTLE_ENDIAN) {
|
|
9
6
|
this.reader = reader;
|
|
10
7
|
this.onCloseCallback = onCloseCallback;
|
|
11
8
|
this.timeout = timeout;
|
|
@@ -21,7 +18,7 @@ class ByteStreamReader {
|
|
|
21
18
|
if (!this.inputStreamIsDone) {
|
|
22
19
|
if (value) {
|
|
23
20
|
const trailingPos = Math.max(0, this.currentByte - this.trailingBufferSize);
|
|
24
|
-
this.operatingStreamBuffer = new Uint8Array(
|
|
21
|
+
this.operatingStreamBuffer = new Uint8Array(ByteWriter.AppendBuffer(this.operatingStreamBuffer.slice(trailingPos), value));
|
|
25
22
|
this.operatingDataView = new DataView(this.operatingStreamBuffer.buffer);
|
|
26
23
|
this.currentByte = Math.min(this.currentByte, this.trailingBufferSize);
|
|
27
24
|
if (this.operatingStreamBuffer.byteLength > this.maxBufferThreshold) {
|
|
@@ -79,7 +76,7 @@ class ByteStreamReader {
|
|
|
79
76
|
}
|
|
80
77
|
if (this.getAmountAllocatedLeft() < count) {
|
|
81
78
|
if (this.inputStreamIsDone) {
|
|
82
|
-
throw new
|
|
79
|
+
throw new CorruptSaveError('Input Stream has finished before needed data was received.');
|
|
83
80
|
}
|
|
84
81
|
if (this.paused) {
|
|
85
82
|
this.resume();
|
|
@@ -109,7 +106,7 @@ class ByteStreamReader {
|
|
|
109
106
|
}
|
|
110
107
|
this.waitingTimeoutHandle = setTimeout(() => {
|
|
111
108
|
if (!this.inputStreamIsDone) {
|
|
112
|
-
reject(new
|
|
109
|
+
reject(new TimeoutError(`Timed out before ${this.neededNextAmountOfBytes} bytes were available to read next.`));
|
|
113
110
|
}
|
|
114
111
|
return resolve();
|
|
115
112
|
}, this.timeout);
|
|
@@ -149,31 +146,31 @@ class ByteStreamReader {
|
|
|
149
146
|
}
|
|
150
147
|
readInt16() {
|
|
151
148
|
this.totalNumberOfBytesRead += 2;
|
|
152
|
-
let data = this.operatingDataView.getInt16(this.currentByte, this.alignment ===
|
|
149
|
+
let data = this.operatingDataView.getInt16(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN);
|
|
153
150
|
this.currentByte += 2;
|
|
154
151
|
return data;
|
|
155
152
|
}
|
|
156
153
|
readUint16() {
|
|
157
154
|
this.totalNumberOfBytesRead += 2;
|
|
158
|
-
let data = this.operatingDataView.getUint16(this.currentByte, this.alignment ===
|
|
155
|
+
let data = this.operatingDataView.getUint16(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN);
|
|
159
156
|
this.currentByte += 2;
|
|
160
157
|
return data;
|
|
161
158
|
}
|
|
162
159
|
readInt32() {
|
|
163
160
|
this.totalNumberOfBytesRead += 4;
|
|
164
|
-
let data = this.operatingDataView.getInt32(this.currentByte, this.alignment ===
|
|
161
|
+
let data = this.operatingDataView.getInt32(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN);
|
|
165
162
|
this.currentByte += 4;
|
|
166
163
|
return data;
|
|
167
164
|
}
|
|
168
165
|
readUint32() {
|
|
169
166
|
this.totalNumberOfBytesRead += 4;
|
|
170
|
-
let data = this.operatingDataView.getUint32(this.currentByte, this.alignment ===
|
|
167
|
+
let data = this.operatingDataView.getUint32(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN);
|
|
171
168
|
this.currentByte += 4;
|
|
172
169
|
return data;
|
|
173
170
|
}
|
|
174
171
|
readLong() {
|
|
175
172
|
this.totalNumberOfBytesRead += 8;
|
|
176
|
-
let data = this.operatingDataView.getBigInt64(this.currentByte, this.alignment ===
|
|
173
|
+
let data = this.operatingDataView.getBigInt64(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN);
|
|
177
174
|
this.currentByte += 8;
|
|
178
175
|
return data;
|
|
179
176
|
}
|
|
@@ -182,19 +179,19 @@ class ByteStreamReader {
|
|
|
182
179
|
}
|
|
183
180
|
readUint64() {
|
|
184
181
|
this.totalNumberOfBytesRead += 8;
|
|
185
|
-
let data = this.operatingDataView.getBigUint64(this.currentByte, this.alignment ===
|
|
182
|
+
let data = this.operatingDataView.getBigUint64(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN);
|
|
186
183
|
this.currentByte += 8;
|
|
187
184
|
return data;
|
|
188
185
|
}
|
|
189
186
|
readFloat32() {
|
|
190
187
|
this.totalNumberOfBytesRead += 4;
|
|
191
|
-
let data = this.operatingDataView.getFloat32(this.currentByte, this.alignment ===
|
|
188
|
+
let data = this.operatingDataView.getFloat32(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN);
|
|
192
189
|
this.currentByte += 4;
|
|
193
190
|
return data;
|
|
194
191
|
}
|
|
195
192
|
readDouble() {
|
|
196
193
|
this.totalNumberOfBytesRead += 8;
|
|
197
|
-
let data = this.operatingDataView.getFloat64(this.currentByte, this.alignment ===
|
|
194
|
+
let data = this.operatingDataView.getFloat64(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN);
|
|
198
195
|
this.currentByte += 8;
|
|
199
196
|
return data;
|
|
200
197
|
}
|
|
@@ -229,7 +226,7 @@ class ByteStreamReader {
|
|
|
229
226
|
return this.totalNumberOfBytesRead;
|
|
230
227
|
}
|
|
231
228
|
getBufferProgress() {
|
|
232
|
-
throw new
|
|
229
|
+
throw new UnimplementedError();
|
|
233
230
|
}
|
|
234
231
|
getBufferLength() {
|
|
235
232
|
return this.operatingStreamBuffer.byteLength;
|
|
@@ -238,4 +235,3 @@ class ByteStreamReader {
|
|
|
238
235
|
return this.operatingStreamBuffer.byteLength - this.currentByte;
|
|
239
236
|
}
|
|
240
237
|
}
|
|
241
|
-
exports.ByteStreamReader = ByteStreamReader;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.JsonStreamStateWriter = void 0;
|
|
4
|
-
const json_stream_writable_1 = require("./json-stream-writable");
|
|
5
|
-
class JsonStreamStateWriter extends json_stream_writable_1.JsonStreamWritable {
|
|
1
|
+
import { JsonStreamWritable } from "./json-stream-writable";
|
|
2
|
+
export class JsonStreamStateWriter extends JsonStreamWritable {
|
|
6
3
|
constructor(pushWritable, startState) {
|
|
7
4
|
super(pushWritable);
|
|
8
5
|
this.currentState = startState;
|
|
@@ -15,4 +12,3 @@ class JsonStreamStateWriter extends json_stream_writable_1.JsonStreamWritable {
|
|
|
15
12
|
this.currentState = transition.assignOnFinish;
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
exports.JsonStreamStateWriter = JsonStreamStateWriter;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonStreamWritable = void 0;
|
|
4
|
-
class JsonStreamWritable {
|
|
1
|
+
export class JsonStreamWritable {
|
|
5
2
|
constructor(pushWritable) {
|
|
6
3
|
this.pushWritable = pushWritable;
|
|
7
4
|
this.isValid = () => this.openedSymbols.length === 0;
|
|
@@ -80,4 +77,3 @@ class JsonStreamWritable {
|
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
|
-
exports.JsonStreamWritable = JsonStreamWritable;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.JsonStreamWriter = void 0;
|
|
4
|
-
const json_stream_state_writer_1 = require("./json-stream-state-writer");
|
|
5
|
-
class JsonStreamWriter extends json_stream_state_writer_1.JsonStreamStateWriter {
|
|
1
|
+
import { JsonStreamStateWriter } from "./json-stream-state-writer";
|
|
2
|
+
export class JsonStreamWriter extends JsonStreamStateWriter {
|
|
6
3
|
constructor(writer) {
|
|
7
4
|
super(async (value) => await writer.write(value), 'BEFORE_START');
|
|
8
5
|
this.writer = writer;
|
|
@@ -124,4 +121,3 @@ class JsonStreamWriter extends json_stream_state_writer_1.JsonStreamStateWriter
|
|
|
124
121
|
await this.useTransition(this.stateMachine.closeSave);
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
|
-
exports.JsonStreamWriter = JsonStreamWriter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReadableStream } from 'web-streams-polyfill';
|
|
2
|
+
export declare class ReadableStreamParser {
|
|
3
|
+
private static CreateReadableStreamForParsingSave;
|
|
4
|
+
static CreateReadableStreamFromSaveToJson: (name: string, bytes: Uint8Array, onDecompressedSaveBody?: (buffer: ArrayBuffer) => void, onProgress?: (progress: number, message?: string) => void) => {
|
|
5
|
+
stream: ReadableStream<string>;
|
|
6
|
+
startStreaming: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
private static WriteHeaderAndGrids;
|
|
9
|
+
private static WriteLevels;
|
|
10
|
+
private static ReadNObjectHeaders;
|
|
11
|
+
private static ReadNObjects;
|
|
12
|
+
}
|