isaacscript-common 20.6.1 → 20.7.1

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/index.d.ts CHANGED
@@ -7971,6 +7971,9 @@ export declare function isTransformationFlying(playerForm: PlayerForm): boolean;
7971
7971
  /** For `PickupVariant.TRINKET` (350). */
7972
7972
  export declare function isTrinket(pickup: EntityPickup): pickup is EntityPickupTrinket;
7973
7973
 
7974
+ /** Helper function to check if a given table is a class table created by TypeScriptToLua. */
7975
+ export declare function isTSTLClass(object: unknown): object is TSTLClass;
7976
+
7974
7977
  /**
7975
7978
  * Helper function to determine if a given object is a TypeScriptToLua `Map`.
7976
7979
  *
@@ -7991,9 +7994,6 @@ export declare function isTSTLSet(object: unknown): object is Set<AnyNotNil>;
7991
7994
 
7992
7995
  export declare function isUserdata(variable: unknown): variable is LuaUserdata;
7993
7996
 
7994
- /** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
7995
- export declare function isUserDefinedTSTLClass(object: unknown): object is TSTLClass;
7996
-
7997
7997
  export declare function isValidCollectibleType(collectibleType: CollectibleType): boolean;
7998
7998
 
7999
7999
  /**
@@ -13518,7 +13518,8 @@ declare class SaveDataManager extends Feature {
13518
13518
  *
13519
13519
  * @param key The name of the file or feature that is submitting data to be managed by the save
13520
13520
  * data manager. The save data manager will throw an error if the key is already
13521
- * registered.
13521
+ * registered. Note that you can also pass a TSTL class instead of a string and the
13522
+ * save data manager will use the name of the class as the key.
13522
13523
  * @param v An object that corresponds to the `SaveData` interface. The object is conventionally
13523
13524
  * called "v" for brevity. ("v" is short for "local variables").
13524
13525
  * @param conditionalFunc Optional. A function to run to check if this save data should be written
@@ -13531,10 +13532,8 @@ declare class SaveDataManager extends Feature {
13531
13532
  * data. (Specifying `false` will allow you to use non-serializable objects
13532
13533
  * in your save data, such as `EntityPtr`.
13533
13534
  */
13534
- saveDataManager<Persistent, Run, Level>(key: string, // This is the overload for the standard case with serializable data.
13535
- v: SaveData<Persistent, Run, Level>, conditionalFunc?: () => boolean): void;
13536
- saveDataManager(key: string, // This is the overload for the case when saving data is disabled.
13537
- v: SaveData, conditionalFunc: false): void;
13535
+ saveDataManager<Persistent, Run, Level>(key: string | object, v: SaveData<Persistent, Run, Level>, conditionalFunc?: () => boolean): void;
13536
+ saveDataManager(key: string | object, v: SaveData, conditionalFunc: false): void;
13538
13537
  /**
13539
13538
  * Recursively traverses an object, collecting all of the class constructors that it encounters.
13540
13539
  */
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 20.6.1
3
+ isaacscript-common 20.7.1
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -20541,6 +20541,10 @@ function ____exports.isDefaultMap(self, object)
20541
20541
  local className = ____exports.getTSTLClassName(nil, object)
20542
20542
  return className == "DefaultMap"
20543
20543
  end
20544
+ function ____exports.isTSTLClass(self, object)
20545
+ local tstlClassName = ____exports.getTSTLClassName(nil, object)
20546
+ return tstlClassName ~= nil
20547
+ end
20544
20548
  function ____exports.isTSTLMap(self, object)
20545
20549
  local className = ____exports.getTSTLClassName(nil, object)
20546
20550
  return className == "Map"
@@ -20549,10 +20553,6 @@ function ____exports.isTSTLSet(self, object)
20549
20553
  local className = ____exports.getTSTLClassName(nil, object)
20550
20554
  return className == "Set"
20551
20555
  end
20552
- function ____exports.isUserDefinedTSTLClass(self, object)
20553
- local tstlClassName = ____exports.getTSTLClassName(nil, object)
20554
- return tstlClassName ~= nil
20555
- end
20556
20556
  function ____exports.newTSTLClass(self, oldClass)
20557
20557
  local constructor = ____exports.getTSTLClassConstructor(nil, oldClass)
20558
20558
  if constructor == nil then
@@ -36834,6 +36834,7 @@ local ____stage = require("src.functions.stage")
36834
36834
  local onFirstFloor = ____stage.onFirstFloor
36835
36835
  local ____tstlClass = require("src.functions.tstlClass")
36836
36836
  local getTSTLClassName = ____tstlClass.getTSTLClassName
36837
+ local isTSTLClass = ____tstlClass.isTSTLClass
36837
36838
  local ____types = require("src.functions.types")
36838
36839
  local isString = ____types.isString
36839
36840
  local isTable = ____types.isTable
@@ -36911,8 +36912,15 @@ function SaveDataManager.prototype.____constructor(self, mod)
36911
36912
  self.mod = mod
36912
36913
  end
36913
36914
  function SaveDataManager.prototype.saveDataManager(self, key, v, conditionalFunc)
36915
+ if isTSTLClass(nil, key) then
36916
+ local className = getTSTLClassName(nil, key)
36917
+ if className == nil then
36918
+ error("Failed to get the class name for the submitted class (as part of the \"key\" parameter) when registering new data with the save data manager.")
36919
+ end
36920
+ key = className
36921
+ end
36914
36922
  if not isString(nil, key) then
36915
- error("The save data manager requires that keys are strings. You tried to use a key of type: " .. __TS__TypeOf(key))
36923
+ error("The save data manager requires that keys are strings or TSTL classes. You tried to use a key of type: " .. __TS__TypeOf(key))
36916
36924
  end
36917
36925
  if self.saveDataMap[key] ~= nil then
36918
36926
  error("The save data manager is already managing save data for a key of: " .. key)
@@ -130,7 +130,8 @@ export declare class SaveDataManager extends Feature {
130
130
  *
131
131
  * @param key The name of the file or feature that is submitting data to be managed by the save
132
132
  * data manager. The save data manager will throw an error if the key is already
133
- * registered.
133
+ * registered. Note that you can also pass a TSTL class instead of a string and the
134
+ * save data manager will use the name of the class as the key.
134
135
  * @param v An object that corresponds to the `SaveData` interface. The object is conventionally
135
136
  * called "v" for brevity. ("v" is short for "local variables").
136
137
  * @param conditionalFunc Optional. A function to run to check if this save data should be written
@@ -143,10 +144,8 @@ export declare class SaveDataManager extends Feature {
143
144
  * data. (Specifying `false` will allow you to use non-serializable objects
144
145
  * in your save data, such as `EntityPtr`.
145
146
  */
146
- saveDataManager<Persistent, Run, Level>(key: string, // This is the overload for the standard case with serializable data.
147
- v: SaveData<Persistent, Run, Level>, conditionalFunc?: () => boolean): void;
148
- saveDataManager(key: string, // This is the overload for the case when saving data is disabled.
149
- v: SaveData, conditionalFunc: false): void;
147
+ saveDataManager<Persistent, Run, Level>(key: string | object, v: SaveData<Persistent, Run, Level>, conditionalFunc?: () => boolean): void;
148
+ saveDataManager(key: string | object, v: SaveData, conditionalFunc: false): void;
150
149
  /**
151
150
  * Recursively traverses an object, collecting all of the class constructors that it encounters.
152
151
  */
@@ -1 +1 @@
1
- {"version":3,"file":"SaveDataManager.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/SaveDataManager.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAMzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAsBhD,qBAAa,eAAgB,SAAQ,OAAO;IAC1C;;;OAGG;IACH,OAAO,CAAC,GAAG,CAAM;IAEjB;;;;OAIG;IACH,OAAO,CAAC,WAAW,CAAkC;IAErD;;;OAGG;IACH,OAAO,CAAC,mBAAmB,CAAkC;IAE7D;;;OAGG;IACH,OAAO,CAAC,0BAA0B,CAAuC;IAEzE;;;;;;OAMG;IACH,OAAO,CAAC,2BAA2B,CAAkC;IAErE;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAkC;IAG3D,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,qCAAqC,CAAS;IAiCtD,OAAO,CAAC,2BAA2B,CAUjC;IAGF,OAAO,CAAC,cAAc,CA0BpB;IAGF,OAAO,CAAC,WAAW,CAajB;IAGF,OAAO,CAAC,YAAY,CAYlB;IAGF,OAAO,CAAC,gBAAgB,CAuBtB;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkGG;IACI,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EAC3C,GAAG,EAAE,MAAM,EAAE,qEAAqE;IAClF,CAAC,EAAE,QAAQ,C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AsB3E;;;;;;;;;;;;OAYG;IAEI,qBAAqB,IAAI,OAAO;CAGxC"}
@@ -26,6 +26,7 @@ local ____stage = require("src.functions.stage")
26
26
  local onFirstFloor = ____stage.onFirstFloor
27
27
  local ____tstlClass = require("src.functions.tstlClass")
28
28
  local getTSTLClassName = ____tstlClass.getTSTLClassName
29
+ local isTSTLClass = ____tstlClass.isTSTLClass
29
30
  local ____types = require("src.functions.types")
30
31
  local isString = ____types.isString
31
32
  local isTable = ____types.isTable
@@ -103,8 +104,15 @@ function SaveDataManager.prototype.____constructor(self, mod)
103
104
  self.mod = mod
104
105
  end
105
106
  function SaveDataManager.prototype.saveDataManager(self, key, v, conditionalFunc)
107
+ if isTSTLClass(nil, key) then
108
+ local className = getTSTLClassName(nil, key)
109
+ if className == nil then
110
+ error("Failed to get the class name for the submitted class (as part of the \"key\" parameter) when registering new data with the save data manager.")
111
+ end
112
+ key = className
113
+ end
106
114
  if not isString(nil, key) then
107
- error("The save data manager requires that keys are strings. You tried to use a key of type: " .. __TS__TypeOf(key))
115
+ error("The save data manager requires that keys are strings or TSTL classes. You tried to use a key of type: " .. __TS__TypeOf(key))
108
116
  end
109
117
  if self.saveDataMap[key] ~= nil then
110
118
  error("The save data manager is already managing save data for a key of: " .. key)
@@ -27,6 +27,8 @@ export declare function getTSTLClassName(object: unknown): string | undefined;
27
27
  * their own copies of the entire lualib and thus their own instantiated version of a `Map`.
28
28
  */
29
29
  export declare function isDefaultMap(object: unknown): object is DefaultMap<AnyNotNil, unknown>;
30
+ /** Helper function to check if a given table is a class table created by TypeScriptToLua. */
31
+ export declare function isTSTLClass(object: unknown): object is TSTLClass;
30
32
  /**
31
33
  * Helper function to determine if a given object is a TypeScriptToLua `Map`.
32
34
  *
@@ -43,8 +45,6 @@ export declare function isTSTLMap(object: unknown): object is Map<AnyNotNil, unk
43
45
  * `Set`.
44
46
  */
45
47
  export declare function isTSTLSet(object: unknown): object is Set<AnyNotNil>;
46
- /** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
47
- export declare function isUserDefinedTSTLClass(object: unknown): object is TSTLClass;
48
48
  /**
49
49
  * Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
50
50
  * it is. This function requires that you provide an instantiated class of the same type, as it will
@@ -1 +1 @@
1
- {"version":3,"file":"tstlClass.d.ts","sourceRoot":"","sources":["../../../src/functions/tstlClass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,GACd,kBAAkB,CAAC,aAAa,CAAC,GAAG,SAAS,CAW/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAG1C;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAG5E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAGnE;AAED,kGAAkG;AAClG,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,SAAS,CAG3E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAiB3D"}
1
+ {"version":3,"file":"tstlClass.d.ts","sourceRoot":"","sources":["../../../src/functions/tstlClass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,GACd,kBAAkB,CAAC,aAAa,CAAC,GAAG,SAAS,CAW/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAG1C;AAED,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,SAAS,CAGhE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAG5E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAiB3D"}
@@ -38,6 +38,11 @@ function ____exports.isDefaultMap(self, object)
38
38
  local className = ____exports.getTSTLClassName(nil, object)
39
39
  return className == "DefaultMap"
40
40
  end
41
+ --- Helper function to check if a given table is a class table created by TypeScriptToLua.
42
+ function ____exports.isTSTLClass(self, object)
43
+ local tstlClassName = ____exports.getTSTLClassName(nil, object)
44
+ return tstlClassName ~= nil
45
+ end
41
46
  --- Helper function to determine if a given object is a TypeScriptToLua `Map`.
42
47
  --
43
48
  -- It is not reliable to use the `instanceof` operator to determine this because each Lua module
@@ -56,11 +61,6 @@ function ____exports.isTSTLSet(self, object)
56
61
  local className = ____exports.getTSTLClassName(nil, object)
57
62
  return className == "Set"
58
63
  end
59
- --- TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys.
60
- function ____exports.isUserDefinedTSTLClass(self, object)
61
- local tstlClassName = ____exports.getTSTLClassName(nil, object)
62
- return tstlClassName ~= nil
63
- end
64
64
  --- Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
65
65
  -- it is. This function requires that you provide an instantiated class of the same type, as it will
66
66
  -- use the class constructor that is present on the other object's metatable to initialize the new
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "20.6.1",
3
+ "version": "20.7.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -11,7 +11,7 @@ import { SaveDataKey } from "../../../enums/SaveDataKey";
11
11
  import { SerializationType } from "../../../enums/SerializationType";
12
12
  import { deepCopy } from "../../../functions/deepCopy";
13
13
  import { onFirstFloor } from "../../../functions/stage";
14
- import { getTSTLClassName } from "../../../functions/tstlClass";
14
+ import { getTSTLClassName, isTSTLClass } from "../../../functions/tstlClass";
15
15
  import { isString, isTable } from "../../../functions/types";
16
16
  import { SaveData } from "../../../interfaces/SaveData";
17
17
  import { AnyClass } from "../../../types/AnyClass";
@@ -297,7 +297,8 @@ export class SaveDataManager extends Feature {
297
297
  *
298
298
  * @param key The name of the file or feature that is submitting data to be managed by the save
299
299
  * data manager. The save data manager will throw an error if the key is already
300
- * registered.
300
+ * registered. Note that you can also pass a TSTL class instead of a string and the
301
+ * save data manager will use the name of the class as the key.
301
302
  * @param v An object that corresponds to the `SaveData` interface. The object is conventionally
302
303
  * called "v" for brevity. ("v" is short for "local variables").
303
304
  * @param conditionalFunc Optional. A function to run to check if this save data should be written
@@ -310,25 +311,38 @@ export class SaveDataManager extends Feature {
310
311
  * data. (Specifying `false` will allow you to use non-serializable objects
311
312
  * in your save data, such as `EntityPtr`.
312
313
  */
314
+ // This is the overload for the standard case with serializable data.
313
315
  public saveDataManager<Persistent, Run, Level>(
314
- key: string, // This is the overload for the standard case with serializable data.
316
+ key: string | object,
315
317
  v: SaveData<Persistent, Run, Level>,
316
318
  conditionalFunc?: () => boolean,
317
319
  ): void;
320
+ // This is the overload for the case when saving data is disabled.
318
321
  public saveDataManager(
319
- key: string, // This is the overload for the case when saving data is disabled.
322
+ key: string | object,
320
323
  v: SaveData,
321
324
  conditionalFunc: false,
322
325
  ): void;
323
326
  @Exported
324
327
  public saveDataManager<Persistent, Run, Level>(
325
- key: string,
328
+ key: string | object,
326
329
  v: SaveData<Persistent, Run, Level>,
327
330
  conditionalFunc?: (() => boolean) | false,
328
331
  ): void {
332
+ if (isTSTLClass(key)) {
333
+ const className = getTSTLClassName(key);
334
+ if (className === undefined) {
335
+ error(
336
+ 'Failed to get the class name for the submitted class (as part of the "key" parameter) when registering new data with the save data manager.',
337
+ );
338
+ }
339
+
340
+ key = className;
341
+ }
342
+
329
343
  if (!isString(key)) {
330
344
  error(
331
- `The save data manager requires that keys are strings. You tried to use a key of type: ${typeof key}`,
345
+ `The save data manager requires that keys are strings or TSTL classes. You tried to use a key of type: ${typeof key}`,
332
346
  );
333
347
  }
334
348
 
@@ -56,6 +56,12 @@ export function isDefaultMap(
56
56
  return className === "DefaultMap";
57
57
  }
58
58
 
59
+ /** Helper function to check if a given table is a class table created by TypeScriptToLua. */
60
+ export function isTSTLClass(object: unknown): object is TSTLClass {
61
+ const tstlClassName = getTSTLClassName(object);
62
+ return tstlClassName !== undefined;
63
+ }
64
+
59
65
  /**
60
66
  * Helper function to determine if a given object is a TypeScriptToLua `Map`.
61
67
  *
@@ -80,12 +86,6 @@ export function isTSTLSet(object: unknown): object is Set<AnyNotNil> {
80
86
  return className === "Set";
81
87
  }
82
88
 
83
- /** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
84
- export function isUserDefinedTSTLClass(object: unknown): object is TSTLClass {
85
- const tstlClassName = getTSTLClassName(object);
86
- return tstlClassName !== undefined;
87
- }
88
-
89
89
  /**
90
90
  * Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
91
91
  * it is. This function requires that you provide an instantiated class of the same type, as it will