@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
54 lines • 2.13 kB
text/typescript
/**
* Maximum size of the DEFLATE dictionary in bytes.
*
* DEFLATE uses only the last 32 KiB of the dictionary buffer.
* Any content beyond this limit is ignored by the compressor.
*/
export declare const MAX_DICTIONARY_SIZE: number;
/**
* Checksum byte length embedded in compressed payloads that use a text
* dictionary. The checksum lets `decompressHast` verify that the caller
* supplied the same `textContent` that was used during compression.
*/
export declare const CHECKSUM_BYTES = 4;
/**
* Shared dictionary for DEFLATE compression of HAST JSON.
*
* Contains byte sequences that frequently appear in JSON-serialized HAST trees
* (syntax-highlighted TypeScript type documentation). The dictionary is
* embedded in both the server build and the client bundle, so it must stay
* small — currently ~3 KB uncompressed.
*/
export declare const HAST_DICTIONARY: Uint8Array<ArrayBufferLike>;
/**
* FNV-1a 32-bit hash of a Uint8Array.
*
* Used to detect dictionary mismatches between compression and decompression.
* This is NOT cryptographic — it catches programming errors (wrong
* `textContent` passed), not adversarial tampering.
*
* Returns 4 bytes in big-endian order.
*/
export declare function computeDictionaryChecksum(dict: Uint8Array): Uint8Array;
/**
* Build a DEFLATE dictionary by combining optional text content with the
* static `HAST_DICTIONARY`.
*
* Layout: `[textContent bytes (truncated)][HAST_DICTIONARY]`
*
* - `HAST_DICTIONARY` is always at the **end** so it falls within DEFLATE's
* 32 KiB window regardless of text length.
* - `textContent` is truncated from the **end** (keeps the start, which
* corresponds to the first-rendered / most important content).
*
* When `textContent` is omitted or empty, returns `HAST_DICTIONARY` as-is.
*/
export declare function buildDictionary(textContent?: string): Uint8Array;
/**
* Error thrown when the dictionary checksum in a compressed payload does not
* match the dictionary built from the provided `textContent`.
*/
export declare class HastDictionaryMismatchError extends Error {
name: string;
constructor();
}