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

+43 -8
View File
@@ -11,13 +11,24 @@ Node 24.21.0 / Yarn 1.22.22 toolchain from the repository root.
| `navigation.ts` | Run Code DOM delegation, URL encoding, loopback targets and first-language navigation |
| `../../../scripts/build-site-assets.mjs` | Deterministic ES2020 bundles, available English routes and read-only drift check |
Generated outputs are `docs/assets/js/loader.js`, `docs/assets/js/mobile.js` and
this workspace's `docs/public/main.js`. Do not hand-edit them. `docs/index.html`
loads the desktop bridge before the old core/Monaco/common bootstrap. Mobile
Generated outputs are `docs/assets/js/bootstrap.js`, `common.js`, `loader.js`,
`mobile.js` and this workspace's `docs/public/main.js`. Do not hand-edit them.
`docs/index.html` loads the console bridge and loader before the typed bootstrap. Mobile
bundles the same loader module locally; it does not depend on the desktop bridge.
`docs/assets/js/common.js` remains the desktop UI source and owns Monaco, controls,
file import, editor state and instance cleanup. Its remaining TS/UI migration is
tracked under SITE-03; this task does not claim that whole file was migrated.
`common.js` is now generated from `editor.ts`. Desktop responsibilities are:
- `bootstrap.ts` and `editor-preferences.ts`: core/AMD/editor boot order, denied
storage defaults and the exact prod/ts/code/log preference keys.
- `editor.ts` and `editor-host.ts`: DOM bindings, page lifetime and the explicit
player/AMD/console boundary. Monaco globals come from the HTML bootstrap.
- `editor-monaco.ts`: model/declaration ownership, AMD language readiness and TS emit.
- `editor-session.ts`: latest-run ordering, source priority and classic-script execution.
- `editor-files.ts`: serialized JS/CSS imports, FileReader errors/cancellation and nodes.
- `editor-libraries.ts`: generated declaration URLs, authored through build:ts.
Root `monaco-editor@0.30.1` is a development type dependency matching the existing
browser vendor version. It is imported only as types, never bundled to replace
the browser assets. It does not complete the separate vendor provenance review.
The loader serializes all batches in one page. Each dependency completes before
the next is inserted; successful absolute URLs are cached even if a later resource
@@ -41,6 +52,28 @@ acceptance remains a separate environment check, not inferred from the branch.
Desktop request generations prevent a late example fetch from overwriting a newer
Run. Existing `artplayer:example:cleanup`, instance destruction and controls remain.
Successful preference changes keep their old true/false strings and reload behavior;
code/log visibility and URL pushState/Ctrl/Cmd-S remain. Denied storage defaults to
false, while failed writes report an error and restore the checkbox. Run is unavailable
until initialization finishes. Actual JS/TS AMD modules are awaited before example
dependencies can mask define; the old arbitrary one-second delay is removed.
TypeScript mode now compiles an immutable temporary model before Run. Syntax failures
keep the current player; semantic diagnostics are visible but are not a runtime gate.
This is a classic-script editor, not a module bundler or npm import resolver. JavaScript
uses a fresh non-strict function scope: globals work and top-level var stays local to
that Run. Access to the old private common.js closure was not a supported interface.
Late compilation cannot replace a newer Run; temporary models are disposed on settlement
and page disposal. Monaco worker RPCs have no invented cancellation API.
Imports preserve sequential JS/CSS insertion and the last lowercased `[name]` label.
Unsupported extensions are ignored; local labels are not persistable dependency URLs.
File errors now reject, cancellation removes handlers, and batches are serialized.
On non-persisted pagehide the editor cleans listeners, models, declaration libraries,
FileReaders, imported nodes and players. Executed script globals cannot be undone by
removing script nodes. Persisted pagehide keeps state; synthetic lifecycle tests do
not certify physical-device BFCache behavior.
Query parsing preserves raw values (including literal `+`) for one explicit decode;
the last duplicate wins and fragments are not part of query values. Example still
takes priority over code; mobile/index remain their original defaults. Example HTTP
@@ -62,14 +95,16 @@ yarn build:site-assets
yarn check:site-assets
yarn typecheck:site-assets
yarn typecheck:docs-tools
yarn test:site-editor
node --test test/site-loading.test.js
yarn test:browser test/browser/site-loading.spec.js --workers=1
```
Root build:docs regenerates site assets first. ci:check checks their types and drift;
root lint includes the TS modules and legacy common.js. Direct workspace VitePress
root lint includes the TS sources; common.js is checked by generated asset comparison. Direct workspace VitePress
commands still require regenerating these assets after source edits. The full
VitePress build/deploy, i18n and remote translation/LLM tooling remain SITE-03/05.
VitePress build/i18n tools are in scripts/site-build and offline LLM/draft translation
tools are in scripts/documentation. Full site/search and release acceptance remain separate.
Tests use real local pages, Monaco and controlled media, with unrelated remote
analytics/ads fulfilled inertly in test routes. They do not validate those services.
Keep browser verification serial with expensive compiler baselines when local