aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/doc/plugins
diff options
context:
space:
mode:
authorlutangar <johan.dufour@gmail.com>2021-11-09 13:49:08 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-12-16 10:08:43 +0100
commit8b03e2ce1a2098261de2f729f660b1ae2a320b65 (patch)
treeca4770cf86c9c54814dbb62bfc95ef38661646b2 /support/doc/plugins
parent06aad80165d09a8863ab8103149a8ff518b10641 (diff)
downloadPeerTube-8b03e2ce1a2098261de2f729f660b1ae2a320b65.tar.gz
PeerTube-8b03e2ce1a2098261de2f729f660b1ae2a320b65.tar.zst
PeerTube-8b03e2ce1a2098261de2f729f660b1ae2a320b65.zip
feat(types): create peertube-types package
Create dedicated Typescript "types" configuration file for each "projects". Create a types folder which includes every useful ts definition: - client - server - shared Add tooling to create a proper package, extract dependencies, etc... Add CI Github task. refactor(types): publish types package in release script
Diffstat (limited to 'support/doc/plugins')
-rw-r--r--support/doc/plugins/guide.md33
1 files changed, 33 insertions, 0 deletions
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,
884and will be supported by web browsers. 884and will be supported by web browsers.
885If you want to write modern JavaScript, please use a transpiler like [Babel](https://babeljs.io/). 885If you want to write modern JavaScript, please use a transpiler like [Babel](https://babeljs.io/).
886If you want to use __Typescript__ see section below.
887
888### Typescript
889
890You can add __PeerTube__ types as dev dependencies:
891```
892npm install --dev @peertube/peertube-types
893```
894
895This package exposes *server* definition files by default:
896```ts
897import { RegisterServerOptions } from '@peertube/peertube-types'
898
899export async function register ({ registerHook }: RegisterServerOptions) {
900 registerHook({
901 target: 'action:application.listening',
902 handler: () => displayHelloWorld()
903 })
904}
905```
906
907But it also exposes client types and various models used in __PeerTube__:
908```ts
909import { RegisterClientOptions } from '@peertube/peertube-types/client'
910
911export 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