'use strict'; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; /** * Determine the greatest common denominator */ function gcd(a, b) { if (b === 0) return a; return gcd(b, a % b); } /** * Reduce a numerator and denominator to it's smallest, integer ratio using Euclid's Algorithm */ function reduceRatio(numerator, denominator) { // from: http://pages.pacificcoast.net/~cazelais/euclid.html let temp; let divisor; if (!isInteger(numerator) || !isInteger(denominator)) return '? : ?'; if (numerator === denominator) return '1 : 1'; // make sure numerator is always the larger number if (+numerator < +denominator) { temp = numerator; numerator = denominator; denominator = temp; } divisor = gcd(+numerator, +denominator); return 'undefined' === typeof temp ? (numerator / divisor) + ' : ' + (denominator / divisor) : (denominator / divisor) + ' : ' + (numerator / divisor); } /** * Determine whether a value is an integer (ie. only numbers) */ function isInteger(value) { return /^[0-9]+$/.test(value); } let filmout; class FilmOut { constructor() { this.id = 'filmout'; this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4', '.gif']; this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp']; this.sequenceExtensions = ['.png', '.jpg', '.jpeg']; this.displays = []; this.state = { frame: 0, display: null }; } init() { this.listen(); } listen() { ipcRenderer.on(this.id, this.onFilmout.bind(this)); ipcRenderer.on('system', this.onSystem.bind(this)); ipcRenderer.on('preview_frame', this.onFrame.bind(this)); ipcRenderer.on('pre_export', this.onPreExport.bind(this)); ipcRenderer.on('pre_export_progress', this.onPreExportProgress.bind(this)); } onSystem(evt, args) { let option; for (let display of args.displays) { this.displays.push(display); option = $('