isaacscript-common 1.2.249 → 1.2.250
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/enums/private/CopyableIsaacAPIClassType.d.ts +7 -0
- package/dist/enums/private/CopyableIsaacAPIClassType.lua +8 -0
- package/dist/enums/private/SerializationBrand.d.ts +19 -9
- package/dist/enums/private/SerializationBrand.lua +2 -2
- package/dist/features/saveDataManager/exports.lua +1 -2
- package/dist/features/saveDataManager/main.lua +2 -3
- package/dist/functions/deepCopy.d.ts +9 -6
- package/dist/functions/deepCopy.lua +269 -147
- package/dist/functions/log.d.ts +1 -1
- package/dist/functions/serialization.d.ts +5 -6
- package/dist/functions/serialization.lua +11 -28
- package/dist/functions/table.d.ts +1 -1
- package/dist/functions/tstlClass.d.ts +10 -5
- package/dist/functions/tstlClass.lua +11 -3
- package/dist/functions/utils.d.ts +1 -2
- package/dist/objects/isaacAPIClassTypeToBrand.d.ts +2 -2
- package/dist/objects/isaacAPIClassTypeToBrand.lua +3 -3
- package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts +2 -2
- package/dist/objects/isaacAPIClassTypeToCopyFunction.lua +3 -3
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts +2 -2
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.lua +3 -3
- package/dist/types/private/SaveData.d.ts +4 -0
- package/dist/types/private/TSTLClass.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
____exports.CopyableIsaacAPIClassType = CopyableIsaacAPIClassType or ({})
|
|
4
|
+
____exports.CopyableIsaacAPIClassType.COLOR = "Color"
|
|
5
|
+
____exports.CopyableIsaacAPIClassType.KCOLOR = "KColor"
|
|
6
|
+
____exports.CopyableIsaacAPIClassType.RNG = "RNG"
|
|
7
|
+
____exports.CopyableIsaacAPIClassType.VECTOR = "Vector"
|
|
8
|
+
return ____exports
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
1
|
/**
|
|
3
2
|
* During serialization, we write an arbitrary string key to the object with a value of an empty
|
|
4
3
|
* string. This is used during deserialization to instantiate the correct type of object.
|
|
@@ -8,6 +7,12 @@
|
|
|
8
7
|
*/
|
|
9
8
|
export declare enum SerializationBrand {
|
|
10
9
|
DEFAULT_MAP = "__TSTL_DEFAULT_MAP",
|
|
10
|
+
MAP = "__TSTL_MAP",
|
|
11
|
+
SET = "__TSTL_SET",
|
|
12
|
+
COLOR = "__COLOR",
|
|
13
|
+
KCOLOR = "__KCOLOR",
|
|
14
|
+
RNG = "__RNG",
|
|
15
|
+
VECTOR = "__VECTOR",
|
|
11
16
|
/**
|
|
12
17
|
* This is set to the value that represents the default value (instead of an empty string like the
|
|
13
18
|
* other brands are).
|
|
@@ -17,12 +22,17 @@ export declare enum SerializationBrand {
|
|
|
17
22
|
* object.
|
|
18
23
|
*/
|
|
19
24
|
DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The JSON library is unable to distinguish between a maps with number keys and an array. It will
|
|
27
|
+
* assume that both of these are an array. Thus, in the case of a map with number keys, it will
|
|
28
|
+
* insert null in every empty spot, leading to crashes.
|
|
29
|
+
*
|
|
30
|
+
* For example, a map with keys of 5 and 10 would be converted to the following array:
|
|
31
|
+
* `[null, null, null, null, "myValueForKey5", null, null, null, null, "myValueForKey10"]`
|
|
32
|
+
*
|
|
33
|
+
* The deep copier works around this by converting number keys to strings. It inserts this brand
|
|
34
|
+
* to keep track of the mutation.
|
|
35
|
+
*/
|
|
36
|
+
OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
27
37
|
}
|
|
28
|
-
export declare function isSerializationBrand(key:
|
|
38
|
+
export declare function isSerializationBrand(key: unknown): boolean;
|
|
@@ -6,14 +6,14 @@ local ____utils = require("functions.utils")
|
|
|
6
6
|
local getEnumValues = ____utils.getEnumValues
|
|
7
7
|
____exports.SerializationBrand = SerializationBrand or ({})
|
|
8
8
|
____exports.SerializationBrand.DEFAULT_MAP = "__TSTL_DEFAULT_MAP"
|
|
9
|
-
____exports.SerializationBrand.DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE"
|
|
10
9
|
____exports.SerializationBrand.MAP = "__TSTL_MAP"
|
|
11
10
|
____exports.SerializationBrand.SET = "__TSTL_SET"
|
|
12
|
-
____exports.SerializationBrand.OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
13
11
|
____exports.SerializationBrand.COLOR = "__COLOR"
|
|
14
12
|
____exports.SerializationBrand.KCOLOR = "__KCOLOR"
|
|
15
13
|
____exports.SerializationBrand.RNG = "__RNG"
|
|
16
14
|
____exports.SerializationBrand.VECTOR = "__VECTOR"
|
|
15
|
+
____exports.SerializationBrand.DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE"
|
|
16
|
+
____exports.SerializationBrand.OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
17
17
|
local SERIALIZATION_BRANDS = getEnumValues(nil, ____exports.SerializationBrand)
|
|
18
18
|
local SERIALIZATION_BRAND_SET = __TS__New(Set, SERIALIZATION_BRANDS)
|
|
19
19
|
function ____exports.isSerializationBrand(self, key)
|
|
@@ -32,8 +32,7 @@ function ____exports.saveDataManager(self, key, v, conditionalFunc)
|
|
|
32
32
|
conditionalFunc = function() return false end
|
|
33
33
|
end
|
|
34
34
|
local saveDataTable = v
|
|
35
|
-
local
|
|
36
|
-
local saveDataCopy = saveDataTableCopy
|
|
35
|
+
local saveDataCopy = deepCopy(nil, saveDataTable, SerializationType.NONE, key)
|
|
37
36
|
saveDataDefaultsMap[key] = saveDataCopy
|
|
38
37
|
if conditionalFunc ~= nil then
|
|
39
38
|
saveDataConditionalFuncMap:set(key, conditionalFunc)
|
|
@@ -80,9 +80,8 @@ function restoreDefaults(self, childTableName)
|
|
|
80
80
|
logError(((("Failed to find the default copy of the child table \"" .. childTableName) .. "\" for subscriber \"") .. subscriberName) .. "\". This error usually means that your save data is out of date. You can try purging all of your save data by deleting the following directory: C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\data")
|
|
81
81
|
goto __continue14
|
|
82
82
|
end
|
|
83
|
-
local
|
|
84
|
-
|
|
85
|
-
clearAndCopyAllElements(nil, childTable, childTableDefaultsTableCopy)
|
|
83
|
+
local childTableDefaultsCopy = deepCopy(nil, childTableDefaults, SerializationType.NONE, (subscriberName .. " --> ") .. childTableName)
|
|
84
|
+
clearAndCopyAllElements(nil, childTable, childTableDefaultsCopy)
|
|
86
85
|
end
|
|
87
86
|
::__continue14::
|
|
88
87
|
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
1
|
import { SerializationType } from "../enums/SerializationType";
|
|
3
2
|
/**
|
|
4
3
|
* deepCopy is a semi-generic deep cloner. It will recursively copy all of the values so that none
|
|
@@ -6,6 +5,7 @@ import { SerializationType } from "../enums/SerializationType";
|
|
|
6
5
|
*
|
|
7
6
|
* It supports the following object types:
|
|
8
7
|
*
|
|
8
|
+
* - Primitives (i.e. strings, numbers, and booleans)
|
|
9
9
|
* - `LuaTable` / basic TSTL objects
|
|
10
10
|
* - TSTL `Map`
|
|
11
11
|
* - TSTL `Set`
|
|
@@ -16,10 +16,13 @@ import { SerializationType } from "../enums/SerializationType";
|
|
|
16
16
|
* - Isaac `RNG` objects
|
|
17
17
|
* - Isaac `Vector` objects
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* It does not support:
|
|
20
|
+
* - objects with values of `null` (since that transpiles to `nil`)
|
|
21
|
+
* - other Isaac API objects (that have a type of "userdata")
|
|
22
|
+
*
|
|
23
|
+
* @param value The primitive or object to copy.
|
|
24
|
+
* @param serializationType Has 3 possible values. Can leave objects as-is, or can serialize objects
|
|
25
|
+
* to Lua tables, or can deserialize Lua tables to objects. Default is `SerializationType.NONE`.
|
|
23
26
|
* @param traversalDescription Used to track the current key that we are operating on.
|
|
24
27
|
*/
|
|
25
|
-
export declare function deepCopy(
|
|
28
|
+
export declare function deepCopy(value: unknown, serializationType?: SerializationType, traversalDescription?: string): unknown;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Map = ____lualib.Map
|
|
3
|
-
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
2
|
local Set = ____lualib.Set
|
|
5
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
|
+
local Map = ____lualib.Map
|
|
6
|
+
local WeakMap = ____lualib.WeakMap
|
|
7
|
+
local WeakSet = ____lualib.WeakSet
|
|
8
|
+
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
6
9
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
10
|
+
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
7
11
|
local ____exports = {}
|
|
8
|
-
local
|
|
12
|
+
local deepCopyTable, deepCopyDefaultMap, deepCopyMap, deepCopySet, deepCopyTSTLClass, getCopiedEntries, checkMetatable, deepCopyUserdata, COPYABLE_ISAAC_API_CLASS_TYPES_SET
|
|
9
13
|
local ____DefaultMap = require("classes.DefaultMap")
|
|
10
14
|
local DefaultMap = ____DefaultMap.DefaultMap
|
|
15
|
+
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
16
|
+
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
11
17
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
12
18
|
local isSerializationBrand = ____SerializationBrand.isSerializationBrand
|
|
13
19
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
@@ -15,19 +21,22 @@ local ____SerializationType = require("enums.SerializationType")
|
|
|
15
21
|
local SerializationType = ____SerializationType.SerializationType
|
|
16
22
|
local ____constants = require("features.saveDataManager.constants")
|
|
17
23
|
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
24
|
+
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
25
|
+
local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
|
|
18
26
|
local ____log = require("functions.log")
|
|
19
27
|
local log = ____log.log
|
|
20
28
|
local ____serialization = require("functions.serialization")
|
|
21
29
|
local copyIsaacAPIClass = ____serialization.copyIsaacAPIClass
|
|
22
30
|
local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
|
|
23
|
-
local isSerializableIsaacAPIClass = ____serialization.isSerializableIsaacAPIClass
|
|
24
31
|
local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
|
|
25
32
|
local ____tstlClass = require("functions.tstlClass")
|
|
26
|
-
local
|
|
33
|
+
local isUserDefinedTSTLClass = ____tstlClass.isUserDefinedTSTLClass
|
|
27
34
|
local newTSTLClass = ____tstlClass.newTSTLClass
|
|
28
35
|
local ____utils = require("functions.utils")
|
|
36
|
+
local ensureAllCases = ____utils.ensureAllCases
|
|
37
|
+
local getEnumValues = ____utils.getEnumValues
|
|
29
38
|
local getTraversalDescription = ____utils.getTraversalDescription
|
|
30
|
-
function ____exports.deepCopy(self,
|
|
39
|
+
function ____exports.deepCopy(self, value, serializationType, traversalDescription)
|
|
31
40
|
if serializationType == nil then
|
|
32
41
|
serializationType = SerializationType.NONE
|
|
33
42
|
end
|
|
@@ -41,178 +50,291 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
41
50
|
elseif serializationType == SerializationType.DESERIALIZE then
|
|
42
51
|
logString = logString .. " (deserializing)"
|
|
43
52
|
end
|
|
53
|
+
logString = logString .. ": " .. tostring(value)
|
|
44
54
|
log(logString)
|
|
45
55
|
end
|
|
46
|
-
local
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
local valueType = type(value)
|
|
57
|
+
repeat
|
|
58
|
+
local ____switch6 = valueType
|
|
59
|
+
local ____cond6 = ____switch6 == "nil" or ____switch6 == "boolean" or ____switch6 == "number" or ____switch6 == "string"
|
|
60
|
+
if ____cond6 then
|
|
61
|
+
do
|
|
62
|
+
return value
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
____cond6 = ____cond6 or (____switch6 == "function" or ____switch6 == "thread")
|
|
66
|
+
if ____cond6 then
|
|
67
|
+
do
|
|
68
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
69
|
+
error((("The deep copy function does not support serialization of \"" .. traversalDescription) .. "\", since it is type: ") .. valueType)
|
|
70
|
+
end
|
|
71
|
+
return value
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
____cond6 = ____cond6 or ____switch6 == "table"
|
|
75
|
+
if ____cond6 then
|
|
76
|
+
do
|
|
77
|
+
local valueTable = value
|
|
78
|
+
return deepCopyTable(nil, valueTable, serializationType, traversalDescription)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
____cond6 = ____cond6 or ____switch6 == "userdata"
|
|
82
|
+
if ____cond6 then
|
|
83
|
+
do
|
|
84
|
+
return deepCopyUserdata(nil, value, serializationType, traversalDescription)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
do
|
|
88
|
+
do
|
|
89
|
+
return ensureAllCases(nil, valueType)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
until true
|
|
93
|
+
end
|
|
94
|
+
function deepCopyTable(self, ____table, serializationType, traversalDescription)
|
|
95
|
+
if __TS__InstanceOf(____table, DefaultMap) or ____table[SerializationBrand.DEFAULT_MAP] ~= nil then
|
|
96
|
+
return deepCopyDefaultMap(nil, ____table, serializationType, traversalDescription)
|
|
97
|
+
end
|
|
98
|
+
if __TS__InstanceOf(____table, Map) or ____table[SerializationBrand.MAP] ~= nil then
|
|
99
|
+
return deepCopyMap(nil, ____table, serializationType, traversalDescription)
|
|
100
|
+
end
|
|
101
|
+
if __TS__InstanceOf(____table, Set) or ____table[SerializationBrand.SET] ~= nil then
|
|
102
|
+
return deepCopySet(nil, ____table, serializationType, traversalDescription)
|
|
103
|
+
end
|
|
104
|
+
if __TS__InstanceOf(____table, WeakMap) then
|
|
105
|
+
error("The deep copy function does not support copying the \"WeakMap\" class: " .. traversalDescription)
|
|
106
|
+
end
|
|
107
|
+
if __TS__InstanceOf(____table, WeakSet) then
|
|
108
|
+
error("The deep copy function does not support copying the \"WeakSet\" class: " .. traversalDescription)
|
|
109
|
+
end
|
|
110
|
+
if isUserDefinedTSTLClass(nil, ____table) then
|
|
111
|
+
return deepCopyTSTLClass(nil, ____table, serializationType, traversalDescription)
|
|
112
|
+
end
|
|
113
|
+
checkMetatable(nil, ____table, traversalDescription)
|
|
114
|
+
if isSerializedIsaacAPIClass(nil, ____table) and serializationType == SerializationType.DESERIALIZE then
|
|
115
|
+
return deserializeIsaacAPIClass(nil, ____table)
|
|
116
|
+
end
|
|
117
|
+
local newTable = {}
|
|
118
|
+
local ____getCopiedEntries_result_0 = getCopiedEntries(nil, ____table, serializationType, traversalDescription)
|
|
119
|
+
local entries = ____getCopiedEntries_result_0.entries
|
|
120
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_0.convertedNumberKeysToStrings
|
|
121
|
+
if convertedNumberKeysToStrings then
|
|
122
|
+
newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
123
|
+
end
|
|
124
|
+
for ____, ____value in ipairs(entries) do
|
|
125
|
+
local key = ____value[1]
|
|
126
|
+
local value = ____value[2]
|
|
127
|
+
newTable[key] = value
|
|
128
|
+
end
|
|
129
|
+
return newTable
|
|
130
|
+
end
|
|
131
|
+
function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescription)
|
|
132
|
+
local ____temp_1
|
|
133
|
+
if __TS__InstanceOf(defaultMap, DefaultMap) then
|
|
134
|
+
____temp_1 = defaultMap:getConstructorArg()
|
|
80
135
|
else
|
|
81
|
-
|
|
136
|
+
____temp_1 = nil
|
|
82
137
|
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
138
|
+
local constructorArg = ____temp_1
|
|
139
|
+
local newDefaultMap
|
|
140
|
+
repeat
|
|
141
|
+
local ____switch25 = serializationType
|
|
142
|
+
local ____cond25 = ____switch25 == SerializationType.NONE
|
|
143
|
+
if ____cond25 then
|
|
144
|
+
do
|
|
145
|
+
newDefaultMap = __TS__New(DefaultMap, constructorArg)
|
|
146
|
+
break
|
|
91
147
|
end
|
|
92
|
-
elseif __TS__InstanceOf(oldObject, Map) then
|
|
93
|
-
newTable[SerializationBrand.MAP] = ""
|
|
94
|
-
elseif __TS__InstanceOf(oldObject, Set) then
|
|
95
|
-
newTable[SerializationBrand.SET] = ""
|
|
96
148
|
end
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
for ____, ____value in __TS__Iterator(oldObject:entries()) do
|
|
100
|
-
local key = ____value[1]
|
|
101
|
-
local value = ____value[2]
|
|
149
|
+
____cond25 = ____cond25 or ____switch25 == SerializationType.SERIALIZE
|
|
150
|
+
if ____cond25 then
|
|
102
151
|
do
|
|
103
|
-
if
|
|
104
|
-
|
|
152
|
+
if type(constructorArg) ~= "boolean" and type(constructorArg) ~= "number" and type(constructorArg) ~= "string" then
|
|
153
|
+
return deepCopyMap(nil, defaultMap, serializationType, traversalDescription)
|
|
105
154
|
end
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
key,
|
|
111
|
-
value,
|
|
112
|
-
traversalDescription,
|
|
113
|
-
serializationType
|
|
114
|
-
)
|
|
155
|
+
newDefaultMap = {}
|
|
156
|
+
newDefaultMap[SerializationBrand.DEFAULT_MAP] = ""
|
|
157
|
+
newDefaultMap[SerializationBrand.DEFAULT_MAP_VALUE] = constructorArg
|
|
158
|
+
break
|
|
115
159
|
end
|
|
116
|
-
::__continue22::
|
|
117
160
|
end
|
|
118
|
-
|
|
119
|
-
|
|
161
|
+
____cond25 = ____cond25 or ____switch25 == SerializationType.DESERIALIZE
|
|
162
|
+
if ____cond25 then
|
|
120
163
|
do
|
|
121
|
-
if
|
|
122
|
-
|
|
164
|
+
if __TS__InstanceOf(defaultMap, DefaultMap) then
|
|
165
|
+
error(("The deep copy function failed to deserialize a default map of \"" .. traversalDescription) .. "\", since it was not a Lua table.")
|
|
166
|
+
end
|
|
167
|
+
local defaultMapValue = defaultMap[SerializationBrand.DEFAULT_MAP_VALUE]
|
|
168
|
+
if defaultMapValue == nil then
|
|
169
|
+
error((("The deep copy function failed to deserialize a default map of \"" .. traversalDescription) .. "\", since there was no serialization brand of: ") .. SerializationBrand.DEFAULT_MAP_VALUE)
|
|
123
170
|
end
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
nil,
|
|
127
|
-
oldObject,
|
|
128
|
-
newObject,
|
|
129
|
-
key,
|
|
130
|
-
value,
|
|
131
|
-
traversalDescription,
|
|
132
|
-
serializationType
|
|
133
|
-
)
|
|
171
|
+
newDefaultMap = __TS__New(DefaultMap, defaultMapValue)
|
|
172
|
+
break
|
|
134
173
|
end
|
|
135
|
-
::__continue26::
|
|
136
174
|
end
|
|
137
|
-
|
|
138
|
-
for key, value in pairs(oldObject) do
|
|
175
|
+
do
|
|
139
176
|
do
|
|
140
|
-
|
|
141
|
-
goto __continue30
|
|
142
|
-
end
|
|
143
|
-
deepCopyValue(
|
|
144
|
-
nil,
|
|
145
|
-
oldObject,
|
|
146
|
-
newObject,
|
|
147
|
-
key,
|
|
148
|
-
value,
|
|
149
|
-
traversalDescription,
|
|
150
|
-
serializationType
|
|
151
|
-
)
|
|
177
|
+
return ensureAllCases(nil, serializationType)
|
|
152
178
|
end
|
|
153
|
-
|
|
179
|
+
end
|
|
180
|
+
until true
|
|
181
|
+
local ____getCopiedEntries_result_2 = getCopiedEntries(nil, defaultMap, serializationType, traversalDescription)
|
|
182
|
+
local entries = ____getCopiedEntries_result_2.entries
|
|
183
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_2.convertedNumberKeysToStrings
|
|
184
|
+
if convertedNumberKeysToStrings then
|
|
185
|
+
if __TS__InstanceOf(newDefaultMap, DefaultMap) then
|
|
186
|
+
newDefaultMap:set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "")
|
|
187
|
+
else
|
|
188
|
+
newDefaultMap[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
for ____, ____value in ipairs(entries) do
|
|
192
|
+
local key = ____value[1]
|
|
193
|
+
local value = ____value[2]
|
|
194
|
+
if __TS__InstanceOf(newDefaultMap, DefaultMap) then
|
|
195
|
+
newDefaultMap:set(key, value)
|
|
196
|
+
else
|
|
197
|
+
newDefaultMap[key] = value
|
|
154
198
|
end
|
|
155
199
|
end
|
|
156
|
-
return
|
|
200
|
+
return newDefaultMap
|
|
157
201
|
end
|
|
158
|
-
function
|
|
159
|
-
local
|
|
160
|
-
if
|
|
161
|
-
|
|
202
|
+
function deepCopyMap(self, map, serializationType, traversalDescription)
|
|
203
|
+
local newMap
|
|
204
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
205
|
+
newMap = {}
|
|
206
|
+
newMap[SerializationBrand.MAP] = ""
|
|
207
|
+
else
|
|
208
|
+
newMap = __TS__New(Map)
|
|
162
209
|
end
|
|
163
|
-
local
|
|
164
|
-
|
|
210
|
+
local ____getCopiedEntries_result_3 = getCopiedEntries(nil, map, serializationType, traversalDescription)
|
|
211
|
+
local entries = ____getCopiedEntries_result_3.entries
|
|
212
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_3.convertedNumberKeysToStrings
|
|
213
|
+
if convertedNumberKeysToStrings then
|
|
214
|
+
if __TS__InstanceOf(newMap, Map) then
|
|
215
|
+
newMap:set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "")
|
|
216
|
+
else
|
|
217
|
+
newMap[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
for ____, ____value in ipairs(entries) do
|
|
221
|
+
local key = ____value[1]
|
|
222
|
+
local value = ____value[2]
|
|
223
|
+
if __TS__InstanceOf(newMap, Map) then
|
|
224
|
+
newMap:set(key, value)
|
|
225
|
+
else
|
|
226
|
+
newMap[key] = value
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
return newMap
|
|
165
230
|
end
|
|
166
|
-
function
|
|
167
|
-
local
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
231
|
+
function deepCopySet(self, set, serializationType, traversalDescription)
|
|
232
|
+
local newSet
|
|
233
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
234
|
+
newSet = {}
|
|
235
|
+
newSet[SerializationBrand.SET] = ""
|
|
236
|
+
else
|
|
237
|
+
newSet = __TS__New(Set)
|
|
238
|
+
end
|
|
239
|
+
local ____getCopiedEntries_result_4 = getCopiedEntries(nil, set, serializationType, traversalDescription)
|
|
240
|
+
local entries = ____getCopiedEntries_result_4.entries
|
|
241
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_4.convertedNumberKeysToStrings
|
|
242
|
+
if convertedNumberKeysToStrings then
|
|
243
|
+
if __TS__InstanceOf(newSet, Set) then
|
|
244
|
+
error("The deep copy function cannot convert number keys to strings for a Set.")
|
|
245
|
+
else
|
|
246
|
+
newSet[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
178
247
|
end
|
|
179
248
|
end
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
249
|
+
for ____, ____value in ipairs(entries) do
|
|
250
|
+
local key = ____value[1]
|
|
251
|
+
if __TS__InstanceOf(newSet, Set) then
|
|
252
|
+
newSet:add(key)
|
|
253
|
+
else
|
|
254
|
+
newSet[key] = ""
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
return newSet
|
|
258
|
+
end
|
|
259
|
+
function deepCopyTSTLClass(self, tstlClass, serializationType, traversalDescription)
|
|
260
|
+
local newClass
|
|
261
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
262
|
+
newClass = {}
|
|
191
263
|
else
|
|
192
|
-
|
|
193
|
-
|
|
264
|
+
newClass = newTSTLClass(nil, tstlClass)
|
|
265
|
+
end
|
|
266
|
+
local ____getCopiedEntries_result_5 = getCopiedEntries(nil, tstlClass, serializationType, traversalDescription)
|
|
267
|
+
local entries = ____getCopiedEntries_result_5.entries
|
|
268
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_5.convertedNumberKeysToStrings
|
|
269
|
+
if convertedNumberKeysToStrings then
|
|
270
|
+
newClass[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
271
|
+
end
|
|
272
|
+
for ____, ____value in ipairs(entries) do
|
|
273
|
+
local key = ____value[1]
|
|
274
|
+
local value = ____value[2]
|
|
275
|
+
newClass[key] = value
|
|
194
276
|
end
|
|
277
|
+
return newClass
|
|
195
278
|
end
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
|
|
279
|
+
function getCopiedEntries(self, object, serializationType, traversalDescription)
|
|
280
|
+
local entries = {}
|
|
281
|
+
if __TS__InstanceOf(object, Map) or __TS__InstanceOf(object, Set) then
|
|
282
|
+
for ____, ____value in __TS__Iterator(object:entries()) do
|
|
283
|
+
local key = ____value[1]
|
|
284
|
+
local value = ____value[2]
|
|
285
|
+
__TS__ArrayPush(entries, {key, value})
|
|
286
|
+
end
|
|
287
|
+
else
|
|
288
|
+
for key, value in pairs(object) do
|
|
289
|
+
__TS__ArrayPush(entries, {key, value})
|
|
290
|
+
end
|
|
199
291
|
end
|
|
200
|
-
|
|
201
|
-
|
|
292
|
+
local hasNumberKeys = __TS__ArraySome(
|
|
293
|
+
entries,
|
|
294
|
+
function(____, ____bindingPattern0)
|
|
295
|
+
local key
|
|
296
|
+
key = ____bindingPattern0[1]
|
|
297
|
+
return type(key) == "number"
|
|
298
|
+
end
|
|
299
|
+
)
|
|
300
|
+
local convertNumberKeysToStrings = serializationType == SerializationType.SERIALIZE and hasNumberKeys
|
|
301
|
+
local copiedEntries = {}
|
|
302
|
+
for ____, ____value in ipairs(entries) do
|
|
303
|
+
local key = ____value[1]
|
|
304
|
+
local value = ____value[2]
|
|
305
|
+
do
|
|
306
|
+
if isSerializationBrand(nil, key) then
|
|
307
|
+
goto __continue73
|
|
308
|
+
end
|
|
309
|
+
traversalDescription = getTraversalDescription(nil, key, traversalDescription)
|
|
310
|
+
local newValue = ____exports.deepCopy(nil, value, serializationType, traversalDescription)
|
|
311
|
+
local keyToUse = convertNumberKeysToStrings and tostring(key) or key
|
|
312
|
+
__TS__ArrayPush(copiedEntries, {keyToUse, newValue})
|
|
313
|
+
end
|
|
314
|
+
::__continue73::
|
|
202
315
|
end
|
|
316
|
+
return {entries = copiedEntries, convertedNumberKeysToStrings = convertNumberKeysToStrings}
|
|
203
317
|
end
|
|
204
|
-
function
|
|
205
|
-
|
|
206
|
-
|
|
318
|
+
function checkMetatable(self, ____table, traversalDescription)
|
|
319
|
+
local metatable = getmetatable(____table)
|
|
320
|
+
if metatable == nil then
|
|
321
|
+
return
|
|
207
322
|
end
|
|
208
|
-
|
|
209
|
-
|
|
323
|
+
local tableDescription = traversalDescription == "" and "the table to copy" or ("\"" .. traversalDescription) .. "\""
|
|
324
|
+
error(("The deepCopy function detected that \"" .. tableDescription) .. "\" has a metatable. Copying tables with metatables is not supported, unless they are explicitly handled by the save data manager. (e.g. TypeScriptToLua Maps, TypeScriptToLua Sets, etc.)")
|
|
325
|
+
end
|
|
326
|
+
function deepCopyUserdata(self, value, serializationType, traversalDescription)
|
|
327
|
+
local classType = getIsaacAPIClassType(nil, value)
|
|
328
|
+
if classType == nil then
|
|
329
|
+
error("The deep copy function was not able to derive the Isaac API class type for: " .. traversalDescription)
|
|
210
330
|
end
|
|
211
|
-
if
|
|
212
|
-
|
|
213
|
-
traversalDescription = getTraversalDescription(nil, key, traversalDescription)
|
|
214
|
-
return ____exports.deepCopy(nil, ____table, serializationType, traversalDescription)
|
|
331
|
+
if not COPYABLE_ISAAC_API_CLASS_TYPES_SET:has(classType) then
|
|
332
|
+
error((("The deep copy function does not support copying \"" .. traversalDescription) .. "\", since it is an Isaac API class of type: ") .. classType)
|
|
215
333
|
end
|
|
216
|
-
return value
|
|
334
|
+
return copyIsaacAPIClass(nil, value, serializationType)
|
|
217
335
|
end
|
|
336
|
+
COPYABLE_ISAAC_API_CLASS_TYPES_SET = __TS__New(
|
|
337
|
+
Set,
|
|
338
|
+
getEnumValues(nil, CopyableIsaacAPIClassType)
|
|
339
|
+
)
|
|
218
340
|
return ____exports
|
package/dist/functions/log.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare function logEntityID(this: void, entity: Entity): void;
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function logError(this: void, msg: string): void;
|
|
29
29
|
/** Helper function for printing out every flag that is turned on. Useful when debugging. */
|
|
30
|
-
export declare function logFlags(this: void, flags: int, flagEnum?: LuaTable, description?: string): void;
|
|
30
|
+
export declare function logFlags(this: void, flags: int, flagEnum?: LuaTable<AnyNotNil, unknown>, description?: string): void;
|
|
31
31
|
/**
|
|
32
32
|
* Helper function for printing out every game state flag that is turned on. Useful when debugging.
|
|
33
33
|
*/
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { SerializationType } from "../enums/SerializationType";
|
|
2
|
-
import { SerializableIsaacAPIClass } from "../types/private/SerializableIsaacAPIClass";
|
|
3
2
|
import { SerializedIsaacAPIClass } from "../types/private/SerializedIsaacAPIClass";
|
|
4
|
-
export declare function copyIsaacAPIClass(isaacAPIClass:
|
|
3
|
+
export declare function copyIsaacAPIClass(isaacAPIClass: unknown, serializationType: SerializationType): unknown;
|
|
5
4
|
/**
|
|
6
|
-
* Deserialization is a special case, so we make a dedicated function for this.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Deserialization is a special case, so we make a dedicated function for this.
|
|
6
|
+
*
|
|
7
|
+
* There is no need for a corresponding "serializeIsaacAPIClass" function because the
|
|
8
|
+
* "copyIsaacAPIClass" function can handles all serialization types.
|
|
9
9
|
*/
|
|
10
10
|
export declare function deserializeIsaacAPIClass(serializedIsaacAPIClass: SerializedIsaacAPIClass): unknown;
|
|
11
|
-
export declare function isSerializableIsaacAPIClass(object: unknown): object is SerializableIsaacAPIClass;
|
|
12
11
|
export declare function isSerializedIsaacAPIClass(object: unknown): object is SerializedIsaacAPIClass;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Set = ____lualib.Set
|
|
3
|
-
local __TS__New = ____lualib.__TS__New
|
|
4
2
|
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
5
3
|
local __TS__ObjectValues = ____lualib.__TS__ObjectValues
|
|
6
4
|
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
7
5
|
local ____exports = {}
|
|
8
6
|
local getSerializedTableType
|
|
9
|
-
local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
|
|
10
|
-
local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
|
|
11
7
|
local ____SerializationType = require("enums.SerializationType")
|
|
12
8
|
local SerializationType = ____SerializationType.SerializationType
|
|
13
9
|
local ____isaacAPIClassTypeToBrand = require("objects.isaacAPIClassTypeToBrand")
|
|
@@ -18,35 +14,29 @@ local ____serializedIsaacAPIClassTypeToIdentityFunction = require("objects.seria
|
|
|
18
14
|
local SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = ____serializedIsaacAPIClassTypeToIdentityFunction.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION
|
|
19
15
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
20
16
|
local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
|
|
21
|
-
local ____utils = require("functions.utils")
|
|
22
|
-
local getEnumValues = ____utils.getEnumValues
|
|
23
17
|
function getSerializedTableType(self, serializedIsaacAPIClass)
|
|
24
18
|
for ____, ____value in ipairs(__TS__ObjectEntries(ISAAC_API_CLASS_TYPE_TO_BRAND)) do
|
|
25
|
-
local
|
|
19
|
+
local copyableIsaacAPIClassType = ____value[1]
|
|
26
20
|
local serializationBrand = ____value[2]
|
|
27
21
|
if serializedIsaacAPIClass[serializationBrand] ~= nil then
|
|
28
|
-
return
|
|
22
|
+
return copyableIsaacAPIClassType
|
|
29
23
|
end
|
|
30
24
|
end
|
|
31
25
|
return nil
|
|
32
26
|
end
|
|
33
|
-
local SERIALIZABLE_ISAAC_API_CLASS_TYPES_SET = __TS__New(
|
|
34
|
-
Set,
|
|
35
|
-
getEnumValues(nil, SerializableIsaacAPIClassType)
|
|
36
|
-
)
|
|
37
27
|
function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
|
|
38
28
|
local objectType = type(isaacAPIClass)
|
|
39
29
|
if objectType ~= "userdata" then
|
|
40
|
-
error("Failed to
|
|
30
|
+
error("Failed to copy an Isaac API class since the provided object was of type: " .. objectType)
|
|
41
31
|
end
|
|
42
32
|
local isaacAPIClassType = getIsaacAPIClassType(nil, isaacAPIClass)
|
|
43
33
|
if isaacAPIClassType == nil then
|
|
44
|
-
error("Failed to
|
|
34
|
+
error("Failed to copy an Isaac API class due to it not having a class type.")
|
|
45
35
|
end
|
|
46
|
-
local
|
|
47
|
-
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[
|
|
36
|
+
local copyableIsaacAPIClassType = isaacAPIClassType
|
|
37
|
+
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[copyableIsaacAPIClassType]
|
|
48
38
|
if copyFunction == nil then
|
|
49
|
-
error(("Failed to copy Isaac API class \"" ..
|
|
39
|
+
error(("Failed to copy Isaac API class \"" .. copyableIsaacAPIClassType) .. "\" since there is not a defined copy function for this class type.")
|
|
50
40
|
end
|
|
51
41
|
return copyFunction(nil, isaacAPIClass, serializationType)
|
|
52
42
|
end
|
|
@@ -55,23 +45,16 @@ function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
|
|
|
55
45
|
if objectType ~= "table" then
|
|
56
46
|
error("Failed to deserialize an Isaac API class since the provided object was of type: " .. objectType)
|
|
57
47
|
end
|
|
58
|
-
local
|
|
59
|
-
if
|
|
48
|
+
local copyableIsaacAPIClassType = getSerializedTableType(nil, serializedIsaacAPIClass)
|
|
49
|
+
if copyableIsaacAPIClassType == nil then
|
|
60
50
|
error("Failed to deserialize an API class since a valid class type brand was not found.")
|
|
61
51
|
end
|
|
62
|
-
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[
|
|
52
|
+
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[copyableIsaacAPIClassType]
|
|
63
53
|
if copyFunction == nil then
|
|
64
|
-
error(("Failed to deserialize Isaac API class \"" ..
|
|
54
|
+
error(("Failed to deserialize Isaac API class \"" .. copyableIsaacAPIClassType) .. "\" since there is not a defined copy function for this class type.")
|
|
65
55
|
end
|
|
66
56
|
return copyFunction(nil, serializedIsaacAPIClass, SerializationType.DESERIALIZE)
|
|
67
57
|
end
|
|
68
|
-
function ____exports.isSerializableIsaacAPIClass(self, object)
|
|
69
|
-
local classType = getIsaacAPIClassType(nil, object)
|
|
70
|
-
if classType == nil then
|
|
71
|
-
return false
|
|
72
|
-
end
|
|
73
|
-
return SERIALIZABLE_ISAAC_API_CLASS_TYPES_SET:has(classType)
|
|
74
|
-
end
|
|
75
58
|
function ____exports.isSerializedIsaacAPIClass(self, object)
|
|
76
59
|
local identityFunctions = __TS__ObjectValues(SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION)
|
|
77
60
|
return __TS__ArraySome(
|
|
@@ -33,4 +33,4 @@ export declare function getStringsFromTable(table: LuaTable<string, unknown>, ob
|
|
|
33
33
|
* This function is variadic, meaning that you can specify as many arguments as you want to check
|
|
34
34
|
* for.
|
|
35
35
|
*/
|
|
36
|
-
export declare function tableHasKeys(table: LuaTable, ...keys: string[]): boolean;
|
|
36
|
+
export declare function tableHasKeys(table: LuaTable<AnyNotNil, unknown>, ...keys: string[]): boolean;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { TSTLClass } from "../types/private/TSTLClass";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* For the purposes of this function, TSTL Maps, Sets, WeakMaps, and WeakSets do not count as TSTL
|
|
6
|
-
* classes, because this function is intended to detect user-defined classes.
|
|
3
|
+
* Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
|
|
4
|
+
* as a `DefaultMap`.
|
|
7
5
|
*/
|
|
8
|
-
export declare function
|
|
6
|
+
export declare function isIsaacScriptCommonClass(object: unknown): boolean;
|
|
7
|
+
/** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
|
|
8
|
+
export declare function isUserDefinedTSTLClass(object: unknown): object is TSTLClass;
|
|
9
|
+
/**
|
|
10
|
+
* Returns whether or not this is a class that is provided as part of the TypeScriptToLua
|
|
11
|
+
* transpiler, such as a `Map` or a `Set`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isVanillaTSTLClass(object: unknown): boolean;
|
|
9
14
|
/**
|
|
10
15
|
* Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
|
|
11
16
|
* it is. This function requires that you provide an instantiated class of the same type, as it will
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
-
local Map = ____lualib.Map
|
|
5
4
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
|
+
local Map = ____lualib.Map
|
|
6
6
|
local WeakMap = ____lualib.WeakMap
|
|
7
7
|
local WeakSet = ____lualib.WeakSet
|
|
8
8
|
local ____exports = {}
|
|
9
9
|
local newTSTLClassFromMetatable
|
|
10
|
+
local ____DefaultMap = require("classes.DefaultMap")
|
|
11
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
12
|
+
function ____exports.isVanillaTSTLClass(self, object)
|
|
13
|
+
return __TS__InstanceOf(object, Map) or __TS__InstanceOf(object, Set) or __TS__InstanceOf(object, WeakMap) or __TS__InstanceOf(object, WeakSet)
|
|
14
|
+
end
|
|
10
15
|
function newTSTLClassFromMetatable(self, metatable)
|
|
11
16
|
local newClass = {}
|
|
12
17
|
local newClassMetatable = setmetatable(newClass, metatable.constructor.prototype)
|
|
@@ -14,8 +19,11 @@ function newTSTLClassFromMetatable(self, metatable)
|
|
|
14
19
|
return newClass
|
|
15
20
|
end
|
|
16
21
|
local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
|
|
17
|
-
function ____exports.
|
|
18
|
-
|
|
22
|
+
function ____exports.isIsaacScriptCommonClass(self, object)
|
|
23
|
+
return __TS__InstanceOf(object, DefaultMap)
|
|
24
|
+
end
|
|
25
|
+
function ____exports.isUserDefinedTSTLClass(self, object)
|
|
26
|
+
if ____exports.isVanillaTSTLClass(nil, object) or ____exports.isIsaacScriptCommonClass(nil, object) then
|
|
19
27
|
return false
|
|
20
28
|
end
|
|
21
29
|
local objectType = type(object)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
2
|
/**
|
|
4
3
|
* Helper function to get type safety on a switch statement.
|
|
5
4
|
*
|
|
@@ -74,7 +73,7 @@ export declare function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]>;
|
|
|
74
73
|
* Helper function to log what is happening in functions that recursively move through nested data
|
|
75
74
|
* structures.
|
|
76
75
|
*/
|
|
77
|
-
export declare function getTraversalDescription(key:
|
|
76
|
+
export declare function getTraversalDescription(key: unknown, traversalDescription: string): string;
|
|
78
77
|
/**
|
|
79
78
|
* Converts a hex string like "#33aa33" to a KColor object.
|
|
80
79
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
2
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
3
3
|
export declare const ISAAC_API_CLASS_TYPE_TO_BRAND: {
|
|
4
|
-
readonly [key in
|
|
4
|
+
readonly [key in CopyableIsaacAPIClassType]: SerializationBrand;
|
|
5
5
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
-
local
|
|
4
|
-
local
|
|
3
|
+
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
4
|
+
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
5
5
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
6
6
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
7
|
-
____exports.ISAAC_API_CLASS_TYPE_TO_BRAND = {[
|
|
7
|
+
____exports.ISAAC_API_CLASS_TYPE_TO_BRAND = {[CopyableIsaacAPIClassType.COLOR] = SerializationBrand.COLOR, [CopyableIsaacAPIClassType.KCOLOR] = SerializationBrand.KCOLOR, [CopyableIsaacAPIClassType.RNG] = SerializationBrand.RNG, [CopyableIsaacAPIClassType.VECTOR] = SerializationBrand.VECTOR}
|
|
8
8
|
return ____exports
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
2
|
import { SerializationType } from "../enums/SerializationType";
|
|
3
3
|
export declare const ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION: {
|
|
4
|
-
readonly [key in
|
|
4
|
+
readonly [key in CopyableIsaacAPIClassType]: (object: unknown, serializationType: SerializationType) => boolean;
|
|
5
5
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
-
local
|
|
4
|
-
local
|
|
3
|
+
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
4
|
+
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
5
5
|
local ____color = require("functions.color")
|
|
6
6
|
local copyColor = ____color.copyColor
|
|
7
7
|
local ____kColor = require("functions.kColor")
|
|
@@ -10,5 +10,5 @@ local ____rng = require("functions.rng")
|
|
|
10
10
|
local copyRNG = ____rng.copyRNG
|
|
11
11
|
local ____vector = require("functions.vector")
|
|
12
12
|
local copyVector = ____vector.copyVector
|
|
13
|
-
____exports.ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = {[
|
|
13
|
+
____exports.ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = {[CopyableIsaacAPIClassType.COLOR] = copyColor, [CopyableIsaacAPIClassType.KCOLOR] = copyKColor, [CopyableIsaacAPIClassType.RNG] = copyRNG, [CopyableIsaacAPIClassType.VECTOR] = copyVector}
|
|
14
14
|
return ____exports
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
2
|
export declare const SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION: {
|
|
3
|
-
readonly [key in
|
|
3
|
+
readonly [key in CopyableIsaacAPIClassType]: (object: unknown) => boolean;
|
|
4
4
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
-
local
|
|
4
|
-
local
|
|
3
|
+
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
4
|
+
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
5
5
|
local ____color = require("functions.color")
|
|
6
6
|
local isSerializedColor = ____color.isSerializedColor
|
|
7
7
|
local ____kColor = require("functions.kColor")
|
|
@@ -10,5 +10,5 @@ local ____rng = require("functions.rng")
|
|
|
10
10
|
local isSerializedRNG = ____rng.isSerializedRNG
|
|
11
11
|
local ____vector = require("functions.vector")
|
|
12
12
|
local isSerializedVector = ____vector.isSerializedVector
|
|
13
|
-
____exports.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = {[
|
|
13
|
+
____exports.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = {[CopyableIsaacAPIClassType.COLOR] = isSerializedColor, [CopyableIsaacAPIClassType.KCOLOR] = isSerializedKColor, [CopyableIsaacAPIClassType.RNG] = isSerializedRNG, [CopyableIsaacAPIClassType.VECTOR] = isSerializedVector}
|
|
14
14
|
return ____exports
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Primitive } from "../Primitive";
|
|
2
|
+
/**
|
|
3
|
+
* I don't know how to create a recursive type definition for only primitive values. For now, this
|
|
4
|
+
* is typed as "unknown", which provides no type safety.
|
|
5
|
+
*/
|
|
2
6
|
declare type Serializable = Primitive | unknown;
|
|
3
7
|
/**
|
|
4
8
|
* Each sub-object of save data has a string as a key, without arbitrary data as a value. However,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.250",
|
|
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.99",
|
|
30
30
|
"isaacscript-tsconfig": "^1.1.8",
|
|
31
31
|
"typedoc": "^0.22.13",
|
|
32
32
|
"typescript": "4.6.3",
|