@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250825020008 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@league-of-foundry-developers/foundry-vtt-types",
4
- "version": "13.346.0-beta.20250825020008",
4
+ "version": "13.346.0-beta.20250825021358",
5
5
  "description": "TypeScript type definitions for Foundry VTT",
6
6
  "type": "module",
7
7
  "types": "./src/index.d.mts",
@@ -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 till v14
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) or (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] (default: `0`)
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 Use Math.normalizeDegrees(degrees: number): number.
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?: number): number;
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
- * (default: `1`)
96
- * @param func - The optional math function to use for oscillation.
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
- func?: (radians: number) => number,
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
- * @returns The signed number as a string
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 nearest number which is a multiple of a given interval
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 to round the number to the nearest multiple of
42
- * (default: `1`)
43
- * @param method - The rounding method in: round, ceil, floor
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
- * ```typescript
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 {@link NumberInstance.between | `Number#between`}
76
+ * @see {@linkcode Number#between}
73
77
  */
74
78
  between(num: number, a: number, b: number, inclusive?: boolean): boolean;
75
79
 
@@ -2,20 +2,13 @@ export {};
2
2
 
3
3
  declare global {
4
4
  interface Set<T> {
5
- /**
6
- * Return the difference of two sets.
7
- * @param other - Some other set to compare against
8
- * @returns The difference defined as objects in this which are not present in other
9
- */
10
- difference(other: Set<T>): Set<T>;
11
-
12
5
  /**
13
6
  * Test whether this set is equal to some other set.
14
7
  * Sets are equal if they share the same members, independent of order
15
8
  * @param other - Some other set to compare against
16
9
  * @returns Are the sets equal?
17
10
  */
18
- equals(other: Set<T>): boolean;
11
+ equals(other: ReadonlySetLike<unknown>): boolean;
19
12
 
20
13
  /**
21
14
  * Return the first value from the set.
@@ -23,27 +16,22 @@ declare global {
23
16
  */
24
17
  first(): T | undefined;
25
18
 
26
- /**
27
- * Return the intersection of two sets.
28
- * @param other - Some other set to compare against
29
- * @returns The intersection of both sets
30
- */
31
- intersection(other: Set<T>): Set<T>;
32
-
33
19
  /**
34
20
  * Test whether this set has an intersection with another set.
35
21
  * @param other - Another set to compare against
36
22
  * @returns Do the sets intersect?
23
+ * @remarks Just returns {@linkcode Set.isDisjointFrom | !this.isDisjointFrom(other)}
37
24
  */
38
- intersects(other: Set<T>): boolean;
25
+ intersects(other: ReadonlySetLike<unknown>): boolean;
39
26
 
40
27
  /**
41
28
  * Test whether this set is a subset of some other set.
42
29
  * A set is a subset if all its members are also present in the other set.
43
30
  * @param other - Some other set that may be a subset of this one
44
31
  * @returns Is the other set a subset of this one?
32
+ * @deprecated "`Set#isSubset` is deprecated in favor of the native {@linkcode Set.isSubsetOf | Set#isSubsetOf}." (since v13, until v15)
45
33
  */
46
- isSubset(other: Set<T>): boolean;
34
+ isSubset(other: ReadonlySetLike<unknown>): boolean;
47
35
 
48
36
  /**
49
37
  * Convert a set to a JSON object by mapping its contents to an array
@@ -53,15 +41,16 @@ declare global {
53
41
 
54
42
  /**
55
43
  * Test whether every element in this Set satisfies a certain test criterion.
56
- * @see {@link Array.every | `Array#every`}
44
+ * @see {@linkcode Array.every | Array#every}
57
45
  * @param test - The test criterion to apply. Positional arguments are the value, the index of iteration, and the set being tested.
58
46
  * @returns Does every element in the set satisfy the test criterion?
59
47
  */
48
+ every<S extends T>(/** @immediate */ test: (value: T, index: number, set: Set<T>) => value is S): this is Set<S>;
60
49
  every(/** @immediate */ test: (value: T, index: number, set: Set<T>) => boolean): boolean;
61
50
 
62
51
  /**
63
52
  * Filter this set to create a subset of elements which satisfy a certain test criterion.
64
- * @see {@link Array.filter | `Array#filter`}
53
+ * @see {@linkcode Array.filter | Array#filter}
65
54
  * @param test - The test criterion to apply. Positional arguments are the value, the index of iteration, and the set being filtered.
66
55
  * @returns A new Set containing only elements which satisfy the test criterion.
67
56
  */
@@ -70,7 +59,7 @@ declare global {
70
59
 
71
60
  /**
72
61
  * Find the first element in this set which satisfies a certain test criterion.
73
- * @see {@link Array.find | `Array#find`}
62
+ * @see {@linkcode Array.find | Array#find}
74
63
  * @param test - The test criterion to apply. Positional arguments are the value, the index of iteration, and the set being searched.
75
64
  * @returns The first element in the set which satisfies the test criterion, or undefined.
76
65
  */
@@ -79,7 +68,7 @@ declare global {
79
68
 
80
69
  /**
81
70
  * Create a new Set where every element is modified by a provided transformation function.
82
- * @see {@link Array.map | `Array#map`}
71
+ * @see {@linkcode Array.map | Array#map}
83
72
  * @param transform - The transformation function to apply.Positional arguments are the value, the index of iteration, and the set being transformed.
84
73
  * @returns A new Set of equal size containing transformed elements.
85
74
  */
@@ -87,19 +76,16 @@ declare global {
87
76
 
88
77
  /**
89
78
  * Create a new Set with elements that are filtered and transformed by a provided reducer function.
90
- * @see {@link Array.reduce | `Array#reduce`}
79
+ * @see {@linkcode Array.reduce | Array#reduce}
91
80
  * @param reducer - A reducer function applied to each value. Positional arguments are the accumulator, the value, the index of iteration, and the set being reduced.
92
- * @param accumulator - The initial value of the returned accumulator.
81
+ * @param initial - The initial value of the returned accumulator.
93
82
  * @returns The final value of the accumulator.
94
83
  */
95
- reduce<V>(
96
- /** @immediate */ reducer: (accumulator: V, value: T, index: number, set: Set<T>) => V,
97
- accumulator: V,
98
- ): V;
84
+ reduce<V>(/** @immediate */ reducer: (accumulator: V, value: T, index: number, set: Set<T>) => V, initial: V): V;
99
85
 
100
86
  /**
101
87
  * Test whether any element in this Set satisfies a certain test criterion.
102
- * @see {@link Array.some | `Array#some`}
88
+ * @see {@linkcode Array.some | Array#some}
103
89
  * @param test - The test criterion to apply. Positional arguments are the value, the index of iteration, and the set being tested.
104
90
  * @returns Does any element in the set satisfy the test criterion?
105
91
  */
@@ -9,12 +9,13 @@ declare global {
9
9
 
10
10
  /**
11
11
  * Compare this string (x) with the other string (y) by comparing each character's Unicode code point value.
12
+ * Returns a negative Number if x \< y, a positive Number if x\> y, or a zero otherwise.
12
13
  * This is the same comparison function that used by Array#sort if the compare function argument is omitted.
13
14
  * The result is host/locale-independent.
14
15
  * @param other - The other string to compare this string to.
15
16
  * @returns A negative Number if x \< y, a positive Number if x \> y, or a zero otherwise.
16
17
  */
17
- compare<S extends string>(this: S, other: string): number;
18
+ compare<S extends string>(this: S, other: string): -1 | 0 | 1;
18
19
 
19
20
  /**
20
21
  * Convert a string to Title Case where the first letter of each word is capitalized
@@ -3,11 +3,15 @@ export {};
3
3
  declare global {
4
4
  // Non-functional due to upstream
5
5
  // https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1379
6
- // declare const URL: {
6
+ // Foundry's override is redundant in 2025, as the native `URL.parse` (https://developer.mozilla.org/en-US/docs/Web/API/URL/parse_static)
7
+ // is a drop-in replacement
8
+ // const URL: {
7
9
  // prototype: URL;
8
10
  // new (url: string | URL, base?: string | URL): URL;
9
11
  // createObjectURL(obj: Blob | MediaSource): string;
10
12
  // revokeObjectURL(url: string): void;
13
+ // canParse(url: string | URL, base?: string | URL): boolean;
14
+ // parse(url: string | URL, base?: string | URL): URL | null;
11
15
  // /**
12
16
  // * Attempt to parse a URL without throwing an error.
13
17
  // * @param url - The string to parse.
@@ -82,7 +82,7 @@ export type IntentionalPartial<T extends object> = Partial<T>;
82
82
  *
83
83
  * @example
84
84
  * ```ts
85
- * // The `const T` allows inference to be a bit more specific. This is useful for a utility type like this.`
85
+ * // The `const T` allows inference to be a bit more specific. This is useful for a utility type like this.
86
86
  * function takesNumber<const T>(input: OverlapsWith<T, number>): void {
87
87
  * // This function body is an example of a method this might be useful for.
88
88
  * // If the input isn't an number it simply returns in this case.