@etothepii/satisfactory-file-parser 0.0.10 → 0.0.12

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.
Files changed (46) hide show
  1. package/build/index.d.ts +15 -0
  2. package/build/index.js +49 -0
  3. package/build/parser/blueprint-reader.d.ts +18 -0
  4. package/build/parser/blueprint-reader.js +136 -0
  5. package/build/parser/blueprint-writer.d.ts +21 -0
  6. package/build/parser/blueprint-writer.js +69 -0
  7. package/build/parser/byte/alignment.enum.d.ts +4 -0
  8. package/build/parser/byte/alignment.enum.js +8 -0
  9. package/build/parser/byte/byte-reader.class.d.ts +38 -0
  10. package/build/parser/byte/byte-reader.class.js +132 -0
  11. package/build/parser/byte/byte-writer.class.d.ts +38 -0
  12. package/build/parser/byte/byte-writer.class.js +149 -0
  13. package/build/parser/error/parser.error.d.ts +12 -0
  14. package/build/parser/error/parser.error.js +28 -0
  15. package/build/parser/parser.d.ts +44 -0
  16. package/build/parser/parser.js +84 -0
  17. package/build/parser/satisfactory/blueprint/blueprint.d.ts +20 -0
  18. package/build/parser/satisfactory/blueprint/blueprint.js +2 -0
  19. package/build/parser/satisfactory/level.class.d.ts +21 -0
  20. package/build/parser/satisfactory/level.class.js +148 -0
  21. package/build/parser/satisfactory/objects/DataFields.d.ts +13 -0
  22. package/build/parser/satisfactory/objects/DataFields.js +249 -0
  23. package/build/parser/satisfactory/objects/ObjectReference.d.ts +9 -0
  24. package/build/parser/satisfactory/objects/ObjectReference.js +17 -0
  25. package/build/parser/satisfactory/objects/Property.d.ts +270 -0
  26. package/build/parser/satisfactory/objects/Property.js +1150 -0
  27. package/build/parser/satisfactory/objects/SaveComponent.d.ts +16 -0
  28. package/build/parser/satisfactory/objects/SaveComponent.js +31 -0
  29. package/build/parser/satisfactory/objects/SaveEntity.d.ts +25 -0
  30. package/build/parser/satisfactory/objects/SaveEntity.js +70 -0
  31. package/build/parser/satisfactory/objects/SaveObject.d.ts +14 -0
  32. package/build/parser/satisfactory/objects/SaveObject.js +29 -0
  33. package/build/parser/satisfactory/satisfactory-save.d.ts +57 -0
  34. package/build/parser/satisfactory/satisfactory-save.js +11 -0
  35. package/build/parser/satisfactory/static-data.d.ts +7 -0
  36. package/build/parser/satisfactory/static-data.js +2 -0
  37. package/build/parser/satisfactory/structs/util.types.d.ts +40 -0
  38. package/build/parser/satisfactory/structs/util.types.js +95 -0
  39. package/build/parser/save-reader.d.ts +43 -0
  40. package/build/parser/save-reader.js +251 -0
  41. package/build/parser/save-writer.d.ts +22 -0
  42. package/build/parser/save-writer.js +121 -0
  43. package/package.json +3 -3
  44. package/index.d.ts +0 -2356
  45. package/index.js +0 -2364
  46. package/rollup.config.mjs +0 -11
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Conveyor = exports.SaveReader = exports.projectionFilterApplies = void 0;
7
+ const pako_1 = __importDefault(require("pako"));
8
+ const alignment_enum_1 = require("./byte/alignment.enum");
9
+ const byte_reader_class_1 = require("./byte/byte-reader.class");
10
+ const parser_error_1 = require("./error/parser.error");
11
+ const level_class_1 = require("./satisfactory/level.class");
12
+ const SaveComponent_1 = require("./satisfactory/objects/SaveComponent");
13
+ const SaveEntity_1 = require("./satisfactory/objects/SaveEntity");
14
+ const projectionFilterApplies = (config, object) => {
15
+ let cond1 = false;
16
+ if ((0, SaveEntity_1.isSaveEntity)(object) || (config.includeComponents && (0, SaveComponent_1.isSaveComponent)(object))) {
17
+ cond1 = true;
18
+ }
19
+ let cond2 = true;
20
+ if ((0, SaveEntity_1.isSaveEntity)(object)) {
21
+ cond2 = false;
22
+ if (config.entityPathFilter.behavior === 'whitelist') {
23
+ cond2 = config.entityPathFilter.list.find(en => object.typePath.startsWith(en)) !== undefined;
24
+ }
25
+ else if (config.entityPathFilter.behavior === 'blacklist') {
26
+ cond2 = config.entityPathFilter.list.find(en => object.typePath.startsWith(en)) === undefined;
27
+ }
28
+ }
29
+ return cond1 && cond2;
30
+ };
31
+ exports.projectionFilterApplies = projectionFilterApplies;
32
+ class SaveReader extends byte_reader_class_1.ByteReader {
33
+ constructor(fileBuffer, onProgressCallback = () => { }) {
34
+ super(fileBuffer, alignment_enum_1.Alignment.LITTLE_ENDIAN);
35
+ this.onProgressCallback = onProgressCallback;
36
+ this.levels = [];
37
+ this.trailingCollectedObjects = [];
38
+ this.compressionInfo = {
39
+ packageFileTag: 0,
40
+ maxChunkContentSize: 0,
41
+ chunkHeaderSize: 48
42
+ };
43
+ }
44
+ readHeader() {
45
+ this.header = {
46
+ saveHeaderType: 0,
47
+ saveVersion: 0,
48
+ buildVersion: 0,
49
+ mapName: "DEFAULT",
50
+ mapOptions: "",
51
+ sessionName: "",
52
+ playDurationSeconds: 0,
53
+ saveDateTime: "0",
54
+ sessionVisibility: 0
55
+ };
56
+ this.header.saveHeaderType = this.readInt32();
57
+ this.header.saveVersion = this.readInt32();
58
+ this.header.buildVersion = this.readInt32();
59
+ this.header.mapName = this.readString();
60
+ this.header.mapOptions = this.readString();
61
+ this.header.sessionName = this.readString();
62
+ this.header.playDurationSeconds = this.readInt32();
63
+ const rawSaveDateTimeInTicks = this.readLong();
64
+ const unixMilliseconds = (rawSaveDateTimeInTicks - SaveReader.EPOCH_TICKS) / 10000n;
65
+ this.header.saveDateTime = unixMilliseconds.toString();
66
+ this.header.sessionVisibility = this.readByte();
67
+ if (this.header.saveHeaderType >= 7) {
68
+ this.header.fEditorObjectVersion = this.readInt32();
69
+ }
70
+ if (this.header.saveHeaderType >= 8) {
71
+ this.header.rawModMetadataString = this.readString();
72
+ try {
73
+ this.header.modMetadata = JSON.parse(this.header.rawModMetadataString);
74
+ }
75
+ catch (error) {
76
+ //
77
+ }
78
+ this.header.isModdedSave = this.readInt32();
79
+ }
80
+ if (this.header.saveHeaderType >= 10) {
81
+ this.header.saveIdentifier = this.readString();
82
+ }
83
+ if (this.header.saveVersion >= 21) {
84
+ // all good, ready to read chunks now.
85
+ }
86
+ else {
87
+ throw new parser_error_1.UnsupportedVersionError("The save version is too old to support encoding currently. Save in newer game version.");
88
+ }
89
+ return this.header;
90
+ }
91
+ inflateChunks() {
92
+ // free memory
93
+ this.fileBuffer = this.fileBuffer.slice(this.currentByte);
94
+ this.handledByte = 0;
95
+ this.currentByte = 0;
96
+ this.maxByte = this.fileBuffer.byteLength;
97
+ let currentChunks = [];
98
+ let totalUncompressedBodySize = 0;
99
+ // read while we can handle
100
+ while (this.handledByte < this.maxByte) {
101
+ // Read chunk info size...
102
+ let chunkHeader = new DataView(this.fileBuffer.slice(0, this.compressionInfo.chunkHeaderSize));
103
+ this.currentByte = this.compressionInfo.chunkHeaderSize;
104
+ this.handledByte += this.compressionInfo.chunkHeaderSize;
105
+ if (this.compressionInfo.packageFileTag <= 0) {
106
+ this.compressionInfo.packageFileTag = chunkHeader.getInt32(0, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
107
+ }
108
+ if (this.compressionInfo.maxChunkContentSize <= 0) {
109
+ this.compressionInfo.maxChunkContentSize = chunkHeader.getInt32(8, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
110
+ }
111
+ const chunkCompressedLength = chunkHeader.getInt32(32, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
112
+ const chunkUncompressedLength = chunkHeader.getInt32(40, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
113
+ totalUncompressedBodySize += chunkUncompressedLength;
114
+ const currentChunkSize = chunkCompressedLength;
115
+ let currentChunk = this.fileBuffer.slice(this.currentByte, this.currentByte + currentChunkSize);
116
+ this.handledByte += currentChunkSize;
117
+ this.currentByte += currentChunkSize;
118
+ // Free memory from previous chunk...
119
+ this.fileBuffer = this.fileBuffer.slice(this.currentByte);
120
+ this.currentByte = 0;
121
+ // Unzip!
122
+ try {
123
+ // Inflate current chunk
124
+ let currentInflatedChunk = null;
125
+ currentInflatedChunk = pako_1.default.inflate(currentChunk);
126
+ currentChunks.push(currentInflatedChunk);
127
+ }
128
+ catch (err) {
129
+ throw new parser_error_1.CompressionLibraryError("Failed to inflate compressed save data. " + err);
130
+ }
131
+ }
132
+ //TODO we can get rid of file buffer here.
133
+ // Create one big chunk out of the little chunks
134
+ let newChunkLength = currentChunks.map(cc => cc.length).reduce((prev, cur) => prev + cur);
135
+ const bigWholeChunk = new Uint8Array(newChunkLength);
136
+ let currentLength = 0;
137
+ for (let i = 0; i < currentChunks.length; i++) {
138
+ bigWholeChunk.set(currentChunks[i], currentLength);
139
+ currentLength += currentChunks[i].length;
140
+ }
141
+ this.currentByte = 0;
142
+ this.maxByte = bigWholeChunk.buffer.byteLength;
143
+ this.bufferView = new DataView(bigWholeChunk.buffer);
144
+ const dataLength = this.readInt32();
145
+ if (totalUncompressedBodySize !== dataLength + 4) {
146
+ throw new parser_error_1.CorruptSaveError(`Possibly corrupt. Indicated size of total save body (${dataLength}) does not match the uncompressed real size of ${totalUncompressedBodySize}.`);
147
+ }
148
+ return {
149
+ concatenatedChunkLength: newChunkLength,
150
+ numChunks: currentChunks.length
151
+ };
152
+ }
153
+ readLevels() {
154
+ if (!this.header) {
155
+ throw new parser_error_1.ParserError('ParserError', 'Header must be set before objects can be read.');
156
+ }
157
+ if (this.header.saveVersion < 29) {
158
+ throw new parser_error_1.UnsupportedVersionError('Support for < U6 is not yet implemented.');
159
+ }
160
+ const numSubLevels = this.readInt32();
161
+ this.levels = new Array(numSubLevels + 1);
162
+ // read levels
163
+ for (let j = 0; j <= numSubLevels; j++) {
164
+ let levelName = (j === numSubLevels) ? '' + this.header.mapName : this.readString();
165
+ this.onProgressCallback(this.getBufferProgress(), `reading level [${(j + 1)}/${(numSubLevels + 1)}] ${levelName}`);
166
+ this.levels[j] = level_class_1.Level.ReadLevel(this, levelName, this.header.buildVersion);
167
+ }
168
+ // in U6/U7 there were more collectibles added that do not belong to a particular level
169
+ if (this.getBufferPosition() < this.bufferView.byteLength) {
170
+ this.trailingCollectedObjects = level_class_1.Level.ReadCollectablesList(this);
171
+ }
172
+ return this.levels;
173
+ }
174
+ }
175
+ // the number of .net ticks at the unix epoch
176
+ SaveReader.EPOCH_TICKS = 621355968000000000n;
177
+ exports.SaveReader = SaveReader;
178
+ class Conveyor {
179
+ static getConveyorBeltRegex() {
180
+ return /\/Game\/FactoryGame\/Buildable\/Factory\/(ConveyorBeltMk[0-9]+)\/Build_(\1)\.Build_(\1)_C/g;
181
+ }
182
+ ;
183
+ static getConveyorLiftRegex() {
184
+ return /\/Game\/FactoryGame\/Buildable\/Factory\/(ConveyorLiftMk[0-9]+)\/Build_(\1)\.Build_(\1)_C/g;
185
+ }
186
+ ;
187
+ static isAConveyorBelt(obj) {
188
+ return obj.typePath.match(this.getConveyorBeltRegex()) !== null;
189
+ }
190
+ static isAConveyorLift(obj) {
191
+ return obj.typePath.match(this.getConveyorLiftRegex()) !== null;
192
+ }
193
+ static get availableConnections() { return ['.ConveyorAny0', '.ConveyorAny1', '.Input0', '.Input1', '.Input2', '.Input3', '.InPut3', '.Input4', '.Input5', '.Input6', '.Output0', '.Output1', '.Output2', '.Output3']; }
194
+ static get availableConveyorBelts() {
195
+ return [
196
+ '/Game/FactoryGame/Buildable/Factory/ConveyorBeltMk1/Build_ConveyorBeltMk1.Build_ConveyorBeltMk1_C',
197
+ '/Game/FactoryGame/Buildable/Factory/ConveyorBeltMk2/Build_ConveyorBeltMk2.Build_ConveyorBeltMk2_C',
198
+ '/Game/FactoryGame/Buildable/Factory/ConveyorBeltMk3/Build_ConveyorBeltMk3.Build_ConveyorBeltMk3_C',
199
+ '/Game/FactoryGame/Buildable/Factory/ConveyorBeltMk4/Build_ConveyorBeltMk4.Build_ConveyorBeltMk4_C',
200
+ '/Game/FactoryGame/Buildable/Factory/ConveyorBeltMk5/Build_ConveyorBeltMk5.Build_ConveyorBeltMk5_C'
201
+ ];
202
+ }
203
+ static get availableConveyorLifts() {
204
+ return [
205
+ '/Game/FactoryGame/Buildable/Factory/ConveyorLiftMk1/Build_ConveyorLiftMk1.Build_ConveyorLiftMk1_C',
206
+ '/Game/FactoryGame/Buildable/Factory/ConveyorLiftMk2/Build_ConveyorLiftMk2.Build_ConveyorLiftMk2_C',
207
+ '/Game/FactoryGame/Buildable/Factory/ConveyorLiftMk3/Build_ConveyorLiftMk3.Build_ConveyorLiftMk3_C',
208
+ '/Game/FactoryGame/Buildable/Factory/ConveyorLiftMk4/Build_ConveyorLiftMk4.Build_ConveyorLiftMk4_C',
209
+ '/Game/FactoryGame/Buildable/Factory/ConveyorLiftMk5/Build_ConveyorLiftMk5.Build_ConveyorLiftMk5_C'
210
+ ];
211
+ }
212
+ /*
213
+ * BELT/LIFT LOOKUP, includes mods to avoid finding them everywhere
214
+ */
215
+ static isConveyor(currentObject) {
216
+ return Conveyor.isConveyorBelt(currentObject) || Conveyor.isConveyorLift(currentObject);
217
+ }
218
+ static isConveyorBelt(currentObject) {
219
+ if (Conveyor.availableConveyorBelts.includes(currentObject.className)) {
220
+ return true;
221
+ }
222
+ // Belts Mod
223
+ if (currentObject.className.startsWith('/Conveyors_Mod/Build_BeltMk')
224
+ || currentObject.className.startsWith('/Game/Conveyors_Mod/Build_BeltMk')
225
+ || currentObject.className.startsWith('/UltraFastLogistics/Buildable/build_conveyorbeltMK')
226
+ || currentObject.className.startsWith('/FlexSplines/Conveyor/Build_Belt')
227
+ || currentObject.className.startsWith('/conveyorbeltmod/Belt/mk')
228
+ || currentObject.className.startsWith('/minerplus/content/buildable/Factory/belt_')
229
+ || currentObject.className.startsWith('/bamfp/content/buildable/Factory/belt_')) {
230
+ return true;
231
+ }
232
+ return false;
233
+ }
234
+ static isConveyorLift(currentObject) {
235
+ if (Conveyor.availableConveyorLifts.includes(currentObject.className)) {
236
+ return true;
237
+ }
238
+ // Lifts Mod
239
+ if (currentObject.className.startsWith('/minerplus/content/buildable/Factory/lift')
240
+ || currentObject.className.startsWith('/bamfp/content/buildable/Factory/lift')
241
+ || currentObject.className.startsWith('/Game/Conveyors_Mod/Build_LiftMk')
242
+ || currentObject.className.startsWith('/Conveyors_Mod/Build_LiftMk')
243
+ || currentObject.className.startsWith('/Game/CoveredConveyor')
244
+ || currentObject.className.startsWith('/CoveredConveyor')
245
+ || currentObject.className.startsWith('/conveyorbeltmod/lift/')) {
246
+ return true;
247
+ }
248
+ return false;
249
+ }
250
+ }
251
+ exports.Conveyor = Conveyor;
@@ -0,0 +1,22 @@
1
+ import { Alignment } from "./byte/alignment.enum";
2
+ import { ByteWriter } from "./byte/byte-writer.class";
3
+ import { ChunkCompressionInfo, SatisfactorySave, SatisfactorySaveHeader } from "./satisfactory/satisfactory-save";
4
+ export declare class SaveWriter extends ByteWriter {
5
+ constructor();
6
+ static WriteHeader(writer: ByteWriter, header: SatisfactorySaveHeader): void;
7
+ static WriteLevels(writer: ByteWriter, save: SatisfactorySave, buildVersion: number): void;
8
+ static GenerateCompressedChunksFromData(bufferArray: ArrayBuffer, compressionInfo: ChunkCompressionInfo, onBinaryBeforeCompressing: (binary: ArrayBuffer) => void, onChunk: (chunk: Uint8Array) => void, onFinish: (summary: {
9
+ errors: string[];
10
+ chunkSummary: {
11
+ uncompressedSize: number;
12
+ compressedSize: number;
13
+ }[];
14
+ }) => void, alignment?: Alignment): void;
15
+ generateChunks(compressionInfo: ChunkCompressionInfo, posAfterHeader: number, onBinaryBeforeCompressing: (binary: ArrayBuffer) => void, onHeader: (header: Uint8Array) => void, onChunk: (chunk: Uint8Array) => void, onFinish: (summary: {
16
+ errors: string[];
17
+ chunkSummary: {
18
+ uncompressedSize: number;
19
+ compressedSize: number;
20
+ }[];
21
+ }) => void): void;
22
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SaveWriter = void 0;
7
+ const pako_1 = __importDefault(require("pako"));
8
+ const alignment_enum_1 = require("./byte/alignment.enum");
9
+ const byte_writer_class_1 = require("./byte/byte-writer.class");
10
+ const parser_error_1 = require("./error/parser.error");
11
+ const level_class_1 = require("./satisfactory/level.class");
12
+ class SaveWriter extends byte_writer_class_1.ByteWriter {
13
+ constructor() {
14
+ super(alignment_enum_1.Alignment.LITTLE_ENDIAN);
15
+ }
16
+ static WriteHeader(writer, header) {
17
+ writer.writeInt32(header.saveHeaderType);
18
+ writer.writeInt32(header.saveVersion);
19
+ writer.writeInt32(header.buildVersion);
20
+ writer.writeString(header.mapName);
21
+ writer.writeString(header.mapOptions);
22
+ writer.writeString(header.sessionName);
23
+ writer.writeInt32(header.playDurationSeconds);
24
+ writer.writeInt64(BigInt(header.saveDateTime));
25
+ writer.writeByte(header.sessionVisibility);
26
+ if (header.saveHeaderType >= 7) {
27
+ writer.writeInt32(header.fEditorObjectVersion);
28
+ }
29
+ if (header.saveHeaderType >= 8) {
30
+ if (header.modMetadata) {
31
+ writer.writeString(JSON.stringify(header.modMetadata));
32
+ }
33
+ else {
34
+ writer.writeString(header.rawModMetadataString);
35
+ }
36
+ writer.writeInt32(header.isModdedSave);
37
+ }
38
+ if (header.saveHeaderType >= 10) {
39
+ writer.writeString(header.saveIdentifier);
40
+ }
41
+ if (header.saveVersion >= 21) {
42
+ // ready to write levels now.
43
+ }
44
+ else {
45
+ throw new parser_error_1.UnsupportedVersionError("The save version is too old to be supported currently.");
46
+ }
47
+ }
48
+ static WriteLevels(writer, save, buildVersion) {
49
+ writer.writeInt32(save.levels.length - 1);
50
+ for (const level of save.levels) {
51
+ if (level.name !== save.header.mapName) {
52
+ writer.writeString(level.name);
53
+ }
54
+ level_class_1.Level.WriteLevel(writer, level, buildVersion);
55
+ }
56
+ level_class_1.Level.SerializeCollectablesList(writer, save.trailingCollectedObjects);
57
+ }
58
+ static GenerateCompressedChunksFromData(bufferArray, compressionInfo, onBinaryBeforeCompressing, onChunk, onFinish, alignment = alignment_enum_1.Alignment.LITTLE_ENDIAN) {
59
+ const errors = [];
60
+ const totalUncompressedSize = bufferArray.byteLength;
61
+ const saveBody = new Uint8Array(bufferArray.byteLength + 4);
62
+ saveBody.set(new Uint8Array(bufferArray), 4);
63
+ const miniView = new DataView(saveBody.buffer);
64
+ miniView.setInt32(0, totalUncompressedSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
65
+ onBinaryBeforeCompressing(saveBody.buffer);
66
+ // collect slices of chunks with help of compression info for max chunk size
67
+ let handledByte = 0;
68
+ const chunkSummary = [];
69
+ while (handledByte < saveBody.byteLength) {
70
+ // create uncompressed chunk.
71
+ const uncompressedContentSize = Math.min(compressionInfo.maxChunkContentSize, saveBody.byteLength - handledByte);
72
+ const uncompressedChunk = saveBody.buffer.slice(handledByte, handledByte + uncompressedContentSize);
73
+ // deflate chunk while we're at it.
74
+ let compressedChunk = new Uint8Array(0);
75
+ try {
76
+ compressedChunk = pako_1.default.deflate(uncompressedChunk);
77
+ }
78
+ catch (err) {
79
+ errors.push("An error occurred while calling pako deflate. -> " + err);
80
+ }
81
+ const chunk = new Uint8Array(compressionInfo.chunkHeaderSize + compressedChunk.byteLength);
82
+ chunk.set(compressedChunk, compressionInfo.chunkHeaderSize);
83
+ // write header
84
+ const view = new DataView(chunk.buffer);
85
+ view.setInt32(0, compressionInfo.packageFileTag, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
86
+ view.setInt32(4, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
87
+ view.setInt32(8, compressionInfo.maxChunkContentSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
88
+ view.setInt32(12, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
89
+ view.setInt32(16, compressedChunk.byteLength, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
90
+ view.setInt32(20, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
91
+ view.setInt32(24, uncompressedContentSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
92
+ view.setInt32(28, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
93
+ view.setInt32(32, compressedChunk.byteLength, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
94
+ view.setInt32(36, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
95
+ view.setInt32(40, uncompressedContentSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
96
+ view.setInt32(44, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
97
+ onChunk(chunk);
98
+ chunkSummary.push({
99
+ uncompressedSize: uncompressedContentSize + compressionInfo.chunkHeaderSize,
100
+ compressedSize: compressedChunk.byteLength + compressionInfo.chunkHeaderSize
101
+ });
102
+ handledByte += uncompressedContentSize;
103
+ }
104
+ onFinish({
105
+ errors,
106
+ chunkSummary
107
+ });
108
+ }
109
+ generateChunks(compressionInfo, posAfterHeader, onBinaryBeforeCompressing, onHeader, onChunk, onFinish) {
110
+ if (posAfterHeader <= 0) {
111
+ throw new parser_error_1.ParserError('ParserError', 'Seems like this buffer has no header. Please write the header first before you can generate chunks.');
112
+ }
113
+ // send plain header first.
114
+ const header = new Uint8Array(this.bufferArray.slice(0, posAfterHeader));
115
+ onHeader(header);
116
+ // create save body
117
+ this.bufferArray = this.bufferArray.slice(posAfterHeader);
118
+ SaveWriter.GenerateCompressedChunksFromData(this.bufferArray, compressionInfo, onBinaryBeforeCompressing, onChunk, onFinish, this.alignment);
119
+ }
120
+ }
121
+ exports.SaveWriter = SaveWriter;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@etothepii/satisfactory-file-parser",
3
3
  "author": "etothepii",
4
- "version": "0.0.10",
4
+ "version": "0.0.12",
5
5
  "description": "A file parser for satisfactory files. Includes save files and blueprint files.",
6
- "main": "index.js",
6
+ "main": "build/index.js",
7
7
  "keywords": [
8
8
  "satisfactory",
9
9
  "save",
@@ -15,7 +15,7 @@
15
15
  "scripts": {
16
16
  "test": "jest --config=jest.config.json",
17
17
  "build": "tsc",
18
- "prepublish": "rollup -c && npm version patch"
18
+ "prepublish": "npm version patch"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",