isaacscript-common 1.2.243 → 1.2.246
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/features/saveDataManager/merge.lua +8 -7
- package/dist/functions/debug.lua +4 -2
- package/dist/functions/deepCopy.lua +8 -5
- package/dist/functions/isaacAPIClass.d.ts +0 -2
- package/dist/functions/isaacAPIClass.lua +0 -17
- package/dist/functions/jsonHelpers.d.ts +1 -1
- package/dist/functions/mergeTests.lua +65 -2
- package/dist/functions/serialization.d.ts +8 -1
- package/dist/functions/serialization.lua +64 -12
- package/dist/objects/isaacAPIClassTypeToBrand.d.ts +5 -0
- package/dist/objects/isaacAPIClassTypeToBrand.lua +8 -0
- package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts +5 -0
- package/dist/objects/isaacAPIClassTypeToCopyFunction.lua +14 -0
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts +4 -0
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.lua +14 -0
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@ local deepCopy = ____deepCopy.deepCopy
|
|
|
16
16
|
local ____log = require("functions.log")
|
|
17
17
|
local log = ____log.log
|
|
18
18
|
local ____serialization = require("functions.serialization")
|
|
19
|
-
local
|
|
19
|
+
local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
|
|
20
20
|
local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
|
|
21
21
|
local ____table = require("functions.table")
|
|
22
22
|
local clearTable = ____table.clearTable
|
|
@@ -26,7 +26,7 @@ local ____constants = require("features.saveDataManager.constants")
|
|
|
26
26
|
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
27
27
|
function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
28
28
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
29
|
-
log("merge is
|
|
29
|
+
log("merge is traversing: " .. traversalDescription)
|
|
30
30
|
end
|
|
31
31
|
local oldObjectType = type(oldObject)
|
|
32
32
|
if oldObjectType ~= "table" then
|
|
@@ -95,13 +95,17 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
95
95
|
for key, value in pairs(newTable) do
|
|
96
96
|
do
|
|
97
97
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
98
|
-
|
|
98
|
+
local valueToPrint = value == "" and "(empty string)" or tostring(value)
|
|
99
|
+
log((("merge is merging: " .. traversalDescription) .. " --> ") .. valueToPrint)
|
|
99
100
|
end
|
|
100
101
|
if isSerializationBrand(nil, key) then
|
|
101
102
|
goto __continue23
|
|
102
103
|
end
|
|
103
104
|
if isSerializedIsaacAPIClass(nil, value) then
|
|
104
|
-
|
|
105
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
106
|
+
log("merge found a serialized Isaac API class.")
|
|
107
|
+
end
|
|
108
|
+
local deserializedObject = deserializeIsaacAPIClass(nil, value)
|
|
105
109
|
oldTable[key] = deserializedObject
|
|
106
110
|
goto __continue23
|
|
107
111
|
end
|
|
@@ -116,9 +120,6 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
116
120
|
traversalDescription = getTraversalDescription(nil, key, traversalDescription)
|
|
117
121
|
____exports.merge(nil, oldValue, value, traversalDescription)
|
|
118
122
|
else
|
|
119
|
-
if SAVE_DATA_MANAGER_DEBUG then
|
|
120
|
-
log((("Merging key \"" .. tostring(key)) .. "\" with value: ") .. tostring(value))
|
|
121
|
-
end
|
|
122
123
|
oldTable[key] = value
|
|
123
124
|
end
|
|
124
125
|
end
|
package/dist/functions/debug.lua
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
+
local ____log = require("functions.log")
|
|
4
|
+
local log = ____log.log
|
|
3
5
|
function ____exports.getTraceback(self)
|
|
4
6
|
if debug ~= nil then
|
|
5
7
|
return debug.traceback()
|
|
@@ -11,10 +13,10 @@ function ____exports.getTraceback(self)
|
|
|
11
13
|
end
|
|
12
14
|
function ____exports.traceback(self)
|
|
13
15
|
local tracebackOutput = ____exports.getTraceback(nil)
|
|
14
|
-
|
|
16
|
+
log(tracebackOutput)
|
|
15
17
|
end
|
|
16
18
|
local function setDebugFunctionsGlobal(self)
|
|
17
|
-
if debug == nil then
|
|
19
|
+
if debug == nil and sandboxGetTraceback == nil then
|
|
18
20
|
return
|
|
19
21
|
end
|
|
20
22
|
local globals = _G
|
|
@@ -15,12 +15,12 @@ local ____SerializationType = require("enums.SerializationType")
|
|
|
15
15
|
local SerializationType = ____SerializationType.SerializationType
|
|
16
16
|
local ____constants = require("features.saveDataManager.constants")
|
|
17
17
|
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
18
|
-
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
19
|
-
local isSerializableIsaacAPIClass = ____isaacAPIClass.isSerializableIsaacAPIClass
|
|
20
18
|
local ____log = require("functions.log")
|
|
21
19
|
local log = ____log.log
|
|
22
20
|
local ____serialization = require("functions.serialization")
|
|
23
|
-
local
|
|
21
|
+
local copyIsaacAPIClass = ____serialization.copyIsaacAPIClass
|
|
22
|
+
local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
|
|
23
|
+
local isSerializableIsaacAPIClass = ____serialization.isSerializableIsaacAPIClass
|
|
24
24
|
local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
|
|
25
25
|
local ____utils = require("functions.utils")
|
|
26
26
|
local getTraversalDescription = ____utils.getTraversalDescription
|
|
@@ -236,8 +236,11 @@ function validateValue(self, value, valueType, traversalDescription)
|
|
|
236
236
|
end
|
|
237
237
|
end
|
|
238
238
|
function getNewValue(self, key, value, traversalDescription, serializationType)
|
|
239
|
-
if isSerializableIsaacAPIClass(nil, value)
|
|
240
|
-
return
|
|
239
|
+
if isSerializableIsaacAPIClass(nil, value) then
|
|
240
|
+
return copyIsaacAPIClass(nil, value, serializationType)
|
|
241
|
+
end
|
|
242
|
+
if isSerializedIsaacAPIClass(nil, value) and serializationType == SerializationType.DESERIALIZE then
|
|
243
|
+
return deserializeIsaacAPIClass(nil, value)
|
|
241
244
|
end
|
|
242
245
|
if type(value) == "table" then
|
|
243
246
|
local ____table = value
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IsaacAPIClass } from "../types/private/IsaacAPIClass";
|
|
2
|
-
import { SerializableIsaacAPIClass } from "../types/private/SerializableIsaacAPIClass";
|
|
3
2
|
/**
|
|
4
3
|
* Helper function to get the type of a class from the Isaac API. This is contained within the
|
|
5
4
|
* "__type" metatable key. In this context, the type of the class is equivalent to the name.
|
|
@@ -17,7 +16,6 @@ export declare function getIsaacAPIClassType(object: unknown): string | undefine
|
|
|
17
16
|
*/
|
|
18
17
|
export declare function isIsaacAPIClass(object: unknown): object is IsaacAPIClass;
|
|
19
18
|
export declare function isIsaacAPIClassOfType(object: unknown, classType: string): boolean;
|
|
20
|
-
export declare function isSerializableIsaacAPIClass(object: unknown): object is SerializableIsaacAPIClass;
|
|
21
19
|
/**
|
|
22
20
|
* Helper function to check if an instantiated Isaac API class is equal to another one of the same
|
|
23
21
|
* type. You must provide the list of keys to check for.
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Set = ____lualib.Set
|
|
3
|
-
local __TS__New = ____lualib.__TS__New
|
|
4
2
|
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
5
3
|
local ____exports = {}
|
|
6
|
-
local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
|
|
7
|
-
local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
|
|
8
|
-
local ____utils = require("functions.utils")
|
|
9
|
-
local getEnumValues = ____utils.getEnumValues
|
|
10
|
-
local SERIALIZABLE_ISAAC_API_CLASS_TYPES_SET = __TS__New(
|
|
11
|
-
Set,
|
|
12
|
-
getEnumValues(nil, SerializableIsaacAPIClassType)
|
|
13
|
-
)
|
|
14
4
|
function ____exports.getIsaacAPIClassType(self, object)
|
|
15
5
|
local objectType = type(object)
|
|
16
6
|
if objectType ~= "userdata" then
|
|
@@ -34,13 +24,6 @@ function ____exports.isIsaacAPIClassOfType(self, object, classType)
|
|
|
34
24
|
local isaacAPIClassType = ____exports.getIsaacAPIClassType(nil, object)
|
|
35
25
|
return isaacAPIClassType == classType or isaacAPIClassType == "const " .. classType
|
|
36
26
|
end
|
|
37
|
-
function ____exports.isSerializableIsaacAPIClass(self, object)
|
|
38
|
-
local classType = ____exports.getIsaacAPIClassType(nil, object)
|
|
39
|
-
if classType == nil then
|
|
40
|
-
return false
|
|
41
|
-
end
|
|
42
|
-
return SERIALIZABLE_ISAAC_API_CLASS_TYPES_SET:has(classType)
|
|
43
|
-
end
|
|
44
27
|
function ____exports.isaacAPIClassEquals(self, object1, object2, keys)
|
|
45
28
|
local table1 = object1
|
|
46
29
|
local table2 = object2
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* (This allows execution to continue in cases where users have no current save data or have
|
|
7
7
|
* manually removed their existing save data.)
|
|
8
8
|
*/
|
|
9
|
-
export declare function jsonDecode(jsonString: string): LuaTable
|
|
9
|
+
export declare function jsonDecode(jsonString: string): LuaTable<AnyNotNil, unknown>;
|
|
10
10
|
/**
|
|
11
11
|
* Converts a Lua table to a JSON string.
|
|
12
12
|
* In most cases, this function will be used for writing data to a "save#.dat" file.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
-
local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasFilledInterface, oldTableHasVector, oldTableHasVectorSerialized
|
|
3
|
+
local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasSerializedIsaacAPIClass, oldTableHasFilledInterface, oldTableHasVector, oldTableHasVectorSerialized, oldTableHasRNG, oldTableHasRNGSerialized
|
|
4
4
|
local ____SerializationType = require("enums.SerializationType")
|
|
5
5
|
local SerializationType = ____SerializationType.SerializationType
|
|
6
6
|
local ____merge = require("features.saveDataManager.merge")
|
|
@@ -9,7 +9,13 @@ local ____deepCopy = require("functions.deepCopy")
|
|
|
9
9
|
local deepCopy = ____deepCopy.deepCopy
|
|
10
10
|
local ____log = require("functions.log")
|
|
11
11
|
local log = ____log.log
|
|
12
|
+
local ____rng = require("functions.rng")
|
|
13
|
+
local isRNG = ____rng.isRNG
|
|
14
|
+
local newRNG = ____rng.newRNG
|
|
15
|
+
local ____serialization = require("functions.serialization")
|
|
16
|
+
local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
|
|
12
17
|
local ____vector = require("functions.vector")
|
|
18
|
+
local copyVector = ____vector.copyVector
|
|
13
19
|
local isVector = ____vector.isVector
|
|
14
20
|
function oldTableHasUpdatedValue(self)
|
|
15
21
|
local key = "foo"
|
|
@@ -46,6 +52,15 @@ function oldTableHasUpdatedValueFromNull(self)
|
|
|
46
52
|
error("The old table does not have a value of: " .. newValue)
|
|
47
53
|
end
|
|
48
54
|
end
|
|
55
|
+
function oldTableHasSerializedIsaacAPIClass(self)
|
|
56
|
+
local x = 50
|
|
57
|
+
local y = 60
|
|
58
|
+
local vector = Vector(x, y)
|
|
59
|
+
local vectorSerialized = copyVector(nil, vector, SerializationType.SERIALIZE)
|
|
60
|
+
if not isSerializedIsaacAPIClass(nil, vectorSerialized) then
|
|
61
|
+
error("The \"isSerializedIsaacAPIClass\" function says that a serialized vector is not serialized.")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
49
64
|
function oldTableHasFilledInterface(self)
|
|
50
65
|
local key = "foo"
|
|
51
66
|
local newValue = "baz"
|
|
@@ -62,6 +77,7 @@ function oldTableHasFilledInterface(self)
|
|
|
62
77
|
end
|
|
63
78
|
end
|
|
64
79
|
function oldTableHasVector(self)
|
|
80
|
+
log("Starting test: oldTableHasVector")
|
|
65
81
|
local key = "foo"
|
|
66
82
|
local x = 50
|
|
67
83
|
local y = 60
|
|
@@ -85,6 +101,7 @@ function oldTableHasVector(self)
|
|
|
85
101
|
end
|
|
86
102
|
end
|
|
87
103
|
function oldTableHasVectorSerialized(self)
|
|
104
|
+
log("Starting test: oldTableHasVectorSerialized")
|
|
88
105
|
local key = "foo"
|
|
89
106
|
local x = 50
|
|
90
107
|
local y = 60
|
|
@@ -105,16 +122,62 @@ function oldTableHasVectorSerialized(self)
|
|
|
105
122
|
error("The old table's value for \"y\" does not match: " .. tostring(y))
|
|
106
123
|
end
|
|
107
124
|
if not isVector(nil, oldTableValue.bar) then
|
|
108
|
-
error("The old table's value is not a Vector object.")
|
|
125
|
+
error("The old table's value is not a Vector object (during the serialized test).")
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
function oldTableHasRNG(self)
|
|
129
|
+
log("Starting test: oldTableHasRNG")
|
|
130
|
+
local key = "foo"
|
|
131
|
+
local seed = 50
|
|
132
|
+
local newValue = newRNG(nil, seed)
|
|
133
|
+
local oldTable = {foo = nil}
|
|
134
|
+
local foo = {bar = newValue}
|
|
135
|
+
local newTable = {foo = foo}
|
|
136
|
+
merge(nil, oldTable, newTable, "oldTableHasRNG")
|
|
137
|
+
local oldTableValue = oldTable[key]
|
|
138
|
+
if oldTableValue == nil then
|
|
139
|
+
error(("The old table's key of \"" .. key) .. "\" was not filled.")
|
|
140
|
+
end
|
|
141
|
+
if not isRNG(nil, oldTableValue.bar) then
|
|
142
|
+
error("The old table's value is not an RNG object.")
|
|
143
|
+
end
|
|
144
|
+
local newSeed = oldTableValue.bar:GetSeed()
|
|
145
|
+
if newSeed ~= seed then
|
|
146
|
+
error("The old table's seed not match: " .. tostring(seed))
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
function oldTableHasRNGSerialized(self)
|
|
150
|
+
log("Starting test: oldTableHasRNGSerialized")
|
|
151
|
+
local key = "foo"
|
|
152
|
+
local seed = 50
|
|
153
|
+
local newValue = newRNG(nil, seed)
|
|
154
|
+
local oldTable = {foo = nil}
|
|
155
|
+
local foo = {bar = newValue}
|
|
156
|
+
local newTable = {foo = foo}
|
|
157
|
+
local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE)
|
|
158
|
+
merge(nil, oldTable, newTableSerialized, "oldTableHasRNGSerialized")
|
|
159
|
+
local oldTableValue = oldTable[key]
|
|
160
|
+
if oldTableValue == nil then
|
|
161
|
+
error(("The old table's key of \"" .. key) .. "\" was not filled.")
|
|
162
|
+
end
|
|
163
|
+
if not isRNG(nil, oldTableValue.bar) then
|
|
164
|
+
error("The old table's value is not an RNG object (during the serialized test).")
|
|
165
|
+
end
|
|
166
|
+
local newSeed = oldTableValue.bar:GetSeed()
|
|
167
|
+
if newSeed ~= seed then
|
|
168
|
+
error("The old table's seed not match: " .. tostring(seed))
|
|
109
169
|
end
|
|
110
170
|
end
|
|
111
171
|
function ____exports.mergeTests(self)
|
|
112
172
|
oldTableHasUpdatedValue(nil)
|
|
113
173
|
newTableHasSameValue(nil)
|
|
114
174
|
oldTableHasUpdatedValueFromNull(nil)
|
|
175
|
+
oldTableHasSerializedIsaacAPIClass(nil)
|
|
115
176
|
oldTableHasFilledInterface(nil)
|
|
116
177
|
oldTableHasVector(nil)
|
|
117
178
|
oldTableHasVectorSerialized(nil)
|
|
179
|
+
oldTableHasRNG(nil)
|
|
180
|
+
oldTableHasRNGSerialized(nil)
|
|
118
181
|
log("All merge tests passed!")
|
|
119
182
|
end
|
|
120
183
|
return ____exports
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { SerializationType } from "../enums/SerializationType";
|
|
2
2
|
import { SerializableIsaacAPIClass } from "../types/private/SerializableIsaacAPIClass";
|
|
3
3
|
import { SerializedIsaacAPIClass } from "../types/private/SerializedIsaacAPIClass";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function copyIsaacAPIClass(isaacAPIClass: SerializableIsaacAPIClass, serializationType: SerializationType): unknown;
|
|
5
|
+
/**
|
|
6
|
+
* Deserialization is a special case, so we make a dedicated function for this. There is no need for
|
|
7
|
+
* a "serializeIsaacAPIClass" function because the "copyIsaacAPIClass" function can handles all
|
|
8
|
+
* serialization types.
|
|
9
|
+
*/
|
|
10
|
+
export declare function deserializeIsaacAPIClass(serializedIsaacAPIClass: SerializedIsaacAPIClass): unknown;
|
|
11
|
+
export declare function isSerializableIsaacAPIClass(object: unknown): object is SerializableIsaacAPIClass;
|
|
5
12
|
export declare function isSerializedIsaacAPIClass(object: unknown): object is SerializedIsaacAPIClass;
|
|
@@ -1,27 +1,79 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Set = ____lualib.Set
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
2
5
|
local __TS__ObjectValues = ____lualib.__TS__ObjectValues
|
|
3
6
|
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
4
7
|
local ____exports = {}
|
|
5
|
-
local
|
|
6
|
-
local
|
|
7
|
-
local
|
|
8
|
-
local
|
|
8
|
+
local getSerializedTableType
|
|
9
|
+
local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
|
|
10
|
+
local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
|
|
11
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
12
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
13
|
+
local ____isaacAPIClassTypeToBrand = require("objects.isaacAPIClassTypeToBrand")
|
|
14
|
+
local ISAAC_API_CLASS_TYPE_TO_BRAND = ____isaacAPIClassTypeToBrand.ISAAC_API_CLASS_TYPE_TO_BRAND
|
|
15
|
+
local ____isaacAPIClassTypeToCopyFunction = require("objects.isaacAPIClassTypeToCopyFunction")
|
|
16
|
+
local ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = ____isaacAPIClassTypeToCopyFunction.ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION
|
|
17
|
+
local ____serializedIsaacAPIClassTypeToIdentityFunction = require("objects.serializedIsaacAPIClassTypeToIdentityFunction")
|
|
18
|
+
local SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = ____serializedIsaacAPIClassTypeToIdentityFunction.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION
|
|
9
19
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
10
20
|
local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
local ____utils = require("functions.utils")
|
|
22
|
+
local getEnumValues = ____utils.getEnumValues
|
|
23
|
+
function getSerializedTableType(self, serializedIsaacAPIClass)
|
|
24
|
+
for ____, ____value in ipairs(__TS__ObjectEntries(ISAAC_API_CLASS_TYPE_TO_BRAND)) do
|
|
25
|
+
local serializableIsaacAPIClassType = ____value[1]
|
|
26
|
+
local serializationBrand = ____value[2]
|
|
27
|
+
if serializedIsaacAPIClass[serializationBrand] ~= nil then
|
|
28
|
+
return serializableIsaacAPIClassType
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
return nil
|
|
32
|
+
end
|
|
33
|
+
local SERIALIZABLE_ISAAC_API_CLASS_TYPES_SET = __TS__New(
|
|
34
|
+
Set,
|
|
35
|
+
getEnumValues(nil, SerializableIsaacAPIClassType)
|
|
36
|
+
)
|
|
37
|
+
function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
|
|
38
|
+
local objectType = type(isaacAPIClass)
|
|
39
|
+
if objectType ~= "userdata" then
|
|
40
|
+
error("Failed to serialize an Isaac API class since the provided object was of type: " .. objectType)
|
|
41
|
+
end
|
|
42
|
+
local isaacAPIClassType = getIsaacAPIClassType(nil, isaacAPIClass)
|
|
43
|
+
if isaacAPIClassType == nil then
|
|
44
|
+
error("Failed to serialize an Isaac API class due to it not having a class type.")
|
|
45
|
+
end
|
|
46
|
+
local serializableIsaacAPIClassType = isaacAPIClassType
|
|
47
|
+
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[serializableIsaacAPIClassType]
|
|
14
48
|
if copyFunction == nil then
|
|
15
|
-
error(("Failed to copy Isaac API class \"" ..
|
|
49
|
+
error(("Failed to copy Isaac API class \"" .. serializableIsaacAPIClassType) .. "\" since there is not a defined copy function for this class type.")
|
|
16
50
|
end
|
|
17
|
-
return copyFunction(nil,
|
|
51
|
+
return copyFunction(nil, isaacAPIClass, serializationType)
|
|
18
52
|
end
|
|
19
|
-
function ____exports.
|
|
20
|
-
local objectType = type(
|
|
53
|
+
function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
|
|
54
|
+
local objectType = type(serializedIsaacAPIClass)
|
|
21
55
|
if objectType ~= "table" then
|
|
56
|
+
error("Failed to deserialize an Isaac API class since the provided object was of type: " .. objectType)
|
|
57
|
+
end
|
|
58
|
+
local serializableIsaacAPIClassType = getSerializedTableType(nil, serializedIsaacAPIClass)
|
|
59
|
+
if serializableIsaacAPIClassType == nil then
|
|
60
|
+
error("Failed to deserialize an API class since a valid class type brand was not found.")
|
|
61
|
+
end
|
|
62
|
+
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[serializableIsaacAPIClassType]
|
|
63
|
+
if copyFunction == nil then
|
|
64
|
+
error(("Failed to deserialize Isaac API class \"" .. serializableIsaacAPIClassType) .. "\" since there is not a defined copy function for this class type.")
|
|
65
|
+
end
|
|
66
|
+
return copyFunction(nil, serializedIsaacAPIClass, SerializationType.DESERIALIZE)
|
|
67
|
+
end
|
|
68
|
+
function ____exports.isSerializableIsaacAPIClass(self, object)
|
|
69
|
+
local classType = getIsaacAPIClassType(nil, object)
|
|
70
|
+
if classType == nil then
|
|
22
71
|
return false
|
|
23
72
|
end
|
|
24
|
-
|
|
73
|
+
return SERIALIZABLE_ISAAC_API_CLASS_TYPES_SET:has(classType)
|
|
74
|
+
end
|
|
75
|
+
function ____exports.isSerializedIsaacAPIClass(self, object)
|
|
76
|
+
local identityFunctions = __TS__ObjectValues(SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION)
|
|
25
77
|
return __TS__ArraySome(
|
|
26
78
|
identityFunctions,
|
|
27
79
|
function(____, identityFunction) return identityFunction(nil, object) end
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SerializableIsaacAPIClassType } from "../enums/private/SerializableIsaacAPIClassType";
|
|
2
|
+
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
3
|
+
export declare const ISAAC_API_CLASS_TYPE_TO_BRAND: {
|
|
4
|
+
readonly [key in SerializableIsaacAPIClassType]: SerializationBrand;
|
|
5
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
|
|
4
|
+
local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
|
|
5
|
+
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
6
|
+
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
7
|
+
____exports.ISAAC_API_CLASS_TYPE_TO_BRAND = {[SerializableIsaacAPIClassType.COLOR] = SerializationBrand.COLOR, [SerializableIsaacAPIClassType.KCOLOR] = SerializationBrand.KCOLOR, [SerializableIsaacAPIClassType.RNG] = SerializationBrand.RNG, [SerializableIsaacAPIClassType.VECTOR] = SerializationBrand.VECTOR}
|
|
8
|
+
return ____exports
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SerializableIsaacAPIClassType } from "../enums/private/SerializableIsaacAPIClassType";
|
|
2
|
+
import { SerializationType } from "../enums/SerializationType";
|
|
3
|
+
export declare const ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION: {
|
|
4
|
+
readonly [key in SerializableIsaacAPIClassType]: (object: unknown, serializationType: SerializationType) => boolean;
|
|
5
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
|
|
4
|
+
local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
|
|
5
|
+
local ____color = require("functions.color")
|
|
6
|
+
local copyColor = ____color.copyColor
|
|
7
|
+
local ____kColor = require("functions.kColor")
|
|
8
|
+
local copyKColor = ____kColor.copyKColor
|
|
9
|
+
local ____rng = require("functions.rng")
|
|
10
|
+
local copyRNG = ____rng.copyRNG
|
|
11
|
+
local ____vector = require("functions.vector")
|
|
12
|
+
local copyVector = ____vector.copyVector
|
|
13
|
+
____exports.ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = {[SerializableIsaacAPIClassType.COLOR] = copyColor, [SerializableIsaacAPIClassType.KCOLOR] = copyKColor, [SerializableIsaacAPIClassType.RNG] = copyRNG, [SerializableIsaacAPIClassType.VECTOR] = copyVector}
|
|
14
|
+
return ____exports
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
|
|
4
|
+
local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
|
|
5
|
+
local ____color = require("functions.color")
|
|
6
|
+
local isSerializedColor = ____color.isSerializedColor
|
|
7
|
+
local ____kColor = require("functions.kColor")
|
|
8
|
+
local isSerializedKColor = ____kColor.isSerializedKColor
|
|
9
|
+
local ____rng = require("functions.rng")
|
|
10
|
+
local isSerializedRNG = ____rng.isSerializedRNG
|
|
11
|
+
local ____vector = require("functions.vector")
|
|
12
|
+
local isSerializedVector = ____vector.isSerializedVector
|
|
13
|
+
____exports.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = {[SerializableIsaacAPIClassType.COLOR] = isSerializedColor, [SerializableIsaacAPIClassType.KCOLOR] = isSerializedKColor, [SerializableIsaacAPIClassType.RNG] = isSerializedRNG, [SerializableIsaacAPIClassType.VECTOR] = isSerializedVector}
|
|
14
|
+
return ____exports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.246",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"isaac-typescript-definitions": "^1.0.388",
|
|
29
|
-
"isaacscript-lint": "^1.0.
|
|
29
|
+
"isaacscript-lint": "^1.0.98",
|
|
30
30
|
"isaacscript-tsconfig": "^1.1.8",
|
|
31
31
|
"typedoc": "^0.22.13",
|
|
32
32
|
"typescript": "4.6.3",
|