import type { CopyableIsaacAPIClass } from "../objects/isaacAPIClassTypeToFunctions"; /** * This is the format of the object that you give to the save data manager. It will contains all of * the variables for the particular mod feature. * * Depending on which object keys you use, the variables will automatically be reset at certain * times and automatically saved to disk. * * Each sub-object of save data has a string as a key and arbitrary data as a value. However, the * data has to be serializable. Specifically, this means that you can only use the following types: * * - `boolean` * - `number` * - `string` * - `undefined` (will be skipped over when saving) * - `null` (will be skipped over when saving) * - `Map` / `DefaultMap` * - `Set` * - serializable Isaac API classes (such as `Color`) * - TSTL classes (i.e. classes that you made yourself) * - sub-objects or a `LuaMap` that contains the above values */ export interface SaveData { persistent?: Serializable; run?: Serializable; level?: Serializable; room?: Record; } /** * A type that represents valid serializable data fed to the save data manager. * * Custom errors are thrown when an Isaac API class or a nested custom class is detected. * * The recursive nature of this type is based on the `Immutable` type: * https://stackoverflow.com/questions/41879327/deepreadonly-object-typescript */ type Serializable = T extends SerializablePrimitive ? T : T extends CopyableIsaacAPIClass ? T : T extends IsaacAPIClass ? ErrorIsaacAPIClassIsNotSerializable : T extends Array ? SerializableArray : T extends ReadonlyArray ? SerializableReadonlyArray : T extends Map ? SerializableMap : T extends ReadonlyMap ? SerializableReadonlyMap : T extends Set ? SerializableSet : T extends ReadonlySet ? SerializableReadonlySet : SerializableObject; /** * This is mostly copied from the `Serializable` type. The difference is that we want to disallow * functions inside of containers. */ type SerializableInsideArrayOrMap = T extends SerializablePrimitive ? T : T extends CopyableIsaacAPIClass ? T : T extends IsaacAPIClass ? ErrorIsaacAPIClassIsNotSerializable : T extends Array ? SerializableArray : T extends ReadonlyArray ? SerializableReadonlyArray : T extends Map ? SerializableMap : T extends ReadonlyMap ? SerializableReadonlyMap : T extends Set ? SerializableSet : T extends ReadonlySet ? SerializableReadonlySet : T extends Function ? FunctionIsNotSerializable : SerializableObject; type SerializablePrimitive = boolean | string | number | undefined | null; type SerializableArray = Array>; type SerializableReadonlyArray = ReadonlyArray>; type SerializableMap = Map, SerializableInsideArrayOrMap>; type SerializableReadonlyMap = ReadonlyMap, SerializableInsideArrayOrMap>; type SerializableSet = Set>; type SerializableReadonlySet = ReadonlySet>; type SerializableObject = { [K in keyof T]: Serializable; }; type FunctionIsNotSerializable = "Error: Functions are not serializable. For more information, see: https://isaacscript.github.io/main/gotchas#functions-are-not-serializable"; type ErrorIsaacAPIClassIsNotSerializable = "Error: Isaac API classes (such as e.g. `Entity` or `RoomConfig`) are not serializable. For more information, see: https://isaacscript.github.io/main/gotchas#isaac-api-classes-are-not-serializable"; export {}; //# sourceMappingURL=SaveData.d.ts.map