You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
24 KiB
1 line
24 KiB
2 years ago
|
{"ast":null,"code":"\"use strict\";\n\nvar __assign = this && this.__assign || function () {\n __assign = Object.assign || function (t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n\n return t;\n };\n\n return __assign.apply(this, arguments);\n};\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar named_references_1 = require(\"./named-references\");\n\nvar numeric_unicode_map_1 = require(\"./numeric-unicode-map\");\n\nvar surrogate_pairs_1 = require(\"./surrogate-pairs\");\n\nvar allNamedReferences = __assign(__assign({}, named_references_1.namedReferences), {\n all: named_references_1.namedReferences.html5\n});\n\nvar encodeRegExps = {\n specialChars: /[<>'\"&]/g,\n nonAscii: /(?:[<>'\"&\\u0080-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/g,\n nonAsciiPrintable: /(?:[<>'\"&\\x01-\\x08\\x11-\\x15\\x17-\\x1F\\x7f-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/g,\n extensive: /(?:[\\x01-\\x0c\\x0e-\\x1f\\x21-\\x2c\\x2e-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7d\\x7f-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/g\n};\nvar defaultEncodeOptions = {\n mode: 'specialChars',\n level: 'all',\n numeric: 'decimal'\n};\n/** Encodes all the necessary (specified by `level`) characters in the text */\n\nfunction encode(text, _a) {\n var _b = _a === void 0 ? defaultEncodeOptions : _a,\n _c = _b.mode,\n mode = _c === void 0 ? 'specialChars' : _c,\n _d = _b.numeric,\n numeric = _d === void 0 ? 'decimal' : _d,\n _e = _b.level,\n level = _e === void 0 ? 'all' : _e;\n\n if (!text) {\n return '';\n }\n\n var encodeRegExp = encodeRegExps[mode];\n var references = allNamedReferences[level].characters;\n var isHex = numeric === 'hexadecimal';\n encodeRegExp.lastIndex = 0;\n\n var _b = encodeRegExp.exec(text);\n\n var _c;\n\n if (_b) {\n _c = '';\n var _d = 0;\n\n do {\n if (_d !== _b.index) {\n _c += text.substring(_d, _b.index);\n }\n\n var _e = _b[0];\n var result_1 = references[_e];\n\n if (!result_1) {\n var code_1 = _e.length > 1 ? surrogate_pairs_1.getCodePoint(_e, 0) : _e.charCodeAt(0);\n result_1 = (isHex ? '&#x' + code_1.toString(16) : '&#' + code_1) + ';';\n }\n\n _c += result_1;\n _d = _b.index + _e.length;\n } while (_b = encodeRegExp.exec(text));\n\n if (_d !== text.length) {\n _c += text.substring(_d);\n }\n } else {\n _c = text;\n }\n\n return _c;\n}\n\nexports.encode = encode;\nvar defaultDecodeOptions = {\n scope: 'body',\n level: 'all'\n};\nvar strict = /&(?:#\\d+|#[xX][\\da-fA-F]+|[0-9a-zA-Z]+);/g;\nvar attribute = /&(?:#\\d+|#[xX][\\da-fA-F]+|[0-9a-zA-Z]+)[;=]?/g;\nvar baseDecodeRegExps = {\n xml: {\n strict: strict,\n attribute: attribute,\n body: named_references_1.bodyRegExps.xml\n },\n html4: {\n strict: strict,\n attribute: attribute,\n body: named_references_1.bodyRegExps.html4\n },\n html5: {\n strict: strict,\n attribute: attribute,\n body: named_references_1.bodyRegExps.html5\n }\n};\n\nvar decodeRegExps = __assign(__assign({}, baseDecodeRegExps), {\n all: baseDecodeRegExps.html5\n});\n\nvar fromCharCode = String.fromCharCode;\nvar outOfBoundsChar = fromCharCode(65533);\nvar defaultDecodeEntityOptions = {\n level: 'all'\n};\n/** Decodes a single entity */\n\nfunction decodeEntity(entity, _a) {\n var _b = (_a === void 0 ? defaultDecodeEntityOptions : _a).level,\n level = _b === void 0 ? 'all' : _b;\n\n if (!entity) {\n return '';\n }\n\n var _b = entity;\n var decodeEntityLastChar_1 = entity[entity.length - 1];\n\n if (false && decodeEntityLastChar_1 === '=') {\n _b = entity;\n }
|