Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@meyer/hyperdeck-emulator

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meyer/hyperdeck-emulator - npm Package Compare versions

Comparing version 0.0.4-canary.37.241f21f to 0.0.4-canary.38.80bd642

dist/utils.d.ts

72

dist/api.d.ts
export declare const paramsByKey: {
help: Set<string>;
commands: Set<string>;
"device info": Set<string>;
"disk list": Set<string>;
quit: Set<string>;
ping: Set<string>;
preview: Set<string>;
play: Set<string>;
playrange: Set<string>;
"playrange set": Set<string>;
"playrange clear": Set<string>;
"play on startup": Set<string>;
"play option": Set<string>;
record: Set<string>;
"record spill": Set<string>;
stop: Set<string>;
"clips count": Set<string>;
"clips get": Set<string>;
"clips add": Set<string>;
"clips remove": Set<string>;
"clips clear": Set<string>;
"transport info": Set<string>;
"slot info": Set<string>;
"slot select": Set<string>;
"slot unblock": Set<string>;
"dynamic range": Set<string>;
notify: Set<string>;
goto: Set<string>;
jog: Set<string>;
shuttle: Set<string>;
remote: Set<string>;
configuration: Set<string>;
uptime: Set<string>;
format: Set<string>;
identify: Set<string>;
watchdog: Set<string>;
help: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
commands: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"device info": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"disk list": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
quit: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
ping: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
preview: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
play: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
playrange: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"playrange set": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"playrange clear": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"play on startup": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"play option": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
record: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"record spill": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
stop: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"clips count": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"clips get": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"clips add": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"clips remove": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"clips clear": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"transport info": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"slot info": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"slot select": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"slot unblock": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
"dynamic range": Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
notify: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
goto: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
jog: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
shuttle: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
remote: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
configuration: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
uptime: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
format: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
identify: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
watchdog: Record<string, "string" | "number" | "boolean" | "timecode" | "videoformat" | "stopmode" | "goto" | "videoinput" | "audioinput" | "fileformat" | "audiocodec" | "timecodeinput" | "recordtrigger">;
};
//# sourceMappingURL=api.d.ts.map

@@ -163,4 +163,37 @@ 'use strict';

function invariant(condition, message) {
if (!condition) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
throw new Error(util.format.apply(util, [message].concat(args)));
}
}
var Timecode = function Timecode(hh, mm, ss, ff) {
var timecode = [hh, mm, ss, ff].map(function (code) {
var codeInt = Math.floor(code);
!(codeInt === code && code >= 0 && code <= 99) ? invariant(false, 'Timecode params must be an integer between 0 and 99') : void 0; // turn the integer into a potentially zero-prefixed string
return (codeInt + 100).toString().slice(-2);
}).join(':');
this.toString = function () {
return timecode;
};
};
Timecode.toTimecode = function (tcString) {
var bits = tcString.split(':');
!(bits.length === 4) ? invariant(false, 'Expected 4 bits, received %o bits', bits.length) : void 0;
var bitsInt = bits.map(function (bit) {
var bitInt = parseInt(bit, 10);
!!isNaN(bitInt) ? invariant(false, 'bit `%s` is NaN', bit) : void 0;
return bitInt;
});
return new Timecode(bitsInt[0], bitsInt[1], bitsInt[2], bitsInt[3]);
};
var _responseNamesByCode;
var ErrorCode;

@@ -217,42 +250,10 @@

var responseNamesByCode = (_responseNamesByCode = {}, _responseNamesByCode[AsynchronousCode.ConfigurationInfo] = 'configuration info', _responseNamesByCode[AsynchronousCode.ConnectionInfo] = 'connection info', _responseNamesByCode[AsynchronousCode.RemoteInfo] = 'remote info', _responseNamesByCode[AsynchronousCode.SlotInfo] = 'slot info', _responseNamesByCode[AsynchronousCode.TransportInfo] = 'transport info', _responseNamesByCode[ErrorCode.ConnectionRejected] = 'connection rejected', _responseNamesByCode[ErrorCode.DiskError] = 'disk error', _responseNamesByCode[ErrorCode.DiskFull] = 'disk full', _responseNamesByCode[ErrorCode.FormatNotPrepared] = 'format not prepared', _responseNamesByCode[ErrorCode.InternalError] = 'internal error', _responseNamesByCode[ErrorCode.InvalidCodec] = 'invalid codec', _responseNamesByCode[ErrorCode.InvalidFormat] = 'invalid format', _responseNamesByCode[ErrorCode.InvalidState] = 'invalid state', _responseNamesByCode[ErrorCode.InvalidToken] = 'invalid token', _responseNamesByCode[ErrorCode.InvalidValue] = 'invalid value', _responseNamesByCode[ErrorCode.NoDisk] = 'no disk', _responseNamesByCode[ErrorCode.NoInput] = 'no input', _responseNamesByCode[ErrorCode.OutOfRange] = 'out of range', _responseNamesByCode[ErrorCode.RemoteControlDisabled] = 'remote control disabled', _responseNamesByCode[ErrorCode.SyntaxError] = 'syntax error', _responseNamesByCode[ErrorCode.TimelineEmpty] = 'timeline empty', _responseNamesByCode[ErrorCode.Unsupported] = 'unsupported', _responseNamesByCode[ErrorCode.UnsupportedParameter] = 'unsupported parameter', _responseNamesByCode[SynchronousCode.ClipsCount] = 'clips count', _responseNamesByCode[SynchronousCode.ClipsInfo] = 'clips info', _responseNamesByCode[SynchronousCode.Configuration] = 'configuration', _responseNamesByCode[SynchronousCode.DeviceInfo] = 'device info', _responseNamesByCode[SynchronousCode.DiskList] = 'disk list', _responseNamesByCode[SynchronousCode.FormatReady] = 'format ready', _responseNamesByCode[SynchronousCode.Notify] = 'notify', _responseNamesByCode[SynchronousCode.OK] = 'ok', _responseNamesByCode[SynchronousCode.Remote] = 'remote', _responseNamesByCode[SynchronousCode.SlotInfo] = 'slot info', _responseNamesByCode[SynchronousCode.TransportInfo] = 'transport info', _responseNamesByCode[SynchronousCode.Uptime] = 'uptime', _responseNamesByCode);
var FileFormat;
(function (FileFormat) {
FileFormat["QuickTimeUncompressed"] = "QuickTimeUncompressed";
FileFormat["QuickTimeProResHQ"] = "QuickTimeProResHQ";
FileFormat["QuickTimeProRes"] = "QuickTimeProRes";
FileFormat["QuickTimeProResLT"] = "QuickTimeProResLT";
FileFormat["QuickTimeProResProxy"] = "QuickTimeProResProxy";
FileFormat["QuickTimeDNxHR220"] = "QuickTimeDNxHR220";
FileFormat["DNxHR220"] = "DNxHR220";
})(FileFormat || (FileFormat = {}));
var AudioInput;
(function (AudioInput) {
AudioInput["embedded"] = "embedded";
AudioInput["XLR"] = "XLR";
AudioInput["RCA"] = "RCA";
})(AudioInput || (AudioInput = {}));
var VideoInputs;
(function (VideoInputs) {
VideoInputs["SDI"] = "SDI";
VideoInputs["HDMI"] = "HDMI";
VideoInputs["component"] = "component";
})(VideoInputs || (VideoInputs = {}));
var CRLF = '\r\n';
function invariant(condition, message) {
if (!condition) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
/** Convert `yourExampleKey` to `your example key` */
var camelcaseToSpaceCase = function camelcaseToSpaceCase(key) {
return key.replace(/([a-z])([A-Z]+)/g, '$1 $2').toLowerCase();
};
throw new Error(util.format.apply(util, [message].concat(args)));
}
}
/** Internal container class that holds metadata about each HyperDeck event */

@@ -279,3 +280,3 @@

};
/** Get a Set of param names keyed by function name */
/** Get a `Set` of param names keyed by function name */

@@ -285,7 +286,17 @@

return Object.entries(_this.options).reduce(function (prev, _ref) {
var key = _ref[0],
var commandName = _ref[0],
value = _ref[1];
prev[key] = new Set(value.arguments ? Object.keys(value.arguments).map(function (key) {
return key.replace(/([a-z])([A-Z]+)/g, '$1 $2').toLowerCase();
}) : []);
if (!value.arguments) {
// we still want hasOwnProperty(key) to be true
prev[commandName] = {};
return prev;
}
prev[commandName] = Object.entries(value.arguments).reduce(function (argObj, _ref2) {
var argKey = _ref2[0],
argType = _ref2[1];
argObj[camelcaseToSpaceCase(argKey)] = argType;
return argObj;
}, {});
return prev;

@@ -561,3 +572,3 @@ }, {});

if (paramNames.has(nextParam)) {
if (paramNames.hasOwnProperty(nextParam)) {
break;

@@ -660,3 +671,3 @@ }

var formattedKey = key.replace(/([a-z])([A-Z]+)/g, '$1 $2').toLowerCase();
var formattedKey = camelcaseToSpaceCase(key);
return prev + formattedKey + ': ' + valueString + CRLF;

@@ -1417,17 +1428,4 @@ }, firstLine + ':' + CRLF) + CRLF;

var Timecode = function Timecode(hh, mm, ss, ff) {
var timecode = [hh, mm, ss, ff].map(function (code) {
var codeInt = Math.floor(code);
!(codeInt === code && code >= 0 && code <= 99) ? invariant(false, 'Timecode params must be an integer between 0 and 99') : void 0; // turn the integer into a potentially zero-prefixed string
return (codeInt + 100).toString().slice(-2);
}).join(':');
this.toString = function () {
return timecode;
};
};
var ResponseInterface = {

@@ -1434,0 +1432,0 @@ __proto__: null

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n,t,r,o,i=require("events"),a=e(require("util")),s=require("net"),u=e(require("pino"));function c(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,n){return(f=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function p(e,n,t){return(p=d()?Reflect.construct:function(e,n,t){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(e,r));return t&&f(o,t.prototype),o}).apply(null,arguments)}function m(e){var n="function"==typeof Map?new Map:void 0;return(m=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return p(e,arguments,l(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),f(t,e)})(e)}function h(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))),function(e){e[e.SyntaxError=100]="SyntaxError",e[e.UnsupportedParameter=101]="UnsupportedParameter",e[e.InvalidValue=102]="InvalidValue",e[e.Unsupported=103]="Unsupported",e[e.DiskFull=104]="DiskFull",e[e.NoDisk=105]="NoDisk",e[e.DiskError=106]="DiskError",e[e.TimelineEmpty=107]="TimelineEmpty",e[e.InternalError=108]="InternalError",e[e.OutOfRange=109]="OutOfRange",e[e.NoInput=110]="NoInput",e[e.RemoteControlDisabled=111]="RemoteControlDisabled",e[e.ConnectionRejected=120]="ConnectionRejected",e[e.InvalidState=150]="InvalidState",e[e.InvalidCodec=151]="InvalidCodec",e[e.InvalidFormat=160]="InvalidFormat",e[e.InvalidToken=161]="InvalidToken",e[e.FormatNotPrepared=162]="FormatNotPrepared"}(t||(t={})),function(e){e[e.OK=200]="OK",e[e.SlotInfo=202]="SlotInfo",e[e.DeviceInfo=204]="DeviceInfo",e[e.ClipsInfo=205]="ClipsInfo",e[e.DiskList=206]="DiskList",e[e.TransportInfo=208]="TransportInfo",e[e.Notify=209]="Notify",e[e.Remote=210]="Remote",e[e.Configuration=211]="Configuration",e[e.ClipsCount=214]="ClipsCount",e[e.Uptime=215]="Uptime",e[e.FormatReady=216]="FormatReady"}(r||(r={})),function(e){e[e.ConnectionInfo=500]="ConnectionInfo",e[e.SlotInfo=502]="SlotInfo",e[e.TransportInfo=508]="TransportInfo",e[e.RemoteInfo=510]="RemoteInfo",e[e.ConfigurationInfo=511]="ConfigurationInfo"}(o||(o={}));var v,g,y,b=((n={})[o.ConfigurationInfo]="configuration info",n[o.ConnectionInfo]="connection info",n[o.RemoteInfo]="remote info",n[o.SlotInfo]="slot info",n[o.TransportInfo]="transport info",n[t.ConnectionRejected]="connection rejected",n[t.DiskError]="disk error",n[t.DiskFull]="disk full",n[t.FormatNotPrepared]="format not prepared",n[t.InternalError]="internal error",n[t.InvalidCodec]="invalid codec",n[t.InvalidFormat]="invalid format",n[t.InvalidState]="invalid state",n[t.InvalidToken]="invalid token",n[t.InvalidValue]="invalid value",n[t.NoDisk]="no disk",n[t.NoInput]="no input",n[t.OutOfRange]="out of range",n[t.RemoteControlDisabled]="remote control disabled",n[t.SyntaxError]="syntax error",n[t.TimelineEmpty]="timeline empty",n[t.Unsupported]="unsupported",n[t.UnsupportedParameter]="unsupported parameter",n[r.ClipsCount]="clips count",n[r.ClipsInfo]="clips info",n[r.Configuration]="configuration",n[r.DeviceInfo]="device info",n[r.DiskList]="disk list",n[r.FormatReady]="format ready",n[r.Notify]="notify",n[r.OK]="ok",n[r.Remote]="remote",n[r.SlotInfo]="slot info",n[r.TransportInfo]="transport info",n[r.Uptime]="uptime",n);function I(e,n){if(!e){for(var t=arguments.length,r=new Array(t>2?t-2:0),o=2;o<t;o++)r[o-2]=arguments[o];throw new Error(a.format.apply(a,[n].concat(r)))}}!function(e){e.QuickTimeUncompressed="QuickTimeUncompressed",e.QuickTimeProResHQ="QuickTimeProResHQ",e.QuickTimeProRes="QuickTimeProRes",e.QuickTimeProResLT="QuickTimeProResLT",e.QuickTimeProResProxy="QuickTimeProResProxy",e.QuickTimeDNxHR220="QuickTimeDNxHR220",e.DNxHR220="DNxHR220"}(v||(v={})),function(e){e.embedded="embedded",e.XLR="XLR",e.RCA="RCA"}(g||(g={})),function(e){e.SDI="SDI",e.HDMI="HDMI",e.component="component"}(y||(y={}));var O=(new function(e){var n=this;void 0===e&&(e={}),this.options=e,this.addOption=function(e,t){var r,o=Array.isArray(e)?e[0]:e;return n.options.hasOwnProperty(o)&&I(!1),Object.assign(n.options,((r={})[o]=t,r)),n},this.getParamsByKey=function(){return Object.entries(n.options).reduce((function(e,n){var t=n[1];return e[n[0]]=new Set(t.arguments?Object.keys(t.arguments).map((function(e){return e.replace(/([a-z])([A-Z]+)/g,"$1 $2").toLowerCase()})):[]),e}),{})}}).addOption(["help","?"],{description:"Provides help text on all commands and parameters"}).addOption("commands",{description:"return commands in XML format"}).addOption("device info",{description:"return device information"}).addOption("disk list",{description:"query clip list on active disk",arguments:{slotId:"number"}}).addOption("quit",{description:"disconnect ethernet control"}).addOption("ping",{description:"check device is responding"}).addOption("preview",{description:"switch to preview or output",arguments:{enable:"boolean"}}).addOption("play",{description:"play from current timecode",arguments:{speed:"number",loop:"boolean",singleClip:"boolean"}}).addOption("playrange",{description:"query playrange setting"}).addOption("playrange set",{description:"set play range to play clip {n} only",arguments:{clipId:"string",in:"timecode",out:"timecode",timelineIn:"number",timelineOut:"number"}}).addOption("playrange clear",{description:"clear/reset play range setting"}).addOption("play on startup",{description:"query unit play on startup state",arguments:{enable:"boolean",singleClip:"boolean"}}).addOption("play option",{description:"query play options",arguments:{stopMode:"stopmode"}}).addOption("record",{description:"record from current input",arguments:{name:"string"}}).addOption("record spill",{description:"spill current recording to next slot",arguments:{slotId:"number"}}).addOption("stop",{description:"stop playback or recording"}).addOption("clips count",{description:"query number of clips on timeline"}).addOption("clips get",{description:"query all timeline clips",arguments:{clipId:"number",count:"number",version:"number"}}).addOption("clips add",{description:"append a clip to timeline",arguments:{name:"string",clipId:"string",in:"timecode",out:"timecode"}}).addOption("clips remove",{description:"remove clip {n} from the timeline (invalidates clip ids following clip {n})",arguments:{clidId:"string"}}).addOption("clips clear",{description:"empty timeline clip list"}).addOption("transport info",{description:"query current activity"}).addOption("slot info",{description:"query active slot",arguments:{slotId:"number"}}).addOption("slot select",{description:"switch to specified slot",arguments:{slotId:"number",videoFormat:"videoformat"}}).addOption("slot unblock",{description:"unblock active slot",arguments:{slotId:"number"}}).addOption("dynamic range",{description:"query dynamic range settings",arguments:{playbackOverride:"string"}}).addOption("notify",{description:"query notification status",arguments:{remote:"boolean",transport:"boolean",slot:"boolean",configuration:"boolean",droppedFrames:"boolean",displayTimecode:"boolean",timelinePosition:"boolean",playrange:"boolean",dynamicRange:"boolean"}}).addOption("goto",{description:"go forward or backward within a clip or timeline",arguments:{clipId:"string",clip:"goto",timeline:"goto",timecode:"timecode",slotId:"number"}}).addOption("jog",{description:"jog forward or backward",arguments:{timecode:"timecode"}}).addOption("shuttle",{description:"shuttle with speed",arguments:{speed:"number"}}).addOption("remote",{description:"query unit remote control state",arguments:{enable:"boolean",override:"boolean"}}).addOption("configuration",{description:"query configuration settings",arguments:{videoInput:"videoinput",audioInput:"audioinput",fileFormat:"fileformat",audioCodec:"audiocodec",timecodeInput:"timecodeinput",timecodePreset:"timecode",audioInputChannels:"number",recordTrigger:"recordtrigger",recordPrefix:"string",appendTimestamp:"boolean"}}).addOption("uptime",{description:"return time since last boot"}).addOption("format",{description:"prepare a disk formatting operation to filesystem {format}",arguments:{prepare:"string",confirm:"string"}}).addOption("identify",{description:"identify the device",arguments:{enable:"boolean"}}).addOption("watchdog",{description:"client connection timeout",arguments:{period:"number"}}).getParamsByKey(),S=function(){function e(e){this.linesQueue=[],this.logger=e.child({name:"MultilineParser"})}var n=e.prototype;return n.receivedString=function(e){var n=[],t=e.split("\r\n");for(t.length>0&&""===t[t.length-1]&&t.pop(),this.linesQueue=this.linesQueue.concat(t);this.linesQueue.length>0;)if(""!==this.linesQueue[0])if(!this.linesQueue[0].includes(":")||1===this.linesQueue.length&&this.linesQueue[0].includes(":")){var r=this.parseResponse(this.linesQueue.splice(0,1));r&&n.push(r)}else{var o=this.linesQueue.indexOf("");if(-1===o)break;var i=this.linesQueue.splice(0,o+1),a=this.parseResponse(i);a&&n.push(a)}else this.linesQueue.shift();return n},n.parseResponse=function(e){var n=e.map((function(e){return e.trim()}));if(1===n.length&&n[0].includes(":")){var t=n[0].split(": "),r=t.shift();r||I(!1),O.hasOwnProperty(r)||I(!1);var o={},i=O[r],a=t.shift();a||I(!1);for(var s=0;s<t.length-1;s++){for(var u=t[s].split(" "),c="",l=u.length-1;l>=0&&(c=(u.pop()+" "+c).trim(),!i.has(c));l--);u.length>0||I(!1),o[a]=u.join(" "),a=c}return o[a]=t[t.length-1],{raw:n.join("\r\n"),name:r,parameters:o}}var f=n[0].match(/(.+?)(:|)$/im);if(!f)return this.logger.error({header:n[0]},"failed to parse header"),null;for(var d=f[1],p={},m=1;m<n.length;m++){var h=n[m].match(/^(.*?): (.*)$/im);h?p[h[1]]=h[2]:this.logger.error({line:n[m]},"failed to parse line")}return{raw:n.join("\r\n"),name:d,parameters:p}},e}(),k=function(e){function n(n,t,r){var i;return(i=e.call(this)||this).socket=n,i.logger=t,i.receivedCommand=r,i.lastReceivedMS=-1,i.watchdogTimer=null,i.notifySettings={slot:!1,transport:!1,remote:!1,configuration:!1,"dropped frames":!1},i.parser=new S(t),i.socket.setEncoding("utf-8"),i.socket.on("data",(function(e){i.onMessage(e)})),i.socket.on("error",(function(e){t.info({err:e},"error"),i.socket.destroy(),i.emit("disconnected"),t.info("manually disconnected")})),i.sendResponse(o.ConnectionInfo,{"protocol version":"1.11",model:"NodeJS HyperDeck Server Library"}),i}c(n,e);var i=n.prototype;return i.onMessage=function(e){var n=this;this.logger.info({data:e},"<-- received message from client"),this.lastReceivedMS=Date.now();var i=this.parser.receivedString(e);this.logger.info({cmds:i},"parsed commands");for(var a,s=function(){var e=a.value;if("watchdog"===e.name){n.watchdogTimer&&clearInterval(n.watchdogTimer);var i=e;i.parameters.period&&(n.watchdogTimer=setInterval((function(){Date.now()-n.lastReceivedMS>Number(i.parameters.period)&&(n.socket.destroy(),n.emit("disconnected"),n.watchdogTimer&&clearInterval(n.watchdogTimer))}),1e3*Number(i.parameters.period)))}else if("notify"===e.name){var s=e;if(!(Object.keys(s.parameters).length>0)){for(var u={},c=0,l=Object.keys(n.notifySettings);c<l.length;c++){var f=l[c];u[f]=n.notifySettings[f]?"true":"false"}return n.sendResponse(r.Notify,u,e),"continue"}for(var d=0,p=Object.keys(s.parameters);d<p.length;d++){var m=p[d];void 0!==n.notifySettings[m]&&(n.notifySettings[m]="true"===s.parameters[m])}}n.receivedCommand(e).then((function(i){return"object"==typeof i?n.sendResponse(i.code,"params"in i&&i.params||"message"in i&&i.message||void 0,e):"number"==typeof i&&(t[i]||r[i]||o[i])?n.sendResponse(i,void 0,e):(n.logger.error({cmd:e,codeOrObj:i},"codeOrObj was neither a ResponseCode nor a response object"),void n.sendResponse(t.InternalError,void 0,e))}),(function(){return n.sendResponse(t.Unsupported,void 0,e)}))},u=function(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return h(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?h(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(i);!(a=u()).done;)s()},i.sendResponse=function(e,n,r){var o=function(e,n){if("string"==typeof n)return e+" "+n.replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/:/g,"")+"\r\n";var t=e+" "+b[e];if(!n)return t+"\r\n";var r=Object.entries(n).filter((function(e){return null!=e[1]}));return 0===r.length?t+"\r\n":r.reduce((function(e,n){var t,r=n[0],o=n[1];return"string"==typeof o?t=o:"boolean"==typeof o?t=o?"true":"false":"number"==typeof o?t=o.toString():I(!1),e+r.replace(/([a-z])([A-Z]+)/g,"$1 $2").toLowerCase()+": "+t+"\r\n"}),t+":\r\n")+"\r\n"}(e,n);this.logger[t[e]?"error":"info"]({responseText:o,cmd:r},"--\x3e send response to client"),this.socket.write(o)},i.notify=function(e,n){this.logger.info({type:e,params:n},"notify"),"configuration"===e&&this.notifySettings.configuration?this.sendResponse(o.ConfigurationInfo,n):"remote"===e&&this.notifySettings.remote?this.sendResponse(o.RemoteInfo,n):"slot"===e&&this.notifySettings.slot?this.sendResponse(o.SlotInfo,n):"transport"===e&&this.notifySettings.transport?this.sendResponse(o.TransportInfo,n):this.logger.error({type:e,params:n},"unhandled notify type")},n}(i.EventEmitter),C=function(e){for(var n=e.clips.length,t={clipsCount:n},r=0;r<n;r++){var o=e.clips[r];t[(r+1).toString()]=o.name+" "+o.startT+" "+o.duration}return t},P=function(e){function n(){return e.apply(this,arguments)||this}return c(n,e),n}(m(Error)),R=function(){try{throw new P}catch(e){return Promise.reject(e)}};exports.HyperDeckServer=function(){function e(e,n){var o=this,i=this;void 0===n&&(n=u()),this.sockets={},this.onDeviceInfo=R,this.onDiskList=R,this.onPreview=R,this.onPlay=R,this.onPlayrangeSet=R,this.onPlayrangeClear=R,this.onRecord=R,this.onStop=R,this.onClipsCount=R,this.onClipsGet=R,this.onClipsAdd=R,this.onClipsClear=R,this.onTransportInfo=R,this.onSlotInfo=R,this.onSlotSelect=R,this.onGoTo=R,this.onJog=R,this.onShuttle=R,this.onConfiguration=R,this.onUptime=R,this.onFormat=R,this.onIdentify=R,this.onWatchdog=R,this.receivedCommand=function(e){try{return Promise.resolve(new Promise((function(e){return setTimeout((function(){return e()}),200)}))).then((function(){var n=!1;return i.logger.info({cmd:e},"<-- "+e.name),function(t,o){try{var a=function(){function t(t){var o=!1;if(n)return t;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){var t=!1;if(o)return n;function a(n){var o=!1;if(t)return n;function a(n){return o?n:"watchdog"===e.name||"ping"===e.name?r.OK:void I(!1)}var s=function(){if("identify"===e.name)return Promise.resolve(i.onIdentify(e)).then((function(){return o=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("format"===e.name)return Promise.resolve(i.onFormat(e)).then((function(e){return e?(t=!0,{code:r.FormatReady,params:e}):(t=!0,r.OK)}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("uptime"===e.name)return Promise.resolve(i.onUptime(e)).then((function(e){return o=!0,{code:r.Uptime,params:e}}))}();return s&&s.then?s.then(a):a(s)}if("remote"===e.name)return{code:r.Remote,params:{enabled:!0,override:!1}};var s=function(){if("configuration"===e.name)return Promise.resolve(i.onConfiguration(e)).then((function(e){return e?(t=!0,{code:r.Configuration,params:e}):(t=!0,r.OK)}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("shuttle"===e.name)return Promise.resolve(i.onShuttle(e)).then((function(){return o=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("jog"===e.name)return Promise.resolve(i.onJog(e)).then((function(){return t=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}if("notify"===e.name)return r.OK;var s=function(){if("go to"===e.name)return Promise.resolve(i.onGoTo(e)).then((function(){return o=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("slot select"===e.name)return Promise.resolve(i.onSlotSelect(e)).then((function(){return t=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("slot info"===e.name)return Promise.resolve(i.onSlotInfo(e)).then((function(e){return o=!0,{code:r.SlotInfo,params:e}}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("transport info"===e.name)return Promise.resolve(i.onTransportInfo(e)).then((function(e){return t=!0,{code:r.TransportInfo,params:e}}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("clips clear"===e.name)return Promise.resolve(i.onClipsClear(e)).then((function(){return o=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("clips add"===e.name)return Promise.resolve(i.onClipsAdd(e)).then((function(){return t=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("clips get"===e.name)return Promise.resolve(i.onClipsGet(e).then(C)).then((function(e){return o=!0,{code:r.ClipsInfo,params:e}}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("clips count"===e.name)return Promise.resolve(i.onClipsCount(e)).then((function(e){return t=!0,{code:r.ClipsCount,params:e}}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("stop"===e.name)return Promise.resolve(i.onStop(e)).then((function(){return o=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("record"===e.name)return Promise.resolve(i.onRecord(e)).then((function(){return t=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("playrange clear"===e.name)return Promise.resolve(i.onPlayrangeClear(e)).then((function(){return o=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("playrange set"===e.name)return Promise.resolve(i.onPlayrangeSet(e)).then((function(){return t=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("play"===e.name)return Promise.resolve(i.onPlay(e)).then((function(){return o=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("preview"===e.name)return Promise.resolve(i.onPreview(e)).then((function(){return t=!0,r.OK}))}();return s&&s.then?s.then(a):a(s)}var s=function(){if("disk list"===e.name)return Promise.resolve(i.onDiskList(e)).then((function(e){return o=!0,{code:r.DiskList,params:e}}))}();return s&&s.then?s.then(a):a(s)}var o=function(){if("device info"===e.name)return Promise.resolve(i.onDeviceInfo(e)).then((function(e){return n=!0,{code:r.DeviceInfo,params:e}}))}();return o&&o.then?o.then(t):t(o)}()}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,(function(n){return n instanceof P?(i.logger.error({cmd:e},"unimplemented"),t.Unsupported):(i.logger.error({cmd:e,err:n.message},"unhandled command name"),t.InternalError)}))}))}catch(e){return Promise.reject(e)}},this.logger=n.child({name:"HyperDeck Emulator"}),this.server=s.createServer((function(e){o.logger.info("connection");var n=Math.random().toString(35).substr(-6),t=o.logger.child({name:"HyperDeck socket "+n});o.sockets[n]=new k(e,t,(function(e){return o.receivedCommand(e)})),o.sockets[n].on("disconnected",(function(){t.info("disconnected"),delete o.sockets[n]}))})),this.server.on("listening",(function(){return o.logger.info("listening")})),this.server.on("close",(function(){return o.logger.info("connection closed")})),this.server.on("error",(function(e){return o.logger.error("server error:",e)})),this.server.maxConnections=1,this.server.listen(9993,e)}var n=e.prototype;return n.close=function(){this.server.unref()},n.notifySlot=function(e){this.notify("slot",e)},n.notifyTransport=function(e){this.notify("transport",e)},n.notify=function(e,n){for(var t=0,r=Object.keys(this.sockets);t<r.length;t++)this.sockets[r[t]].notify(e,n)},e}(),exports.ResponseInterface={__proto__:null},exports.Timecode=function(e,n,t,r){var o=[e,n,t,r].map((function(e){var n=Math.floor(e);return n===e&&e>=0&&e<=99||I(!1),(n+100).toString().slice(-2)})).join(":");this.toString=function(){return o}};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("events"),t=e(require("util")),r=require("net"),o=e(require("pino"));function i(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,n){return(s=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,n,t){return(c=u()?Reflect.construct:function(e,n,t){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(e,r));return t&&s(o,t.prototype),o}).apply(null,arguments)}function l(e){var n="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return c(e,arguments,a(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),s(t,e)})(e)}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function p(e,n){if(!e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];throw new Error(t.format.apply(t,[n].concat(o)))}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var d,m,h,v,g=function(e,n,t,r){var o=[e,n,t,r].map((function(e){var n=Math.floor(e);return n===e&&e>=0&&e<=99||p(!1),(n+100).toString().slice(-2)})).join(":");this.toString=function(){return o}};g.toTimecode=function(e){var n=e.split(":");4!==n.length&&p(!1);var t=n.map((function(e){var n=parseInt(e,10);return isNaN(n)&&p(!1),n}));return new g(t[0],t[1],t[2],t[3])},function(e){e[e.SyntaxError=100]="SyntaxError",e[e.UnsupportedParameter=101]="UnsupportedParameter",e[e.InvalidValue=102]="InvalidValue",e[e.Unsupported=103]="Unsupported",e[e.DiskFull=104]="DiskFull",e[e.NoDisk=105]="NoDisk",e[e.DiskError=106]="DiskError",e[e.TimelineEmpty=107]="TimelineEmpty",e[e.InternalError=108]="InternalError",e[e.OutOfRange=109]="OutOfRange",e[e.NoInput=110]="NoInput",e[e.RemoteControlDisabled=111]="RemoteControlDisabled",e[e.ConnectionRejected=120]="ConnectionRejected",e[e.InvalidState=150]="InvalidState",e[e.InvalidCodec=151]="InvalidCodec",e[e.InvalidFormat=160]="InvalidFormat",e[e.InvalidToken=161]="InvalidToken",e[e.FormatNotPrepared=162]="FormatNotPrepared"}(m||(m={})),function(e){e[e.OK=200]="OK",e[e.SlotInfo=202]="SlotInfo",e[e.DeviceInfo=204]="DeviceInfo",e[e.ClipsInfo=205]="ClipsInfo",e[e.DiskList=206]="DiskList",e[e.TransportInfo=208]="TransportInfo",e[e.Notify=209]="Notify",e[e.Remote=210]="Remote",e[e.Configuration=211]="Configuration",e[e.ClipsCount=214]="ClipsCount",e[e.Uptime=215]="Uptime",e[e.FormatReady=216]="FormatReady"}(h||(h={})),function(e){e[e.ConnectionInfo=500]="ConnectionInfo",e[e.SlotInfo=502]="SlotInfo",e[e.TransportInfo=508]="TransportInfo",e[e.RemoteInfo=510]="RemoteInfo",e[e.ConfigurationInfo=511]="ConfigurationInfo"}(v||(v={}));var y=((d={})[v.ConfigurationInfo]="configuration info",d[v.ConnectionInfo]="connection info",d[v.RemoteInfo]="remote info",d[v.SlotInfo]="slot info",d[v.TransportInfo]="transport info",d[m.ConnectionRejected]="connection rejected",d[m.DiskError]="disk error",d[m.DiskFull]="disk full",d[m.FormatNotPrepared]="format not prepared",d[m.InternalError]="internal error",d[m.InvalidCodec]="invalid codec",d[m.InvalidFormat]="invalid format",d[m.InvalidState]="invalid state",d[m.InvalidToken]="invalid token",d[m.InvalidValue]="invalid value",d[m.NoDisk]="no disk",d[m.NoInput]="no input",d[m.OutOfRange]="out of range",d[m.RemoteControlDisabled]="remote control disabled",d[m.SyntaxError]="syntax error",d[m.TimelineEmpty]="timeline empty",d[m.Unsupported]="unsupported",d[m.UnsupportedParameter]="unsupported parameter",d[h.ClipsCount]="clips count",d[h.ClipsInfo]="clips info",d[h.Configuration]="configuration",d[h.DeviceInfo]="device info",d[h.DiskList]="disk list",d[h.FormatReady]="format ready",d[h.Notify]="notify",d[h.OK]="ok",d[h.Remote]="remote",d[h.SlotInfo]="slot info",d[h.TransportInfo]="transport info",d[h.Uptime]="uptime",d),b=function(e){return e.replace(/([a-z])([A-Z]+)/g,"$1 $2").toLowerCase()},O=(new function(e){var n=this;void 0===e&&(e={}),this.options=e,this.addOption=function(e,t){var r,o=Array.isArray(e)?e[0]:e;return n.options.hasOwnProperty(o)&&p(!1),Object.assign(n.options,((r={})[o]=t,r)),n},this.getParamsByKey=function(){return Object.entries(n.options).reduce((function(e,n){var t=n[0],r=n[1];return r.arguments?(e[t]=Object.entries(r.arguments).reduce((function(e,n){var t=n[1];return e[b(n[0])]=t,e}),{}),e):(e[t]={},e)}),{})}}).addOption(["help","?"],{description:"Provides help text on all commands and parameters"}).addOption("commands",{description:"return commands in XML format"}).addOption("device info",{description:"return device information"}).addOption("disk list",{description:"query clip list on active disk",arguments:{slotId:"number"}}).addOption("quit",{description:"disconnect ethernet control"}).addOption("ping",{description:"check device is responding"}).addOption("preview",{description:"switch to preview or output",arguments:{enable:"boolean"}}).addOption("play",{description:"play from current timecode",arguments:{speed:"number",loop:"boolean",singleClip:"boolean"}}).addOption("playrange",{description:"query playrange setting"}).addOption("playrange set",{description:"set play range to play clip {n} only",arguments:{clipId:"string",in:"timecode",out:"timecode",timelineIn:"number",timelineOut:"number"}}).addOption("playrange clear",{description:"clear/reset play range setting"}).addOption("play on startup",{description:"query unit play on startup state",arguments:{enable:"boolean",singleClip:"boolean"}}).addOption("play option",{description:"query play options",arguments:{stopMode:"stopmode"}}).addOption("record",{description:"record from current input",arguments:{name:"string"}}).addOption("record spill",{description:"spill current recording to next slot",arguments:{slotId:"number"}}).addOption("stop",{description:"stop playback or recording"}).addOption("clips count",{description:"query number of clips on timeline"}).addOption("clips get",{description:"query all timeline clips",arguments:{clipId:"number",count:"number",version:"number"}}).addOption("clips add",{description:"append a clip to timeline",arguments:{name:"string",clipId:"string",in:"timecode",out:"timecode"}}).addOption("clips remove",{description:"remove clip {n} from the timeline (invalidates clip ids following clip {n})",arguments:{clidId:"string"}}).addOption("clips clear",{description:"empty timeline clip list"}).addOption("transport info",{description:"query current activity"}).addOption("slot info",{description:"query active slot",arguments:{slotId:"number"}}).addOption("slot select",{description:"switch to specified slot",arguments:{slotId:"number",videoFormat:"videoformat"}}).addOption("slot unblock",{description:"unblock active slot",arguments:{slotId:"number"}}).addOption("dynamic range",{description:"query dynamic range settings",arguments:{playbackOverride:"string"}}).addOption("notify",{description:"query notification status",arguments:{remote:"boolean",transport:"boolean",slot:"boolean",configuration:"boolean",droppedFrames:"boolean",displayTimecode:"boolean",timelinePosition:"boolean",playrange:"boolean",dynamicRange:"boolean"}}).addOption("goto",{description:"go forward or backward within a clip or timeline",arguments:{clipId:"string",clip:"goto",timeline:"goto",timecode:"timecode",slotId:"number"}}).addOption("jog",{description:"jog forward or backward",arguments:{timecode:"timecode"}}).addOption("shuttle",{description:"shuttle with speed",arguments:{speed:"number"}}).addOption("remote",{description:"query unit remote control state",arguments:{enable:"boolean",override:"boolean"}}).addOption("configuration",{description:"query configuration settings",arguments:{videoInput:"videoinput",audioInput:"audioinput",fileFormat:"fileformat",audioCodec:"audiocodec",timecodeInput:"timecodeinput",timecodePreset:"timecode",audioInputChannels:"number",recordTrigger:"recordtrigger",recordPrefix:"string",appendTimestamp:"boolean"}}).addOption("uptime",{description:"return time since last boot"}).addOption("format",{description:"prepare a disk formatting operation to filesystem {format}",arguments:{prepare:"string",confirm:"string"}}).addOption("identify",{description:"identify the device",arguments:{enable:"boolean"}}).addOption("watchdog",{description:"client connection timeout",arguments:{period:"number"}}).getParamsByKey(),I=function(){function e(e){this.linesQueue=[],this.logger=e.child({name:"MultilineParser"})}var n=e.prototype;return n.receivedString=function(e){var n=[],t=e.split("\r\n");for(t.length>0&&""===t[t.length-1]&&t.pop(),this.linesQueue=this.linesQueue.concat(t);this.linesQueue.length>0;)if(""!==this.linesQueue[0])if(!this.linesQueue[0].includes(":")||1===this.linesQueue.length&&this.linesQueue[0].includes(":")){var r=this.parseResponse(this.linesQueue.splice(0,1));r&&n.push(r)}else{var o=this.linesQueue.indexOf("");if(-1===o)break;var i=this.linesQueue.splice(0,o+1),a=this.parseResponse(i);a&&n.push(a)}else this.linesQueue.shift();return n},n.parseResponse=function(e){var n=e.map((function(e){return e.trim()}));if(1===n.length&&n[0].includes(":")){var t=n[0].split(": "),r=t.shift();r||p(!1),O.hasOwnProperty(r)||p(!1);var o={},i=O[r],a=t.shift();a||p(!1);for(var s=0;s<t.length-1;s++){for(var u=t[s].split(" "),c="",l=u.length-1;l>=0&&(c=(u.pop()+" "+c).trim(),!i.hasOwnProperty(c));l--);u.length>0||p(!1),o[a]=u.join(" "),a=c}return o[a]=t[t.length-1],{raw:n.join("\r\n"),name:r,parameters:o}}var f=n[0].match(/(.+?)(:|)$/im);if(!f)return this.logger.error({header:n[0]},"failed to parse header"),null;for(var d=f[1],m={},h=1;h<n.length;h++){var v=n[h].match(/^(.*?): (.*)$/im);v?m[v[1]]=v[2]:this.logger.error({line:n[h]},"failed to parse line")}return{raw:n.join("\r\n"),name:d,parameters:m}},e}(),S=function(e){function n(n,t,r){var o;return(o=e.call(this)||this).socket=n,o.logger=t,o.receivedCommand=r,o.lastReceivedMS=-1,o.watchdogTimer=null,o.notifySettings={slot:!1,transport:!1,remote:!1,configuration:!1,"dropped frames":!1},o.parser=new I(t),o.socket.setEncoding("utf-8"),o.socket.on("data",(function(e){o.onMessage(e)})),o.socket.on("error",(function(e){t.info({err:e},"error"),o.socket.destroy(),o.emit("disconnected"),t.info("manually disconnected")})),o.sendResponse(v.ConnectionInfo,{"protocol version":"1.11",model:"NodeJS HyperDeck Server Library"}),o}i(n,e);var t=n.prototype;return t.onMessage=function(e){var n=this;this.logger.info({data:e},"<-- received message from client"),this.lastReceivedMS=Date.now();var t=this.parser.receivedString(e);this.logger.info({cmds:t},"parsed commands");for(var r,o=function(){var e=r.value;if("watchdog"===e.name){n.watchdogTimer&&clearInterval(n.watchdogTimer);var t=e;t.parameters.period&&(n.watchdogTimer=setInterval((function(){Date.now()-n.lastReceivedMS>Number(t.parameters.period)&&(n.socket.destroy(),n.emit("disconnected"),n.watchdogTimer&&clearInterval(n.watchdogTimer))}),1e3*Number(t.parameters.period)))}else if("notify"===e.name){var o=e;if(!(Object.keys(o.parameters).length>0)){for(var i={},a=0,s=Object.keys(n.notifySettings);a<s.length;a++){var u=s[a];i[u]=n.notifySettings[u]?"true":"false"}return n.sendResponse(h.Notify,i,e),"continue"}for(var c=0,l=Object.keys(o.parameters);c<l.length;c++){var f=l[c];void 0!==n.notifySettings[f]&&(n.notifySettings[f]="true"===o.parameters[f])}}n.receivedCommand(e).then((function(t){return"object"==typeof t?n.sendResponse(t.code,"params"in t&&t.params||"message"in t&&t.message||void 0,e):"number"==typeof t&&(m[t]||h[t]||v[t])?n.sendResponse(t,void 0,e):(n.logger.error({cmd:e,codeOrObj:t},"codeOrObj was neither a ResponseCode nor a response object"),void n.sendResponse(m.InternalError,void 0,e))}),(function(){return n.sendResponse(m.Unsupported,void 0,e)}))},i=function(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return f(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?f(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(t);!(r=i()).done;)o()},t.sendResponse=function(e,n,t){var r=function(e,n){if("string"==typeof n)return e+" "+n.replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/:/g,"")+"\r\n";var t=e+" "+y[e];if(!n)return t+"\r\n";var r=Object.entries(n).filter((function(e){return null!=e[1]}));return 0===r.length?t+"\r\n":r.reduce((function(e,n){var t,r=n[0],o=n[1];return"string"==typeof o?t=o:"boolean"==typeof o?t=o?"true":"false":"number"==typeof o?t=o.toString():p(!1),e+b(r)+": "+t+"\r\n"}),t+":\r\n")+"\r\n"}(e,n);this.logger[m[e]?"error":"info"]({responseText:r,cmd:t},"--\x3e send response to client"),this.socket.write(r)},t.notify=function(e,n){this.logger.info({type:e,params:n},"notify"),"configuration"===e&&this.notifySettings.configuration?this.sendResponse(v.ConfigurationInfo,n):"remote"===e&&this.notifySettings.remote?this.sendResponse(v.RemoteInfo,n):"slot"===e&&this.notifySettings.slot?this.sendResponse(v.SlotInfo,n):"transport"===e&&this.notifySettings.transport?this.sendResponse(v.TransportInfo,n):this.logger.error({type:e,params:n},"unhandled notify type")},n}(n.EventEmitter),C=function(e){for(var n=e.clips.length,t={clipsCount:n},r=0;r<n;r++){var o=e.clips[r];t[(r+1).toString()]=o.name+" "+o.startT+" "+o.duration}return t},k=function(e){function n(){return e.apply(this,arguments)||this}return i(n,e),n}(l(Error)),P=function(){try{throw new k}catch(e){return Promise.reject(e)}};exports.HyperDeckServer=function(){function e(e,n){var t=this,i=this;void 0===n&&(n=o()),this.sockets={},this.onDeviceInfo=P,this.onDiskList=P,this.onPreview=P,this.onPlay=P,this.onPlayrangeSet=P,this.onPlayrangeClear=P,this.onRecord=P,this.onStop=P,this.onClipsCount=P,this.onClipsGet=P,this.onClipsAdd=P,this.onClipsClear=P,this.onTransportInfo=P,this.onSlotInfo=P,this.onSlotSelect=P,this.onGoTo=P,this.onJog=P,this.onShuttle=P,this.onConfiguration=P,this.onUptime=P,this.onFormat=P,this.onIdentify=P,this.onWatchdog=P,this.receivedCommand=function(e){try{return Promise.resolve(new Promise((function(e){return setTimeout((function(){return e()}),200)}))).then((function(){var n=!1;return i.logger.info({cmd:e},"<-- "+e.name),function(t,r){try{var o=function(){function t(t){var r=!1;if(n)return t;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){var t=!1;if(r)return n;function o(n){var r=!1;if(t)return n;function o(n){return r?n:"watchdog"===e.name||"ping"===e.name?h.OK:void p(!1)}var a=function(){if("identify"===e.name)return Promise.resolve(i.onIdentify(e)).then((function(){return r=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("format"===e.name)return Promise.resolve(i.onFormat(e)).then((function(e){return e?(t=!0,{code:h.FormatReady,params:e}):(t=!0,h.OK)}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("uptime"===e.name)return Promise.resolve(i.onUptime(e)).then((function(e){return r=!0,{code:h.Uptime,params:e}}))}();return a&&a.then?a.then(o):o(a)}if("remote"===e.name)return{code:h.Remote,params:{enabled:!0,override:!1}};var a=function(){if("configuration"===e.name)return Promise.resolve(i.onConfiguration(e)).then((function(e){return e?(t=!0,{code:h.Configuration,params:e}):(t=!0,h.OK)}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("shuttle"===e.name)return Promise.resolve(i.onShuttle(e)).then((function(){return r=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("jog"===e.name)return Promise.resolve(i.onJog(e)).then((function(){return t=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}if("notify"===e.name)return h.OK;var a=function(){if("go to"===e.name)return Promise.resolve(i.onGoTo(e)).then((function(){return r=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("slot select"===e.name)return Promise.resolve(i.onSlotSelect(e)).then((function(){return t=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("slot info"===e.name)return Promise.resolve(i.onSlotInfo(e)).then((function(e){return r=!0,{code:h.SlotInfo,params:e}}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("transport info"===e.name)return Promise.resolve(i.onTransportInfo(e)).then((function(e){return t=!0,{code:h.TransportInfo,params:e}}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("clips clear"===e.name)return Promise.resolve(i.onClipsClear(e)).then((function(){return r=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("clips add"===e.name)return Promise.resolve(i.onClipsAdd(e)).then((function(){return t=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("clips get"===e.name)return Promise.resolve(i.onClipsGet(e).then(C)).then((function(e){return r=!0,{code:h.ClipsInfo,params:e}}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("clips count"===e.name)return Promise.resolve(i.onClipsCount(e)).then((function(e){return t=!0,{code:h.ClipsCount,params:e}}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("stop"===e.name)return Promise.resolve(i.onStop(e)).then((function(){return r=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("record"===e.name)return Promise.resolve(i.onRecord(e)).then((function(){return t=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("playrange clear"===e.name)return Promise.resolve(i.onPlayrangeClear(e)).then((function(){return r=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("playrange set"===e.name)return Promise.resolve(i.onPlayrangeSet(e)).then((function(){return t=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("play"===e.name)return Promise.resolve(i.onPlay(e)).then((function(){return r=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("preview"===e.name)return Promise.resolve(i.onPreview(e)).then((function(){return t=!0,h.OK}))}();return a&&a.then?a.then(o):o(a)}var a=function(){if("disk list"===e.name)return Promise.resolve(i.onDiskList(e)).then((function(e){return r=!0,{code:h.DiskList,params:e}}))}();return a&&a.then?a.then(o):o(a)}var r=function(){if("device info"===e.name)return Promise.resolve(i.onDeviceInfo(e)).then((function(e){return n=!0,{code:h.DeviceInfo,params:e}}))}();return r&&r.then?r.then(t):t(r)}()}catch(e){return r(e)}return o&&o.then?o.then(void 0,r):o}(0,(function(n){return n instanceof k?(i.logger.error({cmd:e},"unimplemented"),m.Unsupported):(i.logger.error({cmd:e,err:n.message},"unhandled command name"),m.InternalError)}))}))}catch(e){return Promise.reject(e)}},this.logger=n.child({name:"HyperDeck Emulator"}),this.server=r.createServer((function(e){t.logger.info("connection");var n=Math.random().toString(35).substr(-6),r=t.logger.child({name:"HyperDeck socket "+n});t.sockets[n]=new S(e,r,(function(e){return t.receivedCommand(e)})),t.sockets[n].on("disconnected",(function(){r.info("disconnected"),delete t.sockets[n]}))})),this.server.on("listening",(function(){return t.logger.info("listening")})),this.server.on("close",(function(){return t.logger.info("connection closed")})),this.server.on("error",(function(e){return t.logger.error("server error:",e)})),this.server.maxConnections=1,this.server.listen(9993,e)}var n=e.prototype;return n.close=function(){this.server.unref()},n.notifySlot=function(e){this.notify("slot",e)},n.notifyTransport=function(e){this.notify("transport",e)},n.notify=function(e,n){for(var t=0,r=Object.keys(this.sockets);t<r.length;t++)this.sockets[r[t]].notify(e,n)},e}(),exports.ResponseInterface={__proto__:null},exports.Timecode=g;
//# sourceMappingURL=hyperdeck-emulator.cjs.production.min.js.map

@@ -157,4 +157,37 @@ import { EventEmitter } from 'events';

function invariant(condition, message) {
if (!condition) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
throw new Error(util.format.apply(util, [message].concat(args)));
}
}
var Timecode = function Timecode(hh, mm, ss, ff) {
var timecode = [hh, mm, ss, ff].map(function (code) {
var codeInt = Math.floor(code);
!(codeInt === code && code >= 0 && code <= 99) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Timecode params must be an integer between 0 and 99') : invariant(false) : void 0; // turn the integer into a potentially zero-prefixed string
return (codeInt + 100).toString().slice(-2);
}).join(':');
this.toString = function () {
return timecode;
};
};
Timecode.toTimecode = function (tcString) {
var bits = tcString.split(':');
!(bits.length === 4) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected 4 bits, received %o bits', bits.length) : invariant(false) : void 0;
var bitsInt = bits.map(function (bit) {
var bitInt = parseInt(bit, 10);
!!isNaN(bitInt) ? process.env.NODE_ENV !== "production" ? invariant(false, 'bit `%s` is NaN', bit) : invariant(false) : void 0;
return bitInt;
});
return new Timecode(bitsInt[0], bitsInt[1], bitsInt[2], bitsInt[3]);
};
var _responseNamesByCode;
var ErrorCode;

@@ -211,42 +244,10 @@

var responseNamesByCode = (_responseNamesByCode = {}, _responseNamesByCode[AsynchronousCode.ConfigurationInfo] = 'configuration info', _responseNamesByCode[AsynchronousCode.ConnectionInfo] = 'connection info', _responseNamesByCode[AsynchronousCode.RemoteInfo] = 'remote info', _responseNamesByCode[AsynchronousCode.SlotInfo] = 'slot info', _responseNamesByCode[AsynchronousCode.TransportInfo] = 'transport info', _responseNamesByCode[ErrorCode.ConnectionRejected] = 'connection rejected', _responseNamesByCode[ErrorCode.DiskError] = 'disk error', _responseNamesByCode[ErrorCode.DiskFull] = 'disk full', _responseNamesByCode[ErrorCode.FormatNotPrepared] = 'format not prepared', _responseNamesByCode[ErrorCode.InternalError] = 'internal error', _responseNamesByCode[ErrorCode.InvalidCodec] = 'invalid codec', _responseNamesByCode[ErrorCode.InvalidFormat] = 'invalid format', _responseNamesByCode[ErrorCode.InvalidState] = 'invalid state', _responseNamesByCode[ErrorCode.InvalidToken] = 'invalid token', _responseNamesByCode[ErrorCode.InvalidValue] = 'invalid value', _responseNamesByCode[ErrorCode.NoDisk] = 'no disk', _responseNamesByCode[ErrorCode.NoInput] = 'no input', _responseNamesByCode[ErrorCode.OutOfRange] = 'out of range', _responseNamesByCode[ErrorCode.RemoteControlDisabled] = 'remote control disabled', _responseNamesByCode[ErrorCode.SyntaxError] = 'syntax error', _responseNamesByCode[ErrorCode.TimelineEmpty] = 'timeline empty', _responseNamesByCode[ErrorCode.Unsupported] = 'unsupported', _responseNamesByCode[ErrorCode.UnsupportedParameter] = 'unsupported parameter', _responseNamesByCode[SynchronousCode.ClipsCount] = 'clips count', _responseNamesByCode[SynchronousCode.ClipsInfo] = 'clips info', _responseNamesByCode[SynchronousCode.Configuration] = 'configuration', _responseNamesByCode[SynchronousCode.DeviceInfo] = 'device info', _responseNamesByCode[SynchronousCode.DiskList] = 'disk list', _responseNamesByCode[SynchronousCode.FormatReady] = 'format ready', _responseNamesByCode[SynchronousCode.Notify] = 'notify', _responseNamesByCode[SynchronousCode.OK] = 'ok', _responseNamesByCode[SynchronousCode.Remote] = 'remote', _responseNamesByCode[SynchronousCode.SlotInfo] = 'slot info', _responseNamesByCode[SynchronousCode.TransportInfo] = 'transport info', _responseNamesByCode[SynchronousCode.Uptime] = 'uptime', _responseNamesByCode);
var FileFormat;
(function (FileFormat) {
FileFormat["QuickTimeUncompressed"] = "QuickTimeUncompressed";
FileFormat["QuickTimeProResHQ"] = "QuickTimeProResHQ";
FileFormat["QuickTimeProRes"] = "QuickTimeProRes";
FileFormat["QuickTimeProResLT"] = "QuickTimeProResLT";
FileFormat["QuickTimeProResProxy"] = "QuickTimeProResProxy";
FileFormat["QuickTimeDNxHR220"] = "QuickTimeDNxHR220";
FileFormat["DNxHR220"] = "DNxHR220";
})(FileFormat || (FileFormat = {}));
var AudioInput;
(function (AudioInput) {
AudioInput["embedded"] = "embedded";
AudioInput["XLR"] = "XLR";
AudioInput["RCA"] = "RCA";
})(AudioInput || (AudioInput = {}));
var VideoInputs;
(function (VideoInputs) {
VideoInputs["SDI"] = "SDI";
VideoInputs["HDMI"] = "HDMI";
VideoInputs["component"] = "component";
})(VideoInputs || (VideoInputs = {}));
var CRLF = '\r\n';
function invariant(condition, message) {
if (!condition) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
/** Convert `yourExampleKey` to `your example key` */
var camelcaseToSpaceCase = function camelcaseToSpaceCase(key) {
return key.replace(/([a-z])([A-Z]+)/g, '$1 $2').toLowerCase();
};
throw new Error(util.format.apply(util, [message].concat(args)));
}
}
/** Internal container class that holds metadata about each HyperDeck event */

@@ -273,3 +274,3 @@

};
/** Get a Set of param names keyed by function name */
/** Get a `Set` of param names keyed by function name */

@@ -279,7 +280,17 @@

return Object.entries(_this.options).reduce(function (prev, _ref) {
var key = _ref[0],
var commandName = _ref[0],
value = _ref[1];
prev[key] = new Set(value.arguments ? Object.keys(value.arguments).map(function (key) {
return key.replace(/([a-z])([A-Z]+)/g, '$1 $2').toLowerCase();
}) : []);
if (!value.arguments) {
// we still want hasOwnProperty(key) to be true
prev[commandName] = {};
return prev;
}
prev[commandName] = Object.entries(value.arguments).reduce(function (argObj, _ref2) {
var argKey = _ref2[0],
argType = _ref2[1];
argObj[camelcaseToSpaceCase(argKey)] = argType;
return argObj;
}, {});
return prev;

@@ -555,3 +566,3 @@ }, {});

if (paramNames.has(nextParam)) {
if (paramNames.hasOwnProperty(nextParam)) {
break;

@@ -654,3 +665,3 @@ }

var formattedKey = key.replace(/([a-z])([A-Z]+)/g, '$1 $2').toLowerCase();
var formattedKey = camelcaseToSpaceCase(key);
return prev + formattedKey + ': ' + valueString + CRLF;

@@ -1411,17 +1422,4 @@ }, firstLine + ':' + CRLF) + CRLF;

var Timecode = function Timecode(hh, mm, ss, ff) {
var timecode = [hh, mm, ss, ff].map(function (code) {
var codeInt = Math.floor(code);
!(codeInt === code && code >= 0 && code <= 99) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Timecode params must be an integer between 0 and 99') : invariant(false) : void 0; // turn the integer into a potentially zero-prefixed string
return (codeInt + 100).toString().slice(-2);
}).join(':');
this.toString = function () {
return timecode;
};
};
var ResponseInterface = {

@@ -1428,0 +1426,0 @@ __proto__: null

export declare class Timecode {
constructor(hh: number, mm: number, ss: number, ff: number);
toString: () => string;
static toTimecode: (tcString: string) => Timecode;
}
//# sourceMappingURL=Timecode.d.ts.map

@@ -0,1 +1,2 @@

import { Timecode } from './Timecode';
export interface NotificationConfig {

@@ -103,21 +104,64 @@ transport: boolean;

export declare const isTransportStatus: (value: any) => value is "preview" | "stopped" | "play" | "forward" | "rewind" | "jog" | "shuttle" | "record";
export declare enum FileFormat {
QuickTimeUncompressed = "QuickTimeUncompressed",
QuickTimeProResHQ = "QuickTimeProResHQ",
QuickTimeProRes = "QuickTimeProRes",
QuickTimeProResLT = "QuickTimeProResLT",
QuickTimeProResProxy = "QuickTimeProResProxy",
QuickTimeDNxHR220 = "QuickTimeDNxHR220",
DNxHR220 = "DNxHR220"
export declare const stopModes: {
lastframe: boolean;
nextframe: boolean;
black: boolean;
};
export declare type StopMode = keyof typeof stopModes;
export declare const isStopMode: (value: any) => value is "lastframe" | "nextframe" | "black";
export declare const videoInputs: {
SDI: boolean;
HDMI: boolean;
component: boolean;
};
export declare type VideoInput = keyof typeof videoInputs;
export declare const isVideoInput: (value: any) => value is "SDI" | "HDMI" | "component";
export declare const audioInputs: {
XLR: boolean;
RCA: boolean;
embedded: boolean;
};
export declare type AudioInput = keyof typeof audioInputs;
export declare const isAudioInput: (value: any) => value is "XLR" | "RCA" | "embedded";
export declare const audioCodecs: {
PCM: boolean;
AAC: boolean;
};
export declare type AudioCodec = keyof typeof audioCodecs;
export declare const isAudioCodec: (value: any) => value is "PCM" | "AAC";
export declare const timecodeInputs: {
external: boolean;
embedded: boolean;
preset: boolean;
clip: boolean;
};
export declare type TimecodeInput = keyof typeof timecodeInputs;
export declare const isTimecodeInput: (value: any) => value is "embedded" | "external" | "preset" | "clip";
export declare const recordTriggers: {
none: boolean;
recordbit: boolean;
timecoderun: boolean;
};
export declare type RecordTrigger = keyof typeof recordTriggers;
export declare const isRecordTrigger: (value: any) => value is "none" | "recordbit" | "timecoderun";
export declare type FileFormat = 'QuickTimeUncompressed' | 'QuickTimeProResHQ' | 'QuickTimeProRes' | 'QuickTimeProResLT' | 'QuickTimeProResProxy' | 'QuickTimeDNxHR220' | 'DNxHR220';
export declare type ArgKey = keyof TypesByStringKey;
export interface TypesByStringKey {
boolean: boolean;
string: string;
timecode: Timecode;
number: number;
videoformat: VideoFormat;
stopmode: StopMode;
goto: 'start' | 'end' | string | number;
videoinput: VideoInput;
audioinput: AudioInput;
fileformat: string;
audiocodec: AudioCodec;
timecodeinput: TimecodeInput;
recordtrigger: RecordTrigger;
}
export declare enum AudioInput {
embedded = "embedded",
XLR = "XLR",
RCA = "RCA"
}
export declare enum VideoInputs {
SDI = "SDI",
HDMI = "HDMI",
component = "component"
}
export declare const stringToValueFns: {
[K in keyof TypesByStringKey]: (value: string) => TypesByStringKey[K];
};
//# sourceMappingURL=types.d.ts.map
import type { Timecode } from '../Timecode';
import type { TransportStatus, VideoFormat, SlotStatus, AudioInput, VideoInputs, FileFormat } from '../types';
import type { TransportStatus, VideoFormat, SlotStatus, AudioInput, VideoInput, FileFormat } from '../types';
export interface DeviceInfo {

@@ -49,3 +49,3 @@ 'protocol version': string;

'audio input': AudioInput;
'video input': VideoInputs;
'video input': VideoInput;
'file format': FileFormat;

@@ -52,0 +52,0 @@ }

{
"name": "@meyer/hyperdeck-emulator",
"version": "0.0.4-canary.37.241f21f",
"version": "0.0.4-canary.38.80bd642",
"description": "Typescript Node.js library for emulating a Blackmagic Hyperdeck",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -74,2 +74,4 @@ import packlist = require('npm-packlist');

- dist/types/ResponseInterface.d.ts.map
- dist/utils.d.ts
- dist/utils.d.ts.map
- src/__tests__/HyperDeckServer.spec.ts

@@ -93,2 +95,3 @@ - src/__tests__/messageForCode.spec.ts

- src/types/ResponseInterface.ts
- src/utils.ts
"

@@ -95,0 +98,0 @@ `);

@@ -1,24 +0,6 @@

import { Timecode } from './Timecode';
import { VideoFormat } from './types';
import { invariant } from './invariant';
import { camelcaseToSpaceCase } from './utils';
import { ArgKey } from './types';
type ArgStringTypes = Record<string, keyof TypesByStringKey>;
interface TypesByStringKey {
boolean: boolean;
string: string;
timecode: Timecode;
number: number;
videoformat: VideoFormat;
stopmode: 'lastframe' | 'nextframe' | 'black';
goto: 'start' | 'end' | string | number;
videoinput: 'SDI' | 'HDMI' | 'component';
audioinput: 'XLR' | 'RCA';
fileformat: string;
audiocodec: 'PCM' | 'AAC';
timecodeinput: 'external' | 'embedded' | 'preset' | 'clip';
recordtrigger: 'none' | 'recordbit' | 'timecoderun';
}
interface Option<T extends ArgStringTypes> {
interface Option<T extends Record<string, ArgKey> = Record<string, ArgKey>> {
description: string;

@@ -28,8 +10,4 @@ arguments?: T;

// type ArgsTypes<T extends ArgStringTypes> = {
// [K in keyof T]?: T[K] extends (infer R)[] ? R : TypesByStringKey[T[K]]
// }
type ParamMap = Record<string, Option>;
type ParamMap = Record<string, Option<any>>;
/** Internal container class that holds metadata about each HyperDeck event */

@@ -39,3 +17,3 @@ class HyperDeckAPI<T extends ParamMap = {}> {

public addOption = <K extends string, R extends ArgStringTypes = {}>(
public addOption = <K extends string, R extends Record<string, ArgKey> = {}>(
key: K | [K, ...string[]],

@@ -49,17 +27,25 @@ option: Option<R>

Object.assign(this.options, { [k]: option });
return this;
return this as any;
};
/** Get a Set of param names keyed by function name */
public getParamsByKey = (): { [K in keyof T]: Set<string> } =>
Object.entries(this.options).reduce<Record<string, Set<string>>>((prev, [key, value]) => {
prev[key] = new Set(
value.arguments
? Object.keys(value.arguments).map((key) =>
key.replace(/([a-z])([A-Z]+)/g, '$1 $2').toLowerCase()
)
: []
);
return prev;
}, {}) as any;
/** Get a `Set` of param names keyed by function name */
public getParamsByKey = (): { [K in keyof T]: Record<string, ArgKey> } =>
Object.entries(this.options).reduce<Record<string, Record<string, ArgKey>>>(
(prev, [commandName, value]) => {
if (!value.arguments) {
// we still want hasOwnProperty(key) to be true
prev[commandName] = {};
return prev;
}
prev[commandName] = Object.entries(value.arguments).reduce<Record<string, ArgKey>>(
(argObj, [argKey, argType]) => {
argObj[camelcaseToSpaceCase(argKey)] = argType;
return argObj;
},
{}
);
return prev;
},
{}
) as any;
}

@@ -66,0 +52,0 @@

import { CRLF } from './constants';
import { ResponseCode, responseNamesByCode } from './types';
import { invariant } from './invariant';
import { camelcaseToSpaceCase } from './utils';

@@ -50,3 +51,3 @@ // escape CR/LF and remove colons

// convert camelCase keys to space-separated words
const formattedKey = key.replace(/([a-z])([A-Z]+)/g, '$1 $2').toLowerCase();
const formattedKey = camelcaseToSpaceCase(key);

@@ -53,0 +54,0 @@ return prev + formattedKey + ': ' + valueString + CRLF;

@@ -83,3 +83,3 @@ import type { DeserializedCommand } from './types';

nextParam = (bobs.pop() + ' ' + nextParam).trim();
if (paramNames.has(nextParam)) {
if (paramNames.hasOwnProperty(nextParam)) {
break;

@@ -86,0 +86,0 @@ }

@@ -22,2 +22,13 @@ import { invariant } from './invariant';

public toString: () => string;
static toTimecode = (tcString: string): Timecode => {
const bits = tcString.split(':');
invariant(bits.length === 4, 'Expected 4 bits, received %o bits', bits.length);
const bitsInt = bits.map((bit) => {
const bitInt = parseInt(bit, 10);
invariant(!isNaN(bitInt), 'bit `%s` is NaN', bit);
return bitInt;
});
return new Timecode(bitsInt[0], bitsInt[1], bitsInt[2], bitsInt[3]);
};
}

@@ -0,1 +1,4 @@

import { invariant } from './invariant';
import { Timecode } from './Timecode';
export interface NotificationConfig {

@@ -162,22 +165,158 @@ transport: boolean;

export enum FileFormat {
QuickTimeUncompressed = 'QuickTimeUncompressed',
QuickTimeProResHQ = 'QuickTimeProResHQ',
QuickTimeProRes = 'QuickTimeProRes',
QuickTimeProResLT = 'QuickTimeProResLT',
QuickTimeProResProxy = 'QuickTimeProResProxy',
QuickTimeDNxHR220 = 'QuickTimeDNxHR220',
DNxHR220 = 'DNxHR220',
}
export const stopModes = {
lastframe: true,
nextframe: true,
black: true,
};
export enum AudioInput {
embedded = 'embedded',
XLR = 'XLR',
RCA = 'RCA',
export type StopMode = keyof typeof stopModes;
export const isStopMode = (value: any): value is StopMode => {
return typeof value === 'string' && stopModes.hasOwnProperty(value);
};
export const videoInputs = {
SDI: true,
HDMI: true,
component: true,
};
export type VideoInput = keyof typeof videoInputs;
export const isVideoInput = (value: any): value is VideoInput => {
return typeof value === 'string' && videoInputs.hasOwnProperty(value);
};
export const audioInputs = {
XLR: true,
RCA: true,
// TODO(meyer) verify this
embedded: true,
};
export type AudioInput = keyof typeof audioInputs;
export const isAudioInput = (value: any): value is AudioInput => {
return typeof value === 'string' && audioInputs.hasOwnProperty(value);
};
export const audioCodecs = {
PCM: true,
AAC: true,
};
export type AudioCodec = keyof typeof audioCodecs;
export const isAudioCodec = (value: any): value is AudioCodec => {
return typeof value === 'string' && audioCodecs.hasOwnProperty(value);
};
export const timecodeInputs = {
external: true,
embedded: true,
preset: true,
clip: true,
};
export type TimecodeInput = keyof typeof timecodeInputs;
export const isTimecodeInput = (value: any): value is TimecodeInput => {
return typeof value === 'string' && timecodeInputs.hasOwnProperty(value);
};
export const recordTriggers = {
none: true,
recordbit: true,
timecoderun: true,
};
export type RecordTrigger = keyof typeof recordTriggers;
export const isRecordTrigger = (value: any): value is RecordTrigger => {
return typeof value === 'string' && recordTriggers.hasOwnProperty(value);
};
export type FileFormat =
| 'QuickTimeUncompressed'
| 'QuickTimeProResHQ'
| 'QuickTimeProRes'
| 'QuickTimeProResLT'
| 'QuickTimeProResProxy'
| 'QuickTimeDNxHR220'
| 'DNxHR220';
export type ArgKey = keyof TypesByStringKey;
export interface TypesByStringKey {
boolean: boolean;
string: string;
timecode: Timecode;
number: number;
videoformat: VideoFormat;
stopmode: StopMode;
goto: 'start' | 'end' | string | number;
videoinput: VideoInput;
audioinput: AudioInput;
fileformat: string;
audiocodec: AudioCodec;
timecodeinput: TimecodeInput;
recordtrigger: RecordTrigger;
}
export enum VideoInputs {
SDI = 'SDI',
HDMI = 'HDMI',
component = 'component',
}
export const stringToValueFns: {
/** Coerce string to the correct type or throw if the string cannot be converted. */
[K in keyof TypesByStringKey]: (value: string) => TypesByStringKey[K];
} = {
boolean: (value) => {
if (value === 'true') return true;
if (value === 'false') return false;
invariant(false, 'Unsupported value `%o` passed to `boolean`', value);
},
string: (value) => value,
timecode: (value) => Timecode.toTimecode(value),
number: (value) => {
const valueNum = parseFloat(value);
invariant(!isNaN(valueNum), 'valueNum `%o` is NaN', value);
return valueNum;
},
videoformat: (value) => {
invariant(isVideoFormat(value), 'Unsupported video format: `%o`');
return value;
},
stopmode: (value) => {
invariant(isStopMode(value), 'Unsupported stopmode: `%o`', value);
return value;
},
goto: (value) => {
if (value === 'start' || value === 'end') {
return value;
}
const valueNum = parseInt(value, 10);
if (!isNaN(valueNum)) {
return valueNum;
}
// TODO(meyer) validate further
return value;
},
videoinput: (value) => {
invariant(isVideoInput(value), 'Unsupported video input: `%o`', value);
return value;
},
audioinput: (value) => {
invariant(isAudioInput(value), 'Unsupported audio input: `%o`', value);
return value;
},
fileformat: (value) => value,
audiocodec: (value) => {
invariant(isAudioCodec(value), 'Unsupported audio codec: `%o`', value);
return value;
},
timecodeinput: (value) => {
invariant(isTimecodeInput(value), 'Unsupported timecode input: `%o`', value);
return value;
},
recordtrigger: (value) => {
invariant(isRecordTrigger(value), 'Unsupported record trigger: `%o`', value);
return value;
},
};

@@ -7,3 +7,3 @@ import type { Timecode } from '../Timecode';

AudioInput,
VideoInputs,
VideoInput,
FileFormat,

@@ -66,3 +66,3 @@ } from '../types';

'audio input': AudioInput;
'video input': VideoInputs;
'video input': VideoInput;
'file format': FileFormat;

@@ -69,0 +69,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc