/** * Office preview components: {@link DocxView} renders .docx via docx-preview * (preserved styles/images/tables), {@link XlsxView} renders .xlsx via the * Univer sheets preset (data + formulas + formatting). Both load the file * bytes through the existing /sidebar/file media route and own their library * lifecycle (dispose on unmount so canvases/workers don't leak — mirrors the * TerminalView dispose discipline). * * Errors degrade to the same download-button affordance the binary * placeholder uses, so a corrupted / encrypted / oversized file always * leaves the user with a way to get the file. * * Both libraries pull in several MB; tsdown's `codeSplitting: false` inlines * them into the single client bundle (the CJS __ModuleLoader__ wrapper's * `require` cannot load relative chunk URLs in the browser, so dynamic * import() collapses to a synchronous inline — see tsdown.config.ts). */ import { useEffect, useRef, useState } from 'react' import { downloadUrl, mediaUrl, type SessionScope } from './api.ts' import { t } from './locales.ts' import { xlsxWorkbookToUniver } from './xlsx-to-univer.ts' import css from './sidebar.module.css' // Univer's stylesheets ride the same dsh-css-inline pipeline as xterm's CSS // (one