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

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 (559) hide show
  1. package/README.md +17 -18
  2. package/package.json +91 -32
  3. package/src/configuration/configuration.d.mts +316 -0
  4. package/src/configuration/documents.d.mts +295 -0
  5. package/src/configuration/globals.d.mts +357 -0
  6. package/src/configuration/index.d.mts +5 -0
  7. package/src/foundry/client/apps/app.d.mts +129 -122
  8. package/src/foundry/client/apps/av/av-config.d.mts +12 -7
  9. package/src/foundry/client/apps/av/cameras.d.mts +12 -7
  10. package/src/foundry/client/apps/dice/dice-config.d.mts +59 -0
  11. package/src/foundry/client/apps/dice/index.d.mts +1 -0
  12. package/src/foundry/client/apps/form.d.mts +114 -86
  13. package/src/foundry/client/apps/forms/actor.d.mts +21 -11
  14. package/src/foundry/client/apps/forms/adventure-exporter.d.mts +12 -7
  15. package/src/foundry/client/apps/forms/adventure-importer.d.mts +14 -6
  16. package/src/foundry/client/apps/forms/base-sheet.d.mts +16 -8
  17. package/src/foundry/client/apps/forms/card-config.d.mts +16 -8
  18. package/src/foundry/client/apps/forms/cards-config.d.mts +15 -14
  19. package/src/foundry/client/apps/forms/combat-config.d.mts +7 -7
  20. package/src/foundry/client/apps/forms/combatant-config.d.mts +3 -3
  21. package/src/foundry/client/apps/forms/default-sheets-config.d.mts +1 -1
  22. package/src/foundry/client/apps/forms/effect-config.d.mts +7 -7
  23. package/src/foundry/client/apps/forms/folder-config.d.mts +10 -5
  24. package/src/foundry/client/apps/forms/fonts.d.mts +42 -35
  25. package/src/foundry/client/apps/forms/grid-config.d.mts +12 -13
  26. package/src/foundry/client/apps/forms/image-popout.d.mts +29 -23
  27. package/src/foundry/client/apps/forms/item.d.mts +9 -9
  28. package/src/foundry/client/apps/forms/journal-page-sheet.d.mts +16 -14
  29. package/src/foundry/client/apps/forms/journal-sheet.d.mts +48 -38
  30. package/src/foundry/client/apps/forms/macro-config.d.mts +7 -7
  31. package/src/foundry/client/apps/forms/measure-template.d.mts +10 -12
  32. package/src/foundry/client/apps/forms/ownership.d.mts +5 -5
  33. package/src/foundry/client/apps/forms/playlist-config.d.mts +8 -10
  34. package/src/foundry/client/apps/forms/playlist-sound-config.d.mts +7 -7
  35. package/src/foundry/client/apps/forms/roll-table-config.d.mts +11 -10
  36. package/src/foundry/client/apps/forms/scene-config.d.mts +40 -41
  37. package/src/foundry/client/apps/forms/sheet-config.d.mts +9 -21
  38. package/src/foundry/client/apps/forms/user-config.d.mts +13 -12
  39. package/src/foundry/client/apps/hud/chatbubble.d.mts +18 -6
  40. package/src/foundry/client/apps/hud/container.d.mts +4 -4
  41. package/src/foundry/client/apps/hud/controls.d.mts +126 -81
  42. package/src/foundry/client/apps/hud/hotbar.d.mts +17 -12
  43. package/src/foundry/client/apps/hud/hud.d.mts +5 -5
  44. package/src/foundry/client/apps/hud/menu.d.mts +10 -3
  45. package/src/foundry/client/apps/hud/navigation.d.mts +14 -9
  46. package/src/foundry/client/apps/hud/pause.d.mts +9 -4
  47. package/src/foundry/client/apps/hud/players.d.mts +14 -9
  48. package/src/foundry/client/apps/i18n.d.mts +31 -27
  49. package/src/foundry/client/apps/index.d.mts +1 -0
  50. package/src/foundry/client/apps/placeables/drawing-config.d.mts +41 -33
  51. package/src/foundry/client/apps/placeables/drawing-hud.d.mts +5 -5
  52. package/src/foundry/client/apps/placeables/index.d.mts +0 -2
  53. package/src/foundry/client/apps/placeables/note-config.d.mts +28 -18
  54. package/src/foundry/client/apps/placeables/tile-config.d.mts +23 -10
  55. package/src/foundry/client/apps/placeables/tile-hud.d.mts +10 -5
  56. package/src/foundry/client/apps/placeables/token-config.d.mts +91 -58
  57. package/src/foundry/client/apps/placeables/token-hud.d.mts +12 -7
  58. package/src/foundry/client/apps/placeables/wall-config.d.mts +21 -17
  59. package/src/foundry/client/apps/sidebar/apps/chat-popout.d.mts +5 -5
  60. package/src/foundry/client/apps/sidebar/apps/client-settings.d.mts +3 -3
  61. package/src/foundry/client/apps/sidebar/apps/compendium.d.mts +15 -13
  62. package/src/foundry/client/apps/sidebar/apps/invitation-links.d.mts +3 -3
  63. package/src/foundry/client/apps/sidebar/apps/keybindings-config.d.mts +3 -2
  64. package/src/foundry/client/apps/sidebar/apps/module-management.d.mts +6 -6
  65. package/src/foundry/client/apps/sidebar/apps/permission-config.d.mts +6 -6
  66. package/src/foundry/client/apps/sidebar/apps/support-details.d.mts +34 -29
  67. package/src/foundry/client/apps/sidebar/apps/tours-management.d.mts +2 -2
  68. package/src/foundry/client/apps/sidebar/apps/world-config.d.mts +13 -10
  69. package/src/foundry/client/apps/sidebar/directory-tab-mixin.d.mts +50 -35
  70. package/src/foundry/client/apps/sidebar/document-directory.d.mts +52 -38
  71. package/src/foundry/client/apps/sidebar/package-configuration.d.mts +4 -4
  72. package/src/foundry/client/apps/sidebar/sidebar-tab.d.mts +3 -3
  73. package/src/foundry/client/apps/sidebar/sidebar.d.mts +9 -4
  74. package/src/foundry/client/apps/sidebar/tabs/actors-directory.d.mts +11 -2
  75. package/src/foundry/client/apps/sidebar/tabs/cards-directory.d.mts +11 -2
  76. package/src/foundry/client/apps/sidebar/tabs/chat-log.d.mts +39 -27
  77. package/src/foundry/client/apps/sidebar/tabs/combat-tracker.d.mts +21 -12
  78. package/src/foundry/client/apps/sidebar/tabs/compendium-directory.d.mts +30 -15
  79. package/src/foundry/client/apps/sidebar/tabs/items-directory.d.mts +11 -2
  80. package/src/foundry/client/apps/sidebar/tabs/journal-directory.d.mts +11 -2
  81. package/src/foundry/client/apps/sidebar/tabs/macros-directory.d.mts +14 -5
  82. package/src/foundry/client/apps/sidebar/tabs/playlists-directory.d.mts +30 -22
  83. package/src/foundry/client/apps/sidebar/tabs/roll-table-directory.d.mts +11 -2
  84. package/src/foundry/client/apps/sidebar/tabs/scenes-directory.d.mts +14 -5
  85. package/src/foundry/client/apps/sidebar/tabs/settings.d.mts +23 -5
  86. package/src/foundry/client/apps/templates.d.mts +1 -1
  87. package/src/foundry/client/av/client.d.mts +1 -1
  88. package/src/foundry/client/av/clients/simplepeer.d.mts +11 -1
  89. package/src/foundry/client/av/master.d.mts +2 -2
  90. package/src/foundry/client/av/settings.d.mts +17 -15
  91. package/src/foundry/client/config.d.mts +444 -312
  92. package/src/foundry/client/core/document-index.d.mts +11 -3
  93. package/src/foundry/client/core/hooks.d.mts +2 -4
  94. package/src/foundry/client/core/image.d.mts +14 -13
  95. package/src/foundry/client/core/issues.d.mts +9 -4
  96. package/src/foundry/client/core/keybindings.d.mts +5 -5
  97. package/src/foundry/client/core/nue.d.mts +1 -1
  98. package/src/foundry/client/core/packages.d.mts +400 -62
  99. package/src/foundry/client/core/settings.d.mts +62 -38
  100. package/src/foundry/client/core/socket.d.mts +2 -2
  101. package/src/foundry/client/core/sorting.d.mts +6 -6
  102. package/src/foundry/client/core/time.d.mts +6 -3
  103. package/src/foundry/client/core/tooltip.d.mts +2 -2
  104. package/src/foundry/client/core/tour.d.mts +59 -50
  105. package/src/foundry/client/core/tours.d.mts +1 -1
  106. package/src/foundry/client/core/utils.d.mts +33 -10
  107. package/src/foundry/client/core/video.d.mts +1 -1
  108. package/src/foundry/client/core/workers.d.mts +24 -17
  109. package/src/foundry/client/data/abstract/canvas-document.d.mts +22 -28
  110. package/src/foundry/client/data/abstract/client-document.d.mts +238 -206
  111. package/src/foundry/client/data/abstract/directory-collection-mixin.d.mts +24 -40
  112. package/src/foundry/client/data/abstract/document-collection.d.mts +96 -68
  113. package/src/foundry/client/data/abstract/world-collection.d.mts +53 -54
  114. package/src/foundry/client/data/collections/actors.d.mts +30 -28
  115. package/src/foundry/client/data/collections/cards.d.mts +16 -3
  116. package/src/foundry/client/data/collections/combats.d.mts +18 -5
  117. package/src/foundry/client/data/collections/compendium-collection.d.mts +84 -101
  118. package/src/foundry/client/data/collections/compendium-folders.d.mts +6 -6
  119. package/src/foundry/client/data/collections/compendium-packs.d.mts +5 -5
  120. package/src/foundry/client/data/collections/fog.d.mts +16 -3
  121. package/src/foundry/client/data/collections/folder.d.mts +20 -6
  122. package/src/foundry/client/data/collections/items.d.mts +17 -4
  123. package/src/foundry/client/data/collections/journal.d.mts +22 -7
  124. package/src/foundry/client/data/collections/macros.d.mts +21 -19
  125. package/src/foundry/client/data/collections/messages.d.mts +19 -6
  126. package/src/foundry/client/data/collections/playlists.d.mts +17 -5
  127. package/src/foundry/client/data/collections/scenes.d.mts +24 -27
  128. package/src/foundry/client/data/collections/settings.d.mts +16 -3
  129. package/src/foundry/client/data/collections/tables.d.mts +18 -5
  130. package/src/foundry/client/data/collections/users.d.mts +22 -10
  131. package/src/foundry/client/data/documents/active-effect.d.mts +780 -112
  132. package/src/foundry/client/data/documents/actor-delta.d.mts +705 -31
  133. package/src/foundry/client/data/documents/actor.d.mts +806 -98
  134. package/src/foundry/client/data/documents/adventure.d.mts +522 -59
  135. package/src/foundry/client/data/documents/ambient-light.d.mts +427 -20
  136. package/src/foundry/client/data/documents/ambient-sound.d.mts +478 -14
  137. package/src/foundry/client/data/documents/card.d.mts +598 -44
  138. package/src/foundry/client/data/documents/cards.d.mts +862 -169
  139. package/src/foundry/client/data/documents/chat-message.d.mts +668 -77
  140. package/src/foundry/client/data/documents/combat.d.mts +757 -107
  141. package/src/foundry/client/data/documents/combatant.d.mts +545 -32
  142. package/src/foundry/client/data/documents/drawing.d.mts +545 -14
  143. package/src/foundry/client/data/documents/fog-exploration.d.mts +465 -30
  144. package/src/foundry/client/data/documents/folder.d.mts +567 -51
  145. package/src/foundry/client/data/documents/index.d.mts +2 -0
  146. package/src/foundry/client/data/documents/item.d.mts +691 -24
  147. package/src/foundry/client/data/documents/journal-entry-page.d.mts +654 -55
  148. package/src/foundry/client/data/documents/journal-entry.d.mts +631 -35
  149. package/src/foundry/client/data/documents/macro.d.mts +560 -31
  150. package/src/foundry/client/data/documents/measured-template.d.mts +484 -15
  151. package/src/foundry/client/data/documents/note.d.mts +498 -15
  152. package/src/foundry/client/data/documents/playlist-sound.d.mts +443 -45
  153. package/src/foundry/client/data/documents/playlist.d.mts +710 -99
  154. package/src/foundry/client/data/documents/region-behavior.d.mts +516 -0
  155. package/src/foundry/client/data/documents/region.d.mts +789 -0
  156. package/src/foundry/client/data/documents/scene.d.mts +1216 -159
  157. package/src/foundry/client/data/documents/setting.d.mts +406 -23
  158. package/src/foundry/client/data/documents/table-result.d.mts +488 -14
  159. package/src/foundry/client/data/documents/table.d.mts +667 -78
  160. package/src/foundry/client/data/documents/tile.d.mts +505 -14
  161. package/src/foundry/client/data/documents/token.d.mts +1191 -143
  162. package/src/foundry/client/data/documents/user.d.mts +613 -57
  163. package/src/foundry/client/data/documents/wall.d.mts +555 -14
  164. package/src/foundry/client/game.d.mts +60 -92
  165. package/src/foundry/client/head.d.mts +9 -9
  166. package/src/foundry/client/hooks.d.mts +259 -248
  167. package/src/foundry/client/pixi/board.d.mts +107 -94
  168. package/src/foundry/client/pixi/core/containers/base-canvas-group.d.mts +97 -25
  169. package/src/foundry/client/pixi/core/containers/cached-container.d.mts +37 -19
  170. package/src/foundry/client/pixi/core/containers/full-canvas-container.d.mts +7 -10
  171. package/src/foundry/client/pixi/core/containers/point-source-mesh.d.mts +25 -15
  172. package/src/foundry/client/pixi/core/containers/quad-mesh.d.mts +16 -6
  173. package/src/foundry/client/pixi/core/containers/quadtree.d.mts +113 -54
  174. package/src/foundry/client/pixi/core/containers/sprite-mesh.d.mts +69 -26
  175. package/src/foundry/client/pixi/core/containers/unbound-container.d.mts +20 -2
  176. package/src/foundry/client/pixi/core/interaction/canvas-animation.d.mts +164 -99
  177. package/src/foundry/client/pixi/core/interaction/control-icon.d.mts +61 -22
  178. package/src/foundry/client/pixi/core/interaction/mouse-handler.d.mts +120 -53
  179. package/src/foundry/client/pixi/core/interaction/ping.d.mts +62 -31
  180. package/src/foundry/client/pixi/core/interaction/pings/chevron.d.mts +23 -10
  181. package/src/foundry/client/pixi/core/interaction/pings/pulse.d.mts +91 -34
  182. package/src/foundry/client/pixi/core/interaction/render-flags.d.mts +69 -30
  183. package/src/foundry/client/pixi/core/interaction/resize-handle.d.mts +35 -5
  184. package/src/foundry/client/pixi/core/interaction/targets.d.mts +21 -18
  185. package/src/foundry/client/pixi/core/loader.d.mts +86 -76
  186. package/src/foundry/client/pixi/core/shapes/limited-angle-polygon.d.mts +42 -17
  187. package/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts +92 -64
  188. package/src/foundry/client/pixi/core/shapes/precise-text.d.mts +28 -10
  189. package/src/foundry/client/pixi/core/shapes/ray.d.mts +47 -23
  190. package/src/foundry/client/pixi/core/shapes/source-polygon.d.mts +170 -75
  191. package/src/foundry/client/pixi/extensions/circle.d.mts +128 -125
  192. package/src/foundry/client/pixi/extensions/graphics.d.mts +3 -1
  193. package/src/foundry/client/pixi/extensions/observable-transform.d.mts +5 -4
  194. package/src/foundry/client/pixi/extensions/polygon.d.mts +154 -134
  195. package/src/foundry/client/pixi/extensions/rectangle.d.mts +242 -259
  196. package/src/foundry/client/pixi/groups/effects.d.mts +75 -24
  197. package/src/foundry/client/pixi/groups/environment.d.mts +68 -19
  198. package/src/foundry/client/pixi/groups/hidden.d.mts +27 -11
  199. package/src/foundry/client/pixi/groups/interface.d.mts +62 -38
  200. package/src/foundry/client/pixi/groups/overlay.d.mts +19 -7
  201. package/src/foundry/client/pixi/groups/primary.d.mts +66 -44
  202. package/src/foundry/client/pixi/groups/rendered.d.mts +19 -7
  203. package/src/foundry/client/pixi/layers/base/canvas-layer.d.mts +11 -15
  204. package/src/foundry/client/pixi/layers/base/interaction-layer.d.mts +29 -28
  205. package/src/foundry/client/pixi/layers/base/placeables-layer.d.mts +306 -272
  206. package/src/foundry/client/pixi/layers/controls/cursor.d.mts +18 -9
  207. package/src/foundry/client/pixi/layers/controls/door.d.mts +32 -11
  208. package/src/foundry/client/pixi/layers/controls/layer.d.mts +89 -77
  209. package/src/foundry/client/pixi/layers/controls/ruler.d.mts +121 -96
  210. package/src/foundry/client/pixi/layers/effects/background-effects.d.mts +9 -12
  211. package/src/foundry/client/pixi/layers/effects/coloration-effects.d.mts +9 -10
  212. package/src/foundry/client/pixi/layers/effects/darkness-effects.d.mts +8 -8
  213. package/src/foundry/client/pixi/layers/effects/illumination-effects.d.mts +22 -22
  214. package/src/foundry/client/pixi/layers/effects/visibility.d.mts +106 -86
  215. package/src/foundry/client/pixi/layers/effects/weather/particles/effect.d.mts +14 -5
  216. package/src/foundry/client/pixi/layers/effects/weather/particles/leaves.d.mts +31 -2
  217. package/src/foundry/client/pixi/layers/effects/weather-effects.d.mts +137 -65
  218. package/src/foundry/client/pixi/layers/grid/highlight.d.mts +14 -4
  219. package/src/foundry/client/pixi/layers/grid/layer.d.mts +92 -92
  220. package/src/foundry/client/pixi/layers/grid/mesh.d.mts +37 -16
  221. package/src/foundry/client/pixi/layers/masks/depth.d.mts +12 -7
  222. package/src/foundry/client/pixi/layers/masks/occlusion.d.mts +19 -12
  223. package/src/foundry/client/pixi/layers/masks/vision.d.mts +104 -18
  224. package/src/foundry/client/pixi/layers/placeables/drawings.d.mts +16 -15
  225. package/src/foundry/client/pixi/layers/placeables/index.d.mts +1 -0
  226. package/src/foundry/client/pixi/layers/placeables/lighting.d.mts +12 -14
  227. package/src/foundry/client/pixi/layers/placeables/notes.d.mts +49 -32
  228. package/src/foundry/client/pixi/layers/placeables/regions.d.mts +113 -0
  229. package/src/foundry/client/pixi/layers/placeables/sounds.d.mts +81 -67
  230. package/src/foundry/client/pixi/layers/placeables/templates.d.mts +11 -15
  231. package/src/foundry/client/pixi/layers/placeables/tiles.d.mts +30 -21
  232. package/src/foundry/client/pixi/layers/placeables/tokens.d.mts +66 -52
  233. package/src/foundry/client/pixi/layers/placeables/walls.d.mts +54 -57
  234. package/src/foundry/client/pixi/perception/clockwise-sweep.d.mts +62 -27
  235. package/src/foundry/client/pixi/perception/detection-mode.d.mts +121 -47
  236. package/src/foundry/client/pixi/perception/fog.d.mts +38 -15
  237. package/src/foundry/client/pixi/perception/perception-manager.d.mts +136 -136
  238. package/src/foundry/client/pixi/perception/vision-mode.d.mts +91 -64
  239. package/src/foundry/client/pixi/perception/weiler-atherton-clipping.d.mts +44 -16
  240. package/src/foundry/client/pixi/placeable.d.mts +239 -137
  241. package/src/foundry/client/pixi/placeables/drawing.d.mts +255 -133
  242. package/src/foundry/client/pixi/placeables/index.d.mts +1 -0
  243. package/src/foundry/client/pixi/placeables/light.d.mts +193 -64
  244. package/src/foundry/client/pixi/placeables/note.d.mts +145 -54
  245. package/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.mts +30 -8
  246. package/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-graphics.d.mts +41 -11
  247. package/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-occludable-object.d.mts +59 -18
  248. package/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-sprite-mesh.d.mts +120 -37
  249. package/src/foundry/client/pixi/placeables/region.d.mts +280 -0
  250. package/src/foundry/client/pixi/placeables/sound.d.mts +205 -66
  251. package/src/foundry/client/pixi/placeables/template.d.mts +181 -100
  252. package/src/foundry/client/pixi/placeables/tile.d.mts +206 -140
  253. package/src/foundry/client/pixi/placeables/token.d.mts +916 -449
  254. package/src/foundry/client/pixi/placeables/wall.d.mts +249 -129
  255. package/src/foundry/client/pixi/webgl/extensions/batch-renderer.d.mts +72 -33
  256. package/src/foundry/client/pixi/webgl/extensions/batch-shader-generator.d.mts +10 -9
  257. package/src/foundry/client/pixi/webgl/helpers/{framebugger-snapshot.d.mts → framebuffer-snapshot.d.mts} +10 -9
  258. package/src/foundry/client/pixi/webgl/helpers/index.d.mts +1 -1
  259. package/src/foundry/client/pixi/webgl/helpers/smooth-noise.d.mts +38 -23
  260. package/src/foundry/client/pixi/webgl/helpers/texture-extractor.d.mts +82 -53
  261. package/src/foundry/client/pixi/webgl/shaders/base-shader-mixin.d.mts +12 -12
  262. package/src/foundry/client/pixi/webgl/shaders/base-shader.d.mts +45 -28
  263. package/src/foundry/client/pixi/webgl/shaders/filters/base-filter.d.mts +12 -11
  264. package/src/foundry/client/pixi/webgl/shaders/filters/base-mask-filter.d.mts +12 -10
  265. package/src/foundry/client/pixi/webgl/shaders/filters/blur.d.mts +22 -20
  266. package/src/foundry/client/pixi/webgl/shaders/filters/effects-masking.d.mts +36 -32
  267. package/src/foundry/client/pixi/webgl/shaders/filters/environment.d.mts +10 -9
  268. package/src/foundry/client/pixi/webgl/shaders/filters/glow-overlay.d.mts +12 -11
  269. package/src/foundry/client/pixi/webgl/shaders/filters/invisibility.d.mts +10 -9
  270. package/src/foundry/client/pixi/webgl/shaders/filters/outline-overlay.d.mts +12 -11
  271. package/src/foundry/client/pixi/webgl/shaders/filters/transition.d.mts +67 -60
  272. package/src/foundry/client/pixi/webgl/shaders/filters/visibility.d.mts +24 -17
  273. package/src/foundry/client/pixi/webgl/shaders/filters/vision-mask-filter.d.mts +13 -10
  274. package/src/foundry/client/pixi/webgl/shaders/filters/void.d.mts +10 -9
  275. package/src/foundry/client/pixi/webgl/shaders/filters/weather-occlusion-masks.d.mts +11 -10
  276. package/src/foundry/client/pixi/webgl/shaders/fragment-channel-mixin.d.mts +20 -14
  277. package/src/foundry/client/pixi/webgl/shaders/grid/grid.d.mts +12 -11
  278. package/src/foundry/client/pixi/webgl/shaders/lighting/background-lighting.d.mts +10 -9
  279. package/src/foundry/client/pixi/webgl/shaders/lighting/base-lighting.d.mts +33 -33
  280. package/src/foundry/client/pixi/webgl/shaders/lighting/coloration-lighting.d.mts +10 -9
  281. package/src/foundry/client/pixi/webgl/shaders/lighting/darkness-lighting.d.mts +10 -9
  282. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/bewitching-wave.d.mts +19 -17
  283. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/black-hole.d.mts +10 -9
  284. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/chroma.d.mts +10 -9
  285. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/emanation.d.mts +10 -9
  286. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/energy-field.d.mts +10 -9
  287. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/fairy-light.d.mts +19 -17
  288. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/flame.d.mts +19 -17
  289. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/fog.d.mts +10 -9
  290. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/force-grid.d.mts +10 -8
  291. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/ghost-light.d.mts +19 -17
  292. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/hexa-dome.d.mts +10 -9
  293. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/light-dome.d.mts +10 -9
  294. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/magical-gloom.d.mts +10 -9
  295. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/pulse.d.mts +19 -17
  296. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/radial-rainbow.d.mts +10 -9
  297. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/revolving-light.d.mts +10 -9
  298. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/roiling-mass.d.mts +10 -9
  299. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/siren-light.d.mts +19 -17
  300. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/smoke-patch.d.mts +20 -17
  301. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/star-light.d.mts +10 -9
  302. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/sunburst.d.mts +19 -17
  303. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/swirling-rainbow.d.mts +10 -9
  304. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/torch.d.mts +19 -17
  305. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/vortex.d.mts +19 -17
  306. package/src/foundry/client/pixi/webgl/shaders/lighting/effects/wave.d.mts +19 -17
  307. package/src/foundry/client/pixi/webgl/shaders/lighting/illumination-lighting.d.mts +10 -9
  308. package/src/foundry/client/pixi/webgl/shaders/region/adjust-darkness-level.d.mts +71 -29
  309. package/src/foundry/client/pixi/webgl/shaders/region/base.d.mts +54 -10
  310. package/src/foundry/client/pixi/webgl/shaders/region/highlight.d.mts +69 -9
  311. package/src/foundry/client/pixi/webgl/shaders/samplers/base-sampler.d.mts +24 -25
  312. package/src/foundry/client/pixi/webgl/shaders/samplers/baseline-illumination.d.mts +10 -9
  313. package/src/foundry/client/pixi/webgl/shaders/samplers/color-adjustment.d.mts +38 -29
  314. package/src/foundry/client/pixi/webgl/shaders/samplers/depth.d.mts +21 -17
  315. package/src/foundry/client/pixi/webgl/shaders/samplers/fog-of-war.d.mts +10 -9
  316. package/src/foundry/client/pixi/webgl/shaders/samplers/occlusion.d.mts +20 -18
  317. package/src/foundry/client/pixi/webgl/shaders/samplers/primary.d.mts +11 -2
  318. package/src/foundry/client/pixi/webgl/shaders/samplers/token-ring.d.mts +28 -2
  319. package/src/foundry/client/pixi/webgl/shaders/vision/background-vision.d.mts +10 -9
  320. package/src/foundry/client/pixi/webgl/shaders/vision/base-vision.d.mts +11 -9
  321. package/src/foundry/client/pixi/webgl/shaders/vision/coloration-vision.d.mts +10 -9
  322. package/src/foundry/client/pixi/webgl/shaders/vision/effects/amplification.d.mts +10 -9
  323. package/src/foundry/client/pixi/webgl/shaders/vision/effects/wave.d.mts +19 -17
  324. package/src/foundry/client/pixi/webgl/shaders/vision/illumination-vision.d.mts +10 -9
  325. package/src/foundry/client/pixi/webgl/shaders/weather/base-weather.d.mts +40 -36
  326. package/src/foundry/client/pixi/webgl/shaders/weather/effect.d.mts +27 -33
  327. package/src/foundry/client/pixi/webgl/shaders/weather/fog.d.mts +17 -16
  328. package/src/foundry/client/pixi/webgl/shaders/weather/rain.d.mts +19 -18
  329. package/src/foundry/client/pixi/webgl/shaders/weather/snow.d.mts +15 -14
  330. package/src/foundry/client/pixi/workers/texture-worker.d.mts +33 -53
  331. package/src/foundry/client/tours/setup-tour.d.mts +15 -10
  332. package/src/foundry/client/ui/context.d.mts +48 -40
  333. package/src/foundry/client/ui/dialog.d.mts +137 -126
  334. package/src/foundry/client/ui/drag.d.mts +1 -1
  335. package/src/foundry/client/ui/dragdrop.d.mts +34 -28
  336. package/src/foundry/client/ui/editor.d.mts +29 -21
  337. package/src/foundry/client/ui/filepicker.d.mts +43 -38
  338. package/src/foundry/client/ui/filter.d.mts +62 -50
  339. package/src/foundry/client/ui/forms.d.mts +22 -22
  340. package/src/foundry/client/ui/notifications.d.mts +10 -3
  341. package/src/foundry/client/ui/prosemirror.d.mts +15 -7
  342. package/src/foundry/client/ui/secrets.d.mts +42 -27
  343. package/src/foundry/client/ui/tabs.d.mts +40 -33
  344. package/src/foundry/client-esm/applications/_module.d.mts +3 -3
  345. package/src/foundry/client-esm/applications/_types.d.mts +0 -2
  346. package/src/foundry/client-esm/applications/api/_module.d.mts +2 -2
  347. package/src/foundry/client-esm/applications/api/application.d.mts +28 -19
  348. package/src/foundry/client-esm/applications/api/dialog.d.mts +20 -22
  349. package/src/foundry/client-esm/applications/api/document-sheet.d.mts +26 -12
  350. package/src/foundry/client-esm/applications/api/handlebars-application.d.mts +142 -126
  351. package/src/foundry/client-esm/applications/apps/_module.d.mts +2 -2
  352. package/src/foundry/client-esm/applications/apps/compendium-art-config.d.mts +10 -10
  353. package/src/foundry/client-esm/applications/apps/permission-config.d.mts +3 -3
  354. package/src/foundry/client-esm/applications/dice/_module.d.mts +2 -2
  355. package/src/foundry/client-esm/applications/dice/roll-resolver.d.mts +14 -2
  356. package/src/foundry/client-esm/applications/elements/_module.d.mts +2 -2
  357. package/src/foundry/client-esm/applications/elements/document-tags.d.mts +2 -0
  358. package/src/foundry/client-esm/applications/elements/file-picker.d.mts +1 -1
  359. package/src/foundry/client-esm/applications/elements/multi-select.d.mts +15 -5
  360. package/src/foundry/client-esm/applications/elements/string-tags.d.mts +1 -1
  361. package/src/foundry/client-esm/applications/forms/fields.d.mts +1 -1
  362. package/src/foundry/client-esm/applications/sheets/_module.d.mts +2 -2
  363. package/src/foundry/client-esm/applications/sheets/actor-sheet.d.mts +3 -3
  364. package/src/foundry/client-esm/applications/sheets/ambient-light-config.d.mts +10 -8
  365. package/src/foundry/client-esm/applications/sheets/ambient-sound-config.d.mts +9 -7
  366. package/src/foundry/client-esm/applications/sheets/item-sheet.d.mts +3 -3
  367. package/src/foundry/client-esm/applications/sheets/region-behavior-config.d.mts +30 -5
  368. package/src/foundry/client-esm/applications/sheets/region-config.d.mts +36 -5
  369. package/src/foundry/client-esm/applications/sheets/user-config.d.mts +8 -7
  370. package/src/foundry/client-esm/applications/ui/_module.d.mts +2 -2
  371. package/src/foundry/client-esm/applications/ui/region-legend.d.mts +45 -3
  372. package/src/foundry/client-esm/audio/_module.d.mts +2 -3
  373. package/src/foundry/client-esm/audio/_types.d.mts +2 -0
  374. package/src/foundry/client-esm/audio/biquad.d.mts +76 -26
  375. package/src/foundry/client-esm/audio/cache.d.mts +31 -20
  376. package/src/foundry/client-esm/audio/convolver.d.mts +47 -25
  377. package/src/foundry/client-esm/audio/helper.d.mts +124 -80
  378. package/src/foundry/client-esm/audio/sound.d.mts +230 -126
  379. package/src/foundry/client-esm/audio/timeout.d.mts +28 -12
  380. package/src/foundry/client-esm/canvas/_module.d.mts +2 -2
  381. package/src/foundry/client-esm/canvas/edges/_module.d.mts +2 -2
  382. package/src/foundry/client-esm/canvas/edges/collision.d.mts +69 -18
  383. package/src/foundry/client-esm/canvas/edges/edge.d.mts +110 -41
  384. package/src/foundry/client-esm/canvas/edges/edges.d.mts +10 -0
  385. package/src/foundry/client-esm/canvas/edges/vertex.d.mts +56 -26
  386. package/src/foundry/client-esm/canvas/regions/_module.d.mts +6 -11
  387. package/src/foundry/client-esm/canvas/regions/geometry.d.mts +38 -0
  388. package/src/foundry/client-esm/canvas/regions/mesh.d.mts +72 -0
  389. package/src/foundry/client-esm/canvas/regions/polygon-tree.d.mts +130 -0
  390. package/src/foundry/client-esm/canvas/regions/shape.d.mts +129 -0
  391. package/src/foundry/client-esm/canvas/scene-manager.d.mts +13 -3
  392. package/src/foundry/client-esm/canvas/smaa/blend.d.mts +14 -3
  393. package/src/foundry/client-esm/canvas/smaa/edges.d.mts +25 -3
  394. package/src/foundry/client-esm/canvas/smaa/smaa.d.mts +121 -23
  395. package/src/foundry/client-esm/canvas/smaa/weights.d.mts +26 -3
  396. package/src/foundry/client-esm/canvas/sources/_module.d.mts +2 -2
  397. package/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts +84 -40
  398. package/src/foundry/client-esm/canvas/sources/base-light-source.d.mts +103 -39
  399. package/src/foundry/client-esm/canvas/sources/global-light-source.d.mts +89 -15
  400. package/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts +71 -27
  401. package/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts +49 -20
  402. package/src/foundry/client-esm/canvas/sources/point-light-source.d.mts +57 -16
  403. package/src/foundry/client-esm/canvas/sources/point-movement-source.d.mts +31 -4
  404. package/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts +45 -12
  405. package/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts +98 -52
  406. package/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts +180 -69
  407. package/src/foundry/client-esm/canvas/tokens/_module.d.mts +2 -3
  408. package/src/foundry/client-esm/canvas/tokens/ring-config.d.mts +175 -2
  409. package/src/foundry/client-esm/canvas/tokens/ring-data.d.mts +142 -2
  410. package/src/foundry/client-esm/canvas/tokens/ring.d.mts +284 -2
  411. package/src/foundry/client-esm/client.d.mts +47 -54
  412. package/src/foundry/client-esm/data/_module.d.mts +2 -2
  413. package/src/foundry/client-esm/data/client-backend.d.mts +22 -23
  414. package/src/foundry/client-esm/data/region-behaviors/_module.d.mts +11 -14
  415. package/src/foundry/client-esm/data/region-behaviors/adjust-darkness-level.d.mts +56 -0
  416. package/src/foundry/client-esm/data/region-behaviors/base.d.mts +59 -0
  417. package/src/foundry/client-esm/data/region-behaviors/display-scrolling-text.d.mts +64 -0
  418. package/src/foundry/client-esm/data/region-behaviors/execute-macro.d.mts +27 -0
  419. package/src/foundry/client-esm/data/region-behaviors/execute-script.d.mts +23 -0
  420. package/src/foundry/client-esm/data/region-behaviors/pause-game.d.mts +23 -0
  421. package/src/foundry/client-esm/data/region-behaviors/suppress-weather.d.mts +17 -0
  422. package/src/foundry/client-esm/data/region-behaviors/teleport-token.d.mts +32 -0
  423. package/src/foundry/client-esm/data/region-behaviors/toggle-behavior.d.mts +31 -0
  424. package/src/foundry/client-esm/dice/_module.d.mts +2 -3
  425. package/src/foundry/client-esm/dice/parser.d.mts +11 -25
  426. package/src/foundry/client-esm/dice/roll.d.mts +112 -89
  427. package/src/foundry/client-esm/dice/terms/_module.d.mts +2 -3
  428. package/src/foundry/client-esm/dice/terms/coin.d.mts +8 -5
  429. package/src/foundry/client-esm/dice/terms/dice.d.mts +93 -63
  430. package/src/foundry/client-esm/dice/terms/die.d.mts +11 -4
  431. package/src/foundry/client-esm/dice/terms/fate.d.mts +9 -2
  432. package/src/foundry/client-esm/dice/terms/function.d.mts +18 -18
  433. package/src/foundry/client-esm/dice/terms/numeric.d.mts +3 -5
  434. package/src/foundry/client-esm/dice/terms/operator.d.mts +2 -2
  435. package/src/foundry/client-esm/dice/terms/parenthetical.d.mts +9 -10
  436. package/src/foundry/client-esm/dice/terms/pool.d.mts +25 -31
  437. package/src/foundry/client-esm/dice/terms/string.d.mts +4 -4
  438. package/src/foundry/client-esm/dice/terms/term.d.mts +18 -4
  439. package/src/foundry/client-esm/dice/twister.d.mts +3 -3
  440. package/src/foundry/client-esm/helpers/_module.d.mts +2 -2
  441. package/src/foundry/client-esm/helpers/_types.d.mts +12 -46
  442. package/src/foundry/client-esm/helpers/compendium-art.d.mts +56 -4
  443. package/src/foundry/common/abstract/_types.d.mts +60 -54
  444. package/src/foundry/common/abstract/backend.d.mts +51 -45
  445. package/src/foundry/common/abstract/data.d.mts +265 -236
  446. package/src/foundry/common/abstract/document.d.mts +1449 -464
  447. package/src/foundry/common/abstract/embedded-collection-delta.d.mts +1 -1
  448. package/src/foundry/common/abstract/embedded-collection.d.mts +37 -7
  449. package/src/foundry/common/abstract/module.d.mts +3 -2
  450. package/src/foundry/common/abstract/singleton-collection.d.mts +1 -1
  451. package/src/foundry/common/abstract/socket.d.mts +1 -1
  452. package/src/foundry/common/abstract/type-data.d.mts +61 -55
  453. package/src/foundry/common/config.d.mts +11 -3
  454. package/src/foundry/common/constants.d.mts +261 -231
  455. package/src/foundry/common/data/data.d.mts +238 -102
  456. package/src/foundry/common/data/fields.d.mts +1334 -874
  457. package/src/foundry/common/data/module.d.mts +2 -2
  458. package/src/foundry/common/data/validation-failure.d.mts +12 -9
  459. package/src/foundry/common/documents/_module.d.mts +4 -2
  460. package/src/foundry/common/documents/_types.d.mts +22 -56
  461. package/src/foundry/common/documents/active-effect.d.mts +358 -194
  462. package/src/foundry/common/documents/actor-delta.d.mts +403 -73
  463. package/src/foundry/common/documents/actor.d.mts +359 -117
  464. package/src/foundry/common/documents/adventure.d.mts +312 -142
  465. package/src/foundry/common/documents/ambient-light.d.mts +296 -75
  466. package/src/foundry/common/documents/ambient-sound.d.mts +296 -109
  467. package/src/foundry/common/documents/card.d.mts +321 -187
  468. package/src/foundry/common/documents/cards.d.mts +353 -125
  469. package/src/foundry/common/documents/chat-message.d.mts +338 -167
  470. package/src/foundry/common/documents/combat.d.mts +358 -94
  471. package/src/foundry/common/documents/combatant.d.mts +323 -92
  472. package/src/foundry/common/documents/drawing.d.mts +327 -206
  473. package/src/foundry/common/documents/fog-exploration.d.mts +303 -69
  474. package/src/foundry/common/documents/folder.d.mts +307 -82
  475. package/src/foundry/common/documents/item.d.mts +377 -100
  476. package/src/foundry/common/documents/journal-entry-page.d.mts +327 -187
  477. package/src/foundry/common/documents/journal-entry.d.mts +345 -68
  478. package/src/foundry/common/documents/macro.d.mts +325 -139
  479. package/src/foundry/common/documents/measured-template.d.mts +328 -138
  480. package/src/foundry/common/documents/note.d.mts +312 -151
  481. package/src/foundry/common/documents/playlist-sound.d.mts +309 -102
  482. package/src/foundry/common/documents/playlist.d.mts +341 -131
  483. package/src/foundry/common/documents/region-behavior.d.mts +360 -0
  484. package/src/foundry/common/documents/region.d.mts +355 -0
  485. package/src/foundry/common/documents/roll-table.d.mts +320 -102
  486. package/src/foundry/common/documents/scene.d.mts +437 -350
  487. package/src/foundry/common/documents/setting.d.mts +285 -54
  488. package/src/foundry/common/documents/table-result.d.mts +326 -103
  489. package/src/foundry/common/documents/tile.d.mts +337 -172
  490. package/src/foundry/common/documents/token.d.mts +396 -447
  491. package/src/foundry/common/documents/user.d.mts +296 -173
  492. package/src/foundry/common/documents/wall.d.mts +303 -156
  493. package/src/foundry/common/grid/_module.d.mts +3 -3
  494. package/src/foundry/common/grid/base.d.mts +66 -49
  495. package/src/foundry/common/grid/gridless.d.mts +2 -2
  496. package/src/foundry/common/grid/hexagonal.d.mts +35 -28
  497. package/src/foundry/common/grid/square.d.mts +3 -3
  498. package/src/foundry/common/packages/base-module.d.mts +6 -24
  499. package/src/foundry/common/packages/base-package.d.mts +56 -31
  500. package/src/foundry/common/packages/base-system.d.mts +45 -63
  501. package/src/foundry/common/packages/base-world.d.mts +15 -61
  502. package/src/foundry/common/packages/module.d.mts +7 -7
  503. package/src/foundry/common/packages/sub-types.d.mts +4 -6
  504. package/src/foundry/common/primitives/array.d.mts +4 -4
  505. package/src/foundry/common/primitives/math.d.mts +7 -1
  506. package/src/foundry/common/primitives/number.d.mts +2 -2
  507. package/src/foundry/common/primitives/set.d.mts +17 -14
  508. package/src/foundry/common/primitives/string.d.mts +1 -1
  509. package/src/foundry/common/prosemirror/_module.d.mts +15 -15
  510. package/src/foundry/common/prosemirror/dirty-plugin.d.mts +1 -1
  511. package/src/foundry/common/prosemirror/dom-parser.d.mts +2 -1
  512. package/src/foundry/common/prosemirror/dropdown.d.mts +1 -1
  513. package/src/foundry/common/prosemirror/highlight-matches-plugin.d.mts +2 -2
  514. package/src/foundry/common/prosemirror/image-plugin.d.mts +1 -1
  515. package/src/foundry/common/prosemirror/menu.d.mts +3 -3
  516. package/src/foundry/common/prosemirror/paste-transformer.d.mts +1 -1
  517. package/src/foundry/common/prosemirror/plugin.d.mts +2 -2
  518. package/src/foundry/common/prosemirror/schema/index.d.mts +0 -1
  519. package/src/foundry/common/prosemirror/schema/lists.d.mts +2 -0
  520. package/src/foundry/common/prosemirror/util.d.mts +1 -1
  521. package/src/foundry/common/types.d.mts +3 -3
  522. package/src/foundry/common/utils/bitmask.d.mts +23 -11
  523. package/src/foundry/common/utils/collection.d.mts +61 -38
  524. package/src/foundry/common/utils/color.d.mts +20 -2
  525. package/src/foundry/common/utils/event-emitter.d.mts +32 -17
  526. package/src/foundry/common/utils/helpers.d.mts +36 -26
  527. package/src/foundry/common/utils/http.d.mts +2 -2
  528. package/src/foundry/common/utils/module.d.mts +2 -2
  529. package/src/foundry/common/utils/string-tree.d.mts +45 -39
  530. package/src/foundry/common/utils/word-tree.d.mts +10 -23
  531. package/src/foundry/index.d.mts +0 -1
  532. package/src/foundry/{clipper → public/scripts/clipper}/clipper.d.mts +58 -16
  533. package/src/foundry/public/scripts/index.d.mts +1 -0
  534. package/src/foundry/public/scripts/workers/image-compressor.d.mts +23 -0
  535. package/src/foundry/public/scripts/workers/index.d.mts +1 -0
  536. package/{index-lenient.d.mts → src/index-lenient.d.mts} +2 -0
  537. package/src/index.d.mts +6 -0
  538. package/src/tsconfig.json +15 -0
  539. package/src/types/augments/particles.d.mts +29 -0
  540. package/src/types/augments/pixi.d.mts +1024 -21
  541. package/src/types/augments/smooth.d.mts +31 -0
  542. package/src/types/augments/tinyMCE.d.mts +1 -1
  543. package/src/types/config.d.mts +18 -313
  544. package/src/types/documentConfiguration.d.mts +286 -542
  545. package/src/types/index.d.mts +1 -1
  546. package/src/types/lib.d.mts +12 -0
  547. package/src/types/workers/image-compressor.d.mts +176 -0
  548. package/src/utils/index.d.mts +1279 -0
  549. package/tsconfig.json +29 -0
  550. package/tsconfig.main.json +8 -0
  551. package/tsconfig.miscellaneous.json +16 -0
  552. package/index.d.mts +0 -5
  553. package/src/foundry/client/apps/placeables/light-config.d.mts +0 -100
  554. package/src/foundry/client/apps/placeables/sound-config.d.mts +0 -43
  555. package/src/foundry/common/documents/module.d.mts +0 -35
  556. package/src/foundry/common/primitives/regex.d.mts +0 -12
  557. package/src/types/helperTypes.d.mts +0 -583
  558. package/src/types/utils.d.mts +0 -539
  559. /package/src/foundry/{clipper → public/scripts/clipper}/index.d.mts +0 -0
@@ -1,68 +1,994 @@
1
- import type { DeepPartial, InexactPartial } from "../../../../types/utils.d.mts";
1
+ import type DataModel from "#common/abstract/data.mjs";
2
+ import type { AnyArray, AnyObject, InexactPartial, InterfaceToObject, Merge, NullishProps } from "#utils";
3
+ import type { documents } from "../../../client-esm/client.d.mts";
2
4
  import type Document from "../../../common/abstract/document.d.mts";
3
- import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts";
4
- import type { SchemaField } from "../../../common/data/fields.d.mts";
5
+ import type { DataSchema, SchemaField } from "../../../common/data/fields.d.mts";
6
+ import type { fields, LightData, TextureData } from "../../../common/data/module.d.mts";
7
+ import type { ActorDeltaField } from "../../../common/documents/token.d.mts";
5
8
  import type BaseToken from "../../../common/documents/token.d.mts";
6
9
 
7
10
  declare global {
8
11
  namespace TokenDocument {
9
- type Metadata = Document.MetadataFor<TokenDocument>;
12
+ /**
13
+ * The document's name.
14
+ */
15
+ type Name = "Token";
16
+
17
+ /**
18
+ * The arguments to construct the document.
19
+ */
20
+ type ConstructorArgs = Document.ConstructorParameters<CreateData, Parent>;
21
+
22
+ /**
23
+ * The documents embedded within `TokenDocument`.
24
+ */
25
+ type Hierarchy = Readonly<Document.HierarchyOf<Schema>>;
26
+
27
+ /**
28
+ * The implementation of the `TokenDocument` document instance configured through `CONFIG.Token.documentClass` in Foundry and
29
+ * {@link DocumentClassConfig | `DocumentClassConfig`} or {@link ConfiguredTokenDocument | `fvtt-types/configuration/ConfiguredTokenDocument`} in fvtt-types.
30
+ */
31
+ type Implementation = Document.ImplementationFor<Name>;
32
+
33
+ /**
34
+ * The implementation of the `TokenDocument` document configured through `CONFIG.Token.documentClass` in Foundry and
35
+ * {@link DocumentClassConfig | `DocumentClassConfig`} in fvtt-types.
36
+ */
37
+ type ImplementationClass = Document.ImplementationClassFor<Name>;
38
+
39
+ /**
40
+ * A document's metadata is special information about the document ranging anywhere from its name,
41
+ * whether it's indexed, or to the permissions a user has over it.
42
+ */
43
+ interface Metadata
44
+ extends Merge<
45
+ Document.Metadata.Default,
46
+ Readonly<{
47
+ name: "Token";
48
+ collection: "tokens";
49
+ label: string;
50
+ labelPlural: string;
51
+ isEmbedded: true;
52
+ embedded: TokenDocument.Metadata.Embedded;
53
+ permissions: TokenDocument.Metadata.Permissions;
54
+ schemaVersion: string;
55
+ }>
56
+ > {}
57
+
58
+ namespace Metadata {
59
+ /**
60
+ * The embedded metadata
61
+ */
62
+ interface Embedded {
63
+ ActorDelta: "delta";
64
+ }
65
+
66
+ /**
67
+ * The permissions for whether a certain user can create, update, or delete this document.
68
+ */
69
+ interface Permissions {
70
+ create: "TOKEN_CREATE";
71
+ update(
72
+ user: User.Internal.Implementation,
73
+ doc: TokenDocument.Implementation,
74
+ data: BaseToken.UpdateData,
75
+ ): boolean;
76
+ delete: "TOKEN_DELETE";
77
+ }
78
+ }
79
+
80
+ /**
81
+ * A document's parent is something that can contain it.
82
+ * For example an `Item` can be contained by an `Actor` which makes `Actor` one of its possible parents.
83
+ */
84
+ type Parent = Scene.Implementation | null;
85
+
86
+ /**
87
+ * A document's direct descendants are documents that are contained directly within its schema.
88
+ * This is a union of all such instances, or never if the document doesn't have any descendants.
89
+ */
90
+ type DirectDescendant = ActorDelta.Stored;
91
+
92
+ /**
93
+ * A document's direct descendants are documents that are contained directly within its schema.
94
+ * This is a union of all such classes, or never if the document doesn't have any descendants.
95
+ */
96
+ type DirectDescendantClass = ActorDelta.ImplementationClass;
97
+
98
+ /**
99
+ * A document's descendants are any documents that are contained within, either within its schema
100
+ * or its descendant's schemas.
101
+ * This is a union of all such instances, or never if the document doesn't have any descendants.
102
+ */
103
+ type Descendant = DirectDescendant | ActorDelta.Descendant;
104
+
105
+ /**
106
+ * A document's descendants are any child documents, grandchild documents, etc.
107
+ * This is a union of all classes, or never if the document doesn't have any descendants.
108
+ */
109
+ type DescendantClass = DirectDescendantClass | ActorDelta.DescendantClass;
110
+
111
+ /**
112
+ * Types of `CompendiumCollection` this document might be contained in.
113
+ * Note that `this.pack` will always return a string; this is the type for `game.packs.get(this.pack)`
114
+ */
115
+ type Pack = CompendiumCollection.ForDocument<"Token">;
116
+
117
+ /**
118
+ * An embedded document is a document contained in another.
119
+ * For example an `Item` can be contained by an `Actor` which means `Item` can be embedded in `Actor`.
120
+ *
121
+ * If this is `never` it is because there are no embeddable documents (or there's a bug!).
122
+ */
123
+ type Embedded = Document.ImplementationFor<Embedded.Name>;
124
+
125
+ namespace Embedded {
126
+ /**
127
+ * An embedded document is a document contained in another.
128
+ * For example an `Item` can be contained by an `Actor` which means `Item` can be embedded in `Actor`.
129
+ *
130
+ * If this is `never` it is because there are no embeddable documents (or there's a bug!).
131
+ */
132
+ type Name = keyof Metadata.Embedded;
133
+
134
+ /**
135
+ * Gets the collection name for an embedded document.
136
+ */
137
+ type CollectionNameOf<CollectionName extends Embedded.CollectionName> = Document.Embedded.CollectionNameFor<
138
+ Metadata.Embedded,
139
+ CollectionName
140
+ >;
141
+
142
+ /**
143
+ * Gets the collection document for an embedded document.
144
+ */
145
+ // TODO(LukeAbby): There's a circularity. Should be `Document.Embedded.CollectionDocumentFor<Metadata.Embedded, CollectionName>`
146
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
147
+ type DocumentFor<CollectionName extends Embedded.CollectionName> = Document.Any;
148
+
149
+ /**
150
+ * Gets the collection for an embedded document.
151
+ */
152
+ type CollectionFor<CollectionName extends Embedded.CollectionName> = Document.Embedded.CollectionFor<
153
+ // TODO(LukeAbby): This should be `TokenDocument.Implementation` but this causes a circularity.
154
+ Document.Any,
155
+ Metadata.Embedded,
156
+ CollectionName
157
+ >;
158
+
159
+ /**
160
+ * A valid name to refer to a collection embedded in this document. For example an `Actor`
161
+ * has the key `"items"` which contains `Item` instance which would make both `"Item" | "Items"`
162
+ * valid keys (amongst others).
163
+ */
164
+ type CollectionName = Document.Embedded.CollectionName<Metadata.Embedded>;
165
+ }
166
+
167
+ /**
168
+ * The name of the world or embedded collection this document can find itself in.
169
+ * For example an `Item` is always going to be inside a collection with a key of `items`.
170
+ * This is a fixed string per document type and is primarily useful for {@link ClientDocumentMixin | `Descendant Document Events`}.
171
+ */
172
+ type ParentCollectionName = Metadata["collection"];
173
+
174
+ /**
175
+ * The world collection that contains this document type. Will be `never` if none exists.
176
+ */
177
+ type CollectionClass = never;
178
+
179
+ /**
180
+ * The world collection that contains this document type. Will be `never` if none exists.
181
+ */
182
+ type Collection = never;
183
+
184
+ /**
185
+ * An instance of `TokenDocument` that comes from the database but failed validation meaning that
186
+ * its `system` and `_source` could theoretically be anything.
187
+ */
188
+ interface Invalid extends Document.Invalid<TokenDocument.Implementation> {}
189
+
190
+ /**
191
+ * An instance of `TokenDocument` that comes from the database.
192
+ */
193
+ interface Stored extends Document.Stored<TokenDocument.Implementation> {}
194
+
195
+ /**
196
+ * The data put in {@link TokenDocument._source | `TokenDocument#_source`}. This data is what was
197
+ * persisted to the database and therefore it must be valid JSON.
198
+ *
199
+ * For example a {@link fields.SetField | `SetField`} is persisted to the database as an array
200
+ * but initialized as a {@link Set | `Set`}.
201
+ */
202
+ interface Source extends fields.SchemaField.SourceData<Schema> {}
203
+
204
+ /**
205
+ * @deprecated {@link TokenDocument.Source | `TokenDocument.Source`}
206
+ */
207
+ type PersistedData = Source;
208
+
209
+ /**
210
+ * The data necessary to create a document. Used in places like {@link TokenDocument.create | `TokenDocument.create`}
211
+ * and {@link TokenDocument | `new TokenDocument(...)`}.
212
+ *
213
+ * For example a {@link fields.SetField | `SetField`} can accept any {@link Iterable | `Iterable`}
214
+ * with the right values. This means you can pass a `Set` instance, an array of values,
215
+ * a generator, or any other iterable.
216
+ */
217
+ interface CreateData extends fields.SchemaField.CreateData<Schema> {}
218
+
219
+ /**
220
+ * The data after a {@link foundry.abstract.Document | `Document`} has been initialized, for example
221
+ * {@link TokenDocument.name | `TokenDocument#name`}.
222
+ *
223
+ * This is data transformed from {@link TokenDocument.Source | `TokenDocument.Source`} and turned into more
224
+ * convenient runtime data structures. For example a {@link fields.SetField | `SetField`} is
225
+ * persisted to the database as an array of values but at runtime it is a `Set` instance.
226
+ */
227
+ interface InitializedData extends fields.SchemaField.InitializedData<Schema> {}
228
+
229
+ /**
230
+ * The data used to update a document, for example {@link TokenDocument.update | `TokenDocument#update`}.
231
+ * It is a distinct type from {@link TokenDocument.CreateData | `DeepPartial<TokenDocument.CreateData>`} because
232
+ * it has different rules for `null` and `undefined`.
233
+ */
234
+ interface UpdateData extends fields.SchemaField.UpdateData<Schema> {}
10
235
 
11
- type ConfiguredClass = Document.ConfiguredClassForName<"Token">;
12
- type ConfiguredInstance = Document.ConfiguredInstanceForName<"Token">;
236
+ /**
237
+ * Schema definition shared by {@link foundry.data.PrototypeToken | `PrototypeToken`}.
238
+ * Foundry technically implements this through deletion, but it's easier for us to do by extension as there are field
239
+ * option overrides (e.g `textSearch` on `name`) that cause type issues otherwise.
240
+ */
241
+ interface SharedProtoSchema extends DataSchema {
242
+ // `name` omitted here because, while it is not in the list of omitted fields for `PrototypeToken`, it's `textSearch: true` in the base schema, but overridden to `false` in `PrototypeToken`
13
243
 
14
- type ObjectClass = Document.ConfiguredObjectClassForName<"Token">;
15
- type ObjectInstance = Document.ConfiguredObjectInstanceForName<"Token">;
244
+ /**
245
+ * The display mode of the Token nameplate, from CONST.TOKEN_DISPLAY_MODES
246
+ * @defaultValue `CONST.TOKEN_DISPLAY_MODES.NONE`
247
+ */
248
+ displayName: fields.NumberField<
249
+ {
250
+ required: true;
251
+ initial: typeof CONST.TOKEN_DISPLAY_MODES.NONE;
252
+ choices: CONST.TOKEN_DISPLAY_MODES[];
253
+ validationError: "must be a value in CONST.TOKEN_DISPLAY_MODES";
254
+ },
255
+ // FIXME: Without these overrides, the branded type from `choices` is not respected, and the field types as `number`
256
+ CONST.TOKEN_DISPLAY_MODES | null | undefined,
257
+ CONST.TOKEN_DISPLAY_MODES,
258
+ CONST.TOKEN_DISPLAY_MODES
259
+ >;
16
260
 
17
- /* eslint-disable @typescript-eslint/no-empty-object-type */
18
- interface DatabaseOperations
19
- extends DocumentDatabaseOperations<
20
- TokenDocument,
21
- {},
261
+ /**
262
+ * Does this Token uniquely represent a singular Actor, or is it one of many?
263
+ * @defaultValue `false`
264
+ */
265
+ actorLink: fields.BooleanField;
266
+
267
+ appendNumber: fields.BooleanField;
268
+
269
+ prependAdjective: fields.BooleanField;
270
+
271
+ /**
272
+ * The width of the Token in grid units
273
+ * @defaultValue `1`
274
+ */
275
+ width: fields.NumberField<{ nullable: false; positive: true; initial: 1; step: 0.5; label: "Width" }>;
276
+
277
+ /**
278
+ * The height of the Token in grid units
279
+ * @defaultValue `1`
280
+ */
281
+ height: fields.NumberField<{ nullable: false; positive: true; initial: 1; step: 0.5; label: "Height" }>;
282
+
283
+ /**
284
+ * The token's texture on the canvas.
285
+ */
286
+ texture: TextureData<{
287
+ initial: {
288
+ src: () => typeof BaseToken.DEFAULT_ICON;
289
+ anchorX: 0.5;
290
+ anchorY: 0.5;
291
+ fit: "contain";
292
+ alphaThreshold: 0.75;
293
+ };
294
+ wildcard: true;
295
+ }>;
296
+
297
+ /**
298
+ * @defaultValue `CONST.TOKEN_HEXAGONAL_SHAPES.ELLIPSE_1`
299
+ */
300
+ hexagonalShape: fields.NumberField<
22
301
  {
23
- previousActorId: string | null;
24
- animate: boolean;
25
- _priorRegions: Record<string, string[]>;
26
- _priorPosition: Record<string, { x: number; y: number; elevation: number }>;
27
- teleport: boolean;
28
- forced: boolean;
302
+ initial: typeof CONST.TOKEN_HEXAGONAL_SHAPES.ELLIPSE_1;
303
+ choices: CONST.TOKEN_HEXAGONAL_SHAPES[];
29
304
  },
30
- {}
31
- > {}
32
- /* eslint-enable @typescript-eslint/no-empty-object-type */
305
+ // FIXME: Without these overrides, the branded type from `choices` is not respected, and the field types as `number`
306
+ CONST.TOKEN_HEXAGONAL_SHAPES | null | undefined,
307
+ CONST.TOKEN_HEXAGONAL_SHAPES,
308
+ CONST.TOKEN_HEXAGONAL_SHAPES
309
+ >;
310
+
311
+ /**
312
+ * Prevent the Token image from visually rotating?
313
+ * @defaultValue `false`
314
+ */
315
+ lockRotation: fields.BooleanField;
316
+
317
+ /**
318
+ * The rotation of the Token in degrees, from 0 to 360. A value of 0 represents a southward-facing Token.
319
+ * @defaultValue `0`
320
+ */
321
+ rotation: fields.AngleField;
322
+
323
+ /**
324
+ * The opacity of the token image
325
+ * @defaultValue `1`
326
+ */
327
+ alpha: fields.AlphaField;
328
+
329
+ /**
330
+ * A displayed Token disposition from CONST.TOKEN_DISPOSITIONS
331
+ * @defaultValue `CONST.TOKEN_DISPOSITIONS.HOSTILE` (`-1`)
332
+ */
333
+ disposition: fields.NumberField<
334
+ {
335
+ required: true;
336
+ choices: CONST.TOKEN_DISPOSITIONS[];
337
+ initial: typeof CONST.TOKEN_DISPOSITIONS.HOSTILE;
338
+ validationError: "must be a value in CONST.TOKEN_DISPOSITIONS";
339
+ },
340
+ // FIXME: Without these overrides, the branded type from `choices` is not respected, and the field types as `number`
341
+ CONST.TOKEN_DISPOSITIONS | null | undefined,
342
+ CONST.TOKEN_DISPOSITIONS,
343
+ CONST.TOKEN_DISPOSITIONS
344
+ >;
345
+
346
+ /**
347
+ * The display mode of Token resource bars, from CONST.TOKEN_DISPLAY_MODES
348
+ * @defaultValue `CONST.TOKEN_DISPLAY_MODES.NONE`
349
+ */
350
+ displayBars: fields.NumberField<
351
+ {
352
+ required: true;
353
+ choices: CONST.TOKEN_DISPLAY_MODES[];
354
+ initial: typeof CONST.TOKEN_DISPLAY_MODES.NONE;
355
+ validationError: "must be a value in CONST.TOKEN_DISPLAY_MODES";
356
+ },
357
+ // FIXME: Without these overrides, the branded type from `choices` is not respected, and the field types as `number`
358
+ CONST.TOKEN_DISPLAY_MODES | null | undefined,
359
+ CONST.TOKEN_DISPLAY_MODES,
360
+ CONST.TOKEN_DISPLAY_MODES
361
+ >;
362
+
363
+ /**
364
+ * The configuration of the Token's primary resource bar
365
+ * @defaultValue see property
366
+ */
367
+ bar1: fields.SchemaField<{
368
+ /**
369
+ * The attribute path within the Token's Actor data which should be displayed
370
+ * @defaultValue `game?.system.primaryTokenAttribute || null`
371
+ */
372
+ attribute: fields.StringField<{
373
+ required: true;
374
+ nullable: true;
375
+ blank: false;
376
+ initial: () => string | null;
377
+ }>;
378
+ }>;
379
+
380
+ /**
381
+ * The configuration of the Token's secondary resource bar
382
+ * @defaultValue see property
383
+ */
384
+ bar2: fields.SchemaField<{
385
+ /**
386
+ * The attribute path within the Token's Actor data which should be displayed
387
+ * @defaultValue `game?.system.secondaryTokenAttribute || null`
388
+ */
389
+ attribute: fields.StringField<{
390
+ required: true;
391
+ nullable: true;
392
+ blank: false;
393
+ initial: () => string | null;
394
+ }>;
395
+ }>;
396
+
397
+ /**
398
+ * Configuration of the light source that this Token emits
399
+ * @defaultValue see {@link LightData | `LightData`}
400
+ */
401
+ light: fields.EmbeddedDataField<typeof LightData>;
402
+
403
+ /**
404
+ * Configuration of sight and vision properties for the Token
405
+ * @defaultValue see properties
406
+ * @privateRemarks Foundry has this split out into its own `@typedef TokenSightData`, but it's never
407
+ * referenced outside `@typedef TokenData`, so no need for a separate interface
408
+ */
409
+ sight: fields.SchemaField<{
410
+ /**
411
+ * Should vision computation and rendering be active for this Token?
412
+ * @defaultValue `true`, when the token's sight range is greater than 0
413
+ */
414
+ enabled: fields.BooleanField<{ initial: (data: unknown) => boolean }>;
415
+
416
+ /**
417
+ * How far in distance units the Token can see without the aid of a light source
418
+ * @defaultValue `0`
419
+ */
420
+ range: fields.NumberField<{ required: true; nullable: true; min: 0; step: 0.01; initial: 0 }>;
421
+
422
+ /**
423
+ * An angle at which the Token can see relative to their direction of facing
424
+ * @defaultValue `360`
425
+ */
426
+ angle: fields.AngleField<{ initial: 360; normalize: false }>;
427
+
428
+ /**
429
+ * The vision mode which is used to render the appearance of the visible area
430
+ * @defaultValue `"basic"`
431
+ */
432
+ visionMode: fields.StringField<{
433
+ required: true;
434
+ blank: false;
435
+ initial: "basic";
436
+ label: "TOKEN.VisionMode";
437
+ hint: "TOKEN.VisionModeHint";
438
+ }>;
439
+
440
+ /**
441
+ * A special color which applies a hue to the visible area
442
+ * @defaultValue `null`
443
+ */
444
+ color: fields.ColorField<{ label: "TOKEN.VisionColor" }>;
445
+
446
+ /**
447
+ * A degree of attenuation which gradually fades the edges of the visible area
448
+ * @defaultValue `0.1`
449
+ */
450
+ attenuation: fields.AlphaField<{
451
+ initial: 0.1;
452
+ label: "TOKEN.VisionAttenuation";
453
+ hint: "TOKEN.VisionAttenuationHint";
454
+ }>;
455
+
456
+ /**
457
+ * An advanced customization for the perceived brightness of the visible area
458
+ * @defaultValue `0`
459
+ */
460
+ brightness: fields.NumberField<{
461
+ required: true;
462
+ nullable: false;
463
+ initial: 0;
464
+ min: -1;
465
+ max: 1;
466
+ label: "TOKEN.VisionBrightness";
467
+ hint: "TOKEN.VisionBrightnessHint";
468
+ }>;
469
+
470
+ /**
471
+ * An advanced customization of color saturation within the visible area
472
+ * @defaultValue `0`
473
+ */
474
+ saturation: fields.NumberField<{
475
+ required: true;
476
+ nullable: false;
477
+ initial: 0;
478
+ min: -1;
479
+ max: 1;
480
+ label: "TOKEN.VisionSaturation";
481
+ hint: "TOKEN.VisionSaturationHint";
482
+ }>;
483
+
484
+ /**
485
+ * An advanced customization for contrast within the visible area
486
+ * @defaultValue `0`
487
+ */
488
+ contrast: fields.NumberField<{
489
+ required: true;
490
+ nullable: false;
491
+ initial: 0;
492
+ min: -1;
493
+ max: 1;
494
+ label: "TOKEN.VisionContrast";
495
+ hint: "TOKEN.VisionContrastHint";
496
+ }>;
497
+ }>;
498
+
499
+ /**
500
+ * An array of detection modes which are available to this Token
501
+ * @defaultValue `[]`
502
+ * @remarks The validation function is a `BaseToken.#validateDetectionModes` reference, which throws if there's a duplicate mode ID
503
+ */
504
+ detectionModes: fields.ArrayField<
505
+ fields.SchemaField<{
506
+ /**
507
+ * The id of the detection mode, a key from CONFIG.Canvas.detectionModes
508
+ * @defaultValue `""`
509
+ */
510
+ id: fields.StringField;
511
+
512
+ /**
513
+ * Whether or not this detection mode is presently enabled
514
+ * @defaultValue `true`
515
+ */
516
+ enabled: fields.BooleanField<{ initial: true }>;
517
+
518
+ /**
519
+ * The maximum range in distance units at which this mode can detect targets
520
+ * @defaultValue `null`
521
+ */
522
+ range: fields.NumberField<{ required: true; min: 0; step: 0.01 }>;
523
+ }>,
524
+ {
525
+ validate: () => void;
526
+ }
527
+ >;
528
+
529
+ /**
530
+ * @defaultValue see properties
531
+ */
532
+ occludable: fields.SchemaField<{
533
+ /**
534
+ * @defaultValue `0`
535
+ */
536
+ radius: fields.NumberField<{ nullable: false; min: 0; step: 0.01; initial: 0 }>;
537
+ }>;
538
+
539
+ /**
540
+ * @defaultValue see properties
541
+ */
542
+ ring: fields.SchemaField<{
543
+ /**
544
+ * @defaultValue `false`
545
+ */
546
+ enabled: fields.BooleanField;
547
+
548
+ /**
549
+ * @defaultValue see properties
550
+ */
551
+ colors: fields.SchemaField<{
552
+ /**
553
+ * @defaultValue `null`
554
+ */
555
+ ring: fields.ColorField;
556
+
557
+ /**
558
+ * @defaultValue `null`
559
+ */
560
+ background: fields.ColorField;
561
+ }>;
562
+
563
+ /**
564
+ * @defaultValue `1`
565
+ */
566
+ effects: fields.NumberField<{ initial: 1; min: 0; max: 0x7fffff; integer: true }>;
567
+
568
+ /**
569
+ * @defaultValue see properties
570
+ */
571
+ subject: fields.SchemaField<{
572
+ /**
573
+ * @defaultValue `1`
574
+ */
575
+ scale: fields.NumberField<{ initial: 1; min: 0.5 }>;
576
+
577
+ /**
578
+ * @defaultValue `null`
579
+ */
580
+ texture: fields.FilePathField<{ categories: ["IMAGE"] }>;
581
+ }>;
582
+ }>;
583
+
584
+ /**
585
+ * @remarks Foundry marked `@internal`
586
+ */
587
+ _regions: fields.ArrayField<fields.ForeignDocumentField<typeof documents.BaseRegion, { idOnly: true }>>;
588
+
589
+ /**
590
+ * An object of optional key/value flags
591
+ * @defaultValue `{}`
592
+ */
593
+ flags: fields.ObjectField.FlagsField<Name, InterfaceToObject<CoreFlags>>;
594
+ }
595
+
596
+ /**
597
+ * The schema for {@link TokenDocument | `TokenDocument`}. This is the source of truth for how an TokenDocument document
598
+ * must be structured.
599
+ *
600
+ * Foundry uses this schema to validate the structure of the {@link TokenDocument | `TokenDocument`}. For example
601
+ * a {@link fields.StringField | `StringField`} will enforce that the value is a string. More
602
+ * complex fields like {@link fields.SetField | `SetField`} goes through various conversions
603
+ * starting as an array in the database, initialized as a set, and allows updates with any
604
+ * iterable.
605
+ */
606
+ interface Schema extends SharedProtoSchema {
607
+ /**
608
+ * The Token _id which uniquely identifies it within its parent Scene
609
+ * @defaultValue `null`
610
+ */
611
+ _id: fields.DocumentIdField;
612
+
613
+ /**
614
+ * The name used to describe the Token
615
+ * @defaultValue `""`
616
+ */
617
+ name: fields.StringField<{ required: true; blank: true; textSearch: true }>;
618
+
619
+ /**
620
+ * The _id of an Actor document which this Token represents
621
+ * @defaultValue `null`
622
+ */
623
+ actorId: fields.ForeignDocumentField<typeof documents.BaseActor, { idOnly: true }>;
624
+
625
+ /**
626
+ * The ActorDelta embedded document which stores the differences between this
627
+ * token and the base actor it represents.
628
+ */
629
+ delta: ActorDeltaField<typeof documents.BaseActor>;
630
+
631
+ /**
632
+ * The x-coordinate of the top-left corner of the Token
633
+ * @defaultValue `0`
634
+ */
635
+ x: fields.NumberField<{ required: true; integer: true; nullable: false; initial: 0; label: "XCoord" }>;
636
+
637
+ /**
638
+ * The y-coordinate of the top-left corner of the Token
639
+ * @defaultValue `0`
640
+ */
641
+ y: fields.NumberField<{ required: true; integer: true; nullable: false; initial: 0; label: "YCoord" }>;
642
+
643
+ /**
644
+ * The vertical elevation of the Token, in distance units
645
+ * @defaultValue `0`
646
+ */
647
+ elevation: fields.NumberField<{ required: true; nullable: false; initial: 0 }>;
648
+
649
+ /**
650
+ * Is the Token currently locked? A locked token cannot be moved or rotated via
651
+ * standard keyboard or mouse interaction.
652
+ * @defaultValue `false`
653
+ */
654
+ locked: fields.BooleanField;
655
+
656
+ /**
657
+ * The z-index of this token relative to other siblings
658
+ * @defaultValue `0`
659
+ */
660
+ sort: fields.NumberField<{ required: true; integer: true; nullable: false; initial: 0 }>;
661
+
662
+ /**
663
+ * Is the Token currently hidden from player view?
664
+ * @defaultValue `false`
665
+ */
666
+ hidden: fields.BooleanField;
667
+ }
668
+
669
+ namespace Database {
670
+ /** Options passed along in Get operations for TokenDocuments */
671
+ interface Get extends foundry.abstract.types.DatabaseGetOperation<TokenDocument.Parent> {}
672
+
673
+ /** Options passed along in Create operations for TokenDocuments */
674
+ interface Create<Temporary extends boolean | undefined = boolean | undefined>
675
+ extends foundry.abstract.types.DatabaseCreateOperation<
676
+ TokenDocument.CreateData,
677
+ TokenDocument.Parent,
678
+ Temporary
679
+ > {}
680
+
681
+ /** Options passed along in Delete operations for TokenDocuments */
682
+ interface Delete extends foundry.abstract.types.DatabaseDeleteOperation<TokenDocument.Parent> {}
683
+
684
+ /** Options passed along in Update operations for TokenDocuments */
685
+ interface Update
686
+ extends foundry.abstract.types.DatabaseUpdateOperation<TokenDocument.UpdateData, TokenDocument.Parent> {
687
+ previousActorId?: string | null;
688
+ animate?: boolean;
689
+ _priorRegions?: Record<string, string[]>;
690
+ _priorPosition?: Record<string, { x: number; y: number; elevation: number }>;
691
+ teleport?: boolean;
692
+ forced?: boolean;
693
+ // TODO: Type this accurately when going over the Token placeable
694
+ animation: AnyObject;
695
+ }
696
+
697
+ /** Operation for {@link TokenDocument.createDocuments | `TokenDocument.createDocuments`} */
698
+ interface CreateDocumentsOperation<Temporary extends boolean | undefined>
699
+ extends Document.Database.CreateOperation<TokenDocument.Database.Create<Temporary>> {}
700
+
701
+ /** Operation for {@link TokenDocument.updateDocuments | `TokenDocument.updateDocuments`} */
702
+ interface UpdateDocumentsOperation
703
+ extends Document.Database.UpdateDocumentsOperation<TokenDocument.Database.Update> {}
704
+
705
+ /** Operation for {@link TokenDocument.deleteDocuments | `TokenDocument.deleteDocuments`} */
706
+ interface DeleteDocumentsOperation
707
+ extends Document.Database.DeleteDocumentsOperation<TokenDocument.Database.Delete> {}
708
+
709
+ /** Operation for {@link TokenDocument.create | `TokenDocument.create`} */
710
+ interface CreateOperation<Temporary extends boolean | undefined>
711
+ extends Document.Database.CreateOperation<TokenDocument.Database.Create<Temporary>> {}
712
+
713
+ /** Operation for {@link TokenDocument.update | `TokenDocument#update`} */
714
+ interface UpdateOperation extends Document.Database.UpdateOperation<Update> {}
715
+
716
+ interface DeleteOperation extends Document.Database.DeleteOperation<Delete> {}
717
+
718
+ /** Options for {@link TokenDocument.get | `TokenDocument.get`} */
719
+ interface GetOptions extends Document.Database.GetOptions {}
720
+
721
+ /** Options for {@link TokenDocument._preCreate | `TokenDocument#_preCreate`} */
722
+ interface PreCreateOptions extends Document.Database.PreCreateOptions<Create> {}
723
+
724
+ /** Options for {@link TokenDocument._onCreate | `TokenDocument#_onCreate`} */
725
+ interface OnCreateOptions extends Document.Database.CreateOptions<Create> {}
726
+
727
+ /** Operation for {@link TokenDocument._preCreateOperation | `TokenDocument._preCreateOperation`} */
728
+ interface PreCreateOperation extends Document.Database.PreCreateOperationStatic<TokenDocument.Database.Create> {}
729
+
730
+ /** Operation for {@link TokenDocument._onCreateOperation | `TokenDocument#_onCreateOperation`} */
731
+ interface OnCreateOperation extends TokenDocument.Database.Create {}
732
+
733
+ /** Options for {@link TokenDocument._preUpdate | `TokenDocument#_preUpdate`} */
734
+ interface PreUpdateOptions extends Document.Database.PreUpdateOptions<Update> {}
735
+
736
+ /** Options for {@link TokenDocument._onUpdate | `TokenDocument#_onUpdate`} */
737
+ interface OnUpdateOptions extends Document.Database.UpdateOptions<Update> {}
738
+
739
+ /** Operation for {@link TokenDocument._preUpdateOperation | `TokenDocument._preUpdateOperation`} */
740
+ interface PreUpdateOperation extends TokenDocument.Database.Update {}
741
+
742
+ /** Operation for {@link TokenDocument._onUpdateOperation | `TokenDocument._preUpdateOperation`} */
743
+ interface OnUpdateOperation extends TokenDocument.Database.Update {}
744
+
745
+ /** Options for {@link TokenDocument._preDelete | `TokenDocument#_preDelete`} */
746
+ interface PreDeleteOptions extends Document.Database.PreDeleteOperationInstance<Delete> {}
747
+
748
+ /** Options for {@link TokenDocument._onDelete | `TokenDocument#_onDelete`} */
749
+ interface OnDeleteOptions extends Document.Database.DeleteOptions<Delete> {}
750
+
751
+ /** Options for {@link TokenDocument._preDeleteOperation | `TokenDocument#_preDeleteOperation`} */
752
+ interface PreDeleteOperation extends TokenDocument.Database.Delete {}
753
+
754
+ /** Options for {@link TokenDocument._onDeleteOperation | `TokenDocument#_onDeleteOperation`} */
755
+ interface OnDeleteOperation extends TokenDocument.Database.Delete {}
756
+
757
+ /** Context for {@link TokenDocument._onDeleteOperation | `TokenDocument._onDeleteOperation`} */
758
+ interface OnDeleteDocumentsContext extends Document.ModificationContext<TokenDocument.Parent> {}
759
+
760
+ /** Context for {@link TokenDocument._onCreateDocuments | `TokenDocument._onCreateDocuments`} */
761
+ interface OnCreateDocumentsContext extends Document.ModificationContext<TokenDocument.Parent> {}
762
+
763
+ /** Context for {@link TokenDocument._onUpdateDocuments | `TokenDocument._onUpdateDocuments`} */
764
+ interface OnUpdateDocumentsContext extends Document.ModificationContext<TokenDocument.Parent> {}
765
+
766
+ /**
767
+ * Options for {@link TokenDocument._preCreateDescendantDocuments | `TokenDocument#_preCreateDescendantDocuments`}
768
+ * and {@link TokenDocument._onCreateDescendantDocuments | `TokenDocument#_onCreateDescendantDocuments`}
769
+ */
770
+ interface CreateOptions extends Document.Database.CreateOptions<TokenDocument.Database.Create> {}
771
+
772
+ /**
773
+ * Options for {@link TokenDocument._preUpdateDescendantDocuments | `TokenDocument#_preUpdateDescendantDocuments`}
774
+ * and {@link TokenDocument._onUpdateDescendantDocuments | `TokenDocument#_onUpdateDescendantDocuments`}
775
+ */
776
+ interface UpdateOptions extends Document.Database.UpdateOptions<TokenDocument.Database.Update> {}
777
+
778
+ /**
779
+ * Options for {@link TokenDocument._preDeleteDescendantDocuments | `TokenDocument#_preDeleteDescendantDocuments`}
780
+ * and {@link TokenDocument._onDeleteDescendantDocuments | `TokenDocument#_onDeleteDescendantDocuments`}
781
+ */
782
+ interface DeleteOptions extends Document.Database.DeleteOptions<TokenDocument.Database.Delete> {}
783
+ }
784
+
785
+ /**
786
+ * The flags that are available for this document in the form `{ [scope: string]: { [key: string]: unknown } }`.
787
+ */
788
+ interface Flags extends Document.ConfiguredFlagsForName<Name> {}
789
+
790
+ namespace Flags {
791
+ /**
792
+ * The valid scopes for the flags on this document e.g. `"core"` or `"dnd5e"`.
793
+ */
794
+ type Scope = Document.FlagKeyOf<Flags>;
795
+
796
+ /**
797
+ * The valid keys for a certain scope for example if the scope is "core" then a valid key may be `"sheetLock"` or `"viewMode"`.
798
+ */
799
+ type Key<Scope extends Flags.Scope> = Document.FlagKeyOf<Document.FlagGetKey<Flags, Scope>>;
800
+
801
+ /**
802
+ * Gets the type of a particular flag given a `Scope` and a `Key`.
803
+ */
804
+ type Get<Scope extends Flags.Scope, Key extends Flags.Key<Scope>> = Document.GetFlag<Name, Scope, Key>;
805
+ }
806
+
807
+ interface CoreFlags {
808
+ core?: {
809
+ /** @remarks If provided, will be used for any light animations emanating from this token */
810
+ animationSeed?: number;
811
+
812
+ /** @remarks If true, and texture.src is a video, it will jump to a random timestamp every time the token is drawn */
813
+ randomizeVideo?: boolean;
814
+ };
815
+ }
816
+
817
+ type PreCreateDescendantDocumentsArgs =
818
+ | Document.PreCreateDescendantDocumentsArgs<
819
+ TokenDocument.Stored,
820
+ TokenDocument.DirectDescendant,
821
+ TokenDocument.Metadata.Embedded
822
+ >
823
+ | ActorDelta.PreCreateDescendantDocumentsArgs;
824
+
825
+ type OnCreateDescendantDocumentsArgs =
826
+ | Document.OnCreateDescendantDocumentsArgs<
827
+ TokenDocument.Stored,
828
+ TokenDocument.DirectDescendant,
829
+ TokenDocument.Metadata.Embedded
830
+ >
831
+ | ActorDelta.OnCreateDescendantDocumentsArgs;
832
+
833
+ type PreUpdateDescendantDocumentsArgs =
834
+ | Document.PreUpdateDescendantDocumentsArgs<
835
+ TokenDocument.Stored,
836
+ TokenDocument.DirectDescendant,
837
+ TokenDocument.Metadata.Embedded
838
+ >
839
+ | ActorDelta.PreUpdateDescendantDocumentsArgs;
840
+
841
+ type OnUpdateDescendantDocumentsArgs =
842
+ | Document.OnUpdateDescendantDocumentsArgs<
843
+ TokenDocument.Stored,
844
+ TokenDocument.DirectDescendant,
845
+ TokenDocument.Metadata.Embedded
846
+ >
847
+ | ActorDelta.OnUpdateDescendantDocumentsArgs;
33
848
 
34
- // Helpful aliases
35
- type ConstructorData = BaseToken.ConstructorData;
36
- type UpdateData = BaseToken.UpdateData;
37
- type Schema = BaseToken.Schema;
38
- type Source = BaseToken.Source;
849
+ type PreDeleteDescendantDocumentsArgs =
850
+ | Document.PreDeleteDescendantDocumentsArgs<
851
+ TokenDocument.Stored,
852
+ TokenDocument.DirectDescendant,
853
+ TokenDocument.Metadata.Embedded
854
+ >
855
+ | ActorDelta.PreDeleteDescendantDocumentsArgs;
856
+
857
+ type OnDeleteDescendantDocumentsArgs =
858
+ | Document.OnDeleteDescendantDocumentsArgs<
859
+ TokenDocument.Stored,
860
+ TokenDocument.DirectDescendant,
861
+ TokenDocument.Metadata.Embedded
862
+ >
863
+ | ActorDelta.OnDeleteDescendantDocumentsArgs;
864
+
865
+ // The getBarAttribute monkeypatch is simply inside the data model definition at `src/foundry/common/data/data.d.mts`
866
+
867
+ interface PseudoActorCollection extends foundry.utils.Collection<Actor.Implementation> {
868
+ documentClass: Actor.ImplementationClass;
869
+ }
870
+
871
+ /** @internal */
872
+ type _GetBarAttributeOptions = NullishProps<{
873
+ /**
874
+ * An alternative attribute path to get instead of the default one
875
+ * @defaultValue `this[barName]?.attribute`
876
+ * @remarks If the above default returns falsey, the {@link TokenDocument.getBarAttribute | `TokenDocument#getBarAttribute`}
877
+ * call returns `null`
878
+ */
879
+ alternative: string;
880
+ }>;
881
+
882
+ interface GetBarAttributeOptions extends _GetBarAttributeOptions {}
883
+
884
+ type GetBarAttributeReturn = SingleAttributeBar | ObjectAttributeBar | null;
885
+
886
+ /** @internal */
887
+ type _CreateCombatantsOptions = NullishProps<{
888
+ /**
889
+ * A specific Combat instance which should be modified. If undefined,
890
+ * the current active combat will be modified if one exists. Otherwise, a new
891
+ * Combat encounter will be created if the requesting user is a Gamemaster.
892
+ * @defaultValue `game.combats.viewed`
893
+ */
894
+ combat: Combat.Implementation;
895
+ }>;
896
+
897
+ interface CreateCombatantsOptions extends _CreateCombatantsOptions {}
898
+
899
+ interface DeleteCombatantsOptions extends _CreateCombatantsOptions {}
900
+
901
+ type TrackedAttributesSubject =
902
+ | DataModel.Any
903
+ | DataModel.AnyConstructor
904
+ | SchemaField.Any
905
+ | Actor.SubType
906
+ | AnyObject
907
+ | AnyArray;
908
+
909
+ interface TrackedAttributesDescription {
910
+ /** A list of property path arrays to attributes with both a value and a max property. */
911
+ bar: string[][];
912
+ /** A list of property path arrays to attributes that have only a value property. */
913
+ value: string[][];
914
+ }
915
+
916
+ interface TrackedAttributesChoice {
917
+ group: string;
918
+ value: string;
919
+ label: string;
920
+ }
921
+
922
+ interface ToggleCombatantOptions extends InexactPartial<TokenDocument.CreateCombatantsOptions> {
923
+ /**
924
+ * Require this token to be an active Combatant or to be removed.
925
+ * Otherwise, the current combat state of the Token is toggled.
926
+ */
927
+ active: boolean;
928
+ }
929
+
930
+ type GetEmbeddedCollectionName = Embedded.CollectionName | "Actor" | "Item" | "ActiveEffect";
931
+
932
+ // TODO(LukeAbby): Simplified for now to prevent circularities. The correct implementation would
933
+ // be this:
934
+ // | (Name extends "Actor" ? globalThis.Collection<Actor.Implementation> : never)
935
+ // | (Name extends "Item" ? globalThis.Collection<Item.Implementation> : never)
936
+ // | (Name extends "ActiveEffect" ? globalThis.Collection<ActiveEffect.Implementation> : never)
937
+ // | (Name extends Embedded.CollectionName ? Embedded.CollectionFor<Name> : never);
938
+ type GetEmbeddedCollectionResult<_Name extends GetEmbeddedCollectionName> = Collection.Any;
939
+
940
+ /**
941
+ * @deprecated {@link TokenDocument.Database | `TokenDocument.DatabaseOperation`}
942
+ */
943
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
944
+ interface DatabaseOperations extends Document.Database.Operations<TokenDocument.Implementation> {}
945
+
946
+ /**
947
+ * @deprecated {@link TokenDocument.CreateData | `TokenDocument.CreateData`}
948
+ */
949
+ interface ConstructorData extends TokenDocument.CreateData {}
950
+
951
+ /**
952
+ * @deprecated {@link TokenDocument.implementation | `TokenDocument.ImplementationClass`}
953
+ */
954
+ type ConfiguredClass = ImplementationClass;
955
+
956
+ /**
957
+ * @deprecated {@link TokenDocument.Implementation | `TokenDocument.Implementation`}
958
+ */
959
+ type ConfiguredInstance = Implementation;
39
960
  }
40
961
 
41
962
  /**
42
963
  * The client-side Token document which extends the common BaseToken model.
43
964
  *
44
- * @see {@link Scene} The Scene document type which contains Token embedded documents
45
- * @see {@link TokenConfig} The Token configuration application
965
+ * @see {@link Scene | `Scene`} The Scene document type which contains Token embedded documents
966
+ * @see {@link TokenConfig | `TokenConfig`} The Token configuration application
46
967
  */
47
968
  class TokenDocument extends CanvasDocumentMixin(foundry.documents.BaseToken) {
48
- static override metadata: TokenDocument.Metadata;
969
+ /**
970
+ * @param data - Initial data from which to construct the `TokenDocument`
971
+ * @param context - Construction context options
972
+ */
973
+ constructor(...args: TokenDocument.ConstructorArgs);
49
974
 
50
975
  /**
51
976
  * A singleton collection which holds a reference to the synthetic token actor by its base actor's ID.
977
+ * @remarks Initialized by an IIFE that makes a base-model {@linkcode Collection} and adds a `documentClass` property to it
52
978
  */
53
- actors(): Collection<Actor.ConfiguredInstance>;
979
+ actors: TokenDocument.PseudoActorCollection;
54
980
 
55
981
  /**
56
982
  * A lazily evaluated reference to the Actor this Token modifies.
57
983
  * If actorLink is true, then the document is the primary Actor document.
58
984
  * Otherwise the Actor document is a synthetic (ephemeral) document constructed using the Token's ActorDelta.
59
985
  */
60
- get actor(): Actor.ConfiguredInstance | null;
986
+ get actor(): Actor.Implementation | null;
61
987
 
62
988
  /**
63
989
  * A reference to the base, World-level Actor this token represents.
64
990
  */
65
- get baseActor(): Actor | undefined;
991
+ get baseActor(): Actor.Implementation | undefined;
66
992
 
67
993
  /**
68
994
  * An indicator for whether or not the current User has full control over this Token document.
@@ -83,7 +1009,7 @@ declare global {
83
1009
  /**
84
1010
  * Return a reference to a Combatant that represents this Token, if one is present in the current encounter.
85
1011
  */
86
- get combatant(): Combatant.ConfiguredInstance | null;
1012
+ get combatant(): Combatant.Implementation | null;
87
1013
 
88
1014
  /**
89
1015
  * An indicator for whether or not this Token is currently involved in the active combat encounter.
@@ -92,12 +1018,11 @@ declare global {
92
1018
 
93
1019
  /**
94
1020
  * The Regions this Token is currently in.
95
- * @privateRemarks TODO: Change Set<any> to Set<RegionDocuments> when RegionDocuments are implemented
96
1021
  */
97
- regions: Set<any> | null;
1022
+ regions: Set<RegionDocument.Implementation> | null;
98
1023
 
99
- // TODO: Same as `DataModel._initialize`
100
- protected override _initialize(options?: any): void;
1024
+ // options: not null (parameter default only)
1025
+ protected override _initialize(options?: Document.InitializeOptions): void;
101
1026
 
102
1027
  override prepareBaseData(): void;
103
1028
 
@@ -121,15 +1046,11 @@ declare global {
121
1046
  * @param barName - The named bar to retrieve the attribute for
122
1047
  * @returns The attribute displayed on the Token bar, if any
123
1048
  */
1049
+ // options: not null (destructured)
124
1050
  getBarAttribute(
125
1051
  barName: string,
126
- options?: InexactPartial<{
127
- /**
128
- * An alternative attribute path to get instead of the default one
129
- */
130
- alternative: string;
131
- }>,
132
- ): SingleAttributeBar | ObjectAttributeBar | null;
1052
+ options?: TokenDocument.GetBarAttributeOptions,
1053
+ ): TokenDocument.GetBarAttributeReturn;
133
1054
 
134
1055
  /**
135
1056
  * Test whether a Token has a specific status effect.
@@ -140,63 +1061,59 @@ declare global {
140
1061
 
141
1062
  /**
142
1063
  * Add or remove this Token from a Combat encounter.
143
- * @param options - Additional options passed to TokenDocument.createCombatants or
144
- * TokenDocument.deleteCombatants
145
- * Default: `{}`
146
- * @returns Is this Token now an active Combatant?
147
- */
148
- toggleCombatant({
149
- active,
150
- ...options
151
- }?: InexactPartial<
152
- CreateCombatantOptions & {
153
- /**
154
- * Require this token to be an active Combatant or to be removed.
155
- * Otherwise, the current combat state of the Token is toggled.
156
- */
157
- active: boolean;
158
- }
159
- >): Promise<boolean>;
1064
+ * @param options - Additional options passed to TokenDocument.createCombatants or TokenDocument.deleteCombatants (default: `{}`)
1065
+ * @returns Is this Token now an active Combatant?
1066
+ */
1067
+ // options: not null (destructured)
1068
+ toggleCombatant(options?: TokenDocument.ToggleCombatantOptions): Promise<boolean>;
160
1069
 
161
1070
  /**
162
1071
  * Create or remove Combatants for an array of provided Token objects.
163
1072
  * @param tokens - The tokens which should be added to the Combat
164
- * @param options - Options which modify the toggle operation
165
- * Default: `{}`
1073
+ * @param options - Options which modify the toggle operation (default: `{}`)
166
1074
  * @returns An array of created Combatant documents
167
1075
  */
168
- static createCombatants(tokens: TokenDocument[], options?: CreateCombatantOptions): Promise<Combatant[]>;
1076
+ // options: not null (destructured)
1077
+ static createCombatants(
1078
+ tokens: TokenDocument.Implementation[],
1079
+ options?: TokenDocument.CreateCombatantsOptions,
1080
+ ): Promise<Combatant.Implementation[]>;
169
1081
 
170
1082
  /**
171
1083
  * Remove Combatants for the array of provided Tokens.
172
1084
  * @param tokens - The tokens which should removed from the Combat
173
- * @param options - Options which modify the operation
174
- * Default: `{}`
1085
+ * @param options - Options which modify the operation (default: `{}`)
175
1086
  * @returns An array of deleted Combatant documents
176
1087
  */
177
- static deleteCombatants(tokens: TokenDocument[], options?: CreateCombatantOptions): Promise<Combatant[]>;
1088
+ // options: not null (destructured)
1089
+ static deleteCombatants(
1090
+ tokens: TokenDocument.Implementation[],
1091
+ options?: TokenDocument.DeleteCombatantsOptions,
1092
+ ): Promise<Combatant.Implementation[]>;
178
1093
 
179
1094
  /**
180
1095
  * Convenience method to change a token vision mode.
181
1096
  * @param visionMode - The vision mode to apply to this token.
182
- * @param defaults - If the vision mode should be updated with its defaults.
183
- * Default = `true`
1097
+ * @param defaults - If the vision mode should be updated with its defaults. (default: `true`)
184
1098
  */
185
1099
  updateVisionMode(
186
- visionMode: typeof CONFIG.Canvas.visionModes,
187
- defaults?: boolean,
188
- ): Promise<ReturnType<this["update"]>>;
189
-
190
- override getEmbeddedCollection<DocType extends Document.Type>(
191
- embeddedName: DocType,
192
- ): Collection<Document.ConfiguredInstanceForName<DocType>>;
1100
+ visionMode: VisionMode.ConfiguredModes,
1101
+ defaults?: boolean | null,
1102
+ ): Promise<TokenDocument.Implementation | undefined>;
193
1103
 
194
1104
  /**
195
- * @privateRemarks _onCreate, _preUpdate, _onUpdate, _onDelete, preCreateOperation, _preUpdateOperation, _onCreateOperation,
196
- * _onUpdateOperation, _onDeleteOperation, _preCreateDescendantDocuments, _preUpdateDescendantDocuments, _preDeleteDescendantDocuments,
197
- * _onUpdateDescendantDocuments, and _onDeleteDescendantDocuments are all overridden but with no signature changes.
198
- * For type simplicity they are left off. These methods historically have been the source of a large amount of computation from tsc.
1105
+ * @remarks Foundry specifically overrides this method such that unlinked `TokenDocument` instances
1106
+ * handles 3 extra cases:
1107
+ * - Passing `"Actor"` returns `this.actors`.
1108
+ * - Passing `"Item"` returns `this.actor.items`.
1109
+ * - Passing `"ActiveEffect"` returns `this.actor.effects`.
199
1110
  */
1111
+ override getEmbeddedCollection<EmbeddedName extends TokenDocument.GetEmbeddedCollectionName>(
1112
+ embeddedName: EmbeddedName,
1113
+ ): TokenDocument.GetEmbeddedCollectionResult<EmbeddedName>;
1114
+
1115
+ // _onCreate, _preUpdate, _onUpdate, _onDelete, preCreateOperation, _preUpdateOperation, _onCreateOperation,
1116
+ // _onUpdateOperation, _onDeleteOperation are all overridden but with no signature changes from their definition in BaseToken.
200
1117
 
201
1118
  /**
202
1119
  * Is to Token document updated such that the Regions the Token is contained in may change?
@@ -204,18 +1121,122 @@ declare global {
204
1121
  * @param changes - The changes.
205
1122
  * @returns Could this Token update change Region containment?
206
1123
  */
1124
+ protected _couldRegionsChange(changes: TokenDocument.UpdateData): boolean;
1125
+
1126
+ /**
1127
+ * @remarks To make it possible for narrowing one parameter to jointly narrow other parameters
1128
+ * this method must be overridden like so:
1129
+ * ```typescript
1130
+ * class SwadeActorDelta extends ActorDelta {
1131
+ * protected override _preCreateDescendantDocuments(...args: ActorDelta.PreCreateDescendantDocumentsArgs) {
1132
+ * super._preCreateDescendantDocuments(...args);
1133
+ *
1134
+ * const [parent, collection, data, options, userId] = args;
1135
+ * if (collection === "items") {
1136
+ * options; // Will be narrowed.
1137
+ * }
1138
+ * }
1139
+ * }
1140
+ * ```
1141
+ */
1142
+ protected override _preCreateDescendantDocuments(...args: ActorDelta.PreCreateDescendantDocumentsArgs): void;
1143
+
1144
+ /**
1145
+ * @remarks To make it possible for narrowing one parameter to jointly narrow other parameters
1146
+ * this method must be overridden like so:
1147
+ * ```typescript
1148
+ * class GurpsActorDelta extends ActorDelta {
1149
+ * protected override _onCreateDescendantDocuments(...args: ActorDelta.OnCreateDescendantDocumentsArgs) {
1150
+ * super._onCreateDescendantDocuments(...args);
1151
+ *
1152
+ * const [parent, collection, documents, data, options, userId] = args;
1153
+ * if (collection === "items") {
1154
+ * options; // Will be narrowed.
1155
+ * }
1156
+ * }
1157
+ * }
1158
+ * ```
1159
+ */
1160
+ protected override _onCreateDescendantDocuments(...args: ActorDelta.OnCreateDescendantDocumentsArgs): void;
207
1161
 
208
- protected _couldRegionsChange(
209
- changes: SchemaField.InnerAssignmentType<foundry.documents.BaseToken.Schema>,
210
- ): boolean;
1162
+ /**
1163
+ * @remarks To make it possible for narrowing one parameter to jointly narrow other parameters
1164
+ * this method must be overridden like so:
1165
+ * ```typescript
1166
+ * class LancerActorDelta extends ActorDelta {
1167
+ * protected override _preUpdateDescendantDocuments(...args: ActorDelta.OnUpdateDescendantDocuments) {
1168
+ * super._preUpdateDescendantDocuments(...args);
1169
+ *
1170
+ * const [parent, collection, changes, options, userId] = args;
1171
+ * if (collection === "tokens") {
1172
+ * options; // Will be narrowed.
1173
+ * }
1174
+ * }
1175
+ * }
1176
+ * ```
1177
+ */
1178
+ protected override _preUpdateDescendantDocuments(...args: ActorDelta.PreUpdateDescendantDocumentsArgs): void;
1179
+
1180
+ /**
1181
+ * @remarks To make it possible for narrowing one parameter to jointly narrow other parameters
1182
+ * this method must be overridden like so:
1183
+ * ```typescript
1184
+ * class Ptr2eTokenDocument extends TokenDocument {
1185
+ * protected override _onUpdateDescendantDocuments(...args: TokenDocument.OnUpdateDescendantDocumentsArgs) {
1186
+ * super._onUpdateDescendantDocuments(...args);
1187
+ *
1188
+ * const [parent, collection, documents, changes, options, userId] = args;
1189
+ * if (collection === "items") {
1190
+ * options; // Will be narrowed.
1191
+ * }
1192
+ * }
1193
+ * }
1194
+ * ```
1195
+ */
1196
+ protected override _onUpdateDescendantDocuments(...args: TokenDocument.OnUpdateDescendantDocumentsArgs): void;
1197
+
1198
+ /**
1199
+ * @remarks To make it possible for narrowing one parameter to jointly narrow other parameters
1200
+ * this method must be overridden like so:
1201
+ * ```typescript
1202
+ * class KultTokenDocument extends TokenDocument {
1203
+ * protected override _preDeleteDescendantDocuments(...args: TokenDocument.PreDeleteDescendantDocumentsArgs) {
1204
+ * super._preDeleteDescendantDocuments(...args);
1205
+ *
1206
+ * const [parent, collection, ids, options, userId] = args;
1207
+ * if (collection === "items") {
1208
+ * options; // Will be narrowed.
1209
+ * }
1210
+ * }
1211
+ * }
1212
+ * ```
1213
+ */
1214
+ protected override _preDeleteDescendantDocuments(...args: TokenDocument.PreDeleteDescendantDocumentsArgs): void;
1215
+
1216
+ /**
1217
+ * @remarks To make it possible for narrowing one parameter to jointly narrow other parameters
1218
+ * this method must be overridden like so:
1219
+ * ```typescript
1220
+ * class BladesTokenDocument extends TokenDocument {
1221
+ * protected override _onDeleteDescendantDocuments(...args: TokenDocument.OnUpdateDescendantDocuments) {
1222
+ * super._onDeleteDescendantDocuments(...args);
1223
+ *
1224
+ * const [parent, collection, documents, ids, options, userId] = args;
1225
+ * if (collection === "tokens") {
1226
+ * options; // Will be narrowed.
1227
+ * }
1228
+ * }
1229
+ * }
1230
+ * ```
1231
+ */
1232
+ protected override _onDeleteDescendantDocuments(...args: TokenDocument.OnDeleteDescendantDocumentsArgs): void;
211
1233
 
212
1234
  /**
213
1235
  * When the base Actor for a TokenDocument changes, we may need to update its Actor instance
1236
+ * @remarks After updating the synthetic actor, forwards to {@link TokenDocument._onRelatedUpdate | `TokenDocument#_onRelatedUpdate`}
214
1237
  */
215
- protected _onUpdateBaseActor(
216
- update?: DeepPartial<Actor.ConfiguredInstance["_source"]>,
217
- options?: Document.OnUpdateOptions<"Actor">,
218
- ): void;
1238
+ // update, options: not null (parameter defaults only)
1239
+ protected _onUpdateBaseActor(update?: Actor.UpdateData, options?: Actor.Database.OnUpdateOperation): void;
219
1240
 
220
1241
  /**
221
1242
  * Whenever the token's actor delta changes, or the base actor changes, perform associated refreshes.
@@ -223,68 +1244,81 @@ declare global {
223
1244
  * @param options - The options provided to the update.
224
1245
  */
225
1246
  protected _onRelatedUpdate(
226
- update?: DeepPartial<Actor.ConfiguredInstance["_source"]>,
227
- /** @privateRemarks foundry calls this field operation
1247
+ update?: Actor.UpdateData | ActorDelta.UpdateData,
1248
+ /**
1249
+ * @privateRemarks foundry calls this field operation
228
1250
  * but it's being passed options (and then ignores them)
229
1251
  */
230
- operation?: Document.OnUpdateOptions<"Actor">,
1252
+ operation?: Actor.Database.OnUpdateOperation,
231
1253
  ): void;
232
1254
 
233
1255
  /**
234
1256
  * Get an Array of attribute choices which could be tracked for Actors in the Combat Tracker
1257
+ * @param data - The object to explore for attributes, or an Actor type.
235
1258
  * @param _path - (default: `[]`)
236
1259
  */
237
1260
  // TODO: There's some very complex handling for non-datamodel Actor system implementations if we want
1261
+ // _path: not null (parameter default only)
238
1262
  static getTrackedAttributes(
239
- data?: Actor.ConfiguredInstance["system"],
1263
+ data?: TokenDocument.TrackedAttributesSubject | null,
240
1264
  _path?: string[],
241
- ): TrackedAttributesDescription;
1265
+ ): TokenDocument.TrackedAttributesDescription;
242
1266
 
243
1267
  /**
244
1268
  * Retrieve an Array of attribute choices from a plain object.
245
1269
  * @param schema - The schema to explore for attributes.
246
1270
  */
247
- protected static _getTrackedAttributesFromObject(data: object, _path?: string[]): TrackedAttributesDescription;
1271
+ // _path: not null (parameter default only)
1272
+ protected static _getTrackedAttributesFromObject(
1273
+ data: AnyObject | AnyArray,
1274
+ _path?: string[],
1275
+ ): TokenDocument.TrackedAttributesDescription;
248
1276
 
249
1277
  /**
250
1278
  * Retrieve an Array of attribute choices from a SchemaField.
251
1279
  * @param schema - The schema to explore for attributes.
252
1280
  */
253
1281
  protected static _getTrackedAttributesFromSchema(
254
- schema: foundry.data.fields.SchemaField.Any,
1282
+ schema: SchemaField.Any,
255
1283
  _path?: string[],
256
- ): TrackedAttributesDescription;
1284
+ ): TokenDocument.TrackedAttributesDescription;
257
1285
 
258
1286
  /**
259
1287
  * Retrieve any configured attributes for a given Actor type.
260
1288
  * @param type - The Actor type.
1289
+ * @remarks If `type` is invalid, or doesn't have an entry in {@linkcode CONFIG.Actor.trackableAttributes}, returns the merged
1290
+ * tracked attributes of all types. If no types have any configured, returns `void`
261
1291
  */
262
- static _getConfiguredTrackedAttributes(type: string): TrackedAttributesDescription | void;
1292
+ static _getConfiguredTrackedAttributes(
1293
+ type?: Actor.SubType | null,
1294
+ ): TokenDocument.TrackedAttributesDescription | void;
263
1295
 
264
1296
  /**
265
1297
  * Inspect the Actor data model and identify the set of attributes which could be used for a Token Bar
266
- * @param attributes - The tracked attributes which can be chosen from
1298
+ * @param attributes - The tracked attributes which can be chosen from (default: `this.getTrackedAttributes()`)
267
1299
  * @returns A nested object of attribute choices to display
268
1300
  */
269
- static getTrackedAttributeChoices(attributes?: TrackedAttributesDescription): Record<string, string[]>;
1301
+ static getTrackedAttributeChoices(
1302
+ attributes?: TokenDocument.TrackedAttributesDescription | null,
1303
+ ): TokenDocument.TrackedAttributesChoice[];
270
1304
 
271
1305
  /**
272
- * @deprecated since v11
1306
+ * @deprecated since v11, no specified end
273
1307
  * @remarks `"TokenDocument#getActor has been deprecated. Please use the`
274
1308
  * `TokenDocument#actor getter to retrieve the Actor instance that the TokenDocument represents, or use`
275
1309
  * `TokenDocument#delta#apply to generate a new synthetic Actor instance."`
276
1310
  */
277
- getActor(): Actor.ConfiguredInstance;
1311
+ getActor(): Actor.Implementation;
278
1312
 
279
1313
  /**
280
- * @deprecated since v11
1314
+ * @deprecated since v11, until v13
1315
+ * @remarks "You are accessing `TokenDocument#actorData` which is deprecated. Source data may be retrieved via
1316
+ * {@link TokenDocument.delta | `TokenDocument#delta`} but all modifications/access should be done via the
1317
+ * synthetic Actor at {@link TokenDocument.actor | `TokenDocument#actor`} if possible."
281
1318
  */
282
- get actorData(): this["delta"]["_source"];
1319
+ get actorData(): ActorDelta.Source;
283
1320
 
284
- /**
285
- * @deprecated since v11
286
- */
287
- set actorData(actorData: this["delta"]["_source"]);
1321
+ set actorData(actorData: ActorDelta.CreateData);
288
1322
 
289
1323
  /**
290
1324
  * A helper function to toggle a status effect which includes an Active Effect template
@@ -293,31 +1327,61 @@ declare global {
293
1327
  * (default: `{}`)
294
1328
  * @returns Whether the Active Effect is now on or off
295
1329
  * @deprecated since v12
296
- * @remarks `TokenDocument#toggleActiveEffect is deprecated in favor of Actor#toggleStatusEffect"`
1330
+ * @remarks "`TokenDocument#toggleActiveEffect` is deprecated in favor of {@link Actor.toggleStatusEffect | `Actor#toggleStatusEffect`}"
1331
+ */
1332
+ // options: not null (destructured)
1333
+ toggleActiveEffect(effectData: CONFIG.StatusEffect, options?: Actor.ToggleStatusEffectOptions): Promise<boolean>;
1334
+
1335
+ /*
1336
+ * After this point these are not really overridden methods.
1337
+ * They are here because Foundry's documents are complex and have lots of edge cases.
1338
+ * There are DRY ways of representing this but this ends up being harder to understand
1339
+ * for end users extending these functions, especially for static methods. There are also a
1340
+ * number of methods that don't make sense to call directly on `Document` like `createDocuments`,
1341
+ * as there is no data that can safely construct every possible document. Finally keeping definitions
1342
+ * separate like this helps against circularities.
297
1343
  */
298
- toggleActiveEffect(
299
- effectData: CONFIG.StatusEffect,
300
- options?: InexactPartial<ToggleActiveEffectOptions> | undefined,
301
- ): Promise<boolean>;
302
- }
303
1344
 
304
- // The getBarAttribute monkeypatch is simply inside the data model definition at `src\foundry\common\data\data.d.mts`
1345
+ // ClientDocument overrides
305
1346
 
306
- interface TrackedAttributesDescription {
307
- /** A list of property path arrays to attributes with both a value and a max property. */
308
- bar: string[][];
309
- /** A list of property path arrays to attributes that have only a value property. */
310
- value: string[][];
311
- }
1347
+ // context: not null (destructured)
1348
+ static override defaultName(
1349
+ context?: Document.DefaultNameContext<"Token", NonNullable<TokenDocument.Parent>>,
1350
+ ): string;
312
1351
 
313
- interface CreateCombatantOptions {
314
- /**
315
- * A specific Combat instance which should be modified. If undefined,
316
- * the current active combat will be modified if one exists. Otherwise, a new
317
- * Combat encounter will be created if the requesting user is a Gamemaster.
318
- */
319
- combat?: Combat | undefined;
1352
+ /** @remarks `context.parent` is required as creation requires one */
1353
+ static override createDialog(
1354
+ data: Document.CreateDialogData<TokenDocument.CreateData> | undefined,
1355
+ context: Document.CreateDialogContext<"Token", NonNullable<TokenDocument.Parent>>,
1356
+ ): Promise<TokenDocument.Stored | null | undefined>;
1357
+
1358
+ // options: not null (parameter default only)
1359
+ static override fromDropData(
1360
+ data: Document.DropData<TokenDocument.Implementation>,
1361
+ options?: AnyObject,
1362
+ ): Promise<TokenDocument.Implementation | undefined>;
1363
+
1364
+ static override fromImport(
1365
+ source: TokenDocument.Source,
1366
+ context?: Document.FromImportContext<TokenDocument.Parent> | null,
1367
+ ): Promise<TokenDocument.Implementation>;
1368
+
1369
+ override _onClickDocumentLink(event: MouseEvent): ClientDocument.OnClickDocumentLinkReturn;
1370
+
1371
+ // TODO: The deprecated Embedded Document Operations
1372
+
1373
+ #TokenDocument: true;
320
1374
  }
1375
+
1376
+ /**
1377
+ * @deprecated {@link TokenDocument.TrackedAttributesDescription | `TokenDocument.TrackedAttributesDescription`}
1378
+ */
1379
+ type TrackedAttributesDescription = TokenDocument.TrackedAttributesDescription;
1380
+
1381
+ /**
1382
+ * @deprecated {@link TokenDocument.CreateCombatantsOptions | `TokenDocument.CreateCombatantOptions`}
1383
+ */
1384
+ type CreateCombatantOptions = TokenDocument.CreateCombatantsOptions;
321
1385
  }
322
1386
 
323
1387
  interface SingleAttributeBar {
@@ -334,19 +1398,3 @@ interface ObjectAttributeBar {
334
1398
  max: number;
335
1399
  editable: boolean;
336
1400
  }
337
-
338
- interface ToggleActiveEffectOptions {
339
- /**
340
- * Should the Active Effect icon be displayed as an overlay on the token?
341
- * @defaultValue `false`
342
- */
343
- overlay: boolean;
344
-
345
- /** Force a certain active state for the effect. */
346
- active: boolean;
347
- }
348
-
349
- /**
350
- * @deprecated See {@link CONFIG.StatusEffect}
351
- */
352
- export type StatusEffect = CONFIG.StatusEffect;