mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-12 23:36:15 -08:00
refactor(vast): [PKG-VAST-04] retain published types and add accurate runtime declarations
This commit is contained in:
1 parent
c162d2b3b3
commit
e5c73fa620
34 files changed
+7819
-1495
No files matched your search
@@ -4,6 +4,7 @@ import fs from 'node:fs'
|
||||
import { test } from 'node:test'
|
||||
import { ESLint } from 'eslint'
|
||||
import compat from 'typescript-compat'
|
||||
import { verifyVastContract } from '../refactor/scripts/vast-contract.mjs'
|
||||
import { vastSdkDeclarations } from '../scripts/editor-declarations/dependencies.ts'
|
||||
import { editorLibUris, generateEditorDeclarations } from '../scripts/editor-declarations/generate.ts'
|
||||
import { checkStandaloneDeclarations } from '../scripts/editor-declarations/validation.ts'
|
||||
@@ -24,11 +25,14 @@ test('editor declarations are reproducible, standalone and preserve constructor/
|
||||
assert.throws(() => asGlobalDeclaration('export { default } from "./missing"', 'Artplayer'), /unresolved exports/)
|
||||
})
|
||||
|
||||
test('Chapter and VAST editor consumers preserve SDK types, optional Window hook and named results', () => {
|
||||
test('Chapter and historical workspace VAST editor consumers preserve SDK types, optional Window hook and named results', async () => {
|
||||
const contract = await verifyVastContract()
|
||||
const core = fs.readFileSync('docs/assets/ts/artplayer.d.ts', 'utf8')
|
||||
const generated = new Map([['artplayer.d.ts', core]])
|
||||
for (const [suffix, global] of [['chapter', 'artplayerPluginChapter'], ['vast', 'artplayerPluginVast']]) {
|
||||
const source = fs.readFileSync(`packages/artplayer-plugin-${suffix}/types/artplayer-plugin-${suffix}.d.ts`, 'utf8')
|
||||
const source = suffix === 'vast'
|
||||
? contract.sources.get('packages/artplayer-plugin-vast/types/artplayer-plugin-vast.d.ts')
|
||||
: fs.readFileSync(`packages/artplayer-plugin-${suffix}/types/artplayer-plugin-${suffix}.d.ts`, 'utf8')
|
||||
const old = `${source.replace(/^import.*$/gim, '')}\nexport = ${global};\nexport as namespace ${global};\n`
|
||||
const diagnostics = checkPluginEditorDeclaration(old, core)
|
||||
assert(diagnostics.some(item => item.code === 2309))
|
||||
|
||||
Reference in new issue
Block a user