Added return types to Filmout library and added return types to comments where needed.

This commit is contained in:
Matt McWilliams 2021-03-19 12:09:03 -04:00
parent 394fbe2323
commit 3e0ac3f0d0
3 changed files with 26 additions and 15 deletions

View File

@ -92,11 +92,13 @@ class FilmOut {
}
/**
* Moves filmout a frame at a time.
*
* @returns {number} Time since start
**/
async move() {
let start = +new Date();
if (this.state.still) {
return false;
return -1;
}
if (this.state.dir) {
this.state.frame++;
@ -136,6 +138,8 @@ class FilmOut {
*
* @param {object} evt Original connect event
* @param {object} arg Arguments from ipc message
*
* @returns {boolean} Success state
**/
async onConnect(evt, arg) {
let frames = 0;
@ -240,7 +244,6 @@ class FilmOut {
return false;
}
}
console.dir(info);
this.state.frame = 0;
this.state.path = arg.path;
this.state.fileName = arg.fileName;
@ -265,13 +268,16 @@ class FilmOut {
this.log.info(`Opened ${this.state.fileName}`, 'FILMOUT', true, true);
this.log.info(`Frames : ${frames}`, 'FILMOUT', true, true);
this.state.enabled = true;
return await this.ui.send(this.id, { valid: true, state: JSON.stringify(this.state) });
await this.ui.send(this.id, { valid: true, state: JSON.stringify(this.state) });
return true;
}
/**
* Pre-export all frames from video for display.
*
* @param {object} evt IPC event
* @param {object} arg IPC args
*
* @returns {any} UI send call
*/
async onPreExport(evt, arg) {
if (!this.state.path) {

File diff suppressed because one or more lines are too long

View File

@ -102,11 +102,13 @@ class FilmOut {
}
/**
* Moves filmout a frame at a time.
*
* @returns {number} Time since start
**/
public async move () {
public async move () : Promise<number> {
let start : number = +new Date();
if (this.state.still) {
return false;
return -1;
}
if (this.state.dir) {
this.state.frame++;
@ -146,8 +148,10 @@ class FilmOut {
*
* @param {object} evt Original connect event
* @param {object} arg Arguments from ipc message
*
* @returns {boolean} Success state
**/
async onConnect (evt : any, arg : any) {
async onConnect (evt : any, arg : any) : Promise<boolean> {
let frames : number = 0;
let isAnimated : boolean = false;
let info : any;
@ -244,8 +248,6 @@ class FilmOut {
}
}
console.dir(info);
this.state.frame = 0;
this.state.path = arg.path;
this.state.fileName = arg.fileName;
@ -270,7 +272,8 @@ class FilmOut {
this.log.info(`Opened ${this.state.fileName}`, 'FILMOUT', true, true);
this.log.info(`Frames : ${frames}`, 'FILMOUT', true, true);
this.state.enabled = true;
return await this.ui.send(this.id, { valid : true, state : JSON.stringify(this.state) });
await this.ui.send(this.id, { valid : true, state : JSON.stringify(this.state) });
return true;
}
/**
@ -278,8 +281,10 @@ class FilmOut {
*
* @param {object} evt IPC event
* @param {object} arg IPC args
*
* @returns {any} UI send call
*/
async onPreExport (evt : Event, arg : any) {
async onPreExport (evt : Event, arg : any) : Promise<any> {
if (!this.state.path) {
return await this.ui.send('pre_export', { complete : false, err : 'No file to pre export.' });
}
@ -300,7 +305,7 @@ class FilmOut {
*
* @returns {boolean} Whether or not gif is animated
**/
async isGifAnimated (pathStr : string) {
async isGifAnimated (pathStr : string) : Promise<boolean> {
let gifBuffer : Buffer;
try {
gifBuffer = await readFile(pathStr);
@ -317,7 +322,7 @@ class FilmOut {
*
* @returns {object} Info about still from sharp
**/
async stillInfo (pathStr : string) {
async stillInfo (pathStr : string) : Promise<any> {
let info : any;
try {
@ -337,7 +342,7 @@ class FilmOut {
*
* @returns {object} Info about first image
**/
async dirInfo (images : string[]) {
async dirInfo (images : string[]) : Promise<any> {
let info : any;
try {
@ -357,7 +362,7 @@ class FilmOut {
*
* @returns {array} Array of image paths
**/
async dirList (pathStr : string) {
async dirList (pathStr : string) : Promise<string[]> {
let frameList : string[] = [];
try {
frameList = await readdir(pathStr)