From bfa1a32b34e14975e8f9ad43b5c9799fe5ced38a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 24 Jul 2019 11:55:08 +0200 Subject: Add client hook/register typings --- client/src/app/core/plugins/plugin.service.ts | 3 ++- client/src/types/client-script.model.ts | 7 +++++++ client/src/types/register-client-option.model.ts | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 client/src/types/client-script.model.ts create mode 100644 client/src/types/register-client-option.model.ts (limited to 'client') 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' import { ServerConfigPlugin } from '@shared/models' import { ServerService } from '@app/core/server/server.service' import { ClientScript } from '@shared/models/plugins/plugin-package-json.model' +import { ClientScript as ClientScriptModule } from '../../../types/client-script.model' import { environment } from '../../../environments/environment' import { ReplaySubject } from 'rxjs' import { first, shareReplay } from 'rxjs/operators' @@ -186,7 +187,7 @@ export class PluginService implements ClientHook { console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name) return import(/* webpackIgnore: true */ clientScript.script) - .then(script => script.register({ registerHook, peertubeHelpers })) + .then((script: ClientScriptModule) => script.register({ registerHook, peertubeHelpers })) .then(() => this.sortHooksByPriority()) } 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 @@ +import { RegisterClientOptions } from './register-client-option.model' + +export interface ClientScript { + register: (options: RegisterClientOptions) => Promise + + unregister: () => Promise +} 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 @@ +import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model' + +export type RegisterClientOptions = { + registerHook: (options: RegisterClientHookOptions) => void + + peertubeHelpers: { + getBaseStaticRoute: () => string + } +} -- cgit v1.2.3