diff options
Diffstat (limited to 'packages/models/src/plugins/client')
9 files changed, 280 insertions, 0 deletions
diff --git a/packages/models/src/plugins/client/client-hook.model.ts b/packages/models/src/plugins/client/client-hook.model.ts new file mode 100644 index 000000000..4a0818c99 --- /dev/null +++ b/packages/models/src/plugins/client/client-hook.model.ts | |||
@@ -0,0 +1,195 @@ | |||
1 | // Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target} | ||
2 | // Data in internal functions: {hookType}:{location}.{elementType}.{actionType}.{target} | ||
3 | |||
4 | export const clientFilterHookObject = { | ||
5 | // Filter params/result of the function that fetch videos of the trending page | ||
6 | 'filter:api.trending-videos.videos.list.params': true, | ||
7 | 'filter:api.trending-videos.videos.list.result': true, | ||
8 | |||
9 | // Filter params/result of the function that fetch videos of the trending page | ||
10 | 'filter:api.most-liked-videos.videos.list.params': true, | ||
11 | 'filter:api.most-liked-videos.videos.list.result': true, | ||
12 | |||
13 | // Filter params/result of the function that fetch videos of the local page | ||
14 | 'filter:api.local-videos.videos.list.params': true, | ||
15 | 'filter:api.local-videos.videos.list.result': true, | ||
16 | |||
17 | // Filter params/result of the function that fetch videos of the recently-added page | ||
18 | 'filter:api.recently-added-videos.videos.list.params': true, | ||
19 | 'filter:api.recently-added-videos.videos.list.result': true, | ||
20 | |||
21 | // Filter params/result of the function that fetch videos of the user subscription page | ||
22 | 'filter:api.user-subscriptions-videos.videos.list.params': true, | ||
23 | 'filter:api.user-subscriptions-videos.videos.list.result': true, | ||
24 | |||
25 | // Filter params/result of the function that fetch the video of the video-watch page | ||
26 | 'filter:api.video-watch.video.get.params': true, | ||
27 | 'filter:api.video-watch.video.get.result': true, | ||
28 | |||
29 | // Filter params/result of the function that fetch video playlist elements of the video-watch page | ||
30 | 'filter:api.video-watch.video-playlist-elements.get.params': true, | ||
31 | 'filter:api.video-watch.video-playlist-elements.get.result': true, | ||
32 | |||
33 | // Filter params/result of the function that fetch the threads of the video-watch page | ||
34 | 'filter:api.video-watch.video-threads.list.params': true, | ||
35 | 'filter:api.video-watch.video-threads.list.result': true, | ||
36 | |||
37 | // Filter params/result of the function that fetch the replies of a thread in the video-watch page | ||
38 | 'filter:api.video-watch.video-thread-replies.list.params': true, | ||
39 | 'filter:api.video-watch.video-thread-replies.list.result': true, | ||
40 | |||
41 | // Filter params/result of the function that fetch videos according to the user search | ||
42 | 'filter:api.search.videos.list.params': true, | ||
43 | 'filter:api.search.videos.list.result': true, | ||
44 | // Filter params/result of the function that fetch video channels according to the user search | ||
45 | 'filter:api.search.video-channels.list.params': true, | ||
46 | 'filter:api.search.video-channels.list.result': true, | ||
47 | // Filter params/result of the function that fetch video playlists according to the user search | ||
48 | 'filter:api.search.video-playlists.list.params': true, | ||
49 | 'filter:api.search.video-playlists.list.result': true, | ||
50 | |||
51 | // Filter form | ||
52 | 'filter:api.signup.registration.create.params': true, | ||
53 | |||
54 | // Filter params/result of the function that fetch video playlist elements of the my-library page | ||
55 | 'filter:api.my-library.video-playlist-elements.list.params': true, | ||
56 | 'filter:api.my-library.video-playlist-elements.list.result': true, | ||
57 | |||
58 | // Filter the options to create our player | ||
59 | 'filter:internal.video-watch.player.build-options.params': true, | ||
60 | 'filter:internal.video-watch.player.build-options.result': true, | ||
61 | |||
62 | // Filter the options to load a new video in our player | ||
63 | 'filter:internal.video-watch.player.load-options.params': true, | ||
64 | 'filter:internal.video-watch.player.load-options.result': true, | ||
65 | |||
66 | // Filter our SVG icons content | ||
67 | 'filter:internal.common.svg-icons.get-content.params': true, | ||
68 | 'filter:internal.common.svg-icons.get-content.result': true, | ||
69 | |||
70 | // Filter left menu links | ||
71 | 'filter:left-menu.links.create.result': true, | ||
72 | |||
73 | // Filter upload page alert messages | ||
74 | 'filter:upload.messages.create.result': true, | ||
75 | |||
76 | 'filter:login.instance-about-plugin-panels.create.result': true, | ||
77 | 'filter:signup.instance-about-plugin-panels.create.result': true, | ||
78 | |||
79 | 'filter:share.video-embed-code.build.params': true, | ||
80 | 'filter:share.video-embed-code.build.result': true, | ||
81 | 'filter:share.video-playlist-embed-code.build.params': true, | ||
82 | 'filter:share.video-playlist-embed-code.build.result': true, | ||
83 | |||
84 | 'filter:share.video-embed-url.build.params': true, | ||
85 | 'filter:share.video-embed-url.build.result': true, | ||
86 | 'filter:share.video-playlist-embed-url.build.params': true, | ||
87 | 'filter:share.video-playlist-embed-url.build.result': true, | ||
88 | |||
89 | 'filter:share.video-url.build.params': true, | ||
90 | 'filter:share.video-url.build.result': true, | ||
91 | 'filter:share.video-playlist-url.build.params': true, | ||
92 | 'filter:share.video-playlist-url.build.result': true, | ||
93 | |||
94 | 'filter:video-watch.video-plugin-metadata.result': true, | ||
95 | |||
96 | // Filter videojs options built for PeerTube player | ||
97 | 'filter:internal.player.videojs.options.result': true, | ||
98 | |||
99 | // Filter p2p media loader options built for PeerTube player | ||
100 | 'filter:internal.player.p2p-media-loader.options.result': true | ||
101 | } | ||
102 | |||
103 | export type ClientFilterHookName = keyof typeof clientFilterHookObject | ||
104 | |||
105 | export const clientActionHookObject = { | ||
106 | // Fired when the application is being initialized | ||
107 | 'action:application.init': true, | ||
108 | |||
109 | // Fired when the video watch page is being initialized | ||
110 | 'action:video-watch.init': true, | ||
111 | // Fired when the video watch page loaded the video | ||
112 | 'action:video-watch.video.loaded': true, | ||
113 | // Fired when the player finished loading | ||
114 | 'action:video-watch.player.loaded': true, | ||
115 | // Fired when the video watch page comments(threads) are loaded and load more comments on scroll | ||
116 | 'action:video-watch.video-threads.loaded': true, | ||
117 | // Fired when a user click on 'View x replies' and they're loaded | ||
118 | 'action:video-watch.video-thread-replies.loaded': true, | ||
119 | |||
120 | // Fired when the video channel creation page is being initialized | ||
121 | 'action:video-channel-create.init': true, | ||
122 | |||
123 | // Fired when the video channel update page is being initialized | ||
124 | 'action:video-channel-update.init': true, | ||
125 | 'action:video-channel-update.video-channel.loaded': true, | ||
126 | |||
127 | // Fired when the page that list video channel videos is being initialized | ||
128 | 'action:video-channel-videos.init': true, | ||
129 | 'action:video-channel-videos.video-channel.loaded': true, | ||
130 | 'action:video-channel-videos.videos.loaded': true, | ||
131 | |||
132 | // Fired when the page that list video channel playlists is being initialized | ||
133 | 'action:video-channel-playlists.init': true, | ||
134 | 'action:video-channel-playlists.video-channel.loaded': true, | ||
135 | 'action:video-channel-playlists.playlists.loaded': true, | ||
136 | |||
137 | // Fired when the video edit page (upload, URL/torrent import, update) is being initialized | ||
138 | // Contains a `type` and `updateForm` object attributes | ||
139 | 'action:video-edit.init': true, | ||
140 | |||
141 | // Fired when values of the video edit form changed | ||
142 | 'action:video-edit.form.updated': true, | ||
143 | |||
144 | // Fired when the login page is being initialized | ||
145 | 'action:login.init': true, | ||
146 | |||
147 | // Fired when the search page is being initialized | ||
148 | 'action:search.init': true, | ||
149 | |||
150 | // Fired every time Angular URL changes | ||
151 | 'action:router.navigation-end': true, | ||
152 | |||
153 | // Fired when the registration page is being initialized | ||
154 | 'action:signup.register.init': true, | ||
155 | |||
156 | // PeerTube >= 3.2 | ||
157 | // Fired when the admin plugin settings page is being initialized | ||
158 | 'action:admin-plugin-settings.init': true, | ||
159 | |||
160 | // Fired when the video upload page is being initialized | ||
161 | 'action:video-upload.init': true, | ||
162 | // Fired when the video import by URL page is being initialized | ||
163 | 'action:video-url-import.init': true, | ||
164 | // Fired when the video import by torrent/magnet URI page is being initialized | ||
165 | 'action:video-torrent-import.init': true, | ||
166 | // Fired when the "Go Live" page is being initialized | ||
167 | 'action:go-live.init': true, | ||
168 | |||
169 | // Fired when the user explicitly logged in/logged out | ||
170 | 'action:auth-user.logged-in': true, | ||
171 | 'action:auth-user.logged-out': true, | ||
172 | // Fired when the application loaded user information (using tokens from the local storage or after a successful login) | ||
173 | 'action:auth-user.information-loaded': true, | ||
174 | |||
175 | // Fired when the modal to download a video/caption is shown | ||
176 | 'action:modal.video-download.shown': true, | ||
177 | // Fired when the modal to share a video/playlist is shown | ||
178 | 'action:modal.share.shown': true, | ||
179 | |||
180 | // ####### Embed hooks ####### | ||
181 | // /!\ In embed scope, peertube helpers are not available | ||
182 | // ########################### | ||
183 | |||
184 | // Fired when the embed loaded the player | ||
185 | 'action:embed.player.loaded': true | ||
186 | } | ||
187 | |||
188 | export type ClientActionHookName = keyof typeof clientActionHookObject | ||
189 | |||
190 | export const clientHookObject = Object.assign({}, clientFilterHookObject, clientActionHookObject) | ||
191 | export type ClientHookName = keyof typeof clientHookObject | ||
192 | |||
193 | export interface ClientHook { | ||
194 | runHook <T> (hookName: ClientHookName, result?: T, params?: any): Promise<T> | ||
195 | } | ||
diff --git a/packages/models/src/plugins/client/index.ts b/packages/models/src/plugins/client/index.ts new file mode 100644 index 000000000..04fa32d6d --- /dev/null +++ b/packages/models/src/plugins/client/index.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export * from './client-hook.model.js' | ||
2 | export * from './plugin-client-scope.type.js' | ||
3 | export * from './plugin-element-placeholder.type.js' | ||
4 | export * from './plugin-selector-id.type.js' | ||
5 | export * from './register-client-form-field.model.js' | ||
6 | export * from './register-client-hook.model.js' | ||
7 | export * from './register-client-route.model.js' | ||
8 | export * from './register-client-settings-script.model.js' | ||
diff --git a/packages/models/src/plugins/client/plugin-client-scope.type.ts b/packages/models/src/plugins/client/plugin-client-scope.type.ts new file mode 100644 index 000000000..c09a453b8 --- /dev/null +++ b/packages/models/src/plugins/client/plugin-client-scope.type.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | export type PluginClientScope = | ||
2 | 'common' | | ||
3 | 'video-watch' | | ||
4 | 'search' | | ||
5 | 'signup' | | ||
6 | 'login' | | ||
7 | 'embed' | | ||
8 | 'video-edit' | | ||
9 | 'admin-plugin' | | ||
10 | 'my-library' | | ||
11 | 'video-channel' | ||
diff --git a/packages/models/src/plugins/client/plugin-element-placeholder.type.ts b/packages/models/src/plugins/client/plugin-element-placeholder.type.ts new file mode 100644 index 000000000..7b8a2605b --- /dev/null +++ b/packages/models/src/plugins/client/plugin-element-placeholder.type.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export type PluginElementPlaceholder = | ||
2 | 'player-next' | | ||
3 | 'share-modal-playlist-settings' | | ||
4 | 'share-modal-video-settings' | ||
diff --git a/packages/models/src/plugins/client/plugin-selector-id.type.ts b/packages/models/src/plugins/client/plugin-selector-id.type.ts new file mode 100644 index 000000000..8d23314b5 --- /dev/null +++ b/packages/models/src/plugins/client/plugin-selector-id.type.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | export type PluginSelectorId = | ||
2 | 'login-form' | | ||
3 | 'menu-user-dropdown-language-item' | | ||
4 | 'about-instance-features' | | ||
5 | 'about-instance-statistics' | | ||
6 | 'about-instance-moderation' | | ||
7 | 'about-menu-instance' | | ||
8 | 'about-menu-peertube' | | ||
9 | 'about-menu-network' | | ||
10 | 'about-instance-other-information' | ||
diff --git a/packages/models/src/plugins/client/register-client-form-field.model.ts b/packages/models/src/plugins/client/register-client-form-field.model.ts new file mode 100644 index 000000000..153c4a6ea --- /dev/null +++ b/packages/models/src/plugins/client/register-client-form-field.model.ts | |||
@@ -0,0 +1,30 @@ | |||
1 | export type RegisterClientFormFieldOptions = { | ||
2 | name?: string | ||
3 | label?: string | ||
4 | type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced' | 'select' | 'html' | ||
5 | |||
6 | // For select type | ||
7 | options?: { value: string, label: string }[] | ||
8 | |||
9 | // For html type | ||
10 | html?: string | ||
11 | |||
12 | descriptionHTML?: string | ||
13 | |||
14 | // Default setting value | ||
15 | default?: string | boolean | ||
16 | |||
17 | // Not supported by plugin setting registration, use registerSettingsScript instead | ||
18 | hidden?: (options: any) => boolean | ||
19 | |||
20 | // Return undefined | null if there is no error or return a string with the detailed error | ||
21 | // Not supported by plugin setting registration | ||
22 | error?: (options: any) => Promise<{ error: boolean, text?: string }> | ||
23 | } | ||
24 | |||
25 | export interface RegisterClientVideoFieldOptions { | ||
26 | type: 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live' | ||
27 | |||
28 | // Default to 'plugin-settings' | ||
29 | tab?: 'main' | 'plugin-settings' | ||
30 | } | ||
diff --git a/packages/models/src/plugins/client/register-client-hook.model.ts b/packages/models/src/plugins/client/register-client-hook.model.ts new file mode 100644 index 000000000..19159ed1e --- /dev/null +++ b/packages/models/src/plugins/client/register-client-hook.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { ClientHookName } from './client-hook.model.js' | ||
2 | |||
3 | export interface RegisterClientHookOptions { | ||
4 | target: ClientHookName | ||
5 | handler: Function | ||
6 | priority?: number | ||
7 | } | ||
diff --git a/packages/models/src/plugins/client/register-client-route.model.ts b/packages/models/src/plugins/client/register-client-route.model.ts new file mode 100644 index 000000000..271b67834 --- /dev/null +++ b/packages/models/src/plugins/client/register-client-route.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export interface RegisterClientRouteOptions { | ||
2 | route: string | ||
3 | |||
4 | onMount (options: { | ||
5 | rootEl: HTMLElement | ||
6 | }): void | ||
7 | } | ||
diff --git a/packages/models/src/plugins/client/register-client-settings-script.model.ts b/packages/models/src/plugins/client/register-client-settings-script.model.ts new file mode 100644 index 000000000..7de3c1c28 --- /dev/null +++ b/packages/models/src/plugins/client/register-client-settings-script.model.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | import { RegisterServerSettingOptions } from '../server/index.js' | ||
2 | |||
3 | export interface RegisterClientSettingsScriptOptions { | ||
4 | isSettingHidden (options: { | ||
5 | setting: RegisterServerSettingOptions | ||
6 | formValues: { [name: string]: any } | ||
7 | }): boolean | ||
8 | } | ||