@zebbedaja/er-save-parser 0.1.2 → 0.1.4

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/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@
2
2
  type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
3
3
  interface ParseOptions {
4
4
  logLevel?: LogLevel;
5
+ includeEventFlagUInt8Array?: boolean;
5
6
  }
6
7
  interface Save {
7
8
  magicBytes?: string;
@@ -79,6 +80,7 @@ interface Slot {
79
80
  notAloneFlag?: number;
80
81
  inGameCountdownTimer?: number;
81
82
  eventFlags?: EventFlag[];
83
+ eventFlagUint8Array?: Uint8Array;
82
84
  }
83
85
  interface Character {
84
86
  unk0x0?: number;
@@ -141,6 +143,12 @@ interface EventFlag {
141
143
  location?: string;
142
144
  state?: boolean;
143
145
  }
146
+ interface BitDifference {
147
+ offset: number;
148
+ bitIndex: number;
149
+ oldBit: 0 | 1;
150
+ newBit: 0 | 1;
151
+ }
144
152
  //#endregion
145
153
  //#region src/parser.d.ts
146
154
  /**
@@ -149,8 +157,93 @@ interface EventFlag {
149
157
  * @param buffer - The ArrayBuffer containing the save file data
150
158
  * @param options - Optional configuration for parsing
151
159
  * @param options.logLevel - Log level threshold: 'debug', 'info', 'warn', 'error', or 'none'. Defaults to 'error'
160
+ * @param options.includeEventFlagUInt8Array - Includes the raw event flag array data
152
161
  * @returns A Save object containing parsed slot and profile data
153
162
  */
154
163
  declare function parse(buffer: ArrayBuffer, options?: ParseOptions): Save;
155
164
  //#endregion
156
- export { type Character, type EventFlag, type LogLevel, type ParseOptions, type ProfileSummary, type Save, type Settings, type Slot, parse };
165
+ //#region src/util.d.ts
166
+ /**
167
+ * Compare two ArrayBuffers for byte-by-byte equality.
168
+ *
169
+ * @param buf1 - The first ArrayBuffer to compare
170
+ * @param buf2 - The second ArrayBuffer to compare
171
+ * @returns True if both buffers have identical byte content
172
+ */
173
+ declare function arrayBuffersEqual(buf1: ArrayBuffer, buf2: ArrayBuffer): boolean;
174
+ /**
175
+ * Convert a string into an array of byte values.
176
+ *
177
+ * @param string - The string to convert
178
+ * @returns An array of ASCII/Unicode byte values for each character
179
+ */
180
+ declare function stringToBytes(string: string): number[];
181
+ /**
182
+ * Convert an ArrayBuffer to a lowercase hexadecimal string.
183
+ *
184
+ * @param buffer - The ArrayBuffer to convert
185
+ * @returns A lowercase hexadecimal string representation of the buffer
186
+ */
187
+ declare function toHexString(buffer: ArrayBuffer): string;
188
+ /**
189
+ * Remove all null ('\x00') characters from a string.
190
+ *
191
+ * @param text - The string to clean
192
+ * @returns The input string with all null ('\x00') characters removed
193
+ */
194
+ declare const trim: (text: string) => string;
195
+ /**
196
+ * Parse a string of delimiter-separated "key,value" pairs into a Map.
197
+ *
198
+ * @param text - A string of delimiter-separated pairs, one per line
199
+ * @param delimiter - The character separating key and value (default: ",")
200
+ * @returns A Map with numeric keys and values parsed from the input
201
+ */
202
+ declare const parseToMap: (text: string, delimiter?: string) => Map<number, number>;
203
+ /**
204
+ * Returns tha Bst Map as a Map
205
+ *
206
+ * @returns Bst Map as Map
207
+ */
208
+ declare const getBstMap: () => Map<number, number>;
209
+ /**
210
+ * Determine whether a specific event flag is set.
211
+ *
212
+ * @param bstMap - A map of block IDs to their binary offsets
213
+ * @param eventFlags - The raw event_flags byte array from the save data
214
+ * @param eventId - The event ID to check
215
+ * @returns True if the event flag is set (active), false otherwise
216
+ */
217
+ declare const getEventFlagState: (bstMap: Map<number, number>, eventFlags: Uint8Array, eventId: number) => boolean;
218
+ /**
219
+ * Determine the event ID from a byte position and bit index.
220
+ *
221
+ * @param bstMap - A map of block IDs to their binary offsets
222
+ * @param bytePos - The byte position in the event_flags array
223
+ * @param bitIndex - The bit index within the byte (0-7)
224
+ * @returns The event ID corresponding to the given position
225
+ */
226
+ declare const getEventIdFromPosition: (bstMap: Map<number, number>, bytePos: number, bitIndex: number) => number;
227
+ /**
228
+ * Compares two Uint8Arrays and returns all bit-level differences.
229
+ *
230
+ * Arrays of different lengths are supported — missing bytes in the shorter
231
+ * array are treated as `0`.
232
+ *
233
+ * @param a - The original Uint8Array.
234
+ * @param b - The Uint8Array to compare against.
235
+ * @returns An array of {@link BitDifference} objects, one per differing bit.
236
+ *
237
+ * @example
238
+ * const a = new Uint8Array([0b00001111, 0b11110000]);
239
+ * const b = new Uint8Array([0b00001111, 0b10110001]);
240
+ *
241
+ * const diffs = compareUint8Arrays(a, b);
242
+ * // [
243
+ * // { offset: 1, bitIndex: 0, oldBit: 0, newBit: 1 },
244
+ * // { offset: 1, bitIndex: 6, oldBit: 1, newBit: 0 },
245
+ * // ]
246
+ */
247
+ declare const compareUint8Arrays: (a: Uint8Array, b: Uint8Array) => BitDifference[];
248
+ //#endregion
249
+ export { type BitDifference, type Character, type EventFlag, type LogLevel, type ParseOptions, type ProfileSummary, type Save, type Settings, type Slot, arrayBuffersEqual, compareUint8Arrays, getBstMap, getEventFlagState, getEventIdFromPosition, parse, parseToMap, stringToBytes, toHexString, trim };