@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250825015921 → 13.346.0-beta.20250825021358
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 +1 -1
- package/src/configuration/configuration.d.mts +3 -3
- package/src/foundry/client/audio/_types.d.mts +11 -0
- package/src/foundry/client/audio/biquad.d.mts +7 -9
- package/src/foundry/client/audio/cache.d.mts +3 -2
- package/src/foundry/client/audio/convolver.d.mts +2 -6
- package/src/foundry/client/audio/helper.d.mts +263 -87
- package/src/foundry/client/audio/sound.d.mts +172 -70
- package/src/foundry/client/audio/timeout.d.mts +9 -3
- package/src/foundry/common/primitives/math.d.mts +19 -17
- package/src/foundry/common/primitives/number.d.mts +17 -13
- package/src/foundry/common/primitives/set.d.mts +14 -28
- package/src/foundry/common/primitives/string.d.mts +2 -1
- package/src/foundry/common/primitives/url.d.mts +5 -1
- package/src/utils/index.d.mts +1 -1
@@ -1,13 +1,16 @@
|
|
1
|
-
import type { Brand, InexactPartial, MaybePromise,
|
1
|
+
import type { Brand, InexactPartial, MaybePromise, Identity, IntentionalPartial } from "#utils";
|
2
2
|
import type EventEmitterMixin from "#common/utils/event-emitter.d.mts";
|
3
3
|
import type { AmbientSound } from "#client/canvas/placeables/_module.d.mts";
|
4
|
+
import type { Canvas } from "#client/canvas/_module.d.mts";
|
5
|
+
import type { PointSoundSource } from "#client/canvas/sources/_module.d.mts";
|
6
|
+
import type { AudioTimeout } from "./_module.d.mts";
|
4
7
|
|
5
8
|
declare namespace Sound {
|
6
9
|
interface Any extends AnySound {}
|
7
10
|
interface AnyConstructor extends Identity<typeof AnySound> {}
|
8
11
|
|
9
12
|
/** @internal */
|
10
|
-
type _ConstructorOptions =
|
13
|
+
type _ConstructorOptions = InexactPartial<{
|
11
14
|
/**
|
12
15
|
* Force use of an AudioBufferSourceNode even if the audio duration is long
|
13
16
|
* @defaultValue `false`
|
@@ -38,21 +41,19 @@ declare namespace Sound {
|
|
38
41
|
}
|
39
42
|
|
40
43
|
/** @internal */
|
41
|
-
type _LoadOptions =
|
44
|
+
type _LoadOptions = InexactPartial<{
|
42
45
|
/**
|
43
46
|
* Automatically begin playback of the sound once loaded
|
44
47
|
* @defaultValue `false`
|
45
48
|
*/
|
46
49
|
autoplay: boolean;
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
autoplayOptions: Sound.PlaybackOptions;
|
55
|
-
}>;
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Playback options passed to Sound#play, if autoplay
|
53
|
+
* @defaultValue `{}`
|
54
|
+
*/
|
55
|
+
autoplayOptions: Sound.PlaybackOptions;
|
56
|
+
}>;
|
56
57
|
|
57
58
|
interface LoadOptions extends _LoadOptions {}
|
58
59
|
|
@@ -60,10 +61,9 @@ declare namespace Sound {
|
|
60
61
|
* Since `Sound##playback` isn't exposed, this interface can *just* be accurate to what's allowable to pass
|
61
62
|
* to {@link Sound.play | `Sound#play`} or {@link Sound.stop | `#stop`}, which in reality is what's allowed
|
62
63
|
* by `Sound##configurePlayback`
|
63
|
-
*
|
64
64
|
* @internal
|
65
65
|
*/
|
66
|
-
type _PlaybackOptions =
|
66
|
+
type _PlaybackOptions = InexactPartial<{
|
67
67
|
/**
|
68
68
|
* A delay in seconds by which to delay playback
|
69
69
|
* @defaultValue `0`
|
@@ -87,49 +87,54 @@ declare namespace Sound {
|
|
87
87
|
/**
|
88
88
|
* Should sound playback loop?
|
89
89
|
* @defaultValue `false`
|
90
|
-
* @remarks The above default is true for initial calls, but the actual default
|
91
|
-
*
|
90
|
+
* @remarks The above default is true for initial calls, but the actual default value, if this is passed nullish or omitted, is whatever the current value in `this##playback`
|
91
|
+
* is, unless this is part of a {@linkcode foundry.canvas.layers.SoundsLayer.playAtPosition | SoundsLayer#playAtPosition} call, as that method always creates a new sound with
|
92
|
+
* no playback history
|
92
93
|
*/
|
93
94
|
loop: boolean;
|
94
95
|
|
95
96
|
/**
|
96
97
|
* Seconds of the AudioBuffer when looped playback should start. Only works for AudioBufferSourceNode.
|
97
98
|
* @defaultValue `0`
|
98
|
-
* @remarks The above default is true for initial calls, but the actual default
|
99
|
-
*
|
99
|
+
* @remarks The above default is true for initial calls, but the actual default value, if this is passed nullish or omitted, is whatever the current value in `this##playback`
|
100
|
+
* is, unless this is part of a {@linkcode foundry.canvas.layers.SoundsLayer.playAtPosition | SoundsLayer#playAtPosition} call, as that method always creates a new sound with
|
101
|
+
* no playback history
|
100
102
|
*/
|
101
103
|
loopStart: number;
|
102
104
|
|
103
105
|
/**
|
104
106
|
* Seconds of the Audio buffer when looped playback should restart. Only works for AudioBufferSourceNode.
|
105
107
|
* @defaultValue `undefined`
|
106
|
-
* @remarks The above default is true for initial calls, but the actual default
|
107
|
-
*
|
108
|
+
* @remarks The above default is true for initial calls, but the actual default value, if this is passed nullish or omitted, is whatever the current value in `this##playback`
|
109
|
+
* is, unless this is part of a {@linkcode foundry.canvas.layers.SoundsLayer.playAtPosition | SoundsLayer#playAtPosition} call, as that method always creates a new sound with
|
110
|
+
* no playback history
|
108
111
|
*/
|
109
112
|
loopEnd: number;
|
110
113
|
|
111
114
|
/**
|
112
115
|
* An offset in seconds at which to start playback
|
113
116
|
* @defaultValue `0`
|
114
|
-
* @remarks The above default is true for initial calls, but the actual default
|
115
|
-
*
|
116
|
-
*
|
117
|
+
* @remarks The above default is true for initial calls, but the actual default value, if this is passed nullish or omitted, is whatever the current value of `loopStart` in
|
118
|
+
* `this##playback` is, unless this is part of a {@linkcode foundry.canvas.layers.SoundsLayer.playAtPosition | SoundsLayer#playAtPosition} call, as that method always creates
|
119
|
+
* a new sound with no playback history
|
117
120
|
*/
|
118
121
|
offset: number;
|
119
122
|
|
120
123
|
/**
|
121
124
|
* A callback function attached to the source node
|
122
125
|
* @defaultValue `null`
|
123
|
-
* @remarks The above default is true for initial calls, but the actual default
|
124
|
-
*
|
126
|
+
* @remarks The above default is true for initial calls, but the actual default value, if this is passed nullish or omitted, is whatever the current value in `this##playback`
|
127
|
+
* is, unless this is part of a {@linkcode foundry.canvas.layers.SoundsLayer.playAtPosition | SoundsLayer#playAtPosition} call, as that method always creates a new sound with
|
128
|
+
* no playback history
|
125
129
|
*/
|
126
130
|
onended: ScheduleCallback | null;
|
127
131
|
|
128
132
|
/**
|
129
133
|
* The volume at which to play the sound
|
130
134
|
* @defaultValue `1.0`
|
131
|
-
* @remarks The above default is true for initial calls, but the actual default
|
132
|
-
*
|
135
|
+
* @remarks The above default is true for initial calls, but the actual default value, if this is passed nullish or omitted, is whatever the current value in `this##playback`
|
136
|
+
* is, unless this is part of a {@linkcode foundry.canvas.layers.SoundsLayer.playAtPosition | SoundsLayer#playAtPosition} call, as that method always creates a new sound with
|
137
|
+
* no playback history
|
133
138
|
*/
|
134
139
|
volume: number;
|
135
140
|
}>;
|
@@ -137,29 +142,78 @@ declare namespace Sound {
|
|
137
142
|
/** @remarks Default values here are what `Sound##configurePlayback` would use if passed an empty object with no prior calls */
|
138
143
|
interface PlaybackOptions extends _PlaybackOptions {}
|
139
144
|
|
145
|
+
/** @remarks `volume` is always overwritten in {@linkcode Sound.playAtPosition | Sound#playAtPosition} */
|
146
|
+
interface PlaybackOptionsPositional extends Omit<PlaybackOptions, "volume"> {}
|
147
|
+
|
148
|
+
/** @remarks The keys omitted are generated from other data passed to {@linkcode Sound.playAtPosition | Sound#playAtPosition} */
|
149
|
+
interface PartialSourceData
|
150
|
+
extends IntentionalPartial<Omit<PointSoundSource.SourceData, "x" | "y" | "elevation" | "radius" | "walls">> {}
|
151
|
+
|
152
|
+
/** @internal */
|
153
|
+
type _PlayAtPositionOptions = InexactPartial<{
|
154
|
+
/**
|
155
|
+
* The maximum volume at which the effect should be played
|
156
|
+
* @defaultValue `1.0`
|
157
|
+
*/
|
158
|
+
volume: number;
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Should volume be attenuated by distance?
|
162
|
+
* @defaultValue `true`
|
163
|
+
*/
|
164
|
+
easing: boolean;
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Should the sound be constrained by walls?
|
168
|
+
* @defaultValue `true`
|
169
|
+
*/
|
170
|
+
walls: boolean;
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Should the sound always be played for GM users regardless of actively controlled tokens?
|
174
|
+
* @defaultValue `true`
|
175
|
+
*/
|
176
|
+
gmAlways: boolean;
|
177
|
+
|
178
|
+
/** A base sound effect to apply to playback */
|
179
|
+
baseEffect: AmbientSoundDocument.Effect;
|
180
|
+
|
181
|
+
/** A muffled sound effect to apply to playback, a sound may only be muffled if it is not constrained by walls */
|
182
|
+
muffledEffect: AmbientSoundDocument.Effect;
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Additional data passed to the SoundSource constructor
|
186
|
+
*/
|
187
|
+
sourceData: Sound.PartialSourceData;
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Additional options passed to {@linkcode Sound.play | Sound#play}
|
191
|
+
*/
|
192
|
+
playbackOptions: Sound.PlaybackOptionsPositional;
|
193
|
+
}>;
|
194
|
+
|
195
|
+
interface PlayAtPositionOptions extends _PlayAtPositionOptions {}
|
196
|
+
|
140
197
|
/** @internal */
|
141
198
|
type _FadeOptions = InexactPartial<{
|
142
199
|
/**
|
143
200
|
* The duration of the fade effect in milliseconds
|
144
201
|
* @defaultValue `1000`
|
145
|
-
* @remarks Can't be `null` as it only has a parameter default
|
146
202
|
*/
|
147
203
|
duration: number;
|
148
204
|
|
149
205
|
/**
|
150
206
|
* The type of fade easing, "linear" or "exponential"
|
151
207
|
* @defaultValue `"linear"`
|
152
|
-
* @remarks Can't be `null` as it only has a parameter default
|
153
208
|
*/
|
154
209
|
type: "linear" | "exponential";
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
}>;
|
210
|
+
|
211
|
+
/**
|
212
|
+
* A volume level to start from, the current volume by default
|
213
|
+
* @defaultValue `this.gain.value`
|
214
|
+
*/
|
215
|
+
from: number;
|
216
|
+
}>;
|
163
217
|
|
164
218
|
interface FadeOptions extends _FadeOptions {}
|
165
219
|
|
@@ -177,7 +231,6 @@ declare class Sound extends EventEmitterMixin() {
|
|
177
231
|
* @param src - The audio source path, either a relative path or a remote URL
|
178
232
|
* @param options - Additional options which configure the Sound
|
179
233
|
*/
|
180
|
-
// options: not null (destructured)
|
181
234
|
constructor(src: string, options?: Sound.ConstructorOptions);
|
182
235
|
|
183
236
|
/**
|
@@ -241,7 +294,7 @@ declare class Sound extends EventEmitterMixin() {
|
|
241
294
|
|
242
295
|
/**
|
243
296
|
* The life-cycle state of the sound.
|
244
|
-
* @defaultValue
|
297
|
+
* @defaultValue {@linkcode Sound.STATES.NONE}
|
245
298
|
*/
|
246
299
|
protected _state: Sound.STATES;
|
247
300
|
|
@@ -268,7 +321,7 @@ declare class Sound extends EventEmitterMixin() {
|
|
268
321
|
|
269
322
|
/**
|
270
323
|
* A convenience reference to the GainNode gain audio parameter.
|
271
|
-
* @remarks `undefined` if {@
|
324
|
+
* @remarks `undefined` if {@linkcode Sound.gainNode | Sound#gainNode} is.
|
272
325
|
*/
|
273
326
|
get gain(): AudioParam | undefined;
|
274
327
|
|
@@ -325,11 +378,8 @@ declare class Sound extends EventEmitterMixin() {
|
|
325
378
|
/**
|
326
379
|
* An internal reference to some object which is managing this Sound instance.
|
327
380
|
* @defaultValue `null`
|
328
|
-
* @
|
329
|
-
*
|
330
|
-
* Only ever set *or* read externally by core, so not protected
|
331
|
-
*
|
332
|
-
* @privateRemarks Foundry types this as `Object|null` but the only place in Core this gets set is in `AmbientSound`, to `this`
|
381
|
+
* @internal
|
382
|
+
* @remarks Only ever set *or* read externally by core, so not protected
|
333
383
|
*/
|
334
384
|
_manager: AmbientSound.Implementation | null;
|
335
385
|
|
@@ -338,14 +388,12 @@ declare class Sound extends EventEmitterMixin() {
|
|
338
388
|
* @param options - Additional options which affect resource loading
|
339
389
|
* @returns A Promise which resolves to the Sound once it is loaded
|
340
390
|
*/
|
341
|
-
// options: not null (destructured)
|
342
391
|
load(options?: Sound.LoadOptions): Promise<this>;
|
343
392
|
|
344
393
|
/**
|
345
394
|
* An inner method which handles loading so that it can be de-duplicated under a single shared Promise resolution.
|
346
395
|
* This method is factored out to allow for subclasses to override loading behavior.
|
347
396
|
* @returns A Promise which resolves once the sound is loaded
|
348
|
-
* @throws An error if loading failed for any reason
|
349
397
|
*/
|
350
398
|
protected _load(): Promise<void>;
|
351
399
|
|
@@ -359,11 +407,60 @@ declare class Sound extends EventEmitterMixin() {
|
|
359
407
|
play(options?: Sound.PlaybackOptions): Promise<this>;
|
360
408
|
|
361
409
|
/**
|
362
|
-
* @deprecated since v12, until v14
|
363
|
-
* @remarks "`Sound#play` now takes an object of playback options instead of positional arguments."
|
410
|
+
* @deprecated "`Sound#play` now takes an object of playback options instead of positional arguments." (since v12, until v14)
|
364
411
|
*/
|
365
412
|
play(offset: number, onended?: Sound.ScheduleCallback | null): Promise<this>;
|
366
413
|
|
414
|
+
/**
|
415
|
+
* Play a one-shot Sound originating from a predefined point on the canvas.
|
416
|
+
* The sound plays locally for the current client only.
|
417
|
+
* To play a sound for all connected clients use {@linkcode foundry.canvas.layers.SoundsLayer.emitAtPosition | SoundsLayer#emitAtPosition}.
|
418
|
+
* A helper which does not depend on a pre-existing Sound instance is available at
|
419
|
+
* {@linkcode foundry.canvas.layers.SoundsLayer.playAtPosition | SoundsLayer#playAtPosition}.
|
420
|
+
*
|
421
|
+
* @param origin - The canvas coordinates from which the sound originates
|
422
|
+
* @param radius - The radius of effect in distance units
|
423
|
+
* @param options - Additional options which configure playback
|
424
|
+
* @returns A Promise which resolves to the played Sound, or null
|
425
|
+
*
|
426
|
+
* Play the sound of a trap springing
|
427
|
+
* @example
|
428
|
+
* ```js
|
429
|
+
* const sound = new Sound("modules/my-module/sounds/spring-trap.ogg", {context: game.audio.environment});
|
430
|
+
* await sound.load();
|
431
|
+
* const origin = {x: 5200, y: 3700}; // The origin point for the sound
|
432
|
+
* const radius = 30; // Audible in a 30-foot radius
|
433
|
+
* await sound.playAtPosition(origin, radius);
|
434
|
+
* ```
|
435
|
+
*
|
436
|
+
* A Token casts a spell
|
437
|
+
* @example
|
438
|
+
* ```js
|
439
|
+
* const sound = new Sound("modules/my-module/sounds/spells-sprite.ogg", {context: game.audio.environment});
|
440
|
+
* const origin = token.center; // The origin point for the sound
|
441
|
+
* const radius = 60; // Audible in a 60-foot radius
|
442
|
+
* await sound.playAtPosition(origin, radius, {
|
443
|
+
* walls: false, // Not constrained by walls with a lowpass muffled effect
|
444
|
+
* muffledEffect: {type: "lowpass", intensity: 6},
|
445
|
+
* sourceData: {
|
446
|
+
* angle: 120, // Sound emitted at a limited angle
|
447
|
+
* rotation: 270 // Configure the direction of sound emission
|
448
|
+
* }
|
449
|
+
* playbackOptions: {
|
450
|
+
* loopStart: 12, // Audio sprite timing
|
451
|
+
* loopEnd: 16,
|
452
|
+
* fade: 300, // Fade-in 300ms
|
453
|
+
* onended: () => console.log("Do something after the spell sound has played")
|
454
|
+
* }
|
455
|
+
* });
|
456
|
+
* ```
|
457
|
+
*/
|
458
|
+
playAtPosition(
|
459
|
+
origin: Canvas.PossiblyElevatedPoint,
|
460
|
+
radius: number,
|
461
|
+
options?: Sound.PlayAtPositionOptions,
|
462
|
+
): Promise<this | null>;
|
463
|
+
|
367
464
|
/**
|
368
465
|
* Begin playback for the configured pipeline and playback options.
|
369
466
|
* This method is factored out so that subclass implementations of Sound can implement alternative behavior.
|
@@ -372,9 +469,10 @@ declare class Sound extends EventEmitterMixin() {
|
|
372
469
|
|
373
470
|
/**
|
374
471
|
* Pause playback of the Sound.
|
375
|
-
* For AudioBufferSourceNode this stops playback after recording the current time.
|
376
|
-
* Calling Sound#play will resume playback from the pausedTime unless some other offset is passed.
|
377
|
-
* For a MediaElementAudioSourceNode this simply calls the HTMLAudioElement#pause method directly.
|
472
|
+
* For {@linkcode AudioBufferSourceNode} this stops playback after recording the current time.
|
473
|
+
* Calling {@linkcode Sound.play | Sound#play} will resume playback from the {@linkcode Sound.pauseTime | #pausedTime} unless some other offset is passed.
|
474
|
+
* For a {@linkcode MediaElementAudioSourceNode} this simply calls the {@linkcode HTMLAudioElement.pause | HTMLAudioElement#pause} method directly.
|
475
|
+
* @remarks
|
378
476
|
* @throws If called while the Sound isn't playing
|
379
477
|
*/
|
380
478
|
pause(): void;
|
@@ -392,7 +490,6 @@ declare class Sound extends EventEmitterMixin() {
|
|
392
490
|
* @param options - Options which configure the stopping of sound playback
|
393
491
|
* @returns A Promise which resolves once playback is fully stopped (including fade)
|
394
492
|
*/
|
395
|
-
// options: not null (parameter default only, destructured where forwarded)
|
396
493
|
stop(options?: Sound.PlaybackOptions): Promise<this>;
|
397
494
|
|
398
495
|
/**
|
@@ -407,7 +504,6 @@ declare class Sound extends EventEmitterMixin() {
|
|
407
504
|
* @param options - Additional options that configure the fade operation
|
408
505
|
* @returns A Promise that resolves after the requested fade duration
|
409
506
|
*/
|
410
|
-
// options: not null (destructured)
|
411
507
|
fade(volume: number, options?: Sound.FadeOptions): Promise<void>;
|
412
508
|
|
413
509
|
/**
|
@@ -432,6 +528,18 @@ declare class Sound extends EventEmitterMixin() {
|
|
432
528
|
*/
|
433
529
|
schedule<R extends Sound.ScheduleCallback>(fn: R, playbackTime: number): Promise<Awaited<ReturnType<R>>>;
|
434
530
|
|
531
|
+
/**
|
532
|
+
* Cancel one scheduled event created with {@linkcode Sound.schedule | Sound#schedule}.
|
533
|
+
* You may pass either the {@linkcode AudioTimeout} returned internally or the Promise returned by `Sound#schedule`.
|
534
|
+
* @param handle - The handle to cancel.
|
535
|
+
*/
|
536
|
+
unschedule(handle: AudioTimeout | { timeout: AudioTimeout }): void;
|
537
|
+
|
538
|
+
/**
|
539
|
+
* Cancel all events that are still scheduled for this sound.
|
540
|
+
*/
|
541
|
+
unscheduleAll(): void;
|
542
|
+
|
435
543
|
/**
|
436
544
|
* Update the array of effects applied to a Sound instance.
|
437
545
|
* Optionally a new array of effects can be assigned. If no effects are passed, the current effects are re-applied.
|
@@ -458,48 +566,42 @@ declare class Sound extends EventEmitterMixin() {
|
|
458
566
|
protected _disconnectPipeline(): void;
|
459
567
|
|
460
568
|
/**
|
461
|
-
* @deprecated since v12,
|
462
|
-
* @remarks "`AudioContainer.LOAD_STATES` is deprecated in favor of {@linkcode Sound.STATES}"
|
569
|
+
* @deprecated "`AudioContainer.LOAD_STATES` is deprecated in favor of {@linkcode Sound.STATES}" (since v12, until v14)
|
463
570
|
*/
|
464
571
|
static get LOAD_STATES(): Sound.States;
|
465
572
|
|
466
573
|
/**
|
467
|
-
* @deprecated since v12,
|
468
|
-
* @remarks "`AudioContainer#loadState` is deprecated in favor of {@link Sound._state | `Sound#_state`}"
|
574
|
+
* @deprecated "`AudioContainer#loadState` is deprecated in favor of {@linkcode Sound._state | Sound#_state}" (since v12, until v14)
|
469
575
|
*/
|
470
576
|
get loadState(): Sound.STATES;
|
471
577
|
|
472
578
|
/**
|
473
|
-
* @deprecated since v12,
|
474
|
-
* @remarks "`Sound#container` is deprecated without replacement because the `Sound` and `AudioContainer` classes are now merged"
|
579
|
+
* @deprecated "`Sound#container` is deprecated without replacement because the `Sound` and `AudioContainer` classes are now merged" (since v12, until v14)
|
475
580
|
*/
|
476
581
|
get container(): this;
|
477
582
|
|
478
583
|
/**
|
479
|
-
* @deprecated since v12,
|
480
|
-
* @remarks "`Sound#node` is renamed {@link Sound.sourceNode | `Sound#sourceNode`}"
|
584
|
+
* @deprecated "`Sound#node` is renamed {@linkcode Sound.sourceNode | Sound#sourceNode}" (since v12, until v14)
|
481
585
|
*/
|
482
586
|
get node(): this["sourceNode"];
|
483
587
|
|
484
588
|
/**
|
485
|
-
* @deprecated since v12,
|
486
|
-
* @remarks "`Sound#on` is deprecated in favor of {@link Sound.addEventListener | `Sound#addEventListener`}"
|
589
|
+
* @deprecated "`Sound#on` is deprecated in favor of {@linkcode Sound.addEventListener | Sound#addEventListener}" (since v12, until v14)
|
487
590
|
*/
|
488
591
|
on(eventName: string, fn: EventEmitterMixin.EventListener, options?: EventEmitterMixin.AddListenerOptions): void;
|
489
592
|
|
490
593
|
/**
|
491
|
-
* @deprecated since v12,
|
492
|
-
* @remarks "`Sound#off` is deprecated in favor of {@link Sound.removeEventListener | `Sound#removeEventListener`}"
|
594
|
+
* @deprecated "`Sound#off` is deprecated in favor of {@linkcode Sound.removeEventListener | Sound#removeEventListener}" (since v12, until v14)
|
493
595
|
*/
|
494
596
|
off(eventName: string, fn: EventEmitterMixin.EventListener): void;
|
495
597
|
|
496
598
|
/**
|
497
|
-
* @deprecated since v12,
|
498
|
-
* @remarks
|
499
|
-
*
|
500
|
-
* This method still takes a string, then creates an `Event` with it and passes that along to `dispatchEvent`
|
599
|
+
* @deprecated "`Sound#emit` is deprecated in favor of {@linkcode Sound.dispatchEvent | Sound#dispatchEvent}" (since v12, until v14)
|
600
|
+
* @remarks This method still takes a string, then creates an `Event` with it and passes that along to `dispatchEvent`
|
501
601
|
*/
|
502
602
|
emit(eventName: string): void;
|
603
|
+
|
604
|
+
#Sound: true;
|
503
605
|
}
|
504
606
|
|
505
607
|
export default Sound;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Identity,
|
1
|
+
import type { Identity, InexactPartial } from "#utils";
|
2
2
|
|
3
3
|
/**
|
4
4
|
* A special error class used for cancellation.
|
@@ -56,6 +56,11 @@ declare class AudioTimeout<CallbackReturn = undefined> {
|
|
56
56
|
*/
|
57
57
|
complete: Promise<CallbackReturn> | undefined;
|
58
58
|
|
59
|
+
/**
|
60
|
+
* Is this audio timeout cancelled?
|
61
|
+
*/
|
62
|
+
get cancelled(): boolean;
|
63
|
+
|
59
64
|
/**
|
60
65
|
* Cancel an AudioTimeout by ending it early, rejecting its completion promise, and skipping any callback function.
|
61
66
|
*/
|
@@ -72,11 +77,12 @@ declare class AudioTimeout<CallbackReturn = undefined> {
|
|
72
77
|
* @param options - Additional options which modify timeout behavior
|
73
78
|
* @returns A promise which resolves as a returned value of the callback or void
|
74
79
|
*/
|
75
|
-
// options: not null (destructured where forwarded)
|
76
80
|
static wait<CallbackReturn = undefined>(
|
77
81
|
delayMS: number,
|
78
82
|
options?: AudioTimeout.ConstructorOptions<CallbackReturn>,
|
79
83
|
): Promise<CallbackReturn>;
|
84
|
+
|
85
|
+
#AudioTimeout: true;
|
80
86
|
}
|
81
87
|
|
82
88
|
declare namespace AudioTimeout {
|
@@ -84,7 +90,7 @@ declare namespace AudioTimeout {
|
|
84
90
|
interface AnyConstructor extends Identity<typeof AnyAudioTimeout> {}
|
85
91
|
|
86
92
|
/** @internal */
|
87
|
-
type _ConstructorOptions<Return = undefined> =
|
93
|
+
type _ConstructorOptions<Return = undefined> = InexactPartial<{
|
88
94
|
/** @defaultValue `game.audio.music` */
|
89
95
|
context: AudioContext;
|
90
96
|
|
@@ -4,13 +4,17 @@ declare global {
|
|
4
4
|
interface Math {
|
5
5
|
/**
|
6
6
|
* √3
|
7
|
+
* @remarks Created with `defineProperties` with no options other than `value` specified, making it
|
8
|
+
* `writeable: false, enumerable: false, configurable: false` by default
|
7
9
|
*/
|
8
|
-
SQRT3: 1.7320508075688772;
|
10
|
+
readonly SQRT3: 1.7320508075688772;
|
9
11
|
|
10
12
|
/**
|
11
13
|
* √⅓
|
14
|
+
* @remarks Created with `defineProperties` with no options other than `value` specified, making it
|
15
|
+
* `writeable: false, enumerable: false, configurable: false` by default
|
12
16
|
*/
|
13
|
-
SQRT1_3: 0.5773502691896257;
|
17
|
+
readonly SQRT1_3: 0.5773502691896257;
|
14
18
|
|
15
19
|
/**
|
16
20
|
* Bound a number between some minimum and maximum value, inclusively.
|
@@ -27,7 +31,7 @@ declare global {
|
|
27
31
|
* @param min - The minimum allowed value
|
28
32
|
* @param max - The maximum allowed value
|
29
33
|
* @returns The clamped number
|
30
|
-
* @deprecated since v12
|
34
|
+
* @deprecated "Math.clamped is deprecated in favor of {@linkcode Math.clamp}." (since v12, until v14)
|
31
35
|
*/
|
32
36
|
clamped(num: number, min: number, max: number): number;
|
33
37
|
|
@@ -41,21 +45,22 @@ declare global {
|
|
41
45
|
mix(a: number, b: number, w: number): number;
|
42
46
|
|
43
47
|
/**
|
44
|
-
* Transform an angle in degrees to be bounded within the domain [0, 360
|
48
|
+
* Transform an angle in degrees to be bounded within the domain [0, 360)
|
45
49
|
* @param degrees - An angle in degrees
|
46
|
-
* @returns The same angle on the range [0, 360)
|
50
|
+
* @returns The same angle on the range [0, 360)
|
47
51
|
*/
|
48
52
|
normalizeDegrees(degrees: number): number;
|
49
53
|
|
50
54
|
/**
|
51
55
|
* Transform an angle in degrees to be bounded within the domain [0, 360]
|
52
56
|
* @param degrees - An angle in degrees
|
53
|
-
* @param base - The base angle to normalize to, either 0 for [0, 360) or 360 for (0, 360]
|
57
|
+
* @param base - The base angle to normalize to, either 0 for [0, 360) or 360 for (0, 360]
|
54
58
|
* @returns The same angle on the range [0, 360) or (0, 360]
|
55
|
-
* @deprecated since v12, until v14
|
56
|
-
* @remarks
|
59
|
+
* @deprecated "`Math.normalizeDegrees(degrees, base)` is deprecated." (since v12, until v14)
|
60
|
+
* @remarks Despite the parameter description, passing *any* non-`undefined` value for `base` changes behaviour.
|
61
|
+
* This is accurate to the behaviour in v11 and earlier, it's unclear why this wasn't originally a boolean.
|
57
62
|
*/
|
58
|
-
normalizeDegrees(degrees: number, base
|
63
|
+
normalizeDegrees(degrees: number, base: number): number;
|
59
64
|
|
60
65
|
/**
|
61
66
|
* Transform an angle in radians to be bounded within the domain [-PI, PI]
|
@@ -68,7 +73,7 @@ declare global {
|
|
68
73
|
* Round a floating point number to a certain number of decimal places
|
69
74
|
* @param number - A floating point number
|
70
75
|
* @param places - An integer number of decimal places
|
71
|
-
* @deprecated since v12, until v14
|
76
|
+
* @deprecated "`Math.roundDecimals` is deprecated." (since v12, until v14)
|
72
77
|
*/
|
73
78
|
roundDecimals(number: number, places: number): number;
|
74
79
|
|
@@ -91,12 +96,9 @@ declare global {
|
|
91
96
|
* @param minVal - The minimal value of the oscillation.
|
92
97
|
* @param maxVal - The maximum value of the oscillation.
|
93
98
|
* @param t - The time value.
|
94
|
-
* @param p - The period (must be nonzero).
|
95
|
-
*
|
96
|
-
* @
|
97
|
-
* (default: `Math.cos`)
|
98
|
-
* Its period must be 2π
|
99
|
-
* @returns The oscillation according to t. `((maxValue - minValue) * (f(2π * t / p) + 1) / 2) + minValue`
|
99
|
+
* @param p - The period (must be nonzero). (default: `1`)
|
100
|
+
* @param fn - The optional math function to use for oscillation. Its period must be 2π (default: `Math.cos`)
|
101
|
+
* @returns The oscillation according to t. `((maxVal - minVal) * (fn(2π * t / p) + 1) / 2) + minVal`
|
100
102
|
*/
|
101
103
|
oscillation(
|
102
104
|
minVal: number,
|
@@ -105,7 +107,7 @@ declare global {
|
|
105
107
|
p?: number,
|
106
108
|
|
107
109
|
/** @immediate */
|
108
|
-
|
110
|
+
fn?: (radians: number) => number,
|
109
111
|
): number;
|
110
112
|
}
|
111
113
|
}
|
@@ -5,8 +5,7 @@ declare global {
|
|
5
5
|
/**
|
6
6
|
* Test for near-equivalence of two numbers within some permitted epsilon
|
7
7
|
* @param n - Some other number
|
8
|
-
* @param e - Some permitted epsilon, by default 1e-8
|
9
|
-
(default: `1e-8`)
|
8
|
+
* @param e - Some permitted epsilon, by default 1e-8 (default: `1e-8`)
|
10
9
|
* @returns Are the numbers almost equal?
|
11
10
|
*/
|
12
11
|
almostEqual(n: number, e?: number): boolean;
|
@@ -29,39 +28,44 @@ declare global {
|
|
29
28
|
paddedString(digits: number): string;
|
30
29
|
|
31
30
|
/**
|
32
|
-
* Return a string prefaced by the sign of the number (+) or (-)
|
33
|
-
*
|
31
|
+
* Return a locally formatted string prefaced by the explicit sign of the number (+) or (-). Use of this method is
|
32
|
+
* intended for display purposes only.
|
33
|
+
* @returns The signed number as a locally formatted string
|
34
|
+
* @remarks Uses `−` (`U+2212 Minus Sign`) instead of a regular ASCII `-`
|
34
35
|
*/
|
35
36
|
signedString(): string;
|
36
37
|
|
37
38
|
/**
|
38
|
-
* Round a number to the
|
39
|
+
* Round a number to the closest number which subtracted from the base is a multiple of the provided interval.
|
39
40
|
* This is a convenience function intended to humanize issues of floating point precision.
|
40
41
|
* The interval is treated as a standard string representation to determine the amount of decimal truncation applied.
|
41
|
-
* @param interval - The interval
|
42
|
-
*
|
43
|
-
* @param
|
44
|
-
* (default: `"round"`)
|
42
|
+
* @param interval - The step interval (default: `1`)
|
43
|
+
* @param method - The rounding method (default: `"round"`)
|
44
|
+
* @param base - The step base (default: `0`)
|
45
45
|
* @returns The rounded number
|
46
46
|
*
|
47
47
|
* @example Round a number to the nearest step interval
|
48
|
-
* ```
|
48
|
+
* ```js
|
49
49
|
* let n = 17.18;
|
50
50
|
* n.toNearest(5); // 15
|
51
51
|
* n.toNearest(10); // 20
|
52
52
|
* n.toNearest(10, "floor"); // 10
|
53
53
|
* n.toNearest(10, "ceil"); // 20
|
54
54
|
* n.toNearest(0.25); // 17.25
|
55
|
+
* n.toNearest(2, "round", 1); // 17
|
55
56
|
* ```
|
57
|
+
*
|
58
|
+
* @remarks
|
59
|
+
* @throws If `interval` is negative
|
56
60
|
*/
|
57
|
-
toNearest(interval?: number, method?: "round" | "ceil" | "floor"): number;
|
61
|
+
toNearest(interval?: number, method?: "round" | "ceil" | "floor", base?: number): number;
|
58
62
|
|
59
63
|
/**
|
60
64
|
* A faster numeric between check which avoids type coercion to the Number object.
|
61
65
|
* Since this avoids coercion, if non-numbers are passed in unpredictable results will occur. Use with caution.
|
62
66
|
* @param a - The lower-bound
|
63
67
|
* @param b - The upper-bound
|
64
|
-
* @param inclusive - Include the bounding values as a true result?
|
68
|
+
* @param inclusive - Include the bounding values as a true result? (default: `true`)
|
65
69
|
* @returns Is the number between the two bounds?
|
66
70
|
*/
|
67
71
|
between(a: number, b: number, inclusive?: boolean): boolean;
|
@@ -69,7 +73,7 @@ declare global {
|
|
69
73
|
|
70
74
|
interface NumberConstructor {
|
71
75
|
/**
|
72
|
-
* @see {@
|
76
|
+
* @see {@linkcode Number#between}
|
73
77
|
*/
|
74
78
|
between(num: number, a: number, b: number, inclusive?: boolean): boolean;
|
75
79
|
|