6416 lines
395 KiB
JavaScript
6416 lines
395 KiB
JavaScript
|
/*
|
|||
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|||
|
if you want to view the source, please visit the github repository of this plugin
|
|||
|
*/
|
|||
|
|
|||
|
var __create = Object.create;
|
|||
|
var __defProp = Object.defineProperty;
|
|||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|||
|
var __getProtoOf = Object.getPrototypeOf;
|
|||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|||
|
var __commonJS = (cb, mod) => function __require() {
|
|||
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|||
|
};
|
|||
|
var __export = (target, all) => {
|
|||
|
for (var name in all)
|
|||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|||
|
};
|
|||
|
var __copyProps = (to, from, except, desc) => {
|
|||
|
if (from && typeof from === "object" || typeof from === "function") {
|
|||
|
for (let key of __getOwnPropNames(from))
|
|||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|||
|
}
|
|||
|
return to;
|
|||
|
};
|
|||
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|||
|
|
|||
|
// node_modules/he/he.js
|
|||
|
var require_he = __commonJS({
|
|||
|
"node_modules/he/he.js"(exports, module2) {
|
|||
|
(function(root) {
|
|||
|
var freeExports = typeof exports == "object" && exports;
|
|||
|
var freeModule = typeof module2 == "object" && module2 && module2.exports == freeExports && module2;
|
|||
|
var freeGlobal = typeof global == "object" && global;
|
|||
|
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
|||
|
root = freeGlobal;
|
|||
|
}
|
|||
|
var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|||
|
var regexAsciiWhitelist = /[\x01-\x7F]/g;
|
|||
|
var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
|
|||
|
var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g;
|
|||
|
var encodeMap = { "\xAD": "shy", "\u200C": "zwnj", "\u200D": "zwj", "\u200E": "lrm", "\u2063": "ic", "\u2062": "it", "\u2061": "af", "\u200F": "rlm", "\u200B": "ZeroWidthSpace", "\u2060": "NoBreak", "\u0311": "DownBreve", "\u20DB": "tdot", "\u20DC": "DotDot", " ": "Tab", "\n": "NewLine", "\u2008": "puncsp", "\u205F": "MediumSpace", "\u2009": "thinsp", "\u200A": "hairsp", "\u2004": "emsp13", "\u2002": "ensp", "\u2005": "emsp14", "\u2003": "emsp", "\u2007": "numsp", "\xA0": "nbsp", "\u205F\u200A": "ThickSpace", "\u203E": "oline", "_": "lowbar", "\u2010": "dash", "\u2013": "ndash", "\u2014": "mdash", "\u2015": "horbar", ",": "comma", ";": "semi", "\u204F": "bsemi", ":": "colon", "\u2A74": "Colone", "!": "excl", "\xA1": "iexcl", "?": "quest", "\xBF": "iquest", ".": "period", "\u2025": "nldr", "\u2026": "mldr", "\xB7": "middot", "'": "apos", "\u2018": "lsquo", "\u2019": "rsquo", "\u201A": "sbquo", "\u2039": "lsaquo", "\u203A": "rsaquo", '"': "quot", "\u201C": "ldquo", "\u201D": "rdquo", "\u201E": "bdquo", "\xAB": "laquo", "\xBB": "raquo", "(": "lpar", ")": "rpar", "[": "lsqb", "]": "rsqb", "{": "lcub", "}": "rcub", "\u2308": "lceil", "\u2309": "rceil", "\u230A": "lfloor", "\u230B": "rfloor", "\u2985": "lopar", "\u2986": "ropar", "\u298B": "lbrke", "\u298C": "rbrke", "\u298D": "lbrkslu", "\u298E": "rbrksld", "\u298F": "lbrksld", "\u2990": "rbrkslu", "\u2991": "langd", "\u2992": "rangd", "\u2993": "lparlt", "\u2994": "rpargt", "\u2995": "gtlPar", "\u2996": "ltrPar", "\u27E6": "lobrk", "\u27E7": "robrk", "\u27E8": "lang", "\u27E9": "rang", "\u27EA": "Lang", "\u27EB": "Rang", "\u27EC": "loang", "\u27ED": "roang", "\u2772": "lbbrk", "\u2773": "rbbrk", "\u2016": "Vert", "\xA7": "sect", "\xB6": "para", "@": "commat", "*": "ast", "/": "sol", "undefined": null, "&": "amp", "#": "num", "%": "percnt", "\u2030": "permil", "\u2031": "pertenk", "\u2020": "dagger", "\u2021": "Dagger", "\u2022": "bull", "\u2043": "hybull", "\u2032": "prime", "\u2033": "Prime", "\u2034": "tprime", "\u2057": "qprime", "\u2035": "bprime", "\u2041": "caret", "`": "grave", "\xB4": "acute", "\u02DC": "tilde", "^": "Hat", "\xAF": "macr", "\u02D8": "breve", "\u02D9": "dot", "\xA8": "die", "\u02DA": "ring", "\u02DD": "dblac", "\xB8": "cedil", "\u02DB": "ogon", "\u02C6": "circ", "\u02C7": "caron", "\xB0": "deg", "\xA9": "copy", "\xAE": "reg", "\u2117": "copysr", "\u2118": "wp", "\u211E": "rx", "\u2127": "mho", "\u2129": "iiota", "\u2190": "larr", "\u219A": "nlarr", "\u2192": "rarr", "\u219B": "nrarr", "\u2191": "uarr", "\u2193": "darr", "\u2194": "harr", "\u21AE": "nharr", "\u2195": "varr", "\u2196": "nwarr", "\u2197": "nearr", "\u2198": "searr", "\u2199": "swarr", "\u219D": "rarrw", "\u219D\u0338": "nrarrw", "\u219E": "Larr", "\u219F": "Uarr", "\u21A0": "Rarr", "\u21A1": "Darr", "\u21A2": "larrtl", "\u21A3": "rarrtl", "\u21A4": "mapstoleft", "\u21A5": "mapstoup", "\u21A6": "map", "\u21A7": "mapstodown", "\u21A9": "larrhk", "\u21AA": "rarrhk", "\u21AB": "larrlp", "\u21AC": "rarrlp", "\u21AD": "harrw", "\u21B0": "lsh", "\u21B1": "rsh", "\u21B2": "ldsh", "\u21B3": "rdsh", "\u21B5": "crarr", "\u21B6": "cularr", "\u21B7": "curarr", "\u21BA": "olarr", "\u21BB": "orarr", "\u21BC": "lharu", "\u21BD": "lhard", "\u21BE": "uharr", "\u21BF": "uharl", "\u21C0": "rharu", "\u21C1": "rhard", "\u21C2": "dharr", "\u21C3": "dharl", "\u21C4": "rlarr", "\u21C5": "udarr", "\u21C6": "lrarr", "\u21C7": "llarr", "\u21C8": "uuarr", "\u21C9": "rrarr", "\u21CA": "ddarr", "\u21CB": "lrhar", "\u21CC": "rlhar", "\u21D0": "lArr", "\u21CD": "nlArr", "\u21D1": "uArr", "\u21D2": "rArr", "\u21CF": "nrArr", "\u21D3": "dArr", "\u21D4": "iff", "\u21CE": "nhArr", "\u21D5": "vArr", "\u21D6": "nwArr", "\u21D7": "neArr", "\u21D8": "seArr", "\u21D9": "swArr", "\u21DA": "lAarr", "\u21DB": "rAarr", "\u21DD": "zigrarr", "\u21E4": "larrb", "\u21E5": "rarrb", "\u21F5": "duarr", "\u21FD": "loarr", "\u21FE": "roarr", "\u21FF": "hoarr", "\u2200": "forall", "\u2201": "comp", "\u2202": "part", "\u2202\u0338": "npart", "\u2203": "exist", "\u2204": "nexist", "\u2205": "empty", "\u2207": "Del", "\u2208": "in", "\u22
|
|||
|
var regexEscape = /["&'<>`]/g;
|
|||
|
var escapeMap = {
|
|||
|
'"': """,
|
|||
|
"&": "&",
|
|||
|
"'": "'",
|
|||
|
"<": "<",
|
|||
|
">": ">",
|
|||
|
"`": "`"
|
|||
|
};
|
|||
|
var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
|
|||
|
var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|||
|
var regexDecode = /&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArro
|
|||
|
var decodeMap = { "aacute": "\xE1", "Aacute": "\xC1", "abreve": "\u0103", "Abreve": "\u0102", "ac": "\u223E", "acd": "\u223F", "acE": "\u223E\u0333", "acirc": "\xE2", "Acirc": "\xC2", "acute": "\xB4", "acy": "\u0430", "Acy": "\u0410", "aelig": "\xE6", "AElig": "\xC6", "af": "\u2061", "afr": "\u{1D51E}", "Afr": "\u{1D504}", "agrave": "\xE0", "Agrave": "\xC0", "alefsym": "\u2135", "aleph": "\u2135", "alpha": "\u03B1", "Alpha": "\u0391", "amacr": "\u0101", "Amacr": "\u0100", "amalg": "\u2A3F", "amp": "&", "AMP": "&", "and": "\u2227", "And": "\u2A53", "andand": "\u2A55", "andd": "\u2A5C", "andslope": "\u2A58", "andv": "\u2A5A", "ang": "\u2220", "ange": "\u29A4", "angle": "\u2220", "angmsd": "\u2221", "angmsdaa": "\u29A8", "angmsdab": "\u29A9", "angmsdac": "\u29AA", "angmsdad": "\u29AB", "angmsdae": "\u29AC", "angmsdaf": "\u29AD", "angmsdag": "\u29AE", "angmsdah": "\u29AF", "angrt": "\u221F", "angrtvb": "\u22BE", "angrtvbd": "\u299D", "angsph": "\u2222", "angst": "\xC5", "angzarr": "\u237C", "aogon": "\u0105", "Aogon": "\u0104", "aopf": "\u{1D552}", "Aopf": "\u{1D538}", "ap": "\u2248", "apacir": "\u2A6F", "ape": "\u224A", "apE": "\u2A70", "apid": "\u224B", "apos": "'", "ApplyFunction": "\u2061", "approx": "\u2248", "approxeq": "\u224A", "aring": "\xE5", "Aring": "\xC5", "ascr": "\u{1D4B6}", "Ascr": "\u{1D49C}", "Assign": "\u2254", "ast": "*", "asymp": "\u2248", "asympeq": "\u224D", "atilde": "\xE3", "Atilde": "\xC3", "auml": "\xE4", "Auml": "\xC4", "awconint": "\u2233", "awint": "\u2A11", "backcong": "\u224C", "backepsilon": "\u03F6", "backprime": "\u2035", "backsim": "\u223D", "backsimeq": "\u22CD", "Backslash": "\u2216", "Barv": "\u2AE7", "barvee": "\u22BD", "barwed": "\u2305", "Barwed": "\u2306", "barwedge": "\u2305", "bbrk": "\u23B5", "bbrktbrk": "\u23B6", "bcong": "\u224C", "bcy": "\u0431", "Bcy": "\u0411", "bdquo": "\u201E", "becaus": "\u2235", "because": "\u2235", "Because": "\u2235", "bemptyv": "\u29B0", "bepsi": "\u03F6", "bernou": "\u212C", "Bernoullis": "\u212C", "beta": "\u03B2", "Beta": "\u0392", "beth": "\u2136", "between": "\u226C", "bfr": "\u{1D51F}", "Bfr": "\u{1D505}", "bigcap": "\u22C2", "bigcirc": "\u25EF", "bigcup": "\u22C3", "bigodot": "\u2A00", "bigoplus": "\u2A01", "bigotimes": "\u2A02", "bigsqcup": "\u2A06", "bigstar": "\u2605", "bigtriangledown": "\u25BD", "bigtriangleup": "\u25B3", "biguplus": "\u2A04", "bigvee": "\u22C1", "bigwedge": "\u22C0", "bkarow": "\u290D", "blacklozenge": "\u29EB", "blacksquare": "\u25AA", "blacktriangle": "\u25B4", "blacktriangledown": "\u25BE", "blacktriangleleft": "\u25C2", "blacktriangleright": "\u25B8", "blank": "\u2423", "blk12": "\u2592", "blk14": "\u2591", "blk34": "\u2593", "block": "\u2588", "bne": "=\u20E5", "bnequiv": "\u2261\u20E5", "bnot": "\u2310", "bNot": "\u2AED", "bopf": "\u{1D553}", "Bopf": "\u{1D539}", "bot": "\u22A5", "bottom": "\u22A5", "bowtie": "\u22C8", "boxbox": "\u29C9", "boxdl": "\u2510", "boxdL": "\u2555", "boxDl": "\u2556", "boxDL": "\u2557", "boxdr": "\u250C", "boxdR": "\u2552", "boxDr": "\u2553", "boxDR": "\u2554", "boxh": "\u2500", "boxH": "\u2550", "boxhd": "\u252C", "boxhD": "\u2565", "boxHd": "\u2564", "boxHD": "\u2566", "boxhu": "\u2534", "boxhU": "\u2568", "boxHu": "\u2567", "boxHU": "\u2569", "boxminus": "\u229F", "boxplus": "\u229E", "boxtimes": "\u22A0", "boxul": "\u2518", "boxuL": "\u255B", "boxUl": "\u255C", "boxUL": "\u255D", "boxur": "\u2514", "boxuR": "\u2558", "boxUr": "\u2559", "boxUR": "\u255A", "boxv": "\u2502", "boxV": "\u2551", "boxvh": "\u253C", "boxvH": "\u256A", "boxVh": "\u256B", "boxVH": "\u256C", "boxvl": "\u2524", "boxvL": "\u2561", "boxVl": "\u2562", "boxVL": "\u2563", "boxvr": "\u251C", "boxvR": "\u255E", "boxVr": "\u255F", "boxVR": "\u2560", "bprime": "\u2035", "breve": "\u02D8", "Breve": "\u02D8", "brvbar": "\xA6", "bscr": "\u{1D4B7}", "Bscr": "\u212C", "bsemi": "\u204F", "bsim": "\u223D", "bsime": "\u22CD", "bsol": "\\", "bsolb": "\u29C5", "bsolhsub": "\u27C8", "bull": "\u2022", "bullet": "\u2022", "bump": "\u224E", "bumpe": "\u224F", "bumpE": "\u2AAE", "bumpeq": "\u224F", "Bumpeq": "\u224E", "cacute": "\
|
|||
|
var decodeMapLegacy = { "aacute": "\xE1", "Aacute": "\xC1", "acirc": "\xE2", "Acirc": "\xC2", "acute": "\xB4", "aelig": "\xE6", "AElig": "\xC6", "agrave": "\xE0", "Agrave": "\xC0", "amp": "&", "AMP": "&", "aring": "\xE5", "Aring": "\xC5", "atilde": "\xE3", "Atilde": "\xC3", "auml": "\xE4", "Auml": "\xC4", "brvbar": "\xA6", "ccedil": "\xE7", "Ccedil": "\xC7", "cedil": "\xB8", "cent": "\xA2", "copy": "\xA9", "COPY": "\xA9", "curren": "\xA4", "deg": "\xB0", "divide": "\xF7", "eacute": "\xE9", "Eacute": "\xC9", "ecirc": "\xEA", "Ecirc": "\xCA", "egrave": "\xE8", "Egrave": "\xC8", "eth": "\xF0", "ETH": "\xD0", "euml": "\xEB", "Euml": "\xCB", "frac12": "\xBD", "frac14": "\xBC", "frac34": "\xBE", "gt": ">", "GT": ">", "iacute": "\xED", "Iacute": "\xCD", "icirc": "\xEE", "Icirc": "\xCE", "iexcl": "\xA1", "igrave": "\xEC", "Igrave": "\xCC", "iquest": "\xBF", "iuml": "\xEF", "Iuml": "\xCF", "laquo": "\xAB", "lt": "<", "LT": "<", "macr": "\xAF", "micro": "\xB5", "middot": "\xB7", "nbsp": "\xA0", "not": "\xAC", "ntilde": "\xF1", "Ntilde": "\xD1", "oacute": "\xF3", "Oacute": "\xD3", "ocirc": "\xF4", "Ocirc": "\xD4", "ograve": "\xF2", "Ograve": "\xD2", "ordf": "\xAA", "ordm": "\xBA", "oslash": "\xF8", "Oslash": "\xD8", "otilde": "\xF5", "Otilde": "\xD5", "ouml": "\xF6", "Ouml": "\xD6", "para": "\xB6", "plusmn": "\xB1", "pound": "\xA3", "quot": '"', "QUOT": '"', "raquo": "\xBB", "reg": "\xAE", "REG": "\xAE", "sect": "\xA7", "shy": "\xAD", "sup1": "\xB9", "sup2": "\xB2", "sup3": "\xB3", "szlig": "\xDF", "thorn": "\xFE", "THORN": "\xDE", "times": "\xD7", "uacute": "\xFA", "Uacute": "\xDA", "ucirc": "\xFB", "Ucirc": "\xDB", "ugrave": "\xF9", "Ugrave": "\xD9", "uml": "\xA8", "uuml": "\xFC", "Uuml": "\xDC", "yacute": "\xFD", "Yacute": "\xDD", "yen": "\xA5", "yuml": "\xFF" };
|
|||
|
var decodeMapNumeric = { "0": "\uFFFD", "128": "\u20AC", "130": "\u201A", "131": "\u0192", "132": "\u201E", "133": "\u2026", "134": "\u2020", "135": "\u2021", "136": "\u02C6", "137": "\u2030", "138": "\u0160", "139": "\u2039", "140": "\u0152", "142": "\u017D", "145": "\u2018", "146": "\u2019", "147": "\u201C", "148": "\u201D", "149": "\u2022", "150": "\u2013", "151": "\u2014", "152": "\u02DC", "153": "\u2122", "154": "\u0161", "155": "\u203A", "156": "\u0153", "158": "\u017E", "159": "\u0178" };
|
|||
|
var invalidReferenceCodePoints = [1, 2, 3, 4, 5, 6, 7, 8, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 64976, 64977, 64978, 64979, 64980, 64981, 64982, 64983, 64984, 64985, 64986, 64987, 64988, 64989, 64990, 64991, 64992, 64993, 64994, 64995, 64996, 64997, 64998, 64999, 65e3, 65001, 65002, 65003, 65004, 65005, 65006, 65007, 65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214, 393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894, 720895, 786430, 786431, 851966, 851967, 917502, 917503, 983038, 983039, 1048574, 1048575, 1114110, 1114111];
|
|||
|
var stringFromCharCode = String.fromCharCode;
|
|||
|
var object = {};
|
|||
|
var hasOwnProperty = object.hasOwnProperty;
|
|||
|
var has = function(object2, propertyName) {
|
|||
|
return hasOwnProperty.call(object2, propertyName);
|
|||
|
};
|
|||
|
var contains = function(array, value) {
|
|||
|
var index = -1;
|
|||
|
var length = array.length;
|
|||
|
while (++index < length) {
|
|||
|
if (array[index] == value) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
};
|
|||
|
var merge = function(options, defaults) {
|
|||
|
if (!options) {
|
|||
|
return defaults;
|
|||
|
}
|
|||
|
var result = {};
|
|||
|
var key2;
|
|||
|
for (key2 in defaults) {
|
|||
|
result[key2] = has(options, key2) ? options[key2] : defaults[key2];
|
|||
|
}
|
|||
|
return result;
|
|||
|
};
|
|||
|
var codePointToSymbol = function(codePoint, strict) {
|
|||
|
var output = "";
|
|||
|
if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) {
|
|||
|
if (strict) {
|
|||
|
parseError("character reference outside the permissible Unicode range");
|
|||
|
}
|
|||
|
return "\uFFFD";
|
|||
|
}
|
|||
|
if (has(decodeMapNumeric, codePoint)) {
|
|||
|
if (strict) {
|
|||
|
parseError("disallowed character reference");
|
|||
|
}
|
|||
|
return decodeMapNumeric[codePoint];
|
|||
|
}
|
|||
|
if (strict && contains(invalidReferenceCodePoints, codePoint)) {
|
|||
|
parseError("disallowed character reference");
|
|||
|
}
|
|||
|
if (codePoint > 65535) {
|
|||
|
codePoint -= 65536;
|
|||
|
output += stringFromCharCode(codePoint >>> 10 & 1023 | 55296);
|
|||
|
codePoint = 56320 | codePoint & 1023;
|
|||
|
}
|
|||
|
output += stringFromCharCode(codePoint);
|
|||
|
return output;
|
|||
|
};
|
|||
|
var hexEscape = function(codePoint) {
|
|||
|
return "&#x" + codePoint.toString(16).toUpperCase() + ";";
|
|||
|
};
|
|||
|
var decEscape = function(codePoint) {
|
|||
|
return "&#" + codePoint + ";";
|
|||
|
};
|
|||
|
var parseError = function(message) {
|
|||
|
throw Error("Parse error: " + message);
|
|||
|
};
|
|||
|
var encode = function(string, options) {
|
|||
|
options = merge(options, encode.options);
|
|||
|
var strict = options.strict;
|
|||
|
if (strict && regexInvalidRawCodePoint.test(string)) {
|
|||
|
parseError("forbidden code point");
|
|||
|
}
|
|||
|
var encodeEverything = options.encodeEverything;
|
|||
|
var useNamedReferences = options.useNamedReferences;
|
|||
|
var allowUnsafeSymbols = options.allowUnsafeSymbols;
|
|||
|
var escapeCodePoint = options.decimal ? decEscape : hexEscape;
|
|||
|
var escapeBmpSymbol = function(symbol) {
|
|||
|
return escapeCodePoint(symbol.charCodeAt(0));
|
|||
|
};
|
|||
|
if (encodeEverything) {
|
|||
|
string = string.replace(regexAsciiWhitelist, function(symbol) {
|
|||
|
if (useNamedReferences && has(encodeMap, symbol)) {
|
|||
|
return "&" + encodeMap[symbol] + ";";
|
|||
|
}
|
|||
|
return escapeBmpSymbol(symbol);
|
|||
|
});
|
|||
|
if (useNamedReferences) {
|
|||
|
string = string.replace(/>\u20D2/g, ">⃒").replace(/<\u20D2/g, "<⃒").replace(/fj/g, "fj");
|
|||
|
}
|
|||
|
if (useNamedReferences) {
|
|||
|
string = string.replace(regexEncodeNonAscii, function(string2) {
|
|||
|
return "&" + encodeMap[string2] + ";";
|
|||
|
});
|
|||
|
}
|
|||
|
} else if (useNamedReferences) {
|
|||
|
if (!allowUnsafeSymbols) {
|
|||
|
string = string.replace(regexEscape, function(string2) {
|
|||
|
return "&" + encodeMap[string2] + ";";
|
|||
|
});
|
|||
|
}
|
|||
|
string = string.replace(/>\u20D2/g, ">⃒").replace(/<\u20D2/g, "<⃒");
|
|||
|
string = string.replace(regexEncodeNonAscii, function(string2) {
|
|||
|
return "&" + encodeMap[string2] + ";";
|
|||
|
});
|
|||
|
} else if (!allowUnsafeSymbols) {
|
|||
|
string = string.replace(regexEscape, escapeBmpSymbol);
|
|||
|
}
|
|||
|
return string.replace(regexAstralSymbols, function($0) {
|
|||
|
var high = $0.charCodeAt(0);
|
|||
|
var low = $0.charCodeAt(1);
|
|||
|
var codePoint = (high - 55296) * 1024 + low - 56320 + 65536;
|
|||
|
return escapeCodePoint(codePoint);
|
|||
|
}).replace(regexBmpWhitelist, escapeBmpSymbol);
|
|||
|
};
|
|||
|
encode.options = {
|
|||
|
"allowUnsafeSymbols": false,
|
|||
|
"encodeEverything": false,
|
|||
|
"strict": false,
|
|||
|
"useNamedReferences": false,
|
|||
|
"decimal": false
|
|||
|
};
|
|||
|
var decode = function(html, options) {
|
|||
|
options = merge(options, decode.options);
|
|||
|
var strict = options.strict;
|
|||
|
if (strict && regexInvalidEntity.test(html)) {
|
|||
|
parseError("malformed character reference");
|
|||
|
}
|
|||
|
return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|||
|
var codePoint;
|
|||
|
var semicolon;
|
|||
|
var decDigits;
|
|||
|
var hexDigits;
|
|||
|
var reference;
|
|||
|
var next;
|
|||
|
if ($1) {
|
|||
|
reference = $1;
|
|||
|
return decodeMap[reference];
|
|||
|
}
|
|||
|
if ($2) {
|
|||
|
reference = $2;
|
|||
|
next = $3;
|
|||
|
if (next && options.isAttributeValue) {
|
|||
|
if (strict && next == "=") {
|
|||
|
parseError("`&` did not start a character reference");
|
|||
|
}
|
|||
|
return $0;
|
|||
|
} else {
|
|||
|
if (strict) {
|
|||
|
parseError("named character reference was not terminated by a semicolon");
|
|||
|
}
|
|||
|
return decodeMapLegacy[reference] + (next || "");
|
|||
|
}
|
|||
|
}
|
|||
|
if ($4) {
|
|||
|
decDigits = $4;
|
|||
|
semicolon = $5;
|
|||
|
if (strict && !semicolon) {
|
|||
|
parseError("character reference was not terminated by a semicolon");
|
|||
|
}
|
|||
|
codePoint = parseInt(decDigits, 10);
|
|||
|
return codePointToSymbol(codePoint, strict);
|
|||
|
}
|
|||
|
if ($6) {
|
|||
|
hexDigits = $6;
|
|||
|
semicolon = $7;
|
|||
|
if (strict && !semicolon) {
|
|||
|
parseError("character reference was not terminated by a semicolon");
|
|||
|
}
|
|||
|
codePoint = parseInt(hexDigits, 16);
|
|||
|
return codePointToSymbol(codePoint, strict);
|
|||
|
}
|
|||
|
if (strict) {
|
|||
|
parseError("named character reference was not terminated by a semicolon");
|
|||
|
}
|
|||
|
return $0;
|
|||
|
});
|
|||
|
};
|
|||
|
decode.options = {
|
|||
|
"isAttributeValue": false,
|
|||
|
"strict": false
|
|||
|
};
|
|||
|
var escape = function(string) {
|
|||
|
return string.replace(regexEscape, function($0) {
|
|||
|
return escapeMap[$0];
|
|||
|
});
|
|||
|
};
|
|||
|
var he = {
|
|||
|
"version": "1.2.0",
|
|||
|
"encode": encode,
|
|||
|
"decode": decode,
|
|||
|
"escape": escape,
|
|||
|
"unescape": decode
|
|||
|
};
|
|||
|
if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
|
|||
|
define(function() {
|
|||
|
return he;
|
|||
|
});
|
|||
|
} else if (freeExports && !freeExports.nodeType) {
|
|||
|
if (freeModule) {
|
|||
|
freeModule.exports = he;
|
|||
|
} else {
|
|||
|
for (var key in he) {
|
|||
|
has(he, key) && (freeExports[key] = he[key]);
|
|||
|
}
|
|||
|
}
|
|||
|
} else {
|
|||
|
root.he = he;
|
|||
|
}
|
|||
|
})(exports);
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/nodes/node.js
|
|||
|
var require_node = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/nodes/node.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
var he_1 = require_he();
|
|||
|
var Node = function() {
|
|||
|
function Node2(parentNode, range) {
|
|||
|
if (parentNode === void 0) {
|
|||
|
parentNode = null;
|
|||
|
}
|
|||
|
this.parentNode = parentNode;
|
|||
|
this.childNodes = [];
|
|||
|
Object.defineProperty(this, "range", {
|
|||
|
enumerable: false,
|
|||
|
writable: true,
|
|||
|
configurable: true,
|
|||
|
value: range !== null && range !== void 0 ? range : [-1, -1]
|
|||
|
});
|
|||
|
}
|
|||
|
Node2.prototype.remove = function() {
|
|||
|
var _this = this;
|
|||
|
if (this.parentNode) {
|
|||
|
var children = this.parentNode.childNodes;
|
|||
|
this.parentNode.childNodes = children.filter(function(child) {
|
|||
|
return _this !== child;
|
|||
|
});
|
|||
|
this.parentNode = null;
|
|||
|
}
|
|||
|
return this;
|
|||
|
};
|
|||
|
Object.defineProperty(Node2.prototype, "innerText", {
|
|||
|
get: function() {
|
|||
|
return this.rawText;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(Node2.prototype, "textContent", {
|
|||
|
get: function() {
|
|||
|
return (0, he_1.decode)(this.rawText);
|
|||
|
},
|
|||
|
set: function(val) {
|
|||
|
this.rawText = (0, he_1.encode)(val);
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return Node2;
|
|||
|
}();
|
|||
|
exports.default = Node;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/nodes/type.js
|
|||
|
var require_type = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/nodes/type.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
var NodeType;
|
|||
|
(function(NodeType2) {
|
|||
|
NodeType2[NodeType2["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
|
|||
|
NodeType2[NodeType2["TEXT_NODE"] = 3] = "TEXT_NODE";
|
|||
|
NodeType2[NodeType2["COMMENT_NODE"] = 8] = "COMMENT_NODE";
|
|||
|
})(NodeType || (NodeType = {}));
|
|||
|
exports.default = NodeType;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/nodes/comment.js
|
|||
|
var require_comment = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/nodes/comment.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __extends = exports && exports.__extends || function() {
|
|||
|
var extendStatics = function(d, b) {
|
|||
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|||
|
d2.__proto__ = b2;
|
|||
|
} || function(d2, b2) {
|
|||
|
for (var p in b2)
|
|||
|
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|||
|
d2[p] = b2[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 = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
var node_1 = __importDefault(require_node());
|
|||
|
var type_1 = __importDefault(require_type());
|
|||
|
var CommentNode = function(_super) {
|
|||
|
__extends(CommentNode2, _super);
|
|||
|
function CommentNode2(rawText, parentNode, range, rawTagName) {
|
|||
|
if (parentNode === void 0) {
|
|||
|
parentNode = null;
|
|||
|
}
|
|||
|
if (rawTagName === void 0) {
|
|||
|
rawTagName = "!--";
|
|||
|
}
|
|||
|
var _this = _super.call(this, parentNode, range) || this;
|
|||
|
_this.rawText = rawText;
|
|||
|
_this.rawTagName = rawTagName;
|
|||
|
_this.nodeType = type_1.default.COMMENT_NODE;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
CommentNode2.prototype.clone = function() {
|
|||
|
return new CommentNode2(this.rawText, null, void 0, this.rawTagName);
|
|||
|
};
|
|||
|
Object.defineProperty(CommentNode2.prototype, "text", {
|
|||
|
get: function() {
|
|||
|
return this.rawText;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
CommentNode2.prototype.toString = function() {
|
|||
|
return "<!--".concat(this.rawText, "-->");
|
|||
|
};
|
|||
|
return CommentNode2;
|
|||
|
}(node_1.default);
|
|||
|
exports.default = CommentNode;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domelementtype/lib/index.js
|
|||
|
var require_lib = __commonJS({
|
|||
|
"node_modules/domelementtype/lib/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
|
|||
|
var ElementType;
|
|||
|
(function(ElementType2) {
|
|||
|
ElementType2["Root"] = "root";
|
|||
|
ElementType2["Text"] = "text";
|
|||
|
ElementType2["Directive"] = "directive";
|
|||
|
ElementType2["Comment"] = "comment";
|
|||
|
ElementType2["Script"] = "script";
|
|||
|
ElementType2["Style"] = "style";
|
|||
|
ElementType2["Tag"] = "tag";
|
|||
|
ElementType2["CDATA"] = "cdata";
|
|||
|
ElementType2["Doctype"] = "doctype";
|
|||
|
})(ElementType = exports.ElementType || (exports.ElementType = {}));
|
|||
|
function isTag(elem) {
|
|||
|
return elem.type === ElementType.Tag || elem.type === ElementType.Script || elem.type === ElementType.Style;
|
|||
|
}
|
|||
|
exports.isTag = isTag;
|
|||
|
exports.Root = ElementType.Root;
|
|||
|
exports.Text = ElementType.Text;
|
|||
|
exports.Directive = ElementType.Directive;
|
|||
|
exports.Comment = ElementType.Comment;
|
|||
|
exports.Script = ElementType.Script;
|
|||
|
exports.Style = ElementType.Style;
|
|||
|
exports.Tag = ElementType.Tag;
|
|||
|
exports.CDATA = ElementType.CDATA;
|
|||
|
exports.Doctype = ElementType.Doctype;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domhandler/lib/node.js
|
|||
|
var require_node2 = __commonJS({
|
|||
|
"node_modules/domhandler/lib/node.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __extends = exports && exports.__extends || function() {
|
|||
|
var extendStatics = function(d, b) {
|
|||
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|||
|
d2.__proto__ = b2;
|
|||
|
} || function(d2, b2) {
|
|||
|
for (var p in b2)
|
|||
|
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|||
|
d2[p] = b2[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 __assign = exports && exports.__assign || function() {
|
|||
|
__assign = Object.assign || function(t) {
|
|||
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|||
|
s = arguments[i];
|
|||
|
for (var p in s)
|
|||
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|||
|
t[p] = s[p];
|
|||
|
}
|
|||
|
return t;
|
|||
|
};
|
|||
|
return __assign.apply(this, arguments);
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.cloneNode = exports.hasChildren = exports.isDocument = exports.isDirective = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = exports.Element = exports.Document = exports.CDATA = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;
|
|||
|
var domelementtype_1 = require_lib();
|
|||
|
var Node = function() {
|
|||
|
function Node2() {
|
|||
|
this.parent = null;
|
|||
|
this.prev = null;
|
|||
|
this.next = null;
|
|||
|
this.startIndex = null;
|
|||
|
this.endIndex = null;
|
|||
|
}
|
|||
|
Object.defineProperty(Node2.prototype, "parentNode", {
|
|||
|
get: function() {
|
|||
|
return this.parent;
|
|||
|
},
|
|||
|
set: function(parent) {
|
|||
|
this.parent = parent;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(Node2.prototype, "previousSibling", {
|
|||
|
get: function() {
|
|||
|
return this.prev;
|
|||
|
},
|
|||
|
set: function(prev) {
|
|||
|
this.prev = prev;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(Node2.prototype, "nextSibling", {
|
|||
|
get: function() {
|
|||
|
return this.next;
|
|||
|
},
|
|||
|
set: function(next) {
|
|||
|
this.next = next;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Node2.prototype.cloneNode = function(recursive) {
|
|||
|
if (recursive === void 0) {
|
|||
|
recursive = false;
|
|||
|
}
|
|||
|
return cloneNode(this, recursive);
|
|||
|
};
|
|||
|
return Node2;
|
|||
|
}();
|
|||
|
exports.Node = Node;
|
|||
|
var DataNode = function(_super) {
|
|||
|
__extends(DataNode2, _super);
|
|||
|
function DataNode2(data) {
|
|||
|
var _this = _super.call(this) || this;
|
|||
|
_this.data = data;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
Object.defineProperty(DataNode2.prototype, "nodeValue", {
|
|||
|
get: function() {
|
|||
|
return this.data;
|
|||
|
},
|
|||
|
set: function(data) {
|
|||
|
this.data = data;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return DataNode2;
|
|||
|
}(Node);
|
|||
|
exports.DataNode = DataNode;
|
|||
|
var Text = function(_super) {
|
|||
|
__extends(Text2, _super);
|
|||
|
function Text2() {
|
|||
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|||
|
_this.type = domelementtype_1.ElementType.Text;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
Object.defineProperty(Text2.prototype, "nodeType", {
|
|||
|
get: function() {
|
|||
|
return 3;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return Text2;
|
|||
|
}(DataNode);
|
|||
|
exports.Text = Text;
|
|||
|
var Comment = function(_super) {
|
|||
|
__extends(Comment2, _super);
|
|||
|
function Comment2() {
|
|||
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|||
|
_this.type = domelementtype_1.ElementType.Comment;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
Object.defineProperty(Comment2.prototype, "nodeType", {
|
|||
|
get: function() {
|
|||
|
return 8;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return Comment2;
|
|||
|
}(DataNode);
|
|||
|
exports.Comment = Comment;
|
|||
|
var ProcessingInstruction = function(_super) {
|
|||
|
__extends(ProcessingInstruction2, _super);
|
|||
|
function ProcessingInstruction2(name, data) {
|
|||
|
var _this = _super.call(this, data) || this;
|
|||
|
_this.name = name;
|
|||
|
_this.type = domelementtype_1.ElementType.Directive;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
Object.defineProperty(ProcessingInstruction2.prototype, "nodeType", {
|
|||
|
get: function() {
|
|||
|
return 1;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return ProcessingInstruction2;
|
|||
|
}(DataNode);
|
|||
|
exports.ProcessingInstruction = ProcessingInstruction;
|
|||
|
var NodeWithChildren = function(_super) {
|
|||
|
__extends(NodeWithChildren2, _super);
|
|||
|
function NodeWithChildren2(children) {
|
|||
|
var _this = _super.call(this) || this;
|
|||
|
_this.children = children;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
Object.defineProperty(NodeWithChildren2.prototype, "firstChild", {
|
|||
|
get: function() {
|
|||
|
var _a;
|
|||
|
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(NodeWithChildren2.prototype, "lastChild", {
|
|||
|
get: function() {
|
|||
|
return this.children.length > 0 ? this.children[this.children.length - 1] : null;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(NodeWithChildren2.prototype, "childNodes", {
|
|||
|
get: function() {
|
|||
|
return this.children;
|
|||
|
},
|
|||
|
set: function(children) {
|
|||
|
this.children = children;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return NodeWithChildren2;
|
|||
|
}(Node);
|
|||
|
exports.NodeWithChildren = NodeWithChildren;
|
|||
|
var CDATA = function(_super) {
|
|||
|
__extends(CDATA2, _super);
|
|||
|
function CDATA2() {
|
|||
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|||
|
_this.type = domelementtype_1.ElementType.CDATA;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
Object.defineProperty(CDATA2.prototype, "nodeType", {
|
|||
|
get: function() {
|
|||
|
return 4;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return CDATA2;
|
|||
|
}(NodeWithChildren);
|
|||
|
exports.CDATA = CDATA;
|
|||
|
var Document = function(_super) {
|
|||
|
__extends(Document2, _super);
|
|||
|
function Document2() {
|
|||
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|||
|
_this.type = domelementtype_1.ElementType.Root;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
Object.defineProperty(Document2.prototype, "nodeType", {
|
|||
|
get: function() {
|
|||
|
return 9;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return Document2;
|
|||
|
}(NodeWithChildren);
|
|||
|
exports.Document = Document;
|
|||
|
var Element = function(_super) {
|
|||
|
__extends(Element2, _super);
|
|||
|
function Element2(name, attribs, children, type) {
|
|||
|
if (children === void 0) {
|
|||
|
children = [];
|
|||
|
}
|
|||
|
if (type === void 0) {
|
|||
|
type = name === "script" ? domelementtype_1.ElementType.Script : name === "style" ? domelementtype_1.ElementType.Style : domelementtype_1.ElementType.Tag;
|
|||
|
}
|
|||
|
var _this = _super.call(this, children) || this;
|
|||
|
_this.name = name;
|
|||
|
_this.attribs = attribs;
|
|||
|
_this.type = type;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
Object.defineProperty(Element2.prototype, "nodeType", {
|
|||
|
get: function() {
|
|||
|
return 1;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(Element2.prototype, "tagName", {
|
|||
|
get: function() {
|
|||
|
return this.name;
|
|||
|
},
|
|||
|
set: function(name) {
|
|||
|
this.name = name;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(Element2.prototype, "attributes", {
|
|||
|
get: function() {
|
|||
|
var _this = this;
|
|||
|
return Object.keys(this.attribs).map(function(name) {
|
|||
|
var _a, _b;
|
|||
|
return {
|
|||
|
name,
|
|||
|
value: _this.attribs[name],
|
|||
|
namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
|
|||
|
prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name]
|
|||
|
};
|
|||
|
});
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
return Element2;
|
|||
|
}(NodeWithChildren);
|
|||
|
exports.Element = Element;
|
|||
|
function isTag(node) {
|
|||
|
return (0, domelementtype_1.isTag)(node);
|
|||
|
}
|
|||
|
exports.isTag = isTag;
|
|||
|
function isCDATA(node) {
|
|||
|
return node.type === domelementtype_1.ElementType.CDATA;
|
|||
|
}
|
|||
|
exports.isCDATA = isCDATA;
|
|||
|
function isText(node) {
|
|||
|
return node.type === domelementtype_1.ElementType.Text;
|
|||
|
}
|
|||
|
exports.isText = isText;
|
|||
|
function isComment(node) {
|
|||
|
return node.type === domelementtype_1.ElementType.Comment;
|
|||
|
}
|
|||
|
exports.isComment = isComment;
|
|||
|
function isDirective(node) {
|
|||
|
return node.type === domelementtype_1.ElementType.Directive;
|
|||
|
}
|
|||
|
exports.isDirective = isDirective;
|
|||
|
function isDocument(node) {
|
|||
|
return node.type === domelementtype_1.ElementType.Root;
|
|||
|
}
|
|||
|
exports.isDocument = isDocument;
|
|||
|
function hasChildren(node) {
|
|||
|
return Object.prototype.hasOwnProperty.call(node, "children");
|
|||
|
}
|
|||
|
exports.hasChildren = hasChildren;
|
|||
|
function cloneNode(node, recursive) {
|
|||
|
if (recursive === void 0) {
|
|||
|
recursive = false;
|
|||
|
}
|
|||
|
var result;
|
|||
|
if (isText(node)) {
|
|||
|
result = new Text(node.data);
|
|||
|
} else if (isComment(node)) {
|
|||
|
result = new Comment(node.data);
|
|||
|
} else if (isTag(node)) {
|
|||
|
var children = recursive ? cloneChildren(node.children) : [];
|
|||
|
var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
|
|||
|
children.forEach(function(child) {
|
|||
|
return child.parent = clone_1;
|
|||
|
});
|
|||
|
if (node.namespace != null) {
|
|||
|
clone_1.namespace = node.namespace;
|
|||
|
}
|
|||
|
if (node["x-attribsNamespace"]) {
|
|||
|
clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
|
|||
|
}
|
|||
|
if (node["x-attribsPrefix"]) {
|
|||
|
clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
|
|||
|
}
|
|||
|
result = clone_1;
|
|||
|
} else if (isCDATA(node)) {
|
|||
|
var children = recursive ? cloneChildren(node.children) : [];
|
|||
|
var clone_2 = new CDATA(children);
|
|||
|
children.forEach(function(child) {
|
|||
|
return child.parent = clone_2;
|
|||
|
});
|
|||
|
result = clone_2;
|
|||
|
} else if (isDocument(node)) {
|
|||
|
var children = recursive ? cloneChildren(node.children) : [];
|
|||
|
var clone_3 = new Document(children);
|
|||
|
children.forEach(function(child) {
|
|||
|
return child.parent = clone_3;
|
|||
|
});
|
|||
|
if (node["x-mode"]) {
|
|||
|
clone_3["x-mode"] = node["x-mode"];
|
|||
|
}
|
|||
|
result = clone_3;
|
|||
|
} else if (isDirective(node)) {
|
|||
|
var instruction = new ProcessingInstruction(node.name, node.data);
|
|||
|
if (node["x-name"] != null) {
|
|||
|
instruction["x-name"] = node["x-name"];
|
|||
|
instruction["x-publicId"] = node["x-publicId"];
|
|||
|
instruction["x-systemId"] = node["x-systemId"];
|
|||
|
}
|
|||
|
result = instruction;
|
|||
|
} else {
|
|||
|
throw new Error("Not implemented yet: ".concat(node.type));
|
|||
|
}
|
|||
|
result.startIndex = node.startIndex;
|
|||
|
result.endIndex = node.endIndex;
|
|||
|
if (node.sourceCodeLocation != null) {
|
|||
|
result.sourceCodeLocation = node.sourceCodeLocation;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
exports.cloneNode = cloneNode;
|
|||
|
function cloneChildren(childs) {
|
|||
|
var children = childs.map(function(child) {
|
|||
|
return cloneNode(child, true);
|
|||
|
});
|
|||
|
for (var i = 1; i < children.length; i++) {
|
|||
|
children[i].prev = children[i - 1];
|
|||
|
children[i - 1].next = children[i];
|
|||
|
}
|
|||
|
return children;
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domhandler/lib/index.js
|
|||
|
var require_lib2 = __commonJS({
|
|||
|
"node_modules/domhandler/lib/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|||
|
desc = { enumerable: true, get: function() {
|
|||
|
return m[k];
|
|||
|
} };
|
|||
|
}
|
|||
|
Object.defineProperty(o, k2, desc);
|
|||
|
} : function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
o[k2] = m[k];
|
|||
|
});
|
|||
|
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|||
|
for (var p in m)
|
|||
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|||
|
__createBinding(exports2, m, p);
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.DomHandler = void 0;
|
|||
|
var domelementtype_1 = require_lib();
|
|||
|
var node_js_1 = require_node2();
|
|||
|
__exportStar(require_node2(), exports);
|
|||
|
var defaultOpts = {
|
|||
|
withStartIndices: false,
|
|||
|
withEndIndices: false,
|
|||
|
xmlMode: false
|
|||
|
};
|
|||
|
var DomHandler = function() {
|
|||
|
function DomHandler2(callback, options, elementCB) {
|
|||
|
this.dom = [];
|
|||
|
this.root = new node_js_1.Document(this.dom);
|
|||
|
this.done = false;
|
|||
|
this.tagStack = [this.root];
|
|||
|
this.lastNode = null;
|
|||
|
this.parser = null;
|
|||
|
if (typeof options === "function") {
|
|||
|
elementCB = options;
|
|||
|
options = defaultOpts;
|
|||
|
}
|
|||
|
if (typeof callback === "object") {
|
|||
|
options = callback;
|
|||
|
callback = void 0;
|
|||
|
}
|
|||
|
this.callback = callback !== null && callback !== void 0 ? callback : null;
|
|||
|
this.options = options !== null && options !== void 0 ? options : defaultOpts;
|
|||
|
this.elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
|
|||
|
}
|
|||
|
DomHandler2.prototype.onparserinit = function(parser) {
|
|||
|
this.parser = parser;
|
|||
|
};
|
|||
|
DomHandler2.prototype.onreset = function() {
|
|||
|
this.dom = [];
|
|||
|
this.root = new node_js_1.Document(this.dom);
|
|||
|
this.done = false;
|
|||
|
this.tagStack = [this.root];
|
|||
|
this.lastNode = null;
|
|||
|
this.parser = null;
|
|||
|
};
|
|||
|
DomHandler2.prototype.onend = function() {
|
|||
|
if (this.done)
|
|||
|
return;
|
|||
|
this.done = true;
|
|||
|
this.parser = null;
|
|||
|
this.handleCallback(null);
|
|||
|
};
|
|||
|
DomHandler2.prototype.onerror = function(error) {
|
|||
|
this.handleCallback(error);
|
|||
|
};
|
|||
|
DomHandler2.prototype.onclosetag = function() {
|
|||
|
this.lastNode = null;
|
|||
|
var elem = this.tagStack.pop();
|
|||
|
if (this.options.withEndIndices) {
|
|||
|
elem.endIndex = this.parser.endIndex;
|
|||
|
}
|
|||
|
if (this.elementCB)
|
|||
|
this.elementCB(elem);
|
|||
|
};
|
|||
|
DomHandler2.prototype.onopentag = function(name, attribs) {
|
|||
|
var type = this.options.xmlMode ? domelementtype_1.ElementType.Tag : void 0;
|
|||
|
var element = new node_js_1.Element(name, attribs, void 0, type);
|
|||
|
this.addNode(element);
|
|||
|
this.tagStack.push(element);
|
|||
|
};
|
|||
|
DomHandler2.prototype.ontext = function(data) {
|
|||
|
var lastNode = this.lastNode;
|
|||
|
if (lastNode && lastNode.type === domelementtype_1.ElementType.Text) {
|
|||
|
lastNode.data += data;
|
|||
|
if (this.options.withEndIndices) {
|
|||
|
lastNode.endIndex = this.parser.endIndex;
|
|||
|
}
|
|||
|
} else {
|
|||
|
var node = new node_js_1.Text(data);
|
|||
|
this.addNode(node);
|
|||
|
this.lastNode = node;
|
|||
|
}
|
|||
|
};
|
|||
|
DomHandler2.prototype.oncomment = function(data) {
|
|||
|
if (this.lastNode && this.lastNode.type === domelementtype_1.ElementType.Comment) {
|
|||
|
this.lastNode.data += data;
|
|||
|
return;
|
|||
|
}
|
|||
|
var node = new node_js_1.Comment(data);
|
|||
|
this.addNode(node);
|
|||
|
this.lastNode = node;
|
|||
|
};
|
|||
|
DomHandler2.prototype.oncommentend = function() {
|
|||
|
this.lastNode = null;
|
|||
|
};
|
|||
|
DomHandler2.prototype.oncdatastart = function() {
|
|||
|
var text = new node_js_1.Text("");
|
|||
|
var node = new node_js_1.CDATA([text]);
|
|||
|
this.addNode(node);
|
|||
|
text.parent = node;
|
|||
|
this.lastNode = text;
|
|||
|
};
|
|||
|
DomHandler2.prototype.oncdataend = function() {
|
|||
|
this.lastNode = null;
|
|||
|
};
|
|||
|
DomHandler2.prototype.onprocessinginstruction = function(name, data) {
|
|||
|
var node = new node_js_1.ProcessingInstruction(name, data);
|
|||
|
this.addNode(node);
|
|||
|
};
|
|||
|
DomHandler2.prototype.handleCallback = function(error) {
|
|||
|
if (typeof this.callback === "function") {
|
|||
|
this.callback(error, this.dom);
|
|||
|
} else if (error) {
|
|||
|
throw error;
|
|||
|
}
|
|||
|
};
|
|||
|
DomHandler2.prototype.addNode = function(node) {
|
|||
|
var parent = this.tagStack[this.tagStack.length - 1];
|
|||
|
var previousSibling = parent.children[parent.children.length - 1];
|
|||
|
if (this.options.withStartIndices) {
|
|||
|
node.startIndex = this.parser.startIndex;
|
|||
|
}
|
|||
|
if (this.options.withEndIndices) {
|
|||
|
node.endIndex = this.parser.endIndex;
|
|||
|
}
|
|||
|
parent.children.push(node);
|
|||
|
if (previousSibling) {
|
|||
|
node.prev = previousSibling;
|
|||
|
previousSibling.next = node;
|
|||
|
}
|
|||
|
node.parent = parent;
|
|||
|
this.lastNode = null;
|
|||
|
};
|
|||
|
return DomHandler2;
|
|||
|
}();
|
|||
|
exports.DomHandler = DomHandler;
|
|||
|
exports.default = DomHandler;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/entities/lib/generated/decode-data-html.js
|
|||
|
var require_decode_data_html = __commonJS({
|
|||
|
"node_modules/entities/lib/generated/decode-data-html.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.default = new Uint16Array('\u1D41<\xD5\u0131\u028A\u049D\u057B\u05D0\u0675\u06DE\u07A2\u07D6\u080F\u0A4A\u0A91\u0DA1\u0E6D\u0F09\u0F26\u10CA\u1228\u12E1\u1415\u149D\u14C3\u14DF\u1525\0\0\0\0\0\0\u156B\u16CD\u198D\u1C12\u1DDD\u1F7E\u2060\u21B0\u228D\u23C0\u23FB\u2442\u2824\u2912\u2D08\u2E48\u2FCE\u3016\u32BA\u3639\u37AC\u38FE\u3A28\u3A71\u3AE0\u3B2E\u0800EMabcfglmnoprstu\\bfms\x7F\x84\x8B\x90\x95\x98\xA6\xB3\xB9\xC8\xCFlig\u803B\xC6\u40C6P\u803B&\u4026cute\u803B\xC1\u40C1reve;\u4102\u0100iyx}rc\u803B\xC2\u40C2;\u4410r;\uC000\u{1D504}rave\u803B\xC0\u40C0pha;\u4391acr;\u4100d;\u6A53\u0100gp\x9D\xA1on;\u4104f;\uC000\u{1D538}plyFunction;\u6061ing\u803B\xC5\u40C5\u0100cs\xBE\xC3r;\uC000\u{1D49C}ign;\u6254ilde\u803B\xC3\u40C3ml\u803B\xC4\u40C4\u0400aceforsu\xE5\xFB\xFE\u0117\u011C\u0122\u0127\u012A\u0100cr\xEA\xF2kslash;\u6216\u0176\xF6\xF8;\u6AE7ed;\u6306y;\u4411\u0180crt\u0105\u010B\u0114ause;\u6235noullis;\u612Ca;\u4392r;\uC000\u{1D505}pf;\uC000\u{1D539}eve;\u42D8c\xF2\u0113mpeq;\u624E\u0700HOacdefhilorsu\u014D\u0151\u0156\u0180\u019E\u01A2\u01B5\u01B7\u01BA\u01DC\u0215\u0273\u0278\u027Ecy;\u4427PY\u803B\xA9\u40A9\u0180cpy\u015D\u0162\u017Aute;\u4106\u0100;i\u0167\u0168\u62D2talDifferentialD;\u6145leys;\u612D\u0200aeio\u0189\u018E\u0194\u0198ron;\u410Cdil\u803B\xC7\u40C7rc;\u4108nint;\u6230ot;\u410A\u0100dn\u01A7\u01ADilla;\u40B8terDot;\u40B7\xF2\u017Fi;\u43A7rcle\u0200DMPT\u01C7\u01CB\u01D1\u01D6ot;\u6299inus;\u6296lus;\u6295imes;\u6297o\u0100cs\u01E2\u01F8kwiseContourIntegral;\u6232eCurly\u0100DQ\u0203\u020FoubleQuote;\u601Duote;\u6019\u0200lnpu\u021E\u0228\u0247\u0255on\u0100;e\u0225\u0226\u6237;\u6A74\u0180git\u022F\u0236\u023Aruent;\u6261nt;\u622FourIntegral;\u622E\u0100fr\u024C\u024E;\u6102oduct;\u6210nterClockwiseContourIntegral;\u6233oss;\u6A2Fcr;\uC000\u{1D49E}p\u0100;C\u0284\u0285\u62D3ap;\u624D\u0580DJSZacefios\u02A0\u02AC\u02B0\u02B4\u02B8\u02CB\u02D7\u02E1\u02E6\u0333\u048D\u0100;o\u0179\u02A5trahd;\u6911cy;\u4402cy;\u4405cy;\u440F\u0180grs\u02BF\u02C4\u02C7ger;\u6021r;\u61A1hv;\u6AE4\u0100ay\u02D0\u02D5ron;\u410E;\u4414l\u0100;t\u02DD\u02DE\u6207a;\u4394r;\uC000\u{1D507}\u0100af\u02EB\u0327\u0100cm\u02F0\u0322ritical\u0200ADGT\u0300\u0306\u0316\u031Ccute;\u40B4o\u0174\u030B\u030D;\u42D9bleAcute;\u42DDrave;\u4060ilde;\u42DCond;\u62C4ferentialD;\u6146\u0470\u033D\0\0\0\u0342\u0354\0\u0405f;\uC000\u{1D53B}\u0180;DE\u0348\u0349\u034D\u40A8ot;\u60DCqual;\u6250ble\u0300CDLRUV\u0363\u0372\u0382\u03CF\u03E2\u03F8ontourIntegra\xEC\u0239o\u0274\u0379\0\0\u037B\xBB\u0349nArrow;\u61D3\u0100eo\u0387\u03A4ft\u0180ART\u0390\u0396\u03A1rrow;\u61D0ightArrow;\u61D4e\xE5\u02CAng\u0100LR\u03AB\u03C4eft\u0100AR\u03B3\u03B9rrow;\u67F8ightArrow;\u67FAightArrow;\u67F9ight\u0100AT\u03D8\u03DErrow;\u61D2ee;\u62A8p\u0241\u03E9\0\0\u03EFrrow;\u61D1ownArrow;\u61D5erticalBar;\u6225n\u0300ABLRTa\u0412\u042A\u0430\u045E\u047F\u037Crrow\u0180;BU\u041D\u041E\u0422\u6193ar;\u6913pArrow;\u61F5reve;\u4311eft\u02D2\u043A\0\u0446\0\u0450ightVector;\u6950eeVector;\u695Eector\u0100;B\u0459\u045A\u61BDar;\u6956ight\u01D4\u0467\0\u0471eeVector;\u695Fector\u0100;B\u047A\u047B\u61C1ar;\u6957ee\u0100;A\u0486\u0487\u62A4rrow;\u61A7\u0100ct\u0492\u0497r;\uC000\u{1D49F}rok;\u4110\u0800NTacdfglmopqstux\u04BD\u04C0\u04C4\u04CB\u04DE\u04E2\u04E7\u04EE\u04F5\u0521\u052F\u0536\u0552\u055D\u0560\u0565G;\u414AH\u803B\xD0\u40D0cute\u803B\xC9\u40C9\u0180aiy\u04D2\u04D7\u04DCron;\u411Arc\u803B\xCA\u40CA;\u442Dot;\u4116r;\uC000\u{1D508}rave\u803B\xC8\u40C8ement;\u6208\u0100ap\u04FA\u04FEcr;\u4112ty\u0253\u0506\0\0\u0512mallSquare;\u65FBerySmallSquare;\u65AB\u0100gp\u0526\u052Aon;\u4118f;\uC000\u{1D53C}silon;\u4395u\u0100ai\u053C\u0549l\u0100;T\u0542\u0543\u6A75ilde;\u6242librium;\u61CC\u0100ci\u0557\u055Ar;\u6130m;\u6A73a;\u4397ml\u803B\xCB\u40CB\u0100ip\u056A\u056Fsts;\u6203onentialE;\u6147\u0280cfios\u0585\u0588\u058D\u05B2\u05CCy;\u4424r;\uC000\u{1D509}lled\u0253\u0597\0\0\u05A3mallSquare;\u65FCerySmallSquare;\u65AA\u0370\u05BA\0\u05BF\0\0\u05C4f;\uC000\u{1D53D}All;\u6200riertrf;\u6131c\xF2\u05CB\u0600JTabcdfgorst\u05E8\u05EC\u05EF\u05FA\u0600\u0612\u061
|
|||
|
return c.charCodeAt(0);
|
|||
|
}));
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/entities/lib/generated/decode-data-xml.js
|
|||
|
var require_decode_data_xml = __commonJS({
|
|||
|
"node_modules/entities/lib/generated/decode-data-xml.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.default = new Uint16Array("\u0200aglq \x1B\u026D\0\0p;\u4026os;\u4027t;\u403Et;\u403Cuot;\u4022".split("").map(function(c) {
|
|||
|
return c.charCodeAt(0);
|
|||
|
}));
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/entities/lib/decode_codepoint.js
|
|||
|
var require_decode_codepoint = __commonJS({
|
|||
|
"node_modules/entities/lib/decode_codepoint.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var _a;
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.replaceCodePoint = exports.fromCodePoint = void 0;
|
|||
|
var decodeMap = /* @__PURE__ */ new Map([
|
|||
|
[0, 65533],
|
|||
|
[128, 8364],
|
|||
|
[130, 8218],
|
|||
|
[131, 402],
|
|||
|
[132, 8222],
|
|||
|
[133, 8230],
|
|||
|
[134, 8224],
|
|||
|
[135, 8225],
|
|||
|
[136, 710],
|
|||
|
[137, 8240],
|
|||
|
[138, 352],
|
|||
|
[139, 8249],
|
|||
|
[140, 338],
|
|||
|
[142, 381],
|
|||
|
[145, 8216],
|
|||
|
[146, 8217],
|
|||
|
[147, 8220],
|
|||
|
[148, 8221],
|
|||
|
[149, 8226],
|
|||
|
[150, 8211],
|
|||
|
[151, 8212],
|
|||
|
[152, 732],
|
|||
|
[153, 8482],
|
|||
|
[154, 353],
|
|||
|
[155, 8250],
|
|||
|
[156, 339],
|
|||
|
[158, 382],
|
|||
|
[159, 376]
|
|||
|
]);
|
|||
|
exports.fromCodePoint = (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : function(codePoint) {
|
|||
|
var output = "";
|
|||
|
if (codePoint > 65535) {
|
|||
|
codePoint -= 65536;
|
|||
|
output += String.fromCharCode(codePoint >>> 10 & 1023 | 55296);
|
|||
|
codePoint = 56320 | codePoint & 1023;
|
|||
|
}
|
|||
|
output += String.fromCharCode(codePoint);
|
|||
|
return output;
|
|||
|
};
|
|||
|
function replaceCodePoint(codePoint) {
|
|||
|
var _a2;
|
|||
|
if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) {
|
|||
|
return 65533;
|
|||
|
}
|
|||
|
return (_a2 = decodeMap.get(codePoint)) !== null && _a2 !== void 0 ? _a2 : codePoint;
|
|||
|
}
|
|||
|
exports.replaceCodePoint = replaceCodePoint;
|
|||
|
function decodeCodePoint(codePoint) {
|
|||
|
return (0, exports.fromCodePoint)(replaceCodePoint(codePoint));
|
|||
|
}
|
|||
|
exports.default = decodeCodePoint;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/entities/lib/decode.js
|
|||
|
var require_decode = __commonJS({
|
|||
|
"node_modules/entities/lib/decode.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|||
|
desc = { enumerable: true, get: function() {
|
|||
|
return m[k];
|
|||
|
} };
|
|||
|
}
|
|||
|
Object.defineProperty(o, k2, desc);
|
|||
|
} : function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
o[k2] = m[k];
|
|||
|
});
|
|||
|
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|||
|
} : function(o, v) {
|
|||
|
o["default"] = v;
|
|||
|
});
|
|||
|
var __importStar = exports && exports.__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 __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.decodeXML = exports.decodeHTMLStrict = exports.decodeHTMLAttribute = exports.decodeHTML = exports.determineBranch = exports.EntityDecoder = exports.DecodingMode = exports.BinTrieFlags = exports.fromCodePoint = exports.replaceCodePoint = exports.decodeCodePoint = exports.xmlDecodeTree = exports.htmlDecodeTree = void 0;
|
|||
|
var decode_data_html_js_1 = __importDefault(require_decode_data_html());
|
|||
|
exports.htmlDecodeTree = decode_data_html_js_1.default;
|
|||
|
var decode_data_xml_js_1 = __importDefault(require_decode_data_xml());
|
|||
|
exports.xmlDecodeTree = decode_data_xml_js_1.default;
|
|||
|
var decode_codepoint_js_1 = __importStar(require_decode_codepoint());
|
|||
|
exports.decodeCodePoint = decode_codepoint_js_1.default;
|
|||
|
var decode_codepoint_js_2 = require_decode_codepoint();
|
|||
|
Object.defineProperty(exports, "replaceCodePoint", { enumerable: true, get: function() {
|
|||
|
return decode_codepoint_js_2.replaceCodePoint;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "fromCodePoint", { enumerable: true, get: function() {
|
|||
|
return decode_codepoint_js_2.fromCodePoint;
|
|||
|
} });
|
|||
|
var CharCodes;
|
|||
|
(function(CharCodes2) {
|
|||
|
CharCodes2[CharCodes2["NUM"] = 35] = "NUM";
|
|||
|
CharCodes2[CharCodes2["SEMI"] = 59] = "SEMI";
|
|||
|
CharCodes2[CharCodes2["EQUALS"] = 61] = "EQUALS";
|
|||
|
CharCodes2[CharCodes2["ZERO"] = 48] = "ZERO";
|
|||
|
CharCodes2[CharCodes2["NINE"] = 57] = "NINE";
|
|||
|
CharCodes2[CharCodes2["LOWER_A"] = 97] = "LOWER_A";
|
|||
|
CharCodes2[CharCodes2["LOWER_F"] = 102] = "LOWER_F";
|
|||
|
CharCodes2[CharCodes2["LOWER_X"] = 120] = "LOWER_X";
|
|||
|
CharCodes2[CharCodes2["LOWER_Z"] = 122] = "LOWER_Z";
|
|||
|
CharCodes2[CharCodes2["UPPER_A"] = 65] = "UPPER_A";
|
|||
|
CharCodes2[CharCodes2["UPPER_F"] = 70] = "UPPER_F";
|
|||
|
CharCodes2[CharCodes2["UPPER_Z"] = 90] = "UPPER_Z";
|
|||
|
})(CharCodes || (CharCodes = {}));
|
|||
|
var TO_LOWER_BIT = 32;
|
|||
|
var BinTrieFlags;
|
|||
|
(function(BinTrieFlags2) {
|
|||
|
BinTrieFlags2[BinTrieFlags2["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
|
|||
|
BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
|
|||
|
BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
|
|||
|
})(BinTrieFlags = exports.BinTrieFlags || (exports.BinTrieFlags = {}));
|
|||
|
function isNumber(code) {
|
|||
|
return code >= CharCodes.ZERO && code <= CharCodes.NINE;
|
|||
|
}
|
|||
|
function isHexadecimalCharacter(code) {
|
|||
|
return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F;
|
|||
|
}
|
|||
|
function isAsciiAlphaNumeric(code) {
|
|||
|
return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber(code);
|
|||
|
}
|
|||
|
function isEntityInAttributeInvalidEnd(code) {
|
|||
|
return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
|
|||
|
}
|
|||
|
var EntityDecoderState;
|
|||
|
(function(EntityDecoderState2) {
|
|||
|
EntityDecoderState2[EntityDecoderState2["EntityStart"] = 0] = "EntityStart";
|
|||
|
EntityDecoderState2[EntityDecoderState2["NumericStart"] = 1] = "NumericStart";
|
|||
|
EntityDecoderState2[EntityDecoderState2["NumericDecimal"] = 2] = "NumericDecimal";
|
|||
|
EntityDecoderState2[EntityDecoderState2["NumericHex"] = 3] = "NumericHex";
|
|||
|
EntityDecoderState2[EntityDecoderState2["NamedEntity"] = 4] = "NamedEntity";
|
|||
|
})(EntityDecoderState || (EntityDecoderState = {}));
|
|||
|
var DecodingMode;
|
|||
|
(function(DecodingMode2) {
|
|||
|
DecodingMode2[DecodingMode2["Legacy"] = 0] = "Legacy";
|
|||
|
DecodingMode2[DecodingMode2["Strict"] = 1] = "Strict";
|
|||
|
DecodingMode2[DecodingMode2["Attribute"] = 2] = "Attribute";
|
|||
|
})(DecodingMode = exports.DecodingMode || (exports.DecodingMode = {}));
|
|||
|
var EntityDecoder = function() {
|
|||
|
function EntityDecoder2(decodeTree, emitCodePoint, errors) {
|
|||
|
this.decodeTree = decodeTree;
|
|||
|
this.emitCodePoint = emitCodePoint;
|
|||
|
this.errors = errors;
|
|||
|
this.state = EntityDecoderState.EntityStart;
|
|||
|
this.consumed = 1;
|
|||
|
this.result = 0;
|
|||
|
this.treeIndex = 0;
|
|||
|
this.excess = 1;
|
|||
|
this.decodeMode = DecodingMode.Strict;
|
|||
|
}
|
|||
|
EntityDecoder2.prototype.startEntity = function(decodeMode) {
|
|||
|
this.decodeMode = decodeMode;
|
|||
|
this.state = EntityDecoderState.EntityStart;
|
|||
|
this.result = 0;
|
|||
|
this.treeIndex = 0;
|
|||
|
this.excess = 1;
|
|||
|
this.consumed = 1;
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.write = function(str, offset) {
|
|||
|
switch (this.state) {
|
|||
|
case EntityDecoderState.EntityStart: {
|
|||
|
if (str.charCodeAt(offset) === CharCodes.NUM) {
|
|||
|
this.state = EntityDecoderState.NumericStart;
|
|||
|
this.consumed += 1;
|
|||
|
return this.stateNumericStart(str, offset + 1);
|
|||
|
}
|
|||
|
this.state = EntityDecoderState.NamedEntity;
|
|||
|
return this.stateNamedEntity(str, offset);
|
|||
|
}
|
|||
|
case EntityDecoderState.NumericStart: {
|
|||
|
return this.stateNumericStart(str, offset);
|
|||
|
}
|
|||
|
case EntityDecoderState.NumericDecimal: {
|
|||
|
return this.stateNumericDecimal(str, offset);
|
|||
|
}
|
|||
|
case EntityDecoderState.NumericHex: {
|
|||
|
return this.stateNumericHex(str, offset);
|
|||
|
}
|
|||
|
case EntityDecoderState.NamedEntity: {
|
|||
|
return this.stateNamedEntity(str, offset);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.stateNumericStart = function(str, offset) {
|
|||
|
if (offset >= str.length) {
|
|||
|
return -1;
|
|||
|
}
|
|||
|
if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
|
|||
|
this.state = EntityDecoderState.NumericHex;
|
|||
|
this.consumed += 1;
|
|||
|
return this.stateNumericHex(str, offset + 1);
|
|||
|
}
|
|||
|
this.state = EntityDecoderState.NumericDecimal;
|
|||
|
return this.stateNumericDecimal(str, offset);
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.addToNumericResult = function(str, start, end, base) {
|
|||
|
if (start !== end) {
|
|||
|
var digitCount = end - start;
|
|||
|
this.result = this.result * Math.pow(base, digitCount) + parseInt(str.substr(start, digitCount), base);
|
|||
|
this.consumed += digitCount;
|
|||
|
}
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.stateNumericHex = function(str, offset) {
|
|||
|
var startIdx = offset;
|
|||
|
while (offset < str.length) {
|
|||
|
var char = str.charCodeAt(offset);
|
|||
|
if (isNumber(char) || isHexadecimalCharacter(char)) {
|
|||
|
offset += 1;
|
|||
|
} else {
|
|||
|
this.addToNumericResult(str, startIdx, offset, 16);
|
|||
|
return this.emitNumericEntity(char, 3);
|
|||
|
}
|
|||
|
}
|
|||
|
this.addToNumericResult(str, startIdx, offset, 16);
|
|||
|
return -1;
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.stateNumericDecimal = function(str, offset) {
|
|||
|
var startIdx = offset;
|
|||
|
while (offset < str.length) {
|
|||
|
var char = str.charCodeAt(offset);
|
|||
|
if (isNumber(char)) {
|
|||
|
offset += 1;
|
|||
|
} else {
|
|||
|
this.addToNumericResult(str, startIdx, offset, 10);
|
|||
|
return this.emitNumericEntity(char, 2);
|
|||
|
}
|
|||
|
}
|
|||
|
this.addToNumericResult(str, startIdx, offset, 10);
|
|||
|
return -1;
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.emitNumericEntity = function(lastCp, expectedLength) {
|
|||
|
var _a;
|
|||
|
if (this.consumed <= expectedLength) {
|
|||
|
(_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|||
|
return 0;
|
|||
|
}
|
|||
|
if (lastCp === CharCodes.SEMI) {
|
|||
|
this.consumed += 1;
|
|||
|
} else if (this.decodeMode === DecodingMode.Strict) {
|
|||
|
return 0;
|
|||
|
}
|
|||
|
this.emitCodePoint((0, decode_codepoint_js_1.replaceCodePoint)(this.result), this.consumed);
|
|||
|
if (this.errors) {
|
|||
|
if (lastCp !== CharCodes.SEMI) {
|
|||
|
this.errors.missingSemicolonAfterCharacterReference();
|
|||
|
}
|
|||
|
this.errors.validateNumericCharacterReference(this.result);
|
|||
|
}
|
|||
|
return this.consumed;
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.stateNamedEntity = function(str, offset) {
|
|||
|
var decodeTree = this.decodeTree;
|
|||
|
var current = decodeTree[this.treeIndex];
|
|||
|
var valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|||
|
for (; offset < str.length; offset++, this.excess++) {
|
|||
|
var char = str.charCodeAt(offset);
|
|||
|
this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
|
|||
|
if (this.treeIndex < 0) {
|
|||
|
return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
|
|||
|
}
|
|||
|
current = decodeTree[this.treeIndex];
|
|||
|
valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|||
|
if (valueLength !== 0) {
|
|||
|
if (char === CharCodes.SEMI) {
|
|||
|
return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
|
|||
|
}
|
|||
|
if (this.decodeMode !== DecodingMode.Strict) {
|
|||
|
this.result = this.treeIndex;
|
|||
|
this.consumed += this.excess;
|
|||
|
this.excess = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return -1;
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.emitNotTerminatedNamedEntity = function() {
|
|||
|
var _a;
|
|||
|
var _b = this, result = _b.result, decodeTree = _b.decodeTree;
|
|||
|
var valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|||
|
this.emitNamedEntityData(result, valueLength, this.consumed);
|
|||
|
(_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
|
|||
|
return this.consumed;
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.emitNamedEntityData = function(result, valueLength, consumed) {
|
|||
|
var decodeTree = this.decodeTree;
|
|||
|
this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH : decodeTree[result + 1], consumed);
|
|||
|
if (valueLength === 3) {
|
|||
|
this.emitCodePoint(decodeTree[result + 2], consumed);
|
|||
|
}
|
|||
|
return consumed;
|
|||
|
};
|
|||
|
EntityDecoder2.prototype.end = function() {
|
|||
|
var _a;
|
|||
|
switch (this.state) {
|
|||
|
case EntityDecoderState.NamedEntity: {
|
|||
|
return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
|
|||
|
}
|
|||
|
case EntityDecoderState.NumericDecimal: {
|
|||
|
return this.emitNumericEntity(0, 2);
|
|||
|
}
|
|||
|
case EntityDecoderState.NumericHex: {
|
|||
|
return this.emitNumericEntity(0, 3);
|
|||
|
}
|
|||
|
case EntityDecoderState.NumericStart: {
|
|||
|
(_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|||
|
return 0;
|
|||
|
}
|
|||
|
case EntityDecoderState.EntityStart: {
|
|||
|
return 0;
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
return EntityDecoder2;
|
|||
|
}();
|
|||
|
exports.EntityDecoder = EntityDecoder;
|
|||
|
function getDecoder(decodeTree) {
|
|||
|
var ret = "";
|
|||
|
var decoder = new EntityDecoder(decodeTree, function(str) {
|
|||
|
return ret += (0, decode_codepoint_js_1.fromCodePoint)(str);
|
|||
|
});
|
|||
|
return function decodeWithTrie(str, decodeMode) {
|
|||
|
var lastIndex = 0;
|
|||
|
var offset = 0;
|
|||
|
while ((offset = str.indexOf("&", offset)) >= 0) {
|
|||
|
ret += str.slice(lastIndex, offset);
|
|||
|
decoder.startEntity(decodeMode);
|
|||
|
var len = decoder.write(str, offset + 1);
|
|||
|
if (len < 0) {
|
|||
|
lastIndex = offset + decoder.end();
|
|||
|
break;
|
|||
|
}
|
|||
|
lastIndex = offset + len;
|
|||
|
offset = len === 0 ? lastIndex + 1 : lastIndex;
|
|||
|
}
|
|||
|
var result = ret + str.slice(lastIndex);
|
|||
|
ret = "";
|
|||
|
return result;
|
|||
|
};
|
|||
|
}
|
|||
|
function determineBranch(decodeTree, current, nodeIdx, char) {
|
|||
|
var branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|||
|
var jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|||
|
if (branchCount === 0) {
|
|||
|
return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
|
|||
|
}
|
|||
|
if (jumpOffset) {
|
|||
|
var value = char - jumpOffset;
|
|||
|
return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIdx + value] - 1;
|
|||
|
}
|
|||
|
var lo = nodeIdx;
|
|||
|
var hi = lo + branchCount - 1;
|
|||
|
while (lo <= hi) {
|
|||
|
var mid = lo + hi >>> 1;
|
|||
|
var midVal = decodeTree[mid];
|
|||
|
if (midVal < char) {
|
|||
|
lo = mid + 1;
|
|||
|
} else if (midVal > char) {
|
|||
|
hi = mid - 1;
|
|||
|
} else {
|
|||
|
return decodeTree[mid + branchCount];
|
|||
|
}
|
|||
|
}
|
|||
|
return -1;
|
|||
|
}
|
|||
|
exports.determineBranch = determineBranch;
|
|||
|
var htmlDecoder = getDecoder(decode_data_html_js_1.default);
|
|||
|
var xmlDecoder = getDecoder(decode_data_xml_js_1.default);
|
|||
|
function decodeHTML(str, mode) {
|
|||
|
if (mode === void 0) {
|
|||
|
mode = DecodingMode.Legacy;
|
|||
|
}
|
|||
|
return htmlDecoder(str, mode);
|
|||
|
}
|
|||
|
exports.decodeHTML = decodeHTML;
|
|||
|
function decodeHTMLAttribute(str) {
|
|||
|
return htmlDecoder(str, DecodingMode.Attribute);
|
|||
|
}
|
|||
|
exports.decodeHTMLAttribute = decodeHTMLAttribute;
|
|||
|
function decodeHTMLStrict(str) {
|
|||
|
return htmlDecoder(str, DecodingMode.Strict);
|
|||
|
}
|
|||
|
exports.decodeHTMLStrict = decodeHTMLStrict;
|
|||
|
function decodeXML(str) {
|
|||
|
return xmlDecoder(str, DecodingMode.Strict);
|
|||
|
}
|
|||
|
exports.decodeXML = decodeXML;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/entities/lib/generated/encode-html.js
|
|||
|
var require_encode_html = __commonJS({
|
|||
|
"node_modules/entities/lib/generated/encode-html.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
function restoreDiff(arr) {
|
|||
|
for (var i = 1; i < arr.length; i++) {
|
|||
|
arr[i][0] += arr[i - 1][0] + 1;
|
|||
|
}
|
|||
|
return arr;
|
|||
|
}
|
|||
|
exports.default = new Map(/* @__PURE__ */ restoreDiff([[9, "	"], [0, "
"], [22, "!"], [0, """], [0, "#"], [0, "$"], [0, "%"], [0, "&"], [0, "'"], [0, "("], [0, ")"], [0, "*"], [0, "+"], [0, ","], [1, "."], [0, "/"], [10, ":"], [0, ";"], [0, { v: "<", n: 8402, o: "<⃒" }], [0, { v: "=", n: 8421, o: "=⃥" }], [0, { v: ">", n: 8402, o: ">⃒" }], [0, "?"], [0, "@"], [26, "["], [0, "\"], [0, "]"], [0, "^"], [0, "_"], [0, "`"], [5, { n: 106, o: "fj" }], [20, "{"], [0, "|"], [0, "}"], [34, " "], [0, "¡"], [0, "¢"], [0, "£"], [0, "¤"], [0, "¥"], [0, "¦"], [0, "§"], [0, "¨"], [0, "©"], [0, "ª"], [0, "«"], [0, "¬"], [0, "­"], [0, "®"], [0, "¯"], [0, "°"], [0, "±"], [0, "²"], [0, "³"], [0, "´"], [0, "µ"], [0, "¶"], [0, "·"], [0, "¸"], [0, "¹"], [0, "º"], [0, "»"], [0, "¼"], [0, "½"], [0, "¾"], [0, "¿"], [0, "À"], [0, "Á"], [0, "Â"], [0, "Ã"], [0, "Ä"], [0, "Å"], [0, "Æ"], [0, "Ç"], [0, "È"], [0, "É"], [0, "Ê"], [0, "Ë"], [0, "Ì"], [0, "Í"], [0, "Î"], [0, "Ï"], [0, "Ð"], [0, "Ñ"], [0, "Ò"], [0, "Ó"], [0, "Ô"], [0, "Õ"], [0, "Ö"], [0, "×"], [0, "Ø"], [0, "Ù"], [0, "Ú"], [0, "Û"], [0, "Ü"], [0, "Ý"], [0, "Þ"], [0, "ß"], [0, "à"], [0, "á"], [0, "â"], [0, "ã"], [0, "ä"], [0, "å"], [0, "æ"], [0, "ç"], [0, "è"], [0, "é"], [0, "ê"], [0, "ë"], [0, "ì"], [0, "í"], [0, "î"], [0, "ï"], [0, "ð"], [0, "ñ"], [0, "ò"], [0, "ó"], [0, "ô"], [0, "õ"], [0, "ö"], [0, "÷"], [0, "ø"], [0, "ù"], [0, "ú"], [0, "û"], [0, "ü"], [0, "ý"], [0, "þ"], [0, "ÿ"], [0, "Ā"], [0, "ā"], [0, "Ă"], [0, "ă"], [0, "Ą"], [0, "ą"], [0, "Ć"], [0, "ć"], [0, "Ĉ"], [0, "ĉ"], [0, "Ċ"], [0, "ċ"], [0, "Č"], [0, "č"], [0, "Ď"], [0, "ď"], [0, "Đ"], [0, "đ"], [0, "Ē"], [0, "ē"], [2, "Ė"], [0, "ė"], [0, "Ę"], [0, "ę"], [0, "Ě"], [0, "ě"], [0, "Ĝ"], [0, "ĝ"], [0, "Ğ"], [0, "ğ"], [0, "Ġ"], [0, "ġ"], [0, "Ģ"], [1, "Ĥ"], [0, "ĥ"], [0, "Ħ"], [0, "ħ"], [0, "Ĩ"], [0, "ĩ"], [0, "Ī"], [0, "ī"], [2, "Į"], [0, "į"], [0, "İ"], [0, "ı"], [0, "IJ"], [0, "ij"], [0, "Ĵ"], [0, "ĵ"], [0, "Ķ"], [0, "ķ"], [0, "ĸ"], [0, "Ĺ"], [0, "ĺ"], [0, "Ļ"], [0, "ļ"], [0, "Ľ"], [0, "ľ"], [0, "Ŀ"], [0, "ŀ"], [0, "Ł"], [0, "ł"], [0, "Ń"], [0, "ń"], [0, "Ņ"], [0, "ņ"], [0, "Ň"], [0, "ň"], [0, "ʼn"], [0, "Ŋ"], [0, "ŋ"], [0, "Ō"], [0, "ō"], [2, "Ő"], [0, "ő"], [0, "Œ"], [0, "œ"], [0, "Ŕ"], [0, "ŕ"], [0, "Ŗ"], [0, "ŗ"], [0, "Ř"], [0, "ř"], [0, "Ś"], [0, "ś"], [0, "Ŝ"], [0, "ŝ"], [0, "Ş"], [0, "ş"], [0, "Š"], [0, "š"], [0, "Ţ"], [0, "ţ"], [0, "Ť"], [0, "ť"], [0, "Ŧ"], [0, "ŧ"], [0, "Ũ"], [0, "ũ"], [0, "Ū"], [0, "ū"], [0, "Ŭ"], [0, "ŭ"], [0, "Ů"], [0, "ů"], [0, "Ű"], [0, "ű"], [0, "Ų"], [0, "ų"], [0, "Ŵ"], [0, "ŵ"], [0, "Ŷ"], [0, "ŷ
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/entities/lib/escape.js
|
|||
|
var require_escape = __commonJS({
|
|||
|
"node_modules/entities/lib/escape.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.escapeText = exports.escapeAttribute = exports.escapeUTF8 = exports.escape = exports.encodeXML = exports.getCodePoint = exports.xmlReplacer = void 0;
|
|||
|
exports.xmlReplacer = /["&'<>$\x80-\uFFFF]/g;
|
|||
|
var xmlCodeMap = /* @__PURE__ */ new Map([
|
|||
|
[34, """],
|
|||
|
[38, "&"],
|
|||
|
[39, "'"],
|
|||
|
[60, "<"],
|
|||
|
[62, ">"]
|
|||
|
]);
|
|||
|
exports.getCodePoint = String.prototype.codePointAt != null ? function(str, index) {
|
|||
|
return str.codePointAt(index);
|
|||
|
} : function(c, index) {
|
|||
|
return (c.charCodeAt(index) & 64512) === 55296 ? (c.charCodeAt(index) - 55296) * 1024 + c.charCodeAt(index + 1) - 56320 + 65536 : c.charCodeAt(index);
|
|||
|
};
|
|||
|
function encodeXML(str) {
|
|||
|
var ret = "";
|
|||
|
var lastIdx = 0;
|
|||
|
var match;
|
|||
|
while ((match = exports.xmlReplacer.exec(str)) !== null) {
|
|||
|
var i = match.index;
|
|||
|
var char = str.charCodeAt(i);
|
|||
|
var next = xmlCodeMap.get(char);
|
|||
|
if (next !== void 0) {
|
|||
|
ret += str.substring(lastIdx, i) + next;
|
|||
|
lastIdx = i + 1;
|
|||
|
} else {
|
|||
|
ret += "".concat(str.substring(lastIdx, i), "&#x").concat((0, exports.getCodePoint)(str, i).toString(16), ";");
|
|||
|
lastIdx = exports.xmlReplacer.lastIndex += Number((char & 64512) === 55296);
|
|||
|
}
|
|||
|
}
|
|||
|
return ret + str.substr(lastIdx);
|
|||
|
}
|
|||
|
exports.encodeXML = encodeXML;
|
|||
|
exports.escape = encodeXML;
|
|||
|
function getEscaper(regex, map) {
|
|||
|
return function escape(data) {
|
|||
|
var match;
|
|||
|
var lastIdx = 0;
|
|||
|
var result = "";
|
|||
|
while (match = regex.exec(data)) {
|
|||
|
if (lastIdx !== match.index) {
|
|||
|
result += data.substring(lastIdx, match.index);
|
|||
|
}
|
|||
|
result += map.get(match[0].charCodeAt(0));
|
|||
|
lastIdx = match.index + 1;
|
|||
|
}
|
|||
|
return result + data.substring(lastIdx);
|
|||
|
};
|
|||
|
}
|
|||
|
exports.escapeUTF8 = getEscaper(/[&<>'"]/g, xmlCodeMap);
|
|||
|
exports.escapeAttribute = getEscaper(/["&\u00A0]/g, /* @__PURE__ */ new Map([
|
|||
|
[34, """],
|
|||
|
[38, "&"],
|
|||
|
[160, " "]
|
|||
|
]));
|
|||
|
exports.escapeText = getEscaper(/[&<>\u00A0]/g, /* @__PURE__ */ new Map([
|
|||
|
[38, "&"],
|
|||
|
[60, "<"],
|
|||
|
[62, ">"],
|
|||
|
[160, " "]
|
|||
|
]));
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/entities/lib/encode.js
|
|||
|
var require_encode = __commonJS({
|
|||
|
"node_modules/entities/lib/encode.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.encodeNonAsciiHTML = exports.encodeHTML = void 0;
|
|||
|
var encode_html_js_1 = __importDefault(require_encode_html());
|
|||
|
var escape_js_1 = require_escape();
|
|||
|
var htmlReplacer = /[\t\n!-,./:-@[-`\f{-}$\x80-\uFFFF]/g;
|
|||
|
function encodeHTML(data) {
|
|||
|
return encodeHTMLTrieRe(htmlReplacer, data);
|
|||
|
}
|
|||
|
exports.encodeHTML = encodeHTML;
|
|||
|
function encodeNonAsciiHTML(data) {
|
|||
|
return encodeHTMLTrieRe(escape_js_1.xmlReplacer, data);
|
|||
|
}
|
|||
|
exports.encodeNonAsciiHTML = encodeNonAsciiHTML;
|
|||
|
function encodeHTMLTrieRe(regExp, str) {
|
|||
|
var ret = "";
|
|||
|
var lastIdx = 0;
|
|||
|
var match;
|
|||
|
while ((match = regExp.exec(str)) !== null) {
|
|||
|
var i = match.index;
|
|||
|
ret += str.substring(lastIdx, i);
|
|||
|
var char = str.charCodeAt(i);
|
|||
|
var next = encode_html_js_1.default.get(char);
|
|||
|
if (typeof next === "object") {
|
|||
|
if (i + 1 < str.length) {
|
|||
|
var nextChar = str.charCodeAt(i + 1);
|
|||
|
var value = typeof next.n === "number" ? next.n === nextChar ? next.o : void 0 : next.n.get(nextChar);
|
|||
|
if (value !== void 0) {
|
|||
|
ret += value;
|
|||
|
lastIdx = regExp.lastIndex += 1;
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
next = next.v;
|
|||
|
}
|
|||
|
if (next !== void 0) {
|
|||
|
ret += next;
|
|||
|
lastIdx = i + 1;
|
|||
|
} else {
|
|||
|
var cp = (0, escape_js_1.getCodePoint)(str, i);
|
|||
|
ret += "&#x".concat(cp.toString(16), ";");
|
|||
|
lastIdx = regExp.lastIndex += Number(cp !== char);
|
|||
|
}
|
|||
|
}
|
|||
|
return ret + str.substr(lastIdx);
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/entities/lib/index.js
|
|||
|
var require_lib3 = __commonJS({
|
|||
|
"node_modules/entities/lib/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.decodeXMLStrict = exports.decodeHTML5Strict = exports.decodeHTML4Strict = exports.decodeHTML5 = exports.decodeHTML4 = exports.decodeHTMLAttribute = exports.decodeHTMLStrict = exports.decodeHTML = exports.decodeXML = exports.DecodingMode = exports.EntityDecoder = exports.encodeHTML5 = exports.encodeHTML4 = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.escapeText = exports.escapeAttribute = exports.escapeUTF8 = exports.escape = exports.encodeXML = exports.encode = exports.decodeStrict = exports.decode = exports.EncodingMode = exports.EntityLevel = void 0;
|
|||
|
var decode_js_1 = require_decode();
|
|||
|
var encode_js_1 = require_encode();
|
|||
|
var escape_js_1 = require_escape();
|
|||
|
var EntityLevel;
|
|||
|
(function(EntityLevel2) {
|
|||
|
EntityLevel2[EntityLevel2["XML"] = 0] = "XML";
|
|||
|
EntityLevel2[EntityLevel2["HTML"] = 1] = "HTML";
|
|||
|
})(EntityLevel = exports.EntityLevel || (exports.EntityLevel = {}));
|
|||
|
var EncodingMode;
|
|||
|
(function(EncodingMode2) {
|
|||
|
EncodingMode2[EncodingMode2["UTF8"] = 0] = "UTF8";
|
|||
|
EncodingMode2[EncodingMode2["ASCII"] = 1] = "ASCII";
|
|||
|
EncodingMode2[EncodingMode2["Extensive"] = 2] = "Extensive";
|
|||
|
EncodingMode2[EncodingMode2["Attribute"] = 3] = "Attribute";
|
|||
|
EncodingMode2[EncodingMode2["Text"] = 4] = "Text";
|
|||
|
})(EncodingMode = exports.EncodingMode || (exports.EncodingMode = {}));
|
|||
|
function decode(data, options) {
|
|||
|
if (options === void 0) {
|
|||
|
options = EntityLevel.XML;
|
|||
|
}
|
|||
|
var level = typeof options === "number" ? options : options.level;
|
|||
|
if (level === EntityLevel.HTML) {
|
|||
|
var mode = typeof options === "object" ? options.mode : void 0;
|
|||
|
return (0, decode_js_1.decodeHTML)(data, mode);
|
|||
|
}
|
|||
|
return (0, decode_js_1.decodeXML)(data);
|
|||
|
}
|
|||
|
exports.decode = decode;
|
|||
|
function decodeStrict(data, options) {
|
|||
|
var _a;
|
|||
|
if (options === void 0) {
|
|||
|
options = EntityLevel.XML;
|
|||
|
}
|
|||
|
var opts = typeof options === "number" ? { level: options } : options;
|
|||
|
(_a = opts.mode) !== null && _a !== void 0 ? _a : opts.mode = decode_js_1.DecodingMode.Strict;
|
|||
|
return decode(data, opts);
|
|||
|
}
|
|||
|
exports.decodeStrict = decodeStrict;
|
|||
|
function encode(data, options) {
|
|||
|
if (options === void 0) {
|
|||
|
options = EntityLevel.XML;
|
|||
|
}
|
|||
|
var opts = typeof options === "number" ? { level: options } : options;
|
|||
|
if (opts.mode === EncodingMode.UTF8)
|
|||
|
return (0, escape_js_1.escapeUTF8)(data);
|
|||
|
if (opts.mode === EncodingMode.Attribute)
|
|||
|
return (0, escape_js_1.escapeAttribute)(data);
|
|||
|
if (opts.mode === EncodingMode.Text)
|
|||
|
return (0, escape_js_1.escapeText)(data);
|
|||
|
if (opts.level === EntityLevel.HTML) {
|
|||
|
if (opts.mode === EncodingMode.ASCII) {
|
|||
|
return (0, encode_js_1.encodeNonAsciiHTML)(data);
|
|||
|
}
|
|||
|
return (0, encode_js_1.encodeHTML)(data);
|
|||
|
}
|
|||
|
return (0, escape_js_1.encodeXML)(data);
|
|||
|
}
|
|||
|
exports.encode = encode;
|
|||
|
var escape_js_2 = require_escape();
|
|||
|
Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function() {
|
|||
|
return escape_js_2.encodeXML;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "escape", { enumerable: true, get: function() {
|
|||
|
return escape_js_2.escape;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "escapeUTF8", { enumerable: true, get: function() {
|
|||
|
return escape_js_2.escapeUTF8;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "escapeAttribute", { enumerable: true, get: function() {
|
|||
|
return escape_js_2.escapeAttribute;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "escapeText", { enumerable: true, get: function() {
|
|||
|
return escape_js_2.escapeText;
|
|||
|
} });
|
|||
|
var encode_js_2 = require_encode();
|
|||
|
Object.defineProperty(exports, "encodeHTML", { enumerable: true, get: function() {
|
|||
|
return encode_js_2.encodeHTML;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "encodeNonAsciiHTML", { enumerable: true, get: function() {
|
|||
|
return encode_js_2.encodeNonAsciiHTML;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "encodeHTML4", { enumerable: true, get: function() {
|
|||
|
return encode_js_2.encodeHTML;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "encodeHTML5", { enumerable: true, get: function() {
|
|||
|
return encode_js_2.encodeHTML;
|
|||
|
} });
|
|||
|
var decode_js_2 = require_decode();
|
|||
|
Object.defineProperty(exports, "EntityDecoder", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.EntityDecoder;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "DecodingMode", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.DecodingMode;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeXML", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeXML;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeHTML;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeHTMLStrict", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeHTMLStrict;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeHTMLAttribute", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeHTMLAttribute;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeHTML4", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeHTML;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeHTML5", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeHTML;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeHTML4Strict", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeHTMLStrict;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeHTML5Strict", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeHTMLStrict;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "decodeXMLStrict", { enumerable: true, get: function() {
|
|||
|
return decode_js_2.decodeXML;
|
|||
|
} });
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/dom-serializer/lib/foreignNames.js
|
|||
|
var require_foreignNames = __commonJS({
|
|||
|
"node_modules/dom-serializer/lib/foreignNames.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.attributeNames = exports.elementNames = void 0;
|
|||
|
exports.elementNames = new Map([
|
|||
|
"altGlyph",
|
|||
|
"altGlyphDef",
|
|||
|
"altGlyphItem",
|
|||
|
"animateColor",
|
|||
|
"animateMotion",
|
|||
|
"animateTransform",
|
|||
|
"clipPath",
|
|||
|
"feBlend",
|
|||
|
"feColorMatrix",
|
|||
|
"feComponentTransfer",
|
|||
|
"feComposite",
|
|||
|
"feConvolveMatrix",
|
|||
|
"feDiffuseLighting",
|
|||
|
"feDisplacementMap",
|
|||
|
"feDistantLight",
|
|||
|
"feDropShadow",
|
|||
|
"feFlood",
|
|||
|
"feFuncA",
|
|||
|
"feFuncB",
|
|||
|
"feFuncG",
|
|||
|
"feFuncR",
|
|||
|
"feGaussianBlur",
|
|||
|
"feImage",
|
|||
|
"feMerge",
|
|||
|
"feMergeNode",
|
|||
|
"feMorphology",
|
|||
|
"feOffset",
|
|||
|
"fePointLight",
|
|||
|
"feSpecularLighting",
|
|||
|
"feSpotLight",
|
|||
|
"feTile",
|
|||
|
"feTurbulence",
|
|||
|
"foreignObject",
|
|||
|
"glyphRef",
|
|||
|
"linearGradient",
|
|||
|
"radialGradient",
|
|||
|
"textPath"
|
|||
|
].map(function(val) {
|
|||
|
return [val.toLowerCase(), val];
|
|||
|
}));
|
|||
|
exports.attributeNames = new Map([
|
|||
|
"definitionURL",
|
|||
|
"attributeName",
|
|||
|
"attributeType",
|
|||
|
"baseFrequency",
|
|||
|
"baseProfile",
|
|||
|
"calcMode",
|
|||
|
"clipPathUnits",
|
|||
|
"diffuseConstant",
|
|||
|
"edgeMode",
|
|||
|
"filterUnits",
|
|||
|
"glyphRef",
|
|||
|
"gradientTransform",
|
|||
|
"gradientUnits",
|
|||
|
"kernelMatrix",
|
|||
|
"kernelUnitLength",
|
|||
|
"keyPoints",
|
|||
|
"keySplines",
|
|||
|
"keyTimes",
|
|||
|
"lengthAdjust",
|
|||
|
"limitingConeAngle",
|
|||
|
"markerHeight",
|
|||
|
"markerUnits",
|
|||
|
"markerWidth",
|
|||
|
"maskContentUnits",
|
|||
|
"maskUnits",
|
|||
|
"numOctaves",
|
|||
|
"pathLength",
|
|||
|
"patternContentUnits",
|
|||
|
"patternTransform",
|
|||
|
"patternUnits",
|
|||
|
"pointsAtX",
|
|||
|
"pointsAtY",
|
|||
|
"pointsAtZ",
|
|||
|
"preserveAlpha",
|
|||
|
"preserveAspectRatio",
|
|||
|
"primitiveUnits",
|
|||
|
"refX",
|
|||
|
"refY",
|
|||
|
"repeatCount",
|
|||
|
"repeatDur",
|
|||
|
"requiredExtensions",
|
|||
|
"requiredFeatures",
|
|||
|
"specularConstant",
|
|||
|
"specularExponent",
|
|||
|
"spreadMethod",
|
|||
|
"startOffset",
|
|||
|
"stdDeviation",
|
|||
|
"stitchTiles",
|
|||
|
"surfaceScale",
|
|||
|
"systemLanguage",
|
|||
|
"tableValues",
|
|||
|
"targetX",
|
|||
|
"targetY",
|
|||
|
"textLength",
|
|||
|
"viewBox",
|
|||
|
"viewTarget",
|
|||
|
"xChannelSelector",
|
|||
|
"yChannelSelector",
|
|||
|
"zoomAndPan"
|
|||
|
].map(function(val) {
|
|||
|
return [val.toLowerCase(), val];
|
|||
|
}));
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/dom-serializer/lib/index.js
|
|||
|
var require_lib4 = __commonJS({
|
|||
|
"node_modules/dom-serializer/lib/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __assign = exports && exports.__assign || function() {
|
|||
|
__assign = Object.assign || function(t) {
|
|||
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|||
|
s = arguments[i];
|
|||
|
for (var p in s)
|
|||
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|||
|
t[p] = s[p];
|
|||
|
}
|
|||
|
return t;
|
|||
|
};
|
|||
|
return __assign.apply(this, arguments);
|
|||
|
};
|
|||
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|||
|
desc = { enumerable: true, get: function() {
|
|||
|
return m[k];
|
|||
|
} };
|
|||
|
}
|
|||
|
Object.defineProperty(o, k2, desc);
|
|||
|
} : function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
o[k2] = m[k];
|
|||
|
});
|
|||
|
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|||
|
} : function(o, v) {
|
|||
|
o["default"] = v;
|
|||
|
});
|
|||
|
var __importStar = exports && exports.__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;
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.render = void 0;
|
|||
|
var ElementType = __importStar(require_lib());
|
|||
|
var entities_1 = require_lib3();
|
|||
|
var foreignNames_js_1 = require_foreignNames();
|
|||
|
var unencodedElements = /* @__PURE__ */ new Set([
|
|||
|
"style",
|
|||
|
"script",
|
|||
|
"xmp",
|
|||
|
"iframe",
|
|||
|
"noembed",
|
|||
|
"noframes",
|
|||
|
"plaintext",
|
|||
|
"noscript"
|
|||
|
]);
|
|||
|
function replaceQuotes(value) {
|
|||
|
return value.replace(/"/g, """);
|
|||
|
}
|
|||
|
function formatAttributes(attributes, opts) {
|
|||
|
var _a;
|
|||
|
if (!attributes)
|
|||
|
return;
|
|||
|
var encode = ((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) === false ? replaceQuotes : opts.xmlMode || opts.encodeEntities !== "utf8" ? entities_1.encodeXML : entities_1.escapeAttribute;
|
|||
|
return Object.keys(attributes).map(function(key) {
|
|||
|
var _a2, _b;
|
|||
|
var value = (_a2 = attributes[key]) !== null && _a2 !== void 0 ? _a2 : "";
|
|||
|
if (opts.xmlMode === "foreign") {
|
|||
|
key = (_b = foreignNames_js_1.attributeNames.get(key)) !== null && _b !== void 0 ? _b : key;
|
|||
|
}
|
|||
|
if (!opts.emptyAttrs && !opts.xmlMode && value === "") {
|
|||
|
return key;
|
|||
|
}
|
|||
|
return "".concat(key, '="').concat(encode(value), '"');
|
|||
|
}).join(" ");
|
|||
|
}
|
|||
|
var singleTag = /* @__PURE__ */ new Set([
|
|||
|
"area",
|
|||
|
"base",
|
|||
|
"basefont",
|
|||
|
"br",
|
|||
|
"col",
|
|||
|
"command",
|
|||
|
"embed",
|
|||
|
"frame",
|
|||
|
"hr",
|
|||
|
"img",
|
|||
|
"input",
|
|||
|
"isindex",
|
|||
|
"keygen",
|
|||
|
"link",
|
|||
|
"meta",
|
|||
|
"param",
|
|||
|
"source",
|
|||
|
"track",
|
|||
|
"wbr"
|
|||
|
]);
|
|||
|
function render(node, options) {
|
|||
|
if (options === void 0) {
|
|||
|
options = {};
|
|||
|
}
|
|||
|
var nodes = "length" in node ? node : [node];
|
|||
|
var output = "";
|
|||
|
for (var i = 0; i < nodes.length; i++) {
|
|||
|
output += renderNode(nodes[i], options);
|
|||
|
}
|
|||
|
return output;
|
|||
|
}
|
|||
|
exports.render = render;
|
|||
|
exports.default = render;
|
|||
|
function renderNode(node, options) {
|
|||
|
switch (node.type) {
|
|||
|
case ElementType.Root:
|
|||
|
return render(node.children, options);
|
|||
|
case ElementType.Doctype:
|
|||
|
case ElementType.Directive:
|
|||
|
return renderDirective(node);
|
|||
|
case ElementType.Comment:
|
|||
|
return renderComment(node);
|
|||
|
case ElementType.CDATA:
|
|||
|
return renderCdata(node);
|
|||
|
case ElementType.Script:
|
|||
|
case ElementType.Style:
|
|||
|
case ElementType.Tag:
|
|||
|
return renderTag(node, options);
|
|||
|
case ElementType.Text:
|
|||
|
return renderText(node, options);
|
|||
|
}
|
|||
|
}
|
|||
|
var foreignModeIntegrationPoints = /* @__PURE__ */ new Set([
|
|||
|
"mi",
|
|||
|
"mo",
|
|||
|
"mn",
|
|||
|
"ms",
|
|||
|
"mtext",
|
|||
|
"annotation-xml",
|
|||
|
"foreignObject",
|
|||
|
"desc",
|
|||
|
"title"
|
|||
|
]);
|
|||
|
var foreignElements = /* @__PURE__ */ new Set(["svg", "math"]);
|
|||
|
function renderTag(elem, opts) {
|
|||
|
var _a;
|
|||
|
if (opts.xmlMode === "foreign") {
|
|||
|
elem.name = (_a = foreignNames_js_1.elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name;
|
|||
|
if (elem.parent && foreignModeIntegrationPoints.has(elem.parent.name)) {
|
|||
|
opts = __assign(__assign({}, opts), { xmlMode: false });
|
|||
|
}
|
|||
|
}
|
|||
|
if (!opts.xmlMode && foreignElements.has(elem.name)) {
|
|||
|
opts = __assign(__assign({}, opts), { xmlMode: "foreign" });
|
|||
|
}
|
|||
|
var tag = "<".concat(elem.name);
|
|||
|
var attribs = formatAttributes(elem.attribs, opts);
|
|||
|
if (attribs) {
|
|||
|
tag += " ".concat(attribs);
|
|||
|
}
|
|||
|
if (elem.children.length === 0 && (opts.xmlMode ? opts.selfClosingTags !== false : opts.selfClosingTags && singleTag.has(elem.name))) {
|
|||
|
if (!opts.xmlMode)
|
|||
|
tag += " ";
|
|||
|
tag += "/>";
|
|||
|
} else {
|
|||
|
tag += ">";
|
|||
|
if (elem.children.length > 0) {
|
|||
|
tag += render(elem.children, opts);
|
|||
|
}
|
|||
|
if (opts.xmlMode || !singleTag.has(elem.name)) {
|
|||
|
tag += "</".concat(elem.name, ">");
|
|||
|
}
|
|||
|
}
|
|||
|
return tag;
|
|||
|
}
|
|||
|
function renderDirective(elem) {
|
|||
|
return "<".concat(elem.data, ">");
|
|||
|
}
|
|||
|
function renderText(elem, opts) {
|
|||
|
var _a;
|
|||
|
var data = elem.data || "";
|
|||
|
if (((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) !== false && !(!opts.xmlMode && elem.parent && unencodedElements.has(elem.parent.name))) {
|
|||
|
data = opts.xmlMode || opts.encodeEntities !== "utf8" ? (0, entities_1.encodeXML)(data) : (0, entities_1.escapeText)(data);
|
|||
|
}
|
|||
|
return data;
|
|||
|
}
|
|||
|
function renderCdata(elem) {
|
|||
|
return "<![CDATA[".concat(elem.children[0].data, "]]>");
|
|||
|
}
|
|||
|
function renderComment(elem) {
|
|||
|
return "<!--".concat(elem.data, "-->");
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domutils/lib/stringify.js
|
|||
|
var require_stringify = __commonJS({
|
|||
|
"node_modules/domutils/lib/stringify.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.innerText = exports.textContent = exports.getText = exports.getInnerHTML = exports.getOuterHTML = void 0;
|
|||
|
var domhandler_1 = require_lib2();
|
|||
|
var dom_serializer_1 = __importDefault(require_lib4());
|
|||
|
var domelementtype_1 = require_lib();
|
|||
|
function getOuterHTML(node, options) {
|
|||
|
return (0, dom_serializer_1.default)(node, options);
|
|||
|
}
|
|||
|
exports.getOuterHTML = getOuterHTML;
|
|||
|
function getInnerHTML(node, options) {
|
|||
|
return (0, domhandler_1.hasChildren)(node) ? node.children.map(function(node2) {
|
|||
|
return getOuterHTML(node2, options);
|
|||
|
}).join("") : "";
|
|||
|
}
|
|||
|
exports.getInnerHTML = getInnerHTML;
|
|||
|
function getText(node) {
|
|||
|
if (Array.isArray(node))
|
|||
|
return node.map(getText).join("");
|
|||
|
if ((0, domhandler_1.isTag)(node))
|
|||
|
return node.name === "br" ? "\n" : getText(node.children);
|
|||
|
if ((0, domhandler_1.isCDATA)(node))
|
|||
|
return getText(node.children);
|
|||
|
if ((0, domhandler_1.isText)(node))
|
|||
|
return node.data;
|
|||
|
return "";
|
|||
|
}
|
|||
|
exports.getText = getText;
|
|||
|
function textContent(node) {
|
|||
|
if (Array.isArray(node))
|
|||
|
return node.map(textContent).join("");
|
|||
|
if ((0, domhandler_1.hasChildren)(node) && !(0, domhandler_1.isComment)(node)) {
|
|||
|
return textContent(node.children);
|
|||
|
}
|
|||
|
if ((0, domhandler_1.isText)(node))
|
|||
|
return node.data;
|
|||
|
return "";
|
|||
|
}
|
|||
|
exports.textContent = textContent;
|
|||
|
function innerText(node) {
|
|||
|
if (Array.isArray(node))
|
|||
|
return node.map(innerText).join("");
|
|||
|
if ((0, domhandler_1.hasChildren)(node) && (node.type === domelementtype_1.ElementType.Tag || (0, domhandler_1.isCDATA)(node))) {
|
|||
|
return innerText(node.children);
|
|||
|
}
|
|||
|
if ((0, domhandler_1.isText)(node))
|
|||
|
return node.data;
|
|||
|
return "";
|
|||
|
}
|
|||
|
exports.innerText = innerText;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domutils/lib/traversal.js
|
|||
|
var require_traversal = __commonJS({
|
|||
|
"node_modules/domutils/lib/traversal.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.prevElementSibling = exports.nextElementSibling = exports.getName = exports.hasAttrib = exports.getAttributeValue = exports.getSiblings = exports.getParent = exports.getChildren = void 0;
|
|||
|
var domhandler_1 = require_lib2();
|
|||
|
function getChildren(elem) {
|
|||
|
return (0, domhandler_1.hasChildren)(elem) ? elem.children : [];
|
|||
|
}
|
|||
|
exports.getChildren = getChildren;
|
|||
|
function getParent(elem) {
|
|||
|
return elem.parent || null;
|
|||
|
}
|
|||
|
exports.getParent = getParent;
|
|||
|
function getSiblings(elem) {
|
|||
|
var _a, _b;
|
|||
|
var parent = getParent(elem);
|
|||
|
if (parent != null)
|
|||
|
return getChildren(parent);
|
|||
|
var siblings = [elem];
|
|||
|
var prev = elem.prev, next = elem.next;
|
|||
|
while (prev != null) {
|
|||
|
siblings.unshift(prev);
|
|||
|
_a = prev, prev = _a.prev;
|
|||
|
}
|
|||
|
while (next != null) {
|
|||
|
siblings.push(next);
|
|||
|
_b = next, next = _b.next;
|
|||
|
}
|
|||
|
return siblings;
|
|||
|
}
|
|||
|
exports.getSiblings = getSiblings;
|
|||
|
function getAttributeValue(elem, name) {
|
|||
|
var _a;
|
|||
|
return (_a = elem.attribs) === null || _a === void 0 ? void 0 : _a[name];
|
|||
|
}
|
|||
|
exports.getAttributeValue = getAttributeValue;
|
|||
|
function hasAttrib(elem, name) {
|
|||
|
return elem.attribs != null && Object.prototype.hasOwnProperty.call(elem.attribs, name) && elem.attribs[name] != null;
|
|||
|
}
|
|||
|
exports.hasAttrib = hasAttrib;
|
|||
|
function getName(elem) {
|
|||
|
return elem.name;
|
|||
|
}
|
|||
|
exports.getName = getName;
|
|||
|
function nextElementSibling(elem) {
|
|||
|
var _a;
|
|||
|
var next = elem.next;
|
|||
|
while (next !== null && !(0, domhandler_1.isTag)(next))
|
|||
|
_a = next, next = _a.next;
|
|||
|
return next;
|
|||
|
}
|
|||
|
exports.nextElementSibling = nextElementSibling;
|
|||
|
function prevElementSibling(elem) {
|
|||
|
var _a;
|
|||
|
var prev = elem.prev;
|
|||
|
while (prev !== null && !(0, domhandler_1.isTag)(prev))
|
|||
|
_a = prev, prev = _a.prev;
|
|||
|
return prev;
|
|||
|
}
|
|||
|
exports.prevElementSibling = prevElementSibling;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domutils/lib/manipulation.js
|
|||
|
var require_manipulation = __commonJS({
|
|||
|
"node_modules/domutils/lib/manipulation.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.prepend = exports.prependChild = exports.append = exports.appendChild = exports.replaceElement = exports.removeElement = void 0;
|
|||
|
function removeElement(elem) {
|
|||
|
if (elem.prev)
|
|||
|
elem.prev.next = elem.next;
|
|||
|
if (elem.next)
|
|||
|
elem.next.prev = elem.prev;
|
|||
|
if (elem.parent) {
|
|||
|
var childs = elem.parent.children;
|
|||
|
var childsIndex = childs.lastIndexOf(elem);
|
|||
|
if (childsIndex >= 0) {
|
|||
|
childs.splice(childsIndex, 1);
|
|||
|
}
|
|||
|
}
|
|||
|
elem.next = null;
|
|||
|
elem.prev = null;
|
|||
|
elem.parent = null;
|
|||
|
}
|
|||
|
exports.removeElement = removeElement;
|
|||
|
function replaceElement(elem, replacement) {
|
|||
|
var prev = replacement.prev = elem.prev;
|
|||
|
if (prev) {
|
|||
|
prev.next = replacement;
|
|||
|
}
|
|||
|
var next = replacement.next = elem.next;
|
|||
|
if (next) {
|
|||
|
next.prev = replacement;
|
|||
|
}
|
|||
|
var parent = replacement.parent = elem.parent;
|
|||
|
if (parent) {
|
|||
|
var childs = parent.children;
|
|||
|
childs[childs.lastIndexOf(elem)] = replacement;
|
|||
|
elem.parent = null;
|
|||
|
}
|
|||
|
}
|
|||
|
exports.replaceElement = replaceElement;
|
|||
|
function appendChild(parent, child) {
|
|||
|
removeElement(child);
|
|||
|
child.next = null;
|
|||
|
child.parent = parent;
|
|||
|
if (parent.children.push(child) > 1) {
|
|||
|
var sibling = parent.children[parent.children.length - 2];
|
|||
|
sibling.next = child;
|
|||
|
child.prev = sibling;
|
|||
|
} else {
|
|||
|
child.prev = null;
|
|||
|
}
|
|||
|
}
|
|||
|
exports.appendChild = appendChild;
|
|||
|
function append(elem, next) {
|
|||
|
removeElement(next);
|
|||
|
var parent = elem.parent;
|
|||
|
var currNext = elem.next;
|
|||
|
next.next = currNext;
|
|||
|
next.prev = elem;
|
|||
|
elem.next = next;
|
|||
|
next.parent = parent;
|
|||
|
if (currNext) {
|
|||
|
currNext.prev = next;
|
|||
|
if (parent) {
|
|||
|
var childs = parent.children;
|
|||
|
childs.splice(childs.lastIndexOf(currNext), 0, next);
|
|||
|
}
|
|||
|
} else if (parent) {
|
|||
|
parent.children.push(next);
|
|||
|
}
|
|||
|
}
|
|||
|
exports.append = append;
|
|||
|
function prependChild(parent, child) {
|
|||
|
removeElement(child);
|
|||
|
child.parent = parent;
|
|||
|
child.prev = null;
|
|||
|
if (parent.children.unshift(child) !== 1) {
|
|||
|
var sibling = parent.children[1];
|
|||
|
sibling.prev = child;
|
|||
|
child.next = sibling;
|
|||
|
} else {
|
|||
|
child.next = null;
|
|||
|
}
|
|||
|
}
|
|||
|
exports.prependChild = prependChild;
|
|||
|
function prepend(elem, prev) {
|
|||
|
removeElement(prev);
|
|||
|
var parent = elem.parent;
|
|||
|
if (parent) {
|
|||
|
var childs = parent.children;
|
|||
|
childs.splice(childs.indexOf(elem), 0, prev);
|
|||
|
}
|
|||
|
if (elem.prev) {
|
|||
|
elem.prev.next = prev;
|
|||
|
}
|
|||
|
prev.parent = parent;
|
|||
|
prev.prev = elem.prev;
|
|||
|
prev.next = elem;
|
|||
|
elem.prev = prev;
|
|||
|
}
|
|||
|
exports.prepend = prepend;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domutils/lib/querying.js
|
|||
|
var require_querying = __commonJS({
|
|||
|
"node_modules/domutils/lib/querying.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.findAll = exports.existsOne = exports.findOne = exports.findOneChild = exports.find = exports.filter = void 0;
|
|||
|
var domhandler_1 = require_lib2();
|
|||
|
function filter(test, node, recurse, limit) {
|
|||
|
if (recurse === void 0) {
|
|||
|
recurse = true;
|
|||
|
}
|
|||
|
if (limit === void 0) {
|
|||
|
limit = Infinity;
|
|||
|
}
|
|||
|
return find(test, Array.isArray(node) ? node : [node], recurse, limit);
|
|||
|
}
|
|||
|
exports.filter = filter;
|
|||
|
function find(test, nodes, recurse, limit) {
|
|||
|
var result = [];
|
|||
|
var nodeStack = [nodes];
|
|||
|
var indexStack = [0];
|
|||
|
for (; ; ) {
|
|||
|
if (indexStack[0] >= nodeStack[0].length) {
|
|||
|
if (indexStack.length === 1) {
|
|||
|
return result;
|
|||
|
}
|
|||
|
nodeStack.shift();
|
|||
|
indexStack.shift();
|
|||
|
continue;
|
|||
|
}
|
|||
|
var elem = nodeStack[0][indexStack[0]++];
|
|||
|
if (test(elem)) {
|
|||
|
result.push(elem);
|
|||
|
if (--limit <= 0)
|
|||
|
return result;
|
|||
|
}
|
|||
|
if (recurse && (0, domhandler_1.hasChildren)(elem) && elem.children.length > 0) {
|
|||
|
indexStack.unshift(0);
|
|||
|
nodeStack.unshift(elem.children);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
exports.find = find;
|
|||
|
function findOneChild(test, nodes) {
|
|||
|
return nodes.find(test);
|
|||
|
}
|
|||
|
exports.findOneChild = findOneChild;
|
|||
|
function findOne(test, nodes, recurse) {
|
|||
|
if (recurse === void 0) {
|
|||
|
recurse = true;
|
|||
|
}
|
|||
|
var elem = null;
|
|||
|
for (var i = 0; i < nodes.length && !elem; i++) {
|
|||
|
var node = nodes[i];
|
|||
|
if (!(0, domhandler_1.isTag)(node)) {
|
|||
|
continue;
|
|||
|
} else if (test(node)) {
|
|||
|
elem = node;
|
|||
|
} else if (recurse && node.children.length > 0) {
|
|||
|
elem = findOne(test, node.children, true);
|
|||
|
}
|
|||
|
}
|
|||
|
return elem;
|
|||
|
}
|
|||
|
exports.findOne = findOne;
|
|||
|
function existsOne(test, nodes) {
|
|||
|
return nodes.some(function(checked) {
|
|||
|
return (0, domhandler_1.isTag)(checked) && (test(checked) || existsOne(test, checked.children));
|
|||
|
});
|
|||
|
}
|
|||
|
exports.existsOne = existsOne;
|
|||
|
function findAll(test, nodes) {
|
|||
|
var result = [];
|
|||
|
var nodeStack = [nodes];
|
|||
|
var indexStack = [0];
|
|||
|
for (; ; ) {
|
|||
|
if (indexStack[0] >= nodeStack[0].length) {
|
|||
|
if (nodeStack.length === 1) {
|
|||
|
return result;
|
|||
|
}
|
|||
|
nodeStack.shift();
|
|||
|
indexStack.shift();
|
|||
|
continue;
|
|||
|
}
|
|||
|
var elem = nodeStack[0][indexStack[0]++];
|
|||
|
if (!(0, domhandler_1.isTag)(elem))
|
|||
|
continue;
|
|||
|
if (test(elem))
|
|||
|
result.push(elem);
|
|||
|
if (elem.children.length > 0) {
|
|||
|
indexStack.unshift(0);
|
|||
|
nodeStack.unshift(elem.children);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
exports.findAll = findAll;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domutils/lib/legacy.js
|
|||
|
var require_legacy = __commonJS({
|
|||
|
"node_modules/domutils/lib/legacy.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.getElementsByTagType = exports.getElementsByTagName = exports.getElementById = exports.getElements = exports.testElement = void 0;
|
|||
|
var domhandler_1 = require_lib2();
|
|||
|
var querying_js_1 = require_querying();
|
|||
|
var Checks = {
|
|||
|
tag_name: function(name) {
|
|||
|
if (typeof name === "function") {
|
|||
|
return function(elem) {
|
|||
|
return (0, domhandler_1.isTag)(elem) && name(elem.name);
|
|||
|
};
|
|||
|
} else if (name === "*") {
|
|||
|
return domhandler_1.isTag;
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
return (0, domhandler_1.isTag)(elem) && elem.name === name;
|
|||
|
};
|
|||
|
},
|
|||
|
tag_type: function(type) {
|
|||
|
if (typeof type === "function") {
|
|||
|
return function(elem) {
|
|||
|
return type(elem.type);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
return elem.type === type;
|
|||
|
};
|
|||
|
},
|
|||
|
tag_contains: function(data) {
|
|||
|
if (typeof data === "function") {
|
|||
|
return function(elem) {
|
|||
|
return (0, domhandler_1.isText)(elem) && data(elem.data);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
return (0, domhandler_1.isText)(elem) && elem.data === data;
|
|||
|
};
|
|||
|
}
|
|||
|
};
|
|||
|
function getAttribCheck(attrib, value) {
|
|||
|
if (typeof value === "function") {
|
|||
|
return function(elem) {
|
|||
|
return (0, domhandler_1.isTag)(elem) && value(elem.attribs[attrib]);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
return (0, domhandler_1.isTag)(elem) && elem.attribs[attrib] === value;
|
|||
|
};
|
|||
|
}
|
|||
|
function combineFuncs(a, b) {
|
|||
|
return function(elem) {
|
|||
|
return a(elem) || b(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
function compileTest(options) {
|
|||
|
var funcs = Object.keys(options).map(function(key) {
|
|||
|
var value = options[key];
|
|||
|
return Object.prototype.hasOwnProperty.call(Checks, key) ? Checks[key](value) : getAttribCheck(key, value);
|
|||
|
});
|
|||
|
return funcs.length === 0 ? null : funcs.reduce(combineFuncs);
|
|||
|
}
|
|||
|
function testElement(options, node) {
|
|||
|
var test = compileTest(options);
|
|||
|
return test ? test(node) : true;
|
|||
|
}
|
|||
|
exports.testElement = testElement;
|
|||
|
function getElements(options, nodes, recurse, limit) {
|
|||
|
if (limit === void 0) {
|
|||
|
limit = Infinity;
|
|||
|
}
|
|||
|
var test = compileTest(options);
|
|||
|
return test ? (0, querying_js_1.filter)(test, nodes, recurse, limit) : [];
|
|||
|
}
|
|||
|
exports.getElements = getElements;
|
|||
|
function getElementById(id, nodes, recurse) {
|
|||
|
if (recurse === void 0) {
|
|||
|
recurse = true;
|
|||
|
}
|
|||
|
if (!Array.isArray(nodes))
|
|||
|
nodes = [nodes];
|
|||
|
return (0, querying_js_1.findOne)(getAttribCheck("id", id), nodes, recurse);
|
|||
|
}
|
|||
|
exports.getElementById = getElementById;
|
|||
|
function getElementsByTagName(tagName, nodes, recurse, limit) {
|
|||
|
if (recurse === void 0) {
|
|||
|
recurse = true;
|
|||
|
}
|
|||
|
if (limit === void 0) {
|
|||
|
limit = Infinity;
|
|||
|
}
|
|||
|
return (0, querying_js_1.filter)(Checks["tag_name"](tagName), nodes, recurse, limit);
|
|||
|
}
|
|||
|
exports.getElementsByTagName = getElementsByTagName;
|
|||
|
function getElementsByTagType(type, nodes, recurse, limit) {
|
|||
|
if (recurse === void 0) {
|
|||
|
recurse = true;
|
|||
|
}
|
|||
|
if (limit === void 0) {
|
|||
|
limit = Infinity;
|
|||
|
}
|
|||
|
return (0, querying_js_1.filter)(Checks["tag_type"](type), nodes, recurse, limit);
|
|||
|
}
|
|||
|
exports.getElementsByTagType = getElementsByTagType;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domutils/lib/helpers.js
|
|||
|
var require_helpers = __commonJS({
|
|||
|
"node_modules/domutils/lib/helpers.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.uniqueSort = exports.compareDocumentPosition = exports.DocumentPosition = exports.removeSubsets = void 0;
|
|||
|
var domhandler_1 = require_lib2();
|
|||
|
function removeSubsets(nodes) {
|
|||
|
var idx = nodes.length;
|
|||
|
while (--idx >= 0) {
|
|||
|
var node = nodes[idx];
|
|||
|
if (idx > 0 && nodes.lastIndexOf(node, idx - 1) >= 0) {
|
|||
|
nodes.splice(idx, 1);
|
|||
|
continue;
|
|||
|
}
|
|||
|
for (var ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
|
|||
|
if (nodes.includes(ancestor)) {
|
|||
|
nodes.splice(idx, 1);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return nodes;
|
|||
|
}
|
|||
|
exports.removeSubsets = removeSubsets;
|
|||
|
var DocumentPosition;
|
|||
|
(function(DocumentPosition2) {
|
|||
|
DocumentPosition2[DocumentPosition2["DISCONNECTED"] = 1] = "DISCONNECTED";
|
|||
|
DocumentPosition2[DocumentPosition2["PRECEDING"] = 2] = "PRECEDING";
|
|||
|
DocumentPosition2[DocumentPosition2["FOLLOWING"] = 4] = "FOLLOWING";
|
|||
|
DocumentPosition2[DocumentPosition2["CONTAINS"] = 8] = "CONTAINS";
|
|||
|
DocumentPosition2[DocumentPosition2["CONTAINED_BY"] = 16] = "CONTAINED_BY";
|
|||
|
})(DocumentPosition = exports.DocumentPosition || (exports.DocumentPosition = {}));
|
|||
|
function compareDocumentPosition(nodeA, nodeB) {
|
|||
|
var aParents = [];
|
|||
|
var bParents = [];
|
|||
|
if (nodeA === nodeB) {
|
|||
|
return 0;
|
|||
|
}
|
|||
|
var current = (0, domhandler_1.hasChildren)(nodeA) ? nodeA : nodeA.parent;
|
|||
|
while (current) {
|
|||
|
aParents.unshift(current);
|
|||
|
current = current.parent;
|
|||
|
}
|
|||
|
current = (0, domhandler_1.hasChildren)(nodeB) ? nodeB : nodeB.parent;
|
|||
|
while (current) {
|
|||
|
bParents.unshift(current);
|
|||
|
current = current.parent;
|
|||
|
}
|
|||
|
var maxIdx = Math.min(aParents.length, bParents.length);
|
|||
|
var idx = 0;
|
|||
|
while (idx < maxIdx && aParents[idx] === bParents[idx]) {
|
|||
|
idx++;
|
|||
|
}
|
|||
|
if (idx === 0) {
|
|||
|
return DocumentPosition.DISCONNECTED;
|
|||
|
}
|
|||
|
var sharedParent = aParents[idx - 1];
|
|||
|
var siblings = sharedParent.children;
|
|||
|
var aSibling = aParents[idx];
|
|||
|
var bSibling = bParents[idx];
|
|||
|
if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) {
|
|||
|
if (sharedParent === nodeB) {
|
|||
|
return DocumentPosition.FOLLOWING | DocumentPosition.CONTAINED_BY;
|
|||
|
}
|
|||
|
return DocumentPosition.FOLLOWING;
|
|||
|
}
|
|||
|
if (sharedParent === nodeA) {
|
|||
|
return DocumentPosition.PRECEDING | DocumentPosition.CONTAINS;
|
|||
|
}
|
|||
|
return DocumentPosition.PRECEDING;
|
|||
|
}
|
|||
|
exports.compareDocumentPosition = compareDocumentPosition;
|
|||
|
function uniqueSort(nodes) {
|
|||
|
nodes = nodes.filter(function(node, i, arr) {
|
|||
|
return !arr.includes(node, i + 1);
|
|||
|
});
|
|||
|
nodes.sort(function(a, b) {
|
|||
|
var relative = compareDocumentPosition(a, b);
|
|||
|
if (relative & DocumentPosition.PRECEDING) {
|
|||
|
return -1;
|
|||
|
} else if (relative & DocumentPosition.FOLLOWING) {
|
|||
|
return 1;
|
|||
|
}
|
|||
|
return 0;
|
|||
|
});
|
|||
|
return nodes;
|
|||
|
}
|
|||
|
exports.uniqueSort = uniqueSort;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domutils/lib/feeds.js
|
|||
|
var require_feeds = __commonJS({
|
|||
|
"node_modules/domutils/lib/feeds.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.getFeed = void 0;
|
|||
|
var stringify_js_1 = require_stringify();
|
|||
|
var legacy_js_1 = require_legacy();
|
|||
|
function getFeed(doc) {
|
|||
|
var feedRoot = getOneElement(isValidFeed, doc);
|
|||
|
return !feedRoot ? null : feedRoot.name === "feed" ? getAtomFeed(feedRoot) : getRssFeed(feedRoot);
|
|||
|
}
|
|||
|
exports.getFeed = getFeed;
|
|||
|
function getAtomFeed(feedRoot) {
|
|||
|
var _a;
|
|||
|
var childs = feedRoot.children;
|
|||
|
var feed = {
|
|||
|
type: "atom",
|
|||
|
items: (0, legacy_js_1.getElementsByTagName)("entry", childs).map(function(item) {
|
|||
|
var _a2;
|
|||
|
var children = item.children;
|
|||
|
var entry = { media: getMediaElements(children) };
|
|||
|
addConditionally(entry, "id", "id", children);
|
|||
|
addConditionally(entry, "title", "title", children);
|
|||
|
var href2 = (_a2 = getOneElement("link", children)) === null || _a2 === void 0 ? void 0 : _a2.attribs["href"];
|
|||
|
if (href2) {
|
|||
|
entry.link = href2;
|
|||
|
}
|
|||
|
var description = fetch("summary", children) || fetch("content", children);
|
|||
|
if (description) {
|
|||
|
entry.description = description;
|
|||
|
}
|
|||
|
var pubDate = fetch("updated", children);
|
|||
|
if (pubDate) {
|
|||
|
entry.pubDate = new Date(pubDate);
|
|||
|
}
|
|||
|
return entry;
|
|||
|
})
|
|||
|
};
|
|||
|
addConditionally(feed, "id", "id", childs);
|
|||
|
addConditionally(feed, "title", "title", childs);
|
|||
|
var href = (_a = getOneElement("link", childs)) === null || _a === void 0 ? void 0 : _a.attribs["href"];
|
|||
|
if (href) {
|
|||
|
feed.link = href;
|
|||
|
}
|
|||
|
addConditionally(feed, "description", "subtitle", childs);
|
|||
|
var updated = fetch("updated", childs);
|
|||
|
if (updated) {
|
|||
|
feed.updated = new Date(updated);
|
|||
|
}
|
|||
|
addConditionally(feed, "author", "email", childs, true);
|
|||
|
return feed;
|
|||
|
}
|
|||
|
function getRssFeed(feedRoot) {
|
|||
|
var _a, _b;
|
|||
|
var childs = (_b = (_a = getOneElement("channel", feedRoot.children)) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [];
|
|||
|
var feed = {
|
|||
|
type: feedRoot.name.substr(0, 3),
|
|||
|
id: "",
|
|||
|
items: (0, legacy_js_1.getElementsByTagName)("item", feedRoot.children).map(function(item) {
|
|||
|
var children = item.children;
|
|||
|
var entry = { media: getMediaElements(children) };
|
|||
|
addConditionally(entry, "id", "guid", children);
|
|||
|
addConditionally(entry, "title", "title", children);
|
|||
|
addConditionally(entry, "link", "link", children);
|
|||
|
addConditionally(entry, "description", "description", children);
|
|||
|
var pubDate = fetch("pubDate", children) || fetch("dc:date", children);
|
|||
|
if (pubDate)
|
|||
|
entry.pubDate = new Date(pubDate);
|
|||
|
return entry;
|
|||
|
})
|
|||
|
};
|
|||
|
addConditionally(feed, "title", "title", childs);
|
|||
|
addConditionally(feed, "link", "link", childs);
|
|||
|
addConditionally(feed, "description", "description", childs);
|
|||
|
var updated = fetch("lastBuildDate", childs);
|
|||
|
if (updated) {
|
|||
|
feed.updated = new Date(updated);
|
|||
|
}
|
|||
|
addConditionally(feed, "author", "managingEditor", childs, true);
|
|||
|
return feed;
|
|||
|
}
|
|||
|
var MEDIA_KEYS_STRING = ["url", "type", "lang"];
|
|||
|
var MEDIA_KEYS_INT = [
|
|||
|
"fileSize",
|
|||
|
"bitrate",
|
|||
|
"framerate",
|
|||
|
"samplingrate",
|
|||
|
"channels",
|
|||
|
"duration",
|
|||
|
"height",
|
|||
|
"width"
|
|||
|
];
|
|||
|
function getMediaElements(where) {
|
|||
|
return (0, legacy_js_1.getElementsByTagName)("media:content", where).map(function(elem) {
|
|||
|
var attribs = elem.attribs;
|
|||
|
var media = {
|
|||
|
medium: attribs["medium"],
|
|||
|
isDefault: !!attribs["isDefault"]
|
|||
|
};
|
|||
|
for (var _i = 0, MEDIA_KEYS_STRING_1 = MEDIA_KEYS_STRING; _i < MEDIA_KEYS_STRING_1.length; _i++) {
|
|||
|
var attrib = MEDIA_KEYS_STRING_1[_i];
|
|||
|
if (attribs[attrib]) {
|
|||
|
media[attrib] = attribs[attrib];
|
|||
|
}
|
|||
|
}
|
|||
|
for (var _a = 0, MEDIA_KEYS_INT_1 = MEDIA_KEYS_INT; _a < MEDIA_KEYS_INT_1.length; _a++) {
|
|||
|
var attrib = MEDIA_KEYS_INT_1[_a];
|
|||
|
if (attribs[attrib]) {
|
|||
|
media[attrib] = parseInt(attribs[attrib], 10);
|
|||
|
}
|
|||
|
}
|
|||
|
if (attribs["expression"]) {
|
|||
|
media.expression = attribs["expression"];
|
|||
|
}
|
|||
|
return media;
|
|||
|
});
|
|||
|
}
|
|||
|
function getOneElement(tagName, node) {
|
|||
|
return (0, legacy_js_1.getElementsByTagName)(tagName, node, true, 1)[0];
|
|||
|
}
|
|||
|
function fetch(tagName, where, recurse) {
|
|||
|
if (recurse === void 0) {
|
|||
|
recurse = false;
|
|||
|
}
|
|||
|
return (0, stringify_js_1.textContent)((0, legacy_js_1.getElementsByTagName)(tagName, where, recurse, 1)).trim();
|
|||
|
}
|
|||
|
function addConditionally(obj, prop, tagName, where, recurse) {
|
|||
|
if (recurse === void 0) {
|
|||
|
recurse = false;
|
|||
|
}
|
|||
|
var val = fetch(tagName, where, recurse);
|
|||
|
if (val)
|
|||
|
obj[prop] = val;
|
|||
|
}
|
|||
|
function isValidFeed(value) {
|
|||
|
return value === "rss" || value === "feed" || value === "rdf:RDF";
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/domutils/lib/index.js
|
|||
|
var require_lib5 = __commonJS({
|
|||
|
"node_modules/domutils/lib/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|||
|
desc = { enumerable: true, get: function() {
|
|||
|
return m[k];
|
|||
|
} };
|
|||
|
}
|
|||
|
Object.defineProperty(o, k2, desc);
|
|||
|
} : function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
o[k2] = m[k];
|
|||
|
});
|
|||
|
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|||
|
for (var p in m)
|
|||
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|||
|
__createBinding(exports2, m, p);
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.hasChildren = exports.isDocument = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = void 0;
|
|||
|
__exportStar(require_stringify(), exports);
|
|||
|
__exportStar(require_traversal(), exports);
|
|||
|
__exportStar(require_manipulation(), exports);
|
|||
|
__exportStar(require_querying(), exports);
|
|||
|
__exportStar(require_legacy(), exports);
|
|||
|
__exportStar(require_helpers(), exports);
|
|||
|
__exportStar(require_feeds(), exports);
|
|||
|
var domhandler_1 = require_lib2();
|
|||
|
Object.defineProperty(exports, "isTag", { enumerable: true, get: function() {
|
|||
|
return domhandler_1.isTag;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "isCDATA", { enumerable: true, get: function() {
|
|||
|
return domhandler_1.isCDATA;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "isText", { enumerable: true, get: function() {
|
|||
|
return domhandler_1.isText;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "isComment", { enumerable: true, get: function() {
|
|||
|
return domhandler_1.isComment;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "isDocument", { enumerable: true, get: function() {
|
|||
|
return domhandler_1.isDocument;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "hasChildren", { enumerable: true, get: function() {
|
|||
|
return domhandler_1.hasChildren;
|
|||
|
} });
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/boolbase/index.js
|
|||
|
var require_boolbase = __commonJS({
|
|||
|
"node_modules/boolbase/index.js"(exports, module2) {
|
|||
|
module2.exports = {
|
|||
|
trueFunc: function trueFunc() {
|
|||
|
return true;
|
|||
|
},
|
|||
|
falseFunc: function falseFunc() {
|
|||
|
return false;
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-what/lib/commonjs/types.js
|
|||
|
var require_types = __commonJS({
|
|||
|
"node_modules/css-what/lib/commonjs/types.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.AttributeAction = exports.IgnoreCaseMode = exports.SelectorType = void 0;
|
|||
|
var SelectorType;
|
|||
|
(function(SelectorType2) {
|
|||
|
SelectorType2["Attribute"] = "attribute";
|
|||
|
SelectorType2["Pseudo"] = "pseudo";
|
|||
|
SelectorType2["PseudoElement"] = "pseudo-element";
|
|||
|
SelectorType2["Tag"] = "tag";
|
|||
|
SelectorType2["Universal"] = "universal";
|
|||
|
SelectorType2["Adjacent"] = "adjacent";
|
|||
|
SelectorType2["Child"] = "child";
|
|||
|
SelectorType2["Descendant"] = "descendant";
|
|||
|
SelectorType2["Parent"] = "parent";
|
|||
|
SelectorType2["Sibling"] = "sibling";
|
|||
|
SelectorType2["ColumnCombinator"] = "column-combinator";
|
|||
|
})(SelectorType = exports.SelectorType || (exports.SelectorType = {}));
|
|||
|
exports.IgnoreCaseMode = {
|
|||
|
Unknown: null,
|
|||
|
QuirksMode: "quirks",
|
|||
|
IgnoreCase: true,
|
|||
|
CaseSensitive: false
|
|||
|
};
|
|||
|
var AttributeAction;
|
|||
|
(function(AttributeAction2) {
|
|||
|
AttributeAction2["Any"] = "any";
|
|||
|
AttributeAction2["Element"] = "element";
|
|||
|
AttributeAction2["End"] = "end";
|
|||
|
AttributeAction2["Equals"] = "equals";
|
|||
|
AttributeAction2["Exists"] = "exists";
|
|||
|
AttributeAction2["Hyphen"] = "hyphen";
|
|||
|
AttributeAction2["Not"] = "not";
|
|||
|
AttributeAction2["Start"] = "start";
|
|||
|
})(AttributeAction = exports.AttributeAction || (exports.AttributeAction = {}));
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-what/lib/commonjs/parse.js
|
|||
|
var require_parse = __commonJS({
|
|||
|
"node_modules/css-what/lib/commonjs/parse.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.parse = exports.isTraversal = void 0;
|
|||
|
var types_1 = require_types();
|
|||
|
var reName = /^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/;
|
|||
|
var reEscape = /\\([\da-f]{1,6}\s?|(\s)|.)/gi;
|
|||
|
var actionTypes = /* @__PURE__ */ new Map([
|
|||
|
[126, types_1.AttributeAction.Element],
|
|||
|
[94, types_1.AttributeAction.Start],
|
|||
|
[36, types_1.AttributeAction.End],
|
|||
|
[42, types_1.AttributeAction.Any],
|
|||
|
[33, types_1.AttributeAction.Not],
|
|||
|
[124, types_1.AttributeAction.Hyphen]
|
|||
|
]);
|
|||
|
var unpackPseudos = /* @__PURE__ */ new Set([
|
|||
|
"has",
|
|||
|
"not",
|
|||
|
"matches",
|
|||
|
"is",
|
|||
|
"where",
|
|||
|
"host",
|
|||
|
"host-context"
|
|||
|
]);
|
|||
|
function isTraversal(selector) {
|
|||
|
switch (selector.type) {
|
|||
|
case types_1.SelectorType.Adjacent:
|
|||
|
case types_1.SelectorType.Child:
|
|||
|
case types_1.SelectorType.Descendant:
|
|||
|
case types_1.SelectorType.Parent:
|
|||
|
case types_1.SelectorType.Sibling:
|
|||
|
case types_1.SelectorType.ColumnCombinator:
|
|||
|
return true;
|
|||
|
default:
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
exports.isTraversal = isTraversal;
|
|||
|
var stripQuotesFromPseudos = /* @__PURE__ */ new Set(["contains", "icontains"]);
|
|||
|
function funescape(_, escaped, escapedWhitespace) {
|
|||
|
var high = parseInt(escaped, 16) - 65536;
|
|||
|
return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320);
|
|||
|
}
|
|||
|
function unescapeCSS(str) {
|
|||
|
return str.replace(reEscape, funescape);
|
|||
|
}
|
|||
|
function isQuote(c) {
|
|||
|
return c === 39 || c === 34;
|
|||
|
}
|
|||
|
function isWhitespace(c) {
|
|||
|
return c === 32 || c === 9 || c === 10 || c === 12 || c === 13;
|
|||
|
}
|
|||
|
function parse2(selector) {
|
|||
|
var subselects = [];
|
|||
|
var endIndex = parseSelector(subselects, "".concat(selector), 0);
|
|||
|
if (endIndex < selector.length) {
|
|||
|
throw new Error("Unmatched selector: ".concat(selector.slice(endIndex)));
|
|||
|
}
|
|||
|
return subselects;
|
|||
|
}
|
|||
|
exports.parse = parse2;
|
|||
|
function parseSelector(subselects, selector, selectorIndex) {
|
|||
|
var tokens = [];
|
|||
|
function getName(offset) {
|
|||
|
var match = selector.slice(selectorIndex + offset).match(reName);
|
|||
|
if (!match) {
|
|||
|
throw new Error("Expected name, found ".concat(selector.slice(selectorIndex)));
|
|||
|
}
|
|||
|
var name = match[0];
|
|||
|
selectorIndex += offset + name.length;
|
|||
|
return unescapeCSS(name);
|
|||
|
}
|
|||
|
function stripWhitespace(offset) {
|
|||
|
selectorIndex += offset;
|
|||
|
while (selectorIndex < selector.length && isWhitespace(selector.charCodeAt(selectorIndex))) {
|
|||
|
selectorIndex++;
|
|||
|
}
|
|||
|
}
|
|||
|
function readValueWithParenthesis() {
|
|||
|
selectorIndex += 1;
|
|||
|
var start = selectorIndex;
|
|||
|
var counter = 1;
|
|||
|
for (; counter > 0 && selectorIndex < selector.length; selectorIndex++) {
|
|||
|
if (selector.charCodeAt(selectorIndex) === 40 && !isEscaped(selectorIndex)) {
|
|||
|
counter++;
|
|||
|
} else if (selector.charCodeAt(selectorIndex) === 41 && !isEscaped(selectorIndex)) {
|
|||
|
counter--;
|
|||
|
}
|
|||
|
}
|
|||
|
if (counter) {
|
|||
|
throw new Error("Parenthesis not matched");
|
|||
|
}
|
|||
|
return unescapeCSS(selector.slice(start, selectorIndex - 1));
|
|||
|
}
|
|||
|
function isEscaped(pos) {
|
|||
|
var slashCount = 0;
|
|||
|
while (selector.charCodeAt(--pos) === 92)
|
|||
|
slashCount++;
|
|||
|
return (slashCount & 1) === 1;
|
|||
|
}
|
|||
|
function ensureNotTraversal() {
|
|||
|
if (tokens.length > 0 && isTraversal(tokens[tokens.length - 1])) {
|
|||
|
throw new Error("Did not expect successive traversals.");
|
|||
|
}
|
|||
|
}
|
|||
|
function addTraversal(type) {
|
|||
|
if (tokens.length > 0 && tokens[tokens.length - 1].type === types_1.SelectorType.Descendant) {
|
|||
|
tokens[tokens.length - 1].type = type;
|
|||
|
return;
|
|||
|
}
|
|||
|
ensureNotTraversal();
|
|||
|
tokens.push({ type });
|
|||
|
}
|
|||
|
function addSpecialAttribute(name, action2) {
|
|||
|
tokens.push({
|
|||
|
type: types_1.SelectorType.Attribute,
|
|||
|
name,
|
|||
|
action: action2,
|
|||
|
value: getName(1),
|
|||
|
namespace: null,
|
|||
|
ignoreCase: "quirks"
|
|||
|
});
|
|||
|
}
|
|||
|
function finalizeSubselector() {
|
|||
|
if (tokens.length && tokens[tokens.length - 1].type === types_1.SelectorType.Descendant) {
|
|||
|
tokens.pop();
|
|||
|
}
|
|||
|
if (tokens.length === 0) {
|
|||
|
throw new Error("Empty sub-selector");
|
|||
|
}
|
|||
|
subselects.push(tokens);
|
|||
|
}
|
|||
|
stripWhitespace(0);
|
|||
|
if (selector.length === selectorIndex) {
|
|||
|
return selectorIndex;
|
|||
|
}
|
|||
|
loop:
|
|||
|
while (selectorIndex < selector.length) {
|
|||
|
var firstChar = selector.charCodeAt(selectorIndex);
|
|||
|
switch (firstChar) {
|
|||
|
case 32:
|
|||
|
case 9:
|
|||
|
case 10:
|
|||
|
case 12:
|
|||
|
case 13: {
|
|||
|
if (tokens.length === 0 || tokens[0].type !== types_1.SelectorType.Descendant) {
|
|||
|
ensureNotTraversal();
|
|||
|
tokens.push({ type: types_1.SelectorType.Descendant });
|
|||
|
}
|
|||
|
stripWhitespace(1);
|
|||
|
break;
|
|||
|
}
|
|||
|
case 62: {
|
|||
|
addTraversal(types_1.SelectorType.Child);
|
|||
|
stripWhitespace(1);
|
|||
|
break;
|
|||
|
}
|
|||
|
case 60: {
|
|||
|
addTraversal(types_1.SelectorType.Parent);
|
|||
|
stripWhitespace(1);
|
|||
|
break;
|
|||
|
}
|
|||
|
case 126: {
|
|||
|
addTraversal(types_1.SelectorType.Sibling);
|
|||
|
stripWhitespace(1);
|
|||
|
break;
|
|||
|
}
|
|||
|
case 43: {
|
|||
|
addTraversal(types_1.SelectorType.Adjacent);
|
|||
|
stripWhitespace(1);
|
|||
|
break;
|
|||
|
}
|
|||
|
case 46: {
|
|||
|
addSpecialAttribute("class", types_1.AttributeAction.Element);
|
|||
|
break;
|
|||
|
}
|
|||
|
case 35: {
|
|||
|
addSpecialAttribute("id", types_1.AttributeAction.Equals);
|
|||
|
break;
|
|||
|
}
|
|||
|
case 91: {
|
|||
|
stripWhitespace(1);
|
|||
|
var name_1 = void 0;
|
|||
|
var namespace = null;
|
|||
|
if (selector.charCodeAt(selectorIndex) === 124) {
|
|||
|
name_1 = getName(1);
|
|||
|
} else if (selector.startsWith("*|", selectorIndex)) {
|
|||
|
namespace = "*";
|
|||
|
name_1 = getName(2);
|
|||
|
} else {
|
|||
|
name_1 = getName(0);
|
|||
|
if (selector.charCodeAt(selectorIndex) === 124 && selector.charCodeAt(selectorIndex + 1) !== 61) {
|
|||
|
namespace = name_1;
|
|||
|
name_1 = getName(1);
|
|||
|
}
|
|||
|
}
|
|||
|
stripWhitespace(0);
|
|||
|
var action = types_1.AttributeAction.Exists;
|
|||
|
var possibleAction = actionTypes.get(selector.charCodeAt(selectorIndex));
|
|||
|
if (possibleAction) {
|
|||
|
action = possibleAction;
|
|||
|
if (selector.charCodeAt(selectorIndex + 1) !== 61) {
|
|||
|
throw new Error("Expected `=`");
|
|||
|
}
|
|||
|
stripWhitespace(2);
|
|||
|
} else if (selector.charCodeAt(selectorIndex) === 61) {
|
|||
|
action = types_1.AttributeAction.Equals;
|
|||
|
stripWhitespace(1);
|
|||
|
}
|
|||
|
var value = "";
|
|||
|
var ignoreCase = null;
|
|||
|
if (action !== "exists") {
|
|||
|
if (isQuote(selector.charCodeAt(selectorIndex))) {
|
|||
|
var quote = selector.charCodeAt(selectorIndex);
|
|||
|
var sectionEnd = selectorIndex + 1;
|
|||
|
while (sectionEnd < selector.length && (selector.charCodeAt(sectionEnd) !== quote || isEscaped(sectionEnd))) {
|
|||
|
sectionEnd += 1;
|
|||
|
}
|
|||
|
if (selector.charCodeAt(sectionEnd) !== quote) {
|
|||
|
throw new Error("Attribute value didn't end");
|
|||
|
}
|
|||
|
value = unescapeCSS(selector.slice(selectorIndex + 1, sectionEnd));
|
|||
|
selectorIndex = sectionEnd + 1;
|
|||
|
} else {
|
|||
|
var valueStart = selectorIndex;
|
|||
|
while (selectorIndex < selector.length && (!isWhitespace(selector.charCodeAt(selectorIndex)) && selector.charCodeAt(selectorIndex) !== 93 || isEscaped(selectorIndex))) {
|
|||
|
selectorIndex += 1;
|
|||
|
}
|
|||
|
value = unescapeCSS(selector.slice(valueStart, selectorIndex));
|
|||
|
}
|
|||
|
stripWhitespace(0);
|
|||
|
var forceIgnore = selector.charCodeAt(selectorIndex) | 32;
|
|||
|
if (forceIgnore === 115) {
|
|||
|
ignoreCase = false;
|
|||
|
stripWhitespace(1);
|
|||
|
} else if (forceIgnore === 105) {
|
|||
|
ignoreCase = true;
|
|||
|
stripWhitespace(1);
|
|||
|
}
|
|||
|
}
|
|||
|
if (selector.charCodeAt(selectorIndex) !== 93) {
|
|||
|
throw new Error("Attribute selector didn't terminate");
|
|||
|
}
|
|||
|
selectorIndex += 1;
|
|||
|
var attributeSelector = {
|
|||
|
type: types_1.SelectorType.Attribute,
|
|||
|
name: name_1,
|
|||
|
action,
|
|||
|
value,
|
|||
|
namespace,
|
|||
|
ignoreCase
|
|||
|
};
|
|||
|
tokens.push(attributeSelector);
|
|||
|
break;
|
|||
|
}
|
|||
|
case 58: {
|
|||
|
if (selector.charCodeAt(selectorIndex + 1) === 58) {
|
|||
|
tokens.push({
|
|||
|
type: types_1.SelectorType.PseudoElement,
|
|||
|
name: getName(2).toLowerCase(),
|
|||
|
data: selector.charCodeAt(selectorIndex) === 40 ? readValueWithParenthesis() : null
|
|||
|
});
|
|||
|
continue;
|
|||
|
}
|
|||
|
var name_2 = getName(1).toLowerCase();
|
|||
|
var data = null;
|
|||
|
if (selector.charCodeAt(selectorIndex) === 40) {
|
|||
|
if (unpackPseudos.has(name_2)) {
|
|||
|
if (isQuote(selector.charCodeAt(selectorIndex + 1))) {
|
|||
|
throw new Error("Pseudo-selector ".concat(name_2, " cannot be quoted"));
|
|||
|
}
|
|||
|
data = [];
|
|||
|
selectorIndex = parseSelector(data, selector, selectorIndex + 1);
|
|||
|
if (selector.charCodeAt(selectorIndex) !== 41) {
|
|||
|
throw new Error("Missing closing parenthesis in :".concat(name_2, " (").concat(selector, ")"));
|
|||
|
}
|
|||
|
selectorIndex += 1;
|
|||
|
} else {
|
|||
|
data = readValueWithParenthesis();
|
|||
|
if (stripQuotesFromPseudos.has(name_2)) {
|
|||
|
var quot = data.charCodeAt(0);
|
|||
|
if (quot === data.charCodeAt(data.length - 1) && isQuote(quot)) {
|
|||
|
data = data.slice(1, -1);
|
|||
|
}
|
|||
|
}
|
|||
|
data = unescapeCSS(data);
|
|||
|
}
|
|||
|
}
|
|||
|
tokens.push({ type: types_1.SelectorType.Pseudo, name: name_2, data });
|
|||
|
break;
|
|||
|
}
|
|||
|
case 44: {
|
|||
|
finalizeSubselector();
|
|||
|
tokens = [];
|
|||
|
stripWhitespace(1);
|
|||
|
break;
|
|||
|
}
|
|||
|
default: {
|
|||
|
if (selector.startsWith("/*", selectorIndex)) {
|
|||
|
var endIndex = selector.indexOf("*/", selectorIndex + 2);
|
|||
|
if (endIndex < 0) {
|
|||
|
throw new Error("Comment was not terminated");
|
|||
|
}
|
|||
|
selectorIndex = endIndex + 2;
|
|||
|
if (tokens.length === 0) {
|
|||
|
stripWhitespace(0);
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
var namespace = null;
|
|||
|
var name_3 = void 0;
|
|||
|
if (firstChar === 42) {
|
|||
|
selectorIndex += 1;
|
|||
|
name_3 = "*";
|
|||
|
} else if (firstChar === 124) {
|
|||
|
name_3 = "";
|
|||
|
if (selector.charCodeAt(selectorIndex + 1) === 124) {
|
|||
|
addTraversal(types_1.SelectorType.ColumnCombinator);
|
|||
|
stripWhitespace(2);
|
|||
|
break;
|
|||
|
}
|
|||
|
} else if (reName.test(selector.slice(selectorIndex))) {
|
|||
|
name_3 = getName(0);
|
|||
|
} else {
|
|||
|
break loop;
|
|||
|
}
|
|||
|
if (selector.charCodeAt(selectorIndex) === 124 && selector.charCodeAt(selectorIndex + 1) !== 124) {
|
|||
|
namespace = name_3;
|
|||
|
if (selector.charCodeAt(selectorIndex + 1) === 42) {
|
|||
|
name_3 = "*";
|
|||
|
selectorIndex += 2;
|
|||
|
} else {
|
|||
|
name_3 = getName(1);
|
|||
|
}
|
|||
|
}
|
|||
|
tokens.push(name_3 === "*" ? { type: types_1.SelectorType.Universal, namespace } : { type: types_1.SelectorType.Tag, name: name_3, namespace });
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
finalizeSubselector();
|
|||
|
return selectorIndex;
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-what/lib/commonjs/stringify.js
|
|||
|
var require_stringify2 = __commonJS({
|
|||
|
"node_modules/css-what/lib/commonjs/stringify.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|||
|
if (pack || arguments.length === 2)
|
|||
|
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|||
|
if (ar || !(i in from)) {
|
|||
|
if (!ar)
|
|||
|
ar = Array.prototype.slice.call(from, 0, i);
|
|||
|
ar[i] = from[i];
|
|||
|
}
|
|||
|
}
|
|||
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.stringify = void 0;
|
|||
|
var types_1 = require_types();
|
|||
|
var attribValChars = ["\\", '"'];
|
|||
|
var pseudoValChars = __spreadArray(__spreadArray([], attribValChars, true), ["(", ")"], false);
|
|||
|
var charsToEscapeInAttributeValue = new Set(attribValChars.map(function(c) {
|
|||
|
return c.charCodeAt(0);
|
|||
|
}));
|
|||
|
var charsToEscapeInPseudoValue = new Set(pseudoValChars.map(function(c) {
|
|||
|
return c.charCodeAt(0);
|
|||
|
}));
|
|||
|
var charsToEscapeInName = new Set(__spreadArray(__spreadArray([], pseudoValChars, true), [
|
|||
|
"~",
|
|||
|
"^",
|
|||
|
"$",
|
|||
|
"*",
|
|||
|
"+",
|
|||
|
"!",
|
|||
|
"|",
|
|||
|
":",
|
|||
|
"[",
|
|||
|
"]",
|
|||
|
" ",
|
|||
|
"."
|
|||
|
], false).map(function(c) {
|
|||
|
return c.charCodeAt(0);
|
|||
|
}));
|
|||
|
function stringify(selector) {
|
|||
|
return selector.map(function(token) {
|
|||
|
return token.map(stringifyToken).join("");
|
|||
|
}).join(", ");
|
|||
|
}
|
|||
|
exports.stringify = stringify;
|
|||
|
function stringifyToken(token, index, arr) {
|
|||
|
switch (token.type) {
|
|||
|
case types_1.SelectorType.Child:
|
|||
|
return index === 0 ? "> " : " > ";
|
|||
|
case types_1.SelectorType.Parent:
|
|||
|
return index === 0 ? "< " : " < ";
|
|||
|
case types_1.SelectorType.Sibling:
|
|||
|
return index === 0 ? "~ " : " ~ ";
|
|||
|
case types_1.SelectorType.Adjacent:
|
|||
|
return index === 0 ? "+ " : " + ";
|
|||
|
case types_1.SelectorType.Descendant:
|
|||
|
return " ";
|
|||
|
case types_1.SelectorType.ColumnCombinator:
|
|||
|
return index === 0 ? "|| " : " || ";
|
|||
|
case types_1.SelectorType.Universal:
|
|||
|
return token.namespace === "*" && index + 1 < arr.length && "name" in arr[index + 1] ? "" : "".concat(getNamespace(token.namespace), "*");
|
|||
|
case types_1.SelectorType.Tag:
|
|||
|
return getNamespacedName(token);
|
|||
|
case types_1.SelectorType.PseudoElement:
|
|||
|
return "::".concat(escapeName(token.name, charsToEscapeInName)).concat(token.data === null ? "" : "(".concat(escapeName(token.data, charsToEscapeInPseudoValue), ")"));
|
|||
|
case types_1.SelectorType.Pseudo:
|
|||
|
return ":".concat(escapeName(token.name, charsToEscapeInName)).concat(token.data === null ? "" : "(".concat(typeof token.data === "string" ? escapeName(token.data, charsToEscapeInPseudoValue) : stringify(token.data), ")"));
|
|||
|
case types_1.SelectorType.Attribute: {
|
|||
|
if (token.name === "id" && token.action === types_1.AttributeAction.Equals && token.ignoreCase === "quirks" && !token.namespace) {
|
|||
|
return "#".concat(escapeName(token.value, charsToEscapeInName));
|
|||
|
}
|
|||
|
if (token.name === "class" && token.action === types_1.AttributeAction.Element && token.ignoreCase === "quirks" && !token.namespace) {
|
|||
|
return ".".concat(escapeName(token.value, charsToEscapeInName));
|
|||
|
}
|
|||
|
var name_1 = getNamespacedName(token);
|
|||
|
if (token.action === types_1.AttributeAction.Exists) {
|
|||
|
return "[".concat(name_1, "]");
|
|||
|
}
|
|||
|
return "[".concat(name_1).concat(getActionValue(token.action), '="').concat(escapeName(token.value, charsToEscapeInAttributeValue), '"').concat(token.ignoreCase === null ? "" : token.ignoreCase ? " i" : " s", "]");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
function getActionValue(action) {
|
|||
|
switch (action) {
|
|||
|
case types_1.AttributeAction.Equals:
|
|||
|
return "";
|
|||
|
case types_1.AttributeAction.Element:
|
|||
|
return "~";
|
|||
|
case types_1.AttributeAction.Start:
|
|||
|
return "^";
|
|||
|
case types_1.AttributeAction.End:
|
|||
|
return "$";
|
|||
|
case types_1.AttributeAction.Any:
|
|||
|
return "*";
|
|||
|
case types_1.AttributeAction.Not:
|
|||
|
return "!";
|
|||
|
case types_1.AttributeAction.Hyphen:
|
|||
|
return "|";
|
|||
|
case types_1.AttributeAction.Exists:
|
|||
|
throw new Error("Shouldn't be here");
|
|||
|
}
|
|||
|
}
|
|||
|
function getNamespacedName(token) {
|
|||
|
return "".concat(getNamespace(token.namespace)).concat(escapeName(token.name, charsToEscapeInName));
|
|||
|
}
|
|||
|
function getNamespace(namespace) {
|
|||
|
return namespace !== null ? "".concat(namespace === "*" ? "*" : escapeName(namespace, charsToEscapeInName), "|") : "";
|
|||
|
}
|
|||
|
function escapeName(str, charsToEscape) {
|
|||
|
var lastIdx = 0;
|
|||
|
var ret = "";
|
|||
|
for (var i = 0; i < str.length; i++) {
|
|||
|
if (charsToEscape.has(str.charCodeAt(i))) {
|
|||
|
ret += "".concat(str.slice(lastIdx, i), "\\").concat(str.charAt(i));
|
|||
|
lastIdx = i + 1;
|
|||
|
}
|
|||
|
}
|
|||
|
return ret.length > 0 ? ret + str.slice(lastIdx) : str;
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-what/lib/commonjs/index.js
|
|||
|
var require_commonjs = __commonJS({
|
|||
|
"node_modules/css-what/lib/commonjs/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|||
|
desc = { enumerable: true, get: function() {
|
|||
|
return m[k];
|
|||
|
} };
|
|||
|
}
|
|||
|
Object.defineProperty(o, k2, desc);
|
|||
|
} : function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
o[k2] = m[k];
|
|||
|
});
|
|||
|
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|||
|
for (var p in m)
|
|||
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|||
|
__createBinding(exports2, m, p);
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.stringify = exports.parse = exports.isTraversal = void 0;
|
|||
|
__exportStar(require_types(), exports);
|
|||
|
var parse_1 = require_parse();
|
|||
|
Object.defineProperty(exports, "isTraversal", { enumerable: true, get: function() {
|
|||
|
return parse_1.isTraversal;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "parse", { enumerable: true, get: function() {
|
|||
|
return parse_1.parse;
|
|||
|
} });
|
|||
|
var stringify_1 = require_stringify2();
|
|||
|
Object.defineProperty(exports, "stringify", { enumerable: true, get: function() {
|
|||
|
return stringify_1.stringify;
|
|||
|
} });
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/sort.js
|
|||
|
var require_sort = __commonJS({
|
|||
|
"node_modules/css-select/lib/sort.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.isTraversal = void 0;
|
|||
|
var css_what_1 = require_commonjs();
|
|||
|
var procedure = /* @__PURE__ */ new Map([
|
|||
|
[css_what_1.SelectorType.Universal, 50],
|
|||
|
[css_what_1.SelectorType.Tag, 30],
|
|||
|
[css_what_1.SelectorType.Attribute, 1],
|
|||
|
[css_what_1.SelectorType.Pseudo, 0]
|
|||
|
]);
|
|||
|
function isTraversal(token) {
|
|||
|
return !procedure.has(token.type);
|
|||
|
}
|
|||
|
exports.isTraversal = isTraversal;
|
|||
|
var attributes = /* @__PURE__ */ new Map([
|
|||
|
[css_what_1.AttributeAction.Exists, 10],
|
|||
|
[css_what_1.AttributeAction.Equals, 8],
|
|||
|
[css_what_1.AttributeAction.Not, 7],
|
|||
|
[css_what_1.AttributeAction.Start, 6],
|
|||
|
[css_what_1.AttributeAction.End, 6],
|
|||
|
[css_what_1.AttributeAction.Any, 5]
|
|||
|
]);
|
|||
|
function sortByProcedure(arr) {
|
|||
|
var procs = arr.map(getProcedure);
|
|||
|
for (var i = 1; i < arr.length; i++) {
|
|||
|
var procNew = procs[i];
|
|||
|
if (procNew < 0)
|
|||
|
continue;
|
|||
|
for (var j = i - 1; j >= 0 && procNew < procs[j]; j--) {
|
|||
|
var token = arr[j + 1];
|
|||
|
arr[j + 1] = arr[j];
|
|||
|
arr[j] = token;
|
|||
|
procs[j + 1] = procs[j];
|
|||
|
procs[j] = procNew;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
exports.default = sortByProcedure;
|
|||
|
function getProcedure(token) {
|
|||
|
var _a, _b;
|
|||
|
var proc = (_a = procedure.get(token.type)) !== null && _a !== void 0 ? _a : -1;
|
|||
|
if (token.type === css_what_1.SelectorType.Attribute) {
|
|||
|
proc = (_b = attributes.get(token.action)) !== null && _b !== void 0 ? _b : 4;
|
|||
|
if (token.action === css_what_1.AttributeAction.Equals && token.name === "id") {
|
|||
|
proc = 9;
|
|||
|
}
|
|||
|
if (token.ignoreCase) {
|
|||
|
proc >>= 1;
|
|||
|
}
|
|||
|
} else if (token.type === css_what_1.SelectorType.Pseudo) {
|
|||
|
if (!token.data) {
|
|||
|
proc = 3;
|
|||
|
} else if (token.name === "has" || token.name === "contains") {
|
|||
|
proc = 0;
|
|||
|
} else if (Array.isArray(token.data)) {
|
|||
|
proc = Math.min.apply(Math, token.data.map(function(d) {
|
|||
|
return Math.min.apply(Math, d.map(getProcedure));
|
|||
|
}));
|
|||
|
if (proc < 0) {
|
|||
|
proc = 0;
|
|||
|
}
|
|||
|
} else {
|
|||
|
proc = 2;
|
|||
|
}
|
|||
|
}
|
|||
|
return proc;
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/attributes.js
|
|||
|
var require_attributes = __commonJS({
|
|||
|
"node_modules/css-select/lib/attributes.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.attributeRules = void 0;
|
|||
|
var boolbase_1 = __importDefault(require_boolbase());
|
|||
|
var reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
|
|||
|
function escapeRegex(value) {
|
|||
|
return value.replace(reChars, "\\$&");
|
|||
|
}
|
|||
|
var caseInsensitiveAttributes = /* @__PURE__ */ new Set([
|
|||
|
"accept",
|
|||
|
"accept-charset",
|
|||
|
"align",
|
|||
|
"alink",
|
|||
|
"axis",
|
|||
|
"bgcolor",
|
|||
|
"charset",
|
|||
|
"checked",
|
|||
|
"clear",
|
|||
|
"codetype",
|
|||
|
"color",
|
|||
|
"compact",
|
|||
|
"declare",
|
|||
|
"defer",
|
|||
|
"dir",
|
|||
|
"direction",
|
|||
|
"disabled",
|
|||
|
"enctype",
|
|||
|
"face",
|
|||
|
"frame",
|
|||
|
"hreflang",
|
|||
|
"http-equiv",
|
|||
|
"lang",
|
|||
|
"language",
|
|||
|
"link",
|
|||
|
"media",
|
|||
|
"method",
|
|||
|
"multiple",
|
|||
|
"nohref",
|
|||
|
"noresize",
|
|||
|
"noshade",
|
|||
|
"nowrap",
|
|||
|
"readonly",
|
|||
|
"rel",
|
|||
|
"rev",
|
|||
|
"rules",
|
|||
|
"scope",
|
|||
|
"scrolling",
|
|||
|
"selected",
|
|||
|
"shape",
|
|||
|
"target",
|
|||
|
"text",
|
|||
|
"type",
|
|||
|
"valign",
|
|||
|
"valuetype",
|
|||
|
"vlink"
|
|||
|
]);
|
|||
|
function shouldIgnoreCase(selector, options) {
|
|||
|
return typeof selector.ignoreCase === "boolean" ? selector.ignoreCase : selector.ignoreCase === "quirks" ? !!options.quirksMode : !options.xmlMode && caseInsensitiveAttributes.has(selector.name);
|
|||
|
}
|
|||
|
exports.attributeRules = {
|
|||
|
equals: function(next, data, options) {
|
|||
|
var adapter = options.adapter;
|
|||
|
var name = data.name;
|
|||
|
var value = data.value;
|
|||
|
if (shouldIgnoreCase(data, options)) {
|
|||
|
value = value.toLowerCase();
|
|||
|
return function(elem) {
|
|||
|
var attr = adapter.getAttributeValue(elem, name);
|
|||
|
return attr != null && attr.length === value.length && attr.toLowerCase() === value && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
return adapter.getAttributeValue(elem, name) === value && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
hyphen: function(next, data, options) {
|
|||
|
var adapter = options.adapter;
|
|||
|
var name = data.name;
|
|||
|
var value = data.value;
|
|||
|
var len = value.length;
|
|||
|
if (shouldIgnoreCase(data, options)) {
|
|||
|
value = value.toLowerCase();
|
|||
|
return function hyphenIC(elem) {
|
|||
|
var attr = adapter.getAttributeValue(elem, name);
|
|||
|
return attr != null && (attr.length === len || attr.charAt(len) === "-") && attr.substr(0, len).toLowerCase() === value && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
return function hyphen(elem) {
|
|||
|
var attr = adapter.getAttributeValue(elem, name);
|
|||
|
return attr != null && (attr.length === len || attr.charAt(len) === "-") && attr.substr(0, len) === value && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
element: function(next, data, options) {
|
|||
|
var adapter = options.adapter;
|
|||
|
var name = data.name, value = data.value;
|
|||
|
if (/\s/.test(value)) {
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
}
|
|||
|
var regex = new RegExp("(?:^|\\s)".concat(escapeRegex(value), "(?:$|\\s)"), shouldIgnoreCase(data, options) ? "i" : "");
|
|||
|
return function element(elem) {
|
|||
|
var attr = adapter.getAttributeValue(elem, name);
|
|||
|
return attr != null && attr.length >= value.length && regex.test(attr) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
exists: function(next, _a, _b) {
|
|||
|
var name = _a.name;
|
|||
|
var adapter = _b.adapter;
|
|||
|
return function(elem) {
|
|||
|
return adapter.hasAttrib(elem, name) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
start: function(next, data, options) {
|
|||
|
var adapter = options.adapter;
|
|||
|
var name = data.name;
|
|||
|
var value = data.value;
|
|||
|
var len = value.length;
|
|||
|
if (len === 0) {
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
}
|
|||
|
if (shouldIgnoreCase(data, options)) {
|
|||
|
value = value.toLowerCase();
|
|||
|
return function(elem) {
|
|||
|
var attr = adapter.getAttributeValue(elem, name);
|
|||
|
return attr != null && attr.length >= len && attr.substr(0, len).toLowerCase() === value && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
var _a;
|
|||
|
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
end: function(next, data, options) {
|
|||
|
var adapter = options.adapter;
|
|||
|
var name = data.name;
|
|||
|
var value = data.value;
|
|||
|
var len = -value.length;
|
|||
|
if (len === 0) {
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
}
|
|||
|
if (shouldIgnoreCase(data, options)) {
|
|||
|
value = value.toLowerCase();
|
|||
|
return function(elem) {
|
|||
|
var _a;
|
|||
|
return ((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
var _a;
|
|||
|
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
any: function(next, data, options) {
|
|||
|
var adapter = options.adapter;
|
|||
|
var name = data.name, value = data.value;
|
|||
|
if (value === "") {
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
}
|
|||
|
if (shouldIgnoreCase(data, options)) {
|
|||
|
var regex_1 = new RegExp(escapeRegex(value), "i");
|
|||
|
return function anyIC(elem) {
|
|||
|
var attr = adapter.getAttributeValue(elem, name);
|
|||
|
return attr != null && attr.length >= value.length && regex_1.test(attr) && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
var _a;
|
|||
|
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
not: function(next, data, options) {
|
|||
|
var adapter = options.adapter;
|
|||
|
var name = data.name;
|
|||
|
var value = data.value;
|
|||
|
if (value === "") {
|
|||
|
return function(elem) {
|
|||
|
return !!adapter.getAttributeValue(elem, name) && next(elem);
|
|||
|
};
|
|||
|
} else if (shouldIgnoreCase(data, options)) {
|
|||
|
value = value.toLowerCase();
|
|||
|
return function(elem) {
|
|||
|
var attr = adapter.getAttributeValue(elem, name);
|
|||
|
return (attr == null || attr.length !== value.length || attr.toLowerCase() !== value) && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
return adapter.getAttributeValue(elem, name) !== value && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/nth-check/lib/parse.js
|
|||
|
var require_parse2 = __commonJS({
|
|||
|
"node_modules/nth-check/lib/parse.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.parse = void 0;
|
|||
|
var whitespace = /* @__PURE__ */ new Set([9, 10, 12, 13, 32]);
|
|||
|
var ZERO = "0".charCodeAt(0);
|
|||
|
var NINE = "9".charCodeAt(0);
|
|||
|
function parse2(formula) {
|
|||
|
formula = formula.trim().toLowerCase();
|
|||
|
if (formula === "even") {
|
|||
|
return [2, 0];
|
|||
|
} else if (formula === "odd") {
|
|||
|
return [2, 1];
|
|||
|
}
|
|||
|
var idx = 0;
|
|||
|
var a = 0;
|
|||
|
var sign = readSign();
|
|||
|
var number = readNumber();
|
|||
|
if (idx < formula.length && formula.charAt(idx) === "n") {
|
|||
|
idx++;
|
|||
|
a = sign * (number !== null && number !== void 0 ? number : 1);
|
|||
|
skipWhitespace();
|
|||
|
if (idx < formula.length) {
|
|||
|
sign = readSign();
|
|||
|
skipWhitespace();
|
|||
|
number = readNumber();
|
|||
|
} else {
|
|||
|
sign = number = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
if (number === null || idx < formula.length) {
|
|||
|
throw new Error("n-th rule couldn't be parsed ('".concat(formula, "')"));
|
|||
|
}
|
|||
|
return [a, sign * number];
|
|||
|
function readSign() {
|
|||
|
if (formula.charAt(idx) === "-") {
|
|||
|
idx++;
|
|||
|
return -1;
|
|||
|
}
|
|||
|
if (formula.charAt(idx) === "+") {
|
|||
|
idx++;
|
|||
|
}
|
|||
|
return 1;
|
|||
|
}
|
|||
|
function readNumber() {
|
|||
|
var start = idx;
|
|||
|
var value = 0;
|
|||
|
while (idx < formula.length && formula.charCodeAt(idx) >= ZERO && formula.charCodeAt(idx) <= NINE) {
|
|||
|
value = value * 10 + (formula.charCodeAt(idx) - ZERO);
|
|||
|
idx++;
|
|||
|
}
|
|||
|
return idx === start ? null : value;
|
|||
|
}
|
|||
|
function skipWhitespace() {
|
|||
|
while (idx < formula.length && whitespace.has(formula.charCodeAt(idx))) {
|
|||
|
idx++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
exports.parse = parse2;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/nth-check/lib/compile.js
|
|||
|
var require_compile = __commonJS({
|
|||
|
"node_modules/nth-check/lib/compile.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.generate = exports.compile = void 0;
|
|||
|
var boolbase_1 = __importDefault(require_boolbase());
|
|||
|
function compile(parsed) {
|
|||
|
var a = parsed[0];
|
|||
|
var b = parsed[1] - 1;
|
|||
|
if (b < 0 && a <= 0)
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
if (a === -1)
|
|||
|
return function(index) {
|
|||
|
return index <= b;
|
|||
|
};
|
|||
|
if (a === 0)
|
|||
|
return function(index) {
|
|||
|
return index === b;
|
|||
|
};
|
|||
|
if (a === 1)
|
|||
|
return b < 0 ? boolbase_1.default.trueFunc : function(index) {
|
|||
|
return index >= b;
|
|||
|
};
|
|||
|
var absA = Math.abs(a);
|
|||
|
var bMod = (b % absA + absA) % absA;
|
|||
|
return a > 1 ? function(index) {
|
|||
|
return index >= b && index % absA === bMod;
|
|||
|
} : function(index) {
|
|||
|
return index <= b && index % absA === bMod;
|
|||
|
};
|
|||
|
}
|
|||
|
exports.compile = compile;
|
|||
|
function generate(parsed) {
|
|||
|
var a = parsed[0];
|
|||
|
var b = parsed[1] - 1;
|
|||
|
var n = 0;
|
|||
|
if (a < 0) {
|
|||
|
var aPos_1 = -a;
|
|||
|
var minValue_1 = (b % aPos_1 + aPos_1) % aPos_1;
|
|||
|
return function() {
|
|||
|
var val = minValue_1 + aPos_1 * n++;
|
|||
|
return val > b ? null : val;
|
|||
|
};
|
|||
|
}
|
|||
|
if (a === 0)
|
|||
|
return b < 0 ? function() {
|
|||
|
return null;
|
|||
|
} : function() {
|
|||
|
return n++ === 0 ? b : null;
|
|||
|
};
|
|||
|
if (b < 0) {
|
|||
|
b += a * Math.ceil(-b / a);
|
|||
|
}
|
|||
|
return function() {
|
|||
|
return a * n++ + b;
|
|||
|
};
|
|||
|
}
|
|||
|
exports.generate = generate;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/nth-check/lib/index.js
|
|||
|
var require_lib6 = __commonJS({
|
|||
|
"node_modules/nth-check/lib/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.sequence = exports.generate = exports.compile = exports.parse = void 0;
|
|||
|
var parse_js_1 = require_parse2();
|
|||
|
Object.defineProperty(exports, "parse", { enumerable: true, get: function() {
|
|||
|
return parse_js_1.parse;
|
|||
|
} });
|
|||
|
var compile_js_1 = require_compile();
|
|||
|
Object.defineProperty(exports, "compile", { enumerable: true, get: function() {
|
|||
|
return compile_js_1.compile;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "generate", { enumerable: true, get: function() {
|
|||
|
return compile_js_1.generate;
|
|||
|
} });
|
|||
|
function nthCheck(formula) {
|
|||
|
return (0, compile_js_1.compile)((0, parse_js_1.parse)(formula));
|
|||
|
}
|
|||
|
exports.default = nthCheck;
|
|||
|
function sequence(formula) {
|
|||
|
return (0, compile_js_1.generate)((0, parse_js_1.parse)(formula));
|
|||
|
}
|
|||
|
exports.sequence = sequence;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/pseudo-selectors/filters.js
|
|||
|
var require_filters = __commonJS({
|
|||
|
"node_modules/css-select/lib/pseudo-selectors/filters.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.filters = void 0;
|
|||
|
var nth_check_1 = __importDefault(require_lib6());
|
|||
|
var boolbase_1 = __importDefault(require_boolbase());
|
|||
|
function getChildFunc(next, adapter) {
|
|||
|
return function(elem) {
|
|||
|
var parent = adapter.getParent(elem);
|
|||
|
return parent != null && adapter.isTag(parent) && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
exports.filters = {
|
|||
|
contains: function(next, text, _a) {
|
|||
|
var adapter = _a.adapter;
|
|||
|
return function contains(elem) {
|
|||
|
return next(elem) && adapter.getText(elem).includes(text);
|
|||
|
};
|
|||
|
},
|
|||
|
icontains: function(next, text, _a) {
|
|||
|
var adapter = _a.adapter;
|
|||
|
var itext = text.toLowerCase();
|
|||
|
return function icontains(elem) {
|
|||
|
return next(elem) && adapter.getText(elem).toLowerCase().includes(itext);
|
|||
|
};
|
|||
|
},
|
|||
|
"nth-child": function(next, rule, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
var func = (0, nth_check_1.default)(rule);
|
|||
|
if (func === boolbase_1.default.falseFunc)
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
if (func === boolbase_1.default.trueFunc)
|
|||
|
return getChildFunc(next, adapter);
|
|||
|
return function nthChild(elem) {
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
var pos = 0;
|
|||
|
for (var i = 0; i < siblings.length; i++) {
|
|||
|
if (equals(elem, siblings[i]))
|
|||
|
break;
|
|||
|
if (adapter.isTag(siblings[i])) {
|
|||
|
pos++;
|
|||
|
}
|
|||
|
}
|
|||
|
return func(pos) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
"nth-last-child": function(next, rule, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
var func = (0, nth_check_1.default)(rule);
|
|||
|
if (func === boolbase_1.default.falseFunc)
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
if (func === boolbase_1.default.trueFunc)
|
|||
|
return getChildFunc(next, adapter);
|
|||
|
return function nthLastChild(elem) {
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
var pos = 0;
|
|||
|
for (var i = siblings.length - 1; i >= 0; i--) {
|
|||
|
if (equals(elem, siblings[i]))
|
|||
|
break;
|
|||
|
if (adapter.isTag(siblings[i])) {
|
|||
|
pos++;
|
|||
|
}
|
|||
|
}
|
|||
|
return func(pos) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
"nth-of-type": function(next, rule, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
var func = (0, nth_check_1.default)(rule);
|
|||
|
if (func === boolbase_1.default.falseFunc)
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
if (func === boolbase_1.default.trueFunc)
|
|||
|
return getChildFunc(next, adapter);
|
|||
|
return function nthOfType(elem) {
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
var pos = 0;
|
|||
|
for (var i = 0; i < siblings.length; i++) {
|
|||
|
var currentSibling = siblings[i];
|
|||
|
if (equals(elem, currentSibling))
|
|||
|
break;
|
|||
|
if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === adapter.getName(elem)) {
|
|||
|
pos++;
|
|||
|
}
|
|||
|
}
|
|||
|
return func(pos) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
"nth-last-of-type": function(next, rule, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
var func = (0, nth_check_1.default)(rule);
|
|||
|
if (func === boolbase_1.default.falseFunc)
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
if (func === boolbase_1.default.trueFunc)
|
|||
|
return getChildFunc(next, adapter);
|
|||
|
return function nthLastOfType(elem) {
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
var pos = 0;
|
|||
|
for (var i = siblings.length - 1; i >= 0; i--) {
|
|||
|
var currentSibling = siblings[i];
|
|||
|
if (equals(elem, currentSibling))
|
|||
|
break;
|
|||
|
if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === adapter.getName(elem)) {
|
|||
|
pos++;
|
|||
|
}
|
|||
|
}
|
|||
|
return func(pos) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
root: function(next, _rule, _a) {
|
|||
|
var adapter = _a.adapter;
|
|||
|
return function(elem) {
|
|||
|
var parent = adapter.getParent(elem);
|
|||
|
return (parent == null || !adapter.isTag(parent)) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
scope: function(next, rule, options, context) {
|
|||
|
var equals = options.equals;
|
|||
|
if (!context || context.length === 0) {
|
|||
|
return exports.filters["root"](next, rule, options);
|
|||
|
}
|
|||
|
if (context.length === 1) {
|
|||
|
return function(elem) {
|
|||
|
return equals(context[0], elem) && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
return context.includes(elem) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
hover: dynamicStatePseudo("isHovered"),
|
|||
|
visited: dynamicStatePseudo("isVisited"),
|
|||
|
active: dynamicStatePseudo("isActive")
|
|||
|
};
|
|||
|
function dynamicStatePseudo(name) {
|
|||
|
return function dynamicPseudo(next, _rule, _a) {
|
|||
|
var adapter = _a.adapter;
|
|||
|
var func = adapter[name];
|
|||
|
if (typeof func !== "function") {
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
}
|
|||
|
return function active(elem) {
|
|||
|
return func(elem) && next(elem);
|
|||
|
};
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/pseudo-selectors/pseudos.js
|
|||
|
var require_pseudos = __commonJS({
|
|||
|
"node_modules/css-select/lib/pseudo-selectors/pseudos.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.verifyPseudoArgs = exports.pseudos = void 0;
|
|||
|
exports.pseudos = {
|
|||
|
empty: function(elem, _a) {
|
|||
|
var adapter = _a.adapter;
|
|||
|
return !adapter.getChildren(elem).some(function(elem2) {
|
|||
|
return adapter.isTag(elem2) || adapter.getText(elem2) !== "";
|
|||
|
});
|
|||
|
},
|
|||
|
"first-child": function(elem, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
if (adapter.prevElementSibling) {
|
|||
|
return adapter.prevElementSibling(elem) == null;
|
|||
|
}
|
|||
|
var firstChild = adapter.getSiblings(elem).find(function(elem2) {
|
|||
|
return adapter.isTag(elem2);
|
|||
|
});
|
|||
|
return firstChild != null && equals(elem, firstChild);
|
|||
|
},
|
|||
|
"last-child": function(elem, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
for (var i = siblings.length - 1; i >= 0; i--) {
|
|||
|
if (equals(elem, siblings[i]))
|
|||
|
return true;
|
|||
|
if (adapter.isTag(siblings[i]))
|
|||
|
break;
|
|||
|
}
|
|||
|
return false;
|
|||
|
},
|
|||
|
"first-of-type": function(elem, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
var elemName = adapter.getName(elem);
|
|||
|
for (var i = 0; i < siblings.length; i++) {
|
|||
|
var currentSibling = siblings[i];
|
|||
|
if (equals(elem, currentSibling))
|
|||
|
return true;
|
|||
|
if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === elemName) {
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
},
|
|||
|
"last-of-type": function(elem, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
var elemName = adapter.getName(elem);
|
|||
|
for (var i = siblings.length - 1; i >= 0; i--) {
|
|||
|
var currentSibling = siblings[i];
|
|||
|
if (equals(elem, currentSibling))
|
|||
|
return true;
|
|||
|
if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === elemName) {
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
},
|
|||
|
"only-of-type": function(elem, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
var elemName = adapter.getName(elem);
|
|||
|
return adapter.getSiblings(elem).every(function(sibling) {
|
|||
|
return equals(elem, sibling) || !adapter.isTag(sibling) || adapter.getName(sibling) !== elemName;
|
|||
|
});
|
|||
|
},
|
|||
|
"only-child": function(elem, _a) {
|
|||
|
var adapter = _a.adapter, equals = _a.equals;
|
|||
|
return adapter.getSiblings(elem).every(function(sibling) {
|
|||
|
return equals(elem, sibling) || !adapter.isTag(sibling);
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
function verifyPseudoArgs(func, name, subselect, argIndex) {
|
|||
|
if (subselect === null) {
|
|||
|
if (func.length > argIndex) {
|
|||
|
throw new Error("Pseudo-class :".concat(name, " requires an argument"));
|
|||
|
}
|
|||
|
} else if (func.length === argIndex) {
|
|||
|
throw new Error("Pseudo-class :".concat(name, " doesn't have any arguments"));
|
|||
|
}
|
|||
|
}
|
|||
|
exports.verifyPseudoArgs = verifyPseudoArgs;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/pseudo-selectors/aliases.js
|
|||
|
var require_aliases = __commonJS({
|
|||
|
"node_modules/css-select/lib/pseudo-selectors/aliases.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.aliases = void 0;
|
|||
|
exports.aliases = {
|
|||
|
"any-link": ":is(a, area, link)[href]",
|
|||
|
link: ":any-link:not(:visited)",
|
|||
|
disabled: ":is(\n :is(button, input, select, textarea, optgroup, option)[disabled],\n optgroup[disabled] > option,\n fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)\n )",
|
|||
|
enabled: ":not(:disabled)",
|
|||
|
checked: ":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",
|
|||
|
required: ":is(input, select, textarea)[required]",
|
|||
|
optional: ":is(input, select, textarea):not([required])",
|
|||
|
selected: "option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",
|
|||
|
checkbox: "[type=checkbox]",
|
|||
|
file: "[type=file]",
|
|||
|
password: "[type=password]",
|
|||
|
radio: "[type=radio]",
|
|||
|
reset: "[type=reset]",
|
|||
|
image: "[type=image]",
|
|||
|
submit: "[type=submit]",
|
|||
|
parent: ":not(:empty)",
|
|||
|
header: ":is(h1, h2, h3, h4, h5, h6)",
|
|||
|
button: ":is(button, input[type=button])",
|
|||
|
input: ":is(input, textarea, select, button)",
|
|||
|
text: "input:is(:not([type!='']), [type=text])"
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/pseudo-selectors/subselects.js
|
|||
|
var require_subselects = __commonJS({
|
|||
|
"node_modules/css-select/lib/pseudo-selectors/subselects.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|||
|
if (pack || arguments.length === 2)
|
|||
|
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|||
|
if (ar || !(i in from)) {
|
|||
|
if (!ar)
|
|||
|
ar = Array.prototype.slice.call(from, 0, i);
|
|||
|
ar[i] = from[i];
|
|||
|
}
|
|||
|
}
|
|||
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|||
|
};
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.subselects = exports.getNextSiblings = exports.ensureIsTag = exports.PLACEHOLDER_ELEMENT = void 0;
|
|||
|
var boolbase_1 = __importDefault(require_boolbase());
|
|||
|
var sort_js_1 = require_sort();
|
|||
|
exports.PLACEHOLDER_ELEMENT = {};
|
|||
|
function ensureIsTag(next, adapter) {
|
|||
|
if (next === boolbase_1.default.falseFunc)
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
return function(elem) {
|
|||
|
return adapter.isTag(elem) && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
exports.ensureIsTag = ensureIsTag;
|
|||
|
function getNextSiblings(elem, adapter) {
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
if (siblings.length <= 1)
|
|||
|
return [];
|
|||
|
var elemIndex = siblings.indexOf(elem);
|
|||
|
if (elemIndex < 0 || elemIndex === siblings.length - 1)
|
|||
|
return [];
|
|||
|
return siblings.slice(elemIndex + 1).filter(adapter.isTag);
|
|||
|
}
|
|||
|
exports.getNextSiblings = getNextSiblings;
|
|||
|
function copyOptions(options) {
|
|||
|
return {
|
|||
|
xmlMode: !!options.xmlMode,
|
|||
|
lowerCaseAttributeNames: !!options.lowerCaseAttributeNames,
|
|||
|
lowerCaseTags: !!options.lowerCaseTags,
|
|||
|
quirksMode: !!options.quirksMode,
|
|||
|
cacheResults: !!options.cacheResults,
|
|||
|
pseudos: options.pseudos,
|
|||
|
adapter: options.adapter,
|
|||
|
equals: options.equals
|
|||
|
};
|
|||
|
}
|
|||
|
var is = function(next, token, options, context, compileToken) {
|
|||
|
var func = compileToken(token, copyOptions(options), context);
|
|||
|
return func === boolbase_1.default.trueFunc ? next : func === boolbase_1.default.falseFunc ? boolbase_1.default.falseFunc : function(elem) {
|
|||
|
return func(elem) && next(elem);
|
|||
|
};
|
|||
|
};
|
|||
|
exports.subselects = {
|
|||
|
is,
|
|||
|
matches: is,
|
|||
|
where: is,
|
|||
|
not: function(next, token, options, context, compileToken) {
|
|||
|
var func = compileToken(token, copyOptions(options), context);
|
|||
|
return func === boolbase_1.default.falseFunc ? next : func === boolbase_1.default.trueFunc ? boolbase_1.default.falseFunc : function(elem) {
|
|||
|
return !func(elem) && next(elem);
|
|||
|
};
|
|||
|
},
|
|||
|
has: function(next, subselect, options, _context, compileToken) {
|
|||
|
var adapter = options.adapter;
|
|||
|
var opts = copyOptions(options);
|
|||
|
opts.relativeSelector = true;
|
|||
|
var context = subselect.some(function(s) {
|
|||
|
return s.some(sort_js_1.isTraversal);
|
|||
|
}) ? [exports.PLACEHOLDER_ELEMENT] : void 0;
|
|||
|
var compiled = compileToken(subselect, opts, context);
|
|||
|
if (compiled === boolbase_1.default.falseFunc)
|
|||
|
return boolbase_1.default.falseFunc;
|
|||
|
var hasElement = ensureIsTag(compiled, adapter);
|
|||
|
if (context && compiled !== boolbase_1.default.trueFunc) {
|
|||
|
var _a = compiled.shouldTestNextSiblings, shouldTestNextSiblings_1 = _a === void 0 ? false : _a;
|
|||
|
return function(elem) {
|
|||
|
if (!next(elem))
|
|||
|
return false;
|
|||
|
context[0] = elem;
|
|||
|
var childs = adapter.getChildren(elem);
|
|||
|
var nextElements = shouldTestNextSiblings_1 ? __spreadArray(__spreadArray([], childs, true), getNextSiblings(elem, adapter), true) : childs;
|
|||
|
return adapter.existsOne(hasElement, nextElements);
|
|||
|
};
|
|||
|
}
|
|||
|
return function(elem) {
|
|||
|
return next(elem) && adapter.existsOne(hasElement, adapter.getChildren(elem));
|
|||
|
};
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/pseudo-selectors/index.js
|
|||
|
var require_pseudo_selectors = __commonJS({
|
|||
|
"node_modules/css-select/lib/pseudo-selectors/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.compilePseudoSelector = exports.aliases = exports.pseudos = exports.filters = void 0;
|
|||
|
var css_what_1 = require_commonjs();
|
|||
|
var filters_js_1 = require_filters();
|
|||
|
Object.defineProperty(exports, "filters", { enumerable: true, get: function() {
|
|||
|
return filters_js_1.filters;
|
|||
|
} });
|
|||
|
var pseudos_js_1 = require_pseudos();
|
|||
|
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function() {
|
|||
|
return pseudos_js_1.pseudos;
|
|||
|
} });
|
|||
|
var aliases_js_1 = require_aliases();
|
|||
|
Object.defineProperty(exports, "aliases", { enumerable: true, get: function() {
|
|||
|
return aliases_js_1.aliases;
|
|||
|
} });
|
|||
|
var subselects_js_1 = require_subselects();
|
|||
|
function compilePseudoSelector(next, selector, options, context, compileToken) {
|
|||
|
var _a;
|
|||
|
var name = selector.name, data = selector.data;
|
|||
|
if (Array.isArray(data)) {
|
|||
|
if (!(name in subselects_js_1.subselects)) {
|
|||
|
throw new Error("Unknown pseudo-class :".concat(name, "(").concat(data, ")"));
|
|||
|
}
|
|||
|
return subselects_js_1.subselects[name](next, data, options, context, compileToken);
|
|||
|
}
|
|||
|
var userPseudo = (_a = options.pseudos) === null || _a === void 0 ? void 0 : _a[name];
|
|||
|
var stringPseudo = typeof userPseudo === "string" ? userPseudo : aliases_js_1.aliases[name];
|
|||
|
if (typeof stringPseudo === "string") {
|
|||
|
if (data != null) {
|
|||
|
throw new Error("Pseudo ".concat(name, " doesn't have any arguments"));
|
|||
|
}
|
|||
|
var alias = (0, css_what_1.parse)(stringPseudo);
|
|||
|
return subselects_js_1.subselects["is"](next, alias, options, context, compileToken);
|
|||
|
}
|
|||
|
if (typeof userPseudo === "function") {
|
|||
|
(0, pseudos_js_1.verifyPseudoArgs)(userPseudo, name, data, 1);
|
|||
|
return function(elem) {
|
|||
|
return userPseudo(elem, data) && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
if (name in filters_js_1.filters) {
|
|||
|
return filters_js_1.filters[name](next, data, options, context);
|
|||
|
}
|
|||
|
if (name in pseudos_js_1.pseudos) {
|
|||
|
var pseudo_1 = pseudos_js_1.pseudos[name];
|
|||
|
(0, pseudos_js_1.verifyPseudoArgs)(pseudo_1, name, data, 2);
|
|||
|
return function(elem) {
|
|||
|
return pseudo_1(elem, options, data) && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
throw new Error("Unknown pseudo-class :".concat(name));
|
|||
|
}
|
|||
|
exports.compilePseudoSelector = compilePseudoSelector;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/general.js
|
|||
|
var require_general = __commonJS({
|
|||
|
"node_modules/css-select/lib/general.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.compileGeneralSelector = void 0;
|
|||
|
var attributes_js_1 = require_attributes();
|
|||
|
var index_js_1 = require_pseudo_selectors();
|
|||
|
var css_what_1 = require_commonjs();
|
|||
|
function getElementParent(node, adapter) {
|
|||
|
var parent = adapter.getParent(node);
|
|||
|
if (parent && adapter.isTag(parent)) {
|
|||
|
return parent;
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
function compileGeneralSelector(next, selector, options, context, compileToken) {
|
|||
|
var adapter = options.adapter, equals = options.equals;
|
|||
|
switch (selector.type) {
|
|||
|
case css_what_1.SelectorType.PseudoElement: {
|
|||
|
throw new Error("Pseudo-elements are not supported by css-select");
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.ColumnCombinator: {
|
|||
|
throw new Error("Column combinators are not yet supported by css-select");
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Attribute: {
|
|||
|
if (selector.namespace != null) {
|
|||
|
throw new Error("Namespaced attributes are not yet supported by css-select");
|
|||
|
}
|
|||
|
if (!options.xmlMode || options.lowerCaseAttributeNames) {
|
|||
|
selector.name = selector.name.toLowerCase();
|
|||
|
}
|
|||
|
return attributes_js_1.attributeRules[selector.action](next, selector, options);
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Pseudo: {
|
|||
|
return (0, index_js_1.compilePseudoSelector)(next, selector, options, context, compileToken);
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Tag: {
|
|||
|
if (selector.namespace != null) {
|
|||
|
throw new Error("Namespaced tag names are not yet supported by css-select");
|
|||
|
}
|
|||
|
var name_1 = selector.name;
|
|||
|
if (!options.xmlMode || options.lowerCaseTags) {
|
|||
|
name_1 = name_1.toLowerCase();
|
|||
|
}
|
|||
|
return function tag(elem) {
|
|||
|
return adapter.getName(elem) === name_1 && next(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Descendant: {
|
|||
|
if (options.cacheResults === false || typeof WeakSet === "undefined") {
|
|||
|
return function descendant(elem) {
|
|||
|
var current = elem;
|
|||
|
while (current = getElementParent(current, adapter)) {
|
|||
|
if (next(current)) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
};
|
|||
|
}
|
|||
|
var isFalseCache_1 = /* @__PURE__ */ new WeakSet();
|
|||
|
return function cachedDescendant(elem) {
|
|||
|
var current = elem;
|
|||
|
while (current = getElementParent(current, adapter)) {
|
|||
|
if (!isFalseCache_1.has(current)) {
|
|||
|
if (adapter.isTag(current) && next(current)) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
isFalseCache_1.add(current);
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
};
|
|||
|
}
|
|||
|
case "_flexibleDescendant": {
|
|||
|
return function flexibleDescendant(elem) {
|
|||
|
var current = elem;
|
|||
|
do {
|
|||
|
if (next(current))
|
|||
|
return true;
|
|||
|
} while (current = getElementParent(current, adapter));
|
|||
|
return false;
|
|||
|
};
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Parent: {
|
|||
|
return function parent(elem) {
|
|||
|
return adapter.getChildren(elem).some(function(elem2) {
|
|||
|
return adapter.isTag(elem2) && next(elem2);
|
|||
|
});
|
|||
|
};
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Child: {
|
|||
|
return function child(elem) {
|
|||
|
var parent = adapter.getParent(elem);
|
|||
|
return parent != null && adapter.isTag(parent) && next(parent);
|
|||
|
};
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Sibling: {
|
|||
|
return function sibling(elem) {
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
for (var i = 0; i < siblings.length; i++) {
|
|||
|
var currentSibling = siblings[i];
|
|||
|
if (equals(elem, currentSibling))
|
|||
|
break;
|
|||
|
if (adapter.isTag(currentSibling) && next(currentSibling)) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
};
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Adjacent: {
|
|||
|
if (adapter.prevElementSibling) {
|
|||
|
return function adjacent(elem) {
|
|||
|
var previous = adapter.prevElementSibling(elem);
|
|||
|
return previous != null && next(previous);
|
|||
|
};
|
|||
|
}
|
|||
|
return function adjacent(elem) {
|
|||
|
var siblings = adapter.getSiblings(elem);
|
|||
|
var lastElement;
|
|||
|
for (var i = 0; i < siblings.length; i++) {
|
|||
|
var currentSibling = siblings[i];
|
|||
|
if (equals(elem, currentSibling))
|
|||
|
break;
|
|||
|
if (adapter.isTag(currentSibling)) {
|
|||
|
lastElement = currentSibling;
|
|||
|
}
|
|||
|
}
|
|||
|
return !!lastElement && next(lastElement);
|
|||
|
};
|
|||
|
}
|
|||
|
case css_what_1.SelectorType.Universal: {
|
|||
|
if (selector.namespace != null && selector.namespace !== "*") {
|
|||
|
throw new Error("Namespaced universal selectors are not yet supported by css-select");
|
|||
|
}
|
|||
|
return next;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
exports.compileGeneralSelector = compileGeneralSelector;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/compile.js
|
|||
|
var require_compile2 = __commonJS({
|
|||
|
"node_modules/css-select/lib/compile.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|||
|
desc = { enumerable: true, get: function() {
|
|||
|
return m[k];
|
|||
|
} };
|
|||
|
}
|
|||
|
Object.defineProperty(o, k2, desc);
|
|||
|
} : function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
o[k2] = m[k];
|
|||
|
});
|
|||
|
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|||
|
} : function(o, v) {
|
|||
|
o["default"] = v;
|
|||
|
});
|
|||
|
var __importStar = exports && exports.__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 __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.compileToken = exports.compileUnsafe = exports.compile = void 0;
|
|||
|
var css_what_1 = require_commonjs();
|
|||
|
var boolbase_1 = __importDefault(require_boolbase());
|
|||
|
var sort_js_1 = __importStar(require_sort());
|
|||
|
var general_js_1 = require_general();
|
|||
|
var subselects_js_1 = require_subselects();
|
|||
|
function compile(selector, options, context) {
|
|||
|
var next = compileUnsafe(selector, options, context);
|
|||
|
return (0, subselects_js_1.ensureIsTag)(next, options.adapter);
|
|||
|
}
|
|||
|
exports.compile = compile;
|
|||
|
function compileUnsafe(selector, options, context) {
|
|||
|
var token = typeof selector === "string" ? (0, css_what_1.parse)(selector) : selector;
|
|||
|
return compileToken(token, options, context);
|
|||
|
}
|
|||
|
exports.compileUnsafe = compileUnsafe;
|
|||
|
function includesScopePseudo(t) {
|
|||
|
return t.type === css_what_1.SelectorType.Pseudo && (t.name === "scope" || Array.isArray(t.data) && t.data.some(function(data) {
|
|||
|
return data.some(includesScopePseudo);
|
|||
|
}));
|
|||
|
}
|
|||
|
var DESCENDANT_TOKEN = { type: css_what_1.SelectorType.Descendant };
|
|||
|
var FLEXIBLE_DESCENDANT_TOKEN = {
|
|||
|
type: "_flexibleDescendant"
|
|||
|
};
|
|||
|
var SCOPE_TOKEN = {
|
|||
|
type: css_what_1.SelectorType.Pseudo,
|
|||
|
name: "scope",
|
|||
|
data: null
|
|||
|
};
|
|||
|
function absolutize(token, _a, context) {
|
|||
|
var adapter = _a.adapter;
|
|||
|
var hasContext = !!(context === null || context === void 0 ? void 0 : context.every(function(e) {
|
|||
|
var parent = adapter.isTag(e) && adapter.getParent(e);
|
|||
|
return e === subselects_js_1.PLACEHOLDER_ELEMENT || parent && adapter.isTag(parent);
|
|||
|
}));
|
|||
|
for (var _i = 0, token_1 = token; _i < token_1.length; _i++) {
|
|||
|
var t = token_1[_i];
|
|||
|
if (t.length > 0 && (0, sort_js_1.isTraversal)(t[0]) && t[0].type !== css_what_1.SelectorType.Descendant) {
|
|||
|
} else if (hasContext && !t.some(includesScopePseudo)) {
|
|||
|
t.unshift(DESCENDANT_TOKEN);
|
|||
|
} else {
|
|||
|
continue;
|
|||
|
}
|
|||
|
t.unshift(SCOPE_TOKEN);
|
|||
|
}
|
|||
|
}
|
|||
|
function compileToken(token, options, context) {
|
|||
|
var _a;
|
|||
|
token.forEach(sort_js_1.default);
|
|||
|
context = (_a = options.context) !== null && _a !== void 0 ? _a : context;
|
|||
|
var isArrayContext = Array.isArray(context);
|
|||
|
var finalContext = context && (Array.isArray(context) ? context : [context]);
|
|||
|
if (options.relativeSelector !== false) {
|
|||
|
absolutize(token, options, finalContext);
|
|||
|
} else if (token.some(function(t) {
|
|||
|
return t.length > 0 && (0, sort_js_1.isTraversal)(t[0]);
|
|||
|
})) {
|
|||
|
throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");
|
|||
|
}
|
|||
|
var shouldTestNextSiblings = false;
|
|||
|
var query = token.map(function(rules) {
|
|||
|
if (rules.length >= 2) {
|
|||
|
var first = rules[0], second = rules[1];
|
|||
|
if (first.type !== css_what_1.SelectorType.Pseudo || first.name !== "scope") {
|
|||
|
} else if (isArrayContext && second.type === css_what_1.SelectorType.Descendant) {
|
|||
|
rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
|
|||
|
} else if (second.type === css_what_1.SelectorType.Adjacent || second.type === css_what_1.SelectorType.Sibling) {
|
|||
|
shouldTestNextSiblings = true;
|
|||
|
}
|
|||
|
}
|
|||
|
return compileRules(rules, options, finalContext);
|
|||
|
}).reduce(reduceRules, boolbase_1.default.falseFunc);
|
|||
|
query.shouldTestNextSiblings = shouldTestNextSiblings;
|
|||
|
return query;
|
|||
|
}
|
|||
|
exports.compileToken = compileToken;
|
|||
|
function compileRules(rules, options, context) {
|
|||
|
var _a;
|
|||
|
return rules.reduce(function(previous, rule) {
|
|||
|
return previous === boolbase_1.default.falseFunc ? boolbase_1.default.falseFunc : (0, general_js_1.compileGeneralSelector)(previous, rule, options, context, compileToken);
|
|||
|
}, (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase_1.default.trueFunc);
|
|||
|
}
|
|||
|
function reduceRules(a, b) {
|
|||
|
if (b === boolbase_1.default.falseFunc || a === boolbase_1.default.trueFunc) {
|
|||
|
return a;
|
|||
|
}
|
|||
|
if (a === boolbase_1.default.falseFunc || b === boolbase_1.default.trueFunc) {
|
|||
|
return b;
|
|||
|
}
|
|||
|
return function combine(elem) {
|
|||
|
return a(elem) || b(elem);
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/css-select/lib/index.js
|
|||
|
var require_lib7 = __commonJS({
|
|||
|
"node_modules/css-select/lib/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|||
|
desc = { enumerable: true, get: function() {
|
|||
|
return m[k];
|
|||
|
} };
|
|||
|
}
|
|||
|
Object.defineProperty(o, k2, desc);
|
|||
|
} : function(o, m, k, k2) {
|
|||
|
if (k2 === void 0)
|
|||
|
k2 = k;
|
|||
|
o[k2] = m[k];
|
|||
|
});
|
|||
|
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|||
|
} : function(o, v) {
|
|||
|
o["default"] = v;
|
|||
|
});
|
|||
|
var __importStar = exports && exports.__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 __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.aliases = exports.pseudos = exports.filters = exports.is = exports.selectOne = exports.selectAll = exports.prepareContext = exports._compileToken = exports._compileUnsafe = exports.compile = void 0;
|
|||
|
var DomUtils = __importStar(require_lib5());
|
|||
|
var boolbase_1 = __importDefault(require_boolbase());
|
|||
|
var compile_js_1 = require_compile2();
|
|||
|
var subselects_js_1 = require_subselects();
|
|||
|
var defaultEquals = function(a, b) {
|
|||
|
return a === b;
|
|||
|
};
|
|||
|
var defaultOptions = {
|
|||
|
adapter: DomUtils,
|
|||
|
equals: defaultEquals
|
|||
|
};
|
|||
|
function convertOptionFormats(options) {
|
|||
|
var _a, _b, _c, _d;
|
|||
|
var opts = options !== null && options !== void 0 ? options : defaultOptions;
|
|||
|
(_a = opts.adapter) !== null && _a !== void 0 ? _a : opts.adapter = DomUtils;
|
|||
|
(_b = opts.equals) !== null && _b !== void 0 ? _b : opts.equals = (_d = (_c = opts.adapter) === null || _c === void 0 ? void 0 : _c.equals) !== null && _d !== void 0 ? _d : defaultEquals;
|
|||
|
return opts;
|
|||
|
}
|
|||
|
function wrapCompile(func) {
|
|||
|
return function addAdapter(selector, options, context) {
|
|||
|
var opts = convertOptionFormats(options);
|
|||
|
return func(selector, opts, context);
|
|||
|
};
|
|||
|
}
|
|||
|
exports.compile = wrapCompile(compile_js_1.compile);
|
|||
|
exports._compileUnsafe = wrapCompile(compile_js_1.compileUnsafe);
|
|||
|
exports._compileToken = wrapCompile(compile_js_1.compileToken);
|
|||
|
function getSelectorFunc(searchFunc) {
|
|||
|
return function select(query, elements, options) {
|
|||
|
var opts = convertOptionFormats(options);
|
|||
|
if (typeof query !== "function") {
|
|||
|
query = (0, compile_js_1.compileUnsafe)(query, opts, elements);
|
|||
|
}
|
|||
|
var filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings);
|
|||
|
return searchFunc(query, filteredElements, opts);
|
|||
|
};
|
|||
|
}
|
|||
|
function prepareContext(elems, adapter, shouldTestNextSiblings) {
|
|||
|
if (shouldTestNextSiblings === void 0) {
|
|||
|
shouldTestNextSiblings = false;
|
|||
|
}
|
|||
|
if (shouldTestNextSiblings) {
|
|||
|
elems = appendNextSiblings(elems, adapter);
|
|||
|
}
|
|||
|
return Array.isArray(elems) ? adapter.removeSubsets(elems) : adapter.getChildren(elems);
|
|||
|
}
|
|||
|
exports.prepareContext = prepareContext;
|
|||
|
function appendNextSiblings(elem, adapter) {
|
|||
|
var elems = Array.isArray(elem) ? elem.slice(0) : [elem];
|
|||
|
var elemsLength = elems.length;
|
|||
|
for (var i = 0; i < elemsLength; i++) {
|
|||
|
var nextSiblings = (0, subselects_js_1.getNextSiblings)(elems[i], adapter);
|
|||
|
elems.push.apply(elems, nextSiblings);
|
|||
|
}
|
|||
|
return elems;
|
|||
|
}
|
|||
|
exports.selectAll = getSelectorFunc(function(query, elems, options) {
|
|||
|
return query === boolbase_1.default.falseFunc || !elems || elems.length === 0 ? [] : options.adapter.findAll(query, elems);
|
|||
|
});
|
|||
|
exports.selectOne = getSelectorFunc(function(query, elems, options) {
|
|||
|
return query === boolbase_1.default.falseFunc || !elems || elems.length === 0 ? null : options.adapter.findOne(query, elems);
|
|||
|
});
|
|||
|
function is(elem, query, options) {
|
|||
|
var opts = convertOptionFormats(options);
|
|||
|
return (typeof query === "function" ? query : (0, compile_js_1.compile)(query, opts))(elem);
|
|||
|
}
|
|||
|
exports.is = is;
|
|||
|
exports.default = exports.selectAll;
|
|||
|
var index_js_1 = require_pseudo_selectors();
|
|||
|
Object.defineProperty(exports, "filters", { enumerable: true, get: function() {
|
|||
|
return index_js_1.filters;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function() {
|
|||
|
return index_js_1.pseudos;
|
|||
|
} });
|
|||
|
Object.defineProperty(exports, "aliases", { enumerable: true, get: function() {
|
|||
|
return index_js_1.aliases;
|
|||
|
} });
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/back.js
|
|||
|
var require_back = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/back.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
function arr_back(arr) {
|
|||
|
return arr[arr.length - 1];
|
|||
|
}
|
|||
|
exports.default = arr_back;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/matcher.js
|
|||
|
var require_matcher = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/matcher.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
var type_1 = __importDefault(require_type());
|
|||
|
function isTag(node) {
|
|||
|
return node && node.nodeType === type_1.default.ELEMENT_NODE;
|
|||
|
}
|
|||
|
function getAttributeValue(elem, name) {
|
|||
|
return isTag(elem) ? elem.getAttribute(name) : void 0;
|
|||
|
}
|
|||
|
function getName(elem) {
|
|||
|
return (elem && elem.rawTagName || "").toLowerCase();
|
|||
|
}
|
|||
|
function getChildren(node) {
|
|||
|
return node && node.childNodes;
|
|||
|
}
|
|||
|
function getParent(node) {
|
|||
|
return node ? node.parentNode : null;
|
|||
|
}
|
|||
|
function getText(node) {
|
|||
|
return node.text;
|
|||
|
}
|
|||
|
function removeSubsets(nodes) {
|
|||
|
var idx = nodes.length;
|
|||
|
var node;
|
|||
|
var ancestor;
|
|||
|
var replace;
|
|||
|
while (--idx > -1) {
|
|||
|
node = ancestor = nodes[idx];
|
|||
|
nodes[idx] = null;
|
|||
|
replace = true;
|
|||
|
while (ancestor) {
|
|||
|
if (nodes.indexOf(ancestor) > -1) {
|
|||
|
replace = false;
|
|||
|
nodes.splice(idx, 1);
|
|||
|
break;
|
|||
|
}
|
|||
|
ancestor = getParent(ancestor);
|
|||
|
}
|
|||
|
if (replace) {
|
|||
|
nodes[idx] = node;
|
|||
|
}
|
|||
|
}
|
|||
|
return nodes;
|
|||
|
}
|
|||
|
function existsOne(test, elems) {
|
|||
|
return elems.some(function(elem) {
|
|||
|
return isTag(elem) ? test(elem) || existsOne(test, getChildren(elem)) : false;
|
|||
|
});
|
|||
|
}
|
|||
|
function getSiblings(node) {
|
|||
|
var parent = getParent(node);
|
|||
|
return parent ? getChildren(parent) : [];
|
|||
|
}
|
|||
|
function hasAttrib(elem, name) {
|
|||
|
return getAttributeValue(elem, name) !== void 0;
|
|||
|
}
|
|||
|
function findOne(test, elems) {
|
|||
|
var elem = null;
|
|||
|
for (var i = 0, l = elems === null || elems === void 0 ? void 0 : elems.length; i < l && !elem; i++) {
|
|||
|
var el = elems[i];
|
|||
|
if (test(el)) {
|
|||
|
elem = el;
|
|||
|
} else {
|
|||
|
var childs = getChildren(el);
|
|||
|
if (childs && childs.length > 0) {
|
|||
|
elem = findOne(test, childs);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return elem;
|
|||
|
}
|
|||
|
function findAll(test, nodes) {
|
|||
|
var result = [];
|
|||
|
for (var i = 0, j = nodes.length; i < j; i++) {
|
|||
|
if (!isTag(nodes[i]))
|
|||
|
continue;
|
|||
|
if (test(nodes[i]))
|
|||
|
result.push(nodes[i]);
|
|||
|
var childs = getChildren(nodes[i]);
|
|||
|
if (childs)
|
|||
|
result = result.concat(findAll(test, childs));
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
exports.default = {
|
|||
|
isTag,
|
|||
|
getAttributeValue,
|
|||
|
getName,
|
|||
|
getChildren,
|
|||
|
getParent,
|
|||
|
getText,
|
|||
|
removeSubsets,
|
|||
|
existsOne,
|
|||
|
getSiblings,
|
|||
|
hasAttrib,
|
|||
|
findOne,
|
|||
|
findAll
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/void-tag.js
|
|||
|
var require_void_tag = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/void-tag.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
var VoidTag = function() {
|
|||
|
function VoidTag2(addClosingSlash, tags) {
|
|||
|
if (addClosingSlash === void 0) {
|
|||
|
addClosingSlash = false;
|
|||
|
}
|
|||
|
this.addClosingSlash = addClosingSlash;
|
|||
|
if (Array.isArray(tags)) {
|
|||
|
this.voidTags = tags.reduce(function(set, tag) {
|
|||
|
return set.add(tag.toLowerCase()).add(tag.toUpperCase()).add(tag);
|
|||
|
}, /* @__PURE__ */ new Set());
|
|||
|
} else {
|
|||
|
this.voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"].reduce(function(set, tag) {
|
|||
|
return set.add(tag.toLowerCase()).add(tag.toUpperCase()).add(tag);
|
|||
|
}, /* @__PURE__ */ new Set());
|
|||
|
}
|
|||
|
}
|
|||
|
VoidTag2.prototype.formatNode = function(tag, attrs, innerHTML) {
|
|||
|
var addClosingSlash = this.addClosingSlash;
|
|||
|
var closingSpace = addClosingSlash && attrs && !attrs.endsWith(" ") ? " " : "";
|
|||
|
var closingSlash = addClosingSlash ? "".concat(closingSpace, "/") : "";
|
|||
|
return this.isVoidElement(tag.toLowerCase()) ? "<".concat(tag).concat(attrs).concat(closingSlash, ">") : "<".concat(tag).concat(attrs, ">").concat(innerHTML, "</").concat(tag, ">");
|
|||
|
};
|
|||
|
VoidTag2.prototype.isVoidElement = function(tag) {
|
|||
|
return this.voidTags.has(tag);
|
|||
|
};
|
|||
|
return VoidTag2;
|
|||
|
}();
|
|||
|
exports.default = VoidTag;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/nodes/text.js
|
|||
|
var require_text = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/nodes/text.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __extends = exports && exports.__extends || function() {
|
|||
|
var extendStatics = function(d, b) {
|
|||
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|||
|
d2.__proto__ = b2;
|
|||
|
} || function(d2, b2) {
|
|||
|
for (var p in b2)
|
|||
|
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|||
|
d2[p] = b2[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 = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
var he_1 = require_he();
|
|||
|
var node_1 = __importDefault(require_node());
|
|||
|
var type_1 = __importDefault(require_type());
|
|||
|
var TextNode = function(_super) {
|
|||
|
__extends(TextNode2, _super);
|
|||
|
function TextNode2(rawText, parentNode, range) {
|
|||
|
if (parentNode === void 0) {
|
|||
|
parentNode = null;
|
|||
|
}
|
|||
|
var _this = _super.call(this, parentNode, range) || this;
|
|||
|
_this.nodeType = type_1.default.TEXT_NODE;
|
|||
|
_this.rawTagName = "";
|
|||
|
_this._rawText = rawText;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
TextNode2.prototype.clone = function() {
|
|||
|
return new TextNode2(this._rawText, null);
|
|||
|
};
|
|||
|
Object.defineProperty(TextNode2.prototype, "rawText", {
|
|||
|
get: function() {
|
|||
|
return this._rawText;
|
|||
|
},
|
|||
|
set: function(text) {
|
|||
|
this._rawText = text;
|
|||
|
this._trimmedRawText = void 0;
|
|||
|
this._trimmedText = void 0;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(TextNode2.prototype, "trimmedRawText", {
|
|||
|
get: function() {
|
|||
|
if (this._trimmedRawText !== void 0)
|
|||
|
return this._trimmedRawText;
|
|||
|
this._trimmedRawText = trimText(this.rawText);
|
|||
|
return this._trimmedRawText;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(TextNode2.prototype, "trimmedText", {
|
|||
|
get: function() {
|
|||
|
if (this._trimmedText !== void 0)
|
|||
|
return this._trimmedText;
|
|||
|
this._trimmedText = trimText(this.text);
|
|||
|
return this._trimmedText;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(TextNode2.prototype, "text", {
|
|||
|
get: function() {
|
|||
|
return (0, he_1.decode)(this.rawText);
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(TextNode2.prototype, "isWhitespace", {
|
|||
|
get: function() {
|
|||
|
return /^(\s| )*$/.test(this.rawText);
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
TextNode2.prototype.toString = function() {
|
|||
|
return this.rawText;
|
|||
|
};
|
|||
|
return TextNode2;
|
|||
|
}(node_1.default);
|
|||
|
exports.default = TextNode;
|
|||
|
function trimText(text) {
|
|||
|
var i = 0;
|
|||
|
var startPos;
|
|||
|
var endPos;
|
|||
|
while (i >= 0 && i < text.length) {
|
|||
|
if (/\S/.test(text[i])) {
|
|||
|
if (startPos === void 0) {
|
|||
|
startPos = i;
|
|||
|
i = text.length;
|
|||
|
} else {
|
|||
|
endPos = i;
|
|||
|
i = void 0;
|
|||
|
}
|
|||
|
}
|
|||
|
if (startPos === void 0)
|
|||
|
i++;
|
|||
|
else
|
|||
|
i--;
|
|||
|
}
|
|||
|
if (startPos === void 0)
|
|||
|
startPos = 0;
|
|||
|
if (endPos === void 0)
|
|||
|
endPos = text.length - 1;
|
|||
|
var hasLeadingSpace = startPos > 0 && /[^\S\r\n]/.test(text[startPos - 1]);
|
|||
|
var hasTrailingSpace = endPos < text.length - 1 && /[^\S\r\n]/.test(text[endPos + 1]);
|
|||
|
return (hasLeadingSpace ? " " : "") + text.slice(startPos, endPos + 1) + (hasTrailingSpace ? " " : "");
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/nodes/html.js
|
|||
|
var require_html = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/nodes/html.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __extends = exports && exports.__extends || function() {
|
|||
|
var extendStatics = function(d, b) {
|
|||
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|||
|
d2.__proto__ = b2;
|
|||
|
} || function(d2, b2) {
|
|||
|
for (var p in b2)
|
|||
|
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|||
|
d2[p] = b2[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 __assign = exports && exports.__assign || function() {
|
|||
|
__assign = Object.assign || function(t) {
|
|||
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|||
|
s = arguments[i];
|
|||
|
for (var p in s)
|
|||
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|||
|
t[p] = s[p];
|
|||
|
}
|
|||
|
return t;
|
|||
|
};
|
|||
|
return __assign.apply(this, arguments);
|
|||
|
};
|
|||
|
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|||
|
if (pack || arguments.length === 2)
|
|||
|
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|||
|
if (ar || !(i in from)) {
|
|||
|
if (!ar)
|
|||
|
ar = Array.prototype.slice.call(from, 0, i);
|
|||
|
ar[i] = from[i];
|
|||
|
}
|
|||
|
}
|
|||
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|||
|
};
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.parse = exports.base_parse = void 0;
|
|||
|
var css_select_1 = require_lib7();
|
|||
|
var he_1 = __importDefault(require_he());
|
|||
|
var back_1 = __importDefault(require_back());
|
|||
|
var matcher_1 = __importDefault(require_matcher());
|
|||
|
var void_tag_1 = __importDefault(require_void_tag());
|
|||
|
var comment_1 = __importDefault(require_comment());
|
|||
|
var node_1 = __importDefault(require_node());
|
|||
|
var text_1 = __importDefault(require_text());
|
|||
|
var type_1 = __importDefault(require_type());
|
|||
|
function decode(val) {
|
|||
|
return JSON.parse(JSON.stringify(he_1.default.decode(val)));
|
|||
|
}
|
|||
|
var Htags = ["h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup"];
|
|||
|
var Dtags = ["details", "dialog", "dd", "div", "dt"];
|
|||
|
var Ftags = ["fieldset", "figcaption", "figure", "footer", "form"];
|
|||
|
var tableTags = ["table", "td", "tr"];
|
|||
|
var htmlTags = ["address", "article", "aside", "blockquote", "br", "hr", "li", "main", "nav", "ol", "p", "pre", "section", "ul"];
|
|||
|
var kBlockElements = /* @__PURE__ */ new Set();
|
|||
|
function addToKBlockElement() {
|
|||
|
var args = [];
|
|||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|||
|
args[_i] = arguments[_i];
|
|||
|
}
|
|||
|
var addToSet = function(array) {
|
|||
|
for (var index = 0; index < array.length; index++) {
|
|||
|
var element = array[index];
|
|||
|
kBlockElements.add(element);
|
|||
|
kBlockElements.add(element.toUpperCase());
|
|||
|
}
|
|||
|
};
|
|||
|
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
|||
|
var arg = args_1[_a];
|
|||
|
addToSet(arg);
|
|||
|
}
|
|||
|
}
|
|||
|
addToKBlockElement(Htags, Dtags, Ftags, tableTags, htmlTags);
|
|||
|
var DOMTokenList = function() {
|
|||
|
function DOMTokenList2(valuesInit, afterUpdate) {
|
|||
|
if (valuesInit === void 0) {
|
|||
|
valuesInit = [];
|
|||
|
}
|
|||
|
if (afterUpdate === void 0) {
|
|||
|
afterUpdate = function() {
|
|||
|
return null;
|
|||
|
};
|
|||
|
}
|
|||
|
this._set = new Set(valuesInit);
|
|||
|
this._afterUpdate = afterUpdate;
|
|||
|
}
|
|||
|
DOMTokenList2.prototype._validate = function(c) {
|
|||
|
if (/\s/.test(c)) {
|
|||
|
throw new Error("DOMException in DOMTokenList.add: The token '".concat(c, "' contains HTML space characters, which are not valid in tokens."));
|
|||
|
}
|
|||
|
};
|
|||
|
DOMTokenList2.prototype.add = function(c) {
|
|||
|
this._validate(c);
|
|||
|
this._set.add(c);
|
|||
|
this._afterUpdate(this);
|
|||
|
};
|
|||
|
DOMTokenList2.prototype.replace = function(c1, c2) {
|
|||
|
this._validate(c2);
|
|||
|
this._set.delete(c1);
|
|||
|
this._set.add(c2);
|
|||
|
this._afterUpdate(this);
|
|||
|
};
|
|||
|
DOMTokenList2.prototype.remove = function(c) {
|
|||
|
this._set.delete(c) && this._afterUpdate(this);
|
|||
|
};
|
|||
|
DOMTokenList2.prototype.toggle = function(c) {
|
|||
|
this._validate(c);
|
|||
|
if (this._set.has(c))
|
|||
|
this._set.delete(c);
|
|||
|
else
|
|||
|
this._set.add(c);
|
|||
|
this._afterUpdate(this);
|
|||
|
};
|
|||
|
DOMTokenList2.prototype.contains = function(c) {
|
|||
|
return this._set.has(c);
|
|||
|
};
|
|||
|
Object.defineProperty(DOMTokenList2.prototype, "length", {
|
|||
|
get: function() {
|
|||
|
return this._set.size;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
DOMTokenList2.prototype.values = function() {
|
|||
|
return this._set.values();
|
|||
|
};
|
|||
|
Object.defineProperty(DOMTokenList2.prototype, "value", {
|
|||
|
get: function() {
|
|||
|
return Array.from(this._set.values());
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
DOMTokenList2.prototype.toString = function() {
|
|||
|
return Array.from(this._set.values()).join(" ");
|
|||
|
};
|
|||
|
return DOMTokenList2;
|
|||
|
}();
|
|||
|
var HTMLElement = function(_super) {
|
|||
|
__extends(HTMLElement2, _super);
|
|||
|
function HTMLElement2(tagName, keyAttrs, rawAttrs, parentNode, range, voidTag, _parseOptions) {
|
|||
|
if (rawAttrs === void 0) {
|
|||
|
rawAttrs = "";
|
|||
|
}
|
|||
|
if (parentNode === void 0) {
|
|||
|
parentNode = null;
|
|||
|
}
|
|||
|
if (voidTag === void 0) {
|
|||
|
voidTag = new void_tag_1.default();
|
|||
|
}
|
|||
|
if (_parseOptions === void 0) {
|
|||
|
_parseOptions = {};
|
|||
|
}
|
|||
|
var _this = _super.call(this, parentNode, range) || this;
|
|||
|
_this.rawAttrs = rawAttrs;
|
|||
|
_this.voidTag = voidTag;
|
|||
|
_this.nodeType = type_1.default.ELEMENT_NODE;
|
|||
|
_this.rawTagName = tagName;
|
|||
|
_this.rawAttrs = rawAttrs || "";
|
|||
|
_this.id = keyAttrs.id || "";
|
|||
|
_this.childNodes = [];
|
|||
|
_this._parseOptions = _parseOptions;
|
|||
|
_this.classList = new DOMTokenList(keyAttrs.class ? keyAttrs.class.split(/\s+/) : [], function(classList) {
|
|||
|
return _this.setAttribute("class", classList.toString());
|
|||
|
});
|
|||
|
if (keyAttrs.id) {
|
|||
|
if (!rawAttrs) {
|
|||
|
_this.rawAttrs = 'id="'.concat(keyAttrs.id, '"');
|
|||
|
}
|
|||
|
}
|
|||
|
if (keyAttrs.class) {
|
|||
|
if (!rawAttrs) {
|
|||
|
var cls = 'class="'.concat(_this.classList.toString(), '"');
|
|||
|
if (_this.rawAttrs) {
|
|||
|
_this.rawAttrs += " ".concat(cls);
|
|||
|
} else {
|
|||
|
_this.rawAttrs = cls;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return _this;
|
|||
|
}
|
|||
|
HTMLElement2.prototype.quoteAttribute = function(attr) {
|
|||
|
if (attr == null) {
|
|||
|
return "null";
|
|||
|
}
|
|||
|
return JSON.stringify(attr.replace(/"/g, """)).replace(/\\t/g, " ").replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\/g, "");
|
|||
|
};
|
|||
|
HTMLElement2.prototype.removeChild = function(node) {
|
|||
|
this.childNodes = this.childNodes.filter(function(child) {
|
|||
|
return child !== node;
|
|||
|
});
|
|||
|
return this;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.exchangeChild = function(oldNode, newNode) {
|
|||
|
var children = this.childNodes;
|
|||
|
this.childNodes = children.map(function(child) {
|
|||
|
if (child === oldNode) {
|
|||
|
return newNode;
|
|||
|
}
|
|||
|
return child;
|
|||
|
});
|
|||
|
return this;
|
|||
|
};
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "tagName", {
|
|||
|
get: function() {
|
|||
|
return this.rawTagName ? this.rawTagName.toUpperCase() : this.rawTagName;
|
|||
|
},
|
|||
|
set: function(newname) {
|
|||
|
this.rawTagName = newname.toLowerCase();
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "localName", {
|
|||
|
get: function() {
|
|||
|
return this.rawTagName.toLowerCase();
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "isVoidElement", {
|
|||
|
get: function() {
|
|||
|
return this.voidTag.isVoidElement(this.localName);
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "rawText", {
|
|||
|
get: function() {
|
|||
|
if (/^br$/i.test(this.rawTagName)) {
|
|||
|
return "\n";
|
|||
|
}
|
|||
|
return this.childNodes.reduce(function(pre, cur) {
|
|||
|
return pre += cur.rawText;
|
|||
|
}, "");
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "textContent", {
|
|||
|
get: function() {
|
|||
|
return decode(this.rawText);
|
|||
|
},
|
|||
|
set: function(val) {
|
|||
|
var content = [new text_1.default(val, this)];
|
|||
|
this.childNodes = content;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "text", {
|
|||
|
get: function() {
|
|||
|
return decode(this.rawText);
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "structuredText", {
|
|||
|
get: function() {
|
|||
|
var currentBlock = [];
|
|||
|
var blocks = [currentBlock];
|
|||
|
function dfs(node) {
|
|||
|
if (node.nodeType === type_1.default.ELEMENT_NODE) {
|
|||
|
if (kBlockElements.has(node.rawTagName)) {
|
|||
|
if (currentBlock.length > 0) {
|
|||
|
blocks.push(currentBlock = []);
|
|||
|
}
|
|||
|
node.childNodes.forEach(dfs);
|
|||
|
if (currentBlock.length > 0) {
|
|||
|
blocks.push(currentBlock = []);
|
|||
|
}
|
|||
|
} else {
|
|||
|
node.childNodes.forEach(dfs);
|
|||
|
}
|
|||
|
} else if (node.nodeType === type_1.default.TEXT_NODE) {
|
|||
|
if (node.isWhitespace) {
|
|||
|
currentBlock.prependWhitespace = true;
|
|||
|
} else {
|
|||
|
var text = node.trimmedText;
|
|||
|
if (currentBlock.prependWhitespace) {
|
|||
|
text = " ".concat(text);
|
|||
|
currentBlock.prependWhitespace = false;
|
|||
|
}
|
|||
|
currentBlock.push(text);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
dfs(this);
|
|||
|
return blocks.map(function(block) {
|
|||
|
return block.join("").replace(/\s{2,}/g, " ");
|
|||
|
}).join("\n").replace(/\s+$/, "");
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
HTMLElement2.prototype.toString = function() {
|
|||
|
var tag = this.rawTagName;
|
|||
|
if (tag) {
|
|||
|
var attrs = this.rawAttrs ? " ".concat(this.rawAttrs) : "";
|
|||
|
return this.voidTag.formatNode(tag, attrs, this.innerHTML);
|
|||
|
}
|
|||
|
return this.innerHTML;
|
|||
|
};
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "innerHTML", {
|
|||
|
get: function() {
|
|||
|
return this.childNodes.map(function(child) {
|
|||
|
return child.toString();
|
|||
|
}).join("");
|
|||
|
},
|
|||
|
set: function(content) {
|
|||
|
var r = parse2(content, this._parseOptions);
|
|||
|
var nodes = r.childNodes.length ? r.childNodes : [new text_1.default(content, this)];
|
|||
|
resetParent(nodes, this);
|
|||
|
resetParent(this.childNodes, null);
|
|||
|
this.childNodes = nodes;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
HTMLElement2.prototype.set_content = function(content, options) {
|
|||
|
if (options === void 0) {
|
|||
|
options = {};
|
|||
|
}
|
|||
|
if (content instanceof node_1.default) {
|
|||
|
content = [content];
|
|||
|
} else if (typeof content == "string") {
|
|||
|
options = __assign(__assign({}, this._parseOptions), options);
|
|||
|
var r = parse2(content, options);
|
|||
|
content = r.childNodes.length ? r.childNodes : [new text_1.default(r.innerHTML, this)];
|
|||
|
}
|
|||
|
resetParent(this.childNodes, null);
|
|||
|
resetParent(content, this);
|
|||
|
this.childNodes = content;
|
|||
|
return this;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.replaceWith = function() {
|
|||
|
var _this = this;
|
|||
|
var nodes = [];
|
|||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|||
|
nodes[_i] = arguments[_i];
|
|||
|
}
|
|||
|
var parent = this.parentNode;
|
|||
|
var content = nodes.map(function(node) {
|
|||
|
if (node instanceof node_1.default) {
|
|||
|
return [node];
|
|||
|
} else if (typeof node == "string") {
|
|||
|
var r = parse2(node, _this._parseOptions);
|
|||
|
return r.childNodes.length ? r.childNodes : [new text_1.default(node, _this)];
|
|||
|
}
|
|||
|
return [];
|
|||
|
}).flat();
|
|||
|
var idx = parent.childNodes.findIndex(function(child) {
|
|||
|
return child === _this;
|
|||
|
});
|
|||
|
resetParent([this], null);
|
|||
|
parent.childNodes = __spreadArray(__spreadArray(__spreadArray([], parent.childNodes.slice(0, idx), true), resetParent(content, parent), true), parent.childNodes.slice(idx + 1), true);
|
|||
|
return this;
|
|||
|
};
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "outerHTML", {
|
|||
|
get: function() {
|
|||
|
return this.toString();
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
HTMLElement2.prototype.trimRight = function(pattern) {
|
|||
|
for (var i = 0; i < this.childNodes.length; i++) {
|
|||
|
var childNode = this.childNodes[i];
|
|||
|
if (childNode.nodeType === type_1.default.ELEMENT_NODE) {
|
|||
|
childNode.trimRight(pattern);
|
|||
|
} else {
|
|||
|
var index = childNode.rawText.search(pattern);
|
|||
|
if (index > -1) {
|
|||
|
childNode.rawText = childNode.rawText.substr(0, index);
|
|||
|
this.childNodes.length = i + 1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return this;
|
|||
|
};
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "structure", {
|
|||
|
get: function() {
|
|||
|
var res = [];
|
|||
|
var indention = 0;
|
|||
|
function write(str) {
|
|||
|
res.push(" ".repeat(indention) + str);
|
|||
|
}
|
|||
|
function dfs(node) {
|
|||
|
var idStr = node.id ? "#".concat(node.id) : "";
|
|||
|
var classStr = node.classList.length ? ".".concat(node.classList.value.join(".")) : "";
|
|||
|
write("".concat(node.rawTagName).concat(idStr).concat(classStr));
|
|||
|
indention++;
|
|||
|
node.childNodes.forEach(function(childNode) {
|
|||
|
if (childNode.nodeType === type_1.default.ELEMENT_NODE) {
|
|||
|
dfs(childNode);
|
|||
|
} else if (childNode.nodeType === type_1.default.TEXT_NODE) {
|
|||
|
if (!childNode.isWhitespace) {
|
|||
|
write("#text");
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
indention--;
|
|||
|
}
|
|||
|
dfs(this);
|
|||
|
return res.join("\n");
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
HTMLElement2.prototype.removeWhitespace = function() {
|
|||
|
var _this = this;
|
|||
|
var o = 0;
|
|||
|
this.childNodes.forEach(function(node) {
|
|||
|
if (node.nodeType === type_1.default.TEXT_NODE) {
|
|||
|
if (node.isWhitespace) {
|
|||
|
return;
|
|||
|
}
|
|||
|
node.rawText = node.trimmedRawText;
|
|||
|
} else if (node.nodeType === type_1.default.ELEMENT_NODE) {
|
|||
|
node.removeWhitespace();
|
|||
|
}
|
|||
|
_this.childNodes[o++] = node;
|
|||
|
});
|
|||
|
this.childNodes.length = o;
|
|||
|
return this;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.querySelectorAll = function(selector) {
|
|||
|
return (0, css_select_1.selectAll)(selector, this, {
|
|||
|
xmlMode: true,
|
|||
|
adapter: matcher_1.default
|
|||
|
});
|
|||
|
};
|
|||
|
HTMLElement2.prototype.querySelector = function(selector) {
|
|||
|
return (0, css_select_1.selectOne)(selector, this, {
|
|||
|
xmlMode: true,
|
|||
|
adapter: matcher_1.default
|
|||
|
});
|
|||
|
};
|
|||
|
HTMLElement2.prototype.getElementsByTagName = function(tagName) {
|
|||
|
var upperCasedTagName = tagName.toUpperCase();
|
|||
|
var re = [];
|
|||
|
var stack = [];
|
|||
|
var currentNodeReference = this;
|
|||
|
var index = 0;
|
|||
|
while (index !== void 0) {
|
|||
|
var child = void 0;
|
|||
|
do {
|
|||
|
child = currentNodeReference.childNodes[index++];
|
|||
|
} while (index < currentNodeReference.childNodes.length && child === void 0);
|
|||
|
if (child === void 0) {
|
|||
|
currentNodeReference = currentNodeReference.parentNode;
|
|||
|
index = stack.pop();
|
|||
|
continue;
|
|||
|
}
|
|||
|
if (child.nodeType === type_1.default.ELEMENT_NODE) {
|
|||
|
if (tagName === "*" || child.tagName === upperCasedTagName)
|
|||
|
re.push(child);
|
|||
|
if (child.childNodes.length > 0) {
|
|||
|
stack.push(index);
|
|||
|
currentNodeReference = child;
|
|||
|
index = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return re;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.getElementById = function(id) {
|
|||
|
var stack = [];
|
|||
|
var currentNodeReference = this;
|
|||
|
var index = 0;
|
|||
|
while (index !== void 0) {
|
|||
|
var child = void 0;
|
|||
|
do {
|
|||
|
child = currentNodeReference.childNodes[index++];
|
|||
|
} while (index < currentNodeReference.childNodes.length && child === void 0);
|
|||
|
if (child === void 0) {
|
|||
|
currentNodeReference = currentNodeReference.parentNode;
|
|||
|
index = stack.pop();
|
|||
|
continue;
|
|||
|
}
|
|||
|
if (child.nodeType === type_1.default.ELEMENT_NODE) {
|
|||
|
if (child.id === id) {
|
|||
|
return child;
|
|||
|
}
|
|||
|
;
|
|||
|
if (child.childNodes.length > 0) {
|
|||
|
stack.push(index);
|
|||
|
currentNodeReference = child;
|
|||
|
index = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.closest = function(selector) {
|
|||
|
var mapChild = /* @__PURE__ */ new Map();
|
|||
|
var el = this;
|
|||
|
var old = null;
|
|||
|
function findOne(test, elems) {
|
|||
|
var elem = null;
|
|||
|
for (var i = 0, l = elems.length; i < l && !elem; i++) {
|
|||
|
var el_1 = elems[i];
|
|||
|
if (test(el_1)) {
|
|||
|
elem = el_1;
|
|||
|
} else {
|
|||
|
var child = mapChild.get(el_1);
|
|||
|
if (child) {
|
|||
|
elem = findOne(test, [child]);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return elem;
|
|||
|
}
|
|||
|
while (el) {
|
|||
|
mapChild.set(el, old);
|
|||
|
old = el;
|
|||
|
el = el.parentNode;
|
|||
|
}
|
|||
|
el = this;
|
|||
|
while (el) {
|
|||
|
var e = (0, css_select_1.selectOne)(selector, el, {
|
|||
|
xmlMode: true,
|
|||
|
adapter: __assign(__assign({}, matcher_1.default), { getChildren: function(node) {
|
|||
|
var child = mapChild.get(node);
|
|||
|
return child && [child];
|
|||
|
}, getSiblings: function(node) {
|
|||
|
return [node];
|
|||
|
}, findOne, findAll: function() {
|
|||
|
return [];
|
|||
|
} })
|
|||
|
});
|
|||
|
if (e) {
|
|||
|
return e;
|
|||
|
}
|
|||
|
el = el.parentNode;
|
|||
|
}
|
|||
|
return null;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.appendChild = function(node) {
|
|||
|
node.remove();
|
|||
|
this.childNodes.push(node);
|
|||
|
node.parentNode = this;
|
|||
|
return node;
|
|||
|
};
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "firstChild", {
|
|||
|
get: function() {
|
|||
|
return this.childNodes[0];
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "lastChild", {
|
|||
|
get: function() {
|
|||
|
return (0, back_1.default)(this.childNodes);
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "attrs", {
|
|||
|
get: function() {
|
|||
|
if (this._attrs) {
|
|||
|
return this._attrs;
|
|||
|
}
|
|||
|
this._attrs = {};
|
|||
|
var attrs = this.rawAttributes;
|
|||
|
for (var key in attrs) {
|
|||
|
var val = attrs[key] || "";
|
|||
|
this._attrs[key.toLowerCase()] = decode(val);
|
|||
|
}
|
|||
|
return this._attrs;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "attributes", {
|
|||
|
get: function() {
|
|||
|
var ret_attrs = {};
|
|||
|
var attrs = this.rawAttributes;
|
|||
|
for (var key in attrs) {
|
|||
|
var val = attrs[key] || "";
|
|||
|
ret_attrs[key] = decode(val);
|
|||
|
}
|
|||
|
return ret_attrs;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "rawAttributes", {
|
|||
|
get: function() {
|
|||
|
if (this._rawAttrs) {
|
|||
|
return this._rawAttrs;
|
|||
|
}
|
|||
|
var attrs = {};
|
|||
|
if (this.rawAttrs) {
|
|||
|
var re = /([a-zA-Z()[\]#@$.?:][a-zA-Z0-9-_:()[\]#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
|
|||
|
var match = void 0;
|
|||
|
while (match = re.exec(this.rawAttrs)) {
|
|||
|
var key = match[1];
|
|||
|
var val = match[2] || null;
|
|||
|
if (val && (val[0] === "'" || val[0] === '"'))
|
|||
|
val = val.slice(1, val.length - 1);
|
|||
|
attrs[key] = attrs[key] || val;
|
|||
|
}
|
|||
|
}
|
|||
|
this._rawAttrs = attrs;
|
|||
|
return attrs;
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
HTMLElement2.prototype.removeAttribute = function(key) {
|
|||
|
var _this = this;
|
|||
|
var attrs = this.rawAttributes;
|
|||
|
delete attrs[key];
|
|||
|
if (this._attrs) {
|
|||
|
delete this._attrs[key];
|
|||
|
}
|
|||
|
this.rawAttrs = Object.keys(attrs).map(function(name) {
|
|||
|
var val = _this.quoteAttribute(attrs[name]);
|
|||
|
if (val === "null" || val === '""')
|
|||
|
return name;
|
|||
|
return "".concat(name, "=").concat(val);
|
|||
|
}).join(" ");
|
|||
|
if (key === "id") {
|
|||
|
this.id = "";
|
|||
|
}
|
|||
|
return this;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.hasAttribute = function(key) {
|
|||
|
return key.toLowerCase() in this.attrs;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.getAttribute = function(key) {
|
|||
|
return this.attrs[key.toLowerCase()];
|
|||
|
};
|
|||
|
HTMLElement2.prototype.setAttribute = function(key, value) {
|
|||
|
var _this = this;
|
|||
|
if (arguments.length < 2) {
|
|||
|
throw new Error("Failed to execute 'setAttribute' on 'Element'");
|
|||
|
}
|
|||
|
var k2 = key.toLowerCase();
|
|||
|
var attrs = this.rawAttributes;
|
|||
|
for (var k in attrs) {
|
|||
|
if (k.toLowerCase() === k2) {
|
|||
|
key = k;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
attrs[key] = String(value);
|
|||
|
if (this._attrs) {
|
|||
|
this._attrs[k2] = decode(attrs[key]);
|
|||
|
}
|
|||
|
this.rawAttrs = Object.keys(attrs).map(function(name) {
|
|||
|
var val = _this.quoteAttribute(attrs[name]);
|
|||
|
if (val === "null" || val === '""')
|
|||
|
return name;
|
|||
|
return "".concat(name, "=").concat(val);
|
|||
|
}).join(" ");
|
|||
|
if (key === "id") {
|
|||
|
this.id = value;
|
|||
|
}
|
|||
|
return this;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.setAttributes = function(attributes) {
|
|||
|
var _this = this;
|
|||
|
if (this._attrs) {
|
|||
|
delete this._attrs;
|
|||
|
}
|
|||
|
if (this._rawAttrs) {
|
|||
|
delete this._rawAttrs;
|
|||
|
}
|
|||
|
this.rawAttrs = Object.keys(attributes).map(function(name) {
|
|||
|
var val = attributes[name];
|
|||
|
if (val === "null" || val === '""')
|
|||
|
return name;
|
|||
|
return "".concat(name, "=").concat(_this.quoteAttribute(String(val)));
|
|||
|
}).join(" ");
|
|||
|
return this;
|
|||
|
};
|
|||
|
HTMLElement2.prototype.insertAdjacentHTML = function(where, html) {
|
|||
|
var _a, _b, _c;
|
|||
|
var _this = this;
|
|||
|
if (arguments.length < 2) {
|
|||
|
throw new Error("2 arguments required");
|
|||
|
}
|
|||
|
var p = parse2(html, this._parseOptions);
|
|||
|
if (where === "afterend") {
|
|||
|
var idx = this.parentNode.childNodes.findIndex(function(child) {
|
|||
|
return child === _this;
|
|||
|
});
|
|||
|
resetParent(p.childNodes, this.parentNode);
|
|||
|
(_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes, false));
|
|||
|
} else if (where === "afterbegin") {
|
|||
|
resetParent(p.childNodes, this);
|
|||
|
(_b = this.childNodes).unshift.apply(_b, p.childNodes);
|
|||
|
} else if (where === "beforeend") {
|
|||
|
p.childNodes.forEach(function(n) {
|
|||
|
_this.appendChild(n);
|
|||
|
});
|
|||
|
} else if (where === "beforebegin") {
|
|||
|
var idx = this.parentNode.childNodes.findIndex(function(child) {
|
|||
|
return child === _this;
|
|||
|
});
|
|||
|
resetParent(p.childNodes, this.parentNode);
|
|||
|
(_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes, false));
|
|||
|
} else {
|
|||
|
throw new Error("The value provided ('".concat(where, "') is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'"));
|
|||
|
}
|
|||
|
return this;
|
|||
|
};
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "nextSibling", {
|
|||
|
get: function() {
|
|||
|
if (this.parentNode) {
|
|||
|
var children = this.parentNode.childNodes;
|
|||
|
var i = 0;
|
|||
|
while (i < children.length) {
|
|||
|
var child = children[i++];
|
|||
|
if (this === child)
|
|||
|
return children[i] || null;
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "nextElementSibling", {
|
|||
|
get: function() {
|
|||
|
if (this.parentNode) {
|
|||
|
var children = this.parentNode.childNodes;
|
|||
|
var i = 0;
|
|||
|
var find = false;
|
|||
|
while (i < children.length) {
|
|||
|
var child = children[i++];
|
|||
|
if (find) {
|
|||
|
if (child instanceof HTMLElement2) {
|
|||
|
return child || null;
|
|||
|
}
|
|||
|
} else if (this === child) {
|
|||
|
find = true;
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "previousSibling", {
|
|||
|
get: function() {
|
|||
|
if (this.parentNode) {
|
|||
|
var children = this.parentNode.childNodes;
|
|||
|
var i = children.length;
|
|||
|
while (i > 0) {
|
|||
|
var child = children[--i];
|
|||
|
if (this === child)
|
|||
|
return children[i - 1] || null;
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "previousElementSibling", {
|
|||
|
get: function() {
|
|||
|
if (this.parentNode) {
|
|||
|
var children = this.parentNode.childNodes;
|
|||
|
var i = children.length;
|
|||
|
var find = false;
|
|||
|
while (i > 0) {
|
|||
|
var child = children[--i];
|
|||
|
if (find) {
|
|||
|
if (child instanceof HTMLElement2) {
|
|||
|
return child || null;
|
|||
|
}
|
|||
|
} else if (this === child) {
|
|||
|
find = true;
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
Object.defineProperty(HTMLElement2.prototype, "classNames", {
|
|||
|
get: function() {
|
|||
|
return this.classList.toString();
|
|||
|
},
|
|||
|
enumerable: false,
|
|||
|
configurable: true
|
|||
|
});
|
|||
|
HTMLElement2.prototype.clone = function() {
|
|||
|
return parse2(this.toString(), this._parseOptions).firstChild;
|
|||
|
};
|
|||
|
return HTMLElement2;
|
|||
|
}(node_1.default);
|
|||
|
exports.default = HTMLElement;
|
|||
|
var kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g;
|
|||
|
var kAttributePattern = /(?:^|\s)(id|class)\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+)/gi;
|
|||
|
var kElementsClosedByOpening = {
|
|||
|
li: { li: true, LI: true },
|
|||
|
LI: { li: true, LI: true },
|
|||
|
p: { p: true, div: true, P: true, DIV: true },
|
|||
|
P: { p: true, div: true, P: true, DIV: true },
|
|||
|
b: { div: true, DIV: true },
|
|||
|
B: { div: true, DIV: true },
|
|||
|
td: { td: true, th: true, TD: true, TH: true },
|
|||
|
TD: { td: true, th: true, TD: true, TH: true },
|
|||
|
th: { td: true, th: true, TD: true, TH: true },
|
|||
|
TH: { td: true, th: true, TD: true, TH: true },
|
|||
|
h1: { h1: true, H1: true },
|
|||
|
H1: { h1: true, H1: true },
|
|||
|
h2: { h2: true, H2: true },
|
|||
|
H2: { h2: true, H2: true },
|
|||
|
h3: { h3: true, H3: true },
|
|||
|
H3: { h3: true, H3: true },
|
|||
|
h4: { h4: true, H4: true },
|
|||
|
H4: { h4: true, H4: true },
|
|||
|
h5: { h5: true, H5: true },
|
|||
|
H5: { h5: true, H5: true },
|
|||
|
h6: { h6: true, H6: true },
|
|||
|
H6: { h6: true, H6: true }
|
|||
|
};
|
|||
|
var kElementsClosedByClosing = {
|
|||
|
li: { ul: true, ol: true, UL: true, OL: true },
|
|||
|
LI: { ul: true, ol: true, UL: true, OL: true },
|
|||
|
a: { div: true, DIV: true },
|
|||
|
A: { div: true, DIV: true },
|
|||
|
b: { div: true, DIV: true },
|
|||
|
B: { div: true, DIV: true },
|
|||
|
i: { div: true, DIV: true },
|
|||
|
I: { div: true, DIV: true },
|
|||
|
p: { div: true, DIV: true },
|
|||
|
P: { div: true, DIV: true },
|
|||
|
td: { tr: true, table: true, TR: true, TABLE: true },
|
|||
|
TD: { tr: true, table: true, TR: true, TABLE: true },
|
|||
|
th: { tr: true, table: true, TR: true, TABLE: true },
|
|||
|
TH: { tr: true, table: true, TR: true, TABLE: true }
|
|||
|
};
|
|||
|
var frameflag = "documentfragmentcontainer";
|
|||
|
function base_parse(data, options) {
|
|||
|
var _a, _b;
|
|||
|
if (options === void 0) {
|
|||
|
options = {};
|
|||
|
}
|
|||
|
var voidTag = new void_tag_1.default((_a = options === null || options === void 0 ? void 0 : options.voidTag) === null || _a === void 0 ? void 0 : _a.closingSlash, (_b = options === null || options === void 0 ? void 0 : options.voidTag) === null || _b === void 0 ? void 0 : _b.tags);
|
|||
|
var elements = options.blockTextElements || {
|
|||
|
script: true,
|
|||
|
noscript: true,
|
|||
|
style: true,
|
|||
|
pre: true
|
|||
|
};
|
|||
|
var element_names = Object.keys(elements);
|
|||
|
var kBlockTextElements = element_names.map(function(it) {
|
|||
|
return new RegExp("^".concat(it, "$"), "i");
|
|||
|
});
|
|||
|
var kIgnoreElements = element_names.filter(function(it) {
|
|||
|
return Boolean(elements[it]);
|
|||
|
}).map(function(it) {
|
|||
|
return new RegExp("^".concat(it, "$"), "i");
|
|||
|
});
|
|||
|
function element_should_be_ignore(tag) {
|
|||
|
return kIgnoreElements.some(function(it) {
|
|||
|
return it.test(tag);
|
|||
|
});
|
|||
|
}
|
|||
|
function is_block_text_element(tag) {
|
|||
|
return kBlockTextElements.some(function(it) {
|
|||
|
return it.test(tag);
|
|||
|
});
|
|||
|
}
|
|||
|
var createRange = function(startPos, endPos) {
|
|||
|
return [startPos - frameFlagOffset, endPos - frameFlagOffset];
|
|||
|
};
|
|||
|
var root = new HTMLElement(null, {}, "", null, [0, data.length], voidTag, options);
|
|||
|
var currentParent = root;
|
|||
|
var stack = [root];
|
|||
|
var lastTextPos = -1;
|
|||
|
var noNestedTagIndex = void 0;
|
|||
|
var match;
|
|||
|
data = "<".concat(frameflag, ">").concat(data, "</").concat(frameflag, ">");
|
|||
|
var lowerCaseTagName = options.lowerCaseTagName, fixNestedATags = options.fixNestedATags;
|
|||
|
var dataEndPos = data.length - (frameflag.length + 2);
|
|||
|
var frameFlagOffset = frameflag.length + 2;
|
|||
|
while (match = kMarkupPattern.exec(data)) {
|
|||
|
var matchText = match[0], leadingSlash = match[1], tagName = match[2], attributes = match[3], closingSlash = match[4];
|
|||
|
var matchLength = matchText.length;
|
|||
|
var tagStartPos = kMarkupPattern.lastIndex - matchLength;
|
|||
|
var tagEndPos = kMarkupPattern.lastIndex;
|
|||
|
if (lastTextPos > -1) {
|
|||
|
if (lastTextPos + matchLength < tagEndPos) {
|
|||
|
var text = data.substring(lastTextPos, tagStartPos);
|
|||
|
currentParent.appendChild(new text_1.default(text, currentParent, createRange(lastTextPos, tagStartPos)));
|
|||
|
}
|
|||
|
}
|
|||
|
lastTextPos = kMarkupPattern.lastIndex;
|
|||
|
if (tagName === frameflag)
|
|||
|
continue;
|
|||
|
if (matchText[1] === "!") {
|
|||
|
if (options.comment) {
|
|||
|
var text = data.substring(tagStartPos + 4, tagEndPos - 3);
|
|||
|
currentParent.appendChild(new comment_1.default(text, currentParent, createRange(tagStartPos, tagEndPos)));
|
|||
|
}
|
|||
|
continue;
|
|||
|
}
|
|||
|
if (lowerCaseTagName)
|
|||
|
tagName = tagName.toLowerCase();
|
|||
|
if (!leadingSlash) {
|
|||
|
var attrs = {};
|
|||
|
for (var attMatch = void 0; attMatch = kAttributePattern.exec(attributes); ) {
|
|||
|
var key = attMatch[1], val = attMatch[2];
|
|||
|
var isQuoted = val[0] === "'" || val[0] === '"';
|
|||
|
attrs[key.toLowerCase()] = isQuoted ? val.slice(1, val.length - 1) : val;
|
|||
|
}
|
|||
|
var parentTagName = currentParent.rawTagName;
|
|||
|
if (!closingSlash && kElementsClosedByOpening[parentTagName]) {
|
|||
|
if (kElementsClosedByOpening[parentTagName][tagName]) {
|
|||
|
stack.pop();
|
|||
|
currentParent = (0, back_1.default)(stack);
|
|||
|
}
|
|||
|
}
|
|||
|
if (fixNestedATags && (tagName === "a" || tagName === "A")) {
|
|||
|
if (noNestedTagIndex !== void 0) {
|
|||
|
stack.splice(noNestedTagIndex);
|
|||
|
currentParent = (0, back_1.default)(stack);
|
|||
|
}
|
|||
|
noNestedTagIndex = stack.length;
|
|||
|
}
|
|||
|
var tagEndPos_1 = kMarkupPattern.lastIndex;
|
|||
|
var tagStartPos_1 = tagEndPos_1 - matchLength;
|
|||
|
currentParent = currentParent.appendChild(new HTMLElement(tagName, attrs, attributes.slice(1), null, createRange(tagStartPos_1, tagEndPos_1), voidTag, options));
|
|||
|
stack.push(currentParent);
|
|||
|
if (is_block_text_element(tagName)) {
|
|||
|
var closeMarkup = "</".concat(tagName, ">");
|
|||
|
var closeIndex = lowerCaseTagName ? data.toLocaleLowerCase().indexOf(closeMarkup, kMarkupPattern.lastIndex) : data.indexOf(closeMarkup, kMarkupPattern.lastIndex);
|
|||
|
var textEndPos = closeIndex === -1 ? dataEndPos : closeIndex;
|
|||
|
if (element_should_be_ignore(tagName)) {
|
|||
|
var text = data.substring(tagEndPos_1, textEndPos);
|
|||
|
if (text.length > 0 && /\S/.test(text)) {
|
|||
|
currentParent.appendChild(new text_1.default(text, currentParent, createRange(tagEndPos_1, textEndPos)));
|
|||
|
}
|
|||
|
}
|
|||
|
if (closeIndex === -1) {
|
|||
|
lastTextPos = kMarkupPattern.lastIndex = data.length + 1;
|
|||
|
} else {
|
|||
|
lastTextPos = kMarkupPattern.lastIndex = closeIndex + closeMarkup.length;
|
|||
|
leadingSlash = "/";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if (leadingSlash || closingSlash || voidTag.isVoidElement(tagName)) {
|
|||
|
while (true) {
|
|||
|
if (noNestedTagIndex != null && (tagName === "a" || tagName === "A"))
|
|||
|
noNestedTagIndex = void 0;
|
|||
|
if (currentParent.rawTagName === tagName) {
|
|||
|
currentParent.range[1] = createRange(-1, Math.max(lastTextPos, tagEndPos))[1];
|
|||
|
stack.pop();
|
|||
|
currentParent = (0, back_1.default)(stack);
|
|||
|
break;
|
|||
|
} else {
|
|||
|
var parentTagName = currentParent.tagName;
|
|||
|
if (kElementsClosedByClosing[parentTagName]) {
|
|||
|
if (kElementsClosedByClosing[parentTagName][tagName]) {
|
|||
|
stack.pop();
|
|||
|
currentParent = (0, back_1.default)(stack);
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return stack;
|
|||
|
}
|
|||
|
exports.base_parse = base_parse;
|
|||
|
function parse2(data, options) {
|
|||
|
if (options === void 0) {
|
|||
|
options = {};
|
|||
|
}
|
|||
|
var stack = base_parse(data, options);
|
|||
|
var root = stack[0];
|
|||
|
var _loop_1 = function() {
|
|||
|
var last = stack.pop();
|
|||
|
var oneBefore = (0, back_1.default)(stack);
|
|||
|
if (last.parentNode && last.parentNode.parentNode) {
|
|||
|
if (last.parentNode === oneBefore && last.tagName === oneBefore.tagName) {
|
|||
|
if (options.parseNoneClosedTags !== true) {
|
|||
|
oneBefore.removeChild(last);
|
|||
|
last.childNodes.forEach(function(child) {
|
|||
|
oneBefore.parentNode.appendChild(child);
|
|||
|
});
|
|||
|
stack.pop();
|
|||
|
}
|
|||
|
} else {
|
|||
|
if (options.parseNoneClosedTags !== true) {
|
|||
|
oneBefore.removeChild(last);
|
|||
|
last.childNodes.forEach(function(child) {
|
|||
|
oneBefore.appendChild(child);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
} else {
|
|||
|
}
|
|||
|
};
|
|||
|
while (stack.length > 1) {
|
|||
|
_loop_1();
|
|||
|
}
|
|||
|
return root;
|
|||
|
}
|
|||
|
exports.parse = parse2;
|
|||
|
function resetParent(nodes, parent) {
|
|||
|
return nodes.map(function(node) {
|
|||
|
node.parentNode = parent;
|
|||
|
return node;
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/parse.js
|
|||
|
var require_parse3 = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/parse.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.default = void 0;
|
|||
|
var html_1 = require_html();
|
|||
|
Object.defineProperty(exports, "default", { enumerable: true, get: function() {
|
|||
|
return html_1.parse;
|
|||
|
} });
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/valid.js
|
|||
|
var require_valid = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/valid.js"(exports) {
|
|||
|
"use strict";
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
var html_1 = require_html();
|
|||
|
function valid(data, options) {
|
|||
|
if (options === void 0) {
|
|||
|
options = {};
|
|||
|
}
|
|||
|
var stack = (0, html_1.base_parse)(data, options);
|
|||
|
return Boolean(stack.length === 1);
|
|||
|
}
|
|||
|
exports.default = valid;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// node_modules/node-html-parser/dist/index.js
|
|||
|
var require_dist = __commonJS({
|
|||
|
"node_modules/node-html-parser/dist/index.js"(exports) {
|
|||
|
"use strict";
|
|||
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
};
|
|||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
exports.NodeType = exports.TextNode = exports.Node = exports.valid = exports.CommentNode = exports.HTMLElement = exports.parse = void 0;
|
|||
|
var comment_1 = __importDefault(require_comment());
|
|||
|
exports.CommentNode = comment_1.default;
|
|||
|
var html_1 = __importDefault(require_html());
|
|||
|
exports.HTMLElement = html_1.default;
|
|||
|
var node_1 = __importDefault(require_node());
|
|||
|
exports.Node = node_1.default;
|
|||
|
var text_1 = __importDefault(require_text());
|
|||
|
exports.TextNode = text_1.default;
|
|||
|
var type_1 = __importDefault(require_type());
|
|||
|
exports.NodeType = type_1.default;
|
|||
|
var parse_1 = __importDefault(require_parse3());
|
|||
|
var valid_1 = __importDefault(require_valid());
|
|||
|
exports.valid = valid_1.default;
|
|||
|
function parse2(data, options) {
|
|||
|
if (options === void 0) {
|
|||
|
options = {};
|
|||
|
}
|
|||
|
return (0, parse_1.default)(data, options);
|
|||
|
}
|
|||
|
exports.default = parse2;
|
|||
|
exports.parse = parse2;
|
|||
|
parse2.parse = parse_1.default;
|
|||
|
parse2.HTMLElement = html_1.default;
|
|||
|
parse2.CommentNode = comment_1.default;
|
|||
|
parse2.valid = valid_1.default;
|
|||
|
parse2.Node = node_1.default;
|
|||
|
parse2.TextNode = text_1.default;
|
|||
|
parse2.NodeType = type_1.default;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// src/main.ts
|
|||
|
var main_exports = {};
|
|||
|
__export(main_exports, {
|
|||
|
default: () => YTranscriptPlugin
|
|||
|
});
|
|||
|
module.exports = __toCommonJS(main_exports);
|
|||
|
var import_obsidian4 = require("obsidian");
|
|||
|
|
|||
|
// src/transcript-view.ts
|
|||
|
var import_obsidian2 = require("obsidian");
|
|||
|
|
|||
|
// src/fetch-transcript.ts
|
|||
|
var import_node_html_parser = __toESM(require_dist());
|
|||
|
var import_obsidian = require("obsidian");
|
|||
|
var YOUTUBE_TITLE_REGEX = new RegExp(/<meta\s+name="title"\s+content="([^"]*)">/);
|
|||
|
var YoutubeTranscriptError = class extends Error {
|
|||
|
constructor(err) {
|
|||
|
if (!(err instanceof Error)) {
|
|||
|
super("");
|
|||
|
return;
|
|||
|
}
|
|||
|
if (err.message.includes("ERR_INVALID_URL")) {
|
|||
|
super("Invalid YouTube URL");
|
|||
|
} else {
|
|||
|
super(err.message);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
var YoutubeTranscript = class {
|
|||
|
static async fetchTranscript(url, config) {
|
|||
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|||
|
try {
|
|||
|
const langCode = (_a = config == null ? void 0 : config.lang) != null ? _a : "en";
|
|||
|
const videoPageBody = await (0, import_obsidian.request)(url);
|
|||
|
const parsedBody = (0, import_node_html_parser.parse)(videoPageBody);
|
|||
|
const titleMatch = videoPageBody.match(YOUTUBE_TITLE_REGEX);
|
|||
|
let title = "";
|
|||
|
if (titleMatch)
|
|||
|
title = titleMatch[1];
|
|||
|
const scripts = parsedBody.getElementsByTagName("script");
|
|||
|
const playerScript = scripts.find((script) => script.textContent.includes("var ytInitialPlayerResponse = {"));
|
|||
|
const dataString = ((_e = (_d = (_c = (_b = playerScript.textContent) == null ? void 0 : _b.split("var ytInitialPlayerResponse = ")) == null ? void 0 : _c[1]) == null ? void 0 : _d.split("};")) == null ? void 0 : _e[0]) + "}";
|
|||
|
const data = JSON.parse(dataString.trim());
|
|||
|
const availableCaptions = ((_g = (_f = data == null ? void 0 : data.captions) == null ? void 0 : _f.playerCaptionsTracklistRenderer) == null ? void 0 : _g.captionTracks) || [];
|
|||
|
let captionTrack = availableCaptions == null ? void 0 : availableCaptions[0];
|
|||
|
if (langCode)
|
|||
|
captionTrack = (_h = availableCaptions.find((track) => track.languageCode.includes(langCode))) != null ? _h : availableCaptions == null ? void 0 : availableCaptions[0];
|
|||
|
const captionsUrl = captionTrack == null ? void 0 : captionTrack.baseUrl;
|
|||
|
const resXML = await (0, import_obsidian.request)(captionsUrl).then((xml) => (0, import_node_html_parser.parse)(xml));
|
|||
|
const chunks = resXML.getElementsByTagName("text");
|
|||
|
console.log(chunks);
|
|||
|
return {
|
|||
|
title,
|
|||
|
lines: chunks.map((cue) => ({
|
|||
|
text: cue.textContent.replaceAll("'", "'"),
|
|||
|
duration: parseFloat(cue.attributes.dur) * 1e3,
|
|||
|
offset: parseFloat(cue.attributes.start) * 1e3
|
|||
|
}))
|
|||
|
};
|
|||
|
} catch (err) {
|
|||
|
throw new YoutubeTranscriptError(err);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// src/timestampt-utils.ts
|
|||
|
var formatTimestamp = (t) => {
|
|||
|
if (t < 0)
|
|||
|
return "00:00";
|
|||
|
const fnum = (n) => `${n | 0}`.padStart(2, "0");
|
|||
|
const s = 1e3;
|
|||
|
const m = 60 * s;
|
|||
|
const h = 60 * m;
|
|||
|
const hours = Math.floor(t / h);
|
|||
|
const minutes = Math.floor((t - hours * h) / m);
|
|||
|
const seconds = Math.floor((t - hours * h - minutes * m) / s);
|
|||
|
const time = hours ? [hours, minutes, seconds] : [minutes, seconds];
|
|||
|
return time.map(fnum).join(":");
|
|||
|
};
|
|||
|
|
|||
|
// src/render-utils.ts
|
|||
|
var highlightText = (div, searchValue) => {
|
|||
|
const content = div.innerHTML;
|
|||
|
const highlightedContent = content.replace(new RegExp(searchValue, "gi"), '<span class="yt-transcript__highlight">$&</span>');
|
|||
|
div.innerHTML = highlightedContent;
|
|||
|
};
|
|||
|
var getTranscriptBlocks = (data, timestampMod) => {
|
|||
|
const transcriptBlocks = [];
|
|||
|
let quote = "";
|
|||
|
let quoteTimeOffset = 0;
|
|||
|
data.forEach((line, i) => {
|
|||
|
if (i === 0) {
|
|||
|
quoteTimeOffset = line.offset;
|
|||
|
quote += line.text + " ";
|
|||
|
return;
|
|||
|
}
|
|||
|
if (i % timestampMod == 0) {
|
|||
|
transcriptBlocks.push({
|
|||
|
quote,
|
|||
|
quoteTimeOffset
|
|||
|
});
|
|||
|
quote = "";
|
|||
|
quoteTimeOffset = line.offset;
|
|||
|
}
|
|||
|
quote += line.text + " ";
|
|||
|
});
|
|||
|
if (quote !== "") {
|
|||
|
transcriptBlocks.push({
|
|||
|
quote,
|
|||
|
quoteTimeOffset
|
|||
|
});
|
|||
|
}
|
|||
|
return transcriptBlocks;
|
|||
|
};
|
|||
|
|
|||
|
// src/transcript-view.ts
|
|||
|
var TRANSCRIPT_TYPE_VIEW = "transcript-view";
|
|||
|
var TranscriptView = class extends import_obsidian2.ItemView {
|
|||
|
constructor(leaf, plugin) {
|
|||
|
super(leaf);
|
|||
|
this.videoData = [];
|
|||
|
this.plugin = plugin;
|
|||
|
this.isDataLoaded = false;
|
|||
|
}
|
|||
|
async onOpen() {
|
|||
|
const { contentEl } = this;
|
|||
|
contentEl.empty();
|
|||
|
contentEl.createEl("h4", { text: "Transcript" });
|
|||
|
}
|
|||
|
async onClose() {
|
|||
|
const leafIndex = this.getLeafIndex();
|
|||
|
this.plugin.settings.leafUrls.splice(leafIndex, 1);
|
|||
|
}
|
|||
|
getLeafIndex() {
|
|||
|
const leaves = this.app.workspace.getLeavesOfType(TRANSCRIPT_TYPE_VIEW);
|
|||
|
return leaves.findIndex((leaf) => leaf === this.leaf);
|
|||
|
}
|
|||
|
renderLoader() {
|
|||
|
if (this.loaderContainerEl !== void 0) {
|
|||
|
this.loaderContainerEl.createEl("div", {
|
|||
|
text: "Loading..."
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
renderSearchInput(url, data, timestampMod) {
|
|||
|
const searchInputEl = this.contentEl.createEl("input");
|
|||
|
searchInputEl.type = "text";
|
|||
|
searchInputEl.placeholder = "Search...";
|
|||
|
searchInputEl.style.marginBottom = "20px";
|
|||
|
searchInputEl.addEventListener("input", (e) => {
|
|||
|
const searchFilter = e.target.value;
|
|||
|
this.renderTranscriptionBlocks(url, data, timestampMod, searchFilter);
|
|||
|
});
|
|||
|
}
|
|||
|
renderVideoTitle(title) {
|
|||
|
const titleEl = this.contentEl.createEl("div");
|
|||
|
titleEl.innerHTML = title;
|
|||
|
titleEl.style.fontWeight = "bold";
|
|||
|
titleEl.style.marginBottom = "20px";
|
|||
|
}
|
|||
|
formatContentToPaste(url, blocks) {
|
|||
|
return blocks.map((block) => {
|
|||
|
const { quote, quoteTimeOffset } = block;
|
|||
|
const href = url + "&t=" + Math.floor(quoteTimeOffset / 1e3);
|
|||
|
const formattedBlock = `[${formatTimestamp(quoteTimeOffset)}](${href}) ${quote}`;
|
|||
|
return formattedBlock;
|
|||
|
}).join("\n");
|
|||
|
}
|
|||
|
renderTranscriptionBlocks(url, data, timestampMod, searchValue) {
|
|||
|
const dataContainerEl = this.dataContainerEl;
|
|||
|
if (dataContainerEl !== void 0) {
|
|||
|
dataContainerEl.empty();
|
|||
|
const transcriptBlocks = getTranscriptBlocks(data.lines, timestampMod);
|
|||
|
const filteredBlocks = transcriptBlocks.filter((block) => block.quote.toLowerCase().includes(searchValue.toLowerCase()));
|
|||
|
filteredBlocks.forEach((block) => {
|
|||
|
const { quote, quoteTimeOffset } = block;
|
|||
|
const blockContainerEl = createEl("div", {
|
|||
|
cls: "yt-transcript__transcript-block"
|
|||
|
});
|
|||
|
blockContainerEl.draggable = true;
|
|||
|
const linkEl = createEl("a", {
|
|||
|
text: formatTimestamp(quoteTimeOffset),
|
|||
|
attr: {
|
|||
|
href: url + "&t=" + Math.floor(quoteTimeOffset / 1e3)
|
|||
|
}
|
|||
|
});
|
|||
|
linkEl.style.marginBottom = "5px";
|
|||
|
const span = dataContainerEl.createEl("span", {
|
|||
|
text: quote,
|
|||
|
title: "Click to copy"
|
|||
|
});
|
|||
|
span.addEventListener("click", (event) => {
|
|||
|
var _a;
|
|||
|
const target = event.target;
|
|||
|
if (target !== null) {
|
|||
|
navigator.clipboard.writeText((_a = target.textContent) != null ? _a : "");
|
|||
|
}
|
|||
|
});
|
|||
|
if (searchValue !== "")
|
|||
|
highlightText(span, searchValue);
|
|||
|
blockContainerEl.appendChild(linkEl);
|
|||
|
blockContainerEl.appendChild(span);
|
|||
|
blockContainerEl.addEventListener("dragstart", (event) => {
|
|||
|
var _a;
|
|||
|
(_a = event.dataTransfer) == null ? void 0 : _a.setData("text/html", blockContainerEl.innerHTML);
|
|||
|
});
|
|||
|
blockContainerEl.addEventListener("contextmenu", (event) => {
|
|||
|
const menu = new import_obsidian2.Menu();
|
|||
|
menu.addItem((item) => item.setTitle("Copy all").onClick(() => {
|
|||
|
navigator.clipboard.writeText(this.formatContentToPaste(url, filteredBlocks));
|
|||
|
}));
|
|||
|
menu.showAtPosition({
|
|||
|
x: event.clientX,
|
|||
|
y: event.clientY
|
|||
|
});
|
|||
|
});
|
|||
|
dataContainerEl.appendChild(blockContainerEl);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
async setEphemeralState(state) {
|
|||
|
var _a;
|
|||
|
if (this.isDataLoaded)
|
|||
|
return;
|
|||
|
const leafIndex = this.getLeafIndex();
|
|||
|
if (state.url) {
|
|||
|
this.plugin.settings.leafUrls[leafIndex] = state.url;
|
|||
|
await this.plugin.saveSettings();
|
|||
|
}
|
|||
|
const { lang, country, timestampMod, leafUrls } = this.plugin.settings;
|
|||
|
const url = leafUrls[leafIndex];
|
|||
|
try {
|
|||
|
if (this.loaderContainerEl === void 0) {
|
|||
|
this.loaderContainerEl = this.contentEl.createEl("div");
|
|||
|
} else {
|
|||
|
this.loaderContainerEl.empty();
|
|||
|
}
|
|||
|
this.renderLoader();
|
|||
|
const data = await YoutubeTranscript.fetchTranscript(url, {
|
|||
|
lang,
|
|||
|
country
|
|||
|
});
|
|||
|
if (!data)
|
|||
|
throw Error();
|
|||
|
this.isDataLoaded = true;
|
|||
|
this.loaderContainerEl.empty();
|
|||
|
this.renderVideoTitle(data.title);
|
|||
|
this.renderSearchInput(url, data, timestampMod);
|
|||
|
if (this.dataContainerEl === void 0) {
|
|||
|
this.dataContainerEl = this.contentEl.createEl("div");
|
|||
|
} else {
|
|||
|
this.dataContainerEl.empty();
|
|||
|
}
|
|||
|
if (this.errorContainerEl !== void 0) {
|
|||
|
this.errorContainerEl.empty();
|
|||
|
}
|
|||
|
if (data.lines.length === 0) {
|
|||
|
this.dataContainerEl.createEl("h4", {
|
|||
|
text: "No transcript found"
|
|||
|
});
|
|||
|
this.dataContainerEl.createEl("div", {
|
|||
|
text: "Please check if video contains any transcript or try adjust language and country in plugin settings."
|
|||
|
});
|
|||
|
} else {
|
|||
|
this.renderTranscriptionBlocks(url, data, timestampMod, "");
|
|||
|
}
|
|||
|
} catch (err) {
|
|||
|
let errorMessage = "";
|
|||
|
if (err instanceof YoutubeTranscriptError) {
|
|||
|
errorMessage = err.message;
|
|||
|
}
|
|||
|
(_a = this.loaderContainerEl) == null ? void 0 : _a.empty();
|
|||
|
if (this.errorContainerEl === void 0) {
|
|||
|
this.errorContainerEl = this.contentEl.createEl("h5");
|
|||
|
} else {
|
|||
|
this.errorContainerEl.empty();
|
|||
|
}
|
|||
|
const titleEl = this.errorContainerEl.createEl("div", {
|
|||
|
text: "Error loading transcript"
|
|||
|
});
|
|||
|
titleEl.style.marginBottom = "5px";
|
|||
|
const messageEl = this.errorContainerEl.createEl("div", {
|
|||
|
text: errorMessage
|
|||
|
});
|
|||
|
messageEl.style.color = "var(--text-muted)";
|
|||
|
messageEl.style.fontSize = "var(--font-ui-small)";
|
|||
|
}
|
|||
|
}
|
|||
|
getViewType() {
|
|||
|
return TRANSCRIPT_TYPE_VIEW;
|
|||
|
}
|
|||
|
getDisplayText() {
|
|||
|
return "YouTube Transcript";
|
|||
|
}
|
|||
|
getIcon() {
|
|||
|
return "scroll";
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// src/prompt-modal.ts
|
|||
|
var import_obsidian3 = require("obsidian");
|
|||
|
var PromptModal = class extends import_obsidian3.Modal {
|
|||
|
constructor() {
|
|||
|
super(app);
|
|||
|
this.submitted = false;
|
|||
|
}
|
|||
|
listenInput(evt) {
|
|||
|
if (evt.key === "Enter") {
|
|||
|
evt.preventDefault();
|
|||
|
this.enterCallback(evt);
|
|||
|
}
|
|||
|
}
|
|||
|
onOpen() {
|
|||
|
this.titleEl.setText("YouTube URL");
|
|||
|
this.createForm();
|
|||
|
}
|
|||
|
onClose() {
|
|||
|
this.contentEl.empty();
|
|||
|
if (!this.submitted) {
|
|||
|
this.reject();
|
|||
|
}
|
|||
|
}
|
|||
|
createForm() {
|
|||
|
const textInput = new import_obsidian3.TextComponent(this.contentEl);
|
|||
|
textInput.inputEl.style.width = "100%";
|
|||
|
textInput.onChange((value) => this.value = value);
|
|||
|
textInput.inputEl.addEventListener("keydown", (evt) => this.enterCallback(evt));
|
|||
|
textInput.inputEl.focus();
|
|||
|
const buttonDiv = this.modalEl.createDiv();
|
|||
|
buttonDiv.addClass("modal-button-container");
|
|||
|
const submitButton = new import_obsidian3.ButtonComponent(buttonDiv);
|
|||
|
submitButton.buttonEl.addClass("mod-cta");
|
|||
|
submitButton.setButtonText("Submit").onClick((evt) => {
|
|||
|
this.resolveAndClose(evt);
|
|||
|
});
|
|||
|
}
|
|||
|
enterCallback(evt) {
|
|||
|
if (evt.key === "Enter") {
|
|||
|
this.resolveAndClose(evt);
|
|||
|
}
|
|||
|
}
|
|||
|
resolveAndClose(evt) {
|
|||
|
this.submitted = true;
|
|||
|
evt.preventDefault();
|
|||
|
this.resolve(this.value);
|
|||
|
this.close();
|
|||
|
}
|
|||
|
async openAndGetValue(resolve, reject) {
|
|||
|
this.resolve = resolve;
|
|||
|
this.reject = reject;
|
|||
|
this.open();
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// src/url-utils.ts
|
|||
|
var UrlPattern = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi;
|
|||
|
function _getLinkNearestCursor(textLine, cursorPosition, linksInLine) {
|
|||
|
if (cursorPosition > textLine.length)
|
|||
|
throw new Error("Cursor out of the line");
|
|||
|
if (!linksInLine || linksInLine.length < 1)
|
|||
|
throw new Error("No links found");
|
|||
|
for (let i = 0; i < linksInLine.length; i++) {
|
|||
|
const link = linksInLine[i];
|
|||
|
const index = linksInLine.length > i + 1 ? textLine.indexOf(linksInLine[i + 1]) : textLine.length;
|
|||
|
if (cursorPosition <= index)
|
|||
|
return link;
|
|||
|
}
|
|||
|
throw new Error("Unexpected");
|
|||
|
}
|
|||
|
function getUrlFromText(lineText, cursorPosition) {
|
|||
|
var _a;
|
|||
|
const url = _getLinkNearestCursor(lineText, cursorPosition, (_a = lineText.match(UrlPattern)) != null ? _a : []);
|
|||
|
return [lineText.indexOf(url), lineText.indexOf(url) + url.length];
|
|||
|
}
|
|||
|
|
|||
|
// editor-extensions.ts
|
|||
|
var EditorExtensions = class {
|
|||
|
static getSelectedText(editor) {
|
|||
|
if (!editor.somethingSelected()) {
|
|||
|
const wordBoundaries = this.getWordBoundaries(editor);
|
|||
|
editor.setSelection(wordBoundaries[0], wordBoundaries[1]);
|
|||
|
}
|
|||
|
return editor.getSelection();
|
|||
|
}
|
|||
|
static getWordBoundaries(editor) {
|
|||
|
const cursor = editor.getCursor();
|
|||
|
const lineText = editor.getLine(cursor.line);
|
|||
|
const urlPosition = getUrlFromText(lineText, cursor.ch);
|
|||
|
return [
|
|||
|
{ line: cursor.line, ch: urlPosition[0] },
|
|||
|
{ line: cursor.line, ch: urlPosition[1] }
|
|||
|
];
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// src/main.ts
|
|||
|
var DEFAULT_SETTINGS = {
|
|||
|
timestampMod: 5,
|
|||
|
lang: "en",
|
|||
|
country: "EN",
|
|||
|
leafUrls: []
|
|||
|
};
|
|||
|
var YTranscriptPlugin = class extends import_obsidian4.Plugin {
|
|||
|
async onload() {
|
|||
|
await this.loadSettings();
|
|||
|
this.registerView(TRANSCRIPT_TYPE_VIEW, (leaf) => new TranscriptView(leaf, this));
|
|||
|
this.addCommand({
|
|||
|
id: "transcript-from-text",
|
|||
|
name: "Get YouTube transcript from selected url",
|
|||
|
editorCallback: (editor, _) => {
|
|||
|
const url = EditorExtensions.getSelectedText(editor).trim();
|
|||
|
this.openView(url);
|
|||
|
}
|
|||
|
});
|
|||
|
this.addCommand({
|
|||
|
id: "transcript-from-prompt",
|
|||
|
name: "Get YouTube transcript from url prompt",
|
|||
|
callback: async () => {
|
|||
|
const prompt = new PromptModal();
|
|||
|
const url = await new Promise((resolve) => prompt.openAndGetValue(resolve, () => {
|
|||
|
}));
|
|||
|
if (url) {
|
|||
|
this.openView(url);
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
this.addSettingTab(new YTranslateSettingTab(this.app, this));
|
|||
|
}
|
|||
|
async openView(url) {
|
|||
|
const leaf = this.app.workspace.getRightLeaf(false);
|
|||
|
await leaf.setViewState({
|
|||
|
type: TRANSCRIPT_TYPE_VIEW
|
|||
|
});
|
|||
|
this.app.workspace.revealLeaf(leaf);
|
|||
|
leaf.setEphemeralState({
|
|||
|
url
|
|||
|
});
|
|||
|
}
|
|||
|
onunload() {
|
|||
|
this.app.workspace.detachLeavesOfType(TRANSCRIPT_TYPE_VIEW);
|
|||
|
}
|
|||
|
async loadSettings() {
|
|||
|
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
|||
|
}
|
|||
|
async saveSettings() {
|
|||
|
await this.saveData(this.settings);
|
|||
|
}
|
|||
|
};
|
|||
|
var YTranslateSettingTab = class extends import_obsidian4.PluginSettingTab {
|
|||
|
constructor(app2, plugin) {
|
|||
|
super(app2, plugin);
|
|||
|
this.plugin = plugin;
|
|||
|
}
|
|||
|
display() {
|
|||
|
const { containerEl } = this;
|
|||
|
containerEl.empty();
|
|||
|
containerEl.createEl("h2", { text: "Settings for YTranscript" });
|
|||
|
new import_obsidian4.Setting(containerEl).setName("Timestamp interval").setDesc("Indicates how often timestamp should occur in text (1 - every line, 10 - every 10 lines)").addText((text) => text.setValue(this.plugin.settings.timestampMod.toFixed()).onChange(async (value) => {
|
|||
|
const v = Number.parseInt(value);
|
|||
|
this.plugin.settings.timestampMod = Number.isNaN(v) ? 5 : v;
|
|||
|
await this.plugin.saveSettings();
|
|||
|
}));
|
|||
|
new import_obsidian4.Setting(containerEl).setName("Language").setDesc("Preferred transcript language").addText((text) => text.setValue(this.plugin.settings.lang).onChange(async (value) => {
|
|||
|
this.plugin.settings.lang = value;
|
|||
|
await this.plugin.saveSettings();
|
|||
|
}));
|
|||
|
new import_obsidian4.Setting(containerEl).setName("Country").setDesc("Preferred transcript country code").addText((text) => text.setValue(this.plugin.settings.country).onChange(async (value) => {
|
|||
|
this.plugin.settings.country = value;
|
|||
|
await this.plugin.saveSettings();
|
|||
|
}));
|
|||
|
}
|
|||
|
};
|
|||
|
/*! https://mths.be/he v1.2.0 by @mathias | MIT license */
|