refactor(core): CORE-16 type display modes and own fullscreen lifetimes

This commit is contained in:
Harvey Zhao committed 2026-09-11 09:42:30 +08:00
1 parent 1b83081e8f
commit 88aef830df
81 files changed
+33897 -1503

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
import type { MiniHost } from '../../packages/artplayer/src/display/types'
import miniMix from '../../packages/artplayer/src/player/miniMix'
declare const host: MiniHost
miniMix(host)
const active: boolean = host.mini
host.mini = true
host.mini = false
// @ts-expect-error Mini retains boolean setters.
host.mini = 'true'
// @ts-expect-error Mini storage persists numeric coordinates.
host.storage.set('left', '25px')
export { active }
+14
View File
@@ -0,0 +1,14 @@
import type { OrientationHost, OrientationLock } from '../../packages/artplayer/src/display/orientation-types'
import autoOrientation from '../../packages/artplayer/src/plugins/autoOrientation'
declare const host: OrientationHost
declare const lock: OrientationLock
const plugin = autoOrientation(host)
const state: boolean = plugin.state
// @ts-expect-error The builtin exposes a getter, not a writable flag.
plugin.state = true
// @ts-expect-error Internal orientation requests use the opposite portrait/landscape mode.
lock.lock('upside-down')
// @ts-expect-error Fullscreen events carry boolean state.
host.on('fullscreen', (value: string) => value)
export { state }
+13
View File
@@ -0,0 +1,13 @@
import type { PipHost } from '../../packages/artplayer/src/display/types'
import pipMix from '../../packages/artplayer/src/player/pipMix'
declare const host: PipHost
pipMix(host)
const state: HTMLElement | null | boolean = host.pip
// @ts-expect-error Native PiP historically returns the element or null, not just boolean.
const booleanOnly: boolean = host.pip
host.pip = true
host.pip = false
// @ts-expect-error PiP setters accept a boolean input.
host.pip = 'picture-in-picture'
export { booleanOnly, state }
+21
View File
@@ -0,0 +1,21 @@
import type { AutoHeightHost, AutoSizeHost } from '../../packages/artplayer/src/display/sizing-types'
import { containSize, proportionalHeight } from '../../packages/artplayer/src/display/sizing'
import autoHeightMix from '../../packages/artplayer/src/player/autoHeightMix'
import autoSizeMix from '../../packages/artplayer/src/player/autoSizeMix'
declare const sizeHost: AutoSizeHost
declare const heightHost: AutoHeightHost
autoSizeMix(sizeHost)
autoHeightMix(heightHost)
const height: number | undefined = proportionalHeight(640, { width: 1920, height: 1080 })
const size = containSize({ width: 640, height: 480 }, 16 / 9)
if (size) {
const axis: 'width' | 'height' = size.axis
sizeHost.emit('autoSize', { width: size.width, height: size.height })
void axis
}
// @ts-expect-error The internal measurement cannot be a CSS string.
heightHost.emit('autoHeight', '360px')
// @ts-expect-error Dimensions must describe both axes.
proportionalHeight(640, { width: 1920 })
export { height }
+15
View File
@@ -0,0 +1,15 @@
import type { WebFullscreenHost } from '../../packages/artplayer/src/display/types'
import { capturePlacement, restorePlacement } from '../../packages/artplayer/src/display/placement'
import fullscreenWebMix from '../../packages/artplayer/src/player/fullscreenWebMix'
declare const host: WebFullscreenHost
fullscreenWebMix(host)
host.fullscreenWeb = true
const active: boolean = host.fullscreenWeb
const placement = capturePlacement(host.template.$player)
restorePlacement(placement)
// @ts-expect-error Display setters retain a boolean input.
host.fullscreenWeb = 'true'
// @ts-expect-error DOM placement cannot be constructed from a string.
capturePlacement('player')
export { active }