{ }} />
*/
(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_fullscreen = exports.send_command = 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 send_command = exports.send_command = function send_command(cmd, payload) {
_socket2.default.live.send_command(cmd, payload);
return { type: _types2.default.player.send_command };
};
var set_fullscreen = exports.set_fullscreen = function set_fullscreen(value) {
return { type: _types2.default.player.set_fullscreen, 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: {
hue: 0, saturation: 0, luminosity: 0,
sequence_playing: true, sequence_step: 1,
recurse_roll: 0, rotate: 0, scale: 0, process_frac: 0.5,
view_mode: 'b',
encoding_stored_mix_n: 0
},
all_checkpoints: [],
checkpoints: [],
epochs: ['latest'],
sequences: [],
fps: 0,
playing: false,
last_message: '',
fullscreen: false,
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];
// console.log(action)
var results = void 0;
switch (action.type) {
case _types2.default.socket.load_params:
console.log(action.opt);
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.player.set_fullscreen:
return _extends({}, state, {
fullscreen: action.value
});
case _types2.default.socket.list_checkpoints:
return _extends({}, state, {
checkpoints: action.checkpoints,
epochs: []
});
case _types2.default.socket.list_all_checkpoints:
return _extends({}, state, {
all_checkpoints: action.all_checkpoints,
epochs: []
});
case _types2.default.socket.list_epochs:
console.log(action);
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') {
// receive parameter updates from the app
if (action.data.data.indexOf('set_opt') !== -1) {
var new_opt = action.data.data.trim().split('\n').reduce(function (a, b) {
if (b.indexOf('set_opt') === 0) {
var terms = b.split(' ');
var key = terms[1];
var value = parseFloat(terms[2]);
if (isNaN(value)) {
value = terms[2];
}
a[key] = value;
}
return a;
}, {});
return _extends({}, state, {
opt: _extends({}, state.opt, new_opt)
});
}
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;
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) {
_store.store.dispatch({
type: _types2.default.player.current_frame,
meta: data.meta
});
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;
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
});
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/biggan/biggan.actions.js":
/*!*****************************************************!*\
!*** ./app/client/modules/biggan/biggan.actions.js ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.load_encodings = exports.load_results = 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 _biggan = __webpack_require__(/*! ./biggan.module */ "./app/client/modules/biggan/biggan.module.js");
var _biggan2 = _interopRequireDefault(_biggan);
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 = _biggan2.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('biggan load progress', i, n);
dispatch({
type: _types2.default.app.load_progress,
progress: { i: i, n: n },
data: { module: 'biggan' }
});
}).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,
resultsFolder = datasetApiReport.resultsFolder;
// 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,
resultsFolder: resultsFolder
}
});
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);
});
if (id) {
console.log('folder id', id);
dispatch({
type: _types2.default.dataset.set_folder,
data: {
folder_id: id,
module: module
}
});
}
};
};
var load_results = exports.load_results = function load_results(id) {
return function (dispatch) {
var module = _biggan2.default.name;
_util2.default.allProgress([_actions2.default.folder.index({
module: module,
name: 'results'
}), _actions2.default.file.index({
module: module,
datatype: 'video',
generated: 1,
limit: 250
})], function (percent, i, n) {
console.log('biggan load progress', i, n);
dispatch({
type: _types2.default.app.load_progress,
progress: { i: i, n: n },
data: { module: 'biggan' }
});
}).then(function (res) {
var _res2 = _slicedToArray(res, 2),
folders = _res2[0],
files = _res2[1]; //, datasets, results, output, datasetUsage, lossReport] = res
// console.log(files, results, renders)
dispatch({
type: _types2.default.biggan.load_results,
results: {
resultsFolder: folders[0],
files: files
}
});
});
};
};
var load_encodings = exports.load_encodings = function load_encodings() {
return function (dispatch) {
var module = _biggan2.default.name;
_util2.default.allProgress([_actions2.default.folder.index({ module: module }), _actions2.default.file.index({
module: module,
datatype: 'image',
generated: 1
})], function (percent, i, n) {
// loading function
}).then(function (res) {
var _res3 = _slicedToArray(res, 2),
folders = _res3[0],
files = _res3[1];
var folder_name_lookup = {};
var encodings = {};
folders.forEach(function (folder) {
folder_name_lookup[folder.id] = folder.name;
encodings[folder.name] = [];
});
files.forEach(function (file) {
var folder_name = folder_name_lookup[file.folder_id];
encodings[folder_name].push(file);
});
folders.forEach(function (folder) {
if (!encodings[folder.name].length) {
delete encodings[folder.name];
}
});
dispatch({
type: _types2.default.biggan.load_encodings,
encodings: encodings
});
});
};
};
/***/ }),
/***/ "./app/client/modules/biggan/biggan.module.js":
/*!****************************************************!*\
!*** ./app/client/modules/biggan/biggan.module.js ***!
\****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var bigganModule = {
name: 'biggan',
displayName: 'BigGAN',
datatype: 'image'
};
exports.default = bigganModule;
/***/ }),
/***/ "./app/client/modules/biggan/biggan.reducer.js":
/*!*****************************************************!*\
!*** ./app/client/modules/biggan/biggan.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 bigganInitialState = {
loading: true,
progress: { i: 0, n: 0 },
error: null,
folder_id: 0,
data: null,
results: null,
encodings: null,
checkpoint: {
name: '',
sequenceCount: 0,
datasetCount: 0
}
};
var bigganReducer = function bigganReducer() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : bigganInitialState;
var action = arguments[1];
if (action.data && action.data.module === 'biggan') {
state = (0, _dataset2.default)(state, action);
}
switch (action.type) {
case _types2.default.biggan.load_results:
return _extends({}, state, {
results: action.results
});
case _types2.default.biggan.load_encodings:
return _extends({}, state, {
encodings: action.encodings
});
case _types2.default.file.destroy:
console.log('file destroy', state.results);
return _extends({}, state, {
results: _extends({}, state.results, {
files: state.results.files.filter(function (f) {
return f.id !== action.data.id;
})
})
});
default:
return state;
}
};
exports.default = bigganReducer;
/***/ }),
/***/ "./app/client/modules/biggan/biggan.tasks.js":
/*!***************************************************!*\
!*** ./app/client/modules/biggan/biggan.tasks.js ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.live_task = exports.invert_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 _biggan = __webpack_require__(/*! ./biggan.module */ "./app/client/modules/biggan/biggan.module.js");
var _biggan2 = _interopRequireDefault(_biggan);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var invert_task = exports.invert_task = function invert_task(folder_id) {
return function (dispatch) {
var task = {
module: _biggan2.default.name,
activity: 'invert',
opt: {
folder_id: folder_id
}
};
console.log(task);
return _actions2.default.queue.add_task(task);
};
};
var live_task = exports.live_task = function live_task(opt) {
return function (dispatch) {
var task = {
module: _biggan2.default.name,
activity: 'live',
dataset: 'biggan',
opt: opt
};
console.log('add live task');
return _actions2.default.queue.add_task(task);
};
};
/***/ }),
/***/ "./app/client/modules/biggan/index.js":
/*!********************************************!*\
!*** ./app/client/modules/biggan/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 _biggan = __webpack_require__(/*! ./views/biggan.new */ "./app/client/modules/biggan/views/biggan.new.js");
var _biggan2 = _interopRequireDefault(_biggan);
var _biggan3 = __webpack_require__(/*! ./views/biggan.show */ "./app/client/modules/biggan/views/biggan.show.js");
var _biggan4 = _interopRequireDefault(_biggan3);
var _biggan5 = __webpack_require__(/*! ./views/biggan.results */ "./app/client/modules/biggan/views/biggan.results.js");
var _biggan6 = _interopRequireDefault(_biggan5);
var _biggan7 = __webpack_require__(/*! ./views/biggan.live */ "./app/client/modules/biggan/views/biggan.live.js");
var _biggan8 = _interopRequireDefault(_biggan7);
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('biggan');
document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #dfe, #def)';
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps() {
_actions2.default.system.changeTool('biggan');
document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #dfe, #def)';
}
}, {
key: 'render',
value: function render() {
return (0, _preact.h)(
'section',
null,
(0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/biggan/new/', component: _biggan2.default }),
(0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/biggan/datasets/', component: _biggan4.default }),
(0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/biggan/datasets/:id/', component: _biggan4.default }),
(0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/biggan/results/', component: _biggan6.default }),
(0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/biggan/live/', component: _biggan8.default })
);
}
}]);
return router;
}();
function links() {
return [{ url: '/biggan/new/', name: 'folders' }, { url: '/biggan/datasets/', name: 'datasets' }, { url: '/biggan/results/', name: 'results' }, { url: '/biggan/live/', name: 'live' }];
}
exports.default = {
name: 'biggan',
router: router, links: links
};
/***/ }),
/***/ "./app/client/modules/biggan/views/biggan.categoryList.js":
/*!****************************************************************!*\
!*** ./app/client/modules/biggan/views/biggan.categoryList.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 _actions = __webpack_require__(/*! ../../../actions */ "./app/client/actions.js");
var _actions2 = _interopRequireDefault(_actions);
var _biggan = __webpack_require__(/*! ../biggan.tasks */ "./app/client/modules/biggan/biggan.tasks.js");
var bigganTasks = _interopRequireWildcard(_biggan);
var _biggan2 = __webpack_require__(/*! ../biggan.actions */ "./app/client/modules/biggan/biggan.actions.js");
var bigganActions = _interopRequireWildcard(_biggan2);
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 ALL_CATEGORIES = 'categories/biggan_all.json';
var BigGANCategoryList = function (_Component) {
_inherits(BigGANCategoryList, _Component);
function BigGANCategoryList(props) {
_classCallCheck(this, BigGANCategoryList);
var _this = _possibleConstructorReturn(this, (BigGANCategoryList.__proto__ || Object.getPrototypeOf(BigGANCategoryList)).call(this, props));
_this.state = {
loading: true,
error: false,
categories: {},
q: "",
fn: ""
};
_this.loadCategories(ALL_CATEGORIES);
return _this;
}
_createClass(BigGANCategoryList, [{
key: 'loadCategories',
value: function loadCategories(fn) {
var _this2 = this;
this.setState({ loading: true, fn: fn });
console.log("fetching", fn);
_actions2.default.socket.read_file({ module: "biggan", fn: fn }).then(function (_ref) {
var name = _ref.name,
buf = _ref.buf;
console.log("fetched", fn);
var categoryJSON = String.fromCharCode.apply(null, new Uint8Array(buf));
var categories = JSON.parse(categoryJSON);
_this2.setState({
categories: categories,
loading: false
});
}).catch(function () {
_this2.setState({ error: true });
});
}
}, {
key: 'setCategory',
value: function setCategory(index) {
_actions2.default.live.send_command('setCategory', String(index));
}
}, {
key: 'updateQuery',
value: function updateQuery(q) {
var _this3 = this;
this.setState({ q: q }, function () {
_this3.categoryRef.scrollTo(0, 0);
});
}
}, {
key: 'render',
value: function render() {
var _this4 = this;
var _state = this.state,
loading = _state.loading,
q = _state.q;
if (loading) {
return (0, _preact.h)(
'div',
{ className: 'categories' },
(0, _preact.h)(_common.Loading, null)
);
}
return (0, _preact.h)(
'div',
null,
(0, _preact.h)(
'div',
{ className: 'search_form' },
(0, _preact.h)('div', { 'class': 'button' }),
(0, _preact.h)('input', {
type: 'text',
className: 'categorySearch',
value: q,
onInput: function onInput(e) {
return _this4.updateQuery(e.target.value);
}
})
),
(0, _preact.h)(
'div',
{ className: 'categories', ref: function ref(_ref2) {
return _this4.categoryRef = _ref2;
} },
this.renderGroup("inanimate"),
this.renderGroup("animate")
)
);
}
}, {
key: 'renderGroup',
value: function renderGroup(groupName) {
var _this5 = this;
var _state2 = this.state,
categories = _state2.categories,
q = _state2.q;
var qRegExp = new RegExp(q || ".*");
var group = categories[groupName];
// console.log(group)
var groups = Object.keys(group).map(function (key) {
var category = group[key];
var categoryGroup = Object.keys(category).map(function (categoryName) {
if (!categoryName.match(qRegExp)) {
return null;
}
return (0, _preact.h)(
'a',
{ key: categoryName, onClick: function onClick() {
return _this5.setCategory(category[categoryName]);
} },
categoryName
);
}).filter(function (g) {
return !!g;
});
return !categoryGroup.length ? null : (0, _preact.h)(
'div',
{ key: key },
(0, _preact.h)(
'h3',
null,
key
),
categoryGroup
);
}).filter(function (g) {
return !!g;
});
if (!groups.length) {
return null;
}
return (0, _preact.h)(
'div',
null,
groupName === "animate" ? (0, _preact.h)(
'h2',
null,
groupName
) : null,
groups
);
}
}]);
return BigGANCategoryList;
}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
return {
opt: state.live.opt,
biggan: state.module.biggan
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
actions: {}
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(BigGANCategoryList);
/***/ }),
/***/ "./app/client/modules/biggan/views/biggan.encodingList.js":
/*!****************************************************************!*\
!*** ./app/client/modules/biggan/views/biggan.encodingList.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 _actions = __webpack_require__(/*! ../../../actions */ "./app/client/actions.js");
var _actions2 = _interopRequireDefault(_actions);
var _biggan = __webpack_require__(/*! ../biggan.tasks */ "./app/client/modules/biggan/biggan.tasks.js");
var bigganTasks = _interopRequireWildcard(_biggan);
var _biggan2 = __webpack_require__(/*! ../biggan.actions */ "./app/client/modules/biggan/biggan.actions.js");
var bigganActions = _interopRequireWildcard(_biggan2);
var _format = __webpack_require__(/*! ../../../util/format */ "./app/client/util/format.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 BigGANEncodingList = function (_Component) {
_inherits(BigGANEncodingList, _Component);
function BigGANEncodingList() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, BigGANEncodingList);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = BigGANEncodingList.__proto__ || Object.getPrototypeOf(BigGANEncodingList)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
file_id: 0
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(BigGANEncodingList, [{
key: 'componentDidMount',
value: function componentDidMount() {
if (!this.props.biggan.encodings) {
this.props.actions.biggan.load_encodings();
}
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var file_id = this.state.file_id;
var _props = this.props,
opt = _props.opt,
frame = _props.frame;
var encodings = this.props.biggan.encodings;
if (!encodings) {
return (0, _preact.h)(
'div',
null,
'Loading encodings...'
);
}
return (0, _preact.h)(
'div',
null,
(0, _preact.h)(
'div',
{ className: 'spacer' },
frame.i ? (0, _preact.h)(
'div',
{ className: 'param frame_counter' },
(0, _preact.h)(
'span',
null,
'Frame #',
frame.i
),
(0, _preact.h)(
'var',
null,
(0, _format.frameTimestamp)(frame.i)
)
) : (0, _preact.h)(
'div',
{ className: 'param frame_counter' },
(0, _preact.h)('span', null)
)
),
(0, _preact.h)(
_common.Group,
{ title: "Stored image" },
(0, _preact.h)(_common.Slider, { live: true,
name: 'encoding_stored_speed',
title: "Load speed",
min: 1, max: 250, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'encoding_stored_n',
title: "Image mix",
min: 0, max: 1, type: 'float'
})
),
(0, _preact.h)(
_common.Group,
{ title: "Latent to Image Transition" },
(0, _preact.h)(
_common.Button,
{
title: "Toggle",
onClick: function onClick() {
return file_id && _actions2.default.live.send_command('switch', 'encoding_stored_mix');
}
},
file_id ? opt.encoding_stored_mix_n < 0.5 ? "To Image" : "Back to Latent" : "Not loaded"
),
(0, _preact.h)(_common.Slider, { live: true,
name: 'encoding_stored_mix_speed',
title: "Transition speed",
min: 1, max: 250, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'encoding_stored_mix_n',
title: "Transition mix",
min: 0, max: 1, type: 'float'
})
),
(0, _preact.h)(
'div',
{ className: 'categories encodings', ref: function ref(_ref2) {
return _this2.categoryRef = _ref2;
} },
Object.keys(encodings).sort().map(function (name) {
return (0, _preact.h)(
'div',
{ key: name },
(0, _preact.h)(
'h3',
null,
name
),
encodings[name].map(function (file) {
return (0, _preact.h)('img', {
key: file.id,
src: file.url,
onClick: function onClick() {
_actions2.default.live.send_command('setEncoding', JSON.stringify({
id: file.id
}));
_this2.setState({ file_id: file.id });
}
});
})
);
})
)
);
}
}]);
return BigGANEncodingList;
}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
return {
last_message: state.live.last_message,
opt: state.live.opt,
frame: state.live.frame,
biggan: state.module.biggan
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
actions: {
biggan: (0, _redux.bindActionCreators)(bigganActions, dispatch),
tasks: (0, _redux.bindActionCreators)(bigganTasks, dispatch)
}
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(BigGANEncodingList);
/***/ }),
/***/ "./app/client/modules/biggan/views/biggan.live.js":
/*!********************************************************!*\
!*** ./app/client/modules/biggan/views/biggan.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 _biggan = __webpack_require__(/*! ../biggan.tasks */ "./app/client/modules/biggan/biggan.tasks.js");
var bigganTasks = _interopRequireWildcard(_biggan);
var _biggan2 = __webpack_require__(/*! ../biggan.actions */ "./app/client/modules/biggan/biggan.actions.js");
var bigganActions = _interopRequireWildcard(_biggan2);
var _bigganCategoryList = __webpack_require__(/*! ./biggan.categoryList.js */ "./app/client/modules/biggan/views/biggan.categoryList.js");
var _bigganCategoryList2 = _interopRequireDefault(_bigganCategoryList);
var _bigganEncodingList = __webpack_require__(/*! ./biggan.encodingList.js */ "./app/client/modules/biggan/views/biggan.encodingList.js");
var _bigganEncodingList2 = _interopRequireDefault(_bigganEncodingList);
var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js");
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 BigGANLive = function (_Component) {
_inherits(BigGANLive, _Component);
function BigGANLive(props) {
_classCallCheck(this, BigGANLive);
var _this = _possibleConstructorReturn(this, (BigGANLive.__proto__ || Object.getPrototypeOf(BigGANLive)).call(this));
props.actions.live.get_params();
return _this;
}
_createClass(BigGANLive, [{
key: 'start',
value: function start() {
// console.log(this.props.opt)
console.log('starting up!');
this.props.actions.tasks.live_task({
// folder_id: this.props.biggan.data.resultsFolder.id,
});
}
}, {
key: 'interrupt',
value: function interrupt() {
this.props.actions.queue.stop_task('gpu');
}
}, {
key: 'render',
value: function render() {
var _props = this.props,
biggan = _props.biggan,
actions = _props.actions,
last_message = _props.last_message;
// console.log(actions)
// if (biggan.loading) {
// return
// }
return (0, _preact.h)(
'div',
{ className: 'app live biggan centered' },
(0, _preact.h)(
'div',
{ className: 'row' },
(0, _preact.h)(
'div',
{ className: 'column' },
(0, _preact.h)(_common.Player, { width: 512, height: 512, square: true, fullscreen: this.props.fullscreen })
),
(0, _preact.h)(
'div',
{ className: 'params column audioParams' },
(0, _preact.h)(
'div',
{ className: 'spacer' },
last_message
),
(0, _preact.h)(
_common.Group,
{ title: 'Player' },
this.renderRestartButton()
),
(0, _preact.h)(
_common.Group,
{ title: "Latent" },
(0, _preact.h)(
_common.Button,
{
title: "Shuffle",
onClick: function onClick() {
return actions.live.send_command('switch', 'latent');
}
},
"Latent"
),
(0, _preact.h)(_common.Slider, { live: true,
name: 'latent_speed',
title: "Update Speed",
min: 1, max: 250, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'truncation',
title: "Truncation",
min: 0.0001, max: 4, type: 'float'
})
),
(0, _preact.h)(
_common.Group,
{ title: "Label" },
(0, _preact.h)(_common.Slider, { live: true,
name: 'num_classes',
title: "Classes to mix",
min: 1, max: 10, type: 'int'
}),
(0, _preact.h)(
_common.Button,
{
title: "Shuffle",
onClick: function onClick() {
return actions.live.send_command('switch', 'label');
}
},
"Label"
),
(0, _preact.h)(_common.Slider, { live: true,
name: 'label_speed',
title: "Mix Speed",
min: 1, max: 250, type: 'int'
})
),
(0, _preact.h)(
_common.Group,
{ title: "Orbit" },
(0, _preact.h)(_common.Slider, { live: true,
name: 'orbit_speed',
title: "Orbit speed",
min: -250, max: 250, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'orbit_radius',
title: "Radius",
min: 0, max: 1.0, type: 'float'
}),
(0, _preact.h)(
_common.Button,
{
title: "Shuffle",
onClick: function onClick() {
return actions.live.send_command('switch', 'orbit_noise');
}
},
"Spin"
),
(0, _preact.h)(_common.Slider, { live: true,
name: 'orbit_noise_speed',
title: "Shuffle Speed",
min: 1, max: 250, type: 'int'
})
),
(0, _preact.h)(
_common.Group,
{ title: "Saturation" },
(0, _preact.h)(_common.Slider, { live: true,
name: 'saturation',
title: "Amount",
min: 0, max: 4, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'saturation_mix_n',
title: "Saturation mix",
min: 0, max: 1, type: 'float'
})
),
(0, _preact.h)(
_common.Group,
{ title: "Scaling" },
(0, _preact.h)(_common.Slider, { live: true,
name: 'zoom',
title: "Zoom",
min: -4.0, max: 4.0, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'Horizontal',
title: "Horizontal",
min: -2.0, max: 2.0, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'Vertical',
title: "Vertical",
min: -2.0, max: 2.0, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'luminance',
title: "Brightness",
min: -2.0, max: 2, type: 'float'
})
)
),
(0, _preact.h)(
'div',
{ className: 'params column' },
(0, _preact.h)(_bigganCategoryList2.default, null)
),
(0, _preact.h)(
'div',
{ className: 'params column' },
(0, _preact.h)(_bigganEncodingList2.default, null)
)
)
);
}
}, {
key: 'renderRestartButton',
value: function renderRestartButton() {
var _this2 = this;
// console.log(this.props.runner.gpu)
var i18n = this.props.i18n;
if (this.props.runner.gpu.status === 'IDLE') {
return (0, _preact.h)(
_common.Button,
{
title: i18n.gpu.idle,
onClick: function onClick() {
return _this2.start();
}
},
i18n.gpu.start
);
}
if (this.props.runner.gpu.task.module !== 'biggan') {
return (0, _preact.h)(
_common.Button,
{
title: i18n.gpu.busy,
onClick: function onClick() {
return _this2.interrupt();
}
},
i18n.gpu.interrupt
);
}
// if (! this.props.opt.processing) {
// return (
//
//
//
//
// )
// }
return (0, _preact.h)(
'div',
null,
(0, _preact.h)(
_common.Button,
{
title: i18n.gpu.busy,
onClick: function onClick() {
return _this2.interrupt();
}
},
i18n.gpu.stop
)
);
}
}]);
return BigGANLive;
}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
return {
fullscreen: state.live.fullscreen,
opt: state.live.opt,
last_message: state.live.last_message,
runner: state.system.runner,
i18n: state.system.i18n.strings,
biggan: state.module.biggan
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
actions: {
live: (0, _redux.bindActionCreators)(liveActions, dispatch),
queue: (0, _redux.bindActionCreators)(queueActions, dispatch),
biggan: (0, _redux.bindActionCreators)(bigganActions, dispatch),
tasks: (0, _redux.bindActionCreators)(bigganTasks, dispatch)
}
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(BigGANLive);
/***/ }),
/***/ "./app/client/modules/biggan/views/biggan.new.js":
/*!*******************************************************!*\
!*** ./app/client/modules/biggan/views/biggan.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 _biggan = __webpack_require__(/*! ../biggan.actions */ "./app/client/modules/biggan/biggan.actions.js");
var bigganActions = _interopRequireWildcard(_biggan);
var _biggan2 = __webpack_require__(/*! ../biggan.module */ "./app/client/modules/biggan/biggan.module.js");
var _biggan3 = _interopRequireDefault(_biggan2);
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 BigGANNew(props) {
return (0, _preact.h)(_common.Views.New, {
db: props.biggan,
path: '/biggan/datasets/',
actions: props.actions,
module: _biggan3.default,
history: props.history
});
}
var mapStateToProps = function mapStateToProps(state) {
return {
biggan: state.module.biggan
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
actions: (0, _redux.bindActionCreators)(bigganActions, dispatch)
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(BigGANNew);
/***/ }),
/***/ "./app/client/modules/biggan/views/biggan.results.js":
/*!***********************************************************!*\
!*** ./app/client/modules/biggan/views/biggan.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 _actions = __webpack_require__(/*! ../../../actions */ "./app/client/actions.js");
var _actions2 = _interopRequireDefault(_actions);
var _biggan = __webpack_require__(/*! ../biggan.actions */ "./app/client/modules/biggan/biggan.actions.js");
var bigganActions = _interopRequireWildcard(_biggan);
var _biggan2 = __webpack_require__(/*! ../biggan.tasks */ "./app/client/modules/biggan/biggan.tasks.js");
var bigganTasks = _interopRequireWildcard(_biggan2);
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 yes_count = 0;
var BigGANResults = function (_Component) {
_inherits(BigGANResults, _Component);
function BigGANResults(props) {
_classCallCheck(this, BigGANResults);
var _this = _possibleConstructorReturn(this, (BigGANResults.__proto__ || Object.getPrototypeOf(BigGANResults)).call(this));
if (!props.biggan.results) props.actions.load_results();
return _this;
}
_createClass(BigGANResults, [{
key: 'componentDidMount',
value: function componentDidMount() {
yes_count = 0;
}
}, {
key: 'render',
value: function render() {
if (!this.props.biggan.results) return (0, _preact.h)(_loading2.default, { progress: this.props.biggan.progress });
var _props$biggan$results = this.props.biggan.results,
resultsFolder = _props$biggan$results.resultsFolder,
results = _props$biggan$results.results,
renders = _props$biggan$results.renders,
files = _props$biggan$results.files;
// console.log(resultsFolder, results)
return (0, _preact.h)(
'div',
{ className: 'app biggan' },
(0, _preact.h)(
'div',
{ className: 'heading row middle' },
(0, _preact.h)(
'h1',
null,
'BigGAN Results'
)
),
(0, _preact.h)(
'div',
{ 'class': 'rows params renders' },
(0, _preact.h)(_fileList.FileList, {
linkFiles: true,
files: files,
orderBy: 'date desc',
fields: 'name date size delete',
onDelete: function onDelete(file) {
var yes = void 0;
if (yes_count < 3) {
yes = confirm('Are you sure you want to delete this file?');
} else {
yes = true;
}
if (yes) {
yes_count += 1;
console.log('delete: confirmed');
_actions2.default.file.destroy(file);
}
}
})
)
);
}
}, {
key: 'handlePick',
value: function handlePick(file) {
// this.props.audioPlayer.play(file)
}
}]);
return BigGANResults;
}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
return {
biggan: state.module.biggan
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
actions: (0, _redux.bindActionCreators)(bigganActions, dispatch),
remote: (0, _redux.bindActionCreators)(bigganTasks, dispatch)
// audioPlayer: bindActionCreators(audioPlayerActions, dispatch),
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(BigGANResults);
/***/ }),
/***/ "./app/client/modules/biggan/views/biggan.show.js":
/*!********************************************************!*\
!*** ./app/client/modules/biggan/views/biggan.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 _biggan = __webpack_require__(/*! ../biggan.actions */ "./app/client/modules/biggan/biggan.actions.js");
var bigganActions = _interopRequireWildcard(_biggan);
var _biggan2 = __webpack_require__(/*! ../biggan.tasks */ "./app/client/modules/biggan/biggan.tasks.js");
var bigganTasks = _interopRequireWildcard(_biggan2);
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 _biggan3 = __webpack_require__(/*! ../biggan.module */ "./app/client/modules/biggan/biggan.module.js");
var _biggan4 = _interopRequireDefault(_biggan3);
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 BigGANShow = function (_Component) {
_inherits(BigGANShow, _Component);
function BigGANShow(props) {
_classCallCheck(this, BigGANShow);
var _this = _possibleConstructorReturn(this, (BigGANShow.__proto__ || Object.getPrototypeOf(BigGANShow)).call(this, props));
_this.datasetActions = _this.datasetActions.bind(_this);
return _this;
}
_createClass(BigGANShow, [{
key: 'componentWillMount',
value: function componentWillMount() {
var id = this.props.match.params.id || localStorage.getItem('biggan.last_id');
console.log('load dataset:', id);
var _props = this.props,
match = _props.match,
biggan = _props.biggan,
actions = _props.actions;
if (id === 'new') return;
if (id) {
if (parseInt(id)) localStorage.setItem('biggan.last_id', id);
if (!biggan.folder || biggan.folder.id !== id) {
actions.load_directories(id);
}
} else {
this.props.history.push('/biggan/new/');
}
}
}, {
key: 'render',
value: function render() {
var _props2 = this.props,
biggan = _props2.biggan,
match = _props2.match,
history = _props2.history,
actions = _props2.actions,
tasks = _props2.tasks;
var _ref = biggan.data || {},
folderLookup = _ref.folderLookup;
var folder = (folderLookup || {})[biggan.folder_id] || {};
return (0, _preact.h)(
'div',
{ className: 'app biggan' },
(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)(
'button',
{ onClick: function onClick() {
return tasks.invert_task(folder.id);
} },
'Run inversion task'
)
)
),
(0, _preact.h)(
'div',
{ className: 'row' },
folder && folder.name && folder.name !== 'unsorted' && (0, _preact.h)(_dataset2.default, {
title: 'Add Files',
module: _biggan4.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: biggan.loading,
progress: biggan.progress,
id: biggan.folder_id,
module: _biggan4.default,
data: biggan.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,
biggan = _props3.biggan,
remote = _props3.remote;
var input = biggan.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' }),
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 BigGANShow;
}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
return {
biggan: state.module.biggan
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
actions: (0, _redux.bindActionCreators)(bigganActions, dispatch),
tasks: (0, _redux.bindActionCreators)(bigganTasks, dispatch),
remote: (0, _redux.bindActionCreators)(bigganTasks, dispatch)
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(BigGANShow);
/***/ }),
/***/ "./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 _biggan = __webpack_require__(/*! ./biggan */ "./app/client/modules/biggan/index.js");
var _biggan2 = _interopRequireDefault(_biggan);
var _morph = __webpack_require__(/*! ./morph */ "./app/client/modules/morph/index.js");
var _morph2 = _interopRequireDefault(_morph);
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 = {
biggan: _biggan2.default, morph: _morph2.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 _biggan = __webpack_require__(/*! ./biggan/biggan.reducer */ "./app/client/modules/biggan/biggan.reducer.js");
var _biggan2 = _interopRequireDefault(_biggan);
var _morph = __webpack_require__(/*! ./morph/morph.reducer */ "./app/client/modules/morph/morph.reducer.js");
var _morph2 = _interopRequireDefault(_morph);
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)({
biggan: _biggan2.default,
morph: _morph2.default,
pix2pix: _pix2pix2.default,
pix2pixhd: _pix2pixhd2.default,
pix2wav: _pix2wav2.default,
samplernn: _samplernn2.default
});
/***/ }),
/***/ "./app/client/modules/morph/index.js":
/*!*******************************************!*\
!*** ./app/client/modules/morph/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 _morph = __webpack_require__(/*! ./views/morph.app */ "./app/client/modules/morph/views/morph.app.js");
var _morph2 = _interopRequireDefault(_morph);
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('morph');
document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #def, #dfe)';
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps() {
_actions2.default.system.changeTool('morph');
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: '/morph/app/', component: _morph2.default })
);
}
}]);
return router;
}();
function links() {
return [{ url: '/morph/app/', name: 'morph' }];
}
exports.default = {
name: 'morph',
router: router, links: links
};
/***/ }),
/***/ "./app/client/modules/morph/morph.actions.js":
/*!***************************************************!*\
!*** ./app/client/modules/morph/morph.actions.js ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.load_data = 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 _morph = __webpack_require__(/*! ./morph.module */ "./app/client/modules/morph/morph.module.js");
var _morph2 = _interopRequireDefault(_morph);
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_data = exports.load_data = function load_data(id) {
return function (dispatch) {
var module = _morph2.default.name;
_util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_sequences({ module: 'pix2pixhd', dir: 'sequences' }), _actions2.default.socket.list_directory({ module: module, dir: 'renders' })], function (percent, i, n) {
console.log('morph load progress', i, n);
dispatch({
type: _types2.default.app.load_progress,
progress: { i: i, n: n },
data: { module: 'morph' }
});
}).then(function (res) {
var _res = _slicedToArray(res, 3),
datasetApiReport = _res[0],
sequences = _res[1],
renders = _res[2];
var folderLookup = datasetApiReport.folderLookup,
fileLookup = datasetApiReport.fileLookup,
datasetLookup = datasetApiReport.datasetLookup,
folders = datasetApiReport.folders,
files = datasetApiReport.files,
unsortedFolder = datasetApiReport.unsortedFolder,
resultsFolder = datasetApiReport.resultsFolder;
dispatch({
type: _types2.default.morph.load,
data: datasetApiReport,
app: {
resultsFolder: resultsFolder,
files: files,
sequences: sequences,
renders: renders
}
});
});
};
};
/***/ }),
/***/ "./app/client/modules/morph/morph.module.js":
/*!**************************************************!*\
!*** ./app/client/modules/morph/morph.module.js ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var morphModule = {
name: 'morph',
displayName: 'Morph',
datatype: 'video'
};
exports.default = morphModule;
/***/ }),
/***/ "./app/client/modules/morph/morph.reducer.js":
/*!***************************************************!*\
!*** ./app/client/modules/morph/morph.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 morphInitialState = {
loading: true,
progress: { i: 0, n: 0 },
error: null,
folder_id: 0,
data: null,
app: null
};
var morphReducer = function morphReducer() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : morphInitialState;
var action = arguments[1];
if (action.data && action.data.module === 'morph') {
state = (0, _dataset2.default)(state, action);
}
switch (action.type) {
case _types2.default.morph.load:
console.log('morph load', action.app);
return _extends({}, state, {
app: action.app,
loading: false,
data: action.data
});
case _types2.default.file.create:
console.log(action);
if (action.data.module !== 'morph') return state;
return _extends({}, state, {
app: state.app && _extends({}, state.app, {
files: [action.data].concat(state.app.files)
})
});
default:
return state;
}
};
exports.default = morphReducer;
/***/ }),
/***/ "./app/client/modules/morph/morph.tasks.js":
/*!*************************************************!*\
!*** ./app/client/modules/morph/morph.tasks.js ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.morph_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 _morph = __webpack_require__(/*! ./morph.module */ "./app/client/modules/morph/morph.module.js");
var _morph2 = _interopRequireDefault(_morph);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var morph_task = exports.morph_task = function morph_task(state, folder) {
return function (dispatch) {
if (state.a === 'PLACEHOLDER' || state.b === 'PLACEHOLDER') return;
var task = {
module: _morph2.default.name,
activity: 'morph',
dataset: state.a,
folder_id: folder.id,
opt: state
};
return _actions2.default.queue.add_task(task);
};
};
/***/ }),
/***/ "./app/client/modules/morph/views/morph.app.js":
/*!*****************************************************!*\
!*** ./app/client/modules/morph/views/morph.app.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 _actions = __webpack_require__(/*! ../../../actions */ "./app/client/actions.js");
var _actions2 = _interopRequireDefault(_actions);
var _morph = __webpack_require__(/*! ../morph.actions */ "./app/client/modules/morph/morph.actions.js");
var morphActions = _interopRequireWildcard(_morph);
var _morph2 = __webpack_require__(/*! ../morph.tasks */ "./app/client/modules/morph/morph.tasks.js");
var morphTasks = _interopRequireWildcard(_morph2);
var _loading = __webpack_require__(/*! ../../../common/loading.component */ "./app/client/common/loading.component.js");
var _loading2 = _interopRequireDefault(_loading);
var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/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 }; }
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 yes_count = 0;
var MorphResults = function (_Component) {
_inherits(MorphResults, _Component);
function MorphResults(props) {
_classCallCheck(this, MorphResults);
var _this = _possibleConstructorReturn(this, (MorphResults.__proto__ || Object.getPrototypeOf(MorphResults)).call(this));
_this.state = {
dataset_module: 'pix2pixhd',
a: "PLACEHOLDER",
b: "PLACEHOLDER",
a_offset: 0,
a_duration: 1,
a_pos: 0,
b_offset: 0,
b_duration: 1,
b_pos: 0,
steps: 16,
dilate: 2,
frames: 32,
padding: 3,
smooth: true,
mode: 'mix'
};
if (!props.morph.data) props.actions.load_data();
return _this;
}
_createClass(MorphResults, [{
key: 'componentDidMount',
value: function componentDidMount() {
yes_count = 0;
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
if (!this.props.morph.app) return (0, _preact.h)(_loading2.default, { progress: this.props.morph.progress });
var _props$morph$app = this.props.morph.app,
resultsFolder = _props$morph$app.resultsFolder,
sequences = _props$morph$app.sequences,
renders = _props$morph$app.renders,
files = _props$morph$app.files;
var sequence_options = sequences.map(function (sequence) {
return [sequence.name.split("_").slice(0, 3).join(" ") + "~ (" + sequence.count + ")", sequence.name];
});
var sequenceLookup = sequences.reduce(function (a, b) {
return a[b.name] = b, a;
}, {});
var totalLength = this.state.frames / 25;
var lengthWarning = void 0;
if (this.state.steps / this.state.dilate > 64 && this.state.mode === 'mix') {
lengthWarning = (0, _preact.h)(
'span',
null,
(0, _preact.h)('br', null),
'warning, this will take a while'
);
}
return (0, _preact.h)(
'div',
{ className: 'app morph' },
(0, _preact.h)(
'div',
{ className: 'heading row middle' },
(0, _preact.h)(
'h1',
null,
'Morph'
)
),
(0, _preact.h)(
'div',
{ className: 'rows params renders' },
(0, _preact.h)(
'div',
{ className: 'column' },
(0, _preact.h)(
_common.Group,
{ title: 'From' },
(0, _preact.h)(_common.Select, {
title: 'Starting sequence',
placeholder: 'Please choose a video',
value: this.state.a,
options: sequence_options,
onChange: function onChange(name, key) {
return _this2.setState({ a: key, a_duration: sequenceLookup[key].count, a_pos: 0, a_offset: 0 });
}
}),
(0, _preact.h)(_common.Slider, {
title: 'Offset',
value: this.state.a_pos,
min: 0, max: 1, step: 0.01,
onChange: function onChange(key) {
return _this2.setState({ a_pos: key, a_offset: Math.floor(key * (_this2.state.a_duration - _this2.state.frames)) });
}
})
),
(0, _preact.h)(
_common.Group,
{ title: 'To' },
(0, _preact.h)(_common.Select, {
title: 'Ending sequence',
placeholder: 'Please choose a video',
value: this.state.b,
options: sequence_options,
onChange: function onChange(name, key) {
return _this2.setState({ b: key, b_duration: sequenceLookup[key].count, b_pos: 0, b_offset: 0 });
}
}),
(0, _preact.h)(_common.Slider, {
title: 'Offset',
value: this.state.b_pos,
min: 0, max: 1, step: 0.01,
onChange: function onChange(key) {
return _this2.setState({ b_pos: key, b_offset: Math.floor(key * (_this2.state.b_duration - _this2.state.frames)) });
}
})
),
(0, _preact.h)(
_common.Group,
{ title: 'Morph Settings' },
(0, _preact.h)(_common.Select, {
title: "Mode",
value: this.state.mode,
options: ['mix', 'average', 'mix_images'],
onChange: function onChange(name, key) {
return _this2.setState({ mode: key });
}
}),
(0, _preact.h)(_common.Slider, {
type: 'list',
title: 'Steps',
value: this.state.steps,
options: [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],
onChange: function onChange(key) {
return _this2.setState({ steps: key, frames: key * _this2.state.dilate });
}
}),
(0, _preact.h)(_common.Slider, {
type: 'list',
title: 'Dilate',
value: this.state.dilate,
options: [1, 2, 4, 8, 16, 32],
onChange: function onChange(key) {
return _this2.setState({ dilate: key, frames: _this2.state.steps * key });
}
}),
(0, _preact.h)(_common.Checkbox, {
title: 'Smooth',
value: this.state.smooth,
onToggle: function onToggle(key) {
return _this2.setState({ smooth: key });
}
}),
(0, _preact.h)(_common.Slider, {
type: 'int',
title: 'Padding (in seconds)',
value: this.state.padding,
min: 0, max: 30, step: 1,
onChange: function onChange(key) {
return _this2.setState({ padding: key });
}
}),
(0, _preact.h)(_common.Button, {
title: 'Run task',
value: 'Morph!',
onClick: function onClick() {
return _this2.props.remote.morph_task(_this2.state, resultsFolder);
}
}),
(0, _preact.h)('br', null),
(0, _preact.h)(
_common.Param,
{ title: 'Total length' },
totalLength.toFixed(1) + " seconds"
),
(0, _preact.h)(
_common.Param,
{ title: 'Total frames' },
this.state.frames + " frames"
),
lengthWarning,
(0, _preact.h)('br', null),
(0, _preact.h)(_common.CurrentTask, null)
)
),
(0, _preact.h)(
'h3',
null,
'morphed videos'
),
(0, _preact.h)(_common.FileList, {
linkFiles: true,
files: files,
orderBy: 'date desc',
fields: 'name datetime size delete',
onDelete: function onDelete(file) {
var yes = void 0;
if (yes_count < 3) {
yes = confirm('Are you sure you want to delete this file?');
} else {
yes = true;
}
if (yes) {
yes_count += 1;
console.log('delete: confirmed');
_actions2.default.file.destroy(file);
}
}
}),
(0, _preact.h)('br', null),
(0, _preact.h)(
'h3',
null,
'renders on server'
),
(0, _preact.h)(_common.FileList, {
files: renders,
orderBy: 'date desc',
fields: 'name datetime time size',
onClick: function onClick(file, e) {
e.preventDefault();
e.stopPropagation();
console.log('picked a result', file);
_this2.handlePick(file);
}
})
)
);
}
}, {
key: 'handlePick',
value: function handlePick(file) {
// this.props.audioPlayer.play(file)
}
}]);
return MorphResults;
}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
return {
morph: state.module.morph
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
actions: (0, _redux.bindActionCreators)(morphActions, dispatch),
remote: (0, _redux.bindActionCreators)(morphTasks, dispatch)
// audioPlayer: bindActionCreators(audioPlayerActions, dispatch),
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(MorphResults);
/***/ }),
/***/ "./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
}
});
}).catch(function (e) {
console.error(e);
});
if (id) {
console.log('folder id', id);
dispatch({
type: _types2.default.dataset.set_folder,
data: {
folder_id: id,
module: module
}
});
}
};
};
/***/ }),
/***/ "./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',
{ className: '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
},
'Stop'
),
(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',
{ className: 'heading' },
(0, _preact.h)(
'div',
{ className: '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',
{ className: 'actions' },
(0, _preact.h)(
'span',
{ className: 'link', onClick: function onClick() {
return remote.train_task(dataset, pix2pix.folder_id, 1);
} },
'train'
),
(0, _preact.h)(
'span',
{ className: 'link', onClick: function onClick() {
return remote.train_task(dataset, pix2pix.folder_id, 5);
} },
'5x'
),
(0, _preact.h)(
'span',
{ className: 'link', onClick: function onClick() {
return remote.train_task(dataset, pix2pix.folder_id, 10);
} },
'10x'
),
(0, _preact.h)(
'span',
{ className: 'link', onClick: function onClick() {
return remote.train_task(dataset, pix2pix.folder_id, 20);
} },
'20x'
),
(0, _preact.h)(
'span',
{ className: 'link', onClick: function onClick() {
return remote.train_task(dataset, pix2pix.folder_id, 50);
} },
'50x'
)
),
dataset.isBuilt ? (0, _preact.h)(
'div',
{ className: 'subtext' },
'fetched ',
(0, _preact.h)(
'span',
{ className: 'link', onClick: function onClick() {
return remote.clear_cache_task(dataset);
} },
'rm'
)
) : isFetching ? (0, _preact.h)(
'div',
{ className: 'subtext' },
'fetching'
) : (0, _preact.h)(
'div',
{ className: 'subtext' },
(0, _preact.h)(
'span',
{ className: '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.uprez */ "./app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js");
var _pix2pixhd8 = _interopRequireDefault(_pix2pixhd7);
var _pix2pixhd9 = __webpack_require__(/*! ./views/pix2pixhd.train */ "./app/client/modules/pix2pixhd/views/pix2pixhd.train.js");
var _pix2pixhd10 = _interopRequireDefault(_pix2pixhd9);
var _pix2pixhd11 = __webpack_require__(/*! ./views/pix2pixhd.live */ "./app/client/modules/pix2pixhd/views/pix2pixhd.live.js");
var _pix2pixhd12 = _interopRequireDefault(_pix2pixhd11);
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/train/', component: _pix2pixhd10.default }),
(0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pixhd/results/', component: _pix2pixhd6.default }),
(0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pixhd/uprez/', component: _pix2pixhd8.default }),
(0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2pixhd/live/', component: _pix2pixhd12.default })
);
}
}]);
return router;
}();
function links() {
return [{ url: '/pix2pixhd/new/', name: 'folders' }, { url: '/pix2pixhd/sequences/', name: 'sequences' }, { url: '/pix2pixhd/train/', name: 'checkpoints' }, { url: '/pix2pixhd/results/', name: 'results' }, { url: '/pix2pixhd/uprez/', name: 'uprez' }, { 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.count_dataset = exports.list_epochs = exports.load_uprez = exports.load_results = 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 },
data: { module: 'pix2pixhd' }
});
}).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,
resultsFolder = datasetApiReport.resultsFolder;
// 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,
resultsFolder: resultsFolder
}
});
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);
});
if (id) {
console.log('folder id', id);
dispatch({
type: _types2.default.dataset.set_folder,
data: {
folder_id: id,
module: module
}
});
}
};
};
var load_results = exports.load_results = function load_results(id) {
return function (dispatch) {
var module = _pix2pixhd2.default.name;
_util2.default.allProgress([_actions2.default.folder.index({ module: module, name: 'results' }), _actions2.default.file.index({ module: module, generated: 1, limit: 250 }), _actions2.default.socket.list_directory({ module: module, dir: 'renders' }), _actions2.default.socket.list_sequences({ module: module, dir: 'results' })], function (percent, i, n) {
console.log('pix2pixhd load progress', i, n);
dispatch({
type: _types2.default.app.load_progress,
progress: { i: i, n: n },
data: { module: 'pix2pixhd' }
});
}).then(function (res) {
var _res2 = _slicedToArray(res, 4),
folders = _res2[0],
files = _res2[1],
renders = _res2[2],
results = _res2[3]; //, datasets, results, output, datasetUsage, lossReport] = res
// console.log(files, results, renders)
dispatch({
type: _types2.default.pix2pixhd.load_results,
results: {
resultsFolder: folders[0],
files: files,
renders: renders,
results: results
}
});
});
};
};
var load_uprez = exports.load_uprez = function load_uprez(id) {
return function (dispatch) {
var module = _pix2pixhd2.default.name;
_util2.default.allProgress([_actions2.default.folder.index({ module: module, name: 'results' }), _actions2.default.socket.list_sequences({ module: module, dir: 'results' }), _actions2.default.file.index({ module: module, activity: 'uprez' })], function (percent, i, n) {
console.log('pix2pixhd load progress', i, n);
dispatch({
type: _types2.default.app.load_progress,
progress: { i: i, n: n },
data: { module: 'pix2pixhd' }
});
}).then(function (res) {
var _res3 = _slicedToArray(res, 3),
folders = _res3[0],
results = _res3[1],
files = _res3[2]; //, datasets, results, output, datasetUsage, lossReport] = res
// console.log(files, results, renders)
dispatch({
type: _types2.default.pix2pixhd.load_uprez,
uprez: {
resultsFolder: folders[0],
results: results,
files: files
}
});
});
};
};
var G_NET_REGEXP = new RegExp('_net_G.pth$');
var list_epochs = exports.list_epochs = function list_epochs(checkpoint_name) {
return function (dispatch) {
var module = _pix2pixhd2.default.name;
_actions2.default.socket.list_directory({ module: module, dir: 'checkpoints/' + checkpoint_name }).then(function (files) {
// console.log(files)
var epochs = files.map(function (f) {
if (!f.name.match(G_NET_REGEXP)) return null;
return f.name.replace(G_NET_REGEXP, '');
}).filter(function (f) {
return !!f;
});
// console.log(epochs)
dispatch({
type: _types2.default.dataset.list_epochs,
data: {
epochs: epochs,
module: module
}
});
});
};
};
var count_dataset = exports.count_dataset = function count_dataset(dataset) {
return function (dispatch) {
var module = _pix2pixhd2.default.name;
_util2.default.allProgress([_actions2.default.socket.list_directory({ module: module, dir: 'sequences/' + dataset + '/' }), _actions2.default.socket.count_directory({ module: module, dir: 'datasets/' + dataset + '/train_A/' })], function (percent, i, n) {
console.log('pix2pixhd load progress', i, n);
// dispatch({
// type: types.app.load_progress,
// progress: { i, n },
// data: { module: 'pix2pixhd' },
// })
}).then(function (res) {
var _res4 = _slicedToArray(res, 2),
sequence = _res4[0],
datasetCount = _res4[1]; //, datasets, results, output, datasetUsage, lossReport] = res
var sequenceCount = sequence.length;
console.log(sequenceCount, datasetCount);
dispatch({
type: _types2.default.pix2pixhd.load_dataset_count,
data: {
name: dataset,
sequence: sequence,
sequenceCount: sequenceCount,
datasetCount: datasetCount
}
});
});
};
};
/***/ }),
/***/ "./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 _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 pix2pixhdInitialState = {
loading: true,
progress: { i: 0, n: 0 },
error: null,
folder_id: 0,
data: null,
results: null,
checkpoint: {
name: '',
sequenceCount: 0,
datasetCount: 0
}
};
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) {
case _types2.default.pix2pixhd.load_results:
return _extends({}, state, {
results: action.results
});
case _types2.default.pix2pixhd.load_uprez:
return _extends({}, state, {
uprez: action.uprez
});
case _types2.default.pix2pixhd.load_dataset_count:
return _extends({}, state, {
checkpoint: action.data
});
case _types2.default.file.destroy:
console.log('file destroy', state.results);
return _extends({}, state, {
results: _extends({}, state.results, {
files: state.results.files.filter(function (f) {
return f.id !== action.data.id;
})
})
});
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.uprez_task = exports.splice_task = exports.augment_task = exports.live_task = exports.train_task = exports.fetch_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 _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) {
dataset = dataset.name || dataset;
if (dataset === 'PLACEHOLDER') return;
var task = {
module: _pix2pixhd2.default.name,
activity: 'train',
dataset: dataset,
epoch: 0,
epochs: epochs,
opt: {
folder_id: folder_id
}
};
if (!task.dataset) {
console.error("train task: no dataset specified");
return;
}
console.log(task);
return _actions2.default.queue.add_task(task);
};
};
var live_task = exports.live_task = function live_task(sequence, checkpoint, opt) {
return function (dispatch) {
var task = {
module: _pix2pixhd2.default.name,
activity: 'live',
dataset: sequence,
checkpoint: checkpoint,
opt: _extends({}, opt, {
poll_delay: 0.01
})
};
console.log(task);
console.log('add live task');
return _actions2.default.queue.add_task(task);
};
};
var augment_task = exports.augment_task = function augment_task(dataset, opt) {
return function (dispatch) {
if (dataset === 'PLACEHOLDER') return;
var task = {
module: _pix2pixhd2.default.name,
activity: 'augment',
dataset: dataset,
folder_id: opt.folder_id,
opt: _extends({}, opt)
};
console.log(task);
console.log('add augment task');
return _actions2.default.queue.add_task(task);
};
};
var splice_task = exports.splice_task = function splice_task(opt) {
return function (dispatch) {
var task = {
module: _pix2pixhd2.default.name,
activity: 'splice',
dataset: opt.title,
folder_id: opt.folder_id,
epochs: 1,
opt: _extends({}, opt)
};
console.log(task);
console.log('add splice task');
return _actions2.default.queue.add_task(task);
};
};
var uprez_task = exports.uprez_task = function uprez_task(opt) {
return function (dispatch) {
var task = {
module: _pix2pixhd2.default.name,
activity: 'uprez',
dataset: opt.dataset,
folder_id: opt.folder_id,
opt: _extends({}, opt)
};
console.log(task);
console.log('add uprez 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);
var _i18n = __webpack_require__(/*! ../../../i18n */ "./app/client/i18n/index.js");
var _i18n2 = _interopRequireDefault(_i18n);
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 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);
_this.handleKeydown = _this.handleKeydown.bind(_this);
return _this;
}
_createClass(Pix2PixHDLive, [{
key: 'componentWillMount',
value: function componentWillMount() {
document.addEventListener('keydown', this.handleKeydown);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
document.removeEventListener('keydown', this.handleKeydown);
}
}, {
key: 'componentWillUpdate',
value: function componentWillUpdate(nextProps) {
if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) {
console.log('listing epochs');
this.props.actions.live.list_epochs('pix2pixhd', nextProps.opt.checkpoint_name);
}
}
}, {
key: 'handleKeydown',
value: function handleKeydown(e) {
console.log(e.keyCode);
if (e.altKey || e.ctrlKey || e.metaKey) return;
switch (e.keyCode) {
case 27:
// esc
e.preventDefault();
this.props.actions.live.set_fullscreen(!this.props.fullscreen);
break;
default:
break;
}
}
}, {
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.opt);
var sequence = this.props.opt.sequence_name || this.props.pix2pixhd.data.sequences[0].name;
var checkpoint = this.props.opt.checkpoint_name || this.props.pix2pixhd.data.checkpoints[0].name;
console.log('starting up!', sequence, checkpoint);
this.props.actions.tasks.live_task(sequence, checkpoint, {
folder_id: this.props.pix2pixhd.data.resultsFolder.id
});
}
}, {
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)
var _props = this.props,
pix2pixhd = _props.pix2pixhd,
i18n = _props.i18n;
if (pix2pixhd.loading) {
return (0, _preact.h)(_common.Loading, { progress: pix2pixhd.progress });
}
var _pix2pixhd$data = pix2pixhd.data,
folderLookup = _pix2pixhd$data.folderLookup,
datasetLookup = _pix2pixhd$data.datasetLookup,
sequences = _pix2pixhd$data.sequences;
var sequenceLookup = sequences.reduce(function (a, b) {
a[b.name] = true;
return a;
}, {});
var sequenceGroups = Object.keys(folderLookup).map(function (id) {
var folder = folderLookup[id];
if (folder.name === 'results') return;
var datasets = folder.datasets.map(function (name) {
var sequence = sequenceLookup[name];
if (sequence) {
return name;
}
return null;
}).filter(function (n) {
return !!n;
});
return {
name: folder.name,
options: datasets.sort()
};
}).filter(function (n) {
return !!n && !!n.options.length;
}).sort(function (a, b) {
return a.name.localeCompare(b.name);
});
var checkpointGroups = Object.keys(folderLookup).map(function (id) {
var folder = folderLookup[id];
if (folder.name === 'results') return;
var datasets = folder.datasets.map(function (name) {
var dataset = datasetLookup[name];
if (dataset.checkpoints.length) {
return name;
}
return null;
}).filter(function (n) {
return !!n;
});
return {
name: folder.name,
options: datasets.sort()
};
}).filter(function (n) {
return !!n && !!n.options.length;
}).sort(function (a, b) {
return a.name.localeCompare(b.name);
});
return (0, _preact.h)(
'div',
{ className: 'app live centered' },
(0, _preact.h)(_common.Player, { width: 424, height: 256, fullscreen: this.props.fullscreen }),
(0, _preact.h)(
'div',
{ className: 'params row' },
(0, _preact.h)(
'div',
{ className: 'column' },
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.network.title,
noToggle: true
},
(0, _preact.h)(_common.Select, { live: true,
name: 'send_image',
title: i18n.pix2pixhd.live.network.view_mode,
options: ['a', 'b', 'sequence', 'recursive'],
onChange: this.props.actions.live.set_param
}),
(0, _preact.h)(_common.SelectGroup, { live: true,
name: 'sequence_name',
title: i18n.pix2pixhd.live.network.sequence,
options: sequenceGroups,
onChange: this.changeSequence
}),
(0, _preact.h)(_common.SelectGroup, { live: true,
name: 'checkpoint_name',
title: i18n.pix2pixhd.live.network.checkpoint,
options: checkpointGroups,
onChange: this.changeCheckpoint
}),
(0, _preact.h)(_common.Select, { live: true,
name: 'epoch',
title: i18n.pix2pixhd.live.network.epoch,
options: this.props.epochs,
onChange: this.changeEpoch
})
),
(0, _preact.h)(
'div',
null,
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.playback.title,
name: 'sequence_playing'
},
(0, _preact.h)(_common.Slider, {
name: i18n.pix2pixhd.live.playback.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,
title: i18n.pix2pixhd.live.playback.playback_rate,
name: 'sequence_step',
min: -4.0, max: 4.0, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.playback.skip_frames,
name: 'sequence_skip',
min: 0, max: 1000, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.playback.fade_sequence,
name: 'fade_sequence',
min: 0, max: 4.0, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.playback.frame_delay,
name: 'frame_delay',
min: 0.0, max: 2.0, type: 'float'
})
)
),
(0, _preact.h)(
_common.Group,
null,
this.renderRestartButton(),
this.renderLiveButtons(),
this.renderRecordButton(),
(0, _preact.h)(
'p',
{ 'class': 'last_message' },
this.props.last_message
)
)
),
(0, _preact.h)(
'div',
{ className: 'column' },
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.transition.title,
name: 'transition'
},
(0, _preact.h)(_common.Slider, { live: true,
name: 'transition_period',
title: i18n.pix2pixhd.live.transition.period,
min: 10, max: 5000, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'transition_min',
title: i18n.pix2pixhd.live.transition.min,
min: 0.001, max: 0.2, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
name: 'transition_max',
title: i18n.pix2pixhd.live.transition.max,
min: 0.1, max: 1.0, type: 'float'
})
),
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.recursion.title,
name: 'recursive'
},
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.recursion.frac,
name: 'recursive_frac',
min: 0.0, max: 0.5, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.recursion.roll,
name: 'recurse_roll',
min: -64, max: 64, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.recursion.axis,
name: 'recurse_roll_axis',
min: 0, max: 1, type: 'int'
})
),
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.sequence.title,
name: 'sequence'
},
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.sequence.frac,
name: 'sequence_frac',
min: 0.0, max: 1.0, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.sequence.process_frac,
name: 'process_frac',
min: 0, max: 1, type: 'float'
})
),
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.transform.title,
name: 'transform'
},
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.transform.rotate,
name: 'rotate',
min: -1, max: 1, type: 'float'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.transform.scale,
name: 'scale',
min: 0.9, max: 1.1, type: 'float'
})
)
),
(0, _preact.h)(
'div',
{ className: 'column' },
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.clahe.title,
name: 'clahe'
},
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.clahe.clip_limit,
name: 'clip_limit',
min: 1.0, max: 4.0, type: 'float'
})
),
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.posterize.title,
name: 'posterize'
},
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.posterize.spatial_window,
name: 'spatial_window',
min: 2, max: 128, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.posterize.color_window,
name: 'color_window',
min: 2, max: 128, type: 'int'
})
),
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.blur.title,
name: 'blur'
},
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.blur.radius,
name: 'blur_radius',
min: 3, max: 7, type: 'odd'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.blur.sigma,
name: 'blur_sigma',
min: 0, max: 2, type: 'float'
})
),
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.canny.title,
name: 'canny'
},
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.canny.lo,
name: 'canny_lo',
min: 10, max: 200, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.canny.hi,
name: 'canny_hi',
min: 10, max: 200, type: 'int'
})
),
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.hsl.title,
name: 'hsl'
},
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.hsl.hue,
name: 'hue',
min: -127, max: 127, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.hsl.saturation,
name: 'saturation',
min: -255, max: 255, type: 'int'
}),
(0, _preact.h)(_common.Slider, { live: true,
title: i18n.pix2pixhd.live.hsl.luminosity,
name: 'luminosity',
min: -255, max: 255, type: 'int'
})
)
)
)
);
}
}, {
key: 'renderRestartButton',
value: function renderRestartButton() {
var _this2 = this;
// console.log(this.props.runner.gpu)
var i18n = this.props.i18n;
if (this.props.runner.gpu.status === 'IDLE') {
return (0, _preact.h)(
_common.Button,
{
title: i18n.gpu.idle,
onClick: function onClick() {
return _this2.start();
}
},
i18n.gpu.start
);
}
if (this.props.runner.gpu.task.module !== 'pix2pixhd') {
return (0, _preact.h)(
_common.Button,
{
title: i18n.gpu.busy,
onClick: function onClick() {
return _this2.interrupt();
}
},
i18n.gpu.interrupt
);
}
if (!this.props.opt.processing) {
return (0, _preact.h)(
'div',
null,
(0, _preact.h)(
_common.Button,
{
title: i18n.gpu.not_processing,
onClick: this.togglePlaying
},
i18n.gpu.restart
),
(0, _preact.h)(
_common.Button,
{
title: i18n.gpu.busy,
onClick: function onClick() {
return _this2.interrupt();
}
},
i18n.gpu.interrupt
)
);
}
return (0, _preact.h)(
'div',
null,
(0, _preact.h)(
_common.Button,
{
title: i18n.gpu.processing,
onClick: this.togglePlaying
},
i18n.gpu.stop
),
(0, _preact.h)(
_common.Button,
{
title: i18n.gpu.busy,
onClick: function onClick() {
return _this2.interrupt();
}
},
i18n.gpu.interrupt
)
);
}
}, {
key: 'renderRecordButton',
value: function renderRecordButton() {
return null;
// return (
//
// )
}
}, {
key: 'renderLiveButtons',
value: function renderLiveButtons() {
var _this3 = this;
var i18n = this.props.i18n;
return (0, _preact.h)(
'div',
null,
(0, _preact.h)(
_common.Button,
{
title: i18n.pix2pixhd.live.record.save_frame,
onClick: _player.saveFrame
},
i18n.pix2pixhd.live.record.save
),
(0, _preact.h)(
_common.ParamGroup,
{
title: i18n.pix2pixhd.live.record.record_video,
name: 'store_b',
noDim: true,
onToggle: function onToggle(value) {
// now storing frames on server...
}
},
(0, _preact.h)(_common.TextInput, {
title: i18n.pix2pixhd.live.record.video_name,
name: 'final_tag',
value: this.props.opt.final_tag,
onSave: function onSave(value) {
_this3.props.actions.live.set_param('final_tag', value);
}
})
)
);
}
}]);
return Pix2PixHDLive;
}(_preact.Component);
function timeInSeconds(n) {
return n.toFixed(1) + ' s.';
}
var mapStateToProps = function mapStateToProps(state) {
return {
last_message: state.live.last_message,
fullscreen: state.live.fullscreen,
opt: state.live.opt,
frame: state.live.frame,
checkpoints: state.live.checkpoints,
epochs: state.live.epochs,
sequences: state.live.sequences,
runner: state.system.runner,
i18n: state.system.i18n.strings,
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)
}
};
};
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 _actions = __webpack_require__(/*! ../../../actions */ "./app/client/actions.js");
var _actions2 = _interopRequireDefault(_actions);
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 yes_count = 0;
var Pix2pixHDResults = function (_Component) {
_inherits(Pix2pixHDResults, _Component);
function Pix2pixHDResults(props) {
_classCallCheck(this, Pix2pixHDResults);
var _this = _possibleConstructorReturn(this, (Pix2pixHDResults.__proto__ || Object.getPrototypeOf(Pix2pixHDResults)).call(this));
if (!props.pix2pixhd.results) props.actions.load_results();
return _this;
}
_createClass(Pix2pixHDResults, [{
key: 'componentDidMount',
value: function componentDidMount() {
yes_count = 0;
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
if (!this.props.pix2pixhd.results) return (0, _preact.h)(_loading2.default, { progress: this.props.pix2pixhd.progress });
var _props$pix2pixhd$resu = this.props.pix2pixhd.results,
resultsFolder = _props$pix2pixhd$resu.resultsFolder,
results = _props$pix2pixhd$resu.results,
renders = _props$pix2pixhd$resu.renders,
files = _props$pix2pixhd$resu.files;
// console.log(resultsFolder, results)
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' },
(0, _preact.h)(_fileList.FileList, {
linkFiles: true,
files: files,
orderBy: 'date desc',
fields: 'name date size delete',
onDelete: function onDelete(file) {
var yes = void 0;
if (yes_count < 3) {
yes = confirm('Are you sure you want to delete this file?');
} else {
yes = true;
}
if (yes) {
yes_count += 1;
console.log('delete: confirmed');
_actions2.default.file.destroy(file);
}
}
}),
(0, _preact.h)('br', null),
(0, _preact.h)(
'h3',
null,
'renders on server'
),
(0, _preact.h)(_fileList.FileList, {
files: renders,
orderBy: 'date desc',
fields: 'name date size',
onClick: function onClick(file, e) {
e.preventDefault();
e.stopPropagation();
console.log('picked a result', file);
_this2.handlePick(file);
}
}),
(0, _preact.h)('br', null),
(0, _preact.h)(
'h3',
null,
'folders on server'
),
(0, _preact.h)(_fileList.FileList, {
files: results,
orderBy: 'date desc',
fields: 'name date count',
onClick: function onClick(file, e) {
e.preventDefault();
e.stopPropagation();
console.log('picked a result', file);
_this2.handlePick(file);
}
})
)
);
}
}, {
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;
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/pix2pixhd/views/pix2pixhd.train.js":
/*!***************************************************************!*\
!*** ./app/client/modules/pix2pixhd/views/pix2pixhd.train.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 _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 _sequence = __webpack_require__(/*! ./sequence.editor */ "./app/client/modules/pix2pixhd/views/sequence.editor.js");
var _sequence2 = _interopRequireDefault(_sequence);
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 _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 Pix2PixHDTrain = function (_Component) {
_inherits(Pix2PixHDTrain, _Component);
function Pix2PixHDTrain(props) {
_classCallCheck(this, Pix2PixHDTrain);
var _this = _possibleConstructorReturn(this, (Pix2PixHDTrain.__proto__ || Object.getPrototypeOf(Pix2PixHDTrain)).call(this, props));
_this.state = {
dataset: 'PLACEHOLDER',
epoch: 'latest',
augment_name: '',
augment_take: 100,
augment_make: 20,
processed: false
};
_this.handleChange = _this.handleChange.bind(_this);
return _this;
}
_createClass(Pix2PixHDTrain, [{
key: 'componentDidMount',
value: function componentDidMount() {
var id = this.props.match.params.id || localStorage.getItem('pix2pixhd.last_id');
var dataset = localStorage.getItem('pix2pixhd.last_dataset');
console.log('load dataset:', id, dataset);
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/');
}
if (dataset) {
this.setState({ dataset: dataset });
}
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps, prevState) {
var _this2 = this;
if (!prevProps.pix2pixhd.data && this.props.pix2pixhd.data || prevProps.pix2pixhd.data && prevState.dataset !== this.state.dataset) {
var dataset = this.props.pix2pixhd.data.datasetLookup[this.state.dataset];
if (dataset) {
var processed = dataset.input.map(function (f) {
return _this2.props.pix2pixhd.data.fileLookup[f];
}).reduce(function (a, b) {
console.log(b);
return b.processed || a;
}, false);
console.log(dataset.input, processed);
dataset.processed = processed;
this.setState({ processed: processed });
}
}
if (prevState.dataset !== this.state.dataset) {
localStorage.setItem('pix2pixhd.last_dataset', this.state.dataset);
this.setState({
epoch: 'latest'
});
this.props.actions.list_epochs(this.state.dataset);
this.props.actions.count_dataset(this.state.dataset);
}
}
}, {
key: 'handleChange',
value: function handleChange(name, value) {
console.log('name', name, 'value', value);
this.setState(_defineProperty({}, name, value));
}
}, {
key: 'interrupt',
value: function interrupt() {
this.props.actions.queue.stop_task('gpu');
}
}, {
key: 'render',
value: function render() {
var _this3 = this;
if (this.props.pix2pixhd.loading) {
return (0, _preact.h)(_common.Loading, { progress: this.props.pix2pixhd.progress });
}
var _props2 = this.props,
pix2pixhd = _props2.pix2pixhd,
match = _props2.match,
history = _props2.history;
var _ref = pix2pixhd.data || {},
folderLookup = _ref.folderLookup,
datasetLookup = _ref.datasetLookup;
var folder = (folderLookup || {})[pix2pixhd.folder_id] || {};
var checkpoint = pix2pixhd.checkpoint;
// console.log(pix2pixhd)
var sequenceGroups = Object.keys(folderLookup).map(function (id) {
var folder = _this3.props.pix2pixhd.data.folderLookup[id];
if (folder.name === 'results') return;
var datasets = folder.datasets.map(function (name) {
var dataset = datasetLookup[name];
// console.log(folder)
if (dataset.isBuilt) {
// && dataset.checkpoints.length
return name;
}
return null;
}).filter(function (n) {
return !!n;
});
return {
name: folder.name,
options: datasets.sort()
};
}).filter(function (n) {
return !!n && !!n.options.length;
}).sort(function (a, b) {
return a.name.localeCompare(b.name);
});
var epochs = this.props.pix2pixhd.epochs;
if (!epochs || !epochs.length) epochs = ["latest"];
// console.log('state', this.props.pix2pixhd.data.epochs)
// console.log(this.state.dataset, this.state.epoch)
// console.log(queue)
return (0, _preact.h)(
'div',
{ className: 'app pix2pixhd' },
(0, _preact.h)(
'div',
{ className: 'heading' },
(0, _preact.h)(
'h1',
null,
'pix2pixhd training'
)
),
(0, _preact.h)(
'div',
{ className: 'columns' },
(0, _preact.h)(
'div',
{ className: 'column' },
(0, _preact.h)(
_common.Group,
{ title: 'Sequence' },
(0, _preact.h)(_common.SelectGroup, {
name: 'dataset',
title: 'Sequence name',
options: sequenceGroups,
onChange: this.handleChange,
placeholder: 'Pick a dataset',
value: this.state.dataset
}),
(0, _preact.h)(_common.Select, {
title: 'Epoch',
name: 'epoch',
options: epochs,
onChange: this.handleChange,
value: this.state.epoch
})
)
)
),
checkpoint && checkpoint.sequence && checkpoint.sequence.length ? this.renderEditor() : checkpoint && (0, _preact.h)(
'div',
null,
'Sequence empty, augmentation impossible'
)
);
}
}, {
key: 'renderEditor',
value: function renderEditor() {
var _this4 = this;
var _props3 = this.props,
pix2pixhd = _props3.pix2pixhd,
queue = _props3.queue,
remote = _props3.remote;
var _state = this.state,
dataset = _state.dataset,
processed = _state.processed;
var checkpoint = pix2pixhd.checkpoint,
folder_id = pix2pixhd.folder_id;
var currentDataset = this.props.pix2pixhd.data.datasetLookup[this.state.dataset];
if (currentDataset && currentDataset.folder_id) {
folder_id = currentDataset.folder_id || folder_id;
console.log("dataset folder id", folder_id);
// const processed = currentDataset.input
// .map(f => this.props.pix2pixhd.data.fileLookup[f])
// .reduce((a, b) => {
// console.log(b)
// return b.processed || a
// }, false)
// console.log("is processed?", processed)
}
console.log(currentDataset);
console.log("so folder id is..", folder_id);
return (0, _preact.h)(
'div',
null,
(0, _preact.h)(
_common.Group,
{ title: 'Sequence Editor' },
(0, _preact.h)(_sequence2.default, {
folder_id: folder_id,
module: _pix2pixhd4.default,
checkpoint: checkpoint,
processed: processed
})
),
(0, _preact.h)(
'div',
{ className: 'columns' },
(0, _preact.h)(
'div',
{ className: 'column' },
(0, _preact.h)(
_common.Group,
{ title: 'Augmentation Grid' },
(0, _preact.h)(_common.AugmentationGrid, {
checkpoint: checkpoint,
take: [1, 2, 3, 4, 5, 10, 15, 20, 25, 50, 75, 100, 200, 300, 400, 500, 1000],
make: [1, 2, 3, 4, 5, 10, 15, 20, 25, 50, 75, 100, 200],
onAugment: function onAugment(augment_take, augment_make) {
remote.augment_task(dataset, _extends({}, _this4.state, {
augment_take: augment_take,
augment_make: augment_make
}));
},
onTrain: function onTrain() {
remote.train_task(dataset, folder_id, 1);
setTimeout(function () {
// auto-generate epoch demo
remote.augment_task(dataset, _extends({}, _this4.state, {
augment_take: 10,
augment_make: 149,
no_symlinks: true,
mov: true,
folder_id: pix2pixhd.data.resultsFolder.id
}));
}, 250);
}
})
),
(0, _preact.h)(
_common.Group,
{ title: 'Augment' },
(0, _preact.h)(_common.NumberInput, {
name: 'augment_take',
title: 'Pick N random frames',
value: this.state.augment_take,
onChange: this.handleChange,
type: 'int',
min: '1',
max: '1000'
}),
(0, _preact.h)(_common.NumberInput, {
name: 'augment_make',
title: 'Generate N recursively',
value: this.state.augment_make,
onChange: this.handleChange,
type: 'int',
min: '1',
max: '1000'
}),
(0, _preact.h)(_common.Button, {
title: 'Augment dataset',
value: 'Augment',
onClick: function onClick() {
return _this4.props.remote.augment_task(dataset, _this4.state);
}
}),
(0, _preact.h)(_common.Button, {
title: 'Make a movie without augmenting',
value: 'Generate',
onClick: function onClick() {
_this4.props.remote.augment_task(dataset, _extends({}, _this4.state, {
no_symlinks: true,
mov: true,
folder_id: pix2pixhd.data.resultsFolder.id
}));
}
})
),
(0, _preact.h)(
_common.Group,
{ title: 'Status' },
(0, _preact.h)(_common.Button, {
title: 'GPU',
value: this.props.runner.gpu.status === 'IDLE' ? "Idle" : "Interrupt",
onClick: function onClick() {
return _this4.interrupt();
}
}),
(0, _preact.h)(_common.CurrentTask, null)
)
),
(0, _preact.h)(
'div',
{ className: 'column' },
(0, _preact.h)(
_common.Group,
{ title: 'Upcoming Tasks' },
(0, _preact.h)(_common.TaskList, { tasks: queue.queue.map(function (id) {
return queue.tasks[id];
}), sort: 'date asc' })
)
)
)
);
}
}]);
return Pix2PixHDTrain;
}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
return {
pix2pixhd: state.module.pix2pixhd,
runner: state.system.runner,
queue: state.queue
};
};
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)(Pix2PixHDTrain);
/***/ }),
/***/ "./app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js":
/*!***************************************************************!*\
!*** ./app/client/modules/pix2pixhd/views/pix2pixhd.uprez.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 _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 _actions = __webpack_require__(/*! ../../../actions */ "./app/client/actions.js");
var _actions2 = _interopRequireDefault(_actions);
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 yes_count = 0;
var Pix2pixHDUprez = function (_Component) {
_inherits(Pix2pixHDUprez, _Component);
function Pix2pixHDUprez(props) {
_classCallCheck(this, Pix2pixHDUprez);
var _this = _possibleConstructorReturn(this, (Pix2pixHDUprez.__proto__ || Object.getPrototypeOf(Pix2pixHDUprez)).call(this));
if (!props.pix2pixhd.uprez) props.actions.load_uprez();
return _this;
}
_createClass(Pix2pixHDUprez, [{
key: 'componentDidMount',
value: function componentDidMount() {
yes_count = 0;
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
if (!this.props.pix2pixhd.uprez) return (0, _preact.h)(_loading2.default, { progress: this.props.pix2pixhd.progress });
var _props$pix2pixhd$upre = this.props.pix2pixhd.uprez,
resultsFolder = _props$pix2pixhd$upre.resultsFolder,
results = _props$pix2pixhd$upre.results,
renders = _props$pix2pixhd$upre.renders,
files = _props$pix2pixhd$upre.files;
// console.log(resultsFolder, results)
return (0, _preact.h)(
'div',
{ className: 'app pix2pixhd' },
(0, _preact.h)(
'div',
{ className: 'heading row middle' },
(0, _preact.h)(
'h1',
null,
'Pix2PixHD Uprez'
)
),
(0, _preact.h)(
'div',
{ 'class': 'rows params renders' },
(0, _preact.h)(
'h3',
null,
'folders on server'
),
(0, _preact.h)(_fileList.FileList, {
files: results,
orderBy: 'date desc',
fields: 'name date count',
onClick: function onClick(file, e) {
e.preventDefault();
e.stopPropagation();
console.log('picked a result', file);
_this2.handlePick(file);
},
options: function options(file) {
console.log(file);
// create uprez task
return (0, _preact.h)(
'div',
null,
' ~ ',
(0, _preact.h)(
'a',
{ href: '#', onClick: function onClick() {
return _this2.handleUprez(file, { end: 250 });
} },
'Uprez 10 seconds'
),
' ~ ',
(0, _preact.h)(
'a',
{ href: '#', onClick: function onClick() {
return _this2.handleUprez(file, { end: 1500 });
} },
'Uprez 1 minute'
),
' ~ ',
(0, _preact.h)(
'a',
{ href: '#', onClick: function onClick() {
return _this2.handleUprez(file);
} },
'Uprez whole thing'
)
);
}
}),
(0, _preact.h)('br', null),
(0, _preact.h)(
'h3',
null,
'uprezzed videos'
),
(0, _preact.h)(_fileList.FileList, {
linkFiles: true,
files: files,
orderBy: 'date desc',
fields: 'name date size delete',
onDelete: function onDelete(file) {
var yes = void 0;
if (yes_count < 3) {
yes = confirm('Are you sure you want to delete this file?');
} else {
yes = true;
}
if (yes) {
yes_count += 1;
console.log('delete: confirmed');
_actions2.default.file.destroy(file);
}
}
})
)
);
}
}, {
key: 'handlePick',
value: function handlePick(file) {
// this.props.audioPlayer.play(file)
}
}, {
key: 'handleUprez',
value: function handleUprez(file, opt) {
console.log(file);
this.props.remote.uprez_task(_extends({
is_result: true,
dataset: file.name,
folder_id: 1
}, opt));
}
}]);
return Pix2pixHDUprez;
}(_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)(Pix2pixHDUprez);
/***/ }),
/***/ "./app/client/modules/pix2pixhd/views/sequence.editor.js":
/*!***************************************************************!*\
!*** ./app/client/modules/pix2pixhd/views/sequence.editor.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 _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);
var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js");
var _pix2pixhd = __webpack_require__(/*! ../pix2pixhd.tasks */ "./app/client/modules/pix2pixhd/pix2pixhd.tasks.js");
var pix2pixhdTasks = _interopRequireWildcard(_pix2pixhd);
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 initialState = {
dir: '/',
cursor: null,
selection: null,
title: null
};
var SequenceEditor = function (_Component) {
_inherits(SequenceEditor, _Component);
function SequenceEditor() {
_classCallCheck(this, SequenceEditor);
var _this = _possibleConstructorReturn(this, (SequenceEditor.__proto__ || Object.getPrototypeOf(SequenceEditor)).call(this));
_this.state = _extends({}, initialState);
_this.handleCursor = _this.handleCursor.bind(_this);
_this.handleSelect = _this.handleSelect.bind(_this);
return _this;
}
_createClass(SequenceEditor, [{
key: 'componentDidMount',
value: function componentDidMount() {
var checkpoint = this.props.checkpoint;
if (checkpoint) {
this.reset();
}
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
var checkpoint = this.props.checkpoint;
if (checkpoint !== prevProps.checkpoint) {
this.reset();
}
}
}, {
key: 'reset',
value: function reset() {
var checkpoint = this.props.checkpoint;
if (!(checkpoint && checkpoint.sequence)) return;
// console.log(checkpoint)
this.setState(_extends({}, initialState, {
title: checkpoint.name + '_' + (0, _moment2.default)().format("YYYYMMDD")
}));
}
}, {
key: 'handleCursor',
value: function handleCursor(cursor) {
this.setState({ cursor: cursor });
}
}, {
key: 'handleSelect',
value: function handleSelect(selection) {
this.setState({ selection: selection });
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var _props = this.props,
app = _props.app,
pix2pixhd = _props.pix2pixhd,
remote = _props.remote,
checkpoint = _props.checkpoint,
folder_id = _props.folder_id,
processed = _props.processed;
var _state = this.state,
cursor = _state.cursor,
selection = _state.selection,
title = _state.title;
var path = "sequences/" + checkpoint.name;
// console.log(checkpoint, pix2pixhd)
return (0, _preact.h)(
'div',
{ className: 'sequenceEditor row' },
selection ? (0, _preact.h)(
'div',
{ className: 'form' },
(0, _preact.h)(
_common.Param,
{ title: 'Selection length' },
selection.end.i - selection.start.i,
' frames'
),
(0, _preact.h)(
_common.Param,
{ title: 'Duration' },
_util2.default.frameTimestamp(selection.end.i - selection.start.i)
),
(0, _preact.h)(
_common.Group,
{ title: 'New dataset' },
(0, _preact.h)(_common.TextInput, {
title: 'Title dataset',
value: title,
onInput: function onInput(title) {
return _this2.setState({ title: title.replace(/ /g, '_').replace(/\/\./g, '').toLowerCase() });
}
}),
(0, _preact.h)(
_common.Button,
{
title: 'Create a new dataset?',
onClick: function onClick() {
return remote.splice_task({ title: title, sequence: checkpoint.name, selection: selection, folder_id: folder_id });
}
},
'Create'
)
)
) : (0, _preact.h)(
'div',
{ className: 'form' },
(0, _preact.h)(
_common.Group,
{ title: 'New dataset' },
'Please select some frames'
)
),
(0, _preact.h)(
'div',
{ className: 'rows' },
(0, _preact.h)(
'div',
{ className: 'row' },
(0, _preact.h)(Frame, { label: 'Cursor', path: path, frame: cursor }),
selection && selection.start && (0, _preact.h)(Frame, { label: 'Selection Start', path: path, frame: selection.start }),
selection && selection.end && (0, _preact.h)(Frame, { label: 'Selection End', path: path, frame: selection.end })
),
(0, _preact.h)(_common.Timeline, {
sequence: checkpoint.sequence,
onCursor: this.handleCursor,
onSelect: this.handleSelect
})
)
);
}
}]);
return SequenceEditor;
}(_preact.Component);
function Frame(_ref) {
var label = _ref.label,
path = _ref.path,
frame = _ref.frame;
if (!frame) return (0, _preact.h)('div', { 'class': 'frame' });
return (0, _preact.h)(
'div',
{ 'class': 'frame' },
(0, _preact.h)(_common.FileViewer, { thumbnail: 140, path: path, file: frame.frame }),
(0, _preact.h)(
'div',
{ 'class': 'spaced' },
(0, _preact.h)(
'span',
null,
label
),
(0, _preact.h)(
'span',
null,
'#',
frame.i,
' ',
_util2.default.frameTimestamp(frame.i)
)
)
);
}
var mapStateToProps = function mapStateToProps(state) {
return {
app: state.system.app,
pix2pixhd: state.module.pix2pixhd
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
remote: (0, _redux.bindActionCreators)(pix2pixhdTasks, dispatch)
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SequenceEditor);
/***/ }),
/***/ "./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)
}
});
}).catch(function (e) {
console.error(e);
});
if (id) {
console.log('folder id', id);
dispatch({
type: _types2.default.dataset.set_folder,
data: {
folder_id: id,
module: module
}
});
}
};
};
/***/ }),
/***/ "./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 },
data: { module: 'samplernn' }
});
}).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;
if (!checkpoint.name) return;
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;
}).filter(function (c) {
return !!c;
});
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
}
});
}).catch(function (e) {
console.error(e);
});
if (id) {
dispatch({
type: _types2.default.dataset.set_folder,
data: {
folder_id: id,
module: module
}
});
}
};
};
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 },
data: { module: 'samplernn' }
});
}).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.generate_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 generate_task = exports.generate_task = function generate_task(dataset, folder_id) {
var sample_length = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5;
var n_samples = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 6;
var epoch = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
return function (dispatch) {
var task = {
module: 'samplernn',
activity: 'generate',
dataset: dataset.name,
epoch: epoch || dataset.checkpoints.length && dataset.checkpoints[0].epoch || 0,
folder_id: folder_id,
opt: {
sample_length: Math.round(44100 * sample_length),
n_samples: n_samples
}
};
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'
)
),
(0, _preact.h)(
'div',
{ 'class': 'actions' },
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 5, 12);
} },
'generate'
),
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 0.5, 120);
} },
'/2'
),
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 0.25, 240);
} },
'/4'
),
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 0.125, 480);
} },
'/8'
),
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 0.0625, 960);
} },
'/16'
)
),
(0, _preact.h)(
'div',
{ 'class': 'actions' },
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 2, 30);
} },
'2s'
),
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 10, 6);
} },
'10s'
),
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 15, 4);
} },
'15s'
),
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 30, 2);
} },
'30s'
),
(0, _preact.h)(
'span',
{ 'class': 'link', onClick: function onClick() {
return remote.generate_task(dataset, samplernn.folder_id, 60, 1);
} },
'1m'
)
),
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 = exports.thumbnail = exports.read_file = exports.upload_file = exports.run_script = exports.list_sequences = exports.count_directory = exports.list_directory = exports.disk_usage = exports.run_system_command = 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 _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 }; }
var run_system_command = exports.run_system_command = function run_system_command(opt) {
return syscall_async('run_system_command', opt);
};
var disk_usage = exports.disk_usage = function disk_usage(opt) {
return syscall_async('run_system_command', _extends({ cmd: 'du' }, opt));
};
var list_directory = exports.list_directory = function list_directory(opt) {
return syscall_async('list_directory', opt).then(function (res) {
return res.files;
});
};
var count_directory = exports.count_directory = function count_directory(opt) {
return syscall_async('count_directory', opt).then(function (res) {
return res.count;
});
};
var list_sequences = exports.list_sequences = function list_sequences(opt) {
return syscall_async('list_sequences', opt).then(function (res) {
return res.sequences;
});
};
var run_script = exports.run_script = function run_script(opt) {
return syscall_async('run_script', opt);
};
var upload_file = exports.upload_file = function upload_file(opt) {
return syscall_async('upload_file', opt);
};
var read_file = exports.read_file = function read_file(opt) {
return syscall_async('read_file', opt).then(function (res) {
return res.file;
});
};
var thumbnail = exports.thumbnail = function thumbnail(opt) {
return syscall_async('thumbnail', opt).then(function (res) {
return res.file;
});
};
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)
data = parse(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;
}
});
function parse(s) {
if (typeof s === 'string') {
try {
var d = JSON.parse(s);
return d;
} catch (e) {
console.error('not valid json');
return s;
}
}
return s;
}
/***/ }),
/***/ "./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.send_command = send_command;
exports.list_checkpoints = list_checkpoints;
exports.list_all_checkpoints = list_all_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_all_checkpoints':
(0, _store.dispatch)({
type: _types2.default.socket.list_all_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 send_command(cmd, payload) {
_socket.socket.emit('cmd', {
cmd: cmd, payload: payload
});
}
function list_checkpoints(module) {
_socket.socket.emit('cmd', {
cmd: 'list_checkpoints',
payload: module
});
}
function list_all_checkpoints(module) {
_socket.socket.emit('cmd', {
cmd: 'list_all_checkpoints',
payload: module
});
}
function list_epochs(module, checkpoint_name) {
_socket.socket.emit('cmd', {
cmd: 'list_epochs',
payload: module === 'pix2pix' || module === 'pix2wav' ? module + '/' + checkpoint_name : 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 (raw_data) {
// does not like the nested task object for some reason..
var data = void 0;
try {
if (typeof raw_data === 'string') {
data = JSON.parse(raw_data);
if (typeof data === 'string') {
data = JSON.parse(data);
}
} else {
data = raw_data;
}
} catch (e) {
console.warn('problem with json', e);
return;
}
if (data.task) {
(0, _store.dispatch)({ type: _types2.default.task.update, data: data.task });
}
// console.log('task', data.type)
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:
console.log(data);
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 _auth = __webpack_require__(/*! ./auth/auth.reducer */ "./app/client/auth/auth.reducer.js");
var _auth2 = _interopRequireDefault(_auth);
var _live = __webpack_require__(/*! ./live/live.reducer */ "./app/client/live/live.reducer.js");
var _live2 = _interopRequireDefault(_live);
var _queue = __webpack_require__(/*! ./queue/queue.reducer */ "./app/client/queue/queue.reducer.js");
var _queue2 = _interopRequireDefault(_queue);
var _system = __webpack_require__(/*! ./system/system.reducer */ "./app/client/system/system.reducer.js");
var _system2 = _interopRequireDefault(_system);
var _upload = __webpack_require__(/*! ./dataset/upload.reducer */ "./app/client/dataset/upload.reducer.js");
var _upload2 = _interopRequireDefault(_upload);
var _dashboard = __webpack_require__(/*! ./dashboard/dashboard.reducer */ "./app/client/dashboard/dashboard.reducer.js");
var _dashboard2 = _interopRequireDefault(_dashboard);
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 }; }
// import navReducer from './nav.reducer'
var appReducer = (0, _redux.combineReducers)({
router: _reactRouterRedux.routerReducer,
auth: _auth2.default,
live: _live2.default,
queue: _queue2.default,
system: _system2.default,
upload: _upload2.default,
dashboard: _dashboard2.default,
audioPlayer: _audioPlayer2.default,
module: _module.moduleReducer
});
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.changeLanguage = exports.changeTool = exports.countDirectory = 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 countDirectory = exports.countDirectory = function countDirectory(opt) {
return function (dispatch) {
dispatch({ type: _types2.default.system.counting_directory, opt: opt });
_socket2.default.actions.count_directory(opt).then(function (data) {
dispatch({
type: _types2.default.system.count_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 changeLanguage = exports.changeLanguage = function changeLanguage(language) {
localStorage.setItem('cortex.i18n.language', language);
return { type: _types2.default.system.change_language, language: language };
};
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);
var _auth = __webpack_require__(/*! ../auth/auth.actions */ "./app/client/auth/auth.actions.js");
var authActions = _interopRequireWildcard(_auth);
var _i18n = __webpack_require__(/*! ../i18n */ "./app/client/i18n/index.js");
var i18n = _interopRequireWildcard(_i18n);
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,
user = _props.user;
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: 'Auth' },
(0, _preact.h)(
_param2.default,
{ title: 'Logged in as ' + user.username },
(0, _preact.h)(
'button',
{ onClick: function onClick() {
return actions.auth.logout();
} },
'Logout'
)
)
),
(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'
)
)
),
(0, _preact.h)(
_group2.default,
{ title: 'Internationalization' },
(0, _preact.h)(
_param2.default,
{ title: 'Language' },
i18n.languages.map(function (language) {
return (0, _preact.h)(
'button',
{ onClick: function onClick() {
return actions.system.changeLanguage(language);
} },
language
);
})
)
)
),
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({
user: state.auth.user
}, state.system, state.live);
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
actions: {
auth: (0, _redux.bindActionCreators)(authActions, dispatch),
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";
/* WEBPACK VAR INJECTION */(function(process) {
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);
var _i18n = __webpack_require__(/*! ../i18n */ "./app/client/i18n/index.js");
var i18n = _interopRequireWildcard(_i18n);
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; }
var FileSaver = __webpack_require__(/*! file-saver */ "./node_modules/file-saver/FileSaver.js");
var initialLanguage = localStorage.getItem('cortex.i18n.language') || process.env.I18N_LANGUAGE || 'en';
var systemInitialState = {
loading: false,
error: null,
site: {
name: 'loading'
},
env: {
env: "development",
production: "development" === 'production',
development: "development" !== 'production'
},
i18n: {
language: initialLanguage,
strings: i18n.strings(initialLanguage)
},
app: {
tool: localStorage.getItem('system.last_tool') || 'pix2pixhd'
},
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', 'pix2pixhd', 'pix2wav', 'samplernn', 'morph'].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.processor === 'cpu' || state.runner.cpu.task && state.runner.cpu.task.uuid === action.task.uuid) {
processor = 'cpu';
} else if (action.task.processor === 'gpu' || state.runner.gpu.task && state.runner.gpu.task.uuid === action.task.uuid) {
processor = 'gpu';
} else {
processor = null;
}
console.log('task finish', action);
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
});
case _types2.default.system.change_language:
return _extends({}, state, {
i18n: {
language: action.language,
strings: i18n.strings(action.language)
}
});
default:
return state;
}
};
exports.default = systemReducer;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/node_modules/process/browser.js */ "./node_modules/webpack/node_modules/process/browser.js")))
/***/ }),
/***/ "./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',
count_directory: 'SYSTEM_COUNT_DIRECTORY',
counting_directory: 'SYSTEM_COUNTING_DIRECTORY',
stdout: 'SYSTEM_STDOUT',
stderr: 'SYSTEM_STDERR',
change_language: 'SYSTEM_CHANGE_LANGUAGE'
},
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']),
auth: (0, _crud.crud_type)('auth', ['set_token', 'set_error', 'set_current_user', 'logout_user', 'loading', 'initialized', 'set_return_to']),
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',
send_command: 'SEND_COMMAND',
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',
set_fullscreen: 'SET_FULLSCREEN'
},
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',
list_epochs: 'DATASET_LIST_EPOCHS'
},
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
},
biggan: (0, _crud.with_type)('biggan', ['init', 'set_folder', 'load_results', 'load_encodings']),
pix2pix: (0, _crud.with_type)('pix2pix', ['init', 'set_folder']),
pix2pixhd: (0, _crud.with_type)('pix2pixhd', ['init', 'set_folder', 'load_results', 'load_dataset_count', 'load_uprez']),
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']),
morph: (0, _crud.with_type)('morph', ['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.frameTimestamp = frameTimestamp;
exports.timeInSeconds = timeInSeconds;
exports.gerund = gerund;
exports.commatize = commatize;
exports.carbon_date = carbon_date;
exports.carbon_time = carbon_time;
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;
exports.pad = pad;
var FRAME_RATE = 25;
function frameTimestamp() {
var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
n /= FRAME_RATE;
var s = pad((n % 60).toFixed(1));
n = Math.floor(n / 60);
if (n > 60) {
return Math.floor(n / 60) + ':' + pad(n % 60) + ':' + s;
}
return n % 60 + ':' + 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 carbon_time(date, no_bold) {
var span = (+new Date() - new Date(date)) / 1000,
color;
if (!no_bold && span < 3600) // modified this hour
{
color = "new";
} else if (span < 3 * 3600) // modifed last 3 hours
{
color = "recent";
} else if (span < 12 * 3600) // modifed last 12 hours
{
color = "med";
} else if (span < 24 * 3600) // modifed last day
{
color = "old";
} else if (span < 48 * 3600) // modifed last two days
{
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."];
}
if (n < 20000000 / bias) {
return ["quiet", txt + " mb."];
}
if (n < 50000000 / bias) {
return ["old", txt + " mb."];
}
if (n < 80000000 / bias) {
return ["med", txt + " mb."];
}
if (no_bold || n < 170000000 / bias) {
return ["recent", txt + " mb."];
}
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";
}
function pad(n, r) {
return n < 10 ? '0' + n : n;
}
/***/ }),
/***/ "./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.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);
};
var randrange = exports.randrange = function randrange(a, b) {
return Math.random() * (b - a) + a;
};
var randsign = exports.randsign = function randsign() {
return Math.random() >= 0.5 ? -1 : 1;
};
var choice = exports.choice = function choice(a) {
return a[Math.floor(Math.random() * a.length)];
};
var angle = exports.angle = function angle(x0, y0, x1, y1) {
return Math.atan2(y1 - y0, x1 - x0);
};
var dist = exports.dist = function dist(x0, y0, x1, y1) {
return Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2));
};
var xor = exports.xor = function xor(a, b) {
a = !!a;b = !!b;return (a || b) && !(a && b);
};
var quantize = exports.quantize = function quantize(a, b) {
return Math.floor(a / b) * b;
};
var shuffle = exports.shuffle = 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/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/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/invariant/browser.js":
/*!*******************************************!*\
!*** ./node_modules/invariant/browser.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 invariant = function(condition, format, a, b, c, d, e, f) {
if (true) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
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/jszip/lib/base64.js":
/*!******************************************!*\
!*** ./node_modules/jszip/lib/base64.js ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
var support = __webpack_require__(/*! ./support */ "./node_modules/jszip/lib/support.js");
// private property
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
// public method for encoding
exports.encode = function(input) {
var output = [];
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0, len = input.length, remainingBytes = len;
var isArray = utils.getTypeOf(input) !== "string";
while (i < input.length) {
remainingBytes = len - i;
if (!isArray) {
chr1 = input.charCodeAt(i++);
chr2 = i < len ? input.charCodeAt(i++) : 0;
chr3 = i < len ? input.charCodeAt(i++) : 0;
} else {
chr1 = input[i++];
chr2 = i < len ? input[i++] : 0;
chr3 = i < len ? input[i++] : 0;
}
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = remainingBytes > 1 ? (((chr2 & 15) << 2) | (chr3 >> 6)) : 64;
enc4 = remainingBytes > 2 ? (chr3 & 63) : 64;
output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4));
}
return output.join("");
};
// public method for decoding
exports.decode = function(input) {
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0, resultIndex = 0;
var dataUrlPrefix = "data:";
if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) {
// This is a common error: people give a data url
// (data:image/png;base64,iVBOR...) with a {base64: true} and
// wonders why things don't work.
// We can detect that the string input looks like a data url but we
// *can't* be sure it is one: removing everything up to the comma would
// be too dangerous.
throw new Error("Invalid base64 input, it looks like a data url.");
}
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
var totalLength = input.length * 3 / 4;
if(input.charAt(input.length - 1) === _keyStr.charAt(64)) {
totalLength--;
}
if(input.charAt(input.length - 2) === _keyStr.charAt(64)) {
totalLength--;
}
if (totalLength % 1 !== 0) {
// totalLength is not an integer, the length does not match a valid
// base64 content. That can happen if:
// - the input is not a base64 content
// - the input is *almost* a base64 content, with a extra chars at the
// beginning or at the end
// - the input uses a base64 variant (base64url for example)
throw new Error("Invalid base64 input, bad content length.");
}
var output;
if (support.uint8array) {
output = new Uint8Array(totalLength|0);
} else {
output = new Array(totalLength|0);
}
while (i < input.length) {
enc1 = _keyStr.indexOf(input.charAt(i++));
enc2 = _keyStr.indexOf(input.charAt(i++));
enc3 = _keyStr.indexOf(input.charAt(i++));
enc4 = _keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output[resultIndex++] = chr1;
if (enc3 !== 64) {
output[resultIndex++] = chr2;
}
if (enc4 !== 64) {
output[resultIndex++] = chr3;
}
}
return output;
};
/***/ }),
/***/ "./node_modules/jszip/lib/compressedObject.js":
/*!****************************************************!*\
!*** ./node_modules/jszip/lib/compressedObject.js ***!
\****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var external = __webpack_require__(/*! ./external */ "./node_modules/jszip/lib/external.js");
var DataWorker = __webpack_require__(/*! ./stream/DataWorker */ "./node_modules/jszip/lib/stream/DataWorker.js");
var DataLengthProbe = __webpack_require__(/*! ./stream/DataLengthProbe */ "./node_modules/jszip/lib/stream/DataLengthProbe.js");
var Crc32Probe = __webpack_require__(/*! ./stream/Crc32Probe */ "./node_modules/jszip/lib/stream/Crc32Probe.js");
var DataLengthProbe = __webpack_require__(/*! ./stream/DataLengthProbe */ "./node_modules/jszip/lib/stream/DataLengthProbe.js");
/**
* Represent a compressed object, with everything needed to decompress it.
* @constructor
* @param {number} compressedSize the size of the data compressed.
* @param {number} uncompressedSize the size of the data after decompression.
* @param {number} crc32 the crc32 of the decompressed file.
* @param {object} compression the type of compression, see lib/compressions.js.
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the compressed data.
*/
function CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) {
this.compressedSize = compressedSize;
this.uncompressedSize = uncompressedSize;
this.crc32 = crc32;
this.compression = compression;
this.compressedContent = data;
}
CompressedObject.prototype = {
/**
* Create a worker to get the uncompressed content.
* @return {GenericWorker} the worker.
*/
getContentWorker : function () {
var worker = new DataWorker(external.Promise.resolve(this.compressedContent))
.pipe(this.compression.uncompressWorker())
.pipe(new DataLengthProbe("data_length"));
var that = this;
worker.on("end", function () {
if(this.streamInfo['data_length'] !== that.uncompressedSize) {
throw new Error("Bug : uncompressed data size mismatch");
}
});
return worker;
},
/**
* Create a worker to get the compressed content.
* @return {GenericWorker} the worker.
*/
getCompressedWorker : function () {
return new DataWorker(external.Promise.resolve(this.compressedContent))
.withStreamInfo("compressedSize", this.compressedSize)
.withStreamInfo("uncompressedSize", this.uncompressedSize)
.withStreamInfo("crc32", this.crc32)
.withStreamInfo("compression", this.compression)
;
}
};
/**
* Chain the given worker with other workers to compress the content with the
* given compresion.
* @param {GenericWorker} uncompressedWorker the worker to pipe.
* @param {Object} compression the compression object.
* @param {Object} compressionOptions the options to use when compressing.
* @return {GenericWorker} the new worker compressing the content.
*/
CompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions) {
return uncompressedWorker
.pipe(new Crc32Probe())
.pipe(new DataLengthProbe("uncompressedSize"))
.pipe(compression.compressWorker(compressionOptions))
.pipe(new DataLengthProbe("compressedSize"))
.withStreamInfo("compression", compression);
};
module.exports = CompressedObject;
/***/ }),
/***/ "./node_modules/jszip/lib/compressions.js":
/*!************************************************!*\
!*** ./node_modules/jszip/lib/compressions.js ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var GenericWorker = __webpack_require__(/*! ./stream/GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
exports.STORE = {
magic: "\x00\x00",
compressWorker : function (compressionOptions) {
return new GenericWorker("STORE compression");
},
uncompressWorker : function () {
return new GenericWorker("STORE decompression");
}
};
exports.DEFLATE = __webpack_require__(/*! ./flate */ "./node_modules/jszip/lib/flate.js");
/***/ }),
/***/ "./node_modules/jszip/lib/crc32.js":
/*!*****************************************!*\
!*** ./node_modules/jszip/lib/crc32.js ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
/**
* The following functions come from pako, from pako/lib/zlib/crc32.js
* released under the MIT license, see pako https://github.com/nodeca/pako/
*/
// Use ordinary array, since untyped makes no boost here
function makeTable() {
var c, table = [];
for(var n =0; n < 256; n++){
c = n;
for(var k =0; k < 8; k++){
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
}
table[n] = c;
}
return table;
}
// Create table on load. Just 255 signed longs. Not a problem.
var crcTable = makeTable();
function crc32(crc, buf, len, pos) {
var t = crcTable, end = pos + len;
crc = crc ^ (-1);
for (var i = pos; i < end; i++ ) {
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
}
return (crc ^ (-1)); // >>> 0;
}
// That's all for the pako functions.
/**
* Compute the crc32 of a string.
* This is almost the same as the function crc32, but for strings. Using the
* same function for the two use cases leads to horrible performances.
* @param {Number} crc the starting value of the crc.
* @param {String} str the string to use.
* @param {Number} len the length of the string.
* @param {Number} pos the starting position for the crc32 computation.
* @return {Number} the computed crc32.
*/
function crc32str(crc, str, len, pos) {
var t = crcTable, end = pos + len;
crc = crc ^ (-1);
for (var i = pos; i < end; i++ ) {
crc = (crc >>> 8) ^ t[(crc ^ str.charCodeAt(i)) & 0xFF];
}
return (crc ^ (-1)); // >>> 0;
}
module.exports = function crc32wrapper(input, crc) {
if (typeof input === "undefined" || !input.length) {
return 0;
}
var isArray = utils.getTypeOf(input) !== "string";
if(isArray) {
return crc32(crc|0, input, input.length, 0);
} else {
return crc32str(crc|0, input, input.length, 0);
}
};
/***/ }),
/***/ "./node_modules/jszip/lib/defaults.js":
/*!********************************************!*\
!*** ./node_modules/jszip/lib/defaults.js ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.base64 = false;
exports.binary = false;
exports.dir = false;
exports.createFolders = true;
exports.date = null;
exports.compression = null;
exports.compressionOptions = null;
exports.comment = null;
exports.unixPermissions = null;
exports.dosPermissions = null;
/***/ }),
/***/ "./node_modules/jszip/lib/external.js":
/*!********************************************!*\
!*** ./node_modules/jszip/lib/external.js ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* global Promise */
// load the global object first:
// - it should be better integrated in the system (unhandledRejection in node)
// - the environment may have a custom Promise implementation (see zone.js)
var ES6Promise = null;
if (typeof Promise !== "undefined") {
ES6Promise = Promise;
} else {
ES6Promise = __webpack_require__(/*! lie */ "./node_modules/jszip/node_modules/lie/lib/browser.js");
}
/**
* Let the user use/change some implementations.
*/
module.exports = {
Promise: ES6Promise
};
/***/ }),
/***/ "./node_modules/jszip/lib/flate.js":
/*!*****************************************!*\
!*** ./node_modules/jszip/lib/flate.js ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var USE_TYPEDARRAY = (typeof Uint8Array !== 'undefined') && (typeof Uint16Array !== 'undefined') && (typeof Uint32Array !== 'undefined');
var pako = __webpack_require__(/*! pako */ "./node_modules/jszip/node_modules/pako/index.js");
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
var GenericWorker = __webpack_require__(/*! ./stream/GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
var ARRAY_TYPE = USE_TYPEDARRAY ? "uint8array" : "array";
exports.magic = "\x08\x00";
/**
* Create a worker that uses pako to inflate/deflate.
* @constructor
* @param {String} action the name of the pako function to call : either "Deflate" or "Inflate".
* @param {Object} options the options to use when (de)compressing.
*/
function FlateWorker(action, options) {
GenericWorker.call(this, "FlateWorker/" + action);
this._pako = null;
this._pakoAction = action;
this._pakoOptions = options;
// the `meta` object from the last chunk received
// this allow this worker to pass around metadata
this.meta = {};
}
utils.inherits(FlateWorker, GenericWorker);
/**
* @see GenericWorker.processChunk
*/
FlateWorker.prototype.processChunk = function (chunk) {
this.meta = chunk.meta;
if (this._pako === null) {
this._createPako();
}
this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false);
};
/**
* @see GenericWorker.flush
*/
FlateWorker.prototype.flush = function () {
GenericWorker.prototype.flush.call(this);
if (this._pako === null) {
this._createPako();
}
this._pako.push([], true);
};
/**
* @see GenericWorker.cleanUp
*/
FlateWorker.prototype.cleanUp = function () {
GenericWorker.prototype.cleanUp.call(this);
this._pako = null;
};
/**
* Create the _pako object.
* TODO: lazy-loading this object isn't the best solution but it's the
* quickest. The best solution is to lazy-load the worker list. See also the
* issue #446.
*/
FlateWorker.prototype._createPako = function () {
this._pako = new pako[this._pakoAction]({
raw: true,
level: this._pakoOptions.level || -1 // default compression
});
var self = this;
this._pako.onData = function(data) {
self.push({
data : data,
meta : self.meta
});
};
};
exports.compressWorker = function (compressionOptions) {
return new FlateWorker("Deflate", compressionOptions);
};
exports.uncompressWorker = function () {
return new FlateWorker("Inflate", {});
};
/***/ }),
/***/ "./node_modules/jszip/lib/generate/ZipFileWorker.js":
/*!**********************************************************!*\
!*** ./node_modules/jszip/lib/generate/ZipFileWorker.js ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
var GenericWorker = __webpack_require__(/*! ../stream/GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
var utf8 = __webpack_require__(/*! ../utf8 */ "./node_modules/jszip/lib/utf8.js");
var crc32 = __webpack_require__(/*! ../crc32 */ "./node_modules/jszip/lib/crc32.js");
var signature = __webpack_require__(/*! ../signature */ "./node_modules/jszip/lib/signature.js");
/**
* Transform an integer into a string in hexadecimal.
* @private
* @param {number} dec the number to convert.
* @param {number} bytes the number of bytes to generate.
* @returns {string} the result.
*/
var decToHex = function(dec, bytes) {
var hex = "", i;
for (i = 0; i < bytes; i++) {
hex += String.fromCharCode(dec & 0xff);
dec = dec >>> 8;
}
return hex;
};
/**
* Generate the UNIX part of the external file attributes.
* @param {Object} unixPermissions the unix permissions or null.
* @param {Boolean} isDir true if the entry is a directory, false otherwise.
* @return {Number} a 32 bit integer.
*
* adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :
*
* TTTTsstrwxrwxrwx0000000000ADVSHR
* ^^^^____________________________ file type, see zipinfo.c (UNX_*)
* ^^^_________________________ setuid, setgid, sticky
* ^^^^^^^^^________________ permissions
* ^^^^^^^^^^______ not used ?
* ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only
*/
var generateUnixExternalFileAttr = function (unixPermissions, isDir) {
var result = unixPermissions;
if (!unixPermissions) {
// I can't use octal values in strict mode, hence the hexa.
// 040775 => 0x41fd
// 0100664 => 0x81b4
result = isDir ? 0x41fd : 0x81b4;
}
return (result & 0xFFFF) << 16;
};
/**
* Generate the DOS part of the external file attributes.
* @param {Object} dosPermissions the dos permissions or null.
* @param {Boolean} isDir true if the entry is a directory, false otherwise.
* @return {Number} a 32 bit integer.
*
* Bit 0 Read-Only
* Bit 1 Hidden
* Bit 2 System
* Bit 3 Volume Label
* Bit 4 Directory
* Bit 5 Archive
*/
var generateDosExternalFileAttr = function (dosPermissions, isDir) {
// the dir flag is already set for compatibility
return (dosPermissions || 0) & 0x3F;
};
/**
* Generate the various parts used in the construction of the final zip file.
* @param {Object} streamInfo the hash with informations about the compressed file.
* @param {Boolean} streamedContent is the content streamed ?
* @param {Boolean} streamingEnded is the stream finished ?
* @param {number} offset the current offset from the start of the zip file.
* @param {String} platform let's pretend we are this platform (change platform dependents fields)
* @param {Function} encodeFileName the function to encode the file name / comment.
* @return {Object} the zip parts.
*/
var generateZipParts = function(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) {
var file = streamInfo['file'],
compression = streamInfo['compression'],
useCustomEncoding = encodeFileName !== utf8.utf8encode,
encodedFileName = utils.transformTo("string", encodeFileName(file.name)),
utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)),
comment = file.comment,
encodedComment = utils.transformTo("string", encodeFileName(comment)),
utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)),
useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,
useUTF8ForComment = utfEncodedComment.length !== comment.length,
dosTime,
dosDate,
extraFields = "",
unicodePathExtraField = "",
unicodeCommentExtraField = "",
dir = file.dir,
date = file.date;
var dataInfo = {
crc32 : 0,
compressedSize : 0,
uncompressedSize : 0
};
// if the content is streamed, the sizes/crc32 are only available AFTER
// the end of the stream.
if (!streamedContent || streamingEnded) {
dataInfo.crc32 = streamInfo['crc32'];
dataInfo.compressedSize = streamInfo['compressedSize'];
dataInfo.uncompressedSize = streamInfo['uncompressedSize'];
}
var bitflag = 0;
if (streamedContent) {
// Bit 3: the sizes/crc32 are set to zero in the local header.
// The correct values are put in the data descriptor immediately
// following the compressed data.
bitflag |= 0x0008;
}
if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) {
// Bit 11: Language encoding flag (EFS).
bitflag |= 0x0800;
}
var extFileAttr = 0;
var versionMadeBy = 0;
if (dir) {
// dos or unix, we set the dos dir flag
extFileAttr |= 0x00010;
}
if(platform === "UNIX") {
versionMadeBy = 0x031E; // UNIX, version 3.0
extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);
} else { // DOS or other, fallback to DOS
versionMadeBy = 0x0014; // DOS, version 2.0
extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);
}
// date
// @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
// @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
// @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
dosTime = date.getUTCHours();
dosTime = dosTime << 6;
dosTime = dosTime | date.getUTCMinutes();
dosTime = dosTime << 5;
dosTime = dosTime | date.getUTCSeconds() / 2;
dosDate = date.getUTCFullYear() - 1980;
dosDate = dosDate << 4;
dosDate = dosDate | (date.getUTCMonth() + 1);
dosDate = dosDate << 5;
dosDate = dosDate | date.getUTCDate();
if (useUTF8ForFileName) {
// set the unicode path extra field. unzip needs at least one extra
// field to correctly handle unicode path, so using the path is as good
// as any other information. This could improve the situation with
// other archive managers too.
// This field is usually used without the utf8 flag, with a non
// unicode path in the header (winrar, winzip). This helps (a bit)
// with the messy Windows' default compressed folders feature but
// breaks on p7zip which doesn't seek the unicode path extra field.
// So for now, UTF-8 everywhere !
unicodePathExtraField =
// Version
decToHex(1, 1) +
// NameCRC32
decToHex(crc32(encodedFileName), 4) +
// UnicodeName
utfEncodedFileName;
extraFields +=
// Info-ZIP Unicode Path Extra Field
"\x75\x70" +
// size
decToHex(unicodePathExtraField.length, 2) +
// content
unicodePathExtraField;
}
if(useUTF8ForComment) {
unicodeCommentExtraField =
// Version
decToHex(1, 1) +
// CommentCRC32
decToHex(crc32(encodedComment), 4) +
// UnicodeName
utfEncodedComment;
extraFields +=
// Info-ZIP Unicode Path Extra Field
"\x75\x63" +
// size
decToHex(unicodeCommentExtraField.length, 2) +
// content
unicodeCommentExtraField;
}
var header = "";
// version needed to extract
header += "\x0A\x00";
// general purpose bit flag
header += decToHex(bitflag, 2);
// compression method
header += compression.magic;
// last mod file time
header += decToHex(dosTime, 2);
// last mod file date
header += decToHex(dosDate, 2);
// crc-32
header += decToHex(dataInfo.crc32, 4);
// compressed size
header += decToHex(dataInfo.compressedSize, 4);
// uncompressed size
header += decToHex(dataInfo.uncompressedSize, 4);
// file name length
header += decToHex(encodedFileName.length, 2);
// extra field length
header += decToHex(extraFields.length, 2);
var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;
var dirRecord = signature.CENTRAL_FILE_HEADER +
// version made by (00: DOS)
decToHex(versionMadeBy, 2) +
// file header (common to file and central directory)
header +
// file comment length
decToHex(encodedComment.length, 2) +
// disk number start
"\x00\x00" +
// internal file attributes TODO
"\x00\x00" +
// external file attributes
decToHex(extFileAttr, 4) +
// relative offset of local header
decToHex(offset, 4) +
// file name
encodedFileName +
// extra field
extraFields +
// file comment
encodedComment;
return {
fileRecord: fileRecord,
dirRecord: dirRecord
};
};
/**
* Generate the EOCD record.
* @param {Number} entriesCount the number of entries in the zip file.
* @param {Number} centralDirLength the length (in bytes) of the central dir.
* @param {Number} localDirLength the length (in bytes) of the local dir.
* @param {String} comment the zip file comment as a binary string.
* @param {Function} encodeFileName the function to encode the comment.
* @return {String} the EOCD record.
*/
var generateCentralDirectoryEnd = function (entriesCount, centralDirLength, localDirLength, comment, encodeFileName) {
var dirEnd = "";
var encodedComment = utils.transformTo("string", encodeFileName(comment));
// end of central dir signature
dirEnd = signature.CENTRAL_DIRECTORY_END +
// number of this disk
"\x00\x00" +
// number of the disk with the start of the central directory
"\x00\x00" +
// total number of entries in the central directory on this disk
decToHex(entriesCount, 2) +
// total number of entries in the central directory
decToHex(entriesCount, 2) +
// size of the central directory 4 bytes
decToHex(centralDirLength, 4) +
// offset of start of central directory with respect to the starting disk number
decToHex(localDirLength, 4) +
// .ZIP file comment length
decToHex(encodedComment.length, 2) +
// .ZIP file comment
encodedComment;
return dirEnd;
};
/**
* Generate data descriptors for a file entry.
* @param {Object} streamInfo the hash generated by a worker, containing informations
* on the file entry.
* @return {String} the data descriptors.
*/
var generateDataDescriptors = function (streamInfo) {
var descriptor = "";
descriptor = signature.DATA_DESCRIPTOR +
// crc-32 4 bytes
decToHex(streamInfo['crc32'], 4) +
// compressed size 4 bytes
decToHex(streamInfo['compressedSize'], 4) +
// uncompressed size 4 bytes
decToHex(streamInfo['uncompressedSize'], 4);
return descriptor;
};
/**
* A worker to concatenate other workers to create a zip file.
* @param {Boolean} streamFiles `true` to stream the content of the files,
* `false` to accumulate it.
* @param {String} comment the comment to use.
* @param {String} platform the platform to use, "UNIX" or "DOS".
* @param {Function} encodeFileName the function to encode file names and comments.
*/
function ZipFileWorker(streamFiles, comment, platform, encodeFileName) {
GenericWorker.call(this, "ZipFileWorker");
// The number of bytes written so far. This doesn't count accumulated chunks.
this.bytesWritten = 0;
// The comment of the zip file
this.zipComment = comment;
// The platform "generating" the zip file.
this.zipPlatform = platform;
// the function to encode file names and comments.
this.encodeFileName = encodeFileName;
// Should we stream the content of the files ?
this.streamFiles = streamFiles;
// If `streamFiles` is false, we will need to accumulate the content of the
// files to calculate sizes / crc32 (and write them *before* the content).
// This boolean indicates if we are accumulating chunks (it will change a lot
// during the lifetime of this worker).
this.accumulate = false;
// The buffer receiving chunks when accumulating content.
this.contentBuffer = [];
// The list of generated directory records.
this.dirRecords = [];
// The offset (in bytes) from the beginning of the zip file for the current source.
this.currentSourceOffset = 0;
// The total number of entries in this zip file.
this.entriesCount = 0;
// the name of the file currently being added, null when handling the end of the zip file.
// Used for the emited metadata.
this.currentFile = null;
this._sources = [];
}
utils.inherits(ZipFileWorker, GenericWorker);
/**
* @see GenericWorker.push
*/
ZipFileWorker.prototype.push = function (chunk) {
var currentFilePercent = chunk.meta.percent || 0;
var entriesCount = this.entriesCount;
var remainingFiles = this._sources.length;
if(this.accumulate) {
this.contentBuffer.push(chunk);
} else {
this.bytesWritten += chunk.data.length;
GenericWorker.prototype.push.call(this, {
data : chunk.data,
meta : {
currentFile : this.currentFile,
percent : entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100
}
});
}
};
/**
* The worker started a new source (an other worker).
* @param {Object} streamInfo the streamInfo object from the new source.
*/
ZipFileWorker.prototype.openedSource = function (streamInfo) {
this.currentSourceOffset = this.bytesWritten;
this.currentFile = streamInfo['file'].name;
var streamedContent = this.streamFiles && !streamInfo['file'].dir;
// don't stream folders (because they don't have any content)
if(streamedContent) {
var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
this.push({
data : record.fileRecord,
meta : {percent:0}
});
} else {
// we need to wait for the whole file before pushing anything
this.accumulate = true;
}
};
/**
* The worker finished a source (an other worker).
* @param {Object} streamInfo the streamInfo object from the finished source.
*/
ZipFileWorker.prototype.closedSource = function (streamInfo) {
this.accumulate = false;
var streamedContent = this.streamFiles && !streamInfo['file'].dir;
var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
this.dirRecords.push(record.dirRecord);
if(streamedContent) {
// after the streamed file, we put data descriptors
this.push({
data : generateDataDescriptors(streamInfo),
meta : {percent:100}
});
} else {
// the content wasn't streamed, we need to push everything now
// first the file record, then the content
this.push({
data : record.fileRecord,
meta : {percent:0}
});
while(this.contentBuffer.length) {
this.push(this.contentBuffer.shift());
}
}
this.currentFile = null;
};
/**
* @see GenericWorker.flush
*/
ZipFileWorker.prototype.flush = function () {
var localDirLength = this.bytesWritten;
for(var i = 0; i < this.dirRecords.length; i++) {
this.push({
data : this.dirRecords[i],
meta : {percent:100}
});
}
var centralDirLength = this.bytesWritten - localDirLength;
var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName);
this.push({
data : dirEnd,
meta : {percent:100}
});
};
/**
* Prepare the next source to be read.
*/
ZipFileWorker.prototype.prepareNextSource = function () {
this.previous = this._sources.shift();
this.openedSource(this.previous.streamInfo);
if (this.isPaused) {
this.previous.pause();
} else {
this.previous.resume();
}
};
/**
* @see GenericWorker.registerPrevious
*/
ZipFileWorker.prototype.registerPrevious = function (previous) {
this._sources.push(previous);
var self = this;
previous.on('data', function (chunk) {
self.processChunk(chunk);
});
previous.on('end', function () {
self.closedSource(self.previous.streamInfo);
if(self._sources.length) {
self.prepareNextSource();
} else {
self.end();
}
});
previous.on('error', function (e) {
self.error(e);
});
return this;
};
/**
* @see GenericWorker.resume
*/
ZipFileWorker.prototype.resume = function () {
if(!GenericWorker.prototype.resume.call(this)) {
return false;
}
if (!this.previous && this._sources.length) {
this.prepareNextSource();
return true;
}
if (!this.previous && !this._sources.length && !this.generatedError) {
this.end();
return true;
}
};
/**
* @see GenericWorker.error
*/
ZipFileWorker.prototype.error = function (e) {
var sources = this._sources;
if(!GenericWorker.prototype.error.call(this, e)) {
return false;
}
for(var i = 0; i < sources.length; i++) {
try {
sources[i].error(e);
} catch(e) {
// the `error` exploded, nothing to do
}
}
return true;
};
/**
* @see GenericWorker.lock
*/
ZipFileWorker.prototype.lock = function () {
GenericWorker.prototype.lock.call(this);
var sources = this._sources;
for(var i = 0; i < sources.length; i++) {
sources[i].lock();
}
};
module.exports = ZipFileWorker;
/***/ }),
/***/ "./node_modules/jszip/lib/generate/index.js":
/*!**************************************************!*\
!*** ./node_modules/jszip/lib/generate/index.js ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var compressions = __webpack_require__(/*! ../compressions */ "./node_modules/jszip/lib/compressions.js");
var ZipFileWorker = __webpack_require__(/*! ./ZipFileWorker */ "./node_modules/jszip/lib/generate/ZipFileWorker.js");
/**
* Find the compression to use.
* @param {String} fileCompression the compression defined at the file level, if any.
* @param {String} zipCompression the compression defined at the load() level.
* @return {Object} the compression object to use.
*/
var getCompression = function (fileCompression, zipCompression) {
var compressionName = fileCompression || zipCompression;
var compression = compressions[compressionName];
if (!compression) {
throw new Error(compressionName + " is not a valid compression method !");
}
return compression;
};
/**
* Create a worker to generate a zip file.
* @param {JSZip} zip the JSZip instance at the right root level.
* @param {Object} options to generate the zip file.
* @param {String} comment the comment to use.
*/
exports.generateWorker = function (zip, options, comment) {
var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName);
var entriesCount = 0;
try {
zip.forEach(function (relativePath, file) {
entriesCount++;
var compression = getCompression(file.options.compression, options.compression);
var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};
var dir = file.dir, date = file.date;
file._compressWorker(compression, compressionOptions)
.withStreamInfo("file", {
name : relativePath,
dir : dir,
date : date,
comment : file.comment || "",
unixPermissions : file.unixPermissions,
dosPermissions : file.dosPermissions
})
.pipe(zipFileWorker);
});
zipFileWorker.entriesCount = entriesCount;
} catch (e) {
zipFileWorker.error(e);
}
return zipFileWorker;
};
/***/ }),
/***/ "./node_modules/jszip/lib/index.js":
/*!*****************************************!*\
!*** ./node_modules/jszip/lib/index.js ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Representation a of zip file in js
* @constructor
*/
function JSZip() {
// if this constructor is used without `new`, it adds `new` before itself:
if(!(this instanceof JSZip)) {
return new JSZip();
}
if(arguments.length) {
throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
}
// object containing the files :
// {
// "folder/" : {...},
// "folder/data.txt" : {...}
// }
this.files = {};
this.comment = null;
// Where we are in the hierarchy
this.root = "";
this.clone = function() {
var newObj = new JSZip();
for (var i in this) {
if (typeof this[i] !== "function") {
newObj[i] = this[i];
}
}
return newObj;
};
}
JSZip.prototype = __webpack_require__(/*! ./object */ "./node_modules/jszip/lib/object.js");
JSZip.prototype.loadAsync = __webpack_require__(/*! ./load */ "./node_modules/jszip/lib/load.js");
JSZip.support = __webpack_require__(/*! ./support */ "./node_modules/jszip/lib/support.js");
JSZip.defaults = __webpack_require__(/*! ./defaults */ "./node_modules/jszip/lib/defaults.js");
// TODO find a better way to handle this version,
// a require('package.json').version doesn't work with webpack, see #327
JSZip.version = "3.1.5";
JSZip.loadAsync = function (content, options) {
return new JSZip().loadAsync(content, options);
};
JSZip.external = __webpack_require__(/*! ./external */ "./node_modules/jszip/lib/external.js");
module.exports = JSZip;
/***/ }),
/***/ "./node_modules/jszip/lib/load.js":
/*!****************************************!*\
!*** ./node_modules/jszip/lib/load.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
var external = __webpack_require__(/*! ./external */ "./node_modules/jszip/lib/external.js");
var utf8 = __webpack_require__(/*! ./utf8 */ "./node_modules/jszip/lib/utf8.js");
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
var ZipEntries = __webpack_require__(/*! ./zipEntries */ "./node_modules/jszip/lib/zipEntries.js");
var Crc32Probe = __webpack_require__(/*! ./stream/Crc32Probe */ "./node_modules/jszip/lib/stream/Crc32Probe.js");
var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ "./node_modules/jszip/lib/nodejsUtils.js");
/**
* Check the CRC32 of an entry.
* @param {ZipEntry} zipEntry the zip entry to check.
* @return {Promise} the result.
*/
function checkEntryCRC32(zipEntry) {
return new external.Promise(function (resolve, reject) {
var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
worker.on("error", function (e) {
reject(e);
})
.on("end", function () {
if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
reject(new Error("Corrupted zip : CRC32 mismatch"));
} else {
resolve();
}
})
.resume();
});
}
module.exports = function(data, options) {
var zip = this;
options = utils.extend(options || {}, {
base64: false,
checkCRC32: false,
optimizedBinaryString: false,
createFolders: false,
decodeFileName: utf8.utf8decode
});
if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
return external.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file."));
}
return utils.prepareContent("the loaded zip file", data, true, options.optimizedBinaryString, options.base64)
.then(function(data) {
var zipEntries = new ZipEntries(options);
zipEntries.load(data);
return zipEntries;
}).then(function checkCRC32(zipEntries) {
var promises = [external.Promise.resolve(zipEntries)];
var files = zipEntries.files;
if (options.checkCRC32) {
for (var i = 0; i < files.length; i++) {
promises.push(checkEntryCRC32(files[i]));
}
}
return external.Promise.all(promises);
}).then(function addFiles(results) {
var zipEntries = results.shift();
var files = zipEntries.files;
for (var i = 0; i < files.length; i++) {
var input = files[i];
zip.file(input.fileNameStr, input.decompressed, {
binary: true,
optimizedBinaryString: true,
date: input.date,
dir: input.dir,
comment : input.fileCommentStr.length ? input.fileCommentStr : null,
unixPermissions : input.unixPermissions,
dosPermissions : input.dosPermissions,
createFolders: options.createFolders
});
}
if (zipEntries.zipComment.length) {
zip.comment = zipEntries.zipComment;
}
return zip;
});
};
/***/ }),
/***/ "./node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js":
/*!*******************************************************************!*\
!*** ./node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js ***!
\*******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
var GenericWorker = __webpack_require__(/*! ../stream/GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
/**
* A worker that use a nodejs stream as source.
* @constructor
* @param {String} filename the name of the file entry for this stream.
* @param {Readable} stream the nodejs stream.
*/
function NodejsStreamInputAdapter(filename, stream) {
GenericWorker.call(this, "Nodejs stream input adapter for " + filename);
this._upstreamEnded = false;
this._bindStream(stream);
}
utils.inherits(NodejsStreamInputAdapter, GenericWorker);
/**
* Prepare the stream and bind the callbacks on it.
* Do this ASAP on node 0.10 ! A lazy binding doesn't always work.
* @param {Stream} stream the nodejs stream to use.
*/
NodejsStreamInputAdapter.prototype._bindStream = function (stream) {
var self = this;
this._stream = stream;
stream.pause();
stream
.on("data", function (chunk) {
self.push({
data: chunk,
meta : {
percent : 0
}
});
})
.on("error", function (e) {
if(self.isPaused) {
this.generatedError = e;
} else {
self.error(e);
}
})
.on("end", function () {
if(self.isPaused) {
self._upstreamEnded = true;
} else {
self.end();
}
});
};
NodejsStreamInputAdapter.prototype.pause = function () {
if(!GenericWorker.prototype.pause.call(this)) {
return false;
}
this._stream.pause();
return true;
};
NodejsStreamInputAdapter.prototype.resume = function () {
if(!GenericWorker.prototype.resume.call(this)) {
return false;
}
if(this._upstreamEnded) {
this.end();
} else {
this._stream.resume();
}
return true;
};
module.exports = NodejsStreamInputAdapter;
/***/ }),
/***/ "./node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js":
/*!********************************************************************!*\
!*** ./node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js ***!
\********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var Readable = __webpack_require__(/*! readable-stream */ "./node_modules/jszip/lib/readable-stream-browser.js").Readable;
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
utils.inherits(NodejsStreamOutputAdapter, Readable);
/**
* A nodejs stream using a worker as source.
* @see the SourceWrapper in http://nodejs.org/api/stream.html
* @constructor
* @param {StreamHelper} helper the helper wrapping the worker
* @param {Object} options the nodejs stream options
* @param {Function} updateCb the update callback.
*/
function NodejsStreamOutputAdapter(helper, options, updateCb) {
Readable.call(this, options);
this._helper = helper;
var self = this;
helper.on("data", function (data, meta) {
if (!self.push(data)) {
self._helper.pause();
}
if(updateCb) {
updateCb(meta);
}
})
.on("error", function(e) {
self.emit('error', e);
})
.on("end", function () {
self.push(null);
});
}
NodejsStreamOutputAdapter.prototype._read = function() {
this._helper.resume();
};
module.exports = NodejsStreamOutputAdapter;
/***/ }),
/***/ "./node_modules/jszip/lib/nodejsUtils.js":
/*!***********************************************!*\
!*** ./node_modules/jszip/lib/nodejsUtils.js ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Buffer) {
module.exports = {
/**
* True if this is running in Nodejs, will be undefined in a browser.
* In a browser, browserify won't include this file and the whole module
* will be resolved an empty object.
*/
isNode : typeof Buffer !== "undefined",
/**
* Create a new nodejs Buffer from an existing content.
* @param {Object} data the data to pass to the constructor.
* @param {String} encoding the encoding to use.
* @return {Buffer} a new Buffer.
*/
newBufferFrom: function(data, encoding) {
// XXX We can't use `Buffer.from` which comes from `Uint8Array.from`
// in nodejs v4 (< v.4.5). It's not the expected implementation (and
// has a different signature).
// see https://github.com/nodejs/node/issues/8053
// A condition on nodejs' version won't solve the issue as we don't
// control the Buffer polyfills that may or may not be used.
return new Buffer(data, encoding);
},
/**
* Create a new nodejs Buffer with the specified size.
* @param {Integer} size the size of the buffer.
* @return {Buffer} a new Buffer.
*/
allocBuffer: function (size) {
if (Buffer.alloc) {
return Buffer.alloc(size);
} else {
return new Buffer(size);
}
},
/**
* Find out if an object is a Buffer.
* @param {Object} b the object to test.
* @return {Boolean} true if the object is a Buffer, false otherwise.
*/
isBuffer : function(b){
return Buffer.isBuffer(b);
},
isStream : function (obj) {
return obj &&
typeof obj.on === "function" &&
typeof obj.pause === "function" &&
typeof obj.resume === "function";
}
};
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/node_modules/buffer/index.js */ "./node_modules/webpack/node_modules/buffer/index.js").Buffer))
/***/ }),
/***/ "./node_modules/jszip/lib/object.js":
/*!******************************************!*\
!*** ./node_modules/jszip/lib/object.js ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utf8 = __webpack_require__(/*! ./utf8 */ "./node_modules/jszip/lib/utf8.js");
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
var GenericWorker = __webpack_require__(/*! ./stream/GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
var StreamHelper = __webpack_require__(/*! ./stream/StreamHelper */ "./node_modules/jszip/lib/stream/StreamHelper.js");
var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/jszip/lib/defaults.js");
var CompressedObject = __webpack_require__(/*! ./compressedObject */ "./node_modules/jszip/lib/compressedObject.js");
var ZipObject = __webpack_require__(/*! ./zipObject */ "./node_modules/jszip/lib/zipObject.js");
var generate = __webpack_require__(/*! ./generate */ "./node_modules/jszip/lib/generate/index.js");
var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ "./node_modules/jszip/lib/nodejsUtils.js");
var NodejsStreamInputAdapter = __webpack_require__(/*! ./nodejs/NodejsStreamInputAdapter */ "./node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js");
/**
* Add a file in the current folder.
* @private
* @param {string} name the name of the file
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file
* @param {Object} originalOptions the options of the file
* @return {Object} the new file.
*/
var fileAdd = function(name, data, originalOptions) {
// be sure sub folders exist
var dataType = utils.getTypeOf(data),
parent;
/*
* Correct options.
*/
var o = utils.extend(originalOptions || {}, defaults);
o.date = o.date || new Date();
if (o.compression !== null) {
o.compression = o.compression.toUpperCase();
}
if (typeof o.unixPermissions === "string") {
o.unixPermissions = parseInt(o.unixPermissions, 8);
}
// UNX_IFDIR 0040000 see zipinfo.c
if (o.unixPermissions && (o.unixPermissions & 0x4000)) {
o.dir = true;
}
// Bit 4 Directory
if (o.dosPermissions && (o.dosPermissions & 0x0010)) {
o.dir = true;
}
if (o.dir) {
name = forceTrailingSlash(name);
}
if (o.createFolders && (parent = parentFolder(name))) {
folderAdd.call(this, parent, true);
}
var isUnicodeString = dataType === "string" && o.binary === false && o.base64 === false;
if (!originalOptions || typeof originalOptions.binary === "undefined") {
o.binary = !isUnicodeString;
}
var isCompressedEmpty = (data instanceof CompressedObject) && data.uncompressedSize === 0;
if (isCompressedEmpty || o.dir || !data || data.length === 0) {
o.base64 = false;
o.binary = true;
data = "";
o.compression = "STORE";
dataType = "string";
}
/*
* Convert content to fit.
*/
var zipObjectContent = null;
if (data instanceof CompressedObject || data instanceof GenericWorker) {
zipObjectContent = data;
} else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
zipObjectContent = new NodejsStreamInputAdapter(name, data);
} else {
zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64);
}
var object = new ZipObject(name, zipObjectContent, o);
this.files[name] = object;
/*
TODO: we can't throw an exception because we have async promises
(we can have a promise of a Date() for example) but returning a
promise is useless because file(name, data) returns the JSZip
object for chaining. Should we break that to allow the user
to catch the error ?
return external.Promise.resolve(zipObjectContent)
.then(function () {
return object;
});
*/
};
/**
* Find the parent folder of the path.
* @private
* @param {string} path the path to use
* @return {string} the parent folder, or ""
*/
var parentFolder = function (path) {
if (path.slice(-1) === '/') {
path = path.substring(0, path.length - 1);
}
var lastSlash = path.lastIndexOf('/');
return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
};
/**
* Returns the path with a slash at the end.
* @private
* @param {String} path the path to check.
* @return {String} the path with a trailing slash.
*/
var forceTrailingSlash = function(path) {
// Check the name ends with a /
if (path.slice(-1) !== "/") {
path += "/"; // IE doesn't like substr(-1)
}
return path;
};
/**
* Add a (sub) folder in the current folder.
* @private
* @param {string} name the folder's name
* @param {boolean=} [createFolders] If true, automatically create sub
* folders. Defaults to false.
* @return {Object} the new folder.
*/
var folderAdd = function(name, createFolders) {
createFolders = (typeof createFolders !== 'undefined') ? createFolders : defaults.createFolders;
name = forceTrailingSlash(name);
// Does this folder already exist?
if (!this.files[name]) {
fileAdd.call(this, name, null, {
dir: true,
createFolders: createFolders
});
}
return this.files[name];
};
/**
* Cross-window, cross-Node-context regular expression detection
* @param {Object} object Anything
* @return {Boolean} true if the object is a regular expression,
* false otherwise
*/
function isRegExp(object) {
return Object.prototype.toString.call(object) === "[object RegExp]";
}
// return the actual prototype of JSZip
var out = {
/**
* @see loadAsync
*/
load: function() {
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
},
/**
* Call a callback function for each entry at this folder level.
* @param {Function} cb the callback function:
* function (relativePath, file) {...}
* It takes 2 arguments : the relative path and the file.
*/
forEach: function(cb) {
var filename, relativePath, file;
for (filename in this.files) {
if (!this.files.hasOwnProperty(filename)) {
continue;
}
file = this.files[filename];
relativePath = filename.slice(this.root.length, filename.length);
if (relativePath && filename.slice(0, this.root.length) === this.root) { // the file is in the current root
cb(relativePath, file); // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...
}
}
},
/**
* Filter nested files/folders with the specified function.
* @param {Function} search the predicate to use :
* function (relativePath, file) {...}
* It takes 2 arguments : the relative path and the file.
* @return {Array} An array of matching elements.
*/
filter: function(search) {
var result = [];
this.forEach(function (relativePath, entry) {
if (search(relativePath, entry)) { // the file matches the function
result.push(entry);
}
});
return result;
},
/**
* Add a file to the zip file, or search a file.
* @param {string|RegExp} name The name of the file to add (if data is defined),
* the name of the file to find (if no data) or a regex to match files.
* @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded
* @param {Object} o File options
* @return {JSZip|Object|Array} this JSZip object (when adding a file),
* a file (when searching by string) or an array of files (when searching by regex).
*/
file: function(name, data, o) {
if (arguments.length === 1) {
if (isRegExp(name)) {
var regexp = name;
return this.filter(function(relativePath, file) {
return !file.dir && regexp.test(relativePath);
});
}
else { // text
var obj = this.files[this.root + name];
if (obj && !obj.dir) {
return obj;
} else {
return null;
}
}
}
else { // more than one argument : we have data !
name = this.root + name;
fileAdd.call(this, name, data, o);
}
return this;
},
/**
* Add a directory to the zip file, or search.
* @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.
* @return {JSZip} an object with the new directory as the root, or an array containing matching folders.
*/
folder: function(arg) {
if (!arg) {
return this;
}
if (isRegExp(arg)) {
return this.filter(function(relativePath, file) {
return file.dir && arg.test(relativePath);
});
}
// else, name is a new folder
var name = this.root + arg;
var newFolder = folderAdd.call(this, name);
// Allow chaining by returning a new object with this folder as the root
var ret = this.clone();
ret.root = newFolder.name;
return ret;
},
/**
* Delete a file, or a directory and all sub-files, from the zip
* @param {string} name the name of the file to delete
* @return {JSZip} this JSZip object
*/
remove: function(name) {
name = this.root + name;
var file = this.files[name];
if (!file) {
// Look for any folders
if (name.slice(-1) !== "/") {
name += "/";
}
file = this.files[name];
}
if (file && !file.dir) {
// file
delete this.files[name];
} else {
// maybe a folder, delete recursively
var kids = this.filter(function(relativePath, file) {
return file.name.slice(0, name.length) === name;
});
for (var i = 0; i < kids.length; i++) {
delete this.files[kids[i].name];
}
}
return this;
},
/**
* Generate the complete zip file
* @param {Object} options the options to generate the zip file :
* - compression, "STORE" by default.
* - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
* @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file
*/
generate: function(options) {
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
},
/**
* Generate the complete zip file as an internal stream.
* @param {Object} options the options to generate the zip file :
* - compression, "STORE" by default.
* - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
* @return {StreamHelper} the streamed zip file.
*/
generateInternalStream: function(options) {
var worker, opts = {};
try {
opts = utils.extend(options || {}, {
streamFiles: false,
compression: "STORE",
compressionOptions : null,
type: "",
platform: "DOS",
comment: null,
mimeType: 'application/zip',
encodeFileName: utf8.utf8encode
});
opts.type = opts.type.toLowerCase();
opts.compression = opts.compression.toUpperCase();
// "binarystring" is prefered but the internals use "string".
if(opts.type === "binarystring") {
opts.type = "string";
}
if (!opts.type) {
throw new Error("No output type specified.");
}
utils.checkSupport(opts.type);
// accept nodejs `process.platform`
if(
opts.platform === 'darwin' ||
opts.platform === 'freebsd' ||
opts.platform === 'linux' ||
opts.platform === 'sunos'
) {
opts.platform = "UNIX";
}
if (opts.platform === 'win32') {
opts.platform = "DOS";
}
var comment = opts.comment || this.comment || "";
worker = generate.generateWorker(this, opts, comment);
} catch (e) {
worker = new GenericWorker("error");
worker.error(e);
}
return new StreamHelper(worker, opts.type || "string", opts.mimeType);
},
/**
* Generate the complete zip file asynchronously.
* @see generateInternalStream
*/
generateAsync: function(options, onUpdate) {
return this.generateInternalStream(options).accumulate(onUpdate);
},
/**
* Generate the complete zip file asynchronously.
* @see generateInternalStream
*/
generateNodeStream: function(options, onUpdate) {
options = options || {};
if (!options.type) {
options.type = "nodebuffer";
}
return this.generateInternalStream(options).toNodejsStream(onUpdate);
}
};
module.exports = out;
/***/ }),
/***/ "./node_modules/jszip/lib/readable-stream-browser.js":
/*!***********************************************************!*\
!*** ./node_modules/jszip/lib/readable-stream-browser.js ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/*
* This file is used by module bundlers (browserify/webpack/etc) when
* including a stream implementation. We use "readable-stream" to get a
* consistent behavior between nodejs versions but bundlers often have a shim
* for "stream". Using this shim greatly improve the compatibility and greatly
* reduce the final size of the bundle (only one stream implementation, not
* two).
*/
module.exports = __webpack_require__(/*! stream */ "./node_modules/webpack/node_modules/stream-browserify/index.js");
/***/ }),
/***/ "./node_modules/jszip/lib/reader/ArrayReader.js":
/*!******************************************************!*\
!*** ./node_modules/jszip/lib/reader/ArrayReader.js ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var DataReader = __webpack_require__(/*! ./DataReader */ "./node_modules/jszip/lib/reader/DataReader.js");
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
function ArrayReader(data) {
DataReader.call(this, data);
for(var i = 0; i < this.data.length; i++) {
data[i] = data[i] & 0xFF;
}
}
utils.inherits(ArrayReader, DataReader);
/**
* @see DataReader.byteAt
*/
ArrayReader.prototype.byteAt = function(i) {
return this.data[this.zero + i];
};
/**
* @see DataReader.lastIndexOfSignature
*/
ArrayReader.prototype.lastIndexOfSignature = function(sig) {
var sig0 = sig.charCodeAt(0),
sig1 = sig.charCodeAt(1),
sig2 = sig.charCodeAt(2),
sig3 = sig.charCodeAt(3);
for (var i = this.length - 4; i >= 0; --i) {
if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {
return i - this.zero;
}
}
return -1;
};
/**
* @see DataReader.readAndCheckSignature
*/
ArrayReader.prototype.readAndCheckSignature = function (sig) {
var sig0 = sig.charCodeAt(0),
sig1 = sig.charCodeAt(1),
sig2 = sig.charCodeAt(2),
sig3 = sig.charCodeAt(3),
data = this.readData(4);
return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3];
};
/**
* @see DataReader.readData
*/
ArrayReader.prototype.readData = function(size) {
this.checkOffset(size);
if(size === 0) {
return [];
}
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
this.index += size;
return result;
};
module.exports = ArrayReader;
/***/ }),
/***/ "./node_modules/jszip/lib/reader/DataReader.js":
/*!*****************************************************!*\
!*** ./node_modules/jszip/lib/reader/DataReader.js ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
function DataReader(data) {
this.data = data; // type : see implementation
this.length = data.length;
this.index = 0;
this.zero = 0;
}
DataReader.prototype = {
/**
* Check that the offset will not go too far.
* @param {string} offset the additional offset to check.
* @throws {Error} an Error if the offset is out of bounds.
*/
checkOffset: function(offset) {
this.checkIndex(this.index + offset);
},
/**
* Check that the specified index will not be too far.
* @param {string} newIndex the index to check.
* @throws {Error} an Error if the index is out of bounds.
*/
checkIndex: function(newIndex) {
if (this.length < this.zero + newIndex || newIndex < 0) {
throw new Error("End of data reached (data length = " + this.length + ", asked index = " + (newIndex) + "). Corrupted zip ?");
}
},
/**
* Change the index.
* @param {number} newIndex The new index.
* @throws {Error} if the new index is out of the data.
*/
setIndex: function(newIndex) {
this.checkIndex(newIndex);
this.index = newIndex;
},
/**
* Skip the next n bytes.
* @param {number} n the number of bytes to skip.
* @throws {Error} if the new index is out of the data.
*/
skip: function(n) {
this.setIndex(this.index + n);
},
/**
* Get the byte at the specified index.
* @param {number} i the index to use.
* @return {number} a byte.
*/
byteAt: function(i) {
// see implementations
},
/**
* Get the next number with a given byte size.
* @param {number} size the number of bytes to read.
* @return {number} the corresponding number.
*/
readInt: function(size) {
var result = 0,
i;
this.checkOffset(size);
for (i = this.index + size - 1; i >= this.index; i--) {
result = (result << 8) + this.byteAt(i);
}
this.index += size;
return result;
},
/**
* Get the next string with a given byte size.
* @param {number} size the number of bytes to read.
* @return {string} the corresponding string.
*/
readString: function(size) {
return utils.transformTo("string", this.readData(size));
},
/**
* Get raw data without conversion, bytes.
* @param {number} size the number of bytes to read.
* @return {Object} the raw data, implementation specific.
*/
readData: function(size) {
// see implementations
},
/**
* Find the last occurence of a zip signature (4 bytes).
* @param {string} sig the signature to find.
* @return {number} the index of the last occurence, -1 if not found.
*/
lastIndexOfSignature: function(sig) {
// see implementations
},
/**
* Read the signature (4 bytes) at the current position and compare it with sig.
* @param {string} sig the expected signature
* @return {boolean} true if the signature matches, false otherwise.
*/
readAndCheckSignature: function(sig) {
// see implementations
},
/**
* Get the next date.
* @return {Date} the date.
*/
readDate: function() {
var dostime = this.readInt(4);
return new Date(Date.UTC(
((dostime >> 25) & 0x7f) + 1980, // year
((dostime >> 21) & 0x0f) - 1, // month
(dostime >> 16) & 0x1f, // day
(dostime >> 11) & 0x1f, // hour
(dostime >> 5) & 0x3f, // minute
(dostime & 0x1f) << 1)); // second
}
};
module.exports = DataReader;
/***/ }),
/***/ "./node_modules/jszip/lib/reader/NodeBufferReader.js":
/*!***********************************************************!*\
!*** ./node_modules/jszip/lib/reader/NodeBufferReader.js ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var Uint8ArrayReader = __webpack_require__(/*! ./Uint8ArrayReader */ "./node_modules/jszip/lib/reader/Uint8ArrayReader.js");
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
function NodeBufferReader(data) {
Uint8ArrayReader.call(this, data);
}
utils.inherits(NodeBufferReader, Uint8ArrayReader);
/**
* @see DataReader.readData
*/
NodeBufferReader.prototype.readData = function(size) {
this.checkOffset(size);
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
this.index += size;
return result;
};
module.exports = NodeBufferReader;
/***/ }),
/***/ "./node_modules/jszip/lib/reader/StringReader.js":
/*!*******************************************************!*\
!*** ./node_modules/jszip/lib/reader/StringReader.js ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var DataReader = __webpack_require__(/*! ./DataReader */ "./node_modules/jszip/lib/reader/DataReader.js");
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
function StringReader(data) {
DataReader.call(this, data);
}
utils.inherits(StringReader, DataReader);
/**
* @see DataReader.byteAt
*/
StringReader.prototype.byteAt = function(i) {
return this.data.charCodeAt(this.zero + i);
};
/**
* @see DataReader.lastIndexOfSignature
*/
StringReader.prototype.lastIndexOfSignature = function(sig) {
return this.data.lastIndexOf(sig) - this.zero;
};
/**
* @see DataReader.readAndCheckSignature
*/
StringReader.prototype.readAndCheckSignature = function (sig) {
var data = this.readData(4);
return sig === data;
};
/**
* @see DataReader.readData
*/
StringReader.prototype.readData = function(size) {
this.checkOffset(size);
// this will work because the constructor applied the "& 0xff" mask.
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
this.index += size;
return result;
};
module.exports = StringReader;
/***/ }),
/***/ "./node_modules/jszip/lib/reader/Uint8ArrayReader.js":
/*!***********************************************************!*\
!*** ./node_modules/jszip/lib/reader/Uint8ArrayReader.js ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var ArrayReader = __webpack_require__(/*! ./ArrayReader */ "./node_modules/jszip/lib/reader/ArrayReader.js");
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
function Uint8ArrayReader(data) {
ArrayReader.call(this, data);
}
utils.inherits(Uint8ArrayReader, ArrayReader);
/**
* @see DataReader.readData
*/
Uint8ArrayReader.prototype.readData = function(size) {
this.checkOffset(size);
if(size === 0) {
// in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].
return new Uint8Array(0);
}
var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);
this.index += size;
return result;
};
module.exports = Uint8ArrayReader;
/***/ }),
/***/ "./node_modules/jszip/lib/reader/readerFor.js":
/*!****************************************************!*\
!*** ./node_modules/jszip/lib/reader/readerFor.js ***!
\****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
var support = __webpack_require__(/*! ../support */ "./node_modules/jszip/lib/support.js");
var ArrayReader = __webpack_require__(/*! ./ArrayReader */ "./node_modules/jszip/lib/reader/ArrayReader.js");
var StringReader = __webpack_require__(/*! ./StringReader */ "./node_modules/jszip/lib/reader/StringReader.js");
var NodeBufferReader = __webpack_require__(/*! ./NodeBufferReader */ "./node_modules/jszip/lib/reader/NodeBufferReader.js");
var Uint8ArrayReader = __webpack_require__(/*! ./Uint8ArrayReader */ "./node_modules/jszip/lib/reader/Uint8ArrayReader.js");
/**
* Create a reader adapted to the data.
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read.
* @return {DataReader} the data reader.
*/
module.exports = function (data) {
var type = utils.getTypeOf(data);
utils.checkSupport(type);
if (type === "string" && !support.uint8array) {
return new StringReader(data);
}
if (type === "nodebuffer") {
return new NodeBufferReader(data);
}
if (support.uint8array) {
return new Uint8ArrayReader(utils.transformTo("uint8array", data));
}
return new ArrayReader(utils.transformTo("array", data));
};
/***/ }),
/***/ "./node_modules/jszip/lib/signature.js":
/*!*********************************************!*\
!*** ./node_modules/jszip/lib/signature.js ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.LOCAL_FILE_HEADER = "PK\x03\x04";
exports.CENTRAL_FILE_HEADER = "PK\x01\x02";
exports.CENTRAL_DIRECTORY_END = "PK\x05\x06";
exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07";
exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06";
exports.DATA_DESCRIPTOR = "PK\x07\x08";
/***/ }),
/***/ "./node_modules/jszip/lib/stream/ConvertWorker.js":
/*!********************************************************!*\
!*** ./node_modules/jszip/lib/stream/ConvertWorker.js ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var GenericWorker = __webpack_require__(/*! ./GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
/**
* A worker which convert chunks to a specified type.
* @constructor
* @param {String} destType the destination type.
*/
function ConvertWorker(destType) {
GenericWorker.call(this, "ConvertWorker to " + destType);
this.destType = destType;
}
utils.inherits(ConvertWorker, GenericWorker);
/**
* @see GenericWorker.processChunk
*/
ConvertWorker.prototype.processChunk = function (chunk) {
this.push({
data : utils.transformTo(this.destType, chunk.data),
meta : chunk.meta
});
};
module.exports = ConvertWorker;
/***/ }),
/***/ "./node_modules/jszip/lib/stream/Crc32Probe.js":
/*!*****************************************************!*\
!*** ./node_modules/jszip/lib/stream/Crc32Probe.js ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var GenericWorker = __webpack_require__(/*! ./GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
var crc32 = __webpack_require__(/*! ../crc32 */ "./node_modules/jszip/lib/crc32.js");
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
/**
* A worker which calculate the crc32 of the data flowing through.
* @constructor
*/
function Crc32Probe() {
GenericWorker.call(this, "Crc32Probe");
this.withStreamInfo("crc32", 0);
}
utils.inherits(Crc32Probe, GenericWorker);
/**
* @see GenericWorker.processChunk
*/
Crc32Probe.prototype.processChunk = function (chunk) {
this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);
this.push(chunk);
};
module.exports = Crc32Probe;
/***/ }),
/***/ "./node_modules/jszip/lib/stream/DataLengthProbe.js":
/*!**********************************************************!*\
!*** ./node_modules/jszip/lib/stream/DataLengthProbe.js ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
var GenericWorker = __webpack_require__(/*! ./GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
/**
* A worker which calculate the total length of the data flowing through.
* @constructor
* @param {String} propName the name used to expose the length
*/
function DataLengthProbe(propName) {
GenericWorker.call(this, "DataLengthProbe for " + propName);
this.propName = propName;
this.withStreamInfo(propName, 0);
}
utils.inherits(DataLengthProbe, GenericWorker);
/**
* @see GenericWorker.processChunk
*/
DataLengthProbe.prototype.processChunk = function (chunk) {
if(chunk) {
var length = this.streamInfo[this.propName] || 0;
this.streamInfo[this.propName] = length + chunk.data.length;
}
GenericWorker.prototype.processChunk.call(this, chunk);
};
module.exports = DataLengthProbe;
/***/ }),
/***/ "./node_modules/jszip/lib/stream/DataWorker.js":
/*!*****************************************************!*\
!*** ./node_modules/jszip/lib/stream/DataWorker.js ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
var GenericWorker = __webpack_require__(/*! ./GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
// the size of the generated chunks
// TODO expose this as a public variable
var DEFAULT_BLOCK_SIZE = 16 * 1024;
/**
* A worker that reads a content and emits chunks.
* @constructor
* @param {Promise} dataP the promise of the data to split
*/
function DataWorker(dataP) {
GenericWorker.call(this, "DataWorker");
var self = this;
this.dataIsReady = false;
this.index = 0;
this.max = 0;
this.data = null;
this.type = "";
this._tickScheduled = false;
dataP.then(function (data) {
self.dataIsReady = true;
self.data = data;
self.max = data && data.length || 0;
self.type = utils.getTypeOf(data);
if(!self.isPaused) {
self._tickAndRepeat();
}
}, function (e) {
self.error(e);
});
}
utils.inherits(DataWorker, GenericWorker);
/**
* @see GenericWorker.cleanUp
*/
DataWorker.prototype.cleanUp = function () {
GenericWorker.prototype.cleanUp.call(this);
this.data = null;
};
/**
* @see GenericWorker.resume
*/
DataWorker.prototype.resume = function () {
if(!GenericWorker.prototype.resume.call(this)) {
return false;
}
if (!this._tickScheduled && this.dataIsReady) {
this._tickScheduled = true;
utils.delay(this._tickAndRepeat, [], this);
}
return true;
};
/**
* Trigger a tick a schedule an other call to this function.
*/
DataWorker.prototype._tickAndRepeat = function() {
this._tickScheduled = false;
if(this.isPaused || this.isFinished) {
return;
}
this._tick();
if(!this.isFinished) {
utils.delay(this._tickAndRepeat, [], this);
this._tickScheduled = true;
}
};
/**
* Read and push a chunk.
*/
DataWorker.prototype._tick = function() {
if(this.isPaused || this.isFinished) {
return false;
}
var size = DEFAULT_BLOCK_SIZE;
var data = null, nextIndex = Math.min(this.max, this.index + size);
if (this.index >= this.max) {
// EOF
return this.end();
} else {
switch(this.type) {
case "string":
data = this.data.substring(this.index, nextIndex);
break;
case "uint8array":
data = this.data.subarray(this.index, nextIndex);
break;
case "array":
case "nodebuffer":
data = this.data.slice(this.index, nextIndex);
break;
}
this.index = nextIndex;
return this.push({
data : data,
meta : {
percent : this.max ? this.index / this.max * 100 : 0
}
});
}
};
module.exports = DataWorker;
/***/ }),
/***/ "./node_modules/jszip/lib/stream/GenericWorker.js":
/*!********************************************************!*\
!*** ./node_modules/jszip/lib/stream/GenericWorker.js ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* A worker that does nothing but passing chunks to the next one. This is like
* a nodejs stream but with some differences. On the good side :
* - it works on IE 6-9 without any issue / polyfill
* - it weights less than the full dependencies bundled with browserify
* - it forwards errors (no need to declare an error handler EVERYWHERE)
*
* A chunk is an object with 2 attributes : `meta` and `data`. The former is an
* object containing anything (`percent` for example), see each worker for more
* details. The latter is the real data (String, Uint8Array, etc).
*
* @constructor
* @param {String} name the name of the stream (mainly used for debugging purposes)
*/
function GenericWorker(name) {
// the name of the worker
this.name = name || "default";
// an object containing metadata about the workers chain
this.streamInfo = {};
// an error which happened when the worker was paused
this.generatedError = null;
// an object containing metadata to be merged by this worker into the general metadata
this.extraStreamInfo = {};
// true if the stream is paused (and should not do anything), false otherwise
this.isPaused = true;
// true if the stream is finished (and should not do anything), false otherwise
this.isFinished = false;
// true if the stream is locked to prevent further structure updates (pipe), false otherwise
this.isLocked = false;
// the event listeners
this._listeners = {
'data':[],
'end':[],
'error':[]
};
// the previous worker, if any
this.previous = null;
}
GenericWorker.prototype = {
/**
* Push a chunk to the next workers.
* @param {Object} chunk the chunk to push
*/
push : function (chunk) {
this.emit("data", chunk);
},
/**
* End the stream.
* @return {Boolean} true if this call ended the worker, false otherwise.
*/
end : function () {
if (this.isFinished) {
return false;
}
this.flush();
try {
this.emit("end");
this.cleanUp();
this.isFinished = true;
} catch (e) {
this.emit("error", e);
}
return true;
},
/**
* End the stream with an error.
* @param {Error} e the error which caused the premature end.
* @return {Boolean} true if this call ended the worker with an error, false otherwise.
*/
error : function (e) {
if (this.isFinished) {
return false;
}
if(this.isPaused) {
this.generatedError = e;
} else {
this.isFinished = true;
this.emit("error", e);
// in the workers chain exploded in the middle of the chain,
// the error event will go downward but we also need to notify
// workers upward that there has been an error.
if(this.previous) {
this.previous.error(e);
}
this.cleanUp();
}
return true;
},
/**
* Add a callback on an event.
* @param {String} name the name of the event (data, end, error)
* @param {Function} listener the function to call when the event is triggered
* @return {GenericWorker} the current object for chainability
*/
on : function (name, listener) {
this._listeners[name].push(listener);
return this;
},
/**
* Clean any references when a worker is ending.
*/
cleanUp : function () {
this.streamInfo = this.generatedError = this.extraStreamInfo = null;
this._listeners = [];
},
/**
* Trigger an event. This will call registered callback with the provided arg.
* @param {String} name the name of the event (data, end, error)
* @param {Object} arg the argument to call the callback with.
*/
emit : function (name, arg) {
if (this._listeners[name]) {
for(var i = 0; i < this._listeners[name].length; i++) {
this._listeners[name][i].call(this, arg);
}
}
},
/**
* Chain a worker with an other.
* @param {Worker} next the worker receiving events from the current one.
* @return {worker} the next worker for chainability
*/
pipe : function (next) {
return next.registerPrevious(this);
},
/**
* Same as `pipe` in the other direction.
* Using an API with `pipe(next)` is very easy.
* Implementing the API with the point of view of the next one registering
* a source is easier, see the ZipFileWorker.
* @param {Worker} previous the previous worker, sending events to this one
* @return {Worker} the current worker for chainability
*/
registerPrevious : function (previous) {
if (this.isLocked) {
throw new Error("The stream '" + this + "' has already been used.");
}
// sharing the streamInfo...
this.streamInfo = previous.streamInfo;
// ... and adding our own bits
this.mergeStreamInfo();
this.previous = previous;
var self = this;
previous.on('data', function (chunk) {
self.processChunk(chunk);
});
previous.on('end', function () {
self.end();
});
previous.on('error', function (e) {
self.error(e);
});
return this;
},
/**
* Pause the stream so it doesn't send events anymore.
* @return {Boolean} true if this call paused the worker, false otherwise.
*/
pause : function () {
if(this.isPaused || this.isFinished) {
return false;
}
this.isPaused = true;
if(this.previous) {
this.previous.pause();
}
return true;
},
/**
* Resume a paused stream.
* @return {Boolean} true if this call resumed the worker, false otherwise.
*/
resume : function () {
if(!this.isPaused || this.isFinished) {
return false;
}
this.isPaused = false;
// if true, the worker tried to resume but failed
var withError = false;
if(this.generatedError) {
this.error(this.generatedError);
withError = true;
}
if(this.previous) {
this.previous.resume();
}
return !withError;
},
/**
* Flush any remaining bytes as the stream is ending.
*/
flush : function () {},
/**
* Process a chunk. This is usually the method overridden.
* @param {Object} chunk the chunk to process.
*/
processChunk : function(chunk) {
this.push(chunk);
},
/**
* Add a key/value to be added in the workers chain streamInfo once activated.
* @param {String} key the key to use
* @param {Object} value the associated value
* @return {Worker} the current worker for chainability
*/
withStreamInfo : function (key, value) {
this.extraStreamInfo[key] = value;
this.mergeStreamInfo();
return this;
},
/**
* Merge this worker's streamInfo into the chain's streamInfo.
*/
mergeStreamInfo : function () {
for(var key in this.extraStreamInfo) {
if (!this.extraStreamInfo.hasOwnProperty(key)) {
continue;
}
this.streamInfo[key] = this.extraStreamInfo[key];
}
},
/**
* Lock the stream to prevent further updates on the workers chain.
* After calling this method, all calls to pipe will fail.
*/
lock: function () {
if (this.isLocked) {
throw new Error("The stream '" + this + "' has already been used.");
}
this.isLocked = true;
if (this.previous) {
this.previous.lock();
}
},
/**
*
* Pretty print the workers chain.
*/
toString : function () {
var me = "Worker " + this.name;
if (this.previous) {
return this.previous + " -> " + me;
} else {
return me;
}
}
};
module.exports = GenericWorker;
/***/ }),
/***/ "./node_modules/jszip/lib/stream/StreamHelper.js":
/*!*******************************************************!*\
!*** ./node_modules/jszip/lib/stream/StreamHelper.js ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Buffer) {
var utils = __webpack_require__(/*! ../utils */ "./node_modules/jszip/lib/utils.js");
var ConvertWorker = __webpack_require__(/*! ./ConvertWorker */ "./node_modules/jszip/lib/stream/ConvertWorker.js");
var GenericWorker = __webpack_require__(/*! ./GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
var base64 = __webpack_require__(/*! ../base64 */ "./node_modules/jszip/lib/base64.js");
var support = __webpack_require__(/*! ../support */ "./node_modules/jszip/lib/support.js");
var external = __webpack_require__(/*! ../external */ "./node_modules/jszip/lib/external.js");
var NodejsStreamOutputAdapter = null;
if (support.nodestream) {
try {
NodejsStreamOutputAdapter = __webpack_require__(/*! ../nodejs/NodejsStreamOutputAdapter */ "./node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js");
} catch(e) {}
}
/**
* Apply the final transformation of the data. If the user wants a Blob for
* example, it's easier to work with an U8intArray and finally do the
* ArrayBuffer/Blob conversion.
* @param {String} type the name of the final type
* @param {String|Uint8Array|Buffer} content the content to transform
* @param {String} mimeType the mime type of the content, if applicable.
* @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the content in the right format.
*/
function transformZipOutput(type, content, mimeType) {
switch(type) {
case "blob" :
return utils.newBlob(utils.transformTo("arraybuffer", content), mimeType);
case "base64" :
return base64.encode(content);
default :
return utils.transformTo(type, content);
}
}
/**
* Concatenate an array of data of the given type.
* @param {String} type the type of the data in the given array.
* @param {Array} dataArray the array containing the data chunks to concatenate
* @return {String|Uint8Array|Buffer} the concatenated data
* @throws Error if the asked type is unsupported
*/
function concat (type, dataArray) {
var i, index = 0, res = null, totalLength = 0;
for(i = 0; i < dataArray.length; i++) {
totalLength += dataArray[i].length;
}
switch(type) {
case "string":
return dataArray.join("");
case "array":
return Array.prototype.concat.apply([], dataArray);
case "uint8array":
res = new Uint8Array(totalLength);
for(i = 0; i < dataArray.length; i++) {
res.set(dataArray[i], index);
index += dataArray[i].length;
}
return res;
case "nodebuffer":
return Buffer.concat(dataArray);
default:
throw new Error("concat : unsupported type '" + type + "'");
}
}
/**
* Listen a StreamHelper, accumulate its content and concatenate it into a
* complete block.
* @param {StreamHelper} helper the helper to use.
* @param {Function} updateCallback a callback called on each update. Called
* with one arg :
* - the metadata linked to the update received.
* @return Promise the promise for the accumulation.
*/
function accumulate(helper, updateCallback) {
return new external.Promise(function (resolve, reject){
var dataArray = [];
var chunkType = helper._internalType,
resultType = helper._outputType,
mimeType = helper._mimeType;
helper
.on('data', function (data, meta) {
dataArray.push(data);
if(updateCallback) {
updateCallback(meta);
}
})
.on('error', function(err) {
dataArray = [];
reject(err);
})
.on('end', function (){
try {
var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);
resolve(result);
} catch (e) {
reject(e);
}
dataArray = [];
})
.resume();
});
}
/**
* An helper to easily use workers outside of JSZip.
* @constructor
* @param {Worker} worker the worker to wrap
* @param {String} outputType the type of data expected by the use
* @param {String} mimeType the mime type of the content, if applicable.
*/
function StreamHelper(worker, outputType, mimeType) {
var internalType = outputType;
switch(outputType) {
case "blob":
case "arraybuffer":
internalType = "uint8array";
break;
case "base64":
internalType = "string";
break;
}
try {
// the type used internally
this._internalType = internalType;
// the type used to output results
this._outputType = outputType;
// the mime type
this._mimeType = mimeType;
utils.checkSupport(internalType);
this._worker = worker.pipe(new ConvertWorker(internalType));
// the last workers can be rewired without issues but we need to
// prevent any updates on previous workers.
worker.lock();
} catch(e) {
this._worker = new GenericWorker("error");
this._worker.error(e);
}
}
StreamHelper.prototype = {
/**
* Listen a StreamHelper, accumulate its content and concatenate it into a
* complete block.
* @param {Function} updateCb the update callback.
* @return Promise the promise for the accumulation.
*/
accumulate : function (updateCb) {
return accumulate(this, updateCb);
},
/**
* Add a listener on an event triggered on a stream.
* @param {String} evt the name of the event
* @param {Function} fn the listener
* @return {StreamHelper} the current helper.
*/
on : function (evt, fn) {
var self = this;
if(evt === "data") {
this._worker.on(evt, function (chunk) {
fn.call(self, chunk.data, chunk.meta);
});
} else {
this._worker.on(evt, function () {
utils.delay(fn, arguments, self);
});
}
return this;
},
/**
* Resume the flow of chunks.
* @return {StreamHelper} the current helper.
*/
resume : function () {
utils.delay(this._worker.resume, [], this._worker);
return this;
},
/**
* Pause the flow of chunks.
* @return {StreamHelper} the current helper.
*/
pause : function () {
this._worker.pause();
return this;
},
/**
* Return a nodejs stream for this helper.
* @param {Function} updateCb the update callback.
* @return {NodejsStreamOutputAdapter} the nodejs stream.
*/
toNodejsStream : function (updateCb) {
utils.checkSupport("nodestream");
if (this._outputType !== "nodebuffer") {
// an object stream containing blob/arraybuffer/uint8array/string
// is strange and I don't know if it would be useful.
// I you find this comment and have a good usecase, please open a
// bug report !
throw new Error(this._outputType + " is not supported by this method");
}
return new NodejsStreamOutputAdapter(this, {
objectMode : this._outputType !== "nodebuffer"
}, updateCb);
}
};
module.exports = StreamHelper;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/node_modules/buffer/index.js */ "./node_modules/webpack/node_modules/buffer/index.js").Buffer))
/***/ }),
/***/ "./node_modules/jszip/lib/support.js":
/*!*******************************************!*\
!*** ./node_modules/jszip/lib/support.js ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Buffer) {
exports.base64 = true;
exports.array = true;
exports.string = true;
exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
exports.nodebuffer = typeof Buffer !== "undefined";
// contains true if JSZip can read/generate Uint8Array, false otherwise.
exports.uint8array = typeof Uint8Array !== "undefined";
if (typeof ArrayBuffer === "undefined") {
exports.blob = false;
}
else {
var buffer = new ArrayBuffer(0);
try {
exports.blob = new Blob([buffer], {
type: "application/zip"
}).size === 0;
}
catch (e) {
try {
var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
var builder = new Builder();
builder.append(buffer);
exports.blob = builder.getBlob('application/zip').size === 0;
}
catch (e) {
exports.blob = false;
}
}
}
try {
exports.nodestream = !!__webpack_require__(/*! readable-stream */ "./node_modules/jszip/lib/readable-stream-browser.js").Readable;
} catch(e) {
exports.nodestream = false;
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/node_modules/buffer/index.js */ "./node_modules/webpack/node_modules/buffer/index.js").Buffer))
/***/ }),
/***/ "./node_modules/jszip/lib/utf8.js":
/*!****************************************!*\
!*** ./node_modules/jszip/lib/utf8.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
var support = __webpack_require__(/*! ./support */ "./node_modules/jszip/lib/support.js");
var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ "./node_modules/jszip/lib/nodejsUtils.js");
var GenericWorker = __webpack_require__(/*! ./stream/GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
/**
* The following functions come from pako, from pako/lib/utils/strings
* released under the MIT license, see pako https://github.com/nodeca/pako/
*/
// Table with utf8 lengths (calculated by first byte of sequence)
// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
// because max possible codepoint is 0x10ffff
var _utf8len = new Array(256);
for (var i=0; i<256; i++) {
_utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);
}
_utf8len[254]=_utf8len[254]=1; // Invalid sequence start
// convert string to array (typed, when possible)
var string2buf = function (str) {
var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
// count binary size
for (m_pos = 0; m_pos < str_len; m_pos++) {
c = str.charCodeAt(m_pos);
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {
c2 = str.charCodeAt(m_pos+1);
if ((c2 & 0xfc00) === 0xdc00) {
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
m_pos++;
}
}
buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
}
// allocate buffer
if (support.uint8array) {
buf = new Uint8Array(buf_len);
} else {
buf = new Array(buf_len);
}
// convert
for (i=0, m_pos = 0; i < buf_len; m_pos++) {
c = str.charCodeAt(m_pos);
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {
c2 = str.charCodeAt(m_pos+1);
if ((c2 & 0xfc00) === 0xdc00) {
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
m_pos++;
}
}
if (c < 0x80) {
/* one byte */
buf[i++] = c;
} else if (c < 0x800) {
/* two bytes */
buf[i++] = 0xC0 | (c >>> 6);
buf[i++] = 0x80 | (c & 0x3f);
} else if (c < 0x10000) {
/* three bytes */
buf[i++] = 0xE0 | (c >>> 12);
buf[i++] = 0x80 | (c >>> 6 & 0x3f);
buf[i++] = 0x80 | (c & 0x3f);
} else {
/* four bytes */
buf[i++] = 0xf0 | (c >>> 18);
buf[i++] = 0x80 | (c >>> 12 & 0x3f);
buf[i++] = 0x80 | (c >>> 6 & 0x3f);
buf[i++] = 0x80 | (c & 0x3f);
}
}
return buf;
};
// Calculate max possible position in utf8 buffer,
// that will not break sequence. If that's not possible
// - (very small limits) return max size as is.
//
// buf[] - utf8 bytes array
// max - length limit (mandatory);
var utf8border = function(buf, max) {
var pos;
max = max || buf.length;
if (max > buf.length) { max = buf.length; }
// go back from last position, until start of sequence found
pos = max-1;
while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
// Fuckup - very small and broken sequence,
// return max, because we should return something anyway.
if (pos < 0) { return max; }
// If we came to start of buffer - that means vuffer is too small,
// return max too.
if (pos === 0) { return max; }
return (pos + _utf8len[buf[pos]] > max) ? pos : max;
};
// convert array to string
var buf2string = function (buf) {
var str, i, out, c, c_len;
var len = buf.length;
// Reserve max possible length (2 words per char)
// NB: by unknown reasons, Array is significantly faster for
// String.fromCharCode.apply than Uint16Array.
var utf16buf = new Array(len*2);
for (out=0, i=0; i 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; }
// apply mask on first byte
c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
// join the rest
while (c_len > 1 && i < len) {
c = (c << 6) | (buf[i++] & 0x3f);
c_len--;
}
// terminated by end of string?
if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }
if (c < 0x10000) {
utf16buf[out++] = c;
} else {
c -= 0x10000;
utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);
utf16buf[out++] = 0xdc00 | (c & 0x3ff);
}
}
// shrinkBuf(utf16buf, out)
if (utf16buf.length !== out) {
if(utf16buf.subarray) {
utf16buf = utf16buf.subarray(0, out);
} else {
utf16buf.length = out;
}
}
// return String.fromCharCode.apply(null, utf16buf);
return utils.applyFromCharCode(utf16buf);
};
// That's all for the pako functions.
/**
* Transform a javascript string into an array (typed if possible) of bytes,
* UTF-8 encoded.
* @param {String} str the string to encode
* @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.
*/
exports.utf8encode = function utf8encode(str) {
if (support.nodebuffer) {
return nodejsUtils.newBufferFrom(str, "utf-8");
}
return string2buf(str);
};
/**
* Transform a bytes array (or a representation) representing an UTF-8 encoded
* string into a javascript string.
* @param {Array|Uint8Array|Buffer} buf the data de decode
* @return {String} the decoded string.
*/
exports.utf8decode = function utf8decode(buf) {
if (support.nodebuffer) {
return utils.transformTo("nodebuffer", buf).toString("utf-8");
}
buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf);
return buf2string(buf);
};
/**
* A worker to decode utf8 encoded binary chunks into string chunks.
* @constructor
*/
function Utf8DecodeWorker() {
GenericWorker.call(this, "utf-8 decode");
// the last bytes if a chunk didn't end with a complete codepoint.
this.leftOver = null;
}
utils.inherits(Utf8DecodeWorker, GenericWorker);
/**
* @see GenericWorker.processChunk
*/
Utf8DecodeWorker.prototype.processChunk = function (chunk) {
var data = utils.transformTo(support.uint8array ? "uint8array" : "array", chunk.data);
// 1st step, re-use what's left of the previous chunk
if (this.leftOver && this.leftOver.length) {
if(support.uint8array) {
var previousData = data;
data = new Uint8Array(previousData.length + this.leftOver.length);
data.set(this.leftOver, 0);
data.set(previousData, this.leftOver.length);
} else {
data = this.leftOver.concat(data);
}
this.leftOver = null;
}
var nextBoundary = utf8border(data);
var usableData = data;
if (nextBoundary !== data.length) {
if (support.uint8array) {
usableData = data.subarray(0, nextBoundary);
this.leftOver = data.subarray(nextBoundary, data.length);
} else {
usableData = data.slice(0, nextBoundary);
this.leftOver = data.slice(nextBoundary, data.length);
}
}
this.push({
data : exports.utf8decode(usableData),
meta : chunk.meta
});
};
/**
* @see GenericWorker.flush
*/
Utf8DecodeWorker.prototype.flush = function () {
if(this.leftOver && this.leftOver.length) {
this.push({
data : exports.utf8decode(this.leftOver),
meta : {}
});
this.leftOver = null;
}
};
exports.Utf8DecodeWorker = Utf8DecodeWorker;
/**
* A worker to endcode string chunks into utf8 encoded binary chunks.
* @constructor
*/
function Utf8EncodeWorker() {
GenericWorker.call(this, "utf-8 encode");
}
utils.inherits(Utf8EncodeWorker, GenericWorker);
/**
* @see GenericWorker.processChunk
*/
Utf8EncodeWorker.prototype.processChunk = function (chunk) {
this.push({
data : exports.utf8encode(chunk.data),
meta : chunk.meta
});
};
exports.Utf8EncodeWorker = Utf8EncodeWorker;
/***/ }),
/***/ "./node_modules/jszip/lib/utils.js":
/*!*****************************************!*\
!*** ./node_modules/jszip/lib/utils.js ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var support = __webpack_require__(/*! ./support */ "./node_modules/jszip/lib/support.js");
var base64 = __webpack_require__(/*! ./base64 */ "./node_modules/jszip/lib/base64.js");
var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ "./node_modules/jszip/lib/nodejsUtils.js");
var setImmediate = __webpack_require__(/*! core-js/library/fn/set-immediate */ "./node_modules/jszip/node_modules/core-js/library/fn/set-immediate.js");
var external = __webpack_require__(/*! ./external */ "./node_modules/jszip/lib/external.js");
/**
* Convert a string that pass as a "binary string": it should represent a byte
* array but may have > 255 char codes. Be sure to take only the first byte
* and returns the byte array.
* @param {String} str the string to transform.
* @return {Array|Uint8Array} the string in a binary format.
*/
function string2binary(str) {
var result = null;
if (support.uint8array) {
result = new Uint8Array(str.length);
} else {
result = new Array(str.length);
}
return stringToArrayLike(str, result);
}
/**
* Create a new blob with the given content and the given type.
* @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use
* an Uint8Array because the stock browser of android 4 won't accept it (it
* will be silently converted to a string, "[object Uint8Array]").
*
* Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:
* when a large amount of Array is used to create the Blob, the amount of
* memory consumed is nearly 100 times the original data amount.
*
* @param {String} type the mime type of the blob.
* @return {Blob} the created blob.
*/
exports.newBlob = function(part, type) {
exports.checkSupport("blob");
try {
// Blob constructor
return new Blob([part], {
type: type
});
}
catch (e) {
try {
// deprecated, browser only, old way
var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
var builder = new Builder();
builder.append(part);
return builder.getBlob(type);
}
catch (e) {
// well, fuck ?!
throw new Error("Bug : can't construct the Blob.");
}
}
};
/**
* The identity function.
* @param {Object} input the input.
* @return {Object} the same input.
*/
function identity(input) {
return input;
}
/**
* Fill in an array with a string.
* @param {String} str the string to use.
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).
* @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.
*/
function stringToArrayLike(str, array) {
for (var i = 0; i < str.length; ++i) {
array[i] = str.charCodeAt(i) & 0xFF;
}
return array;
}
/**
* An helper for the function arrayLikeToString.
* This contains static informations and functions that
* can be optimized by the browser JIT compiler.
*/
var arrayToStringHelper = {
/**
* Transform an array of int into a string, chunk by chunk.
* See the performances notes on arrayLikeToString.
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
* @param {String} type the type of the array.
* @param {Integer} chunk the chunk size.
* @return {String} the resulting string.
* @throws Error if the chunk is too big for the stack.
*/
stringifyByChunk: function(array, type, chunk) {
var result = [], k = 0, len = array.length;
// shortcut
if (len <= chunk) {
return String.fromCharCode.apply(null, array);
}
while (k < len) {
if (type === "array" || type === "nodebuffer") {
result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
}
else {
result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
}
k += chunk;
}
return result.join("");
},
/**
* Call String.fromCharCode on every item in the array.
* This is the naive implementation, which generate A LOT of intermediate string.
* This should be used when everything else fail.
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
* @return {String} the result.
*/
stringifyByChar: function(array){
var resultStr = "";
for(var i = 0; i < array.length; i++) {
resultStr += String.fromCharCode(array[i]);
}
return resultStr;
},
applyCanBeUsed : {
/**
* true if the browser accepts to use String.fromCharCode on Uint8Array
*/
uint8array : (function () {
try {
return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
} catch (e) {
return false;
}
})(),
/**
* true if the browser accepts to use String.fromCharCode on nodejs Buffer.
*/
nodebuffer : (function () {
try {
return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;
} catch (e) {
return false;
}
})()
}
};
/**
* Transform an array-like object to a string.
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
* @return {String} the result.
*/
function arrayLikeToString(array) {
// Performances notes :
// --------------------
// String.fromCharCode.apply(null, array) is the fastest, see
// see http://jsperf.com/converting-a-uint8array-to-a-string/2
// but the stack is limited (and we can get huge arrays !).
//
// result += String.fromCharCode(array[i]); generate too many strings !
//
// This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
// TODO : we now have workers that split the work. Do we still need that ?
var chunk = 65536,
type = exports.getTypeOf(array),
canUseApply = true;
if (type === "uint8array") {
canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;
} else if (type === "nodebuffer") {
canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;
}
if (canUseApply) {
while (chunk > 1) {
try {
return arrayToStringHelper.stringifyByChunk(array, type, chunk);
} catch (e) {
chunk = Math.floor(chunk / 2);
}
}
}
// no apply or chunk error : slow and painful algorithm
// default browser on android 4.*
return arrayToStringHelper.stringifyByChar(array);
}
exports.applyFromCharCode = arrayLikeToString;
/**
* Copy the data from an array-like to an other array-like.
* @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.
* @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.
* @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.
*/
function arrayLikeToArrayLike(arrayFrom, arrayTo) {
for (var i = 0; i < arrayFrom.length; i++) {
arrayTo[i] = arrayFrom[i];
}
return arrayTo;
}
// a matrix containing functions to transform everything into everything.
var transform = {};
// string to ?
transform["string"] = {
"string": identity,
"array": function(input) {
return stringToArrayLike(input, new Array(input.length));
},
"arraybuffer": function(input) {
return transform["string"]["uint8array"](input).buffer;
},
"uint8array": function(input) {
return stringToArrayLike(input, new Uint8Array(input.length));
},
"nodebuffer": function(input) {
return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));
}
};
// array to ?
transform["array"] = {
"string": arrayLikeToString,
"array": identity,
"arraybuffer": function(input) {
return (new Uint8Array(input)).buffer;
},
"uint8array": function(input) {
return new Uint8Array(input);
},
"nodebuffer": function(input) {
return nodejsUtils.newBufferFrom(input);
}
};
// arraybuffer to ?
transform["arraybuffer"] = {
"string": function(input) {
return arrayLikeToString(new Uint8Array(input));
},
"array": function(input) {
return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
},
"arraybuffer": identity,
"uint8array": function(input) {
return new Uint8Array(input);
},
"nodebuffer": function(input) {
return nodejsUtils.newBufferFrom(new Uint8Array(input));
}
};
// uint8array to ?
transform["uint8array"] = {
"string": arrayLikeToString,
"array": function(input) {
return arrayLikeToArrayLike(input, new Array(input.length));
},
"arraybuffer": function(input) {
return input.buffer;
},
"uint8array": identity,
"nodebuffer": function(input) {
return nodejsUtils.newBufferFrom(input);
}
};
// nodebuffer to ?
transform["nodebuffer"] = {
"string": arrayLikeToString,
"array": function(input) {
return arrayLikeToArrayLike(input, new Array(input.length));
},
"arraybuffer": function(input) {
return transform["nodebuffer"]["uint8array"](input).buffer;
},
"uint8array": function(input) {
return arrayLikeToArrayLike(input, new Uint8Array(input.length));
},
"nodebuffer": identity
};
/**
* Transform an input into any type.
* The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.
* If no output type is specified, the unmodified input will be returned.
* @param {String} outputType the output type.
* @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.
* @throws {Error} an Error if the browser doesn't support the requested output type.
*/
exports.transformTo = function(outputType, input) {
if (!input) {
// undefined, null, etc
// an empty string won't harm.
input = "";
}
if (!outputType) {
return input;
}
exports.checkSupport(outputType);
var inputType = exports.getTypeOf(input);
var result = transform[inputType][outputType](input);
return result;
};
/**
* Return the type of the input.
* The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.
* @param {Object} input the input to identify.
* @return {String} the (lowercase) type of the input.
*/
exports.getTypeOf = function(input) {
if (typeof input === "string") {
return "string";
}
if (Object.prototype.toString.call(input) === "[object Array]") {
return "array";
}
if (support.nodebuffer && nodejsUtils.isBuffer(input)) {
return "nodebuffer";
}
if (support.uint8array && input instanceof Uint8Array) {
return "uint8array";
}
if (support.arraybuffer && input instanceof ArrayBuffer) {
return "arraybuffer";
}
};
/**
* Throw an exception if the type is not supported.
* @param {String} type the type to check.
* @throws {Error} an Error if the browser doesn't support the requested type.
*/
exports.checkSupport = function(type) {
var supported = support[type.toLowerCase()];
if (!supported) {
throw new Error(type + " is not supported by this platform");
}
};
exports.MAX_VALUE_16BITS = 65535;
exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1
/**
* Prettify a string read as binary.
* @param {string} str the string to prettify.
* @return {string} a pretty string.
*/
exports.pretty = function(str) {
var res = '',
code, i;
for (i = 0; i < (str || "").length; i++) {
code = str.charCodeAt(i);
res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
}
return res;
};
/**
* Defer the call of a function.
* @param {Function} callback the function to call asynchronously.
* @param {Array} args the arguments to give to the callback.
*/
exports.delay = function(callback, args, self) {
setImmediate(function () {
callback.apply(self || null, args || []);
});
};
/**
* Extends a prototype with an other, without calling a constructor with
* side effects. Inspired by nodejs' `utils.inherits`
* @param {Function} ctor the constructor to augment
* @param {Function} superCtor the parent constructor to use
*/
exports.inherits = function (ctor, superCtor) {
var Obj = function() {};
Obj.prototype = superCtor.prototype;
ctor.prototype = new Obj();
};
/**
* Merge the objects passed as parameters into a new one.
* @private
* @param {...Object} var_args All objects to merge.
* @return {Object} a new object with the data of the others.
*/
exports.extend = function() {
var result = {}, i, attr;
for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers
for (attr in arguments[i]) {
if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") {
result[attr] = arguments[i][attr];
}
}
}
return result;
};
/**
* Transform arbitrary content into a Promise.
* @param {String} name a name for the content being processed.
* @param {Object} inputData the content to process.
* @param {Boolean} isBinary true if the content is not an unicode string
* @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.
* @param {Boolean} isBase64 true if the string content is encoded with base64.
* @return {Promise} a promise in a format usable by JSZip.
*/
exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {
// if inputData is already a promise, this flatten it.
var promise = external.Promise.resolve(inputData).then(function(data) {
var isBlob = support.blob && (data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) !== -1);
if (isBlob && typeof FileReader !== "undefined") {
return new external.Promise(function (resolve, reject) {
var reader = new FileReader();
reader.onload = function(e) {
resolve(e.target.result);
};
reader.onerror = function(e) {
reject(e.target.error);
};
reader.readAsArrayBuffer(data);
});
} else {
return data;
}
});
return promise.then(function(data) {
var dataType = exports.getTypeOf(data);
if (!dataType) {
return external.Promise.reject(
new Error("Can't read the data of '" + name + "'. Is it " +
"in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?")
);
}
// special case : it's way easier to work with Uint8Array than with ArrayBuffer
if (dataType === "arraybuffer") {
data = exports.transformTo("uint8array", data);
} else if (dataType === "string") {
if (isBase64) {
data = base64.decode(data);
}
else if (isBinary) {
// optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask
if (isOptimizedBinaryString !== true) {
// this is a string, not in a base64 format.
// Be sure that this is a correct "binary string"
data = string2binary(data);
}
}
}
return data;
});
};
/***/ }),
/***/ "./node_modules/jszip/lib/zipEntries.js":
/*!**********************************************!*\
!*** ./node_modules/jszip/lib/zipEntries.js ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var readerFor = __webpack_require__(/*! ./reader/readerFor */ "./node_modules/jszip/lib/reader/readerFor.js");
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
var sig = __webpack_require__(/*! ./signature */ "./node_modules/jszip/lib/signature.js");
var ZipEntry = __webpack_require__(/*! ./zipEntry */ "./node_modules/jszip/lib/zipEntry.js");
var utf8 = __webpack_require__(/*! ./utf8 */ "./node_modules/jszip/lib/utf8.js");
var support = __webpack_require__(/*! ./support */ "./node_modules/jszip/lib/support.js");
// class ZipEntries {{{
/**
* All the entries in the zip file.
* @constructor
* @param {Object} loadOptions Options for loading the stream.
*/
function ZipEntries(loadOptions) {
this.files = [];
this.loadOptions = loadOptions;
}
ZipEntries.prototype = {
/**
* Check that the reader is on the specified signature.
* @param {string} expectedSignature the expected signature.
* @throws {Error} if it is an other signature.
*/
checkSignature: function(expectedSignature) {
if (!this.reader.readAndCheckSignature(expectedSignature)) {
this.reader.index -= 4;
var signature = this.reader.readString(4);
throw new Error("Corrupted zip or bug: unexpected signature " + "(" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");
}
},
/**
* Check if the given signature is at the given index.
* @param {number} askedIndex the index to check.
* @param {string} expectedSignature the signature to expect.
* @return {boolean} true if the signature is here, false otherwise.
*/
isSignature: function(askedIndex, expectedSignature) {
var currentIndex = this.reader.index;
this.reader.setIndex(askedIndex);
var signature = this.reader.readString(4);
var result = signature === expectedSignature;
this.reader.setIndex(currentIndex);
return result;
},
/**
* Read the end of the central directory.
*/
readBlockEndOfCentral: function() {
this.diskNumber = this.reader.readInt(2);
this.diskWithCentralDirStart = this.reader.readInt(2);
this.centralDirRecordsOnThisDisk = this.reader.readInt(2);
this.centralDirRecords = this.reader.readInt(2);
this.centralDirSize = this.reader.readInt(4);
this.centralDirOffset = this.reader.readInt(4);
this.zipCommentLength = this.reader.readInt(2);
// warning : the encoding depends of the system locale
// On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.
// On a windows machine, this field is encoded with the localized windows code page.
var zipComment = this.reader.readData(this.zipCommentLength);
var decodeParamType = support.uint8array ? "uint8array" : "array";
// To get consistent behavior with the generation part, we will assume that
// this is utf8 encoded unless specified otherwise.
var decodeContent = utils.transformTo(decodeParamType, zipComment);
this.zipComment = this.loadOptions.decodeFileName(decodeContent);
},
/**
* Read the end of the Zip 64 central directory.
* Not merged with the method readEndOfCentral :
* The end of central can coexist with its Zip64 brother,
* I don't want to read the wrong number of bytes !
*/
readBlockZip64EndOfCentral: function() {
this.zip64EndOfCentralSize = this.reader.readInt(8);
this.reader.skip(4);
// this.versionMadeBy = this.reader.readString(2);
// this.versionNeeded = this.reader.readInt(2);
this.diskNumber = this.reader.readInt(4);
this.diskWithCentralDirStart = this.reader.readInt(4);
this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
this.centralDirRecords = this.reader.readInt(8);
this.centralDirSize = this.reader.readInt(8);
this.centralDirOffset = this.reader.readInt(8);
this.zip64ExtensibleData = {};
var extraDataSize = this.zip64EndOfCentralSize - 44,
index = 0,
extraFieldId,
extraFieldLength,
extraFieldValue;
while (index < extraDataSize) {
extraFieldId = this.reader.readInt(2);
extraFieldLength = this.reader.readInt(4);
extraFieldValue = this.reader.readData(extraFieldLength);
this.zip64ExtensibleData[extraFieldId] = {
id: extraFieldId,
length: extraFieldLength,
value: extraFieldValue
};
}
},
/**
* Read the end of the Zip 64 central directory locator.
*/
readBlockZip64EndOfCentralLocator: function() {
this.diskWithZip64CentralDirStart = this.reader.readInt(4);
this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);
this.disksCount = this.reader.readInt(4);
if (this.disksCount > 1) {
throw new Error("Multi-volumes zip are not supported");
}
},
/**
* Read the local files, based on the offset read in the central part.
*/
readLocalFiles: function() {
var i, file;
for (i = 0; i < this.files.length; i++) {
file = this.files[i];
this.reader.setIndex(file.localHeaderOffset);
this.checkSignature(sig.LOCAL_FILE_HEADER);
file.readLocalPart(this.reader);
file.handleUTF8();
file.processAttributes();
}
},
/**
* Read the central directory.
*/
readCentralDir: function() {
var file;
this.reader.setIndex(this.centralDirOffset);
while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {
file = new ZipEntry({
zip64: this.zip64
}, this.loadOptions);
file.readCentralPart(this.reader);
this.files.push(file);
}
if (this.centralDirRecords !== this.files.length) {
if (this.centralDirRecords !== 0 && this.files.length === 0) {
// We expected some records but couldn't find ANY.
// This is really suspicious, as if something went wrong.
throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
} else {
// We found some records but not all.
// Something is wrong but we got something for the user: no error here.
// console.warn("expected", this.centralDirRecords, "records in central dir, got", this.files.length);
}
}
},
/**
* Read the end of central directory.
*/
readEndOfCentral: function() {
var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
if (offset < 0) {
// Check if the content is a truncated zip or complete garbage.
// A "LOCAL_FILE_HEADER" is not required at the beginning (auto
// extractible zip for example) but it can give a good hint.
// If an ajax request was used without responseType, we will also
// get unreadable data.
var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);
if (isGarbage) {
throw new Error("Can't find end of central directory : is this a zip file ? " +
"If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");
} else {
throw new Error("Corrupted zip: can't find end of central directory");
}
}
this.reader.setIndex(offset);
var endOfCentralDirOffset = offset;
this.checkSignature(sig.CENTRAL_DIRECTORY_END);
this.readBlockEndOfCentral();
/* extract from the zip spec :
4) If one of the fields in the end of central directory
record is too small to hold required data, the field
should be set to -1 (0xFFFF or 0xFFFFFFFF) and the
ZIP64 format record should be created.
5) The end of central directory record and the
Zip64 end of central directory locator record must
reside on the same disk when splitting or spanning
an archive.
*/
if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {
this.zip64 = true;
/*
Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from
the zip file can fit into a 32bits integer. This cannot be solved : JavaScript represents
all numbers as 64-bit double precision IEEE 754 floating point numbers.
So, we have 53bits for integers and bitwise operations treat everything as 32bits.
see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators
and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5
*/
// should look for a zip64 EOCD locator
offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
if (offset < 0) {
throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");
}
this.reader.setIndex(offset);
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
this.readBlockZip64EndOfCentralLocator();
// now the zip64 EOCD record
if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {
// console.warn("ZIP64 end of central directory not where expected.");
this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
if (this.relativeOffsetEndOfZip64CentralDir < 0) {
throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");
}
}
this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
this.readBlockZip64EndOfCentral();
}
var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;
if (this.zip64) {
expectedEndOfCentralDirOffset += 20; // end of central dir 64 locator
expectedEndOfCentralDirOffset += 12 /* should not include the leading 12 bytes */ + this.zip64EndOfCentralSize;
}
var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;
if (extraBytes > 0) {
// console.warn(extraBytes, "extra bytes at beginning or within zipfile");
if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {
// The offsets seem wrong, but we have something at the specified offset.
// So… we keep it.
} else {
// the offset is wrong, update the "zero" of the reader
// this happens if data has been prepended (crx files for example)
this.reader.zero = extraBytes;
}
} else if (extraBytes < 0) {
throw new Error("Corrupted zip: missing " + Math.abs(extraBytes) + " bytes.");
}
},
prepareReader: function(data) {
this.reader = readerFor(data);
},
/**
* Read a zip file and create ZipEntries.
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.
*/
load: function(data) {
this.prepareReader(data);
this.readEndOfCentral();
this.readCentralDir();
this.readLocalFiles();
}
};
// }}} end of ZipEntries
module.exports = ZipEntries;
/***/ }),
/***/ "./node_modules/jszip/lib/zipEntry.js":
/*!********************************************!*\
!*** ./node_modules/jszip/lib/zipEntry.js ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var readerFor = __webpack_require__(/*! ./reader/readerFor */ "./node_modules/jszip/lib/reader/readerFor.js");
var utils = __webpack_require__(/*! ./utils */ "./node_modules/jszip/lib/utils.js");
var CompressedObject = __webpack_require__(/*! ./compressedObject */ "./node_modules/jszip/lib/compressedObject.js");
var crc32fn = __webpack_require__(/*! ./crc32 */ "./node_modules/jszip/lib/crc32.js");
var utf8 = __webpack_require__(/*! ./utf8 */ "./node_modules/jszip/lib/utf8.js");
var compressions = __webpack_require__(/*! ./compressions */ "./node_modules/jszip/lib/compressions.js");
var support = __webpack_require__(/*! ./support */ "./node_modules/jszip/lib/support.js");
var MADE_BY_DOS = 0x00;
var MADE_BY_UNIX = 0x03;
/**
* Find a compression registered in JSZip.
* @param {string} compressionMethod the method magic to find.
* @return {Object|null} the JSZip compression object, null if none found.
*/
var findCompression = function(compressionMethod) {
for (var method in compressions) {
if (!compressions.hasOwnProperty(method)) {
continue;
}
if (compressions[method].magic === compressionMethod) {
return compressions[method];
}
}
return null;
};
// class ZipEntry {{{
/**
* An entry in the zip file.
* @constructor
* @param {Object} options Options of the current file.
* @param {Object} loadOptions Options for loading the stream.
*/
function ZipEntry(options, loadOptions) {
this.options = options;
this.loadOptions = loadOptions;
}
ZipEntry.prototype = {
/**
* say if the file is encrypted.
* @return {boolean} true if the file is encrypted, false otherwise.
*/
isEncrypted: function() {
// bit 1 is set
return (this.bitFlag & 0x0001) === 0x0001;
},
/**
* say if the file has utf-8 filename/comment.
* @return {boolean} true if the filename/comment is in utf-8, false otherwise.
*/
useUTF8: function() {
// bit 11 is set
return (this.bitFlag & 0x0800) === 0x0800;
},
/**
* Read the local part of a zip file and add the info in this object.
* @param {DataReader} reader the reader to use.
*/
readLocalPart: function(reader) {
var compression, localExtraFieldsLength;
// we already know everything from the central dir !
// If the central dir data are false, we are doomed.
// On the bright side, the local part is scary : zip64, data descriptors, both, etc.
// The less data we get here, the more reliable this should be.
// Let's skip the whole header and dash to the data !
reader.skip(22);
// in some zip created on windows, the filename stored in the central dir contains \ instead of /.
// Strangely, the filename here is OK.
// I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes
// or APPNOTE#4.4.17.1, "All slashes MUST be forward slashes '/'") but there are a lot of bad zip generators...
// Search "unzip mismatching "local" filename continuing with "central" filename version" on
// the internet.
//
// I think I see the logic here : the central directory is used to display
// content and the local directory is used to extract the files. Mixing / and \
// may be used to display \ to windows users and use / when extracting the files.
// Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394
this.fileNameLength = reader.readInt(2);
localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir
// the fileName is stored as binary data, the handleUTF8 method will take care of the encoding.
this.fileName = reader.readData(this.fileNameLength);
reader.skip(localExtraFieldsLength);
if (this.compressedSize === -1 || this.uncompressedSize === -1) {
throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory " + "(compressedSize === -1 || uncompressedSize === -1)");
}
compression = findCompression(this.compressionMethod);
if (compression === null) { // no compression found
throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + utils.transformTo("string", this.fileName) + ")");
}
this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));
},
/**
* Read the central part of a zip file and add the info in this object.
* @param {DataReader} reader the reader to use.
*/
readCentralPart: function(reader) {
this.versionMadeBy = reader.readInt(2);
reader.skip(2);
// this.versionNeeded = reader.readInt(2);
this.bitFlag = reader.readInt(2);
this.compressionMethod = reader.readString(2);
this.date = reader.readDate();
this.crc32 = reader.readInt(4);
this.compressedSize = reader.readInt(4);
this.uncompressedSize = reader.readInt(4);
var fileNameLength = reader.readInt(2);
this.extraFieldsLength = reader.readInt(2);
this.fileCommentLength = reader.readInt(2);
this.diskNumberStart = reader.readInt(2);
this.internalFileAttributes = reader.readInt(2);
this.externalFileAttributes = reader.readInt(4);
this.localHeaderOffset = reader.readInt(4);
if (this.isEncrypted()) {
throw new Error("Encrypted zip are not supported");
}
// will be read in the local part, see the comments there
reader.skip(fileNameLength);
this.readExtraFields(reader);
this.parseZIP64ExtraField(reader);
this.fileComment = reader.readData(this.fileCommentLength);
},
/**
* Parse the external file attributes and get the unix/dos permissions.
*/
processAttributes: function () {
this.unixPermissions = null;
this.dosPermissions = null;
var madeBy = this.versionMadeBy >> 8;
// Check if we have the DOS directory flag set.
// We look for it in the DOS and UNIX permissions
// but some unknown platform could set it as a compatibility flag.
this.dir = this.externalFileAttributes & 0x0010 ? true : false;
if(madeBy === MADE_BY_DOS) {
// first 6 bits (0 to 5)
this.dosPermissions = this.externalFileAttributes & 0x3F;
}
if(madeBy === MADE_BY_UNIX) {
this.unixPermissions = (this.externalFileAttributes >> 16) & 0xFFFF;
// the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);
}
// fail safe : if the name ends with a / it probably means a folder
if (!this.dir && this.fileNameStr.slice(-1) === '/') {
this.dir = true;
}
},
/**
* Parse the ZIP64 extra field and merge the info in the current ZipEntry.
* @param {DataReader} reader the reader to use.
*/
parseZIP64ExtraField: function(reader) {
if (!this.extraFields[0x0001]) {
return;
}
// should be something, preparing the extra reader
var extraReader = readerFor(this.extraFields[0x0001].value);
// I really hope that these 64bits integer can fit in 32 bits integer, because js
// won't let us have more.
if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
this.uncompressedSize = extraReader.readInt(8);
}
if (this.compressedSize === utils.MAX_VALUE_32BITS) {
this.compressedSize = extraReader.readInt(8);
}
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
this.localHeaderOffset = extraReader.readInt(8);
}
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
this.diskNumberStart = extraReader.readInt(4);
}
},
/**
* Read the central part of a zip file and add the info in this object.
* @param {DataReader} reader the reader to use.
*/
readExtraFields: function(reader) {
var end = reader.index + this.extraFieldsLength,
extraFieldId,
extraFieldLength,
extraFieldValue;
if (!this.extraFields) {
this.extraFields = {};
}
while (reader.index < end) {
extraFieldId = reader.readInt(2);
extraFieldLength = reader.readInt(2);
extraFieldValue = reader.readData(extraFieldLength);
this.extraFields[extraFieldId] = {
id: extraFieldId,
length: extraFieldLength,
value: extraFieldValue
};
}
},
/**
* Apply an UTF8 transformation if needed.
*/
handleUTF8: function() {
var decodeParamType = support.uint8array ? "uint8array" : "array";
if (this.useUTF8()) {
this.fileNameStr = utf8.utf8decode(this.fileName);
this.fileCommentStr = utf8.utf8decode(this.fileComment);
} else {
var upath = this.findExtraFieldUnicodePath();
if (upath !== null) {
this.fileNameStr = upath;
} else {
// ASCII text or unsupported code page
var fileNameByteArray = utils.transformTo(decodeParamType, this.fileName);
this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);
}
var ucomment = this.findExtraFieldUnicodeComment();
if (ucomment !== null) {
this.fileCommentStr = ucomment;
} else {
// ASCII text or unsupported code page
var commentByteArray = utils.transformTo(decodeParamType, this.fileComment);
this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);
}
}
},
/**
* Find the unicode path declared in the extra field, if any.
* @return {String} the unicode path, null otherwise.
*/
findExtraFieldUnicodePath: function() {
var upathField = this.extraFields[0x7075];
if (upathField) {
var extraReader = readerFor(upathField.value);
// wrong version
if (extraReader.readInt(1) !== 1) {
return null;
}
// the crc of the filename changed, this field is out of date.
if (crc32fn(this.fileName) !== extraReader.readInt(4)) {
return null;
}
return utf8.utf8decode(extraReader.readData(upathField.length - 5));
}
return null;
},
/**
* Find the unicode comment declared in the extra field, if any.
* @return {String} the unicode comment, null otherwise.
*/
findExtraFieldUnicodeComment: function() {
var ucommentField = this.extraFields[0x6375];
if (ucommentField) {
var extraReader = readerFor(ucommentField.value);
// wrong version
if (extraReader.readInt(1) !== 1) {
return null;
}
// the crc of the comment changed, this field is out of date.
if (crc32fn(this.fileComment) !== extraReader.readInt(4)) {
return null;
}
return utf8.utf8decode(extraReader.readData(ucommentField.length - 5));
}
return null;
}
};
module.exports = ZipEntry;
/***/ }),
/***/ "./node_modules/jszip/lib/zipObject.js":
/*!*********************************************!*\
!*** ./node_modules/jszip/lib/zipObject.js ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var StreamHelper = __webpack_require__(/*! ./stream/StreamHelper */ "./node_modules/jszip/lib/stream/StreamHelper.js");
var DataWorker = __webpack_require__(/*! ./stream/DataWorker */ "./node_modules/jszip/lib/stream/DataWorker.js");
var utf8 = __webpack_require__(/*! ./utf8 */ "./node_modules/jszip/lib/utf8.js");
var CompressedObject = __webpack_require__(/*! ./compressedObject */ "./node_modules/jszip/lib/compressedObject.js");
var GenericWorker = __webpack_require__(/*! ./stream/GenericWorker */ "./node_modules/jszip/lib/stream/GenericWorker.js");
/**
* A simple object representing a file in the zip file.
* @constructor
* @param {string} name the name of the file
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data
* @param {Object} options the options of the file
*/
var ZipObject = function(name, data, options) {
this.name = name;
this.dir = options.dir;
this.date = options.date;
this.comment = options.comment;
this.unixPermissions = options.unixPermissions;
this.dosPermissions = options.dosPermissions;
this._data = data;
this._dataBinary = options.binary;
// keep only the compression
this.options = {
compression : options.compression,
compressionOptions : options.compressionOptions
};
};
ZipObject.prototype = {
/**
* Create an internal stream for the content of this object.
* @param {String} type the type of each chunk.
* @return StreamHelper the stream.
*/
internalStream: function (type) {
var result = null, outputType = "string";
try {
if (!type) {
throw new Error("No output type specified.");
}
outputType = type.toLowerCase();
var askUnicodeString = outputType === "string" || outputType === "text";
if (outputType === "binarystring" || outputType === "text") {
outputType = "string";
}
result = this._decompressWorker();
var isUnicodeString = !this._dataBinary;
if (isUnicodeString && !askUnicodeString) {
result = result.pipe(new utf8.Utf8EncodeWorker());
}
if (!isUnicodeString && askUnicodeString) {
result = result.pipe(new utf8.Utf8DecodeWorker());
}
} catch (e) {
result = new GenericWorker("error");
result.error(e);
}
return new StreamHelper(result, outputType, "");
},
/**
* Prepare the content in the asked type.
* @param {String} type the type of the result.
* @param {Function} onUpdate a function to call on each internal update.
* @return Promise the promise of the result.
*/
async: function (type, onUpdate) {
return this.internalStream(type).accumulate(onUpdate);
},
/**
* Prepare the content as a nodejs stream.
* @param {String} type the type of each chunk.
* @param {Function} onUpdate a function to call on each internal update.
* @return Stream the stream.
*/
nodeStream: function (type, onUpdate) {
return this.internalStream(type || "nodebuffer").toNodejsStream(onUpdate);
},
/**
* Return a worker for the compressed content.
* @private
* @param {Object} compression the compression object to use.
* @param {Object} compressionOptions the options to use when compressing.
* @return Worker the worker.
*/
_compressWorker: function (compression, compressionOptions) {
if (
this._data instanceof CompressedObject &&
this._data.compression.magic === compression.magic
) {
return this._data.getCompressedWorker();
} else {
var result = this._decompressWorker();
if(!this._dataBinary) {
result = result.pipe(new utf8.Utf8EncodeWorker());
}
return CompressedObject.createWorkerFrom(result, compression, compressionOptions);
}
},
/**
* Return a worker for the decompressed content.
* @private
* @return Worker the worker.
*/
_decompressWorker : function () {
if (this._data instanceof CompressedObject) {
return this._data.getContentWorker();
} else if (this._data instanceof GenericWorker) {
return this._data;
} else {
return new DataWorker(this._data);
}
}
};
var removedMethods = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"];
var removedFn = function () {
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
};
for(var i = 0; i < removedMethods.length; i++) {
ZipObject.prototype[removedMethods[i]] = removedFn;
}
module.exports = ZipObject;
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/fn/set-immediate.js":
/*!*****************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/fn/set-immediate.js ***!
\*****************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(/*! ../modules/web.immediate */ "./node_modules/jszip/node_modules/core-js/library/modules/web.immediate.js");
module.exports = __webpack_require__(/*! ../modules/_core */ "./node_modules/jszip/node_modules/core-js/library/modules/_core.js").setImmediate;
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_a-function.js":
/*!********************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_a-function.js ***!
\********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = function(it){
if(typeof it != 'function')throw TypeError(it + ' is not a function!');
return it;
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_an-object.js":
/*!*******************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_an-object.js ***!
\*******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(/*! ./_is-object */ "./node_modules/jszip/node_modules/core-js/library/modules/_is-object.js");
module.exports = function(it){
if(!isObject(it))throw TypeError(it + ' is not an object!');
return it;
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_cof.js":
/*!*************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_cof.js ***!
\*************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
var toString = {}.toString;
module.exports = function(it){
return toString.call(it).slice(8, -1);
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_core.js":
/*!**************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_core.js ***!
\**************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
var core = module.exports = {version: '2.3.0'};
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_ctx.js":
/*!*************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_ctx.js ***!
\*************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// optional / simple context binding
var aFunction = __webpack_require__(/*! ./_a-function */ "./node_modules/jszip/node_modules/core-js/library/modules/_a-function.js");
module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
};
case 2: return function(a, b){
return fn.call(that, a, b);
};
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
};
}
return function(/* ...args */){
return fn.apply(that, arguments);
};
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_descriptors.js":
/*!*********************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_descriptors.js ***!
\*********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
module.exports = !__webpack_require__(/*! ./_fails */ "./node_modules/jszip/node_modules/core-js/library/modules/_fails.js")(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_dom-create.js":
/*!********************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_dom-create.js ***!
\********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(/*! ./_is-object */ "./node_modules/jszip/node_modules/core-js/library/modules/_is-object.js")
, document = __webpack_require__(/*! ./_global */ "./node_modules/jszip/node_modules/core-js/library/modules/_global.js").document
// in old IE typeof document.createElement is 'object'
, is = isObject(document) && isObject(document.createElement);
module.exports = function(it){
return is ? document.createElement(it) : {};
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_export.js":
/*!****************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_export.js ***!
\****************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(/*! ./_global */ "./node_modules/jszip/node_modules/core-js/library/modules/_global.js")
, core = __webpack_require__(/*! ./_core */ "./node_modules/jszip/node_modules/core-js/library/modules/_core.js")
, ctx = __webpack_require__(/*! ./_ctx */ "./node_modules/jszip/node_modules/core-js/library/modules/_ctx.js")
, hide = __webpack_require__(/*! ./_hide */ "./node_modules/jszip/node_modules/core-js/library/modules/_hide.js")
, PROTOTYPE = 'prototype';
var $export = function(type, name, source){
var IS_FORCED = type & $export.F
, IS_GLOBAL = type & $export.G
, IS_STATIC = type & $export.S
, IS_PROTO = type & $export.P
, IS_BIND = type & $export.B
, IS_WRAP = type & $export.W
, exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
, expProto = exports[PROTOTYPE]
, target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
, key, own, out;
if(IS_GLOBAL)source = name;
for(key in source){
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
if(own && key in exports)continue;
// export native or passed
out = own ? target[key] : source[key];
// prevent global pollution for namespaces
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
// bind timers to global for call from export context
: IS_BIND && own ? ctx(out, global)
// wrap global constructors for prevent change them in library
: IS_WRAP && target[key] == out ? (function(C){
var F = function(a, b, c){
if(this instanceof C){
switch(arguments.length){
case 0: return new C;
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
// make static versions for prototype methods
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
if(IS_PROTO){
(exports.virtual || (exports.virtual = {}))[key] = out;
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
}
}
};
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_fails.js":
/*!***************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_fails.js ***!
\***************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = function(exec){
try {
return !!exec();
} catch(e){
return true;
}
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_global.js":
/*!****************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_global.js ***!
\****************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_hide.js":
/*!**************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_hide.js ***!
\**************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var dP = __webpack_require__(/*! ./_object-dp */ "./node_modules/jszip/node_modules/core-js/library/modules/_object-dp.js")
, createDesc = __webpack_require__(/*! ./_property-desc */ "./node_modules/jszip/node_modules/core-js/library/modules/_property-desc.js");
module.exports = __webpack_require__(/*! ./_descriptors */ "./node_modules/jszip/node_modules/core-js/library/modules/_descriptors.js") ? function(object, key, value){
return dP.f(object, key, createDesc(1, value));
} : function(object, key, value){
object[key] = value;
return object;
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_html.js":
/*!**************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_html.js ***!
\**************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! ./_global */ "./node_modules/jszip/node_modules/core-js/library/modules/_global.js").document && document.documentElement;
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_ie8-dom-define.js":
/*!************************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_ie8-dom-define.js ***!
\************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = !__webpack_require__(/*! ./_descriptors */ "./node_modules/jszip/node_modules/core-js/library/modules/_descriptors.js") && !__webpack_require__(/*! ./_fails */ "./node_modules/jszip/node_modules/core-js/library/modules/_fails.js")(function(){
return Object.defineProperty(__webpack_require__(/*! ./_dom-create */ "./node_modules/jszip/node_modules/core-js/library/modules/_dom-create.js")('div'), 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_invoke.js":
/*!****************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_invoke.js ***!
\****************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
// fast apply, http://jsperf.lnkit.com/fast-apply/5
module.exports = function(fn, args, that){
var un = that === undefined;
switch(args.length){
case 0: return un ? fn()
: fn.call(that);
case 1: return un ? fn(args[0])
: fn.call(that, args[0]);
case 2: return un ? fn(args[0], args[1])
: fn.call(that, args[0], args[1]);
case 3: return un ? fn(args[0], args[1], args[2])
: fn.call(that, args[0], args[1], args[2]);
case 4: return un ? fn(args[0], args[1], args[2], args[3])
: fn.call(that, args[0], args[1], args[2], args[3]);
} return fn.apply(that, args);
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_is-object.js":
/*!*******************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_is-object.js ***!
\*******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = function(it){
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_object-dp.js":
/*!*******************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_object-dp.js ***!
\*******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(/*! ./_an-object */ "./node_modules/jszip/node_modules/core-js/library/modules/_an-object.js")
, IE8_DOM_DEFINE = __webpack_require__(/*! ./_ie8-dom-define */ "./node_modules/jszip/node_modules/core-js/library/modules/_ie8-dom-define.js")
, toPrimitive = __webpack_require__(/*! ./_to-primitive */ "./node_modules/jszip/node_modules/core-js/library/modules/_to-primitive.js")
, dP = Object.defineProperty;
exports.f = __webpack_require__(/*! ./_descriptors */ "./node_modules/jszip/node_modules/core-js/library/modules/_descriptors.js") ? Object.defineProperty : function defineProperty(O, P, Attributes){
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if(IE8_DOM_DEFINE)try {
return dP(O, P, Attributes);
} catch(e){ /* empty */ }
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
if('value' in Attributes)O[P] = Attributes.value;
return O;
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_property-desc.js":
/*!***********************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_property-desc.js ***!
\***********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = function(bitmap, value){
return {
enumerable : !(bitmap & 1),
configurable: !(bitmap & 2),
writable : !(bitmap & 4),
value : value
};
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_task.js":
/*!**************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_task.js ***!
\**************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var ctx = __webpack_require__(/*! ./_ctx */ "./node_modules/jszip/node_modules/core-js/library/modules/_ctx.js")
, invoke = __webpack_require__(/*! ./_invoke */ "./node_modules/jszip/node_modules/core-js/library/modules/_invoke.js")
, html = __webpack_require__(/*! ./_html */ "./node_modules/jszip/node_modules/core-js/library/modules/_html.js")
, cel = __webpack_require__(/*! ./_dom-create */ "./node_modules/jszip/node_modules/core-js/library/modules/_dom-create.js")
, global = __webpack_require__(/*! ./_global */ "./node_modules/jszip/node_modules/core-js/library/modules/_global.js")
, process = global.process
, setTask = global.setImmediate
, clearTask = global.clearImmediate
, MessageChannel = global.MessageChannel
, counter = 0
, queue = {}
, ONREADYSTATECHANGE = 'onreadystatechange'
, defer, channel, port;
var run = function(){
var id = +this;
if(queue.hasOwnProperty(id)){
var fn = queue[id];
delete queue[id];
fn();
}
};
var listener = function(event){
run.call(event.data);
};
// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
if(!setTask || !clearTask){
setTask = function setImmediate(fn){
var args = [], i = 1;
while(arguments.length > i)args.push(arguments[i++]);
queue[++counter] = function(){
invoke(typeof fn == 'function' ? fn : Function(fn), args);
};
defer(counter);
return counter;
};
clearTask = function clearImmediate(id){
delete queue[id];
};
// Node.js 0.8-
if(__webpack_require__(/*! ./_cof */ "./node_modules/jszip/node_modules/core-js/library/modules/_cof.js")(process) == 'process'){
defer = function(id){
process.nextTick(ctx(run, id, 1));
};
// Browsers with MessageChannel, includes WebWorkers
} else if(MessageChannel){
channel = new MessageChannel;
port = channel.port2;
channel.port1.onmessage = listener;
defer = ctx(port.postMessage, port, 1);
// Browsers with postMessage, skip WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
defer = function(id){
global.postMessage(id + '', '*');
};
global.addEventListener('message', listener, false);
// IE8-
} else if(ONREADYSTATECHANGE in cel('script')){
defer = function(id){
html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
html.removeChild(this);
run.call(id);
};
};
// Rest old browsers
} else {
defer = function(id){
setTimeout(ctx(run, id, 1), 0);
};
}
}
module.exports = {
set: setTask,
clear: clearTask
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/_to-primitive.js":
/*!**********************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_to-primitive.js ***!
\**********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = __webpack_require__(/*! ./_is-object */ "./node_modules/jszip/node_modules/core-js/library/modules/_is-object.js");
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function(it, S){
if(!isObject(it))return it;
var fn, val;
if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to primitive value");
};
/***/ }),
/***/ "./node_modules/jszip/node_modules/core-js/library/modules/web.immediate.js":
/*!**********************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/web.immediate.js ***!
\**********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(/*! ./_export */ "./node_modules/jszip/node_modules/core-js/library/modules/_export.js")
, $task = __webpack_require__(/*! ./_task */ "./node_modules/jszip/node_modules/core-js/library/modules/_task.js");
$export($export.G + $export.B, {
setImmediate: $task.set,
clearImmediate: $task.clear
});
/***/ }),
/***/ "./node_modules/jszip/node_modules/immediate/lib/browser.js":
/*!******************************************************************!*\
!*** ./node_modules/jszip/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