@zebbedaja/er-save-parser 0.1.1 → 0.1.3
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/README.md +12 -0
- package/dist/index.d.mts +80 -2
- package/dist/index.mjs +6630 -6547
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -33,8 +33,14 @@ import { parse, type Save, type Slot, type Character } from '@zebbedaja/er-save-
|
|
|
33
33
|
import { readFileSync } from 'fs'
|
|
34
34
|
|
|
35
35
|
const buffer = readFileSync('ER0000.sl2').buffer
|
|
36
|
+
|
|
37
|
+
// Default: only errors are logged (logLevel: 'error')
|
|
36
38
|
const save: Save = parse(buffer)
|
|
37
39
|
|
|
40
|
+
// Optional: configure logging with one of 'debug', 'info', 'warn', 'error', 'none'
|
|
41
|
+
// const save: Save = parse(buffer, { logLevel: 'debug' }) // Verbose progress logs
|
|
42
|
+
// const save: Save = parse(buffer, { logLevel: 'none' }) // Silent
|
|
43
|
+
|
|
38
44
|
console.log(save.steamId)
|
|
39
45
|
console.log(save.settings?.hud)
|
|
40
46
|
|
|
@@ -65,8 +71,14 @@ import { parse } from '@zebbedaja/er-save-parser'
|
|
|
65
71
|
import { readFileSync } from 'node:fs'
|
|
66
72
|
|
|
67
73
|
const buffer = readFileSync('ER0000.sl2').buffer
|
|
74
|
+
|
|
75
|
+
// Default: only errors are logged (logLevel: 'error')
|
|
68
76
|
const save = parse(buffer)
|
|
69
77
|
|
|
78
|
+
// Optional: configure logging with one of 'debug', 'info', 'warn', 'error', 'none'
|
|
79
|
+
// const save = parse(buffer, { logLevel: 'debug' }) // Verbose progress logs
|
|
80
|
+
// const save = parse(buffer, { logLevel: 'none' }) // Silent
|
|
81
|
+
|
|
70
82
|
console.log(save.steamId)
|
|
71
83
|
console.log(save.settings?.hud)
|
|
72
84
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
3
|
+
interface ParseOptions {
|
|
4
|
+
logLevel?: LogLevel;
|
|
5
|
+
includeEventFlagUInt8Array?: boolean;
|
|
6
|
+
}
|
|
2
7
|
interface Save {
|
|
3
8
|
magicBytes?: string;
|
|
4
9
|
checksum?: string;
|
|
@@ -75,6 +80,7 @@ interface Slot {
|
|
|
75
80
|
notAloneFlag?: number;
|
|
76
81
|
inGameCountdownTimer?: number;
|
|
77
82
|
eventFlags?: EventFlag[];
|
|
83
|
+
eventFlagUint8Array?: Uint8Array;
|
|
78
84
|
}
|
|
79
85
|
interface Character {
|
|
80
86
|
unk0x0?: number;
|
|
@@ -139,6 +145,78 @@ interface EventFlag {
|
|
|
139
145
|
}
|
|
140
146
|
//#endregion
|
|
141
147
|
//#region src/parser.d.ts
|
|
142
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Parse an Elden Ring save file buffer.
|
|
150
|
+
*
|
|
151
|
+
* @param buffer - The ArrayBuffer containing the save file data
|
|
152
|
+
* @param options - Optional configuration for parsing
|
|
153
|
+
* @param options.logLevel - Log level threshold: 'debug', 'info', 'warn', 'error', or 'none'. Defaults to 'error'
|
|
154
|
+
* @param options.includeEventFlagUInt8Array - Includes the raw event flag array data
|
|
155
|
+
* @returns A Save object containing parsed slot and profile data
|
|
156
|
+
*/
|
|
157
|
+
declare function parse(buffer: ArrayBuffer, options?: ParseOptions): Save;
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/util.d.ts
|
|
160
|
+
/**
|
|
161
|
+
* Compare two ArrayBuffers for byte-by-byte equality.
|
|
162
|
+
*
|
|
163
|
+
* @param buf1 - The first ArrayBuffer to compare
|
|
164
|
+
* @param buf2 - The second ArrayBuffer to compare
|
|
165
|
+
* @returns True if both buffers have identical byte content
|
|
166
|
+
*/
|
|
167
|
+
declare function arrayBuffersEqual(buf1: ArrayBuffer, buf2: ArrayBuffer): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Convert a string into an array of byte values.
|
|
170
|
+
*
|
|
171
|
+
* @param string - The string to convert
|
|
172
|
+
* @returns An array of ASCII/Unicode byte values for each character
|
|
173
|
+
*/
|
|
174
|
+
declare function stringToBytes(string: string): number[];
|
|
175
|
+
/**
|
|
176
|
+
* Convert an ArrayBuffer to a lowercase hexadecimal string.
|
|
177
|
+
*
|
|
178
|
+
* @param buffer - The ArrayBuffer to convert
|
|
179
|
+
* @returns A lowercase hexadecimal string representation of the buffer
|
|
180
|
+
*/
|
|
181
|
+
declare function toHexString(buffer: ArrayBuffer): string;
|
|
182
|
+
/**
|
|
183
|
+
* Remove all null ('\x00') characters from a string.
|
|
184
|
+
*
|
|
185
|
+
* @param text - The string to clean
|
|
186
|
+
* @returns The input string with all null ('\x00') characters removed
|
|
187
|
+
*/
|
|
188
|
+
declare const trim: (text: string) => string;
|
|
189
|
+
/**
|
|
190
|
+
* Parse a string of delimiter-separated "key,value" pairs into a Map.
|
|
191
|
+
*
|
|
192
|
+
* @param text - A string of delimiter-separated pairs, one per line
|
|
193
|
+
* @param delimiter - The character separating key and value (default: ",")
|
|
194
|
+
* @returns A Map with numeric keys and values parsed from the input
|
|
195
|
+
*/
|
|
196
|
+
declare const parseToMap: (text: string, delimiter?: string) => Map<number, number>;
|
|
197
|
+
/**
|
|
198
|
+
* Returns tha Bst Map as a Map
|
|
199
|
+
*
|
|
200
|
+
* @returns Bst Map as Map
|
|
201
|
+
*/
|
|
202
|
+
declare const getBstMap: () => Map<number, number>;
|
|
203
|
+
/**
|
|
204
|
+
* Determine whether a specific event flag is set.
|
|
205
|
+
*
|
|
206
|
+
* @param bstMap - A map of block IDs to their binary offsets
|
|
207
|
+
* @param eventFlags - The raw event_flags byte array from the save data
|
|
208
|
+
* @param eventId - The event ID to check
|
|
209
|
+
* @returns True if the event flag is set (active), false otherwise
|
|
210
|
+
*/
|
|
211
|
+
declare const getEventFlagState: (bstMap: Map<number, number>, eventFlags: Uint8Array, eventId: number) => boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Determine the event ID from a byte position and bit index.
|
|
214
|
+
*
|
|
215
|
+
* @param bstMap - A map of block IDs to their binary offsets
|
|
216
|
+
* @param bytePos - The byte position in the event_flags array
|
|
217
|
+
* @param bitIndex - The bit index within the byte (0-7)
|
|
218
|
+
* @returns The event ID corresponding to the given position
|
|
219
|
+
*/
|
|
220
|
+
declare const getEventIdFromPosition: (bstMap: Map<number, number>, bytePos: number, bitIndex: number) => number;
|
|
143
221
|
//#endregion
|
|
144
|
-
export { type Character, type EventFlag, type ProfileSummary, type Save, type Settings, type Slot, parse };
|
|
222
|
+
export { type Character, type EventFlag, type LogLevel, type ParseOptions, type ProfileSummary, type Save, type Settings, type Slot, arrayBuffersEqual, getBstMap, getEventFlagState, getEventIdFromPosition, parse, parseToMap, stringToBytes, toHexString, trim };
|