-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Hooks to v12 #2934
Merged
+88
−38
Merged
Updated Hooks to v12 #2934
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import type { DropData } from "./data/abstract/client-document.d.mts"; | |
import type ProseMirrorMenu from "../common/prosemirror/menu.d.mts"; | ||
import type PointVisionSource from "../client-esm/canvas/sources/point-vision-source.d.mts"; | ||
import type RenderedEffectSource from "../client-esm/canvas/sources/rendered-effect-source.d.mts"; | ||
import type { CompendiumArtInfo } from "../client-esm/helpers/_types.d.mts"; | ||
|
||
declare global { | ||
/** | ||
|
@@ -117,7 +118,6 @@ declare global { | |
* @remarks This is called by {@link Hooks.callAll}. | ||
* @see {@link GameTime#onUpdateWorldTime} | ||
*/ | ||
// Note: Double-listed in the official docs, possible this moves to under Socket | ||
updateWorldTime: (worldTime: number, delta: number) => void; | ||
|
||
/** CanvasLifecycle */ | ||
|
@@ -239,28 +239,6 @@ declare global { | |
*/ | ||
changeSidebarTab: (app: SidebarTab) => void; | ||
|
||
/** EffectsCanvasGroup */ | ||
|
||
/** | ||
* A hook event that fires in the {@link EffectsCanvasGroup} #createLayers private method. | ||
* @param group - The EffectsCanvasGroup instance | ||
* @remarks This is called by {@link Hooks.callAll}. | ||
*/ | ||
createEffectsCanvasGroup: (group: EffectsCanvasGroup) => void; | ||
|
||
/** | ||
* A hook event that fires in the {@link EffectsCanvasGroup} draw method. | ||
* @param group - The EffectsCanvasGroup instance | ||
* @remarks This is called by {@link Hooks.callAll}. | ||
*/ | ||
drawEffectsCanvasGroup: (group: EffectsCanvasGroup) => void; | ||
|
||
/** | ||
* A hook event that fires in the {@link EffectsCanvasGroup} tearDown method. | ||
* @param group - The EffectsCanvasGroup instance | ||
*/ | ||
tearDownEffectsCanvasGroup: (group: EffectsCanvasGroup) => void; | ||
|
||
/** Active Effects */ | ||
|
||
/** | ||
|
@@ -303,7 +281,7 @@ declare global { | |
applyTokenStatusEffect: (token: Token.ConfiguredInstance, statusId: string, active: boolean) => void; | ||
|
||
/** | ||
* A hook event that fires when a chat bubble is rendered. | ||
* A hook event that fires when a chat bubble is initially configured. | ||
* @param token - The speaking token | ||
* @param html - The HTML for the chat bubble | ||
* @param message - The spoken message text | ||
|
@@ -417,6 +395,25 @@ declare global { | |
context: Cards.ReturnContext, | ||
) => boolean | void; | ||
|
||
/** Actor */ | ||
|
||
/** | ||
* A hook even that fires when package-provided art is applied to a compendium Document. | ||
* @param documentClass - The Document class. | ||
* @param source - The Document's source data. | ||
* @param pack - The Document's compendium. | ||
* @param art - The art being applied. | ||
* @remarks Called as part of _initializeSource, after data migration, cleaning, and shims | ||
* @remarks Currently only called by Actor but comments are more generic | ||
* @remarks This is called by {@link Hooks.callAll}. | ||
*/ | ||
applyCompendiumArt: ( | ||
documentClass: Actor.ConfiguredClass, | ||
source: foundry.documents.BaseActor.ConstructorData, | ||
pack: CompendiumCollection.Any, | ||
art: CompendiumArtInfo, | ||
) => void; | ||
|
||
/** ActorSheet */ | ||
|
||
/** | ||
|
@@ -451,6 +448,13 @@ declare global { | |
*/ | ||
lightingRefresh: (layer: LightingLayer) => void; | ||
|
||
/** | ||
* A hook event that fires when visibility is refreshed. | ||
* @param visibility - The CanvasVisibility instance | ||
* @remarks This is called by {@link Hooks.callAll}. | ||
*/ | ||
visibilityRefresh: (visibility: CanvasVisibility) => void; | ||
|
||
/** | ||
* A hook event that fires during light source initialization. | ||
* This hook can be used to add programmatic light sources to the Scene. | ||
|
@@ -460,6 +464,14 @@ declare global { | |
*/ | ||
initializeLightSources: (group: EffectsCanvasGroup) => void; | ||
|
||
/** | ||
* A hook event that fires during darkness source initialization. | ||
* This hook can be used to add programmatic darkness sources to the Scene. | ||
* @param group - The EffectsCanvasGroup where darkness sources are initialized | ||
* @remarks This is called by {@link Hooks.callAll}. | ||
*/ | ||
initializeDarknessSources: (group: EffectsCanvasGroup) => void; | ||
|
||
/** | ||
* A hook event that fires when the CanvasVisibility layer has been refreshed. | ||
* @param visibility - The CanvasVisibility layer | ||
|
@@ -528,8 +540,23 @@ declare global { | |
|
||
/** Combat */ | ||
|
||
/** | ||
* A hook event which fires when the turn order of a Combat encounter is progressed. | ||
* This event fires on all clients after the database update has occurred for the Combat. | ||
* @param combat - The Combat encounter for which the turn order has changed | ||
* @param prior - The prior turn state | ||
* @param current - The new turn state | ||
* @remarks This is called by {@link Hooks.callAll}. | ||
*/ | ||
combatTurnChange: ( | ||
combat: Combat.ConfiguredInstance, | ||
prior: Combat.HistoryData, | ||
current: Combat.HistoryData, | ||
) => void; | ||
|
||
/** | ||
* A hook event that fires when a Combat encounter is started. | ||
* This event fires on the initiating client before any database update occurs. | ||
* @param combat - The Combat encounter which is starting | ||
* @param updateData - An object which contains Combat properties that will be updated. Can be mutated. | ||
*/ | ||
|
@@ -545,6 +572,7 @@ declare global { | |
|
||
/** | ||
* A hook event that fires when the turn of the Combat encounter changes. | ||
* This event fires on the initiating client before any database update occurs. | ||
* @param combat - The Combat encounter which is advancing or rewinding its turn | ||
* @param updateData - An object which contains Combat properties that will be updated. Can be mutated. | ||
* @param updateOptions - An object which contains options provided to the update method. Can be mutated. | ||
|
@@ -657,7 +685,7 @@ declare global { | |
chatLog: ChatLog, | ||
message: string, | ||
chatData: { | ||
/** The User sending the message */ | ||
/** The id of the User sending the message */ | ||
user: string; | ||
|
||
/** The identified speaker data, see {@link ChatMessage.getSpeaker} */ | ||
|
@@ -742,6 +770,13 @@ declare global { | |
data: object, | ||
) => boolean | void; | ||
|
||
/** | ||
* A hook event that allows to pass custom dynamic ring configurations. | ||
* @param ringConfig - The ring configuration instance | ||
* @remarks This is called by {@link Hooks.callAll}. | ||
*/ | ||
initializeDynamicTokenRingConfig: (ringConfig: foundry.canvas.tokens.TokenRingConfig) => void; | ||
|
||
/** Specific implementations of GetEntryContext */ | ||
|
||
/** | ||
|
@@ -810,18 +845,38 @@ declare global { | |
*/ | ||
type CloseApplication<A extends Application = Application> = (app: A, html: JQuery) => boolean | void; | ||
|
||
/** EffectsCanvasGroup */ | ||
|
||
/** | ||
* A hook event that fires when a {@link CanvasGroup} is drawn. | ||
* The dispatched event name replaces "Group" with the named CanvasGroup subclass, i.e. "drawPrimaryCanvasGroup". | ||
* @param group - The group being drawn | ||
*/ | ||
type DrawGroup< | ||
G extends ReturnType<typeof CanvasGroupMixin> = ReturnType<typeof CanvasGroupMixin<CanvasGroupMixin.BaseClass>>, | ||
> = (group: G) => void; | ||
|
||
/** | ||
* A hook event that fires when a {@link CanvasGroup} is deconstructed. | ||
* The dispatched event name replaces "Group" with the named CanvasGroup subclass, i.e. "tearDownPrimaryCanvasGroup". | ||
* @param group - The group being deconstructed | ||
*/ | ||
type TearDownGroup< | ||
G extends ReturnType<typeof CanvasGroupMixin> = ReturnType<typeof CanvasGroupMixin<CanvasGroupMixin.BaseClass>>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd also be useful here. |
||
> = (group: G) => void; | ||
|
||
/** CanvasLayer */ | ||
|
||
/** | ||
* A hook event that fires with a {@link CanvasLayer} is initially drawn. | ||
* A hook event that fires when a {@link CanvasLayer} is initially drawn. | ||
* The dispatched event name replaces "Layer" with the named CanvasLayer subclass, i.e. "drawTokensLayer". | ||
* @param layer - The layer being drawn | ||
* @typeParam L - the type of the CanvasLayer | ||
*/ | ||
type DrawLayer<L extends CanvasLayer = CanvasLayer> = (layer: L) => void; | ||
|
||
/** | ||
* A hook event that fires with a {@link CanvasLayer} is deconstructed. | ||
* A hook event that fires when a {@link CanvasLayer} is deconstructed. | ||
* The dispatched event name replaces "Layer" with the named CanvasLayer subclass, i.e. "tearDownTokensLayer". | ||
* @param layer - The layer being deconstructed | ||
* @typeParam L - the type of the CanvasLayer | ||
|
@@ -941,7 +996,7 @@ declare global { | |
* that data or prevent the workflow entirely by explicitly returning false. | ||
* | ||
* @param document - The Document instance being updated | ||
* @param change - Differential data that will be used to update the document | ||
* @param changed - Differential data that will be used to update the document | ||
* @param options - Additional options which modify the update request | ||
* @param userId - The ID of the requesting user, always game.user.id | ||
* @typeParam D - the type of the Document constructor | ||
|
@@ -953,7 +1008,7 @@ declare global { | |
*/ | ||
type PreUpdateDocument<D extends Document.AnyConstructor = Document.AnyConstructor> = ( | ||
document: Document.ToConfiguredInstance<D>, | ||
change: DeepPartial<ConstructorParameters<D>[0]>, | ||
changed: DeepPartial<ConstructorParameters<D>[0]>, | ||
options: Document.PreUpdateOptions<InstanceType<D>["documentName"]>, | ||
userId: string, | ||
) => boolean | void; | ||
|
@@ -1053,7 +1108,7 @@ declare global { | |
* @remarks The name for this hook is dynamically created by wrapping the type name of the shader in `initialize` and `Shaders`. | ||
* @remarks This is called by {@link Hooks.callAll}. | ||
*/ | ||
type InitializeRenderedPointSourceShaders<RPS extends RenderedEffectSource.Any = RenderedEffectSource.Any> = ( | ||
type InitializeRenderedEffectSourceShaders<RPS extends RenderedEffectSource.Any = RenderedEffectSource.Any> = ( | ||
source: RPS, | ||
) => void; | ||
|
||
|
@@ -1114,6 +1169,8 @@ declare global { | |
| RenderApplication | ||
| GetApplicationHeaderButtons | ||
| CloseApplication | ||
| DrawGroup | ||
| TearDownGroup | ||
| DrawLayer | ||
| TearDownLayer | ||
| PastePlaceableObject | ||
|
@@ -1127,7 +1184,7 @@ declare global { | |
| CreateDocument | ||
| UpdateDocument | ||
| DeleteDocument | ||
| InitializeRenderedPointSourceShaders | ||
| InitializeRenderedEffectSourceShaders | ||
| ActivateLayer | ||
| DeactivateLayer | ||
| GetEntryContext | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this suggests we should have an interface and possible namespace named
CanvasGroup
available in the global scope.I kind of like the idea of being able to write
CanvasGroup.Any
.On that note I'm pretty sure
ReturnType<typeof CanvasGroupMixin>
is the same thing asReturnType<typeof CanvasGroupMixin<CanvasGroupMixin.BaseClass>>
because when generics are left off they seem to default to their generic constraint.So I think this could be
CanvasGroup.Any = CanvasGroup.Any
or possiblyCanvasGroupMixin.Any
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll write that up as a ticket?
EDIT: Done #2937