diff options
author | lutangar <johan.dufour@gmail.com> | 2021-11-09 13:49:08 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-12-16 10:08:43 +0100 |
commit | b8fa3e8c734a46918118afe7976f248cc883f675 (patch) | |
tree | 0ebf8fd10b1c690602da14d4dd626cd04a9ff748 /support/doc | |
parent | 8b03e2ce1a2098261de2f729f660b1ae2a320b65 (diff) | |
download | PeerTube-b8fa3e8c734a46918118afe7976f248cc883f675.tar.gz PeerTube-b8fa3e8c734a46918118afe7976f248cc883f675.tar.zst PeerTube-b8fa3e8c734a46918118afe7976f248cc883f675.zip |
refactor(types): create dedicated folder for types package src
fix guide examples and add types package readme
refactor(tsconfig): move back base tsconfig to base directory
Diffstat (limited to 'support/doc')
-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 | ||