aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-24 11:55:08 +0200
committerChocobozzz <me@florianbigard.com>2019-07-24 11:55:08 +0200
commitbfa1a32b34e14975e8f9ad43b5c9799fe5ced38a (patch)
treef3d0d939cbcfa00be98884a0145740a4e928593f
parent9ae88819c202a6ce4a36b56506f508a5603e8eab (diff)
downloadPeerTube-bfa1a32b34e14975e8f9ad43b5c9799fe5ced38a.tar.gz
PeerTube-bfa1a32b34e14975e8f9ad43b5c9799fe5ced38a.tar.zst
PeerTube-bfa1a32b34e14975e8f9ad43b5c9799fe5ced38a.zip
Add client hook/register typings
-rw-r--r--.github/CONTRIBUTING.md7
-rw-r--r--client/src/app/core/plugins/plugin.service.ts3
-rw-r--r--client/src/types/client-script.model.ts7
-rw-r--r--client/src/types/register-client-option.model.ts9
-rw-r--r--support/doc/plugins/guide.md5
5 files changed, 29 insertions, 2 deletions
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 1672ebfa9..6fc80b6aa 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -7,8 +7,9 @@ Interested in contributing? Awesome!
7 * [Translate](#translate) 7 * [Translate](#translate)
8 * [Give your feedback](#give-your-feedback) 8 * [Give your feedback](#give-your-feedback)
9 * [Write documentation](#write-documentation) 9 * [Write documentation](#write-documentation)
10 * [Develop](#develop)
11 * [Improve the website](#improve-the-website) 10 * [Improve the website](#improve-the-website)
11 * [Develop](#develop)
12 * [Write a plugin or a theme](#plugins--themes)
12 13
13## Translate 14## Translate
14 15
@@ -199,3 +200,7 @@ $ npm run mocha -- --exit --require ts-node/register/type-check --bail server/te
199 200
200Instance configurations are in `config/test-{1,2,3,4,5,6}.yaml`. 201Instance configurations are in `config/test-{1,2,3,4,5,6}.yaml`.
201Note that only instance 2 has transcoding enabled. 202Note that only instance 2 has transcoding enabled.
203
204## Plugins & Themes
205
206See the dedicated documentation: https://docs.joinpeertube.org/#/contribute-plugins
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts
index e4a73de81..1294edd7d 100644
--- a/client/src/app/core/plugins/plugin.service.ts
+++ b/client/src/app/core/plugins/plugin.service.ts
@@ -3,6 +3,7 @@ import { Router } from '@angular/router'
3import { ServerConfigPlugin } from '@shared/models' 3import { ServerConfigPlugin } from '@shared/models'
4import { ServerService } from '@app/core/server/server.service' 4import { ServerService } from '@app/core/server/server.service'
5import { ClientScript } from '@shared/models/plugins/plugin-package-json.model' 5import { ClientScript } from '@shared/models/plugins/plugin-package-json.model'
6import { ClientScript as ClientScriptModule } from '../../../types/client-script.model'
6import { environment } from '../../../environments/environment' 7import { environment } from '../../../environments/environment'
7import { ReplaySubject } from 'rxjs' 8import { ReplaySubject } from 'rxjs'
8import { first, shareReplay } from 'rxjs/operators' 9import { first, shareReplay } from 'rxjs/operators'
@@ -186,7 +187,7 @@ export class PluginService implements ClientHook {
186 console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name) 187 console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name)
187 188
188 return import(/* webpackIgnore: true */ clientScript.script) 189 return import(/* webpackIgnore: true */ clientScript.script)
189 .then(script => script.register({ registerHook, peertubeHelpers })) 190 .then((script: ClientScriptModule) => script.register({ registerHook, peertubeHelpers }))
190 .then(() => this.sortHooksByPriority()) 191 .then(() => this.sortHooksByPriority())
191 } 192 }
192 193
diff --git a/client/src/types/client-script.model.ts b/client/src/types/client-script.model.ts
new file mode 100644
index 000000000..6197fcac9
--- /dev/null
+++ b/client/src/types/client-script.model.ts
@@ -0,0 +1,7 @@
1import { RegisterClientOptions } from './register-client-option.model'
2
3export interface ClientScript {
4 register: (options: RegisterClientOptions) => Promise<any>
5
6 unregister: () => Promise<any>
7}
diff --git a/client/src/types/register-client-option.model.ts b/client/src/types/register-client-option.model.ts
new file mode 100644
index 000000000..42d689403
--- /dev/null
+++ b/client/src/types/register-client-option.model.ts
@@ -0,0 +1,9 @@
1import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model'
2
3export type RegisterClientOptions = {
4 registerHook: (options: RegisterClientHookOptions) => void
5
6 peertubeHelpers: {
7 getBaseStaticRoute: () => string
8 }
9}
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index 0b2d337eb..8f8884d00 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -262,6 +262,11 @@ Every time you want to publish another version of your plugin/theme, just update
262and republish it on NPM. Remember that the PeerTube index will take into account your new plugin/theme version after ~24 hours. 262and republish it on NPM. Remember that the PeerTube index will take into account your new plugin/theme version after ~24 hours.
263 263
264 264
265## Plugin & Theme hooks/helpers API
266
267See the dedicated documentation: https://docs.joinpeertube.org/#/api-plugins
268
269
265## Tips 270## Tips
266 271
267### Compatibility with PeerTube 272### Compatibility with PeerTube