Skip to content

Commit

Permalink
Add some minor type updates for 12.323 (foundryvtt#14743)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFdez committed May 29, 2024
1 parent da634bd commit 0bc0780
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export default class HTMLDocumentTagsElement extends AbstractFormInputElement<
* Create an HTML string fragment for a single document tag.
* @param uuid The document UUID
* @param name The document name
* @param [editable=true] Is the tag editable?
*/
static renderTag(uuid: DocumentUUID, name: string): string;
static renderTag(uuid: DocumentUUID, name: string, editable?: boolean): string;

/** Create a HTMLDocumentTagsElement using provided configuration data. */
static create(config: DocumentTagsInputConfig): HTMLDocumentTagsElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export abstract class AbstractFormInputElement<TInternalValue, TInputValue = TIn
get disabled(): boolean;
set disabled(value: boolean);

/** Is this field editable? The field can be neither disabled nor readonly. */
get editable(): boolean;

/**
* Special behaviors that the subclass should implement when toggling the disabled state of the input.
* @param disabled The new disabled state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import type { AbstractFormInputElement } from "./form-element.d.ts";
export default class HTMLRangePickerElement extends AbstractFormInputElement<number> {
static override tagName: "range-picker";

/** The value of the input element. */
get valueAsNumber(): number;

protected override _buildElements(): HTMLInputElement[];

/** Create a HTMLRangePickerElement using provided configuration data. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export default class HTMLStringTagsElement extends AbstractFormInputElement<Set<
* Render the HTML fragment used to represent a tag.
* @param tag The raw tag value
* @param label An optional tag element
* @param [editable=true] Is the tag editable?
* @returns An HTML string for the tag
*/
static renderTag(tag: string, label?: string): string;
static renderTag(tag: string, label?: string, editable?: boolean): string;

/* -------------------------------------------- */
/* Form Handling */
Expand Down
2 changes: 2 additions & 0 deletions types/foundry/client-esm/applications/forms/fields.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ declare global {
interface FormGroupConfig {
/** A text label to apply to the form group */
label: string;
/** An optional units string which is appended to the label */
units?: string;
/** An HTML element or collection of elements which provide the inputs for the group */
input: HTMLElement | HTMLCollection;
/** Hint text displayed as part of the form group */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
import type { Edge } from "../edges/edge.js";
import type { PointEffectLightSource } from "./point-effect-source-mixes.ts";

export default class PointDarknessSource<
TObject extends Token | AmbientLight | null,
> extends PointEffectLightSource<TObject> {}
> extends PointEffectLightSource<TObject> {
/**
* The optional geometric shape is solely utilized for visual representation regarding darkness sources.
* Used only when an additional radius is added for visuals.
*/
_visualShape: PointSourcePolygon;

/**
* 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.
*/
protected _padding: number;

/** The Edge instances used by this darkness source */
edges: Edge[];

/* -------------------------------------------- */
/* Darkness Source Properties */
/* -------------------------------------------- */

/** A convenience accessor to the darkness layer mesh. */
get darkness(): PointSourceMesh;

/* -------------------------------------------- */
/* Shader Management */
/* -------------------------------------------- */

/** Update the uniforms of the shader on the darkness layer. */
_updateDarknessUniforms(): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ export default class PointVisionSource<
/** Data overrides that could happen with blindness vision mode. */
visionModeOverrides: object;

static blindedColorRGB(): number[];

/* -------------------------------------------- */
/* Vision Source Initialization */
/* -------------------------------------------- */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* @see {@link Macro} The Macro Entity which is being configured
*/
declare class MacroConfig<TMacro extends Macro> extends DocumentSheet<TMacro> {
/** Should this Macro be created in a specific hotbar slot? */
_hotbarSlot?: boolean;

override getData(options?: DocumentSheetOptions): MacroConfigData<TMacro>;

override activateListeners(html: JQuery): void;
Expand Down
6 changes: 5 additions & 1 deletion types/foundry/client/apps/form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ declare global {
* Handle saving the content of a specific editor by name
* @param name The named editor to save
* @param [remove] Remove the editor after saving its content
* @param [preventRender] Prevent normal re-rendering of the sheet after saving
*/
saveEditor(name: string, { remove }?: { remove?: boolean }): Promise<void>;
saveEditor(
name: string,
{ remove, preventRender }?: { remove?: boolean; preventRender?: boolean },
): Promise<void>;

/** Activate a TinyMCE editor instance present within the form */
protected _activateEditor(div: JQuery | HTMLElement): void;
Expand Down
5 changes: 4 additions & 1 deletion types/foundry/client/data/collections/scenes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ declare global {
/* -------------------------------------------- */

/** @override */
fromCompendium(document: TScene): foundry.documents.SceneSource;
fromCompendium(
document: TScene,
{ clearState, clearSort }?: { clearState?: boolean } & FromCompendiumOptions,
): foundry.documents.SceneSource;
}
}
6 changes: 0 additions & 6 deletions types/foundry/client/pixi/board.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,6 @@ declare global {
* @param event The originating mouse movement event
*/
_onDragCanvasPan(event: MouseEvent): void;

/**
* Determine selection coordinate rectangle during a mouse-drag workflow
* @param event
*/
_onDragSelect(event: PIXI.FederatedEvent): void;
}

type DrawnCanvas<T extends Canvas = Canvas> = {
Expand Down
16 changes: 16 additions & 0 deletions types/foundry/client/pixi/groups/effects.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ declare global {
/** Refresh the active display of lighting. */
refreshLighting(): void;

/**
* Test whether the point is inside light.
* @param position The point.
* @param elevation The elevation of the point.
* @returns Is inside light?
*/
testInsideLight(position: Point, elevation: number): boolean;

/**
* Test whether the point is inside darkness.
* @param position The point.
* @param elevation The elevation of the point.
* @returns Is inside a darkness?
*/
testInsideDarkness(position: Point, elevation: number): boolean;

/**
* Activate vision masking for visual effects
* @param [enabled=true] Whether to enable or disable vision masking
Expand Down
20 changes: 14 additions & 6 deletions types/foundry/client/pixi/layers/base/interaction-layer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,42 +46,50 @@ declare abstract class InteractionLayer extends CanvasLayer {

/**
* Handle left mouse-click events which originate from the Canvas stage.
* @see {@link Canvas._onClickLeft}
* @see {@link Canvas.#onClickLeft}
* @param event The PIXI InteractionEvent which wraps a PointerEvent
*/
protected _onClickLeft(event: PIXI.FederatedPointerEvent): void;

/**
* Handle double left-click events which originate from the Canvas stage.
* @see {@link Canvas._onClickLeft2}
* @see {@link Canvas.#onClickLeft2}
* @param event The PIXI InteractionEvent which wraps a PointerEvent
*/
protected _onClickLeft2(event: PIXI.FederatedPointerEvent): void;

/**
* Does the User have permission to left-click drag on the Canvas?
* @param user The User performing the action.
* @param event The event object.
* @protected
*/
protected _canDragLeftStart(user: User, event: PIXI.FederatedEvent): boolean;

/**
* Start a left-click drag workflow originating from the Canvas stage.
* @see {@link Canvas._onDragLeftStart}
* @see {@link Canvas.#onDragLeftStart}
* @param event The PIXI InteractionEvent which wraps a PointerEvent
*/
protected _onDragLeftStart(event: PIXI.FederatedPointerEvent): object | void;

/**
* Continue a left-click drag workflow originating from the Canvas stage.
* @see {@link Canvas._onDragLeftMove}
* @see {@link Canvas.#onDragLeftMove}
* @param event The PIXI InteractionEvent which wraps a PointerEvent
*/
protected _onDragLeftMove(event: PIXI.FederatedPointerEvent): void;

/**
* Conclude a left-click drag workflow originating from the Canvas stage.
* @see {@link Canvas._onDragLeftDrop}
* @see {@link Canvas.#onDragLeftDrop}
* @param event The PIXI InteractionEvent which wraps a PointerEvent
*/
protected _onDragLeftDrop(event: PIXI.FederatedPointerEvent): void;

/**
* Cancel a left-click drag workflow originating from the Canvas stage.
* @see {@link Canvas._onDragLeftDrop}
* @see {@link Canvas.#onDragLeftDrop}
* @param event A right-click pointer event on the document.
*/
protected _onDragLeftCancel(event: PIXI.FederatedPointerEvent): void;
Expand Down
6 changes: 5 additions & 1 deletion types/foundry/client/pixi/layers/effects/visibility.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ declare global {
/** The configured options used for the saved fog-of-war texture. */
get textureConfiguration(): FogTextureConfiguration;

/** Optional overrides for exploration sprite dimensions. */
set explorationRect(rect: FogTextureConfiguration);

/* -------------------------------------------- */
/* Layer Initialization */
/* -------------------------------------------- */
Expand Down Expand Up @@ -118,13 +121,14 @@ declare global {

interface CanvasVisibilityTestConfig {
/** The target object */
object: PlaceableObject | DoorControl;
object: object | null;
/** An array of visibility tests */
tests: CanvasVisibilityTest[];
}

interface CanvasVisibilityTest {
point: Point;
elevation: number;
los: Map<PointVisionSource<Token>, boolean>;
}
}
3 changes: 2 additions & 1 deletion types/foundry/client/pixi/perception/vision-mode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ type VisionModeSchema = {
background: LightingSchema;
coloration: LightingSchema;
illumination: LightingSchema;
ignoreDarkness: fields.BooleanField;
darkness: LightingSchema;
levels: fields.ObjectField<{}>;
multipliers: fields.ObjectField<{}>;
}>;
vision: fields.SchemaField<{
background: ShaderSchema;
coloration: ShaderSchema;
illumination: ShaderSchema;
darkness: fields.SchemaField<{
adaptive: fields.BooleanField;
}>;
Expand Down
15 changes: 15 additions & 0 deletions types/foundry/client/pixi/placeable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ declare global {
/** Is the HUD display active for this Placeable? */
get hasActiveHUD(): boolean;

/**
* Get the snapped position for a given position or the current position.
* @param [position] The position to be used instead of the current position
* @returns The snapped position
*/
getSnappedPosition(position?: Point): Point;

/* -------------------------------------------- */
/* Rendering */
/* -------------------------------------------- */
Expand Down Expand Up @@ -283,6 +290,14 @@ declare global {
/** Does the User have permission to drag this Placeable Object? */
protected _canDrag(user: User, event?: PIXI.FederatedEvent): boolean;

/**
* Does the User have permission to left-click drag this Placeable Object?
* @param user The User performing the action.
* @param event The event object.
* @returns The returned status.
*/
protected _canDragLeftStart(user: User, event: PIXI.FederatedEvent): boolean;

/** Does the User have permission to hover on this Placeable Object? */
protected _canHover(user: User, event?: PIXI.FederatedEvent): boolean;

Expand Down

0 comments on commit 0bc0780

Please sign in to comment.