refactor(site): [SITE-CONSOLE-01] restore typed console and lifecycle ownership

This commit is contained in:
Harvey Zhao committed 2026-09-15 06:15:32 +08:00
1 parent 6cd2d0ffbe
commit 3dba82a453
29 files changed
+1884 -36

No files matched your search

@@ -70,7 +70,9 @@ Imports preserve sequential JS/CSS insertion and the last lowercased `[name]` la
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
FileReaders, imported nodes, players and the desktop console viewer. The optional
`consoleLog.unmount` adapter releases its hook and pending work; older console
bundles without the adapter remain loadable. Executed script globals cannot be undone by
removing script nodes. Persisted pagehide keeps state; synthetic lifecycle tests do
not certify physical-device BFCache behavior.
@@ -25,7 +25,7 @@ export type EditorHost = Window & {
}
monaco: typeof Monaco
require: AmdLoader
consoleLog: (element: HTMLElement) => void
consoleLog: ((element: HTMLElement) => unknown) & { unmount?: (element: HTMLElement) => boolean }
ArtplayerDocsLoader: ReturnType<typeof createLibraryLoader> & {
exampleSource: typeof exampleSource
parameters: typeof parameters
@@ -25,6 +25,9 @@ export async function installEditor(host: EditorHost): Promise<void> {
host.consoleLog(output)
const controller = new AbortController()
const cleanups: (() => void)[] = []
cleanups.push(() => {
host.consoleLog.unmount?.(output)
})
const listen = (
target: EventTarget,
type: string,