@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250731052244 → 13.346.0-beta.20250801172911

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.
Files changed (40) hide show
  1. package/package.json +1 -1
  2. package/src/configuration/hooks.d.mts +2 -1
  3. package/src/foundry/client/canvas/animation/_types.d.mts +1 -1
  4. package/src/foundry/client/canvas/animation/canvas-animation.d.mts +95 -44
  5. package/src/foundry/client/canvas/animation/chat-bubbles.d.mts +79 -8
  6. package/src/foundry/client/canvas/animation/smooth-noise.d.mts +23 -8
  7. package/src/foundry/client/canvas/board.d.mts +180 -31
  8. package/src/foundry/client/canvas/groups/canvas-group-mixin.d.mts +4 -3
  9. package/src/foundry/client/canvas/groups/visibility.d.mts +104 -60
  10. package/src/foundry/client/canvas/interaction/mouse-handler.d.mts +143 -85
  11. package/src/foundry/client/canvas/interaction/ping/alert.d.mts +14 -11
  12. package/src/foundry/client/canvas/interaction/ping/arrow.d.mts +5 -5
  13. package/src/foundry/client/canvas/interaction/ping/chevron.d.mts +27 -56
  14. package/src/foundry/client/canvas/interaction/ping/ping.d.mts +22 -17
  15. package/src/foundry/client/canvas/interaction/ping/pulse.d.mts +15 -44
  16. package/src/foundry/client/canvas/interaction/render-flags.d.mts +29 -15
  17. package/src/foundry/client/canvas/interaction/ruler/base-ruler.d.mts +230 -3
  18. package/src/foundry/client/canvas/interaction/ruler/ruler.d.mts +139 -434
  19. package/src/foundry/client/canvas/layers/controls.d.mts +1 -1
  20. package/src/foundry/client/canvas/layers/masks/vision.d.mts +28 -40
  21. package/src/foundry/client/canvas/perception/detection-mode.d.mts +62 -30
  22. package/src/foundry/client/canvas/perception/detection-modes/darkvision.d.mts +3 -2
  23. package/src/foundry/client/canvas/perception/detection-modes/invisibility-perception.d.mts +8 -3
  24. package/src/foundry/client/canvas/perception/detection-modes/light-perception.d.mts +6 -5
  25. package/src/foundry/client/canvas/perception/detection-modes/super-perception.d.mts +8 -3
  26. package/src/foundry/client/canvas/perception/detection-modes/tremor-perception.d.mts +8 -3
  27. package/src/foundry/client/canvas/perception/fog.d.mts +43 -42
  28. package/src/foundry/client/canvas/perception/perception-manager.d.mts +21 -23
  29. package/src/foundry/client/canvas/perception/vision-mode.d.mts +73 -62
  30. package/src/foundry/client/canvas/placeables/tokens/ring.d.mts +2 -2
  31. package/src/foundry/client/canvas/placeables/tokens/ruler.d.mts +5 -40
  32. package/src/foundry/client/canvas/sources/base-light-source.d.mts +4 -0
  33. package/src/foundry/client/canvas/sources/point-light-source.d.mts +2 -2
  34. package/src/foundry/client/canvas/sources/rendered-effect-source.d.mts +12 -5
  35. package/src/foundry/client/config.d.mts +4 -0
  36. package/src/foundry/client/documents/user.d.mts +2 -2
  37. package/src/foundry/client/hooks.d.mts +7 -0
  38. package/src/foundry/common/grid/base.d.mts +7 -1
  39. package/src/foundry/common/utils/color.d.mts +2 -1
  40. package/src/foundry/common/utils/event-emitter.d.mts +2 -1
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.20250731052244",
4
+ "version": "13.346.0-beta.20250801172911",
5
5
  "description": "TypeScript type definitions for Foundry VTT",
6
6
  "type": "module",
7
7
  "types": "./src/index.d.mts",
@@ -14,7 +14,8 @@ export interface DeprecatedHookConfig {
14
14
  * @remarks This is called by {@linkcode Hooks.call}.
15
15
  * @remarks An explicit return value of `false` prevents the chat bubble being shown.
16
16
  * @see {@link ChatBubbles.say | `ChatBubbles#say`}
17
- * @deprecated since v13 until v15
17
+ * @deprecated "The `chatBubble` hook is deprecated. Please use `chatBubbleHTML` instead, which now passes
18
+ * an HTMLElement argument instead of jQuery." (since v13, until v15)
18
19
  */
19
20
  chatBubble: (
20
21
  token: Token.Implementation,
@@ -11,7 +11,7 @@ import type { CanvasAnimation } from "./_module.mjs";
11
11
 
12
12
  export {};
13
13
 
14
- type CanvasAnimationAttribute = CanvasAnimation.Attribute;
14
+ type CanvasAnimationAttribute = CanvasAnimation.ProcessedAttribute;
15
15
 
16
16
  type CanvasAnimationEasingFunction = CanvasAnimation.EasingFunction;
17
17
 
@@ -1,4 +1,4 @@
1
- import type { PropertiesOfType, Brand, NullishProps, AnyObject, Identity } from "#utils";
1
+ import type { PropertiesOfType, Brand, Identity, InexactPartial, AllKeysOf } from "#utils";
2
2
 
3
3
  /**
4
4
  * A helper class providing utility methods for PIXI Canvas animation
@@ -15,8 +15,6 @@ declare class CanvasAnimation {
15
15
  /**
16
16
  * Track an object of active animations by name, context, and function
17
17
  * This allows a currently playing animation to be referenced and terminated
18
- * @privateRemarks Foundry does not account for the possibility of Symbol animation names and types the keys as simply `string`,
19
- * despite typing `CanvasAnimationOptions.name` as `string | symbol`
20
18
  */
21
19
  static animations: Record<PropertyKey, CanvasAnimation.AnimationData>;
22
20
 
@@ -46,10 +44,12 @@ declare class CanvasAnimation {
46
44
  * ];
47
45
  * CanvasAnimation.animate(attributes, {duration:500});
48
46
  * ```
47
+ *
48
+ * @privateRemarks `extends object` to allow {@linkcode foundry.canvas.interaction.Ping._animateFrame | Ping#_animateFrame} to take `CanvasAnimation.AnimationData<this>`
49
49
  */
50
- static animate(
51
- attributes: CanvasAnimation.Attribute[],
52
- options?: CanvasAnimation.AnimateOptions,
50
+ static animate<Parents extends object[] = object[]>(
51
+ attributes: CanvasAnimation.Attributes<Parents>,
52
+ options?: CanvasAnimation.AnimateOptions<Parents>,
53
53
  ): CanvasAnimation.AnimateReturn;
54
54
 
55
55
  /**
@@ -65,6 +65,13 @@ declare class CanvasAnimation {
65
65
  */
66
66
  static terminateAnimation(name: PropertyKey): void;
67
67
 
68
+ /**
69
+ * Terminate all active animations in progress, forcibly resolving each one with `false`.
70
+ * This method returns a Promise that resolves once all animations have been terminated and removed.
71
+ * @returns A promise that resolves when all animations have been forcibly terminated.
72
+ */
73
+ static terminateAll(): Promise<void>;
74
+
68
75
  /**
69
76
  * Cosine based easing with smooth in-out.
70
77
  * @param pt - The proportional animation timing on [0,1]
@@ -85,6 +92,8 @@ declare class CanvasAnimation {
85
92
  * @returns The eased animation progress on [0,1]
86
93
  */
87
94
  static easeInCircle(pt: number): number;
95
+
96
+ static #CanvasAnimation: true;
88
97
  }
89
98
 
90
99
  declare namespace CanvasAnimation {
@@ -116,28 +125,42 @@ declare namespace CanvasAnimation {
116
125
  readonly COMPLETED: 2 & CanvasAnimation.STATES;
117
126
  }
118
127
 
119
- type OnTickFunction = (dt: number, animation: CanvasAnimation.AnimationData) => void;
128
+ /**
129
+ * @privateRemarks `extends object` to allow {@linkcode foundry.canvas.interaction.Ping._animateFrame | Ping#_animateFrame} to take `CanvasAnimation.AnimationData<this>`
130
+ */
131
+ type OnTickFunction<AnimationParent extends object = object> = (
132
+ dt: number,
133
+ animation: CanvasAnimation.AnimationData<AnimationParent>,
134
+ ) => void;
120
135
 
121
- /** @internal */
122
- type _AnimateOptions = NullishProps<{
136
+ /**
137
+ * `extends object` to allow {@linkcode foundry.canvas.interaction.Ping._animateFrame | Ping#_animateFrame} to take `CanvasAnimation.AnimationData<this>`
138
+ * @internal
139
+ */
140
+ type _AnimateOptions<AnimationParent extends object = object> = InexactPartial<{
123
141
  /**
124
142
  * A DisplayObject which defines context to the PIXI.Ticker function
125
- * @defaultValue `canvas.stage`
126
- * @remarks `null` is allowed here because despite only having a parameter default,
127
- * the (afaict, unexported) PIXI class `TickerListener`'s constructor (where this prop
128
- * ends up) accepts `null` for context. This is likely never actually desireable, however.
143
+ * @defaultValue {@linkcode foundry.canvas.Canvas.stage | canvas.stage}
129
144
  */
130
145
  context: PIXI.DisplayObject;
131
146
 
132
- /** A unique name which can be used to reference the in-progress animation */
147
+ /**
148
+ * A unique name which can be used to reference the in-progress animation
149
+ * @defaultValue `Symbol("CanvasAnimation")`
150
+ */
133
151
  name: PropertyKey;
134
152
 
135
153
  /**
136
- * A priority in PIXI.UPDATE_PRIORITY which defines when the animation
154
+ * A duration in milliseconds over which the animation should occur
155
+ * @defaultValue `1000`
156
+ */
157
+ duration: number;
158
+
159
+ /**
160
+ * A priority in {@linkcode PIXI.UPDATE_PRIORITY} which defines when the animation
137
161
  * should be evaluated related to others
138
- * @defaultValue `PIXI.UPDATE_PRIORITY.LOW + 1`
139
- * @remarks Default provided by `??=` in function body. Numerical values between `UPDATE_PRIORITY`
140
- * levels are valid but must be cast `as PIXI.UPDATE_PRIORITY` due to the Branded enum
162
+ * @defaultValue {@linkcode PIXI.UPDATE_PRIORITY.LOW}`+ 1`
163
+ * @remarks Numerical values between `UPDATE_PRIORITY` levels are valid but must be cast `as PIXI.UPDATE_PRIORITY` due to the Branded enum
141
164
  */
142
165
  priority: PIXI.UPDATE_PRIORITY;
143
166
 
@@ -148,64 +171,91 @@ declare namespace CanvasAnimation {
148
171
  easing: CanvasAnimation.EasingFunction;
149
172
 
150
173
  /** A callback function which fires after every frame */
151
- ontick: OnTickFunction;
174
+ ontick: OnTickFunction<AnimationParent>;
152
175
 
153
176
  /** The animation isn't started until this promise resolves */
154
- wait: Promise<unknown>;
177
+ wait: Promise<void>;
155
178
  }>;
156
179
 
180
+ /**
181
+ * @privateRemarks `extends object[]` to allow {@linkcode foundry.canvas.interaction.Ping._animateFrame | Ping#_animateFrame} to take `CanvasAnimation.AnimationData<this>`
182
+ */
183
+ interface AnimateOptions<Parents extends object[] = object[]>
184
+ extends CanvasAnimation._AnimateOptions<Parents[number]> {}
185
+
157
186
  /** @internal */
158
- type _AnimationAttribute = NullishProps<{
187
+ type _AnimationAttribute = InexactPartial<{
159
188
  /**
160
- * An initial value of the attribute, otherwise parent[attribute] is used
161
- * @remarks Will be replaced inside `.animate` with `Color.from(from)` if `to` is a `Color`
189
+ * An initial value of the attribute, otherwise `parent[attribute]` is used
190
+ * @remarks Will be replaced inside {@linkcode CanvasAnimation.animate} with {@linkcode Color.from | Color.from(from)} if `to` is a `Color`
162
191
  */
163
192
  from: number | Color;
164
193
  }>;
165
194
 
166
- interface Attribute {
167
- /** The attribute name being animated */
168
- attribute: string;
195
+ /**
196
+ * @privateRemarks `extends object` to allow {@linkcode foundry.canvas.interaction.Ping._animateFrame | Ping#_animateFrame} to take `CanvasAnimation.AnimationData<this>`
197
+ */
198
+ type Attributes<Parents extends object[]> = {
199
+ [K in keyof Parents]: Attribute<Parents[K]>;
200
+ };
201
+
202
+ /**
203
+ * @remarks The portion of Foundry's `CanvasAnimationAttribute` typedef that gets respected if passed.
204
+ *
205
+ * See {@linkcode ProcessedAttribute}
206
+ *
207
+ * @privateRemarks `extends object` to allow {@linkcode foundry.canvas.interaction.Ping._animateFrame | Ping#_animateFrame} to take `CanvasAnimation.AnimationData<this>`
208
+ */
209
+ interface Attribute<AnimationParent extends object = object> extends _AnimationAttribute {
210
+ /**
211
+ * The attribute name being animated
212
+ * @remarks Does not support dotkeys
213
+ */
214
+ attribute: AllKeysOf<AnimationParent>;
169
215
 
170
216
  /** The object within which the attribute is stored */
171
- parent: AnyObject;
217
+ parent: AnimationParent;
172
218
 
173
219
  /** The destination value of the attribute */
174
220
  to: number | Color;
175
221
  }
176
222
 
177
- interface AnimateOptions extends CanvasAnimation._AnimateOptions {
178
- /**
179
- * A duration in milliseconds over which the animation should occur
180
- * @defaultValue `1000`
181
- * @remarks Can't be `null` because it only has a parameter default, and is used as a divisor in `CanvasAnimation.#animateFrame`
182
- */
183
- duration?: number | undefined;
184
- }
185
-
186
- interface CanvasAnimationAttribute extends CanvasAnimation.Attribute {
223
+ /**
224
+ * @remarks This is the type after {@linkcode CanvasAnimation.animate} provides the computed `delta` and a `0` value
225
+ * for `done`, which gets bundled into a {@linkcode CanvasAnimation.AnimationData} and put into {@linkcode CanvasAnimation.animations}
226
+ *
227
+ * See {@linkcode CanvasAnimation.Attribute}
228
+ *
229
+ * @privateRemarks `extends object` to allow {@linkcode foundry.canvas.interaction.Ping._animateFrame | Ping#_animateFrame} to take `CanvasAnimation.AnimationData<this>`
230
+ */
231
+ interface ProcessedAttribute<AnimationParent extends object = object>
232
+ extends CanvasAnimation.Attribute<AnimationParent> {
187
233
  /**
188
234
  * The computed delta between to and from
189
- * @remarks This key is always overwritten inside `.animate`, its passed value is irrelevant
235
+ * @remarks This key is always computed inside {@linkcode CanvasAnimation.animate}, its passed value is irrelevant
190
236
  */
191
237
  delta: number;
192
238
 
193
239
  /**
194
240
  * The amount of the total delta which has been animated
195
- * @remarks This key is always overwritten inside `.animate`, its passed value is irrelevant
241
+ * @remarks This key is always computed inside {@linkcode CanvasAnimation.animate}, its passed value is irrelevant
196
242
  */
197
243
  done: number;
198
244
 
199
245
  /**
200
246
  * Is this a color animation that applies to RGB channels
201
- * @remarks When true, `CanvasAnimation.#animateFrame` assumes `to` *and* `from` are
202
- * both `Color`s. It's automatically set `true` if `to` is passed as a `Color`, so it
203
- * should be unnecessary to set manually.
247
+ * @remarks When true, `CanvasAnimation.#animateFrame` assumes `to` *and* `from` are both `Color`s. It's automatically set `true`
248
+ * if `to` is passed as a `Color` regardless of its own passed value, and is irrelevant if `to` isn't a `Color`, so it should be
249
+ * unnecessary to set manually and has been omitted from the passable interface. It is read by `CanvasAnimation##updateAttribute`
250
+ * to determine update behaviour.
204
251
  */
205
252
  color?: boolean;
206
253
  }
207
254
 
208
- interface AnimationData extends CanvasAnimation.AnimateOptions {
255
+ /**
256
+ * @privateRemarks `extends object` to allow {@linkcode foundry.canvas.interaction.Ping._animateFrame | Ping#_animateFrame} to take `CanvasAnimation.AnimationData<this>`
257
+ */
258
+ interface AnimationData<AnimationParent extends object = object> extends CanvasAnimation.AnimateOptions {
209
259
  /** The animation function being executed each frame */
210
260
  fn: (dt: number) => void;
211
261
 
@@ -213,7 +263,8 @@ declare namespace CanvasAnimation {
213
263
  time: number;
214
264
 
215
265
  /** The attributes being animated */
216
- attributes: CanvasAnimationAttribute[];
266
+ // TODO: a method to narrow what `ProcessedAttribute.attributes` can be by the `.parent` (see https://discord.com/channels/732325252788387980/793933527065690184/1391965566276861964)
267
+ attributes: ProcessedAttribute<AnimationParent>[];
217
268
 
218
269
  /** The current state of the animation */
219
270
  state: CanvasAnimation.STATES;
@@ -1,31 +1,102 @@
1
+ import type { AnyMutableObject, Identity, InexactPartial } from "#utils";
2
+ import type { placeables } from "../_module.d.mts";
3
+
1
4
  /**
2
5
  * The Chat Bubble Class
3
- * This application displays a temporary message sent from a particular Token in the active Scene.
6
+ * This application displays a temporary message sent from a particular {@linkcode placeables.Token | Token} in the active {@linkcode Scene}.
4
7
  * The message is displayed on the HUD layer just above the Token.
5
- * @remarks TODO: Stub
6
8
  */
7
- declare class ChatBubbles {}
9
+ declare class ChatBubbles {
10
+ /**
11
+ * The Handlebars template used to render Chat Bubbles.
12
+ * @defaultValue `"templates/hud/chat-bubble.html"`
13
+ */
14
+ template: string;
15
+
16
+ /**
17
+ * Track active Chat Bubbles
18
+ * @defaultValue `{}`
19
+ * @remarks This appears to not be wired up to anything as of 13.346
20
+ */
21
+ bubbles: AnyMutableObject;
22
+
23
+ /**
24
+ * A reference to the chat bubbles HTML container in which rendered bubbles should live
25
+ */
26
+ get element(): HTMLElement;
27
+
28
+ /**
29
+ * Create a chat bubble message for a certain token which is synchronized for display across all connected clients.
30
+ * @param token - The speaking Token Document
31
+ * @param message - The spoken message text
32
+ * @param options - Options which affect the bubble appearance
33
+ * @returns A promise which resolves with the created bubble HTML, or `null`
34
+ */
35
+ broadcast(
36
+ token: placeables.Token.Implementation | TokenDocument.Implementation,
37
+ message: string,
38
+ options?: ChatBubbles.Options,
39
+ ): Promise<HTMLElement | null>;
40
+
41
+ /**
42
+ * Create a chat bubble message for a certain token which is synchronized for display across all connected clients.
43
+ * @param token - The speaking Token Document
44
+ * @param message - The spoken message text
45
+ * @param options - Options which affect the bubble appearance
46
+ * @returns A promise which resolves with the created bubble HTML, or `null`
47
+ * @remarks While {@linkcode broadcast} will take either a placeable or a document, `say` requires a placeable
48
+ */
49
+ say(
50
+ token: placeables.Token.Implementation,
51
+ message: string,
52
+ options?: ChatBubbles.Options,
53
+ ): Promise<HTMLElement | null>;
54
+
55
+ /**
56
+ * Activate Socket event listeners which apply to the ChatBubbles UI.
57
+ * @param socket - The active web socket connection
58
+ * @internal
59
+ */
60
+ protected static _activateSocketListeners(socket: io.Socket): void;
61
+
62
+ /**
63
+ * @deprecated "`ChatBubbles#container` (jQuery) is deprecated in favor of {@linkcode ChatBubbles.element | ChatBubbles#element} (HTMLElement)" (since v13, until v15)
64
+ */
65
+ get container(): JQuery;
66
+
67
+ #ChatBubbles: true;
68
+ }
8
69
 
9
70
  declare namespace ChatBubbles {
10
- interface Options {
71
+ interface Any extends AnyChatBubbles {}
72
+ interface AnyConstructor extends Identity<typeof AnyChatBubbles> {}
73
+
74
+ /** @internal */
75
+ type _Options = InexactPartial<{
11
76
  /**
12
77
  * An optional array of CSS classes to apply to the resulting bubble
13
78
  * @defaultValue `[]`
14
79
  */
15
- cssClasses?: string[] | undefined;
80
+ cssClasses: string[];
16
81
 
17
82
  /**
18
83
  * Pan to the token speaker for this bubble, if allowed by the client
19
84
  * @defaultValue `true`
20
85
  */
21
- pan?: boolean | undefined;
86
+ pan: boolean;
22
87
 
23
88
  /**
24
89
  * Require that the token be visible in order for the bubble to be rendered
25
90
  * @defaultValue `false`
26
91
  */
27
- requireVisible?: boolean | undefined;
28
- }
92
+ requireVisible: boolean;
93
+ }>;
94
+
95
+ interface Options extends _Options {}
29
96
  }
30
97
 
31
98
  export default ChatBubbles;
99
+
100
+ declare abstract class AnyChatBubbles extends ChatBubbles {
101
+ constructor(...args: never);
102
+ }
@@ -7,30 +7,46 @@ declare class SmoothNoise {
7
7
  /**
8
8
  * @param options - Configuration options for the noise process.
9
9
  */
10
- constructor({ amplitude, scale, maxReferences }?: InexactPartial<SmoothNoise.ConstructorOptions>);
10
+ constructor(options?: SmoothNoise.ConstructorOptions);
11
11
 
12
- _maxReferences: number;
12
+ /**
13
+ * @remarks Stores the value passed in construction options, or `1` if that's falsey.
14
+ *
15
+ * `defineProperty`'d in construction with `writable: false`
16
+ */
17
+ protected readonly _maxReferences: number;
13
18
 
14
- _references: number[];
19
+ /**
20
+ * @remarks Stores {@linkcode _maxReferences} number of `Math.random()` calls
21
+ *
22
+ * `defineProperty`'d in construction with `writable: false`
23
+ */
24
+ protected readonly _references: number[];
15
25
 
16
26
  /**
17
27
  * Amplitude of the generated noise output
18
28
  * The noise output is multiplied by this value
29
+ *
30
+ * @remarks
31
+ * @throws If passed `NaN` or `+`/`-Infinity`
19
32
  */
20
33
  get amplitude(): number;
21
34
 
22
35
  set amplitude(amplitude);
23
36
 
24
- _amplitude: number;
37
+ protected _amplitude: number;
25
38
 
26
39
  /**
27
40
  * Scale factor of the random indices
41
+ *
42
+ * @remarks
43
+ * @throws If passed a negative number, `NaN`, or `+`/`-Infinity`
28
44
  */
29
45
  get scale(): number;
30
46
 
31
47
  set scale(scale);
32
48
 
33
- _scale: number;
49
+ protected _scale: number;
34
50
 
35
51
  /**
36
52
  * Generate the noise value corresponding to a provided numeric x value.
@@ -49,14 +65,14 @@ declare namespace SmoothNoise {
49
65
  /**
50
66
  * The generated noise will be on the range [0, amplitude].
51
67
  * @defaultValue `1`
52
- * @remarks Can't be null because it only has a signature-provided default
68
+ * @remarks Must be finite
53
69
  */
54
70
  amplitude: number;
55
71
 
56
72
  /**
57
73
  * An adjustment factor for the input x values which place them on an appropriate range.
58
74
  * @defaultValue `1`
59
- * @remarks Can't be null because it only has a signature-provided default
75
+ * @remarks Must be finite and non-negative
60
76
  */
61
77
  scale: number;
62
78
 
@@ -64,7 +80,6 @@ declare namespace SmoothNoise {
64
80
  * The number of pre-generated random numbers to generate.
65
81
  * @defaultValue `256`
66
82
  * @remarks Must be a power of 2 or construction throws.
67
- * Can't be null because it only has a signature-provided default
68
83
  */
69
84
  maxReferences: number;
70
85
  }>;