1 |
- {"ast":null,"code":"import htmlDecodeTree from \"./generated/decode-data-html.js\";\nimport xmlDecodeTree from \"./generated/decode-data-xml.js\";\nimport decodeCodePoint, { replaceCodePoint, fromCodePoint } from \"./decode_codepoint.js\";\n// Re-export for use by eg. htmlparser2\nexport { htmlDecodeTree, xmlDecodeTree, decodeCodePoint };\nexport { replaceCodePoint, fromCodePoint } from \"./decode_codepoint.js\";\nvar CharCodes;\n(function (CharCodes) {\n CharCodes[CharCodes[\"NUM\"] = 35] = \"NUM\";\n CharCodes[CharCodes[\"SEMI\"] = 59] = \"SEMI\";\n CharCodes[CharCodes[\"EQUALS\"] = 61] = \"EQUALS\";\n CharCodes[CharCodes[\"ZERO\"] = 48] = \"ZERO\";\n CharCodes[CharCodes[\"NINE\"] = 57] = \"NINE\";\n CharCodes[CharCodes[\"LOWER_A\"] = 97] = \"LOWER_A\";\n CharCodes[CharCodes[\"LOWER_F\"] = 102] = \"LOWER_F\";\n CharCodes[CharCodes[\"LOWER_X\"] = 120] = \"LOWER_X\";\n CharCodes[CharCodes[\"LOWER_Z\"] = 122] = \"LOWER_Z\";\n CharCodes[CharCodes[\"UPPER_A\"] = 65] = \"UPPER_A\";\n CharCodes[CharCodes[\"UPPER_F\"] = 70] = \"UPPER_F\";\n CharCodes[CharCodes[\"UPPER_Z\"] = 90] = \"UPPER_Z\";\n})(CharCodes || (CharCodes = {}));\n/** Bit that needs to be set to convert an upper case ASCII character to lower case */\nconst TO_LOWER_BIT = 0b100000;\nexport var BinTrieFlags;\n(function (BinTrieFlags) {\n BinTrieFlags[BinTrieFlags[\"VALUE_LENGTH\"] = 49152] = \"VALUE_LENGTH\";\n BinTrieFlags[BinTrieFlags[\"BRANCH_LENGTH\"] = 16256] = \"BRANCH_LENGTH\";\n BinTrieFlags[BinTrieFlags[\"JUMP_TABLE\"] = 127] = \"JUMP_TABLE\";\n})(BinTrieFlags || (BinTrieFlags = {}));\nfunction isNumber(code) {\n return code >= CharCodes.ZERO && code <= CharCodes.NINE;\n}\nfunction isHexadecimalCharacter(code) {\n return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F;\n}\nfunction isAsciiAlphaNumeric(code) {\n return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber(code);\n}\n/**\n * Checks if the given character is a valid end character for an entity in an attribute.\n *\n * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.\n * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state\n */\nfunction isEntityInAttributeInvalidEnd(code) {\n return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);\n}\nvar EntityDecoderState;\n(function (EntityDecoderState) {\n EntityDecoderState[EntityDecoderState[\"EntityStart\"] = 0] = \"EntityStart\";\n EntityDecoderState[EntityDecoderState[\"NumericStart\"] = 1] = \"NumericStart\";\n EntityDecoderState[EntityDecoderState[\"NumericDecimal\"] = 2] = \"NumericDecimal\";\n EntityDecoderState[EntityDecoderState[\"NumericHex\"] = 3] = \"NumericHex\";\n EntityDecoderState[EntityDecoderState[\"NamedEntity\"] = 4] = \"NamedEntity\";\n})(EntityDecoderState || (EntityDecoderState = {}));\nexport var DecodingMode;\n(function (DecodingMode) {\n /** Entities in text nodes that can end with any character. */\n DecodingMode[DecodingMode[\"Legacy\"] = 0] = \"Legacy\";\n /** Only allow entities terminated with a semicolon. */\n DecodingMode[DecodingMode[\"Strict\"] = 1] = \"Strict\";\n /** Entities in attributes have limitations on ending characters. */\n DecodingMode[DecodingMode[\"Attribute\"] = 2] = \"Attribute\";\n})(DecodingMode || (DecodingMode = {}));\n/**\n * Token decoder with support of writing partial entities.\n */\nexport class EntityDecoder {\n constructor( /** The tree used to decode entities. */\n decodeTree,\n /**\n * The function that is called when a codepoint is decoded.\n *\n * For multi-byte named entities, this will be called multiple times,\n * with the second codepoint, and the same `consumed` value.\n *\n * @param codepoint The decoded codepoint.\n * @param consumed The number of bytes consumed by the decoder.\n */\n emitCodePoint, /** An object that is used to produce errors. */\n errors) {\n this.decodeTree = decodeTree;\n this.emitCodePoint = emitCodePoint;\n this.errors = errors;\n /** The current state of the decoder. */\n this.state = EntityDecoderState.EntityStart;\n /** Characters that were consumed while parsing an entity. */\n this.consumed = 1;\n /**\n * The result of the entity.\n *\n * Either the result index of a numeric entity, or the codepoint of a\n * numeric entity.\n */\n this.result = 0;\n /** The current index in the decode tree. */\n this.treeIndex = 0;\n /** The number of characters that were consumed in excess. */\n this.excess = 1;\n /** The mode in which the decoder is operating. */\n this.decodeMode = DecodingMode.Strict;\n }\n /** Resets the instance to make it reusable. */\n startEntity(decodeMode) {\n this.decodeMode = decodeMode;\n this.state = EntityDecoderState.EntityStart;\n this.result = 0;\n this.treeIndex = 0;\n this.excess = 1;\n this.consumed = 1;\n }\n /**\n * Write an entity to the decoder. This can be called multiple times with partial entities.\n * If the entity is incomplete, the decoder will return -1.\n *\n * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the\n * entity is incomplete, and resume when the next string is written.\n *\n * @param string The string containing the entity (or a continuation of the entity).\n * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n write(str, offset) {\n switch (this.state) {\n case EntityDecoderState.EntityStart:\n {\n if (str.charCodeAt(offset) === CharCodes.NUM) {\n this.state = EntityDecoderState.NumericStart;\n this.consumed += 1;\n return this.stateNumericStart(str, offset + 1);\n }\n this.state = EntityDecoderState.NamedEntity;\n return this.stateNamedEntity(str, offset);\n }\n case EntityDecoderState.NumericStart:\n {\n return this.stateNumericStart(str, offset);\n }\n case EntityDecoderState.NumericDecimal:\n {\n return this.stateNumericDecimal(str, offset);\n }\n case EntityDecoderState.NumericHex:\n {\n return this.stateNumericHex(str, offset);\n }\n case EntityDecoderState.NamedEntity:\n {\n return this.stateNamedEntity(str, offset);\n }\n }\n }\n /**\n * Switches between the numeric decimal and hexadecimal states.\n *\n * Equivalent to the `Numeric character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericStart(str, offset) {\n if (offset >= str.length) {\n return -1;\n }\n if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {\n this.state = EntityDecoderState.NumericHex;\n this.consumed += 1;\n return this.stateNumericHex(str, offset + 1);\n }\n this.state = EntityDecoderState.NumericDecimal;\n return this.stateNumericDecimal(str, offset);\n }\n addToNumericResult(str, start, end, base) {\n if (start !== end) {\n const digitCount = end - start;\n this.result = this.result * Math.pow(base, digitCount) + parseInt(str.substr(start, digitCount), base);\n this.consumed += digitCount;\n }\n }\n /**\n * Parses a hexadecimal numeric entity.\n *\n * Equivalent to the `Hexademical character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericHex(str, offset) {\n const startIdx = offset;\n while (offset < str.length) {\n const char = str.charCodeAt(offset);\n if (isNumber(char) || isHexadecimalCharacter(char)) {\n offset += 1;\n } else {\n this.addToNumericResult(str, startIdx, offset, 16);\n return this.emitNumericEntity(char, 3);\n }\n }\n this.addToNumericResult(str, startIdx, offset, 16);\n return -1;\n }\n /**\n * Parses a decimal numeric entity.\n *\n * Equivalent to the `Decimal character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericDecimal(str, offset) {\n const startIdx = offset;\n while (offset < str.length) {\n const char = str.charCodeAt(offset);\n if (isNumber(char)) {\n offset += 1;\n } else {\n this.addToNumericResult(str, startIdx, offset, 10);\n return this.emitNumericEntity(char, 2);\n }\n }\n this.addToNumericResult(str, startIdx, offset, 10);\n return -1;\n }\n /**\n * Validate and emit a numeric entity.\n *\n * Implements the logic from the `Hexademical character reference start\n * state` and `Numeric character reference end state` in the HTML spec.\n *\n * @param lastCp The last code point of the entity. Used to see if the\n * entity was terminated with a semicolon.\n * @param expectedLength The minimum number of characters that should be\n * consumed. Used to validate that at least one digit\n * was consumed.\n * @returns The number of characters that were consumed.\n */\n emitNumericEntity(lastCp, expectedLength) {\n var _a;\n // Ensure we consumed at least one digit.\n if (this.consumed <= expectedLength) {\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);\n return 0;\n }\n // Figure out if this is a legit end of the entity\n if (lastCp === CharCodes.SEMI) {\n this.consumed += 1;\n } else if (this.decodeMode === DecodingMode.Strict) {\n return 0;\n }\n this.emitCodePoint(replaceCodePoint(this.result), this.consumed);\n if (this.errors) {\n if (lastCp !== CharCodes.SEMI) {\n this.errors.missingSemicolonAfterCharacterReference();\n }\n this.errors.validateNumericCharacterReference(this.result);\n }\n return this.consumed;\n }\n /**\n * Parses a named entity.\n *\n * Equivalent to the `Named character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNamedEntity(str, offset) {\n const {\n decodeTree\n } = this;\n let current = decodeTree[this.treeIndex];\n // The mask is the number of bytes of the value, including the current byte.\n let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;\n for (; offset < str.length; offset++, this.excess++) {\n const char = str.charCodeAt(offset);\n this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);\n if (this.treeIndex < 0) {\n return this.result === 0 ||\n // If we are parsing an attribute\n this.decodeMode === DecodingMode.Attribute && (\n // We shouldn't have consumed any characters after the entity,\n valueLength === 0 ||\n // And there should be no invalid characters.\n isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();\n }\n current = decodeTree[this.treeIndex];\n valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;\n // If the branch is a value, store it and continue\n if (valueLength !== 0) {\n // If the entity is terminated by a semicolon, we are done.\n if (char === CharCodes.SEMI) {\n return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);\n }\n // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.\n if (this.decodeMode !== DecodingMode.Strict) {\n this.result = this.treeIndex;\n this.consumed += this.excess;\n this.excess = 0;\n }\n }\n }\n return -1;\n }\n /**\n * Emit a named entity that was not terminated with a semicolon.\n *\n * @returns The number of characters consumed.\n */\n emitNotTerminatedNamedEntity() {\n var _a;\n const {\n result,\n decodeTree\n } = this;\n const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;\n this.emitNamedEntityData(result, valueLength, this.consumed);\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();\n return this.consumed;\n }\n /**\n * Emit a named entity.\n *\n * @param result The index of the entity in the decode tree.\n * @param valueLength The number of bytes in the entity.\n * @param consumed The number of characters consumed.\n *\n * @returns The number of characters consumed.\n */\n emitNamedEntityData(result, valueLength, consumed) {\n const {\n decodeTree\n } = this;\n this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH : decodeTree[result + 1], consumed);\n if (valueLength === 3) {\n // For multi-byte values, we need to emit the second byte.\n this.emitCodePoint(decodeTree[result + 2], consumed);\n }\n return consumed;\n }\n /**\n * Signal to the parser that the end of the input was reached.\n *\n * Remaining data will be emitted and relevant errors will be produced.\n *\n * @returns The number of characters consumed.\n */\n end() {\n var _a;\n switch (this.state) {\n case EntityDecoderState.NamedEntity:\n {\n // Emit a named entity if we have one.\n return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;\n }\n // Otherwise, emit a numeric entity if we have one.\n case EntityDecoderState.NumericDecimal:\n {\n return this.emitNumericEntity(0, 2);\n }\n case EntityDecoderState.NumericHex:\n {\n return this.emitNumericEntity(0, 3);\n }\n case EntityDecoderState.NumericStart:\n {\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);\n return 0;\n }\n case EntityDecoderState.EntityStart:\n {\n // Return 0 if we have no entity.\n return 0;\n }\n }\n }\n}\n/**\n * Creates a function that decodes entities in a string.\n *\n * @param decodeTree The decode tree.\n * @returns A function that decodes entities in a string.\n */\nfunction getDecoder(decodeTree) {\n let ret = \"\";\n const decoder = new EntityDecoder(decodeTree, str => ret += fromCodePoint(str));\n return function decodeWithTrie(str, decodeMode) {\n let lastIndex = 0;\n let offset = 0;\n while ((offset = str.indexOf(\"&\", offset)) >= 0) {\n ret += str.slice(lastIndex, offset);\n decoder.startEntity(decodeMode);\n const len = decoder.write(str,\n // Skip the \"&\"\n offset + 1);\n if (len < 0) {\n lastIndex = offset + decoder.end();\n break;\n }\n lastIndex = offset + len;\n // If `len` is 0, skip the current `&` and continue.\n offset = len === 0 ? lastIndex + 1 : lastIndex;\n }\n const result = ret + str.slice(lastIndex);\n // Make sure we don't keep a reference to the final string.\n ret = \"\";\n return result;\n };\n}\n/**\n * Determines the branch of the current node that is taken given the current\n * character. This function is used to traverse the trie.\n *\n * @param decodeTree The trie.\n * @param current The current node.\n * @param nodeIdx The index right after the current node and its value.\n * @param char The current character.\n * @returns The index of the next node, or -1 if no branch is taken.\n */\nexport function determineBranch(decodeTree, current, nodeIdx, char) {\n const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;\n const jumpOffset = current & BinTrieFlags.JUMP_TABLE;\n // Case 1: Single branch encoded in jump offset\n if (branchCount === 0) {\n return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;\n }\n // Case 2: Multiple branches encoded in jump table\n if (jumpOffset) {\n const value = char - jumpOffset;\n return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIdx + value] - 1;\n }\n // Case 3: Multiple branches encoded in dictionary\n // Binary search for the character.\n let lo = nodeIdx;\n let hi = lo + branchCount - 1;\n while (lo <= hi) {\n const mid = lo + hi >>> 1;\n const midVal = decodeTree[mid];\n if (midVal < char) {\n lo = mid + 1;\n } else if (midVal > char) {\n hi = mid - 1;\n } else {\n return decodeTree[mid + branchCount];\n }\n }\n return -1;\n}\nconst htmlDecoder = getDecoder(htmlDecodeTree);\nconst xmlDecoder = getDecoder(xmlDecodeTree);\n/**\n * Decodes an HTML string.\n *\n * @param str The string to decode.\n * @param mode The decoding mode.\n * @returns The decoded string.\n */\nexport function decodeHTML(str, mode = DecodingMode.Legacy) {\n return htmlDecoder(str, mode);\n}\n/**\n * Decodes an HTML string in an attribute.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeHTMLAttribute(str) {\n return htmlDecoder(str, DecodingMode.Attribute);\n}\n/**\n * Decodes an HTML string, requiring all entities to be terminated by a semicolon.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeHTMLStrict(str) {\n return htmlDecoder(str, DecodingMode.Strict);\n}\n/**\n * Decodes an XML string, requiring all entities to be terminated by a semicolon.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeXML(str) {\n return xmlDecoder(str, DecodingMode.Strict);\n}","map":{"version":3,"names":["htmlDecodeTree","xmlDecodeTree","decodeCodePoint","replaceCodePoint","fromCodePoint","CharCodes","TO_LOWER_BIT","BinTrieFlags","isNumber","code","ZERO","NINE","isHexadecimalCharacter","UPPER_A","UPPER_F","LOWER_A","LOWER_F","isAsciiAlphaNumeric","UPPER_Z","LOWER_Z","isEntityInAttributeInvalidEnd","EQUALS","EntityDecoderState","DecodingMode","EntityDecoder","constructor","decodeTree","emitCodePoint","errors","state","EntityStart","consumed","result","treeIndex","excess","decodeMode","Strict","startEntity","write","str","offset","charCodeAt","NUM","NumericStart","stateNumericStart","NamedEntity","stateNamedEntity","NumericDecimal","stateNumericDecimal","NumericHex","stateNumericHex","length","LOWER_X","addToNumericResult","start","end","base","digitCount","Math","pow","parseInt","substr","startIdx","char","emitNumericEntity","lastCp","expectedLength","_a","absenceOfDigitsInNumericCharacterReference","SEMI","missingSemicolonAfterCharacterReference","validateNumericCharacterReference","current","valueLength","VALUE_LENGTH","determineBranch","max","Attribute","emitNotTerminatedNamedEntity","emitNamedEntityData","getDecoder","ret","decoder","decodeWithTrie","lastIndex","indexOf","slice","len","nodeIdx","branchCount","BRANCH_LENGTH","jumpOffset","JUMP_TABLE","value","lo","hi","mid","midVal","htmlDecoder","xmlDecoder","decodeHTML","mode","Legacy","decodeHTMLAttribute","decodeHTMLStrict","decodeXML"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/entities/lib/esm/decode.js"],"sourcesContent":["import htmlDecodeTree from \"./generated/decode-data-html.js\";\nimport xmlDecodeTree from \"./generated/decode-data-xml.js\";\nimport decodeCodePoint, { replaceCodePoint, fromCodePoint, } from \"./decode_codepoint.js\";\n// Re-export for use by eg. htmlparser2\nexport { htmlDecodeTree, xmlDecodeTree, decodeCodePoint };\nexport { replaceCodePoint, fromCodePoint } from \"./decode_codepoint.js\";\nvar CharCodes;\n(function (CharCodes) {\n CharCodes[CharCodes[\"NUM\"] = 35] = \"NUM\";\n CharCodes[CharCodes[\"SEMI\"] = 59] = \"SEMI\";\n CharCodes[CharCodes[\"EQUALS\"] = 61] = \"EQUALS\";\n CharCodes[CharCodes[\"ZERO\"] = 48] = \"ZERO\";\n CharCodes[CharCodes[\"NINE\"] = 57] = \"NINE\";\n CharCodes[CharCodes[\"LOWER_A\"] = 97] = \"LOWER_A\";\n CharCodes[CharCodes[\"LOWER_F\"] = 102] = \"LOWER_F\";\n CharCodes[CharCodes[\"LOWER_X\"] = 120] = \"LOWER_X\";\n CharCodes[CharCodes[\"LOWER_Z\"] = 122] = \"LOWER_Z\";\n CharCodes[CharCodes[\"UPPER_A\"] = 65] = \"UPPER_A\";\n CharCodes[CharCodes[\"UPPER_F\"] = 70] = \"UPPER_F\";\n CharCodes[CharCodes[\"UPPER_Z\"] = 90] = \"UPPER_Z\";\n})(CharCodes || (CharCodes = {}));\n/** Bit that needs to be set to convert an upper case ASCII character to lower case */\nconst TO_LOWER_BIT = 0b100000;\nexport var BinTrieFlags;\n(function (BinTrieFlags) {\n BinTrieFlags[BinTrieFlags[\"VALUE_LENGTH\"] = 49152] = \"VALUE_LENGTH\";\n BinTrieFlags[BinTrieFlags[\"BRANCH_LENGTH\"] = 16256] = \"BRANCH_LENGTH\";\n BinTrieFlags[BinTrieFlags[\"JUMP_TABLE\"] = 127] = \"JUMP_TABLE\";\n})(BinTrieFlags || (BinTrieFlags = {}));\nfunction isNumber(code) {\n return code >= CharCodes.ZERO && code <= CharCodes.NINE;\n}\nfunction isHexadecimalCharacter(code) {\n return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||\n (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));\n}\nfunction isAsciiAlphaNumeric(code) {\n return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||\n (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||\n isNumber(code));\n}\n/**\n * Checks if the given character is a valid end character for an entity in an attribute.\n *\n * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.\n * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state\n */\nfunction isEntityInAttributeInvalidEnd(code) {\n return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);\n}\nvar EntityDecoderState;\n(function (EntityDecoderState) {\n EntityDecoderState[EntityDecoderState[\"EntityStart\"] = 0] = \"EntityStart\";\n EntityDecoderState[EntityDecoderState[\"NumericStart\"] = 1] = \"NumericStart\";\n EntityDecoderState[EntityDecoderState[\"NumericDecimal\"] = 2] = \"NumericDecimal\";\n EntityDecoderState[EntityDecoderState[\"NumericHex\"] = 3] = \"NumericHex\";\n EntityDecoderState[EntityDecoderState[\"NamedEntity\"] = 4] = \"NamedEntity\";\n})(EntityDecoderState || (EntityDecoderState = {}));\nexport var DecodingMode;\n(function (DecodingMode) {\n /** Entities in text nodes that can end with any character. */\n DecodingMode[DecodingMode[\"Legacy\"] = 0] = \"Legacy\";\n /** Only allow entities terminated with a semicolon. */\n DecodingMode[DecodingMode[\"Strict\"] = 1] = \"Strict\";\n /** Entities in attributes have limitations on ending characters. */\n DecodingMode[DecodingMode[\"Attribute\"] = 2] = \"Attribute\";\n})(DecodingMode || (DecodingMode = {}));\n/**\n * Token decoder with support of writing partial entities.\n */\nexport class EntityDecoder {\n constructor(\n /** The tree used to decode entities. */\n decodeTree, \n /**\n * The function that is called when a codepoint is decoded.\n *\n * For multi-byte named entities, this will be called multiple times,\n * with the second codepoint, and the same `consumed` value.\n *\n * @param codepoint The decoded codepoint.\n * @param consumed The number of bytes consumed by the decoder.\n */\n emitCodePoint, \n /** An object that is used to produce errors. */\n errors) {\n this.decodeTree = decodeTree;\n this.emitCodePoint = emitCodePoint;\n this.errors = errors;\n /** The current state of the decoder. */\n this.state = EntityDecoderState.EntityStart;\n /** Characters that were consumed while parsing an entity. */\n this.consumed = 1;\n /**\n * The result of the entity.\n *\n * Either the result index of a numeric entity, or the codepoint of a\n * numeric entity.\n */\n this.result = 0;\n /** The current index in the decode tree. */\n this.treeIndex = 0;\n /** The number of characters that were consumed in excess. */\n this.excess = 1;\n /** The mode in which the decoder is operating. */\n this.decodeMode = DecodingMode.Strict;\n }\n /** Resets the instance to make it reusable. */\n startEntity(decodeMode) {\n this.decodeMode = decodeMode;\n this.state = EntityDecoderState.EntityStart;\n this.result = 0;\n this.treeIndex = 0;\n this.excess = 1;\n this.consumed = 1;\n }\n /**\n * Write an entity to the decoder. This can be called multiple times with partial entities.\n * If the entity is incomplete, the decoder will return -1.\n *\n * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the\n * entity is incomplete, and resume when the next string is written.\n *\n * @param string The string containing the entity (or a continuation of the entity).\n * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n write(str, offset) {\n switch (this.state) {\n case EntityDecoderState.EntityStart: {\n if (str.charCodeAt(offset) === CharCodes.NUM) {\n this.state = EntityDecoderState.NumericStart;\n this.consumed += 1;\n return this.stateNumericStart(str, offset + 1);\n }\n this.state = EntityDecoderState.NamedEntity;\n return this.stateNamedEntity(str, offset);\n }\n case EntityDecoderState.NumericStart: {\n return this.stateNumericStart(str, offset);\n }\n case EntityDecoderState.NumericDecimal: {\n return this.stateNumericDecimal(str, offset);\n }\n case EntityDecoderState.NumericHex: {\n return this.stateNumericHex(str, offset);\n }\n case EntityDecoderState.NamedEntity: {\n return this.stateNamedEntity(str, offset);\n }\n }\n }\n /**\n * Switches between the numeric decimal and hexadecimal states.\n *\n * Equivalent to the `Numeric character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericStart(str, offset) {\n if (offset >= str.length) {\n return -1;\n }\n if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {\n this.state = EntityDecoderState.NumericHex;\n this.consumed += 1;\n return this.stateNumericHex(str, offset + 1);\n }\n this.state = EntityDecoderState.NumericDecimal;\n return this.stateNumericDecimal(str, offset);\n }\n addToNumericResult(str, start, end, base) {\n if (start !== end) {\n const digitCount = end - start;\n this.result =\n this.result * Math.pow(base, digitCount) +\n parseInt(str.substr(start, digitCount), base);\n this.consumed += digitCount;\n }\n }\n /**\n * Parses a hexadecimal numeric entity.\n *\n * Equivalent to the `Hexademical character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericHex(str, offset) {\n const startIdx = offset;\n while (offset < str.length) {\n const char = str.charCodeAt(offset);\n if (isNumber(char) || isHexadecimalCharacter(char)) {\n offset += 1;\n }\n else {\n this.addToNumericResult(str, startIdx, offset, 16);\n return this.emitNumericEntity(char, 3);\n }\n }\n this.addToNumericResult(str, startIdx, offset, 16);\n return -1;\n }\n /**\n * Parses a decimal numeric entity.\n *\n * Equivalent to the `Decimal character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericDecimal(str, offset) {\n const startIdx = offset;\n while (offset < str.length) {\n const char = str.charCodeAt(offset);\n if (isNumber(char)) {\n offset += 1;\n }\n else {\n this.addToNumericResult(str, startIdx, offset, 10);\n return this.emitNumericEntity(char, 2);\n }\n }\n this.addToNumericResult(str, startIdx, offset, 10);\n return -1;\n }\n /**\n * Validate and emit a numeric entity.\n *\n * Implements the logic from the `Hexademical character reference start\n * state` and `Numeric character reference end state` in the HTML spec.\n *\n * @param lastCp The last code point of the entity. Used to see if the\n * entity was terminated with a semicolon.\n * @param expectedLength The minimum number of characters that should be\n * consumed. Used to validate that at least one digit\n * was consumed.\n * @returns The number of characters that were consumed.\n */\n emitNumericEntity(lastCp, expectedLength) {\n var _a;\n // Ensure we consumed at least one digit.\n if (this.consumed <= expectedLength) {\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);\n return 0;\n }\n // Figure out if this is a legit end of the entity\n if (lastCp === CharCodes.SEMI) {\n this.consumed += 1;\n }\n else if (this.decodeMode === DecodingMode.Strict) {\n return 0;\n }\n this.emitCodePoint(replaceCodePoint(this.result), this.consumed);\n if (this.errors) {\n if (lastCp !== CharCodes.SEMI) {\n this.errors.missingSemicolonAfterCharacterReference();\n }\n this.errors.validateNumericCharacterReference(this.result);\n }\n return this.consumed;\n }\n /**\n * Parses a named entity.\n *\n * Equivalent to the `Named character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNamedEntity(str, offset) {\n const { decodeTree } = this;\n let current = decodeTree[this.treeIndex];\n // The mask is the number of bytes of the value, including the current byte.\n let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;\n for (; offset < str.length; offset++, this.excess++) {\n const char = str.charCodeAt(offset);\n this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);\n if (this.treeIndex < 0) {\n return this.result === 0 ||\n // If we are parsing an attribute\n (this.decodeMode === DecodingMode.Attribute &&\n // We shouldn't have consumed any characters after the entity,\n (valueLength === 0 ||\n // And there should be no invalid characters.\n isEntityInAttributeInvalidEnd(char)))\n ? 0\n : this.emitNotTerminatedNamedEntity();\n }\n current = decodeTree[this.treeIndex];\n valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;\n // If the branch is a value, store it and continue\n if (valueLength !== 0) {\n // If the entity is terminated by a semicolon, we are done.\n if (char === CharCodes.SEMI) {\n return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);\n }\n // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.\n if (this.decodeMode !== DecodingMode.Strict) {\n this.result = this.treeIndex;\n this.consumed += this.excess;\n this.excess = 0;\n }\n }\n }\n return -1;\n }\n /**\n * Emit a named entity that was not terminated with a semicolon.\n *\n * @returns The number of characters consumed.\n */\n emitNotTerminatedNamedEntity() {\n var _a;\n const { result, decodeTree } = this;\n const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;\n this.emitNamedEntityData(result, valueLength, this.consumed);\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();\n return this.consumed;\n }\n /**\n * Emit a named entity.\n *\n * @param result The index of the entity in the decode tree.\n * @param valueLength The number of bytes in the entity.\n * @param consumed The number of characters consumed.\n *\n * @returns The number of characters consumed.\n */\n emitNamedEntityData(result, valueLength, consumed) {\n const { decodeTree } = this;\n this.emitCodePoint(valueLength === 1\n ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH\n : decodeTree[result + 1], consumed);\n if (valueLength === 3) {\n // For multi-byte values, we need to emit the second byte.\n this.emitCodePoint(decodeTree[result + 2], consumed);\n }\n return consumed;\n }\n /**\n * Signal to the parser that the end of the input was reached.\n *\n * Remaining data will be emitted and relevant errors will be produced.\n *\n * @returns The number of characters consumed.\n */\n end() {\n var _a;\n switch (this.state) {\n case EntityDecoderState.NamedEntity: {\n // Emit a named entity if we have one.\n return this.result !== 0 &&\n (this.decodeMode !== DecodingMode.Attribute ||\n this.result === this.treeIndex)\n ? this.emitNotTerminatedNamedEntity()\n : 0;\n }\n // Otherwise, emit a numeric entity if we have one.\n case EntityDecoderState.NumericDecimal: {\n return this.emitNumericEntity(0, 2);\n }\n case EntityDecoderState.NumericHex: {\n return this.emitNumericEntity(0, 3);\n }\n case EntityDecoderState.NumericStart: {\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);\n return 0;\n }\n case EntityDecoderState.EntityStart: {\n // Return 0 if we have no entity.\n return 0;\n }\n }\n }\n}\n/**\n * Creates a function that decodes entities in a string.\n *\n * @param decodeTree The decode tree.\n * @returns A function that decodes entities in a string.\n */\nfunction getDecoder(decodeTree) {\n let ret = \"\";\n const decoder = new EntityDecoder(decodeTree, (str) => (ret += fromCodePoint(str)));\n return function decodeWithTrie(str, decodeMode) {\n let lastIndex = 0;\n let offset = 0;\n while ((offset = str.indexOf(\"&\", offset)) >= 0) {\n ret += str.slice(lastIndex, offset);\n decoder.startEntity(decodeMode);\n const len = decoder.write(str, \n // Skip the \"&\"\n offset + 1);\n if (len < 0) {\n lastIndex = offset + decoder.end();\n break;\n }\n lastIndex = offset + len;\n // If `len` is 0, skip the current `&` and continue.\n offset = len === 0 ? lastIndex + 1 : lastIndex;\n }\n const result = ret + str.slice(lastIndex);\n // Make sure we don't keep a reference to the final string.\n ret = \"\";\n return result;\n };\n}\n/**\n * Determines the branch of the current node that is taken given the current\n * character. This function is used to traverse the trie.\n *\n * @param decodeTree The trie.\n * @param current The current node.\n * @param nodeIdx The index right after the current node and its value.\n * @param char The current character.\n * @returns The index of the next node, or -1 if no branch is taken.\n */\nexport function determineBranch(decodeTree, current, nodeIdx, char) {\n const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;\n const jumpOffset = current & BinTrieFlags.JUMP_TABLE;\n // Case 1: Single branch encoded in jump offset\n if (branchCount === 0) {\n return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;\n }\n // Case 2: Multiple branches encoded in jump table\n if (jumpOffset) {\n const value = char - jumpOffset;\n return value < 0 || value >= branchCount\n ? -1\n : decodeTree[nodeIdx + value] - 1;\n }\n // Case 3: Multiple branches encoded in dictionary\n // Binary search for the character.\n let lo = nodeIdx;\n let hi = lo + branchCount - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >>> 1;\n const midVal = decodeTree[mid];\n if (midVal < char) {\n lo = mid + 1;\n }\n else if (midVal > char) {\n hi = mid - 1;\n }\n else {\n return decodeTree[mid + branchCount];\n }\n }\n return -1;\n}\nconst htmlDecoder = getDecoder(htmlDecodeTree);\nconst xmlDecoder = getDecoder(xmlDecodeTree);\n/**\n * Decodes an HTML string.\n *\n * @param str The string to decode.\n * @param mode The decoding mode.\n * @returns The decoded string.\n */\nexport function decodeHTML(str, mode = DecodingMode.Legacy) {\n return htmlDecoder(str, mode);\n}\n/**\n * Decodes an HTML string in an attribute.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeHTMLAttribute(str) {\n return htmlDecoder(str, DecodingMode.Attribute);\n}\n/**\n * Decodes an HTML string, requiring all entities to be terminated by a semicolon.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeHTMLStrict(str) {\n return htmlDecoder(str, DecodingMode.Strict);\n}\n/**\n * Decodes an XML string, requiring all entities to be terminated by a semicolon.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeXML(str) {\n return xmlDecoder(str, DecodingMode.Strict);\n}\n"],"mappings":"AAAA,OAAOA,cAAc,MAAM,iCA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IACb,MAAMC,GAAG,GAAIF,EAAE,GAAGC,EAAE,KAAM,CAAC;IAC3B,MAAME,MAAM,GAAGvE,UAAU,CAACsE,GAAG,CAAC;IAC9B,IAAIC,MAAM,GAAGlC,IAAI,EAAE;MACf+B,EAAE,GAAGE,GAAG,GAAG,CAAC;IAChB,CAAC,MACI,IAAIC,MAAM,GAAGlC,IAAI,EAAE;MACpBgC,EAAE,GAAGC,GAAG,GAAG,CAAC;IAChB,CAAC,MACI;MACD,OAAOtE,UAAU,CAACsE,GAAG,GAAGP,WAAW,CAAC;IACxC;EACJ;EACA,OAAO,CAAC,CAAC;AACb;AACA,MAAMS,WAAW,GAAGlB,UAAU,CAAChF,cAAc,CAAC;AAC9C,MAAMmG,UAAU,GAAGnB,UAAU,CAAC/E,aAAa,CAAC;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmG,UAAUA,CAAC7D,GAAG,EAAE8D,IAAI,GAAG9E,YAAY,CAAC+E,MAAM,EAAE;EACxD,OAAOJ,WAAW,CAAC3D,GAAG,EAAE8D,IAAI,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,mBAAmBA,CAAChE,GAAG,EAAE;EACrC,OAAO2D,WAAW,CAAC3D,GAAG,EAAEhB,YAAY,CAACsD,SAAS,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS2B,gBAAgBA,CAACjE,GAAG,EAAE;EAClC,OAAO2D,WAAW,CAAC3D,GAAG,EAAEhB,YAAY,CAACa,MAAM,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASqE,SAASA,CAAClE,GAAG,EAAE;EAC3B,OAAO4D,UAAU,CAAC5D,GAAG,EAAEhB,YAAY,CAACa,MAAM,CAAC;AAC/C","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|