Skip to content

Commit 073b210

Browse files
committed
Bump pf2e types
1 parent a333e6c commit 073b210

File tree

20 files changed

+187
-99
lines changed

20 files changed

+187
-99
lines changed

types/foundry/client-esm/canvas/sources/rendered-effect-source.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type BaseEffectSource from "./base-effect-source.d.ts";
22
import type { BaseEffectSourceData } from "./base-effect-source.d.ts";
33

4+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
5+
46
/**
57
* An abstract class which extends the base PointSource to provide common functionality for rendering.
68
* This class is extended by both the LightSource and VisionSource subclasses.

types/foundry/client/apps/app.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export {};
22

3+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
4+
35
declare global {
46
/** The standard application window that is rendered for a large variety of UI elements in Foundry VTT */
57
class Application<

types/foundry/client/core/audio.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export {};
22

3+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
4+
35
declare global {
46
/**
57
* A helper class to provide common functionality for working with HTML5 audio and Howler instances

types/foundry/client/data/documents/active-effect.d.ts

Lines changed: 150 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {
22
ActiveEffectSource,
3+
EffectChangeData,
34
EffectDurationData,
45
} from "../../../common/documents/active-effect.d.ts";
56
import type { ClientBaseActiveEffect } from "./client-base-mixes.d.ts";
@@ -13,16 +14,88 @@ declare global {
1314
class ActiveEffect<
1415
TParent extends Actor | Item | null,
1516
> extends ClientBaseActiveEffect<TParent> {
16-
constructor(
17-
data: PreCreate<ActiveEffectSource>,
18-
context?: DocumentConstructionContext<TParent>,
19-
);
17+
/**
18+
* Create an ActiveEffect instance from some status effect ID.
19+
* Delegates to {@link ActiveEffect._fromStatusEffect} to create the ActiveEffect instance
20+
* after creating the ActiveEffect data from the status effect data if `CONFIG.statusEffects`.
21+
* @param statusId The status effect ID.
22+
* @param options Additional options to pass to the ActiveEffect constructor.
23+
* @returns The created ActiveEffect instance.
24+
*
25+
* @throws {Error} An error if there is no status effect in `CONFIG.statusEffects` with the given status ID and if
26+
* the status has implicit statuses but doesn't have a static _id.
27+
*/
28+
static fromStatusEffect(
29+
statusId: string,
30+
options?: DocumentConstructionContext<foundry.abstract.Document | null>,
31+
): Promise<ActiveEffect<Actor | Item> | undefined>;
32+
33+
/**
34+
* Create an ActiveEffect instance from status effect data.
35+
* Called by {@link ActiveEffect.fromStatusEffect}.
36+
* @param statusId The status effect ID.
37+
* @param effectData The status effect data.
38+
* @param options Additional options to pass to the ActiveEffect constructor.
39+
* @returns The created ActiveEffect instance.
40+
*/
41+
protected static _fromStatusEffect(
42+
statusId: string,
43+
effectData: Partial<ActiveEffectSource>,
44+
options?: DocumentConstructionContext<foundry.abstract.Document | null>,
45+
): Promise<ActiveEffect<Actor | Item> | undefined>;
46+
47+
/* -------------------------------------------- */
48+
/* Properties */
49+
/* -------------------------------------------- */
2050

21-
/** A cached reference to the source name to avoid recurring database lookups */
22-
protected _sourceName: string | null;
51+
/**
52+
* Is there some system logic that makes this active effect ineligible for application?
53+
*/
54+
get isSuppressed(): boolean;
2355

24-
/** A cached reference to the ActiveEffectConfig instance which configures this effect */
25-
protected override _sheet: ActiveEffectConfig<this> | null;
56+
/**
57+
* Retrieve the Document that this ActiveEffect targets for modification.
58+
*/
59+
get target(): foundry.abstract.Document | null;
60+
61+
/**
62+
* Whether the Active Effect currently applying its changes to the target.
63+
*/
64+
get active(): boolean;
65+
66+
/**
67+
* Does this Active Effect currently modify an Actor?
68+
*/
69+
get modifiesActor(): boolean;
70+
71+
override prepareBaseData(): void;
72+
73+
override prepareDerivedData(): void;
74+
75+
/**
76+
* Update derived Active Effect duration data.
77+
* Configure the remaining and label properties to be getters which lazily recompute only when necessary.
78+
*/
79+
updateDuration(): EffectDurationData;
80+
81+
/**
82+
* Determine whether the ActiveEffect requires a duration update.
83+
* True if the worldTime has changed for an effect whose duration is tracked in seconds.
84+
* True if the combat turn has changed for an effect tracked in turns where the effect target is a combatant.
85+
*/
86+
protected _requiresDurationUpdate(): boolean;
87+
88+
/**
89+
* Compute derived data related to active effect duration.
90+
*/
91+
_prepareDuration(): {
92+
type: string;
93+
duration: number | null;
94+
remaining: number | null;
95+
label: string;
96+
_worldTime?: number;
97+
_combatTime?: number;
98+
};
2699

27100
/**
28101
* Format a round+turn combination as a decimal
@@ -45,100 +118,70 @@ declare global {
45118
*/
46119
protected _getDurationLabel(rounds: number, turns: number): string;
47120

48-
/** Describe whether the ActiveEffect has a temporary duration based on combat turns or rounds. */
121+
/**
122+
* Describe whether the ActiveEffect has a temporary duration based on combat turns or rounds.
123+
*/
49124
get isTemporary(): boolean;
50125

51-
/** A cached property for obtaining the source name */
52-
get sourceName(): string;
53-
54126
/**
55-
* An instance of the ActiveEffectConfig sheet to use for this ActiveEffect instance.
56-
* The reference to the sheet is cached so the same sheet instance is reused.
127+
* A cached property for obtaining the source name
57128
*/
58-
override get sheet(): ActiveEffectConfig<this>;
129+
get sourceName(): string;
59130

60131
/* -------------------------------------------- */
61132
/* Methods */
62133
/* -------------------------------------------- */
63134

64135
/**
65-
* Apply this ActiveEffect to a provided Actor.
66-
* @param actor The Actor to whom this effect should be applied
67-
* @param change The change data being applied
68-
* @return The resulting applied value
136+
* Apply EffectChangeData to a field within a DataModel.
137+
* @param model The model instance.
138+
* @param change The change to apply.
139+
* @param field The field. If not supplied, it will be retrieved from the supplied model.
140+
* @returns The updated value.
69141
*/
70-
apply(
71-
actor: Actor<TokenDocument>,
72-
change: ActiveEffectSource["changes"][number],
142+
static applyField(
143+
model: foundry.abstract.Document,
144+
change: EffectChangeData,
145+
field?: foundry.data.fields.DataField,
73146
): unknown;
74147

75148
/**
76-
* Apply an ActiveEffect that uses an ADD application mode.
77-
* The way that effects are added depends on the data type of the current value.
78-
*
79-
* If the current value is null, the change value is assigned directly.
80-
* If the current type is a string, the change value is concatenated.
81-
* If the current type is a number, the change value is cast to numeric and added.
82-
* If the current type is an array, the change value is appended to the existing array if it matches in type.
83-
*
84-
* @param actor The Actor to whom this effect should be applied
85-
* @param change The change data being applied
86-
* @return The resulting applied value
87-
*/
88-
protected _applyAdd(
89-
actor: Actor<TokenDocument>,
90-
change: ActiveEffectSource["changes"][number],
91-
): unknown;
92-
93-
/**
94-
* Apply an ActiveEffect that uses a MULTIPLY application mode.
95-
* Changes which MULTIPLY must be numeric to allow for multiplication.
149+
* Apply this ActiveEffect to a provided Actor.
150+
* TODO: This method is poorly conceived. Its functionality is static, applying a provided change to an Actor
151+
* TODO: When we revisit this in Active Effects V2 this should become an Actor method, or a static method
96152
* @param actor The Actor to whom this effect should be applied
97153
* @param change The change data being applied
98-
* @return The resulting applied value
154+
* @returns An object of property paths and their updated values.
99155
*/
100-
protected _applyMultiply(
101-
actor: Actor<TokenDocument>,
102-
change: ActiveEffectSource["changes"][number],
103-
): unknown;
156+
apply(actor: Actor, change: EffectChangeData): Record<string, unknown>;
104157

105158
/**
106-
* Apply an ActiveEffect that uses an OVERRIDE application mode.
107-
* Numeric data is overridden by numbers, while other data types are overridden by any value
108-
* @param actor The Actor to whom this effect should be applied
109-
* @param change The change data being applied
110-
* @return The resulting applied value
159+
* Apply this ActiveEffect to a provided Actor using a heuristic to infer the value types based on the current value
160+
* and/or the default value in the template.json.
161+
* @param actor The Actor to whom this effect should be applied.
162+
* @param change The change data being applied.
163+
* @param changes The aggregate update paths and their updated values.
111164
*/
112-
protected _applyOverride(
113-
actor: Actor<TokenDocument>,
114-
change: ActiveEffectSource["changes"][number],
115-
): unknown;
165+
protected _applyLegacy(
166+
actor: Actor,
167+
change: EffectChangeData,
168+
changes: Record<string, unknown>,
169+
): void;
116170

117171
/**
118-
* Apply an ActiveEffect that uses an UPGRADE, or DOWNGRADE application mode.
119-
* Changes which UPGRADE or DOWNGRADE must be numeric to allow for comparison.
120-
* @param actor The Actor to whom this effect should be applied
121-
* @param change The change data being applied
122-
* @return The resulting applied value
172+
* Retrieve the initial duration configuration.
123173
*/
124-
protected _applyUpgrade(
125-
actor: Actor<TokenDocument>,
126-
change: ActiveEffectSource["changes"][number],
127-
): unknown;
174+
static getInitialDuration(): {
175+
startTime: number;
176+
startRound?: number;
177+
startTurn?: number;
178+
};
128179

129-
/**
130-
* Apply an ActiveEffect that uses a CUSTOM application mode.
131-
* @param actor The Actor to whom this effect should be applied
132-
* @param change The change data being applied
133-
* @return The resulting applied value
134-
*/
135-
protected _applyCustom(
136-
actor: Actor<TokenDocument>,
137-
change: ActiveEffectSource["changes"][number],
138-
): unknown;
180+
/* -------------------------------------------- */
181+
/* Flag Operations */
182+
/* -------------------------------------------- */
139183

140-
/** Get the name of the source of the Active Effect */
141-
protected _getSourceName(): Promise<string>;
184+
override getFlag(scope: string, key: string): unknown;
142185

143186
/* -------------------------------------------- */
144187
/* Event Handlers */
@@ -149,6 +192,36 @@ declare global {
149192
operation: DatabaseCreateOperation<TParent>,
150193
user: User,
151194
): Promise<boolean | void>;
195+
196+
protected override _onCreate(
197+
data: this["_source"],
198+
options: DatabaseCreateOperation<TParent>,
199+
userId: string,
200+
): void;
201+
202+
override _preUpdate(
203+
changed: Record<string, unknown>,
204+
options: DatabaseUpdateOperation<TParent>,
205+
user: User,
206+
): Promise<boolean | void>;
207+
208+
override _onUpdate(
209+
changed: Record<string, unknown>,
210+
options: DatabaseUpdateOperation<TParent>,
211+
userId: string,
212+
): void;
213+
214+
/** @inheritDoc */
215+
_onDelete(
216+
options: DatabaseDeleteOperation<TParent>,
217+
userId: string,
218+
): void;
219+
220+
/**
221+
* Display changes to active effects as scrolling Token status text.
222+
* @param enabled Is the active effect currently enabled?
223+
*/
224+
protected _displayScrollingStatus(enabled: boolean): void;
152225
}
153226

154227
interface ActiveEffect<TParent extends Actor | Item | null>

types/foundry/client/data/documents/client-base-mixes.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type {
44
DocumentSheetV2,
55
} from "../../../client-esm/applications/api/module.d.ts";
66

7+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
8+
79
export declare class ClientBaseAmbientLight<
810
TParent extends ClientBaseScene | null,
911
> extends foundry.documents.BaseAmbientLight<TParent> {

types/foundry/client/keyboard/keyboard-manager.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ declare global {
196196
}
197197

198198
type ModifierKey =
199-
| (typeof KeyboardManager.MODIFIER_KEYS)[keyof typeof KeyboardManager.MODIFIER_KEYS]
200-
| typeof KeyboardManager.CONTROL_KEY_STRING;
199+
(typeof KeyboardManager.MODIFIER_KEYS)[keyof typeof KeyboardManager.MODIFIER_KEYS];
201200

202201
interface KeyboardEventContext {
203202
event: KeyboardEvent;

types/foundry/client/pixi/core/interaction/canvas-animation.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
2+
13
interface CanvasAnimationAttribute {
24
/** The attribute name being animated */
35
attribute: string;

types/foundry/client/pixi/layers/base/placeables-layer.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ declare global {
321321
*/
322322
protected override _onDragLeftStart(
323323
event: PlaceablesLayerPointerEvent<TObject>,
324-
): Promise<TObject | void>;
324+
): TObject | void;
325325

326326
/**
327327
* Continue a left-click drag workflow originating from the Canvas stage.
@@ -337,7 +337,7 @@ declare global {
337337
*/
338338
protected override _onDragLeftDrop(
339339
event: PlaceablesLayerPointerEvent<TObject>,
340-
): Promise<void>;
340+
): void;
341341

342342
/**
343343
* Cancel a left-click drag workflow originating from the Canvas stage.

types/foundry/client/pixi/layers/placeables/lighting.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ declare global {
4343

4444
protected override _onDragLeftStart(
4545
event: PlaceablesLayerPointerEvent<TObject>,
46-
): Promise<void>;
46+
): void;
4747

4848
protected override _onDragLeftMove(
4949
event: PlaceablesLayerPointerEvent<TObject>,
50-
): Promise<void>;
50+
): void;
5151

5252
protected override _onDragLeftCancel(event: PIXI.FederatedEvent): void;
5353

types/foundry/client/pixi/layers/placeables/template.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare global {
2727

2828
protected override _onDragLeftStart(
2929
event: PlaceablesLayerPointerEvent<TObject>,
30-
): Promise<TObject | void>;
30+
): void;
3131

3232
protected override _onDragLeftMove(
3333
event: PlaceablesLayerPointerEvent<TObject>,

types/foundry/client/pixi/layers/placeables/walls.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ declare global {
140140

141141
protected override _onDragLeftStart(
142142
event: PlaceablesLayerPointerEvent<TObject>,
143-
): Promise<void>;
143+
): void;
144144

145145
protected override _onDragLeftMove(
146146
event: PlaceablesLayerPointerEvent<TObject>,
147-
): Promise<void>;
147+
): void;
148148

149149
protected override _onDragLeftCancel(event: PIXI.FederatedEvent): void;
150150

types/foundry/client/pixi/webgl/extensions/batch-renderer.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
2+
13
/** A batch renderer with a customizable data transfer function to packed geometries. */
24
declare class BatchRenderer extends PIXI.BatchRenderer {
35
/** The batch shader generator class. */

types/foundry/client/pixi/webgl/shaders/filters/transition.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export {};
22

3+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
4+
35
declare global {
46
/** A filter specialized for transition effects between a source object and a target texture. */
57
class TextureTransitionFilter extends AbstractBaseFilter {

0 commit comments

Comments
 (0)