mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-21 12:41:20 -08:00
refactor(jassub): [PKG-JASSUB-04] migrate owned TypeScript and preserve public types
This commit is contained in:
1 parent
38e7b37878
commit
5e445b1af6
33 files changed
+3636
-61
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import fs from 'node:fs'
|
||||
|
||||
export const jassubInvalidStatements = [
|
||||
'jassub()',
|
||||
'jassub(undefined)',
|
||||
'jassub({ workerUrl: "/worker.js", wasmUrl: "/worker.wasm" })',
|
||||
'jassub({ workerUrl: 1, wasmUrl: "/worker.wasm", modernWasmUrl: "/modern.wasm" })',
|
||||
'instance.resize(640)',
|
||||
'const synchronousDestroy: void = instance.destroy()',
|
||||
'const wrongName: "other" = result.name',
|
||||
]
|
||||
|
||||
export function jassubConsumerSource(mode, raw = false) {
|
||||
let source = fs.readFileSync(new URL('../../test/types/jassub-public.ts', import.meta.url), 'utf8')
|
||||
if (mode === 'nodenext-esm' && !raw) {
|
||||
source = source
|
||||
.replace('import jassub from \'artplayer-plugin-jassub\'', 'import jassubModule from \'artplayer-plugin-jassub\'\nconst jassub = jassubModule.default')
|
||||
.replace('import legacy from \'artplayer-plugin-jassub/legacy\'', 'import legacyModule from \'artplayer-plugin-jassub/legacy\'\nconst legacy = legacyModule.default')
|
||||
}
|
||||
return source
|
||||
}
|
||||
|
||||
export function jassubRuntimeSource(mode) {
|
||||
const source = fs.readFileSync(new URL('../../test/types/jassub-runtime.ts', import.meta.url), 'utf8')
|
||||
return mode.endsWith('-no-interop')
|
||||
? source
|
||||
.replace('import runtime from \'artplayer-plugin-jassub/runtime\'', 'import runtime = require(\'artplayer-plugin-jassub/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