@league-of-foundry-developers/foundry-vtt-types 12.331.2-beta → 13.340.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -17
- package/package.json +84 -41
- package/src/configuration/configuration.d.mts +315 -0
- package/src/configuration/globals.d.mts +349 -0
- package/src/configuration/index.d.mts +4 -0
- package/src/foundry/client/apps/app.d.mts +10 -5
- package/src/foundry/client/apps/av/av-config.d.mts +2 -2
- package/src/foundry/client/apps/av/cameras.d.mts +7 -2
- package/src/foundry/client/apps/dice/dice-config.d.mts +45 -0
- package/src/foundry/client/apps/dice/index.d.mts +1 -0
- package/src/foundry/client/apps/form.d.mts +13 -4
- package/src/foundry/client/apps/forms/actor.d.mts +4 -4
- package/src/foundry/client/apps/forms/adventure-exporter.d.mts +1 -1
- package/src/foundry/client/apps/forms/adventure-importer.d.mts +1 -1
- package/src/foundry/client/apps/forms/base-sheet.d.mts +7 -6
- package/src/foundry/client/apps/forms/card-config.d.mts +8 -8
- package/src/foundry/client/apps/forms/cards-config.d.mts +5 -4
- package/src/foundry/client/apps/forms/combat-config.d.mts +1 -1
- package/src/foundry/client/apps/forms/combatant-config.d.mts +1 -1
- package/src/foundry/client/apps/forms/effect-config.d.mts +1 -1
- package/src/foundry/client/apps/forms/folder-config.d.mts +1 -1
- package/src/foundry/client/apps/forms/fonts.d.mts +1 -1
- package/src/foundry/client/apps/forms/grid-config.d.mts +3 -8
- package/src/foundry/client/apps/forms/image-popout.d.mts +1 -1
- package/src/foundry/client/apps/forms/item.d.mts +8 -8
- package/src/foundry/client/apps/forms/journal-page-sheet.d.mts +1 -1
- package/src/foundry/client/apps/forms/journal-sheet.d.mts +4 -3
- package/src/foundry/client/apps/forms/macro-config.d.mts +2 -2
- package/src/foundry/client/apps/forms/measure-template.d.mts +8 -10
- package/src/foundry/client/apps/forms/ownership.d.mts +1 -1
- package/src/foundry/client/apps/forms/playlist-config.d.mts +1 -1
- package/src/foundry/client/apps/forms/playlist-sound-config.d.mts +1 -1
- package/src/foundry/client/apps/forms/roll-table-config.d.mts +5 -3
- package/src/foundry/client/apps/forms/scene-config.d.mts +5 -6
- package/src/foundry/client/apps/forms/sheet-config.d.mts +6 -18
- package/src/foundry/client/apps/forms/user-config.d.mts +6 -5
- package/src/foundry/client/apps/hud/chatbubble.d.mts +7 -0
- package/src/foundry/client/apps/hud/container.d.mts +1 -1
- package/src/foundry/client/apps/hud/controls.d.mts +6 -1
- package/src/foundry/client/apps/hud/hotbar.d.mts +9 -4
- package/src/foundry/client/apps/hud/hud.d.mts +1 -1
- package/src/foundry/client/apps/hud/menu.d.mts +8 -1
- package/src/foundry/client/apps/hud/navigation.d.mts +8 -3
- package/src/foundry/client/apps/hud/pause.d.mts +7 -2
- package/src/foundry/client/apps/hud/players.d.mts +8 -3
- package/src/foundry/client/apps/i18n.d.mts +16 -13
- package/src/foundry/client/apps/index.d.mts +1 -0
- package/src/foundry/client/apps/placeables/drawing-config.d.mts +1 -1
- package/src/foundry/client/apps/placeables/drawing-hud.d.mts +1 -1
- package/src/foundry/client/apps/placeables/light-config.d.mts +4 -4
- package/src/foundry/client/apps/placeables/note-config.d.mts +3 -3
- package/src/foundry/client/apps/placeables/sound-config.d.mts +4 -3
- package/src/foundry/client/apps/placeables/tile-config.d.mts +2 -2
- package/src/foundry/client/apps/placeables/tile-hud.d.mts +7 -2
- package/src/foundry/client/apps/placeables/token-config.d.mts +16 -4
- package/src/foundry/client/apps/placeables/token-hud.d.mts +7 -2
- package/src/foundry/client/apps/placeables/wall-config.d.mts +4 -3
- package/src/foundry/client/apps/sidebar/apps/client-settings.d.mts +1 -1
- package/src/foundry/client/apps/sidebar/apps/compendium.d.mts +6 -7
- package/src/foundry/client/apps/sidebar/apps/keybindings-config.d.mts +2 -1
- package/src/foundry/client/apps/sidebar/apps/module-management.d.mts +1 -1
- package/src/foundry/client/apps/sidebar/apps/permission-config.d.mts +1 -1
- package/src/foundry/client/apps/sidebar/apps/support-details.d.mts +1 -1
- package/src/foundry/client/apps/sidebar/apps/tours-management.d.mts +1 -1
- package/src/foundry/client/apps/sidebar/apps/world-config.d.mts +1 -1
- package/src/foundry/client/apps/sidebar/directory-tab-mixin.d.mts +12 -5
- package/src/foundry/client/apps/sidebar/document-directory.d.mts +12 -5
- package/src/foundry/client/apps/sidebar/package-configuration.d.mts +1 -1
- package/src/foundry/client/apps/sidebar/sidebar.d.mts +7 -2
- package/src/foundry/client/apps/sidebar/tabs/actors-directory.d.mts +10 -1
- package/src/foundry/client/apps/sidebar/tabs/cards-directory.d.mts +10 -1
- package/src/foundry/client/apps/sidebar/tabs/chat-log.d.mts +8 -1
- package/src/foundry/client/apps/sidebar/tabs/combat-tracker.d.mts +10 -1
- package/src/foundry/client/apps/sidebar/tabs/compendium-directory.d.mts +15 -9
- package/src/foundry/client/apps/sidebar/tabs/items-directory.d.mts +10 -1
- package/src/foundry/client/apps/sidebar/tabs/journal-directory.d.mts +10 -1
- package/src/foundry/client/apps/sidebar/tabs/macros-directory.d.mts +9 -0
- package/src/foundry/client/apps/sidebar/tabs/playlists-directory.d.mts +16 -8
- package/src/foundry/client/apps/sidebar/tabs/roll-table-directory.d.mts +10 -1
- package/src/foundry/client/apps/sidebar/tabs/scenes-directory.d.mts +11 -2
- package/src/foundry/client/apps/sidebar/tabs/settings.d.mts +19 -1
- package/src/foundry/client/apps/templates.d.mts +5 -1
- package/src/foundry/client/av/client.d.mts +1 -1
- package/src/foundry/client/av/clients/simplepeer.d.mts +11 -1
- package/src/foundry/client/av/master.d.mts +2 -2
- package/src/foundry/client/av/settings.d.mts +1 -2
- package/src/foundry/client/config.d.mts +201 -198
- package/src/foundry/client/core/hooks.d.mts +2 -2
- package/src/foundry/client/core/image.d.mts +81 -33
- package/src/foundry/client/core/keybindings.d.mts +2 -2
- package/src/foundry/client/core/packages.d.mts +9 -2
- package/src/foundry/client/core/settings.d.mts +34 -31
- package/src/foundry/client/core/socket.d.mts +1 -1
- package/src/foundry/client/core/sorting.d.mts +1 -1
- package/src/foundry/client/core/tooltip.d.mts +1 -1
- package/src/foundry/client/core/tour.d.mts +1 -1
- package/src/foundry/client/core/utils.d.mts +33 -10
- package/src/foundry/client/core/video.d.mts +1 -1
- package/src/foundry/client/core/workers.d.mts +1 -1
- package/src/foundry/client/data/abstract/canvas-document.d.mts +25 -15
- package/src/foundry/client/data/abstract/client-document.d.mts +48 -39
- package/src/foundry/client/data/abstract/directory-collection-mixin.d.mts +19 -13
- package/src/foundry/client/data/abstract/document-collection.d.mts +8 -8
- package/src/foundry/client/data/abstract/world-collection.d.mts +3 -5
- package/src/foundry/client/data/collections/actors.d.mts +10 -1
- package/src/foundry/client/data/collections/cards.d.mts +9 -0
- package/src/foundry/client/data/collections/combats.d.mts +10 -1
- package/src/foundry/client/data/collections/compendium-collection.d.mts +8 -37
- package/src/foundry/client/data/collections/compendium-packs.d.mts +2 -2
- package/src/foundry/client/data/collections/fog.d.mts +9 -0
- package/src/foundry/client/data/collections/folder.d.mts +9 -0
- package/src/foundry/client/data/collections/items.d.mts +9 -0
- package/src/foundry/client/data/collections/journal.d.mts +10 -1
- package/src/foundry/client/data/collections/macros.d.mts +10 -1
- package/src/foundry/client/data/collections/messages.d.mts +9 -0
- package/src/foundry/client/data/collections/playlists.d.mts +10 -1
- package/src/foundry/client/data/collections/scenes.d.mts +10 -1
- package/src/foundry/client/data/collections/settings.d.mts +9 -0
- package/src/foundry/client/data/collections/tables.d.mts +10 -1
- package/src/foundry/client/data/collections/users.d.mts +10 -1
- package/src/foundry/client/data/documents/active-effect.d.mts +43 -14
- package/src/foundry/client/data/documents/actor-delta.d.mts +4 -4
- package/src/foundry/client/data/documents/actor.d.mts +7 -4
- package/src/foundry/client/data/documents/adventure.d.mts +9 -8
- package/src/foundry/client/data/documents/ambient-light.d.mts +3 -2
- package/src/foundry/client/data/documents/ambient-sound.d.mts +3 -2
- package/src/foundry/client/data/documents/card.d.mts +4 -3
- package/src/foundry/client/data/documents/cards.d.mts +15 -20
- package/src/foundry/client/data/documents/chat-message.d.mts +4 -3
- package/src/foundry/client/data/documents/combat.d.mts +5 -4
- package/src/foundry/client/data/documents/combatant.d.mts +5 -4
- package/src/foundry/client/data/documents/drawing.d.mts +3 -2
- package/src/foundry/client/data/documents/fog-exploration.d.mts +13 -3
- package/src/foundry/client/data/documents/folder.d.mts +27 -9
- package/src/foundry/client/data/documents/index.d.mts +2 -0
- package/src/foundry/client/data/documents/item.d.mts +6 -2
- package/src/foundry/client/data/documents/journal-entry-page.d.mts +5 -4
- package/src/foundry/client/data/documents/journal-entry.d.mts +5 -4
- package/src/foundry/client/data/documents/macro.d.mts +5 -6
- package/src/foundry/client/data/documents/measured-template.d.mts +3 -2
- package/src/foundry/client/data/documents/note.d.mts +3 -2
- package/src/foundry/client/data/documents/playlist-sound.d.mts +4 -3
- package/src/foundry/client/data/documents/playlist.d.mts +13 -13
- package/src/foundry/client/data/documents/region-behavior.d.mts +78 -0
- package/src/foundry/client/data/documents/region.d.mts +160 -0
- package/src/foundry/client/data/documents/scene.d.mts +18 -10
- package/src/foundry/client/data/documents/setting.d.mts +3 -2
- package/src/foundry/client/data/documents/table-result.d.mts +3 -2
- package/src/foundry/client/data/documents/table.d.mts +5 -4
- package/src/foundry/client/data/documents/tile.d.mts +3 -2
- package/src/foundry/client/data/documents/token.d.mts +7 -16
- package/src/foundry/client/data/documents/user.d.mts +5 -4
- package/src/foundry/client/data/documents/wall.d.mts +3 -2
- package/src/foundry/client/game.d.mts +28 -21
- package/src/foundry/client/head.d.mts +12 -7
- package/src/foundry/client/hooks.d.mts +60 -41
- package/src/foundry/client/pixi/board.d.mts +21 -20
- package/src/foundry/client/pixi/core/containers/base-canvas-group.d.mts +95 -24
- package/src/foundry/client/pixi/core/containers/cached-container.d.mts +36 -18
- package/src/foundry/client/pixi/core/containers/full-canvas-container.d.mts +7 -10
- package/src/foundry/client/pixi/core/containers/point-source-mesh.d.mts +24 -14
- package/src/foundry/client/pixi/core/containers/quad-mesh.d.mts +15 -5
- package/src/foundry/client/pixi/core/containers/quadtree.d.mts +107 -50
- package/src/foundry/client/pixi/core/containers/sprite-mesh.d.mts +66 -23
- package/src/foundry/client/pixi/core/containers/unbound-container.d.mts +20 -2
- package/src/foundry/client/pixi/core/interaction/canvas-animation.d.mts +158 -99
- package/src/foundry/client/pixi/core/interaction/control-icon.d.mts +61 -22
- package/src/foundry/client/pixi/core/interaction/mouse-handler.d.mts +119 -52
- package/src/foundry/client/pixi/core/interaction/ping.d.mts +51 -28
- package/src/foundry/client/pixi/core/interaction/pings/chevron.d.mts +16 -8
- package/src/foundry/client/pixi/core/interaction/pings/pulse.d.mts +84 -33
- package/src/foundry/client/pixi/core/interaction/render-flags.d.mts +16 -7
- package/src/foundry/client/pixi/core/interaction/resize-handle.d.mts +35 -5
- package/src/foundry/client/pixi/core/interaction/targets.d.mts +19 -16
- package/src/foundry/client/pixi/core/loader.d.mts +85 -75
- package/src/foundry/client/pixi/core/shapes/limited-angle-polygon.d.mts +36 -16
- package/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts +92 -64
- package/src/foundry/client/pixi/core/shapes/precise-text.d.mts +28 -10
- package/src/foundry/client/pixi/core/shapes/ray.d.mts +27 -9
- package/src/foundry/client/pixi/core/shapes/source-polygon.d.mts +162 -72
- package/src/foundry/client/pixi/extensions/circle.d.mts +133 -122
- package/src/foundry/client/pixi/extensions/graphics.d.mts +3 -1
- package/src/foundry/client/pixi/extensions/observable-transform.d.mts +10 -2
- package/src/foundry/client/pixi/extensions/polygon.d.mts +155 -134
- package/src/foundry/client/pixi/extensions/rectangle.d.mts +266 -240
- package/src/foundry/client/pixi/groups/effects.d.mts +75 -24
- package/src/foundry/client/pixi/groups/environment.d.mts +68 -19
- package/src/foundry/client/pixi/groups/hidden.d.mts +27 -11
- package/src/foundry/client/pixi/groups/interface.d.mts +62 -38
- package/src/foundry/client/pixi/groups/overlay.d.mts +18 -6
- package/src/foundry/client/pixi/groups/primary.d.mts +64 -42
- package/src/foundry/client/pixi/groups/rendered.d.mts +18 -6
- package/src/foundry/client/pixi/layers/base/canvas-layer.d.mts +9 -13
- package/src/foundry/client/pixi/layers/base/interaction-layer.d.mts +18 -17
- package/src/foundry/client/pixi/layers/base/placeables-layer.d.mts +86 -98
- package/src/foundry/client/pixi/layers/controls/cursor.d.mts +1 -1
- package/src/foundry/client/pixi/layers/controls/door.d.mts +9 -0
- package/src/foundry/client/pixi/layers/controls/layer.d.mts +10 -8
- package/src/foundry/client/pixi/layers/controls/ruler.d.mts +1 -1
- package/src/foundry/client/pixi/layers/effects/background-effects.d.mts +6 -8
- package/src/foundry/client/pixi/layers/effects/coloration-effects.d.mts +4 -7
- package/src/foundry/client/pixi/layers/effects/darkness-effects.d.mts +3 -6
- package/src/foundry/client/pixi/layers/effects/illumination-effects.d.mts +4 -7
- package/src/foundry/client/pixi/layers/effects/visibility.d.mts +11 -8
- package/src/foundry/client/pixi/layers/effects/weather/particles/effect.d.mts +1 -1
- package/src/foundry/client/pixi/layers/effects/weather-effects.d.mts +5 -8
- package/src/foundry/client/pixi/layers/grid/highlight.d.mts +1 -1
- package/src/foundry/client/pixi/layers/grid/layer.d.mts +6 -8
- package/src/foundry/client/pixi/layers/grid/mesh.d.mts +1 -1
- package/src/foundry/client/pixi/layers/masks/depth.d.mts +11 -6
- package/src/foundry/client/pixi/layers/masks/occlusion.d.mts +18 -11
- package/src/foundry/client/pixi/layers/masks/vision.d.mts +100 -14
- package/src/foundry/client/pixi/layers/placeables/drawings.d.mts +3 -6
- package/src/foundry/client/pixi/layers/placeables/index.d.mts +1 -0
- package/src/foundry/client/pixi/layers/placeables/lighting.d.mts +4 -7
- package/src/foundry/client/pixi/layers/placeables/notes.d.mts +4 -6
- package/src/foundry/client/pixi/layers/placeables/regions.d.mts +100 -0
- package/src/foundry/client/pixi/layers/placeables/sounds.d.mts +4 -8
- package/src/foundry/client/pixi/layers/placeables/templates.d.mts +3 -6
- package/src/foundry/client/pixi/layers/placeables/tiles.d.mts +3 -5
- package/src/foundry/client/pixi/layers/placeables/tokens.d.mts +6 -10
- package/src/foundry/client/pixi/layers/placeables/walls.d.mts +9 -11
- package/src/foundry/client/pixi/perception/clockwise-sweep.d.mts +53 -24
- package/src/foundry/client/pixi/perception/detection-mode.d.mts +4 -2
- package/src/foundry/client/pixi/perception/fog.d.mts +9 -0
- package/src/foundry/client/pixi/perception/perception-manager.d.mts +1 -1
- package/src/foundry/client/pixi/perception/vision-mode.d.mts +31 -13
- package/src/foundry/client/pixi/perception/weiler-atherton-clipping.d.mts +77 -39
- package/src/foundry/client/pixi/placeable.d.mts +15 -7
- package/src/foundry/client/pixi/placeables/drawing.d.mts +10 -9
- package/src/foundry/client/pixi/placeables/index.d.mts +1 -0
- package/src/foundry/client/pixi/placeables/light.d.mts +8 -6
- package/src/foundry/client/pixi/placeables/note.d.mts +8 -7
- package/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.mts +29 -8
- package/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-graphics.d.mts +41 -11
- package/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-occludable-object.d.mts +59 -18
- package/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-sprite-mesh.d.mts +120 -37
- package/src/foundry/client/pixi/placeables/region.d.mts +177 -0
- package/src/foundry/client/pixi/placeables/sound.d.mts +7 -6
- package/src/foundry/client/pixi/placeables/template.d.mts +12 -11
- package/src/foundry/client/pixi/placeables/tile.d.mts +12 -10
- package/src/foundry/client/pixi/placeables/token.d.mts +149 -19
- package/src/foundry/client/pixi/placeables/wall.d.mts +11 -9
- package/src/foundry/client/pixi/webgl/extensions/batch-renderer.d.mts +50 -33
- package/src/foundry/client/pixi/webgl/extensions/batch-shader-generator.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/helpers/{framebugger-snapshot.d.mts → framebuffer-snapshot.d.mts} +9 -8
- package/src/foundry/client/pixi/webgl/helpers/index.d.mts +1 -1
- package/src/foundry/client/pixi/webgl/helpers/smooth-noise.d.mts +30 -23
- package/src/foundry/client/pixi/webgl/helpers/texture-extractor.d.mts +82 -53
- package/src/foundry/client/pixi/webgl/shaders/base-shader-mixin.d.mts +10 -10
- package/src/foundry/client/pixi/webgl/shaders/base-shader.d.mts +45 -28
- package/src/foundry/client/pixi/webgl/shaders/filters/base-filter.d.mts +11 -10
- package/src/foundry/client/pixi/webgl/shaders/filters/base-mask-filter.d.mts +11 -9
- package/src/foundry/client/pixi/webgl/shaders/filters/blur.d.mts +21 -19
- package/src/foundry/client/pixi/webgl/shaders/filters/effects-masking.d.mts +33 -32
- package/src/foundry/client/pixi/webgl/shaders/filters/environment.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/filters/glow-overlay.d.mts +11 -10
- package/src/foundry/client/pixi/webgl/shaders/filters/invisibility.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/filters/outline-overlay.d.mts +11 -10
- package/src/foundry/client/pixi/webgl/shaders/filters/transition.d.mts +65 -58
- package/src/foundry/client/pixi/webgl/shaders/filters/visibility.d.mts +20 -16
- package/src/foundry/client/pixi/webgl/shaders/filters/vision-mask-filter.d.mts +13 -10
- package/src/foundry/client/pixi/webgl/shaders/filters/void.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/filters/weather-occlusion-masks.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/fragment-channel-mixin.d.mts +20 -14
- package/src/foundry/client/pixi/webgl/shaders/grid/grid.d.mts +11 -10
- package/src/foundry/client/pixi/webgl/shaders/lighting/background-lighting.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/base-lighting.d.mts +32 -32
- package/src/foundry/client/pixi/webgl/shaders/lighting/coloration-lighting.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/darkness-lighting.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/bewitching-wave.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/black-hole.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/chroma.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/emanation.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/energy-field.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/fairy-light.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/flame.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/fog.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/force-grid.d.mts +9 -7
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/ghost-light.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/hexa-dome.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/light-dome.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/magical-gloom.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/pulse.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/radial-rainbow.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/revolving-light.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/roiling-mass.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/siren-light.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/smoke-patch.d.mts +19 -17
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/star-light.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/sunburst.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/swirling-rainbow.d.mts +9 -9
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/torch.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/vortex.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/effects/wave.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/lighting/illumination-lighting.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/region/adjust-darkness-level.d.mts +70 -28
- package/src/foundry/client/pixi/webgl/shaders/region/base.d.mts +52 -8
- package/src/foundry/client/pixi/webgl/shaders/region/highlight.d.mts +68 -8
- package/src/foundry/client/pixi/webgl/shaders/samplers/base-sampler.d.mts +23 -24
- package/src/foundry/client/pixi/webgl/shaders/samplers/baseline-illumination.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/samplers/color-adjustment.d.mts +37 -28
- package/src/foundry/client/pixi/webgl/shaders/samplers/depth.d.mts +20 -16
- package/src/foundry/client/pixi/webgl/shaders/samplers/fog-of-war.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/samplers/occlusion.d.mts +19 -17
- package/src/foundry/client/pixi/webgl/shaders/samplers/primary.d.mts +9 -0
- package/src/foundry/client/pixi/webgl/shaders/samplers/token-ring.d.mts +29 -1
- package/src/foundry/client/pixi/webgl/shaders/vision/background-vision.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/vision/base-vision.d.mts +10 -8
- package/src/foundry/client/pixi/webgl/shaders/vision/coloration-vision.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/vision/effects/amplification.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/vision/effects/wave.d.mts +18 -16
- package/src/foundry/client/pixi/webgl/shaders/vision/illumination-vision.d.mts +9 -8
- package/src/foundry/client/pixi/webgl/shaders/weather/base-weather.d.mts +37 -32
- package/src/foundry/client/pixi/webgl/shaders/weather/effect.d.mts +15 -14
- package/src/foundry/client/pixi/webgl/shaders/weather/fog.d.mts +16 -15
- package/src/foundry/client/pixi/webgl/shaders/weather/rain.d.mts +18 -17
- package/src/foundry/client/pixi/webgl/shaders/weather/snow.d.mts +14 -13
- package/src/foundry/client/pixi/workers/texture-worker.d.mts +33 -53
- package/src/foundry/client/ui/dialog.d.mts +136 -125
- package/src/foundry/client/ui/drag.d.mts +1 -1
- package/src/foundry/client/ui/dragdrop.d.mts +1 -1
- package/src/foundry/client/ui/editor.d.mts +3 -3
- package/src/foundry/client/ui/filepicker.d.mts +1 -1
- package/src/foundry/client/ui/filter.d.mts +2 -2
- package/src/foundry/client/ui/index.d.mts +0 -2
- package/src/foundry/client-esm/_module.d.mts +112 -0
- package/src/foundry/client-esm/_types.d.mts +8 -0
- package/src/foundry/client-esm/applications/_module.d.mts +10 -5
- package/src/foundry/client-esm/applications/_types.d.mts +2 -2
- package/src/foundry/client-esm/applications/api/_module.d.mts +6 -5
- package/src/foundry/client-esm/applications/api/application.d.mts +221 -55
- package/src/foundry/client-esm/applications/api/category-browser.d.mts +40 -0
- package/src/foundry/client-esm/applications/api/dialog.d.mts +152 -74
- package/src/foundry/client-esm/applications/api/document-sheet.d.mts +21 -8
- package/src/foundry/client-esm/applications/api/handlebars-application.d.mts +161 -131
- package/src/foundry/client-esm/applications/apps/_module.d.mts +9 -2
- package/src/foundry/client-esm/applications/apps/av/_module.d.mts +7 -0
- package/src/foundry/client-esm/applications/apps/av/camera-popout.d.mts +23 -0
- package/src/foundry/client-esm/applications/apps/av/cameras.d.mts +95 -0
- package/src/foundry/client-esm/applications/apps/combat-tracker-config.d.mts +21 -0
- package/src/foundry/client-esm/applications/apps/compendium-art-config.d.mts +6 -5
- package/src/foundry/client-esm/applications/apps/document-ownership.d.mts +21 -0
- package/src/foundry/client-esm/applications/apps/document-sheet-config.d.mts +24 -0
- package/src/foundry/client-esm/applications/apps/file-picker.d.mts +410 -0
- package/src/foundry/client-esm/applications/apps/grid-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/apps/image-popout.d.mts +56 -0
- package/src/foundry/client-esm/applications/apps/permission-config.d.mts +4 -4
- package/src/foundry/client-esm/applications/dice/_module.d.mts +2 -2
- package/src/foundry/client-esm/applications/dice/roll-resolver.d.mts +14 -2
- package/src/foundry/client-esm/applications/elements/_module.d.mts +5 -2
- package/src/foundry/client-esm/applications/elements/codemirror/element.d.mts +16 -0
- package/src/foundry/client-esm/applications/elements/codemirror/extensions.d.mts +20 -0
- package/src/foundry/client-esm/applications/elements/codemirror/view.d.mts +8 -0
- package/src/foundry/client-esm/applications/elements/document-embed.d.mts +14 -0
- package/src/foundry/client-esm/applications/elements/document-tags.d.mts +2 -0
- package/src/foundry/client-esm/applications/elements/enriched-content.d.mts +29 -0
- package/src/foundry/client-esm/applications/elements/multi-select.d.mts +15 -5
- package/src/foundry/client-esm/applications/elements/prosemirror-editor.d.mts +1 -1
- package/src/foundry/client-esm/applications/elements/secret-block.d.mts +7 -0
- package/src/foundry/client-esm/applications/elements/string-tags.d.mts +1 -1
- package/src/foundry/client-esm/applications/forms/fields.d.mts +6 -1
- package/src/foundry/client-esm/applications/handlebars.d.mts +3 -0
- package/src/foundry/client-esm/applications/hud/_module.d.mts +10 -0
- package/src/foundry/client-esm/applications/hud/container.d.mts +15 -0
- package/src/foundry/client-esm/applications/hud/drawing-hud.d.mts +19 -0
- package/src/foundry/client-esm/applications/hud/placeable-hud.d.mts +41 -0
- package/src/foundry/client-esm/applications/hud/tile-hud.d.mts +19 -0
- package/src/foundry/client-esm/applications/hud/token-hud.d.mts +20 -0
- package/src/foundry/client-esm/applications/quickstart.d.mts +20 -0
- package/src/foundry/client-esm/applications/settings/_module.d.mts +7 -0
- package/src/foundry/client-esm/applications/settings/config.d.mts +21 -0
- package/src/foundry/client-esm/applications/settings/dependency-resolution.d.mts +19 -0
- package/src/foundry/client-esm/applications/settings/menus/_module.d.mts +11 -0
- package/src/foundry/client-esm/applications/settings/menus/av-config.d.mts +27 -0
- package/src/foundry/client-esm/applications/settings/menus/default-sheets-config.d.mts +19 -0
- package/src/foundry/client-esm/applications/settings/menus/dice-config.d.mts +18 -0
- package/src/foundry/client-esm/applications/settings/menus/font-config.d.mts +43 -0
- package/src/foundry/client-esm/applications/settings/menus/prototype-overrides.d.mts +21 -0
- package/src/foundry/client-esm/applications/settings/menus/ui-config.d.mts +26 -0
- package/src/foundry/client-esm/applications/sheets/_module.d.mts +30 -5
- package/src/foundry/client-esm/applications/sheets/active-effect-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/actor-sheet.d.mts +1 -1
- package/src/foundry/client-esm/applications/sheets/adventure-exporter.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/adventure-importer.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/ambient-light-config.d.mts +9 -6
- package/src/foundry/client-esm/applications/sheets/ambient-sound-config.d.mts +3 -3
- package/src/foundry/client-esm/applications/sheets/base-sheet.d.mts +23 -0
- package/src/foundry/client-esm/applications/sheets/card-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/cards-config.d.mts +49 -0
- package/src/foundry/client-esm/applications/sheets/combatant-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/drawing-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/folder-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/item-sheet.d.mts +1 -1
- package/src/foundry/client-esm/applications/sheets/journal/_module.d.mts +16 -0
- package/src/foundry/client-esm/applications/sheets/journal/dialog-show.d.mts +19 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-category-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-page-hbs-sheet.d.mts +19 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-page-image-sheet.d.mts +18 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-page-markdown-sheet.d.mts +18 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-page-pdf-sheet.d.mts +18 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-page-prose-mirror-sheet.d.mts +18 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-page-sheet.d.mts +28 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-page-text-sheet.d.mts +18 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-page-video-sheet.d.mts +18 -0
- package/src/foundry/client-esm/applications/sheets/journal/journal-entry-sheet.d.mts +35 -0
- package/src/foundry/client-esm/applications/sheets/macro-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/note-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/playlist-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/playlist-sound-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/region-behavior-config.d.mts +29 -5
- package/src/foundry/client-esm/applications/sheets/region-config.d.mts +35 -5
- package/src/foundry/client-esm/applications/sheets/roll-table-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/roll-table-sheet.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/scene-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/table-result-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/template-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/tile-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/token/_module.d.mts +7 -0
- package/src/foundry/client-esm/applications/sheets/token/mixin.d.mts +27 -0
- package/src/foundry/client-esm/applications/sheets/token/prototype-config.d.mts +18 -0
- package/src/foundry/client-esm/applications/sheets/token/token-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sheets/user-config.d.mts +3 -3
- package/src/foundry/client-esm/applications/sheets/wall-config.d.mts +25 -0
- package/src/foundry/client-esm/applications/sidebar/_module.d.mts +10 -0
- package/src/foundry/client-esm/applications/sidebar/apps/_module.d.mts +15 -0
- package/src/foundry/client-esm/applications/sidebar/apps/chat-popout.d.mts +22 -0
- package/src/foundry/client-esm/applications/sidebar/apps/compendium.d.mts +21 -0
- package/src/foundry/client-esm/applications/sidebar/apps/controls-config.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/apps/folder-export.d.mts +18 -0
- package/src/foundry/client-esm/applications/sidebar/apps/frame-viewer.d.mts +22 -0
- package/src/foundry/client-esm/applications/sidebar/apps/invitation-links.d.mts +17 -0
- package/src/foundry/client-esm/applications/sidebar/apps/module-management.d.mts +21 -0
- package/src/foundry/client-esm/applications/sidebar/apps/support-details.d.mts +17 -0
- package/src/foundry/client-esm/applications/sidebar/apps/tours-management.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/apps/world-config.d.mts +19 -0
- package/src/foundry/client-esm/applications/sidebar/document-directory.d.mts +30 -0
- package/src/foundry/client-esm/applications/sidebar/sidebar-tab.d.mts +86 -0
- package/src/foundry/client-esm/applications/sidebar/sidebar.d.mts +18 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/_module.d.mts +17 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/actor-directory.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/cards-directory.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/chat.d.mts +19 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/combat-tracker.d.mts +19 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/compendium-directory.d.mts +19 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/item-directory.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/journal-directory.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/macro-directory.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/playlist-directory.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/roll-table-directory.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/scene-directory.d.mts +20 -0
- package/src/foundry/client-esm/applications/sidebar/tabs/settings.d.mts +18 -0
- package/src/foundry/client-esm/applications/ui/_module.d.mts +9 -2
- package/src/foundry/client-esm/applications/ui/game-pause.d.mts +22 -0
- package/src/foundry/client-esm/applications/ui/hotbar.d.mts +29 -0
- package/src/foundry/client-esm/applications/ui/main-menu.d.mts +27 -0
- package/src/foundry/client-esm/applications/ui/notifications.d.mts +208 -0
- package/src/foundry/client-esm/applications/ui/players.d.mts +26 -0
- package/src/foundry/client-esm/applications/ui/region-legend.d.mts +48 -3
- package/src/foundry/client-esm/applications/ui/scene-controls.d.mts +20 -0
- package/src/foundry/client-esm/applications/ui/scene-navigation.d.mts +28 -0
- package/src/foundry/client-esm/applications/ux/_module.d.mts +14 -0
- package/src/foundry/client-esm/applications/ux/context-menu.d.mts +359 -0
- package/src/foundry/client-esm/applications/ux/drag-drop.d.mts +21 -0
- package/src/foundry/client-esm/applications/ux/draggable.d.mts +9 -0
- package/src/foundry/client-esm/applications/ux/form-data-extended.d.mts +17 -0
- package/src/foundry/client-esm/applications/ux/html-secret.d.mts +21 -0
- package/src/foundry/client-esm/applications/ux/prosemirror-editor.d.mts +9 -0
- package/src/foundry/client-esm/applications/ux/search-filter.d.mts +9 -0
- package/src/foundry/client-esm/applications/ux/tabs.d.mts +29 -0
- package/src/foundry/client-esm/applications/ux/text-editor.d.mts +9 -0
- package/src/foundry/client-esm/appv1/_module.d.mts +7 -0
- package/src/foundry/client-esm/appv1/api/_module.d.mts +9 -0
- package/src/foundry/client-esm/appv1/api/application-v1.d.mts +5 -0
- package/src/foundry/client-esm/appv1/api/dialog-v1.d.mts +5 -0
- package/src/foundry/client-esm/appv1/api/document-sheet-v1.d.mts +5 -0
- package/src/foundry/client-esm/appv1/api/form-application-v1.d.mts +5 -0
- package/src/foundry/client-esm/appv1/sheets/_module.d.mts +10 -0
- package/src/foundry/client-esm/appv1/sheets/actor-sheet.d.mts +5 -0
- package/src/foundry/client-esm/appv1/sheets/adventure-importer.d.mts +5 -0
- package/src/foundry/client-esm/appv1/sheets/item-sheet.d.mts +5 -0
- package/src/foundry/client-esm/appv1/sheets/journal-page-sheet.d.mts +7 -0
- package/src/foundry/client-esm/appv1/sheets/journal-sheet.d.mts +5 -0
- package/src/foundry/client-esm/audio/_module.d.mts +2 -3
- package/src/foundry/client-esm/audio/_types.d.mts +1 -1
- package/src/foundry/client-esm/audio/biquad.d.mts +1 -1
- package/src/foundry/client-esm/audio/convolver.d.mts +1 -1
- package/src/foundry/client-esm/audio/helper.d.mts +6 -5
- package/src/foundry/client-esm/audio/sound.d.mts +2 -2
- package/src/foundry/client-esm/audio/timeout.d.mts +5 -2
- package/src/foundry/client-esm/av/_module.d.mts +10 -0
- package/src/foundry/client-esm/av/client.d.mts +18 -0
- package/src/foundry/client-esm/av/clients/_module.d.mts +6 -0
- package/src/foundry/client-esm/av/clients/simplepeer.d.mts +11 -0
- package/src/foundry/client-esm/av/master.d.mts +12 -0
- package/src/foundry/client-esm/av/settings.d.mts +30 -0
- package/src/foundry/client-esm/canvas/_module.d.mts +2 -2
- package/src/foundry/client-esm/canvas/edges/_module.d.mts +2 -2
- package/src/foundry/client-esm/canvas/edges/collision.d.mts +61 -18
- package/src/foundry/client-esm/canvas/edges/edge.d.mts +106 -42
- package/src/foundry/client-esm/canvas/edges/edges.d.mts +9 -0
- package/src/foundry/client-esm/canvas/edges/vertex.d.mts +51 -23
- package/src/foundry/client-esm/canvas/regions/_module.d.mts +2 -3
- package/src/foundry/client-esm/canvas/regions/geometry.d.mts +31 -0
- package/src/foundry/client-esm/canvas/regions/mesh.d.mts +61 -0
- package/src/foundry/client-esm/canvas/regions/polygon-tree.d.mts +101 -0
- package/src/foundry/client-esm/canvas/regions/shape.d.mts +118 -0
- package/src/foundry/client-esm/canvas/scene-manager.d.mts +12 -3
- package/src/foundry/client-esm/canvas/smaa/smaa.d.mts +2 -3
- package/src/foundry/client-esm/canvas/sources/_module.d.mts +2 -2
- package/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts +32 -18
- package/src/foundry/client-esm/canvas/sources/base-light-source.d.mts +53 -15
- package/src/foundry/client-esm/canvas/sources/global-light-source.d.mts +18 -3
- package/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts +47 -23
- package/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts +17 -7
- package/src/foundry/client-esm/canvas/sources/point-light-source.d.mts +26 -14
- package/src/foundry/client-esm/canvas/sources/point-movement-source.d.mts +20 -4
- package/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts +26 -8
- package/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts +26 -25
- package/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts +89 -52
- package/src/foundry/client-esm/canvas/tokens/_module.d.mts +2 -3
- package/src/foundry/client-esm/canvas/tokens/ring-config.d.mts +112 -2
- package/src/foundry/client-esm/canvas/tokens/ring-data.d.mts +170 -3
- package/src/foundry/client-esm/canvas/tokens/ring.d.mts +189 -2
- package/src/foundry/client-esm/client.d.mts +56 -63
- package/src/foundry/client-esm/config.d.mts +1 -0
- package/src/foundry/client-esm/data/_module.d.mts +8 -3
- package/src/foundry/client-esm/data/_types.d.mts +10 -0
- package/src/foundry/client-esm/data/calendar.d.mts +213 -0
- package/src/foundry/client-esm/data/client-backend.d.mts +17 -18
- package/src/foundry/client-esm/data/combat-config.d.mts +53 -0
- package/src/foundry/client-esm/data/region-behaviors/_module.d.mts +3 -3
- package/src/foundry/client-esm/data/region-behaviors/adjust-darkness-level.d.mts +57 -0
- package/src/foundry/client-esm/data/region-behaviors/base.d.mts +59 -0
- package/src/foundry/client-esm/data/region-behaviors/display-scrolling-text.d.mts +64 -0
- package/src/foundry/client-esm/data/region-behaviors/execute-macro.d.mts +27 -0
- package/src/foundry/client-esm/data/region-behaviors/execute-script.d.mts +23 -0
- package/src/foundry/client-esm/data/region-behaviors/pause-game.d.mts +23 -0
- package/src/foundry/client-esm/data/region-behaviors/suppress-weather.d.mts +17 -0
- package/src/foundry/client-esm/data/region-behaviors/teleport-token.d.mts +32 -0
- package/src/foundry/client-esm/data/region-behaviors/toggle-behavior.d.mts +31 -0
- package/src/foundry/client-esm/data/terrain-data.d.mts +22 -0
- package/src/foundry/client-esm/dice/_module.d.mts +2 -3
- package/src/foundry/client-esm/dice/parser.d.mts +8 -0
- package/src/foundry/client-esm/dice/roll.d.mts +64 -30
- package/src/foundry/client-esm/dice/terms/_module.d.mts +2 -3
- package/src/foundry/client-esm/dice/terms/coin.d.mts +8 -1
- package/src/foundry/client-esm/dice/terms/dice.d.mts +11 -2
- package/src/foundry/client-esm/dice/terms/die.d.mts +9 -2
- package/src/foundry/client-esm/dice/terms/fate.d.mts +9 -2
- package/src/foundry/client-esm/dice/terms/function.d.mts +5 -2
- package/src/foundry/client-esm/dice/terms/numeric.d.mts +1 -1
- package/src/foundry/client-esm/dice/terms/operator.d.mts +1 -1
- package/src/foundry/client-esm/dice/terms/parenthetical.d.mts +1 -1
- package/src/foundry/client-esm/dice/terms/pool.d.mts +15 -6
- package/src/foundry/client-esm/dice/terms/string.d.mts +1 -1
- package/src/foundry/client-esm/dice/terms/term.d.mts +12 -3
- package/src/foundry/client-esm/documents/_module.d.mts +11 -0
- package/src/foundry/client-esm/documents/_types.d.mts +8 -0
- package/src/foundry/client-esm/documents/abstract/_module.d.mts +6 -0
- package/src/foundry/client-esm/documents/collections/_module.d.mts +6 -0
- package/src/foundry/client-esm/game.d.mts +7 -0
- package/src/foundry/client-esm/helpers/_module.d.mts +2 -2
- package/src/foundry/client-esm/helpers/_types.d.mts +1 -1
- package/src/foundry/client-esm/hooks.d.mts +1 -0
- package/src/foundry/client-esm/nue/_module.d.mts +9 -0
- package/src/foundry/client-esm/nue/nue-manager.d.mts +18 -0
- package/src/foundry/client-esm/nue/tour.d.mts +9 -0
- package/src/foundry/client-esm/nue/tours/_module.d.mts +8 -0
- package/src/foundry/client-esm/nue/tours/canvas-tour.d.mts +12 -0
- package/src/foundry/client-esm/nue/tours/setup-tour.d.mts +11 -0
- package/src/foundry/client-esm/nue/tours/sidebar-tour.d.mts +11 -0
- package/src/foundry/client-esm/nue/tours-collection.d.mts +25 -0
- package/src/foundry/client-esm/packages/_module.d.mts +22 -0
- package/src/foundry/client-esm/packages/_types.d.mts +11 -0
- package/src/foundry/client-esm/packages/client-package.d.mts +11 -0
- package/src/foundry/client-esm/packages/module.d.mts +8 -0
- package/src/foundry/client-esm/packages/system.d.mts +8 -0
- package/src/foundry/client-esm/packages/world.d.mts +8 -0
- package/src/foundry/client-esm/ui.d.mts +1 -0
- package/src/foundry/client-esm/utils/_module.d.mts +7 -0
- package/src/foundry/client-esm/utils/_types.d.mts +2 -0
- package/src/foundry/client-esm/utils/helpers.d.mts +6 -0
- package/src/foundry/common/{types.d.mts → _types.d.mts} +3 -3
- package/src/foundry/common/abstract/{module.d.mts → _module.d.mts} +2 -2
- package/src/foundry/common/abstract/backend.d.mts +38 -44
- package/src/foundry/common/abstract/data.d.mts +22 -51
- package/src/foundry/common/abstract/document.d.mts +212 -121
- package/src/foundry/common/abstract/embedded-collection-delta.d.mts +1 -1
- package/src/foundry/common/abstract/embedded-collection.d.mts +37 -7
- package/src/foundry/common/abstract/socket.d.mts +1 -1
- package/src/foundry/common/abstract/type-data.d.mts +40 -24
- package/src/foundry/common/config.d.mts +3 -1
- package/src/foundry/common/constants.d.mts +234 -205
- package/src/foundry/common/data/{module.d.mts → _module.d.mts} +2 -2
- package/src/foundry/common/data/_types.d.mts +47 -0
- package/src/foundry/common/data/data.d.mts +25 -19
- package/src/foundry/common/data/fields.d.mts +469 -423
- package/src/foundry/common/data/validation-failure.d.mts +4 -6
- package/src/foundry/common/documents/_module.d.mts +4 -2
- package/src/foundry/common/documents/_types.d.mts +10 -45
- package/src/foundry/common/documents/active-effect.d.mts +7 -4
- package/src/foundry/common/documents/actor-delta.d.mts +7 -5
- package/src/foundry/common/documents/actor.d.mts +6 -19
- package/src/foundry/common/documents/adventure.d.mts +13 -2
- package/src/foundry/common/documents/ambient-light.d.mts +3 -1
- package/src/foundry/common/documents/ambient-sound.d.mts +3 -1
- package/src/foundry/common/documents/card.d.mts +6 -4
- package/src/foundry/common/documents/cards.d.mts +3 -1
- package/src/foundry/common/documents/chat-message.d.mts +10 -8
- package/src/foundry/common/documents/combat.d.mts +3 -1
- package/src/foundry/common/documents/combatant.d.mts +4 -12
- package/src/foundry/common/documents/drawing.d.mts +6 -4
- package/src/foundry/common/documents/fog-exploration.d.mts +3 -1
- package/src/foundry/common/documents/folder.d.mts +9 -1
- package/src/foundry/common/documents/item.d.mts +5 -3
- package/src/foundry/common/documents/journal-entry-page.d.mts +3 -2
- package/src/foundry/common/documents/journal-entry.d.mts +3 -1
- package/src/foundry/common/documents/macro.d.mts +5 -3
- package/src/foundry/common/documents/measured-template.d.mts +6 -8
- package/src/foundry/common/documents/module.d.mts +2 -2
- package/src/foundry/common/documents/note.d.mts +4 -2
- package/src/foundry/common/documents/playlist-sound.d.mts +4 -2
- package/src/foundry/common/documents/playlist.d.mts +3 -1
- package/src/foundry/common/documents/region-behavior.d.mts +88 -0
- package/src/foundry/common/documents/region.d.mts +108 -0
- package/src/foundry/common/documents/roll-table.d.mts +3 -1
- package/src/foundry/common/documents/scene.d.mts +9 -1
- package/src/foundry/common/documents/setting.d.mts +3 -2
- package/src/foundry/common/documents/table-result.d.mts +4 -4
- package/src/foundry/common/documents/tile.d.mts +3 -1
- package/src/foundry/common/documents/token.d.mts +15 -7
- package/src/foundry/common/documents/user.d.mts +7 -5
- package/src/foundry/common/documents/wall.d.mts +12 -15
- package/src/foundry/common/grid/_module.d.mts +3 -3
- package/src/foundry/common/grid/_types.d.mts +47 -0
- package/src/foundry/common/grid/base.d.mts +10 -14
- package/src/foundry/common/grid/gridless.d.mts +2 -2
- package/src/foundry/common/grid/hexagonal.d.mts +21 -10
- package/src/foundry/common/grid/square.d.mts +2 -2
- package/src/foundry/common/packages/{module.d.mts → _module.d.mts} +2 -2
- package/src/foundry/common/packages/_types.d.mts +25 -0
- package/src/foundry/common/packages/base-package.d.mts +6 -6
- package/src/foundry/common/packages/base-system.d.mts +19 -4
- package/src/foundry/common/packages/base-world.d.mts +2 -2
- package/src/foundry/common/packages/sub-types.d.mts +1 -1
- package/src/foundry/common/primitives/array.d.mts +1 -1
- package/src/foundry/common/primitives/number.d.mts +1 -1
- package/src/foundry/common/primitives/string.d.mts +1 -1
- package/src/foundry/common/prosemirror/_module.d.mts +15 -15
- package/src/foundry/common/prosemirror/_types.d.mts +29 -0
- package/src/foundry/common/prosemirror/dirty-plugin.d.mts +1 -1
- package/src/foundry/common/prosemirror/dom-parser.d.mts +2 -1
- package/src/foundry/common/prosemirror/highlight-matches-plugin.d.mts +1 -1
- package/src/foundry/common/prosemirror/image-plugin.d.mts +1 -1
- package/src/foundry/common/prosemirror/paste-transformer.d.mts +1 -1
- package/src/foundry/common/prosemirror/plugin.d.mts +1 -1
- package/src/foundry/common/prosemirror/schema/index.d.mts +1 -1
- package/src/foundry/common/prosemirror/schema/lists.d.mts +2 -0
- package/src/foundry/common/utils/{module.d.mts → _module.d.mts} +2 -2
- package/src/foundry/common/utils/_types.d.mts +1 -0
- package/src/foundry/common/utils/bitmask.d.mts +20 -11
- package/src/foundry/common/utils/collection.d.mts +7 -19
- package/src/foundry/common/utils/color.d.mts +20 -2
- package/src/foundry/common/utils/event-emitter.d.mts +1 -1
- package/src/foundry/common/utils/geometry.d.mts +12 -2
- package/src/foundry/common/utils/helpers.d.mts +23 -13
- package/src/foundry/common/utils/string-tree.d.mts +1 -1
- package/src/foundry/common/utils/word-tree.d.mts +1 -1
- package/src/foundry/index.d.mts +0 -1
- package/src/foundry/{clipper → public/scripts/clipper}/clipper.d.mts +52 -43
- package/src/foundry/public/scripts/index.d.mts +1 -0
- package/src/foundry/public/scripts/workers/image-compressor.d.mts +23 -0
- package/src/foundry/public/scripts/workers/index.d.mts +1 -0
- package/{index-lenient.d.mts → src/index-lenient.d.mts} +2 -0
- package/src/index.d.mts +6 -0
- package/src/tsconfig.json +19 -0
- package/src/types/augments/particles.d.mts +29 -0
- package/src/types/augments/pixi.d.mts +1013 -10
- package/src/types/augments/smooth.d.mts +31 -0
- package/src/types/augments/tinyMCE.d.mts +1 -1
- package/src/types/config.d.mts +20 -311
- package/src/types/documentConfiguration.d.mts +91 -32
- package/src/types/index.d.mts +1 -1
- package/src/types/lib.d.mts +12 -0
- package/src/types/workers/image-compressor.d.mts +176 -0
- package/src/utils/index.d.mts +1091 -0
- package/index.d.mts +0 -5
- package/src/foundry/client/ui/context.d.mts +0 -213
- package/src/foundry/client/ui/notifications.d.mts +0 -136
- package/src/foundry/common/primitives/regex.d.mts +0 -12
- package/src/types/helperTypes.d.mts +0 -389
- package/src/types/utils.d.mts +0 -520
- /package/src/foundry/common/primitives/{module.d.mts → _module.d.mts} +0 -0
- /package/src/foundry/{clipper → public/scripts/clipper}/index.d.mts +0 -0
@@ -0,0 +1,1091 @@
|
|
1
|
+
import type { Document } from "../foundry/common/abstract/_module.d.mts";
|
2
|
+
|
3
|
+
type ConfiguredModuleData<Name extends string> = Name extends keyof ModuleConfig ? ModuleConfig[Name] : EmptyObject;
|
4
|
+
|
5
|
+
/**
|
6
|
+
* This type exists due to https://github.com/microsoft/TypeScript/issues/55667
|
7
|
+
* This will be deprecated once this issue is solved.
|
8
|
+
*/
|
9
|
+
export type FixedInstanceType<T extends AnyConstructor> = T extends abstract new (...args: infer _) => infer R
|
10
|
+
? R
|
11
|
+
: never;
|
12
|
+
|
13
|
+
export type ConfiguredModule<Name extends string> = Name extends keyof RequiredModules
|
14
|
+
? ConfiguredModuleData<Name>
|
15
|
+
:
|
16
|
+
| ({ active: true } & ConfiguredModuleData<Name>)
|
17
|
+
// flawed, can't use `key in module` this way, but omitting the Partial Record type kills nullish
|
18
|
+
// collocating, which is probably the better DX.
|
19
|
+
| ({ active: false } & Record<keyof ConfiguredModuleData<Name>, undefined>);
|
20
|
+
|
21
|
+
/** Keys of functions of console.log / globalThis.logger */
|
22
|
+
export type LoggingLevels = "debug" | "log" | "info" | "warn" | "error";
|
23
|
+
|
24
|
+
/**
|
25
|
+
* `GetKey` accesses a property while intentionally ignoring index signatures. This means `GetKey<Record<string, unknown>, "foo">` will return `never`.
|
26
|
+
*/
|
27
|
+
// Note(LukeAbby): There are two tricky cases:
|
28
|
+
// - `T = {}` would regularly always return `unknown`. The fix here adding a single dummy property `{ _?: any } & T`.
|
29
|
+
// - `T = never` would regularly always return `unknown`. The fix here is adding `_GetKey` which makes the type distributive and therefore `never` as an input becomes `never` in the output.
|
30
|
+
export type GetKey<T, K extends PropertyKey, D = never> = _GetKey<{ _?: any } & T, K, D>;
|
31
|
+
|
32
|
+
type _GetKey<T, K extends PropertyKey, D> = T extends { readonly [_ in K]?: infer V } ? V : D;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* `Partial` is usually the wrong type.
|
36
|
+
* In order to make it easier to audit unintentional uses of `Partial` this type is provided.
|
37
|
+
*
|
38
|
+
* ### Picking the right helper type
|
39
|
+
* - Favor `NullishProps` whenever it is valid. Allowing both `null` and
|
40
|
+
* `undefined` is convenient for the end user and it is very common that
|
41
|
+
* wherever `undefined` is valid so is `null`. For some examples it is valid
|
42
|
+
* for `options.prop ??= "default"`, `options.prop ||= "default"`,
|
43
|
+
* `if (options.prop) { ... }`, `if (options.prop == null)`, or so on.
|
44
|
+
* - Use `IntentionalPartial` when an explicit `undefined` is problematic but
|
45
|
+
* leaving off the property entirely is fine. This primarily occurs when
|
46
|
+
* patterns like `options = { ...defaultOptions, ...options }`,
|
47
|
+
* `Object.assign({}, defaultOptions, options)`,
|
48
|
+
* `foundry.utils.mergeObject(defaultOptions, options)`, or so on.
|
49
|
+
*
|
50
|
+
* Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`}
|
51
|
+
* also expands the object. So once `ExpandsTo` exists you should also use
|
52
|
+
* that helper type.
|
53
|
+
*
|
54
|
+
* What these patterns have in common is that if `options` looks like
|
55
|
+
* `{ prop: undefined }` that will override whatever is in `defaultOptions`
|
56
|
+
* and may cause issues. Note that even if you see one of these patterns you
|
57
|
+
* also need to ensure that `undefined` would cause issues down the road
|
58
|
+
* before using `IntentionalPartial` as it could be an intended way of
|
59
|
+
* resetting a property.
|
60
|
+
* - Use `InexactPartial` when `null` is problematic but `undefined` is not.
|
61
|
+
* The most common time this shows up is with the pattern
|
62
|
+
* `exampleFunction({ prop = "foo" } = {}) { ... }`.
|
63
|
+
*/
|
64
|
+
export type IntentionalPartial<T> = Partial<T>;
|
65
|
+
|
66
|
+
/**
|
67
|
+
* This type is used to make a constraint where `T` must be statically known to overlap with `U`.
|
68
|
+
*
|
69
|
+
* @example
|
70
|
+
* ```ts
|
71
|
+
* // The `const T` allows inference to be a bit more specific. This is useful for a utility type like this.`
|
72
|
+
* function takesNumber<const T>(input: OverlapsWith<T, number>): void {
|
73
|
+
* // This function body is an example of a method this might be useful for.
|
74
|
+
* // If the input isn't an number it simply returns in this case.
|
75
|
+
* if (typeof input !== "number") {
|
76
|
+
* return;
|
77
|
+
* }
|
78
|
+
*
|
79
|
+
* // Assumes, unchecked, that `element` is a number.
|
80
|
+
* // This means an input like `number[] | string[]` would be unsound as it could be a string.
|
81
|
+
* element + 1;
|
82
|
+
* }
|
83
|
+
*
|
84
|
+
* takesNumber(1); // Ok!
|
85
|
+
* takesNumber("foo"); // Error, statically known to never an number and so presumed to be a mistake.
|
86
|
+
* takesNumber(Math.random() > 0.5 ? 1 : "foo"); // Ok, `"foo"` doesn't actually cause any runtime issues, it was just disallowed above because then it'd never do anything useful.
|
87
|
+
* ```
|
88
|
+
*/
|
89
|
+
export type OverlapsWith<T, U> = [Extract<T, U>, any] extends [U, Extract<T, U>] ? T : U extends T ? T : U;
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Used to build a constraint where `T` to overlap with `Item[]` but disallows unrelated arrays.
|
93
|
+
* This is safer than what `OverlapsWith` provides as it ensures that if the type is an array it is an array of `Item`.
|
94
|
+
* Assumes readonly arrays are permitted.
|
95
|
+
*
|
96
|
+
* Note that `never[]` and `any[]` are still accepted due to the unsoundness of those types.
|
97
|
+
*
|
98
|
+
* @example
|
99
|
+
* ```ts
|
100
|
+
* // The `const T` allows inference to be a bit more specific. This is useful for a utility type like this.`
|
101
|
+
* function takesNumericArray<const T>(input: ArrayOverlaps<T, number>): void {
|
102
|
+
* // This function body is an example of a method this might be useful for.
|
103
|
+
* // If the input isn't an array it simply returns in this case.
|
104
|
+
* if (!Array.isArray(input)) {
|
105
|
+
* return;
|
106
|
+
* }
|
107
|
+
*
|
108
|
+
* for (const element of input) {
|
109
|
+
* // Assumes, unchecked, that `element` is a number.
|
110
|
+
* // This means an input like `number[] | string[]` would be unsound as it could be a string.
|
111
|
+
* element + 1;
|
112
|
+
* }
|
113
|
+
* }
|
114
|
+
*
|
115
|
+
* takesNumericArray([1, 2, 3]); // Ok!
|
116
|
+
* takesNumericArray("foo"); // Error, statically known to never an array and so presumed to be a mistake.
|
117
|
+
* takesNumericArray(Math.random() > 0.5 ? [1, 2, 3] : "foo"); // Ok, `"foo"` doesn't actually cause any runtime issues, it was just disallowed above because then it'd never do anything useful.
|
118
|
+
* takesNumericArray(Math.random() > 0.5 ? [1, 2, 3] : ["foo", "bar"]); // Error, at runtime it could be an array of the wrong type and that isn't handled. Notably this would succeed with `OverlapsWith`.
|
119
|
+
* ```
|
120
|
+
*/
|
121
|
+
export type ArrayOverlaps<T, Item> =
|
122
|
+
Extract<T, readonly unknown[]> extends readonly Item[] ? OverlapsWith<T, readonly Item[]> : readonly Item[];
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Use this whenever a type is given that should match some constraint but is
|
126
|
+
* not guaranteed to. For example when additional properties can be declaration
|
127
|
+
* merged into an interface. When the type does not conform then `ConformTo` is
|
128
|
+
* used instead.
|
129
|
+
*
|
130
|
+
* See `MustConform` for a version that throws a compilation error when the type
|
131
|
+
* cannot be statically known to conform.
|
132
|
+
*/
|
133
|
+
export type MakeConform<T, ConformTo, D extends ConformTo = ConformTo> = [T] extends [ConformTo] ? T : D;
|
134
|
+
|
135
|
+
/**
|
136
|
+
* This is useful when you want to ensure that a type conforms to a certain
|
137
|
+
* constraint. If it is not guaranteed to conform then a compilation error is
|
138
|
+
* thrown. This makes it too conservative in some cases.
|
139
|
+
*/
|
140
|
+
export type MustConform<T extends ConformTo, ConformTo> = T;
|
141
|
+
|
142
|
+
/**
|
143
|
+
* This allows you to treat all interfaces as a plain object. But beware, if the
|
144
|
+
* interface represents a function, array, or constructor then these will be
|
145
|
+
* stripped from the interface.
|
146
|
+
*
|
147
|
+
* This is generally intended for cases where an interface is given in order to
|
148
|
+
* be declaration merged and then must be assigned to a plain object type.
|
149
|
+
*
|
150
|
+
* The constraint `T extends object` is used because `object` includes functions
|
151
|
+
* and arrays etc. This is crucial to allow interfaces to be given to this type.
|
152
|
+
*/
|
153
|
+
export type InterfaceToObject<T extends object> = {
|
154
|
+
// This mapped type would be a no-op on most types (even primitives like string)
|
155
|
+
// but for functions, classes, and arrays they convert them to "proper" objects by
|
156
|
+
// stripping constructors/function signatures. One side effect is a type like
|
157
|
+
// `() => number` will result in `{}`.
|
158
|
+
[K in keyof T]: T[K];
|
159
|
+
};
|
160
|
+
|
161
|
+
/**
|
162
|
+
* This is a helper type that allows you to ensure that a record conforms to a
|
163
|
+
* certain shape. This is useful when you want to ensure that a record has all
|
164
|
+
* keys of a certain type.
|
165
|
+
*
|
166
|
+
* When a value does not conform it is replaced with `never` to indicate that
|
167
|
+
* there is an issue.
|
168
|
+
*/
|
169
|
+
export type ConformRecord<T extends object, V, D extends V = V> = {
|
170
|
+
[K in keyof T]: T[K] extends V ? T[K] : D;
|
171
|
+
};
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Converts a regular function type into a function derived from a method.
|
175
|
+
*
|
176
|
+
* Methods have a special exception in TypeScript that allows unsound subtyping
|
177
|
+
* that unfortunately has been deeply engrained into not just JavaScript codebases
|
178
|
+
* but the core APIs of JavaScript itself in the DOM.
|
179
|
+
*
|
180
|
+
* It might seem odd to want to opt-in to this unsoundness but it's unfortunately
|
181
|
+
* useful in several cases, such as when you have a property like
|
182
|
+
* `prop: ((arg: Options) => number) | undefined` and you want to meet the expectations
|
183
|
+
* from other similar methods.
|
184
|
+
*
|
185
|
+
* @example
|
186
|
+
* ```typescript
|
187
|
+
* declare class ExampleBaseClass {
|
188
|
+
* // This demonstrates a typical example of where the allowed unsoundness is useful.
|
189
|
+
* methodOne(arg: { x: string }): number;
|
190
|
+
*
|
191
|
+
* // This helps demonstrates an example that may be easier to recognize as unsound.
|
192
|
+
* methodTwo(arg: string): number;
|
193
|
+
*
|
194
|
+
* functionProperty: (arg: string) => number;
|
195
|
+
* methodLikeProperty: ToMethod<(arg: string) => number>;
|
196
|
+
* }
|
197
|
+
*
|
198
|
+
* // TypeScript allows this without any errors.
|
199
|
+
* declare class MethodSubclassing extends ExampleBaseClass {
|
200
|
+
* // It's a very common thing for subclasses to ask for extra properties.
|
201
|
+
* // This appears in the DOM APIs.
|
202
|
+
* methodOne(arg: { x: string; y: string }): number;
|
203
|
+
*
|
204
|
+
* // Only taking `"foo" | "bar"` should seem pretty unsound.
|
205
|
+
* // The above is actually equally unsound but it's less obvious to many people.
|
206
|
+
* methodTwo(arg: "foo" | "bar"): number;
|
207
|
+
* }
|
208
|
+
*
|
209
|
+
* // This is allowed. If it wasn't subclassing would be less useful.
|
210
|
+
* const exampleMethodSubclass: ExampleBaseClass = new MethodSubclassing();
|
211
|
+
*
|
212
|
+
* // TypeScript does not error here. However at runtime `MethodSubclassing#methodOne`
|
213
|
+
* // will almost certainly error as it has the required property `y`.
|
214
|
+
* // The reason why there's no errors is an intentional unsoundness in TypeScript.
|
215
|
+
* exampleMethodSubclass.methodOne({ x: "foo" });
|
216
|
+
*
|
217
|
+
* // Similarly this is allowed.
|
218
|
+
* // Both methods show taking arguments that are 'subtypes' of the original.
|
219
|
+
* // In the case of functions this is unsound as demonstrated because in both
|
220
|
+
* // examples you're substituting a function that has to be able to be called
|
221
|
+
* // with a wide variety of arguments with one that will error for many of them.
|
222
|
+
* exampleMethodSubclass.methodTwo("lorem");
|
223
|
+
*
|
224
|
+
* declare class PropertySubclassing extends ExampleBaseClass {
|
225
|
+
* // This errors right here. This preventative error is because of the prior
|
226
|
+
* // explained unsoundness. It errors here because there's really only 3
|
227
|
+
* // places to error at compile time to prevent a runtime error:
|
228
|
+
* // 1. At the call site when a subclass is used unsoundly. Unfortunately
|
229
|
+
* // at this point it's too late to know for certain if it's a subclass
|
230
|
+
* // or not. For example there could be a guarded condition to avoid
|
231
|
+
* // subclasses that TypeScript can't possibly track.
|
232
|
+
* // 2. When trying to assign `PropertySubclassing` to `ExampleBaseClass`.
|
233
|
+
* // This would be a feasible alternative but would likely come as a
|
234
|
+
* // surprise as the subclass could have been used for quite a while
|
235
|
+
* // before trying to be assigned to its superclass.
|
236
|
+
* // 3. Error at the definition. This is where TypeScript has chosen to error.
|
237
|
+
* // The error is unfortunately not the most intuitive but it is correct.
|
238
|
+
* functionProperty: (arg: "foo" | "bar") => number;
|
239
|
+
* }
|
240
|
+
*
|
241
|
+
* declare class MethodLikeSubclassing extends ExampleBaseClass {
|
242
|
+
* // This is unsound but by using the `ToMethod` in the parent class it's allowed.
|
243
|
+
* methodLikeProperty: (arg: "foo" | "bar") => number;
|
244
|
+
* }
|
245
|
+
* ```
|
246
|
+
*
|
247
|
+
* The TypeScript FAQ explains this in a way that may either be intuitive and
|
248
|
+
* explain all lingering questions or be confusing and muddle the waters.
|
249
|
+
* It's also worth mentioning that it claims all function parameters work this way,
|
250
|
+
* this behavior is disabled for functions in most codebases (including this one)
|
251
|
+
* because of the `strictFunctionTypes` compiler flag, implicit under `strict: true`.
|
252
|
+
* See: https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-function-parameters-bivariant
|
253
|
+
*/
|
254
|
+
export type ToMethod<T extends AnyFunction> = {
|
255
|
+
method(...args: Parameters<T>): ReturnType<T>;
|
256
|
+
}["method"];
|
257
|
+
|
258
|
+
export type ConfiguredSheetClass<T extends Document.AnyConstructor> = GetKey<
|
259
|
+
GetKey<CONFIG, T["metadata"]["name"]>,
|
260
|
+
"sheetClass",
|
261
|
+
T
|
262
|
+
>;
|
263
|
+
|
264
|
+
export type ObjectClass<T extends Document.AnyConstructor> = GetKey<
|
265
|
+
GetKey<CONFIG, T["metadata"]["name"]>,
|
266
|
+
"objectClass",
|
267
|
+
T
|
268
|
+
>;
|
269
|
+
|
270
|
+
export type LayerClass<T extends Document.AnyConstructor> = GetKey<
|
271
|
+
GetKey<CONFIG, T["metadata"]["name"]>,
|
272
|
+
"layerClass",
|
273
|
+
T
|
274
|
+
>;
|
275
|
+
|
276
|
+
/**
|
277
|
+
* Actual document types that go in folders
|
278
|
+
*/
|
279
|
+
export type FolderDocumentTypes = Exclude<foundry.CONST.FOLDER_DOCUMENT_TYPES, "Compendium">;
|
280
|
+
|
281
|
+
export type MaybeEmpty<T extends AnyObject> =
|
282
|
+
| T
|
283
|
+
| {
|
284
|
+
[K in keyof T]?: never;
|
285
|
+
};
|
286
|
+
|
287
|
+
/**
|
288
|
+
* The following uses `extends object` instead of `AnyObject` to allow `O = typeof SomeClass`
|
289
|
+
*/
|
290
|
+
export type PropertiesOfType<O extends object, T> = {
|
291
|
+
[K in keyof O]: [O[K], T] extends [T, O[K]] ? K : never;
|
292
|
+
}[keyof O];
|
293
|
+
|
294
|
+
declare class Branded<in out BrandName extends string> {
|
295
|
+
#brand: BrandName;
|
296
|
+
}
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Brands a type such that is behaves just like the input type while preventing
|
300
|
+
* assignment to it. This is useful to create types that indicate a specific
|
301
|
+
* invariant that the type must adhere to that a more basic type wouldn't have.
|
302
|
+
*
|
303
|
+
* Note: You can brand most types but due to its implementation this
|
304
|
+
* helper is incompatible with `any`, `unknown`, and `never`. See "Brand Implementation"
|
305
|
+
* for more details.
|
306
|
+
*
|
307
|
+
* For example enum members can be branded to prevent an arbitrary number from
|
308
|
+
* being mistakenly used in their place:
|
309
|
+
*
|
310
|
+
* @example
|
311
|
+
* ```ts
|
312
|
+
* type NUMBER_ENUM = Brand<number, "NUMBER_ENUM">;
|
313
|
+
*
|
314
|
+
* const NUMBER_ENUM: {
|
315
|
+
* X: NUMBER_ENUM,
|
316
|
+
* Y: NUMBER_ENUM
|
317
|
+
* };
|
318
|
+
*
|
319
|
+
* function useNumberEnum(value: NUMBER_ENUM) { ... }
|
320
|
+
* usesNumberEnum(NUMBER_ENUM.X); // Works.
|
321
|
+
* usesNumberEnum(1); // Error.
|
322
|
+
* ```
|
323
|
+
*
|
324
|
+
* ### Brand Implementation
|
325
|
+
*
|
326
|
+
* The fundamental trick of the implementation is that it intersects the base
|
327
|
+
* type with a compile-time only marker property. This marker property will not
|
328
|
+
* exist on the base type and so prevents assignment just like how `{ foo: string }`
|
329
|
+
* can't be assigned to `{ foo: string; bar: number }` because it's missing a property.
|
330
|
+
*
|
331
|
+
* A more basic implementation might look like this:
|
332
|
+
*
|
333
|
+
* ```ts
|
334
|
+
* type Brand<BaseType, BrandName extends string> = BaseType & { brandType: BrandName };
|
335
|
+
* ```
|
336
|
+
*
|
337
|
+
* But this has two problems:
|
338
|
+
* - In theory anyone can add this `brandType` property.
|
339
|
+
* - The `brandType` property is accessible and visible, e.g.
|
340
|
+
* `keyof Brand<BaseType, BrandName>` would include `brandType` because it's a visible property.
|
341
|
+
*
|
342
|
+
* The implementation here solves both of these problems by using a private class field.
|
343
|
+
* This class is unexported and so due to the way that private class properties work this
|
344
|
+
* means there is no other way to create a compatible property (outside of `any`). Using a
|
345
|
+
* class also has the added benefit that the type parameter can be specifically marked as
|
346
|
+
* invariant for a bit of extra protection.
|
347
|
+
*
|
348
|
+
* This does mean that `Brand` only works with types where an intersection is meaningful.
|
349
|
+
* These are the problematic types:
|
350
|
+
* - `any` will become `any` still because `any & T` is still `any`. This makes `Brand` useless.
|
351
|
+
* - `never` stays `never` because `never & T` is `never`. This makes `Brand` useless.
|
352
|
+
* - `unknown` becomes `Branded` because `unknown & T` is `T`. This is a problem because `unknown` can be any type, e.g. `number` but `Branded<unknown, BrandName>` is always an object.
|
353
|
+
*
|
354
|
+
* Unfortunately there aren't really good workarounds either.
|
355
|
+
*/
|
356
|
+
export type Brand<BaseType, BrandName extends string> = BaseType & Branded<BrandName>;
|
357
|
+
|
358
|
+
/**
|
359
|
+
* An at a best effort level expands a type from something complex that shows up like
|
360
|
+
* `DeepPartial<{ x: { y: number } }>` in intellisense to `{ x?: { y?: number } }`.
|
361
|
+
* This is useful for when you want to see what a type looks like in a more human
|
362
|
+
* readable form.
|
363
|
+
*
|
364
|
+
* Using this type is a performance tradeoff, might increase the likelihood of
|
365
|
+
* circularities, and technically in some extremely niche cases changes the type behavior.
|
366
|
+
* ```@example
|
367
|
+
* // The implementation of this type is outside the scope of this example.
|
368
|
+
* // See UnionToIntersection.
|
369
|
+
* type UnionToIntersection<U> = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
|
370
|
+
*
|
371
|
+
* type ObjectIntersection = UnionToIntersection<{ x: string } | { y: number }>;
|
372
|
+
* // ^ { x: string } & { y: number }
|
373
|
+
*
|
374
|
+
* type PrettyObjectIntersection = PrettifyType<ObjectIntersection>;
|
375
|
+
* // ^ { x: string, y: number }
|
376
|
+
*
|
377
|
+
* function example<T extends { someProp: number } | { anotherProp: string }>(t: T) {
|
378
|
+
* Object.assign(t, { a: "foo" }, {b: 2}) satisfies ObjectIntersection
|
379
|
+
* Object.assign(t, { a: "foo" }, {b: 2}) satisfies PrettyObjectIntersection
|
380
|
+
* // ^ Type 'T & { a: string; } & { b: number; }' does not satisfy the expected type '{ a: string; b: number; }'.
|
381
|
+
* // This is an example of changing type behavior. The first line is allowed but the second errors.
|
382
|
+
* // This type of situation will realistically never come up in real code because it's so contrived.
|
383
|
+
* // Note that this difference only appears when generic, specifically `T extends Object | NonObject`.
|
384
|
+
* // See https://github.com/microsoft/TypeScript/pull/60726 for some context.
|
385
|
+
* }
|
386
|
+
* ```
|
387
|
+
*/
|
388
|
+
export type PrettifyType<T> = T extends AnyObject
|
389
|
+
? {
|
390
|
+
[K in keyof T]: T[K];
|
391
|
+
}
|
392
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
393
|
+
T & unknown;
|
394
|
+
|
395
|
+
/**
|
396
|
+
* This behaves the same as {@link PrettifyType | `PrettifyType`} except instead
|
397
|
+
* of prettifying only the first level it prettifies all levels of an object. of prettifying only the first level it prettifies all levels of an object.
|
398
|
+
*/
|
399
|
+
export type PrettifyTypeDeep<T> = T extends AnyObject
|
400
|
+
? {
|
401
|
+
[K in keyof T]: PrettifyTypeDeep<T[K]>;
|
402
|
+
}
|
403
|
+
: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
404
|
+
T & unknown;
|
405
|
+
|
406
|
+
/**
|
407
|
+
* Convert a union of the form `T1 | T2 | T3 | ...` into an intersection of the form `T1 & T2 & T3 & ...`.
|
408
|
+
*
|
409
|
+
* ### Implementation Details
|
410
|
+
*
|
411
|
+
* Breaking this type down into steps evaluation begins with the expression
|
412
|
+
* `U extends unknown ? ... : never`. Note that `U` is a "bare type parameter",
|
413
|
+
* that is written directly as opposed to being wrapped like `U[]`. Because of
|
414
|
+
* this the type is distributive.
|
415
|
+
*
|
416
|
+
* Distributivity means that `U extends unknown ? (arg: U) => void : never` turns the input
|
417
|
+
* of the form `T1 | T2 | T3 | ...` into `((arg: T1) => void) | ((arg: T2) => void) | ((arg: T3) => void)`.
|
418
|
+
* Let's call this new union `FunctionUnion`
|
419
|
+
*
|
420
|
+
* Finally `FunctionUnion extends (arg: infer I) => void ? I : never` is evaluated.
|
421
|
+
* This results in `T1 & T2 & T3 | ...` as promised... but why? Even with distributivity
|
422
|
+
* in play, normally `(T extends unknown ? F<T> : never) extends F<infer T> ? T : never`
|
423
|
+
* would just be a complex way of writing `T`.
|
424
|
+
*
|
425
|
+
* The complete answer is fairly deep and is unlikely to make sense unless you are
|
426
|
+
* already well versed in this area. In particular it lies in what happens when `F<T>`
|
427
|
+
* puts `T` into a contravariant position. In this case inferring `T` back out
|
428
|
+
* requires an intersection effectively because the covariant assignment rules
|
429
|
+
* are flipped.
|
430
|
+
*
|
431
|
+
* That explanation is unlikely to have helped much and so let's run through two
|
432
|
+
* examples.
|
433
|
+
*
|
434
|
+
* First, a refresher:
|
435
|
+
* ```ts
|
436
|
+
* function takesX(arg: { x: number }): number { ... }
|
437
|
+
* function takesY(arg: { y: string }): string { ... }
|
438
|
+
*
|
439
|
+
* let output = ...;
|
440
|
+
* if (Math.random() > 0.5) {
|
441
|
+
* output = takesX({ x: 1 });
|
442
|
+
* } else {
|
443
|
+
* output = takesY({ y: "example" });
|
444
|
+
* }
|
445
|
+
* ```
|
446
|
+
*
|
447
|
+
* What is the best type for `output` in this case? Of course, it'd be `number | string`.
|
448
|
+
*
|
449
|
+
* What about this example?
|
450
|
+
* ```ts
|
451
|
+
* function takesX(arg: { x: number }): number { ... }
|
452
|
+
* function takesY(arg: { y: string }): string { ... }
|
453
|
+
*
|
454
|
+
* let input = ...;
|
455
|
+
* if (Math.random() > 0.5) {
|
456
|
+
* takesX(input);
|
457
|
+
* } else {
|
458
|
+
* takesY(input);
|
459
|
+
* }
|
460
|
+
* ```
|
461
|
+
*
|
462
|
+
* What is the best type for `input` in this case? It might be tempting to say `{ x: number } | { y: string }`
|
463
|
+
* similarly to how `output` was `number | string`. But that's not quite right. The correct type for `input` is
|
464
|
+
* actually `{ x: number } & { y: string }`. The reason why this is the case is that it's unpredictable whether
|
465
|
+
* `takesX` or `takesY` will be called. This means that `input` must be able to used to call both functions.
|
466
|
+
*
|
467
|
+
* This is analogous to asking these two questions at the type level:
|
468
|
+
* ```ts
|
469
|
+
* type Functions = typeof takesX | typeof takesY;
|
470
|
+
* type Output = Functions extends (...args: any[]) => infer Output ? Output : never;
|
471
|
+
* // ^ number | string
|
472
|
+
* type Input = Functions extends (arg: infer Input) => any ? Input : never;
|
473
|
+
* // ^ { x: number } & { y: string }
|
474
|
+
* ```
|
475
|
+
*
|
476
|
+
* And if you reflect on the inciting code, `FunctionUnion extends (arg: infer I) => void ? I : never`
|
477
|
+
* you'll see that it's effectively doing the same thing.
|
478
|
+
*
|
479
|
+
* If you want to read more see TypeScript's handbook section on
|
480
|
+
* [Distributive Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types)
|
481
|
+
* for more information on distributivity. There is also a section on
|
482
|
+
* [Variance](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)
|
483
|
+
* in general but it unfortunately doesn't touch too much on specific details and
|
484
|
+
* the emergent behavior of variance like this.
|
485
|
+
*/
|
486
|
+
export type UnionToIntersection<U> = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void
|
487
|
+
? I
|
488
|
+
: never;
|
489
|
+
|
490
|
+
// Helper Types
|
491
|
+
|
492
|
+
/**
|
493
|
+
* Recursively sets keys of an object to optional. Used primarily for update methods.
|
494
|
+
*
|
495
|
+
* Note: This function is intended to work with plain objects. It takes any object only because
|
496
|
+
* otherwise it makes it more difficult to pass in interfaces.
|
497
|
+
*
|
498
|
+
* Its behavior is unspecified when run on a non-plain object.
|
499
|
+
*/
|
500
|
+
// Allowing passing any `object` is done because it's more convenient for the end user.
|
501
|
+
// Note that `{}` should always be assignable to `DeepPartial<T>`.
|
502
|
+
export type DeepPartial<T extends object> = {
|
503
|
+
[K in keyof T]?: _DeepPartial<T[K]>;
|
504
|
+
};
|
505
|
+
|
506
|
+
// This type has to be factored out for distributivity.
|
507
|
+
type _DeepPartial<T> = T extends object ? (T extends AnyArray | AnyFunction | AnyConstructor ? T : DeepPartial<T>) : T;
|
508
|
+
|
509
|
+
/**
|
510
|
+
* Gets all possible keys of `T`. This is useful because if `T` is a union type
|
511
|
+
* it will get the properties of all types in the union. Otherwise it functions identically to `keyof T`.
|
512
|
+
*/
|
513
|
+
export type AllKeysOf<T extends object> = T extends unknown ? keyof T : never;
|
514
|
+
|
515
|
+
/**
|
516
|
+
* Make all properties in `T` optional and explicitly allow `undefined`
|
517
|
+
*
|
518
|
+
* ### Picking the right helper type
|
519
|
+
* - Favor `NullishProps` whenever it is valid. Allowing both `null` and
|
520
|
+
* `undefined` is convenient for the end user and it is very common that
|
521
|
+
* wherever `undefined` is valid so is `null`. For some examples it is valid
|
522
|
+
* for `options.prop ??= "default"`, `options.prop ||= "default"`,
|
523
|
+
* `if (options.prop) { ... }`, `if (options.prop == null)`, or so on.
|
524
|
+
* - Use `IntentionalPartial` when an explicit `undefined` is problematic but
|
525
|
+
* leaving off the property entirely is fine. This primarily occurs when
|
526
|
+
* patterns like `options = { ...defaultOptions, ...options }`,
|
527
|
+
* `Object.assign({}, defaultOptions, options)`,
|
528
|
+
* `foundry.utils.mergeObject(defaultOptions, options)`, or so on.
|
529
|
+
*
|
530
|
+
* Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`}
|
531
|
+
* also expands the object. So once `ExpandsTo` exists you should also use
|
532
|
+
* that helper type.
|
533
|
+
*
|
534
|
+
* What these patterns have in common is that if `options` looks like
|
535
|
+
* `{ prop: undefined }` that will override whatever is in `defaultOptions`
|
536
|
+
* and may cause issues. Note that even if you see one of these patterns you
|
537
|
+
* also need to ensure that `undefined` would cause issues down the road
|
538
|
+
* before using `IntentionalPartial` as it could be an intended way of
|
539
|
+
* resetting a property.
|
540
|
+
* - Use `InexactPartial` when `null` is problematic but `undefined` is not.
|
541
|
+
* The most common time this shows up is with the pattern
|
542
|
+
* `exampleFunction({ prop = "foo" } = {}) { ... }`.
|
543
|
+
*
|
544
|
+
* @internal
|
545
|
+
*/
|
546
|
+
export type InexactPartial<T extends object, K extends AllKeysOf<T> = AllKeysOf<T>> = {
|
547
|
+
[K2 in keyof T as Extract<K2, K>]?: T[K2] | undefined;
|
548
|
+
} & {
|
549
|
+
// Note(LukeAbby): This effectively inlines `Omit<T, K>`, hoping for slightly better type display.
|
550
|
+
[K2 in keyof T as Exclude<K2, K>]: T[K2];
|
551
|
+
};
|
552
|
+
|
553
|
+
/**
|
554
|
+
* Makes select properties in `T` optional and explicitly allows both `null` and
|
555
|
+
* `undefined` values.
|
556
|
+
*
|
557
|
+
* ### Picking the right helper type
|
558
|
+
* - Favor `NullishProps` whenever it is valid. Allowing both `null` and
|
559
|
+
* `undefined` is convenient for the end user and it is very common that
|
560
|
+
* wherever `undefined` is valid so is `null`. For some examples it is valid
|
561
|
+
* for `options.prop ??= "default"`, `options.prop ||= "default"`,
|
562
|
+
* `if (options.prop) { ... }`, `if (options.prop == null)`, or so on.
|
563
|
+
* - Use `IntentionalPartial` when an explicit `undefined` is problematic but
|
564
|
+
* leaving off the property entirely is fine. This primarily occurs when
|
565
|
+
* patterns like `options = { ...defaultOptions, ...options }`,
|
566
|
+
* `Object.assign({}, defaultOptions, options)`,
|
567
|
+
* `foundry.utils.mergeObject(defaultOptions, options)`, or so on.
|
568
|
+
*
|
569
|
+
* Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`}
|
570
|
+
* also expands the object. So once `ExpandsTo` exists you should also use
|
571
|
+
* that helper type.
|
572
|
+
*
|
573
|
+
* What these patterns have in common is that if `options` looks like
|
574
|
+
* `{ prop: undefined }` that will override whatever is in `defaultOptions`
|
575
|
+
* and may cause issues. Note that even if you see one of these patterns you
|
576
|
+
* also need to ensure that `undefined` would cause issues down the road
|
577
|
+
* before using `IntentionalPartial` as it could be an intended way of
|
578
|
+
* resetting a property.
|
579
|
+
* - Use `InexactPartial` when `null` is problematic but `undefined` is not.
|
580
|
+
* The most common time this shows up is with the pattern
|
581
|
+
* `exampleFunction({ prop = "foo" } = {}) { ... }`.
|
582
|
+
*
|
583
|
+
* @internal
|
584
|
+
*/
|
585
|
+
export type NullishProps<T extends object, K extends AllKeysOf<T> = AllKeysOf<T>> = {
|
586
|
+
[K2 in keyof T as Extract<K2, K>]?: T[K2] | null | undefined;
|
587
|
+
} & {
|
588
|
+
// Note(LukeAbby): This effectively inlines `Omit<T, K>`, hoping for slightly better type display.
|
589
|
+
[K2 in keyof T as Exclude<K2, K>]: T[K2];
|
590
|
+
};
|
591
|
+
|
592
|
+
/**
|
593
|
+
* Expand an object that contains keys in dotted notation
|
594
|
+
* @internal
|
595
|
+
*/
|
596
|
+
export type Expanded<O> = O extends AnyObject
|
597
|
+
? {
|
598
|
+
[KO in keyof O as KO extends `${infer A}.${string}` ? A : KO]: KO extends `${string}.${infer B}`
|
599
|
+
? Expanded<{ [EB in B]: O[KO] }>
|
600
|
+
: Expanded<O[KO]>;
|
601
|
+
}
|
602
|
+
: O;
|
603
|
+
|
604
|
+
/**
|
605
|
+
* Union type of the types of the values in `T`
|
606
|
+
* @internal
|
607
|
+
*/
|
608
|
+
export type ValueOf<T> = T extends ReadonlyArray<infer V> ? V : T[keyof T];
|
609
|
+
|
610
|
+
type OmitIndex<K extends PropertyKey> = string extends K
|
611
|
+
? never
|
612
|
+
: number extends K
|
613
|
+
? never
|
614
|
+
: symbol extends K
|
615
|
+
? never
|
616
|
+
: K;
|
617
|
+
|
618
|
+
/**
|
619
|
+
* Gets the keys of `T` but excluding index signatures unlike `keyof T`. For example `Record<string, any> & { foo: number }` will produce `string` with `keyof` but `foo` with `ConcreteKeys`.
|
620
|
+
*/
|
621
|
+
export type ConcreteKeys<T> = T extends never
|
622
|
+
? never
|
623
|
+
: keyof {
|
624
|
+
[K in keyof T as OmitIndex<K>]: never;
|
625
|
+
};
|
626
|
+
|
627
|
+
/**
|
628
|
+
* Removes all index signatures from an object. Use this instead of `[K in keyof ConcreteKeys<T>]` to preserve modifiers e.g. readonly, or optional.
|
629
|
+
*/
|
630
|
+
// NOTE(LukeAbby): It may seem easier to write `Pick<T, ConcreteKeys<T>>` but this stops it from being a homomorphic mapped type and regresses its power when given a generic type parameter or `this`.
|
631
|
+
// See: https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBDAnmYcDCEB2BjKwbADSwiAzgDwAqAfHALxwDWJEAZnAN4BQccA2oTgBLTExbtKcAIak4pGFBEBzOKAKYAJrMEB+OJmAA3YFDgAufQFcAtgCMTqkOq1xd+ow4ulEdiABtHZ204PQNjUwtCAF0LMJMAbi4AX0SuJBQ4ACVgawhjAElNUABlISVMKRhLPAoaejgABSFsRioAGnQsXHwiElrqalTsPxlZABFKqQBZCA1gP3Ji7AALHKlabl454ak8OFy5vwts3IKikFLyyurgCiXV63Xkri4d0lliy1sZw8WVtcCwE0sg4cCUQJMzQaUAgYAsUkwiHi-EIXgUyhiVjsDiStDUQJcExg01m8z+D3WnB4+3wy1mAAoAJRU3i8AD0bLglGWQlkYBhKCgiDkdMsfg0jl58FslngGggt0wAHIYAA6am8GA80iqg7zVXggyKbDQ2GpVkIbW60l+VVSWzYRK8JLJIA
|
632
|
+
export type RemoveIndexSignatures<T extends AnyObject> = {
|
633
|
+
[K in keyof T as OmitIndex<K>]: T[K];
|
634
|
+
};
|
635
|
+
|
636
|
+
/**
|
637
|
+
* Transforms a string to lowercase and the first character to uppercase.
|
638
|
+
* @internal
|
639
|
+
*/
|
640
|
+
export type Titlecase<S extends string> = S extends `${infer A} ${infer B}`
|
641
|
+
? `${Titlecase<A>} ${Titlecase<B>}`
|
642
|
+
: Capitalize<Lowercase<S>>;
|
643
|
+
|
644
|
+
/**
|
645
|
+
* Deeply merge two types. If either of the given types is not an object then `U`
|
646
|
+
* simply overwrites `T`.
|
647
|
+
*
|
648
|
+
* Nested properties of type `object` are merged recursively unless the property
|
649
|
+
* in `U` is an `Array`.
|
650
|
+
*
|
651
|
+
* @typeParam T - The base type that `U` will be merged into.
|
652
|
+
* @typeParam U - The type that will be merged into `T`.
|
653
|
+
*/
|
654
|
+
export type Merge<T, U> =
|
655
|
+
IsObject<U> extends true
|
656
|
+
? IsObject<T> extends true
|
657
|
+
? SimpleMerge<
|
658
|
+
T,
|
659
|
+
{
|
660
|
+
[K in keyof U]: T extends { readonly [_ in K]?: infer V } ? Merge<V, U[K]> : U[K];
|
661
|
+
}
|
662
|
+
>
|
663
|
+
: U
|
664
|
+
: U;
|
665
|
+
|
666
|
+
/**
|
667
|
+
* Returns whether the type is a plain object. Excludes functions and arrays while still being friendly to interfaces.
|
668
|
+
*
|
669
|
+
* @example
|
670
|
+
* ```ts
|
671
|
+
* interface ObjectInterface {
|
672
|
+
* prop: number;
|
673
|
+
* }
|
674
|
+
*
|
675
|
+
* type Interface = IsObject<ObjectInterface>; // true
|
676
|
+
* type Object = IsObject<{ prop: number }>; // true
|
677
|
+
* type Array = IsObject<number[]>; // false
|
678
|
+
* type Function = IsObject<() => void>; // false
|
679
|
+
*
|
680
|
+
* // By comparison, simply comparing against `Record<string, unknown>` fails.
|
681
|
+
* type RecordFails = Interface extends Record<string, unknown> ? true : false; // false
|
682
|
+
* ```
|
683
|
+
*/
|
684
|
+
export type IsObject<T> = T extends { readonly [K: string]: any }
|
685
|
+
? T extends AnyArray | AnyFunction
|
686
|
+
? false
|
687
|
+
: true
|
688
|
+
: false;
|
689
|
+
|
690
|
+
/**
|
691
|
+
* A simple, non-recursive merge type.
|
692
|
+
* @typeParam Target - the target type to merge into
|
693
|
+
* @typeParam Override - the type whose properties override the ones in Target
|
694
|
+
*/
|
695
|
+
export type SimpleMerge<Target, Override> = Omit<Target, keyof Override> & Override;
|
696
|
+
|
697
|
+
/**
|
698
|
+
* Makes the given keys `K` of the type `T` required
|
699
|
+
*/
|
700
|
+
export type RequiredProps<T extends object, K extends AllKeysOf<T>> = Required<Pick<T, K>> & Omit<T, K>;
|
701
|
+
|
702
|
+
export type Mixin<MixinClass extends AnyConcreteConstructor, BaseClass extends AnyConstructor> = MixinClass & BaseClass;
|
703
|
+
|
704
|
+
interface GetDataConfigOptions<T> {
|
705
|
+
partial: Partial<T> & Record<string, unknown>;
|
706
|
+
exact: T;
|
707
|
+
object: object;
|
708
|
+
}
|
709
|
+
|
710
|
+
type GetDataConfigOption = GetDataConfig extends {
|
711
|
+
mode: infer Mode extends keyof GetDataConfigOptions<unknown>;
|
712
|
+
}
|
713
|
+
? Mode
|
714
|
+
: "object";
|
715
|
+
|
716
|
+
export type GetDataReturnType<T extends object> = GetDataConfigOptions<T>[GetDataConfigOption];
|
717
|
+
|
718
|
+
/**
|
719
|
+
* Replaces the type `{}` with `Record<string, never>` by default which is
|
720
|
+
* usually a better representation of an empty object. The type `{}` actually
|
721
|
+
* allows any type be assigned to it except for `null` and `undefined`.
|
722
|
+
*
|
723
|
+
* The theory behind this is that all non-nullish types allow
|
724
|
+
* you to access any property on them without erroring. Primitive types like
|
725
|
+
* `number` will not store the property but it still will not error to simply
|
726
|
+
* try to get and set properties.
|
727
|
+
*
|
728
|
+
* The type `{}` can appear for example after operations like `Omit` if it
|
729
|
+
* removes all properties rom an object, because an empty interface was given,
|
730
|
+
* or so on.
|
731
|
+
*
|
732
|
+
* Type params extend `object` instead of `AnyObject` to allow interfaces
|
733
|
+
*
|
734
|
+
* @example
|
735
|
+
* ```ts
|
736
|
+
* type ObjectArray<T extends Record<string, unknown>> = T[];
|
737
|
+
*
|
738
|
+
* // As you would hope a union can't be assigned. It errors with:
|
739
|
+
* // "type 'string' is not assignable to type 'Record<string, unknown>'."
|
740
|
+
* type UnionErrors = ObjectArray<string | { x: number }>;
|
741
|
+
*
|
742
|
+
* // However, this works.
|
743
|
+
* type EmptyObjectArray = ObjectArray<{}>;
|
744
|
+
*
|
745
|
+
* // But it allows likely unsound behavior like this:
|
746
|
+
* const emptyObject: EmptyObjectArray = [1, "foo", () => 3];
|
747
|
+
*
|
748
|
+
* // So it may be better to define `ObjectArray` like so:
|
749
|
+
* type ObjectArray<T extends Record<string, unknown>> = HandleEmptyObject<T>[];
|
750
|
+
*
|
751
|
+
* // If it were, then this line would error appropriately!
|
752
|
+
* const emptyObject: EmptyObjectArray = [1, "foo", () => 3];
|
753
|
+
* ```
|
754
|
+
*/
|
755
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
756
|
+
export type HandleEmptyObject<T extends object, D extends object = EmptyObject> = [{}] extends [T] ? D : T;
|
757
|
+
|
758
|
+
/**
|
759
|
+
* This type allows any plain objects. In other words it disallows functions
|
760
|
+
* and arrays.
|
761
|
+
*
|
762
|
+
* Use this type instead of:
|
763
|
+
* - `object`/`Record<any, any>` - This allows functions, classes, and arrays.
|
764
|
+
* - `{}` - This type allows anything besides `null` and `undefined`.
|
765
|
+
* - `Record<string, unknown>` - This is the appropriate type for any mutable object but doesn't allow readonly objects.
|
766
|
+
*/
|
767
|
+
// This type is not meant to be extended and it has to use an indexed type.
|
768
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
769
|
+
export type AnyObject = {
|
770
|
+
readonly [K: string]: unknown;
|
771
|
+
};
|
772
|
+
|
773
|
+
/**
|
774
|
+
* This type allows mutable plain objects. This means readonly objects cannot be
|
775
|
+
* assigned.
|
776
|
+
*
|
777
|
+
* Use this type instead of:
|
778
|
+
* - `object` - This allows functions and arrays.
|
779
|
+
* - `Record<string, any>`/`{}` - These allows anything besides `null` and `undefined`.
|
780
|
+
* - `Record<string, unknown>` - These types are equivalent but `AnyMutableObject` is preferred for explicitness.
|
781
|
+
*/
|
782
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
783
|
+
export type AnyMutableObject = {
|
784
|
+
[K: string]: unknown;
|
785
|
+
};
|
786
|
+
|
787
|
+
/**
|
788
|
+
* Use this type to allow any array. This allows readonly arrays which is
|
789
|
+
* generally what you want. If you need a mutable array use the
|
790
|
+
* {@link MutableArray | `MutableArray`} type instead of the builtin `T[]` or
|
791
|
+
* `Array` types. This allows us to be more explicit about intent.
|
792
|
+
*
|
793
|
+
* Consider being more specific if possible. You should generally try to use a
|
794
|
+
* concrete array with a union or add a type parameter first.
|
795
|
+
*
|
796
|
+
* Use this instead of:
|
797
|
+
* - `any[]` - When elements of this array are accessed you get `any` which is not safe.
|
798
|
+
* - `unknown[]` - This is the appropriate type for any mutable array but doesn't allow readonly arrays.
|
799
|
+
*/
|
800
|
+
export type AnyArray = readonly unknown[];
|
801
|
+
|
802
|
+
/**
|
803
|
+
* Use this type to allow a mutable array of type `T`. Only use this if the
|
804
|
+
* array can be soundly mutated. Otherwise you should be using
|
805
|
+
* `readonly T[]` or {@link ReadonlyArray | `ReadonlyArray`}
|
806
|
+
*/
|
807
|
+
export type MutableArray<T> = Array<T>;
|
808
|
+
|
809
|
+
/**
|
810
|
+
* Use this type to allow any function. Notably since this allows any function
|
811
|
+
* it is difficult to call the function in a safe way. This means its uses are
|
812
|
+
* mostly niche and it should be avoided.
|
813
|
+
*
|
814
|
+
* Make sure you have a good reason to use this type. It is almost always better
|
815
|
+
* to use a more specific function type. Please consider leaving a comment about
|
816
|
+
* why this type is necessary.
|
817
|
+
*
|
818
|
+
* Use this instead of:
|
819
|
+
* - `Function` - This refers to the fundamental `Function` object in JS. It allows classes.
|
820
|
+
* - `(...args: any[]) => any` - If someone explicitly accesses the parameters or uses the return value you get `any` which is not safe.
|
821
|
+
* - `(...args: unknown[]) => unknown` - This allows obviously unsound calls like `fn(1, "foo")` because it indicates it can take any arguments.
|
822
|
+
*/
|
823
|
+
// The explicit arg0 does not prevent a function with no arguments from being assigned to `AnyFunction` because any function that takes less arguments can be assigned to one that takes more.
|
824
|
+
// The point of this is to prevent it from being possible to call with 0 arguments.
|
825
|
+
// never is used to make it impossible to call with anything besides `never` or `any`. This makes it the most type safe way to define any function.
|
826
|
+
export type AnyFunction = (arg0: never, ...args: never[]) => unknown;
|
827
|
+
|
828
|
+
/**
|
829
|
+
* Use this type to allow any class, abstract class, or class-like constructor.
|
830
|
+
*
|
831
|
+
* See {@link AnyConcreteConstructor | `AnyConcreteConstructor`} if you cannot
|
832
|
+
* allow abstract classes. Please also consider writing a comment
|
833
|
+
* explaining why {@link AnyConcreteConstructor | `AnyConcreteConstructor`} is
|
834
|
+
* necessary.
|
835
|
+
*
|
836
|
+
* @example
|
837
|
+
* ```ts
|
838
|
+
* const concrete: AnyConstructor = class Concrete { ... }
|
839
|
+
* const abstract: AnyConstructor = abstract class Abstract { ... }
|
840
|
+
*
|
841
|
+
* // `Date` is not actually a class but it can be used as a constructor.
|
842
|
+
* const classLike: AnyConstructor = Date;
|
843
|
+
* ```
|
844
|
+
*/
|
845
|
+
export type AnyConstructor = abstract new (arg0: never, ...args: never[]) => unknown;
|
846
|
+
|
847
|
+
/**
|
848
|
+
* Use this type to allow any class or class-like constructor but disallow
|
849
|
+
* class-like constructors.
|
850
|
+
*
|
851
|
+
* Use this type only when abstract classes would be problematic such as the
|
852
|
+
* base type of a mixin. Please consider writing a comment explaining why.
|
853
|
+
* See {@link AnyConstructor | `AnyConstructor`} to also allow abstract classes.
|
854
|
+
*
|
855
|
+
* @example
|
856
|
+
* ```ts
|
857
|
+
* const concrete: AnyConcreteConstructor = class Concrete { ... }
|
858
|
+
*
|
859
|
+
* // `Date` is not actually a class but it can be used as a constructor.
|
860
|
+
* const classLike: AnyConcreteConstructor = Date;
|
861
|
+
*
|
862
|
+
* // This next line errors:
|
863
|
+
* const abstract: AnyConcreteConstructor = abstract class Abstract { ... }
|
864
|
+
* ```
|
865
|
+
*/
|
866
|
+
export type AnyConcreteConstructor = new (arg0: never, ...args: never[]) => unknown;
|
867
|
+
|
868
|
+
/**
|
869
|
+
* This type is equivalent to `Promise<T>` but exists to give an explicit signal
|
870
|
+
* that this is not a mistake. When Foundry accepts an asynchronous callback the
|
871
|
+
* vast majority of the time it is best to use {@link MaybePromise | `MaybePromise`}.
|
872
|
+
*
|
873
|
+
* By doing it this way the maximum flexibility is given to the definer of the
|
874
|
+
* callback. This is okay because typically asynchronous callbacks are simply
|
875
|
+
* awaited, meaning that there's no noticeable difference between a `Promise`
|
876
|
+
* and {@link MaybePromise | `MaybePromise`}. Even functions like
|
877
|
+
* {@link Promise.allSettled | `Promise.allSettled`} function correctly
|
878
|
+
* with {@link MaybePromise | `MaybePromise`}.
|
879
|
+
*
|
880
|
+
* Do not use this type or {@link MaybePromise | `MaybePromise`} for the return
|
881
|
+
* type of asynchronous methods on classes. For example for
|
882
|
+
* {@link foundry.abstract.Document._preCreate | `Document#_preCreate`} the typing
|
883
|
+
* should be `Promise<void>` and not this type. In theory we could use
|
884
|
+
* {@link MaybePromise | `MaybePromise`} in this context as well but this seems
|
885
|
+
* more likely to be confusing than to be helpful.
|
886
|
+
*
|
887
|
+
* Use this type only in the rare case where a callback's return type must be a
|
888
|
+
* `Promise`, for example if `promise.then` or `promise.catch` is explicitly
|
889
|
+
* called. Please also writing a comment explaining why
|
890
|
+
* {@link MaybePromise | `MaybePromise`} is problematic in this context.
|
891
|
+
*/
|
892
|
+
export type MustBePromise<T> = Promise<T>;
|
893
|
+
|
894
|
+
/**
|
895
|
+
* Use when a type may be either a promise or not. This is most useful in
|
896
|
+
* asynchronous callbacks where in most cases it's sound to provide a synchronous
|
897
|
+
* callback instead.
|
898
|
+
*
|
899
|
+
* If it is not sound to provide a non-Promise for whatever reason, see
|
900
|
+
* {@link MustBePromise | `MustBePromise`} to declare this more explicitly than simply writing
|
901
|
+
* `Promise<T>`.
|
902
|
+
*
|
903
|
+
* This should generally not be used in asynchronous methods. For example in
|
904
|
+
* {@link foundry.abstract.Document._preCreate | `Document#_preCreate`} the typing
|
905
|
+
* is `Promise<void>` because it's declared as an async method. Overriding an
|
906
|
+
* asynchronous method with a synchronous method is more confusing than
|
907
|
+
* helpful.
|
908
|
+
*/
|
909
|
+
export type MaybePromise<T> = T | Promise<T>;
|
910
|
+
|
911
|
+
/**
|
912
|
+
* Use this to allow any type besides `null` or `undefined`.
|
913
|
+
*
|
914
|
+
* This type is equivalent to the type `{}`. It exists to give this type a
|
915
|
+
* better name. `{}` is not a type representing an empty object. In reality it
|
916
|
+
* allows assigning any type besides `null` or `undefined`. This is frustrating
|
917
|
+
* but it seems the theory is supposed to be that all types except for `null`
|
918
|
+
* and `undefined` will return `undefined` for any property accessed on them.
|
919
|
+
*
|
920
|
+
* Even primitives like `number` will not error when you get or even set a
|
921
|
+
* property on them, although they will not preserve the property. Since the
|
922
|
+
* only type that cannot be indexed is `null` or `undefined` this is the chosen
|
923
|
+
* semantics of `{}` in TypeScript.
|
924
|
+
*/
|
925
|
+
// This type is not meant to be extended and it's meant to be the explicit version of what the type `{}` does, i.e. allow any type besides `null` or `undefined`.
|
926
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-object-type
|
927
|
+
export type NonNullish = {};
|
928
|
+
|
929
|
+
/**
|
930
|
+
* This is the closest approximation to a type representing an empty object.
|
931
|
+
*
|
932
|
+
* Use instead of `{}` when you want to represent an empty object. `{}` actually
|
933
|
+
* allows any type that is not `null` or `undefined`. see
|
934
|
+
* {@link NonNullish | `NonNullish`} if you want that behavior.
|
935
|
+
*/
|
936
|
+
// It would be unsound to merge into so an interface is not used.
|
937
|
+
export type EmptyObject = Record<string, never>;
|
938
|
+
|
939
|
+
declare const empty: unique symbol;
|
940
|
+
|
941
|
+
/**
|
942
|
+
* This helper type helps emulate index signatures for types with incompatible concrete keys.
|
943
|
+
*
|
944
|
+
* For example the type `{ foo: number; [K: string]: string }` is not allowed because the index signature is incompatible with the concrete key `foo`.
|
945
|
+
* It may seem like tricks like `{ foo: number; } & { [K: string]: string }` work but this defers the error to the caller.
|
946
|
+
*
|
947
|
+
* @example
|
948
|
+
* ```typescript
|
949
|
+
* type NaiveType = { foo: number; [K: string]: boolean };
|
950
|
+
* // ^ Property 'foo' of type 'number' is not assignable to 'string' index type 'boolean'.
|
951
|
+
*
|
952
|
+
* type NaiveIntersection = { foo: number } & { [K: string]: string };
|
953
|
+
*
|
954
|
+
* function usesIntersection(intersection: NaiveIntersection) { ... }
|
955
|
+
*
|
956
|
+
* usesIntersection({ foo: 1, x: true });
|
957
|
+
* // ^ Argument of type '{ foo: number; }' is not assignable to parameter of type 'NaiveIntersection'.
|
958
|
+
* // Type '{ foo: number; }' is not assignable to type '{ [K: string]: boolean; }'.
|
959
|
+
* // Property 'foo' is incompatible with index signature.
|
960
|
+
* // Type 'number' is not assignable to type 'boolean'.
|
961
|
+
*
|
962
|
+
* function usesCorrectly<T extends AnyObject>(withIndex: ShapeWithIndexSignature<T, { foo: number }, string, boolean>) { ... }
|
963
|
+
*
|
964
|
+
* usesCorrectly({ foo: 1, x: true });
|
965
|
+
* ```
|
966
|
+
*/
|
967
|
+
// Note: If https://github.com/microsoft/TypeScript/issues/17867 or https://github.com/microsoft/TypeScript/issues/43826 (depending on implementation) is implemented it's likely this type can be expressed in a better way.
|
968
|
+
export type ShapeWithIndexSignature<
|
969
|
+
T extends AnyObject,
|
970
|
+
// Uses `extends object` to allow interfaces and if useful other objects.
|
971
|
+
PrimaryShape extends object,
|
972
|
+
IndexSignature extends PropertyKey,
|
973
|
+
IndexType,
|
974
|
+
> = PrimaryShape & {
|
975
|
+
readonly [K in keyof T & IndexSignature]: K extends keyof PrimaryShape ? PrimaryShape[K] : IndexType;
|
976
|
+
};
|
977
|
+
|
978
|
+
/**
|
979
|
+
* Defer is a utility type that allows you to defer the evaluation of a type.
|
980
|
+
* The use cases for this are extremely advanced. In essence they have to do with breaking cycles in evaluation.
|
981
|
+
*/
|
982
|
+
export type Defer<T> = [T][T extends any ? 0 : never];
|
983
|
+
|
984
|
+
export type MustBeValidUuid<Uuid extends string, Type extends Document.Type = Document.Type> = _MustBeValidUuid<
|
985
|
+
Uuid,
|
986
|
+
Uuid,
|
987
|
+
Type
|
988
|
+
>;
|
989
|
+
|
990
|
+
/**
|
991
|
+
* Quotes a string for human readability. This is useful for error messages.
|
992
|
+
*
|
993
|
+
* @example
|
994
|
+
* ```ts
|
995
|
+
* type Quote1 = Quote<"foo">;
|
996
|
+
* // ^ "'foo'"
|
997
|
+
*
|
998
|
+
* type Quote2 = Quote<"can't">;
|
999
|
+
* // ^ "'can\\'t'"
|
1000
|
+
* ```
|
1001
|
+
*/
|
1002
|
+
export type Quote<T extends string> = T extends `${string}'${string}` ? `'${Escape<T>}'` : `'${T}'`;
|
1003
|
+
|
1004
|
+
type Escape<T extends string> = T extends `${infer Prefix}'${infer Suffix}` ? `${Prefix}\\'${Escape<Suffix>}` : T;
|
1005
|
+
|
1006
|
+
declare class InvalidUuid<OriginalUuid extends string> {
|
1007
|
+
#invalidUuid: true;
|
1008
|
+
|
1009
|
+
message: `The UUID ${Quote<OriginalUuid>} is invalid .`;
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
type _MustBeValidUuid<
|
1013
|
+
Uuid extends string,
|
1014
|
+
OriginalUuid extends string,
|
1015
|
+
Type extends Document.Type,
|
1016
|
+
> = Uuid extends `${string}.${string}.${infer Rest}`
|
1017
|
+
? _MustBeValidUuid<Rest, OriginalUuid, Type>
|
1018
|
+
: Uuid extends `${string}.${string}`
|
1019
|
+
? Uuid extends `${Type}.${string}`
|
1020
|
+
? OriginalUuid
|
1021
|
+
: InvalidUuid<OriginalUuid>
|
1022
|
+
: `${Type}.${string}` | `${string}.${string}.${Type}.${string}`;
|
1023
|
+
|
1024
|
+
/**
|
1025
|
+
* Drops the first element of an array
|
1026
|
+
*/
|
1027
|
+
type DropFirst<T extends AnyArray> = T extends [infer _1, ...infer V] ? V : T;
|
1028
|
+
|
1029
|
+
/**
|
1030
|
+
* This type is used when you want to use `unknown` in a union. This works because while `T | unknown`
|
1031
|
+
* will reduce to `unknown`. However by comparison the only way that `T | LazyUnknown` can reduce is
|
1032
|
+
* if there's
|
1033
|
+
*
|
1034
|
+
* This makes it the ideal type to accept any input in some situations, mostly for documenting types
|
1035
|
+
* where anything is acceptable but certain ones are more notable. For example `number | LazyUnknown`
|
1036
|
+
* would still accept anything but appear as `number | {} | null | undefined` in intellisense, due
|
1037
|
+
* to the inlining of the composite parts of `LazyUnknown`.
|
1038
|
+
*
|
1039
|
+
* The type `{}` isn't actually the type for an empty object. It allows anything except
|
1040
|
+
* `null`/`undefined` which is why `{} | null | undefined` allows anything to be assigned to it.
|
1041
|
+
* See {@link NonNullish | `NonNullish`} for a further explanation on why `{}` allows anything
|
1042
|
+
* besides `null`/`undefined`.
|
1043
|
+
*/
|
1044
|
+
export type LazyUnknown = NonNullish | null | undefined;
|
1045
|
+
|
1046
|
+
/**
|
1047
|
+
* `Coalesce` is useful to provide defaults. For example if you have the function:
|
1048
|
+
* ```js
|
1049
|
+
* function toString(item="default") {
|
1050
|
+
* return `${item}`;
|
1051
|
+
* }
|
1052
|
+
* ```
|
1053
|
+
*
|
1054
|
+
* Then the most appropriate type might be:
|
1055
|
+
* ```ts
|
1056
|
+
* declare function toString<
|
1057
|
+
* Item extends string | number | undefined = undefined
|
1058
|
+
* >(item?: Item): `${Coalesce<Item, "default">}`
|
1059
|
+
*
|
1060
|
+
* const itemUnset = toString();
|
1061
|
+
* // ^ "default"
|
1062
|
+
*
|
1063
|
+
* const itemUndefined = tgoString(undefined);
|
1064
|
+
* // ^ "default"
|
1065
|
+
* ```
|
1066
|
+
*
|
1067
|
+
* This is because generic parameter defaults and function parameters behave differently. A function
|
1068
|
+
* default is used whenever `undefined` would otherwise be the value, either explicitly or implicitly
|
1069
|
+
* i.e. both `doubles()` and `doubles(undefined)` would use the default of `"default"`. However a generic'
|
1070
|
+
* defaults only shows up when it's not used at all. The behavior with an explicit `undefined` has
|
1071
|
+
* two cases to explain:
|
1072
|
+
*
|
1073
|
+
* ```ts
|
1074
|
+
* declare function toString1<Item extends string | number = "foo">(item?: Item): void;
|
1075
|
+
*
|
1076
|
+
* toString1(undefined);
|
1077
|
+
* // `Item` will infer as `string | number` because `undefined` isn't assignable to the constraint of `Item`.
|
1078
|
+
*
|
1079
|
+
* declare function toString2<Item extends string | number | undefined = "foo">(item?: Item): void;
|
1080
|
+
*
|
1081
|
+
* toString2(undefined);
|
1082
|
+
* // `Item` will infer as `undefined` not `"foo"` because the generic has something to infer from.
|
1083
|
+
* ```
|
1084
|
+
*/
|
1085
|
+
export type Coalesce<T, D, CoalesceType = undefined> = T extends CoalesceType ? D : T;
|
1086
|
+
|
1087
|
+
/**
|
1088
|
+
* Coalesces specifically `null | undefined`. Behaves like `??` does at runtime.
|
1089
|
+
* See {@link Coalesce | `Coalesce`}.
|
1090
|
+
*/
|
1091
|
+
export type NullishCoalesce<T, D> = T extends null | undefined ? D : T;
|