1'use strict'; 2 3var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 4 5var loadArrayFromURL = function () { 6 var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(fileName, opts) { 7 var buffer, shape; 8 return regeneratorRuntime.wrap(function _callee$(_context) { 9 while (1) { 10 switch (_context.prev = _context.next) { 11 case 0: 12 _context.t0 = Float32Array; 13 _context.next = 3; 14 return loadBuffer(fileName, opts); 15 16 case 3: 17 _context.t1 = _context.sent; 18 buffer = new _context.t0(_context.t1); 19 shape = fileName.match(/\d+(x\d+)*$/)[0].split('x').map(function (k) { 20 return +k; 21 }); 22 return _context.abrupt('return', ndarray(buffer, shape)); 23 24 case 7: 25 case 'end': 26 return _context.stop(); 27 } 28 } 29 }, _callee, this); 30 })); 31 32 return function loadArrayFromURL(_x, _x2) { 33 return _ref.apply(this, arguments); 34 }; 35}(); 36 37// function createProgress(label, container){ 38// const prog = document.createElement('div') 39// prog.style = ` 40// width: 0; 41// height: 2px; 42// background: #8BC77C; 43// ` 44 45// label = document.createTextNode(label || '') 46 47// let destroy = () => (container.removeChild(prog), container.removeChild(label)) 48 49// if(!container){ 50// container = document.body.appendChild(document.createElement('div')) 51// container.style = ` 52// position: absolute; 53// top: 0; 54// left: 0; 55// width: 100%; 56// padding: 20px; 57// boxSizing: border-box; 58// ` 59// destroy = () => document.body.removeChild(container) 60// } 61 62// container.appendChild(label) 63// container.appendChild(prog) 64 65// return { 66// set value(n){ 67// prog.style.width = n*100+'%' 68// }, 69// destroy 70// } 71// } 72 73var loadBuffer = function () { 74 var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(fileName) { 75 var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, 76 progressContainer = _ref3.progressContainer; 77 78 var xhr, prog; 79 return regeneratorRuntime.wrap(function _callee2$(_context2) { 80 while (1) { 81 switch (_context2.prev = _context2.next) { 82 case 0: 83 xhr = new XMLHttpRequest(); 84 85 xhr.open('GET', fileName, true); 86 xhr.responseType = 'arraybuffer'; 87 xhr.send(null); 88 89 prog = createProgress('downloading model', progressContainer); 90 91 xhr.onprogress = function (progress) { 92 prog.value = progress.loaded / progress.total; 93 }; 94 95 _context2.next = 8; 96 return new Promise(function (resolve) { 97 return xhr.onload = resolve; 98 }); 99 100 case 8: 101 prog.destroy(); 102 103 return _context2.abrupt('return', xhr.response); 104 105 case 10: 106 case 'end': 107 return _context2.stop(); 108 } 109 } 110 }, _callee2, this); 111 })); 112 113 return function loadBuffer(_x3) { 114 return _ref2.apply(this, arguments); 115 }; 116}(); 117 118var loadJSON = function () { 119 var _ref4 = _asyncToGenerator(regeneratorRuntime.mark(function _callee3(fileName) { 120 return regeneratorRuntime.wrap(function _callee3$(_context3) { 121 while (1) { 122 switch (_context3.prev = _context3.next) { 123 case 0: 124 _context3.next = 2; 125 return fetch(fileName); 126 127 case 2: 128 _context3.next = 4; 129 return _context3.sent.json(); 130 131 case 4: 132 return _context3.abrupt('return', _context3.sent); 133 134 case 5: 135 case 'end': 136 return _context3.stop(); 137 } 138 } 139 }, _callee3, this); 140 })); 141 142 return function loadJSON(_x5) { 143 return _ref4.apply(this, arguments); 144 }; 145}(); 146 147var loadImage = function () { 148 var _ref5 = _asyncToGenerator(regeneratorRuntime.mark(function _callee4(url) { 149 var image, canvas, ctx; 150 return regeneratorRuntime.wrap(function _callee4$(_context4) { 151 while (1) { 152 switch (_context4.prev = _context4.next) { 153 case 0: 154 image = new Image(), canvas = document.createElement('canvas'), ctx = canvas.getContext('2d'); 155 156 image.src = url; 157 _context4.next = 4; 158 return new Promise(function (resolve) { 159 image.onload = function () {
160 canvas.width = image.naturalWidth; 161 canvas.height = image.naturalHeight; 162 ctx.drawImage(image, 0, 0); 163 resolve(ctx.getImageData(0, 0, canvas.width, canvas.height)); 164 }; 165 }); 166 167 case 4: 168 return _context4.abrupt('return', _context4.sent); 169 170 case 5: 171 case 'end': 172 return _context4.stop(); 173 } 174 } 175 }, _callee4, this); 176 })); 177 178 return function loadImage(_x6) { 179 return _ref5.apply(this, arguments); 180 }; 181}(); 182 183function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 184 185function createProgress(label, container) { 186 document.querySelector('.pie-wrapper').style.display = ''; 187 188 document.querySelector('.pie-wrapper .label').innerText = label; 189 return { 190 set value(n) { 191 document.querySelector('.pie .left-side').style.transform = 'rotate(' + 360 * n + 'deg)'; 192 document.querySelector('.pie').classList.toggle('over-fifty', n > 0.5); 193 }, 194 destroy: function destroy() { 195 document.querySelector('.pie-wrapper').style.display = 'none'; 196 } 197 }; 198} 199 200function h(type) { 201 var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 202 203 var el = document.createElement(type); 204 (Array.isArray(children) ? children : [children]).forEach(function (k) { 205 return el.appendChild((typeof k === 'undefined' ? 'undefined' : _typeof(k)) != 'object' ? document.createTextNode(k) : k); 206 }); 207 return el; 208}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.