web 3d图形渲染器
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.

167 lines
49 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var surrogate_pairs_1 = require("./surrogate-pairs");
  4. var ENTITIES = [['Aacute', [193]], ['aacute', [225]], ['Abreve', [258]], ['abreve', [259]], ['ac', [8766]], ['acd', [8767]], ['acE', [8766, 819]], ['Acirc', [194]], ['acirc', [226]], ['acute', [180]], ['Acy', [1040]], ['acy', [1072]], ['AElig', [198]], ['aelig', [230]], ['af', [8289]], ['Afr', [120068]], ['afr', [120094]], ['Agrave', [192]], ['agrave', [224]], ['alefsym', [8501]], ['aleph', [8501]], ['Alpha', [913]], ['alpha', [945]], ['Amacr', [256]], ['amacr', [257]], ['amalg', [10815]], ['amp', [38]], ['AMP', [38]], ['andand', [10837]], ['And', [10835]], ['and', [8743]], ['andd', [10844]], ['andslope', [10840]], ['andv', [10842]], ['ang', [8736]], ['ange', [10660]], ['angle', [8736]], ['angmsdaa', [10664]], ['angmsdab', [10665]], ['angmsdac', [10666]], ['angmsdad', [10667]], ['angmsdae', [10668]], ['angmsdaf', [10669]], ['angmsdag', [10670]], ['angmsdah', [10671]], ['angmsd', [8737]], ['angrt', [8735]], ['angrtvb', [8894]], ['angrtvbd', [10653]], ['angsph', [8738]], ['angst', [197]], ['angzarr', [9084]], ['Aogon', [260]], ['aogon', [261]], ['Aopf', [120120]], ['aopf', [120146]], ['apacir', [10863]], ['ap', [8776]], ['apE', [10864]], ['ape', [8778]], ['apid', [8779]], ['apos', [39]], ['ApplyFunction', [8289]], ['approx', [8776]], ['approxeq', [8778]], ['Aring', [197]], ['aring', [229]], ['Ascr', [119964]], ['ascr', [119990]], ['Assign', [8788]], ['ast', [42]], ['asymp', [8776]], ['asympeq', [8781]], ['Atilde', [195]], ['atilde', [227]], ['Auml', [196]], ['auml', [228]], ['awconint', [8755]], ['awint', [10769]], ['backcong', [8780]], ['backepsilon', [1014]], ['backprime', [8245]], ['backsim', [8765]], ['backsimeq', [8909]], ['Backslash', [8726]], ['Barv', [10983]], ['barvee', [8893]], ['barwed', [8965]], ['Barwed', [8966]], ['barwedge', [8965]], ['bbrk', [9141]], ['bbrktbrk', [9142]], ['bcong', [8780]], ['Bcy', [1041]], ['bcy', [1073]], ['bdquo', [8222]], ['becaus', [8757]], ['because', [8757]], ['Because', [8757]], ['bemptyv', [10672]], ['bepsi', [1014]], ['bernou', [8492]], ['Bernoullis', [8492]], ['Beta', [914]], ['beta', [946]], ['beth', [8502]], ['between', [8812]], ['Bfr', [120069]], ['bfr', [120095]], ['bigcap', [8898]], ['bigcirc', [9711]], ['bigcup', [8899]], ['bigodot', [10752]], ['bigoplus', [10753]], ['bigotimes', [10754]], ['bigsqcup', [10758]], ['bigstar', [9733]], ['bigtriangledown', [9661]], ['bigtriangleup', [9651]], ['biguplus', [10756]], ['bigvee', [8897]], ['bigwedge', [8896]], ['bkarow', [10509]], ['blacklozenge', [10731]], ['blacksquare', [9642]], ['blacktriangle', [9652]], ['blacktriangledown', [9662]], ['blacktriangleleft', [9666]], ['blacktriangleright', [9656]], ['blank', [9251]], ['blk12', [9618]], ['blk14', [9617]], ['blk34', [9619]], ['block', [9608]], ['bne', [61, 8421]], ['bnequiv', [8801, 8421]], ['bNot', [10989]], ['bnot', [8976]], ['Bopf', [120121]], ['bopf', [120147]], ['bot', [8869]], ['bottom', [8869]], ['bowtie', [8904]], ['boxbox', [10697]], ['boxdl', [9488]], ['boxdL', [9557]], ['boxDl', [9558]], ['boxDL', [9559]], ['boxdr', [9484]], ['boxdR', [9554]], ['boxDr', [9555]], ['boxDR', [9556]], ['boxh', [9472]], ['boxH', [9552]], ['boxhd', [9516]], ['boxHd', [9572]], ['boxhD', [9573]], ['boxHD', [9574]], ['boxhu', [9524]], ['boxHu', [9575]], ['boxhU', [9576]], ['boxHU', [9577]], ['boxminus', [8863]], ['boxplus', [8862]], ['boxtimes', [8864]], ['boxul', [9496]], ['boxuL', [9563]], ['boxUl', [9564]], ['boxUL', [9565]], ['boxur', [9492]], ['boxuR', [9560]], ['boxUr', [9561]], ['boxUR', [9562]], ['boxv', [9474]], ['boxV', [9553]], ['boxvh', [9532]], ['boxvH', [9578]], ['boxVh', [9579]], ['boxVH', [9580]], ['boxvl', [9508]], ['boxvL', [9569]], ['boxVl', [9570]], ['boxVL', [9571]], ['boxvr', [9500]], ['boxvR', [9566]], ['boxVr', [9567]], ['boxVR', [9568]], ['bprime', [8245]], ['breve', [728]], ['Breve', [728]], ['brvbar', [166]], ['bscr', [119991]], ['Bscr', [8492]], ['bsemi', [8271]], ['bsim', [8765]], ['bsime', [8909]], ['bsolb', [10693]], ['bsol', [92]], ['bsolhsub', [10184]], ['bull', [8226]], ['bullet', [8226]], ['bump', [8782]], ['bumpE', [10926]], ['bumpe', [8783]], ['Bumpeq', [8782]
  5. var DECODE_ONLY_ENTITIES = [['NewLine', [10]]];
  6. var alphaIndex = {};
  7. var charIndex = {};
  8. createIndexes(alphaIndex, charIndex);
  9. var Html5Entities = /** @class */ (function () {
  10. function Html5Entities() {
  11. }
  12. Html5Entities.prototype.decode = function (str) {
  13. if (!str || !str.length) {
  14. return '';
  15. }
  16. return str.replace(/&(#?[\w\d]+);?/g, function (s, entity) {
  17. var chr;
  18. if (entity.charAt(0) === "#") {
  19. var code = entity.charAt(1) === 'x' ?
  20. parseInt(entity.substr(2).toLowerCase(), 16) :
  21. parseInt(entity.substr(1));
  22. if (!isNaN(code) || code >= -32768) {
  23. if (code <= 65535) {
  24. chr = String.fromCharCode(code);
  25. }
  26. else {
  27. chr = surrogate_pairs_1.fromCodePoint(code);
  28. }
  29. }
  30. }
  31. else {
  32. chr = alphaIndex[entity];
  33. }
  34. return chr || s;
  35. });
  36. };
  37. Html5Entities.decode = function (str) {
  38. return new Html5Entities().decode(str);
  39. };
  40. Html5Entities.prototype.encode = function (str) {
  41. if (!str || !str.length) {
  42. return '';
  43. }
  44. var strLength = str.length;
  45. var result = '';
  46. var i = 0;
  47. while (i < strLength) {
  48. var charInfo = charIndex[str.charCodeAt(i)];
  49. if (charInfo) {
  50. var alpha = charInfo[str.charCodeAt(i + 1)];
  51. if (alpha) {
  52. i++;
  53. }
  54. else {
  55. alpha = charInfo[''];
  56. }
  57. if (alpha) {
  58. result += "&" + alpha + ";";
  59. i++;
  60. continue;
  61. }
  62. }
  63. result += str.charAt(i);
  64. i++;
  65. }
  66. return result;
  67. };
  68. Html5Entities.encode = function (str) {
  69. return new Html5Entities().encode(str);
  70. };
  71. Html5Entities.prototype.encodeNonUTF = function (str) {
  72. if (!str || !str.length) {
  73. return '';
  74. }
  75. var strLength = str.length;
  76. var result = '';
  77. var i = 0;
  78. while (i < strLength) {
  79. var c = str.charCodeAt(i);
  80. var charInfo = charIndex[c];
  81. if (charInfo) {
  82. var alpha = charInfo[str.charCodeAt(i + 1)];
  83. if (alpha) {
  84. i++;
  85. }
  86. else {
  87. alpha = charInfo[''];
  88. }
  89. if (alpha) {
  90. result += "&" + alpha + ";";
  91. i++;
  92. continue;
  93. }
  94. }
  95. if (c < 32 || c > 126) {
  96. if (c >= surrogate_pairs_1.highSurrogateFrom && c <= surrogate_pairs_1.highSurrogateTo) {
  97. result += '&#' + surrogate_pairs_1.getCodePoint(str, i) + ';';
  98. i++;
  99. }
  100. else {
  101. result += '&#' + c + ';';
  102. }
  103. }
  104. else {
  105. result += str.charAt(i);
  106. }
  107. i++;
  108. }
  109. return result;
  110. };
  111. Html5Entities.encodeNonUTF = function (str) {
  112. return new Html5Entities().encodeNonUTF(str);
  113. };
  114. Html5Entities.prototype.encodeNonASCII = function (str) {
  115. if (!str || !str.length) {
  116. return '';
  117. }
  118. var strLength = str.length;
  119. var result = '';
  120. var i = 0;
  121. while (i < strLength) {
  122. var c = str.charCodeAt(i);
  123. if (c <= 255) {
  124. result += str[i++];
  125. continue;
  126. }
  127. if (c >= surrogate_pairs_1.highSurrogateFrom && c <= surrogate_pairs_1.highSurrogateTo) {
  128. result += '&#' + surrogate_pairs_1.getCodePoint(str, i) + ';';
  129. i += 2;
  130. }
  131. else {
  132. result += '&#' + c + ';';
  133. i++;
  134. }
  135. }
  136. return result;
  137. };
  138. Html5Entities.encodeNonASCII = function (str) {
  139. return new Html5Entities().encodeNonASCII(str);
  140. };
  141. return Html5Entities;
  142. }());
  143. exports.Html5Entities = Html5Entities;
  144. function createIndexes(alphaIndex, charIndex) {
  145. var i = ENTITIES.length;
  146. while (i--) {
  147. var _a = ENTITIES[i], alpha = _a[0], _b = _a[1], chr = _b[0], chr2 = _b[1];
  148. var addChar = (chr < 32 || chr > 126) || chr === 62 || chr === 60 || chr === 38 || chr === 34 || chr === 39;
  149. var charInfo = void 0;
  150. if (addChar) {
  151. charInfo = charIndex[chr] = charIndex[chr] || {};
  152. }
  153. if (chr2) {
  154. alphaIndex[alpha] = String.fromCharCode(chr) + String.fromCharCode(chr2);
  155. addChar && (charInfo[chr2] = alpha);
  156. }
  157. else {
  158. alphaIndex[alpha] = String.fromCharCode(chr);
  159. addChar && (charInfo[''] = alpha);
  160. }
  161. }
  162. i = DECODE_ONLY_ENTITIES.length;
  163. while (i--) {
  164. var _c = DECODE_ONLY_ENTITIES[i], alpha = _c[0], _d = _c[1], chr = _d[0], chr2 = _d[1];
  165. alphaIndex[alpha] = String.fromCharCode(chr) + (chr2 ? String.fromCharCode(chr2) : '');
  166. }
  167. }