diff options
Diffstat (limited to 'support')
-rw-r--r-- | support/doc/development/lib.md | 13 | ||||
-rw-r--r-- | support/doc/plugins/guide.md | 33 |
2 files changed, 46 insertions, 0 deletions
diff --git a/support/doc/development/lib.md b/support/doc/development/lib.md index 6b0372150..9c67a39dd 100644 --- a/support/doc/development/lib.md +++ b/support/doc/development/lib.md | |||
@@ -8,3 +8,16 @@ | |||
8 | $ cd client/src/standalone/player/ | 8 | $ cd client/src/standalone/player/ |
9 | $ npm run build | 9 | $ npm run build |
10 | ``` | 10 | ``` |
11 | |||
12 | ## @peertube/peertube-types | ||
13 | |||
14 | Typescript definition files generation is controlled by the various `tsconfig.types.json` files, see: | ||
15 | ``` | ||
16 | yarn tsc -b --verbose tsconfig.types.json | ||
17 | ``` | ||
18 | |||
19 | But the complete types package is generated via: | ||
20 | ``` | ||
21 | yarn generate-types-package | ||
22 | ``` | ||
23 | > See [scripts/generate-types-package.ts](scripts/generate-types-package.ts) for details. | ||
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 4a0d318a7..5c96d1b03 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md | |||
@@ -883,6 +883,39 @@ Now you can register hooks or settings, write CSS and add static directories to | |||
883 | **Caution:** It's up to you to check the code you write will be compatible with the PeerTube NodeJS version, | 883 | **Caution:** It's up to you to check the code you write will be compatible with the PeerTube NodeJS version, |
884 | and will be supported by web browsers. | 884 | and will be supported by web browsers. |
885 | If you want to write modern JavaScript, please use a transpiler like [Babel](https://babeljs.io/). | 885 | If you want to write modern JavaScript, please use a transpiler like [Babel](https://babeljs.io/). |
886 | If you want to use __Typescript__ see section below. | ||
887 | |||
888 | ### Typescript | ||
889 | |||
890 | You can add __PeerTube__ types as dev dependencies: | ||
891 | ``` | ||
892 | npm install --dev @peertube/peertube-types | ||
893 | ``` | ||
894 | |||
895 | This package exposes *server* definition files by default: | ||
896 | ```ts | ||
897 | import { RegisterServerOptions } from '@peertube/peertube-types' | ||
898 | |||
899 | export async function register ({ registerHook }: RegisterServerOptions) { | ||
900 | registerHook({ | ||
901 | target: 'action:application.listening', | ||
902 | handler: () => displayHelloWorld() | ||
903 | }) | ||
904 | } | ||
905 | ``` | ||
906 | |||
907 | But it also exposes client types and various models used in __PeerTube__: | ||
908 | ```ts | ||
909 | import { RegisterClientOptions } from '@peertube/peertube-types/client' | ||
910 | |||
911 | export function register ({ registerHook, peertubeHelpers }: RegisterClientOptions) { | ||
912 | registerHook({ | ||
913 | target: 'action:application.init', | ||
914 | handler: () => onApplicationInit(peertubeHelpers) | ||
915 | }) | ||
916 | } | ||
917 | ``` | ||
918 | > Other types are accessible from the shared path `@peertube/peertube-types/shared`. | ||
886 | 919 | ||
887 | ### Add translations | 920 | ### Add translations |
888 | 921 | ||