diff --git a/assets/js/core/event-bus.ts b/assets/js/core/event-bus.ts index 2d477ae8..53d16aa7 100644 --- a/assets/js/core/event-bus.ts +++ b/assets/js/core/event-bus.ts @@ -3,8 +3,8 @@ export interface FixItEventMap { 'fixit:switch-theme': { isDark: boolean, mode: string, isChanged: boolean } 'fixit:scroll': void 'fixit:resize': void - 'fixit:decrypted': { target: Element } - 'fixit:partial-decrypted': { target: Element } + 'fixit:content-decrypted': { target: HTMLElement, isPage: boolean } + 'fixit:toc-decrypted': { html: string } 'fixit:re-encrypt': void 'fixit:code-tab-sync': { lang: string, source: HTMLElement } 'fixit:sw-update': void diff --git a/assets/js/core/tokens.ts b/assets/js/core/tokens.ts index ecdfee38..4e506771 100644 --- a/assets/js/core/tokens.ts +++ b/assets/js/core/tokens.ts @@ -45,9 +45,9 @@ export interface CodeService { // ─── TocService ─── export interface TocService { + renderToc: () => void syncTocHeight: () => void syncTocActiveState: () => void - initToc: () => void setup: () => void } diff --git a/assets/js/lib/aplayer.ts b/assets/js/lib/aplayer.ts index ee16fe61..80653e64 100644 --- a/assets/js/lib/aplayer.ts +++ b/assets/js/lib/aplayer.ts @@ -3,7 +3,7 @@ * * Responsibilities: * - Discover `.shortcode-aplayer` nodes and initialize APlayer instances once. - * - Re-run initialization after decrypted or partially decrypted content is revealed. + * - Re-run initialization when `fixit:content-decrypted` is emitted. * - Keep behavior idempotent through `data-processed` markers. */ import { eventBus } from '../core/event-bus' @@ -24,6 +24,5 @@ function initAPlayer() { document.addEventListener('DOMContentLoaded', () => { initAPlayer() - eventBus.on('fixit:decrypted', initAPlayer) - eventBus.on('fixit:partial-decrypted', initAPlayer) + eventBus.on('fixit:content-decrypted', initAPlayer) }, false) diff --git a/assets/js/lib/echarts.ts b/assets/js/lib/echarts.ts index 5039c814..6073798f 100644 --- a/assets/js/lib/echarts.ts +++ b/assets/js/lib/echarts.ts @@ -5,7 +5,7 @@ * - Initialize ECharts instances with light/dark theme support. * - Re-render all charts on theme switch. * - Resize charts on window resize events. - * - Re-run initialization after decrypted content is revealed. + * - Re-run initialization when `fixit:content-decrypted` is emitted. */ import { eventBus } from '../core/event-bus' import { getStagingDOM, isDarkMode, isObjectLiteral } from '../utils' @@ -84,6 +84,11 @@ document.addEventListener('DOMContentLoaded', () => { eventBus.on('fixit:resize', () => { echartsArr.forEach(chart => chart.resize()) }) - eventBus.on('fixit:decrypted', applyEchartsTheme) - eventBus.on('fixit:partial-decrypted', ({ detail }) => initEchartsInTarget(detail.target)) + eventBus.on('fixit:content-decrypted', ({ detail }) => { + if (detail.isPage) { + applyEchartsTheme() + return + } + initEchartsInTarget(detail.target) + }) }, false) diff --git a/assets/js/lib/file-tree.ts b/assets/js/lib/file-tree.ts index 59e8a096..164525fb 100644 --- a/assets/js/lib/file-tree.ts +++ b/assets/js/lib/file-tree.ts @@ -4,7 +4,7 @@ * Responsibilities: * - Initialize folder expand/collapse interactions for `.file-tree` blocks. * - Recalculate connector line heights when tree visibility/layout changes. - * - Sync tree state across tab switches, print preparation, and decrypted content updates. + * - Sync tree state across tab switches, print preparation, and `fixit:content-decrypted` updates. */ import type { TabContainerChangedEvent } from '../types' import { eventBus } from '../core/event-bus' @@ -88,11 +88,7 @@ function bindEvents() { } }, false) - eventBus.on('fixit:decrypted', () => { - initFileTree() - }) - - eventBus.on('fixit:partial-decrypted', ({ detail }) => { + eventBus.on('fixit:content-decrypted', ({ detail }) => { initFileTree(detail.target) }) } diff --git a/assets/js/lib/fixit-decryptor.ts b/assets/js/lib/fixit-decryptor.ts index ed206054..78586893 100644 --- a/assets/js/lib/fixit-decryptor.ts +++ b/assets/js/lib/fixit-decryptor.ts @@ -2,10 +2,10 @@ * Encrypted content decryptor for FixIt pages and shortcodes. * * Responsibilities: - * - Validate password input and decrypt AES-256-GCM payloads into target containers. + * - Validate password input and decrypt AES-256-GCM payloads. * - Support both full-page and shortcode-scoped encrypted blocks. * - Persist and validate page-level decrypt cache with expiration. - * - Emit and react to FixIt events for decrypted/partial-decrypted/reset flows. + * - Emit FixIt events for content/TOC rendering and re-encrypt flows. * * Encrypted payloads are stored in `