From ff492d2a1247d6a875a59fc4df29f71ecf962b04 Mon Sep 17 00:00:00 2001 From: CY Date: Tue, 26 Mar 2024 10:19:54 +0800 Subject: [PATCH] refactor chromecast (#121) * refactor chromecast --- .github/workflows/compressed-size.yml | 8 +- examples/standalone/main.ts | 5 +- package.json | 4 +- packages/docs/package.json | 2 +- packages/docs/public/ohls.html | 13 +- packages/docs/src/pages/components/player.tsx | 8 +- .../docs/src/pages/plugins/chromecast.mdx | 13 +- packages/docs/src/pages/preview.mdx | 9 +- packages/plugins/CHANGELOG.md | 8 +- packages/plugins/README.md | 6 +- packages/plugins/index.ts | 5 +- packages/plugins/package.json | 2 +- packages/plugins/src/chromecast.ts | 236 ++++++++++++------ packages/plugins/src/hello.ts | 25 -- packages/react/package.json | 2 +- packages/ui/src/components/Progress.style.ts | 4 +- pnpm-lock.yaml | 156 ++++++------ vite.config.ts | 3 +- 18 files changed, 295 insertions(+), 214 deletions(-) delete mode 100644 packages/plugins/src/hello.ts diff --git a/.github/workflows/compressed-size.yml b/.github/workflows/compressed-size.yml index 3d608f3b..389831c2 100644 --- a/.github/workflows/compressed-size.yml +++ b/.github/workflows/compressed-size.yml @@ -22,6 +22,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: setup node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Install pnpm uses: pnpm/action-setup@v2.2.4 with: @@ -32,6 +37,7 @@ jobs: id: pnpm-cache run: | echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + - uses: actions/cache@v3 name: Setup pnpm cache with: @@ -44,4 +50,4 @@ jobs: with: build-script: 'build:packs' repo-token: '${{ secrets.GIT_HUB_TOKEN }}' - pattern: './packages/*/{dist,compiled}/**/*.{js,d.ts}' + pattern: './packages/*/{dist,compiled}/**/*.{js}' diff --git a/examples/standalone/main.ts b/examples/standalone/main.ts index 2ffd9ea7..bf918e1d 100644 --- a/examples/standalone/main.ts +++ b/examples/standalone/main.ts @@ -8,7 +8,7 @@ import hls from '@oplayer/hls' import mpegts from '@oplayer/mpegts' import ui from '@oplayer/ui' import torrent from '@oplayer/torrent' -import { PlaylistPlugin } from '@oplayer/plugins' +import { PlaylistPlugin, Chromecast } from '@oplayer/plugins' import DANMAKU from '../../packages/docs/public/danmaku.xml' import POSTER from '../../packages/docs/public/poster.png' @@ -194,7 +194,8 @@ const player = Player.make('#player', { // } // } // }, - }) + }), + new Chromecast() ]) .create() diff --git a/package.json b/package.json index a0ede979..c2f912f7 100644 --- a/package.json +++ b/package.json @@ -51,13 +51,13 @@ "cross-env": "^7.0.3", "jsdom": "^24.0.0", "lint-staged": "^15.2.2", - "nx": "^18.1.2", + "nx": "^18.1.3", "prettier": "^3.2.5", "rimraf": "^5.0.5", "terser": "^5.29.2", "tslib": "^2.6.2", "typescript": "^5.4.3", - "vite": "^5.2.3", + "vite": "^5.2.6", "vite-plugin-banner": "^0.7.1", "vitest": "^1.4.0" }, diff --git a/packages/docs/package.json b/packages/docs/package.json index b5b3242e..3eaa13d3 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -26,7 +26,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@types/react": "^18.2.69", + "@types/react": "^18.2.70", "@types/react-dom": "^18.2.22", "sass": "^1.72.0" } diff --git a/packages/docs/public/ohls.html b/packages/docs/public/ohls.html index baba673a..1e73bdc2 100644 --- a/packages/docs/public/ohls.html +++ b/packages/docs/public/ohls.html @@ -217,7 +217,8 @@ -``` -### Chromecast - -```js -Player.make('#oplayer').use([chromecast]).create() + ``` diff --git a/packages/docs/src/pages/preview.mdx b/packages/docs/src/pages/preview.mdx index 84bb9e34..efede4b0 100644 --- a/packages/docs/src/pages/preview.mdx +++ b/packages/docs/src/pages/preview.mdx @@ -6,7 +6,7 @@ import dash from '@oplayer/dash' import mpegts from '@oplayer/mpegts' import ui from '@oplayer/ui' import danmaku from '@oplayer/danmaku' -import { PlaylistPlugin, chromecast } from '@oplayer/plugins' +import { PlaylistPlugin, Chromecast } from '@oplayer/plugins'
it?.apply)} /> diff --git a/packages/plugins/CHANGELOG.md b/packages/plugins/CHANGELOG.md index ae087b48..b70f0e44 100644 --- a/packages/plugins/CHANGELOG.md +++ b/packages/plugins/CHANGELOG.md @@ -2,13 +2,17 @@ ## UnRelease +## 1.0.12-beta.0 + +- chromecast: refactor + ## 1.0.11 -- support danmaku +- playlist: support danmaku ## 1.0.11-alpha.1 -- add error fallback for poster +- playlist: add error fallback for poster ## 1.0.10-beta.3 diff --git a/packages/plugins/README.md b/packages/plugins/README.md index 44a5c88f..f4ca4347 100644 --- a/packages/plugins/README.md +++ b/packages/plugins/README.md @@ -5,7 +5,7 @@ npm i @oplayer/plugins ``` ```js -import { PlaylistPlugin, vttThumbnails, chromecast, ad } from '@oplayer/plugins' +import { PlaylistPlugin, Chromecast, ad, vttThumbnails } from '@oplayer/plugins' ``` ```html @@ -94,6 +94,8 @@ Player.make('#oplayer') ### Chromecast -Player.make('#oplayer').use([chromecast]).create() +```js +Player.make('#oplayer').use([new Chromecast()]).create() +``` ### AD diff --git a/packages/plugins/index.ts b/packages/plugins/index.ts index 5b8da22a..b8be696b 100644 --- a/packages/plugins/index.ts +++ b/packages/plugins/index.ts @@ -1,7 +1,6 @@ -import chromecast from './src/chromecast' +import Chromecast from './src/chromecast' import vttThumbnails from './src/vttThumbnails' import PlaylistPlugin from './src/playlist' -import Hello from './src/hello' import ad from './src/ad' -export { chromecast, vttThumbnails, ad, Hello, PlaylistPlugin } +export { Chromecast, vttThumbnails, ad, PlaylistPlugin } diff --git a/packages/plugins/package.json b/packages/plugins/package.json index 5174dac1..d555c195 100644 --- a/packages/plugins/package.json +++ b/packages/plugins/package.json @@ -1,6 +1,6 @@ { "name": "@oplayer/plugins", - "version": "1.0.11", + "version": "1.0.12-beta.0", "author": "shiyiya", "description": "oplayer's plugin", "homepage": "https://github.com/shiyiya/oplayer", diff --git a/packages/plugins/src/chromecast.ts b/packages/plugins/src/chromecast.ts index 6912e0b3..a6ff1246 100644 --- a/packages/plugins/src/chromecast.ts +++ b/packages/plugins/src/chromecast.ts @@ -1,89 +1,179 @@ -import { PlayerPlugin, loadSDK, isIOS } from '@oplayer/core' - -function noop() {} +import Player, { PlayerPlugin, loadSDK, isIOS, Source } from '@oplayer/core' const IS_CHROME = !!globalThis.chrome -//TODO: sync event +const ICON = `` + +// TODO: Sync remote controller state + +export interface ChromeCastOptions { + autoJoinPolicy?: chrome.cast.AutoJoinPolicy + language?: string | undefined + receiverApplicationId?: string | undefined + resumeSavedSession?: boolean | undefined + /** The following flag enables Cast Connect(requires Chrome 87 or higher) */ + androidReceiverCompatible?: boolean | undefined +} + +class ChromeCast implements PlayerPlugin { + public name = 'oplayer-plugin-chromecast' + public version = __VERSION__ + + public player: Player + public _player?: cast.framework.RemotePlayer + + constructor(public options?: ChromeCastOptions) {} + + apply(player: Player) { + if (!this.canPlay()) return + + this.player = player + this.registerUI() + + return this + } + + get cast() { + return cast.framework.CastContext.getInstance() + } + + get castSessionMedia() { + return this.cast.getCurrentSession()?.getSessionObj().media[0] + } + + get isCastConnected() { + return this.cast.getCastState() === cast.framework.CastState.CONNECTED + } -export default { - name: 'oplayer-plugin-chromecast', - version: __VERSION__, - apply(player) { - if (!IS_CHROME || isIOS) return + get device() { + return this.cast.getCurrentSession()?.getCastDevice() + } - let currentSession: chrome.cast.Session | undefined - let currentMedia: chrome.cast.media.Media | undefined - const ui = player.context.ui + hasActiveCastSession(source: Source | undefined | null) { + const contentId = this.castSessionMedia?.media?.contentId + return contentId === source?.src + } + + canPlay() { + return IS_CHROME && !isIOS + } - function onError(e: chrome.cast.Error | Error) { - const message = (e).description || (e).message - if (message) ui.notice('Chromecast: ' + message) - console.warn('chromecast: ', e) + async __requestChromeCast() { + if (!this._player) { + this._player = new cast.framework.RemotePlayer() + new cast.framework.RemotePlayerController(this._player) } - window.__onGCastApiAvailable = (isAvailable) => { - if (isAvailable) { - const sessionRequest = new chrome.cast.SessionRequest(chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID) - const apiConfig = new chrome.cast.ApiConfig(sessionRequest, noop, noop) - chrome.cast.initialize(apiConfig, noop, onError) - } else { - onError(new Error('Chromecast not available')) - } + if (this.hasActiveCastSession(this.player.options.source)) { + return } - const discoverDevices = () => { - chrome.cast.requestSession((session) => { - currentSession = session - const { - source: { title, src, poster, type }, - isLive - } = player.options - const mediaInfo = new chrome.cast.media.MediaInfo(src, type || 'video/mp4') - if (!mediaInfo.metadata) mediaInfo.metadata = {} // ?? - if (title) mediaInfo.metadata.title = title - if (poster) mediaInfo.metadata.images = [{ url: poster }] - // mediaInfo.metadata.subtitle - mediaInfo.streamType = isLive - ? chrome.cast.media.StreamType.LIVE - : chrome.cast.media.StreamType.BUFFERED - - const request = new chrome.cast.media.LoadRequest(mediaInfo) - request.currentTime = player.currentTime - request.autoplay = true - - session.loadMedia( - request, - (media) => { - currentMedia = media - }, - onError - ) - }, onError) + this.cast.setOptions({ + receiverApplicationId: window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID, + autoJoinPolicy: chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED, + ...this.options + }) + + //@ts-ignore + const errorCode = (await chrome.cast.requestSession()) as chrome.cast.ErrorCode + if (errorCode) { + throw new Error(`Chrome Cast Error Code: ${errorCode}`) } + return this.cast.getCurrentSession()?.loadMedia(this.__buildRequest()) + } - ui.menu.register({ - name: 'Chromecast', - position: 'top', - icon: - ui.icons.chromecast || - ``, - onClick() { - loadSDK( - 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1', - 'chrome', - '__onGCastApiAvailable', - (chrome: typeof window.chrome) => typeof chrome.cast != 'undefined' - ) - .then(() => { - if (currentSession || currentMedia) { - currentMedia?.stop(new chrome.cast.media.StopRequest(), noop, noop) - currentSession?.stop(noop, noop) - } - setTimeout(discoverDevices) - }) - .catch(onError) + __buildRequest() { + const { source, isLive } = this.player.options + const mediaInfo = new chrome.cast.media.MediaInfo(source.src, source.type || 'video/mp4') + mediaInfo.streamType = isLive ? chrome.cast.media.StreamType.LIVE : chrome.cast.media.StreamType.BUFFERED + + const metadata = new chrome.cast.media.GenericMediaMetadata() + if (source.title) metadata.title = source.title + if (source.poster) metadata.images = [{ url: source.poster, height: null, width: null }] + mediaInfo.metadata = metadata + + const subtitles = this.player.context.ui?.config.subtitle?.source as any[] + mediaInfo.tracks = subtitles.map((sub, id) => { + const track = new chrome.cast.media.Track(id, chrome.cast.media.TrackType.TEXT) + + track.name = sub.name + track.trackContentId = sub.src + track.trackContentType = sub.type || 'text/vtt' //TODO: url match + track.language = sub.language || sub.name + track.subtype = chrome.cast.media.TextTrackType.CAPTIONS + + return track + }) + + const request = new chrome.cast.media.LoadRequest(mediaInfo) + + request.autoplay = this.player.isPlaying + request.currentTime = this.player.currentTime + + return request + } + + _loadCast() { + if (!!window.cast?.framework) return + + return new Promise((resolve, reject) => { + window.__onGCastApiAvailable = (isAvailable) => { + window.__onGCastApiAvailable == undefined + + if (isAvailable) { + resolve() + } else { + reject(Error('CAST_NOT_AVAILABLE')) + } + } + + loadSDK( + 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1', + 'cast', + '__onGCastApiAvailable' + ) + }) + } + + async start() { + try { + await this._loadCast() + + const State = window.cast.framework.CastState + if (this.cast.getCastState() === State.NO_DEVICES_AVAILABLE) { + throw new Error(`Chrome Cast Error Code: ${State.NO_DEVICES_AVAILABLE}`) + } + + const errorCode = await this.__requestChromeCast() + if (errorCode) { + throw new Error(`Chrome Cast Error Code: ${errorCode}`) } + } catch (error) { + const msg = + error instanceof chrome.cast.Error + ? `${error.code} - ${error.description} \n ${error.details}` + : (error as Error).message + + this._notice(msg) + } + } + + registerUI() { + if (!this.player.context.ui) return + + const { menu, icons } = this.player.context.ui + + menu?.register({ + name: 'ChromeCast', + position: 'top', + icon: icons.chromecast || ICON, + onClick: () => this.start() }) } + + _notice(message: string) { + this.player.context.ui?.notice(message) + } } + +export default ChromeCast diff --git a/packages/plugins/src/hello.ts b/packages/plugins/src/hello.ts deleted file mode 100644 index 9e73e69f..00000000 --- a/packages/plugins/src/hello.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type Player from '@oplayer/core' -import { PlayerPlugin } from '@oplayer/core' - -export default class HelloPlugin implements PlayerPlugin { - key = 'hello' - name = 'oplayer-plugin-hello' - version = __VERSION__ - - apply(player: Player) { - player.on('play', () => { - console.log('enjoy the video!') - }) - - return this - } - - say(who = this.name) { - console.log(`hello! ${who}`) - } - - destroy() { - console.log('bye bye!') - } -} -// treeshaking testing diff --git a/packages/react/package.json b/packages/react/package.json index fc360835..4430198a 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -28,7 +28,7 @@ }, "devDependencies": { "@oplayer/core": "workspace:*", - "@types/react": "^18.2.69", + "@types/react": "^18.2.70", "react": "^18.2.0", "react-dom": "^18.2.0" } diff --git a/packages/ui/src/components/Progress.style.ts b/packages/ui/src/components/Progress.style.ts index a778bdd6..23053700 100644 --- a/packages/ui/src/components/Progress.style.ts +++ b/packages/ui/src/components/Progress.style.ts @@ -21,7 +21,7 @@ export const dot = $.css({ height: '1.4em', top: '0', left: '0', - margin: '-0.5em 0 0 -0.5em', + margin: '-0.535em 0 0 -0.7em', transform: isMobile ? 'none' : 'scale(0)', transition: 'transform 0.3s ease', 'z-index': '1' @@ -30,7 +30,7 @@ export const dot = $.css({ '& > *:not(svg)': { width: '1em', height: '1em', - margin: '-0.4em 0 0 -0.4em', + margin: '-0.335em 0 0 -0.5em', 'border-radius': '50%', 'background-color': '#fff' } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b5ee5a2c..49016577 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -51,7 +51,7 @@ importers: version: 20.11.30 '@vitejs/plugin-react': specifier: ^4.2.1 - version: 4.2.1(vite@5.2.3) + version: 4.2.1(vite@5.2.6) babel-plugin-syntax-trailing-function-commas: specifier: ^6.22.0 version: 6.22.0 @@ -68,8 +68,8 @@ importers: specifier: ^15.2.2 version: 15.2.2 nx: - specifier: ^18.1.2 - version: 18.1.2 + specifier: ^18.1.3 + version: 18.1.3 prettier: specifier: ^3.2.5 version: 3.2.5 @@ -86,8 +86,8 @@ importers: specifier: ^5.4.3 version: 5.4.3 vite: - specifier: ^5.2.3 - version: 5.2.3(@types/node@20.11.30)(terser@5.29.2) + specifier: ^5.2.6 + version: 5.2.6(@types/node@20.11.30)(terser@5.29.2) vite-plugin-banner: specifier: ^0.7.1 version: 0.7.1 @@ -165,8 +165,8 @@ importers: version: 18.2.0(react@18.2.0) devDependencies: '@types/react': - specifier: ^18.2.69 - version: 18.2.69 + specifier: ^18.2.70 + version: 18.2.70 '@types/react-dom': specifier: ^18.2.22 version: 18.2.22 @@ -214,7 +214,7 @@ importers: version: 7.1.0 vite-plugin-css-injected-by-js: specifier: ^3.5.0 - version: 3.5.0(vite@5.2.3) + version: 3.5.0(vite@5.2.6) packages/react: devDependencies: @@ -222,8 +222,8 @@ importers: specifier: workspace:* version: link:../core '@types/react': - specifier: ^18.2.69 - version: 18.2.69 + specifier: ^18.2.70 + version: 18.2.70 react: specifier: ^18.2.0 version: 18.2.0 @@ -457,11 +457,12 @@ packages: /@babel/plugin-proposal-object-rest-spread@7.12.1(@babel/core@7.12.9): resolution: {integrity: sha512-s6SowJIjzlhx8o7lsFx5zmY4At6CTtDvgNQDdPzkBQucle58A6b/TTeEBYtyDgmcXjUTM+vE8YOGHZzzbc/ioA==} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.12.9 - '@babel/helper-plugin-utils': 7.10.4 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.12.9) '@babel/plugin-transform-parameters': 7.24.1(@babel/core@7.12.9) dev: false @@ -1207,7 +1208,7 @@ packages: react: '>=16' dependencies: '@types/mdx': 2.0.12 - '@types/react': 18.2.69 + '@types/react': 18.2.70 react: 18.2.0 dev: false @@ -1437,11 +1438,11 @@ packages: fastq: 1.17.1 dev: true - /@nrwl/tao@18.1.2: - resolution: {integrity: sha512-IA+osZ5TlKMwJmcP7TECW7TO0JdNNQud9Dgkh1ZfJ4GWnT7WEkE9b2Yf1IFeeB81kCTXXq8jfISa8ZY21MjRaQ==} + /@nrwl/tao@18.1.3: + resolution: {integrity: sha512-cRs5kDRhiYVZ9SLQ2ol+2+zltgPemDtsHKz2h2whazHF+d39zsPLYbFm1ZJuDKpZp6TJJercqSH1UQCdOXEkdQ==} hasBin: true dependencies: - nx: 18.1.2 + nx: 18.1.3 tslib: 2.6.2 transitivePeerDependencies: - '@swc-node/register' @@ -1449,8 +1450,8 @@ packages: - debug dev: true - /@nx/nx-darwin-arm64@18.1.2: - resolution: {integrity: sha512-KduC9WBmeTLP8HyTg4NOgQGLk9LEd5qd9dGuYKPU0jA4b+eJIa0rRHEjFdc5WulQrcUAvTIKfmScRCgzR96ogg==} + /@nx/nx-darwin-arm64@18.1.3: + resolution: {integrity: sha512-h3/1ywpLa56RwBnz8Lr9yyUvPvfGvKFxIo8LNptc8fMoONuuIOeZTAmaBxKBOaKtL7g64/LKDs0Ts+mSXzmbqA==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -1458,8 +1459,8 @@ packages: dev: true optional: true - /@nx/nx-darwin-x64@18.1.2: - resolution: {integrity: sha512-mBf3X8m4P4QHoW8g/L/YoK8zkndDyIw4bojLg8Q3xc47s5JZFCqSSMeOXZ9NicM2DpPiDWSQALtQX7A8lIsoAA==} + /@nx/nx-darwin-x64@18.1.3: + resolution: {integrity: sha512-6LHe7MYrKlztLlKhYfGV3CtFPhEqcc2ZgwGVWYiAmS/glcN+Wai7RFQX/cZiJ+TbDRFzvETPPGNRP/aSAOkRnQ==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -1467,8 +1468,8 @@ packages: dev: true optional: true - /@nx/nx-freebsd-x64@18.1.2: - resolution: {integrity: sha512-ZqzT2BTsOHhWip1PvNm7AZ4Pzn4I+IZNRvtRgpETYvIH+nqoCmi5rrEi1avnhnr6P5hyzh2mISRSyk186SbZew==} + /@nx/nx-freebsd-x64@18.1.3: + resolution: {integrity: sha512-ppSkJJVKnfDWYJBKqjEM/p4qdMZsZVV++dkFN/n50p6uwHstv0Kth7dNdsu3ZyPqmg6+IYUZql7JSTeNqKne5A==} engines: {node: '>= 10'} cpu: [x64] os: [freebsd] @@ -1476,8 +1477,8 @@ packages: dev: true optional: true - /@nx/nx-linux-arm-gnueabihf@18.1.2: - resolution: {integrity: sha512-V9Dp9uuuce+/f50dXxaYz1C9ULo5+5VS35yc6gN7b6SchCWjNK+xg1YcHBTRNc2ChBtayO2z+mBQ1s6wMDNs/Q==} + /@nx/nx-linux-arm-gnueabihf@18.1.3: + resolution: {integrity: sha512-1vflQE4gscHq2GJeu2L48Z8rQFcdu+gcprG1cMEf3CIDxh/nJei66bdVJYYYxPNi6rYaeONPJgBjbIih8ce8nQ==} engines: {node: '>= 10'} cpu: [arm] os: [linux] @@ -1485,8 +1486,8 @@ packages: dev: true optional: true - /@nx/nx-linux-arm64-gnu@18.1.2: - resolution: {integrity: sha512-aM860T4Hy2JCLcU56mtARIp1MdT1Ms7cGUQzE+a5irM8ZdaHsPdRnYqIgEKd3hoF6PQ6/piHFXWa4xm7pe/2KA==} + /@nx/nx-linux-arm64-gnu@18.1.3: + resolution: {integrity: sha512-7B5YXjDzzFdEMUzhFifXgsg741Afp3v7vNdPL2joQ7xrERKYEge7eXCjp5/GYhl9J4y5BmdeV2Joqr4WQ6R7Pg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1494,8 +1495,8 @@ packages: dev: true optional: true - /@nx/nx-linux-arm64-musl@18.1.2: - resolution: {integrity: sha512-BgBoOeIgCQ56xii7fKNWiE7UIP/0G+OQhdWJQmh+q6NN0kk78WsdCSq+f7f7LQIji5HiNqUUVx9fd1s6xRSb/w==} + /@nx/nx-linux-arm64-musl@18.1.3: + resolution: {integrity: sha512-OaAVjUli44JUTlGPmtxZDO2U88yK6/cwt1LTbTHGeabupbXR295RDn1TkR1/1oNo8grRaOi/V9DWEg9RRmGvOw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1503,8 +1504,8 @@ packages: dev: true optional: true - /@nx/nx-linux-x64-gnu@18.1.2: - resolution: {integrity: sha512-WDOjtk+K2Tc9SNjGe+zmyy05VUerZpEQ5kvB6Ude0v/W2bMnmpVrLZwwTF5Yrq0ebbUlXM/9wtc1Zjjc75MU2g==} + /@nx/nx-linux-x64-gnu@18.1.3: + resolution: {integrity: sha512-qDinHpGZ9FhoOtdfO23pwN7pBCu25ElJ1InLCeCarl9CQYS1CDZNimrcSOFl20DAZqINQamPqBFJ7nKeDRBy7g==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1512,8 +1513,8 @@ packages: dev: true optional: true - /@nx/nx-linux-x64-musl@18.1.2: - resolution: {integrity: sha512-I7jTmbfR5CHC3KVlU3SkqYKJnn25MbH8pdRZJY4gaHnqL9JzbHw9rxddhKBj41lez7jQZTGLnPFUV7JPLXTzKg==} + /@nx/nx-linux-x64-musl@18.1.3: + resolution: {integrity: sha512-E28Q0v9N7LrV+0uu4ytrcCHfF1MPYwNL2NLZN3yCPgulGHe3NwCuMnbC974+uOZ+MTqua7KnVOQ5VYA5sL1LIw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1521,8 +1522,8 @@ packages: dev: true optional: true - /@nx/nx-win32-arm64-msvc@18.1.2: - resolution: {integrity: sha512-KQobKvkrdkmaJmx0Pyt2lzHkNugO0gE7q9F4h22KIECyGW1tC3nSPAB4F3mmdE2KuWKgYG5WLafvzusysLsR7g==} + /@nx/nx-win32-arm64-msvc@18.1.3: + resolution: {integrity: sha512-EYHPIcanVn6ZWkELnW4wW+gl8Itulmpi7f7s83CFrYxRW0U8SAG2sW4JrlvZgrK2CMyluiCGqZGHDUJZST4CVA==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -1530,8 +1531,8 @@ packages: dev: true optional: true - /@nx/nx-win32-x64-msvc@18.1.2: - resolution: {integrity: sha512-uvJvROSwHBwkTOoOPkb56jEsKJjr4LnZ3fCHmEbrtGhAUC0gAUL+dWJUDHoatrGzN+bM2VqrvgNCGkityK96hw==} + /@nx/nx-win32-x64-msvc@18.1.3: + resolution: {integrity: sha512-1tBViAG9VQ3arKoKFOrkBzYUAGgGsVqYbifng+stb5TPWOj0jjhQpwbsk0u3ROmEBw9crWRwzRt1qh/ZE7SfQQ==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -1915,11 +1916,11 @@ packages: /@types/react-dom@18.2.22: resolution: {integrity: sha512-fHkBXPeNtfvri6gdsMYyW+dW7RXFo6Ad09nLFK0VQWR7yGLai/Cyvyj696gbwYvBnhGtevUG9cET0pmUbMtoPQ==} dependencies: - '@types/react': 18.2.69 + '@types/react': 18.2.70 dev: true - /@types/react@18.2.69: - resolution: {integrity: sha512-W1HOMUWY/1Yyw0ba5TkCV+oqynRjG7BnteBB+B7JmAK7iw3l2SW+VGOxL+akPweix6jk2NNJtyJKpn4TkpfK3Q==} + /@types/react@18.2.70: + resolution: {integrity: sha512-hjlM2hho2vqklPhopNkXkdkeq6Lv8WSZTpr7956zY+3WS5cfYUewtCzsJLsbW5dEv3lfSeQ4W14ZFeKC437JRQ==} dependencies: '@types/prop-types': 15.7.12 '@types/scheduler': 0.16.8 @@ -1968,7 +1969,7 @@ packages: url-toolkit: 2.2.5 dev: true - /@vitejs/plugin-react@4.2.1(vite@5.2.3): + /@vitejs/plugin-react@4.2.1(vite@5.2.6): resolution: {integrity: sha512-oojO9IDc4nCUUi8qIR11KoQm0XFFLIwsRBwHRR4d/88IWghn1y6ckz/bJ8GHDCsYEJee8mDzqtJxh15/cisJNQ==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -1979,7 +1980,7 @@ packages: '@babel/plugin-transform-react-jsx-source': 7.24.1(@babel/core@7.24.3) '@types/babel__core': 7.20.5 react-refresh: 0.14.0 - vite: 5.2.3(@types/node@20.11.30)(terser@5.29.2) + vite: 5.2.6(@types/node@20.11.30)(terser@5.29.2) transitivePeerDependencies: - supports-color dev: true @@ -2085,11 +2086,9 @@ packages: engines: {node: '>=6'} dev: true - /ansi-escapes@6.2.0: - resolution: {integrity: sha512-kzRaCqXnpzWs+3z5ABPQiVke+iq0KXkHo8xiWV4RPTi5Yli0l97BEQuhXV1s7+aSU/fu1kUuxgS4MsQ0fRuygw==} + /ansi-escapes@6.2.1: + resolution: {integrity: sha512-4nJ3yixlEthEJ9Rk4vPcdBRkZvQZlYyu8j4/Mqz5sgIkddmEnH2Yj2ZrnP9S3tQOvSNRUIgVNF/1yPpRAGNRig==} engines: {node: '>=14.16'} - dependencies: - type-fest: 3.13.1 dev: true /ansi-regex@5.0.1: @@ -2452,7 +2451,7 @@ packages: hasBin: true dependencies: caniuse-lite: 1.0.30001600 - electron-to-chromium: 1.4.715 + electron-to-chromium: 1.4.716 node-releases: 2.0.14 update-browserslist-db: 1.0.13(browserslist@4.23.0) dev: true @@ -3452,8 +3451,8 @@ packages: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} dev: true - /electron-to-chromium@1.4.715: - resolution: {integrity: sha512-XzWNH4ZSa9BwVUQSDorPWAUQ5WGuYz7zJUNpNif40zFCiCl20t8zgylmreNmn26h5kiyw2lg7RfTmeMBsDklqg==} + /electron-to-chromium@1.4.716: + resolution: {integrity: sha512-t/MXMzFKQC3UfMDpw7V5wdB/UAB8dWx4hEsy+fpPYJWW3gqh3u5T1uXp6vR+H6dGCPBxkRo+YBcapBLvbGQHRw==} dev: true /elkjs@0.9.2: @@ -4961,8 +4960,8 @@ packages: randombytes: 2.1.0 dev: true - /katex@0.16.9: - resolution: {integrity: sha512-fsSYjWS0EEOwvy81j3vRA8TEAhQhKiqO+FQaKWp0m39qwOzHVBgAUBIXWj1pB+O2W3fIpNa6Y9KSKCVbfPhyAQ==} + /katex@0.16.10: + resolution: {integrity: sha512-ZiqaC04tp2O5utMsl2TEZTXxa6WSC4yo0fv5ML++D3QZv/vx2Mct0mTlRx3O+uUkjfuAgOkzsCmq5MiUEsDDdA==} hasBin: true dependencies: commander: 8.3.0 @@ -5122,7 +5121,7 @@ packages: resolution: {integrity: sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw==} engines: {node: '>=18'} dependencies: - ansi-escapes: 6.2.0 + ansi-escapes: 6.2.1 cli-cursor: 4.0.0 slice-ansi: 7.1.0 strip-ansi: 7.1.0 @@ -5542,7 +5541,7 @@ packages: dayjs: 1.11.10 dompurify: 3.0.11 elkjs: 0.9.2 - katex: 0.16.9 + katex: 0.16.10 khroma: 2.1.0 lodash-es: 4.17.21 mdast-util-from-markdown: 1.3.1 @@ -5652,7 +5651,7 @@ packages: resolution: {integrity: sha512-es0CcOV89VNS9wFmyn+wyFTKweXGW4CEvdaAca6SWRWPyYCbBisnjaHLjWO4Nszuiud84jCpkHsqAJoa768Pvg==} dependencies: '@types/katex': 0.16.7 - katex: 0.16.9 + katex: 0.16.10 micromark-factory-space: 1.1.0 micromark-util-character: 1.2.0 micromark-util-symbol: 1.1.0 @@ -6199,7 +6198,7 @@ packages: github-slugger: 2.0.0 graceful-fs: 4.2.11 gray-matter: 4.0.3 - katex: 0.16.9 + katex: 0.16.10 lodash.get: 4.4.2 next: 14.1.4(@babel/core@7.12.9)(react-dom@18.2.0)(react@18.2.0)(sass@1.72.0) next-mdx-remote: 4.4.1(react-dom@18.2.0)(react@18.2.0) @@ -6284,8 +6283,8 @@ packages: resolution: {integrity: sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==} dev: true - /nx@18.1.2: - resolution: {integrity: sha512-E414xp6lVtiTGdDUMVo72G96G66t7oJMqmcHRMEZ/mVq5ZpNWUhfMuRq5Fh8orXPtrM3xk5SHokmmFvo5PKC+g==} + /nx@18.1.3: + resolution: {integrity: sha512-Ade/BZxK8kf98pBPHVJXRkxRTpBYJceL1YD9LBMP5TwmsVdG5ZbmmpTkCBorCGmCZ8L5WZN3gwoikvPKGs8q5w==} hasBin: true requiresBuild: true peerDependencies: @@ -6297,7 +6296,7 @@ packages: '@swc/core': optional: true dependencies: - '@nrwl/tao': 18.1.2 + '@nrwl/tao': 18.1.3 '@yarnpkg/lockfile': 1.1.0 '@yarnpkg/parsers': 3.0.0-rc.46 '@zkochan/js-yaml': 0.0.6 @@ -6332,16 +6331,16 @@ packages: yargs: 17.7.2 yargs-parser: 21.1.1 optionalDependencies: - '@nx/nx-darwin-arm64': 18.1.2 - '@nx/nx-darwin-x64': 18.1.2 - '@nx/nx-freebsd-x64': 18.1.2 - '@nx/nx-linux-arm-gnueabihf': 18.1.2 - '@nx/nx-linux-arm64-gnu': 18.1.2 - '@nx/nx-linux-arm64-musl': 18.1.2 - '@nx/nx-linux-x64-gnu': 18.1.2 - '@nx/nx-linux-x64-musl': 18.1.2 - '@nx/nx-win32-arm64-msvc': 18.1.2 - '@nx/nx-win32-x64-msvc': 18.1.2 + '@nx/nx-darwin-arm64': 18.1.3 + '@nx/nx-darwin-x64': 18.1.3 + '@nx/nx-freebsd-x64': 18.1.3 + '@nx/nx-linux-arm-gnueabihf': 18.1.3 + '@nx/nx-linux-arm64-gnu': 18.1.3 + '@nx/nx-linux-arm64-musl': 18.1.3 + '@nx/nx-linux-x64-gnu': 18.1.3 + '@nx/nx-linux-x64-musl': 18.1.3 + '@nx/nx-win32-arm64-msvc': 18.1.3 + '@nx/nx-win32-x64-msvc': 18.1.3 transitivePeerDependencies: - debug dev: true @@ -6904,7 +6903,7 @@ packages: '@types/katex': 0.16.7 hast-util-from-html-isomorphic: 2.0.0 hast-util-to-text: 4.0.0 - katex: 0.16.9 + katex: 0.16.10 unist-util-visit-parents: 6.0.1 vfile: 6.0.1 dev: false @@ -7845,8 +7844,8 @@ packages: resolution: {integrity: sha512-N8hW3PG/3aOoZAN5V/NSAEDz0ZixDSSt5b/a05iqtpgfLWMSVuCo7w0k2vVvEjdrIoeGqZzweX2WlyioNIHchA==} dev: true - /tinypool@0.8.2: - resolution: {integrity: sha512-SUszKYe5wgsxnNOVlBYO6IC+8VGWdVGZWAqUxp3UErNBtptZvWbwyUOyzNL59zigz2rCA92QiL3wvG+JDSdJdQ==} + /tinypool@0.8.3: + resolution: {integrity: sha512-Ud7uepAklqRH1bvwy22ynrliC7Dljz7Tm8M/0RBUW+YRa4YHhZ6e4PpgE+fu1zr/WqB1kbeuVrdfeuyIBpy4tw==} engines: {node: '>=14.0.0'} dev: true @@ -8016,11 +8015,6 @@ packages: engines: {node: '>=10'} dev: false - /type-fest@3.13.1: - resolution: {integrity: sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==} - engines: {node: '>=14.16'} - dev: true - /typed-array-buffer@1.0.2: resolution: {integrity: sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==} engines: {node: '>= 0.4'} @@ -8500,7 +8494,7 @@ packages: debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.2.3(@types/node@20.11.30)(terser@5.29.2) + vite: 5.2.6(@types/node@20.11.30)(terser@5.29.2) transitivePeerDependencies: - '@types/node' - less @@ -8516,16 +8510,16 @@ packages: resolution: {integrity: sha512-Bww2Xd5tOGsZ1yZ9rQiGneryvsL1u86znPrqeQjCsXPsG72pnSdV5lcQA+cy8UNDguMqyTJiCevlNUbLnT85UA==} dev: true - /vite-plugin-css-injected-by-js@3.5.0(vite@5.2.3): + /vite-plugin-css-injected-by-js@3.5.0(vite@5.2.6): resolution: {integrity: sha512-d0QaHH9kS93J25SwRqJNEfE29PSuQS5jn51y9N9i2Yoq0FRO7rjuTeLvjM5zwklZlRrIn6SUdtOEDKyHokgJZg==} peerDependencies: vite: '>2.0.0-0' dependencies: - vite: 5.2.3(@types/node@20.11.30)(terser@5.29.2) + vite: 5.2.6(@types/node@20.11.30)(terser@5.29.2) dev: true - /vite@5.2.3(@types/node@20.11.30)(terser@5.29.2): - resolution: {integrity: sha512-+i1oagbvkVIhEy9TnEV+fgXsng13nZM90JQbrcPrf6DvW2mXARlz+DK7DLiDP+qeKoD1FCVx/1SpFL1CLq9Mhw==} + /vite@5.2.6(@types/node@20.11.30)(terser@5.29.2): + resolution: {integrity: sha512-FPtnxFlSIKYjZ2eosBQamz4CbyrTizbZ3hnGJlh/wMtCrlp1Hah6AzBLjGI5I2urTfNnpovpHdrL6YRuBOPnCA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -8604,8 +8598,8 @@ packages: std-env: 3.7.0 strip-literal: 2.0.0 tinybench: 2.6.0 - tinypool: 0.8.2 - vite: 5.2.3(@types/node@20.11.30)(terser@5.29.2) + tinypool: 0.8.3 + vite: 5.2.6(@types/node@20.11.30)(terser@5.29.2) vite-node: 1.4.0(@types/node@20.11.30)(terser@5.29.2) why-is-node-running: 2.2.2 transitivePeerDependencies: diff --git a/vite.config.ts b/vite.config.ts index db625ab1..bcc634f5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -18,7 +18,8 @@ export const globals = { 'hls.js': 'Hls', 'hls.js/dist/hls.min.js': 'Hls', 'mpegts.js/dist/mpegts.js': 'mpegts', - 'webtorrent/dist/webtorrent.min.js': 'WebTorrent' + 'webtorrent/dist/webtorrent.min.js': 'WebTorrent', + 'webtorrent/webtorrent.min.js': 'WebTorrent' } const babelPlugins = [