diff --git a/src/foundry/client-esm/applications/api/application.d.mts b/src/foundry/client-esm/applications/api/application.d.mts index a82571399..9873ef904 100644 --- a/src/foundry/client-esm/applications/api/application.d.mts +++ b/src/foundry/client-esm/applications/api/application.d.mts @@ -1,4 +1,11 @@ -import type { MustConform, AnyObject, DeepPartial, EmptyObject, InexactPartial, MaybePromise } from "../../../../utils/index.d.mts"; +import type { + MustConform, + AnyObject, + DeepPartial, + EmptyObject, + InexactPartial, + MaybePromise, +} from "../../../../utils/index.d.mts"; import type EventEmitterMixin from "../../../common/utils/event-emitter.d.mts"; // TODO: Investigate use of DeepPartial vs Partial vs InexactPartial diff --git a/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts b/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts index 9328b0960..a449e2511 100644 --- a/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../utils/index.d.mts"; +import type { NullishProps, IntentionalPartial } from "../../../../utils/index.d.mts"; /** * TODO - Re-document after ESM refactor. @@ -14,15 +14,16 @@ import type { InexactPartial } from "../../../../utils/index.d.mts"; * ``` * @privateRemarks The TODO is foundry's */ -declare class BaseEffectSource< - SourceData extends BaseEffectSource.BaseEffectSourceData, +declare abstract class BaseEffectSource< + SourceData extends BaseEffectSource.SourceData, SourceShape extends PIXI.Polygon, > { /** * An effect source is constructed by providing configuration options. * @param options - Options which modify the base effect source instance + * @remarks Passing a PlaceableObject is deprecated, and will be removed in v13 */ - constructor(options?: BaseEffectSource.BaseEffectSourceOptions); + constructor(options?: BaseEffectSource.SourceOptions | PlaceableObject); /** * The type of source represented by this data structure. @@ -47,7 +48,7 @@ declare class BaseEffectSource< * } * ``` */ - static defaultData: BaseEffectSource.BaseEffectSourceData; + static defaultData: BaseEffectSource.SourceData; /** * Some other object which is responsible for this source. @@ -56,8 +57,9 @@ declare class BaseEffectSource< /** * The source id linked to this effect source. + * @remarks Foundry types this as Readonly, but does nothing to that effect at runtime */ - readonly sourceId: string; + sourceId: string | undefined; /** * The data of this source. @@ -66,8 +68,9 @@ declare class BaseEffectSource< /** * The geometric shape of the effect source which is generated later. + * @remarks This only isn't `undefined` in subclasses implementing `_createShapes()`, usually via {@link PointEffectSourceMixin} */ - shape: SourceShape; + shape: SourceShape | undefined; /** * A collection of boolean flags which control rendering and refresh behavior for the source. @@ -129,14 +132,14 @@ declare class BaseEffectSource< * @returns The initialized source */ initialize( - data?: InexactPartial, - options?: InexactPartial<{ - // The type def references a behaviors object that is not even passed into the function + data?: NullishProps, + /** @privateRemarks Foundry describes an `options.behaviors` key, but it is neither checked for nor used at runtime */ + options?: NullishProps<{ /** * Should source data be reset to default values before applying changes? * @defaultValue `false` */ - reset?: boolean; + reset: boolean; }>, ): this; @@ -144,7 +147,10 @@ declare class BaseEffectSource< * Subclass specific data initialization steps. * @param data - Provided data for configuration */ - _initialize(data: Partial): void; + _initialize( + /** @remarks IntentionalPartial because `this.initialize` has filtered invalid keys and replaced any nullish values before calling this */ + data: IntentionalPartial, + ): void; /** * Create the polygon shape (or shapes) for this source using configured data. @@ -155,8 +161,9 @@ declare class BaseEffectSource< * Subclass specific configuration steps. Occurs after data initialization and shape computation. * Only called if the source is attached and not disabled. * @param changes - Changes to the source data which were applied + * @remarks This is actually passed *flattened* partial data */ - protected _configure(changes: Partial): void; + protected _configure(changes: IntentionalPartial): void; /** * Refresh the state and uniforms of the source. @@ -211,19 +218,25 @@ declare class BaseEffectSource< declare namespace BaseEffectSource { type AnyConstructor = typeof AnyBaseEffectSource; - interface BaseEffectSourceOptions { + /** @internal */ + type _SourceOptions = NullishProps<{ /** * An optional PlaceableObject which is responsible for this source */ - object?: PlaceableObject | undefined; + object: PlaceableObject; + }>; + + interface SourceOptions extends _SourceOptions { /** * A unique ID for this source. This will be set automatically if an * object is provided, otherwise is required. + * @remarks The above is misleading; sourceId will *not* be inferred if you pass in `{object: PlaceableObject}`, + * only if you pass a `PlaceableObject` *instead* of an options object to the constructor. */ - sourceId?: string | undefined; + sourceId?: string; } - interface BaseEffectSourceData { + interface SourceData { /** * The x-coordinate of the source location */ diff --git a/src/foundry/client-esm/canvas/sources/base-light-source.d.mts b/src/foundry/client-esm/canvas/sources/base-light-source.d.mts index 53ca1d2ec..76322100b 100644 --- a/src/foundry/client-esm/canvas/sources/base-light-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/base-light-source.d.mts @@ -1,13 +1,13 @@ -import type { InexactPartial } from "../../../../utils/index.d.mts"; +import type { InexactPartial, IntentionalPartial } from "../../../../utils/index.d.mts"; import type RenderedEffectSource from "./rendered-effect-source.d.mts"; /** * A specialized subclass of BaseEffectSource which deals with the rendering of light or darkness. */ -declare class BaseLightSource< - SourceData extends BaseLightSource.LightSourceData = BaseLightSource.LightSourceData, +declare abstract class BaseLightSource< + SourceData extends BaseLightSource.SourceData = BaseLightSource.SourceData, SourceShape extends PIXI.Polygon = PIXI.Polygon, - RenderingLayers extends Record = RenderedEffectSource.Layers, + RenderingLayers extends Record = RenderedEffectSource.Layers, > extends RenderedEffectSource { /** @defaultValue `"light"` */ static override sourceType: string; @@ -20,18 +20,22 @@ declare class BaseLightSource< /** * The corresponding lighting levels for dim light. + * @defaultValue `foundry.CONST.LIGHTING_LEVELS.DIM` */ protected static _dimLightingLevel: foundry.CONST.LIGHTING_LEVELS; /** * The corresponding lighting levels for bright light. + * @defaultValue `foundry.CONST.LIGHTING_LEVELS.BRIGHT` */ protected static _brightLightingLevel: foundry.CONST.LIGHTING_LEVELS; /** * The corresponding animation config. + * @remarks More broad than it should be to accomodate {@link foundry.canvas.sources.PointDarknessSource} + * TODO: Reevaluate after CONFIG has been gone over */ - protected static get ANIMATIONS(): CONFIG.Canvas.LightSourceAnimationConfig; + protected static get ANIMATIONS(): typeof CONFIG.Canvas.lightAnimations | typeof CONFIG.Canvas.darknessAnimations; /** * @defaultValue @@ -52,14 +56,14 @@ declare class BaseLightSource< * } * ``` */ - static override defaultData: RenderedEffectSource.RenderedEffectSourceData; + static override defaultData: BaseLightSource.SourceData; /** * A ratio of dim:bright as part of the source radius */ ratio: number; - override _initialize(data: Partial): void; + override _initialize(data: IntentionalPartial): void; override _updateColorationUniforms(): void; @@ -69,12 +73,18 @@ declare class BaseLightSource< override _updateCommonUniforms(shader: AbstractBaseShader): void; + /** @remarks This property is undocumented, and only defined during `_updateCommonUniforms` */ + cachededAttentuation?: number; + + /** @remarks This property is undocumented, and only defined during `_updateCommonUniforms` */ + computedAttentuation?: number; + /** * An animation with flickering ratio and light intensity. * @param dt - Delta time * @param options - Additional options which modify the torch animation */ - animateTorch(dt: number, options?: InexactPartial): void; + animateTorch(dt: number, options?: RenderedEffectSource.AnimationFunctionOptions): void; /** * An animation with flickering ratio and light intensity @@ -83,72 +93,96 @@ declare class BaseLightSource< */ animateFlickering( dt: number, - options?: InexactPartial< - RenderedEffectSource.AnimationOptions & { + options?: RenderedEffectSource.AnimationFunctionOptions & + InexactPartial<{ /** * Noise amplification (\>1) or dampening (\<1) * @defaultValue `1` */ amplification: number; - } - >, + }>, ): void; + /** + * @remarks This property will be generated on any class that is `animateFlickering`'s `this` when it is called. + * Foundry does not document it. + */ + _noise?: SmoothNoise; + /** * A basic "pulse" animation which expands and contracts. * @param dt - Delta time * @param options - Additional options which modify the pulse animation */ - animatePulse(dt: number, options?: InexactPartial): void; + animatePulse(dt: number, options?: RenderedEffectSource.AnimationFunctionOptions): void; /** - * @deprecated since v12 + * @deprecated since v12, until v14 + * @remarks "BaseLightSource#isDarkness is now obsolete. Use DarknessSource instead." */ get isDarkness(): boolean; } declare namespace BaseLightSource { - interface LightSourceData extends RenderedEffectSource.RenderedEffectSourceData { + type AnyConstructor = typeof AnyBaseLightSource; + + type LightAnimationFunction = ( + this: BaseLightSource, + dt: number, + options?: RenderedEffectSource.AnimationFunctionOptions, + ) => void; + + interface SourceData extends RenderedEffectSource.SourceData { /** * An opacity for the emitted light, if any */ alpha: number; + /** * The allowed radius of bright vision or illumination */ bright: number; + /** * The coloration technique applied in the shader */ coloration: number; + /** * The amount of contrast this light applies to the background texture */ contrast: number; + /** * The allowed radius of dim vision or illumination */ dim: number; + /** * Strength of the attenuation between bright, dim, and dark */ attenuation: number; + /** * The luminosity applied in the shader */ luminosity: number; + /** * The amount of color saturation this light applies to the background texture */ saturation: number; + /** * The depth of shadows this light applies to the background texture */ shadows: number; + /** * Whether or not this source provides a source of vision */ vision: boolean; + /** * Strength of this source to beat or not negative/positive sources */ @@ -156,4 +190,8 @@ declare namespace BaseLightSource { } } +declare abstract class AnyBaseLightSource extends BaseLightSource { + constructor(arg0: never, ...args: never[]); +} + export default BaseLightSource; diff --git a/src/foundry/client-esm/canvas/sources/global-light-source.d.mts b/src/foundry/client-esm/canvas/sources/global-light-source.d.mts index aef6f5e5e..53987b285 100644 --- a/src/foundry/client-esm/canvas/sources/global-light-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/global-light-source.d.mts @@ -26,16 +26,18 @@ export default class GlobalLightSource extends BaseLightSource { * } * ``` */ - static override defaultData: BaseLightSource.LightSourceData; + static override defaultData: BaseLightSource.SourceData; /** * Name of this global light source. - * @defaultValue GlobalLightSource.sourceType + * @defaultValue `GlobalLightSource.sourceType` */ name: string; /** * A custom polygon placeholder. + * @defaultValue `null` + * @remarks This is not set anywhere in Foundry code, so will always be null barring system/module/user action */ customPolygon: PIXI.Polygon | number[] | null; @@ -44,4 +46,6 @@ export default class GlobalLightSource extends BaseLightSource { override _initializeSoftEdges(): void; override _updateGeometry(): void; + + override _updateCommonUniforms(shader: AbstractBaseShader): void; } diff --git a/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts b/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts index 3f436d081..e8a998584 100644 --- a/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts @@ -1,45 +1,48 @@ +import type { IntentionalPartial } from "../../../../utils/index.d.mts"; import type BaseLightSource from "./base-light-source.d.mts"; import type PointEffectSourceMixin from "./point-effect-source.d.mts"; import type RenderedEffectSource from "./rendered-effect-source.d.mts"; -type DarknessSourceData = BaseLightSource.LightSourceData & PointEffectSourceMixin.PointEffectSourceData; - -// Interface causes errors -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -type DarknessLayers = { - darkness: RenderedEffectSource.RenderedEffectSourceLayer; -}; - /** * A specialized subclass of the BaseLightSource which renders a source of darkness as a point-based effect. */ -export default class PointDarknessSource< - SourceData extends DarknessSourceData = DarknessSourceData, +declare class PointDarknessSource< + SourceData extends PointDarknessSource.SourceData = PointDarknessSource.SourceData, SourceShape extends PointSourcePolygon = PointSourcePolygon, -> extends PointEffectSourceMixin(BaseLightSource) { +> extends PointEffectSourceMixin(BaseLightSource) { /** @defaultValue `"darknessSources"` */ static override effectsCollection: string; - /** @defaultValue `LIGHTING_LEVELS.HALFDARK` */ + /** @defaultValue `foundry.CONST.LIGHTING_LEVELS.HALFDARK` */ static override _dimLightingLevel: foundry.CONST.LIGHTING_LEVELS; - /** @defaultValue `LIGHTING_LEVELS.DARKNESS` */ + /** @defaultValue `foundry.CONST.LIGHTING_LEVELS.DARKNESS` */ static override _brightLightingLevel: foundry.CONST.LIGHTING_LEVELS; /** @defaultValue `CONFIG.Canvas.darknessAnimations` */ - static get ANIMATIONS(): CONFIG.Canvas.LightSourceAnimationConfig; + static get ANIMATIONS(): typeof CONFIG.Canvas.darknessAnimations; + + static override get _layers(): Record; - static override get _layers(): Record; + /** @privateRemarks This is not in Foundry's code, but accounts for the mixin class's static property's inability to be generic */ + static override defaultData: PointDarknessSource.SourceData; /** * The optional geometric shape is solely utilized for visual representation regarding darkness sources. * Used only when an additional radius is added for visuals. */ - protected _visualShape: SourceShape; + protected _visualShape: SourceShape | null; + + /** + * @privateRemarks This is not in foundry's code, but since this class (and its parent) implements `_createShapes`, + * and we are counting what happens in `initialize` as 'the constructor', this gets to be declared never undefined. + */ + override shape: SourceShape; /** * Padding applied on the darkness source shape for visual appearance only. * Note: for now, padding is increased radius. It might evolve in a future release. + * @defaultValue `(CONFIG.Canvas.darknessSourcePaddingMultiplier ?? 0) * canvas.grid.size` */ protected _padding: number; @@ -48,9 +51,16 @@ export default class PointDarknessSource< */ edges: foundry.canvas.edges.Edge[]; + /** + * A convenience accessor to the darkness layer mesh. + */ + get darkness(): this["layers"]["darkness"]["mesh"]; + + override _initialize(data: IntentionalPartial): void; + override _createShapes(): void; - override _configure(changes: Partial): void; + override _configure(changes: IntentionalPartial): void; override _getPolygonConfiguration(): PointSourcePolygonConfig; @@ -66,9 +76,26 @@ export default class PointDarknessSource< override _destroy(): void; /** - * A convenience accessor to the darkness layer mesh. * @deprecated since v12, until v14 * @remarks `"BaseLightSource#isDarkness is now obsolete. Use DarknessSource instead."` */ - get darkness(): PointSourceMesh; + get isDarkness(): boolean; } + +declare namespace PointDarknessSource { + type AnyConstructor = typeof AnyPointDarknessSource; + + type SourceData = BaseLightSource.SourceData & PointEffectSourceMixin.SourceData; + + // Interface would require `RenderingLayers extends ... = InterfaceToObject` in every subclass signature + // eslint-disable-next-line @typescript-eslint/consistent-type-definitions + type Layers = { + darkness: RenderedEffectSource.SourceLayer; + }; +} + +declare abstract class AnyPointDarknessSource extends PointDarknessSource { + constructor(arg0: never, ...args: never[]); +} + +export default PointDarknessSource; diff --git a/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts b/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts index a129fa195..632f71210 100644 --- a/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts @@ -1,4 +1,4 @@ -import type { Mixin } from "../../../../utils/index.d.mts"; +import type { Mixin, IntentionalPartial } from "../../../../utils/index.d.mts"; import type BaseEffectSource from "./base-effect-source.d.mts"; declare class PointEffectSource { @@ -17,21 +17,27 @@ declare class PointEffectSource { * walls: true * } * ``` + * @privateRemarks This will only be accurate for classes extending `PointEffectSourceMixin(BaseEffectSource)`. + * Other subclasses must override this. */ - static defaultData: PointEffectSourceMixin.PointEffectSourceData; + static defaultData: PointEffectSourceMixin.MixedSourceData; + + /** @privateRemarks This is not in Foundry's code, but the mixin class loses access to the type parameter that would otherwise be here */ + shape: PointSourcePolygon; /** * A convenience reference to the radius of the source. */ get radius(): number; - _initialize(data: Partial): void; + _initialize(data: IntentionalPartial): void; _initializeSoftEdges(): void; /** * Configure the parameters of the polygon that is generated for this source. */ + //TODO: Make sure this is accurate as part of work on "pixi leftovers" protected _getPolygonConfiguration(): PointSourcePolygonConfig; _createShapes(): void; @@ -66,7 +72,9 @@ declare function PointEffectSourceMixin>; - interface PointEffectSourceData extends BaseEffectSource.BaseEffectSourceData { + type MixedSourceData = SourceData & BaseEffectSource.SourceData; + + interface SourceData { /** * The radius of the source */ diff --git a/src/foundry/client-esm/canvas/sources/point-light-source.d.mts b/src/foundry/client-esm/canvas/sources/point-light-source.d.mts index 83f22e259..6a88d127c 100644 --- a/src/foundry/client-esm/canvas/sources/point-light-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/point-light-source.d.mts @@ -1,23 +1,28 @@ +import type { IntentionalPartial } from "../../../../utils/index.d.mts"; import type BaseLightSource from "./base-light-source.d.mts"; import type PointEffectSourceMixin from "./point-effect-source.d.mts"; -type LightSourceData = PointEffectSourceMixin.PointEffectSourceData & BaseLightSource.LightSourceData; - /** * A specialized subclass of the BaseLightSource which renders a source of light as a point-based effect. */ -export default class PointLightSource< - SourceData extends LightSourceData = LightSourceData, +declare class PointLightSource< + SourceData extends PointLightSource.SourceData = PointLightSource.SourceData, SourceShape extends PointSourcePolygon = PointSourcePolygon, > extends PointEffectSourceMixin(BaseLightSource) { /** @defaultValue `"lightSources"` */ static override effectsCollection: string; - override _initialize(data: Partial): void; + /** + * @privateRemarks This is not in foundry's code, but since this class (and its parent) implements `_createShapes`, + * and we are counting what happens in `initialize` as 'the constructor', this gets to be declared never undefined. + */ + override shape: SourceShape; + + override _initialize(data: IntentionalPartial): void; override _createShapes(): void; - override _configure(changes: Partial): void; + override _configure(changes: IntentionalPartial): void; override _getPolygonConfiguration(): PointSourcePolygonConfig; @@ -26,12 +31,7 @@ export default class PointLightSource< * @param config - The visibility test configuration * @returns Is the target object visible to this source? */ - testVisibility(config: { - /** The sequence of tests to perform */ - tests: CanvasVisibilityTest[]; - /** The target object being tested */ - object: PlaceableObject; - }): boolean; + testVisibility(config?: CanvasVisibilityTestConfig): boolean; /** * Can this LightSource theoretically detect a certain object based on its properties? @@ -39,5 +39,17 @@ export default class PointLightSource< * @param target - The target object being tested * @returns Can the target object theoretically be detected by this vision source? */ - _canDetectObject(target: PlaceableObject): boolean; + _canDetectObject(target?: PlaceableObject | null): boolean; +} + +declare namespace PointLightSource { + type AnyConstructor = typeof AnyPointLightSource; + + type SourceData = PointEffectSourceMixin.SourceData & BaseLightSource.SourceData; } + +declare abstract class AnyPointLightSource extends PointLightSource { + constructor(arg0: never, ...args: never[]); +} + +export default PointLightSource; diff --git a/src/foundry/client-esm/canvas/sources/point-movement-source.d.mts b/src/foundry/client-esm/canvas/sources/point-movement-source.d.mts index 345cdb386..0bd9111b2 100644 --- a/src/foundry/client-esm/canvas/sources/point-movement-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/point-movement-source.d.mts @@ -1,15 +1,31 @@ import type BaseEffectSource from "./base-effect-source.d.mts"; import type PointEffectSourceMixin from "./point-effect-source.d.mts"; -type MovementSourceData = PointEffectSourceMixin.PointEffectSourceData & BaseEffectSource.BaseEffectSourceData; - /** * A specialized subclass of the BaseEffectSource which describes a movement-based source. */ -export default class PointMovementSource< - SourceData extends MovementSourceData = MovementSourceData, +declare class PointMovementSource< + SourceData extends PointMovementSource.SourceData = PointMovementSource.SourceData, SourceShape extends PointSourcePolygon = PointSourcePolygon, > extends PointEffectSourceMixin(BaseEffectSource) { /** @defaultValue `"move"` */ static override sourceType: string; + + /** + * @privateRemarks This is not in foundry's code, but since this class (and its parent) implements `_createShapes`, + * and we are counting what happens in `initialize` as 'the constructor', this gets to be declared never undefined. + */ + override shape: SourceShape; +} + +declare namespace PointMovementSource { + type AnyConstructor = typeof AnyPointMovementSource; + + type SourceData = PointEffectSourceMixin.MixedSourceData; +} + +declare abstract class AnyPointMovementSource extends PointMovementSource { + constructor(arg0: never, ...args: never[]); } + +export default PointMovementSource; diff --git a/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts b/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts index dc92ef944..e39328ce9 100644 --- a/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts @@ -1,18 +1,23 @@ +import type { NullishProps } from "../../../../utils/index.d.mts"; import type BaseEffectSource from "./base-effect-source.d.mts"; import type PointEffectSourceMixin from "./point-effect-source.d.mts"; -type SoundSourceData = PointEffectSourceMixin.PointEffectSourceData & BaseEffectSource.BaseEffectSourceData; - /** * A specialized subclass of the BaseEffectSource which describes a point-based source of sound. */ -export default class PointSoundSource< - SourceData extends SoundSourceData = SoundSourceData, +declare class PointSoundSource< + SourceData extends PointSoundSource.SourceData = PointSoundSource.SourceData, SourceShape extends PointSourcePolygon = PointSourcePolygon, > extends PointEffectSourceMixin(BaseEffectSource) { /** @defaultValue `"sound"` */ static override sourceType: string; + /** + * @privateRemarks This is not in foundry's code, but since this class (and its parent) implements `_createShapes`, + * and we are counting what happens in `initialize` as 'the constructor', this gets to be declared never undefined. + */ + override shape: SourceShape; + override get effectsCollection(): Collection; override _getPolygonConfiguration(): PointSourcePolygonConfig; @@ -22,8 +27,21 @@ export default class PointSoundSource< */ getVolumeMultiplier( listener: Canvas.Point, - options?: { - easing?: boolean | undefined; - }, + options?: NullishProps<{ + /** If no easing, return `1` */ + easing: boolean; + }>, ): number; } + +declare namespace PointSoundSource { + type AnyConstructor = typeof AnyPointSoundSource; + + type SourceData = PointEffectSourceMixin.MixedSourceData; +} + +declare abstract class AnyPointSoundSource extends PointSoundSource { + constructor(arg0: never, ...args: never[]); +} + +export default PointSoundSource; diff --git a/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts b/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts index 3ad52368c..15cbbc491 100644 --- a/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts @@ -1,12 +1,15 @@ import type RenderedEffectSource from "./rendered-effect-source.d.mts"; import type PointEffectSourceMixin from "./point-effect-source.d.mts"; +import type { IntentionalPartial } from "../../../../utils/index.d.mts"; /** * A specialized subclass of RenderedEffectSource which represents a source of point-based vision. */ declare class PointVisionSource< - SourceData extends PointVisionSource.VisionSourceData = PointVisionSource.VisionSourceData, -> extends PointEffectSourceMixin(RenderedEffectSource) { + SourceData extends PointVisionSource.SourceData = PointVisionSource.SourceData, + SourceShape extends PointSourcePolygon = PointSourcePolygon, + RenderingLayers extends RenderedEffectSource.Layers = RenderedEffectSource.Layers, +> extends PointEffectSourceMixin(RenderedEffectSource) { /** @defaultValue `"sight"` */ static override sourceType: string; @@ -18,16 +21,18 @@ declare class PointVisionSource< /** * The corresponding lighting levels for dim light. - * @defaultValue `LIGHTING_LEVELS.DIM` + * @defaultValue `foundry.CONST.LIGHTING_LEVELS.DIM` */ protected static _dimLightingLevel: foundry.CONST.LIGHTING_LEVELS; /** * The corresponding lighting levels for bright light. - * @defaultValue `LIGHTING_LEVELS.BRIGHT` + * @defaultValue `foundry.CONST.LIGHTING_LEVELS.BRIGHT` */ protected static _brightLightingLevel: foundry.CONST.LIGHTING_LEVELS; + static override EDGE_OFFSET: number; + /** @defaultValue `"visionSources"` */ static override effectsCollection: string; @@ -45,9 +50,10 @@ declare class PointVisionSource< * } * ``` */ - static override defaultData: PointVisionSourceData; + static override defaultData: PointVisionSource.SourceData; - static get _layers(): Record; + /** @remarks Overrides `Adaptive*Shader` references with `*VisionShader` ones */ + static get _layers(): Record; /** * The vision mode linked to this VisionSource @@ -78,7 +84,7 @@ declare class PointVisionSource< /** * If this vision source background is rendered into the lighting container. */ - get preferred(): boolean; + get preferred(): boolean | undefined; /** * Is the rendered source animated? @@ -108,20 +114,18 @@ declare class PointVisionSource< */ visionModeOverrides: object; - override _initialize(data: Partial): void; + override _initialize(data: IntentionalPartial): void; override _createShapes(): void; - override shape: PointSourcePolygon; - /** * Responsible for assigning the Vision Mode and calling the activation and deactivation handlers. */ protected _updateVisionMode(): void; - override _configure(changes: Partial): void; + override _configure(changes: IntentionalPartial): void; - override _configureLayer(layer: Record, layerId: string): void; + override _configureLayer(layer: RenderedEffectSource.SourceLayer, layerId: string): void; override _getPolygonConfiguration(): PointSourcePolygonConfig; @@ -141,11 +145,7 @@ declare class PointVisionSource< */ protected _createRestrictedPolygon(): PointSourcePolygon; - override _configureShaders(): { - background: AdaptiveLightingShader; - coloration: AdaptiveLightingShader; - illumination: AdaptiveLightingShader; - }; + override _configureShaders(): Record; override _updateColorationUniforms(): void; @@ -164,11 +164,11 @@ declare class PointVisionSource< } declare namespace PointVisionSource { - type Any = PointVisionSource; + type Any = PointVisionSource; - interface VisionSourceData - extends RenderedEffectSource.RenderedEffectSourceData, - PointEffectSourceMixin.PointEffectSourceData { + type AnyConstructor = typeof AnyPointVisionSource; + + interface SourceData extends RenderedEffectSource.SourceData, PointEffectSourceMixin.SourceData { /** * The amount of contrast */ @@ -197,7 +197,7 @@ declare namespace PointVisionSource { /** * The range of light perception. */ - lightRadius: number; + lightRadius: number | null; /** * Is this vision source blinded? @@ -206,7 +206,8 @@ declare namespace PointVisionSource { } } -type PointVisionSourceData = PointEffectSourceMixin.PointEffectSourceData & - RenderedEffectSource.RenderedEffectSourceData; +declare abstract class AnyPointVisionSource extends PointVisionSource { + constructor(arg0: never, ...args: never[]); +} export default PointVisionSource; diff --git a/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts b/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts index 1afeb6468..696690f4a 100644 --- a/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts @@ -1,17 +1,14 @@ -import type { AnyFunction, InexactPartial } from "../../../../utils/index.d.mts"; +import type { InexactPartial, IntentionalPartial } from "../../../../utils/index.d.mts"; import type BaseEffectSource from "./base-effect-source.d.mts"; -// TODO: Remove after shaders are done -type AdaptiveDarknessShader = unknown; - /** * An abstract class which extends the base PointSource to provide common functionality for rendering. * This class is extended by both the LightSource and VisionSource subclasses. */ declare class RenderedEffectSource< - SourceData extends RenderedEffectSource.RenderedEffectSourceData = RenderedEffectSource.RenderedEffectSourceData, + SourceData extends RenderedEffectSource.SourceData = RenderedEffectSource.SourceData, SourceShape extends PIXI.Polygon = PIXI.Polygon, - RenderingLayers extends Record = RenderedEffectSource.Layers, + RenderingLayers extends Record = RenderedEffectSource.Layers, > extends BaseEffectSource { /** * Keys of the data object which require shaders to be re-initialized. @@ -27,7 +24,7 @@ declare class RenderedEffectSource< * Layers handled by this rendered source. * @remarks Keys should match the keys of RenderingLayers */ - protected static get _layers(): Record; + protected static get _layers(): Record; /** * The offset in pixels applied to create soft edges. @@ -47,13 +44,13 @@ declare class RenderedEffectSource< * } * ``` */ - static defaultData: RenderedEffectSource.RenderedEffectSourceData; + static defaultData: RenderedEffectSource.SourceData; /** * The animation configuration applied to this source * @defaultValue `{}` */ - animation: RenderedEffectSource.RenderedEffectSourceAnimationConfig; + animation: RenderedEffectSource.AnimationConfig; /** * Track the status of rendering layers @@ -100,29 +97,25 @@ declare class RenderedEffectSource< */ get illumination(): PointSourceMesh; - _initialize(data: Partial): void; + override _initialize(data: IntentionalPartial): void; /** * Decide whether to render soft edges with a blur. */ protected _initializeSoftEdges(): void; - override _configure(changes: Partial): void; + override _configure(changes: IntentionalPartial): void; /** * Configure which shaders are used for each rendered layer. * @privateRemarks Foundry marks this as private then overrides it in `PointVisionSource` */ - protected _configureShaders(): { - background: AdaptiveLightingShader; - coloration: AdaptiveLightingShader; - illumination: AdaptiveLightingShader; - }; + protected _configureShaders(): Record; /** * Specific configuration for a layer. */ - protected _configureLayer(layer: Record, layerId: string): void; + protected _configureLayer(layer: RenderedEffectSource.SourceLayer, layerId: string): void; /** * Create the geometry for the source shape that is used in shaders and compute its bounds for culling purpose. @@ -134,11 +127,8 @@ declare class RenderedEffectSource< /** * Render the containers used to represent this light source within the LightingLayer */ - drawMeshes(): { - background: PIXI.Mesh; - coloration: PIXI.Mesh; - illumination: PIXI.Mesh; - }; + drawMeshes(): Record; + /** * Create a Mesh for a certain rendered layer of this source. * @param layerId - The layer key in layers to draw @@ -166,9 +156,13 @@ declare class RenderedEffectSource< */ protected _updateIlluminationUniforms(): void; + protected override _destroy(): void; + /** * Animate the PointSource, if an animation is enabled and if it currently has rendered containers. * @param dt - Delta time. + * @privateRemarks In core this will return `void`, as the `this.animation.animation` function will be a {@link BaseLightSource.LightAnimationFunction} + * and in fact most of the time will be `RenderedEffectSource#animateTime`, but it could technically be set to any function */ animate(dt: number): this["animation"]["animation"] extends (...args: any) => infer Return ? Return : void; @@ -177,7 +171,7 @@ declare class RenderedEffectSource< * @param dt - Delta time. * @param options - Options which affect the time animation */ - animateTime(dt: number, options?: InexactPartial): void; + animateTime(dt: number, options?: RenderedEffectSource.AnimationFunctionOptions): void; /** * Get corrected level according to level and active vision mode data. @@ -196,12 +190,14 @@ declare class RenderedEffectSource< ): Color; /** - * @deprecated since v11 + * @deprecated since v11, until v13 + * @remarks "The RenderedEffectSource#preview is deprecated. Use RenderedEffectSource#isPreview instead." */ set preview(preview: boolean); /** - * @deprecated since v11 + * @deprecated since v11, until v13 + * @remarks "The RenderedEffectSource#preview is deprecated. Set RenderedEffectSource#preview as part of RenderedEffectSource#initialize instead." */ get preview(): boolean; } @@ -209,122 +205,163 @@ declare class RenderedEffectSource< declare namespace RenderedEffectSource { type Any = RenderedEffectSource; - interface RenderedEffectSourceData extends BaseEffectSource.BaseEffectSourceData { + type AnyConstructor = typeof AnyRenderedEffectSource; + + interface SourceData extends BaseEffectSource.SourceData { /** * An animation configuration for the source */ animation: object; + /** * A color applied to the rendered effect */ color: number | null; + /** * An integer seed to synchronize (or de-synchronize) animations */ seed: number | null; + /** * Is this source a temporary preview? */ preview: boolean; } - interface AnimationOptions { + type AnimationFunction = ( + this: RenderedEffectSource, + /** Delta time */ + dt: number, + options?: AnimationFunctionOptions, + ) => void; + + /** @internal */ + type _AnimationFunctionOptions = InexactPartial<{ /** * The animation speed, from 0 to 10 * @defaultValue `5` + * @remarks Can't be null due to only having default via signature */ - speed?: number; + speed: number; /** * The animation intensity, from 1 to 10 * @defaultValue `5` + * @remarks Can't be null due to only having default via signature */ - intensity?: number; + intensity: number; /** * Reverse the animation direction * @defaultValue `false` */ - reverse?: boolean; - } + reverse: boolean | null; + }>; + + /** Shared options for the {@link AnimationFunction}s provided by `_Source` classes */ + interface AnimationFunctionOptions extends _AnimationFunctionOptions {} - interface RenderedEffectSourceAnimationConfig { + type AnimationConfig = InexactPartial<{ /** * The human-readable (localized) label for the animation */ - label?: string | undefined; + label: string; + /** * The animation function that runs every frame * @privateRemarks TODO: Figure out if there's a better way to define the function */ - animation?: AnyFunction | undefined; + animation: RenderedEffectSource.AnimationFunction; + /** * A custom illumination shader used by this animation */ - illuminationShader?: AdaptiveIlluminationShader | undefined; + illuminationShader: typeof AdaptiveIlluminationShader; + /** * A custom coloration shader used by this animation */ - colorationShader?: AdaptiveColorationShader | undefined; + colorationShader: typeof AdaptiveColorationShader; + /** * A custom background shader used by this animation */ - backgroundShader?: AdaptiveBackgroundShader | undefined; + backgroundShader: typeof AdaptiveBackgroundShader; + /** * A custom darkness shader used by this animation */ - darknessShader?: AdaptiveDarknessShader | undefined; + darknessShader: typeof AdaptiveDarknessShader; + /** * The animation seed */ - seed?: number | undefined; + seed: number; + /** * The animation time */ - time?: number | undefined; - } + time: number; + }>; - interface RenderedEffectSourceLayer { + /** + * @remarks The properties `mesh` and `shader` from `LayerConfig` are not documented as being part of the typedef. They are given values + * during initialization *if* the Source has a valid `Placeable` as its `object`. `vmUniforms` is only provided a value for `PointVisionSource` layers. + */ + interface SourceLayer extends LayerConfig { /** * Is this layer actively rendered? */ active: boolean; + /** * Do uniforms need to be reset? */ reset: boolean; + /** * Is this layer temporarily suppressed? */ suppressed: boolean; + /** * The rendered mesh for this layer */ - mesh: PointSourceMesh; + mesh: PointSourceMesh | undefined; + /** * The shader instance used for the layer */ - shader: AdaptiveLightingShader; + shader: AdaptiveLightingShader | undefined; + + /** @remarks Foundry does not include this in the typedef but is in the initalization of `RenderedEffectSource#layers` */ + vmUniforms: AbstractBaseShader.Uniforms | undefined; } - interface RenderedEffectLayerConfig { + interface LayerConfig { /** * The default shader used by this layer */ - defaultShader: AdaptiveLightingShader; + defaultShader: typeof AdaptiveLightingShader; + /** * The blend mode used by this layer */ - blendMode: PIXI.BLEND_MODES; + blendMode: keyof typeof PIXI.BLEND_MODES; } - // Interface causes errors + // Interface would require `RenderingLayers extends ... = InterfaceToObject` in every subclass signature // eslint-disable-next-line @typescript-eslint/consistent-type-definitions type Layers = { - background: RenderedEffectSource.RenderedEffectSourceLayer; - coloration: RenderedEffectSource.RenderedEffectSourceLayer; - illumination: RenderedEffectSource.RenderedEffectSourceLayer; + background: RenderedEffectSource.SourceLayer; + coloration: RenderedEffectSource.SourceLayer; + illumination: RenderedEffectSource.SourceLayer; }; } +declare abstract class AnyRenderedEffectSource extends RenderedEffectSource { + constructor(arg0: never, ...args: never[]); +} + export default RenderedEffectSource; diff --git a/src/foundry/client-esm/dice/terms/dice.d.mts b/src/foundry/client-esm/dice/terms/dice.d.mts index 16b8887ab..ceb46bc3c 100644 --- a/src/foundry/client-esm/dice/terms/dice.d.mts +++ b/src/foundry/client-esm/dice/terms/dice.d.mts @@ -315,7 +315,10 @@ declare abstract class DiceTerm extends RollTerm { /* Serialization & Loading */ /* -------------------------------------------- */ - protected static _fromData(this: T, data: Record): InstanceType; + protected static _fromData( + this: T, + data: Record, + ): InstanceType; override toJSON(): Record; } diff --git a/src/foundry/client/config.d.mts b/src/foundry/client/config.d.mts index d3060d76c..9e20d19cf 100644 --- a/src/foundry/client/config.d.mts +++ b/src/foundry/client/config.d.mts @@ -1,7 +1,7 @@ import type * as CONST from "../common/constants.d.mts"; import type { DataModel, Document } from "../common/abstract/module.d.mts"; -import type PointLightSource from "../client-esm/canvas/sources/point-light-source.d.mts"; import type { GetKey, AnyObject, HandleEmptyObject, MaybePromise } from "../../utils/index.d.mts"; +import type BaseLightSource from "../client-esm/canvas/sources/base-light-source.d.mts"; declare global { namespace CONFIG { @@ -1027,13 +1027,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateFlickering` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `FlameIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `FlameColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; torch: { @@ -1041,13 +1041,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTorch` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `TorchIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `TorchColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; revolving: { @@ -1055,10 +1055,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `RevolvingColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; siren: { @@ -1066,13 +1066,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTorch` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `SirenIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `SirenIlluminationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; pulse: { @@ -1080,13 +1080,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animatePulse` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `PulseIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `PulseColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; chroma: { @@ -1094,10 +1094,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `ChromaColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; wave: { @@ -1105,13 +1105,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `WaveIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `WaveColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; fog: { @@ -1119,10 +1119,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `FogColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; sunburst: { @@ -1130,13 +1130,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `SunburstIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `SunburstColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; dome: { @@ -1144,10 +1144,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `LightDomeColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; emanation: { @@ -1155,10 +1155,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `EmanationColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; hexa: { @@ -1166,10 +1166,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `HexaDomeColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; ghost: { @@ -1177,13 +1177,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `GhostLightIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `GhostLightColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; energy: { @@ -1191,10 +1191,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `EnergyFieldColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; vortex: { @@ -1202,13 +1202,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `VortexIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `VortexColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; witchwave: { @@ -1216,13 +1216,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `BewitchingWaveIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `BewitchingWaveColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; rainbowswirl: { @@ -1230,10 +1230,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `SwirlingRainbowColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; radialrainbow: { @@ -1241,10 +1241,10 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `RadialRainbowColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; fairy: { @@ -1252,13 +1252,13 @@ declare global { label: string; /** @defaultValue `foundry.canvas.sources.LightSource.prototype.animateTime` */ - animation: CONFIG.Canvas.LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; /** @defaultValue `FairyLightIlluminationShader` */ - illuminationShader: typeof AbstractBaseShader; + illuminationShader: typeof AdaptiveIlluminationShader; /** @defaultValue `FairyLightColorationShader` */ - colorationShader: typeof AbstractBaseShader; + colorationShader: typeof AdaptiveColorationShader; }; }; @@ -2990,10 +2990,10 @@ declare global { string, { label: string; - animation: LightAnimationFunction; + animation: BaseLightSource.LightAnimationFunction; backgroundShader?: typeof AdaptiveBackgroundShader; - illuminationShader?: typeof AbstractBaseShader; - colorationShader?: typeof AbstractBaseShader; + illuminationShader?: typeof AdaptiveIlluminationShader; + colorationShader?: typeof AdaptiveColorationShader; } >; @@ -3002,18 +3002,13 @@ declare global { */ type DarknessSourceAnimationConfig = Record< string, - { label: string; animation: LightAnimationFunction; darknessShader: typeof AdaptiveDarknessShader } + { + label: string; + animation: BaseLightSource.LightAnimationFunction; + darknessShader: typeof AdaptiveDarknessShader; + } >; - type LightAnimationFunction = ( - // `this` is technically not a `PointLightSource`. - // Instead it is `foundry.canvas.sources.Pointfoundry.canvas.sources.LightSource.prototype`. - // However differentiating this would be a lot of work for little gain as nothing critical happens in the constructor. - this: PointLightSource, - dt: number, - properties?: { speed?: number; intensity?: number; reverse?: false }, - ) => void; - namespace Pings { interface Style { class: unknown; diff --git a/src/foundry/client/data/abstract/client-document.d.mts b/src/foundry/client/data/abstract/client-document.d.mts index e1da94775..4b65bd830 100644 --- a/src/foundry/client/data/abstract/client-document.d.mts +++ b/src/foundry/client/data/abstract/client-document.d.mts @@ -88,7 +88,10 @@ declare class ClientDocument; /** * A perception manager interface for batching lighting, sight, and sound updates diff --git a/src/foundry/client/pixi/core/interaction/render-flags.d.mts b/src/foundry/client/pixi/core/interaction/render-flags.d.mts index 660b22f91..c1c20421e 100644 --- a/src/foundry/client/pixi/core/interaction/render-flags.d.mts +++ b/src/foundry/client/pixi/core/interaction/render-flags.d.mts @@ -86,7 +86,7 @@ declare global { * Valid options are OBJECTS or PERCEPTION. * @defaultValue `PIXI.UPDATE_PRIORITY.OBJECTS` */ - priority?: PIXI.UPDATE_PRIORITY.OBJECTS | PIXI.UPDATE_PRIORITY.PERCEPTION; + priority?: PIXI.UPDATE_PRIORITY; }, ); diff --git a/src/foundry/client/pixi/layers/controls/layer.d.mts b/src/foundry/client/pixi/layers/controls/layer.d.mts index 235a0a95d..66d675f3d 100644 --- a/src/foundry/client/pixi/layers/controls/layer.d.mts +++ b/src/foundry/client/pixi/layers/controls/layer.d.mts @@ -1,4 +1,9 @@ -import type { IntentionalPartial, InexactPartial, NullishProps, RemoveIndexSignatures } from "../../../../../utils/index.d.mts"; +import type { + IntentionalPartial, + InexactPartial, + NullishProps, + RemoveIndexSignatures, +} from "../../../../../utils/index.d.mts"; import type { LineIntersection } from "../../../../common/utils/geometry.d.mts"; declare global { diff --git a/src/foundry/client/pixi/layers/effects/visibility.d.mts b/src/foundry/client/pixi/layers/effects/visibility.d.mts index be8fe4987..58f340c6f 100644 --- a/src/foundry/client/pixi/layers/effects/visibility.d.mts +++ b/src/foundry/client/pixi/layers/effects/visibility.d.mts @@ -211,11 +211,15 @@ declare global { interface CanvasVisibilityTest { point: PIXI.Point; + elevation: number; los: Map; } interface CanvasVisibilityTestConfig { + /** The target object */ object: PlaceableObject | null; + + /** An array of visibility tests */ tests: CanvasVisibilityTest[]; } } diff --git a/src/foundry/common/data/data.d.mts b/src/foundry/common/data/data.d.mts index f4c0e7bfd..7300dc103 100644 --- a/src/foundry/common/data/data.d.mts +++ b/src/foundry/common/data/data.d.mts @@ -2,7 +2,7 @@ import type { DatabaseBackend } from "../abstract/module.d.mts"; import type { DataModel } from "../abstract/data.d.mts"; import type { fields } from "./module.d.mts"; import type * as documents from "../documents/_module.d.mts"; -import type { AnyObject, EmptyObject, ToMethod, ValueOf } from "../../../utils/index.d.mts" +import type { AnyObject, EmptyObject, ToMethod, ValueOf } from "../../../utils/index.d.mts"; // TODO: Implement all of the necessary options diff --git a/src/foundry/common/grid/_module.d.mts b/src/foundry/common/grid/_module.d.mts index acfbdc7cd..eb793d528 100644 --- a/src/foundry/common/grid/_module.d.mts +++ b/src/foundry/common/grid/_module.d.mts @@ -7,4 +7,4 @@ export { default as BaseGrid } from "./base.mjs"; export { default as GridHex } from "./grid-hex.mjs"; export { default as GridlessGrid } from "./gridless.mjs"; export { default as HexagonalGrid } from "./hexagonal.mjs"; -export { default as SquareHex } from "./square.mjs"; +export { default as SquareGrid } from "./square.mjs"; diff --git a/src/types/augments/particles.d.mts b/src/types/augments/particles.d.mts new file mode 100644 index 000000000..9e904fdae --- /dev/null +++ b/src/types/augments/particles.d.mts @@ -0,0 +1,11 @@ +/* eslint-disable import/export */ + +import * as pixiParticles from "@pixi/particle-emitter"; +import type { Brand } from "src/utils/index.d.mts"; + +export namespace behaviors { + type BehaviorOrder = Brand; + const BehaviorOrder: Record; +} + +export * from "@pixi/particle-emitter"; diff --git a/src/types/augments/pixi.d.mts b/src/types/augments/pixi.d.mts index 99566ab47..d162145c1 100644 --- a/src/types/augments/pixi.d.mts +++ b/src/types/augments/pixi.d.mts @@ -1,6 +1,14 @@ import * as _PIXI from "pixi.js"; -import * as pixiParticles from "@pixi/particle-emitter"; -import * as graphicsSmooth from "@pixi/graphics-smooth"; +import type { Brand } from "src/utils/index.d.mts"; + +// Note(LukeAbby): The `smooth.d.mts` and `smooth.d.mts` files exist to make it DRY to selectively tweak PIXI sub-namespaces. +// Each of them write `export * from "..."` and then selectively shadow or augment the exports. + +// eslint-disable-next-line import/extensions +import * as _smooth from "./smooth.mjs"; + +// eslint-disable-next-line import/extensions +import * as _particles from "./particles.mjs"; export * from "pixi.js"; @@ -11,8 +19,93 @@ export as namespace PIXI; declare global { namespace PIXI { - export import smooth = graphicsSmooth; - export import particles = pixiParticles; + /***************************** + * Enum to Brand conversions * + *****************************/ + type ALPHA_MODES = Brand; + const ALPHA_MODES: Record; + + /** @privateRemarks Merges Foundry's extra keys */ + type BLEND_MODES = Brand; + const BLEND_MODES: Record; + + type BUFFER_BITS = Brand; + const BUFFER_BITS: Record; + + type BUFFER_TYPE = Brand; + const BUFFER_TYPE: Record; + + type CLEAR_MODES = Brand; + const CLEAR_MODES: Record; + + type COLOR_MASK_BITS = Brand; + const COLOR_MASK_BITS: Record; + + type DRAW_MODES = Brand; + const DRAW_MODES: Record; + + type ENV = Brand; + const ENV: Record; + + type ExtensionType = Brand; + const ExtensionType: Record; + + type FORMATS = Brand; + const FORMATS: Record; + + type GC_MODES = Brand; + const GC_MODES: Record; + + type INTERNAL_FORMATS = Brand; + const INTERNAL_FORMATS: Record; + + type LINE_CAP = Brand; + const LINE_CAP: Record; + + type LINE_JOIN = Brand; + const LINE_JOIN: Record; + + type LoaderParserPriority = Brand; + const LoaderParserPriority: Record; + + type MASK_TYPES = Brand; + const MASK_TYPES: Record; + + type MIPMAP_MODES = Brand; + const MIPMAP_MODES: Record; + + type MSAA_QUALITY = Brand; + const MSAA_QUALITY: Record; + + type PRECISION = Brand; + const PRECISION: Record; + + type RENDERER_TYPE = Brand; + const RENDERER_TYPE: Record; + + type SAMPLER_TYPES = Brand; + const SAMPLER_TYPES: Record; + + type SCALE_MODES = Brand; + const SCALE_MODES: Record; + + type SHAPES = Brand; + const SHAPES: Record; + + type TARGETS = Brand; + const TARGET: Record; + + type TEXT_GRADIENT = Brand; + const TEXT_GRADIENT: Record; + + type UPDATE_PRIORITY = Brand; + const UPDATE_PRIORITY: Record; + + type WRAP_MODES = Brand; + const WRAP_MODES: Record; + + export import smooth = _smooth; + export import particles = _particles; export class Graphics extends PIXI.smooth.SmoothGraphics {} diff --git a/src/types/augments/smooth.d.mts b/src/types/augments/smooth.d.mts new file mode 100644 index 000000000..7f0ba7ef0 --- /dev/null +++ b/src/types/augments/smooth.d.mts @@ -0,0 +1,13 @@ +import type { Brand } from "src/utils/index.d.mts"; +import * as graphicsSmooth from "@pixi/graphics-smooth"; + +type JOINT_TYPE = Brand; +declare const JOINT_TYPE: Record; + +type LINE_SCALE_MODE = Brand; +declare const LINE_SCALE_MODE: Record; + +// eslint-disable-next-line +export * from "@pixi/graphics-smooth"; +// eslint-disable-next-line +export { JOINT_TYPE, LINE_SCALE_MODE }; diff --git a/tests/foundry/client-esm/canvas/sources/base-effect-source.mjs.test-d.ts b/tests/foundry/client-esm/canvas/sources/base-effect-source.mjs.test-d.ts index dfc93a283..c3b7c1554 100644 --- a/tests/foundry/client-esm/canvas/sources/base-effect-source.mjs.test-d.ts +++ b/tests/foundry/client-esm/canvas/sources/base-effect-source.mjs.test-d.ts @@ -1,5 +1,6 @@ import { expectTypeOf } from "vitest"; +import type BaseEffectSource from "../../../../../src/foundry/client-esm/canvas/sources/base-effect-source.d.mts"; -const mySource = new foundry.canvas.sources.BaseEffectSource(); +declare const mySource: BaseEffectSource; expectTypeOf(mySource.active).toEqualTypeOf(); diff --git a/tests/foundry/client-esm/canvas/sources/base-light-source.mjs.test-d.ts b/tests/foundry/client-esm/canvas/sources/base-light-source.mjs.test-d.ts index c9766a0d3..8f7060de0 100644 --- a/tests/foundry/client-esm/canvas/sources/base-light-source.mjs.test-d.ts +++ b/tests/foundry/client-esm/canvas/sources/base-light-source.mjs.test-d.ts @@ -1,7 +1,8 @@ import { expectTypeOf } from "vitest"; +import type BaseLightSource from "../../../../../src/foundry/client-esm/canvas/sources/base-light-source.d.mts"; -const mySource = new foundry.canvas.sources.BaseLightSource(); +declare const mySource: BaseLightSource; expectTypeOf(mySource.active).toEqualTypeOf(); -expectTypeOf(mySource.drawMeshes().background.visible).toEqualTypeOf(); +expectTypeOf(mySource.drawMeshes().background?.visible).toEqualTypeOf(); expectTypeOf(mySource.animateTorch(5)).toEqualTypeOf(); diff --git a/tests/foundry/client-esm/canvas/sources/point-darkness-sources.mjs.test-d.ts b/tests/foundry/client-esm/canvas/sources/point-darkness-sources.mjs.test-d.ts index e277f89f3..df2386ba3 100644 --- a/tests/foundry/client-esm/canvas/sources/point-darkness-sources.mjs.test-d.ts +++ b/tests/foundry/client-esm/canvas/sources/point-darkness-sources.mjs.test-d.ts @@ -2,8 +2,10 @@ import { expectTypeOf } from "vitest"; const mySource = new foundry.canvas.sources.PointDarknessSource(); +expectTypeOf(mySource.data).toEqualTypeOf(); expectTypeOf(mySource.active).toEqualTypeOf(); -expectTypeOf(mySource.drawMeshes().background.visible).toEqualTypeOf(); +expectTypeOf(mySource.drawMeshes().darkness).toEqualTypeOf(); +expectTypeOf(mySource.drawMeshes().darkness?.visible).toEqualTypeOf(); expectTypeOf(mySource.animateTorch(5)).toEqualTypeOf(); expectTypeOf(mySource.add()).toEqualTypeOf(); expectTypeOf(mySource.shape).toEqualTypeOf(); diff --git a/tests/foundry/client-esm/canvas/sources/point-light-source.mjs.test-d.ts b/tests/foundry/client-esm/canvas/sources/point-light-source.mjs.test-d.ts index 8b399678f..20b959643 100644 --- a/tests/foundry/client-esm/canvas/sources/point-light-source.mjs.test-d.ts +++ b/tests/foundry/client-esm/canvas/sources/point-light-source.mjs.test-d.ts @@ -3,7 +3,7 @@ import { expectTypeOf } from "vitest"; const mySource = new foundry.canvas.sources.PointLightSource(); expectTypeOf(mySource.active).toEqualTypeOf(); -expectTypeOf(mySource.drawMeshes().background.visible).toEqualTypeOf(); +expectTypeOf(mySource.drawMeshes().background?.visible).toEqualTypeOf(); expectTypeOf(mySource.animateTorch(5)).toEqualTypeOf(); expectTypeOf(mySource.add()).toEqualTypeOf(); expectTypeOf(mySource.shape).toEqualTypeOf(); diff --git a/tests/foundry/client-esm/canvas/sources/point-movement-source.mjs.test-d.ts b/tests/foundry/client-esm/canvas/sources/point-movement-source.mjs.test-d.ts index 3dc1d6755..1eec56be1 100644 --- a/tests/foundry/client-esm/canvas/sources/point-movement-source.mjs.test-d.ts +++ b/tests/foundry/client-esm/canvas/sources/point-movement-source.mjs.test-d.ts @@ -1,8 +1,9 @@ import { expectTypeOf } from "vitest"; +import type PointMovementSource from "../../../../../src/foundry/client-esm/canvas/sources/point-movement-source.d.mts"; const mySource = new foundry.canvas.sources.PointMovementSource(); expectTypeOf(mySource.active).toEqualTypeOf(); -expectTypeOf( - mySource.initialize({ x: 3, y: 5, elevation: 7 }), -).toEqualTypeOf(); +expectTypeOf(mySource.initialize({ x: 3, y: 5, elevation: 7 })).toEqualTypeOf(); +expectTypeOf(mySource.shape).toEqualTypeOf(); +expectTypeOf(mySource.data).toEqualTypeOf(); diff --git a/tests/foundry/client-esm/canvas/sources/point-sound-source.mjs.test-d.ts b/tests/foundry/client-esm/canvas/sources/point-sound-source.mjs.test-d.ts index 35037e40d..d4374b953 100644 --- a/tests/foundry/client-esm/canvas/sources/point-sound-source.mjs.test-d.ts +++ b/tests/foundry/client-esm/canvas/sources/point-sound-source.mjs.test-d.ts @@ -1,8 +1,9 @@ import { expectTypeOf } from "vitest"; +import type PointSoundSource from "../../../../../src/foundry/client-esm/canvas/sources/point-sound-source.d.mts"; const mySource = new foundry.canvas.sources.PointSoundSource(); expectTypeOf(mySource.active).toEqualTypeOf(); -expectTypeOf( - mySource.initialize({ radius: 5, walls: true, disabled: false }), -).toEqualTypeOf(); +expectTypeOf(mySource.initialize({ radius: 5, walls: true, disabled: false })).toEqualTypeOf(); +expectTypeOf(mySource.shape).toEqualTypeOf(); +expectTypeOf(mySource.data).toEqualTypeOf(); diff --git a/tests/foundry/client-esm/canvas/sources/point-vision-source.mjs.test-d.ts b/tests/foundry/client-esm/canvas/sources/point-vision-source.mjs.test-d.ts index bf690de43..510338d67 100644 --- a/tests/foundry/client-esm/canvas/sources/point-vision-source.mjs.test-d.ts +++ b/tests/foundry/client-esm/canvas/sources/point-vision-source.mjs.test-d.ts @@ -1,6 +1,10 @@ import { expectTypeOf } from "vitest"; +import type PointVisionSource from "../../../../../src/foundry/client-esm/canvas/sources/point-vision-source.d.mts"; const mySource = new foundry.canvas.sources.PointVisionSource(); expectTypeOf(mySource.active).toEqualTypeOf(); -expectTypeOf(mySource.drawMeshes().background.visible).toEqualTypeOf(); +expectTypeOf(mySource.drawMeshes().background?.visible).toEqualTypeOf(); +expectTypeOf(mySource.data).toEqualTypeOf(); +expectTypeOf(mySource.shape).toEqualTypeOf(); +expectTypeOf(mySource._configureShaders().background).toEqualTypeOf(); diff --git a/tests/foundry/client-esm/canvas/sources/rendered-effect-source.mjs.test-d.ts b/tests/foundry/client-esm/canvas/sources/rendered-effect-source.mjs.test-d.ts index 814c1a482..db8d2a527 100644 --- a/tests/foundry/client-esm/canvas/sources/rendered-effect-source.mjs.test-d.ts +++ b/tests/foundry/client-esm/canvas/sources/rendered-effect-source.mjs.test-d.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from "vitest"; const mySource = new foundry.canvas.sources.RenderedEffectSource(); - +const meshes = mySource.drawMeshes(); expectTypeOf(mySource.active).toEqualTypeOf(); -expectTypeOf(mySource.drawMeshes().background.visible).toEqualTypeOf(); +expectTypeOf(meshes.background?.visible).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/board.test-d.ts b/tests/foundry/client/pixi/board.test-d.ts index 69dbfbdb6..12f76db69 100644 --- a/tests/foundry/client/pixi/board.test-d.ts +++ b/tests/foundry/client/pixi/board.test-d.ts @@ -14,19 +14,21 @@ expectTypeOf(myCanvas.getLayerByEmbeddedName("Token")).toEqualTypeOf(); expectTypeOf(myCanvas.getLayerByEmbeddedName("any-string")).toEqualTypeOf(); -expectTypeOf(myCanvas.animatePan()).toEqualTypeOf>(); -expectTypeOf(myCanvas.animatePan({})).toEqualTypeOf>(); -expectTypeOf(myCanvas.animatePan({ x: 100, y: 100, scale: 1, duration: 250, speed: 10 })).toEqualTypeOf< - Promise +expectTypeOf(myCanvas.animatePan({})).toEqualTypeOf>(); +expectTypeOf( + myCanvas.animatePan({ x: 100, y: 100, scale: 1, duration: 250, easing: (pt: number) => pt }), +).toEqualTypeOf>(); +expectTypeOf(myCanvas.animatePan({ x: 500, y: 500, scale: 10, speed: 6, easing: "easeInCircle" })).toEqualTypeOf< + Promise >(); -expectTypeOf(myCanvas.recenter()).toEqualTypeOf>(); -expectTypeOf(myCanvas.recenter({})).toEqualTypeOf>(); -expectTypeOf(myCanvas.recenter({ x: null, y: null, scale: null })).toEqualTypeOf>(); -expectTypeOf(myCanvas.recenter({ x: 100, y: 100, scale: 1 })).toEqualTypeOf>(); +expectTypeOf(myCanvas.recenter()).toEqualTypeOf>(); +expectTypeOf(myCanvas.recenter({})).toEqualTypeOf>(); +expectTypeOf(myCanvas.recenter({ x: null, y: null, scale: null })).toEqualTypeOf>(); +expectTypeOf(myCanvas.recenter({ x: 100, y: 100, scale: 1 })).toEqualTypeOf>(); myCanvas.pendingRenderFlags.OBJECTS.add(myCanvas.perception); expectTypeOf(myCanvas.hidden).toEqualTypeOf(); -expectTypeOf(myCanvas.rendered).toEqualTypeOf(); -expectTypeOf(myCanvas.environment).toEqualTypeOf(); +expectTypeOf(myCanvas.rendered).toEqualTypeOf(); +expectTypeOf(myCanvas.environment).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/layers/base/placeables-layer.test-d.ts b/tests/foundry/client/pixi/layers/base/placeables-layer.test-d.ts index eaa619ae9..32b0cc244 100644 --- a/tests/foundry/client/pixi/layers/base/placeables-layer.test-d.ts +++ b/tests/foundry/client/pixi/layers/base/placeables-layer.test-d.ts @@ -64,11 +64,11 @@ expectTypeOf(layer.rotateMany({ angle: 10, delta: 20, snap: 20, ids: ["abc", "de >(); expectTypeOf(layer.moveMany()).toEqualTypeOf | undefined>(); expectTypeOf(layer.moveMany({})).toEqualTypeOf | undefined>(); -expectTypeOf(layer.moveMany({ dx: 100, dy: 100, rotate: true, ids: ["abc", "def"] })).toEqualTypeOf< +expectTypeOf(layer.moveMany({ dx: 1, dy: -1, rotate: true, ids: ["abc", "def"] })).toEqualTypeOf< Promise | undefined >(); expectTypeOf(layer.undoHistory()).toEqualTypeOf>(); -expectTypeOf(layer.deleteAll()).toEqualTypeOf>(); +expectTypeOf(layer.deleteAll()).toEqualTypeOf>(); expectTypeOf(layer.storeHistory("create", new AmbientLightDocument()["_source"])).toEqualTypeOf(); expectTypeOf(layer.storeHistory("update", new AmbientLightDocument()["_source"])).toEqualTypeOf(); expectTypeOf(layer.storeHistory("delete", new AmbientLightDocument()["_source"])).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/layers/grid/grid.test-d.ts b/tests/foundry/client/pixi/layers/grid/grid.test-d.ts deleted file mode 100644 index 4260a0052..000000000 --- a/tests/foundry/client/pixi/layers/grid/grid.test-d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { expectTypeOf } from "vitest"; - -const myGrid = new foundry.grid.BaseGrid({ - dimensions: { - width: 1, - height: 2, - sceneHeight: 3, - sceneRect: { x: 1, y: 2, width: 3, height: 4 }, - sceneWidth: 5, - sceneX: 6, - sceneY: 7, - size: 8, - rect: { x: 1, y: 2, width: 3, height: 4 }, - distance: 9, - maxR: 10, - ratio: 11, - }, - color: "0x000000", - alpha: 3, -}); - -expectTypeOf(myGrid.draw()).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/layers/grid/hex.test-d.ts b/tests/foundry/client/pixi/layers/grid/hex.test-d.ts deleted file mode 100644 index 2b1c290fb..000000000 --- a/tests/foundry/client/pixi/layers/grid/hex.test-d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { expectTypeOf } from "vitest"; - -HexagonalGrid.pixelsToOffset({ x: 3, y: 2 }, { columns: true, even: false, size: 4 }, "floor"); - -const myGrid = new HexagonalGrid({ columns: true, even: false, size: 4 }); - -expectTypeOf(myGrid.draw()).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/layers/grid/square.test-d.ts b/tests/foundry/client/pixi/layers/grid/square.test-d.ts deleted file mode 100644 index 94697e4e4..000000000 --- a/tests/foundry/client/pixi/layers/grid/square.test-d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { expectTypeOf } from "vitest"; - -const myGrid = new SquareGrid({ - dimensions: { - width: 1, - height: 2, - sceneHeight: 3, - sceneRect: { x: 1, y: 2, width: 3, height: 4 }, - sceneWidth: 5, - sceneX: 6, - sceneY: 7, - size: 8, - rect: { x: 1, y: 2, width: 3, height: 4 }, - distance: 9, - maxR: 10, - ratio: 11, - }, - color: "0x000000", - alpha: 3, -}); - -expectTypeOf(myGrid.draw()).toEqualTypeOf(); diff --git a/tests/foundry/common/grid/hex.test-d.ts b/tests/foundry/common/grid/hex.test-d.ts new file mode 100644 index 000000000..f555d461b --- /dev/null +++ b/tests/foundry/common/grid/hex.test-d.ts @@ -0,0 +1,10 @@ +import type HexagonalGrid from "src/foundry/common/grid/hexagonal.d.mts"; +import { expectTypeOf } from "vitest"; + +const hexGrid = new foundry.grid.HexagonalGrid({ + columns: false, + even: true, + size: 200, +}); + +expectTypeOf(hexGrid.getOffset({ q: 50, r: 200, s: 500 })).toEqualTypeOf(); diff --git a/tests/foundry/common/grid/square.test-d.ts b/tests/foundry/common/grid/square.test-d.ts new file mode 100644 index 000000000..4d4ee4391 --- /dev/null +++ b/tests/foundry/common/grid/square.test-d.ts @@ -0,0 +1,16 @@ +import type SquareGrid from "src/foundry/common/grid/square.d.mts"; +import { expectTypeOf } from "vitest"; + +const myGrid = new foundry.grid.SquareGrid({ + diagonals: CONST.GRID_DIAGONALS.ALTERNATING_1, + size: 100, + color: "0x000000", + alpha: 3, +}); + +expectTypeOf( + myGrid.getDirectPath([ + { i: 30, j: 200 }, + { x: 2000, y: 2000 }, + ]), +).toEqualTypeOf();