canvas-recorder
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -15,2 +15,13 @@ #! /usr/bin/env node | ||
/** | ||
* Returns the value of a given flag, and falls back to the a given default if flag is not | ||
* specified. An optional array of white listed values can restrict the value | ||
* | ||
* @param {string} name Value of the flag | ||
* @param {string} defaultValue Default value to be returned if flag not found | ||
* @param {string[]=} restrictions Optional. Array of allowed values | ||
* | ||
* @throws If restrictions are given and the value is not listed, the method throws and error | ||
*/ | ||
function valueOrDefault( name, defaultValue, restrictions ) { | ||
@@ -24,3 +35,3 @@ const value = program[ name ]; | ||
if ( restrictions && restrictions.indexOf( value ) < 0 ) { | ||
throw new Error( name + ' has to be one of: ' + restrictions.join ( ', ' ) ); | ||
throw new Error( name + " has to be one of: " + restrictions.join ( ", " ) ); | ||
} | ||
@@ -31,2 +42,12 @@ | ||
/** | ||
* Creates FFMPEG command based on input options. | ||
* | ||
* @param {Object} options Settings to determine the | ||
* @param {string} options.format Output format either "mp4" or "gif"; | ||
* @param {number} options.fps The frames per second used for both input as well as output | ||
* @param {number} options.output Name of the file used as output. | ||
* | ||
* @returns {string[]} Output command as an array of strings. | ||
*/ | ||
function getCommand( options ) { | ||
@@ -55,3 +76,3 @@ switch ( options.format ) { | ||
exec( "ffmpeg -version", function( error, stdout, stderr ) { | ||
exec( "ffmpeg -version", function( error, _, stderr ) { | ||
if ( error || stderr ) { | ||
@@ -69,2 +90,3 @@ console.warn( | ||
try { | ||
options.format = valueOrDefault( "format", "mp4", [ "mp4", "gif" ] ); | ||
@@ -76,4 +98,3 @@ options.fps = valueOrDefault( "fps", 30 ); | ||
} catch( error ) { | ||
console.error( error.message ); | ||
return; | ||
return console.error( error.message ); | ||
} | ||
@@ -80,0 +101,0 @@ |
@@ -19,4 +19,4 @@ import { BaseRecorder, Settings } from "./shared"; | ||
declare const setup: (action: (context: WebGLRenderingContext) => void) => void; | ||
declare const bootstrap: (options?: import("./shared").BoostrapOptions) => void; | ||
declare const bootstrap: (options?: import("../../../../../Users/roboshoes/Projects/canvas-recorder/src/shared").BoostrapOptions) => void; | ||
export default recorder; | ||
export { getCanvas, getContext, options, start, stop, cleanup, reset, draw, setup, bootstrap }; |
@@ -26,5 +26,5 @@ import JSZip from "jszip"; | ||
declare const draw: (action: (context: CanvasRenderingContext2D, time: number, t: number) => void) => void; | ||
declare const bootstrap: (options?: import("./shared").BoostrapOptions) => void; | ||
declare const bootstrap: (options?: import("../../../../../Users/roboshoes/Projects/canvas-recorder/src/shared").BoostrapOptions) => void; | ||
declare const setup: (action: (context: CanvasRenderingContext2D) => void) => void; | ||
export default recorder; | ||
export { getCanvas, getContext, options, start, stop, cleanup, reset, draw, bootstrap, setup }; |
{ | ||
"name": "canvas-recorder", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "Browserside tool to record canvas animations frame by frame.", | ||
@@ -5,0 +5,0 @@ "types": "./", |
@@ -0,0 +0,0 @@ # Canvas Recorder |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35474
630