/** All the states the tokenizer can be in. */ declare const enum State { Text = 1, BeforeTagName = 2, InTagName = 3, InSelfClosingTag = 4, BeforeClosingTagName = 5, InClosingTagName = 6, AfterClosingTagName = 7, BeforeAttributeName = 8, InAttributeName = 9, AfterAttributeName = 10, BeforeAttributeValue = 11, InAttributeValueDq = 12, InAttributeValueSq = 13, InAttributeValueNq = 14, BeforeDeclaration = 15, InDeclaration = 16, InProcessingInstruction = 17, BeforeComment = 18, CDATASequence = 19, InSpecialComment = 20, InCommentLike = 21, BeforeSpecialS = 22, SpecialStartSequence = 23, InSpecialTag = 24, BeforeEntity = 25, BeforeNumericEntity = 26, InNamedEntity = 27, InNumericEntity = 28, InHexEntity = 29 } export interface Callbacks { onattribdata(value: string): void; onattribend(quote: string | undefined | null): void; onattribname(name: string): void; oncdata(data: string): void; onclosetag(name: string): void; oncomment(data: string): void; ondeclaration(content: string): void; onend(): void; onerror(error: Error, state?: State): void; onopentagend(): void; onopentagname(name: string): void; onprocessinginstruction(instruction: string): void; onselfclosingtag(): void; ontext(value: string): void; } export default class Tokenizer { private readonly cbs; /** The current state the tokenizer is in. */ private _state; /** The read buffer. */ private buffer; /** The beginning of the section that is currently being read. */ sectionStart: number; /** The index within the buffer that we are currently looking at. */ private _index; /** * Data that has already been processed will be removed from the buffer occasionally. * `_bufferOffset` keeps track of how many characters have been removed, to make sure position information is accurate. */ private bufferOffset; /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */ private baseState; /** For special parsing behavior inside of script and style tags. */ private isSpecial; /** Indicates whether the tokenizer has been paused. */ private running; /** Indicates whether the tokenizer has finished running / `.end` has been called. */ private ended; private readonly xmlMode; private readonly decodeEntities; private readonly entityTrie; constructor({ xmlMode, decodeEntities, }: { xmlMode?: boolean; decodeEntities?: boolean; }, cbs: Callbacks); reset(): void; write(chunk: string): void; end(chunk?: string): void; pause(): void; resume(): void; /** * The start of the current section. */ getAbsoluteSectionStart(): number; /** * The current index within all of the written data. */ getAbsoluteIndex(): number; private stateText; private currentSequence; private sequenceIndex; private stateSpecialStartSequence; /** Look for an end tag. For