isaacscript-common 24.1.1 → 25.0.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.
Files changed (52) hide show
  1. package/dist/isaacscript-common.lua +44 -52
  2. package/dist/src/arrays/cachedEnumValues.d.ts +1 -1
  3. package/dist/src/arrays/cachedEnumValues.d.ts.map +1 -1
  4. package/dist/src/arrays/cachedEnumValues.lua +1 -1
  5. package/dist/src/core/constantsFirstLast.d.ts.map +1 -1
  6. package/dist/src/core/constantsFirstLast.lua +8 -8
  7. package/dist/src/enums/{SerializationBrand.d.ts → private/SerializationBrand.d.ts} +0 -0
  8. package/dist/src/enums/private/SerializationBrand.d.ts.map +1 -0
  9. package/dist/src/enums/{SerializationBrand.lua → private/SerializationBrand.lua} +0 -0
  10. package/dist/src/functions/bitSet128.lua +1 -1
  11. package/dist/src/functions/color.lua +1 -1
  12. package/dist/src/functions/deepCopy.d.ts.map +1 -1
  13. package/dist/src/functions/deepCopy.lua +3 -2
  14. package/dist/src/functions/deepCopyTests.lua +1 -1
  15. package/dist/src/functions/enums.d.ts +1 -1
  16. package/dist/src/functions/enums.d.ts.map +1 -1
  17. package/dist/src/functions/enums.lua +1 -1
  18. package/dist/src/functions/kColor.lua +1 -1
  19. package/dist/src/functions/merge.d.ts.map +1 -1
  20. package/dist/src/functions/merge.lua +3 -2
  21. package/dist/src/functions/rng.lua +1 -1
  22. package/dist/src/functions/serialization.d.ts.map +1 -1
  23. package/dist/src/functions/serialization.lua +0 -20
  24. package/dist/src/functions/vector.lua +1 -1
  25. package/dist/src/index.d.ts +0 -1
  26. package/dist/src/index.d.ts.map +1 -1
  27. package/dist/src/index.lua +0 -8
  28. package/dist/src/objects/isaacAPIClassTypeToBrand.d.ts +1 -1
  29. package/dist/src/objects/isaacAPIClassTypeToBrand.d.ts.map +1 -1
  30. package/dist/src/objects/isaacAPIClassTypeToBrand.lua +1 -1
  31. package/dist/src/serialization.d.ts +9 -0
  32. package/dist/src/serialization.d.ts.map +1 -0
  33. package/dist/src/serialization.lua +22 -0
  34. package/package.json +1 -1
  35. package/src/arrays/cachedEnumValues.ts +1 -1
  36. package/src/core/constantsFirstLast.ts +9 -8
  37. package/src/enums/{SerializationBrand.ts → private/SerializationBrand.ts} +0 -0
  38. package/src/functions/bitSet128.ts +1 -1
  39. package/src/functions/color.ts +1 -1
  40. package/src/functions/deepCopy.ts +2 -2
  41. package/src/functions/deepCopyTests.ts +1 -1
  42. package/src/functions/enums.ts +1 -1
  43. package/src/functions/kColor.ts +1 -1
  44. package/src/functions/merge.ts +2 -2
  45. package/src/functions/rng.ts +1 -1
  46. package/src/functions/serialization.ts +1 -24
  47. package/src/functions/vector.ts +1 -1
  48. package/src/index.ts +0 -1
  49. package/src/objects/isaacAPIClassTypeToBrand.ts +1 -1
  50. package/src/serialization.ts +22 -0
  51. package/dist/index.rollup.d.ts +0 -15715
  52. package/dist/src/enums/SerializationBrand.d.ts.map +0 -1
@@ -135,14 +135,6 @@ do
135
135
  end
136
136
  end
137
137
  end
138
- do
139
- local ____export = require("src.enums.SerializationBrand")
140
- for ____exportKey, ____exportValue in pairs(____export) do
141
- if ____exportKey ~= "default" then
142
- ____exports[____exportKey] = ____exportValue
143
- end
144
- end
145
- end
146
138
  do
147
139
  local ____export = require("src.enums.SerializationType")
148
140
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -1,4 +1,4 @@
1
- import { SerializationBrand } from "../enums/SerializationBrand";
1
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
2
2
  export declare const ISAAC_API_CLASS_TYPE_TO_BRAND: {
3
3
  readonly BitSet128: SerializationBrand.BIT_SET_128;
4
4
  readonly Color: SerializationBrand.COLOR;
@@ -1 +1 @@
1
- {"version":3,"file":"isaacAPIClassTypeToBrand.d.ts","sourceRoot":"","sources":["../../../src/objects/isaacAPIClassTypeToBrand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,eAAO,MAAM,6BAA6B;;;;;;CAMgC,CAAC"}
1
+ {"version":3,"file":"isaacAPIClassTypeToBrand.d.ts","sourceRoot":"","sources":["../../../src/objects/isaacAPIClassTypeToBrand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,eAAO,MAAM,6BAA6B;;;;;;CAMgC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local CopyableIsaacAPIClassType = ____isaac_2Dtypescript_2Ddefinitions.CopyableIsaacAPIClassType
4
- local ____SerializationBrand = require("src.enums.SerializationBrand")
4
+ local ____SerializationBrand = require("src.enums.private.SerializationBrand")
5
5
  local SerializationBrand = ____SerializationBrand.SerializationBrand
6
6
  ____exports.ISAAC_API_CLASS_TYPE_TO_BRAND = {
7
7
  [CopyableIsaacAPIClassType.BIT_SET_128] = SerializationBrand.BIT_SET_128,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Helper function to check if a key of a table in the "save#.dat" file is a serialization brand
3
+ * inserted by the save data manager (i.e. the `deepCopy` function).
4
+ *
5
+ * This is separated from the other serialization functions because end-users would not normally be
6
+ * iterating through a serialized object directly.
7
+ */
8
+ export declare function isSerializationBrand(key: unknown): boolean;
9
+ //# sourceMappingURL=serialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/serialization.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAM1D"}
@@ -0,0 +1,22 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__New = ____lualib.__TS__New
3
+ local ____exports = {}
4
+ local ____cachedEnumValues = require("src.arrays.cachedEnumValues")
5
+ local SERIALIZATION_BRAND_VALUES = ____cachedEnumValues.SERIALIZATION_BRAND_VALUES
6
+ local ____types = require("src.functions.types")
7
+ local isString = ____types.isString
8
+ local ____ReadonlySet = require("src.types.ReadonlySet")
9
+ local ReadonlySet = ____ReadonlySet.ReadonlySet
10
+ local SERIALIZATION_BRAND_SET = __TS__New(ReadonlySet, SERIALIZATION_BRAND_VALUES)
11
+ --- Helper function to check if a key of a table in the "save#.dat" file is a serialization brand
12
+ -- inserted by the save data manager (i.e. the `deepCopy` function).
13
+ --
14
+ -- This is separated from the other serialization functions because end-users would not normally be
15
+ -- iterating through a serialized object directly.
16
+ function ____exports.isSerializationBrand(self, key)
17
+ if not isString(nil, key) then
18
+ return false
19
+ end
20
+ return SERIALIZATION_BRAND_SET:has(key)
21
+ end
22
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "24.1.1",
3
+ "version": "25.0.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -20,7 +20,7 @@ import {
20
20
  TrinketSlot,
21
21
  } from "isaac-typescript-definitions";
22
22
  import { HealthType } from "../enums/HealthType";
23
- import { SerializationBrand } from "../enums/SerializationBrand";
23
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
24
24
  import { StatType } from "../enums/StatType";
25
25
  import { getEnumValues } from "../functions/enums";
26
26
 
@@ -10,7 +10,7 @@ import {
10
10
  RoomType,
11
11
  TrinketType,
12
12
  } from "isaac-typescript-definitions";
13
- import { getEnumLength, getLastEnumValue } from "../functions/enums";
13
+ import { getEnumLength, getHighestEnumValue } from "../functions/enums";
14
14
  import { iRange } from "../functions/utils";
15
15
 
16
16
  // ------------
@@ -26,7 +26,8 @@ export const FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION;
26
26
  * Note that this cannot be calculated from the length of the enum, because unlike all of the other
27
27
  * enums, collectible types are not contiguous.
28
28
  */
29
- export const LAST_VANILLA_COLLECTIBLE_TYPE = getLastEnumValue(CollectibleType);
29
+ export const LAST_VANILLA_COLLECTIBLE_TYPE =
30
+ getHighestEnumValue(CollectibleType);
30
31
 
31
32
  /** Calculated from the `CollectibleType` enum. (`CollectibleType.NULL` is not included.) */
32
33
  export const NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(CollectibleType) - 1;
@@ -39,7 +40,7 @@ export const NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(CollectibleType) - 1;
39
40
  export const FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY;
40
41
 
41
42
  /** Calculated from the `TrinketType` enum. */
42
- export const LAST_VANILLA_TRINKET_TYPE = getLastEnumValue(TrinketType);
43
+ export const LAST_VANILLA_TRINKET_TYPE = getHighestEnumValue(TrinketType);
43
44
 
44
45
  /** Calculated from the `TrinketType` enum. (`TrinketType.NULL` is not included.) */
45
46
  export const NUM_VANILLA_TRINKET_TYPES = getEnumLength(TrinketType) - 1;
@@ -52,7 +53,7 @@ export const NUM_VANILLA_TRINKET_TYPES = getEnumLength(TrinketType) - 1;
52
53
  export const FIRST_CARD_TYPE = CardType.FOOL;
53
54
 
54
55
  /** Calculated from the `Card` enum. */
55
- export const LAST_VANILLA_CARD_TYPE = getLastEnumValue(CardType);
56
+ export const LAST_VANILLA_CARD_TYPE = getHighestEnumValue(CardType);
56
57
 
57
58
  /** Calculated from the `Card` enum. `Card.NULL` is not included. */
58
59
  export const NUM_VANILLA_CARD_TYPES = getEnumLength(CardType) - 1;
@@ -65,7 +66,7 @@ export const NUM_VANILLA_CARD_TYPES = getEnumLength(CardType) - 1;
65
66
  export const FIRST_PILL_EFFECT = PillEffect.BAD_GAS;
66
67
 
67
68
  /** Calculated from the `PillEffect` enum. */
68
- export const LAST_VANILLA_PILL_EFFECT = getLastEnumValue(PillEffect);
69
+ export const LAST_VANILLA_PILL_EFFECT = getHighestEnumValue(PillEffect);
69
70
 
70
71
  /**
71
72
  * Calculated from the `PillEffect` enum. (There is no `PillEffect.NULL` in the custom enum, so we
@@ -114,18 +115,18 @@ export const FIRST_CHARACTER = PlayerType.ISAAC;
114
115
  // It is not possible to determine "LAST_PLAYER_TYPE", since there is no associated config.
115
116
 
116
117
  /** Calculated from the `PlayerType` enum. */
117
- export const LAST_VANILLA_CHARACTER = getLastEnumValue(PlayerType);
118
+ export const LAST_VANILLA_CHARACTER = getHighestEnumValue(PlayerType);
118
119
 
119
120
  // ----------
120
121
  // Room Types
121
122
  // ----------
122
123
 
123
124
  export const FIRST_ROOM_TYPE = RoomType.DEFAULT;
124
- export const LAST_ROOM_TYPE = getLastEnumValue(RoomType);
125
+ export const LAST_ROOM_TYPE = getHighestEnumValue(RoomType);
125
126
 
126
127
  // ------
127
128
  // Stages
128
129
  // ------
129
130
 
130
131
  export const FIRST_STAGE = LevelStage.BASEMENT_1;
131
- export const LAST_STAGE = getLastEnumValue(LevelStage);
132
+ export const LAST_STAGE = getHighestEnumValue(LevelStage);
@@ -1,5 +1,5 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
- import { SerializationBrand } from "../enums/SerializationBrand";
2
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { isIsaacAPIClassOfType } from "./isaacAPIClass";
4
4
  import {
5
5
  copyUserdataValuesToTable,
@@ -1,5 +1,5 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
- import { SerializationBrand } from "../enums/SerializationBrand";
2
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
4
4
  import { getRandom } from "./random";
5
5
  import { getRandomSeed, isRNG, newRNG } from "./rng";
@@ -1,7 +1,8 @@
1
1
  import { DefaultMap } from "../classes/DefaultMap";
2
2
  import { SAVE_DATA_MANAGER_DEBUG } from "../classes/features/other/saveDataManager/constants";
3
- import { SerializationBrand } from "../enums/SerializationBrand";
3
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
4
4
  import { SerializationType } from "../enums/SerializationType";
5
+ import { isSerializationBrand } from "../serialization";
5
6
  import { AnyClass } from "../types/AnyClass";
6
7
  import { TSTLClass } from "../types/TSTLClass";
7
8
  import { isArray } from "./array";
@@ -11,7 +12,6 @@ import {
11
12
  copyIsaacAPIClass,
12
13
  deserializeIsaacAPIClass,
13
14
  isCopyableIsaacAPIClass,
14
- isSerializationBrand,
15
15
  isSerializedIsaacAPIClass,
16
16
  serializeIsaacAPIClass,
17
17
  } from "./serialization";
@@ -1,5 +1,5 @@
1
1
  import { DefaultMap } from "../classes/DefaultMap";
2
- import { SerializationBrand } from "../enums/SerializationBrand";
2
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { SerializationType } from "../enums/SerializationType";
4
4
  import { arrayEquals } from "./array";
5
5
  import { deepCopy } from "./deepCopy";
@@ -97,7 +97,7 @@ export function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]> {
97
97
  * Note that this is not necessarily the enum value that is declared last, since there is no way to
98
98
  * infer that at run-time.
99
99
  */
100
- export function getLastEnumValue<T>(transpiledEnum: T): T[keyof T] {
100
+ export function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T] {
101
101
  const enumValues = getEnumValues(transpiledEnum);
102
102
 
103
103
  const lastElement = enumValues[enumValues.length - 1];
@@ -1,5 +1,5 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
- import { SerializationBrand } from "../enums/SerializationBrand";
2
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
4
4
  import { getRandom } from "./random";
5
5
  import { getRandomSeed, isRNG, newRNG } from "./rng";
@@ -1,13 +1,13 @@
1
1
  import { SAVE_DATA_MANAGER_DEBUG } from "../classes/features/other/saveDataManager/constants";
2
- import { SerializationBrand } from "../enums/SerializationBrand";
2
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { SerializationType } from "../enums/SerializationType";
4
+ import { isSerializationBrand } from "../serialization";
4
5
  import { AnyClass } from "../types/AnyClass";
5
6
  import { isArray } from "./array";
6
7
  import { deepCopy } from "./deepCopy";
7
8
  import { log } from "./log";
8
9
  import {
9
10
  deserializeIsaacAPIClass,
10
- isSerializationBrand,
11
11
  isSerializedIsaacAPIClass,
12
12
  } from "./serialization";
13
13
  import { clearTable, iterateTableInOrder } from "./table";
@@ -1,6 +1,6 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
2
  import { game } from "../core/cachedClasses";
3
- import { SerializationBrand } from "../enums/SerializationBrand";
3
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
4
4
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
5
5
  import { getNumbersFromTable, tableHasKeys } from "./table";
6
6
  import { isTable } from "./types";
@@ -1,5 +1,4 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
- import { SERIALIZATION_BRAND_VALUES } from "../arrays/cachedEnumValues";
3
2
  import { ISAAC_API_CLASS_TYPE_TO_BRAND } from "../objects/isaacAPIClassTypeToBrand";
4
3
  import {
5
4
  CopyableIsaacAPIClass,
@@ -9,13 +8,8 @@ import {
9
8
  ISAAC_API_CLASS_TYPE_TO_FUNCTIONS,
10
9
  SerializedIsaacAPIClass,
11
10
  } from "../objects/isaacAPIClassTypeToFunctions";
12
- import { ReadonlySet } from "../types/ReadonlySet";
13
11
  import { getIsaacAPIClassName } from "./isaacAPIClass";
14
- import { isString, isTable, isUserdata } from "./types";
15
-
16
- const SERIALIZATION_BRAND_SET = new ReadonlySet<string>(
17
- SERIALIZATION_BRAND_VALUES,
18
- );
12
+ import { isTable, isUserdata } from "./types";
19
13
 
20
14
  /**
21
15
  * Helper function to generically copy an Isaac API class without knowing what specific type of
@@ -142,23 +136,6 @@ export function isCopyableIsaacAPIClass(
142
136
  return isFunctions.some((identityFunction) => identityFunction(object));
143
137
  }
144
138
 
145
- /**
146
- * Helper function to check if a key of a table in the "save#.dat" file is a serialization brand
147
- * inserted by the save data manager (i.e. the `deepCopy` function).
148
- *
149
- * This is marked internal because end-users would not normally be iterating through a serialized
150
- * object directly.
151
- *
152
- * @internal
153
- */
154
- export function isSerializationBrand(key: unknown): boolean {
155
- if (!isString(key)) {
156
- return false;
157
- }
158
-
159
- return SERIALIZATION_BRAND_SET.has(key);
160
- }
161
-
162
139
  /**
163
140
  * Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
164
141
  * is used by the save data manager when reading data from the "save#.dat" file.)
@@ -2,7 +2,7 @@ import {
2
2
  CopyableIsaacAPIClassType,
3
3
  Direction,
4
4
  } from "isaac-typescript-definitions";
5
- import { SerializationBrand } from "../enums/SerializationBrand";
5
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
6
6
  import { angleToDirection } from "./direction";
7
7
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
8
8
  import { getRandomFloat } from "./random";
package/src/index.ts CHANGED
@@ -15,7 +15,6 @@ export * from "./enums/MysteriousPaperEffect";
15
15
  export * from "./enums/PocketItemType";
16
16
  export * from "./enums/RockAltType";
17
17
  export * from "./enums/SaveDataKey";
18
- export * from "./enums/SerializationBrand";
19
18
  export * from "./enums/SerializationType";
20
19
  export * from "./enums/SlotDestructionType";
21
20
  export * from "./enums/StatType";
@@ -1,5 +1,5 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
- import { SerializationBrand } from "../enums/SerializationBrand";
2
+ import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
 
4
4
  export const ISAAC_API_CLASS_TYPE_TO_BRAND = {
5
5
  [CopyableIsaacAPIClassType.BIT_SET_128]: SerializationBrand.BIT_SET_128,
@@ -0,0 +1,22 @@
1
+ import { SERIALIZATION_BRAND_VALUES } from "./arrays/cachedEnumValues";
2
+ import { isString } from "./functions/types";
3
+ import { ReadonlySet } from "./types/ReadonlySet";
4
+
5
+ const SERIALIZATION_BRAND_SET = new ReadonlySet<string>(
6
+ SERIALIZATION_BRAND_VALUES,
7
+ );
8
+
9
+ /**
10
+ * Helper function to check if a key of a table in the "save#.dat" file is a serialization brand
11
+ * inserted by the save data manager (i.e. the `deepCopy` function).
12
+ *
13
+ * This is separated from the other serialization functions because end-users would not normally be
14
+ * iterating through a serialized object directly.
15
+ */
16
+ export function isSerializationBrand(key: unknown): boolean {
17
+ if (!isString(key)) {
18
+ return false;
19
+ }
20
+
21
+ return SERIALIZATION_BRAND_SET.has(key);
22
+ }