diff --git a/src/module/actor/base.ts b/src/module/actor/base.ts index 4db42a26524..05b887bc9c0 100644 --- a/src/module/actor/base.ts +++ b/src/module/actor/base.ts @@ -310,7 +310,7 @@ class ActorPF2e e.system.tokenIcon?.show && (e.isIdentified || game.user.isGM)) .map((e) => new TokenEffect(e)); - return R.uniqBy( + return R.uniqueBy( [super.temporaryEffects, fromConditions, fromEffects, this.synthetics.tokenEffectIcons].flat(), (e) => e.icon, ); diff --git a/src/module/actor/helpers.ts b/src/module/actor/helpers.ts index dd53165f855..b285cdcc280 100644 --- a/src/module/actor/helpers.ts +++ b/src/module/actor/helpers.ts @@ -94,7 +94,7 @@ function userColorForActor(actor: ActorPF2e): HexColorString { game.users.find((u) => u.character === actor) ?? game.users.players.find((u) => actor.testUserPermission(u, "OWNER")) ?? actor.primaryUpdater; - return user?.color ?? "#43dfdf"; + return user?.color.toString() ?? "#43dfdf"; } async function migrateActorSource(source: PreCreate): Promise { diff --git a/src/module/actor/token-effect.ts b/src/module/actor/token-effect.ts index 3ae5b5bd889..260625504d4 100644 --- a/src/module/actor/token-effect.ts +++ b/src/module/actor/token-effect.ts @@ -5,7 +5,7 @@ import { ActorPF2e } from "./base.ts"; export class TokenEffect implements TemporaryEffect { #effect: AbstractEffectPF2e; - tint: HexColorString | null = null; + tint: Color | null = null; readonly isTemporary = true; diff --git a/src/module/apps/sidebar/encounter-tracker.ts b/src/module/apps/sidebar/encounter-tracker.ts index 5db8c7ec7bb..61d2b05b643 100644 --- a/src/module/apps/sidebar/encounter-tracker.ts +++ b/src/module/apps/sidebar/encounter-tracker.ts @@ -202,7 +202,7 @@ export class EncounterTrackerPF2e exten const userIndicators = usersTargetting.map((user): HTMLElement => { const icon = fontAwesomeIcon("location-crosshairs", { style: "duotone", fixedWidth: true }); - icon.style.color = user.color; + icon.style.color = user.color.toString(); return icon; }); diff --git a/src/module/canvas/token/object.ts b/src/module/canvas/token/object.ts index ba8fb729312..4d70e0a8c03 100644 --- a/src/module/canvas/token/object.ts +++ b/src/module/canvas/token/object.ts @@ -96,6 +96,13 @@ class TokenPF2e extends return this.document.sight.range >= dimensions.maxR ? dimensions.maxR : super.sightRange; } + override initializeVisionSource(options?: { deleted?: boolean }): void { + super.initializeVisionSource(options); + if (!options?.deleted) { + this.hearing.initialize(); + } + } + isAdjacentTo(token: TokenPF2e): boolean { return this.distanceTo(token) === 5; } @@ -507,11 +514,11 @@ class TokenPF2e extends super.render(renderer); if (!this.mesh) return; - const configuredTint = this.document.texture.tint ?? "#FFFFFF"; + const configuredTint = this.document.texture.tint ?? Color.fromString("#FFFFFF"); if (this.mesh.tint !== 0 && this.detectionFilter instanceof OutlineOverlayFilter) { this.mesh.tint = 0; - } else if (this.mesh.tint === 0 && configuredTint !== "#000000" && !this.detectionFilter) { - this.mesh.tint = Number(Color.fromString(configuredTint)); + } else if (this.mesh.tint === 0 && configuredTint.toString() !== "#000000" && !this.detectionFilter) { + this.mesh.tint = Number(configuredTint); } } diff --git a/src/module/rules/rule-element/token-image.ts b/src/module/rules/rule-element/token-image.ts index 64f8a2ad4ce..78b175d2438 100644 --- a/src/module/rules/rule-element/token-image.ts +++ b/src/module/rules/rule-element/token-image.ts @@ -43,7 +43,7 @@ class TokenImageRuleElement extends RuleElementPF2e { if (!this.test()) return; - const texture: { src: VideoFilePath; scaleX?: number; scaleY?: number; tint?: HexColorString } = { src }; + const texture: { src: VideoFilePath; scaleX?: number; scaleY?: number; tint?: Color } = { src }; if (this.scale) { texture.scaleX = this.scale; texture.scaleY = this.scale; diff --git a/src/module/rules/synthetics.ts b/src/module/rules/synthetics.ts index f7c919d8081..9d6fef82361 100644 --- a/src/module/rules/synthetics.ts +++ b/src/module/rules/synthetics.ts @@ -21,6 +21,7 @@ import type { MaterialDamageEffect } from "@system/damage/types.ts"; import type { DegreeOfSuccessAdjustment } from "@system/degree-of-success.ts"; import type { Predicate } from "@system/predication.ts"; import type { Statistic } from "@system/statistic/index.ts"; +import type { TokenSource } from "types/foundry/common/documents/token.d.ts"; import type { DamageAlteration } from "./rule-element/damage-alteration/alteration.ts"; import type { Suboption } from "./rule-element/roll-option/data.ts"; @@ -53,10 +54,10 @@ interface RuleElementSynthetics { toggles: Record>; tokenEffectIcons: TokenEffect[]; tokenMarks: Map; - tokenOverrides: DeepPartial> & { + tokenOverrides: DeepPartial> & { texture?: - | { src: VideoFilePath; tint?: HexColorString } - | { src: VideoFilePath; tint?: HexColorString; scaleX: number; scaleY: number }; + | { src: VideoFilePath; tint?: Color } + | { src: VideoFilePath; tint?: Color; scaleX: number; scaleY: number }; }; weaponPotency: Record; } diff --git a/src/module/system/client-backend.ts b/src/module/system/client-backend.ts index 54fc498efa6..669f60fe592 100644 --- a/src/module/system/client-backend.ts +++ b/src/module/system/client-backend.ts @@ -4,7 +4,7 @@ import { MigrationList, MigrationRunner } from "@module/migration/index.ts"; import { UserPF2e } from "@module/user/document.ts"; import * as R from "remeda"; -class ClientDatabaseBackendPF2e extends ClientDatabaseBackend { +class ClientDatabaseBackendPF2e extends foundry.data.ClientDatabaseBackend { protected override async _getDocuments( documentClass: typeof foundry.abstract.Document, context: DatabaseBackendGetContext, diff --git a/src/module/user/sheet.ts b/src/module/user/sheet.ts index fd6ea96a3b1..2dcde4f400b 100644 --- a/src/module/user/sheet.ts +++ b/src/module/user/sheet.ts @@ -1,7 +1,7 @@ import type { UserPF2e } from "./document.ts"; /** Player-specific settings, stored as flags on each User */ -export class UserConfigPF2e extends UserConfig { +export class UserConfigPF2e extends foundry.applications.sheets.UserConfig { override async getData(options: DocumentSheetOptions): Promise> { const data = await super.getData(options); data.actors = data.actors.filter((a) => a.type !== "party"); diff --git a/src/scripts/hooks/ready.ts b/src/scripts/hooks/ready.ts index caec43b532c..a26a46f4009 100644 --- a/src/scripts/hooks/ready.ts +++ b/src/scripts/hooks/ready.ts @@ -106,13 +106,6 @@ export const Ready = { canvas.colorManager.initialize(); } - // Sort item types for display in sidebar create-item dialog - game.system.documentTypes.Item.sort((typeA, typeB) => { - return game.i18n - .localize(CONFIG.Item.typeLabels[typeA] ?? "") - .localeCompare(game.i18n.localize(CONFIG.Item.typeLabels[typeB] ?? "")); - }); - game.pf2e.system.moduleArt.refresh().then(() => { if (game.modules.get("babele")?.active && game.i18n.lang !== "en") { // For some reason, Babele calls its own "ready" hook twice, and only the second one is genuine. diff --git a/src/scripts/register-sheets.ts b/src/scripts/register-sheets.ts index 734e6ba1513..24c8af8bd23 100644 --- a/src/scripts/register-sheets.ts +++ b/src/scripts/register-sheets.ts @@ -182,7 +182,7 @@ export function registerSheets(): void { }); // USER - Users.unregisterSheet("core", UserConfig); + Users.unregisterSheet("core", foundry.applications.sheets.UserConfig); Users.registerSheet("pf2e", UserConfigPF2e, { makeDefault: true, label: () => game.i18n.format("SHEETS.DefaultDocumentSheet", { document: game.i18n.localize("DOCUMENT.User") }), diff --git a/types/foundry/client/application/form-application/document-sheet/user-config.d.ts b/types/foundry/client/application/form-application/document-sheet/user-config.d.ts index b6c08d09bfb..3a3c9884479 100644 --- a/types/foundry/client/application/form-application/document-sheet/user-config.d.ts +++ b/types/foundry/client/application/form-application/document-sheet/user-config.d.ts @@ -1,26 +1,24 @@ -export {}; +/** + * The Application responsible for configuring a single User document. + * @extends {DocumentSheet} + * + * @param user The User document being configured. + * @param [options] Additional rendering options which modify the behavior of the form. + */ +export declare class UserConfig extends DocumentSheet { + static override get defaultOptions(): DocumentSheetOptions; -declare global { - /** - * The Application responsible for configuring a single User document. - * @extends {DocumentSheet} - * - * @param user The User document being configured. - * @param [options] Additional rendering options which modify the behavior of the form. - */ - class UserConfig extends DocumentSheet { - static override get defaultOptions(): DocumentSheetOptions; - - override get title(): string; + override get title(): string; - override getData(options: DocumentSheetOptions): Promise>; + override getData(options: DocumentSheetOptions): Promise>; - override activateListeners(html: JQuery): void; + override activateListeners(html: JQuery): void; - /** Handle changing the user avatar image by opening a FilePicker */ - protected _onEditAvatar(event: JQuery.TriggeredEvent): void; - } + /** Handle changing the user avatar image by opening a FilePicker */ + protected _onEditAvatar(event: JQuery.TriggeredEvent): void; +} +declare global { interface UserConfigData extends DocumentSheetData { user: User; actors: Actor[]; diff --git a/types/foundry/client/config.d.ts b/types/foundry/client/config.d.ts index 6edfeabdd17..a17b31176e0 100644 --- a/types/foundry/client/config.d.ts +++ b/types/foundry/client/config.d.ts @@ -38,7 +38,7 @@ declare global { }; /** Configure the DatabaseBackend used to perform Document operations */ - DatabaseBackend: ClientDatabaseBackend; + DatabaseBackend: foundry.data.ClientDatabaseBackend; /** Configuration for the Actor document */ Actor: { diff --git a/types/foundry/client/data/abstract/client-backend.d.ts b/types/foundry/client/data/abstract/client-backend.d.ts index 6c88588b2c9..e25707324d5 100644 --- a/types/foundry/client/data/abstract/client-backend.d.ts +++ b/types/foundry/client/data/abstract/client-backend.d.ts @@ -2,49 +2,47 @@ import type { Socket } from "socket.io"; import type { DatabaseBackend, Document } from "../../../common/abstract/module.d.ts"; /** The client-side database backend implementation which handles Document modification operations. */ -declare global { - class ClientDatabaseBackend extends DatabaseBackend { - /* -------------------------------------------- */ - /* Document Modification Operations */ - /* -------------------------------------------- */ - - protected override _getDocuments( - documentClass: typeof Document, - request: DatabaseBackendGetContext, - user: User, - ): Promise; - - protected override _createDocuments( - documentClass: typeof Document, - context: DatabaseBackendCreateContext, - user: User, - ): Promise; - - protected override _updateDocuments( - documentClass: typeof Document, - context: DatabaseBackendUpdateContext, - user: User, - ): Promise; - - protected override _deleteDocuments( - documentClass: typeof Document, - context: DatabaseBackendDeleteContext, - user: User, - ): Promise; - - /* -------------------------------------------- */ - /* Socket Workflows */ - /* -------------------------------------------- */ - - /** Activate the Socket event listeners used to receive responses from events which modify database documents */ - activateSocketListeners(socket: Socket): void; - - /* -------------------------------------------- */ - /* Helper Methods */ - /* -------------------------------------------- */ - - override getFlagScopes(): string[]; - - override getCompendiumScopes(): string[]; - } +export declare class ClientDatabaseBackend extends DatabaseBackend { + /* -------------------------------------------- */ + /* Document Modification Operations */ + /* -------------------------------------------- */ + + protected override _getDocuments( + documentClass: typeof Document, + request: DatabaseBackendGetContext, + user: User, + ): Promise; + + protected override _createDocuments( + documentClass: typeof Document, + context: DatabaseBackendCreateContext, + user: User, + ): Promise; + + protected override _updateDocuments( + documentClass: typeof Document, + context: DatabaseBackendUpdateContext, + user: User, + ): Promise; + + protected override _deleteDocuments( + documentClass: typeof Document, + context: DatabaseBackendDeleteContext, + user: User, + ): Promise; + + /* -------------------------------------------- */ + /* Socket Workflows */ + /* -------------------------------------------- */ + + /** Activate the Socket event listeners used to receive responses from events which modify database documents */ + activateSocketListeners(socket: Socket): void; + + /* -------------------------------------------- */ + /* Helper Methods */ + /* -------------------------------------------- */ + + override getFlagScopes(): string[]; + + override getCompendiumScopes(): string[]; } diff --git a/types/foundry/client/foundry/applications/index.d.ts b/types/foundry/client/foundry/applications/index.d.ts new file mode 100644 index 00000000000..e6272d67bc1 --- /dev/null +++ b/types/foundry/client/foundry/applications/index.d.ts @@ -0,0 +1 @@ +export * as sheets from "./sheets.ts"; diff --git a/types/foundry/client/foundry/applications/sheets.d.ts b/types/foundry/client/foundry/applications/sheets.d.ts new file mode 100644 index 00000000000..525df8a77d6 --- /dev/null +++ b/types/foundry/client/foundry/applications/sheets.d.ts @@ -0,0 +1 @@ +export { UserConfig } from "../../application/form-application/document-sheet/user-config.ts"; diff --git a/types/foundry/client/foundry/data/index.d.ts b/types/foundry/client/foundry/data/index.d.ts new file mode 100644 index 00000000000..34d18efac24 --- /dev/null +++ b/types/foundry/client/foundry/data/index.d.ts @@ -0,0 +1,2 @@ +export * from "../../../common/data/module.ts"; +export { ClientDatabaseBackend } from "../../data/abstract/client-backend.ts"; diff --git a/types/foundry/client/foundry/index.d.ts b/types/foundry/client/foundry/index.d.ts new file mode 100644 index 00000000000..12fa1a0a281 --- /dev/null +++ b/types/foundry/client/foundry/index.d.ts @@ -0,0 +1,13 @@ +/** Abstract class definitions for fundamental concepts used throughout the Foundry Virtual Tabletop framework. */ +export * as abstract from "../../common/abstract/module.ts"; +/** Constant definitions used throughout the Foundry Virtual Tabletop framework. */ +export * as CONST from "../../common/constants.ts"; +/** Document definitions used throughout the Foundry Virtual Tabletop framework. */ +export * as documents from "../../common/documents/module.ts"; +/** Package data definitions, validations, and schema. */ +export * as packages from "../../common/packages/module.ts"; +/** Utility functions providing helpful functionality. */ +export * as utils from "../../common/utils/module.ts"; +export * as applications from "./applications/index.ts"; +/** Data schema definitions for data models. */ +export * as data from "./data/index.ts"; diff --git a/types/foundry/client/index.d.ts b/types/foundry/client/index.d.ts index b07ee9b7532..86aa9e36496 100644 --- a/types/foundry/client/index.d.ts +++ b/types/foundry/client/index.d.ts @@ -1,22 +1,13 @@ -import type GSAP from "gsap"; -import type HANDLEBARS from "handlebars"; -import { showdown as SHOWDOWN } from "showdownf"; +import "gsap"; +import "handlebars"; +import SHOWDOWN from "showdown"; +import * as Foundry from "./foundry/index.ts"; declare global { - const CONST: typeof Constants; - namespace globalThis { - const Color = Utils.Color; - export import Handlebars = HANDLEBARS; - const gsap = GSAP; - export import showdown = SHOWDOWN; - - namespace foundry { - const CONST = Constants; - const abstract = Abstract; - const data = Data; - const documents = Documents; - const utils = Utils; - } + export import CONST = Foundry.CONST; + export import Color = Foundry.utils.Color; + export import foundry = Foundry; + const showdown: typeof SHOWDOWN; } } diff --git a/types/foundry/client/pixi/placeables/token.d.ts b/types/foundry/client/pixi/placeables/token.d.ts index 9ce1be8f9c2..6a6e411e7b5 100644 --- a/types/foundry/client/pixi/placeables/token.d.ts +++ b/types/foundry/client/pixi/placeables/token.d.ts @@ -211,6 +211,13 @@ declare global { */ updateLightSource({ defer, deleted }?: { defer?: boolean; deleted?: boolean }): void; + /** + * Update the VisionSource instance associated with this Token. + * @param {object} [options] Options which affect how the vision source is updated + * @param {boolean} [options.deleted] Indicate that this vision source has been deleted. + */ + initializeVisionSource(options?: { deleted?: boolean }): void; + /** * Update an Token vision source associated for this token. * @param [defer] Defer refreshing the LightingLayer to manually call that refresh later. diff --git a/types/foundry/common/data/fields.d.ts b/types/foundry/common/data/fields.d.ts index 6b171185bb6..7a86f8ed74f 100644 --- a/types/foundry/common/data/fields.d.ts +++ b/types/foundry/common/data/fields.d.ts @@ -1,4 +1,5 @@ import type * as abstract from "../abstract/module.d.ts"; +import type Color from "../utils/color.d.ts"; import type { TombstoneDataSchema } from "./data.d.ts"; import type { DataModelValidationFailure } from "./validation-failure.d.ts"; @@ -832,7 +833,7 @@ export class ColorField< TRequired extends boolean = false, TNullable extends boolean = true, THasInitial extends boolean = true, -> extends StringField { +> extends StringField { protected static override get _defaults(): StringFieldOptions; protected override _validateType(value: unknown): boolean; diff --git a/types/foundry/common/data/module.d.ts b/types/foundry/common/data/module.d.ts index ed471a40262..0db8358dd5b 100644 --- a/types/foundry/common/data/module.d.ts +++ b/types/foundry/common/data/module.d.ts @@ -1,4 +1,4 @@ +export * from "./data.ts"; export * as fields from "./fields.ts"; export * as validation from "./validation-failure.ts"; export * as validators from "./validators.ts"; -export * from "./data.ts"; diff --git a/types/foundry/common/module.d.ts b/types/foundry/common/module.d.ts index 4cb760306fd..109442863e4 100644 --- a/types/foundry/common/module.d.ts +++ b/types/foundry/common/module.d.ts @@ -1,30 +1,3 @@ -import * as Abstract from "./abstract/module.ts"; -import * as Constants from "./constants.ts"; -import * as Data from "./data/module.ts"; -import * as Documents from "./documents/module.ts"; -import * as Packages from "./packages/module.ts"; -import * as Utils from "./utils/module.ts"; - // global-modifying module import "./primitives/module.d.ts"; import "./types.ts"; - -declare global { - const CONST: typeof Constants; - namespace globalThis { - namespace foundry { - /** Constant definitions used throughout the Foundry Virtual Tabletop framework. */ - export import CONST = Constants; - /** Abstract class definitions for fundamental concepts used throughout the Foundry Virtual Tabletop framework. */ - export import abstract = Abstract; - /** Data schema definitions for data models. */ - export import data = Data; - /** Document definitions used throughout the Foundry Virtual Tabletop framework. */ - export import documents = Documents; - /** Package data definitions, validations, and schema. */ - export import packages = Packages; - /** Utility functions providing helpful functionality. */ - export import utils = Utils; - } - } -} diff --git a/types/foundry/index.d.ts b/types/foundry/index.d.ts index 0bc2eaf6d79..9786c8930f4 100644 --- a/types/foundry/index.d.ts +++ b/types/foundry/index.d.ts @@ -26,6 +26,7 @@ import "./client/config.d.ts"; import "./client/core/index.d.ts"; import "./client/data/index.d.ts"; import "./client/game.d.ts"; +import "./client/index.d.ts"; import "./client/keyboard/index.d.ts"; import "./client/misc.d.ts"; import "./client/pixi/canvas-layer/base.d.ts";