isaacscript-common 12.3.5 → 12.3.6
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/isaacscript-common.lua +21 -9
- package/dist/src/features/saveDataManager/main.d.ts.map +1 -1
- package/dist/src/features/saveDataManager/main.lua +1 -1
- package/dist/src/features/saveDataManager/maps.d.ts +3 -0
- package/dist/src/features/saveDataManager/maps.d.ts.map +1 -1
- package/dist/src/features/saveDataManager/maps.lua +3 -0
- package/dist/src/features/saveDataManager/merge.lua +16 -7
- package/dist/src/functions/log.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/saveDataManager/main.ts +6 -1
- package/src/features/saveDataManager/maps.ts +3 -0
- package/src/features/saveDataManager/merge.ts +19 -6
- package/src/functions/log.ts +2 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 12.3.
|
|
3
|
+
isaacscript-common 12.3.6
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -31318,7 +31318,7 @@ local ____lualib = require("lualib_bundle")
|
|
|
31318
31318
|
local Set = ____lualib.Set
|
|
31319
31319
|
local Map = ____lualib.Map
|
|
31320
31320
|
local ____exports = {}
|
|
31321
|
-
local
|
|
31321
|
+
local mergeSerializedArray, mergeSerializedTSTLObject, mergeSerializedTable
|
|
31322
31322
|
local ____SerializationBrand = require("src.enums.private.SerializationBrand")
|
|
31323
31323
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
31324
31324
|
local ____SerializationType = require("src.enums.SerializationType")
|
|
@@ -31379,16 +31379,19 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
|
31379
31379
|
error("The second argument given to the merge function is not a table.")
|
|
31380
31380
|
end
|
|
31381
31381
|
if isArray(nil, oldObject) and isArray(nil, newTable) then
|
|
31382
|
-
|
|
31382
|
+
mergeSerializedArray(nil, oldObject, newTable, traversalDescription)
|
|
31383
31383
|
return
|
|
31384
31384
|
end
|
|
31385
31385
|
if isTSTLMap(nil, oldObject) or isTSTLSet(nil, oldObject) or isDefaultMap(nil, oldObject) then
|
|
31386
|
-
|
|
31386
|
+
mergeSerializedTSTLObject(nil, oldObject, newTable, traversalDescription)
|
|
31387
31387
|
else
|
|
31388
|
-
|
|
31388
|
+
mergeSerializedTable(nil, oldObject, newTable, traversalDescription)
|
|
31389
31389
|
end
|
|
31390
31390
|
end
|
|
31391
|
-
function
|
|
31391
|
+
function mergeSerializedArray(self, oldArray, newArray, traversalDescription)
|
|
31392
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
31393
|
+
log(nil, "merge encountered an array: " .. traversalDescription)
|
|
31394
|
+
end
|
|
31392
31395
|
clearTable(nil, oldArray)
|
|
31393
31396
|
iterateTableInOrder(
|
|
31394
31397
|
nil,
|
|
@@ -31399,7 +31402,10 @@ function mergeArray(self, oldArray, newArray)
|
|
|
31399
31402
|
SAVE_DATA_MANAGER_DEBUG
|
|
31400
31403
|
)
|
|
31401
31404
|
end
|
|
31402
|
-
function
|
|
31405
|
+
function mergeSerializedTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
31406
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
31407
|
+
log(nil, "merge encountered a TSTL object: " .. traversalDescription)
|
|
31408
|
+
end
|
|
31403
31409
|
oldObject:clear()
|
|
31404
31410
|
local convertStringKeysToNumbers = newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] ~= nil
|
|
31405
31411
|
iterateTableInOrder(
|
|
@@ -31432,7 +31438,10 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
|
31432
31438
|
SAVE_DATA_MANAGER_DEBUG
|
|
31433
31439
|
)
|
|
31434
31440
|
end
|
|
31435
|
-
function
|
|
31441
|
+
function mergeSerializedTable(self, oldTable, newTable, traversalDescription)
|
|
31442
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
31443
|
+
log(nil, "merge encountered a Lua table: " .. traversalDescription)
|
|
31444
|
+
end
|
|
31436
31445
|
iterateTableInOrder(
|
|
31437
31446
|
nil,
|
|
31438
31447
|
newTable,
|
|
@@ -31556,6 +31565,9 @@ ____exports.saveDataDefaultsMap = {}
|
|
|
31556
31565
|
____exports.saveDataConditionalFuncMap = {}
|
|
31557
31566
|
--- We backup some save data keys on every new room for the purposes of restoring it when Glowing
|
|
31558
31567
|
-- Hour Glass is used.
|
|
31568
|
+
--
|
|
31569
|
+
-- Note that the save data is backed up in serialized form so that we can use the `merge` function
|
|
31570
|
+
-- to restore it.
|
|
31559
31571
|
____exports.saveDataGlowingHourGlassMap = {}
|
|
31560
31572
|
return ____exports
|
|
31561
31573
|
end,
|
|
@@ -31716,7 +31728,7 @@ function makeGlowingHourGlassBackup(self)
|
|
|
31716
31728
|
saveDataGlowingHourGlass = {}
|
|
31717
31729
|
saveDataGlowingHourGlassMap[subscriberName] = saveDataGlowingHourGlass
|
|
31718
31730
|
end
|
|
31719
|
-
local copiedChildTable = deepCopy(nil, childTable)
|
|
31731
|
+
local copiedChildTable = deepCopy(nil, childTable, SerializationType.SERIALIZE)
|
|
31720
31732
|
saveDataGlowingHourGlass[saveDataKey] = copiedChildTable
|
|
31721
31733
|
end
|
|
31722
31734
|
::__continue18::
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AA2BrD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAelE;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AA2BrD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAelE;AA0LD,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,GACvB,IAAI,CA4CN;AAiBD,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C"}
|
|
@@ -104,7 +104,7 @@ function makeGlowingHourGlassBackup(self)
|
|
|
104
104
|
saveDataGlowingHourGlass = {}
|
|
105
105
|
saveDataGlowingHourGlassMap[subscriberName] = saveDataGlowingHourGlass
|
|
106
106
|
end
|
|
107
|
-
local copiedChildTable = deepCopy(nil, childTable)
|
|
107
|
+
local copiedChildTable = deepCopy(nil, childTable, SerializationType.SERIALIZE)
|
|
108
108
|
saveDataGlowingHourGlass[saveDataKey] = copiedChildTable
|
|
109
109
|
end
|
|
110
110
|
::__continue18::
|
|
@@ -11,6 +11,9 @@ export declare const saveDataConditionalFuncMap: LuaMap<string, () => boolean>;
|
|
|
11
11
|
/**
|
|
12
12
|
* We backup some save data keys on every new room for the purposes of restoring it when Glowing
|
|
13
13
|
* Hour Glass is used.
|
|
14
|
+
*
|
|
15
|
+
* Note that the save data is backed up in serialized form so that we can use the `merge` function
|
|
16
|
+
* to restore it.
|
|
14
17
|
*/
|
|
15
18
|
export declare const saveDataGlowingHourGlassMap: LuaMap<string, SaveData<unknown, unknown, unknown>>;
|
|
16
19
|
//# sourceMappingURL=maps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maps.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/maps.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,WAAW,qDAAiC,CAAC;AAE1D,eAAO,MAAM,mBAAmB,qDAAiC,CAAC;AAClE,eAAO,MAAM,0BAA0B,uBAA4B,OAAO,CAAG,CAAC;AAE9E
|
|
1
|
+
{"version":3,"file":"maps.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/maps.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,WAAW,qDAAiC,CAAC;AAE1D,eAAO,MAAM,mBAAmB,qDAAiC,CAAC;AAClE,eAAO,MAAM,0BAA0B,uBAA4B,OAAO,CAAG,CAAC;AAE9E;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,qDAAiC,CAAC"}
|
|
@@ -7,5 +7,8 @@ ____exports.saveDataDefaultsMap = {}
|
|
|
7
7
|
____exports.saveDataConditionalFuncMap = {}
|
|
8
8
|
--- We backup some save data keys on every new room for the purposes of restoring it when Glowing
|
|
9
9
|
-- Hour Glass is used.
|
|
10
|
+
--
|
|
11
|
+
-- Note that the save data is backed up in serialized form so that we can use the `merge` function
|
|
12
|
+
-- to restore it.
|
|
10
13
|
____exports.saveDataGlowingHourGlassMap = {}
|
|
11
14
|
return ____exports
|
|
@@ -2,7 +2,7 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local Map = ____lualib.Map
|
|
4
4
|
local ____exports = {}
|
|
5
|
-
local
|
|
5
|
+
local mergeSerializedArray, mergeSerializedTSTLObject, mergeSerializedTable
|
|
6
6
|
local ____SerializationBrand = require("src.enums.private.SerializationBrand")
|
|
7
7
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
8
8
|
local ____SerializationType = require("src.enums.SerializationType")
|
|
@@ -63,16 +63,19 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
|
63
63
|
error("The second argument given to the merge function is not a table.")
|
|
64
64
|
end
|
|
65
65
|
if isArray(nil, oldObject) and isArray(nil, newTable) then
|
|
66
|
-
|
|
66
|
+
mergeSerializedArray(nil, oldObject, newTable, traversalDescription)
|
|
67
67
|
return
|
|
68
68
|
end
|
|
69
69
|
if isTSTLMap(nil, oldObject) or isTSTLSet(nil, oldObject) or isDefaultMap(nil, oldObject) then
|
|
70
|
-
|
|
70
|
+
mergeSerializedTSTLObject(nil, oldObject, newTable, traversalDescription)
|
|
71
71
|
else
|
|
72
|
-
|
|
72
|
+
mergeSerializedTable(nil, oldObject, newTable, traversalDescription)
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
|
-
function
|
|
75
|
+
function mergeSerializedArray(self, oldArray, newArray, traversalDescription)
|
|
76
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
77
|
+
log(nil, "merge encountered an array: " .. traversalDescription)
|
|
78
|
+
end
|
|
76
79
|
clearTable(nil, oldArray)
|
|
77
80
|
iterateTableInOrder(
|
|
78
81
|
nil,
|
|
@@ -83,7 +86,10 @@ function mergeArray(self, oldArray, newArray)
|
|
|
83
86
|
SAVE_DATA_MANAGER_DEBUG
|
|
84
87
|
)
|
|
85
88
|
end
|
|
86
|
-
function
|
|
89
|
+
function mergeSerializedTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
90
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
91
|
+
log(nil, "merge encountered a TSTL object: " .. traversalDescription)
|
|
92
|
+
end
|
|
87
93
|
oldObject:clear()
|
|
88
94
|
local convertStringKeysToNumbers = newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] ~= nil
|
|
89
95
|
iterateTableInOrder(
|
|
@@ -116,7 +122,10 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
|
116
122
|
SAVE_DATA_MANAGER_DEBUG
|
|
117
123
|
)
|
|
118
124
|
end
|
|
119
|
-
function
|
|
125
|
+
function mergeSerializedTable(self, oldTable, newTable, traversalDescription)
|
|
126
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
127
|
+
log(nil, "merge encountered a Lua table: " .. traversalDescription)
|
|
128
|
+
end
|
|
120
129
|
iterateTableInOrder(
|
|
121
130
|
nil,
|
|
122
131
|
newTable,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/functions/log.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,UAAU,EAKV,cAAc,EAGd,QAAQ,EACR,OAAO,EACR,MAAM,8BAA8B,CAAC;AAkBtC;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EAKX,kBAAkB,SAAI,GACrB,MAAM,CAiBR;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGrC;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAG3D;AAED,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,eAAe,EAAE,GAAG,IAAI,CAS7E;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAI3C;AAED,mGAAmG;AACnG,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAE7E;AAED,mGAAmG;AACnG,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAE7E;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAGhD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAED,4FAA4F;AAC5F,wBAAgB,QAAQ,CAAC,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
|
@@ -163,7 +163,12 @@ function makeGlowingHourGlassBackup() {
|
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
// We serialize the table so that we can use the `merge` function later on with no other
|
|
167
|
+
// modifications.
|
|
168
|
+
const copiedChildTable = deepCopy(
|
|
169
|
+
childTable,
|
|
170
|
+
SerializationType.SERIALIZE,
|
|
171
|
+
) as Record<string, unknown>;
|
|
167
172
|
saveDataGlowingHourGlass[saveDataKey] = copiedChildTable;
|
|
168
173
|
}
|
|
169
174
|
},
|
|
@@ -13,5 +13,8 @@ export const saveDataConditionalFuncMap = new LuaMap<string, () => boolean>();
|
|
|
13
13
|
/**
|
|
14
14
|
* We backup some save data keys on every new room for the purposes of restoring it when Glowing
|
|
15
15
|
* Hour Glass is used.
|
|
16
|
+
*
|
|
17
|
+
* Note that the save data is backed up in serialized form so that we can use the `merge` function
|
|
18
|
+
* to restore it.
|
|
16
19
|
*/
|
|
17
20
|
export const saveDataGlowingHourGlassMap = new LuaMap<string, SaveData>();
|
|
@@ -59,23 +59,28 @@ export function merge(
|
|
|
59
59
|
|
|
60
60
|
// First, handle the special case of an array with a shallow copy.
|
|
61
61
|
if (isArray(oldObject) && isArray(newTable)) {
|
|
62
|
-
|
|
62
|
+
mergeSerializedArray(oldObject, newTable, traversalDescription);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// Depending on whether we are working on a Lua table or a TypeScriptToLua object, we need to
|
|
67
67
|
// iterate in a specific way.
|
|
68
68
|
if (isTSTLMap(oldObject) || isTSTLSet(oldObject) || isDefaultMap(oldObject)) {
|
|
69
|
-
|
|
69
|
+
mergeSerializedTSTLObject(oldObject, newTable, traversalDescription);
|
|
70
70
|
} else {
|
|
71
|
-
|
|
71
|
+
mergeSerializedTable(oldObject, newTable, traversalDescription);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
function
|
|
75
|
+
function mergeSerializedArray(
|
|
76
76
|
oldArray: LuaMap<AnyNotNil, unknown>,
|
|
77
77
|
newArray: LuaMap<AnyNotNil, unknown>,
|
|
78
|
+
traversalDescription: string,
|
|
78
79
|
) {
|
|
80
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
81
|
+
log(`merge encountered an array: ${traversalDescription}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
// Assume that we should blow away all array values with whatever is present in the incoming
|
|
80
85
|
// array.
|
|
81
86
|
clearTable(oldArray);
|
|
@@ -88,11 +93,15 @@ function mergeArray(
|
|
|
88
93
|
);
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
function
|
|
96
|
+
function mergeSerializedTSTLObject(
|
|
92
97
|
oldObject: Map<AnyNotNil, unknown> | Set<AnyNotNil>,
|
|
93
98
|
newTable: LuaMap<AnyNotNil, unknown>,
|
|
94
99
|
traversalDescription: string,
|
|
95
100
|
) {
|
|
101
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
102
|
+
log(`merge encountered a TSTL object: ${traversalDescription}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
// We blow away the old object and recursively copy over all of the incoming values.
|
|
97
106
|
oldObject.clear();
|
|
98
107
|
|
|
@@ -139,11 +148,15 @@ function mergeTSTLObject(
|
|
|
139
148
|
);
|
|
140
149
|
}
|
|
141
150
|
|
|
142
|
-
function
|
|
151
|
+
function mergeSerializedTable(
|
|
143
152
|
oldTable: LuaMap<AnyNotNil, unknown>,
|
|
144
153
|
newTable: LuaMap<AnyNotNil, unknown>,
|
|
145
154
|
traversalDescription: string,
|
|
146
155
|
) {
|
|
156
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
157
|
+
log(`merge encountered a Lua table: ${traversalDescription}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
147
160
|
iterateTableInOrder(
|
|
148
161
|
newTable,
|
|
149
162
|
(key, value) => {
|
package/src/functions/log.ts
CHANGED
|
@@ -365,9 +365,7 @@ export function logTable(luaTable: unknown, parentTables = 0): void {
|
|
|
365
365
|
// Put it in an IIFE so that it will show as "func" instead of "logTable" and align with the
|
|
366
366
|
// other text. We have to use a non-arrow function to prevent Lua language server errors with
|
|
367
367
|
// the self argument.
|
|
368
|
-
|
|
369
|
-
// eslint-disable-next-line func-names
|
|
370
|
-
(function () {
|
|
368
|
+
(function func() {
|
|
371
369
|
log(
|
|
372
370
|
`${indentation}n/a (encountered a variable of type "${typeof luaTable}" instead of a table)`,
|
|
373
371
|
);
|
|
@@ -397,9 +395,7 @@ export function logTable(luaTable: unknown, parentTables = 0): void {
|
|
|
397
395
|
// Put it in an IIFE so that it will show as "func" instead of "logTable" and align with the other
|
|
398
396
|
// text. We have to use a non-arrow function to prevent Lua language server errors with the self
|
|
399
397
|
// argument.
|
|
400
|
-
|
|
401
|
-
// eslint-disable-next-line func-names
|
|
402
|
-
(function () {
|
|
398
|
+
(function func() {
|
|
403
399
|
log(`${indentation}The size of the table was: ${numElements}`);
|
|
404
400
|
})();
|
|
405
401
|
}
|