isaacscript-common 25.2.0 → 25.3.0
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.rollup.d.ts +16 -0
- package/dist/isaacscript-common.lua +25 -10
- package/dist/src/classes/ModFeature.d.ts.map +1 -1
- package/dist/src/classes/ModFeature.lua +12 -5
- package/dist/src/functions/decorators.d.ts +15 -0
- package/dist/src/functions/decorators.d.ts.map +1 -1
- package/dist/src/functions/decorators.lua +21 -5
- package/package.json +1 -1
- package/src/classes/ModFeature.ts +16 -4
- package/src/functions/decorators.ts +45 -4
package/dist/index.rollup.d.ts
CHANGED
|
@@ -12737,6 +12737,22 @@ declare class PreventGridEntityRespawn extends Feature {
|
|
|
12737
12737
|
/** Helper function to print whether something was enabled or disabled to the in-game console. */
|
|
12738
12738
|
export declare function printEnabled(enabled: boolean, description: string): void;
|
|
12739
12739
|
|
|
12740
|
+
/**
|
|
12741
|
+
* A decorator function that signifies that the decorated class method should be automatically
|
|
12742
|
+
* registered with `Mod.AddPriorityCallback`.
|
|
12743
|
+
*
|
|
12744
|
+
* @ignore
|
|
12745
|
+
*/
|
|
12746
|
+
export declare function PriorityCallback<T extends ModCallback>(modCallback: T, priority: CallbackPriority | int, ...optionalArgs: AllButFirst<AddCallbackParameters[T]>): <Class extends ModFeature, Fn extends AddCallbackParameters[T][0]>(target: Class, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void;
|
|
12747
|
+
|
|
12748
|
+
/**
|
|
12749
|
+
* A decorator function that signifies that the decorated class method should be automatically
|
|
12750
|
+
* registered with `ModUpgraded.AddCallbackCustom`.
|
|
12751
|
+
*
|
|
12752
|
+
* @ignore
|
|
12753
|
+
*/
|
|
12754
|
+
export declare function PriorityCallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, priority: CallbackPriority | int, ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): <Class extends ModFeature, Fn extends AddCallbackParametersCustom[T][0]>(target: Class, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void;
|
|
12755
|
+
|
|
12740
12756
|
/** Helper type to extract only the public interface of a class. */
|
|
12741
12757
|
export declare type PublicInterface<T> = Pick<T, keyof T>;
|
|
12742
12758
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 25.
|
|
3
|
+
isaacscript-common 25.3.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -50554,11 +50554,15 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
50554
50554
|
if not isNumber(nil, modCallback) then
|
|
50555
50555
|
error("Failed to get the callback number from the callback tuple for class: " .. tstlClassName)
|
|
50556
50556
|
end
|
|
50557
|
-
local
|
|
50557
|
+
local priority = callbackTuple[2]
|
|
50558
|
+
if not isNumber(nil, priority) then
|
|
50559
|
+
error("Failed to get the callback priority from the callback tuple for class: " .. tstlClassName)
|
|
50560
|
+
end
|
|
50561
|
+
local callback = callbackTuple[3]
|
|
50558
50562
|
if not isFunction(nil, callback) then
|
|
50559
50563
|
error("Failed to get the callback function from the callback tuple for class: " .. tstlClassName)
|
|
50560
50564
|
end
|
|
50561
|
-
local parameters = callbackTuple[
|
|
50565
|
+
local parameters = callbackTuple[4]
|
|
50562
50566
|
if not isArray(nil, parameters, false) then
|
|
50563
50567
|
error("Failed to get the callback parameters from the callback tuple for class: " .. tstlClassName)
|
|
50564
50568
|
end
|
|
@@ -50570,6 +50574,7 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
50570
50574
|
modFeatureConstructor,
|
|
50571
50575
|
mod,
|
|
50572
50576
|
modCallback,
|
|
50577
|
+
priority,
|
|
50573
50578
|
callback,
|
|
50574
50579
|
parameters,
|
|
50575
50580
|
vanilla
|
|
@@ -50585,7 +50590,7 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
50585
50590
|
end
|
|
50586
50591
|
end
|
|
50587
50592
|
end
|
|
50588
|
-
function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback, callback, parameters, vanilla)
|
|
50593
|
+
function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback, priority, callback, parameters, vanilla)
|
|
50589
50594
|
local function wrappedCallback(____, ...)
|
|
50590
50595
|
local conditionalFunc = modFeature.shouldCallbackMethodsFire
|
|
50591
50596
|
if conditionalFunc ~= nil then
|
|
@@ -50615,14 +50620,16 @@ function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback,
|
|
|
50615
50620
|
wrappedMethodsMap:set(modCallbackCustom, wrappedCallback)
|
|
50616
50621
|
end
|
|
50617
50622
|
if vanilla then
|
|
50618
|
-
mod:
|
|
50623
|
+
mod:AddPriorityCallback(
|
|
50619
50624
|
modCallback,
|
|
50625
|
+
priority,
|
|
50620
50626
|
wrappedCallback,
|
|
50621
50627
|
table.unpack(parameters)
|
|
50622
50628
|
)
|
|
50623
50629
|
else
|
|
50624
|
-
mod:
|
|
50630
|
+
mod:AddPriorityCallbackCustom(
|
|
50625
50631
|
modCallback,
|
|
50632
|
+
priority,
|
|
50626
50633
|
wrappedCallback,
|
|
50627
50634
|
table.unpack(parameters)
|
|
50628
50635
|
)
|
|
@@ -51093,17 +51100,19 @@ return ____exports
|
|
|
51093
51100
|
end,
|
|
51094
51101
|
["src.functions.decorators"] = function(...)
|
|
51095
51102
|
local ____exports = {}
|
|
51103
|
+
local ____CallbackPriority = require("lua_modules.isaac-typescript-definitions.dist.src.enums.CallbackPriority")
|
|
51104
|
+
local CallbackPriority = ____CallbackPriority.CallbackPriority
|
|
51096
51105
|
local ____ModFeature = require("src.classes.ModFeature")
|
|
51097
51106
|
local MOD_FEATURE_CALLBACKS_KEY = ____ModFeature.MOD_FEATURE_CALLBACKS_KEY
|
|
51098
51107
|
local MOD_FEATURE_CUSTOM_CALLBACKS_KEY = ____ModFeature.MOD_FEATURE_CUSTOM_CALLBACKS_KEY
|
|
51099
51108
|
local ____tstlClass = require("src.functions.tstlClass")
|
|
51100
51109
|
local getTSTLClassName = ____tstlClass.getTSTLClassName
|
|
51101
|
-
function ____exports.
|
|
51110
|
+
function ____exports.PriorityCallback(self, modCallback, priority, ...)
|
|
51102
51111
|
local optionalArgs = {...}
|
|
51103
51112
|
return function(____, target, propertyKey, _descriptor)
|
|
51104
51113
|
local methodName = propertyKey
|
|
51105
51114
|
local method = target[methodName]
|
|
51106
|
-
local callbackTuple = {modCallback, method, optionalArgs}
|
|
51115
|
+
local callbackTuple = {modCallback, priority, method, optionalArgs}
|
|
51107
51116
|
local constructor = target.constructor
|
|
51108
51117
|
if constructor == nil then
|
|
51109
51118
|
local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
|
|
@@ -51116,12 +51125,12 @@ function ____exports.Callback(self, modCallback, ...)
|
|
|
51116
51125
|
callbackTuples[#callbackTuples + 1] = callbackTuple
|
|
51117
51126
|
end
|
|
51118
51127
|
end
|
|
51119
|
-
function ____exports.
|
|
51128
|
+
function ____exports.PriorityCallbackCustom(self, modCallbackCustom, priority, ...)
|
|
51120
51129
|
local optionalArgs = {...}
|
|
51121
51130
|
return function(____, target, propertyKey, _descriptor)
|
|
51122
51131
|
local methodName = propertyKey
|
|
51123
51132
|
local method = target[methodName]
|
|
51124
|
-
local callbackTuple = {modCallbackCustom, method, optionalArgs}
|
|
51133
|
+
local callbackTuple = {modCallbackCustom, priority, method, optionalArgs}
|
|
51125
51134
|
local constructor = target.constructor
|
|
51126
51135
|
if constructor == nil then
|
|
51127
51136
|
local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
|
|
@@ -51134,6 +51143,12 @@ function ____exports.CallbackCustom(self, modCallbackCustom, ...)
|
|
|
51134
51143
|
callbackTuples[#callbackTuples + 1] = callbackTuple
|
|
51135
51144
|
end
|
|
51136
51145
|
end
|
|
51146
|
+
function ____exports.Callback(self, modCallback, ...)
|
|
51147
|
+
return ____exports.PriorityCallback(nil, modCallback, CallbackPriority.DEFAULT, ...)
|
|
51148
|
+
end
|
|
51149
|
+
function ____exports.CallbackCustom(self, modCallbackCustom, ...)
|
|
51150
|
+
return ____exports.PriorityCallbackCustom(nil, modCallbackCustom, CallbackPriority.DEFAULT, ...)
|
|
51151
|
+
end
|
|
51137
51152
|
return ____exports
|
|
51138
51153
|
end,
|
|
51139
51154
|
["src.functions.globals"] = function(...)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAS/D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAc;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,yBAAyB,EAC/B,CAAC,CAAC,CAAC,SAAS,OAAO,EACjB,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,iBAAiB,EAC7D,GAAG,YAAY,EAAE,OAAO,EAAE,KACvB,OAAO,CAAC,GACb,IAAI,CAAQ;IAEhB;;;;;OAKG;IACI,WAAW,UAAS;gBAEf,GAAG,EAAE,WAAW,EAAE,IAAI,UAAO;IAQzC;;;;;OAKG;IACI,IAAI,CAAC,IAAI,UAAO,GAAG,IAAI;IAqB9B;;;;;OAKG;IACI,MAAM,IAAI,IAAI;CAGtB"}
|
|
@@ -31,11 +31,15 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
31
31
|
if not isNumber(nil, modCallback) then
|
|
32
32
|
error("Failed to get the callback number from the callback tuple for class: " .. tstlClassName)
|
|
33
33
|
end
|
|
34
|
-
local
|
|
34
|
+
local priority = callbackTuple[2]
|
|
35
|
+
if not isNumber(nil, priority) then
|
|
36
|
+
error("Failed to get the callback priority from the callback tuple for class: " .. tstlClassName)
|
|
37
|
+
end
|
|
38
|
+
local callback = callbackTuple[3]
|
|
35
39
|
if not isFunction(nil, callback) then
|
|
36
40
|
error("Failed to get the callback function from the callback tuple for class: " .. tstlClassName)
|
|
37
41
|
end
|
|
38
|
-
local parameters = callbackTuple[
|
|
42
|
+
local parameters = callbackTuple[4]
|
|
39
43
|
if not isArray(nil, parameters, false) then
|
|
40
44
|
error("Failed to get the callback parameters from the callback tuple for class: " .. tstlClassName)
|
|
41
45
|
end
|
|
@@ -47,6 +51,7 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
47
51
|
modFeatureConstructor,
|
|
48
52
|
mod,
|
|
49
53
|
modCallback,
|
|
54
|
+
priority,
|
|
50
55
|
callback,
|
|
51
56
|
parameters,
|
|
52
57
|
vanilla
|
|
@@ -62,7 +67,7 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
62
67
|
end
|
|
63
68
|
end
|
|
64
69
|
end
|
|
65
|
-
function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback, callback, parameters, vanilla)
|
|
70
|
+
function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback, priority, callback, parameters, vanilla)
|
|
66
71
|
local function wrappedCallback(____, ...)
|
|
67
72
|
local conditionalFunc = modFeature.shouldCallbackMethodsFire
|
|
68
73
|
if conditionalFunc ~= nil then
|
|
@@ -92,14 +97,16 @@ function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback,
|
|
|
92
97
|
wrappedMethodsMap:set(modCallbackCustom, wrappedCallback)
|
|
93
98
|
end
|
|
94
99
|
if vanilla then
|
|
95
|
-
mod:
|
|
100
|
+
mod:AddPriorityCallback(
|
|
96
101
|
modCallback,
|
|
102
|
+
priority,
|
|
97
103
|
wrappedCallback,
|
|
98
104
|
table.unpack(parameters)
|
|
99
105
|
)
|
|
100
106
|
else
|
|
101
|
-
mod:
|
|
107
|
+
mod:AddPriorityCallbackCustom(
|
|
102
108
|
modCallback,
|
|
109
|
+
priority,
|
|
103
110
|
wrappedCallback,
|
|
104
111
|
table.unpack(parameters)
|
|
105
112
|
)
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* @module
|
|
21
21
|
*/
|
|
22
22
|
import { ModCallback } from "isaac-typescript-definitions";
|
|
23
|
+
import { CallbackPriority } from "isaac-typescript-definitions/dist/src/enums/CallbackPriority";
|
|
23
24
|
import { ModFeature } from "../classes/ModFeature";
|
|
24
25
|
import { ModCallbackCustom } from "../enums/ModCallbackCustom";
|
|
25
26
|
import { AddCallbackParametersCustom } from "../interfaces/private/AddCallbackParametersCustom";
|
|
@@ -38,4 +39,18 @@ export declare function Callback<T extends ModCallback>(modCallback: T, ...optio
|
|
|
38
39
|
* @ignore
|
|
39
40
|
*/
|
|
40
41
|
export declare function CallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): <Class extends ModFeature, Fn extends AddCallbackParametersCustom[T][0]>(target: Class, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void;
|
|
42
|
+
/**
|
|
43
|
+
* A decorator function that signifies that the decorated class method should be automatically
|
|
44
|
+
* registered with `Mod.AddPriorityCallback`.
|
|
45
|
+
*
|
|
46
|
+
* @ignore
|
|
47
|
+
*/
|
|
48
|
+
export declare function PriorityCallback<T extends ModCallback>(modCallback: T, priority: CallbackPriority | int, ...optionalArgs: AllButFirst<AddCallbackParameters[T]>): <Class extends ModFeature, Fn extends AddCallbackParameters[T][0]>(target: Class, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* A decorator function that signifies that the decorated class method should be automatically
|
|
51
|
+
* registered with `ModUpgraded.AddCallbackCustom`.
|
|
52
|
+
*
|
|
53
|
+
* @ignore
|
|
54
|
+
*/
|
|
55
|
+
export declare function PriorityCallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, priority: CallbackPriority | int, ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): <Class extends ModFeature, Fn extends AddCallbackParametersCustom[T][0]>(target: Class, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void;
|
|
41
56
|
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/functions/decorators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EACL,UAAU,EAGX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/functions/decorators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,OAAO,EACL,UAAU,EAGX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD;;;;;GAKG;AAGH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,EAC5C,WAAW,EAAE,CAAC,EACd,GAAG,YAAY,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,4JAOvD;AAED;;;;;GAKG;AAGH,wBAAgB,cAAc,CAAC,CAAC,SAAS,iBAAiB,EACxD,iBAAiB,EAAE,CAAC,EACpB,GAAG,YAAY,EAAE,WAAW,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,kKAO7D;AAED;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,WAAW,EACpD,WAAW,EAAE,CAAC,EACd,QAAQ,EAAE,gBAAgB,GAAG,GAAG,EAChC,GAAG,YAAY,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,kGAIvC,MAAM,+CAElB,IAAI,CA6BR;AAED;;;;;GAKG;AAEH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,iBAAiB,EAChE,iBAAiB,EAAE,CAAC,EACpB,QAAQ,EAAE,gBAAgB,GAAG,GAAG,EAChC,GAAG,YAAY,EAAE,WAAW,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,wGAO7C,MAAM,+CAElB,IAAI,CA6BR"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
local ____CallbackPriority = require("isaac-typescript-definitions/dist/src/enums/CallbackPriority")
|
|
3
|
+
local CallbackPriority = ____CallbackPriority.CallbackPriority
|
|
2
4
|
local ____ModFeature = require("src.classes.ModFeature")
|
|
3
5
|
local MOD_FEATURE_CALLBACKS_KEY = ____ModFeature.MOD_FEATURE_CALLBACKS_KEY
|
|
4
6
|
local MOD_FEATURE_CUSTOM_CALLBACKS_KEY = ____ModFeature.MOD_FEATURE_CUSTOM_CALLBACKS_KEY
|
|
5
7
|
local ____tstlClass = require("src.functions.tstlClass")
|
|
6
8
|
local getTSTLClassName = ____tstlClass.getTSTLClassName
|
|
7
9
|
--- A decorator function that signifies that the decorated class method should be automatically
|
|
8
|
-
-- registered with `Mod.
|
|
10
|
+
-- registered with `Mod.AddPriorityCallback`.
|
|
9
11
|
--
|
|
10
12
|
-- @ignore
|
|
11
|
-
function ____exports.
|
|
13
|
+
function ____exports.PriorityCallback(self, modCallback, priority, ...)
|
|
12
14
|
local optionalArgs = {...}
|
|
13
15
|
return function(____, target, propertyKey, _descriptor)
|
|
14
16
|
local methodName = propertyKey
|
|
15
17
|
local method = target[methodName]
|
|
16
|
-
local callbackTuple = {modCallback, method, optionalArgs}
|
|
18
|
+
local callbackTuple = {modCallback, priority, method, optionalArgs}
|
|
17
19
|
local constructor = target.constructor
|
|
18
20
|
if constructor == nil then
|
|
19
21
|
local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
|
|
@@ -30,12 +32,12 @@ end
|
|
|
30
32
|
-- registered with `ModUpgraded.AddCallbackCustom`.
|
|
31
33
|
--
|
|
32
34
|
-- @ignore
|
|
33
|
-
function ____exports.
|
|
35
|
+
function ____exports.PriorityCallbackCustom(self, modCallbackCustom, priority, ...)
|
|
34
36
|
local optionalArgs = {...}
|
|
35
37
|
return function(____, target, propertyKey, _descriptor)
|
|
36
38
|
local methodName = propertyKey
|
|
37
39
|
local method = target[methodName]
|
|
38
|
-
local callbackTuple = {modCallbackCustom, method, optionalArgs}
|
|
40
|
+
local callbackTuple = {modCallbackCustom, priority, method, optionalArgs}
|
|
39
41
|
local constructor = target.constructor
|
|
40
42
|
if constructor == nil then
|
|
41
43
|
local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
|
|
@@ -48,4 +50,18 @@ function ____exports.CallbackCustom(self, modCallbackCustom, ...)
|
|
|
48
50
|
callbackTuples[#callbackTuples + 1] = callbackTuple
|
|
49
51
|
end
|
|
50
52
|
end
|
|
53
|
+
--- A decorator function that signifies that the decorated class method should be automatically
|
|
54
|
+
-- registered with `Mod.AddCallback`.
|
|
55
|
+
--
|
|
56
|
+
-- @ignore
|
|
57
|
+
function ____exports.Callback(self, modCallback, ...)
|
|
58
|
+
return ____exports.PriorityCallback(nil, modCallback, CallbackPriority.DEFAULT, ...)
|
|
59
|
+
end
|
|
60
|
+
--- A decorator function that signifies that the decorated class method should be automatically
|
|
61
|
+
-- registered with `ModUpgraded.AddCallbackCustom`.
|
|
62
|
+
--
|
|
63
|
+
-- @ignore
|
|
64
|
+
function ____exports.CallbackCustom(self, modCallbackCustom, ...)
|
|
65
|
+
return ____exports.PriorityCallbackCustom(nil, modCallbackCustom, CallbackPriority.DEFAULT, ...)
|
|
66
|
+
end
|
|
51
67
|
return ____exports
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ModCallback } from "isaac-typescript-definitions";
|
|
2
|
+
import { CallbackPriority } from "isaac-typescript-definitions/dist/src/enums/CallbackPriority";
|
|
2
3
|
import { ModCallbackCustom } from "../enums/ModCallbackCustom";
|
|
3
4
|
import { isArray } from "../functions/array";
|
|
4
5
|
import {
|
|
@@ -191,14 +192,21 @@ function initDecoratedCallbacks(
|
|
|
191
192
|
);
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
const
|
|
195
|
+
const priority = callbackTuple[1];
|
|
196
|
+
if (!isNumber(priority)) {
|
|
197
|
+
error(
|
|
198
|
+
`Failed to get the callback priority from the callback tuple for class: ${tstlClassName}`,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const callback = callbackTuple[2];
|
|
195
203
|
if (!isFunction(callback)) {
|
|
196
204
|
error(
|
|
197
205
|
`Failed to get the callback function from the callback tuple for class: ${tstlClassName}`,
|
|
198
206
|
);
|
|
199
207
|
}
|
|
200
208
|
|
|
201
|
-
const parameters = callbackTuple[
|
|
209
|
+
const parameters = callbackTuple[3];
|
|
202
210
|
// We must pass false as the second argument to `isArray` since the callback parameters may not
|
|
203
211
|
// necessarily be contiguous. (They might be separated by `undefined` values.)
|
|
204
212
|
if (!isArray(parameters, false)) {
|
|
@@ -216,6 +224,7 @@ function initDecoratedCallbacks(
|
|
|
216
224
|
modFeatureConstructor,
|
|
217
225
|
mod,
|
|
218
226
|
modCallback, // eslint-disable-line isaacscript/strict-enums
|
|
227
|
+
priority,
|
|
219
228
|
callback,
|
|
220
229
|
parameters,
|
|
221
230
|
vanilla,
|
|
@@ -236,6 +245,7 @@ function addCallback(
|
|
|
236
245
|
modFeatureConstructor: ModFeatureConstructor,
|
|
237
246
|
mod: ModUpgraded,
|
|
238
247
|
modCallback: ModCallback | ModCallbackCustom,
|
|
248
|
+
priority: CallbackPriority | int,
|
|
239
249
|
callback: Function, // eslint-disable-line @typescript-eslint/ban-types
|
|
240
250
|
parameters: unknown[],
|
|
241
251
|
vanilla: boolean,
|
|
@@ -281,14 +291,16 @@ function addCallback(
|
|
|
281
291
|
}
|
|
282
292
|
|
|
283
293
|
if (vanilla) {
|
|
284
|
-
(mod.
|
|
294
|
+
(mod.AddPriorityCallback as AnyFunction)(
|
|
285
295
|
modCallback,
|
|
296
|
+
priority,
|
|
286
297
|
wrappedCallback,
|
|
287
298
|
...parameters,
|
|
288
299
|
);
|
|
289
300
|
} else {
|
|
290
|
-
(mod.
|
|
301
|
+
(mod.AddPriorityCallbackCustom as AnyFunction)(
|
|
291
302
|
modCallback,
|
|
303
|
+
priority,
|
|
292
304
|
wrappedCallback,
|
|
293
305
|
...parameters,
|
|
294
306
|
);
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import { ModCallback } from "isaac-typescript-definitions";
|
|
24
|
+
import { CallbackPriority } from "isaac-typescript-definitions/dist/src/enums/CallbackPriority";
|
|
24
25
|
import {
|
|
25
26
|
ModFeature,
|
|
26
27
|
MOD_FEATURE_CALLBACKS_KEY,
|
|
@@ -38,19 +39,58 @@ import { getTSTLClassName } from "./tstlClass";
|
|
|
38
39
|
* @ignore
|
|
39
40
|
*/
|
|
40
41
|
// We tell TypeDoc to ignore this function because it generates a bunch of spam.
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
41
43
|
export function Callback<T extends ModCallback>(
|
|
42
44
|
modCallback: T,
|
|
43
45
|
...optionalArgs: AllButFirst<AddCallbackParameters[T]>
|
|
46
|
+
) {
|
|
47
|
+
return PriorityCallback(
|
|
48
|
+
modCallback,
|
|
49
|
+
CallbackPriority.DEFAULT,
|
|
50
|
+
...optionalArgs,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A decorator function that signifies that the decorated class method should be automatically
|
|
56
|
+
* registered with `ModUpgraded.AddCallbackCustom`.
|
|
57
|
+
*
|
|
58
|
+
* @ignore
|
|
59
|
+
*/
|
|
60
|
+
// We tell TypeDoc to ignore this function because it generates a bunch of spam.
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
62
|
+
export function CallbackCustom<T extends ModCallbackCustom>(
|
|
63
|
+
modCallbackCustom: T,
|
|
64
|
+
...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>
|
|
65
|
+
) {
|
|
66
|
+
return PriorityCallbackCustom(
|
|
67
|
+
modCallbackCustom,
|
|
68
|
+
CallbackPriority.DEFAULT,
|
|
69
|
+
...optionalArgs,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A decorator function that signifies that the decorated class method should be automatically
|
|
75
|
+
* registered with `Mod.AddPriorityCallback`.
|
|
76
|
+
*
|
|
77
|
+
* @ignore
|
|
78
|
+
*/
|
|
79
|
+
// We tell TypeDoc to ignore this function because it generates a bunch of spam.
|
|
80
|
+
export function PriorityCallback<T extends ModCallback>(
|
|
81
|
+
modCallback: T,
|
|
82
|
+
priority: CallbackPriority | int,
|
|
83
|
+
...optionalArgs: AllButFirst<AddCallbackParameters[T]>
|
|
44
84
|
) {
|
|
45
85
|
return <Class extends ModFeature, Fn extends AddCallbackParameters[T][0]>(
|
|
46
86
|
target: Class,
|
|
47
87
|
propertyKey: string,
|
|
48
88
|
_descriptor: TypedPropertyDescriptor<Fn>,
|
|
49
89
|
): void => {
|
|
50
|
-
// First, prepare the arguments for the `Mod.
|
|
90
|
+
// First, prepare the arguments for the `Mod.AddPriorityCallback` method.
|
|
51
91
|
const methodName = propertyKey as keyof Class;
|
|
52
92
|
const method = target[methodName] as AddCallbackParameters[T][0];
|
|
53
|
-
const callbackTuple = [modCallback, method, optionalArgs];
|
|
93
|
+
const callbackTuple = [modCallback, priority, method, optionalArgs];
|
|
54
94
|
|
|
55
95
|
// Since the decorator runs prior to instantiation, we only have access to get and set static
|
|
56
96
|
// properties, which are located on the "constructor" table. Thus, we store the callback
|
|
@@ -84,8 +124,9 @@ export function Callback<T extends ModCallback>(
|
|
|
84
124
|
* @ignore
|
|
85
125
|
*/
|
|
86
126
|
// We tell TypeDoc to ignore this function because it generates a bunch of spam.
|
|
87
|
-
export function
|
|
127
|
+
export function PriorityCallbackCustom<T extends ModCallbackCustom>(
|
|
88
128
|
modCallbackCustom: T,
|
|
129
|
+
priority: CallbackPriority | int,
|
|
89
130
|
...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>
|
|
90
131
|
) {
|
|
91
132
|
return <
|
|
@@ -99,7 +140,7 @@ export function CallbackCustom<T extends ModCallbackCustom>(
|
|
|
99
140
|
// First, prepare the arguments for the `Mod.AddCallbackCustom` method.
|
|
100
141
|
const methodName = propertyKey as keyof Class;
|
|
101
142
|
const method = target[methodName] as AddCallbackParametersCustom[T][0];
|
|
102
|
-
const callbackTuple
|
|
143
|
+
const callbackTuple = [modCallbackCustom, priority, method, optionalArgs];
|
|
103
144
|
|
|
104
145
|
// Since the decorator runs prior to instantiation, we only have access to get and set static
|
|
105
146
|
// properties, which are located on the "constructor" table. Thus, we store the callback
|