Fix videojs typings
authorChocobozzz <me@florianbigard.com>
Fri, 17 Apr 2020 09:20:12 +0000 (11:20 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 17 Apr 2020 12:12:43 +0000 (14:12 +0200)
24 files changed:
client/src/assets/player/bezels/bezels-plugin.ts
client/src/assets/player/bezels/pause-bezel.ts
client/src/assets/player/p2p-media-loader/hls-plugin.ts
client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
client/src/assets/player/peertube-player-manager.ts
client/src/assets/player/peertube-plugin.ts
client/src/assets/player/peertube-videojs-typings.ts
client/src/assets/player/upnext/end-card.ts
client/src/assets/player/upnext/upnext-plugin.ts
client/src/assets/player/videojs-components/next-video-button.ts
client/src/assets/player/videojs-components/p2p-info-button.ts
client/src/assets/player/videojs-components/peertube-link-button.ts
client/src/assets/player/videojs-components/peertube-load-progress-bar.ts
client/src/assets/player/videojs-components/resolution-menu-button.ts
client/src/assets/player/videojs-components/resolution-menu-item.ts
client/src/assets/player/videojs-components/settings-dialog.ts
client/src/assets/player/videojs-components/settings-menu-button.ts
client/src/assets/player/videojs-components/settings-menu-item.ts
client/src/assets/player/videojs-components/settings-panel-child.ts
client/src/assets/player/videojs-components/settings-panel.ts
client/src/assets/player/videojs-components/theater-button.ts
client/src/assets/player/webtorrent/webtorrent-plugin.ts
client/src/standalone/videos/embed.ts
client/tsconfig.json

index 49917752622b45c458a4cd415fa3016221ea5a90..ad8bfa70370ffebca898ec6deaef425fe23c67e4 100644 (file)
@@ -1,11 +1,11 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import './pause-bezel'
 
 const Plugin = videojs.getPlugin('plugin')
 
 class BezelsPlugin extends Plugin {
 
-  constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) {
+  constructor (player: videojs.Player, options?: videojs.ComponentOptions) {
     super(player)
 
     this.player.ready(() => {
index 98eb12099e3db74a93cb4f41c5920cbd0ed68aa7..d9ef9a390ba3bb1d8bb465f0aeeb8fe5751bba2a 100644 (file)
@@ -1,4 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 function getPauseBezel () {
   return `
@@ -34,7 +34,7 @@ const Component = videojs.getComponent('Component')
 class PauseBezel extends Component {
   container: HTMLDivElement
 
-  constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) {
+  constructor (player: videojs.Player, options?: videojs.ComponentOptions) {
     super(player, options)
 
     player.on('pause', (_: any) => {
index 876ed7d9c89edf7918ae857aaad74959731d097e..6937d147ab4cab5215baa2d4109642d8e07eda8d 100644 (file)
@@ -2,7 +2,7 @@
 // We duplicated this plugin to choose the hls.js version we want, because streamroot only provide a bundled file
 
 import * as Hlsjs from 'hls.js/dist/hls.light.js'
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { HlsjsConfigHandlerOptions, QualityLevelRepresentation, QualityLevels, VideoJSTechHLS } from '../peertube-videojs-typings'
 
 type ErrorCounts = {
@@ -55,7 +55,7 @@ const registerSourceHandler = function (vjs: typeof videojs) {
   (vjs as any).Html5Hlsjs = Html5Hlsjs
 }
 
-function hlsjsConfigHandler (this: VideoJsPlayer, options: HlsjsConfigHandlerOptions) {
+function hlsjsConfigHandler (this: videojs.Player, options: HlsjsConfigHandlerOptions) {
   const player = this
 
   if (!options) return
@@ -88,7 +88,7 @@ class Html5Hlsjs {
 
   private readonly videoElement: HTMLVideoElement
   private readonly errorCounts: ErrorCounts = {}
-  private readonly player: VideoJsPlayer
+  private readonly player: videojs.Player
   private readonly tech: videojs.Tech
   private readonly source: videojs.Tech.SourceObject
   private readonly vjs: typeof videojs
index ca205d899c9d241bdbe3b55b47d68a9b1855313d..161c92b5e300ed6110b458f1d7014e4e888880fb 100644 (file)
@@ -1,4 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../peertube-videojs-typings'
 import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs'
 import { Events, Segment } from 'p2p-media-loader-core'
@@ -36,7 +36,7 @@ class P2pMediaLoaderPlugin extends Plugin {
 
   private networkInfoInterval: any
 
-  constructor (player: VideoJsPlayer, options?: P2PMediaLoaderPluginOptions) {
+  constructor (player: videojs.Player, options?: P2PMediaLoaderPluginOptions) {
     super(player)
 
     this.options = options
index 6d9236a9da9deea36da764d65b917b9f5b7d2d72..50701eefe4f7b7ad848d066e088caca7c9b05b21 100644 (file)
@@ -1,5 +1,5 @@
 import { VideoFile } from '../../../../shared/models/videos'
-import videojs, { VideoJsPlayer, VideoJsPlayerOptions } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import 'videojs-hotkeys'
 import 'videojs-dock'
 import 'videojs-contextmenu-ui'
@@ -99,9 +99,9 @@ export type PeertubePlayerManagerOptions = {
 
 export class PeertubePlayerManager {
   private static playerElementClassName: string
-  private static onPlayerChange: (player: VideoJsPlayer) => void
+  private static onPlayerChange: (player: videojs.Player) => void
 
-  static async initialize (mode: PlayerMode, options: PeertubePlayerManagerOptions, onPlayerChange: (player: VideoJsPlayer) => void) {
+  static async initialize (mode: PlayerMode, options: PeertubePlayerManagerOptions, onPlayerChange: (player: videojs.Player) => void) {
     let p2pMediaLoader: any
 
     this.onPlayerChange = onPlayerChange
@@ -121,7 +121,7 @@ export class PeertubePlayerManager {
 
     const self = this
     return new Promise(res => {
-      videojs(options.common.playerElement, videojsOptions, function (this: VideoJsPlayer) {
+      videojs(options.common.playerElement, videojsOptions, function (this: videojs.Player) {
         const player = this
 
         let alreadyFallback = false
@@ -171,7 +171,7 @@ export class PeertubePlayerManager {
     const videojsOptions = this.getVideojsOptions(mode, options)
 
     const self = this
-    videojs(newVideoElement, videojsOptions, function (this: VideoJsPlayer) {
+    videojs(newVideoElement, videojsOptions, function (this: videojs.Player) {
       const player = this
 
       self.addContextMenu(mode, player, options.common.embedUrl)
@@ -184,7 +184,7 @@ export class PeertubePlayerManager {
     mode: PlayerMode,
     options: PeertubePlayerManagerOptions,
     p2pMediaLoaderModule?: any
-  ): VideoJsPlayerOptions {
+  ): videojs.PlayerOptions {
     const commonOptions = options.common
 
     let autoplay = commonOptions.autoplay
@@ -417,7 +417,7 @@ export class PeertubePlayerManager {
     return children
   }
 
-  private static addContextMenu (mode: PlayerMode, player: VideoJsPlayer, videoEmbedUrl: string) {
+  private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string) {
     const content = [
       {
         label: player.localize('Copy the video URL'),
@@ -427,7 +427,7 @@ export class PeertubePlayerManager {
       },
       {
         label: player.localize('Copy the video URL at the current time'),
-        listener: function (this: VideoJsPlayer) {
+        listener: function (this: videojs.Player) {
           copyToClipboard(buildVideoLink({ startTime: this.currentTime() }))
         }
       },
@@ -442,7 +442,7 @@ export class PeertubePlayerManager {
     if (mode === 'webtorrent') {
       content.push({
         label: player.localize('Copy magnet URI'),
-        listener: function (this: VideoJsPlayer) {
+        listener: function (this: videojs.Player) {
           copyToClipboard(this.webtorrent().getCurrentVideoFile().magnetUri)
         }
       })
index 19d1046769281f0738f084e9d0563b3574c41850..afd8d678b8258325da96bf86ea796b0c7a4d8864 100644 (file)
@@ -1,4 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core'
 import './videojs-components/settings-menu-button'
 import {
   PeerTubePluginOptions,
@@ -36,7 +36,7 @@ class PeerTubePlugin extends Plugin {
   private mouseInControlBar = false
   private readonly savedInactivityTimeout: number
 
-  constructor (player: VideoJsPlayer, options?: PeerTubePluginOptions) {
+  constructor (player: videojs.Player, options?: PeerTubePluginOptions) {
     super(player)
 
     this.videoViewUrl = options.videoViewUrl
index a4e4c580c12c4eb5e7153b0846886ceefc3eb985..9616dd326e85118109aac802b5fa456c65593ea5 100644 (file)
@@ -4,7 +4,7 @@ import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin
 import { PlayerMode } from './peertube-player-manager'
 import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
 import { VideoFile } from '@shared/models'
-import videojs from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { Config, Level } from 'hls.js'
 
 declare module 'video.js' {
index d121a83a9cbf161b1bd3743c95fe0cc0b9425b64..c39a9c91349ec143a0ec9efd01e574948e7f71f2 100644 (file)
@@ -1,4 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 function getMainTemplate (options: any) {
   return `
@@ -50,7 +50,7 @@ class EndCard extends Component {
   suspendedMessage: HTMLElement
   nextButton: HTMLElement
 
-  constructor (player: VideoJsPlayer, options: EndCardOptions) {
+  constructor (player: videojs.Player, options: EndCardOptions) {
     super(player, options)
 
     this.totalTicks = this.options_.timeout / this.interval
index 6512fec2c62687bceb540e242d302e3abf483aa3..ac7699e9ae827edb0cf1aa593949bd9ecca25ae1 100644 (file)
@@ -1,11 +1,11 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { EndCardOptions } from './end-card'
 
 const Plugin = videojs.getPlugin('plugin')
 
 class UpNextPlugin extends Plugin {
 
-  constructor (player: VideoJsPlayer, options: Partial<EndCardOptions> = {}) {
+  constructor (player: videojs.Player, options: Partial<EndCardOptions> = {}) {
     const settings = {
       next: options.next,
       getTitle: options.getTitle,
index bdb245dccfdb8e2d43a82a184d9ea64f1949aee0..c97ecdda679f19ec86c90fd4b0e96b5b74cc157c 100644 (file)
@@ -1,4 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 const Button = videojs.getComponent('Button')
 
@@ -9,7 +9,7 @@ export interface NextVideoButtonOptions extends videojs.ComponentOptions {
 class NextVideoButton extends Button {
   private readonly nextVideoButtonOptions: NextVideoButtonOptions
 
-  constructor (player: VideoJsPlayer, options?: NextVideoButtonOptions) {
+  constructor (player: videojs.Player, options?: NextVideoButtonOptions) {
     super(player, options)
 
     this.nextVideoButtonOptions = options
index db6806fed121d9605c53647b6f5598164187666d..e340337ede03681bf4fd6c1bf58a6bbfd189d63a 100644 (file)
@@ -1,5 +1,5 @@
 import { PlayerNetworkInfo } from '../peertube-videojs-typings'
-import videojs from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { bytes } from '../utils'
 
 const Button = videojs.getComponent('Button')
index 0db9762a5bdc179f6809546211dd55861500e1e6..4151758d4e76820c1c5a6a430f6c2f46fad923ed 100644 (file)
@@ -1,10 +1,10 @@
 import { buildVideoLink } from '../utils'
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 const Button = videojs.getComponent('Button')
 class PeerTubeLinkButton extends Button {
 
-  constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) {
+  constructor (player: videojs.Player, options?: videojs.ComponentOptions) {
     super(player, options)
   }
 
index 8168e8f2d2506c3440bd9b123944db19bffc24ab..395720c5378376f581051975c14e32de6217d719 100644 (file)
@@ -1,10 +1,10 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 const Component = videojs.getComponent('Component')
 
 class PeerTubeLoadProgressBar extends Component {
 
-  constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) {
+  constructor (player: videojs.Player, options?: videojs.ComponentOptions) {
     super(player, options)
 
     this.on(player, 'progress', this.update)
index 0fa6272e7bcf8ac2183efa6e32f252760f8c9bb7..d49ca02300d8217a05fef67bf68ccbcfd7cbefe5 100644 (file)
@@ -1,4 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 import { LoadedQualityData } from '../peertube-videojs-typings'
 import { ResolutionMenuItem } from './resolution-menu-item'
@@ -8,7 +8,7 @@ const MenuButton = videojs.getComponent('MenuButton')
 class ResolutionMenuButton extends MenuButton {
   labelEl_: HTMLElement
 
-  constructor (player: VideoJsPlayer, options?: videojs.MenuButtonOptions) {
+  constructor (player: videojs.Player, options?: videojs.MenuButtonOptions) {
     super(player, options)
 
     this.controlText('Quality')
index b039c4572a88b5dad12bba9a28a625cb5619dd75..cb0d219ad92d757c81a8d0b72e9cdb6ce7178e77 100644 (file)
@@ -1,4 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { AutoResolutionUpdateData, ResolutionUpdateData } from '../peertube-videojs-typings'
 
 const MenuItem = videojs.getComponent('MenuItem')
@@ -19,7 +19,7 @@ class ResolutionMenuItem extends MenuItem {
   private autoResolutionPossible: boolean
   private currentResolutionLabel: string
 
-  constructor (player: VideoJsPlayer, options?: ResolutionMenuItemOptions) {
+  constructor (player: videojs.Player, options?: ResolutionMenuItemOptions) {
     options.selectable = true
 
     super(player, options)
index dd0b1e4721343e080e8893747c34f00af5b141c3..8fd5ad96c01d1a48fa1b7c3edca4726a15d7bcb4 100644 (file)
@@ -1,9 +1,9 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 const Component = videojs.getComponent('Component')
 
 class SettingsDialog extends Component {
-  constructor (player: VideoJsPlayer) {
+  constructor (player: videojs.Player) {
     super(player)
 
     this.hide()
index eae628e7d05a2933c6ffb752794a8054e27409f0..749128bdce77c5630a2150dde76379788dd7bedc 100644 (file)
@@ -1,7 +1,7 @@
 // Thanks to Yanko Shterev: https://github.com/yshterev/videojs-settings-menu
 import { SettingsMenuItem } from './settings-menu-item'
 import { toTitleCase } from '../utils'
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 import { SettingsDialog } from './settings-dialog'
 import { SettingsPanel } from './settings-panel'
@@ -32,7 +32,7 @@ class SettingsButton extends Button {
 
   private settingsButtonOptions: SettingsButtonOptions
 
-  constructor (player: VideoJsPlayer, options?: SettingsButtonOptions) {
+  constructor (player: videojs.Player, options?: SettingsButtonOptions) {
     super(player, options)
 
     this.settingsButtonOptions = options
index f5671f49d9be2a98e2fa69247afa8135c4701912..8d364591bd4e5fe38d72ce95b0c44e07b7959c7f 100644 (file)
@@ -1,6 +1,6 @@
 // Thanks to Yanko Shterev: https://github.com/yshterev/videojs-settings-menu
 import { toTitleCase } from '../utils'
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { SettingsButton } from './settings-menu-button'
 import { SettingsDialog } from './settings-dialog'
 import { SettingsPanel } from './settings-panel'
@@ -32,7 +32,7 @@ class SettingsMenuItem extends MenuItem {
   settingsSubMenuValueEl_: HTMLElement
   settingsSubMenuEl_: HTMLElement
 
-  constructor (player: VideoJsPlayer, options?: SettingsMenuItemOptions) {
+  constructor (player: videojs.Player, options?: SettingsMenuItemOptions) {
     super(player, options)
 
     this.settingsButton = options.menuButton
index d12e8218a8f63fefa754464fec321175facdd6e0..6dee6d7dfa05f3ee0e1664451fce8e78aa7cc373 100644 (file)
@@ -1,10 +1,10 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 const Component = videojs.getComponent('Component')
 
 class SettingsPanelChild extends Component {
 
-  constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) {
+  constructor (player: videojs.Player, options?: videojs.ComponentOptions) {
     super(player, options)
   }
 
index 2090abf4516558fbd1d4fe42f9a7be90ff6cb7a8..833ee2f2114bf9ecccb1d1c66a2d5a858af78d15 100644 (file)
@@ -1,10 +1,10 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 
 const Component = videojs.getComponent('Component')
 
 class SettingsPanel extends Component {
 
-  constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) {
+  constructor (player: videojs.Player, options?: videojs.ComponentOptions) {
     super(player, options)
   }
 
index 1c8c9f154bdecb17bc886d4da54dec305b6348ca..41875af7152d13d8cb137ec4ad79a0b1725dbeb3 100644 (file)
@@ -1,4 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { saveTheaterInStore, getStoredTheater } from '../peertube-player-local-storage'
 
 const Button = videojs.getComponent('Button')
@@ -6,7 +6,7 @@ class TheaterButton extends Button {
 
   private static readonly THEATER_MODE_CLASS = 'vjs-theater-enabled'
 
-  constructor (player: VideoJsPlayer, options: videojs.ComponentOptions) {
+  constructor (player: videojs.Player, options: videojs.ComponentOptions) {
     super(player, options)
 
     const enabled = getStoredTheater()
index bf6b0a718dcbe024777916bf1ccf46ec091a27ea..26fb5a2451d9dd7876303d29b33aac52b5b12002 100644 (file)
@@ -1,5 +1,4 @@
-import videojs, { VideoJsPlayer } from 'video.js'
-
+import videojs from 'video.js/dist/alt/video.core.js'
 import * as WebTorrent from 'webtorrent'
 import { renderVideo } from './video-renderer'
 import { LoadedQualityData, PlayerNetworkInfo, WebtorrentPluginOptions } from '../peertube-videojs-typings'
@@ -31,7 +30,7 @@ class WebTorrentPlugin extends Plugin {
 
   private readonly autoplay: boolean = false
   private readonly startTime: number = 0
-  private readonly savePlayerSrcFunction: VideoJsPlayer['src']
+  private readonly savePlayerSrcFunction: videojs.Player['src']
   private readonly videoDuration: number
   private readonly CONSTANTS = {
     INFO_SCHEDULER: 1000, // Don't change this
@@ -69,7 +68,7 @@ class WebTorrentPlugin extends Plugin {
 
   private downloadSpeeds: number[] = []
 
-  constructor (player: VideoJsPlayer, options?: WebtorrentPluginOptions) {
+  constructor (player: videojs.Player, options?: WebtorrentPluginOptions) {
     super(player)
 
     this.startTime = timeToInt(options.startTime)
index 879850daf68adf461fbff343216f651b5d569f80..6616fab48708549120463506c24d561529b9aaa4 100644 (file)
@@ -15,14 +15,14 @@ import {
 import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
 import { PeerTubeEmbedApi } from './embed-api'
 import { TranslationsManager } from '../../assets/player/translations-manager'
-import { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js/dist/alt/video.core.js'
 import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
 
 type Translations = { [ id: string ]: string }
 
 export class PeerTubeEmbed {
   videoElement: HTMLVideoElement
-  player: VideoJsPlayer
+  player: videojs.Player
   api: PeerTubeEmbedApi = null
   autoplay: boolean
   controls: boolean
@@ -237,7 +237,7 @@ export class PeerTubeEmbed {
       })
     }
 
-    this.player = await PeertubePlayerManager.initialize(this.mode, options, (player: VideoJsPlayer) => this.player = player)
+    this.player = await PeertubePlayerManager.initialize(this.mode, options, (player: videojs.Player) => this.player = player)
     this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations))
 
     window[ 'videojsPlayer' ] = this.player
index 3c671e579ce3e666512fa275062fddf8c6b6f74f..d9e798f91ac053363ef367599a17fac75273fc7f 100644 (file)
     "paths": {
       "@app/*": [ "src/app/*" ],
       "@shared/*": [ "../shared/*" ],
-      "video.js": [ "node_modules/video.js/dist/alt/video.core" ],
-      "fs": [ "src/shims/noop" ],
-      "http": [ "src/shims/http" ],
-      "https": [ "src/shims/https" ],
-      "path": [ "src/shims/path" ],
-      "stream": [ "src/shims/noop" ],
-      "crypto": [ "src/shims/noop" ]
+      "fs": [ "src/shims/noop.ts" ],
+      "http": [ "src/shims/http.ts" ],
+      "https": [ "src/shims/https.ts" ],
+      "path": [ "src/shims/path.ts" ],
+      "stream": [ "src/shims/noop.ts" ],
+      "crypto": [ "src/shims/noop.ts" ]
     }
   },
   "angularCompilerOptions": {