client-hook.model.ts 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target}
  2. // Data in internal functions: {hookType}:{location}.{elementType}.{actionType}.{target}
  3. export const clientFilterHookObject = {
  4. // Filter params/result of the function that fetch videos of the trending page
  5. 'filter:api.trending-videos.videos.list.params': true,
  6. 'filter:api.trending-videos.videos.list.result': true,
  7. // Filter params/result of the function that fetch videos of the trending page
  8. 'filter:api.most-liked-videos.videos.list.params': true,
  9. 'filter:api.most-liked-videos.videos.list.result': true,
  10. // Filter params/result of the function that fetch videos of the local page
  11. 'filter:api.local-videos.videos.list.params': true,
  12. 'filter:api.local-videos.videos.list.result': true,
  13. // Filter params/result of the function that fetch videos of the recently-added page
  14. 'filter:api.recently-added-videos.videos.list.params': true,
  15. 'filter:api.recently-added-videos.videos.list.result': true,
  16. // Filter params/result of the function that fetch videos of the user subscription page
  17. 'filter:api.user-subscriptions-videos.videos.list.params': true,
  18. 'filter:api.user-subscriptions-videos.videos.list.result': true,
  19. // Filter params/result of the function that fetch the video of the video-watch page
  20. 'filter:api.video-watch.video.get.params': true,
  21. 'filter:api.video-watch.video.get.result': true,
  22. // Filter params/result of the function that fetch video playlist elements of the video-watch page
  23. 'filter:api.video-watch.video-playlist-elements.get.params': true,
  24. 'filter:api.video-watch.video-playlist-elements.get.result': true,
  25. // Filter params/result of the function that fetch the threads of the video-watch page
  26. 'filter:api.video-watch.video-threads.list.params': true,
  27. 'filter:api.video-watch.video-threads.list.result': true,
  28. // Filter params/result of the function that fetch the replies of a thread in the video-watch page
  29. 'filter:api.video-watch.video-thread-replies.list.params': true,
  30. 'filter:api.video-watch.video-thread-replies.list.result': true,
  31. // Filter params/result of the function that fetch videos according to the user search
  32. 'filter:api.search.videos.list.params': true,
  33. 'filter:api.search.videos.list.result': true,
  34. // Filter params/result of the function that fetch video channels according to the user search
  35. 'filter:api.search.video-channels.list.params': true,
  36. 'filter:api.search.video-channels.list.result': true,
  37. // Filter params/result of the function that fetch video playlists according to the user search
  38. 'filter:api.search.video-playlists.list.params': true,
  39. 'filter:api.search.video-playlists.list.result': true,
  40. // Filter form
  41. 'filter:api.signup.registration.create.params': true,
  42. // Filter params/result of the function that fetch video playlist elements of the my-library page
  43. 'filter:api.my-library.video-playlist-elements.list.params': true,
  44. 'filter:api.my-library.video-playlist-elements.list.result': true,
  45. // Filter the options to create our player
  46. 'filter:internal.video-watch.player.build-options.params': true,
  47. 'filter:internal.video-watch.player.build-options.result': true,
  48. // Filter our SVG icons content
  49. 'filter:internal.common.svg-icons.get-content.params': true,
  50. 'filter:internal.common.svg-icons.get-content.result': true,
  51. // Filter left menu links
  52. 'filter:left-menu.links.create.result': true,
  53. // Filter upload page alert messages
  54. 'filter:upload.messages.create.result': true,
  55. 'filter:login.instance-about-plugin-panels.create.result': true,
  56. 'filter:signup.instance-about-plugin-panels.create.result': true,
  57. 'filter:share.video-embed-code.build.params': true,
  58. 'filter:share.video-embed-code.build.result': true,
  59. 'filter:share.video-playlist-embed-code.build.params': true,
  60. 'filter:share.video-playlist-embed-code.build.result': true,
  61. 'filter:share.video-embed-url.build.params': true,
  62. 'filter:share.video-embed-url.build.result': true,
  63. 'filter:share.video-playlist-embed-url.build.params': true,
  64. 'filter:share.video-playlist-embed-url.build.result': true,
  65. 'filter:share.video-url.build.params': true,
  66. 'filter:share.video-url.build.result': true,
  67. 'filter:share.video-playlist-url.build.params': true,
  68. 'filter:share.video-playlist-url.build.result': true,
  69. // Filter videojs options built for PeerTube player
  70. 'filter:internal.player.videojs.options.result': true
  71. }
  72. export type ClientFilterHookName = keyof typeof clientFilterHookObject
  73. export const clientActionHookObject = {
  74. // Fired when the application is being initialized
  75. 'action:application.init': true,
  76. // Fired when the video watch page is being initialized
  77. 'action:video-watch.init': true,
  78. // Fired when the video watch page loaded the video
  79. 'action:video-watch.video.loaded': true,
  80. // Fired when the player finished loading
  81. 'action:video-watch.player.loaded': true,
  82. // Fired when the video watch page comments(threads) are loaded and load more comments on scroll
  83. 'action:video-watch.video-threads.loaded': true,
  84. // Fired when a user click on 'View x replies' and they're loaded
  85. 'action:video-watch.video-thread-replies.loaded': true,
  86. // Fired when the video channel creation page is being initialized
  87. 'action:video-channel-create.init': true,
  88. // Fired when the video channel update page is being initialized
  89. 'action:video-channel-update.init': true,
  90. 'action:video-channel-update.video-channel.loaded': true,
  91. // Fired when the page that list video channel videos is being initialized
  92. 'action:video-channel-videos.init': true,
  93. 'action:video-channel-videos.video-channel.loaded': true,
  94. 'action:video-channel-videos.videos.loaded': true,
  95. // Fired when the page that list video channel playlists is being initialized
  96. 'action:video-channel-playlists.init': true,
  97. 'action:video-channel-playlists.video-channel.loaded': true,
  98. 'action:video-channel-playlists.playlists.loaded': true,
  99. // Fired when the video edit page (upload, URL/torrent import, update) is being initialized
  100. 'action:video-edit.init': true,
  101. // Fired when the login page is being initialized
  102. 'action:login.init': true,
  103. // Fired when the search page is being initialized
  104. 'action:search.init': true,
  105. // Fired every time Angular URL changes
  106. 'action:router.navigation-end': true,
  107. // Fired when the registration page is being initialized
  108. 'action:signup.register.init': true,
  109. // PeerTube >= 3.2
  110. // Fired when the admin plugin settings page is being initialized
  111. 'action:admin-plugin-settings.init': true,
  112. // Fired when the video upload page is being initialized
  113. 'action:video-upload.init': true,
  114. // Fired when the video import by URL page is being initialized
  115. 'action:video-url-import.init': true,
  116. // Fired when the video import by torrent/magnet URI page is being initialized
  117. 'action:video-torrent-import.init': true,
  118. // Fired when the "Go Live" page is being initialized
  119. 'action:go-live.init': true,
  120. // Fired when the user explicitly logged in/logged out
  121. 'action:auth-user.logged-in': true,
  122. 'action:auth-user.logged-out': true,
  123. // Fired when the application loaded user information (using tokens from the local storage or after a successful login)
  124. 'action:auth-user.information-loaded': true,
  125. // Fired when the modal to download a video/caption is shown
  126. 'action:modal.video-download.shown': true,
  127. // Fired when the modal to share a video/playlist is shown
  128. 'action:modal.share.shown': true,
  129. // ####### Embed hooks #######
  130. // /!\ In embed scope, peertube helpers are not available
  131. // ###########################
  132. // Fired when the embed loaded the player
  133. 'action:embed.player.loaded': true
  134. }
  135. export type ClientActionHookName = keyof typeof clientActionHookObject
  136. export const clientHookObject = Object.assign({}, clientFilterHookObject, clientActionHookObject)
  137. export type ClientHookName = keyof typeof clientHookObject
  138. export interface ClientHook {
  139. runHook <T> (hookName: ClientHookName, result?: T, params?: any): Promise<T>
  140. }