import { ProviderMiss, type ProviderMissCode } from "./derive.js"; import type { Cell, ProviderCall, ProviderSource } from "./provider.js"; /** What one archive may hold before any of it is inflated, and what the reader parses of it. */ export type OfficeLimits = { /** Entries: a package holds a few dozen parts, a deck three or four per slide, a bomb of small files millions (2026-10-11). */ readonly maxEntries: number; /** Declared uncompressed bytes over all entries: 16 times the bytes the package reads into the process (2026-10-11). */ readonly maxUncompressedBytes: number; /** Declared bytes per compressed byte over the whole archive, once it declares more than `ratioFloorBytes`: synthetic sheet XML deflates 6 to 1, a run of identical rows 342 to 1, and deflate's own ceiling is 1,032 to 1 (measured 2026-10-11). */ readonly maxRatio: number; readonly ratioFloorBytes: number; /** One XML part parsed, and the most text built from one word or OpenDocument text: @xmldom/xmldom took 2.0 s and 279 MB of heap for 4 MiB of sheet XML, 16 s and 2 GB for 32 MiB (measured 2026-10-11). */ readonly maxPartBytes: number; /** All parts parsed for one read, so a deck of thousands of slides costs seconds of parsing per call, not minutes; also the most text built from the cells of one workbook (2026-10-11). */ readonly maxParsedBytes: number; /** Elements in one XML part, counted before it is parsed: 1,000,000 of them in 3.8 MiB took 2.0 s and 746 MB, and a 4 MiB sheet of real cells holds about 360,000 (measured 2026-10-11). */ readonly maxElements: number; /** Levels an XML part may nest, measured after it is parsed and before any walk of it: a legitimate document nests tables, groups and lists a few dozen levels, and a walk recurses once a level (2026-10-11). */ readonly maxDepth: number; /** Cells one read builds: a part at the cap holds at most about 170,000, but a repeat count in an OpenDocument sheet holds any number (2026-10-11). */ readonly maxCells: number; }; /** The limits an archive is held to before anything is inflated, and every part is held to while it is: entries, sizes, * compression ratio, parsed elements, depth and cells. */ export declare const OFFICE_LIMITS: OfficeLimits; /** An office file that cannot be read, as a typed miss: the codes a provider's failure maps to. The message is one line * the model reads, and names the sizes, the cap and how to narrow the read. */ export type OfficeMissCode = ProviderMissCode; /** An office document that cannot be read, as a typed miss the model can act on. */ export declare class OfficeMissError extends ProviderMiss { readonly name = "OfficeMissError"; } /** A source's bytes through the environment: the one file it opens, never more than the process holds of it, and the very * bytes it was hashed as. A file over the cap, one that cannot be read, and one that changed after its hash are typed * misses; a file that grew after it was described is read only as far as the size it had when opened. */ export declare function readSource(source: ProviderSource, call: ProviderCall): Promise; /** One entry of a zip's central directory: its name, compression method, sizes, checksum and offset. */ export type ZipEntry = { readonly name: string; readonly method: number; readonly size: number; readonly originalSize: number; readonly crc: number; readonly offset: number; }; /** The entries of a zip archive from its central directory, held to the limits before anything is inflated: the count, * the declared total, and the declared ratio of the whole. An encrypted or duplicated entry, a zip64 archive and a * directory that runs off the file are refused. Nothing is inflated, so a bomb costs this much and no more. */ export declare function zipDirectory(data: Uint8Array, limits?: OfficeLimits): ZipEntry[]; /** One entry's bytes, held to its directory entry. It is inflated in pushes of 8 KiB and stopped the moment it passes * the size the directory declares, so an entry that lies about its size costs one push and not its real size; the * bytes must be as many as declared and have the declared CRC-32, so a changed byte is not read as a different value. * An entry declared over `limit` is over budget before it is touched; one that is not what it declares is unreadable. * `keep: false` checks and discards, in memory that does not grow. */ export declare function inflateEntry(data: Uint8Array, entry: ZipEntry, limit: number, keep?: boolean): Promise; /** A cell as the office reader gives it: the package's own, and the date a date-formatted number stands for. */ export type OfficeCell = Cell & { readonly date?: string; }; /** One cell as a model reads it: `D3=71866.19 {=SUM(C$2:C3)}`. A formula with no stored result says so in the cell, and * a number with a date format carries its date. */ export declare function cellText(cell: OfficeCell): string; /** A sheet as text: its name, then one line per row that holds cells, each cell with its reference so that a gap never * shifts a column. */ export declare function sheetText(name: string, cells: readonly OfficeCell[], hidden?: boolean): string; /** What the text of an office document is not, for a result read without a render. */ export declare const notRenderedNote: (kind: "office" | "sheet") => string;