- commit
- 262ca4ef453d6b039e501716468388496b1ebf92
- parent
- ad80bc6edcabdc326b5cddc2db118eb8c4f4b3b8
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2017-11-19 11:32
build
Diffstat
| M | static/style.css | 179 | +++++++++++++++++++++++++++++++------------------------------ |
| M | static/voterunner.js | 24679 | ++++++++++++++++++++++++++++++------------------------------- |
2 files changed, 12190 insertions, 12668 deletions
diff --git a/static/style.css b/static/style.css
@@ -1,11 +1,12 @@1 -1 @charset "UTF-8";2 1 @viewport { 3 2 width: device-width; } 4 3 5 4 *, 6 5 *::before, 7 6 *::after {8 -1 box-sizing: inherit;-1 7 box-sizing: inherit; } -1 8 -1 9 img { 9 10 max-width: 100%; } 10 11 11 12 p, address, blockquote, pre, table, dl, ul, ol, figure, fieldset { @@ -16,15 +17,10 @@ html { 16 17 overflow-y: scroll; 17 18 background-color: #fff; 18 19 box-sizing: border-box;19 -1 color: #000;-1 20 color: #111; 20 21 font-size: 1.2em; 21 22 font-family: sans-serif;22 -1 line-height: 1.4; }23 -124 -1 body {25 -1 margin: 2em auto;26 -1 max-width: 36em;27 -1 padding: 0 0.4em; }-1 23 line-height: 1.5; } 28 24 29 25 h1, h2, h3, h4, h5, h6 { 30 26 line-height: 1.2; @@ -35,7 +31,7 @@ a { 35 31 color: #336DBE; 36 32 text-decoration: underline; } 37 33 a:hover, a:focus, a:active {38 -1 color: #1a375f; }-1 34 color: #223f68; } 39 35 40 36 a:not([href]) { 41 37 color: inherit; @@ -55,7 +51,7 @@ hr { 55 51 pre, code { 56 52 font-size: 90%; 57 53 font-family: monospace;58 -1 background-color: #c2d3ec; }-1 54 background-color: #ccdbef; } 59 55 60 56 code { 61 57 padding: 0 0.25em; } @@ -70,27 +66,30 @@ pre { 70 66 padding: 0; } 71 67 72 68 ol, ul {73 -1 padding-left: 2rem; }-1 69 padding-left: 1.5rem; } 74 70 75 71 dt { 76 72 font-weight: bold; } 77 73 78 74 dd {79 -1 margin-left: 2rem; }-1 75 margin-left: 1.5rem; } 80 76 81 77 blockquote { 82 78 font-style: italic;83 -1 margin-left: 2rem;-1 79 margin-left: 1.5rem; 84 80 margin-right: 0; } 85 81 86 82 table { 87 83 border-collapse: collapse; 88 84 border-spacing: 0; }89 -1 table td, table th {90 -1 text-align: start;91 -1 padding: 0.4em;92 -1 border-top: 1px solid #c0c0c0;93 -1 vertical-align: top; }-1 85 -1 86 tr { -1 87 border-bottom: 1px solid #c0c0c0; } -1 88 -1 89 td, th { -1 90 text-align: start; -1 91 padding: 0.2em; -1 92 vertical-align: top; } 94 93 95 94 textarea { 96 95 resize: vertical; } @@ -108,12 +107,17 @@ sub, sup { 108 107 h2, h3 { 109 108 page-break-after: avoid; } } 110 109 -1 110 body { -1 111 margin: 2em auto; -1 112 max-width: 38em; -1 113 padding: 0 0.4em; } -1 114 111 115 [id^="json-"] { 112 116 display: none; } 113 117 114 118 input[type="text"], 115 119 textarea {116 -1 background: #fff; }-1 120 background-color: #fff; } 117 121 118 122 textarea { 119 123 font-family: inherit; @@ -157,11 +161,11 @@ body > header { 157 161 font-size: 200%; 158 162 color: #fff; } 159 163 body > header h1 span {160 -1 color: #c2d3ec; }-1 164 color: #ccdbef; } 161 165 162 166 #tree,163 -1 #user,164 -1 #tree .node .body {-1 167 .user, -1 168 .node__body { 165 169 border: 1px solid #c0c0c0; 166 170 border-radius: 0.2em 0.2em 0 0; } 167 171 @@ -191,33 +195,41 @@ body > header { 191 195 right: 0; 192 196 width: 42%; } } 193 197194 -1 .node .expand, .node .delegate, #user .undelegate, #rm {-1 198 .bar { -1 199 display: flex; } -1 200 -1 201 .bar__item { -1 202 padding: 0.4em; -1 203 white-space: nowrap; -1 204 overflow: hidden; -1 205 text-overflow: ellipsis; -1 206 flex: 0 0 auto; } -1 207 -1 208 .bar__item--button { 195 209 appearance: none; 196 210 background: none; 197 211 border: 0; 198 212 cursor: pointer; 199 213 font: inherit; 200 214 color: inherit;201 -1 text-align: center; }202 -1 .node .expand:hover, .node .delegate:hover, #user .undelegate:hover, #rm:hover {-1 215 text-align: center; -1 216 min-width: 2.3em; } -1 217 .bar__item--button:focus, .bar__item--button:hover { 203 218 background-color: rgba(255, 255, 255, 0.2); } 204 219 @media print {205 -1 .node .expand, .node .delegate, #user .undelegate, #rm {-1 220 .bar__item--button { 206 221 display: none; } } 207 222208 -1 .node .expand, .node .delegate, .node .votes, #user .votes, #user .undelegate, #rm, .node .name, #user .delegate, #name {209 -1 padding: 0.4em;210 -1 white-space: nowrap;211 -1 overflow: hidden;212 -1 text-overflow: ellipsis; }-1 223 .bar__item--grow { -1 224 flex: 1 1 auto; } 213 225214 -1 .node .expand {215 -1 float: left;216 -1 border-right: 1px solid #c0c0c0; }-1 226 .bar__item--left { -1 227 border-right: 1px solid #c0c0c0; -1 228 order: 0; } 217 229218 -1 .node .delegate, .node .votes, #user .votes, #user .undelegate, #rm {219 -1 float: right;220 -1 border-left: 1px solid #c0c0c0; }-1 230 .bar__item--right { -1 231 border-left: 1px solid #c0c0c0; -1 232 order: 100; } 221 233 222 234 .tree { 223 235 padding: 0; @@ -228,68 +240,61 @@ body > header { 228 240 229 241 .node { 230 242 margin: 1em 0; }231 -1 .node:target > .body {-1 243 .node:target > .node__body { 232 244 outline: 5px auto #336DBE; 233 245 outline-offset: -2px; }234 -1 .node .body {235 -1 background: #fff;236 -1 break-inside: avoid; }237 -1 @media print {238 -1 .node .body {239 -1 border: 1px solid; } }240 -1 .node .header {241 -1 background: #c2d3ec; }242 -1 .node .expand:before {243 -1 content: ">"; }244 -1 .node .comment {245 -1 padding: 0.4em; }246 -1 .node .comment > :first-child {247 -1 margin-top: 0; }248 -1 .node .comment > :last-child {249 -1 margin-bottom: 0; }250 -1 .node.m-self > .body .delegate {-1 246 .node.node--self .node__delegate { 251 247 display: none; }252 -1 .node.m-self > .body .header {253 -1 background: #336DBE;254 -1 color: #fff; }-1 248 @media screen { -1 249 .node.node--self > .node__body .node__header { -1 250 background-color: #336DBE; -1 251 color: #fff; } } -1 252 @media print { -1 253 .node.node--self > .node__body .node__header { -1 254 font-weight: bold; } } 255 255 .node:not(.is-expanded) > .tree { 256 256 display: none; }257 -1 .node.is-expanded > .body .expand:before {258 -1 content: "v"; }259 -1260 -1 #user {261 -1 background: #c2d3ec; }262 -1 #user .delegate {263 -1 float: left; }264 -1 #user .undelegate:before {265 -1 content: "‒"; }266 -1 @media print {267 -1 #user {268 -1 display: none; } }-1 257 .node.is-expanded > .node__body .node__header { -1 258 border-bottom: 1px solid #c0c0c0; } 269 259270 -1 .statusbar {271 -1 width: 100%;272 -1 border-bottom: 1px solid #c0c0c0;-1 260 .node__body { -1 261 background: #fff; -1 262 break-inside: avoid; 273 263 overflow: hidden; } 274 264275 -1 #name {276 -1 float: left;277 -1 max-width: 80%; }278 -1 #name input {279 -1 font-size: 120%;280 -1 height: 1.6em; }-1 265 @media screen { -1 266 .node__header { -1 267 background-color: #ccdbef; } } -1 268 -1 269 .node__preview { -1 270 opacity: 0.7; } 281 271282 -1 #rm {-1 272 .node__comment { -1 273 padding: 0.4em; } -1 274 .node__comment > :first-child { -1 275 margin-top: 0; } -1 276 .node__comment > :last-child { -1 277 margin-bottom: 0; } -1 278 -1 279 .user { -1 280 background: #ccdbef; } -1 281 .user .bar { -1 282 border-bottom: 1px solid #c0c0c0; } -1 283 @media print { -1 284 .user { -1 285 display: none; } } -1 286 -1 287 .user__name input { -1 288 font-size: 120%; -1 289 height: 1.6em; } -1 290 -1 291 .user__rm { 283 292 font-size: 120%; 284 293 padding: 0.4em;285 -1 line-height: 1.6;286 -1 min-width: 2em; }287 -1 #rm:before {288 -1 content: "X"; }-1 294 line-height: 1.6; } 289 295290 -1 #comment textarea {-1 296 .user__comment textarea { 291 297 width: 100%; 292 298 min-height: 15em; 293 299 border: none; 294 300 padding: 0.4em; }295 -1
diff --git a/static/voterunner.js b/static/voterunner.js
@@ -1,6 +1,192 @@ 1 1 (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 2 2 3 3 },{}],2:[function(require,module,exports){ -1 4 // shim for using process in browser -1 5 var process = module.exports = {}; -1 6 -1 7 // cached from whatever global is present so that test runners that stub it -1 8 // don't break things. But we need to wrap it in a try catch in case it is -1 9 // wrapped in strict mode code which doesn't define any globals. It's inside a -1 10 // function because try/catches deoptimize in certain engines. -1 11 -1 12 var cachedSetTimeout; -1 13 var cachedClearTimeout; -1 14 -1 15 function defaultSetTimout() { -1 16 throw new Error('setTimeout has not been defined'); -1 17 } -1 18 function defaultClearTimeout () { -1 19 throw new Error('clearTimeout has not been defined'); -1 20 } -1 21 (function () { -1 22 try { -1 23 if (typeof setTimeout === 'function') { -1 24 cachedSetTimeout = setTimeout; -1 25 } else { -1 26 cachedSetTimeout = defaultSetTimout; -1 27 } -1 28 } catch (e) { -1 29 cachedSetTimeout = defaultSetTimout; -1 30 } -1 31 try { -1 32 if (typeof clearTimeout === 'function') { -1 33 cachedClearTimeout = clearTimeout; -1 34 } else { -1 35 cachedClearTimeout = defaultClearTimeout; -1 36 } -1 37 } catch (e) { -1 38 cachedClearTimeout = defaultClearTimeout; -1 39 } -1 40 } ()) -1 41 function runTimeout(fun) { -1 42 if (cachedSetTimeout === setTimeout) { -1 43 //normal enviroments in sane situations -1 44 return setTimeout(fun, 0); -1 45 } -1 46 // if setTimeout wasn't available but was latter defined -1 47 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { -1 48 cachedSetTimeout = setTimeout; -1 49 return setTimeout(fun, 0); -1 50 } -1 51 try { -1 52 // when when somebody has screwed with setTimeout but no I.E. maddness -1 53 return cachedSetTimeout(fun, 0); -1 54 } catch(e){ -1 55 try { -1 56 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally -1 57 return cachedSetTimeout.call(null, fun, 0); -1 58 } catch(e){ -1 59 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error -1 60 return cachedSetTimeout.call(this, fun, 0); -1 61 } -1 62 } -1 63 -1 64 -1 65 } -1 66 function runClearTimeout(marker) { -1 67 if (cachedClearTimeout === clearTimeout) { -1 68 //normal enviroments in sane situations -1 69 return clearTimeout(marker); -1 70 } -1 71 // if clearTimeout wasn't available but was latter defined -1 72 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { -1 73 cachedClearTimeout = clearTimeout; -1 74 return clearTimeout(marker); -1 75 } -1 76 try { -1 77 // when when somebody has screwed with setTimeout but no I.E. maddness -1 78 return cachedClearTimeout(marker); -1 79 } catch (e){ -1 80 try { -1 81 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally -1 82 return cachedClearTimeout.call(null, marker); -1 83 } catch (e){ -1 84 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. -1 85 // Some versions of I.E. have different rules for clearTimeout vs setTimeout -1 86 return cachedClearTimeout.call(this, marker); -1 87 } -1 88 } -1 89 -1 90 -1 91 -1 92 } -1 93 var queue = []; -1 94 var draining = false; -1 95 var currentQueue; -1 96 var queueIndex = -1; -1 97 -1 98 function cleanUpNextTick() { -1 99 if (!draining || !currentQueue) { -1 100 return; -1 101 } -1 102 draining = false; -1 103 if (currentQueue.length) { -1 104 queue = currentQueue.concat(queue); -1 105 } else { -1 106 queueIndex = -1; -1 107 } -1 108 if (queue.length) { -1 109 drainQueue(); -1 110 } -1 111 } -1 112 -1 113 function drainQueue() { -1 114 if (draining) { -1 115 return; -1 116 } -1 117 var timeout = runTimeout(cleanUpNextTick); -1 118 draining = true; -1 119 -1 120 var len = queue.length; -1 121 while(len) { -1 122 currentQueue = queue; -1 123 queue = []; -1 124 while (++queueIndex < len) { -1 125 if (currentQueue) { -1 126 currentQueue[queueIndex].run(); -1 127 } -1 128 } -1 129 queueIndex = -1; -1 130 len = queue.length; -1 131 } -1 132 currentQueue = null; -1 133 draining = false; -1 134 runClearTimeout(timeout); -1 135 } -1 136 -1 137 process.nextTick = function (fun) { -1 138 var args = new Array(arguments.length - 1); -1 139 if (arguments.length > 1) { -1 140 for (var i = 1; i < arguments.length; i++) { -1 141 args[i - 1] = arguments[i]; -1 142 } -1 143 } -1 144 queue.push(new Item(fun, args)); -1 145 if (queue.length === 1 && !draining) { -1 146 runTimeout(drainQueue); -1 147 } -1 148 }; -1 149 -1 150 // v8 likes predictible objects -1 151 function Item(fun, array) { -1 152 this.fun = fun; -1 153 this.array = array; -1 154 } -1 155 Item.prototype.run = function () { -1 156 this.fun.apply(null, this.array); -1 157 }; -1 158 process.title = 'browser'; -1 159 process.browser = true; -1 160 process.env = {}; -1 161 process.argv = []; -1 162 process.version = ''; // empty string to avoid regexp issues -1 163 process.versions = {}; -1 164 -1 165 function noop() {} -1 166 -1 167 process.on = noop; -1 168 process.addListener = noop; -1 169 process.once = noop; -1 170 process.off = noop; -1 171 process.removeListener = noop; -1 172 process.removeAllListeners = noop; -1 173 process.emit = noop; -1 174 process.prependListener = noop; -1 175 process.prependOnceListener = noop; -1 176 -1 177 process.listeners = function (name) { return [] } -1 178 -1 179 process.binding = function (name) { -1 180 throw new Error('process.binding is not supported'); -1 181 }; -1 182 -1 183 process.cwd = function () { return '/' }; -1 184 process.chdir = function (dir) { -1 185 throw new Error('process.chdir is not supported'); -1 186 }; -1 187 process.umask = function() { return 0; }; -1 188 -1 189 },{}],3:[function(require,module,exports){ 4 190 (function (global){ 5 191 /*! https://mths.be/punycode v1.4.1 by @mathias */ 6 192 ;(function(root) { @@ -537,7 +723,7 @@ 537 723 }(this)); 538 724 539 725 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})540 -1 },{}],3:[function(require,module,exports){-1 726 },{}],4:[function(require,module,exports){ 541 727 module.exports = after 542 728 543 729 function after(count, callback, err_cb) { @@ -567,7 +753,7 @@ function after(count, callback, err_cb) { 567 753 568 754 function noop() {} 569 755570 -1 },{}],4:[function(require,module,exports){-1 756 },{}],5:[function(require,module,exports){ 571 757 /** 572 758 * An abstraction for slicing an arraybuffer even when 573 759 * ArrayBuffer.prototype.slice is not supported @@ -598,7 +784,7 @@ module.exports = function(arraybuffer, start, end) { 598 784 return result.buffer; 599 785 }; 600 786601 -1 },{}],5:[function(require,module,exports){-1 787 },{}],6:[function(require,module,exports){ 602 788 603 789 /** 604 790 * Expose `Backoff`. @@ -685,7 +871,7 @@ Backoff.prototype.setJitter = function(jitter){ 685 871 }; 686 872 687 873688 -1 },{}],6:[function(require,module,exports){-1 874 },{}],7:[function(require,module,exports){ 689 875 /* 690 876 * base64-arraybuffer 691 877 * https://github.com/niklasvh/base64-arraybuffer @@ -693,9 +879,17 @@ Backoff.prototype.setJitter = function(jitter){ 693 879 * Copyright (c) 2012 Niklas von Hertzen 694 880 * Licensed under the MIT license. 695 881 */696 -1 (function(chars){-1 882 (function(){ 697 883 "use strict"; 698 884 -1 885 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -1 886 -1 887 // Use a lookup table to find the index. -1 888 var lookup = new Uint8Array(256); -1 889 for (var i = 0; i < chars.length; i++) { -1 890 lookup[chars.charCodeAt(i)] = i; -1 891 } -1 892 699 893 exports.encode = function(arraybuffer) { 700 894 var bytes = new Uint8Array(arraybuffer), 701 895 i, len = bytes.length, base64 = ""; @@ -732,10 +926,10 @@ Backoff.prototype.setJitter = function(jitter){ 732 926 bytes = new Uint8Array(arraybuffer); 733 927 734 928 for (i = 0; i < len; i+=4) {735 -1 encoded1 = chars.indexOf(base64[i]);736 -1 encoded2 = chars.indexOf(base64[i+1]);737 -1 encoded3 = chars.indexOf(base64[i+2]);738 -1 encoded4 = chars.indexOf(base64[i+3]);-1 929 encoded1 = lookup[base64.charCodeAt(i)]; -1 930 encoded2 = lookup[base64.charCodeAt(i+1)]; -1 931 encoded3 = lookup[base64.charCodeAt(i+2)]; -1 932 encoded4 = lookup[base64.charCodeAt(i+3)]; 739 933 740 934 bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); 741 935 bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); @@ -744,9 +938,9 @@ Backoff.prototype.setJitter = function(jitter){ 744 938 745 939 return arraybuffer; 746 940 };747 -1 })("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");-1 941 })(); 748 942749 -1 },{}],7:[function(require,module,exports){-1 943 },{}],8:[function(require,module,exports){ 750 944 (function (global){ 751 945 /** 752 946 * Create a blob builder even when vendor prefixes exist @@ -846,114 +1040,6 @@ module.exports = (function() { 846 1040 })(); 847 1041 848 1042 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})849 -1 },{}],8:[function(require,module,exports){850 -1 /*!851 -1 * Cross-Browser Split 1.1.1852 -1 * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>853 -1 * Available under the MIT License854 -1 * ECMAScript compliant, uniform cross-browser split method855 -1 */856 -1857 -1 /**858 -1 * Splits a string into an array of strings using a regex or string separator. Matches of the859 -1 * separator are not included in the result array. However, if `separator` is a regex that contains860 -1 * capturing groups, backreferences are spliced into the result each time `separator` is matched.861 -1 * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably862 -1 * cross-browser.863 -1 * @param {String} str String to split.864 -1 * @param {RegExp|String} separator Regex or string to use for separating the string.865 -1 * @param {Number} [limit] Maximum number of items to include in the result array.866 -1 * @returns {Array} Array of substrings.867 -1 * @example868 -1 *869 -1 * // Basic use870 -1 * split('a b c d', ' ');871 -1 * // -> ['a', 'b', 'c', 'd']872 -1 *873 -1 * // With limit874 -1 * split('a b c d', ' ', 2);875 -1 * // -> ['a', 'b']876 -1 *877 -1 * // Backreferences in result array878 -1 * split('..word1 word2..', /([a-z]+)(\d+)/i);879 -1 * // -> ['..', 'word', '1', ' ', 'word', '2', '..']880 -1 */881 -1 module.exports = (function split(undef) {882 -1883 -1 var nativeSplit = String.prototype.split,884 -1 compliantExecNpcg = /()??/.exec("")[1] === undef,885 -1 // NPCG: nonparticipating capturing group886 -1 self;887 -1888 -1 self = function(str, separator, limit) {889 -1 // If `separator` is not a regex, use `nativeSplit`890 -1 if (Object.prototype.toString.call(separator) !== "[object RegExp]") {891 -1 return nativeSplit.call(str, separator, limit);892 -1 }893 -1 var output = [],894 -1 flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6895 -1 (separator.sticky ? "y" : ""),896 -1 // Firefox 3+897 -1 lastLastIndex = 0,898 -1 // Make `global` and avoid `lastIndex` issues by working with a copy899 -1 separator = new RegExp(separator.source, flags + "g"),900 -1 separator2, match, lastIndex, lastLength;901 -1 str += ""; // Type-convert902 -1 if (!compliantExecNpcg) {903 -1 // Doesn't need flags gy, but they don't hurt904 -1 separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);905 -1 }906 -1 /* Values for `limit`, per the spec:907 -1 * If undefined: 4294967295 // Math.pow(2, 32) - 1908 -1 * If 0, Infinity, or NaN: 0909 -1 * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;910 -1 * If negative number: 4294967296 - Math.floor(Math.abs(limit))911 -1 * If other: Type-convert, then use the above rules912 -1 */913 -1 limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1914 -1 limit >>> 0; // ToUint32(limit)915 -1 while (match = separator.exec(str)) {916 -1 // `separator.lastIndex` is not reliable cross-browser917 -1 lastIndex = match.index + match[0].length;918 -1 if (lastIndex > lastLastIndex) {919 -1 output.push(str.slice(lastLastIndex, match.index));920 -1 // Fix browsers whose `exec` methods don't consistently return `undefined` for921 -1 // nonparticipating capturing groups922 -1 if (!compliantExecNpcg && match.length > 1) {923 -1 match[0].replace(separator2, function() {924 -1 for (var i = 1; i < arguments.length - 2; i++) {925 -1 if (arguments[i] === undef) {926 -1 match[i] = undef;927 -1 }928 -1 }929 -1 });930 -1 }931 -1 if (match.length > 1 && match.index < str.length) {932 -1 Array.prototype.push.apply(output, match.slice(1));933 -1 }934 -1 lastLength = match[0].length;935 -1 lastLastIndex = lastIndex;936 -1 if (output.length >= limit) {937 -1 break;938 -1 }939 -1 }940 -1 if (separator.lastIndex === match.index) {941 -1 separator.lastIndex++; // Avoid an infinite loop942 -1 }943 -1 }944 -1 if (lastLastIndex === str.length) {945 -1 if (lastLength || !separator.test("")) {946 -1 output.push("");947 -1 }948 -1 } else {949 -1 output.push(str.slice(lastLastIndex));950 -1 }951 -1 return output.length > limit ? output.slice(0, limit) : output;952 -1 };953 -1954 -1 return self;955 -1 })();956 -1957 1043 },{}],9:[function(require,module,exports){ 958 1044 /** 959 1045 * Slice reference. @@ -1155,1311 +1241,1251 @@ module.exports = function(a, b){ 1155 1241 }; 1156 1242 },{}],12:[function(require,module,exports){ 1157 12431158 -1 /**1159 -1 * This is the web browser implementation of `debug()`.1160 -1 *1161 -1 * Expose `debug()` as the module.1162 -1 */-1 1244 module.exports = require('./lib/index'); 1163 12451164 -1 exports = module.exports = require('./debug');1165 -1 exports.log = log;1166 -1 exports.formatArgs = formatArgs;1167 -1 exports.save = save;1168 -1 exports.load = load;1169 -1 exports.useColors = useColors;1170 -1 exports.storage = 'undefined' != typeof chrome1171 -1 && 'undefined' != typeof chrome.storage1172 -1 ? chrome.storage.local1173 -1 : localstorage();-1 1246 },{"./lib/index":13}],13:[function(require,module,exports){ -1 1247 -1 1248 module.exports = require('./socket'); 1174 1249 1175 1250 /**1176 -1 * Colors.-1 1251 * Exports parser -1 1252 * -1 1253 * @api public -1 1254 * 1177 1255 */ -1 1256 module.exports.parser = require('engine.io-parser'); 1178 12571179 -1 exports.colors = [1180 -1 'lightseagreen',1181 -1 'forestgreen',1182 -1 'goldenrod',1183 -1 'dodgerblue',1184 -1 'darkorchid',1185 -1 'crimson'1186 -1 ];1187 -1-1 1258 },{"./socket":14,"engine.io-parser":26}],14:[function(require,module,exports){ -1 1259 (function (global){ 1188 1260 /**1189 -1 * Currently only WebKit-based Web Inspectors, Firefox >= v31,1190 -1 * and the Firebug extension (any Firefox version) are known1191 -1 * to support "%c" CSS customizations.1192 -1 *1193 -1 * TODO: add a `localStorage` variable to explicitly enable/disable colors-1 1261 * Module dependencies. 1194 1262 */ 1195 12631196 -1 function useColors() {1197 -1 // is webkit? http://stackoverflow.com/a/16459606/3767731198 -1 return ('WebkitAppearance' in document.documentElement.style) ||1199 -1 // is firebug? http://stackoverflow.com/a/398120/3767731200 -1 (window.console && (console.firebug || (console.exception && console.table))) ||1201 -1 // is firefox >= v31?1202 -1 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages1203 -1 (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);1204 -1 }-1 1264 var transports = require('./transports/index'); -1 1265 var Emitter = require('component-emitter'); -1 1266 var debug = require('debug')('engine.io-client:socket'); -1 1267 var index = require('indexof'); -1 1268 var parser = require('engine.io-parser'); -1 1269 var parseuri = require('parseuri'); -1 1270 var parsejson = require('parsejson'); -1 1271 var parseqs = require('parseqs'); 1205 1272 1206 1273 /**1207 -1 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.-1 1274 * Module exports. 1208 1275 */ 1209 12761210 -1 exports.formatters.j = function(v) {1211 -1 return JSON.stringify(v);1212 -1 };1213 -1-1 1277 module.exports = Socket; 1214 1278 1215 1279 /**1216 -1 * Colorize log arguments if enabled.-1 1280 * Socket constructor. 1217 1281 * -1 1282 * @param {String|Object} uri or options -1 1283 * @param {Object} options 1218 1284 * @api public 1219 1285 */ 1220 12861221 -1 function formatArgs() {1222 -1 var args = arguments;1223 -1 var useColors = this.useColors;-1 1287 function Socket (uri, opts) { -1 1288 if (!(this instanceof Socket)) return new Socket(uri, opts); 1224 12891225 -1 args[0] = (useColors ? '%c' : '')1226 -1 + this.namespace1227 -1 + (useColors ? ' %c' : ' ')1228 -1 + args[0]1229 -1 + (useColors ? '%c ' : ' ')1230 -1 + '+' + exports.humanize(this.diff);-1 1290 opts = opts || {}; 1231 12911232 -1 if (!useColors) return args;-1 1292 if (uri && 'object' === typeof uri) { -1 1293 opts = uri; -1 1294 uri = null; -1 1295 } 1233 12961234 -1 var c = 'color: ' + this.color;1235 -1 args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));-1 1297 if (uri) { -1 1298 uri = parseuri(uri); -1 1299 opts.hostname = uri.host; -1 1300 opts.secure = uri.protocol === 'https' || uri.protocol === 'wss'; -1 1301 opts.port = uri.port; -1 1302 if (uri.query) opts.query = uri.query; -1 1303 } else if (opts.host) { -1 1304 opts.hostname = parseuri(opts.host).host; -1 1305 } 1236 13061237 -1 // the final "%c" is somewhat tricky, because there could be other1238 -1 // arguments passed either before or after the %c, so we need to1239 -1 // figure out the correct index to insert the CSS into1240 -1 var index = 0;1241 -1 var lastC = 0;1242 -1 args[0].replace(/%[a-z%]/g, function(match) {1243 -1 if ('%%' === match) return;1244 -1 index++;1245 -1 if ('%c' === match) {1246 -1 // we only are interested in the *last* %c1247 -1 // (the user may have provided their own)1248 -1 lastC = index;1249 -1 }1250 -1 });-1 1307 this.secure = null != opts.secure ? opts.secure -1 1308 : (global.location && 'https:' === location.protocol); 1251 13091252 -1 args.splice(lastC, 0, c);1253 -1 return args;1254 -1 }-1 1310 if (opts.hostname && !opts.port) { -1 1311 // if no port is specified manually, use the protocol default -1 1312 opts.port = this.secure ? '443' : '80'; -1 1313 } 1255 13141256 -1 /**1257 -1 * Invokes `console.log()` when available.1258 -1 * No-op when `console.log` is not a "function".1259 -1 *1260 -1 * @api public1261 -1 */-1 1315 this.agent = opts.agent || false; -1 1316 this.hostname = opts.hostname || -1 1317 (global.location ? location.hostname : 'localhost'); -1 1318 this.port = opts.port || (global.location && location.port -1 1319 ? location.port -1 1320 : (this.secure ? 443 : 80)); -1 1321 this.query = opts.query || {}; -1 1322 if ('string' === typeof this.query) this.query = parseqs.decode(this.query); -1 1323 this.upgrade = false !== opts.upgrade; -1 1324 this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/'; -1 1325 this.forceJSONP = !!opts.forceJSONP; -1 1326 this.jsonp = false !== opts.jsonp; -1 1327 this.forceBase64 = !!opts.forceBase64; -1 1328 this.enablesXDR = !!opts.enablesXDR; -1 1329 this.timestampParam = opts.timestampParam || 't'; -1 1330 this.timestampRequests = opts.timestampRequests; -1 1331 this.transports = opts.transports || ['polling', 'websocket']; -1 1332 this.readyState = ''; -1 1333 this.writeBuffer = []; -1 1334 this.prevBufferLen = 0; -1 1335 this.policyPort = opts.policyPort || 843; -1 1336 this.rememberUpgrade = opts.rememberUpgrade || false; -1 1337 this.binaryType = null; -1 1338 this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades; -1 1339 this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false; 1262 13401263 -1 function log() {1264 -1 // this hackery is required for IE8/9, where1265 -1 // the `console.log` function doesn't have 'apply'1266 -1 return 'object' === typeof console1267 -1 && console.log1268 -1 && Function.prototype.apply.call(console.log, console, arguments);1269 -1 }-1 1341 if (true === this.perMessageDeflate) this.perMessageDeflate = {}; -1 1342 if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) { -1 1343 this.perMessageDeflate.threshold = 1024; -1 1344 } 1270 13451271 -1 /**1272 -1 * Save `namespaces`.1273 -1 *1274 -1 * @param {String} namespaces1275 -1 * @api private1276 -1 */-1 1346 // SSL options for Node.js client -1 1347 this.pfx = opts.pfx || null; -1 1348 this.key = opts.key || null; -1 1349 this.passphrase = opts.passphrase || null; -1 1350 this.cert = opts.cert || null; -1 1351 this.ca = opts.ca || null; -1 1352 this.ciphers = opts.ciphers || null; -1 1353 this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? null : opts.rejectUnauthorized; -1 1354 this.forceNode = !!opts.forceNode; 1277 13551278 -1 function save(namespaces) {1279 -1 try {1280 -1 if (null == namespaces) {1281 -1 exports.storage.removeItem('debug');1282 -1 } else {1283 -1 exports.storage.debug = namespaces;-1 1356 // other options for Node.js client -1 1357 var freeGlobal = typeof global === 'object' && global; -1 1358 if (freeGlobal.global === freeGlobal) { -1 1359 if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) { -1 1360 this.extraHeaders = opts.extraHeaders; 1284 1361 }1285 -1 } catch(e) {}1286 -1 }1287 13621288 -1 /**1289 -1 * Load `namespaces`.1290 -1 *1291 -1 * @return {String} returns the previously persisted debug modes1292 -1 * @api private1293 -1 */-1 1363 if (opts.localAddress) { -1 1364 this.localAddress = opts.localAddress; -1 1365 } -1 1366 } 1294 13671295 -1 function load() {1296 -1 var r;1297 -1 try {1298 -1 r = exports.storage.debug;1299 -1 } catch(e) {}1300 -1 return r;1301 -1 }-1 1368 // set on handshake -1 1369 this.id = null; -1 1370 this.upgrades = null; -1 1371 this.pingInterval = null; -1 1372 this.pingTimeout = null; 1302 13731303 -1 /**1304 -1 * Enable namespaces listed in `localStorage.debug` initially.1305 -1 */-1 1374 // set on heartbeat -1 1375 this.pingIntervalTimer = null; -1 1376 this.pingTimeoutTimer = null; 1306 13771307 -1 exports.enable(load());-1 1378 this.open(); -1 1379 } -1 1380 -1 1381 Socket.priorWebsocketSuccess = false; 1308 1382 1309 1383 /**1310 -1 * Localstorage attempts to return the localstorage.1311 -1 *1312 -1 * This is necessary because safari throws1313 -1 * when a user disables cookies/localstorage1314 -1 * and you attempt to access it.1315 -1 *1316 -1 * @return {LocalStorage}1317 -1 * @api private-1 1384 * Mix in `Emitter`. 1318 1385 */ 1319 13861320 -1 function localstorage(){1321 -1 try {1322 -1 return window.localStorage;1323 -1 } catch (e) {}1324 -1 }1325 -11326 -1 },{"./debug":13}],13:[function(require,module,exports){-1 1387 Emitter(Socket.prototype); 1327 1388 1328 1389 /**1329 -1 * This is the common logic for both the Node.js and web browser1330 -1 * implementations of `debug()`.-1 1390 * Protocol version. 1331 1391 *1332 -1 * Expose `debug()` as the module.-1 1392 * @api public 1333 1393 */ 1334 13941335 -1 exports = module.exports = debug;1336 -1 exports.coerce = coerce;1337 -1 exports.disable = disable;1338 -1 exports.enable = enable;1339 -1 exports.enabled = enabled;1340 -1 exports.humanize = require('ms');-1 1395 Socket.protocol = parser.protocol; // this is an int 1341 1396 1342 1397 /**1343 -1 * The currently active debug mode names, and names to skip.-1 1398 * Expose deps for legacy compatibility -1 1399 * and standalone browser access. 1344 1400 */ 1345 14011346 -1 exports.names = [];1347 -1 exports.skips = [];-1 1402 Socket.Socket = Socket; -1 1403 Socket.Transport = require('./transport'); -1 1404 Socket.transports = require('./transports/index'); -1 1405 Socket.parser = require('engine.io-parser'); 1348 1406 1349 1407 /**1350 -1 * Map of special "%n" handling functions, for the debug "format" argument.-1 1408 * Creates transport of the given type. 1351 1409 *1352 -1 * Valid key names are a single, lowercased letter, i.e. "n".-1 1410 * @param {String} transport name -1 1411 * @return {Transport} -1 1412 * @api private 1353 1413 */ 1354 14141355 -1 exports.formatters = {};-1 1415 Socket.prototype.createTransport = function (name) { -1 1416 debug('creating transport "%s"', name); -1 1417 var query = clone(this.query); 1356 14181357 -1 /**1358 -1 * Previously assigned color.1359 -1 */-1 1419 // append engine.io protocol identifier -1 1420 query.EIO = parser.protocol; 1360 14211361 -1 var prevColor = 0;-1 1422 // transport name -1 1423 query.transport = name; 1362 14241363 -1 /**1364 -1 * Previous log timestamp.1365 -1 */-1 1425 // session id if we already have one -1 1426 if (this.id) query.sid = this.id; 1366 14271367 -1 var prevTime;-1 1428 var transport = new transports[name]({ -1 1429 agent: this.agent, -1 1430 hostname: this.hostname, -1 1431 port: this.port, -1 1432 secure: this.secure, -1 1433 path: this.path, -1 1434 query: query, -1 1435 forceJSONP: this.forceJSONP, -1 1436 jsonp: this.jsonp, -1 1437 forceBase64: this.forceBase64, -1 1438 enablesXDR: this.enablesXDR, -1 1439 timestampRequests: this.timestampRequests, -1 1440 timestampParam: this.timestampParam, -1 1441 policyPort: this.policyPort, -1 1442 socket: this, -1 1443 pfx: this.pfx, -1 1444 key: this.key, -1 1445 passphrase: this.passphrase, -1 1446 cert: this.cert, -1 1447 ca: this.ca, -1 1448 ciphers: this.ciphers, -1 1449 rejectUnauthorized: this.rejectUnauthorized, -1 1450 perMessageDeflate: this.perMessageDeflate, -1 1451 extraHeaders: this.extraHeaders, -1 1452 forceNode: this.forceNode, -1 1453 localAddress: this.localAddress -1 1454 }); -1 1455 -1 1456 return transport; -1 1457 }; -1 1458 -1 1459 function clone (obj) { -1 1460 var o = {}; -1 1461 for (var i in obj) { -1 1462 if (obj.hasOwnProperty(i)) { -1 1463 o[i] = obj[i]; -1 1464 } -1 1465 } -1 1466 return o; -1 1467 } 1368 1468 1369 1469 /**1370 -1 * Select a color.-1 1470 * Initializes transport to use and starts probe. 1371 1471 *1372 -1 * @return {Number}1373 1472 * @api private 1374 1473 */ -1 1474 Socket.prototype.open = function () { -1 1475 var transport; -1 1476 if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') !== -1) { -1 1477 transport = 'websocket'; -1 1478 } else if (0 === this.transports.length) { -1 1479 // Emit error on next tick so it can be listened to -1 1480 var self = this; -1 1481 setTimeout(function () { -1 1482 self.emit('error', 'No transports available'); -1 1483 }, 0); -1 1484 return; -1 1485 } else { -1 1486 transport = this.transports[0]; -1 1487 } -1 1488 this.readyState = 'opening'; 1375 14891376 -1 function selectColor() {1377 -1 return exports.colors[prevColor++ % exports.colors.length];1378 -1 }-1 1490 // Retry with the next transport if the transport is disabled (jsonp: false) -1 1491 try { -1 1492 transport = this.createTransport(transport); -1 1493 } catch (e) { -1 1494 this.transports.shift(); -1 1495 this.open(); -1 1496 return; -1 1497 } -1 1498 -1 1499 transport.open(); -1 1500 this.setTransport(transport); -1 1501 }; 1379 1502 1380 1503 /**1381 -1 * Create a debugger with the given `namespace`.-1 1504 * Sets the current transport. Disables the existing one (if any). 1382 1505 *1383 -1 * @param {String} namespace1384 -1 * @return {Function}1385 -1 * @api public-1 1506 * @api private 1386 1507 */ 1387 15081388 -1 function debug(namespace) {-1 1509 Socket.prototype.setTransport = function (transport) { -1 1510 debug('setting transport %s', transport.name); -1 1511 var self = this; 1389 15121390 -1 // define the `disabled` version1391 -1 function disabled() {-1 1513 if (this.transport) { -1 1514 debug('clearing existing transport %s', this.transport.name); -1 1515 this.transport.removeAllListeners(); 1392 1516 }1393 -1 disabled.enabled = false;1394 -11395 -1 // define the `enabled` version1396 -1 function enabled() {1397 15171398 -1 var self = enabled;-1 1518 // set up transport -1 1519 this.transport = transport; 1399 15201400 -1 // set `diff` timestamp1401 -1 var curr = +new Date();1402 -1 var ms = curr - (prevTime || curr);1403 -1 self.diff = ms;1404 -1 self.prev = prevTime;1405 -1 self.curr = curr;1406 -1 prevTime = curr;-1 1521 // set up transport listeners -1 1522 transport -1 1523 .on('drain', function () { -1 1524 self.onDrain(); -1 1525 }) -1 1526 .on('packet', function (packet) { -1 1527 self.onPacket(packet); -1 1528 }) -1 1529 .on('error', function (e) { -1 1530 self.onError(e); -1 1531 }) -1 1532 .on('close', function () { -1 1533 self.onClose('transport close'); -1 1534 }); -1 1535 }; 1407 15361408 -1 // add the `color` if not set1409 -1 if (null == self.useColors) self.useColors = exports.useColors();1410 -1 if (null == self.color && self.useColors) self.color = selectColor();-1 1537 /** -1 1538 * Probes a transport. -1 1539 * -1 1540 * @param {String} transport name -1 1541 * @api private -1 1542 */ 1411 15431412 -1 var args = Array.prototype.slice.call(arguments);-1 1544 Socket.prototype.probe = function (name) { -1 1545 debug('probing transport "%s"', name); -1 1546 var transport = this.createTransport(name, { probe: 1 }); -1 1547 var failed = false; -1 1548 var self = this; 1413 15491414 -1 args[0] = exports.coerce(args[0]);-1 1550 Socket.priorWebsocketSuccess = false; 1415 15511416 -1 if ('string' !== typeof args[0]) {1417 -1 // anything else let's inspect with %o1418 -1 args = ['%o'].concat(args);-1 1552 function onTransportOpen () { -1 1553 if (self.onlyBinaryUpgrades) { -1 1554 var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary; -1 1555 failed = failed || upgradeLosesBinary; 1419 1556 } -1 1557 if (failed) return; 1420 15581421 -1 // apply any `formatters` transformations1422 -1 var index = 0;1423 -1 args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {1424 -1 // if we encounter an escaped % then don't increase the array index1425 -1 if (match === '%%') return match;1426 -1 index++;1427 -1 var formatter = exports.formatters[format];1428 -1 if ('function' === typeof formatter) {1429 -1 var val = args[index];1430 -1 match = formatter.call(self, val);-1 1559 debug('probe transport "%s" opened', name); -1 1560 transport.send([{ type: 'ping', data: 'probe' }]); -1 1561 transport.once('packet', function (msg) { -1 1562 if (failed) return; -1 1563 if ('pong' === msg.type && 'probe' === msg.data) { -1 1564 debug('probe transport "%s" pong', name); -1 1565 self.upgrading = true; -1 1566 self.emit('upgrading', transport); -1 1567 if (!transport) return; -1 1568 Socket.priorWebsocketSuccess = 'websocket' === transport.name; 1431 15691432 -1 // now we need to remove `args[index]` since it's inlined in the `format`1433 -1 args.splice(index, 1);1434 -1 index--;1435 -1 }1436 -1 return match;1437 -1 });-1 1570 debug('pausing current transport "%s"', self.transport.name); -1 1571 self.transport.pause(function () { -1 1572 if (failed) return; -1 1573 if ('closed' === self.readyState) return; -1 1574 debug('changing transport and sending upgrade packet'); 1438 15751439 -1 if ('function' === typeof exports.formatArgs) {1440 -1 args = exports.formatArgs.apply(self, args);1441 -1 }1442 -1 var logFn = enabled.log || exports.log || console.log.bind(console);1443 -1 logFn.apply(self, args);-1 1576 cleanup(); -1 1577 -1 1578 self.setTransport(transport); -1 1579 transport.send([{ type: 'upgrade' }]); -1 1580 self.emit('upgrade', transport); -1 1581 transport = null; -1 1582 self.upgrading = false; -1 1583 self.flush(); -1 1584 }); -1 1585 } else { -1 1586 debug('probe transport "%s" failed', name); -1 1587 var err = new Error('probe error'); -1 1588 err.transport = transport.name; -1 1589 self.emit('upgradeError', err); -1 1590 } -1 1591 }); 1444 1592 }1445 -1 enabled.enabled = true;1446 15931447 -1 var fn = exports.enabled(namespace) ? enabled : disabled;-1 1594 function freezeTransport () { -1 1595 if (failed) return; 1448 15961449 -1 fn.namespace = namespace;-1 1597 // Any callback called by transport should be ignored since now -1 1598 failed = true; 1450 15991451 -1 return fn;1452 -1 }-1 1600 cleanup(); 1453 16011454 -1 /**1455 -1 * Enables a debug mode by namespaces. This can include modes1456 -1 * separated by a colon and wildcards.1457 -1 *1458 -1 * @param {String} namespaces1459 -1 * @api public1460 -1 */-1 1602 transport.close(); -1 1603 transport = null; -1 1604 } 1461 16051462 -1 function enable(namespaces) {1463 -1 exports.save(namespaces);-1 1606 // Handle any error that happens while probing -1 1607 function onerror (err) { -1 1608 var error = new Error('probe error: ' + err); -1 1609 error.transport = transport.name; 1464 16101465 -1 var split = (namespaces || '').split(/[\s,]+/);1466 -1 var len = split.length;-1 1611 freezeTransport(); 1467 16121468 -1 for (var i = 0; i < len; i++) {1469 -1 if (!split[i]) continue; // ignore empty strings1470 -1 namespaces = split[i].replace(/\*/g, '.*?');1471 -1 if (namespaces[0] === '-') {1472 -1 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));1473 -1 } else {1474 -1 exports.names.push(new RegExp('^' + namespaces + '$'));-1 1613 debug('probe transport "%s" failed because of error: %s', name, err); -1 1614 -1 1615 self.emit('upgradeError', error); -1 1616 } -1 1617 -1 1618 function onTransportClose () { -1 1619 onerror('transport closed'); -1 1620 } -1 1621 -1 1622 // When the socket is closed while we're probing -1 1623 function onclose () { -1 1624 onerror('socket closed'); -1 1625 } -1 1626 -1 1627 // When the socket is upgraded while we're probing -1 1628 function onupgrade (to) { -1 1629 if (transport && to.name !== transport.name) { -1 1630 debug('"%s" works - aborting "%s"', to.name, transport.name); -1 1631 freezeTransport(); 1475 1632 } 1476 1633 }1477 -1 }1478 16341479 -1 /**1480 -1 * Disable debug output.1481 -1 *1482 -1 * @api public1483 -1 */-1 1635 // Remove all listeners on the transport and on self -1 1636 function cleanup () { -1 1637 transport.removeListener('open', onTransportOpen); -1 1638 transport.removeListener('error', onerror); -1 1639 transport.removeListener('close', onTransportClose); -1 1640 self.removeListener('close', onclose); -1 1641 self.removeListener('upgrading', onupgrade); -1 1642 } 1484 16431485 -1 function disable() {1486 -1 exports.enable('');1487 -1 }-1 1644 transport.once('open', onTransportOpen); -1 1645 transport.once('error', onerror); -1 1646 transport.once('close', onTransportClose); -1 1647 -1 1648 this.once('close', onclose); -1 1649 this.once('upgrading', onupgrade); -1 1650 -1 1651 transport.open(); -1 1652 }; 1488 1653 1489 1654 /**1490 -1 * Returns true if the given mode name is enabled, false otherwise.-1 1655 * Called when connection is deemed open. 1491 1656 *1492 -1 * @param {String} name1493 -1 * @return {Boolean}1494 1657 * @api public 1495 1658 */ 1496 16591497 -1 function enabled(name) {1498 -1 var i, len;1499 -1 for (i = 0, len = exports.skips.length; i < len; i++) {1500 -1 if (exports.skips[i].test(name)) {1501 -1 return false;1502 -1 }1503 -1 }1504 -1 for (i = 0, len = exports.names.length; i < len; i++) {1505 -1 if (exports.names[i].test(name)) {1506 -1 return true;-1 1660 Socket.prototype.onOpen = function () { -1 1661 debug('socket open'); -1 1662 this.readyState = 'open'; -1 1663 Socket.priorWebsocketSuccess = 'websocket' === this.transport.name; -1 1664 this.emit('open'); -1 1665 this.flush(); -1 1666 -1 1667 // we check for `readyState` in case an `open` -1 1668 // listener already closed the socket -1 1669 if ('open' === this.readyState && this.upgrade && this.transport.pause) { -1 1670 debug('starting upgrade probes'); -1 1671 for (var i = 0, l = this.upgrades.length; i < l; i++) { -1 1672 this.probe(this.upgrades[i]); 1507 1673 } 1508 1674 }1509 -1 return false;1510 -1 }-1 1675 }; 1511 1676 1512 1677 /**1513 -1 * Coerce `val`.-1 1678 * Handles a packet. 1514 1679 *1515 -1 * @param {Mixed} val1516 -1 * @return {Mixed}1517 1680 * @api private 1518 1681 */ 1519 16821520 -1 function coerce(val) {1521 -1 if (val instanceof Error) return val.stack || val.message;1522 -1 return val;1523 -1 }-1 1683 Socket.prototype.onPacket = function (packet) { -1 1684 if ('opening' === this.readyState || 'open' === this.readyState || -1 1685 'closing' === this.readyState) { -1 1686 debug('socket receive: type "%s", data "%s"', packet.type, packet.data); -1 1687 -1 1688 this.emit('packet', packet); 1524 16891525 -1 },{"ms":96}],14:[function(require,module,exports){-1 1690 // Socket is live - any packet counts -1 1691 this.emit('heartbeat'); 1526 16921527 -1 module.exports = require('./lib/');-1 1693 switch (packet.type) { -1 1694 case 'open': -1 1695 this.onHandshake(parsejson(packet.data)); -1 1696 break; 1528 16971529 -1 },{"./lib/":15}],15:[function(require,module,exports){-1 1698 case 'pong': -1 1699 this.setPing(); -1 1700 this.emit('pong'); -1 1701 break; 1530 17021531 -1 module.exports = require('./socket');-1 1703 case 'error': -1 1704 var err = new Error('server error'); -1 1705 err.code = packet.data; -1 1706 this.onError(err); -1 1707 break; -1 1708 -1 1709 case 'message': -1 1710 this.emit('data', packet.data); -1 1711 this.emit('message', packet.data); -1 1712 break; -1 1713 } -1 1714 } else { -1 1715 debug('packet received with socket readyState "%s"', this.readyState); -1 1716 } -1 1717 }; 1532 1718 1533 1719 /**1534 -1 * Exports parser1535 -1 *1536 -1 * @api public-1 1720 * Called upon handshake completion. 1537 1721 * -1 1722 * @param {Object} handshake obj -1 1723 * @api private 1538 1724 */1539 -1 module.exports.parser = require('engine.io-parser');1540 17251541 -1 },{"./socket":16,"engine.io-parser":24}],16:[function(require,module,exports){1542 -1 (function (global){1543 -1 /**1544 -1 * Module dependencies.1545 -1 */-1 1726 Socket.prototype.onHandshake = function (data) { -1 1727 this.emit('handshake', data); -1 1728 this.id = data.sid; -1 1729 this.transport.query.sid = data.sid; -1 1730 this.upgrades = this.filterUpgrades(data.upgrades); -1 1731 this.pingInterval = data.pingInterval; -1 1732 this.pingTimeout = data.pingTimeout; -1 1733 this.onOpen(); -1 1734 // In case open handler closes socket -1 1735 if ('closed' === this.readyState) return; -1 1736 this.setPing(); 1546 17371547 -1 var transports = require('./transports');1548 -1 var Emitter = require('component-emitter');1549 -1 var debug = require('debug')('engine.io-client:socket');1550 -1 var index = require('indexof');1551 -1 var parser = require('engine.io-parser');1552 -1 var parseuri = require('parseuri');1553 -1 var parsejson = require('parsejson');1554 -1 var parseqs = require('parseqs');-1 1738 // Prolong liveness of socket on heartbeat -1 1739 this.removeListener('heartbeat', this.onHeartbeat); -1 1740 this.on('heartbeat', this.onHeartbeat); -1 1741 }; 1555 1742 1556 1743 /**1557 -1 * Module exports.-1 1744 * Resets ping timeout. -1 1745 * -1 1746 * @api private 1558 1747 */ 1559 17481560 -1 module.exports = Socket;-1 1749 Socket.prototype.onHeartbeat = function (timeout) { -1 1750 clearTimeout(this.pingTimeoutTimer); -1 1751 var self = this; -1 1752 self.pingTimeoutTimer = setTimeout(function () { -1 1753 if ('closed' === self.readyState) return; -1 1754 self.onClose('ping timeout'); -1 1755 }, timeout || (self.pingInterval + self.pingTimeout)); -1 1756 }; 1561 1757 1562 1758 /**1563 -1 * Noop function.-1 1759 * Pings server every `this.pingInterval` and expects response -1 1760 * within `this.pingTimeout` or closes connection. 1564 1761 * 1565 1762 * @api private 1566 1763 */ 1567 17641568 -1 function noop(){}-1 1765 Socket.prototype.setPing = function () { -1 1766 var self = this; -1 1767 clearTimeout(self.pingIntervalTimer); -1 1768 self.pingIntervalTimer = setTimeout(function () { -1 1769 debug('writing ping packet - expecting pong within %sms', self.pingTimeout); -1 1770 self.ping(); -1 1771 self.onHeartbeat(self.pingTimeout); -1 1772 }, self.pingInterval); -1 1773 }; 1569 1774 1570 1775 /**1571 -1 * Socket constructor.-1 1776 * Sends a ping packet. -1 1777 * -1 1778 * @api private -1 1779 */ -1 1780 -1 1781 Socket.prototype.ping = function () { -1 1782 var self = this; -1 1783 this.sendPacket('ping', function () { -1 1784 self.emit('ping'); -1 1785 }); -1 1786 }; -1 1787 -1 1788 /** -1 1789 * Called on `drain` event 1572 1790 *1573 -1 * @param {String|Object} uri or options1574 -1 * @param {Object} options1575 -1 * @api public-1 1791 * @api private 1576 1792 */ 1577 17931578 -1 function Socket(uri, opts){1579 -1 if (!(this instanceof Socket)) return new Socket(uri, opts);1580 -11581 -1 opts = opts || {};-1 1794 Socket.prototype.onDrain = function () { -1 1795 this.writeBuffer.splice(0, this.prevBufferLen); 1582 17961583 -1 if (uri && 'object' == typeof uri) {1584 -1 opts = uri;1585 -1 uri = null;1586 -1 }-1 1797 // setting prevBufferLen = 0 is very important -1 1798 // for example, when upgrading, upgrade packet is sent over, -1 1799 // and a nonzero prevBufferLen could cause problems on `drain` -1 1800 this.prevBufferLen = 0; 1587 18011588 -1 if (uri) {1589 -1 uri = parseuri(uri);1590 -1 opts.hostname = uri.host;1591 -1 opts.secure = uri.protocol == 'https' || uri.protocol == 'wss';1592 -1 opts.port = uri.port;1593 -1 if (uri.query) opts.query = uri.query;1594 -1 } else if (opts.host) {1595 -1 opts.hostname = parseuri(opts.host).host;-1 1802 if (0 === this.writeBuffer.length) { -1 1803 this.emit('drain'); -1 1804 } else { -1 1805 this.flush(); 1596 1806 }1597 -11598 -1 this.secure = null != opts.secure ? opts.secure :1599 -1 (global.location && 'https:' == location.protocol);1600 -11601 -1 if (opts.hostname && !opts.port) {1602 -1 // if no port is specified manually, use the protocol default1603 -1 opts.port = this.secure ? '443' : '80';1604 -1 }1605 -11606 -1 this.agent = opts.agent || false;1607 -1 this.hostname = opts.hostname ||1608 -1 (global.location ? location.hostname : 'localhost');1609 -1 this.port = opts.port || (global.location && location.port ?1610 -1 location.port :1611 -1 (this.secure ? 443 : 80));1612 -1 this.query = opts.query || {};1613 -1 if ('string' == typeof this.query) this.query = parseqs.decode(this.query);1614 -1 this.upgrade = false !== opts.upgrade;1615 -1 this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';1616 -1 this.forceJSONP = !!opts.forceJSONP;1617 -1 this.jsonp = false !== opts.jsonp;1618 -1 this.forceBase64 = !!opts.forceBase64;1619 -1 this.enablesXDR = !!opts.enablesXDR;1620 -1 this.timestampParam = opts.timestampParam || 't';1621 -1 this.timestampRequests = opts.timestampRequests;1622 -1 this.transports = opts.transports || ['polling', 'websocket'];1623 -1 this.readyState = '';1624 -1 this.writeBuffer = [];1625 -1 this.policyPort = opts.policyPort || 843;1626 -1 this.rememberUpgrade = opts.rememberUpgrade || false;1627 -1 this.binaryType = null;1628 -1 this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;1629 -1 this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false;1630 -11631 -1 if (true === this.perMessageDeflate) this.perMessageDeflate = {};1632 -1 if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {1633 -1 this.perMessageDeflate.threshold = 1024;1634 -1 }1635 -11636 -1 // SSL options for Node.js client1637 -1 this.pfx = opts.pfx || null;1638 -1 this.key = opts.key || null;1639 -1 this.passphrase = opts.passphrase || null;1640 -1 this.cert = opts.cert || null;1641 -1 this.ca = opts.ca || null;1642 -1 this.ciphers = opts.ciphers || null;1643 -1 this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized;1644 -11645 -1 // other options for Node.js client1646 -1 var freeGlobal = typeof global == 'object' && global;1647 -1 if (freeGlobal.global === freeGlobal) {1648 -1 if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {1649 -1 this.extraHeaders = opts.extraHeaders;1650 -1 }1651 -1 }1652 -11653 -1 this.open();1654 -1 }1655 -11656 -1 Socket.priorWebsocketSuccess = false;-1 1807 }; 1657 1808 1658 1809 /**1659 -1 * Mix in `Emitter`.-1 1810 * Flush write buffers. -1 1811 * -1 1812 * @api private 1660 1813 */ 1661 18141662 -1 Emitter(Socket.prototype);-1 1815 Socket.prototype.flush = function () { -1 1816 if ('closed' !== this.readyState && this.transport.writable && -1 1817 !this.upgrading && this.writeBuffer.length) { -1 1818 debug('flushing %d packets in socket', this.writeBuffer.length); -1 1819 this.transport.send(this.writeBuffer); -1 1820 // keep track of current length of writeBuffer -1 1821 // splice writeBuffer and callbackBuffer on `drain` -1 1822 this.prevBufferLen = this.writeBuffer.length; -1 1823 this.emit('flush'); -1 1824 } -1 1825 }; 1663 1826 1664 1827 /**1665 -1 * Protocol version.-1 1828 * Sends a message. 1666 1829 * -1 1830 * @param {String} message. -1 1831 * @param {Function} callback function. -1 1832 * @param {Object} options. -1 1833 * @return {Socket} for chaining. 1667 1834 * @api public 1668 1835 */ 1669 18361670 -1 Socket.protocol = parser.protocol; // this is an int1671 -11672 -1 /**1673 -1 * Expose deps for legacy compatibility1674 -1 * and standalone browser access.1675 -1 */1676 -11677 -1 Socket.Socket = Socket;1678 -1 Socket.Transport = require('./transport');1679 -1 Socket.transports = require('./transports');1680 -1 Socket.parser = require('engine.io-parser');-1 1837 Socket.prototype.write = -1 1838 Socket.prototype.send = function (msg, options, fn) { -1 1839 this.sendPacket('message', msg, options, fn); -1 1840 return this; -1 1841 }; 1681 1842 1682 1843 /**1683 -1 * Creates transport of the given type.-1 1844 * Sends a packet. 1684 1845 *1685 -1 * @param {String} transport name1686 -1 * @return {Transport}-1 1846 * @param {String} packet type. -1 1847 * @param {String} data. -1 1848 * @param {Object} options. -1 1849 * @param {Function} callback function. 1687 1850 * @api private 1688 1851 */ 1689 18521690 -1 Socket.prototype.createTransport = function (name) {1691 -1 debug('creating transport "%s"', name);1692 -1 var query = clone(this.query);1693 -11694 -1 // append engine.io protocol identifier1695 -1 query.EIO = parser.protocol;-1 1853 Socket.prototype.sendPacket = function (type, data, options, fn) { -1 1854 if ('function' === typeof data) { -1 1855 fn = data; -1 1856 data = undefined; -1 1857 } 1696 18581697 -1 // transport name1698 -1 query.transport = name;-1 1859 if ('function' === typeof options) { -1 1860 fn = options; -1 1861 options = null; -1 1862 } 1699 18631700 -1 // session id if we already have one1701 -1 if (this.id) query.sid = this.id;-1 1864 if ('closing' === this.readyState || 'closed' === this.readyState) { -1 1865 return; -1 1866 } 1702 18671703 -1 var transport = new transports[name]({1704 -1 agent: this.agent,1705 -1 hostname: this.hostname,1706 -1 port: this.port,1707 -1 secure: this.secure,1708 -1 path: this.path,1709 -1 query: query,1710 -1 forceJSONP: this.forceJSONP,1711 -1 jsonp: this.jsonp,1712 -1 forceBase64: this.forceBase64,1713 -1 enablesXDR: this.enablesXDR,1714 -1 timestampRequests: this.timestampRequests,1715 -1 timestampParam: this.timestampParam,1716 -1 policyPort: this.policyPort,1717 -1 socket: this,1718 -1 pfx: this.pfx,1719 -1 key: this.key,1720 -1 passphrase: this.passphrase,1721 -1 cert: this.cert,1722 -1 ca: this.ca,1723 -1 ciphers: this.ciphers,1724 -1 rejectUnauthorized: this.rejectUnauthorized,1725 -1 perMessageDeflate: this.perMessageDeflate,1726 -1 extraHeaders: this.extraHeaders1727 -1 });-1 1868 options = options || {}; -1 1869 options.compress = false !== options.compress; 1728 18701729 -1 return transport;-1 1871 var packet = { -1 1872 type: type, -1 1873 data: data, -1 1874 options: options -1 1875 }; -1 1876 this.emit('packetCreate', packet); -1 1877 this.writeBuffer.push(packet); -1 1878 if (fn) this.once('flush', fn); -1 1879 this.flush(); 1730 1880 }; 1731 18811732 -1 function clone (obj) {1733 -1 var o = {};1734 -1 for (var i in obj) {1735 -1 if (obj.hasOwnProperty(i)) {1736 -1 o[i] = obj[i];1737 -1 }1738 -1 }1739 -1 return o;1740 -1 }1741 -11742 1882 /**1743 -1 * Initializes transport to use and starts probe.-1 1883 * Closes the connection. 1744 1884 * 1745 1885 * @api private 1746 1886 */1747 -1 Socket.prototype.open = function () {1748 -1 var transport;1749 -1 if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {1750 -1 transport = 'websocket';1751 -1 } else if (0 === this.transports.length) {1752 -1 // Emit error on next tick so it can be listened to-1 1887 -1 1888 Socket.prototype.close = function () { -1 1889 if ('opening' === this.readyState || 'open' === this.readyState) { -1 1890 this.readyState = 'closing'; -1 1891 1753 1892 var self = this;1754 -1 setTimeout(function() {1755 -1 self.emit('error', 'No transports available');1756 -1 }, 0);1757 -1 return;1758 -1 } else {1759 -1 transport = this.transports[0];-1 1893 -1 1894 if (this.writeBuffer.length) { -1 1895 this.once('drain', function () { -1 1896 if (this.upgrading) { -1 1897 waitForUpgrade(); -1 1898 } else { -1 1899 close(); -1 1900 } -1 1901 }); -1 1902 } else if (this.upgrading) { -1 1903 waitForUpgrade(); -1 1904 } else { -1 1905 close(); -1 1906 } 1760 1907 }1761 -1 this.readyState = 'opening';1762 19081763 -1 // Retry with the next transport if the transport is disabled (jsonp: false)1764 -1 try {1765 -1 transport = this.createTransport(transport);1766 -1 } catch (e) {1767 -1 this.transports.shift();1768 -1 this.open();1769 -1 return;-1 1909 function close () { -1 1910 self.onClose('forced close'); -1 1911 debug('socket closing - telling transport to close'); -1 1912 self.transport.close(); 1770 1913 } 1771 19141772 -1 transport.open();1773 -1 this.setTransport(transport);-1 1915 function cleanupAndClose () { -1 1916 self.removeListener('upgrade', cleanupAndClose); -1 1917 self.removeListener('upgradeError', cleanupAndClose); -1 1918 close(); -1 1919 } -1 1920 -1 1921 function waitForUpgrade () { -1 1922 // wait for upgrade to finish since we can't send packets while pausing a transport -1 1923 self.once('upgrade', cleanupAndClose); -1 1924 self.once('upgradeError', cleanupAndClose); -1 1925 } -1 1926 -1 1927 return this; 1774 1928 }; 1775 1929 1776 1930 /**1777 -1 * Sets the current transport. Disables the existing one (if any).-1 1931 * Called upon transport error 1778 1932 * 1779 1933 * @api private 1780 1934 */ 1781 19351782 -1 Socket.prototype.setTransport = function(transport){1783 -1 debug('setting transport %s', transport.name);1784 -1 var self = this;1785 -11786 -1 if (this.transport) {1787 -1 debug('clearing existing transport %s', this.transport.name);1788 -1 this.transport.removeAllListeners();1789 -1 }1790 -11791 -1 // set up transport1792 -1 this.transport = transport;1793 -11794 -1 // set up transport listeners1795 -1 transport1796 -1 .on('drain', function(){1797 -1 self.onDrain();1798 -1 })1799 -1 .on('packet', function(packet){1800 -1 self.onPacket(packet);1801 -1 })1802 -1 .on('error', function(e){1803 -1 self.onError(e);1804 -1 })1805 -1 .on('close', function(){1806 -1 self.onClose('transport close');1807 -1 });-1 1936 Socket.prototype.onError = function (err) { -1 1937 debug('socket error %j', err); -1 1938 Socket.priorWebsocketSuccess = false; -1 1939 this.emit('error', err); -1 1940 this.onClose('transport error', err); 1808 1941 }; 1809 1942 1810 1943 /**1811 -1 * Probes a transport.-1 1944 * Called upon transport close. 1812 1945 *1813 -1 * @param {String} transport name1814 1946 * @api private 1815 1947 */ 1816 19481817 -1 Socket.prototype.probe = function (name) {1818 -1 debug('probing transport "%s"', name);1819 -1 var transport = this.createTransport(name, { probe: 1 })1820 -1 , failed = false1821 -1 , self = this;-1 1949 Socket.prototype.onClose = function (reason, desc) { -1 1950 if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) { -1 1951 debug('socket close with reason: "%s"', reason); -1 1952 var self = this; 1822 19531823 -1 Socket.priorWebsocketSuccess = false;-1 1954 // clear timers -1 1955 clearTimeout(this.pingIntervalTimer); -1 1956 clearTimeout(this.pingTimeoutTimer); 1824 19571825 -1 function onTransportOpen(){1826 -1 if (self.onlyBinaryUpgrades) {1827 -1 var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;1828 -1 failed = failed || upgradeLosesBinary;1829 -1 }1830 -1 if (failed) return;-1 1958 // stop event from firing again for transport -1 1959 this.transport.removeAllListeners('close'); 1831 19601832 -1 debug('probe transport "%s" opened', name);1833 -1 transport.send([{ type: 'ping', data: 'probe' }]);1834 -1 transport.once('packet', function (msg) {1835 -1 if (failed) return;1836 -1 if ('pong' == msg.type && 'probe' == msg.data) {1837 -1 debug('probe transport "%s" pong', name);1838 -1 self.upgrading = true;1839 -1 self.emit('upgrading', transport);1840 -1 if (!transport) return;1841 -1 Socket.priorWebsocketSuccess = 'websocket' == transport.name;-1 1961 // ensure transport won't stay open -1 1962 this.transport.close(); 1842 19631843 -1 debug('pausing current transport "%s"', self.transport.name);1844 -1 self.transport.pause(function () {1845 -1 if (failed) return;1846 -1 if ('closed' == self.readyState) return;1847 -1 debug('changing transport and sending upgrade packet');-1 1964 // ignore further transport communication -1 1965 this.transport.removeAllListeners(); 1848 19661849 -1 cleanup();-1 1967 // set ready state -1 1968 this.readyState = 'closed'; 1850 19691851 -1 self.setTransport(transport);1852 -1 transport.send([{ type: 'upgrade' }]);1853 -1 self.emit('upgrade', transport);1854 -1 transport = null;1855 -1 self.upgrading = false;1856 -1 self.flush();1857 -1 });1858 -1 } else {1859 -1 debug('probe transport "%s" failed', name);1860 -1 var err = new Error('probe error');1861 -1 err.transport = transport.name;1862 -1 self.emit('upgradeError', err);1863 -1 }1864 -1 });1865 -1 }-1 1970 // clear session id -1 1971 this.id = null; 1866 19721867 -1 function freezeTransport() {1868 -1 if (failed) return;-1 1973 // emit close event -1 1974 this.emit('close', reason, desc); 1869 19751870 -1 // Any callback called by transport should be ignored since now1871 -1 failed = true;-1 1976 // clean buffers after, so users can still -1 1977 // grab the buffers on `close` event -1 1978 self.writeBuffer = []; -1 1979 self.prevBufferLen = 0; -1 1980 } -1 1981 }; 1872 19821873 -1 cleanup();-1 1983 /** -1 1984 * Filters upgrades, returning only those matching client transports. -1 1985 * -1 1986 * @param {Array} server upgrades -1 1987 * @api private -1 1988 * -1 1989 */ 1874 19901875 -1 transport.close();1876 -1 transport = null;-1 1991 Socket.prototype.filterUpgrades = function (upgrades) { -1 1992 var filteredUpgrades = []; -1 1993 for (var i = 0, j = upgrades.length; i < j; i++) { -1 1994 if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]); 1877 1995 } -1 1996 return filteredUpgrades; -1 1997 }; 1878 19981879 -1 //Handle any error that happens while probing1880 -1 function onerror(err) {1881 -1 var error = new Error('probe error: ' + err);1882 -1 error.transport = transport.name;-1 1999 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 2000 },{"./transport":15,"./transports/index":16,"component-emitter":22,"debug":23,"engine.io-parser":26,"indexof":31,"parsejson":93,"parseqs":94,"parseuri":95}],15:[function(require,module,exports){ -1 2001 /** -1 2002 * Module dependencies. -1 2003 */ 1883 20041884 -1 freezeTransport();-1 2005 var parser = require('engine.io-parser'); -1 2006 var Emitter = require('component-emitter'); 1885 20071886 -1 debug('probe transport "%s" failed because of error: %s', name, err);-1 2008 /** -1 2009 * Module exports. -1 2010 */ 1887 20111888 -1 self.emit('upgradeError', error);1889 -1 }-1 2012 module.exports = Transport; 1890 20131891 -1 function onTransportClose(){1892 -1 onerror("transport closed");1893 -1 }-1 2014 /** -1 2015 * Transport abstract constructor. -1 2016 * -1 2017 * @param {Object} options. -1 2018 * @api private -1 2019 */ 1894 20201895 -1 //When the socket is closed while we're probing1896 -1 function onclose(){1897 -1 onerror("socket closed");1898 -1 }-1 2021 function Transport (opts) { -1 2022 this.path = opts.path; -1 2023 this.hostname = opts.hostname; -1 2024 this.port = opts.port; -1 2025 this.secure = opts.secure; -1 2026 this.query = opts.query; -1 2027 this.timestampParam = opts.timestampParam; -1 2028 this.timestampRequests = opts.timestampRequests; -1 2029 this.readyState = ''; -1 2030 this.agent = opts.agent || false; -1 2031 this.socket = opts.socket; -1 2032 this.enablesXDR = opts.enablesXDR; 1899 20331900 -1 //When the socket is upgraded while we're probing1901 -1 function onupgrade(to){1902 -1 if (transport && to.name != transport.name) {1903 -1 debug('"%s" works - aborting "%s"', to.name, transport.name);1904 -1 freezeTransport();1905 -1 }1906 -1 }-1 2034 // SSL options for Node.js client -1 2035 this.pfx = opts.pfx; -1 2036 this.key = opts.key; -1 2037 this.passphrase = opts.passphrase; -1 2038 this.cert = opts.cert; -1 2039 this.ca = opts.ca; -1 2040 this.ciphers = opts.ciphers; -1 2041 this.rejectUnauthorized = opts.rejectUnauthorized; -1 2042 this.forceNode = opts.forceNode; 1907 20431908 -1 //Remove all listeners on the transport and on self1909 -1 function cleanup(){1910 -1 transport.removeListener('open', onTransportOpen);1911 -1 transport.removeListener('error', onerror);1912 -1 transport.removeListener('close', onTransportClose);1913 -1 self.removeListener('close', onclose);1914 -1 self.removeListener('upgrading', onupgrade);1915 -1 }-1 2044 // other options for Node.js client -1 2045 this.extraHeaders = opts.extraHeaders; -1 2046 this.localAddress = opts.localAddress; -1 2047 } 1916 20481917 -1 transport.once('open', onTransportOpen);1918 -1 transport.once('error', onerror);1919 -1 transport.once('close', onTransportClose);-1 2049 /** -1 2050 * Mix in `Emitter`. -1 2051 */ 1920 20521921 -1 this.once('close', onclose);1922 -1 this.once('upgrading', onupgrade);-1 2053 Emitter(Transport.prototype); 1923 20541924 -1 transport.open();-1 2055 /** -1 2056 * Emits an error. -1 2057 * -1 2058 * @param {String} str -1 2059 * @return {Transport} for chaining -1 2060 * @api public -1 2061 */ 1925 2062 -1 2063 Transport.prototype.onError = function (msg, desc) { -1 2064 var err = new Error(msg); -1 2065 err.type = 'TransportError'; -1 2066 err.description = desc; -1 2067 this.emit('error', err); -1 2068 return this; 1926 2069 }; 1927 2070 1928 2071 /**1929 -1 * Called when connection is deemed open.-1 2072 * Opens the transport. 1930 2073 * 1931 2074 * @api public 1932 2075 */ 1933 20761934 -1 Socket.prototype.onOpen = function () {1935 -1 debug('socket open');1936 -1 this.readyState = 'open';1937 -1 Socket.priorWebsocketSuccess = 'websocket' == this.transport.name;1938 -1 this.emit('open');1939 -1 this.flush();1940 -11941 -1 // we check for `readyState` in case an `open`1942 -1 // listener already closed the socket1943 -1 if ('open' == this.readyState && this.upgrade && this.transport.pause) {1944 -1 debug('starting upgrade probes');1945 -1 for (var i = 0, l = this.upgrades.length; i < l; i++) {1946 -1 this.probe(this.upgrades[i]);1947 -1 }-1 2077 Transport.prototype.open = function () { -1 2078 if ('closed' === this.readyState || '' === this.readyState) { -1 2079 this.readyState = 'opening'; -1 2080 this.doOpen(); 1948 2081 } -1 2082 -1 2083 return this; 1949 2084 }; 1950 2085 1951 2086 /**1952 -1 * Handles a packet.-1 2087 * Closes the transport. 1953 2088 * 1954 2089 * @api private 1955 2090 */ 1956 20911957 -1 Socket.prototype.onPacket = function (packet) {1958 -1 if ('opening' == this.readyState || 'open' == this.readyState) {1959 -1 debug('socket receive: type "%s", data "%s"', packet.type, packet.data);1960 -11961 -1 this.emit('packet', packet);1962 -11963 -1 // Socket is live - any packet counts1964 -1 this.emit('heartbeat');1965 -11966 -1 switch (packet.type) {1967 -1 case 'open':1968 -1 this.onHandshake(parsejson(packet.data));1969 -1 break;-1 2092 Transport.prototype.close = function () { -1 2093 if ('opening' === this.readyState || 'open' === this.readyState) { -1 2094 this.doClose(); -1 2095 this.onClose(); -1 2096 } 1970 20971971 -1 case 'pong':1972 -1 this.setPing();1973 -1 this.emit('pong');1974 -1 break;-1 2098 return this; -1 2099 }; 1975 21001976 -1 case 'error':1977 -1 var err = new Error('server error');1978 -1 err.code = packet.data;1979 -1 this.onError(err);1980 -1 break;-1 2101 /** -1 2102 * Sends multiple packets. -1 2103 * -1 2104 * @param {Array} packets -1 2105 * @api private -1 2106 */ 1981 21071982 -1 case 'message':1983 -1 this.emit('data', packet.data);1984 -1 this.emit('message', packet.data);1985 -1 break;1986 -1 }-1 2108 Transport.prototype.send = function (packets) { -1 2109 if ('open' === this.readyState) { -1 2110 this.write(packets); 1987 2111 } else {1988 -1 debug('packet received with socket readyState "%s"', this.readyState);-1 2112 throw new Error('Transport not open'); 1989 2113 } 1990 2114 }; 1991 2115 1992 2116 /**1993 -1 * Called upon handshake completion.-1 2117 * Called upon open 1994 2118 *1995 -1 * @param {Object} handshake obj1996 2119 * @api private 1997 2120 */ 1998 21211999 -1 Socket.prototype.onHandshake = function (data) {2000 -1 this.emit('handshake', data);2001 -1 this.id = data.sid;2002 -1 this.transport.query.sid = data.sid;2003 -1 this.upgrades = this.filterUpgrades(data.upgrades);2004 -1 this.pingInterval = data.pingInterval;2005 -1 this.pingTimeout = data.pingTimeout;2006 -1 this.onOpen();2007 -1 // In case open handler closes socket2008 -1 if ('closed' == this.readyState) return;2009 -1 this.setPing();2010 -12011 -1 // Prolong liveness of socket on heartbeat2012 -1 this.removeListener('heartbeat', this.onHeartbeat);2013 -1 this.on('heartbeat', this.onHeartbeat);-1 2122 Transport.prototype.onOpen = function () { -1 2123 this.readyState = 'open'; -1 2124 this.writable = true; -1 2125 this.emit('open'); 2014 2126 }; 2015 2127 2016 2128 /**2017 -1 * Resets ping timeout.-1 2129 * Called with data. 2018 2130 * -1 2131 * @param {String} data 2019 2132 * @api private 2020 2133 */ 2021 21342022 -1 Socket.prototype.onHeartbeat = function (timeout) {2023 -1 clearTimeout(this.pingTimeoutTimer);2024 -1 var self = this;2025 -1 self.pingTimeoutTimer = setTimeout(function () {2026 -1 if ('closed' == self.readyState) return;2027 -1 self.onClose('ping timeout');2028 -1 }, timeout || (self.pingInterval + self.pingTimeout));-1 2135 Transport.prototype.onData = function (data) { -1 2136 var packet = parser.decodePacket(data, this.socket.binaryType); -1 2137 this.onPacket(packet); 2029 2138 }; 2030 2139 2031 2140 /**2032 -1 * Pings server every `this.pingInterval` and expects response2033 -1 * within `this.pingTimeout` or closes connection.2034 -1 *2035 -1 * @api private-1 2141 * Called with a decoded packet. 2036 2142 */ 2037 21432038 -1 Socket.prototype.setPing = function () {2039 -1 var self = this;2040 -1 clearTimeout(self.pingIntervalTimer);2041 -1 self.pingIntervalTimer = setTimeout(function () {2042 -1 debug('writing ping packet - expecting pong within %sms', self.pingTimeout);2043 -1 self.ping();2044 -1 self.onHeartbeat(self.pingTimeout);2045 -1 }, self.pingInterval);-1 2144 Transport.prototype.onPacket = function (packet) { -1 2145 this.emit('packet', packet); 2046 2146 }; 2047 2147 2048 2148 /**2049 -1 * Sends a ping packet.2050 -1 *2051 -1 * @api private2052 -1 */2053 -12054 -1 Socket.prototype.ping = function () {2055 -1 var self = this;2056 -1 this.sendPacket('ping', function(){2057 -1 self.emit('ping');2058 -1 });2059 -1 };2060 -12061 -1 /**2062 -1 * Called on `drain` event-1 2149 * Called upon close. 2063 2150 * 2064 2151 * @api private 2065 2152 */ 2066 21532067 -1 Socket.prototype.onDrain = function() {2068 -1 this.writeBuffer.splice(0, this.prevBufferLen);2069 -12070 -1 // setting prevBufferLen = 0 is very important2071 -1 // for example, when upgrading, upgrade packet is sent over,2072 -1 // and a nonzero prevBufferLen could cause problems on `drain`2073 -1 this.prevBufferLen = 0;2074 -12075 -1 if (0 === this.writeBuffer.length) {2076 -1 this.emit('drain');2077 -1 } else {2078 -1 this.flush();2079 -1 }-1 2154 Transport.prototype.onClose = function () { -1 2155 this.readyState = 'closed'; -1 2156 this.emit('close'); 2080 2157 }; 2081 2158 -1 2159 },{"component-emitter":22,"engine.io-parser":26}],16:[function(require,module,exports){ -1 2160 (function (global){ 2082 2161 /**2083 -1 * Flush write buffers.2084 -1 *2085 -1 * @api private-1 2162 * Module dependencies 2086 2163 */ 2087 21642088 -1 Socket.prototype.flush = function () {2089 -1 if ('closed' != this.readyState && this.transport.writable &&2090 -1 !this.upgrading && this.writeBuffer.length) {2091 -1 debug('flushing %d packets in socket', this.writeBuffer.length);2092 -1 this.transport.send(this.writeBuffer);2093 -1 // keep track of current length of writeBuffer2094 -1 // splice writeBuffer and callbackBuffer on `drain`2095 -1 this.prevBufferLen = this.writeBuffer.length;2096 -1 this.emit('flush');2097 -1 }2098 -1 };-1 2165 var XMLHttpRequest = require('xmlhttprequest-ssl'); -1 2166 var XHR = require('./polling-xhr'); -1 2167 var JSONP = require('./polling-jsonp'); -1 2168 var websocket = require('./websocket'); 2099 2169 2100 2170 /**2101 -1 * Sends a message.2102 -1 *2103 -1 * @param {String} message.2104 -1 * @param {Function} callback function.2105 -1 * @param {Object} options.2106 -1 * @return {Socket} for chaining.2107 -1 * @api public-1 2171 * Export transports. 2108 2172 */ 2109 21732110 -1 Socket.prototype.write =2111 -1 Socket.prototype.send = function (msg, options, fn) {2112 -1 this.sendPacket('message', msg, options, fn);2113 -1 return this;2114 -1 };-1 2174 exports.polling = polling; -1 2175 exports.websocket = websocket; 2115 2176 2116 2177 /**2117 -1 * Sends a packet.-1 2178 * Polling transport polymorphic constructor. -1 2179 * Decides on xhr vs jsonp based on feature detection. 2118 2180 *2119 -1 * @param {String} packet type.2120 -1 * @param {String} data.2121 -1 * @param {Object} options.2122 -1 * @param {Function} callback function.2123 2181 * @api private 2124 2182 */ 2125 21832126 -1 Socket.prototype.sendPacket = function (type, data, options, fn) {2127 -1 if('function' == typeof data) {2128 -1 fn = data;2129 -1 data = undefined;2130 -1 }-1 2184 function polling (opts) { -1 2185 var xhr; -1 2186 var xd = false; -1 2187 var xs = false; -1 2188 var jsonp = false !== opts.jsonp; 2131 21892132 -1 if ('function' == typeof options) {2133 -1 fn = options;2134 -1 options = null;2135 -1 }-1 2190 if (global.location) { -1 2191 var isSSL = 'https:' === location.protocol; -1 2192 var port = location.port; 2136 21932137 -1 if ('closing' == this.readyState || 'closed' == this.readyState) {2138 -1 return;-1 2194 // some user agents have empty `location.port` -1 2195 if (!port) { -1 2196 port = isSSL ? 443 : 80; -1 2197 } -1 2198 -1 2199 xd = opts.hostname !== location.hostname || port !== opts.port; -1 2200 xs = opts.secure !== isSSL; 2139 2201 } 2140 22022141 -1 options = options || {};2142 -1 options.compress = false !== options.compress;-1 2203 opts.xdomain = xd; -1 2204 opts.xscheme = xs; -1 2205 xhr = new XMLHttpRequest(opts); 2143 22062144 -1 var packet = {2145 -1 type: type,2146 -1 data: data,2147 -1 options: options2148 -1 };2149 -1 this.emit('packetCreate', packet);2150 -1 this.writeBuffer.push(packet);2151 -1 if (fn) this.once('flush', fn);2152 -1 this.flush();2153 -1 };-1 2207 if ('open' in xhr && !opts.forceJSONP) { -1 2208 return new XHR(opts); -1 2209 } else { -1 2210 if (!jsonp) throw new Error('JSONP disabled'); -1 2211 return new JSONP(opts); -1 2212 } -1 2213 } -1 2214 -1 2215 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 2216 },{"./polling-jsonp":17,"./polling-xhr":18,"./websocket":20,"xmlhttprequest-ssl":21}],17:[function(require,module,exports){ -1 2217 (function (global){ 2154 2218 2155 2219 /**2156 -1 * Closes the connection.2157 -1 *2158 -1 * @api private-1 2220 * Module requirements. 2159 2221 */ 2160 22222161 -1 Socket.prototype.close = function () {2162 -1 if ('opening' == this.readyState || 'open' == this.readyState) {2163 -1 this.readyState = 'closing';-1 2223 var Polling = require('./polling'); -1 2224 var inherit = require('component-inherit'); 2164 22252165 -1 var self = this;-1 2226 /** -1 2227 * Module exports. -1 2228 */ 2166 22292167 -1 if (this.writeBuffer.length) {2168 -1 this.once('drain', function() {2169 -1 if (this.upgrading) {2170 -1 waitForUpgrade();2171 -1 } else {2172 -1 close();2173 -1 }2174 -1 });2175 -1 } else if (this.upgrading) {2176 -1 waitForUpgrade();2177 -1 } else {2178 -1 close();2179 -1 }2180 -1 }-1 2230 module.exports = JSONPPolling; 2181 22312182 -1 function close() {2183 -1 self.onClose('forced close');2184 -1 debug('socket closing - telling transport to close');2185 -1 self.transport.close();2186 -1 }-1 2232 /** -1 2233 * Cached regular expressions. -1 2234 */ 2187 22352188 -1 function cleanupAndClose() {2189 -1 self.removeListener('upgrade', cleanupAndClose);2190 -1 self.removeListener('upgradeError', cleanupAndClose);2191 -1 close();2192 -1 }-1 2236 var rNewline = /\n/g; -1 2237 var rEscapedNewline = /\\n/g; 2193 22382194 -1 function waitForUpgrade() {2195 -1 // wait for upgrade to finish since we can't send packets while pausing a transport2196 -1 self.once('upgrade', cleanupAndClose);2197 -1 self.once('upgradeError', cleanupAndClose);2198 -1 }-1 2239 /** -1 2240 * Global JSONP callbacks. -1 2241 */ 2199 22422200 -1 return this;2201 -1 };-1 2243 var callbacks; 2202 2244 2203 2245 /**2204 -1 * Called upon transport error2205 -1 *2206 -1 * @api private-1 2246 * Noop. 2207 2247 */ 2208 22482209 -1 Socket.prototype.onError = function (err) {2210 -1 debug('socket error %j', err);2211 -1 Socket.priorWebsocketSuccess = false;2212 -1 this.emit('error', err);2213 -1 this.onClose('transport error', err);2214 -1 };-1 2249 function empty () { } 2215 2250 2216 2251 /**2217 -1 * Called upon transport close.-1 2252 * JSONP Polling constructor. 2218 2253 *2219 -1 * @api private-1 2254 * @param {Object} opts. -1 2255 * @api public 2220 2256 */ 2221 22572222 -1 Socket.prototype.onClose = function (reason, desc) {2223 -1 if ('opening' == this.readyState || 'open' == this.readyState || 'closing' == this.readyState) {2224 -1 debug('socket close with reason: "%s"', reason);2225 -1 var self = this;2226 -12227 -1 // clear timers2228 -1 clearTimeout(this.pingIntervalTimer);2229 -1 clearTimeout(this.pingTimeoutTimer);2230 -12231 -1 // stop event from firing again for transport2232 -1 this.transport.removeAllListeners('close');-1 2258 function JSONPPolling (opts) { -1 2259 Polling.call(this, opts); 2233 22602234 -1 // ensure transport won't stay open2235 -1 this.transport.close();-1 2261 this.query = this.query || {}; 2236 22622237 -1 // ignore further transport communication2238 -1 this.transport.removeAllListeners();-1 2263 // define global callbacks array if not present -1 2264 // we do this here (lazily) to avoid unneeded global pollution -1 2265 if (!callbacks) { -1 2266 // we need to consider multiple engines in the same page -1 2267 if (!global.___eio) global.___eio = []; -1 2268 callbacks = global.___eio; -1 2269 } 2239 22702240 -1 // set ready state2241 -1 this.readyState = 'closed';-1 2271 // callback identifier -1 2272 this.index = callbacks.length; 2242 22732243 -1 // clear session id2244 -1 this.id = null;-1 2274 // add callback to jsonp global -1 2275 var self = this; -1 2276 callbacks.push(function (msg) { -1 2277 self.onData(msg); -1 2278 }); 2245 22792246 -1 // emit close event2247 -1 this.emit('close', reason, desc);-1 2280 // append to query string -1 2281 this.query.j = this.index; 2248 22822249 -1 // clean buffers after, so users can still2250 -1 // grab the buffers on `close` event2251 -1 self.writeBuffer = [];2252 -1 self.prevBufferLen = 0;-1 2283 // prevent spurious errors from being emitted when the window is unloaded -1 2284 if (global.document && global.addEventListener) { -1 2285 global.addEventListener('beforeunload', function () { -1 2286 if (self.script) self.script.onerror = empty; -1 2287 }, false); 2253 2288 }2254 -1 };-1 2289 } 2255 2290 2256 2291 /**2257 -1 * Filters upgrades, returning only those matching client transports.2258 -1 *2259 -1 * @param {Array} server upgrades2260 -1 * @api private2261 -1 *-1 2292 * Inherits from Polling. 2262 2293 */ 2263 22942264 -1 Socket.prototype.filterUpgrades = function (upgrades) {2265 -1 var filteredUpgrades = [];2266 -1 for (var i = 0, j = upgrades.length; i<j; i++) {2267 -1 if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);2268 -1 }2269 -1 return filteredUpgrades;2270 -1 };-1 2295 inherit(JSONPPolling, Polling); 2271 22962272 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})2273 -1 },{"./transport":17,"./transports":18,"component-emitter":10,"debug":12,"engine.io-parser":24,"indexof":32,"parsejson":97,"parseqs":98,"parseuri":99}],17:[function(require,module,exports){2274 -1 /**2275 -1 * Module dependencies.-1 2297 /* -1 2298 * JSONP only supports binary as base64 encoded strings 2276 2299 */ 2277 23002278 -1 var parser = require('engine.io-parser');2279 -1 var Emitter = require('component-emitter');-1 2301 JSONPPolling.prototype.supportsBinary = false; 2280 2302 2281 2303 /**2282 -1 * Module exports.-1 2304 * Closes the socket. -1 2305 * -1 2306 * @api private 2283 2307 */ 2284 23082285 -1 module.exports = Transport;2286 -12287 -1 /**2288 -1 * Transport abstract constructor.2289 -1 *2290 -1 * @param {Object} options.2291 -1 * @api private2292 -1 */2293 -12294 -1 function Transport (opts) {2295 -1 this.path = opts.path;2296 -1 this.hostname = opts.hostname;2297 -1 this.port = opts.port;2298 -1 this.secure = opts.secure;2299 -1 this.query = opts.query;2300 -1 this.timestampParam = opts.timestampParam;2301 -1 this.timestampRequests = opts.timestampRequests;2302 -1 this.readyState = '';2303 -1 this.agent = opts.agent || false;2304 -1 this.socket = opts.socket;2305 -1 this.enablesXDR = opts.enablesXDR;2306 -12307 -1 // SSL options for Node.js client2308 -1 this.pfx = opts.pfx;2309 -1 this.key = opts.key;2310 -1 this.passphrase = opts.passphrase;2311 -1 this.cert = opts.cert;2312 -1 this.ca = opts.ca;2313 -1 this.ciphers = opts.ciphers;2314 -1 this.rejectUnauthorized = opts.rejectUnauthorized;2315 -12316 -1 // other options for Node.js client2317 -1 this.extraHeaders = opts.extraHeaders;2318 -1 }-1 2309 JSONPPolling.prototype.doClose = function () { -1 2310 if (this.script) { -1 2311 this.script.parentNode.removeChild(this.script); -1 2312 this.script = null; -1 2313 } 2319 23142320 -1 /**2321 -1 * Mix in `Emitter`.2322 -1 */-1 2315 if (this.form) { -1 2316 this.form.parentNode.removeChild(this.form); -1 2317 this.form = null; -1 2318 this.iframe = null; -1 2319 } 2323 23202324 -1 Emitter(Transport.prototype);-1 2321 Polling.prototype.doClose.call(this); -1 2322 }; 2325 2323 2326 2324 /**2327 -1 * Emits an error.-1 2325 * Starts a poll cycle. 2328 2326 *2329 -1 * @param {String} str2330 -1 * @return {Transport} for chaining2331 -1 * @api public-1 2327 * @api private 2332 2328 */ 2333 23292334 -1 Transport.prototype.onError = function (msg, desc) {2335 -1 var err = new Error(msg);2336 -1 err.type = 'TransportError';2337 -1 err.description = desc;2338 -1 this.emit('error', err);2339 -1 return this;2340 -1 };-1 2330 JSONPPolling.prototype.doPoll = function () { -1 2331 var self = this; -1 2332 var script = document.createElement('script'); 2341 23332342 -1 /**2343 -1 * Opens the transport.2344 -1 *2345 -1 * @api public2346 -1 */-1 2334 if (this.script) { -1 2335 this.script.parentNode.removeChild(this.script); -1 2336 this.script = null; -1 2337 } 2347 23382348 -1 Transport.prototype.open = function () {2349 -1 if ('closed' == this.readyState || '' == this.readyState) {2350 -1 this.readyState = 'opening';2351 -1 this.doOpen();-1 2339 script.async = true; -1 2340 script.src = this.uri(); -1 2341 script.onerror = function (e) { -1 2342 self.onError('jsonp poll error', e); -1 2343 }; -1 2344 -1 2345 var insertAt = document.getElementsByTagName('script')[0]; -1 2346 if (insertAt) { -1 2347 insertAt.parentNode.insertBefore(script, insertAt); -1 2348 } else { -1 2349 (document.head || document.body).appendChild(script); 2352 2350 } -1 2351 this.script = script; 2353 23522354 -1 return this;-1 2353 var isUAgecko = 'undefined' !== typeof navigator && /gecko/i.test(navigator.userAgent); -1 2354 -1 2355 if (isUAgecko) { -1 2356 setTimeout(function () { -1 2357 var iframe = document.createElement('iframe'); -1 2358 document.body.appendChild(iframe); -1 2359 document.body.removeChild(iframe); -1 2360 }, 100); -1 2361 } 2355 2362 }; 2356 2363 2357 2364 /**2358 -1 * Closes the transport.-1 2365 * Writes with a hidden iframe. 2359 2366 * -1 2367 * @param {String} data to send -1 2368 * @param {Function} called upon flush. 2360 2369 * @api private 2361 2370 */ 2362 23712363 -1 Transport.prototype.close = function () {2364 -1 if ('opening' == this.readyState || 'open' == this.readyState) {2365 -1 this.doClose();2366 -1 this.onClose();2367 -1 }-1 2372 JSONPPolling.prototype.doWrite = function (data, fn) { -1 2373 var self = this; 2368 23742369 -1 return this;2370 -1 };-1 2375 if (!this.form) { -1 2376 var form = document.createElement('form'); -1 2377 var area = document.createElement('textarea'); -1 2378 var id = this.iframeId = 'eio_iframe_' + this.index; -1 2379 var iframe; 2371 23802372 -1 /**2373 -1 * Sends multiple packets.2374 -1 *2375 -1 * @param {Array} packets2376 -1 * @api private2377 -1 */-1 2381 form.className = 'socketio'; -1 2382 form.style.position = 'absolute'; -1 2383 form.style.top = '-1000px'; -1 2384 form.style.left = '-1000px'; -1 2385 form.target = id; -1 2386 form.method = 'POST'; -1 2387 form.setAttribute('accept-charset', 'utf-8'); -1 2388 area.name = 'd'; -1 2389 form.appendChild(area); -1 2390 document.body.appendChild(form); 2378 23912379 -1 Transport.prototype.send = function(packets){2380 -1 if ('open' == this.readyState) {2381 -1 this.write(packets);2382 -1 } else {2383 -1 throw new Error('Transport not open');-1 2392 this.form = form; -1 2393 this.area = area; 2384 2394 }2385 -1 };2386 23952387 -1 /**2388 -1 * Called upon open2389 -1 *2390 -1 * @api private2391 -1 */-1 2396 this.form.action = this.uri(); 2392 23972393 -1 Transport.prototype.onOpen = function () {2394 -1 this.readyState = 'open';2395 -1 this.writable = true;2396 -1 this.emit('open');2397 -1 };-1 2398 function complete () { -1 2399 initIframe(); -1 2400 fn(); -1 2401 } 2398 24022399 -1 /**2400 -1 * Called with data.2401 -1 *2402 -1 * @param {String} data2403 -1 * @api private2404 -1 */-1 2403 function initIframe () { -1 2404 if (self.iframe) { -1 2405 try { -1 2406 self.form.removeChild(self.iframe); -1 2407 } catch (e) { -1 2408 self.onError('jsonp polling iframe removal error', e); -1 2409 } -1 2410 } 2405 24112406 -1 Transport.prototype.onData = function(data){2407 -1 var packet = parser.decodePacket(data, this.socket.binaryType);2408 -1 this.onPacket(packet);2409 -1 };-1 2412 try { -1 2413 // ie6 dynamic iframes with target="" support (thanks Chris Lambacher) -1 2414 var html = '<iframe src="javascript:0" name="' + self.iframeId + '">'; -1 2415 iframe = document.createElement(html); -1 2416 } catch (e) { -1 2417 iframe = document.createElement('iframe'); -1 2418 iframe.name = self.iframeId; -1 2419 iframe.src = 'javascript:0'; -1 2420 } 2410 24212411 -1 /**2412 -1 * Called with a decoded packet.2413 -1 */-1 2422 iframe.id = self.iframeId; 2414 24232415 -1 Transport.prototype.onPacket = function (packet) {2416 -1 this.emit('packet', packet);2417 -1 };-1 2424 self.form.appendChild(iframe); -1 2425 self.iframe = iframe; -1 2426 } 2418 24272419 -1 /**2420 -1 * Called upon close.2421 -1 *2422 -1 * @api private2423 -1 */-1 2428 initIframe(); 2424 24292425 -1 Transport.prototype.onClose = function () {2426 -1 this.readyState = 'closed';2427 -1 this.emit('close');-1 2430 // escape \n to prevent it from being converted into \r\n by some UAs -1 2431 // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side -1 2432 data = data.replace(rEscapedNewline, '\\\n'); -1 2433 this.area.value = data.replace(rNewline, '\\n'); -1 2434 -1 2435 try { -1 2436 this.form.submit(); -1 2437 } catch (e) {} -1 2438 -1 2439 if (this.iframe.attachEvent) { -1 2440 this.iframe.onreadystatechange = function () { -1 2441 if (self.iframe.readyState === 'complete') { -1 2442 complete(); -1 2443 } -1 2444 }; -1 2445 } else { -1 2446 this.iframe.onload = complete; -1 2447 } 2428 2448 }; 2429 24492430 -1 },{"component-emitter":10,"engine.io-parser":24}],18:[function(require,module,exports){-1 2450 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 2451 },{"./polling":19,"component-inherit":11}],18:[function(require,module,exports){ 2431 2452 (function (global){ 2432 2453 /**2433 -1 * Module dependencies-1 2454 * Module requirements. 2434 2455 */ 2435 2456 2436 2457 var XMLHttpRequest = require('xmlhttprequest-ssl');2437 -1 var XHR = require('./polling-xhr');2438 -1 var JSONP = require('./polling-jsonp');2439 -1 var websocket = require('./websocket');-1 2458 var Polling = require('./polling'); -1 2459 var Emitter = require('component-emitter'); -1 2460 var inherit = require('component-inherit'); -1 2461 var debug = require('debug')('engine.io-client:polling-xhr'); 2440 2462 2441 2463 /**2442 -1 * Export transports.-1 2464 * Module exports. 2443 2465 */ 2444 24662445 -1 exports.polling = polling;2446 -1 exports.websocket = websocket;-1 2467 module.exports = XHR; -1 2468 module.exports.Request = Request; 2447 2469 2448 2470 /**2449 -1 * Polling transport polymorphic constructor.2450 -1 * Decides on xhr vs jsonp based on feature detection.-1 2471 * Empty function -1 2472 */ -1 2473 -1 2474 function empty () {} -1 2475 -1 2476 /** -1 2477 * XHR Polling constructor. 2451 2478 *2452 -1 * @api private-1 2479 * @param {Object} opts -1 2480 * @api public 2453 2481 */ 2454 24822455 -1 function polling(opts){2456 -1 var xhr;2457 -1 var xd = false;2458 -1 var xs = false;2459 -1 var jsonp = false !== opts.jsonp;-1 2483 function XHR (opts) { -1 2484 Polling.call(this, opts); -1 2485 this.requestTimeout = opts.requestTimeout; 2460 2486 2461 2487 if (global.location) {2462 -1 var isSSL = 'https:' == location.protocol;-1 2488 var isSSL = 'https:' === location.protocol; 2463 2489 var port = location.port; 2464 2490 2465 2491 // some user agents have empty `location.port` @@ -2467,921 +2493,904 @@ function polling(opts){ 2467 2493 port = isSSL ? 443 : 80; 2468 2494 } 2469 24952470 -1 xd = opts.hostname != location.hostname || port != opts.port;2471 -1 xs = opts.secure != isSSL;2472 -1 }2473 -12474 -1 opts.xdomain = xd;2475 -1 opts.xscheme = xs;2476 -1 xhr = new XMLHttpRequest(opts);2477 -12478 -1 if ('open' in xhr && !opts.forceJSONP) {2479 -1 return new XHR(opts);-1 2496 this.xd = opts.hostname !== global.location.hostname || -1 2497 port !== opts.port; -1 2498 this.xs = opts.secure !== isSSL; 2480 2499 } else {2481 -1 if (!jsonp) throw new Error('JSONP disabled');2482 -1 return new JSONP(opts);-1 2500 this.extraHeaders = opts.extraHeaders; 2483 2501 } 2484 2502 } 2485 25032486 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})2487 -1 },{"./polling-jsonp":19,"./polling-xhr":20,"./websocket":22,"xmlhttprequest-ssl":23}],19:[function(require,module,exports){2488 -1 (function (global){2489 -12490 2504 /**2491 -1 * Module requirements.-1 2505 * Inherits from Polling. 2492 2506 */ 2493 25072494 -1 var Polling = require('./polling');2495 -1 var inherit = require('component-inherit');-1 2508 inherit(XHR, Polling); 2496 2509 2497 2510 /**2498 -1 * Module exports.-1 2511 * XHR supports binary 2499 2512 */ 2500 25132501 -1 module.exports = JSONPPolling;-1 2514 XHR.prototype.supportsBinary = true; 2502 2515 2503 2516 /**2504 -1 * Cached regular expressions.-1 2517 * Creates a request. -1 2518 * -1 2519 * @param {String} method -1 2520 * @api private 2505 2521 */ 2506 25222507 -1 var rNewline = /\n/g;2508 -1 var rEscapedNewline = /\\n/g;-1 2523 XHR.prototype.request = function (opts) { -1 2524 opts = opts || {}; -1 2525 opts.uri = this.uri(); -1 2526 opts.xd = this.xd; -1 2527 opts.xs = this.xs; -1 2528 opts.agent = this.agent || false; -1 2529 opts.supportsBinary = this.supportsBinary; -1 2530 opts.enablesXDR = this.enablesXDR; 2509 25312510 -1 /**2511 -1 * Global JSONP callbacks.2512 -1 */-1 2532 // SSL options for Node.js client -1 2533 opts.pfx = this.pfx; -1 2534 opts.key = this.key; -1 2535 opts.passphrase = this.passphrase; -1 2536 opts.cert = this.cert; -1 2537 opts.ca = this.ca; -1 2538 opts.ciphers = this.ciphers; -1 2539 opts.rejectUnauthorized = this.rejectUnauthorized; -1 2540 opts.requestTimeout = this.requestTimeout; 2513 25412514 -1 var callbacks;-1 2542 // other options for Node.js client -1 2543 opts.extraHeaders = this.extraHeaders; -1 2544 -1 2545 return new Request(opts); -1 2546 }; 2515 2547 2516 2548 /**2517 -1 * Callbacks count.-1 2549 * Sends data. -1 2550 * -1 2551 * @param {String} data to send. -1 2552 * @param {Function} called upon flush. -1 2553 * @api private 2518 2554 */ 2519 25552520 -1 var index = 0;-1 2556 XHR.prototype.doWrite = function (data, fn) { -1 2557 var isBinary = typeof data !== 'string' && data !== undefined; -1 2558 var req = this.request({ method: 'POST', data: data, isBinary: isBinary }); -1 2559 var self = this; -1 2560 req.on('success', fn); -1 2561 req.on('error', function (err) { -1 2562 self.onError('xhr post error', err); -1 2563 }); -1 2564 this.sendXhr = req; -1 2565 }; 2521 2566 2522 2567 /**2523 -1 * Noop.-1 2568 * Starts a poll cycle. -1 2569 * -1 2570 * @api private 2524 2571 */ 2525 25722526 -1 function empty () { }-1 2573 XHR.prototype.doPoll = function () { -1 2574 debug('xhr poll'); -1 2575 var req = this.request(); -1 2576 var self = this; -1 2577 req.on('data', function (data) { -1 2578 self.onData(data); -1 2579 }); -1 2580 req.on('error', function (err) { -1 2581 self.onError('xhr poll error', err); -1 2582 }); -1 2583 this.pollXhr = req; -1 2584 }; 2527 2585 2528 2586 /**2529 -1 * JSONP Polling constructor.-1 2587 * Request constructor 2530 2588 *2531 -1 * @param {Object} opts.-1 2589 * @param {Object} options 2532 2590 * @api public 2533 2591 */ 2534 25922535 -1 function JSONPPolling (opts) {2536 -1 Polling.call(this, opts);2537 -12538 -1 this.query = this.query || {};2539 -12540 -1 // define global callbacks array if not present2541 -1 // we do this here (lazily) to avoid unneeded global pollution2542 -1 if (!callbacks) {2543 -1 // we need to consider multiple engines in the same page2544 -1 if (!global.___eio) global.___eio = [];2545 -1 callbacks = global.___eio;2546 -1 }2547 -12548 -1 // callback identifier2549 -1 this.index = callbacks.length;-1 2593 function Request (opts) { -1 2594 this.method = opts.method || 'GET'; -1 2595 this.uri = opts.uri; -1 2596 this.xd = !!opts.xd; -1 2597 this.xs = !!opts.xs; -1 2598 this.async = false !== opts.async; -1 2599 this.data = undefined !== opts.data ? opts.data : null; -1 2600 this.agent = opts.agent; -1 2601 this.isBinary = opts.isBinary; -1 2602 this.supportsBinary = opts.supportsBinary; -1 2603 this.enablesXDR = opts.enablesXDR; -1 2604 this.requestTimeout = opts.requestTimeout; 2550 26052551 -1 // add callback to jsonp global2552 -1 var self = this;2553 -1 callbacks.push(function (msg) {2554 -1 self.onData(msg);2555 -1 });-1 2606 // SSL options for Node.js client -1 2607 this.pfx = opts.pfx; -1 2608 this.key = opts.key; -1 2609 this.passphrase = opts.passphrase; -1 2610 this.cert = opts.cert; -1 2611 this.ca = opts.ca; -1 2612 this.ciphers = opts.ciphers; -1 2613 this.rejectUnauthorized = opts.rejectUnauthorized; 2556 26142557 -1 // append to query string2558 -1 this.query.j = this.index;-1 2615 // other options for Node.js client -1 2616 this.extraHeaders = opts.extraHeaders; 2559 26172560 -1 // prevent spurious errors from being emitted when the window is unloaded2561 -1 if (global.document && global.addEventListener) {2562 -1 global.addEventListener('beforeunload', function () {2563 -1 if (self.script) self.script.onerror = empty;2564 -1 }, false);2565 -1 }-1 2618 this.create(); 2566 2619 } 2567 2620 2568 2621 /**2569 -1 * Inherits from Polling.2570 -1 */2571 -12572 -1 inherit(JSONPPolling, Polling);2573 -12574 -1 /*2575 -1 * JSONP only supports binary as base64 encoded strings-1 2622 * Mix in `Emitter`. 2576 2623 */ 2577 26242578 -1 JSONPPolling.prototype.supportsBinary = false;-1 2625 Emitter(Request.prototype); 2579 2626 2580 2627 /**2581 -1 * Closes the socket.-1 2628 * Creates the XHR object and sends the request. 2582 2629 * 2583 2630 * @api private 2584 2631 */ 2585 26322586 -1 JSONPPolling.prototype.doClose = function () {2587 -1 if (this.script) {2588 -1 this.script.parentNode.removeChild(this.script);2589 -1 this.script = null;2590 -1 }-1 2633 Request.prototype.create = function () { -1 2634 var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR }; 2591 26352592 -1 if (this.form) {2593 -1 this.form.parentNode.removeChild(this.form);2594 -1 this.form = null;2595 -1 this.iframe = null;2596 -1 }-1 2636 // SSL options for Node.js client -1 2637 opts.pfx = this.pfx; -1 2638 opts.key = this.key; -1 2639 opts.passphrase = this.passphrase; -1 2640 opts.cert = this.cert; -1 2641 opts.ca = this.ca; -1 2642 opts.ciphers = this.ciphers; -1 2643 opts.rejectUnauthorized = this.rejectUnauthorized; 2597 26442598 -1 Polling.prototype.doClose.call(this);2599 -1 };-1 2645 var xhr = this.xhr = new XMLHttpRequest(opts); -1 2646 var self = this; 2600 26472601 -1 /**2602 -1 * Starts a poll cycle.2603 -1 *2604 -1 * @api private2605 -1 */-1 2648 try { -1 2649 debug('xhr open %s: %s', this.method, this.uri); -1 2650 xhr.open(this.method, this.uri, this.async); -1 2651 try { -1 2652 if (this.extraHeaders) { -1 2653 xhr.setDisableHeaderCheck(true); -1 2654 for (var i in this.extraHeaders) { -1 2655 if (this.extraHeaders.hasOwnProperty(i)) { -1 2656 xhr.setRequestHeader(i, this.extraHeaders[i]); -1 2657 } -1 2658 } -1 2659 } -1 2660 } catch (e) {} -1 2661 if (this.supportsBinary) { -1 2662 // This has to be done after open because Firefox is stupid -1 2663 // http://stackoverflow.com/questions/13216903/get-binary-data-with-xmlhttprequest-in-a-firefox-extension -1 2664 xhr.responseType = 'arraybuffer'; -1 2665 } 2606 26662607 -1 JSONPPolling.prototype.doPoll = function () {2608 -1 var self = this;2609 -1 var script = document.createElement('script');-1 2667 if ('POST' === this.method) { -1 2668 try { -1 2669 if (this.isBinary) { -1 2670 xhr.setRequestHeader('Content-type', 'application/octet-stream'); -1 2671 } else { -1 2672 xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8'); -1 2673 } -1 2674 } catch (e) {} -1 2675 } 2610 26762611 -1 if (this.script) {2612 -1 this.script.parentNode.removeChild(this.script);2613 -1 this.script = null;2614 -1 }-1 2677 try { -1 2678 xhr.setRequestHeader('Accept', '*/*'); -1 2679 } catch (e) {} 2615 26802616 -1 script.async = true;2617 -1 script.src = this.uri();2618 -1 script.onerror = function(e){2619 -1 self.onError('jsonp poll error',e);2620 -1 };-1 2681 // ie6 check -1 2682 if ('withCredentials' in xhr) { -1 2683 xhr.withCredentials = true; -1 2684 } 2621 26852622 -1 var insertAt = document.getElementsByTagName('script')[0];2623 -1 if (insertAt) {2624 -1 insertAt.parentNode.insertBefore(script, insertAt);2625 -1 }2626 -1 else {2627 -1 (document.head || document.body).appendChild(script);2628 -1 }2629 -1 this.script = script;-1 2686 if (this.requestTimeout) { -1 2687 xhr.timeout = this.requestTimeout; -1 2688 } 2630 26892631 -1 var isUAgecko = 'undefined' != typeof navigator && /gecko/i.test(navigator.userAgent);2632 -12633 -1 if (isUAgecko) {-1 2690 if (this.hasXDR()) { -1 2691 xhr.onload = function () { -1 2692 self.onLoad(); -1 2693 }; -1 2694 xhr.onerror = function () { -1 2695 self.onError(xhr.responseText); -1 2696 }; -1 2697 } else { -1 2698 xhr.onreadystatechange = function () { -1 2699 if (4 !== xhr.readyState) return; -1 2700 if (200 === xhr.status || 1223 === xhr.status) { -1 2701 self.onLoad(); -1 2702 } else { -1 2703 // make sure the `error` event handler that's user-set -1 2704 // does not throw in the same tick and gets caught here -1 2705 setTimeout(function () { -1 2706 self.onError(xhr.status); -1 2707 }, 0); -1 2708 } -1 2709 }; -1 2710 } -1 2711 -1 2712 debug('xhr data %s', this.data); -1 2713 xhr.send(this.data); -1 2714 } catch (e) { -1 2715 // Need to defer since .create() is called directly fhrom the constructor -1 2716 // and thus the 'error' event can only be only bound *after* this exception -1 2717 // occurs. Therefore, also, we cannot throw here at all. 2634 2718 setTimeout(function () {2635 -1 var iframe = document.createElement('iframe');2636 -1 document.body.appendChild(iframe);2637 -1 document.body.removeChild(iframe);2638 -1 }, 100);-1 2719 self.onError(e); -1 2720 }, 0); -1 2721 return; -1 2722 } -1 2723 -1 2724 if (global.document) { -1 2725 this.index = Request.requestsCount++; -1 2726 Request.requests[this.index] = this; 2639 2727 } 2640 2728 }; 2641 2729 2642 2730 /**2643 -1 * Writes with a hidden iframe.-1 2731 * Called upon successful response. 2644 2732 *2645 -1 * @param {String} data to send2646 -1 * @param {Function} called upon flush.2647 2733 * @api private 2648 2734 */ 2649 27352650 -1 JSONPPolling.prototype.doWrite = function (data, fn) {2651 -1 var self = this;-1 2736 Request.prototype.onSuccess = function () { -1 2737 this.emit('success'); -1 2738 this.cleanup(); -1 2739 }; 2652 27402653 -1 if (!this.form) {2654 -1 var form = document.createElement('form');2655 -1 var area = document.createElement('textarea');2656 -1 var id = this.iframeId = 'eio_iframe_' + this.index;2657 -1 var iframe;-1 2741 /** -1 2742 * Called if we have data. -1 2743 * -1 2744 * @api private -1 2745 */ 2658 27462659 -1 form.className = 'socketio';2660 -1 form.style.position = 'absolute';2661 -1 form.style.top = '-1000px';2662 -1 form.style.left = '-1000px';2663 -1 form.target = id;2664 -1 form.method = 'POST';2665 -1 form.setAttribute('accept-charset', 'utf-8');2666 -1 area.name = 'd';2667 -1 form.appendChild(area);2668 -1 document.body.appendChild(form);-1 2747 Request.prototype.onData = function (data) { -1 2748 this.emit('data', data); -1 2749 this.onSuccess(); -1 2750 }; 2669 27512670 -1 this.form = form;2671 -1 this.area = area;2672 -1 }-1 2752 /** -1 2753 * Called upon error. -1 2754 * -1 2755 * @api private -1 2756 */ 2673 27572674 -1 this.form.action = this.uri();-1 2758 Request.prototype.onError = function (err) { -1 2759 this.emit('error', err); -1 2760 this.cleanup(true); -1 2761 }; 2675 27622676 -1 function complete () {2677 -1 initIframe();2678 -1 fn();2679 -1 }-1 2763 /** -1 2764 * Cleans up house. -1 2765 * -1 2766 * @api private -1 2767 */ 2680 27682681 -1 function initIframe () {2682 -1 if (self.iframe) {2683 -1 try {2684 -1 self.form.removeChild(self.iframe);2685 -1 } catch (e) {2686 -1 self.onError('jsonp polling iframe removal error', e);2687 -1 }2688 -1 }-1 2769 Request.prototype.cleanup = function (fromError) { -1 2770 if ('undefined' === typeof this.xhr || null === this.xhr) { -1 2771 return; -1 2772 } -1 2773 // xmlhttprequest -1 2774 if (this.hasXDR()) { -1 2775 this.xhr.onload = this.xhr.onerror = empty; -1 2776 } else { -1 2777 this.xhr.onreadystatechange = empty; -1 2778 } 2689 2779 -1 2780 if (fromError) { 2690 2781 try {2691 -1 // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)2692 -1 var html = '<iframe src="javascript:0" name="'+ self.iframeId +'">';2693 -1 iframe = document.createElement(html);2694 -1 } catch (e) {2695 -1 iframe = document.createElement('iframe');2696 -1 iframe.name = self.iframeId;2697 -1 iframe.src = 'javascript:0';2698 -1 }2699 -12700 -1 iframe.id = self.iframeId;-1 2782 this.xhr.abort(); -1 2783 } catch (e) {} -1 2784 } 2701 27852702 -1 self.form.appendChild(iframe);2703 -1 self.iframe = iframe;-1 2786 if (global.document) { -1 2787 delete Request.requests[this.index]; 2704 2788 } 2705 27892706 -1 initIframe();-1 2790 this.xhr = null; -1 2791 }; 2707 27922708 -1 // escape \n to prevent it from being converted into \r\n by some UAs2709 -1 // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side2710 -1 data = data.replace(rEscapedNewline, '\\\n');2711 -1 this.area.value = data.replace(rNewline, '\\n');-1 2793 /** -1 2794 * Called upon load. -1 2795 * -1 2796 * @api private -1 2797 */ 2712 2798 -1 2799 Request.prototype.onLoad = function () { -1 2800 var data; 2713 2801 try {2714 -1 this.form.submit();2715 -1 } catch(e) {}-1 2802 var contentType; -1 2803 try { -1 2804 contentType = this.xhr.getResponseHeader('Content-Type').split(';')[0]; -1 2805 } catch (e) {} -1 2806 if (contentType === 'application/octet-stream') { -1 2807 data = this.xhr.response || this.xhr.responseText; -1 2808 } else { -1 2809 if (!this.supportsBinary) { -1 2810 data = this.xhr.responseText; -1 2811 } else { -1 2812 try { -1 2813 data = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response)); -1 2814 } catch (e) { -1 2815 var ui8Arr = new Uint8Array(this.xhr.response); -1 2816 var dataArray = []; -1 2817 for (var idx = 0, length = ui8Arr.length; idx < length; idx++) { -1 2818 dataArray.push(ui8Arr[idx]); -1 2819 } 2716 28202717 -1 if (this.iframe.attachEvent) {2718 -1 this.iframe.onreadystatechange = function(){2719 -1 if (self.iframe.readyState == 'complete') {2720 -1 complete();-1 2821 data = String.fromCharCode.apply(null, dataArray); -1 2822 } 2721 2823 }2722 -1 };2723 -1 } else {2724 -1 this.iframe.onload = complete;-1 2824 } -1 2825 } catch (e) { -1 2826 this.onError(e); -1 2827 } -1 2828 if (null != data) { -1 2829 this.onData(data); 2725 2830 } 2726 2831 }; 2727 28322728 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})2729 -1 },{"./polling":21,"component-inherit":11}],20:[function(require,module,exports){2730 -1 (function (global){2731 -1 /**2732 -1 * Module requirements.2733 -1 */2734 -12735 -1 var XMLHttpRequest = require('xmlhttprequest-ssl');2736 -1 var Polling = require('./polling');2737 -1 var Emitter = require('component-emitter');2738 -1 var inherit = require('component-inherit');2739 -1 var debug = require('debug')('engine.io-client:polling-xhr');2740 -12741 2833 /**2742 -1 * Module exports.-1 2834 * Check if it has XDomainRequest. -1 2835 * -1 2836 * @api private 2743 2837 */ 2744 28382745 -1 module.exports = XHR;2746 -1 module.exports.Request = Request;-1 2839 Request.prototype.hasXDR = function () { -1 2840 return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR; -1 2841 }; 2747 2842 2748 2843 /**2749 -1 * Empty function-1 2844 * Aborts the request. -1 2845 * -1 2846 * @api public 2750 2847 */ 2751 28482752 -1 function empty(){}-1 2849 Request.prototype.abort = function () { -1 2850 this.cleanup(); -1 2851 }; 2753 2852 2754 2853 /**2755 -1 * XHR Polling constructor.2756 -1 *2757 -1 * @param {Object} opts2758 -1 * @api public-1 2854 * Aborts pending requests when unloading the window. This is needed to prevent -1 2855 * memory leaks (e.g. when using IE) and to ensure that no spurious error is -1 2856 * emitted. 2759 2857 */ 2760 28582761 -1 function XHR(opts){2762 -1 Polling.call(this, opts);-1 2859 Request.requestsCount = 0; -1 2860 Request.requests = {}; 2763 28612764 -1 if (global.location) {2765 -1 var isSSL = 'https:' == location.protocol;2766 -1 var port = location.port;-1 2862 if (global.document) { -1 2863 if (global.attachEvent) { -1 2864 global.attachEvent('onunload', unloadHandler); -1 2865 } else if (global.addEventListener) { -1 2866 global.addEventListener('beforeunload', unloadHandler, false); -1 2867 } -1 2868 } 2767 28692768 -1 // some user agents have empty `location.port`2769 -1 if (!port) {2770 -1 port = isSSL ? 443 : 80;-1 2870 function unloadHandler () { -1 2871 for (var i in Request.requests) { -1 2872 if (Request.requests.hasOwnProperty(i)) { -1 2873 Request.requests[i].abort(); 2771 2874 }2772 -12773 -1 this.xd = opts.hostname != global.location.hostname ||2774 -1 port != opts.port;2775 -1 this.xs = opts.secure != isSSL;2776 -1 } else {2777 -1 this.extraHeaders = opts.extraHeaders;2778 2875 } 2779 2876 } 2780 2877 -1 2878 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 2879 },{"./polling":19,"component-emitter":22,"component-inherit":11,"debug":23,"xmlhttprequest-ssl":21}],19:[function(require,module,exports){ 2781 2880 /**2782 -1 * Inherits from Polling.-1 2881 * Module dependencies. 2783 2882 */ 2784 28832785 -1 inherit(XHR, Polling);-1 2884 var Transport = require('../transport'); -1 2885 var parseqs = require('parseqs'); -1 2886 var parser = require('engine.io-parser'); -1 2887 var inherit = require('component-inherit'); -1 2888 var yeast = require('yeast'); -1 2889 var debug = require('debug')('engine.io-client:polling'); 2786 2890 2787 2891 /**2788 -1 * XHR supports binary-1 2892 * Module exports. 2789 2893 */ 2790 28942791 -1 XHR.prototype.supportsBinary = true;-1 2895 module.exports = Polling; 2792 2896 2793 2897 /**2794 -1 * Creates a request.-1 2898 * Is XHR2 supported? -1 2899 */ -1 2900 -1 2901 var hasXHR2 = (function () { -1 2902 var XMLHttpRequest = require('xmlhttprequest-ssl'); -1 2903 var xhr = new XMLHttpRequest({ xdomain: false }); -1 2904 return null != xhr.responseType; -1 2905 })(); -1 2906 -1 2907 /** -1 2908 * Polling interface. 2795 2909 *2796 -1 * @param {String} method-1 2910 * @param {Object} opts 2797 2911 * @api private 2798 2912 */ 2799 29132800 -1 XHR.prototype.request = function(opts){2801 -1 opts = opts || {};2802 -1 opts.uri = this.uri();2803 -1 opts.xd = this.xd;2804 -1 opts.xs = this.xs;2805 -1 opts.agent = this.agent || false;2806 -1 opts.supportsBinary = this.supportsBinary;2807 -1 opts.enablesXDR = this.enablesXDR;-1 2914 function Polling (opts) { -1 2915 var forceBase64 = (opts && opts.forceBase64); -1 2916 if (!hasXHR2 || forceBase64) { -1 2917 this.supportsBinary = false; -1 2918 } -1 2919 Transport.call(this, opts); -1 2920 } 2808 29212809 -1 // SSL options for Node.js client2810 -1 opts.pfx = this.pfx;2811 -1 opts.key = this.key;2812 -1 opts.passphrase = this.passphrase;2813 -1 opts.cert = this.cert;2814 -1 opts.ca = this.ca;2815 -1 opts.ciphers = this.ciphers;2816 -1 opts.rejectUnauthorized = this.rejectUnauthorized;-1 2922 /** -1 2923 * Inherits from Transport. -1 2924 */ 2817 29252818 -1 // other options for Node.js client2819 -1 opts.extraHeaders = this.extraHeaders;-1 2926 inherit(Polling, Transport); 2820 29272821 -1 return new Request(opts);2822 -1 };-1 2928 /** -1 2929 * Transport name. -1 2930 */ -1 2931 -1 2932 Polling.prototype.name = 'polling'; 2823 2933 2824 2934 /**2825 -1 * Sends data.-1 2935 * Opens the socket (triggers polling). We write a PING message to determine -1 2936 * when the transport is open. 2826 2937 *2827 -1 * @param {String} data to send.2828 -1 * @param {Function} called upon flush.2829 2938 * @api private 2830 2939 */ 2831 29402832 -1 XHR.prototype.doWrite = function(data, fn){2833 -1 var isBinary = typeof data !== 'string' && data !== undefined;2834 -1 var req = this.request({ method: 'POST', data: data, isBinary: isBinary });2835 -1 var self = this;2836 -1 req.on('success', fn);2837 -1 req.on('error', function(err){2838 -1 self.onError('xhr post error', err);2839 -1 });2840 -1 this.sendXhr = req;-1 2941 Polling.prototype.doOpen = function () { -1 2942 this.poll(); 2841 2943 }; 2842 2944 2843 2945 /**2844 -1 * Starts a poll cycle.-1 2946 * Pauses polling. 2845 2947 * -1 2948 * @param {Function} callback upon buffers are flushed and transport is paused 2846 2949 * @api private 2847 2950 */ 2848 29512849 -1 XHR.prototype.doPoll = function(){2850 -1 debug('xhr poll');2851 -1 var req = this.request();-1 2952 Polling.prototype.pause = function (onPause) { 2852 2953 var self = this;2853 -1 req.on('data', function(data){2854 -1 self.onData(data);2855 -1 });2856 -1 req.on('error', function(err){2857 -1 self.onError('xhr poll error', err);2858 -1 });2859 -1 this.pollXhr = req;2860 -1 };2861 29542862 -1 /**2863 -1 * Request constructor2864 -1 *2865 -1 * @param {Object} options2866 -1 * @api public2867 -1 */-1 2955 this.readyState = 'pausing'; 2868 29562869 -1 function Request(opts){2870 -1 this.method = opts.method || 'GET';2871 -1 this.uri = opts.uri;2872 -1 this.xd = !!opts.xd;2873 -1 this.xs = !!opts.xs;2874 -1 this.async = false !== opts.async;2875 -1 this.data = undefined != opts.data ? opts.data : null;2876 -1 this.agent = opts.agent;2877 -1 this.isBinary = opts.isBinary;2878 -1 this.supportsBinary = opts.supportsBinary;2879 -1 this.enablesXDR = opts.enablesXDR;-1 2957 function pause () { -1 2958 debug('paused'); -1 2959 self.readyState = 'paused'; -1 2960 onPause(); -1 2961 } 2880 29622881 -1 // SSL options for Node.js client2882 -1 this.pfx = opts.pfx;2883 -1 this.key = opts.key;2884 -1 this.passphrase = opts.passphrase;2885 -1 this.cert = opts.cert;2886 -1 this.ca = opts.ca;2887 -1 this.ciphers = opts.ciphers;2888 -1 this.rejectUnauthorized = opts.rejectUnauthorized;-1 2963 if (this.polling || !this.writable) { -1 2964 var total = 0; 2889 29652890 -1 // other options for Node.js client2891 -1 this.extraHeaders = opts.extraHeaders;-1 2966 if (this.polling) { -1 2967 debug('we are currently polling - waiting to pause'); -1 2968 total++; -1 2969 this.once('pollComplete', function () { -1 2970 debug('pre-pause polling complete'); -1 2971 --total || pause(); -1 2972 }); -1 2973 } 2892 29742893 -1 this.create();2894 -1 }-1 2975 if (!this.writable) { -1 2976 debug('we are currently writing - waiting to pause'); -1 2977 total++; -1 2978 this.once('drain', function () { -1 2979 debug('pre-pause writing complete'); -1 2980 --total || pause(); -1 2981 }); -1 2982 } -1 2983 } else { -1 2984 pause(); -1 2985 } -1 2986 }; 2895 2987 2896 2988 /**2897 -1 * Mix in `Emitter`.-1 2989 * Starts polling cycle. -1 2990 * -1 2991 * @api public 2898 2992 */ 2899 29932900 -1 Emitter(Request.prototype);-1 2994 Polling.prototype.poll = function () { -1 2995 debug('polling'); -1 2996 this.polling = true; -1 2997 this.doPoll(); -1 2998 this.emit('poll'); -1 2999 }; 2901 3000 2902 3001 /**2903 -1 * Creates the XHR object and sends the request.-1 3002 * Overloads onData to detect payloads. 2904 3003 * 2905 3004 * @api private 2906 3005 */ 2907 30062908 -1 Request.prototype.create = function(){2909 -1 var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };2910 -12911 -1 // SSL options for Node.js client2912 -1 opts.pfx = this.pfx;2913 -1 opts.key = this.key;2914 -1 opts.passphrase = this.passphrase;2915 -1 opts.cert = this.cert;2916 -1 opts.ca = this.ca;2917 -1 opts.ciphers = this.ciphers;2918 -1 opts.rejectUnauthorized = this.rejectUnauthorized;2919 -12920 -1 var xhr = this.xhr = new XMLHttpRequest(opts);-1 3007 Polling.prototype.onData = function (data) { 2921 3008 var self = this;2922 -12923 -1 try {2924 -1 debug('xhr open %s: %s', this.method, this.uri);2925 -1 xhr.open(this.method, this.uri, this.async);2926 -1 try {2927 -1 if (this.extraHeaders) {2928 -1 xhr.setDisableHeaderCheck(true);2929 -1 for (var i in this.extraHeaders) {2930 -1 if (this.extraHeaders.hasOwnProperty(i)) {2931 -1 xhr.setRequestHeader(i, this.extraHeaders[i]);2932 -1 }2933 -1 }2934 -1 }2935 -1 } catch (e) {}2936 -1 if (this.supportsBinary) {2937 -1 // This has to be done after open because Firefox is stupid2938 -1 // http://stackoverflow.com/questions/13216903/get-binary-data-with-xmlhttprequest-in-a-firefox-extension2939 -1 xhr.responseType = 'arraybuffer';-1 3009 debug('polling got data %s', data); -1 3010 var callback = function (packet, index, total) { -1 3011 // if its the first message we consider the transport open -1 3012 if ('opening' === self.readyState) { -1 3013 self.onOpen(); 2940 3014 } 2941 30152942 -1 if ('POST' == this.method) {2943 -1 try {2944 -1 if (this.isBinary) {2945 -1 xhr.setRequestHeader('Content-type', 'application/octet-stream');2946 -1 } else {2947 -1 xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');2948 -1 }2949 -1 } catch (e) {}-1 3016 // if its a close packet, we close the ongoing requests -1 3017 if ('close' === packet.type) { -1 3018 self.onClose(); -1 3019 return false; 2950 3020 } 2951 30212952 -1 // ie6 check2953 -1 if ('withCredentials' in xhr) {2954 -1 xhr.withCredentials = true;2955 -1 }-1 3022 // otherwise bypass onData and handle the message -1 3023 self.onPacket(packet); -1 3024 }; 2956 30252957 -1 if (this.hasXDR()) {2958 -1 xhr.onload = function(){2959 -1 self.onLoad();2960 -1 };2961 -1 xhr.onerror = function(){2962 -1 self.onError(xhr.responseText);2963 -1 };2964 -1 } else {2965 -1 xhr.onreadystatechange = function(){2966 -1 if (4 != xhr.readyState) return;2967 -1 if (200 == xhr.status || 1223 == xhr.status) {2968 -1 self.onLoad();2969 -1 } else {2970 -1 // make sure the `error` event handler that's user-set2971 -1 // does not throw in the same tick and gets caught here2972 -1 setTimeout(function(){2973 -1 self.onError(xhr.status);2974 -1 }, 0);2975 -1 }2976 -1 };2977 -1 }-1 3026 // decode payload -1 3027 parser.decodePayload(data, this.socket.binaryType, callback); 2978 30282979 -1 debug('xhr data %s', this.data);2980 -1 xhr.send(this.data);2981 -1 } catch (e) {2982 -1 // Need to defer since .create() is called directly fhrom the constructor2983 -1 // and thus the 'error' event can only be only bound *after* this exception2984 -1 // occurs. Therefore, also, we cannot throw here at all.2985 -1 setTimeout(function() {2986 -1 self.onError(e);2987 -1 }, 0);2988 -1 return;2989 -1 }-1 3029 // if an event did not trigger closing -1 3030 if ('closed' !== this.readyState) { -1 3031 // if we got data we're not polling -1 3032 this.polling = false; -1 3033 this.emit('pollComplete'); 2990 30342991 -1 if (global.document) {2992 -1 this.index = Request.requestsCount++;2993 -1 Request.requests[this.index] = this;-1 3035 if ('open' === this.readyState) { -1 3036 this.poll(); -1 3037 } else { -1 3038 debug('ignoring poll - transport state "%s"', this.readyState); -1 3039 } 2994 3040 } 2995 3041 }; 2996 3042 2997 3043 /**2998 -1 * Called upon successful response.-1 3044 * For polling, send a close packet. 2999 3045 * 3000 3046 * @api private 3001 3047 */ 3002 30483003 -1 Request.prototype.onSuccess = function(){3004 -1 this.emit('success');3005 -1 this.cleanup();3006 -1 };-1 3049 Polling.prototype.doClose = function () { -1 3050 var self = this; 3007 30513008 -1 /**3009 -1 * Called if we have data.3010 -1 *3011 -1 * @api private3012 -1 */-1 3052 function close () { -1 3053 debug('writing close packet'); -1 3054 self.write([{ type: 'close' }]); -1 3055 } 3013 30563014 -1 Request.prototype.onData = function(data){3015 -1 this.emit('data', data);3016 -1 this.onSuccess();-1 3057 if ('open' === this.readyState) { -1 3058 debug('transport open - closing'); -1 3059 close(); -1 3060 } else { -1 3061 // in case we're trying to close while -1 3062 // handshaking is in progress (GH-164) -1 3063 debug('transport not open - deferring close'); -1 3064 this.once('open', close); -1 3065 } 3017 3066 }; 3018 3067 3019 3068 /**3020 -1 * Called upon error.-1 3069 * Writes a packets payload. 3021 3070 * -1 3071 * @param {Array} data packets -1 3072 * @param {Function} drain callback 3022 3073 * @api private 3023 3074 */ 3024 30753025 -1 Request.prototype.onError = function(err){3026 -1 this.emit('error', err);3027 -1 this.cleanup(true);-1 3076 Polling.prototype.write = function (packets) { -1 3077 var self = this; -1 3078 this.writable = false; -1 3079 var callbackfn = function () { -1 3080 self.writable = true; -1 3081 self.emit('drain'); -1 3082 }; -1 3083 -1 3084 parser.encodePayload(packets, this.supportsBinary, function (data) { -1 3085 self.doWrite(data, callbackfn); -1 3086 }); 3028 3087 }; 3029 3088 3030 3089 /**3031 -1 * Cleans up house.-1 3090 * Generates uri for connection. 3032 3091 * 3033 3092 * @api private 3034 3093 */ 3035 30943036 -1 Request.prototype.cleanup = function(fromError){3037 -1 if ('undefined' == typeof this.xhr || null === this.xhr) {3038 -1 return;-1 3095 Polling.prototype.uri = function () { -1 3096 var query = this.query || {}; -1 3097 var schema = this.secure ? 'https' : 'http'; -1 3098 var port = ''; -1 3099 -1 3100 // cache busting is forced -1 3101 if (false !== this.timestampRequests) { -1 3102 query[this.timestampParam] = yeast(); 3039 3103 }3040 -1 // xmlhttprequest3041 -1 if (this.hasXDR()) {3042 -1 this.xhr.onload = this.xhr.onerror = empty;3043 -1 } else {3044 -1 this.xhr.onreadystatechange = empty;-1 3104 -1 3105 if (!this.supportsBinary && !query.sid) { -1 3106 query.b64 = 1; 3045 3107 } 3046 31083047 -1 if (fromError) {3048 -1 try {3049 -1 this.xhr.abort();3050 -1 } catch(e) {}-1 3109 query = parseqs.encode(query); -1 3110 -1 3111 // avoid port if default for schema -1 3112 if (this.port && (('https' === schema && Number(this.port) !== 443) || -1 3113 ('http' === schema && Number(this.port) !== 80))) { -1 3114 port = ':' + this.port; 3051 3115 } 3052 31163053 -1 if (global.document) {3054 -1 delete Request.requests[this.index];-1 3117 // prepend ? to query -1 3118 if (query.length) { -1 3119 query = '?' + query; 3055 3120 } 3056 31213057 -1 this.xhr = null;-1 3122 var ipv6 = this.hostname.indexOf(':') !== -1; -1 3123 return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query; 3058 3124 }; 3059 3125 -1 3126 },{"../transport":15,"component-inherit":11,"debug":23,"engine.io-parser":26,"parseqs":94,"xmlhttprequest-ssl":21,"yeast":120}],20:[function(require,module,exports){ -1 3127 (function (global){ 3060 3128 /**3061 -1 * Called upon load.3062 -1 *3063 -1 * @api private-1 3129 * Module dependencies. 3064 3130 */ 3065 31313066 -1 Request.prototype.onLoad = function(){3067 -1 var data;-1 3132 var Transport = require('../transport'); -1 3133 var parser = require('engine.io-parser'); -1 3134 var parseqs = require('parseqs'); -1 3135 var inherit = require('component-inherit'); -1 3136 var yeast = require('yeast'); -1 3137 var debug = require('debug')('engine.io-client:websocket'); -1 3138 var BrowserWebSocket = global.WebSocket || global.MozWebSocket; -1 3139 var NodeWebSocket; -1 3140 if (typeof window === 'undefined') { 3068 3141 try {3069 -1 var contentType;3070 -1 try {3071 -1 contentType = this.xhr.getResponseHeader('Content-Type').split(';')[0];3072 -1 } catch (e) {}3073 -1 if (contentType === 'application/octet-stream') {3074 -1 data = this.xhr.response;3075 -1 } else {3076 -1 if (!this.supportsBinary) {3077 -1 data = this.xhr.responseText;3078 -1 } else {3079 -1 try {3080 -1 data = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response));3081 -1 } catch (e) {3082 -1 var ui8Arr = new Uint8Array(this.xhr.response);3083 -1 var dataArray = [];3084 -1 for (var idx = 0, length = ui8Arr.length; idx < length; idx++) {3085 -1 dataArray.push(ui8Arr[idx]);3086 -1 }3087 -13088 -1 data = String.fromCharCode.apply(null, dataArray);3089 -1 }3090 -1 }3091 -1 }3092 -1 } catch (e) {3093 -1 this.onError(e);3094 -1 }3095 -1 if (null != data) {3096 -1 this.onData(data);3097 -1 }3098 -1 };-1 3142 NodeWebSocket = require('ws'); -1 3143 } catch (e) { } -1 3144 } 3099 3145 3100 3146 /**3101 -1 * Check if it has XDomainRequest.3102 -1 *3103 -1 * @api private-1 3147 * Get either the `WebSocket` or `MozWebSocket` globals -1 3148 * in the browser or try to resolve WebSocket-compatible -1 3149 * interface exposed by `ws` for Node-like environment. 3104 3150 */ 3105 31513106 -1 Request.prototype.hasXDR = function(){3107 -1 return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR;3108 -1 };-1 3152 var WebSocket = BrowserWebSocket; -1 3153 if (!WebSocket && typeof window === 'undefined') { -1 3154 WebSocket = NodeWebSocket; -1 3155 } 3109 3156 3110 3157 /**3111 -1 * Aborts the request.3112 -1 *3113 -1 * @api public-1 3158 * Module exports. 3114 3159 */ 3115 31603116 -1 Request.prototype.abort = function(){3117 -1 this.cleanup();3118 -1 };-1 3161 module.exports = WS; 3119 3162 3120 3163 /**3121 -1 * Aborts pending requests when unloading the window. This is needed to prevent3122 -1 * memory leaks (e.g. when using IE) and to ensure that no spurious error is3123 -1 * emitted.-1 3164 * WebSocket transport constructor. -1 3165 * -1 3166 * @api {Object} connection options -1 3167 * @api public 3124 3168 */ 3125 31693126 -1 if (global.document) {3127 -1 Request.requestsCount = 0;3128 -1 Request.requests = {};3129 -1 if (global.attachEvent) {3130 -1 global.attachEvent('onunload', unloadHandler);3131 -1 } else if (global.addEventListener) {3132 -1 global.addEventListener('beforeunload', unloadHandler, false);-1 3170 function WS (opts) { -1 3171 var forceBase64 = (opts && opts.forceBase64); -1 3172 if (forceBase64) { -1 3173 this.supportsBinary = false; 3133 3174 }3134 -1 }3135 -13136 -1 function unloadHandler() {3137 -1 for (var i in Request.requests) {3138 -1 if (Request.requests.hasOwnProperty(i)) {3139 -1 Request.requests[i].abort();3140 -1 }-1 3175 this.perMessageDeflate = opts.perMessageDeflate; -1 3176 this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode; -1 3177 if (!this.usingBrowserWebSocket) { -1 3178 WebSocket = NodeWebSocket; 3141 3179 } -1 3180 Transport.call(this, opts); 3142 3181 } 3143 31823144 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})3145 -1 },{"./polling":21,"component-emitter":10,"component-inherit":11,"debug":12,"xmlhttprequest-ssl":23}],21:[function(require,module,exports){3146 3183 /**3147 -1 * Module dependencies.-1 3184 * Inherits from Transport. 3148 3185 */ 3149 31863150 -1 var Transport = require('../transport');3151 -1 var parseqs = require('parseqs');3152 -1 var parser = require('engine.io-parser');3153 -1 var inherit = require('component-inherit');3154 -1 var yeast = require('yeast');3155 -1 var debug = require('debug')('engine.io-client:polling');-1 3187 inherit(WS, Transport); 3156 3188 3157 3189 /**3158 -1 * Module exports.-1 3190 * Transport name. -1 3191 * -1 3192 * @api public 3159 3193 */ 3160 31943161 -1 module.exports = Polling;-1 3195 WS.prototype.name = 'websocket'; 3162 31963163 -1 /**3164 -1 * Is XHR2 supported?-1 3197 /* -1 3198 * WebSockets support binary 3165 3199 */ 3166 32003167 -1 var hasXHR2 = (function() {3168 -1 var XMLHttpRequest = require('xmlhttprequest-ssl');3169 -1 var xhr = new XMLHttpRequest({ xdomain: false });3170 -1 return null != xhr.responseType;3171 -1 })();-1 3201 WS.prototype.supportsBinary = true; 3172 3202 3173 3203 /**3174 -1 * Polling interface.-1 3204 * Opens socket. 3175 3205 *3176 -1 * @param {Object} opts3177 3206 * @api private 3178 3207 */ 3179 32083180 -1 function Polling(opts){3181 -1 var forceBase64 = (opts && opts.forceBase64);3182 -1 if (!hasXHR2 || forceBase64) {3183 -1 this.supportsBinary = false;-1 3209 WS.prototype.doOpen = function () { -1 3210 if (!this.check()) { -1 3211 // let probe timeout -1 3212 return; 3184 3213 }3185 -1 Transport.call(this, opts);3186 -1 }3187 32143188 -1 /**3189 -1 * Inherits from Transport.3190 -1 */-1 3215 var uri = this.uri(); -1 3216 var protocols = void (0); -1 3217 var opts = { -1 3218 agent: this.agent, -1 3219 perMessageDeflate: this.perMessageDeflate -1 3220 }; 3191 32213192 -1 inherit(Polling, Transport);-1 3222 // SSL options for Node.js client -1 3223 opts.pfx = this.pfx; -1 3224 opts.key = this.key; -1 3225 opts.passphrase = this.passphrase; -1 3226 opts.cert = this.cert; -1 3227 opts.ca = this.ca; -1 3228 opts.ciphers = this.ciphers; -1 3229 opts.rejectUnauthorized = this.rejectUnauthorized; -1 3230 if (this.extraHeaders) { -1 3231 opts.headers = this.extraHeaders; -1 3232 } -1 3233 if (this.localAddress) { -1 3234 opts.localAddress = this.localAddress; -1 3235 } 3193 32363194 -1 /**3195 -1 * Transport name.3196 -1 */-1 3237 try { -1 3238 this.ws = this.usingBrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts); -1 3239 } catch (err) { -1 3240 return this.emit('error', err); -1 3241 } 3197 32423198 -1 Polling.prototype.name = 'polling';-1 3243 if (this.ws.binaryType === undefined) { -1 3244 this.supportsBinary = false; -1 3245 } -1 3246 -1 3247 if (this.ws.supports && this.ws.supports.binary) { -1 3248 this.supportsBinary = true; -1 3249 this.ws.binaryType = 'nodebuffer'; -1 3250 } else { -1 3251 this.ws.binaryType = 'arraybuffer'; -1 3252 } -1 3253 -1 3254 this.addEventListeners(); -1 3255 }; 3199 3256 3200 3257 /**3201 -1 * Opens the socket (triggers polling). We write a PING message to determine3202 -1 * when the transport is open.-1 3258 * Adds event listeners to the socket 3203 3259 * 3204 3260 * @api private 3205 3261 */ 3206 32623207 -1 Polling.prototype.doOpen = function(){3208 -1 this.poll();-1 3263 WS.prototype.addEventListeners = function () { -1 3264 var self = this; -1 3265 -1 3266 this.ws.onopen = function () { -1 3267 self.onOpen(); -1 3268 }; -1 3269 this.ws.onclose = function () { -1 3270 self.onClose(); -1 3271 }; -1 3272 this.ws.onmessage = function (ev) { -1 3273 self.onData(ev.data); -1 3274 }; -1 3275 this.ws.onerror = function (e) { -1 3276 self.onError('websocket error', e); -1 3277 }; 3209 3278 }; 3210 3279 3211 3280 /**3212 -1 * Pauses polling.-1 3281 * Writes data to socket. 3213 3282 *3214 -1 * @param {Function} callback upon buffers are flushed and transport is paused-1 3283 * @param {Array} array of packets. 3215 3284 * @api private 3216 3285 */ 3217 32863218 -1 Polling.prototype.pause = function(onPause){3219 -1 var pending = 0;-1 3287 WS.prototype.write = function (packets) { 3220 3288 var self = this; -1 3289 this.writable = false; 3221 32903222 -1 this.readyState = 'pausing';-1 3291 // encodePacket efficient as it uses WS framing -1 3292 // no need for encodePayload -1 3293 var total = packets.length; -1 3294 for (var i = 0, l = total; i < l; i++) { -1 3295 (function (packet) { -1 3296 parser.encodePacket(packet, self.supportsBinary, function (data) { -1 3297 if (!self.usingBrowserWebSocket) { -1 3298 // always create a new object (GH-437) -1 3299 var opts = {}; -1 3300 if (packet.options) { -1 3301 opts.compress = packet.options.compress; -1 3302 } 3223 33033224 -1 function pause(){3225 -1 debug('paused');3226 -1 self.readyState = 'paused';3227 -1 onPause();3228 -1 }-1 3304 if (self.perMessageDeflate) { -1 3305 var len = 'string' === typeof data ? global.Buffer.byteLength(data) : data.length; -1 3306 if (len < self.perMessageDeflate.threshold) { -1 3307 opts.compress = false; -1 3308 } -1 3309 } -1 3310 } 3229 33113230 -1 if (this.polling || !this.writable) {3231 -1 var total = 0;-1 3312 // Sometimes the websocket has already been closed but the browser didn't -1 3313 // have a chance of informing us about it yet, in that case send will -1 3314 // throw an error -1 3315 try { -1 3316 if (self.usingBrowserWebSocket) { -1 3317 // TypeError is thrown when passing the second argument on Safari -1 3318 self.ws.send(data); -1 3319 } else { -1 3320 self.ws.send(data, opts); -1 3321 } -1 3322 } catch (e) { -1 3323 debug('websocket closed before onclose event'); -1 3324 } 3232 33253233 -1 if (this.polling) {3234 -1 debug('we are currently polling - waiting to pause');3235 -1 total++;3236 -1 this.once('pollComplete', function(){3237 -1 debug('pre-pause polling complete');3238 -1 --total || pause();-1 3326 --total || done(); 3239 3327 });3240 -1 }-1 3328 })(packets[i]); -1 3329 } 3241 33303242 -1 if (!this.writable) {3243 -1 debug('we are currently writing - waiting to pause');3244 -1 total++;3245 -1 this.once('drain', function(){3246 -1 debug('pre-pause writing complete');3247 -1 --total || pause();3248 -1 });3249 -1 }3250 -1 } else {3251 -1 pause();-1 3331 function done () { -1 3332 self.emit('flush'); -1 3333 -1 3334 // fake drain -1 3335 // defer to next tick to allow Socket to clear writeBuffer -1 3336 setTimeout(function () { -1 3337 self.writable = true; -1 3338 self.emit('drain'); -1 3339 }, 0); 3252 3340 } 3253 3341 }; 3254 3342 3255 3343 /**3256 -1 * Starts polling cycle.-1 3344 * Called upon close 3257 3345 *3258 -1 * @api public-1 3346 * @api private 3259 3347 */ 3260 33483261 -1 Polling.prototype.poll = function(){3262 -1 debug('polling');3263 -1 this.polling = true;3264 -1 this.doPoll();3265 -1 this.emit('poll');-1 3349 WS.prototype.onClose = function () { -1 3350 Transport.prototype.onClose.call(this); 3266 3351 }; 3267 3352 3268 3353 /**3269 -1 * Overloads onData to detect payloads.-1 3354 * Closes socket. 3270 3355 * 3271 3356 * @api private 3272 3357 */ 3273 33583274 -1 Polling.prototype.onData = function(data){3275 -1 var self = this;3276 -1 debug('polling got data %s', data);3277 -1 var callback = function(packet, index, total) {3278 -1 // if its the first message we consider the transport open3279 -1 if ('opening' == self.readyState) {3280 -1 self.onOpen();3281 -1 }3282 -13283 -1 // if its a close packet, we close the ongoing requests3284 -1 if ('close' == packet.type) {3285 -1 self.onClose();3286 -1 return false;3287 -1 }3288 -13289 -1 // otherwise bypass onData and handle the message3290 -1 self.onPacket(packet);3291 -1 };3292 -13293 -1 // decode payload3294 -1 parser.decodePayload(data, this.socket.binaryType, callback);3295 -13296 -1 // if an event did not trigger closing3297 -1 if ('closed' != this.readyState) {3298 -1 // if we got data we're not polling3299 -1 this.polling = false;3300 -1 this.emit('pollComplete');3301 -13302 -1 if ('open' == this.readyState) {3303 -1 this.poll();3304 -1 } else {3305 -1 debug('ignoring poll - transport state "%s"', this.readyState);3306 -1 }-1 3359 WS.prototype.doClose = function () { -1 3360 if (typeof this.ws !== 'undefined') { -1 3361 this.ws.close(); 3307 3362 } 3308 3363 }; 3309 3364 3310 3365 /**3311 -1 * For polling, send a close packet.-1 3366 * Generates uri for connection. 3312 3367 * 3313 3368 * @api private 3314 3369 */ 3315 33703316 -1 Polling.prototype.doClose = function(){3317 -1 var self = this;-1 3371 WS.prototype.uri = function () { -1 3372 var query = this.query || {}; -1 3373 var schema = this.secure ? 'wss' : 'ws'; -1 3374 var port = ''; 3318 33753319 -1 function close(){3320 -1 debug('writing close packet');3321 -1 self.write([{ type: 'close' }]);-1 3376 // avoid port if default for schema -1 3377 if (this.port && (('wss' === schema && Number(this.port) !== 443) || -1 3378 ('ws' === schema && Number(this.port) !== 80))) { -1 3379 port = ':' + this.port; 3322 3380 } 3323 33813324 -1 if ('open' == this.readyState) {3325 -1 debug('transport open - closing');3326 -1 close();3327 -1 } else {3328 -1 // in case we're trying to close while3329 -1 // handshaking is in progress (GH-164)3330 -1 debug('transport not open - deferring close');3331 -1 this.once('open', close);3332 -1 }3333 -1 };3334 -13335 -1 /**3336 -1 * Writes a packets payload.3337 -1 *3338 -1 * @param {Array} data packets3339 -1 * @param {Function} drain callback3340 -1 * @api private3341 -1 */3342 -13343 -1 Polling.prototype.write = function(packets){3344 -1 var self = this;3345 -1 this.writable = false;3346 -1 var callbackfn = function() {3347 -1 self.writable = true;3348 -1 self.emit('drain');3349 -1 };3350 -13351 -1 var self = this;3352 -1 parser.encodePayload(packets, this.supportsBinary, function(data) {3353 -1 self.doWrite(data, callbackfn);3354 -1 });3355 -1 };3356 -13357 -1 /**3358 -1 * Generates uri for connection.3359 -1 *3360 -1 * @api private3361 -1 */3362 -13363 -1 Polling.prototype.uri = function(){3364 -1 var query = this.query || {};3365 -1 var schema = this.secure ? 'https' : 'http';3366 -1 var port = '';3367 -13368 -1 // cache busting is forced3369 -1 if (false !== this.timestampRequests) {-1 3382 // append timestamp to URI -1 3383 if (this.timestampRequests) { 3370 3384 query[this.timestampParam] = yeast(); 3371 3385 } 3372 33863373 -1 if (!this.supportsBinary && !query.sid) {-1 3387 // communicate binary support capabilities -1 3388 if (!this.supportsBinary) { 3374 3389 query.b64 = 1; 3375 3390 } 3376 3391 3377 3392 query = parseqs.encode(query); 3378 33933379 -1 // avoid port if default for schema3380 -1 if (this.port && (('https' == schema && this.port != 443) ||3381 -1 ('http' == schema && this.port != 80))) {3382 -1 port = ':' + this.port;3383 -1 }3384 -13385 3394 // prepend ? to query 3386 3395 if (query.length) { 3387 3396 query = '?' + query; @@ -3391,13163 +3400,12646 @@ Polling.prototype.uri = function(){ 3391 3400 return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query; 3392 3401 }; 3393 34023394 -1 },{"../transport":17,"component-inherit":11,"debug":12,"engine.io-parser":24,"parseqs":98,"xmlhttprequest-ssl":23,"yeast":146}],22:[function(require,module,exports){3395 -1 (function (global){3396 3403 /**3397 -1 * Module dependencies.-1 3404 * Feature detection for WebSocket. -1 3405 * -1 3406 * @return {Boolean} whether this transport is available. -1 3407 * @api public 3398 3408 */ 3399 34093400 -1 var Transport = require('../transport');3401 -1 var parser = require('engine.io-parser');3402 -1 var parseqs = require('parseqs');3403 -1 var inherit = require('component-inherit');3404 -1 var yeast = require('yeast');3405 -1 var debug = require('debug')('engine.io-client:websocket');3406 -1 var BrowserWebSocket = global.WebSocket || global.MozWebSocket;-1 3410 WS.prototype.check = function () { -1 3411 return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name); -1 3412 }; 3407 34133408 -1 /**3409 -1 * Get either the `WebSocket` or `MozWebSocket` globals3410 -1 * in the browser or try to resolve WebSocket-compatible3411 -1 * interface exposed by `ws` for Node-like environment.3412 -1 */-1 3414 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 3415 },{"../transport":15,"component-inherit":11,"debug":23,"engine.io-parser":26,"parseqs":94,"ws":1,"yeast":120}],21:[function(require,module,exports){ -1 3416 (function (global){ -1 3417 // browser shim for xmlhttprequest module 3413 34183414 -1 var WebSocket = BrowserWebSocket;3415 -1 if (!WebSocket && typeof window === 'undefined') {-1 3419 var hasCORS = require('has-cors'); -1 3420 -1 3421 module.exports = function (opts) { -1 3422 var xdomain = opts.xdomain; -1 3423 -1 3424 // scheme must be same when usign XDomainRequest -1 3425 // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx -1 3426 var xscheme = opts.xscheme; -1 3427 -1 3428 // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default. -1 3429 // https://github.com/Automattic/engine.io-client/pull/217 -1 3430 var enablesXDR = opts.enablesXDR; -1 3431 -1 3432 // XMLHttpRequest can be disabled on IE 3416 3433 try {3417 -1 WebSocket = require('ws');-1 3434 if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) { -1 3435 return new XMLHttpRequest(); -1 3436 } 3418 3437 } catch (e) { }3419 -1 }3420 34383421 -1 /**3422 -1 * Module exports.3423 -1 */-1 3439 // Use XDomainRequest for IE8 if enablesXDR is true -1 3440 // because loading bar keeps flashing when using jsonp-polling -1 3441 // https://github.com/yujiosaka/socke.io-ie8-loading-example -1 3442 try { -1 3443 if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) { -1 3444 return new XDomainRequest(); -1 3445 } -1 3446 } catch (e) { } 3424 34473425 -1 module.exports = WS;-1 3448 if (!xdomain) { -1 3449 try { -1 3450 return new global[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP'); -1 3451 } catch (e) { } -1 3452 } -1 3453 }; -1 3454 -1 3455 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 3456 },{"has-cors":30}],22:[function(require,module,exports){ -1 3457 -1 3458 /** -1 3459 * Expose `Emitter`. -1 3460 */ -1 3461 -1 3462 if (typeof module !== 'undefined') { -1 3463 module.exports = Emitter; -1 3464 } -1 3465 -1 3466 /** -1 3467 * Initialize a new `Emitter`. -1 3468 * -1 3469 * @api public -1 3470 */ -1 3471 -1 3472 function Emitter(obj) { -1 3473 if (obj) return mixin(obj); -1 3474 }; -1 3475 -1 3476 /** -1 3477 * Mixin the emitter properties. -1 3478 * -1 3479 * @param {Object} obj -1 3480 * @return {Object} -1 3481 * @api private -1 3482 */ -1 3483 -1 3484 function mixin(obj) { -1 3485 for (var key in Emitter.prototype) { -1 3486 obj[key] = Emitter.prototype[key]; -1 3487 } -1 3488 return obj; -1 3489 } -1 3490 -1 3491 /** -1 3492 * Listen on the given `event` with `fn`. -1 3493 * -1 3494 * @param {String} event -1 3495 * @param {Function} fn -1 3496 * @return {Emitter} -1 3497 * @api public -1 3498 */ -1 3499 -1 3500 Emitter.prototype.on = -1 3501 Emitter.prototype.addEventListener = function(event, fn){ -1 3502 this._callbacks = this._callbacks || {}; -1 3503 (this._callbacks['$' + event] = this._callbacks['$' + event] || []) -1 3504 .push(fn); -1 3505 return this; -1 3506 }; -1 3507 -1 3508 /** -1 3509 * Adds an `event` listener that will be invoked a single -1 3510 * time then automatically removed. -1 3511 * -1 3512 * @param {String} event -1 3513 * @param {Function} fn -1 3514 * @return {Emitter} -1 3515 * @api public -1 3516 */ -1 3517 -1 3518 Emitter.prototype.once = function(event, fn){ -1 3519 function on() { -1 3520 this.off(event, on); -1 3521 fn.apply(this, arguments); -1 3522 } -1 3523 -1 3524 on.fn = fn; -1 3525 this.on(event, on); -1 3526 return this; -1 3527 }; -1 3528 -1 3529 /** -1 3530 * Remove the given callback for `event` or all -1 3531 * registered callbacks. -1 3532 * -1 3533 * @param {String} event -1 3534 * @param {Function} fn -1 3535 * @return {Emitter} -1 3536 * @api public -1 3537 */ -1 3538 -1 3539 Emitter.prototype.off = -1 3540 Emitter.prototype.removeListener = -1 3541 Emitter.prototype.removeAllListeners = -1 3542 Emitter.prototype.removeEventListener = function(event, fn){ -1 3543 this._callbacks = this._callbacks || {}; -1 3544 -1 3545 // all -1 3546 if (0 == arguments.length) { -1 3547 this._callbacks = {}; -1 3548 return this; -1 3549 } -1 3550 -1 3551 // specific event -1 3552 var callbacks = this._callbacks['$' + event]; -1 3553 if (!callbacks) return this; -1 3554 -1 3555 // remove all handlers -1 3556 if (1 == arguments.length) { -1 3557 delete this._callbacks['$' + event]; -1 3558 return this; -1 3559 } -1 3560 -1 3561 // remove specific handler -1 3562 var cb; -1 3563 for (var i = 0; i < callbacks.length; i++) { -1 3564 cb = callbacks[i]; -1 3565 if (cb === fn || cb.fn === fn) { -1 3566 callbacks.splice(i, 1); -1 3567 break; -1 3568 } -1 3569 } -1 3570 return this; -1 3571 }; -1 3572 -1 3573 /** -1 3574 * Emit `event` with the given args. -1 3575 * -1 3576 * @param {String} event -1 3577 * @param {Mixed} ... -1 3578 * @return {Emitter} -1 3579 */ -1 3580 -1 3581 Emitter.prototype.emit = function(event){ -1 3582 this._callbacks = this._callbacks || {}; -1 3583 var args = [].slice.call(arguments, 1) -1 3584 , callbacks = this._callbacks['$' + event]; -1 3585 -1 3586 if (callbacks) { -1 3587 callbacks = callbacks.slice(0); -1 3588 for (var i = 0, len = callbacks.length; i < len; ++i) { -1 3589 callbacks[i].apply(this, args); -1 3590 } -1 3591 } -1 3592 -1 3593 return this; -1 3594 }; -1 3595 -1 3596 /** -1 3597 * Return array of callbacks for `event`. -1 3598 * -1 3599 * @param {String} event -1 3600 * @return {Array} -1 3601 * @api public -1 3602 */ -1 3603 -1 3604 Emitter.prototype.listeners = function(event){ -1 3605 this._callbacks = this._callbacks || {}; -1 3606 return this._callbacks['$' + event] || []; -1 3607 }; -1 3608 -1 3609 /** -1 3610 * Check if this emitter has `event` handlers. -1 3611 * -1 3612 * @param {String} event -1 3613 * @return {Boolean} -1 3614 * @api public -1 3615 */ -1 3616 -1 3617 Emitter.prototype.hasListeners = function(event){ -1 3618 return !! this.listeners(event).length; -1 3619 }; -1 3620 -1 3621 },{}],23:[function(require,module,exports){ -1 3622 (function (process){ 3426 3623 3427 3624 /**3428 -1 * WebSocket transport constructor.-1 3625 * This is the web browser implementation of `debug()`. 3429 3626 *3430 -1 * @api {Object} connection options3431 -1 * @api public-1 3627 * Expose `debug()` as the module. 3432 3628 */ 3433 36293434 -1 function WS(opts){3435 -1 var forceBase64 = (opts && opts.forceBase64);3436 -1 if (forceBase64) {3437 -1 this.supportsBinary = false;3438 -1 }3439 -1 this.perMessageDeflate = opts.perMessageDeflate;3440 -1 Transport.call(this, opts);3441 -1 }-1 3630 exports = module.exports = require('./debug'); -1 3631 exports.log = log; -1 3632 exports.formatArgs = formatArgs; -1 3633 exports.save = save; -1 3634 exports.load = load; -1 3635 exports.useColors = useColors; -1 3636 exports.storage = 'undefined' != typeof chrome -1 3637 && 'undefined' != typeof chrome.storage -1 3638 ? chrome.storage.local -1 3639 : localstorage(); 3442 3640 3443 3641 /**3444 -1 * Inherits from Transport.-1 3642 * Colors. 3445 3643 */ 3446 36443447 -1 inherit(WS, Transport);-1 3645 exports.colors = [ -1 3646 'lightseagreen', -1 3647 'forestgreen', -1 3648 'goldenrod', -1 3649 'dodgerblue', -1 3650 'darkorchid', -1 3651 'crimson' -1 3652 ]; 3448 3653 3449 3654 /**3450 -1 * Transport name.-1 3655 * Currently only WebKit-based Web Inspectors, Firefox >= v31, -1 3656 * and the Firebug extension (any Firefox version) are known -1 3657 * to support "%c" CSS customizations. 3451 3658 *3452 -1 * @api public-1 3659 * TODO: add a `localStorage` variable to explicitly enable/disable colors 3453 3660 */ 3454 36613455 -1 WS.prototype.name = 'websocket';-1 3662 function useColors() { -1 3663 // is webkit? http://stackoverflow.com/a/16459606/376773 -1 3664 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 -1 3665 return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || -1 3666 // is firebug? http://stackoverflow.com/a/398120/376773 -1 3667 (window.console && (console.firebug || (console.exception && console.table))) || -1 3668 // is firefox >= v31? -1 3669 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages -1 3670 (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -1 3671 } 3456 36723457 -1 /*3458 -1 * WebSockets support binary-1 3673 /** -1 3674 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. 3459 3675 */ 3460 36763461 -1 WS.prototype.supportsBinary = true;-1 3677 exports.formatters.j = function(v) { -1 3678 try { -1 3679 return JSON.stringify(v); -1 3680 } catch (err) { -1 3681 return '[UnexpectedJSONParseError]: ' + err.message; -1 3682 } -1 3683 }; -1 3684 3462 3685 3463 3686 /**3464 -1 * Opens socket.-1 3687 * Colorize log arguments if enabled. 3465 3688 *3466 -1 * @api private-1 3689 * @api public 3467 3690 */ 3468 36913469 -1 WS.prototype.doOpen = function(){3470 -1 if (!this.check()) {3471 -1 // let probe timeout3472 -1 return;3473 -1 }3474 -13475 -1 var self = this;3476 -1 var uri = this.uri();3477 -1 var protocols = void(0);3478 -1 var opts = {3479 -1 agent: this.agent,3480 -1 perMessageDeflate: this.perMessageDeflate3481 -1 };-1 3692 function formatArgs() { -1 3693 var args = arguments; -1 3694 var useColors = this.useColors; 3482 36953483 -1 // SSL options for Node.js client3484 -1 opts.pfx = this.pfx;3485 -1 opts.key = this.key;3486 -1 opts.passphrase = this.passphrase;3487 -1 opts.cert = this.cert;3488 -1 opts.ca = this.ca;3489 -1 opts.ciphers = this.ciphers;3490 -1 opts.rejectUnauthorized = this.rejectUnauthorized;3491 -1 if (this.extraHeaders) {3492 -1 opts.headers = this.extraHeaders;3493 -1 }-1 3696 args[0] = (useColors ? '%c' : '') -1 3697 + this.namespace -1 3698 + (useColors ? ' %c' : ' ') -1 3699 + args[0] -1 3700 + (useColors ? '%c ' : ' ') -1 3701 + '+' + exports.humanize(this.diff); 3494 37023495 -1 this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts);-1 3703 if (!useColors) return args; 3496 37043497 -1 if (this.ws.binaryType === undefined) {3498 -1 this.supportsBinary = false;3499 -1 }-1 3705 var c = 'color: ' + this.color; -1 3706 args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); 3500 37073501 -1 if (this.ws.supports && this.ws.supports.binary) {3502 -1 this.supportsBinary = true;3503 -1 this.ws.binaryType = 'buffer';3504 -1 } else {3505 -1 this.ws.binaryType = 'arraybuffer';3506 -1 }-1 3708 // the final "%c" is somewhat tricky, because there could be other -1 3709 // arguments passed either before or after the %c, so we need to -1 3710 // figure out the correct index to insert the CSS into -1 3711 var index = 0; -1 3712 var lastC = 0; -1 3713 args[0].replace(/%[a-z%]/g, function(match) { -1 3714 if ('%%' === match) return; -1 3715 index++; -1 3716 if ('%c' === match) { -1 3717 // we only are interested in the *last* %c -1 3718 // (the user may have provided their own) -1 3719 lastC = index; -1 3720 } -1 3721 }); 3507 37223508 -1 this.addEventListeners();3509 -1 };-1 3723 args.splice(lastC, 0, c); -1 3724 return args; -1 3725 } 3510 3726 3511 3727 /**3512 -1 * Adds event listeners to the socket-1 3728 * Invokes `console.log()` when available. -1 3729 * No-op when `console.log` is not a "function". 3513 3730 *3514 -1 * @api private-1 3731 * @api public 3515 3732 */ 3516 37333517 -1 WS.prototype.addEventListeners = function(){3518 -1 var self = this;3519 -13520 -1 this.ws.onopen = function(){3521 -1 self.onOpen();3522 -1 };3523 -1 this.ws.onclose = function(){3524 -1 self.onClose();3525 -1 };3526 -1 this.ws.onmessage = function(ev){3527 -1 self.onData(ev.data);3528 -1 };3529 -1 this.ws.onerror = function(e){3530 -1 self.onError('websocket error', e);3531 -1 };3532 -1 };-1 3734 function log() { -1 3735 // this hackery is required for IE8/9, where -1 3736 // the `console.log` function doesn't have 'apply' -1 3737 return 'object' === typeof console -1 3738 && console.log -1 3739 && Function.prototype.apply.call(console.log, console, arguments); -1 3740 } 3533 3741 3534 3742 /**3535 -1 * Override `onData` to use a timer on iOS.3536 -1 * See: https://gist.github.com/mloughran/2052006-1 3743 * Save `namespaces`. 3537 3744 * -1 3745 * @param {String} namespaces 3538 3746 * @api private 3539 3747 */ 3540 37483541 -1 if ('undefined' != typeof navigator3542 -1 && /iPad|iPhone|iPod/i.test(navigator.userAgent)) {3543 -1 WS.prototype.onData = function(data){3544 -1 var self = this;3545 -1 setTimeout(function(){3546 -1 Transport.prototype.onData.call(self, data);3547 -1 }, 0);3548 -1 };-1 3749 function save(namespaces) { -1 3750 try { -1 3751 if (null == namespaces) { -1 3752 exports.storage.removeItem('debug'); -1 3753 } else { -1 3754 exports.storage.debug = namespaces; -1 3755 } -1 3756 } catch(e) {} 3549 3757 } 3550 3758 3551 3759 /**3552 -1 * Writes data to socket.-1 3760 * Load `namespaces`. 3553 3761 *3554 -1 * @param {Array} array of packets.-1 3762 * @return {String} returns the previously persisted debug modes 3555 3763 * @api private 3556 3764 */ 3557 37653558 -1 WS.prototype.write = function(packets){3559 -1 var self = this;3560 -1 this.writable = false;3561 -13562 -1 // encodePacket efficient as it uses WS framing3563 -1 // no need for encodePayload3564 -1 var total = packets.length;3565 -1 for (var i = 0, l = total; i < l; i++) {3566 -1 (function(packet) {3567 -1 parser.encodePacket(packet, self.supportsBinary, function(data) {3568 -1 if (!BrowserWebSocket) {3569 -1 // always create a new object (GH-437)3570 -1 var opts = {};3571 -1 if (packet.options) {3572 -1 opts.compress = packet.options.compress;3573 -1 }3574 -13575 -1 if (self.perMessageDeflate) {3576 -1 var len = 'string' == typeof data ? global.Buffer.byteLength(data) : data.length;3577 -1 if (len < self.perMessageDeflate.threshold) {3578 -1 opts.compress = false;3579 -1 }3580 -1 }3581 -1 }3582 -13583 -1 //Sometimes the websocket has already been closed but the browser didn't3584 -1 //have a chance of informing us about it yet, in that case send will3585 -1 //throw an error3586 -1 try {3587 -1 if (BrowserWebSocket) {3588 -1 // TypeError is thrown when passing the second argument on Safari3589 -1 self.ws.send(data);3590 -1 } else {3591 -1 self.ws.send(data, opts);3592 -1 }3593 -1 } catch (e){3594 -1 debug('websocket closed before onclose event');3595 -1 }3596 -13597 -1 --total || done();3598 -1 });3599 -1 })(packets[i]);3600 -1 }3601 -13602 -1 function done(){3603 -1 self.emit('flush');-1 3766 function load() { -1 3767 var r; -1 3768 try { -1 3769 return exports.storage.debug; -1 3770 } catch(e) {} 3604 37713605 -1 // fake drain3606 -1 // defer to next tick to allow Socket to clear writeBuffer3607 -1 setTimeout(function(){3608 -1 self.writable = true;3609 -1 self.emit('drain');3610 -1 }, 0);-1 3772 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG -1 3773 if (typeof process !== 'undefined' && 'env' in process) { -1 3774 return process.env.DEBUG; 3611 3775 }3612 -1 };-1 3776 } 3613 3777 3614 3778 /**3615 -1 * Called upon close3616 -1 *3617 -1 * @api private-1 3779 * Enable namespaces listed in `localStorage.debug` initially. 3618 3780 */ 3619 37813620 -1 WS.prototype.onClose = function(){3621 -1 Transport.prototype.onClose.call(this);3622 -1 };-1 3782 exports.enable(load()); 3623 3783 3624 3784 /**3625 -1 * Closes socket.-1 3785 * Localstorage attempts to return the localstorage. 3626 3786 *3627 -1 * @api private3628 -1 */3629 -13630 -1 WS.prototype.doClose = function(){3631 -1 if (typeof this.ws !== 'undefined') {3632 -1 this.ws.close();3633 -1 }3634 -1 };3635 -13636 -1 /**3637 -1 * Generates uri for connection.-1 3787 * This is necessary because safari throws -1 3788 * when a user disables cookies/localstorage -1 3789 * and you attempt to access it. 3638 3790 * -1 3791 * @return {LocalStorage} 3639 3792 * @api private 3640 3793 */ 3641 37943642 -1 WS.prototype.uri = function(){3643 -1 var query = this.query || {};3644 -1 var schema = this.secure ? 'wss' : 'ws';3645 -1 var port = '';3646 -13647 -1 // avoid port if default for schema3648 -1 if (this.port && (('wss' == schema && this.port != 443)3649 -1 || ('ws' == schema && this.port != 80))) {3650 -1 port = ':' + this.port;3651 -1 }3652 -13653 -1 // append timestamp to URI3654 -1 if (this.timestampRequests) {3655 -1 query[this.timestampParam] = yeast();3656 -1 }3657 -13658 -1 // communicate binary support capabilities3659 -1 if (!this.supportsBinary) {3660 -1 query.b64 = 1;3661 -1 }3662 -13663 -1 query = parseqs.encode(query);3664 -13665 -1 // prepend ? to query3666 -1 if (query.length) {3667 -1 query = '?' + query;3668 -1 }-1 3795 function localstorage(){ -1 3796 try { -1 3797 return window.localStorage; -1 3798 } catch (e) {} -1 3799 } 3669 38003670 -1 var ipv6 = this.hostname.indexOf(':') !== -1;3671 -1 return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;3672 -1 };-1 3801 }).call(this,require('_process')) -1 3802 },{"./debug":24,"_process":2}],24:[function(require,module,exports){ 3673 3803 3674 3804 /**3675 -1 * Feature detection for WebSocket.-1 3805 * This is the common logic for both the Node.js and web browser -1 3806 * implementations of `debug()`. 3676 3807 *3677 -1 * @return {Boolean} whether this transport is available.3678 -1 * @api public-1 3808 * Expose `debug()` as the module. 3679 3809 */ 3680 38103681 -1 WS.prototype.check = function(){3682 -1 return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name);3683 -1 };3684 -13685 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})3686 -1 },{"../transport":17,"component-inherit":11,"debug":12,"engine.io-parser":24,"parseqs":98,"ws":1,"yeast":146}],23:[function(require,module,exports){3687 -1 // browser shim for xmlhttprequest module3688 -1 var hasCORS = require('has-cors');3689 -13690 -1 module.exports = function(opts) {3691 -1 var xdomain = opts.xdomain;3692 -13693 -1 // scheme must be same when usign XDomainRequest3694 -1 // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx3695 -1 var xscheme = opts.xscheme;3696 -13697 -1 // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.3698 -1 // https://github.com/Automattic/engine.io-client/pull/2173699 -1 var enablesXDR = opts.enablesXDR;3700 -13701 -1 // XMLHttpRequest can be disabled on IE3702 -1 try {3703 -1 if ('undefined' != typeof XMLHttpRequest && (!xdomain || hasCORS)) {3704 -1 return new XMLHttpRequest();3705 -1 }3706 -1 } catch (e) { }3707 -13708 -1 // Use XDomainRequest for IE8 if enablesXDR is true3709 -1 // because loading bar keeps flashing when using jsonp-polling3710 -1 // https://github.com/yujiosaka/socke.io-ie8-loading-example3711 -1 try {3712 -1 if ('undefined' != typeof XDomainRequest && !xscheme && enablesXDR) {3713 -1 return new XDomainRequest();3714 -1 }3715 -1 } catch (e) { }3716 -13717 -1 if (!xdomain) {3718 -1 try {3719 -1 return new ActiveXObject('Microsoft.XMLHTTP');3720 -1 } catch(e) { }3721 -1 }3722 -1 }-1 3811 exports = module.exports = debug.debug = debug; -1 3812 exports.coerce = coerce; -1 3813 exports.disable = disable; -1 3814 exports.enable = enable; -1 3815 exports.enabled = enabled; -1 3816 exports.humanize = require('ms'); 3723 38173724 -1 },{"has-cors":31}],24:[function(require,module,exports){3725 -1 (function (global){3726 3818 /**3727 -1 * Module dependencies.-1 3819 * The currently active debug mode names, and names to skip. 3728 3820 */ 3729 38213730 -1 var keys = require('./keys');3731 -1 var hasBinary = require('has-binary');3732 -1 var sliceBuffer = require('arraybuffer.slice');3733 -1 var base64encoder = require('base64-arraybuffer');3734 -1 var after = require('after');3735 -1 var utf8 = require('utf8');-1 3822 exports.names = []; -1 3823 exports.skips = []; 3736 3824 3737 3825 /**3738 -1 * Check if we are running an android browser. That requires us to use3739 -1 * ArrayBuffer with polling transports...-1 3826 * Map of special "%n" handling functions, for the debug "format" argument. 3740 3827 *3741 -1 * http://ghinda.net/jpeg-blob-ajax-android/-1 3828 * Valid key names are a single, lowercased letter, i.e. "n". 3742 3829 */ 3743 38303744 -1 var isAndroid = navigator.userAgent.match(/Android/i);-1 3831 exports.formatters = {}; 3745 3832 3746 3833 /**3747 -1 * Check if we are running in PhantomJS.3748 -1 * Uploading a Blob with PhantomJS does not work correctly, as reported here:3749 -1 * https://github.com/ariya/phantomjs/issues/113953750 -1 * @type boolean-1 3834 * Previously assigned color. 3751 3835 */3752 -1 var isPhantomJS = /PhantomJS/i.test(navigator.userAgent);3753 38363754 -1 /**3755 -1 * When true, avoids using Blobs to encode payloads.3756 -1 * @type boolean3757 -1 */3758 -1 var dontSendBlobs = isAndroid || isPhantomJS;-1 3837 var prevColor = 0; 3759 3838 3760 3839 /**3761 -1 * Current protocol version.-1 3840 * Previous log timestamp. 3762 3841 */ 3763 38423764 -1 exports.protocol = 3;-1 3843 var prevTime; 3765 3844 3766 3845 /**3767 -1 * Packet types.-1 3846 * Select a color. -1 3847 * -1 3848 * @return {Number} -1 3849 * @api private 3768 3850 */ 3769 38513770 -1 var packets = exports.packets = {3771 -1 open: 0 // non-ws3772 -1 , close: 1 // non-ws3773 -1 , ping: 23774 -1 , pong: 33775 -1 , message: 43776 -1 , upgrade: 53777 -1 , noop: 63778 -1 };3779 -13780 -1 var packetslist = keys(packets);-1 3852 function selectColor() { -1 3853 return exports.colors[prevColor++ % exports.colors.length]; -1 3854 } 3781 3855 3782 3856 /**3783 -1 * Premade error packet.-1 3857 * Create a debugger with the given `namespace`. -1 3858 * -1 3859 * @param {String} namespace -1 3860 * @return {Function} -1 3861 * @api public 3784 3862 */ 3785 38633786 -1 var err = { type: 'error', data: 'parser error' };-1 3864 function debug(namespace) { 3787 38653788 -1 /**3789 -1 * Create a blob api even for blob builder when vendor prefixes exist3790 -1 */-1 3866 // define the `disabled` version -1 3867 function disabled() { -1 3868 } -1 3869 disabled.enabled = false; 3791 38703792 -1 var Blob = require('blob');-1 3871 // define the `enabled` version -1 3872 function enabled() { 3793 38733794 -1 /**3795 -1 * Encodes a packet.3796 -1 *3797 -1 * <packet type id> [ <data> ]3798 -1 *3799 -1 * Example:3800 -1 *3801 -1 * 5hello world3802 -1 * 33803 -1 * 43804 -1 *3805 -1 * Binary is encoded in an identical principle3806 -1 *3807 -1 * @api private3808 -1 */-1 3874 var self = enabled; 3809 38753810 -1 exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {3811 -1 if ('function' == typeof supportsBinary) {3812 -1 callback = supportsBinary;3813 -1 supportsBinary = false;3814 -1 }-1 3876 // set `diff` timestamp -1 3877 var curr = +new Date(); -1 3878 var ms = curr - (prevTime || curr); -1 3879 self.diff = ms; -1 3880 self.prev = prevTime; -1 3881 self.curr = curr; -1 3882 prevTime = curr; 3815 38833816 -1 if ('function' == typeof utf8encode) {3817 -1 callback = utf8encode;3818 -1 utf8encode = null;3819 -1 }-1 3884 // add the `color` if not set -1 3885 if (null == self.useColors) self.useColors = exports.useColors(); -1 3886 if (null == self.color && self.useColors) self.color = selectColor(); 3820 38873821 -1 var data = (packet.data === undefined)3822 -1 ? undefined3823 -1 : packet.data.buffer || packet.data;-1 3888 var args = new Array(arguments.length); -1 3889 for (var i = 0; i < args.length; i++) { -1 3890 args[i] = arguments[i]; -1 3891 } 3824 38923825 -1 if (global.ArrayBuffer && data instanceof ArrayBuffer) {3826 -1 return encodeArrayBuffer(packet, supportsBinary, callback);3827 -1 } else if (Blob && data instanceof global.Blob) {3828 -1 return encodeBlob(packet, supportsBinary, callback);3829 -1 }-1 3893 args[0] = exports.coerce(args[0]); 3830 38943831 -1 // might be an object with { base64: true, data: dataAsBase64String }3832 -1 if (data && data.base64) {3833 -1 return encodeBase64Object(packet, callback);3834 -1 }-1 3895 if ('string' !== typeof args[0]) { -1 3896 // anything else let's inspect with %o -1 3897 args = ['%o'].concat(args); -1 3898 } 3835 38993836 -1 // Sending data as a utf-8 string3837 -1 var encoded = packets[packet.type];-1 3900 // apply any `formatters` transformations -1 3901 var index = 0; -1 3902 args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { -1 3903 // if we encounter an escaped % then don't increase the array index -1 3904 if (match === '%%') return match; -1 3905 index++; -1 3906 var formatter = exports.formatters[format]; -1 3907 if ('function' === typeof formatter) { -1 3908 var val = args[index]; -1 3909 match = formatter.call(self, val); 3838 39103839 -1 // data fragment is optional3840 -1 if (undefined !== packet.data) {3841 -1 encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data);-1 3911 // now we need to remove `args[index]` since it's inlined in the `format` -1 3912 args.splice(index, 1); -1 3913 index--; -1 3914 } -1 3915 return match; -1 3916 }); -1 3917 -1 3918 // apply env-specific formatting -1 3919 args = exports.formatArgs.apply(self, args); -1 3920 -1 3921 var logFn = enabled.log || exports.log || console.log.bind(console); -1 3922 logFn.apply(self, args); 3842 3923 } -1 3924 enabled.enabled = true; 3843 39253844 -1 return callback('' + encoded);-1 3926 var fn = exports.enabled(namespace) ? enabled : disabled; 3845 39273846 -1 };-1 3928 fn.namespace = namespace; 3847 39293848 -1 function encodeBase64Object(packet, callback) {3849 -1 // packet data is an object { base64: true, data: dataAsBase64String }3850 -1 var message = 'b' + exports.packets[packet.type] + packet.data.data;3851 -1 return callback(message);-1 3930 return fn; 3852 3931 } 3853 3932 3854 3933 /**3855 -1 * Encode packet helpers for binary types-1 3934 * Enables a debug mode by namespaces. This can include modes -1 3935 * separated by a colon and wildcards. -1 3936 * -1 3937 * @param {String} namespaces -1 3938 * @api public 3856 3939 */ 3857 39403858 -1 function encodeArrayBuffer(packet, supportsBinary, callback) {3859 -1 if (!supportsBinary) {3860 -1 return exports.encodeBase64Packet(packet, callback);3861 -1 }3862 -13863 -1 var data = packet.data;3864 -1 var contentArray = new Uint8Array(data);3865 -1 var resultBuffer = new Uint8Array(1 + data.byteLength);3866 -13867 -1 resultBuffer[0] = packets[packet.type];3868 -1 for (var i = 0; i < contentArray.length; i++) {3869 -1 resultBuffer[i+1] = contentArray[i];3870 -1 }-1 3941 function enable(namespaces) { -1 3942 exports.save(namespaces); 3871 39433872 -1 return callback(resultBuffer.buffer);3873 -1 }-1 3944 var split = (namespaces || '').split(/[\s,]+/); -1 3945 var len = split.length; 3874 39463875 -1 function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {3876 -1 if (!supportsBinary) {3877 -1 return exports.encodeBase64Packet(packet, callback);-1 3947 for (var i = 0; i < len; i++) { -1 3948 if (!split[i]) continue; // ignore empty strings -1 3949 namespaces = split[i].replace(/[\\^$+?.()|[\]{}]/g, '\\$&').replace(/\*/g, '.*?'); -1 3950 if (namespaces[0] === '-') { -1 3951 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); -1 3952 } else { -1 3953 exports.names.push(new RegExp('^' + namespaces + '$')); -1 3954 } 3878 3955 }3879 -13880 -1 var fr = new FileReader();3881 -1 fr.onload = function() {3882 -1 packet.data = fr.result;3883 -1 exports.encodePacket(packet, supportsBinary, true, callback);3884 -1 };3885 -1 return fr.readAsArrayBuffer(packet.data);3886 3956 } 3887 39573888 -1 function encodeBlob(packet, supportsBinary, callback) {3889 -1 if (!supportsBinary) {3890 -1 return exports.encodeBase64Packet(packet, callback);3891 -1 }3892 -13893 -1 if (dontSendBlobs) {3894 -1 return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);3895 -1 }3896 -13897 -1 var length = new Uint8Array(1);3898 -1 length[0] = packets[packet.type];3899 -1 var blob = new Blob([length.buffer, packet.data]);-1 3958 /** -1 3959 * Disable debug output. -1 3960 * -1 3961 * @api public -1 3962 */ 3900 39633901 -1 return callback(blob);-1 3964 function disable() { -1 3965 exports.enable(''); 3902 3966 } 3903 3967 3904 3968 /**3905 -1 * Encodes a packet with binary data in a base64 string-1 3969 * Returns true if the given mode name is enabled, false otherwise. 3906 3970 *3907 -1 * @param {Object} packet, has `type` and `data`3908 -1 * @return {String} base64 encoded message-1 3971 * @param {String} name -1 3972 * @return {Boolean} -1 3973 * @api public 3909 3974 */ 3910 39753911 -1 exports.encodeBase64Packet = function(packet, callback) {3912 -1 var message = 'b' + exports.packets[packet.type];3913 -1 if (Blob && packet.data instanceof global.Blob) {3914 -1 var fr = new FileReader();3915 -1 fr.onload = function() {3916 -1 var b64 = fr.result.split(',')[1];3917 -1 callback(message + b64);3918 -1 };3919 -1 return fr.readAsDataURL(packet.data);-1 3976 function enabled(name) { -1 3977 var i, len; -1 3978 for (i = 0, len = exports.skips.length; i < len; i++) { -1 3979 if (exports.skips[i].test(name)) { -1 3980 return false; -1 3981 } 3920 3982 }3921 -13922 -1 var b64data;3923 -1 try {3924 -1 b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));3925 -1 } catch (e) {3926 -1 // iPhone Safari doesn't let you apply with typed arrays3927 -1 var typed = new Uint8Array(packet.data);3928 -1 var basic = new Array(typed.length);3929 -1 for (var i = 0; i < typed.length; i++) {3930 -1 basic[i] = typed[i];-1 3983 for (i = 0, len = exports.names.length; i < len; i++) { -1 3984 if (exports.names[i].test(name)) { -1 3985 return true; 3931 3986 }3932 -1 b64data = String.fromCharCode.apply(null, basic);3933 3987 }3934 -1 message += global.btoa(b64data);3935 -1 return callback(message);3936 -1 };-1 3988 return false; -1 3989 } 3937 3990 3938 3991 /**3939 -1 * Decodes a packet. Changes format to Blob if requested.-1 3992 * Coerce `val`. 3940 3993 *3941 -1 * @return {Object} with `type` and `data` (if any)-1 3994 * @param {Mixed} val -1 3995 * @return {Mixed} 3942 3996 * @api private 3943 3997 */ 3944 39983945 -1 exports.decodePacket = function (data, binaryType, utf8decode) {3946 -1 // String data3947 -1 if (typeof data == 'string' || data === undefined) {3948 -1 if (data.charAt(0) == 'b') {3949 -1 return exports.decodeBase64Packet(data.substr(1), binaryType);3950 -1 }-1 3999 function coerce(val) { -1 4000 if (val instanceof Error) return val.stack || val.message; -1 4001 return val; -1 4002 } 3951 40033952 -1 if (utf8decode) {3953 -1 try {3954 -1 data = utf8.decode(data);3955 -1 } catch (e) {3956 -1 return err;3957 -1 }3958 -1 }3959 -1 var type = data.charAt(0);-1 4004 },{"ms":25}],25:[function(require,module,exports){ -1 4005 /** -1 4006 * Helpers. -1 4007 */ 3960 40083961 -1 if (Number(type) != type || !packetslist[type]) {3962 -1 return err;3963 -1 }-1 4009 var s = 1000 -1 4010 var m = s * 60 -1 4011 var h = m * 60 -1 4012 var d = h * 24 -1 4013 var y = d * 365.25 3964 40143965 -1 if (data.length > 1) {3966 -1 return { type: packetslist[type], data: data.substring(1) };3967 -1 } else {3968 -1 return { type: packetslist[type] };3969 -1 }3970 -1 }-1 4015 /** -1 4016 * Parse or format the given `val`. -1 4017 * -1 4018 * Options: -1 4019 * -1 4020 * - `long` verbose formatting [false] -1 4021 * -1 4022 * @param {String|Number} val -1 4023 * @param {Object} options -1 4024 * @throws {Error} throw an error if val is not a non-empty string or a number -1 4025 * @return {String|Number} -1 4026 * @api public -1 4027 */ 3971 40283972 -1 var asArray = new Uint8Array(data);3973 -1 var type = asArray[0];3974 -1 var rest = sliceBuffer(data, 1);3975 -1 if (Blob && binaryType === 'blob') {3976 -1 rest = new Blob([rest]);-1 4029 module.exports = function (val, options) { -1 4030 options = options || {} -1 4031 var type = typeof val -1 4032 if (type === 'string' && val.length > 0) { -1 4033 return parse(val) -1 4034 } else if (type === 'number' && isNaN(val) === false) { -1 4035 return options.long ? -1 4036 fmtLong(val) : -1 4037 fmtShort(val) 3977 4038 }3978 -1 return { type: packetslist[type], data: rest };3979 -1 };-1 4039 throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)) -1 4040 } 3980 4041 3981 4042 /**3982 -1 * Decodes a packet encoded in a base64 string-1 4043 * Parse the given `str` and return milliseconds. 3983 4044 *3984 -1 * @param {String} base64 encoded message3985 -1 * @return {Object} with `type` and `data` (if any)-1 4045 * @param {String} str -1 4046 * @return {Number} -1 4047 * @api private 3986 4048 */ 3987 40493988 -1 exports.decodeBase64Packet = function(msg, binaryType) {3989 -1 var type = packetslist[msg.charAt(0)];3990 -1 if (!global.ArrayBuffer) {3991 -1 return { type: type, data: { base64: true, data: msg.substr(1) } };-1 4050 function parse(str) { -1 4051 str = String(str) -1 4052 if (str.length > 10000) { -1 4053 return 3992 4054 }3993 -13994 -1 var data = base64encoder.decode(msg.substr(1));3995 -13996 -1 if (binaryType === 'blob' && Blob) {3997 -1 data = new Blob([data]);-1 4055 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str) -1 4056 if (!match) { -1 4057 return 3998 4058 }3999 -14000 -1 return { type: type, data: data };4001 -1 };-1 4059 var n = parseFloat(match[1]) -1 4060 var type = (match[2] || 'ms').toLowerCase() -1 4061 switch (type) { -1 4062 case 'years': -1 4063 case 'year': -1 4064 case 'yrs': -1 4065 case 'yr': -1 4066 case 'y': -1 4067 return n * y -1 4068 case 'days': -1 4069 case 'day': -1 4070 case 'd': -1 4071 return n * d -1 4072 case 'hours': -1 4073 case 'hour': -1 4074 case 'hrs': -1 4075 case 'hr': -1 4076 case 'h': -1 4077 return n * h -1 4078 case 'minutes': -1 4079 case 'minute': -1 4080 case 'mins': -1 4081 case 'min': -1 4082 case 'm': -1 4083 return n * m -1 4084 case 'seconds': -1 4085 case 'second': -1 4086 case 'secs': -1 4087 case 'sec': -1 4088 case 's': -1 4089 return n * s -1 4090 case 'milliseconds': -1 4091 case 'millisecond': -1 4092 case 'msecs': -1 4093 case 'msec': -1 4094 case 'ms': -1 4095 return n -1 4096 default: -1 4097 return undefined -1 4098 } -1 4099 } 4002 4100 4003 4101 /**4004 -1 * Encodes multiple messages (payload).4005 -1 *4006 -1 * <length>:data4007 -1 *4008 -1 * Example:4009 -1 *4010 -1 * 11:hello world2:hi4011 -1 *4012 -1 * If any contents are binary, they will be encoded as base64 strings. Base644013 -1 * encoded strings are marked with a b before the length specifier-1 4102 * Short format for `ms`. 4014 4103 *4015 -1 * @param {Array} packets-1 4104 * @param {Number} ms -1 4105 * @return {String} 4016 4106 * @api private 4017 4107 */ 4018 41084019 -1 exports.encodePayload = function (packets, supportsBinary, callback) {4020 -1 if (typeof supportsBinary == 'function') {4021 -1 callback = supportsBinary;4022 -1 supportsBinary = null;4023 -1 }4024 -14025 -1 var isBinary = hasBinary(packets);4026 -14027 -1 if (supportsBinary && isBinary) {4028 -1 if (Blob && !dontSendBlobs) {4029 -1 return exports.encodePayloadAsBlob(packets, callback);4030 -1 }4031 -14032 -1 return exports.encodePayloadAsArrayBuffer(packets, callback);-1 4109 function fmtShort(ms) { -1 4110 if (ms >= d) { -1 4111 return Math.round(ms / d) + 'd' 4033 4112 }4034 -14035 -1 if (!packets.length) {4036 -1 return callback('0:');-1 4113 if (ms >= h) { -1 4114 return Math.round(ms / h) + 'h' 4037 4115 }4038 -14039 -1 function setLengthHeader(message) {4040 -1 return message.length + ':' + message;-1 4116 if (ms >= m) { -1 4117 return Math.round(ms / m) + 'm' 4041 4118 }4042 -14043 -1 function encodeOne(packet, doneCallback) {4044 -1 exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) {4045 -1 doneCallback(null, setLengthHeader(message));4046 -1 });-1 4119 if (ms >= s) { -1 4120 return Math.round(ms / s) + 's' 4047 4121 }4048 -14049 -1 map(packets, encodeOne, function(err, results) {4050 -1 return callback(results.join(''));4051 -1 });4052 -1 };-1 4122 return ms + 'ms' -1 4123 } 4053 4124 4054 4125 /**4055 -1 * Async array map using after-1 4126 * Long format for `ms`. -1 4127 * -1 4128 * @param {Number} ms -1 4129 * @return {String} -1 4130 * @api private 4056 4131 */ 4057 41324058 -1 function map(ary, each, done) {4059 -1 var result = new Array(ary.length);4060 -1 var next = after(ary.length, done);-1 4133 function fmtLong(ms) { -1 4134 return plural(ms, d, 'day') || -1 4135 plural(ms, h, 'hour') || -1 4136 plural(ms, m, 'minute') || -1 4137 plural(ms, s, 'second') || -1 4138 ms + ' ms' -1 4139 } 4061 41404062 -1 var eachWithIndex = function(i, el, cb) {4063 -1 each(el, function(error, msg) {4064 -1 result[i] = msg;4065 -1 cb(error, result);4066 -1 });4067 -1 };-1 4141 /** -1 4142 * Pluralization helper. -1 4143 */ 4068 41444069 -1 for (var i = 0; i < ary.length; i++) {4070 -1 eachWithIndex(i, ary[i], next);-1 4145 function plural(ms, n, name) { -1 4146 if (ms < n) { -1 4147 return -1 4148 } -1 4149 if (ms < n * 1.5) { -1 4150 return Math.floor(ms / n) + ' ' + name 4071 4151 } -1 4152 return Math.ceil(ms / n) + ' ' + name + 's' 4072 4153 } 4073 41544074 -1 /*4075 -1 * Decodes data when a payload is maybe expected. Possible binary contents are4076 -1 * decoded from their base64 representation4077 -1 *4078 -1 * @param {String} data, callback method4079 -1 * @api public-1 4155 },{}],26:[function(require,module,exports){ -1 4156 (function (global){ -1 4157 /** -1 4158 * Module dependencies. 4080 4159 */ 4081 41604082 -1 exports.decodePayload = function (data, binaryType, callback) {4083 -1 if (typeof data != 'string') {4084 -1 return exports.decodePayloadAsBinary(data, binaryType, callback);4085 -1 }-1 4161 var keys = require('./keys'); -1 4162 var hasBinary = require('has-binary'); -1 4163 var sliceBuffer = require('arraybuffer.slice'); -1 4164 var after = require('after'); -1 4165 var utf8 = require('wtf-8'); 4086 41664087 -1 if (typeof binaryType === 'function') {4088 -1 callback = binaryType;4089 -1 binaryType = null;4090 -1 }-1 4167 var base64encoder; -1 4168 if (global && global.ArrayBuffer) { -1 4169 base64encoder = require('base64-arraybuffer'); -1 4170 } 4091 41714092 -1 var packet;4093 -1 if (data == '') {4094 -1 // parser error - ignoring payload4095 -1 return callback(err, 0, 1);4096 -1 }-1 4172 /** -1 4173 * Check if we are running an android browser. That requires us to use -1 4174 * ArrayBuffer with polling transports... -1 4175 * -1 4176 * http://ghinda.net/jpeg-blob-ajax-android/ -1 4177 */ 4097 41784098 -1 var length = ''4099 -1 , n, msg;-1 4179 var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent); 4100 41804101 -1 for (var i = 0, l = data.length; i < l; i++) {4102 -1 var chr = data.charAt(i);-1 4181 /** -1 4182 * Check if we are running in PhantomJS. -1 4183 * Uploading a Blob with PhantomJS does not work correctly, as reported here: -1 4184 * https://github.com/ariya/phantomjs/issues/11395 -1 4185 * @type boolean -1 4186 */ -1 4187 var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent); 4103 41884104 -1 if (':' != chr) {4105 -1 length += chr;4106 -1 } else {4107 -1 if ('' == length || (length != (n = Number(length)))) {4108 -1 // parser error - ignoring payload4109 -1 return callback(err, 0, 1);4110 -1 }-1 4189 /** -1 4190 * When true, avoids using Blobs to encode payloads. -1 4191 * @type boolean -1 4192 */ -1 4193 var dontSendBlobs = isAndroid || isPhantomJS; 4111 41944112 -1 msg = data.substr(i + 1, n);-1 4195 /** -1 4196 * Current protocol version. -1 4197 */ 4113 41984114 -1 if (length != msg.length) {4115 -1 // parser error - ignoring payload4116 -1 return callback(err, 0, 1);4117 -1 }-1 4199 exports.protocol = 3; 4118 42004119 -1 if (msg.length) {4120 -1 packet = exports.decodePacket(msg, binaryType, true);-1 4201 /** -1 4202 * Packet types. -1 4203 */ 4121 42044122 -1 if (err.type == packet.type && err.data == packet.data) {4123 -1 // parser error in individual packet - ignoring payload4124 -1 return callback(err, 0, 1);4125 -1 }-1 4205 var packets = exports.packets = { -1 4206 open: 0 // non-ws -1 4207 , close: 1 // non-ws -1 4208 , ping: 2 -1 4209 , pong: 3 -1 4210 , message: 4 -1 4211 , upgrade: 5 -1 4212 , noop: 6 -1 4213 }; 4126 42144127 -1 var ret = callback(packet, i + n, l);4128 -1 if (false === ret) return;4129 -1 }-1 4215 var packetslist = keys(packets); 4130 42164131 -1 // advance cursor4132 -1 i += n;4133 -1 length = '';4134 -1 }4135 -1 }-1 4217 /** -1 4218 * Premade error packet. -1 4219 */ 4136 42204137 -1 if (length != '') {4138 -1 // parser error - ignoring payload4139 -1 return callback(err, 0, 1);4140 -1 }-1 4221 var err = { type: 'error', data: 'parser error' }; 4141 42224142 -1 };-1 4223 /** -1 4224 * Create a blob api even for blob builder when vendor prefixes exist -1 4225 */ -1 4226 -1 4227 var Blob = require('blob'); 4143 4228 4144 4229 /**4145 -1 * Encodes multiple messages (payload) as binary.-1 4230 * Encodes a packet. 4146 4231 *4147 -1 * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number4148 -1 * 255><data>-1 4232 * <packet type id> [ <data> ] 4149 4233 * 4150 4234 * Example:4151 -1 * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers4152 4235 *4153 -1 * @param {Array} packets4154 -1 * @return {ArrayBuffer} encoded payload-1 4236 * 5hello world -1 4237 * 3 -1 4238 * 4 -1 4239 * -1 4240 * Binary is encoded in an identical principle -1 4241 * 4155 4242 * @api private 4156 4243 */ 4157 42444158 -1 exports.encodePayloadAsArrayBuffer = function(packets, callback) {4159 -1 if (!packets.length) {4160 -1 return callback(new ArrayBuffer(0));-1 4245 exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) { -1 4246 if ('function' == typeof supportsBinary) { -1 4247 callback = supportsBinary; -1 4248 supportsBinary = false; 4161 4249 } 4162 42504163 -1 function encodeOne(packet, doneCallback) {4164 -1 exports.encodePacket(packet, true, true, function(data) {4165 -1 return doneCallback(null, data);4166 -1 });-1 4251 if ('function' == typeof utf8encode) { -1 4252 callback = utf8encode; -1 4253 utf8encode = null; 4167 4254 } 4168 42554169 -1 map(packets, encodeOne, function(err, encodedPackets) {4170 -1 var totalLength = encodedPackets.reduce(function(acc, p) {4171 -1 var len;4172 -1 if (typeof p === 'string'){4173 -1 len = p.length;4174 -1 } else {4175 -1 len = p.byteLength;4176 -1 }4177 -1 return acc + len.toString().length + len + 2; // string/binary identifier + separator = 24178 -1 }, 0);4179 -14180 -1 var resultArray = new Uint8Array(totalLength);-1 4256 var data = (packet.data === undefined) -1 4257 ? undefined -1 4258 : packet.data.buffer || packet.data; 4181 42594182 -1 var bufferIndex = 0;4183 -1 encodedPackets.forEach(function(p) {4184 -1 var isString = typeof p === 'string';4185 -1 var ab = p;4186 -1 if (isString) {4187 -1 var view = new Uint8Array(p.length);4188 -1 for (var i = 0; i < p.length; i++) {4189 -1 view[i] = p.charCodeAt(i);4190 -1 }4191 -1 ab = view.buffer;4192 -1 }-1 4260 if (global.ArrayBuffer && data instanceof ArrayBuffer) { -1 4261 return encodeArrayBuffer(packet, supportsBinary, callback); -1 4262 } else if (Blob && data instanceof global.Blob) { -1 4263 return encodeBlob(packet, supportsBinary, callback); -1 4264 } 4193 42654194 -1 if (isString) { // not true binary4195 -1 resultArray[bufferIndex++] = 0;4196 -1 } else { // true binary4197 -1 resultArray[bufferIndex++] = 1;4198 -1 }-1 4266 // might be an object with { base64: true, data: dataAsBase64String } -1 4267 if (data && data.base64) { -1 4268 return encodeBase64Object(packet, callback); -1 4269 } 4199 42704200 -1 var lenStr = ab.byteLength.toString();4201 -1 for (var i = 0; i < lenStr.length; i++) {4202 -1 resultArray[bufferIndex++] = parseInt(lenStr[i]);4203 -1 }4204 -1 resultArray[bufferIndex++] = 255;-1 4271 // Sending data as a utf-8 string -1 4272 var encoded = packets[packet.type]; 4205 42734206 -1 var view = new Uint8Array(ab);4207 -1 for (var i = 0; i < view.length; i++) {4208 -1 resultArray[bufferIndex++] = view[i];4209 -1 }4210 -1 });-1 4274 // data fragment is optional -1 4275 if (undefined !== packet.data) { -1 4276 encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data); -1 4277 } -1 4278 -1 4279 return callback('' + encoded); 4211 42804212 -1 return callback(resultArray.buffer);4213 -1 });4214 4281 }; 4215 4282 -1 4283 function encodeBase64Object(packet, callback) { -1 4284 // packet data is an object { base64: true, data: dataAsBase64String } -1 4285 var message = 'b' + exports.packets[packet.type] + packet.data.data; -1 4286 return callback(message); -1 4287 } -1 4288 4216 4289 /**4217 -1 * Encode as Blob-1 4290 * Encode packet helpers for binary types 4218 4291 */ 4219 42924220 -1 exports.encodePayloadAsBlob = function(packets, callback) {4221 -1 function encodeOne(packet, doneCallback) {4222 -1 exports.encodePacket(packet, true, true, function(encoded) {4223 -1 var binaryIdentifier = new Uint8Array(1);4224 -1 binaryIdentifier[0] = 1;4225 -1 if (typeof encoded === 'string') {4226 -1 var view = new Uint8Array(encoded.length);4227 -1 for (var i = 0; i < encoded.length; i++) {4228 -1 view[i] = encoded.charCodeAt(i);4229 -1 }4230 -1 encoded = view.buffer;4231 -1 binaryIdentifier[0] = 0;4232 -1 }-1 4293 function encodeArrayBuffer(packet, supportsBinary, callback) { -1 4294 if (!supportsBinary) { -1 4295 return exports.encodeBase64Packet(packet, callback); -1 4296 } 4233 42974234 -1 var len = (encoded instanceof ArrayBuffer)4235 -1 ? encoded.byteLength4236 -1 : encoded.size;-1 4298 var data = packet.data; -1 4299 var contentArray = new Uint8Array(data); -1 4300 var resultBuffer = new Uint8Array(1 + data.byteLength); 4237 43014238 -1 var lenStr = len.toString();4239 -1 var lengthAry = new Uint8Array(lenStr.length + 1);4240 -1 for (var i = 0; i < lenStr.length; i++) {4241 -1 lengthAry[i] = parseInt(lenStr[i]);4242 -1 }4243 -1 lengthAry[lenStr.length] = 255;-1 4302 resultBuffer[0] = packets[packet.type]; -1 4303 for (var i = 0; i < contentArray.length; i++) { -1 4304 resultBuffer[i+1] = contentArray[i]; -1 4305 } 4244 43064245 -1 if (Blob) {4246 -1 var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);4247 -1 doneCallback(null, blob);4248 -1 }4249 -1 });-1 4307 return callback(resultBuffer.buffer); -1 4308 } -1 4309 -1 4310 function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) { -1 4311 if (!supportsBinary) { -1 4312 return exports.encodeBase64Packet(packet, callback); 4250 4313 } 4251 43144252 -1 map(packets, encodeOne, function(err, results) {4253 -1 return callback(new Blob(results));4254 -1 });4255 -1 };-1 4315 var fr = new FileReader(); -1 4316 fr.onload = function() { -1 4317 packet.data = fr.result; -1 4318 exports.encodePacket(packet, supportsBinary, true, callback); -1 4319 }; -1 4320 return fr.readAsArrayBuffer(packet.data); -1 4321 } 4256 43224257 -1 /*4258 -1 * Decodes data when a payload is maybe expected. Strings are decoded by4259 -1 * interpreting each byte as a key code for entries marked to start with 0. See4260 -1 * description of encodePayloadAsBinary4261 -1 *4262 -1 * @param {ArrayBuffer} data, callback method4263 -1 * @api public4264 -1 */-1 4323 function encodeBlob(packet, supportsBinary, callback) { -1 4324 if (!supportsBinary) { -1 4325 return exports.encodeBase64Packet(packet, callback); -1 4326 } 4265 43274266 -1 exports.decodePayloadAsBinary = function (data, binaryType, callback) {4267 -1 if (typeof binaryType === 'function') {4268 -1 callback = binaryType;4269 -1 binaryType = null;-1 4328 if (dontSendBlobs) { -1 4329 return encodeBlobAsArrayBuffer(packet, supportsBinary, callback); 4270 4330 } 4271 43314272 -1 var bufferTail = data;4273 -1 var buffers = [];-1 4332 var length = new Uint8Array(1); -1 4333 length[0] = packets[packet.type]; -1 4334 var blob = new Blob([length.buffer, packet.data]); 4274 43354275 -1 var numberTooLong = false;4276 -1 while (bufferTail.byteLength > 0) {4277 -1 var tailArray = new Uint8Array(bufferTail);4278 -1 var isString = tailArray[0] === 0;4279 -1 var msgLength = '';-1 4336 return callback(blob); -1 4337 } 4280 43384281 -1 for (var i = 1; ; i++) {4282 -1 if (tailArray[i] == 255) break;-1 4339 /** -1 4340 * Encodes a packet with binary data in a base64 string -1 4341 * -1 4342 * @param {Object} packet, has `type` and `data` -1 4343 * @return {String} base64 encoded message -1 4344 */ 4283 43454284 -1 if (msgLength.length > 310) {4285 -1 numberTooLong = true;4286 -1 break;4287 -1 }-1 4346 exports.encodeBase64Packet = function(packet, callback) { -1 4347 var message = 'b' + exports.packets[packet.type]; -1 4348 if (Blob && packet.data instanceof global.Blob) { -1 4349 var fr = new FileReader(); -1 4350 fr.onload = function() { -1 4351 var b64 = fr.result.split(',')[1]; -1 4352 callback(message + b64); -1 4353 }; -1 4354 return fr.readAsDataURL(packet.data); -1 4355 } 4288 43564289 -1 msgLength += tailArray[i];-1 4357 var b64data; -1 4358 try { -1 4359 b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data)); -1 4360 } catch (e) { -1 4361 // iPhone Safari doesn't let you apply with typed arrays -1 4362 var typed = new Uint8Array(packet.data); -1 4363 var basic = new Array(typed.length); -1 4364 for (var i = 0; i < typed.length; i++) { -1 4365 basic[i] = typed[i]; 4290 4366 } -1 4367 b64data = String.fromCharCode.apply(null, basic); -1 4368 } -1 4369 message += global.btoa(b64data); -1 4370 return callback(message); -1 4371 }; 4291 43724292 -1 if(numberTooLong) return callback(err, 0, 1);-1 4373 /** -1 4374 * Decodes a packet. Changes format to Blob if requested. -1 4375 * -1 4376 * @return {Object} with `type` and `data` (if any) -1 4377 * @api private -1 4378 */ 4293 43794294 -1 bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);4295 -1 msgLength = parseInt(msgLength);-1 4380 exports.decodePacket = function (data, binaryType, utf8decode) { -1 4381 if (data === undefined) { -1 4382 return err; -1 4383 } -1 4384 // String data -1 4385 if (typeof data == 'string') { -1 4386 if (data.charAt(0) == 'b') { -1 4387 return exports.decodeBase64Packet(data.substr(1), binaryType); -1 4388 } 4296 43894297 -1 var msg = sliceBuffer(bufferTail, 0, msgLength);4298 -1 if (isString) {4299 -1 try {4300 -1 msg = String.fromCharCode.apply(null, new Uint8Array(msg));4301 -1 } catch (e) {4302 -1 // iPhone Safari doesn't let you apply to typed arrays4303 -1 var typed = new Uint8Array(msg);4304 -1 msg = '';4305 -1 for (var i = 0; i < typed.length; i++) {4306 -1 msg += String.fromCharCode(typed[i]);4307 -1 }-1 4390 if (utf8decode) { -1 4391 data = tryDecode(data); -1 4392 if (data === false) { -1 4393 return err; 4308 4394 } 4309 4395 } -1 4396 var type = data.charAt(0); 4310 43974311 -1 buffers.push(msg);4312 -1 bufferTail = sliceBuffer(bufferTail, msgLength);-1 4398 if (Number(type) != type || !packetslist[type]) { -1 4399 return err; -1 4400 } -1 4401 -1 4402 if (data.length > 1) { -1 4403 return { type: packetslist[type], data: data.substring(1) }; -1 4404 } else { -1 4405 return { type: packetslist[type] }; -1 4406 } 4313 4407 } 4314 44084315 -1 var total = buffers.length;4316 -1 buffers.forEach(function(buffer, i) {4317 -1 callback(exports.decodePacket(buffer, binaryType, true), i, total);4318 -1 });-1 4409 var asArray = new Uint8Array(data); -1 4410 var type = asArray[0]; -1 4411 var rest = sliceBuffer(data, 1); -1 4412 if (Blob && binaryType === 'blob') { -1 4413 rest = new Blob([rest]); -1 4414 } -1 4415 return { type: packetslist[type], data: rest }; 4319 4416 }; 4320 44174321 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})4322 -1 },{"./keys":25,"after":3,"arraybuffer.slice":4,"base64-arraybuffer":6,"blob":7,"has-binary":26,"utf8":117}],25:[function(require,module,exports){-1 4418 function tryDecode(data) { -1 4419 try { -1 4420 data = utf8.decode(data); -1 4421 } catch (e) { -1 4422 return false; -1 4423 } -1 4424 return data; -1 4425 } 4323 4426 4324 4427 /**4325 -1 * Gets the keys for an object.-1 4428 * Decodes a packet encoded in a base64 string 4326 4429 *4327 -1 * @return {Array} keys4328 -1 * @api private-1 4430 * @param {String} base64 encoded message -1 4431 * @return {Object} with `type` and `data` (if any) 4329 4432 */ 4330 44334331 -1 module.exports = Object.keys || function keys (obj){4332 -1 var arr = [];4333 -1 var has = Object.prototype.hasOwnProperty;-1 4434 exports.decodeBase64Packet = function(msg, binaryType) { -1 4435 var type = packetslist[msg.charAt(0)]; -1 4436 if (!base64encoder) { -1 4437 return { type: type, data: { base64: true, data: msg.substr(1) } }; -1 4438 } 4334 44394335 -1 for (var i in obj) {4336 -1 if (has.call(obj, i)) {4337 -1 arr.push(i);4338 -1 }-1 4440 var data = base64encoder.decode(msg.substr(1)); -1 4441 -1 4442 if (binaryType === 'blob' && Blob) { -1 4443 data = new Blob([data]); 4339 4444 }4340 -1 return arr;-1 4445 -1 4446 return { type: type, data: data }; 4341 4447 }; 4342 44484343 -1 },{}],26:[function(require,module,exports){4344 -1 (function (global){4345 -14346 -1 /*4347 -1 * Module requirements.4348 -1 */4349 -14350 -1 var isArray = require('isarray');4351 -14352 -1 /**4353 -1 * Module exports.4354 -1 */4355 -14356 -1 module.exports = hasBinary;4357 -14358 4449 /**4359 -1 * Checks for binary data.-1 4450 * Encodes multiple messages (payload). 4360 4451 *4361 -1 * Right now only Buffer and ArrayBuffer are supported..-1 4452 * <length>:data 4362 4453 *4363 -1 * @param {Object} anything4364 -1 * @api public-1 4454 * Example: -1 4455 * -1 4456 * 11:hello world2:hi -1 4457 * -1 4458 * If any contents are binary, they will be encoded as base64 strings. Base64 -1 4459 * encoded strings are marked with a b before the length specifier -1 4460 * -1 4461 * @param {Array} packets -1 4462 * @api private 4365 4463 */ 4366 44644367 -1 function hasBinary(data) {4368 -14369 -1 function _hasBinary(obj) {4370 -1 if (!obj) return false;4371 -14372 -1 if ( (global.Buffer && global.Buffer.isBuffer(obj)) ||4373 -1 (global.ArrayBuffer && obj instanceof ArrayBuffer) ||4374 -1 (global.Blob && obj instanceof Blob) ||4375 -1 (global.File && obj instanceof File)4376 -1 ) {4377 -1 return true;4378 -1 }-1 4465 exports.encodePayload = function (packets, supportsBinary, callback) { -1 4466 if (typeof supportsBinary == 'function') { -1 4467 callback = supportsBinary; -1 4468 supportsBinary = null; -1 4469 } 4379 44704380 -1 if (isArray(obj)) {4381 -1 for (var i = 0; i < obj.length; i++) {4382 -1 if (_hasBinary(obj[i])) {4383 -1 return true;4384 -1 }4385 -1 }4386 -1 } else if (obj && 'object' == typeof obj) {4387 -1 if (obj.toJSON) {4388 -1 obj = obj.toJSON();4389 -1 }-1 4471 var isBinary = hasBinary(packets); 4390 44724391 -1 for (var key in obj) {4392 -1 if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) {4393 -1 return true;4394 -1 }4395 -1 }-1 4473 if (supportsBinary && isBinary) { -1 4474 if (Blob && !dontSendBlobs) { -1 4475 return exports.encodePayloadAsBlob(packets, callback); 4396 4476 } 4397 44774398 -1 return false;-1 4478 return exports.encodePayloadAsArrayBuffer(packets, callback); 4399 4479 } 4400 44804401 -1 return _hasBinary(data);4402 -1 }4403 -14404 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})4405 -1 },{"isarray":36}],27:[function(require,module,exports){4406 -1 module.exports={"Aacute":"\u00C1","aacute":"\u00E1","Abreve":"\u0102","abreve":"\u0103","ac":"\u223E","acd":"\u223F","acE":"\u223E\u0333","Acirc":"\u00C2","acirc":"\u00E2","acute":"\u00B4","Acy":"\u0410","acy":"\u0430","AElig":"\u00C6","aelig":"\u00E6","af":"\u2061","Afr":"\uD835\uDD04","afr":"\uD835\uDD1E","Agrave":"\u00C0","agrave":"\u00E0","alefsym":"\u2135","aleph":"\u2135","Alpha":"\u0391","alpha":"\u03B1","Amacr":"\u0100","amacr":"\u0101","amalg":"\u2A3F","amp":"&","AMP":"&","andand":"\u2A55","And":"\u2A53","and":"\u2227","andd":"\u2A5C","andslope":"\u2A58","andv":"\u2A5A","ang":"\u2220","ange":"\u29A4","angle":"\u2220","angmsdaa":"\u29A8","angmsdab":"\u29A9","angmsdac":"\u29AA","angmsdad":"\u29AB","angmsdae":"\u29AC","angmsdaf":"\u29AD","angmsdag":"\u29AE","angmsdah":"\u29AF","angmsd":"\u2221","angrt":"\u221F","angrtvb":"\u22BE","angrtvbd":"\u299D","angsph":"\u2222","angst":"\u00C5","angzarr":"\u237C","Aogon":"\u0104","aogon":"\u0105","Aopf":"\uD835\uDD38","aopf":"\uD835\uDD52","apacir":"\u2A6F","ap":"\u2248","apE":"\u2A70","ape":"\u224A","apid":"\u224B","apos":"'","ApplyFunction":"\u2061","approx":"\u2248","approxeq":"\u224A","Aring":"\u00C5","aring":"\u00E5","Ascr":"\uD835\uDC9C","ascr":"\uD835\uDCB6","Assign":"\u2254","ast":"*","asymp":"\u2248","asympeq":"\u224D","Atilde":"\u00C3","atilde":"\u00E3","Auml":"\u00C4","auml":"\u00E4","awconint":"\u2233","awint":"\u2A11","backcong":"\u224C","backepsilon":"\u03F6","backprime":"\u2035","backsim":"\u223D","backsimeq":"\u22CD","Backslash":"\u2216","Barv":"\u2AE7","barvee":"\u22BD","barwed":"\u2305","Barwed":"\u2306","barwedge":"\u2305","bbrk":"\u23B5","bbrktbrk":"\u23B6","bcong":"\u224C","Bcy":"\u0411","bcy":"\u0431","bdquo":"\u201E","becaus":"\u2235","because":"\u2235","Because":"\u2235","bemptyv":"\u29B0","bepsi":"\u03F6","bernou":"\u212C","Bernoullis":"\u212C","Beta":"\u0392","beta":"\u03B2","beth":"\u2136","between":"\u226C","Bfr":"\uD835\uDD05","bfr":"\uD835\uDD1F","bigcap":"\u22C2","bigcirc":"\u25EF","bigcup":"\u22C3","bigodot":"\u2A00","bigoplus":"\u2A01","bigotimes":"\u2A02","bigsqcup":"\u2A06","bigstar":"\u2605","bigtriangledown":"\u25BD","bigtriangleup":"\u25B3","biguplus":"\u2A04","bigvee":"\u22C1","bigwedge":"\u22C0","bkarow":"\u290D","blacklozenge":"\u29EB","blacksquare":"\u25AA","blacktriangle":"\u25B4","blacktriangledown":"\u25BE","blacktriangleleft":"\u25C2","blacktriangleright":"\u25B8","blank":"\u2423","blk12":"\u2592","blk14":"\u2591","blk34":"\u2593","block":"\u2588","bne":"=\u20E5","bnequiv":"\u2261\u20E5","bNot":"\u2AED","bnot":"\u2310","Bopf":"\uD835\uDD39","bopf":"\uD835\uDD53","bot":"\u22A5","bottom":"\u22A5","bowtie":"\u22C8","boxbox":"\u29C9","boxdl":"\u2510","boxdL":"\u2555","boxDl":"\u2556","boxDL":"\u2557","boxdr":"\u250C","boxdR":"\u2552","boxDr":"\u2553","boxDR":"\u2554","boxh":"\u2500","boxH":"\u2550","boxhd":"\u252C","boxHd":"\u2564","boxhD":"\u2565","boxHD":"\u2566","boxhu":"\u2534","boxHu":"\u2567","boxhU":"\u2568","boxHU":"\u2569","boxminus":"\u229F","boxplus":"\u229E","boxtimes":"\u22A0","boxul":"\u2518","boxuL":"\u255B","boxUl":"\u255C","boxUL":"\u255D","boxur":"\u2514","boxuR":"\u2558","boxUr":"\u2559","boxUR":"\u255A","boxv":"\u2502","boxV":"\u2551","boxvh":"\u253C","boxvH":"\u256A","boxVh":"\u256B","boxVH":"\u256C","boxvl":"\u2524","boxvL":"\u2561","boxVl":"\u2562","boxVL":"\u2563","boxvr":"\u251C","boxvR":"\u255E","boxVr":"\u255F","boxVR":"\u2560","bprime":"\u2035","breve":"\u02D8","Breve":"\u02D8","brvbar":"\u00A6","bscr":"\uD835\uDCB7","Bscr":"\u212C","bsemi":"\u204F","bsim":"\u223D","bsime":"\u22CD","bsolb":"\u29C5","bsol":"\\","bsolhsub":"\u27C8","bull":"\u2022","bullet":"\u2022","bump":"\u224E","bumpE":"\u2AAE","bumpe":"\u224F","Bumpeq":"\u224E","bumpeq":"\u224F","Cacute":"\u0106","cacute":"\u0107","capand":"\u2A44","capbrcup":"\u2A49","capcap":"\u2A4B","cap":"\u2229","Cap":"\u22D2","capcup":"\u2A47","capdot":"\u2A40","CapitalDifferentialD":"\u2145","caps":"\u2229\uFE00","caret":"\u2041","caron":"\u02C7","Cayleys":"\u212D","ccaps":"\u2A4D","Ccaron":"\u010C","ccaron":"\u010D","Ccedil":"\u00C7","ccedil":"\u00E7","Ccirc":"\u0108","ccirc":"\u0109","Cconint":"\u2230","ccups":"\u2A4C","ccupssm":"\u2A50","Cdot":"\u010A","cdot":"\u010B","cedil":"\u00B8","Cedilla":"\u00B8","cemptyv":"\u29B2","cent":"\u00A2","centerdot":"\u00B7","CenterDot":"\u00B7","cfr":"\uD835\uDD20","Cfr":"\u212D","CHcy":"\u0427","chcy":"\u0447","check":"\u2713","checkmark":"\u2713","Chi":"\u03A7","chi":"\u03C7","circ":"\u02C6","circeq":"\u2257","circlearrowleft":"\u21BA","circlearrowright":"\u21BB","circledast":"\u229B","circledcirc":"\u229A","circleddash":"\u229D","CircleDot":"\u2299","circledR":"\u00AE","circledS":"\u24C8","CircleMinus":"\u2296","CirclePlus":"\u2295","CircleTimes":"\u2297","cir":"\u25CB","cirE":"\u29C3","cire":"\u2257","cirfnint":"\u2A10","cirmid":"\u2AEF","cirscir":"\u29C2","ClockwiseContourIntegral":"\u2232","CloseCurlyDoubleQuote":"\u201D","CloseCurlyQuote":"\u2019","clubs":"\u2663","clubsuit":"\u2663","colon":":","Colon":"\u2237","Colone":"\u2A74","colone":"\u2254","coloneq":"\u2254","comma":",","commat":"@","comp":"\u2201","compfn":"\u2218","complement":"\u2201","complexes":"\u2102","cong":"\u2245","congdot":"\u2A6D","Congruent":"\u2261","conint":"\u222E","Conint":"\u222F","ContourIntegral":"\u222E","copf":"\uD835\uDD54","Copf":"\u2102","coprod":"\u2210","Coproduct":"\u2210","copy":"\u00A9","COPY":"\u00A9","copysr":"\u2117","CounterClockwiseContourIntegral":"\u2233","crarr":"\u21B5","cross":"\u2717","Cross":"\u2A2F","Cscr":"\uD835\uDC9E","cscr":"\uD835\uDCB8","csub":"\u2ACF","csube":"\u2AD1","csup":"\u2AD0","csupe":"\u2AD2","ctdot":"\u22EF","cudarrl":"\u2938","cudarrr":"\u2935","cuepr":"\u22DE","cuesc":"\u22DF","cularr":"\u21B6","cularrp":"\u293D","cupbrcap":"\u2A48","cupcap":"\u2A46","CupCap":"\u224D","cup":"\u222A","Cup":"\u22D3","cupcup":"\u2A4A","cupdot":"\u228D","cupor":"\u2A45","cups":"\u222A\uFE00","curarr":"\u21B7","curarrm":"\u293C","curlyeqprec":"\u22DE","curlyeqsucc":"\u22DF","curlyvee":"\u22CE","curlywedge":"\u22CF","curren":"\u00A4","curvearrowleft":"\u21B6","curvearrowright":"\u21B7","cuvee":"\u22CE","cuwed":"\u22CF","cwconint":"\u2232","cwint":"\u2231","cylcty":"\u232D","dagger":"\u2020","Dagger":"\u2021","daleth":"\u2138","darr":"\u2193","Darr":"\u21A1","dArr":"\u21D3","dash":"\u2010","Dashv":"\u2AE4","dashv":"\u22A3","dbkarow":"\u290F","dblac":"\u02DD","Dcaron":"\u010E","dcaron":"\u010F","Dcy":"\u0414","dcy":"\u0434","ddagger":"\u2021","ddarr":"\u21CA","DD":"\u2145","dd":"\u2146","DDotrahd":"\u2911","ddotseq":"\u2A77","deg":"\u00B0","Del":"\u2207","Delta":"\u0394","delta":"\u03B4","demptyv":"\u29B1","dfisht":"\u297F","Dfr":"\uD835\uDD07","dfr":"\uD835\uDD21","dHar":"\u2965","dharl":"\u21C3","dharr":"\u21C2","DiacriticalAcute":"\u00B4","DiacriticalDot":"\u02D9","DiacriticalDoubleAcute":"\u02DD","DiacriticalGrave":"`","DiacriticalTilde":"\u02DC","diam":"\u22C4","diamond":"\u22C4","Diamond":"\u22C4","diamondsuit":"\u2666","diams":"\u2666","die":"\u00A8","DifferentialD":"\u2146","digamma":"\u03DD","disin":"\u22F2","div":"\u00F7","divide":"\u00F7","divideontimes":"\u22C7","divonx":"\u22C7","DJcy":"\u0402","djcy":"\u0452","dlcorn":"\u231E","dlcrop":"\u230D","dollar":"$","Dopf":"\uD835\uDD3B","dopf":"\uD835\uDD55","Dot":"\u00A8","dot":"\u02D9","DotDot":"\u20DC","doteq":"\u2250","doteqdot":"\u2251","DotEqual":"\u2250","dotminus":"\u2238","dotplus":"\u2214","dotsquare":"\u22A1","doublebarwedge":"\u2306","DoubleContourIntegral":"\u222F","DoubleDot":"\u00A8","DoubleDownArrow":"\u21D3","DoubleLeftArrow":"\u21D0","DoubleLeftRightArrow":"\u21D4","DoubleLeftTee":"\u2AE4","DoubleLongLeftArrow":"\u27F8","DoubleLongLeftRightArrow":"\u27FA","DoubleLongRightArrow":"\u27F9","DoubleRightArrow":"\u21D2","DoubleRightTee":"\u22A8","DoubleUpArrow":"\u21D1","DoubleUpDownArrow":"\u21D5","DoubleVerticalBar":"\u2225","DownArrowBar":"\u2913","downarrow":"\u2193","DownArrow":"\u2193","Downarrow":"\u21D3","DownArrowUpArrow":"\u21F5","DownBreve":"\u0311","downdownarrows":"\u21CA","downharpoonleft":"\u21C3","downharpoonright":"\u21C2","DownLeftRightVector":"\u2950","DownLeftTeeVector":"\u295E","DownLeftVectorBar":"\u2956","DownLeftVector":"\u21BD","DownRightTeeVector":"\u295F","DownRightVectorBar":"\u2957","DownRightVector":"\u21C1","DownTeeArrow":"\u21A7","DownTee":"\u22A4","drbkarow":"\u2910","drcorn":"\u231F","drcrop":"\u230C","Dscr":"\uD835\uDC9F","dscr":"\uD835\uDCB9","DScy":"\u0405","dscy":"\u0455","dsol":"\u29F6","Dstrok":"\u0110","dstrok":"\u0111","dtdot":"\u22F1","dtri":"\u25BF","dtrif":"\u25BE","duarr":"\u21F5","duhar":"\u296F","dwangle":"\u29A6","DZcy":"\u040F","dzcy":"\u045F","dzigrarr":"\u27FF","Eacute":"\u00C9","eacute":"\u00E9","easter":"\u2A6E","Ecaron":"\u011A","ecaron":"\u011B","Ecirc":"\u00CA","ecirc":"\u00EA","ecir":"\u2256","ecolon":"\u2255","Ecy":"\u042D","ecy":"\u044D","eDDot":"\u2A77","Edot":"\u0116","edot":"\u0117","eDot":"\u2251","ee":"\u2147","efDot":"\u2252","Efr":"\uD835\uDD08","efr":"\uD835\uDD22","eg":"\u2A9A","Egrave":"\u00C8","egrave":"\u00E8","egs":"\u2A96","egsdot":"\u2A98","el":"\u2A99","Element":"\u2208","elinters":"\u23E7","ell":"\u2113","els":"\u2A95","elsdot":"\u2A97","Emacr":"\u0112","emacr":"\u0113","empty":"\u2205","emptyset":"\u2205","EmptySmallSquare":"\u25FB","emptyv":"\u2205","EmptyVerySmallSquare":"\u25AB","emsp13":"\u2004","emsp14":"\u2005","emsp":"\u2003","ENG":"\u014A","eng":"\u014B","ensp":"\u2002","Eogon":"\u0118","eogon":"\u0119","Eopf":"\uD835\uDD3C","eopf":"\uD835\uDD56","epar":"\u22D5","eparsl":"\u29E3","eplus":"\u2A71","epsi":"\u03B5","Epsilon":"\u0395","epsilon":"\u03B5","epsiv":"\u03F5","eqcirc":"\u2256","eqcolon":"\u2255","eqsim":"\u2242","eqslantgtr":"\u2A96","eqslantless":"\u2A95","Equal":"\u2A75","equals":"=","EqualTilde":"\u2242","equest":"\u225F","Equilibrium":"\u21CC","equiv":"\u2261","equivDD":"\u2A78","eqvparsl":"\u29E5","erarr":"\u2971","erDot":"\u2253","escr":"\u212F","Escr":"\u2130","esdot":"\u2250","Esim":"\u2A73","esim":"\u2242","Eta":"\u0397","eta":"\u03B7","ETH":"\u00D0","eth":"\u00F0","Euml":"\u00CB","euml":"\u00EB","euro":"\u20AC","excl":"!","exist":"\u2203","Exists":"\u2203","expectation":"\u2130","exponentiale":"\u2147","ExponentialE":"\u2147","fallingdotseq":"\u2252","Fcy":"\u0424","fcy":"\u0444","female":"\u2640","ffilig":"\uFB03","fflig":"\uFB00","ffllig":"\uFB04","Ffr":"\uD835\uDD09","ffr":"\uD835\uDD23","filig":"\uFB01","FilledSmallSquare":"\u25FC","FilledVerySmallSquare":"\u25AA","fjlig":"fj","flat":"\u266D","fllig":"\uFB02","fltns":"\u25B1","fnof":"\u0192","Fopf":"\uD835\uDD3D","fopf":"\uD835\uDD57","forall":"\u2200","ForAll":"\u2200","fork":"\u22D4","forkv":"\u2AD9","Fouriertrf":"\u2131","fpartint":"\u2A0D","frac12":"\u00BD","frac13":"\u2153","frac14":"\u00BC","frac15":"\u2155","frac16":"\u2159","frac18":"\u215B","frac23":"\u2154","frac25":"\u2156","frac34":"\u00BE","frac35":"\u2157","frac38":"\u215C","frac45":"\u2158","frac56":"\u215A","frac58":"\u215D","frac78":"\u215E","frasl":"\u2044","frown":"\u2322","fscr":"\uD835\uDCBB","Fscr":"\u2131","gacute":"\u01F5","Gamma":"\u0393","gamma":"\u03B3","Gammad":"\u03DC","gammad":"\u03DD","gap":"\u2A86","Gbreve":"\u011E","gbreve":"\u011F","Gcedil":"\u0122","Gcirc":"\u011C","gcirc":"\u011D","Gcy":"\u0413","gcy":"\u0433","Gdot":"\u0120","gdot":"\u0121","ge":"\u2265","gE":"\u2267","gEl":"\u2A8C","gel":"\u22DB","geq":"\u2265","geqq":"\u2267","geqslant":"\u2A7E","gescc":"\u2AA9","ges":"\u2A7E","gesdot":"\u2A80","gesdoto":"\u2A82","gesdotol":"\u2A84","gesl":"\u22DB\uFE00","gesles":"\u2A94","Gfr":"\uD835\uDD0A","gfr":"\uD835\uDD24","gg":"\u226B","Gg":"\u22D9","ggg":"\u22D9","gimel":"\u2137","GJcy":"\u0403","gjcy":"\u0453","gla":"\u2AA5","gl":"\u2277","glE":"\u2A92","glj":"\u2AA4","gnap":"\u2A8A","gnapprox":"\u2A8A","gne":"\u2A88","gnE":"\u2269","gneq":"\u2A88","gneqq":"\u2269","gnsim":"\u22E7","Gopf":"\uD835\uDD3E","gopf":"\uD835\uDD58","grave":"`","GreaterEqual":"\u2265","GreaterEqualLess":"\u22DB","GreaterFullEqual":"\u2267","GreaterGreater":"\u2AA2","GreaterLess":"\u2277","GreaterSlantEqual":"\u2A7E","GreaterTilde":"\u2273","Gscr":"\uD835\uDCA2","gscr":"\u210A","gsim":"\u2273","gsime":"\u2A8E","gsiml":"\u2A90","gtcc":"\u2AA7","gtcir":"\u2A7A","gt":">","GT":">","Gt":"\u226B","gtdot":"\u22D7","gtlPar":"\u2995","gtquest":"\u2A7C","gtrapprox":"\u2A86","gtrarr":"\u2978","gtrdot":"\u22D7","gtreqless":"\u22DB","gtreqqless":"\u2A8C","gtrless":"\u2277","gtrsim":"\u2273","gvertneqq":"\u2269\uFE00","gvnE":"\u2269\uFE00","Hacek":"\u02C7","hairsp":"\u200A","half":"\u00BD","hamilt":"\u210B","HARDcy":"\u042A","hardcy":"\u044A","harrcir":"\u2948","harr":"\u2194","hArr":"\u21D4","harrw":"\u21AD","Hat":"^","hbar":"\u210F","Hcirc":"\u0124","hcirc":"\u0125","hearts":"\u2665","heartsuit":"\u2665","hellip":"\u2026","hercon":"\u22B9","hfr":"\uD835\uDD25","Hfr":"\u210C","HilbertSpace":"\u210B","hksearow":"\u2925","hkswarow":"\u2926","hoarr":"\u21FF","homtht":"\u223B","hookleftarrow":"\u21A9","hookrightarrow":"\u21AA","hopf":"\uD835\uDD59","Hopf":"\u210D","horbar":"\u2015","HorizontalLine":"\u2500","hscr":"\uD835\uDCBD","Hscr":"\u210B","hslash":"\u210F","Hstrok":"\u0126","hstrok":"\u0127","HumpDownHump":"\u224E","HumpEqual":"\u224F","hybull":"\u2043","hyphen":"\u2010","Iacute":"\u00CD","iacute":"\u00ED","ic":"\u2063","Icirc":"\u00CE","icirc":"\u00EE","Icy":"\u0418","icy":"\u0438","Idot":"\u0130","IEcy":"\u0415","iecy":"\u0435","iexcl":"\u00A1","iff":"\u21D4","ifr":"\uD835\uDD26","Ifr":"\u2111","Igrave":"\u00CC","igrave":"\u00EC","ii":"\u2148","iiiint":"\u2A0C","iiint":"\u222D","iinfin":"\u29DC","iiota":"\u2129","IJlig":"\u0132","ijlig":"\u0133","Imacr":"\u012A","imacr":"\u012B","image":"\u2111","ImaginaryI":"\u2148","imagline":"\u2110","imagpart":"\u2111","imath":"\u0131","Im":"\u2111","imof":"\u22B7","imped":"\u01B5","Implies":"\u21D2","incare":"\u2105","in":"\u2208","infin":"\u221E","infintie":"\u29DD","inodot":"\u0131","intcal":"\u22BA","int":"\u222B","Int":"\u222C","integers":"\u2124","Integral":"\u222B","intercal":"\u22BA","Intersection":"\u22C2","intlarhk":"\u2A17","intprod":"\u2A3C","InvisibleComma":"\u2063","InvisibleTimes":"\u2062","IOcy":"\u0401","iocy":"\u0451","Iogon":"\u012E","iogon":"\u012F","Iopf":"\uD835\uDD40","iopf":"\uD835\uDD5A","Iota":"\u0399","iota":"\u03B9","iprod":"\u2A3C","iquest":"\u00BF","iscr":"\uD835\uDCBE","Iscr":"\u2110","isin":"\u2208","isindot":"\u22F5","isinE":"\u22F9","isins":"\u22F4","isinsv":"\u22F3","isinv":"\u2208","it":"\u2062","Itilde":"\u0128","itilde":"\u0129","Iukcy":"\u0406","iukcy":"\u0456","Iuml":"\u00CF","iuml":"\u00EF","Jcirc":"\u0134","jcirc":"\u0135","Jcy":"\u0419","jcy":"\u0439","Jfr":"\uD835\uDD0D","jfr":"\uD835\uDD27","jmath":"\u0237","Jopf":"\uD835\uDD41","jopf":"\uD835\uDD5B","Jscr":"\uD835\uDCA5","jscr":"\uD835\uDCBF","Jsercy":"\u0408","jsercy":"\u0458","Jukcy":"\u0404","jukcy":"\u0454","Kappa":"\u039A","kappa":"\u03BA","kappav":"\u03F0","Kcedil":"\u0136","kcedil":"\u0137","Kcy":"\u041A","kcy":"\u043A","Kfr":"\uD835\uDD0E","kfr":"\uD835\uDD28","kgreen":"\u0138","KHcy":"\u0425","khcy":"\u0445","KJcy":"\u040C","kjcy":"\u045C","Kopf":"\uD835\uDD42","kopf":"\uD835\uDD5C","Kscr":"\uD835\uDCA6","kscr":"\uD835\uDCC0","lAarr":"\u21DA","Lacute":"\u0139","lacute":"\u013A","laemptyv":"\u29B4","lagran":"\u2112","Lambda":"\u039B","lambda":"\u03BB","lang":"\u27E8","Lang":"\u27EA","langd":"\u2991","langle":"\u27E8","lap":"\u2A85","Laplacetrf":"\u2112","laquo":"\u00AB","larrb":"\u21E4","larrbfs":"\u291F","larr":"\u2190","Larr":"\u219E","lArr":"\u21D0","larrfs":"\u291D","larrhk":"\u21A9","larrlp":"\u21AB","larrpl":"\u2939","larrsim":"\u2973","larrtl":"\u21A2","latail":"\u2919","lAtail":"\u291B","lat":"\u2AAB","late":"\u2AAD","lates":"\u2AAD\uFE00","lbarr":"\u290C","lBarr":"\u290E","lbbrk":"\u2772","lbrace":"{","lbrack":"[","lbrke":"\u298B","lbrksld":"\u298F","lbrkslu":"\u298D","Lcaron":"\u013D","lcaron":"\u013E","Lcedil":"\u013B","lcedil":"\u013C","lceil":"\u2308","lcub":"{","Lcy":"\u041B","lcy":"\u043B","ldca":"\u2936","ldquo":"\u201C","ldquor":"\u201E","ldrdhar":"\u2967","ldrushar":"\u294B","ldsh":"\u21B2","le":"\u2264","lE":"\u2266","LeftAngleBracket":"\u27E8","LeftArrowBar":"\u21E4","leftarrow":"\u2190","LeftArrow":"\u2190","Leftarrow":"\u21D0","LeftArrowRightArrow":"\u21C6","leftarrowtail":"\u21A2","LeftCeiling":"\u2308","LeftDoubleBracket":"\u27E6","LeftDownTeeVector":"\u2961","LeftDownVectorBar":"\u2959","LeftDownVector":"\u21C3","LeftFloor":"\u230A","leftharpoondown":"\u21BD","leftharpoonup":"\u21BC","leftleftarrows":"\u21C7","leftrightarrow":"\u2194","LeftRightArrow":"\u2194","Leftrightarrow":"\u21D4","leftrightarrows":"\u21C6","leftrightharpoons":"\u21CB","leftrightsquigarrow":"\u21AD","LeftRightVector":"\u294E","LeftTeeArrow":"\u21A4","LeftTee":"\u22A3","LeftTeeVector":"\u295A","leftthreetimes":"\u22CB","LeftTriangleBar":"\u29CF","LeftTriangle":"\u22B2","LeftTriangleEqual":"\u22B4","LeftUpDownVector":"\u2951","LeftUpTeeVector":"\u2960","LeftUpVectorBar":"\u2958","LeftUpVector":"\u21BF","LeftVectorBar":"\u2952","LeftVector":"\u21BC","lEg":"\u2A8B","leg":"\u22DA","leq":"\u2264","leqq":"\u2266","leqslant":"\u2A7D","lescc":"\u2AA8","les":"\u2A7D","lesdot":"\u2A7F","lesdoto":"\u2A81","lesdotor":"\u2A83","lesg":"\u22DA\uFE00","lesges":"\u2A93","lessapprox":"\u2A85","lessdot":"\u22D6","lesseqgtr":"\u22DA","lesseqqgtr":"\u2A8B","LessEqualGreater":"\u22DA","LessFullEqual":"\u2266","LessGreater":"\u2276","lessgtr":"\u2276","LessLess":"\u2AA1","lesssim":"\u2272","LessSlantEqual":"\u2A7D","LessTilde":"\u2272","lfisht":"\u297C","lfloor":"\u230A","Lfr":"\uD835\uDD0F","lfr":"\uD835\uDD29","lg":"\u2276","lgE":"\u2A91","lHar":"\u2962","lhard":"\u21BD","lharu":"\u21BC","lharul":"\u296A","lhblk":"\u2584","LJcy":"\u0409","ljcy":"\u0459","llarr":"\u21C7","ll":"\u226A","Ll":"\u22D8","llcorner":"\u231E","Lleftarrow":"\u21DA","llhard":"\u296B","lltri":"\u25FA","Lmidot":"\u013F","lmidot":"\u0140","lmoustache":"\u23B0","lmoust":"\u23B0","lnap":"\u2A89","lnapprox":"\u2A89","lne":"\u2A87","lnE":"\u2268","lneq":"\u2A87","lneqq":"\u2268","lnsim":"\u22E6","loang":"\u27EC","loarr":"\u21FD","lobrk":"\u27E6","longleftarrow":"\u27F5","LongLeftArrow":"\u27F5","Longleftarrow":"\u27F8","longleftrightarrow":"\u27F7","LongLeftRightArrow":"\u27F7","Longleftrightarrow":"\u27FA","longmapsto":"\u27FC","longrightarrow":"\u27F6","LongRightArrow":"\u27F6","Longrightarrow":"\u27F9","looparrowleft":"\u21AB","looparrowright":"\u21AC","lopar":"\u2985","Lopf":"\uD835\uDD43","lopf":"\uD835\uDD5D","loplus":"\u2A2D","lotimes":"\u2A34","lowast":"\u2217","lowbar":"_","LowerLeftArrow":"\u2199","LowerRightArrow":"\u2198","loz":"\u25CA","lozenge":"\u25CA","lozf":"\u29EB","lpar":"(","lparlt":"\u2993","lrarr":"\u21C6","lrcorner":"\u231F","lrhar":"\u21CB","lrhard":"\u296D","lrm":"\u200E","lrtri":"\u22BF","lsaquo":"\u2039","lscr":"\uD835\uDCC1","Lscr":"\u2112","lsh":"\u21B0","Lsh":"\u21B0","lsim":"\u2272","lsime":"\u2A8D","lsimg":"\u2A8F","lsqb":"[","lsquo":"\u2018","lsquor":"\u201A","Lstrok":"\u0141","lstrok":"\u0142","ltcc":"\u2AA6","ltcir":"\u2A79","lt":"<","LT":"<","Lt":"\u226A","ltdot":"\u22D6","lthree":"\u22CB","ltimes":"\u22C9","ltlarr":"\u2976","ltquest":"\u2A7B","ltri":"\u25C3","ltrie":"\u22B4","ltrif":"\u25C2","ltrPar":"\u2996","lurdshar":"\u294A","luruhar":"\u2966","lvertneqq":"\u2268\uFE00","lvnE":"\u2268\uFE00","macr":"\u00AF","male":"\u2642","malt":"\u2720","maltese":"\u2720","Map":"\u2905","map":"\u21A6","mapsto":"\u21A6","mapstodown":"\u21A7","mapstoleft":"\u21A4","mapstoup":"\u21A5","marker":"\u25AE","mcomma":"\u2A29","Mcy":"\u041C","mcy":"\u043C","mdash":"\u2014","mDDot":"\u223A","measuredangle":"\u2221","MediumSpace":"\u205F","Mellintrf":"\u2133","Mfr":"\uD835\uDD10","mfr":"\uD835\uDD2A","mho":"\u2127","micro":"\u00B5","midast":"*","midcir":"\u2AF0","mid":"\u2223","middot":"\u00B7","minusb":"\u229F","minus":"\u2212","minusd":"\u2238","minusdu":"\u2A2A","MinusPlus":"\u2213","mlcp":"\u2ADB","mldr":"\u2026","mnplus":"\u2213","models":"\u22A7","Mopf":"\uD835\uDD44","mopf":"\uD835\uDD5E","mp":"\u2213","mscr":"\uD835\uDCC2","Mscr":"\u2133","mstpos":"\u223E","Mu":"\u039C","mu":"\u03BC","multimap":"\u22B8","mumap":"\u22B8","nabla":"\u2207","Nacute":"\u0143","nacute":"\u0144","nang":"\u2220\u20D2","nap":"\u2249","napE":"\u2A70\u0338","napid":"\u224B\u0338","napos":"\u0149","napprox":"\u2249","natural":"\u266E","naturals":"\u2115","natur":"\u266E","nbsp":"\u00A0","nbump":"\u224E\u0338","nbumpe":"\u224F\u0338","ncap":"\u2A43","Ncaron":"\u0147","ncaron":"\u0148","Ncedil":"\u0145","ncedil":"\u0146","ncong":"\u2247","ncongdot":"\u2A6D\u0338","ncup":"\u2A42","Ncy":"\u041D","ncy":"\u043D","ndash":"\u2013","nearhk":"\u2924","nearr":"\u2197","neArr":"\u21D7","nearrow":"\u2197","ne":"\u2260","nedot":"\u2250\u0338","NegativeMediumSpace":"\u200B","NegativeThickSpace":"\u200B","NegativeThinSpace":"\u200B","NegativeVeryThinSpace":"\u200B","nequiv":"\u2262","nesear":"\u2928","nesim":"\u2242\u0338","NestedGreaterGreater":"\u226B","NestedLessLess":"\u226A","NewLine":"\n","nexist":"\u2204","nexists":"\u2204","Nfr":"\uD835\uDD11","nfr":"\uD835\uDD2B","ngE":"\u2267\u0338","nge":"\u2271","ngeq":"\u2271","ngeqq":"\u2267\u0338","ngeqslant":"\u2A7E\u0338","nges":"\u2A7E\u0338","nGg":"\u22D9\u0338","ngsim":"\u2275","nGt":"\u226B\u20D2","ngt":"\u226F","ngtr":"\u226F","nGtv":"\u226B\u0338","nharr":"\u21AE","nhArr":"\u21CE","nhpar":"\u2AF2","ni":"\u220B","nis":"\u22FC","nisd":"\u22FA","niv":"\u220B","NJcy":"\u040A","njcy":"\u045A","nlarr":"\u219A","nlArr":"\u21CD","nldr":"\u2025","nlE":"\u2266\u0338","nle":"\u2270","nleftarrow":"\u219A","nLeftarrow":"\u21CD","nleftrightarrow":"\u21AE","nLeftrightarrow":"\u21CE","nleq":"\u2270","nleqq":"\u2266\u0338","nleqslant":"\u2A7D\u0338","nles":"\u2A7D\u0338","nless":"\u226E","nLl":"\u22D8\u0338","nlsim":"\u2274","nLt":"\u226A\u20D2","nlt":"\u226E","nltri":"\u22EA","nltrie":"\u22EC","nLtv":"\u226A\u0338","nmid":"\u2224","NoBreak":"\u2060","NonBreakingSpace":"\u00A0","nopf":"\uD835\uDD5F","Nopf":"\u2115","Not":"\u2AEC","not":"\u00AC","NotCongruent":"\u2262","NotCupCap":"\u226D","NotDoubleVerticalBar":"\u2226","NotElement":"\u2209","NotEqual":"\u2260","NotEqualTilde":"\u2242\u0338","NotExists":"\u2204","NotGreater":"\u226F","NotGreaterEqual":"\u2271","NotGreaterFullEqual":"\u2267\u0338","NotGreaterGreater":"\u226B\u0338","NotGreaterLess":"\u2279","NotGreaterSlantEqual":"\u2A7E\u0338","NotGreaterTilde":"\u2275","NotHumpDownHump":"\u224E\u0338","NotHumpEqual":"\u224F\u0338","notin":"\u2209","notindot":"\u22F5\u0338","notinE":"\u22F9\u0338","notinva":"\u2209","notinvb":"\u22F7","notinvc":"\u22F6","NotLeftTriangleBar":"\u29CF\u0338","NotLeftTriangle":"\u22EA","NotLeftTriangleEqual":"\u22EC","NotLess":"\u226E","NotLessEqual":"\u2270","NotLessGreater":"\u2278","NotLessLess":"\u226A\u0338","NotLessSlantEqual":"\u2A7D\u0338","NotLessTilde":"\u2274","NotNestedGreaterGreater":"\u2AA2\u0338","NotNestedLessLess":"\u2AA1\u0338","notni":"\u220C","notniva":"\u220C","notnivb":"\u22FE","notnivc":"\u22FD","NotPrecedes":"\u2280","NotPrecedesEqual":"\u2AAF\u0338","NotPrecedesSlantEqual":"\u22E0","NotReverseElement":"\u220C","NotRightTriangleBar":"\u29D0\u0338","NotRightTriangle":"\u22EB","NotRightTriangleEqual":"\u22ED","NotSquareSubset":"\u228F\u0338","NotSquareSubsetEqual":"\u22E2","NotSquareSuperset":"\u2290\u0338","NotSquareSupersetEqual":"\u22E3","NotSubset":"\u2282\u20D2","NotSubsetEqual":"\u2288","NotSucceeds":"\u2281","NotSucceedsEqual":"\u2AB0\u0338","NotSucceedsSlantEqual":"\u22E1","NotSucceedsTilde":"\u227F\u0338","NotSuperset":"\u2283\u20D2","NotSupersetEqual":"\u2289","NotTilde":"\u2241","NotTildeEqual":"\u2244","NotTildeFullEqual":"\u2247","NotTildeTilde":"\u2249","NotVerticalBar":"\u2224","nparallel":"\u2226","npar":"\u2226","nparsl":"\u2AFD\u20E5","npart":"\u2202\u0338","npolint":"\u2A14","npr":"\u2280","nprcue":"\u22E0","nprec":"\u2280","npreceq":"\u2AAF\u0338","npre":"\u2AAF\u0338","nrarrc":"\u2933\u0338","nrarr":"\u219B","nrArr":"\u21CF","nrarrw":"\u219D\u0338","nrightarrow":"\u219B","nRightarrow":"\u21CF","nrtri":"\u22EB","nrtrie":"\u22ED","nsc":"\u2281","nsccue":"\u22E1","nsce":"\u2AB0\u0338","Nscr":"\uD835\uDCA9","nscr":"\uD835\uDCC3","nshortmid":"\u2224","nshortparallel":"\u2226","nsim":"\u2241","nsime":"\u2244","nsimeq":"\u2244","nsmid":"\u2224","nspar":"\u2226","nsqsube":"\u22E2","nsqsupe":"\u22E3","nsub":"\u2284","nsubE":"\u2AC5\u0338","nsube":"\u2288","nsubset":"\u2282\u20D2","nsubseteq":"\u2288","nsubseteqq":"\u2AC5\u0338","nsucc":"\u2281","nsucceq":"\u2AB0\u0338","nsup":"\u2285","nsupE":"\u2AC6\u0338","nsupe":"\u2289","nsupset":"\u2283\u20D2","nsupseteq":"\u2289","nsupseteqq":"\u2AC6\u0338","ntgl":"\u2279","Ntilde":"\u00D1","ntilde":"\u00F1","ntlg":"\u2278","ntriangleleft":"\u22EA","ntrianglelefteq":"\u22EC","ntriangleright":"\u22EB","ntrianglerighteq":"\u22ED","Nu":"\u039D","nu":"\u03BD","num":"#","numero":"\u2116","numsp":"\u2007","nvap":"\u224D\u20D2","nvdash":"\u22AC","nvDash":"\u22AD","nVdash":"\u22AE","nVDash":"\u22AF","nvge":"\u2265\u20D2","nvgt":">\u20D2","nvHarr":"\u2904","nvinfin":"\u29DE","nvlArr":"\u2902","nvle":"\u2264\u20D2","nvlt":"<\u20D2","nvltrie":"\u22B4\u20D2","nvrArr":"\u2903","nvrtrie":"\u22B5\u20D2","nvsim":"\u223C\u20D2","nwarhk":"\u2923","nwarr":"\u2196","nwArr":"\u21D6","nwarrow":"\u2196","nwnear":"\u2927","Oacute":"\u00D3","oacute":"\u00F3","oast":"\u229B","Ocirc":"\u00D4","ocirc":"\u00F4","ocir":"\u229A","Ocy":"\u041E","ocy":"\u043E","odash":"\u229D","Odblac":"\u0150","odblac":"\u0151","odiv":"\u2A38","odot":"\u2299","odsold":"\u29BC","OElig":"\u0152","oelig":"\u0153","ofcir":"\u29BF","Ofr":"\uD835\uDD12","ofr":"\uD835\uDD2C","ogon":"\u02DB","Ograve":"\u00D2","ograve":"\u00F2","ogt":"\u29C1","ohbar":"\u29B5","ohm":"\u03A9","oint":"\u222E","olarr":"\u21BA","olcir":"\u29BE","olcross":"\u29BB","oline":"\u203E","olt":"\u29C0","Omacr":"\u014C","omacr":"\u014D","Omega":"\u03A9","omega":"\u03C9","Omicron":"\u039F","omicron":"\u03BF","omid":"\u29B6","ominus":"\u2296","Oopf":"\uD835\uDD46","oopf":"\uD835\uDD60","opar":"\u29B7","OpenCurlyDoubleQuote":"\u201C","OpenCurlyQuote":"\u2018","operp":"\u29B9","oplus":"\u2295","orarr":"\u21BB","Or":"\u2A54","or":"\u2228","ord":"\u2A5D","order":"\u2134","orderof":"\u2134","ordf":"\u00AA","ordm":"\u00BA","origof":"\u22B6","oror":"\u2A56","orslope":"\u2A57","orv":"\u2A5B","oS":"\u24C8","Oscr":"\uD835\uDCAA","oscr":"\u2134","Oslash":"\u00D8","oslash":"\u00F8","osol":"\u2298","Otilde":"\u00D5","otilde":"\u00F5","otimesas":"\u2A36","Otimes":"\u2A37","otimes":"\u2297","Ouml":"\u00D6","ouml":"\u00F6","ovbar":"\u233D","OverBar":"\u203E","OverBrace":"\u23DE","OverBracket":"\u23B4","OverParenthesis":"\u23DC","para":"\u00B6","parallel":"\u2225","par":"\u2225","parsim":"\u2AF3","parsl":"\u2AFD","part":"\u2202","PartialD":"\u2202","Pcy":"\u041F","pcy":"\u043F","percnt":"%","period":".","permil":"\u2030","perp":"\u22A5","pertenk":"\u2031","Pfr":"\uD835\uDD13","pfr":"\uD835\uDD2D","Phi":"\u03A6","phi":"\u03C6","phiv":"\u03D5","phmmat":"\u2133","phone":"\u260E","Pi":"\u03A0","pi":"\u03C0","pitchfork":"\u22D4","piv":"\u03D6","planck":"\u210F","planckh":"\u210E","plankv":"\u210F","plusacir":"\u2A23","plusb":"\u229E","pluscir":"\u2A22","plus":"+","plusdo":"\u2214","plusdu":"\u2A25","pluse":"\u2A72","PlusMinus":"\u00B1","plusmn":"\u00B1","plussim":"\u2A26","plustwo":"\u2A27","pm":"\u00B1","Poincareplane":"\u210C","pointint":"\u2A15","popf":"\uD835\uDD61","Popf":"\u2119","pound":"\u00A3","prap":"\u2AB7","Pr":"\u2ABB","pr":"\u227A","prcue":"\u227C","precapprox":"\u2AB7","prec":"\u227A","preccurlyeq":"\u227C","Precedes":"\u227A","PrecedesEqual":"\u2AAF","PrecedesSlantEqual":"\u227C","PrecedesTilde":"\u227E","preceq":"\u2AAF","precnapprox":"\u2AB9","precneqq":"\u2AB5","precnsim":"\u22E8","pre":"\u2AAF","prE":"\u2AB3","precsim":"\u227E","prime":"\u2032","Prime":"\u2033","primes":"\u2119","prnap":"\u2AB9","prnE":"\u2AB5","prnsim":"\u22E8","prod":"\u220F","Product":"\u220F","profalar":"\u232E","profline":"\u2312","profsurf":"\u2313","prop":"\u221D","Proportional":"\u221D","Proportion":"\u2237","propto":"\u221D","prsim":"\u227E","prurel":"\u22B0","Pscr":"\uD835\uDCAB","pscr":"\uD835\uDCC5","Psi":"\u03A8","psi":"\u03C8","puncsp":"\u2008","Qfr":"\uD835\uDD14","qfr":"\uD835\uDD2E","qint":"\u2A0C","qopf":"\uD835\uDD62","Qopf":"\u211A","qprime":"\u2057","Qscr":"\uD835\uDCAC","qscr":"\uD835\uDCC6","quaternions":"\u210D","quatint":"\u2A16","quest":"?","questeq":"\u225F","quot":"\"","QUOT":"\"","rAarr":"\u21DB","race":"\u223D\u0331","Racute":"\u0154","racute":"\u0155","radic":"\u221A","raemptyv":"\u29B3","rang":"\u27E9","Rang":"\u27EB","rangd":"\u2992","range":"\u29A5","rangle":"\u27E9","raquo":"\u00BB","rarrap":"\u2975","rarrb":"\u21E5","rarrbfs":"\u2920","rarrc":"\u2933","rarr":"\u2192","Rarr":"\u21A0","rArr":"\u21D2","rarrfs":"\u291E","rarrhk":"\u21AA","rarrlp":"\u21AC","rarrpl":"\u2945","rarrsim":"\u2974","Rarrtl":"\u2916","rarrtl":"\u21A3","rarrw":"\u219D","ratail":"\u291A","rAtail":"\u291C","ratio":"\u2236","rationals":"\u211A","rbarr":"\u290D","rBarr":"\u290F","RBarr":"\u2910","rbbrk":"\u2773","rbrace":"}","rbrack":"]","rbrke":"\u298C","rbrksld":"\u298E","rbrkslu":"\u2990","Rcaron":"\u0158","rcaron":"\u0159","Rcedil":"\u0156","rcedil":"\u0157","rceil":"\u2309","rcub":"}","Rcy":"\u0420","rcy":"\u0440","rdca":"\u2937","rdldhar":"\u2969","rdquo":"\u201D","rdquor":"\u201D","rdsh":"\u21B3","real":"\u211C","realine":"\u211B","realpart":"\u211C","reals":"\u211D","Re":"\u211C","rect":"\u25AD","reg":"\u00AE","REG":"\u00AE","ReverseElement":"\u220B","ReverseEquilibrium":"\u21CB","ReverseUpEquilibrium":"\u296F","rfisht":"\u297D","rfloor":"\u230B","rfr":"\uD835\uDD2F","Rfr":"\u211C","rHar":"\u2964","rhard":"\u21C1","rharu":"\u21C0","rharul":"\u296C","Rho":"\u03A1","rho":"\u03C1","rhov":"\u03F1","RightAngleBracket":"\u27E9","RightArrowBar":"\u21E5","rightarrow":"\u2192","RightArrow":"\u2192","Rightarrow":"\u21D2","RightArrowLeftArrow":"\u21C4","rightarrowtail":"\u21A3","RightCeiling":"\u2309","RightDoubleBracket":"\u27E7","RightDownTeeVector":"\u295D","RightDownVectorBar":"\u2955","RightDownVector":"\u21C2","RightFloor":"\u230B","rightharpoondown":"\u21C1","rightharpoonup":"\u21C0","rightleftarrows":"\u21C4","rightleftharpoons":"\u21CC","rightrightarrows":"\u21C9","rightsquigarrow":"\u219D","RightTeeArrow":"\u21A6","RightTee":"\u22A2","RightTeeVector":"\u295B","rightthreetimes":"\u22CC","RightTriangleBar":"\u29D0","RightTriangle":"\u22B3","RightTriangleEqual":"\u22B5","RightUpDownVector":"\u294F","RightUpTeeVector":"\u295C","RightUpVectorBar":"\u2954","RightUpVector":"\u21BE","RightVectorBar":"\u2953","RightVector":"\u21C0","ring":"\u02DA","risingdotseq":"\u2253","rlarr":"\u21C4","rlhar":"\u21CC","rlm":"\u200F","rmoustache":"\u23B1","rmoust":"\u23B1","rnmid":"\u2AEE","roang":"\u27ED","roarr":"\u21FE","robrk":"\u27E7","ropar":"\u2986","ropf":"\uD835\uDD63","Ropf":"\u211D","roplus":"\u2A2E","rotimes":"\u2A35","RoundImplies":"\u2970","rpar":")","rpargt":"\u2994","rppolint":"\u2A12","rrarr":"\u21C9","Rrightarrow":"\u21DB","rsaquo":"\u203A","rscr":"\uD835\uDCC7","Rscr":"\u211B","rsh":"\u21B1","Rsh":"\u21B1","rsqb":"]","rsquo":"\u2019","rsquor":"\u2019","rthree":"\u22CC","rtimes":"\u22CA","rtri":"\u25B9","rtrie":"\u22B5","rtrif":"\u25B8","rtriltri":"\u29CE","RuleDelayed":"\u29F4","ruluhar":"\u2968","rx":"\u211E","Sacute":"\u015A","sacute":"\u015B","sbquo":"\u201A","scap":"\u2AB8","Scaron":"\u0160","scaron":"\u0161","Sc":"\u2ABC","sc":"\u227B","sccue":"\u227D","sce":"\u2AB0","scE":"\u2AB4","Scedil":"\u015E","scedil":"\u015F","Scirc":"\u015C","scirc":"\u015D","scnap":"\u2ABA","scnE":"\u2AB6","scnsim":"\u22E9","scpolint":"\u2A13","scsim":"\u227F","Scy":"\u0421","scy":"\u0441","sdotb":"\u22A1","sdot":"\u22C5","sdote":"\u2A66","searhk":"\u2925","searr":"\u2198","seArr":"\u21D8","searrow":"\u2198","sect":"\u00A7","semi":";","seswar":"\u2929","setminus":"\u2216","setmn":"\u2216","sext":"\u2736","Sfr":"\uD835\uDD16","sfr":"\uD835\uDD30","sfrown":"\u2322","sharp":"\u266F","SHCHcy":"\u0429","shchcy":"\u0449","SHcy":"\u0428","shcy":"\u0448","ShortDownArrow":"\u2193","ShortLeftArrow":"\u2190","shortmid":"\u2223","shortparallel":"\u2225","ShortRightArrow":"\u2192","ShortUpArrow":"\u2191","shy":"\u00AD","Sigma":"\u03A3","sigma":"\u03C3","sigmaf":"\u03C2","sigmav":"\u03C2","sim":"\u223C","simdot":"\u2A6A","sime":"\u2243","simeq":"\u2243","simg":"\u2A9E","simgE":"\u2AA0","siml":"\u2A9D","simlE":"\u2A9F","simne":"\u2246","simplus":"\u2A24","simrarr":"\u2972","slarr":"\u2190","SmallCircle":"\u2218","smallsetminus":"\u2216","smashp":"\u2A33","smeparsl":"\u29E4","smid":"\u2223","smile":"\u2323","smt":"\u2AAA","smte":"\u2AAC","smtes":"\u2AAC\uFE00","SOFTcy":"\u042C","softcy":"\u044C","solbar":"\u233F","solb":"\u29C4","sol":"/","Sopf":"\uD835\uDD4A","sopf":"\uD835\uDD64","spades":"\u2660","spadesuit":"\u2660","spar":"\u2225","sqcap":"\u2293","sqcaps":"\u2293\uFE00","sqcup":"\u2294","sqcups":"\u2294\uFE00","Sqrt":"\u221A","sqsub":"\u228F","sqsube":"\u2291","sqsubset":"\u228F","sqsubseteq":"\u2291","sqsup":"\u2290","sqsupe":"\u2292","sqsupset":"\u2290","sqsupseteq":"\u2292","square":"\u25A1","Square":"\u25A1","SquareIntersection":"\u2293","SquareSubset":"\u228F","SquareSubsetEqual":"\u2291","SquareSuperset":"\u2290","SquareSupersetEqual":"\u2292","SquareUnion":"\u2294","squarf":"\u25AA","squ":"\u25A1","squf":"\u25AA","srarr":"\u2192","Sscr":"\uD835\uDCAE","sscr":"\uD835\uDCC8","ssetmn":"\u2216","ssmile":"\u2323","sstarf":"\u22C6","Star":"\u22C6","star":"\u2606","starf":"\u2605","straightepsilon":"\u03F5","straightphi":"\u03D5","strns":"\u00AF","sub":"\u2282","Sub":"\u22D0","subdot":"\u2ABD","subE":"\u2AC5","sube":"\u2286","subedot":"\u2AC3","submult":"\u2AC1","subnE":"\u2ACB","subne":"\u228A","subplus":"\u2ABF","subrarr":"\u2979","subset":"\u2282","Subset":"\u22D0","subseteq":"\u2286","subseteqq":"\u2AC5","SubsetEqual":"\u2286","subsetneq":"\u228A","subsetneqq":"\u2ACB","subsim":"\u2AC7","subsub":"\u2AD5","subsup":"\u2AD3","succapprox":"\u2AB8","succ":"\u227B","succcurlyeq":"\u227D","Succeeds":"\u227B","SucceedsEqual":"\u2AB0","SucceedsSlantEqual":"\u227D","SucceedsTilde":"\u227F","succeq":"\u2AB0","succnapprox":"\u2ABA","succneqq":"\u2AB6","succnsim":"\u22E9","succsim":"\u227F","SuchThat":"\u220B","sum":"\u2211","Sum":"\u2211","sung":"\u266A","sup1":"\u00B9","sup2":"\u00B2","sup3":"\u00B3","sup":"\u2283","Sup":"\u22D1","supdot":"\u2ABE","supdsub":"\u2AD8","supE":"\u2AC6","supe":"\u2287","supedot":"\u2AC4","Superset":"\u2283","SupersetEqual":"\u2287","suphsol":"\u27C9","suphsub":"\u2AD7","suplarr":"\u297B","supmult":"\u2AC2","supnE":"\u2ACC","supne":"\u228B","supplus":"\u2AC0","supset":"\u2283","Supset":"\u22D1","supseteq":"\u2287","supseteqq":"\u2AC6","supsetneq":"\u228B","supsetneqq":"\u2ACC","supsim":"\u2AC8","supsub":"\u2AD4","supsup":"\u2AD6","swarhk":"\u2926","swarr":"\u2199","swArr":"\u21D9","swarrow":"\u2199","swnwar":"\u292A","szlig":"\u00DF","Tab":"\t","target":"\u2316","Tau":"\u03A4","tau":"\u03C4","tbrk":"\u23B4","Tcaron":"\u0164","tcaron":"\u0165","Tcedil":"\u0162","tcedil":"\u0163","Tcy":"\u0422","tcy":"\u0442","tdot":"\u20DB","telrec":"\u2315","Tfr":"\uD835\uDD17","tfr":"\uD835\uDD31","there4":"\u2234","therefore":"\u2234","Therefore":"\u2234","Theta":"\u0398","theta":"\u03B8","thetasym":"\u03D1","thetav":"\u03D1","thickapprox":"\u2248","thicksim":"\u223C","ThickSpace":"\u205F\u200A","ThinSpace":"\u2009","thinsp":"\u2009","thkap":"\u2248","thksim":"\u223C","THORN":"\u00DE","thorn":"\u00FE","tilde":"\u02DC","Tilde":"\u223C","TildeEqual":"\u2243","TildeFullEqual":"\u2245","TildeTilde":"\u2248","timesbar":"\u2A31","timesb":"\u22A0","times":"\u00D7","timesd":"\u2A30","tint":"\u222D","toea":"\u2928","topbot":"\u2336","topcir":"\u2AF1","top":"\u22A4","Topf":"\uD835\uDD4B","topf":"\uD835\uDD65","topfork":"\u2ADA","tosa":"\u2929","tprime":"\u2034","trade":"\u2122","TRADE":"\u2122","triangle":"\u25B5","triangledown":"\u25BF","triangleleft":"\u25C3","trianglelefteq":"\u22B4","triangleq":"\u225C","triangleright":"\u25B9","trianglerighteq":"\u22B5","tridot":"\u25EC","trie":"\u225C","triminus":"\u2A3A","TripleDot":"\u20DB","triplus":"\u2A39","trisb":"\u29CD","tritime":"\u2A3B","trpezium":"\u23E2","Tscr":"\uD835\uDCAF","tscr":"\uD835\uDCC9","TScy":"\u0426","tscy":"\u0446","TSHcy":"\u040B","tshcy":"\u045B","Tstrok":"\u0166","tstrok":"\u0167","twixt":"\u226C","twoheadleftarrow":"\u219E","twoheadrightarrow":"\u21A0","Uacute":"\u00DA","uacute":"\u00FA","uarr":"\u2191","Uarr":"\u219F","uArr":"\u21D1","Uarrocir":"\u2949","Ubrcy":"\u040E","ubrcy":"\u045E","Ubreve":"\u016C","ubreve":"\u016D","Ucirc":"\u00DB","ucirc":"\u00FB","Ucy":"\u0423","ucy":"\u0443","udarr":"\u21C5","Udblac":"\u0170","udblac":"\u0171","udhar":"\u296E","ufisht":"\u297E","Ufr":"\uD835\uDD18","ufr":"\uD835\uDD32","Ugrave":"\u00D9","ugrave":"\u00F9","uHar":"\u2963","uharl":"\u21BF","uharr":"\u21BE","uhblk":"\u2580","ulcorn":"\u231C","ulcorner":"\u231C","ulcrop":"\u230F","ultri":"\u25F8","Umacr":"\u016A","umacr":"\u016B","uml":"\u00A8","UnderBar":"_","UnderBrace":"\u23DF","UnderBracket":"\u23B5","UnderParenthesis":"\u23DD","Union":"\u22C3","UnionPlus":"\u228E","Uogon":"\u0172","uogon":"\u0173","Uopf":"\uD835\uDD4C","uopf":"\uD835\uDD66","UpArrowBar":"\u2912","uparrow":"\u2191","UpArrow":"\u2191","Uparrow":"\u21D1","UpArrowDownArrow":"\u21C5","updownarrow":"\u2195","UpDownArrow":"\u2195","Updownarrow":"\u21D5","UpEquilibrium":"\u296E","upharpoonleft":"\u21BF","upharpoonright":"\u21BE","uplus":"\u228E","UpperLeftArrow":"\u2196","UpperRightArrow":"\u2197","upsi":"\u03C5","Upsi":"\u03D2","upsih":"\u03D2","Upsilon":"\u03A5","upsilon":"\u03C5","UpTeeArrow":"\u21A5","UpTee":"\u22A5","upuparrows":"\u21C8","urcorn":"\u231D","urcorner":"\u231D","urcrop":"\u230E","Uring":"\u016E","uring":"\u016F","urtri":"\u25F9","Uscr":"\uD835\uDCB0","uscr":"\uD835\uDCCA","utdot":"\u22F0","Utilde":"\u0168","utilde":"\u0169","utri":"\u25B5","utrif":"\u25B4","uuarr":"\u21C8","Uuml":"\u00DC","uuml":"\u00FC","uwangle":"\u29A7","vangrt":"\u299C","varepsilon":"\u03F5","varkappa":"\u03F0","varnothing":"\u2205","varphi":"\u03D5","varpi":"\u03D6","varpropto":"\u221D","varr":"\u2195","vArr":"\u21D5","varrho":"\u03F1","varsigma":"\u03C2","varsubsetneq":"\u228A\uFE00","varsubsetneqq":"\u2ACB\uFE00","varsupsetneq":"\u228B\uFE00","varsupsetneqq":"\u2ACC\uFE00","vartheta":"\u03D1","vartriangleleft":"\u22B2","vartriangleright":"\u22B3","vBar":"\u2AE8","Vbar":"\u2AEB","vBarv":"\u2AE9","Vcy":"\u0412","vcy":"\u0432","vdash":"\u22A2","vDash":"\u22A8","Vdash":"\u22A9","VDash":"\u22AB","Vdashl":"\u2AE6","veebar":"\u22BB","vee":"\u2228","Vee":"\u22C1","veeeq":"\u225A","vellip":"\u22EE","verbar":"|","Verbar":"\u2016","vert":"|","Vert":"\u2016","VerticalBar":"\u2223","VerticalLine":"|","VerticalSeparator":"\u2758","VerticalTilde":"\u2240","VeryThinSpace":"\u200A","Vfr":"\uD835\uDD19","vfr":"\uD835\uDD33","vltri":"\u22B2","vnsub":"\u2282\u20D2","vnsup":"\u2283\u20D2","Vopf":"\uD835\uDD4D","vopf":"\uD835\uDD67","vprop":"\u221D","vrtri":"\u22B3","Vscr":"\uD835\uDCB1","vscr":"\uD835\uDCCB","vsubnE":"\u2ACB\uFE00","vsubne":"\u228A\uFE00","vsupnE":"\u2ACC\uFE00","vsupne":"\u228B\uFE00","Vvdash":"\u22AA","vzigzag":"\u299A","Wcirc":"\u0174","wcirc":"\u0175","wedbar":"\u2A5F","wedge":"\u2227","Wedge":"\u22C0","wedgeq":"\u2259","weierp":"\u2118","Wfr":"\uD835\uDD1A","wfr":"\uD835\uDD34","Wopf":"\uD835\uDD4E","wopf":"\uD835\uDD68","wp":"\u2118","wr":"\u2240","wreath":"\u2240","Wscr":"\uD835\uDCB2","wscr":"\uD835\uDCCC","xcap":"\u22C2","xcirc":"\u25EF","xcup":"\u22C3","xdtri":"\u25BD","Xfr":"\uD835\uDD1B","xfr":"\uD835\uDD35","xharr":"\u27F7","xhArr":"\u27FA","Xi":"\u039E","xi":"\u03BE","xlarr":"\u27F5","xlArr":"\u27F8","xmap":"\u27FC","xnis":"\u22FB","xodot":"\u2A00","Xopf":"\uD835\uDD4F","xopf":"\uD835\uDD69","xoplus":"\u2A01","xotime":"\u2A02","xrarr":"\u27F6","xrArr":"\u27F9","Xscr":"\uD835\uDCB3","xscr":"\uD835\uDCCD","xsqcup":"\u2A06","xuplus":"\u2A04","xutri":"\u25B3","xvee":"\u22C1","xwedge":"\u22C0","Yacute":"\u00DD","yacute":"\u00FD","YAcy":"\u042F","yacy":"\u044F","Ycirc":"\u0176","ycirc":"\u0177","Ycy":"\u042B","ycy":"\u044B","yen":"\u00A5","Yfr":"\uD835\uDD1C","yfr":"\uD835\uDD36","YIcy":"\u0407","yicy":"\u0457","Yopf":"\uD835\uDD50","yopf":"\uD835\uDD6A","Yscr":"\uD835\uDCB4","yscr":"\uD835\uDCCE","YUcy":"\u042E","yucy":"\u044E","yuml":"\u00FF","Yuml":"\u0178","Zacute":"\u0179","zacute":"\u017A","Zcaron":"\u017D","zcaron":"\u017E","Zcy":"\u0417","zcy":"\u0437","Zdot":"\u017B","zdot":"\u017C","zeetrf":"\u2128","ZeroWidthSpace":"\u200B","Zeta":"\u0396","zeta":"\u03B6","zfr":"\uD835\uDD37","Zfr":"\u2128","ZHcy":"\u0416","zhcy":"\u0436","zigrarr":"\u21DD","zopf":"\uD835\uDD6B","Zopf":"\u2124","Zscr":"\uD835\uDCB5","zscr":"\uD835\uDCCF","zwj":"\u200D","zwnj":"\u200C"}4407 -1 },{}],28:[function(require,module,exports){4408 -1 'use strict';4409 -14410 -1 var OneVersionConstraint = require('individual/one-version');4411 -14412 -1 var MY_VERSION = '7';4413 -1 OneVersionConstraint('ev-store', MY_VERSION);4414 -14415 -1 var hashKey = '__EV_STORE_KEY@' + MY_VERSION;4416 -14417 -1 module.exports = EvStore;-1 4481 if (!packets.length) { -1 4482 return callback('0:'); -1 4483 } 4418 44844419 -1 function EvStore(elem) {4420 -1 var hash = elem[hashKey];-1 4485 function setLengthHeader(message) { -1 4486 return message.length + ':' + message; -1 4487 } 4421 44884422 -1 if (!hash) {4423 -1 hash = elem[hashKey] = {};4424 -1 }-1 4489 function encodeOne(packet, doneCallback) { -1 4490 exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) { -1 4491 doneCallback(null, setLengthHeader(message)); -1 4492 }); -1 4493 } 4425 44944426 -1 return hash;4427 -1 }-1 4495 map(packets, encodeOne, function(err, results) { -1 4496 return callback(results.join('')); -1 4497 }); -1 4498 }; 4428 44994429 -1 },{"individual/one-version":34}],29:[function(require,module,exports){4430 -1 (function (global){4431 -1 var topLevel = typeof global !== 'undefined' ? global :4432 -1 typeof window !== 'undefined' ? window : {}4433 -1 var minDoc = require('min-document');-1 4500 /** -1 4501 * Async array map using after -1 4502 */ 4434 45034435 -1 if (typeof document !== 'undefined') {4436 -1 module.exports = document;4437 -1 } else {4438 -1 var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];-1 4504 function map(ary, each, done) { -1 4505 var result = new Array(ary.length); -1 4506 var next = after(ary.length, done); 4439 45074440 -1 if (!doccy) {4441 -1 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;4442 -1 }-1 4508 var eachWithIndex = function(i, el, cb) { -1 4509 each(el, function(error, msg) { -1 4510 result[i] = msg; -1 4511 cb(error, result); -1 4512 }); -1 4513 }; 4443 45144444 -1 module.exports = doccy;-1 4515 for (var i = 0; i < ary.length; i++) { -1 4516 eachWithIndex(i, ary[i], next); -1 4517 } 4445 4518 } 4446 45194447 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})4448 -1 },{"min-document":1}],30:[function(require,module,exports){4449 -1 (function (global){4450 -14451 4520 /*4452 -1 * Module requirements.-1 4521 * Decodes data when a payload is maybe expected. Possible binary contents are -1 4522 * decoded from their base64 representation -1 4523 * -1 4524 * @param {String} data, callback method -1 4525 * @api public 4453 4526 */ 4454 45274455 -1 var isArray = require('isarray');-1 4528 exports.decodePayload = function (data, binaryType, callback) { -1 4529 if (typeof data != 'string') { -1 4530 return exports.decodePayloadAsBinary(data, binaryType, callback); -1 4531 } 4456 45324457 -1 /**4458 -1 * Module exports.4459 -1 */-1 4533 if (typeof binaryType === 'function') { -1 4534 callback = binaryType; -1 4535 binaryType = null; -1 4536 } 4460 45374461 -1 module.exports = hasBinary;-1 4538 var packet; -1 4539 if (data == '') { -1 4540 // parser error - ignoring payload -1 4541 return callback(err, 0, 1); -1 4542 } 4462 45434463 -1 /**4464 -1 * Checks for binary data.4465 -1 *4466 -1 * Right now only Buffer and ArrayBuffer are supported..4467 -1 *4468 -1 * @param {Object} anything4469 -1 * @api public4470 -1 */-1 4544 var length = '' -1 4545 , n, msg; 4471 45464472 -1 function hasBinary(data) {-1 4547 for (var i = 0, l = data.length; i < l; i++) { -1 4548 var chr = data.charAt(i); 4473 45494474 -1 function _hasBinary(obj) {4475 -1 if (!obj) return false;-1 4550 if (':' != chr) { -1 4551 length += chr; -1 4552 } else { -1 4553 if ('' == length || (length != (n = Number(length)))) { -1 4554 // parser error - ignoring payload -1 4555 return callback(err, 0, 1); -1 4556 } 4476 45574477 -1 if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) ||4478 -1 (global.ArrayBuffer && obj instanceof ArrayBuffer) ||4479 -1 (global.Blob && obj instanceof Blob) ||4480 -1 (global.File && obj instanceof File)4481 -1 ) {4482 -1 return true;4483 -1 }-1 4558 msg = data.substr(i + 1, n); 4484 45594485 -1 if (isArray(obj)) {4486 -1 for (var i = 0; i < obj.length; i++) {4487 -1 if (_hasBinary(obj[i])) {4488 -1 return true;4489 -1 }4490 -1 }4491 -1 } else if (obj && 'object' == typeof obj) {4492 -1 // see: https://github.com/Automattic/has-binary/pull/44493 -1 if (obj.toJSON && 'function' == typeof obj.toJSON) {4494 -1 obj = obj.toJSON();-1 4560 if (length != msg.length) { -1 4561 // parser error - ignoring payload -1 4562 return callback(err, 0, 1); 4495 4563 } 4496 45644497 -1 for (var key in obj) {4498 -1 if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) {4499 -1 return true;-1 4565 if (msg.length) { -1 4566 packet = exports.decodePacket(msg, binaryType, true); -1 4567 -1 4568 if (err.type == packet.type && err.data == packet.data) { -1 4569 // parser error in individual packet - ignoring payload -1 4570 return callback(err, 0, 1); 4500 4571 } -1 4572 -1 4573 var ret = callback(packet, i + n, l); -1 4574 if (false === ret) return; 4501 4575 }4502 -1 }4503 45764504 -1 return false;-1 4577 // advance cursor -1 4578 i += n; -1 4579 length = ''; -1 4580 } 4505 4581 } 4506 45824507 -1 return _hasBinary(data);4508 -1 }-1 4583 if (length != '') { -1 4584 // parser error - ignoring payload -1 4585 return callback(err, 0, 1); -1 4586 } 4509 45874510 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})4511 -1 },{"isarray":36}],31:[function(require,module,exports){-1 4588 }; 4512 4589 4513 4590 /**4514 -1 * Module exports.-1 4591 * Encodes multiple messages (payload) as binary. 4515 4592 *4516 -1 * Logic borrowed from Modernizr:-1 4593 * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number -1 4594 * 255><data> 4517 4595 *4518 -1 * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js-1 4596 * Example: -1 4597 * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers -1 4598 * -1 4599 * @param {Array} packets -1 4600 * @return {ArrayBuffer} encoded payload -1 4601 * @api private 4519 4602 */ 4520 46034521 -1 try {4522 -1 module.exports = typeof XMLHttpRequest !== 'undefined' &&4523 -1 'withCredentials' in new XMLHttpRequest();4524 -1 } catch (err) {4525 -1 // if XMLHttp support is disabled in IE then it will throw4526 -1 // when trying to create4527 -1 module.exports = false;4528 -1 }4529 -14530 -1 },{}],32:[function(require,module,exports){4531 -14532 -1 var indexOf = [].indexOf;4533 -14534 -1 module.exports = function(arr, obj){4535 -1 if (indexOf) return arr.indexOf(obj);4536 -1 for (var i = 0; i < arr.length; ++i) {4537 -1 if (arr[i] === obj) return i;-1 4604 exports.encodePayloadAsArrayBuffer = function(packets, callback) { -1 4605 if (!packets.length) { -1 4606 return callback(new ArrayBuffer(0)); 4538 4607 }4539 -1 return -1;4540 -1 };4541 -1 },{}],33:[function(require,module,exports){4542 -1 (function (global){4543 -1 'use strict';4544 -14545 -1 /*global window, global*/4546 -14547 -1 var root = typeof window !== 'undefined' ?4548 -1 window : typeof global !== 'undefined' ?4549 -1 global : {};4550 -14551 -1 module.exports = Individual;4552 -14553 -1 function Individual(key, value) {4554 -1 if (key in root) {4555 -1 return root[key];4556 -1 }4557 -14558 -1 root[key] = value;4559 46084560 -1 return value;4561 -1 }-1 4609 function encodeOne(packet, doneCallback) { -1 4610 exports.encodePacket(packet, true, true, function(data) { -1 4611 return doneCallback(null, data); -1 4612 }); -1 4613 } 4562 46144563 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})4564 -1 },{}],34:[function(require,module,exports){4565 -1 'use strict';4566 -14567 -1 var Individual = require('./index.js');4568 -14569 -1 module.exports = OneVersion;4570 -14571 -1 function OneVersion(moduleName, version, defaultValue) {4572 -1 var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;4573 -1 var enforceKey = key + '_ENFORCE_SINGLETON';-1 4615 map(packets, encodeOne, function(err, encodedPackets) { -1 4616 var totalLength = encodedPackets.reduce(function(acc, p) { -1 4617 var len; -1 4618 if (typeof p === 'string'){ -1 4619 len = p.length; -1 4620 } else { -1 4621 len = p.byteLength; -1 4622 } -1 4623 return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2 -1 4624 }, 0); 4574 46254575 -1 var versionValue = Individual(enforceKey, version);-1 4626 var resultArray = new Uint8Array(totalLength); 4576 46274577 -1 if (versionValue !== version) {4578 -1 throw new Error('Can only have one copy of ' +4579 -1 moduleName + '.\n' +4580 -1 'You already have version ' + versionValue +4581 -1 ' installed.\n' +4582 -1 'This means you cannot install version ' + version);4583 -1 }-1 4628 var bufferIndex = 0; -1 4629 encodedPackets.forEach(function(p) { -1 4630 var isString = typeof p === 'string'; -1 4631 var ab = p; -1 4632 if (isString) { -1 4633 var view = new Uint8Array(p.length); -1 4634 for (var i = 0; i < p.length; i++) { -1 4635 view[i] = p.charCodeAt(i); -1 4636 } -1 4637 ab = view.buffer; -1 4638 } 4584 46394585 -1 return Individual(key, defaultValue);4586 -1 }-1 4640 if (isString) { // not true binary -1 4641 resultArray[bufferIndex++] = 0; -1 4642 } else { // true binary -1 4643 resultArray[bufferIndex++] = 1; -1 4644 } 4587 46454588 -1 },{"./index.js":33}],35:[function(require,module,exports){4589 -1 "use strict";-1 4646 var lenStr = ab.byteLength.toString(); -1 4647 for (var i = 0; i < lenStr.length; i++) { -1 4648 resultArray[bufferIndex++] = parseInt(lenStr[i]); -1 4649 } -1 4650 resultArray[bufferIndex++] = 255; 4590 46514591 -1 module.exports = function isObject(x) {4592 -1 return typeof x === "object" && x !== null;4593 -1 };-1 4652 var view = new Uint8Array(ab); -1 4653 for (var i = 0; i < view.length; i++) { -1 4654 resultArray[bufferIndex++] = view[i]; -1 4655 } -1 4656 }); 4594 46574595 -1 },{}],36:[function(require,module,exports){4596 -1 module.exports = Array.isArray || function (arr) {4597 -1 return Object.prototype.toString.call(arr) == '[object Array]';-1 4658 return callback(resultArray.buffer); -1 4659 }); 4598 4660 }; 4599 46614600 -1 },{}],37:[function(require,module,exports){4601 -1 'use strict';4602 -1-1 4662 /** -1 4663 * Encode as Blob -1 4664 */ 4603 46654604 -1 ////////////////////////////////////////////////////////////////////////////////4605 -1 // Helpers-1 4666 exports.encodePayloadAsBlob = function(packets, callback) { -1 4667 function encodeOne(packet, doneCallback) { -1 4668 exports.encodePacket(packet, true, true, function(encoded) { -1 4669 var binaryIdentifier = new Uint8Array(1); -1 4670 binaryIdentifier[0] = 1; -1 4671 if (typeof encoded === 'string') { -1 4672 var view = new Uint8Array(encoded.length); -1 4673 for (var i = 0; i < encoded.length; i++) { -1 4674 view[i] = encoded.charCodeAt(i); -1 4675 } -1 4676 encoded = view.buffer; -1 4677 binaryIdentifier[0] = 0; -1 4678 } 4606 46794607 -1 // Merge objects4608 -1 //4609 -1 function assign(obj /*from1, from2, from3, ...*/) {4610 -1 var sources = Array.prototype.slice.call(arguments, 1);-1 4680 var len = (encoded instanceof ArrayBuffer) -1 4681 ? encoded.byteLength -1 4682 : encoded.size; 4611 46834612 -1 sources.forEach(function (source) {4613 -1 if (!source) { return; }-1 4684 var lenStr = len.toString(); -1 4685 var lengthAry = new Uint8Array(lenStr.length + 1); -1 4686 for (var i = 0; i < lenStr.length; i++) { -1 4687 lengthAry[i] = parseInt(lenStr[i]); -1 4688 } -1 4689 lengthAry[lenStr.length] = 255; 4614 46904615 -1 Object.keys(source).forEach(function (key) {4616 -1 obj[key] = source[key];-1 4691 if (Blob) { -1 4692 var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]); -1 4693 doneCallback(null, blob); -1 4694 } 4617 4695 });4618 -1 });4619 -14620 -1 return obj;4621 -1 }-1 4696 } 4622 46974623 -1 function _class(obj) { return Object.prototype.toString.call(obj); }4624 -1 function isString(obj) { return _class(obj) === '[object String]'; }4625 -1 function isObject(obj) { return _class(obj) === '[object Object]'; }4626 -1 function isRegExp(obj) { return _class(obj) === '[object RegExp]'; }4627 -1 function isFunction(obj) { return _class(obj) === '[object Function]'; }-1 4698 map(packets, encodeOne, function(err, results) { -1 4699 return callback(new Blob(results)); -1 4700 }); -1 4701 }; 4628 4702 -1 4703 /* -1 4704 * Decodes data when a payload is maybe expected. Strings are decoded by -1 4705 * interpreting each byte as a key code for entries marked to start with 0. See -1 4706 * description of encodePayloadAsBinary -1 4707 * -1 4708 * @param {ArrayBuffer} data, callback method -1 4709 * @api public -1 4710 */ 4629 47114630 -1 function escapeRE(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); }-1 4712 exports.decodePayloadAsBinary = function (data, binaryType, callback) { -1 4713 if (typeof binaryType === 'function') { -1 4714 callback = binaryType; -1 4715 binaryType = null; -1 4716 } 4631 47174632 -1 ////////////////////////////////////////////////////////////////////////////////-1 4718 var bufferTail = data; -1 4719 var buffers = []; 4633 4720 -1 4721 var numberTooLong = false; -1 4722 while (bufferTail.byteLength > 0) { -1 4723 var tailArray = new Uint8Array(bufferTail); -1 4724 var isString = tailArray[0] === 0; -1 4725 var msgLength = ''; 4634 47264635 -1 var defaultOptions = {4636 -1 fuzzyLink: true,4637 -1 fuzzyEmail: true,4638 -1 fuzzyIP: false4639 -1 };-1 4727 for (var i = 1; ; i++) { -1 4728 if (tailArray[i] == 255) break; 4640 4729 -1 4730 if (msgLength.length > 310) { -1 4731 numberTooLong = true; -1 4732 break; -1 4733 } 4641 47344642 -1 function isOptionsObj(obj) {4643 -1 return Object.keys(obj || {}).reduce(function (acc, k) {4644 -1 return acc || defaultOptions.hasOwnProperty(k);4645 -1 }, false);4646 -1 }-1 4735 msgLength += tailArray[i]; -1 4736 } 4647 4737 -1 4738 if(numberTooLong) return callback(err, 0, 1); 4648 47394649 -1 var defaultSchemas = {4650 -1 'http:': {4651 -1 validate: function (text, pos, self) {4652 -1 var tail = text.slice(pos);-1 4740 bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length); -1 4741 msgLength = parseInt(msgLength); 4653 47424654 -1 if (!self.re.http) {4655 -1 // compile lazily, because "host"-containing variables can change on tlds update.4656 -1 self.re.http = new RegExp(4657 -1 '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i'4658 -1 );4659 -1 }4660 -1 if (self.re.http.test(tail)) {4661 -1 return tail.match(self.re.http)[0].length;-1 4743 var msg = sliceBuffer(bufferTail, 0, msgLength); -1 4744 if (isString) { -1 4745 try { -1 4746 msg = String.fromCharCode.apply(null, new Uint8Array(msg)); -1 4747 } catch (e) { -1 4748 // iPhone Safari doesn't let you apply to typed arrays -1 4749 var typed = new Uint8Array(msg); -1 4750 msg = ''; -1 4751 for (var i = 0; i < typed.length; i++) { -1 4752 msg += String.fromCharCode(typed[i]); -1 4753 } 4662 4754 }4663 -1 return 0;4664 4755 }4665 -1 },4666 -1 'https:': 'http:',4667 -1 'ftp:': 'http:',4668 -1 '//': {4669 -1 validate: function (text, pos, self) {4670 -1 var tail = text.slice(pos);4671 47564672 -1 if (!self.re.no_http) {4673 -1 // compile lazily, because "host"-containing variables can change on tlds update.4674 -1 self.re.no_http = new RegExp(4675 -1 '^' +4676 -1 self.re.src_auth +4677 -1 // Don't allow single-level domains, because of false positives like '//test'4678 -1 // with code comments4679 -1 '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' +4680 -1 self.re.src_port +4681 -1 self.re.src_host_terminator +4682 -1 self.re.src_path,-1 4757 buffers.push(msg); -1 4758 bufferTail = sliceBuffer(bufferTail, msgLength); -1 4759 } 4683 47604684 -1 'i'4685 -1 );4686 -1 }-1 4761 var total = buffers.length; -1 4762 buffers.forEach(function(buffer, i) { -1 4763 callback(exports.decodePacket(buffer, binaryType, true), i, total); -1 4764 }); -1 4765 }; 4687 47664688 -1 if (self.re.no_http.test(tail)) {4689 -1 // should not be `://` & `///`, that protects from errors in protocol name4690 -1 if (pos >= 3 && text[pos - 3] === ':') { return 0; }4691 -1 if (pos >= 3 && text[pos - 3] === '/') { return 0; }4692 -1 return tail.match(self.re.no_http)[0].length;4693 -1 }4694 -1 return 0;4695 -1 }4696 -1 },4697 -1 'mailto:': {4698 -1 validate: function (text, pos, self) {4699 -1 var tail = text.slice(pos);-1 4767 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 4768 },{"./keys":27,"after":4,"arraybuffer.slice":5,"base64-arraybuffer":7,"blob":8,"has-binary":29,"wtf-8":119}],27:[function(require,module,exports){ 4700 47694701 -1 if (!self.re.mailto) {4702 -1 self.re.mailto = new RegExp(4703 -1 '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i'4704 -1 );4705 -1 }4706 -1 if (self.re.mailto.test(tail)) {4707 -1 return tail.match(self.re.mailto)[0].length;4708 -1 }4709 -1 return 0;-1 4770 /** -1 4771 * Gets the keys for an object. -1 4772 * -1 4773 * @return {Array} keys -1 4774 * @api private -1 4775 */ -1 4776 -1 4777 module.exports = Object.keys || function keys (obj){ -1 4778 var arr = []; -1 4779 var has = Object.prototype.hasOwnProperty; -1 4780 -1 4781 for (var i in obj) { -1 4782 if (has.call(obj, i)) { -1 4783 arr.push(i); 4710 4784 } 4711 4785 } -1 4786 return arr; 4712 4787 }; 4713 47884714 -1 /*eslint-disable max-len*/-1 4789 },{}],28:[function(require,module,exports){ -1 4790 module.exports={"Aacute":"\u00C1","aacute":"\u00E1","Abreve":"\u0102","abreve":"\u0103","ac":"\u223E","acd":"\u223F","acE":"\u223E\u0333","Acirc":"\u00C2","acirc":"\u00E2","acute":"\u00B4","Acy":"\u0410","acy":"\u0430","AElig":"\u00C6","aelig":"\u00E6","af":"\u2061","Afr":"\uD835\uDD04","afr":"\uD835\uDD1E","Agrave":"\u00C0","agrave":"\u00E0","alefsym":"\u2135","aleph":"\u2135","Alpha":"\u0391","alpha":"\u03B1","Amacr":"\u0100","amacr":"\u0101","amalg":"\u2A3F","amp":"&","AMP":"&","andand":"\u2A55","And":"\u2A53","and":"\u2227","andd":"\u2A5C","andslope":"\u2A58","andv":"\u2A5A","ang":"\u2220","ange":"\u29A4","angle":"\u2220","angmsdaa":"\u29A8","angmsdab":"\u29A9","angmsdac":"\u29AA","angmsdad":"\u29AB","angmsdae":"\u29AC","angmsdaf":"\u29AD","angmsdag":"\u29AE","angmsdah":"\u29AF","angmsd":"\u2221","angrt":"\u221F","angrtvb":"\u22BE","angrtvbd":"\u299D","angsph":"\u2222","angst":"\u00C5","angzarr":"\u237C","Aogon":"\u0104","aogon":"\u0105","Aopf":"\uD835\uDD38","aopf":"\uD835\uDD52","apacir":"\u2A6F","ap":"\u2248","apE":"\u2A70","ape":"\u224A","apid":"\u224B","apos":"'","ApplyFunction":"\u2061","approx":"\u2248","approxeq":"\u224A","Aring":"\u00C5","aring":"\u00E5","Ascr":"\uD835\uDC9C","ascr":"\uD835\uDCB6","Assign":"\u2254","ast":"*","asymp":"\u2248","asympeq":"\u224D","Atilde":"\u00C3","atilde":"\u00E3","Auml":"\u00C4","auml":"\u00E4","awconint":"\u2233","awint":"\u2A11","backcong":"\u224C","backepsilon":"\u03F6","backprime":"\u2035","backsim":"\u223D","backsimeq":"\u22CD","Backslash":"\u2216","Barv":"\u2AE7","barvee":"\u22BD","barwed":"\u2305","Barwed":"\u2306","barwedge":"\u2305","bbrk":"\u23B5","bbrktbrk":"\u23B6","bcong":"\u224C","Bcy":"\u0411","bcy":"\u0431","bdquo":"\u201E","becaus":"\u2235","because":"\u2235","Because":"\u2235","bemptyv":"\u29B0","bepsi":"\u03F6","bernou":"\u212C","Bernoullis":"\u212C","Beta":"\u0392","beta":"\u03B2","beth":"\u2136","between":"\u226C","Bfr":"\uD835\uDD05","bfr":"\uD835\uDD1F","bigcap":"\u22C2","bigcirc":"\u25EF","bigcup":"\u22C3","bigodot":"\u2A00","bigoplus":"\u2A01","bigotimes":"\u2A02","bigsqcup":"\u2A06","bigstar":"\u2605","bigtriangledown":"\u25BD","bigtriangleup":"\u25B3","biguplus":"\u2A04","bigvee":"\u22C1","bigwedge":"\u22C0","bkarow":"\u290D","blacklozenge":"\u29EB","blacksquare":"\u25AA","blacktriangle":"\u25B4","blacktriangledown":"\u25BE","blacktriangleleft":"\u25C2","blacktriangleright":"\u25B8","blank":"\u2423","blk12":"\u2592","blk14":"\u2591","blk34":"\u2593","block":"\u2588","bne":"=\u20E5","bnequiv":"\u2261\u20E5","bNot":"\u2AED","bnot":"\u2310","Bopf":"\uD835\uDD39","bopf":"\uD835\uDD53","bot":"\u22A5","bottom":"\u22A5","bowtie":"\u22C8","boxbox":"\u29C9","boxdl":"\u2510","boxdL":"\u2555","boxDl":"\u2556","boxDL":"\u2557","boxdr":"\u250C","boxdR":"\u2552","boxDr":"\u2553","boxDR":"\u2554","boxh":"\u2500","boxH":"\u2550","boxhd":"\u252C","boxHd":"\u2564","boxhD":"\u2565","boxHD":"\u2566","boxhu":"\u2534","boxHu":"\u2567","boxhU":"\u2568","boxHU":"\u2569","boxminus":"\u229F","boxplus":"\u229E","boxtimes":"\u22A0","boxul":"\u2518","boxuL":"\u255B","boxUl":"\u255C","boxUL":"\u255D","boxur":"\u2514","boxuR":"\u2558","boxUr":"\u2559","boxUR":"\u255A","boxv":"\u2502","boxV":"\u2551","boxvh":"\u253C","boxvH":"\u256A","boxVh":"\u256B","boxVH":"\u256C","boxvl":"\u2524","boxvL":"\u2561","boxVl":"\u2562","boxVL":"\u2563","boxvr":"\u251C","boxvR":"\u255E","boxVr":"\u255F","boxVR":"\u2560","bprime":"\u2035","breve":"\u02D8","Breve":"\u02D8","brvbar":"\u00A6","bscr":"\uD835\uDCB7","Bscr":"\u212C","bsemi":"\u204F","bsim":"\u223D","bsime":"\u22CD","bsolb":"\u29C5","bsol":"\\","bsolhsub":"\u27C8","bull":"\u2022","bullet":"\u2022","bump":"\u224E","bumpE":"\u2AAE","bumpe":"\u224F","Bumpeq":"\u224E","bumpeq":"\u224F","Cacute":"\u0106","cacute":"\u0107","capand":"\u2A44","capbrcup":"\u2A49","capcap":"\u2A4B","cap":"\u2229","Cap":"\u22D2","capcup":"\u2A47","capdot":"\u2A40","CapitalDifferentialD":"\u2145","caps":"\u2229\uFE00","caret":"\u2041","caron":"\u02C7","Cayleys":"\u212D","ccaps":"\u2A4D","Ccaron":"\u010C","ccaron":"\u010D","Ccedil":"\u00C7","ccedil":"\u00E7","Ccirc":"\u0108","ccirc":"\u0109","Cconint":"\u2230","ccups":"\u2A4C","ccupssm":"\u2A50","Cdot":"\u010A","cdot":"\u010B","cedil":"\u00B8","Cedilla":"\u00B8","cemptyv":"\u29B2","cent":"\u00A2","centerdot":"\u00B7","CenterDot":"\u00B7","cfr":"\uD835\uDD20","Cfr":"\u212D","CHcy":"\u0427","chcy":"\u0447","check":"\u2713","checkmark":"\u2713","Chi":"\u03A7","chi":"\u03C7","circ":"\u02C6","circeq":"\u2257","circlearrowleft":"\u21BA","circlearrowright":"\u21BB","circledast":"\u229B","circledcirc":"\u229A","circleddash":"\u229D","CircleDot":"\u2299","circledR":"\u00AE","circledS":"\u24C8","CircleMinus":"\u2296","CirclePlus":"\u2295","CircleTimes":"\u2297","cir":"\u25CB","cirE":"\u29C3","cire":"\u2257","cirfnint":"\u2A10","cirmid":"\u2AEF","cirscir":"\u29C2","ClockwiseContourIntegral":"\u2232","CloseCurlyDoubleQuote":"\u201D","CloseCurlyQuote":"\u2019","clubs":"\u2663","clubsuit":"\u2663","colon":":","Colon":"\u2237","Colone":"\u2A74","colone":"\u2254","coloneq":"\u2254","comma":",","commat":"@","comp":"\u2201","compfn":"\u2218","complement":"\u2201","complexes":"\u2102","cong":"\u2245","congdot":"\u2A6D","Congruent":"\u2261","conint":"\u222E","Conint":"\u222F","ContourIntegral":"\u222E","copf":"\uD835\uDD54","Copf":"\u2102","coprod":"\u2210","Coproduct":"\u2210","copy":"\u00A9","COPY":"\u00A9","copysr":"\u2117","CounterClockwiseContourIntegral":"\u2233","crarr":"\u21B5","cross":"\u2717","Cross":"\u2A2F","Cscr":"\uD835\uDC9E","cscr":"\uD835\uDCB8","csub":"\u2ACF","csube":"\u2AD1","csup":"\u2AD0","csupe":"\u2AD2","ctdot":"\u22EF","cudarrl":"\u2938","cudarrr":"\u2935","cuepr":"\u22DE","cuesc":"\u22DF","cularr":"\u21B6","cularrp":"\u293D","cupbrcap":"\u2A48","cupcap":"\u2A46","CupCap":"\u224D","cup":"\u222A","Cup":"\u22D3","cupcup":"\u2A4A","cupdot":"\u228D","cupor":"\u2A45","cups":"\u222A\uFE00","curarr":"\u21B7","curarrm":"\u293C","curlyeqprec":"\u22DE","curlyeqsucc":"\u22DF","curlyvee":"\u22CE","curlywedge":"\u22CF","curren":"\u00A4","curvearrowleft":"\u21B6","curvearrowright":"\u21B7","cuvee":"\u22CE","cuwed":"\u22CF","cwconint":"\u2232","cwint":"\u2231","cylcty":"\u232D","dagger":"\u2020","Dagger":"\u2021","daleth":"\u2138","darr":"\u2193","Darr":"\u21A1","dArr":"\u21D3","dash":"\u2010","Dashv":"\u2AE4","dashv":"\u22A3","dbkarow":"\u290F","dblac":"\u02DD","Dcaron":"\u010E","dcaron":"\u010F","Dcy":"\u0414","dcy":"\u0434","ddagger":"\u2021","ddarr":"\u21CA","DD":"\u2145","dd":"\u2146","DDotrahd":"\u2911","ddotseq":"\u2A77","deg":"\u00B0","Del":"\u2207","Delta":"\u0394","delta":"\u03B4","demptyv":"\u29B1","dfisht":"\u297F","Dfr":"\uD835\uDD07","dfr":"\uD835\uDD21","dHar":"\u2965","dharl":"\u21C3","dharr":"\u21C2","DiacriticalAcute":"\u00B4","DiacriticalDot":"\u02D9","DiacriticalDoubleAcute":"\u02DD","DiacriticalGrave":"`","DiacriticalTilde":"\u02DC","diam":"\u22C4","diamond":"\u22C4","Diamond":"\u22C4","diamondsuit":"\u2666","diams":"\u2666","die":"\u00A8","DifferentialD":"\u2146","digamma":"\u03DD","disin":"\u22F2","div":"\u00F7","divide":"\u00F7","divideontimes":"\u22C7","divonx":"\u22C7","DJcy":"\u0402","djcy":"\u0452","dlcorn":"\u231E","dlcrop":"\u230D","dollar":"$","Dopf":"\uD835\uDD3B","dopf":"\uD835\uDD55","Dot":"\u00A8","dot":"\u02D9","DotDot":"\u20DC","doteq":"\u2250","doteqdot":"\u2251","DotEqual":"\u2250","dotminus":"\u2238","dotplus":"\u2214","dotsquare":"\u22A1","doublebarwedge":"\u2306","DoubleContourIntegral":"\u222F","DoubleDot":"\u00A8","DoubleDownArrow":"\u21D3","DoubleLeftArrow":"\u21D0","DoubleLeftRightArrow":"\u21D4","DoubleLeftTee":"\u2AE4","DoubleLongLeftArrow":"\u27F8","DoubleLongLeftRightArrow":"\u27FA","DoubleLongRightArrow":"\u27F9","DoubleRightArrow":"\u21D2","DoubleRightTee":"\u22A8","DoubleUpArrow":"\u21D1","DoubleUpDownArrow":"\u21D5","DoubleVerticalBar":"\u2225","DownArrowBar":"\u2913","downarrow":"\u2193","DownArrow":"\u2193","Downarrow":"\u21D3","DownArrowUpArrow":"\u21F5","DownBreve":"\u0311","downdownarrows":"\u21CA","downharpoonleft":"\u21C3","downharpoonright":"\u21C2","DownLeftRightVector":"\u2950","DownLeftTeeVector":"\u295E","DownLeftVectorBar":"\u2956","DownLeftVector":"\u21BD","DownRightTeeVector":"\u295F","DownRightVectorBar":"\u2957","DownRightVector":"\u21C1","DownTeeArrow":"\u21A7","DownTee":"\u22A4","drbkarow":"\u2910","drcorn":"\u231F","drcrop":"\u230C","Dscr":"\uD835\uDC9F","dscr":"\uD835\uDCB9","DScy":"\u0405","dscy":"\u0455","dsol":"\u29F6","Dstrok":"\u0110","dstrok":"\u0111","dtdot":"\u22F1","dtri":"\u25BF","dtrif":"\u25BE","duarr":"\u21F5","duhar":"\u296F","dwangle":"\u29A6","DZcy":"\u040F","dzcy":"\u045F","dzigrarr":"\u27FF","Eacute":"\u00C9","eacute":"\u00E9","easter":"\u2A6E","Ecaron":"\u011A","ecaron":"\u011B","Ecirc":"\u00CA","ecirc":"\u00EA","ecir":"\u2256","ecolon":"\u2255","Ecy":"\u042D","ecy":"\u044D","eDDot":"\u2A77","Edot":"\u0116","edot":"\u0117","eDot":"\u2251","ee":"\u2147","efDot":"\u2252","Efr":"\uD835\uDD08","efr":"\uD835\uDD22","eg":"\u2A9A","Egrave":"\u00C8","egrave":"\u00E8","egs":"\u2A96","egsdot":"\u2A98","el":"\u2A99","Element":"\u2208","elinters":"\u23E7","ell":"\u2113","els":"\u2A95","elsdot":"\u2A97","Emacr":"\u0112","emacr":"\u0113","empty":"\u2205","emptyset":"\u2205","EmptySmallSquare":"\u25FB","emptyv":"\u2205","EmptyVerySmallSquare":"\u25AB","emsp13":"\u2004","emsp14":"\u2005","emsp":"\u2003","ENG":"\u014A","eng":"\u014B","ensp":"\u2002","Eogon":"\u0118","eogon":"\u0119","Eopf":"\uD835\uDD3C","eopf":"\uD835\uDD56","epar":"\u22D5","eparsl":"\u29E3","eplus":"\u2A71","epsi":"\u03B5","Epsilon":"\u0395","epsilon":"\u03B5","epsiv":"\u03F5","eqcirc":"\u2256","eqcolon":"\u2255","eqsim":"\u2242","eqslantgtr":"\u2A96","eqslantless":"\u2A95","Equal":"\u2A75","equals":"=","EqualTilde":"\u2242","equest":"\u225F","Equilibrium":"\u21CC","equiv":"\u2261","equivDD":"\u2A78","eqvparsl":"\u29E5","erarr":"\u2971","erDot":"\u2253","escr":"\u212F","Escr":"\u2130","esdot":"\u2250","Esim":"\u2A73","esim":"\u2242","Eta":"\u0397","eta":"\u03B7","ETH":"\u00D0","eth":"\u00F0","Euml":"\u00CB","euml":"\u00EB","euro":"\u20AC","excl":"!","exist":"\u2203","Exists":"\u2203","expectation":"\u2130","exponentiale":"\u2147","ExponentialE":"\u2147","fallingdotseq":"\u2252","Fcy":"\u0424","fcy":"\u0444","female":"\u2640","ffilig":"\uFB03","fflig":"\uFB00","ffllig":"\uFB04","Ffr":"\uD835\uDD09","ffr":"\uD835\uDD23","filig":"\uFB01","FilledSmallSquare":"\u25FC","FilledVerySmallSquare":"\u25AA","fjlig":"fj","flat":"\u266D","fllig":"\uFB02","fltns":"\u25B1","fnof":"\u0192","Fopf":"\uD835\uDD3D","fopf":"\uD835\uDD57","forall":"\u2200","ForAll":"\u2200","fork":"\u22D4","forkv":"\u2AD9","Fouriertrf":"\u2131","fpartint":"\u2A0D","frac12":"\u00BD","frac13":"\u2153","frac14":"\u00BC","frac15":"\u2155","frac16":"\u2159","frac18":"\u215B","frac23":"\u2154","frac25":"\u2156","frac34":"\u00BE","frac35":"\u2157","frac38":"\u215C","frac45":"\u2158","frac56":"\u215A","frac58":"\u215D","frac78":"\u215E","frasl":"\u2044","frown":"\u2322","fscr":"\uD835\uDCBB","Fscr":"\u2131","gacute":"\u01F5","Gamma":"\u0393","gamma":"\u03B3","Gammad":"\u03DC","gammad":"\u03DD","gap":"\u2A86","Gbreve":"\u011E","gbreve":"\u011F","Gcedil":"\u0122","Gcirc":"\u011C","gcirc":"\u011D","Gcy":"\u0413","gcy":"\u0433","Gdot":"\u0120","gdot":"\u0121","ge":"\u2265","gE":"\u2267","gEl":"\u2A8C","gel":"\u22DB","geq":"\u2265","geqq":"\u2267","geqslant":"\u2A7E","gescc":"\u2AA9","ges":"\u2A7E","gesdot":"\u2A80","gesdoto":"\u2A82","gesdotol":"\u2A84","gesl":"\u22DB\uFE00","gesles":"\u2A94","Gfr":"\uD835\uDD0A","gfr":"\uD835\uDD24","gg":"\u226B","Gg":"\u22D9","ggg":"\u22D9","gimel":"\u2137","GJcy":"\u0403","gjcy":"\u0453","gla":"\u2AA5","gl":"\u2277","glE":"\u2A92","glj":"\u2AA4","gnap":"\u2A8A","gnapprox":"\u2A8A","gne":"\u2A88","gnE":"\u2269","gneq":"\u2A88","gneqq":"\u2269","gnsim":"\u22E7","Gopf":"\uD835\uDD3E","gopf":"\uD835\uDD58","grave":"`","GreaterEqual":"\u2265","GreaterEqualLess":"\u22DB","GreaterFullEqual":"\u2267","GreaterGreater":"\u2AA2","GreaterLess":"\u2277","GreaterSlantEqual":"\u2A7E","GreaterTilde":"\u2273","Gscr":"\uD835\uDCA2","gscr":"\u210A","gsim":"\u2273","gsime":"\u2A8E","gsiml":"\u2A90","gtcc":"\u2AA7","gtcir":"\u2A7A","gt":">","GT":">","Gt":"\u226B","gtdot":"\u22D7","gtlPar":"\u2995","gtquest":"\u2A7C","gtrapprox":"\u2A86","gtrarr":"\u2978","gtrdot":"\u22D7","gtreqless":"\u22DB","gtreqqless":"\u2A8C","gtrless":"\u2277","gtrsim":"\u2273","gvertneqq":"\u2269\uFE00","gvnE":"\u2269\uFE00","Hacek":"\u02C7","hairsp":"\u200A","half":"\u00BD","hamilt":"\u210B","HARDcy":"\u042A","hardcy":"\u044A","harrcir":"\u2948","harr":"\u2194","hArr":"\u21D4","harrw":"\u21AD","Hat":"^","hbar":"\u210F","Hcirc":"\u0124","hcirc":"\u0125","hearts":"\u2665","heartsuit":"\u2665","hellip":"\u2026","hercon":"\u22B9","hfr":"\uD835\uDD25","Hfr":"\u210C","HilbertSpace":"\u210B","hksearow":"\u2925","hkswarow":"\u2926","hoarr":"\u21FF","homtht":"\u223B","hookleftarrow":"\u21A9","hookrightarrow":"\u21AA","hopf":"\uD835\uDD59","Hopf":"\u210D","horbar":"\u2015","HorizontalLine":"\u2500","hscr":"\uD835\uDCBD","Hscr":"\u210B","hslash":"\u210F","Hstrok":"\u0126","hstrok":"\u0127","HumpDownHump":"\u224E","HumpEqual":"\u224F","hybull":"\u2043","hyphen":"\u2010","Iacute":"\u00CD","iacute":"\u00ED","ic":"\u2063","Icirc":"\u00CE","icirc":"\u00EE","Icy":"\u0418","icy":"\u0438","Idot":"\u0130","IEcy":"\u0415","iecy":"\u0435","iexcl":"\u00A1","iff":"\u21D4","ifr":"\uD835\uDD26","Ifr":"\u2111","Igrave":"\u00CC","igrave":"\u00EC","ii":"\u2148","iiiint":"\u2A0C","iiint":"\u222D","iinfin":"\u29DC","iiota":"\u2129","IJlig":"\u0132","ijlig":"\u0133","Imacr":"\u012A","imacr":"\u012B","image":"\u2111","ImaginaryI":"\u2148","imagline":"\u2110","imagpart":"\u2111","imath":"\u0131","Im":"\u2111","imof":"\u22B7","imped":"\u01B5","Implies":"\u21D2","incare":"\u2105","in":"\u2208","infin":"\u221E","infintie":"\u29DD","inodot":"\u0131","intcal":"\u22BA","int":"\u222B","Int":"\u222C","integers":"\u2124","Integral":"\u222B","intercal":"\u22BA","Intersection":"\u22C2","intlarhk":"\u2A17","intprod":"\u2A3C","InvisibleComma":"\u2063","InvisibleTimes":"\u2062","IOcy":"\u0401","iocy":"\u0451","Iogon":"\u012E","iogon":"\u012F","Iopf":"\uD835\uDD40","iopf":"\uD835\uDD5A","Iota":"\u0399","iota":"\u03B9","iprod":"\u2A3C","iquest":"\u00BF","iscr":"\uD835\uDCBE","Iscr":"\u2110","isin":"\u2208","isindot":"\u22F5","isinE":"\u22F9","isins":"\u22F4","isinsv":"\u22F3","isinv":"\u2208","it":"\u2062","Itilde":"\u0128","itilde":"\u0129","Iukcy":"\u0406","iukcy":"\u0456","Iuml":"\u00CF","iuml":"\u00EF","Jcirc":"\u0134","jcirc":"\u0135","Jcy":"\u0419","jcy":"\u0439","Jfr":"\uD835\uDD0D","jfr":"\uD835\uDD27","jmath":"\u0237","Jopf":"\uD835\uDD41","jopf":"\uD835\uDD5B","Jscr":"\uD835\uDCA5","jscr":"\uD835\uDCBF","Jsercy":"\u0408","jsercy":"\u0458","Jukcy":"\u0404","jukcy":"\u0454","Kappa":"\u039A","kappa":"\u03BA","kappav":"\u03F0","Kcedil":"\u0136","kcedil":"\u0137","Kcy":"\u041A","kcy":"\u043A","Kfr":"\uD835\uDD0E","kfr":"\uD835\uDD28","kgreen":"\u0138","KHcy":"\u0425","khcy":"\u0445","KJcy":"\u040C","kjcy":"\u045C","Kopf":"\uD835\uDD42","kopf":"\uD835\uDD5C","Kscr":"\uD835\uDCA6","kscr":"\uD835\uDCC0","lAarr":"\u21DA","Lacute":"\u0139","lacute":"\u013A","laemptyv":"\u29B4","lagran":"\u2112","Lambda":"\u039B","lambda":"\u03BB","lang":"\u27E8","Lang":"\u27EA","langd":"\u2991","langle":"\u27E8","lap":"\u2A85","Laplacetrf":"\u2112","laquo":"\u00AB","larrb":"\u21E4","larrbfs":"\u291F","larr":"\u2190","Larr":"\u219E","lArr":"\u21D0","larrfs":"\u291D","larrhk":"\u21A9","larrlp":"\u21AB","larrpl":"\u2939","larrsim":"\u2973","larrtl":"\u21A2","latail":"\u2919","lAtail":"\u291B","lat":"\u2AAB","late":"\u2AAD","lates":"\u2AAD\uFE00","lbarr":"\u290C","lBarr":"\u290E","lbbrk":"\u2772","lbrace":"{","lbrack":"[","lbrke":"\u298B","lbrksld":"\u298F","lbrkslu":"\u298D","Lcaron":"\u013D","lcaron":"\u013E","Lcedil":"\u013B","lcedil":"\u013C","lceil":"\u2308","lcub":"{","Lcy":"\u041B","lcy":"\u043B","ldca":"\u2936","ldquo":"\u201C","ldquor":"\u201E","ldrdhar":"\u2967","ldrushar":"\u294B","ldsh":"\u21B2","le":"\u2264","lE":"\u2266","LeftAngleBracket":"\u27E8","LeftArrowBar":"\u21E4","leftarrow":"\u2190","LeftArrow":"\u2190","Leftarrow":"\u21D0","LeftArrowRightArrow":"\u21C6","leftarrowtail":"\u21A2","LeftCeiling":"\u2308","LeftDoubleBracket":"\u27E6","LeftDownTeeVector":"\u2961","LeftDownVectorBar":"\u2959","LeftDownVector":"\u21C3","LeftFloor":"\u230A","leftharpoondown":"\u21BD","leftharpoonup":"\u21BC","leftleftarrows":"\u21C7","leftrightarrow":"\u2194","LeftRightArrow":"\u2194","Leftrightarrow":"\u21D4","leftrightarrows":"\u21C6","leftrightharpoons":"\u21CB","leftrightsquigarrow":"\u21AD","LeftRightVector":"\u294E","LeftTeeArrow":"\u21A4","LeftTee":"\u22A3","LeftTeeVector":"\u295A","leftthreetimes":"\u22CB","LeftTriangleBar":"\u29CF","LeftTriangle":"\u22B2","LeftTriangleEqual":"\u22B4","LeftUpDownVector":"\u2951","LeftUpTeeVector":"\u2960","LeftUpVectorBar":"\u2958","LeftUpVector":"\u21BF","LeftVectorBar":"\u2952","LeftVector":"\u21BC","lEg":"\u2A8B","leg":"\u22DA","leq":"\u2264","leqq":"\u2266","leqslant":"\u2A7D","lescc":"\u2AA8","les":"\u2A7D","lesdot":"\u2A7F","lesdoto":"\u2A81","lesdotor":"\u2A83","lesg":"\u22DA\uFE00","lesges":"\u2A93","lessapprox":"\u2A85","lessdot":"\u22D6","lesseqgtr":"\u22DA","lesseqqgtr":"\u2A8B","LessEqualGreater":"\u22DA","LessFullEqual":"\u2266","LessGreater":"\u2276","lessgtr":"\u2276","LessLess":"\u2AA1","lesssim":"\u2272","LessSlantEqual":"\u2A7D","LessTilde":"\u2272","lfisht":"\u297C","lfloor":"\u230A","Lfr":"\uD835\uDD0F","lfr":"\uD835\uDD29","lg":"\u2276","lgE":"\u2A91","lHar":"\u2962","lhard":"\u21BD","lharu":"\u21BC","lharul":"\u296A","lhblk":"\u2584","LJcy":"\u0409","ljcy":"\u0459","llarr":"\u21C7","ll":"\u226A","Ll":"\u22D8","llcorner":"\u231E","Lleftarrow":"\u21DA","llhard":"\u296B","lltri":"\u25FA","Lmidot":"\u013F","lmidot":"\u0140","lmoustache":"\u23B0","lmoust":"\u23B0","lnap":"\u2A89","lnapprox":"\u2A89","lne":"\u2A87","lnE":"\u2268","lneq":"\u2A87","lneqq":"\u2268","lnsim":"\u22E6","loang":"\u27EC","loarr":"\u21FD","lobrk":"\u27E6","longleftarrow":"\u27F5","LongLeftArrow":"\u27F5","Longleftarrow":"\u27F8","longleftrightarrow":"\u27F7","LongLeftRightArrow":"\u27F7","Longleftrightarrow":"\u27FA","longmapsto":"\u27FC","longrightarrow":"\u27F6","LongRightArrow":"\u27F6","Longrightarrow":"\u27F9","looparrowleft":"\u21AB","looparrowright":"\u21AC","lopar":"\u2985","Lopf":"\uD835\uDD43","lopf":"\uD835\uDD5D","loplus":"\u2A2D","lotimes":"\u2A34","lowast":"\u2217","lowbar":"_","LowerLeftArrow":"\u2199","LowerRightArrow":"\u2198","loz":"\u25CA","lozenge":"\u25CA","lozf":"\u29EB","lpar":"(","lparlt":"\u2993","lrarr":"\u21C6","lrcorner":"\u231F","lrhar":"\u21CB","lrhard":"\u296D","lrm":"\u200E","lrtri":"\u22BF","lsaquo":"\u2039","lscr":"\uD835\uDCC1","Lscr":"\u2112","lsh":"\u21B0","Lsh":"\u21B0","lsim":"\u2272","lsime":"\u2A8D","lsimg":"\u2A8F","lsqb":"[","lsquo":"\u2018","lsquor":"\u201A","Lstrok":"\u0141","lstrok":"\u0142","ltcc":"\u2AA6","ltcir":"\u2A79","lt":"<","LT":"<","Lt":"\u226A","ltdot":"\u22D6","lthree":"\u22CB","ltimes":"\u22C9","ltlarr":"\u2976","ltquest":"\u2A7B","ltri":"\u25C3","ltrie":"\u22B4","ltrif":"\u25C2","ltrPar":"\u2996","lurdshar":"\u294A","luruhar":"\u2966","lvertneqq":"\u2268\uFE00","lvnE":"\u2268\uFE00","macr":"\u00AF","male":"\u2642","malt":"\u2720","maltese":"\u2720","Map":"\u2905","map":"\u21A6","mapsto":"\u21A6","mapstodown":"\u21A7","mapstoleft":"\u21A4","mapstoup":"\u21A5","marker":"\u25AE","mcomma":"\u2A29","Mcy":"\u041C","mcy":"\u043C","mdash":"\u2014","mDDot":"\u223A","measuredangle":"\u2221","MediumSpace":"\u205F","Mellintrf":"\u2133","Mfr":"\uD835\uDD10","mfr":"\uD835\uDD2A","mho":"\u2127","micro":"\u00B5","midast":"*","midcir":"\u2AF0","mid":"\u2223","middot":"\u00B7","minusb":"\u229F","minus":"\u2212","minusd":"\u2238","minusdu":"\u2A2A","MinusPlus":"\u2213","mlcp":"\u2ADB","mldr":"\u2026","mnplus":"\u2213","models":"\u22A7","Mopf":"\uD835\uDD44","mopf":"\uD835\uDD5E","mp":"\u2213","mscr":"\uD835\uDCC2","Mscr":"\u2133","mstpos":"\u223E","Mu":"\u039C","mu":"\u03BC","multimap":"\u22B8","mumap":"\u22B8","nabla":"\u2207","Nacute":"\u0143","nacute":"\u0144","nang":"\u2220\u20D2","nap":"\u2249","napE":"\u2A70\u0338","napid":"\u224B\u0338","napos":"\u0149","napprox":"\u2249","natural":"\u266E","naturals":"\u2115","natur":"\u266E","nbsp":"\u00A0","nbump":"\u224E\u0338","nbumpe":"\u224F\u0338","ncap":"\u2A43","Ncaron":"\u0147","ncaron":"\u0148","Ncedil":"\u0145","ncedil":"\u0146","ncong":"\u2247","ncongdot":"\u2A6D\u0338","ncup":"\u2A42","Ncy":"\u041D","ncy":"\u043D","ndash":"\u2013","nearhk":"\u2924","nearr":"\u2197","neArr":"\u21D7","nearrow":"\u2197","ne":"\u2260","nedot":"\u2250\u0338","NegativeMediumSpace":"\u200B","NegativeThickSpace":"\u200B","NegativeThinSpace":"\u200B","NegativeVeryThinSpace":"\u200B","nequiv":"\u2262","nesear":"\u2928","nesim":"\u2242\u0338","NestedGreaterGreater":"\u226B","NestedLessLess":"\u226A","NewLine":"\n","nexist":"\u2204","nexists":"\u2204","Nfr":"\uD835\uDD11","nfr":"\uD835\uDD2B","ngE":"\u2267\u0338","nge":"\u2271","ngeq":"\u2271","ngeqq":"\u2267\u0338","ngeqslant":"\u2A7E\u0338","nges":"\u2A7E\u0338","nGg":"\u22D9\u0338","ngsim":"\u2275","nGt":"\u226B\u20D2","ngt":"\u226F","ngtr":"\u226F","nGtv":"\u226B\u0338","nharr":"\u21AE","nhArr":"\u21CE","nhpar":"\u2AF2","ni":"\u220B","nis":"\u22FC","nisd":"\u22FA","niv":"\u220B","NJcy":"\u040A","njcy":"\u045A","nlarr":"\u219A","nlArr":"\u21CD","nldr":"\u2025","nlE":"\u2266\u0338","nle":"\u2270","nleftarrow":"\u219A","nLeftarrow":"\u21CD","nleftrightarrow":"\u21AE","nLeftrightarrow":"\u21CE","nleq":"\u2270","nleqq":"\u2266\u0338","nleqslant":"\u2A7D\u0338","nles":"\u2A7D\u0338","nless":"\u226E","nLl":"\u22D8\u0338","nlsim":"\u2274","nLt":"\u226A\u20D2","nlt":"\u226E","nltri":"\u22EA","nltrie":"\u22EC","nLtv":"\u226A\u0338","nmid":"\u2224","NoBreak":"\u2060","NonBreakingSpace":"\u00A0","nopf":"\uD835\uDD5F","Nopf":"\u2115","Not":"\u2AEC","not":"\u00AC","NotCongruent":"\u2262","NotCupCap":"\u226D","NotDoubleVerticalBar":"\u2226","NotElement":"\u2209","NotEqual":"\u2260","NotEqualTilde":"\u2242\u0338","NotExists":"\u2204","NotGreater":"\u226F","NotGreaterEqual":"\u2271","NotGreaterFullEqual":"\u2267\u0338","NotGreaterGreater":"\u226B\u0338","NotGreaterLess":"\u2279","NotGreaterSlantEqual":"\u2A7E\u0338","NotGreaterTilde":"\u2275","NotHumpDownHump":"\u224E\u0338","NotHumpEqual":"\u224F\u0338","notin":"\u2209","notindot":"\u22F5\u0338","notinE":"\u22F9\u0338","notinva":"\u2209","notinvb":"\u22F7","notinvc":"\u22F6","NotLeftTriangleBar":"\u29CF\u0338","NotLeftTriangle":"\u22EA","NotLeftTriangleEqual":"\u22EC","NotLess":"\u226E","NotLessEqual":"\u2270","NotLessGreater":"\u2278","NotLessLess":"\u226A\u0338","NotLessSlantEqual":"\u2A7D\u0338","NotLessTilde":"\u2274","NotNestedGreaterGreater":"\u2AA2\u0338","NotNestedLessLess":"\u2AA1\u0338","notni":"\u220C","notniva":"\u220C","notnivb":"\u22FE","notnivc":"\u22FD","NotPrecedes":"\u2280","NotPrecedesEqual":"\u2AAF\u0338","NotPrecedesSlantEqual":"\u22E0","NotReverseElement":"\u220C","NotRightTriangleBar":"\u29D0\u0338","NotRightTriangle":"\u22EB","NotRightTriangleEqual":"\u22ED","NotSquareSubset":"\u228F\u0338","NotSquareSubsetEqual":"\u22E2","NotSquareSuperset":"\u2290\u0338","NotSquareSupersetEqual":"\u22E3","NotSubset":"\u2282\u20D2","NotSubsetEqual":"\u2288","NotSucceeds":"\u2281","NotSucceedsEqual":"\u2AB0\u0338","NotSucceedsSlantEqual":"\u22E1","NotSucceedsTilde":"\u227F\u0338","NotSuperset":"\u2283\u20D2","NotSupersetEqual":"\u2289","NotTilde":"\u2241","NotTildeEqual":"\u2244","NotTildeFullEqual":"\u2247","NotTildeTilde":"\u2249","NotVerticalBar":"\u2224","nparallel":"\u2226","npar":"\u2226","nparsl":"\u2AFD\u20E5","npart":"\u2202\u0338","npolint":"\u2A14","npr":"\u2280","nprcue":"\u22E0","nprec":"\u2280","npreceq":"\u2AAF\u0338","npre":"\u2AAF\u0338","nrarrc":"\u2933\u0338","nrarr":"\u219B","nrArr":"\u21CF","nrarrw":"\u219D\u0338","nrightarrow":"\u219B","nRightarrow":"\u21CF","nrtri":"\u22EB","nrtrie":"\u22ED","nsc":"\u2281","nsccue":"\u22E1","nsce":"\u2AB0\u0338","Nscr":"\uD835\uDCA9","nscr":"\uD835\uDCC3","nshortmid":"\u2224","nshortparallel":"\u2226","nsim":"\u2241","nsime":"\u2244","nsimeq":"\u2244","nsmid":"\u2224","nspar":"\u2226","nsqsube":"\u22E2","nsqsupe":"\u22E3","nsub":"\u2284","nsubE":"\u2AC5\u0338","nsube":"\u2288","nsubset":"\u2282\u20D2","nsubseteq":"\u2288","nsubseteqq":"\u2AC5\u0338","nsucc":"\u2281","nsucceq":"\u2AB0\u0338","nsup":"\u2285","nsupE":"\u2AC6\u0338","nsupe":"\u2289","nsupset":"\u2283\u20D2","nsupseteq":"\u2289","nsupseteqq":"\u2AC6\u0338","ntgl":"\u2279","Ntilde":"\u00D1","ntilde":"\u00F1","ntlg":"\u2278","ntriangleleft":"\u22EA","ntrianglelefteq":"\u22EC","ntriangleright":"\u22EB","ntrianglerighteq":"\u22ED","Nu":"\u039D","nu":"\u03BD","num":"#","numero":"\u2116","numsp":"\u2007","nvap":"\u224D\u20D2","nvdash":"\u22AC","nvDash":"\u22AD","nVdash":"\u22AE","nVDash":"\u22AF","nvge":"\u2265\u20D2","nvgt":">\u20D2","nvHarr":"\u2904","nvinfin":"\u29DE","nvlArr":"\u2902","nvle":"\u2264\u20D2","nvlt":"<\u20D2","nvltrie":"\u22B4\u20D2","nvrArr":"\u2903","nvrtrie":"\u22B5\u20D2","nvsim":"\u223C\u20D2","nwarhk":"\u2923","nwarr":"\u2196","nwArr":"\u21D6","nwarrow":"\u2196","nwnear":"\u2927","Oacute":"\u00D3","oacute":"\u00F3","oast":"\u229B","Ocirc":"\u00D4","ocirc":"\u00F4","ocir":"\u229A","Ocy":"\u041E","ocy":"\u043E","odash":"\u229D","Odblac":"\u0150","odblac":"\u0151","odiv":"\u2A38","odot":"\u2299","odsold":"\u29BC","OElig":"\u0152","oelig":"\u0153","ofcir":"\u29BF","Ofr":"\uD835\uDD12","ofr":"\uD835\uDD2C","ogon":"\u02DB","Ograve":"\u00D2","ograve":"\u00F2","ogt":"\u29C1","ohbar":"\u29B5","ohm":"\u03A9","oint":"\u222E","olarr":"\u21BA","olcir":"\u29BE","olcross":"\u29BB","oline":"\u203E","olt":"\u29C0","Omacr":"\u014C","omacr":"\u014D","Omega":"\u03A9","omega":"\u03C9","Omicron":"\u039F","omicron":"\u03BF","omid":"\u29B6","ominus":"\u2296","Oopf":"\uD835\uDD46","oopf":"\uD835\uDD60","opar":"\u29B7","OpenCurlyDoubleQuote":"\u201C","OpenCurlyQuote":"\u2018","operp":"\u29B9","oplus":"\u2295","orarr":"\u21BB","Or":"\u2A54","or":"\u2228","ord":"\u2A5D","order":"\u2134","orderof":"\u2134","ordf":"\u00AA","ordm":"\u00BA","origof":"\u22B6","oror":"\u2A56","orslope":"\u2A57","orv":"\u2A5B","oS":"\u24C8","Oscr":"\uD835\uDCAA","oscr":"\u2134","Oslash":"\u00D8","oslash":"\u00F8","osol":"\u2298","Otilde":"\u00D5","otilde":"\u00F5","otimesas":"\u2A36","Otimes":"\u2A37","otimes":"\u2297","Ouml":"\u00D6","ouml":"\u00F6","ovbar":"\u233D","OverBar":"\u203E","OverBrace":"\u23DE","OverBracket":"\u23B4","OverParenthesis":"\u23DC","para":"\u00B6","parallel":"\u2225","par":"\u2225","parsim":"\u2AF3","parsl":"\u2AFD","part":"\u2202","PartialD":"\u2202","Pcy":"\u041F","pcy":"\u043F","percnt":"%","period":".","permil":"\u2030","perp":"\u22A5","pertenk":"\u2031","Pfr":"\uD835\uDD13","pfr":"\uD835\uDD2D","Phi":"\u03A6","phi":"\u03C6","phiv":"\u03D5","phmmat":"\u2133","phone":"\u260E","Pi":"\u03A0","pi":"\u03C0","pitchfork":"\u22D4","piv":"\u03D6","planck":"\u210F","planckh":"\u210E","plankv":"\u210F","plusacir":"\u2A23","plusb":"\u229E","pluscir":"\u2A22","plus":"+","plusdo":"\u2214","plusdu":"\u2A25","pluse":"\u2A72","PlusMinus":"\u00B1","plusmn":"\u00B1","plussim":"\u2A26","plustwo":"\u2A27","pm":"\u00B1","Poincareplane":"\u210C","pointint":"\u2A15","popf":"\uD835\uDD61","Popf":"\u2119","pound":"\u00A3","prap":"\u2AB7","Pr":"\u2ABB","pr":"\u227A","prcue":"\u227C","precapprox":"\u2AB7","prec":"\u227A","preccurlyeq":"\u227C","Precedes":"\u227A","PrecedesEqual":"\u2AAF","PrecedesSlantEqual":"\u227C","PrecedesTilde":"\u227E","preceq":"\u2AAF","precnapprox":"\u2AB9","precneqq":"\u2AB5","precnsim":"\u22E8","pre":"\u2AAF","prE":"\u2AB3","precsim":"\u227E","prime":"\u2032","Prime":"\u2033","primes":"\u2119","prnap":"\u2AB9","prnE":"\u2AB5","prnsim":"\u22E8","prod":"\u220F","Product":"\u220F","profalar":"\u232E","profline":"\u2312","profsurf":"\u2313","prop":"\u221D","Proportional":"\u221D","Proportion":"\u2237","propto":"\u221D","prsim":"\u227E","prurel":"\u22B0","Pscr":"\uD835\uDCAB","pscr":"\uD835\uDCC5","Psi":"\u03A8","psi":"\u03C8","puncsp":"\u2008","Qfr":"\uD835\uDD14","qfr":"\uD835\uDD2E","qint":"\u2A0C","qopf":"\uD835\uDD62","Qopf":"\u211A","qprime":"\u2057","Qscr":"\uD835\uDCAC","qscr":"\uD835\uDCC6","quaternions":"\u210D","quatint":"\u2A16","quest":"?","questeq":"\u225F","quot":"\"","QUOT":"\"","rAarr":"\u21DB","race":"\u223D\u0331","Racute":"\u0154","racute":"\u0155","radic":"\u221A","raemptyv":"\u29B3","rang":"\u27E9","Rang":"\u27EB","rangd":"\u2992","range":"\u29A5","rangle":"\u27E9","raquo":"\u00BB","rarrap":"\u2975","rarrb":"\u21E5","rarrbfs":"\u2920","rarrc":"\u2933","rarr":"\u2192","Rarr":"\u21A0","rArr":"\u21D2","rarrfs":"\u291E","rarrhk":"\u21AA","rarrlp":"\u21AC","rarrpl":"\u2945","rarrsim":"\u2974","Rarrtl":"\u2916","rarrtl":"\u21A3","rarrw":"\u219D","ratail":"\u291A","rAtail":"\u291C","ratio":"\u2236","rationals":"\u211A","rbarr":"\u290D","rBarr":"\u290F","RBarr":"\u2910","rbbrk":"\u2773","rbrace":"}","rbrack":"]","rbrke":"\u298C","rbrksld":"\u298E","rbrkslu":"\u2990","Rcaron":"\u0158","rcaron":"\u0159","Rcedil":"\u0156","rcedil":"\u0157","rceil":"\u2309","rcub":"}","Rcy":"\u0420","rcy":"\u0440","rdca":"\u2937","rdldhar":"\u2969","rdquo":"\u201D","rdquor":"\u201D","rdsh":"\u21B3","real":"\u211C","realine":"\u211B","realpart":"\u211C","reals":"\u211D","Re":"\u211C","rect":"\u25AD","reg":"\u00AE","REG":"\u00AE","ReverseElement":"\u220B","ReverseEquilibrium":"\u21CB","ReverseUpEquilibrium":"\u296F","rfisht":"\u297D","rfloor":"\u230B","rfr":"\uD835\uDD2F","Rfr":"\u211C","rHar":"\u2964","rhard":"\u21C1","rharu":"\u21C0","rharul":"\u296C","Rho":"\u03A1","rho":"\u03C1","rhov":"\u03F1","RightAngleBracket":"\u27E9","RightArrowBar":"\u21E5","rightarrow":"\u2192","RightArrow":"\u2192","Rightarrow":"\u21D2","RightArrowLeftArrow":"\u21C4","rightarrowtail":"\u21A3","RightCeiling":"\u2309","RightDoubleBracket":"\u27E7","RightDownTeeVector":"\u295D","RightDownVectorBar":"\u2955","RightDownVector":"\u21C2","RightFloor":"\u230B","rightharpoondown":"\u21C1","rightharpoonup":"\u21C0","rightleftarrows":"\u21C4","rightleftharpoons":"\u21CC","rightrightarrows":"\u21C9","rightsquigarrow":"\u219D","RightTeeArrow":"\u21A6","RightTee":"\u22A2","RightTeeVector":"\u295B","rightthreetimes":"\u22CC","RightTriangleBar":"\u29D0","RightTriangle":"\u22B3","RightTriangleEqual":"\u22B5","RightUpDownVector":"\u294F","RightUpTeeVector":"\u295C","RightUpVectorBar":"\u2954","RightUpVector":"\u21BE","RightVectorBar":"\u2953","RightVector":"\u21C0","ring":"\u02DA","risingdotseq":"\u2253","rlarr":"\u21C4","rlhar":"\u21CC","rlm":"\u200F","rmoustache":"\u23B1","rmoust":"\u23B1","rnmid":"\u2AEE","roang":"\u27ED","roarr":"\u21FE","robrk":"\u27E7","ropar":"\u2986","ropf":"\uD835\uDD63","Ropf":"\u211D","roplus":"\u2A2E","rotimes":"\u2A35","RoundImplies":"\u2970","rpar":")","rpargt":"\u2994","rppolint":"\u2A12","rrarr":"\u21C9","Rrightarrow":"\u21DB","rsaquo":"\u203A","rscr":"\uD835\uDCC7","Rscr":"\u211B","rsh":"\u21B1","Rsh":"\u21B1","rsqb":"]","rsquo":"\u2019","rsquor":"\u2019","rthree":"\u22CC","rtimes":"\u22CA","rtri":"\u25B9","rtrie":"\u22B5","rtrif":"\u25B8","rtriltri":"\u29CE","RuleDelayed":"\u29F4","ruluhar":"\u2968","rx":"\u211E","Sacute":"\u015A","sacute":"\u015B","sbquo":"\u201A","scap":"\u2AB8","Scaron":"\u0160","scaron":"\u0161","Sc":"\u2ABC","sc":"\u227B","sccue":"\u227D","sce":"\u2AB0","scE":"\u2AB4","Scedil":"\u015E","scedil":"\u015F","Scirc":"\u015C","scirc":"\u015D","scnap":"\u2ABA","scnE":"\u2AB6","scnsim":"\u22E9","scpolint":"\u2A13","scsim":"\u227F","Scy":"\u0421","scy":"\u0441","sdotb":"\u22A1","sdot":"\u22C5","sdote":"\u2A66","searhk":"\u2925","searr":"\u2198","seArr":"\u21D8","searrow":"\u2198","sect":"\u00A7","semi":";","seswar":"\u2929","setminus":"\u2216","setmn":"\u2216","sext":"\u2736","Sfr":"\uD835\uDD16","sfr":"\uD835\uDD30","sfrown":"\u2322","sharp":"\u266F","SHCHcy":"\u0429","shchcy":"\u0449","SHcy":"\u0428","shcy":"\u0448","ShortDownArrow":"\u2193","ShortLeftArrow":"\u2190","shortmid":"\u2223","shortparallel":"\u2225","ShortRightArrow":"\u2192","ShortUpArrow":"\u2191","shy":"\u00AD","Sigma":"\u03A3","sigma":"\u03C3","sigmaf":"\u03C2","sigmav":"\u03C2","sim":"\u223C","simdot":"\u2A6A","sime":"\u2243","simeq":"\u2243","simg":"\u2A9E","simgE":"\u2AA0","siml":"\u2A9D","simlE":"\u2A9F","simne":"\u2246","simplus":"\u2A24","simrarr":"\u2972","slarr":"\u2190","SmallCircle":"\u2218","smallsetminus":"\u2216","smashp":"\u2A33","smeparsl":"\u29E4","smid":"\u2223","smile":"\u2323","smt":"\u2AAA","smte":"\u2AAC","smtes":"\u2AAC\uFE00","SOFTcy":"\u042C","softcy":"\u044C","solbar":"\u233F","solb":"\u29C4","sol":"/","Sopf":"\uD835\uDD4A","sopf":"\uD835\uDD64","spades":"\u2660","spadesuit":"\u2660","spar":"\u2225","sqcap":"\u2293","sqcaps":"\u2293\uFE00","sqcup":"\u2294","sqcups":"\u2294\uFE00","Sqrt":"\u221A","sqsub":"\u228F","sqsube":"\u2291","sqsubset":"\u228F","sqsubseteq":"\u2291","sqsup":"\u2290","sqsupe":"\u2292","sqsupset":"\u2290","sqsupseteq":"\u2292","square":"\u25A1","Square":"\u25A1","SquareIntersection":"\u2293","SquareSubset":"\u228F","SquareSubsetEqual":"\u2291","SquareSuperset":"\u2290","SquareSupersetEqual":"\u2292","SquareUnion":"\u2294","squarf":"\u25AA","squ":"\u25A1","squf":"\u25AA","srarr":"\u2192","Sscr":"\uD835\uDCAE","sscr":"\uD835\uDCC8","ssetmn":"\u2216","ssmile":"\u2323","sstarf":"\u22C6","Star":"\u22C6","star":"\u2606","starf":"\u2605","straightepsilon":"\u03F5","straightphi":"\u03D5","strns":"\u00AF","sub":"\u2282","Sub":"\u22D0","subdot":"\u2ABD","subE":"\u2AC5","sube":"\u2286","subedot":"\u2AC3","submult":"\u2AC1","subnE":"\u2ACB","subne":"\u228A","subplus":"\u2ABF","subrarr":"\u2979","subset":"\u2282","Subset":"\u22D0","subseteq":"\u2286","subseteqq":"\u2AC5","SubsetEqual":"\u2286","subsetneq":"\u228A","subsetneqq":"\u2ACB","subsim":"\u2AC7","subsub":"\u2AD5","subsup":"\u2AD3","succapprox":"\u2AB8","succ":"\u227B","succcurlyeq":"\u227D","Succeeds":"\u227B","SucceedsEqual":"\u2AB0","SucceedsSlantEqual":"\u227D","SucceedsTilde":"\u227F","succeq":"\u2AB0","succnapprox":"\u2ABA","succneqq":"\u2AB6","succnsim":"\u22E9","succsim":"\u227F","SuchThat":"\u220B","sum":"\u2211","Sum":"\u2211","sung":"\u266A","sup1":"\u00B9","sup2":"\u00B2","sup3":"\u00B3","sup":"\u2283","Sup":"\u22D1","supdot":"\u2ABE","supdsub":"\u2AD8","supE":"\u2AC6","supe":"\u2287","supedot":"\u2AC4","Superset":"\u2283","SupersetEqual":"\u2287","suphsol":"\u27C9","suphsub":"\u2AD7","suplarr":"\u297B","supmult":"\u2AC2","supnE":"\u2ACC","supne":"\u228B","supplus":"\u2AC0","supset":"\u2283","Supset":"\u22D1","supseteq":"\u2287","supseteqq":"\u2AC6","supsetneq":"\u228B","supsetneqq":"\u2ACC","supsim":"\u2AC8","supsub":"\u2AD4","supsup":"\u2AD6","swarhk":"\u2926","swarr":"\u2199","swArr":"\u21D9","swarrow":"\u2199","swnwar":"\u292A","szlig":"\u00DF","Tab":"\t","target":"\u2316","Tau":"\u03A4","tau":"\u03C4","tbrk":"\u23B4","Tcaron":"\u0164","tcaron":"\u0165","Tcedil":"\u0162","tcedil":"\u0163","Tcy":"\u0422","tcy":"\u0442","tdot":"\u20DB","telrec":"\u2315","Tfr":"\uD835\uDD17","tfr":"\uD835\uDD31","there4":"\u2234","therefore":"\u2234","Therefore":"\u2234","Theta":"\u0398","theta":"\u03B8","thetasym":"\u03D1","thetav":"\u03D1","thickapprox":"\u2248","thicksim":"\u223C","ThickSpace":"\u205F\u200A","ThinSpace":"\u2009","thinsp":"\u2009","thkap":"\u2248","thksim":"\u223C","THORN":"\u00DE","thorn":"\u00FE","tilde":"\u02DC","Tilde":"\u223C","TildeEqual":"\u2243","TildeFullEqual":"\u2245","TildeTilde":"\u2248","timesbar":"\u2A31","timesb":"\u22A0","times":"\u00D7","timesd":"\u2A30","tint":"\u222D","toea":"\u2928","topbot":"\u2336","topcir":"\u2AF1","top":"\u22A4","Topf":"\uD835\uDD4B","topf":"\uD835\uDD65","topfork":"\u2ADA","tosa":"\u2929","tprime":"\u2034","trade":"\u2122","TRADE":"\u2122","triangle":"\u25B5","triangledown":"\u25BF","triangleleft":"\u25C3","trianglelefteq":"\u22B4","triangleq":"\u225C","triangleright":"\u25B9","trianglerighteq":"\u22B5","tridot":"\u25EC","trie":"\u225C","triminus":"\u2A3A","TripleDot":"\u20DB","triplus":"\u2A39","trisb":"\u29CD","tritime":"\u2A3B","trpezium":"\u23E2","Tscr":"\uD835\uDCAF","tscr":"\uD835\uDCC9","TScy":"\u0426","tscy":"\u0446","TSHcy":"\u040B","tshcy":"\u045B","Tstrok":"\u0166","tstrok":"\u0167","twixt":"\u226C","twoheadleftarrow":"\u219E","twoheadrightarrow":"\u21A0","Uacute":"\u00DA","uacute":"\u00FA","uarr":"\u2191","Uarr":"\u219F","uArr":"\u21D1","Uarrocir":"\u2949","Ubrcy":"\u040E","ubrcy":"\u045E","Ubreve":"\u016C","ubreve":"\u016D","Ucirc":"\u00DB","ucirc":"\u00FB","Ucy":"\u0423","ucy":"\u0443","udarr":"\u21C5","Udblac":"\u0170","udblac":"\u0171","udhar":"\u296E","ufisht":"\u297E","Ufr":"\uD835\uDD18","ufr":"\uD835\uDD32","Ugrave":"\u00D9","ugrave":"\u00F9","uHar":"\u2963","uharl":"\u21BF","uharr":"\u21BE","uhblk":"\u2580","ulcorn":"\u231C","ulcorner":"\u231C","ulcrop":"\u230F","ultri":"\u25F8","Umacr":"\u016A","umacr":"\u016B","uml":"\u00A8","UnderBar":"_","UnderBrace":"\u23DF","UnderBracket":"\u23B5","UnderParenthesis":"\u23DD","Union":"\u22C3","UnionPlus":"\u228E","Uogon":"\u0172","uogon":"\u0173","Uopf":"\uD835\uDD4C","uopf":"\uD835\uDD66","UpArrowBar":"\u2912","uparrow":"\u2191","UpArrow":"\u2191","Uparrow":"\u21D1","UpArrowDownArrow":"\u21C5","updownarrow":"\u2195","UpDownArrow":"\u2195","Updownarrow":"\u21D5","UpEquilibrium":"\u296E","upharpoonleft":"\u21BF","upharpoonright":"\u21BE","uplus":"\u228E","UpperLeftArrow":"\u2196","UpperRightArrow":"\u2197","upsi":"\u03C5","Upsi":"\u03D2","upsih":"\u03D2","Upsilon":"\u03A5","upsilon":"\u03C5","UpTeeArrow":"\u21A5","UpTee":"\u22A5","upuparrows":"\u21C8","urcorn":"\u231D","urcorner":"\u231D","urcrop":"\u230E","Uring":"\u016E","uring":"\u016F","urtri":"\u25F9","Uscr":"\uD835\uDCB0","uscr":"\uD835\uDCCA","utdot":"\u22F0","Utilde":"\u0168","utilde":"\u0169","utri":"\u25B5","utrif":"\u25B4","uuarr":"\u21C8","Uuml":"\u00DC","uuml":"\u00FC","uwangle":"\u29A7","vangrt":"\u299C","varepsilon":"\u03F5","varkappa":"\u03F0","varnothing":"\u2205","varphi":"\u03D5","varpi":"\u03D6","varpropto":"\u221D","varr":"\u2195","vArr":"\u21D5","varrho":"\u03F1","varsigma":"\u03C2","varsubsetneq":"\u228A\uFE00","varsubsetneqq":"\u2ACB\uFE00","varsupsetneq":"\u228B\uFE00","varsupsetneqq":"\u2ACC\uFE00","vartheta":"\u03D1","vartriangleleft":"\u22B2","vartriangleright":"\u22B3","vBar":"\u2AE8","Vbar":"\u2AEB","vBarv":"\u2AE9","Vcy":"\u0412","vcy":"\u0432","vdash":"\u22A2","vDash":"\u22A8","Vdash":"\u22A9","VDash":"\u22AB","Vdashl":"\u2AE6","veebar":"\u22BB","vee":"\u2228","Vee":"\u22C1","veeeq":"\u225A","vellip":"\u22EE","verbar":"|","Verbar":"\u2016","vert":"|","Vert":"\u2016","VerticalBar":"\u2223","VerticalLine":"|","VerticalSeparator":"\u2758","VerticalTilde":"\u2240","VeryThinSpace":"\u200A","Vfr":"\uD835\uDD19","vfr":"\uD835\uDD33","vltri":"\u22B2","vnsub":"\u2282\u20D2","vnsup":"\u2283\u20D2","Vopf":"\uD835\uDD4D","vopf":"\uD835\uDD67","vprop":"\u221D","vrtri":"\u22B3","Vscr":"\uD835\uDCB1","vscr":"\uD835\uDCCB","vsubnE":"\u2ACB\uFE00","vsubne":"\u228A\uFE00","vsupnE":"\u2ACC\uFE00","vsupne":"\u228B\uFE00","Vvdash":"\u22AA","vzigzag":"\u299A","Wcirc":"\u0174","wcirc":"\u0175","wedbar":"\u2A5F","wedge":"\u2227","Wedge":"\u22C0","wedgeq":"\u2259","weierp":"\u2118","Wfr":"\uD835\uDD1A","wfr":"\uD835\uDD34","Wopf":"\uD835\uDD4E","wopf":"\uD835\uDD68","wp":"\u2118","wr":"\u2240","wreath":"\u2240","Wscr":"\uD835\uDCB2","wscr":"\uD835\uDCCC","xcap":"\u22C2","xcirc":"\u25EF","xcup":"\u22C3","xdtri":"\u25BD","Xfr":"\uD835\uDD1B","xfr":"\uD835\uDD35","xharr":"\u27F7","xhArr":"\u27FA","Xi":"\u039E","xi":"\u03BE","xlarr":"\u27F5","xlArr":"\u27F8","xmap":"\u27FC","xnis":"\u22FB","xodot":"\u2A00","Xopf":"\uD835\uDD4F","xopf":"\uD835\uDD69","xoplus":"\u2A01","xotime":"\u2A02","xrarr":"\u27F6","xrArr":"\u27F9","Xscr":"\uD835\uDCB3","xscr":"\uD835\uDCCD","xsqcup":"\u2A06","xuplus":"\u2A04","xutri":"\u25B3","xvee":"\u22C1","xwedge":"\u22C0","Yacute":"\u00DD","yacute":"\u00FD","YAcy":"\u042F","yacy":"\u044F","Ycirc":"\u0176","ycirc":"\u0177","Ycy":"\u042B","ycy":"\u044B","yen":"\u00A5","Yfr":"\uD835\uDD1C","yfr":"\uD835\uDD36","YIcy":"\u0407","yicy":"\u0457","Yopf":"\uD835\uDD50","yopf":"\uD835\uDD6A","Yscr":"\uD835\uDCB4","yscr":"\uD835\uDCCE","YUcy":"\u042E","yucy":"\u044E","yuml":"\u00FF","Yuml":"\u0178","Zacute":"\u0179","zacute":"\u017A","Zcaron":"\u017D","zcaron":"\u017E","Zcy":"\u0417","zcy":"\u0437","Zdot":"\u017B","zdot":"\u017C","zeetrf":"\u2128","ZeroWidthSpace":"\u200B","Zeta":"\u0396","zeta":"\u03B6","zfr":"\uD835\uDD37","Zfr":"\u2128","ZHcy":"\u0416","zhcy":"\u0436","zigrarr":"\u21DD","zopf":"\uD835\uDD6B","Zopf":"\u2124","Zscr":"\uD835\uDCB5","zscr":"\uD835\uDCCF","zwj":"\u200D","zwnj":"\u200C"} -1 4791 },{}],29:[function(require,module,exports){ -1 4792 (function (global){ 4715 47934716 -1 // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)4717 -1 var tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';-1 4794 /* -1 4795 * Module requirements. -1 4796 */ 4718 47974719 -1 // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead4720 -1 var tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');-1 4798 var isArray = require('isarray'); 4721 47994722 -1 /*eslint-enable max-len*/-1 4800 /** -1 4801 * Module exports. -1 4802 */ 4723 48034724 -1 ////////////////////////////////////////////////////////////////////////////////-1 4804 module.exports = hasBinary; 4725 48054726 -1 function resetScanCache(self) {4727 -1 self.__index__ = -1;4728 -1 self.__text_cache__ = '';4729 -1 }4730 -14731 -1 function createValidator(re) {4732 -1 return function (text, pos) {4733 -1 var tail = text.slice(pos);4734 -14735 -1 if (re.test(tail)) {4736 -1 return tail.match(re)[0].length;4737 -1 }4738 -1 return 0;4739 -1 };4740 -1 }-1 4806 /** -1 4807 * Checks for binary data. -1 4808 * -1 4809 * Right now only Buffer and ArrayBuffer are supported.. -1 4810 * -1 4811 * @param {Object} anything -1 4812 * @api public -1 4813 */ 4741 48144742 -1 function createNormalizer() {4743 -1 return function (match, self) {4744 -1 self.normalize(match);4745 -1 };4746 -1 }-1 4815 function hasBinary(data) { 4747 48164748 -1 // Schemas compiler. Build regexps.4749 -1 //4750 -1 function compile(self) {-1 4817 function _hasBinary(obj) { -1 4818 if (!obj) return false; 4751 48194752 -1 // Load & clone RE patterns.4753 -1 var re = self.re = require('./lib/re')(self.__opts__);-1 4820 if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) || -1 4821 (global.ArrayBuffer && obj instanceof ArrayBuffer) || -1 4822 (global.Blob && obj instanceof Blob) || -1 4823 (global.File && obj instanceof File) -1 4824 ) { -1 4825 return true; -1 4826 } 4754 48274755 -1 // Define dynamic patterns4756 -1 var tlds = self.__tlds__.slice();-1 4828 if (isArray(obj)) { -1 4829 for (var i = 0; i < obj.length; i++) { -1 4830 if (_hasBinary(obj[i])) { -1 4831 return true; -1 4832 } -1 4833 } -1 4834 } else if (obj && 'object' == typeof obj) { -1 4835 // see: https://github.com/Automattic/has-binary/pull/4 -1 4836 if (obj.toJSON && 'function' == typeof obj.toJSON) { -1 4837 obj = obj.toJSON(); -1 4838 } 4757 48394758 -1 self.onCompile();-1 4840 for (var key in obj) { -1 4841 if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) { -1 4842 return true; -1 4843 } -1 4844 } -1 4845 } 4759 48464760 -1 if (!self.__tlds_replaced__) {4761 -1 tlds.push(tlds_2ch_src_re);-1 4847 return false; 4762 4848 }4763 -1 tlds.push(re.src_xn);4764 48494765 -1 re.src_tlds = tlds.join('|');-1 4850 return _hasBinary(data); -1 4851 } 4766 48524767 -1 function untpl(tpl) { return tpl.replace('%TLDS%', re.src_tlds); }-1 4853 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 4854 },{"isarray":32}],30:[function(require,module,exports){ 4768 48554769 -1 re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');4770 -1 re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');4771 -1 re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');4772 -1 re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');-1 4856 /** -1 4857 * Module exports. -1 4858 * -1 4859 * Logic borrowed from Modernizr: -1 4860 * -1 4861 * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js -1 4862 */ 4773 48634774 -1 //4775 -1 // Compile each schema4776 -1 //-1 4864 try { -1 4865 module.exports = typeof XMLHttpRequest !== 'undefined' && -1 4866 'withCredentials' in new XMLHttpRequest(); -1 4867 } catch (err) { -1 4868 // if XMLHttp support is disabled in IE then it will throw -1 4869 // when trying to create -1 4870 module.exports = false; -1 4871 } 4777 48724778 -1 var aliases = [];-1 4873 },{}],31:[function(require,module,exports){ 4779 48744780 -1 self.__compiled__ = {}; // Reset compiled data-1 4875 var indexOf = [].indexOf; 4781 48764782 -1 function schemaError(name, val) {4783 -1 throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);-1 4877 module.exports = function(arr, obj){ -1 4878 if (indexOf) return arr.indexOf(obj); -1 4879 for (var i = 0; i < arr.length; ++i) { -1 4880 if (arr[i] === obj) return i; 4784 4881 } -1 4882 return -1; -1 4883 }; -1 4884 },{}],32:[function(require,module,exports){ -1 4885 module.exports = Array.isArray || function (arr) { -1 4886 return Object.prototype.toString.call(arr) == '[object Array]'; -1 4887 }; 4785 48884786 -1 Object.keys(self.__schemas__).forEach(function (name) {4787 -1 var val = self.__schemas__[name];4788 -14789 -1 // skip disabled methods4790 -1 if (val === null) { return; }4791 -14792 -1 var compiled = { validate: null, link: null };4793 -14794 -1 self.__compiled__[name] = compiled;-1 4889 },{}],33:[function(require,module,exports){ -1 4890 (function (global){ -1 4891 /*! JSON v3.3.2 | http://bestiejs.github.io/json3 | Copyright 2012-2014, Kit Cambridge | http://kit.mit-license.org */ -1 4892 ;(function () { -1 4893 // Detect the `define` function exposed by asynchronous module loaders. The -1 4894 // strict `define` check is necessary for compatibility with `r.js`. -1 4895 var isLoader = typeof define === "function" && define.amd; 4795 48964796 -1 if (isObject(val)) {4797 -1 if (isRegExp(val.validate)) {4798 -1 compiled.validate = createValidator(val.validate);4799 -1 } else if (isFunction(val.validate)) {4800 -1 compiled.validate = val.validate;4801 -1 } else {4802 -1 schemaError(name, val);4803 -1 }-1 4897 // A set of types used to distinguish objects from primitives. -1 4898 var objectTypes = { -1 4899 "function": true, -1 4900 "object": true -1 4901 }; 4804 49024805 -1 if (isFunction(val.normalize)) {4806 -1 compiled.normalize = val.normalize;4807 -1 } else if (!val.normalize) {4808 -1 compiled.normalize = createNormalizer();4809 -1 } else {4810 -1 schemaError(name, val);4811 -1 }-1 4903 // Detect the `exports` object exposed by CommonJS implementations. -1 4904 var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; 4812 49054813 -1 return;4814 -1 }-1 4906 // Use the `global` object exposed by Node (including Browserify via -1 4907 // `insert-module-globals`), Narwhal, and Ringo as the default context, -1 4908 // and the `window` object in browsers. Rhino exports a `global` function -1 4909 // instead. -1 4910 var root = objectTypes[typeof window] && window || this, -1 4911 freeGlobal = freeExports && objectTypes[typeof module] && module && !module.nodeType && typeof global == "object" && global; 4815 49124816 -1 if (isString(val)) {4817 -1 aliases.push(name);4818 -1 return;4819 -1 }-1 4913 if (freeGlobal && (freeGlobal["global"] === freeGlobal || freeGlobal["window"] === freeGlobal || freeGlobal["self"] === freeGlobal)) { -1 4914 root = freeGlobal; -1 4915 } 4820 49164821 -1 schemaError(name, val);4822 -1 });-1 4917 // Public: Initializes JSON 3 using the given `context` object, attaching the -1 4918 // `stringify` and `parse` functions to the specified `exports` object. -1 4919 function runInContext(context, exports) { -1 4920 context || (context = root["Object"]()); -1 4921 exports || (exports = root["Object"]()); 4823 49224824 -1 //4825 -1 // Compile postponed aliases4826 -1 //-1 4923 // Native constructor aliases. -1 4924 var Number = context["Number"] || root["Number"], -1 4925 String = context["String"] || root["String"], -1 4926 Object = context["Object"] || root["Object"], -1 4927 Date = context["Date"] || root["Date"], -1 4928 SyntaxError = context["SyntaxError"] || root["SyntaxError"], -1 4929 TypeError = context["TypeError"] || root["TypeError"], -1 4930 Math = context["Math"] || root["Math"], -1 4931 nativeJSON = context["JSON"] || root["JSON"]; 4827 49324828 -1 aliases.forEach(function (alias) {4829 -1 if (!self.__compiled__[self.__schemas__[alias]]) {4830 -1 // Silently fail on missed schemas to avoid errons on disable.4831 -1 // schemaError(alias, self.__schemas__[alias]);4832 -1 return;-1 4933 // Delegate to the native `stringify` and `parse` implementations. -1 4934 if (typeof nativeJSON == "object" && nativeJSON) { -1 4935 exports.stringify = nativeJSON.stringify; -1 4936 exports.parse = nativeJSON.parse; 4833 4937 } 4834 49384835 -1 self.__compiled__[alias].validate =4836 -1 self.__compiled__[self.__schemas__[alias]].validate;4837 -1 self.__compiled__[alias].normalize =4838 -1 self.__compiled__[self.__schemas__[alias]].normalize;4839 -1 });4840 -14841 -1 //4842 -1 // Fake record for guessed links4843 -1 //4844 -1 self.__compiled__[''] = { validate: null, normalize: createNormalizer() };4845 -14846 -1 //4847 -1 // Build schema condition4848 -1 //4849 -1 var slist = Object.keys(self.__compiled__)4850 -1 .filter(function (name) {4851 -1 // Filter disabled & fake schemas4852 -1 return name.length > 0 && self.__compiled__[name];4853 -1 })4854 -1 .map(escapeRE)4855 -1 .join('|');4856 -1 // (?!_) cause 1.5x slowdown4857 -1 self.re.schema_test = RegExp('(^|(?!_)(?:[><]|' + re.src_ZPCc + '))(' + slist + ')', 'i');4858 -1 self.re.schema_search = RegExp('(^|(?!_)(?:[><]|' + re.src_ZPCc + '))(' + slist + ')', 'ig');4859 -14860 -1 self.re.pretest = RegExp(4861 -1 '(' + self.re.schema_test.source + ')|' +4862 -1 '(' + self.re.host_fuzzy_test.source + ')|' +4863 -1 '@',4864 -1 'i');4865 -14866 -1 //4867 -1 // Cleanup4868 -1 //4869 -14870 -1 resetScanCache(self);4871 -1 }-1 4939 // Convenience aliases. -1 4940 var objectProto = Object.prototype, -1 4941 getClass = objectProto.toString, -1 4942 isProperty, forEach, undef; 4872 49434873 -1 /**4874 -1 * class Match4875 -1 *4876 -1 * Match result. Single element of array, returned by [[LinkifyIt#match]]4877 -1 **/4878 -1 function Match(self, shift) {4879 -1 var start = self.__index__,4880 -1 end = self.__last_index__,4881 -1 text = self.__text_cache__.slice(start, end);-1 4944 // Test the `Date#getUTC*` methods. Based on work by @Yaffle. -1 4945 var isExtended = new Date(-3509827334573292); -1 4946 try { -1 4947 // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical -1 4948 // results for certain dates in Opera >= 10.53. -1 4949 isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 && -1 4950 // Safari < 2.0.2 stores the internal millisecond time value correctly, -1 4951 // but clips the values returned by the date methods to the range of -1 4952 // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]). -1 4953 isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708; -1 4954 } catch (exception) {} 4882 49554883 -1 /**4884 -1 * Match#schema -> String4885 -1 *4886 -1 * Prefix (protocol) for matched string.4887 -1 **/4888 -1 this.schema = self.__schema__.toLowerCase();4889 -1 /**4890 -1 * Match#index -> Number4891 -1 *4892 -1 * First position of matched string.4893 -1 **/4894 -1 this.index = start + shift;4895 -1 /**4896 -1 * Match#lastIndex -> Number4897 -1 *4898 -1 * Next position after matched string.4899 -1 **/4900 -1 this.lastIndex = end + shift;4901 -1 /**4902 -1 * Match#raw -> String4903 -1 *4904 -1 * Matched string.4905 -1 **/4906 -1 this.raw = text;4907 -1 /**4908 -1 * Match#text -> String4909 -1 *4910 -1 * Notmalized text of matched string.4911 -1 **/4912 -1 this.text = text;4913 -1 /**4914 -1 * Match#url -> String4915 -1 *4916 -1 * Normalized url of matched string.4917 -1 **/4918 -1 this.url = text;4919 -1 }-1 4956 // Internal: Determines whether the native `JSON.stringify` and `parse` -1 4957 // implementations are spec-compliant. Based on work by Ken Snyder. -1 4958 function has(name) { -1 4959 if (has[name] !== undef) { -1 4960 // Return cached feature test result. -1 4961 return has[name]; -1 4962 } -1 4963 var isSupported; -1 4964 if (name == "bug-string-char-index") { -1 4965 // IE <= 7 doesn't support accessing string characters using square -1 4966 // bracket notation. IE 8 only supports this for primitives. -1 4967 isSupported = "a"[0] != "a"; -1 4968 } else if (name == "json") { -1 4969 // Indicates whether both `JSON.stringify` and `JSON.parse` are -1 4970 // supported. -1 4971 isSupported = has("json-stringify") && has("json-parse"); -1 4972 } else { -1 4973 var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'; -1 4974 // Test `JSON.stringify`. -1 4975 if (name == "json-stringify") { -1 4976 var stringify = exports.stringify, stringifySupported = typeof stringify == "function" && isExtended; -1 4977 if (stringifySupported) { -1 4978 // A test function object with a custom `toJSON` method. -1 4979 (value = function () { -1 4980 return 1; -1 4981 }).toJSON = value; -1 4982 try { -1 4983 stringifySupported = -1 4984 // Firefox 3.1b1 and b2 serialize string, number, and boolean -1 4985 // primitives as object literals. -1 4986 stringify(0) === "0" && -1 4987 // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object -1 4988 // literals. -1 4989 stringify(new Number()) === "0" && -1 4990 stringify(new String()) == '""' && -1 4991 // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or -1 4992 // does not define a canonical JSON representation (this applies to -1 4993 // objects with `toJSON` properties as well, *unless* they are nested -1 4994 // within an object or array). -1 4995 stringify(getClass) === undef && -1 4996 // IE 8 serializes `undefined` as `"undefined"`. Safari <= 5.1.7 and -1 4997 // FF 3.1b3 pass this test. -1 4998 stringify(undef) === undef && -1 4999 // Safari <= 5.1.7 and FF 3.1b3 throw `Error`s and `TypeError`s, -1 5000 // respectively, if the value is omitted entirely. -1 5001 stringify() === undef && -1 5002 // FF 3.1b1, 2 throw an error if the given value is not a number, -1 5003 // string, array, object, Boolean, or `null` literal. This applies to -1 5004 // objects with custom `toJSON` methods as well, unless they are nested -1 5005 // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON` -1 5006 // methods entirely. -1 5007 stringify(value) === "1" && -1 5008 stringify([value]) == "[1]" && -1 5009 // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of -1 5010 // `"[null]"`. -1 5011 stringify([undef]) == "[null]" && -1 5012 // YUI 3.0.0b1 fails to serialize `null` literals. -1 5013 stringify(null) == "null" && -1 5014 // FF 3.1b1, 2 halts serialization if an array contains a function: -1 5015 // `[1, true, getClass, 1]` serializes as "[1,true,],". FF 3.1b3 -1 5016 // elides non-JSON values from objects and arrays, unless they -1 5017 // define custom `toJSON` methods. -1 5018 stringify([undef, getClass, null]) == "[null,null,null]" && -1 5019 // Simple serialization test. FF 3.1b1 uses Unicode escape sequences -1 5020 // where character escape codes are expected (e.g., `\b` => `\u0008`). -1 5021 stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized && -1 5022 // FF 3.1b1 and b2 ignore the `filter` and `width` arguments. -1 5023 stringify(null, value) === "1" && -1 5024 stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" && -1 5025 // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly -1 5026 // serialize extended years. -1 5027 stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' && -1 5028 // The milliseconds are optional in ES 5, but required in 5.1. -1 5029 stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' && -1 5030 // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative -1 5031 // four-digit years instead of six-digit years. Credits: @Yaffle. -1 5032 stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' && -1 5033 // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond -1 5034 // values less than 1000. Credits: @Yaffle. -1 5035 stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"'; -1 5036 } catch (exception) { -1 5037 stringifySupported = false; -1 5038 } -1 5039 } -1 5040 isSupported = stringifySupported; -1 5041 } -1 5042 // Test `JSON.parse`. -1 5043 if (name == "json-parse") { -1 5044 var parse = exports.parse; -1 5045 if (typeof parse == "function") { -1 5046 try { -1 5047 // FF 3.1b1, b2 will throw an exception if a bare literal is provided. -1 5048 // Conforming implementations should also coerce the initial argument to -1 5049 // a string prior to parsing. -1 5050 if (parse("0") === 0 && !parse(false)) { -1 5051 // Simple parsing test. -1 5052 value = parse(serialized); -1 5053 var parseSupported = value["a"].length == 5 && value["a"][0] === 1; -1 5054 if (parseSupported) { -1 5055 try { -1 5056 // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings. -1 5057 parseSupported = !parse('"\t"'); -1 5058 } catch (exception) {} -1 5059 if (parseSupported) { -1 5060 try { -1 5061 // FF 4.0 and 4.0.1 allow leading `+` signs and leading -1 5062 // decimal points. FF 4.0, 4.0.1, and IE 9-10 also allow -1 5063 // certain octal literals. -1 5064 parseSupported = parse("01") !== 1; -1 5065 } catch (exception) {} -1 5066 } -1 5067 if (parseSupported) { -1 5068 try { -1 5069 // FF 4.0, 4.0.1, and Rhino 1.7R3-R4 allow trailing decimal -1 5070 // points. These environments, along with FF 3.1b1 and 2, -1 5071 // also allow trailing commas in JSON objects and arrays. -1 5072 parseSupported = parse("1.") !== 1; -1 5073 } catch (exception) {} -1 5074 } -1 5075 } -1 5076 } -1 5077 } catch (exception) { -1 5078 parseSupported = false; -1 5079 } -1 5080 } -1 5081 isSupported = parseSupported; -1 5082 } -1 5083 } -1 5084 return has[name] = !!isSupported; -1 5085 } 4920 50864921 -1 function createMatch(self, shift) {4922 -1 var match = new Match(self, shift);-1 5087 if (!has("json")) { -1 5088 // Common `[[Class]]` name aliases. -1 5089 var functionClass = "[object Function]", -1 5090 dateClass = "[object Date]", -1 5091 numberClass = "[object Number]", -1 5092 stringClass = "[object String]", -1 5093 arrayClass = "[object Array]", -1 5094 booleanClass = "[object Boolean]"; 4923 50954924 -1 self.__compiled__[match.schema].normalize(match, self);-1 5096 // Detect incomplete support for accessing string characters by index. -1 5097 var charIndexBuggy = has("bug-string-char-index"); 4925 50984926 -1 return match;4927 -1 }-1 5099 // Define additional utility methods if the `Date` methods are buggy. -1 5100 if (!isExtended) { -1 5101 var floor = Math.floor; -1 5102 // A mapping between the months of the year and the number of days between -1 5103 // January 1st and the first of the respective month. -1 5104 var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; -1 5105 // Internal: Calculates the number of days between the Unix epoch and the -1 5106 // first day of the given month. -1 5107 var getDay = function (year, month) { -1 5108 return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400); -1 5109 }; -1 5110 } 4928 5111 -1 5112 // Internal: Determines if a property is a direct property of the given -1 5113 // object. Delegates to the native `Object#hasOwnProperty` method. -1 5114 if (!(isProperty = objectProto.hasOwnProperty)) { -1 5115 isProperty = function (property) { -1 5116 var members = {}, constructor; -1 5117 if ((members.__proto__ = null, members.__proto__ = { -1 5118 // The *proto* property cannot be set multiple times in recent -1 5119 // versions of Firefox and SeaMonkey. -1 5120 "toString": 1 -1 5121 }, members).toString != getClass) { -1 5122 // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but -1 5123 // supports the mutable *proto* property. -1 5124 isProperty = function (property) { -1 5125 // Capture and break the object's prototype chain (see section 8.6.2 -1 5126 // of the ES 5.1 spec). The parenthesized expression prevents an -1 5127 // unsafe transformation by the Closure Compiler. -1 5128 var original = this.__proto__, result = property in (this.__proto__ = null, this); -1 5129 // Restore the original prototype chain. -1 5130 this.__proto__ = original; -1 5131 return result; -1 5132 }; -1 5133 } else { -1 5134 // Capture a reference to the top-level `Object` constructor. -1 5135 constructor = members.constructor; -1 5136 // Use the `constructor` property to simulate `Object#hasOwnProperty` in -1 5137 // other environments. -1 5138 isProperty = function (property) { -1 5139 var parent = (this.constructor || constructor).prototype; -1 5140 return property in this && !(property in parent && this[property] === parent[property]); -1 5141 }; -1 5142 } -1 5143 members = null; -1 5144 return isProperty.call(this, property); -1 5145 }; -1 5146 } 4929 51474930 -1 /**4931 -1 * class LinkifyIt4932 -1 **/-1 5148 // Internal: Normalizes the `for...in` iteration algorithm across -1 5149 // environments. Each enumerated key is yielded to a `callback` function. -1 5150 forEach = function (object, callback) { -1 5151 var size = 0, Properties, members, property; 4933 51524934 -1 /**4935 -1 * new LinkifyIt(schemas, options)4936 -1 * - schemas (Object): Optional. Additional schemas to validate (prefix/validator)4937 -1 * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }4938 -1 *4939 -1 * Creates new linkifier instance with optional additional schemas.4940 -1 * Can be called without `new` keyword for convenience.4941 -1 *4942 -1 * By default understands:4943 -1 *4944 -1 * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links4945 -1 * - "fuzzy" links and emails (example.com, foo@bar.com).4946 -1 *4947 -1 * `schemas` is an object, where each key/value describes protocol/rule:4948 -1 *4949 -1 * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`4950 -1 * for example). `linkify-it` makes shure that prefix is not preceeded with4951 -1 * alphanumeric char and symbols. Only whitespaces and punctuation allowed.4952 -1 * - __value__ - rule to check tail after link prefix4953 -1 * - _String_ - just alias to existing rule4954 -1 * - _Object_4955 -1 * - _validate_ - validator function (should return matched length on success),4956 -1 * or `RegExp`.4957 -1 * - _normalize_ - optional function to normalize text & url of matched result4958 -1 * (for example, for @twitter mentions).4959 -1 *4960 -1 * `options`:4961 -1 *4962 -1 * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.4963 -1 * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts4964 -1 * like version numbers. Default `false`.4965 -1 * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.4966 -1 *4967 -1 **/4968 -1 function LinkifyIt(schemas, options) {4969 -1 if (!(this instanceof LinkifyIt)) {4970 -1 return new LinkifyIt(schemas, options);4971 -1 }4972 -14973 -1 if (!options) {4974 -1 if (isOptionsObj(schemas)) {4975 -1 options = schemas;4976 -1 schemas = {};4977 -1 }4978 -1 }4979 -14980 -1 this.__opts__ = assign({}, defaultOptions, options);4981 -14982 -1 // Cache last tested result. Used to skip repeating steps on next `match` call.4983 -1 this.__index__ = -1;4984 -1 this.__last_index__ = -1; // Next scan position4985 -1 this.__schema__ = '';4986 -1 this.__text_cache__ = '';4987 -14988 -1 this.__schemas__ = assign({}, defaultSchemas, schemas);4989 -1 this.__compiled__ = {};4990 -14991 -1 this.__tlds__ = tlds_default;4992 -1 this.__tlds_replaced__ = false;4993 -14994 -1 this.re = {};4995 -14996 -1 compile(this);4997 -1 }4998 -14999 -15000 -1 /** chainable5001 -1 * LinkifyIt#add(schema, definition)5002 -1 * - schema (String): rule name (fixed pattern prefix)5003 -1 * - definition (String|RegExp|Object): schema definition5004 -1 *5005 -1 * Add new rule definition. See constructor description for details.5006 -1 **/5007 -1 LinkifyIt.prototype.add = function add(schema, definition) {5008 -1 this.__schemas__[schema] = definition;5009 -1 compile(this);5010 -1 return this;5011 -1 };5012 -15013 -15014 -1 /** chainable5015 -1 * LinkifyIt#set(options)5016 -1 * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }5017 -1 *5018 -1 * Set recognition options for links without schema.5019 -1 **/5020 -1 LinkifyIt.prototype.set = function set(options) {5021 -1 this.__opts__ = assign(this.__opts__, options);5022 -1 return this;5023 -1 };5024 -15025 -15026 -1 /**5027 -1 * LinkifyIt#test(text) -> Boolean5028 -1 *5029 -1 * Searches linkifiable pattern and returns `true` on success or `false` on fail.5030 -1 **/5031 -1 LinkifyIt.prototype.test = function test(text) {5032 -1 // Reset scan cache5033 -1 this.__text_cache__ = text;5034 -1 this.__index__ = -1;5035 -15036 -1 if (!text.length) { return false; }5037 -15038 -1 var m, ml, me, len, shift, next, re, tld_pos, at_pos;5039 -15040 -1 // try to scan for link with schema - that's the most simple rule5041 -1 if (this.re.schema_test.test(text)) {5042 -1 re = this.re.schema_search;5043 -1 re.lastIndex = 0;5044 -1 while ((m = re.exec(text)) !== null) {5045 -1 len = this.testSchemaAt(text, m[2], re.lastIndex);5046 -1 if (len) {5047 -1 this.__schema__ = m[2];5048 -1 this.__index__ = m.index + m[1].length;5049 -1 this.__last_index__ = m.index + m[0].length + len;5050 -1 break;5051 -1 }5052 -1 }5053 -1 }5054 -15055 -1 if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {5056 -1 // guess schemaless links5057 -1 tld_pos = text.search(this.re.host_fuzzy_test);5058 -1 if (tld_pos >= 0) {5059 -1 // if tld is located after found link - no need to check fuzzy pattern5060 -1 if (this.__index__ < 0 || tld_pos < this.__index__) {5061 -1 if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {5062 -15063 -1 shift = ml.index + ml[1].length;-1 5153 // Tests for bugs in the current environment's `for...in` algorithm. The -1 5154 // `valueOf` property inherits the non-enumerable flag from -1 5155 // `Object.prototype` in older versions of IE, Netscape, and Mozilla. -1 5156 (Properties = function () { -1 5157 this.valueOf = 0; -1 5158 }).prototype.valueOf = 0; 5064 51595065 -1 if (this.__index__ < 0 || shift < this.__index__) {5066 -1 this.__schema__ = '';5067 -1 this.__index__ = shift;5068 -1 this.__last_index__ = ml.index + ml[0].length;-1 5160 // Iterate over a new instance of the `Properties` class. -1 5161 members = new Properties(); -1 5162 for (property in members) { -1 5163 // Ignore all properties inherited from `Object.prototype`. -1 5164 if (isProperty.call(members, property)) { -1 5165 size++; 5069 5166 } 5070 5167 }5071 -1 }5072 -1 }5073 -1 }5074 -15075 -1 if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {5076 -1 // guess schemaless emails5077 -1 at_pos = text.indexOf('@');5078 -1 if (at_pos >= 0) {5079 -1 // We can't skip this check, because this cases are possible:5080 -1 // 192.168.1.1@gmail.com, my.in@example.com5081 -1 if ((me = text.match(this.re.email_fuzzy)) !== null) {5082 -15083 -1 shift = me.index + me[1].length;5084 -1 next = me.index + me[0].length;-1 5168 Properties = members = null; 5085 51695086 -1 if (this.__index__ < 0 || shift < this.__index__ ||5087 -1 (shift === this.__index__ && next > this.__last_index__)) {5088 -1 this.__schema__ = 'mailto:';5089 -1 this.__index__ = shift;5090 -1 this.__last_index__ = next;-1 5170 // Normalize the iteration algorithm. -1 5171 if (!size) { -1 5172 // A list of non-enumerable properties inherited from `Object.prototype`. -1 5173 members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"]; -1 5174 // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable -1 5175 // properties. -1 5176 forEach = function (object, callback) { -1 5177 var isFunction = getClass.call(object) == functionClass, property, length; -1 5178 var hasProperty = !isFunction && typeof object.constructor != "function" && objectTypes[typeof object.hasOwnProperty] && object.hasOwnProperty || isProperty; -1 5179 for (property in object) { -1 5180 // Gecko <= 1.0 enumerates the `prototype` property of functions under -1 5181 // certain conditions; IE does not. -1 5182 if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) { -1 5183 callback(property); -1 5184 } -1 5185 } -1 5186 // Manually invoke the callback for each non-enumerable property. -1 5187 for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property)); -1 5188 }; -1 5189 } else if (size == 2) { -1 5190 // Safari <= 2.0.4 enumerates shadowed properties twice. -1 5191 forEach = function (object, callback) { -1 5192 // Create a set of iterated properties. -1 5193 var members = {}, isFunction = getClass.call(object) == functionClass, property; -1 5194 for (property in object) { -1 5195 // Store each property name to prevent double enumeration. The -1 5196 // `prototype` property of functions is not enumerated due to cross- -1 5197 // environment inconsistencies. -1 5198 if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) { -1 5199 callback(property); -1 5200 } -1 5201 } -1 5202 }; -1 5203 } else { -1 5204 // No bugs detected; use the standard `for...in` algorithm. -1 5205 forEach = function (object, callback) { -1 5206 var isFunction = getClass.call(object) == functionClass, property, isConstructor; -1 5207 for (property in object) { -1 5208 if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) { -1 5209 callback(property); -1 5210 } -1 5211 } -1 5212 // Manually invoke the callback for the `constructor` property due to -1 5213 // cross-environment inconsistencies. -1 5214 if (isConstructor || isProperty.call(object, (property = "constructor"))) { -1 5215 callback(property); -1 5216 } -1 5217 }; 5091 5218 }5092 -1 }5093 -1 }5094 -1 }5095 -15096 -1 return this.__index__ >= 0;5097 -1 };-1 5219 return forEach(object, callback); -1 5220 }; 5098 5221 -1 5222 // Public: Serializes a JavaScript `value` as a JSON string. The optional -1 5223 // `filter` argument may specify either a function that alters how object and -1 5224 // array members are serialized, or an array of strings and numbers that -1 5225 // indicates which properties should be serialized. The optional `width` -1 5226 // argument may be either a string or number that specifies the indentation -1 5227 // level of the output. -1 5228 if (!has("json-stringify")) { -1 5229 // Internal: A map of control characters and their escaped equivalents. -1 5230 var Escapes = { -1 5231 92: "\\\\", -1 5232 34: '\\"', -1 5233 8: "\\b", -1 5234 12: "\\f", -1 5235 10: "\\n", -1 5236 13: "\\r", -1 5237 9: "\\t" -1 5238 }; 5099 52395100 -1 /**5101 -1 * LinkifyIt#pretest(text) -> Boolean5102 -1 *5103 -1 * Very quick check, that can give false positives. Returns true if link MAY BE5104 -1 * can exists. Can be used for speed optimization, when you need to check that5105 -1 * link NOT exists.5106 -1 **/5107 -1 LinkifyIt.prototype.pretest = function pretest(text) {5108 -1 return this.re.pretest.test(text);5109 -1 };-1 5240 // Internal: Converts `value` into a zero-padded string such that its -1 5241 // length is at least equal to `width`. The `width` must be <= 6. -1 5242 var leadingZeroes = "000000"; -1 5243 var toPaddedString = function (width, value) { -1 5244 // The `|| 0` expression is necessary to work around a bug in -1 5245 // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`. -1 5246 return (leadingZeroes + (value || 0)).slice(-width); -1 5247 }; 5110 5248 -1 5249 // Internal: Double-quotes a string `value`, replacing all ASCII control -1 5250 // characters (characters with code unit values between 0 and 31) with -1 5251 // their escaped equivalents. This is an implementation of the -1 5252 // `Quote(value)` operation defined in ES 5.1 section 15.12.3. -1 5253 var unicodePrefix = "\\u00"; -1 5254 var quote = function (value) { -1 5255 var result = '"', index = 0, length = value.length, useCharIndex = !charIndexBuggy || length > 10; -1 5256 var symbols = useCharIndex && (charIndexBuggy ? value.split("") : value); -1 5257 for (; index < length; index++) { -1 5258 var charCode = value.charCodeAt(index); -1 5259 // If the character is a control character, append its Unicode or -1 5260 // shorthand escape sequence; otherwise, append the character as-is. -1 5261 switch (charCode) { -1 5262 case 8: case 9: case 10: case 12: case 13: case 34: case 92: -1 5263 result += Escapes[charCode]; -1 5264 break; -1 5265 default: -1 5266 if (charCode < 32) { -1 5267 result += unicodePrefix + toPaddedString(2, charCode.toString(16)); -1 5268 break; -1 5269 } -1 5270 result += useCharIndex ? symbols[index] : value.charAt(index); -1 5271 } -1 5272 } -1 5273 return result + '"'; -1 5274 }; 5111 52755112 -1 /**5113 -1 * LinkifyIt#testSchemaAt(text, name, position) -> Number5114 -1 * - text (String): text to scan5115 -1 * - name (String): rule (schema) name5116 -1 * - position (Number): text offset to check from5117 -1 *5118 -1 * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly5119 -1 * at given position. Returns length of found pattern (0 on fail).5120 -1 **/5121 -1 LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {5122 -1 // If not supported schema check requested - terminate5123 -1 if (!this.__compiled__[schema.toLowerCase()]) {5124 -1 return 0;5125 -1 }5126 -1 return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);5127 -1 };5128 -15129 -15130 -1 /**5131 -1 * LinkifyIt#match(text) -> Array|null5132 -1 *5133 -1 * Returns array of found link descriptions or `null` on fail. We strongly5134 -1 * recommend to use [[LinkifyIt#test]] first, for best speed.5135 -1 *5136 -1 * ##### Result match description5137 -1 *5138 -1 * - __schema__ - link schema, can be empty for fuzzy links, or `//` for5139 -1 * protocol-neutral links.5140 -1 * - __index__ - offset of matched text5141 -1 * - __lastIndex__ - index of next char after mathch end5142 -1 * - __raw__ - matched text5143 -1 * - __text__ - normalized text5144 -1 * - __url__ - link, generated from matched text5145 -1 **/5146 -1 LinkifyIt.prototype.match = function match(text) {5147 -1 var shift = 0, result = [];5148 -15149 -1 // Try to take previous element from cache, if .test() called before5150 -1 if (this.__index__ >= 0 && this.__text_cache__ === text) {5151 -1 result.push(createMatch(this, shift));5152 -1 shift = this.__last_index__;5153 -1 }5154 -15155 -1 // Cut head if cache was used5156 -1 var tail = shift ? text.slice(shift) : text;5157 -15158 -1 // Scan string until end reached5159 -1 while (this.test(tail)) {5160 -1 result.push(createMatch(this, shift));-1 5276 // Internal: Recursively serializes an object. Implements the -1 5277 // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations. -1 5278 var serialize = function (property, object, callback, properties, whitespace, indentation, stack) { -1 5279 var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, result; -1 5280 try { -1 5281 // Necessary for host object support. -1 5282 value = object[property]; -1 5283 } catch (exception) {} -1 5284 if (typeof value == "object" && value) { -1 5285 className = getClass.call(value); -1 5286 if (className == dateClass && !isProperty.call(value, "toJSON")) { -1 5287 if (value > -1 / 0 && value < 1 / 0) { -1 5288 // Dates are serialized according to the `Date#toJSON` method -1 5289 // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15 -1 5290 // for the ISO 8601 date time string format. -1 5291 if (getDay) { -1 5292 // Manually compute the year, month, date, hours, minutes, -1 5293 // seconds, and milliseconds if the `getUTC*` methods are -1 5294 // buggy. Adapted from @Yaffle's `date-shim` project. -1 5295 date = floor(value / 864e5); -1 5296 for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++); -1 5297 for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++); -1 5298 date = 1 + date - getDay(year, month); -1 5299 // The `time` value specifies the time within the day (see ES -1 5300 // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used -1 5301 // to compute `A modulo B`, as the `%` operator does not -1 5302 // correspond to the `modulo` operation for negative numbers. -1 5303 time = (value % 864e5 + 864e5) % 864e5; -1 5304 // The hours, minutes, seconds, and milliseconds are obtained by -1 5305 // decomposing the time within the day. See section 15.9.1.10. -1 5306 hours = floor(time / 36e5) % 24; -1 5307 minutes = floor(time / 6e4) % 60; -1 5308 seconds = floor(time / 1e3) % 60; -1 5309 milliseconds = time % 1e3; -1 5310 } else { -1 5311 year = value.getUTCFullYear(); -1 5312 month = value.getUTCMonth(); -1 5313 date = value.getUTCDate(); -1 5314 hours = value.getUTCHours(); -1 5315 minutes = value.getUTCMinutes(); -1 5316 seconds = value.getUTCSeconds(); -1 5317 milliseconds = value.getUTCMilliseconds(); -1 5318 } -1 5319 // Serialize extended years correctly. -1 5320 value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) + -1 5321 "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) + -1 5322 // Months, dates, hours, minutes, and seconds should have two -1 5323 // digits; milliseconds should have three. -1 5324 "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) + -1 5325 // Milliseconds are optional in ES 5.0, but required in 5.1. -1 5326 "." + toPaddedString(3, milliseconds) + "Z"; -1 5327 } else { -1 5328 value = null; -1 5329 } -1 5330 } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) { -1 5331 // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the -1 5332 // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3 -1 5333 // ignores all `toJSON` methods on these objects unless they are -1 5334 // defined directly on an instance. -1 5335 value = value.toJSON(property); -1 5336 } -1 5337 } -1 5338 if (callback) { -1 5339 // If a replacement function was provided, call it to obtain the value -1 5340 // for serialization. -1 5341 value = callback.call(object, property, value); -1 5342 } -1 5343 if (value === null) { -1 5344 return "null"; -1 5345 } -1 5346 className = getClass.call(value); -1 5347 if (className == booleanClass) { -1 5348 // Booleans are represented literally. -1 5349 return "" + value; -1 5350 } else if (className == numberClass) { -1 5351 // JSON numbers must be finite. `Infinity` and `NaN` are serialized as -1 5352 // `"null"`. -1 5353 return value > -1 / 0 && value < 1 / 0 ? "" + value : "null"; -1 5354 } else if (className == stringClass) { -1 5355 // Strings are double-quoted and escaped. -1 5356 return quote("" + value); -1 5357 } -1 5358 // Recursively serialize objects and arrays. -1 5359 if (typeof value == "object") { -1 5360 // Check for cyclic structures. This is a linear search; performance -1 5361 // is inversely proportional to the number of unique nested objects. -1 5362 for (length = stack.length; length--;) { -1 5363 if (stack[length] === value) { -1 5364 // Cyclic structures cannot be serialized by `JSON.stringify`. -1 5365 throw TypeError(); -1 5366 } -1 5367 } -1 5368 // Add the object to the stack of traversed objects. -1 5369 stack.push(value); -1 5370 results = []; -1 5371 // Save the current indentation level and indent one additional level. -1 5372 prefix = indentation; -1 5373 indentation += whitespace; -1 5374 if (className == arrayClass) { -1 5375 // Recursively serialize array elements. -1 5376 for (index = 0, length = value.length; index < length; index++) { -1 5377 element = serialize(index, value, callback, properties, whitespace, indentation, stack); -1 5378 results.push(element === undef ? "null" : element); -1 5379 } -1 5380 result = results.length ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]"; -1 5381 } else { -1 5382 // Recursively serialize object members. Members are selected from -1 5383 // either a user-specified list of property names, or the object -1 5384 // itself. -1 5385 forEach(properties || value, function (property) { -1 5386 var element = serialize(property, value, callback, properties, whitespace, indentation, stack); -1 5387 if (element !== undef) { -1 5388 // According to ES 5.1 section 15.12.3: "If `gap` {whitespace} -1 5389 // is not the empty string, let `member` {quote(property) + ":"} -1 5390 // be the concatenation of `member` and the `space` character." -1 5391 // The "`space` character" refers to the literal space -1 5392 // character, not the `space` {width} argument provided to -1 5393 // `JSON.stringify`. -1 5394 results.push(quote(property) + ":" + (whitespace ? " " : "") + element); -1 5395 } -1 5396 }); -1 5397 result = results.length ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}"; -1 5398 } -1 5399 // Remove the object from the traversed object stack. -1 5400 stack.pop(); -1 5401 return result; -1 5402 } -1 5403 }; 5161 54045162 -1 tail = tail.slice(this.__last_index__);5163 -1 shift += this.__last_index__;5164 -1 }-1 5405 // Public: `JSON.stringify`. See ES 5.1 section 15.12.3. -1 5406 exports.stringify = function (source, filter, width) { -1 5407 var whitespace, callback, properties, className; -1 5408 if (objectTypes[typeof filter] && filter) { -1 5409 if ((className = getClass.call(filter)) == functionClass) { -1 5410 callback = filter; -1 5411 } else if (className == arrayClass) { -1 5412 // Convert the property names array into a makeshift set. -1 5413 properties = {}; -1 5414 for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((className = getClass.call(value)), className == stringClass || className == numberClass) && (properties[value] = 1)); -1 5415 } -1 5416 } -1 5417 if (width) { -1 5418 if ((className = getClass.call(width)) == numberClass) { -1 5419 // Convert the `width` to an integer and create a string containing -1 5420 // `width` number of space characters. -1 5421 if ((width -= width % 1) > 0) { -1 5422 for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " "); -1 5423 } -1 5424 } else if (className == stringClass) { -1 5425 whitespace = width.length <= 10 ? width : width.slice(0, 10); -1 5426 } -1 5427 } -1 5428 // Opera <= 7.54u2 discards the values associated with empty string keys -1 5429 // (`""`) only if they are used directly within an object member list -1 5430 // (e.g., `!("" in { "": 1})`). -1 5431 return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []); -1 5432 }; -1 5433 } 5165 54345166 -1 if (result.length) {5167 -1 return result;5168 -1 }-1 5435 // Public: Parses a JSON source string. -1 5436 if (!has("json-parse")) { -1 5437 var fromCharCode = String.fromCharCode; 5169 54385170 -1 return null;5171 -1 };-1 5439 // Internal: A map of escaped control characters and their unescaped -1 5440 // equivalents. -1 5441 var Unescapes = { -1 5442 92: "\\", -1 5443 34: '"', -1 5444 47: "/", -1 5445 98: "\b", -1 5446 116: "\t", -1 5447 110: "\n", -1 5448 102: "\f", -1 5449 114: "\r" -1 5450 }; 5172 5451 -1 5452 // Internal: Stores the parser state. -1 5453 var Index, Source; 5173 54545174 -1 /** chainable5175 -1 * LinkifyIt#tlds(list [, keepOld]) -> this5176 -1 * - list (Array): list of tlds5177 -1 * - keepOld (Boolean): merge with current list if `true` (`false` by default)5178 -1 *5179 -1 * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix)5180 -1 * to avoid false positives. By default this algorythm used:5181 -1 *5182 -1 * - hostname with any 2-letter root zones are ok.5183 -1 * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф5184 -1 * are ok.5185 -1 * - encoded (`xn--...`) root zones are ok.5186 -1 *5187 -1 * If list is replaced, then exact match for 2-chars root zones will be checked.5188 -1 **/5189 -1 LinkifyIt.prototype.tlds = function tlds(list, keepOld) {5190 -1 list = Array.isArray(list) ? list : [ list ];-1 5455 // Internal: Resets the parser state and throws a `SyntaxError`. -1 5456 var abort = function () { -1 5457 Index = Source = null; -1 5458 throw SyntaxError(); -1 5459 }; 5191 54605192 -1 if (!keepOld) {5193 -1 this.__tlds__ = list.slice();5194 -1 this.__tlds_replaced__ = true;5195 -1 compile(this);5196 -1 return this;5197 -1 }5198 -15199 -1 this.__tlds__ = this.__tlds__.concat(list)5200 -1 .sort()5201 -1 .filter(function (el, idx, arr) {5202 -1 return el !== arr[idx - 1];5203 -1 })5204 -1 .reverse();5205 -15206 -1 compile(this);5207 -1 return this;5208 -1 };5209 -15210 -1 /**5211 -1 * LinkifyIt#normalize(match)5212 -1 *5213 -1 * Default normalizer (if schema does not define it's own).5214 -1 **/5215 -1 LinkifyIt.prototype.normalize = function normalize(match) {5216 -15217 -1 // Do minimal possible changes by default. Need to collect feedback prior5218 -1 // to move forward https://github.com/markdown-it/linkify-it/issues/15219 -15220 -1 if (!match.schema) { match.url = 'http://' + match.url; }5221 -15222 -1 if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {5223 -1 match.url = 'mailto:' + match.url;5224 -1 }5225 -1 };5226 -15227 -15228 -1 /**5229 -1 * LinkifyIt#onCompile()5230 -1 *5231 -1 * Override to modify basic RegExp-s.5232 -1 **/5233 -1 LinkifyIt.prototype.onCompile = function onCompile() {5234 -1 };5235 -15236 -15237 -1 module.exports = LinkifyIt;5238 -15239 -1 },{"./lib/re":38}],38:[function(require,module,exports){5240 -1 'use strict';5241 -15242 -15243 -1 module.exports = function (opts) {5244 -1 var re = {};5245 -15246 -1 // Use direct extract instead of `regenerate` to reduse browserified size5247 -1 re.src_Any = require('uc.micro/properties/Any/regex').source;5248 -1 re.src_Cc = require('uc.micro/categories/Cc/regex').source;5249 -1 re.src_Z = require('uc.micro/categories/Z/regex').source;5250 -1 re.src_P = require('uc.micro/categories/P/regex').source;5251 -15252 -1 // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)5253 -1 re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join('|');5254 -15255 -1 // \p{\Z\Cc} (white spaces + control)5256 -1 re.src_ZCc = [ re.src_Z, re.src_Cc ].join('|');5257 -15258 -1 // All possible word characters (everything without punctuation, spaces & controls)5259 -1 // Defined via punctuation & spaces to save space5260 -1 // Should be something like \p{\L\N\S\M} (\w but without `_`)5261 -1 re.src_pseudo_letter = '(?:(?!>|<|' + re.src_ZPCc + ')' + re.src_Any + ')';5262 -1 // The same as abothe but without [0-9]5263 -1 // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';5264 -15265 -1 ////////////////////////////////////////////////////////////////////////////////5266 -15267 -1 re.src_ip4 =5268 -15269 -1 '(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';5270 -15271 -1 // Prohibit [@/] in user/pass to avoid wrong domain fetch.5272 -1 re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/]).)+@)?';5273 -15274 -1 re.src_port =5275 -15276 -1 '(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';5277 -15278 -1 re.src_host_terminator =5279 -15280 -1 '(?=$|>|<|' + re.src_ZPCc + ')(?!-|_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))';5281 -15282 -1 re.src_path =5283 -15284 -1 '(?:' +5285 -1 '[/?#]' +5286 -1 '(?:' +5287 -1 '(?!' + re.src_ZCc + '|[()[\\]{}.,"\'?!\\-<>]).|' +5288 -1 '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +5289 -1 '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +5290 -1 '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +5291 -1 '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +5292 -1 "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +5293 -1 "\\'(?=" + re.src_pseudo_letter + '|[-]).|' + // allow `I'm_king` if no pair found5294 -1 '\\.{2,3}[a-zA-Z0-9%/]|' + // github has ... in commit range links. Restrict to5295 -1 // - english5296 -1 // - percent-encoded5297 -1 // - parts of file path5298 -1 // until more examples found.5299 -1 '\\.(?!' + re.src_ZCc + '|[.]).|' +5300 -1 (opts && opts['---'] ?5301 -1 '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate5302 -1 :5303 -1 '\\-+|'5304 -1 ) +5305 -1 '\\,(?!' + re.src_ZCc + ').|' + // allow `,,,` in paths5306 -1 '\\!(?!' + re.src_ZCc + '|[!]).|' +5307 -1 '\\?(?!' + re.src_ZCc + '|[?]).' +5308 -1 ')+' +5309 -1 '|\\/' +5310 -1 ')?';5311 -15312 -1 re.src_email_name =5313 -15314 -1 '[\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]+';5315 -15316 -1 re.src_xn =5317 -15318 -1 'xn--[a-z0-9\\-]{1,59}';5319 -15320 -1 // More to read about domain names5321 -1 // http://serverfault.com/questions/638260/5322 -15323 -1 re.src_domain_root =5324 -15325 -1 // Allow letters & digits (http://test1)5326 -1 '(?:' +5327 -1 re.src_xn +5328 -1 '|' +5329 -1 re.src_pseudo_letter + '{1,63}' +5330 -1 ')';5331 -15332 -1 re.src_domain =5333 -15334 -1 '(?:' +5335 -1 re.src_xn +5336 -1 '|' +5337 -1 '(?:' + re.src_pseudo_letter + ')' +5338 -1 '|' +5339 -1 // don't allow `--` in domain names, because:5340 -1 // - that can conflict with markdown — / –5341 -1 // - nobody use those anyway5342 -1 '(?:' + re.src_pseudo_letter + '(?:-(?!-)|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +5343 -1 ')';5344 -15345 -1 re.src_host =5346 -15347 -1 '(?:' +5348 -1 // Don't need IP check, because digits are already allowed in normal domain names5349 -1 // src_ip4 +5350 -1 // '|' +5351 -1 '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain_root + ')' +5352 -1 ')';5353 -15354 -1 re.tpl_host_fuzzy =5355 -15356 -1 '(?:' +5357 -1 re.src_ip4 +5358 -1 '|' +5359 -1 '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +5360 -1 ')';5361 -15362 -1 re.tpl_host_no_ip_fuzzy =5363 -15364 -1 '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))';5365 -15366 -1 re.src_host_strict =5367 -15368 -1 re.src_host + re.src_host_terminator;5369 -15370 -1 re.tpl_host_fuzzy_strict =5371 -15372 -1 re.tpl_host_fuzzy + re.src_host_terminator;5373 -15374 -1 re.src_host_port_strict =5375 -15376 -1 re.src_host + re.src_port + re.src_host_terminator;5377 -15378 -1 re.tpl_host_port_fuzzy_strict =5379 -15380 -1 re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;5381 -15382 -1 re.tpl_host_port_no_ip_fuzzy_strict =5383 -15384 -1 re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;5385 -15386 -15387 -1 ////////////////////////////////////////////////////////////////////////////////5388 -1 // Main rules5389 -15390 -1 // Rude test fuzzy links by host, for quick deny5391 -1 re.tpl_host_fuzzy_test =5392 -15393 -1 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))';5394 -15395 -1 re.tpl_email_fuzzy =5396 -15397 -1 '(^|<|>|\\(|' + re.src_ZCc + ')(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')';5398 -15399 -1 re.tpl_link_fuzzy =5400 -1 // Fuzzy link can't be prepended with .:/\- and non punctuation.5401 -1 // but can start with > (markdown blockquote)5402 -1 '(^|(?![.:/\\-_@])(?:[$+<=>^`|]|' + re.src_ZPCc + '))' +5403 -1 '((?![$+<=>^`|])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')';5404 -15405 -1 re.tpl_link_no_ip_fuzzy =5406 -1 // Fuzzy link can't be prepended with .:/\- and non punctuation.5407 -1 // but can start with > (markdown blockquote)5408 -1 '(^|(?![.:/\\-_@])(?:[$+<=>^`|]|' + re.src_ZPCc + '))' +5409 -1 '((?![$+<=>^`|])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')';5410 -15411 -1 return re;5412 -1 };5413 -15414 -1 },{"uc.micro/categories/Cc/regex":111,"uc.micro/categories/P/regex":113,"uc.micro/categories/Z/regex":114,"uc.micro/properties/Any/regex":116}],39:[function(require,module,exports){5415 -1 'use strict';5416 -15417 -15418 -1 module.exports = require('./lib/');5419 -15420 -1 },{"./lib/":48}],40:[function(require,module,exports){5421 -1 // HTML5 entities map: { name -> utf16string }5422 -1 //5423 -1 'use strict';5424 -15425 -1 /*eslint quotes:0*/5426 -1 module.exports = require('entities/maps/entities.json');5427 -15428 -1 },{"entities/maps/entities.json":27}],41:[function(require,module,exports){5429 -1 // List of valid html blocks names, accorting to commonmark spec5430 -1 // http://jgm.github.io/CommonMark/spec.html#html-blocks5431 -15432 -1 'use strict';5433 -15434 -15435 -1 module.exports = [5436 -1 'address',5437 -1 'article',5438 -1 'aside',5439 -1 'base',5440 -1 'basefont',5441 -1 'blockquote',5442 -1 'body',5443 -1 'caption',5444 -1 'center',5445 -1 'col',5446 -1 'colgroup',5447 -1 'dd',5448 -1 'details',5449 -1 'dialog',5450 -1 'dir',5451 -1 'div',5452 -1 'dl',5453 -1 'dt',5454 -1 'fieldset',5455 -1 'figcaption',5456 -1 'figure',5457 -1 'footer',5458 -1 'form',5459 -1 'frame',5460 -1 'frameset',5461 -1 'h1',5462 -1 'head',5463 -1 'header',5464 -1 'hr',5465 -1 'html',5466 -1 'iframe',5467 -1 'legend',5468 -1 'li',5469 -1 'link',5470 -1 'main',5471 -1 'menu',5472 -1 'menuitem',5473 -1 'meta',5474 -1 'nav',5475 -1 'noframes',5476 -1 'ol',5477 -1 'optgroup',5478 -1 'option',5479 -1 'p',5480 -1 'param',5481 -1 'pre',5482 -1 'section',5483 -1 'source',5484 -1 'title',5485 -1 'summary',5486 -1 'table',5487 -1 'tbody',5488 -1 'td',5489 -1 'tfoot',5490 -1 'th',5491 -1 'thead',5492 -1 'title',5493 -1 'tr',5494 -1 'track',5495 -1 'ul'5496 -1 ];5497 -15498 -1 },{}],42:[function(require,module,exports){5499 -1 // Regexps to match html elements5500 -15501 -1 'use strict';5502 -15503 -1 var attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*';5504 -15505 -1 var unquoted = '[^"\'=<>`\\x00-\\x20]+';5506 -1 var single_quoted = "'[^']*'";5507 -1 var double_quoted = '"[^"]*"';5508 -15509 -1 var attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')';5510 -15511 -1 var attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)';5512 -15513 -1 var open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>';5514 -15515 -1 var close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>';5516 -1 var comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';5517 -1 var processing = '<[?].*?[?]>';5518 -1 var declaration = '<![A-Z]+\\s+[^>]*>';5519 -1 var cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';5520 -15521 -1 var HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +5522 -1 '|' + processing + '|' + declaration + '|' + cdata + ')');5523 -1 var HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')');5524 -15525 -1 module.exports.HTML_TAG_RE = HTML_TAG_RE;5526 -1 module.exports.HTML_OPEN_CLOSE_TAG_RE = HTML_OPEN_CLOSE_TAG_RE;5527 -15528 -1 },{}],43:[function(require,module,exports){5529 -1 // Utilities5530 -1 //5531 -1 'use strict';5532 -15533 -15534 -1 function _class(obj) { return Object.prototype.toString.call(obj); }5535 -15536 -1 function isString(obj) { return _class(obj) === '[object String]'; }5537 -15538 -1 var _hasOwnProperty = Object.prototype.hasOwnProperty;5539 -15540 -1 function has(object, key) {5541 -1 return _hasOwnProperty.call(object, key);5542 -1 }5543 -15544 -1 // Merge objects5545 -1 //5546 -1 function assign(obj /*from1, from2, from3, ...*/) {5547 -1 var sources = Array.prototype.slice.call(arguments, 1);5548 -15549 -1 sources.forEach(function (source) {5550 -1 if (!source) { return; }5551 -15552 -1 if (typeof source !== 'object') {5553 -1 throw new TypeError(source + 'must be object');5554 -1 }5555 -15556 -1 Object.keys(source).forEach(function (key) {5557 -1 obj[key] = source[key];5558 -1 });5559 -1 });5560 -15561 -1 return obj;5562 -1 }5563 -15564 -1 // Remove element from array and put another array at those position.5565 -1 // Useful for some operations with tokens5566 -1 function arrayReplaceAt(src, pos, newElements) {5567 -1 return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));5568 -1 }5569 -15570 -1 ////////////////////////////////////////////////////////////////////////////////5571 -15572 -1 function isValidEntityCode(c) {5573 -1 /*eslint no-bitwise:0*/5574 -1 // broken sequence5575 -1 if (c >= 0xD800 && c <= 0xDFFF) { return false; }5576 -1 // never used5577 -1 if (c >= 0xFDD0 && c <= 0xFDEF) { return false; }5578 -1 if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; }5579 -1 // control codes5580 -1 if (c >= 0x00 && c <= 0x08) { return false; }5581 -1 if (c === 0x0B) { return false; }5582 -1 if (c >= 0x0E && c <= 0x1F) { return false; }5583 -1 if (c >= 0x7F && c <= 0x9F) { return false; }5584 -1 // out of range5585 -1 if (c > 0x10FFFF) { return false; }5586 -1 return true;5587 -1 }5588 -15589 -1 function fromCodePoint(c) {5590 -1 /*eslint no-bitwise:0*/5591 -1 if (c > 0xffff) {5592 -1 c -= 0x10000;5593 -1 var surrogate1 = 0xd800 + (c >> 10),5594 -1 surrogate2 = 0xdc00 + (c & 0x3ff);5595 -15596 -1 return String.fromCharCode(surrogate1, surrogate2);5597 -1 }5598 -1 return String.fromCharCode(c);5599 -1 }5600 -15601 -15602 -1 var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g;5603 -1 var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;5604 -1 var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi');5605 -15606 -1 var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;5607 -15608 -1 var entities = require('./entities');5609 -15610 -1 function replaceEntityPattern(match, name) {5611 -1 var code = 0;5612 -15613 -1 if (has(entities, name)) {5614 -1 return entities[name];5615 -1 }5616 -15617 -1 if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {5618 -1 code = name[1].toLowerCase() === 'x' ?5619 -1 parseInt(name.slice(2), 16)5620 -1 :5621 -1 parseInt(name.slice(1), 10);5622 -1 if (isValidEntityCode(code)) {5623 -1 return fromCodePoint(code);5624 -1 }5625 -1 }5626 -15627 -1 return match;5628 -1 }5629 -15630 -1 /*function replaceEntities(str) {5631 -1 if (str.indexOf('&') < 0) { return str; }5632 -15633 -1 return str.replace(ENTITY_RE, replaceEntityPattern);5634 -1 }*/5635 -15636 -1 function unescapeMd(str) {5637 -1 if (str.indexOf('\\') < 0) { return str; }5638 -1 return str.replace(UNESCAPE_MD_RE, '$1');5639 -1 }5640 -15641 -1 function unescapeAll(str) {5642 -1 if (str.indexOf('\\') < 0 && str.indexOf('&') < 0) { return str; }5643 -15644 -1 return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) {5645 -1 if (escaped) { return escaped; }5646 -1 return replaceEntityPattern(match, entity);5647 -1 });5648 -1 }5649 -15650 -1 ////////////////////////////////////////////////////////////////////////////////5651 -15652 -1 var HTML_ESCAPE_TEST_RE = /[&<>"]/;5653 -1 var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;5654 -1 var HTML_REPLACEMENTS = {5655 -1 '&': '&',5656 -1 '<': '<',5657 -1 '>': '>',5658 -1 '"': '"'5659 -1 };5660 -15661 -1 function replaceUnsafeChar(ch) {5662 -1 return HTML_REPLACEMENTS[ch];5663 -1 }5664 -15665 -1 function escapeHtml(str) {5666 -1 if (HTML_ESCAPE_TEST_RE.test(str)) {5667 -1 return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);5668 -1 }5669 -1 return str;5670 -1 }5671 -15672 -1 ////////////////////////////////////////////////////////////////////////////////5673 -15674 -1 var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g;5675 -15676 -1 function escapeRE(str) {5677 -1 return str.replace(REGEXP_ESCAPE_RE, '\\$&');5678 -1 }5679 -15680 -1 ////////////////////////////////////////////////////////////////////////////////5681 -15682 -1 function isSpace(code) {5683 -1 switch (code) {5684 -1 case 0x09:5685 -1 case 0x20:5686 -1 return true;5687 -1 }5688 -1 return false;5689 -1 }5690 -15691 -1 // Zs (unicode class) || [\t\f\v\r\n]5692 -1 function isWhiteSpace(code) {5693 -1 if (code >= 0x2000 && code <= 0x200A) { return true; }5694 -1 switch (code) {5695 -1 case 0x09: // \t5696 -1 case 0x0A: // \n5697 -1 case 0x0B: // \v5698 -1 case 0x0C: // \f5699 -1 case 0x0D: // \r5700 -1 case 0x20:5701 -1 case 0xA0:5702 -1 case 0x1680:5703 -1 case 0x202F:5704 -1 case 0x205F:5705 -1 case 0x3000:5706 -1 return true;5707 -1 }5708 -1 return false;5709 -1 }5710 -15711 -1 ////////////////////////////////////////////////////////////////////////////////5712 -15713 -1 /*eslint-disable max-len*/5714 -1 var UNICODE_PUNCT_RE = require('uc.micro/categories/P/regex');5715 -15716 -1 // Currently without astral characters support.5717 -1 function isPunctChar(ch) {5718 -1 return UNICODE_PUNCT_RE.test(ch);5719 -1 }5720 -15721 -15722 -1 // Markdown ASCII punctuation characters.5723 -1 //5724 -1 // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~5725 -1 // http://spec.commonmark.org/0.15/#ascii-punctuation-character5726 -1 //5727 -1 // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.5728 -1 //5729 -1 function isMdAsciiPunct(ch) {5730 -1 switch (ch) {5731 -1 case 0x21/* ! */:5732 -1 case 0x22/* " */:5733 -1 case 0x23/* # */:5734 -1 case 0x24/* $ */:5735 -1 case 0x25/* % */:5736 -1 case 0x26/* & */:5737 -1 case 0x27/* ' */:5738 -1 case 0x28/* ( */:5739 -1 case 0x29/* ) */:5740 -1 case 0x2A/* * */:5741 -1 case 0x2B/* + */:5742 -1 case 0x2C/* , */:5743 -1 case 0x2D/* - */:5744 -1 case 0x2E/* . */:5745 -1 case 0x2F/* / */:5746 -1 case 0x3A/* : */:5747 -1 case 0x3B/* ; */:5748 -1 case 0x3C/* < */:5749 -1 case 0x3D/* = */:5750 -1 case 0x3E/* > */:5751 -1 case 0x3F/* ? */:5752 -1 case 0x40/* @ */:5753 -1 case 0x5B/* [ */:5754 -1 case 0x5C/* \ */:5755 -1 case 0x5D/* ] */:5756 -1 case 0x5E/* ^ */:5757 -1 case 0x5F/* _ */:5758 -1 case 0x60/* ` */:5759 -1 case 0x7B/* { */:5760 -1 case 0x7C/* | */:5761 -1 case 0x7D/* } */:5762 -1 case 0x7E/* ~ */:5763 -1 return true;5764 -1 default:5765 -1 return false;5766 -1 }5767 -1 }5768 -15769 -1 // Hepler to unify [reference labels].5770 -1 //5771 -1 function normalizeReference(str) {5772 -1 // use .toUpperCase() instead of .toLowerCase()5773 -1 // here to avoid a conflict with Object.prototype5774 -1 // members (most notably, `__proto__`)5775 -1 return str.trim().replace(/\s+/g, ' ').toUpperCase();5776 -1 }5777 -15778 -1 ////////////////////////////////////////////////////////////////////////////////5779 -15780 -1 // Re-export libraries commonly used in both markdown-it and its plugins,5781 -1 // so plugins won't have to depend on them explicitly, which reduces their5782 -1 // bundled size (e.g. a browser build).5783 -1 //5784 -1 exports.lib = {};5785 -1 exports.lib.mdurl = require('mdurl');5786 -1 exports.lib.ucmicro = require('uc.micro');5787 -15788 -1 exports.assign = assign;5789 -1 exports.isString = isString;5790 -1 exports.has = has;5791 -1 exports.unescapeMd = unescapeMd;5792 -1 exports.unescapeAll = unescapeAll;5793 -1 exports.isValidEntityCode = isValidEntityCode;5794 -1 exports.fromCodePoint = fromCodePoint;5795 -1 // exports.replaceEntities = replaceEntities;5796 -1 exports.escapeHtml = escapeHtml;5797 -1 exports.arrayReplaceAt = arrayReplaceAt;5798 -1 exports.isSpace = isSpace;5799 -1 exports.isWhiteSpace = isWhiteSpace;5800 -1 exports.isMdAsciiPunct = isMdAsciiPunct;5801 -1 exports.isPunctChar = isPunctChar;5802 -1 exports.escapeRE = escapeRE;5803 -1 exports.normalizeReference = normalizeReference;5804 -15805 -1 },{"./entities":40,"mdurl":94,"uc.micro":115,"uc.micro/categories/P/regex":113}],44:[function(require,module,exports){5806 -1 // Just a shortcut for bulk export5807 -1 'use strict';5808 -15809 -15810 -1 exports.parseLinkLabel = require('./parse_link_label');5811 -1 exports.parseLinkDestination = require('./parse_link_destination');5812 -1 exports.parseLinkTitle = require('./parse_link_title');5813 -15814 -1 },{"./parse_link_destination":45,"./parse_link_label":46,"./parse_link_title":47}],45:[function(require,module,exports){5815 -1 // Parse link destination5816 -1 //5817 -1 'use strict';5818 -15819 -15820 -1 var isSpace = require('../common/utils').isSpace;5821 -1 var unescapeAll = require('../common/utils').unescapeAll;5822 -15823 -15824 -1 module.exports = function parseLinkDestination(str, pos, max) {5825 -1 var code, level,5826 -1 lines = 0,5827 -1 start = pos,5828 -1 result = {5829 -1 ok: false,5830 -1 pos: 0,5831 -1 lines: 0,5832 -1 str: ''5833 -1 };5834 -15835 -1 if (str.charCodeAt(pos) === 0x3C /* < */) {5836 -1 pos++;5837 -1 while (pos < max) {5838 -1 code = str.charCodeAt(pos);5839 -1 if (code === 0x0A /* \n */ || isSpace(code)) { return result; }5840 -1 if (code === 0x3E /* > */) {5841 -1 result.pos = pos + 1;5842 -1 result.str = unescapeAll(str.slice(start + 1, pos));5843 -1 result.ok = true;5844 -1 return result;5845 -1 }5846 -1 if (code === 0x5C /* \ */ && pos + 1 < max) {5847 -1 pos += 2;5848 -1 continue;5849 -1 }5850 -15851 -1 pos++;5852 -1 }5853 -15854 -1 // no closing '>'5855 -1 return result;5856 -1 }5857 -15858 -1 // this should be ... } else { ... branch5859 -15860 -1 level = 0;5861 -1 while (pos < max) {5862 -1 code = str.charCodeAt(pos);5863 -15864 -1 if (code === 0x20) { break; }5865 -15866 -1 // ascii control characters5867 -1 if (code < 0x20 || code === 0x7F) { break; }5868 -15869 -1 if (code === 0x5C /* \ */ && pos + 1 < max) {5870 -1 pos += 2;5871 -1 continue;5872 -1 }5873 -15874 -1 if (code === 0x28 /* ( */) {5875 -1 level++;5876 -1 if (level > 1) { break; }5877 -1 }5878 -15879 -1 if (code === 0x29 /* ) */) {5880 -1 level--;5881 -1 if (level < 0) { break; }5882 -1 }5883 -15884 -1 pos++;5885 -1 }5886 -15887 -1 if (start === pos) { return result; }5888 -15889 -1 result.str = unescapeAll(str.slice(start, pos));5890 -1 result.lines = lines;5891 -1 result.pos = pos;5892 -1 result.ok = true;5893 -1 return result;5894 -1 };5895 -15896 -1 },{"../common/utils":43}],46:[function(require,module,exports){5897 -1 // Parse link label5898 -1 //5899 -1 // this function assumes that first character ("[") already matches;5900 -1 // returns the end of the label5901 -1 //5902 -1 'use strict';5903 -15904 -1 module.exports = function parseLinkLabel(state, start, disableNested) {5905 -1 var level, found, marker, prevPos,5906 -1 labelEnd = -1,5907 -1 max = state.posMax,5908 -1 oldPos = state.pos;5909 -15910 -1 state.pos = start + 1;5911 -1 level = 1;5912 -15913 -1 while (state.pos < max) {5914 -1 marker = state.src.charCodeAt(state.pos);5915 -1 if (marker === 0x5D /* ] */) {5916 -1 level--;5917 -1 if (level === 0) {5918 -1 found = true;5919 -1 break;5920 -1 }5921 -1 }5922 -15923 -1 prevPos = state.pos;5924 -1 state.md.inline.skipToken(state);5925 -1 if (marker === 0x5B /* [ */) {5926 -1 if (prevPos === state.pos - 1) {5927 -1 // increase level if we find text `[`, which is not a part of any token5928 -1 level++;5929 -1 } else if (disableNested) {5930 -1 state.pos = oldPos;5931 -1 return -1;5932 -1 }5933 -1 }5934 -1 }5935 -15936 -1 if (found) {5937 -1 labelEnd = state.pos;5938 -1 }5939 -15940 -1 // restore old state5941 -1 state.pos = oldPos;5942 -15943 -1 return labelEnd;5944 -1 };5945 -15946 -1 },{}],47:[function(require,module,exports){5947 -1 // Parse link title5948 -1 //5949 -1 'use strict';5950 -15951 -15952 -1 var unescapeAll = require('../common/utils').unescapeAll;5953 -15954 -15955 -1 module.exports = function parseLinkTitle(str, pos, max) {5956 -1 var code,5957 -1 marker,5958 -1 lines = 0,5959 -1 start = pos,5960 -1 result = {5961 -1 ok: false,5962 -1 pos: 0,5963 -1 lines: 0,5964 -1 str: ''5965 -1 };5966 -15967 -1 if (pos >= max) { return result; }5968 -15969 -1 marker = str.charCodeAt(pos);5970 -15971 -1 if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result; }5972 -15973 -1 pos++;5974 -15975 -1 // if opening marker is "(", switch it to closing marker ")"5976 -1 if (marker === 0x28) { marker = 0x29; }5977 -15978 -1 while (pos < max) {5979 -1 code = str.charCodeAt(pos);5980 -1 if (code === marker) {5981 -1 result.pos = pos + 1;5982 -1 result.lines = lines;5983 -1 result.str = unescapeAll(str.slice(start + 1, pos));5984 -1 result.ok = true;5985 -1 return result;5986 -1 } else if (code === 0x0A) {5987 -1 lines++;5988 -1 } else if (code === 0x5C /* \ */ && pos + 1 < max) {5989 -1 pos++;5990 -1 if (str.charCodeAt(pos) === 0x0A) {5991 -1 lines++;5992 -1 }5993 -1 }5994 -15995 -1 pos++;5996 -1 }5997 -15998 -1 return result;5999 -1 };6000 -16001 -1 },{"../common/utils":43}],48:[function(require,module,exports){6002 -1 // Main parser class6003 -16004 -1 'use strict';6005 -16006 -16007 -1 var utils = require('./common/utils');6008 -1 var helpers = require('./helpers');6009 -1 var Renderer = require('./renderer');6010 -1 var ParserCore = require('./parser_core');6011 -1 var ParserBlock = require('./parser_block');6012 -1 var ParserInline = require('./parser_inline');6013 -1 var LinkifyIt = require('linkify-it');6014 -1 var mdurl = require('mdurl');6015 -1 var punycode = require('punycode');6016 -16017 -16018 -1 var config = {6019 -1 'default': require('./presets/default'),6020 -1 zero: require('./presets/zero'),6021 -1 commonmark: require('./presets/commonmark')6022 -1 };6023 -16024 -1 ////////////////////////////////////////////////////////////////////////////////6025 -1 //6026 -1 // This validator can prohibit more than really needed to prevent XSS. It's a6027 -1 // tradeoff to keep code simple and to be secure by default.6028 -1 //6029 -1 // If you need different setup - override validator method as you wish. Or6030 -1 // replace it with dummy function and use external sanitizer.6031 -1 //6032 -16033 -1 var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;6034 -1 var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;6035 -16036 -1 function validateLink(url) {6037 -1 // url should be normalized at this point, and existing entities are decoded6038 -1 var str = url.trim().toLowerCase();6039 -16040 -1 return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true;6041 -1 }6042 -16043 -1 ////////////////////////////////////////////////////////////////////////////////6044 -16045 -16046 -1 var RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ];6047 -16048 -1 function normalizeLink(url) {6049 -1 var parsed = mdurl.parse(url, true);6050 -16051 -1 if (parsed.hostname) {6052 -1 // Encode hostnames in urls like:6053 -1 // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`6054 -1 //6055 -1 // We don't encode unknown schemas, because it's likely that we encode6056 -1 // something we shouldn't (e.g. `skype:name` treated as `skype:host`)6057 -1 //6058 -1 if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {6059 -1 try {6060 -1 parsed.hostname = punycode.toASCII(parsed.hostname);6061 -1 } catch (er) { /**/ }6062 -1 }6063 -1 }6064 -16065 -1 return mdurl.encode(mdurl.format(parsed));6066 -1 }6067 -16068 -1 function normalizeLinkText(url) {6069 -1 var parsed = mdurl.parse(url, true);6070 -16071 -1 if (parsed.hostname) {6072 -1 // Encode hostnames in urls like:6073 -1 // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`6074 -1 //6075 -1 // We don't encode unknown schemas, because it's likely that we encode6076 -1 // something we shouldn't (e.g. `skype:name` treated as `skype:host`)6077 -1 //6078 -1 if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {6079 -1 try {6080 -1 parsed.hostname = punycode.toUnicode(parsed.hostname);6081 -1 } catch (er) { /**/ }6082 -1 }6083 -1 }6084 -16085 -1 return mdurl.decode(mdurl.format(parsed));6086 -1 }6087 -16088 -16089 -1 /**6090 -1 * class MarkdownIt6091 -1 *6092 -1 * Main parser/renderer class.6093 -1 *6094 -1 * ##### Usage6095 -1 *6096 -1 * ```javascript6097 -1 * // node.js, "classic" way:6098 -1 * var MarkdownIt = require('markdown-it'),6099 -1 * md = new MarkdownIt();6100 -1 * var result = md.render('# markdown-it rulezz!');6101 -1 *6102 -1 * // node.js, the same, but with sugar:6103 -1 * var md = require('markdown-it')();6104 -1 * var result = md.render('# markdown-it rulezz!');6105 -1 *6106 -1 * // browser without AMD, added to "window" on script load6107 -1 * // Note, there are no dash.6108 -1 * var md = window.markdownit();6109 -1 * var result = md.render('# markdown-it rulezz!');6110 -1 * ```6111 -1 *6112 -1 * Single line rendering, without paragraph wrap:6113 -1 *6114 -1 * ```javascript6115 -1 * var md = require('markdown-it')();6116 -1 * var result = md.renderInline('__markdown-it__ rulezz!');6117 -1 * ```6118 -1 **/6119 -16120 -1 /**6121 -1 * new MarkdownIt([presetName, options])6122 -1 * - presetName (String): optional, `commonmark` / `zero`6123 -1 * - options (Object)6124 -1 *6125 -1 * Creates parser instanse with given config. Can be called without `new`.6126 -1 *6127 -1 * ##### presetName6128 -1 *6129 -1 * MarkdownIt provides named presets as a convenience to quickly6130 -1 * enable/disable active syntax rules and options for common use cases.6131 -1 *6132 -1 * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -6133 -1 * configures parser to strict [CommonMark](http://commonmark.org/) mode.6134 -1 * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -6135 -1 * similar to GFM, used when no preset name given. Enables all available rules,6136 -1 * but still without html, typographer & autolinker.6137 -1 * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -6138 -1 * all rules disabled. Useful to quickly setup your config via `.enable()`.6139 -1 * For example, when you need only `bold` and `italic` markup and nothing else.6140 -1 *6141 -1 * ##### options:6142 -1 *6143 -1 * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!6144 -1 * That's not safe! You may need external sanitizer to protect output from XSS.6145 -1 * It's better to extend features via plugins, instead of enabling HTML.6146 -1 * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags6147 -1 * (`<br />`). This is needed only for full CommonMark compatibility. In real6148 -1 * world you will need HTML output.6149 -1 * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`.6150 -1 * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.6151 -1 * Can be useful for external highlighters.6152 -1 * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.6153 -1 * - __typographer__ - `false`. Set `true` to enable [some language-neutral6154 -1 * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +6155 -1 * quotes beautification (smartquotes).6156 -1 * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement6157 -1 * pairs, when typographer enabled and smartquotes on. For example, you can6158 -1 * use `'«»„“'` for Russian, `'„“‚‘'` for German, and6159 -1 * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).6160 -1 * - __highlight__ - `null`. Highlighter function for fenced code blocks.6161 -1 * Highlighter `function (str, lang)` should return escaped HTML. It can also6162 -1 * return empty string if the source was not changed and should be escaped6163 -1 * externaly. If result starts with <pre... internal wrapper is skipped.6164 -1 *6165 -1 * ##### Example6166 -1 *6167 -1 * ```javascript6168 -1 * // commonmark mode6169 -1 * var md = require('markdown-it')('commonmark');6170 -1 *6171 -1 * // default mode6172 -1 * var md = require('markdown-it')();6173 -1 *6174 -1 * // enable everything6175 -1 * var md = require('markdown-it')({6176 -1 * html: true,6177 -1 * linkify: true,6178 -1 * typographer: true6179 -1 * });6180 -1 * ```6181 -1 *6182 -1 * ##### Syntax highlighting6183 -1 *6184 -1 * ```js6185 -1 * var hljs = require('highlight.js') // https://highlightjs.org/6186 -1 *6187 -1 * var md = require('markdown-it')({6188 -1 * highlight: function (str, lang) {6189 -1 * if (lang && hljs.getLanguage(lang)) {6190 -1 * try {6191 -1 * return hljs.highlight(lang, str, true).value;6192 -1 * } catch (__) {}6193 -1 * }6194 -1 *6195 -1 * return ''; // use external default escaping6196 -1 * }6197 -1 * });6198 -1 * ```6199 -1 *6200 -1 * Or with full wrapper override (if you need assign class to `<pre>`):6201 -1 *6202 -1 * ```javascript6203 -1 * var hljs = require('highlight.js') // https://highlightjs.org/6204 -1 *6205 -1 * // Actual default values6206 -1 * var md = require('markdown-it')({6207 -1 * highlight: function (str, lang) {6208 -1 * if (lang && hljs.getLanguage(lang)) {6209 -1 * try {6210 -1 * return '<pre class="hljs"><code>' +6211 -1 * hljs.highlight(lang, str, true).value +6212 -1 * '</code></pre>';6213 -1 * } catch (__) {}6214 -1 * }6215 -1 *6216 -1 * return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';6217 -1 * }6218 -1 * });6219 -1 * ```6220 -1 *6221 -1 **/6222 -1 function MarkdownIt(presetName, options) {6223 -1 if (!(this instanceof MarkdownIt)) {6224 -1 return new MarkdownIt(presetName, options);6225 -1 }6226 -16227 -1 if (!options) {6228 -1 if (!utils.isString(presetName)) {6229 -1 options = presetName || {};6230 -1 presetName = 'default';6231 -1 }6232 -1 }6233 -16234 -1 /**6235 -1 * MarkdownIt#inline -> ParserInline6236 -1 *6237 -1 * Instance of [[ParserInline]]. You may need it to add new rules when6238 -1 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and6239 -1 * [[MarkdownIt.enable]].6240 -1 **/6241 -1 this.inline = new ParserInline();6242 -16243 -1 /**6244 -1 * MarkdownIt#block -> ParserBlock6245 -1 *6246 -1 * Instance of [[ParserBlock]]. You may need it to add new rules when6247 -1 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and6248 -1 * [[MarkdownIt.enable]].6249 -1 **/6250 -1 this.block = new ParserBlock();6251 -16252 -1 /**6253 -1 * MarkdownIt#core -> Core6254 -1 *6255 -1 * Instance of [[Core]] chain executor. You may need it to add new rules when6256 -1 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and6257 -1 * [[MarkdownIt.enable]].6258 -1 **/6259 -1 this.core = new ParserCore();6260 -16261 -1 /**6262 -1 * MarkdownIt#renderer -> Renderer6263 -1 *6264 -1 * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering6265 -1 * rules for new token types, generated by plugins.6266 -1 *6267 -1 * ##### Example6268 -1 *6269 -1 * ```javascript6270 -1 * var md = require('markdown-it')();6271 -1 *6272 -1 * function myToken(tokens, idx, options, env, self) {6273 -1 * //...6274 -1 * return result;6275 -1 * };6276 -1 *6277 -1 * md.renderer.rules['my_token'] = myToken6278 -1 * ```6279 -1 *6280 -1 * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).6281 -1 **/6282 -1 this.renderer = new Renderer();6283 -16284 -1 /**6285 -1 * MarkdownIt#linkify -> LinkifyIt6286 -1 *6287 -1 * [linkify-it](https://github.com/markdown-it/linkify-it) instance.6288 -1 * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)6289 -1 * rule.6290 -1 **/6291 -1 this.linkify = new LinkifyIt();6292 -16293 -1 /**6294 -1 * MarkdownIt#validateLink(url) -> Boolean6295 -1 *6296 -1 * Link validation function. CommonMark allows too much in links. By default6297 -1 * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas6298 -1 * except some embedded image types.6299 -1 *6300 -1 * You can change this behaviour:6301 -1 *6302 -1 * ```javascript6303 -1 * var md = require('markdown-it')();6304 -1 * // enable everything6305 -1 * md.validateLink = function () { return true; }6306 -1 * ```6307 -1 **/6308 -1 this.validateLink = validateLink;6309 -16310 -1 /**6311 -1 * MarkdownIt#normalizeLink(url) -> String6312 -1 *6313 -1 * Function used to encode link url to a machine-readable format,6314 -1 * which includes url-encoding, punycode, etc.6315 -1 **/6316 -1 this.normalizeLink = normalizeLink;6317 -16318 -1 /**6319 -1 * MarkdownIt#normalizeLinkText(url) -> String6320 -1 *6321 -1 * Function used to decode link url to a human-readable format`6322 -1 **/6323 -1 this.normalizeLinkText = normalizeLinkText;6324 -16325 -16326 -1 // Expose utils & helpers for easy acces from plugins6327 -16328 -1 /**6329 -1 * MarkdownIt#utils -> utils6330 -1 *6331 -1 * Assorted utility functions, useful to write plugins. See details6332 -1 * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).6333 -1 **/6334 -1 this.utils = utils;6335 -16336 -1 /**6337 -1 * MarkdownIt#helpers -> helpers6338 -1 *6339 -1 * Link components parser functions, useful to write plugins. See details6340 -1 * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).6341 -1 **/6342 -1 this.helpers = helpers;6343 -16344 -16345 -1 this.options = {};6346 -1 this.configure(presetName);6347 -16348 -1 if (options) { this.set(options); }6349 -1 }6350 -16351 -16352 -1 /** chainable6353 -1 * MarkdownIt.set(options)6354 -1 *6355 -1 * Set parser options (in the same format as in constructor). Probably, you6356 -1 * will never need it, but you can change options after constructor call.6357 -1 *6358 -1 * ##### Example6359 -1 *6360 -1 * ```javascript6361 -1 * var md = require('markdown-it')()6362 -1 * .set({ html: true, breaks: true })6363 -1 * .set({ typographer, true });6364 -1 * ```6365 -1 *6366 -1 * __Note:__ To achieve the best possible performance, don't modify a6367 -1 * `markdown-it` instance options on the fly. If you need multiple configurations6368 -1 * it's best to create multiple instances and initialize each with separate6369 -1 * config.6370 -1 **/6371 -1 MarkdownIt.prototype.set = function (options) {6372 -1 utils.assign(this.options, options);6373 -1 return this;6374 -1 };6375 -16376 -16377 -1 /** chainable, internal6378 -1 * MarkdownIt.configure(presets)6379 -1 *6380 -1 * Batch load of all options and compenent settings. This is internal method,6381 -1 * and you probably will not need it. But if you with - see available presets6382 -1 * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)6383 -1 *6384 -1 * We strongly recommend to use presets instead of direct config loads. That6385 -1 * will give better compatibility with next versions.6386 -1 **/6387 -1 MarkdownIt.prototype.configure = function (presets) {6388 -1 var self = this, presetName;6389 -16390 -1 if (utils.isString(presets)) {6391 -1 presetName = presets;6392 -1 presets = config[presetName];6393 -1 if (!presets) { throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name'); }6394 -1 }6395 -16396 -1 if (!presets) { throw new Error('Wrong `markdown-it` preset, can\'t be empty'); }6397 -16398 -1 if (presets.options) { self.set(presets.options); }6399 -16400 -1 if (presets.components) {6401 -1 Object.keys(presets.components).forEach(function (name) {6402 -1 if (presets.components[name].rules) {6403 -1 self[name].ruler.enableOnly(presets.components[name].rules);6404 -1 }6405 -1 if (presets.components[name].rules2) {6406 -1 self[name].ruler2.enableOnly(presets.components[name].rules2);6407 -1 }6408 -1 });6409 -1 }6410 -1 return this;6411 -1 };6412 -16413 -16414 -1 /** chainable6415 -1 * MarkdownIt.enable(list, ignoreInvalid)6416 -1 * - list (String|Array): rule name or list of rule names to enable6417 -1 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.6418 -1 *6419 -1 * Enable list or rules. It will automatically find appropriate components,6420 -1 * containing rules with given names. If rule not found, and `ignoreInvalid`6421 -1 * not set - throws exception.6422 -1 *6423 -1 * ##### Example6424 -1 *6425 -1 * ```javascript6426 -1 * var md = require('markdown-it')()6427 -1 * .enable(['sub', 'sup'])6428 -1 * .disable('smartquotes');6429 -1 * ```6430 -1 **/6431 -1 MarkdownIt.prototype.enable = function (list, ignoreInvalid) {6432 -1 var result = [];6433 -16434 -1 if (!Array.isArray(list)) { list = [ list ]; }6435 -16436 -1 [ 'core', 'block', 'inline' ].forEach(function (chain) {6437 -1 result = result.concat(this[chain].ruler.enable(list, true));6438 -1 }, this);6439 -16440 -1 result = result.concat(this.inline.ruler2.enable(list, true));6441 -16442 -1 var missed = list.filter(function (name) { return result.indexOf(name) < 0; });6443 -16444 -1 if (missed.length && !ignoreInvalid) {6445 -1 throw new Error('MarkdownIt. Failed to enable unknown rule(s): ' + missed);6446 -1 }6447 -16448 -1 return this;6449 -1 };6450 -16451 -16452 -1 /** chainable6453 -1 * MarkdownIt.disable(list, ignoreInvalid)6454 -1 * - list (String|Array): rule name or list of rule names to disable.6455 -1 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.6456 -1 *6457 -1 * The same as [[MarkdownIt.enable]], but turn specified rules off.6458 -1 **/6459 -1 MarkdownIt.prototype.disable = function (list, ignoreInvalid) {6460 -1 var result = [];6461 -16462 -1 if (!Array.isArray(list)) { list = [ list ]; }6463 -16464 -1 [ 'core', 'block', 'inline' ].forEach(function (chain) {6465 -1 result = result.concat(this[chain].ruler.disable(list, true));6466 -1 }, this);6467 -16468 -1 result = result.concat(this.inline.ruler2.disable(list, true));6469 -16470 -1 var missed = list.filter(function (name) { return result.indexOf(name) < 0; });6471 -16472 -1 if (missed.length && !ignoreInvalid) {6473 -1 throw new Error('MarkdownIt. Failed to disable unknown rule(s): ' + missed);6474 -1 }6475 -1 return this;6476 -1 };6477 -16478 -16479 -1 /** chainable6480 -1 * MarkdownIt.use(plugin, params)6481 -1 *6482 -1 * Load specified plugin with given params into current parser instance.6483 -1 * It's just a sugar to call `plugin(md, params)` with curring.6484 -1 *6485 -1 * ##### Example6486 -1 *6487 -1 * ```javascript6488 -1 * var iterator = require('markdown-it-for-inline');6489 -1 * var md = require('markdown-it')()6490 -1 * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {6491 -1 * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');6492 -1 * });6493 -1 * ```6494 -1 **/6495 -1 MarkdownIt.prototype.use = function (plugin /*, params, ... */) {6496 -1 var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));6497 -1 plugin.apply(plugin, args);6498 -1 return this;6499 -1 };6500 -16501 -16502 -1 /** internal6503 -1 * MarkdownIt.parse(src, env) -> Array6504 -1 * - src (String): source string6505 -1 * - env (Object): environment sandbox6506 -1 *6507 -1 * Parse input string and returns list of block tokens (special token type6508 -1 * "inline" will contain list of inline tokens). You should not call this6509 -1 * method directly, until you write custom renderer (for example, to produce6510 -1 * AST).6511 -1 *6512 -1 * `env` is used to pass data between "distributed" rules and return additional6513 -1 * metadata like reference info, needed for the renderer. It also can be used to6514 -1 * inject data in specific cases. Usually, you will be ok to pass `{}`,6515 -1 * and then pass updated object to renderer.6516 -1 **/6517 -1 MarkdownIt.prototype.parse = function (src, env) {6518 -1 var state = new this.core.State(src, this, env);6519 -16520 -1 this.core.process(state);6521 -16522 -1 return state.tokens;6523 -1 };6524 -16525 -16526 -1 /**6527 -1 * MarkdownIt.render(src [, env]) -> String6528 -1 * - src (String): source string6529 -1 * - env (Object): environment sandbox6530 -1 *6531 -1 * Render markdown string into html. It does all magic for you :).6532 -1 *6533 -1 * `env` can be used to inject additional metadata (`{}` by default).6534 -1 * But you will not need it with high probability. See also comment6535 -1 * in [[MarkdownIt.parse]].6536 -1 **/6537 -1 MarkdownIt.prototype.render = function (src, env) {6538 -1 env = env || {};6539 -16540 -1 return this.renderer.render(this.parse(src, env), this.options, env);6541 -1 };6542 -16543 -16544 -1 /** internal6545 -1 * MarkdownIt.parseInline(src, env) -> Array6546 -1 * - src (String): source string6547 -1 * - env (Object): environment sandbox6548 -1 *6549 -1 * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the6550 -1 * block tokens list with the single `inline` element, containing parsed inline6551 -1 * tokens in `children` property. Also updates `env` object.6552 -1 **/6553 -1 MarkdownIt.prototype.parseInline = function (src, env) {6554 -1 var state = new this.core.State(src, this, env);6555 -16556 -1 state.inlineMode = true;6557 -1 this.core.process(state);6558 -16559 -1 return state.tokens;6560 -1 };6561 -16562 -16563 -1 /**6564 -1 * MarkdownIt.renderInline(src [, env]) -> String6565 -1 * - src (String): source string6566 -1 * - env (Object): environment sandbox6567 -1 *6568 -1 * Similar to [[MarkdownIt.render]] but for single paragraph content. Result6569 -1 * will NOT be wrapped into `<p>` tags.6570 -1 **/6571 -1 MarkdownIt.prototype.renderInline = function (src, env) {6572 -1 env = env || {};6573 -16574 -1 return this.renderer.render(this.parseInline(src, env), this.options, env);6575 -1 };6576 -16577 -16578 -1 module.exports = MarkdownIt;6579 -16580 -1 },{"./common/utils":43,"./helpers":44,"./parser_block":49,"./parser_core":50,"./parser_inline":51,"./presets/commonmark":52,"./presets/default":53,"./presets/zero":54,"./renderer":55,"linkify-it":37,"mdurl":94,"punycode":2}],49:[function(require,module,exports){6581 -1 /** internal6582 -1 * class ParserBlock6583 -1 *6584 -1 * Block-level tokenizer.6585 -1 **/6586 -1 'use strict';6587 -16588 -16589 -1 var Ruler = require('./ruler');-1 5461 // Internal: Returns the next token, or `"$"` if the parser has reached -1 5462 // the end of the source string. A token may be a string, number, `null` -1 5463 // literal, or Boolean literal. -1 5464 var lex = function () { -1 5465 var source = Source, length = source.length, value, begin, position, isSigned, charCode; -1 5466 while (Index < length) { -1 5467 charCode = source.charCodeAt(Index); -1 5468 switch (charCode) { -1 5469 case 9: case 10: case 13: case 32: -1 5470 // Skip whitespace tokens, including tabs, carriage returns, line -1 5471 // feeds, and space characters. -1 5472 Index++; -1 5473 break; -1 5474 case 123: case 125: case 91: case 93: case 58: case 44: -1 5475 // Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at -1 5476 // the current position. -1 5477 value = charIndexBuggy ? source.charAt(Index) : source[Index]; -1 5478 Index++; -1 5479 return value; -1 5480 case 34: -1 5481 // `"` delimits a JSON string; advance to the next character and -1 5482 // begin parsing the string. String tokens are prefixed with the -1 5483 // sentinel `@` character to distinguish them from punctuators and -1 5484 // end-of-string tokens. -1 5485 for (value = "@", Index++; Index < length;) { -1 5486 charCode = source.charCodeAt(Index); -1 5487 if (charCode < 32) { -1 5488 // Unescaped ASCII control characters (those with a code unit -1 5489 // less than the space character) are not permitted. -1 5490 abort(); -1 5491 } else if (charCode == 92) { -1 5492 // A reverse solidus (`\`) marks the beginning of an escaped -1 5493 // control character (including `"`, `\`, and `/`) or Unicode -1 5494 // escape sequence. -1 5495 charCode = source.charCodeAt(++Index); -1 5496 switch (charCode) { -1 5497 case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114: -1 5498 // Revive escaped control characters. -1 5499 value += Unescapes[charCode]; -1 5500 Index++; -1 5501 break; -1 5502 case 117: -1 5503 // `\u` marks the beginning of a Unicode escape sequence. -1 5504 // Advance to the first character and validate the -1 5505 // four-digit code point. -1 5506 begin = ++Index; -1 5507 for (position = Index + 4; Index < position; Index++) { -1 5508 charCode = source.charCodeAt(Index); -1 5509 // A valid sequence comprises four hexdigits (case- -1 5510 // insensitive) that form a single hexadecimal value. -1 5511 if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) { -1 5512 // Invalid Unicode escape sequence. -1 5513 abort(); -1 5514 } -1 5515 } -1 5516 // Revive the escaped character. -1 5517 value += fromCharCode("0x" + source.slice(begin, Index)); -1 5518 break; -1 5519 default: -1 5520 // Invalid escape sequence. -1 5521 abort(); -1 5522 } -1 5523 } else { -1 5524 if (charCode == 34) { -1 5525 // An unescaped double-quote character marks the end of the -1 5526 // string. -1 5527 break; -1 5528 } -1 5529 charCode = source.charCodeAt(Index); -1 5530 begin = Index; -1 5531 // Optimize for the common case where a string is valid. -1 5532 while (charCode >= 32 && charCode != 92 && charCode != 34) { -1 5533 charCode = source.charCodeAt(++Index); -1 5534 } -1 5535 // Append the string as-is. -1 5536 value += source.slice(begin, Index); -1 5537 } -1 5538 } -1 5539 if (source.charCodeAt(Index) == 34) { -1 5540 // Advance to the next character and return the revived string. -1 5541 Index++; -1 5542 return value; -1 5543 } -1 5544 // Unterminated string. -1 5545 abort(); -1 5546 default: -1 5547 // Parse numbers and literals. -1 5548 begin = Index; -1 5549 // Advance past the negative sign, if one is specified. -1 5550 if (charCode == 45) { -1 5551 isSigned = true; -1 5552 charCode = source.charCodeAt(++Index); -1 5553 } -1 5554 // Parse an integer or floating-point value. -1 5555 if (charCode >= 48 && charCode <= 57) { -1 5556 // Leading zeroes are interpreted as octal literals. -1 5557 if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) { -1 5558 // Illegal octal literal. -1 5559 abort(); -1 5560 } -1 5561 isSigned = false; -1 5562 // Parse the integer component. -1 5563 for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++); -1 5564 // Floats cannot contain a leading decimal point; however, this -1 5565 // case is already accounted for by the parser. -1 5566 if (source.charCodeAt(Index) == 46) { -1 5567 position = ++Index; -1 5568 // Parse the decimal component. -1 5569 for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++); -1 5570 if (position == Index) { -1 5571 // Illegal trailing decimal. -1 5572 abort(); -1 5573 } -1 5574 Index = position; -1 5575 } -1 5576 // Parse exponents. The `e` denoting the exponent is -1 5577 // case-insensitive. -1 5578 charCode = source.charCodeAt(Index); -1 5579 if (charCode == 101 || charCode == 69) { -1 5580 charCode = source.charCodeAt(++Index); -1 5581 // Skip past the sign following the exponent, if one is -1 5582 // specified. -1 5583 if (charCode == 43 || charCode == 45) { -1 5584 Index++; -1 5585 } -1 5586 // Parse the exponential component. -1 5587 for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++); -1 5588 if (position == Index) { -1 5589 // Illegal empty exponent. -1 5590 abort(); -1 5591 } -1 5592 Index = position; -1 5593 } -1 5594 // Coerce the parsed value to a JavaScript number. -1 5595 return +source.slice(begin, Index); -1 5596 } -1 5597 // A negative sign may only precede numbers. -1 5598 if (isSigned) { -1 5599 abort(); -1 5600 } -1 5601 // `true`, `false`, and `null` literals. -1 5602 if (source.slice(Index, Index + 4) == "true") { -1 5603 Index += 4; -1 5604 return true; -1 5605 } else if (source.slice(Index, Index + 5) == "false") { -1 5606 Index += 5; -1 5607 return false; -1 5608 } else if (source.slice(Index, Index + 4) == "null") { -1 5609 Index += 4; -1 5610 return null; -1 5611 } -1 5612 // Unrecognized token. -1 5613 abort(); -1 5614 } -1 5615 } -1 5616 // Return the sentinel `$` character if the parser has reached the end -1 5617 // of the source string. -1 5618 return "$"; -1 5619 }; 6590 5620 -1 5621 // Internal: Parses a JSON `value` token. -1 5622 var get = function (value) { -1 5623 var results, hasMembers; -1 5624 if (value == "$") { -1 5625 // Unexpected end of input. -1 5626 abort(); -1 5627 } -1 5628 if (typeof value == "string") { -1 5629 if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") { -1 5630 // Remove the sentinel `@` character. -1 5631 return value.slice(1); -1 5632 } -1 5633 // Parse object and array literals. -1 5634 if (value == "[") { -1 5635 // Parses a JSON array, returning a new JavaScript array. -1 5636 results = []; -1 5637 for (;; hasMembers || (hasMembers = true)) { -1 5638 value = lex(); -1 5639 // A closing square bracket marks the end of the array literal. -1 5640 if (value == "]") { -1 5641 break; -1 5642 } -1 5643 // If the array literal contains elements, the current token -1 5644 // should be a comma separating the previous element from the -1 5645 // next. -1 5646 if (hasMembers) { -1 5647 if (value == ",") { -1 5648 value = lex(); -1 5649 if (value == "]") { -1 5650 // Unexpected trailing `,` in array literal. -1 5651 abort(); -1 5652 } -1 5653 } else { -1 5654 // A `,` must separate each array element. -1 5655 abort(); -1 5656 } -1 5657 } -1 5658 // Elisions and leading commas are not permitted. -1 5659 if (value == ",") { -1 5660 abort(); -1 5661 } -1 5662 results.push(get(value)); -1 5663 } -1 5664 return results; -1 5665 } else if (value == "{") { -1 5666 // Parses a JSON object, returning a new JavaScript object. -1 5667 results = {}; -1 5668 for (;; hasMembers || (hasMembers = true)) { -1 5669 value = lex(); -1 5670 // A closing curly brace marks the end of the object literal. -1 5671 if (value == "}") { -1 5672 break; -1 5673 } -1 5674 // If the object literal contains members, the current token -1 5675 // should be a comma separator. -1 5676 if (hasMembers) { -1 5677 if (value == ",") { -1 5678 value = lex(); -1 5679 if (value == "}") { -1 5680 // Unexpected trailing `,` in object literal. -1 5681 abort(); -1 5682 } -1 5683 } else { -1 5684 // A `,` must separate each object member. -1 5685 abort(); -1 5686 } -1 5687 } -1 5688 // Leading commas are not permitted, object property names must be -1 5689 // double-quoted strings, and a `:` must separate each property -1 5690 // name and value. -1 5691 if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") { -1 5692 abort(); -1 5693 } -1 5694 results[value.slice(1)] = get(lex()); -1 5695 } -1 5696 return results; -1 5697 } -1 5698 // Unexpected token encountered. -1 5699 abort(); -1 5700 } -1 5701 return value; -1 5702 }; 6591 57036592 -1 var _rules = [6593 -1 // First 2 params - rule name & source. Secondary array - list of rules,6594 -1 // which can be terminated by this one.6595 -1 [ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],6596 -1 [ 'code', require('./rules_block/code') ],6597 -1 [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],6598 -1 [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'list' ] ],6599 -1 [ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],6600 -1 [ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ],6601 -1 [ 'reference', require('./rules_block/reference') ],6602 -1 [ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ],6603 -1 [ 'lheading', require('./rules_block/lheading') ],6604 -1 [ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ],6605 -1 [ 'paragraph', require('./rules_block/paragraph') ]6606 -1 ];-1 5704 // Internal: Updates a traversed object member. -1 5705 var update = function (source, property, callback) { -1 5706 var element = walk(source, property, callback); -1 5707 if (element === undef) { -1 5708 delete source[property]; -1 5709 } else { -1 5710 source[property] = element; -1 5711 } -1 5712 }; 6607 5713 -1 5714 // Internal: Recursively traverses a parsed JSON object, invoking the -1 5715 // `callback` function for each value. This is an implementation of the -1 5716 // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2. -1 5717 var walk = function (source, property, callback) { -1 5718 var value = source[property], length; -1 5719 if (typeof value == "object" && value) { -1 5720 // `forEach` can't be used to traverse an array in Opera <= 8.54 -1 5721 // because its `Object#hasOwnProperty` implementation returns `false` -1 5722 // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`). -1 5723 if (getClass.call(value) == arrayClass) { -1 5724 for (length = value.length; length--;) { -1 5725 update(value, length, callback); -1 5726 } -1 5727 } else { -1 5728 forEach(value, function (property) { -1 5729 update(value, property, callback); -1 5730 }); -1 5731 } -1 5732 } -1 5733 return callback.call(source, property, value); -1 5734 }; 6608 57356609 -1 /**6610 -1 * new ParserBlock()6611 -1 **/6612 -1 function ParserBlock() {6613 -1 /**6614 -1 * ParserBlock#ruler -> Ruler6615 -1 *6616 -1 * [[Ruler]] instance. Keep configuration of block rules.6617 -1 **/6618 -1 this.ruler = new Ruler();-1 5736 // Public: `JSON.parse`. See ES 5.1 section 15.12.2. -1 5737 exports.parse = function (source, callback) { -1 5738 var result, value; -1 5739 Index = 0; -1 5740 Source = "" + source; -1 5741 result = get(lex()); -1 5742 // If a JSON string contains multiple tokens, it is invalid. -1 5743 if (lex() != "$") { -1 5744 abort(); -1 5745 } -1 5746 // Reset the parser state. -1 5747 Index = Source = null; -1 5748 return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result; -1 5749 }; -1 5750 } -1 5751 } 6619 57526620 -1 for (var i = 0; i < _rules.length; i++) {6621 -1 this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() });-1 5753 exports["runInContext"] = runInContext; -1 5754 return exports; 6622 5755 }6623 -1 }6624 5756 -1 5757 if (freeExports && !isLoader) { -1 5758 // Export for CommonJS environments. -1 5759 runInContext(root, freeExports); -1 5760 } else { -1 5761 // Export for web browsers and JavaScript engines. -1 5762 var nativeJSON = root.JSON, -1 5763 previousJSON = root["JSON3"], -1 5764 isRestored = false; 6625 57656626 -1 // Generate tokens for input range6627 -1 //6628 -1 ParserBlock.prototype.tokenize = function (state, startLine, endLine) {6629 -1 var ok, i,6630 -1 rules = this.ruler.getRules(''),6631 -1 len = rules.length,6632 -1 line = startLine,6633 -1 hasEmptyLines = false,6634 -1 maxNesting = state.md.options.maxNesting;-1 5766 var JSON3 = runInContext(root, (root["JSON3"] = { -1 5767 // Public: Restores the original value of the global `JSON` object and -1 5768 // returns a reference to the `JSON3` object. -1 5769 "noConflict": function () { -1 5770 if (!isRestored) { -1 5771 isRestored = true; -1 5772 root.JSON = nativeJSON; -1 5773 root["JSON3"] = previousJSON; -1 5774 nativeJSON = previousJSON = null; -1 5775 } -1 5776 return JSON3; -1 5777 } -1 5778 })); 6635 57796636 -1 while (line < endLine) {6637 -1 state.line = line = state.skipEmptyLines(line);6638 -1 if (line >= endLine) { break; }-1 5780 root.JSON = { -1 5781 "parse": JSON3.parse, -1 5782 "stringify": JSON3.stringify -1 5783 }; -1 5784 } 6639 57856640 -1 // Termination condition for nested calls.6641 -1 // Nested calls currently used for blockquotes & lists6642 -1 if (state.sCount[line] < state.blkIndent) { break; }-1 5786 // Export for asynchronous module loaders. -1 5787 if (isLoader) { -1 5788 define(function () { -1 5789 return JSON3; -1 5790 }); -1 5791 } -1 5792 }).call(this); 6643 57936644 -1 // If nesting level exceeded - skip tail to the end. That's not ordinary6645 -1 // situation and we should not care about content.6646 -1 if (state.level >= maxNesting) {6647 -1 state.line = endLine;6648 -1 break;6649 -1 }-1 5794 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 5795 },{}],34:[function(require,module,exports){ -1 5796 'use strict'; 6650 57976651 -1 // Try all possible rules.6652 -1 // On success, rule should:6653 -1 //6654 -1 // - update `state.line`6655 -1 // - update `state.tokens`6656 -1 // - return true6657 57986658 -1 for (i = 0; i < len; i++) {6659 -1 ok = rules[i](state, line, endLine, false);6660 -1 if (ok) { break; }6661 -1 }-1 5799 //////////////////////////////////////////////////////////////////////////////// -1 5800 // Helpers 6662 58016663 -1 // set state.tight iff we had an empty line before current tag6664 -1 // i.e. latest empty line should not count6665 -1 state.tight = !hasEmptyLines;-1 5802 // Merge objects -1 5803 // -1 5804 function assign(obj /*from1, from2, from3, ...*/) { -1 5805 var sources = Array.prototype.slice.call(arguments, 1); 6666 58066667 -1 // paragraph might "eat" one newline after it in nested lists6668 -1 if (state.isEmpty(state.line - 1)) {6669 -1 hasEmptyLines = true;6670 -1 }-1 5807 sources.forEach(function (source) { -1 5808 if (!source) { return; } 6671 58096672 -1 line = state.line;-1 5810 Object.keys(source).forEach(function (key) { -1 5811 obj[key] = source[key]; -1 5812 }); -1 5813 }); 6673 58146674 -1 if (line < endLine && state.isEmpty(line)) {6675 -1 hasEmptyLines = true;6676 -1 line++;-1 5815 return obj; -1 5816 } 6677 58176678 -1 // two empty lines should stop the parser in list mode6679 -1 if (line < endLine && state.parentType === 'list' && state.isEmpty(line)) { break; }6680 -1 state.line = line;6681 -1 }6682 -1 }6683 -1 };-1 5818 function _class(obj) { return Object.prototype.toString.call(obj); } -1 5819 function isString(obj) { return _class(obj) === '[object String]'; } -1 5820 function isObject(obj) { return _class(obj) === '[object Object]'; } -1 5821 function isRegExp(obj) { return _class(obj) === '[object RegExp]'; } -1 5822 function isFunction(obj) { return _class(obj) === '[object Function]'; } 6684 5823 6685 58246686 -1 /**6687 -1 * ParserBlock.parse(str, md, env, outTokens)6688 -1 *6689 -1 * Process input string and push block tokens into `outTokens`6690 -1 **/6691 -1 ParserBlock.prototype.parse = function (src, md, env, outTokens) {6692 -1 var state;-1 5825 function escapeRE(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); } 6693 58266694 -1 if (!src) { return; }-1 5827 //////////////////////////////////////////////////////////////////////////////// 6695 58286696 -1 state = new this.State(src, md, env, outTokens);6697 58296698 -1 this.tokenize(state, state.line, state.lineMax);-1 5830 var defaultOptions = { -1 5831 fuzzyLink: true, -1 5832 fuzzyEmail: true, -1 5833 fuzzyIP: false 6699 5834 }; 6700 5835 6701 58366702 -1 ParserBlock.prototype.State = require('./rules_block/state_block');6703 -16704 -16705 -1 module.exports = ParserBlock;6706 -16707 -1 },{"./ruler":56,"./rules_block/blockquote":57,"./rules_block/code":58,"./rules_block/fence":59,"./rules_block/heading":60,"./rules_block/hr":61,"./rules_block/html_block":62,"./rules_block/lheading":63,"./rules_block/list":64,"./rules_block/paragraph":65,"./rules_block/reference":66,"./rules_block/state_block":67,"./rules_block/table":68}],50:[function(require,module,exports){6708 -1 /** internal6709 -1 * class Core6710 -1 *6711 -1 * Top-level rules executor. Glues block/inline parsers and does intermediate6712 -1 * transformations.6713 -1 **/6714 -1 'use strict';6715 -16716 -16717 -1 var Ruler = require('./ruler');6718 -16719 -16720 -1 var _rules = [6721 -1 [ 'normalize', require('./rules_core/normalize') ],6722 -1 [ 'block', require('./rules_core/block') ],6723 -1 [ 'inline', require('./rules_core/inline') ],6724 -1 [ 'linkify', require('./rules_core/linkify') ],6725 -1 [ 'replacements', require('./rules_core/replacements') ],6726 -1 [ 'smartquotes', require('./rules_core/smartquotes') ]6727 -1 ];-1 5837 function isOptionsObj(obj) { -1 5838 return Object.keys(obj || {}).reduce(function (acc, k) { -1 5839 return acc || defaultOptions.hasOwnProperty(k); -1 5840 }, false); -1 5841 } 6728 5842 6729 58436730 -1 /**6731 -1 * new Core()6732 -1 **/6733 -1 function Core() {6734 -1 /**6735 -1 * Core#ruler -> Ruler6736 -1 *6737 -1 * [[Ruler]] instance. Keep configuration of core rules.6738 -1 **/6739 -1 this.ruler = new Ruler();-1 5844 var defaultSchemas = { -1 5845 'http:': { -1 5846 validate: function (text, pos, self) { -1 5847 var tail = text.slice(pos); 6740 58486741 -1 for (var i = 0; i < _rules.length; i++) {6742 -1 this.ruler.push(_rules[i][0], _rules[i][1]);6743 -1 }6744 -1 }-1 5849 if (!self.re.http) { -1 5850 // compile lazily, because "host"-containing variables can change on tlds update. -1 5851 self.re.http = new RegExp( -1 5852 '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i' -1 5853 ); -1 5854 } -1 5855 if (self.re.http.test(tail)) { -1 5856 return tail.match(self.re.http)[0].length; -1 5857 } -1 5858 return 0; -1 5859 } -1 5860 }, -1 5861 'https:': 'http:', -1 5862 'ftp:': 'http:', -1 5863 '//': { -1 5864 validate: function (text, pos, self) { -1 5865 var tail = text.slice(pos); 6745 5866 -1 5867 if (!self.re.no_http) { -1 5868 // compile lazily, because "host"-containing variables can change on tlds update. -1 5869 self.re.no_http = new RegExp( -1 5870 '^' + -1 5871 self.re.src_auth + -1 5872 // Don't allow single-level domains, because of false positives like '//test' -1 5873 // with code comments -1 5874 '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' + -1 5875 self.re.src_port + -1 5876 self.re.src_host_terminator + -1 5877 self.re.src_path, 6746 58786747 -1 /**6748 -1 * Core.process(state)6749 -1 *6750 -1 * Executes core chain rules.6751 -1 **/6752 -1 Core.prototype.process = function (state) {6753 -1 var i, l, rules;-1 5879 'i' -1 5880 ); -1 5881 } 6754 58826755 -1 rules = this.ruler.getRules('');-1 5883 if (self.re.no_http.test(tail)) { -1 5884 // should not be `://` & `///`, that protects from errors in protocol name -1 5885 if (pos >= 3 && text[pos - 3] === ':') { return 0; } -1 5886 if (pos >= 3 && text[pos - 3] === '/') { return 0; } -1 5887 return tail.match(self.re.no_http)[0].length; -1 5888 } -1 5889 return 0; -1 5890 } -1 5891 }, -1 5892 'mailto:': { -1 5893 validate: function (text, pos, self) { -1 5894 var tail = text.slice(pos); 6756 58956757 -1 for (i = 0, l = rules.length; i < l; i++) {6758 -1 rules[i](state);-1 5896 if (!self.re.mailto) { -1 5897 self.re.mailto = new RegExp( -1 5898 '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i' -1 5899 ); -1 5900 } -1 5901 if (self.re.mailto.test(tail)) { -1 5902 return tail.match(self.re.mailto)[0].length; -1 5903 } -1 5904 return 0; -1 5905 } 6759 5906 } 6760 5907 }; 6761 59086762 -1 Core.prototype.State = require('./rules_core/state_core');-1 5909 /*eslint-disable max-len*/ 6763 5910 -1 5911 // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js) -1 5912 var tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]'; 6764 59136765 -1 module.exports = Core;-1 5914 // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead -1 5915 var tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|'); 6766 59166767 -1 },{"./ruler":56,"./rules_core/block":69,"./rules_core/inline":70,"./rules_core/linkify":71,"./rules_core/normalize":72,"./rules_core/replacements":73,"./rules_core/smartquotes":74,"./rules_core/state_core":75}],51:[function(require,module,exports){6768 -1 /** internal6769 -1 * class ParserInline6770 -1 *6771 -1 * Tokenizes paragraph content.6772 -1 **/6773 -1 'use strict';-1 5917 /*eslint-enable max-len*/ 6774 5918 -1 5919 //////////////////////////////////////////////////////////////////////////////// 6775 59206776 -1 var Ruler = require('./ruler');-1 5921 function resetScanCache(self) { -1 5922 self.__index__ = -1; -1 5923 self.__text_cache__ = ''; -1 5924 } 6777 5925 -1 5926 function createValidator(re) { -1 5927 return function (text, pos) { -1 5928 var tail = text.slice(pos); 6778 59296779 -1 ////////////////////////////////////////////////////////////////////////////////6780 -1 // Parser rules-1 5930 if (re.test(tail)) { -1 5931 return tail.match(re)[0].length; -1 5932 } -1 5933 return 0; -1 5934 }; -1 5935 } 6781 59366782 -1 var _rules = [6783 -1 [ 'text', require('./rules_inline/text') ],6784 -1 [ 'newline', require('./rules_inline/newline') ],6785 -1 [ 'escape', require('./rules_inline/escape') ],6786 -1 [ 'backticks', require('./rules_inline/backticks') ],6787 -1 [ 'strikethrough', require('./rules_inline/strikethrough').tokenize ],6788 -1 [ 'emphasis', require('./rules_inline/emphasis').tokenize ],6789 -1 [ 'link', require('./rules_inline/link') ],6790 -1 [ 'image', require('./rules_inline/image') ],6791 -1 [ 'autolink', require('./rules_inline/autolink') ],6792 -1 [ 'html_inline', require('./rules_inline/html_inline') ],6793 -1 [ 'entity', require('./rules_inline/entity') ]6794 -1 ];-1 5937 function createNormalizer() { -1 5938 return function (match, self) { -1 5939 self.normalize(match); -1 5940 }; -1 5941 } 6795 59426796 -1 var _rules2 = [6797 -1 [ 'balance_pairs', require('./rules_inline/balance_pairs') ],6798 -1 [ 'strikethrough', require('./rules_inline/strikethrough').postProcess ],6799 -1 [ 'emphasis', require('./rules_inline/emphasis').postProcess ],6800 -1 [ 'text_collapse', require('./rules_inline/text_collapse') ]6801 -1 ];-1 5943 // Schemas compiler. Build regexps. -1 5944 // -1 5945 function compile(self) { 6802 5946 -1 5947 // Load & clone RE patterns. -1 5948 var re = self.re = require('./lib/re')(self.__opts__); 6803 59496804 -1 /**6805 -1 * new ParserInline()6806 -1 **/6807 -1 function ParserInline() {6808 -1 var i;-1 5950 // Define dynamic patterns -1 5951 var tlds = self.__tlds__.slice(); 6809 59526810 -1 /**6811 -1 * ParserInline#ruler -> Ruler6812 -1 *6813 -1 * [[Ruler]] instance. Keep configuration of inline rules.6814 -1 **/6815 -1 this.ruler = new Ruler();-1 5953 self.onCompile(); 6816 59546817 -1 for (i = 0; i < _rules.length; i++) {6818 -1 this.ruler.push(_rules[i][0], _rules[i][1]);-1 5955 if (!self.__tlds_replaced__) { -1 5956 tlds.push(tlds_2ch_src_re); 6819 5957 } -1 5958 tlds.push(re.src_xn); 6820 59596821 -1 /**6822 -1 * ParserInline#ruler2 -> Ruler6823 -1 *6824 -1 * [[Ruler]] instance. Second ruler used for post-processing6825 -1 * (e.g. in emphasis-like rules).6826 -1 **/6827 -1 this.ruler2 = new Ruler();6828 -16829 -1 for (i = 0; i < _rules2.length; i++) {6830 -1 this.ruler2.push(_rules2[i][0], _rules2[i][1]);6831 -1 }6832 -1 }-1 5960 re.src_tlds = tlds.join('|'); 6833 5961 -1 5962 function untpl(tpl) { return tpl.replace('%TLDS%', re.src_tlds); } 6834 59636835 -1 // Skip single token by running all rules in validation mode;6836 -1 // returns `true` if any rule reported success6837 -1 //6838 -1 ParserInline.prototype.skipToken = function (state) {6839 -1 var ok, i, pos = state.pos,6840 -1 rules = this.ruler.getRules(''),6841 -1 len = rules.length,6842 -1 maxNesting = state.md.options.maxNesting,6843 -1 cache = state.cache;-1 5964 re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i'); -1 5965 re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i'); -1 5966 re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i'); -1 5967 re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i'); 6844 5968 -1 5969 // -1 5970 // Compile each schema -1 5971 // 6845 59726846 -1 if (typeof cache[pos] !== 'undefined') {6847 -1 state.pos = cache[pos];6848 -1 return;6849 -1 }-1 5973 var aliases = []; 6850 59746851 -1 if (state.level < maxNesting) {6852 -1 for (i = 0; i < len; i++) {6853 -1 // Increment state.level and decrement it later to limit recursion.6854 -1 // It's harmless to do here, because no tokens are created. But ideally,6855 -1 // we'd need a separate private state variable for this purpose.6856 -1 //6857 -1 state.level++;6858 -1 ok = rules[i](state, true);6859 -1 state.level--;-1 5975 self.__compiled__ = {}; // Reset compiled data 6860 59766861 -1 if (ok) { break; }6862 -1 }6863 -1 } else {6864 -1 // Too much nesting, just skip until the end of the paragraph.6865 -1 //6866 -1 // NOTE: this will cause links to behave incorrectly in the following case,6867 -1 // when an amount of `[` is exactly equal to `maxNesting + 1`:6868 -1 //6869 -1 // [[[[[[[[[[[[[[[[[[[[[foo]()6870 -1 //6871 -1 // TODO: remove this workaround when CM standard will allow nested links6872 -1 // (we can replace it by preventing links from being parsed in6873 -1 // validation mode)6874 -1 //6875 -1 state.pos = state.posMax;-1 5977 function schemaError(name, val) { -1 5978 throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val); 6876 5979 } 6877 59806878 -1 if (!ok) { state.pos++; }6879 -1 cache[pos] = state.pos;6880 -1 };-1 5981 Object.keys(self.__schemas__).forEach(function (name) { -1 5982 var val = self.__schemas__[name]; 6881 5983 -1 5984 // skip disabled methods -1 5985 if (val === null) { return; } 6882 59866883 -1 // Generate tokens for input range6884 -1 //6885 -1 ParserInline.prototype.tokenize = function (state) {6886 -1 var ok, i,6887 -1 rules = this.ruler.getRules(''),6888 -1 len = rules.length,6889 -1 end = state.posMax,6890 -1 maxNesting = state.md.options.maxNesting;-1 5987 var compiled = { validate: null, link: null }; 6891 59886892 -1 while (state.pos < end) {6893 -1 // Try all possible rules.6894 -1 // On success, rule should:6895 -1 //6896 -1 // - update `state.pos`6897 -1 // - update `state.tokens`6898 -1 // - return true-1 5989 self.__compiled__[name] = compiled; 6899 59906900 -1 if (state.level < maxNesting) {6901 -1 for (i = 0; i < len; i++) {6902 -1 ok = rules[i](state, false);6903 -1 if (ok) { break; }-1 5991 if (isObject(val)) { -1 5992 if (isRegExp(val.validate)) { -1 5993 compiled.validate = createValidator(val.validate); -1 5994 } else if (isFunction(val.validate)) { -1 5995 compiled.validate = val.validate; -1 5996 } else { -1 5997 schemaError(name, val); -1 5998 } -1 5999 -1 6000 if (isFunction(val.normalize)) { -1 6001 compiled.normalize = val.normalize; -1 6002 } else if (!val.normalize) { -1 6003 compiled.normalize = createNormalizer(); -1 6004 } else { -1 6005 schemaError(name, val); 6904 6006 } -1 6007 -1 6008 return; -1 6009 } -1 6010 -1 6011 if (isString(val)) { -1 6012 aliases.push(name); -1 6013 return; 6905 6014 } 6906 60156907 -1 if (ok) {6908 -1 if (state.pos >= end) { break; }6909 -1 continue;-1 6016 schemaError(name, val); -1 6017 }); -1 6018 -1 6019 // -1 6020 // Compile postponed aliases -1 6021 // -1 6022 -1 6023 aliases.forEach(function (alias) { -1 6024 if (!self.__compiled__[self.__schemas__[alias]]) { -1 6025 // Silently fail on missed schemas to avoid errons on disable. -1 6026 // schemaError(alias, self.__schemas__[alias]); -1 6027 return; 6910 6028 } 6911 60296912 -1 state.pending += state.src[state.pos++];6913 -1 }-1 6030 self.__compiled__[alias].validate = -1 6031 self.__compiled__[self.__schemas__[alias]].validate; -1 6032 self.__compiled__[alias].normalize = -1 6033 self.__compiled__[self.__schemas__[alias]].normalize; -1 6034 }); 6914 60356915 -1 if (state.pending) {6916 -1 state.pushPending();6917 -1 }6918 -1 };-1 6036 // -1 6037 // Fake record for guessed links -1 6038 // -1 6039 self.__compiled__[''] = { validate: null, normalize: createNormalizer() }; 6919 6040 -1 6041 // -1 6042 // Build schema condition -1 6043 // -1 6044 var slist = Object.keys(self.__compiled__) -1 6045 .filter(function (name) { -1 6046 // Filter disabled & fake schemas -1 6047 return name.length > 0 && self.__compiled__[name]; -1 6048 }) -1 6049 .map(escapeRE) -1 6050 .join('|'); -1 6051 // (?!_) cause 1.5x slowdown -1 6052 self.re.schema_test = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'i'); -1 6053 self.re.schema_search = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'ig'); 6920 60546921 -1 /**6922 -1 * ParserInline.parse(str, md, env, outTokens)6923 -1 *6924 -1 * Process input string and push inline tokens into `outTokens`6925 -1 **/6926 -1 ParserInline.prototype.parse = function (str, md, env, outTokens) {6927 -1 var i, rules, len;6928 -1 var state = new this.State(str, md, env, outTokens);-1 6055 self.re.pretest = RegExp( -1 6056 '(' + self.re.schema_test.source + ')|' + -1 6057 '(' + self.re.host_fuzzy_test.source + ')|' + -1 6058 '@', -1 6059 'i'); 6929 60606930 -1 this.tokenize(state);-1 6061 // -1 6062 // Cleanup -1 6063 // 6931 60646932 -1 rules = this.ruler2.getRules('');6933 -1 len = rules.length;-1 6065 resetScanCache(self); -1 6066 } 6934 60676935 -1 for (i = 0; i < len; i++) {6936 -1 rules[i](state);6937 -1 }6938 -1 };-1 6068 /** -1 6069 * class Match -1 6070 * -1 6071 * Match result. Single element of array, returned by [[LinkifyIt#match]] -1 6072 **/ -1 6073 function Match(self, shift) { -1 6074 var start = self.__index__, -1 6075 end = self.__last_index__, -1 6076 text = self.__text_cache__.slice(start, end); 6939 6077 -1 6078 /** -1 6079 * Match#schema -> String -1 6080 * -1 6081 * Prefix (protocol) for matched string. -1 6082 **/ -1 6083 this.schema = self.__schema__.toLowerCase(); -1 6084 /** -1 6085 * Match#index -> Number -1 6086 * -1 6087 * First position of matched string. -1 6088 **/ -1 6089 this.index = start + shift; -1 6090 /** -1 6091 * Match#lastIndex -> Number -1 6092 * -1 6093 * Next position after matched string. -1 6094 **/ -1 6095 this.lastIndex = end + shift; -1 6096 /** -1 6097 * Match#raw -> String -1 6098 * -1 6099 * Matched string. -1 6100 **/ -1 6101 this.raw = text; -1 6102 /** -1 6103 * Match#text -> String -1 6104 * -1 6105 * Notmalized text of matched string. -1 6106 **/ -1 6107 this.text = text; -1 6108 /** -1 6109 * Match#url -> String -1 6110 * -1 6111 * Normalized url of matched string. -1 6112 **/ -1 6113 this.url = text; -1 6114 } 6940 61156941 -1 ParserInline.prototype.State = require('./rules_inline/state_inline');-1 6116 function createMatch(self, shift) { -1 6117 var match = new Match(self, shift); 6942 6118 -1 6119 self.__compiled__[match.schema].normalize(match, self); 6943 61206944 -1 module.exports = ParserInline;-1 6121 return match; -1 6122 } 6945 61236946 -1 },{"./ruler":56,"./rules_inline/autolink":76,"./rules_inline/backticks":77,"./rules_inline/balance_pairs":78,"./rules_inline/emphasis":79,"./rules_inline/entity":80,"./rules_inline/escape":81,"./rules_inline/html_inline":82,"./rules_inline/image":83,"./rules_inline/link":84,"./rules_inline/newline":85,"./rules_inline/state_inline":86,"./rules_inline/strikethrough":87,"./rules_inline/text":88,"./rules_inline/text_collapse":89}],52:[function(require,module,exports){6947 -1 // Commonmark default options6948 61246949 -1 'use strict';-1 6125 /** -1 6126 * class LinkifyIt -1 6127 **/ 6950 6128 -1 6129 /** -1 6130 * new LinkifyIt(schemas, options) -1 6131 * - schemas (Object): Optional. Additional schemas to validate (prefix/validator) -1 6132 * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false } -1 6133 * -1 6134 * Creates new linkifier instance with optional additional schemas. -1 6135 * Can be called without `new` keyword for convenience. -1 6136 * -1 6137 * By default understands: -1 6138 * -1 6139 * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links -1 6140 * - "fuzzy" links and emails (example.com, foo@bar.com). -1 6141 * -1 6142 * `schemas` is an object, where each key/value describes protocol/rule: -1 6143 * -1 6144 * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:` -1 6145 * for example). `linkify-it` makes shure that prefix is not preceeded with -1 6146 * alphanumeric char and symbols. Only whitespaces and punctuation allowed. -1 6147 * - __value__ - rule to check tail after link prefix -1 6148 * - _String_ - just alias to existing rule -1 6149 * - _Object_ -1 6150 * - _validate_ - validator function (should return matched length on success), -1 6151 * or `RegExp`. -1 6152 * - _normalize_ - optional function to normalize text & url of matched result -1 6153 * (for example, for @twitter mentions). -1 6154 * -1 6155 * `options`: -1 6156 * -1 6157 * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`. -1 6158 * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts -1 6159 * like version numbers. Default `false`. -1 6160 * - __fuzzyEmail__ - recognize emails without `mailto:` prefix. -1 6161 * -1 6162 **/ -1 6163 function LinkifyIt(schemas, options) { -1 6164 if (!(this instanceof LinkifyIt)) { -1 6165 return new LinkifyIt(schemas, options); -1 6166 } 6951 61676952 -1 module.exports = {6953 -1 options: {6954 -1 html: true, // Enable HTML tags in source6955 -1 xhtmlOut: true, // Use '/' to close single tags (<br />)6956 -1 breaks: false, // Convert '\n' in paragraphs into <br>6957 -1 langPrefix: 'language-', // CSS language prefix for fenced blocks6958 -1 linkify: false, // autoconvert URL-like texts to links-1 6168 if (!options) { -1 6169 if (isOptionsObj(schemas)) { -1 6170 options = schemas; -1 6171 schemas = {}; -1 6172 } -1 6173 } 6959 61746960 -1 // Enable some language-neutral replacements + quotes beautification6961 -1 typographer: false,-1 6175 this.__opts__ = assign({}, defaultOptions, options); 6962 61766963 -1 // Double + single quotes replacement pairs, when typographer enabled,6964 -1 // and smartquotes on. Could be either a String or an Array.6965 -1 //6966 -1 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,6967 -1 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).6968 -1 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */-1 6177 // Cache last tested result. Used to skip repeating steps on next `match` call. -1 6178 this.__index__ = -1; -1 6179 this.__last_index__ = -1; // Next scan position -1 6180 this.__schema__ = ''; -1 6181 this.__text_cache__ = ''; 6969 61826970 -1 // Highlighter function. Should return escaped HTML,6971 -1 // or '' if the source string is not changed and should be escaped externaly.6972 -1 // If result starts with <pre... internal wrapper is skipped.6973 -1 //6974 -1 // function (/*str, lang*/) { return ''; }6975 -1 //6976 -1 highlight: null,-1 6183 this.__schemas__ = assign({}, defaultSchemas, schemas); -1 6184 this.__compiled__ = {}; 6977 61856978 -1 maxNesting: 20 // Internal protection, recursion limit6979 -1 },-1 6186 this.__tlds__ = tlds_default; -1 6187 this.__tlds_replaced__ = false; 6980 61886981 -1 components: {-1 6189 this.re = {}; 6982 61906983 -1 core: {6984 -1 rules: [6985 -1 'normalize',6986 -1 'block',6987 -1 'inline'6988 -1 ]6989 -1 },-1 6191 compile(this); -1 6192 } 6990 61936991 -1 block: {6992 -1 rules: [6993 -1 'blockquote',6994 -1 'code',6995 -1 'fence',6996 -1 'heading',6997 -1 'hr',6998 -1 'html_block',6999 -1 'lheading',7000 -1 'list',7001 -1 'reference',7002 -1 'paragraph'7003 -1 ]7004 -1 },7005 61947006 -1 inline: {7007 -1 rules: [7008 -1 'autolink',7009 -1 'backticks',7010 -1 'emphasis',7011 -1 'entity',7012 -1 'escape',7013 -1 'html_inline',7014 -1 'image',7015 -1 'link',7016 -1 'newline',7017 -1 'text'7018 -1 ],7019 -1 rules2: [7020 -1 'balance_pairs',7021 -1 'emphasis',7022 -1 'text_collapse'7023 -1 ]7024 -1 }7025 -1 }-1 6195 /** chainable -1 6196 * LinkifyIt#add(schema, definition) -1 6197 * - schema (String): rule name (fixed pattern prefix) -1 6198 * - definition (String|RegExp|Object): schema definition -1 6199 * -1 6200 * Add new rule definition. See constructor description for details. -1 6201 **/ -1 6202 LinkifyIt.prototype.add = function add(schema, definition) { -1 6203 this.__schemas__[schema] = definition; -1 6204 compile(this); -1 6205 return this; 7026 6206 }; 7027 62077028 -1 },{}],53:[function(require,module,exports){7029 -1 // markdown-it default options7030 62087031 -1 'use strict';-1 6209 /** chainable -1 6210 * LinkifyIt#set(options) -1 6211 * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false } -1 6212 * -1 6213 * Set recognition options for links without schema. -1 6214 **/ -1 6215 LinkifyIt.prototype.set = function set(options) { -1 6216 this.__opts__ = assign(this.__opts__, options); -1 6217 return this; -1 6218 }; 7032 6219 7033 62207034 -1 module.exports = {7035 -1 options: {7036 -1 html: false, // Enable HTML tags in source7037 -1 xhtmlOut: false, // Use '/' to close single tags (<br />)7038 -1 breaks: false, // Convert '\n' in paragraphs into <br>7039 -1 langPrefix: 'language-', // CSS language prefix for fenced blocks7040 -1 linkify: false, // autoconvert URL-like texts to links-1 6221 /** -1 6222 * LinkifyIt#test(text) -> Boolean -1 6223 * -1 6224 * Searches linkifiable pattern and returns `true` on success or `false` on fail. -1 6225 **/ -1 6226 LinkifyIt.prototype.test = function test(text) { -1 6227 // Reset scan cache -1 6228 this.__text_cache__ = text; -1 6229 this.__index__ = -1; 7041 62307042 -1 // Enable some language-neutral replacements + quotes beautification7043 -1 typographer: false,-1 6231 if (!text.length) { return false; } 7044 62327045 -1 // Double + single quotes replacement pairs, when typographer enabled,7046 -1 // and smartquotes on. Could be either a String or an Array.7047 -1 //7048 -1 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,7049 -1 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).7050 -1 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */-1 6233 var m, ml, me, len, shift, next, re, tld_pos, at_pos; 7051 62347052 -1 // Highlighter function. Should return escaped HTML,7053 -1 // or '' if the source string is not changed and should be escaped externaly.7054 -1 // If result starts with <pre... internal wrapper is skipped.7055 -1 //7056 -1 // function (/*str, lang*/) { return ''; }7057 -1 //7058 -1 highlight: null,-1 6235 // try to scan for link with schema - that's the most simple rule -1 6236 if (this.re.schema_test.test(text)) { -1 6237 re = this.re.schema_search; -1 6238 re.lastIndex = 0; -1 6239 while ((m = re.exec(text)) !== null) { -1 6240 len = this.testSchemaAt(text, m[2], re.lastIndex); -1 6241 if (len) { -1 6242 this.__schema__ = m[2]; -1 6243 this.__index__ = m.index + m[1].length; -1 6244 this.__last_index__ = m.index + m[0].length + len; -1 6245 break; -1 6246 } -1 6247 } -1 6248 } 7059 62497060 -1 maxNesting: 100 // Internal protection, recursion limit7061 -1 },-1 6250 if (this.__opts__.fuzzyLink && this.__compiled__['http:']) { -1 6251 // guess schemaless links -1 6252 tld_pos = text.search(this.re.host_fuzzy_test); -1 6253 if (tld_pos >= 0) { -1 6254 // if tld is located after found link - no need to check fuzzy pattern -1 6255 if (this.__index__ < 0 || tld_pos < this.__index__) { -1 6256 if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) { 7062 62577063 -1 components: {-1 6258 shift = ml.index + ml[1].length; 7064 62597065 -1 core: {},7066 -1 block: {},7067 -1 inline: {}-1 6260 if (this.__index__ < 0 || shift < this.__index__) { -1 6261 this.__schema__ = ''; -1 6262 this.__index__ = shift; -1 6263 this.__last_index__ = ml.index + ml[0].length; -1 6264 } -1 6265 } -1 6266 } -1 6267 } 7068 6268 }7069 -1 };7070 62697071 -1 },{}],54:[function(require,module,exports){7072 -1 // "Zero" preset, with nothing enabled. Useful for manual configuring of simple7073 -1 // modes. For example, to parse bold/italic only.-1 6270 if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) { -1 6271 // guess schemaless emails -1 6272 at_pos = text.indexOf('@'); -1 6273 if (at_pos >= 0) { -1 6274 // We can't skip this check, because this cases are possible: -1 6275 // 192.168.1.1@gmail.com, my.in@example.com -1 6276 if ((me = text.match(this.re.email_fuzzy)) !== null) { 7074 62777075 -1 'use strict';-1 6278 shift = me.index + me[1].length; -1 6279 next = me.index + me[0].length; 7076 6280 -1 6281 if (this.__index__ < 0 || shift < this.__index__ || -1 6282 (shift === this.__index__ && next > this.__last_index__)) { -1 6283 this.__schema__ = 'mailto:'; -1 6284 this.__index__ = shift; -1 6285 this.__last_index__ = next; -1 6286 } -1 6287 } -1 6288 } -1 6289 } 7077 62907078 -1 module.exports = {7079 -1 options: {7080 -1 html: false, // Enable HTML tags in source7081 -1 xhtmlOut: false, // Use '/' to close single tags (<br />)7082 -1 breaks: false, // Convert '\n' in paragraphs into <br>7083 -1 langPrefix: 'language-', // CSS language prefix for fenced blocks7084 -1 linkify: false, // autoconvert URL-like texts to links-1 6291 return this.__index__ >= 0; -1 6292 }; 7085 62937086 -1 // Enable some language-neutral replacements + quotes beautification7087 -1 typographer: false,7088 62947089 -1 // Double + single quotes replacement pairs, when typographer enabled,7090 -1 // and smartquotes on. Could be either a String or an Array.7091 -1 //7092 -1 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,7093 -1 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).7094 -1 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */-1 6295 /** -1 6296 * LinkifyIt#pretest(text) -> Boolean -1 6297 * -1 6298 * Very quick check, that can give false positives. Returns true if link MAY BE -1 6299 * can exists. Can be used for speed optimization, when you need to check that -1 6300 * link NOT exists. -1 6301 **/ -1 6302 LinkifyIt.prototype.pretest = function pretest(text) { -1 6303 return this.re.pretest.test(text); -1 6304 }; 7095 63057096 -1 // Highlighter function. Should return escaped HTML,7097 -1 // or '' if the source string is not changed and should be escaped externaly.7098 -1 // If result starts with <pre... internal wrapper is skipped.7099 -1 //7100 -1 // function (/*str, lang*/) { return ''; }7101 -1 //7102 -1 highlight: null,7103 63067104 -1 maxNesting: 20 // Internal protection, recursion limit7105 -1 },-1 6307 /** -1 6308 * LinkifyIt#testSchemaAt(text, name, position) -> Number -1 6309 * - text (String): text to scan -1 6310 * - name (String): rule (schema) name -1 6311 * - position (Number): text offset to check from -1 6312 * -1 6313 * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly -1 6314 * at given position. Returns length of found pattern (0 on fail). -1 6315 **/ -1 6316 LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) { -1 6317 // If not supported schema check requested - terminate -1 6318 if (!this.__compiled__[schema.toLowerCase()]) { -1 6319 return 0; -1 6320 } -1 6321 return this.__compiled__[schema.toLowerCase()].validate(text, pos, this); -1 6322 }; 7106 63237107 -1 components: {7108 63247109 -1 core: {7110 -1 rules: [7111 -1 'normalize',7112 -1 'block',7113 -1 'inline'7114 -1 ]7115 -1 },-1 6325 /** -1 6326 * LinkifyIt#match(text) -> Array|null -1 6327 * -1 6328 * Returns array of found link descriptions or `null` on fail. We strongly -1 6329 * recommend to use [[LinkifyIt#test]] first, for best speed. -1 6330 * -1 6331 * ##### Result match description -1 6332 * -1 6333 * - __schema__ - link schema, can be empty for fuzzy links, or `//` for -1 6334 * protocol-neutral links. -1 6335 * - __index__ - offset of matched text -1 6336 * - __lastIndex__ - index of next char after mathch end -1 6337 * - __raw__ - matched text -1 6338 * - __text__ - normalized text -1 6339 * - __url__ - link, generated from matched text -1 6340 **/ -1 6341 LinkifyIt.prototype.match = function match(text) { -1 6342 var shift = 0, result = []; 7116 63437117 -1 block: {7118 -1 rules: [7119 -1 'paragraph'7120 -1 ]7121 -1 },-1 6344 // Try to take previous element from cache, if .test() called before -1 6345 if (this.__index__ >= 0 && this.__text_cache__ === text) { -1 6346 result.push(createMatch(this, shift)); -1 6347 shift = this.__last_index__; -1 6348 } 7122 63497123 -1 inline: {7124 -1 rules: [7125 -1 'text'7126 -1 ],7127 -1 rules2: [7128 -1 'balance_pairs',7129 -1 'text_collapse'7130 -1 ]7131 -1 }-1 6350 // Cut head if cache was used -1 6351 var tail = shift ? text.slice(shift) : text; -1 6352 -1 6353 // Scan string until end reached -1 6354 while (this.test(tail)) { -1 6355 result.push(createMatch(this, shift)); -1 6356 -1 6357 tail = tail.slice(this.__last_index__); -1 6358 shift += this.__last_index__; -1 6359 } -1 6360 -1 6361 if (result.length) { -1 6362 return result; 7132 6363 } -1 6364 -1 6365 return null; 7133 6366 }; 7134 63677135 -1 },{}],55:[function(require,module,exports){7136 -1 /**7137 -1 * class Renderer-1 6368 -1 6369 /** chainable -1 6370 * LinkifyIt#tlds(list [, keepOld]) -> this -1 6371 * - list (Array): list of tlds -1 6372 * - keepOld (Boolean): merge with current list if `true` (`false` by default) 7138 6373 *7139 -1 * Generates HTML from parsed token stream. Each instance has independent7140 -1 * copy of rules. Those can be rewritten with ease. Also, you can add new7141 -1 * rules if you create plugin and adds new token types.-1 6374 * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix) -1 6375 * to avoid false positives. By default this algorythm used: -1 6376 * -1 6377 * - hostname with any 2-letter root zones are ok. -1 6378 * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф -1 6379 * are ok. -1 6380 * - encoded (`xn--...`) root zones are ok. -1 6381 * -1 6382 * If list is replaced, then exact match for 2-chars root zones will be checked. 7142 6383 **/7143 -1 'use strict';7144 -1-1 6384 LinkifyIt.prototype.tlds = function tlds(list, keepOld) { -1 6385 list = Array.isArray(list) ? list : [ list ]; 7145 63867146 -1 var assign = require('./common/utils').assign;7147 -1 var unescapeAll = require('./common/utils').unescapeAll;7148 -1 var escapeHtml = require('./common/utils').escapeHtml;-1 6387 if (!keepOld) { -1 6388 this.__tlds__ = list.slice(); -1 6389 this.__tlds_replaced__ = true; -1 6390 compile(this); -1 6391 return this; -1 6392 } 7149 6393 -1 6394 this.__tlds__ = this.__tlds__.concat(list) -1 6395 .sort() -1 6396 .filter(function (el, idx, arr) { -1 6397 return el !== arr[idx - 1]; -1 6398 }) -1 6399 .reverse(); 7150 64007151 -1 ////////////////////////////////////////////////////////////////////////////////-1 6401 compile(this); -1 6402 return this; -1 6403 }; 7152 64047153 -1 var default_rules = {};-1 6405 /** -1 6406 * LinkifyIt#normalize(match) -1 6407 * -1 6408 * Default normalizer (if schema does not define it's own). -1 6409 **/ -1 6410 LinkifyIt.prototype.normalize = function normalize(match) { 7154 6411 -1 6412 // Do minimal possible changes by default. Need to collect feedback prior -1 6413 // to move forward https://github.com/markdown-it/linkify-it/issues/1 7155 64147156 -1 default_rules.code_inline = function (tokens, idx, options, env, slf) {7157 -1 var token = tokens[idx],7158 -1 attrs = slf.renderAttrs(token);-1 6415 if (!match.schema) { match.url = 'http://' + match.url; } 7159 64167160 -1 return '<code' + (attrs ? ' ' + attrs : '') + '>' +7161 -1 escapeHtml(tokens[idx].content) +7162 -1 '</code>';-1 6417 if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) { -1 6418 match.url = 'mailto:' + match.url; -1 6419 } 7163 6420 }; 7164 6421 7165 64227166 -1 default_rules.code_block = function (tokens, idx, options, env, slf) {7167 -1 var token = tokens[idx],7168 -1 attrs = slf.renderAttrs(token);7169 -17170 -1 return '<pre' + (attrs ? ' ' + attrs : '') + '><code>' +7171 -1 escapeHtml(tokens[idx].content) +7172 -1 '</code></pre>\n';-1 6423 /** -1 6424 * LinkifyIt#onCompile() -1 6425 * -1 6426 * Override to modify basic RegExp-s. -1 6427 **/ -1 6428 LinkifyIt.prototype.onCompile = function onCompile() { 7173 6429 }; 7174 6430 7175 64317176 -1 default_rules.fence = function (tokens, idx, options, env, slf) {7177 -1 var token = tokens[idx],7178 -1 info = token.info ? unescapeAll(token.info).trim() : '',7179 -1 langName = '',7180 -1 highlighted, i, tmpAttrs, tmpToken;-1 6432 module.exports = LinkifyIt; 7181 64337182 -1 if (info) {7183 -1 langName = info.split(/\s+/g)[0];7184 -1 }-1 6434 },{"./lib/re":35}],35:[function(require,module,exports){ -1 6435 'use strict'; 7185 64367186 -1 if (options.highlight) {7187 -1 highlighted = options.highlight(token.content, langName) || escapeHtml(token.content);7188 -1 } else {7189 -1 highlighted = escapeHtml(token.content);7190 -1 }7191 64377192 -1 if (highlighted.indexOf('<pre') === 0) {7193 -1 return highlighted + '\n';7194 -1 }-1 6438 module.exports = function (opts) { -1 6439 var re = {}; 7195 64407196 -1 // If language exists, inject class gently, without mudofying original token.7197 -1 // May be, one day we will add .clone() for token and simplify this part, but7198 -1 // now we prefer to keep things local.7199 -1 if (info) {7200 -1 i = token.attrIndex('class');7201 -1 tmpAttrs = token.attrs ? token.attrs.slice() : [];-1 6441 // Use direct extract instead of `regenerate` to reduse browserified size -1 6442 re.src_Any = require('uc.micro/properties/Any/regex').source; -1 6443 re.src_Cc = require('uc.micro/categories/Cc/regex').source; -1 6444 re.src_Z = require('uc.micro/categories/Z/regex').source; -1 6445 re.src_P = require('uc.micro/categories/P/regex').source; 7202 64467203 -1 if (i < 0) {7204 -1 tmpAttrs.push([ 'class', options.langPrefix + langName ]);7205 -1 } else {7206 -1 tmpAttrs[i] += ' ' + options.langPrefix + langName;7207 -1 }-1 6447 // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation) -1 6448 re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join('|'); 7208 64497209 -1 // Fake token just to render attributes7210 -1 tmpToken = {7211 -1 attrs: tmpAttrs7212 -1 };-1 6450 // \p{\Z\Cc} (white spaces + control) -1 6451 re.src_ZCc = [ re.src_Z, re.src_Cc ].join('|'); 7213 64527214 -1 return '<pre><code' + slf.renderAttrs(tmpToken) + '>'7215 -1 + highlighted7216 -1 + '</code></pre>\n';7217 -1 }-1 6453 // Experimental. List of chars, completely prohibited in links -1 6454 // because can separate it from other part of text -1 6455 var text_separators = '[><\uff5c]'; 7218 6456 -1 6457 // All possible word characters (everything without punctuation, spaces & controls) -1 6458 // Defined via punctuation & spaces to save space -1 6459 // Should be something like \p{\L\N\S\M} (\w but without `_`) -1 6460 re.src_pseudo_letter = '(?:(?!' + text_separators + '|' + re.src_ZPCc + ')' + re.src_Any + ')'; -1 6461 // The same as abothe but without [0-9] -1 6462 // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')'; 7219 64637220 -1 return '<pre><code' + slf.renderAttrs(token) + '>'7221 -1 + highlighted7222 -1 + '</code></pre>\n';7223 -1 };-1 6464 //////////////////////////////////////////////////////////////////////////////// 7224 6465 -1 6466 re.src_ip4 = 7225 64677226 -1 default_rules.image = function (tokens, idx, options, env, slf) {7227 -1 var token = tokens[idx];-1 6468 '(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; 7228 64697229 -1 // "alt" attr MUST be set, even if empty. Because it's mandatory and7230 -1 // should be placed on proper position for tests.7231 -1 //7232 -1 // Replace content with actual value-1 6470 // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch. -1 6471 re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?'; 7233 64727234 -1 token.attrs[token.attrIndex('alt')][1] =7235 -1 slf.renderInlineAsText(token.children, options, env);-1 6473 re.src_port = 7236 64747237 -1 return slf.renderToken(tokens, idx, options);7238 -1 };-1 6475 '(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?'; 7239 6476 -1 6477 re.src_host_terminator = 7240 64787241 -1 default_rules.hardbreak = function (tokens, idx, options /*, env */) {7242 -1 return options.xhtmlOut ? '<br />\n' : '<br>\n';7243 -1 };7244 -1 default_rules.softbreak = function (tokens, idx, options /*, env */) {7245 -1 return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n';7246 -1 };-1 6479 '(?=$|' + text_separators + '|' + re.src_ZPCc + ')(?!-|_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))'; 7247 6480 -1 6481 re.src_path = 7248 64827249 -1 default_rules.text = function (tokens, idx /*, options, env */) {7250 -1 return escapeHtml(tokens[idx].content);7251 -1 };-1 6483 '(?:' + -1 6484 '[/?#]' + -1 6485 '(?:' + -1 6486 '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-]).|' + -1 6487 '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' + -1 6488 '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' + -1 6489 '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' + -1 6490 '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' + -1 6491 "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" + -1 6492 "\\'(?=" + re.src_pseudo_letter + '|[-]).|' + // allow `I'm_king` if no pair found -1 6493 '\\.{2,3}[a-zA-Z0-9%/]|' + // github has ... in commit range links. Restrict to -1 6494 // - english -1 6495 // - percent-encoded -1 6496 // - parts of file path -1 6497 // until more examples found. -1 6498 '\\.(?!' + re.src_ZCc + '|[.]).|' + -1 6499 (opts && opts['---'] ? -1 6500 '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate -1 6501 : -1 6502 '\\-+|' -1 6503 ) + -1 6504 '\\,(?!' + re.src_ZCc + ').|' + // allow `,,,` in paths -1 6505 '\\!(?!' + re.src_ZCc + '|[!]).|' + -1 6506 '\\?(?!' + re.src_ZCc + '|[?]).' + -1 6507 ')+' + -1 6508 '|\\/' + -1 6509 ')?'; 7252 6510 -1 6511 re.src_email_name = 7253 65127254 -1 default_rules.html_block = function (tokens, idx /*, options, env */) {7255 -1 return tokens[idx].content;7256 -1 };7257 -1 default_rules.html_inline = function (tokens, idx /*, options, env */) {7258 -1 return tokens[idx].content;7259 -1 };-1 6513 '[\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]+'; 7260 6514 -1 6515 re.src_xn = 7261 65167262 -1 /**7263 -1 * new Renderer()7264 -1 *7265 -1 * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.7266 -1 **/7267 -1 function Renderer() {-1 6517 'xn--[a-z0-9\\-]{1,59}'; 7268 65187269 -1 /**7270 -1 * Renderer#rules -> Object7271 -1 *7272 -1 * Contains render rules for tokens. Can be updated and extended.7273 -1 *7274 -1 * ##### Example7275 -1 *7276 -1 * ```javascript7277 -1 * var md = require('markdown-it')();7278 -1 *7279 -1 * md.renderer.rules.strong_open = function () { return '<b>'; };7280 -1 * md.renderer.rules.strong_close = function () { return '</b>'; };7281 -1 *7282 -1 * var result = md.renderInline(...);7283 -1 * ```7284 -1 *7285 -1 * Each rule is called as independed static function with fixed signature:7286 -1 *7287 -1 * ```javascript7288 -1 * function my_token_render(tokens, idx, options, env, renderer) {7289 -1 * // ...7290 -1 * return renderedHTML;7291 -1 * }7292 -1 * ```7293 -1 *7294 -1 * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)7295 -1 * for more details and examples.7296 -1 **/7297 -1 this.rules = assign({}, default_rules);7298 -1 }-1 6519 // More to read about domain names -1 6520 // http://serverfault.com/questions/638260/ -1 6521 -1 6522 re.src_domain_root = 7299 6523 -1 6524 // Allow letters & digits (http://test1) -1 6525 '(?:' + -1 6526 re.src_xn + -1 6527 '|' + -1 6528 re.src_pseudo_letter + '{1,63}' + -1 6529 ')'; 7300 65307301 -1 /**7302 -1 * Renderer.renderAttrs(token) -> String7303 -1 *7304 -1 * Render token attributes to string.7305 -1 **/7306 -1 Renderer.prototype.renderAttrs = function renderAttrs(token) {7307 -1 var i, l, result;-1 6531 re.src_domain = 7308 65327309 -1 if (!token.attrs) { return ''; }-1 6533 '(?:' + -1 6534 re.src_xn + -1 6535 '|' + -1 6536 '(?:' + re.src_pseudo_letter + ')' + -1 6537 '|' + -1 6538 // don't allow `--` in domain names, because: -1 6539 // - that can conflict with markdown — / – -1 6540 // - nobody use those anyway -1 6541 '(?:' + re.src_pseudo_letter + '(?:-(?!-)|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' + -1 6542 ')'; 7310 65437311 -1 result = '';-1 6544 re.src_host = 7312 65457313 -1 for (i = 0, l = token.attrs.length; i < l; i++) {7314 -1 result += ' ' + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';7315 -1 }-1 6546 '(?:' + -1 6547 // Don't need IP check, because digits are already allowed in normal domain names -1 6548 // src_ip4 + -1 6549 // '|' + -1 6550 '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/*_root*/ + ')' + -1 6551 ')'; 7316 65527317 -1 return result;7318 -1 };-1 6553 re.tpl_host_fuzzy = 7319 6554 -1 6555 '(?:' + -1 6556 re.src_ip4 + -1 6557 '|' + -1 6558 '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' + -1 6559 ')'; 7320 65607321 -1 /**7322 -1 * Renderer.renderToken(tokens, idx, options) -> String7323 -1 * - tokens (Array): list of tokens7324 -1 * - idx (Numbed): token index to render7325 -1 * - options (Object): params of parser instance7326 -1 *7327 -1 * Default token renderer. Can be overriden by custom function7328 -1 * in [[Renderer#rules]].7329 -1 **/7330 -1 Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {7331 -1 var nextToken,7332 -1 result = '',7333 -1 needLf = false,7334 -1 token = tokens[idx];-1 6561 re.tpl_host_no_ip_fuzzy = 7335 65627336 -1 // Tight list paragraphs7337 -1 if (token.hidden) {7338 -1 return '';7339 -1 }-1 6563 '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))'; 7340 65647341 -1 // Insert a newline between hidden paragraph and subsequent opening7342 -1 // block-level tag.7343 -1 //7344 -1 // For example, here we should insert a newline before blockquote:7345 -1 // - a7346 -1 // >7347 -1 //7348 -1 if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {7349 -1 result += '\n';7350 -1 }-1 6565 re.src_host_strict = 7351 65667352 -1 // Add token name, e.g. `<img`7353 -1 result += (token.nesting === -1 ? '</' : '<') + token.tag;-1 6567 re.src_host + re.src_host_terminator; 7354 65687355 -1 // Encode attributes, e.g. `<img src="foo"`7356 -1 result += this.renderAttrs(token);-1 6569 re.tpl_host_fuzzy_strict = 7357 65707358 -1 // Add a slash for self-closing tags, e.g. `<img src="foo" /`7359 -1 if (token.nesting === 0 && options.xhtmlOut) {7360 -1 result += ' /';7361 -1 }-1 6571 re.tpl_host_fuzzy + re.src_host_terminator; 7362 65727363 -1 // Check if we need to add a newline after this tag7364 -1 if (token.block) {7365 -1 needLf = true;-1 6573 re.src_host_port_strict = 7366 65747367 -1 if (token.nesting === 1) {7368 -1 if (idx + 1 < tokens.length) {7369 -1 nextToken = tokens[idx + 1];-1 6575 re.src_host + re.src_port + re.src_host_terminator; 7370 65767371 -1 if (nextToken.type === 'inline' || nextToken.hidden) {7372 -1 // Block-level tag containing an inline tag.7373 -1 //7374 -1 needLf = false;-1 6577 re.tpl_host_port_fuzzy_strict = 7375 65787376 -1 } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) {7377 -1 // Opening tag + closing tag of the same type. E.g. `<li></li>`.7378 -1 //7379 -1 needLf = false;7380 -1 }7381 -1 }7382 -1 }7383 -1 }-1 6579 re.tpl_host_fuzzy + re.src_port + re.src_host_terminator; 7384 65807385 -1 result += needLf ? '>\n' : '>';-1 6581 re.tpl_host_port_no_ip_fuzzy_strict = 7386 65827387 -1 return result;7388 -1 };-1 6583 re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator; 7389 6584 7390 65857391 -1 /**7392 -1 * Renderer.renderInline(tokens, options, env) -> String7393 -1 * - tokens (Array): list on block tokens to renter7394 -1 * - options (Object): params of parser instance7395 -1 * - env (Object): additional data from parsed input (references, for example)7396 -1 *7397 -1 * The same as [[Renderer.render]], but for single token of `inline` type.7398 -1 **/7399 -1 Renderer.prototype.renderInline = function (tokens, options, env) {7400 -1 var type,7401 -1 result = '',7402 -1 rules = this.rules;-1 6586 //////////////////////////////////////////////////////////////////////////////// -1 6587 // Main rules 7403 65887404 -1 for (var i = 0, len = tokens.length; i < len; i++) {7405 -1 type = tokens[i].type;-1 6589 // Rude test fuzzy links by host, for quick deny -1 6590 re.tpl_host_fuzzy_test = 7406 65917407 -1 if (typeof rules[type] !== 'undefined') {7408 -1 result += rules[type](tokens, i, options, env, this);7409 -1 } else {7410 -1 result += this.renderToken(tokens, i, options);7411 -1 }7412 -1 }-1 6592 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))'; 7413 65937414 -1 return result;7415 -1 };-1 6594 re.tpl_email_fuzzy = 7416 6595 -1 6596 '(^|' + text_separators + '|\\(|' + re.src_ZCc + ')(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')'; 7417 65977418 -1 /** internal7419 -1 * Renderer.renderInlineAsText(tokens, options, env) -> String7420 -1 * - tokens (Array): list on block tokens to renter7421 -1 * - options (Object): params of parser instance7422 -1 * - env (Object): additional data from parsed input (references, for example)7423 -1 *7424 -1 * Special kludge for image `alt` attributes to conform CommonMark spec.7425 -1 * Don't try to use it! Spec requires to show `alt` content with stripped markup,7426 -1 * instead of simple escaping.7427 -1 **/7428 -1 Renderer.prototype.renderInlineAsText = function (tokens, options, env) {7429 -1 var result = '';-1 6598 re.tpl_link_fuzzy = -1 6599 // Fuzzy link can't be prepended with .:/\- and non punctuation. -1 6600 // but can start with > (markdown blockquote) -1 6601 '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' + -1 6602 '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')'; 7430 66037431 -1 for (var i = 0, len = tokens.length; i < len; i++) {7432 -1 if (tokens[i].type === 'text') {7433 -1 result += tokens[i].content;7434 -1 } else if (tokens[i].type === 'image') {7435 -1 result += this.renderInlineAsText(tokens[i].children, options, env);7436 -1 }7437 -1 }-1 6604 re.tpl_link_no_ip_fuzzy = -1 6605 // Fuzzy link can't be prepended with .:/\- and non punctuation. -1 6606 // but can start with > (markdown blockquote) -1 6607 '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' + -1 6608 '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')'; 7438 66097439 -1 return result;-1 6610 return re; 7440 6611 }; 7441 6612 -1 6613 },{"uc.micro/categories/Cc/regex":113,"uc.micro/categories/P/regex":115,"uc.micro/categories/Z/regex":116,"uc.micro/properties/Any/regex":118}],36:[function(require,module,exports){ -1 6614 'use strict'; 7442 66157443 -1 /**7444 -1 * Renderer.render(tokens, options, env) -> String7445 -1 * - tokens (Array): list on block tokens to renter7446 -1 * - options (Object): params of parser instance7447 -1 * - env (Object): additional data from parsed input (references, for example)7448 -1 *7449 -1 * Takes token stream and generates HTML. Probably, you will never need to call7450 -1 * this method directly.7451 -1 **/7452 -1 Renderer.prototype.render = function (tokens, options, env) {7453 -1 var i, len, type,7454 -1 result = '',7455 -1 rules = this.rules;7456 66167457 -1 for (i = 0, len = tokens.length; i < len; i++) {7458 -1 type = tokens[i].type;-1 6617 module.exports = require('./lib/'); 7459 66187460 -1 if (type === 'inline') {7461 -1 result += this.renderInline(tokens[i].children, options, env);7462 -1 } else if (typeof rules[type] !== 'undefined') {7463 -1 result += rules[tokens[i].type](tokens, i, options, env, this);7464 -1 } else {7465 -1 result += this.renderToken(tokens, i, options, env);7466 -1 }7467 -1 }-1 6619 },{"./lib/":45}],37:[function(require,module,exports){ -1 6620 // HTML5 entities map: { name -> utf16string } -1 6621 // -1 6622 'use strict'; 7468 66237469 -1 return result;7470 -1 };-1 6624 /*eslint quotes:0*/ -1 6625 module.exports = require('entities/maps/entities.json'); 7471 66267472 -1 module.exports = Renderer;-1 6627 },{"entities/maps/entities.json":28}],38:[function(require,module,exports){ -1 6628 // List of valid html blocks names, accorting to commonmark spec -1 6629 // http://jgm.github.io/CommonMark/spec.html#html-blocks 7473 66307474 -1 },{"./common/utils":43}],56:[function(require,module,exports){7475 -1 /**7476 -1 * class Ruler7477 -1 *7478 -1 * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and7479 -1 * [[MarkdownIt#inline]] to manage sequences of functions (rules):7480 -1 *7481 -1 * - keep rules in defined order7482 -1 * - assign the name to each rule7483 -1 * - enable/disable rules7484 -1 * - add/replace rules7485 -1 * - allow assign rules to additional named chains (in the same)7486 -1 * - cacheing lists of active rules7487 -1 *7488 -1 * You will not need use this class directly until write plugins. For simple7489 -1 * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and7490 -1 * [[MarkdownIt.use]].7491 -1 **/7492 6631 'use strict'; 7493 6632 7494 66337495 -1 /**7496 -1 * new Ruler()7497 -1 **/7498 -1 function Ruler() {7499 -1 // List of added rules. Each element is:7500 -1 //7501 -1 // {7502 -1 // name: XXX,7503 -1 // enabled: Boolean,7504 -1 // fn: Function(),7505 -1 // alt: [ name2, name3 ]7506 -1 // }7507 -1 //7508 -1 this.__rules__ = [];-1 6634 module.exports = [ -1 6635 'address', -1 6636 'article', -1 6637 'aside', -1 6638 'base', -1 6639 'basefont', -1 6640 'blockquote', -1 6641 'body', -1 6642 'caption', -1 6643 'center', -1 6644 'col', -1 6645 'colgroup', -1 6646 'dd', -1 6647 'details', -1 6648 'dialog', -1 6649 'dir', -1 6650 'div', -1 6651 'dl', -1 6652 'dt', -1 6653 'fieldset', -1 6654 'figcaption', -1 6655 'figure', -1 6656 'footer', -1 6657 'form', -1 6658 'frame', -1 6659 'frameset', -1 6660 'h1', -1 6661 'head', -1 6662 'header', -1 6663 'hr', -1 6664 'html', -1 6665 'iframe', -1 6666 'legend', -1 6667 'li', -1 6668 'link', -1 6669 'main', -1 6670 'menu', -1 6671 'menuitem', -1 6672 'meta', -1 6673 'nav', -1 6674 'noframes', -1 6675 'ol', -1 6676 'optgroup', -1 6677 'option', -1 6678 'p', -1 6679 'param', -1 6680 'pre', -1 6681 'section', -1 6682 'source', -1 6683 'title', -1 6684 'summary', -1 6685 'table', -1 6686 'tbody', -1 6687 'td', -1 6688 'tfoot', -1 6689 'th', -1 6690 'thead', -1 6691 'title', -1 6692 'tr', -1 6693 'track', -1 6694 'ul' -1 6695 ]; 7509 66967510 -1 // Cached rule chains.7511 -1 //7512 -1 // First level - chain name, '' for default.7513 -1 // Second level - diginal anchor for fast filtering by charcodes.7514 -1 //7515 -1 this.__cache__ = null;7516 -1 }-1 6697 },{}],39:[function(require,module,exports){ -1 6698 // Regexps to match html elements 7517 66997518 -1 ////////////////////////////////////////////////////////////////////////////////7519 -1 // Helper methods, should not be used directly-1 6700 'use strict'; 7520 6701 -1 6702 var attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*'; 7521 67037522 -1 // Find rule index by name7523 -1 //7524 -1 Ruler.prototype.__find__ = function (name) {7525 -1 for (var i = 0; i < this.__rules__.length; i++) {7526 -1 if (this.__rules__[i].name === name) {7527 -1 return i;7528 -1 }7529 -1 }7530 -1 return -1;7531 -1 };-1 6704 var unquoted = '[^"\'=<>`\\x00-\\x20]+'; -1 6705 var single_quoted = "'[^']*'"; -1 6706 var double_quoted = '"[^"]*"'; 7532 6707 -1 6708 var attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')'; 7533 67097534 -1 // Build rules lookup cache7535 -1 //7536 -1 Ruler.prototype.__compile__ = function () {7537 -1 var self = this;7538 -1 var chains = [ '' ];-1 6710 var attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)'; 7539 67117540 -1 // collect unique names7541 -1 self.__rules__.forEach(function (rule) {7542 -1 if (!rule.enabled) { return; }-1 6712 var open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>'; 7543 67137544 -1 rule.alt.forEach(function (altName) {7545 -1 if (chains.indexOf(altName) < 0) {7546 -1 chains.push(altName);7547 -1 }7548 -1 });7549 -1 });-1 6714 var close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>'; -1 6715 var comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->'; -1 6716 var processing = '<[?].*?[?]>'; -1 6717 var declaration = '<![A-Z]+\\s+[^>]*>'; -1 6718 var cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'; 7550 67197551 -1 self.__cache__ = {};-1 6720 var HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment + -1 6721 '|' + processing + '|' + declaration + '|' + cdata + ')'); -1 6722 var HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')'); 7552 67237553 -1 chains.forEach(function (chain) {7554 -1 self.__cache__[chain] = [];7555 -1 self.__rules__.forEach(function (rule) {7556 -1 if (!rule.enabled) { return; }-1 6724 module.exports.HTML_TAG_RE = HTML_TAG_RE; -1 6725 module.exports.HTML_OPEN_CLOSE_TAG_RE = HTML_OPEN_CLOSE_TAG_RE; 7557 67267558 -1 if (chain && rule.alt.indexOf(chain) < 0) { return; }-1 6727 },{}],40:[function(require,module,exports){ -1 6728 // Utilities -1 6729 // -1 6730 'use strict'; 7559 67317560 -1 self.__cache__[chain].push(rule.fn);7561 -1 });7562 -1 });7563 -1 };7564 6732 -1 6733 function _class(obj) { return Object.prototype.toString.call(obj); } 7565 67347566 -1 /**7567 -1 * Ruler.at(name, fn [, options])7568 -1 * - name (String): rule name to replace.7569 -1 * - fn (Function): new rule function.7570 -1 * - options (Object): new rule options (not mandatory).7571 -1 *7572 -1 * Replace rule by name with new function & options. Throws error if name not7573 -1 * found.7574 -1 *7575 -1 * ##### Options:7576 -1 *7577 -1 * - __alt__ - array with names of "alternate" chains.7578 -1 *7579 -1 * ##### Example7580 -1 *7581 -1 * Replace existing typorgapher replacement rule with new one:7582 -1 *7583 -1 * ```javascript7584 -1 * var md = require('markdown-it')();7585 -1 *7586 -1 * md.core.ruler.at('replacements', function replace(state) {7587 -1 * //...7588 -1 * });7589 -1 * ```7590 -1 **/7591 -1 Ruler.prototype.at = function (name, fn, options) {7592 -1 var index = this.__find__(name);7593 -1 var opt = options || {};-1 6735 function isString(obj) { return _class(obj) === '[object String]'; } 7594 67367595 -1 if (index === -1) { throw new Error('Parser rule not found: ' + name); }-1 6737 var _hasOwnProperty = Object.prototype.hasOwnProperty; 7596 67387597 -1 this.__rules__[index].fn = fn;7598 -1 this.__rules__[index].alt = opt.alt || [];7599 -1 this.__cache__ = null;7600 -1 };-1 6739 function has(object, key) { -1 6740 return _hasOwnProperty.call(object, key); -1 6741 } 7601 6742 -1 6743 // Merge objects -1 6744 // -1 6745 function assign(obj /*from1, from2, from3, ...*/) { -1 6746 var sources = Array.prototype.slice.call(arguments, 1); 7602 67477603 -1 /**7604 -1 * Ruler.before(beforeName, ruleName, fn [, options])7605 -1 * - beforeName (String): new rule will be added before this one.7606 -1 * - ruleName (String): name of added rule.7607 -1 * - fn (Function): rule function.7608 -1 * - options (Object): rule options (not mandatory).7609 -1 *7610 -1 * Add new rule to chain before one with given name. See also7611 -1 * [[Ruler.after]], [[Ruler.push]].7612 -1 *7613 -1 * ##### Options:7614 -1 *7615 -1 * - __alt__ - array with names of "alternate" chains.7616 -1 *7617 -1 * ##### Example7618 -1 *7619 -1 * ```javascript7620 -1 * var md = require('markdown-it')();7621 -1 *7622 -1 * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {7623 -1 * //...7624 -1 * });7625 -1 * ```7626 -1 **/7627 -1 Ruler.prototype.before = function (beforeName, ruleName, fn, options) {7628 -1 var index = this.__find__(beforeName);7629 -1 var opt = options || {};-1 6748 sources.forEach(function (source) { -1 6749 if (!source) { return; } 7630 67507631 -1 if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); }-1 6751 if (typeof source !== 'object') { -1 6752 throw new TypeError(source + 'must be object'); -1 6753 } 7632 67547633 -1 this.__rules__.splice(index, 0, {7634 -1 name: ruleName,7635 -1 enabled: true,7636 -1 fn: fn,7637 -1 alt: opt.alt || []-1 6755 Object.keys(source).forEach(function (key) { -1 6756 obj[key] = source[key]; -1 6757 }); 7638 6758 }); 7639 67597640 -1 this.__cache__ = null;7641 -1 };-1 6760 return obj; -1 6761 } 7642 6762 -1 6763 // Remove element from array and put another array at those position. -1 6764 // Useful for some operations with tokens -1 6765 function arrayReplaceAt(src, pos, newElements) { -1 6766 return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1)); -1 6767 } 7643 67687644 -1 /**7645 -1 * Ruler.after(afterName, ruleName, fn [, options])7646 -1 * - afterName (String): new rule will be added after this one.7647 -1 * - ruleName (String): name of added rule.7648 -1 * - fn (Function): rule function.7649 -1 * - options (Object): rule options (not mandatory).7650 -1 *7651 -1 * Add new rule to chain after one with given name. See also7652 -1 * [[Ruler.before]], [[Ruler.push]].7653 -1 *7654 -1 * ##### Options:7655 -1 *7656 -1 * - __alt__ - array with names of "alternate" chains.7657 -1 *7658 -1 * ##### Example7659 -1 *7660 -1 * ```javascript7661 -1 * var md = require('markdown-it')();7662 -1 *7663 -1 * md.inline.ruler.after('text', 'my_rule', function replace(state) {7664 -1 * //...7665 -1 * });7666 -1 * ```7667 -1 **/7668 -1 Ruler.prototype.after = function (afterName, ruleName, fn, options) {7669 -1 var index = this.__find__(afterName);7670 -1 var opt = options || {};-1 6769 //////////////////////////////////////////////////////////////////////////////// 7671 67707672 -1 if (index === -1) { throw new Error('Parser rule not found: ' + afterName); }-1 6771 function isValidEntityCode(c) { -1 6772 /*eslint no-bitwise:0*/ -1 6773 // broken sequence -1 6774 if (c >= 0xD800 && c <= 0xDFFF) { return false; } -1 6775 // never used -1 6776 if (c >= 0xFDD0 && c <= 0xFDEF) { return false; } -1 6777 if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; } -1 6778 // control codes -1 6779 if (c >= 0x00 && c <= 0x08) { return false; } -1 6780 if (c === 0x0B) { return false; } -1 6781 if (c >= 0x0E && c <= 0x1F) { return false; } -1 6782 if (c >= 0x7F && c <= 0x9F) { return false; } -1 6783 // out of range -1 6784 if (c > 0x10FFFF) { return false; } -1 6785 return true; -1 6786 } 7673 67877674 -1 this.__rules__.splice(index + 1, 0, {7675 -1 name: ruleName,7676 -1 enabled: true,7677 -1 fn: fn,7678 -1 alt: opt.alt || []7679 -1 });-1 6788 function fromCodePoint(c) { -1 6789 /*eslint no-bitwise:0*/ -1 6790 if (c > 0xffff) { -1 6791 c -= 0x10000; -1 6792 var surrogate1 = 0xd800 + (c >> 10), -1 6793 surrogate2 = 0xdc00 + (c & 0x3ff); 7680 67947681 -1 this.__cache__ = null;7682 -1 };-1 6795 return String.fromCharCode(surrogate1, surrogate2); -1 6796 } -1 6797 return String.fromCharCode(c); -1 6798 } 7683 67997684 -1 /**7685 -1 * Ruler.push(ruleName, fn [, options])7686 -1 * - ruleName (String): name of added rule.7687 -1 * - fn (Function): rule function.7688 -1 * - options (Object): rule options (not mandatory).7689 -1 *7690 -1 * Push new rule to the end of chain. See also7691 -1 * [[Ruler.before]], [[Ruler.after]].7692 -1 *7693 -1 * ##### Options:7694 -1 *7695 -1 * - __alt__ - array with names of "alternate" chains.7696 -1 *7697 -1 * ##### Example7698 -1 *7699 -1 * ```javascript7700 -1 * var md = require('markdown-it')();7701 -1 *7702 -1 * md.core.ruler.push('my_rule', function replace(state) {7703 -1 * //...7704 -1 * });7705 -1 * ```7706 -1 **/7707 -1 Ruler.prototype.push = function (ruleName, fn, options) {7708 -1 var opt = options || {};7709 68007710 -1 this.__rules__.push({7711 -1 name: ruleName,7712 -1 enabled: true,7713 -1 fn: fn,7714 -1 alt: opt.alt || []7715 -1 });-1 6801 var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g; -1 6802 var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi; -1 6803 var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi'); 7716 68047717 -1 this.__cache__ = null;7718 -1 };-1 6805 var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i; 7719 6806 -1 6807 var entities = require('./entities'); 7720 68087721 -1 /**7722 -1 * Ruler.enable(list [, ignoreInvalid]) -> Array7723 -1 * - list (String|Array): list of rule names to enable.7724 -1 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.7725 -1 *7726 -1 * Enable rules with given names. If any rule name not found - throw Error.7727 -1 * Errors can be disabled by second param.7728 -1 *7729 -1 * Returns list of found rule names (if no exception happened).7730 -1 *7731 -1 * See also [[Ruler.disable]], [[Ruler.enableOnly]].7732 -1 **/7733 -1 Ruler.prototype.enable = function (list, ignoreInvalid) {7734 -1 if (!Array.isArray(list)) { list = [ list ]; }-1 6809 function replaceEntityPattern(match, name) { -1 6810 var code = 0; -1 6811 -1 6812 if (has(entities, name)) { -1 6813 return entities[name]; -1 6814 } -1 6815 -1 6816 if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) { -1 6817 code = name[1].toLowerCase() === 'x' ? -1 6818 parseInt(name.slice(2), 16) -1 6819 : -1 6820 parseInt(name.slice(1), 10); -1 6821 if (isValidEntityCode(code)) { -1 6822 return fromCodePoint(code); -1 6823 } -1 6824 } 7735 68257736 -1 var result = [];-1 6826 return match; -1 6827 } 7737 68287738 -1 // Search by name and enable7739 -1 list.forEach(function (name) {7740 -1 var idx = this.__find__(name);-1 6829 /*function replaceEntities(str) { -1 6830 if (str.indexOf('&') < 0) { return str; } 7741 68317742 -1 if (idx < 0) {7743 -1 if (ignoreInvalid) { return; }7744 -1 throw new Error('Rules manager: invalid rule name ' + name);7745 -1 }7746 -1 this.__rules__[idx].enabled = true;7747 -1 result.push(name);7748 -1 }, this);-1 6832 return str.replace(ENTITY_RE, replaceEntityPattern); -1 6833 }*/ 7749 68347750 -1 this.__cache__ = null;7751 -1 return result;7752 -1 };-1 6835 function unescapeMd(str) { -1 6836 if (str.indexOf('\\') < 0) { return str; } -1 6837 return str.replace(UNESCAPE_MD_RE, '$1'); -1 6838 } 7753 6839 -1 6840 function unescapeAll(str) { -1 6841 if (str.indexOf('\\') < 0 && str.indexOf('&') < 0) { return str; } 7754 68427755 -1 /**7756 -1 * Ruler.enableOnly(list [, ignoreInvalid])7757 -1 * - list (String|Array): list of rule names to enable (whitelist).7758 -1 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.7759 -1 *7760 -1 * Enable rules with given names, and disable everything else. If any rule name7761 -1 * not found - throw Error. Errors can be disabled by second param.7762 -1 *7763 -1 * See also [[Ruler.disable]], [[Ruler.enable]].7764 -1 **/7765 -1 Ruler.prototype.enableOnly = function (list, ignoreInvalid) {7766 -1 if (!Array.isArray(list)) { list = [ list ]; }-1 6843 return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) { -1 6844 if (escaped) { return escaped; } -1 6845 return replaceEntityPattern(match, entity); -1 6846 }); -1 6847 } 7767 68487768 -1 this.__rules__.forEach(function (rule) { rule.enabled = false; });-1 6849 //////////////////////////////////////////////////////////////////////////////// 7769 68507770 -1 this.enable(list, ignoreInvalid);-1 6851 var HTML_ESCAPE_TEST_RE = /[&<>"]/; -1 6852 var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g; -1 6853 var HTML_REPLACEMENTS = { -1 6854 '&': '&', -1 6855 '<': '<', -1 6856 '>': '>', -1 6857 '"': '"' 7771 6858 }; 7772 6859 -1 6860 function replaceUnsafeChar(ch) { -1 6861 return HTML_REPLACEMENTS[ch]; -1 6862 } 7773 68637774 -1 /**7775 -1 * Ruler.disable(list [, ignoreInvalid]) -> Array7776 -1 * - list (String|Array): list of rule names to disable.7777 -1 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.7778 -1 *7779 -1 * Disable rules with given names. If any rule name not found - throw Error.7780 -1 * Errors can be disabled by second param.7781 -1 *7782 -1 * Returns list of found rule names (if no exception happened).7783 -1 *7784 -1 * See also [[Ruler.enable]], [[Ruler.enableOnly]].7785 -1 **/7786 -1 Ruler.prototype.disable = function (list, ignoreInvalid) {7787 -1 if (!Array.isArray(list)) { list = [ list ]; }-1 6864 function escapeHtml(str) { -1 6865 if (HTML_ESCAPE_TEST_RE.test(str)) { -1 6866 return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar); -1 6867 } -1 6868 return str; -1 6869 } 7788 68707789 -1 var result = [];-1 6871 //////////////////////////////////////////////////////////////////////////////// 7790 68727791 -1 // Search by name and disable7792 -1 list.forEach(function (name) {7793 -1 var idx = this.__find__(name);-1 6873 var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g; 7794 68747795 -1 if (idx < 0) {7796 -1 if (ignoreInvalid) { return; }7797 -1 throw new Error('Rules manager: invalid rule name ' + name);7798 -1 }7799 -1 this.__rules__[idx].enabled = false;7800 -1 result.push(name);7801 -1 }, this);-1 6875 function escapeRE(str) { -1 6876 return str.replace(REGEXP_ESCAPE_RE, '\\$&'); -1 6877 } 7802 68787803 -1 this.__cache__ = null;7804 -1 return result;7805 -1 };-1 6879 //////////////////////////////////////////////////////////////////////////////// 7806 6880 -1 6881 function isSpace(code) { -1 6882 switch (code) { -1 6883 case 0x09: -1 6884 case 0x20: -1 6885 return true; -1 6886 } -1 6887 return false; -1 6888 } 7807 68897808 -1 /**7809 -1 * Ruler.getRules(chainName) -> Array7810 -1 *7811 -1 * Return array of active functions (rules) for given chain name. It analyzes7812 -1 * rules configuration, compiles caches if not exists and returns result.7813 -1 *7814 -1 * Default chain name is `''` (empty string). It can't be skipped. That's7815 -1 * done intentionally, to keep signature monomorphic for high speed.7816 -1 **/7817 -1 Ruler.prototype.getRules = function (chainName) {7818 -1 if (this.__cache__ === null) {7819 -1 this.__compile__();-1 6890 // Zs (unicode class) || [\t\f\v\r\n] -1 6891 function isWhiteSpace(code) { -1 6892 if (code >= 0x2000 && code <= 0x200A) { return true; } -1 6893 switch (code) { -1 6894 case 0x09: // \t -1 6895 case 0x0A: // \n -1 6896 case 0x0B: // \v -1 6897 case 0x0C: // \f -1 6898 case 0x0D: // \r -1 6899 case 0x20: -1 6900 case 0xA0: -1 6901 case 0x1680: -1 6902 case 0x202F: -1 6903 case 0x205F: -1 6904 case 0x3000: -1 6905 return true; 7820 6906 } -1 6907 return false; -1 6908 } 7821 69097822 -1 // Chain can be empty, if rules disabled. But we still have to return Array.7823 -1 return this.__cache__[chainName] || [];7824 -1 };-1 6910 //////////////////////////////////////////////////////////////////////////////// 7825 69117826 -1 module.exports = Ruler;-1 6912 /*eslint-disable max-len*/ -1 6913 var UNICODE_PUNCT_RE = require('uc.micro/categories/P/regex'); 7827 69147828 -1 },{}],57:[function(require,module,exports){7829 -1 // Block quotes-1 6915 // Currently without astral characters support. -1 6916 function isPunctChar(ch) { -1 6917 return UNICODE_PUNCT_RE.test(ch); -1 6918 } 7830 69197831 -1 'use strict';7832 69207833 -1 var isSpace = require('../common/utils').isSpace;-1 6921 // Markdown ASCII punctuation characters. -1 6922 // -1 6923 // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~ -1 6924 // http://spec.commonmark.org/0.15/#ascii-punctuation-character -1 6925 // -1 6926 // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range. -1 6927 // -1 6928 function isMdAsciiPunct(ch) { -1 6929 switch (ch) { -1 6930 case 0x21/* ! */: -1 6931 case 0x22/* " */: -1 6932 case 0x23/* # */: -1 6933 case 0x24/* $ */: -1 6934 case 0x25/* % */: -1 6935 case 0x26/* & */: -1 6936 case 0x27/* ' */: -1 6937 case 0x28/* ( */: -1 6938 case 0x29/* ) */: -1 6939 case 0x2A/* * */: -1 6940 case 0x2B/* + */: -1 6941 case 0x2C/* , */: -1 6942 case 0x2D/* - */: -1 6943 case 0x2E/* . */: -1 6944 case 0x2F/* / */: -1 6945 case 0x3A/* : */: -1 6946 case 0x3B/* ; */: -1 6947 case 0x3C/* < */: -1 6948 case 0x3D/* = */: -1 6949 case 0x3E/* > */: -1 6950 case 0x3F/* ? */: -1 6951 case 0x40/* @ */: -1 6952 case 0x5B/* [ */: -1 6953 case 0x5C/* \ */: -1 6954 case 0x5D/* ] */: -1 6955 case 0x5E/* ^ */: -1 6956 case 0x5F/* _ */: -1 6957 case 0x60/* ` */: -1 6958 case 0x7B/* { */: -1 6959 case 0x7C/* | */: -1 6960 case 0x7D/* } */: -1 6961 case 0x7E/* ~ */: -1 6962 return true; -1 6963 default: -1 6964 return false; -1 6965 } -1 6966 } 7834 6967 -1 6968 // Hepler to unify [reference labels]. -1 6969 // -1 6970 function normalizeReference(str) { -1 6971 // use .toUpperCase() instead of .toLowerCase() -1 6972 // here to avoid a conflict with Object.prototype -1 6973 // members (most notably, `__proto__`) -1 6974 return str.trim().replace(/\s+/g, ' ').toUpperCase(); -1 6975 } 7835 69767836 -1 module.exports = function blockquote(state, startLine, endLine, silent) {7837 -1 var nextLine, lastLineEmpty, oldTShift, oldSCount, oldBMarks, oldIndent, oldParentType, lines, initial, offset, ch,7838 -1 terminatorRules, token,7839 -1 i, l, terminate,7840 -1 pos = state.bMarks[startLine] + state.tShift[startLine],7841 -1 max = state.eMarks[startLine];-1 6977 //////////////////////////////////////////////////////////////////////////////// 7842 69787843 -1 // check the block quote marker7844 -1 if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }-1 6979 // Re-export libraries commonly used in both markdown-it and its plugins, -1 6980 // so plugins won't have to depend on them explicitly, which reduces their -1 6981 // bundled size (e.g. a browser build). -1 6982 // -1 6983 exports.lib = {}; -1 6984 exports.lib.mdurl = require('mdurl'); -1 6985 exports.lib.ucmicro = require('uc.micro'); 7845 69867846 -1 // we know that it's going to be a valid blockquote,7847 -1 // so no point trying to find the end of it in silent mode7848 -1 if (silent) { return true; }-1 6987 exports.assign = assign; -1 6988 exports.isString = isString; -1 6989 exports.has = has; -1 6990 exports.unescapeMd = unescapeMd; -1 6991 exports.unescapeAll = unescapeAll; -1 6992 exports.isValidEntityCode = isValidEntityCode; -1 6993 exports.fromCodePoint = fromCodePoint; -1 6994 // exports.replaceEntities = replaceEntities; -1 6995 exports.escapeHtml = escapeHtml; -1 6996 exports.arrayReplaceAt = arrayReplaceAt; -1 6997 exports.isSpace = isSpace; -1 6998 exports.isWhiteSpace = isWhiteSpace; -1 6999 exports.isMdAsciiPunct = isMdAsciiPunct; -1 7000 exports.isPunctChar = isPunctChar; -1 7001 exports.escapeRE = escapeRE; -1 7002 exports.normalizeReference = normalizeReference; 7849 70037850 -1 // skip one optional space (but not tab, check cmark impl) after '>'7851 -1 if (state.src.charCodeAt(pos) === 0x20) { pos++; }-1 7004 },{"./entities":37,"mdurl":91,"uc.micro":117,"uc.micro/categories/P/regex":115}],41:[function(require,module,exports){ -1 7005 // Just a shortcut for bulk export -1 7006 'use strict'; -1 7007 -1 7008 -1 7009 exports.parseLinkLabel = require('./parse_link_label'); -1 7010 exports.parseLinkDestination = require('./parse_link_destination'); -1 7011 exports.parseLinkTitle = require('./parse_link_title'); 7852 70127853 -1 oldIndent = state.blkIndent;7854 -1 state.blkIndent = 0;-1 7013 },{"./parse_link_destination":42,"./parse_link_label":43,"./parse_link_title":44}],42:[function(require,module,exports){ -1 7014 // Parse link destination -1 7015 // -1 7016 'use strict'; 7855 70177856 -1 // skip spaces after ">" and re-calculate offset7857 -1 initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);7858 70187859 -1 oldBMarks = [ state.bMarks[startLine] ];7860 -1 state.bMarks[startLine] = pos;-1 7019 var isSpace = require('../common/utils').isSpace; -1 7020 var unescapeAll = require('../common/utils').unescapeAll; 7861 70217862 -1 while (pos < max) {7863 -1 ch = state.src.charCodeAt(pos);7864 70227865 -1 if (isSpace(ch)) {7866 -1 if (ch === 0x09) {7867 -1 offset += 4 - offset % 4;7868 -1 } else {7869 -1 offset++;-1 7023 module.exports = function parseLinkDestination(str, pos, max) { -1 7024 var code, level, -1 7025 lines = 0, -1 7026 start = pos, -1 7027 result = { -1 7028 ok: false, -1 7029 pos: 0, -1 7030 lines: 0, -1 7031 str: '' -1 7032 }; -1 7033 -1 7034 if (str.charCodeAt(pos) === 0x3C /* < */) { -1 7035 pos++; -1 7036 while (pos < max) { -1 7037 code = str.charCodeAt(pos); -1 7038 if (code === 0x0A /* \n */ || isSpace(code)) { return result; } -1 7039 if (code === 0x3E /* > */) { -1 7040 result.pos = pos + 1; -1 7041 result.str = unescapeAll(str.slice(start + 1, pos)); -1 7042 result.ok = true; -1 7043 return result; 7870 7044 }7871 -1 } else {7872 -1 break;-1 7045 if (code === 0x5C /* \ */ && pos + 1 < max) { -1 7046 pos += 2; -1 7047 continue; -1 7048 } -1 7049 -1 7050 pos++; 7873 7051 } 7874 70527875 -1 pos++;-1 7053 // no closing '>' -1 7054 return result; 7876 7055 } 7877 70567878 -1 lastLineEmpty = pos >= max;-1 7057 // this should be ... } else { ... branch 7879 70587880 -1 oldSCount = [ state.sCount[startLine] ];7881 -1 state.sCount[startLine] = offset - initial;-1 7059 level = 0; -1 7060 while (pos < max) { -1 7061 code = str.charCodeAt(pos); 7882 70627883 -1 oldTShift = [ state.tShift[startLine] ];7884 -1 state.tShift[startLine] = pos - state.bMarks[startLine];-1 7063 if (code === 0x20) { break; } 7885 70647886 -1 terminatorRules = state.md.block.ruler.getRules('blockquote');-1 7065 // ascii control characters -1 7066 if (code < 0x20 || code === 0x7F) { break; } 7887 70677888 -1 // Search the end of the block7889 -1 //7890 -1 // Block ends with either:7891 -1 // 1. an empty line outside:7892 -1 // ```7893 -1 // > test7894 -1 //7895 -1 // ```7896 -1 // 2. an empty line inside:7897 -1 // ```7898 -1 // >7899 -1 // test7900 -1 // ```7901 -1 // 3. another tag7902 -1 // ```7903 -1 // > test7904 -1 // - - -7905 -1 // ```7906 -1 for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {7907 -1 if (state.sCount[nextLine] < oldIndent) { break; }-1 7068 if (code === 0x5C /* \ */ && pos + 1 < max) { -1 7069 pos += 2; -1 7070 continue; -1 7071 } 7908 70727909 -1 pos = state.bMarks[nextLine] + state.tShift[nextLine];7910 -1 max = state.eMarks[nextLine];-1 7073 if (code === 0x28 /* ( */) { -1 7074 level++; -1 7075 if (level > 1) { break; } -1 7076 } 7911 70777912 -1 if (pos >= max) {7913 -1 // Case 1: line is not inside the blockquote, and this line is empty.7914 -1 break;-1 7078 if (code === 0x29 /* ) */) { -1 7079 level--; -1 7080 if (level < 0) { break; } 7915 7081 } 7916 70827917 -1 if (state.src.charCodeAt(pos++) === 0x3E/* > */) {7918 -1 // This line is inside the blockquote.-1 7083 pos++; -1 7084 } 7919 70857920 -1 // skip one optional space (but not tab, check cmark impl) after '>'7921 -1 if (state.src.charCodeAt(pos) === 0x20) { pos++; }-1 7086 if (start === pos) { return result; } 7922 70877923 -1 // skip spaces after ">" and re-calculate offset7924 -1 initial = offset = state.sCount[nextLine] + pos - (state.bMarks[nextLine] + state.tShift[nextLine]);-1 7088 result.str = unescapeAll(str.slice(start, pos)); -1 7089 result.lines = lines; -1 7090 result.pos = pos; -1 7091 result.ok = true; -1 7092 return result; -1 7093 }; 7925 70947926 -1 oldBMarks.push(state.bMarks[nextLine]);7927 -1 state.bMarks[nextLine] = pos;-1 7095 },{"../common/utils":40}],43:[function(require,module,exports){ -1 7096 // Parse link label -1 7097 // -1 7098 // this function assumes that first character ("[") already matches; -1 7099 // returns the end of the label -1 7100 // -1 7101 'use strict'; 7928 71027929 -1 while (pos < max) {7930 -1 ch = state.src.charCodeAt(pos);-1 7103 module.exports = function parseLinkLabel(state, start, disableNested) { -1 7104 var level, found, marker, prevPos, -1 7105 labelEnd = -1, -1 7106 max = state.posMax, -1 7107 oldPos = state.pos; 7931 71087932 -1 if (isSpace(ch)) {7933 -1 if (ch === 0x09) {7934 -1 offset += 4 - offset % 4;7935 -1 } else {7936 -1 offset++;7937 -1 }7938 -1 } else {7939 -1 break;7940 -1 }-1 7109 state.pos = start + 1; -1 7110 level = 1; 7941 71117942 -1 pos++;-1 7112 while (state.pos < max) { -1 7113 marker = state.src.charCodeAt(state.pos); -1 7114 if (marker === 0x5D /* ] */) { -1 7115 level--; -1 7116 if (level === 0) { -1 7117 found = true; -1 7118 break; 7943 7119 }7944 -17945 -1 lastLineEmpty = pos >= max;7946 -17947 -1 oldSCount.push(state.sCount[nextLine]);7948 -1 state.sCount[nextLine] = offset - initial;7949 -17950 -1 oldTShift.push(state.tShift[nextLine]);7951 -1 state.tShift[nextLine] = pos - state.bMarks[nextLine];7952 -1 continue;7953 7120 } 7954 71217955 -1 // Case 2: line is not inside the blockquote, and the last line was empty.7956 -1 if (lastLineEmpty) { break; }7957 -17958 -1 // Case 3: another tag found.7959 -1 terminate = false;7960 -1 for (i = 0, l = terminatorRules.length; i < l; i++) {7961 -1 if (terminatorRules[i](state, nextLine, endLine, true)) {7962 -1 terminate = true;7963 -1 break;-1 7122 prevPos = state.pos; -1 7123 state.md.inline.skipToken(state); -1 7124 if (marker === 0x5B /* [ */) { -1 7125 if (prevPos === state.pos - 1) { -1 7126 // increase level if we find text `[`, which is not a part of any token -1 7127 level++; -1 7128 } else if (disableNested) { -1 7129 state.pos = oldPos; -1 7130 return -1; 7964 7131 } 7965 7132 }7966 -1 if (terminate) { break; }7967 -17968 -1 oldBMarks.push(state.bMarks[nextLine]);7969 -1 oldTShift.push(state.tShift[nextLine]);7970 -1 oldSCount.push(state.sCount[nextLine]);7971 -17972 -1 // A negative indentation means that this is a paragraph continuation7973 -1 //7974 -1 state.sCount[nextLine] = -1;7975 7133 } 7976 71347977 -1 oldParentType = state.parentType;7978 -1 state.parentType = 'blockquote';7979 -17980 -1 token = state.push('blockquote_open', 'blockquote', 1);7981 -1 token.markup = '>';7982 -1 token.map = lines = [ startLine, 0 ];-1 7135 if (found) { -1 7136 labelEnd = state.pos; -1 7137 } 7983 71387984 -1 state.md.block.tokenize(state, startLine, nextLine);-1 7139 // restore old state -1 7140 state.pos = oldPos; 7985 71417986 -1 token = state.push('blockquote_close', 'blockquote', -1);7987 -1 token.markup = '>';-1 7142 return labelEnd; -1 7143 }; 7988 71447989 -1 state.parentType = oldParentType;7990 -1 lines[1] = state.line;-1 7145 },{}],44:[function(require,module,exports){ -1 7146 // Parse link title -1 7147 // -1 7148 'use strict'; 7991 71497992 -1 // Restore original tShift; this might not be necessary since the parser7993 -1 // has already been here, but just to make sure we can do that.7994 -1 for (i = 0; i < oldTShift.length; i++) {7995 -1 state.bMarks[i + startLine] = oldBMarks[i];7996 -1 state.tShift[i + startLine] = oldTShift[i];7997 -1 state.sCount[i + startLine] = oldSCount[i];7998 -1 }7999 -1 state.blkIndent = oldIndent;8000 71508001 -1 return true;8002 -1 };-1 7151 var unescapeAll = require('../common/utils').unescapeAll; 8003 71528004 -1 },{"../common/utils":43}],58:[function(require,module,exports){8005 -1 // Code block (4 spaces padded)8006 71538007 -1 'use strict';-1 7154 module.exports = function parseLinkTitle(str, pos, max) { -1 7155 var code, -1 7156 marker, -1 7157 lines = 0, -1 7158 start = pos, -1 7159 result = { -1 7160 ok: false, -1 7161 pos: 0, -1 7162 lines: 0, -1 7163 str: '' -1 7164 }; 8008 7165 -1 7166 if (pos >= max) { return result; } 8009 71678010 -1 module.exports = function code(state, startLine, endLine/*, silent*/) {8011 -1 var nextLine, last, token, emptyLines = 0;-1 7168 marker = str.charCodeAt(pos); 8012 71698013 -1 if (state.sCount[startLine] - state.blkIndent < 4) { return false; }-1 7170 if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result; } 8014 71718015 -1 last = nextLine = startLine + 1;-1 7172 pos++; 8016 71738017 -1 while (nextLine < endLine) {8018 -1 if (state.isEmpty(nextLine)) {8019 -1 emptyLines++;-1 7174 // if opening marker is "(", switch it to closing marker ")" -1 7175 if (marker === 0x28) { marker = 0x29; } 8020 71768021 -1 // workaround for lists: 2 blank lines should terminate indented8022 -1 // code block, but not fenced code block8023 -1 if (emptyLines >= 2 && state.parentType === 'list') {8024 -1 break;-1 7177 while (pos < max) { -1 7178 code = str.charCodeAt(pos); -1 7179 if (code === marker) { -1 7180 result.pos = pos + 1; -1 7181 result.lines = lines; -1 7182 result.str = unescapeAll(str.slice(start + 1, pos)); -1 7183 result.ok = true; -1 7184 return result; -1 7185 } else if (code === 0x0A) { -1 7186 lines++; -1 7187 } else if (code === 0x5C /* \ */ && pos + 1 < max) { -1 7188 pos++; -1 7189 if (str.charCodeAt(pos) === 0x0A) { -1 7190 lines++; 8025 7191 }8026 -18027 -1 nextLine++;8028 -1 continue;8029 7192 } 8030 71938031 -1 emptyLines = 0;8032 -18033 -1 if (state.sCount[nextLine] - state.blkIndent >= 4) {8034 -1 nextLine++;8035 -1 last = nextLine;8036 -1 continue;8037 -1 }8038 -1 break;-1 7194 pos++; 8039 7195 } 8040 71968041 -1 state.line = last;8042 -18043 -1 token = state.push('code_block', 'code', 0);8044 -1 token.content = state.getLines(startLine, last, 4 + state.blkIndent, true);8045 -1 token.map = [ startLine, state.line ];8046 -18047 -1 return true;-1 7197 return result; 8048 7198 }; 8049 71998050 -1 },{}],59:[function(require,module,exports){8051 -1 // fences (``` lang, ~~~ lang)-1 7200 },{"../common/utils":40}],45:[function(require,module,exports){ -1 7201 // Main parser class 8052 7202 8053 7203 'use strict'; 8054 7204 8055 72058056 -1 module.exports = function fence(state, startLine, endLine, silent) {8057 -1 var marker, len, params, nextLine, mem, token, markup,8058 -1 haveEndMarker = false,8059 -1 pos = state.bMarks[startLine] + state.tShift[startLine],8060 -1 max = state.eMarks[startLine];-1 7206 var utils = require('./common/utils'); -1 7207 var helpers = require('./helpers'); -1 7208 var Renderer = require('./renderer'); -1 7209 var ParserCore = require('./parser_core'); -1 7210 var ParserBlock = require('./parser_block'); -1 7211 var ParserInline = require('./parser_inline'); -1 7212 var LinkifyIt = require('linkify-it'); -1 7213 var mdurl = require('mdurl'); -1 7214 var punycode = require('punycode'); 8061 72158062 -1 if (pos + 3 > max) { return false; }8063 72168064 -1 marker = state.src.charCodeAt(pos);-1 7217 var config = { -1 7218 'default': require('./presets/default'), -1 7219 zero: require('./presets/zero'), -1 7220 commonmark: require('./presets/commonmark') -1 7221 }; 8065 72228066 -1 if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {8067 -1 return false;8068 -1 }-1 7223 //////////////////////////////////////////////////////////////////////////////// -1 7224 // -1 7225 // This validator can prohibit more than really needed to prevent XSS. It's a -1 7226 // tradeoff to keep code simple and to be secure by default. -1 7227 // -1 7228 // If you need different setup - override validator method as you wish. Or -1 7229 // replace it with dummy function and use external sanitizer. -1 7230 // 8069 72318070 -1 // scan marker length8071 -1 mem = pos;8072 -1 pos = state.skipChars(pos, marker);-1 7232 var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/; -1 7233 var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/; 8073 72348074 -1 len = pos - mem;-1 7235 function validateLink(url) { -1 7236 // url should be normalized at this point, and existing entities are decoded -1 7237 var str = url.trim().toLowerCase(); 8075 72388076 -1 if (len < 3) { return false; }-1 7239 return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true; -1 7240 } 8077 72418078 -1 markup = state.src.slice(mem, pos);8079 -1 params = state.src.slice(pos, max);-1 7242 //////////////////////////////////////////////////////////////////////////////// 8080 72438081 -1 if (params.indexOf('`') >= 0) { return false; }8082 72448083 -1 // Since start is found, we can report success here in validation mode8084 -1 if (silent) { return true; }-1 7245 var RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ]; 8085 72468086 -1 // search end of block8087 -1 nextLine = startLine;-1 7247 function normalizeLink(url) { -1 7248 var parsed = mdurl.parse(url, true); 8088 72498089 -1 for (;;) {8090 -1 nextLine++;8091 -1 if (nextLine >= endLine) {8092 -1 // unclosed block should be autoclosed by end of document.8093 -1 // also block seems to be autoclosed by end of parent8094 -1 break;-1 7250 if (parsed.hostname) { -1 7251 // Encode hostnames in urls like: -1 7252 // `http://host/`, `https://host/`, `mailto:user@host`, `//host/` -1 7253 // -1 7254 // We don't encode unknown schemas, because it's likely that we encode -1 7255 // something we shouldn't (e.g. `skype:name` treated as `skype:host`) -1 7256 // -1 7257 if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) { -1 7258 try { -1 7259 parsed.hostname = punycode.toASCII(parsed.hostname); -1 7260 } catch (er) { /**/ } 8095 7261 } -1 7262 } 8096 72638097 -1 pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];8098 -1 max = state.eMarks[nextLine];-1 7264 return mdurl.encode(mdurl.format(parsed)); -1 7265 } -1 7266 -1 7267 function normalizeLinkText(url) { -1 7268 var parsed = mdurl.parse(url, true); -1 7269 -1 7270 if (parsed.hostname) { -1 7271 // Encode hostnames in urls like: -1 7272 // `http://host/`, `https://host/`, `mailto:user@host`, `//host/` -1 7273 // -1 7274 // We don't encode unknown schemas, because it's likely that we encode -1 7275 // something we shouldn't (e.g. `skype:name` treated as `skype:host`) -1 7276 // -1 7277 if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) { -1 7278 try { -1 7279 parsed.hostname = punycode.toUnicode(parsed.hostname); -1 7280 } catch (er) { /**/ } -1 7281 } -1 7282 } -1 7283 -1 7284 return mdurl.decode(mdurl.format(parsed)); -1 7285 } -1 7286 -1 7287 -1 7288 /** -1 7289 * class MarkdownIt -1 7290 * -1 7291 * Main parser/renderer class. -1 7292 * -1 7293 * ##### Usage -1 7294 * -1 7295 * ```javascript -1 7296 * // node.js, "classic" way: -1 7297 * var MarkdownIt = require('markdown-it'), -1 7298 * md = new MarkdownIt(); -1 7299 * var result = md.render('# markdown-it rulezz!'); -1 7300 * -1 7301 * // node.js, the same, but with sugar: -1 7302 * var md = require('markdown-it')(); -1 7303 * var result = md.render('# markdown-it rulezz!'); -1 7304 * -1 7305 * // browser without AMD, added to "window" on script load -1 7306 * // Note, there are no dash. -1 7307 * var md = window.markdownit(); -1 7308 * var result = md.render('# markdown-it rulezz!'); -1 7309 * ``` -1 7310 * -1 7311 * Single line rendering, without paragraph wrap: -1 7312 * -1 7313 * ```javascript -1 7314 * var md = require('markdown-it')(); -1 7315 * var result = md.renderInline('__markdown-it__ rulezz!'); -1 7316 * ``` -1 7317 **/ -1 7318 -1 7319 /** -1 7320 * new MarkdownIt([presetName, options]) -1 7321 * - presetName (String): optional, `commonmark` / `zero` -1 7322 * - options (Object) -1 7323 * -1 7324 * Creates parser instanse with given config. Can be called without `new`. -1 7325 * -1 7326 * ##### presetName -1 7327 * -1 7328 * MarkdownIt provides named presets as a convenience to quickly -1 7329 * enable/disable active syntax rules and options for common use cases. -1 7330 * -1 7331 * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) - -1 7332 * configures parser to strict [CommonMark](http://commonmark.org/) mode. -1 7333 * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) - -1 7334 * similar to GFM, used when no preset name given. Enables all available rules, -1 7335 * but still without html, typographer & autolinker. -1 7336 * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) - -1 7337 * all rules disabled. Useful to quickly setup your config via `.enable()`. -1 7338 * For example, when you need only `bold` and `italic` markup and nothing else. -1 7339 * -1 7340 * ##### options: -1 7341 * -1 7342 * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful! -1 7343 * That's not safe! You may need external sanitizer to protect output from XSS. -1 7344 * It's better to extend features via plugins, instead of enabling HTML. -1 7345 * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags -1 7346 * (`<br />`). This is needed only for full CommonMark compatibility. In real -1 7347 * world you will need HTML output. -1 7348 * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`. -1 7349 * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks. -1 7350 * Can be useful for external highlighters. -1 7351 * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links. -1 7352 * - __typographer__ - `false`. Set `true` to enable [some language-neutral -1 7353 * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) + -1 7354 * quotes beautification (smartquotes). -1 7355 * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement -1 7356 * pairs, when typographer enabled and smartquotes on. For example, you can -1 7357 * use `'«»„“'` for Russian, `'„“‚‘'` for German, and -1 7358 * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp). -1 7359 * - __highlight__ - `null`. Highlighter function for fenced code blocks. -1 7360 * Highlighter `function (str, lang)` should return escaped HTML. It can also -1 7361 * return empty string if the source was not changed and should be escaped -1 7362 * externaly. If result starts with <pre... internal wrapper is skipped. -1 7363 * -1 7364 * ##### Example -1 7365 * -1 7366 * ```javascript -1 7367 * // commonmark mode -1 7368 * var md = require('markdown-it')('commonmark'); -1 7369 * -1 7370 * // default mode -1 7371 * var md = require('markdown-it')(); -1 7372 * -1 7373 * // enable everything -1 7374 * var md = require('markdown-it')({ -1 7375 * html: true, -1 7376 * linkify: true, -1 7377 * typographer: true -1 7378 * }); -1 7379 * ``` -1 7380 * -1 7381 * ##### Syntax highlighting -1 7382 * -1 7383 * ```js -1 7384 * var hljs = require('highlight.js') // https://highlightjs.org/ -1 7385 * -1 7386 * var md = require('markdown-it')({ -1 7387 * highlight: function (str, lang) { -1 7388 * if (lang && hljs.getLanguage(lang)) { -1 7389 * try { -1 7390 * return hljs.highlight(lang, str, true).value; -1 7391 * } catch (__) {} -1 7392 * } -1 7393 * -1 7394 * return ''; // use external default escaping -1 7395 * } -1 7396 * }); -1 7397 * ``` -1 7398 * -1 7399 * Or with full wrapper override (if you need assign class to `<pre>`): -1 7400 * -1 7401 * ```javascript -1 7402 * var hljs = require('highlight.js') // https://highlightjs.org/ -1 7403 * -1 7404 * // Actual default values -1 7405 * var md = require('markdown-it')({ -1 7406 * highlight: function (str, lang) { -1 7407 * if (lang && hljs.getLanguage(lang)) { -1 7408 * try { -1 7409 * return '<pre class="hljs"><code>' + -1 7410 * hljs.highlight(lang, str, true).value + -1 7411 * '</code></pre>'; -1 7412 * } catch (__) {} -1 7413 * } -1 7414 * -1 7415 * return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>'; -1 7416 * } -1 7417 * }); -1 7418 * ``` -1 7419 * -1 7420 **/ -1 7421 function MarkdownIt(presetName, options) { -1 7422 if (!(this instanceof MarkdownIt)) { -1 7423 return new MarkdownIt(presetName, options); -1 7424 } 8099 74258100 -1 if (pos < max && state.sCount[nextLine] < state.blkIndent) {8101 -1 // non-empty line with negative indent should stop the list:8102 -1 // - ```8103 -1 // test8104 -1 break;-1 7426 if (!options) { -1 7427 if (!utils.isString(presetName)) { -1 7428 options = presetName || {}; -1 7429 presetName = 'default'; 8105 7430 } -1 7431 } 8106 74328107 -1 if (state.src.charCodeAt(pos) !== marker) { continue; }-1 7433 /** -1 7434 * MarkdownIt#inline -> ParserInline -1 7435 * -1 7436 * Instance of [[ParserInline]]. You may need it to add new rules when -1 7437 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and -1 7438 * [[MarkdownIt.enable]]. -1 7439 **/ -1 7440 this.inline = new ParserInline(); 8108 74418109 -1 if (state.sCount[nextLine] - state.blkIndent >= 4) {8110 -1 // closing fence should be indented less than 4 spaces8111 -1 continue;8112 -1 }-1 7442 /** -1 7443 * MarkdownIt#block -> ParserBlock -1 7444 * -1 7445 * Instance of [[ParserBlock]]. You may need it to add new rules when -1 7446 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and -1 7447 * [[MarkdownIt.enable]]. -1 7448 **/ -1 7449 this.block = new ParserBlock(); 8113 74508114 -1 pos = state.skipChars(pos, marker);-1 7451 /** -1 7452 * MarkdownIt#core -> Core -1 7453 * -1 7454 * Instance of [[Core]] chain executor. You may need it to add new rules when -1 7455 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and -1 7456 * [[MarkdownIt.enable]]. -1 7457 **/ -1 7458 this.core = new ParserCore(); 8115 74598116 -1 // closing code fence must be at least as long as the opening one8117 -1 if (pos - mem < len) { continue; }-1 7460 /** -1 7461 * MarkdownIt#renderer -> Renderer -1 7462 * -1 7463 * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering -1 7464 * rules for new token types, generated by plugins. -1 7465 * -1 7466 * ##### Example -1 7467 * -1 7468 * ```javascript -1 7469 * var md = require('markdown-it')(); -1 7470 * -1 7471 * function myToken(tokens, idx, options, env, self) { -1 7472 * //... -1 7473 * return result; -1 7474 * }; -1 7475 * -1 7476 * md.renderer.rules['my_token'] = myToken -1 7477 * ``` -1 7478 * -1 7479 * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js). -1 7480 **/ -1 7481 this.renderer = new Renderer(); 8118 74828119 -1 // make sure tail has spaces only8120 -1 pos = state.skipSpaces(pos);-1 7483 /** -1 7484 * MarkdownIt#linkify -> LinkifyIt -1 7485 * -1 7486 * [linkify-it](https://github.com/markdown-it/linkify-it) instance. -1 7487 * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js) -1 7488 * rule. -1 7489 **/ -1 7490 this.linkify = new LinkifyIt(); 8121 74918122 -1 if (pos < max) { continue; }-1 7492 /** -1 7493 * MarkdownIt#validateLink(url) -> Boolean -1 7494 * -1 7495 * Link validation function. CommonMark allows too much in links. By default -1 7496 * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas -1 7497 * except some embedded image types. -1 7498 * -1 7499 * You can change this behaviour: -1 7500 * -1 7501 * ```javascript -1 7502 * var md = require('markdown-it')(); -1 7503 * // enable everything -1 7504 * md.validateLink = function () { return true; } -1 7505 * ``` -1 7506 **/ -1 7507 this.validateLink = validateLink; 8123 75088124 -1 haveEndMarker = true;8125 -1 // found!8126 -1 break;8127 -1 }-1 7509 /** -1 7510 * MarkdownIt#normalizeLink(url) -> String -1 7511 * -1 7512 * Function used to encode link url to a machine-readable format, -1 7513 * which includes url-encoding, punycode, etc. -1 7514 **/ -1 7515 this.normalizeLink = normalizeLink; 8128 75168129 -1 // If a fence has heading spaces, they should be removed from its inner block8130 -1 len = state.sCount[startLine];-1 7517 /** -1 7518 * MarkdownIt#normalizeLinkText(url) -> String -1 7519 * -1 7520 * Function used to decode link url to a human-readable format` -1 7521 **/ -1 7522 this.normalizeLinkText = normalizeLinkText; 8131 75238132 -1 state.line = nextLine + (haveEndMarker ? 1 : 0);8133 75248134 -1 token = state.push('fence', 'code', 0);8135 -1 token.info = params;8136 -1 token.content = state.getLines(startLine + 1, nextLine, len, true);8137 -1 token.markup = markup;8138 -1 token.map = [ startLine, state.line ];-1 7525 // Expose utils & helpers for easy acces from plugins 8139 75268140 -1 return true;8141 -1 };-1 7527 /** -1 7528 * MarkdownIt#utils -> utils -1 7529 * -1 7530 * Assorted utility functions, useful to write plugins. See details -1 7531 * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js). -1 7532 **/ -1 7533 this.utils = utils; 8142 75348143 -1 },{}],60:[function(require,module,exports){8144 -1 // heading (#, ##, ...)-1 7535 /** -1 7536 * MarkdownIt#helpers -> helpers -1 7537 * -1 7538 * Link components parser functions, useful to write plugins. See details -1 7539 * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers). -1 7540 **/ -1 7541 this.helpers = helpers; 8145 75428146 -1 'use strict';8147 75438148 -1 var isSpace = require('../common/utils').isSpace;-1 7544 this.options = {}; -1 7545 this.configure(presetName); 8149 7546 -1 7547 if (options) { this.set(options); } -1 7548 } 8150 75498151 -1 module.exports = function heading(state, startLine, endLine, silent) {8152 -1 var ch, level, tmp, token,8153 -1 pos = state.bMarks[startLine] + state.tShift[startLine],8154 -1 max = state.eMarks[startLine];8155 75508156 -1 ch = state.src.charCodeAt(pos);-1 7551 /** chainable -1 7552 * MarkdownIt.set(options) -1 7553 * -1 7554 * Set parser options (in the same format as in constructor). Probably, you -1 7555 * will never need it, but you can change options after constructor call. -1 7556 * -1 7557 * ##### Example -1 7558 * -1 7559 * ```javascript -1 7560 * var md = require('markdown-it')() -1 7561 * .set({ html: true, breaks: true }) -1 7562 * .set({ typographer, true }); -1 7563 * ``` -1 7564 * -1 7565 * __Note:__ To achieve the best possible performance, don't modify a -1 7566 * `markdown-it` instance options on the fly. If you need multiple configurations -1 7567 * it's best to create multiple instances and initialize each with separate -1 7568 * config. -1 7569 **/ -1 7570 MarkdownIt.prototype.set = function (options) { -1 7571 utils.assign(this.options, options); -1 7572 return this; -1 7573 }; 8157 75748158 -1 if (ch !== 0x23/* # */ || pos >= max) { return false; }8159 75758160 -1 // count heading level8161 -1 level = 1;8162 -1 ch = state.src.charCodeAt(++pos);8163 -1 while (ch === 0x23/* # */ && pos < max && level <= 6) {8164 -1 level++;8165 -1 ch = state.src.charCodeAt(++pos);8166 -1 }-1 7576 /** chainable, internal -1 7577 * MarkdownIt.configure(presets) -1 7578 * -1 7579 * Batch load of all options and compenent settings. This is internal method, -1 7580 * and you probably will not need it. But if you with - see available presets -1 7581 * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets) -1 7582 * -1 7583 * We strongly recommend to use presets instead of direct config loads. That -1 7584 * will give better compatibility with next versions. -1 7585 **/ -1 7586 MarkdownIt.prototype.configure = function (presets) { -1 7587 var self = this, presetName; 8167 75888168 -1 if (level > 6 || (pos < max && ch !== 0x20/* space */)) { return false; }-1 7589 if (utils.isString(presets)) { -1 7590 presetName = presets; -1 7591 presets = config[presetName]; -1 7592 if (!presets) { throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name'); } -1 7593 } 8169 75948170 -1 if (silent) { return true; }-1 7595 if (!presets) { throw new Error('Wrong `markdown-it` preset, can\'t be empty'); } 8171 75968172 -1 // Let's cut tails like ' ### ' from the end of string-1 7597 if (presets.options) { self.set(presets.options); } 8173 75988174 -1 max = state.skipSpacesBack(max, pos);8175 -1 tmp = state.skipCharsBack(max, 0x23, pos); // #8176 -1 if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {8177 -1 max = tmp;-1 7599 if (presets.components) { -1 7600 Object.keys(presets.components).forEach(function (name) { -1 7601 if (presets.components[name].rules) { -1 7602 self[name].ruler.enableOnly(presets.components[name].rules); -1 7603 } -1 7604 if (presets.components[name].rules2) { -1 7605 self[name].ruler2.enableOnly(presets.components[name].rules2); -1 7606 } -1 7607 }); 8178 7608 } -1 7609 return this; -1 7610 }; 8179 76118180 -1 state.line = startLine + 1;8181 76128182 -1 token = state.push('heading_open', 'h' + String(level), 1);8183 -1 token.markup = '########'.slice(0, level);8184 -1 token.map = [ startLine, state.line ];-1 7613 /** chainable -1 7614 * MarkdownIt.enable(list, ignoreInvalid) -1 7615 * - list (String|Array): rule name or list of rule names to enable -1 7616 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. -1 7617 * -1 7618 * Enable list or rules. It will automatically find appropriate components, -1 7619 * containing rules with given names. If rule not found, and `ignoreInvalid` -1 7620 * not set - throws exception. -1 7621 * -1 7622 * ##### Example -1 7623 * -1 7624 * ```javascript -1 7625 * var md = require('markdown-it')() -1 7626 * .enable(['sub', 'sup']) -1 7627 * .disable('smartquotes'); -1 7628 * ``` -1 7629 **/ -1 7630 MarkdownIt.prototype.enable = function (list, ignoreInvalid) { -1 7631 var result = []; 8185 76328186 -1 token = state.push('inline', '', 0);8187 -1 token.content = state.src.slice(pos, max).trim();8188 -1 token.map = [ startLine, state.line ];8189 -1 token.children = [];-1 7633 if (!Array.isArray(list)) { list = [ list ]; } 8190 76348191 -1 token = state.push('heading_close', 'h' + String(level), -1);8192 -1 token.markup = '########'.slice(0, level);-1 7635 [ 'core', 'block', 'inline' ].forEach(function (chain) { -1 7636 result = result.concat(this[chain].ruler.enable(list, true)); -1 7637 }, this); -1 7638 -1 7639 result = result.concat(this.inline.ruler2.enable(list, true)); -1 7640 -1 7641 var missed = list.filter(function (name) { return result.indexOf(name) < 0; }); 8193 76428194 -1 return true;-1 7643 if (missed.length && !ignoreInvalid) { -1 7644 throw new Error('MarkdownIt. Failed to enable unknown rule(s): ' + missed); -1 7645 } -1 7646 -1 7647 return this; 8195 7648 }; 8196 76498197 -1 },{"../common/utils":43}],61:[function(require,module,exports){8198 -1 // Horizontal rule8199 76508200 -1 'use strict';-1 7651 /** chainable -1 7652 * MarkdownIt.disable(list, ignoreInvalid) -1 7653 * - list (String|Array): rule name or list of rule names to disable. -1 7654 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. -1 7655 * -1 7656 * The same as [[MarkdownIt.enable]], but turn specified rules off. -1 7657 **/ -1 7658 MarkdownIt.prototype.disable = function (list, ignoreInvalid) { -1 7659 var result = []; 8201 76608202 -1 var isSpace = require('../common/utils').isSpace;-1 7661 if (!Array.isArray(list)) { list = [ list ]; } 8203 7662 -1 7663 [ 'core', 'block', 'inline' ].forEach(function (chain) { -1 7664 result = result.concat(this[chain].ruler.disable(list, true)); -1 7665 }, this); 8204 76668205 -1 module.exports = function hr(state, startLine, endLine, silent) {8206 -1 var marker, cnt, ch, token,8207 -1 pos = state.bMarks[startLine] + state.tShift[startLine],8208 -1 max = state.eMarks[startLine];-1 7667 result = result.concat(this.inline.ruler2.disable(list, true)); 8209 76688210 -1 marker = state.src.charCodeAt(pos++);-1 7669 var missed = list.filter(function (name) { return result.indexOf(name) < 0; }); 8211 76708212 -1 // Check hr marker8213 -1 if (marker !== 0x2A/* * */ &&8214 -1 marker !== 0x2D/* - */ &&8215 -1 marker !== 0x5F/* _ */) {8216 -1 return false;-1 7671 if (missed.length && !ignoreInvalid) { -1 7672 throw new Error('MarkdownIt. Failed to disable unknown rule(s): ' + missed); 8217 7673 } -1 7674 return this; -1 7675 }; 8218 76768219 -1 // markers can be mixed with spaces, but there should be at least 3 of them8220 -18221 -1 cnt = 1;8222 -1 while (pos < max) {8223 -1 ch = state.src.charCodeAt(pos++);8224 -1 if (ch !== marker && !isSpace(ch)) { return false; }8225 -1 if (ch === marker) { cnt++; }8226 -1 }8227 76778228 -1 if (cnt < 3) { return false; }-1 7678 /** chainable -1 7679 * MarkdownIt.use(plugin, params) -1 7680 * -1 7681 * Load specified plugin with given params into current parser instance. -1 7682 * It's just a sugar to call `plugin(md, params)` with curring. -1 7683 * -1 7684 * ##### Example -1 7685 * -1 7686 * ```javascript -1 7687 * var iterator = require('markdown-it-for-inline'); -1 7688 * var md = require('markdown-it')() -1 7689 * .use(iterator, 'foo_replace', 'text', function (tokens, idx) { -1 7690 * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar'); -1 7691 * }); -1 7692 * ``` -1 7693 **/ -1 7694 MarkdownIt.prototype.use = function (plugin /*, params, ... */) { -1 7695 var args = [ this ].concat(Array.prototype.slice.call(arguments, 1)); -1 7696 plugin.apply(plugin, args); -1 7697 return this; -1 7698 }; 8229 76998230 -1 if (silent) { return true; }8231 77008232 -1 state.line = startLine + 1;-1 7701 /** internal -1 7702 * MarkdownIt.parse(src, env) -> Array -1 7703 * - src (String): source string -1 7704 * - env (Object): environment sandbox -1 7705 * -1 7706 * Parse input string and returns list of block tokens (special token type -1 7707 * "inline" will contain list of inline tokens). You should not call this -1 7708 * method directly, until you write custom renderer (for example, to produce -1 7709 * AST). -1 7710 * -1 7711 * `env` is used to pass data between "distributed" rules and return additional -1 7712 * metadata like reference info, needed for the renderer. It also can be used to -1 7713 * inject data in specific cases. Usually, you will be ok to pass `{}`, -1 7714 * and then pass updated object to renderer. -1 7715 **/ -1 7716 MarkdownIt.prototype.parse = function (src, env) { -1 7717 var state = new this.core.State(src, this, env); 8233 77188234 -1 token = state.push('hr', 'hr', 0);8235 -1 token.map = [ startLine, state.line ];8236 -1 token.markup = Array(cnt + 1).join(String.fromCharCode(marker));-1 7719 this.core.process(state); 8237 77208238 -1 return true;-1 7721 return state.tokens; 8239 7722 }; 8240 77238241 -1 },{"../common/utils":43}],62:[function(require,module,exports){8242 -1 // HTML block8243 77248244 -1 'use strict';-1 7725 /** -1 7726 * MarkdownIt.render(src [, env]) -> String -1 7727 * - src (String): source string -1 7728 * - env (Object): environment sandbox -1 7729 * -1 7730 * Render markdown string into html. It does all magic for you :). -1 7731 * -1 7732 * `env` can be used to inject additional metadata (`{}` by default). -1 7733 * But you will not need it with high probability. See also comment -1 7734 * in [[MarkdownIt.parse]]. -1 7735 **/ -1 7736 MarkdownIt.prototype.render = function (src, env) { -1 7737 env = env || {}; 8245 7738 -1 7739 return this.renderer.render(this.parse(src, env), this.options, env); -1 7740 }; 8246 77418247 -1 var block_names = require('../common/html_blocks');8248 -1 var HTML_OPEN_CLOSE_TAG_RE = require('../common/html_re').HTML_OPEN_CLOSE_TAG_RE;8249 77428250 -1 // An array of opening and corresponding closing sequences for html tags,8251 -1 // last argument defines whether it can terminate a paragraph or not8252 -1 //8253 -1 var HTML_SEQUENCES = [8254 -1 [ /^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true ],8255 -1 [ /^<!--/, /-->/, true ],8256 -1 [ /^<\?/, /\?>/, true ],8257 -1 [ /^<![A-Z]/, />/, true ],8258 -1 [ /^<!\[CDATA\[/, /\]\]>/, true ],8259 -1 [ new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ],8260 -1 [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ]8261 -1 ];-1 7743 /** internal -1 7744 * MarkdownIt.parseInline(src, env) -> Array -1 7745 * - src (String): source string -1 7746 * - env (Object): environment sandbox -1 7747 * -1 7748 * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the -1 7749 * block tokens list with the single `inline` element, containing parsed inline -1 7750 * tokens in `children` property. Also updates `env` object. -1 7751 **/ -1 7752 MarkdownIt.prototype.parseInline = function (src, env) { -1 7753 var state = new this.core.State(src, this, env); 8262 7754 -1 7755 state.inlineMode = true; -1 7756 this.core.process(state); 8263 77578264 -1 module.exports = function html_block(state, startLine, endLine, silent) {8265 -1 var i, nextLine, token, lineText,8266 -1 pos = state.bMarks[startLine] + state.tShift[startLine],8267 -1 max = state.eMarks[startLine];-1 7758 return state.tokens; -1 7759 }; 8268 77608269 -1 if (!state.md.options.html) { return false; }8270 77618271 -1 if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }-1 7762 /** -1 7763 * MarkdownIt.renderInline(src [, env]) -> String -1 7764 * - src (String): source string -1 7765 * - env (Object): environment sandbox -1 7766 * -1 7767 * Similar to [[MarkdownIt.render]] but for single paragraph content. Result -1 7768 * will NOT be wrapped into `<p>` tags. -1 7769 **/ -1 7770 MarkdownIt.prototype.renderInline = function (src, env) { -1 7771 env = env || {}; 8272 77728273 -1 lineText = state.src.slice(pos, max);-1 7773 return this.renderer.render(this.parseInline(src, env), this.options, env); -1 7774 }; 8274 77758275 -1 for (i = 0; i < HTML_SEQUENCES.length; i++) {8276 -1 if (HTML_SEQUENCES[i][0].test(lineText)) { break; }8277 -1 }8278 77768279 -1 if (i === HTML_SEQUENCES.length) { return false; }-1 7777 module.exports = MarkdownIt; 8280 77788281 -1 if (silent) {8282 -1 // true if this sequence can be a terminator, false otherwise8283 -1 return HTML_SEQUENCES[i][2];8284 -1 }-1 7779 },{"./common/utils":40,"./helpers":41,"./parser_block":46,"./parser_core":47,"./parser_inline":48,"./presets/commonmark":49,"./presets/default":50,"./presets/zero":51,"./renderer":52,"linkify-it":34,"mdurl":91,"punycode":3}],46:[function(require,module,exports){ -1 7780 /** internal -1 7781 * class ParserBlock -1 7782 * -1 7783 * Block-level tokenizer. -1 7784 **/ -1 7785 'use strict'; 8285 77868286 -1 nextLine = startLine + 1;8287 77878288 -1 // If we are here - we detected HTML block.8289 -1 // Let's roll down till block end.8290 -1 if (!HTML_SEQUENCES[i][1].test(lineText)) {8291 -1 for (; nextLine < endLine; nextLine++) {8292 -1 if (state.sCount[nextLine] < state.blkIndent) { break; }-1 7788 var Ruler = require('./ruler'); 8293 77898294 -1 pos = state.bMarks[nextLine] + state.tShift[nextLine];8295 -1 max = state.eMarks[nextLine];8296 -1 lineText = state.src.slice(pos, max);8297 77908298 -1 if (HTML_SEQUENCES[i][1].test(lineText)) {8299 -1 if (lineText.length !== 0) { nextLine++; }8300 -1 break;8301 -1 }8302 -1 }8303 -1 }-1 7791 var _rules = [ -1 7792 // First 2 params - rule name & source. Secondary array - list of rules, -1 7793 // which can be terminated by this one. -1 7794 [ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ], -1 7795 [ 'code', require('./rules_block/code') ], -1 7796 [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ], -1 7797 [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'list' ] ], -1 7798 [ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ], -1 7799 [ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ], -1 7800 [ 'reference', require('./rules_block/reference') ], -1 7801 [ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ], -1 7802 [ 'lheading', require('./rules_block/lheading') ], -1 7803 [ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ], -1 7804 [ 'paragraph', require('./rules_block/paragraph') ] -1 7805 ]; 8304 78068305 -1 state.line = nextLine;8306 78078307 -1 token = state.push('html_block', '', 0);8308 -1 token.map = [ startLine, nextLine ];8309 -1 token.content = state.getLines(startLine, nextLine, state.blkIndent, true);-1 7808 /** -1 7809 * new ParserBlock() -1 7810 **/ -1 7811 function ParserBlock() { -1 7812 /** -1 7813 * ParserBlock#ruler -> Ruler -1 7814 * -1 7815 * [[Ruler]] instance. Keep configuration of block rules. -1 7816 **/ -1 7817 this.ruler = new Ruler(); 8310 78188311 -1 return true;8312 -1 };-1 7819 for (var i = 0; i < _rules.length; i++) { -1 7820 this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() }); -1 7821 } -1 7822 } 8313 78238314 -1 },{"../common/html_blocks":41,"../common/html_re":42}],63:[function(require,module,exports){8315 -1 // lheading (---, ===)8316 78248317 -1 'use strict';-1 7825 // Generate tokens for input range -1 7826 // -1 7827 ParserBlock.prototype.tokenize = function (state, startLine, endLine) { -1 7828 var ok, i, -1 7829 rules = this.ruler.getRules(''), -1 7830 len = rules.length, -1 7831 line = startLine, -1 7832 hasEmptyLines = false, -1 7833 maxNesting = state.md.options.maxNesting; 8318 7834 -1 7835 while (line < endLine) { -1 7836 state.line = line = state.skipEmptyLines(line); -1 7837 if (line >= endLine) { break; } 8319 78388320 -1 module.exports = function lheading(state, startLine, endLine/*, silent*/) {8321 -1 var content, terminate, i, l, token, pos, max, level, marker,8322 -1 nextLine = startLine + 1,8323 -1 terminatorRules = state.md.block.ruler.getRules('paragraph');-1 7839 // Termination condition for nested calls. -1 7840 // Nested calls currently used for blockquotes & lists -1 7841 if (state.sCount[line] < state.blkIndent) { break; } 8324 78428325 -1 // jump line-by-line until empty one or EOF8326 -1 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {8327 -1 // this would be a code block normally, but after paragraph8328 -1 // it's considered a lazy continuation regardless of what's there8329 -1 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }-1 7843 // If nesting level exceeded - skip tail to the end. That's not ordinary -1 7844 // situation and we should not care about content. -1 7845 if (state.level >= maxNesting) { -1 7846 state.line = endLine; -1 7847 break; -1 7848 } 8330 7849 -1 7850 // Try all possible rules. -1 7851 // On success, rule should: 8331 7852 //8332 -1 // Check for underline in setext header8333 -1 //8334 -1 if (state.sCount[nextLine] >= state.blkIndent) {8335 -1 pos = state.bMarks[nextLine] + state.tShift[nextLine];8336 -1 max = state.eMarks[nextLine];-1 7853 // - update `state.line` -1 7854 // - update `state.tokens` -1 7855 // - return true 8337 78568338 -1 if (pos < max) {8339 -1 marker = state.src.charCodeAt(pos);-1 7857 for (i = 0; i < len; i++) { -1 7858 ok = rules[i](state, line, endLine, false); -1 7859 if (ok) { break; } -1 7860 } 8340 78618341 -1 if (marker === 0x2D/* - */ || marker === 0x3D/* = */) {8342 -1 pos = state.skipChars(pos, marker);8343 -1 pos = state.skipSpaces(pos);-1 7862 // set state.tight iff we had an empty line before current tag -1 7863 // i.e. latest empty line should not count -1 7864 state.tight = !hasEmptyLines; 8344 78658345 -1 if (pos >= max) {8346 -1 level = (marker === 0x3D/* = */ ? 1 : 2);8347 -1 break;8348 -1 }8349 -1 }8350 -1 }-1 7866 // paragraph might "eat" one newline after it in nested lists -1 7867 if (state.isEmpty(state.line - 1)) { -1 7868 hasEmptyLines = true; 8351 7869 } 8352 78708353 -1 // quirk for blockquotes, this line should already be checked by that rule8354 -1 if (state.sCount[nextLine] < 0) { continue; }-1 7871 line = state.line; 8355 78728356 -1 // Some tags can terminate paragraph without empty line.8357 -1 terminate = false;8358 -1 for (i = 0, l = terminatorRules.length; i < l; i++) {8359 -1 if (terminatorRules[i](state, nextLine, endLine, true)) {8360 -1 terminate = true;8361 -1 break;8362 -1 }-1 7873 if (line < endLine && state.isEmpty(line)) { -1 7874 hasEmptyLines = true; -1 7875 line++; -1 7876 -1 7877 // two empty lines should stop the parser in list mode -1 7878 if (line < endLine && state.parentType === 'list' && state.isEmpty(line)) { break; } -1 7879 state.line = line; 8363 7880 }8364 -1 if (terminate) { break; }8365 7881 } -1 7882 }; 8366 78838367 -1 if (!level) {8368 -1 // Didn't find valid underline8369 -1 return false;8370 -1 }8371 78848372 -1 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();-1 7885 /** -1 7886 * ParserBlock.parse(str, md, env, outTokens) -1 7887 * -1 7888 * Process input string and push block tokens into `outTokens` -1 7889 **/ -1 7890 ParserBlock.prototype.parse = function (src, md, env, outTokens) { -1 7891 var state; 8373 78928374 -1 state.line = nextLine + 1;-1 7893 if (!src) { return; } 8375 78948376 -1 token = state.push('heading_open', 'h' + String(level), 1);8377 -1 token.markup = String.fromCharCode(marker);8378 -1 token.map = [ startLine, state.line ];-1 7895 state = new this.State(src, md, env, outTokens); 8379 78968380 -1 token = state.push('inline', '', 0);8381 -1 token.content = content;8382 -1 token.map = [ startLine, state.line - 1 ];8383 -1 token.children = [];-1 7897 this.tokenize(state, state.line, state.lineMax); -1 7898 }; 8384 78998385 -1 token = state.push('heading_close', 'h' + String(level), -1);8386 -1 token.markup = String.fromCharCode(marker);8387 79008388 -1 return true;8389 -1 };-1 7901 ParserBlock.prototype.State = require('./rules_block/state_block'); 8390 79028391 -1 },{}],64:[function(require,module,exports){8392 -1 // Lists8393 7903 -1 7904 module.exports = ParserBlock; -1 7905 -1 7906 },{"./ruler":53,"./rules_block/blockquote":54,"./rules_block/code":55,"./rules_block/fence":56,"./rules_block/heading":57,"./rules_block/hr":58,"./rules_block/html_block":59,"./rules_block/lheading":60,"./rules_block/list":61,"./rules_block/paragraph":62,"./rules_block/reference":63,"./rules_block/state_block":64,"./rules_block/table":65}],47:[function(require,module,exports){ -1 7907 /** internal -1 7908 * class Core -1 7909 * -1 7910 * Top-level rules executor. Glues block/inline parsers and does intermediate -1 7911 * transformations. -1 7912 **/ 8394 7913 'use strict'; 8395 79148396 -1 var isSpace = require('../common/utils').isSpace;8397 7915 -1 7916 var Ruler = require('./ruler'); 8398 79178399 -1 // Search `[-+*][\n ]`, returns next pos arter marker on success8400 -1 // or -1 on fail.8401 -1 function skipBulletListMarker(state, startLine) {8402 -1 var marker, pos, max, ch;8403 79188404 -1 pos = state.bMarks[startLine] + state.tShift[startLine];8405 -1 max = state.eMarks[startLine];-1 7919 var _rules = [ -1 7920 [ 'normalize', require('./rules_core/normalize') ], -1 7921 [ 'block', require('./rules_core/block') ], -1 7922 [ 'inline', require('./rules_core/inline') ], -1 7923 [ 'linkify', require('./rules_core/linkify') ], -1 7924 [ 'replacements', require('./rules_core/replacements') ], -1 7925 [ 'smartquotes', require('./rules_core/smartquotes') ] -1 7926 ]; 8406 79278407 -1 marker = state.src.charCodeAt(pos++);8408 -1 // Check bullet8409 -1 if (marker !== 0x2A/* * */ &&8410 -1 marker !== 0x2D/* - */ &&8411 -1 marker !== 0x2B/* + */) {8412 -1 return -1;8413 -1 }8414 79288415 -1 if (pos < max) {8416 -1 ch = state.src.charCodeAt(pos);-1 7929 /** -1 7930 * new Core() -1 7931 **/ -1 7932 function Core() { -1 7933 /** -1 7934 * Core#ruler -> Ruler -1 7935 * -1 7936 * [[Ruler]] instance. Keep configuration of core rules. -1 7937 **/ -1 7938 this.ruler = new Ruler(); 8417 79398418 -1 if (!isSpace(ch)) {8419 -1 // " -test " - is not a list item8420 -1 return -1;8421 -1 }-1 7940 for (var i = 0; i < _rules.length; i++) { -1 7941 this.ruler.push(_rules[i][0], _rules[i][1]); 8422 7942 }8423 -18424 -1 return pos;8425 7943 } 8426 79448427 -1 // Search `\d+[.)][\n ]`, returns next pos arter marker on success8428 -1 // or -1 on fail.8429 -1 function skipOrderedListMarker(state, startLine) {8430 -1 var ch,8431 -1 start = state.bMarks[startLine] + state.tShift[startLine],8432 -1 pos = start,8433 -1 max = state.eMarks[startLine];8434 -18435 -1 // List marker should have at least 2 chars (digit + dot)8436 -1 if (pos + 1 >= max) { return -1; }8437 79458438 -1 ch = state.src.charCodeAt(pos++);-1 7946 /** -1 7947 * Core.process(state) -1 7948 * -1 7949 * Executes core chain rules. -1 7950 **/ -1 7951 Core.prototype.process = function (state) { -1 7952 var i, l, rules; 8439 79538440 -1 if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }-1 7954 rules = this.ruler.getRules(''); 8441 79558442 -1 for (;;) {8443 -1 // EOL -> fail8444 -1 if (pos >= max) { return -1; }-1 7956 for (i = 0, l = rules.length; i < l; i++) { -1 7957 rules[i](state); -1 7958 } -1 7959 }; 8445 79608446 -1 ch = state.src.charCodeAt(pos++);-1 7961 Core.prototype.State = require('./rules_core/state_core'); 8447 79628448 -1 if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {8449 79638450 -1 // List marker should have no more than 9 digits8451 -1 // (prevents integer overflow in browsers)8452 -1 if (pos - start >= 10) { return -1; }-1 7964 module.exports = Core; 8453 79658454 -1 continue;8455 -1 }-1 7966 },{"./ruler":53,"./rules_core/block":66,"./rules_core/inline":67,"./rules_core/linkify":68,"./rules_core/normalize":69,"./rules_core/replacements":70,"./rules_core/smartquotes":71,"./rules_core/state_core":72}],48:[function(require,module,exports){ -1 7967 /** internal -1 7968 * class ParserInline -1 7969 * -1 7970 * Tokenizes paragraph content. -1 7971 **/ -1 7972 'use strict'; 8456 79738457 -1 // found valid marker8458 -1 if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {8459 -1 break;8460 -1 }8461 79748462 -1 return -1;8463 -1 }-1 7975 var Ruler = require('./ruler'); 8464 7976 8465 79778466 -1 if (pos < max) {8467 -1 ch = state.src.charCodeAt(pos);-1 7978 //////////////////////////////////////////////////////////////////////////////// -1 7979 // Parser rules 8468 79808469 -1 if (!isSpace(ch)) {8470 -1 // " 1.test " - is not a list item8471 -1 return -1;8472 -1 }8473 -1 }8474 -1 return pos;8475 -1 }-1 7981 var _rules = [ -1 7982 [ 'text', require('./rules_inline/text') ], -1 7983 [ 'newline', require('./rules_inline/newline') ], -1 7984 [ 'escape', require('./rules_inline/escape') ], -1 7985 [ 'backticks', require('./rules_inline/backticks') ], -1 7986 [ 'strikethrough', require('./rules_inline/strikethrough').tokenize ], -1 7987 [ 'emphasis', require('./rules_inline/emphasis').tokenize ], -1 7988 [ 'link', require('./rules_inline/link') ], -1 7989 [ 'image', require('./rules_inline/image') ], -1 7990 [ 'autolink', require('./rules_inline/autolink') ], -1 7991 [ 'html_inline', require('./rules_inline/html_inline') ], -1 7992 [ 'entity', require('./rules_inline/entity') ] -1 7993 ]; 8476 79948477 -1 function markTightParagraphs(state, idx) {8478 -1 var i, l,8479 -1 level = state.level + 2;-1 7995 var _rules2 = [ -1 7996 [ 'balance_pairs', require('./rules_inline/balance_pairs') ], -1 7997 [ 'strikethrough', require('./rules_inline/strikethrough').postProcess ], -1 7998 [ 'emphasis', require('./rules_inline/emphasis').postProcess ], -1 7999 [ 'text_collapse', require('./rules_inline/text_collapse') ] -1 8000 ]; 8480 80018481 -1 for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {8482 -1 if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {8483 -1 state.tokens[i + 2].hidden = true;8484 -1 state.tokens[i].hidden = true;8485 -1 i += 2;8486 -1 }8487 -1 }8488 -1 }8489 8002 -1 8003 /** -1 8004 * new ParserInline() -1 8005 **/ -1 8006 function ParserInline() { -1 8007 var i; 8490 80088491 -1 module.exports = function list(state, startLine, endLine, silent) {8492 -1 var nextLine,8493 -1 initial,8494 -1 offset,8495 -1 indent,8496 -1 oldTShift,8497 -1 oldIndent,8498 -1 oldLIndent,8499 -1 oldTight,8500 -1 oldParentType,8501 -1 start,8502 -1 posAfterMarker,8503 -1 ch,8504 -1 pos,8505 -1 max,8506 -1 indentAfterMarker,8507 -1 markerValue,8508 -1 markerCharCode,8509 -1 isOrdered,8510 -1 contentStart,8511 -1 listTokIdx,8512 -1 prevEmptyEnd,8513 -1 listLines,8514 -1 itemLines,8515 -1 tight = true,8516 -1 terminatorRules,8517 -1 token,8518 -1 i, l, terminate;-1 8009 /** -1 8010 * ParserInline#ruler -> Ruler -1 8011 * -1 8012 * [[Ruler]] instance. Keep configuration of inline rules. -1 8013 **/ -1 8014 this.ruler = new Ruler(); 8519 80158520 -1 // Detect list type and position after marker8521 -1 if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {8522 -1 isOrdered = true;8523 -1 } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {8524 -1 isOrdered = false;8525 -1 } else {8526 -1 return false;-1 8016 for (i = 0; i < _rules.length; i++) { -1 8017 this.ruler.push(_rules[i][0], _rules[i][1]); 8527 8018 } 8528 80198529 -1 // We should terminate list on style change. Remember first one to compare.8530 -1 markerCharCode = state.src.charCodeAt(posAfterMarker - 1);-1 8020 /** -1 8021 * ParserInline#ruler2 -> Ruler -1 8022 * -1 8023 * [[Ruler]] instance. Second ruler used for post-processing -1 8024 * (e.g. in emphasis-like rules). -1 8025 **/ -1 8026 this.ruler2 = new Ruler(); 8531 80278532 -1 // For validation mode we can terminate immediately8533 -1 if (silent) { return true; }-1 8028 for (i = 0; i < _rules2.length; i++) { -1 8029 this.ruler2.push(_rules2[i][0], _rules2[i][1]); -1 8030 } -1 8031 } 8534 80328535 -1 // Start list8536 -1 listTokIdx = state.tokens.length;8537 80338538 -1 if (isOrdered) {8539 -1 start = state.bMarks[startLine] + state.tShift[startLine];8540 -1 markerValue = Number(state.src.substr(start, posAfterMarker - start - 1));-1 8034 // Skip single token by running all rules in validation mode; -1 8035 // returns `true` if any rule reported success -1 8036 // -1 8037 ParserInline.prototype.skipToken = function (state) { -1 8038 var ok, i, pos = state.pos, -1 8039 rules = this.ruler.getRules(''), -1 8040 len = rules.length, -1 8041 maxNesting = state.md.options.maxNesting, -1 8042 cache = state.cache; 8541 80438542 -1 token = state.push('ordered_list_open', 'ol', 1);8543 -1 if (markerValue !== 1) {8544 -1 token.attrs = [ [ 'start', markerValue ] ];8545 -1 }8546 80448547 -1 } else {8548 -1 token = state.push('bullet_list_open', 'ul', 1);-1 8045 if (typeof cache[pos] !== 'undefined') { -1 8046 state.pos = cache[pos]; -1 8047 return; 8549 8048 } 8550 80498551 -1 token.map = listLines = [ startLine, 0 ];8552 -1 token.markup = String.fromCharCode(markerCharCode);-1 8050 if (state.level < maxNesting) { -1 8051 for (i = 0; i < len; i++) { -1 8052 // Increment state.level and decrement it later to limit recursion. -1 8053 // It's harmless to do here, because no tokens are created. But ideally, -1 8054 // we'd need a separate private state variable for this purpose. -1 8055 // -1 8056 state.level++; -1 8057 ok = rules[i](state, true); -1 8058 state.level--; 8553 80598554 -1 //8555 -1 // Iterate list items8556 -1 //-1 8060 if (ok) { break; } -1 8061 } -1 8062 } else { -1 8063 // Too much nesting, just skip until the end of the paragraph. -1 8064 // -1 8065 // NOTE: this will cause links to behave incorrectly in the following case, -1 8066 // when an amount of `[` is exactly equal to `maxNesting + 1`: -1 8067 // -1 8068 // [[[[[[[[[[[[[[[[[[[[[foo]() -1 8069 // -1 8070 // TODO: remove this workaround when CM standard will allow nested links -1 8071 // (we can replace it by preventing links from being parsed in -1 8072 // validation mode) -1 8073 // -1 8074 state.pos = state.posMax; -1 8075 } 8557 80768558 -1 nextLine = startLine;8559 -1 prevEmptyEnd = false;8560 -1 terminatorRules = state.md.block.ruler.getRules('list');-1 8077 if (!ok) { state.pos++; } -1 8078 cache[pos] = state.pos; -1 8079 }; 8561 80808562 -1 while (nextLine < endLine) {8563 -1 pos = posAfterMarker;8564 -1 max = state.eMarks[nextLine];8565 80818566 -1 initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);-1 8082 // Generate tokens for input range -1 8083 // -1 8084 ParserInline.prototype.tokenize = function (state) { -1 8085 var ok, i, -1 8086 rules = this.ruler.getRules(''), -1 8087 len = rules.length, -1 8088 end = state.posMax, -1 8089 maxNesting = state.md.options.maxNesting; 8567 80908568 -1 while (pos < max) {8569 -1 ch = state.src.charCodeAt(pos);-1 8091 while (state.pos < end) { -1 8092 // Try all possible rules. -1 8093 // On success, rule should: -1 8094 // -1 8095 // - update `state.pos` -1 8096 // - update `state.tokens` -1 8097 // - return true 8570 80988571 -1 if (isSpace(ch)) {8572 -1 if (ch === 0x09) {8573 -1 offset += 4 - offset % 4;8574 -1 } else {8575 -1 offset++;8576 -1 }8577 -1 } else {8578 -1 break;-1 8099 if (state.level < maxNesting) { -1 8100 for (i = 0; i < len; i++) { -1 8101 ok = rules[i](state, false); -1 8102 if (ok) { break; } 8579 8103 }8580 -18581 -1 pos++;8582 8104 } 8583 81058584 -1 contentStart = pos;8585 -18586 -1 if (contentStart >= max) {8587 -1 // trimming space in "- \n 3" case, indent is 1 here8588 -1 indentAfterMarker = 1;8589 -1 } else {8590 -1 indentAfterMarker = offset - initial;-1 8106 if (ok) { -1 8107 if (state.pos >= end) { break; } -1 8108 continue; 8591 8109 } 8592 81108593 -1 // If we have more than 4 spaces, the indent is 18594 -1 // (the rest is just indented code block)8595 -1 if (indentAfterMarker > 4) { indentAfterMarker = 1; }8596 -18597 -1 // " - test"8598 -1 // ^^^^^ - calculating total length of this thing8599 -1 indent = initial + indentAfterMarker;8600 -18601 -1 // Run subparser & write tokens8602 -1 token = state.push('list_item_open', 'li', 1);8603 -1 token.markup = String.fromCharCode(markerCharCode);8604 -1 token.map = itemLines = [ startLine, 0 ];8605 -18606 -1 oldIndent = state.blkIndent;8607 -1 oldTight = state.tight;8608 -1 oldTShift = state.tShift[startLine];8609 -1 oldLIndent = state.sCount[startLine];8610 -1 oldParentType = state.parentType;8611 -1 state.blkIndent = indent;8612 -1 state.tight = true;8613 -1 state.parentType = 'list';8614 -1 state.tShift[startLine] = contentStart - state.bMarks[startLine];8615 -1 state.sCount[startLine] = offset;-1 8111 state.pending += state.src[state.pos++]; -1 8112 } 8616 81138617 -1 if (contentStart >= max && state.isEmpty(startLine + 1)) {8618 -1 // workaround for this case8619 -1 // (list item is empty, list terminates before "foo"):8620 -1 // ~~~~~~~~8621 -1 // -8622 -1 //8623 -1 // foo8624 -1 // ~~~~~~~~8625 -1 state.line = Math.min(state.line + 2, endLine);8626 -1 } else {8627 -1 state.md.block.tokenize(state, startLine, endLine, true);8628 -1 }-1 8114 if (state.pending) { -1 8115 state.pushPending(); -1 8116 } -1 8117 }; 8629 81188630 -1 // If any of list item is tight, mark list as tight8631 -1 if (!state.tight || prevEmptyEnd) {8632 -1 tight = false;8633 -1 }8634 -1 // Item become loose if finish with empty line,8635 -1 // but we should filter last element, because it means list finish8636 -1 prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1);8637 81198638 -1 state.blkIndent = oldIndent;8639 -1 state.tShift[startLine] = oldTShift;8640 -1 state.sCount[startLine] = oldLIndent;8641 -1 state.tight = oldTight;8642 -1 state.parentType = oldParentType;-1 8120 /** -1 8121 * ParserInline.parse(str, md, env, outTokens) -1 8122 * -1 8123 * Process input string and push inline tokens into `outTokens` -1 8124 **/ -1 8125 ParserInline.prototype.parse = function (str, md, env, outTokens) { -1 8126 var i, rules, len; -1 8127 var state = new this.State(str, md, env, outTokens); 8643 81288644 -1 token = state.push('list_item_close', 'li', -1);8645 -1 token.markup = String.fromCharCode(markerCharCode);-1 8129 this.tokenize(state); 8646 81308647 -1 nextLine = startLine = state.line;8648 -1 itemLines[1] = nextLine;8649 -1 contentStart = state.bMarks[startLine];-1 8131 rules = this.ruler2.getRules(''); -1 8132 len = rules.length; 8650 81338651 -1 if (nextLine >= endLine) { break; }-1 8134 for (i = 0; i < len; i++) { -1 8135 rules[i](state); -1 8136 } -1 8137 }; 8652 81388653 -1 if (state.isEmpty(nextLine)) {8654 -1 break;8655 -1 }8656 81398657 -1 //8658 -1 // Try to check if list is terminated or continued.8659 -1 //8660 -1 if (state.sCount[nextLine] < state.blkIndent) { break; }-1 8140 ParserInline.prototype.State = require('./rules_inline/state_inline'); 8661 81418662 -1 // fail if terminating block found8663 -1 terminate = false;8664 -1 for (i = 0, l = terminatorRules.length; i < l; i++) {8665 -1 if (terminatorRules[i](state, nextLine, endLine, true)) {8666 -1 terminate = true;8667 -1 break;8668 -1 }8669 -1 }8670 -1 if (terminate) { break; }8671 81428672 -1 // fail if list has another type8673 -1 if (isOrdered) {8674 -1 posAfterMarker = skipOrderedListMarker(state, nextLine);8675 -1 if (posAfterMarker < 0) { break; }8676 -1 } else {8677 -1 posAfterMarker = skipBulletListMarker(state, nextLine);8678 -1 if (posAfterMarker < 0) { break; }8679 -1 }-1 8143 module.exports = ParserInline; 8680 81448681 -1 if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }8682 -1 }-1 8145 },{"./ruler":53,"./rules_inline/autolink":73,"./rules_inline/backticks":74,"./rules_inline/balance_pairs":75,"./rules_inline/emphasis":76,"./rules_inline/entity":77,"./rules_inline/escape":78,"./rules_inline/html_inline":79,"./rules_inline/image":80,"./rules_inline/link":81,"./rules_inline/newline":82,"./rules_inline/state_inline":83,"./rules_inline/strikethrough":84,"./rules_inline/text":85,"./rules_inline/text_collapse":86}],49:[function(require,module,exports){ -1 8146 // Commonmark default options 8683 81478684 -1 // Finilize list8685 -1 if (isOrdered) {8686 -1 token = state.push('ordered_list_close', 'ol', -1);8687 -1 } else {8688 -1 token = state.push('bullet_list_close', 'ul', -1);8689 -1 }8690 -1 token.markup = String.fromCharCode(markerCharCode);-1 8148 'use strict'; 8691 81498692 -1 listLines[1] = nextLine;8693 -1 state.line = nextLine;8694 81508695 -1 // mark paragraphs tight if needed8696 -1 if (tight) {8697 -1 markTightParagraphs(state, listTokIdx);8698 -1 }-1 8151 module.exports = { -1 8152 options: { -1 8153 html: true, // Enable HTML tags in source -1 8154 xhtmlOut: true, // Use '/' to close single tags (<br />) -1 8155 breaks: false, // Convert '\n' in paragraphs into <br> -1 8156 langPrefix: 'language-', // CSS language prefix for fenced blocks -1 8157 linkify: false, // autoconvert URL-like texts to links 8699 81588700 -1 return true;8701 -1 };-1 8159 // Enable some language-neutral replacements + quotes beautification -1 8160 typographer: false, 8702 81618703 -1 },{"../common/utils":43}],65:[function(require,module,exports){8704 -1 // Paragraph-1 8162 // Double + single quotes replacement pairs, when typographer enabled, -1 8163 // and smartquotes on. Could be either a String or an Array. -1 8164 // -1 8165 // For example, you can use '«»„“' for Russian, '„“‚‘' for German, -1 8166 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp). -1 8167 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */ 8705 81688706 -1 'use strict';-1 8169 // Highlighter function. Should return escaped HTML, -1 8170 // or '' if the source string is not changed and should be escaped externaly. -1 8171 // If result starts with <pre... internal wrapper is skipped. -1 8172 // -1 8173 // function (/*str, lang*/) { return ''; } -1 8174 // -1 8175 highlight: null, 8707 8176 -1 8177 maxNesting: 20 // Internal protection, recursion limit -1 8178 }, 8708 81798709 -1 module.exports = function paragraph(state, startLine/*, endLine*/) {8710 -1 var content, terminate, i, l, token,8711 -1 nextLine = startLine + 1,8712 -1 terminatorRules = state.md.block.ruler.getRules('paragraph'),8713 -1 endLine = state.lineMax;-1 8180 components: { 8714 81818715 -1 // jump line-by-line until empty one or EOF8716 -1 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {8717 -1 // this would be a code block normally, but after paragraph8718 -1 // it's considered a lazy continuation regardless of what's there8719 -1 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }-1 8182 core: { -1 8183 rules: [ -1 8184 'normalize', -1 8185 'block', -1 8186 'inline' -1 8187 ] -1 8188 }, 8720 81898721 -1 // quirk for blockquotes, this line should already be checked by that rule8722 -1 if (state.sCount[nextLine] < 0) { continue; }-1 8190 block: { -1 8191 rules: [ -1 8192 'blockquote', -1 8193 'code', -1 8194 'fence', -1 8195 'heading', -1 8196 'hr', -1 8197 'html_block', -1 8198 'lheading', -1 8199 'list', -1 8200 'reference', -1 8201 'paragraph' -1 8202 ] -1 8203 }, 8723 82048724 -1 // Some tags can terminate paragraph without empty line.8725 -1 terminate = false;8726 -1 for (i = 0, l = terminatorRules.length; i < l; i++) {8727 -1 if (terminatorRules[i](state, nextLine, endLine, true)) {8728 -1 terminate = true;8729 -1 break;8730 -1 }-1 8205 inline: { -1 8206 rules: [ -1 8207 'autolink', -1 8208 'backticks', -1 8209 'emphasis', -1 8210 'entity', -1 8211 'escape', -1 8212 'html_inline', -1 8213 'image', -1 8214 'link', -1 8215 'newline', -1 8216 'text' -1 8217 ], -1 8218 rules2: [ -1 8219 'balance_pairs', -1 8220 'emphasis', -1 8221 'text_collapse' -1 8222 ] 8731 8223 }8732 -1 if (terminate) { break; }8733 8224 } -1 8225 }; 8734 82268735 -1 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();-1 8227 },{}],50:[function(require,module,exports){ -1 8228 // markdown-it default options 8736 82298737 -1 state.line = nextLine;-1 8230 'use strict'; 8738 82318739 -1 token = state.push('paragraph_open', 'p', 1);8740 -1 token.map = [ startLine, state.line ];8741 82328742 -1 token = state.push('inline', '', 0);8743 -1 token.content = content;8744 -1 token.map = [ startLine, state.line ];8745 -1 token.children = [];-1 8233 module.exports = { -1 8234 options: { -1 8235 html: false, // Enable HTML tags in source -1 8236 xhtmlOut: false, // Use '/' to close single tags (<br />) -1 8237 breaks: false, // Convert '\n' in paragraphs into <br> -1 8238 langPrefix: 'language-', // CSS language prefix for fenced blocks -1 8239 linkify: false, // autoconvert URL-like texts to links 8746 82408747 -1 token = state.push('paragraph_close', 'p', -1);-1 8241 // Enable some language-neutral replacements + quotes beautification -1 8242 typographer: false, 8748 82438749 -1 return true;8750 -1 };-1 8244 // Double + single quotes replacement pairs, when typographer enabled, -1 8245 // and smartquotes on. Could be either a String or an Array. -1 8246 // -1 8247 // For example, you can use '«»„“' for Russian, '„“‚‘' for German, -1 8248 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp). -1 8249 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */ 8751 82508752 -1 },{}],66:[function(require,module,exports){8753 -1 'use strict';-1 8251 // Highlighter function. Should return escaped HTML, -1 8252 // or '' if the source string is not changed and should be escaped externaly. -1 8253 // If result starts with <pre... internal wrapper is skipped. -1 8254 // -1 8255 // function (/*str, lang*/) { return ''; } -1 8256 // -1 8257 highlight: null, 8754 8258 -1 8259 maxNesting: 100 // Internal protection, recursion limit -1 8260 }, 8755 82618756 -1 var parseLinkDestination = require('../helpers/parse_link_destination');8757 -1 var parseLinkTitle = require('../helpers/parse_link_title');8758 -1 var normalizeReference = require('../common/utils').normalizeReference;8759 -1 var isSpace = require('../common/utils').isSpace;-1 8262 components: { 8760 8263 -1 8264 core: {}, -1 8265 block: {}, -1 8266 inline: {} -1 8267 } -1 8268 }; 8761 82698762 -1 module.exports = function reference(state, startLine, _endLine, silent) {8763 -1 var ch,8764 -1 destEndPos,8765 -1 destEndLineNo,8766 -1 endLine,8767 -1 href,8768 -1 i,8769 -1 l,8770 -1 label,8771 -1 labelEnd,8772 -1 res,8773 -1 start,8774 -1 str,8775 -1 terminate,8776 -1 terminatorRules,8777 -1 title,8778 -1 lines = 0,8779 -1 pos = state.bMarks[startLine] + state.tShift[startLine],8780 -1 max = state.eMarks[startLine],8781 -1 nextLine = startLine + 1;-1 8270 },{}],51:[function(require,module,exports){ -1 8271 // "Zero" preset, with nothing enabled. Useful for manual configuring of simple -1 8272 // modes. For example, to parse bold/italic only. 8782 82738783 -1 if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; }-1 8274 'use strict'; 8784 82758785 -1 // Simple check to quickly interrupt scan on [link](url) at the start of line.8786 -1 // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/548787 -1 while (++pos < max) {8788 -1 if (state.src.charCodeAt(pos) === 0x5D /* ] */ &&8789 -1 state.src.charCodeAt(pos - 1) !== 0x5C/* \ */) {8790 -1 if (pos + 1 === max) { return false; }8791 -1 if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false; }8792 -1 break;8793 -1 }8794 -1 }8795 82768796 -1 endLine = state.lineMax;-1 8277 module.exports = { -1 8278 options: { -1 8279 html: false, // Enable HTML tags in source -1 8280 xhtmlOut: false, // Use '/' to close single tags (<br />) -1 8281 breaks: false, // Convert '\n' in paragraphs into <br> -1 8282 langPrefix: 'language-', // CSS language prefix for fenced blocks -1 8283 linkify: false, // autoconvert URL-like texts to links 8797 82848798 -1 // jump line-by-line until empty one or EOF8799 -1 terminatorRules = state.md.block.ruler.getRules('reference');-1 8285 // Enable some language-neutral replacements + quotes beautification -1 8286 typographer: false, 8800 82878801 -1 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {8802 -1 // this would be a code block normally, but after paragraph8803 -1 // it's considered a lazy continuation regardless of what's there8804 -1 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }-1 8288 // Double + single quotes replacement pairs, when typographer enabled, -1 8289 // and smartquotes on. Could be either a String or an Array. -1 8290 // -1 8291 // For example, you can use '«»„“' for Russian, '„“‚‘' for German, -1 8292 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp). -1 8293 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */ 8805 82948806 -1 // quirk for blockquotes, this line should already be checked by that rule8807 -1 if (state.sCount[nextLine] < 0) { continue; }-1 8295 // Highlighter function. Should return escaped HTML, -1 8296 // or '' if the source string is not changed and should be escaped externaly. -1 8297 // If result starts with <pre... internal wrapper is skipped. -1 8298 // -1 8299 // function (/*str, lang*/) { return ''; } -1 8300 // -1 8301 highlight: null, 8808 83028809 -1 // Some tags can terminate paragraph without empty line.8810 -1 terminate = false;8811 -1 for (i = 0, l = terminatorRules.length; i < l; i++) {8812 -1 if (terminatorRules[i](state, nextLine, endLine, true)) {8813 -1 terminate = true;8814 -1 break;8815 -1 }8816 -1 }8817 -1 if (terminate) { break; }8818 -1 }-1 8303 maxNesting: 20 // Internal protection, recursion limit -1 8304 }, 8819 83058820 -1 str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();8821 -1 max = str.length;-1 8306 components: { 8822 83078823 -1 for (pos = 1; pos < max; pos++) {8824 -1 ch = str.charCodeAt(pos);8825 -1 if (ch === 0x5B /* [ */) {8826 -1 return false;8827 -1 } else if (ch === 0x5D /* ] */) {8828 -1 labelEnd = pos;8829 -1 break;8830 -1 } else if (ch === 0x0A /* \n */) {8831 -1 lines++;8832 -1 } else if (ch === 0x5C /* \ */) {8833 -1 pos++;8834 -1 if (pos < max && str.charCodeAt(pos) === 0x0A) {8835 -1 lines++;8836 -1 }8837 -1 }8838 -1 }-1 8308 core: { -1 8309 rules: [ -1 8310 'normalize', -1 8311 'block', -1 8312 'inline' -1 8313 ] -1 8314 }, 8839 83158840 -1 if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false; }-1 8316 block: { -1 8317 rules: [ -1 8318 'paragraph' -1 8319 ] -1 8320 }, 8841 83218842 -1 // [label]: destination 'title'8843 -1 // ^^^ skip optional whitespace here8844 -1 for (pos = labelEnd + 2; pos < max; pos++) {8845 -1 ch = str.charCodeAt(pos);8846 -1 if (ch === 0x0A) {8847 -1 lines++;8848 -1 } else if (isSpace(ch)) {8849 -1 /*eslint no-empty:0*/8850 -1 } else {8851 -1 break;-1 8322 inline: { -1 8323 rules: [ -1 8324 'text' -1 8325 ], -1 8326 rules2: [ -1 8327 'balance_pairs', -1 8328 'text_collapse' -1 8329 ] 8852 8330 } 8853 8331 } -1 8332 }; 8854 83338855 -1 // [label]: destination 'title'8856 -1 // ^^^^^^^^^^^ parse this8857 -1 res = parseLinkDestination(str, pos, max);8858 -1 if (!res.ok) { return false; }-1 8334 },{}],52:[function(require,module,exports){ -1 8335 /** -1 8336 * class Renderer -1 8337 * -1 8338 * Generates HTML from parsed token stream. Each instance has independent -1 8339 * copy of rules. Those can be rewritten with ease. Also, you can add new -1 8340 * rules if you create plugin and adds new token types. -1 8341 **/ -1 8342 'use strict'; 8859 83438860 -1 href = state.md.normalizeLink(res.str);8861 -1 if (!state.md.validateLink(href)) { return false; }8862 83448863 -1 pos = res.pos;8864 -1 lines += res.lines;-1 8345 var assign = require('./common/utils').assign; -1 8346 var unescapeAll = require('./common/utils').unescapeAll; -1 8347 var escapeHtml = require('./common/utils').escapeHtml; 8865 83488866 -1 // save cursor state, we could require to rollback later8867 -1 destEndPos = pos;8868 -1 destEndLineNo = lines;8869 83498870 -1 // [label]: destination 'title'8871 -1 // ^^^ skipping those spaces8872 -1 start = pos;8873 -1 for (; pos < max; pos++) {8874 -1 ch = str.charCodeAt(pos);8875 -1 if (ch === 0x0A) {8876 -1 lines++;8877 -1 } else if (isSpace(ch)) {8878 -1 /*eslint no-empty:0*/8879 -1 } else {8880 -1 break;8881 -1 }8882 -1 }-1 8350 //////////////////////////////////////////////////////////////////////////////// 8883 83518884 -1 // [label]: destination 'title'8885 -1 // ^^^^^^^ parse this8886 -1 res = parseLinkTitle(str, pos, max);8887 -1 if (pos < max && start !== pos && res.ok) {8888 -1 title = res.str;8889 -1 pos = res.pos;8890 -1 lines += res.lines;8891 -1 } else {8892 -1 title = '';8893 -1 pos = destEndPos;8894 -1 lines = destEndLineNo;8895 -1 }-1 8352 var default_rules = {}; 8896 83538897 -1 // skip trailing spaces until the rest of the line8898 -1 while (pos < max) {8899 -1 ch = str.charCodeAt(pos);8900 -1 if (!isSpace(ch)) { break; }8901 -1 pos++;8902 -1 }8903 83548904 -1 if (pos < max && str.charCodeAt(pos) !== 0x0A) {8905 -1 if (title) {8906 -1 // garbage at the end of the line after title,8907 -1 // but it could still be a valid reference if we roll back8908 -1 title = '';8909 -1 pos = destEndPos;8910 -1 lines = destEndLineNo;8911 -1 while (pos < max) {8912 -1 ch = str.charCodeAt(pos);8913 -1 if (!isSpace(ch)) { break; }8914 -1 pos++;8915 -1 }8916 -1 }8917 -1 }-1 8355 default_rules.code_inline = function (tokens, idx, options, env, slf) { -1 8356 var token = tokens[idx]; 8918 83578919 -1 if (pos < max && str.charCodeAt(pos) !== 0x0A) {8920 -1 // garbage at the end of the line8921 -1 return false;8922 -1 }-1 8358 return '<code' + slf.renderAttrs(token) + '>' + -1 8359 escapeHtml(tokens[idx].content) + -1 8360 '</code>'; -1 8361 }; 8923 83628924 -1 label = normalizeReference(str.slice(1, labelEnd));8925 -1 if (!label) {8926 -1 // CommonMark 0.20 disallows empty labels8927 -1 return false;8928 -1 }8929 83638930 -1 // Reference can not terminate anything. This check is for safety only.8931 -1 /*istanbul ignore if*/8932 -1 if (silent) { return true; }-1 8364 default_rules.code_block = function (tokens, idx, options, env, slf) { -1 8365 var token = tokens[idx]; 8933 83668934 -1 if (typeof state.env.references === 'undefined') {8935 -1 state.env.references = {};-1 8367 return '<pre' + slf.renderAttrs(token) + '><code>' + -1 8368 escapeHtml(tokens[idx].content) + -1 8369 '</code></pre>\n'; -1 8370 }; -1 8371 -1 8372 -1 8373 default_rules.fence = function (tokens, idx, options, env, slf) { -1 8374 var token = tokens[idx], -1 8375 info = token.info ? unescapeAll(token.info).trim() : '', -1 8376 langName = '', -1 8377 highlighted, i, tmpAttrs, tmpToken; -1 8378 -1 8379 if (info) { -1 8380 langName = info.split(/\s+/g)[0]; 8936 8381 }8937 -1 if (typeof state.env.references[label] === 'undefined') {8938 -1 state.env.references[label] = { title: title, href: href };-1 8382 -1 8383 if (options.highlight) { -1 8384 highlighted = options.highlight(token.content, langName) || escapeHtml(token.content); -1 8385 } else { -1 8386 highlighted = escapeHtml(token.content); 8939 8387 } 8940 83888941 -1 state.line = startLine + lines + 1;8942 -1 return true;8943 -1 };-1 8389 if (highlighted.indexOf('<pre') === 0) { -1 8390 return highlighted + '\n'; -1 8391 } 8944 83928945 -1 },{"../common/utils":43,"../helpers/parse_link_destination":45,"../helpers/parse_link_title":47}],67:[function(require,module,exports){8946 -1 // Parser state class-1 8393 // If language exists, inject class gently, without mudofying original token. -1 8394 // May be, one day we will add .clone() for token and simplify this part, but -1 8395 // now we prefer to keep things local. -1 8396 if (info) { -1 8397 i = token.attrIndex('class'); -1 8398 tmpAttrs = token.attrs ? token.attrs.slice() : []; 8947 83998948 -1 'use strict';-1 8400 if (i < 0) { -1 8401 tmpAttrs.push([ 'class', options.langPrefix + langName ]); -1 8402 } else { -1 8403 tmpAttrs[i][1] += ' ' + options.langPrefix + langName; -1 8404 } 8949 84058950 -1 var Token = require('../token');8951 -1 var isSpace = require('../common/utils').isSpace;-1 8406 // Fake token just to render attributes -1 8407 tmpToken = { -1 8408 attrs: tmpAttrs -1 8409 }; 8952 8410 -1 8411 return '<pre><code' + slf.renderAttrs(tmpToken) + '>' -1 8412 + highlighted -1 8413 + '</code></pre>\n'; -1 8414 } 8953 84158954 -1 function StateBlock(src, md, env, tokens) {8955 -1 var ch, s, start, pos, len, indent, offset, indent_found;8956 84168957 -1 this.src = src;-1 8417 return '<pre><code' + slf.renderAttrs(token) + '>' -1 8418 + highlighted -1 8419 + '</code></pre>\n'; -1 8420 }; 8958 84218959 -1 // link to parser instance8960 -1 this.md = md;8961 84228962 -1 this.env = env;-1 8423 default_rules.image = function (tokens, idx, options, env, slf) { -1 8424 var token = tokens[idx]; 8963 8425 -1 8426 // "alt" attr MUST be set, even if empty. Because it's mandatory and -1 8427 // should be placed on proper position for tests. 8964 8428 //8965 -1 // Internal state vartiables8966 -1 //8967 -18968 -1 this.tokens = tokens;8969 -18970 -1 this.bMarks = []; // line begin offsets for fast jumps8971 -1 this.eMarks = []; // line end offsets for fast jumps8972 -1 this.tShift = []; // offsets of the first non-space characters (tabs not expanded)8973 -1 this.sCount = []; // indents for each line (tabs expanded)-1 8429 // Replace content with actual value 8974 84308975 -1 // block parser variables8976 -1 this.blkIndent = 0; // required block content indent8977 -1 // (for example, if we are in list)8978 -1 this.line = 0; // line index in src8979 -1 this.lineMax = 0; // lines count8980 -1 this.tight = false; // loose/tight mode for lists8981 -1 this.parentType = 'root'; // if `list`, block parser stops on two newlines8982 -1 this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)-1 8431 token.attrs[token.attrIndex('alt')][1] = -1 8432 slf.renderInlineAsText(token.children, options, env); 8983 84338984 -1 this.level = 0;-1 8434 return slf.renderToken(tokens, idx, options); -1 8435 }; 8985 84368986 -1 // renderer8987 -1 this.result = '';8988 84378989 -1 // Create caches8990 -1 // Generate markers.8991 -1 s = this.src;8992 -1 indent_found = false;-1 8438 default_rules.hardbreak = function (tokens, idx, options /*, env */) { -1 8439 return options.xhtmlOut ? '<br />\n' : '<br>\n'; -1 8440 }; -1 8441 default_rules.softbreak = function (tokens, idx, options /*, env */) { -1 8442 return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n'; -1 8443 }; 8993 84448994 -1 for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {8995 -1 ch = s.charCodeAt(pos);8996 84458997 -1 if (!indent_found) {8998 -1 if (isSpace(ch)) {8999 -1 indent++;-1 8446 default_rules.text = function (tokens, idx /*, options, env */) { -1 8447 return escapeHtml(tokens[idx].content); -1 8448 }; 9000 84499001 -1 if (ch === 0x09) {9002 -1 offset += 4 - offset % 4;9003 -1 } else {9004 -1 offset++;9005 -1 }9006 -1 continue;9007 -1 } else {9008 -1 indent_found = true;9009 -1 }9010 -1 }9011 84509012 -1 if (ch === 0x0A || pos === len - 1) {9013 -1 if (ch !== 0x0A) { pos++; }9014 -1 this.bMarks.push(start);9015 -1 this.eMarks.push(pos);9016 -1 this.tShift.push(indent);9017 -1 this.sCount.push(offset);-1 8451 default_rules.html_block = function (tokens, idx /*, options, env */) { -1 8452 return tokens[idx].content; -1 8453 }; -1 8454 default_rules.html_inline = function (tokens, idx /*, options, env */) { -1 8455 return tokens[idx].content; -1 8456 }; 9018 84579019 -1 indent_found = false;9020 -1 indent = 0;9021 -1 offset = 0;9022 -1 start = pos + 1;9023 -1 }9024 -1 }9025 84589026 -1 // Push fake entry to simplify cache bounds checks9027 -1 this.bMarks.push(s.length);9028 -1 this.eMarks.push(s.length);9029 -1 this.tShift.push(0);9030 -1 this.sCount.push(0);-1 8459 /** -1 8460 * new Renderer() -1 8461 * -1 8462 * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults. -1 8463 **/ -1 8464 function Renderer() { 9031 84659032 -1 this.lineMax = this.bMarks.length - 1; // don't count last fake line-1 8466 /** -1 8467 * Renderer#rules -> Object -1 8468 * -1 8469 * Contains render rules for tokens. Can be updated and extended. -1 8470 * -1 8471 * ##### Example -1 8472 * -1 8473 * ```javascript -1 8474 * var md = require('markdown-it')(); -1 8475 * -1 8476 * md.renderer.rules.strong_open = function () { return '<b>'; }; -1 8477 * md.renderer.rules.strong_close = function () { return '</b>'; }; -1 8478 * -1 8479 * var result = md.renderInline(...); -1 8480 * ``` -1 8481 * -1 8482 * Each rule is called as independed static function with fixed signature: -1 8483 * -1 8484 * ```javascript -1 8485 * function my_token_render(tokens, idx, options, env, renderer) { -1 8486 * // ... -1 8487 * return renderedHTML; -1 8488 * } -1 8489 * ``` -1 8490 * -1 8491 * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js) -1 8492 * for more details and examples. -1 8493 **/ -1 8494 this.rules = assign({}, default_rules); 9033 8495 } 9034 84969035 -1 // Push new token to "stream".9036 -1 //9037 -1 StateBlock.prototype.push = function (type, tag, nesting) {9038 -1 var token = new Token(type, tag, nesting);9039 -1 token.block = true;9040 84979041 -1 if (nesting < 0) { this.level--; }9042 -1 token.level = this.level;9043 -1 if (nesting > 0) { this.level++; }-1 8498 /** -1 8499 * Renderer.renderAttrs(token) -> String -1 8500 * -1 8501 * Render token attributes to string. -1 8502 **/ -1 8503 Renderer.prototype.renderAttrs = function renderAttrs(token) { -1 8504 var i, l, result; 9044 85059045 -1 this.tokens.push(token);9046 -1 return token;9047 -1 };-1 8506 if (!token.attrs) { return ''; } 9048 85079049 -1 StateBlock.prototype.isEmpty = function isEmpty(line) {9050 -1 return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];9051 -1 };-1 8508 result = ''; 9052 85099053 -1 StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {9054 -1 for (var max = this.lineMax; from < max; from++) {9055 -1 if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {9056 -1 break;9057 -1 }-1 8510 for (i = 0, l = token.attrs.length; i < l; i++) { -1 8511 result += ' ' + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"'; 9058 8512 }9059 -1 return from;9060 -1 };9061 -19062 -1 // Skip spaces from given position.9063 -1 StateBlock.prototype.skipSpaces = function skipSpaces(pos) {9064 -1 var ch;9065 85139066 -1 for (var max = this.src.length; pos < max; pos++) {9067 -1 ch = this.src.charCodeAt(pos);9068 -1 if (!isSpace(ch)) { break; }9069 -1 }9070 -1 return pos;-1 8514 return result; 9071 8515 }; 9072 85169073 -1 // Skip spaces from given position in reverse.9074 -1 StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {9075 -1 if (pos <= min) { return pos; }9076 85179077 -1 while (pos > min) {9078 -1 if (!isSpace(this.src.charCodeAt(--pos))) { return pos + 1; }9079 -1 }9080 -1 return pos;9081 -1 };-1 8518 /** -1 8519 * Renderer.renderToken(tokens, idx, options) -> String -1 8520 * - tokens (Array): list of tokens -1 8521 * - idx (Numbed): token index to render -1 8522 * - options (Object): params of parser instance -1 8523 * -1 8524 * Default token renderer. Can be overriden by custom function -1 8525 * in [[Renderer#rules]]. -1 8526 **/ -1 8527 Renderer.prototype.renderToken = function renderToken(tokens, idx, options) { -1 8528 var nextToken, -1 8529 result = '', -1 8530 needLf = false, -1 8531 token = tokens[idx]; 9082 85329083 -1 // Skip char codes from given position9084 -1 StateBlock.prototype.skipChars = function skipChars(pos, code) {9085 -1 for (var max = this.src.length; pos < max; pos++) {9086 -1 if (this.src.charCodeAt(pos) !== code) { break; }-1 8533 // Tight list paragraphs -1 8534 if (token.hidden) { -1 8535 return ''; 9087 8536 }9088 -1 return pos;9089 -1 };9090 -19091 -1 // Skip char codes reverse from given position - 19092 -1 StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {9093 -1 if (pos <= min) { return pos; }9094 85379095 -1 while (pos > min) {9096 -1 if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }-1 8538 // Insert a newline between hidden paragraph and subsequent opening -1 8539 // block-level tag. -1 8540 // -1 8541 // For example, here we should insert a newline before blockquote: -1 8542 // - a -1 8543 // > -1 8544 // -1 8545 if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) { -1 8546 result += '\n'; 9097 8547 }9098 -1 return pos;9099 -1 };9100 85489101 -1 // cut lines range from source.9102 -1 StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {9103 -1 var i, lineIndent, ch, first, last, queue, lineStart,9104 -1 line = begin;-1 8549 // Add token name, e.g. `<img` -1 8550 result += (token.nesting === -1 ? '</' : '<') + token.tag; 9105 85519106 -1 if (begin >= end) {9107 -1 return '';9108 -1 }-1 8552 // Encode attributes, e.g. `<img src="foo"` -1 8553 result += this.renderAttrs(token); 9109 85549110 -1 queue = new Array(end - begin);-1 8555 // Add a slash for self-closing tags, e.g. `<img src="foo" /` -1 8556 if (token.nesting === 0 && options.xhtmlOut) { -1 8557 result += ' /'; -1 8558 } 9111 85599112 -1 for (i = 0; line < end; line++, i++) {9113 -1 lineIndent = 0;9114 -1 lineStart = first = this.bMarks[line];-1 8560 // Check if we need to add a newline after this tag -1 8561 if (token.block) { -1 8562 needLf = true; 9115 85639116 -1 if (line + 1 < end || keepLastLF) {9117 -1 // No need for bounds check because we have fake entry on tail.9118 -1 last = this.eMarks[line] + 1;9119 -1 } else {9120 -1 last = this.eMarks[line];9121 -1 }-1 8564 if (token.nesting === 1) { -1 8565 if (idx + 1 < tokens.length) { -1 8566 nextToken = tokens[idx + 1]; 9122 85679123 -1 while (first < last && lineIndent < indent) {9124 -1 ch = this.src.charCodeAt(first);-1 8568 if (nextToken.type === 'inline' || nextToken.hidden) { -1 8569 // Block-level tag containing an inline tag. -1 8570 // -1 8571 needLf = false; 9125 85729126 -1 if (isSpace(ch)) {9127 -1 if (ch === 0x09) {9128 -1 lineIndent += 4 - lineIndent % 4;9129 -1 } else {9130 -1 lineIndent++;-1 8573 } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) { -1 8574 // Opening tag + closing tag of the same type. E.g. `<li></li>`. -1 8575 // -1 8576 needLf = false; 9131 8577 }9132 -1 } else if (first - lineStart < this.tShift[line]) {9133 -1 // patched tShift masked characters to look like spaces (blockquotes, list markers)9134 -1 lineIndent++;9135 -1 } else {9136 -1 break;9137 8578 }9138 -19139 -1 first++;9140 8579 }9141 -19142 -1 queue[i] = this.src.slice(first, last);9143 8580 } 9144 85819145 -1 return queue.join('');9146 -1 };9147 -19148 -1 // re-export Token class to use in block rules9149 -1 StateBlock.prototype.Token = Token;9150 -19151 -19152 -1 module.exports = StateBlock;9153 -19154 -1 },{"../common/utils":43,"../token":90}],68:[function(require,module,exports){9155 -1 // GFM table, non-standard9156 -19157 -1 'use strict';9158 -1-1 8582 result += needLf ? '>\n' : '>'; 9159 85839160 -1 function getLine(state, line) {9161 -1 var pos = state.bMarks[line] + state.blkIndent,9162 -1 max = state.eMarks[line];-1 8584 return result; -1 8585 }; 9163 85869164 -1 return state.src.substr(pos, max - pos);9165 -1 }9166 85879167 -1 function escapedSplit(str) {9168 -1 var result = [],9169 -1 pos = 0,9170 -1 max = str.length,9171 -1 ch,9172 -1 escapes = 0,9173 -1 lastPos = 0,9174 -1 backTicked = false,9175 -1 lastBackTick = 0;-1 8588 /** -1 8589 * Renderer.renderInline(tokens, options, env) -> String -1 8590 * - tokens (Array): list on block tokens to renter -1 8591 * - options (Object): params of parser instance -1 8592 * - env (Object): additional data from parsed input (references, for example) -1 8593 * -1 8594 * The same as [[Renderer.render]], but for single token of `inline` type. -1 8595 **/ -1 8596 Renderer.prototype.renderInline = function (tokens, options, env) { -1 8597 var type, -1 8598 result = '', -1 8599 rules = this.rules; 9176 86009177 -1 ch = str.charCodeAt(pos);-1 8601 for (var i = 0, len = tokens.length; i < len; i++) { -1 8602 type = tokens[i].type; 9178 86039179 -1 while (pos < max) {9180 -1 if (ch === 0x60/* ` */ && (escapes % 2 === 0)) {9181 -1 backTicked = !backTicked;9182 -1 lastBackTick = pos;9183 -1 } else if (ch === 0x7c/* | */ && (escapes % 2 === 0) && !backTicked) {9184 -1 result.push(str.substring(lastPos, pos));9185 -1 lastPos = pos + 1;9186 -1 } else if (ch === 0x5c/* \ */) {9187 -1 escapes++;-1 8604 if (typeof rules[type] !== 'undefined') { -1 8605 result += rules[type](tokens, i, options, env, this); 9188 8606 } else {9189 -1 escapes = 0;9190 -1 }9191 -19192 -1 pos++;9193 -19194 -1 // If there was an un-closed backtick, go back to just after9195 -1 // the last backtick, but as if it was a normal character9196 -1 if (pos === max && backTicked) {9197 -1 backTicked = false;9198 -1 pos = lastBackTick + 1;-1 8607 result += this.renderToken(tokens, i, options); 9199 8608 }9200 -19201 -1 ch = str.charCodeAt(pos);9202 8609 } 9203 86109204 -1 result.push(str.substring(lastPos));9205 -19206 8611 return result;9207 -1 }9208 -19209 -19210 -1 module.exports = function table(state, startLine, endLine, silent) {9211 -1 var ch, lineText, pos, i, nextLine, columns, columnCount, token,9212 -1 aligns, t, tableLines, tbodyLines;9213 -19214 -1 // should have at least three lines9215 -1 if (startLine + 2 > endLine) { return false; }-1 8612 }; 9216 86139217 -1 nextLine = startLine + 1;9218 86149219 -1 if (state.sCount[nextLine] < state.blkIndent) { return false; }-1 8615 /** internal -1 8616 * Renderer.renderInlineAsText(tokens, options, env) -> String -1 8617 * - tokens (Array): list on block tokens to renter -1 8618 * - options (Object): params of parser instance -1 8619 * - env (Object): additional data from parsed input (references, for example) -1 8620 * -1 8621 * Special kludge for image `alt` attributes to conform CommonMark spec. -1 8622 * Don't try to use it! Spec requires to show `alt` content with stripped markup, -1 8623 * instead of simple escaping. -1 8624 **/ -1 8625 Renderer.prototype.renderInlineAsText = function (tokens, options, env) { -1 8626 var result = ''; 9220 86279221 -1 // first character of the second line should be '|' or '-'-1 8628 for (var i = 0, len = tokens.length; i < len; i++) { -1 8629 if (tokens[i].type === 'text') { -1 8630 result += tokens[i].content; -1 8631 } else if (tokens[i].type === 'image') { -1 8632 result += this.renderInlineAsText(tokens[i].children, options, env); -1 8633 } -1 8634 } 9222 86359223 -1 pos = state.bMarks[nextLine] + state.tShift[nextLine];9224 -1 if (pos >= state.eMarks[nextLine]) { return false; }-1 8636 return result; -1 8637 }; 9225 86389226 -1 ch = state.src.charCodeAt(pos);9227 -1 if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; }9228 86399229 -1 lineText = getLine(state, startLine + 1);9230 -1 if (!/^[-:| ]+$/.test(lineText)) { return false; }-1 8640 /** -1 8641 * Renderer.render(tokens, options, env) -> String -1 8642 * - tokens (Array): list on block tokens to renter -1 8643 * - options (Object): params of parser instance -1 8644 * - env (Object): additional data from parsed input (references, for example) -1 8645 * -1 8646 * Takes token stream and generates HTML. Probably, you will never need to call -1 8647 * this method directly. -1 8648 **/ -1 8649 Renderer.prototype.render = function (tokens, options, env) { -1 8650 var i, len, type, -1 8651 result = '', -1 8652 rules = this.rules; 9231 86539232 -1 columns = lineText.split('|');9233 -1 aligns = [];9234 -1 for (i = 0; i < columns.length; i++) {9235 -1 t = columns[i].trim();9236 -1 if (!t) {9237 -1 // allow empty columns before and after table, but not in between columns;9238 -1 // e.g. allow ` |---| `, disallow ` ---||--- `9239 -1 if (i === 0 || i === columns.length - 1) {9240 -1 continue;9241 -1 } else {9242 -1 return false;9243 -1 }9244 -1 }-1 8654 for (i = 0, len = tokens.length; i < len; i++) { -1 8655 type = tokens[i].type; 9245 86569246 -1 if (!/^:?-+:?$/.test(t)) { return false; }9247 -1 if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {9248 -1 aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');9249 -1 } else if (t.charCodeAt(0) === 0x3A/* : */) {9250 -1 aligns.push('left');-1 8657 if (type === 'inline') { -1 8658 result += this.renderInline(tokens[i].children, options, env); -1 8659 } else if (typeof rules[type] !== 'undefined') { -1 8660 result += rules[tokens[i].type](tokens, i, options, env, this); 9251 8661 } else {9252 -1 aligns.push('');-1 8662 result += this.renderToken(tokens, i, options, env); 9253 8663 } 9254 8664 } 9255 86659256 -1 lineText = getLine(state, startLine).trim();9257 -1 if (lineText.indexOf('|') === -1) { return false; }9258 -1 columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));-1 8666 return result; -1 8667 }; 9259 86689260 -1 // header row will define an amount of columns in the entire table,9261 -1 // and align row shouldn't be smaller than that (the rest of the rows can)9262 -1 columnCount = columns.length;9263 -1 if (columnCount > aligns.length) { return false; }-1 8669 module.exports = Renderer; 9264 86709265 -1 if (silent) { return true; }-1 8671 },{"./common/utils":40}],53:[function(require,module,exports){ -1 8672 /** -1 8673 * class Ruler -1 8674 * -1 8675 * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and -1 8676 * [[MarkdownIt#inline]] to manage sequences of functions (rules): -1 8677 * -1 8678 * - keep rules in defined order -1 8679 * - assign the name to each rule -1 8680 * - enable/disable rules -1 8681 * - add/replace rules -1 8682 * - allow assign rules to additional named chains (in the same) -1 8683 * - cacheing lists of active rules -1 8684 * -1 8685 * You will not need use this class directly until write plugins. For simple -1 8686 * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and -1 8687 * [[MarkdownIt.use]]. -1 8688 **/ -1 8689 'use strict'; 9266 86909267 -1 token = state.push('table_open', 'table', 1);9268 -1 token.map = tableLines = [ startLine, 0 ];9269 86919270 -1 token = state.push('thead_open', 'thead', 1);9271 -1 token.map = [ startLine, startLine + 1 ];-1 8692 /** -1 8693 * new Ruler() -1 8694 **/ -1 8695 function Ruler() { -1 8696 // List of added rules. Each element is: -1 8697 // -1 8698 // { -1 8699 // name: XXX, -1 8700 // enabled: Boolean, -1 8701 // fn: Function(), -1 8702 // alt: [ name2, name3 ] -1 8703 // } -1 8704 // -1 8705 this.__rules__ = []; 9272 87069273 -1 token = state.push('tr_open', 'tr', 1);9274 -1 token.map = [ startLine, startLine + 1 ];-1 8707 // Cached rule chains. -1 8708 // -1 8709 // First level - chain name, '' for default. -1 8710 // Second level - diginal anchor for fast filtering by charcodes. -1 8711 // -1 8712 this.__cache__ = null; -1 8713 } 9275 87149276 -1 for (i = 0; i < columns.length; i++) {9277 -1 token = state.push('th_open', 'th', 1);9278 -1 token.map = [ startLine, startLine + 1 ];9279 -1 if (aligns[i]) {9280 -1 token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];9281 -1 }-1 8715 //////////////////////////////////////////////////////////////////////////////// -1 8716 // Helper methods, should not be used directly 9282 87179283 -1 token = state.push('inline', '', 0);9284 -1 token.content = columns[i].trim();9285 -1 token.map = [ startLine, startLine + 1 ];9286 -1 token.children = [];9287 87189288 -1 token = state.push('th_close', 'th', -1);-1 8719 // Find rule index by name -1 8720 // -1 8721 Ruler.prototype.__find__ = function (name) { -1 8722 for (var i = 0; i < this.__rules__.length; i++) { -1 8723 if (this.__rules__[i].name === name) { -1 8724 return i; -1 8725 } 9289 8726 } -1 8727 return -1; -1 8728 }; 9290 87299291 -1 token = state.push('tr_close', 'tr', -1);9292 -1 token = state.push('thead_close', 'thead', -1);9293 -19294 -1 token = state.push('tbody_open', 'tbody', 1);9295 -1 token.map = tbodyLines = [ startLine + 2, 0 ];9296 -19297 -1 for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {9298 -1 if (state.sCount[nextLine] < state.blkIndent) { break; }9299 87309300 -1 lineText = getLine(state, nextLine);9301 -1 if (lineText.indexOf('|') === -1) { break; }-1 8731 // Build rules lookup cache -1 8732 // -1 8733 Ruler.prototype.__compile__ = function () { -1 8734 var self = this; -1 8735 var chains = [ '' ]; 9302 87369303 -1 // keep spaces at beginning of line to indicate an empty first cell, but9304 -1 // strip trailing whitespace9305 -1 columns = escapedSplit(lineText.replace(/^\||\|\s*$/g, ''));-1 8737 // collect unique names -1 8738 self.__rules__.forEach(function (rule) { -1 8739 if (!rule.enabled) { return; } 9306 87409307 -1 token = state.push('tr_open', 'tr', 1);9308 -1 for (i = 0; i < columnCount; i++) {9309 -1 token = state.push('td_open', 'td', 1);9310 -1 if (aligns[i]) {9311 -1 token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];-1 8741 rule.alt.forEach(function (altName) { -1 8742 if (chains.indexOf(altName) < 0) { -1 8743 chains.push(altName); 9312 8744 } -1 8745 }); -1 8746 }); 9313 87479314 -1 token = state.push('inline', '', 0);9315 -1 token.content = columns[i] ? columns[i].trim() : '';9316 -1 token.children = [];-1 8748 self.__cache__ = {}; 9317 87499318 -1 token = state.push('td_close', 'td', -1);9319 -1 }9320 -1 token = state.push('tr_close', 'tr', -1);9321 -1 }9322 -1 token = state.push('tbody_close', 'tbody', -1);9323 -1 token = state.push('table_close', 'table', -1);-1 8750 chains.forEach(function (chain) { -1 8751 self.__cache__[chain] = []; -1 8752 self.__rules__.forEach(function (rule) { -1 8753 if (!rule.enabled) { return; } 9324 87549325 -1 tableLines[1] = tbodyLines[1] = nextLine;9326 -1 state.line = nextLine;9327 -1 return true;-1 8755 if (chain && rule.alt.indexOf(chain) < 0) { return; } -1 8756 -1 8757 self.__cache__[chain].push(rule.fn); -1 8758 }); -1 8759 }); 9328 8760 }; 9329 87619330 -1 },{}],69:[function(require,module,exports){9331 -1 'use strict';9332 8762 -1 8763 /** -1 8764 * Ruler.at(name, fn [, options]) -1 8765 * - name (String): rule name to replace. -1 8766 * - fn (Function): new rule function. -1 8767 * - options (Object): new rule options (not mandatory). -1 8768 * -1 8769 * Replace rule by name with new function & options. Throws error if name not -1 8770 * found. -1 8771 * -1 8772 * ##### Options: -1 8773 * -1 8774 * - __alt__ - array with names of "alternate" chains. -1 8775 * -1 8776 * ##### Example -1 8777 * -1 8778 * Replace existing typorgapher replacement rule with new one: -1 8779 * -1 8780 * ```javascript -1 8781 * var md = require('markdown-it')(); -1 8782 * -1 8783 * md.core.ruler.at('replacements', function replace(state) { -1 8784 * //... -1 8785 * }); -1 8786 * ``` -1 8787 **/ -1 8788 Ruler.prototype.at = function (name, fn, options) { -1 8789 var index = this.__find__(name); -1 8790 var opt = options || {}; 9333 87919334 -1 module.exports = function block(state) {9335 -1 var token;-1 8792 if (index === -1) { throw new Error('Parser rule not found: ' + name); } 9336 87939337 -1 if (state.inlineMode) {9338 -1 token = new state.Token('inline', '', 0);9339 -1 token.content = state.src;9340 -1 token.map = [ 0, 1 ];9341 -1 token.children = [];9342 -1 state.tokens.push(token);9343 -1 } else {9344 -1 state.md.block.parse(state.src, state.md, state.env, state.tokens);9345 -1 }-1 8794 this.__rules__[index].fn = fn; -1 8795 this.__rules__[index].alt = opt.alt || []; -1 8796 this.__cache__ = null; 9346 8797 }; 9347 87989348 -1 },{}],70:[function(require,module,exports){9349 -1 'use strict';9350 -19351 -1 module.exports = function inline(state) {9352 -1 var tokens = state.tokens, tok, i, l;9353 87999354 -1 // Parse inlines9355 -1 for (i = 0, l = tokens.length; i < l; i++) {9356 -1 tok = tokens[i];9357 -1 if (tok.type === 'inline') {9358 -1 state.md.inline.parse(tok.content, state.md, state.env, tok.children);9359 -1 }9360 -1 }9361 -1 };-1 8800 /** -1 8801 * Ruler.before(beforeName, ruleName, fn [, options]) -1 8802 * - beforeName (String): new rule will be added before this one. -1 8803 * - ruleName (String): name of added rule. -1 8804 * - fn (Function): rule function. -1 8805 * - options (Object): rule options (not mandatory). -1 8806 * -1 8807 * Add new rule to chain before one with given name. See also -1 8808 * [[Ruler.after]], [[Ruler.push]]. -1 8809 * -1 8810 * ##### Options: -1 8811 * -1 8812 * - __alt__ - array with names of "alternate" chains. -1 8813 * -1 8814 * ##### Example -1 8815 * -1 8816 * ```javascript -1 8817 * var md = require('markdown-it')(); -1 8818 * -1 8819 * md.block.ruler.before('paragraph', 'my_rule', function replace(state) { -1 8820 * //... -1 8821 * }); -1 8822 * ``` -1 8823 **/ -1 8824 Ruler.prototype.before = function (beforeName, ruleName, fn, options) { -1 8825 var index = this.__find__(beforeName); -1 8826 var opt = options || {}; 9362 88279363 -1 },{}],71:[function(require,module,exports){9364 -1 // Replace link-like texts with link nodes.9365 -1 //9366 -1 // Currently restricted by `md.validateLink()` to http/https/ftp9367 -1 //9368 -1 'use strict';-1 8828 if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); } 9369 8829 -1 8830 this.__rules__.splice(index, 0, { -1 8831 name: ruleName, -1 8832 enabled: true, -1 8833 fn: fn, -1 8834 alt: opt.alt || [] -1 8835 }); 9370 88369371 -1 var arrayReplaceAt = require('../common/utils').arrayReplaceAt;-1 8837 this.__cache__ = null; -1 8838 }; 9372 8839 9373 88409374 -1 function isLinkOpen(str) {9375 -1 return /^<a[>\s]/i.test(str);9376 -1 }9377 -1 function isLinkClose(str) {9378 -1 return /^<\/a\s*>/i.test(str);9379 -1 }-1 8841 /** -1 8842 * Ruler.after(afterName, ruleName, fn [, options]) -1 8843 * - afterName (String): new rule will be added after this one. -1 8844 * - ruleName (String): name of added rule. -1 8845 * - fn (Function): rule function. -1 8846 * - options (Object): rule options (not mandatory). -1 8847 * -1 8848 * Add new rule to chain after one with given name. See also -1 8849 * [[Ruler.before]], [[Ruler.push]]. -1 8850 * -1 8851 * ##### Options: -1 8852 * -1 8853 * - __alt__ - array with names of "alternate" chains. -1 8854 * -1 8855 * ##### Example -1 8856 * -1 8857 * ```javascript -1 8858 * var md = require('markdown-it')(); -1 8859 * -1 8860 * md.inline.ruler.after('text', 'my_rule', function replace(state) { -1 8861 * //... -1 8862 * }); -1 8863 * ``` -1 8864 **/ -1 8865 Ruler.prototype.after = function (afterName, ruleName, fn, options) { -1 8866 var index = this.__find__(afterName); -1 8867 var opt = options || {}; 9380 8868 -1 8869 if (index === -1) { throw new Error('Parser rule not found: ' + afterName); } 9381 88709382 -1 module.exports = function linkify(state) {9383 -1 var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos,9384 -1 level, htmlLinkLevel, url, fullUrl, urlText,9385 -1 blockTokens = state.tokens,9386 -1 links;-1 8871 this.__rules__.splice(index + 1, 0, { -1 8872 name: ruleName, -1 8873 enabled: true, -1 8874 fn: fn, -1 8875 alt: opt.alt || [] -1 8876 }); 9387 88779388 -1 if (!state.md.options.linkify) { return; }-1 8878 this.__cache__ = null; -1 8879 }; 9389 88809390 -1 for (j = 0, l = blockTokens.length; j < l; j++) {9391 -1 if (blockTokens[j].type !== 'inline' ||9392 -1 !state.md.linkify.pretest(blockTokens[j].content)) {9393 -1 continue;9394 -1 }-1 8881 /** -1 8882 * Ruler.push(ruleName, fn [, options]) -1 8883 * - ruleName (String): name of added rule. -1 8884 * - fn (Function): rule function. -1 8885 * - options (Object): rule options (not mandatory). -1 8886 * -1 8887 * Push new rule to the end of chain. See also -1 8888 * [[Ruler.before]], [[Ruler.after]]. -1 8889 * -1 8890 * ##### Options: -1 8891 * -1 8892 * - __alt__ - array with names of "alternate" chains. -1 8893 * -1 8894 * ##### Example -1 8895 * -1 8896 * ```javascript -1 8897 * var md = require('markdown-it')(); -1 8898 * -1 8899 * md.core.ruler.push('my_rule', function replace(state) { -1 8900 * //... -1 8901 * }); -1 8902 * ``` -1 8903 **/ -1 8904 Ruler.prototype.push = function (ruleName, fn, options) { -1 8905 var opt = options || {}; 9395 89069396 -1 tokens = blockTokens[j].children;-1 8907 this.__rules__.push({ -1 8908 name: ruleName, -1 8909 enabled: true, -1 8910 fn: fn, -1 8911 alt: opt.alt || [] -1 8912 }); 9397 89139398 -1 htmlLinkLevel = 0;-1 8914 this.__cache__ = null; -1 8915 }; 9399 89169400 -1 // We scan from the end, to keep position when new tags added.9401 -1 // Use reversed logic in links start/end match9402 -1 for (i = tokens.length - 1; i >= 0; i--) {9403 -1 currentToken = tokens[i];9404 89179405 -1 // Skip content of markdown links9406 -1 if (currentToken.type === 'link_close') {9407 -1 i--;9408 -1 while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') {9409 -1 i--;9410 -1 }9411 -1 continue;9412 -1 }-1 8918 /** -1 8919 * Ruler.enable(list [, ignoreInvalid]) -> Array -1 8920 * - list (String|Array): list of rule names to enable. -1 8921 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. -1 8922 * -1 8923 * Enable rules with given names. If any rule name not found - throw Error. -1 8924 * Errors can be disabled by second param. -1 8925 * -1 8926 * Returns list of found rule names (if no exception happened). -1 8927 * -1 8928 * See also [[Ruler.disable]], [[Ruler.enableOnly]]. -1 8929 **/ -1 8930 Ruler.prototype.enable = function (list, ignoreInvalid) { -1 8931 if (!Array.isArray(list)) { list = [ list ]; } 9413 89329414 -1 // Skip content of html tag links9415 -1 if (currentToken.type === 'html_inline') {9416 -1 if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {9417 -1 htmlLinkLevel--;9418 -1 }9419 -1 if (isLinkClose(currentToken.content)) {9420 -1 htmlLinkLevel++;9421 -1 }9422 -1 }9423 -1 if (htmlLinkLevel > 0) { continue; }-1 8933 var result = []; 9424 89349425 -1 if (currentToken.type === 'text' && state.md.linkify.test(currentToken.content)) {-1 8935 // Search by name and enable -1 8936 list.forEach(function (name) { -1 8937 var idx = this.__find__(name); 9426 89389427 -1 text = currentToken.content;9428 -1 links = state.md.linkify.match(text);-1 8939 if (idx < 0) { -1 8940 if (ignoreInvalid) { return; } -1 8941 throw new Error('Rules manager: invalid rule name ' + name); -1 8942 } -1 8943 this.__rules__[idx].enabled = true; -1 8944 result.push(name); -1 8945 }, this); 9429 89469430 -1 // Now split string to nodes9431 -1 nodes = [];9432 -1 level = currentToken.level;9433 -1 lastPos = 0;-1 8947 this.__cache__ = null; -1 8948 return result; -1 8949 }; 9434 89509435 -1 for (ln = 0; ln < links.length; ln++) {9436 89519437 -1 url = links[ln].url;9438 -1 fullUrl = state.md.normalizeLink(url);9439 -1 if (!state.md.validateLink(fullUrl)) { continue; }-1 8952 /** -1 8953 * Ruler.enableOnly(list [, ignoreInvalid]) -1 8954 * - list (String|Array): list of rule names to enable (whitelist). -1 8955 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. -1 8956 * -1 8957 * Enable rules with given names, and disable everything else. If any rule name -1 8958 * not found - throw Error. Errors can be disabled by second param. -1 8959 * -1 8960 * See also [[Ruler.disable]], [[Ruler.enable]]. -1 8961 **/ -1 8962 Ruler.prototype.enableOnly = function (list, ignoreInvalid) { -1 8963 if (!Array.isArray(list)) { list = [ list ]; } 9440 89649441 -1 urlText = links[ln].text;-1 8965 this.__rules__.forEach(function (rule) { rule.enabled = false; }); 9442 89669443 -1 // Linkifier might send raw hostnames like "example.com", where url9444 -1 // starts with domain name. So we prepend http:// in those cases,9445 -1 // and remove it afterwards.9446 -1 //9447 -1 if (!links[ln].schema) {9448 -1 urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\/\//, '');9449 -1 } else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) {9450 -1 urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, '');9451 -1 } else {9452 -1 urlText = state.md.normalizeLinkText(urlText);9453 -1 }-1 8967 this.enable(list, ignoreInvalid); -1 8968 }; 9454 89699455 -1 pos = links[ln].index;9456 89709457 -1 if (pos > lastPos) {9458 -1 token = new state.Token('text', '', 0);9459 -1 token.content = text.slice(lastPos, pos);9460 -1 token.level = level;9461 -1 nodes.push(token);9462 -1 }-1 8971 /** -1 8972 * Ruler.disable(list [, ignoreInvalid]) -> Array -1 8973 * - list (String|Array): list of rule names to disable. -1 8974 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. -1 8975 * -1 8976 * Disable rules with given names. If any rule name not found - throw Error. -1 8977 * Errors can be disabled by second param. -1 8978 * -1 8979 * Returns list of found rule names (if no exception happened). -1 8980 * -1 8981 * See also [[Ruler.enable]], [[Ruler.enableOnly]]. -1 8982 **/ -1 8983 Ruler.prototype.disable = function (list, ignoreInvalid) { -1 8984 if (!Array.isArray(list)) { list = [ list ]; } 9463 89859464 -1 token = new state.Token('link_open', 'a', 1);9465 -1 token.attrs = [ [ 'href', fullUrl ] ];9466 -1 token.level = level++;9467 -1 token.markup = 'linkify';9468 -1 token.info = 'auto';9469 -1 nodes.push(token);-1 8986 var result = []; 9470 89879471 -1 token = new state.Token('text', '', 0);9472 -1 token.content = urlText;9473 -1 token.level = level;9474 -1 nodes.push(token);-1 8988 // Search by name and disable -1 8989 list.forEach(function (name) { -1 8990 var idx = this.__find__(name); 9475 89919476 -1 token = new state.Token('link_close', 'a', -1);9477 -1 token.level = --level;9478 -1 token.markup = 'linkify';9479 -1 token.info = 'auto';9480 -1 nodes.push(token);-1 8992 if (idx < 0) { -1 8993 if (ignoreInvalid) { return; } -1 8994 throw new Error('Rules manager: invalid rule name ' + name); -1 8995 } -1 8996 this.__rules__[idx].enabled = false; -1 8997 result.push(name); -1 8998 }, this); 9481 89999482 -1 lastPos = links[ln].lastIndex;9483 -1 }9484 -1 if (lastPos < text.length) {9485 -1 token = new state.Token('text', '', 0);9486 -1 token.content = text.slice(lastPos);9487 -1 token.level = level;9488 -1 nodes.push(token);9489 -1 }-1 9000 this.__cache__ = null; -1 9001 return result; -1 9002 }; 9490 90039491 -1 // replace current node9492 -1 blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);9493 -1 }9494 -1 }-1 9004 -1 9005 /** -1 9006 * Ruler.getRules(chainName) -> Array -1 9007 * -1 9008 * Return array of active functions (rules) for given chain name. It analyzes -1 9009 * rules configuration, compiles caches if not exists and returns result. -1 9010 * -1 9011 * Default chain name is `''` (empty string). It can't be skipped. That's -1 9012 * done intentionally, to keep signature monomorphic for high speed. -1 9013 **/ -1 9014 Ruler.prototype.getRules = function (chainName) { -1 9015 if (this.__cache__ === null) { -1 9016 this.__compile__(); 9495 9017 } -1 9018 -1 9019 // Chain can be empty, if rules disabled. But we still have to return Array. -1 9020 return this.__cache__[chainName] || []; 9496 9021 }; 9497 90229498 -1 },{"../common/utils":43}],72:[function(require,module,exports){9499 -1 // Normalize input string-1 9023 module.exports = Ruler; -1 9024 -1 9025 },{}],54:[function(require,module,exports){ -1 9026 // Block quotes 9500 9027 9501 9028 'use strict'; 9502 9029 -1 9030 var isSpace = require('../common/utils').isSpace; 9503 90319504 -1 var NEWLINES_RE = /\r[\n\u0085]?|[\u2424\u2028\u0085]/g;9505 -1 var NULL_RE = /\u0000/g;9506 9032 -1 9033 module.exports = function blockquote(state, startLine, endLine, silent) { -1 9034 var nextLine, lastLineEmpty, oldTShift, oldSCount, oldBMarks, oldIndent, oldParentType, lines, initial, offset, ch, -1 9035 terminatorRules, token, -1 9036 i, l, terminate, -1 9037 pos = state.bMarks[startLine] + state.tShift[startLine], -1 9038 max = state.eMarks[startLine]; 9507 90399508 -1 module.exports = function inline(state) {9509 -1 var str;-1 9040 // check the block quote marker -1 9041 if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; } 9510 90429511 -1 // Normalize newlines9512 -1 str = state.src.replace(NEWLINES_RE, '\n');-1 9043 // we know that it's going to be a valid blockquote, -1 9044 // so no point trying to find the end of it in silent mode -1 9045 if (silent) { return true; } 9513 90469514 -1 // Replace NULL characters9515 -1 str = str.replace(NULL_RE, '\uFFFD');-1 9047 // skip one optional space (but not tab, check cmark impl) after '>' -1 9048 if (state.src.charCodeAt(pos) === 0x20) { pos++; } 9516 90499517 -1 state.src = str;9518 -1 };-1 9050 oldIndent = state.blkIndent; -1 9051 state.blkIndent = 0; 9519 90529520 -1 },{}],73:[function(require,module,exports){9521 -1 // Simple typographyc replacements9522 -1 //9523 -1 // (c) (C) → ©9524 -1 // (tm) (TM) → ™9525 -1 // (r) (R) → ®9526 -1 // +- → ±9527 -1 // (p) (P) -> §9528 -1 // ... → … (also ?.... → ?.., !.... → !..)9529 -1 // ???????? → ???, !!!!! → !!!, `,,` → `,`9530 -1 // -- → –, --- → —9531 -1 //9532 -1 'use strict';-1 9053 // skip spaces after ">" and re-calculate offset -1 9054 initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]); 9533 90559534 -1 // TODO:9535 -1 // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾9536 -1 // - miltiplication 2 x 4 -> 2 × 4-1 9056 oldBMarks = [ state.bMarks[startLine] ]; -1 9057 state.bMarks[startLine] = pos; 9537 90589538 -1 var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;-1 9059 while (pos < max) { -1 9060 ch = state.src.charCodeAt(pos); 9539 90619540 -1 // Workaround for phantomjs - need regex without /g flag,9541 -1 // or root check will fail every second time9542 -1 var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i;-1 9062 if (isSpace(ch)) { -1 9063 if (ch === 0x09) { -1 9064 offset += 4 - offset % 4; -1 9065 } else { -1 9066 offset++; -1 9067 } -1 9068 } else { -1 9069 break; -1 9070 } 9543 90719544 -1 var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig;9545 -1 var SCOPED_ABBR = {9546 -1 c: '©',9547 -1 r: '®',9548 -1 p: '§',9549 -1 tm: '™'9550 -1 };-1 9072 pos++; -1 9073 } 9551 90749552 -1 function replaceFn(match, name) {9553 -1 return SCOPED_ABBR[name.toLowerCase()];9554 -1 }-1 9075 lastLineEmpty = pos >= max; 9555 90769556 -1 function replace_scoped(inlineTokens) {9557 -1 var i, token;-1 9077 oldSCount = [ state.sCount[startLine] ]; -1 9078 state.sCount[startLine] = offset - initial; 9558 90799559 -1 for (i = inlineTokens.length - 1; i >= 0; i--) {9560 -1 token = inlineTokens[i];9561 -1 if (token.type === 'text') {9562 -1 token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);9563 -1 }9564 -1 }9565 -1 }-1 9080 oldTShift = [ state.tShift[startLine] ]; -1 9081 state.tShift[startLine] = pos - state.bMarks[startLine]; 9566 90829567 -1 function replace_rare(inlineTokens) {9568 -1 var i, token;-1 9083 terminatorRules = state.md.block.ruler.getRules('blockquote'); 9569 90849570 -1 for (i = inlineTokens.length - 1; i >= 0; i--) {9571 -1 token = inlineTokens[i];9572 -1 if (token.type === 'text') {9573 -1 if (RARE_RE.test(token.content)) {9574 -1 token.content = token.content9575 -1 .replace(/\+-/g, '±')9576 -1 // .., ..., ....... -> …9577 -1 // but ?..... & !..... -> ?.. & !..9578 -1 .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')9579 -1 .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')9580 -1 // em-dash9581 -1 .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')9582 -1 // en-dash9583 -1 .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')9584 -1 .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');9585 -1 }-1 9085 // Search the end of the block -1 9086 // -1 9087 // Block ends with either: -1 9088 // 1. an empty line outside: -1 9089 // ``` -1 9090 // > test -1 9091 // -1 9092 // ``` -1 9093 // 2. an empty line inside: -1 9094 // ``` -1 9095 // > -1 9096 // test -1 9097 // ``` -1 9098 // 3. another tag -1 9099 // ``` -1 9100 // > test -1 9101 // - - - -1 9102 // ``` -1 9103 for (nextLine = startLine + 1; nextLine < endLine; nextLine++) { -1 9104 if (state.sCount[nextLine] < oldIndent) { break; } -1 9105 -1 9106 pos = state.bMarks[nextLine] + state.tShift[nextLine]; -1 9107 max = state.eMarks[nextLine]; -1 9108 -1 9109 if (pos >= max) { -1 9110 // Case 1: line is not inside the blockquote, and this line is empty. -1 9111 break; 9586 9112 }9587 -1 }9588 -1 }9589 9113 -1 9114 if (state.src.charCodeAt(pos++) === 0x3E/* > */) { -1 9115 // This line is inside the blockquote. -1 9116 -1 9117 // skip one optional space (but not tab, check cmark impl) after '>' -1 9118 if (state.src.charCodeAt(pos) === 0x20) { pos++; } 9590 91199591 -1 module.exports = function replace(state) {9592 -1 var blkIdx;-1 9120 // skip spaces after ">" and re-calculate offset -1 9121 initial = offset = state.sCount[nextLine] + pos - (state.bMarks[nextLine] + state.tShift[nextLine]); 9593 91229594 -1 if (!state.md.options.typographer) { return; }-1 9123 oldBMarks.push(state.bMarks[nextLine]); -1 9124 state.bMarks[nextLine] = pos; 9595 91259596 -1 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {-1 9126 while (pos < max) { -1 9127 ch = state.src.charCodeAt(pos); 9597 91289598 -1 if (state.tokens[blkIdx].type !== 'inline') { continue; }-1 9129 if (isSpace(ch)) { -1 9130 if (ch === 0x09) { -1 9131 offset += 4 - offset % 4; -1 9132 } else { -1 9133 offset++; -1 9134 } -1 9135 } else { -1 9136 break; -1 9137 } 9599 91389600 -1 if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {9601 -1 replace_scoped(state.tokens[blkIdx].children);9602 -1 }-1 9139 pos++; -1 9140 } 9603 91419604 -1 if (RARE_RE.test(state.tokens[blkIdx].content)) {9605 -1 replace_rare(state.tokens[blkIdx].children);-1 9142 lastLineEmpty = pos >= max; -1 9143 -1 9144 oldSCount.push(state.sCount[nextLine]); -1 9145 state.sCount[nextLine] = offset - initial; -1 9146 -1 9147 oldTShift.push(state.tShift[nextLine]); -1 9148 state.tShift[nextLine] = pos - state.bMarks[nextLine]; -1 9149 continue; 9606 9150 } 9607 91519608 -1 }9609 -1 };-1 9152 // Case 2: line is not inside the blockquote, and the last line was empty. -1 9153 if (lastLineEmpty) { break; } 9610 91549611 -1 },{}],74:[function(require,module,exports){9612 -1 // Convert straight quotation marks to typographic ones9613 -1 //9614 -1 'use strict';-1 9155 // Case 3: another tag found. -1 9156 terminate = false; -1 9157 for (i = 0, l = terminatorRules.length; i < l; i++) { -1 9158 if (terminatorRules[i](state, nextLine, endLine, true)) { -1 9159 terminate = true; -1 9160 break; -1 9161 } -1 9162 } -1 9163 if (terminate) { break; } 9615 9164 -1 9165 oldBMarks.push(state.bMarks[nextLine]); -1 9166 oldTShift.push(state.tShift[nextLine]); -1 9167 oldSCount.push(state.sCount[nextLine]); 9616 91689617 -1 var isWhiteSpace = require('../common/utils').isWhiteSpace;9618 -1 var isPunctChar = require('../common/utils').isPunctChar;9619 -1 var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;-1 9169 // A negative indentation means that this is a paragraph continuation -1 9170 // -1 9171 state.sCount[nextLine] = -1; -1 9172 } 9620 91739621 -1 var QUOTE_TEST_RE = /['"]/;9622 -1 var QUOTE_RE = /['"]/g;9623 -1 var APOSTROPHE = '\u2019'; /* ’ */-1 9174 oldParentType = state.parentType; -1 9175 state.parentType = 'blockquote'; 9624 9176 -1 9177 token = state.push('blockquote_open', 'blockquote', 1); -1 9178 token.markup = '>'; -1 9179 token.map = lines = [ startLine, 0 ]; 9625 91809626 -1 function replaceAt(str, index, ch) {9627 -1 return str.substr(0, index) + ch + str.substr(index + 1);9628 -1 }-1 9181 state.md.block.tokenize(state, startLine, nextLine); 9629 91829630 -1 function process_inlines(tokens, state) {9631 -1 var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar,9632 -1 isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace,9633 -1 canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;-1 9183 token = state.push('blockquote_close', 'blockquote', -1); -1 9184 token.markup = '>'; 9634 91859635 -1 stack = [];-1 9186 state.parentType = oldParentType; -1 9187 lines[1] = state.line; 9636 91889637 -1 for (i = 0; i < tokens.length; i++) {9638 -1 token = tokens[i];-1 9189 // Restore original tShift; this might not be necessary since the parser -1 9190 // has already been here, but just to make sure we can do that. -1 9191 for (i = 0; i < oldTShift.length; i++) { -1 9192 state.bMarks[i + startLine] = oldBMarks[i]; -1 9193 state.tShift[i + startLine] = oldTShift[i]; -1 9194 state.sCount[i + startLine] = oldSCount[i]; -1 9195 } -1 9196 state.blkIndent = oldIndent; 9639 91979640 -1 thisLevel = tokens[i].level;-1 9198 return true; -1 9199 }; 9641 92009642 -1 for (j = stack.length - 1; j >= 0; j--) {9643 -1 if (stack[j].level <= thisLevel) { break; }9644 -1 }9645 -1 stack.length = j + 1;-1 9201 },{"../common/utils":40}],55:[function(require,module,exports){ -1 9202 // Code block (4 spaces padded) 9646 92039647 -1 if (token.type !== 'text') { continue; }-1 9204 'use strict'; 9648 92059649 -1 text = token.content;9650 -1 pos = 0;9651 -1 max = text.length;9652 92069653 -1 /*eslint no-labels:0,block-scoped-var:0*/9654 -1 OUTER:9655 -1 while (pos < max) {9656 -1 QUOTE_RE.lastIndex = pos;9657 -1 t = QUOTE_RE.exec(text);9658 -1 if (!t) { break; }-1 9207 module.exports = function code(state, startLine, endLine/*, silent*/) { -1 9208 var nextLine, last, token, emptyLines = 0; 9659 92099660 -1 canOpen = canClose = true;9661 -1 pos = t.index + 1;9662 -1 isSingle = (t[0] === "'");-1 9210 if (state.sCount[startLine] - state.blkIndent < 4) { return false; } 9663 92119664 -1 // Find previous character,9665 -1 // default to space if it's the beginning of the line9666 -1 //9667 -1 lastChar = 0x20;-1 9212 last = nextLine = startLine + 1; 9668 92139669 -1 if (t.index - 1 >= 0) {9670 -1 lastChar = text.charCodeAt(t.index - 1);9671 -1 } else {9672 -1 for (j = i - 1; j >= 0; j--) {9673 -1 if (tokens[j].type !== 'text') { continue; }-1 9214 while (nextLine < endLine) { -1 9215 if (state.isEmpty(nextLine)) { -1 9216 emptyLines++; 9674 92179675 -1 lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);9676 -1 break;9677 -1 }-1 9218 // workaround for lists: 2 blank lines should terminate indented -1 9219 // code block, but not fenced code block -1 9220 if (emptyLines >= 2 && state.parentType === 'list') { -1 9221 break; 9678 9222 } 9679 92239680 -1 // Find next character,9681 -1 // default to space if it's the end of the line9682 -1 //9683 -1 nextChar = 0x20;9684 -19685 -1 if (pos < max) {9686 -1 nextChar = text.charCodeAt(pos);9687 -1 } else {9688 -1 for (j = i + 1; j < tokens.length; j++) {9689 -1 if (tokens[j].type !== 'text') { continue; }-1 9224 nextLine++; -1 9225 continue; -1 9226 } 9690 92279691 -1 nextChar = tokens[j].content.charCodeAt(0);9692 -1 break;9693 -1 }9694 -1 }-1 9228 emptyLines = 0; 9695 92299696 -1 isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));9697 -1 isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));-1 9230 if (state.sCount[nextLine] - state.blkIndent >= 4) { -1 9231 nextLine++; -1 9232 last = nextLine; -1 9233 continue; -1 9234 } -1 9235 break; -1 9236 } 9698 92379699 -1 isLastWhiteSpace = isWhiteSpace(lastChar);9700 -1 isNextWhiteSpace = isWhiteSpace(nextChar);-1 9238 state.line = last; 9701 92399702 -1 if (isNextWhiteSpace) {9703 -1 canOpen = false;9704 -1 } else if (isNextPunctChar) {9705 -1 if (!(isLastWhiteSpace || isLastPunctChar)) {9706 -1 canOpen = false;9707 -1 }9708 -1 }-1 9240 token = state.push('code_block', 'code', 0); -1 9241 token.content = state.getLines(startLine, last, 4 + state.blkIndent, true); -1 9242 token.map = [ startLine, state.line ]; 9709 92439710 -1 if (isLastWhiteSpace) {9711 -1 canClose = false;9712 -1 } else if (isLastPunctChar) {9713 -1 if (!(isNextWhiteSpace || isNextPunctChar)) {9714 -1 canClose = false;9715 -1 }9716 -1 }-1 9244 return true; -1 9245 }; 9717 92469718 -1 if (nextChar === 0x22 /* " */ && t[0] === '"') {9719 -1 if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) {9720 -1 // special case: 1"" - count first quote as an inch9721 -1 canClose = canOpen = false;9722 -1 }9723 -1 }-1 9247 },{}],56:[function(require,module,exports){ -1 9248 // fences (``` lang, ~~~ lang) 9724 92499725 -1 if (canOpen && canClose) {9726 -1 // treat this as the middle of the word9727 -1 canOpen = false;9728 -1 canClose = isNextPunctChar;9729 -1 }-1 9250 'use strict'; 9730 92519731 -1 if (!canOpen && !canClose) {9732 -1 // middle of word9733 -1 if (isSingle) {9734 -1 token.content = replaceAt(token.content, t.index, APOSTROPHE);9735 -1 }9736 -1 continue;9737 -1 }9738 92529739 -1 if (canClose) {9740 -1 // this could be a closing quote, rewind the stack to get a match9741 -1 for (j = stack.length - 1; j >= 0; j--) {9742 -1 item = stack[j];9743 -1 if (stack[j].level < thisLevel) { break; }9744 -1 if (item.single === isSingle && stack[j].level === thisLevel) {9745 -1 item = stack[j];-1 9253 module.exports = function fence(state, startLine, endLine, silent) { -1 9254 var marker, len, params, nextLine, mem, token, markup, -1 9255 haveEndMarker = false, -1 9256 pos = state.bMarks[startLine] + state.tShift[startLine], -1 9257 max = state.eMarks[startLine]; 9746 92589747 -1 if (isSingle) {9748 -1 openQuote = state.md.options.quotes[2];9749 -1 closeQuote = state.md.options.quotes[3];9750 -1 } else {9751 -1 openQuote = state.md.options.quotes[0];9752 -1 closeQuote = state.md.options.quotes[1];9753 -1 }-1 9259 if (pos + 3 > max) { return false; } 9754 92609755 -1 // replace token.content *before* tokens[item.token].content,9756 -1 // because, if they are pointing at the same token, replaceAt9757 -1 // could mess up indices when quote length != 19758 -1 token.content = replaceAt(token.content, t.index, closeQuote);9759 -1 tokens[item.token].content = replaceAt(9760 -1 tokens[item.token].content, item.pos, openQuote);-1 9261 marker = state.src.charCodeAt(pos); 9761 92629762 -1 pos += closeQuote.length - 1;9763 -1 if (item.token === i) { pos += openQuote.length - 1; }-1 9263 if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) { -1 9264 return false; -1 9265 } 9764 92669765 -1 text = token.content;9766 -1 max = text.length;-1 9267 // scan marker length -1 9268 mem = pos; -1 9269 pos = state.skipChars(pos, marker); 9767 92709768 -1 stack.length = j;9769 -1 continue OUTER;9770 -1 }9771 -1 }9772 -1 }-1 9271 len = pos - mem; 9773 92729774 -1 if (canOpen) {9775 -1 stack.push({9776 -1 token: i,9777 -1 pos: t.index,9778 -1 single: isSingle,9779 -1 level: thisLevel9780 -1 });9781 -1 } else if (canClose && isSingle) {9782 -1 token.content = replaceAt(token.content, t.index, APOSTROPHE);9783 -1 }9784 -1 }9785 -1 }9786 -1 }-1 9273 if (len < 3) { return false; } 9787 9274 -1 9275 markup = state.src.slice(mem, pos); -1 9276 params = state.src.slice(pos, max); 9788 92779789 -1 module.exports = function smartquotes(state) {9790 -1 /*eslint max-depth:0*/9791 -1 var blkIdx;-1 9278 if (params.indexOf('`') >= 0) { return false; } 9792 92799793 -1 if (!state.md.options.typographer) { return; }-1 9280 // Since start is found, we can report success here in validation mode -1 9281 if (silent) { return true; } 9794 92829795 -1 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {-1 9283 // search end of block -1 9284 nextLine = startLine; 9796 92859797 -1 if (state.tokens[blkIdx].type !== 'inline' ||9798 -1 !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {9799 -1 continue;-1 9286 for (;;) { -1 9287 nextLine++; -1 9288 if (nextLine >= endLine) { -1 9289 // unclosed block should be autoclosed by end of document. -1 9290 // also block seems to be autoclosed by end of parent -1 9291 break; 9800 9292 } 9801 92939802 -1 process_inlines(state.tokens[blkIdx].children, state);9803 -1 }9804 -1 };9805 -19806 -1 },{"../common/utils":43}],75:[function(require,module,exports){9807 -1 // Core state object9808 -1 //9809 -1 'use strict';9810 -19811 -1 var Token = require('../token');-1 9294 pos = mem = state.bMarks[nextLine] + state.tShift[nextLine]; -1 9295 max = state.eMarks[nextLine]; 9812 9296 -1 9297 if (pos < max && state.sCount[nextLine] < state.blkIndent) { -1 9298 // non-empty line with negative indent should stop the list: -1 9299 // - ``` -1 9300 // test -1 9301 break; -1 9302 } 9813 93039814 -1 function StateCore(src, md, env) {9815 -1 this.src = src;9816 -1 this.env = env;9817 -1 this.tokens = [];9818 -1 this.inlineMode = false;9819 -1 this.md = md; // link to parser instance9820 -1 }-1 9304 if (state.src.charCodeAt(pos) !== marker) { continue; } 9821 93059822 -1 // re-export Token class to use in core rules9823 -1 StateCore.prototype.Token = Token;-1 9306 if (state.sCount[nextLine] - state.blkIndent >= 4) { -1 9307 // closing fence should be indented less than 4 spaces -1 9308 continue; -1 9309 } 9824 9310 -1 9311 pos = state.skipChars(pos, marker); 9825 93129826 -1 module.exports = StateCore;-1 9313 // closing code fence must be at least as long as the opening one -1 9314 if (pos - mem < len) { continue; } 9827 93159828 -1 },{"../token":90}],76:[function(require,module,exports){9829 -1 // Process autolinks '<protocol:...>'-1 9316 // make sure tail has spaces only -1 9317 pos = state.skipSpaces(pos); 9830 93189831 -1 'use strict';-1 9319 if (pos < max) { continue; } 9832 9320 -1 9321 haveEndMarker = true; -1 9322 // found! -1 9323 break; -1 9324 } 9833 93259834 -1 /*eslint max-len:0*/9835 -1 var EMAIL_RE = /^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/;9836 -1 var AUTOLINK_RE = /^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/;-1 9326 // If a fence has heading spaces, they should be removed from its inner block -1 9327 len = state.sCount[startLine]; 9837 9328 -1 9329 state.line = nextLine + (haveEndMarker ? 1 : 0); 9838 93309839 -1 module.exports = function autolink(state, silent) {9840 -1 var tail, linkMatch, emailMatch, url, fullUrl, token,9841 -1 pos = state.pos;-1 9331 token = state.push('fence', 'code', 0); -1 9332 token.info = params; -1 9333 token.content = state.getLines(startLine + 1, nextLine, len, true); -1 9334 token.markup = markup; -1 9335 token.map = [ startLine, state.line ]; 9842 93369843 -1 if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }-1 9337 return true; -1 9338 }; 9844 93399845 -1 tail = state.src.slice(pos);-1 9340 },{}],57:[function(require,module,exports){ -1 9341 // heading (#, ##, ...) 9846 93429847 -1 if (tail.indexOf('>') < 0) { return false; }-1 9343 'use strict'; 9848 93449849 -1 if (AUTOLINK_RE.test(tail)) {9850 -1 linkMatch = tail.match(AUTOLINK_RE);-1 9345 var isSpace = require('../common/utils').isSpace; 9851 93469852 -1 url = linkMatch[0].slice(1, -1);9853 -1 fullUrl = state.md.normalizeLink(url);9854 -1 if (!state.md.validateLink(fullUrl)) { return false; }9855 93479856 -1 if (!silent) {9857 -1 token = state.push('link_open', 'a', 1);9858 -1 token.attrs = [ [ 'href', fullUrl ] ];9859 -1 token.markup = 'autolink';9860 -1 token.info = 'auto';-1 9348 module.exports = function heading(state, startLine, endLine, silent) { -1 9349 var ch, level, tmp, token, -1 9350 pos = state.bMarks[startLine] + state.tShift[startLine], -1 9351 max = state.eMarks[startLine]; 9861 93529862 -1 token = state.push('text', '', 0);9863 -1 token.content = state.md.normalizeLinkText(url);-1 9353 ch = state.src.charCodeAt(pos); 9864 93549865 -1 token = state.push('link_close', 'a', -1);9866 -1 token.markup = 'autolink';9867 -1 token.info = 'auto';9868 -1 }-1 9355 if (ch !== 0x23/* # */ || pos >= max) { return false; } 9869 93569870 -1 state.pos += linkMatch[0].length;9871 -1 return true;-1 9357 // count heading level -1 9358 level = 1; -1 9359 ch = state.src.charCodeAt(++pos); -1 9360 while (ch === 0x23/* # */ && pos < max && level <= 6) { -1 9361 level++; -1 9362 ch = state.src.charCodeAt(++pos); 9872 9363 } 9873 93649874 -1 if (EMAIL_RE.test(tail)) {9875 -1 emailMatch = tail.match(EMAIL_RE);-1 9365 if (level > 6 || (pos < max && ch !== 0x20/* space */)) { return false; } 9876 93669877 -1 url = emailMatch[0].slice(1, -1);9878 -1 fullUrl = state.md.normalizeLink('mailto:' + url);9879 -1 if (!state.md.validateLink(fullUrl)) { return false; }-1 9367 if (silent) { return true; } 9880 93689881 -1 if (!silent) {9882 -1 token = state.push('link_open', 'a', 1);9883 -1 token.attrs = [ [ 'href', fullUrl ] ];9884 -1 token.markup = 'autolink';9885 -1 token.info = 'auto';-1 9369 // Let's cut tails like ' ### ' from the end of string 9886 93709887 -1 token = state.push('text', '', 0);9888 -1 token.content = state.md.normalizeLinkText(url);-1 9371 max = state.skipSpacesBack(max, pos); -1 9372 tmp = state.skipCharsBack(max, 0x23, pos); // # -1 9373 if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) { -1 9374 max = tmp; -1 9375 } 9889 93769890 -1 token = state.push('link_close', 'a', -1);9891 -1 token.markup = 'autolink';9892 -1 token.info = 'auto';9893 -1 }-1 9377 state.line = startLine + 1; 9894 93789895 -1 state.pos += emailMatch[0].length;9896 -1 return true;9897 -1 }-1 9379 token = state.push('heading_open', 'h' + String(level), 1); -1 9380 token.markup = '########'.slice(0, level); -1 9381 token.map = [ startLine, state.line ]; 9898 93829899 -1 return false;-1 9383 token = state.push('inline', '', 0); -1 9384 token.content = state.src.slice(pos, max).trim(); -1 9385 token.map = [ startLine, state.line ]; -1 9386 token.children = []; -1 9387 -1 9388 token = state.push('heading_close', 'h' + String(level), -1); -1 9389 token.markup = '########'.slice(0, level); -1 9390 -1 9391 return true; 9900 9392 }; 9901 93939902 -1 },{}],77:[function(require,module,exports){9903 -1 // Parse backticks-1 9394 },{"../common/utils":40}],58:[function(require,module,exports){ -1 9395 // Horizontal rule 9904 9396 9905 9397 'use strict'; 9906 93989907 -1 module.exports = function backtick(state, silent) {9908 -1 var start, max, marker, matchStart, matchEnd, token,9909 -1 pos = state.pos,9910 -1 ch = state.src.charCodeAt(pos);-1 9399 var isSpace = require('../common/utils').isSpace; 9911 94009912 -1 if (ch !== 0x60/* ` */) { return false; }9913 94019914 -1 start = pos;9915 -1 pos++;9916 -1 max = state.posMax;-1 9402 module.exports = function hr(state, startLine, endLine, silent) { -1 9403 var marker, cnt, ch, token, -1 9404 pos = state.bMarks[startLine] + state.tShift[startLine], -1 9405 max = state.eMarks[startLine]; 9917 94069918 -1 while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }-1 9407 marker = state.src.charCodeAt(pos++); 9919 94089920 -1 marker = state.src.slice(start, pos);-1 9409 // Check hr marker -1 9410 if (marker !== 0x2A/* * */ && -1 9411 marker !== 0x2D/* - */ && -1 9412 marker !== 0x5F/* _ */) { -1 9413 return false; -1 9414 } 9921 94159922 -1 matchStart = matchEnd = pos;-1 9416 // markers can be mixed with spaces, but there should be at least 3 of them 9923 94179924 -1 while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {9925 -1 matchEnd = matchStart + 1;-1 9418 cnt = 1; -1 9419 while (pos < max) { -1 9420 ch = state.src.charCodeAt(pos++); -1 9421 if (ch !== marker && !isSpace(ch)) { return false; } -1 9422 if (ch === marker) { cnt++; } -1 9423 } 9926 94249927 -1 while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }-1 9425 if (cnt < 3) { return false; } 9928 94269929 -1 if (matchEnd - matchStart === marker.length) {9930 -1 if (!silent) {9931 -1 token = state.push('code_inline', 'code', 0);9932 -1 token.markup = marker;9933 -1 token.content = state.src.slice(pos, matchStart)9934 -1 .replace(/[ \n]+/g, ' ')9935 -1 .trim();9936 -1 }9937 -1 state.pos = matchEnd;9938 -1 return true;9939 -1 }9940 -1 }-1 9427 if (silent) { return true; } -1 9428 -1 9429 state.line = startLine + 1; -1 9430 -1 9431 token = state.push('hr', 'hr', 0); -1 9432 token.map = [ startLine, state.line ]; -1 9433 token.markup = Array(cnt + 1).join(String.fromCharCode(marker)); 9941 94349942 -1 if (!silent) { state.pending += marker; }9943 -1 state.pos += marker.length;9944 9435 return true; 9945 9436 }; 9946 94379947 -1 },{}],78:[function(require,module,exports){9948 -1 // For each opening emphasis-like marker find a matching closing one9949 -1 //-1 9438 },{"../common/utils":40}],59:[function(require,module,exports){ -1 9439 // HTML block -1 9440 9950 9441 'use strict'; 9951 9442 9952 94439953 -1 module.exports = function link_pairs(state) {9954 -1 var i, j, lastDelim, currDelim,9955 -1 delimiters = state.delimiters,9956 -1 max = state.delimiters.length;-1 9444 var block_names = require('../common/html_blocks'); -1 9445 var HTML_OPEN_CLOSE_TAG_RE = require('../common/html_re').HTML_OPEN_CLOSE_TAG_RE; 9957 94469958 -1 for (i = 0; i < max; i++) {9959 -1 lastDelim = delimiters[i];-1 9447 // An array of opening and corresponding closing sequences for html tags, -1 9448 // last argument defines whether it can terminate a paragraph or not -1 9449 // -1 9450 var HTML_SEQUENCES = [ -1 9451 [ /^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true ], -1 9452 [ /^<!--/, /-->/, true ], -1 9453 [ /^<\?/, /\?>/, true ], -1 9454 [ /^<![A-Z]/, />/, true ], -1 9455 [ /^<!\[CDATA\[/, /\]\]>/, true ], -1 9456 [ new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ], -1 9457 [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ] -1 9458 ]; 9960 94599961 -1 if (!lastDelim.close) { continue; }9962 94609963 -1 j = i - lastDelim.jump - 1;-1 9461 module.exports = function html_block(state, startLine, endLine, silent) { -1 9462 var i, nextLine, token, lineText, -1 9463 pos = state.bMarks[startLine] + state.tShift[startLine], -1 9464 max = state.eMarks[startLine]; 9964 94659965 -1 while (j >= 0) {9966 -1 currDelim = delimiters[j];-1 9466 if (!state.md.options.html) { return false; } 9967 94679968 -1 if (currDelim.open &&9969 -1 currDelim.marker === lastDelim.marker &&9970 -1 currDelim.end < 0 &&9971 -1 currDelim.level === lastDelim.level) {-1 9468 if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; } 9972 94699973 -1 lastDelim.jump = i - j;9974 -1 lastDelim.open = false;9975 -1 currDelim.end = i;9976 -1 currDelim.jump = 0;9977 -1 break;9978 -1 }-1 9470 lineText = state.src.slice(pos, max); 9979 94719980 -1 j -= currDelim.jump + 1;9981 -1 }-1 9472 for (i = 0; i < HTML_SEQUENCES.length; i++) { -1 9473 if (HTML_SEQUENCES[i][0].test(lineText)) { break; } 9982 9474 }9983 -1 };9984 -19985 -1 },{}],79:[function(require,module,exports){9986 -1 // Process *this* and _that_9987 -1 //9988 -1 'use strict';9989 9475 -1 9476 if (i === HTML_SEQUENCES.length) { return false; } 9990 94779991 -1 // Insert each marker as a separate text token, and add it to delimiter list9992 -1 //9993 -1 module.exports.tokenize = function emphasis(state, silent) {9994 -1 var i, scanned, token,9995 -1 start = state.pos,9996 -1 marker = state.src.charCodeAt(start);-1 9478 if (silent) { -1 9479 // true if this sequence can be a terminator, false otherwise -1 9480 return HTML_SEQUENCES[i][2]; -1 9481 } 9997 94829998 -1 if (silent) { return false; }-1 9483 nextLine = startLine + 1; 9999 948410000 -1 if (marker !== 0x5F /* _ */ && marker !== 0x2A /* * */) { return false; }-1 9485 // If we are here - we detected HTML block. -1 9486 // Let's roll down till block end. -1 9487 if (!HTML_SEQUENCES[i][1].test(lineText)) { -1 9488 for (; nextLine < endLine; nextLine++) { -1 9489 if (state.sCount[nextLine] < state.blkIndent) { break; } 10001 949010002 -1 scanned = state.scanDelims(state.pos, marker === 0x2A);-1 9491 pos = state.bMarks[nextLine] + state.tShift[nextLine]; -1 9492 max = state.eMarks[nextLine]; -1 9493 lineText = state.src.slice(pos, max); 10003 949410004 -1 for (i = 0; i < scanned.length; i++) {10005 -1 token = state.push('text', '', 0);10006 -1 token.content = String.fromCharCode(marker);-1 9495 if (HTML_SEQUENCES[i][1].test(lineText)) { -1 9496 if (lineText.length !== 0) { nextLine++; } -1 9497 break; -1 9498 } -1 9499 } -1 9500 } 10007 950110008 -1 state.delimiters.push({10009 -1 // Char code of the starting marker (number).10010 -1 //10011 -1 marker: marker,-1 9502 state.line = nextLine; 10012 950310013 -1 // An amount of characters before this one that's equivalent to10014 -1 // current one. In plain English: if this delimiter does not open10015 -1 // an emphasis, neither do previous `jump` characters.10016 -1 //10017 -1 // Used to skip sequences like "*****" in one step, for 1st asterisk10018 -1 // value will be 0, for 2nd it's 1 and so on.10019 -1 //10020 -1 jump: i,-1 9504 token = state.push('html_block', '', 0); -1 9505 token.map = [ startLine, nextLine ]; -1 9506 token.content = state.getLines(startLine, nextLine, state.blkIndent, true); 10021 950710022 -1 // A position of the token this delimiter corresponds to.10023 -1 //10024 -1 token: state.tokens.length - 1,-1 9508 return true; -1 9509 }; 10025 951010026 -1 // Token level.10027 -1 //10028 -1 level: state.level,-1 9511 },{"../common/html_blocks":38,"../common/html_re":39}],60:[function(require,module,exports){ -1 9512 // lheading (---, ===) 10029 951310030 -1 // If this delimiter is matched as a valid opener, `end` will be10031 -1 // equal to its position, otherwise it's `-1`.10032 -1 //10033 -1 end: -1,-1 9514 'use strict'; 10034 951510035 -1 // Boolean flags that determine if this delimiter could open or close10036 -1 // an emphasis.10037 -1 //10038 -1 open: scanned.can_open,10039 -1 close: scanned.can_close10040 -1 });10041 -1 }10042 951610043 -1 state.pos += scanned.length;-1 9517 module.exports = function lheading(state, startLine, endLine/*, silent*/) { -1 9518 var content, terminate, i, l, token, pos, max, level, marker, -1 9519 nextLine = startLine + 1, -1 9520 terminatorRules = state.md.block.ruler.getRules('paragraph'); 10044 952110045 -1 return true;10046 -1 };-1 9522 // jump line-by-line until empty one or EOF -1 9523 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) { -1 9524 // this would be a code block normally, but after paragraph -1 9525 // it's considered a lazy continuation regardless of what's there -1 9526 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; } 10047 9527 -1 9528 // -1 9529 // Check for underline in setext header -1 9530 // -1 9531 if (state.sCount[nextLine] >= state.blkIndent) { -1 9532 pos = state.bMarks[nextLine] + state.tShift[nextLine]; -1 9533 max = state.eMarks[nextLine]; 10048 953410049 -1 // Walk through delimiter list and replace text tokens with tags10050 -1 //10051 -1 module.exports.postProcess = function emphasis(state) {10052 -1 var i,10053 -1 startDelim,10054 -1 endDelim,10055 -1 token,10056 -1 ch,10057 -1 isStrong,10058 -1 delimiters = state.delimiters,10059 -1 max = state.delimiters.length;-1 9535 if (pos < max) { -1 9536 marker = state.src.charCodeAt(pos); 10060 953710061 -1 for (i = 0; i < max; i++) {10062 -1 startDelim = delimiters[i];-1 9538 if (marker === 0x2D/* - */ || marker === 0x3D/* = */) { -1 9539 pos = state.skipChars(pos, marker); -1 9540 pos = state.skipSpaces(pos); 10063 954110064 -1 if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) {10065 -1 continue;-1 9542 if (pos >= max) { -1 9543 level = (marker === 0x3D/* = */ ? 1 : 2); -1 9544 break; -1 9545 } -1 9546 } -1 9547 } 10066 9548 } 10067 954910068 -1 // Process only opening markers10069 -1 if (startDelim.end === -1) {10070 -1 continue;-1 9550 // quirk for blockquotes, this line should already be checked by that rule -1 9551 if (state.sCount[nextLine] < 0) { continue; } -1 9552 -1 9553 // Some tags can terminate paragraph without empty line. -1 9554 terminate = false; -1 9555 for (i = 0, l = terminatorRules.length; i < l; i++) { -1 9556 if (terminatorRules[i](state, nextLine, endLine, true)) { -1 9557 terminate = true; -1 9558 break; -1 9559 } 10071 9560 } -1 9561 if (terminate) { break; } -1 9562 } 10072 956310073 -1 endDelim = delimiters[startDelim.end];-1 9564 if (!level) { -1 9565 // Didn't find valid underline -1 9566 return false; -1 9567 } 10074 956810075 -1 // If the next delimiter has the same marker and is adjacent to this one,10076 -1 // merge those into one strong delimiter.10077 -1 //10078 -1 // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`10079 -1 //10080 -1 isStrong = i + 1 < max &&10081 -1 delimiters[i + 1].end === startDelim.end - 1 &&10082 -1 delimiters[i + 1].token === startDelim.token + 1 &&10083 -1 delimiters[startDelim.end - 1].token === endDelim.token - 1 &&10084 -1 delimiters[i + 1].marker === startDelim.marker;-1 9569 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim(); 10085 957010086 -1 ch = String.fromCharCode(startDelim.marker);-1 9571 state.line = nextLine + 1; 10087 957210088 -1 token = state.tokens[startDelim.token];10089 -1 token.type = isStrong ? 'strong_open' : 'em_open';10090 -1 token.tag = isStrong ? 'strong' : 'em';10091 -1 token.nesting = 1;10092 -1 token.markup = isStrong ? ch + ch : ch;10093 -1 token.content = '';-1 9573 token = state.push('heading_open', 'h' + String(level), 1); -1 9574 token.markup = String.fromCharCode(marker); -1 9575 token.map = [ startLine, state.line ]; 10094 957610095 -1 token = state.tokens[endDelim.token];10096 -1 token.type = isStrong ? 'strong_close' : 'em_close';10097 -1 token.tag = isStrong ? 'strong' : 'em';10098 -1 token.nesting = -1;10099 -1 token.markup = isStrong ? ch + ch : ch;10100 -1 token.content = '';-1 9577 token = state.push('inline', '', 0); -1 9578 token.content = content; -1 9579 token.map = [ startLine, state.line - 1 ]; -1 9580 token.children = []; 10101 958110102 -1 if (isStrong) {10103 -1 state.tokens[delimiters[i + 1].token].content = '';10104 -1 state.tokens[delimiters[startDelim.end - 1].token].content = '';10105 -1 i++;10106 -1 }10107 -1 }-1 9582 token = state.push('heading_close', 'h' + String(level), -1); -1 9583 token.markup = String.fromCharCode(marker); -1 9584 -1 9585 return true; 10108 9586 }; 10109 958710110 -1 },{}],80:[function(require,module,exports){10111 -1 // Process html entity - {, ¯, ", ...-1 9588 },{}],61:[function(require,module,exports){ -1 9589 // Lists 10112 9590 10113 9591 'use strict'; 10114 959210115 -1 var entities = require('../common/entities');10116 -1 var has = require('../common/utils').has;10117 -1 var isValidEntityCode = require('../common/utils').isValidEntityCode;10118 -1 var fromCodePoint = require('../common/utils').fromCodePoint;10119 -1-1 9593 var isSpace = require('../common/utils').isSpace; 10120 959410121 -1 var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i;10122 -1 var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;10123 9595 -1 9596 // Search `[-+*][\n ]`, returns next pos arter marker on success -1 9597 // or -1 on fail. -1 9598 function skipBulletListMarker(state, startLine) { -1 9599 var marker, pos, max, ch; 10124 960010125 -1 module.exports = function entity(state, silent) {10126 -1 var ch, code, match, pos = state.pos, max = state.posMax;-1 9601 pos = state.bMarks[startLine] + state.tShift[startLine]; -1 9602 max = state.eMarks[startLine]; 10127 960310128 -1 if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; }-1 9604 marker = state.src.charCodeAt(pos++); -1 9605 // Check bullet -1 9606 if (marker !== 0x2A/* * */ && -1 9607 marker !== 0x2D/* - */ && -1 9608 marker !== 0x2B/* + */) { -1 9609 return -1; -1 9610 } 10129 961110130 -1 if (pos + 1 < max) {10131 -1 ch = state.src.charCodeAt(pos + 1);-1 9612 if (pos < max) { -1 9613 ch = state.src.charCodeAt(pos); 10132 961410133 -1 if (ch === 0x23 /* # */) {10134 -1 match = state.src.slice(pos).match(DIGITAL_RE);10135 -1 if (match) {10136 -1 if (!silent) {10137 -1 code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);10138 -1 state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);10139 -1 }10140 -1 state.pos += match[0].length;10141 -1 return true;10142 -1 }10143 -1 } else {10144 -1 match = state.src.slice(pos).match(NAMED_RE);10145 -1 if (match) {10146 -1 if (has(entities, match[1])) {10147 -1 if (!silent) { state.pending += entities[match[1]]; }10148 -1 state.pos += match[0].length;10149 -1 return true;10150 -1 }10151 -1 }-1 9615 if (!isSpace(ch)) { -1 9616 // " -test " - is not a list item -1 9617 return -1; 10152 9618 } 10153 9619 } 10154 962010155 -1 if (!silent) { state.pending += '&'; }10156 -1 state.pos++;10157 -1 return true;10158 -1 };-1 9621 return pos; -1 9622 } 10159 962310160 -1 },{"../common/entities":40,"../common/utils":43}],81:[function(require,module,exports){10161 -1 // Proceess escaped chars and hardbreaks-1 9624 // Search `\d+[.)][\n ]`, returns next pos arter marker on success -1 9625 // or -1 on fail. -1 9626 function skipOrderedListMarker(state, startLine) { -1 9627 var ch, -1 9628 start = state.bMarks[startLine] + state.tShift[startLine], -1 9629 pos = start, -1 9630 max = state.eMarks[startLine]; 10162 963110163 -1 'use strict';-1 9632 // List marker should have at least 2 chars (digit + dot) -1 9633 if (pos + 1 >= max) { return -1; } 10164 963410165 -1 var isSpace = require('../common/utils').isSpace;-1 9635 ch = state.src.charCodeAt(pos++); 10166 963610167 -1 var ESCAPED = [];-1 9637 if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; } 10168 963810169 -1 for (var i = 0; i < 256; i++) { ESCAPED.push(0); }-1 9639 for (;;) { -1 9640 // EOL -> fail -1 9641 if (pos >= max) { return -1; } 10170 964210171 -1 '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'10172 -1 .split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; });-1 9643 ch = state.src.charCodeAt(pos++); 10173 9644 -1 9645 if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) { 10174 964610175 -1 module.exports = function escape(state, silent) {10176 -1 var ch, pos = state.pos, max = state.posMax;-1 9647 // List marker should have no more than 9 digits -1 9648 // (prevents integer overflow in browsers) -1 9649 if (pos - start >= 10) { return -1; } 10177 965010178 -1 if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; }-1 9651 continue; -1 9652 } -1 9653 -1 9654 // found valid marker -1 9655 if (ch === 0x29/* ) */ || ch === 0x2e/* . */) { -1 9656 break; -1 9657 } -1 9658 -1 9659 return -1; -1 9660 } 10179 966110180 -1 pos++;10181 9662 10182 9663 if (pos < max) { 10183 9664 ch = state.src.charCodeAt(pos); 10184 966510185 -1 if (ch < 256 && ESCAPED[ch] !== 0) {10186 -1 if (!silent) { state.pending += state.src[pos]; }10187 -1 state.pos += 2;10188 -1 return true;-1 9666 if (!isSpace(ch)) { -1 9667 // " 1.test " - is not a list item -1 9668 return -1; 10189 9669 } -1 9670 } -1 9671 return pos; -1 9672 } 10190 967310191 -1 if (ch === 0x0A) {10192 -1 if (!silent) {10193 -1 state.push('hardbreak', 'br', 0);10194 -1 }-1 9674 function markTightParagraphs(state, idx) { -1 9675 var i, l, -1 9676 level = state.level + 2; 10195 967710196 -1 pos++;10197 -1 // skip leading whitespaces from next line10198 -1 while (pos < max) {10199 -1 ch = state.src.charCodeAt(pos);10200 -1 if (!isSpace(ch)) { break; }10201 -1 pos++;10202 -1 }-1 9678 for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) { -1 9679 if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') { -1 9680 state.tokens[i + 2].hidden = true; -1 9681 state.tokens[i].hidden = true; -1 9682 i += 2; -1 9683 } -1 9684 } -1 9685 } -1 9686 -1 9687 -1 9688 module.exports = function list(state, startLine, endLine, silent) { -1 9689 var nextLine, -1 9690 initial, -1 9691 offset, -1 9692 indent, -1 9693 oldTShift, -1 9694 oldIndent, -1 9695 oldLIndent, -1 9696 oldTight, -1 9697 oldParentType, -1 9698 start, -1 9699 posAfterMarker, -1 9700 ch, -1 9701 pos, -1 9702 max, -1 9703 indentAfterMarker, -1 9704 markerValue, -1 9705 markerCharCode, -1 9706 isOrdered, -1 9707 contentStart, -1 9708 listTokIdx, -1 9709 prevEmptyEnd, -1 9710 listLines, -1 9711 itemLines, -1 9712 tight = true, -1 9713 terminatorRules, -1 9714 token, -1 9715 i, l, terminate; 10203 971610204 -1 state.pos = pos;10205 -1 return true;10206 -1 }-1 9717 // Detect list type and position after marker -1 9718 if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) { -1 9719 isOrdered = true; -1 9720 } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) { -1 9721 isOrdered = false; -1 9722 } else { -1 9723 return false; 10207 9724 } 10208 972510209 -1 if (!silent) { state.pending += '\\'; }10210 -1 state.pos++;10211 -1 return true;10212 -1 };10213 -110214 -1 },{"../common/utils":43}],82:[function(require,module,exports){10215 -1 // Process html tags10216 -110217 -1 'use strict';10218 -1-1 9726 // We should terminate list on style change. Remember first one to compare. -1 9727 markerCharCode = state.src.charCodeAt(posAfterMarker - 1); 10219 972810220 -1 var HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE;-1 9729 // For validation mode we can terminate immediately -1 9730 if (silent) { return true; } 10221 9731 -1 9732 // Start list -1 9733 listTokIdx = state.tokens.length; 10222 973410223 -1 function isLetter(ch) {10224 -1 /*eslint no-bitwise:0*/10225 -1 var lc = ch | 0x20; // to lower case10226 -1 return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);10227 -1 }-1 9735 if (isOrdered) { -1 9736 start = state.bMarks[startLine] + state.tShift[startLine]; -1 9737 markerValue = Number(state.src.substr(start, posAfterMarker - start - 1)); 10228 9738 -1 9739 token = state.push('ordered_list_open', 'ol', 1); -1 9740 if (markerValue !== 1) { -1 9741 token.attrs = [ [ 'start', markerValue ] ]; -1 9742 } 10229 974310230 -1 module.exports = function html_inline(state, silent) {10231 -1 var ch, match, max, token,10232 -1 pos = state.pos;-1 9744 } else { -1 9745 token = state.push('bullet_list_open', 'ul', 1); -1 9746 } 10233 974710234 -1 if (!state.md.options.html) { return false; }-1 9748 token.map = listLines = [ startLine, 0 ]; -1 9749 token.markup = String.fromCharCode(markerCharCode); 10235 975010236 -1 // Check start10237 -1 max = state.posMax;10238 -1 if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||10239 -1 pos + 2 >= max) {10240 -1 return false;10241 -1 }-1 9751 // -1 9752 // Iterate list items -1 9753 // 10242 975410243 -1 // Quick fail on second char10244 -1 ch = state.src.charCodeAt(pos + 1);10245 -1 if (ch !== 0x21/* ! */ &&10246 -1 ch !== 0x3F/* ? */ &&10247 -1 ch !== 0x2F/* / */ &&10248 -1 !isLetter(ch)) {10249 -1 return false;10250 -1 }-1 9755 nextLine = startLine; -1 9756 prevEmptyEnd = false; -1 9757 terminatorRules = state.md.block.ruler.getRules('list'); 10251 975810252 -1 match = state.src.slice(pos).match(HTML_TAG_RE);10253 -1 if (!match) { return false; }-1 9759 while (nextLine < endLine) { -1 9760 pos = posAfterMarker; -1 9761 max = state.eMarks[nextLine]; 10254 976210255 -1 if (!silent) {10256 -1 token = state.push('html_inline', '', 0);10257 -1 token.content = state.src.slice(pos, pos + match[0].length);10258 -1 }10259 -1 state.pos += match[0].length;10260 -1 return true;10261 -1 };-1 9763 initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]); 10262 976410263 -1 },{"../common/html_re":42}],83:[function(require,module,exports){10264 -1 // Process -1 9765 while (pos < max) { -1 9766 ch = state.src.charCodeAt(pos); 10265 976710266 -1 'use strict';-1 9768 if (isSpace(ch)) { -1 9769 if (ch === 0x09) { -1 9770 offset += 4 - offset % 4; -1 9771 } else { -1 9772 offset++; -1 9773 } -1 9774 } else { -1 9775 break; -1 9776 } 10267 977710268 -1 var parseLinkLabel = require('../helpers/parse_link_label');10269 -1 var parseLinkDestination = require('../helpers/parse_link_destination');10270 -1 var parseLinkTitle = require('../helpers/parse_link_title');10271 -1 var normalizeReference = require('../common/utils').normalizeReference;10272 -1 var isSpace = require('../common/utils').isSpace;-1 9778 pos++; -1 9779 } 10273 9780 -1 9781 contentStart = pos; 10274 978210275 -1 module.exports = function image(state, silent) {10276 -1 var attrs,10277 -1 code,10278 -1 content,10279 -1 label,10280 -1 labelEnd,10281 -1 labelStart,10282 -1 pos,10283 -1 ref,10284 -1 res,10285 -1 title,10286 -1 token,10287 -1 tokens,10288 -1 start,10289 -1 href = '',10290 -1 oldPos = state.pos,10291 -1 max = state.posMax;-1 9783 if (contentStart >= max) { -1 9784 // trimming space in "- \n 3" case, indent is 1 here -1 9785 indentAfterMarker = 1; -1 9786 } else { -1 9787 indentAfterMarker = offset - initial; -1 9788 } 10292 978910293 -1 if (state.src.charCodeAt(state.pos) !== 0x21/* ! */) { return false; }10294 -1 if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; }-1 9790 // If we have more than 4 spaces, the indent is 1 -1 9791 // (the rest is just indented code block) -1 9792 if (indentAfterMarker > 4) { indentAfterMarker = 1; } 10295 979310296 -1 labelStart = state.pos + 2;10297 -1 labelEnd = parseLinkLabel(state, state.pos + 1, false);-1 9794 // " - test" -1 9795 // ^^^^^ - calculating total length of this thing -1 9796 indent = initial + indentAfterMarker; 10298 979710299 -1 // parser failed to find ']', so it's not a valid link10300 -1 if (labelEnd < 0) { return false; }-1 9798 // Run subparser & write tokens -1 9799 token = state.push('list_item_open', 'li', 1); -1 9800 token.markup = String.fromCharCode(markerCharCode); -1 9801 token.map = itemLines = [ startLine, 0 ]; 10301 980210302 -1 pos = labelEnd + 1;10303 -1 if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {10304 -1 //10305 -1 // Inline link10306 -1 //-1 9803 oldIndent = state.blkIndent; -1 9804 oldTight = state.tight; -1 9805 oldTShift = state.tShift[startLine]; -1 9806 oldLIndent = state.sCount[startLine]; -1 9807 oldParentType = state.parentType; -1 9808 state.blkIndent = indent; -1 9809 state.tight = true; -1 9810 state.parentType = 'list'; -1 9811 state.tShift[startLine] = contentStart - state.bMarks[startLine]; -1 9812 state.sCount[startLine] = offset; 10307 981310308 -1 // [link]( <href> "title" )10309 -1 // ^^ skipping these spaces10310 -1 pos++;10311 -1 for (; pos < max; pos++) {10312 -1 code = state.src.charCodeAt(pos);10313 -1 if (!isSpace(code) && code !== 0x0A) { break; }-1 9814 if (contentStart >= max && state.isEmpty(startLine + 1)) { -1 9815 // workaround for this case -1 9816 // (list item is empty, list terminates before "foo"): -1 9817 // ~~~~~~~~ -1 9818 // - -1 9819 // -1 9820 // foo -1 9821 // ~~~~~~~~ -1 9822 state.line = Math.min(state.line + 2, endLine); -1 9823 } else { -1 9824 state.md.block.tokenize(state, startLine, endLine, true); 10314 9825 }10315 -1 if (pos >= max) { return false; }10316 982610317 -1 // [link]( <href> "title" )10318 -1 // ^^^^^^ parsing link destination10319 -1 start = pos;10320 -1 res = parseLinkDestination(state.src, pos, state.posMax);10321 -1 if (res.ok) {10322 -1 href = state.md.normalizeLink(res.str);10323 -1 if (state.md.validateLink(href)) {10324 -1 pos = res.pos;10325 -1 } else {10326 -1 href = '';10327 -1 }-1 9827 // If any of list item is tight, mark list as tight -1 9828 if (!state.tight || prevEmptyEnd) { -1 9829 tight = false; 10328 9830 } -1 9831 // Item become loose if finish with empty line, -1 9832 // but we should filter last element, because it means list finish -1 9833 prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1); 10329 983410330 -1 // [link]( <href> "title" )10331 -1 // ^^ skipping these spaces10332 -1 start = pos;10333 -1 for (; pos < max; pos++) {10334 -1 code = state.src.charCodeAt(pos);10335 -1 if (!isSpace(code) && code !== 0x0A) { break; }10336 -1 }-1 9835 state.blkIndent = oldIndent; -1 9836 state.tShift[startLine] = oldTShift; -1 9837 state.sCount[startLine] = oldLIndent; -1 9838 state.tight = oldTight; -1 9839 state.parentType = oldParentType; 10337 984010338 -1 // [link]( <href> "title" )10339 -1 // ^^^^^^^ parsing link title10340 -1 res = parseLinkTitle(state.src, pos, state.posMax);10341 -1 if (pos < max && start !== pos && res.ok) {10342 -1 title = res.str;10343 -1 pos = res.pos;-1 9841 token = state.push('list_item_close', 'li', -1); -1 9842 token.markup = String.fromCharCode(markerCharCode); 10344 984310345 -1 // [link]( <href> "title" )10346 -1 // ^^ skipping these spaces10347 -1 for (; pos < max; pos++) {10348 -1 code = state.src.charCodeAt(pos);10349 -1 if (!isSpace(code) && code !== 0x0A) { break; }10350 -1 }10351 -1 } else {10352 -1 title = '';10353 -1 }-1 9844 nextLine = startLine = state.line; -1 9845 itemLines[1] = nextLine; -1 9846 contentStart = state.bMarks[startLine]; 10354 984710355 -1 if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {10356 -1 state.pos = oldPos;10357 -1 return false;-1 9848 if (nextLine >= endLine) { break; } -1 9849 -1 9850 if (state.isEmpty(nextLine)) { -1 9851 break; 10358 9852 }10359 -1 pos++;10360 -1 } else {-1 9853 10361 9854 //10362 -1 // Link reference-1 9855 // Try to check if list is terminated or continued. 10363 9856 //10364 -1 if (typeof state.env.references === 'undefined') { return false; }-1 9857 if (state.sCount[nextLine] < state.blkIndent) { break; } 10365 985810366 -1 if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {10367 -1 start = pos + 1;10368 -1 pos = parseLinkLabel(state, pos);10369 -1 if (pos >= 0) {10370 -1 label = state.src.slice(start, pos++);10371 -1 } else {10372 -1 pos = labelEnd + 1;-1 9859 // fail if terminating block found -1 9860 terminate = false; -1 9861 for (i = 0, l = terminatorRules.length; i < l; i++) { -1 9862 if (terminatorRules[i](state, nextLine, endLine, true)) { -1 9863 terminate = true; -1 9864 break; 10373 9865 } -1 9866 } -1 9867 if (terminate) { break; } -1 9868 -1 9869 // fail if list has another type -1 9870 if (isOrdered) { -1 9871 posAfterMarker = skipOrderedListMarker(state, nextLine); -1 9872 if (posAfterMarker < 0) { break; } 10374 9873 } else {10375 -1 pos = labelEnd + 1;-1 9874 posAfterMarker = skipBulletListMarker(state, nextLine); -1 9875 if (posAfterMarker < 0) { break; } 10376 9876 } 10377 987710378 -1 // covers label === '' and label === undefined10379 -1 // (collapsed reference link and shortcut reference link respectively)10380 -1 if (!label) { label = state.src.slice(labelStart, labelEnd); }-1 9878 if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; } -1 9879 } 10381 988010382 -1 ref = state.env.references[normalizeReference(label)];10383 -1 if (!ref) {10384 -1 state.pos = oldPos;10385 -1 return false;10386 -1 }10387 -1 href = ref.href;10388 -1 title = ref.title;-1 9881 // Finilize list -1 9882 if (isOrdered) { -1 9883 token = state.push('ordered_list_close', 'ol', -1); -1 9884 } else { -1 9885 token = state.push('bullet_list_close', 'ul', -1); 10389 9886 } -1 9887 token.markup = String.fromCharCode(markerCharCode); 10390 988810391 -1 //10392 -1 // We found the end of the link, and know for a fact it's a valid link;10393 -1 // so all that's left to do is to call tokenizer.10394 -1 //10395 -1 if (!silent) {10396 -1 content = state.src.slice(labelStart, labelEnd);-1 9889 listLines[1] = nextLine; -1 9890 state.line = nextLine; 10397 989110398 -1 state.md.inline.parse(10399 -1 content,10400 -1 state.md,10401 -1 state.env,10402 -1 tokens = []10403 -1 );-1 9892 // mark paragraphs tight if needed -1 9893 if (tight) { -1 9894 markTightParagraphs(state, listTokIdx); -1 9895 } 10404 989610405 -1 token = state.push('image', 'img', 0);10406 -1 token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ];10407 -1 token.children = tokens;10408 -1 token.content = content;-1 9897 return true; -1 9898 }; 10409 989910410 -1 if (title) {10411 -1 attrs.push([ 'title', title ]);-1 9900 },{"../common/utils":40}],62:[function(require,module,exports){ -1 9901 // Paragraph -1 9902 -1 9903 'use strict'; -1 9904 -1 9905 -1 9906 module.exports = function paragraph(state, startLine/*, endLine*/) { -1 9907 var content, terminate, i, l, token, -1 9908 nextLine = startLine + 1, -1 9909 terminatorRules = state.md.block.ruler.getRules('paragraph'), -1 9910 endLine = state.lineMax; -1 9911 -1 9912 // jump line-by-line until empty one or EOF -1 9913 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) { -1 9914 // this would be a code block normally, but after paragraph -1 9915 // it's considered a lazy continuation regardless of what's there -1 9916 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; } -1 9917 -1 9918 // quirk for blockquotes, this line should already be checked by that rule -1 9919 if (state.sCount[nextLine] < 0) { continue; } -1 9920 -1 9921 // Some tags can terminate paragraph without empty line. -1 9922 terminate = false; -1 9923 for (i = 0, l = terminatorRules.length; i < l; i++) { -1 9924 if (terminatorRules[i](state, nextLine, endLine, true)) { -1 9925 terminate = true; -1 9926 break; -1 9927 } 10412 9928 } -1 9929 if (terminate) { break; } 10413 9930 } 10414 993110415 -1 state.pos = pos;10416 -1 state.posMax = max;-1 9932 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim(); -1 9933 -1 9934 state.line = nextLine; -1 9935 -1 9936 token = state.push('paragraph_open', 'p', 1); -1 9937 token.map = [ startLine, state.line ]; -1 9938 -1 9939 token = state.push('inline', '', 0); -1 9940 token.content = content; -1 9941 token.map = [ startLine, state.line ]; -1 9942 token.children = []; -1 9943 -1 9944 token = state.push('paragraph_close', 'p', -1); -1 9945 10417 9946 return true; 10418 9947 }; 10419 994810420 -1 },{"../common/utils":43,"../helpers/parse_link_destination":45,"../helpers/parse_link_label":46,"../helpers/parse_link_title":47}],84:[function(require,module,exports){10421 -1 // Process [link](<to> "stuff")10422 -1-1 9949 },{}],63:[function(require,module,exports){ 10423 9950 'use strict'; 10424 995110425 -1 var parseLinkLabel = require('../helpers/parse_link_label');-1 9952 10426 9953 var parseLinkDestination = require('../helpers/parse_link_destination'); 10427 9954 var parseLinkTitle = require('../helpers/parse_link_title'); 10428 9955 var normalizeReference = require('../common/utils').normalizeReference; 10429 9956 var isSpace = require('../common/utils').isSpace; 10430 9957 10431 995810432 -1 module.exports = function link(state, silent) {10433 -1 var attrs,10434 -1 code,-1 9959 module.exports = function reference(state, startLine, _endLine, silent) { -1 9960 var ch, -1 9961 destEndPos, -1 9962 destEndLineNo, -1 9963 endLine, -1 9964 href, -1 9965 i, -1 9966 l, 10435 9967 label, 10436 9968 labelEnd,10437 -1 labelStart,10438 -1 pos,10439 9969 res,10440 -1 ref,-1 9970 start, -1 9971 str, -1 9972 terminate, -1 9973 terminatorRules, 10441 9974 title,10442 -1 token,10443 -1 href = '',10444 -1 oldPos = state.pos,10445 -1 max = state.posMax,10446 -1 start = state.pos;-1 9975 lines = 0, -1 9976 pos = state.bMarks[startLine] + state.tShift[startLine], -1 9977 max = state.eMarks[startLine], -1 9978 nextLine = startLine + 1; 10447 997910448 -1 if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; }-1 9980 if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; } 10449 998110450 -1 labelStart = state.pos + 1;10451 -1 labelEnd = parseLinkLabel(state, state.pos, true);-1 9982 // Simple check to quickly interrupt scan on [link](url) at the start of line. -1 9983 // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54 -1 9984 while (++pos < max) { -1 9985 if (state.src.charCodeAt(pos) === 0x5D /* ] */ && -1 9986 state.src.charCodeAt(pos - 1) !== 0x5C/* \ */) { -1 9987 if (pos + 1 === max) { return false; } -1 9988 if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false; } -1 9989 break; -1 9990 } -1 9991 } 10452 999210453 -1 // parser failed to find ']', so it's not a valid link10454 -1 if (labelEnd < 0) { return false; }-1 9993 endLine = state.lineMax; 10455 999410456 -1 pos = labelEnd + 1;10457 -1 if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {10458 -1 //10459 -1 // Inline link10460 -1 //-1 9995 // jump line-by-line until empty one or EOF -1 9996 terminatorRules = state.md.block.ruler.getRules('reference'); 10461 999710462 -1 // [link]( <href> "title" )10463 -1 // ^^ skipping these spaces10464 -1 pos++;10465 -1 for (; pos < max; pos++) {10466 -1 code = state.src.charCodeAt(pos);10467 -1 if (!isSpace(code) && code !== 0x0A) { break; }-1 9998 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) { -1 9999 // this would be a code block normally, but after paragraph -1 10000 // it's considered a lazy continuation regardless of what's there -1 10001 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; } -1 10002 -1 10003 // quirk for blockquotes, this line should already be checked by that rule -1 10004 if (state.sCount[nextLine] < 0) { continue; } -1 10005 -1 10006 // Some tags can terminate paragraph without empty line. -1 10007 terminate = false; -1 10008 for (i = 0, l = terminatorRules.length; i < l; i++) { -1 10009 if (terminatorRules[i](state, nextLine, endLine, true)) { -1 10010 terminate = true; -1 10011 break; -1 10012 } 10468 10013 }10469 -1 if (pos >= max) { return false; }-1 10014 if (terminate) { break; } -1 10015 } 10470 1001610471 -1 // [link]( <href> "title" )10472 -1 // ^^^^^^ parsing link destination10473 -1 start = pos;10474 -1 res = parseLinkDestination(state.src, pos, state.posMax);10475 -1 if (res.ok) {10476 -1 href = state.md.normalizeLink(res.str);10477 -1 if (state.md.validateLink(href)) {10478 -1 pos = res.pos;10479 -1 } else {10480 -1 href = '';-1 10017 str = state.getLines(startLine, nextLine, state.blkIndent, false).trim(); -1 10018 max = str.length; -1 10019 -1 10020 for (pos = 1; pos < max; pos++) { -1 10021 ch = str.charCodeAt(pos); -1 10022 if (ch === 0x5B /* [ */) { -1 10023 return false; -1 10024 } else if (ch === 0x5D /* ] */) { -1 10025 labelEnd = pos; -1 10026 break; -1 10027 } else if (ch === 0x0A /* \n */) { -1 10028 lines++; -1 10029 } else if (ch === 0x5C /* \ */) { -1 10030 pos++; -1 10031 if (pos < max && str.charCodeAt(pos) === 0x0A) { -1 10032 lines++; 10481 10033 } 10482 10034 } -1 10035 } 10483 1003610484 -1 // [link]( <href> "title" )10485 -1 // ^^ skipping these spaces10486 -1 start = pos;10487 -1 for (; pos < max; pos++) {10488 -1 code = state.src.charCodeAt(pos);10489 -1 if (!isSpace(code) && code !== 0x0A) { break; }-1 10037 if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false; } -1 10038 -1 10039 // [label]: destination 'title' -1 10040 // ^^^ skip optional whitespace here -1 10041 for (pos = labelEnd + 2; pos < max; pos++) { -1 10042 ch = str.charCodeAt(pos); -1 10043 if (ch === 0x0A) { -1 10044 lines++; -1 10045 } else if (isSpace(ch)) { -1 10046 /*eslint no-empty:0*/ -1 10047 } else { -1 10048 break; 10490 10049 } -1 10050 } 10491 1005110492 -1 // [link]( <href> "title" )10493 -1 // ^^^^^^^ parsing link title10494 -1 res = parseLinkTitle(state.src, pos, state.posMax);10495 -1 if (pos < max && start !== pos && res.ok) {10496 -1 title = res.str;10497 -1 pos = res.pos;-1 10052 // [label]: destination 'title' -1 10053 // ^^^^^^^^^^^ parse this -1 10054 res = parseLinkDestination(str, pos, max); -1 10055 if (!res.ok) { return false; } 10498 1005610499 -1 // [link]( <href> "title" )10500 -1 // ^^ skipping these spaces10501 -1 for (; pos < max; pos++) {10502 -1 code = state.src.charCodeAt(pos);10503 -1 if (!isSpace(code) && code !== 0x0A) { break; }10504 -1 }-1 10057 href = state.md.normalizeLink(res.str); -1 10058 if (!state.md.validateLink(href)) { return false; } -1 10059 -1 10060 pos = res.pos; -1 10061 lines += res.lines; -1 10062 -1 10063 // save cursor state, we could require to rollback later -1 10064 destEndPos = pos; -1 10065 destEndLineNo = lines; -1 10066 -1 10067 // [label]: destination 'title' -1 10068 // ^^^ skipping those spaces -1 10069 start = pos; -1 10070 for (; pos < max; pos++) { -1 10071 ch = str.charCodeAt(pos); -1 10072 if (ch === 0x0A) { -1 10073 lines++; -1 10074 } else if (isSpace(ch)) { -1 10075 /*eslint no-empty:0*/ 10505 10076 } else {10506 -1 title = '';-1 10077 break; 10507 10078 } -1 10079 } 10508 1008010509 -1 if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {10510 -1 state.pos = oldPos;10511 -1 return false;10512 -1 }10513 -1 pos++;-1 10081 // [label]: destination 'title' -1 10082 // ^^^^^^^ parse this -1 10083 res = parseLinkTitle(str, pos, max); -1 10084 if (pos < max && start !== pos && res.ok) { -1 10085 title = res.str; -1 10086 pos = res.pos; -1 10087 lines += res.lines; 10514 10088 } else {10515 -1 //10516 -1 // Link reference10517 -1 //10518 -1 if (typeof state.env.references === 'undefined') { return false; }10519 -110520 -1 if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {10521 -1 start = pos + 1;10522 -1 pos = parseLinkLabel(state, pos);10523 -1 if (pos >= 0) {10524 -1 label = state.src.slice(start, pos++);10525 -1 } else {10526 -1 pos = labelEnd + 1;10527 -1 }10528 -1 } else {10529 -1 pos = labelEnd + 1;10530 -1 }-1 10089 title = ''; -1 10090 pos = destEndPos; -1 10091 lines = destEndLineNo; -1 10092 } 10531 1009310532 -1 // covers label === '' and label === undefined10533 -1 // (collapsed reference link and shortcut reference link respectively)10534 -1 if (!label) { label = state.src.slice(labelStart, labelEnd); }-1 10094 // skip trailing spaces until the rest of the line -1 10095 while (pos < max) { -1 10096 ch = str.charCodeAt(pos); -1 10097 if (!isSpace(ch)) { break; } -1 10098 pos++; -1 10099 } 10535 1010010536 -1 ref = state.env.references[normalizeReference(label)];10537 -1 if (!ref) {10538 -1 state.pos = oldPos;10539 -1 return false;-1 10101 if (pos < max && str.charCodeAt(pos) !== 0x0A) { -1 10102 if (title) { -1 10103 // garbage at the end of the line after title, -1 10104 // but it could still be a valid reference if we roll back -1 10105 title = ''; -1 10106 pos = destEndPos; -1 10107 lines = destEndLineNo; -1 10108 while (pos < max) { -1 10109 ch = str.charCodeAt(pos); -1 10110 if (!isSpace(ch)) { break; } -1 10111 pos++; -1 10112 } 10540 10113 }10541 -1 href = ref.href;10542 -1 title = ref.title;10543 10114 } 10544 1011510545 -1 //10546 -1 // We found the end of the link, and know for a fact it's a valid link;10547 -1 // so all that's left to do is to call tokenizer.10548 -1 //10549 -1 if (!silent) {10550 -1 state.pos = labelStart;10551 -1 state.posMax = labelEnd;-1 10116 if (pos < max && str.charCodeAt(pos) !== 0x0A) { -1 10117 // garbage at the end of the line -1 10118 return false; -1 10119 } 10552 1012010553 -1 token = state.push('link_open', 'a', 1);10554 -1 token.attrs = attrs = [ [ 'href', href ] ];10555 -1 if (title) {10556 -1 attrs.push([ 'title', title ]);10557 -1 }-1 10121 label = normalizeReference(str.slice(1, labelEnd)); -1 10122 if (!label) { -1 10123 // CommonMark 0.20 disallows empty labels -1 10124 return false; -1 10125 } 10558 1012610559 -1 state.md.inline.tokenize(state);-1 10127 // Reference can not terminate anything. This check is for safety only. -1 10128 /*istanbul ignore if*/ -1 10129 if (silent) { return true; } 10560 1013010561 -1 token = state.push('link_close', 'a', -1);-1 10131 if (typeof state.env.references === 'undefined') { -1 10132 state.env.references = {}; -1 10133 } -1 10134 if (typeof state.env.references[label] === 'undefined') { -1 10135 state.env.references[label] = { title: title, href: href }; 10562 10136 } 10563 1013710564 -1 state.pos = pos;10565 -1 state.posMax = max;-1 10138 state.line = startLine + lines + 1; 10566 10139 return true; 10567 10140 }; 10568 1014110569 -1 },{"../common/utils":43,"../helpers/parse_link_destination":45,"../helpers/parse_link_label":46,"../helpers/parse_link_title":47}],85:[function(require,module,exports){10570 -1 // Proceess '\n'-1 10142 },{"../common/utils":40,"../helpers/parse_link_destination":42,"../helpers/parse_link_title":44}],64:[function(require,module,exports){ -1 10143 // Parser state class 10571 10144 10572 10145 'use strict'; 10573 1014610574 -1 module.exports = function newline(state, silent) {10575 -1 var pmax, max, pos = state.pos;-1 10147 var Token = require('../token'); -1 10148 var isSpace = require('../common/utils').isSpace; 10576 1014910577 -1 if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }10578 1015010579 -1 pmax = state.pending.length - 1;10580 -1 max = state.posMax;-1 10151 function StateBlock(src, md, env, tokens) { -1 10152 var ch, s, start, pos, len, indent, offset, indent_found; 10581 1015310582 -1 // ' \n' -> hardbreak10583 -1 // Lookup in pending chars is bad practice! Don't copy to other rules!10584 -1 // Pending string is stored in concat mode, indexed lookups will cause10585 -1 // convertion to flat mode.10586 -1 if (!silent) {10587 -1 if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {10588 -1 if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {10589 -1 state.pending = state.pending.replace(/ +$/, '');10590 -1 state.push('hardbreak', 'br', 0);10591 -1 } else {10592 -1 state.pending = state.pending.slice(0, -1);10593 -1 state.push('softbreak', 'br', 0);10594 -1 }-1 10154 this.src = src; 10595 1015510596 -1 } else {10597 -1 state.push('softbreak', 'br', 0);10598 -1 }10599 -1 }-1 10156 // link to parser instance -1 10157 this.md = md; 10600 1015810601 -1 pos++;-1 10159 this.env = env; 10602 1016010603 -1 // skip heading spaces for next line10604 -1 while (pos < max && state.src.charCodeAt(pos) === 0x20) { pos++; }-1 10161 // -1 10162 // Internal state vartiables -1 10163 // 10605 1016410606 -1 state.pos = pos;10607 -1 return true;10608 -1 };-1 10165 this.tokens = tokens; 10609 1016610610 -1 },{}],86:[function(require,module,exports){10611 -1 // Inline parser state-1 10167 this.bMarks = []; // line begin offsets for fast jumps -1 10168 this.eMarks = []; // line end offsets for fast jumps -1 10169 this.tShift = []; // offsets of the first non-space characters (tabs not expanded) -1 10170 this.sCount = []; // indents for each line (tabs expanded) 10612 1017110613 -1 'use strict';-1 10172 // block parser variables -1 10173 this.blkIndent = 0; // required block content indent -1 10174 // (for example, if we are in list) -1 10175 this.line = 0; // line index in src -1 10176 this.lineMax = 0; // lines count -1 10177 this.tight = false; // loose/tight mode for lists -1 10178 this.parentType = 'root'; // if `list`, block parser stops on two newlines -1 10179 this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any) 10614 10180 -1 10181 this.level = 0; 10615 1018210616 -1 var Token = require('../token');10617 -1 var isWhiteSpace = require('../common/utils').isWhiteSpace;10618 -1 var isPunctChar = require('../common/utils').isPunctChar;10619 -1 var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;-1 10183 // renderer -1 10184 this.result = ''; 10620 10185 -1 10186 // Create caches -1 10187 // Generate markers. -1 10188 s = this.src; -1 10189 indent_found = false; 10621 1019010622 -1 function StateInline(src, md, env, outTokens) {10623 -1 this.src = src;10624 -1 this.env = env;10625 -1 this.md = md;10626 -1 this.tokens = outTokens;-1 10191 for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) { -1 10192 ch = s.charCodeAt(pos); 10627 1019310628 -1 this.pos = 0;10629 -1 this.posMax = this.src.length;10630 -1 this.level = 0;10631 -1 this.pending = '';10632 -1 this.pendingLevel = 0;-1 10194 if (!indent_found) { -1 10195 if (isSpace(ch)) { -1 10196 indent++; 10633 1019710634 -1 this.cache = {}; // Stores { start: end } pairs. Useful for backtrack10635 -1 // optimization of pairs parse (emphasis, strikes).-1 10198 if (ch === 0x09) { -1 10199 offset += 4 - offset % 4; -1 10200 } else { -1 10201 offset++; -1 10202 } -1 10203 continue; -1 10204 } else { -1 10205 indent_found = true; -1 10206 } -1 10207 } 10636 1020810637 -1 this.delimiters = []; // Emphasis-like delimiters10638 -1 }-1 10209 if (ch === 0x0A || pos === len - 1) { -1 10210 if (ch !== 0x0A) { pos++; } -1 10211 this.bMarks.push(start); -1 10212 this.eMarks.push(pos); -1 10213 this.tShift.push(indent); -1 10214 this.sCount.push(offset); -1 10215 -1 10216 indent_found = false; -1 10217 indent = 0; -1 10218 offset = 0; -1 10219 start = pos + 1; -1 10220 } -1 10221 } 10639 10222 -1 10223 // Push fake entry to simplify cache bounds checks -1 10224 this.bMarks.push(s.length); -1 10225 this.eMarks.push(s.length); -1 10226 this.tShift.push(0); -1 10227 this.sCount.push(0); 10640 1022810641 -1 // Flush pending text-1 10229 this.lineMax = this.bMarks.length - 1; // don't count last fake line -1 10230 } -1 10231 -1 10232 // Push new token to "stream". 10642 10233 //10643 -1 StateInline.prototype.pushPending = function () {10644 -1 var token = new Token('text', '', 0);10645 -1 token.content = this.pending;10646 -1 token.level = this.pendingLevel;-1 10234 StateBlock.prototype.push = function (type, tag, nesting) { -1 10235 var token = new Token(type, tag, nesting); -1 10236 token.block = true; -1 10237 -1 10238 if (nesting < 0) { this.level--; } -1 10239 token.level = this.level; -1 10240 if (nesting > 0) { this.level++; } -1 10241 10647 10242 this.tokens.push(token);10648 -1 this.pending = '';10649 10243 return token; 10650 10244 }; 10651 10245 -1 10246 StateBlock.prototype.isEmpty = function isEmpty(line) { -1 10247 return this.bMarks[line] + this.tShift[line] >= this.eMarks[line]; -1 10248 }; -1 10249 -1 10250 StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) { -1 10251 for (var max = this.lineMax; from < max; from++) { -1 10252 if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) { -1 10253 break; -1 10254 } -1 10255 } -1 10256 return from; -1 10257 }; -1 10258 -1 10259 // Skip spaces from given position. -1 10260 StateBlock.prototype.skipSpaces = function skipSpaces(pos) { -1 10261 var ch; -1 10262 -1 10263 for (var max = this.src.length; pos < max; pos++) { -1 10264 ch = this.src.charCodeAt(pos); -1 10265 if (!isSpace(ch)) { break; } -1 10266 } -1 10267 return pos; -1 10268 }; -1 10269 -1 10270 // Skip spaces from given position in reverse. -1 10271 StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) { -1 10272 if (pos <= min) { return pos; } 10652 1027310653 -1 // Push new token to "stream".10654 -1 // If pending text exists - flush it as text token10655 -1 //10656 -1 StateInline.prototype.push = function (type, tag, nesting) {10657 -1 if (this.pending) {10658 -1 this.pushPending();-1 10274 while (pos > min) { -1 10275 if (!isSpace(this.src.charCodeAt(--pos))) { return pos + 1; } 10659 10276 } -1 10277 return pos; -1 10278 }; 10660 1027910661 -1 var token = new Token(type, tag, nesting);10662 -110663 -1 if (nesting < 0) { this.level--; }10664 -1 token.level = this.level;10665 -1 if (nesting > 0) { this.level++; }10666 -110667 -1 this.pendingLevel = this.level;10668 -1 this.tokens.push(token);10669 -1 return token;-1 10280 // Skip char codes from given position -1 10281 StateBlock.prototype.skipChars = function skipChars(pos, code) { -1 10282 for (var max = this.src.length; pos < max; pos++) { -1 10283 if (this.src.charCodeAt(pos) !== code) { break; } -1 10284 } -1 10285 return pos; 10670 10286 }; 10671 10287 -1 10288 // Skip char codes reverse from given position - 1 -1 10289 StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) { -1 10290 if (pos <= min) { return pos; } 10672 1029110673 -1 // Scan a sequence of emphasis-like markers, and determine whether10674 -1 // it can start an emphasis sequence or end an emphasis sequence.10675 -1 //10676 -1 // - start - position to scan from (it should point at a valid marker);10677 -1 // - canSplitWord - determine if these markers can be found inside a word10678 -1 //10679 -1 StateInline.prototype.scanDelims = function (start, canSplitWord) {10680 -1 var pos = start, lastChar, nextChar, count, can_open, can_close,10681 -1 isLastWhiteSpace, isLastPunctChar,10682 -1 isNextWhiteSpace, isNextPunctChar,10683 -1 left_flanking = true,10684 -1 right_flanking = true,10685 -1 max = this.posMax,10686 -1 marker = this.src.charCodeAt(start);-1 10292 while (pos > min) { -1 10293 if (code !== this.src.charCodeAt(--pos)) { return pos + 1; } -1 10294 } -1 10295 return pos; -1 10296 }; 10687 1029710688 -1 // treat beginning of the line as a whitespace10689 -1 lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;-1 10298 // cut lines range from source. -1 10299 StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) { -1 10300 var i, lineIndent, ch, first, last, queue, lineStart, -1 10301 line = begin; 10690 1030210691 -1 while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }-1 10303 if (begin >= end) { -1 10304 return ''; -1 10305 } 10692 1030610693 -1 count = pos - start;-1 10307 queue = new Array(end - begin); 10694 1030810695 -1 // treat end of the line as a whitespace10696 -1 nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;-1 10309 for (i = 0; line < end; line++, i++) { -1 10310 lineIndent = 0; -1 10311 lineStart = first = this.bMarks[line]; 10697 1031210698 -1 isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));10699 -1 isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));-1 10313 if (line + 1 < end || keepLastLF) { -1 10314 // No need for bounds check because we have fake entry on tail. -1 10315 last = this.eMarks[line] + 1; -1 10316 } else { -1 10317 last = this.eMarks[line]; -1 10318 } 10700 1031910701 -1 isLastWhiteSpace = isWhiteSpace(lastChar);10702 -1 isNextWhiteSpace = isWhiteSpace(nextChar);-1 10320 while (first < last && lineIndent < indent) { -1 10321 ch = this.src.charCodeAt(first); 10703 1032210704 -1 if (isNextWhiteSpace) {10705 -1 left_flanking = false;10706 -1 } else if (isNextPunctChar) {10707 -1 if (!(isLastWhiteSpace || isLastPunctChar)) {10708 -1 left_flanking = false;10709 -1 }10710 -1 }-1 10323 if (isSpace(ch)) { -1 10324 if (ch === 0x09) { -1 10325 lineIndent += 4 - lineIndent % 4; -1 10326 } else { -1 10327 lineIndent++; -1 10328 } -1 10329 } else if (first - lineStart < this.tShift[line]) { -1 10330 // patched tShift masked characters to look like spaces (blockquotes, list markers) -1 10331 lineIndent++; -1 10332 } else { -1 10333 break; -1 10334 } 10711 1033510712 -1 if (isLastWhiteSpace) {10713 -1 right_flanking = false;10714 -1 } else if (isLastPunctChar) {10715 -1 if (!(isNextWhiteSpace || isNextPunctChar)) {10716 -1 right_flanking = false;-1 10336 first++; 10717 10337 }10718 -1 }10719 1033810720 -1 if (!canSplitWord) {10721 -1 can_open = left_flanking && (!right_flanking || isLastPunctChar);10722 -1 can_close = right_flanking && (!left_flanking || isNextPunctChar);10723 -1 } else {10724 -1 can_open = left_flanking;10725 -1 can_close = right_flanking;-1 10339 queue[i] = this.src.slice(first, last); 10726 10340 } 10727 1034110728 -1 return {10729 -1 can_open: can_open,10730 -1 can_close: can_close,10731 -1 length: count10732 -1 };-1 10342 return queue.join(''); 10733 10343 }; 10734 1034410735 -110736 10345 // re-export Token class to use in block rules10737 -1 StateInline.prototype.Token = Token;-1 10346 StateBlock.prototype.Token = Token; 10738 10347 10739 1034810740 -1 module.exports = StateInline;-1 10349 module.exports = StateBlock; -1 10350 -1 10351 },{"../common/utils":40,"../token":87}],65:[function(require,module,exports){ -1 10352 // GFM table, non-standard 10741 1035310742 -1 },{"../common/utils":43,"../token":90}],87:[function(require,module,exports){10743 -1 // ~~strike through~~10744 -1 //10745 10354 'use strict'; 10746 10355 10747 1035610748 -1 // Insert each marker as a separate text token, and add it to delimiter list10749 -1 //10750 -1 module.exports.tokenize = function strikethrough(state, silent) {10751 -1 var i, scanned, token, len, ch,10752 -1 start = state.pos,10753 -1 marker = state.src.charCodeAt(start);-1 10357 function getLine(state, line) { -1 10358 var pos = state.bMarks[line] + state.blkIndent, -1 10359 max = state.eMarks[line]; 10754 1036010755 -1 if (silent) { return false; }-1 10361 return state.src.substr(pos, max - pos); -1 10362 } 10756 1036310757 -1 if (marker !== 0x7E/* ~ */) { return false; }-1 10364 function escapedSplit(str) { -1 10365 var result = [], -1 10366 pos = 0, -1 10367 max = str.length, -1 10368 ch, -1 10369 escapes = 0, -1 10370 lastPos = 0, -1 10371 backTicked = false, -1 10372 lastBackTick = 0; 10758 1037310759 -1 scanned = state.scanDelims(state.pos, true);10760 -1 len = scanned.length;10761 -1 ch = String.fromCharCode(marker);-1 10374 ch = str.charCodeAt(pos); 10762 1037510763 -1 if (len < 2) { return false; }-1 10376 while (pos < max) { -1 10377 if (ch === 0x60/* ` */ && (escapes % 2 === 0)) { -1 10378 backTicked = !backTicked; -1 10379 lastBackTick = pos; -1 10380 } else if (ch === 0x7c/* | */ && (escapes % 2 === 0) && !backTicked) { -1 10381 result.push(str.substring(lastPos, pos)); -1 10382 lastPos = pos + 1; -1 10383 } else if (ch === 0x5c/* \ */) { -1 10384 escapes++; -1 10385 } else { -1 10386 escapes = 0; -1 10387 } 10764 1038810765 -1 if (len % 2) {10766 -1 token = state.push('text', '', 0);10767 -1 token.content = ch;10768 -1 len--;10769 -1 }-1 10389 pos++; 10770 1039010771 -1 for (i = 0; i < len; i += 2) {10772 -1 token = state.push('text', '', 0);10773 -1 token.content = ch + ch;-1 10391 // If there was an un-closed backtick, go back to just after -1 10392 // the last backtick, but as if it was a normal character -1 10393 if (pos === max && backTicked) { -1 10394 backTicked = false; -1 10395 pos = lastBackTick + 1; -1 10396 } 10774 1039710775 -1 state.delimiters.push({10776 -1 marker: marker,10777 -1 jump: i,10778 -1 token: state.tokens.length - 1,10779 -1 level: state.level,10780 -1 end: -1,10781 -1 open: scanned.can_open,10782 -1 close: scanned.can_close10783 -1 });-1 10398 ch = str.charCodeAt(pos); 10784 10399 } 10785 1040010786 -1 state.pos += scanned.length;10787 -110788 -1 return true;10789 -1 };10790 -110791 -110792 -1 // Walk through delimiter list and replace text tokens with tags10793 -1 //10794 -1 module.exports.postProcess = function strikethrough(state) {10795 -1 var i, j,10796 -1 startDelim,10797 -1 endDelim,10798 -1 token,10799 -1 loneMarkers = [],10800 -1 delimiters = state.delimiters,10801 -1 max = state.delimiters.length;-1 10401 result.push(str.substring(lastPos)); 10802 1040210803 -1 for (i = 0; i < max; i++) {10804 -1 startDelim = delimiters[i];-1 10403 return result; -1 10404 } 10805 1040510806 -1 if (startDelim.marker !== 0x7E/* ~ */) {10807 -1 continue;10808 -1 }10809 1040610810 -1 if (startDelim.end === -1) {10811 -1 continue;10812 -1 }-1 10407 module.exports = function table(state, startLine, endLine, silent) { -1 10408 var ch, lineText, pos, i, nextLine, columns, columnCount, token, -1 10409 aligns, t, tableLines, tbodyLines; 10813 1041010814 -1 endDelim = delimiters[startDelim.end];-1 10411 // should have at least three lines -1 10412 if (startLine + 2 > endLine) { return false; } 10815 1041310816 -1 token = state.tokens[startDelim.token];10817 -1 token.type = 's_open';10818 -1 token.tag = 's';10819 -1 token.nesting = 1;10820 -1 token.markup = '~~';10821 -1 token.content = '';-1 10414 nextLine = startLine + 1; 10822 1041510823 -1 token = state.tokens[endDelim.token];10824 -1 token.type = 's_close';10825 -1 token.tag = 's';10826 -1 token.nesting = -1;10827 -1 token.markup = '~~';10828 -1 token.content = '';-1 10416 if (state.sCount[nextLine] < state.blkIndent) { return false; } 10829 1041710830 -1 if (state.tokens[endDelim.token - 1].type === 'text' &&10831 -1 state.tokens[endDelim.token - 1].content === '~') {-1 10418 // first character of the second line should be '|' or '-' 10832 1041910833 -1 loneMarkers.push(endDelim.token - 1);10834 -1 }10835 -1 }-1 10420 pos = state.bMarks[nextLine] + state.tShift[nextLine]; -1 10421 if (pos >= state.eMarks[nextLine]) { return false; } 10836 1042210837 -1 // If a marker sequence has an odd number of characters, it's splitted10838 -1 // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the10839 -1 // start of the sequence.10840 -1 //10841 -1 // So, we have to move all those markers after subsequent s_close tags.10842 -1 //10843 -1 while (loneMarkers.length) {10844 -1 i = loneMarkers.pop();10845 -1 j = i + 1;-1 10423 ch = state.src.charCodeAt(pos); -1 10424 if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; } 10846 1042510847 -1 while (j < state.tokens.length && state.tokens[j].type === 's_close') {10848 -1 j++;10849 -1 }-1 10426 lineText = getLine(state, startLine + 1); -1 10427 if (!/^[-:| ]+$/.test(lineText)) { return false; } 10850 1042810851 -1 j--;-1 10429 columns = lineText.split('|'); -1 10430 aligns = []; -1 10431 for (i = 0; i < columns.length; i++) { -1 10432 t = columns[i].trim(); -1 10433 if (!t) { -1 10434 // allow empty columns before and after table, but not in between columns; -1 10435 // e.g. allow ` |---| `, disallow ` ---||--- ` -1 10436 if (i === 0 || i === columns.length - 1) { -1 10437 continue; -1 10438 } else { -1 10439 return false; -1 10440 } -1 10441 } 10852 1044210853 -1 if (i !== j) {10854 -1 token = state.tokens[j];10855 -1 state.tokens[j] = state.tokens[i];10856 -1 state.tokens[i] = token;-1 10443 if (!/^:?-+:?$/.test(t)) { return false; } -1 10444 if (t.charCodeAt(t.length - 1) === 0x3A/* : */) { -1 10445 aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right'); -1 10446 } else if (t.charCodeAt(0) === 0x3A/* : */) { -1 10447 aligns.push('left'); -1 10448 } else { -1 10449 aligns.push(''); 10857 10450 } 10858 10451 }10859 -1 };10860 1045210861 -1 },{}],88:[function(require,module,exports){10862 -1 // Skip text characters for text token, place those to pending buffer10863 -1 // and increment current pos-1 10453 lineText = getLine(state, startLine).trim(); -1 10454 if (lineText.indexOf('|') === -1) { return false; } -1 10455 columns = escapedSplit(lineText.replace(/^\||\|$/g, '')); 10864 1045610865 -1 'use strict';-1 10457 // header row will define an amount of columns in the entire table, -1 10458 // and align row shouldn't be smaller than that (the rest of the rows can) -1 10459 columnCount = columns.length; -1 10460 if (columnCount > aligns.length) { return false; } 10866 10461 -1 10462 if (silent) { return true; } 10867 1046310868 -1 // Rule to skip pure text10869 -1 // '{}$%@~+=:' reserved for extentions-1 10464 token = state.push('table_open', 'table', 1); -1 10465 token.map = tableLines = [ startLine, 0 ]; 10870 1046610871 -1 // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~-1 10467 token = state.push('thead_open', 'thead', 1); -1 10468 token.map = [ startLine, startLine + 1 ]; 10872 1046910873 -1 // !!!! Don't confuse with "Markdown ASCII Punctuation" chars10874 -1 // http://spec.commonmark.org/0.15/#ascii-punctuation-character10875 -1 function isTerminatorChar(ch) {10876 -1 switch (ch) {10877 -1 case 0x0A/* \n */:10878 -1 case 0x21/* ! */:10879 -1 case 0x23/* # */:10880 -1 case 0x24/* $ */:10881 -1 case 0x25/* % */:10882 -1 case 0x26/* & */:10883 -1 case 0x2A/* * */:10884 -1 case 0x2B/* + */:10885 -1 case 0x2D/* - */:10886 -1 case 0x3A/* : */:10887 -1 case 0x3C/* < */:10888 -1 case 0x3D/* = */:10889 -1 case 0x3E/* > */:10890 -1 case 0x40/* @ */:10891 -1 case 0x5B/* [ */:10892 -1 case 0x5C/* \ */:10893 -1 case 0x5D/* ] */:10894 -1 case 0x5E/* ^ */:10895 -1 case 0x5F/* _ */:10896 -1 case 0x60/* ` */:10897 -1 case 0x7B/* { */:10898 -1 case 0x7D/* } */:10899 -1 case 0x7E/* ~ */:10900 -1 return true;10901 -1 default:10902 -1 return false;10903 -1 }10904 -1 }-1 10470 token = state.push('tr_open', 'tr', 1); -1 10471 token.map = [ startLine, startLine + 1 ]; 10905 1047210906 -1 module.exports = function text(state, silent) {10907 -1 var pos = state.pos;-1 10473 for (i = 0; i < columns.length; i++) { -1 10474 token = state.push('th_open', 'th', 1); -1 10475 token.map = [ startLine, startLine + 1 ]; -1 10476 if (aligns[i]) { -1 10477 token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ]; -1 10478 } 10908 1047910909 -1 while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {10910 -1 pos++;10911 -1 }-1 10480 token = state.push('inline', '', 0); -1 10481 token.content = columns[i].trim(); -1 10482 token.map = [ startLine, startLine + 1 ]; -1 10483 token.children = []; 10912 1048410913 -1 if (pos === state.pos) { return false; }-1 10485 token = state.push('th_close', 'th', -1); -1 10486 } 10914 1048710915 -1 if (!silent) { state.pending += state.src.slice(state.pos, pos); }-1 10488 token = state.push('tr_close', 'tr', -1); -1 10489 token = state.push('thead_close', 'thead', -1); 10916 1049010917 -1 state.pos = pos;-1 10491 token = state.push('tbody_open', 'tbody', 1); -1 10492 token.map = tbodyLines = [ startLine + 2, 0 ]; 10918 1049310919 -1 return true;10920 -1 };-1 10494 for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { -1 10495 if (state.sCount[nextLine] < state.blkIndent) { break; } 10921 1049610922 -1 // Alternative implementation, for memory.10923 -1 //10924 -1 // It costs 10% of performance, but allows extend terminators list, if place it10925 -1 // to `ParcerInline` property. Probably, will switch to it sometime, such10926 -1 // flexibility required.-1 10497 lineText = getLine(state, nextLine); -1 10498 if (lineText.indexOf('|') === -1) { break; } 10927 1049910928 -1 /*10929 -1 var TERMINATOR_RE = /[\n!#$%&*+\-:<=>@[\\\]^_`{}~]/;-1 10500 // keep spaces at beginning of line to indicate an empty first cell, but -1 10501 // strip trailing whitespace -1 10502 columns = escapedSplit(lineText.replace(/^\||\|\s*$/g, '')); 10930 1050310931 -1 module.exports = function text(state, silent) {10932 -1 var pos = state.pos,10933 -1 idx = state.src.slice(pos).search(TERMINATOR_RE);-1 10504 token = state.push('tr_open', 'tr', 1); -1 10505 for (i = 0; i < columnCount; i++) { -1 10506 token = state.push('td_open', 'td', 1); -1 10507 if (aligns[i]) { -1 10508 token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ]; -1 10509 } 10934 1051010935 -1 // first char is terminator -> empty text10936 -1 if (idx === 0) { return false; }-1 10511 token = state.push('inline', '', 0); -1 10512 token.content = columns[i] ? columns[i].trim() : ''; -1 10513 token.children = []; 10937 1051410938 -1 // no terminator -> text till end of string10939 -1 if (idx < 0) {10940 -1 if (!silent) { state.pending += state.src.slice(pos); }10941 -1 state.pos = state.src.length;10942 -1 return true;-1 10515 token = state.push('td_close', 'td', -1); -1 10516 } -1 10517 token = state.push('tr_close', 'tr', -1); 10943 10518 } -1 10519 token = state.push('tbody_close', 'tbody', -1); -1 10520 token = state.push('table_close', 'table', -1); 10944 1052110945 -1 if (!silent) { state.pending += state.src.slice(pos, pos + idx); }10946 -110947 -1 state.pos += idx;10948 -1-1 10522 tableLines[1] = tbodyLines[1] = nextLine; -1 10523 state.line = nextLine; 10949 10524 return true;10950 -1 };*/-1 10525 }; 10951 1052610952 -1 },{}],89:[function(require,module,exports){10953 -1 // Merge adjacent text nodes into one, and re-calculate all token levels10954 -1 //-1 10527 },{}],66:[function(require,module,exports){ 10955 10528 'use strict'; 10956 10529 10957 1053010958 -1 module.exports = function text_collapse(state) {10959 -1 var curr, last,10960 -1 level = 0,10961 -1 tokens = state.tokens,10962 -1 max = state.tokens.length;-1 10531 module.exports = function block(state) { -1 10532 var token; 10963 1053310964 -1 for (curr = last = 0; curr < max; curr++) {10965 -1 // re-calculate levels10966 -1 level += tokens[curr].nesting;10967 -1 tokens[curr].level = level;-1 10534 if (state.inlineMode) { -1 10535 token = new state.Token('inline', '', 0); -1 10536 token.content = state.src; -1 10537 token.map = [ 0, 1 ]; -1 10538 token.children = []; -1 10539 state.tokens.push(token); -1 10540 } else { -1 10541 state.md.block.parse(state.src, state.md, state.env, state.tokens); -1 10542 } -1 10543 }; 10968 1054410969 -1 if (tokens[curr].type === 'text' &&10970 -1 curr + 1 < max &&10971 -1 tokens[curr + 1].type === 'text') {-1 10545 },{}],67:[function(require,module,exports){ -1 10546 'use strict'; 10972 1054710973 -1 // collapse two adjacent text nodes10974 -1 tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;10975 -1 } else {10976 -1 if (curr !== last) { tokens[last] = tokens[curr]; }-1 10548 module.exports = function inline(state) { -1 10549 var tokens = state.tokens, tok, i, l; 10977 1055010978 -1 last++;-1 10551 // Parse inlines -1 10552 for (i = 0, l = tokens.length; i < l; i++) { -1 10553 tok = tokens[i]; -1 10554 if (tok.type === 'inline') { -1 10555 state.md.inline.parse(tok.content, state.md, state.env, tok.children); 10979 10556 } 10980 10557 }10981 -110982 -1 if (curr !== last) {10983 -1 tokens.length = last;10984 -1 }10985 10558 }; 10986 1055910987 -1 },{}],90:[function(require,module,exports){10988 -1 // Token class10989 -1-1 10560 },{}],68:[function(require,module,exports){ -1 10561 // Replace link-like texts with link nodes. -1 10562 // -1 10563 // Currently restricted by `md.validateLink()` to http/https/ftp -1 10564 // 10990 10565 'use strict'; 10991 10566 10992 1056710993 -1 /**10994 -1 * class Token10995 -1 **/-1 10568 var arrayReplaceAt = require('../common/utils').arrayReplaceAt; 10996 1056910997 -1 /**10998 -1 * new Token(type, tag, nesting)10999 -1 *11000 -1 * Create new token and fill passed properties.11001 -1 **/11002 -1 function Token(type, tag, nesting) {11003 -1 /**11004 -1 * Token#type -> String11005 -1 *11006 -1 * Type of the token (string, e.g. "paragraph_open")11007 -1 **/11008 -1 this.type = type;11009 1057011010 -1 /**11011 -1 * Token#tag -> String11012 -1 *11013 -1 * html tag name, e.g. "p"11014 -1 **/11015 -1 this.tag = tag;-1 10571 function isLinkOpen(str) { -1 10572 return /^<a[>\s]/i.test(str); -1 10573 } -1 10574 function isLinkClose(str) { -1 10575 return /^<\/a\s*>/i.test(str); -1 10576 } 11016 1057711017 -1 /**11018 -1 * Token#attrs -> Array11019 -1 *11020 -1 * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`11021 -1 **/11022 -1 this.attrs = null;11023 1057811024 -1 /**11025 -1 * Token#map -> Array11026 -1 *11027 -1 * Source map info. Format: `[ line_begin, line_end ]`11028 -1 **/11029 -1 this.map = null;-1 10579 module.exports = function linkify(state) { -1 10580 var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos, -1 10581 level, htmlLinkLevel, url, fullUrl, urlText, -1 10582 blockTokens = state.tokens, -1 10583 links; -1 10584 -1 10585 if (!state.md.options.linkify) { return; } -1 10586 -1 10587 for (j = 0, l = blockTokens.length; j < l; j++) { -1 10588 if (blockTokens[j].type !== 'inline' || -1 10589 !state.md.linkify.pretest(blockTokens[j].content)) { -1 10590 continue; -1 10591 } -1 10592 -1 10593 tokens = blockTokens[j].children; 11030 1059411031 -1 /**11032 -1 * Token#nesting -> Number11033 -1 *11034 -1 * Level change (number in {-1, 0, 1} set), where:11035 -1 *11036 -1 * - `1` means the tag is opening11037 -1 * - `0` means the tag is self-closing11038 -1 * - `-1` means the tag is closing11039 -1 **/11040 -1 this.nesting = nesting;-1 10595 htmlLinkLevel = 0; 11041 1059611042 -1 /**11043 -1 * Token#level -> Number11044 -1 *11045 -1 * nesting level, the same as `state.level`11046 -1 **/11047 -1 this.level = 0;-1 10597 // We scan from the end, to keep position when new tags added. -1 10598 // Use reversed logic in links start/end match -1 10599 for (i = tokens.length - 1; i >= 0; i--) { -1 10600 currentToken = tokens[i]; 11048 1060111049 -1 /**11050 -1 * Token#children -> Array11051 -1 *11052 -1 * An array of child nodes (inline and img tokens)11053 -1 **/11054 -1 this.children = null;-1 10602 // Skip content of markdown links -1 10603 if (currentToken.type === 'link_close') { -1 10604 i--; -1 10605 while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') { -1 10606 i--; -1 10607 } -1 10608 continue; -1 10609 } 11055 1061011056 -1 /**11057 -1 * Token#content -> String11058 -1 *11059 -1 * In a case of self-closing tag (code, html, fence, etc.),11060 -1 * it has contents of this tag.11061 -1 **/11062 -1 this.content = '';-1 10611 // Skip content of html tag links -1 10612 if (currentToken.type === 'html_inline') { -1 10613 if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) { -1 10614 htmlLinkLevel--; -1 10615 } -1 10616 if (isLinkClose(currentToken.content)) { -1 10617 htmlLinkLevel++; -1 10618 } -1 10619 } -1 10620 if (htmlLinkLevel > 0) { continue; } 11063 1062111064 -1 /**11065 -1 * Token#markup -> String11066 -1 *11067 -1 * '*' or '_' for emphasis, fence string for fence, etc.11068 -1 **/11069 -1 this.markup = '';-1 10622 if (currentToken.type === 'text' && state.md.linkify.test(currentToken.content)) { 11070 1062311071 -1 /**11072 -1 * Token#info -> String11073 -1 *11074 -1 * fence infostring11075 -1 **/11076 -1 this.info = '';-1 10624 text = currentToken.content; -1 10625 links = state.md.linkify.match(text); 11077 1062611078 -1 /**11079 -1 * Token#meta -> Object11080 -1 *11081 -1 * A place for plugins to store an arbitrary data11082 -1 **/11083 -1 this.meta = null;-1 10627 // Now split string to nodes -1 10628 nodes = []; -1 10629 level = currentToken.level; -1 10630 lastPos = 0; 11084 1063111085 -1 /**11086 -1 * Token#block -> Boolean11087 -1 *11088 -1 * True for block-level tokens, false for inline tokens.11089 -1 * Used in renderer to calculate line breaks11090 -1 **/11091 -1 this.block = false;-1 10632 for (ln = 0; ln < links.length; ln++) { 11092 1063311093 -1 /**11094 -1 * Token#hidden -> Boolean11095 -1 *11096 -1 * If it's true, ignore this element when rendering. Used for tight lists11097 -1 * to hide paragraphs.11098 -1 **/11099 -1 this.hidden = false;11100 -1 }-1 10634 url = links[ln].url; -1 10635 fullUrl = state.md.normalizeLink(url); -1 10636 if (!state.md.validateLink(fullUrl)) { continue; } 11101 10637 -1 10638 urlText = links[ln].text; 11102 1063911103 -1 /**11104 -1 * Token.attrIndex(name) -> Number11105 -1 *11106 -1 * Search attribute index by name.11107 -1 **/11108 -1 Token.prototype.attrIndex = function attrIndex(name) {11109 -1 var attrs, i, len;-1 10640 // Linkifier might send raw hostnames like "example.com", where url -1 10641 // starts with domain name. So we prepend http:// in those cases, -1 10642 // and remove it afterwards. -1 10643 // -1 10644 if (!links[ln].schema) { -1 10645 urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\/\//, ''); -1 10646 } else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) { -1 10647 urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, ''); -1 10648 } else { -1 10649 urlText = state.md.normalizeLinkText(urlText); -1 10650 } 11110 1065111111 -1 if (!this.attrs) { return -1; }-1 10652 pos = links[ln].index; 11112 1065311113 -1 attrs = this.attrs;-1 10654 if (pos > lastPos) { -1 10655 token = new state.Token('text', '', 0); -1 10656 token.content = text.slice(lastPos, pos); -1 10657 token.level = level; -1 10658 nodes.push(token); -1 10659 } 11114 1066011115 -1 for (i = 0, len = attrs.length; i < len; i++) {11116 -1 if (attrs[i][0] === name) { return i; }11117 -1 }11118 -1 return -1;11119 -1 };-1 10661 token = new state.Token('link_open', 'a', 1); -1 10662 token.attrs = [ [ 'href', fullUrl ] ]; -1 10663 token.level = level++; -1 10664 token.markup = 'linkify'; -1 10665 token.info = 'auto'; -1 10666 nodes.push(token); 11120 10667 -1 10668 token = new state.Token('text', '', 0); -1 10669 token.content = urlText; -1 10670 token.level = level; -1 10671 nodes.push(token); 11121 1067211122 -1 /**11123 -1 * Token.attrPush(attrData)11124 -1 *11125 -1 * Add `[ name, value ]` attribute to list. Init attrs if necessary11126 -1 **/11127 -1 Token.prototype.attrPush = function attrPush(attrData) {11128 -1 if (this.attrs) {11129 -1 this.attrs.push(attrData);11130 -1 } else {11131 -1 this.attrs = [ attrData ];-1 10673 token = new state.Token('link_close', 'a', -1); -1 10674 token.level = --level; -1 10675 token.markup = 'linkify'; -1 10676 token.info = 'auto'; -1 10677 nodes.push(token); -1 10678 -1 10679 lastPos = links[ln].lastIndex; -1 10680 } -1 10681 if (lastPos < text.length) { -1 10682 token = new state.Token('text', '', 0); -1 10683 token.content = text.slice(lastPos); -1 10684 token.level = level; -1 10685 nodes.push(token); -1 10686 } -1 10687 -1 10688 // replace current node -1 10689 blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes); -1 10690 } -1 10691 } 11132 10692 } 11133 10693 }; 11134 10694 -1 10695 },{"../common/utils":40}],69:[function(require,module,exports){ -1 10696 // Normalize input string 11135 1069711136 -1 /**11137 -1 * Token.attrSet(name, value)11138 -1 *11139 -1 * Set `name` attribute to `value`. Override old value if exists.11140 -1 **/11141 -1 Token.prototype.attrSet = function attrSet(name, value) {11142 -1 var idx = this.attrIndex(name),11143 -1 attrData = [ name, value ];-1 10698 'use strict'; 11144 1069911145 -1 if (idx < 0) {11146 -1 this.attrPush(attrData);11147 -1 } else {11148 -1 this.attrs[idx] = attrData;11149 -1 }11150 -1 };11151 10700 -1 10701 var NEWLINES_RE = /\r[\n\u0085]?|[\u2424\u2028\u0085]/g; -1 10702 var NULL_RE = /\u0000/g; 11152 1070311153 -1 /**11154 -1 * Token.attrGet(name)11155 -1 *11156 -1 * Get the value of attribute `name`, or null if it does not exist.11157 -1 **/11158 -1 Token.prototype.attrGet = function attrGet(name) {11159 -1 var idx = this.attrIndex(name), value = null;11160 -1 if (idx >= 0) {11161 -1 value = this.attrs[idx][1];11162 -1 }11163 -1 return value;11164 -1 };11165 10704 -1 10705 module.exports = function inline(state) { -1 10706 var str; 11166 1070711167 -1 /**11168 -1 * Token.attrJoin(name, value)11169 -1 *11170 -1 * Join value to existing attribute via space. Or create new attribute if not11171 -1 * exists. Useful to operate with token classes.11172 -1 **/11173 -1 Token.prototype.attrJoin = function attrJoin(name, value) {11174 -1 var idx = this.attrIndex(name);-1 10708 // Normalize newlines -1 10709 str = state.src.replace(NEWLINES_RE, '\n'); 11175 1071011176 -1 if (idx < 0) {11177 -1 this.attrPush([ name, value ]);11178 -1 } else {11179 -1 this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value;11180 -1 }-1 10711 // Replace NULL characters -1 10712 str = str.replace(NULL_RE, '\uFFFD'); -1 10713 -1 10714 state.src = str; 11181 10715 }; 11182 10716 -1 10717 },{}],70:[function(require,module,exports){ -1 10718 // Simple typographyc replacements -1 10719 // -1 10720 // (c) (C) → © -1 10721 // (tm) (TM) → ™ -1 10722 // (r) (R) → ® -1 10723 // +- → ± -1 10724 // (p) (P) -> § -1 10725 // ... → … (also ?.... → ?.., !.... → !..) -1 10726 // ???????? → ???, !!!!! → !!!, `,,` → `,` -1 10727 // -- → –, --- → — -1 10728 // -1 10729 'use strict'; -1 10730 -1 10731 // TODO: -1 10732 // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾ -1 10733 // - miltiplication 2 x 4 -> 2 × 4 11183 1073411184 -1 module.exports = Token;-1 10735 var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/; 11185 1073611186 -1 },{}],91:[function(require,module,exports){-1 10737 // Workaround for phantomjs - need regex without /g flag, -1 10738 // or root check will fail every second time -1 10739 var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i; 11187 1074011188 -1 'use strict';-1 10741 var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig; -1 10742 var SCOPED_ABBR = { -1 10743 c: '©', -1 10744 r: '®', -1 10745 p: '§', -1 10746 tm: '™' -1 10747 }; 11189 10748 -1 10749 function replaceFn(match, name) { -1 10750 return SCOPED_ABBR[name.toLowerCase()]; -1 10751 } 11190 1075211191 -1 /* eslint-disable no-bitwise */-1 10753 function replace_scoped(inlineTokens) { -1 10754 var i, token, inside_autolink = 0; 11192 1075511193 -1 var decodeCache = {};-1 10756 for (i = inlineTokens.length - 1; i >= 0; i--) { -1 10757 token = inlineTokens[i]; 11194 1075811195 -1 function getDecodeCache(exclude) {11196 -1 var i, ch, cache = decodeCache[exclude];11197 -1 if (cache) { return cache; }-1 10759 if (token.type === 'text' && !inside_autolink) { -1 10760 token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn); -1 10761 } 11198 1076211199 -1 cache = decodeCache[exclude] = [];-1 10763 if (token.type === 'link_open' && token.info === 'auto') { -1 10764 inside_autolink--; -1 10765 } 11200 1076611201 -1 for (i = 0; i < 128; i++) {11202 -1 ch = String.fromCharCode(i);11203 -1 cache.push(ch);-1 10767 if (token.type === 'link_close' && token.info === 'auto') { -1 10768 inside_autolink++; -1 10769 } 11204 10770 } -1 10771 } 11205 1077211206 -1 for (i = 0; i < exclude.length; i++) {11207 -1 ch = exclude.charCodeAt(i);11208 -1 cache[ch] = '%' + ('0' + ch.toString(16).toUpperCase()).slice(-2);11209 -1 }-1 10773 function replace_rare(inlineTokens) { -1 10774 var i, token, inside_autolink = 0; 11210 1077511211 -1 return cache;11212 -1 }-1 10776 for (i = inlineTokens.length - 1; i >= 0; i--) { -1 10777 token = inlineTokens[i]; 11213 10778 -1 10779 if (token.type === 'text' && !inside_autolink) { -1 10780 if (RARE_RE.test(token.content)) { -1 10781 token.content = token.content -1 10782 .replace(/\+-/g, '±') -1 10783 // .., ..., ....... -> … -1 10784 // but ?..... & !..... -> ?.. & !.. -1 10785 .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..') -1 10786 .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',') -1 10787 // em-dash -1 10788 .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2') -1 10789 // en-dash -1 10790 .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2') -1 10791 .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2'); -1 10792 } -1 10793 } 11214 1079411215 -1 // Decode percent-encoded string.11216 -1 //11217 -1 function decode(string, exclude) {11218 -1 var cache;-1 10795 if (token.type === 'link_open' && token.info === 'auto') { -1 10796 inside_autolink--; -1 10797 } 11219 1079811220 -1 if (typeof exclude !== 'string') {11221 -1 exclude = decode.defaultChars;-1 10799 if (token.type === 'link_close' && token.info === 'auto') { -1 10800 inside_autolink++; -1 10801 } 11222 10802 } -1 10803 } 11223 1080411224 -1 cache = getDecodeCache(exclude);11225 1080511226 -1 return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) {11227 -1 var i, l, b1, b2, b3, b4, chr,11228 -1 result = '';-1 10806 module.exports = function replace(state) { -1 10807 var blkIdx; 11229 1080811230 -1 for (i = 0, l = seq.length; i < l; i += 3) {11231 -1 b1 = parseInt(seq.slice(i + 1, i + 3), 16);-1 10809 if (!state.md.options.typographer) { return; } 11232 1081011233 -1 if (b1 < 0x80) {11234 -1 result += cache[b1];11235 -1 continue;11236 -1 }-1 10811 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) { 11237 1081211238 -1 if ((b1 & 0xE0) === 0xC0 && (i + 3 < l)) {11239 -1 // 110xxxxx 10xxxxxx11240 -1 b2 = parseInt(seq.slice(i + 4, i + 6), 16);-1 10813 if (state.tokens[blkIdx].type !== 'inline') { continue; } 11241 1081411242 -1 if ((b2 & 0xC0) === 0x80) {11243 -1 chr = ((b1 << 6) & 0x7C0) | (b2 & 0x3F);-1 10815 if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) { -1 10816 replace_scoped(state.tokens[blkIdx].children); -1 10817 } 11244 1081811245 -1 if (chr < 0x80) {11246 -1 result += '\ufffd\ufffd';11247 -1 } else {11248 -1 result += String.fromCharCode(chr);11249 -1 }-1 10819 if (RARE_RE.test(state.tokens[blkIdx].content)) { -1 10820 replace_rare(state.tokens[blkIdx].children); -1 10821 } 11250 1082211251 -1 i += 3;11252 -1 continue;11253 -1 }11254 -1 }-1 10823 } -1 10824 }; 11255 1082511256 -1 if ((b1 & 0xF0) === 0xE0 && (i + 6 < l)) {11257 -1 // 1110xxxx 10xxxxxx 10xxxxxx11258 -1 b2 = parseInt(seq.slice(i + 4, i + 6), 16);11259 -1 b3 = parseInt(seq.slice(i + 7, i + 9), 16);-1 10826 },{}],71:[function(require,module,exports){ -1 10827 // Convert straight quotation marks to typographic ones -1 10828 // -1 10829 'use strict'; 11260 1083011261 -1 if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {11262 -1 chr = ((b1 << 12) & 0xF000) | ((b2 << 6) & 0xFC0) | (b3 & 0x3F);11263 1083111264 -1 if (chr < 0x800 || (chr >= 0xD800 && chr <= 0xDFFF)) {11265 -1 result += '\ufffd\ufffd\ufffd';11266 -1 } else {11267 -1 result += String.fromCharCode(chr);11268 -1 }-1 10832 var isWhiteSpace = require('../common/utils').isWhiteSpace; -1 10833 var isPunctChar = require('../common/utils').isPunctChar; -1 10834 var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct; 11269 1083511270 -1 i += 6;11271 -1 continue;11272 -1 }11273 -1 }-1 10836 var QUOTE_TEST_RE = /['"]/; -1 10837 var QUOTE_RE = /['"]/g; -1 10838 var APOSTROPHE = '\u2019'; /* ’ */ 11274 1083911275 -1 if ((b1 & 0xF8) === 0xF0 && (i + 9 < l)) {11276 -1 // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx11277 -1 b2 = parseInt(seq.slice(i + 4, i + 6), 16);11278 -1 b3 = parseInt(seq.slice(i + 7, i + 9), 16);11279 -1 b4 = parseInt(seq.slice(i + 10, i + 12), 16);11280 1084011281 -1 if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80 && (b4 & 0xC0) === 0x80) {11282 -1 chr = ((b1 << 18) & 0x1C0000) | ((b2 << 12) & 0x3F000) | ((b3 << 6) & 0xFC0) | (b4 & 0x3F);-1 10841 function replaceAt(str, index, ch) { -1 10842 return str.substr(0, index) + ch + str.substr(index + 1); -1 10843 } 11283 1084411284 -1 if (chr < 0x10000 || chr > 0x10FFFF) {11285 -1 result += '\ufffd\ufffd\ufffd\ufffd';11286 -1 } else {11287 -1 chr -= 0x10000;11288 -1 result += String.fromCharCode(0xD800 + (chr >> 10), 0xDC00 + (chr & 0x3FF));11289 -1 }-1 10845 function process_inlines(tokens, state) { -1 10846 var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar, -1 10847 isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace, -1 10848 canOpen, canClose, j, isSingle, stack, openQuote, closeQuote; 11290 1084911291 -1 i += 9;11292 -1 continue;11293 -1 }11294 -1 }-1 10850 stack = []; 11295 1085111296 -1 result += '\ufffd';11297 -1 }-1 10852 for (i = 0; i < tokens.length; i++) { -1 10853 token = tokens[i]; 11298 1085411299 -1 return result;11300 -1 });11301 -1 }-1 10855 thisLevel = tokens[i].level; 11302 10856 -1 10857 for (j = stack.length - 1; j >= 0; j--) { -1 10858 if (stack[j].level <= thisLevel) { break; } -1 10859 } -1 10860 stack.length = j + 1; 11303 1086111304 -1 decode.defaultChars = ';/?:@&=+$,#';11305 -1 decode.componentChars = '';-1 10862 if (token.type !== 'text') { continue; } 11306 10863 -1 10864 text = token.content; -1 10865 pos = 0; -1 10866 max = text.length; 11307 1086711308 -1 module.exports = decode;-1 10868 /*eslint no-labels:0,block-scoped-var:0*/ -1 10869 OUTER: -1 10870 while (pos < max) { -1 10871 QUOTE_RE.lastIndex = pos; -1 10872 t = QUOTE_RE.exec(text); -1 10873 if (!t) { break; } 11309 1087411310 -1 },{}],92:[function(require,module,exports){-1 10875 canOpen = canClose = true; -1 10876 pos = t.index + 1; -1 10877 isSingle = (t[0] === "'"); 11311 1087811312 -1 'use strict';-1 10879 // Find previous character, -1 10880 // default to space if it's the beginning of the line -1 10881 // -1 10882 lastChar = 0x20; 11313 10883 -1 10884 if (t.index - 1 >= 0) { -1 10885 lastChar = text.charCodeAt(t.index - 1); -1 10886 } else { -1 10887 for (j = i - 1; j >= 0; j--) { -1 10888 if (tokens[j].type !== 'text') { continue; } 11314 1088911315 -1 var encodeCache = {};-1 10890 lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1); -1 10891 break; -1 10892 } -1 10893 } 11316 10894 -1 10895 // Find next character, -1 10896 // default to space if it's the end of the line -1 10897 // -1 10898 nextChar = 0x20; 11317 1089911318 -1 // Create a lookup array where anything but characters in `chars` string11319 -1 // and alphanumeric chars is percent-encoded.11320 -1 //11321 -1 function getEncodeCache(exclude) {11322 -1 var i, ch, cache = encodeCache[exclude];11323 -1 if (cache) { return cache; }-1 10900 if (pos < max) { -1 10901 nextChar = text.charCodeAt(pos); -1 10902 } else { -1 10903 for (j = i + 1; j < tokens.length; j++) { -1 10904 if (tokens[j].type !== 'text') { continue; } 11324 1090511325 -1 cache = encodeCache[exclude] = [];-1 10906 nextChar = tokens[j].content.charCodeAt(0); -1 10907 break; -1 10908 } -1 10909 } 11326 1091011327 -1 for (i = 0; i < 128; i++) {11328 -1 ch = String.fromCharCode(i);-1 10911 isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar)); -1 10912 isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar)); 11329 1091311330 -1 if (/^[0-9a-z]$/i.test(ch)) {11331 -1 // always allow unencoded alphanumeric characters11332 -1 cache.push(ch);11333 -1 } else {11334 -1 cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2));11335 -1 }11336 -1 }-1 10914 isLastWhiteSpace = isWhiteSpace(lastChar); -1 10915 isNextWhiteSpace = isWhiteSpace(nextChar); 11337 1091611338 -1 for (i = 0; i < exclude.length; i++) {11339 -1 cache[exclude.charCodeAt(i)] = exclude[i];11340 -1 }-1 10917 if (isNextWhiteSpace) { -1 10918 canOpen = false; -1 10919 } else if (isNextPunctChar) { -1 10920 if (!(isLastWhiteSpace || isLastPunctChar)) { -1 10921 canOpen = false; -1 10922 } -1 10923 } 11341 1092411342 -1 return cache;11343 -1 }-1 10925 if (isLastWhiteSpace) { -1 10926 canClose = false; -1 10927 } else if (isLastPunctChar) { -1 10928 if (!(isNextWhiteSpace || isNextPunctChar)) { -1 10929 canClose = false; -1 10930 } -1 10931 } 11344 10932 -1 10933 if (nextChar === 0x22 /* " */ && t[0] === '"') { -1 10934 if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) { -1 10935 // special case: 1"" - count first quote as an inch -1 10936 canClose = canOpen = false; -1 10937 } -1 10938 } 11345 1093911346 -1 // Encode unsafe characters with percent-encoding, skipping already11347 -1 // encoded sequences.11348 -1 //11349 -1 // - string - string to encode11350 -1 // - exclude - list of characters to ignore (in addition to a-zA-Z0-9)11351 -1 // - keepEscaped - don't encode '%' in a correct escape sequence (default: true)11352 -1 //11353 -1 function encode(string, exclude, keepEscaped) {11354 -1 var i, l, code, nextCode, cache,11355 -1 result = '';-1 10940 if (canOpen && canClose) { -1 10941 // treat this as the middle of the word -1 10942 canOpen = false; -1 10943 canClose = isNextPunctChar; -1 10944 } 11356 1094511357 -1 if (typeof exclude !== 'string') {11358 -1 // encode(string, keepEscaped)11359 -1 keepEscaped = exclude;11360 -1 exclude = encode.defaultChars;11361 -1 }-1 10946 if (!canOpen && !canClose) { -1 10947 // middle of word -1 10948 if (isSingle) { -1 10949 token.content = replaceAt(token.content, t.index, APOSTROPHE); -1 10950 } -1 10951 continue; -1 10952 } 11362 1095311363 -1 if (typeof keepEscaped === 'undefined') {11364 -1 keepEscaped = true;11365 -1 }-1 10954 if (canClose) { -1 10955 // this could be a closing quote, rewind the stack to get a match -1 10956 for (j = stack.length - 1; j >= 0; j--) { -1 10957 item = stack[j]; -1 10958 if (stack[j].level < thisLevel) { break; } -1 10959 if (item.single === isSingle && stack[j].level === thisLevel) { -1 10960 item = stack[j]; 11366 1096111367 -1 cache = getEncodeCache(exclude);-1 10962 if (isSingle) { -1 10963 openQuote = state.md.options.quotes[2]; -1 10964 closeQuote = state.md.options.quotes[3]; -1 10965 } else { -1 10966 openQuote = state.md.options.quotes[0]; -1 10967 closeQuote = state.md.options.quotes[1]; -1 10968 } 11368 1096911369 -1 for (i = 0, l = string.length; i < l; i++) {11370 -1 code = string.charCodeAt(i);-1 10970 // replace token.content *before* tokens[item.token].content, -1 10971 // because, if they are pointing at the same token, replaceAt -1 10972 // could mess up indices when quote length != 1 -1 10973 token.content = replaceAt(token.content, t.index, closeQuote); -1 10974 tokens[item.token].content = replaceAt( -1 10975 tokens[item.token].content, item.pos, openQuote); 11371 1097611372 -1 if (keepEscaped && code === 0x25 /* % */ && i + 2 < l) {11373 -1 if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) {11374 -1 result += string.slice(i, i + 3);11375 -1 i += 2;11376 -1 continue;11377 -1 }11378 -1 }-1 10977 pos += closeQuote.length - 1; -1 10978 if (item.token === i) { pos += openQuote.length - 1; } 11379 1097911380 -1 if (code < 128) {11381 -1 result += cache[code];11382 -1 continue;11383 -1 }-1 10980 text = token.content; -1 10981 max = text.length; 11384 1098211385 -1 if (code >= 0xD800 && code <= 0xDFFF) {11386 -1 if (code >= 0xD800 && code <= 0xDBFF && i + 1 < l) {11387 -1 nextCode = string.charCodeAt(i + 1);11388 -1 if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {11389 -1 result += encodeURIComponent(string[i] + string[i + 1]);11390 -1 i++;11391 -1 continue;-1 10983 stack.length = j; -1 10984 continue OUTER; -1 10985 } 11392 10986 } 11393 10987 }11394 -1 result += '%EF%BF%BD';11395 -1 continue;11396 -1 }11397 1098811398 -1 result += encodeURIComponent(string[i]);-1 10989 if (canOpen) { -1 10990 stack.push({ -1 10991 token: i, -1 10992 pos: t.index, -1 10993 single: isSingle, -1 10994 level: thisLevel -1 10995 }); -1 10996 } else if (canClose && isSingle) { -1 10997 token.content = replaceAt(token.content, t.index, APOSTROPHE); -1 10998 } -1 10999 } 11399 11000 }11400 -111401 -1 return result;11402 11001 } 11403 1100211404 -1 encode.defaultChars = ";/?:@&=+$,-_.!~*'()#";11405 -1 encode.componentChars = "-_.!~*'()";11406 11003 -1 11004 module.exports = function smartquotes(state) { -1 11005 /*eslint max-depth:0*/ -1 11006 var blkIdx; 11407 1100711408 -1 module.exports = encode;-1 11008 if (!state.md.options.typographer) { return; } 11409 1100911410 -1 },{}],93:[function(require,module,exports){-1 11010 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) { -1 11011 -1 11012 if (state.tokens[blkIdx].type !== 'inline' || -1 11013 !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) { -1 11014 continue; -1 11015 } 11411 11016 -1 11017 process_inlines(state.tokens[blkIdx].children, state); -1 11018 } -1 11019 }; -1 11020 -1 11021 },{"../common/utils":40}],72:[function(require,module,exports){ -1 11022 // Core state object -1 11023 // 11412 11024 'use strict'; 11413 11025 -1 11026 var Token = require('../token'); 11414 1102711415 -1 module.exports = function format(url) {11416 -1 var result = '';11417 1102811418 -1 result += url.protocol || '';11419 -1 result += url.slashes ? '//' : '';11420 -1 result += url.auth ? url.auth + '@' : '';-1 11029 function StateCore(src, md, env) { -1 11030 this.src = src; -1 11031 this.env = env; -1 11032 this.tokens = []; -1 11033 this.inlineMode = false; -1 11034 this.md = md; // link to parser instance -1 11035 } 11421 1103611422 -1 if (url.hostname && url.hostname.indexOf(':') !== -1) {11423 -1 // ipv6 address11424 -1 result += '[' + url.hostname + ']';11425 -1 } else {11426 -1 result += url.hostname || '';11427 -1 }-1 11037 // re-export Token class to use in core rules -1 11038 StateCore.prototype.Token = Token; 11428 1103911429 -1 result += url.port ? ':' + url.port : '';11430 -1 result += url.pathname || '';11431 -1 result += url.search || '';11432 -1 result += url.hash || '';11433 1104011434 -1 return result;11435 -1 };-1 11041 module.exports = StateCore; 11436 1104211437 -1 },{}],94:[function(require,module,exports){11438 -1 'use strict';-1 11043 },{"../token":87}],73:[function(require,module,exports){ -1 11044 // Process autolinks '<protocol:...>' 11439 11045 -1 11046 'use strict'; 11440 1104711441 -1 module.exports.encode = require('./encode');11442 -1 module.exports.decode = require('./decode');11443 -1 module.exports.format = require('./format');11444 -1 module.exports.parse = require('./parse');11445 1104811446 -1 },{"./decode":91,"./encode":92,"./format":93,"./parse":95}],95:[function(require,module,exports){11447 -1 // Copyright Joyent, Inc. and other Node contributors.11448 -1 //11449 -1 // Permission is hereby granted, free of charge, to any person obtaining a11450 -1 // copy of this software and associated documentation files (the11451 -1 // "Software"), to deal in the Software without restriction, including11452 -1 // without limitation the rights to use, copy, modify, merge, publish,11453 -1 // distribute, sublicense, and/or sell copies of the Software, and to permit11454 -1 // persons to whom the Software is furnished to do so, subject to the11455 -1 // following conditions:11456 -1 //11457 -1 // The above copyright notice and this permission notice shall be included11458 -1 // in all copies or substantial portions of the Software.11459 -1 //11460 -1 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS11461 -1 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF11462 -1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN11463 -1 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,11464 -1 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR11465 -1 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE11466 -1 // USE OR OTHER DEALINGS IN THE SOFTWARE.-1 11049 /*eslint max-len:0*/ -1 11050 var EMAIL_RE = /^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/; -1 11051 var AUTOLINK_RE = /^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/; 11467 1105211468 -1 'use strict';11469 1105311470 -1 //11471 -1 // Changes from joyent/node:11472 -1 //11473 -1 // 1. No leading slash in paths,11474 -1 // e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/`11475 -1 //11476 -1 // 2. Backslashes are not replaced with slashes,11477 -1 // so `http:\\example.org\` is treated like a relative path11478 -1 //11479 -1 // 3. Trailing colon is treated like a part of the path,11480 -1 // i.e. in `http://example.org:foo` pathname is `:foo`11481 -1 //11482 -1 // 4. Nothing is URL-encoded in the resulting object,11483 -1 // (in joyent/node some chars in auth and paths are encoded)11484 -1 //11485 -1 // 5. `url.parse()` does not have `parseQueryString` argument11486 -1 //11487 -1 // 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,11488 -1 // which can be constructed using other parts of the url.11489 -1 //-1 11054 module.exports = function autolink(state, silent) { -1 11055 var tail, linkMatch, emailMatch, url, fullUrl, token, -1 11056 pos = state.pos; 11490 11057 -1 11058 if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; } 11491 1105911492 -1 function Url() {11493 -1 this.protocol = null;11494 -1 this.slashes = null;11495 -1 this.auth = null;11496 -1 this.port = null;11497 -1 this.hostname = null;11498 -1 this.hash = null;11499 -1 this.search = null;11500 -1 this.pathname = null;11501 -1 }-1 11060 tail = state.src.slice(pos); 11502 1106111503 -1 // Reference: RFC 3986, RFC 1808, RFC 2396-1 11062 if (tail.indexOf('>') < 0) { return false; } 11504 1106311505 -1 // define these here so at least they only have to be11506 -1 // compiled once on the first module load.11507 -1 var protocolPattern = /^([a-z0-9.+-]+:)/i,11508 -1 portPattern = /:[0-9]*$/,-1 11064 if (AUTOLINK_RE.test(tail)) { -1 11065 linkMatch = tail.match(AUTOLINK_RE); 11509 1106611510 -1 // Special case for a simple path URL11511 -1 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,-1 11067 url = linkMatch[0].slice(1, -1); -1 11068 fullUrl = state.md.normalizeLink(url); -1 11069 if (!state.md.validateLink(fullUrl)) { return false; } 11512 1107011513 -1 // RFC 2396: characters reserved for delimiting URLs.11514 -1 // We actually just auto-escape these.11515 -1 delims = [ '<', '>', '"', '`', ' ', '\r', '\n', '\t' ],-1 11071 if (!silent) { -1 11072 token = state.push('link_open', 'a', 1); -1 11073 token.attrs = [ [ 'href', fullUrl ] ]; -1 11074 token.markup = 'autolink'; -1 11075 token.info = 'auto'; 11516 1107611517 -1 // RFC 2396: characters not allowed for various reasons.11518 -1 unwise = [ '{', '}', '|', '\\', '^', '`' ].concat(delims),-1 11077 token = state.push('text', '', 0); -1 11078 token.content = state.md.normalizeLinkText(url); 11519 1107911520 -1 // Allowed by RFCs, but cause of XSS attacks. Always escape these.11521 -1 autoEscape = [ '\'' ].concat(unwise),11522 -1 // Characters that are never ever allowed in a hostname.11523 -1 // Note that any invalid chars are also handled, but these11524 -1 // are the ones that are *expected* to be seen, so we fast-path11525 -1 // them.11526 -1 nonHostChars = [ '%', '/', '?', ';', '#' ].concat(autoEscape),11527 -1 hostEndingChars = [ '/', '?', '#' ],11528 -1 hostnameMaxLen = 255,11529 -1 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,11530 -1 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,11531 -1 // protocols that can allow "unsafe" and "unwise" chars.11532 -1 /* eslint-disable no-script-url */11533 -1 // protocols that never have a hostname.11534 -1 hostlessProtocol = {11535 -1 'javascript': true,11536 -1 'javascript:': true11537 -1 },11538 -1 // protocols that always contain a // bit.11539 -1 slashedProtocol = {11540 -1 'http': true,11541 -1 'https': true,11542 -1 'ftp': true,11543 -1 'gopher': true,11544 -1 'file': true,11545 -1 'http:': true,11546 -1 'https:': true,11547 -1 'ftp:': true,11548 -1 'gopher:': true,11549 -1 'file:': true11550 -1 };11551 -1 /* eslint-enable no-script-url */-1 11080 token = state.push('link_close', 'a', -1); -1 11081 token.markup = 'autolink'; -1 11082 token.info = 'auto'; -1 11083 } 11552 1108411553 -1 function urlParse(url, slashesDenoteHost) {11554 -1 if (url && url instanceof Url) { return url; }-1 11085 state.pos += linkMatch[0].length; -1 11086 return true; -1 11087 } 11555 1108811556 -1 var u = new Url();11557 -1 u.parse(url, slashesDenoteHost);11558 -1 return u;11559 -1 }-1 11089 if (EMAIL_RE.test(tail)) { -1 11090 emailMatch = tail.match(EMAIL_RE); 11560 1109111561 -1 Url.prototype.parse = function(url, slashesDenoteHost) {11562 -1 var i, l, lowerProto, hec, slashes,11563 -1 rest = url;-1 11092 url = emailMatch[0].slice(1, -1); -1 11093 fullUrl = state.md.normalizeLink('mailto:' + url); -1 11094 if (!state.md.validateLink(fullUrl)) { return false; } 11564 1109511565 -1 // trim before proceeding.11566 -1 // This is to support parse stuff like " http://foo.com \n"11567 -1 rest = rest.trim();-1 11096 if (!silent) { -1 11097 token = state.push('link_open', 'a', 1); -1 11098 token.attrs = [ [ 'href', fullUrl ] ]; -1 11099 token.markup = 'autolink'; -1 11100 token.info = 'auto'; 11568 1110111569 -1 if (!slashesDenoteHost && url.split('#').length === 1) {11570 -1 // Try fast path regexp11571 -1 var simplePath = simplePathPattern.exec(rest);11572 -1 if (simplePath) {11573 -1 this.pathname = simplePath[1];11574 -1 if (simplePath[2]) {11575 -1 this.search = simplePath[2];11576 -1 }11577 -1 return this;-1 11102 token = state.push('text', '', 0); -1 11103 token.content = state.md.normalizeLinkText(url); -1 11104 -1 11105 token = state.push('link_close', 'a', -1); -1 11106 token.markup = 'autolink'; -1 11107 token.info = 'auto'; 11578 11108 }11579 -1 }11580 1110911581 -1 var proto = protocolPattern.exec(rest);11582 -1 if (proto) {11583 -1 proto = proto[0];11584 -1 lowerProto = proto.toLowerCase();11585 -1 this.protocol = proto;11586 -1 rest = rest.substr(proto.length);-1 11110 state.pos += emailMatch[0].length; -1 11111 return true; 11587 11112 } 11588 1111311589 -1 // figure out if it's got a host11590 -1 // user@server is *always* interpreted as a hostname, and url11591 -1 // resolution will treat //foo/bar as host=foo,path=bar because that's11592 -1 // how the browser resolves relative URLs.11593 -1 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {11594 -1 slashes = rest.substr(0, 2) === '//';11595 -1 if (slashes && !(proto && hostlessProtocol[proto])) {11596 -1 rest = rest.substr(2);11597 -1 this.slashes = true;11598 -1 }11599 -1 }-1 11114 return false; -1 11115 }; 11600 1111611601 -1 if (!hostlessProtocol[proto] &&11602 -1 (slashes || (proto && !slashedProtocol[proto]))) {-1 11117 },{}],74:[function(require,module,exports){ -1 11118 // Parse backticks 11603 1111911604 -1 // there's a hostname.11605 -1 // the first instance of /, ?, ;, or # ends the host.11606 -1 //11607 -1 // If there is an @ in the hostname, then non-host chars *are* allowed11608 -1 // to the left of the last @ sign, unless some host-ending character11609 -1 // comes *before* the @-sign.11610 -1 // URLs are obnoxious.11611 -1 //11612 -1 // ex:11613 -1 // http://a@b@c/ => user:a@b host:c11614 -1 // http://a@b?@c => user:a host:c path:/?@c-1 11120 'use strict'; 11615 1112111616 -1 // v0.12 TODO(isaacs): This is not quite how Chrome does things.11617 -1 // Review our test case against browsers more comprehensively.-1 11122 module.exports = function backtick(state, silent) { -1 11123 var start, max, marker, matchStart, matchEnd, token, -1 11124 pos = state.pos, -1 11125 ch = state.src.charCodeAt(pos); 11618 1112611619 -1 // find the first instance of any hostEndingChars11620 -1 var hostEnd = -1;11621 -1 for (i = 0; i < hostEndingChars.length; i++) {11622 -1 hec = rest.indexOf(hostEndingChars[i]);11623 -1 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {11624 -1 hostEnd = hec;11625 -1 }11626 -1 }-1 11127 if (ch !== 0x60/* ` */) { return false; } 11627 1112811628 -1 // at this point, either we have an explicit point where the11629 -1 // auth portion cannot go past, or the last @ char is the decider.11630 -1 var auth, atSign;11631 -1 if (hostEnd === -1) {11632 -1 // atSign can be anywhere.11633 -1 atSign = rest.lastIndexOf('@');11634 -1 } else {11635 -1 // atSign must be in auth portion.11636 -1 // http://a@b/c@d => host:b auth:a path:/c@d11637 -1 atSign = rest.lastIndexOf('@', hostEnd);11638 -1 }-1 11129 start = pos; -1 11130 pos++; -1 11131 max = state.posMax; 11639 1113211640 -1 // Now we have a portion which is definitely the auth.11641 -1 // Pull that off.11642 -1 if (atSign !== -1) {11643 -1 auth = rest.slice(0, atSign);11644 -1 rest = rest.slice(atSign + 1);11645 -1 this.auth = auth;11646 -1 }-1 11133 while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; } 11647 1113411648 -1 // the host is the remaining to the left of the first non-host char11649 -1 hostEnd = -1;11650 -1 for (i = 0; i < nonHostChars.length; i++) {11651 -1 hec = rest.indexOf(nonHostChars[i]);11652 -1 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {11653 -1 hostEnd = hec;-1 11135 marker = state.src.slice(start, pos); -1 11136 -1 11137 matchStart = matchEnd = pos; -1 11138 -1 11139 while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) { -1 11140 matchEnd = matchStart + 1; -1 11141 -1 11142 while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; } -1 11143 -1 11144 if (matchEnd - matchStart === marker.length) { -1 11145 if (!silent) { -1 11146 token = state.push('code_inline', 'code', 0); -1 11147 token.markup = marker; -1 11148 token.content = state.src.slice(pos, matchStart) -1 11149 .replace(/[ \n]+/g, ' ') -1 11150 .trim(); 11654 11151 } -1 11152 state.pos = matchEnd; -1 11153 return true; 11655 11154 }11656 -1 // if we still have not hit it, then the entire thing is a host.11657 -1 if (hostEnd === -1) {11658 -1 hostEnd = rest.length;11659 -1 }-1 11155 } 11660 1115611661 -1 if (rest[hostEnd - 1] === ':') { hostEnd--; }11662 -1 var host = rest.slice(0, hostEnd);11663 -1 rest = rest.slice(hostEnd);-1 11157 if (!silent) { state.pending += marker; } -1 11158 state.pos += marker.length; -1 11159 return true; -1 11160 }; 11664 1116111665 -1 // pull out port.11666 -1 this.parseHost(host);-1 11162 },{}],75:[function(require,module,exports){ -1 11163 // For each opening emphasis-like marker find a matching closing one -1 11164 // -1 11165 'use strict'; 11667 1116611668 -1 // we've indicated that there is a hostname,11669 -1 // so even if it's empty, it has to be present.11670 -1 this.hostname = this.hostname || '';11671 1116711672 -1 // if hostname begins with [ and ends with ]11673 -1 // assume that it's an IPv6 address.11674 -1 var ipv6Hostname = this.hostname[0] === '[' &&11675 -1 this.hostname[this.hostname.length - 1] === ']';-1 11168 module.exports = function link_pairs(state) { -1 11169 var i, j, lastDelim, currDelim, -1 11170 delimiters = state.delimiters, -1 11171 max = state.delimiters.length; 11676 1117211677 -1 // validate a little.11678 -1 if (!ipv6Hostname) {11679 -1 var hostparts = this.hostname.split(/\./);11680 -1 for (i = 0, l = hostparts.length; i < l; i++) {11681 -1 var part = hostparts[i];11682 -1 if (!part) { continue; }11683 -1 if (!part.match(hostnamePartPattern)) {11684 -1 var newpart = '';11685 -1 for (var j = 0, k = part.length; j < k; j++) {11686 -1 if (part.charCodeAt(j) > 127) {11687 -1 // we replace non-ASCII char with a temporary placeholder11688 -1 // we need this to make sure size of hostname is not11689 -1 // broken by replacing non-ASCII by nothing11690 -1 newpart += 'x';11691 -1 } else {11692 -1 newpart += part[j];11693 -1 }11694 -1 }11695 -1 // we test again with ASCII char only11696 -1 if (!newpart.match(hostnamePartPattern)) {11697 -1 var validParts = hostparts.slice(0, i);11698 -1 var notHost = hostparts.slice(i + 1);11699 -1 var bit = part.match(hostnamePartStart);11700 -1 if (bit) {11701 -1 validParts.push(bit[1]);11702 -1 notHost.unshift(bit[2]);11703 -1 }11704 -1 if (notHost.length) {11705 -1 rest = notHost.join('.') + rest;11706 -1 }11707 -1 this.hostname = validParts.join('.');11708 -1 break;11709 -1 }11710 -1 }11711 -1 }11712 -1 }-1 11173 for (i = 0; i < max; i++) { -1 11174 lastDelim = delimiters[i]; 11713 1117511714 -1 if (this.hostname.length > hostnameMaxLen) {11715 -1 this.hostname = '';11716 -1 }-1 11176 if (!lastDelim.close) { continue; } 11717 1117711718 -1 // strip [ and ] from the hostname11719 -1 // the host field still retains them, though11720 -1 if (ipv6Hostname) {11721 -1 this.hostname = this.hostname.substr(1, this.hostname.length - 2);11722 -1 }11723 -1 }-1 11178 j = i - lastDelim.jump - 1; 11724 1117911725 -1 // chop off from the tail first.11726 -1 var hash = rest.indexOf('#');11727 -1 if (hash !== -1) {11728 -1 // got a fragment string.11729 -1 this.hash = rest.substr(hash);11730 -1 rest = rest.slice(0, hash);11731 -1 }11732 -1 var qm = rest.indexOf('?');11733 -1 if (qm !== -1) {11734 -1 this.search = rest.substr(qm);11735 -1 rest = rest.slice(0, qm);11736 -1 }11737 -1 if (rest) { this.pathname = rest; }11738 -1 if (slashedProtocol[lowerProto] &&11739 -1 this.hostname && !this.pathname) {11740 -1 this.pathname = '';11741 -1 }-1 11180 while (j >= 0) { -1 11181 currDelim = delimiters[j]; 11742 1118211743 -1 return this;11744 -1 };-1 11183 if (currDelim.open && -1 11184 currDelim.marker === lastDelim.marker && -1 11185 currDelim.end < 0 && -1 11186 currDelim.level === lastDelim.level) { 11745 1118711746 -1 Url.prototype.parseHost = function(host) {11747 -1 var port = portPattern.exec(host);11748 -1 if (port) {11749 -1 port = port[0];11750 -1 if (port !== ':') {11751 -1 this.port = port.substr(1);-1 11188 lastDelim.jump = i - j; -1 11189 lastDelim.open = false; -1 11190 currDelim.end = i; -1 11191 currDelim.jump = 0; -1 11192 break; -1 11193 } -1 11194 -1 11195 j -= currDelim.jump + 1; 11752 11196 }11753 -1 host = host.substr(0, host.length - port.length);11754 11197 }11755 -1 if (host) { this.hostname = host; }11756 11198 }; 11757 1119911758 -1 module.exports = urlParse;11759 -111760 -1 },{}],96:[function(require,module,exports){11761 -1 /**11762 -1 * Helpers.11763 -1 */-1 11200 },{}],76:[function(require,module,exports){ -1 11201 // Process *this* and _that_ -1 11202 // -1 11203 'use strict'; 11764 1120411765 -1 var s = 1000;11766 -1 var m = s * 60;11767 -1 var h = m * 60;11768 -1 var d = h * 24;11769 -1 var y = d * 365.25;11770 1120511771 -1 /**11772 -1 * Parse or format the given `val`.11773 -1 *11774 -1 * Options:11775 -1 *11776 -1 * - `long` verbose formatting [false]11777 -1 *11778 -1 * @param {String|Number} val11779 -1 * @param {Object} options11780 -1 * @return {String|Number}11781 -1 * @api public11782 -1 */-1 11206 // Insert each marker as a separate text token, and add it to delimiter list -1 11207 // -1 11208 module.exports.tokenize = function emphasis(state, silent) { -1 11209 var i, scanned, token, -1 11210 start = state.pos, -1 11211 marker = state.src.charCodeAt(start); 11783 1121211784 -1 module.exports = function(val, options){11785 -1 options = options || {};11786 -1 if ('string' == typeof val) return parse(val);11787 -1 return options.long11788 -1 ? long(val)11789 -1 : short(val);11790 -1 };-1 11213 if (silent) { return false; } 11791 1121411792 -1 /**11793 -1 * Parse the given `str` and return milliseconds.11794 -1 *11795 -1 * @param {String} str11796 -1 * @return {Number}11797 -1 * @api private11798 -1 */-1 11215 if (marker !== 0x5F /* _ */ && marker !== 0x2A /* * */) { return false; } 11799 1121611800 -1 function parse(str) {11801 -1 str = '' + str;11802 -1 if (str.length > 10000) return;11803 -1 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);11804 -1 if (!match) return;11805 -1 var n = parseFloat(match[1]);11806 -1 var type = (match[2] || 'ms').toLowerCase();11807 -1 switch (type) {11808 -1 case 'years':11809 -1 case 'year':11810 -1 case 'yrs':11811 -1 case 'yr':11812 -1 case 'y':11813 -1 return n * y;11814 -1 case 'days':11815 -1 case 'day':11816 -1 case 'd':11817 -1 return n * d;11818 -1 case 'hours':11819 -1 case 'hour':11820 -1 case 'hrs':11821 -1 case 'hr':11822 -1 case 'h':11823 -1 return n * h;11824 -1 case 'minutes':11825 -1 case 'minute':11826 -1 case 'mins':11827 -1 case 'min':11828 -1 case 'm':11829 -1 return n * m;11830 -1 case 'seconds':11831 -1 case 'second':11832 -1 case 'secs':11833 -1 case 'sec':11834 -1 case 's':11835 -1 return n * s;11836 -1 case 'milliseconds':11837 -1 case 'millisecond':11838 -1 case 'msecs':11839 -1 case 'msec':11840 -1 case 'ms':11841 -1 return n;11842 -1 }11843 -1 }-1 11217 scanned = state.scanDelims(state.pos, marker === 0x2A); 11844 1121811845 -1 /**11846 -1 * Short format for `ms`.11847 -1 *11848 -1 * @param {Number} ms11849 -1 * @return {String}11850 -1 * @api private11851 -1 */-1 11219 for (i = 0; i < scanned.length; i++) { -1 11220 token = state.push('text', '', 0); -1 11221 token.content = String.fromCharCode(marker); 11852 1122211853 -1 function short(ms) {11854 -1 if (ms >= d) return Math.round(ms / d) + 'd';11855 -1 if (ms >= h) return Math.round(ms / h) + 'h';11856 -1 if (ms >= m) return Math.round(ms / m) + 'm';11857 -1 if (ms >= s) return Math.round(ms / s) + 's';11858 -1 return ms + 'ms';11859 -1 }-1 11223 state.delimiters.push({ -1 11224 // Char code of the starting marker (number). -1 11225 // -1 11226 marker: marker, 11860 1122711861 -1 /**11862 -1 * Long format for `ms`.11863 -1 *11864 -1 * @param {Number} ms11865 -1 * @return {String}11866 -1 * @api private11867 -1 */-1 11228 // An amount of characters before this one that's equivalent to -1 11229 // current one. In plain English: if this delimiter does not open -1 11230 // an emphasis, neither do previous `jump` characters. -1 11231 // -1 11232 // Used to skip sequences like "*****" in one step, for 1st asterisk -1 11233 // value will be 0, for 2nd it's 1 and so on. -1 11234 // -1 11235 jump: i, 11868 1123611869 -1 function long(ms) {11870 -1 return plural(ms, d, 'day')11871 -1 || plural(ms, h, 'hour')11872 -1 || plural(ms, m, 'minute')11873 -1 || plural(ms, s, 'second')11874 -1 || ms + ' ms';11875 -1 }-1 11237 // A position of the token this delimiter corresponds to. -1 11238 // -1 11239 token: state.tokens.length - 1, 11876 1124011877 -1 /**11878 -1 * Pluralization helper.11879 -1 */-1 11241 // Token level. -1 11242 // -1 11243 level: state.level, 11880 1124411881 -1 function plural(ms, n, name) {11882 -1 if (ms < n) return;11883 -1 if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;11884 -1 return Math.ceil(ms / n) + ' ' + name + 's';11885 -1 }-1 11245 // If this delimiter is matched as a valid opener, `end` will be -1 11246 // equal to its position, otherwise it's `-1`. -1 11247 // -1 11248 end: -1, 11886 1124911887 -1 },{}],97:[function(require,module,exports){11888 -1 (function (global){11889 -1 /**11890 -1 * JSON parse.11891 -1 *11892 -1 * @see Based on jQuery#parseJSON (MIT) and JSON211893 -1 * @api private11894 -1 */-1 11250 // Boolean flags that determine if this delimiter could open or close -1 11251 // an emphasis. -1 11252 // -1 11253 open: scanned.can_open, -1 11254 close: scanned.can_close -1 11255 }); -1 11256 } 11895 1125711896 -1 var rvalidchars = /^[\],:{}\s]*$/;11897 -1 var rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g;11898 -1 var rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;11899 -1 var rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g;11900 -1 var rtrimLeft = /^\s+/;11901 -1 var rtrimRight = /\s+$/;-1 11258 state.pos += scanned.length; 11902 1125911903 -1 module.exports = function parsejson(data) {11904 -1 if ('string' != typeof data || !data) {11905 -1 return null;11906 -1 }-1 11260 return true; -1 11261 }; 11907 1126211908 -1 data = data.replace(rtrimLeft, '').replace(rtrimRight, '');11909 1126311910 -1 // Attempt to parse using the native JSON parser first11911 -1 if (global.JSON && JSON.parse) {11912 -1 return JSON.parse(data);11913 -1 }-1 11264 // Walk through delimiter list and replace text tokens with tags -1 11265 // -1 11266 module.exports.postProcess = function emphasis(state) { -1 11267 var i, -1 11268 startDelim, -1 11269 endDelim, -1 11270 token, -1 11271 ch, -1 11272 isStrong, -1 11273 delimiters = state.delimiters, -1 11274 max = state.delimiters.length; 11914 1127511915 -1 if (rvalidchars.test(data.replace(rvalidescape, '@')11916 -1 .replace(rvalidtokens, ']')11917 -1 .replace(rvalidbraces, ''))) {11918 -1 return (new Function('return ' + data))();11919 -1 }11920 -1 };11921 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})11922 -1 },{}],98:[function(require,module,exports){11923 -1 /**11924 -1 * Compiles a querystring11925 -1 * Returns string representation of the object11926 -1 *11927 -1 * @param {Object}11928 -1 * @api private11929 -1 */-1 11276 for (i = 0; i < max; i++) { -1 11277 startDelim = delimiters[i]; 11930 1127811931 -1 exports.encode = function (obj) {11932 -1 var str = '';-1 11279 if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) { -1 11280 continue; -1 11281 } 11933 1128211934 -1 for (var i in obj) {11935 -1 if (obj.hasOwnProperty(i)) {11936 -1 if (str.length) str += '&';11937 -1 str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);-1 11283 // Process only opening markers -1 11284 if (startDelim.end === -1) { -1 11285 continue; 11938 11286 }11939 -1 }11940 1128711941 -1 return str;11942 -1 };-1 11288 endDelim = delimiters[startDelim.end]; 11943 1128911944 -1 /**11945 -1 * Parses a simple querystring into an object11946 -1 *11947 -1 * @param {String} qs11948 -1 * @api private11949 -1 */-1 11290 // If the next delimiter has the same marker and is adjacent to this one, -1 11291 // merge those into one strong delimiter. -1 11292 // -1 11293 // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>` -1 11294 // -1 11295 isStrong = i + 1 < max && -1 11296 delimiters[i + 1].end === startDelim.end - 1 && -1 11297 delimiters[i + 1].token === startDelim.token + 1 && -1 11298 delimiters[startDelim.end - 1].token === endDelim.token - 1 && -1 11299 delimiters[i + 1].marker === startDelim.marker; -1 11300 -1 11301 ch = String.fromCharCode(startDelim.marker); 11950 1130211951 -1 exports.decode = function(qs){11952 -1 var qry = {};11953 -1 var pairs = qs.split('&');11954 -1 for (var i = 0, l = pairs.length; i < l; i++) {11955 -1 var pair = pairs[i].split('=');11956 -1 qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);-1 11303 token = state.tokens[startDelim.token]; -1 11304 token.type = isStrong ? 'strong_open' : 'em_open'; -1 11305 token.tag = isStrong ? 'strong' : 'em'; -1 11306 token.nesting = 1; -1 11307 token.markup = isStrong ? ch + ch : ch; -1 11308 token.content = ''; -1 11309 -1 11310 token = state.tokens[endDelim.token]; -1 11311 token.type = isStrong ? 'strong_close' : 'em_close'; -1 11312 token.tag = isStrong ? 'strong' : 'em'; -1 11313 token.nesting = -1; -1 11314 token.markup = isStrong ? ch + ch : ch; -1 11315 token.content = ''; -1 11316 -1 11317 if (isStrong) { -1 11318 state.tokens[delimiters[i + 1].token].content = ''; -1 11319 state.tokens[delimiters[startDelim.end - 1].token].content = ''; -1 11320 i++; -1 11321 } 11957 11322 }11958 -1 return qry;11959 11323 }; 11960 1132411961 -1 },{}],99:[function(require,module,exports){11962 -1 /**11963 -1 * Parses an URI11964 -1 *11965 -1 * @author Steven Levithan <stevenlevithan.com> (MIT license)11966 -1 * @api private11967 -1 */-1 11325 },{}],77:[function(require,module,exports){ -1 11326 // Process html entity - {, ¯, ", ... -1 11327 -1 11328 'use strict'; -1 11329 -1 11330 var entities = require('../common/entities'); -1 11331 var has = require('../common/utils').has; -1 11332 var isValidEntityCode = require('../common/utils').isValidEntityCode; -1 11333 var fromCodePoint = require('../common/utils').fromCodePoint; 11968 1133411969 -1 var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;11970 1133511971 -1 var parts = [11972 -1 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'11973 -1 ];-1 11336 var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i; -1 11337 var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i; 11974 1133811975 -1 module.exports = function parseuri(str) {11976 -1 var src = str,11977 -1 b = str.indexOf('['),11978 -1 e = str.indexOf(']');11979 1133911980 -1 if (b != -1 && e != -1) {11981 -1 str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);11982 -1 }-1 11340 module.exports = function entity(state, silent) { -1 11341 var ch, code, match, pos = state.pos, max = state.posMax; 11983 1134211984 -1 var m = re.exec(str || ''),11985 -1 uri = {},11986 -1 i = 14;-1 11343 if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; } 11987 1134411988 -1 while (i--) {11989 -1 uri[parts[i]] = m[i] || '';11990 -1 }-1 11345 if (pos + 1 < max) { -1 11346 ch = state.src.charCodeAt(pos + 1); 11991 1134711992 -1 if (b != -1 && e != -1) {11993 -1 uri.source = src;11994 -1 uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');11995 -1 uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');11996 -1 uri.ipv6uri = true;-1 11348 if (ch === 0x23 /* # */) { -1 11349 match = state.src.slice(pos).match(DIGITAL_RE); -1 11350 if (match) { -1 11351 if (!silent) { -1 11352 code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10); -1 11353 state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD); -1 11354 } -1 11355 state.pos += match[0].length; -1 11356 return true; -1 11357 } -1 11358 } else { -1 11359 match = state.src.slice(pos).match(NAMED_RE); -1 11360 if (match) { -1 11361 if (has(entities, match[1])) { -1 11362 if (!silent) { state.pending += entities[match[1]]; } -1 11363 state.pos += match[0].length; -1 11364 return true; -1 11365 } -1 11366 } 11997 11367 } -1 11368 } 11998 1136911999 -1 return uri;-1 11370 if (!silent) { state.pending += '&'; } -1 11371 state.pos++; -1 11372 return true; 12000 11373 }; 12001 1137412002 -1 },{}],100:[function(require,module,exports){12003 -112004 -1 /**12005 -1 * Module dependencies.12006 -1 */-1 11375 },{"../common/entities":37,"../common/utils":40}],78:[function(require,module,exports){ -1 11376 // Proceess escaped chars and hardbreaks 12007 1137712008 -1 var url = require('./url');12009 -1 var parser = require('socket.io-parser');12010 -1 var Manager = require('./manager');12011 -1 var debug = require('debug')('socket.io-client');-1 11378 'use strict'; 12012 1137912013 -1 /**12014 -1 * Module exports.12015 -1 */-1 11380 var isSpace = require('../common/utils').isSpace; 12016 1138112017 -1 module.exports = exports = lookup;-1 11382 var ESCAPED = []; 12018 1138312019 -1 /**12020 -1 * Managers cache.12021 -1 */-1 11384 for (var i = 0; i < 256; i++) { ESCAPED.push(0); } 12022 1138512023 -1 var cache = exports.managers = {};-1 11386 '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-' -1 11387 .split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; }); 12024 1138812025 -1 /**12026 -1 * Looks up an existing `Manager` for multiplexing.12027 -1 * If the user summons:12028 -1 *12029 -1 * `io('http://localhost/a');`12030 -1 * `io('http://localhost/b');`12031 -1 *12032 -1 * We reuse the existing instance based on same scheme/port/host,12033 -1 * and we initialize sockets for each namespace.12034 -1 *12035 -1 * @api public12036 -1 */12037 1138912038 -1 function lookup(uri, opts) {12039 -1 if (typeof uri == 'object') {12040 -1 opts = uri;12041 -1 uri = undefined;12042 -1 }-1 11390 module.exports = function escape(state, silent) { -1 11391 var ch, pos = state.pos, max = state.posMax; 12043 1139212044 -1 opts = opts || {};-1 11393 if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; } 12045 1139412046 -1 var parsed = url(uri);12047 -1 var source = parsed.source;12048 -1 var id = parsed.id;12049 -1 var path = parsed.path;12050 -1 var sameNamespace = cache[id] && path in cache[id].nsps;12051 -1 var newConnection = opts.forceNew || opts['force new connection'] ||12052 -1 false === opts.multiplex || sameNamespace;-1 11395 pos++; 12053 1139612054 -1 var io;-1 11397 if (pos < max) { -1 11398 ch = state.src.charCodeAt(pos); 12055 1139912056 -1 if (newConnection) {12057 -1 debug('ignoring socket cache for %s', source);12058 -1 io = Manager(source, opts);12059 -1 } else {12060 -1 if (!cache[id]) {12061 -1 debug('new io instance for %s', source);12062 -1 cache[id] = Manager(source, opts);-1 11400 if (ch < 256 && ESCAPED[ch] !== 0) { -1 11401 if (!silent) { state.pending += state.src[pos]; } -1 11402 state.pos += 2; -1 11403 return true; 12063 11404 }12064 -1 io = cache[id];12065 -1 }12066 -112067 -1 return io.socket(parsed.path);12068 -1 }12069 -112070 -1 /**12071 -1 * Protocol version.12072 -1 *12073 -1 * @api public12074 -1 */12075 -112076 -1 exports.protocol = parser.protocol;12077 -112078 -1 /**12079 -1 * `connect`.12080 -1 *12081 -1 * @param {String} uri12082 -1 * @api public12083 -1 */12084 -112085 -1 exports.connect = lookup;12086 -112087 -1 /**12088 -1 * Expose constructors for standalone build.12089 -1 *12090 -1 * @api public12091 -1 */12092 -112093 -1 exports.Manager = require('./manager');12094 -1 exports.Socket = require('./socket');12095 1140512096 -1 },{"./manager":101,"./socket":103,"./url":104,"debug":12,"socket.io-parser":107}],101:[function(require,module,exports){-1 11406 if (ch === 0x0A) { -1 11407 if (!silent) { -1 11408 state.push('hardbreak', 'br', 0); -1 11409 } 12097 1141012098 -1 /**12099 -1 * Module dependencies.12100 -1 */-1 11411 pos++; -1 11412 // skip leading whitespaces from next line -1 11413 while (pos < max) { -1 11414 ch = state.src.charCodeAt(pos); -1 11415 if (!isSpace(ch)) { break; } -1 11416 pos++; -1 11417 } 12101 1141812102 -1 var eio = require('engine.io-client');12103 -1 var Socket = require('./socket');12104 -1 var Emitter = require('component-emitter');12105 -1 var parser = require('socket.io-parser');12106 -1 var on = require('./on');12107 -1 var bind = require('component-bind');12108 -1 var debug = require('debug')('socket.io-client:manager');12109 -1 var indexOf = require('indexof');12110 -1 var Backoff = require('backo2');-1 11419 state.pos = pos; -1 11420 return true; -1 11421 } -1 11422 } 12111 1142312112 -1 /**12113 -1 * IE6+ hasOwnProperty12114 -1 */-1 11424 if (!silent) { state.pending += '\\'; } -1 11425 state.pos++; -1 11426 return true; -1 11427 }; 12115 1142812116 -1 var has = Object.prototype.hasOwnProperty;-1 11429 },{"../common/utils":40}],79:[function(require,module,exports){ -1 11430 // Process html tags 12117 1143112118 -1 /**12119 -1 * Module exports12120 -1 */-1 11432 'use strict'; 12121 1143312122 -1 module.exports = Manager;12123 1143412124 -1 /**12125 -1 * `Manager` constructor.12126 -1 *12127 -1 * @param {String} engine instance or engine uri/opts12128 -1 * @param {Object} options12129 -1 * @api public12130 -1 */-1 11435 var HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE; 12131 1143612132 -1 function Manager(uri, opts){12133 -1 if (!(this instanceof Manager)) return new Manager(uri, opts);12134 -1 if (uri && ('object' == typeof uri)) {12135 -1 opts = uri;12136 -1 uri = undefined;12137 -1 }12138 -1 opts = opts || {};12139 1143712140 -1 opts.path = opts.path || '/socket.io';12141 -1 this.nsps = {};12142 -1 this.subs = [];12143 -1 this.opts = opts;12144 -1 this.reconnection(opts.reconnection !== false);12145 -1 this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);12146 -1 this.reconnectionDelay(opts.reconnectionDelay || 1000);12147 -1 this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);12148 -1 this.randomizationFactor(opts.randomizationFactor || 0.5);12149 -1 this.backoff = new Backoff({12150 -1 min: this.reconnectionDelay(),12151 -1 max: this.reconnectionDelayMax(),12152 -1 jitter: this.randomizationFactor()12153 -1 });12154 -1 this.timeout(null == opts.timeout ? 20000 : opts.timeout);12155 -1 this.readyState = 'closed';12156 -1 this.uri = uri;12157 -1 this.connecting = [];12158 -1 this.lastPing = null;12159 -1 this.encoding = false;12160 -1 this.packetBuffer = [];12161 -1 this.encoder = new parser.Encoder();12162 -1 this.decoder = new parser.Decoder();12163 -1 this.autoConnect = opts.autoConnect !== false;12164 -1 if (this.autoConnect) this.open();-1 11438 function isLetter(ch) { -1 11439 /*eslint no-bitwise:0*/ -1 11440 var lc = ch | 0x20; // to lower case -1 11441 return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */); 12165 11442 } 12166 1144312167 -1 /**12168 -1 * Propagate given event to sockets and emit on `this`12169 -1 *12170 -1 * @api private12171 -1 */12172 1144412173 -1 Manager.prototype.emitAll = function() {12174 -1 this.emit.apply(this, arguments);12175 -1 for (var nsp in this.nsps) {12176 -1 if (has.call(this.nsps, nsp)) {12177 -1 this.nsps[nsp].emit.apply(this.nsps[nsp], arguments);12178 -1 }12179 -1 }12180 -1 };-1 11445 module.exports = function html_inline(state, silent) { -1 11446 var ch, match, max, token, -1 11447 pos = state.pos; 12181 1144812182 -1 /**12183 -1 * Update `socket.id` of all sockets12184 -1 *12185 -1 * @api private12186 -1 */-1 11449 if (!state.md.options.html) { return false; } 12187 1145012188 -1 Manager.prototype.updateSocketIds = function(){12189 -1 for (var nsp in this.nsps) {12190 -1 if (has.call(this.nsps, nsp)) {12191 -1 this.nsps[nsp].id = this.engine.id;12192 -1 }-1 11451 // Check start -1 11452 max = state.posMax; -1 11453 if (state.src.charCodeAt(pos) !== 0x3C/* < */ || -1 11454 pos + 2 >= max) { -1 11455 return false; 12193 11456 }12194 -1 };12195 -112196 -1 /**12197 -1 * Mix in `Emitter`.12198 -1 */12199 -112200 -1 Emitter(Manager.prototype);12201 -112202 -1 /**12203 -1 * Sets the `reconnection` config.12204 -1 *12205 -1 * @param {Boolean} true/false if it should automatically reconnect12206 -1 * @return {Manager} self or value12207 -1 * @api public12208 -1 */12209 1145712210 -1 Manager.prototype.reconnection = function(v){12211 -1 if (!arguments.length) return this._reconnection;12212 -1 this._reconnection = !!v;12213 -1 return this;12214 -1 };-1 11458 // Quick fail on second char -1 11459 ch = state.src.charCodeAt(pos + 1); -1 11460 if (ch !== 0x21/* ! */ && -1 11461 ch !== 0x3F/* ? */ && -1 11462 ch !== 0x2F/* / */ && -1 11463 !isLetter(ch)) { -1 11464 return false; -1 11465 } 12215 1146612216 -1 /**12217 -1 * Sets the reconnection attempts config.12218 -1 *12219 -1 * @param {Number} max reconnection attempts before giving up12220 -1 * @return {Manager} self or value12221 -1 * @api public12222 -1 */-1 11467 match = state.src.slice(pos).match(HTML_TAG_RE); -1 11468 if (!match) { return false; } 12223 1146912224 -1 Manager.prototype.reconnectionAttempts = function(v){12225 -1 if (!arguments.length) return this._reconnectionAttempts;12226 -1 this._reconnectionAttempts = v;12227 -1 return this;-1 11470 if (!silent) { -1 11471 token = state.push('html_inline', '', 0); -1 11472 token.content = state.src.slice(pos, pos + match[0].length); -1 11473 } -1 11474 state.pos += match[0].length; -1 11475 return true; 12228 11476 }; 12229 1147712230 -1 /**12231 -1 * Sets the delay between reconnections.12232 -1 *12233 -1 * @param {Number} delay12234 -1 * @return {Manager} self or value12235 -1 * @api public12236 -1 */-1 11478 },{"../common/html_re":39}],80:[function(require,module,exports){ -1 11479 // Process  12237 1148012238 -1 Manager.prototype.reconnectionDelay = function(v){12239 -1 if (!arguments.length) return this._reconnectionDelay;12240 -1 this._reconnectionDelay = v;12241 -1 this.backoff && this.backoff.setMin(v);12242 -1 return this;12243 -1 };-1 11481 'use strict'; 12244 1148212245 -1 Manager.prototype.randomizationFactor = function(v){12246 -1 if (!arguments.length) return this._randomizationFactor;12247 -1 this._randomizationFactor = v;12248 -1 this.backoff && this.backoff.setJitter(v);12249 -1 return this;12250 -1 };-1 11483 var parseLinkLabel = require('../helpers/parse_link_label'); -1 11484 var parseLinkDestination = require('../helpers/parse_link_destination'); -1 11485 var parseLinkTitle = require('../helpers/parse_link_title'); -1 11486 var normalizeReference = require('../common/utils').normalizeReference; -1 11487 var isSpace = require('../common/utils').isSpace; 12251 1148812252 -1 /**12253 -1 * Sets the maximum delay between reconnections.12254 -1 *12255 -1 * @param {Number} delay12256 -1 * @return {Manager} self or value12257 -1 * @api public12258 -1 */12259 1148912260 -1 Manager.prototype.reconnectionDelayMax = function(v){12261 -1 if (!arguments.length) return this._reconnectionDelayMax;12262 -1 this._reconnectionDelayMax = v;12263 -1 this.backoff && this.backoff.setMax(v);12264 -1 return this;12265 -1 };-1 11490 module.exports = function image(state, silent) { -1 11491 var attrs, -1 11492 code, -1 11493 content, -1 11494 label, -1 11495 labelEnd, -1 11496 labelStart, -1 11497 pos, -1 11498 ref, -1 11499 res, -1 11500 title, -1 11501 token, -1 11502 tokens, -1 11503 start, -1 11504 href = '', -1 11505 oldPos = state.pos, -1 11506 max = state.posMax; 12266 1150712267 -1 /**12268 -1 * Sets the connection timeout. `false` to disable12269 -1 *12270 -1 * @return {Manager} self or value12271 -1 * @api public12272 -1 */-1 11508 if (state.src.charCodeAt(state.pos) !== 0x21/* ! */) { return false; } -1 11509 if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; } 12273 1151012274 -1 Manager.prototype.timeout = function(v){12275 -1 if (!arguments.length) return this._timeout;12276 -1 this._timeout = v;12277 -1 return this;12278 -1 };-1 11511 labelStart = state.pos + 2; -1 11512 labelEnd = parseLinkLabel(state, state.pos + 1, false); 12279 1151312280 -1 /**12281 -1 * Starts trying to reconnect if reconnection is enabled and we have not12282 -1 * started reconnecting yet12283 -1 *12284 -1 * @api private12285 -1 */-1 11514 // parser failed to find ']', so it's not a valid link -1 11515 if (labelEnd < 0) { return false; } 12286 1151612287 -1 Manager.prototype.maybeReconnectOnOpen = function() {12288 -1 // Only try to reconnect if it's the first time we're connecting12289 -1 if (!this.reconnecting && this._reconnection && this.backoff.attempts === 0) {12290 -1 // keeps reconnection from firing twice for the same reconnection loop12291 -1 this.reconnect();12292 -1 }12293 -1 };-1 11517 pos = labelEnd + 1; -1 11518 if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) { -1 11519 // -1 11520 // Inline link -1 11521 // 12294 11522 -1 11523 // [link]( <href> "title" ) -1 11524 // ^^ skipping these spaces -1 11525 pos++; -1 11526 for (; pos < max; pos++) { -1 11527 code = state.src.charCodeAt(pos); -1 11528 if (!isSpace(code) && code !== 0x0A) { break; } -1 11529 } -1 11530 if (pos >= max) { return false; } 12295 1153112296 -1 /**12297 -1 * Sets the current transport `socket`.12298 -1 *12299 -1 * @param {Function} optional, callback12300 -1 * @return {Manager} self12301 -1 * @api public12302 -1 */-1 11532 // [link]( <href> "title" ) -1 11533 // ^^^^^^ parsing link destination -1 11534 start = pos; -1 11535 res = parseLinkDestination(state.src, pos, state.posMax); -1 11536 if (res.ok) { -1 11537 href = state.md.normalizeLink(res.str); -1 11538 if (state.md.validateLink(href)) { -1 11539 pos = res.pos; -1 11540 } else { -1 11541 href = ''; -1 11542 } -1 11543 } 12303 1154412304 -1 Manager.prototype.open =12305 -1 Manager.prototype.connect = function(fn){12306 -1 debug('readyState %s', this.readyState);12307 -1 if (~this.readyState.indexOf('open')) return this;-1 11545 // [link]( <href> "title" ) -1 11546 // ^^ skipping these spaces -1 11547 start = pos; -1 11548 for (; pos < max; pos++) { -1 11549 code = state.src.charCodeAt(pos); -1 11550 if (!isSpace(code) && code !== 0x0A) { break; } -1 11551 } 12308 1155212309 -1 debug('opening %s', this.uri);12310 -1 this.engine = eio(this.uri, this.opts);12311 -1 var socket = this.engine;12312 -1 var self = this;12313 -1 this.readyState = 'opening';12314 -1 this.skipReconnect = false;-1 11553 // [link]( <href> "title" ) -1 11554 // ^^^^^^^ parsing link title -1 11555 res = parseLinkTitle(state.src, pos, state.posMax); -1 11556 if (pos < max && start !== pos && res.ok) { -1 11557 title = res.str; -1 11558 pos = res.pos; 12315 1155912316 -1 // emit `open`12317 -1 var openSub = on(socket, 'open', function() {12318 -1 self.onopen();12319 -1 fn && fn();12320 -1 });-1 11560 // [link]( <href> "title" ) -1 11561 // ^^ skipping these spaces -1 11562 for (; pos < max; pos++) { -1 11563 code = state.src.charCodeAt(pos); -1 11564 if (!isSpace(code) && code !== 0x0A) { break; } -1 11565 } -1 11566 } else { -1 11567 title = ''; -1 11568 } 12321 1156912322 -1 // emit `connect_error`12323 -1 var errorSub = on(socket, 'error', function(data){12324 -1 debug('connect_error');12325 -1 self.cleanup();12326 -1 self.readyState = 'closed';12327 -1 self.emitAll('connect_error', data);12328 -1 if (fn) {12329 -1 var err = new Error('Connection error');12330 -1 err.data = data;12331 -1 fn(err);-1 11570 if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) { -1 11571 state.pos = oldPos; -1 11572 return false; -1 11573 } -1 11574 pos++; -1 11575 } else { -1 11576 // -1 11577 // Link reference -1 11578 // -1 11579 if (typeof state.env.references === 'undefined') { return false; } -1 11580 -1 11581 if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) { -1 11582 start = pos + 1; -1 11583 pos = parseLinkLabel(state, pos); -1 11584 if (pos >= 0) { -1 11585 label = state.src.slice(start, pos++); -1 11586 } else { -1 11587 pos = labelEnd + 1; -1 11588 } 12332 11589 } else {12333 -1 // Only do this if there is no fn to handle the error12334 -1 self.maybeReconnectOnOpen();-1 11590 pos = labelEnd + 1; 12335 11591 }12336 -1 });12337 1159212338 -1 // emit `connect_timeout`12339 -1 if (false !== this._timeout) {12340 -1 var timeout = this._timeout;12341 -1 debug('connect attempt will timeout after %d', timeout);-1 11593 // covers label === '' and label === undefined -1 11594 // (collapsed reference link and shortcut reference link respectively) -1 11595 if (!label) { label = state.src.slice(labelStart, labelEnd); } 12342 1159612343 -1 // set timer12344 -1 var timer = setTimeout(function(){12345 -1 debug('connect attempt timed out after %d', timeout);12346 -1 openSub.destroy();12347 -1 socket.close();12348 -1 socket.emit('error', 'timeout');12349 -1 self.emitAll('connect_timeout', timeout);12350 -1 }, timeout);-1 11597 ref = state.env.references[normalizeReference(label)]; -1 11598 if (!ref) { -1 11599 state.pos = oldPos; -1 11600 return false; -1 11601 } -1 11602 href = ref.href; -1 11603 title = ref.title; -1 11604 } 12351 1160512352 -1 this.subs.push({12353 -1 destroy: function(){12354 -1 clearTimeout(timer);12355 -1 }12356 -1 });-1 11606 // -1 11607 // We found the end of the link, and know for a fact it's a valid link; -1 11608 // so all that's left to do is to call tokenizer. -1 11609 // -1 11610 if (!silent) { -1 11611 content = state.src.slice(labelStart, labelEnd); -1 11612 -1 11613 state.md.inline.parse( -1 11614 content, -1 11615 state.md, -1 11616 state.env, -1 11617 tokens = [] -1 11618 ); -1 11619 -1 11620 token = state.push('image', 'img', 0); -1 11621 token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ]; -1 11622 token.children = tokens; -1 11623 token.content = content; -1 11624 -1 11625 if (title) { -1 11626 attrs.push([ 'title', title ]); -1 11627 } 12357 11628 } 12358 1162912359 -1 this.subs.push(openSub);12360 -1 this.subs.push(errorSub);12361 -112362 -1 return this;-1 11630 state.pos = pos; -1 11631 state.posMax = max; -1 11632 return true; 12363 11633 }; 12364 1163412365 -1 /**12366 -1 * Called upon transport open.12367 -1 *12368 -1 * @api private12369 -1 */-1 11635 },{"../common/utils":40,"../helpers/parse_link_destination":42,"../helpers/parse_link_label":43,"../helpers/parse_link_title":44}],81:[function(require,module,exports){ -1 11636 // Process [link](<to> "stuff") 12370 1163712371 -1 Manager.prototype.onopen = function(){12372 -1 debug('open');-1 11638 'use strict'; 12373 1163912374 -1 // clear old subs12375 -1 this.cleanup();-1 11640 var parseLinkLabel = require('../helpers/parse_link_label'); -1 11641 var parseLinkDestination = require('../helpers/parse_link_destination'); -1 11642 var parseLinkTitle = require('../helpers/parse_link_title'); -1 11643 var normalizeReference = require('../common/utils').normalizeReference; -1 11644 var isSpace = require('../common/utils').isSpace; 12376 1164512377 -1 // mark as open12378 -1 this.readyState = 'open';12379 -1 this.emit('open');12380 1164612381 -1 // add new subs12382 -1 var socket = this.engine;12383 -1 this.subs.push(on(socket, 'data', bind(this, 'ondata')));12384 -1 this.subs.push(on(socket, 'ping', bind(this, 'onping')));12385 -1 this.subs.push(on(socket, 'pong', bind(this, 'onpong')));12386 -1 this.subs.push(on(socket, 'error', bind(this, 'onerror')));12387 -1 this.subs.push(on(socket, 'close', bind(this, 'onclose')));12388 -1 this.subs.push(on(this.decoder, 'decoded', bind(this, 'ondecoded')));12389 -1 };-1 11647 module.exports = function link(state, silent) { -1 11648 var attrs, -1 11649 code, -1 11650 label, -1 11651 labelEnd, -1 11652 labelStart, -1 11653 pos, -1 11654 res, -1 11655 ref, -1 11656 title, -1 11657 token, -1 11658 href = '', -1 11659 oldPos = state.pos, -1 11660 max = state.posMax, -1 11661 start = state.pos; 12390 1166212391 -1 /**12392 -1 * Called upon a ping.12393 -1 *12394 -1 * @api private12395 -1 */-1 11663 if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; } 12396 1166412397 -1 Manager.prototype.onping = function(){12398 -1 this.lastPing = new Date;12399 -1 this.emitAll('ping');12400 -1 };-1 11665 labelStart = state.pos + 1; -1 11666 labelEnd = parseLinkLabel(state, state.pos, true); 12401 1166712402 -1 /**12403 -1 * Called upon a packet.12404 -1 *12405 -1 * @api private12406 -1 */-1 11668 // parser failed to find ']', so it's not a valid link -1 11669 if (labelEnd < 0) { return false; } 12407 1167012408 -1 Manager.prototype.onpong = function(){12409 -1 this.emitAll('pong', new Date - this.lastPing);12410 -1 };-1 11671 pos = labelEnd + 1; -1 11672 if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) { -1 11673 // -1 11674 // Inline link -1 11675 // 12411 1167612412 -1 /**12413 -1 * Called with data.12414 -1 *12415 -1 * @api private12416 -1 */-1 11677 // [link]( <href> "title" ) -1 11678 // ^^ skipping these spaces -1 11679 pos++; -1 11680 for (; pos < max; pos++) { -1 11681 code = state.src.charCodeAt(pos); -1 11682 if (!isSpace(code) && code !== 0x0A) { break; } -1 11683 } -1 11684 if (pos >= max) { return false; } 12417 1168512418 -1 Manager.prototype.ondata = function(data){12419 -1 this.decoder.add(data);12420 -1 };-1 11686 // [link]( <href> "title" ) -1 11687 // ^^^^^^ parsing link destination -1 11688 start = pos; -1 11689 res = parseLinkDestination(state.src, pos, state.posMax); -1 11690 if (res.ok) { -1 11691 href = state.md.normalizeLink(res.str); -1 11692 if (state.md.validateLink(href)) { -1 11693 pos = res.pos; -1 11694 } else { -1 11695 href = ''; -1 11696 } -1 11697 } 12421 1169812422 -1 /**12423 -1 * Called when parser fully decodes a packet.12424 -1 *12425 -1 * @api private12426 -1 */-1 11699 // [link]( <href> "title" ) -1 11700 // ^^ skipping these spaces -1 11701 start = pos; -1 11702 for (; pos < max; pos++) { -1 11703 code = state.src.charCodeAt(pos); -1 11704 if (!isSpace(code) && code !== 0x0A) { break; } -1 11705 } 12427 1170612428 -1 Manager.prototype.ondecoded = function(packet) {12429 -1 this.emit('packet', packet);12430 -1 };-1 11707 // [link]( <href> "title" ) -1 11708 // ^^^^^^^ parsing link title -1 11709 res = parseLinkTitle(state.src, pos, state.posMax); -1 11710 if (pos < max && start !== pos && res.ok) { -1 11711 title = res.str; -1 11712 pos = res.pos; 12431 1171312432 -1 /**12433 -1 * Called upon socket error.12434 -1 *12435 -1 * @api private12436 -1 */-1 11714 // [link]( <href> "title" ) -1 11715 // ^^ skipping these spaces -1 11716 for (; pos < max; pos++) { -1 11717 code = state.src.charCodeAt(pos); -1 11718 if (!isSpace(code) && code !== 0x0A) { break; } -1 11719 } -1 11720 } else { -1 11721 title = ''; -1 11722 } 12437 1172312438 -1 Manager.prototype.onerror = function(err){12439 -1 debug('error', err);12440 -1 this.emitAll('error', err);12441 -1 };-1 11724 if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) { -1 11725 state.pos = oldPos; -1 11726 return false; -1 11727 } -1 11728 pos++; -1 11729 } else { -1 11730 // -1 11731 // Link reference -1 11732 // -1 11733 if (typeof state.env.references === 'undefined') { return false; } 12442 1173412443 -1 /**12444 -1 * Creates a new socket for the given `nsp`.12445 -1 *12446 -1 * @return {Socket}12447 -1 * @api public12448 -1 */-1 11735 if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) { -1 11736 start = pos + 1; -1 11737 pos = parseLinkLabel(state, pos); -1 11738 if (pos >= 0) { -1 11739 label = state.src.slice(start, pos++); -1 11740 } else { -1 11741 pos = labelEnd + 1; -1 11742 } -1 11743 } else { -1 11744 pos = labelEnd + 1; -1 11745 } 12449 1174612450 -1 Manager.prototype.socket = function(nsp){12451 -1 var socket = this.nsps[nsp];12452 -1 if (!socket) {12453 -1 socket = new Socket(this, nsp);12454 -1 this.nsps[nsp] = socket;12455 -1 var self = this;12456 -1 socket.on('connecting', onConnecting);12457 -1 socket.on('connect', function(){12458 -1 socket.id = self.engine.id;12459 -1 });-1 11747 // covers label === '' and label === undefined -1 11748 // (collapsed reference link and shortcut reference link respectively) -1 11749 if (!label) { label = state.src.slice(labelStart, labelEnd); } 12460 1175012461 -1 if (this.autoConnect) {12462 -1 // manually call here since connecting evnet is fired before listening12463 -1 onConnecting();-1 11751 ref = state.env.references[normalizeReference(label)]; -1 11752 if (!ref) { -1 11753 state.pos = oldPos; -1 11754 return false; 12464 11755 } -1 11756 href = ref.href; -1 11757 title = ref.title; 12465 11758 } 12466 1175912467 -1 function onConnecting() {12468 -1 if (!~indexOf(self.connecting, socket)) {12469 -1 self.connecting.push(socket);-1 11760 // -1 11761 // We found the end of the link, and know for a fact it's a valid link; -1 11762 // so all that's left to do is to call tokenizer. -1 11763 // -1 11764 if (!silent) { -1 11765 state.pos = labelStart; -1 11766 state.posMax = labelEnd; -1 11767 -1 11768 token = state.push('link_open', 'a', 1); -1 11769 token.attrs = attrs = [ [ 'href', href ] ]; -1 11770 if (title) { -1 11771 attrs.push([ 'title', title ]); 12470 11772 } -1 11773 -1 11774 state.md.inline.tokenize(state); -1 11775 -1 11776 token = state.push('link_close', 'a', -1); 12471 11777 } 12472 1177812473 -1 return socket;-1 11779 state.pos = pos; -1 11780 state.posMax = max; -1 11781 return true; 12474 11782 }; 12475 1178312476 -1 /**12477 -1 * Called upon a socket close.12478 -1 *12479 -1 * @param {Socket} socket12480 -1 */-1 11784 },{"../common/utils":40,"../helpers/parse_link_destination":42,"../helpers/parse_link_label":43,"../helpers/parse_link_title":44}],82:[function(require,module,exports){ -1 11785 // Proceess '\n' 12481 1178612482 -1 Manager.prototype.destroy = function(socket){12483 -1 var index = indexOf(this.connecting, socket);12484 -1 if (~index) this.connecting.splice(index, 1);12485 -1 if (this.connecting.length) return;-1 11787 'use strict'; 12486 1178812487 -1 this.close();12488 -1 };-1 11789 module.exports = function newline(state, silent) { -1 11790 var pmax, max, pos = state.pos; 12489 1179112490 -1 /**12491 -1 * Writes a packet.12492 -1 *12493 -1 * @param {Object} packet12494 -1 * @api private12495 -1 */-1 11792 if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; } 12496 1179312497 -1 Manager.prototype.packet = function(packet){12498 -1 debug('writing packet %j', packet);12499 -1 var self = this;-1 11794 pmax = state.pending.length - 1; -1 11795 max = state.posMax; 12500 1179612501 -1 if (!self.encoding) {12502 -1 // encode, then write to engine with result12503 -1 self.encoding = true;12504 -1 this.encoder.encode(packet, function(encodedPackets) {12505 -1 for (var i = 0; i < encodedPackets.length; i++) {12506 -1 self.engine.write(encodedPackets[i], packet.options);-1 11797 // ' \n' -> hardbreak -1 11798 // Lookup in pending chars is bad practice! Don't copy to other rules! -1 11799 // Pending string is stored in concat mode, indexed lookups will cause -1 11800 // convertion to flat mode. -1 11801 if (!silent) { -1 11802 if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) { -1 11803 if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) { -1 11804 state.pending = state.pending.replace(/ +$/, ''); -1 11805 state.push('hardbreak', 'br', 0); -1 11806 } else { -1 11807 state.pending = state.pending.slice(0, -1); -1 11808 state.push('softbreak', 'br', 0); 12507 11809 }12508 -1 self.encoding = false;12509 -1 self.processPacketQueue();12510 -1 });12511 -1 } else { // add packet to the queue12512 -1 self.packetBuffer.push(packet);-1 11810 -1 11811 } else { -1 11812 state.push('softbreak', 'br', 0); -1 11813 } 12513 11814 }12514 -1 };12515 1181512516 -1 /**12517 -1 * If packet buffer is non-empty, begins encoding the12518 -1 * next packet in line.12519 -1 *12520 -1 * @api private12521 -1 */-1 11816 pos++; 12522 1181712523 -1 Manager.prototype.processPacketQueue = function() {12524 -1 if (this.packetBuffer.length > 0 && !this.encoding) {12525 -1 var pack = this.packetBuffer.shift();12526 -1 this.packet(pack);12527 -1 }-1 11818 // skip heading spaces for next line -1 11819 while (pos < max && state.src.charCodeAt(pos) === 0x20) { pos++; } -1 11820 -1 11821 state.pos = pos; -1 11822 return true; 12528 11823 }; 12529 1182412530 -1 /**12531 -1 * Clean up transport subscriptions and packet buffer.12532 -1 *12533 -1 * @api private12534 -1 */-1 11825 },{}],83:[function(require,module,exports){ -1 11826 // Inline parser state 12535 1182712536 -1 Manager.prototype.cleanup = function(){12537 -1 debug('cleanup');-1 11828 'use strict'; 12538 1182912539 -1 var sub;12540 -1 while (sub = this.subs.shift()) sub.destroy();12541 1183012542 -1 this.packetBuffer = [];12543 -1 this.encoding = false;12544 -1 this.lastPing = null;-1 11831 var Token = require('../token'); -1 11832 var isWhiteSpace = require('../common/utils').isWhiteSpace; -1 11833 var isPunctChar = require('../common/utils').isPunctChar; -1 11834 var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct; 12545 1183512546 -1 this.decoder.destroy();12547 -1 };12548 1183612549 -1 /**12550 -1 * Close the current socket.12551 -1 *12552 -1 * @api private12553 -1 */-1 11837 function StateInline(src, md, env, outTokens) { -1 11838 this.src = src; -1 11839 this.env = env; -1 11840 this.md = md; -1 11841 this.tokens = outTokens; 12554 1184212555 -1 Manager.prototype.close =12556 -1 Manager.prototype.disconnect = function(){12557 -1 debug('disconnect');12558 -1 this.skipReconnect = true;12559 -1 this.reconnecting = false;12560 -1 if ('opening' == this.readyState) {12561 -1 // `onclose` will not fire because12562 -1 // an open event never happened12563 -1 this.cleanup();12564 -1 }12565 -1 this.backoff.reset();12566 -1 this.readyState = 'closed';12567 -1 if (this.engine) this.engine.close();12568 -1 };-1 11843 this.pos = 0; -1 11844 this.posMax = this.src.length; -1 11845 this.level = 0; -1 11846 this.pending = ''; -1 11847 this.pendingLevel = 0; 12569 1184812570 -1 /**12571 -1 * Called upon engine close.12572 -1 *12573 -1 * @api private12574 -1 */-1 11849 this.cache = {}; // Stores { start: end } pairs. Useful for backtrack -1 11850 // optimization of pairs parse (emphasis, strikes). 12575 1185112576 -1 Manager.prototype.onclose = function(reason){12577 -1 debug('onclose');-1 11852 this.delimiters = []; // Emphasis-like delimiters -1 11853 } 12578 1185412579 -1 this.cleanup();12580 -1 this.backoff.reset();12581 -1 this.readyState = 'closed';12582 -1 this.emit('close', reason);12583 1185512584 -1 if (this._reconnection && !this.skipReconnect) {12585 -1 this.reconnect();-1 11856 // Flush pending text -1 11857 // -1 11858 StateInline.prototype.pushPending = function () { -1 11859 var token = new Token('text', '', 0); -1 11860 token.content = this.pending; -1 11861 token.level = this.pendingLevel; -1 11862 this.tokens.push(token); -1 11863 this.pending = ''; -1 11864 return token; -1 11865 }; -1 11866 -1 11867 -1 11868 // Push new token to "stream". -1 11869 // If pending text exists - flush it as text token -1 11870 // -1 11871 StateInline.prototype.push = function (type, tag, nesting) { -1 11872 if (this.pending) { -1 11873 this.pushPending(); 12586 11874 } -1 11875 -1 11876 var token = new Token(type, tag, nesting); -1 11877 -1 11878 if (nesting < 0) { this.level--; } -1 11879 token.level = this.level; -1 11880 if (nesting > 0) { this.level++; } -1 11881 -1 11882 this.pendingLevel = this.level; -1 11883 this.tokens.push(token); -1 11884 return token; 12587 11885 }; 12588 1188612589 -1 /**12590 -1 * Attempt a reconnection.12591 -1 *12592 -1 * @api private12593 -1 */12594 1188712595 -1 Manager.prototype.reconnect = function(){12596 -1 if (this.reconnecting || this.skipReconnect) return this;-1 11888 // Scan a sequence of emphasis-like markers, and determine whether -1 11889 // it can start an emphasis sequence or end an emphasis sequence. -1 11890 // -1 11891 // - start - position to scan from (it should point at a valid marker); -1 11892 // - canSplitWord - determine if these markers can be found inside a word -1 11893 // -1 11894 StateInline.prototype.scanDelims = function (start, canSplitWord) { -1 11895 var pos = start, lastChar, nextChar, count, can_open, can_close, -1 11896 isLastWhiteSpace, isLastPunctChar, -1 11897 isNextWhiteSpace, isNextPunctChar, -1 11898 left_flanking = true, -1 11899 right_flanking = true, -1 11900 max = this.posMax, -1 11901 marker = this.src.charCodeAt(start); 12597 1190212598 -1 var self = this;-1 11903 // treat beginning of the line as a whitespace -1 11904 lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20; 12599 1190512600 -1 if (this.backoff.attempts >= this._reconnectionAttempts) {12601 -1 debug('reconnect failed');12602 -1 this.backoff.reset();12603 -1 this.emitAll('reconnect_failed');12604 -1 this.reconnecting = false;12605 -1 } else {12606 -1 var delay = this.backoff.duration();12607 -1 debug('will wait %dms before reconnect attempt', delay);-1 11906 while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; } 12608 1190712609 -1 this.reconnecting = true;12610 -1 var timer = setTimeout(function(){12611 -1 if (self.skipReconnect) return;-1 11908 count = pos - start; 12612 1190912613 -1 debug('attempting reconnect');12614 -1 self.emitAll('reconnect_attempt', self.backoff.attempts);12615 -1 self.emitAll('reconnecting', self.backoff.attempts);-1 11910 // treat end of the line as a whitespace -1 11911 nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20; 12616 1191212617 -1 // check again for the case socket closed in above events12618 -1 if (self.skipReconnect) return;-1 11913 isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar)); -1 11914 isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar)); 12619 1191512620 -1 self.open(function(err){12621 -1 if (err) {12622 -1 debug('reconnect attempt error');12623 -1 self.reconnecting = false;12624 -1 self.reconnect();12625 -1 self.emitAll('reconnect_error', err.data);12626 -1 } else {12627 -1 debug('reconnect success');12628 -1 self.onreconnect();12629 -1 }12630 -1 });12631 -1 }, delay);-1 11916 isLastWhiteSpace = isWhiteSpace(lastChar); -1 11917 isNextWhiteSpace = isWhiteSpace(nextChar); 12632 1191812633 -1 this.subs.push({12634 -1 destroy: function(){12635 -1 clearTimeout(timer);12636 -1 }12637 -1 });-1 11919 if (isNextWhiteSpace) { -1 11920 left_flanking = false; -1 11921 } else if (isNextPunctChar) { -1 11922 if (!(isLastWhiteSpace || isLastPunctChar)) { -1 11923 left_flanking = false; -1 11924 } 12638 11925 }12639 -1 };12640 1192612641 -1 /**12642 -1 * Called upon successful reconnect.12643 -1 *12644 -1 * @api private12645 -1 */-1 11927 if (isLastWhiteSpace) { -1 11928 right_flanking = false; -1 11929 } else if (isLastPunctChar) { -1 11930 if (!(isNextWhiteSpace || isNextPunctChar)) { -1 11931 right_flanking = false; -1 11932 } -1 11933 } 12646 1193412647 -1 Manager.prototype.onreconnect = function(){12648 -1 var attempt = this.backoff.attempts;12649 -1 this.reconnecting = false;12650 -1 this.backoff.reset();12651 -1 this.updateSocketIds();12652 -1 this.emitAll('reconnect', attempt);-1 11935 if (!canSplitWord) { -1 11936 can_open = left_flanking && (!right_flanking || isLastPunctChar); -1 11937 can_close = right_flanking && (!left_flanking || isNextPunctChar); -1 11938 } else { -1 11939 can_open = left_flanking; -1 11940 can_close = right_flanking; -1 11941 } -1 11942 -1 11943 return { -1 11944 can_open: can_open, -1 11945 can_close: can_close, -1 11946 length: count -1 11947 }; 12653 11948 }; 12654 1194912655 -1 },{"./on":102,"./socket":103,"backo2":5,"component-bind":9,"component-emitter":105,"debug":12,"engine.io-client":14,"indexof":32,"socket.io-parser":107}],102:[function(require,module,exports){12656 1195012657 -1 /**12658 -1 * Module exports.12659 -1 */-1 11951 // re-export Token class to use in block rules -1 11952 StateInline.prototype.Token = Token; 12660 1195312661 -1 module.exports = on;12662 1195412663 -1 /**12664 -1 * Helper for subscriptions.12665 -1 *12666 -1 * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter`12667 -1 * @param {String} event name12668 -1 * @param {Function} callback12669 -1 * @api public12670 -1 */-1 11955 module.exports = StateInline; 12671 1195612672 -1 function on(obj, ev, fn) {12673 -1 obj.on(ev, fn);12674 -1 return {12675 -1 destroy: function(){12676 -1 obj.removeListener(ev, fn);12677 -1 }12678 -1 };12679 -1 }-1 11957 },{"../common/utils":40,"../token":87}],84:[function(require,module,exports){ -1 11958 // ~~strike through~~ -1 11959 // -1 11960 'use strict'; 12680 1196112681 -1 },{}],103:[function(require,module,exports){12682 1196212683 -1 /**12684 -1 * Module dependencies.12685 -1 */-1 11963 // Insert each marker as a separate text token, and add it to delimiter list -1 11964 // -1 11965 module.exports.tokenize = function strikethrough(state, silent) { -1 11966 var i, scanned, token, len, ch, -1 11967 start = state.pos, -1 11968 marker = state.src.charCodeAt(start); 12686 1196912687 -1 var parser = require('socket.io-parser');12688 -1 var Emitter = require('component-emitter');12689 -1 var toArray = require('to-array');12690 -1 var on = require('./on');12691 -1 var bind = require('component-bind');12692 -1 var debug = require('debug')('socket.io-client:socket');12693 -1 var hasBin = require('has-binary');-1 11970 if (silent) { return false; } -1 11971 -1 11972 if (marker !== 0x7E/* ~ */) { return false; } -1 11973 -1 11974 scanned = state.scanDelims(state.pos, true); -1 11975 len = scanned.length; -1 11976 ch = String.fromCharCode(marker); -1 11977 -1 11978 if (len < 2) { return false; } -1 11979 -1 11980 if (len % 2) { -1 11981 token = state.push('text', '', 0); -1 11982 token.content = ch; -1 11983 len--; -1 11984 } 12694 1198512695 -1 /**12696 -1 * Module exports.12697 -1 */-1 11986 for (i = 0; i < len; i += 2) { -1 11987 token = state.push('text', '', 0); -1 11988 token.content = ch + ch; 12698 1198912699 -1 module.exports = exports = Socket;-1 11990 state.delimiters.push({ -1 11991 marker: marker, -1 11992 jump: i, -1 11993 token: state.tokens.length - 1, -1 11994 level: state.level, -1 11995 end: -1, -1 11996 open: scanned.can_open, -1 11997 close: scanned.can_close -1 11998 }); -1 11999 } 12700 1200012701 -1 /**12702 -1 * Internal events (blacklisted).12703 -1 * These events can't be emitted by the user.12704 -1 *12705 -1 * @api private12706 -1 */-1 12001 state.pos += scanned.length; 12707 1200212708 -1 var events = {12709 -1 connect: 1,12710 -1 connect_error: 1,12711 -1 connect_timeout: 1,12712 -1 connecting: 1,12713 -1 disconnect: 1,12714 -1 error: 1,12715 -1 reconnect: 1,12716 -1 reconnect_attempt: 1,12717 -1 reconnect_failed: 1,12718 -1 reconnect_error: 1,12719 -1 reconnecting: 1,12720 -1 ping: 1,12721 -1 pong: 1-1 12003 return true; 12722 12004 }; 12723 1200512724 -1 /**12725 -1 * Shortcut to `Emitter#emit`.12726 -1 */12727 1200612728 -1 var emit = Emitter.prototype.emit;-1 12007 // Walk through delimiter list and replace text tokens with tags -1 12008 // -1 12009 module.exports.postProcess = function strikethrough(state) { -1 12010 var i, j, -1 12011 startDelim, -1 12012 endDelim, -1 12013 token, -1 12014 loneMarkers = [], -1 12015 delimiters = state.delimiters, -1 12016 max = state.delimiters.length; 12729 1201712730 -1 /**12731 -1 * `Socket` constructor.12732 -1 *12733 -1 * @api public12734 -1 */-1 12018 for (i = 0; i < max; i++) { -1 12019 startDelim = delimiters[i]; 12735 1202012736 -1 function Socket(io, nsp){12737 -1 this.io = io;12738 -1 this.nsp = nsp;12739 -1 this.json = this; // compat12740 -1 this.ids = 0;12741 -1 this.acks = {};12742 -1 this.receiveBuffer = [];12743 -1 this.sendBuffer = [];12744 -1 this.connected = false;12745 -1 this.disconnected = true;12746 -1 if (this.io.autoConnect) this.open();12747 -1 }-1 12021 if (startDelim.marker !== 0x7E/* ~ */) { -1 12022 continue; -1 12023 } 12748 1202412749 -1 /**12750 -1 * Mix in `Emitter`.12751 -1 */-1 12025 if (startDelim.end === -1) { -1 12026 continue; -1 12027 } 12752 1202812753 -1 Emitter(Socket.prototype);-1 12029 endDelim = delimiters[startDelim.end]; 12754 1203012755 -1 /**12756 -1 * Subscribe to open, close and packet events12757 -1 *12758 -1 * @api private12759 -1 */-1 12031 token = state.tokens[startDelim.token]; -1 12032 token.type = 's_open'; -1 12033 token.tag = 's'; -1 12034 token.nesting = 1; -1 12035 token.markup = '~~'; -1 12036 token.content = ''; 12760 1203712761 -1 Socket.prototype.subEvents = function() {12762 -1 if (this.subs) return;-1 12038 token = state.tokens[endDelim.token]; -1 12039 token.type = 's_close'; -1 12040 token.tag = 's'; -1 12041 token.nesting = -1; -1 12042 token.markup = '~~'; -1 12043 token.content = ''; 12763 1204412764 -1 var io = this.io;12765 -1 this.subs = [12766 -1 on(io, 'open', bind(this, 'onopen')),12767 -1 on(io, 'packet', bind(this, 'onpacket')),12768 -1 on(io, 'close', bind(this, 'onclose'))12769 -1 ];12770 -1 };-1 12045 if (state.tokens[endDelim.token - 1].type === 'text' && -1 12046 state.tokens[endDelim.token - 1].content === '~') { 12771 1204712772 -1 /**12773 -1 * "Opens" the socket.12774 -1 *12775 -1 * @api public12776 -1 */-1 12048 loneMarkers.push(endDelim.token - 1); -1 12049 } -1 12050 } 12777 1205112778 -1 Socket.prototype.open =12779 -1 Socket.prototype.connect = function(){12780 -1 if (this.connected) return this;-1 12052 // If a marker sequence has an odd number of characters, it's splitted -1 12053 // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the -1 12054 // start of the sequence. -1 12055 // -1 12056 // So, we have to move all those markers after subsequent s_close tags. -1 12057 // -1 12058 while (loneMarkers.length) { -1 12059 i = loneMarkers.pop(); -1 12060 j = i + 1; 12781 1206112782 -1 this.subEvents();12783 -1 this.io.open(); // ensure open12784 -1 if ('open' == this.io.readyState) this.onopen();12785 -1 this.emit('connecting');12786 -1 return this;12787 -1 };-1 12062 while (j < state.tokens.length && state.tokens[j].type === 's_close') { -1 12063 j++; -1 12064 } 12788 1206512789 -1 /**12790 -1 * Sends a `message` event.12791 -1 *12792 -1 * @return {Socket} self12793 -1 * @api public12794 -1 */-1 12066 j--; 12795 1206712796 -1 Socket.prototype.send = function(){12797 -1 var args = toArray(arguments);12798 -1 args.unshift('message');12799 -1 this.emit.apply(this, args);12800 -1 return this;-1 12068 if (i !== j) { -1 12069 token = state.tokens[j]; -1 12070 state.tokens[j] = state.tokens[i]; -1 12071 state.tokens[i] = token; -1 12072 } -1 12073 } 12801 12074 }; 12802 1207512803 -1 /**12804 -1 * Override `emit`.12805 -1 * If the event is in `events`, it's emitted normally.12806 -1 *12807 -1 * @param {String} event name12808 -1 * @return {Socket} self12809 -1 * @api public12810 -1 */-1 12076 },{}],85:[function(require,module,exports){ -1 12077 // Skip text characters for text token, place those to pending buffer -1 12078 // and increment current pos 12811 1207912812 -1 Socket.prototype.emit = function(ev){12813 -1 if (events.hasOwnProperty(ev)) {12814 -1 emit.apply(this, arguments);12815 -1 return this;12816 -1 }-1 12080 'use strict'; 12817 1208112818 -1 var args = toArray(arguments);12819 -1 var parserType = parser.EVENT; // default12820 -1 if (hasBin(args)) { parserType = parser.BINARY_EVENT; } // binary12821 -1 var packet = { type: parserType, data: args };12822 1208212823 -1 packet.options = {};12824 -1 packet.options.compress = !this.flags || false !== this.flags.compress;-1 12083 // Rule to skip pure text -1 12084 // '{}$%@~+=:' reserved for extentions 12825 1208512826 -1 // event ack callback12827 -1 if ('function' == typeof args[args.length - 1]) {12828 -1 debug('emitting packet with ack id %d', this.ids);12829 -1 this.acks[this.ids] = args.pop();12830 -1 packet.id = this.ids++;-1 12086 // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~ -1 12087 -1 12088 // !!!! Don't confuse with "Markdown ASCII Punctuation" chars -1 12089 // http://spec.commonmark.org/0.15/#ascii-punctuation-character -1 12090 function isTerminatorChar(ch) { -1 12091 switch (ch) { -1 12092 case 0x0A/* \n */: -1 12093 case 0x21/* ! */: -1 12094 case 0x23/* # */: -1 12095 case 0x24/* $ */: -1 12096 case 0x25/* % */: -1 12097 case 0x26/* & */: -1 12098 case 0x2A/* * */: -1 12099 case 0x2B/* + */: -1 12100 case 0x2D/* - */: -1 12101 case 0x3A/* : */: -1 12102 case 0x3C/* < */: -1 12103 case 0x3D/* = */: -1 12104 case 0x3E/* > */: -1 12105 case 0x40/* @ */: -1 12106 case 0x5B/* [ */: -1 12107 case 0x5C/* \ */: -1 12108 case 0x5D/* ] */: -1 12109 case 0x5E/* ^ */: -1 12110 case 0x5F/* _ */: -1 12111 case 0x60/* ` */: -1 12112 case 0x7B/* { */: -1 12113 case 0x7D/* } */: -1 12114 case 0x7E/* ~ */: -1 12115 return true; -1 12116 default: -1 12117 return false; 12831 12118 } -1 12119 } 12832 1212012833 -1 if (this.connected) {12834 -1 this.packet(packet);12835 -1 } else {12836 -1 this.sendBuffer.push(packet);-1 12121 module.exports = function text(state, silent) { -1 12122 var pos = state.pos; -1 12123 -1 12124 while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) { -1 12125 pos++; 12837 12126 } 12838 1212712839 -1 delete this.flags;-1 12128 if (pos === state.pos) { return false; } 12840 1212912841 -1 return this;12842 -1 };-1 12130 if (!silent) { state.pending += state.src.slice(state.pos, pos); } 12843 1213112844 -1 /**12845 -1 * Sends a packet.12846 -1 *12847 -1 * @param {Object} packet12848 -1 * @api private12849 -1 */-1 12132 state.pos = pos; 12850 1213312851 -1 Socket.prototype.packet = function(packet){12852 -1 packet.nsp = this.nsp;12853 -1 this.io.packet(packet);-1 12134 return true; 12854 12135 }; 12855 1213612856 -1 /**12857 -1 * Called upon engine `open`.12858 -1 *12859 -1 * @api private12860 -1 */-1 12137 // Alternative implementation, for memory. -1 12138 // -1 12139 // It costs 10% of performance, but allows extend terminators list, if place it -1 12140 // to `ParcerInline` property. Probably, will switch to it sometime, such -1 12141 // flexibility required. -1 12142 -1 12143 /* -1 12144 var TERMINATOR_RE = /[\n!#$%&*+\-:<=>@[\\\]^_`{}~]/; -1 12145 -1 12146 module.exports = function text(state, silent) { -1 12147 var pos = state.pos, -1 12148 idx = state.src.slice(pos).search(TERMINATOR_RE); 12861 1214912862 -1 Socket.prototype.onopen = function(){12863 -1 debug('transport is open - connecting');-1 12150 // first char is terminator -> empty text -1 12151 if (idx === 0) { return false; } 12864 1215212865 -1 // write connect packet if necessary12866 -1 if ('/' != this.nsp) {12867 -1 this.packet({ type: parser.CONNECT });-1 12153 // no terminator -> text till end of string -1 12154 if (idx < 0) { -1 12155 if (!silent) { state.pending += state.src.slice(pos); } -1 12156 state.pos = state.src.length; -1 12157 return true; 12868 12158 }12869 -1 };12870 1215912871 -1 /**12872 -1 * Called upon engine `close`.12873 -1 *12874 -1 * @param {String} reason12875 -1 * @api private12876 -1 */-1 12160 if (!silent) { state.pending += state.src.slice(pos, pos + idx); } 12877 1216112878 -1 Socket.prototype.onclose = function(reason){12879 -1 debug('close (%s)', reason);12880 -1 this.connected = false;12881 -1 this.disconnected = true;12882 -1 delete this.id;12883 -1 this.emit('disconnect', reason);12884 -1 };-1 12162 state.pos += idx; 12885 1216312886 -1 /**12887 -1 * Called with socket packet.12888 -1 *12889 -1 * @param {Object} packet12890 -1 * @api private12891 -1 */-1 12164 return true; -1 12165 };*/ 12892 1216612893 -1 Socket.prototype.onpacket = function(packet){12894 -1 if (packet.nsp != this.nsp) return;-1 12167 },{}],86:[function(require,module,exports){ -1 12168 // Merge adjacent text nodes into one, and re-calculate all token levels -1 12169 // -1 12170 'use strict'; 12895 1217112896 -1 switch (packet.type) {12897 -1 case parser.CONNECT:12898 -1 this.onconnect();12899 -1 break;12900 1217212901 -1 case parser.EVENT:12902 -1 this.onevent(packet);12903 -1 break;-1 12173 module.exports = function text_collapse(state) { -1 12174 var curr, last, -1 12175 level = 0, -1 12176 tokens = state.tokens, -1 12177 max = state.tokens.length; 12904 1217812905 -1 case parser.BINARY_EVENT:12906 -1 this.onevent(packet);12907 -1 break;-1 12179 for (curr = last = 0; curr < max; curr++) { -1 12180 // re-calculate levels -1 12181 level += tokens[curr].nesting; -1 12182 tokens[curr].level = level; 12908 1218312909 -1 case parser.ACK:12910 -1 this.onack(packet);12911 -1 break;-1 12184 if (tokens[curr].type === 'text' && -1 12185 curr + 1 < max && -1 12186 tokens[curr + 1].type === 'text') { 12912 1218712913 -1 case parser.BINARY_ACK:12914 -1 this.onack(packet);12915 -1 break;-1 12188 // collapse two adjacent text nodes -1 12189 tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content; -1 12190 } else { -1 12191 if (curr !== last) { tokens[last] = tokens[curr]; } 12916 1219212917 -1 case parser.DISCONNECT:12918 -1 this.ondisconnect();12919 -1 break;-1 12193 last++; -1 12194 } -1 12195 } 12920 1219612921 -1 case parser.ERROR:12922 -1 this.emit('error', packet.data);12923 -1 break;-1 12197 if (curr !== last) { -1 12198 tokens.length = last; 12924 12199 } 12925 12200 }; 12926 1220112927 -1 /**12928 -1 * Called upon a server event.12929 -1 *12930 -1 * @param {Object} packet12931 -1 * @api private12932 -1 */-1 12202 },{}],87:[function(require,module,exports){ -1 12203 // Token class 12933 1220412934 -1 Socket.prototype.onevent = function(packet){12935 -1 var args = packet.data || [];12936 -1 debug('emitting event %j', args);-1 12205 'use strict'; 12937 1220612938 -1 if (null != packet.id) {12939 -1 debug('attaching ack callback to event');12940 -1 args.push(this.ack(packet.id));12941 -1 }12942 1220712943 -1 if (this.connected) {12944 -1 emit.apply(this, args);12945 -1 } else {12946 -1 this.receiveBuffer.push(args);12947 -1 }12948 -1 };-1 12208 /** -1 12209 * class Token -1 12210 **/ 12949 12211 12950 12212 /**12951 -1 * Produces an ack callback to emit with an event.-1 12213 * new Token(type, tag, nesting) 12952 12214 *12953 -1 * @api private12954 -1 */-1 12215 * Create new token and fill passed properties. -1 12216 **/ -1 12217 function Token(type, tag, nesting) { -1 12218 /** -1 12219 * Token#type -> String -1 12220 * -1 12221 * Type of the token (string, e.g. "paragraph_open") -1 12222 **/ -1 12223 this.type = type; 12955 1222412956 -1 Socket.prototype.ack = function(id){12957 -1 var self = this;12958 -1 var sent = false;12959 -1 return function(){12960 -1 // prevent double callbacks12961 -1 if (sent) return;12962 -1 sent = true;12963 -1 var args = toArray(arguments);12964 -1 debug('sending ack %j', args);-1 12225 /** -1 12226 * Token#tag -> String -1 12227 * -1 12228 * html tag name, e.g. "p" -1 12229 **/ -1 12230 this.tag = tag; 12965 1223112966 -1 var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK;12967 -1 self.packet({12968 -1 type: type,12969 -1 id: id,12970 -1 data: args12971 -1 });12972 -1 };12973 -1 };-1 12232 /** -1 12233 * Token#attrs -> Array -1 12234 * -1 12235 * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]` -1 12236 **/ -1 12237 this.attrs = null; 12974 1223812975 -1 /**12976 -1 * Called upon a server acknowlegement.12977 -1 *12978 -1 * @param {Object} packet12979 -1 * @api private12980 -1 */-1 12239 /** -1 12240 * Token#map -> Array -1 12241 * -1 12242 * Source map info. Format: `[ line_begin, line_end ]` -1 12243 **/ -1 12244 this.map = null; 12981 1224512982 -1 Socket.prototype.onack = function(packet){12983 -1 var ack = this.acks[packet.id];12984 -1 if ('function' == typeof ack) {12985 -1 debug('calling ack %s with %j', packet.id, packet.data);12986 -1 ack.apply(this, packet.data);12987 -1 delete this.acks[packet.id];12988 -1 } else {12989 -1 debug('bad ack %s', packet.id);12990 -1 }12991 -1 };-1 12246 /** -1 12247 * Token#nesting -> Number -1 12248 * -1 12249 * Level change (number in {-1, 0, 1} set), where: -1 12250 * -1 12251 * - `1` means the tag is opening -1 12252 * - `0` means the tag is self-closing -1 12253 * - `-1` means the tag is closing -1 12254 **/ -1 12255 this.nesting = nesting; 12992 1225612993 -1 /**12994 -1 * Called upon server connect.12995 -1 *12996 -1 * @api private12997 -1 */-1 12257 /** -1 12258 * Token#level -> Number -1 12259 * -1 12260 * nesting level, the same as `state.level` -1 12261 **/ -1 12262 this.level = 0; -1 12263 -1 12264 /** -1 12265 * Token#children -> Array -1 12266 * -1 12267 * An array of child nodes (inline and img tokens) -1 12268 **/ -1 12269 this.children = null; -1 12270 -1 12271 /** -1 12272 * Token#content -> String -1 12273 * -1 12274 * In a case of self-closing tag (code, html, fence, etc.), -1 12275 * it has contents of this tag. -1 12276 **/ -1 12277 this.content = ''; -1 12278 -1 12279 /** -1 12280 * Token#markup -> String -1 12281 * -1 12282 * '*' or '_' for emphasis, fence string for fence, etc. -1 12283 **/ -1 12284 this.markup = ''; -1 12285 -1 12286 /** -1 12287 * Token#info -> String -1 12288 * -1 12289 * fence infostring -1 12290 **/ -1 12291 this.info = ''; -1 12292 -1 12293 /** -1 12294 * Token#meta -> Object -1 12295 * -1 12296 * A place for plugins to store an arbitrary data -1 12297 **/ -1 12298 this.meta = null; -1 12299 -1 12300 /** -1 12301 * Token#block -> Boolean -1 12302 * -1 12303 * True for block-level tokens, false for inline tokens. -1 12304 * Used in renderer to calculate line breaks -1 12305 **/ -1 12306 this.block = false; -1 12307 -1 12308 /** -1 12309 * Token#hidden -> Boolean -1 12310 * -1 12311 * If it's true, ignore this element when rendering. Used for tight lists -1 12312 * to hide paragraphs. -1 12313 **/ -1 12314 this.hidden = false; -1 12315 } 12998 1231612999 -1 Socket.prototype.onconnect = function(){13000 -1 this.connected = true;13001 -1 this.disconnected = false;13002 -1 this.emit('connect');13003 -1 this.emitBuffered();13004 -1 };13005 12317 13006 12318 /**13007 -1 * Emit buffered events (received and emitted).-1 12319 * Token.attrIndex(name) -> Number 13008 12320 *13009 -1 * @api private13010 -1 */-1 12321 * Search attribute index by name. -1 12322 **/ -1 12323 Token.prototype.attrIndex = function attrIndex(name) { -1 12324 var attrs, i, len; 13011 1232513012 -1 Socket.prototype.emitBuffered = function(){13013 -1 var i;13014 -1 for (i = 0; i < this.receiveBuffer.length; i++) {13015 -1 emit.apply(this, this.receiveBuffer[i]);13016 -1 }13017 -1 this.receiveBuffer = [];-1 12326 if (!this.attrs) { return -1; } 13018 1232713019 -1 for (i = 0; i < this.sendBuffer.length; i++) {13020 -1 this.packet(this.sendBuffer[i]);-1 12328 attrs = this.attrs; -1 12329 -1 12330 for (i = 0, len = attrs.length; i < len; i++) { -1 12331 if (attrs[i][0] === name) { return i; } 13021 12332 }13022 -1 this.sendBuffer = [];-1 12333 return -1; 13023 12334 }; 13024 1233513025 -1 /**13026 -1 * Called upon server disconnect.13027 -1 *13028 -1 * @api private13029 -1 */13030 -113031 -1 Socket.prototype.ondisconnect = function(){13032 -1 debug('server disconnect (%s)', this.nsp);13033 -1 this.destroy();13034 -1 this.onclose('io server disconnect');13035 -1 };13036 12336 13037 12337 /**13038 -1 * Called upon forced client/server side disconnections,13039 -1 * this method ensures the manager stops tracking us and13040 -1 * that reconnections don't get triggered for this.-1 12338 * Token.attrPush(attrData) 13041 12339 *13042 -1 * @api private.13043 -1 */13044 -113045 -1 Socket.prototype.destroy = function(){13046 -1 if (this.subs) {13047 -1 // clean subscriptions to avoid reconnections13048 -1 for (var i = 0; i < this.subs.length; i++) {13049 -1 this.subs[i].destroy();13050 -1 }13051 -1 this.subs = null;-1 12340 * Add `[ name, value ]` attribute to list. Init attrs if necessary -1 12341 **/ -1 12342 Token.prototype.attrPush = function attrPush(attrData) { -1 12343 if (this.attrs) { -1 12344 this.attrs.push(attrData); -1 12345 } else { -1 12346 this.attrs = [ attrData ]; 13052 12347 }13053 -113054 -1 this.io.destroy(this);13055 12348 }; 13056 12349 -1 12350 13057 12351 /**13058 -1 * Disconnects the socket manually.-1 12352 * Token.attrSet(name, value) 13059 12353 *13060 -1 * @return {Socket} self13061 -1 * @api public13062 -1 */-1 12354 * Set `name` attribute to `value`. Override old value if exists. -1 12355 **/ -1 12356 Token.prototype.attrSet = function attrSet(name, value) { -1 12357 var idx = this.attrIndex(name), -1 12358 attrData = [ name, value ]; 13063 1235913064 -1 Socket.prototype.close =13065 -1 Socket.prototype.disconnect = function(){13066 -1 if (this.connected) {13067 -1 debug('performing disconnect (%s)', this.nsp);13068 -1 this.packet({ type: parser.DISCONNECT });-1 12360 if (idx < 0) { -1 12361 this.attrPush(attrData); -1 12362 } else { -1 12363 this.attrs[idx] = attrData; 13069 12364 } -1 12365 }; 13070 1236613071 -1 // remove socket from pool13072 -1 this.destroy();13073 1236713074 -1 if (this.connected) {13075 -1 // fire events13076 -1 this.onclose('io client disconnect');-1 12368 /** -1 12369 * Token.attrGet(name) -1 12370 * -1 12371 * Get the value of attribute `name`, or null if it does not exist. -1 12372 **/ -1 12373 Token.prototype.attrGet = function attrGet(name) { -1 12374 var idx = this.attrIndex(name), value = null; -1 12375 if (idx >= 0) { -1 12376 value = this.attrs[idx][1]; 13077 12377 }13078 -1 return this;-1 12378 return value; 13079 12379 }; 13080 12380 -1 12381 13081 12382 /**13082 -1 * Sets the compress flag.-1 12383 * Token.attrJoin(name, value) 13083 12384 *13084 -1 * @param {Boolean} if `true`, compresses the sending data13085 -1 * @return {Socket} self13086 -1 * @api public13087 -1 */-1 12385 * Join value to existing attribute via space. Or create new attribute if not -1 12386 * exists. Useful to operate with token classes. -1 12387 **/ -1 12388 Token.prototype.attrJoin = function attrJoin(name, value) { -1 12389 var idx = this.attrIndex(name); 13088 1239013089 -1 Socket.prototype.compress = function(compress){13090 -1 this.flags = this.flags || {};13091 -1 this.flags.compress = compress;13092 -1 return this;-1 12391 if (idx < 0) { -1 12392 this.attrPush([ name, value ]); -1 12393 } else { -1 12394 this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value; -1 12395 } 13093 12396 }; 13094 1239713095 -1 },{"./on":102,"component-bind":9,"component-emitter":105,"debug":12,"has-binary":30,"socket.io-parser":107,"to-array":110}],104:[function(require,module,exports){13096 -1 (function (global){13097 -113098 -1 /**13099 -1 * Module dependencies.13100 -1 */13101 1239813102 -1 var parseuri = require('parseuri');13103 -1 var debug = require('debug')('socket.io-client:url');-1 12399 module.exports = Token; 13104 1240013105 -1 /**13106 -1 * Module exports.13107 -1 */-1 12401 },{}],88:[function(require,module,exports){ 13108 1240213109 -1 module.exports = url;-1 12403 'use strict'; 13110 1240413111 -1 /**13112 -1 * URL parser.13113 -1 *13114 -1 * @param {String} url13115 -1 * @param {Object} An object meant to mimic window.location.13116 -1 * Defaults to window.location.13117 -1 * @api public13118 -1 */13119 1240513120 -1 function url(uri, loc){13121 -1 var obj = uri;-1 12406 /* eslint-disable no-bitwise */ 13122 1240713123 -1 // default to window.location13124 -1 var loc = loc || global.location;13125 -1 if (null == uri) uri = loc.protocol + '//' + loc.host;-1 12408 var decodeCache = {}; 13126 1240913127 -1 // relative path support13128 -1 if ('string' == typeof uri) {13129 -1 if ('/' == uri.charAt(0)) {13130 -1 if ('/' == uri.charAt(1)) {13131 -1 uri = loc.protocol + uri;13132 -1 } else {13133 -1 uri = loc.host + uri;13134 -1 }13135 -1 }-1 12410 function getDecodeCache(exclude) { -1 12411 var i, ch, cache = decodeCache[exclude]; -1 12412 if (cache) { return cache; } 13136 1241313137 -1 if (!/^(https?|wss?):\/\//.test(uri)) {13138 -1 debug('protocol-less url %s', uri);13139 -1 if ('undefined' != typeof loc) {13140 -1 uri = loc.protocol + '//' + uri;13141 -1 } else {13142 -1 uri = 'https://' + uri;13143 -1 }13144 -1 }-1 12414 cache = decodeCache[exclude] = []; 13145 1241513146 -1 // parse13147 -1 debug('parse %s', uri);13148 -1 obj = parseuri(uri);-1 12416 for (i = 0; i < 128; i++) { -1 12417 ch = String.fromCharCode(i); -1 12418 cache.push(ch); 13149 12419 } 13150 1242013151 -1 // make sure we treat `localhost:80` and `localhost` equally13152 -1 if (!obj.port) {13153 -1 if (/^(http|ws)$/.test(obj.protocol)) {13154 -1 obj.port = '80';13155 -1 }13156 -1 else if (/^(http|ws)s$/.test(obj.protocol)) {13157 -1 obj.port = '443';13158 -1 }-1 12421 for (i = 0; i < exclude.length; i++) { -1 12422 ch = exclude.charCodeAt(i); -1 12423 cache[ch] = '%' + ('0' + ch.toString(16).toUpperCase()).slice(-2); 13159 12424 } 13160 1242513161 -1 obj.path = obj.path || '/';-1 12426 return cache; -1 12427 } 13162 1242813163 -1 var ipv6 = obj.host.indexOf(':') !== -1;13164 -1 var host = ipv6 ? '[' + obj.host + ']' : obj.host;13165 1242913166 -1 // define unique id13167 -1 obj.id = obj.protocol + '://' + host + ':' + obj.port;13168 -1 // define href13169 -1 obj.href = obj.protocol + '://' + host + (loc && loc.port == obj.port ? '' : (':' + obj.port));-1 12430 // Decode percent-encoded string. -1 12431 // -1 12432 function decode(string, exclude) { -1 12433 var cache; 13170 1243413171 -1 return obj;13172 -1 }-1 12435 if (typeof exclude !== 'string') { -1 12436 exclude = decode.defaultChars; -1 12437 } 13173 1243813174 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})13175 -1 },{"debug":12,"parseuri":99}],105:[function(require,module,exports){-1 12439 cache = getDecodeCache(exclude); 13176 1244013177 -1 /**13178 -1 * Expose `Emitter`.13179 -1 */-1 12441 return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) { -1 12442 var i, l, b1, b2, b3, b4, chr, -1 12443 result = ''; 13180 1244413181 -1 module.exports = Emitter;-1 12445 for (i = 0, l = seq.length; i < l; i += 3) { -1 12446 b1 = parseInt(seq.slice(i + 1, i + 3), 16); 13182 1244713183 -1 /**13184 -1 * Initialize a new `Emitter`.13185 -1 *13186 -1 * @api public13187 -1 */-1 12448 if (b1 < 0x80) { -1 12449 result += cache[b1]; -1 12450 continue; -1 12451 } 13188 1245213189 -1 function Emitter(obj) {13190 -1 if (obj) return mixin(obj);13191 -1 };-1 12453 if ((b1 & 0xE0) === 0xC0 && (i + 3 < l)) { -1 12454 // 110xxxxx 10xxxxxx -1 12455 b2 = parseInt(seq.slice(i + 4, i + 6), 16); 13192 1245613193 -1 /**13194 -1 * Mixin the emitter properties.13195 -1 *13196 -1 * @param {Object} obj13197 -1 * @return {Object}13198 -1 * @api private13199 -1 */-1 12457 if ((b2 & 0xC0) === 0x80) { -1 12458 chr = ((b1 << 6) & 0x7C0) | (b2 & 0x3F); 13200 1245913201 -1 function mixin(obj) {13202 -1 for (var key in Emitter.prototype) {13203 -1 obj[key] = Emitter.prototype[key];13204 -1 }13205 -1 return obj;13206 -1 }-1 12460 if (chr < 0x80) { -1 12461 result += '\ufffd\ufffd'; -1 12462 } else { -1 12463 result += String.fromCharCode(chr); -1 12464 } 13207 1246513208 -1 /**13209 -1 * Listen on the given `event` with `fn`.13210 -1 *13211 -1 * @param {String} event13212 -1 * @param {Function} fn13213 -1 * @return {Emitter}13214 -1 * @api public13215 -1 */-1 12466 i += 3; -1 12467 continue; -1 12468 } -1 12469 } 13216 1247013217 -1 Emitter.prototype.on =13218 -1 Emitter.prototype.addEventListener = function(event, fn){13219 -1 this._callbacks = this._callbacks || {};13220 -1 (this._callbacks['$' + event] = this._callbacks['$' + event] || [])13221 -1 .push(fn);13222 -1 return this;13223 -1 };-1 12471 if ((b1 & 0xF0) === 0xE0 && (i + 6 < l)) { -1 12472 // 1110xxxx 10xxxxxx 10xxxxxx -1 12473 b2 = parseInt(seq.slice(i + 4, i + 6), 16); -1 12474 b3 = parseInt(seq.slice(i + 7, i + 9), 16); -1 12475 -1 12476 if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) { -1 12477 chr = ((b1 << 12) & 0xF000) | ((b2 << 6) & 0xFC0) | (b3 & 0x3F); -1 12478 -1 12479 if (chr < 0x800 || (chr >= 0xD800 && chr <= 0xDFFF)) { -1 12480 result += '\ufffd\ufffd\ufffd'; -1 12481 } else { -1 12482 result += String.fromCharCode(chr); -1 12483 } -1 12484 -1 12485 i += 6; -1 12486 continue; -1 12487 } -1 12488 } 13224 1248913225 -1 /**13226 -1 * Adds an `event` listener that will be invoked a single13227 -1 * time then automatically removed.13228 -1 *13229 -1 * @param {String} event13230 -1 * @param {Function} fn13231 -1 * @return {Emitter}13232 -1 * @api public13233 -1 */-1 12490 if ((b1 & 0xF8) === 0xF0 && (i + 9 < l)) { -1 12491 // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx -1 12492 b2 = parseInt(seq.slice(i + 4, i + 6), 16); -1 12493 b3 = parseInt(seq.slice(i + 7, i + 9), 16); -1 12494 b4 = parseInt(seq.slice(i + 10, i + 12), 16); 13234 1249513235 -1 Emitter.prototype.once = function(event, fn){13236 -1 function on() {13237 -1 this.off(event, on);13238 -1 fn.apply(this, arguments);13239 -1 }-1 12496 if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80 && (b4 & 0xC0) === 0x80) { -1 12497 chr = ((b1 << 18) & 0x1C0000) | ((b2 << 12) & 0x3F000) | ((b3 << 6) & 0xFC0) | (b4 & 0x3F); 13240 1249813241 -1 on.fn = fn;13242 -1 this.on(event, on);13243 -1 return this;13244 -1 };-1 12499 if (chr < 0x10000 || chr > 0x10FFFF) { -1 12500 result += '\ufffd\ufffd\ufffd\ufffd'; -1 12501 } else { -1 12502 chr -= 0x10000; -1 12503 result += String.fromCharCode(0xD800 + (chr >> 10), 0xDC00 + (chr & 0x3FF)); -1 12504 } 13245 1250513246 -1 /**13247 -1 * Remove the given callback for `event` or all13248 -1 * registered callbacks.13249 -1 *13250 -1 * @param {String} event13251 -1 * @param {Function} fn13252 -1 * @return {Emitter}13253 -1 * @api public13254 -1 */-1 12506 i += 9; -1 12507 continue; -1 12508 } -1 12509 } 13255 1251013256 -1 Emitter.prototype.off =13257 -1 Emitter.prototype.removeListener =13258 -1 Emitter.prototype.removeAllListeners =13259 -1 Emitter.prototype.removeEventListener = function(event, fn){13260 -1 this._callbacks = this._callbacks || {};-1 12511 result += '\ufffd'; -1 12512 } 13261 1251313262 -1 // all13263 -1 if (0 == arguments.length) {13264 -1 this._callbacks = {};13265 -1 return this;13266 -1 }-1 12514 return result; -1 12515 }); -1 12516 } 13267 1251713268 -1 // specific event13269 -1 var callbacks = this._callbacks['$' + event];13270 -1 if (!callbacks) return this;13271 1251813272 -1 // remove all handlers13273 -1 if (1 == arguments.length) {13274 -1 delete this._callbacks['$' + event];13275 -1 return this;13276 -1 }-1 12519 decode.defaultChars = ';/?:@&=+$,#'; -1 12520 decode.componentChars = ''; 13277 1252113278 -1 // remove specific handler13279 -1 var cb;13280 -1 for (var i = 0; i < callbacks.length; i++) {13281 -1 cb = callbacks[i];13282 -1 if (cb === fn || cb.fn === fn) {13283 -1 callbacks.splice(i, 1);13284 -1 break;13285 -1 }13286 -1 }13287 -1 return this;13288 -1 };13289 1252213290 -1 /**13291 -1 * Emit `event` with the given args.13292 -1 *13293 -1 * @param {String} event13294 -1 * @param {Mixed} ...13295 -1 * @return {Emitter}13296 -1 */-1 12523 module.exports = decode; 13297 1252413298 -1 Emitter.prototype.emit = function(event){13299 -1 this._callbacks = this._callbacks || {};13300 -1 var args = [].slice.call(arguments, 1)13301 -1 , callbacks = this._callbacks['$' + event];-1 12525 },{}],89:[function(require,module,exports){ 13302 1252613303 -1 if (callbacks) {13304 -1 callbacks = callbacks.slice(0);13305 -1 for (var i = 0, len = callbacks.length; i < len; ++i) {13306 -1 callbacks[i].apply(this, args);13307 -1 }13308 -1 }-1 12527 'use strict'; 13309 1252813310 -1 return this;13311 -1 };13312 1252913313 -1 /**13314 -1 * Return array of callbacks for `event`.13315 -1 *13316 -1 * @param {String} event13317 -1 * @return {Array}13318 -1 * @api public13319 -1 */-1 12530 var encodeCache = {}; 13320 1253113321 -1 Emitter.prototype.listeners = function(event){13322 -1 this._callbacks = this._callbacks || {};13323 -1 return this._callbacks['$' + event] || [];13324 -1 };13325 1253213326 -1 /**13327 -1 * Check if this emitter has `event` handlers.13328 -1 *13329 -1 * @param {String} event13330 -1 * @return {Boolean}13331 -1 * @api public13332 -1 */-1 12533 // Create a lookup array where anything but characters in `chars` string -1 12534 // and alphanumeric chars is percent-encoded. -1 12535 // -1 12536 function getEncodeCache(exclude) { -1 12537 var i, ch, cache = encodeCache[exclude]; -1 12538 if (cache) { return cache; } 13333 1253913334 -1 Emitter.prototype.hasListeners = function(event){13335 -1 return !! this.listeners(event).length;13336 -1 };-1 12540 cache = encodeCache[exclude] = []; 13337 1254113338 -1 },{}],106:[function(require,module,exports){13339 -1 (function (global){13340 -1 /*global Blob,File*/-1 12542 for (i = 0; i < 128; i++) { -1 12543 ch = String.fromCharCode(i); 13341 1254413342 -1 /**13343 -1 * Module requirements13344 -1 */-1 12545 if (/^[0-9a-z]$/i.test(ch)) { -1 12546 // always allow unencoded alphanumeric characters -1 12547 cache.push(ch); -1 12548 } else { -1 12549 cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2)); -1 12550 } -1 12551 } 13345 1255213346 -1 var isArray = require('isarray');13347 -1 var isBuf = require('./is-buffer');-1 12553 for (i = 0; i < exclude.length; i++) { -1 12554 cache[exclude.charCodeAt(i)] = exclude[i]; -1 12555 } 13348 1255613349 -1 /**13350 -1 * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.13351 -1 * Anything with blobs or files should be fed through removeBlobs before coming13352 -1 * here.13353 -1 *13354 -1 * @param {Object} packet - socket.io event packet13355 -1 * @return {Object} with deconstructed packet and list of buffers13356 -1 * @api public13357 -1 */-1 12557 return cache; -1 12558 } 13358 1255913359 -1 exports.deconstructPacket = function(packet){13360 -1 var buffers = [];13361 -1 var packetData = packet.data;13362 1256013363 -1 function _deconstructPacket(data) {13364 -1 if (!data) return data;-1 12561 // Encode unsafe characters with percent-encoding, skipping already -1 12562 // encoded sequences. -1 12563 // -1 12564 // - string - string to encode -1 12565 // - exclude - list of characters to ignore (in addition to a-zA-Z0-9) -1 12566 // - keepEscaped - don't encode '%' in a correct escape sequence (default: true) -1 12567 // -1 12568 function encode(string, exclude, keepEscaped) { -1 12569 var i, l, code, nextCode, cache, -1 12570 result = ''; 13365 1257113366 -1 if (isBuf(data)) {13367 -1 var placeholder = { _placeholder: true, num: buffers.length };13368 -1 buffers.push(data);13369 -1 return placeholder;13370 -1 } else if (isArray(data)) {13371 -1 var newData = new Array(data.length);13372 -1 for (var i = 0; i < data.length; i++) {13373 -1 newData[i] = _deconstructPacket(data[i]);13374 -1 }13375 -1 return newData;13376 -1 } else if ('object' == typeof data && !(data instanceof Date)) {13377 -1 var newData = {};13378 -1 for (var key in data) {13379 -1 newData[key] = _deconstructPacket(data[key]);13380 -1 }13381 -1 return newData;13382 -1 }13383 -1 return data;-1 12572 if (typeof exclude !== 'string') { -1 12573 // encode(string, keepEscaped) -1 12574 keepEscaped = exclude; -1 12575 exclude = encode.defaultChars; 13384 12576 } 13385 1257713386 -1 var pack = packet;13387 -1 pack.data = _deconstructPacket(packetData);13388 -1 pack.attachments = buffers.length; // number of binary 'attachments'13389 -1 return {packet: pack, buffers: buffers};13390 -1 };-1 12578 if (typeof keepEscaped === 'undefined') { -1 12579 keepEscaped = true; -1 12580 } 13391 1258113392 -1 /**13393 -1 * Reconstructs a binary packet from its placeholder packet and buffers13394 -1 *13395 -1 * @param {Object} packet - event packet with placeholders13396 -1 * @param {Array} buffers - binary buffers to put in placeholder positions13397 -1 * @return {Object} reconstructed packet13398 -1 * @api public13399 -1 */-1 12582 cache = getEncodeCache(exclude); 13400 1258313401 -1 exports.reconstructPacket = function(packet, buffers) {13402 -1 var curPlaceHolder = 0;-1 12584 for (i = 0, l = string.length; i < l; i++) { -1 12585 code = string.charCodeAt(i); 13403 1258613404 -1 function _reconstructPacket(data) {13405 -1 if (data && data._placeholder) {13406 -1 var buf = buffers[data.num]; // appropriate buffer (should be natural order anyway)13407 -1 return buf;13408 -1 } else if (isArray(data)) {13409 -1 for (var i = 0; i < data.length; i++) {13410 -1 data[i] = _reconstructPacket(data[i]);-1 12587 if (keepEscaped && code === 0x25 /* % */ && i + 2 < l) { -1 12588 if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) { -1 12589 result += string.slice(i, i + 3); -1 12590 i += 2; -1 12591 continue; 13411 12592 }13412 -1 return data;13413 -1 } else if (data && 'object' == typeof data) {13414 -1 for (var key in data) {13415 -1 data[key] = _reconstructPacket(data[key]);-1 12593 } -1 12594 -1 12595 if (code < 128) { -1 12596 result += cache[code]; -1 12597 continue; -1 12598 } -1 12599 -1 12600 if (code >= 0xD800 && code <= 0xDFFF) { -1 12601 if (code >= 0xD800 && code <= 0xDBFF && i + 1 < l) { -1 12602 nextCode = string.charCodeAt(i + 1); -1 12603 if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) { -1 12604 result += encodeURIComponent(string[i] + string[i + 1]); -1 12605 i++; -1 12606 continue; -1 12607 } 13416 12608 }13417 -1 return data;-1 12609 result += '%EF%BF%BD'; -1 12610 continue; 13418 12611 }13419 -1 return data;-1 12612 -1 12613 result += encodeURIComponent(string[i]); 13420 12614 } 13421 1261513422 -1 packet.data = _reconstructPacket(packet.data);13423 -1 packet.attachments = undefined; // no longer useful13424 -1 return packet;13425 -1 };-1 12616 return result; -1 12617 } -1 12618 -1 12619 encode.defaultChars = ";/?:@&=+$,-_.!~*'()#"; -1 12620 encode.componentChars = "-_.!~*'()"; -1 12621 13426 1262213427 -1 /**13428 -1 * Asynchronously removes Blobs or Files from data via13429 -1 * FileReader's readAsArrayBuffer method. Used before encoding13430 -1 * data as msgpack. Calls callback with the blobless data.13431 -1 *13432 -1 * @param {Object} data13433 -1 * @param {Function} callback13434 -1 * @api private13435 -1 */-1 12623 module.exports = encode; 13436 1262413437 -1 exports.removeBlobs = function(data, callback) {13438 -1 function _removeBlobs(obj, curKey, containingObject) {13439 -1 if (!obj) return obj;-1 12625 },{}],90:[function(require,module,exports){ 13440 1262613441 -1 // convert any blob13442 -1 if ((global.Blob && obj instanceof Blob) ||13443 -1 (global.File && obj instanceof File)) {13444 -1 pendingBlobs++;-1 12627 'use strict'; 13445 1262813446 -1 // async filereader13447 -1 var fileReader = new FileReader();13448 -1 fileReader.onload = function() { // this.result == arraybuffer13449 -1 if (containingObject) {13450 -1 containingObject[curKey] = this.result;13451 -1 }13452 -1 else {13453 -1 bloblessData = this.result;13454 -1 }13455 1262913456 -1 // if nothing pending its callback time13457 -1 if(! --pendingBlobs) {13458 -1 callback(bloblessData);13459 -1 }13460 -1 };-1 12630 module.exports = function format(url) { -1 12631 var result = ''; 13461 1263213462 -1 fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer13463 -1 } else if (isArray(obj)) { // handle array13464 -1 for (var i = 0; i < obj.length; i++) {13465 -1 _removeBlobs(obj[i], i, obj);13466 -1 }13467 -1 } else if (obj && 'object' == typeof obj && !isBuf(obj)) { // and object13468 -1 for (var key in obj) {13469 -1 _removeBlobs(obj[key], key, obj);13470 -1 }13471 -1 }13472 -1 }-1 12633 result += url.protocol || ''; -1 12634 result += url.slashes ? '//' : ''; -1 12635 result += url.auth ? url.auth + '@' : ''; 13473 1263613474 -1 var pendingBlobs = 0;13475 -1 var bloblessData = data;13476 -1 _removeBlobs(bloblessData);13477 -1 if (!pendingBlobs) {13478 -1 callback(bloblessData);-1 12637 if (url.hostname && url.hostname.indexOf(':') !== -1) { -1 12638 // ipv6 address -1 12639 result += '[' + url.hostname + ']'; -1 12640 } else { -1 12641 result += url.hostname || ''; 13479 12642 } -1 12643 -1 12644 result += url.port ? ':' + url.port : ''; -1 12645 result += url.pathname || ''; -1 12646 result += url.search || ''; -1 12647 result += url.hash || ''; -1 12648 -1 12649 return result; 13480 12650 }; 13481 1265113482 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})13483 -1 },{"./is-buffer":108,"isarray":36}],107:[function(require,module,exports){-1 12652 },{}],91:[function(require,module,exports){ -1 12653 'use strict'; 13484 1265413485 -1 /**13486 -1 * Module dependencies.13487 -1 */13488 1265513489 -1 var debug = require('debug')('socket.io-parser');13490 -1 var json = require('json3');13491 -1 var isArray = require('isarray');13492 -1 var Emitter = require('component-emitter');13493 -1 var binary = require('./binary');13494 -1 var isBuf = require('./is-buffer');-1 12656 module.exports.encode = require('./encode'); -1 12657 module.exports.decode = require('./decode'); -1 12658 module.exports.format = require('./format'); -1 12659 module.exports.parse = require('./parse'); 13495 1266013496 -1 /**13497 -1 * Protocol version.13498 -1 *13499 -1 * @api public13500 -1 */-1 12661 },{"./decode":88,"./encode":89,"./format":90,"./parse":92}],92:[function(require,module,exports){ -1 12662 // Copyright Joyent, Inc. and other Node contributors. -1 12663 // -1 12664 // Permission is hereby granted, free of charge, to any person obtaining a -1 12665 // copy of this software and associated documentation files (the -1 12666 // "Software"), to deal in the Software without restriction, including -1 12667 // without limitation the rights to use, copy, modify, merge, publish, -1 12668 // distribute, sublicense, and/or sell copies of the Software, and to permit -1 12669 // persons to whom the Software is furnished to do so, subject to the -1 12670 // following conditions: -1 12671 // -1 12672 // The above copyright notice and this permission notice shall be included -1 12673 // in all copies or substantial portions of the Software. -1 12674 // -1 12675 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -1 12676 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -1 12677 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -1 12678 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -1 12679 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -1 12680 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -1 12681 // USE OR OTHER DEALINGS IN THE SOFTWARE. 13501 1268213502 -1 exports.protocol = 4;-1 12683 'use strict'; 13503 1268413504 -1 /**13505 -1 * Packet types.13506 -1 *13507 -1 * @api public13508 -1 */-1 12685 // -1 12686 // Changes from joyent/node: -1 12687 // -1 12688 // 1. No leading slash in paths, -1 12689 // e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/` -1 12690 // -1 12691 // 2. Backslashes are not replaced with slashes, -1 12692 // so `http:\\example.org\` is treated like a relative path -1 12693 // -1 12694 // 3. Trailing colon is treated like a part of the path, -1 12695 // i.e. in `http://example.org:foo` pathname is `:foo` -1 12696 // -1 12697 // 4. Nothing is URL-encoded in the resulting object, -1 12698 // (in joyent/node some chars in auth and paths are encoded) -1 12699 // -1 12700 // 5. `url.parse()` does not have `parseQueryString` argument -1 12701 // -1 12702 // 6. Removed extraneous result properties: `host`, `path`, `query`, etc., -1 12703 // which can be constructed using other parts of the url. -1 12704 // 13509 1270513510 -1 exports.types = [13511 -1 'CONNECT',13512 -1 'DISCONNECT',13513 -1 'EVENT',13514 -1 'ACK',13515 -1 'ERROR',13516 -1 'BINARY_EVENT',13517 -1 'BINARY_ACK'13518 -1 ];13519 1270613520 -1 /**13521 -1 * Packet type `connect`.13522 -1 *13523 -1 * @api public13524 -1 */-1 12707 function Url() { -1 12708 this.protocol = null; -1 12709 this.slashes = null; -1 12710 this.auth = null; -1 12711 this.port = null; -1 12712 this.hostname = null; -1 12713 this.hash = null; -1 12714 this.search = null; -1 12715 this.pathname = null; -1 12716 } 13525 1271713526 -1 exports.CONNECT = 0;-1 12718 // Reference: RFC 3986, RFC 1808, RFC 2396 13527 1271913528 -1 /**13529 -1 * Packet type `disconnect`.13530 -1 *13531 -1 * @api public13532 -1 */-1 12720 // define these here so at least they only have to be -1 12721 // compiled once on the first module load. -1 12722 var protocolPattern = /^([a-z0-9.+-]+:)/i, -1 12723 portPattern = /:[0-9]*$/, 13533 1272413534 -1 exports.DISCONNECT = 1;-1 12725 // Special case for a simple path URL -1 12726 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, 13535 1272713536 -1 /**13537 -1 * Packet type `event`.13538 -1 *13539 -1 * @api public13540 -1 */-1 12728 // RFC 2396: characters reserved for delimiting URLs. -1 12729 // We actually just auto-escape these. -1 12730 delims = [ '<', '>', '"', '`', ' ', '\r', '\n', '\t' ], 13541 1273113542 -1 exports.EVENT = 2;-1 12732 // RFC 2396: characters not allowed for various reasons. -1 12733 unwise = [ '{', '}', '|', '\\', '^', '`' ].concat(delims), 13543 1273413544 -1 /**13545 -1 * Packet type `ack`.13546 -1 *13547 -1 * @api public13548 -1 */-1 12735 // Allowed by RFCs, but cause of XSS attacks. Always escape these. -1 12736 autoEscape = [ '\'' ].concat(unwise), -1 12737 // Characters that are never ever allowed in a hostname. -1 12738 // Note that any invalid chars are also handled, but these -1 12739 // are the ones that are *expected* to be seen, so we fast-path -1 12740 // them. -1 12741 nonHostChars = [ '%', '/', '?', ';', '#' ].concat(autoEscape), -1 12742 hostEndingChars = [ '/', '?', '#' ], -1 12743 hostnameMaxLen = 255, -1 12744 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, -1 12745 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, -1 12746 // protocols that can allow "unsafe" and "unwise" chars. -1 12747 /* eslint-disable no-script-url */ -1 12748 // protocols that never have a hostname. -1 12749 hostlessProtocol = { -1 12750 'javascript': true, -1 12751 'javascript:': true -1 12752 }, -1 12753 // protocols that always contain a // bit. -1 12754 slashedProtocol = { -1 12755 'http': true, -1 12756 'https': true, -1 12757 'ftp': true, -1 12758 'gopher': true, -1 12759 'file': true, -1 12760 'http:': true, -1 12761 'https:': true, -1 12762 'ftp:': true, -1 12763 'gopher:': true, -1 12764 'file:': true -1 12765 }; -1 12766 /* eslint-enable no-script-url */ -1 12767 -1 12768 function urlParse(url, slashesDenoteHost) { -1 12769 if (url && url instanceof Url) { return url; } -1 12770 -1 12771 var u = new Url(); -1 12772 u.parse(url, slashesDenoteHost); -1 12773 return u; -1 12774 } -1 12775 -1 12776 Url.prototype.parse = function(url, slashesDenoteHost) { -1 12777 var i, l, lowerProto, hec, slashes, -1 12778 rest = url; -1 12779 -1 12780 // trim before proceeding. -1 12781 // This is to support parse stuff like " http://foo.com \n" -1 12782 rest = rest.trim(); -1 12783 -1 12784 if (!slashesDenoteHost && url.split('#').length === 1) { -1 12785 // Try fast path regexp -1 12786 var simplePath = simplePathPattern.exec(rest); -1 12787 if (simplePath) { -1 12788 this.pathname = simplePath[1]; -1 12789 if (simplePath[2]) { -1 12790 this.search = simplePath[2]; -1 12791 } -1 12792 return this; -1 12793 } -1 12794 } -1 12795 -1 12796 var proto = protocolPattern.exec(rest); -1 12797 if (proto) { -1 12798 proto = proto[0]; -1 12799 lowerProto = proto.toLowerCase(); -1 12800 this.protocol = proto; -1 12801 rest = rest.substr(proto.length); -1 12802 } 13549 1280313550 -1 exports.ACK = 3;-1 12804 // figure out if it's got a host -1 12805 // user@server is *always* interpreted as a hostname, and url -1 12806 // resolution will treat //foo/bar as host=foo,path=bar because that's -1 12807 // how the browser resolves relative URLs. -1 12808 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { -1 12809 slashes = rest.substr(0, 2) === '//'; -1 12810 if (slashes && !(proto && hostlessProtocol[proto])) { -1 12811 rest = rest.substr(2); -1 12812 this.slashes = true; -1 12813 } -1 12814 } 13551 1281513552 -1 /**13553 -1 * Packet type `error`.13554 -1 *13555 -1 * @api public13556 -1 */-1 12816 if (!hostlessProtocol[proto] && -1 12817 (slashes || (proto && !slashedProtocol[proto]))) { 13557 1281813558 -1 exports.ERROR = 4;-1 12819 // there's a hostname. -1 12820 // the first instance of /, ?, ;, or # ends the host. -1 12821 // -1 12822 // If there is an @ in the hostname, then non-host chars *are* allowed -1 12823 // to the left of the last @ sign, unless some host-ending character -1 12824 // comes *before* the @-sign. -1 12825 // URLs are obnoxious. -1 12826 // -1 12827 // ex: -1 12828 // http://a@b@c/ => user:a@b host:c -1 12829 // http://a@b?@c => user:a host:c path:/?@c 13559 1283013560 -1 /**13561 -1 * Packet type 'binary event'13562 -1 *13563 -1 * @api public13564 -1 */-1 12831 // v0.12 TODO(isaacs): This is not quite how Chrome does things. -1 12832 // Review our test case against browsers more comprehensively. 13565 1283313566 -1 exports.BINARY_EVENT = 5;-1 12834 // find the first instance of any hostEndingChars -1 12835 var hostEnd = -1; -1 12836 for (i = 0; i < hostEndingChars.length; i++) { -1 12837 hec = rest.indexOf(hostEndingChars[i]); -1 12838 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) { -1 12839 hostEnd = hec; -1 12840 } -1 12841 } 13567 1284213568 -1 /**13569 -1 * Packet type `binary ack`. For acks with binary arguments.13570 -1 *13571 -1 * @api public13572 -1 */-1 12843 // at this point, either we have an explicit point where the -1 12844 // auth portion cannot go past, or the last @ char is the decider. -1 12845 var auth, atSign; -1 12846 if (hostEnd === -1) { -1 12847 // atSign can be anywhere. -1 12848 atSign = rest.lastIndexOf('@'); -1 12849 } else { -1 12850 // atSign must be in auth portion. -1 12851 // http://a@b/c@d => host:b auth:a path:/c@d -1 12852 atSign = rest.lastIndexOf('@', hostEnd); -1 12853 } 13573 1285413574 -1 exports.BINARY_ACK = 6;-1 12855 // Now we have a portion which is definitely the auth. -1 12856 // Pull that off. -1 12857 if (atSign !== -1) { -1 12858 auth = rest.slice(0, atSign); -1 12859 rest = rest.slice(atSign + 1); -1 12860 this.auth = auth; -1 12861 } 13575 1286213576 -1 /**13577 -1 * Encoder constructor.13578 -1 *13579 -1 * @api public13580 -1 */-1 12863 // the host is the remaining to the left of the first non-host char -1 12864 hostEnd = -1; -1 12865 for (i = 0; i < nonHostChars.length; i++) { -1 12866 hec = rest.indexOf(nonHostChars[i]); -1 12867 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) { -1 12868 hostEnd = hec; -1 12869 } -1 12870 } -1 12871 // if we still have not hit it, then the entire thing is a host. -1 12872 if (hostEnd === -1) { -1 12873 hostEnd = rest.length; -1 12874 } 13581 1287513582 -1 exports.Encoder = Encoder;-1 12876 if (rest[hostEnd - 1] === ':') { hostEnd--; } -1 12877 var host = rest.slice(0, hostEnd); -1 12878 rest = rest.slice(hostEnd); 13583 1287913584 -1 /**13585 -1 * Decoder constructor.13586 -1 *13587 -1 * @api public13588 -1 */-1 12880 // pull out port. -1 12881 this.parseHost(host); 13589 1288213590 -1 exports.Decoder = Decoder;-1 12883 // we've indicated that there is a hostname, -1 12884 // so even if it's empty, it has to be present. -1 12885 this.hostname = this.hostname || ''; 13591 1288613592 -1 /**13593 -1 * A socket.io Encoder instance13594 -1 *13595 -1 * @api public13596 -1 */-1 12887 // if hostname begins with [ and ends with ] -1 12888 // assume that it's an IPv6 address. -1 12889 var ipv6Hostname = this.hostname[0] === '[' && -1 12890 this.hostname[this.hostname.length - 1] === ']'; 13597 1289113598 -1 function Encoder() {}-1 12892 // validate a little. -1 12893 if (!ipv6Hostname) { -1 12894 var hostparts = this.hostname.split(/\./); -1 12895 for (i = 0, l = hostparts.length; i < l; i++) { -1 12896 var part = hostparts[i]; -1 12897 if (!part) { continue; } -1 12898 if (!part.match(hostnamePartPattern)) { -1 12899 var newpart = ''; -1 12900 for (var j = 0, k = part.length; j < k; j++) { -1 12901 if (part.charCodeAt(j) > 127) { -1 12902 // we replace non-ASCII char with a temporary placeholder -1 12903 // we need this to make sure size of hostname is not -1 12904 // broken by replacing non-ASCII by nothing -1 12905 newpart += 'x'; -1 12906 } else { -1 12907 newpart += part[j]; -1 12908 } -1 12909 } -1 12910 // we test again with ASCII char only -1 12911 if (!newpart.match(hostnamePartPattern)) { -1 12912 var validParts = hostparts.slice(0, i); -1 12913 var notHost = hostparts.slice(i + 1); -1 12914 var bit = part.match(hostnamePartStart); -1 12915 if (bit) { -1 12916 validParts.push(bit[1]); -1 12917 notHost.unshift(bit[2]); -1 12918 } -1 12919 if (notHost.length) { -1 12920 rest = notHost.join('.') + rest; -1 12921 } -1 12922 this.hostname = validParts.join('.'); -1 12923 break; -1 12924 } -1 12925 } -1 12926 } -1 12927 } 13599 1292813600 -1 /**13601 -1 * Encode a packet as a single string if non-binary, or as a13602 -1 * buffer sequence, depending on packet type.13603 -1 *13604 -1 * @param {Object} obj - packet object13605 -1 * @param {Function} callback - function to handle encodings (likely engine.write)13606 -1 * @return Calls callback with Array of encodings13607 -1 * @api public13608 -1 */-1 12929 if (this.hostname.length > hostnameMaxLen) { -1 12930 this.hostname = ''; -1 12931 } 13609 1293213610 -1 Encoder.prototype.encode = function(obj, callback){13611 -1 debug('encoding packet %j', obj);-1 12933 // strip [ and ] from the hostname -1 12934 // the host field still retains them, though -1 12935 if (ipv6Hostname) { -1 12936 this.hostname = this.hostname.substr(1, this.hostname.length - 2); -1 12937 } -1 12938 } 13612 1293913613 -1 if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) {13614 -1 encodeAsBinary(obj, callback);-1 12940 // chop off from the tail first. -1 12941 var hash = rest.indexOf('#'); -1 12942 if (hash !== -1) { -1 12943 // got a fragment string. -1 12944 this.hash = rest.substr(hash); -1 12945 rest = rest.slice(0, hash); 13615 12946 }13616 -1 else {13617 -1 var encoding = encodeAsString(obj);13618 -1 callback([encoding]);-1 12947 var qm = rest.indexOf('?'); -1 12948 if (qm !== -1) { -1 12949 this.search = rest.substr(qm); -1 12950 rest = rest.slice(0, qm); -1 12951 } -1 12952 if (rest) { this.pathname = rest; } -1 12953 if (slashedProtocol[lowerProto] && -1 12954 this.hostname && !this.pathname) { -1 12955 this.pathname = ''; 13619 12956 }13620 -1 };13621 -113622 -1 /**13623 -1 * Encode packet as string.13624 -1 *13625 -1 * @param {Object} packet13626 -1 * @return {String} encoded13627 -1 * @api private13628 -1 */13629 -113630 -1 function encodeAsString(obj) {13631 -1 var str = '';13632 -1 var nsp = false;13633 1295713634 -1 // first is type13635 -1 str += obj.type;-1 12958 return this; -1 12959 }; 13636 1296013637 -1 // attachments if we have them13638 -1 if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) {13639 -1 str += obj.attachments;13640 -1 str += '-';-1 12961 Url.prototype.parseHost = function(host) { -1 12962 var port = portPattern.exec(host); -1 12963 if (port) { -1 12964 port = port[0]; -1 12965 if (port !== ':') { -1 12966 this.port = port.substr(1); -1 12967 } -1 12968 host = host.substr(0, host.length - port.length); 13641 12969 } -1 12970 if (host) { this.hostname = host; } -1 12971 }; 13642 1297213643 -1 // if we have a namespace other than `/`13644 -1 // we append it followed by a comma `,`13645 -1 if (obj.nsp && '/' != obj.nsp) {13646 -1 nsp = true;13647 -1 str += obj.nsp;13648 -1 }-1 12973 module.exports = urlParse; -1 12974 -1 12975 },{}],93:[function(require,module,exports){ -1 12976 (function (global){ -1 12977 /** -1 12978 * JSON parse. -1 12979 * -1 12980 * @see Based on jQuery#parseJSON (MIT) and JSON2 -1 12981 * @api private -1 12982 */ -1 12983 -1 12984 var rvalidchars = /^[\],:{}\s]*$/; -1 12985 var rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g; -1 12986 var rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; -1 12987 var rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g; -1 12988 var rtrimLeft = /^\s+/; -1 12989 var rtrimRight = /\s+$/; -1 12990 -1 12991 module.exports = function parsejson(data) { -1 12992 if ('string' != typeof data || !data) { -1 12993 return null; -1 12994 } -1 12995 -1 12996 data = data.replace(rtrimLeft, '').replace(rtrimRight, ''); -1 12997 -1 12998 // Attempt to parse using the native JSON parser first -1 12999 if (global.JSON && JSON.parse) { -1 13000 return JSON.parse(data); -1 13001 } -1 13002 -1 13003 if (rvalidchars.test(data.replace(rvalidescape, '@') -1 13004 .replace(rvalidtokens, ']') -1 13005 .replace(rvalidbraces, ''))) { -1 13006 return (new Function('return ' + data))(); -1 13007 } -1 13008 }; -1 13009 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 13010 },{}],94:[function(require,module,exports){ -1 13011 /** -1 13012 * Compiles a querystring -1 13013 * Returns string representation of the object -1 13014 * -1 13015 * @param {Object} -1 13016 * @api private -1 13017 */ -1 13018 -1 13019 exports.encode = function (obj) { -1 13020 var str = ''; -1 13021 -1 13022 for (var i in obj) { -1 13023 if (obj.hasOwnProperty(i)) { -1 13024 if (str.length) str += '&'; -1 13025 str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); -1 13026 } -1 13027 } -1 13028 -1 13029 return str; -1 13030 }; -1 13031 -1 13032 /** -1 13033 * Parses a simple querystring into an object -1 13034 * -1 13035 * @param {String} qs -1 13036 * @api private -1 13037 */ -1 13038 -1 13039 exports.decode = function(qs){ -1 13040 var qry = {}; -1 13041 var pairs = qs.split('&'); -1 13042 for (var i = 0, l = pairs.length; i < l; i++) { -1 13043 var pair = pairs[i].split('='); -1 13044 qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); -1 13045 } -1 13046 return qry; -1 13047 }; -1 13048 -1 13049 },{}],95:[function(require,module,exports){ -1 13050 /** -1 13051 * Parses an URI -1 13052 * -1 13053 * @author Steven Levithan <stevenlevithan.com> (MIT license) -1 13054 * @api private -1 13055 */ -1 13056 -1 13057 var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; -1 13058 -1 13059 var parts = [ -1 13060 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' -1 13061 ]; -1 13062 -1 13063 module.exports = function parseuri(str) { -1 13064 var src = str, -1 13065 b = str.indexOf('['), -1 13066 e = str.indexOf(']'); -1 13067 -1 13068 if (b != -1 && e != -1) { -1 13069 str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); -1 13070 } -1 13071 -1 13072 var m = re.exec(str || ''), -1 13073 uri = {}, -1 13074 i = 14; -1 13075 -1 13076 while (i--) { -1 13077 uri[parts[i]] = m[i] || ''; -1 13078 } -1 13079 -1 13080 if (b != -1 && e != -1) { -1 13081 uri.source = src; -1 13082 uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); -1 13083 uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); -1 13084 uri.ipv6uri = true; -1 13085 } -1 13086 -1 13087 return uri; -1 13088 }; 13649 1308913650 -1 // immediately followed by the id13651 -1 if (null != obj.id) {13652 -1 if (nsp) {13653 -1 str += ',';13654 -1 nsp = false;-1 13090 },{}],96:[function(require,module,exports){ -1 13091 !function() { -1 13092 'use strict'; -1 13093 function VNode() {} -1 13094 function h(nodeName, attributes) { -1 13095 var lastSimple, child, simple, i, children = EMPTY_CHILDREN; -1 13096 for (i = arguments.length; i-- > 2; ) stack.push(arguments[i]); -1 13097 if (attributes && null != attributes.children) { -1 13098 if (!stack.length) stack.push(attributes.children); -1 13099 delete attributes.children; -1 13100 } -1 13101 while (stack.length) if ((child = stack.pop()) && void 0 !== child.pop) for (i = child.length; i--; ) stack.push(child[i]); else { -1 13102 if ('boolean' == typeof child) child = null; -1 13103 if (simple = 'function' != typeof nodeName) if (null == child) child = ''; else if ('number' == typeof child) child = String(child); else if ('string' != typeof child) simple = !1; -1 13104 if (simple && lastSimple) children[children.length - 1] += child; else if (children === EMPTY_CHILDREN) children = [ child ]; else children.push(child); -1 13105 lastSimple = simple; -1 13106 } -1 13107 var p = new VNode(); -1 13108 p.nodeName = nodeName; -1 13109 p.children = children; -1 13110 p.attributes = null == attributes ? void 0 : attributes; -1 13111 p.key = null == attributes ? void 0 : attributes.key; -1 13112 if (void 0 !== options.vnode) options.vnode(p); -1 13113 return p; -1 13114 } -1 13115 function extend(obj, props) { -1 13116 for (var i in props) obj[i] = props[i]; -1 13117 return obj; -1 13118 } -1 13119 function cloneElement(vnode, props) { -1 13120 return h(vnode.nodeName, extend(extend({}, vnode.attributes), props), arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children); -1 13121 } -1 13122 function enqueueRender(component) { -1 13123 if (!component.__d && (component.__d = !0) && 1 == items.push(component)) (options.debounceRendering || defer)(rerender); -1 13124 } -1 13125 function rerender() { -1 13126 var p, list = items; -1 13127 items = []; -1 13128 while (p = list.pop()) if (p.__d) renderComponent(p); -1 13129 } -1 13130 function isSameNodeType(node, vnode, hydrating) { -1 13131 if ('string' == typeof vnode || 'number' == typeof vnode) return void 0 !== node.splitText; -1 13132 if ('string' == typeof vnode.nodeName) return !node._componentConstructor && isNamedNode(node, vnode.nodeName); else return hydrating || node._componentConstructor === vnode.nodeName; -1 13133 } -1 13134 function isNamedNode(node, nodeName) { -1 13135 return node.__n === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase(); -1 13136 } -1 13137 function getNodeProps(vnode) { -1 13138 var props = extend({}, vnode.attributes); -1 13139 props.children = vnode.children; -1 13140 var defaultProps = vnode.nodeName.defaultProps; -1 13141 if (void 0 !== defaultProps) for (var i in defaultProps) if (void 0 === props[i]) props[i] = defaultProps[i]; -1 13142 return props; -1 13143 } -1 13144 function createNode(nodeName, isSvg) { -1 13145 var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName); -1 13146 node.__n = nodeName; -1 13147 return node; -1 13148 } -1 13149 function removeNode(node) { -1 13150 var parentNode = node.parentNode; -1 13151 if (parentNode) parentNode.removeChild(node); -1 13152 } -1 13153 function setAccessor(node, name, old, value, isSvg) { -1 13154 if ('className' === name) name = 'class'; -1 13155 if ('key' === name) ; else if ('ref' === name) { -1 13156 if (old) old(null); -1 13157 if (value) value(node); -1 13158 } else if ('class' === name && !isSvg) node.className = value || ''; else if ('style' === name) { -1 13159 if (!value || 'string' == typeof value || 'string' == typeof old) node.style.cssText = value || ''; -1 13160 if (value && 'object' == typeof value) { -1 13161 if ('string' != typeof old) for (var i in old) if (!(i in value)) node.style[i] = ''; -1 13162 for (var i in value) node.style[i] = 'number' == typeof value[i] && !1 === IS_NON_DIMENSIONAL.test(i) ? value[i] + 'px' : value[i]; -1 13163 } -1 13164 } else if ('dangerouslySetInnerHTML' === name) { -1 13165 if (value) node.innerHTML = value.__html || ''; -1 13166 } else if ('o' == name[0] && 'n' == name[1]) { -1 13167 var useCapture = name !== (name = name.replace(/Capture$/, '')); -1 13168 name = name.toLowerCase().substring(2); -1 13169 if (value) { -1 13170 if (!old) node.addEventListener(name, eventProxy, useCapture); -1 13171 } else node.removeEventListener(name, eventProxy, useCapture); -1 13172 (node.__l || (node.__l = {}))[name] = value; -1 13173 } else if ('list' !== name && 'type' !== name && !isSvg && name in node) { -1 13174 setProperty(node, name, null == value ? '' : value); -1 13175 if (null == value || !1 === value) node.removeAttribute(name); -1 13176 } else { -1 13177 var ns = isSvg && name !== (name = name.replace(/^xlink\:?/, '')); -1 13178 if (null == value || !1 === value) if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase()); else node.removeAttribute(name); else if ('function' != typeof value) if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value); else node.setAttribute(name, value); -1 13179 } 13655 13180 }13656 -1 str += obj.id;13657 -1 }13658 -113659 -1 // json data13660 -1 if (null != obj.data) {13661 -1 if (nsp) str += ',';13662 -1 str += json.stringify(obj.data);13663 -1 }-1 13181 function setProperty(node, name, value) { -1 13182 try { -1 13183 node[name] = value; -1 13184 } catch (e) {} -1 13185 } -1 13186 function eventProxy(e) { -1 13187 return this.__l[e.type](options.event && options.event(e) || e); -1 13188 } -1 13189 function flushMounts() { -1 13190 var c; -1 13191 while (c = mounts.pop()) { -1 13192 if (options.afterMount) options.afterMount(c); -1 13193 if (c.componentDidMount) c.componentDidMount(); -1 13194 } -1 13195 } -1 13196 function diff(dom, vnode, context, mountAll, parent, componentRoot) { -1 13197 if (!diffLevel++) { -1 13198 isSvgMode = null != parent && void 0 !== parent.ownerSVGElement; -1 13199 hydrating = null != dom && !('__preactattr_' in dom); -1 13200 } -1 13201 var ret = idiff(dom, vnode, context, mountAll, componentRoot); -1 13202 if (parent && ret.parentNode !== parent) parent.appendChild(ret); -1 13203 if (!--diffLevel) { -1 13204 hydrating = !1; -1 13205 if (!componentRoot) flushMounts(); -1 13206 } -1 13207 return ret; -1 13208 } -1 13209 function idiff(dom, vnode, context, mountAll, componentRoot) { -1 13210 var out = dom, prevSvgMode = isSvgMode; -1 13211 if (null == vnode || 'boolean' == typeof vnode) vnode = ''; -1 13212 if ('string' == typeof vnode || 'number' == typeof vnode) { -1 13213 if (dom && void 0 !== dom.splitText && dom.parentNode && (!dom._component || componentRoot)) { -1 13214 if (dom.nodeValue != vnode) dom.nodeValue = vnode; -1 13215 } else { -1 13216 out = document.createTextNode(vnode); -1 13217 if (dom) { -1 13218 if (dom.parentNode) dom.parentNode.replaceChild(out, dom); -1 13219 recollectNodeTree(dom, !0); -1 13220 } -1 13221 } -1 13222 out.__preactattr_ = !0; -1 13223 return out; -1 13224 } -1 13225 var vnodeName = vnode.nodeName; -1 13226 if ('function' == typeof vnodeName) return buildComponentFromVNode(dom, vnode, context, mountAll); -1 13227 isSvgMode = 'svg' === vnodeName ? !0 : 'foreignObject' === vnodeName ? !1 : isSvgMode; -1 13228 vnodeName = String(vnodeName); -1 13229 if (!dom || !isNamedNode(dom, vnodeName)) { -1 13230 out = createNode(vnodeName, isSvgMode); -1 13231 if (dom) { -1 13232 while (dom.firstChild) out.appendChild(dom.firstChild); -1 13233 if (dom.parentNode) dom.parentNode.replaceChild(out, dom); -1 13234 recollectNodeTree(dom, !0); -1 13235 } -1 13236 } -1 13237 var fc = out.firstChild, props = out.__preactattr_, vchildren = vnode.children; -1 13238 if (null == props) { -1 13239 props = out.__preactattr_ = {}; -1 13240 for (var a = out.attributes, i = a.length; i--; ) props[a[i].name] = a[i].value; -1 13241 } -1 13242 if (!hydrating && vchildren && 1 === vchildren.length && 'string' == typeof vchildren[0] && null != fc && void 0 !== fc.splitText && null == fc.nextSibling) { -1 13243 if (fc.nodeValue != vchildren[0]) fc.nodeValue = vchildren[0]; -1 13244 } else if (vchildren && vchildren.length || null != fc) innerDiffNode(out, vchildren, context, mountAll, hydrating || null != props.dangerouslySetInnerHTML); -1 13245 diffAttributes(out, vnode.attributes, props); -1 13246 isSvgMode = prevSvgMode; -1 13247 return out; -1 13248 } -1 13249 function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) { -1 13250 var j, c, f, vchild, child, originalChildren = dom.childNodes, children = [], keyed = {}, keyedLen = 0, min = 0, len = originalChildren.length, childrenLen = 0, vlen = vchildren ? vchildren.length : 0; -1 13251 if (0 !== len) for (var i = 0; i < len; i++) { -1 13252 var _child = originalChildren[i], props = _child.__preactattr_, key = vlen && props ? _child._component ? _child._component.__k : props.key : null; -1 13253 if (null != key) { -1 13254 keyedLen++; -1 13255 keyed[key] = _child; -1 13256 } else if (props || (void 0 !== _child.splitText ? isHydrating ? _child.nodeValue.trim() : !0 : isHydrating)) children[childrenLen++] = _child; -1 13257 } -1 13258 if (0 !== vlen) for (var i = 0; i < vlen; i++) { -1 13259 vchild = vchildren[i]; -1 13260 child = null; -1 13261 var key = vchild.key; -1 13262 if (null != key) { -1 13263 if (keyedLen && void 0 !== keyed[key]) { -1 13264 child = keyed[key]; -1 13265 keyed[key] = void 0; -1 13266 keyedLen--; -1 13267 } -1 13268 } else if (!child && min < childrenLen) for (j = min; j < childrenLen; j++) if (void 0 !== children[j] && isSameNodeType(c = children[j], vchild, isHydrating)) { -1 13269 child = c; -1 13270 children[j] = void 0; -1 13271 if (j === childrenLen - 1) childrenLen--; -1 13272 if (j === min) min++; -1 13273 break; -1 13274 } -1 13275 child = idiff(child, vchild, context, mountAll); -1 13276 f = originalChildren[i]; -1 13277 if (child && child !== dom && child !== f) if (null == f) dom.appendChild(child); else if (child === f.nextSibling) removeNode(f); else dom.insertBefore(child, f); -1 13278 } -1 13279 if (keyedLen) for (var i in keyed) if (void 0 !== keyed[i]) recollectNodeTree(keyed[i], !1); -1 13280 while (min <= childrenLen) if (void 0 !== (child = children[childrenLen--])) recollectNodeTree(child, !1); -1 13281 } -1 13282 function recollectNodeTree(node, unmountOnly) { -1 13283 var component = node._component; -1 13284 if (component) unmountComponent(component); else { -1 13285 if (null != node.__preactattr_ && node.__preactattr_.ref) node.__preactattr_.ref(null); -1 13286 if (!1 === unmountOnly || null == node.__preactattr_) removeNode(node); -1 13287 removeChildren(node); -1 13288 } -1 13289 } -1 13290 function removeChildren(node) { -1 13291 node = node.lastChild; -1 13292 while (node) { -1 13293 var next = node.previousSibling; -1 13294 recollectNodeTree(node, !0); -1 13295 node = next; -1 13296 } -1 13297 } -1 13298 function diffAttributes(dom, attrs, old) { -1 13299 var name; -1 13300 for (name in old) if ((!attrs || null == attrs[name]) && null != old[name]) setAccessor(dom, name, old[name], old[name] = void 0, isSvgMode); -1 13301 for (name in attrs) if (!('children' === name || 'innerHTML' === name || name in old && attrs[name] === ('value' === name || 'checked' === name ? dom[name] : old[name]))) setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode); -1 13302 } -1 13303 function collectComponent(component) { -1 13304 var name = component.constructor.name; -1 13305 (components[name] || (components[name] = [])).push(component); -1 13306 } -1 13307 function createComponent(Ctor, props, context) { -1 13308 var inst, list = components[Ctor.name]; -1 13309 if (Ctor.prototype && Ctor.prototype.render) { -1 13310 inst = new Ctor(props, context); -1 13311 Component.call(inst, props, context); -1 13312 } else { -1 13313 inst = new Component(props, context); -1 13314 inst.constructor = Ctor; -1 13315 inst.render = doRender; -1 13316 } -1 13317 if (list) for (var i = list.length; i--; ) if (list[i].constructor === Ctor) { -1 13318 inst.__b = list[i].__b; -1 13319 list.splice(i, 1); -1 13320 break; -1 13321 } -1 13322 return inst; -1 13323 } -1 13324 function doRender(props, state, context) { -1 13325 return this.constructor(props, context); -1 13326 } -1 13327 function setComponentProps(component, props, opts, context, mountAll) { -1 13328 if (!component.__x) { -1 13329 component.__x = !0; -1 13330 if (component.__r = props.ref) delete props.ref; -1 13331 if (component.__k = props.key) delete props.key; -1 13332 if (!component.base || mountAll) { -1 13333 if (component.componentWillMount) component.componentWillMount(); -1 13334 } else if (component.componentWillReceiveProps) component.componentWillReceiveProps(props, context); -1 13335 if (context && context !== component.context) { -1 13336 if (!component.__c) component.__c = component.context; -1 13337 component.context = context; -1 13338 } -1 13339 if (!component.__p) component.__p = component.props; -1 13340 component.props = props; -1 13341 component.__x = !1; -1 13342 if (0 !== opts) if (1 === opts || !1 !== options.syncComponentUpdates || !component.base) renderComponent(component, 1, mountAll); else enqueueRender(component); -1 13343 if (component.__r) component.__r(component); -1 13344 } -1 13345 } -1 13346 function renderComponent(component, opts, mountAll, isChild) { -1 13347 if (!component.__x) { -1 13348 var rendered, inst, cbase, props = component.props, state = component.state, context = component.context, previousProps = component.__p || props, previousState = component.__s || state, previousContext = component.__c || context, isUpdate = component.base, nextBase = component.__b, initialBase = isUpdate || nextBase, initialChildComponent = component._component, skip = !1; -1 13349 if (isUpdate) { -1 13350 component.props = previousProps; -1 13351 component.state = previousState; -1 13352 component.context = previousContext; -1 13353 if (2 !== opts && component.shouldComponentUpdate && !1 === component.shouldComponentUpdate(props, state, context)) skip = !0; else if (component.componentWillUpdate) component.componentWillUpdate(props, state, context); -1 13354 component.props = props; -1 13355 component.state = state; -1 13356 component.context = context; -1 13357 } -1 13358 component.__p = component.__s = component.__c = component.__b = null; -1 13359 component.__d = !1; -1 13360 if (!skip) { -1 13361 rendered = component.render(props, state, context); -1 13362 if (component.getChildContext) context = extend(extend({}, context), component.getChildContext()); -1 13363 var toUnmount, base, childComponent = rendered && rendered.nodeName; -1 13364 if ('function' == typeof childComponent) { -1 13365 var childProps = getNodeProps(rendered); -1 13366 inst = initialChildComponent; -1 13367 if (inst && inst.constructor === childComponent && childProps.key == inst.__k) setComponentProps(inst, childProps, 1, context, !1); else { -1 13368 toUnmount = inst; -1 13369 component._component = inst = createComponent(childComponent, childProps, context); -1 13370 inst.__b = inst.__b || nextBase; -1 13371 inst.__u = component; -1 13372 setComponentProps(inst, childProps, 0, context, !1); -1 13373 renderComponent(inst, 1, mountAll, !0); -1 13374 } -1 13375 base = inst.base; -1 13376 } else { -1 13377 cbase = initialBase; -1 13378 toUnmount = initialChildComponent; -1 13379 if (toUnmount) cbase = component._component = null; -1 13380 if (initialBase || 1 === opts) { -1 13381 if (cbase) cbase._component = null; -1 13382 base = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, !0); -1 13383 } -1 13384 } -1 13385 if (initialBase && base !== initialBase && inst !== initialChildComponent) { -1 13386 var baseParent = initialBase.parentNode; -1 13387 if (baseParent && base !== baseParent) { -1 13388 baseParent.replaceChild(base, initialBase); -1 13389 if (!toUnmount) { -1 13390 initialBase._component = null; -1 13391 recollectNodeTree(initialBase, !1); -1 13392 } -1 13393 } -1 13394 } -1 13395 if (toUnmount) unmountComponent(toUnmount); -1 13396 component.base = base; -1 13397 if (base && !isChild) { -1 13398 var componentRef = component, t = component; -1 13399 while (t = t.__u) (componentRef = t).base = base; -1 13400 base._component = componentRef; -1 13401 base._componentConstructor = componentRef.constructor; -1 13402 } -1 13403 } -1 13404 if (!isUpdate || mountAll) mounts.unshift(component); else if (!skip) { -1 13405 if (component.componentDidUpdate) component.componentDidUpdate(previousProps, previousState, previousContext); -1 13406 if (options.afterUpdate) options.afterUpdate(component); -1 13407 } -1 13408 if (null != component.__h) while (component.__h.length) component.__h.pop().call(component); -1 13409 if (!diffLevel && !isChild) flushMounts(); -1 13410 } -1 13411 } -1 13412 function buildComponentFromVNode(dom, vnode, context, mountAll) { -1 13413 var c = dom && dom._component, originalComponent = c, oldDom = dom, isDirectOwner = c && dom._componentConstructor === vnode.nodeName, isOwner = isDirectOwner, props = getNodeProps(vnode); -1 13414 while (c && !isOwner && (c = c.__u)) isOwner = c.constructor === vnode.nodeName; -1 13415 if (c && isOwner && (!mountAll || c._component)) { -1 13416 setComponentProps(c, props, 3, context, mountAll); -1 13417 dom = c.base; -1 13418 } else { -1 13419 if (originalComponent && !isDirectOwner) { -1 13420 unmountComponent(originalComponent); -1 13421 dom = oldDom = null; -1 13422 } -1 13423 c = createComponent(vnode.nodeName, props, context); -1 13424 if (dom && !c.__b) { -1 13425 c.__b = dom; -1 13426 oldDom = null; -1 13427 } -1 13428 setComponentProps(c, props, 1, context, mountAll); -1 13429 dom = c.base; -1 13430 if (oldDom && dom !== oldDom) { -1 13431 oldDom._component = null; -1 13432 recollectNodeTree(oldDom, !1); -1 13433 } -1 13434 } -1 13435 return dom; -1 13436 } -1 13437 function unmountComponent(component) { -1 13438 if (options.beforeUnmount) options.beforeUnmount(component); -1 13439 var base = component.base; -1 13440 component.__x = !0; -1 13441 if (component.componentWillUnmount) component.componentWillUnmount(); -1 13442 component.base = null; -1 13443 var inner = component._component; -1 13444 if (inner) unmountComponent(inner); else if (base) { -1 13445 if (base.__preactattr_ && base.__preactattr_.ref) base.__preactattr_.ref(null); -1 13446 component.__b = base; -1 13447 removeNode(base); -1 13448 collectComponent(component); -1 13449 removeChildren(base); -1 13450 } -1 13451 if (component.__r) component.__r(null); -1 13452 } -1 13453 function Component(props, context) { -1 13454 this.__d = !0; -1 13455 this.context = context; -1 13456 this.props = props; -1 13457 this.state = this.state || {}; -1 13458 } -1 13459 function render(vnode, parent, merge) { -1 13460 return diff(merge, vnode, {}, !1, parent, !1); -1 13461 } -1 13462 var options = {}; -1 13463 var stack = []; -1 13464 var EMPTY_CHILDREN = []; -1 13465 var defer = 'function' == typeof Promise ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; -1 13466 var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i; -1 13467 var items = []; -1 13468 var mounts = []; -1 13469 var diffLevel = 0; -1 13470 var isSvgMode = !1; -1 13471 var hydrating = !1; -1 13472 var components = {}; -1 13473 extend(Component.prototype, { -1 13474 setState: function(state, callback) { -1 13475 var s = this.state; -1 13476 if (!this.__s) this.__s = extend({}, s); -1 13477 extend(s, 'function' == typeof state ? state(s, this.props) : state); -1 13478 if (callback) (this.__h = this.__h || []).push(callback); -1 13479 enqueueRender(this); -1 13480 }, -1 13481 forceUpdate: function(callback) { -1 13482 if (callback) (this.__h = this.__h || []).push(callback); -1 13483 renderComponent(this, 2); -1 13484 }, -1 13485 render: function() {} -1 13486 }); -1 13487 var preact = { -1 13488 h: h, -1 13489 createElement: h, -1 13490 cloneElement: cloneElement, -1 13491 Component: Component, -1 13492 render: render, -1 13493 rerender: rerender, -1 13494 options: options -1 13495 }; -1 13496 if ('undefined' != typeof module) module.exports = preact; else self.preact = preact; -1 13497 }(); 13664 1349813665 -1 debug('encoded %j as %s', obj, str);13666 -1 return str;13667 -1 }-1 13499 },{}],97:[function(require,module,exports){ 13668 13500 13669 13501 /**13670 -1 * Encode packet as 'buffer sequence' by removing blobs, and13671 -1 * deconstructing packet into object with placeholders and13672 -1 * a list of buffers.13673 -1 *13674 -1 * @param {Object} packet13675 -1 * @return {Buffer} encoded13676 -1 * @api private-1 13502 * Module dependencies. 13677 13503 */ 13678 1350413679 -1 function encodeAsBinary(obj, callback) {13680 -113681 -1 function writeEncoding(bloblessData) {13682 -1 var deconstruction = binary.deconstructPacket(bloblessData);13683 -1 var pack = encodeAsString(deconstruction.packet);13684 -1 var buffers = deconstruction.buffers;13685 -113686 -1 buffers.unshift(pack); // add packet info to beginning of data list13687 -1 callback(buffers); // write all the buffers13688 -1 }13689 -113690 -1 binary.removeBlobs(obj, writeEncoding);13691 -1 }-1 13505 var url = require('./url'); -1 13506 var parser = require('socket.io-parser'); -1 13507 var Manager = require('./manager'); -1 13508 var debug = require('debug')('socket.io-client'); 13692 13509 13693 13510 /**13694 -1 * A socket.io Decoder instance13695 -1 *13696 -1 * @return {Object} decoder13697 -1 * @api public-1 13511 * Module exports. 13698 13512 */ 13699 1351313700 -1 function Decoder() {13701 -1 this.reconstructor = null;13702 -1 }-1 13514 module.exports = exports = lookup; 13703 13515 13704 13516 /**13705 -1 * Mix in `Emitter` with Decoder.-1 13517 * Managers cache. 13706 13518 */ 13707 1351913708 -1 Emitter(Decoder.prototype);-1 13520 var cache = exports.managers = {}; 13709 13521 13710 13522 /**13711 -1 * Decodes an ecoded packet string into packet JSON.-1 13523 * Looks up an existing `Manager` for multiplexing. -1 13524 * If the user summons: -1 13525 * -1 13526 * `io('http://localhost/a');` -1 13527 * `io('http://localhost/b');` -1 13528 * -1 13529 * We reuse the existing instance based on same scheme/port/host, -1 13530 * and we initialize sockets for each namespace. 13712 13531 *13713 -1 * @param {String} obj - encoded packet13714 -1 * @return {Object} packet13715 13532 * @api public 13716 13533 */ 13717 1353413718 -1 Decoder.prototype.add = function(obj) {13719 -1 var packet;13720 -1 if ('string' == typeof obj) {13721 -1 packet = decodeString(obj);13722 -1 if (exports.BINARY_EVENT == packet.type || exports.BINARY_ACK == packet.type) { // binary packet's json13723 -1 this.reconstructor = new BinaryReconstructor(packet);13724 -113725 -1 // no attachments, labeled binary but no binary data to follow13726 -1 if (this.reconstructor.reconPack.attachments === 0) {13727 -1 this.emit('decoded', packet);13728 -1 }13729 -1 } else { // non-binary full packet13730 -1 this.emit('decoded', packet);13731 -1 }13732 -1 }13733 -1 else if (isBuf(obj) || obj.base64) { // raw binary data13734 -1 if (!this.reconstructor) {13735 -1 throw new Error('got binary data when not reconstructing a packet');13736 -1 } else {13737 -1 packet = this.reconstructor.takeBinaryData(obj);13738 -1 if (packet) { // received final buffer13739 -1 this.reconstructor = null;13740 -1 this.emit('decoded', packet);13741 -1 }13742 -1 }13743 -1 }13744 -1 else {13745 -1 throw new Error('Unknown type: ' + obj);-1 13535 function lookup (uri, opts) { -1 13536 if (typeof uri === 'object') { -1 13537 opts = uri; -1 13538 uri = undefined; 13746 13539 }13747 -1 };13748 -113749 -1 /**13750 -1 * Decode a packet String (JSON data)13751 -1 *13752 -1 * @param {String} str13753 -1 * @return {Object} packet13754 -1 * @api private13755 -1 */13756 1354013757 -1 function decodeString(str) {13758 -1 var p = {};13759 -1 var i = 0;-1 13541 opts = opts || {}; 13760 1354213761 -1 // look up type13762 -1 p.type = Number(str.charAt(0));13763 -1 if (null == exports.types[p.type]) return error();-1 13543 var parsed = url(uri); -1 13544 var source = parsed.source; -1 13545 var id = parsed.id; -1 13546 var path = parsed.path; -1 13547 var sameNamespace = cache[id] && path in cache[id].nsps; -1 13548 var newConnection = opts.forceNew || opts['force new connection'] || -1 13549 false === opts.multiplex || sameNamespace; 13764 1355013765 -1 // look up attachments if type binary13766 -1 if (exports.BINARY_EVENT == p.type || exports.BINARY_ACK == p.type) {13767 -1 var buf = '';13768 -1 while (str.charAt(++i) != '-') {13769 -1 buf += str.charAt(i);13770 -1 if (i == str.length) break;13771 -1 }13772 -1 if (buf != Number(buf) || str.charAt(i) != '-') {13773 -1 throw new Error('Illegal attachments');13774 -1 }13775 -1 p.attachments = Number(buf);13776 -1 }-1 13551 var io; 13777 1355213778 -1 // look up namespace (if any)13779 -1 if ('/' == str.charAt(i + 1)) {13780 -1 p.nsp = '';13781 -1 while (++i) {13782 -1 var c = str.charAt(i);13783 -1 if (',' == c) break;13784 -1 p.nsp += c;13785 -1 if (i == str.length) break;13786 -1 }-1 13553 if (newConnection) { -1 13554 debug('ignoring socket cache for %s', source); -1 13555 io = Manager(source, opts); 13787 13556 } else {13788 -1 p.nsp = '/';13789 -1 }13790 -113791 -1 // look up id13792 -1 var next = str.charAt(i + 1);13793 -1 if ('' !== next && Number(next) == next) {13794 -1 p.id = '';13795 -1 while (++i) {13796 -1 var c = str.charAt(i);13797 -1 if (null == c || Number(c) != c) {13798 -1 --i;13799 -1 break;13800 -1 }13801 -1 p.id += str.charAt(i);13802 -1 if (i == str.length) break;-1 13557 if (!cache[id]) { -1 13558 debug('new io instance for %s', source); -1 13559 cache[id] = Manager(source, opts); 13803 13560 }13804 -1 p.id = Number(p.id);-1 13561 io = cache[id]; 13805 13562 }13806 -113807 -1 // look up json data13808 -1 if (str.charAt(++i)) {13809 -1 try {13810 -1 p.data = json.parse(str.substr(i));13811 -1 } catch(e){13812 -1 return error();13813 -1 }-1 13563 if (parsed.query && !opts.query) { -1 13564 opts.query = parsed.query; -1 13565 } else if (opts && 'object' === typeof opts.query) { -1 13566 opts.query = encodeQueryString(opts.query); 13814 13567 }13815 -113816 -1 debug('decoded %s as %j', str, p);13817 -1 return p;-1 13568 return io.socket(parsed.path, opts); 13818 13569 }13819 -113820 13570 /**13821 -1 * Deallocates a parser's resources13822 -1 *13823 -1 * @api public-1 13571 * Helper method to parse query objects to string. -1 13572 * @param {object} query -1 13573 * @returns {string} 13824 13574 */13825 -113826 -1 Decoder.prototype.destroy = function() {13827 -1 if (this.reconstructor) {13828 -1 this.reconstructor.finishedReconstruction();-1 13575 function encodeQueryString (obj) { -1 13576 var str = []; -1 13577 for (var p in obj) { -1 13578 if (obj.hasOwnProperty(p)) { -1 13579 str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p])); -1 13580 } 13829 13581 }13830 -1 };13831 -113832 -1 /**13833 -1 * A manager of a binary event's 'buffer sequence'. Should13834 -1 * be constructed whenever a packet of type BINARY_EVENT is13835 -1 * decoded.13836 -1 *13837 -1 * @param {Object} packet13838 -1 * @return {BinaryReconstructor} initialized reconstructor13839 -1 * @api private13840 -1 */13841 -113842 -1 function BinaryReconstructor(packet) {13843 -1 this.reconPack = packet;13844 -1 this.buffers = [];-1 13582 return str.join('&'); 13845 13583 }13846 -113847 13584 /**13848 -1 * Method to be called when binary data received from connection13849 -1 * after a BINARY_EVENT packet.-1 13585 * Protocol version. 13850 13586 *13851 -1 * @param {Buffer | ArrayBuffer} binData - the raw binary data received13852 -1 * @return {null | Object} returns null if more binary data is expected or13853 -1 * a reconstructed packet object if all buffers have been received.13854 -1 * @api private-1 13587 * @api public 13855 13588 */ 13856 1358913857 -1 BinaryReconstructor.prototype.takeBinaryData = function(binData) {13858 -1 this.buffers.push(binData);13859 -1 if (this.buffers.length == this.reconPack.attachments) { // done with buffer list13860 -1 var packet = binary.reconstructPacket(this.reconPack, this.buffers);13861 -1 this.finishedReconstruction();13862 -1 return packet;13863 -1 }13864 -1 return null;13865 -1 };-1 13590 exports.protocol = parser.protocol; 13866 13591 13867 13592 /**13868 -1 * Cleans up binary packet reconstruction variables.-1 13593 * `connect`. 13869 13594 *13870 -1 * @api private-1 13595 * @param {String} uri -1 13596 * @api public 13871 13597 */ 13872 1359813873 -1 BinaryReconstructor.prototype.finishedReconstruction = function() {13874 -1 this.reconPack = null;13875 -1 this.buffers = [];13876 -1 };13877 -113878 -1 function error(data){13879 -1 return {13880 -1 type: exports.ERROR,13881 -1 data: 'parser error'13882 -1 };13883 -1 }13884 -113885 -1 },{"./binary":106,"./is-buffer":108,"component-emitter":10,"debug":12,"isarray":36,"json3":109}],108:[function(require,module,exports){13886 -1 (function (global){13887 -113888 -1 module.exports = isBuf;-1 13599 exports.connect = lookup; 13889 13600 13890 13601 /**13891 -1 * Returns true if obj is a buffer or an arraybuffer.-1 13602 * Expose constructors for standalone build. 13892 13603 *13893 -1 * @api private-1 13604 * @api public 13894 13605 */ 13895 1360613896 -1 function isBuf(obj) {13897 -1 return (global.Buffer && global.Buffer.isBuffer(obj)) ||13898 -1 (global.ArrayBuffer && obj instanceof ArrayBuffer);13899 -1 }13900 -113901 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})13902 -1 },{}],109:[function(require,module,exports){13903 -1 (function (global){13904 -1 /*! JSON v3.3.2 | http://bestiejs.github.io/json3 | Copyright 2012-2014, Kit Cambridge | http://kit.mit-license.org */13905 -1 ;(function () {13906 -1 // Detect the `define` function exposed by asynchronous module loaders. The13907 -1 // strict `define` check is necessary for compatibility with `r.js`.13908 -1 var isLoader = typeof define === "function" && define.amd;13909 -113910 -1 // A set of types used to distinguish objects from primitives.13911 -1 var objectTypes = {13912 -1 "function": true,13913 -1 "object": true13914 -1 };13915 -113916 -1 // Detect the `exports` object exposed by CommonJS implementations.13917 -1 var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;13918 -113919 -1 // Use the `global` object exposed by Node (including Browserify via13920 -1 // `insert-module-globals`), Narwhal, and Ringo as the default context,13921 -1 // and the `window` object in browsers. Rhino exports a `global` function13922 -1 // instead.13923 -1 var root = objectTypes[typeof window] && window || this,13924 -1 freeGlobal = freeExports && objectTypes[typeof module] && module && !module.nodeType && typeof global == "object" && global;13925 -113926 -1 if (freeGlobal && (freeGlobal["global"] === freeGlobal || freeGlobal["window"] === freeGlobal || freeGlobal["self"] === freeGlobal)) {13927 -1 root = freeGlobal;13928 -1 }13929 -113930 -1 // Public: Initializes JSON 3 using the given `context` object, attaching the13931 -1 // `stringify` and `parse` functions to the specified `exports` object.13932 -1 function runInContext(context, exports) {13933 -1 context || (context = root["Object"]());13934 -1 exports || (exports = root["Object"]());13935 -113936 -1 // Native constructor aliases.13937 -1 var Number = context["Number"] || root["Number"],13938 -1 String = context["String"] || root["String"],13939 -1 Object = context["Object"] || root["Object"],13940 -1 Date = context["Date"] || root["Date"],13941 -1 SyntaxError = context["SyntaxError"] || root["SyntaxError"],13942 -1 TypeError = context["TypeError"] || root["TypeError"],13943 -1 Math = context["Math"] || root["Math"],13944 -1 nativeJSON = context["JSON"] || root["JSON"];-1 13607 exports.Manager = require('./manager'); -1 13608 exports.Socket = require('./socket'); 13945 1360913946 -1 // Delegate to the native `stringify` and `parse` implementations.13947 -1 if (typeof nativeJSON == "object" && nativeJSON) {13948 -1 exports.stringify = nativeJSON.stringify;13949 -1 exports.parse = nativeJSON.parse;13950 -1 }-1 13610 },{"./manager":98,"./socket":100,"./url":101,"debug":103,"socket.io-parser":107}],98:[function(require,module,exports){ 13951 1361113952 -1 // Convenience aliases.13953 -1 var objectProto = Object.prototype,13954 -1 getClass = objectProto.toString,13955 -1 isProperty, forEach, undef;-1 13612 /** -1 13613 * Module dependencies. -1 13614 */ 13956 1361513957 -1 // Test the `Date#getUTC*` methods. Based on work by @Yaffle.13958 -1 var isExtended = new Date(-3509827334573292);13959 -1 try {13960 -1 // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical13961 -1 // results for certain dates in Opera >= 10.53.13962 -1 isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 &&13963 -1 // Safari < 2.0.2 stores the internal millisecond time value correctly,13964 -1 // but clips the values returned by the date methods to the range of13965 -1 // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]).13966 -1 isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708;13967 -1 } catch (exception) {}-1 13616 var eio = require('engine.io-client'); -1 13617 var Socket = require('./socket'); -1 13618 var Emitter = require('component-emitter'); -1 13619 var parser = require('socket.io-parser'); -1 13620 var on = require('./on'); -1 13621 var bind = require('component-bind'); -1 13622 var debug = require('debug')('socket.io-client:manager'); -1 13623 var indexOf = require('indexof'); -1 13624 var Backoff = require('backo2'); 13968 1362513969 -1 // Internal: Determines whether the native `JSON.stringify` and `parse`13970 -1 // implementations are spec-compliant. Based on work by Ken Snyder.13971 -1 function has(name) {13972 -1 if (has[name] !== undef) {13973 -1 // Return cached feature test result.13974 -1 return has[name];13975 -1 }13976 -1 var isSupported;13977 -1 if (name == "bug-string-char-index") {13978 -1 // IE <= 7 doesn't support accessing string characters using square13979 -1 // bracket notation. IE 8 only supports this for primitives.13980 -1 isSupported = "a"[0] != "a";13981 -1 } else if (name == "json") {13982 -1 // Indicates whether both `JSON.stringify` and `JSON.parse` are13983 -1 // supported.13984 -1 isSupported = has("json-stringify") && has("json-parse");13985 -1 } else {13986 -1 var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';13987 -1 // Test `JSON.stringify`.13988 -1 if (name == "json-stringify") {13989 -1 var stringify = exports.stringify, stringifySupported = typeof stringify == "function" && isExtended;13990 -1 if (stringifySupported) {13991 -1 // A test function object with a custom `toJSON` method.13992 -1 (value = function () {13993 -1 return 1;13994 -1 }).toJSON = value;13995 -1 try {13996 -1 stringifySupported =13997 -1 // Firefox 3.1b1 and b2 serialize string, number, and boolean13998 -1 // primitives as object literals.13999 -1 stringify(0) === "0" &&14000 -1 // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object14001 -1 // literals.14002 -1 stringify(new Number()) === "0" &&14003 -1 stringify(new String()) == '""' &&14004 -1 // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or14005 -1 // does not define a canonical JSON representation (this applies to14006 -1 // objects with `toJSON` properties as well, *unless* they are nested14007 -1 // within an object or array).14008 -1 stringify(getClass) === undef &&14009 -1 // IE 8 serializes `undefined` as `"undefined"`. Safari <= 5.1.7 and14010 -1 // FF 3.1b3 pass this test.14011 -1 stringify(undef) === undef &&14012 -1 // Safari <= 5.1.7 and FF 3.1b3 throw `Error`s and `TypeError`s,14013 -1 // respectively, if the value is omitted entirely.14014 -1 stringify() === undef &&14015 -1 // FF 3.1b1, 2 throw an error if the given value is not a number,14016 -1 // string, array, object, Boolean, or `null` literal. This applies to14017 -1 // objects with custom `toJSON` methods as well, unless they are nested14018 -1 // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON`14019 -1 // methods entirely.14020 -1 stringify(value) === "1" &&14021 -1 stringify([value]) == "[1]" &&14022 -1 // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of14023 -1 // `"[null]"`.14024 -1 stringify([undef]) == "[null]" &&14025 -1 // YUI 3.0.0b1 fails to serialize `null` literals.14026 -1 stringify(null) == "null" &&14027 -1 // FF 3.1b1, 2 halts serialization if an array contains a function:14028 -1 // `[1, true, getClass, 1]` serializes as "[1,true,],". FF 3.1b314029 -1 // elides non-JSON values from objects and arrays, unless they14030 -1 // define custom `toJSON` methods.14031 -1 stringify([undef, getClass, null]) == "[null,null,null]" &&14032 -1 // Simple serialization test. FF 3.1b1 uses Unicode escape sequences14033 -1 // where character escape codes are expected (e.g., `\b` => `\u0008`).14034 -1 stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized &&14035 -1 // FF 3.1b1 and b2 ignore the `filter` and `width` arguments.14036 -1 stringify(null, value) === "1" &&14037 -1 stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" &&14038 -1 // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly14039 -1 // serialize extended years.14040 -1 stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' &&14041 -1 // The milliseconds are optional in ES 5, but required in 5.1.14042 -1 stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' &&14043 -1 // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative14044 -1 // four-digit years instead of six-digit years. Credits: @Yaffle.14045 -1 stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' &&14046 -1 // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond14047 -1 // values less than 1000. Credits: @Yaffle.14048 -1 stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"';14049 -1 } catch (exception) {14050 -1 stringifySupported = false;14051 -1 }14052 -1 }14053 -1 isSupported = stringifySupported;14054 -1 }14055 -1 // Test `JSON.parse`.14056 -1 if (name == "json-parse") {14057 -1 var parse = exports.parse;14058 -1 if (typeof parse == "function") {14059 -1 try {14060 -1 // FF 3.1b1, b2 will throw an exception if a bare literal is provided.14061 -1 // Conforming implementations should also coerce the initial argument to14062 -1 // a string prior to parsing.14063 -1 if (parse("0") === 0 && !parse(false)) {14064 -1 // Simple parsing test.14065 -1 value = parse(serialized);14066 -1 var parseSupported = value["a"].length == 5 && value["a"][0] === 1;14067 -1 if (parseSupported) {14068 -1 try {14069 -1 // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings.14070 -1 parseSupported = !parse('"\t"');14071 -1 } catch (exception) {}14072 -1 if (parseSupported) {14073 -1 try {14074 -1 // FF 4.0 and 4.0.1 allow leading `+` signs and leading14075 -1 // decimal points. FF 4.0, 4.0.1, and IE 9-10 also allow14076 -1 // certain octal literals.14077 -1 parseSupported = parse("01") !== 1;14078 -1 } catch (exception) {}14079 -1 }14080 -1 if (parseSupported) {14081 -1 try {14082 -1 // FF 4.0, 4.0.1, and Rhino 1.7R3-R4 allow trailing decimal14083 -1 // points. These environments, along with FF 3.1b1 and 2,14084 -1 // also allow trailing commas in JSON objects and arrays.14085 -1 parseSupported = parse("1.") !== 1;14086 -1 } catch (exception) {}14087 -1 }14088 -1 }14089 -1 }14090 -1 } catch (exception) {14091 -1 parseSupported = false;14092 -1 }14093 -1 }14094 -1 isSupported = parseSupported;14095 -1 }14096 -1 }14097 -1 return has[name] = !!isSupported;-1 13626 /** -1 13627 * IE6+ hasOwnProperty -1 13628 */ -1 13629 -1 13630 var has = Object.prototype.hasOwnProperty; -1 13631 -1 13632 /** -1 13633 * Module exports -1 13634 */ -1 13635 -1 13636 module.exports = Manager; -1 13637 -1 13638 /** -1 13639 * `Manager` constructor. -1 13640 * -1 13641 * @param {String} engine instance or engine uri/opts -1 13642 * @param {Object} options -1 13643 * @api public -1 13644 */ -1 13645 -1 13646 function Manager (uri, opts) { -1 13647 if (!(this instanceof Manager)) return new Manager(uri, opts); -1 13648 if (uri && ('object' === typeof uri)) { -1 13649 opts = uri; -1 13650 uri = undefined; -1 13651 } -1 13652 opts = opts || {}; -1 13653 -1 13654 opts.path = opts.path || '/socket.io'; -1 13655 this.nsps = {}; -1 13656 this.subs = []; -1 13657 this.opts = opts; -1 13658 this.reconnection(opts.reconnection !== false); -1 13659 this.reconnectionAttempts(opts.reconnectionAttempts || Infinity); -1 13660 this.reconnectionDelay(opts.reconnectionDelay || 1000); -1 13661 this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000); -1 13662 this.randomizationFactor(opts.randomizationFactor || 0.5); -1 13663 this.backoff = new Backoff({ -1 13664 min: this.reconnectionDelay(), -1 13665 max: this.reconnectionDelayMax(), -1 13666 jitter: this.randomizationFactor() -1 13667 }); -1 13668 this.timeout(null == opts.timeout ? 20000 : opts.timeout); -1 13669 this.readyState = 'closed'; -1 13670 this.uri = uri; -1 13671 this.connecting = []; -1 13672 this.lastPing = null; -1 13673 this.encoding = false; -1 13674 this.packetBuffer = []; -1 13675 this.encoder = new parser.Encoder(); -1 13676 this.decoder = new parser.Decoder(); -1 13677 this.autoConnect = opts.autoConnect !== false; -1 13678 if (this.autoConnect) this.open(); -1 13679 } -1 13680 -1 13681 /** -1 13682 * Propagate given event to sockets and emit on `this` -1 13683 * -1 13684 * @api private -1 13685 */ -1 13686 -1 13687 Manager.prototype.emitAll = function () { -1 13688 this.emit.apply(this, arguments); -1 13689 for (var nsp in this.nsps) { -1 13690 if (has.call(this.nsps, nsp)) { -1 13691 this.nsps[nsp].emit.apply(this.nsps[nsp], arguments); 14098 13692 } -1 13693 } -1 13694 }; 14099 1369514100 -1 if (!has("json")) {14101 -1 // Common `[[Class]]` name aliases.14102 -1 var functionClass = "[object Function]",14103 -1 dateClass = "[object Date]",14104 -1 numberClass = "[object Number]",14105 -1 stringClass = "[object String]",14106 -1 arrayClass = "[object Array]",14107 -1 booleanClass = "[object Boolean]";-1 13696 /** -1 13697 * Update `socket.id` of all sockets -1 13698 * -1 13699 * @api private -1 13700 */ 14108 1370114109 -1 // Detect incomplete support for accessing string characters by index.14110 -1 var charIndexBuggy = has("bug-string-char-index");-1 13702 Manager.prototype.updateSocketIds = function () { -1 13703 for (var nsp in this.nsps) { -1 13704 if (has.call(this.nsps, nsp)) { -1 13705 this.nsps[nsp].id = this.engine.id; -1 13706 } -1 13707 } -1 13708 }; 14111 1370914112 -1 // Define additional utility methods if the `Date` methods are buggy.14113 -1 if (!isExtended) {14114 -1 var floor = Math.floor;14115 -1 // A mapping between the months of the year and the number of days between14116 -1 // January 1st and the first of the respective month.14117 -1 var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];14118 -1 // Internal: Calculates the number of days between the Unix epoch and the14119 -1 // first day of the given month.14120 -1 var getDay = function (year, month) {14121 -1 return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);14122 -1 };14123 -1 }-1 13710 /** -1 13711 * Mix in `Emitter`. -1 13712 */ 14124 1371314125 -1 // Internal: Determines if a property is a direct property of the given14126 -1 // object. Delegates to the native `Object#hasOwnProperty` method.14127 -1 if (!(isProperty = objectProto.hasOwnProperty)) {14128 -1 isProperty = function (property) {14129 -1 var members = {}, constructor;14130 -1 if ((members.__proto__ = null, members.__proto__ = {14131 -1 // The *proto* property cannot be set multiple times in recent14132 -1 // versions of Firefox and SeaMonkey.14133 -1 "toString": 114134 -1 }, members).toString != getClass) {14135 -1 // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but14136 -1 // supports the mutable *proto* property.14137 -1 isProperty = function (property) {14138 -1 // Capture and break the object's prototype chain (see section 8.6.214139 -1 // of the ES 5.1 spec). The parenthesized expression prevents an14140 -1 // unsafe transformation by the Closure Compiler.14141 -1 var original = this.__proto__, result = property in (this.__proto__ = null, this);14142 -1 // Restore the original prototype chain.14143 -1 this.__proto__ = original;14144 -1 return result;14145 -1 };14146 -1 } else {14147 -1 // Capture a reference to the top-level `Object` constructor.14148 -1 constructor = members.constructor;14149 -1 // Use the `constructor` property to simulate `Object#hasOwnProperty` in14150 -1 // other environments.14151 -1 isProperty = function (property) {14152 -1 var parent = (this.constructor || constructor).prototype;14153 -1 return property in this && !(property in parent && this[property] === parent[property]);14154 -1 };14155 -1 }14156 -1 members = null;14157 -1 return isProperty.call(this, property);14158 -1 };14159 -1 }-1 13714 Emitter(Manager.prototype); 14160 1371514161 -1 // Internal: Normalizes the `for...in` iteration algorithm across14162 -1 // environments. Each enumerated key is yielded to a `callback` function.14163 -1 forEach = function (object, callback) {14164 -1 var size = 0, Properties, members, property;-1 13716 /** -1 13717 * Sets the `reconnection` config. -1 13718 * -1 13719 * @param {Boolean} true/false if it should automatically reconnect -1 13720 * @return {Manager} self or value -1 13721 * @api public -1 13722 */ 14165 1372314166 -1 // Tests for bugs in the current environment's `for...in` algorithm. The14167 -1 // `valueOf` property inherits the non-enumerable flag from14168 -1 // `Object.prototype` in older versions of IE, Netscape, and Mozilla.14169 -1 (Properties = function () {14170 -1 this.valueOf = 0;14171 -1 }).prototype.valueOf = 0;-1 13724 Manager.prototype.reconnection = function (v) { -1 13725 if (!arguments.length) return this._reconnection; -1 13726 this._reconnection = !!v; -1 13727 return this; -1 13728 }; 14172 1372914173 -1 // Iterate over a new instance of the `Properties` class.14174 -1 members = new Properties();14175 -1 for (property in members) {14176 -1 // Ignore all properties inherited from `Object.prototype`.14177 -1 if (isProperty.call(members, property)) {14178 -1 size++;14179 -1 }14180 -1 }14181 -1 Properties = members = null;-1 13730 /** -1 13731 * Sets the reconnection attempts config. -1 13732 * -1 13733 * @param {Number} max reconnection attempts before giving up -1 13734 * @return {Manager} self or value -1 13735 * @api public -1 13736 */ 14182 1373714183 -1 // Normalize the iteration algorithm.14184 -1 if (!size) {14185 -1 // A list of non-enumerable properties inherited from `Object.prototype`.14186 -1 members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];14187 -1 // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable14188 -1 // properties.14189 -1 forEach = function (object, callback) {14190 -1 var isFunction = getClass.call(object) == functionClass, property, length;14191 -1 var hasProperty = !isFunction && typeof object.constructor != "function" && objectTypes[typeof object.hasOwnProperty] && object.hasOwnProperty || isProperty;14192 -1 for (property in object) {14193 -1 // Gecko <= 1.0 enumerates the `prototype` property of functions under14194 -1 // certain conditions; IE does not.14195 -1 if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) {14196 -1 callback(property);14197 -1 }14198 -1 }14199 -1 // Manually invoke the callback for each non-enumerable property.14200 -1 for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property));14201 -1 };14202 -1 } else if (size == 2) {14203 -1 // Safari <= 2.0.4 enumerates shadowed properties twice.14204 -1 forEach = function (object, callback) {14205 -1 // Create a set of iterated properties.14206 -1 var members = {}, isFunction = getClass.call(object) == functionClass, property;14207 -1 for (property in object) {14208 -1 // Store each property name to prevent double enumeration. The14209 -1 // `prototype` property of functions is not enumerated due to cross-14210 -1 // environment inconsistencies.14211 -1 if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {14212 -1 callback(property);14213 -1 }14214 -1 }14215 -1 };14216 -1 } else {14217 -1 // No bugs detected; use the standard `for...in` algorithm.14218 -1 forEach = function (object, callback) {14219 -1 var isFunction = getClass.call(object) == functionClass, property, isConstructor;14220 -1 for (property in object) {14221 -1 if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {14222 -1 callback(property);14223 -1 }14224 -1 }14225 -1 // Manually invoke the callback for the `constructor` property due to14226 -1 // cross-environment inconsistencies.14227 -1 if (isConstructor || isProperty.call(object, (property = "constructor"))) {14228 -1 callback(property);14229 -1 }14230 -1 };14231 -1 }14232 -1 return forEach(object, callback);14233 -1 };-1 13738 Manager.prototype.reconnectionAttempts = function (v) { -1 13739 if (!arguments.length) return this._reconnectionAttempts; -1 13740 this._reconnectionAttempts = v; -1 13741 return this; -1 13742 }; -1 13743 -1 13744 /** -1 13745 * Sets the delay between reconnections. -1 13746 * -1 13747 * @param {Number} delay -1 13748 * @return {Manager} self or value -1 13749 * @api public -1 13750 */ -1 13751 -1 13752 Manager.prototype.reconnectionDelay = function (v) { -1 13753 if (!arguments.length) return this._reconnectionDelay; -1 13754 this._reconnectionDelay = v; -1 13755 this.backoff && this.backoff.setMin(v); -1 13756 return this; -1 13757 }; -1 13758 -1 13759 Manager.prototype.randomizationFactor = function (v) { -1 13760 if (!arguments.length) return this._randomizationFactor; -1 13761 this._randomizationFactor = v; -1 13762 this.backoff && this.backoff.setJitter(v); -1 13763 return this; -1 13764 }; -1 13765 -1 13766 /** -1 13767 * Sets the maximum delay between reconnections. -1 13768 * -1 13769 * @param {Number} delay -1 13770 * @return {Manager} self or value -1 13771 * @api public -1 13772 */ 14234 1377314235 -1 // Public: Serializes a JavaScript `value` as a JSON string. The optional14236 -1 // `filter` argument may specify either a function that alters how object and14237 -1 // array members are serialized, or an array of strings and numbers that14238 -1 // indicates which properties should be serialized. The optional `width`14239 -1 // argument may be either a string or number that specifies the indentation14240 -1 // level of the output.14241 -1 if (!has("json-stringify")) {14242 -1 // Internal: A map of control characters and their escaped equivalents.14243 -1 var Escapes = {14244 -1 92: "\\\\",14245 -1 34: '\\"',14246 -1 8: "\\b",14247 -1 12: "\\f",14248 -1 10: "\\n",14249 -1 13: "\\r",14250 -1 9: "\\t"14251 -1 };-1 13774 Manager.prototype.reconnectionDelayMax = function (v) { -1 13775 if (!arguments.length) return this._reconnectionDelayMax; -1 13776 this._reconnectionDelayMax = v; -1 13777 this.backoff && this.backoff.setMax(v); -1 13778 return this; -1 13779 }; 14252 1378014253 -1 // Internal: Converts `value` into a zero-padded string such that its14254 -1 // length is at least equal to `width`. The `width` must be <= 6.14255 -1 var leadingZeroes = "000000";14256 -1 var toPaddedString = function (width, value) {14257 -1 // The `|| 0` expression is necessary to work around a bug in14258 -1 // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`.14259 -1 return (leadingZeroes + (value || 0)).slice(-width);14260 -1 };-1 13781 /** -1 13782 * Sets the connection timeout. `false` to disable -1 13783 * -1 13784 * @return {Manager} self or value -1 13785 * @api public -1 13786 */ 14261 1378714262 -1 // Internal: Double-quotes a string `value`, replacing all ASCII control14263 -1 // characters (characters with code unit values between 0 and 31) with14264 -1 // their escaped equivalents. This is an implementation of the14265 -1 // `Quote(value)` operation defined in ES 5.1 section 15.12.3.14266 -1 var unicodePrefix = "\\u00";14267 -1 var quote = function (value) {14268 -1 var result = '"', index = 0, length = value.length, useCharIndex = !charIndexBuggy || length > 10;14269 -1 var symbols = useCharIndex && (charIndexBuggy ? value.split("") : value);14270 -1 for (; index < length; index++) {14271 -1 var charCode = value.charCodeAt(index);14272 -1 // If the character is a control character, append its Unicode or14273 -1 // shorthand escape sequence; otherwise, append the character as-is.14274 -1 switch (charCode) {14275 -1 case 8: case 9: case 10: case 12: case 13: case 34: case 92:14276 -1 result += Escapes[charCode];14277 -1 break;14278 -1 default:14279 -1 if (charCode < 32) {14280 -1 result += unicodePrefix + toPaddedString(2, charCode.toString(16));14281 -1 break;14282 -1 }14283 -1 result += useCharIndex ? symbols[index] : value.charAt(index);14284 -1 }14285 -1 }14286 -1 return result + '"';14287 -1 };-1 13788 Manager.prototype.timeout = function (v) { -1 13789 if (!arguments.length) return this._timeout; -1 13790 this._timeout = v; -1 13791 return this; -1 13792 }; 14288 1379314289 -1 // Internal: Recursively serializes an object. Implements the14290 -1 // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations.14291 -1 var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {14292 -1 var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, result;14293 -1 try {14294 -1 // Necessary for host object support.14295 -1 value = object[property];14296 -1 } catch (exception) {}14297 -1 if (typeof value == "object" && value) {14298 -1 className = getClass.call(value);14299 -1 if (className == dateClass && !isProperty.call(value, "toJSON")) {14300 -1 if (value > -1 / 0 && value < 1 / 0) {14301 -1 // Dates are serialized according to the `Date#toJSON` method14302 -1 // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.1514303 -1 // for the ISO 8601 date time string format.14304 -1 if (getDay) {14305 -1 // Manually compute the year, month, date, hours, minutes,14306 -1 // seconds, and milliseconds if the `getUTC*` methods are14307 -1 // buggy. Adapted from @Yaffle's `date-shim` project.14308 -1 date = floor(value / 864e5);14309 -1 for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);14310 -1 for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);14311 -1 date = 1 + date - getDay(year, month);14312 -1 // The `time` value specifies the time within the day (see ES14313 -1 // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used14314 -1 // to compute `A modulo B`, as the `%` operator does not14315 -1 // correspond to the `modulo` operation for negative numbers.14316 -1 time = (value % 864e5 + 864e5) % 864e5;14317 -1 // The hours, minutes, seconds, and milliseconds are obtained by14318 -1 // decomposing the time within the day. See section 15.9.1.10.14319 -1 hours = floor(time / 36e5) % 24;14320 -1 minutes = floor(time / 6e4) % 60;14321 -1 seconds = floor(time / 1e3) % 60;14322 -1 milliseconds = time % 1e3;14323 -1 } else {14324 -1 year = value.getUTCFullYear();14325 -1 month = value.getUTCMonth();14326 -1 date = value.getUTCDate();14327 -1 hours = value.getUTCHours();14328 -1 minutes = value.getUTCMinutes();14329 -1 seconds = value.getUTCSeconds();14330 -1 milliseconds = value.getUTCMilliseconds();14331 -1 }14332 -1 // Serialize extended years correctly.14333 -1 value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +14334 -1 "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +14335 -1 // Months, dates, hours, minutes, and seconds should have two14336 -1 // digits; milliseconds should have three.14337 -1 "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +14338 -1 // Milliseconds are optional in ES 5.0, but required in 5.1.14339 -1 "." + toPaddedString(3, milliseconds) + "Z";14340 -1 } else {14341 -1 value = null;14342 -1 }14343 -1 } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) {14344 -1 // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the14345 -1 // `Number`, `String`, `Date`, and `Array` prototypes. JSON 314346 -1 // ignores all `toJSON` methods on these objects unless they are14347 -1 // defined directly on an instance.14348 -1 value = value.toJSON(property);14349 -1 }14350 -1 }14351 -1 if (callback) {14352 -1 // If a replacement function was provided, call it to obtain the value14353 -1 // for serialization.14354 -1 value = callback.call(object, property, value);14355 -1 }14356 -1 if (value === null) {14357 -1 return "null";14358 -1 }14359 -1 className = getClass.call(value);14360 -1 if (className == booleanClass) {14361 -1 // Booleans are represented literally.14362 -1 return "" + value;14363 -1 } else if (className == numberClass) {14364 -1 // JSON numbers must be finite. `Infinity` and `NaN` are serialized as14365 -1 // `"null"`.14366 -1 return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";14367 -1 } else if (className == stringClass) {14368 -1 // Strings are double-quoted and escaped.14369 -1 return quote("" + value);14370 -1 }14371 -1 // Recursively serialize objects and arrays.14372 -1 if (typeof value == "object") {14373 -1 // Check for cyclic structures. This is a linear search; performance14374 -1 // is inversely proportional to the number of unique nested objects.14375 -1 for (length = stack.length; length--;) {14376 -1 if (stack[length] === value) {14377 -1 // Cyclic structures cannot be serialized by `JSON.stringify`.14378 -1 throw TypeError();14379 -1 }14380 -1 }14381 -1 // Add the object to the stack of traversed objects.14382 -1 stack.push(value);14383 -1 results = [];14384 -1 // Save the current indentation level and indent one additional level.14385 -1 prefix = indentation;14386 -1 indentation += whitespace;14387 -1 if (className == arrayClass) {14388 -1 // Recursively serialize array elements.14389 -1 for (index = 0, length = value.length; index < length; index++) {14390 -1 element = serialize(index, value, callback, properties, whitespace, indentation, stack);14391 -1 results.push(element === undef ? "null" : element);14392 -1 }14393 -1 result = results.length ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";14394 -1 } else {14395 -1 // Recursively serialize object members. Members are selected from14396 -1 // either a user-specified list of property names, or the object14397 -1 // itself.14398 -1 forEach(properties || value, function (property) {14399 -1 var element = serialize(property, value, callback, properties, whitespace, indentation, stack);14400 -1 if (element !== undef) {14401 -1 // According to ES 5.1 section 15.12.3: "If `gap` {whitespace}14402 -1 // is not the empty string, let `member` {quote(property) + ":"}14403 -1 // be the concatenation of `member` and the `space` character."14404 -1 // The "`space` character" refers to the literal space14405 -1 // character, not the `space` {width} argument provided to14406 -1 // `JSON.stringify`.14407 -1 results.push(quote(property) + ":" + (whitespace ? " " : "") + element);14408 -1 }14409 -1 });14410 -1 result = results.length ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";14411 -1 }14412 -1 // Remove the object from the traversed object stack.14413 -1 stack.pop();14414 -1 return result;14415 -1 }14416 -1 };-1 13794 /** -1 13795 * Starts trying to reconnect if reconnection is enabled and we have not -1 13796 * started reconnecting yet -1 13797 * -1 13798 * @api private -1 13799 */ -1 13800 -1 13801 Manager.prototype.maybeReconnectOnOpen = function () { -1 13802 // Only try to reconnect if it's the first time we're connecting -1 13803 if (!this.reconnecting && this._reconnection && this.backoff.attempts === 0) { -1 13804 // keeps reconnection from firing twice for the same reconnection loop -1 13805 this.reconnect(); -1 13806 } -1 13807 }; -1 13808 -1 13809 /** -1 13810 * Sets the current transport `socket`. -1 13811 * -1 13812 * @param {Function} optional, callback -1 13813 * @return {Manager} self -1 13814 * @api public -1 13815 */ -1 13816 -1 13817 Manager.prototype.open = -1 13818 Manager.prototype.connect = function (fn, opts) { -1 13819 debug('readyState %s', this.readyState); -1 13820 if (~this.readyState.indexOf('open')) return this; -1 13821 -1 13822 debug('opening %s', this.uri); -1 13823 this.engine = eio(this.uri, this.opts); -1 13824 var socket = this.engine; -1 13825 var self = this; -1 13826 this.readyState = 'opening'; -1 13827 this.skipReconnect = false; -1 13828 -1 13829 // emit `open` -1 13830 var openSub = on(socket, 'open', function () { -1 13831 self.onopen(); -1 13832 fn && fn(); -1 13833 }); -1 13834 -1 13835 // emit `connect_error` -1 13836 var errorSub = on(socket, 'error', function (data) { -1 13837 debug('connect_error'); -1 13838 self.cleanup(); -1 13839 self.readyState = 'closed'; -1 13840 self.emitAll('connect_error', data); -1 13841 if (fn) { -1 13842 var err = new Error('Connection error'); -1 13843 err.data = data; -1 13844 fn(err); -1 13845 } else { -1 13846 // Only do this if there is no fn to handle the error -1 13847 self.maybeReconnectOnOpen(); -1 13848 } -1 13849 }); -1 13850 -1 13851 // emit `connect_timeout` -1 13852 if (false !== this._timeout) { -1 13853 var timeout = this._timeout; -1 13854 debug('connect attempt will timeout after %d', timeout); -1 13855 -1 13856 // set timer -1 13857 var timer = setTimeout(function () { -1 13858 debug('connect attempt timed out after %d', timeout); -1 13859 openSub.destroy(); -1 13860 socket.close(); -1 13861 socket.emit('error', 'timeout'); -1 13862 self.emitAll('connect_timeout', timeout); -1 13863 }, timeout); 14417 1386414418 -1 // Public: `JSON.stringify`. See ES 5.1 section 15.12.3.14419 -1 exports.stringify = function (source, filter, width) {14420 -1 var whitespace, callback, properties, className;14421 -1 if (objectTypes[typeof filter] && filter) {14422 -1 if ((className = getClass.call(filter)) == functionClass) {14423 -1 callback = filter;14424 -1 } else if (className == arrayClass) {14425 -1 // Convert the property names array into a makeshift set.14426 -1 properties = {};14427 -1 for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((className = getClass.call(value)), className == stringClass || className == numberClass) && (properties[value] = 1));14428 -1 }14429 -1 }14430 -1 if (width) {14431 -1 if ((className = getClass.call(width)) == numberClass) {14432 -1 // Convert the `width` to an integer and create a string containing14433 -1 // `width` number of space characters.14434 -1 if ((width -= width % 1) > 0) {14435 -1 for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");14436 -1 }14437 -1 } else if (className == stringClass) {14438 -1 whitespace = width.length <= 10 ? width : width.slice(0, 10);14439 -1 }14440 -1 }14441 -1 // Opera <= 7.54u2 discards the values associated with empty string keys14442 -1 // (`""`) only if they are used directly within an object member list14443 -1 // (e.g., `!("" in { "": 1})`).14444 -1 return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);14445 -1 };-1 13865 this.subs.push({ -1 13866 destroy: function () { -1 13867 clearTimeout(timer); 14446 13868 } -1 13869 }); -1 13870 } 14447 1387114448 -1 // Public: Parses a JSON source string.14449 -1 if (!has("json-parse")) {14450 -1 var fromCharCode = String.fromCharCode;-1 13872 this.subs.push(openSub); -1 13873 this.subs.push(errorSub); 14451 1387414452 -1 // Internal: A map of escaped control characters and their unescaped14453 -1 // equivalents.14454 -1 var Unescapes = {14455 -1 92: "\\",14456 -1 34: '"',14457 -1 47: "/",14458 -1 98: "\b",14459 -1 116: "\t",14460 -1 110: "\n",14461 -1 102: "\f",14462 -1 114: "\r"14463 -1 };-1 13875 return this; -1 13876 }; 14464 1387714465 -1 // Internal: Stores the parser state.14466 -1 var Index, Source;-1 13878 /** -1 13879 * Called upon transport open. -1 13880 * -1 13881 * @api private -1 13882 */ 14467 1388314468 -1 // Internal: Resets the parser state and throws a `SyntaxError`.14469 -1 var abort = function () {14470 -1 Index = Source = null;14471 -1 throw SyntaxError();14472 -1 };-1 13884 Manager.prototype.onopen = function () { -1 13885 debug('open'); 14473 1388614474 -1 // Internal: Returns the next token, or `"$"` if the parser has reached14475 -1 // the end of the source string. A token may be a string, number, `null`14476 -1 // literal, or Boolean literal.14477 -1 var lex = function () {14478 -1 var source = Source, length = source.length, value, begin, position, isSigned, charCode;14479 -1 while (Index < length) {14480 -1 charCode = source.charCodeAt(Index);14481 -1 switch (charCode) {14482 -1 case 9: case 10: case 13: case 32:14483 -1 // Skip whitespace tokens, including tabs, carriage returns, line14484 -1 // feeds, and space characters.14485 -1 Index++;14486 -1 break;14487 -1 case 123: case 125: case 91: case 93: case 58: case 44:14488 -1 // Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at14489 -1 // the current position.14490 -1 value = charIndexBuggy ? source.charAt(Index) : source[Index];14491 -1 Index++;14492 -1 return value;14493 -1 case 34:14494 -1 // `"` delimits a JSON string; advance to the next character and14495 -1 // begin parsing the string. String tokens are prefixed with the14496 -1 // sentinel `@` character to distinguish them from punctuators and14497 -1 // end-of-string tokens.14498 -1 for (value = "@", Index++; Index < length;) {14499 -1 charCode = source.charCodeAt(Index);14500 -1 if (charCode < 32) {14501 -1 // Unescaped ASCII control characters (those with a code unit14502 -1 // less than the space character) are not permitted.14503 -1 abort();14504 -1 } else if (charCode == 92) {14505 -1 // A reverse solidus (`\`) marks the beginning of an escaped14506 -1 // control character (including `"`, `\`, and `/`) or Unicode14507 -1 // escape sequence.14508 -1 charCode = source.charCodeAt(++Index);14509 -1 switch (charCode) {14510 -1 case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114:14511 -1 // Revive escaped control characters.14512 -1 value += Unescapes[charCode];14513 -1 Index++;14514 -1 break;14515 -1 case 117:14516 -1 // `\u` marks the beginning of a Unicode escape sequence.14517 -1 // Advance to the first character and validate the14518 -1 // four-digit code point.14519 -1 begin = ++Index;14520 -1 for (position = Index + 4; Index < position; Index++) {14521 -1 charCode = source.charCodeAt(Index);14522 -1 // A valid sequence comprises four hexdigits (case-14523 -1 // insensitive) that form a single hexadecimal value.14524 -1 if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) {14525 -1 // Invalid Unicode escape sequence.14526 -1 abort();14527 -1 }14528 -1 }14529 -1 // Revive the escaped character.14530 -1 value += fromCharCode("0x" + source.slice(begin, Index));14531 -1 break;14532 -1 default:14533 -1 // Invalid escape sequence.14534 -1 abort();14535 -1 }14536 -1 } else {14537 -1 if (charCode == 34) {14538 -1 // An unescaped double-quote character marks the end of the14539 -1 // string.14540 -1 break;14541 -1 }14542 -1 charCode = source.charCodeAt(Index);14543 -1 begin = Index;14544 -1 // Optimize for the common case where a string is valid.14545 -1 while (charCode >= 32 && charCode != 92 && charCode != 34) {14546 -1 charCode = source.charCodeAt(++Index);14547 -1 }14548 -1 // Append the string as-is.14549 -1 value += source.slice(begin, Index);14550 -1 }14551 -1 }14552 -1 if (source.charCodeAt(Index) == 34) {14553 -1 // Advance to the next character and return the revived string.14554 -1 Index++;14555 -1 return value;14556 -1 }14557 -1 // Unterminated string.14558 -1 abort();14559 -1 default:14560 -1 // Parse numbers and literals.14561 -1 begin = Index;14562 -1 // Advance past the negative sign, if one is specified.14563 -1 if (charCode == 45) {14564 -1 isSigned = true;14565 -1 charCode = source.charCodeAt(++Index);14566 -1 }14567 -1 // Parse an integer or floating-point value.14568 -1 if (charCode >= 48 && charCode <= 57) {14569 -1 // Leading zeroes are interpreted as octal literals.14570 -1 if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) {14571 -1 // Illegal octal literal.14572 -1 abort();14573 -1 }14574 -1 isSigned = false;14575 -1 // Parse the integer component.14576 -1 for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++);14577 -1 // Floats cannot contain a leading decimal point; however, this14578 -1 // case is already accounted for by the parser.14579 -1 if (source.charCodeAt(Index) == 46) {14580 -1 position = ++Index;14581 -1 // Parse the decimal component.14582 -1 for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);14583 -1 if (position == Index) {14584 -1 // Illegal trailing decimal.14585 -1 abort();14586 -1 }14587 -1 Index = position;14588 -1 }14589 -1 // Parse exponents. The `e` denoting the exponent is14590 -1 // case-insensitive.14591 -1 charCode = source.charCodeAt(Index);14592 -1 if (charCode == 101 || charCode == 69) {14593 -1 charCode = source.charCodeAt(++Index);14594 -1 // Skip past the sign following the exponent, if one is14595 -1 // specified.14596 -1 if (charCode == 43 || charCode == 45) {14597 -1 Index++;14598 -1 }14599 -1 // Parse the exponential component.14600 -1 for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);14601 -1 if (position == Index) {14602 -1 // Illegal empty exponent.14603 -1 abort();14604 -1 }14605 -1 Index = position;14606 -1 }14607 -1 // Coerce the parsed value to a JavaScript number.14608 -1 return +source.slice(begin, Index);14609 -1 }14610 -1 // A negative sign may only precede numbers.14611 -1 if (isSigned) {14612 -1 abort();14613 -1 }14614 -1 // `true`, `false`, and `null` literals.14615 -1 if (source.slice(Index, Index + 4) == "true") {14616 -1 Index += 4;14617 -1 return true;14618 -1 } else if (source.slice(Index, Index + 5) == "false") {14619 -1 Index += 5;14620 -1 return false;14621 -1 } else if (source.slice(Index, Index + 4) == "null") {14622 -1 Index += 4;14623 -1 return null;14624 -1 }14625 -1 // Unrecognized token.14626 -1 abort();14627 -1 }14628 -1 }14629 -1 // Return the sentinel `$` character if the parser has reached the end14630 -1 // of the source string.14631 -1 return "$";14632 -1 };-1 13887 // clear old subs -1 13888 this.cleanup(); -1 13889 -1 13890 // mark as open -1 13891 this.readyState = 'open'; -1 13892 this.emit('open'); -1 13893 -1 13894 // add new subs -1 13895 var socket = this.engine; -1 13896 this.subs.push(on(socket, 'data', bind(this, 'ondata'))); -1 13897 this.subs.push(on(socket, 'ping', bind(this, 'onping'))); -1 13898 this.subs.push(on(socket, 'pong', bind(this, 'onpong'))); -1 13899 this.subs.push(on(socket, 'error', bind(this, 'onerror'))); -1 13900 this.subs.push(on(socket, 'close', bind(this, 'onclose'))); -1 13901 this.subs.push(on(this.decoder, 'decoded', bind(this, 'ondecoded'))); -1 13902 }; -1 13903 -1 13904 /** -1 13905 * Called upon a ping. -1 13906 * -1 13907 * @api private -1 13908 */ -1 13909 -1 13910 Manager.prototype.onping = function () { -1 13911 this.lastPing = new Date(); -1 13912 this.emitAll('ping'); -1 13913 }; -1 13914 -1 13915 /** -1 13916 * Called upon a packet. -1 13917 * -1 13918 * @api private -1 13919 */ 14633 1392014634 -1 // Internal: Parses a JSON `value` token.14635 -1 var get = function (value) {14636 -1 var results, hasMembers;14637 -1 if (value == "$") {14638 -1 // Unexpected end of input.14639 -1 abort();14640 -1 }14641 -1 if (typeof value == "string") {14642 -1 if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") {14643 -1 // Remove the sentinel `@` character.14644 -1 return value.slice(1);14645 -1 }14646 -1 // Parse object and array literals.14647 -1 if (value == "[") {14648 -1 // Parses a JSON array, returning a new JavaScript array.14649 -1 results = [];14650 -1 for (;; hasMembers || (hasMembers = true)) {14651 -1 value = lex();14652 -1 // A closing square bracket marks the end of the array literal.14653 -1 if (value == "]") {14654 -1 break;14655 -1 }14656 -1 // If the array literal contains elements, the current token14657 -1 // should be a comma separating the previous element from the14658 -1 // next.14659 -1 if (hasMembers) {14660 -1 if (value == ",") {14661 -1 value = lex();14662 -1 if (value == "]") {14663 -1 // Unexpected trailing `,` in array literal.14664 -1 abort();14665 -1 }14666 -1 } else {14667 -1 // A `,` must separate each array element.14668 -1 abort();14669 -1 }14670 -1 }14671 -1 // Elisions and leading commas are not permitted.14672 -1 if (value == ",") {14673 -1 abort();14674 -1 }14675 -1 results.push(get(value));14676 -1 }14677 -1 return results;14678 -1 } else if (value == "{") {14679 -1 // Parses a JSON object, returning a new JavaScript object.14680 -1 results = {};14681 -1 for (;; hasMembers || (hasMembers = true)) {14682 -1 value = lex();14683 -1 // A closing curly brace marks the end of the object literal.14684 -1 if (value == "}") {14685 -1 break;14686 -1 }14687 -1 // If the object literal contains members, the current token14688 -1 // should be a comma separator.14689 -1 if (hasMembers) {14690 -1 if (value == ",") {14691 -1 value = lex();14692 -1 if (value == "}") {14693 -1 // Unexpected trailing `,` in object literal.14694 -1 abort();14695 -1 }14696 -1 } else {14697 -1 // A `,` must separate each object member.14698 -1 abort();14699 -1 }14700 -1 }14701 -1 // Leading commas are not permitted, object property names must be14702 -1 // double-quoted strings, and a `:` must separate each property14703 -1 // name and value.14704 -1 if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") {14705 -1 abort();14706 -1 }14707 -1 results[value.slice(1)] = get(lex());14708 -1 }14709 -1 return results;14710 -1 }14711 -1 // Unexpected token encountered.14712 -1 abort();14713 -1 }14714 -1 return value;14715 -1 };-1 13921 Manager.prototype.onpong = function () { -1 13922 this.emitAll('pong', new Date() - this.lastPing); -1 13923 }; 14716 1392414717 -1 // Internal: Updates a traversed object member.14718 -1 var update = function (source, property, callback) {14719 -1 var element = walk(source, property, callback);14720 -1 if (element === undef) {14721 -1 delete source[property];14722 -1 } else {14723 -1 source[property] = element;14724 -1 }14725 -1 };-1 13925 /** -1 13926 * Called with data. -1 13927 * -1 13928 * @api private -1 13929 */ 14726 1393014727 -1 // Internal: Recursively traverses a parsed JSON object, invoking the14728 -1 // `callback` function for each value. This is an implementation of the14729 -1 // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.14730 -1 var walk = function (source, property, callback) {14731 -1 var value = source[property], length;14732 -1 if (typeof value == "object" && value) {14733 -1 // `forEach` can't be used to traverse an array in Opera <= 8.5414734 -1 // because its `Object#hasOwnProperty` implementation returns `false`14735 -1 // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`).14736 -1 if (getClass.call(value) == arrayClass) {14737 -1 for (length = value.length; length--;) {14738 -1 update(value, length, callback);14739 -1 }14740 -1 } else {14741 -1 forEach(value, function (property) {14742 -1 update(value, property, callback);14743 -1 });14744 -1 }14745 -1 }14746 -1 return callback.call(source, property, value);14747 -1 };-1 13931 Manager.prototype.ondata = function (data) { -1 13932 this.decoder.add(data); -1 13933 }; -1 13934 -1 13935 /** -1 13936 * Called when parser fully decodes a packet. -1 13937 * -1 13938 * @api private -1 13939 */ -1 13940 -1 13941 Manager.prototype.ondecoded = function (packet) { -1 13942 this.emit('packet', packet); -1 13943 }; -1 13944 -1 13945 /** -1 13946 * Called upon socket error. -1 13947 * -1 13948 * @api private -1 13949 */ -1 13950 -1 13951 Manager.prototype.onerror = function (err) { -1 13952 debug('error', err); -1 13953 this.emitAll('error', err); -1 13954 }; -1 13955 -1 13956 /** -1 13957 * Creates a new socket for the given `nsp`. -1 13958 * -1 13959 * @return {Socket} -1 13960 * @api public -1 13961 */ -1 13962 -1 13963 Manager.prototype.socket = function (nsp, opts) { -1 13964 var socket = this.nsps[nsp]; -1 13965 if (!socket) { -1 13966 socket = new Socket(this, nsp, opts); -1 13967 this.nsps[nsp] = socket; -1 13968 var self = this; -1 13969 socket.on('connecting', onConnecting); -1 13970 socket.on('connect', function () { -1 13971 socket.id = self.engine.id; -1 13972 }); -1 13973 -1 13974 if (this.autoConnect) { -1 13975 // manually call here since connecting evnet is fired before listening -1 13976 onConnecting(); -1 13977 } -1 13978 } -1 13979 -1 13980 function onConnecting () { -1 13981 if (!~indexOf(self.connecting, socket)) { -1 13982 self.connecting.push(socket); -1 13983 } -1 13984 } -1 13985 -1 13986 return socket; -1 13987 }; -1 13988 -1 13989 /** -1 13990 * Called upon a socket close. -1 13991 * -1 13992 * @param {Socket} socket -1 13993 */ -1 13994 -1 13995 Manager.prototype.destroy = function (socket) { -1 13996 var index = indexOf(this.connecting, socket); -1 13997 if (~index) this.connecting.splice(index, 1); -1 13998 if (this.connecting.length) return; -1 13999 -1 14000 this.close(); -1 14001 }; -1 14002 -1 14003 /** -1 14004 * Writes a packet. -1 14005 * -1 14006 * @param {Object} packet -1 14007 * @api private -1 14008 */ -1 14009 -1 14010 Manager.prototype.packet = function (packet) { -1 14011 debug('writing packet %j', packet); -1 14012 var self = this; -1 14013 if (packet.query && packet.type === 0) packet.nsp += '?' + packet.query; -1 14014 -1 14015 if (!self.encoding) { -1 14016 // encode, then write to engine with result -1 14017 self.encoding = true; -1 14018 this.encoder.encode(packet, function (encodedPackets) { -1 14019 for (var i = 0; i < encodedPackets.length; i++) { -1 14020 self.engine.write(encodedPackets[i], packet.options); -1 14021 } -1 14022 self.encoding = false; -1 14023 self.processPacketQueue(); -1 14024 }); -1 14025 } else { // add packet to the queue -1 14026 self.packetBuffer.push(packet); -1 14027 } -1 14028 }; -1 14029 -1 14030 /** -1 14031 * If packet buffer is non-empty, begins encoding the -1 14032 * next packet in line. -1 14033 * -1 14034 * @api private -1 14035 */ -1 14036 -1 14037 Manager.prototype.processPacketQueue = function () { -1 14038 if (this.packetBuffer.length > 0 && !this.encoding) { -1 14039 var pack = this.packetBuffer.shift(); -1 14040 this.packet(pack); -1 14041 } -1 14042 }; -1 14043 -1 14044 /** -1 14045 * Clean up transport subscriptions and packet buffer. -1 14046 * -1 14047 * @api private -1 14048 */ -1 14049 -1 14050 Manager.prototype.cleanup = function () { -1 14051 debug('cleanup'); -1 14052 -1 14053 var subsLength = this.subs.length; -1 14054 for (var i = 0; i < subsLength; i++) { -1 14055 var sub = this.subs.shift(); -1 14056 sub.destroy(); -1 14057 } -1 14058 -1 14059 this.packetBuffer = []; -1 14060 this.encoding = false; -1 14061 this.lastPing = null; -1 14062 -1 14063 this.decoder.destroy(); -1 14064 }; -1 14065 -1 14066 /** -1 14067 * Close the current socket. -1 14068 * -1 14069 * @api private -1 14070 */ -1 14071 -1 14072 Manager.prototype.close = -1 14073 Manager.prototype.disconnect = function () { -1 14074 debug('disconnect'); -1 14075 this.skipReconnect = true; -1 14076 this.reconnecting = false; -1 14077 if ('opening' === this.readyState) { -1 14078 // `onclose` will not fire because -1 14079 // an open event never happened -1 14080 this.cleanup(); -1 14081 } -1 14082 this.backoff.reset(); -1 14083 this.readyState = 'closed'; -1 14084 if (this.engine) this.engine.close(); -1 14085 }; 14748 1408614749 -1 // Public: `JSON.parse`. See ES 5.1 section 15.12.2.14750 -1 exports.parse = function (source, callback) {14751 -1 var result, value;14752 -1 Index = 0;14753 -1 Source = "" + source;14754 -1 result = get(lex());14755 -1 // If a JSON string contains multiple tokens, it is invalid.14756 -1 if (lex() != "$") {14757 -1 abort();14758 -1 }14759 -1 // Reset the parser state.14760 -1 Index = Source = null;14761 -1 return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result;14762 -1 };14763 -1 }14764 -1 }-1 14087 /** -1 14088 * Called upon engine close. -1 14089 * -1 14090 * @api private -1 14091 */ 14765 1409214766 -1 exports["runInContext"] = runInContext;14767 -1 return exports;-1 14093 Manager.prototype.onclose = function (reason) { -1 14094 debug('onclose'); -1 14095 -1 14096 this.cleanup(); -1 14097 this.backoff.reset(); -1 14098 this.readyState = 'closed'; -1 14099 this.emit('close', reason); -1 14100 -1 14101 if (this._reconnection && !this.skipReconnect) { -1 14102 this.reconnect(); 14768 14103 } -1 14104 }; 14769 1410514770 -1 if (freeExports && !isLoader) {14771 -1 // Export for CommonJS environments.14772 -1 runInContext(root, freeExports);-1 14106 /** -1 14107 * Attempt a reconnection. -1 14108 * -1 14109 * @api private -1 14110 */ -1 14111 -1 14112 Manager.prototype.reconnect = function () { -1 14113 if (this.reconnecting || this.skipReconnect) return this; -1 14114 -1 14115 var self = this; -1 14116 -1 14117 if (this.backoff.attempts >= this._reconnectionAttempts) { -1 14118 debug('reconnect failed'); -1 14119 this.backoff.reset(); -1 14120 this.emitAll('reconnect_failed'); -1 14121 this.reconnecting = false; 14773 14122 } else {14774 -1 // Export for web browsers and JavaScript engines.14775 -1 var nativeJSON = root.JSON,14776 -1 previousJSON = root["JSON3"],14777 -1 isRestored = false;-1 14123 var delay = this.backoff.duration(); -1 14124 debug('will wait %dms before reconnect attempt', delay); 14778 1412514779 -1 var JSON3 = runInContext(root, (root["JSON3"] = {14780 -1 // Public: Restores the original value of the global `JSON` object and14781 -1 // returns a reference to the `JSON3` object.14782 -1 "noConflict": function () {14783 -1 if (!isRestored) {14784 -1 isRestored = true;14785 -1 root.JSON = nativeJSON;14786 -1 root["JSON3"] = previousJSON;14787 -1 nativeJSON = previousJSON = null;14788 -1 }14789 -1 return JSON3;14790 -1 }14791 -1 }));-1 14126 this.reconnecting = true; -1 14127 var timer = setTimeout(function () { -1 14128 if (self.skipReconnect) return; 14792 1412914793 -1 root.JSON = {14794 -1 "parse": JSON3.parse,14795 -1 "stringify": JSON3.stringify14796 -1 };14797 -1 }-1 14130 debug('attempting reconnect'); -1 14131 self.emitAll('reconnect_attempt', self.backoff.attempts); -1 14132 self.emitAll('reconnecting', self.backoff.attempts); 14798 1413314799 -1 // Export for asynchronous module loaders.14800 -1 if (isLoader) {14801 -1 define(function () {14802 -1 return JSON3;-1 14134 // check again for the case socket closed in above events -1 14135 if (self.skipReconnect) return; -1 14136 -1 14137 self.open(function (err) { -1 14138 if (err) { -1 14139 debug('reconnect attempt error'); -1 14140 self.reconnecting = false; -1 14141 self.reconnect(); -1 14142 self.emitAll('reconnect_error', err.data); -1 14143 } else { -1 14144 debug('reconnect success'); -1 14145 self.onreconnect(); -1 14146 } -1 14147 }); -1 14148 }, delay); -1 14149 -1 14150 this.subs.push({ -1 14151 destroy: function () { -1 14152 clearTimeout(timer); -1 14153 } 14803 14154 }); 14804 14155 }14805 -1 }).call(this);-1 14156 }; 14806 1415714807 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})14808 -1 },{}],110:[function(require,module,exports){14809 -1 module.exports = toArray-1 14158 /** -1 14159 * Called upon successful reconnect. -1 14160 * -1 14161 * @api private -1 14162 */ 14810 1416314811 -1 function toArray(list, index) {14812 -1 var array = []-1 14164 Manager.prototype.onreconnect = function () { -1 14165 var attempt = this.backoff.attempts; -1 14166 this.reconnecting = false; -1 14167 this.backoff.reset(); -1 14168 this.updateSocketIds(); -1 14169 this.emitAll('reconnect', attempt); -1 14170 }; 14813 1417114814 -1 index = index || 0-1 14172 },{"./on":99,"./socket":100,"backo2":6,"component-bind":9,"component-emitter":102,"debug":103,"engine.io-client":12,"indexof":31,"socket.io-parser":107}],99:[function(require,module,exports){ 14815 1417314816 -1 for (var i = index || 0; i < list.length; i++) {14817 -1 array[i - index] = list[i]14818 -1 }-1 14174 /** -1 14175 * Module exports. -1 14176 */ 14819 1417714820 -1 return array-1 14178 module.exports = on; -1 14179 -1 14180 /** -1 14181 * Helper for subscriptions. -1 14182 * -1 14183 * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter` -1 14184 * @param {String} event name -1 14185 * @param {Function} callback -1 14186 * @api public -1 14187 */ -1 14188 -1 14189 function on (obj, ev, fn) { -1 14190 obj.on(ev, fn); -1 14191 return { -1 14192 destroy: function () { -1 14193 obj.removeListener(ev, fn); -1 14194 } -1 14195 }; 14821 14196 } 14822 1419714823 -1 },{}],111:[function(require,module,exports){14824 -1 module.exports=/[\0-\x1F\x7F-\x9F]/14825 -1 },{}],112:[function(require,module,exports){14826 -1 module.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804\uDCBD|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/14827 -1 },{}],113:[function(require,module,exports){14828 -1 module.exports=/[!-#%-\*,-/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/14829 -1 },{}],114:[function(require,module,exports){14830 -1 module.exports=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/14831 -1 },{}],115:[function(require,module,exports){-1 14198 },{}],100:[function(require,module,exports){ 14832 1419914833 -1 module.exports.Any = require('./properties/Any/regex');14834 -1 module.exports.Cc = require('./categories/Cc/regex');14835 -1 module.exports.Cf = require('./categories/Cf/regex');14836 -1 module.exports.P = require('./categories/P/regex');14837 -1 module.exports.Z = require('./categories/Z/regex');-1 14200 /** -1 14201 * Module dependencies. -1 14202 */ 14838 1420314839 -1 },{"./categories/Cc/regex":111,"./categories/Cf/regex":112,"./categories/P/regex":113,"./categories/Z/regex":114,"./properties/Any/regex":116}],116:[function(require,module,exports){14840 -1 module.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/14841 -1 },{}],117:[function(require,module,exports){14842 -1 (function (global){14843 -1 /*! https://mths.be/utf8js v2.0.0 by @mathias */14844 -1 ;(function(root) {-1 14204 var parser = require('socket.io-parser'); -1 14205 var Emitter = require('component-emitter'); -1 14206 var toArray = require('to-array'); -1 14207 var on = require('./on'); -1 14208 var bind = require('component-bind'); -1 14209 var debug = require('debug')('socket.io-client:socket'); -1 14210 var hasBin = require('has-binary'); 14845 1421114846 -1 // Detect free variables `exports`14847 -1 var freeExports = typeof exports == 'object' && exports;-1 14212 /** -1 14213 * Module exports. -1 14214 */ 14848 1421514849 -1 // Detect free variable `module`14850 -1 var freeModule = typeof module == 'object' && module &&14851 -1 module.exports == freeExports && module;-1 14216 module.exports = exports = Socket; 14852 1421714853 -1 // Detect free variable `global`, from Node.js or Browserified code,14854 -1 // and use it as `root`14855 -1 var freeGlobal = typeof global == 'object' && global;14856 -1 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {14857 -1 root = freeGlobal;14858 -1 }-1 14218 /** -1 14219 * Internal events (blacklisted). -1 14220 * These events can't be emitted by the user. -1 14221 * -1 14222 * @api private -1 14223 */ 14859 1422414860 -1 /*--------------------------------------------------------------------------*/-1 14225 var events = { -1 14226 connect: 1, -1 14227 connect_error: 1, -1 14228 connect_timeout: 1, -1 14229 connecting: 1, -1 14230 disconnect: 1, -1 14231 error: 1, -1 14232 reconnect: 1, -1 14233 reconnect_attempt: 1, -1 14234 reconnect_failed: 1, -1 14235 reconnect_error: 1, -1 14236 reconnecting: 1, -1 14237 ping: 1, -1 14238 pong: 1 -1 14239 }; 14861 1424014862 -1 var stringFromCharCode = String.fromCharCode;-1 14241 /** -1 14242 * Shortcut to `Emitter#emit`. -1 14243 */ 14863 1424414864 -1 // Taken from https://mths.be/punycode14865 -1 function ucs2decode(string) {14866 -1 var output = [];14867 -1 var counter = 0;14868 -1 var length = string.length;14869 -1 var value;14870 -1 var extra;14871 -1 while (counter < length) {14872 -1 value = string.charCodeAt(counter++);14873 -1 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {14874 -1 // high surrogate, and there is a next character14875 -1 extra = string.charCodeAt(counter++);14876 -1 if ((extra & 0xFC00) == 0xDC00) { // low surrogate14877 -1 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);14878 -1 } else {14879 -1 // unmatched surrogate; only append this code unit, in case the next14880 -1 // code unit is the high surrogate of a surrogate pair14881 -1 output.push(value);14882 -1 counter--;14883 -1 }14884 -1 } else {14885 -1 output.push(value);14886 -1 }14887 -1 }14888 -1 return output;14889 -1 }-1 14245 var emit = Emitter.prototype.emit; -1 14246 -1 14247 /** -1 14248 * `Socket` constructor. -1 14249 * -1 14250 * @api public -1 14251 */ -1 14252 -1 14253 function Socket (io, nsp, opts) { -1 14254 this.io = io; -1 14255 this.nsp = nsp; -1 14256 this.json = this; // compat -1 14257 this.ids = 0; -1 14258 this.acks = {}; -1 14259 this.receiveBuffer = []; -1 14260 this.sendBuffer = []; -1 14261 this.connected = false; -1 14262 this.disconnected = true; -1 14263 if (opts && opts.query) { -1 14264 this.query = opts.query; -1 14265 } -1 14266 if (this.io.autoConnect) this.open(); -1 14267 } -1 14268 -1 14269 /** -1 14270 * Mix in `Emitter`. -1 14271 */ -1 14272 -1 14273 Emitter(Socket.prototype); 14890 1427414891 -1 // Taken from https://mths.be/punycode14892 -1 function ucs2encode(array) {14893 -1 var length = array.length;14894 -1 var index = -1;14895 -1 var value;14896 -1 var output = '';14897 -1 while (++index < length) {14898 -1 value = array[index];14899 -1 if (value > 0xFFFF) {14900 -1 value -= 0x10000;14901 -1 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);14902 -1 value = 0xDC00 | value & 0x3FF;14903 -1 }14904 -1 output += stringFromCharCode(value);14905 -1 }14906 -1 return output;14907 -1 }-1 14275 /** -1 14276 * Subscribe to open, close and packet events -1 14277 * -1 14278 * @api private -1 14279 */ 14908 1428014909 -1 function checkScalarValue(codePoint) {14910 -1 if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {14911 -1 throw Error(14912 -1 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +14913 -1 ' is not a scalar value'14914 -1 );14915 -1 }14916 -1 }14917 -1 /*--------------------------------------------------------------------------*/-1 14281 Socket.prototype.subEvents = function () { -1 14282 if (this.subs) return; 14918 1428314919 -1 function createByte(codePoint, shift) {14920 -1 return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);14921 -1 }-1 14284 var io = this.io; -1 14285 this.subs = [ -1 14286 on(io, 'open', bind(this, 'onopen')), -1 14287 on(io, 'packet', bind(this, 'onpacket')), -1 14288 on(io, 'close', bind(this, 'onclose')) -1 14289 ]; -1 14290 }; 14922 1429114923 -1 function encodeCodePoint(codePoint) {14924 -1 if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence14925 -1 return stringFromCharCode(codePoint);14926 -1 }14927 -1 var symbol = '';14928 -1 if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence14929 -1 symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);14930 -1 }14931 -1 else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence14932 -1 checkScalarValue(codePoint);14933 -1 symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);14934 -1 symbol += createByte(codePoint, 6);14935 -1 }14936 -1 else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence14937 -1 symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);14938 -1 symbol += createByte(codePoint, 12);14939 -1 symbol += createByte(codePoint, 6);14940 -1 }14941 -1 symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);14942 -1 return symbol;14943 -1 }-1 14292 /** -1 14293 * "Opens" the socket. -1 14294 * -1 14295 * @api public -1 14296 */ 14944 1429714945 -1 function utf8encode(string) {14946 -1 var codePoints = ucs2decode(string);14947 -1 var length = codePoints.length;14948 -1 var index = -1;14949 -1 var codePoint;14950 -1 var byteString = '';14951 -1 while (++index < length) {14952 -1 codePoint = codePoints[index];14953 -1 byteString += encodeCodePoint(codePoint);14954 -1 }14955 -1 return byteString;14956 -1 }-1 14298 Socket.prototype.open = -1 14299 Socket.prototype.connect = function () { -1 14300 if (this.connected) return this; 14957 1430114958 -1 /*--------------------------------------------------------------------------*/-1 14302 this.subEvents(); -1 14303 this.io.open(); // ensure open -1 14304 if ('open' === this.io.readyState) this.onopen(); -1 14305 this.emit('connecting'); -1 14306 return this; -1 14307 }; 14959 1430814960 -1 function readContinuationByte() {14961 -1 if (byteIndex >= byteCount) {14962 -1 throw Error('Invalid byte index');14963 -1 }-1 14309 /** -1 14310 * Sends a `message` event. -1 14311 * -1 14312 * @return {Socket} self -1 14313 * @api public -1 14314 */ 14964 1431514965 -1 var continuationByte = byteArray[byteIndex] & 0xFF;14966 -1 byteIndex++;-1 14316 Socket.prototype.send = function () { -1 14317 var args = toArray(arguments); -1 14318 args.unshift('message'); -1 14319 this.emit.apply(this, args); -1 14320 return this; -1 14321 }; 14967 1432214968 -1 if ((continuationByte & 0xC0) == 0x80) {14969 -1 return continuationByte & 0x3F;14970 -1 }-1 14323 /** -1 14324 * Override `emit`. -1 14325 * If the event is in `events`, it's emitted normally. -1 14326 * -1 14327 * @param {String} event name -1 14328 * @return {Socket} self -1 14329 * @api public -1 14330 */ 14971 1433114972 -1 // If we end up here, it’s not a continuation byte14973 -1 throw Error('Invalid continuation byte');14974 -1 }-1 14332 Socket.prototype.emit = function (ev) { -1 14333 if (events.hasOwnProperty(ev)) { -1 14334 emit.apply(this, arguments); -1 14335 return this; -1 14336 } 14975 1433714976 -1 function decodeSymbol() {14977 -1 var byte1;14978 -1 var byte2;14979 -1 var byte3;14980 -1 var byte4;14981 -1 var codePoint;-1 14338 var args = toArray(arguments); -1 14339 var parserType = parser.EVENT; // default -1 14340 if (hasBin(args)) { parserType = parser.BINARY_EVENT; } // binary -1 14341 var packet = { type: parserType, data: args }; 14982 1434214983 -1 if (byteIndex > byteCount) {14984 -1 throw Error('Invalid byte index');14985 -1 }-1 14343 packet.options = {}; -1 14344 packet.options.compress = !this.flags || false !== this.flags.compress; 14986 1434514987 -1 if (byteIndex == byteCount) {14988 -1 return false;14989 -1 }-1 14346 // event ack callback -1 14347 if ('function' === typeof args[args.length - 1]) { -1 14348 debug('emitting packet with ack id %d', this.ids); -1 14349 this.acks[this.ids] = args.pop(); -1 14350 packet.id = this.ids++; -1 14351 } 14990 1435214991 -1 // Read first byte14992 -1 byte1 = byteArray[byteIndex] & 0xFF;14993 -1 byteIndex++;-1 14353 if (this.connected) { -1 14354 this.packet(packet); -1 14355 } else { -1 14356 this.sendBuffer.push(packet); -1 14357 } 14994 1435814995 -1 // 1-byte sequence (no continuation bytes)14996 -1 if ((byte1 & 0x80) == 0) {14997 -1 return byte1;14998 -1 }-1 14359 delete this.flags; 14999 1436015000 -1 // 2-byte sequence15001 -1 if ((byte1 & 0xE0) == 0xC0) {15002 -1 var byte2 = readContinuationByte();15003 -1 codePoint = ((byte1 & 0x1F) << 6) | byte2;15004 -1 if (codePoint >= 0x80) {15005 -1 return codePoint;15006 -1 } else {15007 -1 throw Error('Invalid continuation byte');15008 -1 }15009 -1 }-1 14361 return this; -1 14362 }; 15010 1436315011 -1 // 3-byte sequence (may include unpaired surrogates)15012 -1 if ((byte1 & 0xF0) == 0xE0) {15013 -1 byte2 = readContinuationByte();15014 -1 byte3 = readContinuationByte();15015 -1 codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;15016 -1 if (codePoint >= 0x0800) {15017 -1 checkScalarValue(codePoint);15018 -1 return codePoint;15019 -1 } else {15020 -1 throw Error('Invalid continuation byte');15021 -1 }15022 -1 }-1 14364 /** -1 14365 * Sends a packet. -1 14366 * -1 14367 * @param {Object} packet -1 14368 * @api private -1 14369 */ 15023 1437015024 -1 // 4-byte sequence15025 -1 if ((byte1 & 0xF8) == 0xF0) {15026 -1 byte2 = readContinuationByte();15027 -1 byte3 = readContinuationByte();15028 -1 byte4 = readContinuationByte();15029 -1 codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) |15030 -1 (byte3 << 0x06) | byte4;15031 -1 if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {15032 -1 return codePoint;15033 -1 }15034 -1 }-1 14371 Socket.prototype.packet = function (packet) { -1 14372 packet.nsp = this.nsp; -1 14373 this.io.packet(packet); -1 14374 }; 15035 1437515036 -1 throw Error('Invalid UTF-8 detected');15037 -1 }-1 14376 /** -1 14377 * Called upon engine `open`. -1 14378 * -1 14379 * @api private -1 14380 */ 15038 1438115039 -1 var byteArray;15040 -1 var byteCount;15041 -1 var byteIndex;15042 -1 function utf8decode(byteString) {15043 -1 byteArray = ucs2decode(byteString);15044 -1 byteCount = byteArray.length;15045 -1 byteIndex = 0;15046 -1 var codePoints = [];15047 -1 var tmp;15048 -1 while ((tmp = decodeSymbol()) !== false) {15049 -1 codePoints.push(tmp);15050 -1 }15051 -1 return ucs2encode(codePoints);15052 -1 }-1 14382 Socket.prototype.onopen = function () { -1 14383 debug('transport is open - connecting'); 15053 1438415054 -1 /*--------------------------------------------------------------------------*/-1 14385 // write connect packet if necessary -1 14386 if ('/' !== this.nsp) { -1 14387 if (this.query) { -1 14388 this.packet({type: parser.CONNECT, query: this.query}); -1 14389 } else { -1 14390 this.packet({type: parser.CONNECT}); -1 14391 } -1 14392 } -1 14393 }; 15055 1439415056 -1 var utf8 = {15057 -1 'version': '2.0.0',15058 -1 'encode': utf8encode,15059 -1 'decode': utf8decode15060 -1 };-1 14395 /** -1 14396 * Called upon engine `close`. -1 14397 * -1 14398 * @param {String} reason -1 14399 * @api private -1 14400 */ 15061 1440115062 -1 // Some AMD build optimizers, like r.js, check for specific condition patterns15063 -1 // like the following:15064 -1 if (15065 -1 typeof define == 'function' &&15066 -1 typeof define.amd == 'object' &&15067 -1 define.amd15068 -1 ) {15069 -1 define(function() {15070 -1 return utf8;15071 -1 });15072 -1 } else if (freeExports && !freeExports.nodeType) {15073 -1 if (freeModule) { // in Node.js or RingoJS v0.8.0+15074 -1 freeModule.exports = utf8;15075 -1 } else { // in Narwhal or RingoJS v0.7.0-15076 -1 var object = {};15077 -1 var hasOwnProperty = object.hasOwnProperty;15078 -1 for (var key in utf8) {15079 -1 hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);15080 -1 }15081 -1 }15082 -1 } else { // in Rhino or a web browser15083 -1 root.utf8 = utf8;15084 -1 }-1 14402 Socket.prototype.onclose = function (reason) { -1 14403 debug('close (%s)', reason); -1 14404 this.connected = false; -1 14405 this.disconnected = true; -1 14406 delete this.id; -1 14407 this.emit('disconnect', reason); -1 14408 }; -1 14409 -1 14410 /** -1 14411 * Called with socket packet. -1 14412 * -1 14413 * @param {Object} packet -1 14414 * @api private -1 14415 */ 15085 1441615086 -1 }(this));-1 14417 Socket.prototype.onpacket = function (packet) { -1 14418 if (packet.nsp !== this.nsp) return; 15087 1441915088 -1 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})15089 -1 },{}],118:[function(require,module,exports){15090 -1 var createElement = require("./vdom/create-element.js")-1 14420 switch (packet.type) { -1 14421 case parser.CONNECT: -1 14422 this.onconnect(); -1 14423 break; 15091 1442415092 -1 module.exports = createElement-1 14425 case parser.EVENT: -1 14426 this.onevent(packet); -1 14427 break; 15093 1442815094 -1 },{"./vdom/create-element.js":124}],119:[function(require,module,exports){15095 -1 var diff = require("./vtree/diff.js")-1 14429 case parser.BINARY_EVENT: -1 14430 this.onevent(packet); -1 14431 break; 15096 1443215097 -1 module.exports = diff-1 14433 case parser.ACK: -1 14434 this.onack(packet); -1 14435 break; 15098 1443615099 -1 },{"./vtree/diff.js":144}],120:[function(require,module,exports){15100 -1 var h = require("./virtual-hyperscript/index.js")-1 14437 case parser.BINARY_ACK: -1 14438 this.onack(packet); -1 14439 break; 15101 1444015102 -1 module.exports = h-1 14441 case parser.DISCONNECT: -1 14442 this.ondisconnect(); -1 14443 break; 15103 1444415104 -1 },{"./virtual-hyperscript/index.js":131}],121:[function(require,module,exports){15105 -1 var diff = require("./diff.js")15106 -1 var patch = require("./patch.js")15107 -1 var h = require("./h.js")15108 -1 var create = require("./create-element.js")15109 -1 var VNode = require('./vnode/vnode.js')15110 -1 var VText = require('./vnode/vtext.js')15111 -115112 -1 module.exports = {15113 -1 diff: diff,15114 -1 patch: patch,15115 -1 h: h,15116 -1 create: create,15117 -1 VNode: VNode,15118 -1 VText: VText15119 -1 }-1 14445 case parser.ERROR: -1 14446 this.emit('error', packet.data); -1 14447 break; -1 14448 } -1 14449 }; 15120 1445015121 -1 },{"./create-element.js":118,"./diff.js":119,"./h.js":120,"./patch.js":122,"./vnode/vnode.js":140,"./vnode/vtext.js":142}],122:[function(require,module,exports){15122 -1 var patch = require("./vdom/patch.js")-1 14451 /** -1 14452 * Called upon a server event. -1 14453 * -1 14454 * @param {Object} packet -1 14455 * @api private -1 14456 */ 15123 1445715124 -1 module.exports = patch-1 14458 Socket.prototype.onevent = function (packet) { -1 14459 var args = packet.data || []; -1 14460 debug('emitting event %j', args); 15125 1446115126 -1 },{"./vdom/patch.js":127}],123:[function(require,module,exports){15127 -1 var isObject = require("is-object")15128 -1 var isHook = require("../vnode/is-vhook.js")-1 14462 if (null != packet.id) { -1 14463 debug('attaching ack callback to event'); -1 14464 args.push(this.ack(packet.id)); -1 14465 } 15129 1446615130 -1 module.exports = applyProperties-1 14467 if (this.connected) { -1 14468 emit.apply(this, args); -1 14469 } else { -1 14470 this.receiveBuffer.push(args); -1 14471 } -1 14472 }; 15131 1447315132 -1 function applyProperties(node, props, previous) {15133 -1 for (var propName in props) {15134 -1 var propValue = props[propName]-1 14474 /** -1 14475 * Produces an ack callback to emit with an event. -1 14476 * -1 14477 * @api private -1 14478 */ 15135 1447915136 -1 if (propValue === undefined) {15137 -1 removeProperty(node, propName, propValue, previous);15138 -1 } else if (isHook(propValue)) {15139 -1 removeProperty(node, propName, propValue, previous)15140 -1 if (propValue.hook) {15141 -1 propValue.hook(node,15142 -1 propName,15143 -1 previous ? previous[propName] : undefined)15144 -1 }15145 -1 } else {15146 -1 if (isObject(propValue)) {15147 -1 patchObject(node, props, previous, propName, propValue);15148 -1 } else {15149 -1 node[propName] = propValue15150 -1 }15151 -1 }15152 -1 }15153 -1 }-1 14480 Socket.prototype.ack = function (id) { -1 14481 var self = this; -1 14482 var sent = false; -1 14483 return function () { -1 14484 // prevent double callbacks -1 14485 if (sent) return; -1 14486 sent = true; -1 14487 var args = toArray(arguments); -1 14488 debug('sending ack %j', args); 15154 1448915155 -1 function removeProperty(node, propName, propValue, previous) {15156 -1 if (previous) {15157 -1 var previousValue = previous[propName]-1 14490 var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK; -1 14491 self.packet({ -1 14492 type: type, -1 14493 id: id, -1 14494 data: args -1 14495 }); -1 14496 }; -1 14497 }; 15158 1449815159 -1 if (!isHook(previousValue)) {15160 -1 if (propName === "attributes") {15161 -1 for (var attrName in previousValue) {15162 -1 node.removeAttribute(attrName)15163 -1 }15164 -1 } else if (propName === "style") {15165 -1 for (var i in previousValue) {15166 -1 node.style[i] = ""15167 -1 }15168 -1 } else if (typeof previousValue === "string") {15169 -1 node[propName] = ""15170 -1 } else {15171 -1 node[propName] = null15172 -1 }15173 -1 } else if (previousValue.unhook) {15174 -1 previousValue.unhook(node, propName, propValue)15175 -1 }15176 -1 }15177 -1 }-1 14499 /** -1 14500 * Called upon a server acknowlegement. -1 14501 * -1 14502 * @param {Object} packet -1 14503 * @api private -1 14504 */ -1 14505 -1 14506 Socket.prototype.onack = function (packet) { -1 14507 var ack = this.acks[packet.id]; -1 14508 if ('function' === typeof ack) { -1 14509 debug('calling ack %s with %j', packet.id, packet.data); -1 14510 ack.apply(this, packet.data); -1 14511 delete this.acks[packet.id]; -1 14512 } else { -1 14513 debug('bad ack %s', packet.id); -1 14514 } -1 14515 }; 15178 1451615179 -1 function patchObject(node, props, previous, propName, propValue) {15180 -1 var previousValue = previous ? previous[propName] : undefined-1 14517 /** -1 14518 * Called upon server connect. -1 14519 * -1 14520 * @api private -1 14521 */ 15181 1452215182 -1 // Set attributes15183 -1 if (propName === "attributes") {15184 -1 for (var attrName in propValue) {15185 -1 var attrValue = propValue[attrName]-1 14523 Socket.prototype.onconnect = function () { -1 14524 this.connected = true; -1 14525 this.disconnected = false; -1 14526 this.emit('connect'); -1 14527 this.emitBuffered(); -1 14528 }; 15186 1452915187 -1 if (attrValue === undefined) {15188 -1 node.removeAttribute(attrName)15189 -1 } else {15190 -1 node.setAttribute(attrName, attrValue)15191 -1 }15192 -1 }-1 14530 /** -1 14531 * Emit buffered events (received and emitted). -1 14532 * -1 14533 * @api private -1 14534 */ 15193 1453515194 -1 return15195 -1 }-1 14536 Socket.prototype.emitBuffered = function () { -1 14537 var i; -1 14538 for (i = 0; i < this.receiveBuffer.length; i++) { -1 14539 emit.apply(this, this.receiveBuffer[i]); -1 14540 } -1 14541 this.receiveBuffer = []; 15196 1454215197 -1 if(previousValue && isObject(previousValue) &&15198 -1 getPrototype(previousValue) !== getPrototype(propValue)) {15199 -1 node[propName] = propValue15200 -1 return15201 -1 }-1 14543 for (i = 0; i < this.sendBuffer.length; i++) { -1 14544 this.packet(this.sendBuffer[i]); -1 14545 } -1 14546 this.sendBuffer = []; -1 14547 }; 15202 1454815203 -1 if (!isObject(node[propName])) {15204 -1 node[propName] = {}15205 -1 }-1 14549 /** -1 14550 * Called upon server disconnect. -1 14551 * -1 14552 * @api private -1 14553 */ 15206 1455415207 -1 var replacer = propName === "style" ? "" : undefined-1 14555 Socket.prototype.ondisconnect = function () { -1 14556 debug('server disconnect (%s)', this.nsp); -1 14557 this.destroy(); -1 14558 this.onclose('io server disconnect'); -1 14559 }; 15208 1456015209 -1 for (var k in propValue) {15210 -1 var value = propValue[k]15211 -1 node[propName][k] = (value === undefined) ? replacer : value15212 -1 }15213 -1 }-1 14561 /** -1 14562 * Called upon forced client/server side disconnections, -1 14563 * this method ensures the manager stops tracking us and -1 14564 * that reconnections don't get triggered for this. -1 14565 * -1 14566 * @api private. -1 14567 */ 15214 1456815215 -1 function getPrototype(value) {15216 -1 if (Object.getPrototypeOf) {15217 -1 return Object.getPrototypeOf(value)15218 -1 } else if (value.__proto__) {15219 -1 return value.__proto__15220 -1 } else if (value.constructor) {15221 -1 return value.constructor.prototype-1 14569 Socket.prototype.destroy = function () { -1 14570 if (this.subs) { -1 14571 // clean subscriptions to avoid reconnections -1 14572 for (var i = 0; i < this.subs.length; i++) { -1 14573 this.subs[i].destroy(); 15222 14574 }15223 -1 }-1 14575 this.subs = null; -1 14576 } 15224 1457715225 -1 },{"../vnode/is-vhook.js":135,"is-object":35}],124:[function(require,module,exports){15226 -1 var document = require("global/document")-1 14578 this.io.destroy(this); -1 14579 }; 15227 1458015228 -1 var applyProperties = require("./apply-properties")-1 14581 /** -1 14582 * Disconnects the socket manually. -1 14583 * -1 14584 * @return {Socket} self -1 14585 * @api public -1 14586 */ 15229 1458715230 -1 var isVNode = require("../vnode/is-vnode.js")15231 -1 var isVText = require("../vnode/is-vtext.js")15232 -1 var isWidget = require("../vnode/is-widget.js")15233 -1 var handleThunk = require("../vnode/handle-thunk.js")-1 14588 Socket.prototype.close = -1 14589 Socket.prototype.disconnect = function () { -1 14590 if (this.connected) { -1 14591 debug('performing disconnect (%s)', this.nsp); -1 14592 this.packet({ type: parser.DISCONNECT }); -1 14593 } 15234 1459415235 -1 module.exports = createElement-1 14595 // remove socket from pool -1 14596 this.destroy(); 15236 1459715237 -1 function createElement(vnode, opts) {15238 -1 var doc = opts ? opts.document || document : document15239 -1 var warn = opts ? opts.warn : null-1 14598 if (this.connected) { -1 14599 // fire events -1 14600 this.onclose('io client disconnect'); -1 14601 } -1 14602 return this; -1 14603 }; 15240 1460415241 -1 vnode = handleThunk(vnode).a-1 14605 /** -1 14606 * Sets the compress flag. -1 14607 * -1 14608 * @param {Boolean} if `true`, compresses the sending data -1 14609 * @return {Socket} self -1 14610 * @api public -1 14611 */ 15242 1461215243 -1 if (isWidget(vnode)) {15244 -1 return vnode.init()15245 -1 } else if (isVText(vnode)) {15246 -1 return doc.createTextNode(vnode.text)15247 -1 } else if (!isVNode(vnode)) {15248 -1 if (warn) {15249 -1 warn("Item is not a valid virtual dom node", vnode)15250 -1 }15251 -1 return null15252 -1 }-1 14613 Socket.prototype.compress = function (compress) { -1 14614 this.flags = this.flags || {}; -1 14615 this.flags.compress = compress; -1 14616 return this; -1 14617 }; 15253 1461815254 -1 var node = (vnode.namespace === null) ?15255 -1 doc.createElement(vnode.tagName) :15256 -1 doc.createElementNS(vnode.namespace, vnode.tagName)-1 14619 },{"./on":99,"component-bind":9,"component-emitter":102,"debug":103,"has-binary":29,"socket.io-parser":107,"to-array":112}],101:[function(require,module,exports){ -1 14620 (function (global){ 15257 1462115258 -1 var props = vnode.properties15259 -1 applyProperties(node, props)-1 14622 /** -1 14623 * Module dependencies. -1 14624 */ 15260 1462515261 -1 var children = vnode.children-1 14626 var parseuri = require('parseuri'); -1 14627 var debug = require('debug')('socket.io-client:url'); 15262 1462815263 -1 for (var i = 0; i < children.length; i++) {15264 -1 var childNode = createElement(children[i], opts)15265 -1 if (childNode) {15266 -1 node.appendChild(childNode)15267 -1 }15268 -1 }-1 14629 /** -1 14630 * Module exports. -1 14631 */ 15269 1463215270 -1 return node15271 -1 }-1 14633 module.exports = url; 15272 1463415273 -1 },{"../vnode/handle-thunk.js":133,"../vnode/is-vnode.js":136,"../vnode/is-vtext.js":137,"../vnode/is-widget.js":138,"./apply-properties":123,"global/document":29}],125:[function(require,module,exports){15274 -1 // Maps a virtual DOM tree onto a real DOM tree in an efficient manner.15275 -1 // We don't want to read all of the DOM nodes in the tree so we use15276 -1 // the in-order tree indexing to eliminate recursion down certain branches.15277 -1 // We only recurse into a DOM node if we know that it contains a child of15278 -1 // interest.-1 14635 /** -1 14636 * URL parser. -1 14637 * -1 14638 * @param {String} url -1 14639 * @param {Object} An object meant to mimic window.location. -1 14640 * Defaults to window.location. -1 14641 * @api public -1 14642 */ 15279 1464315280 -1 var noChild = {}-1 14644 function url (uri, loc) { -1 14645 var obj = uri; 15281 1464615282 -1 module.exports = domIndex-1 14647 // default to window.location -1 14648 loc = loc || global.location; -1 14649 if (null == uri) uri = loc.protocol + '//' + loc.host; 15283 1465015284 -1 function domIndex(rootNode, tree, indices, nodes) {15285 -1 if (!indices || indices.length === 0) {15286 -1 return {}15287 -1 } else {15288 -1 indices.sort(ascending)15289 -1 return recurse(rootNode, tree, indices, nodes, 0)-1 14651 // relative path support -1 14652 if ('string' === typeof uri) { -1 14653 if ('/' === uri.charAt(0)) { -1 14654 if ('/' === uri.charAt(1)) { -1 14655 uri = loc.protocol + uri; -1 14656 } else { -1 14657 uri = loc.host + uri; -1 14658 } 15290 14659 }15291 -1 }15292 -115293 -1 function recurse(rootNode, tree, indices, nodes, rootIndex) {15294 -1 nodes = nodes || {}15295 -115296 -115297 -1 if (rootNode) {15298 -1 if (indexInRange(indices, rootIndex, rootIndex)) {15299 -1 nodes[rootIndex] = rootNode15300 -1 }15301 -115302 -1 var vChildren = tree.children15303 1466015304 -1 if (vChildren) {-1 14661 if (!/^(https?|wss?):\/\//.test(uri)) { -1 14662 debug('protocol-less url %s', uri); -1 14663 if ('undefined' !== typeof loc) { -1 14664 uri = loc.protocol + '//' + uri; -1 14665 } else { -1 14666 uri = 'https://' + uri; -1 14667 } -1 14668 } 15305 1466915306 -1 var childNodes = rootNode.childNodes-1 14670 // parse -1 14671 debug('parse %s', uri); -1 14672 obj = parseuri(uri); -1 14673 } 15307 1467415308 -1 for (var i = 0; i < tree.children.length; i++) {15309 -1 rootIndex += 1-1 14675 // make sure we treat `localhost:80` and `localhost` equally -1 14676 if (!obj.port) { -1 14677 if (/^(http|ws)$/.test(obj.protocol)) { -1 14678 obj.port = '80'; -1 14679 } else if (/^(http|ws)s$/.test(obj.protocol)) { -1 14680 obj.port = '443'; -1 14681 } -1 14682 } 15310 1468315311 -1 var vChild = vChildren[i] || noChild15312 -1 var nextIndex = rootIndex + (vChild.count || 0)-1 14684 obj.path = obj.path || '/'; 15313 1468515314 -1 // skip recursion down the tree if there are no nodes down here15315 -1 if (indexInRange(indices, rootIndex, nextIndex)) {15316 -1 recurse(childNodes[i], vChild, indices, nodes, rootIndex)15317 -1 }-1 14686 var ipv6 = obj.host.indexOf(':') !== -1; -1 14687 var host = ipv6 ? '[' + obj.host + ']' : obj.host; 15318 1468815319 -1 rootIndex = nextIndex15320 -1 }15321 -1 }15322 -1 }-1 14689 // define unique id -1 14690 obj.id = obj.protocol + '://' + host + ':' + obj.port; -1 14691 // define href -1 14692 obj.href = obj.protocol + '://' + host + (loc && loc.port === obj.port ? '' : (':' + obj.port)); 15323 1469315324 -1 return nodes-1 14694 return obj; 15325 14695 } 15326 1469615327 -1 // Binary search for an index in the interval [left, right]15328 -1 function indexInRange(indices, left, right) {15329 -1 if (indices.length === 0) {15330 -1 return false15331 -1 }-1 14697 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 14698 },{"debug":103,"parseuri":95}],102:[function(require,module,exports){ -1 14699 arguments[4][22][0].apply(exports,arguments) -1 14700 },{"dup":22}],103:[function(require,module,exports){ -1 14701 arguments[4][23][0].apply(exports,arguments) -1 14702 },{"./debug":104,"_process":2,"dup":23}],104:[function(require,module,exports){ -1 14703 arguments[4][24][0].apply(exports,arguments) -1 14704 },{"dup":24,"ms":105}],105:[function(require,module,exports){ -1 14705 arguments[4][25][0].apply(exports,arguments) -1 14706 },{"dup":25}],106:[function(require,module,exports){ -1 14707 (function (global){ -1 14708 /*global Blob,File*/ 15332 1470915333 -1 var minIndex = 015334 -1 var maxIndex = indices.length - 115335 -1 var currentIndex15336 -1 var currentItem-1 14710 /** -1 14711 * Module requirements -1 14712 */ 15337 1471315338 -1 while (minIndex <= maxIndex) {15339 -1 currentIndex = ((maxIndex + minIndex) / 2) >> 015340 -1 currentItem = indices[currentIndex]-1 14714 var isArray = require('isarray'); -1 14715 var isBuf = require('./is-buffer'); 15341 1471615342 -1 if (minIndex === maxIndex) {15343 -1 return currentItem >= left && currentItem <= right15344 -1 } else if (currentItem < left) {15345 -1 minIndex = currentIndex + 115346 -1 } else if (currentItem > right) {15347 -1 maxIndex = currentIndex - 115348 -1 } else {15349 -1 return true15350 -1 }15351 -1 }-1 14717 /** -1 14718 * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder. -1 14719 * Anything with blobs or files should be fed through removeBlobs before coming -1 14720 * here. -1 14721 * -1 14722 * @param {Object} packet - socket.io event packet -1 14723 * @return {Object} with deconstructed packet and list of buffers -1 14724 * @api public -1 14725 */ 15352 1472615353 -1 return false;15354 -1 }-1 14727 exports.deconstructPacket = function(packet){ -1 14728 var buffers = []; -1 14729 var packetData = packet.data; 15355 1473015356 -1 function ascending(a, b) {15357 -1 return a > b ? 1 : -115358 -1 }-1 14731 function _deconstructPacket(data) { -1 14732 if (!data) return data; 15359 1473315360 -1 },{}],126:[function(require,module,exports){15361 -1 var applyProperties = require("./apply-properties")15362 -115363 -1 var isWidget = require("../vnode/is-widget.js")15364 -1 var VPatch = require("../vnode/vpatch.js")15365 -115366 -1 var updateWidget = require("./update-widget")15367 -115368 -1 module.exports = applyPatch15369 -115370 -1 function applyPatch(vpatch, domNode, renderOptions) {15371 -1 var type = vpatch.type15372 -1 var vNode = vpatch.vNode15373 -1 var patch = vpatch.patch15374 -115375 -1 switch (type) {15376 -1 case VPatch.REMOVE:15377 -1 return removeNode(domNode, vNode)15378 -1 case VPatch.INSERT:15379 -1 return insertNode(domNode, patch, renderOptions)15380 -1 case VPatch.VTEXT:15381 -1 return stringPatch(domNode, vNode, patch, renderOptions)15382 -1 case VPatch.WIDGET:15383 -1 return widgetPatch(domNode, vNode, patch, renderOptions)15384 -1 case VPatch.VNODE:15385 -1 return vNodePatch(domNode, vNode, patch, renderOptions)15386 -1 case VPatch.ORDER:15387 -1 reorderChildren(domNode, patch)15388 -1 return domNode15389 -1 case VPatch.PROPS:15390 -1 applyProperties(domNode, patch, vNode.properties)15391 -1 return domNode15392 -1 case VPatch.THUNK:15393 -1 return replaceRoot(domNode,15394 -1 renderOptions.patch(domNode, patch, renderOptions))15395 -1 default:15396 -1 return domNode-1 14734 if (isBuf(data)) { -1 14735 var placeholder = { _placeholder: true, num: buffers.length }; -1 14736 buffers.push(data); -1 14737 return placeholder; -1 14738 } else if (isArray(data)) { -1 14739 var newData = new Array(data.length); -1 14740 for (var i = 0; i < data.length; i++) { -1 14741 newData[i] = _deconstructPacket(data[i]); -1 14742 } -1 14743 return newData; -1 14744 } else if ('object' == typeof data && !(data instanceof Date)) { -1 14745 var newData = {}; -1 14746 for (var key in data) { -1 14747 newData[key] = _deconstructPacket(data[key]); -1 14748 } -1 14749 return newData; 15397 14750 }15398 -1 }-1 14751 return data; -1 14752 } 15399 1475315400 -1 function removeNode(domNode, vNode) {15401 -1 var parentNode = domNode.parentNode-1 14754 var pack = packet; -1 14755 pack.data = _deconstructPacket(packetData); -1 14756 pack.attachments = buffers.length; // number of binary 'attachments' -1 14757 return {packet: pack, buffers: buffers}; -1 14758 }; 15402 1475915403 -1 if (parentNode) {15404 -1 parentNode.removeChild(domNode)15405 -1 }-1 14760 /** -1 14761 * Reconstructs a binary packet from its placeholder packet and buffers -1 14762 * -1 14763 * @param {Object} packet - event packet with placeholders -1 14764 * @param {Array} buffers - binary buffers to put in placeholder positions -1 14765 * @return {Object} reconstructed packet -1 14766 * @api public -1 14767 */ 15406 1476815407 -1 destroyWidget(domNode, vNode);-1 14769 exports.reconstructPacket = function(packet, buffers) { -1 14770 var curPlaceHolder = 0; 15408 1477115409 -1 return null15410 -1 }-1 14772 function _reconstructPacket(data) { -1 14773 if (data && data._placeholder) { -1 14774 var buf = buffers[data.num]; // appropriate buffer (should be natural order anyway) -1 14775 return buf; -1 14776 } else if (isArray(data)) { -1 14777 for (var i = 0; i < data.length; i++) { -1 14778 data[i] = _reconstructPacket(data[i]); -1 14779 } -1 14780 return data; -1 14781 } else if (data && 'object' == typeof data) { -1 14782 for (var key in data) { -1 14783 data[key] = _reconstructPacket(data[key]); -1 14784 } -1 14785 return data; -1 14786 } -1 14787 return data; -1 14788 } 15411 1478915412 -1 function insertNode(parentNode, vNode, renderOptions) {15413 -1 var newNode = renderOptions.render(vNode, renderOptions)-1 14790 packet.data = _reconstructPacket(packet.data); -1 14791 packet.attachments = undefined; // no longer useful -1 14792 return packet; -1 14793 }; 15414 1479415415 -1 if (parentNode) {15416 -1 parentNode.appendChild(newNode)15417 -1 }-1 14795 /** -1 14796 * Asynchronously removes Blobs or Files from data via -1 14797 * FileReader's readAsArrayBuffer method. Used before encoding -1 14798 * data as msgpack. Calls callback with the blobless data. -1 14799 * -1 14800 * @param {Object} data -1 14801 * @param {Function} callback -1 14802 * @api private -1 14803 */ 15418 1480415419 -1 return parentNode15420 -1 }-1 14805 exports.removeBlobs = function(data, callback) { -1 14806 function _removeBlobs(obj, curKey, containingObject) { -1 14807 if (!obj) return obj; 15421 1480815422 -1 function stringPatch(domNode, leftVNode, vText, renderOptions) {15423 -1 var newNode-1 14809 // convert any blob -1 14810 if ((global.Blob && obj instanceof Blob) || -1 14811 (global.File && obj instanceof File)) { -1 14812 pendingBlobs++; 15424 1481315425 -1 if (domNode.nodeType === 3) {15426 -1 domNode.replaceData(0, domNode.length, vText.text)15427 -1 newNode = domNode15428 -1 } else {15429 -1 var parentNode = domNode.parentNode15430 -1 newNode = renderOptions.render(vText, renderOptions)-1 14814 // async filereader -1 14815 var fileReader = new FileReader(); -1 14816 fileReader.onload = function() { // this.result == arraybuffer -1 14817 if (containingObject) { -1 14818 containingObject[curKey] = this.result; -1 14819 } -1 14820 else { -1 14821 bloblessData = this.result; -1 14822 } 15431 1482315432 -1 if (parentNode && newNode !== domNode) {15433 -1 parentNode.replaceChild(newNode, domNode)-1 14824 // if nothing pending its callback time -1 14825 if(! --pendingBlobs) { -1 14826 callback(bloblessData); 15434 14827 } -1 14828 }; -1 14829 -1 14830 fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer -1 14831 } else if (isArray(obj)) { // handle array -1 14832 for (var i = 0; i < obj.length; i++) { -1 14833 _removeBlobs(obj[i], i, obj); -1 14834 } -1 14835 } else if (obj && 'object' == typeof obj && !isBuf(obj)) { // and object -1 14836 for (var key in obj) { -1 14837 _removeBlobs(obj[key], key, obj); -1 14838 } 15435 14839 } -1 14840 } 15436 1484115437 -1 return newNode15438 -1 }-1 14842 var pendingBlobs = 0; -1 14843 var bloblessData = data; -1 14844 _removeBlobs(bloblessData); -1 14845 if (!pendingBlobs) { -1 14846 callback(bloblessData); -1 14847 } -1 14848 }; 15439 1484915440 -1 function widgetPatch(domNode, leftVNode, widget, renderOptions) {15441 -1 var updating = updateWidget(leftVNode, widget)15442 -1 var newNode-1 14850 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 14851 },{"./is-buffer":108,"isarray":32}],107:[function(require,module,exports){ 15443 1485215444 -1 if (updating) {15445 -1 newNode = widget.update(leftVNode, domNode) || domNode15446 -1 } else {15447 -1 newNode = renderOptions.render(widget, renderOptions)15448 -1 }-1 14853 /** -1 14854 * Module dependencies. -1 14855 */ 15449 1485615450 -1 var parentNode = domNode.parentNode-1 14857 var debug = require('debug')('socket.io-parser'); -1 14858 var json = require('json3'); -1 14859 var Emitter = require('component-emitter'); -1 14860 var binary = require('./binary'); -1 14861 var isBuf = require('./is-buffer'); 15451 1486215452 -1 if (parentNode && newNode !== domNode) {15453 -1 parentNode.replaceChild(newNode, domNode)15454 -1 }-1 14863 /** -1 14864 * Protocol version. -1 14865 * -1 14866 * @api public -1 14867 */ 15455 1486815456 -1 if (!updating) {15457 -1 destroyWidget(domNode, leftVNode)15458 -1 }-1 14869 exports.protocol = 4; 15459 1487015460 -1 return newNode15461 -1 }-1 14871 /** -1 14872 * Packet types. -1 14873 * -1 14874 * @api public -1 14875 */ 15462 1487615463 -1 function vNodePatch(domNode, leftVNode, vNode, renderOptions) {15464 -1 var parentNode = domNode.parentNode15465 -1 var newNode = renderOptions.render(vNode, renderOptions)-1 14877 exports.types = [ -1 14878 'CONNECT', -1 14879 'DISCONNECT', -1 14880 'EVENT', -1 14881 'ACK', -1 14882 'ERROR', -1 14883 'BINARY_EVENT', -1 14884 'BINARY_ACK' -1 14885 ]; 15466 1488615467 -1 if (parentNode && newNode !== domNode) {15468 -1 parentNode.replaceChild(newNode, domNode)15469 -1 }-1 14887 /** -1 14888 * Packet type `connect`. -1 14889 * -1 14890 * @api public -1 14891 */ 15470 1489215471 -1 return newNode15472 -1 }-1 14893 exports.CONNECT = 0; 15473 1489415474 -1 function destroyWidget(domNode, w) {15475 -1 if (typeof w.destroy === "function" && isWidget(w)) {15476 -1 w.destroy(domNode)15477 -1 }15478 -1 }-1 14895 /** -1 14896 * Packet type `disconnect`. -1 14897 * -1 14898 * @api public -1 14899 */ 15479 1490015480 -1 function reorderChildren(domNode, moves) {15481 -1 var childNodes = domNode.childNodes15482 -1 var keyMap = {}15483 -1 var node15484 -1 var remove15485 -1 var insert15486 -115487 -1 for (var i = 0; i < moves.removes.length; i++) {15488 -1 remove = moves.removes[i]15489 -1 node = childNodes[remove.from]15490 -1 if (remove.key) {15491 -1 keyMap[remove.key] = node15492 -1 }15493 -1 domNode.removeChild(node)15494 -1 }-1 14901 exports.DISCONNECT = 1; 15495 1490215496 -1 var length = childNodes.length15497 -1 for (var j = 0; j < moves.inserts.length; j++) {15498 -1 insert = moves.inserts[j]15499 -1 node = keyMap[insert.key]15500 -1 // this is the weirdest bug i've ever seen in webkit15501 -1 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])15502 -1 }15503 -1 }-1 14903 /** -1 14904 * Packet type `event`. -1 14905 * -1 14906 * @api public -1 14907 */ 15504 1490815505 -1 function replaceRoot(oldRoot, newRoot) {15506 -1 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {15507 -1 oldRoot.parentNode.replaceChild(newRoot, oldRoot)15508 -1 }-1 14909 exports.EVENT = 2; 15509 1491015510 -1 return newRoot;15511 -1 }-1 14911 /** -1 14912 * Packet type `ack`. -1 14913 * -1 14914 * @api public -1 14915 */ 15512 1491615513 -1 },{"../vnode/is-widget.js":138,"../vnode/vpatch.js":141,"./apply-properties":123,"./update-widget":128}],127:[function(require,module,exports){15514 -1 var document = require("global/document")15515 -1 var isArray = require("x-is-array")-1 14917 exports.ACK = 3; 15516 1491815517 -1 var render = require("./create-element")15518 -1 var domIndex = require("./dom-index")15519 -1 var patchOp = require("./patch-op")15520 -1 module.exports = patch-1 14919 /** -1 14920 * Packet type `error`. -1 14921 * -1 14922 * @api public -1 14923 */ 15521 1492415522 -1 function patch(rootNode, patches, renderOptions) {15523 -1 renderOptions = renderOptions || {}15524 -1 renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch15525 -1 ? renderOptions.patch15526 -1 : patchRecursive15527 -1 renderOptions.render = renderOptions.render || render-1 14925 exports.ERROR = 4; 15528 1492615529 -1 return renderOptions.patch(rootNode, patches, renderOptions)15530 -1 }-1 14927 /** -1 14928 * Packet type 'binary event' -1 14929 * -1 14930 * @api public -1 14931 */ 15531 1493215532 -1 function patchRecursive(rootNode, patches, renderOptions) {15533 -1 var indices = patchIndices(patches)-1 14933 exports.BINARY_EVENT = 5; 15534 1493415535 -1 if (indices.length === 0) {15536 -1 return rootNode15537 -1 }-1 14935 /** -1 14936 * Packet type `binary ack`. For acks with binary arguments. -1 14937 * -1 14938 * @api public -1 14939 */ 15538 1494015539 -1 var index = domIndex(rootNode, patches.a, indices)15540 -1 var ownerDocument = rootNode.ownerDocument-1 14941 exports.BINARY_ACK = 6; 15541 1494215542 -1 if (!renderOptions.document && ownerDocument !== document) {15543 -1 renderOptions.document = ownerDocument15544 -1 }-1 14943 /** -1 14944 * Encoder constructor. -1 14945 * -1 14946 * @api public -1 14947 */ 15545 1494815546 -1 for (var i = 0; i < indices.length; i++) {15547 -1 var nodeIndex = indices[i]15548 -1 rootNode = applyPatch(rootNode,15549 -1 index[nodeIndex],15550 -1 patches[nodeIndex],15551 -1 renderOptions)15552 -1 }-1 14949 exports.Encoder = Encoder; 15553 1495015554 -1 return rootNode15555 -1 }-1 14951 /** -1 14952 * Decoder constructor. -1 14953 * -1 14954 * @api public -1 14955 */ 15556 1495615557 -1 function applyPatch(rootNode, domNode, patchList, renderOptions) {15558 -1 if (!domNode) {15559 -1 return rootNode15560 -1 }-1 14957 exports.Decoder = Decoder; 15561 1495815562 -1 var newNode-1 14959 /** -1 14960 * A socket.io Encoder instance -1 14961 * -1 14962 * @api public -1 14963 */ 15563 1496415564 -1 if (isArray(patchList)) {15565 -1 for (var i = 0; i < patchList.length; i++) {15566 -1 newNode = patchOp(patchList[i], domNode, renderOptions)-1 14965 function Encoder() {} 15567 1496615568 -1 if (domNode === rootNode) {15569 -1 rootNode = newNode15570 -1 }15571 -1 }15572 -1 } else {15573 -1 newNode = patchOp(patchList, domNode, renderOptions)-1 14967 /** -1 14968 * Encode a packet as a single string if non-binary, or as a -1 14969 * buffer sequence, depending on packet type. -1 14970 * -1 14971 * @param {Object} obj - packet object -1 14972 * @param {Function} callback - function to handle encodings (likely engine.write) -1 14973 * @return Calls callback with Array of encodings -1 14974 * @api public -1 14975 */ 15574 1497615575 -1 if (domNode === rootNode) {15576 -1 rootNode = newNode15577 -1 }15578 -1 }-1 14977 Encoder.prototype.encode = function(obj, callback){ -1 14978 debug('encoding packet %j', obj); 15579 1497915580 -1 return rootNode15581 -1 }-1 14980 if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) { -1 14981 encodeAsBinary(obj, callback); -1 14982 } -1 14983 else { -1 14984 var encoding = encodeAsString(obj); -1 14985 callback([encoding]); -1 14986 } -1 14987 }; 15582 1498815583 -1 function patchIndices(patches) {15584 -1 var indices = []-1 14989 /** -1 14990 * Encode packet as string. -1 14991 * -1 14992 * @param {Object} packet -1 14993 * @return {String} encoded -1 14994 * @api private -1 14995 */ 15585 1499615586 -1 for (var key in patches) {15587 -1 if (key !== "a") {15588 -1 indices.push(Number(key))15589 -1 }15590 -1 }-1 14997 function encodeAsString(obj) { -1 14998 var str = ''; -1 14999 var nsp = false; 15591 1500015592 -1 return indices15593 -1 }-1 15001 // first is type -1 15002 str += obj.type; 15594 1500315595 -1 },{"./create-element":124,"./dom-index":125,"./patch-op":126,"global/document":29,"x-is-array":145}],128:[function(require,module,exports){15596 -1 var isWidget = require("../vnode/is-widget.js")-1 15004 // attachments if we have them -1 15005 if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) { -1 15006 str += obj.attachments; -1 15007 str += '-'; -1 15008 } 15597 1500915598 -1 module.exports = updateWidget-1 15010 // if we have a namespace other than `/` -1 15011 // we append it followed by a comma `,` -1 15012 if (obj.nsp && '/' != obj.nsp) { -1 15013 nsp = true; -1 15014 str += obj.nsp; -1 15015 } 15599 1501615600 -1 function updateWidget(a, b) {15601 -1 if (isWidget(a) && isWidget(b)) {15602 -1 if ("name" in a && "name" in b) {15603 -1 return a.id === b.id15604 -1 } else {15605 -1 return a.init === b.init15606 -1 }-1 15017 // immediately followed by the id -1 15018 if (null != obj.id) { -1 15019 if (nsp) { -1 15020 str += ','; -1 15021 nsp = false; 15607 15022 } -1 15023 str += obj.id; -1 15024 } -1 15025 -1 15026 // json data -1 15027 if (null != obj.data) { -1 15028 if (nsp) str += ','; -1 15029 str += json.stringify(obj.data); -1 15030 } 15608 1503115609 -1 return false-1 15032 debug('encoded %j as %s', obj, str); -1 15033 return str; 15610 15034 } 15611 1503515612 -1 },{"../vnode/is-widget.js":138}],129:[function(require,module,exports){15613 -1 'use strict';-1 15036 /** -1 15037 * Encode packet as 'buffer sequence' by removing blobs, and -1 15038 * deconstructing packet into object with placeholders and -1 15039 * a list of buffers. -1 15040 * -1 15041 * @param {Object} packet -1 15042 * @return {Buffer} encoded -1 15043 * @api private -1 15044 */ 15614 1504515615 -1 var EvStore = require('ev-store');-1 15046 function encodeAsBinary(obj, callback) { 15616 1504715617 -1 module.exports = EvHook;-1 15048 function writeEncoding(bloblessData) { -1 15049 var deconstruction = binary.deconstructPacket(bloblessData); -1 15050 var pack = encodeAsString(deconstruction.packet); -1 15051 var buffers = deconstruction.buffers; 15618 1505215619 -1 function EvHook(value) {15620 -1 if (!(this instanceof EvHook)) {15621 -1 return new EvHook(value);15622 -1 }-1 15053 buffers.unshift(pack); // add packet info to beginning of data list -1 15054 callback(buffers); // write all the buffers -1 15055 } 15623 1505615624 -1 this.value = value;-1 15057 binary.removeBlobs(obj, writeEncoding); 15625 15058 } 15626 1505915627 -1 EvHook.prototype.hook = function (node, propertyName) {15628 -1 var es = EvStore(node);15629 -1 var propName = propertyName.substr(3);-1 15060 /** -1 15061 * A socket.io Decoder instance -1 15062 * -1 15063 * @return {Object} decoder -1 15064 * @api public -1 15065 */ 15630 1506615631 -1 es[propName] = this.value;15632 -1 };-1 15067 function Decoder() { -1 15068 this.reconstructor = null; -1 15069 } 15633 1507015634 -1 EvHook.prototype.unhook = function(node, propertyName) {15635 -1 var es = EvStore(node);15636 -1 var propName = propertyName.substr(3);-1 15071 /** -1 15072 * Mix in `Emitter` with Decoder. -1 15073 */ 15637 1507415638 -1 es[propName] = undefined;15639 -1 };-1 15075 Emitter(Decoder.prototype); 15640 1507615641 -1 },{"ev-store":28}],130:[function(require,module,exports){15642 -1 'use strict';-1 15077 /** -1 15078 * Decodes an ecoded packet string into packet JSON. -1 15079 * -1 15080 * @param {String} obj - encoded packet -1 15081 * @return {Object} packet -1 15082 * @api public -1 15083 */ 15643 1508415644 -1 module.exports = SoftSetHook;-1 15085 Decoder.prototype.add = function(obj) { -1 15086 var packet; -1 15087 if ('string' == typeof obj) { -1 15088 packet = decodeString(obj); -1 15089 if (exports.BINARY_EVENT == packet.type || exports.BINARY_ACK == packet.type) { // binary packet's json -1 15090 this.reconstructor = new BinaryReconstructor(packet); 15645 1509115646 -1 function SoftSetHook(value) {15647 -1 if (!(this instanceof SoftSetHook)) {15648 -1 return new SoftSetHook(value);-1 15092 // no attachments, labeled binary but no binary data to follow -1 15093 if (this.reconstructor.reconPack.attachments === 0) { -1 15094 this.emit('decoded', packet); -1 15095 } -1 15096 } else { // non-binary full packet -1 15097 this.emit('decoded', packet); 15649 15098 }15650 -115651 -1 this.value = value;15652 -1 }15653 -115654 -1 SoftSetHook.prototype.hook = function (node, propertyName) {15655 -1 if (node[propertyName] !== this.value) {15656 -1 node[propertyName] = this.value;-1 15099 } -1 15100 else if (isBuf(obj) || obj.base64) { // raw binary data -1 15101 if (!this.reconstructor) { -1 15102 throw new Error('got binary data when not reconstructing a packet'); -1 15103 } else { -1 15104 packet = this.reconstructor.takeBinaryData(obj); -1 15105 if (packet) { // received final buffer -1 15106 this.reconstructor = null; -1 15107 this.emit('decoded', packet); -1 15108 } 15657 15109 } -1 15110 } -1 15111 else { -1 15112 throw new Error('Unknown type: ' + obj); -1 15113 } 15658 15114 }; 15659 1511515660 -1 },{}],131:[function(require,module,exports){15661 -1 'use strict';15662 -115663 -1 var isArray = require('x-is-array');15664 -115665 -1 var VNode = require('../vnode/vnode.js');15666 -1 var VText = require('../vnode/vtext.js');15667 -1 var isVNode = require('../vnode/is-vnode');15668 -1 var isVText = require('../vnode/is-vtext');15669 -1 var isWidget = require('../vnode/is-widget');15670 -1 var isHook = require('../vnode/is-vhook');15671 -1 var isVThunk = require('../vnode/is-thunk');15672 -115673 -1 var parseTag = require('./parse-tag.js');15674 -1 var softSetHook = require('./hooks/soft-set-hook.js');15675 -1 var evHook = require('./hooks/ev-hook.js');-1 15116 /** -1 15117 * Decode a packet String (JSON data) -1 15118 * -1 15119 * @param {String} str -1 15120 * @return {Object} packet -1 15121 * @api private -1 15122 */ 15676 1512315677 -1 module.exports = h;-1 15124 function decodeString(str) { -1 15125 var p = {}; -1 15126 var i = 0; 15678 1512715679 -1 function h(tagName, properties, children) {15680 -1 var childNodes = [];15681 -1 var tag, props, key, namespace;-1 15128 // look up type -1 15129 p.type = Number(str.charAt(0)); -1 15130 if (null == exports.types[p.type]) return error(); 15682 1513115683 -1 if (!children && isChildren(properties)) {15684 -1 children = properties;15685 -1 props = {};-1 15132 // look up attachments if type binary -1 15133 if (exports.BINARY_EVENT == p.type || exports.BINARY_ACK == p.type) { -1 15134 var buf = ''; -1 15135 while (str.charAt(++i) != '-') { -1 15136 buf += str.charAt(i); -1 15137 if (i == str.length) break; 15686 15138 }15687 -115688 -1 props = props || properties || {};15689 -1 tag = parseTag(tagName, props);15690 -115691 -1 // support keys15692 -1 if (props.hasOwnProperty('key')) {15693 -1 key = props.key;15694 -1 props.key = undefined;-1 15139 if (buf != Number(buf) || str.charAt(i) != '-') { -1 15140 throw new Error('Illegal attachments'); 15695 15141 } -1 15142 p.attachments = Number(buf); -1 15143 } 15696 1514415697 -1 // support namespace15698 -1 if (props.hasOwnProperty('namespace')) {15699 -1 namespace = props.namespace;15700 -1 props.namespace = undefined;-1 15145 // look up namespace (if any) -1 15146 if ('/' == str.charAt(i + 1)) { -1 15147 p.nsp = ''; -1 15148 while (++i) { -1 15149 var c = str.charAt(i); -1 15150 if (',' == c) break; -1 15151 p.nsp += c; -1 15152 if (i == str.length) break; 15701 15153 } -1 15154 } else { -1 15155 p.nsp = '/'; -1 15156 } 15702 1515715703 -1 // fix cursor bug15704 -1 if (tag === 'INPUT' &&15705 -1 !namespace &&15706 -1 props.hasOwnProperty('value') &&15707 -1 props.value !== undefined &&15708 -1 !isHook(props.value)15709 -1 ) {15710 -1 props.value = softSetHook(props.value);-1 15158 // look up id -1 15159 var next = str.charAt(i + 1); -1 15160 if ('' !== next && Number(next) == next) { -1 15161 p.id = ''; -1 15162 while (++i) { -1 15163 var c = str.charAt(i); -1 15164 if (null == c || Number(c) != c) { -1 15165 --i; -1 15166 break; -1 15167 } -1 15168 p.id += str.charAt(i); -1 15169 if (i == str.length) break; 15711 15170 } -1 15171 p.id = Number(p.id); -1 15172 } 15712 1517315713 -1 transformProperties(props);-1 15174 // look up json data -1 15175 if (str.charAt(++i)) { -1 15176 p = tryParse(p, str.substr(i)); -1 15177 } 15714 1517815715 -1 if (children !== undefined && children !== null) {15716 -1 addChild(children, childNodes, tag, props);15717 -1 }-1 15179 debug('decoded %s as %j', str, p); -1 15180 return p; -1 15181 } 15718 15182 -1 15183 function tryParse(p, str) { -1 15184 try { -1 15185 p.data = json.parse(str); -1 15186 } catch(e){ -1 15187 return error(); -1 15188 } -1 15189 return p; -1 15190 }; 15719 1519115720 -1 return new VNode(tag, props, childNodes, key, namespace);15721 -1 }-1 15192 /** -1 15193 * Deallocates a parser's resources -1 15194 * -1 15195 * @api public -1 15196 */ 15722 1519715723 -1 function addChild(c, childNodes, tag, props) {15724 -1 if (typeof c === 'string') {15725 -1 childNodes.push(new VText(c));15726 -1 } else if (typeof c === 'number') {15727 -1 childNodes.push(new VText(String(c)));15728 -1 } else if (isChild(c)) {15729 -1 childNodes.push(c);15730 -1 } else if (isArray(c)) {15731 -1 for (var i = 0; i < c.length; i++) {15732 -1 addChild(c[i], childNodes, tag, props);15733 -1 }15734 -1 } else if (c === null || c === undefined) {15735 -1 return;15736 -1 } else {15737 -1 throw UnexpectedVirtualElement({15738 -1 foreignObject: c,15739 -1 parentVnode: {15740 -1 tagName: tag,15741 -1 properties: props15742 -1 }15743 -1 });15744 -1 }-1 15198 Decoder.prototype.destroy = function() { -1 15199 if (this.reconstructor) { -1 15200 this.reconstructor.finishedReconstruction(); -1 15201 } -1 15202 }; -1 15203 -1 15204 /** -1 15205 * A manager of a binary event's 'buffer sequence'. Should -1 15206 * be constructed whenever a packet of type BINARY_EVENT is -1 15207 * decoded. -1 15208 * -1 15209 * @param {Object} packet -1 15210 * @return {BinaryReconstructor} initialized reconstructor -1 15211 * @api private -1 15212 */ -1 15213 -1 15214 function BinaryReconstructor(packet) { -1 15215 this.reconPack = packet; -1 15216 this.buffers = []; 15745 15217 } 15746 1521815747 -1 function transformProperties(props) {15748 -1 for (var propName in props) {15749 -1 if (props.hasOwnProperty(propName)) {15750 -1 var value = props[propName];-1 15219 /** -1 15220 * Method to be called when binary data received from connection -1 15221 * after a BINARY_EVENT packet. -1 15222 * -1 15223 * @param {Buffer | ArrayBuffer} binData - the raw binary data received -1 15224 * @return {null | Object} returns null if more binary data is expected or -1 15225 * a reconstructed packet object if all buffers have been received. -1 15226 * @api private -1 15227 */ -1 15228 -1 15229 BinaryReconstructor.prototype.takeBinaryData = function(binData) { -1 15230 this.buffers.push(binData); -1 15231 if (this.buffers.length == this.reconPack.attachments) { // done with buffer list -1 15232 var packet = binary.reconstructPacket(this.reconPack, this.buffers); -1 15233 this.finishedReconstruction(); -1 15234 return packet; -1 15235 } -1 15236 return null; -1 15237 }; -1 15238 -1 15239 /** -1 15240 * Cleans up binary packet reconstruction variables. -1 15241 * -1 15242 * @api private -1 15243 */ 15751 1524415752 -1 if (isHook(value)) {15753 -1 continue;15754 -1 }-1 15245 BinaryReconstructor.prototype.finishedReconstruction = function() { -1 15246 this.reconPack = null; -1 15247 this.buffers = []; -1 15248 }; 15755 1524915756 -1 if (propName.substr(0, 3) === 'ev-') {15757 -1 // add ev-foo support15758 -1 props[propName] = evHook(value);15759 -1 }15760 -1 }15761 -1 }-1 15250 function error(data){ -1 15251 return { -1 15252 type: exports.ERROR, -1 15253 data: 'parser error' -1 15254 }; 15762 15255 } 15763 1525615764 -1 function isChild(x) {15765 -1 return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);15766 -1 }-1 15257 },{"./binary":106,"./is-buffer":108,"component-emitter":10,"debug":109,"json3":33}],108:[function(require,module,exports){ -1 15258 (function (global){ 15767 1525915768 -1 function isChildren(x) {15769 -1 return typeof x === 'string' || isArray(x) || isChild(x);15770 -1 }-1 15260 module.exports = isBuf; 15771 1526115772 -1 function UnexpectedVirtualElement(data) {15773 -1 var err = new Error();15774 -115775 -1 err.type = 'virtual-hyperscript.unexpected.virtual-element';15776 -1 err.message = 'Unexpected virtual child passed to h().\n' +15777 -1 'Expected a VNode / Vthunk / VWidget / string but:\n' +15778 -1 'got:\n' +15779 -1 errorString(data.foreignObject) +15780 -1 '.\n' +15781 -1 'The parent vnode is:\n' +15782 -1 errorString(data.parentVnode)15783 -1 '\n' +15784 -1 'Suggested fix: change your `h(..., [ ... ])` callsite.';15785 -1 err.foreignObject = data.foreignObject;15786 -1 err.parentVnode = data.parentVnode;-1 15262 /** -1 15263 * Returns true if obj is a buffer or an arraybuffer. -1 15264 * -1 15265 * @api private -1 15266 */ 15787 1526715788 -1 return err;-1 15268 function isBuf(obj) { -1 15269 return (global.Buffer && global.Buffer.isBuffer(obj)) || -1 15270 (global.ArrayBuffer && obj instanceof ArrayBuffer); 15789 15271 } 15790 1527215791 -1 function errorString(obj) {15792 -1 try {15793 -1 return JSON.stringify(obj, null, ' ');15794 -1 } catch (e) {15795 -1 return String(obj);15796 -1 }15797 -1 }-1 15273 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 15274 },{}],109:[function(require,module,exports){ 15798 1527515799 -1 },{"../vnode/is-thunk":134,"../vnode/is-vhook":135,"../vnode/is-vnode":136,"../vnode/is-vtext":137,"../vnode/is-widget":138,"../vnode/vnode.js":140,"../vnode/vtext.js":142,"./hooks/ev-hook.js":129,"./hooks/soft-set-hook.js":130,"./parse-tag.js":132,"x-is-array":145}],132:[function(require,module,exports){15800 -1 'use strict';-1 15276 /** -1 15277 * This is the web browser implementation of `debug()`. -1 15278 * -1 15279 * Expose `debug()` as the module. -1 15280 */ 15801 1528115802 -1 var split = require('browser-split');-1 15282 exports = module.exports = require('./debug'); -1 15283 exports.log = log; -1 15284 exports.formatArgs = formatArgs; -1 15285 exports.save = save; -1 15286 exports.load = load; -1 15287 exports.useColors = useColors; -1 15288 exports.storage = 'undefined' != typeof chrome -1 15289 && 'undefined' != typeof chrome.storage -1 15290 ? chrome.storage.local -1 15291 : localstorage(); 15803 1529215804 -1 var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;15805 -1 var notClassId = /^\.|#/;-1 15293 /** -1 15294 * Colors. -1 15295 */ 15806 1529615807 -1 module.exports = parseTag;-1 15297 exports.colors = [ -1 15298 'lightseagreen', -1 15299 'forestgreen', -1 15300 'goldenrod', -1 15301 'dodgerblue', -1 15302 'darkorchid', -1 15303 'crimson' -1 15304 ]; 15808 1530515809 -1 function parseTag(tag, props) {15810 -1 if (!tag) {15811 -1 return 'DIV';15812 -1 }-1 15306 /** -1 15307 * Currently only WebKit-based Web Inspectors, Firefox >= v31, -1 15308 * and the Firebug extension (any Firefox version) are known -1 15309 * to support "%c" CSS customizations. -1 15310 * -1 15311 * TODO: add a `localStorage` variable to explicitly enable/disable colors -1 15312 */ 15813 1531315814 -1 var noId = !(props.hasOwnProperty('id'));-1 15314 function useColors() { -1 15315 // is webkit? http://stackoverflow.com/a/16459606/376773 -1 15316 return ('WebkitAppearance' in document.documentElement.style) || -1 15317 // is firebug? http://stackoverflow.com/a/398120/376773 -1 15318 (window.console && (console.firebug || (console.exception && console.table))) || -1 15319 // is firefox >= v31? -1 15320 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages -1 15321 (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -1 15322 } 15815 1532315816 -1 var tagParts = split(tag, classIdSplit);15817 -1 var tagName = null;-1 15324 /** -1 15325 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. -1 15326 */ 15818 1532715819 -1 if (notClassId.test(tagParts[1])) {15820 -1 tagName = 'DIV';15821 -1 }-1 15328 exports.formatters.j = function(v) { -1 15329 return JSON.stringify(v); -1 15330 }; 15822 1533115823 -1 var classes, part, type, i;15824 1533215825 -1 for (i = 0; i < tagParts.length; i++) {15826 -1 part = tagParts[i];-1 15333 /** -1 15334 * Colorize log arguments if enabled. -1 15335 * -1 15336 * @api public -1 15337 */ 15827 1533815828 -1 if (!part) {15829 -1 continue;15830 -1 }-1 15339 function formatArgs() { -1 15340 var args = arguments; -1 15341 var useColors = this.useColors; 15831 1534215832 -1 type = part.charAt(0);-1 15343 args[0] = (useColors ? '%c' : '') -1 15344 + this.namespace -1 15345 + (useColors ? ' %c' : ' ') -1 15346 + args[0] -1 15347 + (useColors ? '%c ' : ' ') -1 15348 + '+' + exports.humanize(this.diff); 15833 1534915834 -1 if (!tagName) {15835 -1 tagName = part;15836 -1 } else if (type === '.') {15837 -1 classes = classes || [];15838 -1 classes.push(part.substring(1, part.length));15839 -1 } else if (type === '#' && noId) {15840 -1 props.id = part.substring(1, part.length);15841 -1 }15842 -1 }-1 15350 if (!useColors) return args; 15843 1535115844 -1 if (classes) {15845 -1 if (props.className) {15846 -1 classes.push(props.className);15847 -1 }-1 15352 var c = 'color: ' + this.color; -1 15353 args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); 15848 1535415849 -1 props.className = classes.join(' ');-1 15355 // the final "%c" is somewhat tricky, because there could be other -1 15356 // arguments passed either before or after the %c, so we need to -1 15357 // figure out the correct index to insert the CSS into -1 15358 var index = 0; -1 15359 var lastC = 0; -1 15360 args[0].replace(/%[a-z%]/g, function(match) { -1 15361 if ('%%' === match) return; -1 15362 index++; -1 15363 if ('%c' === match) { -1 15364 // we only are interested in the *last* %c -1 15365 // (the user may have provided their own) -1 15366 lastC = index; 15850 15367 } -1 15368 }); 15851 1536915852 -1 return props.namespace ? tagName : tagName.toUpperCase();-1 15370 args.splice(lastC, 0, c); -1 15371 return args; 15853 15372 } 15854 1537315855 -1 },{"browser-split":8}],133:[function(require,module,exports){15856 -1 var isVNode = require("./is-vnode")15857 -1 var isVText = require("./is-vtext")15858 -1 var isWidget = require("./is-widget")15859 -1 var isThunk = require("./is-thunk")-1 15374 /** -1 15375 * Invokes `console.log()` when available. -1 15376 * No-op when `console.log` is not a "function". -1 15377 * -1 15378 * @api public -1 15379 */ 15860 1538015861 -1 module.exports = handleThunk-1 15381 function log() { -1 15382 // this hackery is required for IE8/9, where -1 15383 // the `console.log` function doesn't have 'apply' -1 15384 return 'object' === typeof console -1 15385 && console.log -1 15386 && Function.prototype.apply.call(console.log, console, arguments); -1 15387 } 15862 1538815863 -1 function handleThunk(a, b) {15864 -1 var renderedA = a15865 -1 var renderedB = b-1 15389 /** -1 15390 * Save `namespaces`. -1 15391 * -1 15392 * @param {String} namespaces -1 15393 * @api private -1 15394 */ 15866 1539515867 -1 if (isThunk(b)) {15868 -1 renderedB = renderThunk(b, a)-1 15396 function save(namespaces) { -1 15397 try { -1 15398 if (null == namespaces) { -1 15399 exports.storage.removeItem('debug'); -1 15400 } else { -1 15401 exports.storage.debug = namespaces; 15869 15402 } -1 15403 } catch(e) {} -1 15404 } 15870 1540515871 -1 if (isThunk(a)) {15872 -1 renderedA = renderThunk(a, null)15873 -1 }-1 15406 /** -1 15407 * Load `namespaces`. -1 15408 * -1 15409 * @return {String} returns the previously persisted debug modes -1 15410 * @api private -1 15411 */ 15874 1541215875 -1 return {15876 -1 a: renderedA,15877 -1 b: renderedB15878 -1 }-1 15413 function load() { -1 15414 var r; -1 15415 try { -1 15416 r = exports.storage.debug; -1 15417 } catch(e) {} -1 15418 return r; 15879 15419 } 15880 1542015881 -1 function renderThunk(thunk, previous) {15882 -1 var renderedThunk = thunk.vnode-1 15421 /** -1 15422 * Enable namespaces listed in `localStorage.debug` initially. -1 15423 */ 15883 1542415884 -1 if (!renderedThunk) {15885 -1 renderedThunk = thunk.vnode = thunk.render(previous)15886 -1 }-1 15425 exports.enable(load()); 15887 1542615888 -1 if (!(isVNode(renderedThunk) ||15889 -1 isVText(renderedThunk) ||15890 -1 isWidget(renderedThunk))) {15891 -1 throw new Error("thunk did not return a valid node");15892 -1 }-1 15427 /** -1 15428 * Localstorage attempts to return the localstorage. -1 15429 * -1 15430 * This is necessary because safari throws -1 15431 * when a user disables cookies/localstorage -1 15432 * and you attempt to access it. -1 15433 * -1 15434 * @return {LocalStorage} -1 15435 * @api private -1 15436 */ 15893 1543715894 -1 return renderedThunk-1 15438 function localstorage(){ -1 15439 try { -1 15440 return window.localStorage; -1 15441 } catch (e) {} 15895 15442 } 15896 1544315897 -1 },{"./is-thunk":134,"./is-vnode":136,"./is-vtext":137,"./is-widget":138}],134:[function(require,module,exports){15898 -1 module.exports = isThunk15899 -115900 -1 function isThunk(t) {15901 -1 return t && t.type === "Thunk"15902 -1 }-1 15444 },{"./debug":110}],110:[function(require,module,exports){ 15903 1544515904 -1 },{}],135:[function(require,module,exports){15905 -1 module.exports = isHook-1 15446 /** -1 15447 * This is the common logic for both the Node.js and web browser -1 15448 * implementations of `debug()`. -1 15449 * -1 15450 * Expose `debug()` as the module. -1 15451 */ 15906 1545215907 -1 function isHook(hook) {15908 -1 return hook &&15909 -1 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||15910 -1 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))15911 -1 }-1 15453 exports = module.exports = debug; -1 15454 exports.coerce = coerce; -1 15455 exports.disable = disable; -1 15456 exports.enable = enable; -1 15457 exports.enabled = enabled; -1 15458 exports.humanize = require('ms'); 15912 1545915913 -1 },{}],136:[function(require,module,exports){15914 -1 var version = require("./version")-1 15460 /** -1 15461 * The currently active debug mode names, and names to skip. -1 15462 */ 15915 1546315916 -1 module.exports = isVirtualNode-1 15464 exports.names = []; -1 15465 exports.skips = []; 15917 1546615918 -1 function isVirtualNode(x) {15919 -1 return x && x.type === "VirtualNode" && x.version === version15920 -1 }-1 15467 /** -1 15468 * Map of special "%n" handling functions, for the debug "format" argument. -1 15469 * -1 15470 * Valid key names are a single, lowercased letter, i.e. "n". -1 15471 */ -1 15472 -1 15473 exports.formatters = {}; -1 15474 -1 15475 /** -1 15476 * Previously assigned color. -1 15477 */ 15921 1547815922 -1 },{"./version":139}],137:[function(require,module,exports){15923 -1 var version = require("./version")-1 15479 var prevColor = 0; 15924 1548015925 -1 module.exports = isVirtualText-1 15481 /** -1 15482 * Previous log timestamp. -1 15483 */ 15926 1548415927 -1 function isVirtualText(x) {15928 -1 return x && x.type === "VirtualText" && x.version === version15929 -1 }-1 15485 var prevTime; 15930 1548615931 -1 },{"./version":139}],138:[function(require,module,exports){15932 -1 module.exports = isWidget-1 15487 /** -1 15488 * Select a color. -1 15489 * -1 15490 * @return {Number} -1 15491 * @api private -1 15492 */ 15933 1549315934 -1 function isWidget(w) {15935 -1 return w && w.type === "Widget"-1 15494 function selectColor() { -1 15495 return exports.colors[prevColor++ % exports.colors.length]; 15936 15496 } 15937 1549715938 -1 },{}],139:[function(require,module,exports){15939 -1 module.exports = "2"15940 -115941 -1 },{}],140:[function(require,module,exports){15942 -1 var version = require("./version")15943 -1 var isVNode = require("./is-vnode")15944 -1 var isWidget = require("./is-widget")15945 -1 var isThunk = require("./is-thunk")15946 -1 var isVHook = require("./is-vhook")15947 -115948 -1 module.exports = VirtualNode15949 -115950 -1 var noProperties = {}15951 -1 var noChildren = []15952 -115953 -1 function VirtualNode(tagName, properties, children, key, namespace) {15954 -1 this.tagName = tagName15955 -1 this.properties = properties || noProperties15956 -1 this.children = children || noChildren15957 -1 this.key = key != null ? String(key) : undefined15958 -1 this.namespace = (typeof namespace === "string") ? namespace : null15959 -115960 -1 var count = (children && children.length) || 015961 -1 var descendants = 015962 -1 var hasWidgets = false15963 -1 var hasThunks = false15964 -1 var descendantHooks = false15965 -1 var hooks15966 -115967 -1 for (var propName in properties) {15968 -1 if (properties.hasOwnProperty(propName)) {15969 -1 var property = properties[propName]15970 -1 if (isVHook(property) && property.unhook) {15971 -1 if (!hooks) {15972 -1 hooks = {}15973 -1 }-1 15498 /** -1 15499 * Create a debugger with the given `namespace`. -1 15500 * -1 15501 * @param {String} namespace -1 15502 * @return {Function} -1 15503 * @api public -1 15504 */ 15974 1550515975 -1 hooks[propName] = property15976 -1 }15977 -1 }15978 -1 }-1 15506 function debug(namespace) { 15979 1550715980 -1 for (var i = 0; i < count; i++) {15981 -1 var child = children[i]15982 -1 if (isVNode(child)) {15983 -1 descendants += child.count || 0-1 15508 // define the `disabled` version -1 15509 function disabled() { -1 15510 } -1 15511 disabled.enabled = false; 15984 1551215985 -1 if (!hasWidgets && child.hasWidgets) {15986 -1 hasWidgets = true15987 -1 }-1 15513 // define the `enabled` version -1 15514 function enabled() { 15988 1551515989 -1 if (!hasThunks && child.hasThunks) {15990 -1 hasThunks = true15991 -1 }-1 15516 var self = enabled; 15992 1551715993 -1 if (!descendantHooks && (child.hooks || child.descendantHooks)) {15994 -1 descendantHooks = true15995 -1 }15996 -1 } else if (!hasWidgets && isWidget(child)) {15997 -1 if (typeof child.destroy === "function") {15998 -1 hasWidgets = true15999 -1 }16000 -1 } else if (!hasThunks && isThunk(child)) {16001 -1 hasThunks = true;16002 -1 }-1 15518 // set `diff` timestamp -1 15519 var curr = +new Date(); -1 15520 var ms = curr - (prevTime || curr); -1 15521 self.diff = ms; -1 15522 self.prev = prevTime; -1 15523 self.curr = curr; -1 15524 prevTime = curr; -1 15525 -1 15526 // add the `color` if not set -1 15527 if (null == self.useColors) self.useColors = exports.useColors(); -1 15528 if (null == self.color && self.useColors) self.color = selectColor(); -1 15529 -1 15530 var args = Array.prototype.slice.call(arguments); -1 15531 -1 15532 args[0] = exports.coerce(args[0]); -1 15533 -1 15534 if ('string' !== typeof args[0]) { -1 15535 // anything else let's inspect with %o -1 15536 args = ['%o'].concat(args); 16003 15537 } 16004 1553816005 -1 this.count = count + descendants16006 -1 this.hasWidgets = hasWidgets16007 -1 this.hasThunks = hasThunks16008 -1 this.hooks = hooks16009 -1 this.descendantHooks = descendantHooks16010 -1 }-1 15539 // apply any `formatters` transformations -1 15540 var index = 0; -1 15541 args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { -1 15542 // if we encounter an escaped % then don't increase the array index -1 15543 if (match === '%%') return match; -1 15544 index++; -1 15545 var formatter = exports.formatters[format]; -1 15546 if ('function' === typeof formatter) { -1 15547 var val = args[index]; -1 15548 match = formatter.call(self, val); 16011 1554916012 -1 VirtualNode.prototype.version = version16013 -1 VirtualNode.prototype.type = "VirtualNode"-1 15550 // now we need to remove `args[index]` since it's inlined in the `format` -1 15551 args.splice(index, 1); -1 15552 index--; -1 15553 } -1 15554 return match; -1 15555 }); 16014 1555616015 -1 },{"./is-thunk":134,"./is-vhook":135,"./is-vnode":136,"./is-widget":138,"./version":139}],141:[function(require,module,exports){16016 -1 var version = require("./version")-1 15557 if ('function' === typeof exports.formatArgs) { -1 15558 args = exports.formatArgs.apply(self, args); -1 15559 } -1 15560 var logFn = enabled.log || exports.log || console.log.bind(console); -1 15561 logFn.apply(self, args); -1 15562 } -1 15563 enabled.enabled = true; 16017 1556416018 -1 VirtualPatch.NONE = 016019 -1 VirtualPatch.VTEXT = 116020 -1 VirtualPatch.VNODE = 216021 -1 VirtualPatch.WIDGET = 316022 -1 VirtualPatch.PROPS = 416023 -1 VirtualPatch.ORDER = 516024 -1 VirtualPatch.INSERT = 616025 -1 VirtualPatch.REMOVE = 716026 -1 VirtualPatch.THUNK = 8-1 15565 var fn = exports.enabled(namespace) ? enabled : disabled; 16027 1556616028 -1 module.exports = VirtualPatch-1 15567 fn.namespace = namespace; 16029 1556816030 -1 function VirtualPatch(type, vNode, patch) {16031 -1 this.type = Number(type)16032 -1 this.vNode = vNode16033 -1 this.patch = patch-1 15569 return fn; 16034 15570 } 16035 1557116036 -1 VirtualPatch.prototype.version = version16037 -1 VirtualPatch.prototype.type = "VirtualPatch"-1 15572 /** -1 15573 * Enables a debug mode by namespaces. This can include modes -1 15574 * separated by a colon and wildcards. -1 15575 * -1 15576 * @param {String} namespaces -1 15577 * @api public -1 15578 */ 16038 1557916039 -1 },{"./version":139}],142:[function(require,module,exports){16040 -1 var version = require("./version")-1 15580 function enable(namespaces) { -1 15581 exports.save(namespaces); 16041 1558216042 -1 module.exports = VirtualText-1 15583 var split = (namespaces || '').split(/[\s,]+/); -1 15584 var len = split.length; 16043 1558516044 -1 function VirtualText(text) {16045 -1 this.text = String(text)-1 15586 for (var i = 0; i < len; i++) { -1 15587 if (!split[i]) continue; // ignore empty strings -1 15588 namespaces = split[i].replace(/\*/g, '.*?'); -1 15589 if (namespaces[0] === '-') { -1 15590 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); -1 15591 } else { -1 15592 exports.names.push(new RegExp('^' + namespaces + '$')); -1 15593 } -1 15594 } 16046 15595 } 16047 1559616048 -1 VirtualText.prototype.version = version16049 -1 VirtualText.prototype.type = "VirtualText"16050 -116051 -1 },{"./version":139}],143:[function(require,module,exports){16052 -1 var isObject = require("is-object")16053 -1 var isHook = require("../vnode/is-vhook")16054 -116055 -1 module.exports = diffProps-1 15597 /** -1 15598 * Disable debug output. -1 15599 * -1 15600 * @api public -1 15601 */ 16056 1560216057 -1 function diffProps(a, b) {16058 -1 var diff-1 15603 function disable() { -1 15604 exports.enable(''); -1 15605 } 16059 1560616060 -1 for (var aKey in a) {16061 -1 if (!(aKey in b)) {16062 -1 diff = diff || {}16063 -1 diff[aKey] = undefined16064 -1 }-1 15607 /** -1 15608 * Returns true if the given mode name is enabled, false otherwise. -1 15609 * -1 15610 * @param {String} name -1 15611 * @return {Boolean} -1 15612 * @api public -1 15613 */ 16065 1561416066 -1 var aValue = a[aKey]16067 -1 var bValue = b[aKey]16068 -116069 -1 if (aValue === bValue) {16070 -1 continue16071 -1 } else if (isObject(aValue) && isObject(bValue)) {16072 -1 if (getPrototype(bValue) !== getPrototype(aValue)) {16073 -1 diff = diff || {}16074 -1 diff[aKey] = bValue16075 -1 } else if (isHook(bValue)) {16076 -1 diff = diff || {}16077 -1 diff[aKey] = bValue16078 -1 } else {16079 -1 var objectDiff = diffProps(aValue, bValue)16080 -1 if (objectDiff) {16081 -1 diff = diff || {}16082 -1 diff[aKey] = objectDiff16083 -1 }16084 -1 }16085 -1 } else {16086 -1 diff = diff || {}16087 -1 diff[aKey] = bValue16088 -1 }-1 15615 function enabled(name) { -1 15616 var i, len; -1 15617 for (i = 0, len = exports.skips.length; i < len; i++) { -1 15618 if (exports.skips[i].test(name)) { -1 15619 return false; 16089 15620 }16090 -116091 -1 for (var bKey in b) {16092 -1 if (!(bKey in a)) {16093 -1 diff = diff || {}16094 -1 diff[bKey] = b[bKey]16095 -1 }-1 15621 } -1 15622 for (i = 0, len = exports.names.length; i < len; i++) { -1 15623 if (exports.names[i].test(name)) { -1 15624 return true; 16096 15625 }16097 -116098 -1 return diff16099 -1 }16100 -116101 -1 function getPrototype(value) {16102 -1 if (Object.getPrototypeOf) {16103 -1 return Object.getPrototypeOf(value)16104 -1 } else if (value.__proto__) {16105 -1 return value.__proto__16106 -1 } else if (value.constructor) {16107 -1 return value.constructor.prototype16108 15626 } -1 15627 return false; 16109 15628 } 16110 1562916111 -1 },{"../vnode/is-vhook":135,"is-object":35}],144:[function(require,module,exports){16112 -1 var isArray = require("x-is-array")16113 -116114 -1 var VPatch = require("../vnode/vpatch")16115 -1 var isVNode = require("../vnode/is-vnode")16116 -1 var isVText = require("../vnode/is-vtext")16117 -1 var isWidget = require("../vnode/is-widget")16118 -1 var isThunk = require("../vnode/is-thunk")16119 -1 var handleThunk = require("../vnode/handle-thunk")16120 -116121 -1 var diffProps = require("./diff-props")16122 -116123 -1 module.exports = diff-1 15630 /** -1 15631 * Coerce `val`. -1 15632 * -1 15633 * @param {Mixed} val -1 15634 * @return {Mixed} -1 15635 * @api private -1 15636 */ 16124 1563716125 -1 function diff(a, b) {16126 -1 var patch = { a: a }16127 -1 walk(a, b, patch, 0)16128 -1 return patch-1 15638 function coerce(val) { -1 15639 if (val instanceof Error) return val.stack || val.message; -1 15640 return val; 16129 15641 } 16130 1564216131 -1 function walk(a, b, patch, index) {16132 -1 if (a === b) {16133 -1 return16134 -1 }16135 -116136 -1 var apply = patch[index]16137 -1 var applyClear = false16138 -116139 -1 if (isThunk(a) || isThunk(b)) {16140 -1 thunks(a, b, patch, index)16141 -1 } else if (b == null) {-1 15643 },{"ms":111}],111:[function(require,module,exports){ -1 15644 /** -1 15645 * Helpers. -1 15646 */ 16142 1564716143 -1 // If a is a widget we will add a remove patch for it16144 -1 // Otherwise any child widgets/hooks must be destroyed.16145 -1 // This prevents adding two remove patches for a widget.16146 -1 if (!isWidget(a)) {16147 -1 clearState(a, patch, index)16148 -1 apply = patch[index]16149 -1 }-1 15648 var s = 1000; -1 15649 var m = s * 60; -1 15650 var h = m * 60; -1 15651 var d = h * 24; -1 15652 var y = d * 365.25; 16150 1565316151 -1 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))16152 -1 } else if (isVNode(b)) {16153 -1 if (isVNode(a)) {16154 -1 if (a.tagName === b.tagName &&16155 -1 a.namespace === b.namespace &&16156 -1 a.key === b.key) {16157 -1 var propsPatch = diffProps(a.properties, b.properties)16158 -1 if (propsPatch) {16159 -1 apply = appendPatch(apply,16160 -1 new VPatch(VPatch.PROPS, a, propsPatch))16161 -1 }16162 -1 apply = diffChildren(a, b, patch, apply, index)16163 -1 } else {16164 -1 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))16165 -1 applyClear = true16166 -1 }16167 -1 } else {16168 -1 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))16169 -1 applyClear = true16170 -1 }16171 -1 } else if (isVText(b)) {16172 -1 if (!isVText(a)) {16173 -1 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))16174 -1 applyClear = true16175 -1 } else if (a.text !== b.text) {16176 -1 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))16177 -1 }16178 -1 } else if (isWidget(b)) {16179 -1 if (!isWidget(a)) {16180 -1 applyClear = true16181 -1 }-1 15654 /** -1 15655 * Parse or format the given `val`. -1 15656 * -1 15657 * Options: -1 15658 * -1 15659 * - `long` verbose formatting [false] -1 15660 * -1 15661 * @param {String|Number} val -1 15662 * @param {Object} options -1 15663 * @return {String|Number} -1 15664 * @api public -1 15665 */ 16182 1566616183 -1 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))16184 -1 }-1 15667 module.exports = function(val, options){ -1 15668 options = options || {}; -1 15669 if ('string' == typeof val) return parse(val); -1 15670 return options.long -1 15671 ? long(val) -1 15672 : short(val); -1 15673 }; 16185 1567416186 -1 if (apply) {16187 -1 patch[index] = apply16188 -1 }-1 15675 /** -1 15676 * Parse the given `str` and return milliseconds. -1 15677 * -1 15678 * @param {String} str -1 15679 * @return {Number} -1 15680 * @api private -1 15681 */ 16189 1568216190 -1 if (applyClear) {16191 -1 clearState(a, patch, index)16192 -1 }-1 15683 function parse(str) { -1 15684 str = '' + str; -1 15685 if (str.length > 10000) return; -1 15686 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); -1 15687 if (!match) return; -1 15688 var n = parseFloat(match[1]); -1 15689 var type = (match[2] || 'ms').toLowerCase(); -1 15690 switch (type) { -1 15691 case 'years': -1 15692 case 'year': -1 15693 case 'yrs': -1 15694 case 'yr': -1 15695 case 'y': -1 15696 return n * y; -1 15697 case 'days': -1 15698 case 'day': -1 15699 case 'd': -1 15700 return n * d; -1 15701 case 'hours': -1 15702 case 'hour': -1 15703 case 'hrs': -1 15704 case 'hr': -1 15705 case 'h': -1 15706 return n * h; -1 15707 case 'minutes': -1 15708 case 'minute': -1 15709 case 'mins': -1 15710 case 'min': -1 15711 case 'm': -1 15712 return n * m; -1 15713 case 'seconds': -1 15714 case 'second': -1 15715 case 'secs': -1 15716 case 'sec': -1 15717 case 's': -1 15718 return n * s; -1 15719 case 'milliseconds': -1 15720 case 'millisecond': -1 15721 case 'msecs': -1 15722 case 'msec': -1 15723 case 'ms': -1 15724 return n; -1 15725 } 16193 15726 } 16194 1572716195 -1 function diffChildren(a, b, patch, apply, index) {16196 -1 var aChildren = a.children16197 -1 var orderedSet = reorder(aChildren, b.children)16198 -1 var bChildren = orderedSet.children16199 -116200 -1 var aLen = aChildren.length16201 -1 var bLen = bChildren.length16202 -1 var len = aLen > bLen ? aLen : bLen16203 -116204 -1 for (var i = 0; i < len; i++) {16205 -1 var leftNode = aChildren[i]16206 -1 var rightNode = bChildren[i]16207 -1 index += 116208 -116209 -1 if (!leftNode) {16210 -1 if (rightNode) {16211 -1 // Excess nodes in b need to be added16212 -1 apply = appendPatch(apply,16213 -1 new VPatch(VPatch.INSERT, null, rightNode))16214 -1 }16215 -1 } else {16216 -1 walk(leftNode, rightNode, patch, index)16217 -1 }16218 -116219 -1 if (isVNode(leftNode) && leftNode.count) {16220 -1 index += leftNode.count16221 -1 }16222 -1 }16223 -116224 -1 if (orderedSet.moves) {16225 -1 // Reorder nodes last16226 -1 apply = appendPatch(apply, new VPatch(16227 -1 VPatch.ORDER,16228 -1 a,16229 -1 orderedSet.moves16230 -1 ))16231 -1 }16232 -116233 -1 return apply16234 -1 }-1 15728 /** -1 15729 * Short format for `ms`. -1 15730 * -1 15731 * @param {Number} ms -1 15732 * @return {String} -1 15733 * @api private -1 15734 */ 16235 1573516236 -1 function clearState(vNode, patch, index) {16237 -1 // TODO: Make this a single walk, not two16238 -1 unhook(vNode, patch, index)16239 -1 destroyWidgets(vNode, patch, index)-1 15736 function short(ms) { -1 15737 if (ms >= d) return Math.round(ms / d) + 'd'; -1 15738 if (ms >= h) return Math.round(ms / h) + 'h'; -1 15739 if (ms >= m) return Math.round(ms / m) + 'm'; -1 15740 if (ms >= s) return Math.round(ms / s) + 's'; -1 15741 return ms + 'ms'; 16240 15742 } 16241 1574316242 -1 // Patch records for all destroyed widgets must be added because we need16243 -1 // a DOM node reference for the destroy function16244 -1 function destroyWidgets(vNode, patch, index) {16245 -1 if (isWidget(vNode)) {16246 -1 if (typeof vNode.destroy === "function") {16247 -1 patch[index] = appendPatch(16248 -1 patch[index],16249 -1 new VPatch(VPatch.REMOVE, vNode, null)16250 -1 )16251 -1 }16252 -1 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {16253 -1 var children = vNode.children16254 -1 var len = children.length16255 -1 for (var i = 0; i < len; i++) {16256 -1 var child = children[i]16257 -1 index += 116258 -116259 -1 destroyWidgets(child, patch, index)16260 -116261 -1 if (isVNode(child) && child.count) {16262 -1 index += child.count16263 -1 }16264 -1 }16265 -1 } else if (isThunk(vNode)) {16266 -1 thunks(vNode, null, patch, index)16267 -1 }16268 -1 }-1 15744 /** -1 15745 * Long format for `ms`. -1 15746 * -1 15747 * @param {Number} ms -1 15748 * @return {String} -1 15749 * @api private -1 15750 */ 16269 1575116270 -1 // Create a sub-patch for thunks16271 -1 function thunks(a, b, patch, index) {16272 -1 var nodes = handleThunk(a, b)16273 -1 var thunkPatch = diff(nodes.a, nodes.b)16274 -1 if (hasPatches(thunkPatch)) {16275 -1 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)16276 -1 }-1 15752 function long(ms) { -1 15753 return plural(ms, d, 'day') -1 15754 || plural(ms, h, 'hour') -1 15755 || plural(ms, m, 'minute') -1 15756 || plural(ms, s, 'second') -1 15757 || ms + ' ms'; 16277 15758 } 16278 1575916279 -1 function hasPatches(patch) {16280 -1 for (var index in patch) {16281 -1 if (index !== "a") {16282 -1 return true16283 -1 }16284 -1 }-1 15760 /** -1 15761 * Pluralization helper. -1 15762 */ 16285 1576316286 -1 return false-1 15764 function plural(ms, n, name) { -1 15765 if (ms < n) return; -1 15766 if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; -1 15767 return Math.ceil(ms / n) + ' ' + name + 's'; 16287 15768 } 16288 1576916289 -1 // Execute hooks when two nodes are identical16290 -1 function unhook(vNode, patch, index) {16291 -1 if (isVNode(vNode)) {16292 -1 if (vNode.hooks) {16293 -1 patch[index] = appendPatch(16294 -1 patch[index],16295 -1 new VPatch(16296 -1 VPatch.PROPS,16297 -1 vNode,16298 -1 undefinedKeys(vNode.hooks)16299 -1 )16300 -1 )16301 -1 }-1 15770 },{}],112:[function(require,module,exports){ -1 15771 module.exports = toArray 16302 1577216303 -1 if (vNode.descendantHooks || vNode.hasThunks) {16304 -1 var children = vNode.children16305 -1 var len = children.length16306 -1 for (var i = 0; i < len; i++) {16307 -1 var child = children[i]16308 -1 index += 1-1 15773 function toArray(list, index) { -1 15774 var array = [] 16309 1577516310 -1 unhook(child, patch, index)-1 15776 index = index || 0 16311 1577716312 -1 if (isVNode(child) && child.count) {16313 -1 index += child.count16314 -1 }16315 -1 }16316 -1 }16317 -1 } else if (isThunk(vNode)) {16318 -1 thunks(vNode, null, patch, index)-1 15778 for (var i = index || 0; i < list.length; i++) { -1 15779 array[i - index] = list[i] 16319 15780 } -1 15781 -1 15782 return array 16320 15783 } 16321 1578416322 -1 function undefinedKeys(obj) {16323 -1 var result = {}-1 15785 },{}],113:[function(require,module,exports){ -1 15786 module.exports=/[\0-\x1F\x7F-\x9F]/ -1 15787 },{}],114:[function(require,module,exports){ -1 15788 module.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804\uDCBD|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/ -1 15789 },{}],115:[function(require,module,exports){ -1 15790 module.exports=/[!-#%-\*,-/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E44\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD807[\uDC41-\uDC45\uDC70\uDC71]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/ -1 15791 },{}],116:[function(require,module,exports){ -1 15792 module.exports=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/ -1 15793 },{}],117:[function(require,module,exports){ -1 15794 'use strict'; 16324 1579516325 -1 for (var key in obj) {16326 -1 result[key] = undefined16327 -1 }-1 15796 exports.Any = require('./properties/Any/regex'); -1 15797 exports.Cc = require('./categories/Cc/regex'); -1 15798 exports.Cf = require('./categories/Cf/regex'); -1 15799 exports.P = require('./categories/P/regex'); -1 15800 exports.Z = require('./categories/Z/regex'); 16328 1580116329 -1 return result16330 -1 }-1 15802 },{"./categories/Cc/regex":113,"./categories/Cf/regex":114,"./categories/P/regex":115,"./categories/Z/regex":116,"./properties/Any/regex":118}],118:[function(require,module,exports){ -1 15803 module.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/ -1 15804 },{}],119:[function(require,module,exports){ -1 15805 (function (global){ -1 15806 /*! https://mths.be/wtf8 v1.0.0 by @mathias */ -1 15807 ;(function(root) { 16331 1580816332 -1 // List diff, naive left to right reordering16333 -1 function reorder(aChildren, bChildren) {16334 -1 // O(M) time, O(M) memory16335 -1 var bChildIndex = keyIndex(bChildren)16336 -1 var bKeys = bChildIndex.keys16337 -1 var bFree = bChildIndex.free16338 -116339 -1 if (bFree.length === bChildren.length) {16340 -1 return {16341 -1 children: bChildren,16342 -1 moves: null16343 -1 }16344 -1 }-1 15809 // Detect free variables `exports` -1 15810 var freeExports = typeof exports == 'object' && exports; 16345 1581116346 -1 // O(N) time, O(N) memory16347 -1 var aChildIndex = keyIndex(aChildren)16348 -1 var aKeys = aChildIndex.keys16349 -1 var aFree = aChildIndex.free-1 15812 // Detect free variable `module` -1 15813 var freeModule = typeof module == 'object' && module && -1 15814 module.exports == freeExports && module; 16350 1581516351 -1 if (aFree.length === aChildren.length) {16352 -1 return {16353 -1 children: bChildren,16354 -1 moves: null16355 -1 }16356 -1 }-1 15816 // Detect free variable `global`, from Node.js or Browserified code, -1 15817 // and use it as `root` -1 15818 var freeGlobal = typeof global == 'object' && global; -1 15819 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { -1 15820 root = freeGlobal; -1 15821 } 16357 1582216358 -1 // O(MAX(N, M)) memory16359 -1 var newChildren = []-1 15823 /*--------------------------------------------------------------------------*/ 16360 1582416361 -1 var freeIndex = 016362 -1 var freeCount = bFree.length16363 -1 var deletedItems = 0-1 15825 var stringFromCharCode = String.fromCharCode; 16364 1582616365 -1 // Iterate through a and match a node in b16366 -1 // O(N) time,16367 -1 for (var i = 0 ; i < aChildren.length; i++) {16368 -1 var aItem = aChildren[i]16369 -1 var itemIndex-1 15827 // Taken from https://mths.be/punycode -1 15828 function ucs2decode(string) { -1 15829 var output = []; -1 15830 var counter = 0; -1 15831 var length = string.length; -1 15832 var value; -1 15833 var extra; -1 15834 while (counter < length) { -1 15835 value = string.charCodeAt(counter++); -1 15836 if (value >= 0xD800 && value <= 0xDBFF && counter < length) { -1 15837 // high surrogate, and there is a next character -1 15838 extra = string.charCodeAt(counter++); -1 15839 if ((extra & 0xFC00) == 0xDC00) { // low surrogate -1 15840 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); -1 15841 } else { -1 15842 // unmatched surrogate; only append this code unit, in case the next -1 15843 // code unit is the high surrogate of a surrogate pair -1 15844 output.push(value); -1 15845 counter--; -1 15846 } -1 15847 } else { -1 15848 output.push(value); -1 15849 } -1 15850 } -1 15851 return output; -1 15852 } 16370 1585316371 -1 if (aItem.key) {16372 -1 if (bKeys.hasOwnProperty(aItem.key)) {16373 -1 // Match up the old keys16374 -1 itemIndex = bKeys[aItem.key]16375 -1 newChildren.push(bChildren[itemIndex])-1 15854 // Taken from https://mths.be/punycode -1 15855 function ucs2encode(array) { -1 15856 var length = array.length; -1 15857 var index = -1; -1 15858 var value; -1 15859 var output = ''; -1 15860 while (++index < length) { -1 15861 value = array[index]; -1 15862 if (value > 0xFFFF) { -1 15863 value -= 0x10000; -1 15864 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); -1 15865 value = 0xDC00 | value & 0x3FF; -1 15866 } -1 15867 output += stringFromCharCode(value); -1 15868 } -1 15869 return output; -1 15870 } 16376 1587116377 -1 } else {16378 -1 // Remove old keyed items16379 -1 itemIndex = i - deletedItems++16380 -1 newChildren.push(null)16381 -1 }16382 -1 } else {16383 -1 // Match the item in a with the next free item in b16384 -1 if (freeIndex < freeCount) {16385 -1 itemIndex = bFree[freeIndex++]16386 -1 newChildren.push(bChildren[itemIndex])16387 -1 } else {16388 -1 // There are no free items in b to match with16389 -1 // the free items in a, so the extra free nodes16390 -1 // are deleted.16391 -1 itemIndex = i - deletedItems++16392 -1 newChildren.push(null)16393 -1 }16394 -1 }16395 -1 }-1 15872 /*--------------------------------------------------------------------------*/ 16396 1587316397 -1 var lastFreeIndex = freeIndex >= bFree.length ?16398 -1 bChildren.length :16399 -1 bFree[freeIndex]-1 15874 function createByte(codePoint, shift) { -1 15875 return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80); -1 15876 } 16400 1587716401 -1 // Iterate through b and append any new keys16402 -1 // O(M) time16403 -1 for (var j = 0; j < bChildren.length; j++) {16404 -1 var newItem = bChildren[j]-1 15878 function encodeCodePoint(codePoint) { -1 15879 if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence -1 15880 return stringFromCharCode(codePoint); -1 15881 } -1 15882 var symbol = ''; -1 15883 if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence -1 15884 symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0); -1 15885 } -1 15886 else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence -1 15887 symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0); -1 15888 symbol += createByte(codePoint, 6); -1 15889 } -1 15890 else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence -1 15891 symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0); -1 15892 symbol += createByte(codePoint, 12); -1 15893 symbol += createByte(codePoint, 6); -1 15894 } -1 15895 symbol += stringFromCharCode((codePoint & 0x3F) | 0x80); -1 15896 return symbol; -1 15897 } 16405 1589816406 -1 if (newItem.key) {16407 -1 if (!aKeys.hasOwnProperty(newItem.key)) {16408 -1 // Add any new keyed items16409 -1 // We are adding new items to the end and then sorting them16410 -1 // in place. In future we should insert new items in place.16411 -1 newChildren.push(newItem)16412 -1 }16413 -1 } else if (j >= lastFreeIndex) {16414 -1 // Add any leftover non-keyed items16415 -1 newChildren.push(newItem)16416 -1 }16417 -1 }-1 15899 function wtf8encode(string) { -1 15900 var codePoints = ucs2decode(string); -1 15901 var length = codePoints.length; -1 15902 var index = -1; -1 15903 var codePoint; -1 15904 var byteString = ''; -1 15905 while (++index < length) { -1 15906 codePoint = codePoints[index]; -1 15907 byteString += encodeCodePoint(codePoint); -1 15908 } -1 15909 return byteString; -1 15910 } 16418 1591116419 -1 var simulate = newChildren.slice()16420 -1 var simulateIndex = 016421 -1 var removes = []16422 -1 var inserts = []16423 -1 var simulateItem-1 15912 /*--------------------------------------------------------------------------*/ 16424 1591316425 -1 for (var k = 0; k < bChildren.length;) {16426 -1 var wantedItem = bChildren[k]16427 -1 simulateItem = simulate[simulateIndex]-1 15914 function readContinuationByte() { -1 15915 if (byteIndex >= byteCount) { -1 15916 throw Error('Invalid byte index'); -1 15917 } 16428 1591816429 -1 // remove items16430 -1 while (simulateItem === null && simulate.length) {16431 -1 removes.push(remove(simulate, simulateIndex, null))16432 -1 simulateItem = simulate[simulateIndex]16433 -1 }-1 15919 var continuationByte = byteArray[byteIndex] & 0xFF; -1 15920 byteIndex++; 16434 1592116435 -1 if (!simulateItem || simulateItem.key !== wantedItem.key) {16436 -1 // if we need a key in this position...16437 -1 if (wantedItem.key) {16438 -1 if (simulateItem && simulateItem.key) {16439 -1 // if an insert doesn't put this key in place, it needs to move16440 -1 if (bKeys[simulateItem.key] !== k + 1) {16441 -1 removes.push(remove(simulate, simulateIndex, simulateItem.key))16442 -1 simulateItem = simulate[simulateIndex]16443 -1 // if the remove didn't put the wanted item in place, we need to insert it16444 -1 if (!simulateItem || simulateItem.key !== wantedItem.key) {16445 -1 inserts.push({key: wantedItem.key, to: k})16446 -1 }16447 -1 // items are matching, so skip ahead16448 -1 else {16449 -1 simulateIndex++16450 -1 }16451 -1 }16452 -1 else {16453 -1 inserts.push({key: wantedItem.key, to: k})16454 -1 }16455 -1 }16456 -1 else {16457 -1 inserts.push({key: wantedItem.key, to: k})16458 -1 }16459 -1 k++16460 -1 }16461 -1 // a key in simulate has no matching wanted key, remove it16462 -1 else if (simulateItem && simulateItem.key) {16463 -1 removes.push(remove(simulate, simulateIndex, simulateItem.key))16464 -1 }16465 -1 }16466 -1 else {16467 -1 simulateIndex++16468 -1 k++16469 -1 }16470 -1 }-1 15922 if ((continuationByte & 0xC0) == 0x80) { -1 15923 return continuationByte & 0x3F; -1 15924 } 16471 1592516472 -1 // remove all the remaining nodes from simulate16473 -1 while(simulateIndex < simulate.length) {16474 -1 simulateItem = simulate[simulateIndex]16475 -1 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))16476 -1 }-1 15926 // If we end up here, it’s not a continuation byte. -1 15927 throw Error('Invalid continuation byte'); -1 15928 } 16477 1592916478 -1 // If the only moves we have are deletes then we can just16479 -1 // let the delete patch remove these items.16480 -1 if (removes.length === deletedItems && !inserts.length) {16481 -1 return {16482 -1 children: newChildren,16483 -1 moves: null16484 -1 }16485 -1 }-1 15930 function decodeSymbol() { -1 15931 var byte1; -1 15932 var byte2; -1 15933 var byte3; -1 15934 var byte4; -1 15935 var codePoint; 16486 1593616487 -1 return {16488 -1 children: newChildren,16489 -1 moves: {16490 -1 removes: removes,16491 -1 inserts: inserts16492 -1 }16493 -1 }16494 -1 }-1 15937 if (byteIndex > byteCount) { -1 15938 throw Error('Invalid byte index'); -1 15939 } 16495 1594016496 -1 function remove(arr, index, key) {16497 -1 arr.splice(index, 1)-1 15941 if (byteIndex == byteCount) { -1 15942 return false; -1 15943 } 16498 1594416499 -1 return {16500 -1 from: index,16501 -1 key: key16502 -1 }16503 -1 }-1 15945 // Read the first byte. -1 15946 byte1 = byteArray[byteIndex] & 0xFF; -1 15947 byteIndex++; 16504 1594816505 -1 function keyIndex(children) {16506 -1 var keys = {}16507 -1 var free = []16508 -1 var length = children.length-1 15949 // 1-byte sequence (no continuation bytes) -1 15950 if ((byte1 & 0x80) == 0) { -1 15951 return byte1; -1 15952 } 16509 1595316510 -1 for (var i = 0; i < length; i++) {16511 -1 var child = children[i]-1 15954 // 2-byte sequence -1 15955 if ((byte1 & 0xE0) == 0xC0) { -1 15956 var byte2 = readContinuationByte(); -1 15957 codePoint = ((byte1 & 0x1F) << 6) | byte2; -1 15958 if (codePoint >= 0x80) { -1 15959 return codePoint; -1 15960 } else { -1 15961 throw Error('Invalid continuation byte'); -1 15962 } -1 15963 } 16512 1596416513 -1 if (child.key) {16514 -1 keys[child.key] = i16515 -1 } else {16516 -1 free.push(i)16517 -1 }16518 -1 }-1 15965 // 3-byte sequence (may include unpaired surrogates) -1 15966 if ((byte1 & 0xF0) == 0xE0) { -1 15967 byte2 = readContinuationByte(); -1 15968 byte3 = readContinuationByte(); -1 15969 codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3; -1 15970 if (codePoint >= 0x0800) { -1 15971 return codePoint; -1 15972 } else { -1 15973 throw Error('Invalid continuation byte'); -1 15974 } -1 15975 } 16519 1597616520 -1 return {16521 -1 keys: keys, // A hash of key name to index16522 -1 free: free // An array of unkeyed item indices16523 -1 }16524 -1 }-1 15977 // 4-byte sequence -1 15978 if ((byte1 & 0xF8) == 0xF0) { -1 15979 byte2 = readContinuationByte(); -1 15980 byte3 = readContinuationByte(); -1 15981 byte4 = readContinuationByte(); -1 15982 codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) | -1 15983 (byte3 << 0x06) | byte4; -1 15984 if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) { -1 15985 return codePoint; -1 15986 } -1 15987 } 16525 1598816526 -1 function appendPatch(apply, patch) {16527 -1 if (apply) {16528 -1 if (isArray(apply)) {16529 -1 apply.push(patch)16530 -1 } else {16531 -1 apply = [apply, patch]16532 -1 }-1 15989 throw Error('Invalid WTF-8 detected'); -1 15990 } 16533 1599116534 -1 return apply16535 -1 } else {16536 -1 return patch16537 -1 }16538 -1 }-1 15992 var byteArray; -1 15993 var byteCount; -1 15994 var byteIndex; -1 15995 function wtf8decode(byteString) { -1 15996 byteArray = ucs2decode(byteString); -1 15997 byteCount = byteArray.length; -1 15998 byteIndex = 0; -1 15999 var codePoints = []; -1 16000 var tmp; -1 16001 while ((tmp = decodeSymbol()) !== false) { -1 16002 codePoints.push(tmp); -1 16003 } -1 16004 return ucs2encode(codePoints); -1 16005 } 16539 1600616540 -1 },{"../vnode/handle-thunk":133,"../vnode/is-thunk":134,"../vnode/is-vnode":136,"../vnode/is-vtext":137,"../vnode/is-widget":138,"../vnode/vpatch":141,"./diff-props":143,"x-is-array":145}],145:[function(require,module,exports){16541 -1 var nativeIsArray = Array.isArray16542 -1 var toString = Object.prototype.toString-1 16007 /*--------------------------------------------------------------------------*/ 16543 1600816544 -1 module.exports = nativeIsArray || isArray-1 16009 var wtf8 = { -1 16010 'version': '1.0.0', -1 16011 'encode': wtf8encode, -1 16012 'decode': wtf8decode -1 16013 }; 16545 1601416546 -1 function isArray(obj) {16547 -1 return toString.call(obj) === "[object Array]"16548 -1 }-1 16015 // Some AMD build optimizers, like r.js, check for specific condition patterns -1 16016 // like the following: -1 16017 if ( -1 16018 typeof define == 'function' && -1 16019 typeof define.amd == 'object' && -1 16020 define.amd -1 16021 ) { -1 16022 define(function() { -1 16023 return wtf8; -1 16024 }); -1 16025 } else if (freeExports && !freeExports.nodeType) { -1 16026 if (freeModule) { // in Node.js or RingoJS v0.8.0+ -1 16027 freeModule.exports = wtf8; -1 16028 } else { // in Narwhal or RingoJS v0.7.0- -1 16029 var object = {}; -1 16030 var hasOwnProperty = object.hasOwnProperty; -1 16031 for (var key in wtf8) { -1 16032 hasOwnProperty.call(wtf8, key) && (freeExports[key] = wtf8[key]); -1 16033 } -1 16034 } -1 16035 } else { // in Rhino or a web browser -1 16036 root.wtf8 = wtf8; -1 16037 } -1 16038 -1 16039 }(this)); 16549 1604016550 -1 },{}],146:[function(require,module,exports){-1 16041 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -1 16042 },{}],120:[function(require,module,exports){ 16551 16043 'use strict'; 16552 16044 16553 16045 var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('') @@ -16617,9 +16109,9 @@ yeast.encode = encode; 16617 16109 yeast.decode = decode; 16618 16110 module.exports = yeast; 16619 1611116620 -1 },{}],147:[function(require,module,exports){16621 -1 var virtualDom = require('virtual-dom');16622 -1 var h = require('virtual-dom/h');-1 16112 },{}],121:[function(require,module,exports){ -1 16113 var preact = require('preact'); -1 16114 var h = require('preact').h; 16623 16115 var MarkdownIt = require('markdown-it'); 16624 16116 var io = require('socket.io-client'); 16625 16117 @@ -16629,6 +16121,12 @@ var _ = function(s) { 16629 16121 return s; 16630 16122 }; 16631 16123 -1 16124 var forEach = function(list, fn) { -1 16125 for (var i = 0; i < list.length; i++) { -1 16126 fn(list[i], i); -1 16127 } -1 16128 }; -1 16129 16632 16130 var throttle = function(fn, timeout) { 16633 16131 var called, blocked; 16634 16132 @@ -16704,7 +16202,7 @@ var tplNode = function(nodes, node, ID) { 16704 16202 classList.push('is-expanded'); 16705 16203 } 16706 16204 if (node.id === ID) {16707 -1 classList.push('m-self');-1 16205 classList.push('node--self'); 16708 16206 } 16709 16207 16710 16208 var delegateAttrs = {}; @@ -16712,46 +16210,62 @@ var tplNode = function(nodes, node, ID) { 16712 16210 delegateAttrs.disabled = true; 16713 16211 } 16714 1621216715 -1 return h('li.node#node-' + node.id, {-1 16213 return h('li', { 16716 16214 key: 'node-' + node.id,16717 -1 className: classList.join(' '),-1 16215 id: 'node-' + node.id, -1 16216 className: 'node ' + classList.join(' '), -1 16217 role: 'treeitem', -1 16218 'aria-expanded': '' + !!node.expanded, 16718 16219 }, [16719 -1 h('article.body', [16720 -1 h('header.header', [16721 -1 h('button.expand', {-1 16220 h('article', { -1 16221 className: 'node__body', -1 16222 }, [ -1 16223 h('header', { -1 16224 className: 'node__header bar', -1 16225 }, [ -1 16226 h('button', { -1 16227 className: 'node__expand bar__item bar__item--button bar__item--left', 16722 16228 title: _(node.expanded ? 'collapse' : 'expand'),16723 -1 }),16724 -1 h('div.votes', '' + getVotes(nodes, node)),16725 -1 h('button.delegate', {-1 16229 }, node.expanded ? '\u25BC' : '\u25B6'), -1 16230 h('button', { -1 16231 className: 'node__delegate bar__item bar__item--button bar__item--right', 16726 16232 title: _('delegate to ') + getName(node), 16727 16233 attributes: delegateAttrs,16728 -1 }, '+'),16729 -1 h('div.name', getName(node)),-1 16234 }, '\u2795'), -1 16235 h('div', {className: 'node__votes bar__item bar__item--right'}, '' + getVotes(nodes, node)), -1 16236 h('div', {className: 'node__name bar__item' + (!node.expanded && node.comment ? '' : ' bar__item--grow')}, getName(node)), -1 16237 !node.expanded && node.comment && h('div', {className: 'node__preview bar__item bar__item--grow'}, node.comment.substr(0, 100)), 16730 16238 ]),16731 -1 h('div.comment', {16732 -1 innerHTML: md.render(node.comment || ''),-1 16239 node.expanded && h('div', { -1 16240 className: 'node__comment', -1 16241 dangerouslySetInnerHTML: { -1 16242 __html: md.render(node.comment || '') -1 16243 }, 16733 16244 }), 16734 16245 ]),16735 -1 h('ul.tree', tplFollowers(nodes, node.id, ID)),-1 16246 h('ul', { -1 16247 className: 'tree', -1 16248 role: 'group', -1 16249 }, tplFollowers(nodes, node.id, ID)), 16736 16250 ]); 16737 16251 }; 16738 16252 16739 16253 var template = function(nodes, ID) {16740 -1 return h('ul.tree', tplFollowers(nodes, null, ID));-1 16254 return h('ul', { -1 16255 className: 'tree', -1 16256 role: 'tree', -1 16257 }, tplFollowers(nodes, null, ID)); 16741 16258 }; 16742 16259 16743 16260 var initVDom = function(wrapper, nodes, ID, afterRender) {16744 -1 var tree = template(nodes, ID);16745 -1 var element = virtualDom.create(tree);16746 16261 wrapper.innerHTML = '';16747 -1 wrapper.appendChild(element);-1 16262 var tree = template(nodes, ID); -1 16263 var element = preact.render(tree, wrapper); 16748 16264 afterRender(); 16749 16265 16750 16266 return function(newState) { 16751 16267 var newTree = template(newState, ID);16752 -1 var patches = virtualDom.diff(tree, newTree);16753 -1 virtualDom.patch(element, patches);16754 -1 tree = newTree;-1 16268 preact.render(newTree, wrapper, element); 16755 16269 afterRender(); 16756 16270 }; 16757 16271 }; @@ -16815,19 +16329,19 @@ document.addEventListener('DOMContentLoaded', function() { 16815 16329 return node.id === ID; 16816 16330 }); 16817 16331 if (user) {16818 -1 document.querySelector('#name input').value = user.name;16819 -1 document.querySelector('#comment textarea').value = user.comment;-1 16332 document.querySelector('.user__name input').value = user.name; -1 16333 document.querySelector('.user__comment textarea').value = user.comment; 16820 16334 ensureVisible(user); 16821 16335 } 16822 16336 16823 16337 var updateUser = function() {16824 -1 document.querySelector('#user .votes').textContent = getVotes(nodes, user || {});-1 16338 document.querySelector('.user__votes').textContent = getVotes(nodes, user || {}); 16825 16339 16826 16340 if (user && user.delegate) { 16827 16341 var delegatee = getNode(user.delegate);16828 -1 document.querySelector('#user .delegate').textContent = getName(delegatee);-1 16342 document.querySelector('.user__delegation').textContent = _('delegated to: ') + getName(delegatee); 16829 16343 } else {16830 -1 document.querySelector('#user .delegate').textContent = _('(no delegation)');-1 16344 document.querySelector('.user__delegation').textContent = _('(no delegation)'); 16831 16345 } 16832 16346 }; 16833 16347 @@ -16848,33 +16362,33 @@ document.addEventListener('DOMContentLoaded', function() { 16848 16362 var update = initVDom(document.querySelector('#tree'), nodes, ID, function() { 16849 16363 updateUser(); 16850 1636416851 -1 document.querySelectorAll('.expand').forEach(function(element) {-1 16365 forEach(document.querySelectorAll('.node__expand'), function(element) { 16852 16366 element.addEventListener('click', toggleExpand); 16853 16367 }); 16854 1636816855 -1 document.querySelectorAll('.delegate').forEach(function(element) {-1 16369 forEach(document.querySelectorAll('.node__delegate'), function(element) { 16856 16370 element.addEventListener('click', setDelegate); 16857 16371 }); 16858 16372 }); 16859 1637316860 -1 document.querySelector('#rm').addEventListener('click', function(event) {-1 16374 document.querySelector('.user__rm').addEventListener('click', function(event) { 16861 16375 if (confirm(_("Do you really want to delete this opinion?"))) { 16862 16376 socket.emit('rmNode');16863 -1 document.querySelector('#name input').value = '';16864 -1 document.querySelector('#comment textarea').value = '';-1 16377 document.querySelector('.user__name input').value = ''; -1 16378 document.querySelector('.user__comment textarea').value = ''; 16865 16379 } 16866 16380 }); 16867 1638116868 -1 document.querySelector('#name input').addEventListener('change', function(event) {-1 16382 document.querySelector('.user__name input').addEventListener('change', function(event) { 16869 16383 socket.emit('setNodeName', event.target.value); 16870 16384 }); 16871 1638516872 -1 document.querySelector('.undelegate').addEventListener('click', function(event) {-1 16386 document.querySelector('.user__undelegate').addEventListener('click', function(event) { 16873 16387 socket.emit('rmDelegate'); 16874 16388 }); 16875 16389 16876 16390 var pushComment = throttle(function() {16877 -1 var comment = document.querySelector('#comment textarea').value;-1 16391 var comment = document.querySelector('.user__comment textarea').value; 16878 16392 var node = nodes.find(function(n) { 16879 16393 return n.id === ID; 16880 16394 }); @@ -16885,11 +16399,14 @@ document.addEventListener('DOMContentLoaded', function() { 16885 16399 } 16886 16400 }, 1000); 16887 1640116888 -1 document.querySelector('#comment textarea').addEventListener('change', pushComment);16889 -1 document.querySelector('#comment textarea').addEventListener('keydown', pushComment);-1 16402 document.querySelector('.user__comment textarea').addEventListener('change', pushComment); -1 16403 document.querySelector('.user__comment textarea').addEventListener('keydown', pushComment); 16890 16404 16891 16405 socket.on('rmNode', function(id) { 16892 16406 nodes = nodes.filter(function(node) { -1 16407 if (node.delegate === id) { -1 16408 node.delegate = null; -1 16409 } 16893 16410 return node.id !== id; 16894 16411 }); 16895 16412 invalidateVotes(); @@ -16916,4 +16433,4 @@ document.addEventListener('DOMContentLoaded', function() { 16916 16433 }); 16917 16434 }); 16918 1643516919 -1 },{"markdown-it":39,"socket.io-client":100,"virtual-dom":121,"virtual-dom/h":120}]},{},[147]);-1 16436 },{"markdown-it":36,"preact":96,"socket.io-client":97}]},{},[121]);