@rian8337/osu-base 2.0.0-alpha.7 → 2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-base",
3
- "version": "2.0.0-alpha.7",
3
+ "version": "2.0.1",
4
4
  "description": "Base module for all osu! related modules.",
5
5
  "keywords": [
6
6
  "osu",
@@ -19,7 +19,7 @@
19
19
  "scripts": {
20
20
  "build": "rollup -c ../../rollup.config.js",
21
21
  "lint": "eslint --ext ts",
22
- "prepublishOnly": "npm run build",
22
+ "prepare": "npm run build",
23
23
  "test": "jest -i"
24
24
  },
25
25
  "repository": {
@@ -41,5 +41,5 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "cea730e1d7922e2ec6c1553e9f16f034f7af8e61"
44
+ "gitHead": "e48b38c17a7fd73c2cf286c5824b689697e61284"
45
45
  }
@@ -317,7 +317,7 @@ declare class MapStats {
317
317
  */
318
318
  speedMultiplier?: number;
319
319
  /**
320
- * Whether or not force AR is turned on.
320
+ * Whether force AR is turned on.
321
321
  */
322
322
  isForceAR?: boolean;
323
323
  }): MapStats;
@@ -907,6 +907,8 @@ declare abstract class ControlPointManager<T extends ControlPoint> {
907
907
  /**
908
908
  * Removes a control point.
909
909
  *
910
+ * This method will remove the earliest control point in the array that is equal to the given control point.
911
+ *
910
912
  * @param controlPoint The control point to remove.
911
913
  * @returns Whether the control point was removed.
912
914
  */
@@ -1621,17 +1623,24 @@ declare abstract class Encoder<T, E extends BaseEncoder> {
1621
1623
  * The result of the encoding process.
1622
1624
  */
1623
1625
  protected finalResult: string;
1626
+ /**
1627
+ * The result of the encoding process.
1628
+ */
1629
+ get result(): string;
1624
1630
  /**
1625
1631
  * Available per-section encoders.
1626
1632
  */
1627
1633
  protected abstract encoders: E[];
1634
+ /**
1635
+ * @param target The target of the encoding process.
1636
+ */
1628
1637
  constructor(target: T);
1629
1638
  /**
1630
1639
  * Performs the decoding process.
1631
1640
  *
1632
1641
  * Keep in mind that this will not produce the exact same file as the original decoded file.
1633
1642
  */
1634
- encode(): string;
1643
+ encode(): this;
1635
1644
  /**
1636
1645
  * Writes a line to encoded text.
1637
1646
  *
@@ -2117,21 +2126,24 @@ declare abstract class HitWindow {
2117
2126
  */
2118
2127
  constructor(overallDifficulty: number);
2119
2128
  /**
2120
- * Gets the threshold for 300 (great) hit result.
2129
+ * Gets the hit window for 300 (great) hit result.
2121
2130
  *
2122
- * @param isPrecise Whether or not to calculate for Precise mod. This is only available for `DroidHitWindow`.
2131
+ * @param isPrecise Whether to calculate for Precise mod.
2132
+ * @returns The hit window in milliseconds.
2123
2133
  */
2124
2134
  abstract hitWindowFor300(isPrecise?: boolean): number;
2125
2135
  /**
2126
- * Gets the threshold for 100 (good) hit result.
2136
+ * Gets the hit window for 100 (good) hit result.
2127
2137
  *
2128
- * @param isPrecise Whether or not to calculate for Precise mod. This is only available for `DroidHitWindow`.
2138
+ * @param isPrecise Whether to calculate for Precise mod.
2139
+ * @returns The hit window in milliseconds.
2129
2140
  */
2130
2141
  abstract hitWindowFor100(isPrecise?: boolean): number;
2131
2142
  /**
2132
- * Gets the threshold for 50 (meh) hit result.
2143
+ * Gets the hit window for 50 (meh) hit result.
2133
2144
  *
2134
- * @param isPrecise Whether or not to calculate for Precise mod. This is only available for `DroidHitWindow`.
2145
+ * @param isPrecise Whether to calculate for Precise mod.
2146
+ * @returns The hit window in milliseconds.
2135
2147
  */
2136
2148
  abstract hitWindowFor50(isPrecise?: boolean): number;
2137
2149
  }
@@ -2139,6 +2151,30 @@ declare abstract class HitWindow {
2139
2151
  * Represents the hit window of osu!droid.
2140
2152
  */
2141
2153
  declare class DroidHitWindow extends HitWindow {
2154
+ /**
2155
+ * Calculates the overall difficulty value of a great hit window.
2156
+ *
2157
+ * @param value The value of the hit window, in milliseconds.
2158
+ * @param isPrecise Whether to calculate for Precise mod.
2159
+ * @returns The overall difficulty value.
2160
+ */
2161
+ static hitWindow300ToOD(value: number, isPrecise?: boolean): number;
2162
+ /**
2163
+ * Calculates the overall difficulty value of a good hit window.
2164
+ *
2165
+ * @param value The value of the hit window, in milliseconds.
2166
+ * @param isPrecise Whether to calculate for Precise mod.
2167
+ * @returns The overall difficulty value.
2168
+ */
2169
+ static hitWindow100ToOD(value: number, isPrecise?: boolean): number;
2170
+ /**
2171
+ * Calculates the overall difficulty value of a meh hit window.
2172
+ *
2173
+ * @param value The value of the hit window, in milliseconds.
2174
+ * @param isPrecise Whether to calculate for Precise mod.
2175
+ * @returns The overall difficulty value.
2176
+ */
2177
+ static hitWindow50ToOD(value: number, isPrecise?: boolean): number;
2142
2178
  hitWindowFor300(isPrecise?: boolean): number;
2143
2179
  hitWindowFor100(isPrecise?: boolean): number;
2144
2180
  hitWindowFor50(isPrecise?: boolean): number;
@@ -2147,6 +2183,27 @@ declare class DroidHitWindow extends HitWindow {
2147
2183
  * Represents the hit window of osu!standard.
2148
2184
  */
2149
2185
  declare class OsuHitWindow extends HitWindow {
2186
+ /**
2187
+ * Calculates the overall difficulty value of a great hit window.
2188
+ *
2189
+ * @param value The value of the hit window, in milliseconds.
2190
+ * @returns The overall difficulty value.
2191
+ */
2192
+ static hitWindow300ToOD(value: number): number;
2193
+ /**
2194
+ * Calculates the overall difficulty value of a good hit window.
2195
+ *
2196
+ * @param value The value of the hit window, in milliseconds.
2197
+ * @returns The overall difficulty value.
2198
+ */
2199
+ static hitWindow100ToOD(value: number): number;
2200
+ /**
2201
+ * Calculates the overall difficulty value of a meh hit window.
2202
+ *
2203
+ * @param value The value of the hit window, in milliseconds.
2204
+ * @returns The overall difficulty value.
2205
+ */
2206
+ static hitWindow50ToOD(value: number): number;
2150
2207
  hitWindowFor300(): number;
2151
2208
  hitWindowFor100(): number;
2152
2209
  hitWindowFor50(): number;
@@ -2163,6 +2220,11 @@ declare enum HitSoundType {
2163
2220
  clap = 8
2164
2221
  }
2165
2222
 
2223
+ /**
2224
+ * Quick and simple if statement for type checking.
2225
+ */
2226
+ declare type If<T extends boolean, A, B = null> = T extends true ? A : T extends false ? B : A | B;
2227
+
2166
2228
  declare abstract class Interpolation {
2167
2229
  static lerp(start: number, final: number, amount: number): number;
2168
2230
  }
@@ -2225,7 +2287,7 @@ interface OsuAPIResponse {
2225
2287
  /**
2226
2288
  * Represents a beatmap with general information.
2227
2289
  */
2228
- declare class MapInfo {
2290
+ declare class MapInfo<HasBeatmap extends boolean = boolean> {
2229
2291
  /**
2230
2292
  * The title of the song of the beatmap.
2231
2293
  */
@@ -2355,41 +2417,60 @@ declare class MapInfo {
2355
2417
  */
2356
2418
  videoAvailable: boolean;
2357
2419
  /**
2358
- * The parsed beatmap from beatmap parser.
2420
+ * The decoded beatmap from beatmap decoder.
2359
2421
  */
2360
- get map(): Beatmap | undefined;
2361
- private cachedBeatmap?;
2422
+ get beatmap(): If<HasBeatmap, Beatmap>;
2423
+ private cachedBeatmap;
2362
2424
  /**
2363
2425
  * Retrieve a beatmap's general information.
2364
2426
  *
2365
- * Either beatmap ID or MD5 hash of the beatmap must be specified. If both are specified, beatmap ID is taken.
2427
+ * @param beatmapId The ID of the beatmap.
2428
+ * @param downloadBeatmap Whether to also retrieve the .osu file of the beatmap. Defaults to `true`.
2429
+ * @returns The beatmap, `null` if the beatmap is not found or the beatmap is not an osu!standard beatmap.
2366
2430
  */
2367
- static getInformation(params: {
2368
- /**
2369
- * The ID of the beatmap.
2370
- */
2371
- beatmapID?: number;
2372
- /**
2373
- * The MD5 hash of the beatmap.
2374
- */
2375
- hash?: string;
2376
- /**
2377
- * Whether or not to also retrieve the .osu file of the beatmap (required for some utilities). Defaults to `true`.
2378
- */
2379
- file?: boolean;
2380
- }): Promise<MapInfo>;
2431
+ static getInformation(beatmapId: number, downloadBeatmap?: boolean): Promise<MapInfo<true> | null>;
2432
+ /**
2433
+ * Retrieve a beatmap's general information.
2434
+ *
2435
+ * @param beatmapId The ID of the beatmap.
2436
+ * @param downloadBeatmap Whether to also retrieve the .osu file of the beatmap. Defaults to `true`.
2437
+ * @returns The beatmap, `null` if the beatmap is not found or the beatmap is not an osu!standard beatmap.
2438
+ */
2439
+ static getInformation(beatmapId: number, downloadBeatmap: false): Promise<MapInfo<false> | null>;
2440
+ /**
2441
+ * Retrieve a beatmap's general information.
2442
+ *
2443
+ * @param hash The MD5 hash of the beatmap.
2444
+ * @param downloadBeatmap Whether to also retrieve the .osu file of the beatmap. Defaults to `true`.
2445
+ * @returns The beatmap, `null` if the beatmap is not found or the beatmap is not an osu!standard beatmap.
2446
+ */
2447
+ static getInformation(hash: string, downloadBeatmap?: boolean): Promise<MapInfo<true> | null>;
2448
+ /**
2449
+ * Retrieve a beatmap's general information.
2450
+ *
2451
+ * @param hash The MD5 hash of the beatmap.
2452
+ * @param downloadBeatmap Whether to also retrieve the .osu file of the beatmap. Defaults to `true`.
2453
+ * @returns The beatmap, `null` if the beatmap is not found or the beatmap is not an osu!standard beatmap.
2454
+ */
2455
+ static getInformation(hash: string, downloadBeatmap: false): Promise<MapInfo<false> | null>;
2381
2456
  /**
2382
2457
  * Fills the current instance with map data.
2383
2458
  *
2384
2459
  * @param mapinfo The map data.
2385
2460
  */
2386
2461
  fillMetadata(mapinfo: OsuAPIResponse): MapInfo;
2462
+ /**
2463
+ * Checks whether the beatmap file has been downloaded.
2464
+ */
2465
+ hasDownloadedBeatmap(): this is MapInfo<true>;
2387
2466
  /**
2388
2467
  * Retrieves the .osu file of the beatmap.
2389
2468
  *
2390
- * @param forceDownload Whether or not to download the file regardless if it's already available.
2469
+ * After this, you can use the `hasDownloadedBeatmap` method to check if the beatmap has been downloaded.
2470
+ *
2471
+ * @param force Whether to download the file regardless if it's already available.
2391
2472
  */
2392
- retrieveBeatmapFile(forceDownload?: boolean): Promise<MapInfo>;
2473
+ retrieveBeatmapFile(force?: boolean): Promise<void>;
2393
2474
  /**
2394
2475
  * Converts the beatmap's BPM if speed-changing mods are applied.
2395
2476
  */
@@ -2411,10 +2492,12 @@ declare class MapInfo {
2411
2492
  *
2412
2493
  * - Option `0`: return map title and mods used if defined
2413
2494
  * - Option `1`: return song source and map download link to beatmap mirrors
2414
- * - Option `2`: return CS, AR, OD, HP
2415
- * - Option `3`: return BPM, map length, max combo
2416
- * - Option `4`: return last update date and map status
2417
- * - Option `5`: return favorite count and play count
2495
+ * - Option `2`: return circle, slider, and spinner count
2496
+ * - Option `3`: return CS, AR, OD, HP, and max score statistics for droid
2497
+ * - Option `4`: return CS, AR, OD, HP, and max score statistics for PC
2498
+ * - Option `5`: return BPM, map length, and max combo
2499
+ * - Option `6`: return last update date and map status
2500
+ * - Option `7`: return favorite count and play count
2418
2501
  *
2419
2502
  * @param option The option to pick.
2420
2503
  * @param stats The custom statistics to apply. This will only be used to apply mods, custom speed multiplier, and force AR.
@@ -2575,6 +2658,8 @@ declare class ModHardRock extends Mod {
2575
2658
  * Represents the Hidden mod.
2576
2659
  */
2577
2660
  declare class ModHidden extends Mod {
2661
+ static readonly fadeInDurationMultiplier: number;
2662
+ static readonly fadeOutDurationMultiplier: number;
2578
2663
  readonly scoreMultiplier: number;
2579
2664
  readonly acronym: string;
2580
2665
  readonly name: string;
@@ -2739,6 +2824,19 @@ declare class ModTouchDevice extends Mod {
2739
2824
  readonly droidOnly: boolean;
2740
2825
  }
2741
2826
 
2827
+ /**
2828
+ * Options for parsing mods.
2829
+ */
2830
+ interface ModParseOptions {
2831
+ /**
2832
+ * Whether to check for duplicate mods. Defaults to `true`.
2833
+ */
2834
+ checkDuplicate?: boolean;
2835
+ /**
2836
+ * Whether to check for incompatible mods. Defaults to `true`.
2837
+ */
2838
+ checkIncompatible?: boolean;
2839
+ }
2742
2840
  /**
2743
2841
  * Utilities for mods.
2744
2842
  */
@@ -2763,26 +2861,46 @@ declare abstract class ModUtil {
2763
2861
  * Gets a list of mods from a droid mod string, such as "hd".
2764
2862
  *
2765
2863
  * @param str The string.
2864
+ * @param options Options for parsing behavior.
2766
2865
  */
2767
- static droidStringToMods(str: string): Mod[];
2866
+ static droidStringToMods(str: string, options?: ModParseOptions): Mod[];
2768
2867
  /**
2769
2868
  * Gets a list of mods from a PC modbits.
2770
2869
  *
2771
2870
  * @param modbits The modbits.
2871
+ * @param options Options for parsing behavior.
2772
2872
  */
2773
- static pcModbitsToMods(modbits: number): Mod[];
2873
+ static pcModbitsToMods(modbits: number, options?: ModParseOptions): Mod[];
2774
2874
  /**
2775
2875
  * Gets a list of mods from a PC mod string, such as "HDHR".
2776
2876
  *
2777
2877
  * @param str The string.
2878
+ * @param options Options for parsing behavior.
2778
2879
  */
2779
- static pcStringToMods(str: string): Mod[];
2880
+ static pcStringToMods(str: string, options?: ModParseOptions): Mod[];
2780
2881
  /**
2781
- * Checks for mods that are duplicate and incompatible with each other.
2882
+ * Checks for mods that are duplicated.
2782
2883
  *
2783
2884
  * @param mods The mods to check for.
2885
+ * @returns Mods that have been filtered.
2886
+ */
2887
+ static checkDuplicateMods(mods: Mod[]): Mod[];
2888
+ /**
2889
+ * Checks for mods that are incompatible with each other.
2890
+ *
2891
+ * This will modify the original array.
2892
+ *
2893
+ * @param mods The mods to check for.
2894
+ */
2895
+ static checkIncompatibleMods(mods: Mod[]): void;
2896
+ /**
2897
+ * Processes parsing options.
2898
+ *
2899
+ * @param mods The mods to process.
2900
+ * @param options The options to process.
2901
+ * @returns The processed mods.
2784
2902
  */
2785
- private static checkDuplicateMods;
2903
+ private static processParsingOptions;
2786
2904
  }
2787
2905
 
2788
2906
  /**
@@ -3336,4 +3454,4 @@ declare abstract class Utils {
3336
3454
  static sleep(duration: number): Promise<void>;
3337
3455
  }
3338
3456
 
3339
- export { Accuracy, Anchor, AnimationLoopType, Beatmap, BeatmapBackground, BeatmapColor, BeatmapControlPoints, BeatmapCountdown, BeatmapDecoder, BeatmapDifficulty, BeatmapEditor, BeatmapEncoder, BeatmapEvents, BeatmapGeneral, BeatmapHitObjects, BeatmapMetadata, BeatmapOverlayPosition, BeatmapVideo, BlendingEquation, BlendingParameters, BlendingType, BreakPoint, Circle, Command, CommandLoop, CommandTimeline, CommandTimelineGroup, CommandTimelineSelector, CommandTrigger, ControlPointManager, DifficultyControlPoint, DroidAPIRequestBuilder, DroidHitWindow, Easing, EditorGridSize, EffectControlPoint, GameMode, HitObject, HitSampleInfo, HitSoundType, ICommandTimeline, Interpolation, MapInfo, MapStats, MathUtils, Mod, ModAuto, ModAutopilot, ModDoubleTime, ModEasy, ModFlashlight, ModHalfTime, ModHardRock, ModHidden, ModNightCore, ModNoFail, ModPerfect, ModPrecise, ModReallyEasy, ModRelax, ModScoreV2, ModSmallCircle, ModSpunOut, ModSuddenDeath, ModTouchDevice, ModUtil, OsuAPIRequestBuilder, OsuAPIResponse, OsuHitWindow, PathApproximator, PathType, Precision, RGBColor, RequestResponse, SampleBank, SampleBankInfo, SampleControlPoint, Slider, SliderHead, SliderPath, SliderRepeat, SliderTail, SliderTick, Spinner, Storyboard, StoryboardAnimation, StoryboardCommandType, StoryboardDecoder, StoryboardElement, StoryboardEncoder, StoryboardEventType, StoryboardLayer, StoryboardLayerType, StoryboardParameterCommandType, StoryboardSample, StoryboardSprite, TimingControlPoint, Utils, Vector2, modes, objectTypes, rankedStatus };
3457
+ export { Accuracy, Anchor, AnimationLoopType, Beatmap, BeatmapBackground, BeatmapColor, BeatmapControlPoints, BeatmapCountdown, BeatmapDecoder, BeatmapDifficulty, BeatmapEditor, BeatmapEncoder, BeatmapEvents, BeatmapGeneral, BeatmapHitObjects, BeatmapMetadata, BeatmapOverlayPosition, BeatmapVideo, BlendingEquation, BlendingParameters, BlendingType, BreakPoint, Circle, Command, CommandLoop, CommandTimeline, CommandTimelineGroup, CommandTimelineSelector, CommandTrigger, ControlPointManager, DifficultyControlPoint, DifficultyControlPointManager, DroidAPIRequestBuilder, DroidHitWindow, Easing, EditorGridSize, EffectControlPoint, EffectControlPointManager, GameMode, HitObject, HitSampleInfo, HitSoundType, ICommandTimeline, If, Interpolation, MapInfo, MapStats, MathUtils, Mod, ModAuto, ModAutopilot, ModDoubleTime, ModEasy, ModFlashlight, ModHalfTime, ModHardRock, ModHidden, ModNightCore, ModNoFail, ModParseOptions, ModPerfect, ModPrecise, ModReallyEasy, ModRelax, ModScoreV2, ModSmallCircle, ModSpunOut, ModSuddenDeath, ModTouchDevice, ModUtil, OsuAPIRequestBuilder, OsuAPIResponse, OsuHitWindow, PathApproximator, PathType, Precision, RGBColor, RequestResponse, SampleBank, SampleBankInfo, SampleControlPoint, SampleControlPointManager, Slider, SliderHead, SliderPath, SliderRepeat, SliderTail, SliderTick, Spinner, Storyboard, StoryboardAnimation, StoryboardCommandType, StoryboardDecoder, StoryboardElement, StoryboardEncoder, StoryboardEventType, StoryboardLayer, StoryboardLayerType, StoryboardParameterCommandType, StoryboardSample, StoryboardSprite, TimingControlPoint, TimingControlPointManager, Utils, Vector2, modes, objectTypes, rankedStatus };