isaacscript-common 14.1.1 → 14.1.2

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
@@ -2651,7 +2651,6 @@ declare class Feature {
2651
2651
  featuresUsed?: ISCFeature[];
2652
2652
  callbacksUsed?: CallbackTuple[];
2653
2653
  customCallbacksUsed?: CustomCallbackTuple[];
2654
- exportedMethods: string[];
2655
2654
  }
2656
2655
 
2657
2656
  export declare function fillLevelWithRedRooms(): void;
@@ -5911,8 +5910,6 @@ export declare function getTrinketTypes(): TrinketType[];
5911
5910
  */
5912
5911
  export declare function getTSTLClassConstructor(object: unknown): TSTLClassMetatable["constructor"] | undefined;
5913
5912
 
5914
- export declare function getTSTLClassMethods(object: unknown): FunctionTuple[];
5915
-
5916
5913
  /**
5917
5914
  * Helper function to get the name of a TypeScriptToLua class from the instantiated class object.
5918
5915
  *
@@ -9520,8 +9517,8 @@ export declare class ModUpgraded implements Mod {
9520
9517
  */
9521
9518
  RemoveCallbackCustom<T extends ModCallbackCustom2>(modCallbackCustom: T, callback: AddCallbackParametersCustom2[T][0]): void;
9522
9519
  /**
9523
- * This method should only be used by the `upgradeMod` function. Returns the class methods from
9524
- * the features that were added.
9520
+ * This method should only be used by the `upgradeMod` function. Returns the names of the exported
9521
+ * class methods from the features that were added.
9525
9522
  */
9526
9523
  initOptionalFeature(feature: ISCFeature): FunctionTuple[];
9527
9524
  /** This is used to initialize both custom callbacks and "extra features". */
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 14.1.1
3
+ isaacscript-common 14.1.2
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -16939,18 +16939,12 @@ return ____exports
16939
16939
  end,
16940
16940
  ["src.interfaces.TSTLClassMetatable"] = function(...)
16941
16941
  local ____exports = {}
16942
- return ____exports
16943
- end,
16944
- ["src.types.FunctionTuple"] = function(...)
16945
- local ____exports = {}
16946
16942
  return ____exports
16947
16943
  end,
16948
16944
  ["src.functions.tstlClass"] = function(...)
16949
16945
  local ____lualib = require("lualib_bundle")
16950
16946
  local Set = ____lualib.Set
16951
16947
  local __TS__New = ____lualib.__TS__New
16952
- local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
16953
- local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
16954
16948
  local ____exports = {}
16955
16949
  local VANILLA_TSTL_CLASSES
16956
16950
  local ____types = require("src.functions.types")
@@ -16982,23 +16976,6 @@ function ____exports.isVanillaTSTLClass(self, object)
16982
16976
  end
16983
16977
  VANILLA_TSTL_CLASSES = __TS__New(Set, {"Map", "Set", "WeakMap", "WeakSet"})
16984
16978
  local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
16985
- function ____exports.getTSTLClassMethods(self, object)
16986
- local constructor = ____exports.getTSTLClassConstructor(nil, object)
16987
- if constructor == nil then
16988
- return {}
16989
- end
16990
- local classEntries = __TS__ObjectEntries(constructor.prototype)
16991
- return __TS__ArrayFilter(
16992
- classEntries,
16993
- function(____, ____bindingPattern0)
16994
- local value
16995
- local key
16996
- key = ____bindingPattern0[1]
16997
- value = ____bindingPattern0[2]
16998
- return not TSTL_CLASS_METATABLE_KEYS:has(key) and type(value) == "function"
16999
- end
17000
- )
17001
- end
17002
16979
  function ____exports.isDefaultMap(self, object)
17003
16980
  local className = ____exports.getTSTLClassName(nil, object)
17004
16981
  return className == "DefaultMap"
@@ -27124,7 +27101,6 @@ local Feature = ____exports.Feature
27124
27101
  Feature.name = "Feature"
27125
27102
  function Feature.prototype.____constructor(self)
27126
27103
  self.initialized = false
27127
- self.exportedMethods = {}
27128
27104
  end
27129
27105
  return ____exports
27130
27106
  end,
@@ -30763,9 +30739,7 @@ return ____exports
30763
30739
  end,
30764
30740
  ["src.callbacks"] = function(...)
30765
30741
  local ____lualib = require("lualib_bundle")
30766
- local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
30767
30742
  local __TS__New = ____lualib.__TS__New
30768
- local __TS__ArrayMap = ____lualib.__TS__ArrayMap
30769
30743
  local ____exports = {}
30770
30744
  local ____PostAmbushFinished = require("src.classes.callbacks.PostAmbushFinished")
30771
30745
  local PostAmbushFinished = ____PostAmbushFinished.PostAmbushFinished
@@ -30867,6 +30841,8 @@ local ____PreCustomRevive = require("src.classes.callbacks.PreCustomRevive")
30867
30841
  local PreCustomRevive = ____PreCustomRevive.PreCustomRevive
30868
30842
  local ____ModCallbackCustom2 = require("src.enums.ModCallbackCustom2")
30869
30843
  local ModCallbackCustom2 = ____ModCallbackCustom2.ModCallbackCustom2
30844
+ local ____enums = require("src.functions.enums")
30845
+ local getEnumValues = ____enums.getEnumValues
30870
30846
  local ____utils = require("src.functions.utils")
30871
30847
  local newObjectWithEnumKeys = ____utils.newObjectWithEnumKeys
30872
30848
  local MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(nil, ModCallbackCustom2, {
@@ -30921,28 +30897,26 @@ local MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(nil, ModCallbackCusto
30921
30897
  [ModCallbackCustom2.PRE_CUSTOM_REVIVE] = PreCustomRevive
30922
30898
  })
30923
30899
  function ____exports.getCallbacks(self)
30924
- local entries = __TS__ObjectEntries(MOD_CALLBACK_CUSTOM_TO_CLASS)
30925
- local instantiatedClasses = __TS__ArrayMap(
30926
- entries,
30927
- function(____, ____bindingPattern0)
30928
- local constructor
30929
- local modCallbackCustom
30930
- modCallbackCustom = ____bindingPattern0[1]
30931
- constructor = ____bindingPattern0[2]
30932
- return {
30933
- modCallbackCustom,
30934
- __TS__New(constructor)
30935
- }
30936
- end
30937
- )
30900
+ local instantiatedClasses = {}
30901
+ for ____, modCallbackCustom in ipairs(getEnumValues(nil, ModCallbackCustom2)) do
30902
+ local constructor = MOD_CALLBACK_CUSTOM_TO_CLASS[modCallbackCustom]
30903
+ instantiatedClasses[modCallbackCustom] = __TS__New(constructor)
30904
+ end
30938
30905
  return instantiatedClasses
30939
30906
  end
30940
30907
  return ____exports
30941
30908
  end,
30942
30909
  ["src.decorators"] = function(...)
30943
30910
  local ____exports = {}
30911
+ ____exports.EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames"
30944
30912
  function ____exports.Exported(self)
30945
- return function(____, _target, _propertyKey)
30913
+ return function(____, target, propertyKey)
30914
+ local constructor = target.constructor
30915
+ if not (constructor[____exports.EXPORTED_METHOD_NAMES_KEY] ~= nil) then
30916
+ constructor[____exports.EXPORTED_METHOD_NAMES_KEY] = {}
30917
+ end
30918
+ local exportedMethodNames = constructor[____exports.EXPORTED_METHOD_NAMES_KEY]
30919
+ exportedMethodNames[#exportedMethodNames + 1] = propertyKey
30946
30920
  end
30947
30921
  end
30948
30922
  return ____exports
@@ -34847,17 +34821,25 @@ ____exports.CALLBACK_REGISTER_FUNCTIONS = {
34847
34821
  [ModCallbackCustom.PRE_ITEM_PICKUP] = preItemPickupRegister,
34848
34822
  [ModCallbackCustom.PRE_NEW_LEVEL] = preNewLevelRegister
34849
34823
  }
34824
+ return ____exports
34825
+ end,
34826
+ ["src.types.FunctionTuple"] = function(...)
34827
+ local ____exports = {}
34850
34828
  return ____exports
34851
34829
  end,
34852
34830
  ["src.classes.ModUpgraded"] = function(...)
34853
34831
  local ____lualib = require("lualib_bundle")
34854
34832
  local __TS__Class = ____lualib.__TS__Class
34855
34833
  local __TS__Spread = ____lualib.__TS__Spread
34834
+ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
34856
34835
  local ____exports = {}
34836
+ local getExportedMethodsFromFeature
34857
34837
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
34858
34838
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
34859
34839
  local ____callbacks = require("src.callbacks")
34860
34840
  local getCallbacks = ____callbacks.getCallbacks
34841
+ local ____decorators = require("src.decorators")
34842
+ local EXPORTED_METHOD_NAMES_KEY = ____decorators.EXPORTED_METHOD_NAMES_KEY
34861
34843
  local ____features = require("src.features")
34862
34844
  local getFeatures = ____features.getFeatures
34863
34845
  local ____exports = require("src.features.saveDataManager.exports")
@@ -34868,10 +34850,28 @@ local getTime = ____debugFunctions.getTime
34868
34850
  local ____log = require("src.functions.log")
34869
34851
  local getParentFunctionDescription = ____log.getParentFunctionDescription
34870
34852
  local ____tstlClass = require("src.functions.tstlClass")
34871
- local getTSTLClassMethods = ____tstlClass.getTSTLClassMethods
34853
+ local getTSTLClassConstructor = ____tstlClass.getTSTLClassConstructor
34872
34854
  local getTSTLClassName = ____tstlClass.getTSTLClassName
34873
34855
  local ____callbackRegisterFunctions = require("src.objects.callbackRegisterFunctions")
34874
34856
  local CALLBACK_REGISTER_FUNCTIONS = ____callbackRegisterFunctions.CALLBACK_REGISTER_FUNCTIONS
34857
+ function getExportedMethodsFromFeature(self, featureClass)
34858
+ local constructor = getTSTLClassConstructor(nil, featureClass)
34859
+ local exportedMethodNames = constructor[EXPORTED_METHOD_NAMES_KEY]
34860
+ return __TS__ArrayMap(
34861
+ exportedMethodNames,
34862
+ function(____, name)
34863
+ local featureClassRecord = featureClass
34864
+ local method = featureClassRecord[name]
34865
+ if method == nil then
34866
+ error("Failed to find a decorated exported method: " .. name)
34867
+ end
34868
+ local function wrappedMethod(____, ...)
34869
+ return featureClassRecord[name](featureClassRecord, ...)
34870
+ end
34871
+ return {name, wrappedMethod}
34872
+ end
34873
+ )
34874
+ end
34875
34875
  ____exports.ModUpgraded = __TS__Class()
34876
34876
  local ModUpgraded = ____exports.ModUpgraded
34877
34877
  ModUpgraded.name = "ModUpgraded"
@@ -34950,7 +34950,7 @@ end
34950
34950
  function ModUpgraded.prototype.initOptionalFeature(self, feature)
34951
34951
  local featureClass = self.features[feature]
34952
34952
  self:initFeature(featureClass)
34953
- return getTSTLClassMethods(nil, featureClass)
34953
+ return getExportedMethodsFromFeature(nil, featureClass)
34954
34954
  end
34955
34955
  function ModUpgraded.prototype.initFeature(self, feature)
34956
34956
  if feature.initialized then
@@ -46715,9 +46715,9 @@ function ____exports.upgradeMod(self, modVanilla, features, ____debug, timeThres
46715
46715
  loadShaderCrashFix(nil, modVanilla)
46716
46716
  legacyInit(nil, mod)
46717
46717
  for ____, feature in ipairs(features) do
46718
- local tstlClassMethods = mod:initOptionalFeature(feature)
46718
+ local exportedMethodTuples = mod:initOptionalFeature(feature)
46719
46719
  local modRecord = mod
46720
- for ____, ____value in ipairs(tstlClassMethods) do
46720
+ for ____, ____value in ipairs(exportedMethodTuples) do
46721
46721
  local funcName = ____value[1]
46722
46722
  local func = ____value[2]
46723
46723
  modRecord[funcName] = func
@@ -99,7 +99,7 @@ declare const MOD_CALLBACK_CUSTOM_TO_CLASS: {
99
99
  readonly 48: typeof PreCustomRevive;
100
100
  };
101
101
  export declare type ModCallbackCustomToClass = {
102
- [Property in keyof typeof MOD_CALLBACK_CUSTOM_TO_CLASS]: InstanceType<typeof MOD_CALLBACK_CUSTOM_TO_CLASS[Property]>;
102
+ readonly [key in keyof typeof MOD_CALLBACK_CUSTOM_TO_CLASS]: InstanceType<typeof MOD_CALLBACK_CUSTOM_TO_CLASS[key]>;
103
103
  };
104
104
  export declare function getCallbacks(): ModCallbackCustomToClass;
105
105
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../../src/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CA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AE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAKtE,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DvB,CAAC;AAEZ,oBAAY,wBAAwB,GAAG;IACrC,QAAQ,EAAE,GAAG,IAAI,MAAM,OAAO,4BAA4B,GAAG,YAAY,CACvE,OAAO,4BAA4B,CAAC,GAAG,CAAC,CACzC;CACF,CAAC;AAEF,wBAAgB,YAAY,IAAI,wBAAwB,CASvD"}
@@ -1,7 +1,5 @@
1
1
  local ____lualib = require("lualib_bundle")
2
- local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
3
2
  local __TS__New = ____lualib.__TS__New
4
- local __TS__ArrayMap = ____lualib.__TS__ArrayMap
5
3
  local ____exports = {}
6
4
  local ____PostAmbushFinished = require("src.classes.callbacks.PostAmbushFinished")
7
5
  local PostAmbushFinished = ____PostAmbushFinished.PostAmbushFinished
@@ -103,6 +101,8 @@ local ____PreCustomRevive = require("src.classes.callbacks.PreCustomRevive")
103
101
  local PreCustomRevive = ____PreCustomRevive.PreCustomRevive
104
102
  local ____ModCallbackCustom2 = require("src.enums.ModCallbackCustom2")
105
103
  local ModCallbackCustom2 = ____ModCallbackCustom2.ModCallbackCustom2
104
+ local ____enums = require("src.functions.enums")
105
+ local getEnumValues = ____enums.getEnumValues
106
106
  local ____utils = require("src.functions.utils")
107
107
  local newObjectWithEnumKeys = ____utils.newObjectWithEnumKeys
108
108
  local MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(nil, ModCallbackCustom2, {
@@ -157,20 +157,11 @@ local MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(nil, ModCallbackCusto
157
157
  [ModCallbackCustom2.PRE_CUSTOM_REVIVE] = PreCustomRevive
158
158
  })
159
159
  function ____exports.getCallbacks(self)
160
- local entries = __TS__ObjectEntries(MOD_CALLBACK_CUSTOM_TO_CLASS)
161
- local instantiatedClasses = __TS__ArrayMap(
162
- entries,
163
- function(____, ____bindingPattern0)
164
- local constructor
165
- local modCallbackCustom
166
- modCallbackCustom = ____bindingPattern0[1]
167
- constructor = ____bindingPattern0[2]
168
- return {
169
- modCallbackCustom,
170
- __TS__New(constructor)
171
- }
172
- end
173
- )
160
+ local instantiatedClasses = {}
161
+ for ____, modCallbackCustom in ipairs(getEnumValues(nil, ModCallbackCustom2)) do
162
+ local constructor = MOD_CALLBACK_CUSTOM_TO_CLASS[modCallbackCustom]
163
+ instantiatedClasses[modCallbackCustom] = __TS__New(constructor)
164
+ end
174
165
  return instantiatedClasses
175
166
  end
176
167
  return ____exports
@@ -66,8 +66,8 @@ export declare class ModUpgraded implements Mod {
66
66
  */
67
67
  RemoveCallbackCustom<T extends ModCallbackCustom2>(modCallbackCustom: T, callback: AddCallbackParametersCustom2[T][0]): void;
68
68
  /**
69
- * This method should only be used by the `upgradeMod` function. Returns the class methods from
70
- * the features that were added.
69
+ * This method should only be used by the `upgradeMod` function. Returns the names of the exported
70
+ * class methods from the features that were added.
71
71
  */
72
72
  initOptionalFeature(feature: ISCFeature): FunctionTuple[];
73
73
  /** This is used to initialize both custom callbacks and "extra features". */
@@ -1 +1 @@
1
- {"version":3,"file":"ModUpgraded.d.ts","sourceRoot":"","sources":["../../../src/classes/ModUpgraded.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAA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IAkDP,0FAA0F;IACnF,OAAO,IAAI,OAAO;IAIzB;;;OAGG;IACI,QAAQ,IAAI,MAAM;IAIzB;;;;;OAKG;IACI,cAAc,CAAC,CAAC,SAAS,WAAW,EACzC,WAAW,EAAE,CAAC,EACd,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACpC,IAAI;IAIP,6EAA6E;IACtE,UAAU,IAAI,IAAI;IAIzB;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQnC;;;;OAIG;IAEI,iBAAiB,CAAC,CAAC,SAAS,iBAAiB,EAClD,iBAAiB,EAAE,CAAC,EACpB,GAAG,IAAI,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACtC,IAAI;IAMP,wFAAwF;IACjF,kBAAkB,CAAC,CAAC,SAAS,kBAAkB,EACpD,iBAAiB,EAAE,CAAC,EACpB,GAAG,IAAI,EAAE,4BAA4B,CAAC,CAAC,CAAC,GACvC,IAAI;IAOP;;;;;OAKG;IACI,oBAAoB,CAAC,CAAC,SAAS,kBAAkB,EACtD,iBAAiB,EAAE,CAAC,EACpB,QAAQ,EAAE,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC3C,IAAI;IASP;;;OAGG;IACI,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,aAAa,EAAE;IAWhE,6EAA6E;IAC7E,OAAO,CAAC,WAAW;IAoCnB,OAAO,CAAC,aAAa;CAqCtB"}
@@ -1,11 +1,15 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__Spread = ____lualib.__TS__Spread
4
+ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
4
5
  local ____exports = {}
6
+ local getExportedMethodsFromFeature
5
7
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
8
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
7
9
  local ____callbacks = require("src.callbacks")
8
10
  local getCallbacks = ____callbacks.getCallbacks
11
+ local ____decorators = require("src.decorators")
12
+ local EXPORTED_METHOD_NAMES_KEY = ____decorators.EXPORTED_METHOD_NAMES_KEY
9
13
  local ____features = require("src.features")
10
14
  local getFeatures = ____features.getFeatures
11
15
  local ____exports = require("src.features.saveDataManager.exports")
@@ -16,10 +20,28 @@ local getTime = ____debugFunctions.getTime
16
20
  local ____log = require("src.functions.log")
17
21
  local getParentFunctionDescription = ____log.getParentFunctionDescription
18
22
  local ____tstlClass = require("src.functions.tstlClass")
19
- local getTSTLClassMethods = ____tstlClass.getTSTLClassMethods
23
+ local getTSTLClassConstructor = ____tstlClass.getTSTLClassConstructor
20
24
  local getTSTLClassName = ____tstlClass.getTSTLClassName
21
25
  local ____callbackRegisterFunctions = require("src.objects.callbackRegisterFunctions")
22
26
  local CALLBACK_REGISTER_FUNCTIONS = ____callbackRegisterFunctions.CALLBACK_REGISTER_FUNCTIONS
27
+ function getExportedMethodsFromFeature(self, featureClass)
28
+ local constructor = getTSTLClassConstructor(nil, featureClass)
29
+ local exportedMethodNames = constructor[EXPORTED_METHOD_NAMES_KEY]
30
+ return __TS__ArrayMap(
31
+ exportedMethodNames,
32
+ function(____, name)
33
+ local featureClassRecord = featureClass
34
+ local method = featureClassRecord[name]
35
+ if method == nil then
36
+ error("Failed to find a decorated exported method: " .. name)
37
+ end
38
+ local function wrappedMethod(____, ...)
39
+ return featureClassRecord[name](featureClassRecord, ...)
40
+ end
41
+ return {name, wrappedMethod}
42
+ end
43
+ )
44
+ end
23
45
  --- `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
24
46
  -- hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
25
47
  -- extends the base class and adds a new method of `AddCallbackCustom`.
@@ -105,7 +127,7 @@ end
105
127
  function ModUpgraded.prototype.initOptionalFeature(self, feature)
106
128
  local featureClass = self.features[feature]
107
129
  self:initFeature(featureClass)
108
- return getTSTLClassMethods(nil, featureClass)
130
+ return getExportedMethodsFromFeature(nil, featureClass)
109
131
  end
110
132
  function ModUpgraded.prototype.initFeature(self, feature)
111
133
  if feature.initialized then
@@ -14,6 +14,5 @@ export declare class Feature {
14
14
  featuresUsed?: ISCFeature[];
15
15
  callbacksUsed?: CallbackTuple[];
16
16
  customCallbacksUsed?: CustomCallbackTuple[];
17
- exportedMethods: string[];
18
17
  }
19
18
  //# sourceMappingURL=Feature.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Feature.d.ts","sourceRoot":"","sources":["../../../../src/classes/private/Feature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,aAAa,EACb,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;GAMG;AACH,qBAAa,OAAO;IACX,WAAW,UAAS;IAEpB,CAAC,CAAC,EAAE,QAAQ,CAAC;IACb,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAE5C,eAAe,EAAE,MAAM,EAAE,CAAM;CACvC"}
1
+ {"version":3,"file":"Feature.d.ts","sourceRoot":"","sources":["../../../../src/classes/private/Feature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,aAAa,EACb,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;GAMG;AACH,qBAAa,OAAO;IACX,WAAW,UAAS;IAEpB,CAAC,CAAC,EAAE,QAAQ,CAAC;IACb,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACpD"}
@@ -11,6 +11,5 @@ local Feature = ____exports.Feature
11
11
  Feature.name = "Feature"
12
12
  function Feature.prototype.____constructor(self)
13
13
  self.initialized = false
14
- self.exportedMethods = {}
15
14
  end
16
15
  return ____exports
@@ -82,9 +82,9 @@ function ____exports.upgradeMod(self, modVanilla, features, ____debug, timeThres
82
82
  loadShaderCrashFix(nil, modVanilla)
83
83
  legacyInit(nil, mod)
84
84
  for ____, feature in ipairs(features) do
85
- local tstlClassMethods = mod:initOptionalFeature(feature)
85
+ local exportedMethodTuples = mod:initOptionalFeature(feature)
86
86
  local modRecord = mod
87
- for ____, ____value in ipairs(tstlClassMethods) do
87
+ for ____, ____value in ipairs(exportedMethodTuples) do
88
88
  local funcName = ____value[1]
89
89
  local func = ____value[2]
90
90
  modRecord[funcName] = func
@@ -1,9 +1,10 @@
1
1
  import { Feature } from "./classes/private/Feature";
2
+ export declare const EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames";
2
3
  /**
3
4
  * A decorator function that signifies that the decorated class method should be added to the
4
5
  * `ModUpgraded` object.
5
6
  *
6
7
  * This is only meant to be used internally.
7
8
  */
8
- export declare function Exported(): <T extends Feature>(_target: T, _propertyKey: keyof T) => void;
9
+ export declare function Exported(): <T extends Feature>(target: T, propertyKey: keyof T) => void;
9
10
  //# sourceMappingURL=decorators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,QAAQ,8DACyC,IAAI,CAGpE"}
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,eAAO,MAAM,yBAAyB,0BAA0B,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,QAAQ,4DACuC,IAAI,CAgBlE"}
@@ -1,10 +1,17 @@
1
1
  local ____exports = {}
2
+ ____exports.EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames"
2
3
  --- A decorator function that signifies that the decorated class method should be added to the
3
4
  -- `ModUpgraded` object.
4
5
  --
5
6
  -- This is only meant to be used internally.
6
7
  function ____exports.Exported(self)
7
- return function(____, _target, _propertyKey)
8
+ return function(____, target, propertyKey)
9
+ local constructor = target.constructor
10
+ if not (constructor[____exports.EXPORTED_METHOD_NAMES_KEY] ~= nil) then
11
+ constructor[____exports.EXPORTED_METHOD_NAMES_KEY] = {}
12
+ end
13
+ local exportedMethodNames = constructor[____exports.EXPORTED_METHOD_NAMES_KEY]
14
+ exportedMethodNames[#exportedMethodNames + 1] = propertyKey
8
15
  end
9
16
  end
10
17
  return ____exports
@@ -1,7 +1,6 @@
1
1
  /// <reference types="@typescript-to-lua/language-extensions" />
2
2
  import { DefaultMap } from "../classes/DefaultMap";
3
3
  import { TSTLClassMetatable } from "../interfaces/TSTLClassMetatable";
4
- import { FunctionTuple } from "../types/FunctionTuple";
5
4
  import { TSTLClass } from "../types/TSTLClass";
6
5
  /**
7
6
  * Helper function to get the constructor from an instantiated TypeScriptToLua class, which is
@@ -10,7 +9,6 @@ import { TSTLClass } from "../types/TSTLClass";
10
9
  * Returns undefined if passed a non-table or if the provided table does not have a metatable.
11
10
  */
12
11
  export declare function getTSTLClassConstructor(object: unknown): TSTLClassMetatable["constructor"] | undefined;
13
- export declare function getTSTLClassMethods(object: unknown): FunctionTuple[];
14
12
  /**
15
13
  * Helper function to get the name of a TypeScriptToLua class from the instantiated class object.
16
14
  *
@@ -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,kB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nD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAW/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;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEjE;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,CA4B3E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAO3D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAiB3D"}
@@ -1,8 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
- local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
5
- local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
4
  local ____exports = {}
7
5
  local VANILLA_TSTL_CLASSES
8
6
  local ____types = require("src.functions.types")
@@ -48,23 +46,6 @@ function ____exports.isVanillaTSTLClass(self, object)
48
46
  end
49
47
  VANILLA_TSTL_CLASSES = __TS__New(Set, {"Map", "Set", "WeakMap", "WeakSet"})
50
48
  local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
51
- function ____exports.getTSTLClassMethods(self, object)
52
- local constructor = ____exports.getTSTLClassConstructor(nil, object)
53
- if constructor == nil then
54
- return {}
55
- end
56
- local classEntries = __TS__ObjectEntries(constructor.prototype)
57
- return __TS__ArrayFilter(
58
- classEntries,
59
- function(____, ____bindingPattern0)
60
- local value
61
- local key
62
- key = ____bindingPattern0[1]
63
- value = ____bindingPattern0[2]
64
- return not TSTL_CLASS_METATABLE_KEYS:has(key) and type(value) == "function"
65
- end
66
- )
67
- end
68
49
  --- Helper function to determine if a given object is a TypeScriptToLua `Map`.
69
50
  --
70
51
  -- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
@@ -1 +1 @@
1
- {"version":3,"file":"TSTLClassMetatable.d.ts","sourceRoot":"","sources":["../../../src/interfaces/TSTLClassMetatable.ts"],"names":[],"mappings":";;;;AAAA,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;KACrD,CAAC;CACH"}
1
+ {"version":3,"file":"TSTLClassMetatable.d.ts","sourceRoot":"","sources":["../../../src/interfaces/TSTLClassMetatable.ts"],"names":[],"mappings":";;;;AAAA,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;KAErD,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "14.1.1",
3
+ "version": "14.1.2",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
package/src/callbacks.ts CHANGED
@@ -48,6 +48,7 @@ import { PostSpikesRender } from "./classes/callbacks/PostSpikesRender";
48
48
  import { PreBerserkDeath } from "./classes/callbacks/PreBerserkDeath";
49
49
  import { PreCustomRevive } from "./classes/callbacks/PreCustomRevive";
50
50
  import { ModCallbackCustom2 } from "./enums/ModCallbackCustom2";
51
+ import { getEnumValues } from "./functions/enums";
51
52
  import { newObjectWithEnumKeys } from "./functions/utils";
52
53
 
53
54
  const MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(ModCallbackCustom2, {
@@ -116,19 +117,18 @@ const MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(ModCallbackCustom2, {
116
117
  } as const);
117
118
 
118
119
  export type ModCallbackCustomToClass = {
119
- [Property in keyof typeof MOD_CALLBACK_CUSTOM_TO_CLASS]: InstanceType<
120
- typeof MOD_CALLBACK_CUSTOM_TO_CLASS[Property]
120
+ readonly [key in keyof typeof MOD_CALLBACK_CUSTOM_TO_CLASS]: InstanceType<
121
+ typeof MOD_CALLBACK_CUSTOM_TO_CLASS[key]
121
122
  >;
122
123
  };
123
124
 
124
125
  export function getCallbacks(): ModCallbackCustomToClass {
125
- const entries = Object.entries(MOD_CALLBACK_CUSTOM_TO_CLASS);
126
- const instantiatedClasses = entries.map(
127
- ([modCallbackCustom, constructor]) => [
128
- modCallbackCustom,
129
- new constructor(),
130
- ],
131
- );
126
+ const instantiatedClasses: Record<number, unknown> = {};
127
+
128
+ for (const modCallbackCustom of getEnumValues(ModCallbackCustom2)) {
129
+ const constructor = MOD_CALLBACK_CUSTOM_TO_CLASS[modCallbackCustom];
130
+ instantiatedClasses[modCallbackCustom] = new constructor();
131
+ }
132
132
 
133
133
  return instantiatedClasses as unknown as ModCallbackCustomToClass;
134
134
  }
@@ -1,5 +1,6 @@
1
1
  import { ModCallback } from "isaac-typescript-definitions";
2
2
  import { getCallbacks } from "../callbacks";
3
+ import { EXPORTED_METHOD_NAMES_KEY } from "../decorators";
3
4
  import { ISCFeature } from "../enums/ISCFeature";
4
5
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
5
6
  import { ModCallbackCustom2 } from "../enums/ModCallbackCustom2";
@@ -10,7 +11,10 @@ import {
10
11
  } from "../features/saveDataManager/exports";
11
12
  import { getTime } from "../functions/debugFunctions";
12
13
  import { getParentFunctionDescription } from "../functions/log";
13
- import { getTSTLClassMethods, getTSTLClassName } from "../functions/tstlClass";
14
+ import {
15
+ getTSTLClassConstructor,
16
+ getTSTLClassName,
17
+ } from "../functions/tstlClass";
14
18
  import { AddCallbackParametersCustom } from "../interfaces/private/AddCallbackParametersCustom";
15
19
  import { AddCallbackParametersCustom2 } from "../interfaces/private/AddCallbackParametersCustom2";
16
20
  import { CALLBACK_REGISTER_FUNCTIONS } from "../objects/callbackRegisterFunctions";
@@ -213,14 +217,14 @@ export class ModUpgraded implements Mod {
213
217
  }
214
218
 
215
219
  /**
216
- * This method should only be used by the `upgradeMod` function. Returns the class methods from
217
- * the features that were added.
220
+ * This method should only be used by the `upgradeMod` function. Returns the names of the exported
221
+ * class methods from the features that were added.
218
222
  */
219
223
  public initOptionalFeature(feature: ISCFeature): FunctionTuple[] {
220
224
  const featureClass = this.features[feature];
221
225
  this.initFeature(featureClass);
222
226
 
223
- return getTSTLClassMethods(featureClass);
227
+ return getExportedMethodsFromFeature(featureClass);
224
228
  }
225
229
 
226
230
  // ----------------------
@@ -302,3 +306,41 @@ export class ModUpgraded implements Mod {
302
306
  }
303
307
  }
304
308
  }
309
+
310
+ /**
311
+ * In this context, "exported" methods are methods that are annotated with the "@Exported"
312
+ * decorator, which signify that the method should be attached to the `ModUpgraded` class.
313
+ *
314
+ * Exported methods are stored in an internal static array on the class that is created by the
315
+ * decorator.
316
+ */
317
+ function getExportedMethodsFromFeature(featureClass: unknown): FunctionTuple[] {
318
+ const constructor = getTSTLClassConstructor(featureClass) as Record<
319
+ string,
320
+ unknown
321
+ >;
322
+ const exportedMethodNames = constructor[
323
+ EXPORTED_METHOD_NAMES_KEY
324
+ ] as string[];
325
+
326
+ return exportedMethodNames.map((name) => {
327
+ const featureClassRecord = featureClass as Record<
328
+ string,
329
+ (...args: unknown[]) => unknown
330
+ >;
331
+ const method = featureClassRecord[name];
332
+ if (method === undefined) {
333
+ error(`Failed to find a decorated exported method: ${name}`);
334
+ }
335
+
336
+ // In order for "this" to work properly in the method, we have to wrap the method invocation in
337
+ // an arrow function.
338
+ const wrappedMethod = (...args: unknown[]) =>
339
+ // We cannot split out the method to a separate variable or else the "self" parameter will not
340
+ // be properly passed to the method.
341
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
342
+ featureClassRecord[name]!(...args);
343
+
344
+ return [name, wrappedMethod];
345
+ });
346
+ }
@@ -19,6 +19,4 @@ export class Feature {
19
19
  public featuresUsed?: ISCFeature[];
20
20
  public callbacksUsed?: CallbackTuple[];
21
21
  public customCallbacksUsed?: CustomCallbackTuple[];
22
-
23
- public exportedMethods: string[] = [];
24
22
  }
@@ -83,7 +83,7 @@ export function upgradeMod<T extends ISCFeature = never>(
83
83
  legacyInit(mod); // TODO: remove
84
84
 
85
85
  for (const feature of features) {
86
- const tstlClassMethods = mod.initOptionalFeature(feature);
86
+ const exportedMethodTuples = mod.initOptionalFeature(feature);
87
87
 
88
88
  // If the optional feature provides helper functions, attach them to the base mod object. (This
89
89
  // provides a convenient API for end-users.)
@@ -91,7 +91,7 @@ export function upgradeMod<T extends ISCFeature = never>(
91
91
  string,
92
92
  (...args: unknown[]) => unknown
93
93
  >;
94
- for (const [funcName, func] of tstlClassMethods) {
94
+ for (const [funcName, func] of exportedMethodTuples) {
95
95
  modRecord[funcName] = func;
96
96
  }
97
97
  }
package/src/decorators.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Feature } from "./classes/private/Feature";
2
2
 
3
+ export const EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames";
4
+
3
5
  /**
4
6
  * A decorator function that signifies that the decorated class method should be added to the
5
7
  * `ModUpgraded` object.
@@ -7,7 +9,20 @@ import { Feature } from "./classes/private/Feature";
7
9
  * This is only meant to be used internally.
8
10
  */
9
11
  export function Exported() {
10
- return <T extends Feature>(_target: T, _propertyKey: keyof T): void => {
11
- // target.exportedMethods.push(propertyKey as string);
12
+ return <T extends Feature>(target: T, propertyKey: keyof T): void => {
13
+ // Since the decorator runs prior to instantiation, we only have access to get and set static
14
+ // properties, which are located on the "constructor" table.
15
+ const constructor = target.constructor as unknown as LuaTable<
16
+ AnyNotNil,
17
+ unknown
18
+ >;
19
+ if (!constructor.has(EXPORTED_METHOD_NAMES_KEY)) {
20
+ constructor.set(EXPORTED_METHOD_NAMES_KEY, []);
21
+ }
22
+
23
+ const exportedMethodNames = constructor.get(
24
+ EXPORTED_METHOD_NAMES_KEY,
25
+ ) as string[];
26
+ exportedMethodNames.push(propertyKey as string);
12
27
  };
13
28
  }
@@ -1,6 +1,5 @@
1
1
  import { DefaultMap } from "../classes/DefaultMap";
2
2
  import { TSTLClassMetatable } from "../interfaces/TSTLClassMetatable";
3
- import { FunctionTuple } from "../types/FunctionTuple";
4
3
  import { TSTLClass } from "../types/TSTLClass";
5
4
  import { isString, isTable } from "./types";
6
5
 
@@ -33,20 +32,6 @@ export function getTSTLClassConstructor(
33
32
  return metatable.constructor;
34
33
  }
35
34
 
36
- export function getTSTLClassMethods(object: unknown): FunctionTuple[] {
37
- const constructor = getTSTLClassConstructor(object);
38
- if (constructor === undefined) {
39
- return [];
40
- }
41
-
42
- const classEntries = Object.entries(constructor.prototype);
43
- return classEntries.filter(
44
- ([key, value]) =>
45
- // Ignore the stock TSTL keys that are baked into every class.
46
- !TSTL_CLASS_METATABLE_KEYS.has(key) && type(value) === "function",
47
- );
48
- }
49
-
50
35
  /**
51
36
  * Helper function to get the name of a TypeScriptToLua class from the instantiated class object.
52
37
  *
@@ -4,5 +4,6 @@ export interface TSTLClassMetatable {
4
4
  constructor: {
5
5
  name: string;
6
6
  prototype: LuaMetatable<LuaMap<AnyNotNil, unknown>>;
7
+ // Other static things on the class will be here, if any.
7
8
  };
8
9
  }