/** * Base utility functions shared between Node.js and Browser * All functions use standard Web APIs that work in both environments * (Node.js 16+ supports atob/btoa/TextEncoder/TextDecoder globally) */ /** * Convert base64 string to Uint8Array * Uses native Buffer in Node.js for better performance */ export declare function base64ToUint8Array(base64: string): Uint8Array; export declare function delay(ms: number): Promise; export declare function dateToExcel(d: Date, date1904?: boolean): number; export declare function excelToDate(v: number, date1904?: boolean): Date; /** * Parse an OOXML date string into a Date object. * OOXML dates like "2024-01-15T00:00:00" lack a timezone suffix, * which some JS engines parse as local time. Appending "Z" forces UTC. */ export declare function parseOoxmlDate(raw: string): Date; /** * Decode OOXML `_xHHHH_` escape sequences in a string. * * Used when reading text content from `` elements in shared strings, * rich text runs, and inline strings. The replacement works left-to-right, * so `_x005F_x000D_` correctly decodes to the literal string `_x000D_` * (the `_x005F_` decodes to `_`, consuming the match). */ export declare function decodeOoxmlEscape(text: string): string; /** * Encode literal `_xHHHH_` patterns in a string for OOXML output. * * If a string naturally contains the pattern `_xHHHH_` (e.g., the user typed * `_x000D_`), the leading underscore must be escaped as `_x005F_` to prevent * readers from misinterpreting it as an escape sequence. * * Roundtrip guarantee: `decodeOoxmlEscape(encodeOoxmlEscape(s)) === s` */ export declare function encodeOoxmlEscape(text: string): string; /** * Encode a string for safe use in an OOXML **XML attribute** value. * * Two transformations are applied (order matters): * 1. Literal `_xHHHH_` patterns are escaped (`_x005F_xHHHH_`) so readers * do not misinterpret them as escape sequences. * 2. Characters that XML attribute-value normalisation would mangle * (`\t`, `\n`, `\r`) are encoded as `_x0009_`, `_x000A_`, `_x000D_`. * * This is the write-side counterpart of {@link decodeOoxmlEscape}. * Use `encodeOoxmlEscape` for element **text** content and this function * for **attribute** values. */ export declare function encodeOoxmlAttr(text: string): string; export { xmlEncode, xmlDecode } from "../modules/xml/encode.js"; export declare function validInt(value: string | number): number; /** * Split an Excel numFmt string by semicolons, respecting quoted strings and brackets. * * Excel numFmt can have up to 4 sections: `positive ; negative ; zero ; text`. * Semicolons inside `"..."` (literal text) or `[...]` (locale/color tags) must NOT * be treated as section separators. */ export declare function splitFormatSections(fmt: string): string[]; export declare function isDateFmt(fmt: string | null | undefined): boolean; export declare function parseBoolean(value: unknown): boolean; export declare function range(start: number, stop: number, step?: number): Generator; export declare function toSortedArray(values: Iterable): T[]; /** * Convert a Buffer, ArrayBuffer, or Uint8Array to a UTF-8 string * Works in both Node.js and browser environments */ export declare function bufferToString(chunk: ArrayBuffer | Uint8Array | string): string; /** * Convert Uint8Array to base64 string * Uses native Buffer in Node.js, optimized chunked conversion in browser */ export declare function uint8ArrayToBase64(bytes: Uint8Array): string; /** * Convert string to UTF-16LE Uint8Array (used for Excel password hashing) */ export declare function stringToUtf16Le(str: string): Uint8Array; /** * Yield to the event loop via a macrotask. * Uses `setTimeout(0)` which works in both Node.js and browsers. */ export declare function yieldToEventLoop(): Promise;