|
"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.js"); |
|
var encode_js_1 = require("./encode.js"); |
|
var escape_js_1 = require("./escape.js"); |
|
|
|
var EntityLevel; |
|
(function (EntityLevel) { |
|
|
|
EntityLevel[EntityLevel["XML"] = 0] = "XML"; |
|
|
|
EntityLevel[EntityLevel["HTML"] = 1] = "HTML"; |
|
})(EntityLevel = exports.EntityLevel || (exports.EntityLevel = {})); |
|
var EncodingMode; |
|
(function (EncodingMode) { |
|
|
|
|
|
|
|
|
|
EncodingMode[EncodingMode["UTF8"] = 0] = "UTF8"; |
|
|
|
|
|
|
|
|
|
|
|
EncodingMode[EncodingMode["ASCII"] = 1] = "ASCII"; |
|
|
|
|
|
|
|
|
|
EncodingMode[EncodingMode["Extensive"] = 2] = "Extensive"; |
|
|
|
|
|
|
|
|
|
EncodingMode[EncodingMode["Attribute"] = 3] = "Attribute"; |
|
|
|
|
|
|
|
|
|
EncodingMode[EncodingMode["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 : undefined; |
|
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.js"); |
|
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.js"); |
|
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.js"); |
|
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; } }); |
|
|