/** * Chunked Builder (Browser Compatible) * * Browser-compatible version that uses Uint8Array instead of Buffer. * This file provides the same API but works in browser environments. */ /** * Options for ChunkedBuilder */ export interface ChunkedBuilderOptions { /** Number of pieces to accumulate before consolidation */ chunkSize?: number; /** Initial capacity hint */ initialCapacity?: number; } /** * Efficient builder for accumulating and consolidating string chunks * Browser-compatible version */ export declare class ChunkedBuilder { protected _pieces: string[]; protected _chunks: string[]; protected readonly _chunkSize: number; protected _totalLength: number; constructor(options?: ChunkedBuilderOptions); /** * Add a piece to the builder */ push(piece: string): void; /** * Add multiple pieces */ pushAll(pieces: string[]): void; /** * Consolidate pieces into chunks. * Subclasses may override to guard against consolidation (e.g. during active snapshots). */ protected _consolidate(): void; /** * Get current cursor position (useful for tracking changes) */ get cursor(): number; /** * Get total piece/chunk count */ get length(): number; /** * Get total string length (character count) */ get stringLength(): number; /** * Check if empty */ get isEmpty(): boolean; /** * Clear all content */ clear(): void; /** * Build final string */ toString(): string; /** * Convert to Uint8Array (browser-compatible) */ toUint8Array(): Uint8Array; } /** * Snapshot for rollback support */ export interface BuilderSnapshot { piecesLength: number; chunksLength: number; totalLength: number; } /** * Chunked builder with rollback/commit support * Browser-compatible version */ export declare class TransactionalChunkedBuilder extends ChunkedBuilder { private _snapshots; /** * Skip consolidation while snapshots are active. * Consolidation joins pieces into a chunk and clears the pieces array, * which makes it impossible to rollback to a previous pieces position. */ protected _consolidate(): void; /** * Create a rollback point */ snapshot(): BuilderSnapshot; /** * Commit the current snapshot (remove rollback point) */ commit(): void; /** * Rollback to the last snapshot */ rollback(): void; /** * Check if there are active snapshots */ get hasSnapshots(): boolean; }