refactor(docs): [SITE-03] migrate desktop editor and integrate typed generation

This commit is contained in:
Harvey Zhao committed 2026-09-14 09:25:46 +08:00
1 parent a468cb2c39
commit 2f130c58f1
37 files changed
+1921 -305

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ const englishPaths = globSync('**/*.md', { cwd: `${root}/docs/en`, posix: true }
/** @type {Map<string, string>} */
const outputs = new Map()
/** @type {[string, string][]} */
const entries = [['editor-loader.ts', 'docs/assets/js/loader.js'], ['mobile.ts', 'docs/assets/js/mobile.js'], ['navigation.ts', `${root}/docs/public/main.js`]]
const entries = [['bootstrap.ts', 'docs/assets/js/bootstrap.js'], ['editor.ts', 'docs/assets/js/common.js'], ['editor-loader.ts', 'docs/assets/js/loader.js'], ['mobile.ts', 'docs/assets/js/mobile.js'], ['navigation.ts', `${root}/docs/public/main.js`]]
for (const [entry, output] of entries) {
const result = await build({
...(entry === 'navigation.ts'
+7
View File
@@ -1,4 +1,11 @@
import { spawnSync } from 'node:child_process'
import process from 'node:process'
import { runEditorDeclarations } from './editor-declarations/generate.ts'
await runEditorDeclarations(process.argv.slice(2))
if (!process.argv.includes('--check')) {
const child = spawnSync(process.execPath, ['scripts/build-site-assets.mjs'], { stdio: 'inherit', windowsHide: true })
if (child.error)
throw child.error
process.exitCode = child.status ?? 1
}
+3 -3
View File
@@ -5,11 +5,11 @@ import { ownedPath, read, sha256 } from './files.ts'
export function buildCorpus(root: string): Map<string, string> {
const common = ts.createSourceFile(
'common.js',
read(ownedPath(root, 'docs/assets/js/common.js')),
'editor-libraries.ts',
read(ownedPath(root, 'packages/artplayer-vitepress/browser/editor-libraries.ts')),
ts.ScriptTarget.Latest,
true,
ts.ScriptKind.JS,
ts.ScriptKind.TS,
)
const declarations: string[] = []
let lists = 0
+14 -3
View File
@@ -22,6 +22,15 @@ Orchestration depends on conversion and validation; conversion does not write.
Public package declarations remain the source of truth. Do not hand-edit
`docs/assets/ts/*.d.ts`.
The editor URL list is generated in
`packages/artplayer-vitepress/browser/editor-libraries.ts`, then imported by the
desktop TypeScript entry. `common.js` is a generated browser bundle. `build:ts`
regenerates site assets after successful writes; package selection arguments still
reach declaration generation. Read-only `check:editor-types` checks the list and
declarations, while `check:site-assets` independently checks the compiled UI.
The LLM corpus and site inventory read this source list to avoid using a stale
compiled UI as the declaration authority.
All selected declarations are formatted in memory using layout-only ESLint fixes,
then checked together with TypeScript 5.9.3 and 4.3.5, without `skipLibCheck` or
ambient dependency discovery. This checks cross-package globals too. SDK methods
@@ -44,7 +53,7 @@ Adjacent generated `artplayer-plugin-vast.LICENSE.txt` preserves upstream notice
This does not settle VAST's runtime default-behavior compatibility decision.
The editor loads 22 declarations: core, 20 ecosystem libraries and i18n. The
unreferenced legacy `artplayer-plugin-websr.d.ts` asset is not in the `common.js`
unreferenced legacy `artplayer-plugin-websr.d.ts` asset is not in the canonical
library list and is not owned or deleted here. Monaco tests follow the actual
list. AST updates require exactly one array-valued `libUris` declaration; missing
or ambiguous declarations fail. Package-only builds leave that list alone.
@@ -66,5 +75,7 @@ yarn test:browser test/browser/editor-declarations.spec.js --workers=1
Browser coverage uses the actual repository Monaco assets, all loaded declarations,
positive/negative consumers and emitted Chapter code against controlled media.
VAST is type-checked only: no ad request or SDK/network/device acceptance. Full
editor UI, routes, example coverage and release reviews remain SITE-03/04/05,
EX-03 and release tasks. SITE-02 installs no new dependencies.
editor UI migration and its targeted interaction checks are recorded in SITE-03;
full routes, example coverage and release reviews remain SITE-04/05, EX-03 and
release tasks. SITE-02 installs no new dependencies; SITE-03 adds matching
Monaco 0.30.1 development types without replacing browser vendor assets.
+5 -2
View File
@@ -64,8 +64,11 @@ export async function generateEditorDeclarations(selected: string[] = []): Promi
for (const compiler of [ts, compat as unknown as typeof ts])
assert.deepEqual(checkStandaloneDeclarations(declarations, compiler), [], `Invalid editor declarations (TS ${compiler.version})`)
if (!selected.length) {
const file = 'docs/assets/js/common.js'
outputs.set(file, editorLibUris(fs.readFileSync(file, 'utf8'), [...pluginFiles.sort(), 'artplayer.d.ts', languageFile]))
const file = 'packages/artplayer-vitepress/browser/editor-libraries.ts'
const code = editorLibUris(fs.readFileSync(file, 'utf8'), [...pluginFiles.sort(), 'artplayer.d.ts', languageFile])
const [result] = await eslint.lintText(code, { filePath: file })
assert(result && !result.errorCount, 'Invalid editor library manifest')
outputs.set(file, result.output || code)
}
if (sources.some(file => pluginIdentity(file).packageName === 'artplayer-plugin-vast')) {
const notices = [['@glomex/vast-ima-player', 'LICENSE'], ['@alugha/ima', 'LICENSE.md']].map(([name, file]) => `${name}\n${fs.readFileSync(path.join('node_modules', name!, file!), 'utf8').replaceAll('\r\n', '\n').trim()}\n`).join('\n')