Refactor Hooks
Intent
As per #970 (closed) this MR splits the current hook files into atomic hooks.
- Refactor
src/modules/system/hooks.js
to use a loop to load hooks- Removes the need to both declare the import and then export the imported function manually
- Does limit us to using default exports for all hooks but we were following this pattern anyway
- Make each hook a default export (remove uneeded function names)
- Move all hooks into a folder structure that resembles other directory hierarchies
hooks/actor
hooks/actor/sheet
hooks/chat
hooks/item
- etc.
- Split overloaded hooks (multiple actions per hook) into single function hooks
- Some re-formatting of comments
New file layout:
src/modules/hooks/
├── actor
│ ├── sheet
│ │ ├── persist-section-views.js
│ │ ├── resize-name.js
│ │ └── resize-type-tag.js
│ ├── check-emp-and-luck.js
│ ├── set-default-image.js
│ ├── sync-black-ice-with-program.js
│ ├── sync-tracked-armor.js
│ ├── update-role-from-item.js
│ └── update-role-on-item-delete.js
├── chat
│ ├── add-glyphs.js
│ ├── hide-blind-rolls.js
│ └── parse-red-command.js
├── external
│ ├── babele.js
│ ├── drag-ruler.js
│ └── popout.js
├── foundry
│ ├── ui
│ │ ├── item-folder-upgraded-display.js
│ │ ├── pause-animation.js
│ │ └── theme.js
│ └── delete-folder.js
├── hotbar
│ └── generate-item-macro.js
├── item
│ ├── role
│ │ └── update-sub-roles.js
│ ├── sheet
│ └── set-default-image.js
└── token
├── add-dv-token-hud.js
├── close-unlinked-sheet-on-delete.js
└── warn-on-moving-locked-container.js
-
This is meant for a hotfix -
This is meant for the next release (see milestone) -
This needs more reviewers than normal; there may be controversy or high complexity -
This intentionally introduces regressions that will be addressed later -
There is/will be documentation changes on the wiki -
Please do not send commits here without coordinating closely with the owner -
This is a Build System change
Related Issues
Steps to Test
- Read the Diffs
AND
- Read each hook
- Understand what it's meant to do
- The comment/docstring should give you this information if it doesn't that should be considered a bug
- In Foundry do the thing that would tigger the Hook
- Make sure the hook fires (trace logs)
- Make sure the hook does what it's supposed to do
Future Work
hotbar.js
/hotbar/generate-item-macro.js
really should be refactored/split but it's a beast so I'm not doing it right now.
Edited by Ryan Walder