diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/core/plugins/plugin.service.ts | 3 | ||||
-rw-r--r-- | client/src/types/client-script.model.ts | 7 | ||||
-rw-r--r-- | client/src/types/register-client-option.model.ts | 9 |
3 files changed, 18 insertions, 1 deletions
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' | |||
3 | import { ServerConfigPlugin } from '@shared/models' | 3 | import { ServerConfigPlugin } from '@shared/models' |
4 | import { ServerService } from '@app/core/server/server.service' | 4 | import { ServerService } from '@app/core/server/server.service' |
5 | import { ClientScript } from '@shared/models/plugins/plugin-package-json.model' | 5 | import { ClientScript } from '@shared/models/plugins/plugin-package-json.model' |
6 | import { ClientScript as ClientScriptModule } from '../../../types/client-script.model' | ||
6 | import { environment } from '../../../environments/environment' | 7 | import { environment } from '../../../environments/environment' |
7 | import { ReplaySubject } from 'rxjs' | 8 | import { ReplaySubject } from 'rxjs' |
8 | import { first, shareReplay } from 'rxjs/operators' | 9 | import { 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 @@ | |||
1 | import { RegisterClientOptions } from './register-client-option.model' | ||
2 | |||
3 | export 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 @@ | |||
1 | import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model' | ||
2 | |||
3 | export type RegisterClientOptions = { | ||
4 | registerHook: (options: RegisterClientHookOptions) => void | ||
5 | |||
6 | peertubeHelpers: { | ||
7 | getBaseStaticRoute: () => string | ||
8 | } | ||
9 | } | ||