diff options
Diffstat (limited to 'support/doc/plugins')
-rw-r--r-- | support/doc/plugins/guide.md | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 5c96d1b03..92cc20db0 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md | |||
@@ -889,12 +889,12 @@ If you want to use __Typescript__ see section below. | |||
889 | 889 | ||
890 | You can add __PeerTube__ types as dev dependencies: | 890 | You can add __PeerTube__ types as dev dependencies: |
891 | ``` | 891 | ``` |
892 | npm install --dev @peertube/peertube-types | 892 | npm install --save-dev @peertube/peertube-types |
893 | ``` | 893 | ``` |
894 | 894 | ||
895 | This package exposes *server* definition files by default: | 895 | This package exposes *server* definition files by default: |
896 | ```ts | 896 | ```ts |
897 | import { RegisterServerOptions } from '@peertube/peertube-types' | 897 | import { RegisterServerOptions } from '@peertube/peertube-types/server/types' |
898 | 898 | ||
899 | export async function register ({ registerHook }: RegisterServerOptions) { | 899 | export async function register ({ registerHook }: RegisterServerOptions) { |
900 | registerHook({ | 900 | registerHook({ |
@@ -906,14 +906,33 @@ export async function register ({ registerHook }: RegisterServerOptions) { | |||
906 | 906 | ||
907 | But it also exposes client types and various models used in __PeerTube__: | 907 | But it also exposes client types and various models used in __PeerTube__: |
908 | ```ts | 908 | ```ts |
909 | import { RegisterClientOptions } from '@peertube/peertube-types/client' | 909 | import { RegisterClientOptions } from '@larriereguichet/peertube-types/client/types'; |
910 | import { Video } from '@larriereguichet/peertube-types/shared'; | ||
910 | 911 | ||
911 | export function register ({ registerHook, peertubeHelpers }: RegisterClientOptions) { | 912 | function register({ registerHook, peertubeHelpers }: RegisterClientOptions) { |
912 | registerHook({ | 913 | registerHook({ |
913 | target: 'action:application.init', | 914 | target: 'action:admin-plugin-settings.init', |
914 | handler: () => onApplicationInit(peertubeHelpers) | 915 | handler: ({ npmName }: { npmName: string }) => { |
915 | }) | 916 | if ('peertube-plugin-transcription' !== npmName) { |
917 | return; | ||
918 | } | ||
919 | }, | ||
920 | }); | ||
921 | |||
922 | registerHook({ | ||
923 | target: 'action:video-watch.video.loaded', | ||
924 | handler: ({ video }: { video: Video }) => { | ||
925 | fetch(`${peertubeHelpers.getBaseRouterRoute()}/videos/${video.uuid}/captions`, { | ||
926 | method: 'PUT', | ||
927 | headers: peertubeHelpers.getAuthHeader(), | ||
928 | }) | ||
929 | .then((res) => res.json()) | ||
930 | .then((data) => console.log('Hi %s.', data)); | ||
931 | }, | ||
932 | }); | ||
916 | } | 933 | } |
934 | |||
935 | export { register }; | ||
917 | ``` | 936 | ``` |
918 | > Other types are accessible from the shared path `@peertube/peertube-types/shared`. | 937 | > Other types are accessible from the shared path `@peertube/peertube-types/shared`. |
919 | 938 | ||