chore: types

This commit is contained in:
ThaUnknown 2023-10-16 18:06:02 +02:00
parent fcb4af670c
commit a506a06688
5 changed files with 29 additions and 11 deletions

View file

@ -1,6 +1,6 @@
{
"name": "Miru",
"version": "4.4.13",
"version": "4.4.14",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"description": "Stream anime torrents, real-time with no waiting for downloads.",
"main": "build/main.js",

View file

@ -156,7 +156,7 @@
$: checkAvail(current)
let hasNext = false
let hasLast = false
function checkAvail () {
function checkAvail (current) {
if ((media?.media?.nextAiringEpisode?.episode - 1 || media?.media?.episodes) > media?.episode) {
hasNext = true
} else if (videos.indexOf(current) !== videos.length - 1) {
@ -339,9 +339,10 @@
}
}
function updatePiPState (paused) {
if (!document.pictureInPictureElement || document.pictureInPictureElement.id) return
if (paused) document.pictureInPictureElement.pause()
else document.pictureInPictureElement.play()
const element = /** @type {HTMLVideoElement | undefined} */ (document.pictureInPictureElement)
if (!element || element.id) return
if (paused) element.pause()
else element.play()
}
$: updatePiPState(paused)
function togglePopout () {
@ -647,7 +648,7 @@
function getBufferHealth (time) {
for (let index = video.buffered.length; index--;) {
if (time < video.buffered.end(index) && time >= video.buffered.start(index)) {
return parseInt(video.buffered.end(index) - time)
return (video.buffered.end(index) - time) | 0
}
}
return 0
@ -681,7 +682,7 @@
]
function isChapterSkippable (chapter) {
for (const [name, regex] of skippableChaptersRx) {
if (regex.test(chapter.text)) {
if (/** @type {RegExp} */ (regex).test(chapter.text)) {
return name
}
}

View file

@ -30,7 +30,7 @@
}
update()
}
function getStatusText () {
function getStatusText (media) {
if (media.mediaListEntry) {
const { status } = media.mediaListEntry
if (status === 'PLANNING') return 'Remove From List'
@ -85,7 +85,7 @@
}
return 'Play'
}
async function play () {
async function play (media) {
let ep = 1
if (media.mediaListEntry) {
const { status, progress } = media.mediaListEntry

View file

@ -25,7 +25,7 @@
src={'https://www.youtube.com/embed/' + $url}
frameborder='0'
title='trailer'
allowfullscreen='allowfullscreen'
allowfullscreen
class='w-full h-full position-absolute rounded top-0 left-0' />
</div>
</div>

19
types.d.ts vendored
View file

@ -1,9 +1,22 @@
export {}
type Track = {
selected: boolean
enabled: boolean
id: string
kind: string
label: string
language: string
}
declare global {
interface Window {
IPC: any;
IPC: any
port: MessagePort
version: {
platform: string
arch: string
}
}
interface EventTarget {
on: (type: string, callback: (any) => void, options?: boolean | {}) => void
@ -13,4 +26,8 @@ declare global {
removeListener: (type: string, callback: (any) => void) => void
off: (type: string, callback: (any) => void) => void
}
interface HTMLMediaElement {
videoTracks: Track[]
audioTracks: Track[]
}
}