VersionedSaveEngine

Versioned Save Engine providing sequential migrations, step verification, atomic rollback on failure, future version detection, reference validation, and corrupt JSON diagnostics/recovery.

Constructor

new VersionedSaveEngine(optionsopt)

Parameters:
NameTypeAttributesDescription
optionsObject<optional>

Classes

VersionedSaveEngine

Methods

diagnoseCorruptJson(rawText, syntaxErroropt) → {Object}

Diagnose a corrupt JSON string and produce line, column, snippet, and reason.

Parameters:
NameTypeAttributesDescription
rawTextstring
syntaxErrorError<optional>
Returns:
Type: 
Object

has(slot) → {boolean}

Check if a save slot exists in storage.

Parameters:
NameTypeDescription
slotstring
Returns:
Type: 
boolean

key(slot) → {string}

Build storage key for a save slot.

Parameters:
NameTypeDescription
slotstring
Returns:
Type: 
string

load(slotOrRaw, optionsopt) → {Object|null}

Load, migrate, and validate save data from a slot or raw JSON text.

Parameters:
NameTypeAttributesDescription
slotOrRawstring | Object
optionsObject<optional>
Returns:
Type: 
Object | null

migrate(record, targetVersionopt) → {Object}

Migrate a save record through sequential registered schema migrations. Enforces step verification and atomic abort on errors.

Parameters:
NameTypeAttributesDescription
recordObject
targetVersionnumber<optional>
Returns:
Type: 
Object

recoverCorruptJson(rawText, optionsopt) → {Object}

Attempt recovery of corrupt JSON through heuristics and fallback backups.

Parameters:
NameTypeAttributesDescription
rawTextstring
optionsObject<optional>
Returns:
Type: 
Object

registerMigration(fromVersion, toVersionOrFn, maybeFnopt, optionsopt) → {VersionedSaveEngine}

Register a schema migration.

Parameters:
NameTypeAttributesDescription
fromVersionnumber
toVersionOrFnnumber | function
maybeFnfunction<optional>
optionsObject<optional>
Returns:
Type: 
VersionedSaveEngine

remove(slot)

Remove a save slot and its backup from storage.

Parameters:
NameTypeDescription
slotstring

save(slot, data, optionsopt) → {Object}

Save data into a named storage slot with backup and reference validation.

Parameters:
NameTypeAttributesDescription
slotstring
dataObject
optionsObject<optional>
Returns:
Type: 
Object

slots() → {Array.<string>}

List all save slots currently present in storage.

Returns:
Type: 
Array.<string>

validate(data, optionsopt) → {Object}

Validate references on entities and components.

Parameters:
NameTypeAttributesDescription
dataObject
optionsObject<optional>
Returns:
Type: 
Object