refactor(core): [CORE-20] type entry and converge initialization

This commit is contained in:
Harvey Zhao committed 2026-09-11 16:07:06 +08:00
1 parent ccf77c4ed2
commit ee895a558f
100 files changed
+33854 -839

No files matched your search

+6 -7
View File
@@ -1,15 +1,13 @@
import type { CoreEmission } from '../../events/core-types'
import type { NoticeSink } from '../../notice'
export type MediaEventName = `video:${string}`
export type MediaListener = (event?: unknown) => void
export interface MediaEvents {
export interface MediaEvents extends CoreEmission<MediaEventName | 'ready' | 'resize' | 'error'> {
on: (name: MediaEventName, callback: MediaListener) => unknown
once: (name: MediaEventName, callback: MediaListener) => unknown
off: (name: MediaEventName, callback: MediaListener) => unknown
emit: {
(name: MediaEventName, event: Event): unknown
(name: 'ready' | 'resize'): unknown
(name: 'error', error: unknown, attempt: number): unknown
}
}
export interface MediaUI {
@@ -28,11 +26,12 @@ export interface MediaEventHost extends MediaEvents, MediaUI {
isReady: boolean
readonly playing: boolean
url: string | null
get seek(): undefined
set seek(time: number)
play: () => unknown
option: { url: string, loop: boolean }
i18n: { get: (key: string) => string }
notice: { set show(message: string) }
notice: NoticeSink
constructor: { RECONNECT_TIME_MAX: number, RECONNECT_SLEEP_TIME: number }
}
+2 -1
View File
@@ -1,3 +1,4 @@
import type { NoticeSink } from '../notice'
import type { ResolvedOption } from '../option/types'
import type { PlaybackMethods } from './types'
@@ -7,7 +8,7 @@ export interface MediaHost<Media> {
interface NoticeHost {
i18n: { get: (key: string) => string }
notice: { get show(): unknown, set show(value: string | Error) }
notice: NoticeSink
emit: (name: 'play' | 'pause') => unknown
}
+6 -3
View File
@@ -1,3 +1,6 @@
import type { PipProperty } from '../display/types'
import type { NoticeSink } from '../notice'
export interface Position {
readonly duration: number
get currentTime(): number
@@ -14,13 +17,13 @@ export interface SeekMethods {
}
export interface SeekHost extends Position {
notice: { set show(message: string) }
notice: NoticeSink
emit: (name: 'seek', currentTime: number, requestedTime: number | string) => unknown
}
export interface PlaybackNotice {
i18n: { get: (key: string) => string }
notice: { set show(message: string) }
notice: NoticeSink
}
export interface VolumeHost extends PlaybackNotice {
@@ -30,7 +33,7 @@ export interface VolumeHost extends PlaybackNotice {
}
export type DisplayState = 'mini' | 'pip' | 'fullscreen' | 'fullscreenWeb'
export type DisplayStates = Record<DisplayState, boolean>
export type DisplayStates = Record<'mini' | 'fullscreenWeb', boolean> & PipProperty & { fullscreen?: boolean }
export interface StateProperty {
get state(): DisplayState | 'standard'