@meyer/hyperdeck-emulator
Advanced tools
Comparing version 0.0.4-canary.14.326f2c9 to 0.0.4-canary.24.60511e7
@@ -286,2 +286,3 @@ 'use strict'; | ||
CommandNames["NotifyCommand"] = "notify"; | ||
CommandNames["GoToCommand"] = "goto"; | ||
CommandNames["JogCommand"] = "jog"; | ||
@@ -720,2 +721,3 @@ CommandNames["ShuttleCommand"] = "shuttle"; | ||
this.onSlotSelect = noop; | ||
this.onGoTo = noop; | ||
this.onJog = noop; | ||
@@ -788,3 +790,3 @@ this.onShuttle = noop; | ||
try { | ||
var _exit23 = false; | ||
var _exit24 = false; | ||
@@ -798,105 +800,126 @@ var _this3 = this; | ||
return Promise.resolve(_catch(function () { | ||
function _temp44(_result) { | ||
function _temp46(_result) { | ||
var _exit2 = false; | ||
if (_exit23) return _result; | ||
if (_exit24) return _result; | ||
function _temp42(_result2) { | ||
function _temp44(_result2) { | ||
var _exit3 = false; | ||
if (_exit2) return _result2; | ||
function _temp40(_result3) { | ||
function _temp42(_result3) { | ||
var _exit4 = false; | ||
if (_exit3) return _result3; | ||
function _temp38(_result4) { | ||
function _temp40(_result4) { | ||
var _exit5 = false; | ||
if (_exit4) return _result4; | ||
function _temp36(_result5) { | ||
function _temp38(_result5) { | ||
var _exit6 = false; | ||
if (_exit5) return _result5; | ||
function _temp34(_result6) { | ||
function _temp36(_result6) { | ||
var _exit7 = false; | ||
if (_exit6) return _result6; | ||
function _temp32(_result7) { | ||
function _temp34(_result7) { | ||
var _exit8 = false; | ||
if (_exit7) return _result7; | ||
function _temp30(_result8) { | ||
function _temp32(_result8) { | ||
var _exit9 = false; | ||
if (_exit8) return _result8; | ||
function _temp28(_result9) { | ||
function _temp30(_result9) { | ||
var _exit10 = false; | ||
if (_exit9) return _result9; | ||
function _temp26(_result10) { | ||
function _temp28(_result10) { | ||
var _exit11 = false; | ||
if (_exit10) return _result10; | ||
function _temp24(_result11) { | ||
function _temp26(_result11) { | ||
var _exit12 = false; | ||
if (_exit11) return _result11; | ||
function _temp22(_result12) { | ||
function _temp24(_result12) { | ||
var _exit13 = false; | ||
if (_exit12) return _result12; | ||
function _temp20(_result13) { | ||
function _temp22(_result13) { | ||
var _exit14 = false; | ||
if (_exit13) return _result13; | ||
function _temp18(_result14) { | ||
function _temp20(_result14) { | ||
var _exit15 = false; | ||
if (_exit14) return _result14; | ||
function _temp16(_result15) { | ||
function _temp18(_result15) { | ||
var _exit16 = false; | ||
if (_exit15) return _result15; | ||
function _temp14(_result16) { | ||
function _temp16(_result16) { | ||
var _exit17 = false; | ||
if (_exit16) return _result16; | ||
function _temp12(_result17) { | ||
function _temp14(_result17) { | ||
var _exit18 = false; | ||
if (_exit17) return _result17; | ||
function _temp10(_result18) { | ||
function _temp12(_result18) { | ||
var _exit19 = false; | ||
if (_exit18) return _result18; | ||
function _temp8(_result19) { | ||
function _temp10(_result19) { | ||
var _exit20 = false; | ||
if (_exit19) return _result19; | ||
function _temp6(_result20) { | ||
function _temp8(_result20) { | ||
var _exit21 = false; | ||
if (_exit20) return _result20; | ||
function _temp4(_result21) { | ||
function _temp6(_result21) { | ||
var _exit22 = false; | ||
if (_exit21) return _result21; | ||
function _temp2(_result22) { | ||
function _temp4(_result22) { | ||
var _exit23 = false; | ||
if (_exit22) return _result22; | ||
if (cmd.name === CommandNames.WatchdogCommand) { | ||
// implemented in socket.ts | ||
return new TResponse(exports.SynchronousCode.OK); | ||
} | ||
function _temp2(_result23) { | ||
if (_exit23) return _result23; | ||
if (cmd.name === CommandNames.PingCommand) { | ||
// implemented in socket.ts | ||
return new TResponse(exports.SynchronousCode.OK); | ||
if (cmd.name === CommandNames.WatchdogCommand) { | ||
// implemented in socket.ts | ||
return new TResponse(exports.SynchronousCode.OK); | ||
} | ||
if (cmd.name === CommandNames.PingCommand) { | ||
// implemented in socket.ts | ||
return new TResponse(exports.SynchronousCode.OK); | ||
} | ||
throw new Error('Unhandled command name: ' + cmd.name); | ||
} | ||
throw new Error('Unhandled command name: ' + cmd.name); | ||
var _temp = function () { | ||
if (cmd.name === CommandNames.IdentifyCommand) { | ||
return Promise.resolve(_this3.onIdentify(cmd)).then(function () { | ||
_exit23 = true; | ||
return new TResponse(exports.SynchronousCode.OK); | ||
}); | ||
} | ||
}(); | ||
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp); | ||
} | ||
var _temp = function () { | ||
if (cmd.name === CommandNames.IdentifyCommand) { | ||
return Promise.resolve(_this3.onIdentify(cmd)).then(function () { | ||
var _temp3 = function () { | ||
if (cmd.name === CommandNames.FormatCommand) { | ||
return Promise.resolve(_this3.onFormat(cmd)).then(function (res) { | ||
if (res) { | ||
_exit22 = true; | ||
return new TResponse(exports.SynchronousCode.FormatReady, res); | ||
} | ||
_exit22 = true; | ||
@@ -908,15 +931,10 @@ return new TResponse(exports.SynchronousCode.OK); | ||
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp); | ||
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3); | ||
} | ||
var _temp3 = function () { | ||
if (cmd.name === CommandNames.FormatCommand) { | ||
return Promise.resolve(_this3.onFormat(cmd)).then(function (res) { | ||
if (res) { | ||
_exit21 = true; | ||
return new TResponse(exports.SynchronousCode.FormatReady, res); | ||
} | ||
var _temp5 = function () { | ||
if (cmd.name === CommandNames.UptimeCommand) { | ||
return Promise.resolve(_this3.onUptime(cmd)).then(function (res) { | ||
_exit21 = true; | ||
return new TResponse(exports.SynchronousCode.OK); | ||
return new TResponse(exports.SynchronousCode.Uptime, res); | ||
}); | ||
@@ -926,10 +944,15 @@ } | ||
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3); | ||
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5); | ||
} | ||
var _temp5 = function () { | ||
if (cmd.name === CommandNames.UptimeCommand) { | ||
return Promise.resolve(_this3.onUptime(cmd)).then(function (res) { | ||
var _temp7 = function () { | ||
if (cmd.name === CommandNames.ConfigurationCommand) { | ||
return Promise.resolve(_this3.onConfiguration(cmd)).then(function (res) { | ||
if (res) { | ||
_exit20 = true; | ||
return new TResponse(exports.SynchronousCode.Configuration, res); | ||
} | ||
_exit20 = true; | ||
return new TResponse(exports.SynchronousCode.Uptime, res); | ||
return new TResponse(exports.SynchronousCode.OK); | ||
}); | ||
@@ -939,15 +962,15 @@ } | ||
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5); | ||
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7); | ||
} | ||
var _temp7 = function () { | ||
if (cmd.name === CommandNames.ConfigurationCommand) { | ||
return Promise.resolve(_this3.onConfiguration(cmd)).then(function (res) { | ||
if (res) { | ||
var _temp9 = function () { | ||
if (cmd.name === CommandNames.RemoteCommand) { | ||
return Promise.resolve(_this3.onRemote(cmd)).then(function (res) { | ||
if (!res) { | ||
_exit19 = true; | ||
return new TResponse(exports.SynchronousCode.Configuration, res); | ||
return new TResponse(exports.SynchronousCode.OK); | ||
} | ||
_exit19 = true; | ||
return new TResponse(exports.SynchronousCode.OK); | ||
return new TResponse(exports.SynchronousCode.Remote, res); | ||
}); | ||
@@ -957,15 +980,10 @@ } | ||
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7); | ||
return _temp9 && _temp9.then ? _temp9.then(_temp10) : _temp10(_temp9); | ||
} | ||
var _temp9 = function () { | ||
if (cmd.name === CommandNames.RemoteCommand) { | ||
return Promise.resolve(_this3.onRemote(cmd)).then(function (res) { | ||
if (!res) { | ||
_exit18 = true; | ||
return new TResponse(exports.SynchronousCode.OK); | ||
} | ||
var _temp11 = function () { | ||
if (cmd.name === CommandNames.ShuttleCommand) { | ||
return Promise.resolve(_this3.onShuttle(cmd)).then(function () { | ||
_exit18 = true; | ||
return new TResponse(exports.SynchronousCode.Remote, res); | ||
return new TResponse(exports.SynchronousCode.OK); | ||
}); | ||
@@ -975,8 +993,8 @@ } | ||
return _temp9 && _temp9.then ? _temp9.then(_temp10) : _temp10(_temp9); | ||
return _temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11); | ||
} | ||
var _temp11 = function () { | ||
if (cmd.name === CommandNames.ShuttleCommand) { | ||
return Promise.resolve(_this3.onShuttle(cmd)).then(function () { | ||
var _temp13 = function () { | ||
if (cmd.name === CommandNames.JogCommand) { | ||
return Promise.resolve(_this3.onJog(cmd)).then(function () { | ||
_exit17 = true; | ||
@@ -988,3 +1006,3 @@ return new TResponse(exports.SynchronousCode.OK); | ||
return _temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11); | ||
return _temp13 && _temp13.then ? _temp13.then(_temp14) : _temp14(_temp13); | ||
} | ||
@@ -997,5 +1015,5 @@ | ||
var _temp13 = function () { | ||
if (cmd.name === CommandNames.JogCommand) { | ||
return Promise.resolve(_this3.onJog(cmd)).then(function () { | ||
var _temp15 = function () { | ||
if (cmd.name === CommandNames.GoToCommand) { | ||
return Promise.resolve(_this3.onGoTo(cmd)).then(function () { | ||
_exit16 = true; | ||
@@ -1007,6 +1025,6 @@ return new TResponse(exports.SynchronousCode.OK); | ||
return _temp13 && _temp13.then ? _temp13.then(_temp14) : _temp14(_temp13); | ||
return _temp15 && _temp15.then ? _temp15.then(_temp16) : _temp16(_temp15); | ||
} | ||
var _temp15 = function () { | ||
var _temp17 = function () { | ||
if (cmd.name === CommandNames.SlotSelectCommand) { | ||
@@ -1020,6 +1038,6 @@ return Promise.resolve(_this3.onSlotSelect(cmd)).then(function () { | ||
return _temp15 && _temp15.then ? _temp15.then(_temp16) : _temp16(_temp15); | ||
return _temp17 && _temp17.then ? _temp17.then(_temp18) : _temp18(_temp17); | ||
} | ||
var _temp17 = function () { | ||
var _temp19 = function () { | ||
if (cmd.name === CommandNames.SlotInfoCommand) { | ||
@@ -1033,6 +1051,6 @@ return Promise.resolve(_this3.onSlotInfo(cmd)).then(function (res) { | ||
return _temp17 && _temp17.then ? _temp17.then(_temp18) : _temp18(_temp17); | ||
return _temp19 && _temp19.then ? _temp19.then(_temp20) : _temp20(_temp19); | ||
} | ||
var _temp19 = function () { | ||
var _temp21 = function () { | ||
if (cmd.name === CommandNames.TransportInfoCommand) { | ||
@@ -1046,6 +1064,6 @@ return Promise.resolve(_this3.onTransportInfo(cmd)).then(function (res) { | ||
return _temp19 && _temp19.then ? _temp19.then(_temp20) : _temp20(_temp19); | ||
return _temp21 && _temp21.then ? _temp21.then(_temp22) : _temp22(_temp21); | ||
} | ||
var _temp21 = function () { | ||
var _temp23 = function () { | ||
if (cmd.name === CommandNames.ClipsClearCommand) { | ||
@@ -1059,6 +1077,6 @@ return Promise.resolve(_this3.onClipsClear(cmd)).then(function () { | ||
return _temp21 && _temp21.then ? _temp21.then(_temp22) : _temp22(_temp21); | ||
return _temp23 && _temp23.then ? _temp23.then(_temp24) : _temp24(_temp23); | ||
} | ||
var _temp23 = function () { | ||
var _temp25 = function () { | ||
if (cmd.name === CommandNames.ClipsAddCommand) { | ||
@@ -1072,6 +1090,6 @@ return Promise.resolve(_this3.onClipsAdd(cmd)).then(function () { | ||
return _temp23 && _temp23.then ? _temp23.then(_temp24) : _temp24(_temp23); | ||
return _temp25 && _temp25.then ? _temp25.then(_temp26) : _temp26(_temp25); | ||
} | ||
var _temp25 = function () { | ||
var _temp27 = function () { | ||
if (cmd.name === CommandNames.ClipsGetCommand) { | ||
@@ -1085,6 +1103,6 @@ return Promise.resolve(_this3.onClipsGet(cmd)).then(function (res) { | ||
return _temp25 && _temp25.then ? _temp25.then(_temp26) : _temp26(_temp25); | ||
return _temp27 && _temp27.then ? _temp27.then(_temp28) : _temp28(_temp27); | ||
} | ||
var _temp27 = function () { | ||
var _temp29 = function () { | ||
if (cmd.name === CommandNames.ClipsCountCommand) { | ||
@@ -1098,6 +1116,6 @@ return Promise.resolve(_this3.onClipsCount(cmd)).then(function (res) { | ||
return _temp27 && _temp27.then ? _temp27.then(_temp28) : _temp28(_temp27); | ||
return _temp29 && _temp29.then ? _temp29.then(_temp30) : _temp30(_temp29); | ||
} | ||
var _temp29 = function () { | ||
var _temp31 = function () { | ||
if (cmd.name === CommandNames.StopCommand) { | ||
@@ -1111,6 +1129,6 @@ return Promise.resolve(_this3.onStop(cmd)).then(function () { | ||
return _temp29 && _temp29.then ? _temp29.then(_temp30) : _temp30(_temp29); | ||
return _temp31 && _temp31.then ? _temp31.then(_temp32) : _temp32(_temp31); | ||
} | ||
var _temp31 = function () { | ||
var _temp33 = function () { | ||
if (cmd.name === CommandNames.RecordCommand) { | ||
@@ -1124,6 +1142,6 @@ return Promise.resolve(_this3.onRecord(cmd)).then(function () { | ||
return _temp31 && _temp31.then ? _temp31.then(_temp32) : _temp32(_temp31); | ||
return _temp33 && _temp33.then ? _temp33.then(_temp34) : _temp34(_temp33); | ||
} | ||
var _temp33 = function () { | ||
var _temp35 = function () { | ||
if (cmd.name === CommandNames.PlayrangeClearCommand) { | ||
@@ -1137,6 +1155,6 @@ return Promise.resolve(_this3.onPlayrangeClear(cmd)).then(function () { | ||
return _temp33 && _temp33.then ? _temp33.then(_temp34) : _temp34(_temp33); | ||
return _temp35 && _temp35.then ? _temp35.then(_temp36) : _temp36(_temp35); | ||
} | ||
var _temp35 = function () { | ||
var _temp37 = function () { | ||
if (cmd.name === CommandNames.PlayrangeSetCommand) { | ||
@@ -1150,6 +1168,6 @@ return Promise.resolve(_this3.onPlayrangeSet(cmd)).then(function () { | ||
return _temp35 && _temp35.then ? _temp35.then(_temp36) : _temp36(_temp35); | ||
return _temp37 && _temp37.then ? _temp37.then(_temp38) : _temp38(_temp37); | ||
} | ||
var _temp37 = function () { | ||
var _temp39 = function () { | ||
if (cmd.name === CommandNames.PlayCommand) { | ||
@@ -1163,6 +1181,6 @@ return Promise.resolve(_this3.onPlay(cmd)).then(function () { | ||
return _temp37 && _temp37.then ? _temp37.then(_temp38) : _temp38(_temp37); | ||
return _temp39 && _temp39.then ? _temp39.then(_temp40) : _temp40(_temp39); | ||
} | ||
var _temp39 = function () { | ||
var _temp41 = function () { | ||
if (cmd.name === CommandNames.PreviewCommand) { | ||
@@ -1176,6 +1194,6 @@ return Promise.resolve(_this3.onPreview(cmd)).then(function () { | ||
return _temp39 && _temp39.then ? _temp39.then(_temp40) : _temp40(_temp39); | ||
return _temp41 && _temp41.then ? _temp41.then(_temp42) : _temp42(_temp41); | ||
} | ||
var _temp41 = function () { | ||
var _temp43 = function () { | ||
if (cmd.name === CommandNames.DiskListCommand) { | ||
@@ -1189,9 +1207,9 @@ return Promise.resolve(_this3.onDiskList(cmd)).then(function (res) { | ||
return _temp41 && _temp41.then ? _temp41.then(_temp42) : _temp42(_temp41); | ||
return _temp43 && _temp43.then ? _temp43.then(_temp44) : _temp44(_temp43); | ||
} | ||
var _temp43 = function () { | ||
var _temp45 = function () { | ||
if (cmd.name === CommandNames.DeviceInfoCommand) { | ||
return Promise.resolve(_this3.onDeviceInfo(cmd)).then(function (res) { | ||
_exit23 = true; | ||
_exit24 = true; | ||
return new TResponse(exports.SynchronousCode.DeviceInfo, res); | ||
@@ -1202,3 +1220,3 @@ }); | ||
return _temp43 && _temp43.then ? _temp43.then(_temp44) : _temp44(_temp43); | ||
return _temp45 && _temp45.then ? _temp45.then(_temp46) : _temp46(_temp45); | ||
}, function (err) { | ||
@@ -1205,0 +1223,0 @@ if (err instanceof UnimplementedError) { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("events"),o=require("util"),r=require("net"),t=(e=require("pino"))&&"object"==typeof e&&"default"in e?e.default:e;function i(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,n){return(a=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,o){return(c=u()?Reflect.construct:function(e,n,o){var r=[null];r.push.apply(r,n);var t=new(Function.bind.apply(e,r));return o&&a(t,o.prototype),t}).apply(null,arguments)}function f(e){var n="function"==typeof Map?new Map:void 0;return(f=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,o)}function o(){return c(e,arguments,s(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),a(o,e)})(e)}function p(e,n){(null==n||n>e.length)&&(n=e.length);for(var o=0,r=new Array(n);o<n;o++)r[o]=e[o];return r}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var d,m,l,h,C,y,v=function(){function e(e,n){this.code=e,this.params=n,this.name=P[e]}return e.prototype.build=function(){var e=o.format("%d %s",this.code,this.name);if(this.params){e+=":\r\n";for(var n=0,r=Object.entries(this.params);n<r.length;n++){var t=r[n],i=t[1];i&&(e+=o.format("%s: %s",t[0],i)+"\r\n")}}return e+"\r\n"},e}(),g=function(e,n){var r=this;this.code=e,this.message=n,this.build=function(){return o.format("%d %s",r.code,r.message)}};(m=exports.ErrorCode||(exports.ErrorCode={}))[m.SyntaxError=100]="SyntaxError",m[m.UnsupportedParameter=101]="UnsupportedParameter",m[m.InvalidValue=102]="InvalidValue",m[m.Unsupported=103]="Unsupported",m[m.DiskFull=104]="DiskFull",m[m.NoDisk=105]="NoDisk",m[m.DiskError=106]="DiskError",m[m.TimelineEmpty=107]="TimelineEmpty",m[m.InternalError=108]="InternalError",m[m.OutOfRange=109]="OutOfRange",m[m.NoInput=110]="NoInput",m[m.RemoteControlDisabled=111]="RemoteControlDisabled",m[m.ConnectionRejected=120]="ConnectionRejected",m[m.InvalidState=150]="InvalidState",m[m.InvalidCodec=151]="InvalidCodec",m[m.InvalidFormat=160]="InvalidFormat",m[m.InvalidToken=161]="InvalidToken",m[m.FormatNotPrepared=162]="FormatNotPrepared",(l=exports.SynchronousCode||(exports.SynchronousCode={}))[l.OK=200]="OK",l[l.SlotInfo=202]="SlotInfo",l[l.DeviceInfo=204]="DeviceInfo",l[l.ClipsInfo=205]="ClipsInfo",l[l.DiskList=206]="DiskList",l[l.TransportInfo=208]="TransportInfo",l[l.Notify=209]="Notify",l[l.Remote=210]="Remote",l[l.Configuration=211]="Configuration",l[l.ClipsCount=214]="ClipsCount",l[l.Uptime=215]="Uptime",l[l.FormatReady=216]="FormatReady",(h=exports.AsynchronousCode||(exports.AsynchronousCode={}))[h.ConnectionInfo=500]="ConnectionInfo",h[h.SlotInfo=502]="SlotInfo",h[h.TransportInfo=508]="TransportInfo",h[h.RemoteInfo=510]="RemoteInfo",h[h.ConfigurationInfo=511]="ConfigurationInfo",(C=exports.NotifyType||(exports.NotifyType={}))[C.Slot=0]="Slot",C[C.Transport=1]="Transport",C[C.Remote=2]="Remote",C[C.Configuration=3]="Configuration",function(e){e.DeviceInfoCommand="device info",e.DiskListCommand="disk list",e.PreviewCommand="preview",e.PlayCommand="play",e.PlayrangeSetCommand="playrange set",e.PlayrangeClearCommand="playrange clear",e.RecordCommand="record",e.StopCommand="stop",e.ClipsCountCommand="clips count",e.ClipsGetCommand="clips get",e.ClipsAddCommand="clips add",e.ClipsClearCommand="clips clear",e.TransportInfoCommand="transport info",e.SlotInfoCommand="slot info",e.SlotSelectCommand="slot select",e.NotifyCommand="notify",e.JogCommand="jog",e.ShuttleCommand="shuttle",e.RemoteCommand="remote",e.ConfigurationCommand="configuration",e.UptimeCommand="uptime",e.FormatCommand="format",e.IdentifyCommand="identify",e.WatchdogCommand="watchdog",e.PingCommand="ping"}(y||(y={}));var S,x,_,I,w,R,P=((d={})[exports.AsynchronousCode.ConfigurationInfo]="configuration info",d[exports.AsynchronousCode.ConnectionInfo]="connection info",d[exports.AsynchronousCode.RemoteInfo]="remote info",d[exports.AsynchronousCode.SlotInfo]=y.SlotInfoCommand,d[exports.AsynchronousCode.TransportInfo]=y.TransportInfoCommand,d[exports.ErrorCode.ConnectionRejected]="connection rejected",d[exports.ErrorCode.DiskError]="disk error",d[exports.ErrorCode.DiskFull]="disk full",d[exports.ErrorCode.FormatNotPrepared]="format not prepared",d[exports.ErrorCode.InternalError]="internal error",d[exports.ErrorCode.InvalidCodec]="invalid codec",d[exports.ErrorCode.InvalidFormat]="invalid format",d[exports.ErrorCode.InvalidState]="invalid state",d[exports.ErrorCode.InvalidToken]="invalid token",d[exports.ErrorCode.InvalidValue]="invalid value",d[exports.ErrorCode.NoDisk]="no disk",d[exports.ErrorCode.NoInput]="no input",d[exports.ErrorCode.OutOfRange]="out of range",d[exports.ErrorCode.RemoteControlDisabled]="remote control disabled",d[exports.ErrorCode.SyntaxError]="syntax error",d[exports.ErrorCode.TimelineEmpty]="timeline empty",d[exports.ErrorCode.Unsupported]="unsupported",d[exports.ErrorCode.UnsupportedParameter]="unsupported parameter",d[exports.SynchronousCode.ClipsCount]=y.ClipsCountCommand,d[exports.SynchronousCode.ClipsInfo]="clips info",d[exports.SynchronousCode.Configuration]=y.ConfigurationCommand,d[exports.SynchronousCode.DeviceInfo]=y.DeviceInfoCommand,d[exports.SynchronousCode.DiskList]=y.DiskListCommand,d[exports.SynchronousCode.FormatReady]="format ready",d[exports.SynchronousCode.Notify]=y.NotifyCommand,d[exports.SynchronousCode.OK]="ok",d[exports.SynchronousCode.Remote]=y.RemoteCommand,d[exports.SynchronousCode.SlotInfo]=y.SlotInfoCommand,d[exports.SynchronousCode.TransportInfo]=y.TransportInfoCommand,d[exports.SynchronousCode.Uptime]=y.UptimeCommand,d),T={help:[],commands:[],"device info":[],"disk list":["slot id"],quit:[],ping:[],preview:["enable"],play:["speed","loop","single clip"],"playrange set":["clip id","in","out"],"playrange clear":[],record:["name"],stop:[],"clips count":[],"clips get":["clip id","count"],"clips add":["name"],"clips clear":[],"transport info":[],"slot info":["slot id"],"slot select":["slot id","video format"],notify:["remote","transport","slot","configuration","dropped frames"],goto:["clip id","clip","timeline","timecode","slot id"],jog:["timecode"],shuttle:["speed"],remote:["enable","override"],configuration:["video input","audio input","file format"],uptime:[],format:["prepare","confirm"],identify:["enable"],watchdog:["period"]};!function(e){e.EMPTY="empty",e.MOUNTING="mounting",e.ERROR="error",e.MOUNTED="mounted"}(S||(S={})),(x=exports.VideoFormat||(exports.VideoFormat={})).NTSC="NTSC",x.PAL="PAL",x.NTSCp="NTSCp",x.PALp="PALp",x._720p50="720p50",x._720p5994="720p5994",x._720p60="720p60",x._1080p23976="1080p23976",x._1080p24="1080p24",x._1080p25="1080p25",x._1080p2997="1080p2997",x._1080p30="1080p30",x._1080i50="1080i50",x._1080i5994="1080i5994",x._1080i60="1080i60",x._4Kp23976="4Kp23976",x._4Kp24="4Kp24",x._4Kp25="4Kp25",x._4Kp2997="4Kp2997",x._4Kp30="4Kp30",x._4Kp50="4Kp50",x._4Kp5994="4Kp5994",x._4Kp60="4Kp60",(_=exports.TransportStatus||(exports.TransportStatus={})).PREVIEW="preview",_.STOPPED="stopped",_.PLAY="play",_.FORWARD="forward",_.REWIND="rewind",_.JOG="jog",_.SHUTTLE="shuttle",_.RECORD="record",(I=exports.FileFormats||(exports.FileFormats={})).QuickTimeUncompressed="QuickTimeUncompressed",I.QuickTimeProResHQ="QuickTimeProResHQ",I.QuickTimeProRes="QuickTimeProRes",I.QuickTimeProResLT="QuickTimeProResLT",I.QuickTimeProResProxy="QuickTimeProResProxy",I.QuickTimeDNxHR220="QuickTimeDNxHR220",I.DNxHR220="DNxHR220",function(e){e.embedded="embedded",e.XLR="XLR",e.RCA="RCA"}(w||(w={})),function(e){e.SDI="SDI",e.HDMI="HDMI",e.component="component"}(R||(R={}));var k=function(){function e(e){this._linesQueue=[],this._log=e.child({source:"MultilineParser"})}var n=e.prototype;return n.receivedString=function(e){var n=[],o=e.split("\r\n");for(o.length>0&&""===o[o.length-1]&&o.pop(),this._linesQueue=this._linesQueue.concat(o);this._linesQueue.length>0;)if(""!==this._linesQueue[0])if(-1===this._linesQueue[0].indexOf(":")||1===this._linesQueue.length&&this._linesQueue[0].indexOf(":")>0){var r=this.parseResponse(this._linesQueue.splice(0,1));r&&n.push(r)}else{var t=this._linesQueue.indexOf("");if(-1===t)break;var i=this._linesQueue.splice(0,t+1),s=this.parseResponse(i);s&&n.push(s)}else this._linesQueue.shift();return n},n.parseResponse=function(e){if(1===(e=e.map((function(e){return e.trim()}))).length&&e[0].indexOf(":")>-1){var n=e[0].split(": "),o=n.shift();if(!o)throw new Error("Unrecognised command");var r={},t=new Set(T[o]),i=n.shift();if(!i)throw new Error("No named parameters found");for(var s=0;s<n.length-1;s++){for(var a=n[s].split(" "),u="",c=a.length-1;c>=0&&(u=(a.pop()+" "+u).trim(),!t.has(u));c--);if(!a.length)throw new Error("Command malformed / paramName not recognised");r[i]=a.join(" "),i=u}return r[i]=n[n.length-1],{raw:e.join("\r\n"),name:o,parameters:r}}var f=e[0].match(/(.+?)(:|)$/im);if(!f)return this._log.error({header:e[0]},"failed to parse header"),null;for(var p=f[1],d={},m=1;m<e.length;m++){var l=e[m].match(/^(.*?): (.*)$/im);l?d[l[1]]=l[2]:this._log.error({line:e[m]},"failed to parse line")}return{raw:e.join("\r\n"),name:p,parameters:d}},e}(),b=function(e){function n(n,o,r){var t;return(t=e.call(this)||this)._socket=n,t.logger=o,t._receivedCommand=r,t._lastReceived=-1,t._watchdogTimer=null,t._notifySettings={slot:!1,transport:!1,remote:!1,configuration:!1,"dropped frames":!1},t._parser=new k(t.logger),t._socket.setEncoding("utf-8"),t._socket.on("data",(function(e){t._onMessage(e)})),t._socket.on("error",(function(){o.info("error"),t._socket.destroy(),t.emit("disconnected"),o.info("disconnected")})),t.sendResponse(new v(exports.AsynchronousCode.ConnectionInfo,{"protocol version":"1.6",model:"NodeJS Hyperdeck Server Library"})),t}i(n,e);var o=n.prototype;return o._onMessage=function(e){var n=this;this.logger.debug("onMessage(%s)",e),this._lastReceived=Date.now();var o=this._parser.receivedString(e);this.logger.debug("commands:",o);for(var r,t=function(e,n){var o;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(o=function(e,n){if(e){if("string"==typeof e)return p(e,void 0);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?p(e,void 0):void 0}}(e))){o&&(e=o);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(o=e[Symbol.iterator]()).next.bind(o)}(o);!(r=t()).done;){var i=r.value;if(i.name===y.WatchdogCommand)!function(){n._watchdogTimer&&clearInterval(n._watchdogTimer);var e=i;e.parameters.period&&(n._watchdogTimer=setInterval((function(){Date.now()-n._lastReceived>Number(e.parameters.period)&&(n._socket.destroy(),n.emit("disconnected"),n._watchdogTimer&&clearInterval(n._watchdogTimer))}),1e3*Number(e.parameters.period)))}();else if(i.name===y.NotifyCommand){var s=i;if(!(Object.keys(s.parameters).length>0)){for(var a={},u=0,c=Object.keys(this._notifySettings);u<c.length;u++){var f=c[u];a[f]=this._notifySettings[f]?"true":"false"}this.sendResponse(new v(exports.SynchronousCode.Notify,a));continue}for(var d=0,m=Object.keys(s.parameters);d<m.length;d++){var l=m[d];void 0!==this._notifySettings[l]&&(this._notifySettings[l]="true"===s.parameters[l])}}this._receivedCommand(i).then((function(e){n.logger.info({res:e},"_receivedCommand response"),n.sendResponse(e)}),(function(){n.logger.error({},"_receivedCommand error response"),n.sendResponse(new v(exports.ErrorCode.Unsupported))}))}},o.sendResponse=function(e){var n=e.build();this._socket.write(n)},o.notify=function(e,n){this.logger.debug("notify:",e,n),e===exports.NotifyType.Configuration&&this._notifySettings.configuration?this.sendResponse(new v(exports.AsynchronousCode.ConfigurationInfo,n)):e===exports.NotifyType.Remote&&this._notifySettings.remote?this.sendResponse(new v(exports.AsynchronousCode.RemoteInfo,n)):e===exports.NotifyType.Slot&&this._notifySettings.slot?this.sendResponse(new v(exports.AsynchronousCode.SlotInfo,n)):e===exports.NotifyType.Transport&&this._notifySettings.transport&&this.sendResponse(new v(exports.AsynchronousCode.TransportInfo,n))},n}(n.EventEmitter),E=function(e){function n(){return e.apply(this,arguments)||this}return i(n,e),n}(f(Error)),O=function(){try{throw new E}catch(e){return Promise.reject(e)}};exports.HyperdeckServer=function(){function e(e,n){var o=this;void 0===n&&(n=t()),this._sockets={},this.onDeviceInfo=O,this.onDiskList=O,this.onPreview=O,this.onPlay=O,this.onPlayrangeSet=O,this.onPlayrangeClear=O,this.onRecord=O,this.onStop=O,this.onClipsCount=O,this.onClipsGet=O,this.onClipsAdd=O,this.onClipsClear=O,this.onTransportInfo=O,this.onSlotInfo=O,this.onSlotSelect=O,this.onJog=O,this.onShuttle=O,this.onRemote=O,this.onConfiguration=O,this.onUptime=O,this.onFormat=O,this.onIdentify=O,this.onWatchdog=O,this.logger=n.child({source:"HyperDeck Emulator"}),this._server=r.createServer((function(e){o.logger.debug("connection");var n=Math.random().toString(35).substr(-6);o._sockets[n]=new b(e,o.logger.child({source:"HyperDeck socket "+n}),(function(e){return o._receivedCommand(e)})),o._sockets[n].on("disconnected",(function(){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(exports.NotifyType.Slot,e)},n.notifyTransport=function(e){this._notify(exports.NotifyType.Transport,e)},n._notify=function(e,n){for(var o=0,r=Object.keys(this._sockets);o<r.length;o++)this._sockets[r[o]].notify(e,n)},n._receivedCommand=function(e){try{var n=!1,o=this;return o.logger.info({cmd:e},"_receivedCommand"),Promise.resolve(function(r,t){try{var i=function(){function r(r){var t=!1;if(n)return r;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){if(t)return n;if(e.name===y.WatchdogCommand)return new v(exports.SynchronousCode.OK);if(e.name===y.PingCommand)return new v(exports.SynchronousCode.OK);throw new Error("Unhandled command name: "+e.name)}var s=function(){if(e.name===y.IdentifyCommand)return Promise.resolve(o.onIdentify(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.FormatCommand)return Promise.resolve(o.onFormat(e)).then((function(e){return e?(r=!0,new v(exports.SynchronousCode.FormatReady,e)):(r=!0,new v(exports.SynchronousCode.OK))}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.UptimeCommand)return Promise.resolve(o.onUptime(e)).then((function(e){return t=!0,new v(exports.SynchronousCode.Uptime,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ConfigurationCommand)return Promise.resolve(o.onConfiguration(e)).then((function(e){return e?(r=!0,new v(exports.SynchronousCode.Configuration,e)):(r=!0,new v(exports.SynchronousCode.OK))}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.RemoteCommand)return Promise.resolve(o.onRemote(e)).then((function(e){return e?(t=!0,new v(exports.SynchronousCode.Remote,e)):(t=!0,new v(exports.SynchronousCode.OK))}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ShuttleCommand)return Promise.resolve(o.onShuttle(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}if(e.name===y.NotifyCommand)return new v(exports.SynchronousCode.OK);var s=function(){if(e.name===y.JogCommand)return Promise.resolve(o.onJog(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.SlotSelectCommand)return Promise.resolve(o.onSlotSelect(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.SlotInfoCommand)return Promise.resolve(o.onSlotInfo(e)).then((function(e){return t=!0,new v(exports.SynchronousCode.SlotInfo,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.TransportInfoCommand)return Promise.resolve(o.onTransportInfo(e)).then((function(e){return r=!0,new v(exports.SynchronousCode.TransportInfo,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ClipsClearCommand)return Promise.resolve(o.onClipsClear(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ClipsAddCommand)return Promise.resolve(o.onClipsAdd(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ClipsGetCommand)return Promise.resolve(o.onClipsGet(e)).then((function(e){return t=!0,new v(exports.SynchronousCode.ClipsInfo,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ClipsCountCommand)return Promise.resolve(o.onClipsCount(e)).then((function(e){return r=!0,new v(exports.SynchronousCode.ClipsCount,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.StopCommand)return Promise.resolve(o.onStop(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.RecordCommand)return Promise.resolve(o.onRecord(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.PlayrangeClearCommand)return Promise.resolve(o.onPlayrangeClear(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.PlayrangeSetCommand)return Promise.resolve(o.onPlayrangeSet(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.PlayCommand)return Promise.resolve(o.onPlay(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.PreviewCommand)return Promise.resolve(o.onPreview(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.DiskListCommand)return Promise.resolve(o.onDiskList(e)).then((function(e){return t=!0,new v(exports.SynchronousCode.DiskList,e)}))}();return s&&s.then?s.then(i):i(s)}var t=function(){if(e.name===y.DeviceInfoCommand)return Promise.resolve(o.onDeviceInfo(e)).then((function(e){return n=!0,new v(exports.SynchronousCode.DeviceInfo,e)}))}();return t&&t.then?t.then(r):r(t)}()}catch(e){return t(e)}return i&&i.then?i.then(void 0,t):i}(0,(function(e){return e instanceof E?new v(exports.ErrorCode.Unsupported):e&&"number"==typeof e.code&&exports.ErrorCode[e.code]&&e.msg?new g(e.code,e.msg):new v(exports.ErrorCode.InternalError)})))}catch(e){return Promise.reject(e)}},e}(),exports.ResponseInterface={__proto__:null}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("events"),o=require("util"),r=require("net"),t=(e=require("pino"))&&"object"==typeof e&&"default"in e?e.default:e;function i(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,n){return(a=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,o){return(c=u()?Reflect.construct:function(e,n,o){var r=[null];r.push.apply(r,n);var t=new(Function.bind.apply(e,r));return o&&a(t,o.prototype),t}).apply(null,arguments)}function f(e){var n="function"==typeof Map?new Map:void 0;return(f=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,o)}function o(){return c(e,arguments,s(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),a(o,e)})(e)}function p(e,n){(null==n||n>e.length)&&(n=e.length);for(var o=0,r=new Array(n);o<n;o++)r[o]=e[o];return r}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var d,m,l,h,C,y,v=function(){function e(e,n){this.code=e,this.params=n,this.name=P[e]}return e.prototype.build=function(){var e=o.format("%d %s",this.code,this.name);if(this.params){e+=":\r\n";for(var n=0,r=Object.entries(this.params);n<r.length;n++){var t=r[n],i=t[1];i&&(e+=o.format("%s: %s",t[0],i)+"\r\n")}}return e+"\r\n"},e}(),g=function(e,n){var r=this;this.code=e,this.message=n,this.build=function(){return o.format("%d %s",r.code,r.message)}};(m=exports.ErrorCode||(exports.ErrorCode={}))[m.SyntaxError=100]="SyntaxError",m[m.UnsupportedParameter=101]="UnsupportedParameter",m[m.InvalidValue=102]="InvalidValue",m[m.Unsupported=103]="Unsupported",m[m.DiskFull=104]="DiskFull",m[m.NoDisk=105]="NoDisk",m[m.DiskError=106]="DiskError",m[m.TimelineEmpty=107]="TimelineEmpty",m[m.InternalError=108]="InternalError",m[m.OutOfRange=109]="OutOfRange",m[m.NoInput=110]="NoInput",m[m.RemoteControlDisabled=111]="RemoteControlDisabled",m[m.ConnectionRejected=120]="ConnectionRejected",m[m.InvalidState=150]="InvalidState",m[m.InvalidCodec=151]="InvalidCodec",m[m.InvalidFormat=160]="InvalidFormat",m[m.InvalidToken=161]="InvalidToken",m[m.FormatNotPrepared=162]="FormatNotPrepared",(l=exports.SynchronousCode||(exports.SynchronousCode={}))[l.OK=200]="OK",l[l.SlotInfo=202]="SlotInfo",l[l.DeviceInfo=204]="DeviceInfo",l[l.ClipsInfo=205]="ClipsInfo",l[l.DiskList=206]="DiskList",l[l.TransportInfo=208]="TransportInfo",l[l.Notify=209]="Notify",l[l.Remote=210]="Remote",l[l.Configuration=211]="Configuration",l[l.ClipsCount=214]="ClipsCount",l[l.Uptime=215]="Uptime",l[l.FormatReady=216]="FormatReady",(h=exports.AsynchronousCode||(exports.AsynchronousCode={}))[h.ConnectionInfo=500]="ConnectionInfo",h[h.SlotInfo=502]="SlotInfo",h[h.TransportInfo=508]="TransportInfo",h[h.RemoteInfo=510]="RemoteInfo",h[h.ConfigurationInfo=511]="ConfigurationInfo",(C=exports.NotifyType||(exports.NotifyType={}))[C.Slot=0]="Slot",C[C.Transport=1]="Transport",C[C.Remote=2]="Remote",C[C.Configuration=3]="Configuration",function(e){e.DeviceInfoCommand="device info",e.DiskListCommand="disk list",e.PreviewCommand="preview",e.PlayCommand="play",e.PlayrangeSetCommand="playrange set",e.PlayrangeClearCommand="playrange clear",e.RecordCommand="record",e.StopCommand="stop",e.ClipsCountCommand="clips count",e.ClipsGetCommand="clips get",e.ClipsAddCommand="clips add",e.ClipsClearCommand="clips clear",e.TransportInfoCommand="transport info",e.SlotInfoCommand="slot info",e.SlotSelectCommand="slot select",e.NotifyCommand="notify",e.GoToCommand="goto",e.JogCommand="jog",e.ShuttleCommand="shuttle",e.RemoteCommand="remote",e.ConfigurationCommand="configuration",e.UptimeCommand="uptime",e.FormatCommand="format",e.IdentifyCommand="identify",e.WatchdogCommand="watchdog",e.PingCommand="ping"}(y||(y={}));var S,x,_,I,w,R,P=((d={})[exports.AsynchronousCode.ConfigurationInfo]="configuration info",d[exports.AsynchronousCode.ConnectionInfo]="connection info",d[exports.AsynchronousCode.RemoteInfo]="remote info",d[exports.AsynchronousCode.SlotInfo]=y.SlotInfoCommand,d[exports.AsynchronousCode.TransportInfo]=y.TransportInfoCommand,d[exports.ErrorCode.ConnectionRejected]="connection rejected",d[exports.ErrorCode.DiskError]="disk error",d[exports.ErrorCode.DiskFull]="disk full",d[exports.ErrorCode.FormatNotPrepared]="format not prepared",d[exports.ErrorCode.InternalError]="internal error",d[exports.ErrorCode.InvalidCodec]="invalid codec",d[exports.ErrorCode.InvalidFormat]="invalid format",d[exports.ErrorCode.InvalidState]="invalid state",d[exports.ErrorCode.InvalidToken]="invalid token",d[exports.ErrorCode.InvalidValue]="invalid value",d[exports.ErrorCode.NoDisk]="no disk",d[exports.ErrorCode.NoInput]="no input",d[exports.ErrorCode.OutOfRange]="out of range",d[exports.ErrorCode.RemoteControlDisabled]="remote control disabled",d[exports.ErrorCode.SyntaxError]="syntax error",d[exports.ErrorCode.TimelineEmpty]="timeline empty",d[exports.ErrorCode.Unsupported]="unsupported",d[exports.ErrorCode.UnsupportedParameter]="unsupported parameter",d[exports.SynchronousCode.ClipsCount]=y.ClipsCountCommand,d[exports.SynchronousCode.ClipsInfo]="clips info",d[exports.SynchronousCode.Configuration]=y.ConfigurationCommand,d[exports.SynchronousCode.DeviceInfo]=y.DeviceInfoCommand,d[exports.SynchronousCode.DiskList]=y.DiskListCommand,d[exports.SynchronousCode.FormatReady]="format ready",d[exports.SynchronousCode.Notify]=y.NotifyCommand,d[exports.SynchronousCode.OK]="ok",d[exports.SynchronousCode.Remote]=y.RemoteCommand,d[exports.SynchronousCode.SlotInfo]=y.SlotInfoCommand,d[exports.SynchronousCode.TransportInfo]=y.TransportInfoCommand,d[exports.SynchronousCode.Uptime]=y.UptimeCommand,d),T={help:[],commands:[],"device info":[],"disk list":["slot id"],quit:[],ping:[],preview:["enable"],play:["speed","loop","single clip"],"playrange set":["clip id","in","out"],"playrange clear":[],record:["name"],stop:[],"clips count":[],"clips get":["clip id","count"],"clips add":["name"],"clips clear":[],"transport info":[],"slot info":["slot id"],"slot select":["slot id","video format"],notify:["remote","transport","slot","configuration","dropped frames"],goto:["clip id","clip","timeline","timecode","slot id"],jog:["timecode"],shuttle:["speed"],remote:["enable","override"],configuration:["video input","audio input","file format"],uptime:[],format:["prepare","confirm"],identify:["enable"],watchdog:["period"]};!function(e){e.EMPTY="empty",e.MOUNTING="mounting",e.ERROR="error",e.MOUNTED="mounted"}(S||(S={})),(x=exports.VideoFormat||(exports.VideoFormat={})).NTSC="NTSC",x.PAL="PAL",x.NTSCp="NTSCp",x.PALp="PALp",x._720p50="720p50",x._720p5994="720p5994",x._720p60="720p60",x._1080p23976="1080p23976",x._1080p24="1080p24",x._1080p25="1080p25",x._1080p2997="1080p2997",x._1080p30="1080p30",x._1080i50="1080i50",x._1080i5994="1080i5994",x._1080i60="1080i60",x._4Kp23976="4Kp23976",x._4Kp24="4Kp24",x._4Kp25="4Kp25",x._4Kp2997="4Kp2997",x._4Kp30="4Kp30",x._4Kp50="4Kp50",x._4Kp5994="4Kp5994",x._4Kp60="4Kp60",(_=exports.TransportStatus||(exports.TransportStatus={})).PREVIEW="preview",_.STOPPED="stopped",_.PLAY="play",_.FORWARD="forward",_.REWIND="rewind",_.JOG="jog",_.SHUTTLE="shuttle",_.RECORD="record",(I=exports.FileFormats||(exports.FileFormats={})).QuickTimeUncompressed="QuickTimeUncompressed",I.QuickTimeProResHQ="QuickTimeProResHQ",I.QuickTimeProRes="QuickTimeProRes",I.QuickTimeProResLT="QuickTimeProResLT",I.QuickTimeProResProxy="QuickTimeProResProxy",I.QuickTimeDNxHR220="QuickTimeDNxHR220",I.DNxHR220="DNxHR220",function(e){e.embedded="embedded",e.XLR="XLR",e.RCA="RCA"}(w||(w={})),function(e){e.SDI="SDI",e.HDMI="HDMI",e.component="component"}(R||(R={}));var k=function(){function e(e){this._linesQueue=[],this._log=e.child({source:"MultilineParser"})}var n=e.prototype;return n.receivedString=function(e){var n=[],o=e.split("\r\n");for(o.length>0&&""===o[o.length-1]&&o.pop(),this._linesQueue=this._linesQueue.concat(o);this._linesQueue.length>0;)if(""!==this._linesQueue[0])if(-1===this._linesQueue[0].indexOf(":")||1===this._linesQueue.length&&this._linesQueue[0].indexOf(":")>0){var r=this.parseResponse(this._linesQueue.splice(0,1));r&&n.push(r)}else{var t=this._linesQueue.indexOf("");if(-1===t)break;var i=this._linesQueue.splice(0,t+1),s=this.parseResponse(i);s&&n.push(s)}else this._linesQueue.shift();return n},n.parseResponse=function(e){if(1===(e=e.map((function(e){return e.trim()}))).length&&e[0].indexOf(":")>-1){var n=e[0].split(": "),o=n.shift();if(!o)throw new Error("Unrecognised command");var r={},t=new Set(T[o]),i=n.shift();if(!i)throw new Error("No named parameters found");for(var s=0;s<n.length-1;s++){for(var a=n[s].split(" "),u="",c=a.length-1;c>=0&&(u=(a.pop()+" "+u).trim(),!t.has(u));c--);if(!a.length)throw new Error("Command malformed / paramName not recognised");r[i]=a.join(" "),i=u}return r[i]=n[n.length-1],{raw:e.join("\r\n"),name:o,parameters:r}}var f=e[0].match(/(.+?)(:|)$/im);if(!f)return this._log.error({header:e[0]},"failed to parse header"),null;for(var p=f[1],d={},m=1;m<e.length;m++){var l=e[m].match(/^(.*?): (.*)$/im);l?d[l[1]]=l[2]:this._log.error({line:e[m]},"failed to parse line")}return{raw:e.join("\r\n"),name:p,parameters:d}},e}(),b=function(e){function n(n,o,r){var t;return(t=e.call(this)||this)._socket=n,t.logger=o,t._receivedCommand=r,t._lastReceived=-1,t._watchdogTimer=null,t._notifySettings={slot:!1,transport:!1,remote:!1,configuration:!1,"dropped frames":!1},t._parser=new k(t.logger),t._socket.setEncoding("utf-8"),t._socket.on("data",(function(e){t._onMessage(e)})),t._socket.on("error",(function(){o.info("error"),t._socket.destroy(),t.emit("disconnected"),o.info("disconnected")})),t.sendResponse(new v(exports.AsynchronousCode.ConnectionInfo,{"protocol version":"1.6",model:"NodeJS Hyperdeck Server Library"})),t}i(n,e);var o=n.prototype;return o._onMessage=function(e){var n=this;this.logger.debug("onMessage(%s)",e),this._lastReceived=Date.now();var o=this._parser.receivedString(e);this.logger.debug("commands:",o);for(var r,t=function(e,n){var o;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(o=function(e,n){if(e){if("string"==typeof e)return p(e,void 0);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?p(e,void 0):void 0}}(e))){o&&(e=o);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(o=e[Symbol.iterator]()).next.bind(o)}(o);!(r=t()).done;){var i=r.value;if(i.name===y.WatchdogCommand)!function(){n._watchdogTimer&&clearInterval(n._watchdogTimer);var e=i;e.parameters.period&&(n._watchdogTimer=setInterval((function(){Date.now()-n._lastReceived>Number(e.parameters.period)&&(n._socket.destroy(),n.emit("disconnected"),n._watchdogTimer&&clearInterval(n._watchdogTimer))}),1e3*Number(e.parameters.period)))}();else if(i.name===y.NotifyCommand){var s=i;if(!(Object.keys(s.parameters).length>0)){for(var a={},u=0,c=Object.keys(this._notifySettings);u<c.length;u++){var f=c[u];a[f]=this._notifySettings[f]?"true":"false"}this.sendResponse(new v(exports.SynchronousCode.Notify,a));continue}for(var d=0,m=Object.keys(s.parameters);d<m.length;d++){var l=m[d];void 0!==this._notifySettings[l]&&(this._notifySettings[l]="true"===s.parameters[l])}}this._receivedCommand(i).then((function(e){n.logger.info({res:e},"_receivedCommand response"),n.sendResponse(e)}),(function(){n.logger.error({},"_receivedCommand error response"),n.sendResponse(new v(exports.ErrorCode.Unsupported))}))}},o.sendResponse=function(e){var n=e.build();this._socket.write(n)},o.notify=function(e,n){this.logger.debug("notify:",e,n),e===exports.NotifyType.Configuration&&this._notifySettings.configuration?this.sendResponse(new v(exports.AsynchronousCode.ConfigurationInfo,n)):e===exports.NotifyType.Remote&&this._notifySettings.remote?this.sendResponse(new v(exports.AsynchronousCode.RemoteInfo,n)):e===exports.NotifyType.Slot&&this._notifySettings.slot?this.sendResponse(new v(exports.AsynchronousCode.SlotInfo,n)):e===exports.NotifyType.Transport&&this._notifySettings.transport&&this.sendResponse(new v(exports.AsynchronousCode.TransportInfo,n))},n}(n.EventEmitter),O=function(e){function n(){return e.apply(this,arguments)||this}return i(n,e),n}(f(Error)),E=function(){try{throw new O}catch(e){return Promise.reject(e)}};exports.HyperdeckServer=function(){function e(e,n){var o=this;void 0===n&&(n=t()),this._sockets={},this.onDeviceInfo=E,this.onDiskList=E,this.onPreview=E,this.onPlay=E,this.onPlayrangeSet=E,this.onPlayrangeClear=E,this.onRecord=E,this.onStop=E,this.onClipsCount=E,this.onClipsGet=E,this.onClipsAdd=E,this.onClipsClear=E,this.onTransportInfo=E,this.onSlotInfo=E,this.onSlotSelect=E,this.onGoTo=E,this.onJog=E,this.onShuttle=E,this.onRemote=E,this.onConfiguration=E,this.onUptime=E,this.onFormat=E,this.onIdentify=E,this.onWatchdog=E,this.logger=n.child({source:"HyperDeck Emulator"}),this._server=r.createServer((function(e){o.logger.debug("connection");var n=Math.random().toString(35).substr(-6);o._sockets[n]=new b(e,o.logger.child({source:"HyperDeck socket "+n}),(function(e){return o._receivedCommand(e)})),o._sockets[n].on("disconnected",(function(){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(exports.NotifyType.Slot,e)},n.notifyTransport=function(e){this._notify(exports.NotifyType.Transport,e)},n._notify=function(e,n){for(var o=0,r=Object.keys(this._sockets);o<r.length;o++)this._sockets[r[o]].notify(e,n)},n._receivedCommand=function(e){try{var n=!1,o=this;return o.logger.info({cmd:e},"_receivedCommand"),Promise.resolve(function(r,t){try{var i=function(){function r(r){var t=!1;if(n)return r;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){var t=!1;if(r)return n;function i(n){var r=!1;if(t)return n;function i(n){if(r)return n;if(e.name===y.WatchdogCommand)return new v(exports.SynchronousCode.OK);if(e.name===y.PingCommand)return new v(exports.SynchronousCode.OK);throw new Error("Unhandled command name: "+e.name)}var s=function(){if(e.name===y.IdentifyCommand)return Promise.resolve(o.onIdentify(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.FormatCommand)return Promise.resolve(o.onFormat(e)).then((function(e){return e?(t=!0,new v(exports.SynchronousCode.FormatReady,e)):(t=!0,new v(exports.SynchronousCode.OK))}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.UptimeCommand)return Promise.resolve(o.onUptime(e)).then((function(e){return r=!0,new v(exports.SynchronousCode.Uptime,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ConfigurationCommand)return Promise.resolve(o.onConfiguration(e)).then((function(e){return e?(t=!0,new v(exports.SynchronousCode.Configuration,e)):(t=!0,new v(exports.SynchronousCode.OK))}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.RemoteCommand)return Promise.resolve(o.onRemote(e)).then((function(e){return e?(r=!0,new v(exports.SynchronousCode.Remote,e)):(r=!0,new v(exports.SynchronousCode.OK))}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ShuttleCommand)return Promise.resolve(o.onShuttle(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.JogCommand)return Promise.resolve(o.onJog(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}if(e.name===y.NotifyCommand)return new v(exports.SynchronousCode.OK);var s=function(){if(e.name===y.GoToCommand)return Promise.resolve(o.onGoTo(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.SlotSelectCommand)return Promise.resolve(o.onSlotSelect(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.SlotInfoCommand)return Promise.resolve(o.onSlotInfo(e)).then((function(e){return t=!0,new v(exports.SynchronousCode.SlotInfo,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.TransportInfoCommand)return Promise.resolve(o.onTransportInfo(e)).then((function(e){return r=!0,new v(exports.SynchronousCode.TransportInfo,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ClipsClearCommand)return Promise.resolve(o.onClipsClear(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ClipsAddCommand)return Promise.resolve(o.onClipsAdd(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ClipsGetCommand)return Promise.resolve(o.onClipsGet(e)).then((function(e){return t=!0,new v(exports.SynchronousCode.ClipsInfo,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.ClipsCountCommand)return Promise.resolve(o.onClipsCount(e)).then((function(e){return r=!0,new v(exports.SynchronousCode.ClipsCount,e)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.StopCommand)return Promise.resolve(o.onStop(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.RecordCommand)return Promise.resolve(o.onRecord(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.PlayrangeClearCommand)return Promise.resolve(o.onPlayrangeClear(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.PlayrangeSetCommand)return Promise.resolve(o.onPlayrangeSet(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.PlayCommand)return Promise.resolve(o.onPlay(e)).then((function(){return t=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.PreviewCommand)return Promise.resolve(o.onPreview(e)).then((function(){return r=!0,new v(exports.SynchronousCode.OK)}))}();return s&&s.then?s.then(i):i(s)}var s=function(){if(e.name===y.DiskListCommand)return Promise.resolve(o.onDiskList(e)).then((function(e){return t=!0,new v(exports.SynchronousCode.DiskList,e)}))}();return s&&s.then?s.then(i):i(s)}var t=function(){if(e.name===y.DeviceInfoCommand)return Promise.resolve(o.onDeviceInfo(e)).then((function(e){return n=!0,new v(exports.SynchronousCode.DeviceInfo,e)}))}();return t&&t.then?t.then(r):r(t)}()}catch(e){return t(e)}return i&&i.then?i.then(void 0,t):i}(0,(function(e){return e instanceof O?new v(exports.ErrorCode.Unsupported):e&&"number"==typeof e.code&&exports.ErrorCode[e.code]&&e.msg?new g(e.code,e.msg):new v(exports.ErrorCode.InternalError)})))}catch(e){return Promise.reject(e)}},e}(),exports.ResponseInterface={__proto__:null}; | ||
//# sourceMappingURL=hyperdeck-emulator.cjs.production.min.js.map |
@@ -287,2 +287,3 @@ import { EventEmitter } from 'events'; | ||
CommandNames["NotifyCommand"] = "notify"; | ||
CommandNames["GoToCommand"] = "goto"; | ||
CommandNames["JogCommand"] = "jog"; | ||
@@ -727,2 +728,3 @@ CommandNames["ShuttleCommand"] = "shuttle"; | ||
this.onSlotSelect = noop; | ||
this.onGoTo = noop; | ||
this.onJog = noop; | ||
@@ -795,3 +797,3 @@ this.onShuttle = noop; | ||
try { | ||
var _exit23 = false; | ||
var _exit24 = false; | ||
@@ -805,105 +807,126 @@ var _this3 = this; | ||
return Promise.resolve(_catch(function () { | ||
function _temp44(_result) { | ||
function _temp46(_result) { | ||
var _exit2 = false; | ||
if (_exit23) return _result; | ||
if (_exit24) return _result; | ||
function _temp42(_result2) { | ||
function _temp44(_result2) { | ||
var _exit3 = false; | ||
if (_exit2) return _result2; | ||
function _temp40(_result3) { | ||
function _temp42(_result3) { | ||
var _exit4 = false; | ||
if (_exit3) return _result3; | ||
function _temp38(_result4) { | ||
function _temp40(_result4) { | ||
var _exit5 = false; | ||
if (_exit4) return _result4; | ||
function _temp36(_result5) { | ||
function _temp38(_result5) { | ||
var _exit6 = false; | ||
if (_exit5) return _result5; | ||
function _temp34(_result6) { | ||
function _temp36(_result6) { | ||
var _exit7 = false; | ||
if (_exit6) return _result6; | ||
function _temp32(_result7) { | ||
function _temp34(_result7) { | ||
var _exit8 = false; | ||
if (_exit7) return _result7; | ||
function _temp30(_result8) { | ||
function _temp32(_result8) { | ||
var _exit9 = false; | ||
if (_exit8) return _result8; | ||
function _temp28(_result9) { | ||
function _temp30(_result9) { | ||
var _exit10 = false; | ||
if (_exit9) return _result9; | ||
function _temp26(_result10) { | ||
function _temp28(_result10) { | ||
var _exit11 = false; | ||
if (_exit10) return _result10; | ||
function _temp24(_result11) { | ||
function _temp26(_result11) { | ||
var _exit12 = false; | ||
if (_exit11) return _result11; | ||
function _temp22(_result12) { | ||
function _temp24(_result12) { | ||
var _exit13 = false; | ||
if (_exit12) return _result12; | ||
function _temp20(_result13) { | ||
function _temp22(_result13) { | ||
var _exit14 = false; | ||
if (_exit13) return _result13; | ||
function _temp18(_result14) { | ||
function _temp20(_result14) { | ||
var _exit15 = false; | ||
if (_exit14) return _result14; | ||
function _temp16(_result15) { | ||
function _temp18(_result15) { | ||
var _exit16 = false; | ||
if (_exit15) return _result15; | ||
function _temp14(_result16) { | ||
function _temp16(_result16) { | ||
var _exit17 = false; | ||
if (_exit16) return _result16; | ||
function _temp12(_result17) { | ||
function _temp14(_result17) { | ||
var _exit18 = false; | ||
if (_exit17) return _result17; | ||
function _temp10(_result18) { | ||
function _temp12(_result18) { | ||
var _exit19 = false; | ||
if (_exit18) return _result18; | ||
function _temp8(_result19) { | ||
function _temp10(_result19) { | ||
var _exit20 = false; | ||
if (_exit19) return _result19; | ||
function _temp6(_result20) { | ||
function _temp8(_result20) { | ||
var _exit21 = false; | ||
if (_exit20) return _result20; | ||
function _temp4(_result21) { | ||
function _temp6(_result21) { | ||
var _exit22 = false; | ||
if (_exit21) return _result21; | ||
function _temp2(_result22) { | ||
function _temp4(_result22) { | ||
var _exit23 = false; | ||
if (_exit22) return _result22; | ||
if (cmd.name === CommandNames.WatchdogCommand) { | ||
// implemented in socket.ts | ||
return new TResponse(SynchronousCode.OK); | ||
} | ||
function _temp2(_result23) { | ||
if (_exit23) return _result23; | ||
if (cmd.name === CommandNames.PingCommand) { | ||
// implemented in socket.ts | ||
return new TResponse(SynchronousCode.OK); | ||
if (cmd.name === CommandNames.WatchdogCommand) { | ||
// implemented in socket.ts | ||
return new TResponse(SynchronousCode.OK); | ||
} | ||
if (cmd.name === CommandNames.PingCommand) { | ||
// implemented in socket.ts | ||
return new TResponse(SynchronousCode.OK); | ||
} | ||
throw new Error('Unhandled command name: ' + cmd.name); | ||
} | ||
throw new Error('Unhandled command name: ' + cmd.name); | ||
var _temp = function () { | ||
if (cmd.name === CommandNames.IdentifyCommand) { | ||
return Promise.resolve(_this3.onIdentify(cmd)).then(function () { | ||
_exit23 = true; | ||
return new TResponse(SynchronousCode.OK); | ||
}); | ||
} | ||
}(); | ||
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp); | ||
} | ||
var _temp = function () { | ||
if (cmd.name === CommandNames.IdentifyCommand) { | ||
return Promise.resolve(_this3.onIdentify(cmd)).then(function () { | ||
var _temp3 = function () { | ||
if (cmd.name === CommandNames.FormatCommand) { | ||
return Promise.resolve(_this3.onFormat(cmd)).then(function (res) { | ||
if (res) { | ||
_exit22 = true; | ||
return new TResponse(SynchronousCode.FormatReady, res); | ||
} | ||
_exit22 = true; | ||
@@ -915,15 +938,10 @@ return new TResponse(SynchronousCode.OK); | ||
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp); | ||
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3); | ||
} | ||
var _temp3 = function () { | ||
if (cmd.name === CommandNames.FormatCommand) { | ||
return Promise.resolve(_this3.onFormat(cmd)).then(function (res) { | ||
if (res) { | ||
_exit21 = true; | ||
return new TResponse(SynchronousCode.FormatReady, res); | ||
} | ||
var _temp5 = function () { | ||
if (cmd.name === CommandNames.UptimeCommand) { | ||
return Promise.resolve(_this3.onUptime(cmd)).then(function (res) { | ||
_exit21 = true; | ||
return new TResponse(SynchronousCode.OK); | ||
return new TResponse(SynchronousCode.Uptime, res); | ||
}); | ||
@@ -933,10 +951,15 @@ } | ||
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3); | ||
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5); | ||
} | ||
var _temp5 = function () { | ||
if (cmd.name === CommandNames.UptimeCommand) { | ||
return Promise.resolve(_this3.onUptime(cmd)).then(function (res) { | ||
var _temp7 = function () { | ||
if (cmd.name === CommandNames.ConfigurationCommand) { | ||
return Promise.resolve(_this3.onConfiguration(cmd)).then(function (res) { | ||
if (res) { | ||
_exit20 = true; | ||
return new TResponse(SynchronousCode.Configuration, res); | ||
} | ||
_exit20 = true; | ||
return new TResponse(SynchronousCode.Uptime, res); | ||
return new TResponse(SynchronousCode.OK); | ||
}); | ||
@@ -946,15 +969,15 @@ } | ||
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5); | ||
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7); | ||
} | ||
var _temp7 = function () { | ||
if (cmd.name === CommandNames.ConfigurationCommand) { | ||
return Promise.resolve(_this3.onConfiguration(cmd)).then(function (res) { | ||
if (res) { | ||
var _temp9 = function () { | ||
if (cmd.name === CommandNames.RemoteCommand) { | ||
return Promise.resolve(_this3.onRemote(cmd)).then(function (res) { | ||
if (!res) { | ||
_exit19 = true; | ||
return new TResponse(SynchronousCode.Configuration, res); | ||
return new TResponse(SynchronousCode.OK); | ||
} | ||
_exit19 = true; | ||
return new TResponse(SynchronousCode.OK); | ||
return new TResponse(SynchronousCode.Remote, res); | ||
}); | ||
@@ -964,15 +987,10 @@ } | ||
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7); | ||
return _temp9 && _temp9.then ? _temp9.then(_temp10) : _temp10(_temp9); | ||
} | ||
var _temp9 = function () { | ||
if (cmd.name === CommandNames.RemoteCommand) { | ||
return Promise.resolve(_this3.onRemote(cmd)).then(function (res) { | ||
if (!res) { | ||
_exit18 = true; | ||
return new TResponse(SynchronousCode.OK); | ||
} | ||
var _temp11 = function () { | ||
if (cmd.name === CommandNames.ShuttleCommand) { | ||
return Promise.resolve(_this3.onShuttle(cmd)).then(function () { | ||
_exit18 = true; | ||
return new TResponse(SynchronousCode.Remote, res); | ||
return new TResponse(SynchronousCode.OK); | ||
}); | ||
@@ -982,8 +1000,8 @@ } | ||
return _temp9 && _temp9.then ? _temp9.then(_temp10) : _temp10(_temp9); | ||
return _temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11); | ||
} | ||
var _temp11 = function () { | ||
if (cmd.name === CommandNames.ShuttleCommand) { | ||
return Promise.resolve(_this3.onShuttle(cmd)).then(function () { | ||
var _temp13 = function () { | ||
if (cmd.name === CommandNames.JogCommand) { | ||
return Promise.resolve(_this3.onJog(cmd)).then(function () { | ||
_exit17 = true; | ||
@@ -995,3 +1013,3 @@ return new TResponse(SynchronousCode.OK); | ||
return _temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11); | ||
return _temp13 && _temp13.then ? _temp13.then(_temp14) : _temp14(_temp13); | ||
} | ||
@@ -1004,5 +1022,5 @@ | ||
var _temp13 = function () { | ||
if (cmd.name === CommandNames.JogCommand) { | ||
return Promise.resolve(_this3.onJog(cmd)).then(function () { | ||
var _temp15 = function () { | ||
if (cmd.name === CommandNames.GoToCommand) { | ||
return Promise.resolve(_this3.onGoTo(cmd)).then(function () { | ||
_exit16 = true; | ||
@@ -1014,6 +1032,6 @@ return new TResponse(SynchronousCode.OK); | ||
return _temp13 && _temp13.then ? _temp13.then(_temp14) : _temp14(_temp13); | ||
return _temp15 && _temp15.then ? _temp15.then(_temp16) : _temp16(_temp15); | ||
} | ||
var _temp15 = function () { | ||
var _temp17 = function () { | ||
if (cmd.name === CommandNames.SlotSelectCommand) { | ||
@@ -1027,6 +1045,6 @@ return Promise.resolve(_this3.onSlotSelect(cmd)).then(function () { | ||
return _temp15 && _temp15.then ? _temp15.then(_temp16) : _temp16(_temp15); | ||
return _temp17 && _temp17.then ? _temp17.then(_temp18) : _temp18(_temp17); | ||
} | ||
var _temp17 = function () { | ||
var _temp19 = function () { | ||
if (cmd.name === CommandNames.SlotInfoCommand) { | ||
@@ -1040,6 +1058,6 @@ return Promise.resolve(_this3.onSlotInfo(cmd)).then(function (res) { | ||
return _temp17 && _temp17.then ? _temp17.then(_temp18) : _temp18(_temp17); | ||
return _temp19 && _temp19.then ? _temp19.then(_temp20) : _temp20(_temp19); | ||
} | ||
var _temp19 = function () { | ||
var _temp21 = function () { | ||
if (cmd.name === CommandNames.TransportInfoCommand) { | ||
@@ -1053,6 +1071,6 @@ return Promise.resolve(_this3.onTransportInfo(cmd)).then(function (res) { | ||
return _temp19 && _temp19.then ? _temp19.then(_temp20) : _temp20(_temp19); | ||
return _temp21 && _temp21.then ? _temp21.then(_temp22) : _temp22(_temp21); | ||
} | ||
var _temp21 = function () { | ||
var _temp23 = function () { | ||
if (cmd.name === CommandNames.ClipsClearCommand) { | ||
@@ -1066,6 +1084,6 @@ return Promise.resolve(_this3.onClipsClear(cmd)).then(function () { | ||
return _temp21 && _temp21.then ? _temp21.then(_temp22) : _temp22(_temp21); | ||
return _temp23 && _temp23.then ? _temp23.then(_temp24) : _temp24(_temp23); | ||
} | ||
var _temp23 = function () { | ||
var _temp25 = function () { | ||
if (cmd.name === CommandNames.ClipsAddCommand) { | ||
@@ -1079,6 +1097,6 @@ return Promise.resolve(_this3.onClipsAdd(cmd)).then(function () { | ||
return _temp23 && _temp23.then ? _temp23.then(_temp24) : _temp24(_temp23); | ||
return _temp25 && _temp25.then ? _temp25.then(_temp26) : _temp26(_temp25); | ||
} | ||
var _temp25 = function () { | ||
var _temp27 = function () { | ||
if (cmd.name === CommandNames.ClipsGetCommand) { | ||
@@ -1092,6 +1110,6 @@ return Promise.resolve(_this3.onClipsGet(cmd)).then(function (res) { | ||
return _temp25 && _temp25.then ? _temp25.then(_temp26) : _temp26(_temp25); | ||
return _temp27 && _temp27.then ? _temp27.then(_temp28) : _temp28(_temp27); | ||
} | ||
var _temp27 = function () { | ||
var _temp29 = function () { | ||
if (cmd.name === CommandNames.ClipsCountCommand) { | ||
@@ -1105,6 +1123,6 @@ return Promise.resolve(_this3.onClipsCount(cmd)).then(function (res) { | ||
return _temp27 && _temp27.then ? _temp27.then(_temp28) : _temp28(_temp27); | ||
return _temp29 && _temp29.then ? _temp29.then(_temp30) : _temp30(_temp29); | ||
} | ||
var _temp29 = function () { | ||
var _temp31 = function () { | ||
if (cmd.name === CommandNames.StopCommand) { | ||
@@ -1118,6 +1136,6 @@ return Promise.resolve(_this3.onStop(cmd)).then(function () { | ||
return _temp29 && _temp29.then ? _temp29.then(_temp30) : _temp30(_temp29); | ||
return _temp31 && _temp31.then ? _temp31.then(_temp32) : _temp32(_temp31); | ||
} | ||
var _temp31 = function () { | ||
var _temp33 = function () { | ||
if (cmd.name === CommandNames.RecordCommand) { | ||
@@ -1131,6 +1149,6 @@ return Promise.resolve(_this3.onRecord(cmd)).then(function () { | ||
return _temp31 && _temp31.then ? _temp31.then(_temp32) : _temp32(_temp31); | ||
return _temp33 && _temp33.then ? _temp33.then(_temp34) : _temp34(_temp33); | ||
} | ||
var _temp33 = function () { | ||
var _temp35 = function () { | ||
if (cmd.name === CommandNames.PlayrangeClearCommand) { | ||
@@ -1144,6 +1162,6 @@ return Promise.resolve(_this3.onPlayrangeClear(cmd)).then(function () { | ||
return _temp33 && _temp33.then ? _temp33.then(_temp34) : _temp34(_temp33); | ||
return _temp35 && _temp35.then ? _temp35.then(_temp36) : _temp36(_temp35); | ||
} | ||
var _temp35 = function () { | ||
var _temp37 = function () { | ||
if (cmd.name === CommandNames.PlayrangeSetCommand) { | ||
@@ -1157,6 +1175,6 @@ return Promise.resolve(_this3.onPlayrangeSet(cmd)).then(function () { | ||
return _temp35 && _temp35.then ? _temp35.then(_temp36) : _temp36(_temp35); | ||
return _temp37 && _temp37.then ? _temp37.then(_temp38) : _temp38(_temp37); | ||
} | ||
var _temp37 = function () { | ||
var _temp39 = function () { | ||
if (cmd.name === CommandNames.PlayCommand) { | ||
@@ -1170,6 +1188,6 @@ return Promise.resolve(_this3.onPlay(cmd)).then(function () { | ||
return _temp37 && _temp37.then ? _temp37.then(_temp38) : _temp38(_temp37); | ||
return _temp39 && _temp39.then ? _temp39.then(_temp40) : _temp40(_temp39); | ||
} | ||
var _temp39 = function () { | ||
var _temp41 = function () { | ||
if (cmd.name === CommandNames.PreviewCommand) { | ||
@@ -1183,6 +1201,6 @@ return Promise.resolve(_this3.onPreview(cmd)).then(function () { | ||
return _temp39 && _temp39.then ? _temp39.then(_temp40) : _temp40(_temp39); | ||
return _temp41 && _temp41.then ? _temp41.then(_temp42) : _temp42(_temp41); | ||
} | ||
var _temp41 = function () { | ||
var _temp43 = function () { | ||
if (cmd.name === CommandNames.DiskListCommand) { | ||
@@ -1196,9 +1214,9 @@ return Promise.resolve(_this3.onDiskList(cmd)).then(function (res) { | ||
return _temp41 && _temp41.then ? _temp41.then(_temp42) : _temp42(_temp41); | ||
return _temp43 && _temp43.then ? _temp43.then(_temp44) : _temp44(_temp43); | ||
} | ||
var _temp43 = function () { | ||
var _temp45 = function () { | ||
if (cmd.name === CommandNames.DeviceInfoCommand) { | ||
return Promise.resolve(_this3.onDeviceInfo(cmd)).then(function (res) { | ||
_exit23 = true; | ||
_exit24 = true; | ||
return new TResponse(SynchronousCode.DeviceInfo, res); | ||
@@ -1209,3 +1227,3 @@ }); | ||
return _temp43 && _temp43.then ? _temp43.then(_temp44) : _temp44(_temp43); | ||
return _temp45 && _temp45.then ? _temp45.then(_temp46) : _temp46(_temp45); | ||
}, function (err) { | ||
@@ -1212,0 +1230,0 @@ if (err instanceof UnimplementedError) { |
@@ -23,2 +23,3 @@ import { DeserializedCommand, DeserializedCommands, Hash, ResponseInterface } from './types'; | ||
onSlotSelect: Handler<DeserializedCommands.SlotSelectCommand, void>; | ||
onGoTo: Handler<DeserializedCommands.GoToCommand, void>; | ||
onJog: Handler<DeserializedCommands.JogCommand, void>; | ||
@@ -25,0 +26,0 @@ onShuttle: Handler<DeserializedCommands.ShuttleCommand, void>; |
@@ -104,2 +104,3 @@ import * as DeserializedCommands from './types/DeserializedCommands'; | ||
NotifyCommand = "notify", | ||
GoToCommand = "goto", | ||
JogCommand = "jog", | ||
@@ -106,0 +107,0 @@ ShuttleCommand = "shuttle", |
@@ -57,2 +57,11 @@ import { DeserializedCommand } from '../types'; | ||
} | ||
export interface GoToCommand extends DeserializedCommand { | ||
parameters: { | ||
'clip id'?: string; | ||
clip?: string; | ||
timeline?: string; | ||
timecode?: string; | ||
'slot id'?: string; | ||
}; | ||
} | ||
export interface JogCommand extends DeserializedCommand { | ||
@@ -59,0 +68,0 @@ parameters: { |
{ | ||
"name": "@meyer/hyperdeck-emulator", | ||
"version": "0.0.4-canary.14.326f2c9", | ||
"version": "0.0.4-canary.24.60511e7", | ||
"description": "Typescript Node.js library for emulating a Blackmagic Hyperdeck", | ||
@@ -40,3 +40,6 @@ "main": "dist/index.js", | ||
"message": "chore(release): %s [skip ci]", | ||
"tagPrefix": "" | ||
"tagPrefix": "", | ||
"scripts": { | ||
"postchangelog": "prettier --write CHANGELOG.md" | ||
} | ||
}, | ||
@@ -57,3 +60,3 @@ "scripts": { | ||
"changelog": "standard-version", | ||
"release": "yarn reset && yarn test && yarn changelog", | ||
"release": "yarn reset && yarn lint && yarn changelog", | ||
"reset": "git clean -dfx && git reset --hard && yarn", | ||
@@ -60,0 +63,0 @@ "validate:dependencies": "yarn audit && yarn license-validate", |
@@ -46,2 +46,3 @@ import { HyperdeckSocket } from './socket' | ||
onSlotSelect: Handler<DeserializedCommands.SlotSelectCommand, void> = noop | ||
onGoTo: Handler<DeserializedCommands.GoToCommand, void> = noop | ||
onJog: Handler<DeserializedCommands.JogCommand, void> = noop | ||
@@ -183,2 +184,7 @@ onShuttle: Handler<DeserializedCommands.ShuttleCommand, void> = noop | ||
if (cmd.name === CommandNames.GoToCommand) { | ||
await this.onGoTo(cmd) | ||
return new TResponse(SynchronousCode.OK) | ||
} | ||
if (cmd.name === CommandNames.JogCommand) { | ||
@@ -185,0 +191,0 @@ await this.onJog(cmd) |
@@ -135,2 +135,3 @@ import * as util from 'util' | ||
NotifyCommand = 'notify', | ||
GoToCommand = 'goto', | ||
JogCommand = 'jog', | ||
@@ -137,0 +138,0 @@ ShuttleCommand = 'shuttle', |
@@ -67,2 +67,12 @@ import { DeserializedCommand } from '../types' | ||
export interface GoToCommand extends DeserializedCommand { | ||
parameters: { | ||
'clip id'?: string | ||
clip?: string | ||
timeline?: string | ||
timecode?: string | ||
'slot id'?: string | ||
} | ||
} | ||
export interface JogCommand extends DeserializedCommand { | ||
@@ -69,0 +79,0 @@ parameters: { |
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
388756
3431