Using types declarations from the official @peertube/peertube-types package.
This commit is contained in:
80
client/@types/peertube.d.ts
vendored
80
client/@types/peertube.d.ts
vendored
@ -1,80 +0,0 @@
|
||||
// TODO: import @types/peertube when available
|
||||
|
||||
interface RegisterClientHookOptions {
|
||||
target: string // FIXME
|
||||
handler: Function
|
||||
priority?: number
|
||||
}
|
||||
|
||||
interface RegisterClientHelpers {
|
||||
getBaseStaticRoute: () => string
|
||||
// NB: getBaseRouterRoute will come with Peertube > 3.2.1 (3.3.0?)
|
||||
getBaseRouterRoute?: () => string
|
||||
isLoggedIn: () => boolean
|
||||
getAuthHeader: () => { 'Authorization': string } | undefined
|
||||
getSettings: () => Promise<{ [ name: string ]: string }>
|
||||
notifier: {
|
||||
info: (text: string, title?: string, timeout?: number) => void
|
||||
error: (text: string, title?: string, timeout?: number) => void
|
||||
success: (text: string, title?: string, timeout?: number) => void
|
||||
}
|
||||
showModal: (input: {
|
||||
title: string
|
||||
content: string
|
||||
close?: boolean
|
||||
cancel?: { value: string, action?: () => void }
|
||||
confirm?: { value: string, action?: () => void }
|
||||
}) => void
|
||||
markdownRenderer: {
|
||||
textMarkdownToHTML: (textMarkdown: string) => Promise<string>
|
||||
enhancedMarkdownToHTML: (enhancedMarkdown: string) => Promise<string>
|
||||
}
|
||||
translate: (toTranslate: string) => Promise<string>
|
||||
}
|
||||
|
||||
interface RegisterClientFormFieldOptions {
|
||||
name: string
|
||||
label: string
|
||||
type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced'
|
||||
descriptionHTML?: string
|
||||
default?: string | boolean
|
||||
hidden?: (options: any) => boolean
|
||||
}
|
||||
interface RegisterClientSettingsScript {
|
||||
isSettingHidden: (options: {
|
||||
setting: RegisterClientFormFieldOptions
|
||||
formValues: { [name: string]: any }
|
||||
}) => boolean
|
||||
}
|
||||
|
||||
interface RegisterClientVideoFieldOptions {
|
||||
type: 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live'
|
||||
}
|
||||
|
||||
interface RegisterOptions {
|
||||
registerHook: (options: RegisterClientHookOptions) => void
|
||||
peertubeHelpers: RegisterClientHelpers
|
||||
registerSettingsScript: (options: RegisterClientSettingsScript) => void
|
||||
registerVideoField: (
|
||||
commonOptions: RegisterClientFormFieldOptions,
|
||||
videoFormOptions: RegisterClientVideoFieldOptions
|
||||
) => void
|
||||
}
|
||||
|
||||
interface Video {
|
||||
isLive: boolean
|
||||
isLocal: boolean
|
||||
name: string
|
||||
originInstanceUrl: string
|
||||
uuid: string
|
||||
channel: Channel
|
||||
byAccount: string
|
||||
}
|
||||
|
||||
interface Channel {
|
||||
id: number
|
||||
name: string
|
||||
displayName: string
|
||||
url: string
|
||||
host: string
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import type { Video } from '@peertube/peertube-types'
|
||||
import type { ChatType, ProsodyListRoomsResult } from 'shared/lib/types'
|
||||
|
||||
interface ActionPluginSettingsParams {
|
||||
npmName: string
|
||||
}
|
||||
|
||||
function register ({ registerHook, registerSettingsScript, peertubeHelpers }: RegisterOptions): void {
|
||||
function register ({ registerHook, registerSettingsScript, peertubeHelpers }: RegisterClientOptions): void {
|
||||
function getBaseRoute (): string {
|
||||
// NB: this will come with Peertube > 3.2.1 (3.3.0?)
|
||||
if (peertubeHelpers.getBaseRouterRoute) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import type { RegisterClientFormFieldOptions } from '@peertube/peertube-types'
|
||||
|
||||
async function register ({ peertubeHelpers, registerHook, registerVideoField }: RegisterOptions): Promise<void> {
|
||||
async function register ({ peertubeHelpers, registerHook, registerVideoField }: RegisterClientOptions): Promise<void> {
|
||||
registerHook({
|
||||
target: 'action:router.navigation-end',
|
||||
handler: () => {
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "es6",
|
||||
"moduleResolution": "node",
|
||||
"target": "es5",
|
||||
"allowJs": true,
|
||||
"sourceMap": true,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import type { Video } from '@peertube/peertube-types'
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import { videoHasWebchat } from 'shared/lib/video'
|
||||
import { logger } from './videowatch/logger'
|
||||
import { closeSVG, openBlankChatSVG, openChatSVG, shareChatUrlSVG } from './videowatch/buttons'
|
||||
@ -11,7 +13,7 @@ interface VideoWatchLoadedHookOptions {
|
||||
playlist?: any
|
||||
}
|
||||
|
||||
function guessIsMine (registerOptions: RegisterOptions, video: Video): boolean {
|
||||
function guessIsMine (registerOptions: RegisterClientOptions, video: Video): boolean {
|
||||
// Note: this is not safe, but it is not a problem:
|
||||
// this function is used for non critical functions
|
||||
try {
|
||||
@ -28,7 +30,7 @@ function guessIsMine (registerOptions: RegisterOptions, video: Video): boolean {
|
||||
if (!username) {
|
||||
return false
|
||||
}
|
||||
if (username !== video.byAccount) {
|
||||
if (username !== video.account?.name) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@ -38,7 +40,7 @@ function guessIsMine (registerOptions: RegisterOptions, video: Video): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
function guessIamIModerator (_registerOptions: RegisterOptions): boolean {
|
||||
function guessIamIModerator (_registerOptions: RegisterClientOptions): boolean {
|
||||
// Note: this is not safe, but it is not a problem:
|
||||
// this function is used for non critical functions
|
||||
try {
|
||||
@ -59,7 +61,7 @@ function guessIamIModerator (_registerOptions: RegisterOptions): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
function register (registerOptions: RegisterOptions): void {
|
||||
function register (registerOptions: RegisterClientOptions): void {
|
||||
const { registerHook, peertubeHelpers } = registerOptions
|
||||
let settings: any = {}
|
||||
|
||||
@ -161,7 +163,7 @@ function register (registerOptions: RegisterOptions): void {
|
||||
return false
|
||||
}
|
||||
|
||||
logger.info('Trying to load the chat for video ' + video.uuid + '.')
|
||||
logger.info(`Trying to load the chat for video ${video.uuid}.`)
|
||||
const iframeUri = getIframeUri(registerOptions, settings, video)
|
||||
if (!iframeUri) {
|
||||
logger.error('Incorrect iframe uri')
|
||||
|
@ -1,3 +1,5 @@
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import type { Video } from '@peertube/peertube-types'
|
||||
import { logger } from './logger'
|
||||
import { getIframeUri, UriOptions } from './uri'
|
||||
import { isAutoColorsAvailable } from 'shared/lib/autocolors'
|
||||
@ -10,7 +12,7 @@ interface ShareForm {
|
||||
autoColors?: HTMLInputElement
|
||||
}
|
||||
|
||||
async function shareChatUrl (registerOptions: RegisterOptions, settings: any, video: Video): Promise<void> {
|
||||
async function shareChatUrl (registerOptions: RegisterClientOptions, settings: any, video: Video): Promise<void> {
|
||||
const peertubeHelpers = registerOptions.peertubeHelpers
|
||||
|
||||
const [
|
||||
|
@ -1,3 +1,5 @@
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import type { Video } from '@peertube/peertube-types'
|
||||
import type { ChatType } from 'shared/lib/types'
|
||||
import { AutoColors, isAutoColorsAvailable } from 'shared/lib/autocolors'
|
||||
import { logger } from './logger'
|
||||
@ -9,7 +11,7 @@ interface UriOptions {
|
||||
permanent?: boolean
|
||||
}
|
||||
|
||||
function getBaseRoute ({ peertubeHelpers }: RegisterOptions, permanent: boolean = false): string {
|
||||
function getBaseRoute ({ peertubeHelpers }: RegisterClientOptions, permanent: boolean = false): string {
|
||||
if (permanent) {
|
||||
return '/plugins/livechat/router'
|
||||
}
|
||||
@ -23,7 +25,7 @@ function getBaseRoute ({ peertubeHelpers }: RegisterOptions, permanent: boolean
|
||||
}
|
||||
|
||||
function getIframeUri (
|
||||
registerOptions: RegisterOptions, settings: any, video: Video, uriOptions: UriOptions = {}
|
||||
registerOptions: RegisterClientOptions, settings: any, video: Video, uriOptions: UriOptions = {}
|
||||
): string | null {
|
||||
if (!settings) {
|
||||
logger.error('Settings are not initialized, too soon to compute the iframeUri')
|
||||
|
Reference in New Issue
Block a user