/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./app/client/index.jsx"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./app/client/actions.js": /*!*******************************!*\ !*** ./app/client/actions.js ***! \*******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _api = __webpack_require__(/*! ./api */ "./app/client/api/index.js"); var _live = __webpack_require__(/*! ./live/live.actions */ "./app/client/live/live.actions.js"); var liveActions = _interopRequireWildcard(_live); var _queue = __webpack_require__(/*! ./queue/queue.actions */ "./app/client/queue/queue.actions.js"); var queueActions = _interopRequireWildcard(_queue); var _system = __webpack_require__(/*! ./system/system.actions */ "./app/client/system/system.actions.js"); var systemActions = _interopRequireWildcard(_system); var _socket = __webpack_require__(/*! ./socket/socket.actions */ "./app/client/socket/socket.actions.js"); var socketActions = _interopRequireWildcard(_socket); var _dataset = __webpack_require__(/*! ./dataset/dataset.actions */ "./app/client/dataset/dataset.actions.js"); var datasetActions = _interopRequireWildcard(_dataset); var _audioPlayer = __webpack_require__(/*! ./common/audioPlayer/audioPlayer.actions */ "./app/client/common/audioPlayer/audioPlayer.actions.js"); var audioPlayerActions = _interopRequireWildcard(_audioPlayer); var _store = __webpack_require__(/*! ./store */ "./app/client/store.js"); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } exports.default = Object.keys(_api.actions).map(function (a) { return [a, _api.actions[a]]; }).concat([['live', liveActions], ['queue', queueActions], ['system', systemActions], ['dataset', datasetActions], ['audioPlayer', audioPlayerActions]]).map(function (p) { return [p[0], (0, _redux.bindActionCreators)(p[1], _store.store.dispatch)]; }).concat([['socket', socketActions]]).reduce(function (a, b) { return (a[b[0]] = b[1]) && a; }, {}); /***/ }), /***/ "./app/client/api/crud.actions.js": /*!****************************************!*\ !*** ./app/client/api/crud.actions.js ***! \****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.crud_action = undefined; exports.crud_actions = crud_actions; var _crud = __webpack_require__(/*! ./crud.fetch */ "./app/client/api/crud.fetch.js"); var _crud2 = __webpack_require__(/*! ./crud.types */ "./app/client/api/crud.types.js"); var _crud3 = __webpack_require__(/*! ./crud.upload */ "./app/client/api/crud.upload.js"); function crud_actions(type) { var fetch_type = (0, _crud.crud_fetch)(type); return ['index', 'show', 'create', 'update', 'destroy'].reduce(function (lookup, param) { lookup[param] = crud_action(type, param, function (q) { return fetch_type[param](q); }); return lookup; }, { action: function action(method, fn) { return crud_action(type, method, fn); }, upload: function upload(id, fd) { return (0, _crud3.upload_action)(type, id, fd); } }); } var crud_action = exports.crud_action = function crud_action(type, method, fn) { return function (q) { return function (dispatch) { return new Promise(function (resolve, reject) { dispatch({ type: (0, _crud2.as_type)(type, method + '_loading') }); fn(q).then(function (data) { dispatch({ type: (0, _crud2.as_type)(type, method), data: data }); resolve(data); }).catch(function (e) { dispatch({ type: (0, _crud2.as_type)(type, method + '_error') }); reject(e); }); }); }; }; }; /***/ }), /***/ "./app/client/api/crud.fetch.js": /*!**************************************!*\ !*** ./app/client/api/crud.fetch.js ***! \**************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.crud_fetch = crud_fetch; exports.postBody = postBody; var _nodeFetch = __webpack_require__(/*! node-fetch */ "./node_modules/node-fetch/browser.js"); var _nodeFetch2 = _interopRequireDefault(_nodeFetch); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function crud_fetch(type, tag) { var uri = '/api/' + type + '/' + (tag || ''); return { index: function index(q) { return (0, _nodeFetch2.default)(_get_url(uri, q), _get_headers()).then(function (req) { return req.json(); }).catch(error); }, show: function show(id) { return (0, _nodeFetch2.default)(uri + id).then(function (req) { return req.json(); }).catch(error); }, create: function create(data) { return (0, _nodeFetch2.default)(uri, post(data)).then(function (req) { return req.json(); }).catch(error); }, update: function update(data) { return (0, _nodeFetch2.default)(uri + data.id, put(data)).then(function (req) { return req.json(); }).catch(error); }, destroy: function destroy(data) { return (0, _nodeFetch2.default)(uri + data.id, _destroy(data)).then(function (req) { return req.json(); }).catch(error); } }; } function _get_url(_url, data) { var url = new URL(window.location.origin + _url); if (data) { Object.keys(data).forEach(function (key) { return url.searchParams.append(key, data[key]); }); } return url; } function _get_headers() { return { method: 'GET', headers: { 'Accept': 'application/json' } }; } function post(data) { return { method: 'POST', body: JSON.stringify(data), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; } function postBody(data) { return { method: 'POST', body: data, headers: { 'Accept': 'application/json' } }; } function put(data) { return { method: 'PUT', body: JSON.stringify(data), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; } function _destroy(data) { return { method: 'DELETE', body: JSON.stringify(data), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; } function error(err) { console.warn(err); } /***/ }), /***/ "./app/client/api/crud.types.js": /*!**************************************!*\ !*** ./app/client/api/crud.types.js ***! \**************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var as_type = exports.as_type = function as_type(a, b) { return [a, b].join('_').toUpperCase(); }; var with_type = exports.with_type = function with_type(type, actions) { return actions.reduce(function (a, b) { return (a[b] = as_type(type, b)) && a; }, {}); }; var crud_type = exports.crud_type = function crud_type(type) { var actions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; return with_type(type, actions.concat(['index_loading', 'index', 'index_error', 'show_loading', 'show', 'show_error', 'create_loading', 'create', 'create_error', 'update_loading', 'update', 'update_error', 'destroy_loading', 'destroy', 'destroy_error', 'upload_loading', 'upload_progress', 'upload_waiting', 'upload_complete', 'upload_error', 'sort'])); }; /***/ }), /***/ "./app/client/api/crud.upload.js": /*!***************************************!*\ !*** ./app/client/api/crud.upload.js ***! \***************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.upload_action = undefined; exports.crud_upload = crud_upload; var _crud = __webpack_require__(/*! ./crud.types */ "./app/client/api/crud.types.js"); function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function crud_upload(type, fd, data, dispatch) { return new Promise(function (resolve, reject) { var id = data.id; Object.keys(data).forEach(function (key) { if (key !== 'id') { fd.append(key, data[key]); } }); console.log('/api/' + type + '/' + id + '/upload/'); var xhr = new XMLHttpRequest(); xhr.upload.addEventListener("progress", uploadProgress, false); xhr.addEventListener("load", uploadComplete, false); xhr.addEventListener("error", uploadFailed, false); xhr.addEventListener("abort", uploadCancelled, false); xhr.open("POST", '/api/' + type + '/' + id + '/upload/'); xhr.send(fd); dispatch && dispatch({ type: (0, _crud.as_type)(type, 'upload_loading') }); var complete = false; function uploadProgress(e) { if (e.lengthComputable) { var percent = Math.round(e.loaded * 100 / e.total) || 0; if (percent > 99) { dispatch && dispatch(_defineProperty({ type: (0, _crud.as_type)(type, 'upload_waiting'), percent: percent }, type, id)); } else { dispatch && dispatch(_defineProperty({ type: (0, _crud.as_type)(type, 'upload_progress'), percent: percent }, type, id)); } } else { dispatch && dispatch(_defineProperty({ type: (0, _crud.as_type)(type, 'upload_error'), error: 'unable to compute upload progress' }, type, id)); } } function uploadComplete(e) { var parsed = void 0; try { parsed = JSON.parse(e.target.responseText); } catch (e) { dispatch && dispatch(_defineProperty({ type: (0, _crud.as_type)(type, 'upload_error'), error: 'upload failed' }, type, id)); reject(e); return; } dispatch && dispatch(_defineProperty({ type: (0, _crud.as_type)(type, 'upload_complete'), data: parsed }, type, id)); if (parsed.files && parsed.files.length) { parsed.files.forEach(function (file) { console.log(file); dispatch && dispatch({ type: (0, _crud.as_type)('file', 'create'), data: file }); }); } resolve(parsed); } function uploadFailed(evt) { dispatch && dispatch(_defineProperty({ type: (0, _crud.as_type)(type, 'upload_error'), error: 'upload failed' }, type, id)); reject(evt); } function uploadCancelled(evt) { dispatch && dispatch(_defineProperty({ type: (0, _crud.as_type)(type, 'upload_error'), error: 'upload cancelled' }, type, id)); reject(evt); } }); } var upload_action = exports.upload_action = function upload_action(type, id, fd) { return function (dispatch) { return crud_upload(type, id, fd, dispatch); }; }; /***/ }), /***/ "./app/client/api/index.js": /*!*********************************!*\ !*** ./app/client/api/index.js ***! \*********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.actions = exports.parser = exports.util = undefined; var _crud = __webpack_require__(/*! ./crud.actions */ "./app/client/api/crud.actions.js"); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _parser = __webpack_require__(/*! ./parser */ "./app/client/api/parser.js"); var parser = _interopRequireWildcard(_parser); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* for our crud events, create corresponding actions the actions fire a 'loading' event, call the underlying api method, and then resolve. so you can do ... import { folderActions } from '../../api' folderActions.index({ module: 'samplernn' }) folderActions.show(12) folderActions.create({ module: 'samplernn', name: 'foo' }) folderActions.update(12, { module: 'pix2pix' }) folderActions.destroy(12, { confirm: true }) folderActions.upload(12, form_data) */ exports.util = _util2.default; exports.parser = parser; var actions = exports.actions = ['folder', 'file', 'dataset', 'task', 'user'].reduce(function (a, b) { return (a[b] = (0, _crud.crud_actions)(b)) && a; }, {}); /***/ }), /***/ "./app/client/api/parser.js": /*!**********************************!*\ !*** ./app/client/api/parser.js ***! \**********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tumblr = exports.thumbnail = exports.loadImage = exports.tag = exports.parse = exports.lookup = exports.integrations = undefined; var _nodeFetch = __webpack_require__(/*! node-fetch */ "./node_modules/node-fetch/browser.js"); var _nodeFetch2 = _interopRequireDefault(_nodeFetch); var _fetchJsonp = __webpack_require__(/*! fetch-jsonp */ "./node_modules/fetch-jsonp/build/fetch-jsonp.js"); var _fetchJsonp2 = _interopRequireDefault(_fetchJsonp); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var integrations = exports.integrations = [{ type: 'image', regex: /\.(jpeg|jpg|gif|png|svg)(\?.*)?$/i, fetch: function fetch(url, done) { var img = new Image(); img.onload = function () { if (!img) return; var width = img.naturalWidth, height = img.naturalHeight; img = null; done({ url: url, type: "image", token: "", thumbnail: "", title: "", width: width, height: height }); }; img.src = url; if (img.complete) { img.onload(); } }, tag: function tag(media) { return ''; } }, { type: 'video', regex: /\.(mp4|webm)(\?.*)?$/i, fetch: function fetch(url, done) { var video = document.createElement("video"); var url_parts = url.replace(/\?.*$/, "").split("/"); var filename = url_parts[url_parts.length - 1]; video.addEventListener("loadedmetadata", function () { var width = video.videoWidth, height = video.videoHeight; video = null; done({ url: url, type: "video", token: url, thumbnail: "/public/assets/img/video-thumbnail.png", title: filename, width: width, height: height }); }); video.src = url; video.load(); }, tag: function tag(media) { return ''; } }, { type: 'audio', regex: /\.(wav|mp3)(\?.*)?$/i, fetch: function fetch(url, done) { var audio = document.createElement("audio"); var url_parts = url.replace(/\?.*$/, "").split("/"); var filename = url_parts[url_parts.length - 1]; audio.addEventListener("loadedmetadata", function () { var duration = audio.duration; audio = null; done({ url: url, type: "audio", token: url, thumbnail: "/public/assets/img/audio-thumbnail.png", title: filename, duration: duration }); }); audio.src = url; audio.load(); }, tag: function tag(media) { return ''; } }, { type: 'youtube', regex: /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i, fetch: function fetch(url, done) { var id = (url.match(/v=([-_a-zA-Z0-9]{11})/i) || url.match(/youtu.be\/([-_a-zA-Z0-9]{11})/i) || url.match(/embed\/([-_a-zA-Z0-9]{11})/i))[1].split('&')[0]; var thumb = "https://i.ytimg.com/vi/" + id + "/hqdefault.jpg"; var jsonp_url = new URL('https://www.googleapis.com/youtube/v3/videos'); var data = { id: id, key: "AIzaSyCaLRGY-hxs92045X-Jew7w1FgQPkStHgc", part: "id,contentDetails,snippet,status" }; Object.keys(data).forEach(function (key) { return jsonp_url.searchParams.append(key, data[key]); }); (0, _fetchJsonp2.default)(jsonp_url.toString()).then(function (result) { return result.json(); }).then(function (result) { if (!result || !result.items.length) { return alert("Sorry, this video URL is invalid."); } var res = result.items[0]; // console.log(res) var dd = res.contentDetails.duration.match(/\d+/g).map(function (i) { return parseInt(i); }); var duration = 0; if (dd.length == 3) { duration = dd[0] * 60 + dd[1] * 60 + dd[2]; } else if (dd.length == 2) { duration = dd[0] * 60 + dd[1]; } else { duration = dd[0]; } ["maxres", "high", "medium", "standard", "default"].some(function (t) { if (res.snippet.thumbnails[t]) { thumb = res.snippet.thumbnails[t].url; return true; } return false; }); done({ url: url, type: "youtube", token: id, thumbnail: thumb, title: res.snippet.title, duration: duration, width: 640, height: 360 }); }); }, tag: function tag(media) { // return '▶'; return ''; } }, { type: 'vimeo', regex: /vimeo.com\/\d+$/i, fetch: function fetch(url, done) { var id = url.match(/\d+$/i)[0]; (0, _nodeFetch2.default)('https://vimeo.com/api/v2/video/' + id + '.json').then(function (result) { return result.json(); }).then(function (result) { if (result.length == 0) { return done(id, "", 640, 360); } var res = result[0]; if (res.embed_privacy != "anywhere") { alert("Sorry, the author of this video has marked it private, preventing it from being embedded.", function () {}); return; } done({ url: url, type: "vimeo", token: id, thumbnail: res.thumbnail_large, duration: res.duration, title: res.title, width: res.width, height: res.height }); }); }, tag: function tag(media) { // return '▶'; return ''; } }, // { // type: 'soundcloud', // regex: /soundcloud.com\/[-a-zA-Z0-9]+\/[-a-zA-Z0-9]+\/?$/i, // fetch: function (url, done) { // fetch('https://api.soundcloud.com/resolve.json?url=' // + url // + '&client_id=' // + '0673fbe6fc794a7750f680747e863b10') // .then(result => result.json()) // .then(result => { // console.log(result) // done({ // url: url, // type: "soundcloud", // token: result.id, // thumbnail: result.artwork_url || result.user.avatar_url, // title: result.user.username + " - " + result.title, // duration: result.duration, // width: 166, // height: 166, // }) // }) // }, // tag: function (media) { // return '' // } // }, { type: 'link', regex: /^http.+/i, fetch: function fetch(url, done) { done({ url: url, type: "link", token: "", thumbnail: "", title: "", width: 100, height: 100 }); }, tag: function tag(media) { return '' + media.url + ''; } }]; var lookup = exports.lookup = integrations.reduce(function (a, b) { return (a[b.type] = b) && a; }, {}); var parse = exports.parse = function parse(url, cb) { var matched = integrations.some(function (integration) { if (integration.regex.test(url)) { integration.fetch(url, function (res) { cb(res); }); return true; } return false; }); if (!matched) { cb(null); } }; var tag = exports.tag = function tag(media) { if (media.type in lookup) { return lookup[media.type].tag(media); } return ""; }; var loadImage = exports.loadImage = function loadImage(url, cb, error) { if (lookup.image.regex.test(url)) { lookup.image.fetch(url, function (media) { cb(media); }); } else error && error(); }; var thumbnail = exports.thumbnail = function thumbnail(media) { return ''; }; var tumblr = exports.tumblr = function tumblr(url, cb) { var domain = url.replace(/^https?:\/\//, "").split("/")[0]; if (domain.indexOf(".") == -1) { domain += ".tumblr.com"; } (0, _fetchJsonp2.default)("http://" + domain + "/api/read").then(function (data) { // const blog = data.tumblelog var media_list = data.posts.reduce(parseTumblrPost, []); cb(media_list); }); }; function parseTumblrPost(media_list, post) { var media = void 0, caption = void 0, url = void 0; switch (post.type) { case 'photo': caption = stripHTML(post['photo-caption']); if (post.photos.length) { post.photos.forEach(function (photo) { media = { url: photo['photo-url-1280'], type: "image", token: "", thumbnail: photo['photo-url-500'], description: caption, width: parseInt(photo.width), height: parseInt(photo.height) }; media_list.push(media); }); } else { media = { url: post['photo-url-1280'], type: "image", token: "", thumbnail: post['photo-url-500'], description: caption, width: parseInt(post.width), height: parseInt(post.height) }; media_list.push(media); } break; case 'video': url = post['video-source']; if (url.indexOf("http") !== 0) { break; } if (lookup.youtube.regex.test(url)) { var id = (url.match(/v=([-_a-zA-Z0-9]{11})/i) || url.match(/youtu.be\/([-_a-zA-Z0-9]{11})/i) || url.match(/embed\/([-_a-zA-Z0-9]{11})/i))[1].split('&')[0]; var thumb = "https://i.ytimg.com/vi/" + id + "/hqdefault.jpg"; media = { url: post['video-source'], type: "youtube", token: id, thumbnail: thumb, title: stripHTML(post['video-caption']), width: 640, height: 360 }; media_list.push(media); } break; default: break; } return media_list; } /***/ }), /***/ "./app/client/audio/lib/draw.js": /*!**************************************!*\ !*** ./app/client/audio/lib/draw.js ***! \**************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.spectrum = spectrum; exports.raw_spectrum = raw_spectrum; var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var scratch = document.createElement('canvas'); var scratchCtx = scratch.getContext('2d-lodpi'); var w = 256; var h = 256; function spectrum(spec, x0, y0, ww, hh) { var data = spec.data; var fft_size = spec.fft_size; var half_fft_size = spec.fft_size / 2; var spec_len = data.length; scratch.width = data.length; scratch.height = half_fft_size; var imageData = ctx.createImageData(scratch.width, scratch.height); var pixels = imageData.data; var i = void 0, j = void 0, u = void 0, v = void 0, _r = void 0, _i = void 0, col = void 0, hsl = void 0; for (i = 0; i < spec_len; i++) { col = data[i]; for (j = 0; j < half_fft_size; j++) { u = ((half_fft_size - j) * spec_len + i) * 4; v = j * 2; _r = col[v]; _i = mod(col[v + 1], Math.PI * 2) / (Math.PI * 2); hsl = color.hsl2rgb((_i + 1) / 2, 1.0, 1 - Math.abs(_r / 10)); // red - real part // pixels[u] = _r * 127 + 127 // // green - imag part // pixels[u+1] = _i * 127 + 127 // // blue - magnitude // pixels[u+2] = Math.sqrt(Math.pow(_r, 2) + Math.pow(_i, 2)) * 128 + 127 // pixels[u+3] = 255 pixels[u] = hsl[0]; pixels[u + 1] = hsl[1]; pixels[u + 2] = hsl[2]; pixels[u + 3] = 255; } } scratchCtx.putImageData(imageData, 0, 0); var pcm_length = spec.fft_overlap * spec_len; x0 = x0 * devicePixelRatio || 0; y0 = y0 * devicePixelRatio || Math.floor(h / 4); ww = ww * devicePixelRatio || w; hh = hh * devicePixelRatio || h / 4; var width = Math.round(pcm_length / spec.sr * pixels_per_second); var height = Math.floor(hh); ctx.save(); clear(1, x0, y0, w, height); ctx.drawImage(scratch, x0, y0, width, height); ctx.restore(); } function raw_spectrum(spec, x0, y0, ww, hh, def_min_r, def_min_i) { var data = spec.data; var fft_size = spec.fft_size; var half_fft_size = spec.fft_size / 2; var spec_len = data.length; var _scratch = document.createElement('canvas'); var _scratchCtx = _scratch.getContext('2d-lodpi'); _scratch.width = data.length; _scratch.height = half_fft_size; // console.log("spectrum w/h:", _scratch.width, _scratch.height) var imageData = _scratchCtx.createImageData(_scratch.width, _scratch.height); var pixels = imageData.data; var i = void 0, j = void 0, u = void 0, v = void 0, _r = void 0, _i = void 0, col = void 0, hsl = void 0; // let min_r = Infinity, max_r = -Infinity // let min_i = Infinity, max_i = -Infinity // determined empirically.. // let min_r = -60.4894057005308 // let max_r = 107.23800966675353 // let min_i = -59.4894057005308 // let max_i = 108.23800966675353 var min_r = -def_min_r; var max_r = def_min_r; var min_i = -def_min_i; var max_i = def_min_i; var delta_r = max_r - min_r; var delta_i = max_i - min_i; var mean_r = 0; var mean_i = 0; var sum_mean_r = 0, sum_mean_i = 0; var real = void 0, imag = void 0; for (i = 0; i < spec_len; i++) { col = data[i]; mean_r = 0; mean_i = 0; for (j = 0; j < half_fft_size; j++) { u = (j * spec_len + i) * 4; v = j * 2; real = col[v]; imag = col[v + 1]; mean_r += real; mean_i += imag; _r = _util2.default.clamp((real - min_r) / delta_r * 255, 0, 255); _i = _util2.default.clamp((imag - min_i) / delta_i * 255, 0, 255); // hsl = color.hsl2rgb((_i + 1) / 2, 1.0, 1 - Math.abs(_r / 10)) pixels[u + 0] = _r; pixels[u + 1] = _i; pixels[u + 2] = 127; // hsl[2] pixels[u + 3] = 255; // min_r = Math.min(min_r, col[v]) // max_r = Math.max(max_r, col[v]) // min_i = Math.min(min_i, col[v]+1) // max_i = Math.max(max_i, col[v]+1) } mean_r /= half_fft_size; mean_i /= half_fft_size; sum_mean_r += mean_r; sum_mean_i += mean_i; } sum_mean_r /= spec_len; sum_mean_i /= spec_len; // console.log(sum_mean_r, sum_mean_i) // console.log("r:", min_r, max_r) // console.log("i:", min_i, max_i) _scratchCtx.putImageData(imageData, 0, 0); return { canvas: _scratch, imageData: imageData }; } /***/ }), /***/ "./app/client/audio/lib/index.js": /*!***************************************!*\ !*** ./app/client/audio/lib/index.js ***! \***************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.requestAudioContext = requestAudioContext; var _tone = __webpack_require__(/*! tone */ "./node_modules/tone/build/Tone.js"); var _tone2 = _interopRequireDefault(_tone); var _startAudioContext = __webpack_require__(/*! ./startAudioContext */ "./app/client/audio/lib/startAudioContext.js"); var _startAudioContext2 = _interopRequireDefault(_startAudioContext); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function requestAudioContext(fn) { if (_util.is_mobile) { var container = document.createElement('div'); var button = document.createElement('div'); button.innerHTML = 'Tap to start - please unmute your phone'; Object.assign(container.style, { display: 'block', position: 'absolute', width: '100%', height: '100%', zIndex: '10000', top: '0px', left: '0px', backgroundColor: 'rgba(0, 0, 0, 0.8)' }); Object.assign(button.style, { display: 'block', position: 'absolute', left: '50%', top: '50%', padding: '20px', backgroundColor: '#7F33ED', color: 'white', fontFamily: 'monospace', borderRadius: '3px', transform: 'translate3D(-50%,-50%,0)', textAlign: 'center', lineHeight: '1.5', width: '150px' }); container.appendChild(button); document.body.appendChild(container); _startAudioContext2.default.setContext(_tone2.default.context); _startAudioContext2.default.on(button); _startAudioContext2.default.onStarted(function (_) { container.remove(); fn(); }); } else { fn(); } } /***/ }), /***/ "./app/client/audio/lib/output.js": /*!****************************************!*\ !*** ./app/client/audio/lib/output.js ***! \****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _tone = __webpack_require__(/*! tone */ "./node_modules/tone/build/Tone.js"); var _tone2 = _interopRequireDefault(_tone); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // const compressor = new Tone.Compressor(-30, 3).toMaster() var compressor = new _tone2.default.Compressor(-30, 3).toMaster(); var gain = new _tone2.default.Gain(1).connect(compressor); exports.default = gain; /***/ }), /***/ "./app/client/audio/lib/spectrum.js": /*!******************************************!*\ !*** ./app/client/audio/lib/spectrum.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _tone = __webpack_require__(/*! tone */ "./node_modules/tone/build/Tone.js"); var _tone2 = _interopRequireDefault(_tone); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _signalWindows = __webpack_require__(/*! signal-windows */ "./node_modules/signal-windows/index.js"); var _fft = __webpack_require__(/*! fft.js */ "./node_modules/fft.js/lib/fft.js"); var _fft2 = _interopRequireDefault(_fft); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var fft_size = 512; var fft_overlap = fft_size / 4; var fft = new _fft2.default(fft_size); function toSpectrum(pcm, sr) { sr = sr || 44100; var ham = _signalWindows.windows.construct('ham', fft_size); var pcm_in = new Array(fft_size); var pcm_length = pcm.length; var pcm_q_length = Math.ceil(pcm_length / fft_size) * fft_size; var i = void 0, j = void 0, fft_out = void 0, data = []; for (i = -fft_size; i < pcm_q_length; i += fft_overlap) { for (j = 0; j < fft_size; j++) { pcm_in[j] = pcm[i + j] * ham[j] || 0; } fft_out = fft.createComplexArray(); fft.realTransform(fft_out, pcm_in); fft.completeSpectrum(fft_out); data.push(fft_out); } return { data: data, sr: sr, fft_size: fft_size, fft_overlap: fft_overlap }; } function fromSpectrum(spec) { var data = spec.data; var sr = spec.sr; var fft_size = spec.fft_size; var fft_overlap = spec.fft_overlap; var spec_len = data.length; var ham = _signalWindows.windows.construct('ham', fft_size); var out = fft.createComplexArray(); var pcm_length = fft_overlap * spec_len; var audioBuffer = _tone2.default.context.createBuffer(1, pcm_length, sr); var pcm = audioBuffer.getChannelData(0); var i = void 0, j = void 0, u = void 0, col = void 0; for (i = 0; i < spec_len; i++) { col = data[i]; // for (j = fft_size; j < fft_size << 1; j++) { // col[j] = 0 // } // if (i == 0) console.log(col) fft.inverseTransform(out, col); u = i * fft_overlap; for (j = 0; j < fft_size; j++) { pcm[u + j] += out[j * 2] * ham[j] || 0; } } fadeInOut(pcm, fft_size); // console.log(pcm) return audioBuffer; } function fromImageData(imageData, sr, _r, _i) { var pixels = imageData.data; var w = imageData.width; var h = imageData.height; var data = new Array(w); var x = void 0, y = void 0, u = void 0, v = void 0, v2 = void 0; for (y = 0; y < h; y++) { var col = data[y] = new Float32Array(h * 4); for (x = 0; x < w; x++) { u = (x * w + y) * 4; v = x * 2; col[v] = (pixels[u] / 255 - 0.5) * _r; col[v + 1] = (pixels[u + 1] / 255 - 0.5) * _i; v2 = (h - y + h) * 2; col[v2] = col[v]; col[v2 + 1] = 0; // col[v+1] } col[h * 2] = col[h * 2 + 1] = col[h * 2 - 1] = col[h * 2 - 2] = 0; } var spec = { data: data, sr: sr, fft_size: fft_size, fft_overlap: fft_overlap }; return spec; } function binToHz(spec, i) { return i / spec.fft_size * spec.sr; } function fadeInOut(pcm, fade_size) { var pcm_length = pcm.length; var fade = 0, i = void 0; for (i = 0; i < fade_size; i++) { fade = i / fade_size; fade *= fade; pcm[i] *= fade; pcm[pcm_length - i] *= fade; } } function rotatePhase(spec, theta) { var data = spec.data, fft_size = spec.fft_size; var i = void 0, j = void 0, col = void 0, len = data.length; for (i = 0; i < len; i++) { col = data[i]; for (j = 0; j < fft_size; j++) { col[j * 2 + 1] += theta; } } return spec; } function linearBins(spec, n) { n = n || 1; var bins = [], i = void 0, q_i = void 0; for (q_i = 0; q_i < n; q_i++) { bins[q_i] = []; } var step = Math.floor(spec.fft_size / n); var len_quantize_n = (0, _util.quantize)(spec.fft_size, n); for (i = 0; i < len_quantize_n; i++) { q_i = Math.floor(i / step); bins[q_i] = bins[q_i] || []; bins[q_i].push(i); } // leftover bins get put at end for (; i < spec.fft_size; i++) { bins[q_i].push(i); } return bins; } function logarithmicBins(spec) { var bins = [], i = void 0, j = void 0, q_i = void 0; var binCount = Math.log2(spec.fft_size) - 1; for (i = 0, q_i = 0, j = 0; i < binCount; i++) { j += 1 << i; bins[i] = []; for (; q_i < j; q_i++) { bins[i].push(q_i); } } return bins; } function concatBins(bins) { return bins.reduce(function (acc, cv) { return acc.concat(cv); }, []); } function reverseBins(bins) { return bins.map(function (bin) { return bin.reverse(); }); } function minBins(bins) { return bins.map(function (bin) { var b = bin[0]; return bin.map(function () { return b; }); }); } function maxBins(bins) { return bins.map(function (bin) { var b = bin[bin.length - 1]; return bin.map(function () { return b; }); }); } function rotateSpectrum(spec, n) { var fft_size = spec.fft_size; if (n && n < 1) { n -= 0.5; n *= fft_size; } n = Math.floor(n); var order = new Array(fft_size), i = void 0; for (i = 0; i < fft_size; i++) { order[i] = (0, _util.mod)(i + n, fft_size / 2); } return reorderBins(spec, order); } function cloneSpectrum(spec) { var data = spec.data, fft_size = spec.fft_size, sr = spec.sr, fft_overlap = spec.fft_overlap; var spec_len = data.length; var new_data = new Array(spec_len); var i = void 0; for (i = 0; i < spec_len; i++) { new_data[i] = data[i].concat(); new_data[i][2] = 0; } return { data: new_data, fft_size: fft_size, sr: sr, fft_overlap: fft_overlap }; } function reverseSpectrum(spec) { var new_spec = cloneSpectrum(spec); new_spec.data = new_spec.data.reverse(); return new_spec; } function shuffleSpectrum(spec) { var fft_size = spec.fft_size; var order = new Array(fft_size), i = void 0; for (i = 0; i < fft_size; i++) { order[i] = i; } (0, _util.shuffle)(order); return reorderBins(spec, order); } function invertSpectrum(spec) { var fft_size = spec.fft_size; var order = new Array(fft_size), i = void 0; for (i = 0; i < fft_size; i++) { order[i] = fft_size - i - 1; } return reorderBins(spec, order); } function reorderBins(spec, order) { var new_spec = cloneSpectrum(spec); var data = spec.data, sr = spec.sr, fft_size = spec.fft_size, fft_overlap = spec.fft_overlap; var spec_len = data.length; var new_data = new_spec.data; var i = void 0, j = void 0, col = void 0, new_col = void 0; for (j = order.length; j < fft_size; j++) { order[j] = j; } for (i = 0; i < spec_len; i++) { col = data[i]; new_col = new_data[i] = data[i].concat(); col[0] = 0; col[2] = 0; col[4] = 0; for (j = 0; j < fft_size / 2; j++) { new_col[j * 2] = col[order[j] * 2]; new_col[j * 2 + 1] = col[order[j] * 2 + 1]; } for (; j < fft_size; j++) { new_col[j * 2] = 0; new_col[j * 2 + 1] = 0; } } return { data: new_data, sr: sr, fft_size: fft_size, fft_overlap: fft_overlap }; } exports.default = { fft_size: fft_size, fft_overlap: fft_overlap, toSpectrum: toSpectrum, fromSpectrum: fromSpectrum, fromImageData: fromImageData, binToHz: binToHz, fadeInOut: fadeInOut, cloneSpectrum: cloneSpectrum, reverseSpectrum: reverseSpectrum, shuffleSpectrum: shuffleSpectrum, invertSpectrum: invertSpectrum, rotateSpectrum: rotateSpectrum, reorderBins: reorderBins, linearBins: linearBins, logarithmicBins: logarithmicBins, concatBins: concatBins, reverseBins: reverseBins, minBins: minBins, maxBins: maxBins, rotatePhase: rotatePhase }; /***/ }), /***/ "./app/client/audio/lib/startAudioContext.js": /*!***************************************************!*\ !*** ./app/client/audio/lib/startAudioContext.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; var _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; }; /** * StartAudioContext.js * @author Yotam Mann * @license http://opensource.org/licenses/MIT MIT License * @copyright 2016 Yotam Mann */ (function (root, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} })(undefined, function () { /** * The StartAudioContext object */ var StartAudioContext = { /** * The audio context passed in by the user * @type {AudioContext} */ context: null, /** * The TapListeners bound to the elements * @type {Array} * @private */ _tapListeners: [], /** * Callbacks to invoke when the audio context is started * @type {Array} * @private */ _onStarted: [] }; /** * Set the context * @param {AudioContext} ctx * @returns {StartAudioContext} */ StartAudioContext.setContext = function (ctx) { StartAudioContext.context = ctx; return StartAudioContext; }; /** * Add a tap listener to the audio context * @param {Array|Element|String|jQuery} element * @returns {StartAudioContext} */ StartAudioContext.on = function (element) { if (Array.isArray(element) || NodeList && element instanceof NodeList) { for (var i = 0; i < element.length; i++) { StartAudioContext.on(element[i]); } } else if (typeof element === "string") { StartAudioContext.on(document.querySelectorAll(element)); } else if (element.jquery && typeof element.toArray === "function") { StartAudioContext.on(element.toArray()); } else if (Element && element instanceof Element) { //if it's an element, create a TapListener var tap = new TapListener(element, onTap); StartAudioContext._tapListeners.push(tap); } return StartAudioContext; }; /** * Bind a callback to when the audio context is started. * @param {Function} cb * @return {StartAudioContext} */ StartAudioContext.onStarted = function (cb) { //if it's already started, invoke the callback if (StartAudioContext.isStarted()) { cb(); } else { StartAudioContext._onStarted.push(cb); } return StartAudioContext; }; /** * returns true if the context is started * @return {Boolean} */ StartAudioContext.isStarted = function () { return StartAudioContext.context !== null && StartAudioContext.context.state === "running"; }; /** * @class Listens for non-dragging tap ends on the given element * @param {Element} element * @internal */ var TapListener = function TapListener(element) { this._dragged = false; this._element = element; this._bindedMove = this._moved.bind(this); this._bindedEnd = this._ended.bind(this); element.addEventListener("touchmove", this._bindedMove); element.addEventListener("touchend", this._bindedEnd); element.addEventListener("mouseup", this._bindedEnd); }; /** * drag move event */ TapListener.prototype._moved = function (e) { this._dragged = true; }; /** * tap ended listener */ TapListener.prototype._ended = function (e) { if (!this._dragged) { onTap(); } this._dragged = false; }; /** * remove all the bound events */ TapListener.prototype.dispose = function () { this._element.removeEventListener("touchmove", this._bindedMove); this._element.removeEventListener("touchend", this._bindedEnd); this._element.removeEventListener("mouseup", this._bindedEnd); this._bindedMove = null; this._bindedEnd = null; this._element = null; }; /** * Invoked the first time of the elements is tapped. * Creates a silent oscillator when a non-dragging touchend * event has been triggered. */ function onTap() { //start the audio context with a silent oscillator if (StartAudioContext.context && !StartAudioContext.isStarted()) { var osc = StartAudioContext.context.createOscillator(); var silent = StartAudioContext.context.createGain(); silent.gain.value = 0; osc.connect(silent); silent.connect(StartAudioContext.context.destination); var now = StartAudioContext.context.currentTime; osc.start(now); osc.stop(now + 0.5); } //dispose all the tap listeners if (StartAudioContext._tapListeners) { for (var i = 0; i < StartAudioContext._tapListeners.length; i++) { StartAudioContext._tapListeners[i].dispose(); } StartAudioContext._tapListeners = null; } //the onstarted callbacks if (StartAudioContext._onStarted) { for (var j = 0; j < StartAudioContext._onStarted.length; j++) { StartAudioContext._onStarted[j](); } StartAudioContext._onStarted = null; } } return StartAudioContext; }); /***/ }), /***/ "./app/client/audio/pix2wav.js": /*!*************************************!*\ !*** ./app/client/audio/pix2wav.js ***! \*************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.play = play; var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _tone = __webpack_require__(/*! tone */ "./node_modules/tone/build/Tone.js"); var _tone2 = _interopRequireDefault(_tone); var _draw = __webpack_require__(/*! ./lib/draw */ "./app/client/audio/lib/draw.js"); var draw = _interopRequireWildcard(_draw); var _output = __webpack_require__(/*! ./lib/output */ "./app/client/audio/lib/output.js"); var _output2 = _interopRequireDefault(_output); var _spectrum = __webpack_require__(/*! ./lib/spectrum */ "./app/client/audio/lib/spectrum.js"); var _spectrum2 = _interopRequireDefault(_spectrum); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _r = 8; var _i = 8; function play(frame) { // const { canvas, imageData } = draw.raw_spectrum(fft, 0, 256, 0, 256, 1, 1) // console.log(_r, _i) // const { canvas, imageData } = draw.raw_spectrum(player.fft, 0, 256, 0, 256, _r, _i) var new_fft = _spectrum2.default.fromImageData(frame.imageData, 44100, _r, _i); // gallery.innerHTML = '' // console.log(player.fft.data, new_fft.data) var buf = _spectrum2.default.fromSpectrum(new_fft); var _p = new _tone2.default.Player(buf); _p.connect(_output2.default); _p.start(_tone2.default.now()); // redraw(new_fft) } // function redraw(new_fft){ // const { canvas, imageData } = draw.raw_spectrum(new_fft, 0, 256, 0, 256, _r, _i) // } /***/ }), /***/ "./app/client/audio/wav2pix.js": /*!*************************************!*\ !*** ./app/client/audio/wav2pix.js ***! \*************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildZip = exports.renderFrames = exports.loadPCM = exports.loadBuffer = exports.spectrum = exports.FRAME_STEP = exports.FRAME_LENGTH = undefined; var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _tone = __webpack_require__(/*! tone */ "./node_modules/tone/build/Tone.js"); var _tone2 = _interopRequireDefault(_tone); var _jszip = __webpack_require__(/*! jszip */ "./node_modules/jszip/lib/index.js"); var _jszip2 = _interopRequireDefault(_jszip); var _sprintfJs = __webpack_require__(/*! sprintf-js */ "./node_modules/sprintf-js/src/sprintf.js"); var _draw = __webpack_require__(/*! ./lib/draw */ "./app/client/audio/lib/draw.js"); var draw = _interopRequireWildcard(_draw); var _output = __webpack_require__(/*! ./lib/output */ "./app/client/audio/lib/output.js"); var _output2 = _interopRequireDefault(_output); var _spectrum = __webpack_require__(/*! ./lib/spectrum */ "./app/client/audio/lib/spectrum.js"); var _spectrum2 = _interopRequireDefault(_spectrum); var _lib = __webpack_require__(/*! ./lib */ "./app/client/audio/lib/index.js"); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var FRAME_LENGTH = exports.FRAME_LENGTH = 126 * 255; var FRAME_STEP = exports.FRAME_STEP = Math.round(FRAME_LENGTH / 4); var _r = 8; var _i = 8; exports.spectrum = _spectrum2.default; // requestAudioContext(() => {}) var loadBuffer = exports.loadBuffer = function loadBuffer(file) { return new Promise(function (resolve, reject) { var url = URL.createObjectURL(file); var buffer = new _tone2.default.Buffer(url, loadBuffer, function (err) { console.error('err', err); reject(err); }); function loadBuffer() { URL.revokeObjectURL(url); resolve(buffer); } }); }; var loadPCM = exports.loadPCM = function loadPCM(file) { return new Promise(function (resolve, reject) { // if we've already fetched this file... if (file.pcm) { return resolve(file); } loadBuffer(file).then(function (buffer) { var pcm = buffer._buffer.getChannelData(0); var sr = buffer._buffer.sampleRate; if (!pcm) return reject(); console.log(pcm.length, sr); resolve({ file: file, buffer: buffer, pcm: pcm, sr: sr }); }); }); }; var renderFrames = exports.renderFrames = function renderFrames(file, _ref) { var _ref$frame_step = _ref.frame_step, frame_step = _ref$frame_step === undefined ? FRAME_STEP : _ref$frame_step, _ref$frame_start = _ref.frame_start, frame_start = _ref$frame_start === undefined ? 0 : _ref$frame_start, _ref$max = _ref.max, max = _ref$max === undefined ? 12 : _ref$max; return function (dispatch) { return new Promise(function (resolve, reject) { loadPCM(file).then(function (pcmProps) { var file = pcmProps.file, buffer = pcmProps.buffer, pcm = pcmProps.pcm, sr = pcmProps.sr; dispatch({ type: _types2.default.wav2pix.load }); var frames = []; var count = 0; var _len = pcm.length - FRAME_LENGTH; var offset = Math.round(_len * frame_start); for (; offset < _len && count < max; offset += frame_step, count += 1) { frames.push(render(pcm.slice(offset, offset + FRAME_LENGTH), sr, count)); } dispatch({ type: _types2.default.wav2pix.finish, message: 'Rendered ' + count + ' images' }); resolve({ pcm: pcmProps, frames: frames }); }); }); }; }; var buildZip = exports.buildZip = function buildZip(name, file, _ref2) { var _ref2$frame_step = _ref2.frame_step, frame_step = _ref2$frame_step === undefined ? FRAME_STEP : _ref2$frame_step, _ref2$frame_start = _ref2.frame_start, frame_start = _ref2$frame_start === undefined ? 0 : _ref2$frame_start, _ref2$max = _ref2.max, max = _ref2$max === undefined ? 10000 : _ref2$max; return function (dispatch) { return new Promise(function (resolve, reject) { loadPCM(file).then(function (_ref3) { var buffer = _ref3.buffer, pcm = _ref3.pcm, sr = _ref3.sr; dispatch({ type: _types2.default.wav2pix.load }); var zip = new _jszip2.default(); var zip_folder = zip.folder("wav2pix_" + name); var steps = (pcm.length - FRAME_LENGTH) / frame_step; console.log(steps); var count = 0; var _len = pcm.length - FRAME_LENGTH; var offset = Math.round(_len * frame_start); for (; offset < _len && count < max; offset += frame_step, count += 1) { if (count % 10 === 0) { dispatch({ type: _types2.default.wav2pix.progress, progress: { i: count / max * 6, n: 6 } }); } render(pcm.slice(offset, offset + FRAME_LENGTH), sr, count, zip_folder); } // dispatch event dispatch({ type: _types2.default.wav2pix.finish, message: 'Rendered ' + count + ' images' }); zip.generateAsync({ type: "blob" }).then(function (content) { dispatch({ type: _types2.default.wav2pix.zip, size: content.size }); // FileSaver.saveAs(content, "wav2pix_" + name + ".zip") resolve({ zip: content, filename: "wav2pix_" + name + ".zip", count: count }); }); }); }); }; }; function render(pcm, sr, count, zip) { var fft = _spectrum2.default.toSpectrum(pcm, sr); // console.log('render', fft) // const pcm_rev = pcm.slice().reverse() // const spec_rev = spectrum.toSpectrum(pcm_rev, spec.sr) var _draw$raw_spectrum = draw.raw_spectrum(fft, 0, 256, 0, 256, _r, _i), canvas = _draw$raw_spectrum.canvas, imageData = _draw$raw_spectrum.imageData; if (zip) { var name = (0, _sprintfJs.sprintf)('frame_%05d.png', count); var dataURL = canvas.toDataURL("image/png"); zip.file(name, dataURL.split(',')[1], { base64: true }); } return { fft: fft, canvas: canvas, imageData: imageData }; } /***/ }), /***/ "./app/client/common/audioPlayer/audioPlayer.actions.js": /*!**************************************************************!*\ !*** ./app/client/common/audioPlayer/audioPlayer.actions.js ***! \**************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.enqueue = exports.resume = exports.pause = exports.play = undefined; var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var play = exports.play = function play(file) { return { type: _types2.default.audioPlayer.play, file: file }; }; var pause = exports.pause = function pause() { return { type: _types2.default.audioPlayer.pause }; }; var resume = exports.resume = function resume() { return { type: _types2.default.audioPlayer.resume }; }; var enqueue = exports.enqueue = function enqueue(file) { return { type: _types2.default.audioPlayer.enqueue, file: file }; }; /***/ }), /***/ "./app/client/common/audioPlayer/audioPlayer.component.js": /*!****************************************************************!*\ !*** ./app/client/common/audioPlayer/audioPlayer.component.js ***! \****************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _audioPlayer = __webpack_require__(/*! ./audioPlayer.actions */ "./app/client/common/audioPlayer/audioPlayer.actions.js"); var audioPlayerActions = _interopRequireWildcard(_audioPlayer); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var AudioPlayer = function (_Component) { _inherits(AudioPlayer, _Component); function AudioPlayer(props) { _classCallCheck(this, AudioPlayer); var _this = _possibleConstructorReturn(this, (AudioPlayer.__proto__ || Object.getPrototypeOf(AudioPlayer)).call(this, props)); _this.handleClick = _this.handleClick.bind(_this); return _this; } _createClass(AudioPlayer, [{ key: 'handleClick', value: function handleClick(e) { var _props = this.props, audioPlayer = _props.audioPlayer, actions = _props.actions; if (audioPlayer.playing) { actions.pause(); } else { actions.resume(); } } }, { key: 'render', value: function render() { var audioPlayer = this.props.audioPlayer; return (0, _preact.h)( 'div', { className: 'audioPlayer' }, (0, _preact.h)( 'span', null, this.props.title ), (0, _preact.h)( 'button', { onClick: this.handleClick }, audioPlayer.playing ? '▶' : '~' ) ); } }]); return AudioPlayer; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { audioPlayer: state.audioPlayer }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(audioPlayerActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(AudioPlayer); /***/ }), /***/ "./app/client/common/audioPlayer/audioPlayer.reducer.js": /*!**************************************************************!*\ !*** ./app/client/common/audioPlayer/audioPlayer.reducer.js ***! \**************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var audioPlayerInitialState = { loading: false, error: null, status: '', current: null, index: -1, playlist: [] }; var audio = document.createElement('audio'); var audioPlayerReducer = function audioPlayerReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : audioPlayerInitialState; var action = arguments[1]; switch (action.type) { case _types2.default.audioPlayer.play: if (!action.file.url) { return state; } audio.src = action.file.url; audio.play(); return _extends({}, state, { playing: true, current: action.file }); case _types2.default.audioPlayer.pause: audio.pause(); return _extends({}, state, { playing: false }); case _types2.default.audioPlayer.resume: audio.play(); return _extends({}, state, { playing: true }); default: return state; } }; exports.default = audioPlayerReducer; /***/ }), /***/ "./app/client/common/button.component.js": /*!***********************************************!*\ !*** ./app/client/common/button.component.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _live = __webpack_require__(/*! ../live/live.actions */ "./app/client/live/live.actions.js"); var liveActions = _interopRequireWildcard(_live); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Button = function (_Component) { _inherits(Button, _Component); function Button(props) { _classCallCheck(this, Button); var _this = _possibleConstructorReturn(this, (Button.__proto__ || Object.getPrototypeOf(Button)).call(this, props)); _this.handleClick = _this.handleClick.bind(_this); return _this; } _createClass(Button, [{ key: 'handleClick', value: function handleClick(e) { this.props.onClick && this.props.onClick(); } }, { key: 'render', value: function render() { return (0, _preact.h)( 'div', { className: 'button param' }, (0, _preact.h)( 'label', null, (0, _preact.h)( 'span', null, this.props.title ), (0, _preact.h)( 'button', { onClick: this.handleClick }, this.props.children ) ) ); } }]); return Button; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return {}; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return {}; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Button); /***/ }), /***/ "./app/client/common/currentTask.component.js": /*!****************************************************!*\ !*** ./app/client/common/currentTask.component.js ***! \****************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // import { Loading, CurrentTask, FileList, FileRow } from '../../../common' function CurrentTask(_ref) { var cpu = _ref.cpu, gpu = _ref.gpu, processor = _ref.processor; var processor_name = void 0; if (processor) { processor_name = processor === 'cpu' ? 'cpu' : 'gpu'; } else if (gpu.status !== 'IDLE') { processor_name = 'gpu'; } else if (cpu.status !== 'IDLE') { processor_name = 'cpu'; } var p = processor_name === 'cpu' ? cpu : gpu; if (!p) return (0, _preact.h)('div', null); if (p.status === 'IDLE') { return (0, _preact.h)( 'div', null, processor_name, ' idle' ); } var last_message = p.last_message, pid = p.pid, task = p.task; var activity = task.activity, epoch = task.epoch, epochs = task.epochs, dataset = task.dataset, module = task.module; return (0, _preact.h)( 'div', null, '#', pid, ': ', (0, _preact.h)( 'b', null, module, ' ', activity ), ' ', (0, _preact.h)( 'i', null, dataset ), ' ', epochs, ' epoch', _util2.default.courtesy_s(epochs), ' (currently #', epoch, ')', (0, _preact.h)('br', null), (0, _preact.h)('br', null), (0, _preact.h)( 'div', { 'class': 'quiet' }, last_message ) ); } var mapStateToProps = function mapStateToProps(state) { return state.system.runner; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { // actions: bindActionCreators(samplernnActions, dispatch), // remote: bindActionCreators(samplernnTasks, dispatch), // audioPlayer: bindActionCreators(audioPlayerActions, dispatch), }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(CurrentTask); /***/ }), /***/ "./app/client/common/fileList.component.js": /*!*************************************************!*\ !*** ./app/client/common/fileList.component.js ***! \*************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FileRow = exports.FileList = undefined; var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); var _moment2 = _interopRequireDefault(_moment); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var fieldSet = _util2.default.fieldSet(new Set(['name', 'date', 'size'])); var FileList = exports.FileList = function FileList(props) { var files = props.files, fields = props.fields, sort = props.sort, title = props.title, linkFiles = props.linkFiles, onClick = props.onClick, onDelete = props.onDelete, _props$orderBy = props.orderBy, orderBy = _props$orderBy === undefined ? 'name asc' : _props$orderBy, _props$className = props.className, className = _props$className === undefined ? '' : _props$className, _props$fileListClassN = props.fileListClassName, fileListClassName = _props$fileListClassN === undefined ? 'filelist' : _props$fileListClassN, _props$rowClassName = props.rowClassName, rowClassName = _props$rowClassName === undefined ? 'row file' : _props$rowClassName; var _util$sort$orderByFn = _util2.default.sort.orderByFn(orderBy), mapFn = _util$sort$orderByFn.mapFn, sortFn = _util$sort$orderByFn.sortFn; var fileList = (files || []).filter(function (f) { return !!f; }).map(mapFn).sort(sortFn).map(function (pair) { return (0, _preact.h)(FileRow, { file: pair[1], fields: fieldSet(fields), className: rowClassName, linkFiles: linkFiles, onDelete: onDelete, onClick: onClick }); }); if (!fileList || !fileList.length) { return (0, _preact.h)( 'div', { className: 'rows ' + className }, (0, _preact.h)( 'div', { 'class': 'row heading' }, (0, _preact.h)( 'h4', { 'class': 'noFiles' }, 'No files' ) ) ); } // console.log(files) return (0, _preact.h)( 'div', { className: 'rows ' + className }, title && (0, _preact.h)( 'div', { 'class': 'row heading' }, (0, _preact.h)( 'h3', null, title ), '}' ), (0, _preact.h)( 'div', { className: 'rows ' + fileListClassName }, fileList ) ); }; var FileRow = exports.FileRow = function FileRow(props) { var file = props.file, linkFiles = props.linkFiles, onDelete = props.onDelete, _onClick = props.onClick, _props$className2 = props.className, className = _props$className2 === undefined ? 'row file' : _props$className2, _props$username = props.username, username = _props$username === undefined ? '' : _props$username; var fields = fieldSet(props.fields); var size = _util2.default.hush_size(file.size); var date = file.date || file.created_at; var epoch = file.epoch || file.epochs || 0; var name = void 0; var key = void 0; if (file.name) { name = file.name; key = name; } else if (file.url) { if (file.opt && file.opt.type) { name = file.opt.type + ': ' + file.opt.title; key = file.opt.token; } else { name = file.url.replace(/^https?:\/\//, ''); key = name; } } return (0, _preact.h)( 'div', { 'class': className, key: key }, fields.has('name') && (0, _preact.h)( 'div', { className: 'filename', title: file.name || file.url }, file.persisted === false ? (0, _preact.h)( 'span', { className: 'unpersisted' }, name ) : linkFiles && file.url ? (0, _preact.h)( 'a', { target: '_blank', onClick: function onClick(e) { if (!(e.metaKey || e.ctrlKey || e.altKey)) { e.preventDefault();_onClick && _onClick(file, e); } }, href: file.url }, name ) : (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick(e) { return _onClick && _onClick(file, e); } }, name ) ), fields.has('age') && (0, _preact.h)( 'div', { className: "age " + _util2.default.carbon_date(date) }, _util2.default.get_age(date) ), fields.has('username') && (0, _preact.h)( 'div', { className: "username" }, username ), fields.has('epoch') && (0, _preact.h)( 'div', { className: "epoch " + _util2.default.hush_null(epoch)[0] }, epoch > 0 ? 'ep. ' + epoch : '' ), fields.has('date') && (0, _preact.h)( 'div', { className: "date " + _util2.default.carbon_date(date) }, (0, _moment2.default)(date).format("YYYY-MM-DD") ), fields.has('datetime') && (0, _preact.h)( 'div', { className: "datetime " + _util2.default.carbon_date(date) }, (0, _moment2.default)(date).format("YYYY-MM-DD h:mm a") ), fields.has('size') && (0, _preact.h)( 'div', { className: "size " + size[0] }, size[1] ), (fields.has('activity') || fields.has('module')) && (0, _preact.h)( 'div', { className: 'activity' }, fields.has('activity') && file.activity, fields.has('module') && file.module ), fields.has('delete') && onDelete && file.id && (0, _preact.h)( 'div', { className: 'destroy', onClick: function onClick(e) { return onDelete(file); } }, 'x' ), props.options && props.options(file) ); }; /***/ }), /***/ "./app/client/common/fileUpload.component.js": /*!***************************************************!*\ !*** ./app/client/common/fileUpload.component.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var FileUpload = function (_Component) { _inherits(FileUpload, _Component); function FileUpload(props) { _classCallCheck(this, FileUpload); var _this = _possibleConstructorReturn(this, (FileUpload.__proto__ || Object.getPrototypeOf(FileUpload)).call(this, props)); _this.handleChange = _this.handleChange.bind(_this); return _this; } _createClass(FileUpload, [{ key: 'handleChange', value: function handleChange(e) { this.props.onChange && this.props.onChange(); e.stopPropagation(); e.preventDefault(); this.setState({ thumbnails: [], images: [] }); var files = e.dataTransfer ? e.dataTransfer.files : e.target.files; var i = void 0, f = void 0; for (i = 0, f; i < files.length; i++) { f = files[i]; if (!f) continue; break; // if (!f.type.match(this.props.mime)) continue } this.props.onUpload && this.props.onUpload(f); } }, { key: 'render', value: function render() { return (0, _preact.h)( 'div', { className: 'fileUpload param' }, (0, _preact.h)( 'label', null, (0, _preact.h)( 'span', null, this.props.title ), (0, _preact.h)('input', { type: 'file', accept: this.props.accept || '*/*', multiple: this.props.multiple, onChange: this.handleChange }), (0, _preact.h)( 'button', null, this.props.label || 'Choose file...' ) ) ); } }]); return FileUpload; }(_preact.Component); exports.default = FileUpload; /***/ }), /***/ "./app/client/common/folderList.component.js": /*!***************************************************!*\ !*** ./app/client/common/folderList.component.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); exports.default = FolderList; var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _group = __webpack_require__(/*! ./group.component */ "./app/client/common/group.component.js"); var _group2 = _interopRequireDefault(_group); var _param = __webpack_require__(/*! ./param.component */ "./app/client/common/param.component.js"); var _param2 = _interopRequireDefault(_param); var _loading = __webpack_require__(/*! ./loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function FolderList(_ref) { var db = _ref.db, path = _ref.path, emptyText = _ref.emptyText; if (!db) return null; if (db.loading || !db.data) { return (0, _preact.h)( 'div', { 'class': 'col folderList' }, (0, _preact.h)(_loading2.default, { progress: db.progress }) ); } else if (!db.data.folders.length && emptyText) { return (0, _preact.h)( 'div', { 'class': 'col folderList' }, emptyText ); } console.log(db.data.folders); var folders = db.data.folders.map(function (raw_folder) { var folder = db.data.folderLookup[raw_folder.id]; var fileCount = folder.files ? folder.files.length : 0; var _util$hush_null = _util2.default.hush_null(fileCount), _util$hush_null2 = _slicedToArray(_util$hush_null, 2), className = _util$hush_null2[0], size = _util$hush_null2[1]; return (0, _preact.h)( _param2.default, { title: (0, _preact.h)( _reactRouterDom.Link, { to: path + folder.id + '/' }, folder.name ) }, (0, _preact.h)( 'span', { className: className }, fileCount, ' file', _util2.default.courtesy_s(fileCount) ) ); }); return (0, _preact.h)( 'div', { 'class': 'col folderList' }, (0, _preact.h)( _group2.default, { title: 'Projects' }, folders ) ); } /***/ }), /***/ "./app/client/common/gallery.component.js": /*!************************************************!*\ !*** ./app/client/common/gallery.component.js ***! \************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Gallery = function (_Component) { _inherits(Gallery, _Component); function Gallery(props) { _classCallCheck(this, Gallery); return _possibleConstructorReturn(this, (Gallery.__proto__ || Object.getPrototypeOf(Gallery)).call(this)); } _createClass(Gallery, [{ key: 'render', value: function render() { var _props = this.props, title = _props.title, images = _props.images; var imageList = images.map(function (image) { return (0, _preact.h)( 'div', null, (0, _preact.h)('img', { src: image.url }) ); }); return (0, _preact.h)( 'div', { 'class': 'gallery' }, imageList ); } }]); return Gallery; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return {}; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { // actions: bindActionCreators(liveActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Gallery); /***/ }), /***/ "./app/client/common/group.component.js": /*!**********************************************!*\ !*** ./app/client/common/group.component.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Group; var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); function Group(props) { return (0, _preact.h)( 'div', { className: 'group' }, this.props.title && (0, _preact.h)( 'h3', null, this.props.title ), this.props.children ); } /***/ }), /***/ "./app/client/common/header.component.js": /*!***********************************************!*\ !*** ./app/client/common/header.component.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _system = __webpack_require__(/*! ../system/system.actions */ "./app/client/system/system.actions.js"); var systemActions = _interopRequireWildcard(_system); var _modules = __webpack_require__(/*! ../modules */ "./app/client/modules/index.js"); var _modules2 = _interopRequireDefault(_modules); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function NavLink(props) { if (!props.to) { return (0, _preact.h)( 'span', null, props.children ); } var children = props.to === props.location.pathname ? (0, _preact.h)( 'b', null, props.children ) : props.children; return (0, _preact.h)( 'span', null, (0, _preact.h)( _reactRouterDom.Link, { to: props.to }, children ) ); } function Header(props) { var site = props.site, app = props.app, fps = props.fps, playing = props.playing, actions = props.actions, location = props.location, history = props.history; var tool_list = Object.keys(_modules2.default).map(function (name, i) { var label = name.replace(/_/, " "); return (0, _preact.h)( 'option', { value: name, key: i }, label ); }); var tool = _modules2.default[app.tool]; var links = tool.links().map(function (link, i) { return (0, _preact.h)( NavLink, { key: i, location: location, to: link.url }, link.name ); }); return (0, _preact.h)( 'header', null, (0, _preact.h)( 'span', null, (0, _preact.h)( 'b', null, site.name, ' cortex' ) ), (0, _preact.h)( 'span', null, (0, _preact.h)( 'select', { onChange: function onChange(e) { var path = window.location.pathname.split("/"); path.shift(); console.log(path); if (path[0] in _modules2.default && path[1]) { history.push('/' + e.target.value + '/' + path[1] + '/'); } actions.changeTool(e.target.value, true); }, value: app.tool }, tool_list ) ), (0, _preact.h)( NavLink, { location: location, to: '/system' }, 'system' ), (0, _preact.h)( NavLink, { location: location, to: '/dashboard' }, 'dashboard' ), (0, _preact.h)( 'span', null, links ), playing && (0, _preact.h)( 'span', null, fps, ' fps' ) ); } var mapStateToProps = function mapStateToProps(state) { return { site: state.system.site, app: state.system.app, fps: state.live.fps, playing: state.live.playing }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(systemActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Header); /***/ }), /***/ "./app/client/common/index.js": /*!************************************!*\ !*** ./app/client/common/index.js ***! \************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CurrentTask = exports.Button = exports.Select = exports.Slider = exports.TextInput = exports.Param = exports.ParamGroup = exports.Group = exports.Player = exports.Gallery = exports.FileUpload = exports.FileRow = exports.FileList = exports.FolderList = exports.Header = exports.Progress = exports.Loading = exports.Views = undefined; var _button = __webpack_require__(/*! ./button.component */ "./app/client/common/button.component.js"); var _button2 = _interopRequireDefault(_button); var _currentTask = __webpack_require__(/*! ./currentTask.component */ "./app/client/common/currentTask.component.js"); var _currentTask2 = _interopRequireDefault(_currentTask); var _fileList = __webpack_require__(/*! ./fileList.component */ "./app/client/common/fileList.component.js"); var _fileUpload = __webpack_require__(/*! ./fileUpload.component */ "./app/client/common/fileUpload.component.js"); var _fileUpload2 = _interopRequireDefault(_fileUpload); var _folderList = __webpack_require__(/*! ./folderList.component */ "./app/client/common/folderList.component.js"); var _folderList2 = _interopRequireDefault(_folderList); var _gallery = __webpack_require__(/*! ./gallery.component */ "./app/client/common/gallery.component.js"); var _gallery2 = _interopRequireDefault(_gallery); var _group = __webpack_require__(/*! ./group.component */ "./app/client/common/group.component.js"); var _group2 = _interopRequireDefault(_group); var _header = __webpack_require__(/*! ./header.component */ "./app/client/common/header.component.js"); var _header2 = _interopRequireDefault(_header); var _loading = __webpack_require__(/*! ./loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); var _param = __webpack_require__(/*! ./param.component */ "./app/client/common/param.component.js"); var _param2 = _interopRequireDefault(_param); var _paramGroup = __webpack_require__(/*! ./paramGroup.component */ "./app/client/common/paramGroup.component.js"); var _paramGroup2 = _interopRequireDefault(_paramGroup); var _player = __webpack_require__(/*! ./player.component */ "./app/client/common/player.component.js"); var _player2 = _interopRequireDefault(_player); var _progress = __webpack_require__(/*! ./progress.component */ "./app/client/common/progress.component.js"); var _progress2 = _interopRequireDefault(_progress); var _select = __webpack_require__(/*! ./select.component */ "./app/client/common/select.component.js"); var _select2 = _interopRequireDefault(_select); var _slider = __webpack_require__(/*! ./slider.component */ "./app/client/common/slider.component.js"); var _slider2 = _interopRequireDefault(_slider); var _textInput = __webpack_require__(/*! ./textInput.component */ "./app/client/common/textInput.component.js"); var _textInput2 = _interopRequireDefault(_textInput); var _views = __webpack_require__(/*! ./views */ "./app/client/common/views/index.js"); var Views = _interopRequireWildcard(_views); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.Views = Views; exports.Loading = _loading2.default; exports.Progress = _progress2.default; exports.Header = _header2.default; exports.FolderList = _folderList2.default; exports.FileList = _fileList.FileList; exports.FileRow = _fileList.FileRow; exports.FileUpload = _fileUpload2.default; exports.Gallery = _gallery2.default; exports.Player = _player2.default; exports.Group = _group2.default; exports.ParamGroup = _paramGroup2.default; exports.Param = _param2.default; exports.TextInput = _textInput2.default; exports.Slider = _slider2.default; exports.Select = _select2.default; exports.Button = _button2.default; exports.CurrentTask = _currentTask2.default; /***/ }), /***/ "./app/client/common/loading.component.js": /*!************************************************!*\ !*** ./app/client/common/loading.component.js ***! \************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Loading; var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _progress = __webpack_require__(/*! ./progress.component */ "./app/client/common/progress.component.js"); var _progress2 = _interopRequireDefault(_progress); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function Loading(_ref) { var progress = _ref.progress; return (0, _preact.h)( 'div', { className: 'loading' }, 'Loading', (0, _preact.h)('br', null), progress && (0, _preact.h)(_progress2.default, { progress: progress }) ); } /***/ }), /***/ "./app/client/common/param.component.js": /*!**********************************************!*\ !*** ./app/client/common/param.component.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Param = function (_Component) { _inherits(Param, _Component); function Param(props) { _classCallCheck(this, Param); return _possibleConstructorReturn(this, (Param.__proto__ || Object.getPrototypeOf(Param)).call(this, props)); } _createClass(Param, [{ key: 'render', value: function render() { return (0, _preact.h)( 'div', { className: 'button param' }, (0, _preact.h)( 'span', null, this.props.title ), (0, _preact.h)( 'span', null, this.props.children ) ); } }]); return Param; }(_preact.Component); exports.default = Param; /***/ }), /***/ "./app/client/common/paramGroup.component.js": /*!***************************************************!*\ !*** ./app/client/common/paramGroup.component.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _live = __webpack_require__(/*! ../live/live.actions */ "./app/client/live/live.actions.js"); var liveActions = _interopRequireWildcard(_live); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ParamGroup = function (_Component) { _inherits(ParamGroup, _Component); function ParamGroup(props) { _classCallCheck(this, ParamGroup); var _this = _possibleConstructorReturn(this, (ParamGroup.__proto__ || Object.getPrototypeOf(ParamGroup)).call(this, props)); _this.handleClick = _this.handleClick.bind(_this); return _this; } _createClass(ParamGroup, [{ key: 'handleClick', value: function handleClick(e) { clearTimeout(this.timeout); var new_value = e.target.checked; this.props.actions.set_param(this.props.name, new_value); this.props.onToggle && this.props.onToggle(new_value); } }, { key: 'render', value: function render() { var checked = this.props.opt[this.props.name]; var toggle = !this.props.noToggle; var className = !toggle || checked ? 'paramGroup active' : 'paramGroup inactive'; return (0, _preact.h)( 'div', { className: className }, (0, _preact.h)( 'label', null, (0, _preact.h)( 'h3', null, this.props.title ), toggle ? (0, _preact.h)('input', { type: 'checkbox', onClick: this.handleClick, checked: checked }) : null ), this.props.children ); } }]); return ParamGroup; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { opt: state.live.opt }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(liveActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(ParamGroup); /***/ }), /***/ "./app/client/common/player.component.js": /*!***********************************************!*\ !*** ./app/client/common/player.component.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); function Player(props) { return (0, _preact.h)( 'div', { className: 'player' }, (0, _preact.h)('canvas', { width: props.width, height: props.height }) ); } var mapStateToProps = function mapStateToProps(state) { return {}; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return {}; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Player); /***/ }), /***/ "./app/client/common/progress.component.js": /*!*************************************************!*\ !*** ./app/client/common/progress.component.js ***! \*************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Progress; var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); function Progress(_ref) { var progress = _ref.progress; if (!progress) return; var i = progress.i, n = progress.n; var a = []; for (var j = 0; j < n; j++) { a.push((0, _preact.h)('div', { key: j, className: j < i ? 'x' : 'o' })); } return (0, _preact.h)( 'div', { className: 'progress' }, a ); } /***/ }), /***/ "./app/client/common/select.component.js": /*!***********************************************!*\ !*** ./app/client/common/select.component.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _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; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Select = function (_Component) { _inherits(Select, _Component); function Select(props) { _classCallCheck(this, Select); var _this = _possibleConstructorReturn(this, (Select.__proto__ || Object.getPrototypeOf(Select)).call(this, props)); _this.handleChange = _this.handleChange.bind(_this); return _this; } _createClass(Select, [{ key: 'handleChange', value: function handleChange(e) { clearTimeout(this.timeout); var new_value = e.target.value; this.props.onChange && this.props.onChange(this.props.name, new_value); } }, { key: 'render', value: function render() { var currentValue = this.props.opt[this.props.name]; var lastValue = void 0; var options = (this.props.options || []).map(function (key, i) { var name = void 0, value = void 0; if (typeof key === 'string') { name = key.length < 4 ? key.toUpperCase() : key; value = key; } else if ((typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object') { if (key.length) { var _key = _slicedToArray(key, 2); name = _key[0]; value = _key[1]; } else if (key.count) { var frames = Math.round(key.count / 30) + ' s.'; name = key.name.replace(/_/g, ' ') + ' (' + frames + ')'; value = key.name; } else { name = key.name; value = key.value || key.name; } } lastValue = value; return (0, _preact.h)( 'option', { value: value, key: i }, name ); }); return (0, _preact.h)( 'div', { className: 'select param' }, (0, _preact.h)( 'label', null, (0, _preact.h)( 'span', null, this.props.title ), (0, _preact.h)( 'select', { onChange: this.handleChange, value: currentValue || lastValue }, options ) ), this.props.children ); } }]); return Select; }(_preact.Component); function capitalize(s) { return (s || "").replace(/(?:^|\s)\S/g, function (a) { return a.toUpperCase(); }); } var mapStateToProps = function mapStateToProps(state, props) { return { opt: props.opt || state.live.opt }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return {}; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Select); /***/ }), /***/ "./app/client/common/slider.component.js": /*!***********************************************!*\ !*** ./app/client/common/slider.component.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _live = __webpack_require__(/*! ../live/live.actions */ "./app/client/live/live.actions.js"); var liveActions = _interopRequireWildcard(_live); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var SLIDER_THROTTLE_TIME = 100; var Slider = function (_Component) { _inherits(Slider, _Component); function Slider(props) { _classCallCheck(this, Slider); var _this = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, props)); _this.timeout = 0; _this.state = { value: props.live ? props.opt[props.name] : props.value }; _this.handleInput = _this.handleInput.bind(_this); _this.handleRange = _this.handleRange.bind(_this); return _this; } _createClass(Slider, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { var next_value = nextProps.value || nextProps.opt[nextProps.name]; if (next_value !== this.state.value) { this.setState({ value: next_value }); } } }, { key: 'handleInput', value: function handleInput(e) { var _props = this.props, name = _props.name, opt = _props.opt; var old_value = opt[name]; var new_value = e.target.value; console.log(this.props); console.log(new_value, this.props.defaultValue); if (new_value === '') { new_value = this.props.defaultValue || (this.props.max - this.props.min) / 2; } else if (this.props.type === 'int') { new_value = parseInt(new_value); } else if (this.props.type === 'odd') { new_value = parseInt(Math.floor(new_value / 2) * 2 + 1); } if (old_value !== new_value) { this.setState({ value: new_value }); this.props.live && this.props.actions.set_param(this.props.name, new_value); this.props.onChange && this.props.onChange(new_value); } clearTimeout(this.timeout); } }, { key: 'handleRange', value: function handleRange(e) { var _this2 = this; clearTimeout(this.timeout); var new_value = e.target.value; if (this.props.type === 'int') { new_value = parseInt(new_value); } if (this.props.type === 'odd') { new_value = parseInt(Math.floor(new_value / 2) * 2 + 1); } this.setState({ value: new_value }); this.timeout = setTimeout(function () { _this2.props.live && _this2.props.actions.set_param(_this2.props.name, new_value); _this2.props.onChange && _this2.props.onChange(new_value); }, SLIDER_THROTTLE_TIME); } }, { key: 'render', value: function render() { var _props2 = this.props, name = _props2.name, title = _props2.title; var value = this.state.value; if (typeof value === 'undefined') { value = this.props.min; } var text_value = value; var step = void 0; if (this.props.type === 'int') { step = 1; } else { step = (this.props.max - this.props.min) / 100; text_value = parseFloat(value).toFixed(2); } return (0, _preact.h)( 'div', { 'class': 'slider param' }, (0, _preact.h)( 'label', null, (0, _preact.h)( 'span', null, title || name.replace(/_/g, ' ') ), (0, _preact.h)('input', { type: 'text', value: text_value, onBlur: this.handleInput }) ), (0, _preact.h)('input', { type: 'range', min: this.props.min, max: this.props.max, step: step, value: value, onInput: this.handleRange }) ); } }]); return Slider; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { opt: state.live.opt }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(liveActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Slider); /***/ }), /***/ "./app/client/common/textInput.component.js": /*!**************************************************!*\ !*** ./app/client/common/textInput.component.js ***! \**************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var TextInput = function (_Component) { _inherits(TextInput, _Component); function TextInput(props) { _classCallCheck(this, TextInput); var _this = _possibleConstructorReturn(this, (TextInput.__proto__ || Object.getPrototypeOf(TextInput)).call(this, props)); _this.handleInput = _this.handleInput.bind(_this); _this.handleKeydown = _this.handleKeydown.bind(_this); return _this; } _createClass(TextInput, [{ key: 'handleInput', value: function handleInput(e) { this.props.onInput && this.props.onInput(e.target.value); } }, { key: 'handleKeydown', value: function handleKeydown(e) { if (e.keyCode === 13) { this.props.onSave && this.props.onSave(e.target.value); } } }, { key: 'render', value: function render() { return (0, _preact.h)( 'div', { className: 'textInput param' }, (0, _preact.h)( 'label', null, (0, _preact.h)( 'span', null, this.props.title ), (0, _preact.h)('input', { type: 'text', value: this.props.value, onInput: this.handleInput, onKeydown: this.handleKeydown, placeholder: this.props.placeholder, autofocus: this.props.autofocus }) ) ); } }]); return TextInput; }(_preact.Component); exports.default = TextInput; /***/ }), /***/ "./app/client/common/views/index.js": /*!******************************************!*\ !*** ./app/client/common/views/index.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.New = undefined; var _newView = __webpack_require__(/*! ./new.view.js */ "./app/client/common/views/new.view.js"); var _newView2 = _interopRequireDefault(_newView); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var New = exports.New = _newView2.default; /***/ }), /***/ "./app/client/common/views/new.view.js": /*!*********************************************!*\ !*** ./app/client/common/views/new.view.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _group = __webpack_require__(/*! ../group.component */ "./app/client/common/group.component.js"); var _group2 = _interopRequireDefault(_group); var _param = __webpack_require__(/*! ../param.component */ "./app/client/common/param.component.js"); var _param2 = _interopRequireDefault(_param); var _loading = __webpack_require__(/*! ../loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); var _folderList = __webpack_require__(/*! ../folderList.component */ "./app/client/common/folderList.component.js"); var _folderList2 = _interopRequireDefault(_folderList); var _dataset = __webpack_require__(/*! ../../dataset/dataset.new */ "./app/client/dataset/dataset.new.js"); var _dataset2 = _interopRequireDefault(_dataset); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var NewView = function (_Component) { _inherits(NewView, _Component); function NewView(props) { _classCallCheck(this, NewView); var _this = _possibleConstructorReturn(this, (NewView.__proto__ || Object.getPrototypeOf(NewView)).call(this, props)); console.log(props); if (!props.db.data) { props.actions.load_directories(); } return _this; } _createClass(NewView, [{ key: 'render', value: function render() { var _props = this.props, module = _props.module, history = _props.history, db = _props.db, path = _props.path; return (0, _preact.h)( 'div', { 'class': 'app new-view ' + module.name }, (0, _preact.h)( 'div', { 'class': 'heading' }, (0, _preact.h)( 'h1', null, module.displayName || module.name ) ), (0, _preact.h)( 'div', { 'class': 'col narrow' }, (0, _preact.h)(_dataset2.default, { module: module, history: history }), (0, _preact.h)(_folderList2.default, { db: db, path: path, emptyText: (0, _preact.h)( 'i', null, 'No projects yet. Please create one~' ) }) ) ); } }]); return NewView; }(_preact.Component); exports.default = NewView; /***/ }), /***/ "./app/client/dashboard/dashboard.actions.js": /*!***************************************************!*\ !*** ./app/client/dashboard/dashboard.actions.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.load = undefined; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var load = exports.load = function load() { return function (dispatch) { _util2.default.allProgress([_actions2.default.task.index({ limit: 40, orderBy: 'created_at desc' }), _actions2.default.folder.index(), _actions2.default.file.index({ module: 'samplernn', generated: 1, limit: 10, orderBy: 'created_at desc' })], function (percent, i, n) { console.log('dashboard load progress', i, n); dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); }).then(function (res) { var _res = _slicedToArray(res, 3), tasks = _res[0], folders = _res[1], sampleRNNrenders = _res[2]; var _util$sort$orderByFn = _util2.default.sort.orderByFn('date desc'), mapFn = _util$sort$orderByFn.mapFn, sortFn = _util$sort$orderByFn.sortFn; var foldersByModule = folders.map(mapFn).sort(sortFn).reduce(function (a, b) { var module = b[1].module; a[module] = a[module] || []; a[module].push(b[1]); return a; }, {}); dispatch({ type: _types2.default.dashboard.load, data: { tasks: tasks, folders: folders, sampleRNNrenders: sampleRNNrenders, foldersByModule: foldersByModule } }); }); }; }; /***/ }), /***/ "./app/client/dashboard/dashboard.component.js": /*!*****************************************************!*\ !*** ./app/client/dashboard/dashboard.component.js ***! \*****************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _player = __webpack_require__(/*! ../common/player.component */ "./app/client/common/player.component.js"); var _player2 = _interopRequireDefault(_player); var _group = __webpack_require__(/*! ../common/group.component */ "./app/client/common/group.component.js"); var _group2 = _interopRequireDefault(_group); var _slider = __webpack_require__(/*! ../common/slider.component */ "./app/client/common/slider.component.js"); var _slider2 = _interopRequireDefault(_slider); var _select = __webpack_require__(/*! ../common/select.component */ "./app/client/common/select.component.js"); var _select2 = _interopRequireDefault(_select); var _button = __webpack_require__(/*! ../common/button.component */ "./app/client/common/button.component.js"); var _button2 = _interopRequireDefault(_button); var _dashboardheader = __webpack_require__(/*! ./dashboardheader.component */ "./app/client/dashboard/dashboardheader.component.js"); var _dashboardheader2 = _interopRequireDefault(_dashboardheader); var _tasklist = __webpack_require__(/*! ./tasklist.component */ "./app/client/dashboard/tasklist.component.js"); var _tasklist2 = _interopRequireDefault(_tasklist); var _common = __webpack_require__(/*! ../common */ "./app/client/common/index.js"); var _gallery = __webpack_require__(/*! ../common/gallery.component */ "./app/client/common/gallery.component.js"); var _gallery2 = _interopRequireDefault(_gallery); var _dashboard = __webpack_require__(/*! ./dashboard.actions */ "./app/client/dashboard/dashboard.actions.js"); var dashboardActions = _interopRequireWildcard(_dashboard); var _audioPlayer = __webpack_require__(/*! ../common/audioPlayer/audioPlayer.actions */ "./app/client/common/audioPlayer/audioPlayer.actions.js"); var audioPlayerActions = _interopRequireWildcard(_audioPlayer); var _modules = __webpack_require__(/*! ../modules */ "./app/client/modules/index.js"); var _modules2 = _interopRequireDefault(_modules); var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Dashboard = function (_Component) { _inherits(Dashboard, _Component); function Dashboard(props) { _classCallCheck(this, Dashboard); var _this = _possibleConstructorReturn(this, (Dashboard.__proto__ || Object.getPrototypeOf(Dashboard)).call(this)); console.log(props); props.actions.load(); return _this; } _createClass(Dashboard, [{ key: 'componentWillUpdate', value: function componentWillUpdate(nextProps) { // if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { // this.props.actions.list_epochs(nextProps.opt.checkpoint_name) } }, { key: 'render', value: function render() { var _this2 = this; var _props = this.props, site = _props.site, foldersByModule = _props.foldersByModule, sampleRNNrenders = _props.sampleRNNrenders, queue = _props.queue, images = _props.images; var tasks = queue.tasks; var folders = foldersByModule && Object.keys(_modules2.default).sort().map(function (key) { if (!foldersByModule[key]) return null; var path = key === 'samplernn' ? '/samplernn/datasets/' : '/' + key + '/sequences/'; var folders = foldersByModule[key].map(function (folder) { return (0, _preact.h)( 'div', { key: folder.id }, (0, _preact.h)( _reactRouterDom.Link, { to: path + folder.id + '/' }, folder.name ) ); }); var files = key === 'samplernn' && (0, _preact.h)(_common.FileList, { linkFiles: true, files: sampleRNNrenders, orderBy: 'date desc', fields: 'name date epoch size', onClick: function onClick(file, e) { e.preventDefault(); e.stopPropagation(); console.log('picked a file', file); _this2.handlePick(file); } }); return (0, _preact.h)( 'div', { className: 'dashboardModule', key: key }, (0, _preact.h)( 'div', { className: 'row moduleHeading' }, (0, _preact.h)( 'h3', null, key ), (0, _preact.h)( 'div', null, (0, _preact.h)( _reactRouterDom.Link, { to: '/' + key + '/new/' }, 'new' ) ), folders ), files ); }).filter(function (a) { return !!a; }); return (0, _preact.h)( 'div', { className: 'app dashboard' }, (0, _preact.h)(_dashboardheader2.default, null), (0, _preact.h)( 'div', { className: 'params row' }, (0, _preact.h)( 'div', { className: 'column' }, !!queue.queue.length && (0, _preact.h)( _group2.default, { title: 'Upcoming Tasks' }, (0, _preact.h)(_tasklist2.default, { tasks: queue.queue.map(function (id) { return tasks[id]; }) }) ), !!queue.completed.length && (0, _preact.h)( _group2.default, { title: 'Completed Tasks' }, (0, _preact.h)(_tasklist2.default, { tasks: queue.completed.map(function (id) { return tasks[id]; }) }) ) ), (0, _preact.h)( 'div', { className: 'column' }, folders ) ) ); } }, { key: 'handlePick', value: function handlePick(file) { this.props.audioPlayer.play(file); } }]); return Dashboard; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { site: state.system.site, foldersByModule: state.dashboard.data.foldersByModule, sampleRNNrenders: state.dashboard.data.sampleRNNrenders, images: state.dashboard.images, files: state.dashboard.files, queue: state.queue }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(dashboardActions, dispatch), audioPlayer: (0, _redux.bindActionCreators)(audioPlayerActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Dashboard); /***/ }), /***/ "./app/client/dashboard/dashboard.reducer.js": /*!***************************************************!*\ !*** ./app/client/dashboard/dashboard.reducer.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); var _moment2 = _interopRequireDefault(_moment); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var FileSaver = __webpack_require__(/*! file-saver */ "./node_modules/file-saver/FileSaver.js"); var dashboardInitialState = { loading: false, error: null, data: {}, images: [], files: [] }; var dashboardReducer = function dashboardReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dashboardInitialState; var action = arguments[1]; switch (action.type) { case _types2.default.dashboard.load: return _extends({}, state, { loading: false, error: null, data: action.data }); default: return state; } }; exports.default = dashboardReducer; /***/ }), /***/ "./app/client/dashboard/dashboardheader.component.js": /*!***********************************************************!*\ !*** ./app/client/dashboard/dashboardheader.component.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var DashboardHeader = function (_Component) { _inherits(DashboardHeader, _Component); function DashboardHeader(props) { _classCallCheck(this, DashboardHeader); var _this = _possibleConstructorReturn(this, (DashboardHeader.__proto__ || Object.getPrototypeOf(DashboardHeader)).call(this, props)); _this.handleClick = _this.handleClick.bind(_this); return _this; } _createClass(DashboardHeader, [{ key: 'handleClick', value: function handleClick(e) { this.props.onClick && this.props.onClick(); } }, { key: 'render', value: function render() { var site = this.props.site; return (0, _preact.h)( 'div', { 'class': 'dashboardHeader heading' }, (0, _preact.h)( 'h1', null, site.name, ' cortex' ), this.renderGPUStatus() ); } }, { key: 'renderGPUStatus', value: function renderGPUStatus() { var runner = this.props.runner; var gpu = runner.cpu; if (gpu.status === 'IDLE') { return null; } var task = gpu.task; var eta = task.epoch ? (task.epochs - (task.epoch || 0)) * 1000 / 60 + " minutes" : null; var activityPhrase = void 0, liveMessage = void 0; if (task.activity === 'live') { return (0, _preact.h)( 'div', null, 'Currently running ', task.module, ' live on "', task.dataset, '"' ); } else { return (0, _preact.h)( 'div', null, 'Currently ', _util2.default.gerund(task.activity), ' ', task.module, ' on ', task.dataset, (0, _preact.h)('br', null), eta && (0, _preact.h)( 'span', null, 'Epoch: ', task.epoch, ' / ', task.epochs, ', ETA ', eta, (0, _preact.h)('br', null) ), (0, _preact.h)('br', null), 'Want to play live? ', (0, _preact.h)( 'button', null, 'Pause at the end of this epoch' ) ); } } }]); return DashboardHeader; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { runner: state.system.runner, site: state.system.site }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return {}; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(DashboardHeader); /***/ }), /***/ "./app/client/dashboard/tasklist.component.js": /*!****************************************************!*\ !*** ./app/client/dashboard/tasklist.component.js ***! \****************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var TaskList = function (_Component) { _inherits(TaskList, _Component); function TaskList(props) { _classCallCheck(this, TaskList); return _possibleConstructorReturn(this, (TaskList.__proto__ || Object.getPrototypeOf(TaskList)).call(this)); } _createClass(TaskList, [{ key: 'render', value: function render() { var _this2 = this; var _props = this.props, title = _props.title, tasks = _props.tasks; var time = 0; var _util$sort$orderByFn = _util2.default.sort.orderByFn('date desc'), mapFn = _util$sort$orderByFn.mapFn, sortFn = _util$sort$orderByFn.sortFn; var taskList = tasks.map(mapFn).sort(sortFn).map(function (pair) { var task = pair[1]; var dataset = task.dataset; var dataset_link = void 0; if (task.folder_id) { var href = '/' + task.module + '/' + (task.module === 'samplernn' ? 'datasets' : 'sequences') + '/' + task.folder_id + '/'; dataset_link = (0, _preact.h)( _reactRouterDom.Link, { to: href }, dataset ); } else { dataset_link = dataset; } return (0, _preact.h)( 'div', { 'class': 'row' }, (0, _preact.h)( 'div', { 'class': 'activity' }, task.activity, ' ', task.module ), (0, _preact.h)( 'div', { 'class': 'dataset' }, dataset_link ), (0, _preact.h)( 'div', { className: "age " + _util2.default.carbon_date(task.updated_at) }, _util2.default.get_age(task.updated_at) ), (0, _preact.h)( 'div', { 'class': 'options' }, (0, _preact.h)( 'span', { 'class': 'destroy', onClick: function onClick() { return _this2.handleDestroy(task); } }, 'x' ) ) ); }); return (0, _preact.h)( 'div', { 'class': 'tasklist rows' }, taskList ); } }, { key: 'handleDestroy', value: function handleDestroy(task) { var yes = confirm('Are you sure you want to delete this task?'); if (yes) { _actions2.default.task.destroy(task); } } }]); return TaskList; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return {}; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { // actions: bindActionCreators(liveActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(TaskList); /***/ }), /***/ "./app/client/dataset/dataset.actions.js": /*!***********************************************!*\ !*** ./app/client/dataset/dataset.actions.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uploadFiles = exports.fetchURL = exports.uploadFile = exports.updateFolder = exports.createFolder = undefined; var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _api = __webpack_require__(/*! ../api */ "./app/client/api/index.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var createFolder = exports.createFolder = function createFolder(module, name) { return function (dispatch) { return _actions2.default.folder.create({ // username... should get added inside the API module: module.name, datatype: module.datatype, activity: 'dataset', name: name }); }; }; // import socket from '../socket' var updateFolder = exports.updateFolder = function updateFolder(module, folder, name) { var opt = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; return function (dispatch) { if (!folder || !folder.id) { return null; } return _actions2.default.folder.update({ id: folder.id, module: module.name, datatype: module.datatype, activity: 'dataset', name: name, opt: opt }); }; }; var uploadFile = exports.uploadFile = function uploadFile(module, folder, file, filename, opt) { return function (dispatch) { var fd = new FormData(); fd.append('file', file, filename); _actions2.default.folder.upload(fd, { id: folder.id, module: module.name, activity: 'file', epoch: 0, processed: false, generated: false, opt: opt }); }; }; var fetchURL = exports.fetchURL = function fetchURL(module, folder, url) { return function (dispatch) { // name url // mime datatype // duration analysis // size activity // opt created_at updated_at console.log(module, folder, url); var seenURL = folder.files.some(function (file) { return file.url === url; }); console.log(seenURL); if (seenURL) { console.log('already seen this url'); return; } _api.parser.parse(url, function (media) { if (!media) return; console.log('media', media); _actions2.default.file.create({ folder_id: folder.id, name: (media.title || "").replace(/\.[^.]+$/g, '').replace(/[^a-zA-Z0-9_]/g, '_').replace(/\s+/g, '_').replace(/_+/g, '_'), module: module.name, dataset: media.token, activity: 'url', duration: parseInt(media.duration) || 0, epoch: 0, processed: false, generated: false, opt: media, url: url }); }); }; }; var uploadFiles = exports.uploadFiles = function uploadFiles(files) { return { type: _types2.default.dataset.upload_files }; }; // export const uploadFiles = (files) => { // return dispatch => { // // return { type: types.dataset.upload_files } // } // } // export const fetchURL = (url) => { type: types.dataset.fetch_url } /***/ }), /***/ "./app/client/dataset/dataset.component.js": /*!*************************************************!*\ !*** ./app/client/dataset/dataset.component.js ***! \*************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _fileList = __webpack_require__(/*! ../common/fileList.component */ "./app/client/common/fileList.component.js"); var _loading = __webpack_require__(/*! ../common/loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var fieldSet = _util2.default.fieldSet(new Set(['input', 'status', 'checkpoint', 'output'])); var DatasetComponent = function (_Component) { _inherits(DatasetComponent, _Component); function DatasetComponent() { _classCallCheck(this, DatasetComponent); return _possibleConstructorReturn(this, (DatasetComponent.__proto__ || Object.getPrototypeOf(DatasetComponent)).apply(this, arguments)); } _createClass(DatasetComponent, [{ key: 'render', value: function render() { var _props = this.props, loading = _props.loading, progress = _props.progress, fields = _props.fields, module = _props.module, data = _props.data, folder = _props.folder, match = _props.match, history = _props.history; if (loading) { return (0, _preact.h)(_loading2.default, { progress: progress }); } if (!data.folders.length) { console.log('no folders, redirect to /new'); return history.push('/' + module.name + '/new/'); } if (!folder || !folder.name) return; fields = fieldSet(fields); return (0, _preact.h)( 'div', { 'class': 'rows params datasets' }, (0, _preact.h)( 'div', { 'class': 'row row-heading dataset' }, fields.has('input') && (0, _preact.h)( 'div', { 'class': 'col' }, 'input' ), fields.has('status') && (0, _preact.h)( 'div', { 'class': 'col' }, 'status' ), fields.has('checkpoint') && (0, _preact.h)( 'div', { 'class': 'col' }, 'checkpoint' ), fields.has('output') && (0, _preact.h)( 'div', { 'class': 'col' }, 'output' ) ), this.renderGroups() ); } }, { key: 'renderGroups', value: function renderGroups() { var _this2 = this; var _props2 = this.props, module = _props2.module, data = _props2.data, folder = _props2.folder, fields = _props2.fields, runner = _props2.runner, onPickDataset = _props2.onPickDataset, onPickFile = _props2.onPickFile, datasetActions = _props2.datasetActions; fields = fieldSet(fields); var datasetLookup = data.datasetLookup, fileLookup = data.fileLookup; var _util$sort$orderByFn = _util2.default.sort.orderByFn('date desc'), mapFn = _util$sort$orderByFn.mapFn, sortFn = _util$sort$orderByFn.sortFn; var moduleOnCPU = runner && runner.cpu.task && runner.cpu.task.module === module.name; var moduleOnGPU = runner && runner.gpu.task && runner.gpu.task.module === module.name; var datasets = folder.datasets.map(function (name) { return datasetLookup[name]; }).map(mapFn).sort(sortFn).map(function (pair) { var dataset = pair[1]; var status = ''; var isProcessing = false, isFetching = false; if (moduleOnGPU && runner.gpu.task.dataset === dataset) { status = _util2.default.gerund(runner.gpu.task.activity); isProcessing = true; } else if (moduleOnCPU && runner.cpu.task.activity === 'fetch' && runner.cpu.task.opt.file_id === dataset.input[0]) { isProcessing = true; isFetching = true; } return (0, _preact.h)( 'div', { key: dataset.name, className: 'row dataset', onClick: function onClick() { return onPickDataset && onPickDataset(dataset); } }, _this2.props.beforeRow && _this2.props.beforeRow(dataset), fields.has('input') && (0, _preact.h)( 'div', { className: 'col' }, !!dataset.input.length && (0, _preact.h)(_fileList.FileList, { files: dataset.input.map(function (id) { return fileLookup[id]; }), className: 'input_files', fileListClassName: '', rowClassName: 'input_file', fields: 'name date size delete', linkFiles: true, onClick: onPickFile, onDelete: function onDelete(file) { return _this2.onDeleteFile(file); } }) ), fields.has('status') && (0, _preact.h)( 'div', { className: ['col', 'quiet', dataset.isBuilt ? 'built' : 'not_built', isProcessing ? 'processing' : 'not_processing'].join(' ') }, _this2.props.datasetActions && _this2.props.datasetActions(dataset, isFetching, isProcessing), status ), fields.has('checkpoint') && (0, _preact.h)( 'div', { className: 'col checkpoint' }, !!dataset.checkpoints.length && (0, _preact.h)(_fileList.FileRow, { file: dataset.checkpoints[0], fields: 'name date epoch', className: 'row checkpoint' }) ), fields.has('output') && (0, _preact.h)( 'div', { className: 'col' }, !!dataset.output.length && (0, _preact.h)(_fileList.FileList, { files: dataset.output.map(function (id) { return fileLookup[id]; }), orderBy: 'epoch desc', fields: 'name date epoch size', linkFiles: true, onClick: onPickFile, onDelete: function onDelete(file) { return _this2.onDeleteFile(file); } }) ), _this2.props.afterRow && _this2.props.afterRow(dataset) ); }); return datasets; } }, { key: 'onDeleteFile', value: function onDeleteFile(file) { var yes = confirm('Are you sure you want to delete this file?'); if (yes) { console.log('delete: confirmed'); if (this.props.onDeleteFile) { console.log('calling custom deletefile function'); this.props.onDeleteFile(file); } else { _actions2.default.file.destroy(file); } } } }]); return DatasetComponent; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { runner: state.system.runner }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return {}; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(DatasetComponent); /***/ }), /***/ "./app/client/dataset/dataset.form.js": /*!********************************************!*\ !*** ./app/client/dataset/dataset.form.js ***! \********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _dataset = __webpack_require__(/*! ./dataset.actions */ "./app/client/dataset/dataset.actions.js"); var datasetActions = _interopRequireWildcard(_dataset); var _group = __webpack_require__(/*! ../common/group.component */ "./app/client/common/group.component.js"); var _group2 = _interopRequireDefault(_group); var _param = __webpack_require__(/*! ../common/param.component */ "./app/client/common/param.component.js"); var _param2 = _interopRequireDefault(_param); var _fileList = __webpack_require__(/*! ../common/fileList.component */ "./app/client/common/fileList.component.js"); var _fileUpload = __webpack_require__(/*! ../common/fileUpload.component */ "./app/client/common/fileUpload.component.js"); var _fileUpload2 = _interopRequireDefault(_fileUpload); var _textInput = __webpack_require__(/*! ../common/textInput.component */ "./app/client/common/textInput.component.js"); var _textInput2 = _interopRequireDefault(_textInput); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var DatasetForm = function (_Component) { _inherits(DatasetForm, _Component); function DatasetForm() { _classCallCheck(this, DatasetForm); return _possibleConstructorReturn(this, (DatasetForm.__proto__ || Object.getPrototypeOf(DatasetForm)).apply(this, arguments)); } _createClass(DatasetForm, [{ key: 'render', value: function render() { var _props = this.props, loading = _props.loading, status = _props.status, error = _props.error, module = _props.module, folder = _props.folder, _props$title = _props.title, title = _props$title === undefined ? 'Dataset' : _props$title, canRename = _props.canRename, canUpload = _props.canUpload, canAddURL = _props.canAddURL; // sort files?? if (!folder.id) { return (0, _preact.h)( 'div', { className: 'params row' }, (0, _preact.h)( 'div', { className: 'column' }, this.renderFolderNameInput(folder.name) ) ); } return (0, _preact.h)( 'div', { className: 'form params row' }, (0, _preact.h)( 'div', { className: 'col' }, (0, _preact.h)( _group2.default, null, canRename && this.renderFolderNameInput(folder.name), canUpload && this.renderUploadInput(), canAddURL && this.renderURLInput() ) ) ); } }, { key: 'curry', value: function curry(action) { var _props2 = this.props, module = _props2.module, folder = _props2.folder; return function (param) { return action(module, folder, param); }; } }, { key: 'renderFolderNameInput', value: function renderFolderNameInput(name) { return (0, _preact.h)(_textInput2.default, { title: 'Dataset name', value: name, onSave: this.curry(this.props.actions.dataset.updateFolder) }); } }, { key: 'renderUploadInput', value: function renderUploadInput() { return (0, _preact.h)(_fileUpload2.default, { title: 'Upload a file', mime: 'image.*', onUpload: this.curry(this.props.actions.dataset.uploadFile) }); } }, { key: 'renderURLInput', value: function renderURLInput() { return (0, _preact.h)(_textInput2.default, { title: 'Fetch a URL', placeholder: 'http://', onSave: this.curry(this.props.actions.dataset.fetchURL) }); } }]); return DatasetForm; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return state.upload; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: { dataset: (0, _redux.bindActionCreators)(datasetActions, dispatch) } }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(DatasetForm); /***/ }), /***/ "./app/client/dataset/dataset.loader.js": /*!**********************************************!*\ !*** ./app/client/dataset/dataset.loader.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.load = exports.getDataset = exports.emptyDataset = exports.unsortedFolder = undefined; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var unsortedFolders = {}; var unsortedFolder = exports.unsortedFolder = function unsortedFolder(module) { var instantiate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; if (!unsortedFolders[module] || instantiate) { var folder = { id: 0, module: module, name: 'unsorted', files: [], datasets: [] }; unsortedFolders[module] = folder; } return unsortedFolders[module]; }; var emptyDataset = exports.emptyDataset = function emptyDataset(module, datasetLookup, name, folder) { var dataset = { name: name, input: [], checkpoints: [], output: [] }; datasetLookup[name] = dataset; folder = folder || unsortedFolder(module); folder.datasets.push(name); return dataset; }; var getDataset = exports.getDataset = function getDataset(module, datasetLookup, name, folder, date) { var dataset = datasetLookup[name] || emptyDataset(module, datasetLookup, name, folder); // folder = folder || unsortedFolder(module) if (date) { dataset.date = dataset.date && !isNaN(dataset.date) ? Math.max(+new Date(date), dataset.date) : +new Date(date); } return dataset; }; var load = exports.load = function load(module) { console.log(module); return Promise.all([_actions2.default.folder.index({ module: module, limit: 0 }), _actions2.default.file.index({ module: module, limit: 0 }), _actions2.default.task.index({ module: module })]).then(function (res) { var _res = _slicedToArray(res, 3), folders = _res[0], files = _res[1], tasks = _res[2]; var datasetLookup = {}; var folderLookup = {}; var fileLookup = {}; // take all of the folders and put them in a lookup folderLookup = folders.reduce(function (folderLookup, folder) { folderLookup[folder.id] = { id: folder.id, name: folder.name, folder: folder, files: [], datasets: [] }; return folderLookup; }, { unsorted: unsortedFolder(module, true) }); // prepare the files by splitting into two groups var generatedFiles = files.filter(function (file) { return file.generated; }); var ungeneratedFiles = files.filter(function (file) { return !file.generated; }); // build the initial dataset lookup table using the ungenerated files ungeneratedFiles.reduce(function (datasetLookup, file) { fileLookup[file.id] = file; if (!file.name) { if (file.opt && file.opt.media && file.opt.media.token) { file.name = file.opt.media.token; } else { file.name = file.url.replace(/^https?:\/\/(www.)?/, '').replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_') || 'unknown_' + Math.floor(1000 * Math.random()); } } var name = (file.name || 'unsorted').split('.')[0]; var folder = folderLookup[file.folder_id] || unsortedFolder(module); var dataset = getDataset(module, datasetLookup, file.dataset || name, folder, file.date || file.created_at); if (file.url.match(file.name)) file.persisted = true; dataset.input.push(file.id); folder.files.push(file.id); return datasetLookup; }, datasetLookup); // go over the generated files and add addl datasets (if the files were deleted) generatedFiles.map(function (file) { fileLookup[file.id] = file; var pair = file.name.split('.')[0].split('-'); var folder = folderLookup[file.folder_id] || unsortedFolder(module); var dataset = getDataset(module, datasetLookup, file.dataset || pair[0], folder, file.date || file.created_at); dataset.output.push(file.id); folder.files.push(file.id); file.epoch = file.epoch || pair[1]; }); return { folderLookup: folderLookup, fileLookup: fileLookup, datasetLookup: datasetLookup, folders: folders, files: files, unsortedFolder: folderLookup.unsorted }; }).catch(function (e) { console.error(e); }); }; /***/ }), /***/ "./app/client/dataset/dataset.new.js": /*!*******************************************!*\ !*** ./app/client/dataset/dataset.new.js ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _dataset = __webpack_require__(/*! ./dataset.actions */ "./app/client/dataset/dataset.actions.js"); var datasetActions = _interopRequireWildcard(_dataset); var _loading = __webpack_require__(/*! ../common/loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); var _textInput = __webpack_require__(/*! ../common/textInput.component */ "./app/client/common/textInput.component.js"); var _textInput2 = _interopRequireDefault(_textInput); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function NewDatasetForm(props) { var loading = props.loading, status = props.status, error = props.error, history = props.history, actions = props.actions, module = props.module; if (loading) return (0, _preact.h)(_loading2.default, null); console.log(props); return (0, _preact.h)( 'div', { 'class': 'opaque' }, (0, _preact.h)( 'div', { 'class': 'heading' }, (0, _preact.h)( 'h2', null, 'Create a new ', module.displayName, ' project' ) ), (0, _preact.h)( 'div', { 'class': 'params' }, (0, _preact.h)(_textInput2.default, { autofocus: true, title: 'Name your project', onSave: function onSave(name) { actions.createFolder(module, name).then(function (folder) { window.location.href = '/' + module.name + '/datasets/' + folder.id + '/'; }); } }) ) ); } var mapStateToProps = function mapStateToProps(state) { return {}; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(datasetActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(NewDatasetForm); /***/ }), /***/ "./app/client/dataset/dataset.reducer.js": /*!***********************************************!*\ !*** ./app/client/dataset/dataset.reducer.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /* Note: This is a sub-reducer intended to process the folder-file API output from the DB. Please run this from inside your module reducers :) */ var datasetInitialState = function datasetInitialState() { return { loading: true, error: null, data: null, folder_id: 0 }; }; var datasetReducer = function datasetReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : datasetInitialState(); var action = arguments[1]; switch (action.type) { case _types2.default.app.load_progress: return _extends({}, state, { progress: action.progress }); case _types2.default.dataset.load: return _extends({}, state, { loading: false, data: action.data }); case _types2.default.dataset.set_folder: return _extends({}, state, { folder_id: action.data.folder_id }); case _types2.default.folder.create: return _extends({}, state, { loading: false, data: { folders: state.data.folders.concat([action.data.id]), folderLookup: _extends({}, state.data.folderLookup, _defineProperty({}, action.data.id, action.data)) } }); return state; case _types2.default.file.create: return handleFileCreate(state, action); case _types2.default.file.update: return handleFileUpdate(state, action); case _types2.default.file.destroy: return handleFileDestroy(state, action); default: return state; } }; function handleFileCreate(state, action) { console.log(action.data); var dataset = void 0, old_dataset = void 0, folder = void 0, old_folder = void 0; var dataset_name = void 0; if (action.data.dataset) { dataset_name = action.data.dataset; } else if (action.data.name) { dataset_name = action.data.name.split('.')[0]; } else if (action.data.url) { dataset_name = action.data.url; } else { dataset_name = null; } if (dataset_name in state.data.datasetLookup) { old_dataset = state.data.datasetLookup[dataset_name]; dataset = _extends({}, old_dataset, { input: action.data.generated ? old_dataset.input : [action.data.id].concat(old_dataset.input), output: !action.data.generated ? old_dataset.output : [action.data.id].concat(old_dataset.output) }); } else { console.log(action.data.created_at, action.data.date); dataset = { name: dataset_name, date: action.data.created_at || action.data.date, input: action.data.generated ? [] : [action.data.id], checkpoints: [], output: !action.data.generated ? [] : [action.data.id] }; } old_folder = state.data.folderLookup[action.data.folder_id]; folder = _extends({}, old_folder, { datasets: old_folder.datasets.concat([dataset_name]), files: old_folder.files.concat([action.data.id]) }); return _extends({}, state, { loading: false, data: _extends({}, state.data, { files: state.data.files.concat([action.data.id]), folderLookup: _extends({}, state.data.folderLookup, _defineProperty({}, action.data.folder_id, folder)), fileLookup: _extends({}, state.data.fileLookup, _defineProperty({}, action.data.id, action.data)), datasetLookup: _extends({}, state.data.datasetLookup, _defineProperty({}, dataset_name, dataset)) }) }); } function handleFileUpdate(state, action) { var _extends6; var old_dataset = void 0; var new_dataset = state.data.datasetLookup[action.data.dataset]; var old_file = state.data.fileLookup[action.data.id]; var new_dataset_update = void 0; if (old_file && action.data.dataset !== old_file.dataset) { if (state.data.datasetLookup[old_file.dataset]) { old_dataset = state.data.datasetLookup[old_file.dataset]; old_dataset_update = _extends({}, old_dataset, { input: old_dataset.input.filter(function (id) { return id !== action.data.id; }), output: old_dataset.output.filter(function (id) { return id !== action.data.id; }) }); } new_dataset_update = _extends({}, new_dataset, { input: action.data.generated ? [] : [action.data.id], output: !action.data.generated ? [] : [action.data.id] }); } console.log('old_dataset', old_dataset_update.name); console.log('new_dataset', new_dataset_update.name); return _extends({}, state, { loading: false, data: _extends({}, state.data, { datasetLookup: old_dataset ? _extends({}, state.data.datasetLookup, (_extends6 = {}, _defineProperty(_extends6, old_dataset.name, old_dataset_update), _defineProperty(_extends6, new_dataset.name, new_dataset_update), _extends6)) : new_dataset_update ? _extends({}, state.data.datasetLookup, _defineProperty({}, new_dataset.name, new_dataset_update)) : state.data.datasetLookup, fileLookup: _extends({}, state.data.fileLookup, _defineProperty({}, action.data.id, action.data)) }) }); return state; } function handleFileDestroy(state, action) { // delete the key from fileLookup var fileLookup = _extends({}, state.data.fileLookup); var datasetLookup = _extends({}, state.data.datasetLookup); var folderLookup = _extends({}, state.data.folderLookup); var old_file = fileLookup[action.data.id]; if (!old_file) return state; var old_dataset = state.data.datasetLookup[old_file.dataset]; var dataset = void 0; if (old_dataset) { dataset = _extends({}, old_dataset, { input: old_dataset.input.filter(function (id) { return id !== old_file.id; }), output: old_dataset.output.filter(function (id) { return id !== old_file.id; }) }); if (!dataset.input.length && !dataset.checkpoints.length && !dataset.output.length) { delete datasetLookup[old_file.dataset]; var old_folder = folderLookup[old_file.folder_id]; folderLookup[old_file.folder_id] = _extends({}, old_folder, { datasets: old_folder.datasets.filter(function (name) { return name !== old_file.dataset; }) }); } else { console.log('dataset just needs sweeping'); datasetLookup[old_file.dataset] = dataset; } } delete fileLookup[old_file.id]; return _extends({}, state, { loading: false, data: _extends({}, state.data, { folderLookup: folderLookup, fileLookup: fileLookup, datasetLookup: datasetLookup }) }); } exports.default = datasetReducer; /***/ }), /***/ "./app/client/dataset/upload.reducer.js": /*!**********************************************!*\ !*** ./app/client/dataset/upload.reducer.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var uploadInitialState = { loading: false, error: null, status: '' }; var uploadReducer = function uploadReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : uploadInitialState; var action = arguments[1]; switch (action.type) { case _types2.default.folder.upload_loading: return { error: null, loading: true, status: 'Loading...' }; case _types2.default.folder.upload_error: return { error: null, loading: false, status: 'Error uploading :(' }; case _types2.default.folder.upload_progress: return { error: null, loading: true, status: 'Upload progress ' + action.percent + '%' }; case _types2.default.folder.upload_waiting: return { error: null, loading: true, status: 'Waiting for server to finish processing...' }; case _types2.default.folder.upload_complete: return { error: null, loading: false, status: 'Upload complete' }; case _types2.default.file.create_loading: return { error: null, loading: true, status: 'Creating file...' }; default: return state; } }; exports.default = uploadReducer; /***/ }), /***/ "./app/client/dataset/upload.status.js": /*!*********************************************!*\ !*** ./app/client/dataset/upload.status.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _loading = __webpack_require__(/*! ../common/loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function UploadStatus(props) { return (0, _preact.h)( 'div', { 'class': 'status' }, props.status ); } var mapStateToProps = function mapStateToProps(state) { return state.upload; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return {}; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(UploadStatus); /***/ }), /***/ "./app/client/index.jsx": /*!******************************!*\ !*** ./app/client/index.jsx ***! \******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _store = __webpack_require__(/*! ./store */ "./app/client/store.js"); var _socket = __webpack_require__(/*! ./socket */ "./app/client/socket/index.js"); var socket = _interopRequireWildcard(_socket); var _util = __webpack_require__(/*! ./util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _header = __webpack_require__(/*! ./common/header.component */ "./app/client/common/header.component.js"); var _header2 = _interopRequireDefault(_header); var _audioPlayer = __webpack_require__(/*! ./common/audioPlayer/audioPlayer.component */ "./app/client/common/audioPlayer/audioPlayer.component.js"); var _audioPlayer2 = _interopRequireDefault(_audioPlayer); var _system = __webpack_require__(/*! ./system/system.component */ "./app/client/system/system.component.js"); var _system2 = _interopRequireDefault(_system); var _dashboard = __webpack_require__(/*! ./dashboard/dashboard.component */ "./app/client/dashboard/dashboard.component.js"); var _dashboard2 = _interopRequireDefault(_dashboard); var _modules = __webpack_require__(/*! ./modules */ "./app/client/modules/index.js"); var _modules2 = _interopRequireDefault(_modules); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } // import client from './client' var module_list = Object.keys(_modules2.default).map(function (name) { var module = _modules2.default[name]; return (0, _preact.h)(_reactRouterDom.Route, { path: '/' + module.name, component: module.router }); }); var app = (0, _preact.h)( _reactRedux.Provider, { store: _store.store }, (0, _preact.h)( _reactRouterDom.BrowserRouter, null, (0, _preact.h)( 'div', null, (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/', component: _dashboard2.default }), (0, _preact.h)(_reactRouterDom.Route, { path: '/system/', component: _system2.default }), (0, _preact.h)(_reactRouterDom.Route, { path: '/dashboard/', component: _dashboard2.default }), module_list, (0, _preact.h)(_reactRouterDom.Route, { path: '/', component: _header2.default }), (0, _preact.h)(_audioPlayer2.default, null) ) ) ); (0, _preact.render)(app, document.getElementById('container')); /***/ }), /***/ "./app/client/live/live.actions.js": /*!*****************************************!*\ !*** ./app/client/live/live.actions.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.play = exports.pause = exports.seek = exports.load_epoch = exports.load_sequence = exports.list_sequences = exports.list_epochs = exports.list_checkpoints = exports.set_param = exports.get_params = undefined; var _socket = __webpack_require__(/*! ../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _player = __webpack_require__(/*! ./player */ "./app/client/live/player.js"); var player = _interopRequireWildcard(_player); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var get_params = exports.get_params = function get_params() { _socket2.default.live.get_params(); return { type: _types2.default.player.get_params }; }; var set_param = exports.set_param = function set_param(key, value) { console.log('set param', key, value); _socket2.default.live.set_param(key, value); return { type: _types2.default.player.set_param, key: key, value: value }; }; var list_checkpoints = exports.list_checkpoints = function list_checkpoints(module) { _socket2.default.live.list_checkpoints(module); return { type: _types2.default.player.loading_checkpoints }; }; var list_epochs = exports.list_epochs = function list_epochs(module, checkpoint) { _socket2.default.live.list_epochs(module, checkpoint); return { type: _types2.default.player.loading_epochs }; }; var list_sequences = exports.list_sequences = function list_sequences(module) { _socket2.default.live.list_sequences(module); return { type: _types2.default.player.loading_sequences }; }; var load_sequence = exports.load_sequence = function load_sequence(sequence_name) { _socket2.default.live.load_sequence(sequence_name); return { type: _types2.default.player.loading_sequence, sequence_name: sequence_name }; }; var load_epoch = exports.load_epoch = function load_epoch(checkpoint_name, epoch) { _socket2.default.live.load_epoch(checkpoint_name, epoch); return { type: _types2.default.player.loading_checkpoint, checkpoint_name: checkpoint_name, epoch: epoch }; }; var seek = exports.seek = function seek(frame) { _socket2.default.live.seek(frame); return { type: _types2.default.player.seeking }; }; var pause = exports.pause = function pause(frame) { _socket2.default.live.pause(pause); player.toggleFPS(false); return { type: _types2.default.player.pausing }; }; var play = exports.play = function play(frame) { _socket2.default.live.play(); player.toggleFPS(true); return { type: _types2.default.player.playing }; }; /***/ }), /***/ "./app/client/live/live.reducer.js": /*!*****************************************!*\ !*** ./app/client/live/live.reducer.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); var _moment2 = _interopRequireDefault(_moment); var _fileSaver = __webpack_require__(/*! file-saver */ "./node_modules/file-saver/FileSaver.js"); var _fileSaver2 = _interopRequireDefault(_fileSaver); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var liveInitialState = { loading: false, error: null, opt: {}, checkpoints: [], epochs: ['latest'], sequences: [], fps: 0, playing: false, last_message: '', frame: { i: 0, sequence_i: 0, sequence_len: '1' } }; var liveReducer = function liveReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : liveInitialState; var action = arguments[1]; var results = void 0; switch (action.type) { case _types2.default.socket.load_params: if (!action.opt || !Object.keys(action.opt).length) { return state; } return _extends({}, state, { loading: false, error: null, opt: action.opt }); case _types2.default.player.set_param: return _extends({}, state, { opt: _extends({}, state.opt, _defineProperty({}, action.key, action.value)) }); case _types2.default.socket.list_checkpoints: return _extends({}, state, { checkpoints: action.checkpoints, epochs: [] }); case _types2.default.socket.list_epochs: if (action.epochs === "not found") return _extends({}, state, { epochs: [] }); return _extends({}, state, { epochs: (action.epochs || []).map(function (a) { return [a == 'latest' ? Infinity : a, a]; }).sort(function (a, b) { return a[0] - b[0]; }).map(function (a) { return a[1]; }) }); case _types2.default.socket.list_sequences: return _extends({}, state, { sequences: action.sequences }); case _types2.default.player.loading_sequence: return _extends({}, state, { opt: _extends({}, state.opt, { sequence_name: action.sequence_name }) }); case _types2.default.player.loading_checkpoint: return _extends({}, state, { opt: _extends({}, state.opt, { checkpoint_name: action.checkpoint_name, epoch: action.epoch }) }); case _types2.default.player.set_fps: return _extends({}, state, { fps: action.fps }); case _types2.default.system.stdout: if (action.data.processor === 'gpu') { return _extends({}, state, { last_message: action.data.data }); } return state; case _types2.default.player.current_frame: return action.meta ? _extends({}, state, { frame: action.meta }) : state; case _types2.default.player.pausing: return _extends({}, state, { playing: false }); case _types2.default.player.playing: return _extends({}, state, { playing: true }); case _types2.default.player.start_recording: return _extends({}, state, { opt: _extends({}, state.opt, { recording: true }) }); case _types2.default.player.add_record_frame: return _extends({}, state, { opt: _extends({}, state.opt, { recordFrames: (state.opt.recordFrames || 0) + 1 }) }); case _types2.default.player.save_frame: _fileSaver2.default.saveAs(action.blob, state.opt.checkpoint_name + "_" + state.opt.sequence + "_" + (0, _moment2.default)().format("YYYYMMDD_HHmm") + ".png"); return state; case _types2.default.player.saving_video: return _extends({}, state, { opt: _extends({}, state.opt, { savingVideo: true }) }); case _types2.default.player.save_video: _fileSaver2.default.saveAs(action.blob, state.opt.checkpoint_name + "_" + state.opt.sequence + "_" + (0, _moment2.default)().format("YYYYMMDD_HHmm") + ".webm"); return _extends({}, state, { opt: _extends({}, state.opt, { recording: false, savingVideo: false, recordFrames: 0 }) }); default: return state; } }; exports.default = liveReducer; /***/ }), /***/ "./app/client/live/player.js": /*!***********************************!*\ !*** ./app/client/live/player.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.startSynthesizing = startSynthesizing; exports.stopSynthesizing = stopSynthesizing; exports.startRecording = startRecording; exports.stopRecording = stopRecording; exports.saveFrame = saveFrame; exports.onFrame = onFrame; exports.toggleFPS = toggleFPS; exports.startWatchingFPS = startWatchingFPS; exports.stopWatchingFPS = stopWatchingFPS; var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); var _whammy = __webpack_require__(/*! ./whammy */ "./app/client/live/whammy.js"); var _whammy2 = _interopRequireDefault(_whammy); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _pix2wav = __webpack_require__(/*! ../audio/pix2wav */ "./app/client/audio/pix2wav.js"); var pix2wav = _interopRequireWildcard(_pix2wav); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var fps = 0, last_frame = void 0; var recording = false, saving = false, synthesizing = false; var videoWriter = void 0; function startSynthesizing() { synthesizing = true; } function stopSynthesizing() { synthesizing = false; } function startRecording() { videoWriter = new _whammy2.default.Video(25, 0.95); recording = true; _store.store.dispatch({ type: _types2.default.player.start_recording }); } function stopRecording() { if (!recording) return; recording = false; _store.store.dispatch({ type: _types2.default.player.saving_video }); videoWriter.compile(false, function (blob) { // console.log(blob) _store.store.dispatch({ type: _types2.default.player.save_video, blob: blob }); }); } function saveFrame() { saving = true; } function onFrame(data) { var blob = new Blob([data.frame], { type: 'image/jpg' }); var url = URL.createObjectURL(blob); var img = new Image(); var canvas = document.querySelector('.player canvas'); if (!canvas) return console.error('no canvas for frame'); img.onload = function () { img.onload = null; last_frame = data.meta; URL.revokeObjectURL(url); var ctx = canvas.getContext('2d-lodpi'); ctx.drawImage(img, 0, 0, canvas.width, canvas.height); if (synthesizing) { var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); pix2wav.play({ imageData: imageData }); } if (recording) { console.log('record frame'); videoWriter.add(canvas); _store.store.dispatch({ type: _types2.default.player.add_record_frame }); } if (saving) { saving = false; canvas.toBlob(function (blob) { _store.store.dispatch({ type: _types2.default.player.save_frame, blob: blob }); }); } fps += 1; }; img.src = url; } var previousValue = void 0, currentValue = void 0; function toggleFPS(state) { currentValue = typeof state !== 'undefined' ? state : _store.store.getState().live.playing; if (previousValue !== currentValue) { if (currentValue) { startWatchingFPS(); } else { stopWatchingFPS(); } } previousValue = currentValue; } var fpsInterval = void 0; function startWatchingFPS() { clearInterval(fpsInterval); fpsInterval = setInterval(function () { _store.store.dispatch({ type: _types2.default.player.set_fps, fps: fps }); _store.store.dispatch({ type: _types2.default.player.current_frame, meta: last_frame }); fps = 0; }, 1000); } function stopWatchingFPS() { clearInterval(fpsInterval); } /***/ }), /***/ "./app/client/live/whammy.js": /*!***********************************!*\ !*** ./app/client/live/whammy.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _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; }; module.exports = function () { // in this case, frames has a very specific meaning, which will be // detailed once i finish writing the code function toWebM(frames, outputAsArray) { var info = checkFrames(frames); //max duration by cluster in milliseconds var CLUSTER_MAX_DURATION = 30000; var EBML = [{ "id": 0x1a45dfa3, // EBML "data": [{ "data": 1, "id": 0x4286 // EBMLVersion }, { "data": 1, "id": 0x42f7 // EBMLReadVersion }, { "data": 4, "id": 0x42f2 // EBMLMaxIDLength }, { "data": 8, "id": 0x42f3 // EBMLMaxSizeLength }, { "data": "webm", "id": 0x4282 // DocType }, { "data": 2, "id": 0x4287 // DocTypeVersion }, { "data": 2, "id": 0x4285 // DocTypeReadVersion }] }, { "id": 0x18538067, // Segment "data": [{ "id": 0x1549a966, // Info "data": [{ "data": 1e6, //do things in millisecs (num of nanosecs for duration scale) "id": 0x2ad7b1 // TimecodeScale }, { "data": "whammy", "id": 0x4d80 // MuxingApp }, { "data": "whammy", "id": 0x5741 // WritingApp }, { "data": doubleToString(info.duration), "id": 0x4489 // Duration }] }, { "id": 0x1654ae6b, // Tracks "data": [{ "id": 0xae, // TrackEntry "data": [{ "data": 1, "id": 0xd7 // TrackNumber }, { "data": 1, "id": 0x73c5 // TrackUID }, { "data": 0, "id": 0x9c // FlagLacing }, { "data": "und", "id": 0x22b59c // Language }, { "data": "V_VP8", "id": 0x86 // CodecID }, { "data": "VP8", "id": 0x258688 // CodecName }, { "data": 1, "id": 0x83 // TrackType }, { "id": 0xe0, // Video "data": [{ "data": info.width, "id": 0xb0 // PixelWidth }, { "data": info.height, "id": 0xba // PixelHeight }] }] }] }, { "id": 0x1c53bb6b, // Cues "data": [ //cue insertion point ] //cluster insertion point }] }]; var segment = EBML[1]; var cues = segment.data[2]; //Generate clusters (max duration) var frameNumber = 0; var clusterTimecode = 0; while (frameNumber < frames.length) { var cuePoint = { "id": 0xbb, // CuePoint "data": [{ "data": Math.round(clusterTimecode), "id": 0xb3 // CueTime }, { "id": 0xb7, // CueTrackPositions "data": [{ "data": 1, "id": 0xf7 // CueTrack }, { "data": 0, // to be filled in when we know it "size": 8, "id": 0xf1 // CueClusterPosition }] }] }; cues.data.push(cuePoint); var clusterFrames = []; var clusterDuration = 0; do { clusterFrames.push(frames[frameNumber]); clusterDuration += frames[frameNumber].duration; frameNumber++; } while (frameNumber < frames.length && clusterDuration < CLUSTER_MAX_DURATION); var clusterCounter = 0; var cluster = { "id": 0x1f43b675, // Cluster "data": [{ "data": Math.round(clusterTimecode), "id": 0xe7 // Timecode }].concat(clusterFrames.map(function (webp) { var block = makeSimpleBlock({ discardable: 0, frame: webp.data.slice(4), invisible: 0, keyframe: 1, lacing: 0, trackNum: 1, timecode: Math.round(clusterCounter) }); clusterCounter += webp.duration; return { data: block, id: 0xa3 }; })) //Add cluster to segment };segment.data.push(cluster); clusterTimecode += clusterDuration; } //First pass to compute cluster positions var position = 0; for (var i = 0; i < segment.data.length; i++) { if (i >= 3) { cues.data[i - 3].data[1].data[1].data = position; } var data = generateEBML([segment.data[i]], outputAsArray); position += data.size || data.byteLength || data.length; if (i != 2) { // not cues //Save results to avoid having to encode everything twice segment.data[i] = data; } } return generateEBML(EBML, outputAsArray); } // sums the lengths of all the frames and gets the duration, woo function checkFrames(frames) { var width = frames[0].width, height = frames[0].height, duration = frames[0].duration; for (var i = 1; i < frames.length; i++) { if (frames[i].width != width) throw "Frame " + (i + 1) + " has a different width"; if (frames[i].height != height) throw "Frame " + (i + 1) + " has a different height"; if (frames[i].duration < 0 || frames[i].duration > 0x7fff) throw "Frame " + (i + 1) + " has a weird duration (must be between 0 and 32767)"; duration += frames[i].duration; } return { duration: duration, width: width, height: height }; } function numToBuffer(num) { var parts = []; while (num > 0) { parts.push(num & 0xff); num = num >> 8; } return new Uint8Array(parts.reverse()); } function numToFixedBuffer(num, size) { var parts = new Uint8Array(size); for (var i = size - 1; i >= 0; i--) { parts[i] = num & 0xff; num = num >> 8; } return parts; } function strToBuffer(str) { // return new Blob([str]); var arr = new Uint8Array(str.length); for (var i = 0; i < str.length; i++) { arr[i] = str.charCodeAt(i); } return arr; // this is slower // return new Uint8Array(str.split('').map(function(e){ // return e.charCodeAt(0) // })) } //sorry this is ugly, and sort of hard to understand exactly why this was done // at all really, but the reason is that there's some code below that i dont really // feel like understanding, and this is easier than using my brain. function bitsToBuffer(bits) { var data = []; var pad = bits.length % 8 ? new Array(1 + 8 - bits.length % 8).join('0') : ''; bits = pad + bits; for (var i = 0; i < bits.length; i += 8) { data.push(parseInt(bits.substr(i, 8), 2)); } return new Uint8Array(data); } function generateEBML(json, outputAsArray) { var ebml = []; for (var i = 0; i < json.length; i++) { if (!('id' in json[i])) { //already encoded blob or byteArray ebml.push(json[i]); continue; } var data = json[i].data; if ((typeof data === "undefined" ? "undefined" : _typeof(data)) == 'object') data = generateEBML(data, outputAsArray); if (typeof data == 'number') data = 'size' in json[i] ? numToFixedBuffer(data, json[i].size) : bitsToBuffer(data.toString(2)); if (typeof data == 'string') data = strToBuffer(data); if (data.length) { var z = z; } var len = data.size || data.byteLength || data.length; var zeroes = Math.ceil(Math.ceil(Math.log(len) / Math.log(2)) / 8); var size_str = len.toString(2); var padded = new Array(zeroes * 7 + 7 + 1 - size_str.length).join('0') + size_str; var size = new Array(zeroes).join('0') + '1' + padded; //i actually dont quite understand what went on up there, so I'm not really //going to fix this, i'm probably just going to write some hacky thing which //converts that string into a buffer-esque thing ebml.push(numToBuffer(json[i].id)); ebml.push(bitsToBuffer(size)); ebml.push(data); } //output as blob or byteArray if (outputAsArray) { //convert ebml to an array var buffer = toFlatArray(ebml); return new Uint8Array(buffer); } else { return new Blob(ebml, { type: "video/webm" }); } } function toFlatArray(arr, outBuffer) { if (outBuffer == null) { outBuffer = []; } for (var i = 0; i < arr.length; i++) { if (_typeof(arr[i]) == 'object') { //an array toFlatArray(arr[i], outBuffer); } else { //a simple element outBuffer.push(arr[i]); } } return outBuffer; } //OKAY, so the following two functions are the string-based old stuff, the reason they're //still sort of in here, is that they're actually faster than the new blob stuff because //getAsFile isn't widely implemented, or at least, it doesn't work in chrome, which is the // only browser which supports get as webp //Converting between a string of 0010101001's and binary back and forth is probably inefficient //TODO: get rid of this function function toBinStr_old(bits) { var data = ''; var pad = bits.length % 8 ? new Array(1 + 8 - bits.length % 8).join('0') : ''; bits = pad + bits; for (var i = 0; i < bits.length; i += 8) { data += String.fromCharCode(parseInt(bits.substr(i, 8), 2)); } return data; } function generateEBML_old(json) { var ebml = ''; for (var i = 0; i < json.length; i++) { var data = json[i].data; if ((typeof data === "undefined" ? "undefined" : _typeof(data)) == 'object') data = generateEBML_old(data); if (typeof data == 'number') data = toBinStr_old(data.toString(2)); var len = data.length; var zeroes = Math.ceil(Math.ceil(Math.log(len) / Math.log(2)) / 8); var size_str = len.toString(2); var padded = new Array(zeroes * 7 + 7 + 1 - size_str.length).join('0') + size_str; var size = new Array(zeroes).join('0') + '1' + padded; ebml += toBinStr_old(json[i].id.toString(2)) + toBinStr_old(size) + data; } return ebml; } //woot, a function that's actually written for this project! //this parses some json markup and makes it into that binary magic //which can then get shoved into the matroska comtainer (peaceably) function makeSimpleBlock(data) { var flags = 0; if (data.keyframe) flags |= 128; if (data.invisible) flags |= 8; if (data.lacing) flags |= data.lacing << 1; if (data.discardable) flags |= 1; if (data.trackNum > 127) { throw "TrackNumber > 127 not supported"; } var out = [data.trackNum | 0x80, data.timecode >> 8, data.timecode & 0xff, flags].map(function (e) { return String.fromCharCode(e); }).join('') + data.frame; return out; } // here's something else taken verbatim from weppy, awesome rite? function parseWebP(riff) { var VP8 = riff.RIFF[0].WEBP[0]; var frame_start = VP8.indexOf('\x9d\x01\x2a'); //A VP8 keyframe starts with the 0x9d012a header for (var i = 0, c = []; i < 4; i++) { c[i] = VP8.charCodeAt(frame_start + 3 + i); }var width, horizontal_scale, height, vertical_scale, tmp; //the code below is literally copied verbatim from the bitstream spec tmp = c[1] << 8 | c[0]; width = tmp & 0x3FFF; horizontal_scale = tmp >> 14; tmp = c[3] << 8 | c[2]; height = tmp & 0x3FFF; vertical_scale = tmp >> 14; return { width: width, height: height, data: VP8, riff: riff }; } // i think i'm going off on a riff by pretending this is some known // idiom which i'm making a casual and brilliant pun about, but since // i can't find anything on google which conforms to this idiomatic // usage, I'm assuming this is just a consequence of some psychotic // break which makes me make up puns. well, enough riff-raff (aha a // rescue of sorts), this function was ripped wholesale from weppy function parseRIFF(string) { var offset = 0; var chunks = {}; while (offset < string.length) { var id = string.substr(offset, 4); chunks[id] = chunks[id] || []; if (id == 'RIFF' || id == 'LIST') { var len = parseInt(string.substr(offset + 4, 4).split('').map(function (i) { var unpadded = i.charCodeAt(0).toString(2); return new Array(8 - unpadded.length + 1).join('0') + unpadded; }).join(''), 2); var data = string.substr(offset + 4 + 4, len); offset += 4 + 4 + len; chunks[id].push(parseRIFF(data)); } else if (id == 'WEBP') { // Use (offset + 8) to skip past "VP8 "/"VP8L"/"VP8X" field after "WEBP" chunks[id].push(string.substr(offset + 8)); offset = string.length; } else { // Unknown chunk type; push entire payload chunks[id].push(string.substr(offset + 4)); offset = string.length; } } return chunks; } // here's a little utility function that acts as a utility for other functions // basically, the only purpose is for encoding "Duration", which is encoded as // a double (considerably more difficult to encode than an integer) function doubleToString(num) { return [].slice.call(new Uint8Array(new Float64Array([num]) //create a float64 array .buffer) //extract the array buffer , 0) // convert the Uint8Array into a regular array .map(function (e) { //since it's a regular array, we can now use map return String.fromCharCode(e); // encode all the bytes individually }).reverse() //correct the byte endianness (assume it's little endian for now) .join(''); // join the bytes in holy matrimony as a string } function WhammyVideo(speed, quality) { // a more abstract-ish API this.frames = []; this.duration = 1000 / speed; this.quality = quality || 0.8; } WhammyVideo.prototype.add = function (frame, duration) { if (typeof duration != 'undefined' && this.duration) throw "you can't pass a duration if the fps is set"; if (typeof duration == 'undefined' && !this.duration) throw "if you don't have the fps set, you need to have durations here."; if (frame.canvas) { //CanvasRenderingContext2D frame = frame.canvas; } if (frame.toDataURL) { // frame = frame.toDataURL('image/webp', this.quality); // quickly store image data so we don't block cpu. encode in compile method. frame = frame.getContext('2d-lodpi').getImageData(0, 0, frame.width, frame.height); } else if (typeof frame != "string") { throw "frame must be a a HTMLCanvasElement, a CanvasRenderingContext2D or a DataURI formatted string"; } if (typeof frame === "string" && !/^data:image\/webp;base64,/ig.test(frame)) { throw "Input must be formatted properly as a base64 encoded DataURI of type image/webp"; } this.frames.push({ image: frame, duration: duration || this.duration }); }; // deferred webp encoding. Draws image data to canvas, then encodes as dataUrl WhammyVideo.prototype.encodeFrames = function (callback) { if (this.frames[0].image instanceof ImageData) { var frames = this.frames; var tmpCanvas = document.createElement('canvas'); var tmpContext = tmpCanvas.getContext('2d-lodpi'); tmpCanvas.width = this.frames[0].image.width; tmpCanvas.height = this.frames[0].image.height; var encodeFrame = function (index) { console.log('encodeFrame', index); var frame = frames[index]; tmpContext.putImageData(frame.image, 0, 0); frame.image = tmpCanvas.toDataURL('image/webp', this.quality); if (index < frames.length - 1) { setTimeout(function () { encodeFrame(index + 1); }, 1); } else { callback(); } }.bind(this); encodeFrame(0); } else { callback(); } }; WhammyVideo.prototype.compile = function (outputAsArray, callback) { this.encodeFrames(function () { var width = 0; var height = 0; var webm = new toWebM(this.frames.map(function (frame) { var webp = parseWebP(parseRIFF(atob(frame.image.slice(23)))); webp.duration = frame.duration; if (!webp || !webp.width || !webp.height) return null; if (!width) width = webp.width;else if (width !== webp.width) return null; if (!height) height = webp.height;else if (height !== webp.height) return null; return webp; }).filter(function (frame) { return !!frame; }), outputAsArray); callback(webm); }.bind(this)); }; return { Video: WhammyVideo, fromImageArray: function fromImageArray(images, fps, outputAsArray) { return toWebM(images.map(function (image) { var webp = parseWebP(parseRIFF(atob(image.slice(23)))); webp.duration = 1000 / fps; return webp; }), outputAsArray); }, toWebM: toWebM // expose methods of madness }; }(); /***/ }), /***/ "./app/client/modules/index.js": /*!*************************************!*\ !*** ./app/client/modules/index.js ***! \*************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _pix2pix = __webpack_require__(/*! ./pix2pix */ "./app/client/modules/pix2pix/index.js"); var _pix2pix2 = _interopRequireDefault(_pix2pix); var _pix2pixhd = __webpack_require__(/*! ./pix2pixhd */ "./app/client/modules/pix2pixhd/index.js"); var _pix2pixhd2 = _interopRequireDefault(_pix2pixhd); var _pix2wav = __webpack_require__(/*! ./pix2wav */ "./app/client/modules/pix2wav/index.js"); var _pix2wav2 = _interopRequireDefault(_pix2wav); var _samplernn = __webpack_require__(/*! ./samplernn */ "./app/client/modules/samplernn/index.js"); var _samplernn2 = _interopRequireDefault(_samplernn); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = { pix2pix: _pix2pix2.default, pix2pixhd: _pix2pixhd2.default, pix2wav: _pix2wav2.default, samplernn: _samplernn2.default }; /***/ }), /***/ "./app/client/modules/module.reducer.js": /*!**********************************************!*\ !*** ./app/client/modules/module.reducer.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.moduleReducer = undefined; var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _pix2pix = __webpack_require__(/*! ./pix2pix/pix2pix.reducer */ "./app/client/modules/pix2pix/pix2pix.reducer.js"); var _pix2pix2 = _interopRequireDefault(_pix2pix); var _pix2pixhd = __webpack_require__(/*! ./pix2pixhd/pix2pixhd.reducer */ "./app/client/modules/pix2pixhd/pix2pixhd.reducer.js"); var _pix2pixhd2 = _interopRequireDefault(_pix2pixhd); var _pix2wav = __webpack_require__(/*! ./pix2wav/pix2wav.reducer */ "./app/client/modules/pix2wav/pix2wav.reducer.js"); var _pix2wav2 = _interopRequireDefault(_pix2wav); var _samplernn = __webpack_require__(/*! ./samplernn/samplernn.reducer */ "./app/client/modules/samplernn/samplernn.reducer.js"); var _samplernn2 = _interopRequireDefault(_samplernn); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var moduleReducer = exports.moduleReducer = (0, _redux.combineReducers)({ pix2pix: _pix2pix2.default, pix2pixhd: _pix2pixhd2.default, pix2wav: _pix2wav2.default, samplernn: _samplernn2.default }); /***/ }), /***/ "./app/client/modules/pix2pix/index.js": /*!*********************************************!*\ !*** ./app/client/modules/pix2pix/index.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2pix = __webpack_require__(/*! ./views/pix2pix.new */ "./app/client/modules/pix2pix/views/pix2pix.new.js"); var _pix2pix2 = _interopRequireDefault(_pix2pix); var _pix2pix3 = __webpack_require__(/*! ./views/pix2pix.show */ "./app/client/modules/pix2pix/views/pix2pix.show.js"); var _pix2pix4 = _interopRequireDefault(_pix2pix3); var _pix2pix5 = __webpack_require__(/*! ./views/pix2pix.live */ "./app/client/modules/pix2pix/views/pix2pix.live.js"); var _pix2pix6 = _interopRequireDefault(_pix2pix5); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var router = function () { function router() { _classCallCheck(this, router); } _createClass(router, [{ key: 'componentWillMount', value: function componentWillMount() { _actions2.default.system.changeTool('pix2pix'); document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #fde, #ffe)'; } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps() { _actions2.default.system.changeTool('pix2pix'); document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #fde, #ffe)'; } }, { key: 'render', value: function render() { return (0, _preact.h)( 'section', null, (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pix/new/', component: _pix2pix2.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pix/sequences/', component: _pix2pix4.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pix/sequences/:id/', component: _pix2pix4.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pix/live/', component: _pix2pix6.default }) ); } }]); return router; }(); function links() { return [{ url: '/pix2pix/new/', name: 'new' }, { url: '/pix2pix/sequences/', name: 'sequences' }, { url: '/pix2pix/live/', name: 'live' }]; } exports.default = { name: 'pix2pix', router: router, links: links }; /***/ }), /***/ "./app/client/modules/pix2pix/pix2pix.actions.js": /*!*******************************************************!*\ !*** ./app/client/modules/pix2pix/pix2pix.actions.js ***! \*******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.load_directories = undefined; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _dataset = __webpack_require__(/*! ../../dataset/dataset.loader */ "./app/client/dataset/dataset.loader.js"); var datasetLoader = _interopRequireWildcard(_dataset); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2pix = __webpack_require__(/*! ./pix2pix.module */ "./app/client/modules/pix2pix/pix2pix.module.js"); var _pix2pix2 = _interopRequireDefault(_pix2pix); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var load_directories = exports.load_directories = function load_directories(id) { return function (dispatch) { var module = _pix2pix2.default.name; _util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_directory({ module: module, dir: 'sequences/pix2pix/' }), _actions2.default.socket.list_directory({ module: module, dir: 'datasets/pix2pix/' }), _actions2.default.socket.list_directory({ module: module, dir: 'checkpoints/pix2pix/' })], function (percent, i, n) { console.log('pix2pix load progress', i, n); dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); }).then(function (res) { var _res = _slicedToArray(res, 4), datasetApiReport = _res[0], sequences = _res[1], datasets = _res[2], checkpoints = _res[3]; //, datasets, results, output, datasetUsage, lossReport] = res var folderLookup = datasetApiReport.folderLookup, fileLookup = datasetApiReport.fileLookup, datasetLookup = datasetApiReport.datasetLookup, folders = datasetApiReport.folders, files = datasetApiReport.files, unsortedFolder = datasetApiReport.unsortedFolder; // console.log(datasetUsage) var sequenceDirectories = sequences.filter(function (s) { return s.dir; }); // console.log(sequenceDirectories) sequenceDirectories.forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.isBuilt = true; // console.log(dir.name, dataset) }); datasets.filter(function (s) { return s.dir; }).forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.hasDataset = true; }); var checkpointDirectories = checkpoints.filter(function (s) { return s.dir; }); checkpointDirectories.forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.hasCheckpoints = true; dataset.checkpoints = [dir]; }); // console.log(res) // flatDatasets.forEach(file => { // file.uuid = uuidv1() // fileLookup[file.uuid] = file // const name = file.name.split('.')[0] // const dataset = datasetLoader.getDataset(module, datasetLookup, name, unsortedFolder, file.date) // file.persisted = false // dataset.input.push(file.uuid) // }) // // exp:coccokit_3-frame_sizes:8,2-n_rnn:2-dataset:coccokit_3 // const checkpoints = results.filter(s => s.dir).map(s => { // const checkpoint = s.name // .split('-') // .map(s => s.split(':')) // .filter(b => b.length && b[1]) // .reduce((a,b) => (a[b[0]] = b[1]) && a, {}) // checkpoint.name = checkpoint.name || checkpoint.dataset || checkpoint.exp // checkpoint.date = s.date // checkpoint.dir = s // checkpoint.persisted = false // const dataset = datasetLoader.getDataset(module, datasetLookup, checkpoint.name, unsortedFolder, checkpoint.date) // const loss = lossReport[checkpoint.name] // if (loss) { // dataset.epoch = checkpoint.epoch = loss.length // checkpoint.training_loss = loss // } // dataset.checkpoints.push(checkpoint) // return checkpoint // }) // output.map(file => { // file.uuid = uuidv1() // fileLookup[file.uuid] = file // const pair = file.name.split('.')[0].split('-') // const dataset = datasetLoader.getDataset(module, datasetLookup, pair[0], unsortedFolder, file.date) // file.persisted = false // file.epoch = parseInt(file.epoch || pair[1].replace(/^\D+/, '')) || 0 // dataset.epoch = Math.max(file.epoch, dataset.epoch || 0) // // here check if the file exists in dataset, if so just check that it's persisted // const found = dataset.output.some(file_id => { // // if (f.name === // if (fileLookup[file_id].name === file.name) { // fileLookup[file_id].persisted = true // return true // } // return false // }) // if (! found) { // dataset.output.push(file.uuid) // } // }) dispatch({ type: _types2.default.dataset.load, data: { module: module, folderLookup: folderLookup, fileLookup: fileLookup, datasetLookup: datasetLookup, folders: folders, files: files, sequences: sequenceDirectories, datasets: datasets, checkpoints: checkpointDirectories } }); if (id) { console.log('folder id', id); dispatch({ type: _types2.default.dataset.set_folder, data: { folder_id: id, module: module } }); } }).catch(function (e) { console.error(e); }); }; }; /***/ }), /***/ "./app/client/modules/pix2pix/pix2pix.module.js": /*!******************************************************!*\ !*** ./app/client/modules/pix2pix/pix2pix.module.js ***! \******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var pix2pixModule = { name: 'pix2pix', displayName: 'Pix2Pix', datatype: 'video' }; exports.default = pix2pixModule; /***/ }), /***/ "./app/client/modules/pix2pix/pix2pix.reducer.js": /*!*******************************************************!*\ !*** ./app/client/modules/pix2pix/pix2pix.reducer.js ***! \*******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _dataset = __webpack_require__(/*! ../../dataset/dataset.reducer */ "./app/client/dataset/dataset.reducer.js"); var _dataset2 = _interopRequireDefault(_dataset); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var pix2pixInitialState = { loading: true, progress: { i: 0, n: 0 }, error: null, folder_id: 0, data: null }; var pix2pixReducer = function pix2pixReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : pix2pixInitialState; var action = arguments[1]; if (action.data && action.data.module === 'pix2pix') { state = (0, _dataset2.default)(state, action); } switch (action.type) { default: return state; } }; exports.default = pix2pixReducer; /***/ }), /***/ "./app/client/modules/pix2pix/pix2pix.tasks.js": /*!*****************************************************!*\ !*** ./app/client/modules/pix2pix/pix2pix.tasks.js ***! \*****************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.train_task = exports.live_task = exports.fetch_task = undefined; var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var fetch_task = exports.fetch_task = function fetch_task(url, file_id, dataset) { return function (dispatch) { if (!url) return console.log('input file inaccessible (no url)'); var task = { module: 'pix2pix', activity: 'fetch', dataset: dataset, opt: { url: url, file_id: file_id, dataset: dataset } }; return _actions2.default.queue.add_task(task); }; }; var live_task = exports.live_task = function live_task(sequence, checkpoint) { return function (dispatch) { var task = { module: 'pix2pix', activity: 'live', dataset: sequence, checkpoint: checkpoint, opt: { poll_delay: 0.09 } }; console.log(task); console.log('add live task'); return _actions2.default.queue.add_task(task); }; }; var train_task = exports.train_task = function train_task(dataset, folder_id) { var epochs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; return function (dispatch) { var task = { module: 'pix2pix', activity: 'train', dataset: dataset.name, epoch: 0, epochs: epochs, opt: { folder_id: folder_id, load_size: 264 // switch to 256 for pix2wav } }; console.log(task); return _actions2.default.queue.add_task(task); }; }; // export const log_task = (dataset) => dispatch => { // const task = { // module: 'samplernn', // activity: 'log', // dataset: dataset.name, // } // return actions.queue.add_task(task) // } // export const clear_cache_task = (dataset) => dispatch => { // const task = { // module: 'samplernn', // activity: 'clear_cache', // dataset: dataset.name, // } // return actions.queue.add_task(task) // } /***/ }), /***/ "./app/client/modules/pix2pix/views/pix2pix.live.js": /*!**********************************************************!*\ !*** ./app/client/modules/pix2pix/views/pix2pix.live.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _common = __webpack_require__(/*! ../../../common/ */ "./app/client/common/index.js"); var _player = __webpack_require__(/*! ../../../live/player */ "./app/client/live/player.js"); var _live = __webpack_require__(/*! ../../../live/live.actions */ "./app/client/live/live.actions.js"); var liveActions = _interopRequireWildcard(_live); var _queue = __webpack_require__(/*! ../../../queue/queue.actions */ "./app/client/queue/queue.actions.js"); var queueActions = _interopRequireWildcard(_queue); var _pix2pix = __webpack_require__(/*! ../pix2pix.tasks */ "./app/client/modules/pix2pix/pix2pix.tasks.js"); var pix2pixTasks = _interopRequireWildcard(_pix2pix); var _pix2pix2 = __webpack_require__(/*! ../pix2pix.actions */ "./app/client/modules/pix2pix/pix2pix.actions.js"); var pix2pixActions = _interopRequireWildcard(_pix2pix2); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Pix2PixLive = function (_Component) { _inherits(Pix2PixLive, _Component); function Pix2PixLive(props) { _classCallCheck(this, Pix2PixLive); // if (! props.pix2pix || ! props.pix2pix.data) { var _this = _possibleConstructorReturn(this, (Pix2PixLive.__proto__ || Object.getPrototypeOf(Pix2PixLive)).call(this)); props.actions.pix2pix.load_directories(); // } props.actions.live.get_params(); // props.actions.live.list_checkpoints('pix2pix') // props.actions.live.list_sequences('pix2pix') _this.changeCheckpoint = _this.changeCheckpoint.bind(_this); _this.changeEpoch = _this.changeEpoch.bind(_this); _this.changeSequence = _this.changeSequence.bind(_this); _this.seek = _this.seek.bind(_this); _this.togglePlaying = _this.togglePlaying.bind(_this); _this.toggleRecording = _this.toggleRecording.bind(_this); return _this; } _createClass(Pix2PixLive, [{ key: 'componentWillUpdate', value: function componentWillUpdate(nextProps) { if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { this.props.actions.live.list_epochs('pix2pix', nextProps.opt.checkpoint_name); } } }, { key: 'changeCheckpoint', value: function changeCheckpoint(field, checkpoint_name) { this.props.actions.live.load_epoch(checkpoint_name, 'latest'); } }, { key: 'changeEpoch', value: function changeEpoch(field, epoch_name) { this.props.actions.live.load_epoch(this.props.opt.checkpoint_name, epoch_name); } }, { key: 'changeSequence', value: function changeSequence(field, sequence) { console.log('load sequence', sequence); this.props.actions.live.load_sequence(sequence); } }, { key: 'seek', value: function seek(percentage) { var frame = Math.floor(percentage * (parseInt(this.props.frame.sequence_len) || 1) + 1); console.log("seek to frame", percentage, frame); this.props.actions.live.seek(frame); } }, { key: 'start', value: function start() { // console.log(this.props) var sequence = this.props.pix2pix.data.sequences[0].name; var checkpoint = this.props.pix2pix.data.checkpoints[0].name; console.log('starting up!', sequence, checkpoint); this.props.actions.tasks.live_task(sequence, checkpoint); } }, { key: 'interrupt', value: function interrupt() { this.props.actions.queue.stop_task('gpu'); } }, { key: 'togglePlaying', value: function togglePlaying() { if (this.props.opt.processing) { this.props.actions.live.pause(); } else { this.props.actions.live.play(); } } }, { key: 'toggleRecording', value: function toggleRecording() { if (this.props.opt.recording) { (0, _player.stopRecording)(); this.props.actions.live.pause(); } else { (0, _player.startRecording)(); } } }, { key: 'render', value: function render() { // console.log(this.props) if (this.props.pix2pix.loading) { return (0, _preact.h)(_common.Loading, null); } return (0, _preact.h)( 'div', { className: 'app centered' }, (0, _preact.h)(_common.Player, { width: 424, height: 256 }), (0, _preact.h)( 'div', { className: 'params row' }, (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Playback', noToggle: true }, (0, _preact.h)(_common.Select, { name: 'send_image', title: 'view mode', options: ['a', 'b', 'sequence', 'recursive'], onChange: this.props.actions.live.set_param }), (0, _preact.h)(_common.Select, { name: 'sequence_name', title: 'sequence', options: this.props.pix2pix.data.sequences.map(function (file) { return file.name; }), onChange: this.changeSequence }), (0, _preact.h)(_common.Select, { name: 'checkpoint_name', title: 'checkpoint', options: this.props.pix2pix.data.checkpoints.map(function (file) { return file.name; }), onChange: this.changeCheckpoint }), (0, _preact.h)(_common.Select, { name: 'epoch', title: 'epoch', options: this.props.epochs, onChange: this.changeEpoch }), (0, _preact.h)(_common.Slider, { name: 'position', min: 0.0, max: 1.0, type: 'float', value: (this.props.frame.sequence_i || 0) / (this.props.frame.sequence_len || 1), onChange: this.seek }), (0, _preact.h)(_common.Slider, { live: true, name: 'frame_delay', min: 0.05, max: 2.0, type: 'float' }), this.renderRestartButton(), (0, _preact.h)( _common.Button, { title: this.props.opt.savingVideo ? 'Saving video...' : this.props.opt.recording ? 'Recording (' + timeInSeconds(this.props.opt.recordFrames / 25) + ')' : 'Record video', onClick: this.toggleRecording }, this.props.opt.savingVideo ? 'Saving' : this.props.opt.recording ? 'Recording' : 'Record' ), (0, _preact.h)( _common.Button, { title: 'Save frame', onClick: _player.saveFrame }, 'Save' ), (0, _preact.h)(_common.ParamGroup, { title: 'Render on server', name: 'store_b', onToggle: function onToggle(value) { // now storing frames on server... } }), (0, _preact.h)( 'p', { 'class': 'last_message' }, this.props.last_message ) ) ), (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Transition', name: 'transition' }, (0, _preact.h)(_common.Slider, { live: true, name: 'transition_period', min: 10, max: 5000, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'transition_min', min: 0.001, max: 0.2, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'transition_max', min: 0.1, max: 1.0, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Recursion', name: 'recursive' }, (0, _preact.h)(_common.Slider, { live: true, name: 'recursive_frac', min: 0.0, max: 0.5, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'recurse_roll', min: -64, max: 64, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'recurse_roll_axis', min: 0, max: 1, type: 'int' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Sequence', name: 'sequence' }, (0, _preact.h)(_common.Slider, { live: true, name: 'sequence_frac', min: 0.0, max: 0.5, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'process_frac', min: 0, max: 1, type: 'float' }) ) ), (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Clahe', name: 'clahe' }, (0, _preact.h)(_common.Slider, { live: true, name: 'clip_limit', min: 1.0, max: 4.0, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Posterize', name: 'posterize' }, (0, _preact.h)(_common.Slider, { live: true, name: 'spatial_window', min: 2, max: 128, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'color_window', min: 2, max: 128, type: 'int' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Blur', name: 'blur' }, (0, _preact.h)(_common.Slider, { live: true, name: 'blur_radius', min: 3, max: 7, type: 'odd' }), (0, _preact.h)(_common.Slider, { live: true, name: 'blur_sigma', min: 0, max: 2, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Canny Edge Detection', name: 'canny' }, (0, _preact.h)(_common.Slider, { live: true, name: 'canny_lo', min: 10, max: 200, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'canny_hi', min: 10, max: 200, type: 'int' }) ) ) ) ); } }, { key: 'renderRestartButton', value: function renderRestartButton() { var _this2 = this; if (this.props.runner.gpu.status === 'IDLE') { return (0, _preact.h)( _common.Button, { title: 'GPU Idle', onClick: function onClick() { return _this2.start(); } }, 'Start' ); } if (this.props.runner.gpu.task.module !== 'pix2pix') { return (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ); } if (!this.props.opt.processing) { return (0, _preact.h)( 'div', null, (0, _preact.h)( _common.Button, { title: 'Not processing', onClick: this.togglePlaying }, 'Restart' ), (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ) ); } return (0, _preact.h)( 'div', null, (0, _preact.h)( _common.Button, { title: 'Processing', onClick: this.togglePlaying }, 'Pause' ), (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ) ); } }]); return Pix2PixLive; }(_preact.Component); function timeInSeconds(n) { return n.toFixed(1) + ' s.'; } var mapStateToProps = function mapStateToProps(state) { return { last_message: state.live.last_message, opt: state.live.opt, frame: state.live.frame, checkpoints: state.live.checkpoints, epochs: state.live.epochs, sequences: state.live.sequences, runner: state.system.runner, pix2pix: state.module.pix2pix }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: { live: (0, _redux.bindActionCreators)(liveActions, dispatch), queue: (0, _redux.bindActionCreators)(queueActions, dispatch), pix2pix: (0, _redux.bindActionCreators)(pix2pixActions, dispatch), tasks: (0, _redux.bindActionCreators)(pix2pixTasks, dispatch), s: s } }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixLive); /***/ }), /***/ "./app/client/modules/pix2pix/views/pix2pix.new.js": /*!*********************************************************!*\ !*** ./app/client/modules/pix2pix/views/pix2pix.new.js ***! \*********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); var _pix2pix = __webpack_require__(/*! ../pix2pix.actions */ "./app/client/modules/pix2pix/pix2pix.actions.js"); var pix2pixActions = _interopRequireWildcard(_pix2pix); var _pix2pix2 = __webpack_require__(/*! ../pix2pix.module */ "./app/client/modules/pix2pix/pix2pix.module.js"); var _pix2pix3 = _interopRequireDefault(_pix2pix2); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function Pix2PixNew(props) { return (0, _preact.h)(_common.Views.New, { db: props.pix2pix, path: '/pix2pix/sequences/', actions: props.actions, module: _pix2pix3.default, history: props.history }); } var mapStateToProps = function mapStateToProps(state) { return { pix2pix: state.module.pix2pix }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(pix2pixActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixNew); /***/ }), /***/ "./app/client/modules/pix2pix/views/pix2pix.show.js": /*!**********************************************************!*\ !*** ./app/client/modules/pix2pix/views/pix2pix.show.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2pix = __webpack_require__(/*! ../pix2pix.actions */ "./app/client/modules/pix2pix/pix2pix.actions.js"); var pix2pixActions = _interopRequireWildcard(_pix2pix); var _pix2pix2 = __webpack_require__(/*! ../pix2pix.tasks */ "./app/client/modules/pix2pix/pix2pix.tasks.js"); var pix2pixTasks = _interopRequireWildcard(_pix2pix2); var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); var _dataset = __webpack_require__(/*! ../../../dataset/dataset.form */ "./app/client/dataset/dataset.form.js"); var _dataset2 = _interopRequireDefault(_dataset); var _dataset3 = __webpack_require__(/*! ../../../dataset/dataset.new */ "./app/client/dataset/dataset.new.js"); var _dataset4 = _interopRequireDefault(_dataset3); var _upload = __webpack_require__(/*! ../../../dataset/upload.status */ "./app/client/dataset/upload.status.js"); var _upload2 = _interopRequireDefault(_upload); var _dataset5 = __webpack_require__(/*! ../../../dataset/dataset.component */ "./app/client/dataset/dataset.component.js"); var _dataset6 = _interopRequireDefault(_dataset5); var _pix2pix3 = __webpack_require__(/*! ../pix2pix.module */ "./app/client/modules/pix2pix/pix2pix.module.js"); var _pix2pix4 = _interopRequireDefault(_pix2pix3); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Pix2pixShow = function (_Component) { _inherits(Pix2pixShow, _Component); function Pix2pixShow(props) { _classCallCheck(this, Pix2pixShow); var _this = _possibleConstructorReturn(this, (Pix2pixShow.__proto__ || Object.getPrototypeOf(Pix2pixShow)).call(this, props)); _this.datasetActions = _this.datasetActions.bind(_this); return _this; } _createClass(Pix2pixShow, [{ key: 'componentWillMount', value: function componentWillMount() { var id = this.props.match.params.id || localStorage.getItem('pix2pix.last_id'); console.log('load dataset:', id); var _props = this.props, match = _props.match, pix2pix = _props.pix2pix, actions = _props.actions; if (id === 'new') return; if (id) { if (parseInt(id)) localStorage.setItem('pix2pix.last_id', id); if (!pix2pix.folder || pix2pix.folder.id !== id) { actions.load_directories(id); } } else { this.props.history.push('/pix2pix/new/'); } } }, { key: 'render', value: function render() { var _props2 = this.props, pix2pix = _props2.pix2pix, match = _props2.match, history = _props2.history; var _ref = pix2pix.data || {}, folderLookup = _ref.folderLookup; var folder = (folderLookup || {})[pix2pix.folder_id] || {}; return (0, _preact.h)( 'div', { className: 'app pix2pix' }, (0, _preact.h)( 'div', { 'class': 'heading' }, (0, _preact.h)( 'div', { 'class': 'spaced' }, (0, _preact.h)( 'h1', null, folder ? folder.name : (0, _preact.h)(_common.Loading, null) ), (0, _preact.h)(_upload2.default, null) ) ), (0, _preact.h)( 'div', { className: 'row' }, folder && folder.name && folder.name !== 'unsorted' && (0, _preact.h)(_dataset2.default, { title: 'Add Files', module: _pix2pix4.default, folder: folder, canUpload: true, canAddURL: true }), (0, _preact.h)( 'div', null, (0, _preact.h)(_upload2.default, null), (0, _preact.h)(_common.CurrentTask, null) ) ), (0, _preact.h)(_dataset6.default, { loading: pix2pix.loading, progress: pix2pix.progress, id: pix2pix.folder_id, module: _pix2pix4.default, data: pix2pix.data, folder: folder, history: history, onPickFile: function onPickFile(file, e) { e.preventDefault(); e.stopPropagation(); console.log('picked a file', file); }, datasetActions: this.datasetActions }) ); } }, { key: 'datasetActions', value: function datasetActions(dataset) { var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var _props3 = this.props, pix2pix = _props3.pix2pix, remote = _props3.remote; var input = pix2pix.data.fileLookup[dataset.input[0]]; if (!input) return null; if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null; console.log(dataset); return (0, _preact.h)( 'div', null, (0, _preact.h)( 'div', { 'class': 'actions' }, (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pix.folder_id, 1); } }, 'train' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pix.folder_id, 5); } }, '5x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pix.folder_id, 10); } }, '10x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pix.folder_id, 20); } }, '20x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pix.folder_id, 50); } }, '50x' ) ), dataset.isBuilt ? (0, _preact.h)( 'div', { 'class': 'subtext' }, 'fetched ', (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.clear_cache_task(dataset); } }, 'rm' ) ) : isFetching ? (0, _preact.h)( 'div', { 'class': 'subtext' }, 'fetching' ) : (0, _preact.h)( 'div', { 'class': 'subtext' }, (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.fetch_task(input.url, input.id, dataset.name); } }, 'fetch' ) ) ); } }]); return Pix2pixShow; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { pix2pix: state.module.pix2pix }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(pix2pixActions, dispatch), remote: (0, _redux.bindActionCreators)(pix2pixTasks, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2pixShow); /***/ }), /***/ "./app/client/modules/pix2pixhd/index.js": /*!***********************************************!*\ !*** ./app/client/modules/pix2pixhd/index.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2pixhd = __webpack_require__(/*! ./views/pix2pixhd.new */ "./app/client/modules/pix2pixhd/views/pix2pixhd.new.js"); var _pix2pixhd2 = _interopRequireDefault(_pix2pixhd); var _pix2pixhd3 = __webpack_require__(/*! ./views/pix2pixhd.show */ "./app/client/modules/pix2pixhd/views/pix2pixhd.show.js"); var _pix2pixhd4 = _interopRequireDefault(_pix2pixhd3); var _pix2pixhd5 = __webpack_require__(/*! ./views/pix2pixhd.results */ "./app/client/modules/pix2pixhd/views/pix2pixhd.results.js"); var _pix2pixhd6 = _interopRequireDefault(_pix2pixhd5); var _pix2pixhd7 = __webpack_require__(/*! ./views/pix2pixhd.live */ "./app/client/modules/pix2pixhd/views/pix2pixhd.live.js"); var _pix2pixhd8 = _interopRequireDefault(_pix2pixhd7); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var router = function () { function router() { _classCallCheck(this, router); } _createClass(router, [{ key: 'componentWillMount', value: function componentWillMount() { _actions2.default.system.changeTool('pix2pixhd'); document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #def, #dfe)'; } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps() { _actions2.default.system.changeTool('pix2pixhd'); document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #def, #dfe)'; } }, { key: 'render', value: function render() { return (0, _preact.h)( 'section', null, (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pixhd/new/', component: _pix2pixhd2.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pixhd/sequences/', component: _pix2pixhd4.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pixhd/sequences/:id/', component: _pix2pixhd4.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pixhd/results/', component: _pix2pixhd6.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pixhd/live/', component: _pix2pixhd8.default }) ); } }]); return router; }(); function links() { return [{ url: '/pix2pixhd/new/', name: 'new' }, { url: '/pix2pixhd/sequences/', name: 'sequences' }, { url: '/pix2pixhd/results/', name: 'results' }, { url: '/pix2pixhd/live/', name: 'live' }]; } exports.default = { name: 'pix2pixhd', router: router, links: links }; /***/ }), /***/ "./app/client/modules/pix2pixhd/pix2pixhd.actions.js": /*!***********************************************************!*\ !*** ./app/client/modules/pix2pixhd/pix2pixhd.actions.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.load_directories = undefined; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _dataset = __webpack_require__(/*! ../../dataset/dataset.loader */ "./app/client/dataset/dataset.loader.js"); var datasetLoader = _interopRequireWildcard(_dataset); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2pixhd = __webpack_require__(/*! ./pix2pixhd.module */ "./app/client/modules/pix2pixhd/pix2pixhd.module.js"); var _pix2pixhd2 = _interopRequireDefault(_pix2pixhd); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var load_directories = exports.load_directories = function load_directories(id) { return function (dispatch) { var module = _pix2pixhd2.default.name; _util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_directory({ module: module, dir: 'sequences' }), _actions2.default.socket.list_directory({ module: module, dir: 'datasets' }), _actions2.default.socket.list_directory({ module: module, dir: 'checkpoints' })], function (percent, i, n) { console.log('pix2pixhd load progress', i, n); dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); }).then(function (res) { var _res = _slicedToArray(res, 4), datasetApiReport = _res[0], sequences = _res[1], datasets = _res[2], checkpoints = _res[3]; //, datasets, results, output, datasetUsage, lossReport] = res var folderLookup = datasetApiReport.folderLookup, fileLookup = datasetApiReport.fileLookup, datasetLookup = datasetApiReport.datasetLookup, folders = datasetApiReport.folders, files = datasetApiReport.files, unsortedFolder = datasetApiReport.unsortedFolder; // console.log(datasetUsage) var sequenceDirectories = sequences.filter(function (s) { return s.dir; }); console.log(sequenceDirectories); sequenceDirectories.forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.isBuilt = true; console.log(dir.name, dataset); }); datasets.filter(function (s) { return s.dir; }).forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.hasDataset = true; }); var checkpointDirectories = checkpoints.filter(function (s) { return s.dir; }); checkpointDirectories.forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.hasCheckpoints = true; dataset.checkpoints = [dir]; }); // console.log(res) // flatDatasets.forEach(file => { // file.uuid = uuidv1() // fileLookup[file.uuid] = file // const name = file.name.split('.')[0] // const dataset = datasetLoader.getDataset(module, datasetLookup, name, unsortedFolder, file.date) // file.persisted = false // dataset.input.push(file.uuid) // }) // // exp:coccokit_3-frame_sizes:8,2-n_rnn:2-dataset:coccokit_3 // const checkpoints = results.filter(s => s.dir).map(s => { // const checkpoint = s.name // .split('-') // .map(s => s.split(':')) // .filter(b => b.length && b[1]) // .reduce((a,b) => (a[b[0]] = b[1]) && a, {}) // checkpoint.name = checkpoint.name || checkpoint.dataset || checkpoint.exp // checkpoint.date = s.date // checkpoint.dir = s // checkpoint.persisted = false // const dataset = datasetLoader.getDataset(module, datasetLookup, checkpoint.name, unsortedFolder, checkpoint.date) // const loss = lossReport[checkpoint.name] // if (loss) { // dataset.epoch = checkpoint.epoch = loss.length // checkpoint.training_loss = loss // } // dataset.checkpoints.push(checkpoint) // return checkpoint // }) // output.map(file => { // file.uuid = uuidv1() // fileLookup[file.uuid] = file // const pair = file.name.split('.')[0].split('-') // const dataset = datasetLoader.getDataset(module, datasetLookup, pair[0], unsortedFolder, file.date) // file.persisted = false // file.epoch = parseInt(file.epoch || pair[1].replace(/^\D+/, '')) || 0 // dataset.epoch = Math.max(file.epoch, dataset.epoch || 0) // // here check if the file exists in dataset, if so just check that it's persisted // const found = dataset.output.some(file_id => { // // if (f.name === // if (fileLookup[file_id].name === file.name) { // fileLookup[file_id].persisted = true // return true // } // return false // }) // if (! found) { // dataset.output.push(file.uuid) // } // }) dispatch({ type: _types2.default.dataset.load, data: { module: module, folderLookup: folderLookup, fileLookup: fileLookup, datasetLookup: datasetLookup, folders: folders, files: files, sequences: sequenceDirectories, datasets: datasets, checkpoints: checkpointDirectories } }); if (id) { console.log('folder id', id); dispatch({ type: _types2.default.dataset.set_folder, data: { folder_id: id, module: module } }); } }).catch(function (e) { console.error(e); }); }; }; /***/ }), /***/ "./app/client/modules/pix2pixhd/pix2pixhd.module.js": /*!**********************************************************!*\ !*** ./app/client/modules/pix2pixhd/pix2pixhd.module.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var pix2pixhdModule = { name: 'pix2pixhd', displayName: 'Pix2PixHD', datatype: 'video' }; exports.default = pix2pixhdModule; /***/ }), /***/ "./app/client/modules/pix2pixhd/pix2pixhd.reducer.js": /*!***********************************************************!*\ !*** ./app/client/modules/pix2pixhd/pix2pixhd.reducer.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _dataset = __webpack_require__(/*! ../../dataset/dataset.reducer */ "./app/client/dataset/dataset.reducer.js"); var _dataset2 = _interopRequireDefault(_dataset); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var pix2pixhdInitialState = { loading: true, progress: { i: 0, n: 0 }, error: null, folder_id: 0, data: null }; var pix2pixhdReducer = function pix2pixhdReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : pix2pixhdInitialState; var action = arguments[1]; if (action.data && action.data.module === 'pix2pixhd') { state = (0, _dataset2.default)(state, action); } switch (action.type) { default: return state; } }; exports.default = pix2pixhdReducer; /***/ }), /***/ "./app/client/modules/pix2pixhd/pix2pixhd.tasks.js": /*!*********************************************************!*\ !*** ./app/client/modules/pix2pixhd/pix2pixhd.tasks.js ***! \*********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.live_task = exports.train_task = exports.fetch_task = undefined; var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _pix2pixhd = __webpack_require__(/*! ./pix2pixhd.module */ "./app/client/modules/pix2pixhd/pix2pixhd.module.js"); var _pix2pixhd2 = _interopRequireDefault(_pix2pixhd); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var fetch_task = exports.fetch_task = function fetch_task(url, file_id, dataset) { return function (dispatch) { if (!url) return console.log('input file inaccessible (no url)'); var task = { module: _pix2pixhd2.default.name, activity: 'fetch', dataset: dataset, opt: { url: url, file_id: file_id, dataset: dataset } }; return _actions2.default.queue.add_task(task); }; }; var train_task = exports.train_task = function train_task(dataset, folder_id) { var epochs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; return function (dispatch) { var task = { module: _pix2pixhd2.default.name, activity: 'train', dataset: dataset.name, epoch: 0, epochs: epochs, opt: { folder_id: folder_id, load_size: 264 // switch to 256 for pix2wav } }; console.log(task); return _actions2.default.queue.add_task(task); }; }; var live_task = exports.live_task = function live_task(sequence, checkpoint) { return function (dispatch) { var task = { module: _pix2pixhd2.default.name, activity: 'live', dataset: sequence, checkpoint: checkpoint, opt: { poll_delay: 0.09 } }; console.log(task); console.log('add live task'); return _actions2.default.queue.add_task(task); }; }; /***/ }), /***/ "./app/client/modules/pix2pixhd/views/pix2pixhd.live.js": /*!**************************************************************!*\ !*** ./app/client/modules/pix2pixhd/views/pix2pixhd.live.js ***! \**************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _common = __webpack_require__(/*! ../../../common/ */ "./app/client/common/index.js"); var _player = __webpack_require__(/*! ../../../live/player */ "./app/client/live/player.js"); var _live = __webpack_require__(/*! ../../../live/live.actions */ "./app/client/live/live.actions.js"); var liveActions = _interopRequireWildcard(_live); var _queue = __webpack_require__(/*! ../../../queue/queue.actions */ "./app/client/queue/queue.actions.js"); var queueActions = _interopRequireWildcard(_queue); var _pix2pixhd = __webpack_require__(/*! ../pix2pixhd.tasks */ "./app/client/modules/pix2pixhd/pix2pixhd.tasks.js"); var pix2pixhdTasks = _interopRequireWildcard(_pix2pixhd); var _pix2pixhd2 = __webpack_require__(/*! ../pix2pixhd.actions */ "./app/client/modules/pix2pixhd/pix2pixhd.actions.js"); var pix2pixhdActions = _interopRequireWildcard(_pix2pixhd2); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Pix2PixHDLive = function (_Component) { _inherits(Pix2PixHDLive, _Component); function Pix2PixHDLive(props) { _classCallCheck(this, Pix2PixHDLive); // if (! props.pix2pixhd || ! props.pix2pixhd.data) { var _this = _possibleConstructorReturn(this, (Pix2PixHDLive.__proto__ || Object.getPrototypeOf(Pix2PixHDLive)).call(this)); props.actions.pix2pixhd.load_directories(); // } props.actions.live.get_params(); // props.actions.live.list_checkpoints('pix2pixhd') // props.actions.live.list_sequences('pix2pixhd') _this.changeCheckpoint = _this.changeCheckpoint.bind(_this); _this.changeEpoch = _this.changeEpoch.bind(_this); _this.changeSequence = _this.changeSequence.bind(_this); _this.seek = _this.seek.bind(_this); _this.togglePlaying = _this.togglePlaying.bind(_this); _this.toggleRecording = _this.toggleRecording.bind(_this); return _this; } _createClass(Pix2PixHDLive, [{ key: 'componentWillUpdate', value: function componentWillUpdate(nextProps) { if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { this.props.actions.live.list_epochs('pix2pixhd', nextProps.opt.checkpoint_name); } } }, { key: 'changeCheckpoint', value: function changeCheckpoint(field, checkpoint_name) { this.props.actions.live.load_epoch(checkpoint_name, 'latest'); } }, { key: 'changeEpoch', value: function changeEpoch(field, epoch_name) { this.props.actions.live.load_epoch(this.props.opt.checkpoint_name, epoch_name); } }, { key: 'changeSequence', value: function changeSequence(field, sequence) { console.log('load sequence', sequence); this.props.actions.live.load_sequence(sequence); } }, { key: 'seek', value: function seek(percentage) { var frame = Math.floor(percentage * (parseInt(this.props.frame.sequence_len) || 1) + 1); console.log("seek to frame", percentage, frame); this.props.actions.live.seek(frame); } }, { key: 'start', value: function start() { // console.log(this.props) var sequence = this.props.pix2pixhd.data.sequences[0].name; var checkpoint = this.props.pix2pixhd.data.checkpoints[0].name; console.log('starting up!', sequence, checkpoint); this.props.actions.tasks.live_task(sequence, checkpoint); } }, { key: 'interrupt', value: function interrupt() { this.props.actions.queue.stop_task('gpu'); } }, { key: 'togglePlaying', value: function togglePlaying() { if (this.props.opt.processing) { this.props.actions.live.pause(); } else { this.props.actions.live.play(); } } }, { key: 'toggleRecording', value: function toggleRecording() { if (this.props.opt.recording) { (0, _player.stopRecording)(); this.props.actions.live.pause(); } else { (0, _player.startRecording)(); } } }, { key: 'render', value: function render() { // console.log(this.props) if (this.props.pix2pixhd.loading) { return (0, _preact.h)(_common.Loading, null); } return (0, _preact.h)( 'div', { className: 'app centered' }, (0, _preact.h)(_common.Player, { width: 424, height: 256 }), (0, _preact.h)( 'div', { className: 'params row' }, (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Playback', noToggle: true }, (0, _preact.h)(_common.Select, { name: 'send_image', title: 'view mode', options: ['a', 'b', 'sequence', 'recursive'], onChange: this.props.actions.live.set_param }), (0, _preact.h)(_common.Select, { name: 'sequence_name', title: 'sequence', options: this.props.pix2pixhd.data.sequences.map(function (file) { return file.name; }), onChange: this.changeSequence }), (0, _preact.h)(_common.Select, { name: 'checkpoint_name', title: 'checkpoint', options: this.props.pix2pixhd.data.checkpoints.map(function (file) { return file.name; }), onChange: this.changeCheckpoint }), (0, _preact.h)(_common.Select, { name: 'epoch', title: 'epoch', options: this.props.epochs, onChange: this.changeEpoch }), (0, _preact.h)(_common.Slider, { name: 'position', min: 0.0, max: 1.0, type: 'float', value: (this.props.frame.sequence_i || 0) / (this.props.frame.sequence_len || 1), onChange: this.seek }), (0, _preact.h)(_common.Slider, { live: true, name: 'frame_delay', min: 0.05, max: 2.0, type: 'float' }), this.renderRestartButton(), (0, _preact.h)( _common.Button, { title: this.props.opt.savingVideo ? 'Saving video...' : this.props.opt.recording ? 'Recording (' + timeInSeconds(this.props.opt.recordFrames / 25) + ')' : 'Record video', onClick: this.toggleRecording }, this.props.opt.savingVideo ? 'Saving' : this.props.opt.recording ? 'Recording' : 'Record' ), (0, _preact.h)( _common.Button, { title: 'Save frame', onClick: _player.saveFrame }, 'Save' ), (0, _preact.h)(_common.ParamGroup, { title: 'Render on server', name: 'store_b', onToggle: function onToggle(value) { // now storing frames on server... } }), (0, _preact.h)( 'p', { 'class': 'last_message' }, this.props.last_message ) ) ), (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Transition', name: 'transition' }, (0, _preact.h)(_common.Slider, { live: true, name: 'transition_period', min: 10, max: 5000, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'transition_min', min: 0.001, max: 0.2, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'transition_max', min: 0.1, max: 1.0, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Recursion', name: 'recursive' }, (0, _preact.h)(_common.Slider, { live: true, name: 'recursive_frac', min: 0.0, max: 0.5, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'recurse_roll', min: -64, max: 64, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'recurse_roll_axis', min: 0, max: 1, type: 'int' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Sequence', name: 'sequence' }, (0, _preact.h)(_common.Slider, { live: true, name: 'sequence_frac', min: 0.0, max: 0.5, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'process_frac', min: 0, max: 1, type: 'float' }) ) ), (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Clahe', name: 'clahe' }, (0, _preact.h)(_common.Slider, { live: true, name: 'clip_limit', min: 1.0, max: 4.0, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Posterize', name: 'posterize' }, (0, _preact.h)(_common.Slider, { live: true, name: 'spatial_window', min: 2, max: 128, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'color_window', min: 2, max: 128, type: 'int' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Blur', name: 'blur' }, (0, _preact.h)(_common.Slider, { live: true, name: 'blur_radius', min: 3, max: 7, type: 'odd' }), (0, _preact.h)(_common.Slider, { live: true, name: 'blur_sigma', min: 0, max: 2, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Canny Edge Detection', name: 'canny' }, (0, _preact.h)(_common.Slider, { live: true, name: 'canny_lo', min: 10, max: 200, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'canny_hi', min: 10, max: 200, type: 'int' }) ) ) ) ); } }, { key: 'renderRestartButton', value: function renderRestartButton() { var _this2 = this; if (this.props.runner.gpu.status === 'IDLE') { return (0, _preact.h)( _common.Button, { title: 'GPU Idle', onClick: function onClick() { return _this2.start(); } }, 'Start' ); } if (this.props.runner.gpu.task.module !== 'pix2pixhd') { return (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ); } if (!this.props.opt.processing) { return (0, _preact.h)( 'div', null, (0, _preact.h)( _common.Button, { title: 'Not processing', onClick: this.togglePlaying }, 'Restart' ), (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ) ); } return (0, _preact.h)( 'div', null, (0, _preact.h)( _common.Button, { title: 'Processing', onClick: this.togglePlaying }, 'Pause' ), (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ) ); } }]); return Pix2PixHDLive; }(_preact.Component); function timeInSeconds(n) { return n.toFixed(1) + ' s.'; } var mapStateToProps = function mapStateToProps(state) { return { last_message: state.live.last_message, opt: state.live.opt, frame: state.live.frame, checkpoints: state.live.checkpoints, epochs: state.live.epochs, sequences: state.live.sequences, runner: state.system.runner, pix2pixhd: state.module.pix2pixhd }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: { live: (0, _redux.bindActionCreators)(liveActions, dispatch), queue: (0, _redux.bindActionCreators)(queueActions, dispatch), pix2pixhd: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch), tasks: (0, _redux.bindActionCreators)(pix2pixhdTasks, dispatch), s: s } }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixHDLive); /***/ }), /***/ "./app/client/modules/pix2pixhd/views/pix2pixhd.new.js": /*!*************************************************************!*\ !*** ./app/client/modules/pix2pixhd/views/pix2pixhd.new.js ***! \*************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); var _pix2pixhd = __webpack_require__(/*! ../pix2pixhd.actions */ "./app/client/modules/pix2pixhd/pix2pixhd.actions.js"); var pix2pixhdActions = _interopRequireWildcard(_pix2pixhd); var _pix2pixhd2 = __webpack_require__(/*! ../pix2pixhd.module */ "./app/client/modules/pix2pixhd/pix2pixhd.module.js"); var _pix2pixhd3 = _interopRequireDefault(_pix2pixhd2); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function Pix2PixHDNew(props) { return (0, _preact.h)(_common.Views.New, { db: props.pix2pixhd, path: '/pix2pixhd/sequences/', actions: props.actions, module: _pix2pixhd3.default, history: props.history }); } var mapStateToProps = function mapStateToProps(state) { return { pix2pixhd: state.module.pix2pixhd }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixHDNew); /***/ }), /***/ "./app/client/modules/pix2pixhd/views/pix2pixhd.results.js": /*!*****************************************************************!*\ !*** ./app/client/modules/pix2pixhd/views/pix2pixhd.results.js ***! \*****************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2pixhd = __webpack_require__(/*! ../pix2pixhd.actions */ "./app/client/modules/pix2pixhd/pix2pixhd.actions.js"); var pix2pixhdActions = _interopRequireWildcard(_pix2pixhd); var _pix2pixhd2 = __webpack_require__(/*! ../pix2pixhd.tasks */ "./app/client/modules/pix2pixhd/pix2pixhd.tasks.js"); var pix2pixhdTasks = _interopRequireWildcard(_pix2pixhd2); var _loading = __webpack_require__(/*! ../../../common/loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); var _fileList = __webpack_require__(/*! ../../../common/fileList.component */ "./app/client/common/fileList.component.js"); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Pix2pixHDResults = function (_Component) { _inherits(Pix2pixHDResults, _Component); function Pix2pixHDResults(props) { _classCallCheck(this, Pix2pixHDResults); return _possibleConstructorReturn(this, (Pix2pixHDResults.__proto__ || Object.getPrototypeOf(Pix2pixHDResults)).call(this)); // if (!props.pix2pixhd.data) props.actions.load_directories() } _createClass(Pix2pixHDResults, [{ key: 'render', value: function render() { if (this.props.pix2pixhd.loading) return (0, _preact.h)(_loading2.default, { progress: this.props.pix2pixhd.progress }); // const { folderLookup, fileLookup, datasetLookup } = this.props.samplernn.data // console.log(bestRenders.map(r => r.epoch)) // const path = folder.name === 'unsorted' // ? "/samplernn/import/" // : "/samplernn/datasets/" + folder.id + "/" // return ( // // {folder.name} // { // e.preventDefault() // e.stopPropagation() // console.log('picked a file', file) // this.handlePick(file) // }} // /> // // ) return (0, _preact.h)( 'div', { className: 'app pix2pixhd' }, (0, _preact.h)( 'div', { className: 'heading row middle' }, (0, _preact.h)( 'h1', null, 'Pix2PixHD Results' ) ), (0, _preact.h)('div', { 'class': 'rows params renders' }) ); } }, { key: 'handlePick', value: function handlePick(file) { // this.props.audioPlayer.play(file) } }]); return Pix2pixHDResults; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { pix2pixhd: state.module.pix2pixhd }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch), remote: (0, _redux.bindActionCreators)(pix2pixhdTasks, dispatch) // audioPlayer: bindActionCreators(audioPlayerActions, dispatch), }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2pixHDResults); /***/ }), /***/ "./app/client/modules/pix2pixhd/views/pix2pixhd.show.js": /*!**************************************************************!*\ !*** ./app/client/modules/pix2pixhd/views/pix2pixhd.show.js ***! \**************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2pixhd = __webpack_require__(/*! ../pix2pixhd.actions */ "./app/client/modules/pix2pixhd/pix2pixhd.actions.js"); var pix2pixhdActions = _interopRequireWildcard(_pix2pixhd); var _pix2pixhd2 = __webpack_require__(/*! ../pix2pixhd.tasks */ "./app/client/modules/pix2pixhd/pix2pixhd.tasks.js"); var pix2pixhdTasks = _interopRequireWildcard(_pix2pixhd2); var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); var _dataset = __webpack_require__(/*! ../../../dataset/dataset.form */ "./app/client/dataset/dataset.form.js"); var _dataset2 = _interopRequireDefault(_dataset); var _dataset3 = __webpack_require__(/*! ../../../dataset/dataset.new */ "./app/client/dataset/dataset.new.js"); var _dataset4 = _interopRequireDefault(_dataset3); var _upload = __webpack_require__(/*! ../../../dataset/upload.status */ "./app/client/dataset/upload.status.js"); var _upload2 = _interopRequireDefault(_upload); var _dataset5 = __webpack_require__(/*! ../../../dataset/dataset.component */ "./app/client/dataset/dataset.component.js"); var _dataset6 = _interopRequireDefault(_dataset5); var _pix2pixhd3 = __webpack_require__(/*! ../pix2pixhd.module */ "./app/client/modules/pix2pixhd/pix2pixhd.module.js"); var _pix2pixhd4 = _interopRequireDefault(_pix2pixhd3); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Pix2PixHDShow = function (_Component) { _inherits(Pix2PixHDShow, _Component); function Pix2PixHDShow(props) { _classCallCheck(this, Pix2PixHDShow); var _this = _possibleConstructorReturn(this, (Pix2PixHDShow.__proto__ || Object.getPrototypeOf(Pix2PixHDShow)).call(this, props)); _this.datasetActions = _this.datasetActions.bind(_this); return _this; } _createClass(Pix2PixHDShow, [{ key: 'componentWillMount', value: function componentWillMount() { var id = this.props.match.params.id || localStorage.getItem('pix2pixhd.last_id'); console.log('load dataset:', id); var _props = this.props, match = _props.match, pix2pixhd = _props.pix2pixhd, actions = _props.actions; if (id === 'new') return; if (id) { if (parseInt(id)) localStorage.setItem('pix2pixhd.last_id', id); if (!pix2pixhd.folder || pix2pixhd.folder.id !== id) { actions.load_directories(id); } } else { this.props.history.push('/pix2pixhd/new/'); } } }, { key: 'render', value: function render() { var _props2 = this.props, pix2pixhd = _props2.pix2pixhd, match = _props2.match, history = _props2.history; var _ref = pix2pixhd.data || {}, folderLookup = _ref.folderLookup; var folder = (folderLookup || {})[pix2pixhd.folder_id] || {}; return (0, _preact.h)( 'div', { className: 'app pix2pixhd' }, (0, _preact.h)( 'div', { 'class': 'heading' }, (0, _preact.h)( 'div', { 'class': 'spaced' }, (0, _preact.h)( 'h1', null, folder ? folder.name : (0, _preact.h)(_common.Loading, null) ), (0, _preact.h)(_upload2.default, null) ) ), (0, _preact.h)( 'div', { className: 'row' }, folder && folder.name && folder.name !== 'unsorted' && (0, _preact.h)(_dataset2.default, { title: 'Add Files', module: _pix2pixhd4.default, folder: folder, canUpload: true, canAddURL: true }), (0, _preact.h)( 'div', null, (0, _preact.h)(_upload2.default, null), (0, _preact.h)(_common.CurrentTask, null) ) ), (0, _preact.h)(_dataset6.default, { loading: pix2pixhd.loading, progress: pix2pixhd.progress, id: pix2pixhd.folder_id, module: _pix2pixhd4.default, data: pix2pixhd.data, folder: folder, history: history, onPickFile: function onPickFile(file, e) { e.preventDefault(); e.stopPropagation(); console.log('picked a file', file); }, datasetActions: this.datasetActions }) ); } }, { key: 'datasetActions', value: function datasetActions(dataset) { var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var _props3 = this.props, pix2pixhd = _props3.pix2pixhd, remote = _props3.remote; var input = pix2pixhd.data.fileLookup[dataset.input[0]]; if (!input) return null; if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null; console.log(dataset); return (0, _preact.h)( 'div', null, (0, _preact.h)( 'div', { 'class': 'actions' }, (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pixhd.folder_id, 1); } }, 'train' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pixhd.folder_id, 5); } }, '5x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pixhd.folder_id, 10); } }, '10x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pixhd.folder_id, 20); } }, '20x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2pixhd.folder_id, 50); } }, '50x' ) ), dataset.isBuilt ? (0, _preact.h)( 'div', { 'class': 'subtext' }, 'fetched ', (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.clear_cache_task(dataset); } }, 'rm' ) ) : isFetching ? (0, _preact.h)( 'div', { 'class': 'subtext' }, 'fetching' ) : (0, _preact.h)( 'div', { 'class': 'subtext' }, (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.fetch_task(input.url, input.id, dataset.name); } }, 'fetch' ) ) ); } }]); return Pix2PixHDShow; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { pix2pixhd: state.module.pix2pixhd }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch), remote: (0, _redux.bindActionCreators)(pix2pixhdTasks, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixHDShow); /***/ }), /***/ "./app/client/modules/pix2wav/index.js": /*!*********************************************!*\ !*** ./app/client/modules/pix2wav/index.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2wav = __webpack_require__(/*! ./views/pix2wav.new */ "./app/client/modules/pix2wav/views/pix2wav.new.js"); var _pix2wav2 = _interopRequireDefault(_pix2wav); var _pix2wav3 = __webpack_require__(/*! ./views/pix2wav.show */ "./app/client/modules/pix2wav/views/pix2wav.show.js"); var _pix2wav4 = _interopRequireDefault(_pix2wav3); var _pix2wav5 = __webpack_require__(/*! ./views/pix2wav.live */ "./app/client/modules/pix2wav/views/pix2wav.live.js"); var _pix2wav6 = _interopRequireDefault(_pix2wav5); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var router = function () { function router() { _classCallCheck(this, router); } _createClass(router, [{ key: 'componentWillMount', value: function componentWillMount() { _actions2.default.system.changeTool('pix2wav'); document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #bdf, #def)'; } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps() { _actions2.default.system.changeTool('pix2wav'); document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #bdf, #def)'; } }, { key: 'render', value: function render() { return (0, _preact.h)( 'section', null, (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/new/', component: _pix2wav2.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/datasets/', component: _pix2wav4.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/datasets/:id/', component: _pix2wav4.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/live/', component: _pix2wav6.default }) ); } }]); return router; }(); function links() { return [{ url: '/pix2wav/new/', name: 'new' }, { url: '/pix2wav/datasets/', name: 'datasets' }, { url: '/pix2wav/live/', name: 'live' }]; } exports.default = { name: 'pix2wav', router: router, links: links }; /***/ }), /***/ "./app/client/modules/pix2wav/pix2wav.actions.js": /*!*******************************************************!*\ !*** ./app/client/modules/pix2wav/pix2wav.actions.js ***! \*******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.load_directories = undefined; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _dataset = __webpack_require__(/*! ../../dataset/dataset.loader */ "./app/client/dataset/dataset.loader.js"); var datasetLoader = _interopRequireWildcard(_dataset); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2wav = __webpack_require__(/*! ./pix2wav.module */ "./app/client/modules/pix2wav/pix2wav.module.js"); var _pix2wav2 = _interopRequireDefault(_pix2wav); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var load_directories = exports.load_directories = function load_directories(id) { return function (dispatch) { var module = _pix2wav2.default.name; _util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'sequences/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'datasets/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'checkpoints/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'checkpoints/pix2pix/' })], function (percent, i, n) { console.log('progress', i, n); dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); }).then(function (res) { var _res = _slicedToArray(res, 5), datasetApiReport = _res[0], sequences = _res[1], datasets = _res[2], checkpoints = _res[3], pix2pixCheckpoints = _res[4]; var folderLookup = datasetApiReport.folderLookup, fileLookup = datasetApiReport.fileLookup, datasetLookup = datasetApiReport.datasetLookup, folders = datasetApiReport.folders, files = datasetApiReport.files, unsortedFolder = datasetApiReport.unsortedFolder; var sequenceDirectories = sequences.filter(function (s) { return s.dir; }); sequenceDirectories.forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.isBuilt = true; }); datasets.filter(function (s) { return s.dir; }).forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.hasDataset = true; }); var checkpointDirectories = checkpoints.filter(function (s) { return s.dir; }); checkpointDirectories.forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.hasCheckpoints = true; dir.module = 'pix2wav'; }); var pix2pixCheckpointDirectories = pix2pixCheckpoints.filter(function (s) { return s.dir; }); pix2pixCheckpointDirectories.forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); dataset.hasCheckpoints = true; dir.module = 'pix2pix'; }); console.log(res); console.log(checkpointDirectories); console.log(pix2pixCheckpointDirectories); dispatch({ type: _types2.default.dataset.load, data: { module: module, folderLookup: folderLookup, fileLookup: fileLookup, datasetLookup: datasetLookup, folders: folders, files: files, sequences: sequenceDirectories, datasets: datasets, checkpoints: checkpointDirectories.concat(pix2pixCheckpointDirectories) } }); if (id) { console.log('folder id', id); dispatch({ type: _types2.default.dataset.set_folder, data: { folder_id: id, module: module } }); } }).catch(function (e) { console.error(e); }); }; }; /***/ }), /***/ "./app/client/modules/pix2wav/pix2wav.module.js": /*!******************************************************!*\ !*** ./app/client/modules/pix2wav/pix2wav.module.js ***! \******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var pix2wavModule = { name: 'pix2wav', displayName: 'Pix2Wav', datatype: 'spectrogram' }; exports.default = pix2wavModule; /***/ }), /***/ "./app/client/modules/pix2wav/pix2wav.reducer.js": /*!*******************************************************!*\ !*** ./app/client/modules/pix2wav/pix2wav.reducer.js ***! \*******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _dataset = __webpack_require__(/*! ../../dataset/dataset.reducer */ "./app/client/dataset/dataset.reducer.js"); var _dataset2 = _interopRequireDefault(_dataset); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var pix2wavInitialState = { loading: true, progress: { i: 0, n: 0 }, status: '', error: null, folder_id: 0, data: null }; var pix2wavReducer = function pix2wavReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : pix2wavInitialState; var action = arguments[1]; if (action.data && action.data.module === 'pix2wav') { state = (0, _dataset2.default)(state, action); } switch (action.type) { case _types2.default.wav2pix.load: return _extends({}, state, { status: 'Loaded buffer' }); case _types2.default.wav2pix.progress: return _extends({}, state, { status: 'Rendering frame ' + action.count }); case _types2.default.wav2pix.finish: return _extends({}, state, { status: action.message || 'Render complete' }); case _types2.default.wav2pix.zip: return _extends({}, state, { status: 'Built zip file ' + _util2.default.hush_size(state.size)[1] }); case _types2.default.wav2pix.uploading: return _extends({}, state, { status: 'Uploading zip file' }); default: return state; } }; exports.default = pix2wavReducer; /***/ }), /***/ "./app/client/modules/pix2wav/pix2wav.tasks.js": /*!*****************************************************!*\ !*** ./app/client/modules/pix2wav/pix2wav.tasks.js ***! \*****************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.live_task = undefined; var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var live_task = exports.live_task = function live_task(sequence, checkpoint) { return function (dispatch) { var task = { module: 'pix2wav', activity: 'live', dataset: sequence, checkpoint: checkpoint, opt: { poll_delay: 0.2 } }; console.log(task); console.log('add live task'); return _actions2.default.queue.add_task(task); }; }; /***/ }), /***/ "./app/client/modules/pix2wav/views/pix2wav.live.js": /*!**********************************************************!*\ !*** ./app/client/modules/pix2wav/views/pix2wav.live.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _common = __webpack_require__(/*! ../../../common/ */ "./app/client/common/index.js"); var _player = __webpack_require__(/*! ../../../live/player */ "./app/client/live/player.js"); var playerActions = _interopRequireWildcard(_player); var _live = __webpack_require__(/*! ../../../live/live.actions */ "./app/client/live/live.actions.js"); var liveActions = _interopRequireWildcard(_live); var _queue = __webpack_require__(/*! ../../../queue/queue.actions */ "./app/client/queue/queue.actions.js"); var queueActions = _interopRequireWildcard(_queue); var _pix2wav = __webpack_require__(/*! ../pix2wav.tasks */ "./app/client/modules/pix2wav/pix2wav.tasks.js"); var pix2wavTasks = _interopRequireWildcard(_pix2wav); var _pix2wav2 = __webpack_require__(/*! ../pix2wav.actions */ "./app/client/modules/pix2wav/pix2wav.actions.js"); var pix2wavActions = _interopRequireWildcard(_pix2wav2); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Pix2WavLive = function (_Component) { _inherits(Pix2WavLive, _Component); function Pix2WavLive(props) { _classCallCheck(this, Pix2WavLive); var _this = _possibleConstructorReturn(this, (Pix2WavLive.__proto__ || Object.getPrototypeOf(Pix2WavLive)).call(this)); props.actions.pix2wav.load_directories(); props.actions.live.get_params(); _this.changeCheckpoint = _this.changeCheckpoint.bind(_this); _this.changeEpoch = _this.changeEpoch.bind(_this); _this.changeSequence = _this.changeSequence.bind(_this); _this.seek = _this.seek.bind(_this); _this.togglePlaying = _this.togglePlaying.bind(_this); _this.toggleRecording = _this.toggleRecording.bind(_this); return _this; } _createClass(Pix2WavLive, [{ key: 'componentWillUpdate', value: function componentWillUpdate(nextProps) { if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { console.log('fetch checkpoint', nextProps.opt.checkpoint_name); this.props.actions.live.list_epochs('pix2wav', nextProps.opt.checkpoint_name); } } }, { key: 'changeCheckpoint', value: function changeCheckpoint(field, checkpoint_name) { this.props.actions.live.load_epoch(checkpoint_name, 'latest'); } }, { key: 'changeEpoch', value: function changeEpoch(field, epoch_name) { this.props.actions.live.load_epoch(this.props.opt.checkpoint_name, epoch_name); } }, { key: 'changeSequence', value: function changeSequence(field, sequence) { console.log('got sequence', sequence); this.props.actions.live.load_sequence(sequence); } }, { key: 'seek', value: function seek(percentage) { var frame = Math.floor(percentage * (parseInt(this.props.frame.sequence_len) || 1) + 1); this.props.actions.live.seek(frame); } }, { key: 'start', value: function start() { // console.log(this.props) console.log(this.props.pix2wav.data); var sequence = this.props.pix2wav.data.sequences[0].name || ''; var checkpoint = this.props.pix2wav.data.checkpoints[0].name || ''; console.log('starting up!', sequence, checkpoint); this.props.actions.tasks.live_task(sequence, checkpoint); } }, { key: 'interrupt', value: function interrupt() { this.props.actions.queue.stop_task('gpu'); } }, { key: 'exit', value: function exit() { this.props.actions.queue.stop_task('gpu', { sigkill: true }); } }, { key: 'togglePlaying', value: function togglePlaying() { if (this.props.opt.processing) { this.props.actions.live.pause(); } else { this.props.actions.live.play(); } } }, { key: 'toggleRecording', value: function toggleRecording() { if (this.props.opt.recording) { (0, _player.stopRecording)(); this.props.actions.live.pause(); } else { (0, _player.startRecording)(); } } }, { key: 'render', value: function render() { // console.log(this.props) if (this.props.pix2wav.loading) { return (0, _preact.h)(_common.Loading, null); } // console.log('sequence', this.props.opt) return (0, _preact.h)( 'div', { className: 'app pix2wav centered' }, (0, _preact.h)( 'div', { className: 'row' }, (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)(_common.Player, { width: 256, height: 256 }) ), (0, _preact.h)( 'div', { className: 'params column audioParams' }, (0, _preact.h)( _common.Group, { title: 'Audio playback' }, (0, _preact.h)( _common.Button, { title: 'Start playback', onClick: function onClick() { return playerActions.startSynthesizing(); } }, 'Start' ), (0, _preact.h)( _common.Button, { title: 'Stop playback', onClick: function onClick() { return playerActions.stopSynthesizing(); } }, 'Stop' ) ) ) ), (0, _preact.h)( 'div', { className: 'params row' }, (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Playback', noToggle: true }, (0, _preact.h)(_common.Select, { name: 'send_image', title: 'view mode', options: ['a', 'b', 'sequence', 'recursive'], onChange: this.props.actions.live.set_param }), (0, _preact.h)(_common.Select, { name: 'sequence_name', title: 'sequence', options: this.props.pix2wav.data.sequences, onChange: this.changeSequence }), (0, _preact.h)(_common.Select, { name: 'output_format', title: 'format', options: ['JPEG', 'PNG'] }), (0, _preact.h)(_common.Select, { name: 'checkpoint_name', title: 'checkpoint', options: this.props.pix2wav.data.checkpoints, onChange: this.changeCheckpoint }), (0, _preact.h)(_common.Select, { name: 'epoch', title: 'epoch', options: this.props.epochs, onChange: this.changeEpoch }), (0, _preact.h)(_common.Slider, { live: true, name: 'position', min: 0.0, max: 1.0, type: 'float', value: (this.props.frame.sequence_i || 0) / (this.props.frame.sequence_len || 1), onChange: this.seek }), this.renderRestartButton(), (0, _preact.h)( _common.Button, { title: this.props.opt.savingVideo ? 'Saving video...' : this.props.opt.recording ? 'Recording (' + timeInSeconds(this.props.opt.recordFrames) + ')' : 'Record video', onClick: this.toggleRecording }, this.props.opt.savingVideo ? 'Saving' : this.props.opt.recording ? 'Recording' : 'Record' ), (0, _preact.h)( _common.Button, { title: 'Save frame', onClick: _player.saveFrame }, 'Save' ), (0, _preact.h)( 'p', { 'class': 'last_message' }, this.props.last_message ) ) ), (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Transition', name: 'transition' }, (0, _preact.h)(_common.Slider, { live: true, name: 'transition_period', min: 10, max: 5000, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'transition_min', min: 0.001, max: 0.2, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'transition_max', min: 0.1, max: 1.0, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Recursion', name: 'recursive' }, (0, _preact.h)(_common.Slider, { live: true, name: 'recursive_frac', min: 0.0, max: 0.5, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'recurse_roll', min: -64, max: 64, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'recurse_roll_axis', min: 0, max: 1, type: 'int' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Sequence', name: 'sequence' }, (0, _preact.h)(_common.Slider, { live: true, name: 'sequence_frac', min: 0.0, max: 1, type: 'float' }), (0, _preact.h)(_common.Slider, { live: true, name: 'process_frac', min: 0, max: 1, type: 'float' }) ) ), (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _common.ParamGroup, { title: 'Clahe', name: 'clahe' }, (0, _preact.h)(_common.Slider, { live: true, name: 'clip_limit', min: 1.0, max: 4.0, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Posterize', name: 'posterize' }, (0, _preact.h)(_common.Slider, { live: true, name: 'spatial_window', min: 2, max: 128, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'color_window', min: 2, max: 128, type: 'int' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Blur', name: 'blur' }, (0, _preact.h)(_common.Slider, { live: true, name: 'blur_radius', min: 3, max: 7, type: 'odd' }), (0, _preact.h)(_common.Slider, { live: true, name: 'blur_sigma', min: 0, max: 2, type: 'float' }) ), (0, _preact.h)( _common.ParamGroup, { title: 'Canny Edge Detection', name: 'canny' }, (0, _preact.h)(_common.Slider, { live: true, name: 'canny_lo', min: 10, max: 200, type: 'int' }), (0, _preact.h)(_common.Slider, { live: true, name: 'canny_hi', min: 10, max: 200, type: 'int' }) ) ) ) ); } }, { key: 'renderRestartButton', value: function renderRestartButton() { var _this2 = this; if (this.props.runner.gpu.status === 'IDLE') { return (0, _preact.h)( _common.Button, { title: 'GPU Idle', onClick: function onClick() { return _this2.start(); } }, 'Start' ); } if (this.props.runner.gpu.task.module !== 'pix2pix' && this.props.runner.gpu.task.module !== 'pix2wav') { return (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ); } if (!this.props.opt.processing) { return (0, _preact.h)( 'div', null, (0, _preact.h)( _common.Button, { title: 'Not processing', onClick: this.togglePlaying }, 'Restart' ), (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ), (0, _preact.h)( _common.Button, { title: 'Last resort', onClick: function onClick() { return _this2.exit(); } }, 'Exit' ) ); } return (0, _preact.h)( 'div', null, (0, _preact.h)( _common.Button, { title: 'Processing', onClick: this.togglePlaying }, 'Pause' ), (0, _preact.h)( _common.Button, { title: 'GPU Busy', onClick: function onClick() { return _this2.interrupt(); } }, 'Interrupt' ), (0, _preact.h)( _common.Button, { title: 'Last resort', onClick: function onClick() { return _this2.exit(); } }, 'Exit' ) ); } }]); return Pix2WavLive; }(_preact.Component); function timeInSeconds(n) { return (n / 10).toFixed(1) + ' s.'; } var mapStateToProps = function mapStateToProps(state) { return { last_message: state.live.last_message, opt: state.live.opt, frame: state.live.frame, checkpoints: state.live.checkpoints, epochs: state.live.epochs, sequences: state.live.sequences, runner: state.system.runner, pix2wav: state.module.pix2wav }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: { live: (0, _redux.bindActionCreators)(liveActions, dispatch), queue: (0, _redux.bindActionCreators)(queueActions, dispatch), pix2wav: (0, _redux.bindActionCreators)(pix2wavActions, dispatch), tasks: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch), s: s } }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2WavLive); /***/ }), /***/ "./app/client/modules/pix2wav/views/pix2wav.new.js": /*!*********************************************************!*\ !*** ./app/client/modules/pix2wav/views/pix2wav.new.js ***! \*********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Pix2WavNew; var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _dataset = __webpack_require__(/*! ../../../dataset/dataset.new */ "./app/client/dataset/dataset.new.js"); var _dataset2 = _interopRequireDefault(_dataset); var _pix2wav = __webpack_require__(/*! ../pix2wav.module */ "./app/client/modules/pix2wav/pix2wav.module.js"); var _pix2wav2 = _interopRequireDefault(_pix2wav); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function Pix2WavNew(_ref) { var history = _ref.history; return (0, _preact.h)( 'div', { 'class': 'app pix2wav' }, (0, _preact.h)(_dataset2.default, { module: _pix2wav2.default, history: history }) ); } /***/ }), /***/ "./app/client/modules/pix2wav/views/pix2wav.show.js": /*!**********************************************************!*\ !*** ./app/client/modules/pix2wav/views/pix2wav.show.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2wav = __webpack_require__(/*! ../pix2wav.actions */ "./app/client/modules/pix2wav/pix2wav.actions.js"); var pix2wavActions = _interopRequireWildcard(_pix2wav); var _pix2wav2 = __webpack_require__(/*! ../pix2wav.tasks */ "./app/client/modules/pix2wav/pix2wav.tasks.js"); var pix2wavTasks = _interopRequireWildcard(_pix2wav2); var _loading = __webpack_require__(/*! ../../../common/loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); var _dataset = __webpack_require__(/*! ../../../dataset/dataset.form */ "./app/client/dataset/dataset.form.js"); var _dataset2 = _interopRequireDefault(_dataset); var _dataset3 = __webpack_require__(/*! ../../../dataset/dataset.new */ "./app/client/dataset/dataset.new.js"); var _dataset4 = _interopRequireDefault(_dataset3); var _upload = __webpack_require__(/*! ../../../dataset/upload.status */ "./app/client/dataset/upload.status.js"); var _upload2 = _interopRequireDefault(_upload); var _fileList = __webpack_require__(/*! ../../../common/fileList.component */ "./app/client/common/fileList.component.js"); var _spectrogram = __webpack_require__(/*! ./spectrogram.upload */ "./app/client/modules/pix2wav/views/spectrogram.upload.js"); var _spectrogram2 = _interopRequireDefault(_spectrogram); var _dataset5 = __webpack_require__(/*! ../../../dataset/dataset.component */ "./app/client/dataset/dataset.component.js"); var _dataset6 = _interopRequireDefault(_dataset5); var _pix2wav3 = __webpack_require__(/*! ../pix2wav.module */ "./app/client/modules/pix2wav/pix2wav.module.js"); var _pix2wav4 = _interopRequireDefault(_pix2wav3); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Pix2wavShow = function (_Component) { _inherits(Pix2wavShow, _Component); function Pix2wavShow(props) { _classCallCheck(this, Pix2wavShow); var _this = _possibleConstructorReturn(this, (Pix2wavShow.__proto__ || Object.getPrototypeOf(Pix2wavShow)).call(this, props)); _this.datasetActions = _this.datasetActions.bind(_this); return _this; } _createClass(Pix2wavShow, [{ key: 'componentWillMount', value: function componentWillMount() { var id = this.props.match.params.id || localStorage.getItem('pix2wav.last_id'); console.log('load dataset:', id); var _props = this.props, match = _props.match, pix2wav = _props.pix2wav, actions = _props.actions; if (id === 'new') return; if (id) { if (parseInt(id)) localStorage.setItem('pix2wav.last_id', id); if (!pix2wav.folder || pix2wav.folder.id !== id) { actions.load_directories(id); } } else { this.props.history.push('/pix2wav/new/'); } } }, { key: 'render', value: function render() { var _props2 = this.props, pix2wav = _props2.pix2wav, match = _props2.match, history = _props2.history; var _ref = pix2wav.data || {}, folderLookup = _ref.folderLookup; var folder = (folderLookup || {})[pix2wav.folder_id] || {}; return (0, _preact.h)( 'div', { className: 'app pix2wav' }, (0, _preact.h)( 'div', { 'class': 'heading' }, (0, _preact.h)( 'div', { 'class': 'spaced' }, (0, _preact.h)( 'h1', null, folder ? folder.name : (0, _preact.h)(_loading2.default, null) ), (0, _preact.h)(_upload2.default, null) ) ), (0, _preact.h)(_spectrogram2.default, { loading: pix2wav.loading, progress: pix2wav.progress, id: pix2wav.folder_id, module: _pix2wav4.default, data: pix2wav.data, folder: folder }), (0, _preact.h)(_dataset6.default, { loading: pix2wav.loading, progress: pix2wav.progress, id: pix2wav.folder_id, module: _pix2wav4.default, data: pix2wav.data, folder: folder, history: history, onPickFile: function onPickFile(file, e) { e.preventDefault(); e.stopPropagation(); console.log('picked a file', file); }, datasetActions: this.datasetActions }) ); } }, { key: 'datasetActions', value: function datasetActions(dataset) { var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var _props3 = this.props, pix2wav = _props3.pix2wav, remote = _props3.remote; var input = pix2wav.data.fileLookup[dataset.input[0]]; if (!input) return null; if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null; return (0, _preact.h)( 'div', null, (0, _preact.h)( 'div', { 'class': 'actions' }, (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2wav.folder_id, 1); } }, 'train' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2wav.folder_id, 2); } }, '2x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2wav.folder_id, 4); } }, '4x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2wav.folder_id, 6); } }, '6x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, pix2wav.folder_id, 18); } }, '18x' ) ), dataset.isBuilt ? (0, _preact.h)( 'div', { 'class': 'subtext' }, 'fetched ', (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.clear_cache_task(dataset); } }, 'rm' ) ) : isFetching ? (0, _preact.h)( 'div', { 'class': 'subtext' }, 'fetching' ) : (0, _preact.h)( 'div', { 'class': 'subtext' }, (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.fetch_task(input.url, input.id, dataset.name); } }, 'fetch' ) ) ); } }]); return Pix2wavShow; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { pix2wav: state.module.pix2wav }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(pix2wavActions, dispatch), remote: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2wavShow); /***/ }), /***/ "./app/client/modules/pix2wav/views/spectrogram.upload.js": /*!****************************************************************!*\ !*** ./app/client/modules/pix2wav/views/spectrogram.upload.js ***! \****************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); var _moment2 = _interopRequireDefault(_moment); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _pix2wav = __webpack_require__(/*! ../pix2wav.actions */ "./app/client/modules/pix2wav/pix2wav.actions.js"); var pix2wavActions = _interopRequireWildcard(_pix2wav); var _pix2wav2 = __webpack_require__(/*! ../pix2wav.tasks */ "./app/client/modules/pix2wav/pix2wav.tasks.js"); var pix2wavTasks = _interopRequireWildcard(_pix2wav2); var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); var _dataset = __webpack_require__(/*! ../../../dataset/dataset.actions */ "./app/client/dataset/dataset.actions.js"); var datasetActions = _interopRequireWildcard(_dataset); var _wav2pix = __webpack_require__(/*! ../../../audio/wav2pix */ "./app/client/audio/wav2pix.js"); var wav2pixActions = _interopRequireWildcard(_wav2pix); var _pix2wav3 = __webpack_require__(/*! ../../../audio/pix2wav */ "./app/client/audio/pix2wav.js"); var pix2wavPlayer = _interopRequireWildcard(_pix2wav3); var _pix2wav4 = __webpack_require__(/*! ../pix2wav.module */ "./app/client/modules/pix2wav/pix2wav.module.js"); var _pix2wav5 = _interopRequireDefault(_pix2wav4); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var date_stamp = function date_stamp() { return (0, _moment2.default)().format("_YYYYMMDD_HHmm"); }; var SpectrogramUpload = function (_Component) { _inherits(SpectrogramUpload, _Component); function SpectrogramUpload(props) { _classCallCheck(this, SpectrogramUpload); var _this = _possibleConstructorReturn(this, (SpectrogramUpload.__proto__ || Object.getPrototypeOf(SpectrogramUpload)).call(this, props)); _this.state = { file: null, pcm: null, name: "", datasetName: "", frames: [], frame_start: 0, max: 1000, preview_count: 8 * 4, frame_step: wav2pixActions.FRAME_STEP }; var audioElement = document.createElement('audio'); audioElement.addEventListener('loadedmetadata', function () { var duration = audioElement.duration; var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / _this.state.frame_step); _this.setState({ duration: duration, max: Math.min(_this.state.max, total_frame_count, 1000) }); }); _this.audioElement = audioElement; return _this; } _createClass(SpectrogramUpload, [{ key: 'pickFile', value: function pickFile(file) { var _this2 = this; var name = file.name.split('.')[0].replace(/\s+/g, '_').replace(/-/g, '_').replace(/_+/g, '_'); this.setState({ file: file, name: name + date_stamp(), datasetName: name, pcm: '' }, function () { _this2.rebuildFrames(); }); this.audioElement.src = URL.createObjectURL(file); } }, { key: 'rebuildFrames', value: function rebuildFrames() { var _this3 = this; var _state = this.state, file = _state.file, pcm = _state.pcm, frame_step = _state.frame_step, frame_start = _state.frame_start, preview_count = _state.preview_count; this.props.wav2pix.renderFrames(pcm || file, { frame_start: frame_start, frame_step: frame_step, max: preview_count }).then(function (data) { console.log('got frames', data.frames.length); _this3.setState(_extends({}, _this3.state, { frames: data.frames, pcm: data.pcm })); }); } }, { key: 'buildZip', value: function buildZip() { var _this4 = this; var _state2 = this.state, pcm = _state2.pcm, file = _state2.file, max = _state2.max, frame_step = _state2.frame_step, frame_start = _state2.frame_start; this.props.wav2pix.buildZip(this.state.name, pcm || file, { frame_start: frame_start, frame_step: frame_step, max: max }).then(function (_ref) { var zip = _ref.zip, filename = _ref.filename, count = _ref.count; _this4.props.datasetActions.uploadFile(_this4.props.module, _this4.props.folder, zip, filename, { count: count, max: max, frame_step: frame_step, frame_size: wav2pixActions.FRAME_LENGTH / 44100 }); }); } }, { key: 'playFrame', value: function playFrame(i) { var _this5 = this; return function () { var frame = _this5.state.frames[i]; pix2wavPlayer.play(frame); }; } }, { key: 'render', value: function render() { var _this6 = this; // loading={pix2wav.loading} // progress={pix2wav.progress} // id={pix2wav.folder_id} // module={pix2wavModule} // data={pix2wav.data} // folder={folder} var _state3 = this.state, file = _state3.file, frames = _state3.frames, preview_count = _state3.preview_count; var canvases = []; for (var i = 0, _len = preview_count; i < _len; i++) { canvases.push((0, _preact.h)('canvas', { key: i, onClick: this.playFrame(i) })); } return (0, _preact.h)( 'div', { className: 'row' }, (0, _preact.h)( 'div', { className: 'col spectrogramBuilder' }, (0, _preact.h)( _common.Group, { title: 'Spectrogram Builder' }, (0, _preact.h)( 'p', null, "Convert your sounds into spectrograms. ", "Sound files can be WAV, MP3, AIFF, or FLAC. " ), (0, _preact.h)(_common.FileUpload, { title: 'Choose a sound file', accept: 'audio/*', onUpload: function onUpload(file) { return _this6.pickFile(file); } }), file && this.renderMetadata(file) ) ), (0, _preact.h)( 'div', { ref: function ref(c) { _this6.canvases = c; }, className: 'thumbs', id: 'pix2wav_canvases' }, canvases ) ); } }, { key: 'renderMetadata', value: function renderMetadata(file) { var _this7 = this; var _state4 = this.state, duration = _state4.duration, preview_count = _state4.preview_count; var size = _util2.default.hush_size(file.size); var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / this.state.frame_step); var frame_size = Math.round(wav2pixActions.FRAME_LENGTH / 44100 * 1000) + ' ms.'; var frame_step = Math.round(this.state.frame_step / 44100 * 1000) + ' ms.'; return (0, _preact.h)( 'div', { className: 'fileMetadata' }, (0, _preact.h)( _common.Group, { title: 'Metadata' }, (0, _preact.h)( _common.Param, { title: 'Name' }, file.name ), (0, _preact.h)( _common.Param, { title: 'Type' }, file.type ), (0, _preact.h)( _common.Param, { title: 'Size' }, (0, _preact.h)( 'span', { className: size[0] }, size[1] ) ), (0, _preact.h)( _common.Param, { title: 'Date' }, (0, _moment2.default)(file.lastModifiedDate).format("YYYY-MM-DD h:mm a") ), (0, _preact.h)( _common.Param, { title: 'Duration' }, Math.floor(duration) + ' s.' ), (0, _preact.h)('br', null), (0, _preact.h)( _common.Param, { title: 'Frames' }, total_frame_count ), (0, _preact.h)( _common.Param, { title: 'Frame Size' }, frame_size ), (0, _preact.h)( _common.Param, { title: 'Frame Step' }, frame_step ), (0, _preact.h)( _common.Param, { title: 'FFT Size' }, wav2pixActions.spectrum.fft_size ), (0, _preact.h)('br', null), (0, _preact.h)( _common.Param, { title: 'Status' }, this.props.pix2wav.status ), (0, _preact.h)('br', null) ), (0, _preact.h)( _common.Group, { title: 'Data settings' }, (0, _preact.h)(_common.TextInput, { title: 'Dataset name', onChange: function onChange(e) { return _this7.setState({ name: e.target.value }); }, value: this.state.name }), (0, _preact.h)(_common.Slider, { name: 'Starting Frame', min: 0, max: 1, type: 'float', value: this.state.frame_start, defaultValue: 0, onChange: function onChange(frame_start) { _this7.setState({ frame_start: frame_start }, function () { _this7.rebuildFrames(); }); } }), (0, _preact.h)(_common.Slider, { name: 'No. Frames', min: 10, max: Math.min(total_frame_count, 1000), type: 'int', value: this.state.max, defaultValue: Math.min(total_frame_count, 300), onChange: function onChange(max) { return _this7.setState({ max: max }); } }), (0, _preact.h)(_common.Slider, { name: 'Frame step', min: 10, max: 20000, type: 'int', value: this.state.frame_step, defaultValue: wav2pixActions.FRAME_STEP, onChange: function onChange(frame_step) { var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / frame_step); _this7.setState({ name: _this7.state.datasetName + '_step_' + frame_step + date_stamp(), frame_step: frame_step, max: Math.min(_this7.state.max, total_frame_count) }, function () { _this7.rebuildFrames(); }); } }), (0, _preact.h)( _common.Button, { onClick: function onClick() { return _this7.buildZip(); } }, 'Upload Frames' ) ), (0, _preact.h)(_common.Progress, null) ); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { var _this8 = this; (this.state.frames || []).map(function (frame, i) { var canvas = _this8.canvases.children[i]; var ctx = canvas.getContext('2d-lodpi'); canvas.width = frame.canvas.width; canvas.height = frame.canvas.height; ctx.drawImage(frame.canvas, 0, 0); }); } }]); return SpectrogramUpload; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { pix2wav: state.module.pix2wav, upload: state.upload }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { datasetActions: (0, _redux.bindActionCreators)(datasetActions, dispatch), actions: (0, _redux.bindActionCreators)(pix2wavActions, dispatch), remote: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch), wav2pix: (0, _redux.bindActionCreators)(wav2pixActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SpectrogramUpload); /***/ }), /***/ "./app/client/modules/samplernn/index.js": /*!***********************************************!*\ !*** ./app/client/modules/samplernn/index.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _samplernn = __webpack_require__(/*! ./views/samplernn.new */ "./app/client/modules/samplernn/views/samplernn.new.js"); var _samplernn2 = _interopRequireDefault(_samplernn); var _samplernn3 = __webpack_require__(/*! ./views/samplernn.show */ "./app/client/modules/samplernn/views/samplernn.show.js"); var _samplernn4 = _interopRequireDefault(_samplernn3); var _samplernn5 = __webpack_require__(/*! ./views/samplernn.import */ "./app/client/modules/samplernn/views/samplernn.import.js"); var _samplernn6 = _interopRequireDefault(_samplernn5); var _samplernn7 = __webpack_require__(/*! ./views/samplernn.results */ "./app/client/modules/samplernn/views/samplernn.results.js"); var _samplernn8 = _interopRequireDefault(_samplernn7); var _samplernn9 = __webpack_require__(/*! ./views/samplernn.graph */ "./app/client/modules/samplernn/views/samplernn.graph.js"); var _samplernn10 = _interopRequireDefault(_samplernn9); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var router = function () { function router() { _classCallCheck(this, router); } _createClass(router, [{ key: 'componentWillMount', value: function componentWillMount() { _actions2.default.system.changeTool('samplernn'); document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #eef, #fef)'; } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps() { _actions2.default.system.changeTool('samplernn'); document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #eef, #fef)'; } }, { key: 'render', value: function render() { return (0, _preact.h)( 'section', null, (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/new', component: _samplernn2.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/datasets', component: _samplernn4.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/datasets/:id', component: _samplernn4.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/import', component: _samplernn6.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/results', component: _samplernn8.default }), (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/graph', component: _samplernn10.default }) ); } }]); return router; }(); function links() { return [{ url: '/samplernn/new/', name: 'new' }, { url: '/samplernn/datasets/', name: 'datasets' }, { url: '/samplernn/graph/', name: 'graph' }, { url: '/samplernn/results/', name: 'results' }]; } exports.default = { name: 'samplernn', router: router, links: links }; /***/ }), /***/ "./app/client/modules/samplernn/samplernn.actions.js": /*!***********************************************************!*\ !*** ./app/client/modules/samplernn/samplernn.actions.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.import_files = exports.load_loss = exports.load_graph = exports.load_directories = undefined; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _dataset = __webpack_require__(/*! ../../dataset/dataset.loader */ "./app/client/dataset/dataset.loader.js"); var datasetLoader = _interopRequireWildcard(_dataset); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _samplernn = __webpack_require__(/*! ./samplernn.module */ "./app/client/modules/samplernn/samplernn.module.js"); var _samplernn2 = _interopRequireDefault(_samplernn); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } var load_directories = exports.load_directories = function load_directories(id) { return function (dispatch) { var module = _samplernn2.default.name; _util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_directory({ module: module, dir: 'datasets' }), _actions2.default.socket.list_directory({ module: module, dir: 'results' }), _actions2.default.socket.list_directory({ module: module, dir: 'output' }), _actions2.default.socket.disk_usage({ module: module, dir: 'datasets' }), load_loss()(dispatch)], function (percent, i, n) { dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); }).then(function (res) { // console.log(res) var _res = _slicedToArray(res, 6), datasetApiReport = _res[0], datasets = _res[1], results = _res[2], output = _res[3], datasetUsage = _res[4], lossReport = _res[5]; var folderLookup = datasetApiReport.folderLookup, fileLookup = datasetApiReport.fileLookup, datasetLookup = datasetApiReport.datasetLookup, folders = datasetApiReport.folders, files = datasetApiReport.files, unsortedFolder = datasetApiReport.unsortedFolder; console.log(datasetUsage); // also show the various flat audio files we have, in the input area.. var flatDatasets = datasets.filter(function (s) { return s.name.match(/(wav|aiff?|flac|mp3)$/) && !s.dir; }); var builtDatasets = datasets.filter(function (s) { return s.dir; }); builtDatasets.forEach(function (dir) { var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name, unsortedFolder, dir.date); dataset.isBuilt = true; }); flatDatasets.forEach(function (file) { file.uuid = (0, _v2.default)(); fileLookup[file.uuid] = file; var name = file.name.split('.')[0]; var dataset = datasetLoader.getDataset(module, datasetLookup, name, unsortedFolder, file.date); file.persisted = false; dataset.input.push(file.uuid); }); // exp:coccokit_3-frame_sizes:8,2-n_rnn:2-dataset:coccokit_3 var checkpoints = results.filter(function (s) { return s.dir; }).map(function (s) { var checkpoint = s.name.split('-').map(function (s) { return s.split(':'); }).filter(function (b) { return b.length && b[1]; }).reduce(function (a, b) { return (a[b[0]] = b[1]) && a; }, {}); checkpoint.name = checkpoint.name || checkpoint.dataset || checkpoint.exp; checkpoint.date = s.date; checkpoint.dir = s; checkpoint.persisted = false; var dataset = datasetLoader.getDataset(module, datasetLookup, checkpoint.name, unsortedFolder, checkpoint.date); var loss = lossReport[checkpoint.name]; if (loss) { dataset.epoch = checkpoint.epoch = loss.length; checkpoint.training_loss = loss; } dataset.checkpoints.push(checkpoint); return checkpoint; }); output.map(function (file) { file.uuid = (0, _v2.default)(); fileLookup[file.uuid] = file; var pair = file.name.split('.')[0].split('-'); var dataset = datasetLoader.getDataset(module, datasetLookup, pair[0], unsortedFolder, file.date); file.persisted = false; file.epoch = parseInt(file.epoch || pair[1].replace(/^\D+/, '')) || 0; dataset.epoch = Math.max(file.epoch, dataset.epoch || 0); // here check if the file exists in dataset, if so just check that it's persisted var found = dataset.output.some(function (file_id) { // if (f.name === if (fileLookup[file_id].name === file.name) { fileLookup[file_id].persisted = true; return true; } return false; }); if (!found) { dataset.output.push(file.uuid); } }); dispatch({ type: _types2.default.dataset.load, data: { module: module, folderLookup: folderLookup, fileLookup: fileLookup, datasetLookup: datasetLookup, folders: folders, files: files, checkpoints: checkpoints, output: output } }); if (id) { dispatch({ type: _types2.default.dataset.set_folder, data: { folder_id: id, module: module } }); } }).catch(function (e) { console.error(e); }); }; }; var load_graph = exports.load_graph = function load_graph() { return function (dispatch) { var module = _samplernn2.default.name; _util2.default.allProgress([load_loss()(dispatch), _actions2.default.socket.list_directory({ module: module, dir: 'results' })], function (percent, i, n) { dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); }).then(function (res) { var _res2 = _slicedToArray(res, 2), lossReport = _res2[0], results = _res2[1]; dispatch({ type: _types2.default.samplernn.load_graph, lossReport: lossReport, results: results }); }); }; }; var load_loss = exports.load_loss = function load_loss() { return function (dispatch) { return _actions2.default.socket.run_script({ module: 'samplernn', activity: 'report' }).then(function (report) { var lossReport = {}; report.stdout.split('\n\n').filter(function (a) { return !!a; }).forEach(function (data) { var _data$split = data.split('\n'), _data$split2 = _toArray(_data$split), name = _data$split2[0], lines = _data$split2.slice(1); lossReport[name] = lines.map(function (s) { return s.split('\t').reduce(function (a, s) { var b = s.split(': '); a[b[0]] = b[1]; return a; }, {}); }); // console.log(data, name, lossReport[name]) }); dispatch({ type: _types2.default.samplernn.load_loss, lossReport: lossReport }); return lossReport; }); }; }; var import_files = exports.import_files = function import_files(state, datasetLookup, fileLookup) { return function (dispatch) { var selected = state.selected, folder_id = state.folder_id, url_base = state.url_base, import_action = state.import_action; var names = Object.keys(selected).filter(function (k) { return selected[k]; }); var promises = void 0; switch (import_action) { case 'Hotlink': // in this case, create a new file for each file we see. promises = names.reduce(function (a, name) { return datasetLookup[name].output.map(function (id) { return fileLookup[id]; }).map(function (file) { var partz = file.name.split('.'); var ext = partz.pop(); return _actions2.default.file.create({ folder_id: folder_id, name: file.name, url: url_base + file.name, mime: 'audio/' + ext, epoch: file.epoch, size: file.size, module: 'samplernn', dataset: name, activity: 'train', datatype: 'audio', generated: true, created_at: new Date(file.date), updated_at: new Date(file.date) }); }).concat(a); }, []); break; case 'Upload': promises = names.reduce(function (a, name) { return datasetLookup[name].input.map(function (id) { return fileLookup[id]; }).map(function (file) { if (file.persisted) return null; var partz = file.name.split('.'); var ext = partz.pop(); if (ext === 'wav' || ext === 'flac') return; console.log(file); return _actions2.default.socket.upload_file({ folder_id: folder_id, module: 'samplernn', activity: 'train', path: 'datasets', filename: file.name, generated: false, processed: false, datatype: 'audio', ttl: 60000 }); }).concat(a); }, []).filter(function (a) { return !!a; }); break; default: break; } console.log(promises); return Promise.all(promises).then(function (data) { console.log(data); window.location.href = '/samplernn/datasets/' + folder_id + '/'; }).catch(function (e) { console.error(e); }); }; }; /***/ }), /***/ "./app/client/modules/samplernn/samplernn.module.js": /*!**********************************************************!*\ !*** ./app/client/modules/samplernn/samplernn.module.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var samplernnModule = { name: 'samplernn', displayName: 'SampleRNN', datatype: 'audio' }; exports.default = samplernnModule; /***/ }), /***/ "./app/client/modules/samplernn/samplernn.reducer.js": /*!***********************************************************!*\ !*** ./app/client/modules/samplernn/samplernn.reducer.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _dataset = __webpack_require__(/*! ../../dataset/dataset.reducer */ "./app/client/dataset/dataset.reducer.js"); var _dataset2 = _interopRequireDefault(_dataset); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var samplernnInitialState = { loading: true, progress: { i: 0, n: 0 }, error: null, folders: [], folder_id: 0, data: null, lossReport: null, results: null }; var samplernnReducer = function samplernnReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : samplernnInitialState; var action = arguments[1]; if (action.data && action.data.module === 'samplernn') { return (0, _dataset2.default)(state, action); } switch (action.type) { case _types2.default.samplernn.load_loss: return _extends({}, state, { lossReport: action.lossReport }); case _types2.default.samplernn.load_graph: return _extends({}, state, { lossReport: action.lossReport, results: action.results }); default: return state; } }; exports.default = samplernnReducer; /***/ }), /***/ "./app/client/modules/samplernn/samplernn.tasks.js": /*!*********************************************************!*\ !*** ./app/client/modules/samplernn/samplernn.tasks.js ***! \*********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clear_cache_task = exports.log_task = exports.fetch_task = exports.train_task = undefined; var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var train_task = exports.train_task = function train_task(dataset, folder_id) { var epochs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; return function (dispatch) { var task = { module: 'samplernn', activity: 'train', dataset: dataset.name, epoch: dataset.checkpoints.length ? dataset.checkpoints[0].epoch || 0 : 0, epochs: epochs, folder_id: folder_id, opt: { sample_length: 44100 * 5, n_samples: 6, keep_old_checkpoints: false } }; console.log(task); return _actions2.default.queue.add_task(task); }; }; var fetch_task = exports.fetch_task = function fetch_task(url, folder_id, file_id, dataset) { return function (dispatch) { if (!url) return console.log('input file inaccessible (no url)'); var task = { module: 'samplernn', activity: 'fetch', dataset: dataset, folder_id: folder_id, opt: { url: url, file_id: file_id, dataset: dataset } }; return _actions2.default.queue.add_task(task); }; }; var log_task = exports.log_task = function log_task(dataset) { return function (dispatch) { var task = { module: 'samplernn', activity: 'log', dataset: dataset.name }; return _actions2.default.queue.add_task(task); }; }; var clear_cache_task = exports.clear_cache_task = function clear_cache_task(dataset) { return function (dispatch) { var task = { module: 'samplernn', activity: 'clear_cache', dataset: dataset.name }; return _actions2.default.queue.add_task(task); }; }; /***/ }), /***/ "./app/client/modules/samplernn/views/samplernn.graph.js": /*!***************************************************************!*\ !*** ./app/client/modules/samplernn/views/samplernn.graph.js ***! \***************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); var samplernnActions = _interopRequireWildcard(_samplernn); var _group = __webpack_require__(/*! ../../../common/group.component */ "./app/client/common/group.component.js"); var _group2 = _interopRequireDefault(_group); var _slider = __webpack_require__(/*! ../../../common/slider.component */ "./app/client/common/slider.component.js"); var _slider2 = _interopRequireDefault(_slider); var _select = __webpack_require__(/*! ../../../common/select.component */ "./app/client/common/select.component.js"); var _select2 = _interopRequireDefault(_select); var _button = __webpack_require__(/*! ../../../common/button.component */ "./app/client/common/button.component.js"); var _button2 = _interopRequireDefault(_button); var _fileList = __webpack_require__(/*! ../../../common/fileList.component */ "./app/client/common/fileList.component.js"); var _textInput = __webpack_require__(/*! ../../../common/textInput.component */ "./app/client/common/textInput.component.js"); var _textInput2 = _interopRequireDefault(_textInput); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var lerp = _util2.default.lerp, norm = _util2.default.norm, randint = _util2.default.randint, randrange = _util2.default.randrange; var SampleRNNGraph = function (_Component) { _inherits(SampleRNNGraph, _Component); function SampleRNNGraph(props) { _classCallCheck(this, SampleRNNGraph); var _this = _possibleConstructorReturn(this, (SampleRNNGraph.__proto__ || Object.getPrototypeOf(SampleRNNGraph)).call(this)); props.actions.load_graph(); return _this; } _createClass(SampleRNNGraph, [{ key: 'render', value: function render() { var _this2 = this; this.refs = {}; return (0, _preact.h)( 'div', { className: 'app lossGraph' }, (0, _preact.h)( 'div', { className: 'heading' }, (0, _preact.h)( 'h3', null, 'SampleRNN Loss Graph' ), (0, _preact.h)('canvas', { ref: function ref(_ref) { return _this2.refs['canvas'] = _ref; } }) ) ); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { var _props$samplernn = this.props.samplernn, lossReport = _props$samplernn.lossReport, results = _props$samplernn.results; if (!lossReport || !results) return; var canvas = this.refs.canvas; canvas.width = window.innerWidth; canvas.height = window.innerHeight; canvas.style.width = canvas.width + 'px'; canvas.style.height = canvas.height + 'px'; var ctx = canvas.getContext('2d'); var w = canvas.width; var h = canvas.height; ctx.clearRect(0, 0, w, h); var resultsByDate = results.map(function (file) { if (!file.name.match(/^exp:/)) return null; var dataset = file.name.split("-")[3].split(":")[1]; return [+new Date(file.date), dataset]; }).filter(function (a) { return !!a; }).sort(function (a, b) { return a[0] - a[1]; }); var keys = Object.keys(lossReport).filter(function (k) { return !!lossReport[k].length; }); var scaleMax = 0; var scaleMin = Infinity; var epochsMax = 0; keys.forEach(function (key) { var loss = lossReport[key]; epochsMax = Math.max(loss.length, epochsMax); loss.forEach(function (a) { var v = parseFloat(a.training_loss); if (!v) return; scaleMax = Math.max(v, scaleMax); scaleMin = Math.min(v, scaleMin); }); }); // scaleMax *= 10 console.log(scaleMax, scaleMin, epochsMax); scaleMax = 3; scaleMin = 0; var margin = 0; var wmin = 0; var wmax = w / 2; var hmin = 0; var hmax = h / 2; var epochsScaleFactor = 1; // 3/2 ctx.save(); var X = void 0, Y = void 0; for (var ii = 0; ii < epochsMax; ii++) { X = lerp(ii / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax); ctx.strokeStyle = 'rgba(0,0,0,0.3)'; ctx.beginPath(0, 0); ctx.moveTo(X, 0); ctx.lineTo(X, h); ctx.lineWidth = 0.5; // ctx.stroke() if ((ii + 1) % 6 === 0) { ctx.lineWidth = 0.5; ctx.stroke(); var fontSize = 12; ctx.font = 'italic ' + fontSize + 'px "Georgia"'; ctx.fillStyle = 'rgba(0,12,28,0.6)'; ctx.fillText(ii / 5 * 6, X + 8, h - (fontSize + 4)); } } for (var ii = scaleMin; ii < scaleMax; ii += 1) { Y = lerp(ii / scaleMax, hmin, hmax); // ctx.strokeStyle = 'rgba(255,255,255,1.0)' ctx.beginPath(0, 0); ctx.moveTo(0, h - Y); ctx.lineTo(w, h - Y); ctx.lineWidth = 1; // ctx.stroke() // if ( (ii % 1) < 0.1) { // ctx.strokeStyle = 'rgba(255,255,255,1.0)' ctx.lineWidth = 2; ctx.setLineDash([4, 4]); ctx.stroke(); ctx.stroke(); ctx.stroke(); ctx.setLineDash([1, 1]); var _fontSize = 12; ctx.font = 'italic ' + _fontSize + 'px "Georgia"'; ctx.fillStyle = 'rgba(0,12,28,0.6)'; ctx.fillText(ii.toFixed(1), w - 50, h - Y + _fontSize + 10); // } } ctx.lineWidth = 1; ctx.restore(); var min_date = resultsByDate[0][0]; var max_date = resultsByDate[resultsByDate.length - 1][0]; resultsByDate.forEach(function (pair) { var date = pair[0]; var key = pair[1]; var loss = lossReport[key]; if (!key || !loss || !loss.length) return; var vf = parseFloat(loss[loss.length - 1].training_loss) || 0; var vg = parseFloat(loss[0].training_loss) || 5; // console.log(vf) var vv = 1 - norm(vf, scaleMin, scaleMax / 2); ctx.lineWidth = (1 - norm(vf, scaleMin, scaleMax)) * 4; // ctx.lineWidth = norm(date, min_date, max_date) * 3 console.log(date, min_date, max_date); ctx.strokeStyle = 'rgba(' + [randrange(30, 190), randrange(30, 150), randrange(60, 120)].join(',') + ',' + 0.8 + ')'; var begun = false; loss.forEach(function (a, i) { var v = parseFloat(a.training_loss); if (!v) return; var x = lerp(i / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax); var y = lerp(norm(v, scaleMin, scaleMax), hmax, hmin); if (!begun) { begun = true; ctx.beginPath(0, 0); ctx.moveTo(x, y); } else { ctx.lineTo(x, y); // ctx.stroke() } }); ctx.stroke(); var i = loss.length - 1; var v = parseFloat(loss[i].training_loss); var x = lerp(i / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax); var y = lerp(norm(v, scaleMin, scaleMax), hmax, hmin); var fontSize = 9; ctx.font = 'italic ' + fontSize + 'px "Georgia"'; ctx.fillStyle = 'rgba(0,12,28,0.6)'; ctx.fillText(key, x + 4, y + fontSize / 2); }); } }]); return SampleRNNGraph; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { samplernn: state.module.samplernn }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNGraph); /***/ }), /***/ "./app/client/modules/samplernn/views/samplernn.import.js": /*!****************************************************************!*\ !*** ./app/client/modules/samplernn/views/samplernn.import.js ***! \****************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); var samplernnActions = _interopRequireWildcard(_samplernn); var _select = __webpack_require__(/*! ../../../common/select.component */ "./app/client/common/select.component.js"); var _select2 = _interopRequireDefault(_select); var _textInput = __webpack_require__(/*! ../../../common/textInput.component */ "./app/client/common/textInput.component.js"); var _textInput2 = _interopRequireDefault(_textInput); var _button = __webpack_require__(/*! ../../../common/button.component */ "./app/client/common/button.component.js"); var _button2 = _interopRequireDefault(_button); var _dataset = __webpack_require__(/*! ../../../dataset/dataset.component */ "./app/client/dataset/dataset.component.js"); var _dataset2 = _interopRequireDefault(_dataset); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var samplernnModule = { name: 'samplernn', datatype: 'audio' }; var SampleRNNImport = function (_Component) { _inherits(SampleRNNImport, _Component); function SampleRNNImport() { _classCallCheck(this, SampleRNNImport); var _this = _possibleConstructorReturn(this, (SampleRNNImport.__proto__ || Object.getPrototypeOf(SampleRNNImport)).call(this)); _this.state = { folder_id: 1, import_action: 'Hotlink', url_base: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4279/', selected: {} }; return _this; } _createClass(SampleRNNImport, [{ key: 'componentWillMount', value: function componentWillMount() { var id = this.props.match.params.id || localStorage.getItem('samplernn.last_id'); console.log('load dataset:', id); var _props = this.props, match = _props.match, samplernn = _props.samplernn, samplernnActions = _props.samplernnActions; if (id === 'new') return; if (id) { if (parseInt(id)) localStorage.setItem('samplernn.last_id', id); if (!samplernn.folder || samplernn.folder.id !== id) { this.props.actions.load_directories(id); } } } }, { key: 'render', value: function render() { var _this2 = this; var samplernn = this.props.samplernn; var datasets = [], folder = void 0; if (this.props.samplernn.data) { datasets = (this.props.samplernn.data.folders || []).map(function (folder) { return [folder.name, folder.id]; }); folder = this.props.samplernn.data.folderLookup.unsorted; } return (0, _preact.h)( 'div', { className: 'app top' }, (0, _preact.h)( 'div', { 'class': 'heading' }, (0, _preact.h)( 'h1', null, 'Import' ) ), (0, _preact.h)( 'div', { 'class': 'params form row datasets' }, (0, _preact.h)( 'div', { 'class': 'row dataset' }, (0, _preact.h)('div', { 'class': 'col' }), (0, _preact.h)('div', { 'class': 'col' }), (0, _preact.h)('div', { 'class': 'col' }), (0, _preact.h)( 'div', { 'class': 'col' }, (0, _preact.h)( 'h2', null, 'Import to dataset' ), (0, _preact.h)(_select2.default, { title: 'Destination dataset', options: datasets, name: 'folder_id', opt: this.state, onChange: function onChange(name, value) { return _this2.setState({ folder_id: value }); } }), (0, _preact.h)(_select2.default, { title: 'Import action', options: ['Hotlink', 'Upload'], name: 'import_action', opt: this.state, onChange: function onChange(name, value) { return _this2.setState({ import_action: value }); } }), (0, _preact.h)(_textInput2.default, { title: 'Remote URL base', value: this.state.url_base, placeholder: 'http://', onSave: function onSave(value) { return _this2.setState({ url_base: value }); } }), (0, _preact.h)( _button2.default, { title: '', onClick: function onClick() { return _this2.doImport(); } }, 'Import' ) ) ) ), (0, _preact.h)(_dataset2.default, { loading: samplernn.loading, progress: samplernn.progress, module: samplernnModule, data: samplernn.data, id: 'unsorted', folder: folder, history: this.props.history, onPickDataset: function onPickDataset(dataset) { return _this2.toggle(dataset.name, _this2.state.selected[name]); }, beforeRow: function beforeRow(dataset) { return _this2.beforeRow(dataset); }, afterRow: function afterRow(dataset) { return _this2.afterRow(dataset); } }) ); } }, { key: 'toggle', value: function toggle(name) { this.setState(_extends({}, this.state, { selected: _extends({}, this.state.selected, _defineProperty({}, name, !this.state.selected[name])) })); } }, { key: 'beforeRow', value: function beforeRow(dataset) { // console.log(dataset) } }, { key: 'afterRow', value: function afterRow(dataset) { var name = dataset.name; return (0, _preact.h)( 'div', null, (0, _preact.h)('input', { type: 'checkbox', value: name, checked: !!this.state.selected[name] }) ); } }, { key: 'doImport', value: function doImport() { var samplernn = this.props.samplernn; console.log(this.state); this.props.actions.import_files(this.state, samplernn.data.datasetLookup, samplernn.data.fileLookup); } }]); return SampleRNNImport; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { samplernn: state.module.samplernn, runner: state.system.runner, task: state.task }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNImport); /***/ }), /***/ "./app/client/modules/samplernn/views/samplernn.new.js": /*!*************************************************************!*\ !*** ./app/client/modules/samplernn/views/samplernn.new.js ***! \*************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); var samplernnActions = _interopRequireWildcard(_samplernn); var _samplernn2 = __webpack_require__(/*! ../samplernn.module */ "./app/client/modules/samplernn/samplernn.module.js"); var _samplernn3 = _interopRequireDefault(_samplernn2); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function SampleRNNNew(props) { return (0, _preact.h)(_common.Views.New, { db: props.samplernn, path: '/samplernn/datasets/', actions: props.actions, module: _samplernn3.default, history: props.history }); } var mapStateToProps = function mapStateToProps(state) { return { samplernn: state.module.samplernn }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNNew); /***/ }), /***/ "./app/client/modules/samplernn/views/samplernn.results.js": /*!*****************************************************************!*\ !*** ./app/client/modules/samplernn/views/samplernn.results.js ***! \*****************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); var samplernnActions = _interopRequireWildcard(_samplernn); var _audioPlayer = __webpack_require__(/*! ../../../common/audioPlayer/audioPlayer.actions */ "./app/client/common/audioPlayer/audioPlayer.actions.js"); var audioPlayerActions = _interopRequireWildcard(_audioPlayer); var _loading = __webpack_require__(/*! ../../../common/loading.component */ "./app/client/common/loading.component.js"); var _loading2 = _interopRequireDefault(_loading); var _fileList = __webpack_require__(/*! ../../../common/fileList.component */ "./app/client/common/fileList.component.js"); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var SampleRNNResults = function (_Component) { _inherits(SampleRNNResults, _Component); function SampleRNNResults(props) { _classCallCheck(this, SampleRNNResults); var _this = _possibleConstructorReturn(this, (SampleRNNResults.__proto__ || Object.getPrototypeOf(SampleRNNResults)).call(this)); if (!props.samplernn.data) props.actions.load_directories(); return _this; } _createClass(SampleRNNResults, [{ key: 'render', value: function render() { var _this2 = this; if (this.props.samplernn.loading) return (0, _preact.h)(_loading2.default, { progress: this.props.samplernn.progress }); var _props$samplernn$data = this.props.samplernn.data, folderLookup = _props$samplernn$data.folderLookup, fileLookup = _props$samplernn$data.fileLookup, datasetLookup = _props$samplernn$data.datasetLookup; // const { folderLookup } = samplernn var renders = Object.keys(folderLookup).sort(_util2.default.sort.stringSort.asc).map(function (key) { var folder = folderLookup[key]; var _util$sort$orderByFn = _util2.default.sort.orderByFn('epoch desc'), mapFn = _util$sort$orderByFn.mapFn, sortFn = _util$sort$orderByFn.sortFn; var datasetPairs = folder.datasets.map(function (name) { return datasetLookup[name]; }).map(mapFn).sort(sortFn); var bestRenders = datasetPairs.map(function (pair) { return pair[1]; }).filter(function (dataset) { return dataset.output.length; }).map(function (dataset) { var output = dataset.output; return output.map(function (id) { return fileLookup[id]; }).map(mapFn).sort(sortFn)[0][1]; }); // console.log(bestRenders.map(r => r.epoch)) var path = folder.name === 'unsorted' ? "/samplernn/import/" : "/samplernn/datasets/" + folder.id + "/"; return (0, _preact.h)( 'div', { className: 'col bestRenders' }, (0, _preact.h)( 'h3', null, (0, _preact.h)( _reactRouterDom.Link, { to: path }, folder.name ) ), (0, _preact.h)(_fileList.FileList, { linkFiles: true, files: bestRenders, orderBy: 'date desc', fields: 'name date epoch size', onClick: function onClick(file, e) { e.preventDefault(); e.stopPropagation(); console.log('picked a file', file); _this2.handlePick(file); } }) ); }); return (0, _preact.h)( 'div', { className: 'app samplernn' }, (0, _preact.h)( 'div', { className: 'heading row middle' }, (0, _preact.h)( 'h1', null, 'SampleRNN Results' ) ), (0, _preact.h)( 'div', { 'class': 'rows params renders' }, renders ) ); } }, { key: 'handlePick', value: function handlePick(file) { this.props.audioPlayer.play(file); } }]); return SampleRNNResults; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { samplernn: state.module.samplernn }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch), audioPlayer: (0, _redux.bindActionCreators)(audioPlayerActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNResults); /***/ }), /***/ "./app/client/modules/samplernn/views/samplernn.show.js": /*!**************************************************************!*\ !*** ./app/client/modules/samplernn/views/samplernn.show.js ***! \**************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); var samplernnActions = _interopRequireWildcard(_samplernn); var _samplernn2 = __webpack_require__(/*! ../samplernn.tasks */ "./app/client/modules/samplernn/samplernn.tasks.js"); var samplernnTasks = _interopRequireWildcard(_samplernn2); var _audioPlayer = __webpack_require__(/*! ../../../common/audioPlayer/audioPlayer.actions */ "./app/client/common/audioPlayer/audioPlayer.actions.js"); var audioPlayerActions = _interopRequireWildcard(_audioPlayer); var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); var _dataset = __webpack_require__(/*! ../../../dataset/dataset.form */ "./app/client/dataset/dataset.form.js"); var _dataset2 = _interopRequireDefault(_dataset); var _upload = __webpack_require__(/*! ../../../dataset/upload.status */ "./app/client/dataset/upload.status.js"); var _upload2 = _interopRequireDefault(_upload); var _dataset3 = __webpack_require__(/*! ../../../dataset/dataset.component */ "./app/client/dataset/dataset.component.js"); var _dataset4 = _interopRequireDefault(_dataset3); var _samplernn3 = __webpack_require__(/*! ../samplernn.module */ "./app/client/modules/samplernn/samplernn.module.js"); var _samplernn4 = _interopRequireDefault(_samplernn3); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var SampleRNNShow = function (_Component) { _inherits(SampleRNNShow, _Component); function SampleRNNShow(props) { _classCallCheck(this, SampleRNNShow); var _this = _possibleConstructorReturn(this, (SampleRNNShow.__proto__ || Object.getPrototypeOf(SampleRNNShow)).call(this, props)); _this.datasetActions = _this.datasetActions.bind(_this); return _this; } _createClass(SampleRNNShow, [{ key: 'componentWillMount', value: function componentWillMount() { var id = this.props.match.params.id || localStorage.getItem('samplernn.last_id'); console.log('load dataset:', id); var _props = this.props, match = _props.match, samplernn = _props.samplernn, actions = _props.actions; if (id === 'new') return; if (id) { if (parseInt(id)) localStorage.setItem('samplernn.last_id', id); if (!samplernn.folder || samplernn.folder.id !== id) { // console.log('looooooooooad', id) actions.load_directories(id); } } else { this.props.history.push('/samplernn/new/'); } } }, { key: 'render', value: function render() { var _this2 = this; var _props2 = this.props, samplernn = _props2.samplernn, runner = _props2.runner, match = _props2.match, history = _props2.history; var _ref = samplernn.data || {}, folderLookup = _ref.folderLookup; // console.log(runner) var folder = (folderLookup || {})[samplernn.folder_id] || {}; return (0, _preact.h)( 'div', { className: 'app samplernn' }, (0, _preact.h)( 'div', { className: 'heading' }, (0, _preact.h)( 'h1', null, folder ? folder.name : (0, _preact.h)(_common.Loading, null) ) ), (0, _preact.h)( 'div', { className: 'row' }, folder && folder.name && folder.name !== 'unsorted' && (0, _preact.h)(_dataset2.default, { title: 'Add Files', module: _samplernn4.default, folder: folder, canUpload: true, canAddURL: true }), (0, _preact.h)( 'div', null, (0, _preact.h)(_upload2.default, null), (0, _preact.h)(_common.CurrentTask, { processor: 'gpu' }) ) ), (0, _preact.h)(_dataset4.default, { loading: samplernn.loading, progress: samplernn.progress, id: samplernn.folder_id, module: _samplernn4.default, data: samplernn.data, folder: folder, history: history, onPickFile: function onPickFile(file, e) { e.preventDefault(); e.stopPropagation(); // console.log('picked a file', file) _this2.handlePick(file); }, datasetActions: this.datasetActions }) ); } }, { key: 'datasetActions', value: function datasetActions(dataset) { var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var _props3 = this.props, samplernn = _props3.samplernn, remote = _props3.remote; var input = samplernn.data.fileLookup[dataset.input[0]]; if (!input) return null; if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null; return (0, _preact.h)( 'div', null, (0, _preact.h)( 'div', { 'class': 'actions' }, (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, samplernn.folder_id, 1); } }, 'train' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, samplernn.folder_id, 2); } }, '2x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, samplernn.folder_id, 4); } }, '4x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, samplernn.folder_id, 6); } }, '6x' ), (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.train_task(dataset, samplernn.folder_id, 18); } }, '18x' ) ), dataset.isBuilt ? (0, _preact.h)( 'div', { 'class': 'subtext' }, 'fetched ', (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.clear_cache_task(dataset); } }, 'x' ) ) : isFetching ? (0, _preact.h)( 'div', { 'class': 'subtext' }, 'fetching' ) : (0, _preact.h)( 'div', { 'class': 'subtext' }, (0, _preact.h)( 'span', { 'class': 'link', onClick: function onClick() { return remote.fetch_task(input.url, samplernn.folder_id, input.id, dataset.name); } }, 'fetch' ) ) ); } }, { key: 'handlePick', value: function handlePick(file) { // console.log(file) this.props.audioPlayer.play(file); } }]); return SampleRNNShow; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return { samplernn: state.module.samplernn, runner: state.system.runner }; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch), remote: (0, _redux.bindActionCreators)(samplernnTasks, dispatch), audioPlayer: (0, _redux.bindActionCreators)(audioPlayerActions, dispatch) }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNShow); /***/ }), /***/ "./app/client/queue/queue.actions.js": /*!*******************************************!*\ !*** ./app/client/queue/queue.actions.js ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.stop_queue = exports.start_queue = exports.add_task = exports.stop_task = exports.start_task = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _socket = __webpack_require__(/*! ../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); var _actions2 = _interopRequireDefault(_actions); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var start_task = exports.start_task = function start_task(task) { var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _socket2.default.task.start_task(task, opt); return _extends({ type: _types2.default.task.starting_task, task: task }, opt); }; var stop_task = exports.stop_task = function stop_task(task) { var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _socket2.default.task.stop_task(task, opt); return _extends({ type: _types2.default.task.stopping_task, task: task }, opt); }; var add_task = exports.add_task = function add_task(new_task) { return function (dispatch) { _actions2.default.task.create(new_task).then(function (task) { _socket2.default.task.add_task(task); }); }; }; var start_queue = exports.start_queue = function start_queue(task) { var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _socket2.default.task.start_queue(task, opt); return _extends({ type: _types2.default.task.starting_queue, task: task }, opt); }; var stop_queue = exports.stop_queue = function stop_queue(task) { var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _socket2.default.task.stop_queue(task, opt); return _extends({ type: _types2.default.task.stopping_queue, task: task }, opt); }; /***/ }), /***/ "./app/client/queue/queue.reducer.js": /*!*******************************************!*\ !*** ./app/client/queue/queue.reducer.js ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var _util2 = _interopRequireDefault(_util); var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); var _moment2 = _interopRequireDefault(_moment); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var queueInitialState = { loading: false, error: null, tasks: {}, queue: [], completed: [] }; var dateSort = _util2.default.sort.orderByFn('updated_at desc'); var prioritySort = _util2.default.sort.orderByFn('priority asc'); var queueReducer = function queueReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : queueInitialState; var action = arguments[1]; switch (action.type) { case _types2.default.task.index: return _extends({}, state, { tasks: action.data.reduce(function (a, b) { return a[b.id] = b, a; }, {}), queue: action.data.filter(function (a) { return !a.completed; }).map(dateSort.mapFn).sort(dateSort.sortFn).map(function (pair) { return pair[1].id; }), completed: action.data.filter(function (a) { return a.completed; }).map(prioritySort.mapFn).sort(prioritySort.sortFn).map(function (pair) { return pair[1].id; }) }); case _types2.default.task.create: console.log(action.data); return _extends({}, state, { tasks: _extends({}, state.tasks, _defineProperty({}, action.data.id, action.data)), queue: state.queue.concat([action.data.id]) }); case _types2.default.task.update: return _extends({}, state, { tasks: _extends({}, state.tasks, _defineProperty({}, action.data.id, action.data)) }); case _types2.default.task.destroy: var _state$tasks = state.tasks, deletedTask = _state$tasks[action.data.id], taskLookup = _objectWithoutProperties(_state$tasks, [action.data.id]); return _extends({}, state, { queue: state.queue.filter(function (id) { return id !== deletedTask.id; }), completed: state.completed.filter(function (id) { return id !== deletedTask.id; }), tasks: taskLookup }); case _types2.default.task.task_finish: return _extends({}, state, { queue: state.queue.filter(function (a) { return a !== action.task.id; }), completed: [action.task.id].concat(state.completed) }); default: return state; } }; exports.default = queueReducer; /***/ }), /***/ "./app/client/socket/index.js": /*!************************************!*\ !*** ./app/client/socket/index.js ***! \************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); var _socket2 = __webpack_require__(/*! ./socket.actions */ "./app/client/socket/socket.actions.js"); var actions = _interopRequireWildcard(_socket2); var _socket3 = __webpack_require__(/*! ./socket.system */ "./app/client/socket/socket.system.js"); var system = _interopRequireWildcard(_socket3); var _socket4 = __webpack_require__(/*! ./socket.live */ "./app/client/socket/socket.live.js"); var live = _interopRequireWildcard(_socket4); var _socket5 = __webpack_require__(/*! ./socket.task */ "./app/client/socket/socket.task.js"); var task = _interopRequireWildcard(_socket5); var _socket6 = __webpack_require__(/*! ./socket.api */ "./app/client/socket/socket.api.js"); var api = _interopRequireWildcard(_socket6); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = { socket: _socket.socket, actions: actions, system: system, live: live, task: task, api: api }; _socket.socket.on('status', function (data) { console.log('got status', data.key, data.value); _store.store.dispatch(_extends({ type: _types2.default.socket.status }, data)); switch (data.key) { case 'processing': _store.store.dispatch(_extends({ type: 'SET_PARAM' }, data)); break; default: break; } }); /***/ }), /***/ "./app/client/socket/socket.actions.js": /*!*********************************************!*\ !*** ./app/client/socket/socket.actions.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.syscall_async = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.run_system_command = run_system_command; exports.disk_usage = disk_usage; exports.list_directory = list_directory; exports.run_script = run_script; exports.upload_file = upload_file; var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); var _v2 = _interopRequireDefault(_v); var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function run_system_command(opt) { return syscall_async('run_system_command', opt); } function disk_usage(opt) { return syscall_async('run_system_command', _extends({ cmd: 'du' }, opt)); } function list_directory(opt) { return syscall_async('list_directory', opt).then(function (res) { return res.files; }); } function run_script(opt) { return syscall_async('run_script', opt); } function upload_file(opt) { return syscall_async('upload_file', opt); } var syscall_async = exports.syscall_async = function syscall_async(tag, payload) { var ttl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10000; ttl = payload.ttl || ttl; return new Promise(function (resolve, reject) { var uuid = (0, _v2.default)(); var timeout = setTimeout(function () { _socket.socket.off('system_res', cb); reject('timeout'); }, ttl); var cb = function cb(data) { if (!data.uuid) return; if (data.uuid === uuid) { clearTimeout(timeout); _socket.socket.off('system_res', cb); resolve(data); } }; _socket.socket.emit('system', { cmd: tag, payload: payload, uuid: uuid }); _socket.socket.on('system_res', cb); }); }; /***/ }), /***/ "./app/client/socket/socket.api.js": /*!*****************************************!*\ !*** ./app/client/socket/socket.api.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _socket.socket.on('api_res', function (data) { // console.log('system response', data) var type = _types2.default[data.datatype]; console.log('api_res', data.type, data.datatype); if (!type) return console.error('socket:api_res bad datatype', data.datatype); switch (data.type) { case 'create': return (0, _store.dispatch)({ type: type.create, source: 'socket', data: data.data }); case 'update': return (0, _store.dispatch)({ type: type.update, source: 'socket', data: data.data }); case 'destroy': return (0, _store.dispatch)({ type: type.destroy, source: 'socket', data: data.data }); default: break; } }); /***/ }), /***/ "./app/client/socket/socket.connection.js": /*!************************************************!*\ !*** ./app/client/socket/socket.connection.js ***! \************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.socket = undefined; var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var socket = exports.socket = io.connect('/client'); // SOCKET ACTIONS socket.on('connect', function () { return _store.store.dispatch({ type: _types2.default.socket.connect }); }); socket.on('connect_error', function (error) { return _store.store.dispatch({ type: _types2.default.socket.connect_error, error: error }); }); socket.on('reconnect', function (attempt) { return _store.store.dispatch({ type: _types2.default.socket.reconnect, attempt: attempt }); }); socket.on('reconnecting', function () { return _store.store.dispatch({ type: _types2.default.socket.reconnecting }); }); socket.on('reconnect_error', function (error) { return _store.store.dispatch({ type: _types2.default.socket.reconnect_error, error: error }); }); socket.on('reconnect_failed', function (error) { return _store.store.dispatch({ type: _types2.default.socket.reconnect_failed, error: error }); }); socket.on('disconnect', function () { return _store.store.dispatch({ type: _types2.default.socket.disconnect }); }); socket.on('error', function (error) { return _store.store.dispatch({ type: _types2.default.socket.error, error: error }); }); /***/ }), /***/ "./app/client/socket/socket.live.js": /*!******************************************!*\ !*** ./app/client/socket/socket.live.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.list_checkpoints = list_checkpoints; exports.list_epochs = list_epochs; exports.list_sequences = list_sequences; exports.load_epoch = load_epoch; exports.load_sequence = load_sequence; exports.seek = seek; exports.pause = pause; exports.play = play; exports.get_params = get_params; exports.set_param = set_param; var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _player = __webpack_require__(/*! ../live/player */ "./app/client/live/player.js"); var player = _interopRequireWildcard(_player); var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _socket.socket.on('res', function (data) { // console.log('socket:', data.cmd) switch (data.cmd) { case 'get_last_frame': if (data.res !== 'working') { _socket.socket.emit('cmd', { cmd: 'get_last_frame' }); } break; case 'get_params': data.res && (0, _store.dispatch)({ type: _types2.default.socket.load_params, opt: data.res }); data.res && player.toggleFPS(data.res.processing); break; case 'list_checkpoints': (0, _store.dispatch)({ type: _types2.default.socket.list_checkpoints, checkpoints: data.res }); break; case 'list_epochs': (0, _store.dispatch)({ type: _types2.default.socket.list_epochs, epochs: data.res }); break; case 'list_sequences': (0, _store.dispatch)({ type: _types2.default.socket.list_sequences, sequences: data.res }); break; default: break; } // console.log(data) }); _socket.socket.on('frame', player.onFrame); function list_checkpoints(module) { _socket.socket.emit('cmd', { cmd: 'list_checkpoints', payload: module }); } function list_epochs(module, checkpoint_name) { _socket.socket.emit('cmd', { cmd: 'list_epochs', payload: module + '/' + checkpoint_name }); } function list_sequences(module) { _socket.socket.emit('cmd', { cmd: 'list_sequences', payload: module }); } function load_epoch(checkpoint_name, epoch) { console.log(">> SWITCH CHECKPOINT", checkpoint_name, epoch); _socket.socket.emit('cmd', { cmd: 'load_epoch', payload: checkpoint_name + ':' + epoch }); } function load_sequence(sequence) { _socket.socket.emit('cmd', { cmd: 'load_sequence', payload: sequence }); } function seek(frame) { _socket.socket.emit('cmd', { cmd: 'seek', payload: frame }); } function pause(frame) { _socket.socket.emit('cmd', { cmd: 'pause' }); } function play(frame) { _socket.socket.emit('cmd', { cmd: 'play' }); } function get_params() { _socket.socket.emit('cmd', { cmd: 'get_params' }); } function set_param(key, value) { _socket.socket.emit('cmd', { cmd: 'set_param', payload: { 'key': key, 'value': value } }); } /***/ }), /***/ "./app/client/socket/socket.system.js": /*!********************************************!*\ !*** ./app/client/socket/socket.system.js ***! \********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _socket.socket.on('system_res', function (data) { // console.log('system response', data) switch (data.type) { case 'relay_connected': return (0, _store.dispatch)({ type: _types2.default.system.relay_connected }); case 'relay_disconnected': return (0, _store.dispatch)({ type: _types2.default.system.relay_disconnected }); case 'rpc_connected': return (0, _store.dispatch)({ type: _types2.default.system.rpc_connected, runner: data.runner }); case 'rpc_disconnected': return (0, _store.dispatch)({ type: _types2.default.system.rpc_disconnected }); case 'relay_status': return (0, _store.dispatch)({ type: data.rpc_connected ? _types2.default.system.rpc_connected : _types2.default.system.rpc_disconnected, runner: data.runner }); case 'site': return (0, _store.dispatch)({ type: _types2.default.system.load_site, site: data.site }); default: break; } }); /***/ }), /***/ "./app/client/socket/socket.task.js": /*!******************************************!*\ !*** ./app/client/socket/socket.task.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.stop_queue = exports.start_queue = exports.stop_task = exports.start_task = exports.remove_task = exports.add_task = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.emit = emit; var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var finishTimeout = void 0; _socket.socket.on('task_res', function (data) { console.log('task response', data); if (data.task) { (0, _store.dispatch)({ type: _types2.default.task.update, data: data.task }); } switch (data.type) { case 'start': // return dispatch({ type: types.system.rpc_connected, runner: data.runner }) break; case 'stop': break; // begin and finish calls often arrive out of order, if the old task was preempted case 'task_begin': (0, _store.dispatch)({ type: _types2.default.task.task_begin, task: data.task }); break; case 'task_finish': (0, _store.dispatch)({ type: _types2.default.task.task_finish, task: data.task }); break; case 'kill': break; case 'stdout': return (0, _store.dispatch)({ type: _types2.default.system.stdout, data: data }); break; case 'stderr': return (0, _store.dispatch)({ type: _types2.default.system.stderr, data: data }); break; case 'add': break; case 'remove': break; case 'start_queue': break; case 'stop_queue': break; case 'list': break; case 'set_priority': break; case 'progress': (0, _store.dispatch)({ type: _types2.default.task.progress, task: data.task }); break; case 'epoch': (0, _store.dispatch)({ type: _types2.default.task.epoch, task: data.task }); break; case 'task_error': return console.log('task error', data); default: return console.log('no such task command', data.type); } }); function emit(type) { var task = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; _socket.socket.emit('task', _extends({ type: type, task: task }, opt)); } var add_task = exports.add_task = function add_task(task) { var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return emit('add', task, opt); }; var remove_task = exports.remove_task = function remove_task(task) { var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return emit('remove', task, opt); }; var start_task = exports.start_task = function start_task(task) { var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return emit('start', task, opt); }; var stop_task = exports.stop_task = function stop_task(task) { var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return emit('stop', task, opt); }; var start_queue = exports.start_queue = function start_queue() { var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return emit('start_queue', {}, opt); }; var stop_queue = exports.stop_queue = function stop_queue() { var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return emit('stop_queue', {}, opt); }; /***/ }), /***/ "./app/client/store.js": /*!*****************************!*\ !*** ./app/client/store.js ***! \*****************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dispatch = exports.store = exports.history = undefined; var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRouterRedux = __webpack_require__(/*! react-router-redux */ "./node_modules/react-router-redux/lib/index.js"); var _reduxThunk = __webpack_require__(/*! redux-thunk */ "./node_modules/redux-thunk/lib/index.js"); var _reduxThunk2 = _interopRequireDefault(_reduxThunk); var _createBrowserHistory = __webpack_require__(/*! history/createBrowserHistory */ "./node_modules/history/createBrowserHistory.js"); var _createBrowserHistory2 = _interopRequireDefault(_createBrowserHistory); var _system = __webpack_require__(/*! ./system/system.reducer */ "./app/client/system/system.reducer.js"); var _system2 = _interopRequireDefault(_system); var _dashboard = __webpack_require__(/*! ./dashboard/dashboard.reducer */ "./app/client/dashboard/dashboard.reducer.js"); var _dashboard2 = _interopRequireDefault(_dashboard); var _live = __webpack_require__(/*! ./live/live.reducer */ "./app/client/live/live.reducer.js"); var _live2 = _interopRequireDefault(_live); var _upload = __webpack_require__(/*! ./dataset/upload.reducer */ "./app/client/dataset/upload.reducer.js"); var _upload2 = _interopRequireDefault(_upload); var _queue = __webpack_require__(/*! ./queue/queue.reducer */ "./app/client/queue/queue.reducer.js"); var _queue2 = _interopRequireDefault(_queue); var _audioPlayer = __webpack_require__(/*! ./common/audioPlayer/audioPlayer.reducer */ "./app/client/common/audioPlayer/audioPlayer.reducer.js"); var _audioPlayer2 = _interopRequireDefault(_audioPlayer); var _module = __webpack_require__(/*! ./modules/module.reducer */ "./app/client/modules/module.reducer.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var appReducer = (0, _redux.combineReducers)({ system: _system2.default, dashboard: _dashboard2.default, live: _live2.default, upload: _upload2.default, queue: _queue2.default, router: _reactRouterRedux.routerReducer, module: _module.moduleReducer, audioPlayer: _audioPlayer2.default }); // import navReducer from './nav.reducer' var history = exports.history = (0, _createBrowserHistory2.default)(); var store = exports.store = (0, _redux.createStore)(appReducer, (0, _redux.compose)((0, _redux.applyMiddleware)( // createLogger(), _reduxThunk2.default, (0, _reactRouterRedux.routerMiddleware)(history)))); var dispatch = exports.dispatch = store.dispatch; /***/ }), /***/ "./app/client/system/system.actions.js": /*!*********************************************!*\ !*** ./app/client/system/system.actions.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.enqueue_test_task = exports.changeTool = exports.listDirectory = exports.run = undefined; var _socket = __webpack_require__(/*! ../socket */ "./app/client/socket/index.js"); var _socket2 = _interopRequireDefault(_socket); var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // import actions from '../actions' var run = exports.run = function run(cmd) { return function (dispatch) { dispatch({ type: _types2.default.system.running_command, cmd: cmd }); _socket2.default.actions.run_system_command({ cmd: cmd }).then(function (data) { dispatch({ type: _types2.default.system.command_output, data: data }); }); }; }; var listDirectory = exports.listDirectory = function listDirectory(opt) { return function (dispatch) { dispatch({ type: _types2.default.system.listing_directory, opt: opt }); _socket2.default.actions.list_directory(opt).then(function (data) { dispatch({ type: _types2.default.system.list_directory, data: data }); }); }; }; var changeTool = exports.changeTool = function changeTool(tool) { localStorage.setItem('system.last_tool', tool); return { type: _types2.default.app.change_tool, tool: tool }; }; var enqueue_test_task = exports.enqueue_test_task = function enqueue_test_task(dataset) { return function (dispatch) { var task = { module: 'test', activity: 'cpu', dataset: dataset // return actions.queue.add_task(task) }; }; }; window.addEventListener('keyDown', function (e) { if (e.altKey) { switch (e.keyCode) { case 192: // tilde - switch tool break; case 49: // 1 break; case 50: // 2 break; case 51: // 3 break; case 52: // 4 break; case 53: // 5 break; case 54: // 6 break; case 55: // 7 break; case 56: // 8 break; case 57: // 9 break; case 48: // 0 break; } } }); /***/ }), /***/ "./app/client/system/system.component.js": /*!***********************************************!*\ !*** ./app/client/system/system.component.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); var _group = __webpack_require__(/*! ../common/group.component */ "./app/client/common/group.component.js"); var _group2 = _interopRequireDefault(_group); var _param = __webpack_require__(/*! ../common/param.component */ "./app/client/common/param.component.js"); var _param2 = _interopRequireDefault(_param); var _system = __webpack_require__(/*! ./system.actions */ "./app/client/system/system.actions.js"); var systemActions = _interopRequireWildcard(_system); var _live = __webpack_require__(/*! ../live/live.actions */ "./app/client/live/live.actions.js"); var liveActions = _interopRequireWildcard(_live); var _queue = __webpack_require__(/*! ../queue/queue.actions */ "./app/client/queue/queue.actions.js"); var queueActions = _interopRequireWildcard(_queue); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var cpu_test_task = { activity: 'cpu', module: 'test', dataset: 'test', epochs: 1, opt: {} }; var gpu_test_task = { activity: 'gpu', module: 'test', dataset: 'test', epochs: 1, opt: {} }; var live_test_task = { activity: 'live', module: 'test', dataset: 'test', epochs: 1, opt: {} }; var wait_test_task = { activity: 'wait', module: 'test', dataset: 'test', epochs: 1, opt: {} }; var fruits = ["apple", "pear", "orange", "strawberry"]; function choice(a) { return a[Math.floor(Math.random() * a.length)]; } var System = function (_Component) { _inherits(System, _Component); function System(props) { _classCallCheck(this, System); return _possibleConstructorReturn(this, (System.__proto__ || Object.getPrototypeOf(System)).call(this)); } _createClass(System, [{ key: 'componentDidUpdate', value: function componentDidUpdate() { if (this._screen.scrollHeight > this._screen.scrollTop - this._screen.offsetHeight + 100) { this._screen.scrollTop = this._screen.scrollHeight; } } }, { key: 'render', value: function render() { var _props = this.props, site = _props.site, server = _props.server, relay = _props.relay, runner = _props.runner, rpc = _props.rpc, actions = _props.actions; return (0, _preact.h)( 'div', { className: 'app system' }, (0, _preact.h)( 'div', { className: 'heading' }, (0, _preact.h)( 'h1', null, site.name, ' system' ) ), (0, _preact.h)( 'div', { className: 'row params' }, (0, _preact.h)( 'div', { className: 'column' }, (0, _preact.h)( _group2.default, { title: 'Status' }, (0, _preact.h)( _param2.default, { title: 'Server' }, server.status ), server.error && (0, _preact.h)( _param2.default, { title: 'Server error' }, server.error.message ), (0, _preact.h)( _param2.default, { title: 'Relay' }, relay.status ), (0, _preact.h)( _param2.default, { title: 'RPC' }, rpc.status ), (0, _preact.h)( _param2.default, { title: 'CPU' }, this.renderStatus(runner.cpu) ), (0, _preact.h)( _param2.default, { title: 'GPU' }, this.renderStatus(runner.gpu) ) ), (0, _preact.h)( _group2.default, { title: 'Diagnostics' }, (0, _preact.h)( _param2.default, { title: 'Check GPU' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.system.run('nvidia-smi'); } }, 'nvidia-smi' ) ), (0, _preact.h)( _param2.default, { title: 'List processes' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.system.run('ps'); } }, 'ps' ) ), (0, _preact.h)( _param2.default, { title: 'List users' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.system.run('w'); } }, 'w' ) ), (0, _preact.h)( _param2.default, { title: 'Disk free space' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.system.run('df'); } }, 'df' ) ) ), (0, _preact.h)( _group2.default, { title: 'Tasks' }, (0, _preact.h)( _param2.default, { title: 'Kill task' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.stop_task('cpu'); } }, 'CPU' ), (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.stop_task('gpu'); } }, 'GPU' ) ), (0, _preact.h)( _param2.default, { title: 'Queue' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.start_queue(); } }, 'Start' ), (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.stop_queue(); } }, 'Stop' ) ) ), (0, _preact.h)( _group2.default, { title: 'Test' }, (0, _preact.h)( _param2.default, { title: 'CPU Test Task' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.start_task(cpu_test_task, { preempt: true, watch: true }); } }, 'Start' ), (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.stop_task(runner.cpu.task); } }, 'Stop' ) ), (0, _preact.h)( _param2.default, { title: 'GPU Test Task' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.start_task(gpu_test_task, { preempt: true, watch: true }); } }, 'Start' ), (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.stop_task(runner.gpu.task); } }, 'Stop' ) ), (0, _preact.h)( _param2.default, { title: 'Live Test Task' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.start_task(live_test_task, { preempt: true, watch: true }); } }, 'Start' ), (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.stop_task(runner.cpu.task); } }, 'Stop' ) ), (0, _preact.h)( _param2.default, { title: 'Test Live RPC' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.live.get_params(); } }, 'Get' ), (0, _preact.h)( 'button', { onClick: function onClick() { return actions.live.set_param('fruit', choice(fruits)); } }, 'Set' ) ), (0, _preact.h)( _param2.default, { title: 'Queue Tests' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.system.enqueue_test_task(choice(fruits)); } }, '+Add test task' ) ), (0, _preact.h)( _param2.default, { title: '' }, (0, _preact.h)( 'button', { onClick: function onClick() { return actions.queue.start_task(wait_test_task, { preempt: true, watch: true }); } }, 'Wait and Buzz' ) ) ) ), this.renderCommandOutput() ) ); } }, { key: 'renderStatus', value: function renderStatus(processor) { if (!processor) { return 'unknown'; } if (processor.status === 'IDLE') { return 'idle'; } var task = processor.task; return task.activity + ' ' + task.module; } }, { key: 'renderCommandOutput', value: function renderCommandOutput() { var _this2 = this; var _props2 = this.props, cmd = _props2.cmd, stdout = _props2.stdout, stderr = _props2.stderr; var output = void 0; if (cmd.loading) { output = 'Loading: ' + cmd.name; } else if (cmd.loaded) { if (cmd.error) { output = 'Error: ' + cmd.name + '\n\n' + JSON.stringify(cmd.error, null, 2); } else { output = cmd.stdout; if (cmd.stderr) { output += '\n\n_________________________________\n\n'; output += cmd.stderr; } } } else { output = stdout; if (stderr.length) { output += '\n\n_________________________________\n\n'; output += stderr; } } return (0, _preact.h)( 'div', null, (0, _preact.h)( 'div', { ref: function ref(_ref) { return _this2._screen = _ref; }, className: 'screen' }, output ) ); } }]); return System; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { return _extends({}, state.system, state.live); }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { return { actions: { system: (0, _redux.bindActionCreators)(systemActions, dispatch), queue: (0, _redux.bindActionCreators)(queueActions, dispatch), live: (0, _redux.bindActionCreators)(liveActions, dispatch) } }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(System); /***/ }), /***/ "./app/client/system/system.reducer.js": /*!*********************************************!*\ !*** ./app/client/system/system.reducer.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); var _types2 = _interopRequireDefault(_types); var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); var _moment2 = _interopRequireDefault(_moment); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var FileSaver = __webpack_require__(/*! file-saver */ "./node_modules/file-saver/FileSaver.js"); var systemInitialState = { loading: false, error: null, site: { name: 'loading' }, app: { tool: localStorage.getItem('system.last_tool') || 'pix2pix' }, server: { connected: false, status: "disconnected", error: null }, relay: { connected: false, status: "unknown", error: null }, rpc: { connected: false, status: "disconnected", error: null }, cmd: { loading: false, loaded: false, name: null, error: null, stdout: "", stderr: "" }, runner: { cpu: { status: 'IDLE', task: {} }, gpu: { status: 'IDLE', task: {} } }, stdout: "", stderr: "" }; var modules = ['pix2pix', 'samplernn', 'pix2wav'].reduce(function (a, b) { return a[b] = b, a; }, {}); var systemReducer = function systemReducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : systemInitialState; var action = arguments[1]; // console.log(action.type) var processor = null; switch (action.type) { case _types2.default.socket.connect: case _types2.default.socket.reconnecting: return _extends({}, state, { server: { status: 'connected', connected: true, error: null } }); case _types2.default.socket.reconnect: return _extends({}, state, { server: { status: 'reconnecting (attempt ' + action.attempt + ')', connected: false, error: null } }); case _types2.default.socket.connect_error: case _types2.default.socket.reconnect_error: case _types2.default.socket.disconnect: case _types2.default.socket.reconnect_failed: return _extends({}, state, { server: { status: 'disconnected', connected: false, error: action.error || null } }); case _types2.default.socket.error: return _extends({}, state, { server: _extends({}, state.socket, { error: action.error }) }); case _types2.default.system.relay_connected: return _extends({}, state, { relay: { status: 'connected', connected: true, error: null } }); case _types2.default.system.relay_disconnected: return _extends({}, state, { relay: { status: 'disconnected', connected: false, error: null }, rpc: { status: 'disconnected', connected: false, error: null } }); case _types2.default.system.rpc_connected: return _extends({}, state, { rpc: { status: 'connected', connected: true, error: null }, runner: action.runner }); case _types2.default.system.rpc_disconnected: return _extends({}, state, { rpc: { status: 'disconnected', connected: false, error: null }, runner: action.runner || state.runner }); case _types2.default.system.load_site: document.querySelector('title').innerHTML = action.site.name + '.cortex'; var tool = state.app.tool; var path = window.location.pathname.split('/')[1]; if (path in modules) { tool = path; } return _extends({}, state, { site: action.site, app: _extends({}, state.app, { tool: tool }) }); case _types2.default.system.running_command: return _extends({}, state, { cmd: { loading: true, loaded: false, name: action.cmd, error: null, stdout: null, stderr: null } }); case _types2.default.system.command_output: return _extends({}, state, { cmd: { loading: false, loaded: true, name: action.data.cmd, error: action.data.error, stdout: action.data.stdout, stderr: action.data.stderr } }); case _types2.default.task.task_begin: console.log('task begin', action.task, action.task.processor); return _extends({}, state, { runner: _extends({}, state.runner, _defineProperty({}, action.task.processor, { status: 'RUNNING', task: action.task })), cmd: _extends({}, state.cmd, { loaded: false, stdout: "", stderr: "" }), stdout: "", stderr: "" }); case _types2.default.task.task_finish: if (action.task === 'cpu' || state.runner.cpu.task && action.task && state.runner.cpu.task.uuid === action.task.uuid) { processor = 'cpu'; } else if (action.task === 'gpu' || state.runner.gpu.task && action.task && state.runner.gpu.task.uuid === action.task.uuid) { processor = 'gpu'; } else { processor = null; } return _extends({}, state, { rpc: { connected: false, status: "disconnected", error: null }, runner: processor ? _extends({}, state.runner, _defineProperty({}, processor, { status: 'IDLE', task: {} })) : state.runner }); case _types2.default.app.change_tool: return _extends({}, state, { app: _extends({}, state.app, { tool: action.tool }) }); case _types2.default.system.stdout: if (action.data.processor && state.runner[action.data.processor]) { return _extends({}, state, { runner: _extends({}, state.runner, _defineProperty({}, action.data.processor, _extends({}, state.runner[action.data.processor], { last_message: action.data.data }))), stdout: state.stdout + action.data.data }); } return _extends({}, state, { stdout: state.stdout + action.data.data }); case _types2.default.system.stderr: return _extends({}, state, { last_message: action.data.data, stderr: state.stderr + action.data.data }); default: return state; } }; exports.default = systemReducer; /***/ }), /***/ "./app/client/types.js": /*!*****************************!*\ !*** ./app/client/types.js ***! \*****************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _crud = __webpack_require__(/*! ./api/crud.types */ "./app/client/api/crud.types.js"); exports.default = { system: { load_site: 'SYSTEM_LOAD_SITE', running_command: 'SYSTEM_RUNNING_COMMAND', command_output: 'SYSTEM_COMMAND_OUTPUT', relay_connected: 'SYSTEM_RELAY_CONNECTED', relay_disconnected: 'SYSTEM_RELAY_DISCONNECTED', rpc_connected: 'SYSTEM_RPC_CONNECTED', rpc_disconnected: 'SYSTEM_RPC_DISCONNECTED', list_directory: 'SYSTEM_LIST_DIRECTORY', listing_directory: 'SYSTEM_LISTING_DIRECTORY', stdout: 'SYSTEM_STDOUT', stderr: 'SYSTEM_STDERR' }, app: { change_tool: "APP_CHANGE_TOOL", load_progress: "APP_LOAD_PROGRESS" }, folder: (0, _crud.crud_type)('folder', []), file: (0, _crud.crud_type)('file', []), task: (0, _crud.crud_type)('task', ['starting_task', 'stopping_task', 'task_begin', 'task_finish', 'start_queue', 'stop_queue', 'starting_queue', 'stopping_queue', 'progress', 'epoch']), socket: { connect: 'SOCKET_CONNECT', connect_error: 'SOCKET_CONNECT_ERROR', reconnect: 'SOCKET_RECONNECT', reconnecting: 'SOCKET_RECONNECTING', reconnect_error: 'SOCKET_RECONNECT_ERROR', reconnect_failed: 'SOCKET_RECONNECT_FAILED', disconnect: 'SOCKET_DISCONNECT', error: 'SOCKET_ERROR', status: 'SOCKET_STATUS', load_params: 'SOCKET_LOAD_PARAMS', list_checkpoints: 'SOCKET_LIST_CHECKPOINTS', list_sequences: 'SOCKET_LIST_SEQUENCES', list_epochs: 'SOCKET_LIST_EPOCHS' }, player: { get_params: 'GET_PARAMS', set_param: 'SET_PARAM', loading_checkpoints: 'LOADING_CHECKPOINTS', loading_checkpoint: 'LOADING_CHECKPOINT', list_checkpoints: 'LIST_CHECKPOINTS', loading_sequences: 'LOADING_SEQUENCES', loading_sequence: 'LOADING_SEQUENCE', load_sequence: 'LOAD_SEQUENCE', loading_epochs: 'LOADING_EPOCHS', load_epoch: 'LOAD_EPOCH', set_fps: 'SET_FPS', seeking: 'SEEKING', pausing: 'PAUSING', playing: 'PLAYING', current_frame: 'CURRENT_FRAME', start_recording: 'START_RECORDING', add_record_frame: 'ADD_RECORD_FRAME', save_frame: 'SAVE_FRAME', saving_video: 'SAVING_VIDEO', save_video: 'SAVE_VIDEO' }, audioPlayer: { play: 'AUDIO_PLAY', pause: 'AUDIO_PAUSE', resume: 'AUDIO_RESUME', enqueue: 'AUDIO_ENQUEUE' }, dataset: { load: 'DATASET_LOAD', set_folder: 'DATASET_SET_FOLDER', upload_files: 'DATASET_UPLOAD_FILES', file_progress: 'DATASET_FILE_PROGRESS', file_uploaded: 'DATASET_FILE_UPLOADED', fetch_url: 'DATASET_FETCH_URL', fetch_progress: 'DATASET_FETCH_PROGRESS' }, samplernn: { init: 'SAMPLERNN_INIT', set_folder: 'SAMPLERNN_SET_FOLDER', load_loss: 'SAMPLERNN_LOAD_LOSS', load_graph: 'SAMPLERNN_LOAD_GRAPH' // queue and train // update checkpoint settings // reset checkpoint settings // queue new checkpoint }, pix2pix: (0, _crud.with_type)('pix2pix', ['init', 'set_folder']), pix2pixhd: (0, _crud.with_type)('pix2pixhd', ['init', 'set_folder']), pix2wav: (0, _crud.with_type)('pix2wav', ['init', 'set_folder']), wav2pix: (0, _crud.with_type)('wav2pix', ['load', 'progress', 'finish', 'zip', 'uploading']), dashboard: (0, _crud.with_type)('dashboard', ['load']) }; /***/ }), /***/ "./app/client/util/format.js": /*!***********************************!*\ !*** ./app/client/util/format.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.timeInSeconds = timeInSeconds; exports.gerund = gerund; exports.commatize = commatize; exports.carbon_date = carbon_date; exports.hush_views = hush_views; exports.hush_threads = hush_threads; exports.hush_size = hush_size; exports.hush_null = hush_null; exports.get_age = get_age; exports.courtesy_s = courtesy_s; function timeInSeconds(n) { return (n / 10).toFixed(1) + ' s.'; } function gerund(s) { return s.replace(/e?$/, 'ing'); } function commatize(n, radix) { radix = radix || 1024; var nums = [], i, counter = 0, r = Math.floor; if (n > radix) { n /= radix; nums.unshift(r(n * 10 % 10)); nums.unshift("."); } do { i = n % 10; n = r(n / 10); if (n && !(++counter % 3)) { i = ' ' + r(i); } nums.unshift(r(i)); } while (n); return nums.join(""); } function carbon_date(date, no_bold) { var span = (+new Date() - new Date(date)) / 1000, color; if (!no_bold && span < 86400) // modified today { color = "new"; } else if (span < 604800) // modifed this week { color = "recent"; } else if (span < 1209600) // modifed 2 weeks ago { color = "med"; } else if (span < 3024000) // modifed 5 weeks ago { color = "old"; } else if (span < 12315200) // modifed 6 months ago { color = "older"; } else { color = "quiet"; } return color; } function hush_views(n, bias, no_bold) { var txt = commatize(n, 1000); bias = bias || 1; n = n || 0; if (n < 30) { return ["quiet", n + " v."]; } if (n < 200) { return ["quiet", txt + " v."]; } else if (n < 500) { return ["quiet", txt + " v."]; } else if (n < 1000) { return ["old", txt + " v."]; } else if (n < 5000) { return ["med", txt + " kv."]; } else if (no_bold || n < 10000) { return ["recent", txt + " kv."]; } else { return ["new", txt + " kv."]; } } function hush_threads(n, bias, no_bold) { var txt = commatize(n, 1000); bias = bias || 1; n = n || 0; if (n < 10) { return ["quiet", n + " t."]; } else if (n < 25) { return ["old", txt + " t."]; } else if (n < 50) { return ["med", txt + " t."]; } else if (no_bold || n < 100) { return ["recent", txt + " t."]; } else { return ["new", txt + " t."]; } } function hush_size(n, bias, no_bold) { var txt = commatize(Math.round(n / 1024)); bias = 1 || bias; n = n || 0; if (!n) { return ['', '']; } if (n < 1000) { return ["quiet", n + " b."]; } if (n < 1000000) { return ["quiet", txt + " kb."]; } else if (n < 20000000 / bias) { return ["quiet", txt + " mb."]; } else if (n < 50000000 / bias) { return ["old", txt + " mb."]; } else if (n < 80000000 / bias) { return ["med", txt + " mb."]; } else if (no_bold || n < 170000000 / bias) { return ["recent", txt + " mb."]; } else { return ["new", txt + " mb."]; } } function hush_null(n, unit, no_bold) { var s = unit ? n + " " + unit + "." : n; if (n < 3) { return ["quiet", s]; } else if (n < 6) { return ["older", s]; } else if (n < 10) { return ["old", s]; } else if (n < 16) { return ["med", s]; } else if (no_bold || n < 21) { return ["recent", s]; } else { return ["new", s]; } } function get_age(t) { var age = Math.abs(+Date.now() - new Date(t)) / 1000; var r = Math.floor; var m; if (age < 5) { return "now"; } if (age < 60) { return r(age) + "s"; } age /= 60; if (age < 60) { return r(age) + "m"; } m = r(age % 60); age /= 60; if (m > 0 && age < 2) { return r(age) + "h" + m + "m"; } if (age < 24) { return r(age) + "h"; } age /= 24; if (age < 7) { return r(age) + "d"; } age /= 7; if (age < 12) { return r(age) + "w"; } age /= 4; if (age < 12) { return r(age) + "m"; } age /= 12; return r(age) + "y"; } function courtesy_s(n, s) { return n == 1 ? "" : s || "s"; } /***/ }), /***/ "./app/client/util/hidpi-canvas.js": /*!*****************************************!*\ !*** ./app/client/util/hidpi-canvas.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * HiDPI Canvas Polyfill (1.0.10) * * Author: Jonathan D. Johnson (http://jondavidjohn.com) * Homepage: https://github.com/jondavidjohn/hidpi-canvas-polyfill * Issue Tracker: https://github.com/jondavidjohn/hidpi-canvas-polyfill/issues * License: Apache-2.0 */ (function (prototype) { var pixelRatio = function () { var canvas = window.document.createElement('canvas'), context = canvas.getContext('2d'), backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; return (window.devicePixelRatio || 1) / backingStore; }(), forEach = function forEach(obj, func) { for (var p in obj) { if (obj.hasOwnProperty(p)) { func(obj[p], p); } } }, ratioArgs = { 'fillRect': 'all', 'clearRect': 'all', 'strokeRect': 'all', 'moveTo': 'all', 'lineTo': 'all', 'arc': [0, 1, 2], 'arcTo': 'all', 'bezierCurveTo': 'all', 'isPointinPath': 'all', 'isPointinStroke': 'all', 'quadraticCurveTo': 'all', 'rect': 'all', 'translate': 'all', 'createRadialGradient': 'all', 'createLinearGradient': 'all' }; if (pixelRatio === 1) return; forEach(ratioArgs, function (value, key) { prototype[key] = function (_super) { return function () { var i, len, args = Array.prototype.slice.call(arguments); if (value === 'all') { args = args.map(function (a) { return a * pixelRatio; }); } else if (Array.isArray(value)) { for (i = 0, len = value.length; i < len; i++) { args[value[i]] *= pixelRatio; } } return _super.apply(this, args); }; }(prototype[key]); }); // Stroke lineWidth adjustment prototype.stroke = function (_super) { return function () { this.lineWidth *= pixelRatio; _super.apply(this, arguments); this.lineWidth /= pixelRatio; }; }(prototype.stroke); // Text // prototype.fillText = function (_super) { return function () { var args = Array.prototype.slice.call(arguments); args[1] *= pixelRatio; // x args[2] *= pixelRatio; // y this.font = this.font.replace(/(\d+)(px|em|rem|pt)/g, function (w, m, u) { return m * pixelRatio + u; }); _super.apply(this, args); this.font = this.font.replace(/(\d+)(px|em|rem|pt)/g, function (w, m, u) { return m / pixelRatio + u; }); }; }(prototype.fillText); prototype.strokeText = function (_super) { return function () { var args = Array.prototype.slice.call(arguments); args[1] *= pixelRatio; // x args[2] *= pixelRatio; // y this.font = this.font.replace(/(\d+)(px|em|rem|pt)/g, function (w, m, u) { return m * pixelRatio + u; }); _super.apply(this, args); this.font = this.font.replace(/(\d+)(px|em|rem|pt)/g, function (w, m, u) { return m / pixelRatio + u; }); }; }(prototype.strokeText); })(window.CanvasRenderingContext2D.prototype); ;(function (prototype) { prototype.getContext = function (_super) { return function (type) { var backingStore, ratio, context; if (type == '2d-lodpi') { context = _super.call(this, '2d'); } else if (type === '2d') { context = _super.call(this, '2d'); backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; ratio = (window.devicePixelRatio || 1) / backingStore; if (ratio > 1) { this.style.height = this.height + 'px'; this.style.width = this.width + 'px'; this.width *= ratio; this.height *= ratio; } } else { context = _super.call(this, type); } return context; }; }(prototype.getContext); })(window.HTMLCanvasElement.prototype); /***/ }), /***/ "./app/client/util/index.js": /*!**********************************!*\ !*** ./app/client/util/index.js ***! \**********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _sort = __webpack_require__(/*! ./sort */ "./app/client/util/sort.js"); var sort = _interopRequireWildcard(_sort); var _format = __webpack_require__(/*! ./format */ "./app/client/util/format.js"); var format = _interopRequireWildcard(_format); var _math = __webpack_require__(/*! ./math */ "./app/client/util/math.js"); var maths = _interopRequireWildcard(_math); __webpack_require__(/*! ./hidpi-canvas */ "./app/client/util/hidpi-canvas.js"); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } var is_iphone = !!(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)); var is_ipad = !!navigator.userAgent.match(/iPad/i); var is_android = !!navigator.userAgent.match(/Android/i); var is_mobile = is_iphone || is_ipad || is_android; var is_desktop = !is_mobile; var htmlClassList = document.body.parentNode.classList; htmlClassList.add(is_desktop ? 'desktop' : 'mobile'); htmlClassList.remove('loading'); // window.debug = false var allProgress = function allProgress(promises, progress_cb) { var d = 0; progress_cb(0, 0, promises.length); promises.forEach(function (p) { p.then(function (s) { d += 1; progress_cb(Math.floor(d * 100 / promises.length), d, promises.length); return s; }); }); return Promise.all(promises); }; document.body.style.backgroundImage = 'linear-gradient(' + (maths.randint(40) + 40) + 'deg, #fde, #ffe)'; var fieldSet = function fieldSet(defaultFields) { return function (fields) { if (fields) { if (fields instanceof Set) { return fields; } return new Set(fields.split(' ')); } return defaultFields; }; }; exports.default = _extends({}, maths, format, { sort: sort, allProgress: allProgress, fieldSet: fieldSet, is_iphone: is_iphone, is_ipad: is_ipad, is_android: is_android, is_mobile: is_mobile, is_desktop: is_desktop }); /***/ }), /***/ "./app/client/util/math.js": /*!*********************************!*\ !*** ./app/client/util/math.js ***! \*********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.randrange = randrange; exports.randsign = randsign; exports.choice = choice; exports.angle = angle; exports.dist = dist; exports.xor = xor; exports.quantize = quantize; exports.shuffle = shuffle; exports.gaussian = gaussian; var mod = exports.mod = function mod(n, m) { return n - m * Math.floor(n / m); }; var clamp = exports.clamp = function clamp(n, a, b) { return n < a ? a : n < b ? n : b; }; var norm = exports.norm = function norm(n, a, b) { return (n - a) / (b - a); }; var lerp = exports.lerp = function lerp(n, a, b) { return (b - a) * n + a; }; var mix = exports.mix = function mix(n, a, b) { return a * (1 - n) + b * n; }; var randint = exports.randint = function randint(n) { return Math.floor(Math.random() * n); }; function randrange(a, b) { return Math.random() * (b - a) + a; } function randsign() { return Math.random() >= 0.5 ? -1 : 1; } function choice(a) { return a[Math.floor(Math.random() * a.length)]; } function angle(x0, y0, x1, y1) { return Math.atan2(y1 - y0, x1 - x0); } function dist(x0, y0, x1, y1) { return Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)); } function xor(a, b) { a = !!a;b = !!b;return (a || b) && !(a && b); } function quantize(a, b) { return Math.floor(a / b) * b; } function shuffle(a) { for (var i = a.length; i > 0; i--) { var r = randint(i); var swap = a[i - 1]; a[i - 1] = a[r]; a[r] = swap; } return a; } // returns a gaussian random function with the given mean and stdev. function gaussian(mean, stdev) { var y2 = void 0; var use_last = false; return function () { var y1 = void 0; if (use_last) { y1 = y2; use_last = false; } else { var x1 = void 0, x2 = void 0, w = void 0; do { x1 = 2.0 * Math.random() - 1.0; x2 = 2.0 * Math.random() - 1.0; w = x1 * x1 + x2 * x2; } while (w >= 1.0); w = Math.sqrt(-2.0 * Math.log(w) / w); y1 = x1 * w; y2 = x2 * w; use_last = true; } var retval = mean + stdev * y1; if (retval > 0) return retval; return -retval; }; } /***/ }), /***/ "./app/client/util/sort.js": /*!*********************************!*\ !*** ./app/client/util/sort.js ***! \*********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var numericSort = exports.numericSort = { asc: function asc(a, b) { return a[0] - b[0]; }, desc: function desc(a, b) { return b[0] - a[0]; } }; var stringSort = exports.stringSort = { asc: function asc(a, b) { return a[0].localeCompare(b[0]); }, desc: function desc(a, b) { return b[0].localeCompare(a[0]); } }; var orderByFn = exports.orderByFn = function orderByFn() { var s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'name asc'; var _s$split = s.split(' '), _s$split2 = _slicedToArray(_s$split, 2), _s$split2$ = _s$split2[0], field = _s$split2$ === undefined ? 'name' : _s$split2$, _s$split2$2 = _s$split2[1], direction = _s$split2$2 === undefined ? 'asc' : _s$split2$2; var mapFn = void 0, sortFn = void 0; switch (field) { case 'epoch': mapFn = function mapFn(a) { return [parseInt(a.epoch || a.epochs) || 0, a]; }; sortFn = numericSort[direction]; break; case 'size': mapFn = function mapFn(a) { return [parseInt(a.size) || 0, a]; }; sortFn = numericSort[direction]; break; case 'date': mapFn = function mapFn(a) { return [+new Date(a.date || a.created_at), a]; }; sortFn = numericSort[direction]; break; case 'updated_at': mapFn = function mapFn(a) { return [+new Date(a.updated_at), a]; }; sortFn = numericSort[direction]; break; case 'priority': mapFn = function mapFn(a) { return [parseInt(a.priority) || parseInt(a.id) || 1000, a]; }; sortFn = numericSort[direction]; case 'name': default: mapFn = function mapFn(a) { return [a.name || "", a]; }; sortFn = stringSort[direction]; break; } return { mapFn: mapFn, sortFn: sortFn }; }; /***/ }), /***/ "./node_modules/base64-js/index.js": /*!*****************************************!*\ !*** ./node_modules/base64-js/index.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.byteLength = byteLength exports.toByteArray = toByteArray exports.fromByteArray = fromByteArray var lookup = [] var revLookup = [] var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i] revLookup[code.charCodeAt(i)] = i } // Support decoding URL-safe base64 strings, as Node.js does. // See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup['-'.charCodeAt(0)] = 62 revLookup['_'.charCodeAt(0)] = 63 function getLens (b64) { var len = b64.length if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf('=') if (validLen === -1) validLen = len var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4) return [validLen, placeHoldersLen] } // base64 is 4/3 + up to two characters of the original data function byteLength (b64) { var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function _byteLength (b64, validLen, placeHoldersLen) { return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { var tmp var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) var curByte = 0 // if there are placeholders, only get up to the last complete 4 chars var len = placeHoldersLen > 0 ? validLen - 4 : validLen for (var i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] arr[curByte++] = (tmp >> 16) & 0xFF arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 2) { tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 1) { tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } return arr } function tripletToBase64 (num) { return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') } function fromByteArray (uint8) { var tmp var len = uint8.length var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes var parts = [] var maxChunkLength = 16383 // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { parts.push(encodeChunk( uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) )) } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] parts.push( lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3F] + '==' ) } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1] parts.push( lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3F] + lookup[(tmp << 2) & 0x3F] + '=' ) } return parts.join('') } /***/ }), /***/ "./node_modules/buffer/index.js": /*!**************************************!*\ !*** ./node_modules/buffer/index.js ***! \**************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) {/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ /* eslint-disable no-proto */ var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js") var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js") var isArray = __webpack_require__(/*! isarray */ "./node_modules/buffer/node_modules/isarray/index.js") exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer exports.INSPECT_MAX_BYTES = 50 /** * If `Buffer.TYPED_ARRAY_SUPPORT`: * === true Use Uint8Array implementation (fastest) * === false Use Object implementation (most compatible, even IE6) * * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, * Opera 11.6+, iOS 4.2+. * * Due to various browser bugs, sometimes the Object implementation will be used even * when the browser supports typed arrays. * * Note: * * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. * * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. * * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of * incorrect length in some situations. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they * get the Object implementation, which is slower but behaves correctly. */ Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined ? global.TYPED_ARRAY_SUPPORT : typedArraySupport() /* * Export kMaxLength after typed array support is determined. */ exports.kMaxLength = kMaxLength() function typedArraySupport () { try { var arr = new Uint8Array(1) arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} return arr.foo() === 42 && // typed array instances can be augmented typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` } catch (e) { return false } } function kMaxLength () { return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff } function createBuffer (that, length) { if (kMaxLength() < length) { throw new RangeError('Invalid typed array length') } if (Buffer.TYPED_ARRAY_SUPPORT) { // Return an augmented `Uint8Array` instance, for best performance that = new Uint8Array(length) that.__proto__ = Buffer.prototype } else { // Fallback: Return an object instance of the Buffer class if (that === null) { that = new Buffer(length) } that.length = length } return that } /** * The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of * `Uint8Array`, so the returned instances will have all the node `Buffer` methods * and the `Uint8Array` methods. Square bracket notation works as expected -- it * returns a single octet. * * The `Uint8Array` prototype remains unmodified. */ function Buffer (arg, encodingOrOffset, length) { if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { return new Buffer(arg, encodingOrOffset, length) } // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { throw new Error( 'If encoding is specified then the first argument must be a string' ) } return allocUnsafe(this, arg) } return from(this, arg, encodingOrOffset, length) } Buffer.poolSize = 8192 // not used by this implementation // TODO: Legacy, not needed anymore. Remove in next major version. Buffer._augment = function (arr) { arr.__proto__ = Buffer.prototype return arr } function from (that, value, encodingOrOffset, length) { if (typeof value === 'number') { throw new TypeError('"value" argument must not be a number') } if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { return fromArrayBuffer(that, value, encodingOrOffset, length) } if (typeof value === 'string') { return fromString(that, value, encodingOrOffset) } return fromObject(that, value) } /** * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError * if value is a number. * Buffer.from(str[, encoding]) * Buffer.from(array) * Buffer.from(buffer) * Buffer.from(arrayBuffer[, byteOffset[, length]]) **/ Buffer.from = function (value, encodingOrOffset, length) { return from(null, value, encodingOrOffset, length) } if (Buffer.TYPED_ARRAY_SUPPORT) { Buffer.prototype.__proto__ = Uint8Array.prototype Buffer.__proto__ = Uint8Array if (typeof Symbol !== 'undefined' && Symbol.species && Buffer[Symbol.species] === Buffer) { // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 Object.defineProperty(Buffer, Symbol.species, { value: null, configurable: true }) } } function assertSize (size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be a number') } else if (size < 0) { throw new RangeError('"size" argument must not be negative') } } function alloc (that, size, fill, encoding) { assertSize(size) if (size <= 0) { return createBuffer(that, size) } if (fill !== undefined) { // Only pay attention to encoding if it's a string. This // prevents accidentally sending in a number that would // be interpretted as a start offset. return typeof encoding === 'string' ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill) } return createBuffer(that, size) } /** * Creates a new filled Buffer instance. * alloc(size[, fill[, encoding]]) **/ Buffer.alloc = function (size, fill, encoding) { return alloc(null, size, fill, encoding) } function allocUnsafe (that, size) { assertSize(size) that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) if (!Buffer.TYPED_ARRAY_SUPPORT) { for (var i = 0; i < size; ++i) { that[i] = 0 } } return that } /** * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. * */ Buffer.allocUnsafe = function (size) { return allocUnsafe(null, size) } /** * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. */ Buffer.allocUnsafeSlow = function (size) { return allocUnsafe(null, size) } function fromString (that, string, encoding) { if (typeof encoding !== 'string' || encoding === '') { encoding = 'utf8' } if (!Buffer.isEncoding(encoding)) { throw new TypeError('"encoding" must be a valid string encoding') } var length = byteLength(string, encoding) | 0 that = createBuffer(that, length) var actual = that.write(string, encoding) if (actual !== length) { // Writing a hex string, for example, that contains invalid characters will // cause everything after the first invalid character to be ignored. (e.g. // 'abxxcd' will be treated as 'ab') that = that.slice(0, actual) } return that } function fromArrayLike (that, array) { var length = array.length < 0 ? 0 : checked(array.length) | 0 that = createBuffer(that, length) for (var i = 0; i < length; i += 1) { that[i] = array[i] & 255 } return that } function fromArrayBuffer (that, array, byteOffset, length) { array.byteLength // this throws if `array` is not a valid ArrayBuffer if (byteOffset < 0 || array.byteLength < byteOffset) { throw new RangeError('\'offset\' is out of bounds') } if (array.byteLength < byteOffset + (length || 0)) { throw new RangeError('\'length\' is out of bounds') } if (byteOffset === undefined && length === undefined) { array = new Uint8Array(array) } else if (length === undefined) { array = new Uint8Array(array, byteOffset) } else { array = new Uint8Array(array, byteOffset, length) } if (Buffer.TYPED_ARRAY_SUPPORT) { // Return an augmented `Uint8Array` instance, for best performance that = array that.__proto__ = Buffer.prototype } else { // Fallback: Return an object instance of the Buffer class that = fromArrayLike(that, array) } return that } function fromObject (that, obj) { if (Buffer.isBuffer(obj)) { var len = checked(obj.length) | 0 that = createBuffer(that, len) if (that.length === 0) { return that } obj.copy(that, 0, 0, len) return that } if (obj) { if ((typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer) || 'length' in obj) { if (typeof obj.length !== 'number' || isnan(obj.length)) { return createBuffer(that, 0) } return fromArrayLike(that, obj) } if (obj.type === 'Buffer' && isArray(obj.data)) { return fromArrayLike(that, obj.data) } } throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') } function checked (length) { // Note: cannot use `length < kMaxLength()` here because that fails when // length is NaN (which is otherwise coerced to zero.) if (length >= kMaxLength()) { throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().toString(16) + ' bytes') } return length | 0 } function SlowBuffer (length) { if (+length != length) { // eslint-disable-line eqeqeq length = 0 } return Buffer.alloc(+length) } Buffer.isBuffer = function isBuffer (b) { return !!(b != null && b._isBuffer) } Buffer.compare = function compare (a, b) { if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { throw new TypeError('Arguments must be Buffers') } if (a === b) return 0 var x = a.length var y = b.length for (var i = 0, len = Math.min(x, y); i < len; ++i) { if (a[i] !== b[i]) { x = a[i] y = b[i] break } } if (x < y) return -1 if (y < x) return 1 return 0 } Buffer.isEncoding = function isEncoding (encoding) { switch (String(encoding).toLowerCase()) { case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'latin1': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return true default: return false } } Buffer.concat = function concat (list, length) { if (!isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers') } if (list.length === 0) { return Buffer.alloc(0) } var i if (length === undefined) { length = 0 for (i = 0; i < list.length; ++i) { length += list[i].length } } var buffer = Buffer.allocUnsafe(length) var pos = 0 for (i = 0; i < list.length; ++i) { var buf = list[i] if (!Buffer.isBuffer(buf)) { throw new TypeError('"list" argument must be an Array of Buffers') } buf.copy(buffer, pos) pos += buf.length } return buffer } function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length } if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { return string.byteLength } if (typeof string !== 'string') { string = '' + string } var len = string.length if (len === 0) return 0 // Use a for loop to avoid recursion var loweredCase = false for (;;) { switch (encoding) { case 'ascii': case 'latin1': case 'binary': return len case 'utf8': case 'utf-8': case undefined: return utf8ToBytes(string).length case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return len * 2 case 'hex': return len >>> 1 case 'base64': return base64ToBytes(string).length default: if (loweredCase) return utf8ToBytes(string).length // assume utf8 encoding = ('' + encoding).toLowerCase() loweredCase = true } } } Buffer.byteLength = byteLength function slowToString (encoding, start, end) { var loweredCase = false // No need to verify that "this.length <= MAX_UINT32" since it's a read-only // property of a typed array. // This behaves neither like String nor Uint8Array in that we set start/end // to their upper/lower bounds if the value passed is out of range. // undefined is handled specially as per ECMA-262 6th Edition, // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. if (start === undefined || start < 0) { start = 0 } // Return early if start > this.length. Done here to prevent potential uint32 // coercion fail below. if (start > this.length) { return '' } if (end === undefined || end > this.length) { end = this.length } if (end <= 0) { return '' } // Force coersion to uint32. This will also coerce falsey/NaN values to 0. end >>>= 0 start >>>= 0 if (end <= start) { return '' } if (!encoding) encoding = 'utf8' while (true) { switch (encoding) { case 'hex': return hexSlice(this, start, end) case 'utf8': case 'utf-8': return utf8Slice(this, start, end) case 'ascii': return asciiSlice(this, start, end) case 'latin1': case 'binary': return latin1Slice(this, start, end) case 'base64': return base64Slice(this, start, end) case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return utf16leSlice(this, start, end) default: if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) encoding = (encoding + '').toLowerCase() loweredCase = true } } } // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect // Buffer instances. Buffer.prototype._isBuffer = true function swap (b, n, m) { var i = b[n] b[n] = b[m] b[m] = i } Buffer.prototype.swap16 = function swap16 () { var len = this.length if (len % 2 !== 0) { throw new RangeError('Buffer size must be a multiple of 16-bits') } for (var i = 0; i < len; i += 2) { swap(this, i, i + 1) } return this } Buffer.prototype.swap32 = function swap32 () { var len = this.length if (len % 4 !== 0) { throw new RangeError('Buffer size must be a multiple of 32-bits') } for (var i = 0; i < len; i += 4) { swap(this, i, i + 3) swap(this, i + 1, i + 2) } return this } Buffer.prototype.swap64 = function swap64 () { var len = this.length if (len % 8 !== 0) { throw new RangeError('Buffer size must be a multiple of 64-bits') } for (var i = 0; i < len; i += 8) { swap(this, i, i + 7) swap(this, i + 1, i + 6) swap(this, i + 2, i + 5) swap(this, i + 3, i + 4) } return this } Buffer.prototype.toString = function toString () { var length = this.length | 0 if (length === 0) return '' if (arguments.length === 0) return utf8Slice(this, 0, length) return slowToString.apply(this, arguments) } Buffer.prototype.equals = function equals (b) { if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') if (this === b) return true return Buffer.compare(this, b) === 0 } Buffer.prototype.inspect = function inspect () { var str = '' var max = exports.INSPECT_MAX_BYTES if (this.length > 0) { str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') if (this.length > max) str += ' ... ' } return '' } Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { if (!Buffer.isBuffer(target)) { throw new TypeError('Argument must be a Buffer') } if (start === undefined) { start = 0 } if (end === undefined) { end = target ? target.length : 0 } if (thisStart === undefined) { thisStart = 0 } if (thisEnd === undefined) { thisEnd = this.length } if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { throw new RangeError('out of range index') } if (thisStart >= thisEnd && start >= end) { return 0 } if (thisStart >= thisEnd) { return -1 } if (start >= end) { return 1 } start >>>= 0 end >>>= 0 thisStart >>>= 0 thisEnd >>>= 0 if (this === target) return 0 var x = thisEnd - thisStart var y = end - start var len = Math.min(x, y) var thisCopy = this.slice(thisStart, thisEnd) var targetCopy = target.slice(start, end) for (var i = 0; i < len; ++i) { if (thisCopy[i] !== targetCopy[i]) { x = thisCopy[i] y = targetCopy[i] break } } if (x < y) return -1 if (y < x) return 1 return 0 } // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, // OR the last index of `val` in `buffer` at offset <= `byteOffset`. // // Arguments: // - buffer - a Buffer to search // - val - a string, Buffer, or number // - byteOffset - an index into `buffer`; will be clamped to an int32 // - encoding - an optional encoding, relevant is val is a string // - dir - true for indexOf, false for lastIndexOf function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { // Empty buffer means no match if (buffer.length === 0) return -1 // Normalize byteOffset if (typeof byteOffset === 'string') { encoding = byteOffset byteOffset = 0 } else if (byteOffset > 0x7fffffff) { byteOffset = 0x7fffffff } else if (byteOffset < -0x80000000) { byteOffset = -0x80000000 } byteOffset = +byteOffset // Coerce to Number. if (isNaN(byteOffset)) { // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer byteOffset = dir ? 0 : (buffer.length - 1) } // Normalize byteOffset: negative offsets start from the end of the buffer if (byteOffset < 0) byteOffset = buffer.length + byteOffset if (byteOffset >= buffer.length) { if (dir) return -1 else byteOffset = buffer.length - 1 } else if (byteOffset < 0) { if (dir) byteOffset = 0 else return -1 } // Normalize val if (typeof val === 'string') { val = Buffer.from(val, encoding) } // Finally, search either indexOf (if dir is true) or lastIndexOf if (Buffer.isBuffer(val)) { // Special case: looking for empty string/buffer always fails if (val.length === 0) { return -1 } return arrayIndexOf(buffer, val, byteOffset, encoding, dir) } else if (typeof val === 'number') { val = val & 0xFF // Search for a byte value [0-255] if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === 'function') { if (dir) { return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) } else { return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) } } return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) } throw new TypeError('val must be string, number or Buffer') } function arrayIndexOf (arr, val, byteOffset, encoding, dir) { var indexSize = 1 var arrLength = arr.length var valLength = val.length if (encoding !== undefined) { encoding = String(encoding).toLowerCase() if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { if (arr.length < 2 || val.length < 2) { return -1 } indexSize = 2 arrLength /= 2 valLength /= 2 byteOffset /= 2 } } function read (buf, i) { if (indexSize === 1) { return buf[i] } else { return buf.readUInt16BE(i * indexSize) } } var i if (dir) { var foundIndex = -1 for (i = byteOffset; i < arrLength; i++) { if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { if (foundIndex === -1) foundIndex = i if (i - foundIndex + 1 === valLength) return foundIndex * indexSize } else { if (foundIndex !== -1) i -= i - foundIndex foundIndex = -1 } } } else { if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength for (i = byteOffset; i >= 0; i--) { var found = true for (var j = 0; j < valLength; j++) { if (read(arr, i + j) !== read(val, j)) { found = false break } } if (found) return i } } return -1 } Buffer.prototype.includes = function includes (val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1 } Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true) } Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false) } function hexWrite (buf, string, offset, length) { offset = Number(offset) || 0 var remaining = buf.length - offset if (!length) { length = remaining } else { length = Number(length) if (length > remaining) { length = remaining } } // must be an even number of digits var strLen = string.length if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') if (length > strLen / 2) { length = strLen / 2 } for (var i = 0; i < length; ++i) { var parsed = parseInt(string.substr(i * 2, 2), 16) if (isNaN(parsed)) return i buf[offset + i] = parsed } return i } function utf8Write (buf, string, offset, length) { return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) } function asciiWrite (buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length) } function latin1Write (buf, string, offset, length) { return asciiWrite(buf, string, offset, length) } function base64Write (buf, string, offset, length) { return blitBuffer(base64ToBytes(string), buf, offset, length) } function ucs2Write (buf, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) } Buffer.prototype.write = function write (string, offset, length, encoding) { // Buffer#write(string) if (offset === undefined) { encoding = 'utf8' length = this.length offset = 0 // Buffer#write(string, encoding) } else if (length === undefined && typeof offset === 'string') { encoding = offset length = this.length offset = 0 // Buffer#write(string, offset[, length][, encoding]) } else if (isFinite(offset)) { offset = offset | 0 if (isFinite(length)) { length = length | 0 if (encoding === undefined) encoding = 'utf8' } else { encoding = length length = undefined } // legacy write(string, encoding, offset, length) - remove in v0.13 } else { throw new Error( 'Buffer.write(string, encoding, offset[, length]) is no longer supported' ) } var remaining = this.length - offset if (length === undefined || length > remaining) length = remaining if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { throw new RangeError('Attempt to write outside buffer bounds') } if (!encoding) encoding = 'utf8' var loweredCase = false for (;;) { switch (encoding) { case 'hex': return hexWrite(this, string, offset, length) case 'utf8': case 'utf-8': return utf8Write(this, string, offset, length) case 'ascii': return asciiWrite(this, string, offset, length) case 'latin1': case 'binary': return latin1Write(this, string, offset, length) case 'base64': // Warning: maxLength not taken into account in base64Write return base64Write(this, string, offset, length) case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return ucs2Write(this, string, offset, length) default: if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) encoding = ('' + encoding).toLowerCase() loweredCase = true } } } Buffer.prototype.toJSON = function toJSON () { return { type: 'Buffer', data: Array.prototype.slice.call(this._arr || this, 0) } } function base64Slice (buf, start, end) { if (start === 0 && end === buf.length) { return base64.fromByteArray(buf) } else { return base64.fromByteArray(buf.slice(start, end)) } } function utf8Slice (buf, start, end) { end = Math.min(buf.length, end) var res = [] var i = start while (i < end) { var firstByte = buf[i] var codePoint = null var bytesPerSequence = (firstByte > 0xEF) ? 4 : (firstByte > 0xDF) ? 3 : (firstByte > 0xBF) ? 2 : 1 if (i + bytesPerSequence <= end) { var secondByte, thirdByte, fourthByte, tempCodePoint switch (bytesPerSequence) { case 1: if (firstByte < 0x80) { codePoint = firstByte } break case 2: secondByte = buf[i + 1] if ((secondByte & 0xC0) === 0x80) { tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) if (tempCodePoint > 0x7F) { codePoint = tempCodePoint } } break case 3: secondByte = buf[i + 1] thirdByte = buf[i + 2] if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { codePoint = tempCodePoint } } break case 4: secondByte = buf[i + 1] thirdByte = buf[i + 2] fourthByte = buf[i + 3] if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { codePoint = tempCodePoint } } } } if (codePoint === null) { // we did not generate a valid codePoint so insert a // replacement char (U+FFFD) and advance only 1 byte codePoint = 0xFFFD bytesPerSequence = 1 } else if (codePoint > 0xFFFF) { // encode to utf16 (surrogate pair dance) codePoint -= 0x10000 res.push(codePoint >>> 10 & 0x3FF | 0xD800) codePoint = 0xDC00 | codePoint & 0x3FF } res.push(codePoint) i += bytesPerSequence } return decodeCodePointsArray(res) } // Based on http://stackoverflow.com/a/22747272/680742, the browser with // the lowest limit is Chrome, with 0x10000 args. // We go 1 magnitude less, for safety var MAX_ARGUMENTS_LENGTH = 0x1000 function decodeCodePointsArray (codePoints) { var len = codePoints.length if (len <= MAX_ARGUMENTS_LENGTH) { return String.fromCharCode.apply(String, codePoints) // avoid extra slice() } // Decode in chunks to avoid "call stack size exceeded". var res = '' var i = 0 while (i < len) { res += String.fromCharCode.apply( String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) ) } return res } function asciiSlice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i] & 0x7F) } return ret } function latin1Slice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i]) } return ret } function hexSlice (buf, start, end) { var len = buf.length if (!start || start < 0) start = 0 if (!end || end < 0 || end > len) end = len var out = '' for (var i = start; i < end; ++i) { out += toHex(buf[i]) } return out } function utf16leSlice (buf, start, end) { var bytes = buf.slice(start, end) var res = '' for (var i = 0; i < bytes.length; i += 2) { res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) } return res } Buffer.prototype.slice = function slice (start, end) { var len = this.length start = ~~start end = end === undefined ? len : ~~end if (start < 0) { start += len if (start < 0) start = 0 } else if (start > len) { start = len } if (end < 0) { end += len if (end < 0) end = 0 } else if (end > len) { end = len } if (end < start) end = start var newBuf if (Buffer.TYPED_ARRAY_SUPPORT) { newBuf = this.subarray(start, end) newBuf.__proto__ = Buffer.prototype } else { var sliceLen = end - start newBuf = new Buffer(sliceLen, undefined) for (var i = 0; i < sliceLen; ++i) { newBuf[i] = this[i + start] } } return newBuf } /* * Need to make sure that buffer isn't trying to write out of bounds. */ function checkOffset (offset, ext, length) { if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') } Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { offset = offset | 0 byteLength = byteLength | 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] var mul = 1 var i = 0 while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul } return val } Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { offset = offset | 0 byteLength = byteLength | 0 if (!noAssert) { checkOffset(offset, byteLength, this.length) } var val = this[offset + --byteLength] var mul = 1 while (byteLength > 0 && (mul *= 0x100)) { val += this[offset + --byteLength] * mul } return val } Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { if (!noAssert) checkOffset(offset, 1, this.length) return this[offset] } Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { if (!noAssert) checkOffset(offset, 2, this.length) return this[offset] | (this[offset + 1] << 8) } Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { if (!noAssert) checkOffset(offset, 2, this.length) return (this[offset] << 8) | this[offset + 1] } Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { if (!noAssert) checkOffset(offset, 4, this.length) return ((this[offset]) | (this[offset + 1] << 8) | (this[offset + 2] << 16)) + (this[offset + 3] * 0x1000000) } Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] * 0x1000000) + ((this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]) } Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { offset = offset | 0 byteLength = byteLength | 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] var mul = 1 var i = 0 while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul } mul *= 0x80 if (val >= mul) val -= Math.pow(2, 8 * byteLength) return val } Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { offset = offset | 0 byteLength = byteLength | 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var i = byteLength var mul = 1 var val = this[offset + --i] while (i > 0 && (mul *= 0x100)) { val += this[offset + --i] * mul } mul *= 0x80 if (val >= mul) val -= Math.pow(2, 8 * byteLength) return val } Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { if (!noAssert) checkOffset(offset, 1, this.length) if (!(this[offset] & 0x80)) return (this[offset]) return ((0xff - this[offset] + 1) * -1) } Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset] | (this[offset + 1] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset + 1] | (this[offset] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset]) | (this[offset + 1] << 8) | (this[offset + 2] << 16) | (this[offset + 3] << 24) } Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] << 24) | (this[offset + 1] << 16) | (this[offset + 2] << 8) | (this[offset + 3]) } Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, true, 23, 4) } Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, false, 23, 4) } Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, true, 52, 8) } Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, false, 52, 8) } function checkInt (buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') if (offset + ext > buf.length) throw new RangeError('Index out of range') } Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value offset = offset | 0 byteLength = byteLength | 0 if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1 checkInt(this, value, offset, byteLength, maxBytes, 0) } var mul = 1 var i = 0 this[offset] = value & 0xFF while (++i < byteLength && (mul *= 0x100)) { this[offset + i] = (value / mul) & 0xFF } return offset + byteLength } Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { value = +value offset = offset | 0 byteLength = byteLength | 0 if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1 checkInt(this, value, offset, byteLength, maxBytes, 0) } var i = byteLength - 1 var mul = 1 this[offset + i] = value & 0xFF while (--i >= 0 && (mul *= 0x100)) { this[offset + i] = (value / mul) & 0xFF } return offset + byteLength } Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) this[offset] = (value & 0xff) return offset + 1 } function objectWriteUInt16 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffff + value + 1 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> (littleEndian ? i : 1 - i) * 8 } } Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) } else { objectWriteUInt16(this, value, offset, true) } return offset + 2 } Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 8) this[offset + 1] = (value & 0xff) } else { objectWriteUInt16(this, value, offset, false) } return offset + 2 } function objectWriteUInt32 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffffffff + value + 1 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff } } Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset + 3] = (value >>> 24) this[offset + 2] = (value >>> 16) this[offset + 1] = (value >>> 8) this[offset] = (value & 0xff) } else { objectWriteUInt32(this, value, offset, true) } return offset + 4 } Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 24) this[offset + 1] = (value >>> 16) this[offset + 2] = (value >>> 8) this[offset + 3] = (value & 0xff) } else { objectWriteUInt32(this, value, offset, false) } return offset + 4 } Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { value = +value offset = offset | 0 if (!noAssert) { var limit = Math.pow(2, 8 * byteLength - 1) checkInt(this, value, offset, byteLength, limit - 1, -limit) } var i = 0 var mul = 1 var sub = 0 this[offset] = value & 0xFF while (++i < byteLength && (mul *= 0x100)) { if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { sub = 1 } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } return offset + byteLength } Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { value = +value offset = offset | 0 if (!noAssert) { var limit = Math.pow(2, 8 * byteLength - 1) checkInt(this, value, offset, byteLength, limit - 1, -limit) } var i = byteLength - 1 var mul = 1 var sub = 0 this[offset + i] = value & 0xFF while (--i >= 0 && (mul *= 0x100)) { if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { sub = 1 } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } return offset + byteLength } Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) if (value < 0) value = 0xff + value + 1 this[offset] = (value & 0xff) return offset + 1 } Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) } else { objectWriteUInt16(this, value, offset, true) } return offset + 2 } Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 8) this[offset + 1] = (value & 0xff) } else { objectWriteUInt16(this, value, offset, false) } return offset + 2 } Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) this[offset + 2] = (value >>> 16) this[offset + 3] = (value >>> 24) } else { objectWriteUInt32(this, value, offset, true) } return offset + 4 } Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { value = +value offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (value < 0) value = 0xffffffff + value + 1 if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 24) this[offset + 1] = (value >>> 16) this[offset + 2] = (value >>> 8) this[offset + 3] = (value & 0xff) } else { objectWriteUInt32(this, value, offset, false) } return offset + 4 } function checkIEEE754 (buf, value, offset, ext, max, min) { if (offset + ext > buf.length) throw new RangeError('Index out of range') if (offset < 0) throw new RangeError('Index out of range') } function writeFloat (buf, value, offset, littleEndian, noAssert) { if (!noAssert) { checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) } ieee754.write(buf, value, offset, littleEndian, 23, 4) return offset + 4 } Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert) } Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert) } function writeDouble (buf, value, offset, littleEndian, noAssert) { if (!noAssert) { checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) } ieee754.write(buf, value, offset, littleEndian, 52, 8) return offset + 8 } Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert) } Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert) } // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) Buffer.prototype.copy = function copy (target, targetStart, start, end) { if (!start) start = 0 if (!end && end !== 0) end = this.length if (targetStart >= target.length) targetStart = target.length if (!targetStart) targetStart = 0 if (end > 0 && end < start) end = start // Copy 0 bytes; we're done if (end === start) return 0 if (target.length === 0 || this.length === 0) return 0 // Fatal error conditions if (targetStart < 0) { throw new RangeError('targetStart out of bounds') } if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') if (end < 0) throw new RangeError('sourceEnd out of bounds') // Are we oob? if (end > this.length) end = this.length if (target.length - targetStart < end - start) { end = target.length - targetStart + start } var len = end - start var i if (this === target && start < targetStart && targetStart < end) { // descending copy from end for (i = len - 1; i >= 0; --i) { target[i + targetStart] = this[i + start] } } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { // ascending copy from start for (i = 0; i < len; ++i) { target[i + targetStart] = this[i + start] } } else { Uint8Array.prototype.set.call( target, this.subarray(start, start + len), targetStart ) } return len } // Usage: // buffer.fill(number[, offset[, end]]) // buffer.fill(buffer[, offset[, end]]) // buffer.fill(string[, offset[, end]][, encoding]) Buffer.prototype.fill = function fill (val, start, end, encoding) { // Handle string cases: if (typeof val === 'string') { if (typeof start === 'string') { encoding = start start = 0 end = this.length } else if (typeof end === 'string') { encoding = end end = this.length } if (val.length === 1) { var code = val.charCodeAt(0) if (code < 256) { val = code } } if (encoding !== undefined && typeof encoding !== 'string') { throw new TypeError('encoding must be a string') } if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { throw new TypeError('Unknown encoding: ' + encoding) } } else if (typeof val === 'number') { val = val & 255 } // Invalid ranges are not set to a default, so can range check early. if (start < 0 || this.length < start || this.length < end) { throw new RangeError('Out of range index') } if (end <= start) { return this } start = start >>> 0 end = end === undefined ? this.length : end >>> 0 if (!val) val = 0 var i if (typeof val === 'number') { for (i = start; i < end; ++i) { this[i] = val } } else { var bytes = Buffer.isBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString()) var len = bytes.length for (i = 0; i < end - start; ++i) { this[i + start] = bytes[i % len] } } return this } // HELPER FUNCTIONS // ================ var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not str = stringtrim(str).replace(INVALID_BASE64_RE, '') // Node converts strings with length < 2 to '' if (str.length < 2) return '' // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not while (str.length % 4 !== 0) { str = str + '=' } return str } function stringtrim (str) { if (str.trim) return str.trim() return str.replace(/^\s+|\s+$/g, '') } function toHex (n) { if (n < 16) return '0' + n.toString(16) return n.toString(16) } function utf8ToBytes (string, units) { units = units || Infinity var codePoint var length = string.length var leadSurrogate = null var bytes = [] for (var i = 0; i < length; ++i) { codePoint = string.charCodeAt(i) // is surrogate component if (codePoint > 0xD7FF && codePoint < 0xE000) { // last char was a lead if (!leadSurrogate) { // no lead yet if (codePoint > 0xDBFF) { // unexpected trail if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue } else if (i + 1 === length) { // unpaired lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue } // valid lead leadSurrogate = codePoint continue } // 2 leads in a row if (codePoint < 0xDC00) { if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) leadSurrogate = codePoint continue } // valid surrogate pair codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 } else if (leadSurrogate) { // valid bmp char, but last char was a lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) } leadSurrogate = null // encode utf8 if (codePoint < 0x80) { if ((units -= 1) < 0) break bytes.push(codePoint) } else if (codePoint < 0x800) { if ((units -= 2) < 0) break bytes.push( codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80 ) } else if (codePoint < 0x10000) { if ((units -= 3) < 0) break bytes.push( codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 ) } else if (codePoint < 0x110000) { if ((units -= 4) < 0) break bytes.push( codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 ) } else { throw new Error('Invalid code point') } } return bytes } function asciiToBytes (str) { var byteArray = [] for (var i = 0; i < str.length; ++i) { // Node's code seems to be doing this and not & 0x7F.. byteArray.push(str.charCodeAt(i) & 0xFF) } return byteArray } function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] for (var i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break c = str.charCodeAt(i) hi = c >> 8 lo = c % 256 byteArray.push(lo) byteArray.push(hi) } return byteArray } function base64ToBytes (str) { return base64.toByteArray(base64clean(str)) } function blitBuffer (src, dst, offset, length) { for (var i = 0; i < length; ++i) { if ((i + offset >= dst.length) || (i >= src.length)) break dst[i + offset] = src[i] } return i } function isnan (val) { return val !== val // eslint-disable-line no-self-compare } /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) /***/ }), /***/ "./node_modules/buffer/node_modules/isarray/index.js": /*!***********************************************************!*\ !*** ./node_modules/buffer/node_modules/isarray/index.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports) { var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; /***/ }), /***/ "./node_modules/core-util-is/lib/util.js": /*!***********************************************!*\ !*** ./node_modules/core-util-is/lib/util.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. function isArray(arg) { if (Array.isArray) { return Array.isArray(arg); } return objectToString(arg) === '[object Array]'; } exports.isArray = isArray; function isBoolean(arg) { return typeof arg === 'boolean'; } exports.isBoolean = isBoolean; function isNull(arg) { return arg === null; } exports.isNull = isNull; function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; function isNumber(arg) { return typeof arg === 'number'; } exports.isNumber = isNumber; function isString(arg) { return typeof arg === 'string'; } exports.isString = isString; function isSymbol(arg) { return typeof arg === 'symbol'; } exports.isSymbol = isSymbol; function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; function isRegExp(re) { return objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; function isDate(d) { return objectToString(d) === '[object Date]'; } exports.isDate = isDate; function isError(e) { return (objectToString(e) === '[object Error]' || e instanceof Error); } exports.isError = isError; function isFunction(arg) { return typeof arg === 'function'; } exports.isFunction = isFunction; function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol typeof arg === 'undefined'; } exports.isPrimitive = isPrimitive; exports.isBuffer = Buffer.isBuffer; function objectToString(o) { return Object.prototype.toString.call(o); } /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer)) /***/ }), /***/ "./node_modules/events/events.js": /*!***************************************!*\ !*** ./node_modules/events/events.js ***! \***************************************/ /*! no static exports found */ /***/ (function(module, exports) { // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. function EventEmitter() { this._events = this._events || {}; this._maxListeners = this._maxListeners || undefined; } module.exports = EventEmitter; // Backwards-compat with node 0.10.x EventEmitter.EventEmitter = EventEmitter; EventEmitter.prototype._events = undefined; EventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are // added to it. This is a useful default which helps finding memory leaks. EventEmitter.defaultMaxListeners = 10; // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function(n) { if (!isNumber(n) || n < 0 || isNaN(n)) throw TypeError('n must be a positive number'); this._maxListeners = n; return this; }; EventEmitter.prototype.emit = function(type) { var er, handler, len, args, i, listeners; if (!this._events) this._events = {}; // If there is no 'error' event listener then throw. if (type === 'error') { if (!this._events.error || (isObject(this._events.error) && !this._events.error.length)) { er = arguments[1]; if (er instanceof Error) { throw er; // Unhandled 'error' event } else { // At least give some kind of context to the user var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); err.context = er; throw err; } } } handler = this._events[type]; if (isUndefined(handler)) return false; if (isFunction(handler)) { switch (arguments.length) { // fast cases case 1: handler.call(this); break; case 2: handler.call(this, arguments[1]); break; case 3: handler.call(this, arguments[1], arguments[2]); break; // slower default: args = Array.prototype.slice.call(arguments, 1); handler.apply(this, args); } } else if (isObject(handler)) { args = Array.prototype.slice.call(arguments, 1); listeners = handler.slice(); len = listeners.length; for (i = 0; i < len; i++) listeners[i].apply(this, args); } return true; }; EventEmitter.prototype.addListener = function(type, listener) { var m; if (!isFunction(listener)) throw TypeError('listener must be a function'); if (!this._events) this._events = {}; // To avoid recursion in the case that type === "newListener"! Before // adding it to the listeners, first emit "newListener". if (this._events.newListener) this.emit('newListener', type, isFunction(listener.listener) ? listener.listener : listener); if (!this._events[type]) // Optimize the case of one listener. Don't need the extra array object. this._events[type] = listener; else if (isObject(this._events[type])) // If we've already got an array, just append. this._events[type].push(listener); else // Adding the second element, need to change to array. this._events[type] = [this._events[type], listener]; // Check for listener leak if (isObject(this._events[type]) && !this._events[type].warned) { if (!isUndefined(this._maxListeners)) { m = this._maxListeners; } else { m = EventEmitter.defaultMaxListeners; } if (m && m > 0 && this._events[type].length > m) { this._events[type].warned = true; console.error('(node) warning: possible EventEmitter memory ' + 'leak detected. %d listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.', this._events[type].length); if (typeof console.trace === 'function') { // not supported in IE 10 console.trace(); } } } return this; }; EventEmitter.prototype.on = EventEmitter.prototype.addListener; EventEmitter.prototype.once = function(type, listener) { if (!isFunction(listener)) throw TypeError('listener must be a function'); var fired = false; function g() { this.removeListener(type, g); if (!fired) { fired = true; listener.apply(this, arguments); } } g.listener = listener; this.on(type, g); return this; }; // emits a 'removeListener' event iff the listener was removed EventEmitter.prototype.removeListener = function(type, listener) { var list, position, length, i; if (!isFunction(listener)) throw TypeError('listener must be a function'); if (!this._events || !this._events[type]) return this; list = this._events[type]; length = list.length; position = -1; if (list === listener || (isFunction(list.listener) && list.listener === listener)) { delete this._events[type]; if (this._events.removeListener) this.emit('removeListener', type, listener); } else if (isObject(list)) { for (i = length; i-- > 0;) { if (list[i] === listener || (list[i].listener && list[i].listener === listener)) { position = i; break; } } if (position < 0) return this; if (list.length === 1) { list.length = 0; delete this._events[type]; } else { list.splice(position, 1); } if (this._events.removeListener) this.emit('removeListener', type, listener); } return this; }; EventEmitter.prototype.removeAllListeners = function(type) { var key, listeners; if (!this._events) return this; // not listening for removeListener, no need to emit if (!this._events.removeListener) { if (arguments.length === 0) this._events = {}; else if (this._events[type]) delete this._events[type]; return this; } // emit removeListener for all listeners on all events if (arguments.length === 0) { for (key in this._events) { if (key === 'removeListener') continue; this.removeAllListeners(key); } this.removeAllListeners('removeListener'); this._events = {}; return this; } listeners = this._events[type]; if (isFunction(listeners)) { this.removeListener(type, listeners); } else if (listeners) { // LIFO order while (listeners.length) this.removeListener(type, listeners[listeners.length - 1]); } delete this._events[type]; return this; }; EventEmitter.prototype.listeners = function(type) { var ret; if (!this._events || !this._events[type]) ret = []; else if (isFunction(this._events[type])) ret = [this._events[type]]; else ret = this._events[type].slice(); return ret; }; EventEmitter.prototype.listenerCount = function(type) { if (this._events) { var evlistener = this._events[type]; if (isFunction(evlistener)) return 1; else if (evlistener) return evlistener.length; } return 0; }; EventEmitter.listenerCount = function(emitter, type) { return emitter.listenerCount(type); }; function isFunction(arg) { return typeof arg === 'function'; } function isNumber(arg) { return typeof arg === 'number'; } function isObject(arg) { return typeof arg === 'object' && arg !== null; } function isUndefined(arg) { return arg === void 0; } /***/ }), /***/ "./node_modules/fbjs/lib/emptyFunction.js": /*!************************************************!*\ !*** ./node_modules/fbjs/lib/emptyFunction.js ***! \************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ function makeEmptyFunction(arg) { return function () { return arg; }; } /** * This function accepts and discards inputs; it has no side effects. This is * primarily useful idiomatically for overridable function endpoints which * always need to be callable, since JS lacks a null-call idiom ala Cocoa. */ var emptyFunction = function emptyFunction() {}; emptyFunction.thatReturns = makeEmptyFunction; emptyFunction.thatReturnsFalse = makeEmptyFunction(false); emptyFunction.thatReturnsTrue = makeEmptyFunction(true); emptyFunction.thatReturnsNull = makeEmptyFunction(null); emptyFunction.thatReturnsThis = function () { return this; }; emptyFunction.thatReturnsArgument = function (arg) { return arg; }; module.exports = emptyFunction; /***/ }), /***/ "./node_modules/fbjs/lib/invariant.js": /*!********************************************!*\ !*** ./node_modules/fbjs/lib/invariant.js ***! \********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var validateFormat = function validateFormat(format) {}; if (true) { validateFormat = function validateFormat(format) { if (format === undefined) { throw new Error('invariant requires an error message argument'); } }; } function invariant(condition, format, a, b, c, d, e, f) { validateFormat(format); if (!condition) { var error; if (format === undefined) { error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error(format.replace(/%s/g, function () { return args[argIndex++]; })); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } } module.exports = invariant; /***/ }), /***/ "./node_modules/fbjs/lib/warning.js": /*!******************************************!*\ !*** ./node_modules/fbjs/lib/warning.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ var emptyFunction = __webpack_require__(/*! ./emptyFunction */ "./node_modules/fbjs/lib/emptyFunction.js"); /** * Similar to invariant but only logs a warning if the condition is not met. * This can be used to log issues in development environments in critical * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ var warning = emptyFunction; if (true) { var printWarning = function printWarning(format) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function () { return args[argIndex++]; }); if (typeof console !== 'undefined') { console.error(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; warning = function warning(condition, format) { if (format === undefined) { throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); } if (format.indexOf('Failed Composite propType: ') === 0) { return; // Ignore CompositeComponent proptype check. } if (!condition) { for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { args[_key2 - 2] = arguments[_key2]; } printWarning.apply(undefined, [format].concat(args)); } }; } module.exports = warning; /***/ }), /***/ "./node_modules/fetch-jsonp/build/fetch-jsonp.js": /*!*******************************************************!*\ !*** ./node_modules/fetch-jsonp/build/fetch-jsonp.js ***! \*******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, module], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else { var mod; } })(this, function (exports, module) { 'use strict'; var defaultOptions = { timeout: 5000, jsonpCallback: 'callback', jsonpCallbackFunction: null }; function generateCallbackFunction() { return 'jsonp_' + Date.now() + '_' + Math.ceil(Math.random() * 100000); } function clearFunction(functionName) { // IE8 throws an exception when you try to delete a property on window // http://stackoverflow.com/a/1824228/751089 try { delete window[functionName]; } catch (e) { window[functionName] = undefined; } } function removeScript(scriptId) { var script = document.getElementById(scriptId); if (script) { document.getElementsByTagName('head')[0].removeChild(script); } } function fetchJsonp(_url) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; // to avoid param reassign var url = _url; var timeout = options.timeout || defaultOptions.timeout; var jsonpCallback = options.jsonpCallback || defaultOptions.jsonpCallback; var timeoutId = undefined; return new Promise(function (resolve, reject) { var callbackFunction = options.jsonpCallbackFunction || generateCallbackFunction(); var scriptId = jsonpCallback + '_' + callbackFunction; window[callbackFunction] = function (response) { resolve({ ok: true, // keep consistent with fetch API json: function json() { return Promise.resolve(response); } }); if (timeoutId) clearTimeout(timeoutId); removeScript(scriptId); clearFunction(callbackFunction); }; // Check if the user set their own params, and if not add a ? to start a list of params url += url.indexOf('?') === -1 ? '?' : '&'; var jsonpScript = document.createElement('script'); jsonpScript.setAttribute('src', '' + url + jsonpCallback + '=' + callbackFunction); if (options.charset) { jsonpScript.setAttribute('charset', options.charset); } jsonpScript.id = scriptId; document.getElementsByTagName('head')[0].appendChild(jsonpScript); timeoutId = setTimeout(function () { reject(new Error('JSONP request to ' + _url + ' timed out')); clearFunction(callbackFunction); removeScript(scriptId); window[callbackFunction] = function () { clearFunction(callbackFunction); }; }, timeout); // Caught if got 404/500 jsonpScript.onerror = function () { reject(new Error('JSONP request to ' + _url + ' failed')); clearFunction(callbackFunction); removeScript(scriptId); if (timeoutId) clearTimeout(timeoutId); }; }); } // export as global function /* let local; if (typeof global !== 'undefined') { local = global; } else if (typeof self !== 'undefined') { local = self; } else { try { local = Function('return this')(); } catch (e) { throw new Error('polyfill failed because global object is unavailable in this environment'); } } local.fetchJsonp = fetchJsonp; */ module.exports = fetchJsonp; }); /***/ }), /***/ "./node_modules/fft.js/lib/fft.js": /*!****************************************!*\ !*** ./node_modules/fft.js/lib/fft.js ***! \****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function FFT(size) { this.size = size | 0; if (this.size <= 1 || (this.size & (this.size - 1)) !== 0) throw new Error('FFT size must be a power of two and bigger than 1'); this._csize = size << 1; // NOTE: Use of `var` is intentional for old V8 versions var table = new Array(this.size * 2); for (var i = 0; i < table.length; i += 2) { const angle = Math.PI * i / this.size; table[i] = Math.cos(angle); table[i + 1] = -Math.sin(angle); } this.table = table; // Find size's power of two var power = 0; for (var t = 1; this.size > t; t <<= 1) power++; // Calculate initial step's width: // * If we are full radix-4 - it is 2x smaller to give inital len=8 // * Otherwise it is the same as `power` to give len=4 this._width = power % 2 === 0 ? power - 1 : power; // Pre-compute bit-reversal patterns this._bitrev = new Array(1 << this._width); for (var j = 0; j < this._bitrev.length; j++) { this._bitrev[j] = 0; for (var shift = 0; shift < this._width; shift += 2) { var revShift = this._width - shift - 2; this._bitrev[j] |= ((j >>> shift) & 3) << revShift; } } this._out = null; this._data = null; this._inv = 0; } module.exports = FFT; FFT.prototype.fromComplexArray = function fromComplexArray(complex, storage) { var res = storage || new Array(complex.length >>> 1); for (var i = 0; i < complex.length; i += 2) res[i >>> 1] = complex[i]; return res; }; FFT.prototype.createComplexArray = function createComplexArray() { const res = new Array(this._csize); for (var i = 0; i < res.length; i++) res[i] = 0; return res; }; FFT.prototype.toComplexArray = function toComplexArray(input, storage) { var res = storage || this.createComplexArray(); for (var i = 0; i < res.length; i += 2) { res[i] = input[i >>> 1]; res[i + 1] = 0; } return res; }; FFT.prototype.completeSpectrum = function completeSpectrum(spectrum) { var size = this._csize; var half = size >>> 1; for (var i = 2; i < half; i += 2) { spectrum[size - i] = spectrum[i]; spectrum[size - i + 1] = -spectrum[i + 1]; } }; FFT.prototype.transform = function transform(out, data) { if (out === data) throw new Error('Input and output buffers must be different'); this._out = out; this._data = data; this._inv = 0; this._transform4(); this._out = null; this._data = null; }; FFT.prototype.realTransform = function realTransform(out, data) { if (out === data) throw new Error('Input and output buffers must be different'); this._out = out; this._data = data; this._inv = 0; this._realTransform4(); this._out = null; this._data = null; }; FFT.prototype.inverseTransform = function inverseTransform(out, data) { if (out === data) throw new Error('Input and output buffers must be different'); this._out = out; this._data = data; this._inv = 1; this._transform4(); for (var i = 0; i < out.length; i++) out[i] /= this.size; this._out = null; this._data = null; }; // radix-4 implementation // // NOTE: Uses of `var` are intentional for older V8 version that do not // support both `let compound assignments` and `const phi` FFT.prototype._transform4 = function _transform4() { var out = this._out; var size = this._csize; // Initial step (permute and transform) var width = this._width; var step = 1 << width; var len = (size / step) << 1; var outOff; var t; var bitrev = this._bitrev; if (len === 4) { for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { const off = bitrev[t]; this._singleTransform2(outOff, off, step); } } else { // len === 8 for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { const off = bitrev[t]; this._singleTransform4(outOff, off, step); } } // Loop through steps in decreasing order var inv = this._inv ? -1 : 1; var table = this.table; for (step >>= 2; step >= 2; step >>= 2) { len = (size / step) << 1; var quarterLen = len >>> 2; // Loop through offsets in the data for (outOff = 0; outOff < size; outOff += len) { // Full case var limit = outOff + quarterLen; for (var i = outOff, k = 0; i < limit; i += 2, k += step) { const A = i; const B = A + quarterLen; const C = B + quarterLen; const D = C + quarterLen; // Original values const Ar = out[A]; const Ai = out[A + 1]; const Br = out[B]; const Bi = out[B + 1]; const Cr = out[C]; const Ci = out[C + 1]; const Dr = out[D]; const Di = out[D + 1]; // Middle values const MAr = Ar; const MAi = Ai; const tableBr = table[k]; const tableBi = inv * table[k + 1]; const MBr = Br * tableBr - Bi * tableBi; const MBi = Br * tableBi + Bi * tableBr; const tableCr = table[2 * k]; const tableCi = inv * table[2 * k + 1]; const MCr = Cr * tableCr - Ci * tableCi; const MCi = Cr * tableCi + Ci * tableCr; const tableDr = table[3 * k]; const tableDi = inv * table[3 * k + 1]; const MDr = Dr * tableDr - Di * tableDi; const MDi = Dr * tableDi + Di * tableDr; // Pre-Final values const T0r = MAr + MCr; const T0i = MAi + MCi; const T1r = MAr - MCr; const T1i = MAi - MCi; const T2r = MBr + MDr; const T2i = MBi + MDi; const T3r = inv * (MBr - MDr); const T3i = inv * (MBi - MDi); // Final values const FAr = T0r + T2r; const FAi = T0i + T2i; const FCr = T0r - T2r; const FCi = T0i - T2i; const FBr = T1r + T3i; const FBi = T1i - T3r; const FDr = T1r - T3i; const FDi = T1i + T3r; out[A] = FAr; out[A + 1] = FAi; out[B] = FBr; out[B + 1] = FBi; out[C] = FCr; out[C + 1] = FCi; out[D] = FDr; out[D + 1] = FDi; } } } }; // radix-2 implementation // // NOTE: Only called for len=4 FFT.prototype._singleTransform2 = function _singleTransform2(outOff, off, step) { const out = this._out; const data = this._data; const evenR = data[off]; const evenI = data[off + 1]; const oddR = data[off + step]; const oddI = data[off + step + 1]; const leftR = evenR + oddR; const leftI = evenI + oddI; const rightR = evenR - oddR; const rightI = evenI - oddI; out[outOff] = leftR; out[outOff + 1] = leftI; out[outOff + 2] = rightR; out[outOff + 3] = rightI; }; // radix-4 // // NOTE: Only called for len=8 FFT.prototype._singleTransform4 = function _singleTransform4(outOff, off, step) { const out = this._out; const data = this._data; const inv = this._inv ? -1 : 1; const step2 = step * 2; const step3 = step * 3; // Original values const Ar = data[off]; const Ai = data[off + 1]; const Br = data[off + step]; const Bi = data[off + step + 1]; const Cr = data[off + step2]; const Ci = data[off + step2 + 1]; const Dr = data[off + step3]; const Di = data[off + step3 + 1]; // Pre-Final values const T0r = Ar + Cr; const T0i = Ai + Ci; const T1r = Ar - Cr; const T1i = Ai - Ci; const T2r = Br + Dr; const T2i = Bi + Di; const T3r = inv * (Br - Dr); const T3i = inv * (Bi - Di); // Final values const FAr = T0r + T2r; const FAi = T0i + T2i; const FBr = T1r + T3i; const FBi = T1i - T3r; const FCr = T0r - T2r; const FCi = T0i - T2i; const FDr = T1r - T3i; const FDi = T1i + T3r; out[outOff] = FAr; out[outOff + 1] = FAi; out[outOff + 2] = FBr; out[outOff + 3] = FBi; out[outOff + 4] = FCr; out[outOff + 5] = FCi; out[outOff + 6] = FDr; out[outOff + 7] = FDi; }; // Real input radix-4 implementation FFT.prototype._realTransform4 = function _realTransform4() { var out = this._out; var size = this._csize; // Initial step (permute and transform) var width = this._width; var step = 1 << width; var len = (size / step) << 1; var outOff; var t; var bitrev = this._bitrev; if (len === 4) { for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { const off = bitrev[t]; this._singleRealTransform2(outOff, off >>> 1, step >>> 1); } } else { // len === 8 for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { const off = bitrev[t]; this._singleRealTransform4(outOff, off >>> 1, step >>> 1); } } // Loop through steps in decreasing order var inv = this._inv ? -1 : 1; var table = this.table; for (step >>= 2; step >= 2; step >>= 2) { len = (size / step) << 1; var halfLen = len >>> 1; var quarterLen = halfLen >>> 1; var hquarterLen = quarterLen >>> 1; // Loop through offsets in the data for (outOff = 0; outOff < size; outOff += len) { for (var i = 0, k = 0; i <= hquarterLen; i += 2, k += step) { var A = outOff + i; var B = A + quarterLen; var C = B + quarterLen; var D = C + quarterLen; // Original values var Ar = out[A]; var Ai = out[A + 1]; var Br = out[B]; var Bi = out[B + 1]; var Cr = out[C]; var Ci = out[C + 1]; var Dr = out[D]; var Di = out[D + 1]; // Middle values var MAr = Ar; var MAi = Ai; var tableBr = table[k]; var tableBi = inv * table[k + 1]; var MBr = Br * tableBr - Bi * tableBi; var MBi = Br * tableBi + Bi * tableBr; var tableCr = table[2 * k]; var tableCi = inv * table[2 * k + 1]; var MCr = Cr * tableCr - Ci * tableCi; var MCi = Cr * tableCi + Ci * tableCr; var tableDr = table[3 * k]; var tableDi = inv * table[3 * k + 1]; var MDr = Dr * tableDr - Di * tableDi; var MDi = Dr * tableDi + Di * tableDr; // Pre-Final values var T0r = MAr + MCr; var T0i = MAi + MCi; var T1r = MAr - MCr; var T1i = MAi - MCi; var T2r = MBr + MDr; var T2i = MBi + MDi; var T3r = inv * (MBr - MDr); var T3i = inv * (MBi - MDi); // Final values var FAr = T0r + T2r; var FAi = T0i + T2i; var FBr = T1r + T3i; var FBi = T1i - T3r; out[A] = FAr; out[A + 1] = FAi; out[B] = FBr; out[B + 1] = FBi; // Output final middle point if (i === 0) { var FCr = T0r - T2r; var FCi = T0i - T2i; out[C] = FCr; out[C + 1] = FCi; continue; } // Do not overwrite ourselves if (i === hquarterLen) continue; // In the flipped case: // MAi = -MAi // MBr=-MBi, MBi=-MBr // MCr=-MCr // MDr=MDi, MDi=MDr var ST0r = T1r; var ST0i = -T1i; var ST1r = T0r; var ST1i = -T0i; var ST2r = -inv * T3i; var ST2i = -inv * T3r; var ST3r = -inv * T2i; var ST3i = -inv * T2r; var SFAr = ST0r + ST2r; var SFAi = ST0i + ST2i; var SFBr = ST1r + ST3i; var SFBi = ST1i - ST3r; var SA = outOff + quarterLen - i; var SB = outOff + halfLen - i; out[SA] = SFAr; out[SA + 1] = SFAi; out[SB] = SFBr; out[SB + 1] = SFBi; } } } }; // radix-2 implementation // // NOTE: Only called for len=4 FFT.prototype._singleRealTransform2 = function _singleRealTransform2(outOff, off, step) { const out = this._out; const data = this._data; const evenR = data[off]; const oddR = data[off + step]; const leftR = evenR + oddR; const rightR = evenR - oddR; out[outOff] = leftR; out[outOff + 1] = 0; out[outOff + 2] = rightR; out[outOff + 3] = 0; }; // radix-4 // // NOTE: Only called for len=8 FFT.prototype._singleRealTransform4 = function _singleRealTransform4(outOff, off, step) { const out = this._out; const data = this._data; const inv = this._inv ? -1 : 1; const step2 = step * 2; const step3 = step * 3; // Original values const Ar = data[off]; const Br = data[off + step]; const Cr = data[off + step2]; const Dr = data[off + step3]; // Pre-Final values const T0r = Ar + Cr; const T1r = Ar - Cr; const T2r = Br + Dr; const T3r = inv * (Br - Dr); // Final values const FAr = T0r + T2r; const FBr = T1r; const FBi = -T3r; const FCr = T0r - T2r; const FDr = T1r; const FDi = T3r; out[outOff] = FAr; out[outOff + 1] = 0; out[outOff + 2] = FBr; out[outOff + 3] = FBi; out[outOff + 4] = FCr; out[outOff + 5] = 0; out[outOff + 6] = FDr; out[outOff + 7] = FDi; }; /***/ }), /***/ "./node_modules/file-saver/FileSaver.js": /*!**********************************************!*\ !*** ./node_modules/file-saver/FileSaver.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/* FileSaver.js * A saveAs() FileSaver implementation. * 1.3.2 * 2016-06-16 18:25:19 * * By Eli Grey, http://eligrey.com * License: MIT * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md */ /*global self */ /*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */ /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ var saveAs = saveAs || (function(view) { "use strict"; // IE <10 is explicitly unsupported if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { return; } var doc = view.document // only get URL when necessary in case Blob.js hasn't overridden it yet , get_URL = function() { return view.URL || view.webkitURL || view; } , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a") , can_use_save_link = "download" in save_link , click = function(node) { var event = new MouseEvent("click"); node.dispatchEvent(event); } , is_safari = /constructor/i.test(view.HTMLElement) || view.safari , is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent) , throw_outside = function(ex) { (view.setImmediate || view.setTimeout)(function() { throw ex; }, 0); } , force_saveable_type = "application/octet-stream" // the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to , arbitrary_revoke_timeout = 1000 * 40 // in ms , revoke = function(file) { var revoker = function() { if (typeof file === "string") { // file is an object URL get_URL().revokeObjectURL(file); } else { // file is a File file.remove(); } }; setTimeout(revoker, arbitrary_revoke_timeout); } , dispatch = function(filesaver, event_types, event) { event_types = [].concat(event_types); var i = event_types.length; while (i--) { var listener = filesaver["on" + event_types[i]]; if (typeof listener === "function") { try { listener.call(filesaver, event || filesaver); } catch (ex) { throw_outside(ex); } } } } , auto_bom = function(blob) { // prepend BOM for UTF-8 XML and text/* types (including HTML) // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type}); } return blob; } , FileSaver = function(blob, name, no_auto_bom) { if (!no_auto_bom) { blob = auto_bom(blob); } // First try a.download, then web filesystem, then object URLs var filesaver = this , type = blob.type , force = type === force_saveable_type , object_url , dispatch_all = function() { dispatch(filesaver, "writestart progress write writeend".split(" ")); } // on any filesys errors revert to saving with object URLs , fs_error = function() { if ((is_chrome_ios || (force && is_safari)) && view.FileReader) { // Safari doesn't allow downloading of blob urls var reader = new FileReader(); reader.onloadend = function() { var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;'); var popup = view.open(url, '_blank'); if(!popup) view.location.href = url; url=undefined; // release reference before dispatching filesaver.readyState = filesaver.DONE; dispatch_all(); }; reader.readAsDataURL(blob); filesaver.readyState = filesaver.INIT; return; } // don't create more object URLs than needed if (!object_url) { object_url = get_URL().createObjectURL(blob); } if (force) { view.location.href = object_url; } else { var opened = view.open(object_url, "_blank"); if (!opened) { // Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html view.location.href = object_url; } } filesaver.readyState = filesaver.DONE; dispatch_all(); revoke(object_url); } ; filesaver.readyState = filesaver.INIT; if (can_use_save_link) { object_url = get_URL().createObjectURL(blob); setTimeout(function() { save_link.href = object_url; save_link.download = name; click(save_link); dispatch_all(); revoke(object_url); filesaver.readyState = filesaver.DONE; }); return; } fs_error(); } , FS_proto = FileSaver.prototype , saveAs = function(blob, name, no_auto_bom) { return new FileSaver(blob, name || blob.name || "download", no_auto_bom); } ; // IE 10+ (native saveAs) if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { return function(blob, name, no_auto_bom) { name = name || blob.name || "download"; if (!no_auto_bom) { blob = auto_bom(blob); } return navigator.msSaveOrOpenBlob(blob, name); }; } FS_proto.abort = function(){}; FS_proto.readyState = FS_proto.INIT = 0; FS_proto.WRITING = 1; FS_proto.DONE = 2; FS_proto.error = FS_proto.onwritestart = FS_proto.onprogress = FS_proto.onwrite = FS_proto.onabort = FS_proto.onerror = FS_proto.onwriteend = null; return saveAs; }( typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content )); // `self` is undefined in Firefox for Android content script context // while `this` is nsIContentFrameMessageManager // with an attribute `content` that corresponds to the window if (typeof module !== "undefined" && module.exports) { module.exports.saveAs = saveAs; } else if (("function" !== "undefined" && __webpack_require__(/*! !webpack amd define */ "./node_modules/webpack/buildin/amd-define.js") !== null) && (__webpack_require__(/*! !webpack amd options */ "./node_modules/webpack/buildin/amd-options.js") !== null)) { !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { return saveAs; }).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } /***/ }), /***/ "./node_modules/history/DOMUtils.js": /*!******************************************!*\ !*** ./node_modules/history/DOMUtils.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var canUseDOM = exports.canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); var addEventListener = exports.addEventListener = function addEventListener(node, event, listener) { return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener); }; var removeEventListener = exports.removeEventListener = function removeEventListener(node, event, listener) { return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener); }; var getConfirmation = exports.getConfirmation = function getConfirmation(message, callback) { return callback(window.confirm(message)); }; // eslint-disable-line no-alert /** * Returns true if the HTML5 history API is supported. Taken from Modernizr. * * https://github.com/Modernizr/Modernizr/blob/master/LICENSE * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586 */ var supportsHistory = exports.supportsHistory = function supportsHistory() { var ua = window.navigator.userAgent; if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false; return window.history && 'pushState' in window.history; }; /** * Returns true if browser fires popstate on hash change. * IE10 and IE11 do not. */ var supportsPopStateOnHashChange = exports.supportsPopStateOnHashChange = function supportsPopStateOnHashChange() { return window.navigator.userAgent.indexOf('Trident') === -1; }; /** * Returns false if using go(n) with hash history causes a full page reload. */ var supportsGoWithoutReloadUsingHash = exports.supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() { return window.navigator.userAgent.indexOf('Firefox') === -1; }; /** * Returns true if a given popstate event is an extraneous WebKit event. * Accounts for the fact that Chrome on iOS fires real popstate events * containing undefined state when pressing the back button. */ var isExtraneousPopstateEvent = exports.isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) { return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1; }; /***/ }), /***/ "./node_modules/history/LocationUtils.js": /*!***********************************************!*\ !*** ./node_modules/history/LocationUtils.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; exports.locationsAreEqual = exports.createLocation = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _resolvePathname = __webpack_require__(/*! resolve-pathname */ "./node_modules/resolve-pathname/index.js"); var _resolvePathname2 = _interopRequireDefault(_resolvePathname); var _valueEqual = __webpack_require__(/*! value-equal */ "./node_modules/value-equal/index.js"); var _valueEqual2 = _interopRequireDefault(_valueEqual); var _PathUtils = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/PathUtils.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var createLocation = exports.createLocation = function createLocation(path, state, key, currentLocation) { var location = void 0; if (typeof path === 'string') { // Two-arg form: push(path, state) location = (0, _PathUtils.parsePath)(path); location.state = state; } else { // One-arg form: push(location) location = _extends({}, path); if (location.pathname === undefined) location.pathname = ''; if (location.search) { if (location.search.charAt(0) !== '?') location.search = '?' + location.search; } else { location.search = ''; } if (location.hash) { if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash; } else { location.hash = ''; } if (state !== undefined && location.state === undefined) location.state = state; } try { location.pathname = decodeURI(location.pathname); } catch (e) { if (e instanceof URIError) { throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.'); } else { throw e; } } if (key) location.key = key; if (currentLocation) { // Resolve incomplete/relative pathname relative to current location. if (!location.pathname) { location.pathname = currentLocation.pathname; } else if (location.pathname.charAt(0) !== '/') { location.pathname = (0, _resolvePathname2.default)(location.pathname, currentLocation.pathname); } } else { // When there is no prior location and pathname is empty, set it to / if (!location.pathname) { location.pathname = '/'; } } return location; }; var locationsAreEqual = exports.locationsAreEqual = function locationsAreEqual(a, b) { return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && (0, _valueEqual2.default)(a.state, b.state); }; /***/ }), /***/ "./node_modules/history/PathUtils.js": /*!*******************************************!*\ !*** ./node_modules/history/PathUtils.js ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var addLeadingSlash = exports.addLeadingSlash = function addLeadingSlash(path) { return path.charAt(0) === '/' ? path : '/' + path; }; var stripLeadingSlash = exports.stripLeadingSlash = function stripLeadingSlash(path) { return path.charAt(0) === '/' ? path.substr(1) : path; }; var hasBasename = exports.hasBasename = function hasBasename(path, prefix) { return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path); }; var stripBasename = exports.stripBasename = function stripBasename(path, prefix) { return hasBasename(path, prefix) ? path.substr(prefix.length) : path; }; var stripTrailingSlash = exports.stripTrailingSlash = function stripTrailingSlash(path) { return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path; }; var parsePath = exports.parsePath = function parsePath(path) { var pathname = path || '/'; var search = ''; var hash = ''; var hashIndex = pathname.indexOf('#'); if (hashIndex !== -1) { hash = pathname.substr(hashIndex); pathname = pathname.substr(0, hashIndex); } var searchIndex = pathname.indexOf('?'); if (searchIndex !== -1) { search = pathname.substr(searchIndex); pathname = pathname.substr(0, searchIndex); } return { pathname: pathname, search: search === '?' ? '' : search, hash: hash === '#' ? '' : hash }; }; var createPath = exports.createPath = function createPath(location) { var pathname = location.pathname, search = location.search, hash = location.hash; var path = pathname || '/'; if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search; if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash; return path; }; /***/ }), /***/ "./node_modules/history/createBrowserHistory.js": /*!******************************************************!*\ !*** ./node_modules/history/createBrowserHistory.js ***! \******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _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; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _warning = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); var _warning2 = _interopRequireDefault(_warning); var _invariant = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); var _invariant2 = _interopRequireDefault(_invariant); var _LocationUtils = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/LocationUtils.js"); var _PathUtils = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/PathUtils.js"); var _createTransitionManager = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/createTransitionManager.js"); var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); var _DOMUtils = __webpack_require__(/*! ./DOMUtils */ "./node_modules/history/DOMUtils.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var PopStateEvent = 'popstate'; var HashChangeEvent = 'hashchange'; var getHistoryState = function getHistoryState() { try { return window.history.state || {}; } catch (e) { // IE 11 sometimes throws when accessing window.history.state // See https://github.com/ReactTraining/history/pull/289 return {}; } }; /** * Creates a history object that uses the HTML5 history API including * pushState, replaceState, and the popstate event. */ var createBrowserHistory = function createBrowserHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; (0, _invariant2.default)(_DOMUtils.canUseDOM, 'Browser history needs a DOM'); var globalHistory = window.history; var canUseHistory = (0, _DOMUtils.supportsHistory)(); var needsHashChangeListener = !(0, _DOMUtils.supportsPopStateOnHashChange)(); var _props$forceRefresh = props.forceRefresh, forceRefresh = _props$forceRefresh === undefined ? false : _props$forceRefresh, _props$getUserConfirm = props.getUserConfirmation, getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils.getConfirmation : _props$getUserConfirm, _props$keyLength = props.keyLength, keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; var basename = props.basename ? (0, _PathUtils.stripTrailingSlash)((0, _PathUtils.addLeadingSlash)(props.basename)) : ''; var getDOMLocation = function getDOMLocation(historyState) { var _ref = historyState || {}, key = _ref.key, state = _ref.state; var _window$location = window.location, pathname = _window$location.pathname, search = _window$location.search, hash = _window$location.hash; var path = pathname + search + hash; (0, _warning2.default)(!basename || (0, _PathUtils.hasBasename)(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'); if (basename) path = (0, _PathUtils.stripBasename)(path, basename); return (0, _LocationUtils.createLocation)(path, state, key); }; var createKey = function createKey() { return Math.random().toString(36).substr(2, keyLength); }; var transitionManager = (0, _createTransitionManager2.default)(); var setState = function setState(nextState) { _extends(history, nextState); history.length = globalHistory.length; transitionManager.notifyListeners(history.location, history.action); }; var handlePopState = function handlePopState(event) { // Ignore extraneous popstate events in WebKit. if ((0, _DOMUtils.isExtraneousPopstateEvent)(event)) return; handlePop(getDOMLocation(event.state)); }; var handleHashChange = function handleHashChange() { handlePop(getDOMLocation(getHistoryState())); }; var forceNextPop = false; var handlePop = function handlePop(location) { if (forceNextPop) { forceNextPop = false; setState(); } else { var action = 'POP'; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location }); } else { revertPop(location); } }); } }; var revertPop = function revertPop(fromLocation) { var toLocation = history.location; // TODO: We could probably make this more reliable by // keeping a list of keys we've seen in sessionStorage. // Instead, we just default to 0 for keys we don't know. var toIndex = allKeys.indexOf(toLocation.key); if (toIndex === -1) toIndex = 0; var fromIndex = allKeys.indexOf(fromLocation.key); if (fromIndex === -1) fromIndex = 0; var delta = toIndex - fromIndex; if (delta) { forceNextPop = true; go(delta); } }; var initialLocation = getDOMLocation(getHistoryState()); var allKeys = [initialLocation.key]; // Public interface var createHref = function createHref(location) { return basename + (0, _PathUtils.createPath)(location); }; var push = function push(path, state) { (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); var action = 'PUSH'; var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var href = createHref(location); var key = location.key, state = location.state; if (canUseHistory) { globalHistory.pushState({ key: key, state: state }, null, href); if (forceRefresh) { window.location.href = href; } else { var prevIndex = allKeys.indexOf(history.location.key); var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); nextKeys.push(location.key); allKeys = nextKeys; setState({ action: action, location: location }); } } else { (0, _warning2.default)(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history'); window.location.href = href; } }); }; var replace = function replace(path, state) { (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); var action = 'REPLACE'; var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var href = createHref(location); var key = location.key, state = location.state; if (canUseHistory) { globalHistory.replaceState({ key: key, state: state }, null, href); if (forceRefresh) { window.location.replace(href); } else { var prevIndex = allKeys.indexOf(history.location.key); if (prevIndex !== -1) allKeys[prevIndex] = location.key; setState({ action: action, location: location }); } } else { (0, _warning2.default)(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history'); window.location.replace(href); } }); }; var go = function go(n) { globalHistory.go(n); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var listenerCount = 0; var checkDOMListeners = function checkDOMListeners(delta) { listenerCount += delta; if (listenerCount === 1) { (0, _DOMUtils.addEventListener)(window, PopStateEvent, handlePopState); if (needsHashChangeListener) (0, _DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange); } else if (listenerCount === 0) { (0, _DOMUtils.removeEventListener)(window, PopStateEvent, handlePopState); if (needsHashChangeListener) (0, _DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange); } }; var isBlocked = false; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var unblock = transitionManager.setPrompt(prompt); if (!isBlocked) { checkDOMListeners(1); isBlocked = true; } return function () { if (isBlocked) { isBlocked = false; checkDOMListeners(-1); } return unblock(); }; }; var listen = function listen(listener) { var unlisten = transitionManager.appendListener(listener); checkDOMListeners(1); return function () { checkDOMListeners(-1); unlisten(); }; }; var history = { length: globalHistory.length, action: 'POP', location: initialLocation, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, block: block, listen: listen }; return history; }; exports.default = createBrowserHistory; /***/ }), /***/ "./node_modules/history/createHashHistory.js": /*!***************************************************!*\ !*** ./node_modules/history/createHashHistory.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _warning = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); var _warning2 = _interopRequireDefault(_warning); var _invariant = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); var _invariant2 = _interopRequireDefault(_invariant); var _LocationUtils = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/LocationUtils.js"); var _PathUtils = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/PathUtils.js"); var _createTransitionManager = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/createTransitionManager.js"); var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); var _DOMUtils = __webpack_require__(/*! ./DOMUtils */ "./node_modules/history/DOMUtils.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var HashChangeEvent = 'hashchange'; var HashPathCoders = { hashbang: { encodePath: function encodePath(path) { return path.charAt(0) === '!' ? path : '!/' + (0, _PathUtils.stripLeadingSlash)(path); }, decodePath: function decodePath(path) { return path.charAt(0) === '!' ? path.substr(1) : path; } }, noslash: { encodePath: _PathUtils.stripLeadingSlash, decodePath: _PathUtils.addLeadingSlash }, slash: { encodePath: _PathUtils.addLeadingSlash, decodePath: _PathUtils.addLeadingSlash } }; var getHashPath = function getHashPath() { // We can't use window.location.hash here because it's not // consistent across browsers - Firefox will pre-decode it! var href = window.location.href; var hashIndex = href.indexOf('#'); return hashIndex === -1 ? '' : href.substring(hashIndex + 1); }; var pushHashPath = function pushHashPath(path) { return window.location.hash = path; }; var replaceHashPath = function replaceHashPath(path) { var hashIndex = window.location.href.indexOf('#'); window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path); }; var createHashHistory = function createHashHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; (0, _invariant2.default)(_DOMUtils.canUseDOM, 'Hash history needs a DOM'); var globalHistory = window.history; var canGoWithoutReload = (0, _DOMUtils.supportsGoWithoutReloadUsingHash)(); var _props$getUserConfirm = props.getUserConfirmation, getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils.getConfirmation : _props$getUserConfirm, _props$hashType = props.hashType, hashType = _props$hashType === undefined ? 'slash' : _props$hashType; var basename = props.basename ? (0, _PathUtils.stripTrailingSlash)((0, _PathUtils.addLeadingSlash)(props.basename)) : ''; var _HashPathCoders$hashT = HashPathCoders[hashType], encodePath = _HashPathCoders$hashT.encodePath, decodePath = _HashPathCoders$hashT.decodePath; var getDOMLocation = function getDOMLocation() { var path = decodePath(getHashPath()); (0, _warning2.default)(!basename || (0, _PathUtils.hasBasename)(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'); if (basename) path = (0, _PathUtils.stripBasename)(path, basename); return (0, _LocationUtils.createLocation)(path); }; var transitionManager = (0, _createTransitionManager2.default)(); var setState = function setState(nextState) { _extends(history, nextState); history.length = globalHistory.length; transitionManager.notifyListeners(history.location, history.action); }; var forceNextPop = false; var ignorePath = null; var handleHashChange = function handleHashChange() { var path = getHashPath(); var encodedPath = encodePath(path); if (path !== encodedPath) { // Ensure we always have a properly-encoded hash. replaceHashPath(encodedPath); } else { var location = getDOMLocation(); var prevLocation = history.location; if (!forceNextPop && (0, _LocationUtils.locationsAreEqual)(prevLocation, location)) return; // A hashchange doesn't always == location change. if (ignorePath === (0, _PathUtils.createPath)(location)) return; // Ignore this change; we already setState in push/replace. ignorePath = null; handlePop(location); } }; var handlePop = function handlePop(location) { if (forceNextPop) { forceNextPop = false; setState(); } else { var action = 'POP'; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location }); } else { revertPop(location); } }); } }; var revertPop = function revertPop(fromLocation) { var toLocation = history.location; // TODO: We could probably make this more reliable by // keeping a list of paths we've seen in sessionStorage. // Instead, we just default to 0 for paths we don't know. var toIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(toLocation)); if (toIndex === -1) toIndex = 0; var fromIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(fromLocation)); if (fromIndex === -1) fromIndex = 0; var delta = toIndex - fromIndex; if (delta) { forceNextPop = true; go(delta); } }; // Ensure the hash is encoded properly before doing anything else. var path = getHashPath(); var encodedPath = encodePath(path); if (path !== encodedPath) replaceHashPath(encodedPath); var initialLocation = getDOMLocation(); var allPaths = [(0, _PathUtils.createPath)(initialLocation)]; // Public interface var createHref = function createHref(location) { return '#' + encodePath(basename + (0, _PathUtils.createPath)(location)); }; var push = function push(path, state) { (0, _warning2.default)(state === undefined, 'Hash history cannot push state; it is ignored'); var action = 'PUSH'; var location = (0, _LocationUtils.createLocation)(path, undefined, undefined, history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var path = (0, _PathUtils.createPath)(location); var encodedPath = encodePath(basename + path); var hashChanged = getHashPath() !== encodedPath; if (hashChanged) { // We cannot tell if a hashchange was caused by a PUSH, so we'd // rather setState here and ignore the hashchange. The caveat here // is that other hash histories in the page will consider it a POP. ignorePath = path; pushHashPath(encodedPath); var prevIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(history.location)); var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); nextPaths.push(path); allPaths = nextPaths; setState({ action: action, location: location }); } else { (0, _warning2.default)(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack'); setState(); } }); }; var replace = function replace(path, state) { (0, _warning2.default)(state === undefined, 'Hash history cannot replace state; it is ignored'); var action = 'REPLACE'; var location = (0, _LocationUtils.createLocation)(path, undefined, undefined, history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var path = (0, _PathUtils.createPath)(location); var encodedPath = encodePath(basename + path); var hashChanged = getHashPath() !== encodedPath; if (hashChanged) { // We cannot tell if a hashchange was caused by a REPLACE, so we'd // rather setState here and ignore the hashchange. The caveat here // is that other hash histories in the page will consider it a POP. ignorePath = path; replaceHashPath(encodedPath); } var prevIndex = allPaths.indexOf((0, _PathUtils.createPath)(history.location)); if (prevIndex !== -1) allPaths[prevIndex] = path; setState({ action: action, location: location }); }); }; var go = function go(n) { (0, _warning2.default)(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser'); globalHistory.go(n); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var listenerCount = 0; var checkDOMListeners = function checkDOMListeners(delta) { listenerCount += delta; if (listenerCount === 1) { (0, _DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange); } else if (listenerCount === 0) { (0, _DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange); } }; var isBlocked = false; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var unblock = transitionManager.setPrompt(prompt); if (!isBlocked) { checkDOMListeners(1); isBlocked = true; } return function () { if (isBlocked) { isBlocked = false; checkDOMListeners(-1); } return unblock(); }; }; var listen = function listen(listener) { var unlisten = transitionManager.appendListener(listener); checkDOMListeners(1); return function () { checkDOMListeners(-1); unlisten(); }; }; var history = { length: globalHistory.length, action: 'POP', location: initialLocation, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, block: block, listen: listen }; return history; }; exports.default = createHashHistory; /***/ }), /***/ "./node_modules/history/createMemoryHistory.js": /*!*****************************************************!*\ !*** ./node_modules/history/createMemoryHistory.js ***! \*****************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _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; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _warning = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); var _warning2 = _interopRequireDefault(_warning); var _PathUtils = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/PathUtils.js"); var _LocationUtils = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/LocationUtils.js"); var _createTransitionManager = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/createTransitionManager.js"); var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var clamp = function clamp(n, lowerBound, upperBound) { return Math.min(Math.max(n, lowerBound), upperBound); }; /** * Creates a history object that stores locations in memory. */ var createMemoryHistory = function createMemoryHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var getUserConfirmation = props.getUserConfirmation, _props$initialEntries = props.initialEntries, initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries, _props$initialIndex = props.initialIndex, initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex, _props$keyLength = props.keyLength, keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; var transitionManager = (0, _createTransitionManager2.default)(); var setState = function setState(nextState) { _extends(history, nextState); history.length = history.entries.length; transitionManager.notifyListeners(history.location, history.action); }; var createKey = function createKey() { return Math.random().toString(36).substr(2, keyLength); }; var index = clamp(initialIndex, 0, initialEntries.length - 1); var entries = initialEntries.map(function (entry) { return typeof entry === 'string' ? (0, _LocationUtils.createLocation)(entry, undefined, createKey()) : (0, _LocationUtils.createLocation)(entry, undefined, entry.key || createKey()); }); // Public interface var createHref = _PathUtils.createPath; var push = function push(path, state) { (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); var action = 'PUSH'; var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var prevIndex = history.index; var nextIndex = prevIndex + 1; var nextEntries = history.entries.slice(0); if (nextEntries.length > nextIndex) { nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location); } else { nextEntries.push(location); } setState({ action: action, location: location, index: nextIndex, entries: nextEntries }); }); }; var replace = function replace(path, state) { (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); var action = 'REPLACE'; var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; history.entries[history.index] = location; setState({ action: action, location: location }); }); }; var go = function go(n) { var nextIndex = clamp(history.index + n, 0, history.entries.length - 1); var action = 'POP'; var location = history.entries[nextIndex]; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location, index: nextIndex }); } else { // Mimic the behavior of DOM histories by // causing a render after a cancelled POP. setState(); } }); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var canGo = function canGo(n) { var nextIndex = history.index + n; return nextIndex >= 0 && nextIndex < history.entries.length; }; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; return transitionManager.setPrompt(prompt); }; var listen = function listen(listener) { return transitionManager.appendListener(listener); }; var history = { length: entries.length, action: 'POP', location: entries[index], index: index, entries: entries, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, canGo: canGo, block: block, listen: listen }; return history; }; exports.default = createMemoryHistory; /***/ }), /***/ "./node_modules/history/createTransitionManager.js": /*!*********************************************************!*\ !*** ./node_modules/history/createTransitionManager.js ***! \*********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _warning = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); var _warning2 = _interopRequireDefault(_warning); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var createTransitionManager = function createTransitionManager() { var prompt = null; var setPrompt = function setPrompt(nextPrompt) { (0, _warning2.default)(prompt == null, 'A history supports only one prompt at a time'); prompt = nextPrompt; return function () { if (prompt === nextPrompt) prompt = null; }; }; var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) { // TODO: If another transition starts while we're still confirming // the previous one, we may end up in a weird state. Figure out the // best way to handle this. if (prompt != null) { var result = typeof prompt === 'function' ? prompt(location, action) : prompt; if (typeof result === 'string') { if (typeof getUserConfirmation === 'function') { getUserConfirmation(result, callback); } else { (0, _warning2.default)(false, 'A history needs a getUserConfirmation function in order to use a prompt message'); callback(true); } } else { // Return false from a transition hook to cancel the transition. callback(result !== false); } } else { callback(true); } }; var listeners = []; var appendListener = function appendListener(fn) { var isActive = true; var listener = function listener() { if (isActive) fn.apply(undefined, arguments); }; listeners.push(listener); return function () { isActive = false; listeners = listeners.filter(function (item) { return item !== listener; }); }; }; var notifyListeners = function notifyListeners() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } listeners.forEach(function (listener) { return listener.apply(undefined, args); }); }; return { setPrompt: setPrompt, confirmTransitionTo: confirmTransitionTo, appendListener: appendListener, notifyListeners: notifyListeners }; }; exports.default = createTransitionManager; /***/ }), /***/ "./node_modules/history/es/DOMUtils.js": /*!*********************************************!*\ !*** ./node_modules/history/es/DOMUtils.js ***! \*********************************************/ /*! exports provided: canUseDOM, addEventListener, removeEventListener, getConfirmation, supportsHistory, supportsPopStateOnHashChange, supportsGoWithoutReloadUsingHash, isExtraneousPopstateEvent */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "canUseDOM", function() { return canUseDOM; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addEventListener", function() { return addEventListener; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeEventListener", function() { return removeEventListener; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getConfirmation", function() { return getConfirmation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "supportsHistory", function() { return supportsHistory; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "supportsPopStateOnHashChange", function() { return supportsPopStateOnHashChange; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "supportsGoWithoutReloadUsingHash", function() { return supportsGoWithoutReloadUsingHash; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isExtraneousPopstateEvent", function() { return isExtraneousPopstateEvent; }); var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); var addEventListener = function addEventListener(node, event, listener) { return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener); }; var removeEventListener = function removeEventListener(node, event, listener) { return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener); }; var getConfirmation = function getConfirmation(message, callback) { return callback(window.confirm(message)); }; // eslint-disable-line no-alert /** * Returns true if the HTML5 history API is supported. Taken from Modernizr. * * https://github.com/Modernizr/Modernizr/blob/master/LICENSE * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586 */ var supportsHistory = function supportsHistory() { var ua = window.navigator.userAgent; if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false; return window.history && 'pushState' in window.history; }; /** * Returns true if browser fires popstate on hash change. * IE10 and IE11 do not. */ var supportsPopStateOnHashChange = function supportsPopStateOnHashChange() { return window.navigator.userAgent.indexOf('Trident') === -1; }; /** * Returns false if using go(n) with hash history causes a full page reload. */ var supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() { return window.navigator.userAgent.indexOf('Firefox') === -1; }; /** * Returns true if a given popstate event is an extraneous WebKit event. * Accounts for the fact that Chrome on iOS fires real popstate events * containing undefined state when pressing the back button. */ var isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) { return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1; }; /***/ }), /***/ "./node_modules/history/es/LocationUtils.js": /*!**************************************************!*\ !*** ./node_modules/history/es/LocationUtils.js ***! \**************************************************/ /*! exports provided: createLocation, locationsAreEqual */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createLocation", function() { return createLocation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "locationsAreEqual", function() { return locationsAreEqual; }); /* harmony import */ var resolve_pathname__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! resolve-pathname */ "./node_modules/resolve-pathname/index.js"); /* harmony import */ var value_equal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! value-equal */ "./node_modules/value-equal/index.js"); /* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var createLocation = function createLocation(path, state, key, currentLocation) { var location = void 0; if (typeof path === 'string') { // Two-arg form: push(path, state) location = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_2__["parsePath"])(path); location.state = state; } else { // One-arg form: push(location) location = _extends({}, path); if (location.pathname === undefined) location.pathname = ''; if (location.search) { if (location.search.charAt(0) !== '?') location.search = '?' + location.search; } else { location.search = ''; } if (location.hash) { if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash; } else { location.hash = ''; } if (state !== undefined && location.state === undefined) location.state = state; } try { location.pathname = decodeURI(location.pathname); } catch (e) { if (e instanceof URIError) { throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.'); } else { throw e; } } if (key) location.key = key; if (currentLocation) { // Resolve incomplete/relative pathname relative to current location. if (!location.pathname) { location.pathname = currentLocation.pathname; } else if (location.pathname.charAt(0) !== '/') { location.pathname = Object(resolve_pathname__WEBPACK_IMPORTED_MODULE_0__["default"])(location.pathname, currentLocation.pathname); } } else { // When there is no prior location and pathname is empty, set it to / if (!location.pathname) { location.pathname = '/'; } } return location; }; var locationsAreEqual = function locationsAreEqual(a, b) { return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && Object(value_equal__WEBPACK_IMPORTED_MODULE_1__["default"])(a.state, b.state); }; /***/ }), /***/ "./node_modules/history/es/PathUtils.js": /*!**********************************************!*\ !*** ./node_modules/history/es/PathUtils.js ***! \**********************************************/ /*! exports provided: addLeadingSlash, stripLeadingSlash, hasBasename, stripBasename, stripTrailingSlash, parsePath, createPath */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addLeadingSlash", function() { return addLeadingSlash; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripLeadingSlash", function() { return stripLeadingSlash; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBasename", function() { return hasBasename; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripBasename", function() { return stripBasename; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripTrailingSlash", function() { return stripTrailingSlash; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parsePath", function() { return parsePath; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createPath", function() { return createPath; }); var addLeadingSlash = function addLeadingSlash(path) { return path.charAt(0) === '/' ? path : '/' + path; }; var stripLeadingSlash = function stripLeadingSlash(path) { return path.charAt(0) === '/' ? path.substr(1) : path; }; var hasBasename = function hasBasename(path, prefix) { return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path); }; var stripBasename = function stripBasename(path, prefix) { return hasBasename(path, prefix) ? path.substr(prefix.length) : path; }; var stripTrailingSlash = function stripTrailingSlash(path) { return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path; }; var parsePath = function parsePath(path) { var pathname = path || '/'; var search = ''; var hash = ''; var hashIndex = pathname.indexOf('#'); if (hashIndex !== -1) { hash = pathname.substr(hashIndex); pathname = pathname.substr(0, hashIndex); } var searchIndex = pathname.indexOf('?'); if (searchIndex !== -1) { search = pathname.substr(searchIndex); pathname = pathname.substr(0, searchIndex); } return { pathname: pathname, search: search === '?' ? '' : search, hash: hash === '#' ? '' : hash }; }; var createPath = function createPath(location) { var pathname = location.pathname, search = location.search, hash = location.hash; var path = pathname || '/'; if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search; if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash; return path; }; /***/ }), /***/ "./node_modules/history/es/createBrowserHistory.js": /*!*********************************************************!*\ !*** ./node_modules/history/es/createBrowserHistory.js ***! \*********************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); /* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(warning__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); /* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(invariant__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _LocationUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/es/LocationUtils.js"); /* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); /* harmony import */ var _createTransitionManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/es/createTransitionManager.js"); /* harmony import */ var _DOMUtils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./DOMUtils */ "./node_modules/history/es/DOMUtils.js"); var _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; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var PopStateEvent = 'popstate'; var HashChangeEvent = 'hashchange'; var getHistoryState = function getHistoryState() { try { return window.history.state || {}; } catch (e) { // IE 11 sometimes throws when accessing window.history.state // See https://github.com/ReactTraining/history/pull/289 return {}; } }; /** * Creates a history object that uses the HTML5 history API including * pushState, replaceState, and the popstate event. */ var createBrowserHistory = function createBrowserHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; invariant__WEBPACK_IMPORTED_MODULE_1___default()(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["canUseDOM"], 'Browser history needs a DOM'); var globalHistory = window.history; var canUseHistory = Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["supportsHistory"])(); var needsHashChangeListener = !Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["supportsPopStateOnHashChange"])(); var _props$forceRefresh = props.forceRefresh, forceRefresh = _props$forceRefresh === undefined ? false : _props$forceRefresh, _props$getUserConfirm = props.getUserConfirmation, getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils__WEBPACK_IMPORTED_MODULE_5__["getConfirmation"] : _props$getUserConfirm, _props$keyLength = props.keyLength, keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; var basename = props.basename ? Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripTrailingSlash"])(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"])(props.basename)) : ''; var getDOMLocation = function getDOMLocation(historyState) { var _ref = historyState || {}, key = _ref.key, state = _ref.state; var _window$location = window.location, pathname = _window$location.pathname, search = _window$location.search, hash = _window$location.hash; var path = pathname + search + hash; warning__WEBPACK_IMPORTED_MODULE_0___default()(!basename || Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["hasBasename"])(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'); if (basename) path = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripBasename"])(path, basename); return Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, key); }; var createKey = function createKey() { return Math.random().toString(36).substr(2, keyLength); }; var transitionManager = Object(_createTransitionManager__WEBPACK_IMPORTED_MODULE_4__["default"])(); var setState = function setState(nextState) { _extends(history, nextState); history.length = globalHistory.length; transitionManager.notifyListeners(history.location, history.action); }; var handlePopState = function handlePopState(event) { // Ignore extraneous popstate events in WebKit. if (Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["isExtraneousPopstateEvent"])(event)) return; handlePop(getDOMLocation(event.state)); }; var handleHashChange = function handleHashChange() { handlePop(getDOMLocation(getHistoryState())); }; var forceNextPop = false; var handlePop = function handlePop(location) { if (forceNextPop) { forceNextPop = false; setState(); } else { var action = 'POP'; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location }); } else { revertPop(location); } }); } }; var revertPop = function revertPop(fromLocation) { var toLocation = history.location; // TODO: We could probably make this more reliable by // keeping a list of keys we've seen in sessionStorage. // Instead, we just default to 0 for keys we don't know. var toIndex = allKeys.indexOf(toLocation.key); if (toIndex === -1) toIndex = 0; var fromIndex = allKeys.indexOf(fromLocation.key); if (fromIndex === -1) fromIndex = 0; var delta = toIndex - fromIndex; if (delta) { forceNextPop = true; go(delta); } }; var initialLocation = getDOMLocation(getHistoryState()); var allKeys = [initialLocation.key]; // Public interface var createHref = function createHref(location) { return basename + Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location); }; var push = function push(path, state) { warning__WEBPACK_IMPORTED_MODULE_0___default()(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); var action = 'PUSH'; var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var href = createHref(location); var key = location.key, state = location.state; if (canUseHistory) { globalHistory.pushState({ key: key, state: state }, null, href); if (forceRefresh) { window.location.href = href; } else { var prevIndex = allKeys.indexOf(history.location.key); var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); nextKeys.push(location.key); allKeys = nextKeys; setState({ action: action, location: location }); } } else { warning__WEBPACK_IMPORTED_MODULE_0___default()(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history'); window.location.href = href; } }); }; var replace = function replace(path, state) { warning__WEBPACK_IMPORTED_MODULE_0___default()(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); var action = 'REPLACE'; var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var href = createHref(location); var key = location.key, state = location.state; if (canUseHistory) { globalHistory.replaceState({ key: key, state: state }, null, href); if (forceRefresh) { window.location.replace(href); } else { var prevIndex = allKeys.indexOf(history.location.key); if (prevIndex !== -1) allKeys[prevIndex] = location.key; setState({ action: action, location: location }); } } else { warning__WEBPACK_IMPORTED_MODULE_0___default()(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history'); window.location.replace(href); } }); }; var go = function go(n) { globalHistory.go(n); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var listenerCount = 0; var checkDOMListeners = function checkDOMListeners(delta) { listenerCount += delta; if (listenerCount === 1) { Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["addEventListener"])(window, PopStateEvent, handlePopState); if (needsHashChangeListener) Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["addEventListener"])(window, HashChangeEvent, handleHashChange); } else if (listenerCount === 0) { Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["removeEventListener"])(window, PopStateEvent, handlePopState); if (needsHashChangeListener) Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["removeEventListener"])(window, HashChangeEvent, handleHashChange); } }; var isBlocked = false; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var unblock = transitionManager.setPrompt(prompt); if (!isBlocked) { checkDOMListeners(1); isBlocked = true; } return function () { if (isBlocked) { isBlocked = false; checkDOMListeners(-1); } return unblock(); }; }; var listen = function listen(listener) { var unlisten = transitionManager.appendListener(listener); checkDOMListeners(1); return function () { checkDOMListeners(-1); unlisten(); }; }; var history = { length: globalHistory.length, action: 'POP', location: initialLocation, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, block: block, listen: listen }; return history; }; /* harmony default export */ __webpack_exports__["default"] = (createBrowserHistory); /***/ }), /***/ "./node_modules/history/es/createHashHistory.js": /*!******************************************************!*\ !*** ./node_modules/history/es/createHashHistory.js ***! \******************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); /* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(warning__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); /* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(invariant__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _LocationUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/es/LocationUtils.js"); /* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); /* harmony import */ var _createTransitionManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/es/createTransitionManager.js"); /* harmony import */ var _DOMUtils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./DOMUtils */ "./node_modules/history/es/DOMUtils.js"); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var HashChangeEvent = 'hashchange'; var HashPathCoders = { hashbang: { encodePath: function encodePath(path) { return path.charAt(0) === '!' ? path : '!/' + Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripLeadingSlash"])(path); }, decodePath: function decodePath(path) { return path.charAt(0) === '!' ? path.substr(1) : path; } }, noslash: { encodePath: _PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripLeadingSlash"], decodePath: _PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"] }, slash: { encodePath: _PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"], decodePath: _PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"] } }; var getHashPath = function getHashPath() { // We can't use window.location.hash here because it's not // consistent across browsers - Firefox will pre-decode it! var href = window.location.href; var hashIndex = href.indexOf('#'); return hashIndex === -1 ? '' : href.substring(hashIndex + 1); }; var pushHashPath = function pushHashPath(path) { return window.location.hash = path; }; var replaceHashPath = function replaceHashPath(path) { var hashIndex = window.location.href.indexOf('#'); window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path); }; var createHashHistory = function createHashHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; invariant__WEBPACK_IMPORTED_MODULE_1___default()(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["canUseDOM"], 'Hash history needs a DOM'); var globalHistory = window.history; var canGoWithoutReload = Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["supportsGoWithoutReloadUsingHash"])(); var _props$getUserConfirm = props.getUserConfirmation, getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils__WEBPACK_IMPORTED_MODULE_5__["getConfirmation"] : _props$getUserConfirm, _props$hashType = props.hashType, hashType = _props$hashType === undefined ? 'slash' : _props$hashType; var basename = props.basename ? Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripTrailingSlash"])(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"])(props.basename)) : ''; var _HashPathCoders$hashT = HashPathCoders[hashType], encodePath = _HashPathCoders$hashT.encodePath, decodePath = _HashPathCoders$hashT.decodePath; var getDOMLocation = function getDOMLocation() { var path = decodePath(getHashPath()); warning__WEBPACK_IMPORTED_MODULE_0___default()(!basename || Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["hasBasename"])(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'); if (basename) path = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripBasename"])(path, basename); return Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path); }; var transitionManager = Object(_createTransitionManager__WEBPACK_IMPORTED_MODULE_4__["default"])(); var setState = function setState(nextState) { _extends(history, nextState); history.length = globalHistory.length; transitionManager.notifyListeners(history.location, history.action); }; var forceNextPop = false; var ignorePath = null; var handleHashChange = function handleHashChange() { var path = getHashPath(); var encodedPath = encodePath(path); if (path !== encodedPath) { // Ensure we always have a properly-encoded hash. replaceHashPath(encodedPath); } else { var location = getDOMLocation(); var prevLocation = history.location; if (!forceNextPop && Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["locationsAreEqual"])(prevLocation, location)) return; // A hashchange doesn't always == location change. if (ignorePath === Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location)) return; // Ignore this change; we already setState in push/replace. ignorePath = null; handlePop(location); } }; var handlePop = function handlePop(location) { if (forceNextPop) { forceNextPop = false; setState(); } else { var action = 'POP'; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location }); } else { revertPop(location); } }); } }; var revertPop = function revertPop(fromLocation) { var toLocation = history.location; // TODO: We could probably make this more reliable by // keeping a list of paths we've seen in sessionStorage. // Instead, we just default to 0 for paths we don't know. var toIndex = allPaths.lastIndexOf(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(toLocation)); if (toIndex === -1) toIndex = 0; var fromIndex = allPaths.lastIndexOf(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(fromLocation)); if (fromIndex === -1) fromIndex = 0; var delta = toIndex - fromIndex; if (delta) { forceNextPop = true; go(delta); } }; // Ensure the hash is encoded properly before doing anything else. var path = getHashPath(); var encodedPath = encodePath(path); if (path !== encodedPath) replaceHashPath(encodedPath); var initialLocation = getDOMLocation(); var allPaths = [Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(initialLocation)]; // Public interface var createHref = function createHref(location) { return '#' + encodePath(basename + Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location)); }; var push = function push(path, state) { warning__WEBPACK_IMPORTED_MODULE_0___default()(state === undefined, 'Hash history cannot push state; it is ignored'); var action = 'PUSH'; var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, undefined, undefined, history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var path = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location); var encodedPath = encodePath(basename + path); var hashChanged = getHashPath() !== encodedPath; if (hashChanged) { // We cannot tell if a hashchange was caused by a PUSH, so we'd // rather setState here and ignore the hashchange. The caveat here // is that other hash histories in the page will consider it a POP. ignorePath = path; pushHashPath(encodedPath); var prevIndex = allPaths.lastIndexOf(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(history.location)); var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); nextPaths.push(path); allPaths = nextPaths; setState({ action: action, location: location }); } else { warning__WEBPACK_IMPORTED_MODULE_0___default()(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack'); setState(); } }); }; var replace = function replace(path, state) { warning__WEBPACK_IMPORTED_MODULE_0___default()(state === undefined, 'Hash history cannot replace state; it is ignored'); var action = 'REPLACE'; var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, undefined, undefined, history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var path = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location); var encodedPath = encodePath(basename + path); var hashChanged = getHashPath() !== encodedPath; if (hashChanged) { // We cannot tell if a hashchange was caused by a REPLACE, so we'd // rather setState here and ignore the hashchange. The caveat here // is that other hash histories in the page will consider it a POP. ignorePath = path; replaceHashPath(encodedPath); } var prevIndex = allPaths.indexOf(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(history.location)); if (prevIndex !== -1) allPaths[prevIndex] = path; setState({ action: action, location: location }); }); }; var go = function go(n) { warning__WEBPACK_IMPORTED_MODULE_0___default()(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser'); globalHistory.go(n); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var listenerCount = 0; var checkDOMListeners = function checkDOMListeners(delta) { listenerCount += delta; if (listenerCount === 1) { Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["addEventListener"])(window, HashChangeEvent, handleHashChange); } else if (listenerCount === 0) { Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["removeEventListener"])(window, HashChangeEvent, handleHashChange); } }; var isBlocked = false; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var unblock = transitionManager.setPrompt(prompt); if (!isBlocked) { checkDOMListeners(1); isBlocked = true; } return function () { if (isBlocked) { isBlocked = false; checkDOMListeners(-1); } return unblock(); }; }; var listen = function listen(listener) { var unlisten = transitionManager.appendListener(listener); checkDOMListeners(1); return function () { checkDOMListeners(-1); unlisten(); }; }; var history = { length: globalHistory.length, action: 'POP', location: initialLocation, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, block: block, listen: listen }; return history; }; /* harmony default export */ __webpack_exports__["default"] = (createHashHistory); /***/ }), /***/ "./node_modules/history/es/createMemoryHistory.js": /*!********************************************************!*\ !*** ./node_modules/history/es/createMemoryHistory.js ***! \********************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); /* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(warning__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); /* harmony import */ var _LocationUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/es/LocationUtils.js"); /* harmony import */ var _createTransitionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/es/createTransitionManager.js"); var _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; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var clamp = function clamp(n, lowerBound, upperBound) { return Math.min(Math.max(n, lowerBound), upperBound); }; /** * Creates a history object that stores locations in memory. */ var createMemoryHistory = function createMemoryHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var getUserConfirmation = props.getUserConfirmation, _props$initialEntries = props.initialEntries, initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries, _props$initialIndex = props.initialIndex, initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex, _props$keyLength = props.keyLength, keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; var transitionManager = Object(_createTransitionManager__WEBPACK_IMPORTED_MODULE_3__["default"])(); var setState = function setState(nextState) { _extends(history, nextState); history.length = history.entries.length; transitionManager.notifyListeners(history.location, history.action); }; var createKey = function createKey() { return Math.random().toString(36).substr(2, keyLength); }; var index = clamp(initialIndex, 0, initialEntries.length - 1); var entries = initialEntries.map(function (entry) { return typeof entry === 'string' ? Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(entry, undefined, createKey()) : Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(entry, undefined, entry.key || createKey()); }); // Public interface var createHref = _PathUtils__WEBPACK_IMPORTED_MODULE_1__["createPath"]; var push = function push(path, state) { warning__WEBPACK_IMPORTED_MODULE_0___default()(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); var action = 'PUSH'; var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var prevIndex = history.index; var nextIndex = prevIndex + 1; var nextEntries = history.entries.slice(0); if (nextEntries.length > nextIndex) { nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location); } else { nextEntries.push(location); } setState({ action: action, location: location, index: nextIndex, entries: nextEntries }); }); }; var replace = function replace(path, state) { warning__WEBPACK_IMPORTED_MODULE_0___default()(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); var action = 'REPLACE'; var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; history.entries[history.index] = location; setState({ action: action, location: location }); }); }; var go = function go(n) { var nextIndex = clamp(history.index + n, 0, history.entries.length - 1); var action = 'POP'; var location = history.entries[nextIndex]; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location, index: nextIndex }); } else { // Mimic the behavior of DOM histories by // causing a render after a cancelled POP. setState(); } }); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var canGo = function canGo(n) { var nextIndex = history.index + n; return nextIndex >= 0 && nextIndex < history.entries.length; }; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; return transitionManager.setPrompt(prompt); }; var listen = function listen(listener) { return transitionManager.appendListener(listener); }; var history = { length: entries.length, action: 'POP', location: entries[index], index: index, entries: entries, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, canGo: canGo, block: block, listen: listen }; return history; }; /* harmony default export */ __webpack_exports__["default"] = (createMemoryHistory); /***/ }), /***/ "./node_modules/history/es/createTransitionManager.js": /*!************************************************************!*\ !*** ./node_modules/history/es/createTransitionManager.js ***! \************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); /* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(warning__WEBPACK_IMPORTED_MODULE_0__); var createTransitionManager = function createTransitionManager() { var prompt = null; var setPrompt = function setPrompt(nextPrompt) { warning__WEBPACK_IMPORTED_MODULE_0___default()(prompt == null, 'A history supports only one prompt at a time'); prompt = nextPrompt; return function () { if (prompt === nextPrompt) prompt = null; }; }; var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) { // TODO: If another transition starts while we're still confirming // the previous one, we may end up in a weird state. Figure out the // best way to handle this. if (prompt != null) { var result = typeof prompt === 'function' ? prompt(location, action) : prompt; if (typeof result === 'string') { if (typeof getUserConfirmation === 'function') { getUserConfirmation(result, callback); } else { warning__WEBPACK_IMPORTED_MODULE_0___default()(false, 'A history needs a getUserConfirmation function in order to use a prompt message'); callback(true); } } else { // Return false from a transition hook to cancel the transition. callback(result !== false); } } else { callback(true); } }; var listeners = []; var appendListener = function appendListener(fn) { var isActive = true; var listener = function listener() { if (isActive) fn.apply(undefined, arguments); }; listeners.push(listener); return function () { isActive = false; listeners = listeners.filter(function (item) { return item !== listener; }); }; }; var notifyListeners = function notifyListeners() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } listeners.forEach(function (listener) { return listener.apply(undefined, args); }); }; return { setPrompt: setPrompt, confirmTransitionTo: confirmTransitionTo, appendListener: appendListener, notifyListeners: notifyListeners }; }; /* harmony default export */ __webpack_exports__["default"] = (createTransitionManager); /***/ }), /***/ "./node_modules/history/es/index.js": /*!******************************************!*\ !*** ./node_modules/history/es/index.js ***! \******************************************/ /*! exports provided: createBrowserHistory, createHashHistory, createMemoryHistory, createLocation, locationsAreEqual, parsePath, createPath */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _createBrowserHistory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./createBrowserHistory */ "./node_modules/history/es/createBrowserHistory.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createBrowserHistory", function() { return _createBrowserHistory__WEBPACK_IMPORTED_MODULE_0__["default"]; }); /* harmony import */ var _createHashHistory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./createHashHistory */ "./node_modules/history/es/createHashHistory.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createHashHistory", function() { return _createHashHistory__WEBPACK_IMPORTED_MODULE_1__["default"]; }); /* harmony import */ var _createMemoryHistory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./createMemoryHistory */ "./node_modules/history/es/createMemoryHistory.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createMemoryHistory", function() { return _createMemoryHistory__WEBPACK_IMPORTED_MODULE_2__["default"]; }); /* harmony import */ var _LocationUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/es/LocationUtils.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createLocation", function() { return _LocationUtils__WEBPACK_IMPORTED_MODULE_3__["createLocation"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "locationsAreEqual", function() { return _LocationUtils__WEBPACK_IMPORTED_MODULE_3__["locationsAreEqual"]; }); /* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "parsePath", function() { return _PathUtils__WEBPACK_IMPORTED_MODULE_4__["parsePath"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createPath", function() { return _PathUtils__WEBPACK_IMPORTED_MODULE_4__["createPath"]; }); /***/ }), /***/ "./node_modules/hoist-non-react-statics/index.js": /*!*******************************************************!*\ !*** ./node_modules/hoist-non-react-statics/index.js ***! \*******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { /** * Copyright 2015, Yahoo! Inc. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ (function (global, factory) { true ? module.exports = factory() : undefined; }(this, (function () { 'use strict'; var REACT_STATICS = { childContextTypes: true, contextTypes: true, defaultProps: true, displayName: true, getDefaultProps: true, getDerivedStateFromProps: true, mixins: true, propTypes: true, type: true }; var KNOWN_STATICS = { name: true, length: true, prototype: true, caller: true, callee: true, arguments: true, arity: true }; var defineProperty = Object.defineProperty; var getOwnPropertyNames = Object.getOwnPropertyNames; var getOwnPropertySymbols = Object.getOwnPropertySymbols; var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var getPrototypeOf = Object.getPrototypeOf; var objectPrototype = getPrototypeOf && getPrototypeOf(Object); return function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components if (objectPrototype) { var inheritedComponent = getPrototypeOf(sourceComponent); if (inheritedComponent && inheritedComponent !== objectPrototype) { hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); } } var keys = getOwnPropertyNames(sourceComponent); if (getOwnPropertySymbols) { keys = keys.concat(getOwnPropertySymbols(sourceComponent)); } for (var i = 0; i < keys.length; ++i) { var key = keys[i]; if (!REACT_STATICS[key] && !KNOWN_STATICS[key] && (!blacklist || !blacklist[key])) { var descriptor = getOwnPropertyDescriptor(sourceComponent, key); try { // Avoid failures from read-only properties defineProperty(targetComponent, key, descriptor); } catch (e) {} } } return targetComponent; } return targetComponent; }; }))); /***/ }), /***/ "./node_modules/ieee754/index.js": /*!***************************************!*\ !*** ./node_modules/ieee754/index.js ***! \***************************************/ /*! no static exports found */ /***/ (function(module, exports) { exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 var eMax = (1 << eLen) - 1 var eBias = eMax >> 1 var nBits = -7 var i = isLE ? (nBytes - 1) : 0 var d = isLE ? -1 : 1 var s = buffer[offset + i] i += d e = s & ((1 << (-nBits)) - 1) s >>= (-nBits) nBits += eLen for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} m = e & ((1 << (-nBits)) - 1) e >>= (-nBits) nBits += mLen for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} if (e === 0) { e = 1 - eBias } else if (e === eMax) { return m ? NaN : ((s ? -1 : 1) * Infinity) } else { m = m + Math.pow(2, mLen) e = e - eBias } return (s ? -1 : 1) * m * Math.pow(2, e - mLen) } exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { var e, m, c var eLen = (nBytes * 8) - mLen - 1 var eMax = (1 << eLen) - 1 var eBias = eMax >> 1 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) var i = isLE ? 0 : (nBytes - 1) var d = isLE ? 1 : -1 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 value = Math.abs(value) if (isNaN(value) || value === Infinity) { m = isNaN(value) ? 1 : 0 e = eMax } else { e = Math.floor(Math.log(value) / Math.LN2) if (value * (c = Math.pow(2, -e)) < 1) { e-- c *= 2 } if (e + eBias >= 1) { value += rt / c } else { value += rt * Math.pow(2, 1 - eBias) } if (value * c >= 2) { e++ c /= 2 } if (e + eBias >= eMax) { m = 0 e = eMax } else if (e + eBias >= 1) { m = ((value * c) - 1) * Math.pow(2, mLen) e = e + eBias } else { m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) e = 0 } } for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} e = (e << mLen) | m eLen += mLen for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} buffer[offset + i - d] |= s * 128 } /***/ }), /***/ "./node_modules/immediate/lib/browser.js": /*!***********************************************!*\ !*** ./node_modules/immediate/lib/browser.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) { var Mutation = global.MutationObserver || global.WebKitMutationObserver; var scheduleDrain; { if (Mutation) { var called = 0; var observer = new Mutation(nextTick); var element = global.document.createTextNode(''); observer.observe(element, { characterData: true }); scheduleDrain = function () { element.data = (called = ++called % 2); }; } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') { var channel = new global.MessageChannel(); channel.port1.onmessage = nextTick; scheduleDrain = function () { channel.port2.postMessage(0); }; } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) { scheduleDrain = function () { // Create a