@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250823115730 → 13.346.0-beta.20250825015921

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/package.json +1 -1
  2. package/src/configuration/configuration.d.mts +1 -3
  3. package/src/configuration/globals.d.mts +1 -1
  4. package/src/foundry/client/_types.d.mts +2 -2
  5. package/src/foundry/client/applications/ui/scene-controls.d.mts +52 -2
  6. package/src/foundry/client/canvas/containers/elements/door-mesh.d.mts +3 -2
  7. package/src/foundry/client/canvas/interaction/render-flags.d.mts +11 -8
  8. package/src/foundry/client/canvas/perception/vision-mode.d.mts +10 -65
  9. package/src/foundry/client/canvas/primary/primary-graphics.d.mts +1 -8
  10. package/src/foundry/client/canvas/rendering/filters/_module.d.mts +1 -0
  11. package/src/foundry/client/canvas/rendering/shaders/base-shader.d.mts +7 -0
  12. package/src/foundry/client/client.d.mts +24 -0
  13. package/src/foundry/client/data/_module.d.mts +4 -2
  14. package/src/foundry/client/data/_types.d.mts +11 -0
  15. package/src/foundry/client/data/fields.d.mts +72 -0
  16. package/src/foundry/client/documents/abstract/canvas-document.d.mts +1 -1
  17. package/src/foundry/client/documents/abstract/client-document.d.mts +31 -6
  18. package/src/foundry/client/documents/actor.d.mts +3 -2
  19. package/src/foundry/client/documents/collections/compendium-collection.d.mts +111 -50
  20. package/src/foundry/client/documents/token.d.mts +6 -0
  21. package/src/foundry/client/helpers/localization.d.mts +2 -37
  22. package/src/foundry/client/packages/system.d.mts +5 -5
  23. package/src/foundry/client/utils/_module.d.mts +6 -5
  24. package/src/foundry/common/abstract/data.d.mts +87 -3
  25. package/src/foundry/common/abstract/embedded-collection.d.mts +5 -4
  26. package/src/foundry/common/abstract/type-data.d.mts +53 -11
  27. package/src/foundry/common/data/fields.d.mts +16 -2
  28. package/src/foundry/common/packages/_module.d.mts +2 -2
  29. package/src/foundry/common/packages/base-package.d.mts +12 -3
  30. package/src/foundry/common/packages/sub-types.d.mts +6 -3
@@ -210,9 +210,8 @@ declare abstract class AnyTypeDataModel extends TypeDataModel<any, any, any, any
210
210
  * Systems or Modules that provide DataModel implementations for sub-types of Documents (such as Actors or Items)
211
211
  * should subclass this class instead of the base DataModel class.
212
212
  *
213
- *
214
- * @example Registering a custom sub-type for a Module.
215
- *
213
+ * @example
214
+ * Registering a custom sub-type for a Module.
216
215
  * **module.json**
217
216
  * ```json
218
217
  * {
@@ -260,6 +259,23 @@ declare abstract class AnyTypeDataModel extends TypeDataModel<any, any, any, any
260
259
  * }
261
260
  * }
262
261
  * ```
262
+ *
263
+ * **en.json** To provide the localization for methods like `ClientDocument.createDialog`
264
+ *
265
+ * ```json
266
+ * {
267
+ * "TYPES": {
268
+ * "Actor": {
269
+ * "sidekick": "Sidekick",
270
+ * "villain": "Villain"
271
+ * },
272
+ * "JournalEntryPage": {
273
+ * "dossier": "Dossier",
274
+ * "quest": "Quest"
275
+ * }
276
+ * }
277
+ * }
278
+ * ```
263
279
  */
264
280
  declare abstract class TypeDataModel<
265
281
  Schema extends DataSchema,
@@ -277,23 +293,49 @@ declare abstract class TypeDataModel<
277
293
 
278
294
  modelProvider: foundry.packages.System | foundry.packages.Module | null;
279
295
 
280
- /**
281
- * A set of localization prefix paths which are used by this data model.
282
- */
283
- static LOCALIZATION_PREFIXES: string[];
296
+ static override LOCALIZATION_PREFIXES: string[];
284
297
 
285
298
  /**
286
- * Prepare data related to this DataModel itself, before any derived data is computed.
299
+ * Prepare data related to this DataModel itself, before any derived data (including Active Effects)
300
+ * is computed. This is especially useful for initializing numbers, arrays, and sets you expect to be
301
+ * modified by active effects.
302
+ *
303
+ * Called before {@linkcode foundry.documents.abstract.ClientDocumentMixin.AnyMixed.prepareBaseData | ClientDocument#prepareBaseData} in
304
+ * {@linkcode foundry.documents.abstract.ClientDocumentMixin.AnyMixed.prepareData | ClientDocument#prepareData}.
287
305
  *
288
- * Called before {@link ClientDocument.prepareBaseData | `ClientDocument#prepareBaseData`} in {@link ClientDocument.prepareData | `ClientDocument#prepareData`}.
306
+ * @example
307
+ * ```js
308
+ * prepareBaseData() {
309
+ * // Ensures an active effect of `system.encumbrance.max | ADD | 10` doesn't produce `NaN`
310
+ * this.encumbrance = {
311
+ * max: 0
312
+ * }
313
+ * // If you need to access the owning Document, `this.parent` provides a reference for properties like the name
314
+ * // or embedded collections, e.g. `this.parent.name` or `this.parent.items`
315
+ * }
316
+ * ```
289
317
  */
290
318
  prepareBaseData(this: TypeDataModel.PrepareBaseDataThis<this>): void;
291
319
 
292
320
  /**
293
- * Apply transformations of derivations to the values of the source data object.
321
+ * Apply transformations or derivations to the values of the source data object.
294
322
  * Compute data fields whose values are not stored to the database.
295
323
  *
296
- * Called before {@link ClientDocument.prepareDerivedData | `ClientDocument#prepareDerivedData`} in {@link ClientDocument.prepareData | `ClientDocument#prepareData`}.
324
+ * Called before {@linkcode foundry.abstract.ClientDocumentMixin.AnyMixed.prepareDerivedData | ClientDocument#prepareDerivedData} in
325
+ * {@linkcode foundry.abstract.ClientDocumentMixin.AnyMixed.prepareData | ClientDocument#prepareData}.
326
+ *
327
+ * @example
328
+ * ```js
329
+ * prepareDerivedData() {
330
+ * this.hp.bloodied = Math.floor(this.hp.max / 2);
331
+ *
332
+ * // this.parent accesses the Document, allowing access to embedded collections
333
+ * this.encumbrance.value = this.parent.items.reduce((total, item) => {
334
+ * total += item.system.weight;
335
+ * return total;
336
+ * }, 0)
337
+ * }
338
+ * ```
297
339
  */
298
340
  prepareDerivedData(this: TypeDataModel.PrepareDerivedDataThis<this>): void;
299
341
 
@@ -465,7 +465,7 @@ declare abstract class DataField<
465
465
  delta: InitializedType,
466
466
  model: DataModel.Any,
467
467
  change: ActiveEffect.ChangeData,
468
- ): InitializedType;
468
+ ): InitializedType | undefined;
469
469
 
470
470
  /**
471
471
  * Apply an UPGRADE change to this field.
@@ -3795,6 +3795,13 @@ declare namespace ColorField {
3795
3795
 
3796
3796
  /**
3797
3797
  * A special {@linkcode StringField} which records a file path or inline base64 data.
3798
+ *
3799
+ * When using the `FilePathField` in a data model that is persisted to the database, for example a Document sub-type,
3800
+ * it is essential to declare this field in the package manifest so that it receives proper server-side validation of
3801
+ * its contents.
3802
+ *
3803
+ * See {@linkcode foundry.packages.AdditionalTypesField.ServerSanitizationFields | ServerSanitizationFields} for information about this structure.
3804
+ *
3798
3805
  * @template Options - the options of the FilePathField instance
3799
3806
  * @template AssignmentType - the type of the allowed assignment values of the FilePathField
3800
3807
  * @template InitializedType - the type of the initialized values of the FilePathField
@@ -4438,9 +4445,16 @@ declare class AnyField extends DataField<DataField.Options.Any, unknown, unknown
4438
4445
  }
4439
4446
 
4440
4447
  /**
4441
- * A subclass of {@linkcode StringField} which contains a sanitized HTML string.
4448
+ * A subclass of {@linkcode foundry.data.fields.StringField | StringField} which contains a sanitized HTML string.
4442
4449
  * This class does not override any StringField behaviors, but is used by the server-side to identify fields which
4443
4450
  * require sanitization of user input.
4451
+ *
4452
+ * When using the `HTMLField` in a data model that is persisted to the database, for example a Document sub-type,
4453
+ * it is essential to declare this field in the package manifest so that it receives proper server-side validation
4454
+ * of its contents.
4455
+ *
4456
+ * See {@linkcode foundry.packages.AdditionalTypesField.ServerSanitizationFields | ServerSanitizationFields} for information about this structure.
4457
+ *
4444
4458
  * @template Options - the options of the HTMLField instance
4445
4459
  * @template AssignmentType - the type of the allowed assignment values of the HTMLField
4446
4460
  * @template InitializedType - the type of the initialized values of the HTMLField
@@ -5,11 +5,11 @@
5
5
 
6
6
  import type { SchemaField } from "../data/fields.d.mts";
7
7
 
8
- export { default as BasePackage } from "./base-package.mjs";
8
+ export { default as BasePackage, PackageCompatibility, RelatedPackage } from "./base-package.mjs";
9
9
  export { default as BaseWorld } from "./base-world.mjs";
10
10
  export { default as BaseSystem } from "./base-system.mjs";
11
11
  export { default as BaseModule } from "./base-module.mjs";
12
- export { PackageCompatibility, RelatedPackage } from "./base-package.mjs";
12
+ export { default as AdditionalTypesField } from "./sub-types.mjs";
13
13
 
14
14
  declare global {
15
15
  type PackageAuthorData = SchemaField.CreateData<foundry.packages.BasePackage.PackageAuthorSchema>;
@@ -84,8 +84,8 @@ declare namespace BasePackage {
84
84
  }
85
85
 
86
86
  type OwnershipRecord = Record<
87
- keyof typeof foundry.CONST.USER_ROLES,
88
- keyof typeof foundry.CONST.DOCUMENT_OWNERSHIP_LEVELS | undefined
87
+ keyof typeof CONST.USER_ROLES,
88
+ keyof typeof CONST.DOCUMENT_OWNERSHIP_LEVELS | undefined
89
89
  >;
90
90
 
91
91
  interface PackageCompendiumSchema extends DataSchema {
@@ -104,6 +104,13 @@ declare namespace BasePackage {
104
104
  */
105
105
  label: fields.StringField<{ required: true; blank: false }>;
106
106
 
107
+ /**
108
+ * A file path to a banner image that will be used in the Compendium sidebar. This should
109
+ * be hosted within your package, e.g. `modules/my-module/assets/banners/bestiary.webp`.
110
+ * The dimensions are 290 x 70; you can either have each be an individual landscape or
111
+ * slice them up to form a composite with your other compendiums, but keep in mind that
112
+ * users can reorder compendium packs as well as filter them to break up the composite.
113
+ */
107
114
  banner: fields.StringField<OptionalString>;
108
115
 
109
116
  /**
@@ -122,7 +129,9 @@ declare namespace BasePackage {
122
129
  }>;
123
130
 
124
131
  /**
125
- * Denote that this compendium pack requires a specific game system to function properly
132
+ * Denote that this compendium pack requires a specific game system to function properly.
133
+ * Required for "Actor" and "Item" packs, but even others should keep in mind that system
134
+ * specific features and subtypes (e.g. JournalEntryPage) may present limitations.
126
135
  */
127
136
  system: fields.StringField<OptionalString>;
128
137
 
@@ -41,17 +41,20 @@ declare namespace AdditionalTypesField {
41
41
  * The first layer of keys are document types, e.g. "Actor" or "Item".
42
42
  * The second layer of keys are document subtypes, e.g. "character" or "feature".
43
43
  */
44
- type DocumentTypesConfiguration = Record<Document.SystemType, Record<string, ServerSanitationFields>>;
44
+ type DocumentTypesConfiguration = Record<Document.SystemType, Record<string, ServerSanitizationFields>>;
45
45
 
46
46
  /** @deprecated Internal type will be removed */
47
47
  type ServerTypeDeclarations = DocumentTypesConfiguration;
48
48
 
49
+ /** @deprecated Use {@linkcode ServerSanitizationFields} instead. This warning will be removed in v14. */
50
+ type ServerSanitationFields = ServerSanitizationFields;
51
+
49
52
  /**
50
53
  * Fields that need dedicated server-side handling. Paths are automatically relative to `system`.
51
54
  */
52
- interface ServerSanitationFields {
55
+ interface ServerSanitizationFields {
53
56
  /**
54
- * HTML fields that must be cleaned by the server, e.g. "description.value"
57
+ * HTML fields that must be cleaned by the server, e.g. `"description.value"`
55
58
  */
56
59
  htmlFields?: string[] | undefined;
57
60