a88ca2eece24a832fed55225612650dd86f3f5667db905f939e6e8f88e0ffedc.json 11 KB

1
  1. {"ast":null,"code":"export const xmlReplacer = /[\"&'<>$\\x80-\\uFFFF]/g;\nconst xmlCodeMap = new Map([[34, \"&quot;\"], [38, \"&amp;\"], [39, \"&apos;\"], [60, \"&lt;\"], [62, \"&gt;\"]]);\n// For compatibility with node < 4, we wrap `codePointAt`\nexport const getCodePoint =\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nString.prototype.codePointAt != null ? (str, index) => str.codePointAt(index) :\n// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\n(c, index) => (c.charCodeAt(index) & 0xfc00) === 0xd800 ? (c.charCodeAt(index) - 0xd800) * 0x400 + c.charCodeAt(index + 1) - 0xdc00 + 0x10000 : c.charCodeAt(index);\n/**\n * Encodes all non-ASCII characters, as well as characters not valid in XML\n * documents using XML entities.\n *\n * If a character has no equivalent entity, a\n * numeric hexadecimal reference (eg. `&#xfc;`) will be used.\n */\nexport function encodeXML(str) {\n let ret = \"\";\n let lastIdx = 0;\n let match;\n while ((match = xmlReplacer.exec(str)) !== null) {\n const i = match.index;\n const char = str.charCodeAt(i);\n const next = xmlCodeMap.get(char);\n if (next !== undefined) {\n ret += str.substring(lastIdx, i) + next;\n lastIdx = i + 1;\n } else {\n ret += `${str.substring(lastIdx, i)}&#x${getCodePoint(str, i).toString(16)};`;\n // Increase by 1 if we have a surrogate pair\n lastIdx = xmlReplacer.lastIndex += Number((char & 0xfc00) === 0xd800);\n }\n }\n return ret + str.substr(lastIdx);\n}\n/**\n * Encodes all non-ASCII characters, as well as characters not valid in XML\n * documents using numeric hexadecimal reference (eg. `&#xfc;`).\n *\n * Have a look at `escapeUTF8` if you want a more concise output at the expense\n * of reduced transportability.\n *\n * @param data String to escape.\n */\nexport const escape = encodeXML;\n/**\n * Creates a function that escapes all characters matched by the given regular\n * expression using the given map of characters to escape to their entities.\n *\n * @param regex Regular expression to match characters to escape.\n * @param map Map of characters to escape to their entities.\n *\n * @returns Function that escapes all characters matched by the given regular\n * expression using the given map of characters to escape to their entities.\n */\nfunction getEscaper(regex, map) {\n return function escape(data) {\n let match;\n let lastIdx = 0;\n let result = \"\";\n while (match = regex.exec(data)) {\n if (lastIdx !== match.index) {\n result += data.substring(lastIdx, match.index);\n }\n // We know that this character will be in the map.\n result += map.get(match[0].charCodeAt(0));\n // Every match will be of length 1\n lastIdx = match.index + 1;\n }\n return result + data.substring(lastIdx);\n };\n}\n/**\n * Encodes all characters not valid in XML documents using XML entities.\n *\n * Note that the output will be character-set dependent.\n *\n * @param data String to escape.\n */\nexport const escapeUTF8 = getEscaper(/[&<>'\"]/g, xmlCodeMap);\n/**\n * Encodes all characters that have to be escaped in HTML attributes,\n * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.\n *\n * @param data String to escape.\n */\nexport const escapeAttribute = getEscaper(/[\"&\\u00A0]/g, new Map([[34, \"&quot;\"], [38, \"&amp;\"], [160, \"&nbsp;\"]]));\n/**\n * Encodes all characters that have to be escaped in HTML text,\n * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.\n *\n * @param data String to escape.\n */\nexport const escapeText = getEscaper(/[&<>\\u00A0]/g, new Map([[38, \"&amp;\"], [60, \"&lt;\"], [62, \"&gt;\"], [160, \"&nbsp;\"]]));","map":{"version":3,"names":["xmlReplacer","xmlCodeMap","Map","getCodePoint","String","prototype","codePointAt","str","index","c","charCodeAt","encodeXML","ret","lastIdx","match","exec","i","char","next","get","undefined","substring","toString","lastIndex","Number","substr","escape","getEscaper","regex","map","data","result","escapeUTF8","escapeAttribute","escapeText"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/entities/lib/esm/escape.js"],"sourcesContent":["export const xmlReplacer = /[\"&'<>$\\x80-\\uFFFF]/g;\nconst xmlCodeMap = new Map([\n [34, \"&quot;\"],\n [38, \"&amp;\"],\n [39, \"&apos;\"],\n [60, \"&lt;\"],\n [62, \"&gt;\"],\n]);\n// For compatibility with node < 4, we wrap `codePointAt`\nexport const getCodePoint = \n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nString.prototype.codePointAt != null\n ? (str, index) => str.codePointAt(index)\n : // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\n (c, index) => (c.charCodeAt(index) & 0xfc00) === 0xd800\n ? (c.charCodeAt(index) - 0xd800) * 0x400 +\n c.charCodeAt(index + 1) -\n 0xdc00 +\n 0x10000\n : c.charCodeAt(index);\n/**\n * Encodes all non-ASCII characters, as well as characters not valid in XML\n * documents using XML entities.\n *\n * If a character has no equivalent entity, a\n * numeric hexadecimal reference (eg. `&#xfc;`) will be used.\n */\nexport function encodeXML(str) {\n let ret = \"\";\n let lastIdx = 0;\n let match;\n while ((match = xmlReplacer.exec(str)) !== null) {\n const i = match.index;\n const char = str.charCodeAt(i);\n const next = xmlCodeMap.get(char);\n if (next !== undefined) {\n ret += str.substring(lastIdx, i) + next;\n lastIdx = i + 1;\n }\n else {\n ret += `${str.substring(lastIdx, i)}&#x${getCodePoint(str, i).toString(16)};`;\n // Increase by 1 if we have a surrogate pair\n lastIdx = xmlReplacer.lastIndex += Number((char & 0xfc00) === 0xd800);\n }\n }\n return ret + str.substr(lastIdx);\n}\n/**\n * Encodes all non-ASCII characters, as well as characters not valid in XML\n * documents using numeric hexadecimal reference (eg. `&#xfc;`).\n *\n * Have a look at `escapeUTF8` if you want a more concise output at the expense\n * of reduced transportability.\n *\n * @param data String to escape.\n */\nexport const escape = encodeXML;\n/**\n * Creates a function that escapes all characters matched by the given regular\n * expression using the given map of characters to escape to their entities.\n *\n * @param regex Regular expression to match characters to escape.\n * @param map Map of characters to escape to their entities.\n *\n * @returns Function that escapes all characters matched by the given regular\n * expression using the given map of characters to escape to their entities.\n */\nfunction getEscaper(regex, map) {\n return function escape(data) {\n let match;\n let lastIdx = 0;\n let result = \"\";\n while ((match = regex.exec(data))) {\n if (lastIdx !== match.index) {\n result += data.substring(lastIdx, match.index);\n }\n // We know that this character will be in the map.\n result += map.get(match[0].charCodeAt(0));\n // Every match will be of length 1\n lastIdx = match.index + 1;\n }\n return result + data.substring(lastIdx);\n };\n}\n/**\n * Encodes all characters not valid in XML documents using XML entities.\n *\n * Note that the output will be character-set dependent.\n *\n * @param data String to escape.\n */\nexport const escapeUTF8 = getEscaper(/[&<>'\"]/g, xmlCodeMap);\n/**\n * Encodes all characters that have to be escaped in HTML attributes,\n * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.\n *\n * @param data String to escape.\n */\nexport const escapeAttribute = getEscaper(/[\"&\\u00A0]/g, new Map([\n [34, \"&quot;\"],\n [38, \"&amp;\"],\n [160, \"&nbsp;\"],\n]));\n/**\n * Encodes all characters that have to be escaped in HTML text,\n * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.\n *\n * @param data String to escape.\n */\nexport const escapeText = getEscaper(/[&<>\\u00A0]/g, new Map([\n [38, \"&amp;\"],\n [60, \"&lt;\"],\n [62, \"&gt;\"],\n [160, \"&nbsp;\"],\n]));\n"],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG,sBAAsB;AACjD,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAC,CACvB,CAAC,EAAE,EAAE,QAAQ,CAAC,EACd,CAAC,EAAE,EAAE,OAAO,CAAC,EACb,CAAC,EAAE,EAAE,QAAQ,CAAC,EACd,CAAC,EAAE,EAAE,MAAM,CAAC,EACZ,CAAC,EAAE,EAAE,MAAM,CAAC,CACf,CAAC;AACF;AACA,OAAO,MAAMC,YAAY;AACzB;AACAC,MAAM,CAACC,SAAS,CAACC,WAAW,IAAI,IAAI,GAC9B,CAACC,GAAG,EAAEC,KAAK,KAAKD,GAAG,CAACD,WAAW,CAACE,KAAK,CAAC;AACtC;AACE,CAACC,CAAC,EAAED,KAAK,KAAK,CAACC,CAAC,CAACC,UAAU,CAACF,KAAK,CAAC,GAAG,MAAM,MAAM,MAAM,GACjD,CAACC,CAAC,CAACC,UAAU,CAACF,KAA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