From 7a52ddeba2a68388b544f529d2d92104420f77b0 Mon Sep 17 00:00:00 2001 From: Shipwreckt Date: Fri, 31 Oct 2025 20:02:14 +0000 Subject: Changed from static to 11ty! --- node_modules/htmlparser2/lib/FeedHandler.d.ts | 23 + node_modules/htmlparser2/lib/FeedHandler.d.ts.map | 1 + node_modules/htmlparser2/lib/FeedHandler.js | 68 ++ node_modules/htmlparser2/lib/Parser.d.ts | 180 +++++ node_modules/htmlparser2/lib/Parser.d.ts.map | 1 + node_modules/htmlparser2/lib/Parser.js | 424 +++++++++++ node_modules/htmlparser2/lib/Tokenizer.d.ts | 173 +++++ node_modules/htmlparser2/lib/Tokenizer.d.ts.map | 1 + node_modules/htmlparser2/lib/Tokenizer.js | 821 +++++++++++++++++++++ node_modules/htmlparser2/lib/WritableStream.d.ts | 16 + .../htmlparser2/lib/WritableStream.d.ts.map | 1 + node_modules/htmlparser2/lib/WritableStream.js | 53 ++ node_modules/htmlparser2/lib/index.d.ts | 39 + node_modules/htmlparser2/lib/index.d.ts.map | 1 + node_modules/htmlparser2/lib/index.js | 84 +++ 15 files changed, 1886 insertions(+) create mode 100644 node_modules/htmlparser2/lib/FeedHandler.d.ts create mode 100644 node_modules/htmlparser2/lib/FeedHandler.d.ts.map create mode 100644 node_modules/htmlparser2/lib/FeedHandler.js create mode 100644 node_modules/htmlparser2/lib/Parser.d.ts create mode 100644 node_modules/htmlparser2/lib/Parser.d.ts.map create mode 100644 node_modules/htmlparser2/lib/Parser.js create mode 100644 node_modules/htmlparser2/lib/Tokenizer.d.ts create mode 100644 node_modules/htmlparser2/lib/Tokenizer.d.ts.map create mode 100644 node_modules/htmlparser2/lib/Tokenizer.js create mode 100644 node_modules/htmlparser2/lib/WritableStream.d.ts create mode 100644 node_modules/htmlparser2/lib/WritableStream.d.ts.map create mode 100644 node_modules/htmlparser2/lib/WritableStream.js create mode 100644 node_modules/htmlparser2/lib/index.d.ts create mode 100644 node_modules/htmlparser2/lib/index.d.ts.map create mode 100644 node_modules/htmlparser2/lib/index.js (limited to 'node_modules/htmlparser2/lib') diff --git a/node_modules/htmlparser2/lib/FeedHandler.d.ts b/node_modules/htmlparser2/lib/FeedHandler.d.ts new file mode 100644 index 0000000..0491715 --- /dev/null +++ b/node_modules/htmlparser2/lib/FeedHandler.d.ts @@ -0,0 +1,23 @@ +import DomHandler, { DomHandlerOptions } from "domhandler"; +import { getFeed, Feed } from "domutils"; +import { ParserOptions } from "./Parser"; +export { getFeed }; +/** @deprecated Handler is no longer necessary; use `getFeed` or `parseFeed` instead. */ +export declare class FeedHandler extends DomHandler { + feed?: Feed; + /** + * + * @param callback + * @param options + */ + constructor(callback?: ((error: Error | null) => void) | DomHandlerOptions, options?: DomHandlerOptions); + onend(): void; +} +/** + * Parse a feed. + * + * @param feed The feed that should be parsed, as a string. + * @param options Optionally, options for parsing. When using this, you should set `xmlMode` to `true`. + */ +export declare function parseFeed(feed: string, options?: ParserOptions & DomHandlerOptions): Feed | null; +//# sourceMappingURL=FeedHandler.d.ts.map \ No newline at end of file diff --git a/node_modules/htmlparser2/lib/FeedHandler.d.ts.map b/node_modules/htmlparser2/lib/FeedHandler.d.ts.map new file mode 100644 index 0000000..34780db --- /dev/null +++ b/node_modules/htmlparser2/lib/FeedHandler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedHandler.d.ts","sourceRoot":"","sources":["../src/FeedHandler.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAU,aAAa,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,wFAAwF;AACxF,qBAAa,WAAY,SAAQ,UAAU;IACvC,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;;OAIG;gBAEC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,iBAAiB,EAC9D,OAAO,CAAC,EAAE,iBAAiB;IAS/B,KAAK,IAAI,IAAI;CAUhB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACrB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,aAAa,GAAG,iBAAqC,GAC/D,IAAI,GAAG,IAAI,CAIb"} \ No newline at end of file diff --git a/node_modules/htmlparser2/lib/FeedHandler.js b/node_modules/htmlparser2/lib/FeedHandler.js new file mode 100644 index 0000000..c85370b --- /dev/null +++ b/node_modules/htmlparser2/lib/FeedHandler.js @@ -0,0 +1,68 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parseFeed = exports.FeedHandler = exports.getFeed = void 0; +var domhandler_1 = __importDefault(require("domhandler")); +var domutils_1 = require("domutils"); +Object.defineProperty(exports, "getFeed", { enumerable: true, get: function () { return domutils_1.getFeed; } }); +var Parser_1 = require("./Parser"); +/** @deprecated Handler is no longer necessary; use `getFeed` or `parseFeed` instead. */ +var FeedHandler = /** @class */ (function (_super) { + __extends(FeedHandler, _super); + /** + * + * @param callback + * @param options + */ + function FeedHandler(callback, options) { + var _this = this; + if (typeof callback === "object") { + callback = undefined; + options = callback; + } + _this = _super.call(this, callback, options) || this; + return _this; + } + FeedHandler.prototype.onend = function () { + var feed = (0, domutils_1.getFeed)(this.dom); + if (feed) { + this.feed = feed; + this.handleCallback(null); + } + else { + this.handleCallback(new Error("couldn't find root of feed")); + } + }; + return FeedHandler; +}(domhandler_1.default)); +exports.FeedHandler = FeedHandler; +/** + * Parse a feed. + * + * @param feed The feed that should be parsed, as a string. + * @param options Optionally, options for parsing. When using this, you should set `xmlMode` to `true`. + */ +function parseFeed(feed, options) { + if (options === void 0) { options = { xmlMode: true }; } + var handler = new domhandler_1.default(null, options); + new Parser_1.Parser(handler, options).end(feed); + return (0, domutils_1.getFeed)(handler.dom); +} +exports.parseFeed = parseFeed; diff --git a/node_modules/htmlparser2/lib/Parser.d.ts b/node_modules/htmlparser2/lib/Parser.d.ts new file mode 100644 index 0000000..dee6755 --- /dev/null +++ b/node_modules/htmlparser2/lib/Parser.d.ts @@ -0,0 +1,180 @@ +import Tokenizer from "./Tokenizer"; +export interface ParserOptions { + /** + * Indicates whether special tags (``. + this.sequenceIndex = Number(c === 60 /* Lt */); + } + }; + Tokenizer.prototype.stateCDATASequence = function (c) { + if (c === Sequences.Cdata[this.sequenceIndex]) { + if (++this.sequenceIndex === Sequences.Cdata.length) { + this._state = 21 /* InCommentLike */; + this.currentSequence = Sequences.CdataEnd; + this.sequenceIndex = 0; + this.sectionStart = this._index + 1; + } + } + else { + this.sequenceIndex = 0; + this._state = 16 /* InDeclaration */; + this.stateInDeclaration(c); // Reconsume the character + } + }; + /** + * When we wait for one specific character, we can speed things up + * by skipping through the buffer until we find it. + * + * @returns Whether the character was found. + */ + Tokenizer.prototype.fastForwardTo = function (c) { + while (++this._index < this.buffer.length) { + if (this.buffer.charCodeAt(this._index) === c) { + return true; + } + } + /* + * We increment the index at the end of the `parse` loop, + * so set it to `buffer.length - 1` here. + * + * TODO: Refactor `parse` to increment index before calling states. + */ + this._index = this.buffer.length - 1; + return false; + }; + /** + * Comments and CDATA end with `-->` and `]]>`. + * + * Their common qualities are: + * - Their end sequences have a distinct character they start with. + * - That character is then repeated, so we have to check multiple repeats. + * - All characters but the start character of the sequence can be skipped. + */ + Tokenizer.prototype.stateInCommentLike = function (c) { + if (c === this.currentSequence[this.sequenceIndex]) { + if (++this.sequenceIndex === this.currentSequence.length) { + // Remove 2 trailing chars + var section = this.buffer.slice(this.sectionStart, this._index - 2); + if (this.currentSequence === Sequences.CdataEnd) { + this.cbs.oncdata(section); + } + else { + this.cbs.oncomment(section); + } + this.sequenceIndex = 0; + this.sectionStart = this._index + 1; + this._state = 1 /* Text */; + } + } + else if (this.sequenceIndex === 0) { + // Fast-forward to the first character of the sequence + if (this.fastForwardTo(this.currentSequence[0])) { + this.sequenceIndex = 1; + } + } + else if (c !== this.currentSequence[this.sequenceIndex - 1]) { + // Allow long sequences, eg. --->, ]]]> + this.sequenceIndex = 0; + } + }; + /** + * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name. + * + * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar). + * We allow anything that wouldn't end the tag. + */ + Tokenizer.prototype.isTagStartChar = function (c) { + return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c); + }; + Tokenizer.prototype.startSpecial = function (sequence, offset) { + this.isSpecial = true; + this.currentSequence = sequence; + this.sequenceIndex = offset; + this._state = 23 /* SpecialStartSequence */; + }; + Tokenizer.prototype.stateBeforeTagName = function (c) { + if (c === 33 /* ExclamationMark */) { + this._state = 15 /* BeforeDeclaration */; + this.sectionStart = this._index + 1; + } + else if (c === 63 /* Questionmark */) { + this._state = 17 /* InProcessingInstruction */; + this.sectionStart = this._index + 1; + } + else if (this.isTagStartChar(c)) { + var lower = c | 0x20; + this.sectionStart = this._index; + if (!this.xmlMode && lower === Sequences.TitleEnd[2]) { + this.startSpecial(Sequences.TitleEnd, 3); + } + else { + this._state = + !this.xmlMode && lower === Sequences.ScriptEnd[2] + ? 22 /* BeforeSpecialS */ + : 3 /* InTagName */; + } + } + else if (c === 47 /* Slash */) { + this._state = 5 /* BeforeClosingTagName */; + } + else { + this._state = 1 /* Text */; + this.stateText(c); + } + }; + Tokenizer.prototype.stateInTagName = function (c) { + if (isEndOfTagSection(c)) { + this.cbs.onopentagname(this.getSection()); + this.sectionStart = -1; + this._state = 8 /* BeforeAttributeName */; + this.stateBeforeAttributeName(c); + } + }; + Tokenizer.prototype.stateBeforeClosingTagName = function (c) { + if (isWhitespace(c)) { + // Ignore + } + else if (c === 62 /* Gt */) { + this._state = 1 /* Text */; + } + else { + this._state = this.isTagStartChar(c) + ? 6 /* InClosingTagName */ + : 20 /* InSpecialComment */; + this.sectionStart = this._index; + } + }; + Tokenizer.prototype.stateInClosingTagName = function (c) { + if (c === 62 /* Gt */ || isWhitespace(c)) { + this.cbs.onclosetag(this.getSection()); + this.sectionStart = -1; + this._state = 7 /* AfterClosingTagName */; + this.stateAfterClosingTagName(c); + } + }; + Tokenizer.prototype.stateAfterClosingTagName = function (c) { + // Skip everything until ">" + if (c === 62 /* Gt */ || this.fastForwardTo(62 /* Gt */)) { + this._state = 1 /* Text */; + this.sectionStart = this._index + 1; + } + }; + Tokenizer.prototype.stateBeforeAttributeName = function (c) { + if (c === 62 /* Gt */) { + this.cbs.onopentagend(); + if (this.isSpecial) { + this._state = 24 /* InSpecialTag */; + this.sequenceIndex = 0; + } + else { + this._state = 1 /* Text */; + } + this.baseState = this._state; + this.sectionStart = this._index + 1; + } + else if (c === 47 /* Slash */) { + this._state = 4 /* InSelfClosingTag */; + } + else if (!isWhitespace(c)) { + this._state = 9 /* InAttributeName */; + this.sectionStart = this._index; + } + }; + Tokenizer.prototype.stateInSelfClosingTag = function (c) { + if (c === 62 /* Gt */) { + this.cbs.onselfclosingtag(); + this._state = 1 /* Text */; + this.baseState = 1 /* Text */; + this.sectionStart = this._index + 1; + this.isSpecial = false; // Reset special state, in case of self-closing special tags + } + else if (!isWhitespace(c)) { + this._state = 8 /* BeforeAttributeName */; + this.stateBeforeAttributeName(c); + } + }; + Tokenizer.prototype.stateInAttributeName = function (c) { + if (c === 61 /* Eq */ || isEndOfTagSection(c)) { + this.cbs.onattribname(this.getSection()); + this.sectionStart = -1; + this._state = 10 /* AfterAttributeName */; + this.stateAfterAttributeName(c); + } + }; + Tokenizer.prototype.stateAfterAttributeName = function (c) { + if (c === 61 /* Eq */) { + this._state = 11 /* BeforeAttributeValue */; + } + else if (c === 47 /* Slash */ || c === 62 /* Gt */) { + this.cbs.onattribend(undefined); + this._state = 8 /* BeforeAttributeName */; + this.stateBeforeAttributeName(c); + } + else if (!isWhitespace(c)) { + this.cbs.onattribend(undefined); + this._state = 9 /* InAttributeName */; + this.sectionStart = this._index; + } + }; + Tokenizer.prototype.stateBeforeAttributeValue = function (c) { + if (c === 34 /* DoubleQuote */) { + this._state = 12 /* InAttributeValueDq */; + this.sectionStart = this._index + 1; + } + else if (c === 39 /* SingleQuote */) { + this._state = 13 /* InAttributeValueSq */; + this.sectionStart = this._index + 1; + } + else if (!isWhitespace(c)) { + this.sectionStart = this._index; + this._state = 14 /* InAttributeValueNq */; + this.stateInAttributeValueNoQuotes(c); // Reconsume token + } + }; + Tokenizer.prototype.handleInAttributeValue = function (c, quote) { + if (c === quote || + (!this.decodeEntities && this.fastForwardTo(quote))) { + this.cbs.onattribdata(this.getSection()); + this.sectionStart = -1; + this.cbs.onattribend(String.fromCharCode(quote)); + this._state = 8 /* BeforeAttributeName */; + } + else if (this.decodeEntities && c === 38 /* Amp */) { + this.baseState = this._state; + this._state = 25 /* BeforeEntity */; + } + }; + Tokenizer.prototype.stateInAttributeValueDoubleQuotes = function (c) { + this.handleInAttributeValue(c, 34 /* DoubleQuote */); + }; + Tokenizer.prototype.stateInAttributeValueSingleQuotes = function (c) { + this.handleInAttributeValue(c, 39 /* SingleQuote */); + }; + Tokenizer.prototype.stateInAttributeValueNoQuotes = function (c) { + if (isWhitespace(c) || c === 62 /* Gt */) { + this.cbs.onattribdata(this.getSection()); + this.sectionStart = -1; + this.cbs.onattribend(null); + this._state = 8 /* BeforeAttributeName */; + this.stateBeforeAttributeName(c); + } + else if (this.decodeEntities && c === 38 /* Amp */) { + this.baseState = this._state; + this._state = 25 /* BeforeEntity */; + } + }; + Tokenizer.prototype.stateBeforeDeclaration = function (c) { + if (c === 91 /* OpeningSquareBracket */) { + this._state = 19 /* CDATASequence */; + this.sequenceIndex = 0; + } + else { + this._state = + c === 45 /* Dash */ + ? 18 /* BeforeComment */ + : 16 /* InDeclaration */; + } + }; + Tokenizer.prototype.stateInDeclaration = function (c) { + if (c === 62 /* Gt */ || this.fastForwardTo(62 /* Gt */)) { + this.cbs.ondeclaration(this.getSection()); + this._state = 1 /* Text */; + this.sectionStart = this._index + 1; + } + }; + Tokenizer.prototype.stateInProcessingInstruction = function (c) { + if (c === 62 /* Gt */ || this.fastForwardTo(62 /* Gt */)) { + this.cbs.onprocessinginstruction(this.getSection()); + this._state = 1 /* Text */; + this.sectionStart = this._index + 1; + } + }; + Tokenizer.prototype.stateBeforeComment = function (c) { + if (c === 45 /* Dash */) { + this._state = 21 /* InCommentLike */; + this.currentSequence = Sequences.CommentEnd; + // Allow short comments (eg. ) + this.sequenceIndex = 2; + this.sectionStart = this._index + 1; + } + else { + this._state = 16 /* InDeclaration */; + } + }; + Tokenizer.prototype.stateInSpecialComment = function (c) { + if (c === 62 /* Gt */ || this.fastForwardTo(62 /* Gt */)) { + this.cbs.oncomment(this.getSection()); + this._state = 1 /* Text */; + this.sectionStart = this._index + 1; + } + }; + Tokenizer.prototype.stateBeforeSpecialS = function (c) { + var lower = c | 0x20; + if (lower === Sequences.ScriptEnd[3]) { + this.startSpecial(Sequences.ScriptEnd, 4); + } + else if (lower === Sequences.StyleEnd[3]) { + this.startSpecial(Sequences.StyleEnd, 4); + } + else { + this._state = 3 /* InTagName */; + this.stateInTagName(c); // Consume the token again + } + }; + Tokenizer.prototype.stateBeforeEntity = function (c) { + // Start excess with 1 to include the '&' + this.entityExcess = 1; + if (c === 35 /* Num */) { + this._state = 26 /* BeforeNumericEntity */; + } + else if (c === 38 /* Amp */) { + // We have two `&` characters in a row. Stay in the current state. + } + else { + this.trieIndex = 0; + this.trieCurrent = this.entityTrie[0]; + this.trieResult = null; + this._state = 27 /* InNamedEntity */; + this.stateInNamedEntity(c); + } + }; + Tokenizer.prototype.stateInNamedEntity = function (c) { + this.entityExcess += 1; + this.trieIndex = (0, decode_1.determineBranch)(this.entityTrie, this.trieCurrent, this.trieIndex + 1, c); + if (this.trieIndex < 0) { + this.emitNamedEntity(); + this._index--; + return; + } + this.trieCurrent = this.entityTrie[this.trieIndex]; + // If the branch is a value, store it and continue + if (this.trieCurrent & decode_1.BinTrieFlags.HAS_VALUE) { + // If we have a legacy entity while parsing strictly, just skip the number of bytes + if (!this.allowLegacyEntity() && c !== 59 /* Semi */) { + // No need to consider multi-byte values, as the legacy entity is always a single byte + this.trieIndex += 1; + } + else { + // Add 1 as we have already incremented the excess + var entityStart = this._index - this.entityExcess + 1; + if (entityStart > this.sectionStart) { + this.emitPartial(this.buffer.substring(this.sectionStart, entityStart)); + } + // If this is a surrogate pair, combine the higher bits from the node with the next byte + this.trieResult = + this.trieCurrent & decode_1.BinTrieFlags.MULTI_BYTE + ? String.fromCharCode(this.entityTrie[++this.trieIndex], this.entityTrie[++this.trieIndex]) + : String.fromCharCode(this.entityTrie[++this.trieIndex]); + this.entityExcess = 0; + this.sectionStart = this._index + 1; + } + } + }; + Tokenizer.prototype.emitNamedEntity = function () { + if (this.trieResult) { + this.emitPartial(this.trieResult); + } + this._state = this.baseState; + }; + Tokenizer.prototype.stateBeforeNumericEntity = function (c) { + if ((c | 0x20) === 120 /* LowerX */) { + this.entityExcess++; + this._state = 29 /* InHexEntity */; + } + else { + this._state = 28 /* InNumericEntity */; + this.stateInNumericEntity(c); + } + }; + Tokenizer.prototype.decodeNumericEntity = function (base, strict) { + var entityStart = this._index - this.entityExcess - 1; + var numberStart = entityStart + 2 + (base >> 4); + if (numberStart !== this._index) { + // Emit leading data if any + if (entityStart > this.sectionStart) { + this.emitPartial(this.buffer.substring(this.sectionStart, entityStart)); + } + // Parse entity + var entity = this.buffer.substring(numberStart, this._index); + var parsed = parseInt(entity, base); + this.emitPartial((0, decode_codepoint_1.default)(parsed)); + this.sectionStart = this._index + Number(strict); + } + this._state = this.baseState; + }; + Tokenizer.prototype.stateInNumericEntity = function (c) { + if (c === 59 /* Semi */) { + this.decodeNumericEntity(10, true); + } + else if (!isNumber(c)) { + if (this.allowLegacyEntity()) { + this.decodeNumericEntity(10, false); + } + else { + this._state = this.baseState; + } + this._index--; + } + else { + this.entityExcess++; + } + }; + Tokenizer.prototype.stateInHexEntity = function (c) { + if (c === 59 /* Semi */) { + this.decodeNumericEntity(16, true); + } + else if ((c < 97 /* LowerA */ || c > 102 /* LowerF */) && + (c < 65 /* UpperA */ || c > 70 /* UpperF */) && + !isNumber(c)) { + if (this.allowLegacyEntity()) { + this.decodeNumericEntity(16, false); + } + else { + this._state = this.baseState; + } + this._index--; + } + else { + this.entityExcess++; + } + }; + Tokenizer.prototype.allowLegacyEntity = function () { + return (!this.xmlMode && + (this.baseState === 1 /* Text */ || + this.baseState === 24 /* InSpecialTag */)); + }; + /** + * Remove data that has already been consumed from the buffer. + */ + Tokenizer.prototype.cleanup = function () { + // If we are inside of text, emit what we already have. + if (this.running && + this.sectionStart !== this._index && + (this._state === 1 /* Text */ || + (this._state === 24 /* InSpecialTag */ && + this.sequenceIndex === 0))) { + // TODO: We could emit attribute data here as well. + this.cbs.ontext(this.buffer.substr(this.sectionStart)); + this.sectionStart = this._index; + } + var start = this.sectionStart < 0 ? this._index : this.sectionStart; + this.buffer = + start === this.buffer.length ? "" : this.buffer.substr(start); + this._index -= start; + this.bufferOffset += start; + if (this.sectionStart > 0) { + this.sectionStart = 0; + } + }; + Tokenizer.prototype.shouldContinue = function () { + return this._index < this.buffer.length && this.running; + }; + /** + * Iterates through the buffer, calling the function corresponding to the current state. + * + * States that are more likely to be hit are higher up, as a performance improvement. + */ + Tokenizer.prototype.parse = function () { + while (this.shouldContinue()) { + var c = this.buffer.charCodeAt(this._index); + if (this._state === 1 /* Text */) { + this.stateText(c); + } + else if (this._state === 23 /* SpecialStartSequence */) { + this.stateSpecialStartSequence(c); + } + else if (this._state === 24 /* InSpecialTag */) { + this.stateInSpecialTag(c); + } + else if (this._state === 19 /* CDATASequence */) { + this.stateCDATASequence(c); + } + else if (this._state === 12 /* InAttributeValueDq */) { + this.stateInAttributeValueDoubleQuotes(c); + } + else if (this._state === 9 /* InAttributeName */) { + this.stateInAttributeName(c); + } + else if (this._state === 21 /* InCommentLike */) { + this.stateInCommentLike(c); + } + else if (this._state === 20 /* InSpecialComment */) { + this.stateInSpecialComment(c); + } + else if (this._state === 8 /* BeforeAttributeName */) { + this.stateBeforeAttributeName(c); + } + else if (this._state === 3 /* InTagName */) { + this.stateInTagName(c); + } + else if (this._state === 6 /* InClosingTagName */) { + this.stateInClosingTagName(c); + } + else if (this._state === 2 /* BeforeTagName */) { + this.stateBeforeTagName(c); + } + else if (this._state === 10 /* AfterAttributeName */) { + this.stateAfterAttributeName(c); + } + else if (this._state === 13 /* InAttributeValueSq */) { + this.stateInAttributeValueSingleQuotes(c); + } + else if (this._state === 11 /* BeforeAttributeValue */) { + this.stateBeforeAttributeValue(c); + } + else if (this._state === 5 /* BeforeClosingTagName */) { + this.stateBeforeClosingTagName(c); + } + else if (this._state === 7 /* AfterClosingTagName */) { + this.stateAfterClosingTagName(c); + } + else if (this._state === 22 /* BeforeSpecialS */) { + this.stateBeforeSpecialS(c); + } + else if (this._state === 14 /* InAttributeValueNq */) { + this.stateInAttributeValueNoQuotes(c); + } + else if (this._state === 4 /* InSelfClosingTag */) { + this.stateInSelfClosingTag(c); + } + else if (this._state === 16 /* InDeclaration */) { + this.stateInDeclaration(c); + } + else if (this._state === 15 /* BeforeDeclaration */) { + this.stateBeforeDeclaration(c); + } + else if (this._state === 18 /* BeforeComment */) { + this.stateBeforeComment(c); + } + else if (this._state === 17 /* InProcessingInstruction */) { + this.stateInProcessingInstruction(c); + } + else if (this._state === 27 /* InNamedEntity */) { + this.stateInNamedEntity(c); + } + else if (this._state === 25 /* BeforeEntity */) { + this.stateBeforeEntity(c); + } + else if (this._state === 29 /* InHexEntity */) { + this.stateInHexEntity(c); + } + else if (this._state === 28 /* InNumericEntity */) { + this.stateInNumericEntity(c); + } + else { + // `this._state === State.BeforeNumericEntity` + this.stateBeforeNumericEntity(c); + } + this._index++; + } + this.cleanup(); + }; + Tokenizer.prototype.finish = function () { + if (this._state === 27 /* InNamedEntity */) { + this.emitNamedEntity(); + } + // If there is remaining data, emit it in a reasonable way + if (this.sectionStart < this._index) { + this.handleTrailingData(); + } + this.cbs.onend(); + }; + /** Handle any trailing data. */ + Tokenizer.prototype.handleTrailingData = function () { + var data = this.buffer.substr(this.sectionStart); + if (this._state === 21 /* InCommentLike */) { + if (this.currentSequence === Sequences.CdataEnd) { + this.cbs.oncdata(data); + } + else { + this.cbs.oncomment(data); + } + } + else if (this._state === 28 /* InNumericEntity */ && + this.allowLegacyEntity()) { + this.decodeNumericEntity(10, false); + // All trailing data will have been consumed + } + else if (this._state === 29 /* InHexEntity */ && + this.allowLegacyEntity()) { + this.decodeNumericEntity(16, false); + // All trailing data will have been consumed + } + else if (this._state === 3 /* InTagName */ || + this._state === 8 /* BeforeAttributeName */ || + this._state === 11 /* BeforeAttributeValue */ || + this._state === 10 /* AfterAttributeName */ || + this._state === 9 /* InAttributeName */ || + this._state === 13 /* InAttributeValueSq */ || + this._state === 12 /* InAttributeValueDq */ || + this._state === 14 /* InAttributeValueNq */ || + this._state === 6 /* InClosingTagName */) { + /* + * If we are currently in an opening or closing tag, us not calling the + * respective callback signals that the tag should be ignored. + */ + } + else { + this.cbs.ontext(data); + } + }; + Tokenizer.prototype.getSection = function () { + return this.buffer.substring(this.sectionStart, this._index); + }; + Tokenizer.prototype.emitPartial = function (value) { + if (this.baseState !== 1 /* Text */ && + this.baseState !== 24 /* InSpecialTag */) { + this.cbs.onattribdata(value); + } + else { + this.cbs.ontext(value); + } + }; + return Tokenizer; +}()); +exports.default = Tokenizer; diff --git a/node_modules/htmlparser2/lib/WritableStream.d.ts b/node_modules/htmlparser2/lib/WritableStream.d.ts new file mode 100644 index 0000000..0755f99 --- /dev/null +++ b/node_modules/htmlparser2/lib/WritableStream.d.ts @@ -0,0 +1,16 @@ +/// +import { Handler, ParserOptions } from "./Parser"; +import { Writable } from "stream"; +/** + * WritableStream makes the `Parser` interface available as a NodeJS stream. + * + * @see Parser + */ +export declare class WritableStream extends Writable { + private readonly _parser; + private readonly _decoder; + constructor(cbs: Partial, options?: ParserOptions); + _write(chunk: string | Buffer, encoding: string, cb: () => void): void; + _final(cb: () => void): void; +} +//# sourceMappingURL=WritableStream.d.ts.map \ No newline at end of file diff --git a/node_modules/htmlparser2/lib/WritableStream.d.ts.map b/node_modules/htmlparser2/lib/WritableStream.d.ts.map new file mode 100644 index 0000000..31295a2 --- /dev/null +++ b/node_modules/htmlparser2/lib/WritableStream.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"WritableStream.d.ts","sourceRoot":"","sources":["../src/WritableStream.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAK1D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAQlC;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;gBAEpC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa;IAK1D,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;IAOtE,MAAM,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;CAI/B"} \ No newline at end of file diff --git a/node_modules/htmlparser2/lib/WritableStream.js b/node_modules/htmlparser2/lib/WritableStream.js new file mode 100644 index 0000000..ff87995 --- /dev/null +++ b/node_modules/htmlparser2/lib/WritableStream.js @@ -0,0 +1,53 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WritableStream = void 0; +var Parser_1 = require("./Parser"); +/* + * NOTE: If either of these two imports produces a type error, + * please update your @types/node dependency! + */ +var stream_1 = require("stream"); +var string_decoder_1 = require("string_decoder"); +// Following the example in https://nodejs.org/api/stream.html#stream_decoding_buffers_in_a_writable_stream +function isBuffer(_chunk, encoding) { + return encoding === "buffer"; +} +/** + * WritableStream makes the `Parser` interface available as a NodeJS stream. + * + * @see Parser + */ +var WritableStream = /** @class */ (function (_super) { + __extends(WritableStream, _super); + function WritableStream(cbs, options) { + var _this = _super.call(this, { decodeStrings: false }) || this; + _this._decoder = new string_decoder_1.StringDecoder(); + _this._parser = new Parser_1.Parser(cbs, options); + return _this; + } + WritableStream.prototype._write = function (chunk, encoding, cb) { + this._parser.write(isBuffer(chunk, encoding) ? this._decoder.write(chunk) : chunk); + cb(); + }; + WritableStream.prototype._final = function (cb) { + this._parser.end(this._decoder.end()); + cb(); + }; + return WritableStream; +}(stream_1.Writable)); +exports.WritableStream = WritableStream; diff --git a/node_modules/htmlparser2/lib/index.d.ts b/node_modules/htmlparser2/lib/index.d.ts new file mode 100644 index 0000000..997c6d9 --- /dev/null +++ b/node_modules/htmlparser2/lib/index.d.ts @@ -0,0 +1,39 @@ +import { Parser, ParserOptions } from "./Parser"; +export { Parser, ParserOptions }; +import { DomHandler, DomHandlerOptions, Node, Element, Document } from "domhandler"; +export { DomHandler, DomHandlerOptions }; +declare type Options = ParserOptions & DomHandlerOptions; +/** + * Parses the data, returns the resulting document. + * + * @param data The data that should be parsed. + * @param options Optional options for the parser and DOM builder. + */ +export declare function parseDocument(data: string, options?: Options): Document; +/** + * Parses data, returns an array of the root nodes. + * + * Note that the root nodes still have a `Document` node as their parent. + * Use `parseDocument` to get the `Document` node instead. + * + * @param data The data that should be parsed. + * @param options Optional options for the parser and DOM builder. + * @deprecated Use `parseDocument` instead. + */ +export declare function parseDOM(data: string, options?: Options): Node[]; +/** + * Creates a parser instance, with an attached DOM handler. + * + * @param cb A callback that will be called once parsing has been completed. + * @param options Optional options for the parser and DOM builder. + * @param elementCb An optional callback that will be called every time a tag has been completed inside of the DOM. + */ +export declare function createDomStream(cb: (error: Error | null, dom: Node[]) => void, options?: Options, elementCb?: (element: Element) => void): Parser; +export { default as Tokenizer, Callbacks as TokenizerCallbacks, } from "./Tokenizer"; +import * as ElementType from "domelementtype"; +export { ElementType }; +export * from "./FeedHandler"; +export * as DomUtils from "domutils"; +export { DomHandler as DefaultHandler }; +export { FeedHandler as RssHandler } from "./FeedHandler"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/htmlparser2/lib/index.d.ts.map b/node_modules/htmlparser2/lib/index.d.ts.map new file mode 100644 index 0000000..058fcba --- /dev/null +++ b/node_modules/htmlparser2/lib/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AAEjC,OAAO,EACH,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,OAAO,EACP,QAAQ,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;AAEzC,aAAK,OAAO,GAAG,aAAa,GAAG,iBAAiB,CAAC;AAIjD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAIvE;AACD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,EAAE,CAEhE;AACD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC3B,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,EAC9C,OAAO,CAAC,EAAE,OAAO,EACjB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GACvC,MAAM,CAGR;AAED,OAAO,EACH,OAAO,IAAI,SAAS,EACpB,SAAS,IAAI,kBAAkB,GAClC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,CAAC;AAOvB,cAAc,eAAe,CAAC;AAC9B,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,CAAC;AACxC,OAAO,EAAE,WAAW,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC"} \ No newline at end of file diff --git a/node_modules/htmlparser2/lib/index.js b/node_modules/htmlparser2/lib/index.js new file mode 100644 index 0000000..3e461fa --- /dev/null +++ b/node_modules/htmlparser2/lib/index.js @@ -0,0 +1,84 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RssHandler = exports.DefaultHandler = exports.DomUtils = exports.ElementType = exports.Tokenizer = exports.createDomStream = exports.parseDOM = exports.parseDocument = exports.DomHandler = exports.Parser = void 0; +var Parser_1 = require("./Parser"); +Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return Parser_1.Parser; } }); +var domhandler_1 = require("domhandler"); +Object.defineProperty(exports, "DomHandler", { enumerable: true, get: function () { return domhandler_1.DomHandler; } }); +Object.defineProperty(exports, "DefaultHandler", { enumerable: true, get: function () { return domhandler_1.DomHandler; } }); +// Helper methods +/** + * Parses the data, returns the resulting document. + * + * @param data The data that should be parsed. + * @param options Optional options for the parser and DOM builder. + */ +function parseDocument(data, options) { + var handler = new domhandler_1.DomHandler(undefined, options); + new Parser_1.Parser(handler, options).end(data); + return handler.root; +} +exports.parseDocument = parseDocument; +/** + * Parses data, returns an array of the root nodes. + * + * Note that the root nodes still have a `Document` node as their parent. + * Use `parseDocument` to get the `Document` node instead. + * + * @param data The data that should be parsed. + * @param options Optional options for the parser and DOM builder. + * @deprecated Use `parseDocument` instead. + */ +function parseDOM(data, options) { + return parseDocument(data, options).children; +} +exports.parseDOM = parseDOM; +/** + * Creates a parser instance, with an attached DOM handler. + * + * @param cb A callback that will be called once parsing has been completed. + * @param options Optional options for the parser and DOM builder. + * @param elementCb An optional callback that will be called every time a tag has been completed inside of the DOM. + */ +function createDomStream(cb, options, elementCb) { + var handler = new domhandler_1.DomHandler(cb, options, elementCb); + return new Parser_1.Parser(handler, options); +} +exports.createDomStream = createDomStream; +var Tokenizer_1 = require("./Tokenizer"); +Object.defineProperty(exports, "Tokenizer", { enumerable: true, get: function () { return __importDefault(Tokenizer_1).default; } }); +var ElementType = __importStar(require("domelementtype")); +exports.ElementType = ElementType; +/* + * All of the following exports exist for backwards-compatibility. + * They should probably be removed eventually. + */ +__exportStar(require("./FeedHandler"), exports); +exports.DomUtils = __importStar(require("domutils")); +var FeedHandler_1 = require("./FeedHandler"); +Object.defineProperty(exports, "RssHandler", { enumerable: true, get: function () { return FeedHandler_1.FeedHandler; } }); -- cgit v1.2.3