mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 05:11:20 -08:00
refactor(core): [CORE-20] type entry and converge initialization
This commit is contained in:
1 parent
ccf77c4ed2
commit
ee895a558f
100 files changed
+33854
-839
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import type { UIEvents } from '../control/types'
|
||||
|
||||
// The emitter stays open to extension names. Known native events retain their
|
||||
// payloads so subsystem subscriptions are checked against the assembled player.
|
||||
export interface CoreEvents extends UIEvents, Record<PropertyKey, unknown[]> {
|
||||
[name: `video:${string}`]: [event: Event]
|
||||
'ready': []
|
||||
'error': [error: unknown, attempt: number]
|
||||
'fullscreenError': [error: unknown]
|
||||
'destroy': []
|
||||
'restart': [string]
|
||||
'focus': [Event]
|
||||
'lock': [boolean]
|
||||
'view': [boolean]
|
||||
'subtitleOffset': [number]
|
||||
'seek': [time: number, requestedTime: number | string]
|
||||
'document:click': [Event]
|
||||
'document:contextmenu': [Event]
|
||||
'document:keydown': [KeyboardEvent]
|
||||
'document:touchmove': [Event]
|
||||
'document:touchend': [Event]
|
||||
'document:touchcancel': [Event]
|
||||
'window:resize': [Event]
|
||||
'window:orientationchange': [Event]
|
||||
'window:scroll': [Event]
|
||||
}
|
||||
|
||||
export interface CoreEmission<Names extends keyof CoreEvents = keyof CoreEvents> {
|
||||
emit: <Name extends Names>(name: Name, ...args: [...CoreEvents[Name]]) => unknown
|
||||
}
|
||||
@@ -5,6 +5,6 @@ export default function moveInit(art: MoveHost, events: Pick<PointerRegistry, 'p
|
||||
const { $player } = art.template
|
||||
events.proxy($player, 'mousemove', (event) => {
|
||||
if (!isClosing(art))
|
||||
art.emit('mousemove', event)
|
||||
art.emit('mousemove', event as MouseEvent)
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { SubscriptionHost } from '../component/resources'
|
||||
import type { NoticeSink } from '../notice'
|
||||
|
||||
export interface ResizeEvents {
|
||||
'resize': []
|
||||
@@ -13,7 +14,7 @@ export interface ResizeHost extends SubscriptionHost<ResizeEvents> {
|
||||
aspectRatio: string
|
||||
state: string
|
||||
autoSize: () => unknown
|
||||
notice: { show: string }
|
||||
notice: NoticeSink
|
||||
emit: (name: 'resize') => unknown
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user