isaacscript-common 21.4.1 → 21.5.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 → index.rollup.d.ts} +78 -69
- package/dist/isaacscript-common.lua +1042 -974
- package/dist/src/classes/ModFeature.d.ts +2 -2
- package/dist/src/classes/ModFeature.d.ts.map +1 -1
- package/dist/src/classes/{ModUpgradedBase.d.ts → ModUpgraded.d.ts} +20 -32
- package/dist/src/classes/ModUpgraded.d.ts.map +1 -0
- package/dist/src/classes/{ModUpgradedBase.lua → ModUpgraded.lua} +30 -29
- package/dist/src/classes/features/other/DebugDisplay.lua +2 -2
- package/dist/src/classes/features/other/ExtraConsoleCommands.lua +2 -2
- package/dist/src/classes/features/other/extraConsoleCommands/commands.d.ts.map +1 -1
- package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +2 -1
- package/dist/src/classes/private/CustomCallback.d.ts +3 -1
- package/dist/src/classes/private/CustomCallback.d.ts.map +1 -1
- package/dist/src/classes/private/CustomCallback.lua +12 -4
- package/dist/src/core/upgradeMod.d.ts +3 -11
- package/dist/src/core/upgradeMod.d.ts.map +1 -1
- package/dist/src/core/upgradeMod.lua +6 -22
- package/dist/src/features.lua +2 -2
- package/dist/src/functions/console.d.ts +8 -0
- package/dist/src/functions/console.d.ts.map +1 -0
- package/dist/src/functions/console.lua +14 -0
- package/dist/src/functions/deepCopy.d.ts.map +1 -1
- package/dist/src/functions/deepCopy.lua +3 -2
- package/dist/src/functions/enums.d.ts +28 -0
- package/dist/src/functions/enums.d.ts.map +1 -1
- package/dist/src/functions/enums.lua +27 -0
- package/dist/src/functions/globals.lua +3 -3
- package/dist/src/functions/log.d.ts +5 -0
- package/dist/src/functions/log.d.ts.map +1 -1
- package/dist/src/functions/log.lua +6 -0
- package/dist/src/functions/mergeTests.lua +2 -2
- package/dist/src/functions/modFeatures.d.ts +1 -1
- package/dist/src/functions/modFeatures.d.ts.map +1 -1
- package/dist/src/functions/sort.d.ts +38 -0
- package/dist/src/functions/sort.d.ts.map +1 -0
- package/dist/src/functions/sort.lua +95 -0
- package/dist/src/functions/utils.d.ts +0 -54
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +0 -91
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +17 -1
- package/dist/src/interfaces/private/AddCallbackParametersCustom.lua +2 -2
- package/dist/src/interfaces/private/ModUpgradedInterface.d.ts +4 -2
- package/dist/src/interfaces/private/ModUpgradedInterface.d.ts.map +1 -1
- package/dist/src/types/{ModUpgraded.d.ts → private/ModUpgradedWithFeatures.d.ts} +13 -9
- package/dist/src/types/private/ModUpgradedWithFeatures.d.ts.map +1 -0
- package/dist/src/types/{ModUpgraded.lua → private/ModUpgradedWithFeatures.lua} +0 -0
- package/package.json +2 -2
- package/src/classes/ModFeature.ts +5 -5
- package/src/classes/{ModUpgradedBase.ts → ModUpgraded.ts} +33 -37
- package/src/classes/features/other/DebugDisplay.ts +1 -1
- package/src/classes/features/other/ExtraConsoleCommands.ts +1 -1
- package/src/classes/features/other/extraConsoleCommands/commands.ts +2 -1
- package/src/classes/private/CustomCallback.ts +17 -7
- package/src/core/upgradeMod.ts +7 -29
- package/src/features.ts +1 -1
- package/src/functions/console.ts +15 -0
- package/src/functions/deepCopy.ts +3 -2
- package/src/functions/enums.ts +33 -0
- package/src/functions/globals.ts +2 -2
- package/src/functions/log.ts +9 -0
- package/src/functions/mergeTests.ts +1 -1
- package/src/functions/modFeatures.ts +1 -1
- package/src/functions/sort.ts +128 -0
- package/src/functions/utils.ts +0 -124
- package/src/index.ts +3 -1
- package/src/interfaces/private/AddCallbackParametersCustom.ts +1 -1
- package/src/interfaces/private/ModUpgradedInterface.ts +4 -2
- package/src/types/{ModUpgraded.ts → private/ModUpgradedWithFeatures.ts} +13 -12
- package/dist/src/classes/ModUpgradedBase.d.ts.map +0 -1
- package/dist/src/types/ModUpgraded.d.ts.map +0 -1
|
@@ -1543,7 +1543,7 @@ export declare function countSetBits(n: int): int;
|
|
|
1543
1543
|
*/
|
|
1544
1544
|
declare abstract class CustomCallback<T extends ModCallbackCustom> extends Feature {
|
|
1545
1545
|
private subscriptions;
|
|
1546
|
-
addSubscriber(callbackFunc: AddCallbackParametersCustom[T][0], ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): void;
|
|
1546
|
+
addSubscriber(priority: CallbackPriority | int, callbackFunc: AddCallbackParametersCustom[T][0], ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): void;
|
|
1547
1547
|
/**
|
|
1548
1548
|
* If the submitted function does not match any of the existing subscriptions, this method will do
|
|
1549
1549
|
* nothing.
|
|
@@ -11652,7 +11652,7 @@ export declare class ModFeature {
|
|
|
11652
11652
|
* argument of the constructor.
|
|
11653
11653
|
*/
|
|
11654
11654
|
initialized: boolean;
|
|
11655
|
-
constructor(mod:
|
|
11655
|
+
constructor(mod: ModUpgraded, init?: boolean);
|
|
11656
11656
|
/**
|
|
11657
11657
|
* Runs the `Mod.AddCallback` and `ModUpgraded.AddCallbackCustom` methods for all of the decorated
|
|
11658
11658
|
* callbacks.
|
|
@@ -11676,22 +11676,11 @@ export declare class ModFeature {
|
|
|
11676
11676
|
*
|
|
11677
11677
|
* To upgrade your mod, use the `upgradeMod` helper function.
|
|
11678
11678
|
*
|
|
11679
|
-
* By specifying one or more optional features,
|
|
11680
|
-
* has extra methods corresponding to the features that were specified.
|
|
11681
|
-
|
|
11682
|
-
declare type ModUpgraded<T extends readonly ISCFeature[] = []> = ModUpgradedBase & ISCFeaturesToKeys<T>;
|
|
11683
|
-
|
|
11684
|
-
/**
|
|
11685
|
-
* `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
|
|
11686
|
-
* hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
|
|
11687
|
-
* extends the base class and adds a new method of `AddCallbackCustom`.
|
|
11688
|
-
*
|
|
11689
|
-
* To upgrade your mod, use the `upgradeMod` helper function.
|
|
11690
|
-
*
|
|
11691
|
-
* `ModUpgradedBase` provides the core functionality of the `ModUpgraded` class. (It does not
|
|
11692
|
-
* include the methods for the individual ISC features.)
|
|
11679
|
+
* By specifying one or more optional features when upgrading your mod, you will get a version of
|
|
11680
|
+
* `ModUpgraded` that has extra methods corresponding to the features that were specified. (This
|
|
11681
|
+
* corresponds to the internal-type `ModUpgradedWithFeatures` type, which extends `ModUpgraded`.)
|
|
11693
11682
|
*/
|
|
11694
|
-
export declare class
|
|
11683
|
+
export declare class ModUpgraded implements Mod {
|
|
11695
11684
|
Name: string;
|
|
11696
11685
|
/** We store a copy of the original mod object so that we can re-implement its functions. */
|
|
11697
11686
|
private mod;
|
|
@@ -11700,42 +11689,34 @@ export declare class ModUpgradedBase implements Mod {
|
|
|
11700
11689
|
private callbacks;
|
|
11701
11690
|
private features;
|
|
11702
11691
|
constructor(mod: Mod, debug: boolean, timeThreshold?: float);
|
|
11703
|
-
/**
|
|
11704
|
-
* Registers a function to be executed when an in-game event happens. For example, the
|
|
11705
|
-
* `ModCallback.POST_UPDATE` event corresponds to being executed once at the end of every game
|
|
11706
|
-
* logic frame.
|
|
11707
|
-
*/
|
|
11708
11692
|
AddCallback<T extends ModCallback | string>(modCallback: T, ...args: T extends ModCallback ? AddCallbackParameters[T] : unknown[]): void;
|
|
11709
11693
|
AddPriorityCallback<T extends ModCallback | string>(modCallback: T, priority: CallbackPriority | int, ...args: T extends ModCallback ? AddCallbackParameters[T] : unknown[]): void;
|
|
11710
|
-
/** Returns whether or not a corresponding "save#.dat" file exists for the current mod. */
|
|
11711
11694
|
HasData(): boolean;
|
|
11712
|
-
/**
|
|
11713
|
-
* Returns a string containing all of the data inside of the corresponding "save#.dat" file for
|
|
11714
|
-
* this mod.
|
|
11715
|
-
*/
|
|
11716
11695
|
LoadData(): string;
|
|
11717
|
-
/**
|
|
11718
|
-
* Unregisters a function that was previously registered with the `AddCallback` method.
|
|
11719
|
-
*
|
|
11720
|
-
* This method does not care about the tertiary argument. In other words, regardless of the
|
|
11721
|
-
* conditions of how you registered the callback, it will be removed.
|
|
11722
|
-
*/
|
|
11723
11696
|
RemoveCallback<T extends ModCallback>(modCallback: T, callback: AddCallbackParameters[T][0]): void;
|
|
11724
|
-
/** Deletes the corresponding "save#.dat" file for this mod, if it exists. */
|
|
11725
11697
|
RemoveData(): void;
|
|
11726
|
-
/**
|
|
11727
|
-
* Creates or updates the corresponding "save#.dat" file for this mod with the provided string.
|
|
11728
|
-
*/
|
|
11729
11698
|
SaveData(data: string): void;
|
|
11730
11699
|
/**
|
|
11731
|
-
* Registers a function to be executed when an in-game event happens.
|
|
11732
|
-
*
|
|
11733
|
-
*
|
|
11700
|
+
* Registers a function to be executed when an in-game event happens.
|
|
11701
|
+
*
|
|
11702
|
+
* This method is specifically for events that are provided by the IsaacScript standard library.
|
|
11703
|
+
* For example, the `ModCallbackCustom.POST_BOMB_EXPLODE` event corresponds to when a bomb
|
|
11704
|
+
* explodes.
|
|
11734
11705
|
*/
|
|
11735
11706
|
AddCallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, ...args: AddCallbackParametersCustom[T]): void;
|
|
11707
|
+
/**
|
|
11708
|
+
* The same as the `ModUpgraded.AddCallbackCustom` method, but allows setting a custom priority.
|
|
11709
|
+
* By default, callbacks are added with a priority of 0, so this allows you to add early or late
|
|
11710
|
+
* callbacks as necessary. See the `CallbackPriority` enum.
|
|
11711
|
+
*/
|
|
11712
|
+
AddPriorityCallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, priority: CallbackPriority | int, ...args: AddCallbackParametersCustom[T]): void;
|
|
11736
11713
|
/**
|
|
11737
11714
|
* Unregisters a function that was previously registered with the `AddCallbackCustom` method.
|
|
11738
11715
|
*
|
|
11716
|
+
* This method is specifically for events that are provided by the IsaacScript standard library.
|
|
11717
|
+
* For example, the `ModCallbackCustom.POST_BOMB_EXPLODE` event corresponds to when a bomb
|
|
11718
|
+
* explodes.
|
|
11719
|
+
*
|
|
11739
11720
|
* This method does not care about the tertiary argument. In other words, regardless of the
|
|
11740
11721
|
* conditions of how you registered the callback, it will be removed.
|
|
11741
11722
|
*/
|
|
@@ -11763,13 +11744,24 @@ export declare class ModUpgradedBase implements Mod {
|
|
|
11763
11744
|
* don't have access to it.
|
|
11764
11745
|
*/
|
|
11765
11746
|
private initOptionalFeature;
|
|
11766
|
-
/**
|
|
11767
|
-
* This is mostly the same as the `AddCustomCallback` method, but we initialize the custom
|
|
11768
|
-
* callback without actually registering a subscription.
|
|
11769
|
-
*/
|
|
11770
|
-
private initCustomCallbackEarly;
|
|
11771
11747
|
}
|
|
11772
11748
|
|
|
11749
|
+
/**
|
|
11750
|
+
* `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
|
|
11751
|
+
* hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
|
|
11752
|
+
* extends the base class and adds a new method of `AddCallbackCustom`.
|
|
11753
|
+
*
|
|
11754
|
+
* To upgrade your mod, use the `upgradeMod` helper function.
|
|
11755
|
+
*
|
|
11756
|
+
* By specifying one or more optional features, end-users will get a version of `ModUpgraded` that
|
|
11757
|
+
* has extra methods corresponding to the features that were specified.
|
|
11758
|
+
*
|
|
11759
|
+
* This type is in the private directory because if it was exported, it would cause all of the
|
|
11760
|
+
* internal feature classes to populate the auto-complete of end-user mods (which should never be
|
|
11761
|
+
* directly imported by end-users).
|
|
11762
|
+
*/
|
|
11763
|
+
declare type ModUpgradedWithFeatures<T extends readonly ISCFeature[] = []> = ModUpgraded & ISCFeaturesToKeys<T>;
|
|
11764
|
+
|
|
11773
11765
|
export declare const MOVEMENT_ACTIONS_SET: ReadonlySet<ButtonAction>;
|
|
11774
11766
|
|
|
11775
11767
|
/**
|
|
@@ -14527,6 +14519,45 @@ export declare function smeltTrinkets(player: EntityPlayer, ...trinketTypes: Tri
|
|
|
14527
14519
|
*/
|
|
14528
14520
|
export declare function some<T>(array: T[], func: (value: T, index: number, array: T[]) => boolean): boolean;
|
|
14529
14521
|
|
|
14522
|
+
/**
|
|
14523
|
+
* Helper function to sort an array of objects by one of the object keys.
|
|
14524
|
+
*
|
|
14525
|
+
* For example:
|
|
14526
|
+
*
|
|
14527
|
+
* ```ts
|
|
14528
|
+
* const myArray = [
|
|
14529
|
+
* {
|
|
14530
|
+
* name: "alice",
|
|
14531
|
+
* age: 30,
|
|
14532
|
+
* },
|
|
14533
|
+
* {
|
|
14534
|
+
* name: "bob",
|
|
14535
|
+
* age: 20,
|
|
14536
|
+
* },
|
|
14537
|
+
* ];
|
|
14538
|
+
* myArray.sort(sortObjectArrayByKey("age"));
|
|
14539
|
+
* ```
|
|
14540
|
+
*/
|
|
14541
|
+
export declare function sortObjectArrayByKey(key: string): (a: unknown, b: unknown) => -1 | 0 | 1;
|
|
14542
|
+
|
|
14543
|
+
/**
|
|
14544
|
+
* Helper function to sort a two-dimensional array by the first element.
|
|
14545
|
+
*
|
|
14546
|
+
* For example:
|
|
14547
|
+
*
|
|
14548
|
+
* ```ts
|
|
14549
|
+
* const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
14550
|
+
* myArray.sort(twoDimensionalSort);
|
|
14551
|
+
* ```
|
|
14552
|
+
*
|
|
14553
|
+
* This function also properly handles when the array elements are strings or numbers (instead of
|
|
14554
|
+
* another array).
|
|
14555
|
+
*
|
|
14556
|
+
* From:
|
|
14557
|
+
* https://stackoverflow.com/questions/16096872/how-to-sort-2-dimensional-array-by-column-value
|
|
14558
|
+
*/
|
|
14559
|
+
export declare function sortTwoDimensionalArray<T>(a: T[], b: T[]): -1 | 0 | 1;
|
|
14560
|
+
|
|
14530
14561
|
export declare type SoulHeartType = HeartSubType.SOUL | HeartSubType.BLACK | HeartSubType.BONE;
|
|
14531
14562
|
|
|
14532
14563
|
/**
|
|
@@ -15353,21 +15384,6 @@ infer F,
|
|
|
15353
15384
|
/** Helper type to convert a tuple to a union. */
|
|
15354
15385
|
export declare type TupleToUnion<T extends unknown[]> = T[number];
|
|
15355
15386
|
|
|
15356
|
-
/**
|
|
15357
|
-
* Helper function to sort a two-dimensional array by the first element.
|
|
15358
|
-
*
|
|
15359
|
-
* For example:
|
|
15360
|
-
*
|
|
15361
|
-
* ```ts
|
|
15362
|
-
* const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
15363
|
-
* myArray.sort(twoDimensionalSort);
|
|
15364
|
-
* ```
|
|
15365
|
-
*
|
|
15366
|
-
* From:
|
|
15367
|
-
* https://stackoverflow.com/questions/16096872/how-to-sort-2-dimensional-array-by-column-value
|
|
15368
|
-
*/
|
|
15369
|
-
export declare function twoDimensionalSort<T>(array1: T[], array2: T[]): -1 | 0 | 1;
|
|
15370
|
-
|
|
15371
15387
|
/**
|
|
15372
15388
|
* This is the number of draw coordinates that each heart spans on the UI in the upper left hand
|
|
15373
15389
|
* corner.
|
|
@@ -15397,22 +15413,15 @@ export declare type UnionToIntersection<U> = (U extends U ? (u: U) => 0 : never)
|
|
|
15397
15413
|
* @param modVanilla The mod object returned by the `RegisterMod` function.
|
|
15398
15414
|
* @param features Optional. An array containing the optional standard library features that you
|
|
15399
15415
|
* want to enable, if any. Default is an empty array.
|
|
15400
|
-
* @param customCallbacksUsed Optional. An array containing the custom callbacks that you will be
|
|
15401
|
-
* subscribing to after you upgrade your mod. Specifying this will
|
|
15402
|
-
* immediately initialize the callbacks (as opposed to lazy-initializing
|
|
15403
|
-
* them when you first subscribe to the callback). This is only necessary
|
|
15404
|
-
* if you the order of callback firing is important for your mod. (For
|
|
15405
|
-
* example, you may want the `POST_NEW_ROOM` part of the
|
|
15406
|
-
* `POST_GRID_ENTITY_INIT` callback to fire before your own
|
|
15407
|
-
* `POST_NEW_ROOM` callbacks.)
|
|
15408
15416
|
* @param debug Optional. Whether to log additional output when a callback is fired. Default is
|
|
15409
15417
|
* false.
|
|
15410
15418
|
* @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
|
|
15411
15419
|
* specified number of seconds (if the "--luadebug" launch flag is turned on)
|
|
15412
15420
|
* or milliseconds (if the "--luadebug" launch flag is turned off).
|
|
15413
15421
|
* @returns The upgraded mod object.
|
|
15422
|
+
* @beta A dummy field used to hide this function from `api-extractor`.
|
|
15414
15423
|
*/
|
|
15415
|
-
export declare function upgradeMod<T extends readonly ISCFeature[] = never[]>(modVanilla: Mod, features?: ISCFeatureTuple<T>,
|
|
15424
|
+
export declare function upgradeMod<T extends readonly ISCFeature[] = never[]>(modVanilla: Mod, features?: ISCFeatureTuple<T>, debug?: boolean, timeThreshold?: float): ModUpgradedWithFeatures<T>;
|
|
15416
15425
|
|
|
15417
15426
|
/** Helper type to match all of the uppercase keys of an object. */
|
|
15418
15427
|
export declare type UppercaseKeys<T> = StartsWithUppercase<keyof T>;
|