@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250824190511 → 13.346.0-beta.20250825020008
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.
- package/package.json +1 -1
- package/src/configuration/configuration.d.mts +4 -6
- package/src/configuration/globals.d.mts +1 -1
- package/src/foundry/client/_types.d.mts +2 -2
- package/src/foundry/client/applications/ui/scene-controls.d.mts +52 -2
- package/src/foundry/client/audio/_types.d.mts +11 -0
- package/src/foundry/client/audio/biquad.d.mts +7 -9
- package/src/foundry/client/audio/cache.d.mts +3 -2
- package/src/foundry/client/audio/convolver.d.mts +2 -6
- package/src/foundry/client/audio/helper.d.mts +263 -87
- package/src/foundry/client/audio/sound.d.mts +172 -70
- package/src/foundry/client/audio/timeout.d.mts +9 -3
- package/src/foundry/client/canvas/containers/elements/door-mesh.d.mts +3 -2
- package/src/foundry/client/canvas/interaction/render-flags.d.mts +11 -8
- package/src/foundry/client/canvas/perception/vision-mode.d.mts +10 -65
- package/src/foundry/client/canvas/primary/primary-graphics.d.mts +1 -8
- package/src/foundry/client/canvas/rendering/filters/_module.d.mts +1 -0
- package/src/foundry/client/canvas/rendering/shaders/base-shader.d.mts +7 -0
- package/src/foundry/client/client.d.mts +24 -0
- package/src/foundry/client/data/_module.d.mts +4 -2
- package/src/foundry/client/data/_types.d.mts +11 -0
- package/src/foundry/client/data/fields.d.mts +72 -0
- package/src/foundry/client/documents/abstract/canvas-document.d.mts +1 -1
- package/src/foundry/client/documents/abstract/client-document.d.mts +31 -6
- package/src/foundry/client/documents/actor.d.mts +3 -2
- package/src/foundry/client/documents/collections/compendium-collection.d.mts +111 -50
- package/src/foundry/client/documents/token.d.mts +6 -0
- package/src/foundry/client/helpers/localization.d.mts +2 -37
- package/src/foundry/client/packages/system.d.mts +5 -5
- package/src/foundry/client/utils/_module.d.mts +6 -5
- package/src/foundry/common/abstract/data.d.mts +87 -3
- package/src/foundry/common/abstract/embedded-collection.d.mts +5 -4
- package/src/foundry/common/abstract/type-data.d.mts +53 -11
- package/src/foundry/common/data/fields.d.mts +15 -1
- package/src/foundry/common/packages/_module.d.mts +2 -2
- package/src/foundry/common/packages/base-package.d.mts +12 -3
- package/src/foundry/common/packages/sub-types.d.mts +6 -3
@@ -3,7 +3,7 @@
|
|
3
3
|
// While `.mts` could work, to avoid `import-x/no-unresolved` from erroring `.mjs` is used.
|
4
4
|
/* eslint-disable import-x/extensions */
|
5
5
|
|
6
|
-
import type {
|
6
|
+
import type { performIntegerSort } from "./helpers.mjs";
|
7
7
|
|
8
8
|
// eslint-disable-next-line import-x/export
|
9
9
|
export * from "./_types.mjs";
|
@@ -15,11 +15,12 @@ export * from "./helpers.mjs";
|
|
15
15
|
* @remarks With the move to ESM, foundry no longer appears to need/want classes that only exist to host static functions in a namespace
|
16
16
|
*/
|
17
17
|
declare const SortingHelpers: {
|
18
|
+
/**
|
19
|
+
* Given a source object to sort, a target to sort relative to, and an Array of siblings in the container.
|
20
|
+
* @deprecated "`foundry.utils.SortingHelpers.performIntegerSort` has been deprecated. Access this helper at {@linkcode foundry.utils.performIntegerSort} instead." (since v13, until v15)
|
21
|
+
* @ignore
|
22
|
+
*/
|
18
23
|
performIntegerSort: typeof performIntegerSort;
|
19
24
|
};
|
20
25
|
|
21
|
-
declare namespace SortingHelpers {
|
22
|
-
interface SortOptions<T, SortKey extends string = "sort"> extends OriginalSortOptions<T, SortKey> {}
|
23
|
-
}
|
24
|
-
|
25
26
|
export { SortingHelpers };
|
@@ -17,7 +17,17 @@ declare class _InternalDataModel<
|
|
17
17
|
export default DataModel;
|
18
18
|
|
19
19
|
/**
|
20
|
-
*
|
20
|
+
* An abstract class which is a fundamental building block of numerous structures and concepts in Foundry Virtual
|
21
|
+
* Tabletop. Data models perform several essential roles:
|
22
|
+
*
|
23
|
+
* - A static schema definition that all instances of that model adhere to.
|
24
|
+
* - A workflow for data migration, cleaning, validation, and initialization such that provided input data is structured
|
25
|
+
* according to the rules of the model's declared schema.
|
26
|
+
* - A workflow for transacting differential updates to the instance data and serializing its data into format suitable
|
27
|
+
* for storage or transport.
|
28
|
+
*
|
29
|
+
* DataModel subclasses can be used for a wide variety of purposes ranging from simple game settings to high complexity
|
30
|
+
* objects like `Scene` documents. Data models are often nested; see the {@linkcode DataModel.parent} property for more.
|
21
31
|
*/
|
22
32
|
declare abstract class DataModel<
|
23
33
|
Schema extends DataSchema,
|
@@ -69,8 +79,40 @@ declare abstract class DataModel<
|
|
69
79
|
readonly parent: Parent;
|
70
80
|
|
71
81
|
/**
|
72
|
-
* Define the data schema for
|
82
|
+
* Define the data schema for models of this type.
|
73
83
|
* The schema is populated the first time it is accessed and cached for future reuse.
|
84
|
+
*
|
85
|
+
* The schema, through its fields, provide the essential cleaning, validation, and initialization methods to turn the
|
86
|
+
* {@linkcode _source} values into direct properties of the data model. The schema is a static property of the model and
|
87
|
+
* is reused by all instances to perform validation.
|
88
|
+
*
|
89
|
+
* The schemas defined by the core software in classes like {@linkcode foundry.documents.BaseActor} are validated by the
|
90
|
+
* server, where user code does not run. However, almost all documents have a `flags` field to store data, and many
|
91
|
+
* have a `system` field that can be configured to be a {@linkcode foundry.abstract.TypeDataModel} instance. Those models
|
92
|
+
* are *not* constructed on the server and rely purely on client-side code, which means certain extra-sensitive fields
|
93
|
+
* must be also be registered through your package manifest. {@linkcode foundry.packages.AdditionalTypesField.ServerSanitizationFields | ServerSanitizationFields}
|
94
|
+
*
|
95
|
+
* @example
|
96
|
+
* ```js
|
97
|
+
* class SomeModel extends foundry.abstract.DataModel {
|
98
|
+
* static defineSchema() {
|
99
|
+
* return {
|
100
|
+
* foo: new foundry.data.fields.StringField()
|
101
|
+
* }
|
102
|
+
* }
|
103
|
+
* }
|
104
|
+
*
|
105
|
+
* class AnotherModel extends SomeModel {
|
106
|
+
* static defineSchema() {
|
107
|
+
* // Inheritance and object oriented principles apply to schema definition
|
108
|
+
* const schema = super.defineSchema()
|
109
|
+
*
|
110
|
+
* schema.bar = new foundry.data.fields.NumberField()
|
111
|
+
*
|
112
|
+
* return schema;
|
113
|
+
* }
|
114
|
+
* }
|
115
|
+
* ```
|
74
116
|
* @remarks The returned value MUST be kept up to sync with the `Schema` type parameter.
|
75
117
|
*/
|
76
118
|
static defineSchema(): DataSchema;
|
@@ -100,7 +142,49 @@ declare abstract class DataModel<
|
|
100
142
|
#validationFailures: { fields: DataModelValidationFailure | null; joint: DataModelValidationFailure | null };
|
101
143
|
|
102
144
|
/**
|
103
|
-
* A set of localization prefix paths which are used by this DataModel.
|
145
|
+
* A set of localization prefix paths which are used by this DataModel. This provides an alternative to defining the
|
146
|
+
* `label` and `hint` property of each field by having foundry map the labels to a structure inside the path
|
147
|
+
* provided by the prefix.
|
148
|
+
*
|
149
|
+
* @example
|
150
|
+
* JavaScript class definition and localization call.
|
151
|
+
* ```js
|
152
|
+
* class MyDataModel extends foundry.abstract.DataModel {
|
153
|
+
* static defineSchema() {
|
154
|
+
* return {
|
155
|
+
* foo: new foundry.data.fields.StringField(),
|
156
|
+
* bar: new foundry.data.fields.NumberField()
|
157
|
+
* };
|
158
|
+
* }
|
159
|
+
* static LOCALIZATION_PREFIXES = ["MYMODULE.MYDATAMODEL"];
|
160
|
+
* }
|
161
|
+
*
|
162
|
+
* Hooks.on("i18nInit", () => {
|
163
|
+
* // Foundry will attempt to automatically localize models registered for a document subtype, so this step is only
|
164
|
+
* // needed for other data model usage, e.g. for a Setting.
|
165
|
+
* Localization.localizeDataModel(MyDataModel);
|
166
|
+
* });
|
167
|
+
* ```
|
168
|
+
*
|
169
|
+
* JSON localization file
|
170
|
+
* ```json
|
171
|
+
* {
|
172
|
+
* "MYMODULE": {
|
173
|
+
* "MYDATAMODEL": {
|
174
|
+
* "FIELDS" : {
|
175
|
+
* "foo": {
|
176
|
+
* "label": "Foo",
|
177
|
+
* "hint": "Instructions for foo"
|
178
|
+
* },
|
179
|
+
* "bar": {
|
180
|
+
* "label": "Bar",
|
181
|
+
* "hint": "Instructions for bar"
|
182
|
+
* }
|
183
|
+
* }
|
184
|
+
* }
|
185
|
+
* }
|
186
|
+
* }
|
187
|
+
* ```
|
104
188
|
*/
|
105
189
|
static LOCALIZATION_PREFIXES: string[];
|
106
190
|
|
@@ -107,7 +107,7 @@ declare class EmbeddedCollection<
|
|
107
107
|
): void;
|
108
108
|
|
109
109
|
/**
|
110
|
-
* Get
|
110
|
+
* Get a document from the EmbeddedCollection by its ID.
|
111
111
|
* @param id - The ID of the Embedded Document to retrieve.
|
112
112
|
* @param options - Additional options to configure retrieval.
|
113
113
|
*/
|
@@ -129,21 +129,21 @@ declare class EmbeddedCollection<
|
|
129
129
|
): ContainedDocument | undefined;
|
130
130
|
|
131
131
|
/**
|
132
|
-
* Get
|
132
|
+
* Get a document from the EmbeddedCollection by its ID.
|
133
133
|
* @param id - The ID of the Embedded Document to retrieve.
|
134
134
|
* @param options - Additional options to configure retrieval.
|
135
135
|
*/
|
136
136
|
get(id: string, options: { strict: true; invalid?: false }): ContainedDocument;
|
137
137
|
|
138
138
|
/**
|
139
|
-
* Get
|
139
|
+
* Get a document from the EmbeddedCollection by its ID.
|
140
140
|
* @param id - The ID of the Embedded Document to retrieve.
|
141
141
|
* @param options - Additional options to configure retrieval.
|
142
142
|
*/
|
143
143
|
get(id: string, options: { strict?: boolean; invalid: true }): unknown;
|
144
144
|
|
145
145
|
/**
|
146
|
-
* Add
|
146
|
+
* Add a document to the collection
|
147
147
|
* @param key - The embedded Document ID
|
148
148
|
* @param value - The embedded Document instance
|
149
149
|
* @param options - Additional options to the set operation
|
@@ -168,6 +168,7 @@ declare class EmbeddedCollection<
|
|
168
168
|
protected _set(key: string, value: ContainedDocument): void;
|
169
169
|
|
170
170
|
/**
|
171
|
+
* Remove a document from the collection.
|
171
172
|
* @param key - The embedded Document ID.
|
172
173
|
* @param options - Additional options to the delete operation.
|
173
174
|
*/
|
@@ -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
|
-
*
|
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
|
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
|
-
*
|
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
|
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 {@
|
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
|
|
@@ -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 {
|
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
|
88
|
-
keyof typeof
|
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,
|
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
|
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
|
|