/** * The SheetJS-backed spreadsheet {@link @nhtio/adk/batteries/media/contracts!MediaEngine}: * the in-process, cross-environment spreadsheet converter, generator, and structural editor. * * @module @nhtio/adk/batteries/media/engines/sheetjs * * @remarks * SheetJS (the `xlsx` package) reads and writes the widest spreadsheet matrix of any pure-JS * library — XLSX/XLSM/XLSB, every XLS BIFF era, ODS/FODS, CSV, SYLK, DIF, DBF, HTML, RTF, * Apple NUMBERS — with no binary, no native bindings, in any environment. This engine exposes * that matrix three ways: * * - **convert**: any readable spreadsheet MIME → any writable format token. * - **generate**: `EMPTY_MIME` → any writable token (a blank `Sheet1` workbook, written out). * - **edit**: the `sheet.*` structural ops via CSF cell-object surgery. ⚠️ SheetJS Community * Edition does NOT model cell styling — fonts, fills, and comments are STRIPPED by any edit * or convert that round-trips a styled workbook (styling is a SheetJS Pro feature). For * fidelity-preserving edits compose the exceljs engine FIRST in the engines array; this * engine's edits are for unstyled/data workbooks and for breadth (it edits ODS, XLS, and * every other readable format by normalizing through CSF). * * ⚠️ **Install from the SheetJS CDN, not the npm registry.** The registry copy of `xlsx` is * frozen at 0.18.5 (2023) and carries CVE-2023-30533 and CVE-2024-22363; this engine requires * `>=0.20.2`. Install: `pnpm add xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz` * (SheetJS recommends vendoring the tarball — see docs.sheetjs.com). * * `xlsx` is an optional peer dependency, lazily imported on first actual use. The NUMBERS * write target additionally loads the ZAHL payload (`xlsx/dist/xlsx.zahl.mjs`, ~110 KB) on * first request of that specific target. */ import type * as XlsxNS from "../../../bundled_xlsx"; import type { MediaEngine } from "../contracts"; type XlsxModule = typeof XlsxNS; /** Options for {@link sheetjsEngine}. */ export interface SheetjsEngineOptions { /** Override the module resolution (tests / custom builds). Default: `import('xlsx')`. */ xlsx?: () => XlsxModule | Promise; /** * Override the ZAHL payload resolution for NUMBERS output (tests / custom builds). * Default: `import('xlsx/dist/xlsx.zahl.mjs')`. */ zahl?: () => unknown | Promise; } /** * Construct the SheetJS-backed spreadsheet engine. * * @param options - Optional module resolver overrides. * @returns The engine. */ export declare const sheetjsEngine: (options?: SheetjsEngineOptions) => MediaEngine; export {};