aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-31 14:34:36 +0200
committerChocobozzz <me@florianbigard.com>2023-08-11 15:02:33 +0200
commit3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch)
treee4510b39bdac9c318fdb4b47018d08f15368b8f0 /client/src/assets/player/shared
parent04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff)
downloadPeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'client/src/assets/player/shared')
-rw-r--r--client/src/assets/player/shared/common/utils.ts2
-rw-r--r--client/src/assets/player/shared/control-bar/peertube-link-button.ts2
-rw-r--r--client/src/assets/player/shared/metrics/metrics-plugin.ts4
-rw-r--r--client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts2
-rw-r--r--client/src/assets/player/shared/p2p-media-loader/segment-validator.ts2
-rw-r--r--client/src/assets/player/shared/peertube/peertube-plugin.ts4
-rw-r--r--client/src/assets/player/shared/player-options-builder/hls-options-builder.ts2
-rw-r--r--client/src/assets/player/shared/playlist/playlist-menu-item.ts4
-rw-r--r--client/src/assets/player/shared/playlist/playlist-menu.ts2
-rw-r--r--client/src/assets/player/shared/stats/stats-card.ts2
-rw-r--r--client/src/assets/player/shared/web-video/web-video-plugin.ts4
11 files changed, 15 insertions, 15 deletions
diff --git a/client/src/assets/player/shared/common/utils.ts b/client/src/assets/player/shared/common/utils.ts
index 609240626..4a7182021 100644
--- a/client/src/assets/player/shared/common/utils.ts
+++ b/client/src/assets/player/shared/common/utils.ts
@@ -1,4 +1,4 @@
1import { VideoFile } from '@shared/models' 1import { VideoFile } from '@peertube/peertube-models'
2 2
3function toTitleCase (str: string) { 3function toTitleCase (str: string) {
4 return str.charAt(0).toUpperCase() + str.slice(1) 4 return str.charAt(0).toUpperCase() + str.slice(1)
diff --git a/client/src/assets/player/shared/control-bar/peertube-link-button.ts b/client/src/assets/player/shared/control-bar/peertube-link-button.ts
index 8242b9cea..f93c265d6 100644
--- a/client/src/assets/player/shared/control-bar/peertube-link-button.ts
+++ b/client/src/assets/player/shared/control-bar/peertube-link-button.ts
@@ -1,5 +1,5 @@
1import videojs from 'video.js' 1import videojs from 'video.js'
2import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' 2import { buildVideoLink, decorateVideoLink } from '@peertube/peertube-core-utils'
3import { PeerTubeLinkButtonOptions } from '../../types' 3import { PeerTubeLinkButtonOptions } from '../../types'
4 4
5const Component = videojs.getComponent('Component') 5const Component = videojs.getComponent('Component')
diff --git a/client/src/assets/player/shared/metrics/metrics-plugin.ts b/client/src/assets/player/shared/metrics/metrics-plugin.ts
index 06ca0c2f2..0ad16338c 100644
--- a/client/src/assets/player/shared/metrics/metrics-plugin.ts
+++ b/client/src/assets/player/shared/metrics/metrics-plugin.ts
@@ -1,7 +1,7 @@
1import debug from 'debug' 1import debug from 'debug'
2import videojs from 'video.js' 2import videojs from 'video.js'
3import { PlaybackMetricCreate, VideoResolutionType } from '@peertube/peertube-models'
3import { logger } from '@root-helpers/logger' 4import { logger } from '@root-helpers/logger'
4import { PlaybackMetricCreate } from '../../../../../../shared/models'
5import { MetricsPluginOptions, PlayerNetworkInfo } from '../../types' 5import { MetricsPluginOptions, PlayerNetworkInfo } from '../../types'
6 6
7const debugLogger = debug('peertube:player:metrics') 7const debugLogger = debug('peertube:player:metrics')
@@ -102,7 +102,7 @@ class MetricsPlugin extends Plugin {
102 } 102 }
103 103
104 const body: PlaybackMetricCreate = { 104 const body: PlaybackMetricCreate = {
105 resolution, 105 resolution: resolution as VideoResolutionType,
106 fps, 106 fps,
107 107
108 playerMode: this.options_.mode(), 108 playerMode: this.options_.mode(),
diff --git a/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts
index 8c376cd21..1e47fe486 100644
--- a/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts
+++ b/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts
@@ -3,7 +3,7 @@ import videojs from 'video.js'
3import { Events, Segment } from '@peertube/p2p-media-loader-core' 3import { Events, Segment } from '@peertube/p2p-media-loader-core'
4import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from '@peertube/p2p-media-loader-hlsjs' 4import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from '@peertube/p2p-media-loader-hlsjs'
5import { logger } from '@root-helpers/logger' 5import { logger } from '@root-helpers/logger'
6import { addQueryParams } from '@shared/core-utils' 6import { addQueryParams } from '@peertube/peertube-core-utils'
7import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../../types' 7import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../../types'
8import { SettingsButton } from '../settings/settings-menu-button' 8import { SettingsButton } from '../settings/settings-menu-button'
9 9
diff --git a/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts b/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts
index 9cb6344a9..75d483015 100644
--- a/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts
+++ b/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts
@@ -2,7 +2,7 @@ import { basename } from 'path'
2import { Segment } from '@peertube/p2p-media-loader-core' 2import { Segment } from '@peertube/p2p-media-loader-core'
3import { logger } from '@root-helpers/logger' 3import { logger } from '@root-helpers/logger'
4import { wait } from '@root-helpers/utils' 4import { wait } from '@root-helpers/utils'
5import { removeQueryParams } from '@shared/core-utils' 5import { removeQueryParams } from '@peertube/peertube-core-utils'
6import { isSameOrigin } from '../common' 6import { isSameOrigin } from '../common'
7 7
8type SegmentsJSON = { [filename: string]: string | { [byterange: string]: string } } 8type SegmentsJSON = { [filename: string]: string | { [byterange: string]: string } }
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts
index f93593415..cf866723c 100644
--- a/client/src/assets/player/shared/peertube/peertube-plugin.ts
+++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts
@@ -1,9 +1,9 @@
1import debug from 'debug' 1import debug from 'debug'
2import videojs from 'video.js' 2import videojs from 'video.js'
3import { timeToInt } from '@peertube/peertube-core-utils'
4import { VideoView, VideoViewEvent } from '@peertube/peertube-models'
3import { logger } from '@root-helpers/logger' 5import { logger } from '@root-helpers/logger'
4import { isIOS, isMobile, isSafari } from '@root-helpers/web-browser' 6import { isIOS, isMobile, isSafari } from '@root-helpers/web-browser'
5import { timeToInt } from '@shared/core-utils'
6import { VideoView, VideoViewEvent } from '@shared/models/videos'
7import { 7import {
8 getStoredLastSubtitle, 8 getStoredLastSubtitle,
9 getStoredMute, 9 getStoredMute,
diff --git a/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts b/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts
index fd632d90d..41198afbe 100644
--- a/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts
+++ b/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts
@@ -1,7 +1,7 @@
1import { HybridLoaderSettings } from '@peertube/p2p-media-loader-core' 1import { HybridLoaderSettings } from '@peertube/p2p-media-loader-core'
2import { HlsJsEngineSettings } from '@peertube/p2p-media-loader-hlsjs' 2import { HlsJsEngineSettings } from '@peertube/p2p-media-loader-hlsjs'
3import { logger } from '@root-helpers/logger' 3import { logger } from '@root-helpers/logger'
4import { LiveVideoLatencyMode } from '@shared/models' 4import { LiveVideoLatencyMode } from '@peertube/peertube-models'
5import { getAverageBandwidthInStore } from '../../peertube-player-local-storage' 5import { getAverageBandwidthInStore } from '../../peertube-player-local-storage'
6import { P2PMediaLoader, P2PMediaLoaderPluginOptions, PeerTubePlayerContructorOptions, PeerTubePlayerLoadOptions } from '../../types' 6import { P2PMediaLoader, P2PMediaLoaderPluginOptions, PeerTubePlayerContructorOptions, PeerTubePlayerLoadOptions } from '../../types'
7import { getRtcConfig, isSameOrigin } from '../common' 7import { getRtcConfig, isSameOrigin } from '../common'
diff --git a/client/src/assets/player/shared/playlist/playlist-menu-item.ts b/client/src/assets/player/shared/playlist/playlist-menu-item.ts
index f9366332d..66c92d9e5 100644
--- a/client/src/assets/player/shared/playlist/playlist-menu-item.ts
+++ b/client/src/assets/player/shared/playlist/playlist-menu-item.ts
@@ -1,6 +1,6 @@
1import videojs from 'video.js' 1import videojs from 'video.js'
2import { secondsToTime } from '@shared/core-utils' 2import { secondsToTime } from '@peertube/peertube-core-utils'
3import { VideoPlaylistElement } from '@shared/models' 3import { VideoPlaylistElement } from '@peertube/peertube-models'
4import { PlaylistItemOptions } from '../../types' 4import { PlaylistItemOptions } from '../../types'
5 5
6const Component = videojs.getComponent('Component') 6const Component = videojs.getComponent('Component')
diff --git a/client/src/assets/player/shared/playlist/playlist-menu.ts b/client/src/assets/player/shared/playlist/playlist-menu.ts
index 53a5a7274..f6795390c 100644
--- a/client/src/assets/player/shared/playlist/playlist-menu.ts
+++ b/client/src/assets/player/shared/playlist/playlist-menu.ts
@@ -1,5 +1,5 @@
1import videojs from 'video.js' 1import videojs from 'video.js'
2import { VideoPlaylistElement } from '@shared/models' 2import { VideoPlaylistElement } from '@peertube/peertube-models'
3import { PlaylistPluginOptions } from '../../types' 3import { PlaylistPluginOptions } from '../../types'
4import { PlaylistMenuItem } from './playlist-menu-item' 4import { PlaylistMenuItem } from './playlist-menu-item'
5 5
diff --git a/client/src/assets/player/shared/stats/stats-card.ts b/client/src/assets/player/shared/stats/stats-card.ts
index 13334d91a..fefe8483e 100644
--- a/client/src/assets/player/shared/stats/stats-card.ts
+++ b/client/src/assets/player/shared/stats/stats-card.ts
@@ -1,6 +1,6 @@
1import videojs from 'video.js' 1import videojs from 'video.js'
2import { logger } from '@root-helpers/logger' 2import { logger } from '@root-helpers/logger'
3import { secondsToTime } from '@shared/core-utils' 3import { secondsToTime } from '@peertube/peertube-core-utils'
4import { PlayerNetworkInfo as EventPlayerNetworkInfo } from '../../types' 4import { PlayerNetworkInfo as EventPlayerNetworkInfo } from '../../types'
5import { bytes } from '../common' 5import { bytes } from '../common'
6 6
diff --git a/client/src/assets/player/shared/web-video/web-video-plugin.ts b/client/src/assets/player/shared/web-video/web-video-plugin.ts
index b839062f2..18d911108 100644
--- a/client/src/assets/player/shared/web-video/web-video-plugin.ts
+++ b/client/src/assets/player/shared/web-video/web-video-plugin.ts
@@ -1,8 +1,8 @@
1import debug from 'debug' 1import debug from 'debug'
2import videojs from 'video.js' 2import videojs from 'video.js'
3import { logger } from '@root-helpers/logger' 3import { logger } from '@root-helpers/logger'
4import { addQueryParams } from '@shared/core-utils' 4import { addQueryParams } from '@peertube/peertube-core-utils'
5import { VideoFile } from '@shared/models' 5import { VideoFile } from '@peertube/peertube-models'
6import { PeerTubeResolution, PlayerNetworkInfo, WebVideoPluginOptions } from '../../types' 6import { PeerTubeResolution, PlayerNetworkInfo, WebVideoPluginOptions } from '../../types'
7 7
8const debugLogger = debug('peertube:player:web-video-plugin') 8const debugLogger = debug('peertube:player:web-video-plugin')