refactor(chromecast): [PKG-CAST-04] preserve published types and add runtime entry

This commit is contained in:
Harvey Zhao committed 2026-09-13 17:34:49 +08:00
1 parent b0cfbfe3a0
commit 8ec9fbe83a
27 files changed
+994 -52

No files matched your search

@@ -1,16 +1,41 @@
import type Artplayer from 'artplayer'
interface Option {
export interface Option {
url?: string
sdk?: string
icon?: string
mimeType?: string
}
interface Chromecast {
export interface Chromecast {
name: 'artplayerPluginChromecast'
}
/** Published 1.1.0 result; actual registration is asynchronous. */
export type Result = Chromecast
export type Factory = (option: Option) => (art: Artplayer) => Chromecast
export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'disconnecting'
export interface RuntimeOption extends Option {
onStateChange?: (this: RuntimeOption, state: ConnectionState) => void
onCastAvailable?: (this: RuntimeOption, available: boolean) => void
onCastStart?: (this: RuntimeOption) => void
onError?: (this: RuntimeOption, error: unknown) => void
}
export interface RuntimeResult extends Chromecast {
/** Last raw SDK SessionState, initially null; not the normalized callback state. */
getCastState: () => string | null
/** Whether this controller retains a session; does not prove receiver playback. */
isCasting: () => boolean
}
export interface RuntimeFactory {
(option: RuntimeOption): (art: Artplayer) => Promise<RuntimeResult>
default: RuntimeFactory
}
declare const artplayerPluginChromecast: (option: Option) => (art: Artplayer) => Chromecast
export default artplayerPluginChromecast
@@ -0,0 +1,15 @@
import type { RuntimeFactory } from './artplayer-plugin-chromecast.js'
declare const artplayerPluginChromecast: RuntimeFactory
// eslint-disable-next-line ts/no-redeclare -- Ambient merge exposes types on the CommonJS factory.
declare namespace artplayerPluginChromecast {
type Chromecast = import('./artplayer-plugin-chromecast.js').Chromecast
type ConnectionState = import('./artplayer-plugin-chromecast.js').ConnectionState
type Factory = import('./artplayer-plugin-chromecast.js').Factory
type Option = import('./artplayer-plugin-chromecast.js').Option
type Result = import('./artplayer-plugin-chromecast.js').Result
type RuntimeFactory = import('./artplayer-plugin-chromecast.js').RuntimeFactory
type RuntimeOption = import('./artplayer-plugin-chromecast.js').RuntimeOption
type RuntimeResult = import('./artplayer-plugin-chromecast.js').RuntimeResult
}
export = artplayerPluginChromecast
@@ -0,0 +1,5 @@
import type { RuntimeFactory } from './artplayer-plugin-chromecast.js'
declare const artplayerPluginChromecast: RuntimeFactory
export default artplayerPluginChromecast
export type { Chromecast, ConnectionState, Factory, Option, Result, RuntimeFactory, RuntimeOption, RuntimeResult } from './artplayer-plugin-chromecast.js'
+15
View File
@@ -0,0 +1,15 @@
import type { RuntimeFactory } from './artplayer-plugin-chromecast.js'
declare const artplayerPluginChromecast: RuntimeFactory
// eslint-disable-next-line ts/no-redeclare -- Ambient merge exposes types on the CommonJS factory.
declare namespace artplayerPluginChromecast {
type Chromecast = import('./artplayer-plugin-chromecast.js').Chromecast
type ConnectionState = import('./artplayer-plugin-chromecast.js').ConnectionState
type Factory = import('./artplayer-plugin-chromecast.js').Factory
type Option = import('./artplayer-plugin-chromecast.js').Option
type Result = import('./artplayer-plugin-chromecast.js').Result
type RuntimeFactory = import('./artplayer-plugin-chromecast.js').RuntimeFactory
type RuntimeOption = import('./artplayer-plugin-chromecast.js').RuntimeOption
type RuntimeResult = import('./artplayer-plugin-chromecast.js').RuntimeResult
}
export = artplayerPluginChromecast