@league-of-foundry-developers/foundry-vtt-types 12.331.2-beta → 12.331.3-beta

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 (60) hide show
  1. package/package.json +7 -8
  2. package/src/foundry/client/apps/forms/grid-config.d.mts +1 -5
  3. package/src/foundry/client/apps/i18n.d.mts +15 -12
  4. package/src/foundry/client/apps/templates.d.mts +5 -1
  5. package/src/foundry/client/config.d.mts +0 -2
  6. package/src/foundry/client/core/image.d.mts +81 -32
  7. package/src/foundry/client/data/abstract/canvas-document.d.mts +1 -2
  8. package/src/foundry/client/data/abstract/client-document.d.mts +3 -3
  9. package/src/foundry/client/data/abstract/directory-collection-mixin.d.mts +1 -1
  10. package/src/foundry/client/data/abstract/world-collection.d.mts +1 -1
  11. package/src/foundry/client/data/collections/compendium-collection.d.mts +5 -3
  12. package/src/foundry/client/data/collections/compendium-packs.d.mts +1 -1
  13. package/src/foundry/client/data/documents/actor.d.mts +10 -1
  14. package/src/foundry/client/data/documents/cards.d.mts +5 -3
  15. package/src/foundry/client/data/documents/folder.d.mts +6 -1
  16. package/src/foundry/client/data/documents/scene.d.mts +14 -7
  17. package/src/foundry/client/data/documents/token.d.mts +1 -5
  18. package/src/foundry/client/data/documents/user.d.mts +1 -1
  19. package/src/foundry/client/game.d.mts +6 -1
  20. package/src/foundry/client/hooks.d.mts +1 -1
  21. package/src/foundry/client/pixi/board.d.mts +10 -15
  22. package/src/foundry/client/pixi/core/interaction/render-flags.d.mts +0 -1
  23. package/src/foundry/client/pixi/core/loader.d.mts +1 -1
  24. package/src/foundry/client/pixi/core/shapes/source-polygon.d.mts +1 -1
  25. package/src/foundry/client/pixi/extensions/circle.d.mts +36 -28
  26. package/src/foundry/client/pixi/extensions/observable-transform.d.mts +8 -1
  27. package/src/foundry/client/pixi/extensions/polygon.d.mts +22 -21
  28. package/src/foundry/client/pixi/extensions/rectangle.d.mts +84 -41
  29. package/src/foundry/client/pixi/perception/perception-manager.d.mts +1 -1
  30. package/src/foundry/client/pixi/perception/vision-mode.d.mts +24 -9
  31. package/src/foundry/client/pixi/perception/weiler-atherton-clipping.d.mts +47 -37
  32. package/src/foundry/client/pixi/placeables/template.d.mts +2 -1
  33. package/src/foundry/client/pixi/placeables/token.d.mts +2 -1
  34. package/src/foundry/client/pixi/webgl/shaders/filters/effects-masking.d.mts +2 -2
  35. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/light-dome.d.mts +1 -1
  36. package/src/foundry/client-esm/applications/api/application.d.mts +22 -27
  37. package/src/foundry/client-esm/applications/forms/fields.d.mts +5 -0
  38. package/src/foundry/client-esm/applications/sheets/ambient-light-config.d.mts +6 -3
  39. package/src/foundry/client-esm/audio/_types.d.mts +1 -1
  40. package/src/foundry/client-esm/audio/helper.d.mts +5 -4
  41. package/src/foundry/client-esm/audio/timeout.d.mts +5 -2
  42. package/src/foundry/client-esm/canvas/regions/_module.d.mts +8 -4
  43. package/src/foundry/client-esm/canvas/scene-manager.d.mts +3 -3
  44. package/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts +1 -4
  45. package/src/foundry/client-esm/canvas/tokens/ring-config.d.mts +0 -1
  46. package/src/foundry/client-esm/data/region-behaviors/_module.d.mts +12 -9
  47. package/src/foundry/clipper/clipper.d.mts +23 -56
  48. package/src/foundry/common/abstract/data.d.mts +14 -6
  49. package/src/foundry/common/abstract/document.d.mts +27 -11
  50. package/src/foundry/common/abstract/type-data.d.mts +5 -0
  51. package/src/foundry/common/data/fields.d.mts +162 -57
  52. package/src/foundry/common/documents/active-effect.d.mts +2 -0
  53. package/src/foundry/common/documents/table-result.d.mts +0 -2
  54. package/src/foundry/common/documents/wall.d.mts +9 -14
  55. package/src/foundry/common/grid/hexagonal.d.mts +5 -1
  56. package/src/foundry/common/utils/geometry.d.mts +12 -2
  57. package/src/types/config.d.mts +6 -5
  58. package/src/types/documentConfiguration.d.mts +25 -25
  59. package/src/types/helperTypes.d.mts +194 -0
  60. package/src/types/utils.d.mts +21 -2
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@league-of-foundry-developers/foundry-vtt-types",
4
- "version": "12.331.2-beta",
4
+ "version": "12.331.3-beta",
5
5
  "description": "TypeScript type definitions for Foundry VTT",
6
6
  "type": "module",
7
7
  "types": "./index.d.mts",
8
8
  "scripts": {
9
- "lint": "./node_modules/typescript/bin/tsc; eslint .",
10
- "lint:fix": "eslint --fix .",
11
- "lint:ci": "eslint .",
9
+ "lint": "./node_modules/typescript/bin/tsc; eslint .; prettier -c .",
10
+ "lint:fix": "eslint --fix .; prettier -w .",
11
+ "lint:ci": "eslint .; prettier -c .",
12
12
  "eslint:report": "eslint --output-file eslint_report.json --format json .",
13
13
  "test": "vitest --typecheck",
14
14
  "typecheck": "./node_modules/typescript/bin/tsc",
@@ -94,13 +94,13 @@
94
94
  "lint-staged": "^15.2.10",
95
95
  "prettier": "^3.0.3",
96
96
  "typescript": "~5.7",
97
- "vitest": "^2.1.4"
97
+ "vitest": "^2.1.8"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "typescript": "^5.4"
101
101
  },
102
102
  "overrides": {
103
- "@types/css-font-loading-module": "^0.0.12s"
103
+ "@types/css-font-loading-module": "^0.0.14"
104
104
  },
105
105
  "resolutions": {
106
106
  "@types/earcut": "patch:@types/earcut@2.1.4#./patches/@types+earcut+2.1.4.patch"
@@ -121,6 +121,5 @@
121
121
  ],
122
122
  "publishConfig": {
123
123
  "access": "public"
124
- },
125
- "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
124
+ }
126
125
  }
@@ -10,11 +10,7 @@ declare global {
10
10
  Options,
11
11
  Scene.ConfiguredInstance
12
12
  > {
13
- constructor(
14
- scene: Scene.ConfiguredInstance,
15
- sheet: GridConfig["sheet"],
16
- options?: Partial<Options>,
17
- );
13
+ constructor(scene: Scene.ConfiguredInstance, sheet: GridConfig["sheet"], options?: Partial<Options>);
18
14
 
19
15
  /**
20
16
  * Track the Scene Configuration sheet reference
@@ -84,18 +84,21 @@ declare global {
84
84
  * }
85
85
  * ```
86
86
  */
87
- static localizeDataModel(model: foundry.abstract.DataModel.AnyConstructor, options?: InexactPartial<{
88
- /**
89
- * An array of localization key prefixes to use. If not specified, prefixes
90
- * are learned from the DataModel.LOCALIZATION_PREFIXES static property.
91
- */
92
- prefixes: string[];
93
-
94
- /**
95
- * A localization path prefix used to prefix all field names within this model. This is generally not required.
96
- */
97
- prefixPath: string;
98
- }>): void;
87
+ static localizeDataModel(
88
+ model: foundry.abstract.DataModel.AnyConstructor,
89
+ options?: InexactPartial<{
90
+ /**
91
+ * An array of localization key prefixes to use. If not specified, prefixes
92
+ * are learned from the DataModel.LOCALIZATION_PREFIXES static property.
93
+ */
94
+ prefixes: string[];
95
+
96
+ /**
97
+ * A localization path prefix used to prefix all field names within this model. This is generally not required.
98
+ */
99
+ prefixPath: string;
100
+ }>,
101
+ ): void;
99
102
 
100
103
  /**
101
104
  * Set a language as the active translation source for the session
@@ -1,4 +1,8 @@
1
- import type { FormInputConfig, NumberInputConfig, SelectInputConfig } from "../../client-esm/applications/forms/fields.d.mts";
1
+ import type {
2
+ FormInputConfig,
3
+ NumberInputConfig,
4
+ SelectInputConfig,
5
+ } from "../../client-esm/applications/forms/fields.d.mts";
2
6
 
3
7
  declare global {
4
8
  /**
@@ -2920,8 +2920,6 @@ declare global {
2920
2920
 
2921
2921
  /** @defaultValue `{ groupClass: OverlayCanvasGroup, parent: "stage" }` */
2922
2922
  overlay: CONFIG.Canvas.GroupDefinition<typeof OverlayCanvasGroup>;
2923
-
2924
- [key: string]: CONFIG.Canvas.GroupDefinition;
2925
2923
  }
2926
2924
 
2927
2925
  interface Layers {
@@ -1,4 +1,4 @@
1
- import type { InexactPartial } from "../../../types/utils.d.mts";
1
+ import type { InexactPartial, NullishProps } from "../../../types/utils.d.mts";
2
2
 
3
3
  declare global {
4
4
  /**
@@ -15,8 +15,15 @@ declare global {
15
15
  */
16
16
  static createThumbnail(
17
17
  src: string | PIXI.DisplayObject,
18
- options?: InexactPartial<ImageHelper.CompositeOptions & ImageHelper.TextureToImageOptions>,
19
- ): Promise<ImageHelper.ThumbnailReturn>;
18
+ options?: ImageHelper.CompositeOptions & ImageHelper.TextureToImageOptions,
19
+ ): Promise<ImageHelper.ThumbnailReturn> | null;
20
+
21
+ /**
22
+ * Test whether a source file has a supported image extension type
23
+ * @param src - A requested image source path
24
+ * @returns Does the filename end with a valid image extension?
25
+ */
26
+ static hasImageExtension(src: string): boolean;
20
27
 
21
28
  /**
22
29
  * Composite a canvas object by rendering it to a single texture
@@ -25,10 +32,7 @@ declare global {
25
32
  * (default: `{}`)
26
33
  * @returns The composite Texture object
27
34
  */
28
- static compositeCanvasTexture(
29
- object: PIXI.DisplayObject,
30
- options?: InexactPartial<ImageHelper.CompositeOptions>,
31
- ): PIXI.Texture;
35
+ static compositeCanvasTexture(object: PIXI.DisplayObject, options?: ImageHelper.CompositeOptions): PIXI.Texture;
32
36
 
33
37
  /**
34
38
  * Extract a texture to a base64 PNG string
@@ -36,10 +40,7 @@ declare global {
36
40
  * @param options - (default: `{}`)
37
41
  * @returns A base64 png string of the texture
38
42
  */
39
- static textureToImage(
40
- texture: PIXI.Texture,
41
- options?: InexactPartial<ImageHelper.TextureToImageOptions>,
42
- ): Promise<string>;
43
+ static textureToImage(texture: PIXI.Texture, options?: ImageHelper.TextureToImageOptions): Promise<string>;
43
44
 
44
45
  /**
45
46
  * Asynchronously convert a DisplayObject container to base64 using Canvas#toBlob and FileReader
@@ -47,12 +48,18 @@ declare global {
47
48
  * @param type - The requested mime type of the output, default is image/png
48
49
  * @param quality - A number between 0 and 1 for image quality if image/jpeg or image/webp
49
50
  * @returns A processed base64 string
51
+ * @privateRemarks Foundry doesn't mark `type` or `quality` as optional, but they're passed directly to `this.canvasToBase64`, where they *are* optional.
50
52
  */
51
- static pixiToBase64(target: PIXI.DisplayObject, type: string, quality: number): Promise<string>;
53
+ static pixiToBase64(
54
+ target: PIXI.DisplayObject,
55
+ type?: foundry.CONST.IMAGE_FILE_EXTENSIONS,
56
+ quality?: number,
57
+ ): Promise<string>;
52
58
 
53
59
  /**
54
60
  * Asynchronously convert a canvas element to base64.
55
- * @param type - (default: `["image/png"]`)
61
+ * @param type - (default: `"image/png"`)
62
+ * @param quality - JPEG or WEBP compression from 0 to 1. Default is 0.92.
56
63
  * @returns The base64 string of the canvas.
57
64
  */
58
65
  static canvasToBase64(
@@ -73,14 +80,7 @@ declare global {
73
80
  base64: string,
74
81
  fileName: string,
75
82
  filePath: string,
76
- options?: {
77
- /** The data storage location to which the file should be uploaded (default: `"data"`) */
78
- storage: string;
79
- /** The MIME type of the file being uploaded */
80
- type?: foundry.CONST.IMAGE_FILE_EXTENSIONS;
81
- /** Display a UI notification when the upload is processed. (default: `true`) */
82
- notify: boolean;
83
- },
83
+ options?: ImageHelper.UploadBase64Options,
84
84
  ): Promise<ReturnType<(typeof FilePicker)["upload"]>>;
85
85
 
86
86
  /**
@@ -93,16 +93,18 @@ declare global {
93
93
  pixels: Uint8ClampedArray,
94
94
  width: number,
95
95
  height: number,
96
- options: InexactPartial<ImageHelper.PixelsToCanvasOptions>,
96
+ options: ImageHelper.PixelsToCanvasOptions,
97
97
  ): HTMLCanvasElement;
98
98
  }
99
99
 
100
100
  namespace ImageHelper {
101
101
  /**
102
- * An interface for options for the {@link ImageHelper.createThumbnail} and {@link ImageHelper.compositeCanvasTexture}
103
- * methods.
102
+ * @internal Helper type to simplify NullishProps usage.
103
+ * @remarks Letting this be NullishProps instead of InexactPartial because despite `tx` and `ty` only
104
+ * having defaults via `{=0}`, they either get overwritten or `*=`ed which casts null to `0`, their default anyway.
105
+ *
104
106
  */
105
- interface CompositeOptions {
107
+ type _CompositeOptions = NullishProps<{
106
108
  /**
107
109
  * Center the texture in the rendered frame?
108
110
  * @defaultValue `true`
@@ -132,21 +134,61 @@ declare global {
132
134
  * @defaultValue The width of the object passed to {@link ImageHelper.compositeCanvasTexture}
133
135
  */
134
136
  width: number;
135
- }
137
+ }>;
138
+
139
+ /**
140
+ * An interface for options for the {@link ImageHelper.createThumbnail} and {@link ImageHelper.compositeCanvasTexture}
141
+ * methods.
142
+ */
143
+ interface CompositeOptions extends _CompositeOptions {}
136
144
 
137
- interface TextureToImageOptions {
145
+ type Format = "image/png" | "image/jpeg" | "image/webp";
146
+
147
+ /**
148
+ * @internal Helper type to simplify NullishProps usage
149
+ * @remarks Letting this be NullishProps, as, after testing, passing null values to `HTMLCanvasElement#toBlob()`,
150
+ * where these eventually end up, doesn't break anything and seems to apply the defaults
151
+ */
152
+ type _TextureToImageOptions = NullishProps<{
138
153
  /**
139
154
  * Image format, e.g. "image/jpeg" or "image/webp".
140
155
  * @defaultValue `"image/png"`
141
156
  */
142
- format: string;
157
+ format: Format;
143
158
 
144
159
  /**
145
160
  * JPEG or WEBP compression from 0 to 1. Default is 0.92.
146
161
  * @defaultValue `0.92`
147
162
  */
148
163
  quality: number;
149
- }
164
+ }>;
165
+
166
+ interface TextureToImageOptions extends _TextureToImageOptions {}
167
+
168
+ /** @internal Intermediary type to simplify use of optionality- and nullish-permissiveness-modifying helpers */
169
+ type _UploadBase64Options = InexactPartial<{
170
+ /**
171
+ * The data storage location to which the file should be uploaded
172
+ * @remarks Can't be null because it's passed directly to `FilePicker.upload` and its only default is via signature default value
173
+ * @defaultValue `"data"`
174
+ */
175
+ storage: FilePicker.SourceType;
176
+ }> &
177
+ NullishProps<{
178
+ /**
179
+ * The MIME type of the file being uploaded
180
+ * @remarks Will be extracted from the base64 data, if not provided.
181
+ */
182
+ type: foundry.CONST.IMAGE_FILE_EXTENSIONS;
183
+
184
+ /**
185
+ * Display a UI notification when the upload is processed.
186
+ * @defaultValue `true`
187
+ */
188
+ notify: boolean;
189
+ }>;
190
+
191
+ interface UploadBase64Options extends _UploadBase64Options {}
150
192
 
151
193
  /**
152
194
  * An interface for return values of the {@link ImageHelper.createThumbnail} method.
@@ -178,13 +220,20 @@ declare global {
178
220
  width: number;
179
221
  }
180
222
 
181
- interface PixelsToCanvasOptions {
182
- /** The element to use. */
223
+ type _PixelsToCanvasOptions = NullishProps<{
224
+ /**
225
+ * The element to use.
226
+ * @remarks If not provided, a new HTMLCanvasElement is created.
227
+ */
183
228
  element: HTMLCanvasElement;
229
+
184
230
  /** Specified width for the element (default to buffer image width). */
185
231
  ew: number;
232
+
186
233
  /** Specified height for the element (default to buffer image height). */
187
234
  eh: number;
188
- }
235
+ }>;
236
+
237
+ interface PixelsToCanvasOptions extends _PixelsToCanvasOptions {}
189
238
  }
190
239
  }
@@ -3,8 +3,7 @@ import type Document from "../../../common/abstract/document.d.mts";
3
3
  import type { ClientDocument } from "./client-document.d.mts";
4
4
 
5
5
  declare class CanvasDocument<
6
- // TODO(LukeAbby): Setting this to `Scene.ConfiguredInstance` causes a lot of circular errors.
7
- BaseDocument extends Document<any, any, Scene | null>,
6
+ BaseDocument extends Document<any, any, Scene.ConfiguredInstance | null>,
8
7
  > extends ClientDocument<BaseDocument> {
9
8
  /** @privateRemarks All mixin classses should accept anything for its constructor. */
10
9
  constructor(...args: any[]);
@@ -336,8 +336,8 @@ declare class ClientDocument<BaseDocument extends Document.Internal.Instance.Any
336
336
  */
337
337
  static createDialog<T extends Document.AnyConstructor>(
338
338
  this: T,
339
- data?: DeepPartial<Document.ConstructorDataFor<T> & Record<string, unknown>>,
340
- context?: Pick<DatabaseCreateOperation<InstanceType<T>>, "parent" | "pack"> &
339
+ data?: DeepPartial<Document.ConstructorDataFor<NoInfer<T>> & Record<string, unknown>>,
340
+ context?: Pick<DatabaseCreateOperation<InstanceType<NoInfer<T>>>, "parent" | "pack"> &
341
341
  InexactPartial<
342
342
  DialogOptions & {
343
343
  /** A restriction the selectable sub-types of the Dialog. */
@@ -378,7 +378,7 @@ declare class ClientDocument<BaseDocument extends Document.Internal.Instance.Any
378
378
  */
379
379
  static fromDropData<T extends Document.AnyConstructor>(
380
380
  this: T,
381
- data: DropData<InstanceType<T>>,
381
+ data: DropData<InstanceType<NoInfer<T>>>,
382
382
  options?: FromDropDataOptions,
383
383
  ): Promise<Document.ToConfiguredInstance<T> | undefined>;
384
384
 
@@ -32,7 +32,7 @@ declare class DirectoryCollection<T extends DirectoryCollection.DirectoryTypes>
32
32
  /**
33
33
  * Reference the set of Folders which contain documents in this collection
34
34
  */
35
- get folders(): Collection<Folder>;
35
+ get folders(): Collection<Folder.Stored>;
36
36
 
37
37
  /**
38
38
  * The built tree structure of the DocumentCollection
@@ -17,7 +17,7 @@ declare global {
17
17
  /**
18
18
  * Reference the set of Folders which contain documents in this collection
19
19
  */
20
- get folders(): Collection<Folder>;
20
+ get folders(): Collection<Folder.Stored>;
21
21
 
22
22
  /**
23
23
  * Return a reference to the SidebarDirectory application for this WorldCollection.
@@ -153,7 +153,9 @@ declare global {
153
153
 
154
154
  // Note(LukeAbby): The overrides for `get` become unreasonably long and don't add any changes and so have been omitted.
155
155
 
156
- set(id: string, document: Document.Stored<Document.ConfiguredInstanceForName<T["type"]>>): this;
156
+ // NOTE(LukeAbby): This override was disabled for the time being because it's erroring.
157
+ // Thankfully it doesn't actually change its parent class's signature.
158
+ // set(id: string, document: Document.Stored<Document.ConfiguredInstanceForName<T["type"]>>): this;
157
159
 
158
160
  delete: (id: string) => boolean;
159
161
 
@@ -432,7 +434,7 @@ declare global {
432
434
  type ConstructorMetadata<T extends CompendiumCollection.Metadata> = T & {
433
435
  index: IndexTypeForMetadata<T>;
434
436
  folders: Folder[];
435
- }
437
+ };
436
438
 
437
439
  // The type that appears in `compendium.metadata` after initialization.
438
440
  interface Metadata {
@@ -440,7 +442,7 @@ declare global {
440
442
  label: string;
441
443
  name: string;
442
444
 
443
- flags: Record<string, never>; // created by the server, but always empty and no way to change it in a way that is s
445
+ flags: Record<string, never>; // created by the server, but always empty and no way to change it in a way that is s
444
446
  ownership: InexactPartial<foundry.packages.BasePackage.OwnershipRecord>;
445
447
  path: string;
446
448
  package: string;
@@ -7,7 +7,7 @@ declare global {
7
7
  /**
8
8
  * Get a Collection of Folders which contain Compendium Packs
9
9
  */
10
- get folders(): Collection<Folder>;
10
+ get folders(): Collection<Folder.Stored>;
11
11
 
12
12
  protected override _getVisibleTreeContents(): CompendiumCollection<CompendiumCollection.Metadata>[];
13
13
 
@@ -18,7 +18,13 @@ declare global {
18
18
  Item.ConfiguredInstance & {
19
19
  type: K;
20
20
  } & (DataModelConfig extends { Item: { readonly [_ in K]?: infer SystemData } }
21
- ? { system: SystemData }
21
+ ? {
22
+ // For backwards compatability both instances and classes are supported for the time being.
23
+ // Only constructors are valid however.
24
+ system: SystemData extends abstract new (arg0: never, ...args: never[]) => infer Instance
25
+ ? Instance
26
+ : SystemData;
27
+ }
22
28
  : // eslint-disable-next-line @typescript-eslint/no-empty-object-type
23
29
  {})
24
30
  >;
@@ -78,6 +84,9 @@ declare global {
78
84
  class Actor extends ClientDocumentMixin(foundry.documents.BaseActor) {
79
85
  static override metadata: Actor.Metadata;
80
86
 
87
+ // NOTE(LukeAbby): Helps stymy circularity.
88
+ // get documentName(): "Actor";
89
+
81
90
  protected override _configure(options?: { pack?: string | null }): void;
82
91
 
83
92
  /**
@@ -180,8 +180,10 @@ declare global {
180
180
 
181
181
  static createDocuments<T extends Document.AnyConstructor, Temporary extends boolean | undefined>(
182
182
  this: T,
183
- data: Array<fields.SchemaField.AssignmentType<InstanceType<T>["schema"]["fields"]> & Record<string, unknown>>,
184
- operation?: InexactPartial<Omit<DatabaseOperationsFor<T["metadata"]["name"], "create">, "data">> & {
183
+ data: Array<
184
+ fields.SchemaField.AssignmentType<InstanceType<NoInfer<T>>["schema"]["fields"]> & Record<string, unknown>
185
+ >,
186
+ operation?: InexactPartial<Omit<DatabaseOperationsFor<NoInfer<T>["metadata"]["name"], "create">, "data">> & {
185
187
  temporary?: Temporary;
186
188
  },
187
189
  ): Promise<Document.ToStoredIf<T, Temporary>[] | undefined>;
@@ -341,7 +343,7 @@ declare global {
341
343
 
342
344
  static override createDialog<T extends Document.AnyConstructor>(
343
345
  this: T,
344
- data?: DeepPartial<Document.ConstructorDataFor<T> & Record<string, unknown>>,
346
+ data?: DeepPartial<Document.ConstructorDataFor<NoInfer<T>> & Record<string, unknown>>,
345
347
  context?: Pick<DatabaseOperationsFor<Cards["documentName"], "create">, "parent" | "pack"> &
346
348
  InexactPartial<
347
349
  DialogOptions & {
@@ -9,6 +9,7 @@ declare global {
9
9
 
10
10
  type ConfiguredClass = Document.ConfiguredClassForName<"Folder">;
11
11
  type ConfiguredInstance = Document.ConfiguredInstanceForName<"Folder">;
12
+ type Stored = Document.Stored<ConfiguredInstance>;
12
13
 
13
14
  interface DatabaseOperations extends DocumentDatabaseOperations<Folder> {}
14
15
 
@@ -34,6 +35,10 @@ declare global {
34
35
  class Folder extends ClientDocumentMixin(foundry.documents.BaseFolder) {
35
36
  static override metadata: Folder.Metadata;
36
37
 
38
+ // TODO(LukeAbby): This random override is a symptom of a greater issue.
39
+ // Namely that `ClientDocumentMixin` incidentally erases some properties and breaks configuration.
40
+ documentName: "Folder";
41
+
37
42
  /**
38
43
  * The depth of this folder in its sidebar tree
39
44
  *
@@ -92,7 +97,7 @@ declare global {
92
97
 
93
98
  static createDialog<T extends Document.AnyConstructor>(
94
99
  this: T,
95
- data?: DeepPartial<Document.ConstructorDataFor<T> | (Document.ConstructorDataFor<T> & Record<string, unknown>)>,
100
+ data?: DeepPartial<Document.ConstructorDataFor<NoInfer<T>>>,
96
101
  context?: InexactPartial<Omit<FolderConfig.Options, "resolve">>,
97
102
  ): Promise<Document.ToConfiguredInstance<T> | null | undefined>;
98
103
 
@@ -169,7 +169,7 @@ declare global {
169
169
  * @param data - (default: `{}`)
170
170
  * @returns The created thumbnail data.
171
171
  */
172
- createThumbnail(data?: InexactPartial<ThumbnailCreationData>): ReturnType<(typeof ImageHelper)["createThumbnail"]>;
172
+ createThumbnail(data?: ThumbnailCreationData): ReturnType<typeof ImageHelper.createThumbnail>;
173
173
  }
174
174
 
175
175
  interface SceneDimensions {
@@ -223,10 +223,12 @@ declare global {
223
223
  }
224
224
  }
225
225
 
226
- interface ThumbnailCreationData extends ImageHelper.TextureToImageOptions {
226
+ interface _ThumbnailCreationData extends ImageHelper.TextureToImageOptions {
227
227
  /**
228
228
  * A background image to use for thumbnail creation, otherwise the current scene
229
229
  * background is used.
230
+ *
231
+ * @remarks This cannot be `null` because Foundry writes `const newImage = img !== undefined;`.
230
232
  */
231
233
  img: string;
232
234
 
@@ -234,23 +236,28 @@ interface ThumbnailCreationData extends ImageHelper.TextureToImageOptions {
234
236
  * The desired thumbnail width. Default is 300px
235
237
  * @defaultValue `300`
236
238
  */
237
- width: number;
239
+ width: number | null;
238
240
 
239
241
  /**
240
242
  * The desired thumbnail height. Default is 100px;
241
243
  * @defaultValue `100`
242
244
  */
243
- height: number;
245
+ height: number | null;
244
246
 
245
247
  /**
246
- * Which image format should be used? image/png, image/jpg, or image/webp
248
+ * Which image format should be used? image/png, image/jpeg, or image/webp
247
249
  * @defaultValue `"image/webp"`
250
+ *
251
+ * @remarks Foundry writes `image/jpg` but this functions the same as `image/png `.
252
+ * The correct MIME type is `image/jpeg`.
248
253
  */
249
- format: "image/png" | "image/jpg" | "image/webp";
254
+ format: ImageHelper.Format | null;
250
255
 
251
256
  /**
252
257
  * What compression quality should be used for jpeg or webp, between 0 and 1
253
258
  * @defaultValue `0.8`
254
259
  */
255
- quality: number;
260
+ quality: number | null;
256
261
  }
262
+
263
+ interface ThumbnailCreationData extends InexactPartial<_ThumbnailCreationData> {}
@@ -9,11 +9,7 @@ declare global {
9
9
  type Metadata = Document.MetadataFor<TokenDocument>;
10
10
 
11
11
  type ConfiguredClass = Document.ConfiguredClassForName<"Token">;
12
- type ConfiguredInstance = InstanceType<ConfiguredClass>;
13
-
14
- // TODO(LukeAbby): This causes a circularity that's likely latent.
15
- // Look into this.
16
- // type ConfiguredInstance = ConfiguredDocumentInstanceForName<"Token">;
12
+ type ConfiguredInstance = Document.ConfiguredInstanceForName<"Token">;
17
13
 
18
14
  type ObjectClass = Document.ConfiguredObjectClassForName<"Token">;
19
15
  type ObjectInstance = Document.ConfiguredObjectInstanceForName<"Token">;
@@ -5,7 +5,7 @@ import type BaseUser from "../../../common/documents/user.d.mts";
5
5
 
6
6
  declare global {
7
7
  namespace User {
8
- type Metadata = Document.Metadata<User>;
8
+ type Metadata = Document.MetadataFor<User>;
9
9
 
10
10
  type ConfiguredClass = Document.ConfiguredClassForName<"User">;
11
11
  type ConfiguredInstance = Document.ConfiguredInstanceForName<"User">;
@@ -660,9 +660,14 @@ declare global {
660
660
  namespace Model {
661
661
  /**
662
662
  * Get the configured core and system type names for a specific document type.
663
+ *
664
+ * Because of module subtypes, extra types of the form `${moduleName}.${subtype}` are always a possibility.
665
+ *
663
666
  * @typeParam DocumentName - the type of the Document this data is for
664
667
  */
665
- type TypeNames<DocumentName extends Document.Type> = string & keyof Model[DocumentName];
668
+ type TypeNames<DocumentName extends Document.Type> =
669
+ | (string & keyof Model[DocumentName])
670
+ | (`${string}.${string}` & {});
666
671
  }
667
672
 
668
673
  type Model = {
@@ -689,7 +689,7 @@ declare global {
689
689
  user: string;
690
690
 
691
691
  /** The identified speaker data, see {@link ChatMessage.getSpeaker} */
692
- speaker: ReturnType<Document.ToConfiguredClass<typeof ChatMessage>["getSpeaker"]>;
692
+ speaker: ReturnType<ChatMessage.ConfiguredClass["getSpeaker"]>;
693
693
  },
694
694
  ) => boolean | void;
695
695
 
@@ -2,6 +2,15 @@ import type { InexactPartial, NullishProps } from "../../../types/utils.d.mts";
2
2
  import type Document from "../../common/abstract/document.d.mts";
3
3
  import type { CANVAS_PERFORMANCE_MODES } from "../../common/constants.d.mts";
4
4
 
5
+ type InternalCanvas = new (
6
+ arg0: never,
7
+ ...args: never[]
8
+ ) => {
9
+ readonly [K in keyof CONFIG.Canvas.Groups]?: InstanceType<CONFIG.Canvas.Groups[K]["groupClass"]> | undefined;
10
+ };
11
+
12
+ declare const _InternalCanvas: InternalCanvas;
13
+
5
14
  declare global {
6
15
  /**
7
16
  * The virtual tabletop environment is implemented using a WebGL powered HTML 5 canvas using the powerful PIXI.js
@@ -29,7 +38,7 @@ declare global {
29
38
  * canvas.recenter(); // Re-center the canvas on the currently controlled Token.
30
39
  * ```
31
40
  */
32
- class Canvas {
41
+ class Canvas extends _InternalCanvas {
33
42
  constructor();
34
43
 
35
44
  /**
@@ -672,9 +681,6 @@ declare global {
672
681
  get colorManager(): this["environment"];
673
682
  }
674
683
 
675
- // Most canvas group properties have explicit type definitions, but some are left off
676
- interface Canvas extends CanvasGroups {}
677
-
678
684
  interface CanvasPerformanceSettings {
679
685
  /** The performance mode in CONST.CANVAS_PERFORMANCE_MODES */
680
686
  mode: CANVAS_PERFORMANCE_MODES;
@@ -807,14 +813,3 @@ interface CollectionNameToLayerMap {
807
813
  tokens: Canvas["tokens"];
808
814
  walls: Canvas["walls"];
809
815
  }
810
-
811
- // TODO: Find a way to make this more dynamic
812
- interface CanvasGroups {
813
- // readonly [GroupName in keyof CONFIG.Canvas.Groups]?: CONFIG.Canvas.Groups[GroupName]["groupClass"];
814
-
815
- readonly hidden?: HiddenCanvasGroup;
816
-
817
- readonly rendered?: RenderedCanvasGroup;
818
-
819
- readonly environment?: EnvironmentCanvasGroup;
820
- }
@@ -60,7 +60,6 @@ type _RenderFlags<Flags> = InexactPartial<{
60
60
  }>;
61
61
 
62
62
  declare global {
63
-
64
63
  interface RenderFlag<Flags> extends _RenderFlags<Flags> {}
65
64
 
66
65
  namespace RenderFlag {
@@ -138,7 +138,7 @@ declare global {
138
138
  * @remarks `"TextureLoader.textureBufferDataMap is deprecated without replacement. Use TextureLoader.getTextureAlphaData`
139
139
  * `to create a texture data map and cache it automatically, or create your own caching system."`
140
140
  */
141
- static get textureBufferDataMap(): Map<string, AnyObject>
141
+ static get textureBufferDataMap(): Map<string, AnyObject>;
142
142
 
143
143
  /**
144
144
  * A global reference to the singleton texture loader