import { ITokenizer, ITokenizerOptions } from "./i-tokenizer"; import { ITokenizerConsumer } from "./i-tokenizer-consumer"; /** * A Tokenizer for the HTML Parser */ export declare class Tokenizer implements ITokenizer { private readonly consumer; /** * The max length of legacy entities * @type {number} */ private static readonly MAX_LENGTH_OF_LEGACY_ENTITIES; /** * The min length of legacy entities * @type {number} */ private static readonly MIN_LENGTH_OF_LEGACY_ENTITIES; /** * The beginning state * @type {number} * @private */ private state; /** * The amount of open brackets inside a current expression * @type {number} */ private expressionBracketsDepth; /** * Holds true if we're currently inside an expression * @type {boolean} */ private insideExpression; /** * Holds true if we've seen an Expression dollar sign * @type {boolean} */ private seenExpressionDollarSign; /** * The beginning index * @type {number} * @private */ private index; /** * The beginning string buffer * @type {string} * @private */ private buffer; /** * The start index of a section * @type {number} * @private */ private sectionStart; /** * The buffer offset * @type {number} * @private */ private bufferOffset; /** * The base state * @type {number} * @private */ private baseState; /** * The current special character * @type {number} * @private */ private special; /** * Whether or not the Tokenizer is running * @type {boolean} * @private */ private running; /** * Whether or not the tokenizer has ended * @type {boolean} * @private */ private ended; /** * Whether or not the Tokenizer runs in XMLMode * @type {boolean} * @private */ private readonly xmlMode; /** * Whether or not the Tokenizer should decode entities * @type {boolean} * @private */ private readonly decodeEntities; /** * Invoked when before a CDATA * @type {(c: string) => void} * @private */ private readonly stateBeforeCdata1; /** * Invoked when before a CDATA * @type {(c: string) => void} * @private */ private readonly stateBeforeCdata2; /** * Invoked when before a CDATA * @type {(c: string) => void} * @private */ private readonly stateBeforeCdata3; /** * Invoked when before a CDATA * @type {(c: string) => void} * @private */ private readonly stateBeforeCdata4; /** * Invoked when before a CDATA * @type {(c: string) => void} * @private */ private readonly stateBeforeCdata5; /** * Invoked after CDATA * @type {(c: string) => void} * @private */ private readonly stateAfterCdata1; /** * Invoked before a script * @type {(c: string) => void} * @private */ private readonly stateBeforeScript1; /** * Invoked before a script * @type {(c: string) => void} * @private */ private readonly stateBeforeScript2; /** * Invoked before a script * @type {(c: string) => void} * @private */ private readonly stateBeforeScript3; /** * Invoked before a script * @type {(c: string) => void} * @private */ private readonly stateBeforeScript4; /** * Invoked after a script * @type {(c: string) => void} * @private */ private readonly _stateAfterScript1; /** * Invoked after a script * @type {(c: string) => void} * @private */ private readonly _stateAfterScript2; /** * Invoked after a script * @type {(c: string) => void} * @private */ private readonly _stateAfterScript3; /** * Invoked after a script * @type {(c: string) => void} * @private */ private readonly _stateAfterScript4; /** * Invoked before a style * @type {(c: string) => void} * @private */ private readonly _stateBeforeStyle1; /** * Invoked before a style * @type {(c: string) => void} * @private */ private readonly _stateBeforeStyle2; /** * Invoked before a style * @type {(c: string) => void} * @private */ private readonly _stateBeforeStyle3; /** * Invoked after a style * @type {(c: string) => void} * @private */ private readonly _stateAfterStyle1; /** * Invoked after a style * @type {(c: string) => void} * @private */ private readonly _stateAfterStyle2; /** * Invoked after a style * @type {(c: string) => void} * @private */ private readonly _stateAfterStyle3; /** * Invoked before an entity * @type {(c: string) => void} * @private */ private readonly _stateBeforeEntity; /** * Invoked before a numeric entity * @type {(c: string) => void} * @private */ private readonly _stateBeforeNumericEntity; constructor(options: ITokenizerOptions, consumer: ITokenizerConsumer); /** * Writes a chunk to the buffer * @param {string} chunk */ write(chunk: string): void; /** * Pauses the parser */ pause(): void; /** * Resumes the parser */ resume(): void; /** * Invoked with the end chunk */ end(chunk: string): void; /** * Resets the Tokenizer */ reset(): void; /** * Gets the absolute index * @returns {number} */ getAbsoluteIndex(): number; /** * Starts parsing * @private */ private _parse; /** * Invoked when inside some text * @param {string} char * @private */ private _stateText; /** * Invoked when before a tag name * @param {string} char * @private */ private _stateBeforeTagName; /** * Invoked when inside a tag name * @param {string} char * @private */ private _stateInTagName; /** * Invoked when before a closing tag name * @param {string} char * @private */ private _stateBeforeCloseingTagName; /** * Invoked when inside a closing tagname * @param {string} char */ private _stateInCloseingTagName; /** * Invoked when inside a closing tag name * @param {string} char * @private */ private _stateAfterCloseingTagName; /** * Invoked when before an attribute name * @param {string} char * @private */ private _stateBeforeAttributeName; /** * Invoked when in a self-closing tag * @param {string} char * @private */ private _stateInSelfClosingTag; /** * Invoked when inside an attribute name * @param {string} char * @private */ private _stateInAttributeName; /** * Invoked after an attribute name * @param {string} char * @private */ private _stateAfterAttributeName; /** * Invoked before the value of an attribute * @param {string} char * @private */ private _stateBeforeAttributeValue; /** * Invoked when at double quotes of an attribute value * @param {string} char * @private */ private _stateInAttributeValueDoubleQuotes; /** * Invoked when at single quotes of an attribute value * @param {string} char * @private */ private _stateInAttributeValueSingleQuotes; /** * Invoked when at quotes of an attribute value * @param {string} char * @param {string} quoteChar * @private */ private _stateInAttributeValueQuotes; /** * Invoked when at an attribute value and there are no quotes around it * @param {string} char * @private */ private _stateInAttributeValueNoQuotes; /** * Invoked before a declaration * @param {string} char * @private */ private _stateBeforeDeclaration; /** * Invoked when inside a declaration * @param {string} char * @private */ private _stateInDeclaration; /** * Invoked when in a processing instruction * @param {string} char * @private */ private _stateInProcessingInstruction; /** * Invoked before a comment * @param {string} char * @private */ private _stateBeforeComment; /** * Invoked when inside of a comment * @param {string} char * @private */ private _stateInComment; /** * Invoked after a comment * @param {string} char * @private */ private _stateAfterComment1; /** * Invoked after a comment * @param {string} char * @private */ private _stateAfterComment2; /** * Invoked when before a CDATA * @param {string} char * @private */ private _stateBeforeCdata6; /** * Invoked when inside CDATA * @param {string} char * @private */ private _stateInCdata; /** * Invoked after CDATA * @param {string} char * @private */ private _stateAfterCdata2; /** * Invoked before a special character * @param {string} char * @private */ private _stateBeforeSpecial; /** * Invoked before a special character ends * @param {string} c * @private */ private _stateBeforeSpecialEnd; /** * Invoked before a script * @param {string} char * @private */ private _stateBeforeScript5; /** * Invoked after a script * @param {string} char * @private */ private _stateAfterScript5; /** * Invoked before a style * @param {string} char * @private */ private _stateBeforeStyle4; /** * Invoked after a style * @param {string} char * @private */ private _stateAfterStyle4; /** * Parses a Named Entity * @private */ private _parseNamedEntityStrict; /** * Parses a Legacy Entity * @private */ private _parseLegacyEntity; /** * Invoked when inside a NamedEntity * @param {string} char * @private */ private _stateInNamedEntity; /** * Decodes a numeric entity * @param {number} offset * @param {number} base * @private */ private _decodeNumericEntity; /** * Invoked when inside a NumericEntity * @param {string} char * @private */ private _stateInNumericEntity; /** * Invoked when inside a Hex entity * @param {string} char * @private */ private _stateInHexEntity; /** * Performs a cleanup * @private */ private _cleanup; /** * Finishes the parsing * @private */ private _finish; /** * Handles trailing data * @private */ private _handleTrailingData; /** * Gets the current section * @returns {string} * @private */ private _getSection; /** * Emits the given token * @param {string} name * @private */ private _emitToken; /** * Emits a partial value * @param {string} value * @private */ private _emitPartial; /** * Returns a function that can update the character state * @param {string} char * @param {number} SUCCESS * @returns {(c: string) => void} */ private characterState; /** * Returns a function that can update the state * @param {string} upper * @param {number} SUCCESS * @param {number} FAILURE * @returns {(c: string) => void} */ private ifElseState; /** * Returns a function that can consume a SpecialNameChar * @param {string} upper * @param {number} NEXT_STATE * @returns {(c: string) => void} */ private consumeSpecialNameChar; }