diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-06 04:05:54 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-06 04:05:54 +0200 |
| commit | 2f4d1e9c43770ca4e72b736a08cd0e3b3945274f (patch) | |
| tree | 95881cf2020f636bf91cf98a560aa530328c3669 /public/bundle.js | |
| parent | 563ca8019025dd1e1febc6179601eee0e1f62724 (diff) | |
form make more sense
Diffstat (limited to 'public/bundle.js')
| -rw-r--r-- | public/bundle.js | 318 |
1 files changed, 285 insertions, 33 deletions
diff --git a/public/bundle.js b/public/bundle.js index fb762ee..1d48d38 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -1703,6 +1703,8 @@ var _fileSaver = __webpack_require__(/*! file-saver */ "./node_modules/file-save var _fileSaver2 = _interopRequireDefault(_fileSaver); +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); @@ -1769,8 +1771,8 @@ var renderFrames = exports.renderFrames = function renderFrames(file, _ref) { dispatch({ type: _types2.default.wav2pix.loaded_buffer }); var canvases = []; - for (var offset = 0, _count = 0, _len = pcm.length - FRAME_LENGTH; offset < _len && _count < max; offset += frame_offset, _count += 1) { - canvases.push(render(pcm.slice(offset, offset + FRAME_LENGTH), sr, _count)); + for (var offset = 0, count = 0, _len = pcm.length - FRAME_LENGTH; offset < _len && count < max; offset += frame_offset, count += 1) { + canvases.push(render(pcm.slice(offset, offset + FRAME_LENGTH), sr, count)); } dispatch({ type: _types2.default.wav2pix.draw_finish }); resolve(canvases); @@ -1796,11 +1798,14 @@ var buildZip = exports.buildZip = function buildZip(name, file, _ref3) { var zip = new _jszip2.default(); var zip_folder = zip.folder("wav2pix_" + name); - for (var offset = 0, _count2 = 0, _len = pcm.length - FRAME_LENGTH; offset < _len && _count2 < max; offset += frame_offset, _count2 += 1) { - if (_count2 % 100 === 0) { - dispatch({ type: _types2.default.wav2pix.draw_progress, count: _count2 }); + var offset = 0, + count = 0, + _len = pcm.length - FRAME_LENGTH; + for (; offset < _len && count < max; offset += frame_offset, count += 1) { + if (count % 10 === 0) { + dispatch({ type: _types2.default.wav2pix.draw_progress, count: count }); } - render(pcm.slice(offset, offset + FRAME_LENGTH), sr, _count2, zip_folder); + render(pcm.slice(offset, offset + FRAME_LENGTH), sr, count, zip_folder); } // dispatch event @@ -1808,7 +1813,11 @@ var buildZip = exports.buildZip = function buildZip(name, file, _ref3) { zip.generateAsync({ type: "blob" }).then(function (content) { dispatch({ type: _types2.default.wav2pix.load_zip }); // FileSaver.saveAs(content, "wav2pix_" + name + ".zip") - resolve({ zip: content, count: count }); + resolve({ + zip: content, + name: "wav2pix_" + name + ".zip", + count: count + }); }); }); }); @@ -1826,7 +1835,7 @@ function render(pcm, sr, count, zip) { imageData = _draw$raw_spectrum.imageData; if (zip) { - var name = sprintf('frame_%05d.png', count); + var name = (0, _sprintfJs.sprintf)('frame_%05d.png', count); var dataURL = canvas.toDataURL("image/png"); zip.file(name, dataURL.split(',')[1], { base64: true }); } @@ -7243,6 +7252,10 @@ var _dataset = __webpack_require__(/*! ../../dataset/dataset.reducer */ "./app/c 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 = { @@ -7270,7 +7283,7 @@ var pix2wavReducer = function pix2wavReducer() { case _types2.default.wav2pix.draw_progress: console.log(action); return _extends({}, state, { - status: 'Rendering frame /' + status: 'Rendering frame ' + action.count }); case _types2.default.wav2pix.draw_finish: return _extends({}, state, { @@ -7280,6 +7293,10 @@ var pix2wavReducer = function pix2wavReducer() { return _extends({}, state, { status: 'Built zip file' }); + case _types2.default.wav2pix.uploading: + return _extends({}, state, { + status: 'Uploading zip file (' + _util2.default.hush_size(action.size) + ')' + }); default: return state; } @@ -7718,7 +7735,7 @@ var SpectrogramUpload = function (_Component) { this.audioElement.src = URL.createObjectURL(file); console.log(file.size); if (file.size < 2 << 20) { - console.log('booooooooo'); + console.log('running le test!!!!!'); this.props.wav2pix.renderFrames(file, {}).then(function (frames) { console.log(frames); _this2.setState(_extends({}, _this2.state, { frames: frames @@ -7739,7 +7756,7 @@ var SpectrogramUpload = function (_Component) { var zip = _ref.zip, count = _ref.count; - _this3.props.datasetActions.uploadFile(_pix2wav4.default, _this3.props.pix2wav.folder_id, zip, { count: count }); + _this3.props.datasetActions.uploadFile(_pix2wav4.default, _this3.props.id, zip, { count: count }); }); } }, { @@ -7753,6 +7770,7 @@ var SpectrogramUpload = function (_Component) { // module={pix2wavModule} // data={pix2wav.data} // folder={folder} + console.log(this.props); var _state = this.state, file = _state.file, frames = _state.frames; @@ -7784,23 +7802,6 @@ var SpectrogramUpload = function (_Component) { return _this4.pickFile(file); } }), - (0, _preact.h)(_common.TextInput, { - title: 'Dataset name', - onChange: function onChange(e) { - return _this4.setState({ name: e.target.value }); - }, - value: this.state.name - }), - (0, _preact.h)( - _common.Button, - { - onClick: function onClick() { - return _this4.buildZip(); - } - }, - 'Build Zip' - ), - (0, _preact.h)(_common.Progress, null), file && this.renderMetadata(file) ) ), @@ -7812,6 +7813,8 @@ var SpectrogramUpload = function (_Component) { }, { key: 'renderMetadata', value: function renderMetadata(file) { + var _this5 = this; + var duration = this.state.duration; var size = _util2.default.hush_size(file.size); @@ -7860,17 +7863,35 @@ var SpectrogramUpload = function (_Component) { (0, _preact.h)( _common.Param, { title: 'Status' }, - this.props.pix2wav.status - ) + this.props.pix2wav.status, + this.props.upload.status + ), + (0, _preact.h)(_common.TextInput, { + title: 'Dataset name', + onChange: function onChange(e) { + return _this5.setState({ name: e.target.value }); + }, + value: this.state.name + }), + (0, _preact.h)( + _common.Button, + { + onClick: function onClick() { + return _this5.buildZip(); + } + }, + 'Build Zip' + ), + (0, _preact.h)(_common.Progress, null) ); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { - var _this5 = this; + var _this6 = this; var canvases = (this.state.frames || []).map(function (c) { - _this5.canvases.append(c.canvas); + _this6.canvases.append(c.canvas); }); } }]); @@ -7880,7 +7901,8 @@ var SpectrogramUpload = function (_Component) { var mapStateToProps = function mapStateToProps(state) { return { - pix2wav: state.module.pix2wav + pix2wav: state.module.pix2wav, + upload: state.upload }; }; @@ -57478,6 +57500,236 @@ module.exports = { /***/ }), +/***/ "./node_modules/sprintf-js/src/sprintf.js": +/*!************************************************!*\ + !*** ./node_modules/sprintf-js/src/sprintf.js ***! + \************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ + +!function() { + 'use strict' + + var re = { + not_string: /[^s]/, + not_bool: /[^t]/, + not_type: /[^T]/, + not_primitive: /[^v]/, + number: /[diefg]/, + numeric_arg: /[bcdiefguxX]/, + json: /[j]/, + not_json: /[^j]/, + text: /^[^\x25]+/, + modulo: /^\x25{2}/, + placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, + key: /^([a-z_][a-z_\d]*)/i, + key_access: /^\.([a-z_][a-z_\d]*)/i, + index_access: /^\[(\d+)\]/, + sign: /^[\+\-]/ + } + + function sprintf(key) { + // `arguments` is not an array, but should be fine for this call + return sprintf_format(sprintf_parse(key), arguments) + } + + function vsprintf(fmt, argv) { + return sprintf.apply(null, [fmt].concat(argv || [])) + } + + function sprintf_format(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, match, pad, pad_character, pad_length, is_positive, sign + for (i = 0; i < tree_length; i++) { + if (typeof parse_tree[i] === 'string') { + output += parse_tree[i] + } + else if (Array.isArray(parse_tree[i])) { + match = parse_tree[i] // convenience purposes only + if (match[2]) { // keyword argument + arg = argv[cursor] + for (k = 0; k < match[2].length; k++) { + if (!arg.hasOwnProperty(match[2][k])) { + throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k])) + } + arg = arg[match[2][k]] + } + } + else if (match[1]) { // positional argument (explicit) + arg = argv[match[1]] + } + else { // positional argument (implicit) + arg = argv[cursor++] + } + + if (re.not_type.test(match[8]) && re.not_primitive.test(match[8]) && arg instanceof Function) { + arg = arg() + } + + if (re.numeric_arg.test(match[8]) && (typeof arg !== 'number' && isNaN(arg))) { + throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) + } + + if (re.number.test(match[8])) { + is_positive = arg >= 0 + } + + switch (match[8]) { + case 'b': + arg = parseInt(arg, 10).toString(2) + break + case 'c': + arg = String.fromCharCode(parseInt(arg, 10)) + break + case 'd': + case 'i': + arg = parseInt(arg, 10) + break + case 'j': + arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0) + break + case 'e': + arg = match[7] ? parseFloat(arg).toExponential(match[7]) : parseFloat(arg).toExponential() + break + case 'f': + arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg) + break + case 'g': + arg = match[7] ? String(Number(arg.toPrecision(match[7]))) : parseFloat(arg) + break + case 'o': + arg = (parseInt(arg, 10) >>> 0).toString(8) + break + case 's': + arg = String(arg) + arg = (match[7] ? arg.substring(0, match[7]) : arg) + break + case 't': + arg = String(!!arg) + arg = (match[7] ? arg.substring(0, match[7]) : arg) + break + case 'T': + arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase() + arg = (match[7] ? arg.substring(0, match[7]) : arg) + break + case 'u': + arg = parseInt(arg, 10) >>> 0 + break + case 'v': + arg = arg.valueOf() + arg = (match[7] ? arg.substring(0, match[7]) : arg) + break + case 'x': + arg = (parseInt(arg, 10) >>> 0).toString(16) + break + case 'X': + arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase() + break + } + if (re.json.test(match[8])) { + output += arg + } + else { + if (re.number.test(match[8]) && (!is_positive || match[3])) { + sign = is_positive ? '+' : '-' + arg = arg.toString().replace(re.sign, '') + } + else { + sign = '' + } + pad_character = match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' ' + pad_length = match[6] - (sign + arg).length + pad = match[6] ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' + output += match[5] ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg) + } + } + } + return output + } + + var sprintf_cache = Object.create(null) + + function sprintf_parse(fmt) { + if (sprintf_cache[fmt]) { + return sprintf_cache[fmt] + } + + var _fmt = fmt, match, parse_tree = [], arg_names = 0 + while (_fmt) { + if ((match = re.text.exec(_fmt)) !== null) { + parse_tree.push(match[0]) + } + else if ((match = re.modulo.exec(_fmt)) !== null) { + parse_tree.push('%') + } + else if ((match = re.placeholder.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1 + var field_list = [], replacement_field = match[2], field_match = [] + if ((field_match = re.key.exec(replacement_field)) !== null) { + field_list.push(field_match[1]) + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = re.key_access.exec(replacement_field)) !== null) { + field_list.push(field_match[1]) + } + else if ((field_match = re.index_access.exec(replacement_field)) !== null) { + field_list.push(field_match[1]) + } + else { + throw new SyntaxError('[sprintf] failed to parse named argument key') + } + } + } + else { + throw new SyntaxError('[sprintf] failed to parse named argument key') + } + match[2] = field_list + } + else { + arg_names |= 2 + } + if (arg_names === 3) { + throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported') + } + parse_tree.push(match) + } + else { + throw new SyntaxError('[sprintf] unexpected placeholder') + } + _fmt = _fmt.substring(match[0].length) + } + return sprintf_cache[fmt] = parse_tree + } + + /** + * export to either browser or node.js + */ + /* eslint-disable quote-props */ + if (true) { + exports['sprintf'] = sprintf + exports['vsprintf'] = vsprintf + } + if (typeof window !== 'undefined') { + window['sprintf'] = sprintf + window['vsprintf'] = vsprintf + + if (true) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { + return { + 'sprintf': sprintf, + 'vsprintf': vsprintf + } + }).call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) + } + } + /* eslint-enable quote-props */ +}() + + +/***/ }), + /***/ "./node_modules/stream-browserify/index.js": /*!*************************************************!*\ !*** ./node_modules/stream-browserify/index.js ***! |
