mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-19 03:11:20 -08:00
refactor(core): [CORE-21] generate compatible public and editor declarations
This commit is contained in:
1 parent
ee895a558f
commit
faaa3e8c2d
123 files changed
+31305
-1712
No files matched your search
+2
-10
@@ -2,6 +2,7 @@ import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { ESLint } from 'eslint'
|
||||
import { glob } from 'glob'
|
||||
import { generateCoreEditorDeclaration } from './editor-types.mjs'
|
||||
|
||||
function ensureDirExists(filePath) {
|
||||
const dir = path.dirname(filePath)
|
||||
@@ -26,17 +27,8 @@ function parsePluginInfo(pluginPath) {
|
||||
}
|
||||
|
||||
const reg = /^import.*$/gim
|
||||
const artplayerTS = glob.sync('packages/artplayer/types/*.d.ts')
|
||||
const artplayerTSoutput = path.join('docs/assets/ts/artplayer.d.ts')
|
||||
|
||||
let code = ''
|
||||
for (let index = 0; index < artplayerTS.length; index++) {
|
||||
const type = artplayerTS[index]
|
||||
code += `${String(fs.readFileSync(type)).replace(reg, '')}\n`
|
||||
}
|
||||
|
||||
code.replace('export default ', '')
|
||||
code += `export = Artplayer;\nexport as namespace Artplayer;\n`
|
||||
const code = generateCoreEditorDeclaration()
|
||||
ensureDirExists(artplayerTSoutput)
|
||||
fs.writeFileSync(artplayerTSoutput, code.trim())
|
||||
console.log(`✨ Built ${artplayerTSoutput}`);
|
||||
|
||||
Reference in new issue
Block a user