mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-16 17:46:17 -08:00
feat(auto-thumbnail): [PKG-AUTO-THUMB-08] add compatible runtime type entry
This commit is contained in:
1 parent
7be628a983
commit
c4f5dcf17f
27 files changed
+2005
-40
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import fs from 'node:fs'
|
||||
|
||||
export const publicInvalid = [
|
||||
'thumbnail()',
|
||||
'thumbnail(undefined)',
|
||||
'thumbnail({ width: "80" })',
|
||||
'thumbnail({ height: 90 })',
|
||||
'const asynchronous: Promise<{name: "artplayerPluginAutoThumbnail"}> = result',
|
||||
'thumbnail.default({})',
|
||||
]
|
||||
|
||||
export const runtimeInvalid = [
|
||||
'runtime()',
|
||||
'runtime(undefined)',
|
||||
'runtime({ url: 1 })',
|
||||
'runtime({ width: "80" })',
|
||||
'runtime({ number: false })',
|
||||
'runtime({ scale: "1" })',
|
||||
'runtime({ height: "90" })',
|
||||
'runtime({ unknown: true })',
|
||||
'runtime({})()',
|
||||
'pending.name',
|
||||
'runtime.default({})',
|
||||
'const synchronous: Result = pending',
|
||||
'const wrong: Factory = (_option) => (_art) => ({name: "artplayerPluginAutoThumbnail"})',
|
||||
]
|
||||
|
||||
export function publicSource(mode, raw = false) {
|
||||
let source = fs.readFileSync(new URL('../../test/types/auto-thumbnail-public.ts', import.meta.url), 'utf8')
|
||||
if (mode === 'nodenext-esm' && !raw) {
|
||||
source = source.replace('import thumbnail from \'artplayer-plugin-auto-thumbnail\'', 'import thumbnailModule from \'artplayer-plugin-auto-thumbnail\'\nconst thumbnail = thumbnailModule.default')
|
||||
.replace('import legacy from \'artplayer-plugin-auto-thumbnail/legacy\'', 'import legacyModule from \'artplayer-plugin-auto-thumbnail/legacy\'\nconst legacy = legacyModule.default')
|
||||
}
|
||||
return source
|
||||
}
|
||||
|
||||
export function runtimeSource(mode) {
|
||||
const source = fs.readFileSync(new URL('../../test/types/auto-thumbnail-runtime.ts', import.meta.url), 'utf8')
|
||||
return mode.endsWith('-no-interop')
|
||||
? source.replace('import runtime from \'artplayer-plugin-auto-thumbnail/runtime\'', 'import runtime = require(\'artplayer-plugin-auto-thumbnail/runtime\')')
|
||||
.replace('import type Artplayer from \'artplayer\'', 'type Core = typeof import(\'artplayer\'); type Artplayer = Core extends { default: { prototype: infer I } } ? I : Core extends { prototype: infer I } ? I : never')
|
||||
: source
|
||||
}
|
||||
Reference in new issue
Block a user