@etothepii/satisfactory-file-parser 0.0.33 → 0.1.1

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 (38) hide show
  1. package/README.md +12 -8
  2. package/build/index.js +41 -51
  3. package/build/parser/byte/alignment.enum.js +8 -18
  4. package/build/parser/byte/binary-operable.interface.js +2 -12
  5. package/build/parser/byte/binary-readable.interface.js +2 -12
  6. package/build/parser/byte/byte-reader.class.js +122 -132
  7. package/build/parser/byte/byte-writer.class.js +133 -143
  8. package/build/parser/error/parser.error.js +40 -50
  9. package/build/parser/file.types.js +2 -12
  10. package/build/parser/parser.js +84 -95
  11. package/build/parser/satisfactory/blueprint/blueprint-reader.js +109 -119
  12. package/build/parser/satisfactory/blueprint/blueprint-writer.js +56 -66
  13. package/build/parser/satisfactory/blueprint/blueprint.types.js +2 -12
  14. package/build/parser/satisfactory/objects/DataFields.js +306 -307
  15. package/build/parser/satisfactory/objects/ObjectReference.js +14 -24
  16. package/build/parser/satisfactory/objects/Property.js +974 -977
  17. package/build/parser/satisfactory/objects/SaveComponent.js +28 -38
  18. package/build/parser/satisfactory/objects/SaveEntity.js +69 -75
  19. package/build/parser/satisfactory/objects/SaveObject.js +26 -36
  20. package/build/parser/satisfactory/save/asynchronous-level.class.js +60 -70
  21. package/build/parser/satisfactory/save/level.class.d.ts +1 -1
  22. package/build/parser/satisfactory/save/level.class.js +147 -128
  23. package/build/parser/satisfactory/save/satisfactory-save.js +10 -20
  24. package/build/parser/satisfactory/save/save-reader.d.ts +2 -2
  25. package/build/parser/satisfactory/save/save-reader.js +209 -171
  26. package/build/parser/satisfactory/save/save-writer.js +97 -107
  27. package/build/parser/satisfactory/save/save.types.js +2 -12
  28. package/build/parser/satisfactory/structs/util.types.d.ts +6 -0
  29. package/build/parser/satisfactory/structs/util.types.js +122 -96
  30. package/build/parser/stream/byte-stream-reader.class.js +217 -227
  31. package/build/parser/stream/json-stream-state-writer.js +15 -25
  32. package/build/parser/stream/json-stream-writable.js +72 -82
  33. package/build/parser/stream/json-stream-writer.js +122 -132
  34. package/build/parser/stream/save-stream-json-stringifier.js +29 -39
  35. package/build/parser/stream/save-stream-reader.class.js +106 -116
  36. package/build/parser/stream/save-stream-writer.class.js +90 -100
  37. package/build/parser/stream/stream-level.class.js +93 -103
  38. package/package.json +2 -2
@@ -1,251 +1,241 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "../byte/alignment.enum", "../byte/byte-writer.class", "../error/parser.error"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ByteStreamReader = void 0;
13
- const alignment_enum_1 = require("../byte/alignment.enum");
14
- const byte_writer_class_1 = require("../byte/byte-writer.class");
15
- const parser_error_1 = require("../error/parser.error");
16
- class ByteStreamReader {
17
- constructor(reader, onCloseCallback, timeout = 30000, maxBufferThreshold = 100 * 1000 * 1000, alignment = alignment_enum_1.Alignment.LITTLE_ENDIAN) {
18
- this.reader = reader;
19
- this.onCloseCallback = onCloseCallback;
20
- this.timeout = timeout;
21
- this.maxBufferThreshold = maxBufferThreshold;
22
- this.alignment = alignment;
23
- this.debug = false;
24
- this.closedAlready = false;
25
- this.totalNumberOfBytesRead = 0;
26
- this.trailingBufferSize = 0;
27
- this.continuousRead = async () => {
28
- while (!this.inputStreamIsDone && !this.paused) {
29
- const { done, value } = await this.reader.read();
30
- if (!this.inputStreamIsDone) {
31
- if (value) {
32
- const trailingPos = Math.max(0, this.currentByte - this.trailingBufferSize);
33
- this.operatingStreamBuffer = new Uint8Array(byte_writer_class_1.ByteWriter.AppendBuffer(this.operatingStreamBuffer.slice(trailingPos), value));
34
- this.operatingDataView = new DataView(this.operatingStreamBuffer.buffer);
35
- this.currentByte = Math.min(this.currentByte, this.trailingBufferSize);
36
- if (this.operatingStreamBuffer.byteLength > this.maxBufferThreshold) {
37
- console.warn('pausing due to size.');
38
- this.pause();
39
- }
40
- if (this.callbackAfterRead) {
41
- this.callbackAfterRead();
42
- }
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();
43
33
  }
44
34
  }
45
- else {
46
- this.close();
47
- }
48
- this.inputStreamIsDone = done;
49
35
  }
50
- };
51
- this.operatingStreamBuffer = new Uint8Array();
52
- this.operatingDataView = new DataView(this.operatingStreamBuffer.buffer);
53
- this.inputStreamIsDone = false;
54
- this.currentByte = 0;
55
- this.neededNextAmountOfBytes = 0;
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) {
56
63
  this.paused = false;
57
- this.trailingBufferSize = 2000;
58
64
  this.readLoopHandle = setTimeout(this.continuousRead);
59
- this.waitingTimeoutHandle = undefined;
60
65
  }
61
- pause() {
62
- this.paused = true;
63
- clearTimeout(this.readLoopHandle);
64
- this.readLoopHandle = undefined;
65
- if (this.waitingTimeoutHandle) {
66
- clearTimeout(this.waitingTimeoutHandle);
67
- this.waitingTimeoutHandle = undefined;
68
- }
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?`);
69
79
  }
70
- resume() {
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
+ }
71
84
  if (this.paused) {
72
- this.paused = false;
73
- this.readLoopHandle = setTimeout(this.continuousRead);
85
+ this.resume();
74
86
  }
87
+ await this.waitUntilNumBytesAvailable(count);
75
88
  }
76
- hasInput() {
77
- return !this.inputStreamIsDone;
78
- }
79
- async close() {
80
- this.inputStreamIsDone = true;
81
- this.pause();
82
- await this.onCloseCallback();
83
- this.closedAlready = true;
84
- }
85
- async allocate(count) {
86
- if (count > this.maxBufferThreshold * 0.5) {
87
- console.warn(`you are waiting for a very big chunk here mate. ${count} bytes. U sure you have your numbers right?`);
88
- }
89
- if (this.getAmountAllocatedLeft() < count) {
90
- if (this.inputStreamIsDone) {
91
- throw new parser_error_1.CorruptSaveError('Input Stream has finished before needed data was received.');
92
- }
93
- if (this.paused) {
94
- this.resume();
95
- }
96
- await this.waitUntilNumBytesAvailable(count);
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();
97
96
  }
98
- }
99
- waitUntilNumBytesAvailable(count) {
100
- this.neededNextAmountOfBytes = count;
101
- return new Promise((resolve, reject) => {
97
+ this.callbackAfterRead = () => {
102
98
  if (this.getAmountAllocatedLeft() >= this.neededNextAmountOfBytes) {
99
+ if (this.waitingTimeoutHandle) {
100
+ clearTimeout(this.waitingTimeoutHandle);
101
+ }
103
102
  this.neededNextAmountOfBytes = 0;
103
+ this.callbackAfterRead = undefined;
104
104
  return resolve();
105
105
  }
106
- this.callbackAfterRead = () => {
107
- if (this.getAmountAllocatedLeft() >= this.neededNextAmountOfBytes) {
108
- if (this.waitingTimeoutHandle) {
109
- clearTimeout(this.waitingTimeoutHandle);
110
- }
111
- this.neededNextAmountOfBytes = 0;
112
- this.callbackAfterRead = undefined;
113
- return resolve();
114
- }
115
- };
116
- if (this.waitingTimeoutHandle) {
117
- clearTimeout(this.waitingTimeoutHandle);
118
- }
119
- this.waitingTimeoutHandle = setTimeout(() => {
120
- if (!this.inputStreamIsDone) {
121
- reject(new parser_error_1.TimeoutError(`Timed out before ${this.neededNextAmountOfBytes} bytes were available to read next.`));
122
- }
123
- return resolve();
124
- }, this.timeout);
125
- });
126
- }
127
- skipBytes(byteLength = 1) {
128
- this.currentByte += byteLength;
129
- this.totalNumberOfBytesRead += byteLength;
130
- return;
131
- }
132
- readByte() {
133
- this.totalNumberOfBytesRead += 1;
134
- return this.operatingDataView.getUint8(this.currentByte++);
135
- }
136
- readBytes(count) {
137
- this.totalNumberOfBytesRead += count;
138
- return new Uint8Array(new Array(count).fill(0).map(pl => this.operatingDataView.getUint8(this.currentByte++)));
139
- }
140
- readHex(hexLength) {
141
- let hexPart = [];
142
- for (let i = 0; i < hexLength; i++) {
143
- let currentHex = String.fromCharCode(this.operatingDataView.getUint8(this.currentByte++));
144
- hexPart.push(currentHex);
106
+ };
107
+ if (this.waitingTimeoutHandle) {
108
+ clearTimeout(this.waitingTimeoutHandle);
145
109
  }
146
- this.totalNumberOfBytesRead += hexLength;
147
- return hexPart.join('');
148
- }
149
- readInt8() {
150
- this.totalNumberOfBytesRead += 1;
151
- let data = this.operatingDataView.getInt8(this.currentByte++);
152
- return data;
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 '';
153
205
  }
154
- readUint8() {
155
- this.totalNumberOfBytesRead += 1;
156
- let data = this.operatingDataView.getUint8(this.currentByte++);
157
- return data;
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);
158
209
  }
159
- readInt16() {
160
- this.totalNumberOfBytesRead += 2;
161
- let data = this.operatingDataView.getInt16(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
210
+ if (strLength < 0) {
211
+ const string = new Array(-strLength - 1).fill('').map(c => String.fromCharCode(this.readUint16()));
162
212
  this.currentByte += 2;
163
- return data;
164
- }
165
- readUint16() {
166
213
  this.totalNumberOfBytesRead += 2;
167
- let data = this.operatingDataView.getUint16(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
168
- this.currentByte += 2;
169
- return data;
214
+ return string.join('');
170
215
  }
171
- readInt32() {
172
- this.totalNumberOfBytesRead += 4;
173
- let data = this.operatingDataView.getInt32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
174
- this.currentByte += 4;
175
- return data;
176
- }
177
- readUint32() {
178
- this.totalNumberOfBytesRead += 4;
179
- let data = this.operatingDataView.getUint32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
180
- this.currentByte += 4;
181
- return data;
182
- }
183
- readLong() {
184
- this.totalNumberOfBytesRead += 8;
185
- let data = this.operatingDataView.getBigInt64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
186
- this.currentByte += 8;
187
- return data;
188
- }
189
- readInt64() {
190
- return this.readLong();
191
- }
192
- readUint64() {
193
- this.totalNumberOfBytesRead += 8;
194
- let data = this.operatingDataView.getBigUint64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
195
- this.currentByte += 8;
196
- return data;
197
- }
198
- readFloat32() {
199
- this.totalNumberOfBytesRead += 4;
200
- let data = this.operatingDataView.getFloat32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
201
- this.currentByte += 4;
202
- return data;
203
- }
204
- readDouble() {
205
- this.totalNumberOfBytesRead += 8;
206
- let data = this.operatingDataView.getFloat64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
207
- this.currentByte += 8;
208
- return data;
209
- }
210
- readString() {
211
- let strLength = this.readInt32();
212
- if (strLength === 0) {
213
- return '';
214
- }
215
- if (strLength > (this.operatingDataView.buffer.byteLength - this.currentByte)) {
216
- let errorMessage = `Cannot read string of length ${strLength} at position ${this.currentByte} as it exceeds the end at ${this.operatingDataView.buffer.byteLength}`;
217
- throw new Error(errorMessage);
218
- }
219
- if (strLength < 0) {
220
- const string = new Array(-strLength - 1).fill('').map(c => String.fromCharCode(this.readUint16()));
221
- this.currentByte += 2;
222
- this.totalNumberOfBytesRead += 2;
223
- return string.join('');
224
- }
225
- try {
226
- const string = new Array(strLength - 1).fill('').map(c => String.fromCharCode(this.readUint8()));
227
- this.currentByte += 1;
228
- this.totalNumberOfBytesRead += 1;
229
- return string.join('');
230
- }
231
- catch (error) {
232
- let errorMessage = `Cannot read UTF8 string of length ${strLength} at position ${this.currentByte}.`;
233
- console.log(errorMessage, error);
234
- throw error;
235
- }
236
- }
237
- getBufferPosition() {
238
- return this.totalNumberOfBytesRead;
239
- }
240
- getBufferProgress() {
241
- throw new parser_error_1.UnimplementedError();
242
- }
243
- getBufferLength() {
244
- return this.operatingStreamBuffer.byteLength;
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('');
245
221
  }
246
- getAmountAllocatedLeft() {
247
- return this.operatingStreamBuffer.byteLength - this.currentByte;
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;
248
226
  }
249
227
  }
250
- exports.ByteStreamReader = ByteStreamReader;
251
- });
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,28 +1,18 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
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;
5
9
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./json-stream-writable"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.JsonStreamStateWriter = void 0;
13
- const json_stream_writable_1 = require("./json-stream-writable");
14
- class JsonStreamStateWriter extends json_stream_writable_1.JsonStreamWritable {
15
- constructor(pushWritable, startState) {
16
- super(pushWritable);
17
- this.currentState = startState;
18
- }
19
- async useTransition(transition, ...params) {
20
- if (!transition.requiresOneOfThemToBeBefore.includes(this.currentState)) {
21
- throw new Error(`Invalid command. Method ${transition.name} is not allowed to be called at this state.`);
22
- }
23
- await transition.do(...params);
24
- this.currentState = transition.assignOnFinish;
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.`);
25
13
  }
14
+ await transition.do(...params);
15
+ this.currentState = transition.assignOnFinish;
26
16
  }
27
- exports.JsonStreamStateWriter = JsonStreamStateWriter;
28
- });
17
+ }
18
+ exports.JsonStreamStateWriter = JsonStreamStateWriter;