feat(auto-thumbnail): [PKG-AUTO-THUMB-08] add compatible runtime type entry

This commit is contained in:
Harvey Zhao committed 2026-09-14 04:07:59 +08:00
1 parent 7be628a983
commit c4f5dcf17f
27 files changed
+2005 -40

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
import type Artplayer from 'artplayer'
import thumbnail from 'artplayer-plugin-auto-thumbnail'
import legacy from 'artplayer-plugin-auto-thumbnail/legacy'
type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false
type Assert<T extends true> = T
interface Option { url?: string, width?: number, number?: number, scale?: number }
interface Result { name: 'artplayerPluginAutoThumbnail' }
type HistoricalFactory = (option: Option) => (art: Artplayer) => Result
type ExactFactory = Assert<Equal<typeof thumbnail, HistoricalFactory>>
type ExactOption = Assert<Equal<Parameters<typeof thumbnail>, [option: Option]>>
type ExactResult = Assert<Equal<ReturnType<ReturnType<typeof thumbnail>>, Result>>
type ExactLegacy = Assert<Equal<typeof legacy, typeof thumbnail>>
declare const art: Artplayer
const result: Result = thumbnail({ url: '/video.mp4', width: 80, number: 12, scale: 0.5 })(art)
const replacement: typeof thumbnail = (_option: Option) => (_art: Artplayer) => result
const assignBack: HistoricalFactory = thumbnail
const legacyReplacement: typeof legacy = replacement
const moduleReplacement: typeof import('artplayer-plugin-auto-thumbnail') = { default: replacement }
const legacyName: Result['name'] = legacy({})(art).name
void [assignBack, legacyReplacement, moduleReplacement, legacyName]
export type { ExactFactory, ExactLegacy, ExactOption, ExactResult }
+18
View File
@@ -0,0 +1,18 @@
import type Artplayer from 'artplayer'
import type { Factory, Option, Result } from 'artplayer-plugin-auto-thumbnail/runtime'
import runtime from 'artplayer-plugin-auto-thumbnail/runtime'
type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false
type Assert<T extends true> = T
type ExactFactory = Assert<Equal<typeof runtime, Factory>>
type ExactOption = Assert<Equal<Parameters<typeof runtime>, [option: Option]>>
type ExactResult = Assert<Equal<ReturnType<ReturnType<typeof runtime>>, Promise<Result>>>
declare const art: Artplayer
const option: Option = { url: '/video.mp4', width: 80, number: 12, scale: 0.5, height: 90 }
const pending: Promise<Result> = runtime(option)(art)
const name: Promise<'artplayerPluginAutoThumbnail'> = pending.then(value => value.name)
const plugins: NonNullable<Artplayer['option']['plugins']> = [runtime(option)]
const replacement: Factory = _option => async _art => ({ name: 'artplayerPluginAutoThumbnail' })
void [name, plugins, replacement]
export type { ExactFactory, ExactOption, ExactResult }