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

+10
View File
@@ -2,6 +2,16 @@
Use the pinned Node/Yarn toolchain from `../refactor/toolchain-setup.md`.
`yarn test:auto-thumbnail-types` checks the preserved npm 1.1.0 declaration,
accurate `/runtime` Promise types, exact rejected consumer lines, and generated
editor globals. It also runs in `test:auto-thumbnail` and `test:baseline`.
`yarn test:auto-thumbnail-types-package` packs the candidate and installs it and
the actual npm 1.1.0 archive outside the workspace with a packed core. It verifies
frozen reinstalls, byte identity, conditional declaration resolution, old/current
compiler consumers, no-interop CommonJS, and installed factory registration.
This does not decode video or close the older 1.0.x export-shape, native pixel,
or device acceptance gaps. Candidate entry types use the same runtime files.
`yarn test:danmuku-mask` runs candidate run cancellation/resource ownership plus
frozen historical defects and public contracts. Candidate tests also run in
`test:unit`; their controlled SDK, RAF and canvas hosts do not prove native model
+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 }