Node-Red configuration
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

index.js 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. 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;
  4. var decode_js_1 = require("./decode.js");
  5. var encode_js_1 = require("./encode.js");
  6. var escape_js_1 = require("./escape.js");
  7. /** The level of entities to support. */
  8. var EntityLevel;
  9. (function (EntityLevel) {
  10. /** Support only XML entities. */
  11. EntityLevel[EntityLevel["XML"] = 0] = "XML";
  12. /** Support HTML entities, which are a superset of XML entities. */
  13. EntityLevel[EntityLevel["HTML"] = 1] = "HTML";
  14. })(EntityLevel = exports.EntityLevel || (exports.EntityLevel = {}));
  15. var EncodingMode;
  16. (function (EncodingMode) {
  17. /**
  18. * The output is UTF-8 encoded. Only characters that need escaping within
  19. * XML will be escaped.
  20. */
  21. EncodingMode[EncodingMode["UTF8"] = 0] = "UTF8";
  22. /**
  23. * The output consists only of ASCII characters. Characters that need
  24. * escaping within HTML, and characters that aren't ASCII characters will
  25. * be escaped.
  26. */
  27. EncodingMode[EncodingMode["ASCII"] = 1] = "ASCII";
  28. /**
  29. * Encode all characters that have an equivalent entity, as well as all
  30. * characters that are not ASCII characters.
  31. */
  32. EncodingMode[EncodingMode["Extensive"] = 2] = "Extensive";
  33. /**
  34. * Encode all characters that have to be escaped in HTML attributes,
  35. * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
  36. */
  37. EncodingMode[EncodingMode["Attribute"] = 3] = "Attribute";
  38. /**
  39. * Encode all characters that have to be escaped in HTML text,
  40. * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
  41. */
  42. EncodingMode[EncodingMode["Text"] = 4] = "Text";
  43. })(EncodingMode = exports.EncodingMode || (exports.EncodingMode = {}));
  44. /**
  45. * Decodes a string with entities.
  46. *
  47. * @param data String to decode.
  48. * @param options Decoding options.
  49. */
  50. function decode(data, options) {
  51. if (options === void 0) { options = EntityLevel.XML; }
  52. var level = typeof options === "number" ? options : options.level;
  53. if (level === EntityLevel.HTML) {
  54. var mode = typeof options === "object" ? options.mode : undefined;
  55. return (0, decode_js_1.decodeHTML)(data, mode);
  56. }
  57. return (0, decode_js_1.decodeXML)(data);
  58. }
  59. exports.decode = decode;
  60. /**
  61. * Decodes a string with entities. Does not allow missing trailing semicolons for entities.
  62. *
  63. * @param data String to decode.
  64. * @param options Decoding options.
  65. * @deprecated Use `decode` with the `mode` set to `Strict`.
  66. */
  67. function decodeStrict(data, options) {
  68. var _a;
  69. if (options === void 0) { options = EntityLevel.XML; }
  70. var opts = typeof options === "number" ? { level: options } : options;
  71. (_a = opts.mode) !== null && _a !== void 0 ? _a : (opts.mode = decode_js_1.DecodingMode.Strict);
  72. return decode(data, opts);
  73. }
  74. exports.decodeStrict = decodeStrict;
  75. /**
  76. * Encodes a string with entities.
  77. *
  78. * @param data String to encode.
  79. * @param options Encoding options.
  80. */
  81. function encode(data, options) {
  82. if (options === void 0) { options = EntityLevel.XML; }
  83. var opts = typeof options === "number" ? { level: options } : options;
  84. // Mode `UTF8` just escapes XML entities
  85. if (opts.mode === EncodingMode.UTF8)
  86. return (0, escape_js_1.escapeUTF8)(data);
  87. if (opts.mode === EncodingMode.Attribute)
  88. return (0, escape_js_1.escapeAttribute)(data);
  89. if (opts.mode === EncodingMode.Text)
  90. return (0, escape_js_1.escapeText)(data);
  91. if (opts.level === EntityLevel.HTML) {
  92. if (opts.mode === EncodingMode.ASCII) {
  93. return (0, encode_js_1.encodeNonAsciiHTML)(data);
  94. }
  95. return (0, encode_js_1.encodeHTML)(data);
  96. }
  97. // ASCII and Extensive are equivalent
  98. return (0, escape_js_1.encodeXML)(data);
  99. }
  100. exports.encode = encode;
  101. var escape_js_2 = require("./escape.js");
  102. Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function () { return escape_js_2.encodeXML; } });
  103. Object.defineProperty(exports, "escape", { enumerable: true, get: function () { return escape_js_2.escape; } });
  104. Object.defineProperty(exports, "escapeUTF8", { enumerable: true, get: function () { return escape_js_2.escapeUTF8; } });
  105. Object.defineProperty(exports, "escapeAttribute", { enumerable: true, get: function () { return escape_js_2.escapeAttribute; } });
  106. Object.defineProperty(exports, "escapeText", { enumerable: true, get: function () { return escape_js_2.escapeText; } });
  107. var encode_js_2 = require("./encode.js");
  108. Object.defineProperty(exports, "encodeHTML", { enumerable: true, get: function () { return encode_js_2.encodeHTML; } });
  109. Object.defineProperty(exports, "encodeNonAsciiHTML", { enumerable: true, get: function () { return encode_js_2.encodeNonAsciiHTML; } });
  110. // Legacy aliases (deprecated)
  111. Object.defineProperty(exports, "encodeHTML4", { enumerable: true, get: function () { return encode_js_2.encodeHTML; } });
  112. Object.defineProperty(exports, "encodeHTML5", { enumerable: true, get: function () { return encode_js_2.encodeHTML; } });
  113. var decode_js_2 = require("./decode.js");
  114. Object.defineProperty(exports, "EntityDecoder", { enumerable: true, get: function () { return decode_js_2.EntityDecoder; } });
  115. Object.defineProperty(exports, "DecodingMode", { enumerable: true, get: function () { return decode_js_2.DecodingMode; } });
  116. Object.defineProperty(exports, "decodeXML", { enumerable: true, get: function () { return decode_js_2.decodeXML; } });
  117. Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function () { return decode_js_2.decodeHTML; } });
  118. Object.defineProperty(exports, "decodeHTMLStrict", { enumerable: true, get: function () { return decode_js_2.decodeHTMLStrict; } });
  119. Object.defineProperty(exports, "decodeHTMLAttribute", { enumerable: true, get: function () { return decode_js_2.decodeHTMLAttribute; } });
  120. // Legacy aliases (deprecated)
  121. Object.defineProperty(exports, "decodeHTML4", { enumerable: true, get: function () { return decode_js_2.decodeHTML; } });
  122. Object.defineProperty(exports, "decodeHTML5", { enumerable: true, get: function () { return decode_js_2.decodeHTML; } });
  123. Object.defineProperty(exports, "decodeHTML4Strict", { enumerable: true, get: function () { return decode_js_2.decodeHTMLStrict; } });
  124. Object.defineProperty(exports, "decodeHTML5Strict", { enumerable: true, get: function () { return decode_js_2.decodeHTMLStrict; } });
  125. Object.defineProperty(exports, "decodeXMLStrict", { enumerable: true, get: function () { return decode_js_2.decodeXML; } });
  126. //# sourceMappingURL=index.js.map